gdcore-tools 2.0.0-gd-v5.5.224-autobuild → 2.0.0-gd-v5.5.225-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 (200) hide show
  1. package/dist/Runtime/CustomRuntimeObject.js +1 -1
  2. package/dist/Runtime/CustomRuntimeObject.js.map +2 -2
  3. package/dist/Runtime/CustomRuntimeObject2D.js.map +2 -2
  4. package/dist/Runtime/Extensions/3D/A_RuntimeObject3D.js.map +2 -2
  5. package/dist/Runtime/Extensions/3D/Base3DBehavior.js.map +2 -2
  6. package/dist/Runtime/Extensions/3D/Cube3DRuntimeObject.js +1 -1
  7. package/dist/Runtime/Extensions/3D/Cube3DRuntimeObject.js.map +2 -2
  8. package/dist/Runtime/Extensions/3D/Cube3DRuntimeObjectPixiRenderer.js +1 -1
  9. package/dist/Runtime/Extensions/3D/Cube3DRuntimeObjectPixiRenderer.js.map +2 -2
  10. package/dist/Runtime/Extensions/3D/CustomRuntimeObject3D.js.map +2 -2
  11. package/dist/Runtime/Extensions/3D/CustomRuntimeObject3DRenderer.js.map +2 -2
  12. package/dist/Runtime/Extensions/3D/JsExtension.js +219 -108
  13. package/dist/Runtime/Extensions/3D/Model3DRuntimeObject.js +1 -1
  14. package/dist/Runtime/Extensions/3D/Model3DRuntimeObject.js.map +2 -2
  15. package/dist/Runtime/Extensions/3D/Model3DRuntimeObject3DRenderer.js +1 -1
  16. package/dist/Runtime/Extensions/3D/Model3DRuntimeObject3DRenderer.js.map +2 -2
  17. package/dist/Runtime/Extensions/AdMob/JsExtension.js +63 -1
  18. package/dist/Runtime/Extensions/AdMob/admobtools.js +1 -1
  19. package/dist/Runtime/Extensions/AdMob/admobtools.js.map +2 -2
  20. package/dist/Runtime/Extensions/AdvancedWindow/electron-advancedwindowtools.js.map +2 -2
  21. package/dist/Runtime/Extensions/AnchorBehavior/anchorruntimebehavior.js +1 -1
  22. package/dist/Runtime/Extensions/AnchorBehavior/anchorruntimebehavior.js.map +2 -2
  23. package/dist/Runtime/Extensions/BBText/JsExtension.js +10 -9
  24. package/dist/Runtime/Extensions/BBText/bbtextruntimeobject.js.map +2 -2
  25. package/dist/Runtime/Extensions/BitmapText/JsExtension.js +4 -6
  26. package/dist/Runtime/Extensions/BitmapText/bitmaptextruntimeobject-pixi-renderer.js.map +2 -2
  27. package/dist/Runtime/Extensions/BitmapText/bitmaptextruntimeobject.js.map +2 -2
  28. package/dist/Runtime/Extensions/DialogueTree/dialoguetools.js.map +2 -2
  29. package/dist/Runtime/Extensions/DraggableBehavior/draggableruntimebehavior.js.map +2 -2
  30. package/dist/Runtime/Extensions/Effects/adjustment-pixi-filter.js.map +2 -2
  31. package/dist/Runtime/Extensions/Effects/advanced-bloom-pixi-filter.js.map +2 -2
  32. package/dist/Runtime/Extensions/Effects/ascii-pixi-filter.js.map +2 -2
  33. package/dist/Runtime/Extensions/Effects/bevel-pixi-filter.js.map +2 -2
  34. package/dist/Runtime/Extensions/Effects/black-and-white-pixi-filter.js.map +2 -2
  35. package/dist/Runtime/Extensions/Effects/blending-mode-pixi-filter.js.map +2 -2
  36. package/dist/Runtime/Extensions/Effects/brightness-pixi-filter.js.map +2 -2
  37. package/dist/Runtime/Extensions/Effects/bulge-pinch-pixi-filter.js.map +2 -2
  38. package/dist/Runtime/Extensions/Effects/color-map-pixi-filter.js.map +2 -2
  39. package/dist/Runtime/Extensions/Effects/color-replace-pixi-filter.js.map +2 -2
  40. package/dist/Runtime/Extensions/Effects/crt-pixi-filter.js.map +2 -2
  41. package/dist/Runtime/Extensions/Effects/displacement-pixi-filter.js.map +2 -2
  42. package/dist/Runtime/Extensions/Effects/dot-pixi-filter.js.map +2 -2
  43. package/dist/Runtime/Extensions/Effects/drop-shadow-pixi-filter.js.map +2 -2
  44. package/dist/Runtime/Extensions/Effects/glitch-pixi-filter.js.map +2 -2
  45. package/dist/Runtime/Extensions/Effects/glow-pixi-filter.js.map +2 -2
  46. package/dist/Runtime/Extensions/Effects/godray-pixi-filter.js.map +2 -2
  47. package/dist/Runtime/Extensions/Effects/kawase-blur-pixi-filter.js.map +2 -2
  48. package/dist/Runtime/Extensions/Effects/noise-pixi-filter.js.map +2 -2
  49. package/dist/Runtime/Extensions/Effects/old-film-pixi-filter.js.map +2 -2
  50. package/dist/Runtime/Extensions/Effects/outline-pixi-filter.js.map +2 -2
  51. package/dist/Runtime/Extensions/Effects/pixelate-pixi-filter.js.map +2 -2
  52. package/dist/Runtime/Extensions/Effects/pixi-filters/types/drop-shadow/types.d.ts +10 -4
  53. package/dist/Runtime/Extensions/Effects/radial-blur-pixi-filter.js.map +2 -2
  54. package/dist/Runtime/Extensions/Effects/reflection-pixi-filter.js.map +2 -2
  55. package/dist/Runtime/Extensions/Effects/rgb-split-pixi-filter.js.map +2 -2
  56. package/dist/Runtime/Extensions/Effects/sepia-pixi-filter.js.map +2 -2
  57. package/dist/Runtime/Extensions/Effects/shockwave-pixi-filter.js.map +2 -2
  58. package/dist/Runtime/Extensions/Effects/tilt-shift-pixi-filter.js.map +2 -2
  59. package/dist/Runtime/Extensions/Effects/twist-pixi-filter.js.map +2 -2
  60. package/dist/Runtime/Extensions/Effects/zoom-blur-pixi-filter.js.map +2 -2
  61. package/dist/Runtime/Extensions/ExampleJsExtension/dummyeffect.js.map +2 -2
  62. package/dist/Runtime/Extensions/FacebookInstantGames/facebookinstantgamestools.js.map +2 -2
  63. package/dist/Runtime/Extensions/Firebase/A_firebasejs/firebase.d.ts +5 -4
  64. package/dist/Runtime/Extensions/Firebase/B_firebasetools/D_cloudfirestoretools.js.map +2 -2
  65. package/dist/Runtime/Extensions/Firebase/B_firebasetools/D_remoteconfigtools.js.map +2 -2
  66. package/dist/Runtime/Extensions/Firebase/JsExtension.js +21 -21
  67. package/dist/Runtime/Extensions/JsExtensionTypes.d.ts +1 -0
  68. package/dist/Runtime/Extensions/Leaderboards/leaderboardstools.js.map +2 -2
  69. package/dist/Runtime/Extensions/Lighting/JsExtension.js +2 -2
  70. package/dist/Runtime/Extensions/Lighting/lightobstacleruntimebehavior.js.map +2 -2
  71. package/dist/Runtime/Extensions/Lighting/lightruntimeobject-pixi-renderer.js.map +2 -2
  72. package/dist/Runtime/Extensions/Lighting/lightruntimeobject.js.map +2 -2
  73. package/dist/Runtime/Extensions/LinkedObjects/linkedobjects.js.map +2 -2
  74. package/dist/Runtime/Extensions/Multiplayer/JsExtension.js +122 -0
  75. package/dist/Runtime/Extensions/Multiplayer/messageManager.js.map +2 -2
  76. package/dist/Runtime/Extensions/Multiplayer/multiplayerVariablesManager.js.map +2 -2
  77. package/dist/Runtime/Extensions/Multiplayer/multiplayercomponents.js +1 -1
  78. package/dist/Runtime/Extensions/Multiplayer/multiplayercomponents.js.map +2 -2
  79. package/dist/Runtime/Extensions/Multiplayer/multiplayerobjectruntimebehavior.js.map +2 -2
  80. package/dist/Runtime/Extensions/Multiplayer/multiplayertools.js +1 -1
  81. package/dist/Runtime/Extensions/Multiplayer/multiplayertools.js.map +2 -2
  82. package/dist/Runtime/Extensions/Multiplayer/peerJsHelper.js +1 -1
  83. package/dist/Runtime/Extensions/Multiplayer/peerJsHelper.js.map +2 -2
  84. package/dist/Runtime/Extensions/Multiplayer/peerjs.d.ts +8 -10
  85. package/dist/Runtime/Extensions/P2P/peerjs.d.ts +8 -10
  86. package/dist/Runtime/Extensions/PanelSpriteObject/panelspriteruntimeobject-pixi-renderer.js.map +2 -2
  87. package/dist/Runtime/Extensions/PanelSpriteObject/panelspriteruntimeobject.js.map +2 -2
  88. package/dist/Runtime/Extensions/ParticleSystem/particleemitterobject-pixi-renderer.js.map +2 -2
  89. package/dist/Runtime/Extensions/ParticleSystem/particleemitterobject.js.map +2 -2
  90. package/dist/Runtime/Extensions/ParticleSystem/pixi-particles-pixi-renderer.d.ts +2 -1
  91. package/dist/Runtime/Extensions/PathfindingBehavior/pathfindingobstacleruntimebehavior.js.map +2 -2
  92. package/dist/Runtime/Extensions/PathfindingBehavior/pathfindingruntimebehavior.js.map +2 -2
  93. package/dist/Runtime/Extensions/Physics2Behavior/JsExtension.js +106 -106
  94. package/dist/Runtime/Extensions/Physics2Behavior/box2d.d.ts +13 -7
  95. package/dist/Runtime/Extensions/Physics2Behavior/physics2runtimebehavior.js.map +2 -2
  96. package/dist/Runtime/Extensions/Physics3DBehavior/Physics3DRuntimeBehavior.js.map +2 -2
  97. package/dist/Runtime/Extensions/Physics3DBehavior/PhysicsCharacter3DRuntimeBehavior.js +1 -1
  98. package/dist/Runtime/Extensions/Physics3DBehavior/PhysicsCharacter3DRuntimeBehavior.js.map +2 -2
  99. package/dist/Runtime/Extensions/PhysicsBehavior/physicsruntimebehavior.js.map +2 -2
  100. package/dist/Runtime/Extensions/PlatformBehavior/platformerobjectruntimebehavior.js.map +2 -2
  101. package/dist/Runtime/Extensions/PlatformBehavior/platformruntimebehavior.js.map +2 -2
  102. package/dist/Runtime/Extensions/PlayerAuthentication/playerauthenticationcomponents.js.map +1 -1
  103. package/dist/Runtime/Extensions/PlayerAuthentication/playerauthenticationtools.js +1 -1
  104. package/dist/Runtime/Extensions/PlayerAuthentication/playerauthenticationtools.js.map +2 -2
  105. package/dist/Runtime/Extensions/PrimitiveDrawing/shapepainterruntimeobject-pixi-renderer.js.map +2 -2
  106. package/dist/Runtime/Extensions/PrimitiveDrawing/shapepainterruntimeobject.js.map +2 -2
  107. package/dist/Runtime/Extensions/SpatialSound/spatialsoundtools.js +1 -1
  108. package/dist/Runtime/Extensions/SpatialSound/spatialsoundtools.js.map +2 -2
  109. package/dist/Runtime/Extensions/Spine/JsExtension.js +5 -4
  110. package/dist/Runtime/Extensions/Spine/managers/pixi-spine-atlas-manager.js +1 -1
  111. package/dist/Runtime/Extensions/Spine/managers/pixi-spine-atlas-manager.js.map +2 -2
  112. package/dist/Runtime/Extensions/Spine/managers/pixi-spine-manager.js +1 -1
  113. package/dist/Runtime/Extensions/Spine/managers/pixi-spine-manager.js.map +2 -2
  114. package/dist/Runtime/Extensions/Spine/spineruntimeobject-pixi-renderer.js.map +2 -2
  115. package/dist/Runtime/Extensions/Spine/spineruntimeobject.js.map +2 -2
  116. package/dist/Runtime/Extensions/Steamworks/JsExtension.js +12 -12
  117. package/dist/Runtime/Extensions/Steamworks/Z_steamworksinputtools.js.map +2 -2
  118. package/dist/Runtime/Extensions/Steamworks/steamworkstools.js.map +2 -2
  119. package/dist/Runtime/Extensions/TextEntryObject/textentryruntimeobject-pixi-renderer.js.map +2 -2
  120. package/dist/Runtime/Extensions/TextInput/textinputruntimeobject-pixi-renderer.js +1 -1
  121. package/dist/Runtime/Extensions/TextInput/textinputruntimeobject-pixi-renderer.js.map +2 -2
  122. package/dist/Runtime/Extensions/TextInput/textinputruntimeobject.js.map +2 -2
  123. package/dist/Runtime/Extensions/TextObject/textruntimeobject-pixi-renderer.js.map +2 -2
  124. package/dist/Runtime/Extensions/TextObject/textruntimeobject.js.map +2 -2
  125. package/dist/Runtime/Extensions/TileMap/JsExtension.js +20 -18
  126. package/dist/Runtime/Extensions/TileMap/TileMapRuntimeManager.js.map +2 -2
  127. package/dist/Runtime/Extensions/TileMap/collision/TransformedTileMap.js.map +2 -2
  128. package/dist/Runtime/Extensions/TileMap/helper/dts/model/TileMapModel.d.ts +1 -3
  129. package/dist/Runtime/Extensions/TileMap/simpletilemapruntimeobject.js.map +2 -2
  130. package/dist/Runtime/Extensions/TileMap/tilemapcollisionmaskruntimeobject.js.map +2 -2
  131. package/dist/Runtime/Extensions/TileMap/tilemapruntimeobject-pixi-renderer.js.map +1 -1
  132. package/dist/Runtime/Extensions/TileMap/tilemapruntimeobject.js.map +2 -2
  133. package/dist/Runtime/Extensions/TiledSpriteObject/tiledspriteruntimeobject-pixi-renderer.js.map +2 -2
  134. package/dist/Runtime/Extensions/TiledSpriteObject/tiledspriteruntimeobject.js.map +2 -2
  135. package/dist/Runtime/Extensions/TopDownMovementBehavior/topdownmovementruntimebehavior.js.map +2 -2
  136. package/dist/Runtime/Extensions/TweenBehavior/tweenruntimebehavior.js.map +1 -1
  137. package/dist/Runtime/Extensions/Video/JsExtension.js +2 -1
  138. package/dist/Runtime/Extensions/Video/videoruntimeobject-pixi-renderer.js.map +2 -2
  139. package/dist/Runtime/Extensions/Video/videoruntimeobject.js.map +2 -2
  140. package/dist/Runtime/InAppTutorialMessage.js +6 -0
  141. package/dist/Runtime/InAppTutorialMessage.js.map +7 -0
  142. package/dist/Runtime/Model3DManager.js.map +2 -2
  143. package/dist/Runtime/ResourceLoader.js.map +2 -2
  144. package/dist/Runtime/RuntimeCustomObjectLayer.js +1 -1
  145. package/dist/Runtime/RuntimeCustomObjectLayer.js.map +2 -2
  146. package/dist/Runtime/RuntimeInstanceContainer.js.map +1 -1
  147. package/dist/Runtime/RuntimeLayer.js.map +2 -2
  148. package/dist/Runtime/SpriteAnimator.js.map +2 -2
  149. package/dist/Runtime/affinetransformation.js.map +1 -1
  150. package/dist/Runtime/debugger-client/abstract-debugger-client.js.map +2 -2
  151. package/dist/Runtime/debugger-client/hot-reloader.js +2 -2
  152. package/dist/Runtime/debugger-client/hot-reloader.js.map +2 -2
  153. package/dist/Runtime/debugger-client/websocket-debugger-client.js +1 -1
  154. package/dist/Runtime/debugger-client/websocket-debugger-client.js.map +2 -2
  155. package/dist/Runtime/events-tools/networktools.js +1 -1
  156. package/dist/Runtime/events-tools/networktools.js.map +2 -2
  157. package/dist/Runtime/fontfaceobserver-font-manager/fontfaceobserver-font-manager.js.map +2 -2
  158. package/dist/Runtime/gd.js.map +2 -2
  159. package/dist/Runtime/howler-sound-manager/howler-sound-manager.js +1 -1
  160. package/dist/Runtime/howler-sound-manager/howler-sound-manager.js.map +2 -2
  161. package/dist/Runtime/inputmanager.js.map +2 -2
  162. package/dist/Runtime/jsonmanager.js.map +2 -2
  163. package/dist/Runtime/layer.js.map +2 -2
  164. package/dist/Runtime/libs/nanomarkdown.js +5 -0
  165. package/dist/Runtime/libs/nanomarkdown.js.map +7 -0
  166. package/dist/Runtime/object-capabilities/AnimatableBehavior.js.map +2 -2
  167. package/dist/Runtime/object-capabilities/EffectBehavior.js.map +2 -2
  168. package/dist/Runtime/object-capabilities/FlippableBehavior.js.map +2 -2
  169. package/dist/Runtime/object-capabilities/OpacityBehavior.js.map +2 -2
  170. package/dist/Runtime/object-capabilities/ResizableBehavior.js.map +2 -2
  171. package/dist/Runtime/object-capabilities/ScalableBehavior.js.map +2 -2
  172. package/dist/Runtime/object-capabilities/TextContainerBehavior.js.map +2 -2
  173. package/dist/Runtime/pixi-renderers/CustomRuntimeObject2DPixiRenderer.js.map +2 -2
  174. package/dist/Runtime/pixi-renderers/DebuggerPixiRenderer.js.map +2 -2
  175. package/dist/Runtime/pixi-renderers/layer-pixi-renderer.js.map +2 -2
  176. package/dist/Runtime/pixi-renderers/loadingscreen-pixi-renderer.js.map +2 -2
  177. package/dist/Runtime/pixi-renderers/pixi-bitmapfont-manager.js.map +2 -2
  178. package/dist/Runtime/pixi-renderers/pixi-filters-tools.js.map +2 -2
  179. package/dist/Runtime/pixi-renderers/pixi-image-manager.js +1 -1
  180. package/dist/Runtime/pixi-renderers/pixi-image-manager.js.map +2 -2
  181. package/dist/Runtime/pixi-renderers/pixi.js +123 -177
  182. package/dist/Runtime/pixi-renderers/runtimegame-pixi-renderer.js +1 -1
  183. package/dist/Runtime/pixi-renderers/runtimegame-pixi-renderer.js.map +2 -2
  184. package/dist/Runtime/pixi-renderers/runtimescene-pixi-renderer.js.map +2 -2
  185. package/dist/Runtime/pixi-renderers/spriteruntimeobject-pixi-renderer.js.map +2 -2
  186. package/dist/Runtime/profiler.js.map +2 -2
  187. package/dist/Runtime/runtimegame.js +1 -1
  188. package/dist/Runtime/runtimegame.js.map +2 -2
  189. package/dist/Runtime/runtimeobject.js +1 -1
  190. package/dist/Runtime/runtimeobject.js.map +2 -2
  191. package/dist/Runtime/runtimescene.js.map +2 -2
  192. package/dist/Runtime/runtimewatermark.js.map +2 -2
  193. package/dist/Runtime/scenestack.js.map +2 -2
  194. package/dist/Runtime/spriteruntimeobject.js.map +2 -2
  195. package/dist/Runtime/variable.js.map +2 -2
  196. package/dist/Runtime/variablescontainer.js.map +2 -2
  197. package/dist/lib/libGD.cjs +1 -1
  198. package/dist/lib/libGD.wasm +0 -0
  199. package/gd.d.ts +2 -0
  200. package/package.json +1 -1
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../GDevelop/GDJS/Runtime/Model3DManager.ts"],
4
- "sourcesContent": ["/*\n * GDevelop JS Platform\n * Copyright 2013-present Florian Rival (Florian.Rival@gmail.com). All rights reserved.\n * This project is released under the MIT License.\n */\nnamespace gdjs {\n const logger = new gdjs.Logger('Model3DManager');\n\n const resourceKinds: Array<ResourceKind> = ['model3D'];\n\n /**\n * Load GLB files (using `Three.js`), using the \"model3D\" resources\n * registered in the game resources.\n */\n export class Model3DManager implements gdjs.ResourceManager {\n /**\n * Map associating a resource name to the loaded Three.js model.\n */\n private _loadedThreeModels = new gdjs.ResourceCache<THREE_ADDONS.GLTF>();\n private _downloadedArrayBuffers = new gdjs.ResourceCache<ArrayBuffer>();\n\n _resourceLoader: gdjs.ResourceLoader;\n\n _loader: THREE_ADDONS.GLTFLoader | null = null;\n _dracoLoader: THREE_ADDONS.DRACOLoader | null = null;\n\n //@ts-ignore Can only be null if THREE is not loaded.\n _invalidModel: THREE_ADDONS.GLTF;\n\n /**\n * @param resourceDataArray The resources data of the game.\n * @param resourceLoader The resources loader of the game.\n */\n constructor(resourceLoader: gdjs.ResourceLoader) {\n this._resourceLoader = resourceLoader;\n\n if (typeof THREE !== 'undefined') {\n this._loader = new THREE_ADDONS.GLTFLoader();\n\n this._dracoLoader = new THREE_ADDONS.DRACOLoader();\n this._dracoLoader.setDecoderPath('./pixi-renderers/draco/gltf/');\n this._loader.setDRACOLoader(this._dracoLoader);\n\n /**\n * The invalid model is a box with magenta (#ff00ff) faces, to be\n * easily spotted if rendered on screen.\n */\n const group = new THREE.Group();\n group.add(\n new THREE.Mesh(\n new THREE.BoxGeometry(1, 1, 1),\n new THREE.MeshBasicMaterial({ color: '#ff00ff' })\n )\n );\n this._invalidModel = {\n scene: group,\n animations: [],\n cameras: [],\n scenes: [],\n asset: {},\n userData: {},\n //@ts-ignore\n parser: null,\n };\n }\n }\n\n getResourceKinds(): ResourceKind[] {\n return resourceKinds;\n }\n\n async processResource(resourceName: string): Promise<void> {\n const resource = this._resourceLoader.getResource(resourceName);\n if (!resource) {\n logger.warn(\n 'Unable to find texture for resource \"' + resourceName + '\".'\n );\n return;\n }\n const loader = this._loader;\n if (!loader) {\n return;\n }\n const data = this._downloadedArrayBuffers.get(resource);\n if (!data) {\n return;\n }\n this._downloadedArrayBuffers.delete(resource);\n try {\n const gltf: THREE_ADDONS.GLTF = await loader.parseAsync(data, '');\n this._loadedThreeModels.set(resource, gltf);\n } catch (error) {\n logger.error(\n \"Can't fetch the 3D model file \" + resource.file + ', error: ' + error\n );\n }\n }\n\n async loadResource(resourceName: string): Promise<void> {\n const resource = this._resourceLoader.getResource(resourceName);\n if (!resource) {\n logger.warn(\n 'Unable to find texture for resource \"' + resourceName + '\".'\n );\n return;\n }\n const loader = this._loader;\n if (!loader) {\n return;\n }\n if (this._loadedThreeModels.get(resource)) {\n return;\n }\n const url = this._resourceLoader.getFullUrl(resource.file);\n try {\n const response = await fetch(url, {\n credentials: this._resourceLoader.checkIfCredentialsRequired(url)\n ? 'include'\n : 'omit',\n });\n if (!response.ok) {\n throw new Error('Network response was not ok');\n }\n const data = await response.arrayBuffer();\n this._downloadedArrayBuffers.set(resource, data);\n } catch (error) {\n logger.error(\n \"Can't fetch the 3D model file \" + resource.file + ', error: ' + error\n );\n }\n }\n\n /**\n * Return a 3D model.\n *\n * Caller should not modify the object but clone it.\n *\n * @param resourceName The name of the json resource.\n * @returns a 3D model if it exists.\n */\n getModel(resourceName: string): THREE_ADDONS.GLTF {\n return (\n this._loadedThreeModels.getFromName(resourceName) || this._invalidModel\n );\n }\n\n /**\n * To be called when the game is disposed.\n * Clear the models, resources loaded and destroy 3D models loaders in this manager.\n */\n dispose(): void {\n this._loadedThreeModels.clear();\n this._downloadedArrayBuffers.clear();\n this._loader = null;\n this._dracoLoader = null;\n\n if (this._invalidModel) {\n this._invalidModel.cameras = [];\n this._invalidModel.animations = [];\n this._invalidModel.scenes = [];\n this._invalidModel.userData = {};\n this._invalidModel.asset = {};\n this._invalidModel.scene.clear();\n }\n }\n }\n}\n"],
5
- "mappings": "AAKA,GAAU,MAAV,UAAU,EAAV,CACE,KAAM,GAAS,GAAI,GAAK,OAAO,kBAEzB,EAAqC,CAAC,WAMrC,OAAqD,CAmB1D,YAAY,EAAqC,CAfzC,wBAAqB,GAAI,GAAK,cAC9B,6BAA0B,GAAI,GAAK,cAI3C,aAA0C,KAC1C,kBAAgD,KAY9C,GAFA,KAAK,gBAAkB,EAEnB,MAAO,QAAU,YAAa,CAChC,KAAK,QAAU,GAAI,cAAa,WAEhC,KAAK,aAAe,GAAI,cAAa,YACrC,KAAK,aAAa,eAAe,gCACjC,KAAK,QAAQ,eAAe,KAAK,cAMjC,KAAM,GAAQ,GAAI,OAAM,MACxB,EAAM,IACJ,GAAI,OAAM,KACR,GAAI,OAAM,YAAY,EAAG,EAAG,GAC5B,GAAI,OAAM,kBAAkB,CAAE,MAAO,cAGzC,KAAK,cAAgB,CACnB,MAAO,EACP,WAAY,GACZ,QAAS,GACT,OAAQ,GACR,MAAO,GACP,SAAU,GAEV,OAAQ,OAKd,kBAAmC,CACjC,MAAO,QAGH,iBAAgB,EAAqC,CACzD,KAAM,GAAW,KAAK,gBAAgB,YAAY,GAClD,GAAI,CAAC,EAAU,CACb,EAAO,KACL,wCAA0C,EAAe,MAE3D,OAEF,KAAM,GAAS,KAAK,QACpB,GAAI,CAAC,EACH,OAEF,KAAM,GAAO,KAAK,wBAAwB,IAAI,GAC9C,GAAI,EAAC,EAGL,MAAK,wBAAwB,OAAO,GACpC,GAAI,CACF,KAAM,GAA0B,KAAM,GAAO,WAAW,EAAM,IAC9D,KAAK,mBAAmB,IAAI,EAAU,SAC/B,EAAP,CACA,EAAO,MACL,iCAAmC,EAAS,KAAO,YAAc,UAKjE,cAAa,EAAqC,CACtD,KAAM,GAAW,KAAK,gBAAgB,YAAY,GAClD,GAAI,CAAC,EAAU,CACb,EAAO,KACL,wCAA0C,EAAe,MAE3D,OAMF,GAHI,CADW,KAAK,SAIhB,KAAK,mBAAmB,IAAI,GAC9B,OAEF,KAAM,GAAM,KAAK,gBAAgB,WAAW,EAAS,MACrD,GAAI,CACF,KAAM,GAAW,KAAM,OAAM,EAAK,CAChC,YAAa,KAAK,gBAAgB,2BAA2B,GACzD,UACA,SAEN,GAAI,CAAC,EAAS,GACZ,KAAM,IAAI,OAAM,+BAElB,KAAM,GAAO,KAAM,GAAS,cAC5B,KAAK,wBAAwB,IAAI,EAAU,SACpC,EAAP,CACA,EAAO,MACL,iCAAmC,EAAS,KAAO,YAAc,IAavE,SAAS,EAAyC,CAChD,MACE,MAAK,mBAAmB,YAAY,IAAiB,KAAK,cAQ9D,SAAgB,CACd,KAAK,mBAAmB,QACxB,KAAK,wBAAwB,QAC7B,KAAK,QAAU,KACf,KAAK,aAAe,KAEhB,KAAK,eACP,MAAK,cAAc,QAAU,GAC7B,KAAK,cAAc,WAAa,GAChC,KAAK,cAAc,OAAS,GAC5B,KAAK,cAAc,SAAW,GAC9B,KAAK,cAAc,MAAQ,GAC3B,KAAK,cAAc,MAAM,UApJxB,EAAM,mBATL",
4
+ "sourcesContent": ["/*\n * GDevelop JS Platform\n * Copyright 2013-present Florian Rival (Florian.Rival@gmail.com). All rights reserved.\n * This project is released under the MIT License.\n */\nnamespace gdjs {\n const logger = new gdjs.Logger('Model3DManager');\n\n const resourceKinds: Array<ResourceKind> = ['model3D'];\n\n /**\n * Load GLB files (using `Three.js`), using the \"model3D\" resources\n * registered in the game resources.\n */\n export class Model3DManager implements gdjs.ResourceManager {\n /**\n * Map associating a resource name to the loaded Three.js model.\n */\n private _loadedThreeModels = new gdjs.ResourceCache<THREE_ADDONS.GLTF>();\n private _downloadedArrayBuffers = new gdjs.ResourceCache<ArrayBuffer>();\n\n _resourceLoader: gdjs.ResourceLoader;\n\n _loader: THREE_ADDONS.GLTFLoader | null = null;\n _dracoLoader: THREE_ADDONS.DRACOLoader | null = null;\n\n //@ts-ignore Can only be null if THREE is not loaded.\n _invalidModel: THREE_ADDONS.GLTF;\n\n /**\n * @param resourceLoader The resources loader of the game.\n */\n constructor(resourceLoader: gdjs.ResourceLoader) {\n this._resourceLoader = resourceLoader;\n\n if (typeof THREE !== 'undefined') {\n this._loader = new THREE_ADDONS.GLTFLoader();\n\n this._dracoLoader = new THREE_ADDONS.DRACOLoader();\n this._dracoLoader.setDecoderPath('./pixi-renderers/draco/gltf/');\n this._loader.setDRACOLoader(this._dracoLoader);\n\n /**\n * The invalid model is a box with magenta (#ff00ff) faces, to be\n * easily spotted if rendered on screen.\n */\n const group = new THREE.Group();\n group.add(\n new THREE.Mesh(\n new THREE.BoxGeometry(1, 1, 1),\n new THREE.MeshBasicMaterial({ color: '#ff00ff' })\n )\n );\n this._invalidModel = {\n scene: group,\n animations: [],\n cameras: [],\n scenes: [],\n asset: {},\n userData: {},\n //@ts-ignore\n parser: null,\n };\n }\n }\n\n getResourceKinds(): ResourceKind[] {\n return resourceKinds;\n }\n\n async processResource(resourceName: string): Promise<void> {\n const resource = this._resourceLoader.getResource(resourceName);\n if (!resource) {\n logger.warn(\n 'Unable to find texture for resource \"' + resourceName + '\".'\n );\n return;\n }\n const loader = this._loader;\n if (!loader) {\n return;\n }\n const data = this._downloadedArrayBuffers.get(resource);\n if (!data) {\n return;\n }\n this._downloadedArrayBuffers.delete(resource);\n try {\n const gltf: THREE_ADDONS.GLTF = await loader.parseAsync(data, '');\n this._loadedThreeModels.set(resource, gltf);\n } catch (error) {\n logger.error(\n \"Can't fetch the 3D model file \" + resource.file + ', error: ' + error\n );\n }\n }\n\n async loadResource(resourceName: string): Promise<void> {\n const resource = this._resourceLoader.getResource(resourceName);\n if (!resource) {\n logger.warn(\n 'Unable to find texture for resource \"' + resourceName + '\".'\n );\n return;\n }\n const loader = this._loader;\n if (!loader) {\n return;\n }\n if (this._loadedThreeModels.get(resource)) {\n return;\n }\n const url = this._resourceLoader.getFullUrl(resource.file);\n try {\n const response = await fetch(url, {\n credentials: this._resourceLoader.checkIfCredentialsRequired(url)\n ? 'include'\n : 'omit',\n });\n if (!response.ok) {\n throw new Error('Network response was not ok');\n }\n const data = await response.arrayBuffer();\n this._downloadedArrayBuffers.set(resource, data);\n } catch (error) {\n logger.error(\n \"Can't fetch the 3D model file \" + resource.file + ', error: ' + error\n );\n }\n }\n\n /**\n * Return a 3D model.\n *\n * Caller should not modify the object but clone it.\n *\n * @param resourceName The name of the json resource.\n * @returns a 3D model if it exists.\n */\n getModel(resourceName: string): THREE_ADDONS.GLTF {\n return (\n this._loadedThreeModels.getFromName(resourceName) || this._invalidModel\n );\n }\n\n /**\n * To be called when the game is disposed.\n * Clear the models, resources loaded and destroy 3D models loaders in this manager.\n */\n dispose(): void {\n this._loadedThreeModels.clear();\n this._downloadedArrayBuffers.clear();\n this._loader = null;\n this._dracoLoader = null;\n\n if (this._invalidModel) {\n this._invalidModel.cameras = [];\n this._invalidModel.animations = [];\n this._invalidModel.scenes = [];\n this._invalidModel.userData = {};\n this._invalidModel.asset = {};\n this._invalidModel.scene.clear();\n }\n }\n }\n}\n"],
5
+ "mappings": "AAKA,GAAU,MAAV,UAAU,EAAV,CACE,KAAM,GAAS,GAAI,GAAK,OAAO,kBAEzB,EAAqC,CAAC,WAMrC,OAAqD,CAkB1D,YAAY,EAAqC,CAdzC,wBAAqB,GAAI,GAAK,cAC9B,6BAA0B,GAAI,GAAK,cAI3C,aAA0C,KAC1C,kBAAgD,KAW9C,GAFA,KAAK,gBAAkB,EAEnB,MAAO,QAAU,YAAa,CAChC,KAAK,QAAU,GAAI,cAAa,WAEhC,KAAK,aAAe,GAAI,cAAa,YACrC,KAAK,aAAa,eAAe,gCACjC,KAAK,QAAQ,eAAe,K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,KAAK,mBAAmB,QACxB,KAAK,wBAAwB,QAC7B,KAAK,QAAU,KACf,KAAK,aAAe,KAEhB,KAAK,eACP,MAAK,cAAc,QAAU,GAC7B,KAAK,cAAc,WAAa,GAChC,KAAK,cAAc,OAAS,GAC5B,KAAK,cAAc,SAAW,GAC9B,KAAK,cAAc,MAAQ,GAC3B,KAAK,cAAc,MAAM,UAnJxB,EAAM,mBATL",
6
6
  "names": []
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../GDevelop/GDJS/Runtime/ResourceLoader.ts"],
4
- "sourcesContent": ["/*\n * GDevelop JS Platform\n * Copyright 2013-2023 Florian Rival (Florian.Rival@gmail.com). All rights reserved.\n * This project is released under the MIT License.\n */\nnamespace gdjs {\n const logger = new gdjs.Logger('ResourceLoader');\n\n const addSearchParameterToUrl = (\n url: string,\n urlEncodedParameterName: string,\n urlEncodedValue: string\n ) => {\n if (url.startsWith('data:') || url.startsWith('blob:')) {\n // blob/data protocol does not support search parameters, which are useless anyway.\n return url;\n }\n\n const separator = url.indexOf('?') === -1 ? '?' : '&';\n return url + separator + urlEncodedParameterName + '=' + urlEncodedValue;\n };\n\n const checkIfIsGDevelopCloudBucketUrl = (url: string): boolean => {\n return (\n url.startsWith('https://project-resources.gdevelop.io/') ||\n url.startsWith('https://project-resources-dev.gdevelop.io/')\n );\n };\n\n const maxForegroundConcurrency = 20;\n const maxBackgroundConcurrency = 5;\n const maxAttempt = 3;\n\n /**\n * A task of pre-loading resources used by a scene.\n *\n * A Promise can't be used instead of this class because a Promise will start\n * as soon as possible. It would flood the server with downloading requests\n * and make impossible to finely tune in which order scenes are actually\n * downloaded.\n */\n class SceneLoadingTask {\n sceneName: string;\n private onProgressCallbacks: Array<(count: number, total: number) => void>;\n private onFinishCallbacks: Array<() => void>;\n private isFinished = false;\n\n constructor(sceneName: string) {\n this.sceneName = sceneName;\n this.onProgressCallbacks = new Array<\n (count: number, total: number) => void\n >();\n this.onFinishCallbacks = new Array<() => void>();\n }\n\n registerCallback(\n onFinish: () => void,\n onProgress?: (count: number, total: number) => void\n ) {\n if (this.isFinished) {\n onFinish();\n return;\n }\n this.onFinishCallbacks.push(onFinish);\n if (onProgress) {\n this.onProgressCallbacks.push(onProgress);\n }\n }\n\n onProgress(count: number, total: number) {\n for (const onProgress of this.onProgressCallbacks) {\n onProgress(count, total);\n }\n }\n\n onFinish() {\n this.isFinished = true;\n for (const onFinish of this.onFinishCallbacks) {\n onFinish();\n }\n }\n }\n\n /**\n * Pre-load resources of any kind needed for a game or a scene.\n */\n export class ResourceLoader {\n _runtimeGame: RuntimeGame;\n /**\n * All the resource of a game by resource name.\n */\n private _resources: Map<string, ResourceData>;\n /**\n * Resources needed for any scene. Typically, they are resources from\n * global objects.\n */\n private _globalResources: Array<string>;\n /**\n * Resources by scene names.\n */\n private _sceneResources: Map<string, Array<string>>;\n /**\n * Keep track of which scene whose resources has already be pre-loaded.\n */\n private _sceneNamesToLoad: Set<string>;\n /**\n * Keep track of which scene whose resources has already be loaded.\n */\n private _sceneNamesToMakeReady: Set<string>;\n /**\n * A queue of scenes whose resources are still to be pre-loaded.\n */\n private _sceneToLoadQueue: Array<SceneLoadingTask> = new Array<\n SceneLoadingTask\n >();\n /**\n * The resource managers that actually download and remember downloaded\n * content.\n */\n _resourceManagersMap: Map<ResourceKind, ResourceManager>;\n private _imageManager: ImageManager;\n private _soundManager: SoundManager;\n private _fontManager: FontManager;\n private _jsonManager: JsonManager;\n private _model3DManager: Model3DManager;\n private _bitmapFontManager: BitmapFontManager;\n private _spineAtlasManager: SpineAtlasManager | null = null;\n private _spineManager: SpineManager | null = null;\n\n /**\n * Only used by events.\n */\n private currentLoadingSceneName: string = '';\n /**\n * Only used by events.\n */\n private currentSceneLoadingProgress: float = 0;\n /**\n * It's set to `true` during intermediary loading screen to use a greater\n * concurrency as the game is paused and doesn't need bandwidth (for video\n * or music streaming or online multiplayer).\n */\n private _isLoadingInForeground = true;\n\n /**\n * @param runtimeGame The game.\n * @param resourceDataArray The resources data of the game.\n * @param globalResources The resources needed for any layer.\n * @param layoutDataArray The resources used by each layer.\n */\n constructor(\n runtimeGame: RuntimeGame,\n resourceDataArray: ResourceData[],\n globalResources: Array<string>,\n layoutDataArray: Array<LayoutData>\n ) {\n this._runtimeGame = runtimeGame;\n this._resources = new Map<string, ResourceData>();\n this._globalResources = globalResources;\n\n // These 3 attributes are filled by `setResources`.\n this._sceneResources = new Map<string, Array<string>>();\n this._sceneNamesToLoad = new Set<string>();\n this._sceneNamesToMakeReady = new Set<string>();\n this.setResources(resourceDataArray, globalResources, layoutDataArray);\n\n this._imageManager = new gdjs.ImageManager(this);\n this._soundManager = new gdjs.SoundManager(this);\n this._fontManager = new gdjs.FontManager(this);\n this._jsonManager = new gdjs.JsonManager(this);\n this._bitmapFontManager = new gdjs.BitmapFontManager(\n this,\n this._imageManager\n );\n this._model3DManager = new gdjs.Model3DManager(this);\n\n // add spine related managers only if spine extension is used\n if (gdjs.SpineAtlasManager && gdjs.SpineManager) {\n this._spineAtlasManager = new gdjs.SpineAtlasManager(\n this,\n this._imageManager\n );\n this._spineManager = new gdjs.SpineManager(\n this,\n this._spineAtlasManager\n );\n }\n\n const resourceManagers: Array<ResourceManager> = [\n this._imageManager,\n this._soundManager,\n this._fontManager,\n this._jsonManager,\n this._bitmapFontManager,\n this._model3DManager,\n ];\n\n if (this._spineAtlasManager)\n resourceManagers.push(this._spineAtlasManager);\n if (this._spineManager) resourceManagers.push(this._spineManager);\n\n this._resourceManagersMap = new Map<ResourceKind, ResourceManager>();\n for (const resourceManager of resourceManagers) {\n for (const resourceKind of resourceManager.getResourceKinds()) {\n this._resourceManagersMap.set(resourceKind, resourceManager);\n }\n }\n }\n\n /**\n * @returns the runtime game instance.\n */\n getRuntimeGame(): RuntimeGame {\n return this._runtimeGame;\n }\n\n /**\n * Update the resources data of the game. Useful for hot-reloading, should\n * not be used otherwise.\n */\n setResources(\n resourceDataArray: ResourceData[],\n globalResources: Array<string>,\n layoutDataArray: Array<LayoutData>\n ): void {\n this._globalResources = globalResources;\n\n this._sceneResources.clear();\n this._sceneNamesToLoad.clear();\n this._sceneNamesToMakeReady.clear();\n for (const layoutData of layoutDataArray) {\n this._sceneResources.set(\n layoutData.name,\n layoutData.usedResources.map((resource) => resource.name)\n );\n this._sceneNamesToLoad.add(layoutData.name);\n this._sceneNamesToMakeReady.add(layoutData.name);\n }\n // TODO Clearing the queue doesn't abort the running task, but it should\n // not matter as resource loading is really fast in preview mode.\n this._sceneToLoadQueue.length = 0;\n for (let index = layoutDataArray.length - 1; index >= 0; index--) {\n const layoutData = layoutDataArray[index];\n this._sceneToLoadQueue.push(new SceneLoadingTask(layoutData.name));\n }\n\n this._resources.clear();\n for (const resourceData of resourceDataArray) {\n if (!resourceData.file) {\n // Empty string or missing `file` field: not a valid resource, let's entirely ignore it.\n // Otherwise, this can confuse some loaders that will consider an empty string different\n // than a file that happen not to fail to load.\n continue;\n }\n\n this._resources.set(resourceData.name, resourceData);\n }\n }\n\n async loadAllResources(\n onProgress: (loadingCount: integer, totalCount: integer) => void\n ): Promise<void> {\n let loadedCount = 0;\n await processAndRetryIfNeededWithPromisePool(\n [...this._resources.values()],\n maxForegroundConcurrency,\n maxAttempt,\n async (resource) => {\n await this._loadResource(resource);\n await this._processResource(resource);\n loadedCount++;\n onProgress(loadedCount, this._resources.size);\n }\n );\n this._sceneNamesToLoad.clear();\n this._sceneNamesToMakeReady.clear();\n }\n\n /**\n * Load the resources that are needed to launch the first scene.\n */\n async loadGlobalAndFirstSceneResources(\n firstSceneName: string,\n onProgress: (count: number, total: number) => void\n ): Promise<void> {\n const sceneResources = this._sceneResources.get(firstSceneName);\n if (!sceneResources) {\n logger.warn(\n 'Can\\'t load resource for unknown scene: \"' + firstSceneName + '\".'\n );\n return;\n }\n let loadedCount = 0;\n const resources = [...this._globalResources, ...sceneResources.values()];\n await processAndRetryIfNeededWithPromisePool(\n resources,\n maxForegroundConcurrency,\n maxAttempt,\n async (resourceName) => {\n const resource = this._resources.get(resourceName);\n if (!resource) {\n logger.warn('Unable to find resource \"' + resourceName + '\".');\n return;\n }\n await this._loadResource(resource);\n await this._processResource(resource);\n loadedCount++;\n onProgress(loadedCount, resources.length);\n }\n );\n this._setSceneAssetsLoaded(firstSceneName);\n this._setSceneAssetsReady(firstSceneName);\n }\n\n /**\n * Load each scene in order.\n *\n * This is done in background to try to avoid loading screens when changing\n * scenes.\n */\n async loadAllSceneInBackground(): Promise<void> {\n while (this._sceneToLoadQueue.length > 0) {\n const task = this._sceneToLoadQueue[this._sceneToLoadQueue.length - 1];\n if (task === undefined) {\n continue;\n }\n this.currentLoadingSceneName = task.sceneName;\n if (!this.areSceneAssetsLoaded(task.sceneName)) {\n await this._doLoadSceneResources(\n task.sceneName,\n async (count, total) => task.onProgress(count, total)\n );\n // A scene may have been moved last while awaiting resources to be\n // downloaded (see _prioritizeScene).\n this._sceneToLoadQueue.splice(\n this._sceneToLoadQueue.findIndex((element) => element === task),\n 1\n );\n task.onFinish();\n } else {\n this._sceneToLoadQueue.pop();\n }\n }\n this.currentLoadingSceneName = '';\n }\n\n private async _doLoadSceneResources(\n sceneName: string,\n onProgress?: (count: number, total: number) => Promise<void>\n ): Promise<void> {\n const sceneResources = this._sceneResources.get(sceneName);\n if (!sceneResources) {\n logger.warn(\n 'Can\\'t load resource for unknown scene: \"' + sceneName + '\".'\n );\n return;\n }\n let loadedCount = 0;\n await processAndRetryIfNeededWithPromisePool(\n [...sceneResources.values()],\n this._isLoadingInForeground\n ? maxForegroundConcurrency\n : maxBackgroundConcurrency,\n maxAttempt,\n async (resourceName) => {\n const resource = this._resources.get(resourceName);\n if (!resource) {\n logger.warn('Unable to find resource \"' + resourceName + '\".');\n return;\n }\n await this._loadResource(resource);\n loadedCount++;\n this.currentSceneLoadingProgress = loadedCount / this._resources.size;\n onProgress && (await onProgress(loadedCount, this._resources.size));\n }\n );\n this._setSceneAssetsLoaded(sceneName);\n }\n\n private async _loadResource(resource: ResourceData): Promise<void> {\n const resourceManager = this._resourceManagersMap.get(resource.kind);\n if (!resourceManager) {\n logger.warn(\n 'Unknown resource kind: \"' +\n resource.kind +\n '\" for: \"' +\n resource.name +\n '\".'\n );\n return;\n }\n await resourceManager.loadResource(resource.name);\n }\n\n /**\n * Load and process a scene that is needed right away.\n *\n * The renderer will show a loading screen while its done.\n */\n async loadAndProcessSceneResources(\n sceneName: string,\n onProgress?: (count: number, total: number) => Promise<void>\n ): Promise<void> {\n if (this.areSceneAssetsReady(sceneName)) {\n return;\n }\n await this.loadSceneResources(sceneName, onProgress);\n\n const sceneResources = this._sceneResources.get(sceneName);\n if (!sceneResources) {\n logger.warn(\n 'Can\\'t load resource for unknown scene: \"' + sceneName + '\".'\n );\n return;\n }\n\n let parsedCount = 0;\n for (const resourceName of sceneResources) {\n const resource = this._resources.get(resourceName);\n if (!resource) {\n logger.warn('Unable to find resource \"' + resourceName + '\".');\n continue;\n }\n await this._processResource(resource);\n parsedCount++;\n onProgress && (await onProgress(parsedCount, sceneResources.length));\n }\n this._setSceneAssetsReady(sceneName);\n }\n\n /**\n * Load a scene resources without parsing them.\n *\n * When another scene resources are loading in background, it waits for\n * all its resources to be loaded before loading resources of the given\n * scene.\n */\n async loadSceneResources(\n sceneName: string,\n onProgress?: (count: number, total: number) => void\n ): Promise<void> {\n this._isLoadingInForeground = true;\n const task = this._prioritizeScene(sceneName);\n return new Promise<void>((resolve, reject) => {\n if (!task) {\n this._isLoadingInForeground = false;\n resolve();\n return;\n }\n task.registerCallback(() => {\n this._isLoadingInForeground = false;\n resolve();\n }, onProgress);\n });\n }\n\n /**\n * To be called when the game is disposed.\n * Dispose all the resource managers.\n */\n dispose(): void {\n for (const resourceManager of this._resourceManagersMap.values()) {\n resourceManager.dispose();\n }\n }\n\n /**\n * Put a given scene at the end of the queue.\n *\n * When the scene that is currently loading in background is done,\n * this scene will be the next to be loaded.\n */\n private _prioritizeScene(sceneName: string): SceneLoadingTask | null {\n const taskIndex = this._sceneToLoadQueue.findIndex(\n (task) => task.sceneName === sceneName\n );\n if (taskIndex < 0) {\n // The scene is already loaded.\n return null;\n }\n const task = this._sceneToLoadQueue[taskIndex];\n this._sceneToLoadQueue.splice(taskIndex, 1);\n this._sceneToLoadQueue.push(task);\n return task;\n }\n\n private async _processResource(resource: ResourceData): Promise<void> {\n const resourceManager = this._resourceManagersMap.get(resource.kind);\n if (!resourceManager) {\n logger.warn(\n 'Unknown resource kind: \"' +\n resource.kind +\n '\" for: \"' +\n resource.name +\n '\".'\n );\n return;\n }\n await resourceManager.processResource(resource.name);\n }\n\n getSceneLoadingProgress(sceneName: string): float {\n return sceneName === this.currentLoadingSceneName\n ? this.currentSceneLoadingProgress\n : this.areSceneAssetsLoaded(sceneName)\n ? 1\n : 0;\n }\n\n /**\n * @returns true when all the resources of the given scene are loaded\n * (but maybe not parsed).\n */\n areSceneAssetsLoaded(sceneName: string): boolean {\n return !this._sceneNamesToLoad.has(sceneName);\n }\n\n /**\n * @returns true when all the resources of the given scene are loaded and\n * parsed.\n */\n areSceneAssetsReady(sceneName: string): boolean {\n return !this._sceneNamesToMakeReady.has(sceneName);\n }\n\n private _setSceneAssetsLoaded(sceneName: string): void {\n this._sceneNamesToLoad.delete(sceneName);\n }\n\n private _setSceneAssetsReady(sceneName: string): void {\n this._sceneNamesToMakeReady.delete(sceneName);\n }\n\n getResource(resourceName: string): ResourceData | null {\n return this._resources.get(resourceName) || null;\n }\n\n // Helper methods used when resources are loaded from an URL.\n\n /**\n * Complete the given URL with any specific parameter required to access\n * the resource (this can be for example a token needed to access the resource).\n */\n getFullUrl(url: string) {\n const { gdevelopResourceToken } = this._runtimeGame._options;\n if (!gdevelopResourceToken) return url;\n\n if (!checkIfIsGDevelopCloudBucketUrl(url)) return url;\n\n return addSearchParameterToUrl(\n url,\n 'gd_resource_token',\n encodeURIComponent(gdevelopResourceToken)\n );\n }\n\n /**\n * Return true if the specified URL must be loaded with cookies (\"credentials\")\n * sent to grant access to them.\n */\n checkIfCredentialsRequired(url: string) {\n if (this._runtimeGame._options.gdevelopResourceToken) return false;\n\n // Any resource stored on the GDevelop Cloud buckets needs the \"credentials\" of the user,\n // i.e: its gdevelop.io cookie, to be passed.\n // Note that this is only useful during previews.\n if (checkIfIsGDevelopCloudBucketUrl(url)) return true;\n\n // For other resources, use the default way of loading resources (\"anonymous\" or \"same-site\").\n return false;\n }\n\n /**\n * Get the gdjs.SoundManager of the RuntimeGame.\n * @return The sound manager.\n */\n getSoundManager(): gdjs.HowlerSoundManager {\n return this._soundManager;\n }\n\n /**\n * Get the gdjs.ImageManager of the RuntimeGame.\n * @return The image manager.\n */\n getImageManager(): gdjs.PixiImageManager {\n return this._imageManager;\n }\n\n /**\n * Get the gdjs.FontManager of the RuntimeGame.\n * @return The font manager.\n */\n getFontManager(): gdjs.FontFaceObserverFontManager {\n return this._fontManager;\n }\n\n /**\n * Get the gdjs.BitmapFontManager of the RuntimeGame.\n * @return The bitmap font manager.\n */\n getBitmapFontManager(): gdjs.BitmapFontManager {\n return this._bitmapFontManager;\n }\n\n /**\n * Get the JSON manager of the game, used to load JSON from game\n * resources.\n * @return The json manager for the game\n */\n getJsonManager(): gdjs.JsonManager {\n return this._jsonManager;\n }\n\n /**\n * Get the 3D model manager of the game, used to load 3D model from game\n * resources.\n * @return The 3D model manager for the game\n */\n getModel3DManager(): gdjs.Model3DManager {\n return this._model3DManager;\n }\n\n /**\n * Get the Spine manager of the game, used to load and construct spine skeletons from game\n * resources.\n * @return The Spine manager for the game\n */\n getSpineManager(): gdjs.SpineManager | null {\n return this._spineManager;\n }\n\n /**\n * Get the Spine Atlas manager of the game, used to load atlases from game\n * resources.\n * @return The Spine Atlas manager for the game\n */\n getSpineAtlasManager(): gdjs.SpineAtlasManager | null {\n return this._spineAtlasManager;\n }\n }\n\n type PromiseError<T> = { item: T; error: Error };\n\n type PromisePoolOutput<T, U> = {\n results: Array<U>;\n errors: Array<PromiseError<T>>;\n };\n\n const processWithPromisePool = <T, U>(\n items: Array<T>,\n maxConcurrency: number,\n asyncFunction: (item: T) => Promise<U>\n ): Promise<PromisePoolOutput<T, U>> => {\n const results: Array<U> = [];\n const errors: Array<PromiseError<T>> = [];\n let activePromises = 0;\n let index = 0;\n\n return new Promise((resolve, reject) => {\n const executeNext = () => {\n if (items.length === 0) {\n resolve({ results, errors });\n return;\n }\n while (activePromises < maxConcurrency && index < items.length) {\n const item = items[index++];\n activePromises++;\n\n asyncFunction(item)\n .then((result) => results.push(result))\n .catch((error) => errors.push({ item, error }))\n .finally(() => {\n activePromises--;\n if (index === items.length && activePromises === 0) {\n resolve({ results, errors });\n } else {\n executeNext();\n }\n });\n }\n };\n\n executeNext();\n });\n };\n\n const processAndRetryIfNeededWithPromisePool = async <T, U>(\n items: Array<T>,\n maxConcurrency: number,\n maxAttempt: number,\n asyncFunction: (item: T) => Promise<U>\n ): Promise<PromisePoolOutput<T, U>> => {\n const output = await processWithPromisePool<T, U>(\n items,\n maxConcurrency,\n asyncFunction\n );\n if (output.errors.length !== 0) {\n logger.warn(\"Some assets couldn't be downloaded. Trying again now.\");\n }\n for (\n let attempt = 1;\n attempt < maxAttempt && output.errors.length !== 0;\n attempt++\n ) {\n const retryOutput = await processWithPromisePool<T, U>(\n items,\n maxConcurrency,\n asyncFunction\n );\n output.results.push.apply(output.results, retryOutput.results);\n output.errors = retryOutput.errors;\n }\n return output;\n };\n}\n"],
5
- "mappings": "AAKA,GAAU,MAAV,UAAU,EAAV,CACE,KAAM,GAAS,GAAI,GAAK,OAAO,kBAEzB,EAA0B,CAC9B,EACA,EACA,IACG,CACH,GAAI,EAAI,WAAW,UAAY,EAAI,WAAW,SAE5C,MAAO,GAGT,KAAM,GAAY,EAAI,QAAQ,OAAS,GAAK,IAAM,IAClD,MAAO,GAAM,EAAY,EAA0B,IAAM,GAGrD,EAAkC,AAAC,GAErC,EAAI,WAAW,2CACf,EAAI,WAAW,8CAIb,EAA2B,GAC3B,EAA2B,EAC3B,EAAa,EAUnB,OAAuB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M,GACnB,EACA,EACA,GAEF,AAAI,EAAO,OAAO,SAAW,GAC3B,EAAO,KAAK,yDAEd,OACM,GAAU,EACd,EAAU,GAAc,EAAO,OAAO,SAAW,EACjD,IACA,CACA,KAAM,GAAc,KAAM,GACxB,EACA,EACA,GAEF,EAAO,QAAQ,KAAK,MAAM,EAAO,QAAS,EAAY,SACtD,EAAO,OAAS,EAAY,OAE9B,MAAO,MApsBD",
4
+ "sourcesContent": ["/*\n * GDevelop JS Platform\n * Copyright 2013-2023 Florian Rival (Florian.Rival@gmail.com). All rights reserved.\n * This project is released under the MIT License.\n */\nnamespace gdjs {\n const logger = new gdjs.Logger('ResourceLoader');\n\n const addSearchParameterToUrl = (\n url: string,\n urlEncodedParameterName: string,\n urlEncodedValue: string\n ) => {\n if (url.startsWith('data:') || url.startsWith('blob:')) {\n // blob/data protocol does not support search parameters, which are useless anyway.\n return url;\n }\n\n const separator = url.indexOf('?') === -1 ? '?' : '&';\n return url + separator + urlEncodedParameterName + '=' + urlEncodedValue;\n };\n\n const checkIfIsGDevelopCloudBucketUrl = (url: string): boolean => {\n return (\n url.startsWith('https://project-resources.gdevelop.io/') ||\n url.startsWith('https://project-resources-dev.gdevelop.io/')\n );\n };\n\n const maxForegroundConcurrency = 20;\n const maxBackgroundConcurrency = 5;\n const maxAttempt = 3;\n\n /**\n * A task of pre-loading resources used by a scene.\n *\n * A Promise can't be used instead of this class because a Promise will start\n * as soon as possible. It would flood the server with downloading requests\n * and make impossible to finely tune in which order scenes are actually\n * downloaded.\n */\n class SceneLoadingTask {\n sceneName: string;\n private onProgressCallbacks: Array<(count: number, total: number) => void>;\n private onFinishCallbacks: Array<() => void>;\n private isFinished = false;\n\n constructor(sceneName: string) {\n this.sceneName = sceneName;\n this.onProgressCallbacks = new Array<\n (count: number, total: number) => void\n >();\n this.onFinishCallbacks = new Array<() => void>();\n }\n\n registerCallback(\n onFinish: () => void,\n onProgress?: (count: number, total: number) => void\n ) {\n if (this.isFinished) {\n onFinish();\n return;\n }\n this.onFinishCallbacks.push(onFinish);\n if (onProgress) {\n this.onProgressCallbacks.push(onProgress);\n }\n }\n\n onProgress(count: number, total: number) {\n for (const onProgress of this.onProgressCallbacks) {\n onProgress(count, total);\n }\n }\n\n onFinish() {\n this.isFinished = true;\n for (const onFinish of this.onFinishCallbacks) {\n onFinish();\n }\n }\n }\n\n /**\n * Pre-load resources of any kind needed for a game or a scene.\n */\n export class ResourceLoader {\n _runtimeGame: RuntimeGame;\n /**\n * All the resource of a game by resource name.\n */\n private _resources: Map<string, ResourceData>;\n /**\n * Resources needed for any scene. Typically, they are resources from\n * global objects.\n */\n private _globalResources: Array<string>;\n /**\n * Resources by scene names.\n */\n private _sceneResources: Map<string, Array<string>>;\n /**\n * Keep track of which scene whose resources has already be pre-loaded.\n */\n private _sceneNamesToLoad: Set<string>;\n /**\n * Keep track of which scene whose resources has already be loaded.\n */\n private _sceneNamesToMakeReady: Set<string>;\n /**\n * A queue of scenes whose resources are still to be pre-loaded.\n */\n private _sceneToLoadQueue: Array<SceneLoadingTask> =\n new Array<SceneLoadingTask>();\n /**\n * The resource managers that actually download and remember downloaded\n * content.\n */\n _resourceManagersMap: Map<ResourceKind, ResourceManager>;\n private _imageManager: ImageManager;\n private _soundManager: SoundManager;\n private _fontManager: FontManager;\n private _jsonManager: JsonManager;\n private _model3DManager: Model3DManager;\n private _bitmapFontManager: BitmapFontManager;\n private _spineAtlasManager: SpineAtlasManager | null = null;\n private _spineManager: SpineManager | null = null;\n\n /**\n * Only used by events.\n */\n private currentLoadingSceneName: string = '';\n /**\n * Only used by events.\n */\n private currentSceneLoadingProgress: float = 0;\n /**\n * It's set to `true` during intermediary loading screen to use a greater\n * concurrency as the game is paused and doesn't need bandwidth (for video\n * or music streaming or online multiplayer).\n */\n private _isLoadingInForeground = true;\n\n /**\n * @param runtimeGame The game.\n * @param resourceDataArray The resources data of the game.\n * @param globalResources The resources needed for any layer.\n * @param layoutDataArray The resources used by each layer.\n */\n constructor(\n runtimeGame: RuntimeGame,\n resourceDataArray: ResourceData[],\n globalResources: Array<string>,\n layoutDataArray: Array<LayoutData>\n ) {\n this._runtimeGame = runtimeGame;\n this._resources = new Map<string, ResourceData>();\n this._globalResources = globalResources;\n\n // These 3 attributes are filled by `setResources`.\n this._sceneResources = new Map<string, Array<string>>();\n this._sceneNamesToLoad = new Set<string>();\n this._sceneNamesToMakeReady = new Set<string>();\n this.setResources(resourceDataArray, globalResources, layoutDataArray);\n\n this._imageManager = new gdjs.ImageManager(this);\n this._soundManager = new gdjs.SoundManager(this);\n this._fontManager = new gdjs.FontManager(this);\n this._jsonManager = new gdjs.JsonManager(this);\n this._bitmapFontManager = new gdjs.BitmapFontManager(\n this,\n this._imageManager\n );\n this._model3DManager = new gdjs.Model3DManager(this);\n\n // add spine related managers only if spine extension is used\n if (gdjs.SpineAtlasManager && gdjs.SpineManager) {\n this._spineAtlasManager = new gdjs.SpineAtlasManager(\n this,\n this._imageManager\n );\n this._spineManager = new gdjs.SpineManager(\n this,\n this._spineAtlasManager\n );\n }\n\n const resourceManagers: Array<ResourceManager> = [\n this._imageManager,\n this._soundManager,\n this._fontManager,\n this._jsonManager,\n this._bitmapFontManager,\n this._model3DManager,\n ];\n\n if (this._spineAtlasManager)\n resourceManagers.push(this._spineAtlasManager);\n if (this._spineManager) resourceManagers.push(this._spineManager);\n\n this._resourceManagersMap = new Map<ResourceKind, ResourceManager>();\n for (const resourceManager of resourceManagers) {\n for (const resourceKind of resourceManager.getResourceKinds()) {\n this._resourceManagersMap.set(resourceKind, resourceManager);\n }\n }\n }\n\n /**\n * @returns the runtime game instance.\n */\n getRuntimeGame(): RuntimeGame {\n return this._runtimeGame;\n }\n\n /**\n * Update the resources data of the game. Useful for hot-reloading, should\n * not be used otherwise.\n */\n setResources(\n resourceDataArray: ResourceData[],\n globalResources: Array<string>,\n layoutDataArray: Array<LayoutData>\n ): void {\n this._globalResources = globalResources;\n\n this._sceneResources.clear();\n this._sceneNamesToLoad.clear();\n this._sceneNamesToMakeReady.clear();\n for (const layoutData of layoutDataArray) {\n this._sceneResources.set(\n layoutData.name,\n layoutData.usedResources.map((resource) => resource.name)\n );\n this._sceneNamesToLoad.add(layoutData.name);\n this._sceneNamesToMakeReady.add(layoutData.name);\n }\n // TODO Clearing the queue doesn't abort the running task, but it should\n // not matter as resource loading is really fast in preview mode.\n this._sceneToLoadQueue.length = 0;\n for (let index = layoutDataArray.length - 1; index >= 0; index--) {\n const layoutData = layoutDataArray[index];\n this._sceneToLoadQueue.push(new SceneLoadingTask(layoutData.name));\n }\n\n this._resources.clear();\n for (const resourceData of resourceDataArray) {\n if (!resourceData.file) {\n // Empty string or missing `file` field: not a valid resource, let's entirely ignore it.\n // Otherwise, this can confuse some loaders that will consider an empty string different\n // than a file that happen not to fail to load.\n continue;\n }\n\n this._resources.set(resourceData.name, resourceData);\n }\n }\n\n async loadAllResources(\n onProgress: (loadingCount: integer, totalCount: integer) => void\n ): Promise<void> {\n let loadedCount = 0;\n await processAndRetryIfNeededWithPromisePool(\n [...this._resources.values()],\n maxForegroundConcurrency,\n maxAttempt,\n async (resource) => {\n await this._loadResource(resource);\n await this._processResource(resource);\n loadedCount++;\n onProgress(loadedCount, this._resources.size);\n }\n );\n this._sceneNamesToLoad.clear();\n this._sceneNamesToMakeReady.clear();\n }\n\n /**\n * Load the resources that are needed to launch the first scene.\n */\n async loadGlobalAndFirstSceneResources(\n firstSceneName: string,\n onProgress: (count: number, total: number) => void\n ): Promise<void> {\n const sceneResources = this._sceneResources.get(firstSceneName);\n if (!sceneResources) {\n logger.warn(\n 'Can\\'t load resource for unknown scene: \"' + firstSceneName + '\".'\n );\n return;\n }\n let loadedCount = 0;\n const resources = [...this._globalResources, ...sceneResources.values()];\n await processAndRetryIfNeededWithPromisePool(\n resources,\n maxForegroundConcurrency,\n maxAttempt,\n async (resourceName) => {\n const resource = this._resources.get(resourceName);\n if (!resource) {\n logger.warn('Unable to find resource \"' + resourceName + '\".');\n return;\n }\n await this._loadResource(resource);\n await this._processResource(resource);\n loadedCount++;\n onProgress(loadedCount, resources.length);\n }\n );\n this._setSceneAssetsLoaded(firstSceneName);\n this._setSceneAssetsReady(firstSceneName);\n }\n\n /**\n * Load each scene in order.\n *\n * This is done in background to try to avoid loading screens when changing\n * scenes.\n */\n async loadAllSceneInBackground(): Promise<void> {\n while (this._sceneToLoadQueue.length > 0) {\n const task = this._sceneToLoadQueue[this._sceneToLoadQueue.length - 1];\n if (task === undefined) {\n continue;\n }\n this.currentLoadingSceneName = task.sceneName;\n if (!this.areSceneAssetsLoaded(task.sceneName)) {\n await this._doLoadSceneResources(\n task.sceneName,\n async (count, total) => task.onProgress(count, total)\n );\n // A scene may have been moved last while awaiting resources to be\n // downloaded (see _prioritizeScene).\n this._sceneToLoadQueue.splice(\n this._sceneToLoadQueue.findIndex((element) => element === task),\n 1\n );\n task.onFinish();\n } else {\n this._sceneToLoadQueue.pop();\n }\n }\n this.currentLoadingSceneName = '';\n }\n\n private async _doLoadSceneResources(\n sceneName: string,\n onProgress?: (count: number, total: number) => Promise<void>\n ): Promise<void> {\n const sceneResources = this._sceneResources.get(sceneName);\n if (!sceneResources) {\n logger.warn(\n 'Can\\'t load resource for unknown scene: \"' + sceneName + '\".'\n );\n return;\n }\n let loadedCount = 0;\n await processAndRetryIfNeededWithPromisePool(\n [...sceneResources.values()],\n this._isLoadingInForeground\n ? maxForegroundConcurrency\n : maxBackgroundConcurrency,\n maxAttempt,\n async (resourceName) => {\n const resource = this._resources.get(resourceName);\n if (!resource) {\n logger.warn('Unable to find resource \"' + resourceName + '\".');\n return;\n }\n await this._loadResource(resource);\n loadedCount++;\n this.currentSceneLoadingProgress = loadedCount / this._resources.size;\n onProgress && (await onProgress(loadedCount, this._resources.size));\n }\n );\n this._setSceneAssetsLoaded(sceneName);\n }\n\n private async _loadResource(resource: ResourceData): Promise<void> {\n const resourceManager = this._resourceManagersMap.get(resource.kind);\n if (!resourceManager) {\n logger.warn(\n 'Unknown resource kind: \"' +\n resource.kind +\n '\" for: \"' +\n resource.name +\n '\".'\n );\n return;\n }\n await resourceManager.loadResource(resource.name);\n }\n\n /**\n * Load and process a scene that is needed right away.\n *\n * The renderer will show a loading screen while its done.\n */\n async loadAndProcessSceneResources(\n sceneName: string,\n onProgress?: (count: number, total: number) => Promise<void>\n ): Promise<void> {\n if (this.areSceneAssetsReady(sceneName)) {\n return;\n }\n await this.loadSceneResources(sceneName, onProgress);\n\n const sceneResources = this._sceneResources.get(sceneName);\n if (!sceneResources) {\n logger.warn(\n 'Can\\'t load resource for unknown scene: \"' + sceneName + '\".'\n );\n return;\n }\n\n let parsedCount = 0;\n for (const resourceName of sceneResources) {\n const resource = this._resources.get(resourceName);\n if (!resource) {\n logger.warn('Unable to find resource \"' + resourceName + '\".');\n continue;\n }\n await this._processResource(resource);\n parsedCount++;\n onProgress && (await onProgress(parsedCount, sceneResources.length));\n }\n this._setSceneAssetsReady(sceneName);\n }\n\n /**\n * Load a scene resources without parsing them.\n *\n * When another scene resources are loading in background, it waits for\n * all its resources to be loaded before loading resources of the given\n * scene.\n */\n async loadSceneResources(\n sceneName: string,\n onProgress?: (count: number, total: number) => void\n ): Promise<void> {\n this._isLoadingInForeground = true;\n const task = this._prioritizeScene(sceneName);\n return new Promise<void>((resolve, reject) => {\n if (!task) {\n this._isLoadingInForeground = false;\n resolve();\n return;\n }\n task.registerCallback(() => {\n this._isLoadingInForeground = false;\n resolve();\n }, onProgress);\n });\n }\n\n /**\n * To be called when the game is disposed.\n * Dispose all the resource managers.\n */\n dispose(): void {\n for (const resourceManager of this._resourceManagersMap.values()) {\n resourceManager.dispose();\n }\n }\n\n /**\n * Put a given scene at the end of the queue.\n *\n * When the scene that is currently loading in background is done,\n * this scene will be the next to be loaded.\n */\n private _prioritizeScene(sceneName: string): SceneLoadingTask | null {\n const taskIndex = this._sceneToLoadQueue.findIndex(\n (task) => task.sceneName === sceneName\n );\n if (taskIndex < 0) {\n // The scene is already loaded.\n return null;\n }\n const task = this._sceneToLoadQueue[taskIndex];\n this._sceneToLoadQueue.splice(taskIndex, 1);\n this._sceneToLoadQueue.push(task);\n return task;\n }\n\n private async _processResource(resource: ResourceData): Promise<void> {\n const resourceManager = this._resourceManagersMap.get(resource.kind);\n if (!resourceManager) {\n logger.warn(\n 'Unknown resource kind: \"' +\n resource.kind +\n '\" for: \"' +\n resource.name +\n '\".'\n );\n return;\n }\n await resourceManager.processResource(resource.name);\n }\n\n getSceneLoadingProgress(sceneName: string): float {\n return sceneName === this.currentLoadingSceneName\n ? this.currentSceneLoadingProgress\n : this.areSceneAssetsLoaded(sceneName)\n ? 1\n : 0;\n }\n\n /**\n * @returns true when all the resources of the given scene are loaded\n * (but maybe not parsed).\n */\n areSceneAssetsLoaded(sceneName: string): boolean {\n return !this._sceneNamesToLoad.has(sceneName);\n }\n\n /**\n * @returns true when all the resources of the given scene are loaded and\n * parsed.\n */\n areSceneAssetsReady(sceneName: string): boolean {\n return !this._sceneNamesToMakeReady.has(sceneName);\n }\n\n private _setSceneAssetsLoaded(sceneName: string): void {\n this._sceneNamesToLoad.delete(sceneName);\n }\n\n private _setSceneAssetsReady(sceneName: string): void {\n this._sceneNamesToMakeReady.delete(sceneName);\n }\n\n getResource(resourceName: string): ResourceData | null {\n return this._resources.get(resourceName) || null;\n }\n\n // Helper methods used when resources are loaded from an URL.\n\n /**\n * Complete the given URL with any specific parameter required to access\n * the resource (this can be for example a token needed to access the resource).\n */\n getFullUrl(url: string) {\n const { gdevelopResourceToken } = this._runtimeGame._options;\n if (!gdevelopResourceToken) return url;\n\n if (!checkIfIsGDevelopCloudBucketUrl(url)) return url;\n\n return addSearchParameterToUrl(\n url,\n 'gd_resource_token',\n encodeURIComponent(gdevelopResourceToken)\n );\n }\n\n /**\n * Return true if the specified URL must be loaded with cookies (\"credentials\")\n * sent to grant access to them.\n */\n checkIfCredentialsRequired(url: string) {\n if (this._runtimeGame._options.gdevelopResourceToken) return false;\n\n // Any resource stored on the GDevelop Cloud buckets needs the \"credentials\" of the user,\n // i.e: its gdevelop.io cookie, to be passed.\n // Note that this is only useful during previews.\n if (checkIfIsGDevelopCloudBucketUrl(url)) return true;\n\n // For other resources, use the default way of loading resources (\"anonymous\" or \"same-site\").\n return false;\n }\n\n /**\n * Get the gdjs.SoundManager of the RuntimeGame.\n * @return The sound manager.\n */\n getSoundManager(): gdjs.HowlerSoundManager {\n return this._soundManager;\n }\n\n /**\n * Get the gdjs.ImageManager of the RuntimeGame.\n * @return The image manager.\n */\n getImageManager(): gdjs.PixiImageManager {\n return this._imageManager;\n }\n\n /**\n * Get the gdjs.FontManager of the RuntimeGame.\n * @return The font manager.\n */\n getFontManager(): gdjs.FontFaceObserverFontManager {\n return this._fontManager;\n }\n\n /**\n * Get the gdjs.BitmapFontManager of the RuntimeGame.\n * @return The bitmap font manager.\n */\n getBitmapFontManager(): gdjs.BitmapFontManager {\n return this._bitmapFontManager;\n }\n\n /**\n * Get the JSON manager of the game, used to load JSON from game\n * resources.\n * @return The json manager for the game\n */\n getJsonManager(): gdjs.JsonManager {\n return this._jsonManager;\n }\n\n /**\n * Get the 3D model manager of the game, used to load 3D model from game\n * resources.\n * @return The 3D model manager for the game\n */\n getModel3DManager(): gdjs.Model3DManager {\n return this._model3DManager;\n }\n\n /**\n * Get the Spine manager of the game, used to load and construct spine skeletons from game\n * resources.\n * @return The Spine manager for the game\n */\n getSpineManager(): gdjs.SpineManager | null {\n return this._spineManager;\n }\n\n /**\n * Get the Spine Atlas manager of the game, used to load atlases from game\n * resources.\n * @return The Spine Atlas manager for the game\n */\n getSpineAtlasManager(): gdjs.SpineAtlasManager | null {\n return this._spineAtlasManager;\n }\n }\n\n type PromiseError<T> = { item: T; error: Error };\n\n type PromisePoolOutput<T, U> = {\n results: Array<U>;\n errors: Array<PromiseError<T>>;\n };\n\n const processWithPromisePool = <T, U>(\n items: Array<T>,\n maxConcurrency: number,\n asyncFunction: (item: T) => Promise<U>\n ): Promise<PromisePoolOutput<T, U>> => {\n const results: Array<U> = [];\n const errors: Array<PromiseError<T>> = [];\n let activePromises = 0;\n let index = 0;\n\n return new Promise((resolve, reject) => {\n const executeNext = () => {\n if (items.length === 0) {\n resolve({ results, errors });\n return;\n }\n while (activePromises < maxConcurrency && index < items.length) {\n const item = items[index++];\n activePromises++;\n\n asyncFunction(item)\n .then((result) => results.push(result))\n .catch((error) => errors.push({ item, error }))\n .finally(() => {\n activePromises--;\n if (index === items.length && activePromises === 0) {\n resolve({ results, errors });\n } else {\n executeNext();\n }\n });\n }\n };\n\n executeNext();\n });\n };\n\n const processAndRetryIfNeededWithPromisePool = async <T, U>(\n items: Array<T>,\n maxConcurrency: number,\n maxAttempt: number,\n asyncFunction: (item: T) => Promise<U>\n ): Promise<PromisePoolOutput<T, U>> => {\n const output = await processWithPromisePool<T, U>(\n items,\n maxConcurrency,\n asyncFunction\n );\n if (output.errors.length !== 0) {\n logger.warn(\"Some assets couldn't be downloaded. Trying again now.\");\n }\n for (\n let attempt = 1;\n attempt < maxAttempt && output.errors.length !== 0;\n attempt++\n ) {\n const retryOutput = await processWithPromisePool<T, U>(\n items,\n maxConcurrency,\n asyncFunction\n );\n output.results.push.apply(output.results, retryOutput.results);\n output.errors = retryOutput.errors;\n }\n return output;\n };\n}\n"],
5
+ "mappings": "AAKA,GAAU,MAAV,UAAU,EAAV,CACE,KAAM,GAAS,GAAI,GAAK,OAAO,kBAEzB,EAA0B,CAC9B,EACA,EACA,IACG,CACH,GAAI,EAAI,WAAW,UAAY,EAAI,WAAW,SAE5C,MAAO,GAGT,KAAM,GAAY,EAAI,QAAQ,OAAS,GAAK,IAAM,IAClD,MAAO,GAAM,EAAY,EAA0B,IAAM,GAGrD,EAAkC,AAAC,GAErC,EAAI,WAAW,2CACf,EAAI,WAAW,8CAIb,EAA2B,GAC3B,EAA2B,EAC3B,EAAa,EAUnB,OAAuB,CAMrB,YAAY,EAAmB,CAFvB,gBAAa,GAGnB,KAAK,UAAY,EACjB,KAAK,oBAAsB,GAAI,OAG/B,KAAK,kBAAoB,GA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AAO,SAAW,EACjD,IACA,CACA,KAAM,GAAc,KAAM,GACxB,EACA,EACA,GAEF,EAAO,QAAQ,KAAK,MAAM,EAAO,QAAS,EAAY,SACtD,EAAO,OAAS,EAAY,OAE9B,MAAO,MAnsBD",
6
6
  "names": []
