gdcore-tools 2.0.0-gd-v5.5.232-autobuild → 2.0.0-gd-v5.5.234-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.
Files changed (61) hide show
  1. package/dist/Runtime/Extensions/3D/Cube3DRuntimeObject.js +1 -1
  2. package/dist/Runtime/Extensions/3D/Cube3DRuntimeObject.js.map +2 -2
  3. package/dist/Runtime/Extensions/3D/Cube3DRuntimeObjectPixiRenderer.js +1 -1
  4. package/dist/Runtime/Extensions/3D/Cube3DRuntimeObjectPixiRenderer.js.map +2 -2
  5. package/dist/Runtime/Extensions/3D/DirectionalLight.js +1 -1
  6. package/dist/Runtime/Extensions/3D/DirectionalLight.js.map +2 -2
  7. package/dist/Runtime/Extensions/3D/JsExtension.js +60 -9
  8. package/dist/Runtime/Extensions/3D/Model3DRuntimeObject.js +1 -1
  9. package/dist/Runtime/Extensions/3D/Model3DRuntimeObject.js.map +2 -2
  10. package/dist/Runtime/Extensions/3D/Model3DRuntimeObject3DRenderer.js +1 -1
  11. package/dist/Runtime/Extensions/3D/Model3DRuntimeObject3DRenderer.js.map +2 -2
  12. package/dist/Runtime/Extensions/BBText/JsExtension.js +6 -6
  13. package/dist/Runtime/Extensions/BitmapText/JsExtension.js +6 -6
  14. package/dist/Runtime/Extensions/Physics2Behavior/JsExtension.js +10 -10
  15. package/dist/Runtime/Extensions/Physics3DBehavior/JsExtension.js +20 -7
  16. package/dist/Runtime/Extensions/Physics3DBehavior/Physics3DRuntimeBehavior.js +1 -1
  17. package/dist/Runtime/Extensions/Physics3DBehavior/Physics3DRuntimeBehavior.js.map +2 -2
  18. package/dist/Runtime/Extensions/Physics3DBehavior/PhysicsCar3DRuntimeBehavior.js +1 -1
  19. package/dist/Runtime/Extensions/Physics3DBehavior/PhysicsCar3DRuntimeBehavior.js.map +2 -2
  20. package/dist/Runtime/Extensions/PlatformBehavior/platformerobjectruntimebehavior.js +1 -1
  21. package/dist/Runtime/Extensions/PlatformBehavior/platformerobjectruntimebehavior.js.map +2 -2
  22. package/dist/Runtime/Extensions/Spine/managers/pixi-spine-atlas-manager.js +1 -1
  23. package/dist/Runtime/Extensions/Spine/managers/pixi-spine-atlas-manager.js.map +2 -2
  24. package/dist/Runtime/Extensions/Spine/managers/pixi-spine-manager.js +1 -1
  25. package/dist/Runtime/Extensions/Spine/managers/pixi-spine-manager.js.map +2 -2
  26. package/dist/Runtime/Extensions/TextInput/JsExtension.js +11 -11
  27. package/dist/Runtime/Extensions/TileMap/JsExtension.js +3 -3
  28. package/dist/Runtime/Model3DManager.js +1 -1
  29. package/dist/Runtime/Model3DManager.js.map +2 -2
  30. package/dist/Runtime/ResourceLoader.js +1 -1
  31. package/dist/Runtime/ResourceLoader.js.map +2 -2
  32. package/dist/Runtime/RuntimeLayer.js +1 -1
  33. package/dist/Runtime/RuntimeLayer.js.map +2 -2
  34. package/dist/Runtime/events-tools/objecttools.js +1 -1
  35. package/dist/Runtime/events-tools/objecttools.js.map +2 -2
  36. package/dist/Runtime/fontfaceobserver-font-manager/fontfaceobserver-font-manager.js +1 -1
  37. package/dist/Runtime/fontfaceobserver-font-manager/fontfaceobserver-font-manager.js.map +2 -2
  38. package/dist/Runtime/howler-sound-manager/howler-sound-manager.js +1 -1
  39. package/dist/Runtime/howler-sound-manager/howler-sound-manager.js.map +2 -2
  40. package/dist/Runtime/jsonmanager.js +1 -1
  41. package/dist/Runtime/jsonmanager.js.map +2 -2
  42. package/dist/Runtime/logger.js +1 -1
  43. package/dist/Runtime/logger.js.map +2 -2
  44. package/dist/Runtime/pixi-renderers/pixi-bitmapfont-manager.js +1 -1
  45. package/dist/Runtime/pixi-renderers/pixi-bitmapfont-manager.js.map +2 -2
  46. package/dist/Runtime/pixi-renderers/pixi-effects-manager.js.map +2 -2
  47. package/dist/Runtime/pixi-renderers/pixi-image-manager.js +1 -1
  48. package/dist/Runtime/pixi-renderers/pixi-image-manager.js.map +2 -2
  49. package/dist/Runtime/pixi-renderers/runtimegame-pixi-renderer.js +1 -1
  50. package/dist/Runtime/pixi-renderers/runtimegame-pixi-renderer.js.map +2 -2
  51. package/dist/Runtime/runtimegame.js +1 -1
  52. package/dist/Runtime/runtimegame.js.map +2 -2
  53. package/dist/Runtime/runtimescene.js +1 -1
  54. package/dist/Runtime/runtimescene.js.map +2 -2
  55. package/dist/Runtime/scenestack.js +1 -1
  56. package/dist/Runtime/scenestack.js.map +2 -2
  57. package/dist/Runtime/types/project-data.d.ts +6 -1
  58. package/dist/lib/libGD.cjs +1 -1
  59. package/dist/lib/libGD.wasm +0 -0
  60. package/gd.d.ts +21 -0
  61. package/package.json +1 -1
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../GDevelop/GDJS/Runtime/logger.ts"],
4
- "sourcesContent": ["namespace gdjs {\n /**\n * A LoggerOutput specifies a single method to be called to display\n * or register a log.\n */\n export interface LoggerOutput {\n log(\n group: string,\n message: string,\n type: 'info' | 'warning' | 'error',\n internal?: boolean\n ): void;\n }\n\n const supportedConsoleFunctions = {\n info: console.log,\n warning: console.warn,\n error: console.error,\n };\n\n /**\n * The default logging output: uses the JavaScript console.\n */\n class ConsoleLoggerOutput implements LoggerOutput {\n private readonly discardedConsoleGroups = new Set<string>();\n\n discardGroup(groupName: string) {\n this.discardedConsoleGroups.add(groupName);\n }\n\n enableGroup(groupName: string) {\n this.discardedConsoleGroups.delete(groupName);\n }\n\n log(\n group: string,\n message: string,\n type: 'info' | 'warning' | 'error' = 'info',\n internal = true\n ): void {\n if (this.discardedConsoleGroups.has(group)) return;\n\n const logger =\n supportedConsoleFunctions[type] || supportedConsoleFunctions.info;\n logger(`[${group}] ${message}`);\n }\n }\n\n const consoleLoggerOutput = new ConsoleLoggerOutput();\n\n /**\n * The current output method - can be changed at runtime.\n * By default, output to the JavaScript console.\n */\n let loggerOutput: LoggerOutput = consoleLoggerOutput;\n\n function objectsToString(objects: any[]): string {\n return objects.reduce(\n (accumulator, value) => accumulator + value.toString(),\n ''\n );\n }\n\n /**\n * A Console API like class for logging in a GDevelop game.\n */\n export class Logger {\n private readonly group: string;\n\n /**\n * Create a new logger with the given group name.\n * You can then use log, info, warn and error on this object.\n */\n constructor(group: string) {\n this.group = group;\n }\n\n log(...messages: any[]): void {\n loggerOutput.log(this.group, objectsToString(messages), 'info');\n }\n\n info(...messages: any[]): void {\n loggerOutput.log(this.group, objectsToString(messages), 'info');\n }\n\n warn(...messages: any[]): void {\n loggerOutput.log(this.group, objectsToString(messages), 'warning');\n }\n\n error(...messages: any[]): void {\n loggerOutput.log(this.group, objectsToString(messages), 'error');\n }\n\n /**\n * Give access to the console output used by default by the logger.\n * This can be useful to restore the default log method if you overrode it\n * or to disable some logging in the console.\n */\n static getDefaultConsoleLoggerOutput() {\n return consoleLoggerOutput;\n }\n\n /**\n * Return the current logger output (common to all gdjs.Logger instances).\n */\n static getLoggerOutput(): LoggerOutput {\n return loggerOutput;\n }\n\n /**\n * Change the logger output (common to all gdjs.Logger instances).\n */\n static setLoggerOutput(newLoggerOutput: LoggerOutput) {\n loggerOutput = newLoggerOutput;\n }\n }\n}\n"],
5
- "mappings": "AAAA,GAAU,MAAV,UAAU,EAAV,CAcE,KAAM,GAA4B,CAChC,KAAM,QAAQ,IACd,QAAS,QAAQ,KACjB,MAAO,QAAQ,OAMjB,OAAkD,CAAlD,aAvBF,CAwBqB,4BAAyB,GAAI,KAE9C,aAAa,EAAmB,CAC9B,KAAK,uBAAuB,IAAI,GAGlC,YAAY,EAAmB,CAC7B,KAAK,uBAAuB,OAAO,GAGrC,IACE,EACA,EACA,EAAqC,OACrC,EAAW,GACL,CACN,GAAI,KAAK,uBAAuB,IAAI,GAAQ,OAI5C,AADE,GAA0B,IAAS,EAA0B,MACxD,IAAI,MAAU,MAIzB,KAAM,GAAsB,GAAI,GAMhC,GAAI,GAA6B,EAEjC,WAAyB,EAAwB,CAC/C,MAAO,GAAQ,OACb,CAAC,EAAa,IAAU,EAAc,EAAM,WAC5C,IAOG,OAAa,CAOlB,YAAY,EAAe,CACzB,KAAK,MAAQ,EAGf,OAAO,EAAuB,CAC5B,EAAa,IAAI,KAAK,MAAO,EAAgB,GAAW,QAG1D,QAAQ,EAAuB,CAC7B,EAAa,IAAI,KAAK,MAAO,EAAgB,GAAW,QAG1D,QAAQ,EAAuB,CAC7B,EAAa,IAAI,KAAK,MAAO,EAAgB,GAAW,WAG1D,SAAS,EAAuB,CAC9B,EAAa,IAAI,KAAK,MAAO,EAAgB,GAAW,eAQnD,gCAAgC,CACrC,MAAO,SAMF,kBAAgC,CACrC,MAAO,SAMF,iBAAgB,EAA+B,CACpD,EAAe,GA/CZ,EAAM,WAlEL",
4
+ "sourcesContent": ["namespace gdjs {\n /**\n * A LoggerOutput specifies a single method to be called to display\n * or register a log.\n */\n export interface LoggerOutput {\n log(\n group: string,\n message: string,\n type: 'info' | 'warning' | 'error',\n internal?: boolean\n ): void;\n }\n\n const supportedConsoleFunctions = {\n info: console.log,\n warning: console.warn,\n error: console.error,\n };\n\n /**\n * The default logging output: uses the JavaScript console.\n */\n class ConsoleLoggerOutput implements LoggerOutput {\n private readonly discardedConsoleGroups = new Set<string>();\n\n discardGroup(groupName: string) {\n this.discardedConsoleGroups.add(groupName);\n }\n\n enableGroup(groupName: string) {\n this.discardedConsoleGroups.delete(groupName);\n }\n\n log(\n group: string,\n message: string,\n type: 'info' | 'warning' | 'error' = 'info',\n internal = true\n ): void {\n if (this.discardedConsoleGroups.has(group)) return;\n\n const logger =\n supportedConsoleFunctions[type] || supportedConsoleFunctions.info;\n logger(`[${group}] ${message}`);\n }\n }\n\n const consoleLoggerOutput = new ConsoleLoggerOutput();\n\n /**\n * The current output method - can be changed at runtime.\n * By default, output to the JavaScript console.\n */\n let loggerOutput: LoggerOutput = consoleLoggerOutput;\n\n function objectsToString(objects: any[]): string {\n return objects.reduce(\n (accumulator, value) => accumulator + value.toString(),\n ''\n );\n }\n\n /**\n * A Console API like class for logging in a GDevelop game.\n */\n export class Logger {\n private readonly group: string;\n private enabled: boolean = true;\n\n /**\n * Create a new logger with the given group name.\n * You can then use log, info, warn and error on this object.\n */\n constructor(group: string) {\n this.group = group;\n }\n\n log(...messages: any[]): void {\n if (!this.enabled) return;\n loggerOutput.log(this.group, objectsToString(messages), 'info');\n }\n\n info(...messages: any[]): void {\n if (!this.enabled) return;\n loggerOutput.log(this.group, objectsToString(messages), 'info');\n }\n\n warn(...messages: any[]): void {\n if (!this.enabled) return;\n loggerOutput.log(this.group, objectsToString(messages), 'warning');\n }\n\n error(...messages: any[]): void {\n if (!this.enabled) return;\n loggerOutput.log(this.group, objectsToString(messages), 'error');\n }\n\n enable(enabled: boolean): gdjs.Logger {\n this.enabled = enabled;\n return this;\n }\n\n /**\n * Give access to the console output used by default by the logger.\n * This can be useful to restore the default log method if you overrode it\n * or to disable some logging in the console.\n */\n static getDefaultConsoleLoggerOutput() {\n return consoleLoggerOutput;\n }\n\n /**\n * Return the current logger output (common to all gdjs.Logger instances).\n */\n static getLoggerOutput(): LoggerOutput {\n return loggerOutput;\n }\n\n /**\n * Change the logger output (common to all gdjs.Logger instances).\n */\n static setLoggerOutput(newLoggerOutput: LoggerOutput) {\n loggerOutput = newLoggerOutput;\n }\n }\n}\n"],
5
+ "mappings": "AAAA,GAAU,MAAV,UAAU,EAAV,CAcE,KAAM,GAA4B,CAChC,KAAM,QAAQ,IACd,QAAS,QAAQ,KACjB,MAAO,QAAQ,OAMjB,OAAkD,CAAlD,aAvBF,CAwBqB,4BAAyB,GAAI,KAE9C,aAAa,EAAmB,CAC9B,KAAK,uBAAuB,IAAI,GAGlC,YAAY,EAAmB,CAC7B,KAAK,uBAAuB,OAAO,GAGrC,IACE,EACA,EACA,EAAqC,OACrC,EAAW,GACL,CACN,GAAI,KAAK,uBAAuB,IAAI,GAAQ,OAI5C,AADE,GAA0B,IAAS,EAA0B,MACxD,IAAI,MAAU,MAIzB,KAAM,GAAsB,GAAI,GAMhC,GAAI,GAA6B,EAEjC,WAAyB,EAAwB,CAC/C,MAAO,GAAQ,OACb,CAAC,EAAa,IAAU,EAAc,EAAM,WAC5C,IAOG,OAAa,CAQlB,YAAY,EAAe,CANnB,aAAmB,GAOzB,KAAK,MAAQ,EAGf,OAAO,EAAuB,CAC5B,AAAI,CAAC,KAAK,SACV,EAAa,IAAI,KAAK,MAAO,EAAgB,GAAW,QAG1D,QAAQ,EAAuB,CAC7B,AAAI,CAAC,KAAK,SACV,EAAa,IAAI,KAAK,MAAO,EAAgB,GAAW,QAG1D,QAAQ,EAAuB,CAC7B,AAAI,CAAC,KAAK,SACV,EAAa,IAAI,KAAK,MAAO,EAAgB,GAAW,WAG1D,SAAS,EAAuB,CAC9B,AAAI,CAAC,KAAK,SACV,EAAa,IAAI,KAAK,MAAO,EAAgB,GAAW,SAG1D,OAAO,EAA+B,CACpC,YAAK,QAAU,EACR,WAQF,gCAAgC,CACrC,MAAO,SAMF,kBAAgC,CACrC,MAAO,SAMF,iBAAgB,EAA+B,CACpD,EAAe,GAzDZ,EAAM,WAlEL",
6
6
  "names": []
7
7
  }
