gdcore-tools 2.0.0-gd-v5.4.218-autobuild → 2.0.0-gd-v5.4.220-autobuild
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Runtime/Extensions/3D/CustomRuntimeObject3D.js +1 -1
- package/dist/Runtime/Extensions/3D/CustomRuntimeObject3D.js.map +2 -2
- package/dist/Runtime/Extensions/AnchorBehavior/anchorruntimebehavior.js +1 -1
- package/dist/Runtime/Extensions/AnchorBehavior/anchorruntimebehavior.js.map +2 -2
- package/dist/Runtime/Extensions/Physics2Behavior/JsExtension.js +19 -19
- package/dist/Runtime/Extensions/Physics2Behavior/physics2runtimebehavior.js +1 -1
- package/dist/Runtime/Extensions/Physics2Behavior/physics2runtimebehavior.js.map +2 -2
- package/dist/Runtime/Extensions/Physics2Behavior/physics2tools.js +1 -1
- package/dist/Runtime/Extensions/Physics2Behavior/physics2tools.js.map +2 -2
- package/dist/Runtime/Extensions/Physics3DBehavior/JsExtension.js +2442 -0
- package/dist/Runtime/Extensions/Physics3DBehavior/Physics3DRuntimeBehavior.js +2 -0
- package/dist/Runtime/Extensions/Physics3DBehavior/Physics3DRuntimeBehavior.js.map +7 -0
- package/dist/Runtime/Extensions/Physics3DBehavior/Physics3DTools.js +2 -0
- package/dist/Runtime/Extensions/Physics3DBehavior/Physics3DTools.js.map +7 -0
- package/dist/Runtime/Extensions/Physics3DBehavior/PhysicsCharacter3DRuntimeBehavior.js +2 -0
- package/dist/Runtime/Extensions/Physics3DBehavior/PhysicsCharacter3DRuntimeBehavior.js.map +7 -0
- package/dist/Runtime/Extensions/Physics3DBehavior/jolt-physics.d.ts +4874 -0
- package/dist/Runtime/Extensions/Physics3DBehavior/jolt-physics.wasm.js +2 -0
- package/dist/Runtime/Extensions/Physics3DBehavior/jolt-physics.wasm.js.map +7 -0
- package/dist/Runtime/Extensions/Physics3DBehavior/jolt-physics.wasm.wasm +0 -0
- package/dist/Runtime/Extensions/PlatformBehavior/platformerobjectruntimebehavior.js.map +2 -2
- package/dist/Runtime/Extensions/TileMap/helper/TileMapHelper.js +1 -1
- package/dist/Runtime/Extensions/TileMap/helper/TileMapHelper.js.map +1 -1
- package/dist/Runtime/Extensions/TileMap/simpletilemapruntimeobject.js +1 -1
- package/dist/Runtime/Extensions/TileMap/simpletilemapruntimeobject.js.map +2 -2
- package/dist/Runtime/RuntimeInstanceContainer.js +1 -1
- package/dist/Runtime/RuntimeInstanceContainer.js.map +2 -2
- package/dist/Runtime/RuntimeLayer.js +1 -1
- package/dist/Runtime/RuntimeLayer.js.map +2 -2
- package/dist/Runtime/layer.js +1 -1
- package/dist/Runtime/layer.js.map +2 -2
- package/dist/Runtime/pixi-renderers/pixi-image-manager.js +1 -1
- package/dist/Runtime/pixi-renderers/pixi-image-manager.js.map +2 -2
- package/dist/Runtime/pixi-renderers/runtimegame-pixi-renderer.js +1 -1
- package/dist/Runtime/pixi-renderers/runtimegame-pixi-renderer.js.map +2 -2
- package/dist/Runtime/runtimegame.js +1 -1
- package/dist/Runtime/runtimegame.js.map +2 -2
- package/dist/Runtime/types/global-types.d.ts +20 -3
- package/dist/Runtime/types/project-data.d.ts +1 -1
- package/dist/lib/libGD.cjs +1 -1
- package/dist/lib/libGD.wasm +0 -0
- package/gd.d.ts +17 -3
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../GDevelop/GDJS/Runtime/pixi-renderers/pixi-image-manager.ts"],
|
|
4
|
-
"sourcesContent": ["/*\n * GDevelop JS Platform\n * Copyright 2013-2016 Florian Rival (Florian.Rival@gmail.com). All rights reserved.\n * This project is released under the MIT License.\n */\nnamespace gdjs {\n const logger = new gdjs.Logger('PIXI Image manager');\n\n const logFileLoadingError = (file: string, error: Error | undefined) => {\n logger.error(\n 'Unable to load file ' + file + ' with error:',\n error ? error : '(unknown error)'\n );\n };\n\n const applyTextureSettings = (\n texture: PIXI.Texture | undefined,\n resourceData: ResourceData\n ) => {\n if (!texture) return;\n\n if (!resourceData.smoothed) {\n texture.baseTexture.scaleMode = PIXI.SCALE_MODES.NEAREST;\n }\n };\n\n const applyThreeTextureSettings = (\n threeTexture: THREE.Texture,\n resourceData: ResourceData | null\n ) => {\n if (resourceData && !resourceData.smoothed) {\n threeTexture.magFilter = THREE.NearestFilter;\n threeTexture.minFilter = THREE.NearestFilter;\n }\n };\n\n const resourceKinds: Array<ResourceKind> = ['image', 'video'];\n\n /**\n * PixiImageManager loads and stores textures that can be used by the Pixi.js renderers.\n */\n export class PixiImageManager implements gdjs.ResourceManager {\n /**\n * The invalid texture is a 8x8 PNG file filled with magenta (#ff00ff), to be\n * easily spotted if rendered on screen.\n */\n private _invalidTexture: PIXI.Texture;\n\n /**\n * Map associating a resource name to the loaded PixiJS texture.\n */\n private _loadedTextures = new gdjs.ResourceCache<PIXI.Texture>();\n\n /**\n * Map associating a resource name to the loaded Three.js texture.\n */\n private _loadedThreeTextures: Hashtable<THREE.Texture>;\n private _loadedThreeMaterials: Hashtable<THREE.Material>;\n\n private _diskTextures = new Map<float, PIXI.Texture>();\n private _rectangleTextures = new Map<string, PIXI.Texture>();\n private _scaledTextures = new Map<string, PIXI.Texture>();\n\n private _resourceLoader: gdjs.ResourceLoader;\n\n /**\n * @param resources 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 this._invalidTexture = PIXI.Texture.from(\n 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAICAYAAADED76LAAAAFElEQVQoU2P8z/D/PwMewDgyFAAApMMX8Zi0uXAAAAAASUVORK5CYIIA'\n );\n this._loadedThreeTextures = new Hashtable();\n this._loadedThreeMaterials = new Hashtable();\n }\n\n getResourceKinds(): ResourceKind[] {\n return resourceKinds;\n }\n\n /**\n * Return the PIXI texture associated to the specified resource name.\n * Returns a placeholder texture if not found.\n * @param resourceName The name of the resource\n * @returns The requested texture, or a placeholder if not found.\n */\n getPIXITexture(resourceName: string): PIXI.Texture {\n const resource = this._getImageResource(resourceName);\n if (!resource) {\n logger.warn(\n 'Unable to find texture for resource \"' + resourceName + '\".'\n );\n return this._invalidTexture;\n }\n\n const existingTexture = this._loadedTextures.get(resource);\n if (!existingTexture) {\n return this._invalidTexture;\n }\n if (!existingTexture.valid) {\n logger.error(\n 'Texture for ' +\n resourceName +\n ' is not valid anymore (or never was).'\n );\n return this._invalidTexture;\n }\n\n return existingTexture;\n }\n\n /**\n * Return the PIXI texture associated to the specified resource name.\n * If not found in the loaded textures, this method will try to load it.\n * Warning: this method should only be used in specific cases that cannot rely on\n * the initial resources loading of the game, such as the splashscreen.\n * @param resourceName The name of the resource\n * @returns The requested texture, or a placeholder if not valid.\n */\n getOrLoadPIXITexture(resourceName: string): PIXI.Texture {\n const resource = this._getImageResource(resourceName);\n if (!resource) {\n logger.warn(\n 'Unable to find texture for resource \"' + resourceName + '\".'\n );\n return this._invalidTexture;\n }\n\n const existingTexture = this._loadedTextures.get(resource);\n if (existingTexture) {\n if (existingTexture.valid) {\n return existingTexture;\n } else {\n logger.error(\n 'Texture for ' +\n resourceName +\n ' is not valid anymore (or never was).'\n );\n return this._invalidTexture;\n }\n }\n\n logger.log('Loading texture for resource \"' + resourceName + '\"...');\n const file = resource.file;\n const url = this._resourceLoader.getFullUrl(file);\n const texture = PIXI.Texture.from(url, {\n resourceOptions: {\n // Note that using `false`\n // to not having `crossorigin` at all would NOT work because the browser would taint the\n // loaded resource so that it can't be read/used in a canvas (it's only working for display `<img>` on screen).\n crossorigin: this._resourceLoader.checkIfCredentialsRequired(file)\n ? 'use-credentials'\n : 'anonymous',\n },\n }).on('error', (error) => {\n logFileLoadingError(file, error);\n });\n if (!texture) {\n throw new Error(\n 'Texture loading by PIXI returned nothing for file ' +\n file +\n ' behind url ' +\n url\n );\n }\n applyTextureSettings(texture, resource);\n\n this._loadedTextures.set(resource, texture);\n return texture;\n }\n\n /**\n * Return the three.js texture associated to the specified resource name.\n * Returns a placeholder texture if not found.\n * @param resourceName The name of the resource\n * @returns The requested texture, or a placeholder if not found.\n */\n getThreeTexture(resourceName: string): THREE.Texture {\n const loadedThreeTexture = this._loadedThreeTextures.get(resourceName);\n if (loadedThreeTexture) {\n return loadedThreeTexture;\n }\n\n // Texture is not loaded, load it now from the PixiJS texture.\n // TODO (3D) - optimization: don't load the PixiJS Texture if not used by PixiJS.\n // TODO (3D) - optimization: Ideally we could even share the same WebGL texture.\n const pixiTexture = this.getPIXITexture(resourceName);\n const pixiRenderer = this._resourceLoader._runtimeGame\n .getRenderer()\n .getPIXIRenderer();\n if (!pixiRenderer) throw new Error('No PIXI renderer was found.');\n\n // @ts-ignore - source does exist on resource.\n const image = pixiTexture.baseTexture.resource.source;\n if (!(image instanceof HTMLImageElement)) {\n throw new Error(\n `Can't load texture for resource \"${resourceName}\" as it's not an image.`\n );\n }\n\n const threeTexture = new THREE.Texture(image);\n threeTexture.magFilter = THREE.LinearFilter;\n threeTexture.minFilter = THREE.LinearFilter;\n threeTexture.wrapS = THREE.RepeatWrapping;\n threeTexture.wrapT = THREE.RepeatWrapping;\n threeTexture.colorSpace = THREE.SRGBColorSpace;\n threeTexture.needsUpdate = true;\n\n const resource = this._getImageResource(resourceName);\n\n applyThreeTextureSettings(threeTexture, resource);\n this._loadedThreeTextures.put(resourceName, threeTexture);\n\n return threeTexture;\n }\n\n /**\n * Return the three.js material associated to the specified resource name.\n * @param resourceName The name of the resource\n * @param options\n * @returns The requested material.\n */\n getThreeMaterial(\n resourceName: string,\n {\n useTransparentTexture,\n forceBasicMaterial,\n }: { useTransparentTexture: boolean; forceBasicMaterial: boolean }\n ): THREE.Material {\n const cacheKey = `${resourceName}|${useTransparentTexture ? 1 : 0}|${\n forceBasicMaterial ? 1 : 0\n }`;\n\n const loadedThreeMaterial = this._loadedThreeMaterials.get(cacheKey);\n if (loadedThreeMaterial) return loadedThreeMaterial;\n\n const material = forceBasicMaterial\n ? new THREE.MeshBasicMaterial({\n map: this.getThreeTexture(resourceName),\n side: useTransparentTexture ? THREE.DoubleSide : THREE.FrontSide,\n transparent: useTransparentTexture,\n })\n : new THREE.MeshStandardMaterial({\n map: this.getThreeTexture(resourceName),\n side: useTransparentTexture ? THREE.DoubleSide : THREE.FrontSide,\n transparent: useTransparentTexture,\n metalness: 0,\n });\n this._loadedThreeMaterials.put(cacheKey, material);\n return material;\n }\n\n /**\n * Return the PIXI video texture associated to the specified resource name.\n * Returns a placeholder texture if not found.\n * @param resourceName The name of the resource to get.\n */\n getPIXIVideoTexture(resourceName: string) {\n if (resourceName === '') {\n return this._invalidTexture;\n }\n const resource = this._getImageResource(resourceName);\n if (!resource) {\n logger.warn(\n 'Unable to find video texture for resource \"' + resourceName + '\".'\n );\n return this._invalidTexture;\n }\n\n const texture = this._loadedTextures.get(resource);\n if (!texture) {\n return this._invalidTexture;\n }\n return texture;\n }\n\n private _getImageResource = (resourceName: string): ResourceData | null => {\n const resource = this._resourceLoader.getResource(resourceName);\n return resource && this.getResourceKinds().includes(resource.kind)\n ? resource\n : null;\n };\n\n /**\n * Return a PIXI texture which can be used as a placeholder when no\n * suitable texture can be found.\n */\n getInvalidPIXITexture() {\n return this._invalidTexture;\n }\n\n /**\n * Load the specified resources, so that textures are loaded and can then be\n * used by calling `getPIXITexture`.\n */\n async loadResource(resourceName: string): Promise<void> {\n const resource = this._resourceLoader.getResource(resourceName);\n if (!resource) {\n logger.warn(\n 'Unable to find texture for resource \"' + resourceName + '\".'\n );\n return;\n }\n await this._loadTexture(resource);\n }\n\n async processResource(resourceName: string): Promise<void> {\n // Do nothing because images are light enough to be parsed in background.\n }\n\n /**\n * Load the specified resources, so that textures are loaded and can then be\n * used by calling `getPIXITexture`.\n * @param onProgress Callback called each time a new file is loaded.\n */\n async _loadTexture(resource: ResourceData): Promise<void> {\n if (this._loadedTextures.get(resource)) {\n return;\n }\n try {\n if (resource.kind === 'video') {\n // For videos, we want to preload them so they are available as soon as we want to use them.\n // We cannot use Pixi.assets.load() as it does not allow passing options (autoplay) to the resource loader.\n // Pixi.Texture.from() does not return a promise, so we need to ensure we look at the 'loaded' event of the baseTexture,\n // to continue, otherwise if we try to play the video too soon (at the beginning of scene for instance),\n // it will fail.\n await new Promise<void>((resolve, reject) => {\n const texture = PIXI.Texture.from(\n this._resourceLoader.getFullUrl(resource.file),\n {\n resourceOptions: {\n crossorigin: this._resourceLoader.checkIfCredentialsRequired(\n resource.file\n )\n ? 'use-credentials'\n : 'anonymous',\n autoPlay: false,\n },\n }\n ).on('error', (error) => {\n reject(error);\n });\n\n const baseTexture = texture.baseTexture;\n baseTexture\n .on('loaded', () => {\n this._loadedTextures.set(resource, texture);\n applyTextureSettings(texture, resource);\n resolve();\n })\n .on('error', (error) => {\n reject(error);\n });\n });\n } else {\n // If the file has no extension, PIXI.assets.load cannot find\n // an adequate load parser and does not load the file although\n // we would like to force it to load (we are confident it's an image).\n // TODO: When PIXI v8+ is used, PIXI.Assets.load can be used because\n // loadParser can be forced in PIXI.Assets.load\n // (see https://github.com/pixijs/pixijs/blob/71ed56c569ebc6b53da19e3c49258a0a84892101/packages/assets/src/loader/Loader.ts#L68)\n const loadedTexture = PIXI.Texture.from(\n this._resourceLoader.getFullUrl(resource.file),\n {\n resourceOptions: {\n autoLoad: false,\n crossorigin: this._resourceLoader.checkIfCredentialsRequired(\n resource.file\n )\n ? 'use-credentials'\n : 'anonymous',\n },\n }\n );\n await loadedTexture.baseTexture.resource.load();\n\n this._loadedTextures.set(resource, loadedTexture);\n // TODO What if 2 assets share the same file with different settings?\n applyTextureSettings(loadedTexture, resource);\n }\n } catch (error) {\n logFileLoadingError(resource.file, error);\n }\n }\n\n /**\n * Return a texture containing a circle filled with white.\n * @param radius The circle radius\n * @param pixiRenderer The renderer used to generate the texture\n */\n getOrCreateDiskTexture(\n radius: float,\n pixiRenderer: PIXI.Renderer\n ): PIXI.Texture {\n let particleTexture = this._diskTextures.get(radius);\n if (!particleTexture) {\n const graphics = new PIXI.Graphics();\n graphics.lineStyle(0, 0, 0);\n graphics.beginFill(gdjs.rgbToHexNumber(255, 255, 255), 1);\n graphics.drawCircle(0, 0, radius);\n graphics.endFill();\n particleTexture = pixiRenderer.generateTexture(graphics);\n graphics.destroy();\n\n this._diskTextures.set(radius, particleTexture);\n }\n return particleTexture;\n }\n\n /**\n * Return a texture filled with white.\n * @param width The texture width\n * @param height The texture height\n * @param pixiRenderer The renderer used to generate the texture\n */\n getOrCreateRectangleTexture(\n width: float,\n height: float,\n pixiRenderer: PIXI.Renderer\n ): PIXI.Texture {\n const key = `${width}_${height}`;\n let particleTexture = this._rectangleTextures.get(key);\n if (!particleTexture) {\n const graphics = new PIXI.Graphics();\n graphics.lineStyle(0, 0, 0);\n graphics.beginFill(gdjs.rgbToHexNumber(255, 255, 255), 1);\n graphics.drawRect(0, 0, width, height);\n graphics.endFill();\n particleTexture = pixiRenderer.generateTexture(graphics);\n graphics.destroy();\n\n this._rectangleTextures.set(key, particleTexture);\n }\n return particleTexture;\n }\n\n /**\n * Return a texture rescaled according to given dimensions.\n * @param width The texture width\n * @param height The texture height\n * @param pixiRenderer The renderer used to generate the texture\n */\n getOrCreateScaledTexture(\n imageResourceName: string,\n width: float,\n height: float,\n pixiRenderer: PIXI.Renderer\n ): PIXI.Texture {\n const key = `${imageResourceName}_${width}_${height}`;\n let particleTexture = this._scaledTextures.get(key);\n if (!particleTexture) {\n const graphics = new PIXI.Graphics();\n const sprite = new PIXI.Sprite(this.getPIXITexture(imageResourceName));\n sprite.width = width;\n sprite.height = height;\n graphics.addChild(sprite);\n particleTexture = pixiRenderer.generateTexture(graphics);\n graphics.destroy();\n\n this._scaledTextures.set(key, particleTexture);\n }\n return particleTexture;\n }\n\n /**\n * To be called when the game is disposed.\n * Clear caches of loaded textures and materials.\n */\n dispose(): void {\n this._loadedTextures.clear();\n\n const threeTextures: THREE.Texture[] = [];\n this._loadedThreeTextures.values(threeTextures);\n this._loadedThreeTextures.clear();\n for (const threeTexture of threeTextures) {\n threeTexture.dispose();\n }\n\n const threeMaterials: THREE.Material[] = [];\n this._loadedThreeMaterials.values(threeMaterials);\n this._loadedThreeMaterials.clear();\n for (const threeMaterial of threeMaterials) {\n threeMaterial.dispose();\n }\n\n for (const pixiTexture of this._diskTextures.values()) {\n if (pixiTexture.destroyed) {\n continue;\n }\n\n pixiTexture.destroy();\n }\n this._diskTextures.clear();\n\n for (const pixiTexture of this._rectangleTextures.values()) {\n if (pixiTexture.destroyed) {\n continue;\n }\n\n pixiTexture.destroy();\n }\n this._rectangleTextures.clear();\n\n for (const pixiTexture of this._scaledTextures.values()) {\n if (pixiTexture.destroyed) {\n continue;\n }\n\n pixiTexture.destroy();\n }\n this._scaledTextures.clear();\n }\n }\n\n //Register the class to let the engine use it.\n export const ImageManager = gdjs.PixiImageManager;\n export type ImageManager = gdjs.PixiImageManager;\n}\n"],
|
|
5
|
-
"mappings": "AAKA,GAAU,MAAV,UAAU,EAAV,CACE,KAAM,GAAS,GAAI,GAAK,OAAO,sBAEzB,EAAsB,CAAC,EAAc,IAA6B,CACtE,EAAO,MACL,uBAAyB,EAAO,eAChC,GAAgB,oBAId,EAAuB,CAC3B,EACA,IACG,CACH,AAAI,CAAC,GAEA,EAAa,UAChB,GAAQ,YAAY,UAAY,KAAK,YAAY,UAI/C,EAA4B,CAChC,EACA,IACG,CACH,AAAI,GAAgB,CAAC,EAAa,UAChC,GAAa,UAAY,MAAM,cAC/B,EAAa,UAAY,MAAM,gBAI7B,EAAqC,CAAC,QAAS,SAK9C,OAAuD,CA4B5D,YAAY,EAAqC,CAlBzC,qBAAkB,GAAI,GAAK,cAQ3B,mBAAgB,GAAI,KACpB,wBAAqB,GAAI,KACzB,qBAAkB,GAAI,
|
|
4
|
+
"sourcesContent": ["/*\n * GDevelop JS Platform\n * Copyright 2013-2016 Florian Rival (Florian.Rival@gmail.com). All rights reserved.\n * This project is released under the MIT License.\n */\nnamespace gdjs {\n const logger = new gdjs.Logger('PIXI Image manager');\n\n const logFileLoadingError = (file: string, error: Error | undefined) => {\n logger.error(\n 'Unable to load file ' + file + ' with error:',\n error ? error : '(unknown error)'\n );\n };\n\n const applyTextureSettings = (\n texture: PIXI.Texture | undefined,\n resourceData: ResourceData\n ) => {\n if (!texture) return;\n\n if (!resourceData.smoothed) {\n texture.baseTexture.scaleMode = PIXI.SCALE_MODES.NEAREST;\n }\n };\n\n const applyThreeTextureSettings = (\n threeTexture: THREE.Texture,\n resourceData: ResourceData | null\n ) => {\n if (resourceData && !resourceData.smoothed) {\n threeTexture.magFilter = THREE.NearestFilter;\n threeTexture.minFilter = THREE.NearestFilter;\n }\n };\n\n const resourceKinds: Array<ResourceKind> = ['image', 'video'];\n\n /**\n * PixiImageManager loads and stores textures that can be used by the Pixi.js renderers.\n */\n export class PixiImageManager implements gdjs.ResourceManager {\n /**\n * The invalid texture is a 8x8 PNG file filled with magenta (#ff00ff), to be\n * easily spotted if rendered on screen.\n */\n private _invalidTexture: PIXI.Texture;\n\n /**\n * Map associating a resource name to the loaded PixiJS texture.\n */\n private _loadedTextures = new gdjs.ResourceCache<PIXI.Texture>();\n\n /**\n * Map associating a resource name to the loaded Three.js texture.\n */\n private _loadedThreeTextures: Hashtable<THREE.Texture>;\n private _loadedThreeMaterials: Hashtable<THREE.Material>;\n\n private _diskTextures = new Map<float, PIXI.Texture>();\n private _rectangleTextures = new Map<string, PIXI.Texture>();\n private _scaledTextures = new Map<string, PIXI.Texture>();\n\n private _resourceLoader: gdjs.ResourceLoader;\n\n /**\n * @param resources 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 this._invalidTexture = PIXI.Texture.from(\n 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMAAAADACAMAAABlApw1AAAAkFBMVEWdIvr///+hOfrx6v7i0/39/P+eK/rn2v6vbPv7+f/cx/359v/38v7s4v7Wvf3LqvzFnvysY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/TcB7e/uA7+03ZsJSaNOuAAAAAElFTkSuQmCC',\n { width: 192, height: 192 }\n );\n this._loadedThreeTextures = new Hashtable();\n this._loadedThreeMaterials = new Hashtable();\n }\n\n getResourceKinds(): ResourceKind[] {\n return resourceKinds;\n }\n\n /**\n * Return the PIXI texture associated to the specified resource name.\n * Returns a placeholder texture if not found.\n * @param resourceName The name of the resource\n * @returns The requested texture, or a placeholder if not found.\n */\n getPIXITexture(resourceName: string): PIXI.Texture {\n const resource = this._getImageResource(resourceName);\n if (!resource) {\n logger.warn(\n 'Unable to find texture for resource \"' + resourceName + '\".'\n );\n return this._invalidTexture;\n }\n\n const existingTexture = this._loadedTextures.get(resource);\n if (!existingTexture) {\n return this._invalidTexture;\n }\n if (!existingTexture.valid) {\n logger.error(\n 'Texture for ' +\n resourceName +\n ' is not valid anymore (or never was).'\n );\n return this._invalidTexture;\n }\n\n return existingTexture;\n }\n\n /**\n * Return the PIXI texture associated to the specified resource name.\n * If not found in the loaded textures, this method will try to load it.\n * Warning: this method should only be used in specific cases that cannot rely on\n * the initial resources loading of the game, such as the splashscreen.\n * @param resourceName The name of the resource\n * @returns The requested texture, or a placeholder if not valid.\n */\n getOrLoadPIXITexture(resourceName: string): PIXI.Texture {\n const resource = this._getImageResource(resourceName);\n if (!resource) {\n logger.warn(\n 'Unable to find texture for resource \"' + resourceName + '\".'\n );\n return this._invalidTexture;\n }\n\n const existingTexture = this._loadedTextures.get(resource);\n if (existingTexture) {\n if (existingTexture.valid) {\n return existingTexture;\n } else {\n logger.error(\n 'Texture for ' +\n resourceName +\n ' is not valid anymore (or never was).'\n );\n return this._invalidTexture;\n }\n }\n\n logger.log('Loading texture for resource \"' + resourceName + '\"...');\n const file = resource.file;\n const url = this._resourceLoader.getFullUrl(file);\n const texture = PIXI.Texture.from(url, {\n resourceOptions: {\n // Note that using `false`\n // to not having `crossorigin` at all would NOT work because the browser would taint the\n // loaded resource so that it can't be read/used in a canvas (it's only working for display `<img>` on screen).\n crossorigin: this._resourceLoader.checkIfCredentialsRequired(file)\n ? 'use-credentials'\n : 'anonymous',\n },\n }).on('error', (error) => {\n logFileLoadingError(file, error);\n });\n if (!texture) {\n throw new Error(\n 'Texture loading by PIXI returned nothing for file ' +\n file +\n ' behind url ' +\n url\n );\n }\n applyTextureSettings(texture, resource);\n\n this._loadedTextures.set(resource, texture);\n return texture;\n }\n\n /**\n * Return the three.js texture associated to the specified resource name.\n * Returns a placeholder texture if not found.\n * @param resourceName The name of the resource\n * @returns The requested texture, or a placeholder if not found.\n */\n getThreeTexture(resourceName: string): THREE.Texture {\n const loadedThreeTexture = this._loadedThreeTextures.get(resourceName);\n if (loadedThreeTexture) {\n return loadedThreeTexture;\n }\n\n // Texture is not loaded, load it now from the PixiJS texture.\n // TODO (3D) - optimization: don't load the PixiJS Texture if not used by PixiJS.\n // TODO (3D) - optimization: Ideally we could even share the same WebGL texture.\n const pixiTexture = this.getPIXITexture(resourceName);\n const pixiRenderer = this._resourceLoader._runtimeGame\n .getRenderer()\n .getPIXIRenderer();\n if (!pixiRenderer) throw new Error('No PIXI renderer was found.');\n\n // @ts-ignore - source does exist on resource.\n const image = pixiTexture.baseTexture.resource.source;\n if (!(image instanceof HTMLImageElement)) {\n throw new Error(\n `Can't load texture for resource \"${resourceName}\" as it's not an image.`\n );\n }\n\n const threeTexture = new THREE.Texture(image);\n threeTexture.magFilter = THREE.LinearFilter;\n threeTexture.minFilter = THREE.LinearFilter;\n threeTexture.wrapS = THREE.RepeatWrapping;\n threeTexture.wrapT = THREE.RepeatWrapping;\n threeTexture.colorSpace = THREE.SRGBColorSpace;\n threeTexture.needsUpdate = true;\n\n const resource = this._getImageResource(resourceName);\n\n applyThreeTextureSettings(threeTexture, resource);\n this._loadedThreeTextures.put(resourceName, threeTexture);\n\n return threeTexture;\n }\n\n /**\n * Return the three.js material associated to the specified resource name.\n * @param resourceName The name of the resource\n * @param options\n * @returns The requested material.\n */\n getThreeMaterial(\n resourceName: string,\n {\n useTransparentTexture,\n forceBasicMaterial,\n }: { useTransparentTexture: boolean; forceBasicMaterial: boolean }\n ): THREE.Material {\n const cacheKey = `${resourceName}|${useTransparentTexture ? 1 : 0}|${\n forceBasicMaterial ? 1 : 0\n }`;\n\n const loadedThreeMaterial = this._loadedThreeMaterials.get(cacheKey);\n if (loadedThreeMaterial) return loadedThreeMaterial;\n\n const material = forceBasicMaterial\n ? new THREE.MeshBasicMaterial({\n map: this.getThreeTexture(resourceName),\n side: useTransparentTexture ? THREE.DoubleSide : THREE.FrontSide,\n transparent: useTransparentTexture,\n })\n : new THREE.MeshStandardMaterial({\n map: this.getThreeTexture(resourceName),\n side: useTransparentTexture ? THREE.DoubleSide : THREE.FrontSide,\n transparent: useTransparentTexture,\n metalness: 0,\n });\n this._loadedThreeMaterials.put(cacheKey, material);\n return material;\n }\n\n /**\n * Return the PIXI video texture associated to the specified resource name.\n * Returns a placeholder texture if not found.\n * @param resourceName The name of the resource to get.\n */\n getPIXIVideoTexture(resourceName: string) {\n if (resourceName === '') {\n return this._invalidTexture;\n }\n const resource = this._getImageResource(resourceName);\n if (!resource) {\n logger.warn(\n 'Unable to find video texture for resource \"' + resourceName + '\".'\n );\n return this._invalidTexture;\n }\n\n const texture = this._loadedTextures.get(resource);\n if (!texture) {\n return this._invalidTexture;\n }\n return texture;\n }\n\n private _getImageResource = (resourceName: string): ResourceData | null => {\n const resource = this._resourceLoader.getResource(resourceName);\n return resource && this.getResourceKinds().includes(resource.kind)\n ? resource\n : null;\n };\n\n /**\n * Return a PIXI texture which can be used as a placeholder when no\n * suitable texture can be found.\n */\n getInvalidPIXITexture() {\n return this._invalidTexture;\n }\n\n /**\n * Load the specified resources, so that textures are loaded and can then be\n * used by calling `getPIXITexture`.\n */\n async loadResource(resourceName: string): Promise<void> {\n const resource = this._resourceLoader.getResource(resourceName);\n if (!resource) {\n logger.warn(\n 'Unable to find texture for resource \"' + resourceName + '\".'\n );\n return;\n }\n await this._loadTexture(resource);\n }\n\n async processResource(resourceName: string): Promise<void> {\n // Do nothing because images are light enough to be parsed in background.\n }\n\n /**\n * Load the specified resources, so that textures are loaded and can then be\n * used by calling `getPIXITexture`.\n * @param onProgress Callback called each time a new file is loaded.\n */\n async _loadTexture(resource: ResourceData): Promise<void> {\n if (this._loadedTextures.get(resource)) {\n return;\n }\n try {\n if (resource.kind === 'video') {\n // For videos, we want to preload them so they are available as soon as we want to use them.\n // We cannot use Pixi.assets.load() as it does not allow passing options (autoplay) to the resource loader.\n // Pixi.Texture.from() does not return a promise, so we need to ensure we look at the 'loaded' event of the baseTexture,\n // to continue, otherwise if we try to play the video too soon (at the beginning of scene for instance),\n // it will fail.\n await new Promise<void>((resolve, reject) => {\n const texture = PIXI.Texture.from(\n this._resourceLoader.getFullUrl(resource.file),\n {\n resourceOptions: {\n crossorigin: this._resourceLoader.checkIfCredentialsRequired(\n resource.file\n )\n ? 'use-credentials'\n : 'anonymous',\n autoPlay: false,\n },\n }\n ).on('error', (error) => {\n reject(error);\n });\n\n const baseTexture = texture.baseTexture;\n baseTexture\n .on('loaded', () => {\n this._loadedTextures.set(resource, texture);\n applyTextureSettings(texture, resource);\n resolve();\n })\n .on('error', (error) => {\n reject(error);\n });\n });\n } else {\n // If the file has no extension, PIXI.assets.load cannot find\n // an adequate load parser and does not load the file although\n // we would like to force it to load (we are confident it's an image).\n // TODO: When PIXI v8+ is used, PIXI.Assets.load can be used because\n // loadParser can be forced in PIXI.Assets.load\n // (see https://github.com/pixijs/pixijs/blob/71ed56c569ebc6b53da19e3c49258a0a84892101/packages/assets/src/loader/Loader.ts#L68)\n const loadedTexture = PIXI.Texture.from(\n this._resourceLoader.getFullUrl(resource.file),\n {\n resourceOptions: {\n autoLoad: false,\n crossorigin: this._resourceLoader.checkIfCredentialsRequired(\n resource.file\n )\n ? 'use-credentials'\n : 'anonymous',\n },\n }\n );\n await loadedTexture.baseTexture.resource.load();\n\n this._loadedTextures.set(resource, loadedTexture);\n // TODO What if 2 assets share the same file with different settings?\n applyTextureSettings(loadedTexture, resource);\n }\n } catch (error) {\n logFileLoadingError(resource.file, error);\n }\n }\n\n /**\n * Return a texture containing a circle filled with white.\n * @param radius The circle radius\n * @param pixiRenderer The renderer used to generate the texture\n */\n getOrCreateDiskTexture(\n radius: float,\n pixiRenderer: PIXI.Renderer\n ): PIXI.Texture {\n let particleTexture = this._diskTextures.get(radius);\n if (!particleTexture) {\n const graphics = new PIXI.Graphics();\n graphics.lineStyle(0, 0, 0);\n graphics.beginFill(gdjs.rgbToHexNumber(255, 255, 255), 1);\n graphics.drawCircle(0, 0, radius);\n graphics.endFill();\n particleTexture = pixiRenderer.generateTexture(graphics);\n graphics.destroy();\n\n this._diskTextures.set(radius, particleTexture);\n }\n return particleTexture;\n }\n\n /**\n * Return a texture filled with white.\n * @param width The texture width\n * @param height The texture height\n * @param pixiRenderer The renderer used to generate the texture\n */\n getOrCreateRectangleTexture(\n width: float,\n height: float,\n pixiRenderer: PIXI.Renderer\n ): PIXI.Texture {\n const key = `${width}_${height}`;\n let particleTexture = this._rectangleTextures.get(key);\n if (!particleTexture) {\n const graphics = new PIXI.Graphics();\n graphics.lineStyle(0, 0, 0);\n graphics.beginFill(gdjs.rgbToHexNumber(255, 255, 255), 1);\n graphics.drawRect(0, 0, width, height);\n graphics.endFill();\n particleTexture = pixiRenderer.generateTexture(graphics);\n graphics.destroy();\n\n this._rectangleTextures.set(key, particleTexture);\n }\n return particleTexture;\n }\n\n /**\n * Return a texture rescaled according to given dimensions.\n * @param width The texture width\n * @param height The texture height\n * @param pixiRenderer The renderer used to generate the texture\n */\n getOrCreateScaledTexture(\n imageResourceName: string,\n width: float,\n height: float,\n pixiRenderer: PIXI.Renderer\n ): PIXI.Texture {\n const key = `${imageResourceName}_${width}_${height}`;\n let particleTexture = this._scaledTextures.get(key);\n if (!particleTexture) {\n const graphics = new PIXI.Graphics();\n const sprite = new PIXI.Sprite(this.getPIXITexture(imageResourceName));\n sprite.width = width;\n sprite.height = height;\n graphics.addChild(sprite);\n particleTexture = pixiRenderer.generateTexture(graphics);\n graphics.destroy();\n\n this._scaledTextures.set(key, particleTexture);\n }\n return particleTexture;\n }\n\n /**\n * To be called when the game is disposed.\n * Clear caches of loaded textures and materials.\n */\n dispose(): void {\n this._loadedTextures.clear();\n\n const threeTextures: THREE.Texture[] = [];\n this._loadedThreeTextures.values(threeTextures);\n this._loadedThreeTextures.clear();\n for (const threeTexture of threeTextures) {\n threeTexture.dispose();\n }\n\n const threeMaterials: THREE.Material[] = [];\n this._loadedThreeMaterials.values(threeMaterials);\n this._loadedThreeMaterials.clear();\n for (const threeMaterial of threeMaterials) {\n threeMaterial.dispose();\n }\n\n for (const pixiTexture of this._diskTextures.values()) {\n if (pixiTexture.destroyed) {\n continue;\n }\n\n pixiTexture.destroy();\n }\n this._diskTextures.clear();\n\n for (const pixiTexture of this._rectangleTextures.values()) {\n if (pixiTexture.destroyed) {\n continue;\n }\n\n pixiTexture.destroy();\n }\n this._rectangleTextures.clear();\n\n for (const pixiTexture of this._scaledTextures.values()) {\n if (pixiTexture.destroyed) {\n continue;\n }\n\n pixiTexture.destroy();\n }\n this._scaledTextures.clear();\n }\n }\n\n //Register the class to let the engine use it.\n export const ImageManager = gdjs.PixiImageManager;\n export type ImageManager = gdjs.PixiImageManager;\n}\n"],
|
|
5
|
+
"mappings": "AAKA,GAAU,MAAV,UAAU,EAAV,CACE,KAAM,GAAS,GAAI,GAAK,OAAO,sBAEzB,EAAsB,CAAC,EAAc,IAA6B,CACtE,EAAO,MACL,uBAAyB,EAAO,eAChC,GAAgB,oBAId,EAAuB,CAC3B,EACA,IACG,CACH,AAAI,CAAC,GAEA,EAAa,UAChB,GAAQ,YAAY,UAAY,KAAK,YAAY,UAI/C,EAA4B,CAChC,EACA,IACG,CACH,AAAI,GAAgB,CAAC,EAAa,UAChC,GAAa,UAAY,MAAM,cAC/B,EAAa,UAAY,MAAM,gBAI7B,EAAqC,CAAC,QAAS,SAK9C,OAAuD,CA4B5D,YAAY,EAAqC,CAlBzC,qBAAk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"names": []
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var gdjs;(function(l){const u=new l.Logger("PIXI game renderer"),f=[37,38,39,40];class R{constructor(t,e){this._isFullPage=!0;this._isFullscreen=!1;this._pixiRenderer=null;this._threeRenderer=null;this._gameCanvas=null;this._domElementsContainer=null;this._canvasWidth=0;this._canvasHeight=0;this._keepRatio=!0;this._nextFrameId=0;this._wasDisposed=!1;this.getElectronRemote=()=>{if(typeof require=="function"){const t=this._game.getAdditionalOptions(),e=t&&t.electronRemoteRequirePath?t.electronRemoteRequirePath:"@electron/remote";try{return require(e)}catch(i){console.error(`Could not load @electron/remote from "${e}". Error is:`,i)}}return null};this._game=t,this._forceFullscreen=e,this._marginLeft=this._marginTop=this._marginRight=this._marginBottom=0,this._setupOrientation()}createStandardCanvas(t){this._throwIfDisposed();let e;typeof THREE!="undefined"?(e=document.createElement("canvas"),this._threeRenderer=new THREE.WebGLRenderer({canvas:e,antialias:this._game.getAntialiasingMode()!=="none"&&(this._game.isAntialisingEnabledOnMobile()||!l.evtTools.common.isMobile()),preserveDrawingBuffer:!0}),this._threeRenderer.useLegacyLights=!0,this._threeRenderer.autoClear=!1,this._threeRenderer.setSize(this._game.getGameResolutionWidth(),this._game.getGameResolutionHeight()),this._pixiRenderer=new PIXI.Renderer({width:this._game.getGameResolutionWidth(),height:this._game.getGameResolutionHeight(),view:e,context:this._threeRenderer.getContext(),clearBeforeRender:!1,preserveDrawingBuffer:!0,antialias:!1,backgroundAlpha:0}),e=this._threeRenderer.domElement):(this._pixiRenderer=PIXI.autoDetectRenderer({width:this._game.getGameResolutionWidth(),height:this._game.getGameResolutionHeight(),preserveDrawingBuffer:!0,antialias:!1}),e=this._pixiRenderer.view),this._pixiRenderer.plugins.accessibility.destroy(),delete this._pixiRenderer.plugins.accessibility,t.appendChild(e),this._gameCanvas=e,e.style.position="absolute",e.tabIndex=1,e.style.userSelect="none",e.style.outline="none";const i=document.createElement("div");i.style.position="absolute",i.style.overflow="hidden",i.style.outline="none",i.style.pointerEvents="none",i.addEventListener("scroll",s=>{i.scrollLeft=0,i.scrollTop=0,s.preventDefault()}),e.addEventListener("pointerdown",()=>{e.focus()}),i.style["-webkit-user-select"]="none",t.appendChild(i),this._domElementsContainer=i,this._resizeCanvas(),this._game.getScaleMode()==="nearest"&&(e.style["image-rendering"]="-moz-crisp-edges",e.style["image-rendering"]="-webkit-optimize-contrast",e.style["image-rendering"]="-webkit-crisp-edges",e.style["image-rendering"]="pixelated"),this._game.getPixelsRounding()&&(PIXI.settings.ROUND_PIXELS=!0),window.addEventListener("resize",()=>{this._game.onWindowInnerSizeChanged(),this._resizeCanvas()}),e.focus()}static getWindowInnerWidth(){return typeof window!="undefined"?window.innerWidth:800}static getWindowInnerHeight(){return typeof window!="undefined"?window.innerHeight:800}updateRendererSize(){this._resizeCanvas()}_setupOrientation(){if(typeof window=="undefined"||!window.screen||!window.screen.orientation)return;const t=this._game.getGameData().properties.orientation;try{if(t==="default"){const e=window.screen.orientation.unlock();e&&e.catch(()=>{})}else window.screen.orientation.lock(t).catch(()=>{})}catch(e){u.error("Unexpected error while setting up orientation: ",e)}}_resizeCanvas(){if(!this._pixiRenderer||!this._domElementsContainer)return;(this._pixiRenderer.width!==this._game.getGameResolutionWidth()||this._pixiRenderer.height!==this._game.getGameResolutionHeight())&&(this._pixiRenderer.resize(this._game.getGameResolutionWidth(),this._game.getGameResolutionHeight()),this._threeRenderer&&this._threeRenderer.setSize(this._game.getGameResolutionWidth(),this._game.getGameResolutionHeight()));const t=this._forceFullscreen||this._isFullPage||this._isFullscreen;let e=this._game.getGameResolutionWidth(),i=this._game.getGameResolutionHeight(),s=window.innerWidth-this._marginLeft-this._marginRight,r=window.innerHeight-this._marginTop-this._marginBottom;if(s<0&&(s=0),r<0&&(r=0),t&&!this._keepRatio)e=s,i=r;else if(t&&this._keepRatio||e>s||i>r){let d=s/e;i*d>r&&(d=r/i),e*=d,i*=d}this._gameCanvas&&(this._gameCanvas.style.top=this._marginTop+(r-i)/2+"px",this._gameCanvas.style.left=this._marginLeft+(s-e)/2+"px",this._gameCanvas.style.width=e+"px",this._gameCanvas.style.height=i+"px"),this._domElementsContainer.style.top=this._marginTop+(r-i)/2+"px",this._domElementsContainer.style.left=this._marginLeft+(s-e)/2+"px",this._domElementsContainer.style.width=e+"px",this._domElementsContainer.style.height=i+"px",this._canvasWidth=e,this._canvasHeight=i}keepAspectRatio(t){this._keepRatio!==t&&(this._keepRatio=t,this._resizeCanvas())}setMargins(t,e,i,s){this._throwIfDisposed(),!(this._marginTop===t&&this._marginRight===e&&this._marginBottom===i&&this._marginLeft===s)&&(this._marginTop=t,this._marginRight=e,this._marginBottom=i,this._marginLeft=s,this._resizeCanvas())}setWindowSize(t,e){this._throwIfDisposed();const i=this.getElectronRemote();if(i){const s=i.getCurrentWindow();try{s&&s.setContentSize(t,e)}catch(r){u.error(`Window size setting to width ${t} and height ${e} failed. See error:`,r)}}else u.warn("Window size can't be changed on this platform.")}centerWindow(){this._throwIfDisposed();const t=this.getElectronRemote();if(t){const e=t.getCurrentWindow();try{e&&e.center()}catch(i){u.error("Window centering failed. See error:",i)}}else u.warn("Window can't be centered on this platform.")}setFullScreen(t){if(this._throwIfDisposed(),!this._forceFullscreen&&this._isFullscreen!==t){this._isFullscreen=!!t;const e=this.getElectronRemote();if(e){const i=e.getCurrentWindow();try{i&&i.setFullScreen(this._isFullscreen)}catch(s){u.error(`Full screen setting to ${this._isFullscreen} failed. See error:`,s)}}else this._isFullscreen?document.documentElement.requestFullscreen?document.documentElement.requestFullscreen():document.documentElement.mozRequestFullScreen?document.documentElement.mozRequestFullScreen():document.documentElement.webkitRequestFullScreen&&document.documentElement.webkitRequestFullScreen():document.exitFullscreen?document.exitFullscreen():document.mozCancelFullScreen?document.mozCancelFullScreen():document.webkitCancelFullScreen&&document.webkitCancelFullScreen();this._resizeCanvas()}}isFullScreen(){const t=this.getElectronRemote();if(t)try{return t.getCurrentWindow().isFullScreen()}catch(e){return u.error("Full screen detection failed. See error:",e),!1}return this._isFullscreen||window.screen.height===window.innerHeight}convertCanvasToDomElementContainerCoords(t,e){const i=e||[0,0];return i[0]=t[0]*this._canvasWidth/this._game.getGameResolutionWidth(),i[1]=t[1]*this._canvasHeight/this._game.getGameResolutionHeight(),i}getCanvasToDomElementContainerHeightScale(){return(this._canvasHeight||1)/this._game.getGameResolutionHeight()}bindStandardEvents(t,e,i){this._throwIfDisposed();const s=this._gameCanvas;if(!s)return;const r=n=>{const o=[n.pageX-s.offsetLeft,n.pageY-s.offsetTop];return o[0]*=this._game.getGameResolutionWidth()/(this._canvasWidth||1),o[1]*=this._game.getGameResolutionHeight()/(this._canvasHeight||1),o},d=n=>{const o=n.pageX-s.offsetLeft,a=n.pageY-s.offsetTop;return 0<=o&&o<(this._canvasWidth||1)&&0<=a&&a<(this._canvasHeight||1)};(function(){isNaN(s.offsetLeft)&&(s.offsetLeft=0,s.offsetTop=0),isNaN(i.body.scrollLeft)&&(i.body.scrollLeft=0,i.body.scrollTop=0),(i.documentElement===void 0||i.documentElement===null)&&(i.documentElement={}),isNaN(i.documentElement.scrollLeft)&&(i.documentElement.scrollLeft=0,i.documentElement.scrollTop=0),isNaN(s.offsetLeft)&&(s.offsetLeft=0,s.offsetTop=0)})();const m=()=>!(i.activeElement===s||i.activeElement===i.body||i.activeElement===null),h=n=>!(n.target===s||n.target===i.body);i.onkeydown=function(n){m()||(f.includes(n.keyCode)&&n.preventDefault(),t.onKeyPressed(n.keyCode,n.location))},i.onkeyup=function(n){m()||(f.includes(n.keyCode)&&n.preventDefault(),t.onKeyReleased(n.keyCode,n.location))};function g(n){switch(n){case 1:return l.InputManager.MOUSE_MIDDLE_BUTTON;case 2:return l.InputManager.MOUSE_RIGHT_BUTTON}return n}s.onmousemove=function(n){const o=r(n);t.onMouseMove(o[0],o[1])},s.onmousedown=function(n){return t.onMouseButtonPressed(g(n.button)),e.focus!==void 0&&e.focus(),!1},s.onmouseup=function(n){return t.onMouseButtonReleased(g(n.button)),!1},s.onmouseleave=function(n){t.onMouseLeave()},s.onmouseenter=function(n){t.onMouseEnter();const o=[l.InputManager.MOUSE_LEFT_BUTTON,l.InputManager.MOUSE_RIGHT_BUTTON,l.InputManager.MOUSE_MIDDLE_BUTTON,l.InputManager.MOUSE_BACK_BUTTON,l.InputManager.MOUSE_FORWARD_BUTTON];for(let a=0,v=o.length;a<v;++a){const c=o[a],p=(n.buttons&1<<a)!=0,_=t.isMouseButtonPressed(c);p&&!_?t.onMouseButtonPressed(c):!p&&_&&t.onMouseButtonReleased(c)}},e.addEventListener("click",function(n){return e.focus!==void 0&&e.focus(),!1},!1),s.oncontextmenu=function(n){return n.preventDefault(),n.stopPropagation(),!1},s.onwheel=function(n){t.onMouseWheel(-n.deltaY)},e.addEventListener("touchmove",function(n){if(!h(n)&&(n.preventDefault(),n.changedTouches))for(let o=0;o<n.changedTouches.length;++o){const a=r(n.changedTouches[o]);t.onTouchMove(n.changedTouches[o].identifier,a[0],a[1]),t.isSimulatingMouseWithTouch()&&(d(n.changedTouches[o])?t.onMouseEnter():t.onMouseLeave())}},{passive:!1}),e.addEventListener("touchstart",function(n){if(!h(n)){if(n.preventDefault(),n.changedTouches)for(let o=0;o<n.changedTouches.length;++o){const a=r(n.changedTouches[o]);t.onTouchStart(n.changedTouches[o].identifier,a[0],a[1])}return!1}},{passive:!1}),e.addEventListener("touchend",function(n){if(!h(n)){if(n.preventDefault(),n.changedTouches)for(let o=0;o<n.changedTouches.length;++o)t.onTouchEnd(n.changedTouches[o].identifier);return!1}},{passive:!1}),e.addEventListener("touchcancel",function(n){if(!h(n)){if(n.preventDefault(),n.changedTouches)for(let o=0;o<n.changedTouches.length;++o)t.onTouchCancel(n.changedTouches[o].identifier);return!1}},{passive:!1})}setWindowTitle(t){typeof document!="undefined"&&(document.title=t)}getWindowTitle(){return typeof document!="undefined"?document.title:""}startGameLoop(t){this._throwIfDisposed();let e=0;const i=s=>{this._nextFrameId=requestAnimationFrame(i);const r=e?s-e:0;e=s,t(r)||cancelAnimationFrame(this._nextFrameId)};requestAnimationFrame(i)}stopGameLoop(){cancelAnimationFrame(this._nextFrameId)}getPIXIRenderer(){return this._pixiRenderer}getThreeRenderer(){return this._threeRenderer}getDomElementContainer(){return this._domElementsContainer}openURL(t){if(typeof window!="undefined"){const e=this.getElectron();e?e.shell.openExternal(t):typeof window.cordova!="undefined"&&typeof window.cordova.InAppBrowser!="undefined"?window.cordova.InAppBrowser.open(t,"_system","location=yes"):window.open(t,"_blank")}}stopGame(){const t=this.getElectronRemote();if(t){const e=t.getCurrentWindow();if(e)try{e.close()}catch(i){u.error("Window closing failed. See error:",i)}}else typeof navigator!="undefined"&&navigator.app&&navigator.app.exitApp&&navigator.app.exitApp()}dispose(){this._pixiRenderer?.destroy(!0),this._threeRenderer?.dispose(),this._pixiRenderer=null,this._threeRenderer=null,this._gameCanvas=null,this._domElementsContainer=null,this._wasDisposed=!0}getCanvas(){return this._gameCanvas}isWebGLSupported(){return!!this._pixiRenderer&&this._pixiRenderer.type===PIXI.RENDERER_TYPE.WEBGL}getElectron(){return typeof require=="function"?require("electron"):null}getGame(){return this._game}_throwIfDisposed(){if(this._wasDisposed)throw"The RuntimeGameRenderer has been disposed and should not be used anymore."}}l.RuntimeGamePixiRenderer=R,l.RuntimeGameRenderer=R})(gdjs||(gdjs={}));
|
|
1
|
+
var gdjs;(function(l){const u=new l.Logger("PIXI game renderer"),f=[37,38,39,40];class R{constructor(e,t){this._isFullPage=!0;this._isFullscreen=!1;this._pixiRenderer=null;this._threeRenderer=null;this._gameCanvas=null;this._domElementsContainer=null;this._canvasWidth=0;this._canvasHeight=0;this._keepRatio=!0;this._nextFrameId=0;this._wasDisposed=!1;this.getElectronRemote=()=>{if(typeof require=="function"){const e=this._game.getAdditionalOptions(),t=e&&e.electronRemoteRequirePath?e.electronRemoteRequirePath:"@electron/remote";try{return require(t)}catch(i){console.error(`Could not load @electron/remote from "${t}". Error is:`,i)}}return null};this._game=e,this._forceFullscreen=t,this._marginLeft=this._marginTop=this._marginRight=this._marginBottom=0,this._setupOrientation()}createStandardCanvas(e){this._throwIfDisposed();const t=document.createElement("canvas");e.appendChild(t),this.initializeRenderers(t),this.initializeCanvas(t)}initializeRenderers(e){this._throwIfDisposed(),typeof THREE!="undefined"?(this._threeRenderer=new THREE.WebGLRenderer({canvas:e,antialias:this._game.getAntialiasingMode()!=="none"&&(this._game.isAntialisingEnabledOnMobile()||!l.evtTools.common.isMobile()),preserveDrawingBuffer:!0}),this._threeRenderer.useLegacyLights=!0,this._threeRenderer.autoClear=!1,this._threeRenderer.setSize(this._game.getGameResolutionWidth(),this._game.getGameResolutionHeight()),this._pixiRenderer=new PIXI.Renderer({width:this._game.getGameResolutionWidth(),height:this._game.getGameResolutionHeight(),view:e,context:this._threeRenderer.getContext(),clearBeforeRender:!1,preserveDrawingBuffer:!0,antialias:!1,backgroundAlpha:0})):this._pixiRenderer=PIXI.autoDetectRenderer({width:this._game.getGameResolutionWidth(),height:this._game.getGameResolutionHeight(),view:e,preserveDrawingBuffer:!0,antialias:!1}),this._pixiRenderer.plugins.accessibility.destroy(),delete this._pixiRenderer.plugins.accessibility}initializeCanvas(e){this._gameCanvas=e,e.style.position="absolute",e.tabIndex=1,e.style.userSelect="none",e.style.outline="none";const t=document.createElement("div");t.style.position="absolute",t.style.overflow="hidden",t.style.outline="none",t.style.pointerEvents="none",t.addEventListener("scroll",i=>{t.scrollLeft=0,t.scrollTop=0,i.preventDefault()}),e.addEventListener("pointerdown",()=>{e.focus()}),t.style["-webkit-user-select"]="none",e.parentNode?.appendChild(t),this._domElementsContainer=t,this._resizeCanvas(),this._game.getScaleMode()==="nearest"&&(e.style["image-rendering"]="-moz-crisp-edges",e.style["image-rendering"]="-webkit-optimize-contrast",e.style["image-rendering"]="-webkit-crisp-edges",e.style["image-rendering"]="pixelated"),this._game.getPixelsRounding()&&(PIXI.settings.ROUND_PIXELS=!0),window.addEventListener("resize",()=>{this._game.onWindowInnerSizeChanged(),this._resizeCanvas()}),e.focus()}static getWindowInnerWidth(){return typeof window!="undefined"?window.innerWidth:800}static getWindowInnerHeight(){return typeof window!="undefined"?window.innerHeight:800}updateRendererSize(){this._resizeCanvas()}_setupOrientation(){if(typeof window=="undefined"||!window.screen||!window.screen.orientation)return;const e=this._game.getGameData().properties.orientation;try{if(e==="default"){const t=window.screen.orientation.unlock();t&&t.catch(()=>{})}else window.screen.orientation.lock(e).catch(()=>{})}catch(t){u.error("Unexpected error while setting up orientation: ",t)}}_resizeCanvas(){if(!this._pixiRenderer||!this._domElementsContainer)return;(this._pixiRenderer.width!==this._game.getGameResolutionWidth()||this._pixiRenderer.height!==this._game.getGameResolutionHeight())&&(this._pixiRenderer.resize(this._game.getGameResolutionWidth(),this._game.getGameResolutionHeight()),this._threeRenderer&&this._threeRenderer.setSize(this._game.getGameResolutionWidth(),this._game.getGameResolutionHeight()));const e=this._forceFullscreen||this._isFullPage||this._isFullscreen;let t=this._game.getGameResolutionWidth(),i=this._game.getGameResolutionHeight(),o=window.innerWidth-this._marginLeft-this._marginRight,r=window.innerHeight-this._marginTop-this._marginBottom;if(o<0&&(o=0),r<0&&(r=0),e&&!this._keepRatio)t=o,i=r;else if(e&&this._keepRatio||t>o||i>r){let d=o/t;i*d>r&&(d=r/i),t*=d,i*=d}this._gameCanvas&&(this._gameCanvas.style.top=this._marginTop+(r-i)/2+"px",this._gameCanvas.style.left=this._marginLeft+(o-t)/2+"px",this._gameCanvas.style.width=t+"px",this._gameCanvas.style.height=i+"px"),this._domElementsContainer.style.top=this._marginTop+(r-i)/2+"px",this._domElementsContainer.style.left=this._marginLeft+(o-t)/2+"px",this._domElementsContainer.style.width=t+"px",this._domElementsContainer.style.height=i+"px",this._canvasWidth=t,this._canvasHeight=i}keepAspectRatio(e){this._keepRatio!==e&&(this._keepRatio=e,this._resizeCanvas())}setMargins(e,t,i,o){this._throwIfDisposed(),!(this._marginTop===e&&this._marginRight===t&&this._marginBottom===i&&this._marginLeft===o)&&(this._marginTop=e,this._marginRight=t,this._marginBottom=i,this._marginLeft=o,this._resizeCanvas())}setWindowSize(e,t){this._throwIfDisposed();const i=this.getElectronRemote();if(i){const o=i.getCurrentWindow();try{o&&o.setContentSize(e,t)}catch(r){u.error(`Window size setting to width ${e} and height ${t} failed. See error:`,r)}}else u.warn("Window size can't be changed on this platform.")}centerWindow(){this._throwIfDisposed();const e=this.getElectronRemote();if(e){const t=e.getCurrentWindow();try{t&&t.center()}catch(i){u.error("Window centering failed. See error:",i)}}else u.warn("Window can't be centered on this platform.")}setFullScreen(e){if(this._throwIfDisposed(),!this._forceFullscreen&&this._isFullscreen!==e){this._isFullscreen=!!e;const t=this.getElectronRemote();if(t){const i=t.getCurrentWindow();try{i&&i.setFullScreen(this._isFullscreen)}catch(o){u.error(`Full screen setting to ${this._isFullscreen} failed. See error:`,o)}}else this._isFullscreen?document.documentElement.requestFullscreen?document.documentElement.requestFullscreen():document.documentElement.mozRequestFullScreen?document.documentElement.mozRequestFullScreen():document.documentElement.webkitRequestFullScreen&&document.documentElement.webkitRequestFullScreen():document.exitFullscreen?document.exitFullscreen():document.mozCancelFullScreen?document.mozCancelFullScreen():document.webkitCancelFullScreen&&document.webkitCancelFullScreen();this._resizeCanvas()}}isFullScreen(){const e=this.getElectronRemote();if(e)try{return e.getCurrentWindow().isFullScreen()}catch(t){return u.error("Full screen detection failed. See error:",t),!1}return this._isFullscreen||window.screen.height===window.innerHeight}convertCanvasToDomElementContainerCoords(e,t){const i=t||[0,0];return i[0]=e[0]*this._canvasWidth/this._game.getGameResolutionWidth(),i[1]=e[1]*this._canvasHeight/this._game.getGameResolutionHeight(),i}getCanvasToDomElementContainerHeightScale(){return(this._canvasHeight||1)/this._game.getGameResolutionHeight()}bindStandardEvents(e,t,i){this._throwIfDisposed();const o=this._gameCanvas;if(!o)return;const r=n=>{const s=[n.pageX-o.offsetLeft,n.pageY-o.offsetTop];return s[0]*=this._game.getGameResolutionWidth()/(this._canvasWidth||1),s[1]*=this._game.getGameResolutionHeight()/(this._canvasHeight||1),s},d=n=>{const s=n.pageX-o.offsetLeft,a=n.pageY-o.offsetTop;return 0<=s&&s<(this._canvasWidth||1)&&0<=a&&a<(this._canvasHeight||1)};(function(){isNaN(o.offsetLeft)&&(o.offsetLeft=0,o.offsetTop=0),isNaN(i.body.scrollLeft)&&(i.body.scrollLeft=0,i.body.scrollTop=0),(i.documentElement===void 0||i.documentElement===null)&&(i.documentElement={}),isNaN(i.documentElement.scrollLeft)&&(i.documentElement.scrollLeft=0,i.documentElement.scrollTop=0),isNaN(o.offsetLeft)&&(o.offsetLeft=0,o.offsetTop=0)})();const m=()=>!(i.activeElement===o||i.activeElement===i.body||i.activeElement===null),h=n=>!(n.target===o||n.target===i.body);i.onkeydown=function(n){m()||(f.includes(n.keyCode)&&n.preventDefault(),e.onKeyPressed(n.keyCode,n.location))},i.onkeyup=function(n){m()||(f.includes(n.keyCode)&&n.preventDefault(),e.onKeyReleased(n.keyCode,n.location))};function g(n){switch(n){case 1:return l.InputManager.MOUSE_MIDDLE_BUTTON;case 2:return l.InputManager.MOUSE_RIGHT_BUTTON}return n}o.onmousemove=function(n){const s=r(n);e.onMouseMove(s[0],s[1])},o.onmousedown=function(n){return e.onMouseButtonPressed(g(n.button)),t.focus!==void 0&&t.focus(),!1},o.onmouseup=function(n){return e.onMouseButtonReleased(g(n.button)),!1},o.onmouseleave=function(n){e.onMouseLeave()},o.onmouseenter=function(n){e.onMouseEnter();const s=[l.InputManager.MOUSE_LEFT_BUTTON,l.InputManager.MOUSE_RIGHT_BUTTON,l.InputManager.MOUSE_MIDDLE_BUTTON,l.InputManager.MOUSE_BACK_BUTTON,l.InputManager.MOUSE_FORWARD_BUTTON];for(let a=0,v=s.length;a<v;++a){const c=s[a],p=(n.buttons&1<<a)!=0,_=e.isMouseButtonPressed(c);p&&!_?e.onMouseButtonPressed(c):!p&&_&&e.onMouseButtonReleased(c)}},t.addEventListener("click",function(n){return t.focus!==void 0&&t.focus(),!1},!1),o.oncontextmenu=function(n){return n.preventDefault(),n.stopPropagation(),!1},o.onwheel=function(n){e.onMouseWheel(-n.deltaY)},t.addEventListener("touchmove",function(n){if(!h(n)&&(n.preventDefault(),n.changedTouches))for(let s=0;s<n.changedTouches.length;++s){const a=r(n.changedTouches[s]);e.onTouchMove(n.changedTouches[s].identifier,a[0],a[1]),e.isSimulatingMouseWithTouch()&&(d(n.changedTouches[s])?e.onMouseEnter():e.onMouseLeave())}},{passive:!1}),t.addEventListener("touchstart",function(n){if(!h(n)){if(n.preventDefault(),n.changedTouches)for(let s=0;s<n.changedTouches.length;++s){const a=r(n.changedTouches[s]);e.onTouchStart(n.changedTouches[s].identifier,a[0],a[1])}return!1}},{passive:!1}),t.addEventListener("touchend",function(n){if(!h(n)){if(n.preventDefault(),n.changedTouches)for(let s=0;s<n.changedTouches.length;++s)e.onTouchEnd(n.changedTouches[s].identifier);return!1}},{passive:!1}),t.addEventListener("touchcancel",function(n){if(!h(n)){if(n.preventDefault(),n.changedTouches)for(let s=0;s<n.changedTouches.length;++s)e.onTouchCancel(n.changedTouches[s].identifier);return!1}},{passive:!1})}setWindowTitle(e){typeof document!="undefined"&&(document.title=e)}getWindowTitle(){return typeof document!="undefined"?document.title:""}startGameLoop(e){this._throwIfDisposed();let t=0;const i=o=>{this._nextFrameId=requestAnimationFrame(i);const r=t?o-t:0;t=o,e(r)||cancelAnimationFrame(this._nextFrameId)};requestAnimationFrame(i)}stopGameLoop(){cancelAnimationFrame(this._nextFrameId)}getPIXIRenderer(){return this._pixiRenderer}getThreeRenderer(){return this._threeRenderer}getDomElementContainer(){return this._domElementsContainer}openURL(e){if(typeof window!="undefined"){const t=this.getElectron();t?t.shell.openExternal(e):typeof window.cordova!="undefined"&&typeof window.cordova.InAppBrowser!="undefined"?window.cordova.InAppBrowser.open(e,"_system","location=yes"):window.open(e,"_blank")}}stopGame(){const e=this.getElectronRemote();if(e){const t=e.getCurrentWindow();if(t)try{t.close()}catch(i){u.error("Window closing failed. See error:",i)}}else typeof navigator!="undefined"&&navigator.app&&navigator.app.exitApp&&navigator.app.exitApp()}dispose(e){this._pixiRenderer?.destroy(),this._threeRenderer?.dispose(),this._pixiRenderer=null,this._threeRenderer=null,e&&this._gameCanvas&&this._gameCanvas.parentNode?.removeChild(this._gameCanvas),this._gameCanvas=null,this._domElementsContainer?.parentNode?.removeChild(this._domElementsContainer),this._domElementsContainer=null,this._wasDisposed=!0}getCanvas(){return this._gameCanvas}isWebGLSupported(){return!!this._pixiRenderer&&this._pixiRenderer.type===PIXI.RENDERER_TYPE.WEBGL}getElectron(){return typeof require=="function"?require("electron"):null}getGame(){return this._game}_throwIfDisposed(){if(this._wasDisposed)throw"The RuntimeGameRenderer has been disposed and should not be used anymore."}}l.RuntimeGamePixiRenderer=R,l.RuntimeGameRenderer=R})(gdjs||(gdjs={}));
|
|
2
2
|
//# sourceMappingURL=runtimegame-pixi-renderer.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../GDevelop/GDJS/Runtime/pixi-renderers/runtimegame-pixi-renderer.ts"],
|
|
4
|
-
"sourcesContent": ["namespace gdjs {\n const logger = new gdjs.Logger('PIXI game renderer');\n\n /**\n * Codes (as in `event.code`) of keys that should have their event `preventDefault`\n * called. This is used to avoid scrolling in a webpage when these keys are pressed\n * in the game.\n */\n const defaultPreventedKeyCodes = [\n 37, // ArrowLeft\n 38, // ArrowUp\n 39, // ArrowRight\n 40, // ArrowDown\n ];\n\n /**\n * The renderer for a gdjs.RuntimeGame using Pixi.js.\n */\n export class RuntimeGamePixiRenderer {\n _game: gdjs.RuntimeGame;\n _isFullPage: boolean = true;\n\n //Used to track if the canvas is displayed on the full page.\n _isFullscreen: boolean = false;\n\n //Used to track if the window is displayed as fullscreen (see setFullscreen method).\n _forceFullscreen: any;\n\n _pixiRenderer: PIXI.Renderer | null = null;\n private _threeRenderer: THREE.WebGLRenderer | null = null;\n private _gameCanvas: HTMLCanvasElement | null = null;\n private _domElementsContainer: HTMLDivElement | null = null;\n\n // Current width of the canvas (might be scaled down/up compared to renderer)\n _canvasWidth: float = 0;\n // Current height of the canvas (might be scaled down/up compared to renderer)\n _canvasHeight: float = 0;\n\n _keepRatio: boolean = true;\n _marginLeft: any;\n _marginTop: any;\n _marginRight: any;\n _marginBottom: any;\n\n _nextFrameId: integer = 0;\n\n _wasDisposed: boolean = false;\n\n /**\n * @param game The game that is being rendered\n * @param forceFullscreen If fullscreen should be always activated\n */\n constructor(game: gdjs.RuntimeGame, forceFullscreen: boolean) {\n this._game = game;\n this._forceFullscreen = forceFullscreen;\n\n //If set to true, the canvas will always be displayed as fullscreen, even if _isFullscreen == false.\n this._marginLeft = this._marginTop = this._marginRight = this._marginBottom = 0;\n this._setupOrientation();\n }\n\n /**\n * Create a standard canvas inside canvasArea.\n *\n */\n createStandardCanvas(parentElement: HTMLElement) {\n this._throwIfDisposed();\n\n let gameCanvas: HTMLCanvasElement;\n if (typeof THREE !== 'undefined') {\n gameCanvas = document.createElement('canvas');\n this._threeRenderer = new THREE.WebGLRenderer({\n canvas: gameCanvas,\n antialias:\n this._game.getAntialiasingMode() !== 'none' &&\n (this._game.isAntialisingEnabledOnMobile() ||\n !gdjs.evtTools.common.isMobile()),\n preserveDrawingBuffer: true, // Keep to true to allow screenshots.\n });\n this._threeRenderer.useLegacyLights = true;\n this._threeRenderer.autoClear = false;\n this._threeRenderer.setSize(\n this._game.getGameResolutionWidth(),\n this._game.getGameResolutionHeight()\n );\n\n // Create a PixiJS renderer that use the same GL context as Three.js\n // so that both can render to the canvas and even have PixiJS rendering\n // reused in Three.js (by using a RenderTexture and the same internal WebGL texture).\n this._pixiRenderer = new PIXI.Renderer({\n width: this._game.getGameResolutionWidth(),\n height: this._game.getGameResolutionHeight(),\n view: gameCanvas,\n // @ts-ignore - reuse the context from Three.js.\n context: this._threeRenderer.getContext(),\n clearBeforeRender: false,\n preserveDrawingBuffer: true, // Keep to true to allow screenshots.\n antialias: false,\n backgroundAlpha: 0,\n // TODO (3D): add a setting for pixel ratio (`resolution: window.devicePixelRatio`)\n });\n\n gameCanvas = this._threeRenderer.domElement;\n } else {\n // Create the renderer and setup the rendering area.\n // \"preserveDrawingBuffer: true\" is needed to avoid flickering\n // and background issues on some mobile phones (see #585 #572 #566 #463).\n this._pixiRenderer = PIXI.autoDetectRenderer({\n width: this._game.getGameResolutionWidth(),\n height: this._game.getGameResolutionHeight(),\n preserveDrawingBuffer: true,\n antialias: false,\n }) as PIXI.Renderer;\n\n gameCanvas = this._pixiRenderer.view as HTMLCanvasElement;\n }\n\n // Deactivating accessibility support in PixiJS renderer, as we want to be in control of this.\n // See https://github.com/pixijs/pixijs/issues/5111#issuecomment-420047824\n this._pixiRenderer.plugins.accessibility.destroy();\n delete this._pixiRenderer.plugins.accessibility;\n\n // Add the renderer view element to the DOM\n parentElement.appendChild(gameCanvas);\n this._gameCanvas = gameCanvas;\n\n gameCanvas.style.position = 'absolute';\n\n // Ensure that the canvas has the focus.\n gameCanvas.tabIndex = 1;\n\n // Ensure long press can't create a selection\n gameCanvas.style.userSelect = 'none';\n gameCanvas.style.outline = 'none'; // No selection/focus ring on the canvas.\n\n // Set up the container for HTML elements on top of the game canvas.\n const domElementsContainer = document.createElement('div');\n domElementsContainer.style.position = 'absolute';\n domElementsContainer.style.overflow = 'hidden'; // Never show anything outside the container.\n domElementsContainer.style.outline = 'none'; // No selection/focus ring on this container.\n domElementsContainer.style.pointerEvents = 'none'; // Clicks go through the container.\n\n // The container should *never* scroll.\n // Elements are put inside with the same coordinates (with a scaling factor)\n // as on the game canvas.\n domElementsContainer.addEventListener('scroll', (event) => {\n domElementsContainer.scrollLeft = 0;\n domElementsContainer.scrollTop = 0;\n event.preventDefault();\n });\n\n // When clicking outside an input, (or other HTML element),\n // give back focus to the game canvas so that this element is blurred.\n gameCanvas.addEventListener('pointerdown', () => {\n gameCanvas.focus();\n });\n\n // Prevent magnifying glass on iOS with a long press.\n // Note that there are related bugs on iOS 15 (see https://bugs.webkit.org/show_bug.cgi?id=231161)\n // but it seems not to affect us as the `domElementsContainer` has `pointerEvents` set to `none`.\n domElementsContainer.style['-webkit-user-select'] = 'none';\n\n parentElement.appendChild(domElementsContainer);\n this._domElementsContainer = domElementsContainer;\n\n this._resizeCanvas();\n\n // Handle scale mode.\n if (this._game.getScaleMode() === 'nearest') {\n gameCanvas.style['image-rendering'] = '-moz-crisp-edges';\n gameCanvas.style['image-rendering'] = '-webkit-optimize-contrast';\n gameCanvas.style['image-rendering'] = '-webkit-crisp-edges';\n gameCanvas.style['image-rendering'] = 'pixelated';\n }\n\n // Handle pixels rounding.\n if (this._game.getPixelsRounding()) {\n PIXI.settings.ROUND_PIXELS = true;\n }\n\n // Handle resize: immediately adjust the game canvas (and dom element container)\n // and notify the game (that may want to adjust to the new size of the window).\n window.addEventListener('resize', () => {\n this._game.onWindowInnerSizeChanged();\n this._resizeCanvas();\n });\n\n // Focus the canvas when created.\n gameCanvas.focus();\n }\n\n static getWindowInnerWidth() {\n return typeof window !== 'undefined' ? window.innerWidth : 800;\n }\n\n static getWindowInnerHeight() {\n return typeof window !== 'undefined' ? window.innerHeight : 800;\n }\n\n /**\n * Update the game renderer size according to the \"game resolution\".\n * Called when game resolution changes.\n *\n * Note that if the canvas is fullscreen, it won't be resized, but when going back to\n * non fullscreen mode, the requested size will be used.\n */\n updateRendererSize(): void {\n this._resizeCanvas();\n }\n\n /**\n * Set the proper screen orientation from the project properties.\n */\n private _setupOrientation() {\n if (\n typeof window === 'undefined' ||\n !window.screen ||\n !window.screen.orientation\n ) {\n return;\n }\n const gameOrientation = this._game.getGameData().properties.orientation;\n try {\n // We ignore the error as some platforms may not supporting locking (i.e: desktop).\n if (gameOrientation === 'default') {\n const promise = window.screen.orientation.unlock();\n // @ts-ignore\n if (promise) {\n // @ts-ignore\n promise.catch(() => {});\n }\n } else {\n // @ts-ignore\n window.screen.orientation.lock(gameOrientation).catch(() => {});\n }\n } catch (error) {\n logger.error('Unexpected error while setting up orientation: ', error);\n }\n }\n\n /**\n * Resize the renderer (the \"game resolution\") and the canvas (which can be larger\n * or smaller to fill the page, with optional margins).\n *\n */\n private _resizeCanvas() {\n if (!this._pixiRenderer || !this._domElementsContainer) return;\n\n // Set the Pixi (and/or Three) renderer size to the game size.\n // There is no \"smart\" resizing to be done here: the rendering of the game\n // should be done with the size set on the game.\n if (\n this._pixiRenderer.width !== this._game.getGameResolutionWidth() ||\n this._pixiRenderer.height !== this._game.getGameResolutionHeight()\n ) {\n // TODO (3D): It might be useful to resize pixi view in 3D depending on FOV value\n // to enable a mode where pixi always fills the whole screen.\n this._pixiRenderer.resize(\n this._game.getGameResolutionWidth(),\n this._game.getGameResolutionHeight()\n );\n\n if (this._threeRenderer) {\n this._threeRenderer.setSize(\n this._game.getGameResolutionWidth(),\n this._game.getGameResolutionHeight()\n );\n }\n }\n\n // Set the canvas size.\n // Resizing is done according to the settings. This is a \"CSS\" resize\n // only, so won't create visual artifacts during the rendering.\n const isFullPage =\n this._forceFullscreen || this._isFullPage || this._isFullscreen;\n let canvasWidth = this._game.getGameResolutionWidth();\n let canvasHeight = this._game.getGameResolutionHeight();\n let maxWidth = window.innerWidth - this._marginLeft - this._marginRight;\n let maxHeight = window.innerHeight - this._marginTop - this._marginBottom;\n if (maxWidth < 0) {\n maxWidth = 0;\n }\n if (maxHeight < 0) {\n maxHeight = 0;\n }\n if (isFullPage && !this._keepRatio) {\n canvasWidth = maxWidth;\n canvasHeight = maxHeight;\n } else {\n if (\n (isFullPage && this._keepRatio) ||\n canvasWidth > maxWidth ||\n canvasHeight > maxHeight\n ) {\n let factor = maxWidth / canvasWidth;\n if (canvasHeight * factor > maxHeight) {\n factor = maxHeight / canvasHeight;\n }\n canvasWidth *= factor;\n canvasHeight *= factor;\n }\n }\n\n // Apply the calculations to the canvas element...\n if (this._gameCanvas) {\n this._gameCanvas.style.top =\n this._marginTop + (maxHeight - canvasHeight) / 2 + 'px';\n this._gameCanvas.style.left =\n this._marginLeft + (maxWidth - canvasWidth) / 2 + 'px';\n this._gameCanvas.style.width = canvasWidth + 'px';\n this._gameCanvas.style.height = canvasHeight + 'px';\n }\n\n // ...and to the div on top of it showing DOM elements (like inputs).\n this._domElementsContainer.style.top =\n this._marginTop + (maxHeight - canvasHeight) / 2 + 'px';\n this._domElementsContainer.style.left =\n this._marginLeft + (maxWidth - canvasWidth) / 2 + 'px';\n this._domElementsContainer.style.width = canvasWidth + 'px';\n this._domElementsContainer.style.height = canvasHeight + 'px';\n\n // Store the canvas size for fast access to it.\n this._canvasWidth = canvasWidth;\n this._canvasHeight = canvasHeight;\n }\n\n /**\n * Set if the aspect ratio must be kept when the game canvas is resized to fill\n * the page.\n */\n keepAspectRatio(enable) {\n if (this._keepRatio === enable) {\n return;\n }\n this._keepRatio = enable;\n this._resizeCanvas();\n }\n\n /**\n * Change the margin that must be preserved around the game canvas.\n */\n setMargins(top, right, bottom, left): void {\n this._throwIfDisposed();\n if (\n this._marginTop === top &&\n this._marginRight === right &&\n this._marginBottom === bottom &&\n this._marginLeft === left\n ) {\n return;\n }\n this._marginTop = top;\n this._marginRight = right;\n this._marginBottom = bottom;\n this._marginLeft = left;\n this._resizeCanvas();\n }\n\n /**\n * Update the window size, if possible.\n * @param width The new width, in pixels.\n * @param height The new height, in pixels.\n */\n setWindowSize(width: float, height: float): void {\n this._throwIfDisposed();\n const remote = this.getElectronRemote();\n if (remote) {\n const browserWindow = remote.getCurrentWindow();\n try {\n if (browserWindow) {\n browserWindow.setContentSize(width, height);\n }\n } catch (error) {\n logger.error(\n `Window size setting to width ${width} and height ${height} failed. See error:`,\n error\n );\n }\n } else {\n logger.warn(\"Window size can't be changed on this platform.\");\n }\n }\n\n /**\n * Center the window on screen.\n */\n centerWindow() {\n this._throwIfDisposed();\n const remote = this.getElectronRemote();\n if (remote) {\n const browserWindow = remote.getCurrentWindow();\n try {\n if (browserWindow) {\n browserWindow.center();\n }\n } catch (error) {\n logger.error('Window centering failed. See error:', error);\n }\n } else {\n logger.warn(\"Window can't be centered on this platform.\");\n }\n }\n\n /**\n * De/activate fullscreen for the game.\n */\n setFullScreen(enable): void {\n this._throwIfDisposed();\n if (this._forceFullscreen) {\n return;\n }\n if (this._isFullscreen !== enable) {\n this._isFullscreen = !!enable;\n const remote = this.getElectronRemote();\n if (remote) {\n const browserWindow = remote.getCurrentWindow();\n try {\n if (browserWindow) {\n browserWindow.setFullScreen(this._isFullscreen);\n }\n } catch (error) {\n logger.error(\n `Full screen setting to ${this._isFullscreen} failed. See error:`,\n error\n );\n }\n } else {\n // Use HTML5 Fullscreen API\n //TODO: Do this on a user gesture, otherwise most browsers won't activate fullscreen\n if (this._isFullscreen) {\n // @ts-ignore\n if (document.documentElement.requestFullscreen) {\n // @ts-ignore\n document.documentElement.requestFullscreen();\n } else {\n // @ts-ignore\n if (document.documentElement.mozRequestFullScreen) {\n // @ts-ignore\n document.documentElement.mozRequestFullScreen();\n } else {\n // @ts-ignore\n if (document.documentElement.webkitRequestFullScreen) {\n // @ts-ignore\n document.documentElement.webkitRequestFullScreen();\n }\n }\n }\n } else {\n // @ts-ignore\n if (document.exitFullscreen) {\n // @ts-ignore\n document.exitFullscreen();\n } else {\n // @ts-ignore\n if (document.mozCancelFullScreen) {\n // @ts-ignore\n document.mozCancelFullScreen();\n } else {\n // @ts-ignore\n if (document.webkitCancelFullScreen) {\n // @ts-ignore\n document.webkitCancelFullScreen();\n }\n }\n }\n }\n }\n this._resizeCanvas();\n }\n }\n\n /**\n * Checks if the game is in full screen.\n */\n isFullScreen(): boolean {\n const remote = this.getElectronRemote();\n if (remote) {\n try {\n return remote.getCurrentWindow().isFullScreen();\n } catch (error) {\n logger.error(`Full screen detection failed. See error:`, error);\n return false;\n }\n }\n\n // Height check is used to detect user triggered full screen (for example F11 shortcut).\n return this._isFullscreen || window.screen.height === window.innerHeight;\n }\n\n /**\n * Convert a point from the canvas coordinates to the dom element container coordinates.\n *\n * @param canvasCoords The point in the canvas coordinates.\n * @param result The point to return.\n * @returns The point in the dom element container coordinates.\n */\n convertCanvasToDomElementContainerCoords(\n canvasCoords: FloatPoint,\n result: FloatPoint\n ): FloatPoint {\n const pageCoords = result || [0, 0];\n\n // Handle the fact that the game is stretched to fill the canvas.\n pageCoords[0] =\n (canvasCoords[0] * this._canvasWidth) /\n this._game.getGameResolutionWidth();\n pageCoords[1] =\n (canvasCoords[1] * this._canvasHeight) /\n this._game.getGameResolutionHeight();\n\n return pageCoords;\n }\n\n /**\n * Return the scale factor between the renderer height and the actual canvas height,\n * which is also the height of the container for DOM elements to be superimposed on top of it.\n *\n * Useful to scale font sizes of DOM elements so that they follow the size of the game.\n */\n getCanvasToDomElementContainerHeightScale(): float {\n return (this._canvasHeight || 1) / this._game.getGameResolutionHeight();\n }\n\n /**\n * Add the standard events handler.\n */\n bindStandardEvents(\n manager: gdjs.InputManager,\n window: Window,\n document: Document\n ) {\n this._throwIfDisposed();\n const canvas = this._gameCanvas;\n if (!canvas) return;\n\n //Translate an event (mouse or touch) made on the canvas on the page\n //to game coordinates.\n const getEventPosition = (e: MouseEvent | Touch) => {\n const pos = [e.pageX - canvas.offsetLeft, e.pageY - canvas.offsetTop];\n\n // Handle the fact that the game is stretched to fill the canvas.\n pos[0] *=\n this._game.getGameResolutionWidth() / (this._canvasWidth || 1);\n pos[1] *=\n this._game.getGameResolutionHeight() / (this._canvasHeight || 1);\n return pos;\n };\n\n const isInsideCanvas = (e: MouseEvent | Touch) => {\n const x = e.pageX - canvas.offsetLeft;\n const y = e.pageY - canvas.offsetTop;\n\n return (\n 0 <= x &&\n x < (this._canvasWidth || 1) &&\n 0 <= y &&\n y < (this._canvasHeight || 1)\n );\n };\n\n //Some browsers lacks definition of some variables used to do calculations\n //in getEventPosition. They are defined to 0 as they are useless.\n\n (function ensureOffsetsExistence() {\n if (isNaN(canvas.offsetLeft)) {\n // @ts-ignore\n canvas.offsetLeft = 0;\n // @ts-ignore\n canvas.offsetTop = 0;\n }\n if (isNaN(document.body.scrollLeft)) {\n document.body.scrollLeft = 0;\n document.body.scrollTop = 0;\n }\n if (\n document.documentElement === undefined ||\n document.documentElement === null\n ) {\n // @ts-ignore\n document.documentElement = {};\n }\n if (isNaN(document.documentElement.scrollLeft)) {\n document.documentElement.scrollLeft = 0;\n document.documentElement.scrollTop = 0;\n }\n if (isNaN(canvas.offsetLeft)) {\n // @ts-ignore\n canvas.offsetLeft = 0;\n // @ts-ignore\n canvas.offsetTop = 0;\n }\n })();\n\n // Keyboard: listen at the document level to capture even when the canvas\n // is not focused.\n\n const isFocusingDomElement = () => {\n // Fast bailout when the game canvas should receive the inputs (i.e: almost always).\n // Also check the document body or null for activeElement, as all of these should go\n // to the game.\n if (\n document.activeElement === canvas ||\n document.activeElement === document.body ||\n document.activeElement === null\n )\n return false;\n\n return true;\n };\n const isTargetDomElement = (event: TouchEvent) => {\n // Fast bailout when the game canvas should receive the inputs (i.e: almost always).\n // Any event with a target that is not the body or the canvas should\n // not go to the game (<input> or <a> elements for instances).\n if (event.target === canvas || event.target === document.body)\n return false;\n return true;\n };\n document.onkeydown = function (e) {\n if (isFocusingDomElement()) {\n // Bail out if the game canvas is not focused. For example,\n // an `<input>` element can be focused, and needs to receive\n // arrow keys events.\n return;\n }\n\n if (defaultPreventedKeyCodes.includes(e.keyCode)) {\n // Some keys are \"default prevented\" to avoid scrolling when the game\n // is integrated in a page as an iframe.\n e.preventDefault();\n }\n\n manager.onKeyPressed(e.keyCode, e.location);\n };\n document.onkeyup = function (e) {\n if (isFocusingDomElement()) {\n // Bail out if the game canvas is not focused. For example,\n // an `<input>` element can be focused, and needs to receive\n // arrow keys events.\n return;\n }\n\n if (defaultPreventedKeyCodes.includes(e.keyCode)) {\n // Some keys are \"default prevented\" to avoid scrolling when the game\n // is integrated in a page as an iframe.\n e.preventDefault();\n }\n\n manager.onKeyReleased(e.keyCode, e.location);\n };\n\n // Mouse:\n\n // Converts HTML mouse button to InputManager mouse button.\n // This function is used to align HTML button values with GDevelop 3 C++ SFML Mouse button enum values,\n // notably the middle and right buttons.\n function convertHtmlMouseButtonToInputManagerMouseButton(button: number) {\n switch (button) {\n case 1: // Middle button\n return gdjs.InputManager.MOUSE_MIDDLE_BUTTON;\n case 2: // Right button\n return gdjs.InputManager.MOUSE_RIGHT_BUTTON;\n }\n return button;\n }\n canvas.onmousemove = function (e) {\n const pos = getEventPosition(e);\n manager.onMouseMove(pos[0], pos[1]);\n };\n canvas.onmousedown = function (e) {\n manager.onMouseButtonPressed(\n convertHtmlMouseButtonToInputManagerMouseButton(e.button)\n );\n if (window.focus !== undefined) {\n window.focus();\n }\n return false;\n };\n canvas.onmouseup = function (e) {\n manager.onMouseButtonReleased(\n convertHtmlMouseButtonToInputManagerMouseButton(e.button)\n );\n return false;\n };\n canvas.onmouseleave = function (e) {\n manager.onMouseLeave();\n };\n canvas.onmouseenter = function (e) {\n manager.onMouseEnter();\n // There is no mouse event when the cursor is outside of the canvas.\n // We catchup what happened.\n const buttons = [\n gdjs.InputManager.MOUSE_LEFT_BUTTON,\n gdjs.InputManager.MOUSE_RIGHT_BUTTON,\n gdjs.InputManager.MOUSE_MIDDLE_BUTTON,\n gdjs.InputManager.MOUSE_BACK_BUTTON,\n gdjs.InputManager.MOUSE_FORWARD_BUTTON,\n ];\n for (let i = 0, len = buttons.length; i < len; ++i) {\n const button = buttons[i];\n const buttonIsPressed = (e.buttons & (1 << i)) !== 0;\n const buttonWasPressed = manager.isMouseButtonPressed(button);\n if (buttonIsPressed && !buttonWasPressed) {\n manager.onMouseButtonPressed(button);\n } else if (!buttonIsPressed && buttonWasPressed) {\n manager.onMouseButtonReleased(button);\n }\n }\n };\n window.addEventListener(\n 'click',\n function (e) {\n if (window.focus !== undefined) {\n window.focus();\n }\n return false;\n },\n false\n );\n canvas.oncontextmenu = function (event) {\n event.preventDefault();\n event.stopPropagation();\n return false;\n };\n // @ts-ignore\n canvas.onwheel = function (event) {\n manager.onMouseWheel(-event.deltaY);\n };\n\n // Touches:\n window.addEventListener(\n 'touchmove',\n function (e) {\n if (isTargetDomElement(e)) {\n // Bail out if the game canvas is not focused. For example,\n // an `<input>` element can be focused, and needs to receive\n // touch events to move the selection (and do other native gestures).\n return;\n }\n\n e.preventDefault();\n if (e.changedTouches) {\n for (let i = 0; i < e.changedTouches.length; ++i) {\n const pos = getEventPosition(e.changedTouches[i]);\n manager.onTouchMove(\n e.changedTouches[i].identifier,\n pos[0],\n pos[1]\n );\n // This works because touch events are sent\n // when they continue outside of the canvas.\n if (manager.isSimulatingMouseWithTouch()) {\n if (isInsideCanvas(e.changedTouches[i])) {\n manager.onMouseEnter();\n } else {\n manager.onMouseLeave();\n }\n }\n }\n }\n },\n // This is important so that we can use e.preventDefault() and block possible following mouse events.\n { passive: false }\n );\n window.addEventListener(\n 'touchstart',\n function (e) {\n if (isTargetDomElement(e)) {\n // Bail out if the game canvas is not focused. For example,\n // an `<input>` element can be focused, and needs to receive\n // touch events to move the selection (and do other native gestures).\n return;\n }\n\n e.preventDefault();\n if (e.changedTouches) {\n for (let i = 0; i < e.changedTouches.length; ++i) {\n const pos = getEventPosition(e.changedTouches[i]);\n manager.onTouchStart(\n e.changedTouches[i].identifier,\n pos[0],\n pos[1]\n );\n }\n }\n return false;\n },\n // This is important so that we can use e.preventDefault() and block possible following mouse events.\n { passive: false }\n );\n window.addEventListener(\n 'touchend',\n function (e) {\n if (isTargetDomElement(e)) {\n // Bail out if the game canvas is not focused. For example,\n // an `<input>` element can be focused, and needs to receive\n // touch events to move the selection (and do other native gestures).\n return;\n }\n\n e.preventDefault();\n if (e.changedTouches) {\n for (let i = 0; i < e.changedTouches.length; ++i) {\n manager.onTouchEnd(e.changedTouches[i].identifier);\n }\n }\n return false;\n },\n // This is important so that we can use e.preventDefault() and block possible following mouse events.\n { passive: false }\n );\n window.addEventListener(\n 'touchcancel',\n function (e) {\n if (isTargetDomElement(e)) {\n // Bail out if the game canvas is not focused. For example,\n // an `<input>` element can be focused, and needs to receive\n // touch events to move the selection (and do other native gestures).\n return;\n }\n\n e.preventDefault();\n if (e.changedTouches) {\n for (let i = 0; i < e.changedTouches.length; ++i) {\n manager.onTouchCancel(e.changedTouches[i].identifier);\n }\n }\n return false;\n },\n // This is important so that we can use e.preventDefault() and block possible following mouse events.\n { passive: false }\n );\n }\n\n setWindowTitle(title): void {\n if (typeof document !== 'undefined') {\n document.title = title;\n }\n }\n\n getWindowTitle() {\n return typeof document !== 'undefined' ? document.title : '';\n }\n\n startGameLoop(fn) {\n this._throwIfDisposed();\n let oldTime = 0;\n const gameLoop = (time: float) => {\n // Schedule the next frame now to be sure it's called as soon\n // as possible after this one is finished.\n this._nextFrameId = requestAnimationFrame(gameLoop);\n\n const dt = oldTime ? time - oldTime : 0;\n oldTime = time;\n if (!fn(dt)) {\n // Stop the game loop if requested.\n cancelAnimationFrame(this._nextFrameId);\n }\n };\n\n requestAnimationFrame(gameLoop);\n }\n\n stopGameLoop(): void {\n cancelAnimationFrame(this._nextFrameId);\n }\n\n getPIXIRenderer() {\n return this._pixiRenderer;\n }\n\n /**\n * Get the Three.js renderer for the game - if any.\n */\n getThreeRenderer(): THREE.WebGLRenderer | null {\n return this._threeRenderer;\n }\n\n /**\n * Get the DOM element used as a container for HTML elements to display\n * on top of the game.\n */\n getDomElementContainer() {\n return this._domElementsContainer;\n }\n\n /**\n * Open the given URL in the system browser (or a new tab)\n */\n openURL(url: string) {\n // Try to detect the environment to use the most adapted\n // way of opening an URL.\n\n if (typeof window !== 'undefined') {\n const electron = this.getElectron();\n if (electron) {\n electron.shell.openExternal(url);\n } else if (\n // @ts-ignore\n typeof window.cordova !== 'undefined' &&\n // @ts-ignore\n typeof window.cordova.InAppBrowser !== 'undefined'\n ) {\n // @ts-ignore\n window.cordova.InAppBrowser.open(url, '_system', 'location=yes');\n } else {\n window.open(url, '_blank');\n }\n }\n }\n\n /**\n * Close the game, if applicable.\n */\n stopGame() {\n // Try to detect the environment to use the most adapted\n // way of closing the app\n const remote = this.getElectronRemote();\n if (remote) {\n const browserWindow = remote.getCurrentWindow();\n if (browserWindow) {\n try {\n browserWindow.close();\n } catch (error) {\n logger.error('Window closing failed. See error:', error);\n }\n }\n } else {\n if (\n typeof navigator !== 'undefined' &&\n // @ts-ignore\n navigator.app &&\n // @ts-ignore\n navigator.app.exitApp\n ) {\n // @ts-ignore\n navigator.app.exitApp();\n }\n }\n // HTML5 games on mobile/browsers don't have a way to close their window/page.\n }\n\n /**\n * Dispose PixiRenderer, ThreeRenderer and remove canvas from DOM.\n */\n dispose() {\n this._pixiRenderer?.destroy(true);\n this._threeRenderer?.dispose();\n this._pixiRenderer = null;\n this._threeRenderer = null;\n this._gameCanvas = null;\n this._domElementsContainer = null;\n this._wasDisposed = true;\n }\n\n /**\n * Get the canvas DOM element.\n */\n getCanvas(): HTMLCanvasElement | null {\n return this._gameCanvas;\n }\n\n /**\n * Check if the device supports WebGL.\n * @returns true if WebGL is supported\n */\n isWebGLSupported(): boolean {\n return (\n !!this._pixiRenderer &&\n this._pixiRenderer.type === PIXI.RENDERER_TYPE.WEBGL\n );\n }\n\n /**\n * Get the electron module, if running as a electron renderer process.\n */\n getElectron() {\n if (typeof require === 'function') {\n return require('electron');\n }\n return null;\n }\n\n /**\n * Helper to get the electron remote module, if running on Electron.\n * Note that is not guaranteed to be supported in the future - avoid if possible.\n */\n getElectronRemote = () => {\n if (typeof require === 'function') {\n const runtimeGameOptions = this._game.getAdditionalOptions();\n const moduleId =\n runtimeGameOptions && runtimeGameOptions.electronRemoteRequirePath\n ? runtimeGameOptions.electronRemoteRequirePath\n : '@electron/remote';\n\n try {\n return require(moduleId);\n } catch (requireError) {\n console.error(\n `Could not load @electron/remote from \"${moduleId}\". Error is:`,\n requireError\n );\n }\n }\n\n return null;\n };\n\n getGame() {\n return this._game;\n }\n\n private _throwIfDisposed(): void {\n if (this._wasDisposed) {\n throw 'The RuntimeGameRenderer has been disposed and should not be used anymore.';\n }\n }\n }\n\n //Register the class to let the engine use it.\n export type RuntimeGameRenderer = RuntimeGamePixiRenderer;\n export const RuntimeGameRenderer = RuntimeGamePixiRenderer;\n}\n"],
|
|
5
|
-
"mappings": "AAAA,GAAU,MAAV,UAAU,EAAV,CACE,KAAM,GAAS,GAAI,GAAK,OAAO,sBAOzB,EAA2B,CAC/B,GACA,GACA,GACA,IAMK,OAA8B,CAkCnC,YAAY,EAAwB,EAA0B,CAhC9D,iBAAuB,GAGvB,mBAAyB,GAKzB,mBAAsC,KAC9B,oBAA6C,KAC7C,iBAAwC,KACxC,2BAA+C,KAGvD,kBAAsB,EAEtB,mBAAuB,EAEvB,gBAAsB,GAMtB,kBAAwB,EAExB,kBAAwB,
|
|
4
|
+
"sourcesContent": ["namespace gdjs {\n const logger = new gdjs.Logger('PIXI game renderer');\n\n /**\n * Codes (as in `event.code`) of keys that should have their event `preventDefault`\n * called. This is used to avoid scrolling in a webpage when these keys are pressed\n * in the game.\n */\n const defaultPreventedKeyCodes = [\n 37, // ArrowLeft\n 38, // ArrowUp\n 39, // ArrowRight\n 40, // ArrowDown\n ];\n\n /**\n * The renderer for a gdjs.RuntimeGame using Pixi.js.\n */\n export class RuntimeGamePixiRenderer {\n _game: gdjs.RuntimeGame;\n _isFullPage: boolean = true;\n\n //Used to track if the canvas is displayed on the full page.\n _isFullscreen: boolean = false;\n\n //Used to track if the window is displayed as fullscreen (see setFullscreen method).\n _forceFullscreen: any;\n\n _pixiRenderer: PIXI.Renderer | null = null;\n private _threeRenderer: THREE.WebGLRenderer | null = null;\n private _gameCanvas: HTMLCanvasElement | null = null;\n private _domElementsContainer: HTMLDivElement | null = null;\n\n // Current width of the canvas (might be scaled down/up compared to renderer)\n _canvasWidth: float = 0;\n // Current height of the canvas (might be scaled down/up compared to renderer)\n _canvasHeight: float = 0;\n\n _keepRatio: boolean = true;\n _marginLeft: any;\n _marginTop: any;\n _marginRight: any;\n _marginBottom: any;\n\n _nextFrameId: integer = 0;\n\n _wasDisposed: boolean = false;\n\n /**\n * @param game The game that is being rendered\n * @param forceFullscreen If fullscreen should be always activated\n */\n constructor(game: gdjs.RuntimeGame, forceFullscreen: boolean) {\n this._game = game;\n this._forceFullscreen = forceFullscreen;\n\n //If set to true, the canvas will always be displayed as fullscreen, even if _isFullscreen == false.\n this._marginLeft = this._marginTop = this._marginRight = this._marginBottom = 0;\n this._setupOrientation();\n }\n\n /**\n * Create the canvas on which the game will be rendered, inside the specified DOM element, and\n * setup the rendering of the game.\n * If you want to use your own canvas, use `initializeRenderers` and `initializeCanvas` instead.\n *\n * @param parentElement The parent element to which the canvas will be added.\n */\n createStandardCanvas(parentElement: HTMLElement) {\n this._throwIfDisposed();\n\n const gameCanvas = document.createElement('canvas');\n parentElement.appendChild(gameCanvas);\n\n this.initializeRenderers(gameCanvas);\n this.initializeCanvas(gameCanvas);\n }\n\n /**\n * Set up the rendering of the game for the given canvas.\n *\n * In most cases, you can use `createStandardCanvas` instead to initialize the game.\n */\n initializeRenderers(gameCanvas: HTMLCanvasElement): void {\n this._throwIfDisposed();\n\n if (typeof THREE !== 'undefined') {\n this._threeRenderer = new THREE.WebGLRenderer({\n canvas: gameCanvas,\n antialias:\n this._game.getAntialiasingMode() !== 'none' &&\n (this._game.isAntialisingEnabledOnMobile() ||\n !gdjs.evtTools.common.isMobile()),\n preserveDrawingBuffer: true, // Keep to true to allow screenshots.\n });\n this._threeRenderer.useLegacyLights = true;\n this._threeRenderer.autoClear = false;\n this._threeRenderer.setSize(\n this._game.getGameResolutionWidth(),\n this._game.getGameResolutionHeight()\n );\n\n // Create a PixiJS renderer that use the same GL context as Three.js\n // so that both can render to the canvas and even have PixiJS rendering\n // reused in Three.js (by using a RenderTexture and the same internal WebGL texture).\n this._pixiRenderer = new PIXI.Renderer({\n width: this._game.getGameResolutionWidth(),\n height: this._game.getGameResolutionHeight(),\n view: gameCanvas,\n // @ts-ignore - reuse the context from Three.js.\n context: this._threeRenderer.getContext(),\n clearBeforeRender: false,\n preserveDrawingBuffer: true, // Keep to true to allow screenshots.\n antialias: false,\n backgroundAlpha: 0,\n // TODO (3D): add a setting for pixel ratio (`resolution: window.devicePixelRatio`)\n });\n } else {\n // Create the renderer and setup the rendering area.\n // \"preserveDrawingBuffer: true\" is needed to avoid flickering\n // and background issues on some mobile phones (see #585 #572 #566 #463).\n this._pixiRenderer = PIXI.autoDetectRenderer({\n width: this._game.getGameResolutionWidth(),\n height: this._game.getGameResolutionHeight(),\n view: gameCanvas,\n preserveDrawingBuffer: true,\n antialias: false,\n }) as PIXI.Renderer;\n }\n\n // Deactivating accessibility support in PixiJS renderer, as we want to be in control of this.\n // See https://github.com/pixijs/pixijs/issues/5111#issuecomment-420047824\n this._pixiRenderer.plugins.accessibility.destroy();\n delete this._pixiRenderer.plugins.accessibility;\n }\n\n /**\n * Set up the game canvas so that it covers the size required by the game\n * and has a container for DOM elements required by the game.\n */\n initializeCanvas(gameCanvas: HTMLCanvasElement): void {\n // Add the renderer view element to the DOM\n this._gameCanvas = gameCanvas;\n\n gameCanvas.style.position = 'absolute';\n\n // Ensure that the canvas has the focus.\n gameCanvas.tabIndex = 1;\n\n // Ensure long press can't create a selection\n gameCanvas.style.userSelect = 'none';\n gameCanvas.style.outline = 'none'; // No selection/focus ring on the canvas.\n\n // Set up the container for HTML elements on top of the game canvas.\n const domElementsContainer = document.createElement('div');\n domElementsContainer.style.position = 'absolute';\n domElementsContainer.style.overflow = 'hidden'; // Never show anything outside the container.\n domElementsContainer.style.outline = 'none'; // No selection/focus ring on this container.\n domElementsContainer.style.pointerEvents = 'none'; // Clicks go through the container.\n\n // The container should *never* scroll.\n // Elements are put inside with the same coordinates (with a scaling factor)\n // as on the game canvas.\n domElementsContainer.addEventListener('scroll', (event) => {\n domElementsContainer.scrollLeft = 0;\n domElementsContainer.scrollTop = 0;\n event.preventDefault();\n });\n\n // When clicking outside an input, (or other HTML element),\n // give back focus to the game canvas so that this element is blurred.\n gameCanvas.addEventListener('pointerdown', () => {\n gameCanvas.focus();\n });\n\n // Prevent magnifying glass on iOS with a long press.\n // Note that there are related bugs on iOS 15 (see https://bugs.webkit.org/show_bug.cgi?id=231161)\n // but it seems not to affect us as the `domElementsContainer` has `pointerEvents` set to `none`.\n domElementsContainer.style['-webkit-user-select'] = 'none';\n\n gameCanvas.parentNode?.appendChild(domElementsContainer);\n this._domElementsContainer = domElementsContainer;\n\n this._resizeCanvas();\n\n // Handle scale mode.\n if (this._game.getScaleMode() === 'nearest') {\n gameCanvas.style['image-rendering'] = '-moz-crisp-edges';\n gameCanvas.style['image-rendering'] = '-webkit-optimize-contrast';\n gameCanvas.style['image-rendering'] = '-webkit-crisp-edges';\n gameCanvas.style['image-rendering'] = 'pixelated';\n }\n\n // Handle pixels rounding.\n if (this._game.getPixelsRounding()) {\n PIXI.settings.ROUND_PIXELS = true;\n }\n\n // Handle resize: immediately adjust the game canvas (and dom element container)\n // and notify the game (that may want to adjust to the new size of the window).\n window.addEventListener('resize', () => {\n this._game.onWindowInnerSizeChanged();\n this._resizeCanvas();\n });\n\n // Focus the canvas when created.\n gameCanvas.focus();\n }\n\n static getWindowInnerWidth() {\n return typeof window !== 'undefined' ? window.innerWidth : 800;\n }\n\n static getWindowInnerHeight() {\n return typeof window !== 'undefined' ? window.innerHeight : 800;\n }\n\n /**\n * Update the game renderer size according to the \"game resolution\".\n * Called when game resolution changes.\n *\n * Note that if the canvas is fullscreen, it won't be resized, but when going back to\n * non fullscreen mode, the requested size will be used.\n */\n updateRendererSize(): void {\n this._resizeCanvas();\n }\n\n /**\n * Set the proper screen orientation from the project properties.\n */\n private _setupOrientation() {\n if (\n typeof window === 'undefined' ||\n !window.screen ||\n !window.screen.orientation\n ) {\n return;\n }\n const gameOrientation = this._game.getGameData().properties.orientation;\n try {\n // We ignore the error as some platforms may not supporting locking (i.e: desktop).\n if (gameOrientation === 'default') {\n const promise = window.screen.orientation.unlock();\n // @ts-ignore\n if (promise) {\n // @ts-ignore\n promise.catch(() => {});\n }\n } else {\n // @ts-ignore\n window.screen.orientation.lock(gameOrientation).catch(() => {});\n }\n } catch (error) {\n logger.error('Unexpected error while setting up orientation: ', error);\n }\n }\n\n /**\n * Resize the renderer (the \"game resolution\") and the canvas (which can be larger\n * or smaller to fill the page, with optional margins).\n *\n */\n private _resizeCanvas() {\n if (!this._pixiRenderer || !this._domElementsContainer) return;\n\n // Set the Pixi (and/or Three) renderer size to the game size.\n // There is no \"smart\" resizing to be done here: the rendering of the game\n // should be done with the size set on the game.\n if (\n this._pixiRenderer.width !== this._game.getGameResolutionWidth() ||\n this._pixiRenderer.height !== this._game.getGameResolutionHeight()\n ) {\n // TODO (3D): It might be useful to resize pixi view in 3D depending on FOV value\n // to enable a mode where pixi always fills the whole screen.\n this._pixiRenderer.resize(\n this._game.getGameResolutionWidth(),\n this._game.getGameResolutionHeight()\n );\n\n if (this._threeRenderer) {\n this._threeRenderer.setSize(\n this._game.getGameResolutionWidth(),\n this._game.getGameResolutionHeight()\n );\n }\n }\n\n // Set the canvas size.\n // Resizing is done according to the settings. This is a \"CSS\" resize\n // only, so won't create visual artifacts during the rendering.\n const isFullPage =\n this._forceFullscreen || this._isFullPage || this._isFullscreen;\n let canvasWidth = this._game.getGameResolutionWidth();\n let canvasHeight = this._game.getGameResolutionHeight();\n let maxWidth = window.innerWidth - this._marginLeft - this._marginRight;\n let maxHeight = window.innerHeight - this._marginTop - this._marginBottom;\n if (maxWidth < 0) {\n maxWidth = 0;\n }\n if (maxHeight < 0) {\n maxHeight = 0;\n }\n if (isFullPage && !this._keepRatio) {\n canvasWidth = maxWidth;\n canvasHeight = maxHeight;\n } else if (\n (isFullPage && this._keepRatio) ||\n canvasWidth > maxWidth ||\n canvasHeight > maxHeight\n ) {\n let factor = maxWidth / canvasWidth;\n if (canvasHeight * factor > maxHeight) {\n factor = maxHeight / canvasHeight;\n }\n canvasWidth *= factor;\n canvasHeight *= factor;\n }\n\n // Apply the calculations to the canvas element...\n if (this._gameCanvas) {\n this._gameCanvas.style.top =\n this._marginTop + (maxHeight - canvasHeight) / 2 + 'px';\n this._gameCanvas.style.left =\n this._marginLeft + (maxWidth - canvasWidth) / 2 + 'px';\n this._gameCanvas.style.width = canvasWidth + 'px';\n this._gameCanvas.style.height = canvasHeight + 'px';\n }\n\n // ...and to the div on top of it showing DOM elements (like inputs).\n this._domElementsContainer.style.top =\n this._marginTop + (maxHeight - canvasHeight) / 2 + 'px';\n this._domElementsContainer.style.left =\n this._marginLeft + (maxWidth - canvasWidth) / 2 + 'px';\n this._domElementsContainer.style.width = canvasWidth + 'px';\n this._domElementsContainer.style.height = canvasHeight + 'px';\n\n // Store the canvas size for fast access to it.\n this._canvasWidth = canvasWidth;\n this._canvasHeight = canvasHeight;\n }\n\n /**\n * Set if the aspect ratio must be kept when the game canvas is resized to fill\n * the page.\n */\n keepAspectRatio(enable) {\n if (this._keepRatio === enable) {\n return;\n }\n this._keepRatio = enable;\n this._resizeCanvas();\n }\n\n /**\n * Change the margin that must be preserved around the game canvas.\n */\n setMargins(top, right, bottom, left): void {\n this._throwIfDisposed();\n if (\n this._marginTop === top &&\n this._marginRight === right &&\n this._marginBottom === bottom &&\n this._marginLeft === left\n ) {\n return;\n }\n this._marginTop = top;\n this._marginRight = right;\n this._marginBottom = bottom;\n this._marginLeft = left;\n this._resizeCanvas();\n }\n\n /**\n * Update the window size, if possible.\n * @param width The new width, in pixels.\n * @param height The new height, in pixels.\n */\n setWindowSize(width: float, height: float): void {\n this._throwIfDisposed();\n const remote = this.getElectronRemote();\n if (remote) {\n const browserWindow = remote.getCurrentWindow();\n try {\n if (browserWindow) {\n browserWindow.setContentSize(width, height);\n }\n } catch (error) {\n logger.error(\n `Window size setting to width ${width} and height ${height} failed. See error:`,\n error\n );\n }\n } else {\n logger.warn(\"Window size can't be changed on this platform.\");\n }\n }\n\n /**\n * Center the window on screen.\n */\n centerWindow() {\n this._throwIfDisposed();\n const remote = this.getElectronRemote();\n if (remote) {\n const browserWindow = remote.getCurrentWindow();\n try {\n if (browserWindow) {\n browserWindow.center();\n }\n } catch (error) {\n logger.error('Window centering failed. See error:', error);\n }\n } else {\n logger.warn(\"Window can't be centered on this platform.\");\n }\n }\n\n /**\n * De/activate fullscreen for the game.\n */\n setFullScreen(enable): void {\n this._throwIfDisposed();\n if (this._forceFullscreen) {\n return;\n }\n if (this._isFullscreen !== enable) {\n this._isFullscreen = !!enable;\n const remote = this.getElectronRemote();\n if (remote) {\n const browserWindow = remote.getCurrentWindow();\n try {\n if (browserWindow) {\n browserWindow.setFullScreen(this._isFullscreen);\n }\n } catch (error) {\n logger.error(\n `Full screen setting to ${this._isFullscreen} failed. See error:`,\n error\n );\n }\n } else {\n // Use HTML5 Fullscreen API\n //TODO: Do this on a user gesture, otherwise most browsers won't activate fullscreen\n if (this._isFullscreen) {\n // @ts-ignore\n if (document.documentElement.requestFullscreen) {\n // @ts-ignore\n document.documentElement.requestFullscreen();\n } else {\n // @ts-ignore\n if (document.documentElement.mozRequestFullScreen) {\n // @ts-ignore\n document.documentElement.mozRequestFullScreen();\n } else {\n // @ts-ignore\n if (document.documentElement.webkitRequestFullScreen) {\n // @ts-ignore\n document.documentElement.webkitRequestFullScreen();\n }\n }\n }\n } else {\n // @ts-ignore\n if (document.exitFullscreen) {\n // @ts-ignore\n document.exitFullscreen();\n } else {\n // @ts-ignore\n if (document.mozCancelFullScreen) {\n // @ts-ignore\n document.mozCancelFullScreen();\n } else {\n // @ts-ignore\n if (document.webkitCancelFullScreen) {\n // @ts-ignore\n document.webkitCancelFullScreen();\n }\n }\n }\n }\n }\n this._resizeCanvas();\n }\n }\n\n /**\n * Checks if the game is in full screen.\n */\n isFullScreen(): boolean {\n const remote = this.getElectronRemote();\n if (remote) {\n try {\n return remote.getCurrentWindow().isFullScreen();\n } catch (error) {\n logger.error(`Full screen detection failed. See error:`, error);\n return false;\n }\n }\n\n // Height check is used to detect user triggered full screen (for example F11 shortcut).\n return this._isFullscreen || window.screen.height === window.innerHeight;\n }\n\n /**\n * Convert a point from the canvas coordinates to the dom element container coordinates.\n *\n * @param canvasCoords The point in the canvas coordinates.\n * @param result The point to return.\n * @returns The point in the dom element container coordinates.\n */\n convertCanvasToDomElementContainerCoords(\n canvasCoords: FloatPoint,\n result: FloatPoint\n ): FloatPoint {\n const pageCoords = result || [0, 0];\n\n // Handle the fact that the game is stretched to fill the canvas.\n pageCoords[0] =\n (canvasCoords[0] * this._canvasWidth) /\n this._game.getGameResolutionWidth();\n pageCoords[1] =\n (canvasCoords[1] * this._canvasHeight) /\n this._game.getGameResolutionHeight();\n\n return pageCoords;\n }\n\n /**\n * Return the scale factor between the renderer height and the actual canvas height,\n * which is also the height of the container for DOM elements to be superimposed on top of it.\n *\n * Useful to scale font sizes of DOM elements so that they follow the size of the game.\n */\n getCanvasToDomElementContainerHeightScale(): float {\n return (this._canvasHeight || 1) / this._game.getGameResolutionHeight();\n }\n\n /**\n * Add the standard events handler.\n *\n * The game canvas must have been initialized before calling this.\n */\n bindStandardEvents(\n manager: gdjs.InputManager,\n window: Window,\n document: Document\n ) {\n this._throwIfDisposed();\n const canvas = this._gameCanvas;\n if (!canvas) return;\n\n //Translate an event (mouse or touch) made on the canvas on the page\n //to game coordinates.\n const getEventPosition = (e: MouseEvent | Touch) => {\n const pos = [e.pageX - canvas.offsetLeft, e.pageY - canvas.offsetTop];\n\n // Handle the fact that the game is stretched to fill the canvas.\n pos[0] *=\n this._game.getGameResolutionWidth() / (this._canvasWidth || 1);\n pos[1] *=\n this._game.getGameResolutionHeight() / (this._canvasHeight || 1);\n return pos;\n };\n\n const isInsideCanvas = (e: MouseEvent | Touch) => {\n const x = e.pageX - canvas.offsetLeft;\n const y = e.pageY - canvas.offsetTop;\n\n return (\n 0 <= x &&\n x < (this._canvasWidth || 1) &&\n 0 <= y &&\n y < (this._canvasHeight || 1)\n );\n };\n\n //Some browsers lacks definition of some variables used to do calculations\n //in getEventPosition. They are defined to 0 as they are useless.\n\n (function ensureOffsetsExistence() {\n if (isNaN(canvas.offsetLeft)) {\n // @ts-ignore\n canvas.offsetLeft = 0;\n // @ts-ignore\n canvas.offsetTop = 0;\n }\n if (isNaN(document.body.scrollLeft)) {\n document.body.scrollLeft = 0;\n document.body.scrollTop = 0;\n }\n if (\n document.documentElement === undefined ||\n document.documentElement === null\n ) {\n // @ts-ignore\n document.documentElement = {};\n }\n if (isNaN(document.documentElement.scrollLeft)) {\n document.documentElement.scrollLeft = 0;\n document.documentElement.scrollTop = 0;\n }\n if (isNaN(canvas.offsetLeft)) {\n // @ts-ignore\n canvas.offsetLeft = 0;\n // @ts-ignore\n canvas.offsetTop = 0;\n }\n })();\n\n // Keyboard: listen at the document level to capture even when the canvas\n // is not focused.\n\n const isFocusingDomElement = () => {\n // Fast bailout when the game canvas should receive the inputs (i.e: almost always).\n // Also check the document body or null for activeElement, as all of these should go\n // to the game.\n if (\n document.activeElement === canvas ||\n document.activeElement === document.body ||\n document.activeElement === null\n )\n return false;\n\n return true;\n };\n const isTargetDomElement = (event: TouchEvent) => {\n // Fast bailout when the game canvas should receive the inputs (i.e: almost always).\n // Any event with a target that is not the body or the canvas should\n // not go to the game (<input> or <a> elements for instances).\n if (event.target === canvas || event.target === document.body)\n return false;\n return true;\n };\n document.onkeydown = function (e) {\n if (isFocusingDomElement()) {\n // Bail out if the game canvas is not focused. For example,\n // an `<input>` element can be focused, and needs to receive\n // arrow keys events.\n return;\n }\n\n if (defaultPreventedKeyCodes.includes(e.keyCode)) {\n // Some keys are \"default prevented\" to avoid scrolling when the game\n // is integrated in a page as an iframe.\n e.preventDefault();\n }\n\n manager.onKeyPressed(e.keyCode, e.location);\n };\n document.onkeyup = function (e) {\n if (isFocusingDomElement()) {\n // Bail out if the game canvas is not focused. For example,\n // an `<input>` element can be focused, and needs to receive\n // arrow keys events.\n return;\n }\n\n if (defaultPreventedKeyCodes.includes(e.keyCode)) {\n // Some keys are \"default prevented\" to avoid scrolling when the game\n // is integrated in a page as an iframe.\n e.preventDefault();\n }\n\n manager.onKeyReleased(e.keyCode, e.location);\n };\n\n // Mouse:\n\n // Converts HTML mouse button to InputManager mouse button.\n // This function is used to align HTML button values with GDevelop 3 C++ SFML Mouse button enum values,\n // notably the middle and right buttons.\n function convertHtmlMouseButtonToInputManagerMouseButton(button: number) {\n switch (button) {\n case 1: // Middle button\n return gdjs.InputManager.MOUSE_MIDDLE_BUTTON;\n case 2: // Right button\n return gdjs.InputManager.MOUSE_RIGHT_BUTTON;\n }\n return button;\n }\n canvas.onmousemove = function (e) {\n const pos = getEventPosition(e);\n manager.onMouseMove(pos[0], pos[1]);\n };\n canvas.onmousedown = function (e) {\n manager.onMouseButtonPressed(\n convertHtmlMouseButtonToInputManagerMouseButton(e.button)\n );\n if (window.focus !== undefined) {\n window.focus();\n }\n return false;\n };\n canvas.onmouseup = function (e) {\n manager.onMouseButtonReleased(\n convertHtmlMouseButtonToInputManagerMouseButton(e.button)\n );\n return false;\n };\n canvas.onmouseleave = function (e) {\n manager.onMouseLeave();\n };\n canvas.onmouseenter = function (e) {\n manager.onMouseEnter();\n // There is no mouse event when the cursor is outside of the canvas.\n // We catchup what happened.\n const buttons = [\n gdjs.InputManager.MOUSE_LEFT_BUTTON,\n gdjs.InputManager.MOUSE_RIGHT_BUTTON,\n gdjs.InputManager.MOUSE_MIDDLE_BUTTON,\n gdjs.InputManager.MOUSE_BACK_BUTTON,\n gdjs.InputManager.MOUSE_FORWARD_BUTTON,\n ];\n for (let i = 0, len = buttons.length; i < len; ++i) {\n const button = buttons[i];\n const buttonIsPressed = (e.buttons & (1 << i)) !== 0;\n const buttonWasPressed = manager.isMouseButtonPressed(button);\n if (buttonIsPressed && !buttonWasPressed) {\n manager.onMouseButtonPressed(button);\n } else if (!buttonIsPressed && buttonWasPressed) {\n manager.onMouseButtonReleased(button);\n }\n }\n };\n window.addEventListener(\n 'click',\n function (e) {\n if (window.focus !== undefined) {\n window.focus();\n }\n return false;\n },\n false\n );\n canvas.oncontextmenu = function (event) {\n event.preventDefault();\n event.stopPropagation();\n return false;\n };\n // @ts-ignore\n canvas.onwheel = function (event) {\n manager.onMouseWheel(-event.deltaY);\n };\n\n // Touches:\n window.addEventListener(\n 'touchmove',\n function (e) {\n if (isTargetDomElement(e)) {\n // Bail out if the game canvas is not focused. For example,\n // an `<input>` element can be focused, and needs to receive\n // touch events to move the selection (and do other native gestures).\n return;\n }\n\n e.preventDefault();\n if (e.changedTouches) {\n for (let i = 0; i < e.changedTouches.length; ++i) {\n const pos = getEventPosition(e.changedTouches[i]);\n manager.onTouchMove(\n e.changedTouches[i].identifier,\n pos[0],\n pos[1]\n );\n // This works because touch events are sent\n // when they continue outside of the canvas.\n if (manager.isSimulatingMouseWithTouch()) {\n if (isInsideCanvas(e.changedTouches[i])) {\n manager.onMouseEnter();\n } else {\n manager.onMouseLeave();\n }\n }\n }\n }\n },\n // This is important so that we can use e.preventDefault() and block possible following mouse events.\n { passive: false }\n );\n window.addEventListener(\n 'touchstart',\n function (e) {\n if (isTargetDomElement(e)) {\n // Bail out if the game canvas is not focused. For example,\n // an `<input>` element can be focused, and needs to receive\n // touch events to move the selection (and do other native gestures).\n return;\n }\n\n e.preventDefault();\n if (e.changedTouches) {\n for (let i = 0; i < e.changedTouches.length; ++i) {\n const pos = getEventPosition(e.changedTouches[i]);\n manager.onTouchStart(\n e.changedTouches[i].identifier,\n pos[0],\n pos[1]\n );\n }\n }\n return false;\n },\n // This is important so that we can use e.preventDefault() and block possible following mouse events.\n { passive: false }\n );\n window.addEventListener(\n 'touchend',\n function (e) {\n if (isTargetDomElement(e)) {\n // Bail out if the game canvas is not focused. For example,\n // an `<input>` element can be focused, and needs to receive\n // touch events to move the selection (and do other native gestures).\n return;\n }\n\n e.preventDefault();\n if (e.changedTouches) {\n for (let i = 0; i < e.changedTouches.length; ++i) {\n manager.onTouchEnd(e.changedTouches[i].identifier);\n }\n }\n return false;\n },\n // This is important so that we can use e.preventDefault() and block possible following mouse events.\n { passive: false }\n );\n window.addEventListener(\n 'touchcancel',\n function (e) {\n if (isTargetDomElement(e)) {\n // Bail out if the game canvas is not focused. For example,\n // an `<input>` element can be focused, and needs to receive\n // touch events to move the selection (and do other native gestures).\n return;\n }\n\n e.preventDefault();\n if (e.changedTouches) {\n for (let i = 0; i < e.changedTouches.length; ++i) {\n manager.onTouchCancel(e.changedTouches[i].identifier);\n }\n }\n return false;\n },\n // This is important so that we can use e.preventDefault() and block possible following mouse events.\n { passive: false }\n );\n }\n\n setWindowTitle(title): void {\n if (typeof document !== 'undefined') {\n document.title = title;\n }\n }\n\n getWindowTitle() {\n return typeof document !== 'undefined' ? document.title : '';\n }\n\n startGameLoop(fn) {\n this._throwIfDisposed();\n let oldTime = 0;\n const gameLoop = (time: float) => {\n // Schedule the next frame now to be sure it's called as soon\n // as possible after this one is finished.\n this._nextFrameId = requestAnimationFrame(gameLoop);\n\n const dt = oldTime ? time - oldTime : 0;\n oldTime = time;\n if (!fn(dt)) {\n // Stop the game loop if requested.\n cancelAnimationFrame(this._nextFrameId);\n }\n };\n\n requestAnimationFrame(gameLoop);\n }\n\n stopGameLoop(): void {\n cancelAnimationFrame(this._nextFrameId);\n }\n\n getPIXIRenderer() {\n return this._pixiRenderer;\n }\n\n /**\n * Get the Three.js renderer for the game - if any.\n */\n getThreeRenderer(): THREE.WebGLRenderer | null {\n return this._threeRenderer;\n }\n\n /**\n * Get the DOM element used as a container for HTML elements to display\n * on top of the game.\n */\n getDomElementContainer() {\n return this._domElementsContainer;\n }\n\n /**\n * Open the given URL in the system browser (or a new tab)\n */\n openURL(url: string) {\n // Try to detect the environment to use the most adapted\n // way of opening an URL.\n\n if (typeof window !== 'undefined') {\n const electron = this.getElectron();\n if (electron) {\n electron.shell.openExternal(url);\n } else if (\n // @ts-ignore\n typeof window.cordova !== 'undefined' &&\n // @ts-ignore\n typeof window.cordova.InAppBrowser !== 'undefined'\n ) {\n // @ts-ignore\n window.cordova.InAppBrowser.open(url, '_system', 'location=yes');\n } else {\n window.open(url, '_blank');\n }\n }\n }\n\n /**\n * Close the game, if applicable.\n */\n stopGame() {\n // Try to detect the environment to use the most adapted\n // way of closing the app\n const remote = this.getElectronRemote();\n if (remote) {\n const browserWindow = remote.getCurrentWindow();\n if (browserWindow) {\n try {\n browserWindow.close();\n } catch (error) {\n logger.error('Window closing failed. See error:', error);\n }\n }\n } else {\n if (\n typeof navigator !== 'undefined' &&\n // @ts-ignore\n navigator.app &&\n // @ts-ignore\n navigator.app.exitApp\n ) {\n // @ts-ignore\n navigator.app.exitApp();\n }\n }\n // HTML5 games on mobile/browsers don't have a way to close their window/page.\n }\n\n /**\n * Dispose the renderers (PixiJS and/or Three.js) as well as DOM elements\n * used for the game (the canvas, if specified, and the additional DOM container\n * created on top of it to allow display HTML elements, for example for text inputs).\n *\n * @param removeCanvas If true, the canvas will be removed from the DOM.\n */\n dispose(removeCanvas?: boolean) {\n this._pixiRenderer?.destroy();\n this._threeRenderer?.dispose();\n this._pixiRenderer = null;\n this._threeRenderer = null;\n\n if (removeCanvas && this._gameCanvas) {\n this._gameCanvas.parentNode?.removeChild(this._gameCanvas);\n }\n\n this._gameCanvas = null;\n this._domElementsContainer?.parentNode?.removeChild(\n this._domElementsContainer\n );\n this._domElementsContainer = null;\n this._wasDisposed = true;\n }\n\n /**\n * Get the canvas DOM element.\n */\n getCanvas(): HTMLCanvasElement | null {\n return this._gameCanvas;\n }\n\n /**\n * Check if the device supports WebGL.\n * @returns true if WebGL is supported\n */\n isWebGLSupported(): boolean {\n return (\n !!this._pixiRenderer &&\n this._pixiRenderer.type === PIXI.RENDERER_TYPE.WEBGL\n );\n }\n\n /**\n * Get the electron module, if running as a electron renderer process.\n */\n getElectron() {\n if (typeof require === 'function') {\n return require('electron');\n }\n return null;\n }\n\n /**\n * Helper to get the electron remote module, if running on Electron.\n * Note that is not guaranteed to be supported in the future - avoid if possible.\n */\n getElectronRemote = () => {\n if (typeof require === 'function') {\n const runtimeGameOptions = this._game.getAdditionalOptions();\n const moduleId =\n runtimeGameOptions && runtimeGameOptions.electronRemoteRequirePath\n ? runtimeGameOptions.electronRemoteRequirePath\n : '@electron/remote';\n\n try {\n return require(moduleId);\n } catch (requireError) {\n console.error(\n `Could not load @electron/remote from \"${moduleId}\". Error is:`,\n requireError\n );\n }\n }\n\n return null;\n };\n\n getGame() {\n return this._game;\n }\n\n private _throwIfDisposed(): void {\n if (this._wasDisposed) {\n throw 'The RuntimeGameRenderer has been disposed and should not be used anymore.';\n }\n }\n }\n\n //Register the class to let the engine use it.\n export type RuntimeGameRenderer = RuntimeGamePixiRenderer;\n export const RuntimeGameRenderer = RuntimeGamePixiRenderer;\n}\n"],
|
|
5
|
+
"mappings": "AAAA,GAAU,MAAV,UAAU,EAAV,CACE,KAAM,GAAS,GAAI,GAAK,OAAO,sBAOzB,EAA2B,CAC/B,GACA,GACA,GACA,IAMK,OAA8B,CAkCnC,YAAY,EAAwB,EAA0B,CAhC9D,iBAAuB,GAGvB,mBAAyB,GAKzB,mBAAsC,KAC9B,oBAA6C,KAC7C,iBAAwC,KACxC,2BAA+C,KAGvD,kBAAsB,EAEtB,mBAAuB,EAEvB,gBAAsB,GAMtB,kBAAwB,EAExB,kBAAwB,GA08BxB,uBAAoB,IAAM,CACxB,GAAI,MAAO,UAAY,WAAY,CACjC,KAAM,GAAqB,KAAK,MAAM,uBAChC,EACJ,GAAsB,EAAmB,0BACrC,EAAmB,0BACnB,mBAEN,GAAI,CACF,MAAO,SAAQ,SACR,EAAP,CACA,QAAQ,MACN,yCAAyC,gBACzC,IAKN,MAAO,OAr9BP,KAAK,MAAQ,EACb,KAAK,iBAAmB,EAGxB,KAAK,YAAc,KAAK,WAAa,KAAK,aAAe,KAAK,cAAgB,EAC9E,KAAK,oBAUP,qBAAqB,EAA4B,CAC/C,KAAK,mBAEL,KAAM,GAAa,SAAS,cAAc,UAC1C,EAAc,YAAY,GAE1B,KAAK,oBAAoB,GACzB,KAAK,iBAAiB,GAQxB,oBAAoB,EAAqC,CACvD,KAAK,mBAEL,AAAI,MAAO,QAAU,YACnB,MAAK,eAAiB,GAAI,OAAM,cAAc,CAC5C,OAAQ,EACR,UACE,KAAK,MAAM,wBAA0B,QACpC,MAAK,MAAM,gCACV,CAAC,EAAK,SAA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AO,mBAC7B,GAAI,EACF,GAAI,CACF,EAAc,cACP,EAAP,CACA,EAAO,MAAM,oCAAqC,QAItD,AACE,OAAO,YAAc,aAErB,UAAU,KAEV,UAAU,IAAI,SAGd,UAAU,IAAI,UAapB,QAAQ,EAAwB,CAC9B,KAAK,eAAe,UACpB,KAAK,gBAAgB,UACrB,KAAK,cAAgB,KACrB,KAAK,eAAiB,KAElB,GAAgB,KAAK,aACvB,KAAK,YAAY,YAAY,YAAY,KAAK,aAGhD,KAAK,YAAc,KACnB,KAAK,uBAAuB,YAAY,YACtC,KAAK,uBAEP,KAAK,sBAAwB,KAC7B,KAAK,aAAe,GAMtB,WAAsC,CACpC,MAAO,MAAK,YAOd,kBAA4B,CAC1B,MACE,CAAC,CAAC,KAAK,eACP,KAAK,cAAc,OAAS,KAAK,cAAc,MAOnD,aAAc,CACZ,MAAI,OAAO,UAAY,WACd,QAAQ,YAEV,KA4BT,SAAU,CACR,MAAO,MAAK,MAGN,kBAAyB,CAC/B,GAAI,KAAK,aACP,KAAM,6EAjgCL,EAAM,0BAwgCA,sBAAsB,IA1hC3B",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var gdjs;(function(n){const g=new n.Logger("Game manager"),c=u=>new Promise(e=>setTimeout(e,u)),h=u=>u.usedResources.map(e=>e.name);let l=null;const p=()=>{if(l)return l;l=[];try{new CompressionStream("gzip"),l.push("cs:gzip")}catch{}try{new CompressionStream("deflate"),l.push("cs:deflate")}catch{}return l};class _{constructor(e,t){this._sceneAndExtensionsData=[];this._notifyScenesForGameResolutionResize=!1;this._paused=!1;this._hasJustResumed=!1;this._sessionMetricsInitialized=!1;this._disableMetrics=!1;this._wasDisposed=!1;this.getPlatformInfo=()=>({isCordova:!!window.cordova,devicePlatform:typeof device!="undefined"&&device.platform||"",navigatorPlatform:typeof navigator!="undefined"?navigator.platform:"",hasTouch:typeof navigator!="undefined"?!!navigator.maxTouchPoints&&navigator.maxTouchPoints>2:!1,supportedCompressionMethods:p()});this._options=t||{},this._variables=new n.VariablesContainer(e.variables),this._variablesByExtensionName=new Map;for(const s of e.eventsFunctionsExtensions)s.globalVariables.length>0&&this._variablesByExtensionName.set(s.name,new n.VariablesContainer(s.globalVariables));this._eventsBasedObjectDatas=new Map,this._data=e,this._updateSceneAndExtensionsData(),this._resourcesLoader=new n.ResourceLoader(this,e.resources.resources,h(e),e.layouts),this._effectsManager=new n.EffectsManager,this._maxFPS=this._data.properties.maxFPS,this._minFPS=this._data.properties.minFPS,this._gameResolutionWidth=this._data.properties.windowWidth,this._gameResolutionHeight=this._data.properties.windowHeight,this._originalWidth=this._gameResolutionWidth,this._originalHeight=this._gameResolutionHeight,this._resizeMode=this._data.properties.sizeOnStartupMode,this._adaptGameResolutionAtRuntime=this._data.properties.adaptGameResolutionAtRuntime,this._scaleMode=e.properties.scaleMode||"linear",this._pixelsRounding=this._data.properties.pixelsRounding,this._antialiasingMode=this._data.properties.antialiasingMode,this._isAntialisingEnabledOnMobile=this._data.properties.antialisingEnabledOnMobile,this._renderer=new n.RuntimeGameRenderer(this,this._options.forceFullscreen||!1),this._watermark=new n.watermark.RuntimeWatermark(this,e.properties.authorUsernames,this._data.properties.watermark),this._sceneStack=new n.SceneStack(this),this._inputManager=new n.InputManager,this._injectExternalLayout=this._options.injectExternalLayout||"",this._debuggerClient=n.DebuggerClient?new n.DebuggerClient(this):null,this._captureManager=n.CaptureManager?new n.CaptureManager(this._renderer,this._options.captureOptions||{}):null,this._isPreview=this._options.isPreview||!1,this._sessionId=null,this._playerId=null,this._embeddedResourcesMappings=new Map;for(const s of this._data.resources.resources)if(s.metadata)try{const i=JSON.parse(s.metadata);i?.embeddedResourcesMapping&&this._embeddedResourcesMappings.set(s.name,i.embeddedResourcesMapping)}catch{g.error("Some metadata of resources can not be successfully parsed.")}this.isUsingGDevelopDevelopmentEnvironment()&&g.info("This game will run on the development version of GDevelop APIs.")}setProjectData(e){this._data=e,this._updateSceneAndExtensionsData(),this._resourcesLoader.setResources(e.resources.resources,h(e),e.layouts)}_updateSceneAndExtensionsData(){const e=this._data.eventsFunctionsExtensions.filter(t=>t.sceneVariables.length>0);if(this._sceneAndExtensionsData=this._data.layouts.map(t=>({sceneData:t,usedExtensionsWithVariablesData:e})),this._eventsBasedObjectDatas.clear(),this._data.eventsFunctionsExtensions)for(const t of this._data.eventsFunctionsExtensions)for(const s of t.eventsBasedObjects)this._eventsBasedObjectDatas.set(t.name+"::"+s.name,s)}getAdditionalOptions(){return this._options}getRenderer(){return this._renderer}getVariables(){return this._variables}getVariablesForExtension(e){return this._variablesByExtensionName.get(e)||null}getSoundManager(){return this._resourcesLoader.getSoundManager()}getImageManager(){return this._resourcesLoader.getImageManager()}getFontManager(){return this._resourcesLoader.getFontManager()}getBitmapFontManager(){return this._resourcesLoader.getBitmapFontManager()}getJsonManager(){return this._resourcesLoader.getJsonManager()}getModel3DManager(){return this._resourcesLoader.getModel3DManager()}getSpineManager(){return this._resourcesLoader.getSpineManager()}getSpineAtlasManager(){return this._resourcesLoader.getSpineAtlasManager()}getInputManager(){return this._inputManager}getEffectsManager(){return this._effectsManager}getGameData(){return this._data}getEventsBasedObjectData(e){const t=this._eventsBasedObjectDatas.get(e);return t||(g.error('The game has no events-based object of the type "'+e+'"'),null)}getSceneAndExtensionsData(e){for(let t=0,s=this._sceneAndExtensionsData.length;t<s;++t){const i=this._sceneAndExtensionsData[t];if(e===void 0||i.sceneData.name===e)return i}return g.error('The game has no scene called "'+e+'"'),null}hasScene(e){for(let t=0,s=this._data.layouts.length;t<s;++t){const i=this._data.layouts[t];if(e===void 0||i.name==e)return!0}return!1}getExternalLayoutData(e){let t=null;for(let s=0,i=this._data.externalLayouts.length;s<i;++s){const r=this._data.externalLayouts[s];if(r.name===e){t=r;break}}return t}getInitialObjectsData(){return this._data.objects||[]}getOriginalWidth(){return this._originalWidth}getOriginalHeight(){return this._originalHeight}getGameResolutionWidth(){return this._gameResolutionWidth}getGameResolutionHeight(){return this._gameResolutionHeight}setGameResolutionSize(e,t){if(this._throwIfDisposed(),this._gameResolutionWidth=e,this._gameResolutionHeight=t,this._adaptGameResolutionAtRuntime&&n.RuntimeGameRenderer&&n.RuntimeGameRenderer.getWindowInnerWidth&&n.RuntimeGameRenderer.getWindowInnerHeight){const s=n.RuntimeGameRenderer.getWindowInnerWidth(),i=n.RuntimeGameRenderer.getWindowInnerHeight();this._resizeMode==="adaptWidth"?this._gameResolutionWidth=this._gameResolutionHeight*s/i:this._resizeMode==="adaptHeight"&&(this._gameResolutionHeight=this._gameResolutionWidth*i/s)}this._renderer.updateRendererSize(),this._notifyScenesForGameResolutionResize=!0}setGameResolutionResizeMode(e){this._resizeMode=e,this._forceGameResolutionUpdate()}getGameResolutionResizeMode(){return this._resizeMode}setAdaptGameResolutionAtRuntime(e){this._adaptGameResolutionAtRuntime=e,this._forceGameResolutionUpdate()}getAdaptGameResolutionAtRuntime(){return this._adaptGameResolutionAtRuntime}getMinimalFramerate(){return this._minFPS}getScaleMode(){return this._scaleMode}getPixelsRounding(){return this._pixelsRounding}getAntialiasingMode(){return this._antialiasingMode}isAntialisingEnabledOnMobile(){return this._isAntialisingEnabledOnMobile}pause(e){this._paused!==e&&(this._paused=e,this._debuggerClient&&(this._paused?this._debuggerClient.sendGamePaused():this._debuggerClient.sendGameResumed()))}hasJustResumed(){return this._hasJustResumed}prioritizeLoadingOfScene(e){this._resourcesLoader.loadSceneResources(e)}getSceneLoadingProgress(e){return this._resourcesLoader.getSceneLoadingProgress(e)}areSceneAssetsLoaded(e){return this._resourcesLoader.areSceneAssetsLoaded(e)}areSceneAssetsReady(e){return this._resourcesLoader.areSceneAssetsReady(e)}loadAllAssets(e,t){this._throwIfDisposed(),this.loadFirstAssetsAndStartBackgroundLoading(this._getFirstSceneName(),t).then(e)}async loadFirstAssetsAndStartBackgroundLoading(e,t){try{const s=this._data.properties.loadingScreen.backgroundImageResourceName;s&&await this._resourcesLoader.getImageManager().loadResource(s),await Promise.all([this._loadAssetsWithLoadingScreen(!0,async i=>{await this._resourcesLoader.loadGlobalAndFirstSceneResources(e,i),this._resourcesLoader.loadAllSceneInBackground()},t),n.getAllAsynchronouslyLoadingLibraryPromise()])}catch(s){throw this._debuggerClient&&this._debuggerClient.onUncaughtException(s),s}}async loadSceneAssets(e,t){await this._loadAssetsWithLoadingScreen(!1,async s=>{await this._resourcesLoader.loadAndProcessSceneResources(e,s)},t)}async _loadAssetsWithLoadingScreen(e,t,s){this.pause(!0);const i=new n.LoadingScreenRenderer(this.getRenderer(),this._resourcesLoader.getImageManager(),this._data.properties.loadingScreen,this._data.properties.watermark.showWatermark,e);await t(async(o,a)=>{const d=Math.floor(100*o/a);i.setPercent(d),s&&s(d),i.renderIfNeeded()&&await c(1)}),await i.unload(),this.pause(!1)}_getFirstSceneName(){const e=this._data.firstLayout;return this.hasScene(e)?e:this.getSceneAndExtensionsData().sceneData.name}startGameLoop(){this._throwIfDisposed();try{if(!this.hasScene()){g.error("The game has no scene.");return}this._forceGameResolutionUpdate(),this._sceneStack.push(this._getFirstSceneName(),this._injectExternalLayout),this._watermark.displayAtStartup(),this._setupGameVisibilityEvents();let e=0;this._hasJustResumed=!1,this._renderer.startGameLoop(t=>{try{if(this._paused||(e+=t,this._maxFPS>0&&1e3/e>this._maxFPS+7))return!0;const s=e;return e=0,this._notifyScenesForGameResolutionResize&&(this._sceneStack.onGameResolutionResized(),this._notifyScenesForGameResolutionResize=!1),this._sceneStack.step(s)?(this.getInputManager().onFrameEnded(),this._hasJustResumed=!1,!0):!1}catch(s){throw this._debuggerClient&&this._debuggerClient.onUncaughtException(s),s}}),setTimeout(()=>{this._setupSessionMetrics()},4e3),this._captureManager&&this._captureManager.setupCaptureOptions(this._isPreview)}catch(e){throw this._debuggerClient&&this._debuggerClient.onUncaughtException(e),e}}dispose(){this._renderer.stopGameLoop(),this._sceneStack.dispose(),this._renderer.dispose(),this._resourcesLoader.dispose(),this._wasDisposed=!0}enableMetrics(e){this._disableMetrics=!e,e&&this._setupSessionMetrics()}_setupGameVisibilityEvents(){typeof navigator!="undefined"&&typeof document!="undefined"&&(document.addEventListener("visibilitychange",()=>{document.visibilityState==="visible"&&(this._hasJustResumed=!0)}),window.addEventListener("resume",()=>{this._hasJustResumed=!0},!1))}_setupSessionMetrics(){if(this._sessionMetricsInitialized||this._disableMetrics||this.isPreview()||typeof fetch=="undefined"||!this._data.properties.projectUuid)return;const e="https://api.gdevelop-app.com/analytics";this._playerId=this._makePlayerUuid();let t=0,s=0,i=Date.now();const r=this.getPlatformInfo();fetch(e+"/session",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({gameId:this._data.properties.projectUuid,playerId:this._playerId,game:{name:this._data.properties.name||"",packageName:this._data.properties.packageName||"",version:this._data.properties.version||"",location:window.location.href},platform:{isCordova:r.isCordova,devicePlatform:r.devicePlatform,navigatorPlatform:r.navigatorPlatform,hasTouch:r.hasTouch}})}).then(a=>{if(!a.ok)throw console.error("Error while creating the session",a),new Error("Error while creating the session");return a}).then(a=>a.text()).then(a=>{this._sessionId=a}).catch(()=>{});const o=()=>{if(!this._sessionId)return;const a=Date.now();if(s+=a-i,i=a,s<5*1e3)return;const d=Math.floor(s/1e3)*1e3;t+=d,s-=d,navigator.sendBeacon(e+"/session-hit",JSON.stringify({gameId:this._data.properties.projectUuid,playerId:this._playerId,sessionId:this._sessionId,duration:Math.floor(t/1e3)}))};if(typeof navigator!="undefined"&&typeof document!="undefined"){document.addEventListener("visibilitychange",()=>{document.visibilityState==="visible"?i=Date.now():o()}),window.addEventListener("pagehide",o,!1),window.addEventListener("pause",o,!1),window.addEventListener("resume",()=>{i=Date.now()},!1);const a=typeof safari=="object"&&safari.pushNotification,d=/electron/i.test(navigator.userAgent);(a||d)&&window.addEventListener("beforeunload",()=>{o()})}this._sessionMetricsInitialized=!0,this._sessionId=this._sessionId}_makePlayerUuid(){try{const e="GDJS-internal-player-uuid",t=localStorage.getItem(e);if(t)return t;const s=n.makeUuid();return localStorage.setItem(e,s),s}catch{return n.makeUuid()}}getSessionId(){return this._sessionId}getPlayerId(){return this._playerId}onWindowInnerSizeChanged(){this._forceGameResolutionUpdate()}_forceGameResolutionUpdate(){this.setGameResolutionSize(this._gameResolutionWidth,this._gameResolutionHeight)}startCurrentSceneProfiler(e){this._throwIfDisposed();const t=this._sceneStack.getCurrentScene();return t?(t.startProfiler(e),!0):!1}stopCurrentSceneProfiler(){this._throwIfDisposed();const e=this._sceneStack.getCurrentScene();!e||e.stopProfiler()}wasFirstSceneLoaded(){return this._sceneStack.wasFirstSceneLoaded()}getSceneStack(){return this._sceneStack}isPreview(){return this._isPreview}isUsingGDevelopDevelopmentEnvironment(){return this._options.environment==="dev"}getExtensionProperty(e,t){for(let s of this._data.properties.extensionProperties)if(s.extension===e&&s.property===t)return s.value;return null}resolveEmbeddedResource(e,t){const s=this._embeddedResourcesMappings.get(e);return s&&s[t]?s[t]:t}getEmbeddedResourcesNames(e){return this._embeddedResourcesMappings.has(e)?Object.keys(this._embeddedResourcesMappings.get(e)):[]}getNetworkSyncData(e){const t={var:this._variables.getNetworkSyncData(e),ss:this._sceneStack.getNetworkSyncData(e)||void 0},s={};return this._variablesByExtensionName.forEach((i,r)=>{const o=i.getNetworkSyncData(e);o.length&&(s[r]=o)}),t.extVar=s,(!t.var||t.var.length===0)&&!t.ss&&(!t.extVar||Object.keys(t.extVar).length===0)?null:t}updateFromNetworkSyncData(e){if(this._throwIfDisposed(),e.var&&this._variables.updateFromNetworkSyncData(e.var),e.ss&&this._sceneStack.updateFromNetworkSyncData(e.ss),e.extVar)for(const t in e.extVar){if(!e.extVar.hasOwnProperty(t))continue;const s=e.extVar[t],i=this.getVariablesForExtension(t);i&&i.updateFromNetworkSyncData(s)}}_throwIfDisposed(){if(this._wasDisposed)throw"The RuntimeGame has been disposed and should not be used anymore."}}n.RuntimeGame=_})(gdjs||(gdjs={}));
|
|
1
|
+
var gdjs;(function(n){const g=new n.Logger("Game manager"),c=u=>new Promise(e=>setTimeout(e,u)),h=u=>u.usedResources.map(e=>e.name);let l=null;const p=()=>{if(l)return l;l=[];try{new CompressionStream("gzip"),l.push("cs:gzip")}catch{}try{new CompressionStream("deflate"),l.push("cs:deflate")}catch{}return l};class _{constructor(e,t){this._sceneAndExtensionsData=[];this._notifyScenesForGameResolutionResize=!1;this._paused=!1;this._hasJustResumed=!1;this._sessionMetricsInitialized=!1;this._disableMetrics=!1;this._wasDisposed=!1;this.getPlatformInfo=()=>({isCordova:!!window.cordova,devicePlatform:typeof device!="undefined"&&device.platform||"",navigatorPlatform:typeof navigator!="undefined"?navigator.platform:"",hasTouch:typeof navigator!="undefined"?!!navigator.maxTouchPoints&&navigator.maxTouchPoints>2:!1,supportedCompressionMethods:p()});this._options=t||{},this._variables=new n.VariablesContainer(e.variables),this._variablesByExtensionName=new Map;for(const s of e.eventsFunctionsExtensions)s.globalVariables.length>0&&this._variablesByExtensionName.set(s.name,new n.VariablesContainer(s.globalVariables));this._eventsBasedObjectDatas=new Map,this._data=e,this._updateSceneAndExtensionsData(),this._resourcesLoader=new n.ResourceLoader(this,e.resources.resources,h(e),e.layouts),this._effectsManager=new n.EffectsManager,this._maxFPS=this._data.properties.maxFPS,this._minFPS=this._data.properties.minFPS,this._gameResolutionWidth=this._data.properties.windowWidth,this._gameResolutionHeight=this._data.properties.windowHeight,this._originalWidth=this._gameResolutionWidth,this._originalHeight=this._gameResolutionHeight,this._resizeMode=this._data.properties.sizeOnStartupMode,this._adaptGameResolutionAtRuntime=this._data.properties.adaptGameResolutionAtRuntime,this._scaleMode=e.properties.scaleMode||"linear",this._pixelsRounding=this._data.properties.pixelsRounding,this._antialiasingMode=this._data.properties.antialiasingMode,this._isAntialisingEnabledOnMobile=this._data.properties.antialisingEnabledOnMobile,this._renderer=new n.RuntimeGameRenderer(this,this._options.forceFullscreen||!1),this._watermark=new n.watermark.RuntimeWatermark(this,e.properties.authorUsernames,this._data.properties.watermark),this._sceneStack=new n.SceneStack(this),this._inputManager=new n.InputManager,this._injectExternalLayout=this._options.injectExternalLayout||"",this._debuggerClient=n.DebuggerClient?new n.DebuggerClient(this):null,this._captureManager=n.CaptureManager?new n.CaptureManager(this._renderer,this._options.captureOptions||{}):null,this._isPreview=this._options.isPreview||!1,this._sessionId=null,this._playerId=null,this._embeddedResourcesMappings=new Map;for(const s of this._data.resources.resources)if(s.metadata)try{const i=JSON.parse(s.metadata);i?.embeddedResourcesMapping&&this._embeddedResourcesMappings.set(s.name,i.embeddedResourcesMapping)}catch{g.error("Some metadata of resources can not be successfully parsed.")}this.isUsingGDevelopDevelopmentEnvironment()&&g.info("This game will run on the development version of GDevelop APIs.")}setProjectData(e){this._data=e,this._updateSceneAndExtensionsData(),this._resourcesLoader.setResources(e.resources.resources,h(e),e.layouts)}_updateSceneAndExtensionsData(){const e=this._data.eventsFunctionsExtensions.filter(t=>t.sceneVariables.length>0);if(this._sceneAndExtensionsData=this._data.layouts.map(t=>({sceneData:t,usedExtensionsWithVariablesData:e})),this._eventsBasedObjectDatas.clear(),this._data.eventsFunctionsExtensions)for(const t of this._data.eventsFunctionsExtensions)for(const s of t.eventsBasedObjects)this._eventsBasedObjectDatas.set(t.name+"::"+s.name,s)}getAdditionalOptions(){return this._options}getRenderer(){return this._renderer}getVariables(){return this._variables}getVariablesForExtension(e){return this._variablesByExtensionName.get(e)||null}getSoundManager(){return this._resourcesLoader.getSoundManager()}getImageManager(){return this._resourcesLoader.getImageManager()}getFontManager(){return this._resourcesLoader.getFontManager()}getBitmapFontManager(){return this._resourcesLoader.getBitmapFontManager()}getJsonManager(){return this._resourcesLoader.getJsonManager()}getModel3DManager(){return this._resourcesLoader.getModel3DManager()}getSpineManager(){return this._resourcesLoader.getSpineManager()}getSpineAtlasManager(){return this._resourcesLoader.getSpineAtlasManager()}getInputManager(){return this._inputManager}getEffectsManager(){return this._effectsManager}getGameData(){return this._data}getEventsBasedObjectData(e){const t=this._eventsBasedObjectDatas.get(e);return t||(g.error('The game has no events-based object of the type "'+e+'"'),null)}getSceneAndExtensionsData(e){for(let t=0,s=this._sceneAndExtensionsData.length;t<s;++t){const i=this._sceneAndExtensionsData[t];if(e===void 0||i.sceneData.name===e)return i}return g.error('The game has no scene called "'+e+'"'),null}hasScene(e){for(let t=0,s=this._data.layouts.length;t<s;++t){const i=this._data.layouts[t];if(e===void 0||i.name==e)return!0}return!1}getExternalLayoutData(e){let t=null;for(let s=0,i=this._data.externalLayouts.length;s<i;++s){const r=this._data.externalLayouts[s];if(r.name===e){t=r;break}}return t}getInitialObjectsData(){return this._data.objects||[]}getOriginalWidth(){return this._originalWidth}getOriginalHeight(){return this._originalHeight}getGameResolutionWidth(){return this._gameResolutionWidth}getGameResolutionHeight(){return this._gameResolutionHeight}setGameResolutionSize(e,t){if(this._throwIfDisposed(),this._gameResolutionWidth=e,this._gameResolutionHeight=t,this._adaptGameResolutionAtRuntime&&n.RuntimeGameRenderer&&n.RuntimeGameRenderer.getWindowInnerWidth&&n.RuntimeGameRenderer.getWindowInnerHeight){const s=n.RuntimeGameRenderer.getWindowInnerWidth(),i=n.RuntimeGameRenderer.getWindowInnerHeight();if(this._resizeMode==="adaptWidth")this._gameResolutionWidth=this._gameResolutionHeight*s/i;else if(this._resizeMode==="adaptHeight")this._gameResolutionHeight=this._gameResolutionWidth*i/s;else if(this._resizeMode==="scaleOuter"){const r=s/this._originalWidth,o=i/this._originalHeight;r<o?(this._gameResolutionWidth=this._originalWidth,this._gameResolutionHeight=Math.floor(i/r)):(this._gameResolutionWidth=Math.floor(s/o),this._gameResolutionHeight=this._originalHeight)}}this._renderer.updateRendererSize(),this._notifyScenesForGameResolutionResize=!0}setGameResolutionResizeMode(e){this._resizeMode=e,this._forceGameResolutionUpdate()}getGameResolutionResizeMode(){return this._resizeMode}setAdaptGameResolutionAtRuntime(e){this._adaptGameResolutionAtRuntime=e,this._forceGameResolutionUpdate()}getAdaptGameResolutionAtRuntime(){return this._adaptGameResolutionAtRuntime}getMinimalFramerate(){return this._minFPS}getScaleMode(){return this._scaleMode}getPixelsRounding(){return this._pixelsRounding}getAntialiasingMode(){return this._antialiasingMode}isAntialisingEnabledOnMobile(){return this._isAntialisingEnabledOnMobile}pause(e){this._paused!==e&&(this._paused=e,this._debuggerClient&&(this._paused?this._debuggerClient.sendGamePaused():this._debuggerClient.sendGameResumed()))}hasJustResumed(){return this._hasJustResumed}prioritizeLoadingOfScene(e){this._resourcesLoader.loadSceneResources(e)}getSceneLoadingProgress(e){return this._resourcesLoader.getSceneLoadingProgress(e)}areSceneAssetsLoaded(e){return this._resourcesLoader.areSceneAssetsLoaded(e)}areSceneAssetsReady(e){return this._resourcesLoader.areSceneAssetsReady(e)}loadAllAssets(e,t){this._throwIfDisposed(),this.loadFirstAssetsAndStartBackgroundLoading(this._getFirstSceneName(),t).then(e)}async loadFirstAssetsAndStartBackgroundLoading(e,t){try{const s=this._data.properties.loadingScreen.backgroundImageResourceName;s&&await this._resourcesLoader.getImageManager().loadResource(s),await Promise.all([this._loadAssetsWithLoadingScreen(!0,async i=>{await this._resourcesLoader.loadGlobalAndFirstSceneResources(e,i),this._resourcesLoader.loadAllSceneInBackground()},t),n.getAllAsynchronouslyLoadingLibraryPromise()])}catch(s){throw this._debuggerClient&&this._debuggerClient.onUncaughtException(s),s}}async loadSceneAssets(e,t){await this._loadAssetsWithLoadingScreen(!1,async s=>{await this._resourcesLoader.loadAndProcessSceneResources(e,s)},t)}async _loadAssetsWithLoadingScreen(e,t,s){this.pause(!0);const i=new n.LoadingScreenRenderer(this.getRenderer(),this._resourcesLoader.getImageManager(),this._data.properties.loadingScreen,this._data.properties.watermark.showWatermark,e);await t(async(o,a)=>{const d=Math.floor(100*o/a);i.setPercent(d),s&&s(d),i.renderIfNeeded()&&await c(1)}),await i.unload(),this.pause(!1)}_getFirstSceneName(){const e=this._data.firstLayout;return this.hasScene(e)?e:this.getSceneAndExtensionsData().sceneData.name}startGameLoop(){this._throwIfDisposed();try{if(!this.hasScene()){g.error("The game has no scene.");return}this._forceGameResolutionUpdate(),this._sceneStack.push(this._getFirstSceneName(),this._injectExternalLayout),this._watermark.displayAtStartup(),this._setupGameVisibilityEvents();let e=0;this._hasJustResumed=!1,this._renderer.startGameLoop(t=>{try{if(this._paused||(e+=t,this._maxFPS>0&&1e3/e>this._maxFPS+7))return!0;const s=e;return e=0,this._notifyScenesForGameResolutionResize&&(this._sceneStack.onGameResolutionResized(),this._notifyScenesForGameResolutionResize=!1),this._sceneStack.step(s)?(this.getInputManager().onFrameEnded(),this._hasJustResumed=!1,!0):!1}catch(s){throw this._debuggerClient&&this._debuggerClient.onUncaughtException(s),s}}),setTimeout(()=>{this._setupSessionMetrics()},4e3),this._captureManager&&this._captureManager.setupCaptureOptions(this._isPreview)}catch(e){throw this._debuggerClient&&this._debuggerClient.onUncaughtException(e),e}}dispose(e){this._renderer.stopGameLoop(),this._sceneStack.dispose(),this._renderer.dispose(e),this._resourcesLoader.dispose(),this._wasDisposed=!0}enableMetrics(e){this._disableMetrics=!e,e&&this._setupSessionMetrics()}_setupGameVisibilityEvents(){typeof navigator!="undefined"&&typeof document!="undefined"&&(document.addEventListener("visibilitychange",()=>{document.visibilityState==="visible"&&(this._hasJustResumed=!0)}),window.addEventListener("resume",()=>{this._hasJustResumed=!0},!1))}_setupSessionMetrics(){if(this._sessionMetricsInitialized||this._disableMetrics||this.isPreview()||typeof fetch=="undefined"||!this._data.properties.projectUuid)return;const e="https://api.gdevelop-app.com/analytics";this._playerId=this._makePlayerUuid();let t=0,s=0,i=Date.now();const r=this.getPlatformInfo();fetch(e+"/session",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({gameId:this._data.properties.projectUuid,playerId:this._playerId,game:{name:this._data.properties.name||"",packageName:this._data.properties.packageName||"",version:this._data.properties.version||"",location:window.location.href},platform:{isCordova:r.isCordova,devicePlatform:r.devicePlatform,navigatorPlatform:r.navigatorPlatform,hasTouch:r.hasTouch}})}).then(a=>{if(!a.ok)throw console.error("Error while creating the session",a),new Error("Error while creating the session");return a}).then(a=>a.text()).then(a=>{this._sessionId=a}).catch(()=>{});const o=()=>{if(!this._sessionId)return;const a=Date.now();if(s+=a-i,i=a,s<5*1e3)return;const d=Math.floor(s/1e3)*1e3;t+=d,s-=d,navigator.sendBeacon(e+"/session-hit",JSON.stringify({gameId:this._data.properties.projectUuid,playerId:this._playerId,sessionId:this._sessionId,duration:Math.floor(t/1e3)}))};if(typeof navigator!="undefined"&&typeof document!="undefined"){document.addEventListener("visibilitychange",()=>{document.visibilityState==="visible"?i=Date.now():o()}),window.addEventListener("pagehide",o,!1),window.addEventListener("pause",o,!1),window.addEventListener("resume",()=>{i=Date.now()},!1);const a=typeof safari=="object"&&safari.pushNotification,d=/electron/i.test(navigator.userAgent);(a||d)&&window.addEventListener("beforeunload",()=>{o()})}this._sessionMetricsInitialized=!0,this._sessionId=this._sessionId}_makePlayerUuid(){try{const e="GDJS-internal-player-uuid",t=localStorage.getItem(e);if(t)return t;const s=n.makeUuid();return localStorage.setItem(e,s),s}catch{return n.makeUuid()}}getSessionId(){return this._sessionId}getPlayerId(){return this._playerId}onWindowInnerSizeChanged(){this._forceGameResolutionUpdate()}_forceGameResolutionUpdate(){this.setGameResolutionSize(this._gameResolutionWidth,this._gameResolutionHeight)}startCurrentSceneProfiler(e){this._throwIfDisposed();const t=this._sceneStack.getCurrentScene();return t?(t.startProfiler(e),!0):!1}stopCurrentSceneProfiler(){this._throwIfDisposed();const e=this._sceneStack.getCurrentScene();!e||e.stopProfiler()}wasFirstSceneLoaded(){return this._sceneStack.wasFirstSceneLoaded()}getSceneStack(){return this._sceneStack}isPreview(){return this._isPreview}isUsingGDevelopDevelopmentEnvironment(){return this._options.environment==="dev"}getExtensionProperty(e,t){for(let s of this._data.properties.extensionProperties)if(s.extension===e&&s.property===t)return s.value;return null}resolveEmbeddedResource(e,t){const s=this._embeddedResourcesMappings.get(e);return s&&s[t]?s[t]:t}getEmbeddedResourcesNames(e){return this._embeddedResourcesMappings.has(e)?Object.keys(this._embeddedResourcesMappings.get(e)):[]}getNetworkSyncData(e){const t={var:this._variables.getNetworkSyncData(e),ss:this._sceneStack.getNetworkSyncData(e)||void 0},s={};return this._variablesByExtensionName.forEach((i,r)=>{const o=i.getNetworkSyncData(e);o.length&&(s[r]=o)}),t.extVar=s,(!t.var||t.var.length===0)&&!t.ss&&(!t.extVar||Object.keys(t.extVar).length===0)?null:t}updateFromNetworkSyncData(e){if(this._throwIfDisposed(),e.var&&this._variables.updateFromNetworkSyncData(e.var),e.ss&&this._sceneStack.updateFromNetworkSyncData(e.ss),e.extVar)for(const t in e.extVar){if(!e.extVar.hasOwnProperty(t))continue;const s=e.extVar[t],i=this.getVariablesForExtension(t);i&&i.updateFromNetworkSyncData(s)}}_throwIfDisposed(){if(this._wasDisposed)throw"The RuntimeGame has been disposed and should not be used anymore."}}n.RuntimeGame=_})(gdjs||(gdjs={}));
|
|
2
2
|
//# sourceMappingURL=runtimegame.js.map
|