7
7
  }
@@ -1,2 +1,2 @@
1
- var gdjs;(function(o){class n extends o.RuntimeLayer{constructor(e,a){super(e,a);this._renderer.onCreated()}onGameResolutionResized(e,a){}getCameraX(e){return 0}getCameraY(e){return 0}setCameraX(e,a){}setCameraY(e,a){}getCameraWidth(e){return 0}getCameraHeight(e){return 0}setCameraZoom(e,a){}getCameraZoom(e){return 1}setCameraZ(e,a,r){}getCameraZ(e,a){return 0}getCameraRotation(e){return 0}setCameraRotation(e,a){}convertCoords(e,a,r,t){return this._runtimeScene.convertCoords(e,a,t||[0,0])}convertInverseCoords(e,a,r,t){return this._runtimeScene.convertInverseCoords(e,a,t||[0,0])}applyLayerInverseTransformation(e,a,r,t){return t[0]=e,t[1]=a,t}applyLayerTransformation(e,a,r,t){return t[0]=e,t[1]=a,t}}o.RuntimeCustomObjectLayer=n})(gdjs||(gdjs={}));
1
+ var gdjs;(function(o){class n extends o.RuntimeLayer{constructor(e,r){super(e,r);this._renderer.onCreated()}onGameResolutionResized(e,r){}getCameraX(e){return 0}getCameraY(e){return 0}setCameraX(e,r){}setCameraY(e,r){}getCameraWidth(e){return 0}getCameraHeight(e){return 0}setCameraZoom(e,r){}getCameraZoom(e){return 1}setCameraZ(e,r,t){}getCameraZ(e,r){return 0}getCameraRotation(e){return 0}setCameraRotation(e,r){}convertCoords(e,r,t,a){return this._runtimeScene.convertCoords(e,r,a||[0,0])}convertInverseCoords(e,r,t,a){return this._runtimeScene.convertInverseCoords(e,r,a||[0,0])}applyLayerInverseTransformation(e,r,t,a){return a[0]=e,a[1]=r,a}applyLayerTransformation(e,r,t,a){return a[0]=e,a[1]=r,a}}o.RuntimeCustomObjectLayer=n})(gdjs||(gdjs={}));
2
2
  //# sourceMappingURL=RuntimeCustomObjectLayer.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../GDevelop/GDJS/Runtime/RuntimeCustomObjectLayer.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 /**\n * Represents a layer of a custom object. It doesn't allow to move any camera\n * because it doesn't make sense inside an object.\n */\n export class RuntimeCustomObjectLayer extends gdjs.RuntimeLayer {\n /**\n * @param layerData The data used to initialize the layer\n * @param instanceContainer The container in which the layer is used\n */\n constructor(\n layerData: LayerData,\n instanceContainer: gdjs.RuntimeInstanceContainer\n ) {\n super(layerData, instanceContainer);\n\n // Let the renderer do its final set up:\n this._renderer.onCreated();\n }\n\n onGameResolutionResized(\n oldGameResolutionOriginX: float,\n oldGameResolutionOriginY: float\n ): void {}\n\n getCameraX(cameraId?: integer): float {\n return 0;\n }\n\n getCameraY(cameraId?: integer): float {\n return 0;\n }\n\n setCameraX(x: float, cameraId?: integer): void {}\n\n setCameraY(y: float, cameraId?: integer): void {}\n\n getCameraWidth(cameraId?: integer): float {\n return 0;\n }\n\n getCameraHeight(cameraId?: integer): float {\n return 0;\n }\n\n setCameraZoom(newZoom: float, cameraId?: integer): void {}\n\n getCameraZoom(cameraId?: integer): float {\n return 1;\n }\n\n setCameraZ(z: float, fov: float, cameraId?: integer): void {}\n\n getCameraZ(fov: float | null, cameraId?: integer): float {\n return 0;\n }\n\n getCameraRotation(cameraId?: integer): float {\n return 0;\n }\n\n setCameraRotation(rotation: float, cameraId?: integer): void {}\n\n convertCoords(\n x: float,\n y: float,\n cameraId: integer,\n result: FloatPoint\n ): FloatPoint {\n // TODO EBO use an AffineTransformation to avoid chained calls.\n // The result parameter used to be optional.\n return this._runtimeScene.convertCoords(x, y, result || [0, 0]);\n }\n\n convertInverseCoords(\n x: float,\n y: float,\n cameraId: integer,\n result: FloatPoint\n ): FloatPoint {\n // TODO EBO use an AffineTransformation to avoid chained calls.\n // The result parameter used to be optional.\n return this._runtimeScene.convertInverseCoords(x, y, result || [0, 0]);\n }\n\n applyLayerInverseTransformation(\n x: float,\n y: float,\n cameraId: integer,\n result: FloatPoint\n ): FloatPoint {\n result[0] = x;\n result[1] = y;\n return result;\n }\n\n applyLayerTransformation(\n x: float,\n y: float,\n cameraId: integer,\n result: FloatPoint\n ): FloatPoint {\n result[0] = x;\n result[1] = y;\n return result;\n }\n }\n}\n"],