@@ -1,2 +1,2 @@
1
- var gdjs;(function(a){const n=new a.Logger("Bitmap text"),l="GDJS-DEFAULT-BITMAP-FONT",m=5,p=(s,t)=>{const i=s.font;return s.font=t,PIXI.BitmapFont.available[t]=s,delete PIXI.BitmapFont.available[i],PIXI.BitmapFont.available[t]},d=["bitmapFont"];class u{constructor(t,i){this._pixiBitmapFontsInUse={};this._pixiBitmapFontsToUninstall=[];this._loadedFontsData=new a.ResourceCache;this._defaultSlugFontName=null;this._imageManager=i,this._resourceLoader=t}getResourceKinds(){return d}getDefaultBitmapFont(){if(this._defaultSlugFontName!==null)return PIXI.BitmapFont.available[this._defaultSlugFontName];const t="Arial",i=new PIXI.TextStyle({fontFamily:t,fontSize:20,padding:5,align:"left",fill:"#ffffff",wordWrap:!0,lineHeight:20}),e=p(PIXI.BitmapFont.from(t,i,{chars:[[" ","~"]]}),l);return this._defaultSlugFontName=e.font,e}_markBitmapFontAsUsed(t){this._pixiBitmapFontsInUse[t]=this._pixiBitmapFontsInUse[t]||{objectsUsingTheFont:0},this._pixiBitmapFontsInUse[t].objectsUsingTheFont++;for(let i=0;i<this._pixiBitmapFontsToUninstall.length;)this._pixiBitmapFontsToUninstall[i]===t?this._pixiBitmapFontsToUninstall.splice(i,1):i++}releaseBitmapFont(t){if(t!==l){if(!this._pixiBitmapFontsInUse[t]){n.warn("BitmapFont with name "+t+" was tried to be released but was never marked as used.");return}if(this._pixiBitmapFontsInUse[t].objectsUsingTheFont--,this._pixiBitmapFontsInUse[t].objectsUsingTheFont===0&&(delete this._pixiBitmapFontsInUse[t],this._pixiBitmapFontsToUninstall.includes(t)||this._pixiBitmapFontsToUninstall.push(t),this._pixiBitmapFontsToUninstall.length>m)){const i=this._pixiBitmapFontsToUninstall.shift();PIXI.BitmapFont.uninstall(i),n.log("Bitmap Text",'Uninstalled BitmapFont "'+i+'" from memory.')}}}obtainBitmapFont(t,i){const e=t+"@"+i;if(PIXI.BitmapFont.available[e])return this._markBitmapFontAsUsed(e),PIXI.BitmapFont.available[e];const o=this._loadedFontsData.getFromName(t);if(!o)return n.warn('Could not find Bitmap Font for resource named "'+t+'". The default font will be used.'),this.getDefaultBitmapFont();const c=this._imageManager.getPIXITexture(i);try{const r=p(PIXI.BitmapFont.install(o,c),e);return this._markBitmapFontAsUsed(e),r}catch(r){return n.error('Could not load the Bitmap Font for resource named "'+t+'". The default font will be used. Error is: '+r),this.getDefaultBitmapFont()}}async processResource(t){}async loadResource(t){const i=this._resourceLoader.getResource(t);if(!i){n.warn('Unable to find bitmap font for resource "'+t+'".');return}if(!this._loadedFontsData.get(i))try{const o=await(await fetch(this._resourceLoader.getFullUrl(i.file),{credentials:this._resourceLoader.checkIfCredentialsRequired(i.file)?"include":"same-origin"})).text();this._loadedFontsData.set(i,o)}catch(e){n.error("Can't fetch the bitmap font file "+i.file+", error: "+e)}}dispose(){for(const t in this._pixiBitmapFontsInUse)PIXI.BitmapFont.uninstall(t);for(const t of this._pixiBitmapFontsToUninstall)PIXI.BitmapFont.uninstall(t);this._pixiBitmapFontsInUse={},this._pixiBitmapFontsToUninstall.length=0,this._loadedFontsData.clear()}}a.PixiBitmapFontManager=u,a.BitmapFontManager=a.PixiBitmapFontManager})(gdjs||(gdjs={}));
1
+ var gdjs;(function(o){const a=new o.Logger("Bitmap text"),l="GDJS-DEFAULT-BITMAP-FONT",d=5,p=(s,t)=>{const i=s.font;return s.font=t,PIXI.BitmapFont.available[t]=s,delete PIXI.BitmapFont.available[i],PIXI.BitmapFont.available[t]},m=["bitmapFont"];class f{constructor(t,i){this._pixiBitmapFontsInUse={};this._pixiBitmapFontsToUninstall=[];this._loadedFontsData=new o.ResourceCache;this._defaultSlugFontName=null;this._imageManager=i,this._resourceLoader=t}getResourceKinds(){return m}getDefaultBitmapFont(){if(this._defaultSlugFontName!==null)return PIXI.BitmapFont.available[this._defaultSlugFontName];const t="Arial",i=new PIXI.TextStyle({fontFamily:t,fontSize:20,padding:5,align:"left",fill:"#ffffff",wordWrap:!0,lineHeight:20}),e=p(PIXI.BitmapFont.from(t,i,{chars:[[" ","~"]]}),l);return this._defaultSlugFontName=e.font,e}_markBitmapFontAsUsed(t){this._pixiBitmapFontsInUse[t]=this._pixiBitmapFontsInUse[t]||{objectsUsingTheFont:0},this._pixiBitmapFontsInUse[t].objectsUsingTheFont++;for(let i=0;i<this._pixiBitmapFontsToUninstall.length;)this._pixiBitmapFontsToUninstall[i]===t?this._pixiBitmapFontsToUninstall.splice(i,1):i++}releaseBitmapFont(t){if(t!==l){if(!this._pixiBitmapFontsInUse[t]){a.warn("BitmapFont with name "+t+" was tried to be released but was never marked as used.");return}if(this._pixiBitmapFontsInUse[t].objectsUsingTheFont--,this._pixiBitmapFontsInUse[t].objectsUsingTheFont===0&&(delete this._pixiBitmapFontsInUse[t],this._pixiBitmapFontsToUninstall.includes(t)||this._pixiBitmapFontsToUninstall.push(t),this._pixiBitmapFontsToUninstall.length>d)){const i=this._pixiBitmapFontsToUninstall.shift();PIXI.BitmapFont.uninstall(i),a.log("Bitmap Text",'Uninstalled BitmapFont "'+i+'" from memory.')}}}obtainBitmapFont(t,i){const e=t+"@"+i;if(PIXI.BitmapFont.available[e])return this._markBitmapFontAsUsed(e),PIXI.BitmapFont.available[e];const n=this._loadedFontsData.getFromName(t);if(!n)return a.warn('Could not find Bitmap Font for resource named "'+t+'". The default font will be used.'),this.getDefaultBitmapFont();const F=this._imageManager.getPIXITexture(i);try{const r=p(PIXI.BitmapFont.install(n,F),e);return this._markBitmapFontAsUsed(e),r}catch(r){return a.error('Could not load the Bitmap Font for resource named "'+t+'". The default font will be used. Error is: '+r),this.getDefaultBitmapFont()}}async processResource(t){}async loadResource(t){const i=this._resourceLoader.getResource(t);if(!i){a.warn('Unable to find bitmap font for resource "'+t+'".');return}if(!this._loadedFontsData.get(i))try{const n=await(await fetch(this._resourceLoader.getFullUrl(i.file),{credentials:this._resourceLoader.checkIfCredentialsRequired(i.file)?"include":"same-origin"})).text();this._loadedFontsData.set(i,n)}catch(e){a.error("Can't fetch the bitmap font file "+i.file+", error: "+e)}}dispose(){for(const t in this._pixiBitmapFontsInUse)PIXI.BitmapFont.uninstall(t);for(const t of this._pixiBitmapFontsToUninstall)PIXI.BitmapFont.uninstall(t);this._pixiBitmapFontsInUse={},this._pixiBitmapFontsToUninstall.length=0,this._loadedFontsData.clear()}unloadResourcesList(t){t.forEach(i=>{this._loadedFontsData.get(i)&&this._loadedFontsData.delete(i);for(const n in this._pixiBitmapFontsInUse)n.endsWith(i.file)&&PIXI.BitmapFont.uninstall(n);for(const n of this._pixiBitmapFontsToUninstall)n.endsWith(i.file)&&PIXI.BitmapFont.uninstall(n)})}}o.PixiBitmapFontManager=f,o.BitmapFontManager=o.PixiBitmapFontManager})(gdjs||(gdjs={}));
2
2
  //# sourceMappingURL=pixi-bitmapfont-manager.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../GDevelop/GDJS/Runtime/pixi-renderers/pixi-bitmapfont-manager.ts"],
