gdcore-tools 2.0.0-gd-v5.4.217-autobuild → 2.0.0-gd-v5.4.219-autobuild
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Runtime/Extensions/3D/CustomRuntimeObject3D.js +1 -1
- package/dist/Runtime/Extensions/3D/CustomRuntimeObject3D.js.map +2 -2
- package/dist/Runtime/Extensions/3D/JsExtension.js +7 -3
- package/dist/Runtime/Extensions/AnchorBehavior/anchorruntimebehavior.js +1 -1
- package/dist/Runtime/Extensions/AnchorBehavior/anchorruntimebehavior.js.map +2 -2
- package/dist/Runtime/Extensions/DialogueTree/JsExtension.js +44 -32
- package/dist/Runtime/Extensions/DialogueTree/dialoguetools.js +2 -2
- package/dist/Runtime/Extensions/DialogueTree/dialoguetools.js.map +2 -2
- package/dist/Runtime/Extensions/Multiplayer/JsExtension.js +15 -0
- package/dist/Runtime/Extensions/Multiplayer/messageManager.js +1 -1
- package/dist/Runtime/Extensions/Multiplayer/messageManager.js.map +2 -2
- package/dist/Runtime/Extensions/Multiplayer/multiplayerobjectruntimebehavior.js +1 -1
- package/dist/Runtime/Extensions/Multiplayer/multiplayerobjectruntimebehavior.js.map +2 -2
- package/dist/Runtime/Extensions/Physics2Behavior/physics2runtimebehavior.js +1 -1
- package/dist/Runtime/Extensions/Physics2Behavior/physics2runtimebehavior.js.map +2 -2
- package/dist/Runtime/Extensions/Spine/managers/pixi-spine-atlas-manager.js +1 -1
- package/dist/Runtime/Extensions/Spine/managers/pixi-spine-atlas-manager.js.map +2 -2
- package/dist/Runtime/Extensions/Spine/managers/pixi-spine-manager.js +1 -1
- package/dist/Runtime/Extensions/Spine/managers/pixi-spine-manager.js.map +2 -2
- package/dist/Runtime/Extensions/TileMap/simpletilemapruntimeobject.js +1 -1
- package/dist/Runtime/Extensions/TileMap/simpletilemapruntimeobject.js.map +2 -2
- package/dist/Runtime/Model3DManager.js +1 -1
- package/dist/Runtime/Model3DManager.js.map +2 -2
- package/dist/Runtime/ResourceLoader.js +1 -1
- package/dist/Runtime/ResourceLoader.js.map +2 -2
- package/dist/Runtime/RuntimeLayer.js +1 -1
- package/dist/Runtime/RuntimeLayer.js.map +2 -2
- package/dist/Runtime/capturemanager.js +2 -0
- package/dist/Runtime/capturemanager.js.map +7 -0
- package/dist/Runtime/fontfaceobserver-font-manager/fontfaceobserver-font-manager.js +1 -1
- package/dist/Runtime/fontfaceobserver-font-manager/fontfaceobserver-font-manager.js.map +2 -2
- package/dist/Runtime/howler-sound-manager/howler-sound-manager.js +1 -1
- package/dist/Runtime/howler-sound-manager/howler-sound-manager.js.map +2 -2
- package/dist/Runtime/jsonmanager.js +1 -1
- package/dist/Runtime/jsonmanager.js.map +2 -2
- package/dist/Runtime/layer.js +1 -1
- package/dist/Runtime/layer.js.map +2 -2
- package/dist/Runtime/pixi-renderers/pixi-bitmapfont-manager.js +1 -1
- package/dist/Runtime/pixi-renderers/pixi-bitmapfont-manager.js.map +2 -2
- package/dist/Runtime/pixi-renderers/pixi-image-manager.js +1 -1
- package/dist/Runtime/pixi-renderers/pixi-image-manager.js.map +2 -2
- package/dist/Runtime/pixi-renderers/runtimegame-pixi-renderer.js +1 -1
- package/dist/Runtime/pixi-renderers/runtimegame-pixi-renderer.js.map +2 -2
- package/dist/Runtime/runtimegame.js +1 -1
- package/dist/Runtime/runtimegame.js.map +2 -2
- package/dist/Runtime/runtimewatermark.js +2 -2
- package/dist/Runtime/runtimewatermark.js.map +2 -2
- package/dist/Runtime/scenestack.js +1 -1
- package/dist/Runtime/scenestack.js.map +2 -2
- package/dist/Runtime/spriteruntimeobject.js +1 -1
- package/dist/Runtime/spriteruntimeobject.js.map +2 -2
- package/dist/Runtime/types/global-types.d.ts +20 -3
- package/dist/Runtime/types/project-data.d.ts +1 -1
- package/dist/lib/libGD.cjs +1 -1
- package/dist/lib/libGD.wasm +0 -0
- package/gd.d.ts +35 -7
- package/package.json +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var gdjs;(function(
|
|
1
|
+
var gdjs;(function(u){const c=["atlas"];class g{constructor(e,s){this._loadedSpineAtlases=new u.ResourceCache;this._loadingSpineAtlases=new u.ResourceCache;this._resourceLoader=e,this._imageManager=s}getResourceKinds(){return c}async processResource(e){}async loadResource(e){await this.getOrLoad(e)}getOrLoad(e){const s=this._getAtlasResource(e);if(!s)return Promise.reject(`Unable to find atlas for resource '${e}'.`);let t=this._loadingSpineAtlases.get(s);return t||(t=new Promise((n,a)=>{const o=(i,r)=>{if(i)return a(`Error while preloading a spine atlas resource: ${i}`);if(!r)return a(`Cannot reach texture atlas for resource '${e}'.`);n(r)};this.load(s,o)}),this._loadingSpineAtlases.set(s,t)),t}load(e,s){const t=this._resourceLoader.getRuntimeGame(),n=t.getEmbeddedResourcesNames(e.name);if(!n.length)return s(new Error(`${e.name} do not have image metadata!`));const a=n.reduce((r,l)=>{const d=t.resolveEmbeddedResource(e.name,l);return r[l]=this._imageManager.getOrLoadPIXITexture(d),r},{}),o=r=>{this._loadedSpineAtlases.set(e,r),s(null,r)},i=this._resourceLoader.getFullUrl(e.file);PIXI.Assets.setPreferences({preferWorkers:!1,crossOrigin:this._resourceLoader.checkIfCredentialsRequired(i)?"use-credentials":"anonymous"}),PIXI.Assets.add(e.name,i,{images:a}),PIXI.Assets.load(e.name).then(r=>{typeof r=="string"?new pixi_spine.TextureAtlas(r,(l,d)=>d(a[l].baseTexture),o):o(r)})}isLoaded(e){return!!this._loadedSpineAtlases.getFromName(e)}getAtlasTexture(e){return this._loadedSpineAtlases.getFromName(e)}_getAtlasResource(e){const s=this._resourceLoader.getResource(e);return s&&this.getResourceKinds().includes(s.kind)?s:null}dispose(){this._loadedSpineAtlases.clear(),this._loadingSpineAtlases.clear()}}u.SpineAtlasManager=g})(gdjs||(gdjs={}));
|
|
2
2
|
//# sourceMappingURL=pixi-spine-atlas-manager.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../GDevelop/Extensions/Spine/managers/pixi-spine-atlas-manager.ts"],
|
|
4
|
-
"sourcesContent": ["/*\n * GDevelop JS Platform\n * Copyright 2013-present Florian Rival (Florian.Rival@gmail.com). All rights reserved.\n * This project is released under the MIT License.\n */\nnamespace gdjs {\n /** The callback called when a text that was requested is loaded (or an error occurred). */\n export type SpineAtlasManagerRequestCallback = (\n error: Error | null,\n content?: pixi_spine.TextureAtlas\n ) => void;\n\n const atlasKinds: ResourceKind[] = ['atlas'];\n\n /**\n * AtlasManager loads atlas files with pixi loader, using the \"atlas\" resources\n * registered in the game resources and process them to Pixi TextureAtlas.\n *\n * Contrary to audio/fonts, text files are loaded asynchronously, when requested.\n * You should properly handle errors, and give the developer/player a way to know\n * that loading failed.\n */\n export class SpineAtlasManager implements gdjs.ResourceManager {\n private _imageManager: ImageManager;\n private _resourceLoader: ResourceLoader;\n private _loadedSpineAtlases = new gdjs.ResourceCache<\n pixi_spine.TextureAtlas\n >();\n private _loadingSpineAtlases = new gdjs.ResourceCache<\n Promise<pixi_spine.TextureAtlas>\n >();\n\n /**\n * @param resources The resources data of the game.\n * @param resourcesLoader The resources loader of the game.\n */\n constructor(\n resourceLoader: gdjs.ResourceLoader,\n imageManager: ImageManager\n ) {\n this._resourceLoader = resourceLoader;\n this._imageManager = imageManager;\n }\n\n getResourceKinds(): ResourceKind[] {\n return atlasKinds;\n }\n\n async processResource(resourceName: string): Promise<void> {\n // Do nothing because pixi-spine parses resources by itself.\n }\n\n async loadResource(resourceName: string): Promise<void> {\n await this.getOrLoad(resourceName);\n }\n\n /**\n * Returns promisified loaded atlas resource if it is availble, loads it otherwise.\n *\n * @param resources The data of resource to load.\n */\n getOrLoad(resourceName: string): Promise<pixi_spine.TextureAtlas> {\n const resource = this._getAtlasResource(resourceName);\n\n if (!resource) {\n return Promise.reject(\n `Unable to find atlas for resource '${resourceName}'.`\n );\n }\n\n let loadingPromise = this._loadingSpineAtlases.get(resource);\n\n if (!loadingPromise) {\n loadingPromise = new Promise<pixi_spine.TextureAtlas>(\n (resolve, reject) => {\n const onLoad: SpineAtlasManagerRequestCallback = (\n error,\n content\n ) => {\n if (error) {\n return reject(\n `Error while preloading a spine atlas resource: ${error}`\n );\n }\n if (!content) {\n return reject(\n `Cannot reach texture atlas for resource '${resourceName}'.`\n );\n }\n\n resolve(content);\n };\n\n this.load(resource, onLoad);\n }\n );\n\n this._loadingSpineAtlases.set(resource, loadingPromise);\n }\n\n return loadingPromise;\n }\n\n /**\n * Load specified atlas resource and pass it to callback once it is loaded.\n *\n * @param resources The data of resource to load.\n * @param callback The callback to pass atlas to it once it is loaded.\n */\n load(\n resource: ResourceData,\n callback: SpineAtlasManagerRequestCallback\n ): void {\n const game = this._resourceLoader.getRuntimeGame();\n const embeddedResourcesNames = game.getEmbeddedResourcesNames(\n resource.name\n );\n\n if (!embeddedResourcesNames.length)\n return callback(\n new Error(`${resource.name} do not have image metadata!`)\n );\n\n const images = embeddedResourcesNames.reduce<{\n [key: string]: PIXI.Texture;\n }>((imagesMap, embeddedResourceName) => {\n const mappedResourceName = game.resolveEmbeddedResource(\n resource.name,\n embeddedResourceName\n );\n imagesMap[\n embeddedResourceName\n ] = this._imageManager.getOrLoadPIXITexture(mappedResourceName);\n\n return imagesMap;\n }, {});\n const onLoad = (atlas: pixi_spine.TextureAtlas) => {\n this._loadedSpineAtlases.set(resource, atlas);\n callback(null, atlas);\n };\n const url = this._resourceLoader.getFullUrl(resource.file);\n\n PIXI.Assets.setPreferences({\n preferWorkers: false,\n crossOrigin: this._resourceLoader.checkIfCredentialsRequired(url)\n ? 'use-credentials'\n : 'anonymous',\n });\n PIXI.Assets.add(resource.name, url, { images });\n PIXI.Assets.load<pixi_spine.TextureAtlas | string>(resource.name).then(\n (atlas) => {\n /**\n * Ideally atlas of TextureAtlas should be passed here\n * but there is known issue in case of preloaded images (see https://github.com/pixijs/spine/issues/537)\n *\n * Here covered all possible ways to make it work fine if issue is fixed in pixi-spine or after migration to spine-pixi\n */\n if (typeof atlas === 'string') {\n new pixi_spine.TextureAtlas(\n atlas,\n (textureName, textureCb) =>\n textureCb(images[textureName].baseTexture),\n onLoad\n );\n } else {\n onLoad(atlas);\n }\n }\n );\n }\n\n /**\n * Check if the given atlas resource was loaded (preloaded or loaded with `load`).\n * @param resourceName The name of the atlas resource.\n * @returns true if the content of the atlas resource is loaded, false otherwise.\n */\n isLoaded(resourceName: string): boolean {\n return !!this._loadedSpineAtlases.getFromName(resourceName);\n }\n\n /**\n * Get the Pixi TextureAtlas for the given resource that is already loaded (preloaded or loaded with `load`).\n * If the resource is not loaded, `null` will be returned.\n * @param resourceName The name of the atlas resource.\n * @returns the TextureAtlas of the atlas if loaded, `null` otherwise.\n */\n getAtlasTexture(resourceName: string): pixi_spine.TextureAtlas | null {\n return this._loadedSpineAtlases.getFromName(resourceName);\n }\n\n private _getAtlasResource(resourceName: string): ResourceData | null {\n const resource = this._resourceLoader.getResource(resourceName);\n return resource && this.getResourceKinds().includes(resource.kind)\n ? resource\n : null;\n }\n }\n}\n"],
|
|
5
|
-
"mappings": "AAKA,GAAU,MAAV,UAAU,EAAV,CAOE,KAAM,GAA6B,CAAC,SAU7B,OAAwD,CAc7D,YACE,EACA,EACA,CAdM,yBAAsB,GAAI,GAAK,cAG/B,0BAAuB,GAAI,GAAK,cAYtC,KAAK,gBAAkB,EACvB,KAAK,cAAgB,EAGvB,kBAAmC,CACjC,MAAO,QAGH,iBAAgB,EAAqC,OAIrD,cAAa,EAAqC,CACtD,KAAM,MAAK,UAAU,GAQvB,UAAU,EAAwD,CAChE,KAAM,GAAW,KAAK,kBAAkB,GAExC,GAAI,CAAC,EACH,MAAO,SAAQ,OACb,sCAAsC,OAI1C,GAAI,GAAiB,KAAK,qBAAqB,IAAI,GAEnD,MAAK,IACH,GAAiB,GAAI,SACnB,CAAC,EAAS,IAAW,CACnB,KAAM,GAA2C,CAC/C,EACA,IACG,CACH,GAAI,EACF,MAAO,GACL,kDAAkD,KAGtD,GAAI,CAAC,EACH,MAAO,GACL,4CAA4C,OAIhD,EAAQ,IAGV,KAAK,KAAK,EAAU,KAIxB,KAAK,qBAAqB,IAAI,EAAU,IAGnC,EAST,KACE,EACA,EACM,CACN,KAAM,GAAO,KAAK,gBAAgB,iBAC5B,EAAyB,EAAK,0BAClC,EAAS,MAGX,GAAI,CAAC,EAAuB,OAC1B,MAAO,GACL,GAAI,OAAM,GAAG,EAAS,qCAG1B,KAAM,GAAS,EAAuB,OAEnC,CAAC,EAAW,IAAyB,CACtC,KAAM,GAAqB,EAAK,wBAC9B,EAAS,KACT,GAEF,SACE,GACE,KAAK,cAAc,qBAAqB,GAErC,GACN,IACG,EAAS,AAAC,GAAmC,CACjD,KAAK,oBAAoB,IAAI,EAAU,GACvC,EAAS,KAAM,IAEX,EAAM,KAAK,gBAAgB,WAAW,EAAS,MAErD,KAAK,OAAO,eAAe,CACzB,cAAe,GACf,YAAa,KAAK,gBAAgB,2BAA2B,GACzD,kBACA,cAEN,KAAK,OAAO,IAAI,EAAS,KAAM,EAAK,CAAE,WACtC,KAAK,OAAO,KAAuC,EAAS,MAAM,KAChE,AAAC,GAAU,CAOT,AAAI,MAAO,IAAU,SACnB,GAAI,YAAW,aACb,EACA,CAAC,EAAa,IACZ,EAAU,EAAO,GAAa,aAChC,GAGF,EAAO,KAWf,SAAS,EAA+B,CACtC,MAAO,CAAC,CAAC,KAAK,oBAAoB,YAAY,GAShD,gBAAgB,EAAsD,CACpE,MAAO,MAAK,oBAAoB,YAAY,GAGtC,kBAAkB,EAA2C,CACnE,KAAM,GAAW,KAAK,gBAAgB,YAAY,GAClD,MAAO,IAAY,KAAK,mBAAmB,SAAS,EAAS,MACzD,EACA,
|
|
4
|
+
"sourcesContent": ["/*\n * GDevelop JS Platform\n * Copyright 2013-present Florian Rival (Florian.Rival@gmail.com). All rights reserved.\n * This project is released under the MIT License.\n */\nnamespace gdjs {\n /** The callback called when a text that was requested is loaded (or an error occurred). */\n export type SpineAtlasManagerRequestCallback = (\n error: Error | null,\n content?: pixi_spine.TextureAtlas\n ) => void;\n\n const atlasKinds: ResourceKind[] = ['atlas'];\n\n /**\n * AtlasManager loads atlas files with pixi loader, using the \"atlas\" resources\n * registered in the game resources and process them to Pixi TextureAtlas.\n *\n * Contrary to audio/fonts, text files are loaded asynchronously, when requested.\n * You should properly handle errors, and give the developer/player a way to know\n * that loading failed.\n */\n export class SpineAtlasManager implements gdjs.ResourceManager {\n private _imageManager: ImageManager;\n private _resourceLoader: ResourceLoader;\n private _loadedSpineAtlases = new gdjs.ResourceCache<\n pixi_spine.TextureAtlas\n >();\n private _loadingSpineAtlases = new gdjs.ResourceCache<\n Promise<pixi_spine.TextureAtlas>\n >();\n\n /**\n * @param resources The resources data of the game.\n * @param resourcesLoader The resources loader of the game.\n */\n constructor(\n resourceLoader: gdjs.ResourceLoader,\n imageManager: ImageManager\n ) {\n this._resourceLoader = resourceLoader;\n this._imageManager = imageManager;\n }\n\n getResourceKinds(): ResourceKind[] {\n return atlasKinds;\n }\n\n async processResource(resourceName: string): Promise<void> {\n // Do nothing because pixi-spine parses resources by itself.\n }\n\n async loadResource(resourceName: string): Promise<void> {\n await this.getOrLoad(resourceName);\n }\n\n /**\n * Returns promisified loaded atlas resource if it is availble, loads it otherwise.\n *\n * @param resources The data of resource to load.\n */\n getOrLoad(resourceName: string): Promise<pixi_spine.TextureAtlas> {\n const resource = this._getAtlasResource(resourceName);\n\n if (!resource) {\n return Promise.reject(\n `Unable to find atlas for resource '${resourceName}'.`\n );\n }\n\n let loadingPromise = this._loadingSpineAtlases.get(resource);\n\n if (!loadingPromise) {\n loadingPromise = new Promise<pixi_spine.TextureAtlas>(\n (resolve, reject) => {\n const onLoad: SpineAtlasManagerRequestCallback = (\n error,\n content\n ) => {\n if (error) {\n return reject(\n `Error while preloading a spine atlas resource: ${error}`\n );\n }\n if (!content) {\n return reject(\n `Cannot reach texture atlas for resource '${resourceName}'.`\n );\n }\n\n resolve(content);\n };\n\n this.load(resource, onLoad);\n }\n );\n\n this._loadingSpineAtlases.set(resource, loadingPromise);\n }\n\n return loadingPromise;\n }\n\n /**\n * Load specified atlas resource and pass it to callback once it is loaded.\n *\n * @param resources The data of resource to load.\n * @param callback The callback to pass atlas to it once it is loaded.\n */\n load(\n resource: ResourceData,\n callback: SpineAtlasManagerRequestCallback\n ): void {\n const game = this._resourceLoader.getRuntimeGame();\n const embeddedResourcesNames = game.getEmbeddedResourcesNames(\n resource.name\n );\n\n if (!embeddedResourcesNames.length)\n return callback(\n new Error(`${resource.name} do not have image metadata!`)\n );\n\n const images = embeddedResourcesNames.reduce<{\n [key: string]: PIXI.Texture;\n }>((imagesMap, embeddedResourceName) => {\n const mappedResourceName = game.resolveEmbeddedResource(\n resource.name,\n embeddedResourceName\n );\n imagesMap[\n embeddedResourceName\n ] = this._imageManager.getOrLoadPIXITexture(mappedResourceName);\n\n return imagesMap;\n }, {});\n const onLoad = (atlas: pixi_spine.TextureAtlas) => {\n this._loadedSpineAtlases.set(resource, atlas);\n callback(null, atlas);\n };\n const url = this._resourceLoader.getFullUrl(resource.file);\n\n PIXI.Assets.setPreferences({\n preferWorkers: false,\n crossOrigin: this._resourceLoader.checkIfCredentialsRequired(url)\n ? 'use-credentials'\n : 'anonymous',\n });\n PIXI.Assets.add(resource.name, url, { images });\n PIXI.Assets.load<pixi_spine.TextureAtlas | string>(resource.name).then(\n (atlas) => {\n /**\n * Ideally atlas of TextureAtlas should be passed here\n * but there is known issue in case of preloaded images (see https://github.com/pixijs/spine/issues/537)\n *\n * Here covered all possible ways to make it work fine if issue is fixed in pixi-spine or after migration to spine-pixi\n */\n if (typeof atlas === 'string') {\n new pixi_spine.TextureAtlas(\n atlas,\n (textureName, textureCb) =>\n textureCb(images[textureName].baseTexture),\n onLoad\n );\n } else {\n onLoad(atlas);\n }\n }\n );\n }\n\n /**\n * Check if the given atlas resource was loaded (preloaded or loaded with `load`).\n * @param resourceName The name of the atlas resource.\n * @returns true if the content of the atlas resource is loaded, false otherwise.\n */\n isLoaded(resourceName: string): boolean {\n return !!this._loadedSpineAtlases.getFromName(resourceName);\n }\n\n /**\n * Get the Pixi TextureAtlas for the given resource that is already loaded (preloaded or loaded with `load`).\n * If the resource is not loaded, `null` will be returned.\n * @param resourceName The name of the atlas resource.\n * @returns the TextureAtlas of the atlas if loaded, `null` otherwise.\n */\n getAtlasTexture(resourceName: string): pixi_spine.TextureAtlas | null {\n return this._loadedSpineAtlases.getFromName(resourceName);\n }\n\n private _getAtlasResource(resourceName: string): ResourceData | null {\n const resource = this._resourceLoader.getResource(resourceName);\n return resource && this.getResourceKinds().includes(resource.kind)\n ? resource\n : null;\n }\n /**\n * To be called when the game is disposed.\n * Clear the Spine Atlases loaded in this manager.\n */\n dispose(): void {\n this._loadedSpineAtlases.clear();\n this._loadingSpineAtlases.clear();\n }\n }\n}\n"],
|
|
5
|
+
"mappings": "AAKA,GAAU,MAAV,UAAU,EAAV,CAOE,KAAM,GAA6B,CAAC,SAU7B,OAAwD,CAc7D,YACE,EACA,EACA,CAdM,yBAAsB,GAAI,GAAK,cAG/B,0BAAuB,GAAI,GAAK,cAYtC,KAAK,gBAAkB,EACvB,KAAK,cAAgB,EAGvB,kBAAmC,CACjC,MAAO,QAGH,iBAAgB,EAAqC,OAIrD,cAAa,EAAqC,CACtD,KAAM,MAAK,UAAU,GAQvB,UAAU,EAAwD,CAChE,KAAM,GAAW,KAAK,kBAAkB,GAExC,GAAI,CAAC,EACH,MAAO,SAAQ,OACb,sCAAsC,OAI1C,GAAI,GAAiB,KAAK,qBAAqB,IAAI,GAEnD,MAAK,IACH,GAAiB,GAAI,SACnB,CAAC,EAAS,IAAW,CACnB,KAAM,GAA2C,CAC/C,EACA,IACG,CACH,GAAI,EACF,MAAO,GACL,kDAAkD,KAGtD,GAAI,CAAC,EACH,MAAO,GACL,4CAA4C,OAIhD,EAAQ,IAGV,KAAK,KAAK,EAAU,KAIxB,KAAK,qBAAqB,IAAI,EAAU,IAGnC,EAST,KACE,EACA,EACM,CACN,KAAM,GAAO,KAAK,gBAAgB,iBAC5B,EAAyB,EAAK,0BAClC,EAAS,MAGX,GAAI,CAAC,EAAuB,OAC1B,MAAO,GACL,GAAI,OAAM,GAAG,EAAS,qCAG1B,KAAM,GAAS,EAAuB,OAEnC,CAAC,EAAW,IAAyB,CACtC,KAAM,GAAqB,EAAK,wBAC9B,EAAS,KACT,GAEF,SACE,GACE,KAAK,cAAc,qBAAqB,GAErC,GACN,IACG,EAAS,AAAC,GAAmC,CACjD,KAAK,oBAAoB,IAAI,EAAU,GACvC,EAAS,KAAM,IAEX,EAAM,KAAK,gBAAgB,WAAW,EAAS,MAErD,KAAK,OAAO,eAAe,CACzB,cAAe,GACf,YAAa,KAAK,gBAAgB,2BAA2B,GACzD,kBACA,cAEN,KAAK,OAAO,IAAI,EAAS,KAAM,EAAK,CAAE,WACtC,KAAK,OAAO,KAAuC,EAAS,MAAM,KAChE,AAAC,GAAU,CAOT,AAAI,MAAO,IAAU,SACnB,GAAI,YAAW,aACb,EACA,CAAC,EAAa,IACZ,EAAU,EAAO,GAAa,aAChC,GAGF,EAAO,KAWf,SAAS,EAA+B,CACtC,MAAO,CAAC,CAAC,KAAK,oBAAoB,YAAY,GAShD,gBAAgB,EAAsD,CACpE,MAAO,MAAK,oBAAoB,YAAY,GAGtC,kBAAkB,EAA2C,CACnE,KAAM,GAAW,KAAK,gBAAgB,YAAY,GAClD,MAAO,IAAY,KAAK,mBAAmB,SAAS,EAAS,MACzD,EACA,KAMN,SAAgB,CACd,KAAK,oBAAoB,QACzB,KAAK,qBAAqB,SApLvB,EAAM,sBAjBL",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var gdjs;(function(o){const
|
|
1
|
+
var gdjs;(function(o){const r=new o.Logger("Spine Manager"),c=["spine"];class l{constructor(s,e){this._loadedSpines=new o.ResourceCache;this._resourceLoader=s,this._spineAtlasManager=e}getResourceKinds(){return c}async processResource(s){}async loadResource(s){const e=this._getSpineResource(s);if(!e)return r.error(`Unable to find spine json for resource ${s}.`);try{const n=this._resourceLoader.getRuntimeGame(),a=n.getEmbeddedResourcesNames(e.name);if(a.length!==1)return r.error(`Unable to find atlas metadata for resource spine json ${s}.`);const d=n.resolveEmbeddedResource(e.name,a[0]),u=await this._spineAtlasManager.getOrLoad(d),t=this._resourceLoader.getFullUrl(e.file);PIXI.Assets.setPreferences({preferWorkers:!1,crossOrigin:this._resourceLoader.checkIfCredentialsRequired(t)?"use-credentials":"anonymous"}),PIXI.Assets.add(e.name,t,{spineAtlas:u});const i=await PIXI.Assets.load(e.name);i.spineData?this._loadedSpines.set(e,i.spineData):r.error(`Loader cannot process spine resource ${e.name} correctly.`)}catch(n){r.error(`Error while preloading spine resource ${e.name}: ${n}`)}}getSpine(s){return this._loadedSpines.getFromName(s)}isSpineLoaded(s){return!!this._loadedSpines.getFromName(s)}_getSpineResource(s){const e=this._resourceLoader.getResource(s);return e&&this.getResourceKinds().includes(e.kind)?e:null}dispose(){this._loadedSpines.clear()}}o.SpineManager=l})(gdjs||(gdjs={}));
|
|
2
2
|
//# sourceMappingURL=pixi-spine-manager.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../GDevelop/Extensions/Spine/managers/pixi-spine-manager.ts"],
|
|
4
|
-
"sourcesContent": ["/*\n * GDevelop JS Platform\n * Copyright 2013-present Florian Rival (Florian.Rival@gmail.com). All rights reserved.\n * This project is released under the MIT License.\n */\nnamespace gdjs {\n const logger = new gdjs.Logger('Spine Manager');\n\n const resourceKinds: ResourceKind[] = ['spine'];\n\n /**\n * SpineManager manages pixi spine skeleton data.\n */\n export class SpineManager implements gdjs.ResourceManager {\n private _spineAtlasManager: SpineAtlasManager;\n private _resourceLoader: ResourceLoader;\n private _loadedSpines = new gdjs.ResourceCache<pixi_spine.ISkeletonData>();\n\n /**\n * @param resourceDataArray The resources data of the game.\n * @param resourcesLoader The resources loader of the game.\n */\n constructor(\n resourceLoader: gdjs.ResourceLoader,\n spineAtlasManager: SpineAtlasManager\n ) {\n this._resourceLoader = resourceLoader;\n this._spineAtlasManager = spineAtlasManager;\n }\n\n getResourceKinds(): ResourceKind[] {\n return resourceKinds;\n }\n\n async processResource(resourceName: string): Promise<void> {\n // Do nothing because pixi-spine parses resources by itself.\n }\n\n async loadResource(resourceName: string): Promise<void> {\n const resource = this._getSpineResource(resourceName);\n\n if (!resource) {\n return logger.error(\n `Unable to find spine json for resource ${resourceName}.`\n );\n }\n\n try {\n const game = this._resourceLoader.getRuntimeGame();\n const embeddedResourcesNames = game.getEmbeddedResourcesNames(\n resource.name\n );\n\n // there should be exactly one file which is pointing to atlas\n if (embeddedResourcesNames.length !== 1) {\n return logger.error(\n `Unable to find atlas metadata for resource spine json ${resourceName}.`\n );\n }\n\n const atlasResourceName = game.resolveEmbeddedResource(\n resource.name,\n embeddedResourcesNames[0]\n );\n const spineAtlas = await this._spineAtlasManager.getOrLoad(\n atlasResourceName\n );\n const url = this._resourceLoader.getFullUrl(resource.file);\n PIXI.Assets.setPreferences({\n preferWorkers: false,\n crossOrigin: this._resourceLoader.checkIfCredentialsRequired(url)\n ? 'use-credentials'\n : 'anonymous',\n });\n PIXI.Assets.add(resource.name, url, { spineAtlas });\n const loadedJson = await PIXI.Assets.load(resource.name);\n\n if (loadedJson.spineData) {\n this._loadedSpines.set(resource, loadedJson.spineData);\n } else {\n logger.error(\n `Loader cannot process spine resource ${resource.name} correctly.`\n );\n }\n } catch (error) {\n logger.error(\n `Error while preloading spine resource ${resource.name}: ${error}`\n );\n }\n }\n\n /**\n * Get the object for the given resource that is already loaded (preloaded or loaded with `loadJson`).\n * If the resource is not loaded, `null` will be returned.\n *\n * @param resourceName The name of the spine skeleton.\n * @returns the spine skeleton if loaded, `null` otherwise.\n */\n getSpine(resourceName: string): pixi_spine.ISkeletonData | null {\n return this._loadedSpines.getFromName(resourceName);\n }\n\n /**\n * Check if the given spine skeleton was loaded.\n * @param resourceName The name of the spine skeleton.\n * @returns true if the content of the spine skeleton is loaded, false otherwise.\n */\n isSpineLoaded(resourceName: string): boolean {\n return !!this._loadedSpines.getFromName(resourceName);\n }\n\n private _getSpineResource(resourceName: string): ResourceData | null {\n const resource = this._resourceLoader.getResource(resourceName);\n return resource && this.getResourceKinds().includes(resource.kind)\n ? resource\n : null;\n }\n }\n}\n"],
|
|
5
|
-
"mappings": "AAKA,GAAU,MAAV,UAAU,EAAV,CACE,KAAM,GAAS,GAAI,GAAK,OAAO,iBAEzB,EAAgC,CAAC,SAKhC,OAAmD,CASxD,YACE,EACA,EACA,CATM,mBAAgB,GAAI,GAAK,cAU/B,KAAK,gBAAkB,EACvB,KAAK,mBAAqB,EAG5B,kBAAmC,CACjC,MAAO,QAGH,iBAAgB,EAAqC,OAIrD,cAAa,EAAqC,CACtD,KAAM,GAAW,KAAK,kBAAkB,GAExC,GAAI,CAAC,EACH,MAAO,GAAO,MACZ,0CAA0C,MAI9C,GAAI,CACF,KAAM,GAAO,KAAK,gBAAgB,iBAC5B,EAAyB,EAAK,0BAClC,EAAS,MAIX,GAAI,EAAuB,SAAW,EACpC,MAAO,GAAO,MACZ,yDAAyD,MAI7D,KAAM,GAAoB,EAAK,wBAC7B,EAAS,KACT,EAAuB,IAEnB,EAAa,KAAM,MAAK,mBAAmB,UAC/C,GAEI,EAAM,KAAK,gBAAgB,WAAW,EAAS,MACrD,KAAK,OAAO,eAAe,CACzB,cAAe,GACf,YAAa,KAAK,gBAAgB,2BAA2B,GACzD,kBACA,cAEN,KAAK,OAAO,IAAI,EAAS,KAAM,EAAK,CAAE,eACtC,KAAM,GAAa,KAAM,MAAK,OAAO,KAAK,EAAS,MAEnD,AAAI,EAAW,UACb,KAAK,cAAc,IAAI,EAAU,EAAW,WAE5C,EAAO,MACL,wCAAwC,EAAS,yBAG9C,EAAP,CACA,EAAO,MACL,yCAAyC,EAAS,SAAS,MAYjE,SAAS,EAAuD,CAC9D,MAAO,MAAK,cAAc,YAAY,GAQxC,cAAc,EAA+B,CAC3C,MAAO,CAAC,CAAC,KAAK,cAAc,YAAY,GAGlC,kBAAkB,EAA2C,CACnE,KAAM,GAAW,KAAK,gBAAgB,YAAY,GAClD,MAAO,IAAY,KAAK,mBAAmB,SAAS,EAAS,MACzD,EACA,
|
|
4
|
+
"sourcesContent": ["/*\n * GDevelop JS Platform\n * Copyright 2013-present Florian Rival (Florian.Rival@gmail.com). All rights reserved.\n * This project is released under the MIT License.\n */\nnamespace gdjs {\n const logger = new gdjs.Logger('Spine Manager');\n\n const resourceKinds: ResourceKind[] = ['spine'];\n\n /**\n * SpineManager manages pixi spine skeleton data.\n */\n export class SpineManager implements gdjs.ResourceManager {\n private _spineAtlasManager: SpineAtlasManager;\n private _resourceLoader: ResourceLoader;\n private _loadedSpines = new gdjs.ResourceCache<pixi_spine.ISkeletonData>();\n\n /**\n * @param resourceDataArray The resources data of the game.\n * @param resourcesLoader The resources loader of the game.\n */\n constructor(\n resourceLoader: gdjs.ResourceLoader,\n spineAtlasManager: SpineAtlasManager\n ) {\n this._resourceLoader = resourceLoader;\n this._spineAtlasManager = spineAtlasManager;\n }\n\n getResourceKinds(): ResourceKind[] {\n return resourceKinds;\n }\n\n async processResource(resourceName: string): Promise<void> {\n // Do nothing because pixi-spine parses resources by itself.\n }\n\n async loadResource(resourceName: string): Promise<void> {\n const resource = this._getSpineResource(resourceName);\n\n if (!resource) {\n return logger.error(\n `Unable to find spine json for resource ${resourceName}.`\n );\n }\n\n try {\n const game = this._resourceLoader.getRuntimeGame();\n const embeddedResourcesNames = game.getEmbeddedResourcesNames(\n resource.name\n );\n\n // there should be exactly one file which is pointing to atlas\n if (embeddedResourcesNames.length !== 1) {\n return logger.error(\n `Unable to find atlas metadata for resource spine json ${resourceName}.`\n );\n }\n\n const atlasResourceName = game.resolveEmbeddedResource(\n resource.name,\n embeddedResourcesNames[0]\n );\n const spineAtlas = await this._spineAtlasManager.getOrLoad(\n atlasResourceName\n );\n const url = this._resourceLoader.getFullUrl(resource.file);\n PIXI.Assets.setPreferences({\n preferWorkers: false,\n crossOrigin: this._resourceLoader.checkIfCredentialsRequired(url)\n ? 'use-credentials'\n : 'anonymous',\n });\n PIXI.Assets.add(resource.name, url, { spineAtlas });\n const loadedJson = await PIXI.Assets.load(resource.name);\n\n if (loadedJson.spineData) {\n this._loadedSpines.set(resource, loadedJson.spineData);\n } else {\n logger.error(\n `Loader cannot process spine resource ${resource.name} correctly.`\n );\n }\n } catch (error) {\n logger.error(\n `Error while preloading spine resource ${resource.name}: ${error}`\n );\n }\n }\n\n /**\n * Get the object for the given resource that is already loaded (preloaded or loaded with `loadJson`).\n * If the resource is not loaded, `null` will be returned.\n *\n * @param resourceName The name of the spine skeleton.\n * @returns the spine skeleton if loaded, `null` otherwise.\n */\n getSpine(resourceName: string): pixi_spine.ISkeletonData | null {\n return this._loadedSpines.getFromName(resourceName);\n }\n\n /**\n * Check if the given spine skeleton was loaded.\n * @param resourceName The name of the spine skeleton.\n * @returns true if the content of the spine skeleton is loaded, false otherwise.\n */\n isSpineLoaded(resourceName: string): boolean {\n return !!this._loadedSpines.getFromName(resourceName);\n }\n\n private _getSpineResource(resourceName: string): ResourceData | null {\n const resource = this._resourceLoader.getResource(resourceName);\n return resource && this.getResourceKinds().includes(resource.kind)\n ? resource\n : null;\n }\n\n /**\n * To be called when the game is disposed.\n * Clear the Spine skeleton data loaded in this manager.\n */\n dispose(): void {\n this._loadedSpines.clear();\n }\n }\n}\n"],
|
|
5
|
+
"mappings": "AAKA,GAAU,MAAV,UAAU,EAAV,CACE,KAAM,GAAS,GAAI,GAAK,OAAO,iBAEzB,EAAgC,CAAC,SAKhC,OAAmD,CASxD,YACE,EACA,EACA,CATM,mBAAgB,GAAI,GAAK,cAU/B,KAAK,gBAAkB,EACvB,KAAK,mBAAqB,EAG5B,kBAAmC,CACjC,MAAO,QAGH,iBAAgB,EAAqC,OAIrD,cAAa,EAAqC,CACtD,KAAM,GAAW,KAAK,kBAAkB,GAExC,GAAI,CAAC,EACH,MAAO,GAAO,MACZ,0CAA0C,MAI9C,GAAI,CACF,KAAM,GAAO,KAAK,gBAAgB,iBAC5B,EAAyB,EAAK,0BAClC,EAAS,MAIX,GAAI,EAAuB,SAAW,EACpC,MAAO,GAAO,MACZ,yDAAyD,MAI7D,KAAM,GAAoB,EAAK,wBAC7B,EAAS,KACT,EAAuB,IAEnB,EAAa,KAAM,MAAK,mBAAmB,UAC/C,GAEI,EAAM,KAAK,gBAAgB,WAAW,EAAS,MACrD,KAAK,OAAO,eAAe,CACzB,cAAe,GACf,YAAa,KAAK,gBAAgB,2BAA2B,GACzD,kBACA,cAEN,KAAK,OAAO,IAAI,EAAS,KAAM,EAAK,CAAE,eACtC,KAAM,GAAa,KAAM,MAAK,OAAO,KAAK,EAAS,MAEnD,AAAI,EAAW,UACb,KAAK,cAAc,IAAI,EAAU,EAAW,WAE5C,EAAO,MACL,wCAAwC,EAAS,yBAG9C,EAAP,CACA,EAAO,MACL,yCAAyC,EAAS,SAAS,MAYjE,SAAS,EAAuD,CAC9D,MAAO,MAAK,cAAc,YAAY,GAQxC,cAAc,EAA+B,CAC3C,MAAO,CAAC,CAAC,KAAK,cAAc,YAAY,GAGlC,kBAAkB,EAA2C,CACnE,KAAM,GAAW,KAAK,gBAAgB,YAAY,GAClD,MAAO,IAAY,KAAK,mBAAmB,SAAS,EAAS,MACzD,EACA,KAON,SAAgB,CACd,KAAK,cAAc,SA9GhB,EAAM,iBARL",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var gdjs;(function(s){const a=class extends s.RuntimeObject{constructor(e,t){super(e,t);this._displayMode="all";this._layerIndex=0;this._initialTileMapAsJsObject=null;this._isTileMapDirty=!1;this._sceneToTileMapTransformation=new s.AffineTransformation;this._tileMapToSceneTransformation=new s.AffineTransformation;this._collisionTileMap=null;this._hitBoxTag="collision";this._transformationIsUpToDate=!1;this._opacity=t.content.opacity,this._atlasImage=t.content.atlasImage,this._rowCount=t.content.rowCount,this._columnCount=t.content.columnCount,this._tileSize=t.content.tileSize,this._initialTilesWithHitBox=t.content.tilesWithHitBox.split(",").filter(i=>!!i).map(i=>parseInt(i,10)),this._tileMapManager=s.TileMap.TileMapRuntimeManager.getManager(e),this._renderer=new s.TileMapRuntimeObjectRenderer(this,e),this.onCreated()}getRendererObject(){return this._renderer.getRendererObject()}updatePreRender(e){if(this._isTileMapDirty){let t=!0;if(this._tileMapManager.getOrLoadSimpleTileMapTextureCache(i=>this.getInstanceContainer().getGame().getImageManager().getPIXITexture(i),this._atlasImage,this._tileSize,this._columnCount,this._rowCount,i=>{!i||this._renderer.refreshPixiTileMap(i)},i=>{t=!1,console.error(`Could not load texture cache for atlas ${this._atlasImage} during prerender. The tilemap might be badly configured or an issues happened with the loaded atlas image:`,i)}),!t)return;if(this._collisionTileMap){const i=this._renderer.getTileMap();i&&this._collisionTileMap.updateFromTileMap(i)}this._isTileMapDirty=!1}}updateFromObjectData(e,t){return e.content.opacity!==t.content.opacity&&this.setOpacity(t.content.opacity),e.content.atlasImage===t.content.atlasImage}getNetworkSyncData(){return{...super.getNetworkSyncData(),op:this._opacity,ai:this._atlasImage,wid:this.getWidth(),hei:this.getHeight()}}updateFromNetworkSyncData(e){super.updateFromNetworkSyncData(e),e.op!==void 0&&e.op!==this._opacity&&this.setOpacity(e.op),e.wid!==void 0&&e.wid!==this.getWidth()&&this.setWidth(e.wid),e.hei!==void 0&&e.hei!==this.getHeight()&&this.setHeight(e.hei),e.ai!==void 0}extraInitializationFromInitialInstance(e){for(const t of e.stringProperties)t.name==="tilemap"&&(this._initialTileMapAsJsObject=JSON.parse(t.value));this._loadInitialTileMap(t=>{e.customSize&&(this.setWidth(e.width),this.setHeight(e.height)),e.opacity!==void 0&&this.setOpacity(e.opacity),this._renderer.updatePosition(),this._collisionTileMap?this._collisionTileMap.updateFromTileMap(t):this._collisionTileMap=new s.TileMap.TransformedCollisionTileMap(t,this._hitBoxTag),this.updateTransformation()})}_loadInitialTileMap(e){if(!!this._initialTileMapAsJsObject){if(this._columnCount<=0||this._rowCount<=0){console.error(`Tilemap object ${this.name} is not configured properly.`);return}this._tileMapManager.getOrLoadSimpleTileMap(this._initialTileMapAsJsObject,this.name,this._tileSize,this._columnCount,this._rowCount,t=>{this._initialTilesWithHitBox.forEach(i=>{const o=t.getTileDefinition(i);if(!o){console.warn(`Could not set hit box for tile with id ${i}. Continuing.`);return}o.addHitBox(this._hitBoxTag,[[0,0],[0,t.getTileHeight()],[t.getTileWidth(),t.getTileHeight()],[t.getTileWidth(),0]],!0)}),this._tileMapManager.getOrLoadSimpleTileMapTextureCache(i=>this.getInstanceContainer().getGame().getImageManager().getPIXITexture(i),this._atlasImage,this._tileSize,this._columnCount,this._rowCount,i=>{!i||(this._renderer.updatePixiTileMap(t,i),e(t))},i=>{console.error(`Could not load texture cache for atlas ${this._atlasImage} during initial loading. The tilemap might be badly configured or an issues happened with the loaded atlas image:`,i)})})}}onDestroyed(){super.onDestroyed(),this._renderer.destroy()}setWidth(e){this.getWidth()!==e&&(this._transformationIsUpToDate=!1,this._renderer.setWidth(e),this.invalidateHitboxes())}setHeight(e){this.getHeight()!==e&&(this._transformationIsUpToDate=!1,this._renderer.setHeight(e),this.invalidateHitboxes())}setSize(e,t){this.setWidth(e),this.setHeight(t),this._transformationIsUpToDate=!1}getScale(){const e=this.getScaleX(),t=this.getScaleY();return e===t?e:Math.sqrt(e*t)}setScale(e){this.setScaleX(e),this.setScaleY(e),this._transformationIsUpToDate=!1}setScaleX(e){e<0&&(e=0),this.getScaleX()!==e&&(this._renderer.setScaleX(e),this.invalidateHitboxes(),this._transformationIsUpToDate=!1)}setScaleY(e){e<0&&(e=0),this.getScaleY()!==e&&(this._renderer.setScaleY(e),this.invalidateHitboxes(),this._transformationIsUpToDate=!1)}setX(e){super.setX(e),this._renderer.updatePosition(),this._transformationIsUpToDate=!1}setY(e){super.setY(e),this._renderer.updatePosition(),this._transformationIsUpToDate=!1}setAngle(e){super.setAngle(e),this._renderer.updateAngle(),this._transformationIsUpToDate=!1}setOpacity(e){this._opacity=e,this._renderer.updateOpacity(),this._isTileMapDirty=!0}getOpacity(){return this._opacity}getWidth(){return this._renderer.getWidth()}getHeight(){return this._renderer.getHeight()}getScaleX(){return this._renderer.getScaleX()}getScaleY(){return this._renderer.getScaleY()}getHitBoxes(){return this.hitBoxesDirty&&(this.updateHitBoxes(),this.updateAABB(),this.hitBoxesDirty=!1),this.hitBoxes}updateHitBoxes(){this.updateTransformation(),!!this._collisionTileMap&&(this.hitBoxes=Array.from(this._collisionTileMap.getAllHitboxes(this._hitBoxTag)),this.hitBoxesDirty=!1,this.updateAABB())}updateAABB(){if(this.getAngle()===0)this.aabb.min[0]=this.x,this.aabb.min[1]=this.y,this.aabb.max[0]=this.aabb.min[0]+this.getWidth(),this.aabb.max[1]=this.aabb.min[1]+this.getHeight();else{if(!this._collisionTileMap)return;const e=this._collisionTileMap.getTransformation(),t=0,i=this._collisionTileMap.getWidth(),o=0,r=this._collisionTileMap.getHeight(),n=this.aabb.min;n[0]=t,n[1]=o,e.transform(n,n);const l=n[0],h=n[1];n[0]=i,n[1]=o,e.transform(n,n);const d=n[0],p=n[1];n[0]=i,n[1]=r,e.transform(n,n);const g=n[0],f=n[1];n[0]=t,n[1]=r,e.transform(n,n);const u=n[0],c=n[1];this.aabb.min[0]=Math.min(l,d,g,u),this.aabb.max[0]=Math.max(l,d,g,u),this.aabb.min[1]=Math.min(h,p,f,c),this.aabb.max[1]=Math.max(h,p,f,c)}}getHitBoxesAround(e,t,i,o){return this.updateTransformation(),this._collisionTileMap?this._collisionTileMap.getHitboxesAround(this._hitBoxTag,e,t,i,o):[]}updateTransformation(){if(this._transformationIsUpToDate)return;const e=Math.abs(this._renderer.getScaleX()),t=Math.abs(this._renderer.getScaleY());this._tileMapToSceneTransformation.setToIdentity(),this._tileMapToSceneTransformation.translate(this.getX(),this.getY());const i=this.getAngle()*Math.PI/180;if(this._tileMapToSceneTransformation.rotateAround(i,this.getCenterX(),this.getCenterY()),this._tileMapToSceneTransformation.scale(e,t),this._collisionTileMap){const o=this._collisionTileMap.getTransformation();o.copyFrom(this._tileMapToSceneTransformation),this._collisionTileMap.setTransformation(o)}this._sceneToTileMapTransformation.copyFrom(this._tileMapToSceneTransformation),this._sceneToTileMapTransformation.invert(),this._transformationIsUpToDate=!0}getSceneXCoordinateOfTileCenter(e,t){const i=a.workingPoint;return this._tileMapToSceneTransformation.transform([(e+.5)*this._tileSize,(t+.5)*this._tileSize],i),i[0]}getSceneYCoordinateOfTileCenter(e,t){const i=a.workingPoint;return this._tileMapToSceneTransformation.transform([(e+.5)*this._tileSize,(t+.5)*this._tileSize],i),i[1]}getGridCoordinatesFromSceneCoordinates(e,t){this.updateTransformation();const i=a.workingPoint;this._sceneToTileMapTransformation.transform([e,t],i);const o=Math.floor(i[0]/this._tileSize),r=Math.floor(i[1]/this._tileSize);return[o,r]}getColumnIndexAtPosition(e,t){return this.getGridCoordinatesFromSceneCoordinates(e,t)[0]}getRowIndexAtPosition(e,t){return this.getGridCoordinatesFromSceneCoordinates(e,t)[1]}getTileAtPosition(e,t){const[i,o]=this.getGridCoordinatesFromSceneCoordinates(e,t);return this.getTileAtGridCoordinates(i,o)}getTileAtGridCoordinates(e,t){return this._renderer.getTileId(e,t,0)}setTileAtPosition(e,t,i){const[o,r]=this.getGridCoordinatesFromSceneCoordinates(t,i);this.setTileAtGridCoordinates(e,o,r)}setTileAtGridCoordinates(e,t,i){const o=this._renderer._tileMap;if(!o)return;const r=o.getTileLayer(this._layerIndex);if(!r)return;const n=r.getTileId(t,i);if(e!==n){if(r.setTile(t,i,e),this._collisionTileMap){const l=n!==void 0&&o.getTileDefinition(n),h=o.getTileDefinition(e),d=!!l&&l.hasFullHitBox(this._hitBoxTag),p=!!h&&h.hasFullHitBox(this._hitBoxTag);d!==p&&this._collisionTileMap.invalidateTile(this._layerIndex,t,i)}this._isTileMapDirty=!0,this.invalidateHitboxes()}}flipTileOnYAtPosition(e,t,i){const[o,r]=this.getGridCoordinatesFromSceneCoordinates(e,t);this.flipTileOnYAtGridCoordinates(o,r,i)}flipTileOnXAtPosition(e,t,i){const[o,r]=this.getGridCoordinatesFromSceneCoordinates(e,t);this.flipTileOnXAtGridCoordinates(o,r,i)}flipTileOnYAtGridCoordinates(e,t,i){this._renderer.flipTileOnY(e,t,0,i),this._isTileMapDirty=!0}flipTileOnXAtGridCoordinates(e,t,i){this._renderer.flipTileOnX(e,t,0,i),this._isTileMapDirty=!0}isTileFlippedOnXAtPosition(e,t){const[i,o]=this.getGridCoordinatesFromSceneCoordinates(e,t);return this._renderer.isTileFlippedOnX(i,o,0)}isTileFlippedOnXAtGridCoordinates(e,t){return this._renderer.isTileFlippedOnX(e,t,0)}isTileFlippedOnYAtPosition(e,t){const[i,o]=this.getGridCoordinatesFromSceneCoordinates(e,t);return this._renderer.isTileFlippedOnY(i,o,0)}isTileFlippedOnYAtGridCoordinates(e,t){return this._renderer.isTileFlippedOnY(e,t,0)}removeTileAtPosition(e,t){const[i,o]=this.getGridCoordinatesFromSceneCoordinates(e,t);this.removeTileAtGridCoordinates(i,o)}removeTileAtGridCoordinates(e,t){const i=this._renderer._tileMap;if(!i)return;const o=i.getTileLayer(this._layerIndex);!o||o.getTileId(e,t)===void 0||(o.removeTile(e,t),this._collisionTileMap&&this._collisionTileMap.invalidateTile(this._layerIndex,e,t),this._isTileMapDirty=!0,this.invalidateHitboxes())}setGridRowCount(e){e<=0||(this._renderer.setGridRowCount(e),this._isTileMapDirty=!0,this.invalidateHitboxes())}setGridColumnCount(e){e<=0||(this._renderer.setGridColumnCount(e),this._isTileMapDirty=!0,this.invalidateHitboxes())}getGridRowCount(){return this._renderer.getGridRowCount()}getGridColumnCount(){return this._renderer.getGridColumnCount()}getTilesetColumnCount(){return this._columnCount}getTilesetRowCount(){return this._rowCount}};let T=a;T.workingPoint=[0,0],s.SimpleTileMapRuntimeObject=T,s.registerObject("TileMap::SimpleTileMap",s.SimpleTileMapRuntimeObject)})(gdjs||(gdjs={}));
|
|
1
|
+
var gdjs;(function(s){const a=class extends s.RuntimeObject{constructor(e,t){super(e,t);this._opacity=255;this._displayMode="all";this._layerIndex=0;this._isTileMapDirty=!1;this._sceneToTileMapTransformation=new s.AffineTransformation;this._tileMapToSceneTransformation=new s.AffineTransformation;this._collisionTileMap=null;this._hitBoxTag="collision";this._transformationIsUpToDate=!1;this._opacity=t.content.opacity,this._atlasImage=t.content.atlasImage,this._rowCount=t.content.rowCount,this._columnCount=t.content.columnCount,this._tileSize=t.content.tileSize,this._initialTileMapAsJsObject={tileWidth:this._tileSize,tileHeight:this._tileSize,dimX:1,dimY:1,layers:[{id:0,alpha:this._opacity/255,tiles:[]}]},this._initialTilesWithHitBox=t.content.tilesWithHitBox.split(",").filter(i=>!!i).map(i=>parseInt(i,10)),this._tileMapManager=s.TileMap.TileMapRuntimeManager.getManager(e),this._renderer=new s.TileMapRuntimeObjectRenderer(this,e),this._loadInitialTileMap(i=>{this._renderer.updatePosition(),this._collisionTileMap=new s.TileMap.TransformedCollisionTileMap(i,this._hitBoxTag),this.updateTransformation()}),this.onCreated()}getRendererObject(){return this._renderer.getRendererObject()}updatePreRender(e){if(this._isTileMapDirty){let t=!0;if(this._tileMapManager.getOrLoadSimpleTileMapTextureCache(i=>this.getInstanceContainer().getGame().getImageManager().getPIXITexture(i),this._atlasImage,this._tileSize,this._columnCount,this._rowCount,i=>{!i||this._renderer.refreshPixiTileMap(i)},i=>{t=!1,console.error(`Could not load texture cache for atlas ${this._atlasImage} during prerender. The tilemap might be badly configured or an issues happened with the loaded atlas image:`,i)}),!t)return;if(this._collisionTileMap){const i=this._renderer.getTileMap();i&&this._collisionTileMap.updateFromTileMap(i)}this._isTileMapDirty=!1}}updateFromObjectData(e,t){return e.content.opacity!==t.content.opacity&&this.setOpacity(t.content.opacity),e.content.atlasImage===t.content.atlasImage}getNetworkSyncData(){return{...super.getNetworkSyncData(),op:this._opacity,ai:this._atlasImage,wid:this.getWidth(),hei:this.getHeight()}}updateFromNetworkSyncData(e){super.updateFromNetworkSyncData(e),e.op!==void 0&&e.op!==this._opacity&&this.setOpacity(e.op),e.wid!==void 0&&e.wid!==this.getWidth()&&this.setWidth(e.wid),e.hei!==void 0&&e.hei!==this.getHeight()&&this.setHeight(e.hei),e.ai!==void 0}extraInitializationFromInitialInstance(e){for(const t of e.stringProperties)t.name==="tilemap"&&(this._initialTileMapAsJsObject=JSON.parse(t.value));this._loadInitialTileMap(t=>{e.customSize&&(this.setWidth(e.width),this.setHeight(e.height)),e.opacity!==void 0&&this.setOpacity(e.opacity),this._renderer.updatePosition(),this._collisionTileMap?this._collisionTileMap.updateFromTileMap(t):this._collisionTileMap=new s.TileMap.TransformedCollisionTileMap(t,this._hitBoxTag),this.updateTransformation()})}_loadInitialTileMap(e){if(!!this._initialTileMapAsJsObject){if(this._columnCount<=0||this._rowCount<=0){console.error(`Tilemap object ${this.name} is not configured properly.`);return}this._tileMapManager.getOrLoadSimpleTileMap(this._initialTileMapAsJsObject,this.name,this._tileSize,this._columnCount,this._rowCount,t=>{this._initialTilesWithHitBox.forEach(i=>{const o=t.getTileDefinition(i);if(!o){console.warn(`Could not set hit box for tile with id ${i}. Continuing.`);return}o.addHitBox(this._hitBoxTag,[[0,0],[0,t.getTileHeight()],[t.getTileWidth(),t.getTileHeight()],[t.getTileWidth(),0]],!0)}),this._tileMapManager.getOrLoadSimpleTileMapTextureCache(i=>this.getInstanceContainer().getGame().getImageManager().getPIXITexture(i),this._atlasImage,this._tileSize,this._columnCount,this._rowCount,i=>{!i||(this._renderer.updatePixiTileMap(t,i),e(t))},i=>{console.error(`Could not load texture cache for atlas ${this._atlasImage} during initial loading. The tilemap might be badly configured or an issues happened with the loaded atlas image:`,i)})})}}onDestroyed(){super.onDestroyed(),this._renderer.destroy()}setWidth(e){this.getWidth()!==e&&(this._transformationIsUpToDate=!1,this._renderer.setWidth(e),this.invalidateHitboxes())}setHeight(e){this.getHeight()!==e&&(this._transformationIsUpToDate=!1,this._renderer.setHeight(e),this.invalidateHitboxes())}setSize(e,t){this.setWidth(e),this.setHeight(t),this._transformationIsUpToDate=!1}getScale(){const e=this.getScaleX(),t=this.getScaleY();return e===t?e:Math.sqrt(e*t)}setScale(e){this.setScaleX(e),this.setScaleY(e),this._transformationIsUpToDate=!1}setScaleX(e){e<0&&(e=0),this.getScaleX()!==e&&(this._renderer.setScaleX(e),this.invalidateHitboxes(),this._transformationIsUpToDate=!1)}setScaleY(e){e<0&&(e=0),this.getScaleY()!==e&&(this._renderer.setScaleY(e),this.invalidateHitboxes(),this._transformationIsUpToDate=!1)}setX(e){super.setX(e),this._renderer.updatePosition(),this._transformationIsUpToDate=!1}setY(e){super.setY(e),this._renderer.updatePosition(),this._transformationIsUpToDate=!1}setAngle(e){super.setAngle(e),this._renderer.updateAngle(),this._transformationIsUpToDate=!1}setOpacity(e){this._opacity=e,this._renderer.updateOpacity(),this._isTileMapDirty=!0}getOpacity(){return this._opacity}getWidth(){return this._renderer.getWidth()}getHeight(){return this._renderer.getHeight()}getScaleX(){return this._renderer.getScaleX()}getScaleY(){return this._renderer.getScaleY()}getHitBoxes(){return this.hitBoxesDirty&&(this.updateHitBoxes(),this.updateAABB(),this.hitBoxesDirty=!1),this.hitBoxes}updateHitBoxes(){this.updateTransformation(),!!this._collisionTileMap&&(this.hitBoxes=Array.from(this._collisionTileMap.getAllHitboxes(this._hitBoxTag)),this.hitBoxesDirty=!1,this.updateAABB())}updateAABB(){if(this.getAngle()===0)this.aabb.min[0]=this.x,this.aabb.min[1]=this.y,this.aabb.max[0]=this.aabb.min[0]+this.getWidth(),this.aabb.max[1]=this.aabb.min[1]+this.getHeight();else{if(!this._collisionTileMap)return;const e=this._collisionTileMap.getTransformation(),t=0,i=this._collisionTileMap.getWidth(),o=0,r=this._collisionTileMap.getHeight(),n=this.aabb.min;n[0]=t,n[1]=o,e.transform(n,n);const l=n[0],h=n[1];n[0]=i,n[1]=o,e.transform(n,n);const d=n[0],p=n[1];n[0]=i,n[1]=r,e.transform(n,n);const g=n[0],f=n[1];n[0]=t,n[1]=r,e.transform(n,n);const u=n[0],c=n[1];this.aabb.min[0]=Math.min(l,d,g,u),this.aabb.max[0]=Math.max(l,d,g,u),this.aabb.min[1]=Math.min(h,p,f,c),this.aabb.max[1]=Math.max(h,p,f,c)}}getHitBoxesAround(e,t,i,o){return this.updateTransformation(),this._collisionTileMap?this._collisionTileMap.getHitboxesAround(this._hitBoxTag,e,t,i,o):[]}updateTransformation(){if(this._transformationIsUpToDate)return;const e=Math.abs(this._renderer.getScaleX()),t=Math.abs(this._renderer.getScaleY());this._tileMapToSceneTransformation.setToIdentity(),this._tileMapToSceneTransformation.translate(this.getX(),this.getY());const i=this.getAngle()*Math.PI/180;if(this._tileMapToSceneTransformation.rotateAround(i,this.getCenterX(),this.getCenterY()),this._tileMapToSceneTransformation.scale(e,t),this._collisionTileMap){const o=this._collisionTileMap.getTransformation();o.copyFrom(this._tileMapToSceneTransformation),this._collisionTileMap.setTransformation(o)}this._sceneToTileMapTransformation.copyFrom(this._tileMapToSceneTransformation),this._sceneToTileMapTransformation.invert(),this._transformationIsUpToDate=!0}getSceneXCoordinateOfTileCenter(e,t){const i=a.workingPoint;return this._tileMapToSceneTransformation.transform([(e+.5)*this._tileSize,(t+.5)*this._tileSize],i),i[0]}getSceneYCoordinateOfTileCenter(e,t){const i=a.workingPoint;return this._tileMapToSceneTransformation.transform([(e+.5)*this._tileSize,(t+.5)*this._tileSize],i),i[1]}getGridCoordinatesFromSceneCoordinates(e,t){this.updateTransformation();const i=a.workingPoint;this._sceneToTileMapTransformation.transform([e,t],i);const o=Math.floor(i[0]/this._tileSize),r=Math.floor(i[1]/this._tileSize);return[o,r]}getColumnIndexAtPosition(e,t){return this.getGridCoordinatesFromSceneCoordinates(e,t)[0]}getRowIndexAtPosition(e,t){return this.getGridCoordinatesFromSceneCoordinates(e,t)[1]}getTileAtPosition(e,t){const[i,o]=this.getGridCoordinatesFromSceneCoordinates(e,t);return this.getTileAtGridCoordinates(i,o)}getTileAtGridCoordinates(e,t){return this._renderer.getTileId(e,t,0)}setTileAtPosition(e,t,i){const[o,r]=this.getGridCoordinatesFromSceneCoordinates(t,i);this.setTileAtGridCoordinates(e,o,r)}setTileAtGridCoordinates(e,t,i){const o=this._renderer._tileMap;if(!o)return;const r=o.getTileLayer(this._layerIndex);if(!r)return;const n=r.getTileId(t,i);if(e!==n){if(r.setTile(t,i,e),this._collisionTileMap){const l=n!==void 0&&o.getTileDefinition(n),h=o.getTileDefinition(e),d=!!l&&l.hasFullHitBox(this._hitBoxTag),p=!!h&&h.hasFullHitBox(this._hitBoxTag);d!==p&&this._collisionTileMap.invalidateTile(this._layerIndex,t,i)}this._isTileMapDirty=!0,this.invalidateHitboxes()}}flipTileOnYAtPosition(e,t,i){const[o,r]=this.getGridCoordinatesFromSceneCoordinates(e,t);this.flipTileOnYAtGridCoordinates(o,r,i)}flipTileOnXAtPosition(e,t,i){const[o,r]=this.getGridCoordinatesFromSceneCoordinates(e,t);this.flipTileOnXAtGridCoordinates(o,r,i)}flipTileOnYAtGridCoordinates(e,t,i){this._renderer.flipTileOnY(e,t,0,i),this._isTileMapDirty=!0}flipTileOnXAtGridCoordinates(e,t,i){this._renderer.flipTileOnX(e,t,0,i),this._isTileMapDirty=!0}isTileFlippedOnXAtPosition(e,t){const[i,o]=this.getGridCoordinatesFromSceneCoordinates(e,t);return this._renderer.isTileFlippedOnX(i,o,0)}isTileFlippedOnXAtGridCoordinates(e,t){return this._renderer.isTileFlippedOnX(e,t,0)}isTileFlippedOnYAtPosition(e,t){const[i,o]=this.getGridCoordinatesFromSceneCoordinates(e,t);return this._renderer.isTileFlippedOnY(i,o,0)}isTileFlippedOnYAtGridCoordinates(e,t){return this._renderer.isTileFlippedOnY(e,t,0)}removeTileAtPosition(e,t){const[i,o]=this.getGridCoordinatesFromSceneCoordinates(e,t);this.removeTileAtGridCoordinates(i,o)}removeTileAtGridCoordinates(e,t){const i=this._renderer._tileMap;if(!i)return;const o=i.getTileLayer(this._layerIndex);!o||o.getTileId(e,t)===void 0||(o.removeTile(e,t),this._collisionTileMap&&this._collisionTileMap.invalidateTile(this._layerIndex,e,t),this._isTileMapDirty=!0,this.invalidateHitboxes())}setGridRowCount(e){e<=0||(this._renderer.setGridRowCount(e),this._isTileMapDirty=!0,this.invalidateHitboxes())}setGridColumnCount(e){e<=0||(this._renderer.setGridColumnCount(e),this._isTileMapDirty=!0,this.invalidateHitboxes())}getGridRowCount(){return this._renderer.getGridRowCount()}getGridColumnCount(){return this._renderer.getGridColumnCount()}getTilesetColumnCount(){return this._columnCount}getTilesetRowCount(){return this._rowCount}};let T=a;T.workingPoint=[0,0],s.SimpleTileMapRuntimeObject=T,s.registerObject("TileMap::SimpleTileMap",s.SimpleTileMapRuntimeObject)})(gdjs||(gdjs={}));
|
|
2
2
|
//# sourceMappingURL=simpletilemapruntimeobject.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../GDevelop/Extensions/TileMap/simpletilemapruntimeobject.ts"],
|
|
4
|
-
"sourcesContent": ["/// <reference path=\"helper/TileMapHelper.d.ts\" />\nnamespace gdjs {\n export type SimpleTileMapObjectDataType = {\n content: {\n opacity: number;\n atlasImage: string;\n rowCount: number;\n columnCount: number;\n tileSize: number;\n tilesWithHitBox: string;\n };\n };\n\n export type SimpleTileMapObjectData = ObjectData &\n SimpleTileMapObjectDataType;\n\n export type SimpleTileMapNetworkSyncDataType = {\n op: number;\n ai: string;\n wid: number;\n hei: number;\n // TODO: Support tilemap synchronization. Find an efficient way to send tiles changes.\n };\n\n export type SimpleTileMapNetworkSyncData = ObjectNetworkSyncData &\n SimpleTileMapNetworkSyncDataType;\n\n /**\n * Displays a SimpleTileMap object.\n */\n export class SimpleTileMapRuntimeObject\n extends gdjs.RuntimeObject\n implements gdjs.Resizable, gdjs.Scalable, gdjs.OpacityHandler {\n /**\n * A reusable Point to avoid allocations.\n */\n private static readonly workingPoint: FloatPoint = [0, 0];\n\n _opacity: float;\n _atlasImage: string;\n _tileMapManager: gdjs.TileMap.TileMapRuntimeManager;\n _renderer: gdjs.TileMapRuntimeObjectPixiRenderer;\n readonly _rowCount: number;\n readonly _columnCount: number;\n readonly _tileSize: number;\n _displayMode = 'all';\n _layerIndex = 0;\n _initialTileMapAsJsObject: TileMapHelper.EditableTileMapAsJsObject | null = null;\n readonly _initialTilesWithHitBox: number[];\n _isTileMapDirty: boolean = false;\n _sceneToTileMapTransformation: gdjs.AffineTransformation = new gdjs.AffineTransformation();\n _tileMapToSceneTransformation: gdjs.AffineTransformation = new gdjs.AffineTransformation();\n _collisionTileMap: gdjs.TileMap.TransformedCollisionTileMap | null = null;\n _hitBoxTag: string = 'collision';\n private _transformationIsUpToDate: boolean = false;\n\n // TODO: Add a debug mode like for TileMapCollisionMaskRuntimeObject to draw?\n\n constructor(\n instanceContainer: gdjs.RuntimeInstanceContainer,\n objectData: SimpleTileMapObjectDataType\n ) {\n super(instanceContainer, objectData);\n this._opacity = objectData.content.opacity;\n this._atlasImage = objectData.content.atlasImage;\n this._rowCount = objectData.content.rowCount;\n this._columnCount = objectData.content.columnCount;\n this._tileSize = objectData.content.tileSize;\n this._initialTilesWithHitBox = (objectData.content\n .tilesWithHitBox as string)\n .split(',')\n .filter((id) => !!id)\n .map((idAsString) => parseInt(idAsString, 10));\n this._tileMapManager = gdjs.TileMap.TileMapRuntimeManager.getManager(\n instanceContainer\n );\n this._renderer = new gdjs.TileMapRuntimeObjectRenderer(\n this,\n instanceContainer\n );\n\n // *ALWAYS* call `this.onCreated()` at the very end of your object constructor.\n this.onCreated();\n }\n\n getRendererObject() {\n return this._renderer.getRendererObject();\n }\n\n updatePreRender(instanceContainer: gdjs.RuntimeInstanceContainer): void {\n if (this._isTileMapDirty) {\n let shouldContinue = true;\n this._tileMapManager.getOrLoadSimpleTileMapTextureCache(\n (textureName) => {\n return (this.getInstanceContainer()\n .getGame()\n .getImageManager()\n .getPIXITexture(textureName) as unknown) as PIXI.BaseTexture<\n PIXI.Resource\n >;\n },\n this._atlasImage,\n this._tileSize,\n this._columnCount,\n this._rowCount,\n (textureCache: TileMapHelper.TileTextureCache | null) => {\n if (!textureCache) {\n // getOrLoadTextureCache already log warns and errors.\n return;\n }\n this._renderer.refreshPixiTileMap(textureCache);\n },\n (error) => {\n shouldContinue = false;\n console.error(\n `Could not load texture cache for atlas ${this._atlasImage} during prerender. The tilemap might be badly configured or an issues happened with the loaded atlas image:`,\n error\n );\n }\n );\n if (!shouldContinue) return;\n if (this._collisionTileMap) {\n const tileMap = this._renderer.getTileMap();\n if (tileMap) this._collisionTileMap.updateFromTileMap(tileMap);\n }\n this._isTileMapDirty = false;\n }\n }\n\n updateFromObjectData(\n oldObjectData: SimpleTileMapObjectData,\n newObjectData: SimpleTileMapObjectData\n ): boolean {\n if (oldObjectData.content.opacity !== newObjectData.content.opacity) {\n this.setOpacity(newObjectData.content.opacity);\n }\n if (\n oldObjectData.content.atlasImage !== newObjectData.content.atlasImage\n ) {\n // TODO: support changing the atlas texture\n return false;\n }\n // Map content is updated at hot-reload by extraInitializationFromInitialInstance.\n return true;\n }\n\n getNetworkSyncData(): SimpleTileMapNetworkSyncData {\n return {\n ...super.getNetworkSyncData(),\n op: this._opacity,\n ai: this._atlasImage,\n wid: this.getWidth(),\n hei: this.getHeight(),\n };\n }\n\n updateFromNetworkSyncData(\n networkSyncData: SimpleTileMapNetworkSyncData\n ): void {\n super.updateFromNetworkSyncData(networkSyncData);\n\n if (\n networkSyncData.op !== undefined &&\n networkSyncData.op !== this._opacity\n ) {\n this.setOpacity(networkSyncData.op);\n }\n if (\n networkSyncData.wid !== undefined &&\n networkSyncData.wid !== this.getWidth()\n ) {\n this.setWidth(networkSyncData.wid);\n }\n if (\n networkSyncData.hei !== undefined &&\n networkSyncData.hei !== this.getHeight()\n ) {\n this.setHeight(networkSyncData.hei);\n }\n if (networkSyncData.ai !== undefined) {\n // TODO: support changing the atlas texture\n }\n }\n\n extraInitializationFromInitialInstance(\n initialInstanceData: InstanceData\n ): void {\n // 1. load the tilemap from the instance.\n for (const property of initialInstanceData.stringProperties) {\n if (property.name === 'tilemap') {\n this._initialTileMapAsJsObject = JSON.parse(property.value);\n }\n }\n\n // 2. Update the renderer so that it updates the tilemap object\n // (used for width and position calculations).\n this._loadInitialTileMap((tileMap: TileMapHelper.EditableTileMap) => {\n // 3. Set custom dimensions & opacity if applicable.\n if (initialInstanceData.customSize) {\n this.setWidth(initialInstanceData.width);\n this.setHeight(initialInstanceData.height);\n }\n if (initialInstanceData.opacity !== undefined) {\n this.setOpacity(initialInstanceData.opacity);\n }\n\n // 4. Update position (calculations based on renderer's dimensions).\n this._renderer.updatePosition();\n\n if (this._collisionTileMap) {\n // If collision tile map is already defined, there's a good chance it means\n // extraInitializationFromInitialInstance is called when hot reloading the\n // scene so the collision is tile map is updated instead of being re-created.\n this._collisionTileMap.updateFromTileMap(tileMap);\n } else {\n this._collisionTileMap = new gdjs.TileMap.TransformedCollisionTileMap(\n tileMap,\n this._hitBoxTag\n );\n }\n\n this.updateTransformation();\n });\n }\n\n private _loadInitialTileMap(\n tileMapLoadingCallback: (tileMap: TileMapHelper.EditableTileMap) => void\n ): void {\n if (!this._initialTileMapAsJsObject) return;\n if (this._columnCount <= 0 || this._rowCount <= 0) {\n console.error(\n `Tilemap object ${this.name} is not configured properly.`\n );\n return;\n }\n\n this._tileMapManager.getOrLoadSimpleTileMap(\n this._initialTileMapAsJsObject,\n this.name,\n this._tileSize,\n this._columnCount,\n this._rowCount,\n (tileMap: TileMapHelper.EditableTileMap) => {\n this._initialTilesWithHitBox.forEach((tileId) => {\n const tileDefinition = tileMap.getTileDefinition(tileId);\n if (!tileDefinition) {\n console.warn(\n `Could not set hit box for tile with id ${tileId}. Continuing.`\n );\n return;\n }\n tileDefinition.addHitBox(\n this._hitBoxTag,\n [\n [0, 0],\n [0, tileMap.getTileHeight()],\n [tileMap.getTileWidth(), tileMap.getTileHeight()],\n [tileMap.getTileWidth(), 0],\n ],\n true\n );\n });\n\n this._tileMapManager.getOrLoadSimpleTileMapTextureCache(\n (textureName) => {\n return (this.getInstanceContainer()\n .getGame()\n .getImageManager()\n .getPIXITexture(textureName) as unknown) as PIXI.BaseTexture<\n PIXI.Resource\n >;\n },\n this._atlasImage,\n this._tileSize,\n this._columnCount,\n this._rowCount,\n (textureCache: TileMapHelper.TileTextureCache | null) => {\n if (!textureCache) {\n // getOrLoadTextureCache already log warns and errors.\n return;\n }\n this._renderer.updatePixiTileMap(tileMap, textureCache);\n tileMapLoadingCallback(tileMap);\n },\n (error) => {\n console.error(\n `Could not load texture cache for atlas ${this._atlasImage} during initial loading. The tilemap might be badly configured or an issues happened with the loaded atlas image:`,\n error\n );\n }\n );\n }\n );\n }\n\n onDestroyed(): void {\n super.onDestroyed();\n this._renderer.destroy();\n }\n\n setWidth(width: float): void {\n if (this.getWidth() === width) return;\n\n this._transformationIsUpToDate = false;\n this._renderer.setWidth(width);\n this.invalidateHitboxes();\n }\n\n setHeight(height: float): void {\n if (this.getHeight() === height) return;\n\n this._transformationIsUpToDate = false;\n this._renderer.setHeight(height);\n this.invalidateHitboxes();\n }\n\n setSize(newWidth: float, newHeight: float): void {\n this.setWidth(newWidth);\n this.setHeight(newHeight);\n this._transformationIsUpToDate = false;\n }\n\n /**\n * Get the scale of the object (or the geometric mean of the X and Y scale in case they are different).\n *\n * @return the scale of the object (or the geometric mean of the X and Y scale in case they are different).\n */\n getScale(): float {\n const scaleX = this.getScaleX();\n const scaleY = this.getScaleY();\n return scaleX === scaleY ? scaleX : Math.sqrt(scaleX * scaleY);\n }\n\n /**\n * Change the scale on X and Y axis of the object.\n *\n * @param scale The new scale (must be greater than 0).\n */\n setScale(scale: float): void {\n this.setScaleX(scale);\n this.setScaleY(scale);\n this._transformationIsUpToDate = false;\n }\n\n /**\n * Change the scale on X axis of the object (changing its width).\n *\n * @param scaleX The new scale (must be greater than 0).\n */\n setScaleX(scaleX: float): void {\n if (scaleX < 0) {\n scaleX = 0;\n }\n if (this.getScaleX() === scaleX) return;\n\n this._renderer.setScaleX(scaleX);\n this.invalidateHitboxes();\n this._transformationIsUpToDate = false;\n }\n\n /**\n * Change the scale on Y axis of the object (changing its width).\n *\n * @param scaleY The new scale (must be greater than 0).\n */\n setScaleY(scaleY: float): void {\n if (scaleY < 0) {\n scaleY = 0;\n }\n if (this.getScaleY() === scaleY) return;\n\n this._renderer.setScaleY(scaleY);\n this.invalidateHitboxes();\n this._transformationIsUpToDate = false;\n }\n\n setX(x: float): void {\n super.setX(x);\n this._renderer.updatePosition();\n this._transformationIsUpToDate = false;\n }\n\n setY(y: float): void {\n super.setY(y);\n this._renderer.updatePosition();\n this._transformationIsUpToDate = false;\n }\n\n setAngle(angle: float): void {\n super.setAngle(angle);\n this._renderer.updateAngle();\n this._transformationIsUpToDate = false;\n }\n\n setOpacity(opacity: float): void {\n this._opacity = opacity;\n this._renderer.updateOpacity();\n this._isTileMapDirty = true;\n }\n\n getOpacity(): float {\n return this._opacity;\n }\n\n getWidth(): float {\n return this._renderer.getWidth();\n }\n\n getHeight(): float {\n return this._renderer.getHeight();\n }\n\n getScaleX(): float {\n return this._renderer.getScaleX();\n }\n\n getScaleY(): float {\n return this._renderer.getScaleY();\n }\n\n /**\n * This method is expensive and should not be called.\n * Prefer using {@link getHitBoxesAround} rather than getHitBoxes.\n */\n getHitBoxes(): gdjs.Polygon[] {\n if (this.hitBoxesDirty) {\n this.updateHitBoxes();\n this.updateAABB();\n this.hitBoxesDirty = false;\n }\n return this.hitBoxes;\n }\n\n updateHitBoxes(): void {\n this.updateTransformation();\n if (!this._collisionTileMap) return;\n this.hitBoxes = Array.from(\n this._collisionTileMap.getAllHitboxes(this._hitBoxTag)\n );\n this.hitBoxesDirty = false;\n this.updateAABB();\n }\n\n // This implementation doesn't use updateHitBoxes.\n // It's important for good performances.\n updateAABB(): void {\n if (this.getAngle() === 0) {\n // Fast computation of AABB for non rotated object\n this.aabb.min[0] = this.x;\n this.aabb.min[1] = this.y;\n this.aabb.max[0] = this.aabb.min[0] + this.getWidth();\n this.aabb.max[1] = this.aabb.min[1] + this.getHeight();\n } else {\n if (!this._collisionTileMap) return;\n const affineTransformation = this._collisionTileMap.getTransformation();\n\n const left = 0;\n const right = this._collisionTileMap.getWidth();\n const top = 0;\n const bottom = this._collisionTileMap.getHeight();\n\n const workingPoint = this.aabb.min;\n\n workingPoint[0] = left;\n workingPoint[1] = top;\n affineTransformation.transform(workingPoint, workingPoint);\n const topLeftX = workingPoint[0];\n const topLeftY = workingPoint[1];\n\n workingPoint[0] = right;\n workingPoint[1] = top;\n affineTransformation.transform(workingPoint, workingPoint);\n const topRightX = workingPoint[0];\n const topRightY = workingPoint[1];\n\n workingPoint[0] = right;\n workingPoint[1] = bottom;\n affineTransformation.transform(workingPoint, workingPoint);\n const bottomRightX = workingPoint[0];\n const bottomRightY = workingPoint[1];\n\n workingPoint[0] = left;\n workingPoint[1] = bottom;\n affineTransformation.transform(workingPoint, workingPoint);\n const bottomLeftX = workingPoint[0];\n const bottomLeftY = workingPoint[1];\n\n this.aabb.min[0] = Math.min(\n topLeftX,\n topRightX,\n bottomRightX,\n bottomLeftX\n );\n this.aabb.max[0] = Math.max(\n topLeftX,\n topRightX,\n bottomRightX,\n bottomLeftX\n );\n this.aabb.min[1] = Math.min(\n topLeftY,\n topRightY,\n bottomRightY,\n bottomLeftY\n );\n this.aabb.max[1] = Math.max(\n topLeftY,\n topRightY,\n bottomRightY,\n bottomLeftY\n );\n }\n }\n\n getHitBoxesAround(\n left: float,\n top: float,\n right: float,\n bottom: float\n ): Iterable<gdjs.Polygon> {\n // This implementation doesn't call updateHitBoxes.\n // It's important for good performances because there is no need to\n // update the whole collision mask where only a few hitboxes must be\n // checked.\n this.updateTransformation();\n if (!this._collisionTileMap) return [];\n return this._collisionTileMap.getHitboxesAround(\n this._hitBoxTag,\n left,\n top,\n right,\n bottom\n );\n }\n\n updateTransformation() {\n if (this._transformationIsUpToDate) {\n return;\n }\n const absScaleX = Math.abs(this._renderer.getScaleX());\n const absScaleY = Math.abs(this._renderer.getScaleY());\n\n this._tileMapToSceneTransformation.setToIdentity();\n\n // Translation\n this._tileMapToSceneTransformation.translate(this.getX(), this.getY());\n\n // Rotation\n const angleInRadians = (this.getAngle() * Math.PI) / 180;\n this._tileMapToSceneTransformation.rotateAround(\n angleInRadians,\n this.getCenterX(),\n this.getCenterY()\n );\n\n // Scale\n this._tileMapToSceneTransformation.scale(absScaleX, absScaleY);\n if (this._collisionTileMap) {\n const collisionTileMapTransformation = this._collisionTileMap.getTransformation();\n collisionTileMapTransformation.copyFrom(\n this._tileMapToSceneTransformation\n );\n this._collisionTileMap.setTransformation(\n collisionTileMapTransformation\n );\n }\n this._sceneToTileMapTransformation.copyFrom(\n this._tileMapToSceneTransformation\n );\n this._sceneToTileMapTransformation.invert();\n this._transformationIsUpToDate = true;\n }\n\n getSceneXCoordinateOfTileCenter(\n columnIndex: integer,\n rowIndex: integer\n ): float {\n const sceneCoordinates: FloatPoint =\n SimpleTileMapRuntimeObject.workingPoint;\n this._tileMapToSceneTransformation.transform(\n [\n (columnIndex + 0.5) * this._tileSize,\n (rowIndex + 0.5) * this._tileSize,\n ],\n sceneCoordinates\n );\n return sceneCoordinates[0];\n }\n\n getSceneYCoordinateOfTileCenter(\n columnIndex: integer,\n rowIndex: integer\n ): float {\n const sceneCoordinates: FloatPoint =\n SimpleTileMapRuntimeObject.workingPoint;\n this._tileMapToSceneTransformation.transform(\n [\n (columnIndex + 0.5) * this._tileSize,\n (rowIndex + 0.5) * this._tileSize,\n ],\n sceneCoordinates\n );\n return sceneCoordinates[1];\n }\n\n getGridCoordinatesFromSceneCoordinates(\n x: float,\n y: float\n ): [integer, integer] {\n this.updateTransformation();\n\n const gridCoordinates: FloatPoint =\n SimpleTileMapRuntimeObject.workingPoint;\n this._sceneToTileMapTransformation.transform([x, y], gridCoordinates);\n\n const columnIndex = Math.floor(gridCoordinates[0] / this._tileSize);\n const rowIndex = Math.floor(gridCoordinates[1] / this._tileSize);\n\n return [columnIndex, rowIndex];\n }\n\n getColumnIndexAtPosition(x: float, y: float): integer {\n return this.getGridCoordinatesFromSceneCoordinates(x, y)[0];\n }\n\n getRowIndexAtPosition(x: float, y: float): integer {\n return this.getGridCoordinatesFromSceneCoordinates(x, y)[1];\n }\n\n getTileAtPosition(x: float, y: float): integer {\n const [\n columnIndex,\n rowIndex,\n ] = this.getGridCoordinatesFromSceneCoordinates(x, y);\n return this.getTileAtGridCoordinates(columnIndex, rowIndex);\n }\n\n getTileAtGridCoordinates(columnIndex: integer, rowIndex: integer): integer {\n return this._renderer.getTileId(columnIndex, rowIndex, 0);\n }\n\n setTileAtPosition(tileId: number, x: float, y: float) {\n const [\n columnIndex,\n rowIndex,\n ] = this.getGridCoordinatesFromSceneCoordinates(x, y);\n this.setTileAtGridCoordinates(tileId, columnIndex, rowIndex);\n }\n\n setTileAtGridCoordinates(\n tileId: number,\n columnIndex: integer,\n rowIndex: integer\n ) {\n const tileMap = this._renderer._tileMap;\n if (!tileMap) {\n return;\n }\n const layer = tileMap.getTileLayer(this._layerIndex);\n if (!layer) {\n return;\n }\n const oldTileId = layer.getTileId(columnIndex, rowIndex);\n if (tileId === oldTileId) {\n return;\n }\n layer.setTile(columnIndex, rowIndex, tileId);\n\n if (this._collisionTileMap) {\n const oldTileDefinition =\n oldTileId !== undefined && tileMap.getTileDefinition(oldTileId);\n const newTileDefinition = tileMap.getTileDefinition(tileId);\n const hadFullHitBox =\n !!oldTileDefinition &&\n oldTileDefinition.hasFullHitBox(this._hitBoxTag);\n const haveFullHitBox =\n !!newTileDefinition &&\n newTileDefinition.hasFullHitBox(this._hitBoxTag);\n if (hadFullHitBox !== haveFullHitBox) {\n this._collisionTileMap.invalidateTile(\n this._layerIndex,\n columnIndex,\n rowIndex\n );\n }\n }\n this._isTileMapDirty = true;\n this.invalidateHitboxes();\n }\n\n flipTileOnYAtPosition(x: float, y: float, flip: boolean) {\n const [\n columnIndex,\n rowIndex,\n ] = this.getGridCoordinatesFromSceneCoordinates(x, y);\n this.flipTileOnYAtGridCoordinates(columnIndex, rowIndex, flip);\n }\n\n flipTileOnXAtPosition(x: float, y: float, flip: boolean) {\n const [\n columnIndex,\n rowIndex,\n ] = this.getGridCoordinatesFromSceneCoordinates(x, y);\n this.flipTileOnXAtGridCoordinates(columnIndex, rowIndex, flip);\n }\n\n flipTileOnYAtGridCoordinates(\n columnIndex: integer,\n rowIndex: integer,\n flip: boolean\n ) {\n this._renderer.flipTileOnY(columnIndex, rowIndex, 0, flip);\n this._isTileMapDirty = true;\n // No need to invalidate hit boxes since at the moment, collision mask\n // cannot be configured on each tile.\n }\n\n flipTileOnXAtGridCoordinates(\n columnIndex: integer,\n rowIndex: integer,\n flip: boolean\n ) {\n this._renderer.flipTileOnX(columnIndex, rowIndex, 0, flip);\n this._isTileMapDirty = true;\n // No need to invalidate hit boxes since at the moment, collision mask\n // cannot be configured on each tile.\n }\n\n isTileFlippedOnXAtPosition(x: float, y: float) {\n const [\n columnIndex,\n rowIndex,\n ] = this.getGridCoordinatesFromSceneCoordinates(x, y);\n\n return this._renderer.isTileFlippedOnX(columnIndex, rowIndex, 0);\n }\n\n isTileFlippedOnXAtGridCoordinates(columnIndex: integer, rowIndex: integer) {\n return this._renderer.isTileFlippedOnX(columnIndex, rowIndex, 0);\n }\n\n isTileFlippedOnYAtPosition(x: float, y: float) {\n const [\n columnIndex,\n rowIndex,\n ] = this.getGridCoordinatesFromSceneCoordinates(x, y);\n\n return this._renderer.isTileFlippedOnY(columnIndex, rowIndex, 0);\n }\n\n isTileFlippedOnYAtGridCoordinates(columnIndex: integer, rowIndex: integer) {\n return this._renderer.isTileFlippedOnY(columnIndex, rowIndex, 0);\n }\n\n removeTileAtPosition(x: float, y: float) {\n const [\n columnIndex,\n rowIndex,\n ] = this.getGridCoordinatesFromSceneCoordinates(x, y);\n this.removeTileAtGridCoordinates(columnIndex, rowIndex);\n }\n\n removeTileAtGridCoordinates(columnIndex: integer, rowIndex: integer) {\n const tileMap = this._renderer._tileMap;\n if (!tileMap) {\n return;\n }\n const layer = tileMap.getTileLayer(this._layerIndex);\n if (!layer) {\n return;\n }\n const oldTileId = layer.getTileId(columnIndex, rowIndex);\n if (oldTileId === undefined) {\n return;\n }\n layer.removeTile(columnIndex, rowIndex);\n if (this._collisionTileMap) {\n this._collisionTileMap.invalidateTile(\n this._layerIndex,\n columnIndex,\n rowIndex\n );\n }\n this._isTileMapDirty = true;\n this.invalidateHitboxes();\n }\n\n setGridRowCount(targetRowCount: integer) {\n if (targetRowCount <= 0) return;\n this._renderer.setGridRowCount(targetRowCount);\n this._isTileMapDirty = true;\n this.invalidateHitboxes();\n }\n\n setGridColumnCount(targetColumnCount: integer) {\n if (targetColumnCount <= 0) return;\n this._renderer.setGridColumnCount(targetColumnCount);\n this._isTileMapDirty = true;\n this.invalidateHitboxes();\n }\n\n getGridRowCount(): integer {\n return this._renderer.getGridRowCount();\n }\n\n getGridColumnCount(): integer {\n return this._renderer.getGridColumnCount();\n }\n\n getTilesetColumnCount(): integer {\n return this._columnCount;\n }\n\n getTilesetRowCount(): integer {\n return this._rowCount;\n }\n }\n gdjs.registerObject(\n 'TileMap::SimpleTileMap',\n gdjs.SimpleTileMapRuntimeObject\n );\n}\n"],
|
|
5
|
-
"mappings": "AACA,GAAU,MAAV,UAAU,EAAV,CA6BS,qBACG,GAAK,aACiD,CA0B9D,YACE,EACA,EACA,CACA,MAAM,EAAmB,
|
|
4
|
+
"sourcesContent": ["/// <reference path=\"helper/TileMapHelper.d.ts\" />\nnamespace gdjs {\n export type SimpleTileMapObjectDataType = {\n content: {\n opacity: number;\n atlasImage: string;\n rowCount: number;\n columnCount: number;\n tileSize: number;\n tilesWithHitBox: string;\n };\n };\n\n export type SimpleTileMapObjectData = ObjectData &\n SimpleTileMapObjectDataType;\n\n export type SimpleTileMapNetworkSyncDataType = {\n op: number;\n ai: string;\n wid: number;\n hei: number;\n // TODO: Support tilemap synchronization. Find an efficient way to send tiles changes.\n };\n\n export type SimpleTileMapNetworkSyncData = ObjectNetworkSyncData &\n SimpleTileMapNetworkSyncDataType;\n\n /**\n * Displays a SimpleTileMap object.\n */\n export class SimpleTileMapRuntimeObject\n extends gdjs.RuntimeObject\n implements gdjs.Resizable, gdjs.Scalable, gdjs.OpacityHandler {\n /**\n * A reusable Point to avoid allocations.\n */\n private static readonly workingPoint: FloatPoint = [0, 0];\n\n _opacity: float = 255;\n _atlasImage: string;\n _tileMapManager: gdjs.TileMap.TileMapRuntimeManager;\n _renderer: gdjs.TileMapRuntimeObjectPixiRenderer;\n readonly _rowCount: number;\n readonly _columnCount: number;\n readonly _tileSize: number;\n _displayMode = 'all';\n _layerIndex = 0;\n _initialTileMapAsJsObject: TileMapHelper.EditableTileMapAsJsObject;\n readonly _initialTilesWithHitBox: number[];\n _isTileMapDirty: boolean = false;\n _sceneToTileMapTransformation: gdjs.AffineTransformation = new gdjs.AffineTransformation();\n _tileMapToSceneTransformation: gdjs.AffineTransformation = new gdjs.AffineTransformation();\n _collisionTileMap: gdjs.TileMap.TransformedCollisionTileMap | null = null;\n _hitBoxTag: string = 'collision';\n private _transformationIsUpToDate: boolean = false;\n\n // TODO: Add a debug mode like for TileMapCollisionMaskRuntimeObject to draw?\n\n constructor(\n instanceContainer: gdjs.RuntimeInstanceContainer,\n objectData: SimpleTileMapObjectDataType\n ) {\n super(instanceContainer, objectData);\n this._opacity = objectData.content.opacity;\n this._atlasImage = objectData.content.atlasImage;\n this._rowCount = objectData.content.rowCount;\n this._columnCount = objectData.content.columnCount;\n this._tileSize = objectData.content.tileSize;\n this._initialTileMapAsJsObject = {\n tileWidth: this._tileSize,\n tileHeight: this._tileSize,\n dimX: 1,\n dimY: 1,\n layers: [{ id: 0, alpha: this._opacity / 255, tiles: [] }],\n };\n this._initialTilesWithHitBox = (objectData.content\n .tilesWithHitBox as string)\n .split(',')\n .filter((id) => !!id)\n .map((idAsString) => parseInt(idAsString, 10));\n this._tileMapManager = gdjs.TileMap.TileMapRuntimeManager.getManager(\n instanceContainer\n );\n this._renderer = new gdjs.TileMapRuntimeObjectRenderer(\n this,\n instanceContainer\n );\n\n this._loadInitialTileMap((tileMap: TileMapHelper.EditableTileMap) => {\n this._renderer.updatePosition();\n\n this._collisionTileMap = new gdjs.TileMap.TransformedCollisionTileMap(\n tileMap,\n this._hitBoxTag\n );\n\n this.updateTransformation();\n });\n\n // *ALWAYS* call `this.onCreated()` at the very end of your object constructor.\n this.onCreated();\n }\n\n getRendererObject() {\n return this._renderer.getRendererObject();\n }\n\n updatePreRender(instanceContainer: gdjs.RuntimeInstanceContainer): void {\n if (this._isTileMapDirty) {\n let shouldContinue = true;\n this._tileMapManager.getOrLoadSimpleTileMapTextureCache(\n (textureName) => {\n return (this.getInstanceContainer()\n .getGame()\n .getImageManager()\n .getPIXITexture(textureName) as unknown) as PIXI.BaseTexture<\n PIXI.Resource\n >;\n },\n this._atlasImage,\n this._tileSize,\n this._columnCount,\n this._rowCount,\n (textureCache: TileMapHelper.TileTextureCache | null) => {\n if (!textureCache) {\n // getOrLoadTextureCache already log warns and errors.\n return;\n }\n this._renderer.refreshPixiTileMap(textureCache);\n },\n (error) => {\n shouldContinue = false;\n console.error(\n `Could not load texture cache for atlas ${this._atlasImage} during prerender. The tilemap might be badly configured or an issues happened with the loaded atlas image:`,\n error\n );\n }\n );\n if (!shouldContinue) return;\n if (this._collisionTileMap) {\n const tileMap = this._renderer.getTileMap();\n if (tileMap) this._collisionTileMap.updateFromTileMap(tileMap);\n }\n this._isTileMapDirty = false;\n }\n }\n\n updateFromObjectData(\n oldObjectData: SimpleTileMapObjectData,\n newObjectData: SimpleTileMapObjectData\n ): boolean {\n if (oldObjectData.content.opacity !== newObjectData.content.opacity) {\n this.setOpacity(newObjectData.content.opacity);\n }\n if (\n oldObjectData.content.atlasImage !== newObjectData.content.atlasImage\n ) {\n // TODO: support changing the atlas texture\n return false;\n }\n // Map content is updated at hot-reload by extraInitializationFromInitialInstance.\n return true;\n }\n\n getNetworkSyncData(): SimpleTileMapNetworkSyncData {\n return {\n ...super.getNetworkSyncData(),\n op: this._opacity,\n ai: this._atlasImage,\n wid: this.getWidth(),\n hei: this.getHeight(),\n };\n }\n\n updateFromNetworkSyncData(\n networkSyncData: SimpleTileMapNetworkSyncData\n ): void {\n super.updateFromNetworkSyncData(networkSyncData);\n\n if (\n networkSyncData.op !== undefined &&\n networkSyncData.op !== this._opacity\n ) {\n this.setOpacity(networkSyncData.op);\n }\n if (\n networkSyncData.wid !== undefined &&\n networkSyncData.wid !== this.getWidth()\n ) {\n this.setWidth(networkSyncData.wid);\n }\n if (\n networkSyncData.hei !== undefined &&\n networkSyncData.hei !== this.getHeight()\n ) {\n this.setHeight(networkSyncData.hei);\n }\n if (networkSyncData.ai !== undefined) {\n // TODO: support changing the atlas texture\n }\n }\n\n extraInitializationFromInitialInstance(\n initialInstanceData: InstanceData\n ): void {\n // 1. load the tilemap from the instance.\n for (const property of initialInstanceData.stringProperties) {\n if (property.name === 'tilemap') {\n this._initialTileMapAsJsObject = JSON.parse(property.value);\n }\n }\n\n // 2. Update the renderer so that it updates the tilemap object\n // (used for width and position calculations).\n this._loadInitialTileMap((tileMap: TileMapHelper.EditableTileMap) => {\n // 3. Set custom dimensions & opacity if applicable.\n if (initialInstanceData.customSize) {\n this.setWidth(initialInstanceData.width);\n this.setHeight(initialInstanceData.height);\n }\n if (initialInstanceData.opacity !== undefined) {\n this.setOpacity(initialInstanceData.opacity);\n }\n\n // 4. Update position (calculations based on renderer's dimensions).\n this._renderer.updatePosition();\n\n if (this._collisionTileMap) {\n // If collision tile map is already defined, there's a good chance it means\n // extraInitializationFromInitialInstance is called when hot reloading the\n // scene so the collision is tile map is updated instead of being re-created.\n this._collisionTileMap.updateFromTileMap(tileMap);\n } else {\n this._collisionTileMap = new gdjs.TileMap.TransformedCollisionTileMap(\n tileMap,\n this._hitBoxTag\n );\n }\n\n this.updateTransformation();\n });\n }\n\n private _loadInitialTileMap(\n tileMapLoadingCallback: (tileMap: TileMapHelper.EditableTileMap) => void\n ): void {\n if (!this._initialTileMapAsJsObject) return;\n if (this._columnCount <= 0 || this._rowCount <= 0) {\n console.error(\n `Tilemap object ${this.name} is not configured properly.`\n );\n return;\n }\n\n this._tileMapManager.getOrLoadSimpleTileMap(\n this._initialTileMapAsJsObject,\n this.name,\n this._tileSize,\n this._columnCount,\n this._rowCount,\n (tileMap: TileMapHelper.EditableTileMap) => {\n this._initialTilesWithHitBox.forEach((tileId) => {\n const tileDefinition = tileMap.getTileDefinition(tileId);\n if (!tileDefinition) {\n console.warn(\n `Could not set hit box for tile with id ${tileId}. Continuing.`\n );\n return;\n }\n tileDefinition.addHitBox(\n this._hitBoxTag,\n [\n [0, 0],\n [0, tileMap.getTileHeight()],\n [tileMap.getTileWidth(), tileMap.getTileHeight()],\n [tileMap.getTileWidth(), 0],\n ],\n true\n );\n });\n\n this._tileMapManager.getOrLoadSimpleTileMapTextureCache(\n (textureName) => {\n return (this.getInstanceContainer()\n .getGame()\n .getImageManager()\n .getPIXITexture(textureName) as unknown) as PIXI.BaseTexture<\n PIXI.Resource\n >;\n },\n this._atlasImage,\n this._tileSize,\n this._columnCount,\n this._rowCount,\n (textureCache: TileMapHelper.TileTextureCache | null) => {\n if (!textureCache) {\n // getOrLoadTextureCache already log warns and errors.\n return;\n }\n this._renderer.updatePixiTileMap(tileMap, textureCache);\n tileMapLoadingCallback(tileMap);\n },\n (error) => {\n console.error(\n `Could not load texture cache for atlas ${this._atlasImage} during initial loading. The tilemap might be badly configured or an issues happened with the loaded atlas image:`,\n error\n );\n }\n );\n }\n );\n }\n\n onDestroyed(): void {\n super.onDestroyed();\n this._renderer.destroy();\n }\n\n setWidth(width: float): void {\n if (this.getWidth() === width) return;\n\n this._transformationIsUpToDate = false;\n this._renderer.setWidth(width);\n this.invalidateHitboxes();\n }\n\n setHeight(height: float): void {\n if (this.getHeight() === height) return;\n\n this._transformationIsUpToDate = false;\n this._renderer.setHeight(height);\n this.invalidateHitboxes();\n }\n\n setSize(newWidth: float, newHeight: float): void {\n this.setWidth(newWidth);\n this.setHeight(newHeight);\n this._transformationIsUpToDate = false;\n }\n\n /**\n * Get the scale of the object (or the geometric mean of the X and Y scale in case they are different).\n *\n * @return the scale of the object (or the geometric mean of the X and Y scale in case they are different).\n */\n getScale(): float {\n const scaleX = this.getScaleX();\n const scaleY = this.getScaleY();\n return scaleX === scaleY ? scaleX : Math.sqrt(scaleX * scaleY);\n }\n\n /**\n * Change the scale on X and Y axis of the object.\n *\n * @param scale The new scale (must be greater than 0).\n */\n setScale(scale: float): void {\n this.setScaleX(scale);\n this.setScaleY(scale);\n this._transformationIsUpToDate = false;\n }\n\n /**\n * Change the scale on X axis of the object (changing its width).\n *\n * @param scaleX The new scale (must be greater than 0).\n */\n setScaleX(scaleX: float): void {\n if (scaleX < 0) {\n scaleX = 0;\n }\n if (this.getScaleX() === scaleX) return;\n\n this._renderer.setScaleX(scaleX);\n this.invalidateHitboxes();\n this._transformationIsUpToDate = false;\n }\n\n /**\n * Change the scale on Y axis of the object (changing its width).\n *\n * @param scaleY The new scale (must be greater than 0).\n */\n setScaleY(scaleY: float): void {\n if (scaleY < 0) {\n scaleY = 0;\n }\n if (this.getScaleY() === scaleY) return;\n\n this._renderer.setScaleY(scaleY);\n this.invalidateHitboxes();\n this._transformationIsUpToDate = false;\n }\n\n setX(x: float): void {\n super.setX(x);\n this._renderer.updatePosition();\n this._transformationIsUpToDate = false;\n }\n\n setY(y: float): void {\n super.setY(y);\n this._renderer.updatePosition();\n this._transformationIsUpToDate = false;\n }\n\n setAngle(angle: float): void {\n super.setAngle(angle);\n this._renderer.updateAngle();\n this._transformationIsUpToDate = false;\n }\n\n setOpacity(opacity: float): void {\n this._opacity = opacity;\n this._renderer.updateOpacity();\n this._isTileMapDirty = true;\n }\n\n getOpacity(): float {\n return this._opacity;\n }\n\n getWidth(): float {\n return this._renderer.getWidth();\n }\n\n getHeight(): float {\n return this._renderer.getHeight();\n }\n\n getScaleX(): float {\n return this._renderer.getScaleX();\n }\n\n getScaleY(): float {\n return this._renderer.getScaleY();\n }\n\n /**\n * This method is expensive and should not be called.\n * Prefer using {@link getHitBoxesAround} rather than getHitBoxes.\n */\n getHitBoxes(): gdjs.Polygon[] {\n if (this.hitBoxesDirty) {\n this.updateHitBoxes();\n this.updateAABB();\n this.hitBoxesDirty = false;\n }\n return this.hitBoxes;\n }\n\n updateHitBoxes(): void {\n this.updateTransformation();\n if (!this._collisionTileMap) return;\n this.hitBoxes = Array.from(\n this._collisionTileMap.getAllHitboxes(this._hitBoxTag)\n );\n this.hitBoxesDirty = false;\n this.updateAABB();\n }\n\n // This implementation doesn't use updateHitBoxes.\n // It's important for good performances.\n updateAABB(): void {\n if (this.getAngle() === 0) {\n // Fast computation of AABB for non rotated object\n this.aabb.min[0] = this.x;\n this.aabb.min[1] = this.y;\n this.aabb.max[0] = this.aabb.min[0] + this.getWidth();\n this.aabb.max[1] = this.aabb.min[1] + this.getHeight();\n } else {\n if (!this._collisionTileMap) return;\n const affineTransformation = this._collisionTileMap.getTransformation();\n\n const left = 0;\n const right = this._collisionTileMap.getWidth();\n const top = 0;\n const bottom = this._collisionTileMap.getHeight();\n\n const workingPoint = this.aabb.min;\n\n workingPoint[0] = left;\n workingPoint[1] = top;\n affineTransformation.transform(workingPoint, workingPoint);\n const topLeftX = workingPoint[0];\n const topLeftY = workingPoint[1];\n\n workingPoint[0] = right;\n workingPoint[1] = top;\n affineTransformation.transform(workingPoint, workingPoint);\n const topRightX = workingPoint[0];\n const topRightY = workingPoint[1];\n\n workingPoint[0] = right;\n workingPoint[1] = bottom;\n affineTransformation.transform(workingPoint, workingPoint);\n const bottomRightX = workingPoint[0];\n const bottomRightY = workingPoint[1];\n\n workingPoint[0] = left;\n workingPoint[1] = bottom;\n affineTransformation.transform(workingPoint, workingPoint);\n const bottomLeftX = workingPoint[0];\n const bottomLeftY = workingPoint[1];\n\n this.aabb.min[0] = Math.min(\n topLeftX,\n topRightX,\n bottomRightX,\n bottomLeftX\n );\n this.aabb.max[0] = Math.max(\n topLeftX,\n topRightX,\n bottomRightX,\n bottomLeftX\n );\n this.aabb.min[1] = Math.min(\n topLeftY,\n topRightY,\n bottomRightY,\n bottomLeftY\n );\n this.aabb.max[1] = Math.max(\n topLeftY,\n topRightY,\n bottomRightY,\n bottomLeftY\n );\n }\n }\n\n getHitBoxesAround(\n left: float,\n top: float,\n right: float,\n bottom: float\n ): Iterable<gdjs.Polygon> {\n // This implementation doesn't call updateHitBoxes.\n // It's important for good performances because there is no need to\n // update the whole collision mask where only a few hitboxes must be\n // checked.\n this.updateTransformation();\n if (!this._collisionTileMap) return [];\n return this._collisionTileMap.getHitboxesAround(\n this._hitBoxTag,\n left,\n top,\n right,\n bottom\n );\n }\n\n updateTransformation() {\n if (this._transformationIsUpToDate) {\n return;\n }\n const absScaleX = Math.abs(this._renderer.getScaleX());\n const absScaleY = Math.abs(this._renderer.getScaleY());\n\n this._tileMapToSceneTransformation.setToIdentity();\n\n // Translation\n this._tileMapToSceneTransformation.translate(this.getX(), this.getY());\n\n // Rotation\n const angleInRadians = (this.getAngle() * Math.PI) / 180;\n this._tileMapToSceneTransformation.rotateAround(\n angleInRadians,\n this.getCenterX(),\n this.getCenterY()\n );\n\n // Scale\n this._tileMapToSceneTransformation.scale(absScaleX, absScaleY);\n if (this._collisionTileMap) {\n const collisionTileMapTransformation = this._collisionTileMap.getTransformation();\n collisionTileMapTransformation.copyFrom(\n this._tileMapToSceneTransformation\n );\n this._collisionTileMap.setTransformation(\n collisionTileMapTransformation\n );\n }\n this._sceneToTileMapTransformation.copyFrom(\n this._tileMapToSceneTransformation\n );\n this._sceneToTileMapTransformation.invert();\n this._transformationIsUpToDate = true;\n }\n\n getSceneXCoordinateOfTileCenter(\n columnIndex: integer,\n rowIndex: integer\n ): float {\n const sceneCoordinates: FloatPoint =\n SimpleTileMapRuntimeObject.workingPoint;\n this._tileMapToSceneTransformation.transform(\n [\n (columnIndex + 0.5) * this._tileSize,\n (rowIndex + 0.5) * this._tileSize,\n ],\n sceneCoordinates\n );\n return sceneCoordinates[0];\n }\n\n getSceneYCoordinateOfTileCenter(\n columnIndex: integer,\n rowIndex: integer\n ): float {\n const sceneCoordinates: FloatPoint =\n SimpleTileMapRuntimeObject.workingPoint;\n this._tileMapToSceneTransformation.transform(\n [\n (columnIndex + 0.5) * this._tileSize,\n (rowIndex + 0.5) * this._tileSize,\n ],\n sceneCoordinates\n );\n return sceneCoordinates[1];\n }\n\n getGridCoordinatesFromSceneCoordinates(\n x: float,\n y: float\n ): [integer, integer] {\n this.updateTransformation();\n\n const gridCoordinates: FloatPoint =\n SimpleTileMapRuntimeObject.workingPoint;\n this._sceneToTileMapTransformation.transform([x, y], gridCoordinates);\n\n const columnIndex = Math.floor(gridCoordinates[0] / this._tileSize);\n const rowIndex = Math.floor(gridCoordinates[1] / this._tileSize);\n\n return [columnIndex, rowIndex];\n }\n\n getColumnIndexAtPosition(x: float, y: float): integer {\n return this.getGridCoordinatesFromSceneCoordinates(x, y)[0];\n }\n\n getRowIndexAtPosition(x: float, y: float): integer {\n return this.getGridCoordinatesFromSceneCoordinates(x, y)[1];\n }\n\n getTileAtPosition(x: float, y: float): integer {\n const [\n columnIndex,\n rowIndex,\n ] = this.getGridCoordinatesFromSceneCoordinates(x, y);\n return this.getTileAtGridCoordinates(columnIndex, rowIndex);\n }\n\n getTileAtGridCoordinates(columnIndex: integer, rowIndex: integer): integer {\n return this._renderer.getTileId(columnIndex, rowIndex, 0);\n }\n\n setTileAtPosition(tileId: number, x: float, y: float) {\n const [\n columnIndex,\n rowIndex,\n ] = this.getGridCoordinatesFromSceneCoordinates(x, y);\n this.setTileAtGridCoordinates(tileId, columnIndex, rowIndex);\n }\n\n setTileAtGridCoordinates(\n tileId: number,\n columnIndex: integer,\n rowIndex: integer\n ) {\n const tileMap = this._renderer._tileMap;\n if (!tileMap) {\n return;\n }\n const layer = tileMap.getTileLayer(this._layerIndex);\n if (!layer) {\n return;\n }\n const oldTileId = layer.getTileId(columnIndex, rowIndex);\n if (tileId === oldTileId) {\n return;\n }\n layer.setTile(columnIndex, rowIndex, tileId);\n\n if (this._collisionTileMap) {\n const oldTileDefinition =\n oldTileId !== undefined && tileMap.getTileDefinition(oldTileId);\n const newTileDefinition = tileMap.getTileDefinition(tileId);\n const hadFullHitBox =\n !!oldTileDefinition &&\n oldTileDefinition.hasFullHitBox(this._hitBoxTag);\n const haveFullHitBox =\n !!newTileDefinition &&\n newTileDefinition.hasFullHitBox(this._hitBoxTag);\n if (hadFullHitBox !== haveFullHitBox) {\n this._collisionTileMap.invalidateTile(\n this._layerIndex,\n columnIndex,\n rowIndex\n );\n }\n }\n this._isTileMapDirty = true;\n this.invalidateHitboxes();\n }\n\n flipTileOnYAtPosition(x: float, y: float, flip: boolean) {\n const [\n columnIndex,\n rowIndex,\n ] = this.getGridCoordinatesFromSceneCoordinates(x, y);\n this.flipTileOnYAtGridCoordinates(columnIndex, rowIndex, flip);\n }\n\n flipTileOnXAtPosition(x: float, y: float, flip: boolean) {\n const [\n columnIndex,\n rowIndex,\n ] = this.getGridCoordinatesFromSceneCoordinates(x, y);\n this.flipTileOnXAtGridCoordinates(columnIndex, rowIndex, flip);\n }\n\n flipTileOnYAtGridCoordinates(\n columnIndex: integer,\n rowIndex: integer,\n flip: boolean\n ) {\n this._renderer.flipTileOnY(columnIndex, rowIndex, 0, flip);\n this._isTileMapDirty = true;\n // No need to invalidate hit boxes since at the moment, collision mask\n // cannot be configured on each tile.\n }\n\n flipTileOnXAtGridCoordinates(\n columnIndex: integer,\n rowIndex: integer,\n flip: boolean\n ) {\n this._renderer.flipTileOnX(columnIndex, rowIndex, 0, flip);\n this._isTileMapDirty = true;\n // No need to invalidate hit boxes since at the moment, collision mask\n // cannot be configured on each tile.\n }\n\n isTileFlippedOnXAtPosition(x: float, y: float) {\n const [\n columnIndex,\n rowIndex,\n ] = this.getGridCoordinatesFromSceneCoordinates(x, y);\n\n return this._renderer.isTileFlippedOnX(columnIndex, rowIndex, 0);\n }\n\n isTileFlippedOnXAtGridCoordinates(columnIndex: integer, rowIndex: integer) {\n return this._renderer.isTileFlippedOnX(columnIndex, rowIndex, 0);\n }\n\n isTileFlippedOnYAtPosition(x: float, y: float) {\n const [\n columnIndex,\n rowIndex,\n ] = this.getGridCoordinatesFromSceneCoordinates(x, y);\n\n return this._renderer.isTileFlippedOnY(columnIndex, rowIndex, 0);\n }\n\n isTileFlippedOnYAtGridCoordinates(columnIndex: integer, rowIndex: integer) {\n return this._renderer.isTileFlippedOnY(columnIndex, rowIndex, 0);\n }\n\n removeTileAtPosition(x: float, y: float) {\n const [\n columnIndex,\n rowIndex,\n ] = this.getGridCoordinatesFromSceneCoordinates(x, y);\n this.removeTileAtGridCoordinates(columnIndex, rowIndex);\n }\n\n removeTileAtGridCoordinates(columnIndex: integer, rowIndex: integer) {\n const tileMap = this._renderer._tileMap;\n if (!tileMap) {\n return;\n }\n const layer = tileMap.getTileLayer(this._layerIndex);\n if (!layer) {\n return;\n }\n const oldTileId = layer.getTileId(columnIndex, rowIndex);\n if (oldTileId === undefined) {\n return;\n }\n layer.removeTile(columnIndex, rowIndex);\n if (this._collisionTileMap) {\n this._collisionTileMap.invalidateTile(\n this._layerIndex,\n columnIndex,\n rowIndex\n );\n }\n this._isTileMapDirty = true;\n this.invalidateHitboxes();\n }\n\n setGridRowCount(targetRowCount: integer) {\n if (targetRowCount <= 0) return;\n this._renderer.setGridRowCount(targetRowCount);\n this._isTileMapDirty = true;\n this.invalidateHitboxes();\n }\n\n setGridColumnCount(targetColumnCount: integer) {\n if (targetColumnCount <= 0) return;\n this._renderer.setGridColumnCount(targetColumnCount);\n this._isTileMapDirty = true;\n this.invalidateHitboxes();\n }\n\n getGridRowCount(): integer {\n return this._renderer.getGridRowCount();\n }\n\n getGridColumnCount(): integer {\n return this._renderer.getGridColumnCount();\n }\n\n getTilesetColumnCount(): integer {\n return this._columnCount;\n }\n\n getTilesetRowCount(): integer {\n return this._rowCount;\n }\n }\n gdjs.registerObject(\n 'TileMap::SimpleTileMap',\n gdjs.SimpleTileMapRuntimeObject\n );\n}\n"],
|
|
5
|
+
"mappings": "AACA,GAAU,MAAV,UAAU,EAAV,CA6BS,qBACG,GAAK,aACiD,CA0B9D,YACE,EACA,EACA,CACA,MAAM,EAAmB,GAxB3B,cAAkB,IAOlB,kBAAe,MACf,iBAAc,EAGd,qBAA2B,GAC3B,mCAA2D,GAAI,GAAK,qBACpE,mCAA2D,GAAI,GAAK,qBACpE,uBAAqE,KACrE,gBAAqB,YACb,+BAAqC,GAS3C,KAAK,SAAW,EAAW,QAAQ,QACnC,KAAK,YAAc,EAAW,QAAQ,WACtC,KAAK,UAAY,EAAW,QAAQ,SACpC,KAAK,aAAe,EAAW,QAAQ,YACvC,KAAK,UAAY,EAAW,QAAQ,SACpC,KAAK,0BAA4B,CAC/B,UAAW,KAAK,UAChB,WAAY,KAAK,UACjB,KAAM,EACN,KAAM,EACN,OAAQ,CAAC,CAAE,GAAI,EAAG,MAAO,KAAK,SAAW,IAAK,MAAO,MAEvD,KAAK,wBAA2B,EAAW,QACxC,gBACA,MAAM,KACN,OAAO,AAAC,GAAO,CAAC,CAAC,GACjB,IAAI,AAAC,GAAe,SAAS,EAAY,KAC5C,KAAK,gBAAkB,EAAK,QAAQ,sBAAsB,WACxD,GAEF,KAAK,UAAY,GAAI,GAAK,6BACxB,KACA,GAGF,KAAK,oBAAoB,AAAC,GAA2C,CACnE,KAAK,UAAU,iBAEf,KAAK,kBAAoB,GAAI,GAAK,QAAQ,4BACxC,EACA,KAAK,YAGP,KAAK,yBAIP,KAAK,YAGP,mBAAoB,CAClB,MAAO,MAAK,UAAU,oBAGxB,gBAAgB,EAAwD,CACtE,GAAI,KAAK,gBAAiB,CACxB,GAAI,GAAiB,GA6BrB,GA5BA,KAAK,gBAAgB,mCACnB,AAAC,GACS,KAAK,uBACV,UACA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,GAGhE,kCAAkC,EAAsB,EAAmB,CACzE,MAAO,MAAK,UAAU,iBAAiB,EAAa,EAAU,GAGhE,qBAAqB,EAAU,EAAU,CACvC,KAAM,CACJ,EACA,GACE,KAAK,uCAAuC,EAAG,GACnD,KAAK,4BAA4B,EAAa,GAGhD,4BAA4B,EAAsB,EAAmB,CACnE,KAAM,GAAU,KAAK,UAAU,SAC/B,GAAI,CAAC,EACH,OAEF,KAAM,GAAQ,EAAQ,aAAa,KAAK,aAKxC,AAJI,CAAC,GAID,AADc,EAAM,UAAU,EAAa,KAC7B,QAGlB,GAAM,WAAW,EAAa,GAC1B,KAAK,mBACP,KAAK,kBAAkB,eACrB,KAAK,YACL,EACA,GAGJ,KAAK,gBAAkB,GACvB,KAAK,sBAGP,gBAAgB,EAAyB,CACvC,AAAI,GAAkB,GACtB,MAAK,UAAU,gBAAgB,GAC/B,KAAK,gBAAkB,GACvB,KAAK,sBAGP,mBAAmB,EAA4B,CAC7C,AAAI,GAAqB,GACzB,MAAK,UAAU,mBAAmB,GAClC,KAAK,gBAAkB,GACvB,KAAK,sBAGP,iBAA2B,CACzB,MAAO,MAAK,UAAU,kBAGxB,oBAA8B,CAC5B,MAAO,MAAK,UAAU,qBAGxB,uBAAiC,CAC/B,MAAO,MAAK,aAGd,oBAA8B,CAC5B,MAAO,MAAK,YAlyBT,QAMmB,AANnB,EAMmB,aAA2B,CAAC,EAAG,GANlD,EAAM,6BAqyBb,EAAK,eACH,yBACA,EAAK,8BAp0BC",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var gdjs;(function(
|
|
1
|
+
var gdjs;(function(d){const a=new d.Logger("Model3DManager"),i=["model3D"];class l{constructor(r){this._loadedThreeModels=new d.ResourceCache;this._downloadedArrayBuffers=new d.ResourceCache;this._loader=null;this._dracoLoader=null;if(this._resourceLoader=r,typeof THREE!="undefined"){this._loader=new THREE_ADDONS.GLTFLoader,this._dracoLoader=new THREE_ADDONS.DRACOLoader,this._dracoLoader.setDecoderPath("./pixi-renderers/draco/gltf/"),this._loader.setDRACOLoader(this._dracoLoader);const e=new THREE.Group;e.add(new THREE.Mesh(new THREE.BoxGeometry(1,1,1),new THREE.MeshBasicMaterial({color:"#ff00ff"}))),this._invalidModel={scene:e,animations:[],cameras:[],scenes:[],asset:{},userData:{},parser:null}}}getResourceKinds(){return i}async processResource(r){const e=this._resourceLoader.getResource(r);if(!e){a.warn('Unable to find texture for resource "'+r+'".');return}const t=this._loader;if(!t)return;const s=this._downloadedArrayBuffers.get(e);if(!!s){this._downloadedArrayBuffers.delete(e);try{const o=await t.parseAsync(s,"");this._loadedThreeModels.set(e,o)}catch(o){a.error("Can't fetch the 3D model file "+e.file+", error: "+o)}}}async loadResource(r){const e=this._resourceLoader.getResource(r);if(!e){a.warn('Unable to find texture for resource "'+r+'".');return}if(!this._loader||this._loadedThreeModels.get(e))return;const s=this._resourceLoader.getFullUrl(e.file);try{const o=await fetch(s,{credentials:this._resourceLoader.checkIfCredentialsRequired(s)?"include":"omit"});if(!o.ok)throw new Error("Network response was not ok");const n=await o.arrayBuffer();this._downloadedArrayBuffers.set(e,n)}catch(o){a.error("Can't fetch the 3D model file "+e.file+", error: "+o)}}getModel(r){return this._loadedThreeModels.getFromName(r)||this._invalidModel}dispose(){this._loadedThreeModels.clear(),this._downloadedArrayBuffers.clear(),this._loader=null,this._dracoLoader=null,this._invalidModel&&(this._invalidModel.cameras=[],this._invalidModel.animations=[],this._invalidModel.scenes=[],this._invalidModel.userData={},this._invalidModel.asset={},this._invalidModel.scene.clear())}}d.Model3DManager=l})(gdjs||(gdjs={}));
|
|
2
2
|
//# sourceMappingURL=Model3DManager.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../GDevelop/GDJS/Runtime/Model3DManager.ts"],
|
|
4
|
-
"sourcesContent": ["/*\n * GDevelop JS Platform\n * Copyright 2013-present Florian Rival (Florian.Rival@gmail.com). All rights reserved.\n * This project is released under the MIT License.\n */\nnamespace gdjs {\n const logger = new gdjs.Logger('Model3DManager');\n\n const resourceKinds: Array<ResourceKind> = ['model3D'];\n\n /**\n * Load GLB files (using `Three.js`), using the \"model3D\" resources\n * registered in the game resources.\n */\n export class Model3DManager implements gdjs.ResourceManager {\n /**\n * Map associating a resource name to the loaded Three.js model.\n */\n private _loadedThreeModels = new gdjs.ResourceCache<THREE_ADDONS.GLTF>();\n private _downloadedArrayBuffers = new gdjs.ResourceCache<ArrayBuffer>();\n\n _resourceLoader: gdjs.ResourceLoader;\n\n _loader: THREE_ADDONS.GLTFLoader | null = null;\n _dracoLoader: THREE_ADDONS.DRACOLoader | null = null;\n\n //@ts-ignore Can only be null if THREE is not loaded.\n _invalidModel: THREE_ADDONS.GLTF;\n\n /**\n * @param resourceDataArray The resources data of the game.\n * @param resourceLoader The resources loader of the game.\n */\n constructor(resourceLoader: gdjs.ResourceLoader) {\n this._resourceLoader = resourceLoader;\n\n if (typeof THREE !== 'undefined') {\n this._loader = new THREE_ADDONS.GLTFLoader();\n\n this._dracoLoader = new THREE_ADDONS.DRACOLoader();\n this._dracoLoader.setDecoderPath('./pixi-renderers/draco/gltf/');\n this._loader.setDRACOLoader(this._dracoLoader);\n\n /**\n * The invalid model is a box with magenta (#ff00ff) faces, to be\n * easily spotted if rendered on screen.\n */\n const group = new THREE.Group();\n group.add(\n new THREE.Mesh(\n new THREE.BoxGeometry(1, 1, 1),\n new THREE.MeshBasicMaterial({ color: '#ff00ff' })\n )\n );\n this._invalidModel = {\n scene: group,\n animations: [],\n cameras: [],\n scenes: [],\n asset: {},\n userData: {},\n //@ts-ignore\n parser: null,\n };\n }\n }\n\n getResourceKinds(): ResourceKind[] {\n return resourceKinds;\n }\n\n async processResource(resourceName: string): Promise<void> {\n const resource = this._resourceLoader.getResource(resourceName);\n if (!resource) {\n logger.warn(\n 'Unable to find texture for resource \"' + resourceName + '\".'\n );\n return;\n }\n const loader = this._loader;\n if (!loader) {\n return;\n }\n const data = this._downloadedArrayBuffers.get(resource);\n if (!data) {\n return;\n }\n this._downloadedArrayBuffers.delete(resource);\n try {\n const gltf: THREE_ADDONS.GLTF = await loader.parseAsync(data, '');\n this._loadedThreeModels.set(resource, gltf);\n } catch (error) {\n logger.error(\n \"Can't fetch the 3D model file \" + resource.file + ', error: ' + error\n );\n }\n }\n\n async loadResource(resourceName: string): Promise<void> {\n const resource = this._resourceLoader.getResource(resourceName);\n if (!resource) {\n logger.warn(\n 'Unable to find texture for resource \"' + resourceName + '\".'\n );\n return;\n }\n const loader = this._loader;\n if (!loader) {\n return;\n }\n if (this._loadedThreeModels.get(resource)) {\n return;\n }\n const url = this._resourceLoader.getFullUrl(resource.file);\n try {\n const response = await fetch(url, {\n credentials: this._resourceLoader.checkIfCredentialsRequired(url)\n ? 'include'\n : 'omit',\n });\n if (!response.ok) {\n throw new Error('Network response was not ok');\n }\n const data = await response.arrayBuffer();\n this._downloadedArrayBuffers.set(resource, data);\n } catch (error) {\n logger.error(\n \"Can't fetch the 3D model file \" + resource.file + ', error: ' + error\n );\n }\n }\n\n /**\n * Return a 3D model.\n *\n * Caller should not modify the object but clone it.\n *\n * @param resourceName The name of the json resource.\n * @returns a 3D model if it exists.\n */\n getModel(resourceName: string): THREE_ADDONS.GLTF {\n return (\n this._loadedThreeModels.getFromName(resourceName) || this._invalidModel\n );\n }\n }\n}\n"],
|
|
5
|
-
"mappings": "AAKA,GAAU,MAAV,UAAU,EAAV,CACE,KAAM,GAAS,GAAI,GAAK,OAAO,kBAEzB,EAAqC,CAAC,WAMrC,OAAqD,CAmB1D,YAAY,EAAqC,CAfzC,wBAAqB,GAAI,GAAK,cAC9B,6BAA0B,GAAI,GAAK,cAI3C,aAA0C,KAC1C,kBAAgD,KAY9C,GAFA,KAAK,gBAAkB,EAEnB,MAAO,QAAU,YAAa,CAChC,KAAK,QAAU,GAAI,cAAa,WAEhC,KAAK,aAAe,GAAI,cAAa,Y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AK,mBAAmB,YAAY,IAAiB,KAAK,
|
|
4
|
+
"sourcesContent": ["/*\n * GDevelop JS Platform\n * Copyright 2013-present Florian Rival (Florian.Rival@gmail.com). All rights reserved.\n * This project is released under the MIT License.\n */\nnamespace gdjs {\n const logger = new gdjs.Logger('Model3DManager');\n\n const resourceKinds: Array<ResourceKind> = ['model3D'];\n\n /**\n * Load GLB files (using `Three.js`), using the \"model3D\" resources\n * registered in the game resources.\n */\n export class Model3DManager implements gdjs.ResourceManager {\n /**\n * Map associating a resource name to the loaded Three.js model.\n */\n private _loadedThreeModels = new gdjs.ResourceCache<THREE_ADDONS.GLTF>();\n private _downloadedArrayBuffers = new gdjs.ResourceCache<ArrayBuffer>();\n\n _resourceLoader: gdjs.ResourceLoader;\n\n _loader: THREE_ADDONS.GLTFLoader | null = null;\n _dracoLoader: THREE_ADDONS.DRACOLoader | null = null;\n\n //@ts-ignore Can only be null if THREE is not loaded.\n _invalidModel: THREE_ADDONS.GLTF;\n\n /**\n * @param resourceDataArray The resources data of the game.\n * @param resourceLoader The resources loader of the game.\n */\n constructor(resourceLoader: gdjs.ResourceLoader) {\n this._resourceLoader = resourceLoader;\n\n if (typeof THREE !== 'undefined') {\n this._loader = new THREE_ADDONS.GLTFLoader();\n\n this._dracoLoader = new THREE_ADDONS.DRACOLoader();\n this._dracoLoader.setDecoderPath('./pixi-renderers/draco/gltf/');\n this._loader.setDRACOLoader(this._dracoLoader);\n\n /**\n * The invalid model is a box with magenta (#ff00ff) faces, to be\n * easily spotted if rendered on screen.\n */\n const group = new THREE.Group();\n group.add(\n new THREE.Mesh(\n new THREE.BoxGeometry(1, 1, 1),\n new THREE.MeshBasicMaterial({ color: '#ff00ff' })\n )\n );\n this._invalidModel = {\n scene: group,\n animations: [],\n cameras: [],\n scenes: [],\n asset: {},\n userData: {},\n //@ts-ignore\n parser: null,\n };\n }\n }\n\n getResourceKinds(): ResourceKind[] {\n return resourceKinds;\n }\n\n async processResource(resourceName: string): Promise<void> {\n const resource = this._resourceLoader.getResource(resourceName);\n if (!resource) {\n logger.warn(\n 'Unable to find texture for resource \"' + resourceName + '\".'\n );\n return;\n }\n const loader = this._loader;\n if (!loader) {\n return;\n }\n const data = this._downloadedArrayBuffers.get(resource);\n if (!data) {\n return;\n }\n this._downloadedArrayBuffers.delete(resource);\n try {\n const gltf: THREE_ADDONS.GLTF = await loader.parseAsync(data, '');\n this._loadedThreeModels.set(resource, gltf);\n } catch (error) {\n logger.error(\n \"Can't fetch the 3D model file \" + resource.file + ', error: ' + error\n );\n }\n }\n\n async loadResource(resourceName: string): Promise<void> {\n const resource = this._resourceLoader.getResource(resourceName);\n if (!resource) {\n logger.warn(\n 'Unable to find texture for resource \"' + resourceName + '\".'\n );\n return;\n }\n const loader = this._loader;\n if (!loader) {\n return;\n }\n if (this._loadedThreeModels.get(resource)) {\n return;\n }\n const url = this._resourceLoader.getFullUrl(resource.file);\n try {\n const response = await fetch(url, {\n credentials: this._resourceLoader.checkIfCredentialsRequired(url)\n ? 'include'\n : 'omit',\n });\n if (!response.ok) {\n throw new Error('Network response was not ok');\n }\n const data = await response.arrayBuffer();\n this._downloadedArrayBuffers.set(resource, data);\n } catch (error) {\n logger.error(\n \"Can't fetch the 3D model file \" + resource.file + ', error: ' + error\n );\n }\n }\n\n /**\n * Return a 3D model.\n *\n * Caller should not modify the object but clone it.\n *\n * @param resourceName The name of the json resource.\n * @returns a 3D model if it exists.\n */\n getModel(resourceName: string): THREE_ADDONS.GLTF {\n return (\n this._loadedThreeModels.getFromName(resourceName) || this._invalidModel\n );\n }\n\n /**\n * To be called when the game is disposed.\n * Clear the models, resources loaded and destroy 3D models loaders in this manager.\n */\n dispose(): void {\n this._loadedThreeModels.clear();\n this._downloadedArrayBuffers.clear();\n this._loader = null;\n this._dracoLoader = null;\n\n if (this._invalidModel) {\n this._invalidModel.cameras = [];\n this._invalidModel.animations = [];\n this._invalidModel.scenes = [];\n this._invalidModel.userData = {};\n this._invalidModel.asset = {};\n this._invalidModel.sc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IhB,KAAK,mBAAmB,IAAI,GAC9B,OAEF,KAAM,GAAM,KAAK,gBAAgB,WAAW,EAAS,MACrD,GAAI,CACF,KAAM,GAAW,KAAM,OAAM,EAAK,CAChC,YAAa,KAAK,gBAAgB,2BAA2B,GACzD,UACA,SAEN,GAAI,CAAC,EAAS,GACZ,KAAM,IAAI,OAAM,+BAElB,KAAM,GAAO,KAAM,GAAS,cAC5B,KAAK,wBAAwB,IAAI,EAAU,SACpC,EAAP,CACA,EAAO,MACL,iCAAmC,EAAS,KAAO,YAAc,IAavE,SAAS,EAAyC,CAChD,MACE,MAAK,mBAAmB,YAAY,IAAiB,KAAK,cAQ9D,SAAgB,CACd,KAAK,mBAAmB,QACxB,KAAK,wBAAwB,QAC7B,KAAK,QAAU,KACf,KAAK,aAAe,KAEhB,KAAK,eACP,MAAK,cAAc,QAAU,GAC7B,KAAK,cAAc,WAAa,GAChC,KAAK,cAAc,OAAS,GAC5B,KAAK,cAAc,SAAW,GAC9B,KAAK,cAAc,MAAQ,GAC3B,KAAK,cAAc,MAAM,UApJxB,EAAM,mBATL",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var gdjs;(function(i){const c=new i.Logger("ResourceLoader"),
|
|
1
|
+
var gdjs;(function(i){const c=new i.Logger("ResourceLoader"),f=(t,e,s)=>{if(t.startsWith("data:")||t.startsWith("blob:"))return t;const n=t.indexOf("?")===-1?"?":"&";return t+n+e+"="+s},_=t=>t.startsWith("https://project-resources.gdevelop.io/")||t.startsWith("https://project-resources-dev.gdevelop.io/"),g=20,R=5,d=3;class v{constructor(e){this.isFinished=!1;this.sceneName=e,this.onProgressCallbacks=new Array,this.onFinishCallbacks=new Array}registerCallback(e,s){if(this.isFinished){e();return}this.onFinishCallbacks.push(e),s&&this.onProgressCallbacks.push(s)}onProgress(e,s){for(const n of this.onProgressCallbacks)n(e,s)}onFinish(){this.isFinished=!0;for(const e of this.onFinishCallbacks)e()}}class w{constructor(e,s,n,r){this._sceneToLoadQueue=new Array;this._spineAtlasManager=null;this._spineManager=null;this.currentLoadingSceneName="";this.currentSceneLoadingProgress=0;this._isLoadingInForeground=!0;this._runtimeGame=e,this._resources=new Map,this._globalResources=n,this._sceneResources=new Map,this._sceneNamesToLoad=new Set,this._sceneNamesToMakeReady=new Set,this.setResources(s,n,r),this._imageManager=new i.ImageManager(this),this._soundManager=new i.SoundManager(this),this._fontManager=new i.FontManager(this),this._jsonManager=new i.JsonManager(this),this._bitmapFontManager=new i.BitmapFontManager(this,this._imageManager),this._model3DManager=new i.Model3DManager(this),i.SpineAtlasManager&&i.SpineManager&&(this._spineAtlasManager=new i.SpineAtlasManager(this,this._imageManager),this._spineManager=new i.SpineManager(this,this._spineAtlasManager));const a=[this._imageManager,this._soundManager,this._fontManager,this._jsonManager,this._bitmapFontManager,this._model3DManager];this._spineAtlasManager&&a.push(this._spineAtlasManager),this._spineManager&&a.push(this._spineManager),this._resourceManagersMap=new Map;for(const o of a)for(const u of o.getResourceKinds())this._resourceManagersMap.set(u,o)}getRuntimeGame(){return this._runtimeGame}setResources(e,s,n){this._globalResources=s,this._sceneResources.clear(),this._sceneNamesToLoad.clear(),this._sceneNamesToMakeReady.clear();for(const r of n)this._sceneResources.set(r.name,r.usedResources.map(a=>a.name)),this._sceneNamesToLoad.add(r.name),this._sceneNamesToMakeReady.add(r.name);this._sceneToLoadQueue.length=0;for(let r=n.length-1;r>=0;r--){const a=n[r];this._sceneToLoadQueue.push(new v(a.name))}this._resources.clear();for(const r of e)!r.file||this._resources.set(r.name,r)}async loadAllResources(e){let s=0;await h([...this._resources.values()],g,d,async n=>{await this._loadResource(n),await this._processResource(n),s++,e(s,this._resources.size)}),this._sceneNamesToLoad.clear(),this._sceneNamesToMakeReady.clear()}async loadGlobalAndFirstSceneResources(e,s){const n=this._sceneResources.get(e);if(!n){c.warn(`Can't load resource for unknown scene: "`+e+'".');return}let r=0;const a=[...this._globalResources,...n.values()];await h(a,g,d,async o=>{const u=this._resources.get(o);if(!u){c.warn('Unable to find resource "'+o+'".');return}await this._loadResource(u),await this._processResource(u),r++,s(r,a.length)}),this._setSceneAssetsLoaded(e),this._setSceneAssetsReady(e)}async loadAllSceneInBackground(){for(;this._sceneToLoadQueue.length>0;){const e=this._sceneToLoadQueue[this._sceneToLoadQueue.length-1];e!==void 0&&(this.currentLoadingSceneName=e.sceneName,this.areSceneAssetsLoaded(e.sceneName)?this._sceneToLoadQueue.pop():(await this._doLoadSceneResources(e.sceneName,async(s,n)=>e.onProgress(s,n)),this._sceneToLoadQueue.splice(this._sceneToLoadQueue.findIndex(s=>s===e),1),e.onFinish()))}this.currentLoadingSceneName=""}async _doLoadSceneResources(e,s){const n=this._sceneResources.get(e);if(!n){c.warn(`Can't load resource for unknown scene: "`+e+'".');return}let r=0;await h([...n.values()],this._isLoadingInForeground?g:R,d,async a=>{const o=this._resources.get(a);if(!o){c.warn('Unable to find resource "'+a+'".');return}await this._loadResource(o),r++,this.currentSceneLoadingProgress=r/this._resources.size,s&&await s(r,this._resources.size)}),this._setSceneAssetsLoaded(e)}async _loadResource(e){const s=this._resourceManagersMap.get(e.kind);if(!s){c.warn('Unknown resource kind: "'+e.kind+'" for: "'+e.name+'".');return}await s.loadResource(e.name)}async loadAndProcessSceneResources(e,s){if(this.areSceneAssetsReady(e))return;await this.loadSceneResources(e,s);const n=this._sceneResources.get(e);if(!n){c.warn(`Can't load resource for unknown scene: "`+e+'".');return}let r=0;for(const a of n){const o=this._resources.get(a);if(!o){c.warn('Unable to find resource "'+a+'".');continue}await this._processResource(o),r++,s&&await s(r,n.length)}this._setSceneAssetsReady(e)}async loadSceneResources(e,s){this._isLoadingInForeground=!0;const n=this._prioritizeScene(e);return new Promise((r,a)=>{if(!n){this._isLoadingInForeground=!1,r();return}n.registerCallback(()=>{this._isLoadingInForeground=!1,r()},s)})}dispose(){for(const e of this._resourceManagersMap.values())e.dispose()}_prioritizeScene(e){const s=this._sceneToLoadQueue.findIndex(r=>r.sceneName===e);if(s<0)return null;const n=this._sceneToLoadQueue[s];return this._sceneToLoadQueue.splice(s,1),this._sceneToLoadQueue.push(n),n}async _processResource(e){const s=this._resourceManagersMap.get(e.kind);if(!s){c.warn('Unknown resource kind: "'+e.kind+'" for: "'+e.name+'".');return}await s.processResource(e.name)}getSceneLoadingProgress(e){return e===this.currentLoadingSceneName?this.currentSceneLoadingProgress:this.areSceneAssetsLoaded(e)?1:0}areSceneAssetsLoaded(e){return!this._sceneNamesToLoad.has(e)}areSceneAssetsReady(e){return!this._sceneNamesToMakeReady.has(e)}_setSceneAssetsLoaded(e){this._sceneNamesToLoad.delete(e)}_setSceneAssetsReady(e){this._sceneNamesToMakeReady.delete(e)}getResource(e){return this._resources.get(e)||null}getFullUrl(e){const{gdevelopResourceToken:s}=this._runtimeGame._options;return!s||!_(e)?e:f(e,"gd_resource_token",encodeURIComponent(s))}checkIfCredentialsRequired(e){return this._runtimeGame._options.gdevelopResourceToken?!1:!!_(e)}getSoundManager(){return this._soundManager}getImageManager(){return this._imageManager}getFontManager(){return this._fontManager}getBitmapFontManager(){return this._bitmapFontManager}getJsonManager(){return this._jsonManager}getModel3DManager(){return this._model3DManager}getSpineManager(){return this._spineManager}getSpineAtlasManager(){return this._spineAtlasManager}}i.ResourceLoader=w;const p=(t,e,s)=>{const n=[],r=[];let a=0,o=0;return new Promise((u,y)=>{const m=()=>{if(t.length===0){u({results:n,errors:r});return}for(;a<e&&o<t.length;){const M=t[o++];a++,s(M).then(l=>n.push(l)).catch(l=>r.push({item:M,error:l})).finally(()=>{a--,o===t.length&&a===0?u({results:n,errors:r}):m()})}};m()})},h=async(t,e,s,n)=>{const r=await p(t,e,n);r.errors.length!==0&&c.warn("Some assets couldn't be downloaded. Trying again now.");for(let a=1;a<s&&r.errors.length!==0;a++){const o=await p(t,e,n);r.results.push.apply(r.results,o.results),r.errors=o.errors}return r}})(gdjs||(gdjs={}));
|
|
2
2
|
//# sourceMappingURL=ResourceLoader.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../GDevelop/GDJS/Runtime/ResourceLoader.ts"],
|
|
4
|
-
"sourcesContent": ["/*\n * GDevelop JS Platform\n * Copyright 2013-2023 Florian Rival (Florian.Rival@gmail.com). All rights reserved.\n * This project is released under the MIT License.\n */\nnamespace gdjs {\n const logger = new gdjs.Logger('ResourceLoader');\n\n const addSearchParameterToUrl = (\n url: string,\n urlEncodedParameterName: string,\n urlEncodedValue: string\n ) => {\n if (url.startsWith('data:') || url.startsWith('blob:')) {\n // blob/data protocol does not support search parameters, which are useless anyway.\n return url;\n }\n\n const separator = url.indexOf('?') === -1 ? '?' : '&';\n return url + separator + urlEncodedParameterName + '=' + urlEncodedValue;\n };\n\n const checkIfIsGDevelopCloudBucketUrl = (url: string): boolean => {\n return (\n url.startsWith('https://project-resources.gdevelop.io/') ||\n url.startsWith('https://project-resources-dev.gdevelop.io/')\n );\n };\n\n const maxForegroundConcurrency = 20;\n const maxBackgroundConcurrency = 5;\n const maxAttempt = 3;\n\n /**\n * A task of pre-loading resources used by a scene.\n *\n * A Promise can't be used instead of this class because a Promise will start\n * as soon as possible. It would flood the server with downloading requests\n * and make impossible to finely tune in which order scenes are actually\n * downloaded.\n */\n class SceneLoadingTask {\n sceneName: string;\n private onProgressCallbacks: Array<(count: number, total: number) => void>;\n private onFinishCallbacks: Array<() => void>;\n private isFinished = false;\n\n constructor(sceneName: string) {\n this.sceneName = sceneName;\n this.onProgressCallbacks = new Array<\n (count: number, total: number) => void\n >();\n this.onFinishCallbacks = new Array<() => void>();\n }\n\n registerCallback(\n onFinish: () => void,\n onProgress?: (count: number, total: number) => void\n ) {\n if (this.isFinished) {\n onFinish();\n return;\n }\n this.onFinishCallbacks.push(onFinish);\n if (onProgress) {\n this.onProgressCallbacks.push(onProgress);\n }\n }\n\n onProgress(count: number, total: number) {\n for (const onProgress of this.onProgressCallbacks) {\n onProgress(count, total);\n }\n }\n\n onFinish() {\n this.isFinished = true;\n for (const onFinish of this.onFinishCallbacks) {\n onFinish();\n }\n }\n }\n\n /**\n * Pre-load resources of any kind needed for a game or a scene.\n */\n export class ResourceLoader {\n _runtimeGame: RuntimeGame;\n /**\n * All the resource of a game by resource name.\n */\n private _resources: Map<string, ResourceData>;\n /**\n * Resources needed for any scene. Typically, they are resources from\n * global objects.\n */\n private _globalResources: Array<string>;\n /**\n * Resources by scene names.\n */\n private _sceneResources: Map<string, Array<string>>;\n /**\n * Keep track of which scene whose resources has already be pre-loaded.\n */\n private _sceneNamesToLoad: Set<string>;\n /**\n * Keep track of which scene whose resources has already be loaded.\n */\n private _sceneNamesToMakeReady: Set<string>;\n /**\n * A queue of scenes whose resources are still to be pre-loaded.\n */\n private _sceneToLoadQueue: Array<SceneLoadingTask> = new Array<\n SceneLoadingTask\n >();\n /**\n * The resource managers that actually download and remember downloaded\n * content.\n */\n _resourceManagersMap: Map<ResourceKind, ResourceManager>;\n private _imageManager: ImageManager;\n private _soundManager: SoundManager;\n private _fontManager: FontManager;\n private _jsonManager: JsonManager;\n private _model3DManager: Model3DManager;\n private _bitmapFontManager: BitmapFontManager;\n private _spineAtlasManager: SpineAtlasManager | null = null;\n private _spineManager: SpineManager | null = null;\n\n /**\n * Only used by events.\n */\n private currentLoadingSceneName: string = '';\n /**\n * Only used by events.\n */\n private currentSceneLoadingProgress: float = 0;\n /**\n * It's set to `true` during intermediary loading screen to use a greater\n * concurrency as the game is paused and doesn't need bandwidth (for video\n * or music streaming or online multiplayer).\n */\n private _isLoadingInForeground = true;\n\n /**\n * @param runtimeGame The game.\n * @param resourceDataArray The resources data of the game.\n * @param globalResources The resources needed for any layer.\n * @param layoutDataArray The resources used by each layer.\n */\n constructor(\n runtimeGame: RuntimeGame,\n resourceDataArray: ResourceData[],\n globalResources: Array<string>,\n layoutDataArray: Array<LayoutData>\n ) {\n this._runtimeGame = runtimeGame;\n this._resources = new Map<string, ResourceData>();\n this._globalResources = globalResources;\n\n // These 3 attributes are filled by `setResources`.\n this._sceneResources = new Map<string, Array<string>>();\n this._sceneNamesToLoad = new Set<string>();\n this._sceneNamesToMakeReady = new Set<string>();\n this.setResources(resourceDataArray, globalResources, layoutDataArray);\n\n this._imageManager = new gdjs.ImageManager(this);\n this._soundManager = new gdjs.SoundManager(this);\n this._fontManager = new gdjs.FontManager(this);\n this._jsonManager = new gdjs.JsonManager(this);\n this._bitmapFontManager = new gdjs.BitmapFontManager(\n this,\n this._imageManager\n );\n this._model3DManager = new gdjs.Model3DManager(this);\n\n // add spine related managers only if spine extension is used\n if (gdjs.SpineAtlasManager && gdjs.SpineManager) {\n this._spineAtlasManager = new gdjs.SpineAtlasManager(\n this,\n this._imageManager\n );\n this._spineManager = new gdjs.SpineManager(\n this,\n this._spineAtlasManager\n );\n }\n\n const resourceManagers: Array<ResourceManager> = [\n this._imageManager,\n this._soundManager,\n this._fontManager,\n this._jsonManager,\n this._bitmapFontManager,\n this._model3DManager,\n ];\n\n if (this._spineAtlasManager)\n resourceManagers.push(this._spineAtlasManager);\n if (this._spineManager) resourceManagers.push(this._spineManager);\n\n this._resourceManagersMap = new Map<ResourceKind, ResourceManager>();\n for (const resourceManager of resourceManagers) {\n for (const resourceKind of resourceManager.getResourceKinds()) {\n this._resourceManagersMap.set(resourceKind, resourceManager);\n }\n }\n }\n\n /**\n * @returns the runtime game instance.\n */\n getRuntimeGame(): RuntimeGame {\n return this._runtimeGame;\n }\n\n /**\n * Update the resources data of the game. Useful for hot-reloading, should\n * not be used otherwise.\n */\n setResources(\n resourceDataArray: ResourceData[],\n globalResources: Array<string>,\n layoutDataArray: Array<LayoutData>\n ): void {\n this._globalResources = globalResources;\n\n this._sceneResources.clear();\n this._sceneNamesToLoad.clear();\n this._sceneNamesToMakeReady.clear();\n for (const layoutData of layoutDataArray) {\n this._sceneResources.set(\n layoutData.name,\n layoutData.usedResources.map((resource) => resource.name)\n );\n this._sceneNamesToLoad.add(layoutData.name);\n this._sceneNamesToMakeReady.add(layoutData.name);\n }\n // TODO Clearing the queue doesn't abort the running task, but it should\n // not matter as resource loading is really fast in preview mode.\n this._sceneToLoadQueue.length = 0;\n for (let index = layoutDataArray.length - 1; index >= 0; index--) {\n const layoutData = layoutDataArray[index];\n this._sceneToLoadQueue.push(new SceneLoadingTask(layoutData.name));\n }\n\n this._resources.clear();\n for (const resourceData of resourceDataArray) {\n if (!resourceData.file) {\n // Empty string or missing `file` field: not a valid resource, let's entirely ignore it.\n // Otherwise, this can confuse some loaders that will consider an empty string different\n // than a file that happen not to fail to load.\n continue;\n }\n\n this._resources.set(resourceData.name, resourceData);\n }\n }\n\n async loadAllResources(\n onProgress: (loadingCount: integer, totalCount: integer) => void\n ): Promise<void> {\n let loadedCount = 0;\n await processAndRetryIfNeededWithPromisePool(\n [...this._resources.values()],\n maxForegroundConcurrency,\n maxAttempt,\n async (resource) => {\n await this._loadResource(resource);\n await this._processResource(resource);\n loadedCount++;\n onProgress(loadedCount, this._resources.size);\n }\n );\n this._sceneNamesToLoad.clear();\n this._sceneNamesToMakeReady.clear();\n }\n\n /**\n * Load the resources that are needed to launch the first scene.\n */\n async loadGlobalAndFirstSceneResources(\n firstSceneName: string,\n onProgress: (count: number, total: number) => void\n ): Promise<void> {\n const sceneResources = this._sceneResources.get(firstSceneName);\n if (!sceneResources) {\n logger.warn(\n 'Can\\'t load resource for unknown scene: \"' + firstSceneName + '\".'\n );\n return;\n }\n let loadedCount = 0;\n const resources = [...this._globalResources, ...sceneResources.values()];\n await processAndRetryIfNeededWithPromisePool(\n resources,\n maxForegroundConcurrency,\n maxAttempt,\n async (resourceName) => {\n const resource = this._resources.get(resourceName);\n if (!resource) {\n logger.warn('Unable to find resource \"' + resourceName + '\".');\n return;\n }\n await this._loadResource(resource);\n await this._processResource(resource);\n loadedCount++;\n onProgress(loadedCount, resources.length);\n }\n );\n this._setSceneAssetsLoaded(firstSceneName);\n this._setSceneAssetsReady(firstSceneName);\n }\n\n /**\n * Load each scene in order.\n *\n * This is done in background to try to avoid loading screens when changing\n * scenes.\n */\n async loadAllSceneInBackground(): Promise<void> {\n while (this._sceneToLoadQueue.length > 0) {\n const task = this._sceneToLoadQueue[this._sceneToLoadQueue.length - 1];\n if (task === undefined) {\n continue;\n }\n this.currentLoadingSceneName = task.sceneName;\n if (!this.areSceneAssetsLoaded(task.sceneName)) {\n await this._doLoadSceneResources(\n task.sceneName,\n async (count, total) => task.onProgress(count, total)\n );\n // A scene may have been moved last while awaiting resources to be\n // downloaded (see _prioritizeScene).\n this._sceneToLoadQueue.splice(\n this._sceneToLoadQueue.findIndex((element) => element === task),\n 1\n );\n task.onFinish();\n } else {\n this._sceneToLoadQueue.pop();\n }\n }\n this.currentLoadingSceneName = '';\n }\n\n private async _doLoadSceneResources(\n sceneName: string,\n onProgress?: (count: number, total: number) => Promise<void>\n ): Promise<void> {\n const sceneResources = this._sceneResources.get(sceneName);\n if (!sceneResources) {\n logger.warn(\n 'Can\\'t load resource for unknown scene: \"' + sceneName + '\".'\n );\n return;\n }\n let loadedCount = 0;\n await processAndRetryIfNeededWithPromisePool(\n [...sceneResources.values()],\n this._isLoadingInForeground\n ? maxForegroundConcurrency\n : maxBackgroundConcurrency,\n maxAttempt,\n async (resourceName) => {\n const resource = this._resources.get(resourceName);\n if (!resource) {\n logger.warn('Unable to find resource \"' + resourceName + '\".');\n return;\n }\n await this._loadResource(resource);\n loadedCount++;\n this.currentSceneLoadingProgress = loadedCount / this._resources.size;\n onProgress && (await onProgress(loadedCount, this._resources.size));\n }\n );\n this._setSceneAssetsLoaded(sceneName);\n }\n\n private async _loadResource(resource: ResourceData): Promise<void> {\n const resourceManager = this._resourceManagersMap.get(resource.kind);\n if (!resourceManager) {\n logger.warn(\n 'Unknown resource kind: \"' +\n resource.kind +\n '\" for: \"' +\n resource.name +\n '\".'\n );\n return;\n }\n await resourceManager.loadResource(resource.name);\n }\n\n /**\n * Load and process a scene that is needed right away.\n *\n * The renderer will show a loading screen while its done.\n */\n async loadAndProcessSceneResources(\n sceneName: string,\n onProgress?: (count: number, total: number) => Promise<void>\n ): Promise<void> {\n if (this.areSceneAssetsReady(sceneName)) {\n return;\n }\n await this.loadSceneResources(sceneName, onProgress);\n\n const sceneResources = this._sceneResources.get(sceneName);\n if (!sceneResources) {\n logger.warn(\n 'Can\\'t load resource for unknown scene: \"' + sceneName + '\".'\n );\n return;\n }\n\n let parsedCount = 0;\n for (const resourceName of sceneResources) {\n const resource = this._resources.get(resourceName);\n if (!resource) {\n logger.warn('Unable to find resource \"' + resourceName + '\".');\n continue;\n }\n await this._processResource(resource);\n parsedCount++;\n onProgress && (await onProgress(parsedCount, sceneResources.length));\n }\n this._setSceneAssetsReady(sceneName);\n }\n\n /**\n * Load a scene resources without parsing them.\n *\n * When another scene resources are loading in background, it waits for\n * all its resources to be loaded before loading resources of the given\n * scene.\n */\n async loadSceneResources(\n sceneName: string,\n onProgress?: (count: number, total: number) => void\n ): Promise<void> {\n this._isLoadingInForeground = true;\n const task = this._prioritizeScene(sceneName);\n return new Promise<void>((resolve, reject) => {\n if (!task) {\n this._isLoadingInForeground = false;\n resolve();\n return;\n }\n task.registerCallback(() => {\n this._isLoadingInForeground = false;\n resolve();\n }, onProgress);\n });\n }\n\n /**\n * Put a given scene at the end of the queue.\n *\n * When the scene that is currently loading in background is done,\n * this scene will be the next to be loaded.\n */\n private _prioritizeScene(sceneName: string): SceneLoadingTask | null {\n const taskIndex = this._sceneToLoadQueue.findIndex(\n (task) => task.sceneName === sceneName\n );\n if (taskIndex < 0) {\n // The scene is already loaded.\n return null;\n }\n const task = this._sceneToLoadQueue[taskIndex];\n this._sceneToLoadQueue.splice(taskIndex, 1);\n this._sceneToLoadQueue.push(task);\n return task;\n }\n\n private async _processResource(resource: ResourceData): Promise<void> {\n const resourceManager = this._resourceManagersMap.get(resource.kind);\n if (!resourceManager) {\n logger.warn(\n 'Unknown resource kind: \"' +\n resource.kind +\n '\" for: \"' +\n resource.name +\n '\".'\n );\n return;\n }\n await resourceManager.processResource(resource.name);\n }\n\n getSceneLoadingProgress(sceneName: string): float {\n return sceneName === this.currentLoadingSceneName\n ? this.currentSceneLoadingProgress\n : this.areSceneAssetsLoaded(sceneName)\n ? 1\n : 0;\n }\n\n /**\n * @returns true when all the resources of the given scene are loaded\n * (but maybe not parsed).\n */\n areSceneAssetsLoaded(sceneName: string): boolean {\n return !this._sceneNamesToLoad.has(sceneName);\n }\n\n /**\n * @returns true when all the resources of the given scene are loaded and\n * parsed.\n */\n areSceneAssetsReady(sceneName: string): boolean {\n return !this._sceneNamesToMakeReady.has(sceneName);\n }\n\n private _setSceneAssetsLoaded(sceneName: string): void {\n this._sceneNamesToLoad.delete(sceneName);\n }\n\n private _setSceneAssetsReady(sceneName: string): void {\n this._sceneNamesToMakeReady.delete(sceneName);\n }\n\n getResource(resourceName: string): ResourceData | null {\n return this._resources.get(resourceName) || null;\n }\n\n // Helper methods used when resources are loaded from an URL.\n\n /**\n * Complete the given URL with any specific parameter required to access\n * the resource (this can be for example a token needed to access the resource).\n */\n getFullUrl(url: string) {\n const { gdevelopResourceToken } = this._runtimeGame._options;\n if (!gdevelopResourceToken) return url;\n\n if (!checkIfIsGDevelopCloudBucketUrl(url)) return url;\n\n return addSearchParameterToUrl(\n url,\n 'gd_resource_token',\n encodeURIComponent(gdevelopResourceToken)\n );\n }\n\n /**\n * Return true if the specified URL must be loaded with cookies (\"credentials\")\n * sent to grant access to them.\n */\n checkIfCredentialsRequired(url: string) {\n if (this._runtimeGame._options.gdevelopResourceToken) return false;\n\n // Any resource stored on the GDevelop Cloud buckets needs the \"credentials\" of the user,\n // i.e: its gdevelop.io cookie, to be passed.\n // Note that this is only useful during previews.\n if (checkIfIsGDevelopCloudBucketUrl(url)) return true;\n\n // For other resources, use the default way of loading resources (\"anonymous\" or \"same-site\").\n return false;\n }\n\n /**\n * Get the gdjs.SoundManager of the RuntimeGame.\n * @return The sound manager.\n */\n getSoundManager(): gdjs.HowlerSoundManager {\n return this._soundManager;\n }\n\n /**\n * Get the gdjs.ImageManager of the RuntimeGame.\n * @return The image manager.\n */\n getImageManager(): gdjs.PixiImageManager {\n return this._imageManager;\n }\n\n /**\n * Get the gdjs.FontManager of the RuntimeGame.\n * @return The font manager.\n */\n getFontManager(): gdjs.FontFaceObserverFontManager {\n return this._fontManager;\n }\n\n /**\n * Get the gdjs.BitmapFontManager of the RuntimeGame.\n * @return The bitmap font manager.\n */\n getBitmapFontManager(): gdjs.BitmapFontManager {\n return this._bitmapFontManager;\n }\n\n /**\n * Get the JSON manager of the game, used to load JSON from game\n * resources.\n * @return The json manager for the game\n */\n getJsonManager(): gdjs.JsonManager {\n return this._jsonManager;\n }\n\n /**\n * Get the 3D model manager of the game, used to load 3D model from game\n * resources.\n * @return The 3D model manager for the game\n */\n getModel3DManager(): gdjs.Model3DManager {\n return this._model3DManager;\n }\n\n /**\n * Get the Spine manager of the game, used to load and construct spine skeletons from game\n * resources.\n * @return The Spine manager for the game\n */\n getSpineManager(): gdjs.SpineManager | null {\n return this._spineManager;\n }\n\n /**\n * Get the Spine Atlas manager of the game, used to load atlases from game\n * resources.\n * @return The Spine Atlas manager for the game\n */\n getSpineAtlasManager(): gdjs.SpineAtlasManager | null {\n return this._spineAtlasManager;\n }\n }\n\n type PromiseError<T> = { item: T; error: Error };\n\n type PromisePoolOutput<T, U> = {\n results: Array<U>;\n errors: Array<PromiseError<T>>;\n };\n\n const processWithPromisePool = <T, U>(\n items: Array<T>,\n maxConcurrency: number,\n asyncFunction: (item: T) => Promise<U>\n ): Promise<PromisePoolOutput<T, U>> => {\n const results: Array<U> = [];\n const errors: Array<PromiseError<T>> = [];\n let activePromises = 0;\n let index = 0;\n\n return new Promise((resolve, reject) => {\n const executeNext = () => {\n if (items.length === 0) {\n resolve({ results, errors });\n return;\n }\n while (activePromises < maxConcurrency && index < items.length) {\n const item = items[index++];\n activePromises++;\n\n asyncFunction(item)\n .then((result) => results.push(result))\n .catch((error) => errors.push({ item, error }))\n .finally(() => {\n activePromises--;\n if (index === items.length && activePromises === 0) {\n resolve({ results, errors });\n } else {\n executeNext();\n }\n });\n }\n };\n\n executeNext();\n });\n };\n\n const processAndRetryIfNeededWithPromisePool = async <T, U>(\n items: Array<T>,\n maxConcurrency: number,\n maxAttempt: number,\n asyncFunction: (item: T) => Promise<U>\n ): Promise<PromisePoolOutput<T, U>> => {\n const output = await processWithPromisePool<T, U>(\n items,\n maxConcurrency,\n asyncFunction\n );\n if (output.errors.length !== 0) {\n logger.warn(\"Some assets couldn't be downloaded. Trying again now.\");\n }\n for (\n let attempt = 1;\n attempt < maxAttempt && output.errors.length !== 0;\n attempt++\n ) {\n const retryOutput = await processWithPromisePool<T, U>(\n items,\n maxConcurrency,\n asyncFunction\n );\n output.results.push.apply(output.results, retryOutput.results);\n output.errors = retryOutput.errors;\n }\n return output;\n };\n}\n"],
|
|
5
|
-
"mappings": "AAKA,GAAU,MAAV,UAAU,EAAV,CACE,KAAM,GAAS,GAAI,GAAK,OAAO,kBAEzB,EAA0B,CAC9B,EACA,EACA,IACG,CACH,GAAI,EAAI,WAAW,UAAY,EAAI,WAAW,SAE5C,MAAO,GAGT,KAAM,GAAY,EAAI,QAAQ,OAAS,GAAK,IAAM,IAClD,MAAO,GAAM,EAAY,EAA0B,IAAM,GAGrD,EAAkC,AAAC,GAErC,EAAI,WAAW,2CACf,EAAI,WAAW,8CAIb,EAA2B,GAC3B,EAA2B,EAC3B,EAAa,EAUnB,OAAuB,CAMrB,YAAY,EAAmB,CAFvB,gBAAa,GAGnB,KAAK,UAAY,EACjB,KAAK,oBAAsB,GAAI,OAG/B,KAAK,kBAAoB,GAAI,OAG/B,iBACE,EACA,EACA,CACA,GAAI,KAAK,WAAY,CACnB,IACA,OAEF,KAAK,kBAAkB,KAAK,GACxB,GACF,KAAK,oBAAoB,KAAK,GAIlC,WAAW,EAAe,EAAe,CACvC,SAAW,KAAc,MAAK,oBAC5B,EAAW,EAAO,GAItB,UAAW,CACT,KAAK,WAAa,GAClB,SAAW,KAAY,MAAK,kB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EACA,EACe,CACf,KAAK,uBAAyB,GAC9B,KAAM,GAAO,KAAK,iBAAiB,GACnC,MAAO,IAAI,SAAc,CAAC,EAAS,IAAW,CAC5C,GAAI,CAAC,EAAM,CACT,KAAK,uBAAyB,GAC9B,IACA,OAEF,EAAK,iBAAiB,IAAM,CAC1B,KAAK,uBAAyB,GAC9B,KACC,
|
|
4
|
+
"sourcesContent": ["/*\n * GDevelop JS Platform\n * Copyright 2013-2023 Florian Rival (Florian.Rival@gmail.com). All rights reserved.\n * This project is released under the MIT License.\n */\nnamespace gdjs {\n const logger = new gdjs.Logger('ResourceLoader');\n\n const addSearchParameterToUrl = (\n url: string,\n urlEncodedParameterName: string,\n urlEncodedValue: string\n ) => {\n if (url.startsWith('data:') || url.startsWith('blob:')) {\n // blob/data protocol does not support search parameters, which are useless anyway.\n return url;\n }\n\n const separator = url.indexOf('?') === -1 ? '?' : '&';\n return url + separator + urlEncodedParameterName + '=' + urlEncodedValue;\n };\n\n const checkIfIsGDevelopCloudBucketUrl = (url: string): boolean => {\n return (\n url.startsWith('https://project-resources.gdevelop.io/') ||\n url.startsWith('https://project-resources-dev.gdevelop.io/')\n );\n };\n\n const maxForegroundConcurrency = 20;\n const maxBackgroundConcurrency = 5;\n const maxAttempt = 3;\n\n /**\n * A task of pre-loading resources used by a scene.\n *\n * A Promise can't be used instead of this class because a Promise will start\n * as soon as possible. It would flood the server with downloading requests\n * and make impossible to finely tune in which order scenes are actually\n * downloaded.\n */\n class SceneLoadingTask {\n sceneName: string;\n private onProgressCallbacks: Array<(count: number, total: number) => void>;\n private onFinishCallbacks: Array<() => void>;\n private isFinished = false;\n\n constructor(sceneName: string) {\n this.sceneName = sceneName;\n this.onProgressCallbacks = new Array<\n (count: number, total: number) => void\n >();\n this.onFinishCallbacks = new Array<() => void>();\n }\n\n registerCallback(\n onFinish: () => void,\n onProgress?: (count: number, total: number) => void\n ) {\n if (this.isFinished) {\n onFinish();\n return;\n }\n this.onFinishCallbacks.push(onFinish);\n if (onProgress) {\n this.onProgressCallbacks.push(onProgress);\n }\n }\n\n onProgress(count: number, total: number) {\n for (const onProgress of this.onProgressCallbacks) {\n onProgress(count, total);\n }\n }\n\n onFinish() {\n this.isFinished = true;\n for (const onFinish of this.onFinishCallbacks) {\n onFinish();\n }\n }\n }\n\n /**\n * Pre-load resources of any kind needed for a game or a scene.\n */\n export class ResourceLoader {\n _runtimeGame: RuntimeGame;\n /**\n * All the resource of a game by resource name.\n */\n private _resources: Map<string, ResourceData>;\n /**\n * Resources needed for any scene. Typically, they are resources from\n * global objects.\n */\n private _globalResources: Array<string>;\n /**\n * Resources by scene names.\n */\n private _sceneResources: Map<string, Array<string>>;\n /**\n * Keep track of which scene whose resources has already be pre-loaded.\n */\n private _sceneNamesToLoad: Set<string>;\n /**\n * Keep track of which scene whose resources has already be loaded.\n */\n private _sceneNamesToMakeReady: Set<string>;\n /**\n * A queue of scenes whose resources are still to be pre-loaded.\n */\n private _sceneToLoadQueue: Array<SceneLoadingTask> = new Array<\n SceneLoadingTask\n >();\n /**\n * The resource managers that actually download and remember downloaded\n * content.\n */\n _resourceManagersMap: Map<ResourceKind, ResourceManager>;\n private _imageManager: ImageManager;\n private _soundManager: SoundManager;\n private _fontManager: FontManager;\n private _jsonManager: JsonManager;\n private _model3DManager: Model3DManager;\n private _bitmapFontManager: BitmapFontManager;\n private _spineAtlasManager: SpineAtlasManager | null = null;\n private _spineManager: SpineManager | null = null;\n\n /**\n * Only used by events.\n */\n private currentLoadingSceneName: string = '';\n /**\n * Only used by events.\n */\n private currentSceneLoadingProgress: float = 0;\n /**\n * It's set to `true` during intermediary loading screen to use a greater\n * concurrency as the game is paused and doesn't need bandwidth (for video\n * or music streaming or online multiplayer).\n */\n private _isLoadingInForeground = true;\n\n /**\n * @param runtimeGame The game.\n * @param resourceDataArray The resources data of the game.\n * @param globalResources The resources needed for any layer.\n * @param layoutDataArray The resources used by each layer.\n */\n constructor(\n runtimeGame: RuntimeGame,\n resourceDataArray: ResourceData[],\n globalResources: Array<string>,\n layoutDataArray: Array<LayoutData>\n ) {\n this._runtimeGame = runtimeGame;\n this._resources = new Map<string, ResourceData>();\n this._globalResources = globalResources;\n\n // These 3 attributes are filled by `setResources`.\n this._sceneResources = new Map<string, Array<string>>();\n this._sceneNamesToLoad = new Set<string>();\n this._sceneNamesToMakeReady = new Set<string>();\n this.setResources(resourceDataArray, globalResources, layoutDataArray);\n\n this._imageManager = new gdjs.ImageManager(this);\n this._soundManager = new gdjs.SoundManager(this);\n this._fontManager = new gdjs.FontManager(this);\n this._jsonManager = new gdjs.JsonManager(this);\n this._bitmapFontManager = new gdjs.BitmapFontManager(\n this,\n this._imageManager\n );\n this._model3DManager = new gdjs.Model3DManager(this);\n\n // add spine related managers only if spine extension is used\n if (gdjs.SpineAtlasManager && gdjs.SpineManager) {\n this._spineAtlasManager = new gdjs.SpineAtlasManager(\n this,\n this._imageManager\n );\n this._spineManager = new gdjs.SpineManager(\n this,\n this._spineAtlasManager\n );\n }\n\n const resourceManagers: Array<ResourceManager> = [\n this._imageManager,\n this._soundManager,\n this._fontManager,\n this._jsonManager,\n this._bitmapFontManager,\n this._model3DManager,\n ];\n\n if (this._spineAtlasManager)\n resourceManagers.push(this._spineAtlasManager);\n if (this._spineManager) resourceManagers.push(this._spineManager);\n\n this._resourceManagersMap = new Map<ResourceKind, ResourceManager>();\n for (const resourceManager of resourceManagers) {\n for (const resourceKind of resourceManager.getResourceKinds()) {\n this._resourceManagersMap.set(resourceKind, resourceManager);\n }\n }\n }\n\n /**\n * @returns the runtime game instance.\n */\n getRuntimeGame(): RuntimeGame {\n return this._runtimeGame;\n }\n\n /**\n * Update the resources data of the game. Useful for hot-reloading, should\n * not be used otherwise.\n */\n setResources(\n resourceDataArray: ResourceData[],\n globalResources: Array<string>,\n layoutDataArray: Array<LayoutData>\n ): void {\n this._globalResources = globalResources;\n\n this._sceneResources.clear();\n this._sceneNamesToLoad.clear();\n this._sceneNamesToMakeReady.clear();\n for (const layoutData of layoutDataArray) {\n this._sceneResources.set(\n layoutData.name,\n layoutData.usedResources.map((resource) => resource.name)\n );\n this._sceneNamesToLoad.add(layoutData.name);\n this._sceneNamesToMakeReady.add(layoutData.name);\n }\n // TODO Clearing the queue doesn't abort the running task, but it should\n // not matter as resource loading is really fast in preview mode.\n this._sceneToLoadQueue.length = 0;\n for (let index = layoutDataArray.length - 1; index >= 0; index--) {\n const layoutData = layoutDataArray[index];\n this._sceneToLoadQueue.push(new SceneLoadingTask(layoutData.name));\n }\n\n this._resources.clear();\n for (const resourceData of resourceDataArray) {\n if (!resourceData.file) {\n // Empty string or missing `file` field: not a valid resource, let's entirely ignore it.\n // Otherwise, this can confuse some loaders that will consider an empty string different\n // than a file that happen not to fail to load.\n continue;\n }\n\n this._resources.set(resourceData.name, resourceData);\n }\n }\n\n async loadAllResources(\n onProgress: (loadingCount: integer, totalCount: integer) => void\n ): Promise<void> {\n let loadedCount = 0;\n await processAndRetryIfNeededWithPromisePool(\n [...this._resources.values()],\n maxForegroundConcurrency,\n maxAttempt,\n async (resource) => {\n await this._loadResource(resource);\n await this._processResource(resource);\n loadedCount++;\n onProgress(loadedCount, this._resources.size);\n }\n );\n this._sceneNamesToLoad.clear();\n this._sceneNamesToMakeReady.clear();\n }\n\n /**\n * Load the resources that are needed to launch the first scene.\n */\n async loadGlobalAndFirstSceneResources(\n firstSceneName: string,\n onProgress: (count: number, total: number) => void\n ): Promise<void> {\n const sceneResources = this._sceneResources.get(firstSceneName);\n if (!sceneResources) {\n logger.warn(\n 'Can\\'t load resource for unknown scene: \"' + firstSceneName + '\".'\n );\n return;\n }\n let loadedCount = 0;\n const resources = [...this._globalResources, ...sceneResources.values()];\n await processAndRetryIfNeededWithPromisePool(\n resources,\n maxForegroundConcurrency,\n maxAttempt,\n async (resourceName) => {\n const resource = this._resources.get(resourceName);\n if (!resource) {\n logger.warn('Unable to find resource \"' + resourceName + '\".');\n return;\n }\n await this._loadResource(resource);\n await this._processResource(resource);\n loadedCount++;\n onProgress(loadedCount, resources.length);\n }\n );\n this._setSceneAssetsLoaded(firstSceneName);\n this._setSceneAssetsReady(firstSceneName);\n }\n\n /**\n * Load each scene in order.\n *\n * This is done in background to try to avoid loading screens when changing\n * scenes.\n */\n async loadAllSceneInBackground(): Promise<void> {\n while (this._sceneToLoadQueue.length > 0) {\n const task = this._sceneToLoadQueue[this._sceneToLoadQueue.length - 1];\n if (task === undefined) {\n continue;\n }\n this.currentLoadingSceneName = task.sceneName;\n if (!this.areSceneAssetsLoaded(task.sceneName)) {\n await this._doLoadSceneResources(\n task.sceneName,\n async (count, total) => task.onProgress(count, total)\n );\n // A scene may have been moved last while awaiting resources to be\n // downloaded (see _prioritizeScene).\n this._sceneToLoadQueue.splice(\n this._sceneToLoadQueue.findIndex((element) => element === task),\n 1\n );\n task.onFinish();\n } else {\n this._sceneToLoadQueue.pop();\n }\n }\n this.currentLoadingSceneName = '';\n }\n\n private async _doLoadSceneResources(\n sceneName: string,\n onProgress?: (count: number, total: number) => Promise<void>\n ): Promise<void> {\n const sceneResources = this._sceneResources.get(sceneName);\n if (!sceneResources) {\n logger.warn(\n 'Can\\'t load resource for unknown scene: \"' + sceneName + '\".'\n );\n return;\n }\n let loadedCount = 0;\n await processAndRetryIfNeededWithPromisePool(\n [...sceneResources.values()],\n this._isLoadingInForeground\n ? maxForegroundConcurrency\n : maxBackgroundConcurrency,\n maxAttempt,\n async (resourceName) => {\n const resource = this._resources.get(resourceName);\n if (!resource) {\n logger.warn('Unable to find resource \"' + resourceName + '\".');\n return;\n }\n await this._loadResource(resource);\n loadedCount++;\n this.currentSceneLoadingProgress = loadedCount / this._resources.size;\n onProgress && (await onProgress(loadedCount, this._resources.size));\n }\n );\n this._setSceneAssetsLoaded(sceneName);\n }\n\n private async _loadResource(resource: ResourceData): Promise<void> {\n const resourceManager = this._resourceManagersMap.get(resource.kind);\n if (!resourceManager) {\n logger.warn(\n 'Unknown resource kind: \"' +\n resource.kind +\n '\" for: \"' +\n resource.name +\n '\".'\n );\n return;\n }\n await resourceManager.loadResource(resource.name);\n }\n\n /**\n * Load and process a scene that is needed right away.\n *\n * The renderer will show a loading screen while its done.\n */\n async loadAndProcessSceneResources(\n sceneName: string,\n onProgress?: (count: number, total: number) => Promise<void>\n ): Promise<void> {\n if (this.areSceneAssetsReady(sceneName)) {\n return;\n }\n await this.loadSceneResources(sceneName, onProgress);\n\n const sceneResources = this._sceneResources.get(sceneName);\n if (!sceneResources) {\n logger.warn(\n 'Can\\'t load resource for unknown scene: \"' + sceneName + '\".'\n );\n return;\n }\n\n let parsedCount = 0;\n for (const resourceName of sceneResources) {\n const resource = this._resources.get(resourceName);\n if (!resource) {\n logger.warn('Unable to find resource \"' + resourceName + '\".');\n continue;\n }\n await this._processResource(resource);\n parsedCount++;\n onProgress && (await onProgress(parsedCount, sceneResources.length));\n }\n this._setSceneAssetsReady(sceneName);\n }\n\n /**\n * Load a scene resources without parsing them.\n *\n * When another scene resources are loading in background, it waits for\n * all its resources to be loaded before loading resources of the given\n * scene.\n */\n async loadSceneResources(\n sceneName: string,\n onProgress?: (count: number, total: number) => void\n ): Promise<void> {\n this._isLoadingInForeground = true;\n const task = this._prioritizeScene(sceneName);\n return new Promise<void>((resolve, reject) => {\n if (!task) {\n this._isLoadingInForeground = false;\n resolve();\n return;\n }\n task.registerCallback(() => {\n this._isLoadingInForeground = false;\n resolve();\n }, onProgress);\n });\n }\n\n /**\n * To be called when the game is disposed.\n * Dispose all the resource managers.\n */\n dispose(): void {\n for (const resourceManager of this._resourceManagersMap.values()) {\n resourceManager.dispose();\n }\n }\n\n /**\n * Put a given scene at the end of the queue.\n *\n * When the scene that is currently loading in background is done,\n * this scene will be the next to be loaded.\n */\n private _prioritizeScene(sceneName: string): SceneLoadingTask | null {\n const taskIndex = this._sceneToLoadQueue.findIndex(\n (task) => task.sceneName === sceneName\n );\n if (taskIndex < 0) {\n // The scene is already loaded.\n return null;\n }\n const task = this._sceneToLoadQueue[taskIndex];\n this._sceneToLoadQueue.splice(taskIndex, 1);\n this._sceneToLoadQueue.push(task);\n return task;\n }\n\n private async _processResource(resource: ResourceData): Promise<void> {\n const resourceManager = this._resourceManagersMap.get(resource.kind);\n if (!resourceManager) {\n logger.warn(\n 'Unknown resource kind: \"' +\n resource.kind +\n '\" for: \"' +\n resource.name +\n '\".'\n );\n return;\n }\n await resourceManager.processResource(resource.name);\n }\n\n getSceneLoadingProgress(sceneName: string): float {\n return sceneName === this.currentLoadingSceneName\n ? this.currentSceneLoadingProgress\n : this.areSceneAssetsLoaded(sceneName)\n ? 1\n : 0;\n }\n\n /**\n * @returns true when all the resources of the given scene are loaded\n * (but maybe not parsed).\n */\n areSceneAssetsLoaded(sceneName: string): boolean {\n return !this._sceneNamesToLoad.has(sceneName);\n }\n\n /**\n * @returns true when all the resources of the given scene are loaded and\n * parsed.\n */\n areSceneAssetsReady(sceneName: string): boolean {\n return !this._sceneNamesToMakeReady.has(sceneName);\n }\n\n private _setSceneAssetsLoaded(sceneName: string): void {\n this._sceneNamesToLoad.delete(sceneName);\n }\n\n private _setSceneAssetsReady(sceneName: string): void {\n this._sceneNamesToMakeReady.delete(sceneName);\n }\n\n getResource(resourceName: string): ResourceData | null {\n return this._resources.get(resourceName) || null;\n }\n\n // Helper methods used when resources are loaded from an URL.\n\n /**\n * Complete the given URL with any specific parameter required to access\n * the resource (this can be for example a token needed to access the resource).\n */\n getFullUrl(url: string) {\n const { gdevelopResourceToken } = this._runtimeGame._options;\n if (!gdevelopResourceToken) return url;\n\n if (!checkIfIsGDevelopCloudBucketUrl(url)) return url;\n\n return addSearchParameterToUrl(\n url,\n 'gd_resource_token',\n encodeURIComponent(gdevelopResourceToken)\n );\n }\n\n /**\n * Return true if the specified URL must be loaded with cookies (\"credentials\")\n * sent to grant access to them.\n */\n checkIfCredentialsRequired(url: string) {\n if (this._runtimeGame._options.gdevelopResourceToken) return false;\n\n // Any resource stored on the GDevelop Cloud buckets needs the \"credentials\" of the user,\n // i.e: its gdevelop.io cookie, to be passed.\n // Note that this is only useful during previews.\n if (checkIfIsGDevelopCloudBucketUrl(url)) return true;\n\n // For other resources, use the default way of loading resources (\"anonymous\" or \"same-site\").\n return false;\n }\n\n /**\n * Get the gdjs.SoundManager of the RuntimeGame.\n * @return The sound manager.\n */\n getSoundManager(): gdjs.HowlerSoundManager {\n return this._soundManager;\n }\n\n /**\n * Get the gdjs.ImageManager of the RuntimeGame.\n * @return The image manager.\n */\n getImageManager(): gdjs.PixiImageManager {\n return this._imageManager;\n }\n\n /**\n * Get the gdjs.FontManager of the RuntimeGame.\n * @return The font manager.\n */\n getFontManager(): gdjs.FontFaceObserverFontManager {\n return this._fontManager;\n }\n\n /**\n * Get the gdjs.BitmapFontManager of the RuntimeGame.\n * @return The bitmap font manager.\n */\n getBitmapFontManager(): gdjs.BitmapFontManager {\n return this._bitmapFontManager;\n }\n\n /**\n * Get the JSON manager of the game, used to load JSON from game\n * resources.\n * @return The json manager for the game\n */\n getJsonManager(): gdjs.JsonManager {\n return this._jsonManager;\n }\n\n /**\n * Get the 3D model manager of the game, used to load 3D model from game\n * resources.\n * @return The 3D model manager for the game\n */\n getModel3DManager(): gdjs.Model3DManager {\n return this._model3DManager;\n }\n\n /**\n * Get the Spine manager of the game, used to load and construct spine skeletons from game\n * resources.\n * @return The Spine manager for the game\n */\n getSpineManager(): gdjs.SpineManager | null {\n return this._spineManager;\n }\n\n /**\n * Get the Spine Atlas manager of the game, used to load atlases from game\n * resources.\n * @return The Spine Atlas manager for the game\n */\n getSpineAtlasManager(): gdjs.SpineAtlasManager | null {\n return this._spineAtlasManager;\n }\n }\n\n type PromiseError<T> = { item: T; error: Error };\n\n type PromisePoolOutput<T, U> = {\n results: Array<U>;\n errors: Array<PromiseError<T>>;\n };\n\n const processWithPromisePool = <T, U>(\n items: Array<T>,\n maxConcurrency: number,\n asyncFunction: (item: T) => Promise<U>\n ): Promise<PromisePoolOutput<T, U>> => {\n const results: Array<U> = [];\n const errors: Array<PromiseError<T>> = [];\n let activePromises = 0;\n let index = 0;\n\n return new Promise((resolve, reject) => {\n const executeNext = () => {\n if (items.length === 0) {\n resolve({ results, errors });\n return;\n }\n while (activePromises < maxConcurrency && index < items.length) {\n const item = items[index++];\n activePromises++;\n\n asyncFunction(item)\n .then((result) => results.push(result))\n .catch((error) => errors.push({ item, error }))\n .finally(() => {\n activePromises--;\n if (index === items.length && activePromises === 0) {\n resolve({ results, errors });\n } else {\n executeNext();\n }\n });\n }\n };\n\n executeNext();\n });\n };\n\n const processAndRetryIfNeededWithPromisePool = async <T, U>(\n items: Array<T>,\n maxConcurrency: number,\n maxAttempt: number,\n asyncFunction: (item: T) => Promise<U>\n ): Promise<PromisePoolOutput<T, U>> => {\n const output = await processWithPromisePool<T, U>(\n items,\n maxConcurrency,\n asyncFunction\n );\n if (output.errors.length !== 0) {\n logger.warn(\"Some assets couldn't be downloaded. Trying again now.\");\n }\n for (\n let attempt = 1;\n attempt < maxAttempt && output.errors.length !== 0;\n attempt++\n ) {\n const retryOutput = await processWithPromisePool<T, U>(\n items,\n maxConcurrency,\n asyncFunction\n );\n output.results.push.apply(output.results, retryOutput.results);\n output.errors = retryOutput.errors;\n }\n return output;\n };\n}\n"],
|
|
5
|
+
"mappings": "AAKA,GAAU,MAAV,UAAU,EAAV,CACE,KAAM,GAAS,GAAI,GAAK,OAAO,kBAEzB,EAA0B,CAC9B,EACA,EACA,IACG,CACH,GAAI,EAAI,WAAW,UAAY,EAAI,WAAW,SAE5C,MAAO,GAGT,KAAM,GAAY,EAAI,QAAQ,OAAS,GAAK,IAAM,IAClD,MAAO,GAAM,EAAY,EAA0B,IAAM,GAGrD,EAAkC,AAAC,GAErC,EAAI,WAAW,2CACf,EAAI,WAAW,8CAIb,EAA2B,GAC3B,EAA2B,EAC3B,EAAa,EAUnB,OAAuB,CAMrB,YAAY,EAAmB,CAFvB,gBAAa,GAGnB,KAAK,UAAY,EACjB,KAAK,oBAAsB,GAAI,OAG/B,KAAK,kBAAoB,GAAI,OAG/B,iBACE,EACA,EACA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