5
- "mappings": "AAKA,GAAU,MAAV,UAAU,EAAV,CAKS,eAAuC,GAAK,YAAa,CAK9D,YACE,EACA,EACA,CACA,MAAM,EAAW,GAGjB,KAAK,UAAU,YAGjB,wBACE,EACA,EACM,EAER,WAAW,EAA2B,CACpC,MAAO,GAGT,WAAW,EAA2B,CACpC,MAAO,GAGT,WAAW,EAAU,EAA0B,EAE/C,WAAW,EAAU,EAA0B,EAE/C,eAAe,EAA2B,CACxC,MAAO,GAGT,gBAAgB,EAA2B,CACzC,MAAO,GAGT,cAAc,EAAgB,EAA0B,EAExD,cAAc,EAA2B,CACvC,MAAO,GAGT,WAAW,EAAU,EAAY,EAA0B,EAE3D,WAAW,EAAmB,EAA2B,CACvD,MAAO,GAGT,kBAAkB,EAA2B,CAC3C,MAAO,GAGT,kBAAkB,EAAiB,EAA0B,EAE7D,cACE,EACA,EACA,EACA,EACY,CAGZ,MAAO,MAAK,cAAc,cAAc,EAAG,EAAG,GAAU,CAAC,EAAG,IAG9D,qBACE,EACA,EACA,EACA,EACY,CAGZ,MAAO,MAAK,cAAc,qBAAqB,EAAG,EAAG,GAAU,CAAC,EAAG,IAGrE,gCACE,EACA,EACA,EACA,EACY,CACZ,SAAO,GAAK,EACZ,EAAO,GAAK,EACL,EAGT,yBACE,EACA,EACA,EACA,EACY,CACZ,SAAO,GAAK,EACZ,EAAO,GAAK,EACL,GAnGJ,EAAM,6BALL",
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 /**\n * Represents a layer of a custom object. It doesn't allow to move any camera\n * because it doesn't make sense inside an object.\n */\n export class RuntimeCustomObjectLayer extends gdjs.RuntimeLayer {\n /**\n * @param layerData The data used to initialize the layer\n * @param instanceContainer The container in which the layer is used\n */\n constructor(\n layerData: LayerData,\n instanceContainer: gdjs.RuntimeInstanceContainer\n ) {\n super(layerData, instanceContainer);\n\n // Let the renderer do its final set up:\n this._renderer.onCreated();\n }\n\n override onGameResolutionResized(\n oldGameResolutionOriginX: float,\n oldGameResolutionOriginY: float\n ): void {}\n\n override getCameraX(cameraId?: integer): float {\n return 0;\n }\n\n override getCameraY(cameraId?: integer): float {\n return 0;\n }\n\n override setCameraX(x: float, cameraId?: integer): void {}\n\n override setCameraY(y: float, cameraId?: integer): void {}\n\n override getCameraWidth(cameraId?: integer): float {\n return 0;\n }\n\n override getCameraHeight(cameraId?: integer): float {\n return 0;\n }\n\n override setCameraZoom(newZoom: float, cameraId?: integer): void {}\n\n override getCameraZoom(cameraId?: integer): float {\n return 1;\n }\n\n override setCameraZ(z: float, fov: float, cameraId?: integer): void {}\n\n override getCameraZ(fov: float | null, cameraId?: integer): float {\n return 0;\n }\n\n override getCameraRotation(cameraId?: integer): float {\n return 0;\n }\n\n override setCameraRotation(rotation: float, cameraId?: integer): void {}\n\n override convertCoords(\n x: float,\n y: float,\n cameraId: integer,\n result: FloatPoint\n ): FloatPoint {\n // TODO EBO use an AffineTransformation to avoid chained calls.\n // The result parameter used to be optional.\n return this._runtimeScene.convertCoords(x, y, result || [0, 0]);\n }\n\n override convertInverseCoords(\n x: float,\n y: float,\n cameraId: integer,\n result: FloatPoint\n ): FloatPoint {\n // TODO EBO use an AffineTransformation to avoid chained calls.\n // The result parameter used to be optional.\n return this._runtimeScene.convertInverseCoords(x, y, result || [0, 0]);\n }\n\n override applyLayerInverseTransformation(\n x: float,\n y: float,\n cameraId: integer,\n result: FloatPoint\n ): FloatPoint {\n result[0] = x;\n result[1] = y;\n return result;\n }\n\n override applyLayerTransformation(\n x: float,\n y: float,\n cameraId: integer,\n result: FloatPoint\n ): FloatPoint {\n result[0] = x;\n result[1] = y;\n return result;\n }\n }\n}\n"],
5
+ "mappings": "AAKA,GAAU,MAAV,UAAU,EAAV,CAKS,eAAuC,GAAK,YAAa,CAK9D,YACE,EACA,EACA,CACA,MAAM,EAAW,GAGjB,KAAK,UAAU,YAGR,wBACP,EACA,EACM,EAEC,WAAW,EAA2B,CAC7C,MAAO,GAGA,WAAW,EAA2B,CAC7C,MAAO,GAGA,WAAW,EAAU,EAA0B,EAE/C,WAAW,EAAU,EAA0B,EAE/C,eAAe,EAA2B,CACjD,MAAO,GAGA,gBAAgB,EAA2B,CAClD,MAAO,GAGA,cAAc,EAAgB,EAA0B,EAExD,cAAc,EAA2B,CAChD,MAAO,GAGA,WAAW,EAAU,EAAY,EAA0B,EAE3D,WAAW,EAAmB,EAA2B,CAChE,MAAO,GAGA,kBAAkB,EAA2B,CACpD,MAAO,GAGA,kBAAkB,EAAiB,EAA0B,EAE7D,cACP,EACA,EACA,EACA,EACY,CAGZ,MAAO,MAAK,cAAc,cAAc,EAAG,EAAG,GAAU,CAAC,EAAG,IAGrD,qBACP,EACA,EACA,EACA,EACY,CAGZ,MAAO,MAAK,cAAc,qBAAqB,EAAG,EAAG,GAAU,CAAC,EAAG,IAG5D,gCACP,EACA,EACA,EACA,EACY,CACZ,SAAO,GAAK,EACZ,EAAO,GAAK,EACL,EAGA,yBACP,EACA,EACA,EACA,EACY,CACZ,SAAO,GAAK,EACZ,EAAO,GAAK,EACL,GAnGJ,EAAM,6BALL",
6
6
  "names": []
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../GDevelop/GDJS/Runtime/RuntimeInstanceContainer.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('RuntimeInstanceContainer');\n\n /**\n * A container of object instances rendered on screen.\n */\n export abstract class RuntimeInstanceContainer {\n _initialBehaviorSharedData: Hashtable<BehaviorSharedData | null>;\n\n /** Contains the instances living on the container */\n _instances: Hashtable<RuntimeObject[]>;\n\n /**\n * An array used to create a list of all instance when necessary.\n * @see gdjs.RuntimeInstanceContainer#_constructListOfAllInstances}\n */\n private _allInstancesList: gdjs.RuntimeObject[] = [];\n _allInstancesListIsUpToDate = true;\n\n /** Used to recycle destroyed instance instead of creating new ones. */\n _instancesCache: Hashtable<RuntimeObject[]>;\n\n /** The instances removed from the container and waiting to be sent to the cache. */\n _instancesRemoved: gdjs.RuntimeObject[] = [];\n\n /** Contains the objects data stored in the project */\n _objects: Hashtable<ObjectData>;\n _objectsCtor: Hashtable<typeof RuntimeObject>;\n\n _layers: Hashtable<RuntimeLayer>;\n _orderedLayers: RuntimeLayer[]; // TODO: should this be a single structure with _layers, to enforce its usage?\n _layersCameraCoordinates: Record<string, [float, float, float, float]> = {};\n\n // Options for the debug draw:\n _debugDrawEnabled: boolean = false;\n _debugDrawShowHiddenInstances: boolean = false;\n _debugDrawShowPointsNames: boolean = false;\n _debugDrawShowCustomPoints: boolean = false;\n\n constructor() {\n this._initialBehaviorSharedData = new Hashtable();\n this._instances = new Hashtable();\n this._instancesCache = new Hashtable();\n this._objects = new Hashtable();\n this._objectsCtor = new Hashtable();\n this._layers = new Hashtable();\n this._orderedLayers = [];\n }\n\n /**\n * Return the time elapsed since the last frame,\n * in milliseconds, for objects on the layer.\n */\n abstract getElapsedTime(): float;\n\n /**\n * Get the renderer associated to the container.\n */\n abstract getRenderer(): gdjs.RuntimeInstanceContainerRenderer;\n\n /**\n * Get the renderer for visual debugging associated to the container.\n */\n abstract getDebuggerRenderer(): gdjs.DebuggerRenderer;\n\n /**\n * Get the {@link gdjs.RuntimeGame} associated to this.\n */\n abstract getGame(): gdjs.RuntimeGame;\n\n /**\n * Get the {@link gdjs.RuntimeScene} associated to this.\n */\n abstract getScene(): gdjs.RuntimeScene;\n\n abstract getAsyncTasksManager(): gdjs.AsyncTasksManager;\n\n /**\n * Convert a point from the canvas coordinates (for example,\n * the mouse position) to the container coordinates.\n *\n * @param x The x position, in container coordinates.\n * @param y The y position, in container coordinates.\n * @param result The point instance that is used to return the result.\n */\n abstract convertCoords(x: float, y: float, result?: FloatPoint): FloatPoint;\n\n /**\n * Convert a point from the container coordinates (for example,\n * an object position) to the canvas coordinates.\n *\n * @param sceneX The x position, in container coordinates.\n * @param sceneY The y position, in container coordinates.\n * @param result The point instance that is used to return the result.\n */\n abstract convertInverseCoords(\n sceneX: float,\n sceneY: float,\n result: FloatPoint\n ): FloatPoint;\n\n /**\n * @return the left bound of:\n * - the game resolution for a {@link gdjs.RuntimeScene}\n * - the default dimensions (the AABB of all its children) for a\n * {@link gdjs.CustomRuntimeObject}.\n */\n abstract getUnrotatedViewportMinX(): float;\n\n /**\n * @return the top bound of:\n * - the game resolution for a {@link gdjs.RuntimeScene}\n * - the default dimensions (the AABB of all its children) for a\n * {@link gdjs.CustomRuntimeObject}.\n */\n abstract getUnrotatedViewportMinY(): float;\n\n /**\n * @return the right bound of:\n * - the game resolution for a {@link gdjs.RuntimeScene}\n * - the default dimensions (the AABB of all its children) for a\n * {@link gdjs.CustomRuntimeObject}.\n */\n abstract getUnrotatedViewportMaxX(): float;\n\n /**\n * @return the bottom bound of:\n * - the game resolution for a {@link gdjs.RuntimeScene}\n * - the default dimensions (the AABB of all its children) for a\n * {@link gdjs.CustomRuntimeObject}.\n */\n abstract getUnrotatedViewportMaxY(): float;\n\n /**\n * @return the left bound of:\n * - the initial game resolution for a {@link gdjs.RuntimeScene}\n * - the initial default dimensions (inner area) set in the editor for a\n * {@link gdjs.CustomRuntimeObject}.\n */\n abstract getInitialUnrotatedViewportMinX(): float;\n\n /**\n * @return the top bound of:\n * - the initial game resolution for a {@link gdjs.RuntimeScene}\n * - the initial default dimensions (inner area) set in the editor for a\n * {@link gdjs.CustomRuntimeObject}.\n */\n abstract getInitialUnrotatedViewportMinY(): float;\n\n /**\n * @return the right bound of:\n * - the initial game resolution for a {@link gdjs.RuntimeScene}\n * - the initial default dimensions (inner area) set in the editor for a\n * {@link gdjs.CustomRuntimeObject}.\n */\n abstract getInitialUnrotatedViewportMaxX(): float;\n\n /**\n * @return the bottom bound of:\n * - the initial game resolution for a {@link gdjs.RuntimeScene}\n * - the initial default dimensions (inner area) set in the editor for a\n * {@link gdjs.CustomRuntimeObject}.\n */\n abstract getInitialUnrotatedViewportMaxY(): float;\n\n /**\n * @return the width of:\n * - the game resolution for a {@link gdjs.RuntimeScene}\n * - the default dimensions (the AABB of all its children) for a\n * {@link gdjs.CustomRuntimeObject}.\n */\n abstract getViewportWidth(): float;\n\n /**\n * @return the height of:\n * - the game resolution for a {@link gdjs.RuntimeScene}\n * - the default dimensions (the AABB of all its children) for a\n * {@link gdjs.CustomRuntimeObject}.\n */\n abstract getViewportHeight(): float;\n\n /**\n * @return the center X of:\n * - the game resolution for a {@link gdjs.RuntimeScene}\n * - the default dimensions (the AABB of all its children) for a\n * {@link gdjs.CustomRuntimeObject}.\n */\n abstract getViewportOriginX(): float;\n\n /**\n * @return the center Y of:\n * - the game resolution for a {@link gdjs.RuntimeScene}\n * - the default dimensions (the AABB of all its children) for a\n * {@link gdjs.CustomRuntimeObject}.\n */\n abstract getViewportOriginY(): float;\n\n /**\n * Triggered when the AABB of a child of the container could have changed.\n */\n abstract onChildrenLocationChanged(): void;\n\n /**\n * Activate or deactivate the debug visualization for collisions and points.\n */\n enableDebugDraw(\n enableDebugDraw: boolean,\n showHiddenInstances: boolean,\n showPointsNames: boolean,\n showCustomPoints: boolean\n ): void {\n if (this._debugDrawEnabled && !enableDebugDraw) {\n this.getDebuggerRenderer().clearDebugDraw();\n }\n\n this._debugDrawEnabled = enableDebugDraw;\n this._debugDrawShowHiddenInstances = showHiddenInstances;\n this._debugDrawShowPointsNames = showPointsNames;\n this._debugDrawShowCustomPoints = showCustomPoints;\n }\n\n /**\n * Check if an object is registered, meaning that instances of it can be\n * created and lives in the container.\n * @see gdjs.RuntimeInstanceContainer#registerObject\n */\n isObjectRegistered(objectName: string): boolean {\n return (\n this._objects.containsKey(objectName) &&\n this._instances.containsKey(objectName) &&\n this._objectsCtor.containsKey(objectName)\n );\n }\n\n /**\n * Register a {@link gdjs.RuntimeObject} so that instances of it can be\n * used in the container.\n * @param objectData The data for the object to register.\n */\n registerObject(objectData: ObjectData) {\n this._objects.put(objectData.name, objectData);\n this._instances.put(objectData.name, []);\n\n // Cache the constructor\n const Ctor = gdjs.getObjectConstructor(objectData.type);\n this._objectsCtor.put(objectData.name, Ctor);\n\n // Also prepare a cache for recycled instances, if the object supports it.\n if (Ctor.supportsReinitialization) {\n this._instancesCache.put(objectData.name, []);\n }\n }\n\n /**\n * Update the data of a {@link gdjs.RuntimeObject} so that instances use\n * this when constructed.\n * @param objectData The data for the object to register.\n */\n updateObject(objectData: ObjectData): void {\n if (!this.isObjectRegistered(objectData.name)) {\n logger.warn(\n 'Tried to call updateObject for an object that was not registered (' +\n objectData.name +\n '). Call registerObject first.'\n );\n }\n this._objects.put(objectData.name, objectData);\n }\n\n // Don't erase instances, nor instances cache, or objectsCtor cache.\n /**\n * Unregister a {@link gdjs.RuntimeObject}. Instances will be destroyed.\n * @param objectName The name of the object to unregister.\n */\n unregisterObject(objectName: string) {\n const instances = this._instances.get(objectName);\n if (instances) {\n // This is sub-optimal: markObjectForDeletion will search the instance to\n // remove in instances, so cost is O(n^2), n being the number of instances.\n // As we're unregistering an object which only happen during a hot-reloading,\n // this is fine.\n const instancesToRemove = instances.slice();\n for (let i = 0; i < instancesToRemove.length; i++) {\n this.markObjectForDeletion(instancesToRemove[i]);\n }\n this._cacheOrClearRemovedInstances();\n }\n this._objects.remove(objectName);\n this._instances.remove(objectName);\n this._instancesCache.remove(objectName);\n this._objectsCtor.remove(objectName);\n }\n\n /**\n * Create objects from initial instances data (for example, the initial instances\n * of the scene or the instances of an external layout).\n *\n * @param data The instances data\n * @param xPos The offset on X axis\n * @param yPos The offset on Y axis\n * @param zPos The offset on Z axis\n * @param trackByPersistentUuid If true, objects are tracked by setting their `persistentUuid`\n * to the same as the associated instance. Useful for hot-reloading when instances are changed.\n */\n createObjectsFrom(\n data: InstanceData[],\n xPos: float,\n yPos: float,\n zPos: float,\n trackByPersistentUuid: boolean\n ): void {\n let zOffset: number;\n let shouldTrackByPersistentUuid: boolean;\n\n if (arguments.length === 5) {\n zOffset = zPos;\n shouldTrackByPersistentUuid = trackByPersistentUuid;\n } else {\n /**\n * Support for the previous signature (before 3D was introduced):\n * createObjectsFrom(data, xPos, yPos, trackByPersistentUuid)\n */\n zOffset = 0;\n shouldTrackByPersistentUuid = arguments[3];\n }\n\n for (let i = 0, len = data.length; i < len; ++i) {\n const instanceData = data[i];\n const objectName = instanceData.name;\n const newObject = this.createObject(objectName);\n if (newObject !== null) {\n if (shouldTrackByPersistentUuid) {\n // Give the object the same persistentUuid as the instance, so that\n // it can be hot-reloaded.\n newObject.persistentUuid = instanceData.persistentUuid || null;\n }\n newObject.setPosition(instanceData.x + xPos, instanceData.y + yPos);\n newObject.setAngle(instanceData.angle);\n if (gdjs.Base3DHandler && gdjs.Base3DHandler.is3D(newObject)) {\n newObject.setZ((instanceData.z || 0) + zOffset);\n if (instanceData.rotationX !== undefined)\n newObject.setRotationX(instanceData.rotationX);\n if (instanceData.rotationY !== undefined)\n newObject.setRotationY(instanceData.rotationY);\n }\n\n newObject.setZOrder(instanceData.zOrder);\n newObject.setLayer(instanceData.layer);\n newObject\n .getVariables()\n .initFrom(instanceData.initialVariables, true);\n newObject.extraInitializationFromInitialInstance(instanceData);\n }\n }\n }\n\n /**\n * Get the data representing the initial shared data of the scene for the specified behavior.\n * @param name The name of the behavior\n * @returns The shared data for the behavior, if any.\n */\n getInitialSharedDataForBehavior(name: string): BehaviorSharedData | null {\n return this._initialBehaviorSharedData.get(name);\n }\n\n /**\n * Set the data representing the initial shared data of the scene for the specified behavior.\n * @param name The name of the behavior\n * @param sharedData The shared data for the behavior, or null to remove it.\n */\n setInitialSharedDataForBehavior(\n name: string,\n sharedData: BehaviorSharedData | null\n ): void {\n this._initialBehaviorSharedData.put(name, sharedData);\n }\n\n /**\n * Set the default Z order for each layer, which is the highest Z order found on each layer.\n * Useful as it ensures that instances created from events are, by default, shown in front\n * of other instances.\n */\n _setLayerDefaultZOrders() {\n if (\n this.getGame().getGameData().properties.useDeprecatedZeroAsDefaultZOrder\n ) {\n // Deprecated option to still support games that were made considered 0 as the\n // default Z order for all layers.\n return;\n }\n const layerHighestZOrders: Record<string, number> = {};\n const allInstances = this.getAdhocListOfAllInstances();\n for (let i = 0, len = allInstances.length; i < len; ++i) {\n const object = allInstances[i];\n let layerName = object.getLayer();\n const zOrder = object.getZOrder();\n if (\n layerHighestZOrders[layerName] === undefined ||\n layerHighestZOrders[layerName] < zOrder\n ) {\n layerHighestZOrders[layerName] = zOrder;\n }\n }\n for (let layerName in layerHighestZOrders) {\n this.getLayer(layerName).setDefaultZOrder(\n layerHighestZOrders[layerName] + 1\n );\n }\n }\n\n _updateLayersCameraCoordinates(scale: float) {\n this._layersCameraCoordinates = this._layersCameraCoordinates || {};\n for (const name in this._layers.items) {\n if (this._layers.items.hasOwnProperty(name)) {\n const theLayer = this._layers.items[name];\n this._layersCameraCoordinates[name] = this._layersCameraCoordinates[\n name\n ] || [0, 0, 0, 0];\n this._layersCameraCoordinates[name][0] =\n theLayer.getCameraX() - (theLayer.getCameraWidth() / 2) * scale;\n this._layersCameraCoordinates[name][1] =\n theLayer.getCameraY() - (theLayer.getCameraHeight() / 2) * scale;\n this._layersCameraCoordinates[name][2] =\n theLayer.getCameraX() + (theLayer.getCameraWidth() / 2) * scale;\n this._layersCameraCoordinates[name][3] =\n theLayer.getCameraY() + (theLayer.getCameraHeight() / 2) * scale;\n }\n }\n }\n\n /**\n * Called to update effects of layers before rendering.\n */\n _updateLayersPreRender() {\n for (const layer of this._orderedLayers) {\n layer.updatePreRender(this);\n }\n }\n\n /**\n * Called to update visibility of the renderers of objects\n * rendered on the scene (\"culling\"), update effects (of visible objects)\n * and give a last chance for objects to update before rendering.\n *\n * Visibility is set to false if object is hidden, or if\n * object is too far from the camera of its layer (\"culling\").\n */\n _updateObjectsPreRender() {\n const allInstancesList = this.getAdhocListOfAllInstances();\n // TODO (3D) culling - add support for 3D object culling?\n for (let i = 0, len = allInstancesList.length; i < len; ++i) {\n const object = allInstancesList[i];\n const rendererObject = object.getRendererObject();\n if (rendererObject) {\n rendererObject.visible = !object.isHidden();\n\n // Update effects, only for visible objects.\n if (rendererObject.visible) {\n this.getGame()\n .getEffectsManager()\n .updatePreRender(object.getRendererEffects(), object);\n }\n }\n\n // Perform pre-render update.\n object.updatePreRender(this);\n }\n return;\n }\n\n /**\n * Empty the list of the removed objects:\n *\n * When an object is removed from the container, it is still kept in\n * {@link gdjs.RuntimeInstanceContainer#_instancesRemoved}.\n *\n * This method should be called regularly (after events or behaviors steps) so as to clear this list\n * and allows the removed objects to be cached (or destroyed if the cache is full).\n *\n * The removed objects could not be sent directly to the cache, as events may still be using them after\n * removing them from the scene for example.\n */\n _cacheOrClearRemovedInstances() {\n for (let k = 0, lenk = this._instancesRemoved.length; k < lenk; ++k) {\n const instance = this._instancesRemoved[k];\n // Cache the instance to recycle it into a new instance later.\n // If the object does not support recycling, the cache won't be defined.\n const cache = this._instancesCache.get(instance.getName());\n if (cache) {\n if (cache.length < 128) {\n cache.push(instance);\n }\n }\n instance.onDestroyed();\n }\n this._instancesRemoved.length = 0;\n }\n\n /**\n * Tool function filling _allInstancesList member with all the living object instances.\n */\n private _constructListOfAllInstances() {\n let currentListSize = 0;\n for (const name in this._instances.items) {\n if (this._instances.items.hasOwnProperty(name)) {\n const list = this._instances.items[name];\n const oldSize = currentListSize;\n currentListSize += list.length;\n for (let j = 0, lenj = list.length; j < lenj; ++j) {\n if (oldSize + j < this._allInstancesList.length) {\n this._allInstancesList[oldSize + j] = list[j];\n } else {\n this._allInstancesList.push(list[j]);\n }\n }\n }\n }\n this._allInstancesList.length = currentListSize;\n this._allInstancesListIsUpToDate = true;\n }\n\n /**\n * @param objectName The name of the object\n * @returns the instances of a given object in the container.\n */\n getInstancesOf(objectName: string): gdjs.RuntimeObject[] {\n return this._instances.items[objectName];\n }\n\n /**\n * Get a list of all {@link gdjs.RuntimeObject} living in the container.\n * You should not, normally, need this method at all. It's only to be used\n * in exceptional use cases where you need to loop through all objects,\n * and it won't be performant.\n *\n * @returns The list of all runtime objects in the container\n */\n getAdhocListOfAllInstances(): gdjs.RuntimeObject[] {\n if (!this._allInstancesListIsUpToDate) {\n this._constructListOfAllInstances();\n }\n return this._allInstancesList;\n }\n\n /**\n * Update the objects before launching the events.\n */\n _updateObjectsPreEvents() {\n // It is *mandatory* to create and iterate on a external list of all objects, as the behaviors\n // may delete the objects.\n const allInstancesList = this.getAdhocListOfAllInstances();\n for (let i = 0, len = allInstancesList.length; i < len; ++i) {\n const obj = allInstancesList[i];\n const elapsedTime = obj.getElapsedTime();\n if (!obj.hasNoForces()) {\n const averageForce = obj.getAverageForce();\n const elapsedTimeInSeconds = elapsedTime / 1000;\n obj.setX(obj.getX() + averageForce.getX() * elapsedTimeInSeconds);\n obj.setY(obj.getY() + averageForce.getY() * elapsedTimeInSeconds);\n obj.update(this);\n obj.updateForces(elapsedTimeInSeconds);\n } else {\n obj.update(this);\n }\n obj.updateTimers(elapsedTime);\n allInstancesList[i].stepBehaviorsPreEvents(this);\n }\n\n // Some behaviors may have request objects to be deleted.\n this._cacheOrClearRemovedInstances();\n }\n\n /**\n * Update the objects (update positions, time management...)\n */\n _updateObjectsPostEvents() {\n this._cacheOrClearRemovedInstances();\n\n // It is *mandatory* to create and iterate on a external list of all objects, as the behaviors\n // may delete the objects.\n const allInstancesList = this.getAdhocListOfAllInstances();\n for (let i = 0, len = allInstancesList.length; i < len; ++i) {\n allInstancesList[i].stepBehaviorsPostEvents(this);\n }\n\n // Some behaviors may have request objects to be deleted.\n this._cacheOrClearRemovedInstances();\n }\n\n /**\n * Add an object to the instances living in the container.\n * @param obj The object to be added.\n */\n addObject(obj: gdjs.RuntimeObject) {\n if (!this._instances.containsKey(obj.name)) {\n this._instances.put(obj.name, []);\n }\n this._instances.get(obj.name).push(obj);\n this._allInstancesListIsUpToDate = false;\n }\n\n /**\n * Get all the instances of the object called name.\n * @param name Name of the object for which the instances must be returned.\n * @return The list of objects with the given name\n */\n getObjects(name: string): gdjs.RuntimeObject[] | undefined {\n if (!this._instances.containsKey(name)) {\n logger.info(\n 'RuntimeScene.getObjects: No instances called \"' +\n name +\n '\"! Adding it.'\n );\n this._instances.put(name, []);\n }\n return this._instances.get(name);\n }\n\n /**\n * Create a new object from its name. The object is also added to the instances\n * living in the container (No need to call {@link gdjs.RuntimeScene.addObject})\n * @param objectName The name of the object to be created\n * @return The created object\n */\n createObject(objectName: string): gdjs.RuntimeObject | null {\n if (\n !this._objectsCtor.containsKey(objectName) ||\n !this._objects.containsKey(objectName)\n ) {\n // There is no such object in this container.\n return null;\n }\n\n // Create a new object using the object constructor (cached during loading)\n // and the stored object's data:\n const cache = this._instancesCache.get(objectName);\n const ctor = this._objectsCtor.get(objectName);\n let obj;\n if (!cache || cache.length === 0) {\n obj = new ctor(this, this._objects.get(objectName));\n } else {\n // Reuse an objet destroyed before. If there is an object in the cache,\n // then it means it does support reinitialization.\n obj = cache.pop();\n obj.reinitialize(this._objects.get(objectName));\n }\n this.addObject(obj);\n return obj;\n }\n\n /**\n * Must be called whenever an object must be removed from the container.\n * @param obj The object to be removed.\n */\n markObjectForDeletion(obj: gdjs.RuntimeObject) {\n // Add to the objects removed list.\n // The objects will be sent to the instances cache or really deleted from memory later.\n if (this._instancesRemoved.indexOf(obj) === -1) {\n this._instancesRemoved.push(obj);\n }\n\n // Delete from the living instances.\n if (this._instances.containsKey(obj.getName())) {\n const objId = obj.id;\n const allInstances = this._instances.get(obj.getName());\n for (let i = 0, len = allInstances.length; i < len; ++i) {\n if (allInstances[i].id == objId) {\n allInstances.splice(i, 1);\n this._allInstancesListIsUpToDate = false;\n break;\n }\n }\n }\n\n // Notify the object it was removed from the container\n obj.onDeletedFromScene(this);\n\n // Notify the global callbacks\n for (let j = 0; j < gdjs.callbacksObjectDeletedFromScene.length; ++j) {\n gdjs.callbacksObjectDeletedFromScene[j](this, obj);\n }\n return;\n }\n\n /**\n * Get the layer with the given name\n * @param name The name of the layer\n * @returns The layer, or the base layer if not found\n */\n getLayer(name: string): gdjs.RuntimeLayer {\n if (this._layers.containsKey(name)) {\n return this._layers.get(name);\n }\n return this._layers.get('');\n }\n\n /**\n * Check if a layer exists\n * @param name The name of the layer\n */\n hasLayer(name: string): boolean {\n return this._layers.containsKey(name);\n }\n\n /**\n * Add a layer.\n * @param layerData The data to construct the layer\n */\n abstract addLayer(layerData: LayerData);\n\n /**\n * Remove a layer. All {@link gdjs.RuntimeObject} on this layer will\n * be moved back to the base layer.\n * @param layerName The name of the layer to remove\n */\n removeLayer(layerName: string) {\n const existingLayer = this._layers.get(layerName);\n if (!existingLayer) return;\n\n const allInstances = this.getAdhocListOfAllInstances();\n for (let i = 0; i < allInstances.length; ++i) {\n const runtimeObject = allInstances[i];\n if (runtimeObject.getLayer() === layerName) {\n runtimeObject.setLayer('');\n }\n }\n this._layers.remove(layerName);\n const layerIndex = this._orderedLayers.indexOf(existingLayer);\n this._orderedLayers.splice(layerIndex, 1);\n }\n\n /**\n * Change the position of a layer.\n *\n * @param layerName The name of the layer to reorder\n * @param index The new position in the list of layers\n */\n setLayerIndex(layerName: string, newIndex: integer): void {\n const layer: gdjs.RuntimeLayer = this._layers.get(layerName);\n if (!layer) {\n return;\n }\n const layerIndex = this._orderedLayers.indexOf(layer);\n if (layerIndex === newIndex) return;\n\n this._orderedLayers.splice(layerIndex, 1);\n this._orderedLayers.splice(newIndex, 0, layer);\n\n this.getRenderer().setLayerIndex(layer, newIndex);\n }\n\n /**\n * Fill the array passed as argument with the names of all layers\n * @param result The array where to put the layer names\n */\n getAllLayerNames(result: string[]) {\n this._layers.keys(result);\n }\n\n /**\n * Return the number of instances of the specified object living in the container.\n * @param objectName The object name for which instances must be counted.\n */\n getInstancesCountOnScene(objectName: string): integer {\n const instances = this._instances.get(objectName);\n if (instances) {\n return instances.length;\n }\n\n return 0;\n }\n\n /**\n * Update the objects positions according to their forces\n */\n updateObjectsForces(): void {\n for (const name in this._instances.items) {\n if (this._instances.items.hasOwnProperty(name)) {\n const list = this._instances.items[name];\n for (let j = 0, listLen = list.length; j < listLen; ++j) {\n const obj = list[j];\n if (!obj.hasNoForces()) {\n const averageForce = obj.getAverageForce();\n const elapsedTimeInSeconds = obj.getElapsedTime() / 1000;\n obj.setX(obj.getX() + averageForce.getX() * elapsedTimeInSeconds);\n obj.setY(obj.getY() + averageForce.getY() * elapsedTimeInSeconds);\n obj.updateForces(elapsedTimeInSeconds);\n }\n }\n }\n }\n }\n\n /**\n * Clear any data structures to make sure memory is freed as soon as\n * possible.\n */\n _destroy() {\n // It should not be necessary to reset these variables, but this help\n // ensuring that all memory related to the container is released immediately.\n this._layers = new Hashtable();\n this._orderedLayers = [];\n this._objects = new Hashtable();\n this._instances = new Hashtable();\n this._instancesCache = new Hashtable();\n this._objectsCtor = new Hashtable();\n this._allInstancesList = [];\n this._instancesRemoved = [];\n }\n }\n}\n"],
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('RuntimeInstanceContainer');\n\n /**\n * A container of object instances rendered on screen.\n */\n export abstract class RuntimeInstanceContainer {\n _initialBehaviorSharedData: Hashtable<BehaviorSharedData | null>;\n\n /** Contains the instances living on the container */\n _instances: Hashtable<RuntimeObject[]>;\n\n /**\n * An array used to create a list of all instance when necessary.\n * @see gdjs.RuntimeInstanceContainer#_constructListOfAllInstances}\n */\n private _allInstancesList: gdjs.RuntimeObject[] = [];\n _allInstancesListIsUpToDate = true;\n\n /** Used to recycle destroyed instance instead of creating new ones. */\n _instancesCache: Hashtable<RuntimeObject[]>;\n\n /** The instances removed from the container and waiting to be sent to the cache. */\n _instancesRemoved: gdjs.RuntimeObject[] = [];\n\n /** Contains the objects data stored in the project */\n _objects: Hashtable<ObjectData>;\n _objectsCtor: Hashtable<typeof RuntimeObject>;\n\n _layers: Hashtable<RuntimeLayer>;\n _orderedLayers: RuntimeLayer[]; // TODO: should this be a single structure with _layers, to enforce its usage?\n _layersCameraCoordinates: Record<string, [float, float, float, float]> = {};\n\n // Options for the debug draw:\n _debugDrawEnabled: boolean = false;\n _debugDrawShowHiddenInstances: boolean = false;\n _debugDrawShowPointsNames: boolean = false;\n _debugDrawShowCustomPoints: boolean = false;\n\n constructor() {\n this._initialBehaviorSharedData = new Hashtable();\n this._instances = new Hashtable();\n this._instancesCache = new Hashtable();\n this._objects = new Hashtable();\n this._objectsCtor = new Hashtable();\n this._layers = new Hashtable();\n this._orderedLayers = [];\n }\n\n /**\n * Return the time elapsed since the last frame,\n * in milliseconds, for objects on the layer.\n */\n abstract getElapsedTime(): float;\n\n /**\n * Get the renderer associated to the container.\n */\n abstract getRenderer(): gdjs.RuntimeInstanceContainerRenderer;\n\n /**\n * Get the renderer for visual debugging associated to the container.\n */\n abstract getDebuggerRenderer(): gdjs.DebuggerRenderer;\n\n /**\n * Get the {@link gdjs.RuntimeGame} associated to this.\n */\n abstract getGame(): gdjs.RuntimeGame;\n\n /**\n * Get the {@link gdjs.RuntimeScene} associated to this.\n */\n abstract getScene(): gdjs.RuntimeScene;\n\n abstract getAsyncTasksManager(): gdjs.AsyncTasksManager;\n\n /**\n * Convert a point from the canvas coordinates (for example,\n * the mouse position) to the container coordinates.\n *\n * @param x The x position, in container coordinates.\n * @param y The y position, in container coordinates.\n * @param result The point instance that is used to return the result.\n */\n abstract convertCoords(x: float, y: float, result?: FloatPoint): FloatPoint;\n\n /**\n * Convert a point from the container coordinates (for example,\n * an object position) to the canvas coordinates.\n *\n * @param sceneX The x position, in container coordinates.\n * @param sceneY The y position, in container coordinates.\n * @param result The point instance that is used to return the result.\n */\n abstract convertInverseCoords(\n sceneX: float,\n sceneY: float,\n result: FloatPoint\n ): FloatPoint;\n\n /**\n * @return the left bound of:\n * - the game resolution for a {@link gdjs.RuntimeScene}\n * - the default dimensions (the AABB of all its children) for a\n * {@link gdjs.CustomRuntimeObject}.\n */\n abstract getUnrotatedViewportMinX(): float;\n\n /**\n * @return the top bound of:\n * - the game resolution for a {@link gdjs.RuntimeScene}\n * - the default dimensions (the AABB of all its children) for a\n * {@link gdjs.CustomRuntimeObject}.\n */\n abstract getUnrotatedViewportMinY(): float;\n\n /**\n * @return the right bound of:\n * - the game resolution for a {@link gdjs.RuntimeScene}\n * - the default dimensions (the AABB of all its children) for a\n * {@link gdjs.CustomRuntimeObject}.\n */\n abstract getUnrotatedViewportMaxX(): float;\n\n /**\n * @return the bottom bound of:\n * - the game resolution for a {@link gdjs.RuntimeScene}\n * - the default dimensions (the AABB of all its children) for a\n * {@link gdjs.CustomRuntimeObject}.\n */\n abstract getUnrotatedViewportMaxY(): float;\n\n /**\n * @return the left bound of:\n * - the initial game resolution for a {@link gdjs.RuntimeScene}\n * - the initial default dimensions (inner area) set in the editor for a\n * {@link gdjs.CustomRuntimeObject}.\n */\n abstract getInitialUnrotatedViewportMinX(): float;\n\n /**\n * @return the top bound of:\n * - the initial game resolution for a {@link gdjs.RuntimeScene}\n * - the initial default dimensions (inner area) set in the editor for a\n * {@link gdjs.CustomRuntimeObject}.\n */\n abstract getInitialUnrotatedViewportMinY(): float;\n\n /**\n * @return the right bound of:\n * - the initial game resolution for a {@link gdjs.RuntimeScene}\n * - the initial default dimensions (inner area) set in the editor for a\n * {@link gdjs.CustomRuntimeObject}.\n */\n abstract getInitialUnrotatedViewportMaxX(): float;\n\n /**\n * @return the bottom bound of:\n * - the initial game resolution for a {@link gdjs.RuntimeScene}\n * - the initial default dimensions (inner area) set in the editor for a\n * {@link gdjs.CustomRuntimeObject}.\n */\n abstract getInitialUnrotatedViewportMaxY(): float;\n\n /**\n * @return the width of:\n * - the game resolution for a {@link gdjs.RuntimeScene}\n * - the default dimensions (the AABB of all its children) for a\n * {@link gdjs.CustomRuntimeObject}.\n */\n abstract getViewportWidth(): float;\n\n /**\n * @return the height of:\n * - the game resolution for a {@link gdjs.RuntimeScene}\n * - the default dimensions (the AABB of all its children) for a\n * {@link gdjs.CustomRuntimeObject}.\n */\n abstract getViewportHeight(): float;\n\n /**\n * @return the center X of:\n * - the game resolution for a {@link gdjs.RuntimeScene}\n * - the default dimensions (the AABB of all its children) for a\n * {@link gdjs.CustomRuntimeObject}.\n */\n abstract getViewportOriginX(): float;\n\n /**\n * @return the center Y of:\n * - the game resolution for a {@link gdjs.RuntimeScene}\n * - the default dimensions (the AABB of all its children) for a\n * {@link gdjs.CustomRuntimeObject}.\n */\n abstract getViewportOriginY(): float;\n\n /**\n * Triggered when the AABB of a child of the container could have changed.\n */\n abstract onChildrenLocationChanged(): void;\n\n /**\n * Activate or deactivate the debug visualization for collisions and points.\n */\n enableDebugDraw(\n enableDebugDraw: boolean,\n showHiddenInstances: boolean,\n showPointsNames: boolean,\n showCustomPoints: boolean\n ): void {\n if (this._debugDrawEnabled && !enableDebugDraw) {\n this.getDebuggerRenderer().clearDebugDraw();\n }\n\n this._debugDrawEnabled = enableDebugDraw;\n this._debugDrawShowHiddenInstances = showHiddenInstances;\n this._debugDrawShowPointsNames = showPointsNames;\n this._debugDrawShowCustomPoints = showCustomPoints;\n }\n\n /**\n * Check if an object is registered, meaning that instances of it can be\n * created and lives in the container.\n * @see gdjs.RuntimeInstanceContainer#registerObject\n */\n isObjectRegistered(objectName: string): boolean {\n return (\n this._objects.containsKey(objectName) &&\n this._instances.containsKey(objectName) &&\n this._objectsCtor.containsKey(objectName)\n );\n }\n\n /**\n * Register a {@link gdjs.RuntimeObject} so that instances of it can be\n * used in the container.\n * @param objectData The data for the object to register.\n */\n registerObject(objectData: ObjectData) {\n this._objects.put(objectData.name, objectData);\n this._instances.put(objectData.name, []);\n\n // Cache the constructor\n const Ctor = gdjs.getObjectConstructor(objectData.type);\n this._objectsCtor.put(objectData.name, Ctor);\n\n // Also prepare a cache for recycled instances, if the object supports it.\n if (Ctor.supportsReinitialization) {\n this._instancesCache.put(objectData.name, []);\n }\n }\n\n /**\n * Update the data of a {@link gdjs.RuntimeObject} so that instances use\n * this when constructed.\n * @param objectData The data for the object to register.\n */\n updateObject(objectData: ObjectData): void {\n if (!this.isObjectRegistered(objectData.name)) {\n logger.warn(\n 'Tried to call updateObject for an object that was not registered (' +\n objectData.name +\n '). Call registerObject first.'\n );\n }\n this._objects.put(objectData.name, objectData);\n }\n\n // Don't erase instances, nor instances cache, or objectsCtor cache.\n /**\n * Unregister a {@link gdjs.RuntimeObject}. Instances will be destroyed.\n * @param objectName The name of the object to unregister.\n */\n unregisterObject(objectName: string) {\n const instances = this._instances.get(objectName);\n if (instances) {\n // This is sub-optimal: markObjectForDeletion will search the instance to\n // remove in instances, so cost is O(n^2), n being the number of instances.\n // As we're unregistering an object which only happen during a hot-reloading,\n // this is fine.\n const instancesToRemove = instances.slice();\n for (let i = 0; i < instancesToRemove.length; i++) {\n this.markObjectForDeletion(instancesToRemove[i]);\n }\n this._cacheOrClearRemovedInstances();\n }\n this._objects.remove(objectName);\n this._instances.remove(objectName);\n this._instancesCache.remove(objectName);\n this._objectsCtor.remove(objectName);\n }\n\n /**\n * Create objects from initial instances data (for example, the initial instances\n * of the scene or the instances of an external layout).\n *\n * @param data The instances data\n * @param xPos The offset on X axis\n * @param yPos The offset on Y axis\n * @param zPos The offset on Z axis\n * @param trackByPersistentUuid If true, objects are tracked by setting their `persistentUuid`\n * to the same as the associated instance. Useful for hot-reloading when instances are changed.\n */\n createObjectsFrom(\n data: InstanceData[],\n xPos: float,\n yPos: float,\n zPos: float,\n trackByPersistentUuid: boolean\n ): void {\n let zOffset: number;\n let shouldTrackByPersistentUuid: boolean;\n\n if (arguments.length === 5) {\n zOffset = zPos;\n shouldTrackByPersistentUuid = trackByPersistentUuid;\n } else {\n /**\n * Support for the previous signature (before 3D was introduced):\n * createObjectsFrom(data, xPos, yPos, trackByPersistentUuid)\n */\n zOffset = 0;\n shouldTrackByPersistentUuid = arguments[3];\n }\n\n for (let i = 0, len = data.length; i < len; ++i) {\n const instanceData = data[i];\n const objectName = instanceData.name;\n const newObject = this.createObject(objectName);\n if (newObject !== null) {\n if (shouldTrackByPersistentUuid) {\n // Give the object the same persistentUuid as the instance, so that\n // it can be hot-reloaded.\n newObject.persistentUuid = instanceData.persistentUuid || null;\n }\n newObject.setPosition(instanceData.x + xPos, instanceData.y + yPos);\n newObject.setAngle(instanceData.angle);\n if (gdjs.Base3DHandler && gdjs.Base3DHandler.is3D(newObject)) {\n newObject.setZ((instanceData.z || 0) + zOffset);\n if (instanceData.rotationX !== undefined)\n newObject.setRotationX(instanceData.rotationX);\n if (instanceData.rotationY !== undefined)\n newObject.setRotationY(instanceData.rotationY);\n }\n\n newObject.setZOrder(instanceData.zOrder);\n newObject.setLayer(instanceData.layer);\n newObject\n .getVariables()\n .initFrom(instanceData.initialVariables, true);\n newObject.extraInitializationFromInitialInstance(instanceData);\n }\n }\n }\n\n /**\n * Get the data representing the initial shared data of the scene for the specified behavior.\n * @param name The name of the behavior\n * @returns The shared data for the behavior, if any.\n */\n getInitialSharedDataForBehavior(name: string): BehaviorSharedData | null {\n return this._initialBehaviorSharedData.get(name);\n }\n\n /**\n * Set the data representing the initial shared data of the scene for the specified behavior.\n * @param name The name of the behavior\n * @param sharedData The shared data for the behavior, or null to remove it.\n */\n setInitialSharedDataForBehavior(\n name: string,\n sharedData: BehaviorSharedData | null\n ): void {\n this._initialBehaviorSharedData.put(name, sharedData);\n }\n\n /**\n * Set the default Z order for each layer, which is the highest Z order found on each layer.\n * Useful as it ensures that instances created from events are, by default, shown in front\n * of other instances.\n */\n _setLayerDefaultZOrders() {\n if (\n this.getGame().getGameData().properties.useDeprecatedZeroAsDefaultZOrder\n ) {\n // Deprecated option to still support games that were made considered 0 as the\n // default Z order for all layers.\n return;\n }\n const layerHighestZOrders: Record<string, number> = {};\n const allInstances = this.getAdhocListOfAllInstances();\n for (let i = 0, len = allInstances.length; i < len; ++i) {\n const object = allInstances[i];\n let layerName = object.getLayer();\n const zOrder = object.getZOrder();\n if (\n layerHighestZOrders[layerName] === undefined ||\n layerHighestZOrders[layerName] < zOrder\n ) {\n layerHighestZOrders[layerName] = zOrder;\n }\n }\n for (let layerName in layerHighestZOrders) {\n this.getLayer(layerName).setDefaultZOrder(\n layerHighestZOrders[layerName] + 1\n );\n }\n }\n\n _updateLayersCameraCoordinates(scale: float) {\n this._layersCameraCoordinates = this._layersCameraCoordinates || {};\n for (const name in this._layers.items) {\n if (this._layers.items.hasOwnProperty(name)) {\n const theLayer = this._layers.items[name];\n this._layersCameraCoordinates[name] = this._layersCameraCoordinates[\n name\n ] || [0, 0, 0, 0];\n this._layersCameraCoordinates[name][0] =\n theLayer.getCameraX() - (theLayer.getCameraWidth() / 2) * scale;\n this._layersCameraCoordinates[name][1] =\n theLayer.getCameraY() - (theLayer.getCameraHeight() / 2) * scale;\n this._layersCameraCoordinates[name][2] =\n theLayer.getCameraX() + (theLayer.getCameraWidth() / 2) * scale;\n this._layersCameraCoordinates[name][3] =\n theLayer.getCameraY() + (theLayer.getCameraHeight() / 2) * scale;\n }\n }\n }\n\n /**\n * Called to update effects of layers before rendering.\n */\n _updateLayersPreRender() {\n for (const layer of this._orderedLayers) {\n layer.updatePreRender(this);\n }\n }\n\n /**\n * Called to update visibility of the renderers of objects\n * rendered on the scene (\"culling\"), update effects (of visible objects)\n * and give a last chance for objects to update before rendering.\n *\n * Visibility is set to false if object is hidden, or if\n * object is too far from the camera of its layer (\"culling\").\n */\n _updateObjectsPreRender() {\n const allInstancesList = this.getAdhocListOfAllInstances();\n // TODO (3D) culling - add support for 3D object culling?\n for (let i = 0, len = allInstancesList.length; i < len; ++i) {\n const object = allInstancesList[i];\n const rendererObject = object.getRendererObject();\n if (rendererObject) {\n rendererObject.visible = !object.isHidden();\n\n // Update effects, only for visible objects.\n if (rendererObject.visible) {\n this.getGame()\n .getEffectsManager()\n .updatePreRender(object.getRendererEffects(), object);\n }\n }\n\n // Perform pre-render update.\n object.updatePreRender(this);\n }\n return;\n }\n\n /**\n * Empty the list of the removed objects:\n *\n * When an object is removed from the container, it is still kept in\n * {@link gdjs.RuntimeInstanceContainer#_instancesRemoved}.\n *\n * This method should be called regularly (after events or behaviors steps) so as to clear this list\n * and allows the removed objects to be cached (or destroyed if the cache is full).\n *\n * The removed objects could not be sent directly to the cache, as events may still be using them after\n * removing them from the scene for example.\n */\n _cacheOrClearRemovedInstances() {\n for (let k = 0, lenk = this._instancesRemoved.length; k < lenk; ++k) {\n const instance = this._instancesRemoved[k];\n // Cache the instance to recycle it into a new instance later.\n // If the object does not support recycling, the cache won't be defined.\n const cache = this._instancesCache.get(instance.getName());\n if (cache) {\n if (cache.length < 128) {\n cache.push(instance);\n }\n }\n instance.onDestroyed();\n }\n this._instancesRemoved.length = 0;\n }\n\n /**\n * Tool function filling _allInstancesList member with all the living object instances.\n */\n private _constructListOfAllInstances() {\n let currentListSize = 0;\n for (const name in this._instances.items) {\n if (this._instances.items.hasOwnProperty(name)) {\n const list = this._instances.items[name];\n const oldSize = currentListSize;\n currentListSize += list.length;\n for (let j = 0, lenj = list.length; j < lenj; ++j) {\n if (oldSize + j < this._allInstancesList.length) {\n this._allInstancesList[oldSize + j] = list[j];\n } else {\n this._allInstancesList.push(list[j]);\n }\n }\n }\n }\n this._allInstancesList.length = currentListSize;\n this._allInstancesListIsUpToDate = true;\n }\n\n /**\n * @param objectName The name of the object\n * @returns the instances of a given object in the container.\n */\n getInstancesOf(objectName: string): gdjs.RuntimeObject[] {\n return this._instances.items[objectName];\n }\n\n /**\n * Get a list of all {@link gdjs.RuntimeObject} living in the container.\n * You should not, normally, need this method at all. It's only to be used\n * in exceptional use cases where you need to loop through all objects,\n * and it won't be performant.\n *\n * @returns The list of all runtime objects in the container\n */\n getAdhocListOfAllInstances(): gdjs.RuntimeObject[] {\n if (!this._allInstancesListIsUpToDate) {\n this._constructListOfAllInstances();\n }\n return this._allInstancesList;\n }\n\n /**\n * Update the objects before launching the events.\n */\n _updateObjectsPreEvents() {\n // It is *mandatory* to create and iterate on a external list of all objects, as the behaviors\n // may delete the objects.\n const allInstancesList = this.getAdhocListOfAllInstances();\n for (let i = 0, len = allInstancesList.length; i < len; ++i) {\n const obj = allInstancesList[i];\n const elapsedTime = obj.getElapsedTime();\n if (!obj.hasNoForces()) {\n const averageForce = obj.getAverageForce();\n const elapsedTimeInSeconds = elapsedTime / 1000;\n obj.setX(obj.getX() + averageForce.getX() * elapsedTimeInSeconds);\n obj.setY(obj.getY() + averageForce.getY() * elapsedTimeInSeconds);\n obj.update(this);\n obj.updateForces(elapsedTimeInSeconds);\n } else {\n obj.update(this);\n }\n obj.updateTimers(elapsedTime);\n allInstancesList[i].stepBehaviorsPreEvents(this);\n }\n\n // Some behaviors may have request objects to be deleted.\n this._cacheOrClearRemovedInstances();\n }\n\n /**\n * Update the objects (update positions, time management...)\n */\n _updateObjectsPostEvents() {\n this._cacheOrClearRemovedInstances();\n\n // It is *mandatory* to create and iterate on a external list of all objects, as the behaviors\n // may delete the objects.\n const allInstancesList = this.getAdhocListOfAllInstances();\n for (let i = 0, len = allInstancesList.length; i < len; ++i) {\n allInstancesList[i].stepBehaviorsPostEvents(this);\n }\n\n // Some behaviors may have request objects to be deleted.\n this._cacheOrClearRemovedInstances();\n }\n\n /**\n * Add an object to the instances living in the container.\n * @param obj The object to be added.\n */\n addObject(obj: gdjs.RuntimeObject) {\n if (!this._instances.containsKey(obj.name)) {\n this._instances.put(obj.name, []);\n }\n this._instances.get(obj.name).push(obj);\n this._allInstancesListIsUpToDate = false;\n }\n\n /**\n * Get all the instances of the object called name.\n * @param name Name of the object for which the instances must be returned.\n * @return The list of objects with the given name\n */\n getObjects(name: string): gdjs.RuntimeObject[] | undefined {\n if (!this._instances.containsKey(name)) {\n logger.info(\n 'RuntimeScene.getObjects: No instances called \"' +\n name +\n '\"! Adding it.'\n );\n this._instances.put(name, []);\n }\n return this._instances.get(name);\n }\n\n /**\n * Create a new object from its name. The object is also added to the instances\n * living in the container (No need to call {@link gdjs.RuntimeScene.addObject})\n * @param objectName The name of the object to be created\n * @return The created object\n */\n createObject(objectName: string): gdjs.RuntimeObject | null {\n if (\n !this._objectsCtor.containsKey(objectName) ||\n !this._objects.containsKey(objectName)\n ) {\n // There is no such object in this container.\n return null;\n }\n\n // Create a new object using the object constructor (cached during loading)\n // and the stored object's data:\n const cache = this._instancesCache.get(objectName);\n const ctor = this._objectsCtor.get(objectName);\n let obj;\n if (!cache || cache.length === 0) {\n obj = new ctor(this, this._objects.get(objectName));\n } else {\n // Reuse an objet destroyed before. If there is an object in the cache,\n // then it means it does support reinitialization.\n obj = cache.pop();\n obj.reinitialize(this._objects.get(objectName));\n }\n this.addObject(obj);\n return obj;\n }\n\n /**\n * Must be called whenever an object must be removed from the container.\n * @param obj The object to be removed.\n */\n markObjectForDeletion(obj: gdjs.RuntimeObject) {\n // Add to the objects removed list.\n // The objects will be sent to the instances cache or really deleted from memory later.\n if (this._instancesRemoved.indexOf(obj) === -1) {\n this._instancesRemoved.push(obj);\n }\n\n // Delete from the living instances.\n if (this._instances.containsKey(obj.getName())) {\n const objId = obj.id;\n const allInstances = this._instances.get(obj.getName());\n for (let i = 0, len = allInstances.length; i < len; ++i) {\n if (allInstances[i].id == objId) {\n allInstances.splice(i, 1);\n this._allInstancesListIsUpToDate = false;\n break;\n }\n }\n }\n\n // Notify the object it was removed from the container\n obj.onDeletedFromScene(this);\n\n // Notify the global callbacks\n for (let j = 0; j < gdjs.callbacksObjectDeletedFromScene.length; ++j) {\n gdjs.callbacksObjectDeletedFromScene[j](this, obj);\n }\n return;\n }\n\n /**\n * Get the layer with the given name\n * @param name The name of the layer\n * @returns The layer, or the base layer if not found\n */\n getLayer(name: string): gdjs.RuntimeLayer {\n if (this._layers.containsKey(name)) {\n return this._layers.get(name);\n }\n return this._layers.get('');\n }\n\n /**\n * Check if a layer exists\n * @param name The name of the layer\n */\n hasLayer(name: string): boolean {\n return this._layers.containsKey(name);\n }\n\n /**\n * Add a layer.\n * @param layerData The data to construct the layer\n */\n abstract addLayer(layerData: LayerData);\n\n /**\n * Remove a layer. All {@link gdjs.RuntimeObject} on this layer will\n * be moved back to the base layer.\n * @param layerName The name of the layer to remove\n */\n removeLayer(layerName: string) {\n const existingLayer = this._layers.get(layerName);\n if (!existingLayer) return;\n\n const allInstances = this.getAdhocListOfAllInstances();\n for (let i = 0; i < allInstances.length; ++i) {\n const runtimeObject = allInstances[i];\n if (runtimeObject.getLayer() === layerName) {\n runtimeObject.setLayer('');\n }\n }\n this._layers.remove(layerName);\n const layerIndex = this._orderedLayers.indexOf(existingLayer);\n this._orderedLayers.splice(layerIndex, 1);\n }\n\n /**\n * Change the position of a layer.\n *\n * @param layerName The name of the layer to reorder\n * @param newIndex The new position in the list of layers\n */\n setLayerIndex(layerName: string, newIndex: integer): void {\n const layer: gdjs.RuntimeLayer = this._layers.get(layerName);\n if (!layer) {\n return;\n }\n const layerIndex = this._orderedLayers.indexOf(layer);\n if (layerIndex === newIndex) return;\n\n this._orderedLayers.splice(layerIndex, 1);\n this._orderedLayers.splice(newIndex, 0, layer);\n\n this.getRenderer().setLayerIndex(layer, newIndex);\n }\n\n /**\n * Fill the array passed as argument with the names of all layers\n * @param result The array where to put the layer names\n */\n getAllLayerNames(result: string[]) {\n this._layers.keys(result);\n }\n\n /**\n * Return the number of instances of the specified object living in the container.\n * @param objectName The object name for which instances must be counted.\n */\n getInstancesCountOnScene(objectName: string): integer {\n const instances = this._instances.get(objectName);\n if (instances) {\n return instances.length;\n }\n\n return 0;\n }\n\n /**\n * Update the objects positions according to their forces\n */\n updateObjectsForces(): void {\n for (const name in this._instances.items) {\n if (this._instances.items.hasOwnProperty(name)) {\n const list = this._instances.items[name];\n for (let j = 0, listLen = list.length; j < listLen; ++j) {\n const obj = list[j];\n if (!obj.hasNoForces()) {\n const averageForce = obj.getAverageForce();\n const elapsedTimeInSeconds = obj.getElapsedTime() / 1000;\n obj.setX(obj.getX() + averageForce.getX() * elapsedTimeInSeconds);\n obj.setY(obj.getY() + averageForce.getY() * elapsedTimeInSeconds);\n obj.updateForces(elapsedTimeInSeconds);\n }\n }\n }\n }\n }\n\n /**\n * Clear any data structures to make sure memory is freed as soon as\n * possible.\n */\n _destroy() {\n // It should not be necessary to reset these variables, but this help\n // ensuring that all memory related to the container is released immediately.\n this._layers = new Hashtable();\n this._orderedLayers = [];\n this._objects = new Hashtable();\n this._instances = new Hashtable();\n this._instancesCache = new Hashtable();\n this._objectsCtor = new Hashtable();\n this._allInstancesList = [];\n this._instancesRemoved = [];\n }\n }\n}\n"],
5
5
  "mappings": "AAKA,GAAU,MAAV,UAAU,EAAV,CACE,KAAM,GAAS,GAAI,GAAK,OAAO,4BAKxB,OAAwC,CAiC7C,aAAc,CAvBN,uBAA0C,GAClD,iCAA8B,GAM9B,uBAA0C,GAQ1C,8BAAyE,GAGzE,uBAA6B,GAC7B,mCAAyC,GACzC,+BAAqC,GACrC,gCAAsC,GAGpC,KAAK,2BAA6B,GAAI,WACtC,KAAK,WAAa,GAAI,WACtB,KAAK,gBAAkB,GAAI,WAC3B,KAAK,SAAW,GAAI,WACpB,KAAK,aAAe,GAAI,WACxB,KAAK,QAAU,GAAI,WACnB,KAAK,eAAiB,GA+JxB,gBACE,EACA,EACA,EACA,EACM,CACN,AAAI,KAAK,mBAAqB,CAAC,GAC7B,KAAK,sBAAsB,iBAG7B,KAAK,kBAAoB,EACzB,KAAK,8BAAgC,EACrC,KAAK,0BAA4B,EACjC,KAAK,2BAA6B,EAQpC,mBAAmB,EAA6B,CAC9C,MACE,MAAK,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,EAAK,OAAQ,EAAI,EAAS,EAAE,EAAG,CACvD,KAAM,GAAM,EAAK,GACjB,GAAI,CAAC,EAAI,cAAe,CACtB,KAAM,GAAe,EAAI,kBACnB,EAAuB,EAAI,iBAAmB,IACpD,EAAI,KAAK,EAAI,OAAS,EAAa,OAAS,GAC5C,EAAI,KAAK,EAAI,OAAS,EAAa,OAAS,GAC5C,EAAI,aAAa,MAW3B,UAAW,CAGT,KAAK,QAAU,GAAI,WACnB,KAAK,eAAiB,GACtB,KAAK,SAAW,GAAI,WACpB,KAAK,WAAa,GAAI,WACtB,KAAK,gBAAkB,GAAI,WAC3B,KAAK,aAAe,GAAI,WACxB,KAAK,kBAAoB,GACzB,KAAK,kBAAoB,IAjyBtB,EAAe,6BANd",
6
6
  "names": []
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../GDevelop/GDJS/Runtime/RuntimeLayer.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 export enum RuntimeLayerRenderingType {\n TWO_D,\n THREE_D,\n TWO_D_PLUS_THREE_D,\n }\n\n const getRenderingTypeFromString = (\n renderingTypeAsString: string | undefined\n ) =>\n renderingTypeAsString === '3d'\n ? RuntimeLayerRenderingType.THREE_D\n : renderingTypeAsString === '2d+3d' || renderingTypeAsString === ''\n ? RuntimeLayerRenderingType.TWO_D_PLUS_THREE_D\n : RuntimeLayerRenderingType.TWO_D;\n\n export enum RuntimeLayerCameraType {\n PERSPECTIVE,\n ORTHOGRAPHIC,\n }\n const getCameraTypeFromString = (renderingTypeAsString: string | undefined) =>\n renderingTypeAsString === 'orthographic'\n ? RuntimeLayerCameraType.ORTHOGRAPHIC\n : RuntimeLayerCameraType.PERSPECTIVE;\n\n export enum RuntimeLayerDefaultCameraBehavior {\n DO_NOTHING,\n TOP_LEFT_ANCHORED_IF_NEVER_MOVED,\n }\n\n const getDefaultCameraBehaviorFromString = (\n defaultCameraBehaviorAsString: string\n ) =>\n defaultCameraBehaviorAsString === 'top-left-anchored-if-never-moved'\n ? RuntimeLayerDefaultCameraBehavior.TOP_LEFT_ANCHORED_IF_NEVER_MOVED\n : RuntimeLayerDefaultCameraBehavior.DO_NOTHING;\n\n /**\n * Represents a layer of a \"container\", used to display objects.\n * The container can be a scene (see gdjs.Layer)\n * or a custom object (see gdjs.RuntimeCustomObjectLayer).\n */\n export abstract class RuntimeLayer implements EffectsTarget {\n _name: string;\n _renderingType: RuntimeLayerRenderingType;\n _cameraType: RuntimeLayerCameraType;\n _defaultCameraBehavior: RuntimeLayerDefaultCameraBehavior;\n _timeScale: float = 1;\n _defaultZOrder: integer = 0;\n _hidden: boolean;\n _initialEffectsData: Array<EffectData>;\n\n // TODO EBO Don't store scene layer related data in layers used by custom objects.\n // (both these 3D settings and the lighting layer properties below).\n _initialCamera3DFieldOfView: float;\n _initialCamera3DFarPlaneDistance: float;\n _initialCamera3DNearPlaneDistance: float;\n\n _runtimeScene: gdjs.RuntimeInstanceContainer;\n _effectsManager: gdjs.EffectsManager;\n\n // Lighting layer properties.\n _isLightingLayer: boolean;\n _followBaseLayerCamera: boolean;\n _clearColor: Array<integer>;\n\n _rendererEffects: Record<string, gdjs.PixiFiltersTools.Filter> = {};\n _renderer: gdjs.LayerRenderer;\n\n /**\n * @param layerData The data used to initialize the layer\n * @param instanceContainer The container in which the layer is used\n */\n constructor(\n layerData: LayerData,\n instanceContainer: gdjs.RuntimeInstanceContainer\n ) {\n this._name = layerData.name;\n this._renderingType = getRenderingTypeFromString(layerData.renderingType);\n this._cameraType = getCameraTypeFromString(layerData.cameraType);\n this._defaultCameraBehavior = getDefaultCameraBehaviorFromString(\n layerData.defaultCameraBehavior || 'top-left-anchored-if-never-moved'\n );\n this._hidden = !layerData.visibility;\n this._initialCamera3DFieldOfView = layerData.camera3DFieldOfView || 45;\n this._initialCamera3DNearPlaneDistance =\n layerData.camera3DNearPlaneDistance || 0.1;\n this._initialCamera3DFarPlaneDistance =\n layerData.camera3DFarPlaneDistance || 2000;\n this._initialEffectsData = layerData.effects || [];\n this._runtimeScene = instanceContainer;\n this._effectsManager = instanceContainer.getGame().getEffectsManager();\n this._isLightingLayer = layerData.isLightingLayer;\n this._followBaseLayerCamera = layerData.followBaseLayerCamera;\n this._clearColor = [\n layerData.ambientLightColorR / 255,\n layerData.ambientLightColorG / 255,\n layerData.ambientLightColorB / 255,\n 1.0,\n ];\n this._renderer = new gdjs.LayerRenderer(\n this,\n instanceContainer.getRenderer(),\n instanceContainer.getGame().getRenderer()\n );\n this.show(!this._hidden);\n for (let i = 0; i < layerData.effects.length; ++i) {\n this.addEffect(layerData.effects[i]);\n }\n }\n\n getRenderer(): gdjs.LayerRenderer {\n return this._renderer;\n }\n\n getRendererObject() {\n return this._renderer.getRendererObject();\n }\n\n get3DRendererObject() {\n return this._renderer.getThreeScene();\n }\n\n getRenderingType(): RuntimeLayerRenderingType {\n return this._renderingType;\n }\n\n getCameraType(): RuntimeLayerCameraType {\n return this._cameraType;\n }\n\n /**\n * Get the default Z order to be attributed to objects created on this layer\n * (usually from events generated code).\n */\n getDefaultZOrder(): float {\n return this._defaultZOrder;\n }\n\n /**\n * Set the default Z order to be attributed to objects created on this layer.\n * @param defaultZOrder The Z order to use when creating a new object from events.\n */\n setDefaultZOrder(defaultZOrder: integer): void {\n this._defaultZOrder = defaultZOrder;\n }\n\n /**\n * Called by the RuntimeScene whenever the game resolution size is changed.\n * Updates the layer width/height and position.\n */\n abstract onGameResolutionResized(\n oldGameResolutionOriginX: float,\n oldGameResolutionOriginY: float\n ): void;\n\n /**\n * Returns the scene the layer belongs to directly or indirectly\n * @returns the scene the layer belongs to directly or indirectly\n */\n getRuntimeScene(): gdjs.RuntimeScene {\n return this._runtimeScene.getScene();\n }\n\n /**\n * Called at each frame, after events are run and before rendering.\n */\n updatePreRender(instanceContainer?: gdjs.RuntimeInstanceContainer): void {\n if (this._followBaseLayerCamera) {\n this.followBaseLayer();\n }\n this._renderer.updatePreRender();\n this._effectsManager.updatePreRender(this._rendererEffects, this);\n }\n\n /**\n * Get the name of the layer\n * @return The name of the layer\n */\n getName(): string {\n return this._name;\n }\n\n /**\n * Change the camera center X position.\n *\n * @param cameraId The camera number. Currently ignored.\n * @return The x position of the camera\n */\n abstract getCameraX(cameraId?: integer): float;\n\n /**\n * Change the camera center Y position.\n *\n * @param cameraId The camera number. Currently ignored.\n * @return The y position of the camera\n */\n abstract getCameraY(cameraId?: integer): float;\n\n /**\n * Set the camera center X position.\n *\n * @param x The new x position\n * @param cameraId The camera number. Currently ignored.\n */\n abstract setCameraX(x: float, cameraId?: integer): void;\n\n /**\n * Set the camera center Y position.\n *\n * @param y The new y position\n * @param cameraId The camera number. Currently ignored.\n */\n abstract setCameraY(y: float, cameraId?: integer): void;\n\n /**\n * Get the camera width (which can be different than the game resolution width\n * if the camera is zoomed).\n *\n * @param cameraId The camera number. Currently ignored.\n * @return The width of the camera\n */\n abstract getCameraWidth(cameraId?: integer): float;\n\n /**\n * Get the camera height (which can be different than the game resolution height\n * if the camera is zoomed).\n *\n * @param cameraId The camera number. Currently ignored.\n * @return The height of the camera\n */\n abstract getCameraHeight(cameraId?: integer): float;\n\n /**\n * Show (or hide) the layer.\n * @param enable true to show the layer, false to hide it.\n */\n show(enable: boolean): void {\n this._hidden = !enable;\n this._renderer.updateVisibility(enable);\n }\n\n /**\n * Check if the layer is visible.\n *\n * @return true if the layer is visible.\n */\n isVisible(): boolean {\n return !this._hidden;\n }\n\n /**\n * Set the zoom of a camera.\n *\n * @param newZoom The new zoom. Must be superior to 0. 1 is the default zoom.\n * @param cameraId The camera number. Currently ignored.\n */\n abstract setCameraZoom(newZoom: float, cameraId?: integer): void;\n\n /**\n * Get the zoom of a camera.\n *\n * @param cameraId The camera number. Currently ignored.\n * @return The zoom.\n */\n abstract getCameraZoom(cameraId?: integer): float;\n\n /**\n * Set the camera center Z position.\n *\n * @param z The new y position.\n * @param fov The field of view.\n * @param cameraId The camera number. Currently ignored.\n */\n abstract setCameraZ(z: float, fov: float | null, cameraId?: integer): void;\n\n /**\n * Get the camera center Z position.\n *\n * @param fov The field of view.\n * @param cameraId The camera number. Currently ignored.\n * @return The z position of the camera\n */\n abstract getCameraZ(fov: float | null, cameraId?: integer): float;\n\n /**\n * Get the rotation of the camera, expressed in degrees.\n *\n * @param cameraId The camera number. Currently ignored.\n * @return The rotation, in degrees.\n */\n abstract getCameraRotation(cameraId?: integer): float;\n\n /**\n * Set the rotation of the camera, expressed in degrees.\n * The rotation is made around the camera center.\n *\n * @param rotation The new rotation, in degrees.\n * @param cameraId The camera number. Currently ignored.\n */\n abstract setCameraRotation(rotation: float, cameraId?: integer): void;\n\n /**\n * Convert a point from the canvas coordinates (for example,\n * the mouse position) to the container coordinates.\n *\n * @param x The x position, in canvas coordinates.\n * @param y The y position, in canvas coordinates.\n * @param cameraId The camera number. Currently ignored.\n * @param result The point instance that is used to return the result.\n */\n abstract convertCoords(\n x: float,\n y: float,\n cameraId: integer,\n result: FloatPoint\n ): FloatPoint;\n\n /**\n * Return an array containing the coordinates of the point passed as parameter\n * in parent coordinate coordinates (as opposed to the layer local coordinates).\n *\n * All transformations (scale, rotation) are supported.\n *\n * @param x The X position of the point, in layer coordinates.\n * @param y The Y position of the point, in layer coordinates.\n * @param result Array that will be updated with the result\n * (x and y position of the point in parent coordinates).\n */\n abstract applyLayerTransformation(\n x: float,\n y: float,\n cameraId: integer,\n result: FloatPoint\n ): FloatPoint;\n\n /**\n * Convert a point from the container coordinates (for example,\n * an object position) to the canvas coordinates.\n *\n * @param x The x position, in container coordinates.\n * @param y The y position, in container coordinates.\n * @param cameraId The camera number. Currently ignored.\n * @param result The point instance that is used to return the result.\n */\n abstract convertInverseCoords(\n x: float,\n y: float,\n cameraId: integer,\n result: FloatPoint\n ): FloatPoint;\n\n /**\n * Return an array containing the coordinates of the point passed as parameter\n * in layer local coordinates (as opposed to the parent coordinates).\n *\n * All transformations (scale, rotation) are supported.\n *\n * @param x The X position of the point, in parent coordinates.\n * @param y The Y position of the point, in parent coordinates.\n * @param result Array that will be updated with the result\n * @param result The point instance that is used to return the result.\n * (x and y position of the point in layer coordinates).\n */\n abstract applyLayerInverseTransformation(\n x: float,\n y: float,\n cameraId: integer,\n result: FloatPoint\n ): FloatPoint;\n\n getWidth(): float {\n return this._runtimeScene.getViewportWidth();\n }\n\n getHeight(): float {\n return this._runtimeScene.getViewportHeight();\n }\n\n getInitialCamera3DFieldOfView(): float {\n return this._initialCamera3DFieldOfView;\n }\n getInitialCamera3DNearPlaneDistance(): float {\n return this._initialCamera3DNearPlaneDistance;\n }\n getInitialCamera3DFarPlaneDistance(): float {\n return this._initialCamera3DFarPlaneDistance;\n }\n\n /**\n * Return the initial effects data for the layer. Only to\n * be used by renderers.\n * @deprecated\n */\n getInitialEffectsData(): EffectData[] {\n return this._initialEffectsData;\n }\n\n /**\n * Returns the collection of effects to be rendered by the\n * underlying renderer.\n * @returns The renderer effects.\n */\n getRendererEffects() {\n return this._rendererEffects;\n }\n\n /**\n * Add a new effect, or replace the one with the same name.\n * @param effectData The data of the effect to add.\n */\n addEffect(effectData: EffectData): void {\n this._effectsManager.addEffect(effectData, this._rendererEffects, this);\n }\n\n /**\n * Remove the effect with the specified name\n * @param effectName The name of the effect.\n */\n removeEffect(effectName: string): void {\n this._effectsManager.removeEffect(\n this._rendererEffects,\n this,\n effectName\n );\n }\n\n /**\n * Change an effect property value (for properties that are numbers).\n * @param name The name of the effect to update.\n * @param parameterName The name of the property to update.\n * @param value The new value (number).\n */\n setEffectDoubleParameter(\n name: string,\n parameterName: string,\n value: float\n ): void {\n this._effectsManager.setEffectDoubleParameter(\n this._rendererEffects,\n name,\n parameterName,\n value\n );\n }\n\n /**\n * Change an effect property value (for properties that are strings).\n * @param name The name of the effect to update.\n * @param parameterName The name of the property to update.\n * @param value The new value (string).\n */\n setEffectStringParameter(\n name: string,\n parameterName: string,\n value: string\n ): void {\n this._effectsManager.setEffectStringParameter(\n this._rendererEffects,\n name,\n parameterName,\n value\n );\n }\n\n /**\n * Change an effect property value (for properties that are booleans).\n * @param name The name of the effect to update.\n * @param parameterName The name of the property to update.\n * @param value The new value (boolean).\n */\n setEffectBooleanParameter(\n name: string,\n parameterName: string,\n value: boolean\n ): void {\n this._effectsManager.setEffectBooleanParameter(\n this._rendererEffects,\n name,\n parameterName,\n value\n );\n }\n\n /**\n * Enable or disable an effect.\n * @param name The name of the effect to enable or disable.\n * @param enable true to enable, false to disable\n */\n enableEffect(name: string, enable: boolean): void {\n this._effectsManager.enableEffect(\n this._rendererEffects,\n this,\n name,\n enable\n );\n }\n\n /**\n * Check if an effect is enabled\n * @param name The name of the effect\n * @return true if the effect is enabled, false otherwise.\n */\n isEffectEnabled(name: string): boolean {\n return this._effectsManager.isEffectEnabled(\n this._rendererEffects,\n this,\n name\n );\n }\n\n /**\n * Check if an effect exists on this layer\n * @param name The name of the effect\n * @return true if the effect exists, false otherwise.\n */\n hasEffect(name: string): boolean {\n return this._effectsManager.hasEffect(this._rendererEffects, name);\n }\n\n /**\n * Set the time scale for the objects on the layer:\n * time will be slower if time scale is < 1, faster if > 1.\n * @param timeScale The new time scale (must be positive).\n */\n setTimeScale(timeScale: float): void {\n if (timeScale >= 0) {\n this._timeScale = timeScale;\n }\n }\n\n /**\n * Get the time scale for the objects on the layer.\n */\n getTimeScale(): float {\n return this._timeScale;\n }\n\n /**\n * Return the time elapsed since the last frame,\n * in milliseconds, for objects on the layer.\n *\n * @param instanceContainer The instance container the layer belongs to (deprecated - can be omitted).\n */\n getElapsedTime(instanceContainer?: gdjs.RuntimeInstanceContainer): float {\n const container = instanceContainer || this._runtimeScene;\n return container.getElapsedTime() * this._timeScale;\n }\n\n /**\n * Change the position, rotation and scale (zoom) of the layer camera to be the same as the base layer camera.\n */\n followBaseLayer(): void {\n const baseLayer = this._runtimeScene.getLayer('');\n this.setCameraX(baseLayer.getCameraX());\n this.setCameraY(baseLayer.getCameraY());\n this.setCameraRotation(baseLayer.getCameraRotation());\n this.setCameraZoom(baseLayer.getCameraZoom());\n }\n\n /**\n * The clear color is defined in the format [r, g, b], with components in the range of 0 to 1.\n * @return the clear color of layer in the range of [0, 1].\n */\n getClearColor(): Array<integer> {\n return this._clearColor;\n }\n\n /**\n * Set the clear color in format [r, g, b], with components in the range of 0 to 1.;\n * @param r Red color component in the range 0-255.\n * @param g Green color component in the range 0-255.\n * @param b Blue color component in the range 0-255.\n */\n setClearColor(r: integer, g: integer, b: integer): void {\n this._clearColor[0] = r / 255;\n this._clearColor[1] = g / 255;\n this._clearColor[2] = b / 255;\n this._renderer.updateClearColor();\n }\n\n /**\n * Set whether layer's camera follows base layer's camera or not.\n */\n setFollowBaseLayerCamera(follow: boolean): void {\n this._followBaseLayerCamera = follow;\n }\n\n /**\n * Return true if the layer is a lighting layer, false otherwise.\n * @return true if it is a lighting layer, false otherwise.\n */\n isLightingLayer(): boolean {\n return this._isLightingLayer;\n }\n }\n}\n"],
5
- "mappings": "AAKA,GAAU,MAAV,UAAU,EAAV,CACS,GAAK,GAAL,UAAK,EAAL,CACL,qBACA,yBACA,iDAHU,iEAMZ,KAAM,GAA6B,AACjC,GAEA,IAA0B,KACtB,EACA,IAA0B,SAAW,IAA0B,GAC/D,EACA,EAEC,GAAK,GAAL,UAAK,EAAL,CACL,iCACA,qCAFU,2DAIZ,KAAM,GAA0B,AAAC,GAC/B,IAA0B,eACtB,EACA,EAEC,GAAK,GAAL,UAAK,EAAL,CACL,+BACA,6EAFU,iFAKZ,KAAM,GAAqC,AACzC,GAEA,IAAkC,mCAC9B,EACA,EAOC,OAAqD,CA+B1D,YACE,EACA,EACA,CA7BF,gBAAoB,EACpB,oBAA0B,EAkB1B,sBAAiE,GAW/D,KAAK,MAAQ,EAAU,KACvB,KAAK,eAAiB,EAA2B,EAAU,eAC3D,KAAK,YAAc,EAAwB,EAAU,YACrD,KAAK,uBAAyB,EAC5B,EAAU,uBA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BAAyB,EAOhC,iBAA2B,CACzB,MAAO,MAAK,kBAviBT,EAAe,iBA1Cd",
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 export enum RuntimeLayerRenderingType {\n TWO_D,\n THREE_D,\n TWO_D_PLUS_THREE_D,\n }\n\n const getRenderingTypeFromString = (\n renderingTypeAsString: string | undefined\n ) =>\n renderingTypeAsString === '3d'\n ? RuntimeLayerRenderingType.THREE_D\n : renderingTypeAsString === '2d+3d' || renderingTypeAsString === ''\n ? RuntimeLayerRenderingType.TWO_D_PLUS_THREE_D\n : RuntimeLayerRenderingType.TWO_D;\n\n export enum RuntimeLayerCameraType {\n PERSPECTIVE,\n ORTHOGRAPHIC,\n }\n const getCameraTypeFromString = (\n renderingTypeAsString: string | undefined\n ) =>\n renderingTypeAsString === 'orthographic'\n ? RuntimeLayerCameraType.ORTHOGRAPHIC\n : RuntimeLayerCameraType.PERSPECTIVE;\n\n export enum RuntimeLayerDefaultCameraBehavior {\n DO_NOTHING,\n TOP_LEFT_ANCHORED_IF_NEVER_MOVED,\n }\n\n const getDefaultCameraBehaviorFromString = (\n defaultCameraBehaviorAsString: string\n ) =>\n defaultCameraBehaviorAsString === 'top-left-anchored-if-never-moved'\n ? RuntimeLayerDefaultCameraBehavior.TOP_LEFT_ANCHORED_IF_NEVER_MOVED\n : RuntimeLayerDefaultCameraBehavior.DO_NOTHING;\n\n /**\n * Represents a layer of a \"container\", used to display objects.\n * The container can be a scene (see gdjs.Layer)\n * or a custom object (see gdjs.RuntimeCustomObjectLayer).\n */\n export abstract class RuntimeLayer implements EffectsTarget {\n _name: string;\n _renderingType: RuntimeLayerRenderingType;\n _cameraType: RuntimeLayerCameraType;\n _defaultCameraBehavior: RuntimeLayerDefaultCameraBehavior;\n _timeScale: float = 1;\n _defaultZOrder: integer = 0;\n _hidden: boolean;\n _initialEffectsData: Array<EffectData>;\n\n // TODO EBO Don't store scene layer related data in layers used by custom objects.\n // (both these 3D settings and the lighting layer properties below).\n _initialCamera3DFieldOfView: float;\n _initialCamera3DFarPlaneDistance: float;\n _initialCamera3DNearPlaneDistance: float;\n\n _runtimeScene: gdjs.RuntimeInstanceContainer;\n _effectsManager: gdjs.EffectsManager;\n\n // Lighting layer properties.\n _isLightingLayer: boolean;\n _followBaseLayerCamera: boolean;\n _clearColor: Array<integer>;\n\n _rendererEffects: Record<string, gdjs.PixiFiltersTools.Filter> = {};\n _renderer: gdjs.LayerRenderer;\n\n /**\n * @param layerData The data used to initialize the layer\n * @param instanceContainer The container in which the layer is used\n */\n constructor(\n layerData: LayerData,\n instanceContainer: gdjs.RuntimeInstanceContainer\n ) {\n this._name = layerData.name;\n this._renderingType = getRenderingTypeFromString(layerData.renderingType);\n this._cameraType = getCameraTypeFromString(layerData.cameraType);\n this._defaultCameraBehavior = getDefaultCameraBehaviorFromString(\n layerData.defaultCameraBehavior || 'top-left-anchored-if-never-moved'\n );\n this._hidden = !layerData.visibility;\n this._initialCamera3DFieldOfView = layerData.camera3DFieldOfView || 45;\n this._initialCamera3DNearPlaneDistance =\n layerData.camera3DNearPlaneDistance || 0.1;\n this._initialCamera3DFarPlaneDistance =\n layerData.camera3DFarPlaneDistance || 2000;\n this._initialEffectsData = layerData.effects || [];\n this._runtimeScene = instanceContainer;\n this._effectsManager = instanceContainer.getGame().getEffectsManager();\n this._isLightingLayer = layerData.isLightingLayer;\n this._followBaseLayerCamera = layerData.followBaseLayerCamera;\n this._clearColor = [\n layerData.ambientLightColorR / 255,\n layerData.ambientLightColorG / 255,\n layerData.ambientLightColorB / 255,\n 1.0,\n ];\n this._renderer = new gdjs.LayerRenderer(\n this,\n instanceContainer.getRenderer(),\n instanceContainer.getGame().getRenderer()\n );\n this.show(!this._hidden);\n for (let i = 0; i < layerData.effects.length; ++i) {\n this.addEffect(layerData.effects[i]);\n }\n }\n\n getRenderer(): gdjs.LayerRenderer {\n return this._renderer;\n }\n\n getRendererObject() {\n return this._renderer.getRendererObject();\n }\n\n get3DRendererObject() {\n return this._renderer.getThreeScene();\n }\n\n getRenderingType(): RuntimeLayerRenderingType {\n return this._renderingType;\n }\n\n getCameraType(): RuntimeLayerCameraType {\n return this._cameraType;\n }\n\n /**\n * Get the default Z order to be attributed to objects created on this layer\n * (usually from events generated code).\n */\n getDefaultZOrder(): float {\n return this._defaultZOrder;\n }\n\n /**\n * Set the default Z order to be attributed to objects created on this layer.\n * @param defaultZOrder The Z order to use when creating a new object from events.\n */\n setDefaultZOrder(defaultZOrder: integer): void {\n this._defaultZOrder = defaultZOrder;\n }\n\n /**\n * Called by the RuntimeScene whenever the game resolution size is changed.\n * Updates the layer width/height and position.\n */\n abstract onGameResolutionResized(\n oldGameResolutionOriginX: float,\n oldGameResolutionOriginY: float\n ): void;\n\n /**\n * Returns the scene the layer belongs to directly or indirectly\n * @returns the scene the layer belongs to directly or indirectly\n */\n getRuntimeScene(): gdjs.RuntimeScene {\n return this._runtimeScene.getScene();\n }\n\n /**\n * Called at each frame, after events are run and before rendering.\n */\n updatePreRender(instanceContainer?: gdjs.RuntimeInstanceContainer): void {\n if (this._followBaseLayerCamera) {\n this.followBaseLayer();\n }\n this._renderer.updatePreRender();\n this._effectsManager.updatePreRender(this._rendererEffects, this);\n }\n\n /**\n * Get the name of the layer\n * @return The name of the layer\n */\n getName(): string {\n return this._name;\n }\n\n /**\n * Change the camera center X position.\n *\n * @param cameraId The camera number. Currently ignored.\n * @return The x position of the camera\n */\n abstract getCameraX(cameraId?: integer): float;\n\n /**\n * Change the camera center Y position.\n *\n * @param cameraId The camera number. Currently ignored.\n * @return The y position of the camera\n */\n abstract getCameraY(cameraId?: integer): float;\n\n /**\n * Set the camera center X position.\n *\n * @param x The new x position\n * @param cameraId The camera number. Currently ignored.\n */\n abstract setCameraX(x: float, cameraId?: integer): void;\n\n /**\n * Set the camera center Y position.\n *\n * @param y The new y position\n * @param cameraId The camera number. Currently ignored.\n */\n abstract setCameraY(y: float, cameraId?: integer): void;\n\n /**\n * Get the camera width (which can be different than the game resolution width\n * if the camera is zoomed).\n *\n * @param cameraId The camera number. Currently ignored.\n * @return The width of the camera\n */\n abstract getCameraWidth(cameraId?: integer): float;\n\n /**\n * Get the camera height (which can be different than the game resolution height\n * if the camera is zoomed).\n *\n * @param cameraId The camera number. Currently ignored.\n * @return The height of the camera\n */\n abstract getCameraHeight(cameraId?: integer): float;\n\n /**\n * Show (or hide) the layer.\n * @param enable true to show the layer, false to hide it.\n */\n show(enable: boolean): void {\n this._hidden = !enable;\n this._renderer.updateVisibility(enable);\n }\n\n /**\n * Check if the layer is visible.\n *\n * @return true if the layer is visible.\n */\n isVisible(): boolean {\n return !this._hidden;\n }\n\n /**\n * Set the zoom of a camera.\n *\n * @param newZoom The new zoom. Must be superior to 0. 1 is the default zoom.\n * @param cameraId The camera number. Currently ignored.\n */\n abstract setCameraZoom(newZoom: float, cameraId?: integer): void;\n\n /**\n * Get the zoom of a camera.\n *\n * @param cameraId The camera number. Currently ignored.\n * @return The zoom.\n */\n abstract getCameraZoom(cameraId?: integer): float;\n\n /**\n * Set the camera center Z position.\n *\n * @param z The new y position.\n * @param fov The field of view.\n * @param cameraId The camera number. Currently ignored.\n */\n abstract setCameraZ(z: float, fov: float | null, cameraId?: integer): void;\n\n /**\n * Get the camera center Z position.\n *\n * @param fov The field of view.\n * @param cameraId The camera number. Currently ignored.\n * @return The z position of the camera\n */\n abstract getCameraZ(fov: float | null, cameraId?: integer): float;\n\n /**\n * Get the rotation of the camera, expressed in degrees.\n *\n * @param cameraId The camera number. Currently ignored.\n * @return The rotation, in degrees.\n */\n abstract getCameraRotation(cameraId?: integer): float;\n\n /**\n * Set the rotation of the camera, expressed in degrees.\n * The rotation is made around the camera center.\n *\n * @param rotation The new rotation, in degrees.\n * @param cameraId The camera number. Currently ignored.\n */\n abstract setCameraRotation(rotation: float, cameraId?: integer): void;\n\n /**\n * Convert a point from the canvas coordinates (for example,\n * the mouse position) to the container coordinates.\n *\n * @param x The x position, in canvas coordinates.\n * @param y The y position, in canvas coordinates.\n * @param cameraId The camera number. Currently ignored.\n * @param result The point instance that is used to return the result.\n */\n abstract convertCoords(\n x: float,\n y: float,\n cameraId: integer,\n result: FloatPoint\n ): FloatPoint;\n\n /**\n * Return an array containing the coordinates of the point passed as parameter\n * in parent coordinate coordinates (as opposed to the layer local coordinates).\n *\n * All transformations (scale, rotation) are supported.\n *\n * @param x The X position of the point, in layer coordinates.\n * @param y The Y position of the point, in layer coordinates.\n * @param result Array that will be updated with the result\n * (x and y position of the point in parent coordinates).\n */\n abstract applyLayerTransformation(\n x: float,\n y: float,\n cameraId: integer,\n result: FloatPoint\n ): FloatPoint;\n\n /**\n * Convert a point from the container coordinates (for example,\n * an object position) to the canvas coordinates.\n *\n * @param x The x position, in container coordinates.\n * @param y The y position, in container coordinates.\n * @param cameraId The camera number. Currently ignored.\n * @param result The point instance that is used to return the result.\n */\n abstract convertInverseCoords(\n x: float,\n y: float,\n cameraId: integer,\n result: FloatPoint\n ): FloatPoint;\n\n /**\n * Return an array containing the coordinates of the point passed as parameter\n * in layer local coordinates (as opposed to the parent coordinates).\n *\n * All transformations (scale, rotation) are supported.\n *\n * @param x The X position of the point, in parent coordinates.\n * @param y The Y position of the point, in parent coordinates.\n * @param result Array that will be updated with the result\n * @param result The point instance that is used to return the result.\n * (x and y position of the point in layer coordinates).\n */\n abstract applyLayerInverseTransformation(\n x: float,\n y: float,\n cameraId: integer,\n result: FloatPoint\n ): FloatPoint;\n\n getWidth(): float {\n return this._runtimeScene.getViewportWidth();\n }\n\n getHeight(): float {\n return this._runtimeScene.getViewportHeight();\n }\n\n getInitialCamera3DFieldOfView(): float {\n return this._initialCamera3DFieldOfView;\n }\n getInitialCamera3DNearPlaneDistance(): float {\n return this._initialCamera3DNearPlaneDistance;\n }\n getInitialCamera3DFarPlaneDistance(): float {\n return this._initialCamera3DFarPlaneDistance;\n }\n\n /**\n * Return the initial effects data for the layer. Only to\n * be used by renderers.\n * @deprecated\n */\n getInitialEffectsData(): EffectData[] {\n return this._initialEffectsData;\n }\n\n /**\n * Returns the collection of effects to be rendered by the\n * underlying renderer.\n * @returns The renderer effects.\n */\n getRendererEffects() {\n return this._rendererEffects;\n }\n\n /**\n * Add a new effect, or replace the one with the same name.\n * @param effectData The data of the effect to add.\n */\n addEffect(effectData: EffectData): void {\n this._effectsManager.addEffect(effectData, this._rendererEffects, this);\n }\n\n /**\n * Remove the effect with the specified name\n * @param effectName The name of the effect.\n */\n removeEffect(effectName: string): void {\n this._effectsManager.removeEffect(\n this._rendererEffects,\n this,\n effectName\n );\n }\n\n /**\n * Change an effect property value (for properties that are numbers).\n * @param name The name of the effect to update.\n * @param parameterName The name of the property to update.\n * @param value The new value (number).\n */\n setEffectDoubleParameter(\n name: string,\n parameterName: string,\n value: float\n ): void {\n this._effectsManager.setEffectDoubleParameter(\n this._rendererEffects,\n name,\n parameterName,\n value\n );\n }\n\n /**\n * Change an effect property value (for properties that are strings).\n * @param name The name of the effect to update.\n * @param parameterName The name of the property to update.\n * @param value The new value (string).\n */\n setEffectStringParameter(\n name: string,\n parameterName: string,\n value: string\n ): void {\n this._effectsManager.setEffectStringParameter(\n this._rendererEffects,\n name,\n parameterName,\n value\n );\n }\n\n /**\n * Change an effect property value (for properties that are booleans).\n * @param name The name of the effect to update.\n * @param parameterName The name of the property to update.\n * @param value The new value (boolean).\n */\n setEffectBooleanParameter(\n name: string,\n parameterName: string,\n value: boolean\n ): void {\n this._effectsManager.setEffectBooleanParameter(\n this._rendererEffects,\n name,\n parameterName,\n value\n );\n }\n\n /**\n * Enable or disable an effect.\n * @param name The name of the effect to enable or disable.\n * @param enable true to enable, false to disable\n */\n enableEffect(name: string, enable: boolean): void {\n this._effectsManager.enableEffect(\n this._rendererEffects,\n this,\n name,\n enable\n );\n }\n\n /**\n * Check if an effect is enabled\n * @param name The name of the effect\n * @return true if the effect is enabled, false otherwise.\n */\n isEffectEnabled(name: string): boolean {\n return this._effectsManager.isEffectEnabled(\n this._rendererEffects,\n this,\n name\n );\n }\n\n /**\n * Check if an effect exists on this layer\n * @param name The name of the effect\n * @return true if the effect exists, false otherwise.\n */\n hasEffect(name: string): boolean {\n return this._effectsManager.hasEffect(this._rendererEffects, name);\n }\n\n /**\n * Set the time scale for the objects on the layer:\n * time will be slower if time scale is < 1, faster if > 1.\n * @param timeScale The new time scale (must be positive).\n */\n setTimeScale(timeScale: float): void {\n if (timeScale >= 0) {\n this._timeScale = timeScale;\n }\n }\n\n /**\n * Get the time scale for the objects on the layer.\n */\n getTimeScale(): float {\n return this._timeScale;\n }\n\n /**\n * Return the time elapsed since the last frame,\n * in milliseconds, for objects on the layer.\n *\n * @param instanceContainer The instance container the layer belongs to (deprecated - can be omitted).\n */\n getElapsedTime(instanceContainer?: gdjs.RuntimeInstanceContainer): float {\n const container = instanceContainer || this._runtimeScene;\n return container.getElapsedTime() * this._timeScale;\n }\n\n /**\n * Change the position, rotation and scale (zoom) of the layer camera to be the same as the base layer camera.\n */\n followBaseLayer(): void {\n const baseLayer = this._runtimeScene.getLayer('');\n this.setCameraX(baseLayer.getCameraX());\n this.setCameraY(baseLayer.getCameraY());\n this.setCameraRotation(baseLayer.getCameraRotation());\n this.setCameraZoom(baseLayer.getCameraZoom());\n }\n\n /**\n * The clear color is defined in the format [r, g, b], with components in the range of 0 to 1.\n * @return the clear color of layer in the range of [0, 1].\n */\n getClearColor(): Array<integer> {\n return this._clearColor;\n }\n\n /**\n * Set the clear color in format [r, g, b], with components in the range of 0 to 1.;\n * @param r Red color component in the range 0-255.\n * @param g Green color component in the range 0-255.\n * @param b Blue color component in the range 0-255.\n */\n setClearColor(r: integer, g: integer, b: integer): void {\n this._clearColor[0] = r / 255;\n this._clearColor[1] = g / 255;\n this._clearColor[2] = b / 255;\n this._renderer.updateClearColor();\n }\n\n /**\n * Set whether layer's camera follows base layer's camera or not.\n */\n setFollowBaseLayerCamera(follow: boolean): void {\n this._followBaseLayerCamera = follow;\n }\n\n /**\n * Return true if the layer is a lighting layer, false otherwise.\n * @return true if it is a lighting layer, false otherwise.\n */\n isLightingLayer(): boolean {\n return this._isLightingLayer;\n }\n }\n}\n"],
5
+ "mappings": "AAKA,GAAU,MAAV,UAAU,EAAV,CACS,GAAK,GAAL,UAAK,EAAL,CACL,qBACA,yBACA,iDAHU,iEAMZ,KAAM,GAA6B,AACjC,GAEA,IAA0B,KACtB,EACA,IAA0B,SAAW,IAA0B,GAC7D,EACA,EAED,GAAK,GAAL,UAAK,EAAL,CACL,iCACA,qCAFU,2DAIZ,KAAM,GAA0B,AAC9B,GAEA,IAA0B,eACtB,EACA,EAEC,GAAK,GAAL,UAAK,EAAL,CACL,+BACA,6EAFU,iFAKZ,KAAM,GAAqC,AACzC,GAEA,IAAkC,mCAC9B,EACA,EAOC,OAAqD,CA+B1D,YACE,EACA,EACA,CA7BF,gBAAoB,EACpB,oBAA0B,EAkB1B,sBAAiE,GAW/D,KAAK,MAAQ,EAAU,KACvB,KAAK,eAAiB,EAA2B,EAAU,eAC3D,KAAK,YAAc,EAAwB,EAAU,YACrD,KAAK,uBAAyB,EAC5B,EAAU,uBAAyB,oCAErC,KAAK,QAAU,CAAC,EAAU,WAC1B,KAAK,4BAA8B,EAAU,qBAAuB,GACpE,KAAK,kCACH,EAAU,2BAA6B,GACzC,KAAK,iCACH,EAAU,0BAA4B,IACxC,KAAK,oBAAsB,EAAU,SAAW,GAChD,KAAK,cAAgB,EACrB,KAAK,gBAAkB,EAAkB,UAAU,oBACnD,KAAK,iBAAmB,EAAU,gBAClC,KAAK,uBAAyB,EAAU,sBACxC,KAAK,YAAc,CACjB,EAAU,mBAAqB,IAC/B,EAAU,mBAAqB,IAC/B,EAAU,mBAAqB,IAC/B,GAEF,KAAK,UAAY,GAAI,GAAK,cACxB,KACA,EAAkB,cAClB,EAAkB,UAAU,eAE9B,KAAK,KAAK,CAAC,KAAK,SAChB,OAAS,GAAI,EAAG,EAAI,EAAU,QAAQ,OA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