4
- "sourcesContent": ["/*\n * GDevelop JS Platform\n * Copyright 2021-present Aur\u00E9lien Vivet (bouh.vivez@gmail.com). All rights reserved.\n * This project is released under the MIT License.\n */\nnamespace gdjs {\n const logger = new gdjs.Logger('Bitmap text');\n\n const defaultBitmapFontKey = 'GDJS-DEFAULT-BITMAP-FONT';\n\n // When a font is unused, we put it in a cache of unused fonts. It's unloaded\n // from memory only when the cache is full and the font is at the last position\n // in the cache.\n // Set this to 0 to unload from memory (\"uninstall\") as soon as a font is unused.\n const uninstallCacheSize = 5;\n\n /**\n * We patch the installed font to use a name that is unique for each font data and texture,\n * to avoid conflicts between different font files using the same font name (by default, the\n * font name used by Pixi is the one inside the font data, but this name is not necessarily unique.\n * For example, 2 resources can use the same font, or we can have multiple objects with the same\n * font data and different textures).\n */\n const patchInstalledBitmapFont = (\n bitmapFont: PIXI.BitmapFont,\n bitmapFontInstallKey: string\n ) => {\n const defaultName = bitmapFont.font;\n // @ts-ignore - we \"hack\" into Pixi to change the font name\n bitmapFont.font = bitmapFontInstallKey;\n PIXI.BitmapFont.available[bitmapFontInstallKey] = bitmapFont;\n delete PIXI.BitmapFont.available[defaultName];\n return PIXI.BitmapFont.available[bitmapFontInstallKey];\n };\n\n const resourceKinds: Array<ResourceKind> = ['bitmapFont'];\n\n /**\n * PixiBitmapFontManager loads fnt/xml files (using `fetch`), from the \"bitmapFont\" resources of the game.\n *\n * It installs the \"BitmapFont\" with PixiJS to be used with PIXI.BitmapText.\n */\n export class PixiBitmapFontManager implements gdjs.ResourceManager {\n private _imageManager: gdjs.PixiImageManager;\n\n /** Pixi.BitmapFont used, indexed by their BitmapFont name. */\n private _pixiBitmapFontsInUse: Record<\n string,\n { objectsUsingTheFont: number }\n > = {};\n\n /** Pixi.BitmapFont not used anymore, but not yet uninstalled, indexed by their BitmapFont name. */\n private _pixiBitmapFontsToUninstall: string[] = [];\n\n /** Loaded fonts data, indexed by resource name. */\n private _loadedFontsData = new gdjs.ResourceCache<any>();\n\n private _defaultSlugFontName: string | null = null;\n\n _resourceLoader: gdjs.ResourceLoader;\n\n /**\n * @param resourceLoader The resources loader of the game.\n * @param imageManager The image manager to be used to get textures used by fonts.\n */\n constructor(\n resourceLoader: gdjs.ResourceLoader,\n imageManager: gdjs.PixiImageManager\n ) {\n this._imageManager = imageManager;\n this._resourceLoader = resourceLoader;\n }\n\n getResourceKinds(): ResourceKind[] {\n return resourceKinds;\n }\n\n /**\n * Get the instance of the default `Pixi.BitmapFont`, always available.\n */\n getDefaultBitmapFont() {\n if (this._defaultSlugFontName !== null) {\n return PIXI.BitmapFont.available[this._defaultSlugFontName];\n }\n\n // Default bitmap font style\n const fontFamily = 'Arial';\n const bitmapFontStyle = new PIXI.TextStyle({\n fontFamily: fontFamily,\n fontSize: 20,\n padding: 5,\n align: 'left',\n fill: '#ffffff',\n wordWrap: true,\n lineHeight: 20,\n });\n\n // Generate default bitmapFont, and replace the name of PIXI.BitmapFont by a unique name\n const defaultBitmapFont = patchInstalledBitmapFont(\n PIXI.BitmapFont.from(fontFamily, bitmapFontStyle, {\n // All the printable ASCII characters\n chars: [[' ', '~']],\n }),\n defaultBitmapFontKey\n );\n\n // Define the default name used for the default bitmap font.\n this._defaultSlugFontName = defaultBitmapFont.font;\n return defaultBitmapFont;\n }\n\n /**\n * Called to specify that the bitmap font with the specified key is used by an object\n * (i.e: this is reference counting).\n * `releaseBitmapFont` *must* be called to mark the font as not used anymore when the\n * object is destroyed or its font changed.\n *\n * @param bitmapFontInstallKey Name of the font of the BitmapFont (`bitmapFont.font`)\n */\n private _markBitmapFontAsUsed(bitmapFontInstallKey: string): void {\n this._pixiBitmapFontsInUse[bitmapFontInstallKey] = this\n ._pixiBitmapFontsInUse[bitmapFontInstallKey] || {\n objectsUsingTheFont: 0,\n };\n this._pixiBitmapFontsInUse[bitmapFontInstallKey].objectsUsingTheFont++;\n\n for (let i = 0; i < this._pixiBitmapFontsToUninstall.length; ) {\n if (this._pixiBitmapFontsToUninstall[i] === bitmapFontInstallKey) {\n // The font is in the cache of fonts to uninstall, because it was previously used and then marked as not used anymore.\n // Remove it from the cache to avoid the font getting uninstalled.\n this._pixiBitmapFontsToUninstall.splice(i, 1);\n } else {\n i++;\n }\n }\n }\n\n /**\n * When a font is not used by an object anymore (object destroyed or font changed),\n * call this function to decrease the internal count of objects using the font.\n *\n * When a font is not unused anymore, it goes in a temporary cache. The cache holds up to 10 fonts.\n * If the cache reaches its maximum capacity, the oldest font is uninstalled from memory.\n *\n * @param bitmapFontInstallKey Name of the font of the BitmapFont (`bitmapFont.font`)\n */\n releaseBitmapFont(bitmapFontInstallKey: string) {\n if (bitmapFontInstallKey === defaultBitmapFontKey) {\n // Never uninstall the default font.\n return;\n }\n\n if (!this._pixiBitmapFontsInUse[bitmapFontInstallKey]) {\n logger.warn(\n 'BitmapFont with name ' +\n bitmapFontInstallKey +\n ' was tried to be released but was never marked as used.'\n );\n return;\n }\n this._pixiBitmapFontsInUse[bitmapFontInstallKey].objectsUsingTheFont--;\n\n if (\n this._pixiBitmapFontsInUse[bitmapFontInstallKey].objectsUsingTheFont ===\n 0\n ) {\n delete this._pixiBitmapFontsInUse[bitmapFontInstallKey];\n\n // Add the font name at the last position of the cache.\n if (!this._pixiBitmapFontsToUninstall.includes(bitmapFontInstallKey)) {\n this._pixiBitmapFontsToUninstall.push(bitmapFontInstallKey);\n }\n if (this._pixiBitmapFontsToUninstall.length > uninstallCacheSize) {\n // Remove the first font (i.e: the oldest one)\n const oldestUnloadedPixiBitmapFontName =\n this._pixiBitmapFontsToUninstall.shift() as string;\n\n PIXI.BitmapFont.uninstall(oldestUnloadedPixiBitmapFontName);\n logger.log(\n 'Bitmap Text',\n 'Uninstalled BitmapFont \"' +\n oldestUnloadedPixiBitmapFontName +\n '\" from memory.'\n );\n }\n }\n }\n\n /**\n * Given a bitmap font resource name and a texture atlas resource name, returns the PIXI.BitmapFont\n * for it.\n * The font is register and should be released with `releaseBitmapFont` - so that it can be removed\n * from memory when unused.\n */\n obtainBitmapFont(\n bitmapFontResourceName: string,\n textureAtlasResourceName: string\n ): PIXI.BitmapFont {\n const bitmapFontInstallKey =\n bitmapFontResourceName + '@' + textureAtlasResourceName;\n\n if (PIXI.BitmapFont.available[bitmapFontInstallKey]) {\n // Return the existing BitmapFont that is already in memory and already installed.\n this._markBitmapFontAsUsed(bitmapFontInstallKey);\n return PIXI.BitmapFont.available[bitmapFontInstallKey];\n }\n\n // The Bitmap Font is not loaded, load it in memory.\n\n // First get the font data:\n const fontData = this._loadedFontsData.getFromName(\n bitmapFontResourceName\n );\n if (!fontData) {\n logger.warn(\n 'Could not find Bitmap Font for resource named \"' +\n bitmapFontResourceName +\n '\". The default font will be used.'\n );\n return this.getDefaultBitmapFont();\n }\n\n // Get the texture to be used in the font:\n const texture = this._imageManager.getPIXITexture(\n textureAtlasResourceName\n );\n\n try {\n // Create and install the Pixi.BitmapFont in memory:\n const bitmapFont = patchInstalledBitmapFont(\n PIXI.BitmapFont.install(fontData, texture),\n bitmapFontInstallKey\n );\n this._markBitmapFontAsUsed(bitmapFontInstallKey);\n return bitmapFont;\n } catch (error) {\n logger.error(\n 'Could not load the Bitmap Font for resource named \"' +\n bitmapFontResourceName +\n '\". The default font will be used. Error is: ' +\n error\n );\n return this.getDefaultBitmapFont();\n }\n }\n\n async processResource(resourceName: string): Promise<void> {\n // Do nothing because fonts are light enough to be parsed in background.\n }\n\n /**\n * Load the \"bitmapFont\" resources of the game, so that they are ready\n * to be used when `obtainBitmapFont` is called.\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 bitmap font for resource \"' + resourceName + '\".'\n );\n return;\n }\n if (this._loadedFontsData.get(resource)) {\n return;\n }\n\n try {\n const response = await fetch(\n this._resourceLoader.getFullUrl(resource.file),\n {\n credentials: this._resourceLoader.checkIfCredentialsRequired(\n resource.file\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 'include'\n : // For other resources, use \"same-origin\" as done by default by fetch.\n 'same-origin',\n }\n );\n const fontData = await response.text();\n this._loadedFontsData.set(resource, fontData);\n } catch (error) {\n logger.error(\n \"Can't fetch the bitmap font file \" +\n resource.file +\n ', error: ' +\n error\n );\n }\n }\n\n /**\n * To be called when the game is disposed.\n * Uninstall all the fonts from memory and clear cache of loaded fonts.\n */\n dispose(): void {\n for (const bitmapFontInstallKey in this._pixiBitmapFontsInUse) {\n PIXI.BitmapFont.uninstall(bitmapFontInstallKey);\n }\n\n for (const bitmapFontInstallKey of this._pixiBitmapFontsToUninstall) {\n PIXI.BitmapFont.uninstall(bitmapFontInstallKey);\n }\n\n this._pixiBitmapFontsInUse = {};\n this._pixiBitmapFontsToUninstall.length = 0;\n this._loadedFontsData.clear();\n }\n }\n\n // Register the class to let the engine use it.\n export const BitmapFontManager = gdjs.PixiBitmapFontManager;\n export type BitmapFontManager = gdjs.PixiBitmapFontManager;\n}\n"],
5
- "mappings": "AAKA,GAAU,MAAV,UAAU,EAAV,CACE,KAAM,GAAS,GAAI,GAAK,OAAO,eAEzB,EAAuB,2BAMvB,EAAqB,EASrB,EAA2B,CAC/B,EACA,IACG,CACH,KAAM,GAAc,EAAW,KAE/B,SAAW,KAAO,EAClB,KAAK,WAAW,UAAU,GAAwB,EAClD,MAAO,MAAK,WAAW,UAAU,GAC1B,KAAK,WAAW,UAAU,IAG7B,EAAqC,CAAC,cAOrC,OAA4D,CAuBjE,YACE,EACA,EACA,CAtBM,2BAGJ,GAGI,iCAAwC,GAGxC,sBAAmB,GAAI,GAAK,cAE5B,0BAAsC,KAY5C,KAAK,cAAgB,EACrB,KAAK,gBAAkB,EAGzB,kBAAmC,CACjC,MAAO,GAMT,sBAAuB,CACrB,GAAI,KAAK,uBAAyB,KAChC,MAAO,MAAK,WAAW,UAAU,KAAK,sBAIxC,KAAM,GAAa,QAC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,CACA,SAAO,MACL,sDACE,EACA,+CACA,GAEG,KAAK,6BAIV,iBAAgB,EAAqC,OAQrD,cAAa,EAAqC,CACtD,KAAM,GAAW,KAAK,gBAAgB,YAAY,GAClD,GAAI,CAAC,EAAU,CACb,EAAO,KACL,4CAA8C,EAAe,MAE/D,OAEF,GAAI,MAAK,iBAAiB,IAAI,GAI9B,GAAI,CAcF,KAAM,GAAW,KAAM,AAbN,MAAM,OACrB,KAAK,gBAAgB,WAAW,EAAS,MACzC,CACE,YAAa,KAAK,gBAAgB,2BAChC,EAAS,MAIP,UAEA,iBAGwB,OAChC,KAAK,iBAAiB,IAAI,EAAU,SAC7B,EAAP,CACA,EAAO,MACL,oCACE,EAAS,KACT,YACA,IASR,SAAgB,CACd,SAAW,KAAwB,MAAK,sBACtC,KAAK,WAAW,UAAU,GAG5B,SAAW,KAAwB,MAAK,4BACtC,KAAK,WAAW,UAAU,GAG5B,KAAK,sBAAwB,GAC7B,KAAK,4BAA4B,OAAS,EAC1C,KAAK,iBAAiB,SAzQnB,EAAM,wBA8QA,oBAAoB,EAAK,wBAnT9B",
4
+ "sourcesContent": ["/*\n * GDevelop JS Platform\n * Copyright 2021-present Aur\u00E9lien Vivet (bouh.vivez@gmail.com). All rights reserved.\n * This project is released under the MIT License.\n */\nnamespace gdjs {\n const logger = new gdjs.Logger('Bitmap text');\n\n const defaultBitmapFontKey = 'GDJS-DEFAULT-BITMAP-FONT';\n\n // When a font is unused, we put it in a cache of unused fonts. It's unloaded\n // from memory only when the cache is full and the font is at the last position\n // in the cache.\n // Set this to 0 to unload from memory (\"uninstall\") as soon as a font is unused.\n const uninstallCacheSize = 5;\n\n /**\n * We patch the installed font to use a name that is unique for each font data and texture,\n * to avoid conflicts between different font files using the same font name (by default, the\n * font name used by Pixi is the one inside the font data, but this name is not necessarily unique.\n * For example, 2 resources can use the same font, or we can have multiple objects with the same\n * font data and different textures).\n */\n const patchInstalledBitmapFont = (\n bitmapFont: PIXI.BitmapFont,\n bitmapFontInstallKey: string\n ) => {\n const defaultName = bitmapFont.font;\n // @ts-ignore - we \"hack\" into Pixi to change the font name\n bitmapFont.font = bitmapFontInstallKey;\n PIXI.BitmapFont.available[bitmapFontInstallKey] = bitmapFont;\n delete PIXI.BitmapFont.available[defaultName];\n return PIXI.BitmapFont.available[bitmapFontInstallKey];\n };\n\n const resourceKinds: Array<ResourceKind> = ['bitmapFont'];\n\n /**\n * PixiBitmapFontManager loads fnt/xml files (using `fetch`), from the \"bitmapFont\" resources of the game.\n *\n * It installs the \"BitmapFont\" with PixiJS to be used with PIXI.BitmapText.\n */\n export class PixiBitmapFontManager implements gdjs.ResourceManager {\n private _imageManager: gdjs.PixiImageManager;\n\n /** Pixi.BitmapFont used, indexed by their BitmapFont name. */\n private _pixiBitmapFontsInUse: Record<\n string,\n { objectsUsingTheFont: number }\n > = {};\n\n /** Pixi.BitmapFont not used anymore, but not yet uninstalled, indexed by their BitmapFont name. */\n private _pixiBitmapFontsToUninstall: string[] = [];\n\n /** Loaded fonts data, indexed by resource name. */\n private _loadedFontsData = new gdjs.ResourceCache<any>();\n\n private _defaultSlugFontName: string | null = null;\n\n _resourceLoader: gdjs.ResourceLoader;\n\n /**\n * @param resourceLoader The resources loader of the game.\n * @param imageManager The image manager to be used to get textures used by fonts.\n */\n constructor(\n resourceLoader: gdjs.ResourceLoader,\n imageManager: gdjs.PixiImageManager\n ) {\n this._imageManager = imageManager;\n this._resourceLoader = resourceLoader;\n }\n\n getResourceKinds(): ResourceKind[] {\n return resourceKinds;\n }\n\n /**\n * Get the instance of the default `Pixi.BitmapFont`, always available.\n */\n getDefaultBitmapFont() {\n if (this._defaultSlugFontName !== null) {\n return PIXI.BitmapFont.available[this._defaultSlugFontName];\n }\n\n // Default bitmap font style\n const fontFamily = 'Arial';\n const bitmapFontStyle = new PIXI.TextStyle({\n fontFamily: fontFamily,\n fontSize: 20,\n padding: 5,\n align: 'left',\n fill: '#ffffff',\n wordWrap: true,\n lineHeight: 20,\n });\n\n // Generate default bitmapFont, and replace the name of PIXI.BitmapFont by a unique name\n const defaultBitmapFont = patchInstalledBitmapFont(\n PIXI.BitmapFont.from(fontFamily, bitmapFontStyle, {\n // All the printable ASCII characters\n chars: [[' ', '~']],\n }),\n defaultBitmapFontKey\n );\n\n // Define the default name used for the default bitmap font.\n this._defaultSlugFontName = defaultBitmapFont.font;\n return defaultBitmapFont;\n }\n\n /**\n * Called to specify that the bitmap font with the specified key is used by an object\n * (i.e: this is reference counting).\n * `releaseBitmapFont` *must* be called to mark the font as not used anymore when the\n * object is destroyed or its font changed.\n *\n * @param bitmapFontInstallKey Name of the font of the BitmapFont (`bitmapFont.font`)\n */\n private _markBitmapFontAsUsed(bitmapFontInstallKey: string): void {\n this._pixiBitmapFontsInUse[bitmapFontInstallKey] = this\n ._pixiBitmapFontsInUse[bitmapFontInstallKey] || {\n objectsUsingTheFont: 0,\n };\n this._pixiBitmapFontsInUse[bitmapFontInstallKey].objectsUsingTheFont++;\n\n for (let i = 0; i < this._pixiBitmapFontsToUninstall.length; ) {\n if (this._pixiBitmapFontsToUninstall[i] === bitmapFontInstallKey) {\n // The font is in the cache of fonts to uninstall, because it was previously used and then marked as not used anymore.\n // Remove it from the cache to avoid the font getting uninstalled.\n this._pixiBitmapFontsToUninstall.splice(i, 1);\n } else {\n i++;\n }\n }\n }\n\n /**\n * When a font is not used by an object anymore (object destroyed or font changed),\n * call this function to decrease the internal count of objects using the font.\n *\n * When a font is not unused anymore, it goes in a temporary cache. The cache holds up to 10 fonts.\n * If the cache reaches its maximum capacity, the oldest font is uninstalled from memory.\n *\n * @param bitmapFontInstallKey Name of the font of the BitmapFont (`bitmapFont.font`)\n */\n releaseBitmapFont(bitmapFontInstallKey: string) {\n if (bitmapFontInstallKey === defaultBitmapFontKey) {\n // Never uninstall the default font.\n return;\n }\n\n if (!this._pixiBitmapFontsInUse[bitmapFontInstallKey]) {\n logger.warn(\n 'BitmapFont with name ' +\n bitmapFontInstallKey +\n ' was tried to be released but was never marked as used.'\n );\n return;\n }\n this._pixiBitmapFontsInUse[bitmapFontInstallKey].objectsUsingTheFont--;\n\n if (\n this._pixiBitmapFontsInUse[bitmapFontInstallKey].objectsUsingTheFont ===\n 0\n ) {\n delete this._pixiBitmapFontsInUse[bitmapFontInstallKey];\n\n // Add the font name at the last position of the cache.\n if (!this._pixiBitmapFontsToUninstall.includes(bitmapFontInstallKey)) {\n this._pixiBitmapFontsToUninstall.push(bitmapFontInstallKey);\n }\n if (this._pixiBitmapFontsToUninstall.length > uninstallCacheSize) {\n // Remove the first font (i.e: the oldest one)\n const oldestUnloadedPixiBitmapFontName =\n this._pixiBitmapFontsToUninstall.shift() as string;\n\n PIXI.BitmapFont.uninstall(oldestUnloadedPixiBitmapFontName);\n logger.log(\n 'Bitmap Text',\n 'Uninstalled BitmapFont \"' +\n oldestUnloadedPixiBitmapFontName +\n '\" from memory.'\n );\n }\n }\n }\n\n /**\n * Given a bitmap font resource name and a texture atlas resource name, returns the PIXI.BitmapFont\n * for it.\n * The font is register and should be released with `releaseBitmapFont` - so that it can be removed\n * from memory when unused.\n */\n obtainBitmapFont(\n bitmapFontResourceName: string,\n textureAtlasResourceName: string\n ): PIXI.BitmapFont {\n const bitmapFontInstallKey =\n bitmapFontResourceName + '@' + textureAtlasResourceName;\n\n if (PIXI.BitmapFont.available[bitmapFontInstallKey]) {\n // Return the existing BitmapFont that is already in memory and already installed.\n this._markBitmapFontAsUsed(bitmapFontInstallKey);\n return PIXI.BitmapFont.available[bitmapFontInstallKey];\n }\n\n // The Bitmap Font is not loaded, load it in memory.\n\n // First get the font data:\n const fontData = this._loadedFontsData.getFromName(\n bitmapFontResourceName\n );\n if (!fontData) {\n logger.warn(\n 'Could not find Bitmap Font for resource named \"' +\n bitmapFontResourceName +\n '\". The default font will be used.'\n );\n return this.getDefaultBitmapFont();\n }\n\n // Get the texture to be used in the font:\n const texture = this._imageManager.getPIXITexture(\n textureAtlasResourceName\n );\n\n try {\n // Create and install the Pixi.BitmapFont in memory:\n const bitmapFont = patchInstalledBitmapFont(\n PIXI.BitmapFont.install(fontData, texture),\n bitmapFontInstallKey\n );\n this._markBitmapFontAsUsed(bitmapFontInstallKey);\n return bitmapFont;\n } catch (error) {\n logger.error(\n 'Could not load the Bitmap Font for resource named \"' +\n bitmapFontResourceName +\n '\". The default font will be used. Error is: ' +\n error\n );\n return this.getDefaultBitmapFont();\n }\n }\n\n async processResource(resourceName: string): Promise<void> {\n // Do nothing because fonts are light enough to be parsed in background.\n }\n\n /**\n * Load the \"bitmapFont\" resources of the game, so that they are ready\n * to be used when `obtainBitmapFont` is called.\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 bitmap font for resource \"' + resourceName + '\".'\n );\n return;\n }\n if (this._loadedFontsData.get(resource)) {\n return;\n }\n\n try {\n const response = await fetch(\n this._resourceLoader.getFullUrl(resource.file),\n {\n credentials: this._resourceLoader.checkIfCredentialsRequired(\n resource.file\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 'include'\n : // For other resources, use \"same-origin\" as done by default by fetch.\n 'same-origin',\n }\n );\n const fontData = await response.text();\n this._loadedFontsData.set(resource, fontData);\n } catch (error) {\n logger.error(\n \"Can't fetch the bitmap font file \" +\n resource.file +\n ', error: ' +\n error\n );\n }\n }\n\n /**\n * To be called when the game is disposed.\n * Uninstall all the fonts from memory and clear cache of loaded fonts.\n */\n dispose(): void {\n for (const bitmapFontInstallKey in this._pixiBitmapFontsInUse) {\n PIXI.BitmapFont.uninstall(bitmapFontInstallKey);\n }\n\n for (const bitmapFontInstallKey of this._pixiBitmapFontsToUninstall) {\n PIXI.BitmapFont.uninstall(bitmapFontInstallKey);\n }\n\n this._pixiBitmapFontsInUse = {};\n this._pixiBitmapFontsToUninstall.length = 0;\n this._loadedFontsData.clear();\n }\n\n /**\n * Unload the specified list of resources:\n * this uninstalls fonts from memory and clear cache of loaded fonts.\n *\n * Usually called when scene resoures are unloaded.\n *\n * @param resourcesList The list of specific resources\n */\n\n unloadResourcesList(resourcesList: ResourceData[]): void {\n resourcesList.forEach((resourceData) => {\n const loadedFont = this._loadedFontsData.get(resourceData);\n if (loadedFont) {\n this._loadedFontsData.delete(resourceData);\n }\n\n for (const bitmapFontInstallKey in this._pixiBitmapFontsInUse) {\n if (bitmapFontInstallKey.endsWith(resourceData.file))\n PIXI.BitmapFont.uninstall(bitmapFontInstallKey);\n }\n\n for (const bitmapFontInstallKey of this._pixiBitmapFontsToUninstall) {\n if (bitmapFontInstallKey.endsWith(resourceData.file))\n PIXI.BitmapFont.uninstall(bitmapFontInstallKey);\n }\n });\n }\n }\n\n // Register the class to let the engine use it.\n export const BitmapFontManager = gdjs.PixiBitmapFontManager;\n export type BitmapFontManager = gdjs.PixiBitmapFontManager;\n}\n"],
5
+ "mappings": "AAKA,GAAU,MAAV,UAAU,EAAV,CACE,KAAM,GAAS,GAAI,GAAK,OAAO,eAEzB,EAAuB,2BAMvB,EAAqB,EASrB,EAA2B,CAC/B,EACA,IACG,CACH,KAAM,GAAc,EAAW,KAE/B,SAAW,KAAO,EAClB,KAAK,WAAW,UAAU,GAAwB,EAClD,MAAO,MAAK,WAAW,UAAU,GAC1B,KAAK,WAAW,UAAU,IAG7B,EAAqC,CAAC,cAOrC,OAA4D,CAuBjE,YACE,EACA,EACA,CAtBM,2BAGJ,GAGI,iCAAwC,GAGxC,sBAAmB,GAAI,GAAK,cAE5B,0BAAsC,KAY5C,KAAK,cAAgB,EACrB,KAAK,gBAAkB,EAGzB,kBAAmC,CACjC,MAAO,GAMT,sBAAuB,CACrB,GAAI,KAAK,uBAAyB,KAChC,MAAO,MAAK,WAAW,UAAU,KAAK,sBAIxC,KAAM,GAAa,QACb,EAAkB,GAAI,MAAK,UAAU,CACzC,WAAY,EACZ,SAAU,GACV,QAAS,EACT,MAAO,OACP,KAAM,UACN,SAAU,GACV,WAAY,KA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AAK,gBAAgB,YAAY,GAClD,GAAI,CAAC,EAAU,CACb,EAAO,KACL,4CAA8C,EAAe,MAE/D,OAEF,GAAI,MAAK,iBAAiB,IAAI,GAI9B,GAAI,CAcF,KAAM,GAAW,KAAM,AAbN,MAAM,OACrB,KAAK,gBAAgB,WAAW,EAAS,MACzC,CACE,YAAa,KAAK,gBAAgB,2BAChC,EAAS,MAIP,UAEA,iBAGwB,OAChC,KAAK,iBAAiB,IAAI,EAAU,SAC7B,EAAP,CACA,EAAO,MACL,oCACE,EAAS,KACT,YACA,IASR,SAAgB,CACd,SAAW,KAAwB,MAAK,sBACtC,KAAK,WAAW,UAAU,GAG5B,SAAW,KAAwB,MAAK,4BACtC,KAAK,WAAW,UAAU,GAG5B,KAAK,sBAAwB,GAC7B,KAAK,4BAA4B,OAAS,EAC1C,KAAK,iBAAiB,QAYxB,oBAAoB,EAAqC,CACvD,EAAc,QAAQ,AAAC,GAAiB,CAEtC,AAAI,AADe,KAAK,iBAAiB,IAAI,IAE3C,KAAK,iBAAiB,OAAO,GAG/B,SAAW,KAAwB,MAAK,sBACtC,AAAI,EAAqB,SAAS,EAAa,OAC7C,KAAK,WAAW,UAAU,GAG9B,SAAW,KAAwB,MAAK,4BACtC,AAAI,EAAqB,SAAS,EAAa,OAC7C,KAAK,WAAW,UAAU,MAnS7B,EAAM,wBA0SA,oBAAoB,EAAK,wBA/U9B",
6
6
  "names": []
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../GDevelop/GDJS/Runtime/pixi-renderers/pixi-effects-manager.ts"],
4
- "sourcesContent": ["/*\n * GDevelop JS Platform\n * Copyright 2013-2021 Florian Rival (Florian.Rival@gmail.com). All rights reserved.\n * This project is released under the MIT License.\n */\nnamespace gdjs {\n type RendererEffects = Record<string, gdjs.PixiFiltersTools.Filter>;\n\n export interface EffectsTarget {\n getRuntimeScene: () => gdjs.RuntimeInstanceContainer;\n getElapsedTime: (\n instanceContainer?: gdjs.RuntimeInstanceContainer\n ) => number;\n getHeight: () => number;\n getWidth: () => number;\n isLightingLayer?: () => boolean;\n getName: () => string;\n getRendererObject: () => RendererObjectInterface | null | undefined;\n get3DRendererObject: () => THREE.Object3D | null | undefined;\n }\n\n /**\n * Handle effects (aka PixiJS \"filters\") on PixiJS objects.\n */\n class PixiEffectsManager {\n /**\n * Initialize the renderer effect (PixiJS filter) from the effect data.\n * Call the applyEffect method afterwards, to correctly apply the\n * initialized effects on the object.\n * @param effectData The effect data\n * @param rendererEffects The collection of PixiJS filters\n * @param target The effects target\n */\n initializeEffect(\n effectData: EffectData,\n rendererEffects: RendererEffects,\n target: EffectsTarget\n ): boolean {\n const filterCreator = gdjs.PixiFiltersTools.getFilterCreator(\n effectData.effectType\n );\n if (!filterCreator) {\n console.warn(\n `Effect: \"${\n effectData.name\n }\", on layer: \"${target.getName()}\", has an unknown effect type: \"${\n effectData.effectType\n }\". Was it registered properly? Is the effect type correct?`\n );\n return false;\n }\n\n rendererEffects[effectData.name] = filterCreator.makeFilter(\n target,\n effectData\n );\n return true;\n }\n\n /**\n * Update the filters applied on a PixiJS DisplayObject.\n * This must be called after the events and before the rendering.\n *\n * This allows effects to be sure that they are up to date and ready\n * to render. This is not called on objects that are not rendered on screen\n * (\"culling\"). This is always called on layers.\n */\n updatePreRender(rendererEffects: RendererEffects, target: EffectsTarget) {\n for (const filterName in rendererEffects) {\n const filter = rendererEffects[filterName];\n filter.updatePreRender(target);\n }\n }\n\n /**\n * Add a new effect on a PixiJS DisplayObject, or replace the one\n * with the same name.\n * @param effectData The effect data\n * @param rendererEffects The renderer effects\n * @param target The effects target\n */\n addEffect(\n effectData: EffectData,\n rendererEffects: RendererEffects,\n target: EffectsTarget\n ): boolean {\n let effectAdded = true;\n effectAdded =\n this.initializeEffect(effectData, rendererEffects, target) &&\n effectAdded;\n effectAdded =\n this.updateAllEffectParameters(rendererEffects, effectData) &&\n effectAdded;\n\n if (rendererEffects[effectData.name]) {\n effectAdded =\n rendererEffects[effectData.name].applyEffect(target) && effectAdded;\n }\n return effectAdded;\n }\n\n /**\n * Remove the effect with the specified name from a PixiJS DisplayObject.\n * @param rendererEffects The collection of PixiJS filters.\n * @param rendererObject The renderer object.\n * @param effectName The name of the effect.\n */\n removeEffect(\n rendererEffects: RendererEffects,\n target: EffectsTarget,\n effectName: string\n ): boolean {\n const filter = rendererEffects[effectName];\n if (!filter) return false;\n\n filter.removeEffect(target);\n\n delete rendererEffects[effectName];\n return true;\n }\n\n /**\n * Remove all effects from a PixiJS DisplayObject.\n * @param rendererObject The renderer object.\n */\n clearEffects(rendererObject: PIXI.DisplayObject): boolean {\n if (rendererObject) {\n rendererObject.filters = [];\n }\n return true;\n }\n\n /**\n * Update the property of an effect (with a number).\n * @param rendererEffects The collection of PixiJS filters.\n * @param name The effect name\n * @param parameterName The property name\n * @param value The new value for the property\n */\n setEffectDoubleParameter(\n rendererEffects: RendererEffects,\n name: string,\n parameterName: string,\n value: float\n ): boolean {\n const filter = rendererEffects[name];\n if (!filter) return false;\n filter.updateDoubleParameter(parameterName, value);\n return true;\n }\n\n /**\n * Update the property of an effect (with a string).\n * @param rendererEffects The collection of PixiJS filters.\n * @param name The effect name\n * @param parameterName The property name\n * @param value The new value for the property\n */\n setEffectStringParameter(\n rendererEffects: RendererEffects,\n name: string,\n parameterName: string,\n value: string\n ): boolean {\n const filter = rendererEffects[name];\n if (!filter) return false;\n filter.updateStringParameter(parameterName, value);\n return true;\n }\n\n /**\n * Enable or disable the property of an effect (boolean).\n * @param rendererEffects The collection of PixiJS filters.\n * @param name The effect name\n * @param parameterName The property name\n * @param value The new value for the property\n */\n setEffectBooleanParameter(\n rendererEffects: RendererEffects,\n name: string,\n parameterName: string,\n value: boolean\n ): boolean {\n const filter = rendererEffects[name];\n if (!filter) return false;\n filter.updateBooleanParameter(parameterName, value);\n return true;\n }\n\n /**\n * Updates all the effect properties.\n * @param rendererEffects\n * @param effectData\n */\n updateAllEffectParameters(\n rendererEffects: RendererEffects,\n effectData: EffectData\n ): boolean {\n let updatedDoubles = true;\n let updatedStrings = true;\n let updatedBooleans = true;\n for (let name in effectData.doubleParameters) {\n updatedDoubles =\n this.setEffectDoubleParameter(\n rendererEffects,\n effectData.name,\n name,\n effectData.doubleParameters[name]\n ) && updatedDoubles;\n }\n for (let name in effectData.stringParameters) {\n updatedStrings =\n this.setEffectStringParameter(\n rendererEffects,\n effectData.name,\n name,\n effectData.stringParameters[name]\n ) && updatedStrings;\n }\n for (let name in effectData.booleanParameters) {\n updatedBooleans =\n this.setEffectBooleanParameter(\n rendererEffects,\n effectData.name,\n name,\n effectData.booleanParameters[name]\n ) && updatedBooleans;\n }\n\n return updatedDoubles && updatedStrings && updatedBooleans;\n }\n\n /**\n * Check if an effect exists.\n * @param rendererEffects The collection of PixiJS filters.\n * @param name The effect name\n * @returns True if the effect exists, false otherwise\n */\n hasEffect(rendererEffects: RendererEffects, name: string): boolean {\n return !!rendererEffects[name];\n }\n\n /**\n * Enable an effect.\n * @param rendererEffects The collection of PixiJS filters.\n * @param name The effect name\n * @param value Set to true to enable, false to disable\n */\n enableEffect(\n rendererEffects: RendererEffects,\n target: EffectsTarget,\n name: string,\n value: boolean\n ): void {\n const filter = rendererEffects[name];\n if (!filter) return;\n filter.setEnabled(target, value);\n }\n\n /**\n * Check if an effect is enabled.\n * @param rendererEffects The collection of PixiJS filters.\n * @param name The effect name\n * @return true if the filter is enabled\n */\n isEffectEnabled(\n rendererEffects: RendererEffects,\n target: EffectsTarget,\n name: string\n ): boolean {\n const filter = rendererEffects[name];\n if (!filter) return false;\n return filter.isEnabled(target);\n }\n }\n\n // Expose the effect manager to the game engine.\n export const EffectsManager = PixiEffectsManager;\n export type EffectsManager = PixiEffectsManager;\n}\n"],
5
- "mappings": "AAKA,GAAU,MAAV,UAAU,EAAV,CAmBE,OAAyB,CASvB,iBACE,EACA,EACA,EACS,CACT,KAAM,GAAgB,EAAK,iBAAiB,iBAC1C,EAAW,YAEb,MAAK,GAWL,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kB,EAS7C,UAAU,EAAkC,EAAuB,CACjE,MAAO,CAAC,CAAC,EAAgB,GAS3B,aACE,EACA,EACA,EACA,EACM,CACN,KAAM,GAAS,EAAgB,GAC/B,AAAI,CAAC,GACL,EAAO,WAAW,EAAQ,GAS5B,gBACE,EACA,EACA,EACS,CACT,KAAM,GAAS,EAAgB,GAC/B,MAAK,GACE,EAAO,UAAU,GADJ,IAMjB,AAAM,iBAAiB,IAhRtB",
4
+ "sourcesContent": ["/*\n * GDevelop JS Platform\n * Copyright 2013-2021 Florian Rival (Florian.Rival@gmail.com). All rights reserved.\n * This project is released under the MIT License.\n */\nnamespace gdjs {\n type RendererEffects = Record<string, gdjs.PixiFiltersTools.Filter>;\n\n export interface EffectsTarget {\n getRuntimeScene: () => gdjs.RuntimeInstanceContainer;\n getElapsedTime: (\n instanceContainer?: gdjs.RuntimeInstanceContainer\n ) => number;\n getHeight: () => number;\n getWidth: () => number;\n isLightingLayer?: () => boolean;\n getName: () => string;\n getRendererObject: () => RendererObjectInterface | null | undefined;\n get3DRendererObject: () => THREE.Object3D | null | undefined;\n getRuntimeLayer?: () => gdjs.RuntimeLayer;\n }\n\n /**\n * Handle effects (aka PixiJS \"filters\") on PixiJS objects.\n */\n class PixiEffectsManager {\n /**\n * Initialize the renderer effect (PixiJS filter) from the effect data.\n * Call the applyEffect method afterwards, to correctly apply the\n * initialized effects on the object.\n * @param effectData The effect data\n * @param rendererEffects The collection of PixiJS filters\n * @param target The effects target\n */\n initializeEffect(\n effectData: EffectData,\n rendererEffects: RendererEffects,\n target: EffectsTarget\n ): boolean {\n const filterCreator = gdjs.PixiFiltersTools.getFilterCreator(\n effectData.effectType\n );\n if (!filterCreator) {\n console.warn(\n `Effect: \"${\n effectData.name\n }\", on layer: \"${target.getName()}\", has an unknown effect type: \"${\n effectData.effectType\n }\". Was it registered properly? Is the effect type correct?`\n );\n return false;\n }\n\n rendererEffects[effectData.name] = filterCreator.makeFilter(\n target,\n effectData\n );\n return true;\n }\n\n /**\n * Update the filters applied on a PixiJS DisplayObject.\n * This must be called after the events and before the rendering.\n *\n * This allows effects to be sure that they are up to date and ready\n * to render. This is not called on objects that are not rendered on screen\n * (\"culling\"). This is always called on layers.\n */\n updatePreRender(rendererEffects: RendererEffects, target: EffectsTarget) {\n for (const filterName in rendererEffects) {\n const filter = rendererEffects[filterName];\n filter.updatePreRender(target);\n }\n }\n\n /**\n * Add a new effect on a PixiJS DisplayObject, or replace the one\n * with the same name.\n * @param effectData The effect data\n * @param rendererEffects The renderer effects\n * @param target The effects target\n */\n addEffect(\n effectData: EffectData,\n rendererEffects: RendererEffects,\n target: EffectsTarget\n ): boolean {\n let effectAdded = true;\n effectAdded =\n this.initializeEffect(effectData, rendererEffects, target) &&\n effectAdded;\n effectAdded =\n this.updateAllEffectParameters(rendererEffects, effectData) &&\n effectAdded;\n\n if (rendererEffects[effectData.name]) {\n effectAdded =\n rendererEffects[effectData.name].applyEffect(target) && effectAdded;\n }\n return effectAdded;\n }\n\n /**\n * Remove the effect with the specified name from a PixiJS DisplayObject.\n * @param rendererEffects The collection of PixiJS filters.\n * @param rendererObject The renderer object.\n * @param effectName The name of the effect.\n */\n removeEffect(\n rendererEffects: RendererEffects,\n target: EffectsTarget,\n effectName: string\n ): boolean {\n const filter = rendererEffects[effectName];\n if (!filter) return false;\n\n filter.removeEffect(target);\n\n delete rendererEffects[effectName];\n return true;\n }\n\n /**\n * Remove all effects from a PixiJS DisplayObject.\n * @param rendererObject The renderer object.\n */\n clearEffects(rendererObject: PIXI.DisplayObject): boolean {\n if (rendererObject) {\n rendererObject.filters = [];\n }\n return true;\n }\n\n /**\n * Update the property of an effect (with a number).\n * @param rendererEffects The collection of PixiJS filters.\n * @param name The effect name\n * @param parameterName The property name\n * @param value The new value for the property\n */\n setEffectDoubleParameter(\n rendererEffects: RendererEffects,\n name: string,\n parameterName: string,\n value: float\n ): boolean {\n const filter = rendererEffects[name];\n if (!filter) return false;\n filter.updateDoubleParameter(parameterName, value);\n return true;\n }\n\n /**\n * Update the property of an effect (with a string).\n * @param rendererEffects The collection of PixiJS filters.\n * @param name The effect name\n * @param parameterName The property name\n * @param value The new value for the property\n */\n setEffectStringParameter(\n rendererEffects: RendererEffects,\n name: string,\n parameterName: string,\n value: string\n ): boolean {\n const filter = rendererEffects[name];\n if (!filter) return false;\n filter.updateStringParameter(parameterName, value);\n return true;\n }\n\n /**\n * Enable or disable the property of an effect (boolean).\n * @param rendererEffects The collection of PixiJS filters.\n * @param name The effect name\n * @param parameterName The property name\n * @param value The new value for the property\n */\n setEffectBooleanParameter(\n rendererEffects: RendererEffects,\n name: string,\n parameterName: string,\n value: boolean\n ): boolean {\n const filter = rendererEffects[name];\n if (!filter) return false;\n filter.updateBooleanParameter(parameterName, value);\n return true;\n }\n\n /**\n * Updates all the effect properties.\n * @param rendererEffects\n * @param effectData\n */\n updateAllEffectParameters(\n rendererEffects: RendererEffects,\n effectData: EffectData\n ): boolean {\n let updatedDoubles = true;\n let updatedStrings = true;\n let updatedBooleans = true;\n for (let name in effectData.doubleParameters) {\n updatedDoubles =\n this.setEffectDoubleParameter(\n rendererEffects,\n effectData.name,\n name,\n effectData.doubleParameters[name]\n ) && updatedDoubles;\n }\n for (let name in effectData.stringParameters) {\n updatedStrings =\n this.setEffectStringParameter(\n rendererEffects,\n effectData.name,\n name,\n effectData.stringParameters[name]\n ) && updatedStrings;\n }\n for (let name in effectData.booleanParameters) {\n updatedBooleans =\n this.setEffectBooleanParameter(\n rendererEffects,\n effectData.name,\n name,\n effectData.booleanParameters[name]\n ) && updatedBooleans;\n }\n\n return updatedDoubles && updatedStrings && updatedBooleans;\n }\n\n /**\n * Check if an effect exists.\n * @param rendererEffects The collection of PixiJS filters.\n * @param name The effect name\n * @returns True if the effect exists, false otherwise\n */\n hasEffect(rendererEffects: RendererEffects, name: string): boolean {\n return !!rendererEffects[name];\n }\n\n /**\n * Enable an effect.\n * @param rendererEffects The collection of PixiJS filters.\n * @param name The effect name\n * @param value Set to true to enable, false to disable\n */\n enableEffect(\n rendererEffects: RendererEffects,\n target: EffectsTarget,\n name: string,\n value: boolean\n ): void {\n const filter = rendererEffects[name];\n if (!filter) return;\n filter.setEnabled(target, value);\n }\n\n /**\n * Check if an effect is enabled.\n * @param rendererEffects The collection of PixiJS filters.\n * @param name The effect name\n * @return true if the filter is enabled\n */\n isEffectEnabled(\n rendererEffects: RendererEffects,\n target: EffectsTarget,\n name: string\n ): boolean {\n const filter = rendererEffects[name];\n if (!filter) return false;\n return filter.isEnabled(target);\n }\n }\n\n // Expose the effect manager to the game engine.\n export const EffectsManager = PixiEffectsManager;\n export type EffectsManager = PixiEffectsManager;\n}\n"],
5
+ "mappings": "AAKA,GAAU,MAAV,UAAU,EAAV,CAoBE,OAAyB,CASvB,iBACE,EACA,EACA,EACS,CACT,KAAM,GAAgB,EAAK,iBAAiB,iBAC1C,EAAW,YAEb,MAAK,GAWL,GAAgB,EAAW,MAAQ,EAAc,WAC/C,EACA,GAEK,IAdL,SAAQ,KACN,YACE,EAAW,qBACI,EAAO,4CACtB,EAAW,wEAGR,IAkBX,gBAAgB,EAAkC,EAAuB,CACvE,SAAW,KAAc,GAEvB,AADe,EAAgB,GACxB,gBAAgB,GAW3B,UACE,EACA,EACA,EACS,CACT,GAAI,GAAc,GAClB,SACE,KAAK,iBAAiB,EAAY,EAAiB,IACnD,EACF,EACE,KAAK,0BAA0B,EAAiB,IAChD,EAEE,EAAgB,EAAW,OAC7B,GACE,EAAgB,EAAW,MAAM,YAAY,IAAW,GAErD,EAST,aACE,EACA,EACA,EACS,CACT,KAAM,GAAS,EAAgB,GAC/B,MAAK,GAEL,GAAO,aAAa,GAEpB,MAAO,GAAgB,GAChB,IALa,GAYtB,aAAa,EAA6C,CACxD,MAAI,IACF,GAAe,QAAU,IAEpB,GAUT,yBACE,EACA,EACA,EACA,EACS,CACT,KAAM,GAAS,EAAgB,GAC/B,MAAK,GACL,GAAO,sBAAsB,EAAe,GACrC,IAFa,GAYtB,yBACE,EACA,EACA,EACA,EACS,CACT,KAAM,GAAS,EAAgB,GAC/B,MAAK,GACL,GAAO,sBAAsB,EAAe,GACrC,IAFa,GAYtB,0BACE,EACA,EACA,EACA,EACS,CACT,KAAM,GAAS,EAAgB,GAC/B,MAAK,GACL,GAAO,uBAAuB,EAAe,GACtC,IAFa,GAUtB,0BACE,EACA,EACS,CACT,GAAI,GAAiB,GACjB,EAAiB,GACjB,EAAkB,GACtB,OAAS,KAAQ,GAAW,iBAC1B,EACE,KAAK,yBACH,EACA,EAAW,KACX,EACA,EAAW,iBAAiB,KACzB,EAET,OAAS,KAAQ,GAAW,iBAC1B,EACE,KAAK,yBACH,EACA,EAAW,KACX,EACA,EAAW,iBAAiB,KACzB,EAET,OAAS,KAAQ,GAAW,kBAC1B,EACE,KAAK,0BACH,EACA,EAAW,KACX,EACA,EAAW,kBAAkB,KAC1B,EAGT,MAAO,IAAkB,GAAkB,EAS7C,UAAU,EAAkC,EAAuB,CACjE,MAAO,CAAC,CAAC,EAAgB,GAS3B,aACE,EACA,EACA,EACA,EACM,CACN,KAAM,GAAS,EAAgB,GAC/B,AAAI,CAAC,GACL,EAAO,WAAW,EAAQ,GAS5B,gBACE,EACA,EACA,EACS,CACT,KAAM,GAAS,EAAgB,GAC/B,MAAK,GACE,EAAO,UAAU,GADJ,IAMjB,AAAM,iBAAiB,IAjRtB",
6
6
  "names": []
