gdcore-tools 2.0.0-gd-v5.5.241-autobuild → 2.0.0-gd-v5.5.243-autobuild
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Runtime/AsyncTasksManager.js +2 -2
- package/dist/Runtime/AsyncTasksManager.js.map +2 -2
- package/dist/Runtime/CustomRuntimeObject.js +1 -1
- package/dist/Runtime/CustomRuntimeObject.js.map +2 -2
- 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/Cube3DRuntimeObject.js +1 -1
- package/dist/Runtime/Extensions/3D/Cube3DRuntimeObject.js.map +2 -2
- package/dist/Runtime/Extensions/3D/CustomRuntimeObject3D.js +1 -1
- package/dist/Runtime/Extensions/3D/CustomRuntimeObject3D.js.map +2 -2
- package/dist/Runtime/Extensions/3D/JsExtension.js +47 -0
- 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/3D/Skybox.js +2 -0
- package/dist/Runtime/Extensions/3D/Skybox.js.map +7 -0
- package/dist/Runtime/Extensions/BBText/bbtextruntimeobject.js +1 -1
- package/dist/Runtime/Extensions/BBText/bbtextruntimeobject.js.map +2 -2
- package/dist/Runtime/Extensions/BitmapText/bitmaptextruntimeobject.js +1 -1
- package/dist/Runtime/Extensions/BitmapText/bitmaptextruntimeobject.js.map +2 -2
- package/dist/Runtime/Extensions/DebuggerTools/JsExtension.js +3 -1
- package/dist/Runtime/Extensions/DestroyOutsideBehavior/destroyoutsideruntimebehavior.js +1 -1
- package/dist/Runtime/Extensions/DestroyOutsideBehavior/destroyoutsideruntimebehavior.js.map +2 -2
- package/dist/Runtime/Extensions/Lighting/lightruntimeobject.js +1 -1
- package/dist/Runtime/Extensions/Lighting/lightruntimeobject.js.map +2 -2
- package/dist/Runtime/Extensions/Multiplayer/messageManager.js +1 -1
- package/dist/Runtime/Extensions/Multiplayer/messageManager.js.map +2 -2
- package/dist/Runtime/Extensions/Multiplayer/multiplayerobjectruntimebehavior.js +1 -1
- package/dist/Runtime/Extensions/Multiplayer/multiplayerobjectruntimebehavior.js.map +2 -2
- package/dist/Runtime/Extensions/PanelSpriteObject/panelspriteruntimeobject.js +1 -1
- package/dist/Runtime/Extensions/PanelSpriteObject/panelspriteruntimeobject.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/pathfindingruntimebehavior.js +1 -1
- package/dist/Runtime/Extensions/PathfindingBehavior/pathfindingruntimebehavior.js.map +2 -2
- package/dist/Runtime/Extensions/Physics2Behavior/physics2runtimebehavior.js +1 -1
- package/dist/Runtime/Extensions/Physics2Behavior/physics2runtimebehavior.js.map +2 -2
- package/dist/Runtime/Extensions/Physics3DBehavior/Physics3DRuntimeBehavior.js +1 -1
- package/dist/Runtime/Extensions/Physics3DBehavior/Physics3DRuntimeBehavior.js.map +2 -2
- package/dist/Runtime/Extensions/Physics3DBehavior/PhysicsCar3DRuntimeBehavior.js +1 -1
- package/dist/Runtime/Extensions/Physics3DBehavior/PhysicsCar3DRuntimeBehavior.js.map +2 -2
- package/dist/Runtime/Extensions/Physics3DBehavior/PhysicsCharacter3DRuntimeBehavior.js +1 -1
- package/dist/Runtime/Extensions/Physics3DBehavior/PhysicsCharacter3DRuntimeBehavior.js.map +2 -2
- 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/PrimitiveDrawing/shapepainterruntimeobject.js +1 -1
- package/dist/Runtime/Extensions/PrimitiveDrawing/shapepainterruntimeobject.js.map +2 -2
- package/dist/Runtime/Extensions/SaveState/JsExtension.js +488 -0
- package/dist/Runtime/Extensions/SaveState/SaveConfigurationRuntimeBehavior.js +2 -0
- package/dist/Runtime/Extensions/SaveState/SaveConfigurationRuntimeBehavior.js.map +7 -0
- package/dist/Runtime/Extensions/SaveState/SaveStateTools.js +2 -0
- package/dist/Runtime/Extensions/SaveState/SaveStateTools.js.map +7 -0
- package/dist/Runtime/Extensions/Spine/spineruntimeobject.js +1 -1
- package/dist/Runtime/Extensions/Spine/spineruntimeobject.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/textruntimeobject.js +1 -1
- package/dist/Runtime/Extensions/TextObject/textruntimeobject.js.map +2 -2
- package/dist/Runtime/Extensions/TileMap/helper/dts/model/TileMapModel.d.ts +4 -4
- package/dist/Runtime/Extensions/TileMap/simpletilemapruntimeobject.js +1 -1
- package/dist/Runtime/Extensions/TileMap/simpletilemapruntimeobject.js.map +2 -2
- 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/tiledspriteruntimeobject.js +1 -1
- package/dist/Runtime/Extensions/TiledSpriteObject/tiledspriteruntimeobject.js.map +2 -2
- package/dist/Runtime/Extensions/TopDownMovementBehavior/topdownmovementruntimebehavior.js +1 -1
- package/dist/Runtime/Extensions/TopDownMovementBehavior/topdownmovementruntimebehavior.js.map +2 -2
- package/dist/Runtime/Extensions/TweenBehavior/TweenManager.js +2 -2
- package/dist/Runtime/Extensions/TweenBehavior/TweenManager.js.map +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/TweenBehavior/tweentools.js +1 -1
- package/dist/Runtime/Extensions/TweenBehavior/tweentools.js.map +2 -2
- 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/RuntimeLayer.js +1 -1
- package/dist/Runtime/RuntimeLayer.js.map +2 -2
- 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/gd.js +1 -1
- package/dist/Runtime/gd.js.map +2 -2
- package/dist/Runtime/howler-sound-manager/howler-sound-manager.js +1 -1
- package/dist/Runtime/howler-sound-manager/howler-sound-manager.js.map +2 -2
- package/dist/Runtime/indexeddb.js +2 -0
- package/dist/Runtime/indexeddb.js.map +7 -0
- package/dist/Runtime/oncetriggers.js +1 -1
- package/dist/Runtime/oncetriggers.js.map +2 -2
- package/dist/Runtime/pixi-renderers/pixi-image-manager.js +1 -1
- package/dist/Runtime/pixi-renderers/pixi-image-manager.js.map +2 -2
- package/dist/Runtime/pixi-renderers/runtimescene-pixi-renderer.js +2 -2
- package/dist/Runtime/pixi-renderers/runtimescene-pixi-renderer.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/timemanager.js +1 -1
- package/dist/Runtime/timemanager.js.map +2 -2
- package/dist/Runtime/timer.js +1 -1
- package/dist/Runtime/timer.js.map +2 -2
- package/dist/Runtime/types/global-types.d.ts +29 -0
- package/dist/Runtime/types/project-data.d.ts +144 -3
- package/dist/Runtime/types/save-state.d.ts +9 -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 +1 -1
- package/dist/lib/libGD.wasm +0 -0
- package/dist/loaders.cjs +1 -1
- package/gd.d.ts +1 -0
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../GDevelop/Extensions/3D/Cube3DRuntimeObject.ts"],
|
|
4
|
-
"sourcesContent": ["namespace gdjs {\n /** Base parameters for {@link gdjs.Cube3DRuntimeObject} */\n export interface Cube3DObjectData extends Object3DData {\n /** The base parameters of the Cube3D object */\n content: Object3DDataContent & {\n enableTextureTransparency: boolean | undefined;\n facesOrientation: 'Y' | 'Z' | undefined;\n frontFaceResourceName: string;\n backFaceResourceName: string;\n backFaceUpThroughWhichAxisRotation: 'X' | 'Y' | undefined;\n leftFaceResourceName: string;\n rightFaceResourceName: string;\n topFaceResourceName: string;\n bottomFaceResourceName: string;\n frontFaceResourceRepeat: boolean | undefined;\n backFaceResourceRepeat: boolean | undefined;\n leftFaceResourceRepeat: boolean | undefined;\n rightFaceResourceRepeat: boolean | undefined;\n topFaceResourceRepeat: boolean | undefined;\n bottomFaceResourceRepeat: boolean | undefined;\n frontFaceVisible: boolean;\n backFaceVisible: boolean;\n leftFaceVisible: boolean;\n rightFaceVisible: boolean;\n topFaceVisible: boolean;\n bottomFaceVisible: boolean;\n tint: string | undefined;\n isCastingShadow: boolean;\n isReceivingShadow: boolean;\n materialType: 'Basic' | 'StandardWithoutMetalness';\n };\n }\n type FaceName = 'front' | 'back' | 'left' | 'right' | 'top' | 'bottom';\n const faceNameToBitmaskIndex = {\n front: 0,\n back: 1,\n left: 2,\n right: 3,\n top: 4,\n bottom: 5,\n };\n\n type Cube3DObjectNetworkSyncDataType = {\n fo: 'Y' | 'Z';\n bfu: 'X' | 'Y';\n vfb: integer;\n trfb: integer;\n frn: [string, string, string, string, string, string];\n mt: number;\n tint: string;\n };\n\n type Cube3DObjectNetworkSyncData = Object3DNetworkSyncData &\n Cube3DObjectNetworkSyncDataType;\n\n /**\n * Shows a 3D box object.\n */\n export class Cube3DRuntimeObject extends gdjs.RuntimeObject3D {\n private _renderer: Cube3DRuntimeObjectRenderer;\n private _facesOrientation: 'Y' | 'Z';\n private _backFaceUpThroughWhichAxisRotation: 'X' | 'Y';\n private _shouldUseTransparentTexture: boolean;\n // `_rotationZ` is `angle` from `gdjs.RuntimeObject`.\n private _visibleFacesBitmask: integer;\n private _textureRepeatFacesBitmask: integer;\n private _faceResourceNames: [\n string,\n string,\n string,\n string,\n string,\n string,\n ];\n _materialType: gdjs.Cube3DRuntimeObject.MaterialType =\n gdjs.Cube3DRuntimeObject.MaterialType.StandardWithoutMetalness;\n _tint: string;\n _isCastingShadow: boolean = true;\n _isReceivingShadow: boolean = true;\n\n constructor(\n instanceContainer: gdjs.RuntimeInstanceContainer,\n objectData: Cube3DObjectData\n ) {\n super(instanceContainer, objectData);\n this._shouldUseTransparentTexture =\n objectData.content.enableTextureTransparency || false;\n this._facesOrientation = objectData.content.facesOrientation || 'Y';\n this._visibleFacesBitmask = 0;\n if (objectData.content.frontFaceVisible)\n this._visibleFacesBitmask |= 1 << faceNameToBitmaskIndex['front'];\n if (objectData.content.backFaceVisible)\n this._visibleFacesBitmask |= 1 << faceNameToBitmaskIndex['back'];\n if (objectData.content.leftFaceVisible)\n this._visibleFacesBitmask |= 1 << faceNameToBitmaskIndex['left'];\n if (objectData.content.rightFaceVisible)\n this._visibleFacesBitmask |= 1 << faceNameToBitmaskIndex['right'];\n if (objectData.content.topFaceVisible)\n this._visibleFacesBitmask |= 1 << faceNameToBitmaskIndex['top'];\n if (objectData.content.bottomFaceVisible)\n this._visibleFacesBitmask |= 1 << faceNameToBitmaskIndex['bottom'];\n this._textureRepeatFacesBitmask = 0;\n if (objectData.content.frontFaceResourceRepeat)\n this._textureRepeatFacesBitmask |= 1 << faceNameToBitmaskIndex['front'];\n if (objectData.content.backFaceResourceRepeat)\n this._textureRepeatFacesBitmask |= 1 << faceNameToBitmaskIndex['back'];\n if (objectData.content.leftFaceResourceRepeat)\n this._textureRepeatFacesBitmask |= 1 << faceNameToBitmaskIndex['left'];\n if (objectData.content.rightFaceResourceRepeat)\n this._textureRepeatFacesBitmask |= 1 << faceNameToBitmaskIndex['right'];\n if (objectData.content.topFaceResourceRepeat)\n this._textureRepeatFacesBitmask |= 1 << faceNameToBitmaskIndex['top'];\n if (objectData.content.bottomFaceResourceRepeat)\n this._textureRepeatFacesBitmask |=\n 1 << faceNameToBitmaskIndex['bottom'];\n this._backFaceUpThroughWhichAxisRotation =\n objectData.content.backFaceUpThroughWhichAxisRotation || 'X';\n this._faceResourceNames = [\n objectData.content.frontFaceResourceName,\n objectData.content.backFaceResourceName,\n objectData.content.leftFaceResourceName,\n objectData.content.rightFaceResourceName,\n objectData.content.topFaceResourceName,\n objectData.content.bottomFaceResourceName,\n ];\n\n this._tint = objectData.content.tint || '255;255;255';\n this._isCastingShadow = objectData.content.isCastingShadow || false;\n this._isReceivingShadow = objectData.content.isReceivingShadow || false;\n\n this._materialType = this._convertMaterialType(\n objectData.content.materialType\n );\n\n this._renderer = new gdjs.Cube3DRuntimeObjectRenderer(\n this,\n instanceContainer\n );\n\n // *ALWAYS* call `this.onCreated()` at the very end of your object constructor.\n this.onCreated();\n }\n\n /**\n * Sets the visibility of a face of the 3D box.\n *\n * @param faceName - The name of the face to set visibility for.\n * @param enable - The visibility value to set.\n */\n setFaceVisibility(faceName: FaceName, enable: boolean) {\n const faceIndex = faceNameToBitmaskIndex[faceName];\n if (faceIndex === undefined) {\n return;\n }\n if (enable === this.isFaceAtIndexVisible(faceIndex)) {\n return;\n }\n\n if (enable) {\n this._visibleFacesBitmask |= 1 << faceIndex;\n } else {\n this._visibleFacesBitmask &= ~(1 << faceIndex);\n }\n this._renderer.updateFace(faceIndex);\n }\n\n /**\n * Sets the texture repeat of a face of the 3D box.\n *\n * @param faceName - The name of the face to set visibility for.\n * @param enable - The visibility value to set.\n */\n setRepeatTextureOnFace(faceName: FaceName, enable: boolean) {\n const faceIndex = faceNameToBitmaskIndex[faceName];\n if (faceIndex === undefined) {\n return;\n }\n if (enable === this.shouldRepeatTextureOnFaceAtIndex(faceIndex)) {\n return;\n }\n\n if (enable) {\n this._textureRepeatFacesBitmask |= 1 << faceIndex;\n } else {\n this._textureRepeatFacesBitmask &= ~(1 << faceIndex);\n }\n this._renderer.updateFace(faceIndex);\n }\n\n isFaceVisible(faceName: FaceName): boolean {\n const faceIndex = faceNameToBitmaskIndex[faceName];\n if (faceIndex === undefined) {\n return false;\n }\n\n return this.isFaceAtIndexVisible(faceIndex);\n }\n\n /** @internal */\n isFaceAtIndexVisible(faceIndex): boolean {\n return (this._visibleFacesBitmask & (1 << faceIndex)) !== 0;\n }\n\n /** @internal */\n shouldRepeatTextureOnFaceAtIndex(faceIndex): boolean {\n return (this._textureRepeatFacesBitmask & (1 << faceIndex)) !== 0;\n }\n\n setFaceResourceName(faceName: FaceName, resourceName: string): void {\n const faceIndex = faceNameToBitmaskIndex[faceName];\n if (faceIndex === undefined) {\n return;\n }\n if (this._faceResourceNames[faceIndex] === resourceName) {\n return;\n }\n this._faceResourceNames[faceIndex] = resourceName;\n this._renderer.updateFace(faceIndex);\n }\n\n setColor(tint: string): void {\n if (this._tint === tint) {\n return;\n }\n this._tint = tint;\n this._renderer.updateTint();\n }\n\n getColor(): string {\n return this._tint;\n }\n\n /** @internal */\n getFaceAtIndexResourceName(faceIndex: integer): string {\n return this._faceResourceNames[faceIndex];\n }\n\n getRenderer(): gdjs.RuntimeObject3DRenderer {\n return this._renderer;\n }\n\n getBackFaceUpThroughWhichAxisRotation(): 'X' | 'Y' {\n return this._backFaceUpThroughWhichAxisRotation;\n }\n\n setBackFaceUpThroughWhichAxisRotation(axis: 'X' | 'Y'): void {\n this._backFaceUpThroughWhichAxisRotation = axis;\n this._renderer.updateFace(faceNameToBitmaskIndex['back']);\n }\n\n getFacesOrientation(): 'Y' | 'Z' {\n return this._facesOrientation;\n }\n\n setFacesOrientation(orientation: 'Y' | 'Z'): void {\n this._facesOrientation = orientation;\n this._renderer.updateFace(faceNameToBitmaskIndex['left']);\n this._renderer.updateFace(faceNameToBitmaskIndex['right']);\n this._renderer.updateFace(faceNameToBitmaskIndex['top']);\n // Bottom texture should not change based on that setting.\n }\n\n updateFromObjectData(\n oldObjectData: Cube3DObjectData,\n newObjectData: Cube3DObjectData\n ): boolean {\n super.updateFromObjectData(oldObjectData, newObjectData);\n if (\n oldObjectData.content.frontFaceVisible !==\n newObjectData.content.frontFaceVisible\n ) {\n this.setFaceVisibility('front', newObjectData.content.frontFaceVisible);\n }\n if (\n oldObjectData.content.backFaceVisible !==\n newObjectData.content.backFaceVisible\n ) {\n this.setFaceVisibility('back', newObjectData.content.backFaceVisible);\n }\n if (\n oldObjectData.content.leftFaceVisible !==\n newObjectData.content.leftFaceVisible\n ) {\n this.setFaceVisibility('left', newObjectData.content.leftFaceVisible);\n }\n if (\n oldObjectData.content.rightFaceVisible !==\n newObjectData.content.rightFaceVisible\n ) {\n this.setFaceVisibility('right', newObjectData.content.rightFaceVisible);\n }\n if (\n oldObjectData.content.topFaceVisible !==\n newObjectData.content.topFaceVisible\n ) {\n this.setFaceVisibility('top', newObjectData.content.topFaceVisible);\n }\n if (\n oldObjectData.content.bottomFaceVisible !==\n newObjectData.content.bottomFaceVisible\n ) {\n this.setFaceVisibility(\n 'bottom',\n newObjectData.content.bottomFaceVisible\n );\n }\n if (\n oldObjectData.content.frontFaceResourceName !==\n newObjectData.content.frontFaceResourceName\n ) {\n this.setFaceResourceName(\n 'front',\n newObjectData.content.frontFaceResourceName\n );\n }\n if (oldObjectData.content.tint !== newObjectData.content.tint) {\n this.setColor(newObjectData.content.tint || '255;255;255');\n }\n\n if (\n oldObjectData.content.backFaceResourceName !==\n newObjectData.content.backFaceResourceName\n ) {\n this.setFaceResourceName(\n 'back',\n newObjectData.content.backFaceResourceName\n );\n }\n if (\n oldObjectData.content.leftFaceResourceName !==\n newObjectData.content.leftFaceResourceName\n ) {\n this.setFaceResourceName(\n 'left',\n newObjectData.content.leftFaceResourceName\n );\n }\n if (\n oldObjectData.content.rightFaceResourceName !==\n newObjectData.content.rightFaceResourceName\n ) {\n this.setFaceResourceName(\n 'right',\n newObjectData.content.rightFaceResourceName\n );\n }\n if (\n oldObjectData.content.topFaceResourceName !==\n newObjectData.content.topFaceResourceName\n ) {\n this.setFaceResourceName(\n 'top',\n newObjectData.content.topFaceResourceName\n );\n }\n if (\n oldObjectData.content.bottomFaceResourceName !==\n newObjectData.content.bottomFaceResourceName\n ) {\n this.setFaceResourceName(\n 'bottom',\n newObjectData.content.bottomFaceResourceName\n );\n }\n if (\n oldObjectData.content.frontFaceResourceRepeat !==\n newObjectData.content.frontFaceResourceRepeat\n ) {\n this.setRepeatTextureOnFace(\n 'front',\n newObjectData.content.frontFaceResourceRepeat || false\n );\n }\n if (\n oldObjectData.content.backFaceResourceRepeat !==\n newObjectData.content.backFaceResourceRepeat\n ) {\n this.setRepeatTextureOnFace(\n 'back',\n newObjectData.content.backFaceResourceRepeat || false\n );\n }\n if (\n oldObjectData.content.leftFaceResourceRepeat !==\n newObjectData.content.leftFaceResourceRepeat\n ) {\n this.setRepeatTextureOnFace(\n 'left',\n newObjectData.content.leftFaceResourceRepeat || false\n );\n }\n if (\n oldObjectData.content.rightFaceResourceRepeat !==\n newObjectData.content.rightFaceResourceRepeat\n ) {\n this.setRepeatTextureOnFace(\n 'right',\n newObjectData.content.rightFaceResourceRepeat || false\n );\n }\n if (\n oldObjectData.content.topFaceResourceRepeat !==\n newObjectData.content.topFaceResourceRepeat\n ) {\n this.setRepeatTextureOnFace(\n 'top',\n newObjectData.content.topFaceResourceRepeat || false\n );\n }\n if (\n oldObjectData.content.bottomFaceResourceRepeat !==\n newObjectData.content.bottomFaceResourceRepeat\n ) {\n this.setRepeatTextureOnFace(\n 'bottom',\n newObjectData.content.bottomFaceResourceRepeat || false\n );\n }\n if (\n oldObjectData.content.backFaceUpThroughWhichAxisRotation !==\n newObjectData.content.backFaceUpThroughWhichAxisRotation\n ) {\n this.setBackFaceUpThroughWhichAxisRotation(\n newObjectData.content.backFaceUpThroughWhichAxisRotation || 'X'\n );\n }\n if (\n oldObjectData.content.facesOrientation !==\n newObjectData.content.facesOrientation\n ) {\n this.setFacesOrientation(newObjectData.content.facesOrientation || 'Y');\n }\n if (\n oldObjectData.content.materialType !==\n newObjectData.content.materialType\n ) {\n this.setMaterialType(newObjectData.content.materialType);\n }\n if (\n oldObjectData.content.isCastingShadow !==\n newObjectData.content.isCastingShadow\n ) {\n this.updateShadowCasting(newObjectData.content.isCastingShadow);\n }\n if (\n oldObjectData.content.isReceivingShadow !==\n newObjectData.content.isReceivingShadow\n ) {\n this.updateShadowReceiving(newObjectData.content.isReceivingShadow);\n }\n\n return true;\n }\n\n getNetworkSyncData(): Cube3DObjectNetworkSyncData {\n return {\n ...super.getNetworkSyncData(),\n mt: this._materialType,\n fo: this._facesOrientation,\n bfu: this._backFaceUpThroughWhichAxisRotation,\n vfb: this._visibleFacesBitmask,\n trfb: this._textureRepeatFacesBitmask,\n frn: this._faceResourceNames,\n tint: this._tint,\n };\n }\n\n updateFromNetworkSyncData(\n networkSyncData: Cube3DObjectNetworkSyncData\n ): void {\n super.updateFromNetworkSyncData(networkSyncData);\n\n if (networkSyncData.mt !== undefined) {\n this._materialType = networkSyncData.mt;\n }\n if (networkSyncData.fo !== undefined) {\n if (this._facesOrientation !== networkSyncData.fo) {\n this.setFacesOrientation(networkSyncData.fo);\n }\n }\n if (networkSyncData.bfu !== undefined) {\n if (this._backFaceUpThroughWhichAxisRotation !== networkSyncData.bfu) {\n this.setBackFaceUpThroughWhichAxisRotation(networkSyncData.bfu);\n }\n }\n if (networkSyncData.vfb !== undefined) {\n // If it is different, update all the faces.\n if (this._visibleFacesBitmask !== networkSyncData.vfb) {\n this._visibleFacesBitmask = networkSyncData.vfb;\n for (let i = 0; i < this._faceResourceNames.length; i++) {\n this._renderer.updateFace(i);\n }\n }\n }\n if (networkSyncData.trfb !== undefined) {\n // If it is different, update all the faces.\n if (this._textureRepeatFacesBitmask !== networkSyncData.trfb) {\n this._textureRepeatFacesBitmask = networkSyncData.trfb;\n for (let i = 0; i < this._faceResourceNames.length; i++) {\n this._renderer.updateFace(i);\n }\n }\n }\n if (networkSyncData.frn !== undefined) {\n // If one element is different, update all the faces.\n if (\n !this._faceResourceNames.every(\n (value, index) => value === networkSyncData.frn[index]\n )\n ) {\n this._faceResourceNames = networkSyncData.frn;\n // Update all faces. (Could optimize to only update the changed ones)\n for (let i = 0; i < this._faceResourceNames.length; i++) {\n this._renderer.updateFace(i);\n }\n }\n }\n if (networkSyncData.tint !== undefined) {\n if (this._tint !== networkSyncData.tint) {\n this._tint = networkSyncData.tint;\n this._renderer.updateTint();\n }\n }\n }\n\n /**\n * Return true if the texture transparency should be enabled.\n */\n shouldUseTransparentTexture(): boolean {\n return this._shouldUseTransparentTexture;\n }\n\n _convertMaterialType(\n materialTypeString: string\n ): gdjs.Cube3DRuntimeObject.MaterialType {\n if (materialTypeString === 'StandardWithoutMetalness') {\n return gdjs.Cube3DRuntimeObject.MaterialType.StandardWithoutMetalness;\n } else {\n return gdjs.Cube3DRuntimeObject.MaterialType.Basic;\n }\n }\n\n setMaterialType(materialTypeString: string) {\n const newMaterialType = this._convertMaterialType(materialTypeString);\n if (this._materialType === newMaterialType) {\n return;\n }\n\n this._materialType = newMaterialType;\n this._renderer._updateMaterials();\n }\n updateShadowCasting(value: boolean) {\n this._isCastingShadow = value;\n this._renderer.updateShadowCasting();\n }\n updateShadowReceiving(value: boolean) {\n this._isReceivingShadow = value;\n this._renderer.updateShadowReceiving();\n }\n }\n\n export namespace Cube3DRuntimeObject {\n export enum MaterialType {\n Basic,\n StandardWithoutMetalness,\n }\n }\n gdjs.registerObject('Scene3D::Cube3DObject', gdjs.Cube3DRuntimeObject);\n}\n"],
|
|
5
|
-
"mappings": "AAAA,GAAU,MAAV,UAAU,EAAV,CAiCE,KAAM,GAAyB,CAC7B,MAAO,EACP,KAAM,EACN,KAAM,EACN,MAAO,EACP,IAAK,EACL,OAAQ,GAmBH,eAAkC,GAAK,eAAgB,CAsB5D,YACE,EACA,EACA,CACA,MAAM,EAAmB,GAV3B,mBACE,EAAK,oBAAoB,aAAa,yBAExC,sBAA4B,GAC5B,wBAA8B,GAO5B,KAAK,6BACH,EAAW,QAAQ,2BAA6B,GAClD,KAAK,kBAAoB,EAAW,QAAQ,kBAAoB,IAChE,KAAK,qBAAuB,EACxB,EAAW,QAAQ,kBACrB,MAAK,sBAAwB,GAAK,EAAuB,OACvD,EAA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ACA,EAAc,QAAQ,yBAA2B,IAInD,EAAc,QAAQ,wBACtB,EAAc,QAAQ,uBAEtB,KAAK,uBACH,MACA,EAAc,QAAQ,uBAAyB,IAIjD,EAAc,QAAQ,2BACtB,EAAc,QAAQ,0BAEtB,KAAK,uBACH,SACA,EAAc,QAAQ,0BAA4B,IAIpD,EAAc,QAAQ,qCACtB,EAAc,QAAQ,oCAEtB,KAAK,sCACH,EAAc,QAAQ,oCAAsC,KAI9D,EAAc,QAAQ,mBACtB,EAAc,QAAQ,kBAEtB,KAAK,oBAAoB,EAAc,QAAQ,kBAAoB,KAGnE,EAAc,QAAQ,eACtB,EAAc,QAAQ,cAEtB,KAAK,gBAAgB,EAAc,QAAQ,cAG3C,EAAc,QAAQ,kBACtB,EAAc,QAAQ,iBAEtB,KAAK,oBAAoB,EAAc,QAAQ,iBAG/C,EAAc,QAAQ,oBACtB,EAAc,QAAQ,mBAEtB,KAAK,sBAAsB,EAAc,QAAQ,mBAG5C,GAGT,
|
|
4
|
+
"sourcesContent": ["namespace gdjs {\n /** Base parameters for {@link gdjs.Cube3DRuntimeObject} */\n export interface Cube3DObjectData extends Object3DData {\n /** The base parameters of the Cube3D object */\n content: Object3DDataContent & {\n enableTextureTransparency: boolean | undefined;\n facesOrientation: 'Y' | 'Z' | undefined;\n frontFaceResourceName: string;\n backFaceResourceName: string;\n backFaceUpThroughWhichAxisRotation: 'X' | 'Y' | undefined;\n leftFaceResourceName: string;\n rightFaceResourceName: string;\n topFaceResourceName: string;\n bottomFaceResourceName: string;\n frontFaceResourceRepeat: boolean | undefined;\n backFaceResourceRepeat: boolean | undefined;\n leftFaceResourceRepeat: boolean | undefined;\n rightFaceResourceRepeat: boolean | undefined;\n topFaceResourceRepeat: boolean | undefined;\n bottomFaceResourceRepeat: boolean | undefined;\n frontFaceVisible: boolean;\n backFaceVisible: boolean;\n leftFaceVisible: boolean;\n rightFaceVisible: boolean;\n topFaceVisible: boolean;\n bottomFaceVisible: boolean;\n tint: string | undefined;\n isCastingShadow: boolean;\n isReceivingShadow: boolean;\n materialType: 'Basic' | 'StandardWithoutMetalness';\n };\n }\n type FaceName = 'front' | 'back' | 'left' | 'right' | 'top' | 'bottom';\n const faceNameToBitmaskIndex = {\n front: 0,\n back: 1,\n left: 2,\n right: 3,\n top: 4,\n bottom: 5,\n };\n\n type Cube3DObjectNetworkSyncDataType = {\n fo: 'Y' | 'Z';\n bfu: 'X' | 'Y';\n vfb: integer;\n trfb: integer;\n frn: [string, string, string, string, string, string];\n mt: number;\n tint: string;\n };\n\n type Cube3DObjectNetworkSyncData = Object3DNetworkSyncData &\n Cube3DObjectNetworkSyncDataType;\n\n /**\n * Shows a 3D box object.\n */\n export class Cube3DRuntimeObject extends gdjs.RuntimeObject3D {\n private _renderer: Cube3DRuntimeObjectRenderer;\n private _facesOrientation: 'Y' | 'Z';\n private _backFaceUpThroughWhichAxisRotation: 'X' | 'Y';\n private _shouldUseTransparentTexture: boolean;\n // `_rotationZ` is `angle` from `gdjs.RuntimeObject`.\n private _visibleFacesBitmask: integer;\n private _textureRepeatFacesBitmask: integer;\n private _faceResourceNames: [\n string,\n string,\n string,\n string,\n string,\n string,\n ];\n _materialType: gdjs.Cube3DRuntimeObject.MaterialType =\n gdjs.Cube3DRuntimeObject.MaterialType.StandardWithoutMetalness;\n _tint: string;\n _isCastingShadow: boolean = true;\n _isReceivingShadow: boolean = true;\n\n constructor(\n instanceContainer: gdjs.RuntimeInstanceContainer,\n objectData: Cube3DObjectData\n ) {\n super(instanceContainer, objectData);\n this._shouldUseTransparentTexture =\n objectData.content.enableTextureTransparency || false;\n this._facesOrientation = objectData.content.facesOrientation || 'Y';\n this._visibleFacesBitmask = 0;\n if (objectData.content.frontFaceVisible)\n this._visibleFacesBitmask |= 1 << faceNameToBitmaskIndex['front'];\n if (objectData.content.backFaceVisible)\n this._visibleFacesBitmask |= 1 << faceNameToBitmaskIndex['back'];\n if (objectData.content.leftFaceVisible)\n this._visibleFacesBitmask |= 1 << faceNameToBitmaskIndex['left'];\n if (objectData.content.rightFaceVisible)\n this._visibleFacesBitmask |= 1 << faceNameToBitmaskIndex['right'];\n if (objectData.content.topFaceVisible)\n this._visibleFacesBitmask |= 1 << faceNameToBitmaskIndex['top'];\n if (objectData.content.bottomFaceVisible)\n this._visibleFacesBitmask |= 1 << faceNameToBitmaskIndex['bottom'];\n this._textureRepeatFacesBitmask = 0;\n if (objectData.content.frontFaceResourceRepeat)\n this._textureRepeatFacesBitmask |= 1 << faceNameToBitmaskIndex['front'];\n if (objectData.content.backFaceResourceRepeat)\n this._textureRepeatFacesBitmask |= 1 << faceNameToBitmaskIndex['back'];\n if (objectData.content.leftFaceResourceRepeat)\n this._textureRepeatFacesBitmask |= 1 << faceNameToBitmaskIndex['left'];\n if (objectData.content.rightFaceResourceRepeat)\n this._textureRepeatFacesBitmask |= 1 << faceNameToBitmaskIndex['right'];\n if (objectData.content.topFaceResourceRepeat)\n this._textureRepeatFacesBitmask |= 1 << faceNameToBitmaskIndex['top'];\n if (objectData.content.bottomFaceResourceRepeat)\n this._textureRepeatFacesBitmask |=\n 1 << faceNameToBitmaskIndex['bottom'];\n this._backFaceUpThroughWhichAxisRotation =\n objectData.content.backFaceUpThroughWhichAxisRotation || 'X';\n this._faceResourceNames = [\n objectData.content.frontFaceResourceName,\n objectData.content.backFaceResourceName,\n objectData.content.leftFaceResourceName,\n objectData.content.rightFaceResourceName,\n objectData.content.topFaceResourceName,\n objectData.content.bottomFaceResourceName,\n ];\n\n this._tint = objectData.content.tint || '255;255;255';\n this._isCastingShadow = objectData.content.isCastingShadow || false;\n this._isReceivingShadow = objectData.content.isReceivingShadow || false;\n\n this._materialType = this._convertMaterialType(\n objectData.content.materialType\n );\n\n this._renderer = new gdjs.Cube3DRuntimeObjectRenderer(\n this,\n instanceContainer\n );\n\n // *ALWAYS* call `this.onCreated()` at the very end of your object constructor.\n this.onCreated();\n }\n\n /**\n * Sets the visibility of a face of the 3D box.\n *\n * @param faceName - The name of the face to set visibility for.\n * @param enable - The visibility value to set.\n */\n setFaceVisibility(faceName: FaceName, enable: boolean) {\n const faceIndex = faceNameToBitmaskIndex[faceName];\n if (faceIndex === undefined) {\n return;\n }\n if (enable === this.isFaceAtIndexVisible(faceIndex)) {\n return;\n }\n\n if (enable) {\n this._visibleFacesBitmask |= 1 << faceIndex;\n } else {\n this._visibleFacesBitmask &= ~(1 << faceIndex);\n }\n this._renderer.updateFace(faceIndex);\n }\n\n /**\n * Sets the texture repeat of a face of the 3D box.\n *\n * @param faceName - The name of the face to set visibility for.\n * @param enable - The visibility value to set.\n */\n setRepeatTextureOnFace(faceName: FaceName, enable: boolean) {\n const faceIndex = faceNameToBitmaskIndex[faceName];\n if (faceIndex === undefined) {\n return;\n }\n if (enable === this.shouldRepeatTextureOnFaceAtIndex(faceIndex)) {\n return;\n }\n\n if (enable) {\n this._textureRepeatFacesBitmask |= 1 << faceIndex;\n } else {\n this._textureRepeatFacesBitmask &= ~(1 << faceIndex);\n }\n this._renderer.updateFace(faceIndex);\n }\n\n isFaceVisible(faceName: FaceName): boolean {\n const faceIndex = faceNameToBitmaskIndex[faceName];\n if (faceIndex === undefined) {\n return false;\n }\n\n return this.isFaceAtIndexVisible(faceIndex);\n }\n\n /** @internal */\n isFaceAtIndexVisible(faceIndex): boolean {\n return (this._visibleFacesBitmask & (1 << faceIndex)) !== 0;\n }\n\n /** @internal */\n shouldRepeatTextureOnFaceAtIndex(faceIndex): boolean {\n return (this._textureRepeatFacesBitmask & (1 << faceIndex)) !== 0;\n }\n\n setFaceResourceName(faceName: FaceName, resourceName: string): void {\n const faceIndex = faceNameToBitmaskIndex[faceName];\n if (faceIndex === undefined) {\n return;\n }\n if (this._faceResourceNames[faceIndex] === resourceName) {\n return;\n }\n this._faceResourceNames[faceIndex] = resourceName;\n this._renderer.updateFace(faceIndex);\n }\n\n setColor(tint: string): void {\n if (this._tint === tint) {\n return;\n }\n this._tint = tint;\n this._renderer.updateTint();\n }\n\n getColor(): string {\n return this._tint;\n }\n\n /** @internal */\n getFaceAtIndexResourceName(faceIndex: integer): string {\n return this._faceResourceNames[faceIndex];\n }\n\n getRenderer(): gdjs.RuntimeObject3DRenderer {\n return this._renderer;\n }\n\n getBackFaceUpThroughWhichAxisRotation(): 'X' | 'Y' {\n return this._backFaceUpThroughWhichAxisRotation;\n }\n\n setBackFaceUpThroughWhichAxisRotation(axis: 'X' | 'Y'): void {\n this._backFaceUpThroughWhichAxisRotation = axis;\n this._renderer.updateFace(faceNameToBitmaskIndex['back']);\n }\n\n getFacesOrientation(): 'Y' | 'Z' {\n return this._facesOrientation;\n }\n\n setFacesOrientation(orientation: 'Y' | 'Z'): void {\n this._facesOrientation = orientation;\n this._renderer.updateFace(faceNameToBitmaskIndex['left']);\n this._renderer.updateFace(faceNameToBitmaskIndex['right']);\n this._renderer.updateFace(faceNameToBitmaskIndex['top']);\n // Bottom texture should not change based on that setting.\n }\n\n updateFromObjectData(\n oldObjectData: Cube3DObjectData,\n newObjectData: Cube3DObjectData\n ): boolean {\n super.updateFromObjectData(oldObjectData, newObjectData);\n if (\n oldObjectData.content.frontFaceVisible !==\n newObjectData.content.frontFaceVisible\n ) {\n this.setFaceVisibility('front', newObjectData.content.frontFaceVisible);\n }\n if (\n oldObjectData.content.backFaceVisible !==\n newObjectData.content.backFaceVisible\n ) {\n this.setFaceVisibility('back', newObjectData.content.backFaceVisible);\n }\n if (\n oldObjectData.content.leftFaceVisible !==\n newObjectData.content.leftFaceVisible\n ) {\n this.setFaceVisibility('left', newObjectData.content.leftFaceVisible);\n }\n if (\n oldObjectData.content.rightFaceVisible !==\n newObjectData.content.rightFaceVisible\n ) {\n this.setFaceVisibility('right', newObjectData.content.rightFaceVisible);\n }\n if (\n oldObjectData.content.topFaceVisible !==\n newObjectData.content.topFaceVisible\n ) {\n this.setFaceVisibility('top', newObjectData.content.topFaceVisible);\n }\n if (\n oldObjectData.content.bottomFaceVisible !==\n newObjectData.content.bottomFaceVisible\n ) {\n this.setFaceVisibility(\n 'bottom',\n newObjectData.content.bottomFaceVisible\n );\n }\n if (\n oldObjectData.content.frontFaceResourceName !==\n newObjectData.content.frontFaceResourceName\n ) {\n this.setFaceResourceName(\n 'front',\n newObjectData.content.frontFaceResourceName\n );\n }\n if (oldObjectData.content.tint !== newObjectData.content.tint) {\n this.setColor(newObjectData.content.tint || '255;255;255');\n }\n\n if (\n oldObjectData.content.backFaceResourceName !==\n newObjectData.content.backFaceResourceName\n ) {\n this.setFaceResourceName(\n 'back',\n newObjectData.content.backFaceResourceName\n );\n }\n if (\n oldObjectData.content.leftFaceResourceName !==\n newObjectData.content.leftFaceResourceName\n ) {\n this.setFaceResourceName(\n 'left',\n newObjectData.content.leftFaceResourceName\n );\n }\n if (\n oldObjectData.content.rightFaceResourceName !==\n newObjectData.content.rightFaceResourceName\n ) {\n this.setFaceResourceName(\n 'right',\n newObjectData.content.rightFaceResourceName\n );\n }\n if (\n oldObjectData.content.topFaceResourceName !==\n newObjectData.content.topFaceResourceName\n ) {\n this.setFaceResourceName(\n 'top',\n newObjectData.content.topFaceResourceName\n );\n }\n if (\n oldObjectData.content.bottomFaceResourceName !==\n newObjectData.content.bottomFaceResourceName\n ) {\n this.setFaceResourceName(\n 'bottom',\n newObjectData.content.bottomFaceResourceName\n );\n }\n if (\n oldObjectData.content.frontFaceResourceRepeat !==\n newObjectData.content.frontFaceResourceRepeat\n ) {\n this.setRepeatTextureOnFace(\n 'front',\n newObjectData.content.frontFaceResourceRepeat || false\n );\n }\n if (\n oldObjectData.content.backFaceResourceRepeat !==\n newObjectData.content.backFaceResourceRepeat\n ) {\n this.setRepeatTextureOnFace(\n 'back',\n newObjectData.content.backFaceResourceRepeat || false\n );\n }\n if (\n oldObjectData.content.leftFaceResourceRepeat !==\n newObjectData.content.leftFaceResourceRepeat\n ) {\n this.setRepeatTextureOnFace(\n 'left',\n newObjectData.content.leftFaceResourceRepeat || false\n );\n }\n if (\n oldObjectData.content.rightFaceResourceRepeat !==\n newObjectData.content.rightFaceResourceRepeat\n ) {\n this.setRepeatTextureOnFace(\n 'right',\n newObjectData.content.rightFaceResourceRepeat || false\n );\n }\n if (\n oldObjectData.content.topFaceResourceRepeat !==\n newObjectData.content.topFaceResourceRepeat\n ) {\n this.setRepeatTextureOnFace(\n 'top',\n newObjectData.content.topFaceResourceRepeat || false\n );\n }\n if (\n oldObjectData.content.bottomFaceResourceRepeat !==\n newObjectData.content.bottomFaceResourceRepeat\n ) {\n this.setRepeatTextureOnFace(\n 'bottom',\n newObjectData.content.bottomFaceResourceRepeat || false\n );\n }\n if (\n oldObjectData.content.backFaceUpThroughWhichAxisRotation !==\n newObjectData.content.backFaceUpThroughWhichAxisRotation\n ) {\n this.setBackFaceUpThroughWhichAxisRotation(\n newObjectData.content.backFaceUpThroughWhichAxisRotation || 'X'\n );\n }\n if (\n oldObjectData.content.facesOrientation !==\n newObjectData.content.facesOrientation\n ) {\n this.setFacesOrientation(newObjectData.content.facesOrientation || 'Y');\n }\n if (\n oldObjectData.content.materialType !==\n newObjectData.content.materialType\n ) {\n this.setMaterialType(newObjectData.content.materialType);\n }\n if (\n oldObjectData.content.isCastingShadow !==\n newObjectData.content.isCastingShadow\n ) {\n this.updateShadowCasting(newObjectData.content.isCastingShadow);\n }\n if (\n oldObjectData.content.isReceivingShadow !==\n newObjectData.content.isReceivingShadow\n ) {\n this.updateShadowReceiving(newObjectData.content.isReceivingShadow);\n }\n\n return true;\n }\n\n getNetworkSyncData(\n syncOptions: GetNetworkSyncDataOptions\n ): Cube3DObjectNetworkSyncData {\n return {\n ...super.getNetworkSyncData(syncOptions),\n mt: this._materialType,\n fo: this._facesOrientation,\n bfu: this._backFaceUpThroughWhichAxisRotation,\n vfb: this._visibleFacesBitmask,\n trfb: this._textureRepeatFacesBitmask,\n frn: this._faceResourceNames,\n tint: this._tint,\n };\n }\n\n updateFromNetworkSyncData(\n networkSyncData: Cube3DObjectNetworkSyncData,\n options: UpdateFromNetworkSyncDataOptions\n ): void {\n super.updateFromNetworkSyncData(networkSyncData, options);\n\n if (networkSyncData.mt !== undefined) {\n this._materialType = networkSyncData.mt;\n }\n if (networkSyncData.fo !== undefined) {\n if (this._facesOrientation !== networkSyncData.fo) {\n this.setFacesOrientation(networkSyncData.fo);\n }\n }\n if (networkSyncData.bfu !== undefined) {\n if (this._backFaceUpThroughWhichAxisRotation !== networkSyncData.bfu) {\n this.setBackFaceUpThroughWhichAxisRotation(networkSyncData.bfu);\n }\n }\n if (networkSyncData.vfb !== undefined) {\n // If it is different, update all the faces.\n if (this._visibleFacesBitmask !== networkSyncData.vfb) {\n this._visibleFacesBitmask = networkSyncData.vfb;\n for (let i = 0; i < this._faceResourceNames.length; i++) {\n this._renderer.updateFace(i);\n }\n }\n }\n if (networkSyncData.trfb !== undefined) {\n // If it is different, update all the faces.\n if (this._textureRepeatFacesBitmask !== networkSyncData.trfb) {\n this._textureRepeatFacesBitmask = networkSyncData.trfb;\n for (let i = 0; i < this._faceResourceNames.length; i++) {\n this._renderer.updateFace(i);\n }\n }\n }\n if (networkSyncData.frn !== undefined) {\n // If one element is different, update all the faces.\n if (\n !this._faceResourceNames.every(\n (value, index) => value === networkSyncData.frn[index]\n )\n ) {\n this._faceResourceNames = networkSyncData.frn;\n // Update all faces. (Could optimize to only update the changed ones)\n for (let i = 0; i < this._faceResourceNames.length; i++) {\n this._renderer.updateFace(i);\n }\n }\n }\n if (networkSyncData.tint !== undefined) {\n if (this._tint !== networkSyncData.tint) {\n this._tint = networkSyncData.tint;\n this._renderer.updateTint();\n }\n }\n }\n\n /**\n * Return true if the texture transparency should be enabled.\n */\n shouldUseTransparentTexture(): boolean {\n return this._shouldUseTransparentTexture;\n }\n\n _convertMaterialType(\n materialTypeString: string\n ): gdjs.Cube3DRuntimeObject.MaterialType {\n if (materialTypeString === 'StandardWithoutMetalness') {\n return gdjs.Cube3DRuntimeObject.MaterialType.StandardWithoutMetalness;\n } else {\n return gdjs.Cube3DRuntimeObject.MaterialType.Basic;\n }\n }\n\n setMaterialType(materialTypeString: string) {\n const newMaterialType = this._convertMaterialType(materialTypeString);\n if (this._materialType === newMaterialType) {\n return;\n }\n\n this._materialType = newMaterialType;\n this._renderer._updateMaterials();\n }\n updateShadowCasting(value: boolean) {\n this._isCastingShadow = value;\n this._renderer.updateShadowCasting();\n }\n updateShadowReceiving(value: boolean) {\n this._isReceivingShadow = value;\n this._renderer.updateShadowReceiving();\n }\n }\n\n export namespace Cube3DRuntimeObject {\n export enum MaterialType {\n Basic,\n StandardWithoutMetalness,\n }\n }\n gdjs.registerObject('Scene3D::Cube3DObject', gdjs.Cube3DRuntimeObject);\n}\n"],
|
|
5
|
+
"mappings": "AAAA,GAAU,MAAV,UAAU,EAAV,CAiCE,KAAM,GAAyB,CAC7B,MAAO,EACP,KAAM,EACN,KAAM,EACN,MAAO,EACP,IAAK,EACL,OAAQ,GAmBH,eAAkC,GAAK,eAAgB,CAsB5D,YACE,EACA,EACA,CACA,MAAM,EAAmB,GAV3B,mBACE,EAAK,oBAAoB,aAAa,yBAExC,sBAA4B,GAC5B,wBAA8B,GAO5B,KAAK,6BACH,EAAW,QAAQ,2BAA6B,GAClD,KAAK,kBAAoB,EAAW,QAAQ,kBAAoB,IAChE,KAAK,qBAAuB,EACxB,EAAW,QAAQ,kBACrB,MAAK,sBAAwB,GAAK,EAAuB,OACvD,EAAW,QAAQ,iBACrB,MAAK,sBAAwB,GAAK,EAAuB,MACvD,EAAW,QAAQ,iBACrB,MAAK,sBAAwB,GAAK,EAAuB,MACvD,EAAW,QAAQ,kBACrB,MAAK,sBAAwB,GAAK,EAAuB,OACvD,EAAW,QAAQ,gBACrB,MAAK,sBAAwB,GAAK,EAAuB,KACvD,EAAW,QAAQ,mBACrB,MAAK,sBAAwB,GAAK,EAAuB,QAC3D,KAAK,2BAA6B,EAC9B,EAAW,QAAQ,yBACrB,MAAK,4BAA8B,GAAK,EAAuB,OAC7D,EAAW,QAAQ,wBACrB,MAAK,4BAA8B,GAAK,EAAuB,MAC7D,EAAW,QAAQ,wBACrB,MA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,KAC7B,KAAK,UAAU,cAQrB,6BAAuC,CACrC,MAAO,MAAK,6BAGd,qBACE,EACuC,CACvC,MAAI,KAAuB,2BAClB,EAAK,oBAAoB,aAAa,yBAEtC,EAAK,oBAAoB,aAAa,MAIjD,gBAAgB,EAA4B,CAC1C,KAAM,GAAkB,KAAK,qBAAqB,GAClD,AAAI,KAAK,gBAAkB,GAI3B,MAAK,cAAgB,EACrB,KAAK,UAAU,oBAEjB,oBAAoB,EAAgB,CAClC,KAAK,iBAAmB,EACxB,KAAK,UAAU,sBAEjB,sBAAsB,EAAgB,CACpC,KAAK,mBAAqB,EAC1B,KAAK,UAAU,yBAtfZ,EAAM,sBA0fN,SAAU,EAAV,CACE,GAAK,GAAL,UAAK,EAAL,CACL,qBACA,6DAFU,wCADG,qDAMjB,EAAK,eAAe,wBAAyB,EAAK,uBA1jB1C",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var gdjs;(function(r){class s extends r.CustomRuntimeObject{constructor(t,
|
|
1
|
+
var gdjs;(function(r){class s extends r.CustomRuntimeObject{constructor(t,e){super(t,e);this._z=0;this._minZ=0;this._maxZ=0;this._scaleZ=1;this._flippedZ=!1;this._rotationX=0;this._rotationY=0;this._customCenterZ=0}_createRender(){const t=this._runtimeScene;return new r.CustomRuntimeObject3DRenderer(this,this._instanceContainer,t)}_reinitializeRenderer(){this.getRenderer().reinitialize(this,this.getParent())}getRenderer(){return super.getRenderer()}get3DRendererObject(){return this.getRenderer().get3DRendererObject()}extraInitializationFromInitialInstance(t){super.extraInitializationFromInitialInstance(t),t.depth!==void 0&&this.setDepth(t.depth),t.flippedX&&this.flipX(t.flippedX),t.flippedY&&this.flipY(t.flippedY),t.flippedZ&&this.flipZ(t.flippedZ)}getNetworkSyncData(t){return{...super.getNetworkSyncData(t),z:this.getZ(),d:this.getDepth(),rx:this.getRotationX(),ry:this.getRotationY(),ifz:this.isFlippedZ(),ccz:this._customCenterZ}}updateFromNetworkSyncData(t,e){super.updateFromNetworkSyncData(t,e),t.z!==void 0&&this.setZ(t.z),t.d!==void 0&&this.setDepth(t.d),t.rx!==void 0&&this.setRotationX(t.rx),t.ry!==void 0&&this.setRotationY(t.ry),t.ifz!==void 0&&this.flipZ(t.ifz),t.ccz!==void 0&&(this._customCenterZ=t.ccz)}setZ(t){t!==this._z&&(this._z=t,this.getRenderer().updatePosition())}getZ(){return this._z}getDrawableZ(){let t=0;this._innerArea?t=this._innerArea.min[2]:(this._isUntransformedHitBoxesDirty&&this._updateUntransformedHitBoxes(),t=this._minZ);const e=this.getScaleZ();return this._flippedZ?this._z+(-t-this.getUnscaledDepth()+2*this.getUnscaledCenterZ())*e:this._z+t*e}getCenterZ(){return this.getDepth()/2}getCenterZInScene(){return this.getDrawableZ()+this.getCenterZ()}setCenterZInScene(t){this.setZ(t+this._z-(this.getDrawableZ()+this.getCenterZ()))}getUnrotatedAABBMinZ(){return this.getDrawableZ()}getUnrotatedAABBMaxZ(){return this.getDrawableZ()+this.getDepth()}setRotationX(t){this._rotationX=t,this.getRenderer().updateRotation()}setRotationY(t){this._rotationY=t,this.getRenderer().updateRotation()}getRotationX(){return this._rotationX}getRotationY(){return this._rotationY}turnAroundX(t){const e=r.CustomRuntimeObject3D._temporaryVector;e.set(1,0,0);const i=this.get3DRendererObject();i.rotateOnWorldAxis(e,r.toRad(t)),this._rotationX=r.toDegrees(i.rotation.x),this._rotationY=r.toDegrees(i.rotation.y),this.setAngle(r.toDegrees(i.rotation.z))}turnAroundY(t){const e=r.CustomRuntimeObject3D._temporaryVector;e.set(0,1,0);const i=this.get3DRendererObject();i.rotateOnWorldAxis(e,r.toRad(t)),this._rotationX=r.toDegrees(i.rotation.x),this._rotationY=r.toDegrees(i.rotation.y),this.setAngle(r.toDegrees(i.rotation.z))}turnAroundZ(t){const e=r.CustomRuntimeObject3D._temporaryVector;e.set(0,0,1);const i=this.get3DRendererObject();i.rotateOnWorldAxis(e,r.toRad(t)),this._rotationX=r.toDegrees(i.rotation.x),this._rotationY=r.toDegrees(i.rotation.y),this.setAngle(r.toDegrees(i.rotation.z))}getInnerAreaMinZ(){return this._innerArea?this._innerArea.min[2]:(this._isUntransformedHitBoxesDirty&&this._updateUntransformedHitBoxes(),this._minZ)}getInnerAreaMaxZ(){return this._innerArea?this._innerArea.max[2]:(this._isUntransformedHitBoxesDirty&&this._updateUntransformedHitBoxes(),this._maxZ)}getUnscaledDepth(){return this._innerArea?this._innerArea.max[2]-this._innerArea.min[2]:(this._isUntransformedHitBoxesDirty&&this._updateUntransformedHitBoxes(),this._maxZ-this._minZ)}_updateUntransformedHitBoxes(){super._updateUntransformedHitBoxes();let t=Number.MAX_VALUE,e=-Number.MAX_VALUE;for(const i of this._instanceContainer.getAdhocListOfAllInstances())!i.isIncludedInParentCollisionMask()||!r.Base3DHandler.is3D(i)||(t=Math.min(t,i.getUnrotatedAABBMinZ()),e=Math.max(e,i.getUnrotatedAABBMaxZ()));t===Number.MAX_VALUE&&(t=0,e=1),this._minZ=t,this._maxZ=e}getUnscaledCenterZ(){return this.hasCustomRotationCenter()?this._customCenterZ:this._innerArea?(this._innerArea.min[2]+this._innerArea.max[2])/2:(this._isUntransformedHitBoxesDirty&&this._updateUntransformedHitBoxes(),(this._minZ+this._maxZ)/2)}setRotationCenter3D(t,e,i){this._customCenterZ=i,this.setRotationCenter(t,e)}getDepth(){return this.getUnscaledDepth()*this.getScaleZ()}setDepth(t){const e=this.getUnscaledDepth();if(e===0)return;const i=t/e;this._innerArea&&this._isInnerAreaFollowingParentSize?(this._innerArea.min[2]*=i,this._innerArea.max[2]*=i):this.setScaleZ(i)}setScale(t){super.setScale(t),this.setScaleZ(t)}setScaleZ(t){this._innerArea&&this._isInnerAreaFollowingParentSize||(t<0&&(t=0),t!==Math.abs(this._scaleZ)&&(this._scaleZ=t*(this._flippedZ?-1:1),this.getRenderer().updateSize()))}getScale(){const t=this.getScaleX(),e=this.getScaleY(),i=this.getScaleZ();return t===e&&t===i?t:Math.pow(t*e*i,1/3)}getScaleZ(){return Math.abs(this._scaleZ)}flipZ(t){t!==this._flippedZ&&(this._flippedZ=t,this.getRenderer().updateSize())}isFlippedZ(){return this._flippedZ}}s._temporaryVector=new THREE.Vector3,r.CustomRuntimeObject3D=s})(gdjs||(gdjs={}));
|
|
2
2
|
//# sourceMappingURL=CustomRuntimeObject3D.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../GDevelop/Extensions/3D/CustomRuntimeObject3D.ts"],
|
|
4
|
-
"sourcesContent": ["namespace gdjs {\n type CustomObject3DNetworkSyncDataType = CustomObjectNetworkSyncDataType & {\n z: float;\n d: float;\n rx: float;\n ry: float;\n ifz: boolean;\n };\n\n /**\n * Base class for 3D custom objects.\n */\n export class CustomRuntimeObject3D\n extends gdjs.CustomRuntimeObject\n implements gdjs.Base3DHandler\n {\n /**\n * Position on the Z axis.\n */\n private _z: float = 0;\n private _minZ: float = 0;\n private _maxZ: float = 0;\n private _scaleZ: float = 1;\n private _flippedZ: boolean = false;\n /**\n * Euler angle with the `ZYX` order.\n *\n * Note that `_rotationZ` is `angle` from `gdjs.RuntimeObject`.\n */\n private _rotationX: float = 0;\n /**\n * Euler angle with the `ZYX` order.\n *\n * Note that `_rotationZ` is `angle` from `gdjs.RuntimeObject`.\n */\n private _rotationY: float = 0;\n private _customCenterZ: float = 0;\n private static _temporaryVector = new THREE.Vector3();\n\n constructor(\n parent: gdjs.RuntimeInstanceContainer,\n objectData: gdjs.Object3DData & gdjs.CustomObjectConfiguration\n ) {\n super(parent, objectData);\n }\n\n protected override _createRender() {\n const parent = this._runtimeScene;\n return new gdjs.CustomRuntimeObject3DRenderer(\n this,\n this._instanceContainer,\n parent\n );\n }\n\n protected override _reinitializeRenderer(): void {\n this.getRenderer().reinitialize(this, this.getParent());\n }\n\n override getRenderer(): gdjs.CustomRuntimeObject3DRenderer {\n return super.getRenderer() as gdjs.CustomRuntimeObject3DRenderer;\n }\n\n override get3DRendererObject() {\n // It can't be null because Three.js is always loaded\n // when a custom 3D object is used.\n return this.getRenderer().get3DRendererObject()!;\n }\n\n override extraInitializationFromInitialInstance(\n initialInstanceData: InstanceData\n ) {\n super.extraInitializationFromInitialInstance(initialInstanceData);\n if (initialInstanceData.depth !== undefined) {\n this.setDepth(initialInstanceData.depth);\n }\n if (initialInstanceData.flippedX) {\n this.flipX(initialInstanceData.flippedX);\n }\n if (initialInstanceData.flippedY) {\n this.flipY(initialInstanceData.flippedY);\n }\n if (initialInstanceData.flippedZ) {\n this.flipZ(initialInstanceData.flippedZ);\n }\n }\n\n getNetworkSyncData(): CustomObject3DNetworkSyncDataType {\n return {\n ...super.getNetworkSyncData(),\n z: this.getZ(),\n d: this.getDepth(),\n rx: this.getRotationX(),\n ry: this.getRotationY(),\n ifz: this.isFlippedZ(),\n };\n }\n\n updateFromNetworkSyncData(\n networkSyncData: CustomObject3DNetworkSyncDataType\n ): void {\n super.updateFromNetworkSyncData(networkSyncData);\n if (networkSyncData.z !== undefined) this.setZ(networkSyncData.z);\n if (networkSyncData.d !== undefined) this.setDepth(networkSyncData.d);\n if (networkSyncData.rx !== undefined)\n this.setRotationX(networkSyncData.rx);\n if (networkSyncData.ry !== undefined)\n this.setRotationY(networkSyncData.ry);\n if (networkSyncData.ifz !== undefined) this.flipZ(networkSyncData.ifz);\n }\n\n /**\n * Set the object position on the Z axis.\n */\n setZ(z: float): void {\n if (z === this._z) return;\n this._z = z;\n this.getRenderer().updatePosition();\n }\n\n /**\n * Get the object position on the Z axis.\n */\n getZ(): float {\n return this._z;\n }\n\n /**\n * Get the Z position of the rendered object.\n *\n * For most objects, this will returns the same value as getZ(). But if the\n * object has an origin that is not the same as the point (0,0,0) of the\n * object displayed, getDrawableZ will differ.\n *\n * @return The Z position of the rendered object.\n */\n getDrawableZ(): float {\n let minZ = 0;\n if (this._innerArea) {\n minZ = this._innerArea.min[2];\n } else {\n if (this._isUntransformedHitBoxesDirty) {\n this._updateUntransformedHitBoxes();\n }\n minZ = this._minZ;\n }\n const absScaleZ = this.getScaleZ();\n if (!this._flippedZ) {\n return this._z + minZ * absScaleZ;\n } else {\n return (\n this._z +\n (-minZ - this.getUnscaledDepth() + 2 * this.getUnscaledCenterZ()) *\n absScaleZ\n );\n }\n }\n\n /**\n * Return the Z position of the object center, **relative to the object Z\n * position** (`getDrawableX`).\n *\n * Use `getCenterZInScene` to get the position of the center in the scene.\n *\n * @return the Z position of the object center, relative to\n * `getDrawableZ()`.\n */\n getCenterZ(): float {\n return this.getDepth() / 2;\n }\n\n getCenterZInScene(): float {\n return this.getDrawableZ() + this.getCenterZ();\n }\n\n setCenterZInScene(z: float): void {\n this.setZ(z + this._z - (this.getDrawableZ() + this.getCenterZ()));\n }\n\n /**\n * Return the bottom Z of the object.\n * Rotations around X and Y are not taken into account.\n */\n getUnrotatedAABBMinZ(): number {\n return this.getDrawableZ();\n }\n\n /**\n * Return the top Z of the object.\n * Rotations around X and Y are not taken into account.\n */\n getUnrotatedAABBMaxZ(): number {\n return this.getDrawableZ() + this.getDepth();\n }\n\n /**\n * Set the object rotation on the X axis.\n *\n * This is an Euler angle. Objects use the `ZYX` order.\n */\n setRotationX(angle: float): void {\n this._rotationX = angle;\n this.getRenderer().updateRotation();\n }\n\n /**\n * Set the object rotation on the Y axis.\n *\n * This is an Euler angle. Objects use the `ZYX` order.\n */\n setRotationY(angle: float): void {\n this._rotationY = angle;\n this.getRenderer().updateRotation();\n }\n\n /**\n * Get the object rotation on the X axis.\n *\n * This is an Euler angle. Objects use the `ZYX` order.\n */\n getRotationX(): float {\n return this._rotationX;\n }\n\n /**\n * Get the object rotation on the Y axis.\n *\n * This is an Euler angle. Objects use the `ZYX` order.\n */\n getRotationY(): float {\n return this._rotationY;\n }\n\n /**\n * Turn the object around the scene x axis at its center.\n * @param deltaAngle the rotation angle\n */\n turnAroundX(deltaAngle: float): void {\n const axisX = gdjs.CustomRuntimeObject3D._temporaryVector;\n axisX.set(1, 0, 0);\n\n const mesh = this.get3DRendererObject();\n mesh.rotateOnWorldAxis(axisX, gdjs.toRad(deltaAngle));\n this._rotationX = gdjs.toDegrees(mesh.rotation.x);\n this._rotationY = gdjs.toDegrees(mesh.rotation.y);\n this.setAngle(gdjs.toDegrees(mesh.rotation.z));\n }\n\n /**\n * Turn the object around the scene y axis at its center.\n * @param deltaAngle the rotation angle\n */\n turnAroundY(deltaAngle: float): void {\n const axisY = gdjs.CustomRuntimeObject3D._temporaryVector;\n axisY.set(0, 1, 0);\n\n const mesh = this.get3DRendererObject();\n mesh.rotateOnWorldAxis(axisY, gdjs.toRad(deltaAngle));\n this._rotationX = gdjs.toDegrees(mesh.rotation.x);\n this._rotationY = gdjs.toDegrees(mesh.rotation.y);\n this.setAngle(gdjs.toDegrees(mesh.rotation.z));\n }\n\n /**\n * Turn the object around the scene z axis at its center.\n * @param deltaAngle the rotation angle\n */\n turnAroundZ(deltaAngle: float): void {\n const axisZ = gdjs.CustomRuntimeObject3D._temporaryVector;\n axisZ.set(0, 0, 1);\n\n const mesh = this.get3DRendererObject();\n mesh.rotateOnWorldAxis(axisZ, gdjs.toRad(deltaAngle));\n this._rotationX = gdjs.toDegrees(mesh.rotation.x);\n this._rotationY = gdjs.toDegrees(mesh.rotation.y);\n this.setAngle(gdjs.toDegrees(mesh.rotation.z));\n }\n\n /**\n * @return the internal top bound of the object according to its children.\n */\n getInnerAreaMinZ(): number {\n if (this._innerArea) {\n return this._innerArea.min[2];\n }\n if (this._isUntransformedHitBoxesDirty) {\n this._updateUntransformedHitBoxes();\n }\n return this._minZ;\n }\n\n /**\n * @return the internal bottom bound of the object according to its children.\n */\n getInnerAreaMaxZ(): number {\n if (this._innerArea) {\n return this._innerArea.max[2];\n }\n if (this._isUntransformedHitBoxesDirty) {\n this._updateUntransformedHitBoxes();\n }\n return this._maxZ;\n }\n\n /**\n * @return the internal width of the object according to its children.\n */\n getUnscaledDepth(): float {\n if (this._innerArea) {\n return this._innerArea.max[2] - this._innerArea.min[2];\n }\n if (this._isUntransformedHitBoxesDirty) {\n this._updateUntransformedHitBoxes();\n }\n return this._maxZ - this._minZ;\n }\n\n override _updateUntransformedHitBoxes(): void {\n super._updateUntransformedHitBoxes();\n\n let minZ = Number.MAX_VALUE;\n let maxZ = -Number.MAX_VALUE;\n for (const childInstance of this._instanceContainer.getAdhocListOfAllInstances()) {\n if (!childInstance.isIncludedInParentCollisionMask()) {\n continue;\n }\n if (!gdjs.Base3DHandler.is3D(childInstance)) {\n continue;\n }\n minZ = Math.min(minZ, childInstance.getUnrotatedAABBMinZ());\n maxZ = Math.max(maxZ, childInstance.getUnrotatedAABBMaxZ());\n }\n if (minZ === Number.MAX_VALUE) {\n // The unscaled size can't be 0 because setWidth and setHeight wouldn't\n // have any effect.\n minZ = 0;\n maxZ = 1;\n }\n this._minZ = minZ;\n this._maxZ = maxZ;\n }\n\n /**\n * @returns the center Z from the local origin (0;0).\n */\n getUnscaledCenterZ(): float {\n if (this.hasCustomRotationCenter()) {\n return this._customCenterZ;\n }\n if (this._innerArea) {\n return (this._innerArea.min[2] + this._innerArea.max[2]) / 2;\n }\n if (this._isUntransformedHitBoxesDirty) {\n this._updateUntransformedHitBoxes();\n }\n return (this._minZ + this._maxZ) / 2;\n }\n\n /**\n * The center of rotation is defined relatively to the origin (the object\n * position).\n * This avoids the center to move when children push the bounds.\n *\n * When no custom center is defined, it will move\n * to stay at the center of the children bounds.\n *\n * @param x coordinate of the custom center\n * @param y coordinate of the custom center\n */\n setRotationCenter3D(x: float, y: float, z: float) {\n this._customCenterZ = z;\n this.setRotationCenter(x, y);\n }\n\n /**\n * Get the object size on the Z axis (called \"depth\").\n */\n getDepth(): float {\n return this.getUnscaledDepth() * this.getScaleZ();\n }\n\n /**\n * Set the object size on the Z axis (called \"depth\").\n */\n setDepth(depth: float): void {\n const unscaledDepth = this.getUnscaledDepth();\n if (unscaledDepth === 0) {\n return;\n }\n const scaleZ = depth / unscaledDepth;\n if (this._innerArea && this._isInnerAreaFollowingParentSize) {\n this._innerArea.min[2] *= scaleZ;\n this._innerArea.max[2] *= scaleZ;\n } else {\n this.setScaleZ(scaleZ);\n }\n }\n\n /**\n * Change the scale on X, Y and Z axis of the object.\n *\n * @param newScale The new scale (must be greater than 0).\n */\n setScale(newScale: number): void {\n super.setScale(newScale);\n this.setScaleZ(newScale);\n }\n\n /**\n * Change the scale on Z axis of the object (changing its height).\n *\n * @param newScale The new scale (must be greater than 0).\n */\n setScaleZ(newScale: number): void {\n if (this._innerArea && this._isInnerAreaFollowingParentSize) {\n // The scale is always 1;\n return;\n }\n if (newScale < 0) {\n newScale = 0;\n }\n if (newScale === Math.abs(this._scaleZ)) {\n return;\n }\n this._scaleZ = newScale * (this._flippedZ ? -1 : 1);\n this.getRenderer().updateSize();\n }\n\n /**\n * Get the scale of the object (or the geometric average of X, Y and Z scale in case they are different).\n *\n * @return the scale of the object (or the geometric average of X, Y and Z scale in case they are different).\n */\n getScale(): number {\n const scaleX = this.getScaleX();\n const scaleY = this.getScaleY();\n const scaleZ = this.getScaleZ();\n return scaleX === scaleY && scaleX === scaleZ\n ? scaleX\n : Math.pow(scaleX * scaleY * scaleZ, 1 / 3);\n }\n\n /**\n * Get the scale of the object on Z axis.\n *\n * @return the scale of the object on Z axis\n */\n getScaleZ(): float {\n return Math.abs(this._scaleZ);\n }\n\n flipZ(enable: boolean) {\n if (enable === this._flippedZ) {\n return;\n }\n this._flippedZ = enable;\n this.getRenderer().updateSize();\n }\n\n isFlippedZ(): boolean {\n return this._flippedZ;\n }\n }\n}\n"],
|
|
5
|
-
"mappings": "AAAA,GAAU,MAAV,UAAU,EAAV,
|
|
4
|
+
"sourcesContent": ["namespace gdjs {\n type CustomObject3DNetworkSyncDataType = {\n z: float;\n d: float;\n rx: float;\n ry: float;\n ifz: boolean;\n ccz: float;\n };\n\n type CustomObject3DNetworkSyncData = CustomObjectNetworkSyncData &\n CustomObject3DNetworkSyncDataType;\n\n /**\n * Base class for 3D custom objects.\n */\n export class CustomRuntimeObject3D\n extends gdjs.CustomRuntimeObject\n implements gdjs.Base3DHandler\n {\n /**\n * Position on the Z axis.\n */\n private _z: float = 0;\n private _minZ: float = 0;\n private _maxZ: float = 0;\n private _scaleZ: float = 1;\n private _flippedZ: boolean = false;\n /**\n * Euler angle with the `ZYX` order.\n *\n * Note that `_rotationZ` is `angle` from `gdjs.RuntimeObject`.\n */\n private _rotationX: float = 0;\n /**\n * Euler angle with the `ZYX` order.\n *\n * Note that `_rotationZ` is `angle` from `gdjs.RuntimeObject`.\n */\n private _rotationY: float = 0;\n private _customCenterZ: float = 0;\n private static _temporaryVector = new THREE.Vector3();\n\n constructor(\n parent: gdjs.RuntimeInstanceContainer,\n objectData: gdjs.Object3DData & gdjs.CustomObjectConfiguration\n ) {\n super(parent, objectData);\n }\n\n protected override _createRender() {\n const parent = this._runtimeScene;\n return new gdjs.CustomRuntimeObject3DRenderer(\n this,\n this._instanceContainer,\n parent\n );\n }\n\n protected override _reinitializeRenderer(): void {\n this.getRenderer().reinitialize(this, this.getParent());\n }\n\n override getRenderer(): gdjs.CustomRuntimeObject3DRenderer {\n return super.getRenderer() as gdjs.CustomRuntimeObject3DRenderer;\n }\n\n override get3DRendererObject() {\n // It can't be null because Three.js is always loaded\n // when a custom 3D object is used.\n return this.getRenderer().get3DRendererObject()!;\n }\n\n override extraInitializationFromInitialInstance(\n initialInstanceData: InstanceData\n ) {\n super.extraInitializationFromInitialInstance(initialInstanceData);\n if (initialInstanceData.depth !== undefined) {\n this.setDepth(initialInstanceData.depth);\n }\n if (initialInstanceData.flippedX) {\n this.flipX(initialInstanceData.flippedX);\n }\n if (initialInstanceData.flippedY) {\n this.flipY(initialInstanceData.flippedY);\n }\n if (initialInstanceData.flippedZ) {\n this.flipZ(initialInstanceData.flippedZ);\n }\n }\n\n getNetworkSyncData(\n syncOptions: GetNetworkSyncDataOptions\n ): CustomObject3DNetworkSyncData {\n return {\n ...super.getNetworkSyncData(syncOptions),\n z: this.getZ(),\n d: this.getDepth(),\n rx: this.getRotationX(),\n ry: this.getRotationY(),\n ifz: this.isFlippedZ(),\n ccz: this._customCenterZ,\n };\n }\n\n updateFromNetworkSyncData(\n networkSyncData: CustomObject3DNetworkSyncData,\n options: UpdateFromNetworkSyncDataOptions\n ): void {\n super.updateFromNetworkSyncData(networkSyncData, options);\n if (networkSyncData.z !== undefined) this.setZ(networkSyncData.z);\n if (networkSyncData.d !== undefined) this.setDepth(networkSyncData.d);\n if (networkSyncData.rx !== undefined)\n this.setRotationX(networkSyncData.rx);\n if (networkSyncData.ry !== undefined)\n this.setRotationY(networkSyncData.ry);\n if (networkSyncData.ifz !== undefined) this.flipZ(networkSyncData.ifz);\n if (networkSyncData.ccz !== undefined)\n this._customCenterZ = networkSyncData.ccz;\n }\n\n /**\n * Set the object position on the Z axis.\n */\n setZ(z: float): void {\n if (z === this._z) return;\n this._z = z;\n this.getRenderer().updatePosition();\n }\n\n /**\n * Get the object position on the Z axis.\n */\n getZ(): float {\n return this._z;\n }\n\n /**\n * Get the Z position of the rendered object.\n *\n * For most objects, this will returns the same value as getZ(). But if the\n * object has an origin that is not the same as the point (0,0,0) of the\n * object displayed, getDrawableZ will differ.\n *\n * @return The Z position of the rendered object.\n */\n getDrawableZ(): float {\n let minZ = 0;\n if (this._innerArea) {\n minZ = this._innerArea.min[2];\n } else {\n if (this._isUntransformedHitBoxesDirty) {\n this._updateUntransformedHitBoxes();\n }\n minZ = this._minZ;\n }\n const absScaleZ = this.getScaleZ();\n if (!this._flippedZ) {\n return this._z + minZ * absScaleZ;\n } else {\n return (\n this._z +\n (-minZ - this.getUnscaledDepth() + 2 * this.getUnscaledCenterZ()) *\n absScaleZ\n );\n }\n }\n\n /**\n * Return the Z position of the object center, **relative to the object Z\n * position** (`getDrawableX`).\n *\n * Use `getCenterZInScene` to get the position of the center in the scene.\n *\n * @return the Z position of the object center, relative to\n * `getDrawableZ()`.\n */\n getCenterZ(): float {\n return this.getDepth() / 2;\n }\n\n getCenterZInScene(): float {\n return this.getDrawableZ() + this.getCenterZ();\n }\n\n setCenterZInScene(z: float): void {\n this.setZ(z + this._z - (this.getDrawableZ() + this.getCenterZ()));\n }\n\n /**\n * Return the bottom Z of the object.\n * Rotations around X and Y are not taken into account.\n */\n getUnrotatedAABBMinZ(): number {\n return this.getDrawableZ();\n }\n\n /**\n * Return the top Z of the object.\n * Rotations around X and Y are not taken into account.\n */\n getUnrotatedAABBMaxZ(): number {\n return this.getDrawableZ() + this.getDepth();\n }\n\n /**\n * Set the object rotation on the X axis.\n *\n * This is an Euler angle. Objects use the `ZYX` order.\n */\n setRotationX(angle: float): void {\n this._rotationX = angle;\n this.getRenderer().updateRotation();\n }\n\n /**\n * Set the object rotation on the Y axis.\n *\n * This is an Euler angle. Objects use the `ZYX` order.\n */\n setRotationY(angle: float): void {\n this._rotationY = angle;\n this.getRenderer().updateRotation();\n }\n\n /**\n * Get the object rotation on the X axis.\n *\n * This is an Euler angle. Objects use the `ZYX` order.\n */\n getRotationX(): float {\n return this._rotationX;\n }\n\n /**\n * Get the object rotation on the Y axis.\n *\n * This is an Euler angle. Objects use the `ZYX` order.\n */\n getRotationY(): float {\n return this._rotationY;\n }\n\n /**\n * Turn the object around the scene x axis at its center.\n * @param deltaAngle the rotation angle\n */\n turnAroundX(deltaAngle: float): void {\n const axisX = gdjs.CustomRuntimeObject3D._temporaryVector;\n axisX.set(1, 0, 0);\n\n const mesh = this.get3DRendererObject();\n mesh.rotateOnWorldAxis(axisX, gdjs.toRad(deltaAngle));\n this._rotationX = gdjs.toDegrees(mesh.rotation.x);\n this._rotationY = gdjs.toDegrees(mesh.rotation.y);\n this.setAngle(gdjs.toDegrees(mesh.rotation.z));\n }\n\n /**\n * Turn the object around the scene y axis at its center.\n * @param deltaAngle the rotation angle\n */\n turnAroundY(deltaAngle: float): void {\n const axisY = gdjs.CustomRuntimeObject3D._temporaryVector;\n axisY.set(0, 1, 0);\n\n const mesh = this.get3DRendererObject();\n mesh.rotateOnWorldAxis(axisY, gdjs.toRad(deltaAngle));\n this._rotationX = gdjs.toDegrees(mesh.rotation.x);\n this._rotationY = gdjs.toDegrees(mesh.rotation.y);\n this.setAngle(gdjs.toDegrees(mesh.rotation.z));\n }\n\n /**\n * Turn the object around the scene z axis at its center.\n * @param deltaAngle the rotation angle\n */\n turnAroundZ(deltaAngle: float): void {\n const axisZ = gdjs.CustomRuntimeObject3D._temporaryVector;\n axisZ.set(0, 0, 1);\n\n const mesh = this.get3DRendererObject();\n mesh.rotateOnWorldAxis(axisZ, gdjs.toRad(deltaAngle));\n this._rotationX = gdjs.toDegrees(mesh.rotation.x);\n this._rotationY = gdjs.toDegrees(mesh.rotation.y);\n this.setAngle(gdjs.toDegrees(mesh.rotation.z));\n }\n\n /**\n * @return the internal top bound of the object according to its children.\n */\n getInnerAreaMinZ(): number {\n if (this._innerArea) {\n return this._innerArea.min[2];\n }\n if (this._isUntransformedHitBoxesDirty) {\n this._updateUntransformedHitBoxes();\n }\n return this._minZ;\n }\n\n /**\n * @return the internal bottom bound of the object according to its children.\n */\n getInnerAreaMaxZ(): number {\n if (this._innerArea) {\n return this._innerArea.max[2];\n }\n if (this._isUntransformedHitBoxesDirty) {\n this._updateUntransformedHitBoxes();\n }\n return this._maxZ;\n }\n\n /**\n * @return the internal width of the object according to its children.\n */\n getUnscaledDepth(): float {\n if (this._innerArea) {\n return this._innerArea.max[2] - this._innerArea.min[2];\n }\n if (this._isUntransformedHitBoxesDirty) {\n this._updateUntransformedHitBoxes();\n }\n return this._maxZ - this._minZ;\n }\n\n override _updateUntransformedHitBoxes(): void {\n super._updateUntransformedHitBoxes();\n\n let minZ = Number.MAX_VALUE;\n let maxZ = -Number.MAX_VALUE;\n for (const childInstance of this._instanceContainer.getAdhocListOfAllInstances()) {\n if (!childInstance.isIncludedInParentCollisionMask()) {\n continue;\n }\n if (!gdjs.Base3DHandler.is3D(childInstance)) {\n continue;\n }\n minZ = Math.min(minZ, childInstance.getUnrotatedAABBMinZ());\n maxZ = Math.max(maxZ, childInstance.getUnrotatedAABBMaxZ());\n }\n if (minZ === Number.MAX_VALUE) {\n // The unscaled size can't be 0 because setWidth and setHeight wouldn't\n // have any effect.\n minZ = 0;\n maxZ = 1;\n }\n this._minZ = minZ;\n this._maxZ = maxZ;\n }\n\n /**\n * @returns the center Z from the local origin (0;0).\n */\n getUnscaledCenterZ(): float {\n if (this.hasCustomRotationCenter()) {\n return this._customCenterZ;\n }\n if (this._innerArea) {\n return (this._innerArea.min[2] + this._innerArea.max[2]) / 2;\n }\n if (this._isUntransformedHitBoxesDirty) {\n this._updateUntransformedHitBoxes();\n }\n return (this._minZ + this._maxZ) / 2;\n }\n\n /**\n * The center of rotation is defined relatively to the origin (the object\n * position).\n * This avoids the center to move when children push the bounds.\n *\n * When no custom center is defined, it will move\n * to stay at the center of the children bounds.\n *\n * @param x coordinate of the custom center\n * @param y coordinate of the custom center\n */\n setRotationCenter3D(x: float, y: float, z: float) {\n this._customCenterZ = z;\n this.setRotationCenter(x, y);\n }\n\n /**\n * Get the object size on the Z axis (called \"depth\").\n */\n getDepth(): float {\n return this.getUnscaledDepth() * this.getScaleZ();\n }\n\n /**\n * Set the object size on the Z axis (called \"depth\").\n */\n setDepth(depth: float): void {\n const unscaledDepth = this.getUnscaledDepth();\n if (unscaledDepth === 0) {\n return;\n }\n const scaleZ = depth / unscaledDepth;\n if (this._innerArea && this._isInnerAreaFollowingParentSize) {\n this._innerArea.min[2] *= scaleZ;\n this._innerArea.max[2] *= scaleZ;\n } else {\n this.setScaleZ(scaleZ);\n }\n }\n\n /**\n * Change the scale on X, Y and Z axis of the object.\n *\n * @param newScale The new scale (must be greater than 0).\n */\n setScale(newScale: number): void {\n super.setScale(newScale);\n this.setScaleZ(newScale);\n }\n\n /**\n * Change the scale on Z axis of the object (changing its height).\n *\n * @param newScale The new scale (must be greater than 0).\n */\n setScaleZ(newScale: number): void {\n if (this._innerArea && this._isInnerAreaFollowingParentSize) {\n // The scale is always 1;\n return;\n }\n if (newScale < 0) {\n newScale = 0;\n }\n if (newScale === Math.abs(this._scaleZ)) {\n return;\n }\n this._scaleZ = newScale * (this._flippedZ ? -1 : 1);\n this.getRenderer().updateSize();\n }\n\n /**\n * Get the scale of the object (or the geometric average of X, Y and Z scale in case they are different).\n *\n * @return the scale of the object (or the geometric average of X, Y and Z scale in case they are different).\n */\n getScale(): number {\n const scaleX = this.getScaleX();\n const scaleY = this.getScaleY();\n const scaleZ = this.getScaleZ();\n return scaleX === scaleY && scaleX === scaleZ\n ? scaleX\n : Math.pow(scaleX * scaleY * scaleZ, 1 / 3);\n }\n\n /**\n * Get the scale of the object on Z axis.\n *\n * @return the scale of the object on Z axis\n */\n getScaleZ(): float {\n return Math.abs(this._scaleZ);\n }\n\n flipZ(enable: boolean) {\n if (enable === this._flippedZ) {\n return;\n }\n this._flippedZ = enable;\n this.getRenderer().updateSize();\n }\n\n isFlippedZ(): boolean {\n return this._flippedZ;\n }\n }\n}\n"],
|
|
5
|
+
"mappings": "AAAA,GAAU,MAAV,UAAU,EAAV,CAgBS,eACG,GAAK,mBAEf,CAwBE,YACE,EACA,EACA,CACA,MAAM,EAAQ,GAxBR,QAAY,EACZ,WAAe,EACf,WAAe,EACf,aAAiB,EACjB,eAAqB,GAMrB,gBAAoB,EAMpB,gBAAoB,EACpB,oBAAwB,EAUb,eAAgB,CACjC,KAAM,GAAS,KAAK,cACpB,MAAO,IAAI,GAAK,8BACd,KACA,KAAK,mBACL,GAIe,uBAA8B,CAC/C,KAAK,cAAc,aAAa,KAAM,KAAK,aAGpC,aAAkD,CACzD,MAAO,OAAM,cAGN,qBAAsB,CAG7B,MAAO,MAAK,cAAc,sBAGnB,uCACP,EACA,CACA,MAAM,uCAAuC,GACzC,EAAoB,QAAU,QAChC,KAAK,SAAS,EAAoB,OAEhC,EAAoB,UACtB,KAAK,MAAM,EAAoB,UAE7B,EAAoB,UACtB,KAAK,MAAM,EAAoB,UAE7B,EAAoB,UACtB,KAAK,MAAM,EAAoB,UA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,CACrB,AAAI,IAAW,KAAK,WAGpB,MAAK,UAAY,EACjB,KAAK,cAAc,cAGrB,YAAsB,CACpB,MAAO,MAAK,WA7aC,AAzBV,EAyBU,iBAAmB,GAAI,OAAM,QAzBvC,EAAM,0BAhBL",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1901,6 +1901,11 @@ module.exports = {
|
|
|
1901
1901
|
.getOrCreate('density')
|
|
1902
1902
|
.setValue('0.0012')
|
|
1903
1903
|
.setLabel(_('Density'))
|
|
1904
|
+
.setDescription(
|
|
1905
|
+
_(
|
|
1906
|
+
'Density of the fog. Usual values are between 0.0005 (far away) and 0.005 (very thick fog).'
|
|
1907
|
+
)
|
|
1908
|
+
)
|
|
1904
1909
|
.setType('number');
|
|
1905
1910
|
}
|
|
1906
1911
|
{
|
|
@@ -2063,6 +2068,48 @@ module.exports = {
|
|
|
2063
2068
|
.setType('number')
|
|
2064
2069
|
.setGroup(_('Orientation'));
|
|
2065
2070
|
}
|
|
2071
|
+
{
|
|
2072
|
+
const effect = extension
|
|
2073
|
+
.addEffect('Skybox')
|
|
2074
|
+
.setFullName(_('Skybox'))
|
|
2075
|
+
.setDescription(
|
|
2076
|
+
_('Display a background on a cube surrounding the scene.')
|
|
2077
|
+
)
|
|
2078
|
+
.markAsNotWorkingForObjects()
|
|
2079
|
+
.markAsOnlyWorkingFor3D()
|
|
2080
|
+
.addIncludeFile('Extensions/3D/Skybox.js');
|
|
2081
|
+
const properties = effect.getProperties();
|
|
2082
|
+
properties
|
|
2083
|
+
.getOrCreate('rightFaceResourceName')
|
|
2084
|
+
.setType('resource')
|
|
2085
|
+
.addExtraInfo('image')
|
|
2086
|
+
.setLabel(_('Right face (X+)'));
|
|
2087
|
+
properties
|
|
2088
|
+
.getOrCreate('leftFaceResourceName')
|
|
2089
|
+
.setType('resource')
|
|
2090
|
+
.addExtraInfo('image')
|
|
2091
|
+
.setLabel(_('Left face (X-)'));
|
|
2092
|
+
properties
|
|
2093
|
+
.getOrCreate('bottomFaceResourceName')
|
|
2094
|
+
.setType('resource')
|
|
2095
|
+
.addExtraInfo('image')
|
|
2096
|
+
.setLabel(_('Bottom face (Y+)'));
|
|
2097
|
+
properties
|
|
2098
|
+
.getOrCreate('topFaceResourceName')
|
|
2099
|
+
.setType('resource')
|
|
2100
|
+
.addExtraInfo('image')
|
|
2101
|
+
.setLabel(_('Top face (Y-)'));
|
|
2102
|
+
properties
|
|
2103
|
+
.getOrCreate('frontFaceResourceName')
|
|
2104
|
+
.setType('resource')
|
|
2105
|
+
.addExtraInfo('image')
|
|
2106
|
+
.setLabel(_('Front face (Z+)'));
|
|
2107
|
+
properties
|
|
2108
|
+
.getOrCreate('backFaceResourceName')
|
|
2109
|
+
.setType('resource')
|
|
2110
|
+
.addExtraInfo('image')
|
|
2111
|
+
.setLabel(_('Back face (Z-)'));
|
|
2112
|
+
}
|
|
2066
2113
|
{
|
|
2067
2114
|
const effect = extension
|
|
2068
2115
|
.addEffect('HueAndSaturation')
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var gdjs;(function(
|
|
1
|
+
var gdjs;(function(n){const o=r=>{switch(r){case"ModelOrigin":return null;case"ObjectCenter":return[.5,.5,.5];case"BottomCenterZ":return[.5,.5,0];case"BottomCenterY":return[.5,1,.5];case"TopLeft":return[0,0,0];default:return null}};class a extends n.RuntimeObject3D{constructor(e,t){super(e,t);this._materialType=n.Model3DRuntimeObject.MaterialType.Basic;this._currentAnimationIndex=0;this._animationSpeedScale=1;this._animationPaused=!1;this._crossfadeDuration=0;this._isCastingShadow=!0;this._isReceivingShadow=!0;this._modelResourceName=t.content.modelResourceName,this._animations=t.content.animations,this._originPoint=o(t.content.originLocation),this._centerPoint=o(t.content.centerLocation),this._renderer=new n.Model3DRuntimeObjectRenderer(this,e),this._materialType=this._convertMaterialType(t.content.materialType),this.setIsCastingShadow(t.content.isCastingShadow),this.setIsReceivingShadow(t.content.isReceivingShadow),this.onModelChanged(t),this._crossfadeDuration=t.content.crossfadeDuration||0,this.onCreated()}onModelChanged(e){this._updateModel(e),this._animations.length>0&&this._renderer.playAnimation(this._animations[0].source,this._animations[0].loop)}updateOriginalDimensionsFromObjectData(e,t){}updateFromObjectData(e,t){return super.updateFromObjectData(e,t),e.content.materialType!==t.content.materialType&&(this._materialType=this._convertMaterialType(t.content.materialType)),e.content.modelResourceName!==t.content.modelResourceName?this._reloadModel(t):(e.content.width!==t.content.width||e.content.height!==t.content.height||e.content.depth!==t.content.depth||e.content.rotationX!==t.content.rotationX||e.content.rotationY!==t.content.rotationY||e.content.rotationZ!==t.content.rotationZ||e.content.keepAspectRatio!==t.content.keepAspectRatio||e.content.materialType!==t.content.materialType||e.content.centerLocation!==t.content.centerLocation)&&(this._centerPoint=o(t.content.centerLocation),this._updateModel(t)),e.content.originLocation!==t.content.originLocation&&(this._originPoint=o(t.content.originLocation),this._renderer.updatePosition()),e.content.isCastingShadow!==t.content.isCastingShadow&&this.setIsCastingShadow(t.content.isCastingShadow),e.content.isReceivingShadow!==t.content.isReceivingShadow&&this.setIsReceivingShadow(t.content.isReceivingShadow),!0}getNetworkSyncData(e){return{...super.getNetworkSyncData(e),mt:this._materialType,op:this._originPoint,cp:this._centerPoint,anis:this._animations,ai:this._currentAnimationIndex,ass:this._animationSpeedScale,aet:this.getAnimationElapsedTime(),ap:this._animationPaused,cfd:this._crossfadeDuration}}updateFromNetworkSyncData(e,t){super.updateFromNetworkSyncData(e,t),e.mt!==void 0&&(this._materialType=e.mt),e.op!==void 0&&(this._originPoint=e.op),e.cp!==void 0&&(this._centerPoint=e.cp),e.anis!==void 0&&(this._animations=e.anis),e.ass!==void 0&&this.setAnimationSpeedScale(e.ass),e.ai!==void 0&&this.setAnimationIndex(e.ai),e.aet!==void 0&&this.setAnimationElapsedTime(e.aet),e.ap!==void 0&&e.ap!==this.isAnimationPaused()&&(e.ap?this.pauseAnimation():this.resumeAnimation()),e.cfd!==void 0&&(this._crossfadeDuration=e.cfd)}_reloadModel(e){this._modelResourceName=e.content.modelResourceName,this._renderer._reloadModel(this,this._runtimeScene),this.onModelChanged(e)}_updateModel(e){const t=e.content.rotationX||0,s=e.content.rotationY||0,d=e.content.rotationZ||0,i=e.content.width||100,h=e.content.height||100,m=e.content.depth||100,c=e.content.keepAspectRatio;this._renderer._updateModel(t,s,d,i,h,m,c)}getRenderer(){return this._renderer}_convertMaterialType(e){return e==="KeepOriginal"?n.Model3DRuntimeObject.MaterialType.KeepOriginal:e==="StandardWithoutMetalness"?n.Model3DRuntimeObject.MaterialType.StandardWithoutMetalness:n.Model3DRuntimeObject.MaterialType.Basic}update(e){const t=this.getElapsedTime()/1e3;this._renderer.updateAnimation(t)}getAnimationIndex(){return this._currentAnimationIndex}setAnimationIndex(e){if(e=e|0,e<this._animations.length&&this._currentAnimationIndex!==e&&e>=0){const t=this._animations[e];this._currentAnimationIndex=e,this._renderer.playAnimation(t.source,t.loop),this._animationPaused&&this._renderer.pauseAnimation()}}getAnimationName(){return this._currentAnimationIndex>=this._animations.length?"":this._animations[this._currentAnimationIndex].name}setAnimationName(e){if(!e)return;const t=this._animations.findIndex(s=>s.name===e);t>=0&&this.setAnimationIndex(t)}isCurrentAnimationName(e){return this.getAnimationName()===e}hasAnimationEnded(){return this._renderer.hasAnimationEnded()}setIsCastingShadow(e){this._isCastingShadow=e,this._renderer._updateShadow()}setIsReceivingShadow(e){this._isReceivingShadow=e,this._renderer._updateShadow()}setCrossfadeDuration(e){this._crossfadeDuration!==e&&(this._crossfadeDuration=e)}isAnimationPaused(){return this._animationPaused}pauseAnimation(){this._animationPaused=!0,this._renderer.pauseAnimation()}resumeAnimation(){this._animationPaused=!1,this._renderer.resumeAnimation()}getAnimationSpeedScale(){return this._animationSpeedScale}setAnimationSpeedScale(e){this._animationSpeedScale=e,this._renderer.setAnimationTimeScale(e)}getAnimationElapsedTime(){return this._renderer.getAnimationElapsedTime()}setAnimationElapsedTime(e){this._renderer.setAnimationElapsedTime(e),this._animationPaused||this._renderer.resumeAnimation()}getAnimationDuration(){return this._renderer.getAnimationDuration(this._animations[this._currentAnimationIndex].source)}getCenterX(){const e=this._renderer.getCenterPoint();return this.getWidth()*e[0]}getCenterY(){const e=this._renderer.getCenterPoint();return this.getHeight()*e[1]}getCenterZ(){const e=this._renderer.getCenterPoint();return this.getDepth()*e[2]}getDrawableX(){const e=this._renderer.getOriginPoint();return this.getX()-this.getWidth()*e[0]}getDrawableY(){const e=this._renderer.getOriginPoint();return this.getY()-this.getHeight()*e[1]}getDrawableZ(){const e=this._renderer.getOriginPoint();return this.getZ()-this.getDepth()*e[2]}}n.Model3DRuntimeObject=a,function(e){let r;(function(i){i[i.Basic=0]="Basic",i[i.StandardWithoutMetalness=1]="StandardWithoutMetalness",i[i.KeepOriginal=2]="KeepOriginal"})(r=e.MaterialType||(e.MaterialType={}))}(a=n.Model3DRuntimeObject||(n.Model3DRuntimeObject={})),n.registerObject("Scene3D::Model3DObject",n.Model3DRuntimeObject)})(gdjs||(gdjs={}));
|
|
2
2
|
//# sourceMappingURL=Model3DRuntimeObject.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../GDevelop/Extensions/3D/Model3DRuntimeObject.ts"],
|
|
4
|
-
"sourcesContent": ["namespace gdjs {\n type Model3DAnimation = { name: string; source: string; loop: boolean };\n\n type Model3DObjectNetworkSyncDataType = {\n mt: number;\n op: FloatPoint3D | null;\n cp: FloatPoint3D | null;\n anis: Model3DAnimation[];\n ai: integer;\n ass: float;\n ap: boolean;\n cfd: float;\n };\n\n type Model3DObjectNetworkSyncData = Object3DNetworkSyncData &\n Model3DObjectNetworkSyncDataType;\n\n /** Base parameters for {@link gdjs.Cube3DRuntimeObject} */\n export interface Model3DObjectData extends Object3DData {\n /** The base parameters of the Model3D object */\n content: Object3DDataContent & {\n modelResourceName: string;\n rotationX: number;\n rotationY: number;\n rotationZ: number;\n keepAspectRatio: boolean;\n materialType: 'Basic' | 'StandardWithoutMetalness' | 'KeepOriginal';\n originLocation:\n | 'ModelOrigin'\n | 'ObjectCenter'\n | 'BottomCenterZ'\n | 'BottomCenterY'\n | 'TopLeft';\n centerLocation:\n | 'ModelOrigin'\n | 'ObjectCenter'\n | 'BottomCenterZ'\n | 'BottomCenterY';\n animations: Model3DAnimation[];\n crossfadeDuration: float;\n isCastingShadow: boolean;\n isReceivingShadow: boolean;\n };\n }\n\n type FloatPoint3D = [float, float, float];\n\n const getPointForLocation = (location: string): FloatPoint3D | null => {\n switch (location) {\n case 'ModelOrigin':\n return null;\n case 'ObjectCenter':\n return [0.5, 0.5, 0.5];\n case 'BottomCenterZ':\n return [0.5, 0.5, 0];\n case 'BottomCenterY':\n return [0.5, 1, 0.5];\n case 'TopLeft':\n return [0, 0, 0];\n default:\n return null;\n }\n };\n\n /**\n * A 3D object which displays a 3D model.\n */\n export class Model3DRuntimeObject\n extends gdjs.RuntimeObject3D\n implements gdjs.Animatable\n {\n _renderer: gdjs.Model3DRuntimeObjectRenderer;\n\n _modelResourceName: string;\n _materialType: gdjs.Model3DRuntimeObject.MaterialType =\n gdjs.Model3DRuntimeObject.MaterialType.Basic;\n\n /**\n * The local point of the model that will be at the object position.\n *\n * Coordinates are between 0 and 1.\n *\n * Its value is `null` when the point is configured to `\"ModelOrigin\"`\n * because the model origin needs to be evaluated according to the object\n * configuration.\n * @see gdjs.Model3DRuntimeObject3DRenderer.getOriginPoint\n */\n _originPoint: FloatPoint3D | null;\n /**\n * The local point of the model that is used as rotation center.\n *\n * Coordinates are between 0 and 1.\n *\n * Its value is `null` when the point is configured to `\"ModelOrigin\"`\n * because the model origin needs to be evaluated according to the object\n * configuration.\n * @see gdjs.Model3DRuntimeObject3DRenderer.getCenterPoint\n */\n _centerPoint: FloatPoint3D | null;\n\n _animations: Model3DAnimation[];\n _currentAnimationIndex: integer = 0;\n _animationSpeedScale: float = 1;\n _animationPaused: boolean = false;\n _crossfadeDuration: float = 0;\n _isCastingShadow: boolean = true;\n _isReceivingShadow: boolean = true;\n\n constructor(\n instanceContainer: gdjs.RuntimeInstanceContainer,\n objectData: Model3DObjectData\n ) {\n super(instanceContainer, objectData);\n this._modelResourceName = objectData.content.modelResourceName;\n this._animations = objectData.content.animations;\n this._originPoint = getPointForLocation(\n objectData.content.originLocation\n );\n this._centerPoint = getPointForLocation(\n objectData.content.centerLocation\n );\n this._renderer = new gdjs.Model3DRuntimeObjectRenderer(\n this,\n instanceContainer\n );\n this._materialType = this._convertMaterialType(\n objectData.content.materialType\n );\n\n this.setIsCastingShadow(objectData.content.isCastingShadow);\n this.setIsReceivingShadow(objectData.content.isReceivingShadow);\n this.onModelChanged(objectData);\n\n this._crossfadeDuration = objectData.content.crossfadeDuration || 0;\n\n // *ALWAYS* call `this.onCreated()` at the very end of your object constructor.\n this.onCreated();\n }\n\n /**\n * To be called after the renderer loaded a Model resource:\n * - After the renderer was instantiated\n * - After reloading the model\n */\n private onModelChanged(objectData) {\n this._updateModel(objectData);\n if (this._animations.length > 0) {\n this._renderer.playAnimation(\n this._animations[0].source,\n this._animations[0].loop\n );\n }\n }\n\n updateFromObjectData(\n oldObjectData: Model3DObjectData,\n newObjectData: Model3DObjectData\n ): boolean {\n super.updateFromObjectData(oldObjectData, newObjectData);\n\n if (\n oldObjectData.content.materialType !==\n newObjectData.content.materialType\n ) {\n this._materialType = this._convertMaterialType(\n newObjectData.content.materialType\n );\n }\n if (\n oldObjectData.content.modelResourceName !==\n newObjectData.content.modelResourceName\n ) {\n this._reloadModel(newObjectData);\n } else if (\n oldObjectData.content.width !== newObjectData.content.width ||\n oldObjectData.content.height !== newObjectData.content.height ||\n oldObjectData.content.depth !== newObjectData.content.depth ||\n oldObjectData.content.rotationX !== newObjectData.content.rotationX ||\n oldObjectData.content.rotationY !== newObjectData.content.rotationY ||\n oldObjectData.content.rotationZ !== newObjectData.content.rotationZ ||\n oldObjectData.content.keepAspectRatio !==\n newObjectData.content.keepAspectRatio ||\n oldObjectData.content.materialType !==\n newObjectData.content.materialType\n ) {\n this._updateModel(newObjectData);\n }\n if (\n oldObjectData.content.originLocation !==\n newObjectData.content.originLocation\n ) {\n this._originPoint = getPointForLocation(\n newObjectData.content.originLocation\n );\n }\n if (\n oldObjectData.content.centerLocation !==\n newObjectData.content.centerLocation\n ) {\n this._centerPoint = getPointForLocation(\n newObjectData.content.centerLocation\n );\n }\n if (\n oldObjectData.content.isCastingShadow !==\n newObjectData.content.isCastingShadow\n ) {\n this.setIsCastingShadow(newObjectData.content.isCastingShadow);\n }\n if (\n oldObjectData.content.isReceivingShadow !==\n newObjectData.content.isReceivingShadow\n ) {\n this.setIsReceivingShadow(newObjectData.content.isReceivingShadow);\n }\n return true;\n }\n\n getNetworkSyncData(): Model3DObjectNetworkSyncData {\n return {\n ...super.getNetworkSyncData(),\n mt: this._materialType,\n op: this._originPoint,\n cp: this._centerPoint,\n anis: this._animations,\n ai: this._currentAnimationIndex,\n ass: this._animationSpeedScale,\n ap: this._animationPaused,\n cfd: this._crossfadeDuration,\n };\n }\n\n updateFromNetworkSyncData(\n networkSyncData: Model3DObjectNetworkSyncData\n ): void {\n super.updateFromNetworkSyncData(networkSyncData);\n\n if (networkSyncData.mt !== undefined) {\n this._materialType = networkSyncData.mt;\n }\n if (networkSyncData.op !== undefined) {\n this._originPoint = networkSyncData.op;\n }\n if (networkSyncData.cp !== undefined) {\n this._centerPoint = networkSyncData.cp;\n }\n if (networkSyncData.anis !== undefined) {\n this._animations = networkSyncData.anis;\n }\n if (networkSyncData.ai !== undefined) {\n this.setAnimationIndex(networkSyncData.ai);\n }\n if (networkSyncData.ass !== undefined) {\n this.setAnimationSpeedScale(networkSyncData.ass);\n }\n if (networkSyncData.ap !== undefined) {\n if (networkSyncData.ap !== this.isAnimationPaused()) {\n networkSyncData.ap ? this.pauseAnimation() : this.resumeAnimation();\n }\n }\n if (networkSyncData.cfd !== undefined) {\n this._crossfadeDuration = networkSyncData.cfd;\n }\n }\n\n _reloadModel(objectData: Model3DObjectData) {\n this._modelResourceName = objectData.content.modelResourceName;\n this._renderer._reloadModel(this, this._runtimeScene);\n this.onModelChanged(objectData);\n }\n\n _updateModel(objectData: Model3DObjectData) {\n const rotationX = objectData.content.rotationX || 0;\n const rotationY = objectData.content.rotationY || 0;\n const rotationZ = objectData.content.rotationZ || 0;\n const keepAspectRatio = objectData.content.keepAspectRatio;\n this._renderer._updateModel(\n rotationX,\n rotationY,\n rotationZ,\n this._getOriginalWidth(),\n this._getOriginalHeight(),\n this._getOriginalDepth(),\n keepAspectRatio\n );\n }\n\n getRenderer(): RuntimeObject3DRenderer {\n return this._renderer;\n }\n\n _convertMaterialType(\n materialTypeString: string\n ): gdjs.Model3DRuntimeObject.MaterialType {\n if (materialTypeString === 'KeepOriginal') {\n return gdjs.Model3DRuntimeObject.MaterialType.KeepOriginal;\n } else if (materialTypeString === 'StandardWithoutMetalness') {\n return gdjs.Model3DRuntimeObject.MaterialType.StandardWithoutMetalness;\n } else {\n return gdjs.Model3DRuntimeObject.MaterialType.Basic;\n }\n }\n\n update(instanceContainer: gdjs.RuntimeInstanceContainer): void {\n const elapsedTime = this.getElapsedTime() / 1000;\n this._renderer.updateAnimation(elapsedTime);\n }\n\n /**\n * Get the index of the animation being played.\n * @return The index of the new animation being played\n */\n getAnimationIndex(): number {\n return this._currentAnimationIndex;\n }\n\n /**\n * Change the animation being played.\n * @param animationIndex The index of the new animation to be played\n */\n setAnimationIndex(animationIndex: number): void {\n animationIndex = animationIndex | 0;\n if (\n animationIndex < this._animations.length &&\n this._currentAnimationIndex !== animationIndex &&\n animationIndex >= 0\n ) {\n const animation = this._animations[animationIndex];\n this._currentAnimationIndex = animationIndex;\n this._renderer.playAnimation(animation.source, animation.loop);\n if (this._animationPaused) {\n this._renderer.pauseAnimation();\n }\n }\n }\n\n /**\n * Get the name of the animation being played.\n * @return The name of the new animation being played\n */\n getAnimationName(): string {\n if (this._currentAnimationIndex >= this._animations.length) {\n return '';\n }\n return this._animations[this._currentAnimationIndex].name;\n }\n\n /**\n * Change the animation being played.\n * @param newAnimationName The name of the new animation to be played\n */\n setAnimationName(newAnimationName: string): void {\n if (!newAnimationName) {\n return;\n }\n const animationIndex = this._animations.findIndex(\n (animation) => animation.name === newAnimationName\n );\n if (animationIndex >= 0) {\n this.setAnimationIndex(animationIndex);\n }\n }\n\n isCurrentAnimationName(name: string): boolean {\n return this.getAnimationName() === name;\n }\n\n /**\n * Return true if animation has ended.\n * The animation had ended if:\n * - it's not configured as a loop;\n * - the current frame is the last frame;\n * - the last frame has been displayed long enough.\n */\n hasAnimationEnded(): boolean {\n return this._renderer.hasAnimationEnded();\n }\n\n setIsCastingShadow(value: boolean): void {\n this._isCastingShadow = value;\n this._renderer._updateShadow();\n }\n\n setIsReceivingShadow(value: boolean): void {\n this._isReceivingShadow = value;\n this._renderer._updateShadow();\n }\n\n setCrossfadeDuration(duration: number): void {\n if (this._crossfadeDuration === duration) return;\n this._crossfadeDuration = duration;\n }\n\n isAnimationPaused() {\n return this._animationPaused;\n }\n\n pauseAnimation() {\n this._animationPaused = true;\n this._renderer.pauseAnimation();\n }\n\n resumeAnimation() {\n this._animationPaused = false;\n this._renderer.resumeAnimation();\n }\n\n getAnimationSpeedScale() {\n return this._animationSpeedScale;\n }\n\n setAnimationSpeedScale(ratio: float): void {\n this._animationSpeedScale = ratio;\n this._renderer.setAnimationTimeScale(ratio);\n }\n\n getAnimationElapsedTime(): float {\n return this._renderer.getAnimationElapsedTime();\n }\n\n setAnimationElapsedTime(time: float): void {\n this._renderer.setAnimationElapsedTime(time);\n if (!this._animationPaused) {\n this._renderer.resumeAnimation();\n }\n }\n\n getAnimationDuration(): float {\n return this._renderer.getAnimationDuration(\n this._animations[this._currentAnimationIndex].source\n );\n }\n\n getCenterX(): float {\n const centerPoint = this._renderer.getCenterPoint();\n return this.getWidth() * centerPoint[0];\n }\n\n getCenterY(): float {\n const centerPoint = this._renderer.getCenterPoint();\n return this.getHeight() * centerPoint[1];\n }\n\n getCenterZ(): float {\n const centerPoint = this._renderer.getCenterPoint();\n return this.getDepth() * centerPoint[2];\n }\n\n getDrawableX(): float {\n const originPoint = this._renderer.getOriginPoint();\n return this.getX() - this.getWidth() * originPoint[0];\n }\n\n getDrawableY(): float {\n const originPoint = this._renderer.getOriginPoint();\n return this.getY() - this.getHeight() * originPoint[1];\n }\n\n getDrawableZ(): float {\n const originPoint = this._renderer.getOriginPoint();\n return this.getZ() - this.getDepth() * originPoint[2];\n }\n }\n\n export namespace Model3DRuntimeObject {\n export enum MaterialType {\n Basic,\n StandardWithoutMetalness,\n KeepOriginal,\n }\n }\n gdjs.registerObject('Scene3D::Model3DObject', gdjs.Model3DRuntimeObject);\n}\n"],
|
|
5
|
-
"mappings": "AAAA,GAAU,MAAV,UAAU,EAAV,
|
|
4
|
+
"sourcesContent": ["namespace gdjs {\n type Model3DAnimation = { name: string; source: string; loop: boolean };\n\n type Model3DObjectNetworkSyncDataType = {\n mt: number;\n op: FloatPoint3D | null;\n cp: FloatPoint3D | null;\n anis: Model3DAnimation[];\n ai: integer;\n ass: float;\n aet: float;\n ap: boolean;\n cfd: float;\n };\n\n type Model3DObjectNetworkSyncData = Object3DNetworkSyncData &\n Model3DObjectNetworkSyncDataType;\n\n /** Base parameters for {@link gdjs.Cube3DRuntimeObject} */\n export interface Model3DObjectData extends Object3DData {\n /** The base parameters of the Model3D object */\n content: Object3DDataContent & {\n modelResourceName: string;\n rotationX: number;\n rotationY: number;\n rotationZ: number;\n keepAspectRatio: boolean;\n materialType: 'Basic' | 'StandardWithoutMetalness' | 'KeepOriginal';\n originLocation:\n | 'ModelOrigin'\n | 'ObjectCenter'\n | 'BottomCenterZ'\n | 'BottomCenterY'\n | 'TopLeft';\n centerLocation:\n | 'ModelOrigin'\n | 'ObjectCenter'\n | 'BottomCenterZ'\n | 'BottomCenterY';\n animations: Model3DAnimation[];\n crossfadeDuration: float;\n isCastingShadow: boolean;\n isReceivingShadow: boolean;\n };\n }\n\n type FloatPoint3D = [float, float, float];\n\n const getPointForLocation = (location: string): FloatPoint3D | null => {\n switch (location) {\n case 'ModelOrigin':\n return null;\n case 'ObjectCenter':\n return [0.5, 0.5, 0.5];\n case 'BottomCenterZ':\n return [0.5, 0.5, 0];\n case 'BottomCenterY':\n return [0.5, 1, 0.5];\n case 'TopLeft':\n return [0, 0, 0];\n default:\n return null;\n }\n };\n\n /**\n * A 3D object which displays a 3D model.\n */\n export class Model3DRuntimeObject\n extends gdjs.RuntimeObject3D\n implements gdjs.Animatable\n {\n _renderer: gdjs.Model3DRuntimeObjectRenderer;\n\n _modelResourceName: string;\n _materialType: gdjs.Model3DRuntimeObject.MaterialType =\n gdjs.Model3DRuntimeObject.MaterialType.Basic;\n\n /**\n * The local point of the model that will be at the object position.\n *\n * Coordinates are between 0 and 1.\n *\n * Its value is `null` when the point is configured to `\"ModelOrigin\"`\n * because the model origin needs to be evaluated according to the object\n * configuration.\n * @see gdjs.Model3DRuntimeObject3DRenderer.getOriginPoint\n */\n _originPoint: FloatPoint3D | null;\n /**\n * The local point of the model that is used as rotation center.\n *\n * Coordinates are between 0 and 1.\n *\n * Its value is `null` when the point is configured to `\"ModelOrigin\"`\n * because the model origin needs to be evaluated according to the object\n * configuration.\n * @see gdjs.Model3DRuntimeObject3DRenderer.getCenterPoint\n */\n _centerPoint: FloatPoint3D | null;\n\n _animations: Model3DAnimation[];\n _currentAnimationIndex: integer = 0;\n _animationSpeedScale: float = 1;\n _animationPaused: boolean = false;\n _crossfadeDuration: float = 0;\n _isCastingShadow: boolean = true;\n _isReceivingShadow: boolean = true;\n\n constructor(\n instanceContainer: gdjs.RuntimeInstanceContainer,\n objectData: Model3DObjectData\n ) {\n super(instanceContainer, objectData);\n this._modelResourceName = objectData.content.modelResourceName;\n this._animations = objectData.content.animations;\n this._originPoint = getPointForLocation(\n objectData.content.originLocation\n );\n this._centerPoint = getPointForLocation(\n objectData.content.centerLocation\n );\n this._renderer = new gdjs.Model3DRuntimeObjectRenderer(\n this,\n instanceContainer\n );\n this._materialType = this._convertMaterialType(\n objectData.content.materialType\n );\n\n this.setIsCastingShadow(objectData.content.isCastingShadow);\n this.setIsReceivingShadow(objectData.content.isReceivingShadow);\n this.onModelChanged(objectData);\n\n this._crossfadeDuration = objectData.content.crossfadeDuration || 0;\n\n // *ALWAYS* call `this.onCreated()` at the very end of your object constructor.\n this.onCreated();\n }\n\n /**\n * To be called after the renderer loaded a Model resource:\n * - After the renderer was instantiated\n * - After reloading the model\n */\n private onModelChanged(objectData) {\n this._updateModel(objectData);\n if (this._animations.length > 0) {\n this._renderer.playAnimation(\n this._animations[0].source,\n this._animations[0].loop\n );\n }\n }\n\n override updateOriginalDimensionsFromObjectData(\n oldObjectData: Object3DData,\n newObjectData: Object3DData\n ): void {\n // Original dimensions must not be reset by `super.updateFromObjectData`.\n // `_updateModel` has a different logic to evaluate them using `keepAspectRatio`.\n }\n\n updateFromObjectData(\n oldObjectData: Model3DObjectData,\n newObjectData: Model3DObjectData\n ): boolean {\n super.updateFromObjectData(oldObjectData, newObjectData);\n\n if (\n oldObjectData.content.materialType !==\n newObjectData.content.materialType\n ) {\n this._materialType = this._convertMaterialType(\n newObjectData.content.materialType\n );\n }\n if (\n oldObjectData.content.modelResourceName !==\n newObjectData.content.modelResourceName\n ) {\n this._reloadModel(newObjectData);\n } else if (\n oldObjectData.content.width !== newObjectData.content.width ||\n oldObjectData.content.height !== newObjectData.content.height ||\n oldObjectData.content.depth !== newObjectData.content.depth ||\n oldObjectData.content.rotationX !== newObjectData.content.rotationX ||\n oldObjectData.content.rotationY !== newObjectData.content.rotationY ||\n oldObjectData.content.rotationZ !== newObjectData.content.rotationZ ||\n oldObjectData.content.keepAspectRatio !==\n newObjectData.content.keepAspectRatio ||\n oldObjectData.content.materialType !==\n newObjectData.content.materialType ||\n oldObjectData.content.centerLocation !==\n newObjectData.content.centerLocation\n ) {\n // The center is applied to the model by `_updateModel`.\n this._centerPoint = getPointForLocation(\n newObjectData.content.centerLocation\n );\n this._updateModel(newObjectData);\n }\n if (\n oldObjectData.content.originLocation !==\n newObjectData.content.originLocation\n ) {\n this._originPoint = getPointForLocation(\n newObjectData.content.originLocation\n );\n this._renderer.updatePosition();\n }\n if (\n oldObjectData.content.isCastingShadow !==\n newObjectData.content.isCastingShadow\n ) {\n this.setIsCastingShadow(newObjectData.content.isCastingShadow);\n }\n if (\n oldObjectData.content.isReceivingShadow !==\n newObjectData.content.isReceivingShadow\n ) {\n this.setIsReceivingShadow(newObjectData.content.isReceivingShadow);\n }\n return true;\n }\n\n getNetworkSyncData(\n syncOptions: GetNetworkSyncDataOptions\n ): Model3DObjectNetworkSyncData {\n return {\n ...super.getNetworkSyncData(syncOptions),\n mt: this._materialType,\n op: this._originPoint,\n cp: this._centerPoint,\n anis: this._animations,\n ai: this._currentAnimationIndex,\n ass: this._animationSpeedScale,\n aet: this.getAnimationElapsedTime(),\n ap: this._animationPaused,\n cfd: this._crossfadeDuration,\n };\n }\n\n updateFromNetworkSyncData(\n networkSyncData: Model3DObjectNetworkSyncData,\n options: UpdateFromNetworkSyncDataOptions\n ): void {\n super.updateFromNetworkSyncData(networkSyncData, options);\n\n if (networkSyncData.mt !== undefined) {\n this._materialType = networkSyncData.mt;\n }\n if (networkSyncData.op !== undefined) {\n this._originPoint = networkSyncData.op;\n }\n if (networkSyncData.cp !== undefined) {\n this._centerPoint = networkSyncData.cp;\n }\n if (networkSyncData.anis !== undefined) {\n this._animations = networkSyncData.anis;\n }\n if (networkSyncData.ass !== undefined) {\n this.setAnimationSpeedScale(networkSyncData.ass);\n }\n if (networkSyncData.ai !== undefined) {\n this.setAnimationIndex(networkSyncData.ai);\n }\n if (networkSyncData.aet !== undefined) {\n this.setAnimationElapsedTime(networkSyncData.aet);\n }\n if (networkSyncData.ap !== undefined) {\n if (networkSyncData.ap !== this.isAnimationPaused()) {\n networkSyncData.ap ? this.pauseAnimation() : this.resumeAnimation();\n }\n }\n if (networkSyncData.cfd !== undefined) {\n this._crossfadeDuration = networkSyncData.cfd;\n }\n }\n\n _reloadModel(objectData: Model3DObjectData) {\n this._modelResourceName = objectData.content.modelResourceName;\n this._renderer._reloadModel(this, this._runtimeScene);\n this.onModelChanged(objectData);\n }\n\n _updateModel(objectData: Model3DObjectData) {\n const rotationX = objectData.content.rotationX || 0;\n const rotationY = objectData.content.rotationY || 0;\n const rotationZ = objectData.content.rotationZ || 0;\n const width = objectData.content.width || 100;\n const height = objectData.content.height || 100;\n const depth = objectData.content.depth || 100;\n const keepAspectRatio = objectData.content.keepAspectRatio;\n this._renderer._updateModel(\n rotationX,\n rotationY,\n rotationZ,\n width,\n height,\n depth,\n keepAspectRatio\n );\n }\n\n getRenderer(): RuntimeObject3DRenderer {\n return this._renderer;\n }\n\n _convertMaterialType(\n materialTypeString: string\n ): gdjs.Model3DRuntimeObject.MaterialType {\n if (materialTypeString === 'KeepOriginal') {\n return gdjs.Model3DRuntimeObject.MaterialType.KeepOriginal;\n } else if (materialTypeString === 'StandardWithoutMetalness') {\n return gdjs.Model3DRuntimeObject.MaterialType.StandardWithoutMetalness;\n } else {\n return gdjs.Model3DRuntimeObject.MaterialType.Basic;\n }\n }\n\n update(instanceContainer: gdjs.RuntimeInstanceContainer): void {\n const elapsedTime = this.getElapsedTime() / 1000;\n this._renderer.updateAnimation(elapsedTime);\n }\n\n /**\n * Get the index of the animation being played.\n * @return The index of the new animation being played\n */\n getAnimationIndex(): number {\n return this._currentAnimationIndex;\n }\n\n /**\n * Change the animation being played.\n * @param animationIndex The index of the new animation to be played\n */\n setAnimationIndex(animationIndex: number): void {\n animationIndex = animationIndex | 0;\n if (\n animationIndex < this._animations.length &&\n this._currentAnimationIndex !== animationIndex &&\n animationIndex >= 0\n ) {\n const animation = this._animations[animationIndex];\n this._currentAnimationIndex = animationIndex;\n this._renderer.playAnimation(animation.source, animation.loop);\n if (this._animationPaused) {\n this._renderer.pauseAnimation();\n }\n }\n }\n\n /**\n * Get the name of the animation being played.\n * @return The name of the new animation being played\n */\n getAnimationName(): string {\n if (this._currentAnimationIndex >= this._animations.length) {\n return '';\n }\n return this._animations[this._currentAnimationIndex].name;\n }\n\n /**\n * Change the animation being played.\n * @param newAnimationName The name of the new animation to be played\n */\n setAnimationName(newAnimationName: string): void {\n if (!newAnimationName) {\n return;\n }\n const animationIndex = this._animations.findIndex(\n (animation) => animation.name === newAnimationName\n );\n if (animationIndex >= 0) {\n this.setAnimationIndex(animationIndex);\n }\n }\n\n isCurrentAnimationName(name: string): boolean {\n return this.getAnimationName() === name;\n }\n\n /**\n * Return true if animation has ended.\n * The animation had ended if:\n * - it's not configured as a loop;\n * - the current frame is the last frame;\n * - the last frame has been displayed long enough.\n */\n hasAnimationEnded(): boolean {\n return this._renderer.hasAnimationEnded();\n }\n\n setIsCastingShadow(value: boolean): void {\n this._isCastingShadow = value;\n this._renderer._updateShadow();\n }\n\n setIsReceivingShadow(value: boolean): void {\n this._isReceivingShadow = value;\n this._renderer._updateShadow();\n }\n\n setCrossfadeDuration(duration: number): void {\n if (this._crossfadeDuration === duration) return;\n this._crossfadeDuration = duration;\n }\n\n isAnimationPaused() {\n return this._animationPaused;\n }\n\n pauseAnimation() {\n this._animationPaused = true;\n this._renderer.pauseAnimation();\n }\n\n resumeAnimation() {\n this._animationPaused = false;\n this._renderer.resumeAnimation();\n }\n\n getAnimationSpeedScale() {\n return this._animationSpeedScale;\n }\n\n setAnimationSpeedScale(ratio: float): void {\n this._animationSpeedScale = ratio;\n this._renderer.setAnimationTimeScale(ratio);\n }\n\n getAnimationElapsedTime(): float {\n return this._renderer.getAnimationElapsedTime();\n }\n\n setAnimationElapsedTime(time: float): void {\n this._renderer.setAnimationElapsedTime(time);\n if (!this._animationPaused) {\n this._renderer.resumeAnimation();\n }\n }\n\n getAnimationDuration(): float {\n return this._renderer.getAnimationDuration(\n this._animations[this._currentAnimationIndex].source\n );\n }\n\n getCenterX(): float {\n const centerPoint = this._renderer.getCenterPoint();\n return this.getWidth() * centerPoint[0];\n }\n\n getCenterY(): float {\n const centerPoint = this._renderer.getCenterPoint();\n return this.getHeight() * centerPoint[1];\n }\n\n getCenterZ(): float {\n const centerPoint = this._renderer.getCenterPoint();\n return this.getDepth() * centerPoint[2];\n }\n\n getDrawableX(): float {\n const originPoint = this._renderer.getOriginPoint();\n return this.getX() - this.getWidth() * originPoint[0];\n }\n\n getDrawableY(): float {\n const originPoint = this._renderer.getOriginPoint();\n return this.getY() - this.getHeight() * originPoint[1];\n }\n\n getDrawableZ(): float {\n const originPoint = this._renderer.getOriginPoint();\n return this.getZ() - this.getDepth() * originPoint[2];\n }\n }\n\n export namespace Model3DRuntimeObject {\n export enum MaterialType {\n Basic,\n StandardWithoutMetalness,\n KeepOriginal,\n }\n }\n gdjs.registerObject('Scene3D::Model3DObject', gdjs.Model3DRuntimeObject);\n}\n"],
|
|
5
|
+
"mappings": "AAAA,GAAU,MAAV,UAAU,EAAV,CAgDE,KAAM,GAAsB,AAAC,GAA0C,CACrE,OAAQ,OACD,cACH,MAAO,UACJ,eACH,MAAO,CAAC,GAAK,GAAK,QACf,gBACH,MAAO,CAAC,GAAK,GAAK,OACf,gBACH,MAAO,CAAC,GAAK,EAAG,QACb,UACH,MAAO,CAAC,EAAG,EAAG,WAEd,MAAO,QAON,eACG,GAAK,eAEf,CAsCE,YACE,EACA,EACA,CACA,MAAM,EAAmB,GAtC3B,mBACE,EAAK,qBAAqB,aAAa,MA0BzC,4BAAkC,EAClC,0BAA8B,EAC9B,sBAA4B,GAC5B,wBAA4B,EAC5B,sBAA4B,GAC5B,wBAA8B,GAO5B,KAAK,mBAAqB,EAAW,QAAQ,kBAC7C,KAAK,YAAc,EAAW,QAAQ,WACtC,KAAK,aAAe,EAClB,EAAW,QAAQ,gBAErB,KAAK,aAAe,EAClB,EAAW,QAAQ,gBAErB,KAAK,UAAY,GAAI,GAAK,6BACxB,KACA,GAEF,KAAK,cAAgB,KAAK,qBACxB,EAAW,QAAQ,cAGrB,KAAK,mBAAmB,EAAW,QAAQ,iBAC3C,KAAK,qBAAqB,EAAW,QAAQ,mBAC7C,KAAK,eAAe,G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AAK,YAAY,KAAK,wBAAwB,QAIlD,YAAoB,CAClB,KAAM,GAAc,KAAK,UAAU,iBACnC,MAAO,MAAK,WAAa,EAAY,GAGvC,YAAoB,CAClB,KAAM,GAAc,KAAK,UAAU,iBACnC,MAAO,MAAK,YAAc,EAAY,GAGxC,YAAoB,CAClB,KAAM,GAAc,KAAK,UAAU,iBACnC,MAAO,MAAK,WAAa,EAAY,GAGvC,cAAsB,CACpB,KAAM,GAAc,KAAK,UAAU,iBACnC,MAAO,MAAK,OAAS,KAAK,WAAa,EAAY,GAGrD,cAAsB,CACpB,KAAM,GAAc,KAAK,UAAU,iBACnC,MAAO,MAAK,OAAS,KAAK,YAAc,EAAY,GAGtD,cAAsB,CACpB,KAAM,GAAc,KAAK,UAAU,iBACnC,MAAO,MAAK,OAAS,KAAK,WAAa,EAAY,IA1ZhD,EAAM,uBA8ZN,SAAU,EAAV,CACE,GAAK,GAAL,UAAK,EAAL,CACL,qBACA,2DACA,qCAHU,wCADG,uDAOjB,EAAK,eAAe,yBAA0B,EAAK,wBAze3C",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var gdjs;(function(a){const s=1/(1<<16),g=i=>{i.metalness&&(i.metalness=0)},
|
|
1
|
+
var gdjs;(function(a){const s=1/(1<<16),g=i=>{i.metalness&&(i.metalness=0)},b=i=>{const t=i;if(!!t.material)if(Array.isArray(t.material))for(let e=0;e<t.material.length;e++)g(t.material[e]);else g(t.material)},f=i=>i.traverse(b),M=i=>{const t=new THREE.MeshBasicMaterial;return i.color&&(t.color=i.color),i.map&&(t.map=i.map),t},D=i=>{const t=i;if(!!t.material)if(Array.isArray(t.material))for(let e=0;e<t.material.length;e++)t.material[e]=M(t.material[e]);else t.material=M(t.material)},T=i=>i.traverse(D);class j extends a.RuntimeObject3DRenderer{constructor(t,e){const r=e.getGame().getModel3DManager().getModel(t._modelResourceName),n=new THREE.Group,l=new THREE.Group;l.rotation.order="ZYX",l.add(n);super(t,e,l);this._model3DRuntimeObject=t,this._threeObject=n,this._originalModel=r,this._modelOriginPoint=[0,0,0],this.updateSize(),this.updatePosition(),this.updateRotation(),this._animationMixer=new THREE.AnimationMixer(n),this._action=null}updateAnimation(t){this._animationMixer.update(t)}updatePosition(){const t=this.getOriginPoint(),e=this.getCenterPoint();this.get3DRendererObject().position.set(this._object.getX()-this._object.getWidth()*(t[0]-e[0]),this._object.getY()-this._object.getHeight()*(t[1]-e[1]),this._object.getZ()-this._object.getDepth()*(t[2]-e[2]))}getOriginPoint(){return this._model3DRuntimeObject._originPoint||this._modelOriginPoint}getCenterPoint(){return this._model3DRuntimeObject._centerPoint||this._modelOriginPoint}_updateDefaultTransformation(t,e,r,n,l,u,R,m){t.rotation.set(a.toRad(e),a.toRad(r),a.toRad(n)),t.updateMatrixWorld(!0);const o=new THREE.Box3().setFromObject(t);!this._model3DRuntimeObject._originPoint&&o.expandByPoint(new THREE.Vector3(0,0,0));const c=o.max.x-o.min.x,d=o.max.y-o.min.y,h=o.max.z-o.min.z;this._modelOriginPoint[0]=c<s?0:-o.min.x/c,this._modelOriginPoint[1]=d<s?0:-o.min.y/d,this._modelOriginPoint[2]=h<s?0:-o.min.z/h,this._modelOriginPoint[1]=1-this._modelOriginPoint[1];const p=this._model3DRuntimeObject._centerPoint;p&&t.position.set(-(o.min.x+c*p[0]),-(o.min.y+d*(1-p[1])),-(o.min.z+h*p[2])),t.scale.set(1,1,1),t.rotation.set(a.toRad(e),a.toRad(r),a.toRad(n));const P=c<s?1:1/c,A=d<s?1:1/d,H=h<s?1:1/h,O=new THREE.Matrix4;if(O.makeScale(P,-A,H),t.updateMatrix(),t.applyMatrix4(O),m){const x=c<s?Number.POSITIVE_INFINITY:l/c,v=d<s?Number.POSITIVE_INFINITY:u/d,I=h<s?Number.POSITIVE_INFINITY:R/h;let _=Math.min(x,v,I);Number.isFinite(_)||(_=1),this._object._setOriginalWidth(_*c),this._object._setOriginalHeight(_*d),this._object._setOriginalDepth(_*h)}else this._object._setOriginalWidth(l),this._object._setOriginalHeight(u),this._object._setOriginalDepth(R)}_reloadModel(t,e){this._originalModel=e.getGame().getModel3DManager().getModel(t._modelResourceName)}_updateModel(t,e,r,n,l,u,R){const m=new THREE.Group;m.rotation.order="ZYX";const o=THREE_ADDONS.SkeletonUtils.clone(this._originalModel.scene);m.add(o),this._replaceMaterials(m),this._updateDefaultTransformation(m,t,e,r,n,l,u,R),this.get3DRendererObject().remove(this._threeObject),this.get3DRendererObject().add(m),this._threeObject=m,this.updatePosition(),this._updateShadow(),this._animationMixer=new THREE.AnimationMixer(o);const E=this._model3DRuntimeObject.isAnimationPaused();this._model3DRuntimeObject.setAnimationIndex(this._model3DRuntimeObject.getAnimationIndex()),E&&this.pauseAnimation()}_replaceMaterials(t){this._model3DRuntimeObject._materialType===a.Model3DRuntimeObject.MaterialType.StandardWithoutMetalness?f(t):this._model3DRuntimeObject._materialType===a.Model3DRuntimeObject.MaterialType.Basic&&T(t)}getAnimationCount(){return this._originalModel.animations.length}getAnimationName(t){return this._originalModel.animations[t].name}_updateShadow(){this._threeObject.traverse(t=>{t.castShadow=this._model3DRuntimeObject._isCastingShadow,t.receiveShadow=this._model3DRuntimeObject._isReceivingShadow})}hasAnimationEnded(){return this._action?!this._action.isRunning():!0}animationPaused(){if(!!this._action)return this._action.paused}pauseAnimation(){!this._action||(this._action.paused=!0)}resumeAnimation(){!this._action||(this._action.paused=!1)}playAnimation(t,e){const r=THREE.AnimationClip.findByName(this._originalModel.animations,t);if(!r){console.error(`The GLB file: ${this._model3DRuntimeObject._modelResourceName} doesn't have any animation named: ${t}`);return}const n=this._action;this._action=this._animationMixer.clipAction(r),this._action.reset(),this._action.setLoop(e?THREE.LoopRepeat:THREE.LoopOnce,Number.POSITIVE_INFINITY),this._action.clampWhenFinished=!0,this._action.timeScale=this._model3DRuntimeObject.getAnimationSpeedScale(),n&&n!==this._action&&this._action.crossFadeFrom(n,this._model3DRuntimeObject._crossfadeDuration,!1),this._action.play(),this._animationMixer.update(0)}getAnimationElapsedTime(){return this._action?this._action.time:0}setAnimationElapsedTime(t){this._action&&(this._action.time=t)}setAnimationTimeScale(t){this._action&&(this._action.timeScale=t)}getAnimationDuration(t){const e=THREE.AnimationClip.findByName(this._originalModel.animations,t);return e?e.duration:0}}a.Model3DRuntimeObjectRenderer=j})(gdjs||(gdjs={}));
|
|
2
2
|
//# sourceMappingURL=Model3DRuntimeObject3DRenderer.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../GDevelop/Extensions/3D/Model3DRuntimeObject3DRenderer.ts"],
|
|
4
|
-
"sourcesContent": ["namespace gdjs {\n type FloatPoint3D = [float, float, float];\n\n const epsilon = 1 / (1 << 16);\n\n const removeMetalness = (material: THREE.Material): void => {\n //@ts-ignore\n if (material.metalness) {\n //@ts-ignore\n material.metalness = 0;\n }\n };\n\n const removeMetalnessFromMesh = (node: THREE.Object3D) => {\n const mesh = node as THREE.Mesh;\n if (!mesh.material) {\n return;\n }\n if (Array.isArray(mesh.material)) {\n for (let index = 0; index < mesh.material.length; index++) {\n removeMetalness(mesh.material[index]);\n }\n } else {\n removeMetalness(mesh.material);\n }\n };\n\n const traverseToRemoveMetalnessFromMeshes = (node: THREE.Object3D) =>\n node.traverse(removeMetalnessFromMesh);\n\n const convertToBasicMaterial = (\n material: THREE.Material\n ): THREE.MeshBasicMaterial => {\n const basicMaterial = new THREE.MeshBasicMaterial();\n //@ts-ignore\n if (material.color) {\n //@ts-ignore\n basicMaterial.color = material.color;\n }\n //@ts-ignore\n if (material.map) {\n //@ts-ignore\n basicMaterial.map = material.map;\n }\n return basicMaterial;\n };\n\n const setBasicMaterialTo = (node: THREE.Object3D): void => {\n const mesh = node as THREE.Mesh;\n if (!mesh.material) {\n return;\n }\n\n if (Array.isArray(mesh.material)) {\n for (let index = 0; index < mesh.material.length; index++) {\n mesh.material[index] = convertToBasicMaterial(mesh.material[index]);\n }\n } else {\n mesh.material = convertToBasicMaterial(mesh.material);\n }\n };\n\n const traverseToSetBasicMaterialFromMeshes = (node: THREE.Object3D) =>\n node.traverse(setBasicMaterialTo);\n\n class Model3DRuntimeObject3DRenderer extends gdjs.RuntimeObject3DRenderer {\n private _model3DRuntimeObject: gdjs.Model3DRuntimeObject;\n /**\n * The 3D model stretched in a 1x1x1 cube.\n */\n private _threeObject: THREE.Object3D;\n private _originalModel: THREE_ADDONS.GLTF;\n private _animationMixer: THREE.AnimationMixer;\n private _action: THREE.AnimationAction | null;\n\n /**\n * The model origin evaluated according to the object configuration.\n *\n * Coordinates are between 0 and 1.\n */\n private _modelOriginPoint: FloatPoint3D;\n\n constructor(\n runtimeObject: gdjs.Model3DRuntimeObject,\n instanceContainer: gdjs.RuntimeInstanceContainer\n ) {\n // GLB files with skeleton must not have any transformation to work properly.\n const originalModel = instanceContainer\n .getGame()\n .getModel3DManager()\n .getModel(runtimeObject._modelResourceName);\n // _updateModel will actually add a clone of the model.\n const model = new THREE.Group();\n\n // Create a group to transform the object according to\n // position, angle and dimensions.\n const group = new THREE.Group();\n group.rotation.order = 'ZYX';\n group.add(model);\n super(runtimeObject, instanceContainer, group);\n\n this._model3DRuntimeObject = runtimeObject;\n this._threeObject = model;\n this._originalModel = originalModel;\n this._modelOriginPoint = [0, 0, 0];\n\n this.updateSize();\n this.updatePosition();\n this.updateRotation();\n\n this._animationMixer = new THREE.AnimationMixer(model);\n this._action = null;\n }\n\n updateAnimation(timeDelta: float) {\n this._animationMixer.update(timeDelta);\n }\n\n updatePosition() {\n const originPoint = this.getOriginPoint();\n const centerPoint = this.getCenterPoint();\n this.get3DRendererObject().position.set(\n this._object.getX() -\n this._object.getWidth() * (originPoint[0] - centerPoint[0]),\n this._object.getY() -\n this._object.getHeight() * (originPoint[1] - centerPoint[1]),\n this._object.getZ() -\n this._object.getDepth() * (originPoint[2] - centerPoint[2])\n );\n }\n\n getOriginPoint() {\n return this._model3DRuntimeObject._originPoint || this._modelOriginPoint;\n }\n\n getCenterPoint() {\n return this._model3DRuntimeObject._centerPoint || this._modelOriginPoint;\n }\n\n private _updateDefaultTransformation(\n threeObject: THREE.Object3D,\n rotationX: float,\n rotationY: float,\n rotationZ: float,\n originalWidth: float,\n originalHeight: float,\n originalDepth: float,\n keepAspectRatio: boolean\n ) {\n // These formulas are also used in:\n // - Model3DEditor.modelSize\n // - Model3DRendered2DInstance\n threeObject.rotation.set(\n gdjs.toRad(rotationX),\n gdjs.toRad(rotationY),\n gdjs.toRad(rotationZ)\n );\n threeObject.updateMatrixWorld(true);\n const boundingBox = new THREE.Box3().setFromObject(threeObject);\n\n const shouldKeepModelOrigin = !this._model3DRuntimeObject._originPoint;\n if (shouldKeepModelOrigin) {\n // Keep the origin as part of the model.\n // For instance, a model can be 1 face of a cube and we want to keep the\n // inside as part of the object even if it's just void.\n // It also avoids to have the origin outside of the object box.\n boundingBox.expandByPoint(new THREE.Vector3(0, 0, 0));\n }\n\n const modelWidth = boundingBox.max.x - boundingBox.min.x;\n const modelHeight = boundingBox.max.y - boundingBox.min.y;\n const modelDepth = boundingBox.max.z - boundingBox.min.z;\n this._modelOriginPoint[0] =\n modelWidth < epsilon ? 0 : -boundingBox.min.x / modelWidth;\n this._modelOriginPoint[1] =\n modelHeight < epsilon ? 0 : -boundingBox.min.y / modelHeight;\n this._modelOriginPoint[2] =\n modelDepth < epsilon ? 0 : -boundingBox.min.z / modelDepth;\n\n // The model is flipped on Y axis.\n this._modelOriginPoint[1] = 1 - this._modelOriginPoint[1];\n\n // Center the model.\n const centerPoint = this._model3DRuntimeObject._centerPoint;\n if (centerPoint) {\n threeObject.position.set(\n -(boundingBox.min.x + modelWidth * centerPoint[0]),\n // The model is flipped on Y axis.\n -(boundingBox.min.y + modelHeight * (1 - centerPoint[1])),\n -(boundingBox.min.z + modelDepth * centerPoint[2])\n );\n }\n\n // Rotate the model.\n threeObject.scale.set(1, 1, 1);\n threeObject.rotation.set(\n gdjs.toRad(rotationX),\n gdjs.toRad(rotationY),\n gdjs.toRad(rotationZ)\n );\n\n // Stretch the model in a 1x1x1 cube.\n const scaleX = modelWidth < epsilon ? 1 : 1 / modelWidth;\n const scaleY = modelHeight < epsilon ? 1 : 1 / modelHeight;\n const scaleZ = modelDepth < epsilon ? 1 : 1 / modelDepth;\n\n const scaleMatrix = new THREE.Matrix4();\n // Flip on Y because the Y axis is on the opposite side of direct basis.\n // It avoids models to be like a mirror refection.\n scaleMatrix.makeScale(scaleX, -scaleY, scaleZ);\n threeObject.updateMatrix();\n threeObject.applyMatrix4(scaleMatrix);\n\n if (keepAspectRatio) {\n // Reduce the object dimensions to keep aspect ratio.\n const widthRatio =\n modelWidth < epsilon\n ? Number.POSITIVE_INFINITY\n : originalWidth / modelWidth;\n const heightRatio =\n modelHeight < epsilon\n ? Number.POSITIVE_INFINITY\n : originalHeight / modelHeight;\n const depthRatio =\n modelDepth < epsilon\n ? Number.POSITIVE_INFINITY\n : originalDepth / modelDepth;\n let scaleRatio = Math.min(widthRatio, heightRatio, depthRatio);\n if (!Number.isFinite(scaleRatio)) {\n scaleRatio = 1;\n }\n\n this._object._setOriginalWidth(scaleRatio * modelWidth);\n this._object._setOriginalHeight(scaleRatio * modelHeight);\n this._object._setOriginalDepth(scaleRatio * modelDepth);\n }\n }\n\n /**\n * `_updateModel` should always be called after this method.\n * Ideally, use `Model3DRuntimeObject#_reloadModel` instead.\n */\n _reloadModel(\n runtimeObject: Model3DRuntimeObject,\n instanceContainer: gdjs.RuntimeInstanceContainer\n ) {\n this._originalModel = instanceContainer\n .getGame()\n .getModel3DManager()\n .getModel(runtimeObject._modelResourceName);\n }\n\n _updateModel(\n rotationX: float,\n rotationY: float,\n rotationZ: float,\n originalWidth: float,\n originalHeight: float,\n originalDepth: float,\n keepAspectRatio: boolean\n ) {\n // Start from the original model because:\n // - _replaceMaterials is destructive\n // - _updateDefaultTransformation may need to work with meshes in local space\n\n // This group hold the rotation defined by properties.\n const threeObject = new THREE.Group();\n threeObject.rotation.order = 'ZYX';\n const root = THREE_ADDONS.SkeletonUtils.clone(this._originalModel.scene);\n threeObject.add(root);\n\n this._replaceMaterials(threeObject);\n\n this._updateDefaultTransformation(\n threeObject,\n rotationX,\n rotationY,\n rotationZ,\n originalWidth,\n originalHeight,\n originalDepth,\n keepAspectRatio\n );\n\n // Replace the 3D object.\n this.get3DRendererObject().remove(this._threeObject);\n this.get3DRendererObject().add(threeObject);\n this._threeObject = threeObject;\n this._updateShadow();\n\n // Start the current animation on the new 3D object.\n this._animationMixer = new THREE.AnimationMixer(root);\n const isAnimationPaused = this._model3DRuntimeObject.isAnimationPaused();\n this._model3DRuntimeObject.setAnimationIndex(\n this._model3DRuntimeObject.getAnimationIndex()\n );\n if (isAnimationPaused) {\n this.pauseAnimation();\n }\n }\n\n /**\n * Replace materials to better work with lights (or no light).\n */\n private _replaceMaterials(threeObject: THREE.Object3D) {\n if (\n this._model3DRuntimeObject._materialType ===\n gdjs.Model3DRuntimeObject.MaterialType.StandardWithoutMetalness\n ) {\n traverseToRemoveMetalnessFromMeshes(threeObject);\n } else if (\n this._model3DRuntimeObject._materialType ===\n gdjs.Model3DRuntimeObject.MaterialType.Basic\n ) {\n traverseToSetBasicMaterialFromMeshes(threeObject);\n }\n }\n\n getAnimationCount() {\n return this._originalModel.animations.length;\n }\n\n getAnimationName(animationIndex: integer) {\n return this._originalModel.animations[animationIndex].name;\n }\n\n _updateShadow() {\n this._threeObject.traverse((child) => {\n child.castShadow = this._model3DRuntimeObject._isCastingShadow;\n child.receiveShadow = this._model3DRuntimeObject._isReceivingShadow;\n });\n }\n\n /**\n * Return true if animation has ended.\n * The animation had ended if:\n * - it's not configured as a loop;\n * - the current frame is the last frame;\n * - the last frame has been displayed long enough.\n */\n hasAnimationEnded(): boolean {\n if (!this._action) {\n return true;\n }\n return !this._action.isRunning();\n }\n\n animationPaused() {\n if (!this._action) {\n return;\n }\n return this._action.paused;\n }\n\n pauseAnimation() {\n if (!this._action) {\n return;\n }\n this._action.paused = true;\n }\n\n resumeAnimation() {\n if (!this._action) {\n return;\n }\n this._action.paused = false;\n }\n\n playAnimation(animationName: string, shouldLoop: boolean) {\n const clip = THREE.AnimationClip.findByName(\n this._originalModel.animations,\n animationName\n );\n if (!clip) {\n console.error(\n `The GLB file: ${this._model3DRuntimeObject._modelResourceName} doesn't have any animation named: ${animationName}`\n );\n return;\n }\n const previousAction = this._action;\n this._action = this._animationMixer.clipAction(clip);\n // Reset the animation and play it from the start.\n // `clipAction` always gives back the same action for a given animation\n // and its likely to be in a finished or at least started state.\n this._action.reset();\n this._action.setLoop(\n shouldLoop ? THREE.LoopRepeat : THREE.LoopOnce,\n Number.POSITIVE_INFINITY\n );\n this._action.clampWhenFinished = true;\n this._action.timeScale =\n this._model3DRuntimeObject.getAnimationSpeedScale();\n\n if (previousAction && previousAction !== this._action) {\n this._action.crossFadeFrom(\n previousAction,\n this._model3DRuntimeObject._crossfadeDuration,\n false\n );\n }\n this._action.play();\n // Make sure the first frame is displayed.\n this._animationMixer.update(0);\n }\n\n getAnimationElapsedTime(): float {\n return this._action ? this._action.time : 0;\n }\n\n setAnimationElapsedTime(time: float): void {\n if (this._action) {\n this._action.time = time;\n }\n }\n\n setAnimationTimeScale(timeScale: float): void {\n if (this._action) {\n this._action.timeScale = timeScale;\n }\n }\n\n getAnimationDuration(animationName: string): float {\n const clip = THREE.AnimationClip.findByName(\n this._originalModel.animations,\n animationName\n );\n return clip ? clip.duration : 0;\n }\n }\n\n export const Model3DRuntimeObjectRenderer = Model3DRuntimeObject3DRenderer;\n export type Model3DRuntimeObjectRenderer = Model3DRuntimeObject3DRenderer;\n}\n"],
|
|
5
|
-
"mappings": "AAAA,GAAU,MAAV,UAAU,EAAV,CAGE,KAAM,GAAU,EAAK,IAAK,IAEpB,EAAkB,AAAC,GAAmC,CAE1D,AAAI,EAAS,WAEX,GAAS,UAAY,IAInB,EAA0B,AAAC,GAAyB,CACxD,KAAM,GAAO,EACb,GAAI,EAAC,EAAK,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AAI,EAAI,EACzC,EAAS,EAAa,EAAU,EAAI,EAAI,EAExC,EAAc,GAAI,OAAM,QAO9B,GAJA,EAAY,UAAU,EAAQ,CAAC,EAAQ,GACvC,EAAY,eACZ,EAAY,aAAa,GAErB,EAAiB,CAEnB,KAAM,GACJ,EAAa,EACT,OAAO,kBACP,EAAgB,EAChB,EACJ,EAAc,EACV,OAAO,kBACP,EAAiB,EACjB,EACJ,EAAa,EACT,OAAO,kBACP,EAAgB,EACtB,GAAI,GAAa,KAAK,IAAI,EAAY,EAAa,GACnD,AAAK,OAAO,SAAS,IACnB,GAAa,GAGf,KAAK,QAAQ,kBAAkB,EAAa,GAC5C,KAAK,QAAQ,mBAAmB,EAAa,GAC7C,KAAK,QAAQ,kBAAkB,EAAa,
|
|
4
|
+
"sourcesContent": ["namespace gdjs {\n type FloatPoint3D = [float, float, float];\n\n const epsilon = 1 / (1 << 16);\n\n const removeMetalness = (material: THREE.Material): void => {\n //@ts-ignore\n if (material.metalness) {\n //@ts-ignore\n material.metalness = 0;\n }\n };\n\n const removeMetalnessFromMesh = (node: THREE.Object3D) => {\n const mesh = node as THREE.Mesh;\n if (!mesh.material) {\n return;\n }\n if (Array.isArray(mesh.material)) {\n for (let index = 0; index < mesh.material.length; index++) {\n removeMetalness(mesh.material[index]);\n }\n } else {\n removeMetalness(mesh.material);\n }\n };\n\n const traverseToRemoveMetalnessFromMeshes = (node: THREE.Object3D) =>\n node.traverse(removeMetalnessFromMesh);\n\n const convertToBasicMaterial = (\n material: THREE.Material\n ): THREE.MeshBasicMaterial => {\n const basicMaterial = new THREE.MeshBasicMaterial();\n //@ts-ignore\n if (material.color) {\n //@ts-ignore\n basicMaterial.color = material.color;\n }\n //@ts-ignore\n if (material.map) {\n //@ts-ignore\n basicMaterial.map = material.map;\n }\n return basicMaterial;\n };\n\n const setBasicMaterialTo = (node: THREE.Object3D): void => {\n const mesh = node as THREE.Mesh;\n if (!mesh.material) {\n return;\n }\n\n if (Array.isArray(mesh.material)) {\n for (let index = 0; index < mesh.material.length; index++) {\n mesh.material[index] = convertToBasicMaterial(mesh.material[index]);\n }\n } else {\n mesh.material = convertToBasicMaterial(mesh.material);\n }\n };\n\n const traverseToSetBasicMaterialFromMeshes = (node: THREE.Object3D) =>\n node.traverse(setBasicMaterialTo);\n\n class Model3DRuntimeObject3DRenderer extends gdjs.RuntimeObject3DRenderer {\n private _model3DRuntimeObject: gdjs.Model3DRuntimeObject;\n /**\n * The 3D model stretched in a 1x1x1 cube.\n */\n private _threeObject: THREE.Object3D;\n private _originalModel: THREE_ADDONS.GLTF;\n private _animationMixer: THREE.AnimationMixer;\n private _action: THREE.AnimationAction | null;\n\n /**\n * The model origin evaluated according to the object configuration.\n *\n * Coordinates are between 0 and 1.\n */\n private _modelOriginPoint: FloatPoint3D;\n\n constructor(\n runtimeObject: gdjs.Model3DRuntimeObject,\n instanceContainer: gdjs.RuntimeInstanceContainer\n ) {\n // GLB files with skeleton must not have any transformation to work properly.\n const originalModel = instanceContainer\n .getGame()\n .getModel3DManager()\n .getModel(runtimeObject._modelResourceName);\n // _updateModel will actually add a clone of the model.\n const model = new THREE.Group();\n\n // Create a group to transform the object according to\n // position, angle and dimensions.\n const group = new THREE.Group();\n group.rotation.order = 'ZYX';\n group.add(model);\n super(runtimeObject, instanceContainer, group);\n\n this._model3DRuntimeObject = runtimeObject;\n this._threeObject = model;\n this._originalModel = originalModel;\n this._modelOriginPoint = [0, 0, 0];\n\n this.updateSize();\n this.updatePosition();\n this.updateRotation();\n\n this._animationMixer = new THREE.AnimationMixer(model);\n this._action = null;\n }\n\n updateAnimation(timeDelta: float) {\n this._animationMixer.update(timeDelta);\n }\n\n updatePosition() {\n const originPoint = this.getOriginPoint();\n const centerPoint = this.getCenterPoint();\n this.get3DRendererObject().position.set(\n this._object.getX() -\n this._object.getWidth() * (originPoint[0] - centerPoint[0]),\n this._object.getY() -\n this._object.getHeight() * (originPoint[1] - centerPoint[1]),\n this._object.getZ() -\n this._object.getDepth() * (originPoint[2] - centerPoint[2])\n );\n }\n\n getOriginPoint() {\n return this._model3DRuntimeObject._originPoint || this._modelOriginPoint;\n }\n\n getCenterPoint() {\n return this._model3DRuntimeObject._centerPoint || this._modelOriginPoint;\n }\n\n private _updateDefaultTransformation(\n threeObject: THREE.Object3D,\n rotationX: float,\n rotationY: float,\n rotationZ: float,\n originalWidth: float,\n originalHeight: float,\n originalDepth: float,\n keepAspectRatio: boolean\n ) {\n // These formulas are also used in:\n // - Model3DEditor.modelSize\n // - Model3DRendered2DInstance\n threeObject.rotation.set(\n gdjs.toRad(rotationX),\n gdjs.toRad(rotationY),\n gdjs.toRad(rotationZ)\n );\n threeObject.updateMatrixWorld(true);\n const boundingBox = new THREE.Box3().setFromObject(threeObject);\n\n const shouldKeepModelOrigin = !this._model3DRuntimeObject._originPoint;\n if (shouldKeepModelOrigin) {\n // Keep the origin as part of the model.\n // For instance, a model can be 1 face of a cube and we want to keep the\n // inside as part of the object even if it's just void.\n // It also avoids to have the origin outside of the object box.\n boundingBox.expandByPoint(new THREE.Vector3(0, 0, 0));\n }\n\n const modelWidth = boundingBox.max.x - boundingBox.min.x;\n const modelHeight = boundingBox.max.y - boundingBox.min.y;\n const modelDepth = boundingBox.max.z - boundingBox.min.z;\n this._modelOriginPoint[0] =\n modelWidth < epsilon ? 0 : -boundingBox.min.x / modelWidth;\n this._modelOriginPoint[1] =\n modelHeight < epsilon ? 0 : -boundingBox.min.y / modelHeight;\n this._modelOriginPoint[2] =\n modelDepth < epsilon ? 0 : -boundingBox.min.z / modelDepth;\n\n // The model is flipped on Y axis.\n this._modelOriginPoint[1] = 1 - this._modelOriginPoint[1];\n\n // Center the model.\n const centerPoint = this._model3DRuntimeObject._centerPoint;\n if (centerPoint) {\n threeObject.position.set(\n -(boundingBox.min.x + modelWidth * centerPoint[0]),\n // The model is flipped on Y axis.\n -(boundingBox.min.y + modelHeight * (1 - centerPoint[1])),\n -(boundingBox.min.z + modelDepth * centerPoint[2])\n );\n }\n\n // Rotate the model.\n threeObject.scale.set(1, 1, 1);\n threeObject.rotation.set(\n gdjs.toRad(rotationX),\n gdjs.toRad(rotationY),\n gdjs.toRad(rotationZ)\n );\n\n // Stretch the model in a 1x1x1 cube.\n const scaleX = modelWidth < epsilon ? 1 : 1 / modelWidth;\n const scaleY = modelHeight < epsilon ? 1 : 1 / modelHeight;\n const scaleZ = modelDepth < epsilon ? 1 : 1 / modelDepth;\n\n const scaleMatrix = new THREE.Matrix4();\n // Flip on Y because the Y axis is on the opposite side of direct basis.\n // It avoids models to be like a mirror refection.\n scaleMatrix.makeScale(scaleX, -scaleY, scaleZ);\n threeObject.updateMatrix();\n threeObject.applyMatrix4(scaleMatrix);\n\n if (keepAspectRatio) {\n // Reduce the object dimensions to keep aspect ratio.\n const widthRatio =\n modelWidth < epsilon\n ? Number.POSITIVE_INFINITY\n : originalWidth / modelWidth;\n const heightRatio =\n modelHeight < epsilon\n ? Number.POSITIVE_INFINITY\n : originalHeight / modelHeight;\n const depthRatio =\n modelDepth < epsilon\n ? Number.POSITIVE_INFINITY\n : originalDepth / modelDepth;\n let scaleRatio = Math.min(widthRatio, heightRatio, depthRatio);\n if (!Number.isFinite(scaleRatio)) {\n scaleRatio = 1;\n }\n\n this._object._setOriginalWidth(scaleRatio * modelWidth);\n this._object._setOriginalHeight(scaleRatio * modelHeight);\n this._object._setOriginalDepth(scaleRatio * modelDepth);\n } else {\n this._object._setOriginalWidth(originalWidth);\n this._object._setOriginalHeight(originalHeight);\n this._object._setOriginalDepth(originalDepth);\n }\n }\n\n /**\n * `_updateModel` should always be called after this method.\n * Ideally, use `Model3DRuntimeObject#_reloadModel` instead.\n */\n _reloadModel(\n runtimeObject: Model3DRuntimeObject,\n instanceContainer: gdjs.RuntimeInstanceContainer\n ) {\n this._originalModel = instanceContainer\n .getGame()\n .getModel3DManager()\n .getModel(runtimeObject._modelResourceName);\n }\n\n _updateModel(\n rotationX: float,\n rotationY: float,\n rotationZ: float,\n originalWidth: float,\n originalHeight: float,\n originalDepth: float,\n keepAspectRatio: boolean\n ) {\n // Start from the original model because:\n // - _replaceMaterials is destructive\n // - _updateDefaultTransformation may need to work with meshes in local space\n\n // This group hold the rotation defined by properties.\n const threeObject = new THREE.Group();\n threeObject.rotation.order = 'ZYX';\n const root = THREE_ADDONS.SkeletonUtils.clone(this._originalModel.scene);\n threeObject.add(root);\n\n this._replaceMaterials(threeObject);\n\n this._updateDefaultTransformation(\n threeObject,\n rotationX,\n rotationY,\n rotationZ,\n originalWidth,\n originalHeight,\n originalDepth,\n keepAspectRatio\n );\n\n // Replace the 3D object.\n this.get3DRendererObject().remove(this._threeObject);\n this.get3DRendererObject().add(threeObject);\n this._threeObject = threeObject;\n this.updatePosition();\n this._updateShadow();\n\n // Start the current animation on the new 3D object.\n this._animationMixer = new THREE.AnimationMixer(root);\n const isAnimationPaused = this._model3DRuntimeObject.isAnimationPaused();\n this._model3DRuntimeObject.setAnimationIndex(\n this._model3DRuntimeObject.getAnimationIndex()\n );\n if (isAnimationPaused) {\n this.pauseAnimation();\n }\n }\n\n /**\n * Replace materials to better work with lights (or no light).\n */\n private _replaceMaterials(threeObject: THREE.Object3D) {\n if (\n this._model3DRuntimeObject._materialType ===\n gdjs.Model3DRuntimeObject.MaterialType.StandardWithoutMetalness\n ) {\n traverseToRemoveMetalnessFromMeshes(threeObject);\n } else if (\n this._model3DRuntimeObject._materialType ===\n gdjs.Model3DRuntimeObject.MaterialType.Basic\n ) {\n traverseToSetBasicMaterialFromMeshes(threeObject);\n }\n }\n\n getAnimationCount() {\n return this._originalModel.animations.length;\n }\n\n getAnimationName(animationIndex: integer) {\n return this._originalModel.animations[animationIndex].name;\n }\n\n _updateShadow() {\n this._threeObject.traverse((child) => {\n child.castShadow = this._model3DRuntimeObject._isCastingShadow;\n child.receiveShadow = this._model3DRuntimeObject._isReceivingShadow;\n });\n }\n\n /**\n * Return true if animation has ended.\n * The animation had ended if:\n * - it's not configured as a loop;\n * - the current frame is the last frame;\n * - the last frame has been displayed long enough.\n */\n hasAnimationEnded(): boolean {\n if (!this._action) {\n return true;\n }\n return !this._action.isRunning();\n }\n\n animationPaused() {\n if (!this._action) {\n return;\n }\n return this._action.paused;\n }\n\n pauseAnimation() {\n if (!this._action) {\n return;\n }\n this._action.paused = true;\n }\n\n resumeAnimation() {\n if (!this._action) {\n return;\n }\n this._action.paused = false;\n }\n\n playAnimation(animationName: string, shouldLoop: boolean) {\n const clip = THREE.AnimationClip.findByName(\n this._originalModel.animations,\n animationName\n );\n if (!clip) {\n console.error(\n `The GLB file: ${this._model3DRuntimeObject._modelResourceName} doesn't have any animation named: ${animationName}`\n );\n return;\n }\n const previousAction = this._action;\n this._action = this._animationMixer.clipAction(clip);\n // Reset the animation and play it from the start.\n // `clipAction` always gives back the same action for a given animation\n // and its likely to be in a finished or at least started state.\n this._action.reset();\n this._action.setLoop(\n shouldLoop ? THREE.LoopRepeat : THREE.LoopOnce,\n Number.POSITIVE_INFINITY\n );\n this._action.clampWhenFinished = true;\n this._action.timeScale =\n this._model3DRuntimeObject.getAnimationSpeedScale();\n\n if (previousAction && previousAction !== this._action) {\n this._action.crossFadeFrom(\n previousAction,\n this._model3DRuntimeObject._crossfadeDuration,\n false\n );\n }\n this._action.play();\n // Make sure the first frame is displayed.\n this._animationMixer.update(0);\n }\n\n getAnimationElapsedTime(): float {\n return this._action ? this._action.time : 0;\n }\n\n setAnimationElapsedTime(time: float): void {\n if (this._action) {\n this._action.time = time;\n }\n }\n\n setAnimationTimeScale(timeScale: float): void {\n if (this._action) {\n this._action.timeScale = timeScale;\n }\n }\n\n getAnimationDuration(animationName: string): float {\n const clip = THREE.AnimationClip.findByName(\n this._originalModel.animations,\n animationName\n );\n return clip ? clip.duration : 0;\n }\n }\n\n export const Model3DRuntimeObjectRenderer = Model3DRuntimeObject3DRenderer;\n export type Model3DRuntimeObjectRenderer = Model3DRuntimeObject3DRenderer;\n}\n"],
|
|
5
|
+
"mappings": "AAAA,GAAU,MAAV,UAAU,EAAV,CAGE,KA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,KAAO,EAG5C,wBAAwB,EAAmB,CACzC,AAAI,KAAK,SACP,MAAK,QAAQ,KAAO,GAIxB,sBAAsB,EAAwB,CAC5C,AAAI,KAAK,SACP,MAAK,QAAQ,UAAY,GAI7B,qBAAqB,EAA8B,CACjD,KAAM,GAAO,MAAM,cAAc,WAC/B,KAAK,eAAe,WACpB,GAEF,MAAO,GAAO,EAAK,SAAW,GAI3B,AAAM,+BAA+B,IAnbpC",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var gdjs;(function(a){a.PixiFiltersTools.registerFilterCreator("Scene3D::Skybox",new class{makeFilter(n,t){return typeof THREE=="undefined"?new a.PixiFiltersTools.EmptyFilter:new class{constructor(){this._oldBackground=null;this._isEnabled=!1;this._cubeTexture=n.getRuntimeScene().getGame().getImageManager().getThreeCubeTexture(t.stringParameters.rightFaceResourceName,t.stringParameters.leftFaceResourceName,t.stringParameters.topFaceResourceName,t.stringParameters.bottomFaceResourceName,t.stringParameters.frontFaceResourceName,t.stringParameters.backFaceResourceName)}isEnabled(r){return this._isEnabled}setEnabled(r,e){return this._isEnabled===e?!0:e?this.applyEffect(r):this.removeEffect(r)}applyEffect(r){const e=r.get3DRendererObject();return e?(this._oldBackground=e.background,e.background=this._cubeTexture,e.environment||(e.environment=this._cubeTexture),this._isEnabled=!0,!0):!1}removeEffect(r){const e=r.get3DRendererObject();return e?(e.background=this._oldBackground,e.environment=null,this._isEnabled=!1,!0):!1}updatePreRender(r){}updateDoubleParameter(r,e){}getDoubleParameter(r){return 0}updateStringParameter(r,e){}updateColorParameter(r,e){}getColorParameter(r){return 0}updateBooleanParameter(r,e){}getNetworkSyncData(){return{}}updateFromNetworkSyncData(r){}}}})})(gdjs||(gdjs={}));
|
|
2
|
+
//# sourceMappingURL=Skybox.js.map
|