gdcore-tools 2.0.0-beta2 → 2.0.0-beta4
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/AsyncTasksManager.js +2 -2
- package/dist/Runtime/AsyncTasksManager.js.map +2 -2
- package/dist/Runtime/Cordova/config.xml +23 -1
- package/dist/Runtime/Cordova/www/LICENSE.GDevelop.txt +2 -0
- package/dist/Runtime/Cordova/www/index.html +1 -1
- package/dist/Runtime/CustomRuntimeObject.js +1 -1
- package/dist/Runtime/CustomRuntimeObject.js.map +2 -2
- package/dist/Runtime/CustomRuntimeObject2D.js +2 -0
- package/dist/Runtime/CustomRuntimeObject2D.js.map +7 -0
- package/dist/Runtime/CustomRuntimeObjectInstanceContainer.js +1 -1
- package/dist/Runtime/CustomRuntimeObjectInstanceContainer.js.map +2 -2
- package/dist/Runtime/Electron/LICENSE.GDevelop.txt +2 -0
- package/dist/Runtime/Electron/package.json +3 -0
- package/dist/Runtime/Extensions/3D/A_RuntimeObject3D.js +1 -1
- package/dist/Runtime/Extensions/3D/A_RuntimeObject3D.js.map +2 -2
- package/dist/Runtime/Extensions/3D/A_RuntimeObject3DRenderer.js +1 -1
- package/dist/Runtime/Extensions/3D/A_RuntimeObject3DRenderer.js.map +2 -2
- package/dist/Runtime/Extensions/3D/AmbientLight.js +1 -1
- package/dist/Runtime/Extensions/3D/AmbientLight.js.map +2 -2
- package/dist/Runtime/Extensions/3D/Base3DBehavior.js +1 -1
- package/dist/Runtime/Extensions/3D/Base3DBehavior.js.map +2 -2
- package/dist/Runtime/Extensions/3D/BloomEffect.js +1 -1
- package/dist/Runtime/Extensions/3D/BloomEffect.js.map +2 -2
- package/dist/Runtime/Extensions/3D/BrightnessAndContrastEffect.js +1 -1
- package/dist/Runtime/Extensions/3D/BrightnessAndContrastEffect.js.map +2 -2
- package/dist/Runtime/Extensions/3D/CMakeLists.txt +23 -0
- package/dist/Runtime/Extensions/3D/Cube3DRuntimeObject.js +1 -1
- package/dist/Runtime/Extensions/3D/Cube3DRuntimeObject.js.map +2 -2
- package/dist/Runtime/Extensions/3D/CustomRuntimeObject3D.js +2 -0
- package/dist/Runtime/Extensions/3D/CustomRuntimeObject3D.js.map +7 -0
- package/dist/Runtime/Extensions/3D/CustomRuntimeObject3DRenderer.js +2 -0
- package/dist/Runtime/Extensions/3D/CustomRuntimeObject3DRenderer.js.map +7 -0
- package/dist/Runtime/Extensions/3D/DirectionalLight.js +1 -1
- package/dist/Runtime/Extensions/3D/DirectionalLight.js.map +2 -2
- package/dist/Runtime/Extensions/3D/ExponentialFog.js +1 -1
- package/dist/Runtime/Extensions/3D/ExponentialFog.js.map +2 -2
- package/dist/Runtime/Extensions/3D/ExposureEffect.js +1 -1
- package/dist/Runtime/Extensions/3D/ExposureEffect.js.map +2 -2
- package/dist/Runtime/Extensions/3D/HemisphereLight.js +1 -1
- package/dist/Runtime/Extensions/3D/HemisphereLight.js.map +2 -2
- package/dist/Runtime/Extensions/3D/HueAndSaturationEffect.js +1 -1
- package/dist/Runtime/Extensions/3D/HueAndSaturationEffect.js.map +2 -2
- package/dist/Runtime/Extensions/3D/JsExtension.js +56 -24
- package/dist/Runtime/Extensions/3D/LinearFog.js +1 -1
- package/dist/Runtime/Extensions/3D/LinearFog.js.map +2 -2
- package/dist/Runtime/Extensions/3D/Model3DRuntimeObject.js +1 -1
- package/dist/Runtime/Extensions/3D/Model3DRuntimeObject.js.map +2 -2
- package/dist/Runtime/Extensions/3D/Model3DRuntimeObject3DRenderer.js +1 -1
- package/dist/Runtime/Extensions/3D/Model3DRuntimeObject3DRenderer.js.map +2 -2
- package/dist/Runtime/Extensions/AdMob/JsExtension.js +11 -10
- package/dist/Runtime/Extensions/AdMob/admobtools.js +1 -1
- package/dist/Runtime/Extensions/AdMob/admobtools.js.map +2 -2
- package/dist/Runtime/Extensions/AnchorBehavior/CMakeLists.txt +23 -0
- package/dist/Runtime/Extensions/BBText/JsExtension.js +20 -11
- package/dist/Runtime/Extensions/BBText/bbtextruntimeobject.js +1 -1
- package/dist/Runtime/Extensions/BBText/bbtextruntimeobject.js.map +2 -2
- package/dist/Runtime/Extensions/BitmapText/JsExtension.js +2 -8
- package/dist/Runtime/Extensions/BitmapText/bitmaptextruntimeobject.js +1 -1
- package/dist/Runtime/Extensions/BitmapText/bitmaptextruntimeobject.js.map +2 -2
- package/dist/Runtime/Extensions/CMakeLists.txt +35 -0
- package/dist/Runtime/Extensions/CMakeUtils.txt +81 -0
- package/dist/Runtime/Extensions/DestroyOutsideBehavior/CMakeLists.txt +23 -0
- package/dist/Runtime/Extensions/DestroyOutsideBehavior/destroyoutsideruntimebehavior.js.map +2 -2
- package/dist/Runtime/Extensions/DialogueTree/bondage.js/version.txt +5 -0
- package/dist/Runtime/Extensions/DraggableBehavior/CMakeLists.txt +23 -0
- package/dist/Runtime/Extensions/Effects/adjustment-pixi-filter.js +1 -1
- package/dist/Runtime/Extensions/Effects/adjustment-pixi-filter.js.map +2 -2
- package/dist/Runtime/Extensions/Effects/advanced-bloom-pixi-filter.js +1 -1
- package/dist/Runtime/Extensions/Effects/advanced-bloom-pixi-filter.js.map +2 -2
- package/dist/Runtime/Extensions/Effects/ascii-pixi-filter.js +1 -1
- package/dist/Runtime/Extensions/Effects/ascii-pixi-filter.js.map +2 -2
- package/dist/Runtime/Extensions/Effects/bevel-pixi-filter.js +1 -1
- package/dist/Runtime/Extensions/Effects/bevel-pixi-filter.js.map +2 -2
- package/dist/Runtime/Extensions/Effects/black-and-white-pixi-filter.js +1 -1
- package/dist/Runtime/Extensions/Effects/black-and-white-pixi-filter.js.map +2 -2
- package/dist/Runtime/Extensions/Effects/blending-mode-pixi-filter.js +1 -1
- package/dist/Runtime/Extensions/Effects/blending-mode-pixi-filter.js.map +2 -2
- package/dist/Runtime/Extensions/Effects/blur-pixi-filter.js +1 -1
- package/dist/Runtime/Extensions/Effects/blur-pixi-filter.js.map +2 -2
- package/dist/Runtime/Extensions/Effects/brightness-pixi-filter.js +1 -1
- package/dist/Runtime/Extensions/Effects/brightness-pixi-filter.js.map +2 -2
- package/dist/Runtime/Extensions/Effects/bulge-pinch-pixi-filter.js +1 -1
- package/dist/Runtime/Extensions/Effects/bulge-pinch-pixi-filter.js.map +2 -2
- package/dist/Runtime/Extensions/Effects/color-map-pixi-filter.js +1 -1
- package/dist/Runtime/Extensions/Effects/color-map-pixi-filter.js.map +2 -2
- package/dist/Runtime/Extensions/Effects/color-replace-pixi-filter.js +1 -1
- package/dist/Runtime/Extensions/Effects/color-replace-pixi-filter.js.map +2 -2
- package/dist/Runtime/Extensions/Effects/crt-pixi-filter.js +1 -1
- package/dist/Runtime/Extensions/Effects/crt-pixi-filter.js.map +2 -2
- package/dist/Runtime/Extensions/Effects/displacement-pixi-filter.js +1 -1
- package/dist/Runtime/Extensions/Effects/displacement-pixi-filter.js.map +2 -2
- package/dist/Runtime/Extensions/Effects/dot-pixi-filter.js +1 -1
- package/dist/Runtime/Extensions/Effects/dot-pixi-filter.js.map +2 -2
- package/dist/Runtime/Extensions/Effects/drop-shadow-pixi-filter.js +1 -1
- package/dist/Runtime/Extensions/Effects/drop-shadow-pixi-filter.js.map +2 -2
- package/dist/Runtime/Extensions/Effects/glitch-pixi-filter.js +1 -1
- package/dist/Runtime/Extensions/Effects/glitch-pixi-filter.js.map +2 -2
- package/dist/Runtime/Extensions/Effects/glow-pixi-filter.js +1 -1
- package/dist/Runtime/Extensions/Effects/glow-pixi-filter.js.map +2 -2
- package/dist/Runtime/Extensions/Effects/godray-pixi-filter.js +1 -1
- package/dist/Runtime/Extensions/Effects/godray-pixi-filter.js.map +2 -2
- package/dist/Runtime/Extensions/Effects/hsl-adjustment-pixi-filter.js +1 -1
- package/dist/Runtime/Extensions/Effects/hsl-adjustment-pixi-filter.js.map +2 -2
- package/dist/Runtime/Extensions/Effects/kawase-blur-pixi-filter.js +1 -1
- package/dist/Runtime/Extensions/Effects/kawase-blur-pixi-filter.js.map +2 -2
- package/dist/Runtime/Extensions/Effects/light-night-pixi-filter.js +2 -2
- package/dist/Runtime/Extensions/Effects/light-night-pixi-filter.js.map +2 -2
- package/dist/Runtime/Extensions/Effects/motion-blur-pixi-filter.js +1 -1
- package/dist/Runtime/Extensions/Effects/motion-blur-pixi-filter.js.map +2 -2
- package/dist/Runtime/Extensions/Effects/night-pixi-filter.js +2 -2
- package/dist/Runtime/Extensions/Effects/night-pixi-filter.js.map +2 -2
- package/dist/Runtime/Extensions/Effects/noise-pixi-filter.js +1 -1
- package/dist/Runtime/Extensions/Effects/noise-pixi-filter.js.map +2 -2
- package/dist/Runtime/Extensions/Effects/old-film-pixi-filter.js +1 -1
- package/dist/Runtime/Extensions/Effects/old-film-pixi-filter.js.map +2 -2
- package/dist/Runtime/Extensions/Effects/outline-pixi-filter.js +1 -1
- package/dist/Runtime/Extensions/Effects/outline-pixi-filter.js.map +2 -2
- package/dist/Runtime/Extensions/Effects/pixelate-pixi-filter.js +1 -1
- package/dist/Runtime/Extensions/Effects/pixelate-pixi-filter.js.map +2 -2
- package/dist/Runtime/Extensions/Effects/radial-blur-pixi-filter.js +1 -1
- package/dist/Runtime/Extensions/Effects/radial-blur-pixi-filter.js.map +2 -2
- package/dist/Runtime/Extensions/Effects/reflection-pixi-filter.js +1 -1
- package/dist/Runtime/Extensions/Effects/reflection-pixi-filter.js.map +2 -2
- package/dist/Runtime/Extensions/Effects/rgb-split-pixi-filter.js +1 -1
- package/dist/Runtime/Extensions/Effects/rgb-split-pixi-filter.js.map +2 -2
- package/dist/Runtime/Extensions/Effects/sepia-pixi-filter.js +1 -1
- package/dist/Runtime/Extensions/Effects/sepia-pixi-filter.js.map +2 -2
- package/dist/Runtime/Extensions/Effects/shockwave-pixi-filter.js +1 -1
- package/dist/Runtime/Extensions/Effects/shockwave-pixi-filter.js.map +2 -2
- package/dist/Runtime/Extensions/Effects/tilt-shift-pixi-filter.js +1 -1
- package/dist/Runtime/Extensions/Effects/tilt-shift-pixi-filter.js.map +2 -2
- package/dist/Runtime/Extensions/Effects/twist-pixi-filter.js +1 -1
- package/dist/Runtime/Extensions/Effects/twist-pixi-filter.js.map +2 -2
- package/dist/Runtime/Extensions/Effects/zoom-blur-pixi-filter.js +1 -1
- package/dist/Runtime/Extensions/Effects/zoom-blur-pixi-filter.js.map +2 -2
- package/dist/Runtime/Extensions/ExampleJsExtension/JsExtension.js +2 -11
- package/dist/Runtime/Extensions/ExampleJsExtension/dummyeffect.js +1 -1
- package/dist/Runtime/Extensions/ExampleJsExtension/dummyeffect.js.map +2 -2
- package/dist/Runtime/Extensions/FileSystem/JsExtension.js +22 -0
- package/dist/Runtime/Extensions/FileSystem/filesystemtools.js +1 -1
- package/dist/Runtime/Extensions/FileSystem/filesystemtools.js.map +2 -2
- package/dist/Runtime/Extensions/Firebase/A_firebasejs/NOTICE.txt +6 -0
- package/dist/Runtime/Extensions/Inventory/CMakeLists.txt +23 -0
- package/dist/Runtime/Extensions/JsExtensionTypes.d.ts +13 -4
- package/dist/Runtime/Extensions/Leaderboards/JsExtension.js +42 -1
- package/dist/Runtime/Extensions/Leaderboards/leaderboardstools.js +1 -1
- package/dist/Runtime/Extensions/Leaderboards/leaderboardstools.js.map +2 -2
- package/dist/Runtime/Extensions/Lighting/JsExtension.js +2 -11
- package/dist/Runtime/Extensions/Lighting/lightruntimeobject.js +1 -1
- package/dist/Runtime/Extensions/Lighting/lightruntimeobject.js.map +2 -2
- package/dist/Runtime/Extensions/LinkedObjects/CMakeLists.txt +23 -0
- package/dist/Runtime/Extensions/LinkedObjects/linkedobjects.js +1 -1
- package/dist/Runtime/Extensions/LinkedObjects/linkedobjects.js.map +2 -2
- package/dist/Runtime/Extensions/Multiplayer/JsExtension.js +1130 -0
- package/dist/Runtime/Extensions/Multiplayer/messageManager.js +2 -0
- package/dist/Runtime/Extensions/Multiplayer/messageManager.js.map +7 -0
- package/dist/Runtime/Extensions/Multiplayer/multiplayerVariablesManager.js +2 -0
- package/dist/Runtime/Extensions/Multiplayer/multiplayerVariablesManager.js.map +7 -0
- package/dist/Runtime/Extensions/Multiplayer/multiplayercomponents.js +2 -0
- package/dist/Runtime/Extensions/Multiplayer/multiplayercomponents.js.map +7 -0
- package/dist/Runtime/Extensions/Multiplayer/multiplayerobjectruntimebehavior.js +2 -0
- package/dist/Runtime/Extensions/Multiplayer/multiplayerobjectruntimebehavior.js.map +7 -0
- package/dist/Runtime/Extensions/Multiplayer/multiplayertools.js +2 -0
- package/dist/Runtime/Extensions/Multiplayer/multiplayertools.js.map +7 -0
- package/dist/Runtime/Extensions/Multiplayer/peer.js +10 -0
- package/dist/Runtime/Extensions/Multiplayer/peer.js.map +1 -0
- package/dist/Runtime/Extensions/Multiplayer/peerJsHelper.js +2 -0
- package/dist/Runtime/Extensions/Multiplayer/peerJsHelper.js.map +7 -0
- package/dist/Runtime/Extensions/Multiplayer/peerjs.d.ts +509 -0
- package/dist/Runtime/Extensions/P2P/A_peer.js +8 -2
- package/dist/Runtime/Extensions/P2P/A_peer.js.map +1 -1
- package/dist/Runtime/Extensions/P2P/B_p2ptools.js +1 -1
- package/dist/Runtime/Extensions/P2P/B_p2ptools.js.map +2 -2
- package/dist/Runtime/Extensions/P2P/JsExtension.js +27 -0
- package/dist/Runtime/Extensions/PanelSpriteObject/CMakeLists.txt +23 -0
- package/dist/Runtime/Extensions/PanelSpriteObject/panelspriteruntimeobject.js +1 -1
- package/dist/Runtime/Extensions/PanelSpriteObject/panelspriteruntimeobject.js.map +2 -2
- package/dist/Runtime/Extensions/ParticleSystem/CMakeLists.txt +23 -0
- package/dist/Runtime/Extensions/ParticleSystem/particleemitterobject-pixi-renderer.js +1 -1
- package/dist/Runtime/Extensions/ParticleSystem/particleemitterobject-pixi-renderer.js.map +2 -2
- package/dist/Runtime/Extensions/ParticleSystem/particleemitterobject.js +1 -1
- package/dist/Runtime/Extensions/ParticleSystem/particleemitterobject.js.map +2 -2
- package/dist/Runtime/Extensions/PathfindingBehavior/CMakeLists.txt +23 -0
- package/dist/Runtime/Extensions/PathfindingBehavior/pathfindingruntimebehavior.js +1 -1
- package/dist/Runtime/Extensions/PathfindingBehavior/pathfindingruntimebehavior.js.map +2 -2
- package/dist/Runtime/Extensions/Physics2Behavior/JsExtension.js +47 -4
- package/dist/Runtime/Extensions/Physics2Behavior/physics2runtimebehavior.js +1 -1
- package/dist/Runtime/Extensions/Physics2Behavior/physics2runtimebehavior.js.map +2 -2
- package/dist/Runtime/Extensions/PhysicsBehavior/CMakeLists.txt +23 -0
- package/dist/Runtime/Extensions/PlatformBehavior/CMakeLists.txt +23 -0
- package/dist/Runtime/Extensions/PlatformBehavior/platformerobjectruntimebehavior.js +1 -1
- package/dist/Runtime/Extensions/PlatformBehavior/platformerobjectruntimebehavior.js.map +2 -2
- package/dist/Runtime/Extensions/PlatformBehavior/platformruntimebehavior.js +1 -1
- package/dist/Runtime/Extensions/PlatformBehavior/platformruntimebehavior.js.map +2 -2
- package/dist/Runtime/Extensions/PlayerAuthentication/JsExtension.js +6 -3
- package/dist/Runtime/Extensions/PlayerAuthentication/playerauthenticationcomponents.js +4 -4
- package/dist/Runtime/Extensions/PlayerAuthentication/playerauthenticationcomponents.js.map +2 -2
- package/dist/Runtime/Extensions/PlayerAuthentication/playerauthenticationtools.js +1 -1
- package/dist/Runtime/Extensions/PlayerAuthentication/playerauthenticationtools.js.map +2 -2
- package/dist/Runtime/Extensions/PrimitiveDrawing/CMakeLists.txt +23 -0
- package/dist/Runtime/Extensions/PrimitiveDrawing/shapepainterruntimeobject-pixi-renderer.js +1 -1
- package/dist/Runtime/Extensions/PrimitiveDrawing/shapepainterruntimeobject-pixi-renderer.js.map +2 -2
- package/dist/Runtime/Extensions/PrimitiveDrawing/shapepainterruntimeobject.js +1 -1
- package/dist/Runtime/Extensions/PrimitiveDrawing/shapepainterruntimeobject.js.map +2 -2
- package/dist/Runtime/Extensions/Shopify/CMakeLists.txt +26 -0
- package/dist/Runtime/Extensions/Spine/CMakeLists.txt +20 -0
- package/dist/Runtime/Extensions/Spine/JsExtension.js +11 -2
- package/dist/Runtime/Extensions/Spine/managers/pixi-spine-atlas-manager.js +1 -1
- package/dist/Runtime/Extensions/Spine/managers/pixi-spine-atlas-manager.js.map +2 -2
- package/dist/Runtime/Extensions/Spine/managers/pixi-spine-manager.js +1 -1
- package/dist/Runtime/Extensions/Spine/managers/pixi-spine-manager.js.map +2 -2
- package/dist/Runtime/Extensions/Spine/pixi-spine/Spine-Runtimes-License-Agreement.txt +11 -0
- package/dist/Runtime/Extensions/Spine/pixi-spine/pixi-spine.js +5 -3
- package/dist/Runtime/Extensions/Spine/spineruntimeobject.js +1 -1
- package/dist/Runtime/Extensions/Spine/spineruntimeobject.js.map +2 -2
- package/dist/Runtime/Extensions/SystemInfo/CMakeLists.txt +23 -0
- package/dist/Runtime/Extensions/TextEntryObject/CMakeLists.txt +23 -0
- package/dist/Runtime/Extensions/TextInput/JsExtension.js +3 -10
- package/dist/Runtime/Extensions/TextInput/textinputruntimeobject-pixi-renderer.js +1 -1
- package/dist/Runtime/Extensions/TextInput/textinputruntimeobject-pixi-renderer.js.map +2 -2
- package/dist/Runtime/Extensions/TextInput/textinputruntimeobject.js +1 -1
- package/dist/Runtime/Extensions/TextInput/textinputruntimeobject.js.map +2 -2
- package/dist/Runtime/Extensions/TextObject/CMakeLists.txt +23 -0
- package/dist/Runtime/Extensions/TextObject/textruntimeobject.js +1 -1
- package/dist/Runtime/Extensions/TextObject/textruntimeobject.js.map +2 -2
- package/dist/Runtime/Extensions/TileMap/JsExtension.js +834 -23
- package/dist/Runtime/Extensions/TileMap/TileMapRuntimeManager.js +1 -1
- package/dist/Runtime/Extensions/TileMap/TileMapRuntimeManager.js.map +2 -2
- package/dist/Runtime/Extensions/TileMap/collision/TransformedTileMap.js +1 -1
- package/dist/Runtime/Extensions/TileMap/collision/TransformedTileMap.js.map +2 -2
- package/dist/Runtime/Extensions/TileMap/helper/TileMapHelper.d.ts +2 -0
- 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/helper/dts/model/CommonTypes.d.ts +12 -0
- package/dist/Runtime/Extensions/TileMap/helper/dts/model/CommonTypes.d.ts.map +1 -1
- package/dist/Runtime/Extensions/TileMap/helper/dts/model/TileMapModel.d.ts +119 -5
- package/dist/Runtime/Extensions/TileMap/helper/dts/model/TileMapModel.d.ts.map +1 -1
- package/dist/Runtime/Extensions/TileMap/helper/dts/render/TileMapManager.d.ts +25 -0
- package/dist/Runtime/Extensions/TileMap/helper/dts/render/TileMapManager.d.ts.map +1 -1
- package/dist/Runtime/Extensions/TileMap/helper/dts/render/TileMapPixiHelper.d.ts +16 -1
- package/dist/Runtime/Extensions/TileMap/helper/dts/render/TileMapPixiHelper.d.ts.map +1 -1
- package/dist/Runtime/Extensions/TileMap/simpletilemapruntimeobject.js +2 -0
- package/dist/Runtime/Extensions/TileMap/simpletilemapruntimeobject.js.map +7 -0
- package/dist/Runtime/Extensions/TileMap/tilemapcollisionmaskruntimeobject.js +1 -1
- package/dist/Runtime/Extensions/TileMap/tilemapcollisionmaskruntimeobject.js.map +2 -2
- package/dist/Runtime/Extensions/TileMap/tilemapruntimeobject-pixi-renderer.js +1 -1
- package/dist/Runtime/Extensions/TileMap/tilemapruntimeobject-pixi-renderer.js.map +2 -2
- package/dist/Runtime/Extensions/TileMap/tilemapruntimeobject.js +1 -1
- package/dist/Runtime/Extensions/TileMap/tilemapruntimeobject.js.map +2 -2
- package/dist/Runtime/Extensions/TiledSpriteObject/CMakeLists.txt +23 -0
- package/dist/Runtime/Extensions/TiledSpriteObject/tiledspriteruntimeobject.js +1 -1
- package/dist/Runtime/Extensions/TiledSpriteObject/tiledspriteruntimeobject.js.map +2 -2
- package/dist/Runtime/Extensions/TopDownMovementBehavior/CMakeLists.txt +23 -0
- package/dist/Runtime/Extensions/TopDownMovementBehavior/topdownmovementruntimebehavior.js +1 -1
- package/dist/Runtime/Extensions/TopDownMovementBehavior/topdownmovementruntimebehavior.js.map +2 -2
- package/dist/Runtime/Extensions/TweenBehavior/JsExtension.js +2 -2
- package/dist/Runtime/Extensions/TweenBehavior/tweenruntimebehavior.js +1 -1
- package/dist/Runtime/Extensions/TweenBehavior/tweenruntimebehavior.js.map +2 -2
- package/dist/Runtime/Extensions/Video/JsExtension.js +2 -11
- package/dist/Runtime/Extensions/Video/videoruntimeobject.js +1 -1
- package/dist/Runtime/Extensions/Video/videoruntimeobject.js.map +2 -2
- package/dist/Runtime/RuntimeInstanceContainer.js +1 -1
- package/dist/Runtime/RuntimeInstanceContainer.js.map +2 -2
- package/dist/Runtime/SpriteAnimator.js +2 -0
- package/dist/Runtime/SpriteAnimator.js.map +7 -0
- package/dist/Runtime/debugger-client/hot-reloader.js +1 -1
- package/dist/Runtime/debugger-client/hot-reloader.js.map +2 -2
- package/dist/Runtime/events-tools/objecttools.js +1 -1
- package/dist/Runtime/events-tools/objecttools.js.map +2 -2
- package/dist/Runtime/events-tools/runtimescenetools.js +1 -1
- package/dist/Runtime/events-tools/runtimescenetools.js.map +2 -2
- package/dist/Runtime/force.js +1 -1
- package/dist/Runtime/force.js.map +2 -2
- package/dist/Runtime/object-capabilities/TextContainerBehavior.js.map +1 -1
- package/dist/Runtime/pixi-renderers/CustomRuntimeObject2DPixiRenderer.js +2 -0
- package/dist/Runtime/pixi-renderers/CustomRuntimeObject2DPixiRenderer.js.map +7 -0
- package/dist/Runtime/pixi-renderers/DebuggerPixiRenderer.js +1 -1
- package/dist/Runtime/pixi-renderers/DebuggerPixiRenderer.js.map +2 -2
- package/dist/Runtime/pixi-renderers/layer-pixi-renderer.js +2 -2
- package/dist/Runtime/pixi-renderers/layer-pixi-renderer.js.map +2 -2
- package/dist/Runtime/pixi-renderers/pixi-filters-tools.js +1 -1
- package/dist/Runtime/pixi-renderers/pixi-filters-tools.js.map +2 -2
- 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/pixi-renderers/spriteruntimeobject-pixi-renderer.js +1 -1
- package/dist/Runtime/pixi-renderers/spriteruntimeobject-pixi-renderer.js.map +2 -2
- package/dist/Runtime/polygon.js +1 -1
- package/dist/Runtime/polygon.js.map +2 -2
- package/dist/Runtime/runtimebehavior.js +1 -1
- package/dist/Runtime/runtimebehavior.js.map +2 -2
- package/dist/Runtime/runtimegame.js +1 -1
- package/dist/Runtime/runtimegame.js.map +2 -2
- package/dist/Runtime/runtimeobject.js +1 -1
- package/dist/Runtime/runtimeobject.js.map +2 -2
- package/dist/Runtime/runtimescene.js +1 -1
- package/dist/Runtime/runtimescene.js.map +2 -2
- package/dist/Runtime/scenestack.js +1 -1
- package/dist/Runtime/scenestack.js.map +2 -2
- package/dist/Runtime/spriteruntimeobject.js +1 -1
- package/dist/Runtime/spriteruntimeobject.js.map +2 -2
- package/dist/Runtime/timer.js +1 -1
- package/dist/Runtime/timer.js.map +2 -2
- package/dist/Runtime/types/project-data.d.ts +115 -0
- package/dist/Runtime/variable.js +1 -1
- package/dist/Runtime/variable.js.map +2 -2
- package/dist/Runtime/variablescontainer.js +1 -1
- package/dist/Runtime/variablescontainer.js.map +2 -2
- package/dist/lib/libGD.cjs +2 -1
- package/dist/lib/libGD.wasm +0 -0
- package/dist/loaders.cjs +2 -1
- package/gd.d.ts +217 -223
- package/package.json +15 -7
- package/src/index.js +2 -0
- package/src/open_project.js +1 -1
- package/types/index.d.ts +2 -2
- package/types/open_project.d.ts +5 -5
- package/dist/Runtime/Extensions/Spine/pixi-spine/pixi-spine.js.map +0 -7
- package/dist/Runtime/pixi-renderers/CustomObjectPixiRenderer.js +0 -2
- package/dist/Runtime/pixi-renderers/CustomObjectPixiRenderer.js.map +0 -7
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../GDevelop/GDJS/Runtime/pixi-renderers/pixi-filters-tools.ts"],
|
|
4
|
-
"sourcesContent": ["namespace gdjs {\n const logger = new gdjs.Logger('Filters');\n\n export namespace PixiFiltersTools {\n export const clampValue = function (value, min, max) {\n return Math.max(min, Math.min(max, value));\n };\n\n export const clampKernelSize = function (value, min, max) {\n const len = Math.round((max - min) / 2 + 1);\n const arr = new Array(len);\n for (let i = 0; i < len; i++) {\n arr[i] = min + 2 * i;\n }\n return arr.indexOf(value) !== -1 ? value : min;\n };\n\n const _filterCreators: {\n [filterName: string]: FilterCreator;\n } = {};\n\n /**\n * Return the creator for the filter with the given name, if any.\n * @param filterName The name of the filter to get\n * @return The filter creator, if any (null otherwise).\n */\n export const getFilterCreator = function (\n filterName: string\n ): FilterCreator | null {\n if (_filterCreators.hasOwnProperty(filterName)) {\n return _filterCreators[filterName];\n }\n return null;\n };\n\n /**\n * Register a new PIXI filter creator, to be used by GDJS.\n * @param filterName The name of the filter to get\n * @param filterCreator The object used to create the filter.\n */\n export const registerFilterCreator = function (\n filterName: string,\n filterCreator: FilterCreator\n ) {\n if (_filterCreators.hasOwnProperty(filterName)) {\n logger.warn(\n 'Filter \"' +\n filterName +\n '\" was already registered in gdjs.PixiFiltersTools. Replacing it with the new one.'\n );\n }\n _filterCreators[filterName] = filterCreator;\n };\n\n /**\n * Convert a string RGB color (\"rrr;ggg;bbb\") or a hex string (#rrggbb) to a hex number.\n * @param value The color as a RGB string or hex string\n */\n export const rgbOrHexToHexNumber = function (value: string): number {\n const splitValue = value.split(';');\n if (splitValue.length === 3) {\n return gdjs.rgbToHexNumber(\n parseInt(splitValue[0], 10),\n parseInt(splitValue[1], 10),\n parseInt(splitValue[2], 10)\n );\n }\n return parseInt(value.replace('#', '0x'), 16);\n };\n\n /** A wrapper allowing to create an effect. */\n export interface FilterCreator {\n /** Function to call to create the filter */\n makeFilter(target: EffectsTarget, effectData: EffectData): Filter;\n }\n\n /** An effect. */\n export interface Filter {\n /**\n * Check if an effect is enabled.\n * @return true if the filter is enabled\n */\n isEnabled(target: EffectsTarget): boolean;\n /**\n * Enable an effect.\n * @param enabled Set to true to enable, false to disable\n */\n setEnabled(target: EffectsTarget, enabled: boolean): boolean;\n /**\n * Apply the effect on the PixiJS DisplayObject.\n * Called after the effect is initialized.\n * @param rendererObject The renderer object\n * @param effect The effect to be applied.\n */\n applyEffect(target: EffectsTarget): boolean;\n removeEffect(target: EffectsTarget): boolean;\n /** The function to be called to update the filter at every frame before the rendering. */\n updatePreRender(target: gdjs.EffectsTarget): any;\n /** The function to be called to update a parameter (with a number) */\n updateDoubleParameter(\n //filter: PIXI.Filter,\n parameterName: string,\n value: number\n ): void;\n /** The function to be called to update a parameter (with a string) */\n updateStringParameter(parameterName: string, value: string): void;\n /** The function to be called to update a parameter (with a boolean) */\n updateBooleanParameter(parameterName: string, value: boolean): void;\n updateColorParameter(parameterName: string, value: number): void;\n getDoubleParameter(parameterName: string): number;\n getColorParameter(parameterName: string): number;\n }\n\n /** A wrapper allowing to create a PIXI filter and update it using a common interface */\n export abstract class PixiFilterCreator implements FilterCreator {\n /** Function to call to create the filter */\n makeFilter(target: EffectsTarget, effectData: EffectData): Filter {\n const pixiFilter = this.makePIXIFilter(target, effectData);\n if (target.isLightingLayer && target.isLightingLayer()) {\n pixiFilter.blendMode = PIXI.BLEND_MODES.ADD;\n }\n return new PixiFilter(pixiFilter, this);\n }\n /** Function to call to create the filter */\n abstract makePIXIFilter(\n target: EffectsTarget,\n effectData: EffectData\n ): any;\n /** The function to be called to update the filter at every frame before the rendering. */\n abstract updatePreRender(\n filter: PIXI.Filter,\n target: gdjs.EffectsTarget\n ): any;\n /** The function to be called to update a parameter (with a number) */\n abstract updateDoubleParameter(\n filter: PIXI.Filter,\n parameterName: string,\n value: number\n ): void;\n /** The function to be called to update a parameter (with a string) */\n abstract updateStringParameter(\n filter: PIXI.Filter,\n parameterName: string,\n value: string\n ): void;\n /** The function to be called to update a parameter (with a boolean) */\n abstract updateBooleanParameter(\n filter: PIXI.Filter,\n parameterName: string,\n value: boolean\n ): void;\n abstract updateColorParameter(\n filter: PIXI.Filter,\n parameterName: string,\n value: number\n ): void;\n abstract getDoubleParameter(\n filter: PIXI.Filter,\n parameterName: string\n ): number;\n abstract getColorParameter(\n filter: PIXI.Filter,\n parameterName: string\n ): number;\n }\n\n /**An effect used to manipulate a Pixi filter. */\n export class PixiFilter implements Filter {\n /** The PIXI filter */\n pixiFilter: PIXI.Filter;\n filterCreator: gdjs.PixiFiltersTools.PixiFilterCreator;\n\n constructor(\n pixiFilter: PIXI.Filter,\n filterCreator: gdjs.PixiFiltersTools.PixiFilterCreator\n ) {\n this.pixiFilter = pixiFilter;\n this.filterCreator = filterCreator;\n }\n\n isEnabled(target: EffectsTarget): boolean {\n return this.pixiFilter.enabled;\n }\n\n setEnabled(target: EffectsTarget, enabled: boolean): boolean {\n return (this.pixiFilter.enabled = enabled);\n }\n\n applyEffect(target: EffectsTarget): boolean {\n const rendererObject = target.getRendererObject() as\n | PIXI.DisplayObject\n | null\n | undefined;\n if (!rendererObject) {\n return false;\n }\n rendererObject.filters = (rendererObject.filters || []).concat(\n this.pixiFilter\n );\n return true;\n }\n\n removeEffect(target: EffectsTarget): boolean {\n const rendererObject = target.getRendererObject() as\n | PIXI.DisplayObject\n | null\n | undefined;\n if (!rendererObject) {\n return false;\n }\n rendererObject.filters = (rendererObject.filters || []).filter(\n (pixiFilter) => pixiFilter !== this.pixiFilter\n );\n return true;\n }\n\n updatePreRender(target: gdjs.EffectsTarget): any {\n this.filterCreator.updatePreRender(this.pixiFilter, target);\n }\n\n updateDoubleParameter(parameterName: string, value: number): void {\n this.filterCreator.updateDoubleParameter(\n this.pixiFilter,\n parameterName,\n value\n );\n }\n\n updateStringParameter(parameterName: string, value: string): void {\n this.filterCreator.updateStringParameter(\n this.pixiFilter,\n parameterName,\n value\n );\n }\n\n updateBooleanParameter(parameterName: string, value: boolean): void {\n this.filterCreator.updateBooleanParameter(\n this.pixiFilter,\n parameterName,\n value\n );\n }\n\n updateColorParameter(parameterName: string, value: number): void {\n this.filterCreator.updateColorParameter(\n this.pixiFilter,\n parameterName,\n value\n );\n }\n\n getDoubleParameter(parameterName: string): number {\n return this.filterCreator.getDoubleParameter(\n this.pixiFilter,\n parameterName\n );\n }\n\n getColorParameter(parameterName: string): number {\n return this.filterCreator.getColorParameter(\n this.pixiFilter,\n parameterName\n );\n }\n }\n\n export class EmptyFilter implements Filter {\n isEnabled(target: EffectsTarget): boolean {\n return false;\n }\n setEnabled(target: EffectsTarget, enabled: boolean): boolean {\n return false;\n }\n applyEffect(target: EffectsTarget): boolean {\n return false;\n }\n removeEffect(target: EffectsTarget): boolean {\n return false;\n }\n updatePreRender(target: gdjs.EffectsTarget): any {}\n updateDoubleParameter(parameterName: string, value: number): void {}\n updateStringParameter(parameterName: string, value: string): void {}\n updateBooleanParameter(parameterName: string, value: boolean): void {}\n updateColorParameter(parameterName: string, value: number): void {}\n getDoubleParameter(parameterName: string): number {\n return 0;\n }\n getColorParameter(parameterName: string): number {\n return 0;\n }\n }\n }\n}\n"],
|
|
5
|
-
"mappings": "AAAA,GAAU,MAAV,UAAU,EAAV,CACE,KAAM,GAAS,GAAI,GAAK,OAAO,WAExB,GAAU,GAAV,UAAU,EAAV,CACE,AAAM,aAAa,SAAU,EAAO,EAAK,EAAK,CACnD,MAAO,MAAK,IAAI,EAAK,KAAK,IAAI,EAAK,KAGxB,kBAAkB,SAAU,EAAO,EAAK,EAAK,CACxD,KAAM,GAAM,KAAK,MAAO,GAAM,GAAO,EAAI,GACnC,EAAM,GAAI,OAAM,GACtB,OAAS,GAAI,EAAG,EAAI,EAAK,IACvB,EAAI,GAAK,EAAM,EAAI,EAErB,MAAO,GAAI,QAAQ,KAAW,GAAK,EAAQ,GAG7C,KAAM,GAEF,GAOG,AAAM,mBAAmB,SAC9B,EACsB,CACtB,MAAI,GAAgB,eAAe,GAC1B,EAAgB,GAElB,MAQI,wBAAwB,SACnC,EACA,EACA,CACA,AAAI,EAAgB,eAAe,IACjC,EAAO,KACL,WACE,EACA,qFAGN,EAAgB,GAAc,GAOnB,sBAAsB,SAAU,EAAuB,CAClE,KAAM,GAAa,EAAM,MAAM,KAC/B,MAAI,GAAW,SAAW,EACjB,EAAK,eACV,SAAS,EAAW,GAAI,IACxB,SAAS,EAAW,GAAI,IACxB,SAAS,EAAW,GAAI,KAGrB,SAAS,EAAM,QAAQ,IAAK,MAAO,
|
|
4
|
+
"sourcesContent": ["namespace gdjs {\n const logger = new gdjs.Logger('Filters');\n\n export namespace PixiFiltersTools {\n export const clampValue = function (value, min, max) {\n return Math.max(min, Math.min(max, value));\n };\n\n export const clampKernelSize = function (value, min, max) {\n const len = Math.round((max - min) / 2 + 1);\n const arr = new Array(len);\n for (let i = 0; i < len; i++) {\n arr[i] = min + 2 * i;\n }\n return arr.indexOf(value) !== -1 ? value : min;\n };\n\n const _filterCreators: {\n [filterName: string]: FilterCreator;\n } = {};\n\n /**\n * Return the creator for the filter with the given name, if any.\n * @param filterName The name of the filter to get\n * @return The filter creator, if any (null otherwise).\n */\n export const getFilterCreator = function (\n filterName: string\n ): FilterCreator | null {\n if (_filterCreators.hasOwnProperty(filterName)) {\n return _filterCreators[filterName];\n }\n return null;\n };\n\n /**\n * Register a new PIXI filter creator, to be used by GDJS.\n * @param filterName The name of the filter to get\n * @param filterCreator The object used to create the filter.\n */\n export const registerFilterCreator = function (\n filterName: string,\n filterCreator: FilterCreator\n ) {\n if (_filterCreators.hasOwnProperty(filterName)) {\n logger.warn(\n 'Filter \"' +\n filterName +\n '\" was already registered in gdjs.PixiFiltersTools. Replacing it with the new one.'\n );\n }\n _filterCreators[filterName] = filterCreator;\n };\n\n /**\n * Convert a string RGB color (\"rrr;ggg;bbb\") or a hex string (#rrggbb) to a hex number.\n * @param value The color as a RGB string or hex string\n */\n export const rgbOrHexToHexNumber = function (value: string): number {\n const splitValue = value.split(';');\n if (splitValue.length === 3) {\n return gdjs.rgbToHexNumber(\n parseInt(splitValue[0], 10),\n parseInt(splitValue[1], 10),\n parseInt(splitValue[2], 10)\n );\n }\n return parseInt(value.replace('#', '0x'), 16);\n };\n\n /** A wrapper allowing to create an effect. */\n export interface FilterCreator {\n /** Function to call to create the filter */\n makeFilter(target: EffectsTarget, effectData: EffectData): Filter;\n }\n\n /** An effect. */\n export interface Filter {\n /**\n * Check if an effect is enabled.\n * @return true if the filter is enabled\n */\n isEnabled(target: EffectsTarget): boolean;\n /**\n * Enable an effect.\n * @param enabled Set to true to enable, false to disable\n */\n setEnabled(target: EffectsTarget, enabled: boolean): boolean;\n /**\n * Apply the effect on the PixiJS DisplayObject.\n * Called after the effect is initialized.\n * @param rendererObject The renderer object\n * @param effect The effect to be applied.\n */\n applyEffect(target: EffectsTarget): boolean;\n removeEffect(target: EffectsTarget): boolean;\n /** The function to be called to update the filter at every frame before the rendering. */\n updatePreRender(target: gdjs.EffectsTarget): any;\n /** The function to be called to update a parameter (with a number) */\n updateDoubleParameter(\n //filter: PIXI.Filter,\n parameterName: string,\n value: number\n ): void;\n /** The function to be called to update a parameter (with a string) */\n updateStringParameter(parameterName: string, value: string): void;\n /** The function to be called to update a parameter (with a boolean) */\n updateBooleanParameter(parameterName: string, value: boolean): void;\n updateColorParameter(parameterName: string, value: number): void;\n getDoubleParameter(parameterName: string): number;\n getColorParameter(parameterName: string): number;\n getNetworkSyncData(): any;\n updateFromNetworkSyncData(syncData: any): void;\n }\n\n /** A wrapper allowing to create a PIXI filter and update it using a common interface */\n export abstract class PixiFilterCreator implements FilterCreator {\n /** Function to call to create the filter */\n makeFilter(target: EffectsTarget, effectData: EffectData): Filter {\n const pixiFilter = this.makePIXIFilter(target, effectData);\n if (target.isLightingLayer && target.isLightingLayer()) {\n pixiFilter.blendMode = PIXI.BLEND_MODES.ADD;\n }\n return new PixiFilter(pixiFilter, this);\n }\n /** Function to call to create the filter */\n abstract makePIXIFilter(\n target: EffectsTarget,\n effectData: EffectData\n ): any;\n /** The function to be called to update the filter at every frame before the rendering. */\n abstract updatePreRender(\n filter: PIXI.Filter,\n target: gdjs.EffectsTarget\n ): any;\n /** The function to be called to update a parameter (with a number) */\n abstract updateDoubleParameter(\n filter: PIXI.Filter,\n parameterName: string,\n value: number\n ): void;\n /** The function to be called to update a parameter (with a string) */\n abstract updateStringParameter(\n filter: PIXI.Filter,\n parameterName: string,\n value: string\n ): void;\n /** The function to be called to update a parameter (with a boolean) */\n abstract updateBooleanParameter(\n filter: PIXI.Filter,\n parameterName: string,\n value: boolean\n ): void;\n abstract updateColorParameter(\n filter: PIXI.Filter,\n parameterName: string,\n value: number\n ): void;\n abstract getDoubleParameter(\n filter: PIXI.Filter,\n parameterName: string\n ): number;\n abstract getColorParameter(\n filter: PIXI.Filter,\n parameterName: string\n ): number;\n abstract getNetworkSyncData(filter: PIXI.Filter): any;\n abstract updateFromNetworkSyncData(\n filter: PIXI.Filter,\n syncData: any\n ): void;\n }\n\n /**An effect used to manipulate a Pixi filter. */\n export class PixiFilter implements Filter {\n /** The PIXI filter */\n pixiFilter: PIXI.Filter;\n filterCreator: gdjs.PixiFiltersTools.PixiFilterCreator;\n\n constructor(\n pixiFilter: PIXI.Filter,\n filterCreator: gdjs.PixiFiltersTools.PixiFilterCreator\n ) {\n this.pixiFilter = pixiFilter;\n this.filterCreator = filterCreator;\n }\n\n isEnabled(target: EffectsTarget): boolean {\n return this.pixiFilter.enabled;\n }\n\n setEnabled(target: EffectsTarget, enabled: boolean): boolean {\n return (this.pixiFilter.enabled = enabled);\n }\n\n applyEffect(target: EffectsTarget): boolean {\n const rendererObject = target.getRendererObject() as\n | PIXI.DisplayObject\n | null\n | undefined;\n if (!rendererObject) {\n return false;\n }\n rendererObject.filters = (rendererObject.filters || []).concat(\n this.pixiFilter\n );\n return true;\n }\n\n removeEffect(target: EffectsTarget): boolean {\n const rendererObject = target.getRendererObject() as\n | PIXI.DisplayObject\n | null\n | undefined;\n if (!rendererObject) {\n return false;\n }\n rendererObject.filters = (rendererObject.filters || []).filter(\n (pixiFilter) => pixiFilter !== this.pixiFilter\n );\n return true;\n }\n\n updatePreRender(target: gdjs.EffectsTarget): any {\n this.filterCreator.updatePreRender(this.pixiFilter, target);\n }\n\n updateDoubleParameter(parameterName: string, value: number): void {\n this.filterCreator.updateDoubleParameter(\n this.pixiFilter,\n parameterName,\n value\n );\n }\n\n updateStringParameter(parameterName: string, value: string): void {\n this.filterCreator.updateStringParameter(\n this.pixiFilter,\n parameterName,\n value\n );\n }\n\n updateBooleanParameter(parameterName: string, value: boolean): void {\n this.filterCreator.updateBooleanParameter(\n this.pixiFilter,\n parameterName,\n value\n );\n }\n\n updateColorParameter(parameterName: string, value: number): void {\n this.filterCreator.updateColorParameter(\n this.pixiFilter,\n parameterName,\n value\n );\n }\n\n getDoubleParameter(parameterName: string): number {\n return this.filterCreator.getDoubleParameter(\n this.pixiFilter,\n parameterName\n );\n }\n\n getColorParameter(parameterName: string): number {\n return this.filterCreator.getColorParameter(\n this.pixiFilter,\n parameterName\n );\n }\n\n getNetworkSyncData(): any {\n return {\n ena: this.pixiFilter.enabled,\n fc: this.filterCreator.getNetworkSyncData(this.pixiFilter),\n };\n }\n\n updateFromNetworkSyncData(syncData: any): void {\n this.pixiFilter.enabled = syncData.ena;\n this.filterCreator.updateFromNetworkSyncData(\n this.pixiFilter,\n syncData.fc\n );\n }\n }\n\n export class EmptyFilter implements Filter {\n isEnabled(target: EffectsTarget): boolean {\n return false;\n }\n setEnabled(target: EffectsTarget, enabled: boolean): boolean {\n return false;\n }\n applyEffect(target: EffectsTarget): boolean {\n return false;\n }\n removeEffect(target: EffectsTarget): boolean {\n return false;\n }\n updatePreRender(target: gdjs.EffectsTarget): any {}\n updateDoubleParameter(parameterName: string, value: number): void {}\n updateStringParameter(parameterName: string, value: string): void {}\n updateBooleanParameter(parameterName: string, value: boolean): void {}\n updateColorParameter(parameterName: string, value: number): void {}\n getDoubleParameter(parameterName: string): number {\n return 0;\n }\n getColorParameter(parameterName: string): number {\n return 0;\n }\n getNetworkSyncData(): any {\n return {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E,mBAAmB,EAA+B,CAChD,MAAO,GAET,kBAAkB,EAA+B,CAC/C,MAAO,GAET,oBAA0B,CACxB,MAAO,GAET,0BAA0B,EAAqB,GA3B1C,EAAM,gBA9RE,iDAHT",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -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 ) {\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 //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,KAyNtB,uBAAoB,AAAC,GAA8C,CACzE,KAAM,GAAW,KAAK,gBAAgB,YAAY,GAClD,MAAO,IAAY,KAAK,mBAAmB,SAAS,EAAS,MACzD,EACA,MApNJ,KAAK,gBAAkB,EACvB,KAAK,gBAAkB,KAAK,QAAQ,KAClC,k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C,EAAa,UAAY,MAAM,aAC/B,EAAa,UAAY,MAAM,aAC/B,EAAa,MAAQ,MAAM,eAC3B,EAAa,MAAQ,MAAM,eAC3B,EAAa,WAAa,MAAM,eAChC,EAAa,YAAc,GAE3B,KAAM,GAAW,KAAK,kBAAkB,GAExC,SAA0B,EAAc,GACxC,KAAK,qBAAqB,IAAI,EAAc,GAErC,EAST,iBACE,EACA,CACE,wBACA,
|
|
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 //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,KAyNtB,uBAAoB,AAAC,GAA8C,CACzE,KAAM,GAAW,KAAK,gBAAgB,YAAY,GAClD,MAAO,IAAY,KAAK,mBAAmB,SAAS,EAAS,MACzD,EACA,MApNJ,KAAK,gBAAkB,EACvB,KAAK,gBAAkB,KAAK,QAAQ,KAClC,kIAEF,KAAK,qBAAuB,GAAI,WAChC,KAA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AEnC,MAAO,GAST,yBACE,EACA,EACA,EACA,EACc,CACd,KAAM,GAAM,GAAG,KAAqB,KAAS,IAC7C,GAAI,GAAkB,KAAK,gBAAgB,IAAI,GAC/C,GAAI,CAAC,EAAiB,CACpB,KAAM,GAAW,GAAI,MAAK,SACpB,EAAS,GAAI,MAAK,OAAO,KAAK,eAAe,IACnD,EAAO,MAAQ,EACf,EAAO,OAAS,EAChB,EAAS,SAAS,GAClB,EAAkB,EAAa,gBAAgB,GAC/C,EAAS,UAET,KAAK,gBAAgB,IAAI,EAAK,GAEhC,MAAO,IAtaJ,EAAM,mBA2aA,eAAe,EAAK,mBA/czB",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var gdjs;(function(l){const d=new l.Logger("PIXI game renderer"),m=[37,38,39,40];class R{constructor(n,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.getElectronRemote=()=>{if(typeof require=="function"){const n=this._game.getAdditionalOptions(),e=n&&n.electronRemoteRequirePath?n.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=n,this._forceFullscreen=e,this._marginLeft=this._marginTop=this._marginRight=this._marginBottom=0,this._setupOrientation()}createStandardCanvas(n){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())}),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,n.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",n.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 n=this._game.getGameData().properties.orientation;try{if(n==="default"){const e=window.screen.orientation.unlock();e&&e.catch(()=>{})}else window.screen.orientation.lock(n).catch(()=>{})}catch(e){d.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 n=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),n&&!this._keepRatio)e=s,i=r;else if(n&&this._keepRatio||e>s||i>r){let u=s/e;i*u>r&&(u=r/i),e*=u,i*=u}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(n){this._keepRatio!==n&&(this._keepRatio=n,this._resizeCanvas())}setMargins(n,e,i,s){this._marginTop===n&&this._marginRight===e&&this._marginBottom===i&&this._marginLeft===s||(this._marginTop=n,this._marginRight=e,this._marginBottom=i,this._marginLeft=s,this._resizeCanvas())}setWindowSize(n,e){const i=this.getElectronRemote();if(i){const s=i.getCurrentWindow();s&&s.setContentSize(n,e)}else d.warn("Window size can't be changed on this platform.")}centerWindow(){const n=this.getElectronRemote();if(n){const e=n.getCurrentWindow();e&&e.center()}}setFullScreen(n){if(!this._forceFullscreen&&this._isFullscreen!==n){this._isFullscreen=!!n;const e=this.getElectronRemote();if(e){const i=e.getCurrentWindow();i&&i.setFullScreen(this._isFullscreen)}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 n=this.getElectronRemote();return n?n.getCurrentWindow().isFullScreen():this._isFullscreen||window.screen.height===window.innerHeight}convertCanvasToDomElementContainerCoords(n,e){const i=e||[0,0];return i[0]=n[0]*this._canvasWidth/this._game.getGameResolutionWidth(),i[1]=n[1]*this._canvasHeight/this._game.getGameResolutionHeight(),i}getCanvasToDomElementContainerHeightScale(){return(this._canvasHeight||1)/this._game.getGameResolutionHeight()}bindStandardEvents(n,e,i){const s=this._gameCanvas;if(!s)return;const r=t=>{const o=[t.pageX-s.offsetLeft,t.pageY-s.offsetTop];return o[0]*=this._game.getGameResolutionWidth()/(this._canvasWidth||1),o[1]*=this._game.getGameResolutionHeight()/(this._canvasHeight||1),o},u=t=>{const o=t.pageX-s.offsetLeft,a=t.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 f=()=>!(i.activeElement===s||i.activeElement===i.body||i.activeElement===null),c=t=>!(t.target===s||t.target===i.body);i.onkeydown=function(t){f()||(m.includes(t.keyCode)&&t.preventDefault(),n.onKeyPressed(t.keyCode,t.location))},i.onkeyup=function(t){f()||(m.includes(t.keyCode)&&t.preventDefault(),n.onKeyReleased(t.keyCode,t.location))};function g(t){switch(t){case 1:return l.InputManager.MOUSE_MIDDLE_BUTTON;case 2:return l.InputManager.MOUSE_RIGHT_BUTTON}return t}s.onmousemove=function(t){const o=r(t);n.onMouseMove(o[0],o[1])},s.onmousedown=function(t){return n.onMouseButtonPressed(g(t.button)),e.focus!==void 0&&e.focus(),!1},s.onmouseup=function(t){return n.onMouseButtonReleased(g(t.button)),!1},s.onmouseleave=function(t){n.onMouseLeave()},s.onmouseenter=function(t){n.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 h=o[a],_=(t.buttons&1<<a)!=0,p=n.isMouseButtonPressed(h);_&&!p?n.onMouseButtonPressed(h):!_&&p&&n.onMouseButtonReleased(h)}},e.addEventListener("click",function(t){return e.focus!==void 0&&e.focus(),!1},!1),s.oncontextmenu=function(t){return t.preventDefault(),t.stopPropagation(),!1},s.onwheel=function(t){n.onMouseWheel(-t.deltaY)},e.addEventListener("touchmove",function(t){if(!c(t)&&(t.preventDefault(),t.changedTouches))for(let o=0;o<t.changedTouches.length;++o){const a=r(t.changedTouches[o]);n.onTouchMove(t.changedTouches[o].identifier,a[0],a[1]),n.isSimulatingMouseWithTouch()&&(u(t.changedTouches[o])?n.onMouseEnter():n.onMouseLeave())}},{passive:!1}),e.addEventListener("touchstart",function(t){if(!c(t)){if(t.preventDefault(),t.changedTouches)for(let o=0;o<t.changedTouches.length;++o){const a=r(t.changedTouches[o]);n.onTouchStart(t.changedTouches[o].identifier,a[0],a[1])}return!1}},{passive:!1}),e.addEventListener("touchend",function(t){if(!c(t)){if(t.preventDefault(),t.changedTouches)for(let o=0;o<t.changedTouches.length;++o)n.onTouchEnd(t.changedTouches[o].identifier);return!1}},{passive:!1}),e.addEventListener("touchcancel",function(t){if(!c(t)){if(t.preventDefault(),t.changedTouches)for(let o=0;o<t.changedTouches.length;++o)n.onTouchCancel(t.changedTouches[o].identifier);return!1}},{passive:!1})}setWindowTitle(n){typeof document!="undefined"&&(document.title=n)}getWindowTitle(){return typeof document!="undefined"?document.title:""}startGameLoop(n){let e=0;const i=s=>{this._nextFrameId=requestAnimationFrame(i);const r=e?s-e:0;e=s,n(r)||cancelAnimationFrame(this._nextFrameId)};requestAnimationFrame(i)}getPIXIRenderer(){return this._pixiRenderer}getThreeRenderer(){return this._threeRenderer}getDomElementContainer(){return this._domElementsContainer}openURL(n){if(typeof window!="undefined"){const e=this.getElectron();if(e)e.shell.openExternal(n);else{const i=window.cordova?"_system":"_blank";window.open(n,i)}}}stopGame(){const n=this.getElectronRemote();if(n){const e=n.getCurrentWindow();e&&e.close()}else typeof navigator!="undefined"&&navigator.app&&navigator.app.exitApp&&navigator.app.exitApp()}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}}l.RuntimeGamePixiRenderer=R,l.RuntimeGameRenderer=R})(gdjs||(gdjs={}));
|
|
1
|
+
var gdjs;(function(l){const d=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.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){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())}),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",o=>{i.scrollLeft=0,i.scrollTop=0,o.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){d.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(),o=window.innerWidth-this._marginLeft-this._marginRight,r=window.innerHeight-this._marginTop-this._marginBottom;if(o<0&&(o=0),r<0&&(r=0),t&&!this._keepRatio)e=o,i=r;else if(t&&this._keepRatio||e>o||i>r){let u=o/e;i*u>r&&(u=r/i),e*=u,i*=u}this._gameCanvas&&(this._gameCanvas.style.top=this._marginTop+(r-i)/2+"px",this._gameCanvas.style.left=this._marginLeft+(o-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+(o-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,o){this._marginTop===t&&this._marginRight===e&&this._marginBottom===i&&this._marginLeft===o||(this._marginTop=t,this._marginRight=e,this._marginBottom=i,this._marginLeft=o,this._resizeCanvas())}setWindowSize(t,e){const i=this.getElectronRemote();if(i){const o=i.getCurrentWindow();o&&o.setContentSize(t,e)}else d.warn("Window size can't be changed on this platform.")}centerWindow(){const t=this.getElectronRemote();if(t){const e=t.getCurrentWindow();e&&e.center()}}setFullScreen(t){if(!this._forceFullscreen&&this._isFullscreen!==t){this._isFullscreen=!!t;const e=this.getElectronRemote();if(e){const i=e.getCurrentWindow();i&&i.setFullScreen(this._isFullscreen)}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();return t?t.getCurrentWindow().isFullScreen():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){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},u=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),c=n=>!(n.target===o||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}o.onmousemove=function(n){const s=r(n);t.onMouseMove(s[0],s[1])},o.onmousedown=function(n){return t.onMouseButtonPressed(g(n.button)),e.focus!==void 0&&e.focus(),!1},o.onmouseup=function(n){return t.onMouseButtonReleased(g(n.button)),!1},o.onmouseleave=function(n){t.onMouseLeave()},o.onmouseenter=function(n){t.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 h=s[a],_=(n.buttons&1<<a)!=0,p=t.isMouseButtonPressed(h);_&&!p?t.onMouseButtonPressed(h):!_&&p&&t.onMouseButtonReleased(h)}},e.addEventListener("click",function(n){return e.focus!==void 0&&e.focus(),!1},!1),o.oncontextmenu=function(n){return n.preventDefault(),n.stopPropagation(),!1},o.onwheel=function(n){t.onMouseWheel(-n.deltaY)},e.addEventListener("touchmove",function(n){if(!c(n)&&(n.preventDefault(),n.changedTouches))for(let s=0;s<n.changedTouches.length;++s){const a=r(n.changedTouches[s]);t.onTouchMove(n.changedTouches[s].identifier,a[0],a[1]),t.isSimulatingMouseWithTouch()&&(u(n.changedTouches[s])?t.onMouseEnter():t.onMouseLeave())}},{passive:!1}),e.addEventListener("touchstart",function(n){if(!c(n)){if(n.preventDefault(),n.changedTouches)for(let s=0;s<n.changedTouches.length;++s){const a=r(n.changedTouches[s]);t.onTouchStart(n.changedTouches[s].identifier,a[0],a[1])}return!1}},{passive:!1}),e.addEventListener("touchend",function(n){if(!c(n)){if(n.preventDefault(),n.changedTouches)for(let s=0;s<n.changedTouches.length;++s)t.onTouchEnd(n.changedTouches[s].identifier);return!1}},{passive:!1}),e.addEventListener("touchcancel",function(n){if(!c(n)){if(n.preventDefault(),n.changedTouches)for(let s=0;s<n.changedTouches.length;++s)t.onTouchCancel(n.changedTouches[s].identifier);return!1}},{passive:!1})}setWindowTitle(t){typeof document!="undefined"&&(document.title=t)}getWindowTitle(){return typeof document!="undefined"?document.title:""}startGameLoop(t){let e=0;const i=o=>{this._nextFrameId=requestAnimationFrame(i);const r=e?o-e:0;e=o,t(r)||cancelAnimationFrame(this._nextFrameId)};requestAnimationFrame(i)}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();e&&e.close()}else typeof navigator!="undefined"&&navigator.app&&navigator.app.exitApp&&navigator.app.exitApp()}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}}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 /**\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 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 });\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,\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 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 const remote = this.getElectronRemote();\n if (remote) {\n // Use Electron BrowserWindow API\n const browserWindow = remote.getCurrentWindow();\n if (browserWindow) {\n browserWindow.setContentSize(width, height);\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 const remote = this.getElectronRemote();\n if (remote) {\n // Use Electron BrowserWindow API\n const browserWindow = remote.getCurrentWindow();\n if (browserWindow) {\n browserWindow.center();\n }\n } else {\n }\n }\n\n // Not supported\n /**\n * De/activate fullscreen for the game.\n */\n setFullScreen(enable): void {\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 // Use Electron BrowserWindow API\n const browserWindow = remote.getCurrentWindow();\n if (browserWindow) {\n browserWindow.setFullScreen(this._isFullscreen);\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 return remote.getCurrentWindow().isFullScreen();\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 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 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 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 {\n // @ts-ignore\n const target = window.cordova ? '_system' : '_blank';\n window.open(url, target);\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 browserWindow.close();\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 * 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\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,CAgCnC,YAAY,EAAwB,EAA0B,CA9B9D,iBAAuB,GAGvB,mBAAyB,GAKzB,mBAAsC,KAC9B,oBAA6C,KAC7C,iBAAwC,KACxC,2BAA+C,KAGvD,kBAAsB,EAEtB,mBAAuB,EAEvB,gBAAsB,GAMtB,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 /**\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 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 });\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,\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 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 const remote = this.getElectronRemote();\n if (remote) {\n // Use Electron BrowserWindow API\n const browserWindow = remote.getCurrentWindow();\n if (browserWindow) {\n browserWindow.setContentSize(width, height);\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 const remote = this.getElectronRemote();\n if (remote) {\n // Use Electron BrowserWindow API\n const browserWindow = remote.getCurrentWindow();\n if (browserWindow) {\n browserWindow.center();\n }\n } else {\n }\n }\n\n // Not supported\n /**\n * De/activate fullscreen for the game.\n */\n setFullScreen(enable): void {\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 // Use Electron BrowserWindow API\n const browserWindow = remote.getCurrentWindow();\n if (browserWindow) {\n browserWindow.setFullScreen(this._isFullscreen);\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 return remote.getCurrentWindow().isFullScreen();\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 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 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 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 browserWindow.close();\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 * 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\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,CAgCnC,YAAY,EAAwB,EAA0B,CA9B9D,iBAAuB,GAGvB,mBAAyB,GAKzB,mBAAsC,KAC9B,oBAA6C,KAC7C,iBAAwC,KACxC,2BAA+C,KAGvD,kBAAsB,EAEtB,mBAAuB,EAEvB,gBAAsB,GAMtB,kBAAwB,EA03BxB,uBAAoB,IAAM,CACxB,GAAI,MAAO,UAAY,WAAY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AAQ,aAAa,KAAK,EAAK,UAAW,gBAEjD,OAAO,KAAK,EAAK,WAQvB,UAAW,CAGT,KAAM,GAAS,KAAK,oBACpB,GAAI,EAAQ,CACV,KAAM,GAAgB,EAAO,mBAC7B,AAAI,GACF,EAAc,YAGhB,AACE,OAAO,YAAc,aAErB,UAAU,KAEV,UAAU,IAAI,SAGd,UAAU,IAAI,UASpB,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,OA16BT,EAAM,0BAg7BA,sBAAsB,IAl8B3B",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var gdjs;(function(
|
|
1
|
+
var gdjs;(function(i){class s{constructor(t,e){this._spriteDirty=!0;this._textureDirty=!0;this._cachedWidth=0;this._cachedHeight=0;this._object=t;const r=e.getGame().getImageManager();this._sprite=new PIXI.Sprite(r.getInvalidPIXITexture());const a=e.getLayer("");a&&a.getRenderer().addRendererObject(this._sprite,t.getZOrder())}reinitialize(t,e){this._object=t,this._spriteDirty=!0,this._textureDirty=!0,this._sprite.tint=16777215;const r=e.getLayer("");r&&r.getRenderer().addRendererObject(this._sprite,t.getZOrder())}getRendererObject(){return this._sprite}_updatePIXISprite(){const t=this._object._animator.getCurrentFrame();t!==null?(this._sprite.anchor.x=t.center.x/this._sprite.texture.frame.width,this._sprite.anchor.y=t.center.y/this._sprite.texture.frame.height,this._sprite.position.x=this._object.x+(t.center.x-t.origin.x)*Math.abs(this._object._scaleX),this._sprite.position.y=this._object.y+(t.center.y-t.origin.y)*Math.abs(this._object._scaleY),this._sprite.rotation=i.toRad(this._object.angle),this._sprite.visible=!this._object.hidden,this._sprite.blendMode=this._object._blendMode,this._sprite.alpha=this._object.opacity/255,this._sprite.scale.x=this._object._scaleX,this._sprite.scale.y=this._object._scaleY,this._cachedWidth=Math.abs(this._sprite.width),this._cachedHeight=Math.abs(this._sprite.height)):(this._sprite.visible=!1,this._sprite.alpha=0,this._cachedWidth=0,this._cachedHeight=0),this._spriteDirty=!1}ensureUpToDate(){this._spriteDirty&&this._updatePIXISprite()}updateFrame(t){this._spriteDirty=!0,this._sprite.texture=t.texture}update(){this._spriteDirty=!0}updateX(){const t=this._object._animator.getCurrentFrame();this._sprite.position.x=this._object.x+(t.center.x-t.origin.x)*Math.abs(this._object._scaleX)}updateY(){const t=this._object._animator.getCurrentFrame();this._sprite.position.y=this._object.y+(t.center.y-t.origin.y)*Math.abs(this._object._scaleY)}updateAngle(){this._sprite.rotation=i.toRad(this._object.angle)}updateOpacity(){this._sprite.alpha=this._object.opacity/255}updateVisibility(){this._sprite.visible=!this._object.hidden}setColor(t){const e=t.split(";");e.length<3||(this._sprite.tint=i.rgbToHexNumber(parseInt(e[0],10),parseInt(e[1],10),parseInt(e[2],10)))}getColor(){const t=new PIXI.Color(this._sprite.tint).toRgbArray();return Math.floor(t[0]*255)+";"+Math.floor(t[1]*255)+";"+Math.floor(t[2]*255)}getWidth(){return this._spriteDirty&&this._updatePIXISprite(),this._cachedWidth}getHeight(){return this._spriteDirty&&this._updatePIXISprite(),this._cachedHeight}getUnscaledWidth(){return this._sprite.texture.frame.width}getUnscaledHeight(){return this._sprite.texture.frame.height}static getAnimationFrameTextureManager(t){return t._pixiAnimationFrameTextureManager||(t._pixiAnimationFrameTextureManager=new n(t)),t._pixiAnimationFrameTextureManager}}i.SpriteRuntimeObjectPixiRenderer=s;class n{constructor(t){this._imageManager=t}getAnimationFrameTexture(t){return this._imageManager.getPIXITexture(t)}getAnimationFrameWidth(t){return t.width}getAnimationFrameHeight(t){return t.height}}i.SpriteRuntimeObjectRenderer=s})(gdjs||(gdjs={}));
|
|
2
2
|
//# sourceMappingURL=spriteruntimeobject-pixi-renderer.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../GDevelop/GDJS/Runtime/pixi-renderers/spriteruntimeobject-pixi-renderer.ts"],
|
|
4
|
-
"sourcesContent": ["namespace gdjs {\n /**\n * The renderer for a gdjs.SpriteRuntimeObject using Pixi.js.\n */\n export class SpriteRuntimeObjectPixiRenderer {\n _object: gdjs.SpriteRuntimeObject;\n _spriteDirty: boolean = true;\n _textureDirty: boolean = true;\n _sprite: PIXI.Sprite;\n _cachedWidth: float = 0;\n _cachedHeight: float = 0;\n\n /**\n * @param runtimeObject The object\n * @param instanceContainer The scene\n */\n constructor(\n runtimeObject: gdjs.SpriteRuntimeObject,\n instanceContainer: gdjs.RuntimeInstanceContainer\n ) {\n this._object = runtimeObject;\n this._sprite = new PIXI.Sprite(
|
|
5
|
-
"mappings": "AAAA,GAAU,MAAV,UAAU,EAAV,
|
|
4
|
+
"sourcesContent": ["namespace gdjs {\n export interface PixiImageManager {\n _pixiAnimationFrameTextureManager: PixiAnimationFrameTextureManager;\n }\n /**\n * The renderer for a gdjs.SpriteRuntimeObject using Pixi.js.\n */\n export class SpriteRuntimeObjectPixiRenderer {\n _object: gdjs.SpriteRuntimeObject;\n _spriteDirty: boolean = true;\n _textureDirty: boolean = true;\n _sprite: PIXI.Sprite;\n _cachedWidth: float = 0;\n _cachedHeight: float = 0;\n\n /**\n * @param runtimeObject The object\n * @param instanceContainer The scene\n */\n constructor(\n runtimeObject: gdjs.SpriteRuntimeObject,\n instanceContainer: gdjs.RuntimeInstanceContainer\n ) {\n this._object = runtimeObject;\n const imageManager = instanceContainer.getGame().getImageManager();\n this._sprite = new PIXI.Sprite(imageManager.getInvalidPIXITexture());\n const layer = instanceContainer.getLayer('');\n if (layer) {\n layer\n .getRenderer()\n .addRendererObject(this._sprite, runtimeObject.getZOrder());\n }\n }\n\n reinitialize(\n runtimeObject: gdjs.SpriteRuntimeObject,\n instanceContainer: gdjs.RuntimeInstanceContainer\n ) {\n this._object = runtimeObject;\n this._spriteDirty = true;\n this._textureDirty = true;\n this._sprite.tint = 0xffffff;\n const layer = instanceContainer.getLayer('');\n if (layer) {\n layer\n .getRenderer()\n .addRendererObject(this._sprite, runtimeObject.getZOrder());\n }\n }\n\n getRendererObject() {\n return this._sprite;\n }\n\n /**\n * Update the internal PIXI.Sprite position, angle...\n */\n _updatePIXISprite() {\n const animationFrame = this._object._animator.getCurrentFrame();\n if (animationFrame !== null) {\n this._sprite.anchor.x =\n animationFrame.center.x / this._sprite.texture.frame.width;\n this._sprite.anchor.y =\n animationFrame.center.y / this._sprite.texture.frame.height;\n this._sprite.position.x =\n this._object.x +\n (animationFrame.center.x - animationFrame.origin.x) *\n Math.abs(this._object._scaleX);\n this._sprite.position.y =\n this._object.y +\n (animationFrame.center.y - animationFrame.origin.y) *\n Math.abs(this._object._scaleY);\n this._sprite.rotation = gdjs.toRad(this._object.angle);\n this._sprite.visible = !this._object.hidden;\n this._sprite.blendMode = this._object._blendMode;\n this._sprite.alpha = this._object.opacity / 255;\n this._sprite.scale.x = this._object._scaleX;\n this._sprite.scale.y = this._object._scaleY;\n this._cachedWidth = Math.abs(this._sprite.width);\n this._cachedHeight = Math.abs(this._sprite.height);\n } else {\n this._sprite.visible = false;\n this._sprite.alpha = 0;\n this._cachedWidth = 0;\n this._cachedHeight = 0;\n }\n this._spriteDirty = false;\n }\n\n /**\n * Call this to make sure the sprite is ready to be rendered.\n */\n ensureUpToDate() {\n if (this._spriteDirty) {\n this._updatePIXISprite();\n }\n }\n\n /**\n * Update the internal texture of the PIXI sprite.\n */\n updateFrame(animationFrame: gdjs.SpriteAnimationFrame<PIXI.Texture>): void {\n this._spriteDirty = true;\n this._sprite.texture = animationFrame.texture;\n }\n\n update(): void {\n this._spriteDirty = true;\n }\n\n updateX(): void {\n const animationFrame = this._object._animator.getCurrentFrame() as SpriteAnimationFrame<\n PIXI.Texture\n >;\n this._sprite.position.x =\n this._object.x +\n (animationFrame.center.x - animationFrame.origin.x) *\n Math.abs(this._object._scaleX);\n }\n\n updateY(): void {\n const animationFrame = this._object._animator.getCurrentFrame() as SpriteAnimationFrame<\n PIXI.Texture\n >;\n this._sprite.position.y =\n this._object.y +\n (animationFrame.center.y - animationFrame.origin.y) *\n Math.abs(this._object._scaleY);\n }\n\n updateAngle(): void {\n this._sprite.rotation = gdjs.toRad(this._object.angle);\n }\n\n updateOpacity(): void {\n this._sprite.alpha = this._object.opacity / 255;\n }\n\n updateVisibility(): void {\n this._sprite.visible = !this._object.hidden;\n }\n\n setColor(rgbColor): void {\n const colors = rgbColor.split(';');\n if (colors.length < 3) {\n return;\n }\n this._sprite.tint = gdjs.rgbToHexNumber(\n parseInt(colors[0], 10),\n parseInt(colors[1], 10),\n parseInt(colors[2], 10)\n );\n }\n\n getColor() {\n const rgb = new PIXI.Color(this._sprite.tint).toRgbArray();\n return (\n Math.floor(rgb[0] * 255) +\n ';' +\n Math.floor(rgb[1] * 255) +\n ';' +\n Math.floor(rgb[2] * 255)\n );\n }\n\n getWidth(): float {\n if (this._spriteDirty) {\n this._updatePIXISprite();\n }\n return this._cachedWidth;\n }\n\n getHeight(): float {\n if (this._spriteDirty) {\n this._updatePIXISprite();\n }\n return this._cachedHeight;\n }\n\n getUnscaledWidth(): float {\n return this._sprite.texture.frame.width;\n }\n\n getUnscaledHeight(): float {\n return this._sprite.texture.frame.height;\n }\n\n static getAnimationFrameTextureManager(\n imageManager: gdjs.PixiImageManager\n ): PixiAnimationFrameTextureManager {\n if (!imageManager._pixiAnimationFrameTextureManager) {\n imageManager._pixiAnimationFrameTextureManager = new PixiAnimationFrameTextureManager(\n imageManager\n );\n }\n return imageManager._pixiAnimationFrameTextureManager;\n }\n }\n\n class PixiAnimationFrameTextureManager\n implements gdjs.AnimationFrameTextureManager<PIXI.Texture> {\n private _imageManager: gdjs.PixiImageManager;\n\n constructor(imageManager: gdjs.PixiImageManager) {\n this._imageManager = imageManager;\n }\n\n getAnimationFrameTexture(imageName: string) {\n return this._imageManager.getPIXITexture(imageName);\n }\n\n getAnimationFrameWidth(pixiTexture: PIXI.Texture) {\n return pixiTexture.width;\n }\n\n getAnimationFrameHeight(pixiTexture: PIXI.Texture) {\n return pixiTexture.height;\n }\n }\n\n // Register the class to let the engine use it.\n export const SpriteRuntimeObjectRenderer = SpriteRuntimeObjectPixiRenderer;\n export type SpriteRuntimeObjectRenderer = SpriteRuntimeObjectPixiRenderer;\n}\n"],
|
|
5
|
+
"mappings": "AAAA,GAAU,MAAV,UAAU,EAAV,CAOS,OAAsC,CAY3C,YACE,EACA,EACA,CAbF,kBAAwB,GACxB,mBAAyB,GAEzB,kBAAsB,EACtB,mBAAuB,EAUrB,KAAK,QAAU,EACf,KAAM,GAAe,EAAkB,UAAU,kBACjD,KAAK,QAAU,GAAI,MAAK,OAAO,EAAa,yBAC5C,KAAM,GAAQ,EAAkB,SAAS,IACzC,AAAI,GACF,EACG,cACA,kBAAkB,KAAK,QAAS,EAAc,aAIrD,aACE,EACA,EACA,CACA,KAAK,QAAU,EACf,KAAK,aAAe,GACpB,KAAK,cAAgB,GACrB,KAAK,QAAQ,KAAO,SACpB,KAAM,GAAQ,EAAkB,SAAS,IACzC,AAAI,GACF,EACG,cACA,kBAAkB,KAAK,QAAS,EAAc,aAIrD,mBAAoB,CAClB,MAAO,MAAK,QAMd,mBAAoB,CAClB,KAAM,GAAiB,KAAK,QAAQ,UAAU,kBAC9C,AAAI,IAAmB,KACrB,MAAK,QAAQ,OAAO,EAClB,EAAe,OAAO,EAAI,KAAK,QAAQ,QAAQ,MAAM,MACvD,KAAK,QAAQ,OAAO,EAClB,EAAe,OAAO,EAAI,KAAK,QAAQ,QAAQ,MAAM,OACvD,KAAK,QAAQ,SAAS,EACpB,KAAK,QAAQ,EACZ,GAAe,OAAO,EAAI,EAAe,OAAO,GAC/C,KAAK,IAAI,KAAK,QAAQ,SAC1B,KAAK,QAAQ,SAAS,EACpB,KAAK,QAAQ,EACZ,GAAe,OAAO,EAAI,EAAe,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I,EAAO,OAAS,GAGpB,MAAK,QAAQ,KAAO,EAAK,eACvB,SAAS,EAAO,GAAI,IACpB,SAAS,EAAO,GAAI,IACpB,SAAS,EAAO,GAAI,MAIxB,UAAW,CACT,KAAM,GAAM,GAAI,MAAK,MAAM,KAAK,QAAQ,MAAM,aAC9C,MACE,MAAK,MAAM,EAAI,GAAK,KACpB,IACA,KAAK,MAAM,EAAI,GAAK,KACpB,IACA,KAAK,MAAM,EAAI,GAAK,KAIxB,UAAkB,CAChB,MAAI,MAAK,cACP,KAAK,oBAEA,KAAK,aAGd,WAAmB,CACjB,MAAI,MAAK,cACP,KAAK,oBAEA,KAAK,cAGd,kBAA0B,CACxB,MAAO,MAAK,QAAQ,QAAQ,MAAM,MAGpC,mBAA2B,CACzB,MAAO,MAAK,QAAQ,QAAQ,MAAM,aAG7B,iCACL,EACkC,CAClC,MAAK,GAAa,mCAChB,GAAa,kCAAoC,GAAI,GACnD,IAGG,EAAa,mCA5LjB,EAAM,kCAgMb,OAC6D,CAG3D,YAAY,EAAqC,CAC/C,KAAK,cAAgB,EAGvB,yBAAyB,EAAmB,CAC1C,MAAO,MAAK,cAAc,eAAe,GAG3C,uBAAuB,EAA2B,CAChD,MAAO,GAAY,MAGrB,wBAAwB,EAA2B,CACjD,MAAO,GAAY,QAKhB,AAAM,8BAA8B,IA7NnC",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/Runtime/polygon.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var gdjs;(function(
|
|
1
|
+
var gdjs;(function(b){const D=()=>({collision:!1,move_axis:[0,0]}),S=()=>({collision:!1,closeX:0,closeY:0,closeSqDist:0,farX:0,farY:0,farSqDist:0,edgeX:0,edgeY:0}),F={minMaxA:[0,0],minMaxB:[0,0],edge:[0,0],axis:[0,0],move_axis:[0,0],result:D()},R={p:[0,0],q:[0,0],r:[0,0],s:[0,0],deltaQP:[0,0],axis:[0,0],result:S()},c=class{constructor(){this.vertices=[];this.edges=[];this.center=[0,0]}move(t,e){for(let o=0,i=this.vertices.length;o<i;++o)this.vertices[o][0]+=t,this.vertices[o][1]+=e}rotate(t){let e=0;const o=Math.cos(-t),i=Math.sin(-t);for(let l=0,s=this.vertices.length;l<s;++l)e=this.vertices[l][0],this.vertices[l][0]=e*o+this.vertices[l][1]*i,this.vertices[l][1]=-e*i+this.vertices[l][1]*o}computeEdges(){for(;this.edges.length<this.vertices.length;)this.edges.push([0,0]);this.edges.length!=this.vertices.length&&(this.edges.length=this.vertices.length);for(let t=0,e=this.vertices.length;t<e;++t){const o=this.vertices[t],i=t+1>=e?this.vertices[0]:this.vertices[t+1];this.edges[t][0]=i[0]-o[0],this.edges[t][1]=i[1]-o[1]}}isConvex(){this.computeEdges();const t=this.edges.length;if(t<3)return!1;const e=this.edges[0][0]*this.edges[0+1][1]-this.edges[0][1]*this.edges[0+1][0]>0;for(let i=1;i<t-1;++i)if(this.edges[i][0]*this.edges[i+1][1]-this.edges[i][1]*this.edges[i+1][0]>0!==e)return!1;return this.edges[t-1][0]*this.edges[0][1]-this.edges[t-1][1]*this.edges[0][0]>0===e}computeCenter(){this.center[0]=0,this.center[1]=0;const t=this.vertices.length;for(let e=0;e<t;++e)this.center[0]+=this.vertices[e][0],this.center[1]+=this.vertices[e][1];return this.center[0]/=t,this.center[1]/=t,this.center}static createRectangle(t,e){const o=new b.Polygon;return o.vertices.push([-t/2,-e/2]),o.vertices.push([+t/2,-e/2]),o.vertices.push([+t/2,+e/2]),o.vertices.push([-t/2,+e/2]),o}static collisionTest(t,e,o){t.computeEdges(),e.computeEdges();let i=F.edge;const l=F.move_axis,s=F.result;let n=Number.MAX_VALUE;i[0]=0,i[1]=0,i[0]=0,i[1]=0,s.collision=!1,s.move_axis[0]=0,s.move_axis[1]=0;for(let m=0,v=t.vertices.length,P=e.vertices.length;m<v+P;m++){m<v?i=t.edges[m]:i=e.edges[m-v];const d=F.axis;d[0]=-i[1],d[1]=i[0],c.normalise(d);const x=F.minMaxA,M=F.minMaxB;c.project(d,t,x),c.project(d,e,M);const r=c.distance(x[0],x[1],M[0],M[1]);if(r>0||r===0&&o)return s.collision=!1,s.move_axis[0]=0,s.move_axis[1]=0,s;const h=Math.abs(r);h<n&&(n=h,l[0]=d[0],l[1]=d[1])}s.collision=!0;const g=t.computeCenter(),a=e.computeCenter(),f=[g[0]-a[0],g[1]-a[1]];return c.dotProduct(f,l)<0&&(l[0]=-l[0],l[1]=-l[1]),s.move_axis[0]=l[0]*n,s.move_axis[1]=l[1]*n,s}static raycastTest(t,e,o,i,l){const s=R.result;if(s.collision=!1,t.vertices.length<2)return s;t.computeEdges();const n=R.p,g=R.q,a=R.r,f=R.s;let m=Number.MAX_VALUE;n[0]=e,n[1]=o,a[0]=i-e,a[1]=l-o;for(let v=0;v<t.edges.length;v++){g[0]=t.vertices[v][0],g[1]=t.vertices[v][1],f[0]=t.edges[v][0],f[1]=t.edges[v][1];const P=R.deltaQP;P[0]=g[0]-n[0],P[1]=g[1]-n[1];const d=c.crossProduct(a,f),x=c.crossProduct(P,f)/d,M=c.crossProduct(P,a)/d;if(Math.abs(d)<=1e-4&&Math.abs(c.crossProduct(P,a))<=1e-4){const r=R.axis;r[0]=a[0],r[1]=a[1],c.normalise(r);const h=0,u=c.dotProduct(r,a),p=c.dotProduct(r,P),X=c.dotProduct(r,[P[0]+f[0],P[1]+f[1]]),Y=Math.max(Math.min(h,u),Math.min(p,X)),y=Math.min(Math.max(h,u),Math.max(p,X));if(Y>y)return s;if(s.collision=!0,u===0)return s.closeX=e,s.closeY=o,s.closeSqDist=0,s.farX=e,s.farY=o,s.farSqDist=0,s.edgeX=f[0],s.edgeY=f[1],s;const q=Y/Math.abs(u),T=y/Math.abs(u);return s.closeX=e+q*a[0],s.closeY=o+q*a[1],s.closeSqDist=q*q*(a[0]*a[0]+a[1]*a[1]),s.farX=e+T*a[0],s.farY=o+T*a[1],s.farSqDist=T*T*(a[0]*a[0]+a[1]*a[1]),s.edgeX=f[0],s.edgeY=f[1],s}else if(d!==0&&0<=x&&x<=1&&0<=M&&M<=1){const r=n[0]+x*a[0],h=n[1]+x*a[1],u=(r-e)*(r-e)+(h-o)*(h-o);u<m?(s.collision||(s.farX=r,s.farY=h,s.farSqDist=u),m=u,s.closeX=r,s.closeY=h,s.closeSqDist=u,s.edgeX=f[0],s.edgeY=f[1],s.collision=!0):(s.farX=r,s.farY=h,s.farSqDist=u)}}return s}static normalise(t){const e=Math.sqrt(t[0]*t[0]+t[1]*t[1]);e!=0&&(t[0]/=e,t[1]/=e)}static dotProduct(t,e){return t[0]*e[0]+t[1]*e[1]}static crossProduct(t,e){return t[0]*e[1]-t[1]*e[0]}static project(t,e,o){let i=c.dotProduct(t,e.vertices[0]);o[0]=i,o[1]=i;for(let l=1,s=e.vertices.length;l<s;++l)i=c.dotProduct(t,e.vertices[l]),i<o[0]?o[0]=i:i>o[1]&&(o[1]=i)}static distance(t,e,o,i){return t<o?o-e:t-i}static isPointInside(t,e,o){let i=!1;for(let l=0,s=t.vertices.length-1;l<t.vertices.length;s=l++){let n=t.vertices[l],g=t.vertices[s];n[1]>o!=g[1]>o&&e<(g[0]-n[0])*(o-n[1])/(g[1]-n[1])+n[0]&&(i=!i)}return i}static copyCollisionTestResult(t,e){e.collision=t.collision,e.move_axis[0]=t.move_axis[0],e.move_axis[1]=t.move_axis[1]}static copyRaycastTestResult(t,e){e.collision=t.collision,e.closeX=t.closeX,e.closeY=t.closeY,e.closeSqDist=t.closeSqDist,e.farX=t.farX,e.farY=t.farY,e.farSqDist=t.farSqDist,e.edgeX=t.edgeX,e.edgeY=t.edgeY}};let C=c;C.makeNewCollisionTestResult=D,C.makeNewRaycastTestResult=S,b.Polygon=C})(gdjs||(gdjs={}));
|
|
2
2
|
//# sourceMappingURL=polygon.js.map
|