7
7
  }
@@ -1,2 +1,2 @@
1
- var gdjs;(function(l){const n=new l.Logger("PIXI Image manager"),T=(u,e)=>{n.error("Unable to load file "+u+" with error:",e||"(unknown error)")},d=(u,e)=>{!u||e.smoothed||(u.baseTexture.scaleMode=PIXI.SCALE_MODES.NEAREST)},A=(u,e)=>{e&&!e.smoothed&&(u.magFilter=THREE.NearestFilter,u.minFilter=THREE.NearestFilter)},g=["image","video"];class x{constructor(e){this._loadedTextures=new l.ResourceCache;this._diskTextures=new Map;this._rectangleTextures=new Map;this._scaledTextures=new Map;this._getImageResource=e=>{const r=this._resourceLoader.getResource(e);return r&&this.getResourceKinds().includes(r.kind)?r:null};this._resourceLoader=e,this._invalidTexture=PIXI.Texture.from("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMAAAADACAMAAABlApw1AAAAkFBMVEWdIvr///+hOfrx6v7i0/39/P+eK/rn2v6vbPv7+f/cx/359v/38v7s4v7Wvf3LqvzFnvysY/v18P6jQvrz7P7u5P7ezP3Or/yoV/qlTfrq3v7l1v3hz/2fLvrTuPy0efufMvraxP3YwP3AlPu2fvuuavvRtPy8i/uqXfu5hvvIo/y4gvuxcvugNfq+j/vCmfxfwZ2lAAAF60lEQVR42uzPMQ0AAAjEQPBvmhkBDE+uAppcdXgfAHXY9R4AAAAAAAAAAGAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAEA/YAQAMNfa2nCoMhmE4HxhcFESggMhGtNa11NLl/d9dO53pQRMklPKn4TllhuEdEjb/CK/WWPXvBTjOOVxvDsvVO3u03e8EnC9BZnNMwNcfYDU728NkLpoDLpmPSQU6Ax5vNsfE0lpbwOs1AYGbroDnBCQyPQH7tQsanpYAqwQVftEQEKWgE9AHtAkIpTV1QBOD1Jk4IPJA6y9tQF2C2Io24ApqXq4OMHgBvTsSBjgVBnA9P7HH2xEGPOM+7hVPQdhGUZRvt4/WeHvCgBJ3uFXYsn4m/BO3HJ2Ko8XuMSogQBdvzXoYFRCjQ3GazWQuRIfKms1o0Skge3DmMxvdckiWzoyGu0dIvGhO0+kAkmBW4/UVRPw0qwAfopKpmRPwh0N0ZGrmBPyDyI2Yms6AaiH48nd3g8hmsijMFkrZ9UQSwCFY9j+EHpgor1wM4gaO9oAKog0TtDEGuxoQIF7DOcZwqQEB4kJe4Bt83QHOEiJLuAGe2QG2KuAF37HUHVAn0wZsdAfs/WkD8pkHrGrtSyhWBVgxhnti5m1itsZg/IUiIO4NKJQBzoFjoJjRB6hfZA0T/U8xTEASkMo7TfEtJLGa4CB81JYeZM3PAmQfUQUEtsUY+zx66N6I+MTuySFJPk48Sl9ACYH/1s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FdCsm0znD4Zg9/eC0a+JuVa0bOARb5BXpor4/v8qdOV7DDstvKQd4kYAfllW/l+Sx+RfzW+XDDy8V8BPnyc511wvHCQPb+F3DDDsIHcfJStc9p5w//zRrL1qazH7ZJ6nP4a8XOI77IlTAld4w4FVu7qqA31SAClABKkAFqAAVoAJUgApQASpABagAFaACVIAKUAH/TcB7e/uA7+03ZsJSaNOuAAAAAElFTkSuQmCC",{width:192,height:192}),this._loadedThreeTextures=new Hashtable,this._loadedThreeMaterials=new Hashtable}getResourceKinds(){return g}getPIXITexture(e){const r=this._getImageResource(e);if(!r)return n.warn('Unable to find texture for resource "'+e+'".'),this._invalidTexture;const t=this._loadedTextures.get(r);return t?t.valid?t:(n.error("Texture for "+e+" is not valid anymore (or never was)."),this._invalidTexture):this._invalidTexture}getOrLoadPIXITexture(e){const r=this._getImageResource(e);if(!r)return n.warn('Unable to find texture for resource "'+e+'".'),this._invalidTexture;const t=this._loadedTextures.get(r);if(t)return t.valid?t:(n.error("Texture for "+e+" is not valid anymore (or never was)."),this._invalidTexture);n.log('Loading texture for resource "'+e+'"...');const i=r.file,o=this._resourceLoader.getFullUrl(i),s=PIXI.Texture.from(o,{resourceOptions:{crossorigin:this._resourceLoader.checkIfCredentialsRequired(i)?"use-credentials":"anonymous"}}).on("error",a=>{T(i,a)});if(!s)throw new Error("Texture loading by PIXI returned nothing for file "+i+" behind url "+o);return d(s,r),this._loadedTextures.set(r,s),s}getThreeTexture(e){const r=this._loadedThreeTextures.get(e);if(r)return r;const t=this.getPIXITexture(e);if(!this._resourceLoader._runtimeGame.getRenderer().getPIXIRenderer())throw new Error("No PIXI renderer was found.");const o=t.baseTexture.resource.source;if(!(o instanceof HTMLImageElement))throw new Error(`Can't load texture for resource "${e}" as it's not an image.`);const s=new THREE.Texture(o);s.magFilter=THREE.LinearFilter,s.minFilter=THREE.LinearFilter,s.wrapS=THREE.RepeatWrapping,s.wrapT=THREE.RepeatWrapping,s.colorSpace=THREE.SRGBColorSpace,s.needsUpdate=!0;const a=this._getImageResource(e);return A(s,a),this._loadedThreeTextures.put(e,s),s}getThreeMaterial(e,{useTransparentTexture:r,forceBasicMaterial:t,vertexColors:i}){const o=`${e}|${r?1:0}|${t?1:0}|${i?1:0}`,s=this._loadedThreeMaterials.get(o);if(s)return s;const a=t?new THREE.MeshBasicMaterial({map:this.getThreeTexture(e),side:r?THREE.DoubleSide:THREE.FrontSide,transparent:r,vertexColors:i}):new THREE.MeshStandardMaterial({map:this.getThreeTexture(e),side:r?THREE.DoubleSide:THREE.FrontSide,transparent:r,metalness:0,vertexColors:i});return this._loadedThreeMaterials.put(o,a),a}getPIXIVideoTexture(e){if(e==="")return this._invalidTexture;const r=this._getImageResource(e);if(!r)return n.warn('Unable to find video texture for resource "'+e+'".'),this._invalidTexture;const t=this._loadedTextures.get(r);return t||this._invalidTexture}getInvalidPIXITexture(){return this._invalidTexture}async loadResource(e){const r=this._resourceLoader.getResource(e);if(!r){n.warn('Unable to find texture for resource "'+e+'".');return}await this._loadTexture(r)}async processResource(e){}async _loadTexture(e){if(!this._loadedTextures.get(e))try{if(e.kind==="video")await new Promise((r,t)=>{const i=PIXI.Texture.from(this._resourceLoader.getFullUrl(e.file),{resourceOptions:{crossorigin:this._resourceLoader.checkIfCredentialsRequired(e.file)?"use-credentials":"anonymous",autoPlay:!1}}).on("error",s=>{t(s)});i.baseTexture.on("loaded",()=>{this._loadedTextures.set(e,i),d(i,e),r()}).on("error",s=>{t(s)})});else{const r=PIXI.Texture.from(this._resourceLoader.getFullUrl(e.file),{resourceOptions:{autoLoad:!1,crossorigin:this._resourceLoader.checkIfCredentialsRequired(e.file)?"use-credentials":"anonymous"}});await r.baseTexture.resource.load(),this._loadedTextures.set(e,r),d(r,e)}}catch(r){T(e.file,r)}}getOrCreateDiskTexture(e,r){let t=this._diskTextures.get(e);if(!t){const i=new PIXI.Graphics;i.lineStyle(0,0,0),i.beginFill(l.rgbToHexNumber(255,255,255),1),i.drawCircle(0,0,e),i.endFill(),t=r.generateTexture(i),i.destroy(),this._diskTextures.set(e,t)}return t}getOrCreateRectangleTexture(e,r,t){const i=`${e}_${r}`;let o=this._rectangleTextures.get(i);if(!o){const s=new PIXI.Graphics;s.lineStyle(0,0,0),s.beginFill(l.rgbToHexNumber(255,255,255),1),s.drawRect(0,0,e,r),s.endFill(),o=t.generateTexture(s),s.destroy(),this._rectangleTextures.set(i,o)}return o}getOrCreateScaledTexture(e,r,t,i){const o=`${e}_${r}_${t}`;let s=this._scaledTextures.get(o);if(!s){const a=new PIXI.Graphics,c=new PIXI.Sprite(this.getPIXITexture(e));c.width=r,c.height=t,a.addChild(c),s=i.generateTexture(a),a.destroy(),this._scaledTextures.set(o,s)}return s}dispose(){this._loadedTextures.clear();const e=[];this._loadedThreeTextures.values(e),this._loadedThreeTextures.clear();for(const t of e)t.dispose();const r=[];this._loadedThreeMaterials.values(r),this._loadedThreeMaterials.clear();for(const t of r)t.dispose();for(const t of this._diskTextures.values())t.destroyed||t.destroy();this._diskTextures.clear();for(const t of this._rectangleTextures.values())t.destroyed||t.destroy();this._rectangleTextures.clear();for(const t of this._scaledTextures.values())t.destroyed||t.destroy();this._scaledTextures.clear()}}l.PixiImageManager=x,l.ImageManager=l.PixiImageManager})(gdjs||(gdjs={}));
1
+ var gdjs;(function(l){const n=new l.Logger("PIXI Image manager"),T=(u,e)=>{n.error("Unable to load file "+u+" with error:",e||"(unknown error)")},d=(u,e)=>{!u||e.smoothed||(u.baseTexture.scaleMode=PIXI.SCALE_MODES.NEAREST)},g=(u,e)=>{e&&!e.smoothed&&(u.magFilter=THREE.NearestFilter,u.minFilter=THREE.NearestFilter)},h=["image","video"];class x{constructor(e){this._loadedTextures=new l.ResourceCache;this._diskTextures=new Map;this._rectangleTextures=new Map;this._scaledTextures=new Map;this._getImageResource=e=>{const r=this._resourceLoader.getResource(e);return r&&this.getResourceKinds().includes(r.kind)?r:null};this._resourceLoader=e,this._invalidTexture=PIXI.Texture.from("data:image/png;base64,iVBORw0KGgo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nyc511wvHCQPb+F3DDDsIHcfJStc9p5w//zRrL1qazH7ZJ6nP4a8XOI77IlTAld4w4FVu7qqA31SAClABKkAFqAAVoAJUgApQASpABagAFaACVIAKUAH/TcB7e/uA7+03ZsJSaNOuAAAAAElFTkSuQmCC",{width:192,height:192}),this._loadedThreeTextures=new Hashtable,this._loadedThreeMaterials=new Hashtable}getResourceKinds(){return h}getPIXITexture(e){const r=this._getImageResource(e);if(!r)return n.warn('Unable to find texture for resource "'+e+'".'),this._invalidTexture;const t=this._loadedTextures.get(r);return t?t.valid?t:(n.error("Texture for "+e+" is not valid anymore (or never was)."),this._invalidTexture):this._invalidTexture}getOrLoadPIXITexture(e){const r=this._getImageResource(e);if(!r)return n.warn('Unable to find texture for resource "'+e+'".'),this._invalidTexture;const t=this._loadedTextures.get(r);if(t)return t.valid?t:(n.error("Texture for "+e+" is not valid anymore (or never was)."),this._invalidTexture);n.log('Loading texture for resource "'+e+'"...');const i=r.file,o=this._resourceLoader.getFullUrl(i),s=PIXI.Texture.from(o,{resourceOptions:{crossorigin:this._resourceLoader.checkIfCredentialsRequired(i)?"use-credentials":"anonymous"}}).on("error",a=>{T(i,a)});if(!s)throw new Error("Texture loading by PIXI returned nothing for file "+i+" behind url "+o);return d(s,r),this._loadedTextures.set(r,s),s}getThreeTexture(e){const r=this._loadedThreeTextures.get(e);if(r)return r;const t=this.getPIXITexture(e);if(!this._resourceLoader._runtimeGame.getRenderer().getPIXIRenderer())throw new Error("No PIXI renderer was found.");const o=t.baseTexture.resource.source;if(!(o instanceof HTMLImageElement))throw new Error(`Can't load texture for resource "${e}" as it's not an image.`);const s=new THREE.Texture(o);s.magFilter=THREE.LinearFilter,s.minFilter=THREE.LinearFilter,s.wrapS=THREE.RepeatWrapping,s.wrapT=THREE.RepeatWrapping,s.colorSpace=THREE.SRGBColorSpace,s.needsUpdate=!0;const a=this._getImageResource(e);return g(s,a),this._loadedThreeTextures.put(e,s),s}getThreeMaterial(e,{useTransparentTexture:r,forceBasicMaterial:t,vertexColors:i}){const o=`${e}|${r?1:0}|${t?1:0}|${i?1:0}`,s=this._loadedThreeMaterials.get(o);if(s)return s;const a=t?new THREE.MeshBasicMaterial({map:this.getThreeTexture(e),side:r?THREE.DoubleSide:THREE.FrontSide,transparent:r,vertexColors:i}):new THREE.MeshStandardMaterial({map:this.getThreeTexture(e),side:r?THREE.DoubleSide:THREE.FrontSide,transparent:r,metalness:0,vertexColors:i});return this._loadedThreeMaterials.put(o,a),a}getPIXIVideoTexture(e){if(e==="")return this._invalidTexture;const r=this._getImageResource(e);if(!r)return n.warn('Unable to find video texture for resource "'+e+'".'),this._invalidTexture;const t=this._loadedTextures.get(r);return t||this._invalidTexture}getInvalidPIXITexture(){return this._invalidTexture}async loadResource(e){const r=this._resourceLoader.getResource(e);if(!r){n.warn('Unable to find texture for resource "'+e+'".');return}await this._loadTexture(r)}async processResource(e){}async _loadTexture(e){if(!this._loadedTextures.get(e))try{if(e.kind==="video")await new Promise((r,t)=>{const i=PIXI.Texture.from(this._resourceLoader.getFullUrl(e.file),{resourceOptions:{crossorigin:this._resourceLoader.checkIfCredentialsRequired(e.file)?"use-credentials":"anonymous",autoPlay:!1}}).on("error",s=>{t(s)});i.baseTexture.on("loaded",()=>{this._loadedTextures.set(e,i),d(i,e),r()}).on("error",s=>{t(s)})});else{const r=PIXI.Texture.from(this._resourceLoader.getFullUrl(e.file),{resourceOptions:{autoLoad:!1,crossorigin:this._resourceLoader.checkIfCredentialsRequired(e.file)?"use-credentials":"anonymous"}});await r.baseTexture.resource.load(),this._loadedTextures.set(e,r),d(r,e)}}catch(r){T(e.file,r)}}getOrCreateDiskTexture(e,r){let t=this._diskTextures.get(e);if(!t){const i=new PIXI.Graphics;i.lineStyle(0,0,0),i.beginFill(l.rgbToHexNumber(255,255,255),1),i.drawCircle(0,0,e),i.endFill(),t=r.generateTexture(i),i.destroy(),this._diskTextures.set(e,t)}return t}getOrCreateRectangleTexture(e,r,t){const i=`${e}_${r}`;let o=this._rectangleTextures.get(i);if(!o){const s=new PIXI.Graphics;s.lineStyle(0,0,0),s.beginFill(l.rgbToHexNumber(255,255,255),1),s.drawRect(0,0,e,r),s.endFill(),o=t.generateTexture(s),s.destroy(),this._rectangleTextures.set(i,o)}return o}getOrCreateScaledTexture(e,r,t,i){const o=`${e}_${r}_${t}`;let s=this._scaledTextures.get(o);if(!s){const a=new PIXI.Graphics,c=new PIXI.Sprite(this.getPIXITexture(e));c.width=r,c.height=t,a.addChild(c),s=i.generateTexture(a),a.destroy(),this._scaledTextures.set(o,s)}return s}dispose(){this._loadedTextures.clear();const e=[];this._loadedThreeTextures.values(e),this._loadedThreeTextures.clear();for(const t of e)t.dispose();const r=[];this._loadedThreeMaterials.values(r),this._loadedThreeMaterials.clear();for(const t of r)t.dispose();for(const t of this._diskTextures.values())t.destroyed||t.destroy();this._diskTextures.clear();for(const t of this._rectangleTextures.values())t.destroyed||t.destroy();this._rectangleTextures.clear();for(const t of this._scaledTextures.values())t.destroyed||t.destroy();this._scaledTextures.clear()}unloadResourcesList(e){e.forEach(r=>{const t=r.name,i=this._loadedTextures.get(r);i&&(i.destroy(!0),this._loadedTextures.delete(r));const o=this._loadedThreeTextures.get(t);o&&(o.dispose(),this._loadedThreeTextures.remove(t));const s=this._loadedThreeMaterials.get(t);s&&(s.dispose(),this._loadedThreeMaterials.remove(t))})}}l.PixiImageManager=x,l.ImageManager=l.PixiImageManager})(gdjs||(gdjs={}));
2
2
  //# sourceMappingURL=pixi-image-manager.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../GDevelop/GDJS/Runtime/pixi-renderers/pixi-image-manager.ts"],
4
- "sourcesContent": ["/*\n * GDevelop JS Platform\n * Copyright 2013-2016 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('PIXI Image manager');\n\n const logFileLoadingError = (file: string, error: Error | undefined) => {\n logger.error(\n 'Unable to load file ' + file + ' with error:',\n error ? error : '(unknown error)'\n );\n };\n\n const applyTextureSettings = (\n texture: PIXI.Texture | undefined,\n resourceData: ResourceData\n ) => {\n if (!texture) return;\n\n if (!resourceData.smoothed) {\n texture.baseTexture.scaleMode = PIXI.SCALE_MODES.NEAREST;\n }\n };\n\n const applyThreeTextureSettings = (\n threeTexture: THREE.Texture,\n resourceData: ResourceData | null\n ) => {\n if (resourceData && !resourceData.smoothed) {\n threeTexture.magFilter = THREE.NearestFilter;\n threeTexture.minFilter = THREE.NearestFilter;\n }\n };\n\n const resourceKinds: Array<ResourceKind> = ['image', 'video'];\n\n /**\n * PixiImageManager loads and stores textures that can be used by the Pixi.js renderers.\n */\n export class PixiImageManager implements gdjs.ResourceManager {\n /**\n * The invalid texture is a 8x8 PNG file filled with magenta (#ff00ff), to be\n * easily spotted if rendered on screen.\n */\n private _invalidTexture: PIXI.Texture;\n\n /**\n * Map associating a resource name to the loaded PixiJS texture.\n */\n private _loadedTextures = new gdjs.ResourceCache<PIXI.Texture>();\n\n /**\n * Map associating a resource name to the loaded Three.js texture.\n */\n private _loadedThreeTextures: Hashtable<THREE.Texture>;\n private _loadedThreeMaterials: Hashtable<THREE.Material>;\n\n private _diskTextures = new Map<float, PIXI.Texture>();\n private _rectangleTextures = new Map<string, PIXI.Texture>();\n private _scaledTextures = new Map<string, PIXI.Texture>();\n\n private _resourceLoader: gdjs.ResourceLoader;\n\n /**\n * @param resourceLoader The resources loader of the game.\n */\n constructor(resourceLoader: gdjs.ResourceLoader) {\n this._resourceLoader = resourceLoader;\n this._invalidTexture = PIXI.Texture.from(\n 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMAAAADACAMAAABlApw1AAAAkFBMVEWdIvr///+hOfrx6v7i0/39/P+eK/rn2v6vbPv7+f/cx/359v/38v7s4v7Wvf3LqvzFnvysY/v18P6jQvrz7P7u5P7ezP3Or/yoV/qlTfrq3v7l1v3hz/2fLvrTuPy0efufMvraxP3YwP3AlPu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hashtable();\n this._loadedThreeMaterials = new Hashtable();\n }\n\n getResourceKinds(): ResourceKind[] {\n return resourceKinds;\n }\n\n /**\n * Return the PIXI texture associated to the specified resource name.\n * Returns a placeholder texture if not found.\n * @param resourceName The name of the resource\n * @returns The requested texture, or a placeholder if not found.\n */\n getPIXITexture(resourceName: string): PIXI.Texture {\n const resource = this._getImageResource(resourceName);\n if (!resource) {\n logger.warn(\n 'Unable to find texture for resource \"' + resourceName + '\".'\n );\n return this._invalidTexture;\n }\n\n const existingTexture = this._loadedTextures.get(resource);\n if (!existingTexture) {\n return this._invalidTexture;\n }\n if (!existingTexture.valid) {\n logger.error(\n 'Texture for ' +\n resourceName +\n ' is not valid anymore (or never was).'\n );\n return this._invalidTexture;\n }\n\n return existingTexture;\n }\n\n /**\n * Return the PIXI texture associated to the specified resource name.\n * If not found in the loaded textures, this method will try to load it.\n * Warning: this method should only be used in specific cases that cannot rely on\n * the initial resources loading of the game, such as the splashscreen.\n * @param resourceName The name of the resource\n * @returns The requested texture, or a placeholder if not valid.\n */\n getOrLoadPIXITexture(resourceName: string): PIXI.Texture {\n const resource = this._getImageResource(resourceName);\n if (!resource) {\n logger.warn(\n 'Unable to find texture for resource \"' + resourceName + '\".'\n );\n return this._invalidTexture;\n }\n\n const existingTexture = this._loadedTextures.get(resource);\n if (existingTexture) {\n if (existingTexture.valid) {\n return existingTexture;\n } else {\n logger.error(\n 'Texture for ' +\n resourceName +\n ' is not valid anymore (or never was).'\n );\n return this._invalidTexture;\n }\n }\n\n logger.log('Loading texture for resource \"' + resourceName + '\"...');\n const file = resource.file;\n const url = this._resourceLoader.getFullUrl(file);\n const texture = PIXI.Texture.from(url, {\n resourceOptions: {\n // Note that using `false`\n // to not having `crossorigin` at all would NOT work because the browser would taint the\n // loaded resource so that it can't be read/used in a canvas (it's only working for display `<img>` on screen).\n crossorigin: this._resourceLoader.checkIfCredentialsRequired(file)\n ? 'use-credentials'\n : 'anonymous',\n },\n }).on('error', (error) => {\n logFileLoadingError(file, error);\n });\n if (!texture) {\n throw new Error(\n 'Texture loading by PIXI returned nothing for file ' +\n file +\n ' behind url ' +\n url\n );\n }\n applyTextureSettings(texture, resource);\n\n this._loadedTextures.set(resource, texture);\n return texture;\n }\n\n /**\n * Return the three.js texture associated to the specified resource name.\n * Returns a placeholder texture if not found.\n * @param resourceName The name of the resource\n * @returns The requested texture, or a placeholder if not found.\n */\n getThreeTexture(resourceName: string): THREE.Texture {\n const loadedThreeTexture = this._loadedThreeTextures.get(resourceName);\n if (loadedThreeTexture) {\n return loadedThreeTexture;\n }\n\n // Texture is not loaded, load it now from the PixiJS texture.\n // TODO (3D) - optimization: don't load the PixiJS Texture if not used by PixiJS.\n // TODO (3D) - optimization: Ideally we could even share the same WebGL texture.\n const pixiTexture = this.getPIXITexture(resourceName);\n const pixiRenderer = this._resourceLoader._runtimeGame\n .getRenderer()\n .getPIXIRenderer();\n if (!pixiRenderer) throw new Error('No PIXI renderer was found.');\n\n // @ts-ignore - source does exist on resource.\n const image = pixiTexture.baseTexture.resource.source;\n if (!(image instanceof HTMLImageElement)) {\n throw new Error(\n `Can't load texture for resource \"${resourceName}\" as it's not an image.`\n );\n }\n\n const threeTexture = new THREE.Texture(image);\n threeTexture.magFilter = THREE.LinearFilter;\n threeTexture.minFilter = THREE.LinearFilter;\n threeTexture.wrapS = THREE.RepeatWrapping;\n threeTexture.wrapT = THREE.RepeatWrapping;\n threeTexture.colorSpace = THREE.SRGBColorSpace;\n threeTexture.needsUpdate = true;\n\n const resource = this._getImageResource(resourceName);\n\n applyThreeTextureSettings(threeTexture, resource);\n this._loadedThreeTextures.put(resourceName, threeTexture);\n\n return threeTexture;\n }\n\n /**\n * Return the three.js material associated to the specified resource name.\n * @param resourceName The name of the resource\n * @param options\n * @returns The requested material.\n */\n getThreeMaterial(\n resourceName: string,\n {\n useTransparentTexture,\n forceBasicMaterial,\n vertexColors,\n }: {\n useTransparentTexture: boolean;\n forceBasicMaterial: boolean;\n vertexColors: boolean;\n }\n ): THREE.Material {\n const cacheKey = `${resourceName}|${useTransparentTexture ? 1 : 0}|${\n forceBasicMaterial ? 1 : 0\n }|${vertexColors ? 1 : 0}`;\n\n const loadedThreeMaterial = this._loadedThreeMaterials.get(cacheKey);\n if (loadedThreeMaterial) return loadedThreeMaterial;\n\n const material = forceBasicMaterial\n ? new THREE.MeshBasicMaterial({\n map: this.getThreeTexture(resourceName),\n side: useTransparentTexture ? THREE.DoubleSide : THREE.FrontSide,\n transparent: useTransparentTexture,\n vertexColors,\n })\n : new THREE.MeshStandardMaterial({\n map: this.getThreeTexture(resourceName),\n side: useTransparentTexture ? THREE.DoubleSide : THREE.FrontSide,\n transparent: useTransparentTexture,\n metalness: 0,\n vertexColors,\n });\n this._loadedThreeMaterials.put(cacheKey, material);\n return material;\n }\n\n /**\n * Return the PIXI video texture associated to the specified resource name.\n * Returns a placeholder texture if not found.\n * @param resourceName The name of the resource to get.\n */\n getPIXIVideoTexture(resourceName: string) {\n if (resourceName === '') {\n return this._invalidTexture;\n }\n const resource = this._getImageResource(resourceName);\n if (!resource) {\n logger.warn(\n 'Unable to find video texture for resource \"' + resourceName + '\".'\n );\n return this._invalidTexture;\n }\n\n const texture = this._loadedTextures.get(resource);\n if (!texture) {\n return this._invalidTexture;\n }\n return texture;\n }\n\n private _getImageResource = (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 * Return a PIXI texture which can be used as a placeholder when no\n * suitable texture can be found.\n */\n getInvalidPIXITexture() {\n return this._invalidTexture;\n }\n\n /**\n * Load the specified resources, so that textures are loaded and can then be\n * used by calling `getPIXITexture`.\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 await this._loadTexture(resource);\n }\n\n async processResource(resourceName: string): Promise<void> {\n // Do nothing because images are light enough to be parsed in background.\n }\n\n /**\n * Load the specified resources, so that textures are loaded and can then be\n * used by calling `getPIXITexture`.\n * @param onProgress Callback called each time a new file is loaded.\n */\n async _loadTexture(resource: ResourceData): Promise<void> {\n if (this._loadedTextures.get(resource)) {\n return;\n }\n try {\n if (resource.kind === 'video') {\n // For videos, we want to preload them so they are available as soon as we want to use them.\n // We cannot use Pixi.assets.load() as it does not allow passing options (autoplay) to the resource loader.\n // Pixi.Texture.from() does not return a promise, so we need to ensure we look at the 'loaded' event of the baseTexture,\n // to continue, otherwise if we try to play the video too soon (at the beginning of scene for instance),\n // it will fail.\n await new Promise<void>((resolve, reject) => {\n const texture = PIXI.Texture.from(\n this._resourceLoader.getFullUrl(resource.file),\n {\n resourceOptions: {\n crossorigin: this._resourceLoader.checkIfCredentialsRequired(\n resource.file\n )\n ? 'use-credentials'\n : 'anonymous',\n autoPlay: false,\n },\n }\n ).on('error', (error) => {\n reject(error);\n });\n\n const baseTexture = texture.baseTexture;\n baseTexture\n .on('loaded', () => {\n this._loadedTextures.set(resource, texture);\n applyTextureSettings(texture, resource);\n resolve();\n })\n .on('error', (error) => {\n reject(error);\n });\n });\n } else {\n // If the file has no extension, PIXI.assets.load cannot find\n // an adequate load parser and does not load the file although\n // we would like to force it to load (we are confident it's an image).\n // TODO: When PIXI v8+ is used, PIXI.Assets.load can be used because\n // loadParser can be forced in PIXI.Assets.load\n // (see https://github.com/pixijs/pixijs/blob/71ed56c569ebc6b53da19e3c49258a0a84892101/packages/assets/src/loader/Loader.ts#L68)\n const loadedTexture = PIXI.Texture.from(\n this._resourceLoader.getFullUrl(resource.file),\n {\n resourceOptions: {\n autoLoad: false,\n crossorigin: this._resourceLoader.checkIfCredentialsRequired(\n resource.file\n )\n ? 'use-credentials'\n : 'anonymous',\n },\n }\n );\n await loadedTexture.baseTexture.resource.load();\n\n this._loadedTextures.set(resource, loadedTexture);\n // TODO What if 2 assets share the same file with different settings?\n applyTextureSettings(loadedTexture, resource);\n }\n } catch (error) {\n logFileLoadingError(resource.file, error);\n }\n }\n\n /**\n * Return a texture containing a circle filled with white.\n * @param radius The circle radius\n * @param pixiRenderer The renderer used to generate the texture\n */\n getOrCreateDiskTexture(\n radius: float,\n pixiRenderer: PIXI.Renderer\n ): PIXI.Texture {\n let particleTexture = this._diskTextures.get(radius);\n if (!particleTexture) {\n const graphics = new PIXI.Graphics();\n graphics.lineStyle(0, 0, 0);\n graphics.beginFill(gdjs.rgbToHexNumber(255, 255, 255), 1);\n graphics.drawCircle(0, 0, radius);\n graphics.endFill();\n particleTexture = pixiRenderer.generateTexture(graphics);\n graphics.destroy();\n\n this._diskTextures.set(radius, particleTexture);\n }\n return particleTexture;\n }\n\n /**\n * Return a texture filled with white.\n * @param width The texture width\n * @param height The texture height\n * @param pixiRenderer The renderer used to generate the texture\n */\n getOrCreateRectangleTexture(\n width: float,\n height: float,\n pixiRenderer: PIXI.Renderer\n ): PIXI.Texture {\n const key = `${width}_${height}`;\n let particleTexture = this._rectangleTextures.get(key);\n if (!particleTexture) {\n const graphics = new PIXI.Graphics();\n graphics.lineStyle(0, 0, 0);\n graphics.beginFill(gdjs.rgbToHexNumber(255, 255, 255), 1);\n graphics.drawRect(0, 0, width, height);\n graphics.endFill();\n particleTexture = pixiRenderer.generateTexture(graphics);\n graphics.destroy();\n\n this._rectangleTextures.set(key, particleTexture);\n }\n return particleTexture;\n }\n\n /**\n * Return a texture rescaled according to given dimensions.\n * @param width The texture width\n * @param height The texture height\n * @param pixiRenderer The renderer used to generate the texture\n */\n getOrCreateScaledTexture(\n imageResourceName: string,\n width: float,\n height: float,\n pixiRenderer: PIXI.Renderer\n ): PIXI.Texture {\n const key = `${imageResourceName}_${width}_${height}`;\n let particleTexture = this._scaledTextures.get(key);\n if (!particleTexture) {\n const graphics = new PIXI.Graphics();\n const sprite = new PIXI.Sprite(this.getPIXITexture(imageResourceName));\n sprite.width = width;\n sprite.height = height;\n graphics.addChild(sprite);\n particleTexture = pixiRenderer.generateTexture(graphics);\n graphics.destroy();\n\n this._scaledTextures.set(key, particleTexture);\n }\n return particleTexture;\n }\n\n /**\n * To be called when the game is disposed.\n * Clear caches of loaded textures and materials.\n */\n dispose(): void {\n this._loadedTextures.clear();\n\n const threeTextures: THREE.Texture[] = [];\n this._loadedThreeTextures.values(threeTextures);\n this._loadedThreeTextures.clear();\n for (const threeTexture of threeTextures) {\n threeTexture.dispose();\n }\n\n const threeMaterials: THREE.Material[] = [];\n this._loadedThreeMaterials.values(threeMaterials);\n this._loadedThreeMaterials.clear();\n for (const threeMaterial of threeMaterials) {\n threeMaterial.dispose();\n }\n\n for (const pixiTexture of this._diskTextures.values()) {\n if (pixiTexture.destroyed) {\n continue;\n }\n\n pixiTexture.destroy();\n }\n this._diskTextures.clear();\n\n for (const pixiTexture of this._rectangleTextures.values()) {\n if (pixiTexture.destroyed) {\n continue;\n }\n\n pixiTexture.destroy();\n }\n this._rectangleTextures.clear();\n\n for (const pixiTexture of this._scaledTextures.values()) {\n if (pixiTexture.destroyed) {\n continue;\n }\n\n pixiTexture.destroy();\n }\n this._scaledTextures.clear();\n }\n }\n\n //Register the class to let the engine use it.\n export const ImageManager = gdjs.PixiImageManager;\n export type ImageManager = gdjs.PixiImageManager;\n}\n"],
5
- "mappings": "AAKA,GAAU,MAAV,UAAU,EAAV,CACE,KAAM,GAAS,GAAI,GAAK,OAAO,sBAEzB,EAAsB,CAAC,EAAc,IAA6B,CACtE,EAAO,MACL,uBAAyB,EAAO,eAChC,GAAgB,oBAId,EAAuB,CAC3B,EACA,IACG,CACH,AAAI,CAAC,GAEA,EAAa,UAChB,GAAQ,YAAY,UAAY,KAAK,YAAY,UAI/C,EAA4B,CAChC,EACA,IACG,CACH,AAAI,GAAgB,CAAC,EAAa,UAChC,GAAa,UAAY,MAAM,cAC/B,EAAa,UAAY,MAAM,gBAI7B,EAAqC,CAAC,QAAS,SAK9C,OAAuD,CA2B5D,YAAY,EAAqC,CAjBzC,qBAAkB,GAAI,GAAK,cAQ3B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",
4
+ "sourcesContent": ["/*\n * GDevelop JS Platform\n * Copyright 2013-2016 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('PIXI Image manager');\n\n const logFileLoadingError = (file: string, error: Error | undefined) => {\n logger.error(\n 'Unable to load file ' + file + ' with error:',\n error ? error : '(unknown error)'\n );\n };\n\n const applyTextureSettings = (\n texture: PIXI.Texture | undefined,\n resourceData: ResourceData\n ) => {\n if (!texture) return;\n\n if (!resourceData.smoothed) {\n texture.baseTexture.scaleMode = PIXI.SCALE_MODES.NEAREST;\n }\n };\n\n const applyThreeTextureSettings = (\n threeTexture: THREE.Texture,\n resourceData: ResourceData | null\n ) => {\n if (resourceData && !resourceData.smoothed) {\n threeTexture.magFilter = THREE.NearestFilter;\n threeTexture.minFilter = THREE.NearestFilter;\n }\n };\n\n const resourceKinds: Array<ResourceKind> = ['image', 'video'];\n\n /**\n * PixiImageManager loads and stores textures that can be used by the Pixi.js renderers.\n */\n export class PixiImageManager implements gdjs.ResourceManager {\n /**\n * The invalid texture is a 8x8 PNG file filled with magenta (#ff00ff), to be\n * easily spotted if rendered on screen.\n */\n private _invalidTexture: PIXI.Texture;\n\n /**\n * Map associating a resource name to the loaded PixiJS texture.\n */\n private _loadedTextures = new gdjs.ResourceCache<PIXI.Texture>();\n\n /**\n * Map associating a resource name to the loaded Three.js texture.\n */\n private _loadedThreeTextures: Hashtable<THREE.Texture>;\n private _loadedThreeMaterials: Hashtable<THREE.Material>;\n\n private _diskTextures = new Map<float, PIXI.Texture>();\n private _rectangleTextures = new Map<string, PIXI.Texture>();\n private _scaledTextures = new Map<string, PIXI.Texture>();\n\n private _resourceLoader: gdjs.ResourceLoader;\n\n /**\n * @param resourceLoader The resources loader of the game.\n */\n constructor(resourceLoader: gdjs.ResourceLoader) {\n this._resourceLoader = resourceLoader;\n this._invalidTexture = PIXI.Texture.from(\n 'data:image/png;base64,iVBORw0KGgoAAAANS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vHCQPb+F3DDDsIHcfJStc9p5w//zRrL1qazH7ZJ6nP4a8XOI77IlTAld4w4FVu7qqA31SAClABKkAFqAAVoAJUgApQASpABagAFaACVIAKUAH/TcB7e/uA7+03ZsJSaNOuAAAAAElFTkSuQmCC',\n { width: 192, height: 192 }\n );\n this._loadedThreeTextures = new Hashtable();\n this._loadedThreeMaterials = new Hashtable();\n }\n\n getResourceKinds(): ResourceKind[] {\n return resourceKinds;\n }\n\n /**\n * Return the PIXI texture associated to the specified resource name.\n * Returns a placeholder texture if not found.\n * @param resourceName The name of the resource\n * @returns The requested texture, or a placeholder if not found.\n */\n getPIXITexture(resourceName: string): PIXI.Texture {\n const resource = this._getImageResource(resourceName);\n if (!resource) {\n logger.warn(\n 'Unable to find texture for resource \"' + resourceName + '\".'\n );\n return this._invalidTexture;\n }\n\n const existingTexture = this._loadedTextures.get(resource);\n if (!existingTexture) {\n return this._invalidTexture;\n }\n if (!existingTexture.valid) {\n logger.error(\n 'Texture for ' +\n resourceName +\n ' is not valid anymore (or never was).'\n );\n return this._invalidTexture;\n }\n\n return existingTexture;\n }\n\n /**\n * Return the PIXI texture associated to the specified resource name.\n * If not found in the loaded textures, this method will try to load it.\n * Warning: this method should only be used in specific cases that cannot rely on\n * the initial resources loading of the game, such as the splashscreen.\n * @param resourceName The name of the resource\n * @returns The requested texture, or a placeholder if not valid.\n */\n getOrLoadPIXITexture(resourceName: string): PIXI.Texture {\n const resource = this._getImageResource(resourceName);\n if (!resource) {\n logger.warn(\n 'Unable to find texture for resource \"' + resourceName + '\".'\n );\n return this._invalidTexture;\n }\n\n const existingTexture = this._loadedTextures.get(resource);\n if (existingTexture) {\n if (existingTexture.valid) {\n return existingTexture;\n } else {\n logger.error(\n 'Texture for ' +\n resourceName +\n ' is not valid anymore (or never was).'\n );\n return this._invalidTexture;\n }\n }\n\n logger.log('Loading texture for resource \"' + resourceName + '\"...');\n const file = resource.file;\n const url = this._resourceLoader.getFullUrl(file);\n const texture = PIXI.Texture.from(url, {\n resourceOptions: {\n // Note that using `false`\n // to not having `crossorigin` at all would NOT work because the browser would taint the\n // loaded resource so that it can't be read/used in a canvas (it's only working for display `<img>` on screen).\n crossorigin: this._resourceLoader.checkIfCredentialsRequired(file)\n ? 'use-credentials'\n : 'anonymous',\n },\n }).on('error', (error) => {\n logFileLoadingError(file, error);\n });\n if (!texture) {\n throw new Error(\n 'Texture loading by PIXI returned nothing for file ' +\n file +\n ' behind url ' +\n url\n );\n }\n applyTextureSettings(texture, resource);\n\n this._loadedTextures.set(resource, texture);\n return texture;\n }\n\n /**\n * Return the three.js texture associated to the specified resource name.\n * Returns a placeholder texture if not found.\n * @param resourceName The name of the resource\n * @returns The requested texture, or a placeholder if not found.\n */\n getThreeTexture(resourceName: string): THREE.Texture {\n const loadedThreeTexture = this._loadedThreeTextures.get(resourceName);\n if (loadedThreeTexture) {\n return loadedThreeTexture;\n }\n\n // Texture is not loaded, load it now from the PixiJS texture.\n // TODO (3D) - optimization: don't load the PixiJS Texture if not used by PixiJS.\n // TODO (3D) - optimization: Ideally we could even share the same WebGL texture.\n const pixiTexture = this.getPIXITexture(resourceName);\n const pixiRenderer = this._resourceLoader._runtimeGame\n .getRenderer()\n .getPIXIRenderer();\n if (!pixiRenderer) throw new Error('No PIXI renderer was found.');\n\n // @ts-ignore - source does exist on resource.\n const image = pixiTexture.baseTexture.resource.source;\n if (!(image instanceof HTMLImageElement)) {\n throw new Error(\n `Can't load texture for resource \"${resourceName}\" as it's not an image.`\n );\n }\n\n const threeTexture = new THREE.Texture(image);\n threeTexture.magFilter = THREE.LinearFilter;\n threeTexture.minFilter = THREE.LinearFilter;\n threeTexture.wrapS = THREE.RepeatWrapping;\n threeTexture.wrapT = THREE.RepeatWrapping;\n threeTexture.colorSpace = THREE.SRGBColorSpace;\n threeTexture.needsUpdate = true;\n\n const resource = this._getImageResource(resourceName);\n\n applyThreeTextureSettings(threeTexture, resource);\n this._loadedThreeTextures.put(resourceName, threeTexture);\n\n return threeTexture;\n }\n\n /**\n * Return the three.js material associated to the specified resource name.\n * @param resourceName The name of the resource\n * @param options\n * @returns The requested material.\n */\n getThreeMaterial(\n resourceName: string,\n {\n useTransparentTexture,\n forceBasicMaterial,\n vertexColors,\n }: {\n useTransparentTexture: boolean;\n forceBasicMaterial: boolean;\n vertexColors: boolean;\n }\n ): THREE.Material {\n const cacheKey = `${resourceName}|${useTransparentTexture ? 1 : 0}|${\n forceBasicMaterial ? 1 : 0\n }|${vertexColors ? 1 : 0}`;\n\n const loadedThreeMaterial = this._loadedThreeMaterials.get(cacheKey);\n if (loadedThreeMaterial) return loadedThreeMaterial;\n\n const material = forceBasicMaterial\n ? new THREE.MeshBasicMaterial({\n map: this.getThreeTexture(resourceName),\n side: useTransparentTexture ? THREE.DoubleSide : THREE.FrontSide,\n transparent: useTransparentTexture,\n vertexColors,\n })\n : new THREE.MeshStandardMaterial({\n map: this.getThreeTexture(resourceName),\n side: useTransparentTexture ? THREE.DoubleSide : THREE.FrontSide,\n transparent: useTransparentTexture,\n metalness: 0,\n vertexColors,\n });\n this._loadedThreeMaterials.put(cacheKey, material);\n return material;\n }\n\n /**\n * Return the PIXI video texture associated to the specified resource name.\n * Returns a placeholder texture if not found.\n * @param resourceName The name of the resource to get.\n */\n getPIXIVideoTexture(resourceName: string) {\n if (resourceName === '') {\n return this._invalidTexture;\n }\n const resource = this._getImageResource(resourceName);\n if (!resource) {\n logger.warn(\n 'Unable to find video texture for resource \"' + resourceName + '\".'\n );\n return this._invalidTexture;\n }\n\n const texture = this._loadedTextures.get(resource);\n if (!texture) {\n return this._invalidTexture;\n }\n return texture;\n }\n\n private _getImageResource = (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 * Return a PIXI texture which can be used as a placeholder when no\n * suitable texture can be found.\n */\n getInvalidPIXITexture() {\n return this._invalidTexture;\n }\n\n /**\n * Load the specified resources, so that textures are loaded and can then be\n * used by calling `getPIXITexture`.\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 await this._loadTexture(resource);\n }\n\n async processResource(resourceName: string): Promise<void> {\n // Do nothing because images are light enough to be parsed in background.\n }\n\n /**\n * Load the specified resources, so that textures are loaded and can then be\n * used by calling `getPIXITexture`.\n * @param onProgress Callback called each time a new file is loaded.\n */\n async _loadTexture(resource: ResourceData): Promise<void> {\n if (this._loadedTextures.get(resource)) {\n return;\n }\n try {\n if (resource.kind === 'video') {\n // For videos, we want to preload them so they are available as soon as we want to use them.\n // We cannot use Pixi.assets.load() as it does not allow passing options (autoplay) to the resource loader.\n // Pixi.Texture.from() does not return a promise, so we need to ensure we look at the 'loaded' event of the baseTexture,\n // to continue, otherwise if we try to play the video too soon (at the beginning of scene for instance),\n // it will fail.\n await new Promise<void>((resolve, reject) => {\n const texture = PIXI.Texture.from(\n this._resourceLoader.getFullUrl(resource.file),\n {\n resourceOptions: {\n crossorigin: this._resourceLoader.checkIfCredentialsRequired(\n resource.file\n )\n ? 'use-credentials'\n : 'anonymous',\n autoPlay: false,\n },\n }\n ).on('error', (error) => {\n reject(error);\n });\n\n const baseTexture = texture.baseTexture;\n baseTexture\n .on('loaded', () => {\n this._loadedTextures.set(resource, texture);\n applyTextureSettings(texture, resource);\n resolve();\n })\n .on('error', (error) => {\n reject(error);\n });\n });\n } else {\n // If the file has no extension, PIXI.assets.load cannot find\n // an adequate load parser and does not load the file although\n // we would like to force it to load (we are confident it's an image).\n // TODO: When PIXI v8+ is used, PIXI.Assets.load can be used because\n // loadParser can be forced in PIXI.Assets.load\n // (see https://github.com/pixijs/pixijs/blob/71ed56c569ebc6b53da19e3c49258a0a84892101/packages/assets/src/loader/Loader.ts#L68)\n const loadedTexture = PIXI.Texture.from(\n this._resourceLoader.getFullUrl(resource.file),\n {\n resourceOptions: {\n autoLoad: false,\n crossorigin: this._resourceLoader.checkIfCredentialsRequired(\n resource.file\n )\n ? 'use-credentials'\n : 'anonymous',\n },\n }\n );\n await loadedTexture.baseTexture.resource.load();\n\n this._loadedTextures.set(resource, loadedTexture);\n // TODO What if 2 assets share the same file with different settings?\n applyTextureSettings(loadedTexture, resource);\n }\n } catch (error) {\n logFileLoadingError(resource.file, error);\n }\n }\n\n /**\n * Return a texture containing a circle filled with white.\n * @param radius The circle radius\n * @param pixiRenderer The renderer used to generate the texture\n */\n getOrCreateDiskTexture(\n radius: float,\n pixiRenderer: PIXI.Renderer\n ): PIXI.Texture {\n let particleTexture = this._diskTextures.get(radius);\n if (!particleTexture) {\n const graphics = new PIXI.Graphics();\n graphics.lineStyle(0, 0, 0);\n graphics.beginFill(gdjs.rgbToHexNumber(255, 255, 255), 1);\n graphics.drawCircle(0, 0, radius);\n graphics.endFill();\n particleTexture = pixiRenderer.generateTexture(graphics);\n graphics.destroy();\n\n this._diskTextures.set(radius, particleTexture);\n }\n return particleTexture;\n }\n\n /**\n * Return a texture filled with white.\n * @param width The texture width\n * @param height The texture height\n * @param pixiRenderer The renderer used to generate the texture\n */\n getOrCreateRectangleTexture(\n width: float,\n height: float,\n pixiRenderer: PIXI.Renderer\n ): PIXI.Texture {\n const key = `${width}_${height}`;\n let particleTexture = this._rectangleTextures.get(key);\n if (!particleTexture) {\n const graphics = new PIXI.Graphics();\n graphics.lineStyle(0, 0, 0);\n graphics.beginFill(gdjs.rgbToHexNumber(255, 255, 255), 1);\n graphics.drawRect(0, 0, width, height);\n graphics.endFill();\n particleTexture = pixiRenderer.generateTexture(graphics);\n graphics.destroy();\n\n this._rectangleTextures.set(key, particleTexture);\n }\n return particleTexture;\n }\n\n /**\n * Return a texture rescaled according to given dimensions.\n * @param width The texture width\n * @param height The texture height\n * @param pixiRenderer The renderer used to generate the texture\n */\n getOrCreateScaledTexture(\n imageResourceName: string,\n width: float,\n height: float,\n pixiRenderer: PIXI.Renderer\n ): PIXI.Texture {\n const key = `${imageResourceName}_${width}_${height}`;\n let particleTexture = this._scaledTextures.get(key);\n if (!particleTexture) {\n const graphics = new PIXI.Graphics();\n const sprite = new PIXI.Sprite(this.getPIXITexture(imageResourceName));\n sprite.width = width;\n sprite.height = height;\n graphics.addChild(sprite);\n particleTexture = pixiRenderer.generateTexture(graphics);\n graphics.destroy();\n\n this._scaledTextures.set(key, particleTexture);\n }\n return particleTexture;\n }\n\n /**\n * To be called when the game is disposed.\n * Clear caches of loaded textures and materials.\n */\n dispose(): void {\n this._loadedTextures.clear();\n\n const threeTextures: THREE.Texture[] = [];\n this._loadedThreeTextures.values(threeTextures);\n this._loadedThreeTextures.clear();\n for (const threeTexture of threeTextures) {\n threeTexture.dispose();\n }\n\n const threeMaterials: THREE.Material[] = [];\n this._loadedThreeMaterials.values(threeMaterials);\n this._loadedThreeMaterials.clear();\n for (const threeMaterial of threeMaterials) {\n threeMaterial.dispose();\n }\n\n for (const pixiTexture of this._diskTextures.values()) {\n if (pixiTexture.destroyed) {\n continue;\n }\n\n pixiTexture.destroy();\n }\n this._diskTextures.clear();\n\n for (const pixiTexture of this._rectangleTextures.values()) {\n if (pixiTexture.destroyed) {\n continue;\n }\n\n pixiTexture.destroy();\n }\n this._rectangleTextures.clear();\n\n for (const pixiTexture of this._scaledTextures.values()) {\n if (pixiTexture.destroyed) {\n continue;\n }\n\n pixiTexture.destroy();\n }\n this._scaledTextures.clear();\n }\n\n /**\n * Unload the specified list of resources:\n * this clears the cache of loaded textures associated to these resources.\n *\n * Usually called when scene resoures are unloaded.\n *\n * @param resourcesList The list of specific resources\n */\n unloadResourcesList(resourcesList: ResourceData[]): void {\n resourcesList.forEach((resourceData) => {\n const resourceName = resourceData.name;\n const resource = this._loadedTextures.get(resourceData);\n if (resource) {\n resource.destroy(true);\n this._loadedTextures.delete(resourceData);\n }\n\n const threeTexture = this._loadedThreeTextures.get(resourceName);\n if (threeTexture) {\n threeTexture.dispose();\n this._loadedThreeTextures.remove(resourceName);\n }\n\n const threeMaterials = this._loadedThreeMaterials.get(resourceName);\n if (threeMaterials) {\n threeMaterials.dispose();\n this._loadedThreeMaterials.remove(resourceName);\n }\n });\n }\n }\n\n //Register the class to let the engine use it.\n export const ImageManager = gdjs.PixiImageManager;\n export type ImageManager = gdjs.PixiImageManager;\n}\n"],
5
+ "mappings": "AAKA,GAAU,MAAV,UAAU,EAAV,CACE,KAAM,GAAS,GAAI,GAAK,OAAO,sBAEzB,EAAsB,CAAC,EAAc,IAA6B,CACtE,EAAO,MACL,uBAAyB,EAAO,eAChC,GAAgB,oBAId,EAAuB,CAC3B,EACA,IACG,CACH,AAAI,CAAC,GAEA,EAAa,UAChB,GAAQ,YAAY,UAAY,KAAK,YAAY,UAI/C,EAA4B,CAChC,EACA,IACG,CACH,AAAI,GAAgB,CAAC,EAAa,UAChC,GAAa,UAAY,MAAM,cAC/B,EAAa,UAAY,MAAM,gBAI7B,EAAqC,CAAC,QAAS,SAK9C,OAAuD,CA2B5D,YAAY,EAAqC,CAjBzC,qBAAkB,GAAI,GAAK,cAQ3B,mBAAgB,GAAI,KACpB,wBAAqB,GAAI,KACzB,qBAAkB,GAAI,KAgOtB,uBAAoB,AAAC,GAA8C,CACzE,KAAM,GAAW,KAAK,gBAAgB,YAAY,GAClD,MAAO,IAAY,KAAK,mBAAmB,SAAS,EAAS,MACzD,EACA,MA5NJ,KAAK,gBAAkB,EACvB,KAAK,gBAAkB,KAAK,QAAQ,KAClC,yxEACA,CAAE,MAAO,IAAK,OAAQ,MAExB,KAAK,qBAAuB,GAAI,WAChC,KAAK,sBAAwB,GAAI,WAGnC,kBAAmC,CACjC,MAAO,GAST,eAAe,EAAoC,CACjD,KAAM,GAAW,KAAK,kBAAkB,GACxC,GAAI,CAAC,EACH,SAAO,KACL,wCAA0C,EAAe,MAEpD,KAAK,gBAGd,KAAM,GAAkB,KAAK,gBAAgB,IAAI,GACjD,MAAK,GAGA,EAAgB,MASd,EARL,GAAO,MACL,eACE,EACA,yCAEG,KA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O,MAAQ,EACf,EAAO,OAAS,EAChB,EAAS,SAAS,GAClB,EAAkB,EAAa,gBAAgB,GAC/C,EAAS,UAET,KAAK,gBAAgB,IAAI,EAAK,GAEhC,MAAO,GAOT,SAAgB,CACd,KAAK,gBAAgB,QAErB,KAAM,GAAiC,GACvC,KAAK,qBAAqB,OAAO,GACjC,KAAK,qBAAqB,QAC1B,SAAW,KAAgB,GACzB,EAAa,UAGf,KAAM,GAAmC,GACzC,KAAK,sBAAsB,OAAO,GAClC,KAAK,sBAAsB,QAC3B,SAAW,KAAiB,GAC1B,EAAc,UAGhB,SAAW,KAAe,MAAK,cAAc,SAC3C,AAAI,EAAY,WAIhB,EAAY,UAEd,KAAK,cAAc,QAEnB,SAAW,KAAe,MAAK,mBAAmB,SAChD,AAAI,EAAY,WAIhB,EAAY,UAEd,KAAK,mBAAmB,QAExB,SAAW,KAAe,MAAK,gBAAgB,SAC7C,AAAI,EAAY,WAIhB,EAAY,UAEd,KAAK,gBAAgB,QAWvB,oBAAoB,EAAqC,CACvD,EAAc,QAAQ,AAAC,GAAiB,CACtC,KAAM,GAAe,EAAa,KAC5B,EAAW,KAAK,gBAAgB,IAAI,GAC1C,AAAI,GACF,GAAS,QAAQ,IACjB,KAAK,gBAAgB,OAAO,IAG9B,KAAM,GAAe,KAAK,qBAAqB,IAAI,GACnD,AAAI,GACF,GAAa,UACb,KAAK,qBAAqB,OAAO,IAGnC,KAAM,GAAiB,KAAK,sBAAsB,IAAI,GACtD,AAAI,GACF,GAAe,UACf,KAAK,sBAAsB,OAAO,OA3fnC,EAAM,mBAkgBA,eAAe,EAAK,mBAtiBzB",
6
6
  "names": []
7
7
  }
@@ -1,2 +1,2 @@
1
- var gdjs;(function(l){const u=new l.Logger("PIXI game renderer"),m=[37,38,39,40];class R{constructor(e,t){this._isFullPage=!0;this._isFullscreen=!1;this._pixiRenderer=null;this._threeRenderer=null;this._gameCanvas=null;this._domElementsContainer=null;this._canvasWidth=0;this._canvasHeight=0;this._keepRatio=!0;this._nextFrameId=0;this._wasDisposed=!1;this.getElectronRemote=()=>{if(typeof require=="function"){const e=this._game.getAdditionalOptions(),t=e&&e.electronRemoteRequirePath?e.electronRemoteRequirePath:"@electron/remote";try{return require(t)}catch(i){console.error(`Could not load @electron/remote from "${t}". Error is:`,i)}}return null};this._game=e,this._forceFullscreen=t,this._marginLeft=this._marginTop=this._marginRight=this._marginBottom=0,this._setupOrientation()}createStandardCanvas(e){this._throwIfDisposed();const t=document.createElement("canvas");e.appendChild(t),this.initializeRenderers(t),this.initializeCanvas(t)}initializeRenderers(e){this._throwIfDisposed(),typeof THREE!="undefined"?(this._threeRenderer=new THREE.WebGLRenderer({canvas:e,antialias:this._game.getAntialiasingMode()!=="none"&&(this._game.isAntialisingEnabledOnMobile()||!l.evtTools.common.isMobile()),preserveDrawingBuffer:!0}),this._threeRenderer.useLegacyLights=!0,this._threeRenderer.autoClear=!1,this._threeRenderer.setSize(this._game.getGameResolutionWidth(),this._game.getGameResolutionHeight()),this._pixiRenderer=new PIXI.Renderer({width:this._game.getGameResolutionWidth(),height:this._game.getGameResolutionHeight(),view:e,context:this._threeRenderer.getContext(),clearBeforeRender:!1,preserveDrawingBuffer:!0,antialias:!1,backgroundAlpha:0})):this._pixiRenderer=PIXI.autoDetectRenderer({width:this._game.getGameResolutionWidth(),height:this._game.getGameResolutionHeight(),view:e,preserveDrawingBuffer:!0,antialias:!1}),this._pixiRenderer.plugins.accessibility.destroy(),delete this._pixiRenderer.plugins.accessibility}initializeCanvas(e){this._gameCanvas=e,e.style.position="absolute",e.tabIndex=1,e.style.userSelect="none",e.style.outline="none";const t=document.createElement("div");t.style.position="absolute",t.style.overflow="hidden",t.style.outline="none",t.style.pointerEvents="none",t.addEventListener("scroll",i=>{t.scrollLeft=0,t.scrollTop=0,i.preventDefault()}),e.addEventListener("pointerdown",()=>{e.focus()}),t.style["-webkit-user-select"]="none",e.parentNode?.appendChild(t),this._domElementsContainer=t,this._resizeCanvas(),this._game.getScaleMode()==="nearest"&&(e.style["image-rendering"]="-moz-crisp-edges",e.style["image-rendering"]="-webkit-optimize-contrast",e.style["image-rendering"]="-webkit-crisp-edges",e.style["image-rendering"]="pixelated"),this._game.getPixelsRounding()&&(PIXI.settings.ROUND_PIXELS=!0),window.addEventListener("resize",()=>{this._game.onWindowInnerSizeChanged(),this._resizeCanvas()}),e.focus()}static getWindowInnerWidth(){return typeof window!="undefined"?window.innerWidth:800}static getWindowInnerHeight(){return typeof window!="undefined"?window.innerHeight:800}updateRendererSize(){this._resizeCanvas()}_setupOrientation(){if(typeof window=="undefined"||!window.screen||!window.screen.orientation)return;const e=this._game.getGameData().properties.orientation;try{if(e==="default"){const t=window.screen.orientation.unlock();t&&t.catch(()=>{})}else window.screen.orientation.lock(e).catch(()=>{})}catch(t){u.error("Unexpected error while setting up orientation: ",t)}}_resizeCanvas(){if(!this._pixiRenderer||!this._domElementsContainer)return;(this._pixiRenderer.width!==this._game.getGameResolutionWidth()||this._pixiRenderer.height!==this._game.getGameResolutionHeight())&&(this._pixiRenderer.resize(this._game.getGameResolutionWidth(),this._game.getGameResolutionHeight()),this._threeRenderer&&this._threeRenderer.setSize(this._game.getGameResolutionWidth(),this._game.getGameResolutionHeight()));const e=this._forceFullscreen||this._isFullPage||this._isFullscreen;let t=this._game.getGameResolutionWidth(),i=this._game.getGameResolutionHeight(),o=window.innerWidth-this._marginLeft-this._marginRight,a=window.innerHeight-this._marginTop-this._marginBottom;if(o<0&&(o=0),a<0&&(a=0),e&&!this._keepRatio)t=o,i=a;else if(e&&this._keepRatio||t>o||i>a){let d=o/t;i*d>a&&(d=a/i),t*=d,i*=d}this._gameCanvas&&(this._gameCanvas.style.top=this._marginTop+(a-i)/2+"px",this._gameCanvas.style.left=this._marginLeft+(o-t)/2+"px",this._gameCanvas.style.width=t+"px",this._gameCanvas.style.height=i+"px"),this._domElementsContainer.style.top=this._marginTop+(a-i)/2+"px",this._domElementsContainer.style.left=this._marginLeft+(o-t)/2+"px",this._domElementsContainer.style.width=t+"px",this._domElementsContainer.style.height=i+"px",this._canvasWidth=t,this._canvasHeight=i}keepAspectRatio(e){this._keepRatio!==e&&(this._keepRatio=e,this._resizeCanvas())}setMargins(e,t,i,o){this._throwIfDisposed(),!(this._marginTop===e&&this._marginRight===t&&this._marginBottom===i&&this._marginLeft===o)&&(this._marginTop=e,this._marginRight=t,this._marginBottom=i,this._marginLeft=o,this._resizeCanvas())}setWindowSize(e,t){this._throwIfDisposed();const i=this.getElectronRemote();if(i){const o=i.getCurrentWindow();try{o&&o.setContentSize(e,t)}catch(a){u.error(`Window size setting to width ${e} and height ${t} failed. See error:`,a)}}else u.warn("Window size can't be changed on this platform.")}centerWindow(){this._throwIfDisposed();const e=this.getElectronRemote();if(e){const t=e.getCurrentWindow();try{t&&t.center()}catch(i){u.error("Window centering failed. See error:",i)}}else u.warn("Window can't be centered on this platform.")}setFullScreen(e){if(this._throwIfDisposed(),!this._forceFullscreen&&this._isFullscreen!==e){this._isFullscreen=!!e;const t=this.getElectronRemote();if(t){const i=t.getCurrentWindow();try{i&&i.setFullScreen(this._isFullscreen)}catch(o){u.error(`Full screen setting to ${this._isFullscreen} failed. See error:`,o)}}else this._isFullscreen?document.documentElement.requestFullscreen?document.documentElement.requestFullscreen():document.documentElement.mozRequestFullScreen?document.documentElement.mozRequestFullScreen():document.documentElement.webkitRequestFullScreen&&document.documentElement.webkitRequestFullScreen():document.exitFullscreen?document.exitFullscreen():document.mozCancelFullScreen?document.mozCancelFullScreen():document.webkitCancelFullScreen&&document.webkitCancelFullScreen();this._resizeCanvas()}}isFullScreen(){const e=this.getElectronRemote();if(e)try{return e.getCurrentWindow().isFullScreen()}catch(t){return u.error("Full screen detection failed. See error:",t),!1}return this._isFullscreen||window.screen.height===window.innerHeight}convertCanvasToDomElementContainerCoords(e,t){const i=t||[0,0];return i[0]=e[0]*this._canvasWidth/this._game.getGameResolutionWidth(),i[1]=e[1]*this._canvasHeight/this._game.getGameResolutionHeight(),i}getCanvasToDomElementContainerHeightScale(){return(this._canvasHeight||1)/this._game.getGameResolutionHeight()}convertPageToGameCoords(e,t){const i=this._gameCanvas;if(!i)return[0,0];const o=[e-i.offsetLeft,t-i.offsetTop];return o[0]*=this._game.getGameResolutionWidth()/(this._canvasWidth||1),o[1]*=this._game.getGameResolutionHeight()/(this._canvasHeight||1),o}bindStandardEvents(e,t,i){this._throwIfDisposed();const o=this._gameCanvas;if(!o)return;const a=n=>{const s=n.pageX-o.offsetLeft,r=n.pageY-o.offsetTop;return 0<=s&&s<(this._canvasWidth||1)&&0<=r&&r<(this._canvasHeight||1)};(function(){isNaN(o.offsetLeft)&&(o.offsetLeft=0,o.offsetTop=0),isNaN(i.body.scrollLeft)&&(i.body.scrollLeft=0,i.body.scrollTop=0),(i.documentElement===void 0||i.documentElement===null)&&(i.documentElement={}),isNaN(i.documentElement.scrollLeft)&&(i.documentElement.scrollLeft=0,i.documentElement.scrollTop=0),isNaN(o.offsetLeft)&&(o.offsetLeft=0,o.offsetTop=0)})();const d=()=>!(i.activeElement===o||i.activeElement===i.body||i.activeElement===null),c=n=>!(n.target===o||n.target===i.body);i.onkeydown=function(n){d()||(m.includes(n.keyCode)&&n.preventDefault(),e.onKeyPressed(n.keyCode,n.location))},i.onkeyup=function(n){d()||(m.includes(n.keyCode)&&n.preventDefault(),e.onKeyReleased(n.keyCode,n.location))};function g(n){switch(n){case 1:return l.InputManager.MOUSE_MIDDLE_BUTTON;case 2:return l.InputManager.MOUSE_RIGHT_BUTTON}return n}o.onmousemove=n=>{const s=this.convertPageToGameCoords(n.pageX,n.pageY);e.onMouseMove(s[0],s[1])},o.onmousedown=n=>{const s=this.convertPageToGameCoords(n.pageX,n.pageY);return e.onMouseMove(s[0],s[1]),e.onMouseButtonPressed(g(n.button)),t.focus!==void 0&&t.focus(),!1},o.onmouseup=function(n){return e.onMouseButtonReleased(g(n.button)),!1},o.onmouseleave=function(n){e.onMouseLeave()},o.onmouseenter=function(n){e.onMouseEnter();const s=[l.InputManager.MOUSE_LEFT_BUTTON,l.InputManager.MOUSE_RIGHT_BUTTON,l.InputManager.MOUSE_MIDDLE_BUTTON,l.InputManager.MOUSE_BACK_BUTTON,l.InputManager.MOUSE_FORWARD_BUTTON];for(let r=0,h=s.length;r<h;++r){const f=s[r],p=(n.buttons&1<<r)!=0,_=e.isMouseButtonPressed(f);p&&!_?e.onMouseButtonPressed(f):!p&&_&&e.onMouseButtonReleased(f)}},t.addEventListener("click",function(n){return t.focus!==void 0&&t.focus(),!1},!1),o.oncontextmenu=function(n){return n.preventDefault(),n.stopPropagation(),!1},o.onwheel=function(n){e.onMouseWheel(-n.deltaY)},t.addEventListener("touchmove",n=>{if(!c(n)&&(n.preventDefault(),n.changedTouches))for(let s=0;s<n.changedTouches.length;++s){const r=n.changedTouches[s],h=this.convertPageToGameCoords(r.pageX,r.pageY);e.onTouchMove(r.identifier,h[0],h[1]),e.isSimulatingMouseWithTouch()&&(a(r)?e.onMouseEnter():e.onMouseLeave())}},{passive:!1}),t.addEventListener("touchstart",n=>{if(!c(n)){if(n.preventDefault(),n.changedTouches)for(let s=0;s<n.changedTouches.length;++s){const r=n.changedTouches[s],h=this.convertPageToGameCoords(r.pageX,r.pageY);e.onTouchStart(n.changedTouches[s].identifier,h[0],h[1])}return!1}},{passive:!1}),t.addEventListener("touchend",function(n){if(!c(n)){if(n.preventDefault(),n.changedTouches)for(let s=0;s<n.changedTouches.length;++s)e.onTouchEnd(n.changedTouches[s].identifier);return!1}},{passive:!1}),t.addEventListener("touchcancel",function(n){if(!c(n)){if(n.preventDefault(),n.changedTouches)for(let s=0;s<n.changedTouches.length;++s)e.onTouchCancel(n.changedTouches[s].identifier);return!1}},{passive:!1})}setWindowTitle(e){typeof document!="undefined"&&(document.title=e)}getWindowTitle(){return typeof document!="undefined"?document.title:""}startGameLoop(e){this._throwIfDisposed();let t=0;const i=o=>{this._nextFrameId=requestAnimationFrame(i);const a=t?o-t:0;t=o,e(a)||cancelAnimationFrame(this._nextFrameId)};requestAnimationFrame(i)}stopGameLoop(){cancelAnimationFrame(this._nextFrameId)}getPIXIRenderer(){return this._pixiRenderer}getThreeRenderer(){return this._threeRenderer}getDomElementContainer(){return this._domElementsContainer}openURL(e){if(typeof window!="undefined"){const t=this.getElectron();t?t.shell.openExternal(e):typeof window.cordova!="undefined"&&typeof window.cordova.InAppBrowser!="undefined"?window.cordova.InAppBrowser.open(e,"_system","location=yes"):window.open(e,"_blank")}}stopGame(){const e=this.getElectronRemote();if(e){const t=e.getCurrentWindow();if(t)try{t.close()}catch(i){u.error("Window closing failed. See error:",i)}}else typeof navigator!="undefined"&&navigator.app&&navigator.app.exitApp&&navigator.app.exitApp()}dispose(e){this._pixiRenderer?.destroy(),this._threeRenderer?.dispose(),this._pixiRenderer=null,this._threeRenderer=null,e&&this._gameCanvas&&this._gameCanvas.parentNode?.removeChild(this._gameCanvas),this._gameCanvas=null,this._domElementsContainer?.parentNode?.removeChild(this._domElementsContainer),this._domElementsContainer=null,this._wasDisposed=!0}getCanvas(){return this._gameCanvas}isWebGLSupported(){return!!this._pixiRenderer&&this._pixiRenderer.type===PIXI.RENDERER_TYPE.WEBGL}getElectron(){return typeof require=="function"?require("electron"):null}getGame(){return this._game}_throwIfDisposed(){if(this._wasDisposed)throw"The RuntimeGameRenderer has been disposed and should not be used anymore."}}l.RuntimeGamePixiRenderer=R,l.RuntimeGameRenderer=R})(gdjs||(gdjs={}));
1
+ var gdjs;(function(l){const d=new l.Logger("PIXI game renderer"),m=[37,38,39,40];class R{constructor(e,t){this._isFullPage=!0;this._isFullscreen=!1;this._pixiRenderer=null;this._threeRenderer=null;this._gameCanvas=null;this._domElementsContainer=null;this._canvasWidth=0;this._canvasHeight=0;this._keepRatio=!0;this._nextFrameId=0;this._wasDisposed=!1;this.getElectronRemote=()=>{if(typeof require=="function"){const e=this._game.getAdditionalOptions(),t=e&&e.electronRemoteRequirePath?e.electronRemoteRequirePath:"@electron/remote";try{return require(t)}catch(i){console.error(`Could not load @electron/remote from "${t}". Error is:`,i)}}return null};this._game=e,this._forceFullscreen=t,this._marginLeft=this._marginTop=this._marginRight=this._marginBottom=0,this._setupOrientation()}createStandardCanvas(e){this._throwIfDisposed();const t=document.createElement("canvas");e.appendChild(t),this.initializeRenderers(t),this.initializeCanvas(t)}initializeRenderers(e){this._throwIfDisposed(),typeof THREE!="undefined"?(this._threeRenderer=new THREE.WebGLRenderer({canvas:e,antialias:this._game.getAntialiasingMode()!=="none"&&(this._game.isAntialisingEnabledOnMobile()||!l.evtTools.common.isMobile()),preserveDrawingBuffer:!0}),this._threeRenderer.shadowMap.enabled=!0,this._threeRenderer.shadowMap.type=THREE.PCFSoftShadowMap,this._threeRenderer.useLegacyLights=!0,this._threeRenderer.autoClear=!1,this._threeRenderer.setSize(this._game.getGameResolutionWidth(),this._game.getGameResolutionHeight()),this._pixiRenderer=new PIXI.Renderer({width:this._game.getGameResolutionWidth(),height:this._game.getGameResolutionHeight(),view:e,context:this._threeRenderer.getContext(),clearBeforeRender:!1,preserveDrawingBuffer:!0,antialias:!1,backgroundAlpha:0})):this._pixiRenderer=PIXI.autoDetectRenderer({width:this._game.getGameResolutionWidth(),height:this._game.getGameResolutionHeight(),view:e,preserveDrawingBuffer:!0,antialias:!1}),this._pixiRenderer.plugins.accessibility.destroy(),delete this._pixiRenderer.plugins.accessibility}initializeCanvas(e){this._gameCanvas=e,e.style.position="absolute",e.tabIndex=1,e.style.userSelect="none",e.style.outline="none";const t=document.createElement("div");t.style.position="absolute",t.style.overflow="hidden",t.style.outline="none",t.style.pointerEvents="none",t.addEventListener("scroll",i=>{t.scrollLeft=0,t.scrollTop=0,i.preventDefault()}),e.addEventListener("pointerdown",()=>{e.focus()}),t.style["-webkit-user-select"]="none",e.parentNode?.appendChild(t),this._domElementsContainer=t,this._resizeCanvas(),this._game.getScaleMode()==="nearest"&&(e.style["image-rendering"]="-moz-crisp-edges",e.style["image-rendering"]="-webkit-optimize-contrast",e.style["image-rendering"]="-webkit-crisp-edges",e.style["image-rendering"]="pixelated"),this._game.getPixelsRounding()&&(PIXI.settings.ROUND_PIXELS=!0),window.addEventListener("resize",()=>{this._game.onWindowInnerSizeChanged(),this._resizeCanvas()}),e.focus()}static getWindowInnerWidth(){return typeof window!="undefined"?window.innerWidth:800}static getWindowInnerHeight(){return typeof window!="undefined"?window.innerHeight:800}updateRendererSize(){this._resizeCanvas()}_setupOrientation(){if(typeof window=="undefined"||!window.screen||!window.screen.orientation)return;const e=this._game.getGameData().properties.orientation;try{if(e==="default"){const t=window.screen.orientation.unlock();t&&t.catch(()=>{})}else window.screen.orientation.lock(e).catch(()=>{})}catch(t){d.error("Unexpected error while setting up orientation: ",t)}}_resizeCanvas(){if(!this._pixiRenderer||!this._domElementsContainer)return;(this._pixiRenderer.width!==this._game.getGameResolutionWidth()||this._pixiRenderer.height!==this._game.getGameResolutionHeight())&&(this._pixiRenderer.resize(this._game.getGameResolutionWidth(),this._game.getGameResolutionHeight()),this._threeRenderer&&this._threeRenderer.setSize(this._game.getGameResolutionWidth(),this._game.getGameResolutionHeight()));const e=this._forceFullscreen||this._isFullPage||this._isFullscreen;let t=this._game.getGameResolutionWidth(),i=this._game.getGameResolutionHeight(),o=window.innerWidth-this._marginLeft-this._marginRight,a=window.innerHeight-this._marginTop-this._marginBottom;if(o<0&&(o=0),a<0&&(a=0),e&&!this._keepRatio)t=o,i=a;else if(e&&this._keepRatio||t>o||i>a){let u=o/t;i*u>a&&(u=a/i),t*=u,i*=u}this._gameCanvas&&(this._gameCanvas.style.top=this._marginTop+(a-i)/2+"px",this._gameCanvas.style.left=this._marginLeft+(o-t)/2+"px",this._gameCanvas.style.width=t+"px",this._gameCanvas.style.height=i+"px"),this._domElementsContainer.style.top=this._marginTop+(a-i)/2+"px",this._domElementsContainer.style.left=this._marginLeft+(o-t)/2+"px",this._domElementsContainer.style.width=t+"px",this._domElementsContainer.style.height=i+"px",this._canvasWidth=t,this._canvasHeight=i}keepAspectRatio(e){this._keepRatio!==e&&(this._keepRatio=e,this._resizeCanvas())}setMargins(e,t,i,o){this._throwIfDisposed(),!(this._marginTop===e&&this._marginRight===t&&this._marginBottom===i&&this._marginLeft===o)&&(this._marginTop=e,this._marginRight=t,this._marginBottom=i,this._marginLeft=o,this._resizeCanvas())}setWindowSize(e,t){this._throwIfDisposed();const i=this.getElectronRemote();if(i){const o=i.getCurrentWindow();try{o&&o.setContentSize(e,t)}catch(a){d.error(`Window size setting to width ${e} and height ${t} failed. See error:`,a)}}else d.warn("Window size can't be changed on this platform.")}centerWindow(){this._throwIfDisposed();const e=this.getElectronRemote();if(e){const t=e.getCurrentWindow();try{t&&t.center()}catch(i){d.error("Window centering failed. See error:",i)}}else d.warn("Window can't be centered on this platform.")}setFullScreen(e){if(this._throwIfDisposed(),!this._forceFullscreen&&this._isFullscreen!==e){this._isFullscreen=!!e;const t=this.getElectronRemote();if(t){const i=t.getCurrentWindow();try{i&&i.setFullScreen(this._isFullscreen)}catch(o){d.error(`Full screen setting to ${this._isFullscreen} failed. See error:`,o)}}else this._isFullscreen?document.documentElement.requestFullscreen?document.documentElement.requestFullscreen():document.documentElement.mozRequestFullScreen?document.documentElement.mozRequestFullScreen():document.documentElement.webkitRequestFullScreen&&document.documentElement.webkitRequestFullScreen():document.exitFullscreen?document.exitFullscreen():document.mozCancelFullScreen?document.mozCancelFullScreen():document.webkitCancelFullScreen&&document.webkitCancelFullScreen();this._resizeCanvas()}}isFullScreen(){const e=this.getElectronRemote();if(e)try{return e.getCurrentWindow().isFullScreen()}catch(t){return d.error("Full screen detection failed. See error:",t),!1}return this._isFullscreen||window.screen.height===window.innerHeight}convertCanvasToDomElementContainerCoords(e,t){const i=t||[0,0];return i[0]=e[0]*this._canvasWidth/this._game.getGameResolutionWidth(),i[1]=e[1]*this._canvasHeight/this._game.getGameResolutionHeight(),i}getCanvasToDomElementContainerHeightScale(){return(this._canvasHeight||1)/this._game.getGameResolutionHeight()}convertPageToGameCoords(e,t){const i=this._gameCanvas;if(!i)return[0,0];const o=[e-i.offsetLeft,t-i.offsetTop];return o[0]*=this._game.getGameResolutionWidth()/(this._canvasWidth||1),o[1]*=this._game.getGameResolutionHeight()/(this._canvasHeight||1),o}bindStandardEvents(e,t,i){this._throwIfDisposed();const o=this._gameCanvas;if(!o)return;const a=n=>{const s=n.pageX-o.offsetLeft,r=n.pageY-o.offsetTop;return 0<=s&&s<(this._canvasWidth||1)&&0<=r&&r<(this._canvasHeight||1)};(function(){isNaN(o.offsetLeft)&&(o.offsetLeft=0,o.offsetTop=0),isNaN(i.body.scrollLeft)&&(i.body.scrollLeft=0,i.body.scrollTop=0),(i.documentElement===void 0||i.documentElement===null)&&(i.documentElement={}),isNaN(i.documentElement.scrollLeft)&&(i.documentElement.scrollLeft=0,i.documentElement.scrollTop=0),isNaN(o.offsetLeft)&&(o.offsetLeft=0,o.offsetTop=0)})();const u=()=>!(i.activeElement===o||i.activeElement===i.body||i.activeElement===null),c=n=>!(n.target===o||n.target===i.body);i.onkeydown=function(n){u()||(m.includes(n.keyCode)&&n.preventDefault(),e.onKeyPressed(n.keyCode,n.location))},i.onkeyup=function(n){u()||(m.includes(n.keyCode)&&n.preventDefault(),e.onKeyReleased(n.keyCode,n.location))};function g(n){switch(n){case 1:return l.InputManager.MOUSE_MIDDLE_BUTTON;case 2:return l.InputManager.MOUSE_RIGHT_BUTTON}return n}o.onmousemove=n=>{const s=this.convertPageToGameCoords(n.pageX,n.pageY);e.onMouseMove(s[0],s[1])},o.onmousedown=n=>{const s=this.convertPageToGameCoords(n.pageX,n.pageY);return e.onMouseMove(s[0],s[1]),e.onMouseButtonPressed(g(n.button)),t.focus!==void 0&&t.focus(),!1},o.onmouseup=function(n){return e.onMouseButtonReleased(g(n.button)),!1},o.onmouseleave=function(n){e.onMouseLeave()},o.onmouseenter=function(n){e.onMouseEnter();const s=[l.InputManager.MOUSE_LEFT_BUTTON,l.InputManager.MOUSE_RIGHT_BUTTON,l.InputManager.MOUSE_MIDDLE_BUTTON,l.InputManager.MOUSE_BACK_BUTTON,l.InputManager.MOUSE_FORWARD_BUTTON];for(let r=0,h=s.length;r<h;++r){const f=s[r],p=(n.buttons&1<<r)!=0,_=e.isMouseButtonPressed(f);p&&!_?e.onMouseButtonPressed(f):!p&&_&&e.onMouseButtonReleased(f)}},t.addEventListener("click",function(n){return t.focus!==void 0&&t.focus(),!1},!1),o.oncontextmenu=function(n){return n.preventDefault(),n.stopPropagation(),!1},o.onwheel=function(n){e.onMouseWheel(-n.deltaY)},t.addEventListener("touchmove",n=>{if(!c(n)&&(n.preventDefault(),n.changedTouches))for(let s=0;s<n.changedTouches.length;++s){const r=n.changedTouches[s],h=this.convertPageToGameCoords(r.pageX,r.pageY);e.onTouchMove(r.identifier,h[0],h[1]),e.isSimulatingMouseWithTouch()&&(a(r)?e.onMouseEnter():e.onMouseLeave())}},{passive:!1}),t.addEventListener("touchstart",n=>{if(!c(n)){if(n.preventDefault(),n.changedTouches)for(let s=0;s<n.changedTouches.length;++s){const r=n.changedTouches[s],h=this.convertPageToGameCoords(r.pageX,r.pageY);e.onTouchStart(n.changedTouches[s].identifier,h[0],h[1])}return!1}},{passive:!1}),t.addEventListener("touchend",function(n){if(!c(n)){if(n.preventDefault(),n.changedTouches)for(let s=0;s<n.changedTouches.length;++s)e.onTouchEnd(n.changedTouches[s].identifier);return!1}},{passive:!1}),t.addEventListener("touchcancel",function(n){if(!c(n)){if(n.preventDefault(),n.changedTouches)for(let s=0;s<n.changedTouches.length;++s)e.onTouchCancel(n.changedTouches[s].identifier);return!1}},{passive:!1})}setWindowTitle(e){typeof document!="undefined"&&(document.title=e)}getWindowTitle(){return typeof document!="undefined"?document.title:""}startGameLoop(e){this._throwIfDisposed();let t=0;const i=o=>{this._nextFrameId=requestAnimationFrame(i);const a=t?o-t:0;t=o,e(a)||cancelAnimationFrame(this._nextFrameId)};requestAnimationFrame(i)}stopGameLoop(){cancelAnimationFrame(this._nextFrameId)}getPIXIRenderer(){return this._pixiRenderer}getThreeRenderer(){return this._threeRenderer}getDomElementContainer(){return this._domElementsContainer}openURL(e){if(typeof window!="undefined"){const t=this.getElectron();t?t.shell.openExternal(e):typeof window.cordova!="undefined"&&typeof window.cordova.InAppBrowser!="undefined"?window.cordova.InAppBrowser.open(e,"_system","location=yes"):window.open(e,"_blank")}}stopGame(){const e=this.getElectronRemote();if(e){const t=e.getCurrentWindow();if(t)try{t.close()}catch(i){d.error("Window closing failed. See error:",i)}}else typeof navigator!="undefined"&&navigator.app&&navigator.app.exitApp&&navigator.app.exitApp()}dispose(e){this._pixiRenderer?.destroy(),this._threeRenderer?.dispose(),this._pixiRenderer=null,this._threeRenderer=null,e&&this._gameCanvas&&this._gameCanvas.parentNode?.removeChild(this._gameCanvas),this._gameCanvas=null,this._domElementsContainer?.parentNode?.removeChild(this._domElementsContainer),this._domElementsContainer=null,this._wasDisposed=!0}getCanvas(){return this._gameCanvas}isWebGLSupported(){return!!this._pixiRenderer&&this._pixiRenderer.type===PIXI.RENDERER_TYPE.WEBGL}getElectron(){return typeof require=="function"?require("electron"):null}getGame(){return this._game}_throwIfDisposed(){if(this._wasDisposed)throw"The RuntimeGameRenderer has been disposed and should not be used anymore."}}l.RuntimeGamePixiRenderer=R,l.RuntimeGameRenderer=R})(gdjs||(gdjs={}));
2
2
  //# sourceMappingURL=runtimegame-pixi-renderer.js.map