@luminocity/lemonate-engine 15.2.2 → 15.2.3
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/engine.min.js +302 -0
- package/dist/player.zip +302 -0
- package/package.json +6 -2
- package/dist/Builder.js +0 -93
- package/dist/Builder.js.map +0 -1
- package/dist/Canvas.js +0 -109
- package/dist/Canvas.js.map +0 -1
- package/dist/Controllers.js +0 -97
- package/dist/Controllers.js.map +0 -1
- package/dist/EditorScene.js +0 -372
- package/dist/EditorScene.js.map +0 -1
- package/dist/Engine.js +0 -1576
- package/dist/Engine.js.map +0 -1
- package/dist/LoadingManager.js +0 -1195
- package/dist/LoadingManager.js.map +0 -1
- package/dist/LoadingState.js +0 -37
- package/dist/LoadingState.js.map +0 -1
- package/dist/Logger.js +0 -141
- package/dist/Logger.js.map +0 -1
- package/dist/Player.js +0 -470
- package/dist/Player.js.map +0 -1
- package/dist/Preview.js +0 -166
- package/dist/Preview.js.map +0 -1
- package/dist/RenderOptions.js +0 -59
- package/dist/RenderOptions.js.map +0 -1
- package/dist/RenderPassInfo.js +0 -133
- package/dist/RenderPassInfo.js.map +0 -1
- package/dist/RenderView.js +0 -459
- package/dist/RenderView.js.map +0 -1
- package/dist/Renderer.js +0 -1867
- package/dist/Renderer.js.map +0 -1
- package/dist/SceneGraph.js +0 -798
- package/dist/SceneGraph.js.map +0 -1
- package/dist/SceneGraphCollection.js +0 -614
- package/dist/SceneGraphCollection.js.map +0 -1
- package/dist/Shortcuts.js +0 -259
- package/dist/Shortcuts.js.map +0 -1
- package/dist/Tools.js +0 -500
- package/dist/Tools.js.map +0 -1
- package/dist/Variables.js +0 -243
- package/dist/Variables.js.map +0 -1
- package/dist/helpers/ArrowHelper.js +0 -104
- package/dist/helpers/ArrowHelper.js.map +0 -1
- package/dist/helpers/BoxHelper.js +0 -112
- package/dist/helpers/BoxHelper.js.map +0 -1
- package/dist/helpers/CameraHelper.js +0 -237
- package/dist/helpers/CameraHelper.js.map +0 -1
- package/dist/helpers/FaceNormalsHelper.js +0 -85
- package/dist/helpers/FaceNormalsHelper.js.map +0 -1
- package/dist/helpers/MeshHelper.js +0 -92
- package/dist/helpers/MeshHelper.js.map +0 -1
- package/dist/helpers/MultiGridHelper.js +0 -61
- package/dist/helpers/MultiGridHelper.js.map +0 -1
- package/dist/helpers/ParticlesHelper.js +0 -245
- package/dist/helpers/ParticlesHelper.js.map +0 -1
- package/dist/helpers/PointHelper.js +0 -85
- package/dist/helpers/PointHelper.js.map +0 -1
- package/dist/helpers/SphereHelper.js +0 -62
- package/dist/helpers/SphereHelper.js.map +0 -1
- package/dist/helpers/VertexNormalsHelper.js +0 -75
- package/dist/helpers/VertexNormalsHelper.js.map +0 -1
- package/dist/helpers/ViewHelper.js +0 -252
- package/dist/helpers/ViewHelper.js.map +0 -1
- package/dist/helpers/lighthelpers/DirectionalLightHelper.js +0 -136
- package/dist/helpers/lighthelpers/DirectionalLightHelper.js.map +0 -1
- package/dist/helpers/lighthelpers/HemisphereLightHelper.js +0 -124
- package/dist/helpers/lighthelpers/HemisphereLightHelper.js.map +0 -1
- package/dist/helpers/lighthelpers/PointLightHelper.js +0 -133
- package/dist/helpers/lighthelpers/PointLightHelper.js.map +0 -1
- package/dist/helpers/lighthelpers/SpotLightHelper.js +0 -123
- package/dist/helpers/lighthelpers/SpotLightHelper.js.map +0 -1
- package/dist/index.js +0 -40
- package/dist/index.js.map +0 -1
- package/dist/items/AudioCollectionItem.js +0 -230
- package/dist/items/AudioCollectionItem.js.map +0 -1
- package/dist/items/AudioItem.js +0 -75
- package/dist/items/AudioItem.js.map +0 -1
- package/dist/items/BackgroundShaderItem.js +0 -239
- package/dist/items/BackgroundShaderItem.js.map +0 -1
- package/dist/items/CanvasTextureItem.js +0 -194
- package/dist/items/CanvasTextureItem.js.map +0 -1
- package/dist/items/CompositionItem.js +0 -110
- package/dist/items/CompositionItem.js.map +0 -1
- package/dist/items/FontItem.js +0 -135
- package/dist/items/FontItem.js.map +0 -1
- package/dist/items/GaussianSplatsItem.js +0 -103
- package/dist/items/GaussianSplatsItem.js.map +0 -1
- package/dist/items/GridMapItem.js +0 -202
- package/dist/items/GridMapItem.js.map +0 -1
- package/dist/items/ImageItem.js +0 -255
- package/dist/items/ImageItem.js.map +0 -1
- package/dist/items/Item.js +0 -739
- package/dist/items/Item.js.map +0 -1
- package/dist/items/MaterialCollectionItem.js +0 -216
- package/dist/items/MaterialCollectionItem.js.map +0 -1
- package/dist/items/MaterialItem.js +0 -1762
- package/dist/items/MaterialItem.js.map +0 -1
- package/dist/items/MeshCollectionItem.js +0 -258
- package/dist/items/MeshCollectionItem.js.map +0 -1
- package/dist/items/MeshItem.js +0 -274
- package/dist/items/MeshItem.js.map +0 -1
- package/dist/items/ParticlesItem.js +0 -187
- package/dist/items/ParticlesItem.js.map +0 -1
- package/dist/items/PixelShaderItem.js +0 -42
- package/dist/items/PixelShaderItem.js.map +0 -1
- package/dist/items/PointsItem.js +0 -122
- package/dist/items/PointsItem.js.map +0 -1
- package/dist/items/PrefabItem.js +0 -140
- package/dist/items/PrefabItem.js.map +0 -1
- package/dist/items/ProjectItem.js +0 -857
- package/dist/items/ProjectItem.js.map +0 -1
- package/dist/items/SceneItem.js +0 -443
- package/dist/items/SceneItem.js.map +0 -1
- package/dist/items/ScriptItem.js +0 -159
- package/dist/items/ScriptItem.js.map +0 -1
- package/dist/items/VariableSetItem.js +0 -208
- package/dist/items/VariableSetItem.js.map +0 -1
- package/dist/items/VertexShaderItem.js +0 -42
- package/dist/items/VertexShaderItem.js.map +0 -1
- package/dist/items/VideoItem.js +0 -152
- package/dist/items/VideoItem.js.map +0 -1
- package/dist/items/base/ImageOwningItem.js +0 -205
- package/dist/items/base/ImageOwningItem.js.map +0 -1
- package/dist/items/base/MeshBase.js +0 -342
- package/dist/items/base/MeshBase.js.map +0 -1
- package/dist/items/base/ShaderBase.js +0 -115
- package/dist/items/base/ShaderBase.js.map +0 -1
- package/dist/items/helpers/ListEntry.js +0 -113
- package/dist/items/helpers/ListEntry.js.map +0 -1
- package/dist/items/helpers/ListField.js +0 -210
- package/dist/items/helpers/ListField.js.map +0 -1
- package/dist/items/helpers/MappingSetup.js +0 -126
- package/dist/items/helpers/MappingSetup.js.map +0 -1
- package/dist/json/packageVersionInfo.json +0 -6
- package/dist/json/shortcuts.json +0 -37
- package/dist/renderers/ForwardRenderer.js +0 -50
- package/dist/renderers/ForwardRenderer.js.map +0 -1
- package/dist/renderers/RendererBase.js +0 -38
- package/dist/renderers/RendererBase.js.map +0 -1
- package/dist/scenegraph/SgAudio.js +0 -286
- package/dist/scenegraph/SgAudio.js.map +0 -1
- package/dist/scenegraph/SgAudioListener.js +0 -64
- package/dist/scenegraph/SgAudioListener.js.map +0 -1
- package/dist/scenegraph/SgBillboard.js +0 -150
- package/dist/scenegraph/SgBillboard.js.map +0 -1
- package/dist/scenegraph/SgBox.js +0 -54
- package/dist/scenegraph/SgBox.js.map +0 -1
- package/dist/scenegraph/SgCamera.js +0 -219
- package/dist/scenegraph/SgCamera.js.map +0 -1
- package/dist/scenegraph/SgCircleShadow.js +0 -105
- package/dist/scenegraph/SgCircleShadow.js.map +0 -1
- package/dist/scenegraph/SgCone.js +0 -61
- package/dist/scenegraph/SgCone.js.map +0 -1
- package/dist/scenegraph/SgCylinder.js +0 -62
- package/dist/scenegraph/SgCylinder.js.map +0 -1
- package/dist/scenegraph/SgGaussianSplats.js +0 -103
- package/dist/scenegraph/SgGaussianSplats.js.map +0 -1
- package/dist/scenegraph/SgGridMap.js +0 -112
- package/dist/scenegraph/SgGridMap.js.map +0 -1
- package/dist/scenegraph/SgGroup.js +0 -40
- package/dist/scenegraph/SgGroup.js.map +0 -1
- package/dist/scenegraph/SgItem.js +0 -1427
- package/dist/scenegraph/SgItem.js.map +0 -1
- package/dist/scenegraph/SgItemScript.js +0 -117
- package/dist/scenegraph/SgItemScript.js.map +0 -1
- package/dist/scenegraph/SgLightsource.js +0 -319
- package/dist/scenegraph/SgLightsource.js.map +0 -1
- package/dist/scenegraph/SgLod.js +0 -82
- package/dist/scenegraph/SgLod.js.map +0 -1
- package/dist/scenegraph/SgMesh.js +0 -662
- package/dist/scenegraph/SgMesh.js.map +0 -1
- package/dist/scenegraph/SgNavMesh.js +0 -503
- package/dist/scenegraph/SgNavMesh.js.map +0 -1
- package/dist/scenegraph/SgParticles.js +0 -796
- package/dist/scenegraph/SgParticles.js.map +0 -1
- package/dist/scenegraph/SgPhysicsItem.js +0 -806
- package/dist/scenegraph/SgPhysicsItem.js.map +0 -1
- package/dist/scenegraph/SgPhysicsSubItem.js +0 -449
- package/dist/scenegraph/SgPhysicsSubItem.js.map +0 -1
- package/dist/scenegraph/SgPlane.js +0 -47
- package/dist/scenegraph/SgPlane.js.map +0 -1
- package/dist/scenegraph/SgPoints.js +0 -143
- package/dist/scenegraph/SgPoints.js.map +0 -1
- package/dist/scenegraph/SgPositionalAudio.js +0 -93
- package/dist/scenegraph/SgPositionalAudio.js.map +0 -1
- package/dist/scenegraph/SgPrefab.js +0 -153
- package/dist/scenegraph/SgPrefab.js.map +0 -1
- package/dist/scenegraph/SgProceduralGeometryItem.js +0 -146
- package/dist/scenegraph/SgProceduralGeometryItem.js.map +0 -1
- package/dist/scenegraph/SgResourceOwner.js +0 -127
- package/dist/scenegraph/SgResourceOwner.js.map +0 -1
- package/dist/scenegraph/SgRibbon.js +0 -107
- package/dist/scenegraph/SgRibbon.js.map +0 -1
- package/dist/scenegraph/SgRing.js +0 -49
- package/dist/scenegraph/SgRing.js.map +0 -1
- package/dist/scenegraph/SgRoot.js +0 -87
- package/dist/scenegraph/SgRoot.js.map +0 -1
- package/dist/scenegraph/SgScriptedMesh.js +0 -213
- package/dist/scenegraph/SgScriptedMesh.js.map +0 -1
- package/dist/scenegraph/SgSky.js +0 -126
- package/dist/scenegraph/SgSky.js.map +0 -1
- package/dist/scenegraph/SgSphere.js +0 -59
- package/dist/scenegraph/SgSphere.js.map +0 -1
- package/dist/scenegraph/SgText.js +0 -182
- package/dist/scenegraph/SgText.js.map +0 -1
- package/dist/scenegraph/SgTorus.js +0 -48
- package/dist/scenegraph/SgTorus.js.map +0 -1
- package/dist/scenegraph/SgVehicle.js +0 -370
- package/dist/scenegraph/SgVehicle.js.map +0 -1
- package/dist/subsystems/AudioSystem.js +0 -128
- package/dist/subsystems/AudioSystem.js.map +0 -1
- package/dist/subsystems/Billboard.js +0 -190
- package/dist/subsystems/Billboard.js.map +0 -1
- package/dist/subsystems/FontLoader.js +0 -161
- package/dist/subsystems/FontLoader.js.map +0 -1
- package/dist/subsystems/Physics.js +0 -1079
- package/dist/subsystems/Physics.js.map +0 -1
- package/dist/subsystems/Ribbons.js +0 -179
- package/dist/subsystems/Ribbons.js.map +0 -1
- package/dist/subsystems/gridmap/GridMapBuilder.js +0 -430
- package/dist/subsystems/gridmap/GridMapBuilder.js.map +0 -1
- package/dist/subsystems/imgui/ImGui.js +0 -742
- package/dist/subsystems/imgui/ImGui.js.map +0 -1
- package/dist/subsystems/importer/Converter.js +0 -199
- package/dist/subsystems/importer/Converter.js.map +0 -1
- package/dist/subsystems/importer/ImageConverter.js +0 -77
- package/dist/subsystems/importer/ImageConverter.js.map +0 -1
- package/dist/subsystems/importer/Importer.js +0 -381
- package/dist/subsystems/importer/Importer.js.map +0 -1
- package/dist/subsystems/importer/MeshConverter.js +0 -595
- package/dist/subsystems/importer/MeshConverter.js.map +0 -1
- package/dist/subsystems/particlesystem/CurlNoiseTexturePreview.js +0 -127
- package/dist/subsystems/particlesystem/CurlNoiseTexturePreview.js.map +0 -1
- package/dist/subsystems/particlesystem/Emitters/CircleEmitter.js +0 -135
- package/dist/subsystems/particlesystem/Emitters/CircleEmitter.js.map +0 -1
- package/dist/subsystems/particlesystem/Emitters/ConeEmitter.js +0 -192
- package/dist/subsystems/particlesystem/Emitters/ConeEmitter.js.map +0 -1
- package/dist/subsystems/particlesystem/Emitters/CubeEmitter.js +0 -157
- package/dist/subsystems/particlesystem/Emitters/CubeEmitter.js.map +0 -1
- package/dist/subsystems/particlesystem/Emitters/EdgeEmitter.js +0 -133
- package/dist/subsystems/particlesystem/Emitters/EdgeEmitter.js.map +0 -1
- package/dist/subsystems/particlesystem/Emitters/Emitter.js +0 -107
- package/dist/subsystems/particlesystem/Emitters/Emitter.js.map +0 -1
- package/dist/subsystems/particlesystem/Emitters/HemiSphereEmitter.js +0 -142
- package/dist/subsystems/particlesystem/Emitters/HemiSphereEmitter.js.map +0 -1
- package/dist/subsystems/particlesystem/Emitters/MeshEmitter.js +0 -56
- package/dist/subsystems/particlesystem/Emitters/MeshEmitter.js.map +0 -1
- package/dist/subsystems/particlesystem/Emitters/SphereEmitter.js +0 -142
- package/dist/subsystems/particlesystem/Emitters/SphereEmitter.js.map +0 -1
- package/dist/subsystems/particlesystem/Emitters/TorusEmitter.js +0 -159
- package/dist/subsystems/particlesystem/Emitters/TorusEmitter.js.map +0 -1
- package/dist/subsystems/particlesystem/ParticleSystem.js +0 -706
- package/dist/subsystems/particlesystem/ParticleSystem.js.map +0 -1
- package/dist/subsystems/particlesystem/Simulation.js +0 -475
- package/dist/subsystems/particlesystem/Simulation.js.map +0 -1
- package/dist/subsystems/particlesystem/Visualization.js +0 -518
- package/dist/subsystems/particlesystem/Visualization.js.map +0 -1
- package/dist/subsystems/particlesystem/shaders/noise/CurlNoiseTexturePreviewShader.js +0 -56
- package/dist/subsystems/particlesystem/shaders/noise/CurlNoiseTexturePreviewShader.js.map +0 -1
- package/dist/subsystems/particlesystem/utils.js +0 -115
- package/dist/subsystems/particlesystem/utils.js.map +0 -1
- package/dist/subsystems/scripting/ScriptEngine.js +0 -1074
- package/dist/subsystems/scripting/ScriptEngine.js.map +0 -1
- package/dist/subsystems/scripting/ScriptRunner.js +0 -153
- package/dist/subsystems/scripting/ScriptRunner.js.map +0 -1
- package/dist/subsystems/scripting/ScriptRuntime.js +0 -244
- package/dist/subsystems/scripting/ScriptRuntime.js.map +0 -1
- package/dist/subsystems/scripting/runtime/RtAudio.js +0 -37
- package/dist/subsystems/scripting/runtime/RtAudio.js.map +0 -1
- package/dist/subsystems/scripting/runtime/RtBase.js +0 -117
- package/dist/subsystems/scripting/runtime/RtBase.js.map +0 -1
- package/dist/subsystems/scripting/runtime/RtCanvas.js +0 -326
- package/dist/subsystems/scripting/runtime/RtCanvas.js.map +0 -1
- package/dist/subsystems/scripting/runtime/RtComposer.js +0 -58
- package/dist/subsystems/scripting/runtime/RtComposer.js.map +0 -1
- package/dist/subsystems/scripting/runtime/RtConsole.js +0 -51
- package/dist/subsystems/scripting/runtime/RtConsole.js.map +0 -1
- package/dist/subsystems/scripting/runtime/RtControllers.js +0 -52
- package/dist/subsystems/scripting/runtime/RtControllers.js.map +0 -1
- package/dist/subsystems/scripting/runtime/RtEvents.js +0 -46
- package/dist/subsystems/scripting/runtime/RtEvents.js.map +0 -1
- package/dist/subsystems/scripting/runtime/RtImGui.js +0 -410
- package/dist/subsystems/scripting/runtime/RtImGui.js.map +0 -1
- package/dist/subsystems/scripting/runtime/RtItem.js +0 -297
- package/dist/subsystems/scripting/runtime/RtItem.js.map +0 -1
- package/dist/subsystems/scripting/runtime/RtLoader.js +0 -77
- package/dist/subsystems/scripting/runtime/RtLoader.js.map +0 -1
- package/dist/subsystems/scripting/runtime/RtObject.js +0 -34
- package/dist/subsystems/scripting/runtime/RtObject.js.map +0 -1
- package/dist/subsystems/scripting/runtime/RtPhysics.js +0 -69
- package/dist/subsystems/scripting/runtime/RtPhysics.js.map +0 -1
- package/dist/subsystems/scripting/runtime/RtPointer.js +0 -45
- package/dist/subsystems/scripting/runtime/RtPointer.js.map +0 -1
- package/dist/subsystems/scripting/runtime/RtProject.js +0 -66
- package/dist/subsystems/scripting/runtime/RtProject.js.map +0 -1
- package/dist/subsystems/scripting/runtime/RtRenderer.js +0 -138
- package/dist/subsystems/scripting/runtime/RtRenderer.js.map +0 -1
- package/dist/subsystems/scripting/runtime/RtSceneEntry.js +0 -67
- package/dist/subsystems/scripting/runtime/RtSceneEntry.js.map +0 -1
- package/dist/subsystems/scripting/runtime/RtSceneObject.js +0 -666
- package/dist/subsystems/scripting/runtime/RtSceneObject.js.map +0 -1
- package/dist/subsystems/scripting/runtime/RtStorage.js +0 -64
- package/dist/subsystems/scripting/runtime/RtStorage.js.map +0 -1
- package/dist/subsystems/scripting/runtime/RtSystem.js +0 -85
- package/dist/subsystems/scripting/runtime/RtSystem.js.map +0 -1
- package/dist/subsystems/scripting/runtime/RtTools.js +0 -37
- package/dist/subsystems/scripting/runtime/RtTools.js.map +0 -1
- package/dist/subsystems/scripting/runtime/RtVariables.js +0 -57
- package/dist/subsystems/scripting/runtime/RtVariables.js.map +0 -1
- package/dist/subsystems/scripting/runtime/items/RtCanvasTexture.js +0 -101
- package/dist/subsystems/scripting/runtime/items/RtCanvasTexture.js.map +0 -1
- package/dist/subsystems/scripting/runtime/items/RtMaterial.js +0 -34
- package/dist/subsystems/scripting/runtime/items/RtMaterial.js.map +0 -1
- package/dist/subsystems/scripting/runtime/items/RtMesh.js +0 -34
- package/dist/subsystems/scripting/runtime/items/RtMesh.js.map +0 -1
- package/dist/subsystems/scripting/runtime/items/RtTexture.js +0 -34
- package/dist/subsystems/scripting/runtime/items/RtTexture.js.map +0 -1
- package/dist/subsystems/scripting/runtime/items/RtVideo.js +0 -56
- package/dist/subsystems/scripting/runtime/items/RtVideo.js.map +0 -1
- package/dist/subsystems/scripting/runtime/sceneobjects/RtSgAudio.js +0 -59
- package/dist/subsystems/scripting/runtime/sceneobjects/RtSgAudio.js.map +0 -1
- package/dist/subsystems/scripting/runtime/sceneobjects/RtSgCamera.js +0 -134
- package/dist/subsystems/scripting/runtime/sceneobjects/RtSgCamera.js.map +0 -1
- package/dist/subsystems/scripting/runtime/sceneobjects/RtSgMesh.js +0 -99
- package/dist/subsystems/scripting/runtime/sceneobjects/RtSgMesh.js.map +0 -1
- package/dist/subsystems/scripting/runtime/sceneobjects/RtSgNavMesh.js +0 -114
- package/dist/subsystems/scripting/runtime/sceneobjects/RtSgNavMesh.js.map +0 -1
- package/dist/subsystems/scripting/runtime/sceneobjects/RtSgParticles.js +0 -576
- package/dist/subsystems/scripting/runtime/sceneobjects/RtSgParticles.js.map +0 -1
- package/dist/subsystems/scripting/runtime/sceneobjects/RtSgPositionalAudio.js +0 -56
- package/dist/subsystems/scripting/runtime/sceneobjects/RtSgPositionalAudio.js.map +0 -1
- package/dist/subsystems/scripting/runtime/sceneobjects/RtSgRibbon.js +0 -42
- package/dist/subsystems/scripting/runtime/sceneobjects/RtSgRibbon.js.map +0 -1
- package/dist/subsystems/scripting/runtime/sceneobjects/RtSgScriptedMesh.js +0 -65
- package/dist/subsystems/scripting/runtime/sceneobjects/RtSgScriptedMesh.js.map +0 -1
- package/dist/subsystems/scripting/runtime/sceneobjects/RtSgVehicle.js +0 -60
- package/dist/subsystems/scripting/runtime/sceneobjects/RtSgVehicle.js.map +0 -1
- package/dist/tools/AsyncInterval.js +0 -55
- package/dist/tools/AsyncInterval.js.map +0 -1
- package/dist/tools/Converters.js +0 -41
- package/dist/tools/Converters.js.map +0 -1
- package/dist/tools/DebugTools.js +0 -91
- package/dist/tools/DebugTools.js.map +0 -1
- package/dist/tools/FontTools.js +0 -43
- package/dist/tools/FontTools.js.map +0 -1
- package/dist/tools/FsShader.js +0 -112
- package/dist/tools/FsShader.js.map +0 -1
- package/dist/tools/GeometryTools.js +0 -373
- package/dist/tools/GeometryTools.js.map +0 -1
- package/dist/tools/ItemTools.js +0 -139
- package/dist/tools/ItemTools.js.map +0 -1
- package/dist/tools/MathHelpers.js +0 -125
- package/dist/tools/MathHelpers.js.map +0 -1
- package/dist/tools/Profiler.js +0 -174
- package/dist/tools/Profiler.js.map +0 -1
- package/dist/tools/Random.js +0 -48
- package/dist/tools/Random.js.map +0 -1
- package/dist/tools/RtDebugger.js +0 -84
- package/dist/tools/RtDebugger.js.map +0 -1
- package/dist/tools/StringExtensions.js +0 -72
- package/dist/tools/StringExtensions.js.map +0 -1
- package/dist/tools/TextureTools.js +0 -444
- package/dist/tools/TextureTools.js.map +0 -1
- package/dist/tools/Timer.js +0 -52
- package/dist/tools/Timer.js.map +0 -1
- package/dist/tools/audioVisualizers/WavyAudioVisualizer.js +0 -59
- package/dist/tools/audioVisualizers/WavyAudioVisualizer.js.map +0 -1
- /package/dist/renderers/{forwardrenderer.d.ts → ForwardRenderer.d.ts} +0 -0
- /package/dist/subsystems/imgui/{imgui.d.ts → ImGui.d.ts} +0 -0
- /package/dist/subsystems/importer/{imageconverter.d.ts → ImageConverter.d.ts} +0 -0
- /package/dist/subsystems/scripting/{scriptrunner.d.ts → ScriptRunner.d.ts} +0 -0
- /package/dist/subsystems/scripting/{scriptruntime.d.ts → ScriptRuntime.d.ts} +0 -0
- /package/dist/subsystems/scripting/runtime/{rtAudio.d.ts → RtAudio.d.ts} +0 -0
- /package/dist/subsystems/scripting/runtime/{rtComposer.d.ts → RtComposer.d.ts} +0 -0
- /package/dist/subsystems/scripting/runtime/{rtObject.d.ts → RtObject.d.ts} +0 -0
|
@@ -1,1427 +0,0 @@
|
|
|
1
|
-
// -----------------------------------------------------------------------------------------------------------
|
|
2
|
-
// __ ______ __ __ ______ __ __ ______ ______ ______
|
|
3
|
-
// /\ \ /\ ___\ /\ "-./ \ /\ __ \ /\ "-.\ \ /\ __ \ /\__ _\ /\ ___\
|
|
4
|
-
// \ \ \____ \ \ __\ \ \ \-./\ \ \ \ \/\ \ \ \ \-. \ \ \ __ \ \/_/\ \/ \ \ __\
|
|
5
|
-
// \ \_____\ \ \_____\ \ \_\ \ \_\ \ \_____\ \ \_\\"\_\ \ \_\ \_\ \ \_\ \ \_____\
|
|
6
|
-
// \/_____/ \/_____/ \/_/ \/_/ \/_____/ \/_/ \/_/ \/_/\/_/ \/_/ \/_____/
|
|
7
|
-
//
|
|
8
|
-
//
|
|
9
|
-
// Copyright 2023- Luminocity AG
|
|
10
|
-
//
|
|
11
|
-
// "I am Error." - The Legend of Zelda: Majora’s Mask (2000)
|
|
12
|
-
//
|
|
13
|
-
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software
|
|
14
|
-
// and associated documentation files (the “Software”), to deal in the Software without restriction,
|
|
15
|
-
// including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
16
|
-
// and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
|
|
17
|
-
// subject to the following conditions:
|
|
18
|
-
//
|
|
19
|
-
// The above copyright notice and this permission notice shall be included in all copies or substantial
|
|
20
|
-
// portions of the Software.
|
|
21
|
-
//
|
|
22
|
-
// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
|
23
|
-
// LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
24
|
-
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
25
|
-
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
26
|
-
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
27
|
-
// -----------------------------------------------------------------------------------------------------------
|
|
28
|
-
import { Color, MeshPhysicalMaterial, MeshStandardMaterial, MeshBasicMaterial, Object3D, Quaternion, Vector3, Box3, Matrix4, BackSide, DoubleSide, Group, Mesh } from 'three';
|
|
29
|
-
import { E_CANCELED, Mutex } from 'async-mutex';
|
|
30
|
-
import tools from '../Tools.js';
|
|
31
|
-
import { VertexNormalsHelper } from "@/helpers/VertexNormalsHelper";
|
|
32
|
-
import { FaceNormalsHelper } from '@/helpers/FaceNormalsHelper';
|
|
33
|
-
import { BoxHelper } from '@/helpers/BoxHelper';
|
|
34
|
-
import { layerIndexHelper, LayerIndexNormalsHelper } from '@/Renderer';
|
|
35
|
-
import { SgItemScript } from "./SgItemScript";
|
|
36
|
-
import { SgResourceOwner } from "./SgResourceOwner";
|
|
37
|
-
import { Block } from "@luminocity/lemonate-gateway";
|
|
38
|
-
export var SgItemState;
|
|
39
|
-
(function (SgItemState) {
|
|
40
|
-
SgItemState[SgItemState["Constructed"] = 1] = "Constructed";
|
|
41
|
-
SgItemState[SgItemState["Created"] = 2] = "Created";
|
|
42
|
-
SgItemState[SgItemState["ToDestroy"] = 3] = "ToDestroy";
|
|
43
|
-
SgItemState[SgItemState["Destroyed"] = 4] = "Destroyed";
|
|
44
|
-
})(SgItemState || (SgItemState = {}));
|
|
45
|
-
export class SgItem extends SgResourceOwner {
|
|
46
|
-
//The block stores the underlying model of the SgItem. It must be set. If it is not passed, an empty one will be created.
|
|
47
|
-
block;
|
|
48
|
-
state;
|
|
49
|
-
fieldMap; // quick lookup of fields by name
|
|
50
|
-
parent;
|
|
51
|
-
scene;
|
|
52
|
-
sceneGraph;
|
|
53
|
-
engine;
|
|
54
|
-
renderer;
|
|
55
|
-
itemRepo;
|
|
56
|
-
editorMode;
|
|
57
|
-
selected = false;
|
|
58
|
-
children = [];
|
|
59
|
-
itemId;
|
|
60
|
-
visible = true;
|
|
61
|
-
autoRecreate = true;
|
|
62
|
-
recreationMutex = new Mutex();
|
|
63
|
-
container = new Group();
|
|
64
|
-
boxHelper;
|
|
65
|
-
normalsHelpers = [];
|
|
66
|
-
scripts = [];
|
|
67
|
-
updateListeners = {};
|
|
68
|
-
// resources, that might better be stored in SgResourceOwner
|
|
69
|
-
material;
|
|
70
|
-
font;
|
|
71
|
-
ownMaterial;
|
|
72
|
-
prefabItem;
|
|
73
|
-
_isPlaying = false;
|
|
74
|
-
_updateContentHook;
|
|
75
|
-
constructor(block, parent, scene, engine, position, sceneGraph) {
|
|
76
|
-
super(engine);
|
|
77
|
-
tools.assert(sceneGraph, 'Scenegraph to add to needs to be specified');
|
|
78
|
-
tools.assert(!block || block instanceof Block, "block must be of type Block!");
|
|
79
|
-
tools.assert(!block || Array.isArray(block.fields), `Field instances for block is not an array! ${block}`);
|
|
80
|
-
this.block = block || new Block();
|
|
81
|
-
this.state = SgItemState.Constructed;
|
|
82
|
-
this.fieldMap = new Map(); // quick lookup of fields by name
|
|
83
|
-
this.parent = parent;
|
|
84
|
-
this.scene = scene;
|
|
85
|
-
this.sceneGraph = sceneGraph;
|
|
86
|
-
this.engine = engine;
|
|
87
|
-
this.renderer = engine.renderer;
|
|
88
|
-
this.itemRepo = engine.itemRepo;
|
|
89
|
-
this.editorMode = engine.editorMode;
|
|
90
|
-
this.container.name = `${this.getType()}Container`;
|
|
91
|
-
this._updateContentHook = (item) => {
|
|
92
|
-
if (!item) {
|
|
93
|
-
console.warn("Update content hook called without item.");
|
|
94
|
-
return;
|
|
95
|
-
}
|
|
96
|
-
const updatedItemId = item.getId();
|
|
97
|
-
const thisItemId = this.getItemId();
|
|
98
|
-
if (thisItemId && updatedItemId === thisItemId) {
|
|
99
|
-
this.destroyHelpers();
|
|
100
|
-
this.createHelpers();
|
|
101
|
-
this.addHelpersToScene();
|
|
102
|
-
}
|
|
103
|
-
};
|
|
104
|
-
this.updateListeners.block = this.engine.addUpdateListener(this.block.id, (field, value, type, oldValue) => {
|
|
105
|
-
this.updateEvent(field, value, type, oldValue);
|
|
106
|
-
});
|
|
107
|
-
if (this.parent) {
|
|
108
|
-
this.parent.add(this, position);
|
|
109
|
-
}
|
|
110
|
-
// correct old layers entries which contained 10 true/false values
|
|
111
|
-
const layers = this.getFieldValue("Layers");
|
|
112
|
-
if (layers && (!Array.isArray(layers) || layers[0] === true || layers[0] === false)) {
|
|
113
|
-
this.setFieldValue("Layers", [0]);
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
getScripts() {
|
|
117
|
-
return this.scripts;
|
|
118
|
-
}
|
|
119
|
-
getSceneGraph() {
|
|
120
|
-
return this.sceneGraph;
|
|
121
|
-
}
|
|
122
|
-
isCreated() {
|
|
123
|
-
return this.state === SgItemState.Created;
|
|
124
|
-
}
|
|
125
|
-
waitForCreated() {
|
|
126
|
-
return new Promise((resolve, reject) => {
|
|
127
|
-
// Immediately resolve if the state is already created
|
|
128
|
-
if (this.state === SgItemState.Created) {
|
|
129
|
-
resolve(this);
|
|
130
|
-
return;
|
|
131
|
-
}
|
|
132
|
-
// Set up a timeout to reject if the state isn't created in time
|
|
133
|
-
const timeout = setTimeout(() => {
|
|
134
|
-
this.$off('sgitem:recreated', onRecreated);
|
|
135
|
-
reject(new Error('Timeout waiting for created state.'));
|
|
136
|
-
}, 3000);
|
|
137
|
-
// Event listener to resolve the promise when the state changes
|
|
138
|
-
const onRecreated = () => {
|
|
139
|
-
clearTimeout(timeout);
|
|
140
|
-
this.$off('sgitem:recreated', onRecreated);
|
|
141
|
-
resolve(this);
|
|
142
|
-
};
|
|
143
|
-
this.$on('sgitem:recreated', onRecreated);
|
|
144
|
-
});
|
|
145
|
-
}
|
|
146
|
-
getParent() {
|
|
147
|
-
if (this.parent && this.parent.getType() === "Scene") {
|
|
148
|
-
// if our parent is a scene, check if it is a prefab scene. If so, we go one more step up to get to the prefab.
|
|
149
|
-
const prefab = this.parent.getParent();
|
|
150
|
-
if (prefab && prefab.getType() === "Prefab")
|
|
151
|
-
return prefab;
|
|
152
|
-
}
|
|
153
|
-
return this.parent;
|
|
154
|
-
}
|
|
155
|
-
getChildren() {
|
|
156
|
-
return this.children;
|
|
157
|
-
}
|
|
158
|
-
// Returns containing sgPrefab. If item is on top level, return item itself
|
|
159
|
-
getTopLevelItem() {
|
|
160
|
-
let currNode = this;
|
|
161
|
-
while (currNode) {
|
|
162
|
-
const containingPrefab = currNode.sceneGraph.root.parent;
|
|
163
|
-
if (containingPrefab) {
|
|
164
|
-
currNode = containingPrefab;
|
|
165
|
-
}
|
|
166
|
-
else {
|
|
167
|
-
return currNode;
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
return this;
|
|
171
|
-
}
|
|
172
|
-
async createFromThis(fieldOverrides, parent) {
|
|
173
|
-
parent = parent ?? this.parent;
|
|
174
|
-
const field = this.sceneGraph.sceneItem.fieldInstances.find(f => f.name === "Scenegraph");
|
|
175
|
-
const cloneResult = await this.engine.apiClient.serializer.clone(this.block, field, parent.block, this.sceneGraph.getOwnerItem(), {
|
|
176
|
-
dontCopyScripts: this._isPlaying,
|
|
177
|
-
fieldOverrides
|
|
178
|
-
});
|
|
179
|
-
const newBlock = cloneResult[0];
|
|
180
|
-
const newBlockDescendants = newBlock.getDescendantBlocks([newBlock]);
|
|
181
|
-
const itemPromises = newBlockDescendants.map((block) => {
|
|
182
|
-
return new Promise(async (resolve, reject) => {
|
|
183
|
-
const result = await this.sceneGraph.findOrWaitForItemByBlockId(block.id);
|
|
184
|
-
await result.node.waitForCreated();
|
|
185
|
-
resolve(result.node);
|
|
186
|
-
});
|
|
187
|
-
});
|
|
188
|
-
const newItems = await Promise.all(itemPromises);
|
|
189
|
-
const newItem = newItems[0];
|
|
190
|
-
const clonedScripts = this.itemRepo.copyScripts(this.block, newBlock, this._isPlaying);
|
|
191
|
-
// wait for all new scripts to have been added to the player, if playing
|
|
192
|
-
if (this._isPlaying) {
|
|
193
|
-
const player = this.engine.player;
|
|
194
|
-
await Promise.all(clonedScripts.map(script => player.waitForScriptAdded(script)));
|
|
195
|
-
// now initialize scripts in a top down, breadth-first order (same as in cloning procedure)
|
|
196
|
-
for (const scriptMeta of clonedScripts) {
|
|
197
|
-
const scriptEntry = player.getScriptEntryFromMetaScript(scriptMeta);
|
|
198
|
-
await player.initializeScript(scriptEntry);
|
|
199
|
-
scriptMeta.deferInitCall = false;
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
return newItem;
|
|
203
|
-
}
|
|
204
|
-
async clone(x, y, z, parent) {
|
|
205
|
-
const oldTransform = this.getFieldValue("Transform");
|
|
206
|
-
return this.createFromThis({ Transform: {
|
|
207
|
-
position: {
|
|
208
|
-
x: x ?? oldTransform.position.x,
|
|
209
|
-
y: y ?? oldTransform.position.y,
|
|
210
|
-
z: z ?? oldTransform.position.z
|
|
211
|
-
},
|
|
212
|
-
rotation: oldTransform.rotation,
|
|
213
|
-
scale: oldTransform.scale
|
|
214
|
-
} }, parent);
|
|
215
|
-
}
|
|
216
|
-
moveToParent(parent) {
|
|
217
|
-
parent = parent || this.block.getRoot();
|
|
218
|
-
this.block.moveToParent(parent.block.id);
|
|
219
|
-
}
|
|
220
|
-
detachFromParent() {
|
|
221
|
-
if (this.parent)
|
|
222
|
-
this.itemRepo.removeBlock(this.block, this.parent.block);
|
|
223
|
-
}
|
|
224
|
-
getId() {
|
|
225
|
-
return this.block.id;
|
|
226
|
-
}
|
|
227
|
-
getType() {
|
|
228
|
-
return "Item";
|
|
229
|
-
}
|
|
230
|
-
hasTag(tag) {
|
|
231
|
-
return this.block && this.block.hasTag(tag);
|
|
232
|
-
}
|
|
233
|
-
hasOneTag(tags) {
|
|
234
|
-
return this.block && this.block.hasOneTag(tags);
|
|
235
|
-
}
|
|
236
|
-
isInLayer(layer) {
|
|
237
|
-
const layers = this.getFieldValue("Layers");
|
|
238
|
-
if (Array.isArray(layers)) {
|
|
239
|
-
return layers.includes(layer);
|
|
240
|
-
}
|
|
241
|
-
return false;
|
|
242
|
-
}
|
|
243
|
-
isInOneLayer(layers) {
|
|
244
|
-
const actualLayers = this.getFieldValue("Layers");
|
|
245
|
-
if (Array.isArray(actualLayers)) {
|
|
246
|
-
for (const layer of layers) {
|
|
247
|
-
if (actualLayers.includes(layer))
|
|
248
|
-
return true;
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
return false;
|
|
252
|
-
}
|
|
253
|
-
play() {
|
|
254
|
-
this._isPlaying = true;
|
|
255
|
-
}
|
|
256
|
-
stop() {
|
|
257
|
-
this._isPlaying = false;
|
|
258
|
-
this.autoRecreate = true;
|
|
259
|
-
}
|
|
260
|
-
pause() {
|
|
261
|
-
}
|
|
262
|
-
resume() {
|
|
263
|
-
}
|
|
264
|
-
setActive(active) {
|
|
265
|
-
if (!active) {
|
|
266
|
-
try {
|
|
267
|
-
this.deactivate();
|
|
268
|
-
}
|
|
269
|
-
catch (err) {
|
|
270
|
-
console.error("Error when deactivating: ", err);
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
this.show(active);
|
|
274
|
-
if (active) {
|
|
275
|
-
try {
|
|
276
|
-
this.activate();
|
|
277
|
-
}
|
|
278
|
-
catch (err) {
|
|
279
|
-
console.error("Error when deactivating: ", err);
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
activate() {
|
|
284
|
-
for (const child of this.children) {
|
|
285
|
-
child.activate();
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
deactivate() {
|
|
289
|
-
for (const child of this.children) {
|
|
290
|
-
child.deactivate();
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
isEnabled() {
|
|
294
|
-
return this.getFieldValue("Active");
|
|
295
|
-
}
|
|
296
|
-
enable() {
|
|
297
|
-
if (!this.isEnabled())
|
|
298
|
-
this.setFieldValue("Active", true);
|
|
299
|
-
}
|
|
300
|
-
disable() {
|
|
301
|
-
if (this.isEnabled())
|
|
302
|
-
this.setFieldValue("Active", false);
|
|
303
|
-
}
|
|
304
|
-
getItemId() {
|
|
305
|
-
if (typeof this.getItem !== 'function')
|
|
306
|
-
return null;
|
|
307
|
-
const item = this.getItem();
|
|
308
|
-
if (!item)
|
|
309
|
-
return null;
|
|
310
|
-
return item.getId();
|
|
311
|
-
}
|
|
312
|
-
getItem() {
|
|
313
|
-
return undefined;
|
|
314
|
-
}
|
|
315
|
-
isPhysicsItem() {
|
|
316
|
-
return false;
|
|
317
|
-
}
|
|
318
|
-
isParticlesItem() {
|
|
319
|
-
return this.getType() === "Particles";
|
|
320
|
-
}
|
|
321
|
-
isFileContentModified() {
|
|
322
|
-
const item = this.getItem();
|
|
323
|
-
if (item && item.isFileContentModified())
|
|
324
|
-
return true;
|
|
325
|
-
return this.areScriptsModified();
|
|
326
|
-
}
|
|
327
|
-
async saveFileContent() {
|
|
328
|
-
const promises = [];
|
|
329
|
-
const item = this.getItem();
|
|
330
|
-
if (item)
|
|
331
|
-
promises.push(item.saveFileContent());
|
|
332
|
-
promises.push(this.saveScriptContent());
|
|
333
|
-
return Promise.all(promises);
|
|
334
|
-
}
|
|
335
|
-
areScriptsModified() {
|
|
336
|
-
for (const script of this.scripts) {
|
|
337
|
-
if (script.isFileContentModified())
|
|
338
|
-
return true;
|
|
339
|
-
}
|
|
340
|
-
return false;
|
|
341
|
-
}
|
|
342
|
-
async saveScriptContent() {
|
|
343
|
-
const promises = [];
|
|
344
|
-
for (const script of this.scripts) {
|
|
345
|
-
if (script.isFileContentModified())
|
|
346
|
-
promises.push(script.saveFileContent());
|
|
347
|
-
}
|
|
348
|
-
return Promise.all(promises);
|
|
349
|
-
}
|
|
350
|
-
isAnimated() {
|
|
351
|
-
return false;
|
|
352
|
-
}
|
|
353
|
-
getAnimations() {
|
|
354
|
-
return [];
|
|
355
|
-
}
|
|
356
|
-
getDisplayName() {
|
|
357
|
-
const name = this.getFieldValue("Name");
|
|
358
|
-
if (name)
|
|
359
|
-
return name;
|
|
360
|
-
const type = this.getType();
|
|
361
|
-
const id = this.getId();
|
|
362
|
-
const truncatedId = id.length > 12 ? `...${id.slice(-12)}` : id;
|
|
363
|
-
return `<${type} (${truncatedId})>`;
|
|
364
|
-
}
|
|
365
|
-
getName() {
|
|
366
|
-
return this.getFieldValue("Name");
|
|
367
|
-
}
|
|
368
|
-
_sceneUpdated() {
|
|
369
|
-
this.engine.eventBus.$emit('scene:updated', this.scene, this);
|
|
370
|
-
this.$emit('updated', this);
|
|
371
|
-
}
|
|
372
|
-
traverseChildren(func, omitSelf = false) {
|
|
373
|
-
if (!omitSelf)
|
|
374
|
-
func(this);
|
|
375
|
-
for (const child of this.children) {
|
|
376
|
-
child.traverseChildren(func);
|
|
377
|
-
}
|
|
378
|
-
}
|
|
379
|
-
/**
|
|
380
|
-
* This function should be overloaded and return any items, the object is using. For example SgMesh should return
|
|
381
|
-
* its internal mesh and material objects or if not yet loaded, the item dataset or item id
|
|
382
|
-
* @returns {*[]}
|
|
383
|
-
*/
|
|
384
|
-
enumerateItemChildren() {
|
|
385
|
-
return [];
|
|
386
|
-
}
|
|
387
|
-
_getChildOrLinkItem(fieldName, linkUsage) {
|
|
388
|
-
const child = this[fieldName];
|
|
389
|
-
if (child)
|
|
390
|
-
return child;
|
|
391
|
-
const linkItem = this.getFieldValue(linkUsage);
|
|
392
|
-
if (linkItem)
|
|
393
|
-
return linkItem;
|
|
394
|
-
return null;
|
|
395
|
-
}
|
|
396
|
-
setContentHookEnabled(value) {
|
|
397
|
-
if (value)
|
|
398
|
-
this.engine.eventBus.$on('item:contentUpdated', this._updateContentHook);
|
|
399
|
-
else
|
|
400
|
-
this.engine.eventBus.$off('item:contentUpdated', this._updateContentHook);
|
|
401
|
-
}
|
|
402
|
-
configure(cfg) {
|
|
403
|
-
if (!cfg)
|
|
404
|
-
return;
|
|
405
|
-
for (const name in cfg) {
|
|
406
|
-
if (cfg.hasOwnProperty(name)) {
|
|
407
|
-
this.setFieldValue(name, cfg[name]);
|
|
408
|
-
}
|
|
409
|
-
}
|
|
410
|
-
}
|
|
411
|
-
async _initScripts() {
|
|
412
|
-
this.scripts = [];
|
|
413
|
-
if (Array.isArray(this.block && this.block.scripts)) {
|
|
414
|
-
for (const scriptMeta of this.block.scripts) {
|
|
415
|
-
await this.addScript(scriptMeta);
|
|
416
|
-
}
|
|
417
|
-
}
|
|
418
|
-
}
|
|
419
|
-
async _setScriptsEnabled(value) {
|
|
420
|
-
const promises = [];
|
|
421
|
-
for (const script of this.scripts) {
|
|
422
|
-
promises.push(this.engine.player.setScriptEnabled(script, value));
|
|
423
|
-
}
|
|
424
|
-
return Promise.all(promises);
|
|
425
|
-
}
|
|
426
|
-
_destroyScripts() {
|
|
427
|
-
for (const script of this.scripts) {
|
|
428
|
-
script.destroy();
|
|
429
|
-
}
|
|
430
|
-
this.scripts = [];
|
|
431
|
-
}
|
|
432
|
-
async addScript(scriptMeta) {
|
|
433
|
-
const itemScript = new SgItemScript(scriptMeta, this, this.engine, this.sceneGraph);
|
|
434
|
-
await itemScript.create();
|
|
435
|
-
this.scripts.push(itemScript);
|
|
436
|
-
}
|
|
437
|
-
removeScript(scriptMeta) {
|
|
438
|
-
const script = this.findScript(scriptMeta.id);
|
|
439
|
-
if (script) {
|
|
440
|
-
script.destroy();
|
|
441
|
-
this.scripts.removeObject(script);
|
|
442
|
-
}
|
|
443
|
-
}
|
|
444
|
-
findScript(scriptId) {
|
|
445
|
-
for (const script of this.scripts) {
|
|
446
|
-
if (script.getId() === scriptId)
|
|
447
|
-
return script;
|
|
448
|
-
}
|
|
449
|
-
}
|
|
450
|
-
setFieldValue(name, value) {
|
|
451
|
-
const field = this.getField(name);
|
|
452
|
-
if (field) {
|
|
453
|
-
field.value = value;
|
|
454
|
-
}
|
|
455
|
-
else {
|
|
456
|
-
console.error(`setFieldValue() : field ${name} not found!`);
|
|
457
|
-
}
|
|
458
|
-
}
|
|
459
|
-
/**
|
|
460
|
-
* Check if the object is either equal to this node object or if it
|
|
461
|
-
* is somewhere in its children
|
|
462
|
-
* @param object
|
|
463
|
-
* @returns {boolean}
|
|
464
|
-
*/
|
|
465
|
-
_contains(object, node) {
|
|
466
|
-
if (node === object) {
|
|
467
|
-
return true;
|
|
468
|
-
}
|
|
469
|
-
for (const child of node.children) {
|
|
470
|
-
if (child.userData.id === this.block.id) {
|
|
471
|
-
if (this._contains(object, child))
|
|
472
|
-
return true;
|
|
473
|
-
}
|
|
474
|
-
}
|
|
475
|
-
return false;
|
|
476
|
-
}
|
|
477
|
-
async _loadMaterial(material, preferredType = "meshPhysical") {
|
|
478
|
-
let matObject = null;
|
|
479
|
-
if (material) {
|
|
480
|
-
if (material instanceof MeshBasicMaterial ||
|
|
481
|
-
material instanceof MeshStandardMaterial ||
|
|
482
|
-
material instanceof MeshPhysicalMaterial) {
|
|
483
|
-
this.material = material;
|
|
484
|
-
matObject = material;
|
|
485
|
-
}
|
|
486
|
-
else if (material.type === "CanvasTexture") {
|
|
487
|
-
const canvasTexture = await this.engine.loadingManager.get(material._id, this.referenceId);
|
|
488
|
-
if (canvasTexture)
|
|
489
|
-
matObject = canvasTexture.getMaterial(preferredType);
|
|
490
|
-
}
|
|
491
|
-
else {
|
|
492
|
-
this.material = await this.engine.loadingManager.loadMaterial(this.referenceId, material);
|
|
493
|
-
this.material.$on('item:objectUpdated', this.recreate, this);
|
|
494
|
-
matObject = this.material.getObject();
|
|
495
|
-
}
|
|
496
|
-
}
|
|
497
|
-
return matObject;
|
|
498
|
-
}
|
|
499
|
-
async _loadFont(font) {
|
|
500
|
-
this.font = await this.engine.loadingManager.loadFont(this.referenceId, font);
|
|
501
|
-
let fontObject = this.font.getObject();
|
|
502
|
-
return fontObject;
|
|
503
|
-
}
|
|
504
|
-
_destroyMaterial() {
|
|
505
|
-
if (this.material && typeof (this.material.getInstanceId) === 'function') {
|
|
506
|
-
this.material.$off('item:objectUpdated', this.recreate, this);
|
|
507
|
-
this.material = null;
|
|
508
|
-
}
|
|
509
|
-
if (this._res?.itemMaterial)
|
|
510
|
-
this.freeResource("itemMaterial");
|
|
511
|
-
if (this._res?.threeMaterial)
|
|
512
|
-
this.freeResource("threeMaterial");
|
|
513
|
-
}
|
|
514
|
-
_ensureMaterial(material, hexValue = 0xffffff, vertexColors = false) {
|
|
515
|
-
if (material)
|
|
516
|
-
return material;
|
|
517
|
-
if (this.ownMaterial)
|
|
518
|
-
this._disposeOwnMaterial();
|
|
519
|
-
this.ownMaterial = new MeshPhysicalMaterial({
|
|
520
|
-
color: hexValue,
|
|
521
|
-
vertexColors: vertexColors,
|
|
522
|
-
side: DoubleSide,
|
|
523
|
-
shadowSide: BackSide,
|
|
524
|
-
map: this.engine.renderer.getDefaultUvTestTexture()
|
|
525
|
-
});
|
|
526
|
-
this.renderer.addMaterial(this.ownMaterial);
|
|
527
|
-
return this.ownMaterial;
|
|
528
|
-
}
|
|
529
|
-
_disposeOwnMaterial() {
|
|
530
|
-
if (this.ownMaterial) {
|
|
531
|
-
this.renderer.removeMaterial(this.ownMaterial);
|
|
532
|
-
this.ownMaterial.dispose();
|
|
533
|
-
this.ownMaterial = undefined;
|
|
534
|
-
}
|
|
535
|
-
}
|
|
536
|
-
getMaterial() {
|
|
537
|
-
return this.material;
|
|
538
|
-
}
|
|
539
|
-
async onDrop(droppedItem) {
|
|
540
|
-
const targetBlock = this.block;
|
|
541
|
-
const type = droppedItem.type === "Package" ? droppedItem.packageType : droppedItem.type;
|
|
542
|
-
// In case we dropped a script, add the dropped script to the item
|
|
543
|
-
// ----------------------------------------------------------------------------
|
|
544
|
-
if (type === "Script") {
|
|
545
|
-
const script = this.itemRepo.createNewScript(targetBlock, undefined, droppedItem);
|
|
546
|
-
const item = await this.itemRepo.loadItem(droppedItem.id, { recursive: true });
|
|
547
|
-
if (item) {
|
|
548
|
-
script.item.value = item;
|
|
549
|
-
return true;
|
|
550
|
-
}
|
|
551
|
-
else {
|
|
552
|
-
console.error("Script could not be loaded: " + droppedItem.id);
|
|
553
|
-
return false;
|
|
554
|
-
}
|
|
555
|
-
}
|
|
556
|
-
// Maybe we got dropped a scenegraph item. If so, move it as child of this item
|
|
557
|
-
// ----------------------------------------------------------------------------
|
|
558
|
-
if (this.engine.activeSceneGraphCollection) {
|
|
559
|
-
const sgDroppedItem = this.engine.activeSceneGraphCollection.findItemById(droppedItem.id);
|
|
560
|
-
const droppedItemIsObject3D = sgDroppedItem && sgDroppedItem.getContainer() instanceof Object3D;
|
|
561
|
-
// Detach dropped item from old parent and add it as child, if the dropped object is an Object3D
|
|
562
|
-
// ----------------------------------------------------------------------------
|
|
563
|
-
if (droppedItemIsObject3D) {
|
|
564
|
-
// Dont allow a parent to drop on its descendants
|
|
565
|
-
const droppedItemIsDescendantOfThis = this.isDescendantOf(sgDroppedItem);
|
|
566
|
-
if (!droppedItemIsDescendantOfThis) {
|
|
567
|
-
this.engine.moveTreeItemsToNewParent([droppedItem.id], this.getId());
|
|
568
|
-
return true;
|
|
569
|
-
}
|
|
570
|
-
}
|
|
571
|
-
}
|
|
572
|
-
// Check if this item has a field which takes the dropped type and add it there. There are exceptions however,
|
|
573
|
-
// we do not want this behaviour for any type of dropped item
|
|
574
|
-
// ----------------------------------------------------------------------------
|
|
575
|
-
if (["Image", "Material"].includes(type)) {
|
|
576
|
-
for (const field of this.block.fields) {
|
|
577
|
-
if (field.type === "Link" && field.linkableTypes.includes(type)) {
|
|
578
|
-
const item = await this.itemRepo.loadItem(droppedItem.id, { recursive: true });
|
|
579
|
-
field.value = item;
|
|
580
|
-
return true;
|
|
581
|
-
}
|
|
582
|
-
}
|
|
583
|
-
}
|
|
584
|
-
return false;
|
|
585
|
-
}
|
|
586
|
-
isDescendantOf(otherItem) {
|
|
587
|
-
let currElem = this;
|
|
588
|
-
while (currElem && currElem.getType() !== "Scene") {
|
|
589
|
-
if (currElem === otherItem) {
|
|
590
|
-
return true;
|
|
591
|
-
}
|
|
592
|
-
currElem = currElem.parent;
|
|
593
|
-
}
|
|
594
|
-
return false;
|
|
595
|
-
}
|
|
596
|
-
setSelected(selected) {
|
|
597
|
-
if (this.selected === selected) {
|
|
598
|
-
return;
|
|
599
|
-
}
|
|
600
|
-
this.selected = selected;
|
|
601
|
-
this.updateSelection();
|
|
602
|
-
}
|
|
603
|
-
setParent(parent) {
|
|
604
|
-
this.parent = parent;
|
|
605
|
-
}
|
|
606
|
-
removeFromParent() {
|
|
607
|
-
if (this.parent) {
|
|
608
|
-
this.parent.remove(this);
|
|
609
|
-
}
|
|
610
|
-
}
|
|
611
|
-
add(child, position) {
|
|
612
|
-
if (!(child instanceof SgItem))
|
|
613
|
-
throw "Can only add instances of SgItem! Invalid type: " + (typeof child);
|
|
614
|
-
child.setParent(this);
|
|
615
|
-
if (Number.isInteger(position))
|
|
616
|
-
this.children.splice(position, 0, child);
|
|
617
|
-
else
|
|
618
|
-
this.children.push(child);
|
|
619
|
-
const container = child.getContainer();
|
|
620
|
-
if (container)
|
|
621
|
-
this.addChild(container);
|
|
622
|
-
}
|
|
623
|
-
remove(child) {
|
|
624
|
-
this.children.removeObject(child);
|
|
625
|
-
}
|
|
626
|
-
addChild(child) {
|
|
627
|
-
const container = this.getContainer();
|
|
628
|
-
if (container) {
|
|
629
|
-
// we handle adding the child to the lod, once the threejs object is being added
|
|
630
|
-
if (this.getType() !== "Lod") {
|
|
631
|
-
container.add(child);
|
|
632
|
-
}
|
|
633
|
-
}
|
|
634
|
-
else {
|
|
635
|
-
console.warn("Cannot add object as child. This item has no container!", this.block);
|
|
636
|
-
}
|
|
637
|
-
}
|
|
638
|
-
removeChild(child) {
|
|
639
|
-
const container = this.getContainer();
|
|
640
|
-
if (container) {
|
|
641
|
-
// we handle removing the object to the lod, once the threejs object is being removed
|
|
642
|
-
if (this.getType() !== "Lod") {
|
|
643
|
-
container.remove(child);
|
|
644
|
-
}
|
|
645
|
-
}
|
|
646
|
-
else {
|
|
647
|
-
console.warn("Cannot remove objects. This item has no container!", this.block);
|
|
648
|
-
}
|
|
649
|
-
}
|
|
650
|
-
/**
|
|
651
|
-
* Check if the object is either equal to this items object or if it
|
|
652
|
-
* is somewhere in its children
|
|
653
|
-
* @param object
|
|
654
|
-
* @returns {boolean}
|
|
655
|
-
*/
|
|
656
|
-
contains(object) {
|
|
657
|
-
const obj = this.getObject();
|
|
658
|
-
if (obj) {
|
|
659
|
-
return this._contains(object, obj);
|
|
660
|
-
}
|
|
661
|
-
return false;
|
|
662
|
-
}
|
|
663
|
-
/**
|
|
664
|
-
* Check if the object is equal to this items object
|
|
665
|
-
* @param object
|
|
666
|
-
* @returns {boolean}
|
|
667
|
-
*/
|
|
668
|
-
is(object) {
|
|
669
|
-
const obj = this.getObject();
|
|
670
|
-
return obj === object;
|
|
671
|
-
}
|
|
672
|
-
/**
|
|
673
|
-
* Updates the transform stored in the block information from the
|
|
674
|
-
* three.js object
|
|
675
|
-
*/
|
|
676
|
-
updateBlockTransform() {
|
|
677
|
-
if (!this.getContainer)
|
|
678
|
-
return;
|
|
679
|
-
const container = this.getContainer();
|
|
680
|
-
if (!container)
|
|
681
|
-
return;
|
|
682
|
-
const transformField = this.getField("Transform");
|
|
683
|
-
if (!transformField)
|
|
684
|
-
return;
|
|
685
|
-
const containerTransform = {
|
|
686
|
-
position: container.position,
|
|
687
|
-
rotation: container.quaternion,
|
|
688
|
-
scale: container.scale
|
|
689
|
-
};
|
|
690
|
-
if (tools.areTransformsEqual(containerTransform, transformField.value))
|
|
691
|
-
return;
|
|
692
|
-
transformField.value = {
|
|
693
|
-
position: {
|
|
694
|
-
x: container.position.x,
|
|
695
|
-
y: container.position.y,
|
|
696
|
-
z: container.position.z
|
|
697
|
-
},
|
|
698
|
-
rotation: {
|
|
699
|
-
x: container.quaternion.x,
|
|
700
|
-
y: container.quaternion.y,
|
|
701
|
-
z: container.quaternion.z,
|
|
702
|
-
w: container.quaternion.w
|
|
703
|
-
},
|
|
704
|
-
scale: {
|
|
705
|
-
x: container.scale.x,
|
|
706
|
-
y: container.scale.y,
|
|
707
|
-
z: container.scale.z
|
|
708
|
-
}
|
|
709
|
-
};
|
|
710
|
-
}
|
|
711
|
-
/**
|
|
712
|
-
* Make sure the item specified by itemId is in the cache. If not, load it
|
|
713
|
-
* @param itemId
|
|
714
|
-
* @returns {Promise<*|string>}
|
|
715
|
-
*/
|
|
716
|
-
async ensureItemInCache(itemId) {
|
|
717
|
-
return this.engine.getDownloadUrl(itemId);
|
|
718
|
-
}
|
|
719
|
-
/**
|
|
720
|
-
* Get the value of the specified field
|
|
721
|
-
* @param name
|
|
722
|
-
* @param defaultValue
|
|
723
|
-
* @returns {null|*}
|
|
724
|
-
*/
|
|
725
|
-
getFieldValue(name, defaultValue) {
|
|
726
|
-
const field = this.getField(name);
|
|
727
|
-
const value = field?.value;
|
|
728
|
-
if (value === undefined)
|
|
729
|
-
return defaultValue;
|
|
730
|
-
return value;
|
|
731
|
-
}
|
|
732
|
-
/**
|
|
733
|
-
* Get the field with the specified name
|
|
734
|
-
* @param name
|
|
735
|
-
* @returns {null}
|
|
736
|
-
*/
|
|
737
|
-
getField(name) {
|
|
738
|
-
let f = this.fieldMap.get(name);
|
|
739
|
-
if (f) {
|
|
740
|
-
return f;
|
|
741
|
-
}
|
|
742
|
-
for (const field of this.block.fields) {
|
|
743
|
-
if (field.name === name) {
|
|
744
|
-
this.fieldMap.set(name, field);
|
|
745
|
-
return field;
|
|
746
|
-
}
|
|
747
|
-
}
|
|
748
|
-
return null;
|
|
749
|
-
}
|
|
750
|
-
/**
|
|
751
|
-
* Convert RGB color object to a three.js color object
|
|
752
|
-
* @param col
|
|
753
|
-
* @returns {Color}
|
|
754
|
-
*/
|
|
755
|
-
toColorObjRgb(col) {
|
|
756
|
-
let color = new Color(col.r / 255, col.g / 255, col.b / 255);
|
|
757
|
-
color.convertSRGBToLinear();
|
|
758
|
-
return color;
|
|
759
|
-
}
|
|
760
|
-
;
|
|
761
|
-
updateEvent(field, value, type, oldValue) {
|
|
762
|
-
switch (field) {
|
|
763
|
-
case "Active": {
|
|
764
|
-
this.setActive(value);
|
|
765
|
-
break;
|
|
766
|
-
}
|
|
767
|
-
case "Layers": {
|
|
768
|
-
this.setLayers(value);
|
|
769
|
-
break;
|
|
770
|
-
}
|
|
771
|
-
case "Name": {
|
|
772
|
-
this.setName(value);
|
|
773
|
-
break;
|
|
774
|
-
}
|
|
775
|
-
case "Transform": {
|
|
776
|
-
this.setTransform(value);
|
|
777
|
-
this.updateHelpers();
|
|
778
|
-
break;
|
|
779
|
-
}
|
|
780
|
-
case "CastShadow": {
|
|
781
|
-
this.setShadows(value, undefined);
|
|
782
|
-
break;
|
|
783
|
-
}
|
|
784
|
-
case "ReceiveShadow": {
|
|
785
|
-
this.setShadows(undefined, value);
|
|
786
|
-
break;
|
|
787
|
-
}
|
|
788
|
-
default:
|
|
789
|
-
return false; // we did not handle the event
|
|
790
|
-
}
|
|
791
|
-
// we handled the event
|
|
792
|
-
return true;
|
|
793
|
-
}
|
|
794
|
-
setTransform(transform) {
|
|
795
|
-
if (!transform)
|
|
796
|
-
return;
|
|
797
|
-
const container = this.getContainer();
|
|
798
|
-
if (!container)
|
|
799
|
-
return;
|
|
800
|
-
tools.setTransformOnObject(container, transform);
|
|
801
|
-
// apply changes to items below this one when this items transform changes
|
|
802
|
-
this.updateTransformChangesOnDescendants();
|
|
803
|
-
}
|
|
804
|
-
updateTransformChangesOnDescendants() {
|
|
805
|
-
for (const child of this.children) {
|
|
806
|
-
child.updateTransformChangesOnDescendants();
|
|
807
|
-
}
|
|
808
|
-
}
|
|
809
|
-
/**
|
|
810
|
-
* A physics item will be added to the physics engine if
|
|
811
|
-
* 1) It is physicsEnabled
|
|
812
|
-
* 2) It is active
|
|
813
|
-
* 3) All its ancestors are active
|
|
814
|
-
*/
|
|
815
|
-
updatePhysicsFromFields(recursively = false) {
|
|
816
|
-
const allAncestorsAreActive = this.allAncestorsAreActive();
|
|
817
|
-
this.setPhysicsFromFields(allAncestorsAreActive, recursively);
|
|
818
|
-
}
|
|
819
|
-
setPhysicsFromFields(allAncestorsActive, recursively) {
|
|
820
|
-
const isActive = this.isEnabled();
|
|
821
|
-
if (this.isPhysicsItem()) {
|
|
822
|
-
const pi = this;
|
|
823
|
-
const isPhysicsEnabled = pi.isPhysicsEnabled();
|
|
824
|
-
const enablePhysics = allAncestorsActive && isActive && isPhysicsEnabled;
|
|
825
|
-
pi.setPhysics(enablePhysics);
|
|
826
|
-
}
|
|
827
|
-
if (recursively) {
|
|
828
|
-
for (const child of this.children) {
|
|
829
|
-
child.setPhysicsFromFields(allAncestorsActive && isActive, recursively);
|
|
830
|
-
}
|
|
831
|
-
if (this.getType() === "Prefab" && this.prefabItem) {
|
|
832
|
-
this.prefabItem.sceneGraph.root?.setPhysicsFromFields?.(allAncestorsActive && isActive, recursively);
|
|
833
|
-
}
|
|
834
|
-
}
|
|
835
|
-
}
|
|
836
|
-
// Helper function to toggle the particle system preview based on parent active status.
|
|
837
|
-
updateParticleSystemPreview(recursively) {
|
|
838
|
-
const allAncestorsActive = this.allAncestorsAreActive();
|
|
839
|
-
const isActive = this.isEnabled();
|
|
840
|
-
if (this.isParticlesItem()) {
|
|
841
|
-
const particles = this;
|
|
842
|
-
if (particles.system) {
|
|
843
|
-
const shouldRun = allAncestorsActive && isActive &&
|
|
844
|
-
(particles.isRunning || particles.isRunningPreview);
|
|
845
|
-
if (shouldRun) {
|
|
846
|
-
particles.system.isRunning = true;
|
|
847
|
-
particles.system.isPaused = false;
|
|
848
|
-
particles.system.showParticles();
|
|
849
|
-
particles.system.restart();
|
|
850
|
-
}
|
|
851
|
-
else {
|
|
852
|
-
particles.system.isRunning = false;
|
|
853
|
-
particles.system.isPaused = true;
|
|
854
|
-
particles.system.hideParticles();
|
|
855
|
-
}
|
|
856
|
-
}
|
|
857
|
-
}
|
|
858
|
-
if (recursively) {
|
|
859
|
-
for (const child of this.children) {
|
|
860
|
-
child.updateParticleSystemPreview?.(recursively);
|
|
861
|
-
}
|
|
862
|
-
}
|
|
863
|
-
}
|
|
864
|
-
getTransform() {
|
|
865
|
-
const container = this.getContainer();
|
|
866
|
-
if (!container)
|
|
867
|
-
return null;
|
|
868
|
-
const pos = container.position;
|
|
869
|
-
const quat = container.quaternion;
|
|
870
|
-
const scale = container.scale;
|
|
871
|
-
return {
|
|
872
|
-
position: {
|
|
873
|
-
x: pos.x,
|
|
874
|
-
y: pos.y,
|
|
875
|
-
z: pos.z
|
|
876
|
-
},
|
|
877
|
-
rotation: {
|
|
878
|
-
x: quat.x,
|
|
879
|
-
y: quat.y,
|
|
880
|
-
z: quat.z,
|
|
881
|
-
w: quat.w
|
|
882
|
-
},
|
|
883
|
-
scale: {
|
|
884
|
-
x: scale.x,
|
|
885
|
-
y: scale.y,
|
|
886
|
-
z: scale.z
|
|
887
|
-
}
|
|
888
|
-
};
|
|
889
|
-
}
|
|
890
|
-
getWorldMatrix() {
|
|
891
|
-
const container = this.getContainer();
|
|
892
|
-
if (!container)
|
|
893
|
-
return null;
|
|
894
|
-
return container.matrixWorld;
|
|
895
|
-
}
|
|
896
|
-
getInverseParentWorldMatrix() {
|
|
897
|
-
if (!this.parent)
|
|
898
|
-
return new Matrix4();
|
|
899
|
-
return this.parent.getInverseWorldMatrix();
|
|
900
|
-
}
|
|
901
|
-
getInverseWorldMatrix(container) {
|
|
902
|
-
container = container || this.getContainer();
|
|
903
|
-
if (!container)
|
|
904
|
-
return new Matrix4();
|
|
905
|
-
let inverseWorldMatrix = container.matrixWorld.clone();
|
|
906
|
-
inverseWorldMatrix.invert();
|
|
907
|
-
return inverseWorldMatrix;
|
|
908
|
-
}
|
|
909
|
-
getInverseParentWorldTransform() {
|
|
910
|
-
if (!this.parent) {
|
|
911
|
-
return {
|
|
912
|
-
position: {
|
|
913
|
-
x: 0,
|
|
914
|
-
y: 0,
|
|
915
|
-
z: 0
|
|
916
|
-
},
|
|
917
|
-
rotation: {
|
|
918
|
-
x: 0,
|
|
919
|
-
y: 0,
|
|
920
|
-
z: 0,
|
|
921
|
-
w: 1
|
|
922
|
-
},
|
|
923
|
-
scale: {
|
|
924
|
-
x: 1,
|
|
925
|
-
y: 1,
|
|
926
|
-
z: 1
|
|
927
|
-
}
|
|
928
|
-
};
|
|
929
|
-
}
|
|
930
|
-
return this.parent.getInverseWorldTransform();
|
|
931
|
-
}
|
|
932
|
-
getInverseWorldTransform(container) {
|
|
933
|
-
container = container || this.getContainer();
|
|
934
|
-
if (!container)
|
|
935
|
-
return null;
|
|
936
|
-
const pos = new Vector3();
|
|
937
|
-
container.getWorldPosition(pos);
|
|
938
|
-
pos.negate();
|
|
939
|
-
const quat = new Quaternion();
|
|
940
|
-
container.getWorldQuaternion(quat);
|
|
941
|
-
quat.invert();
|
|
942
|
-
const scale = new Vector3();
|
|
943
|
-
container.getWorldScale(scale);
|
|
944
|
-
scale.x = 1.0 / scale.x;
|
|
945
|
-
scale.y = 1.0 / scale.y;
|
|
946
|
-
scale.z = 1.0 / scale.z;
|
|
947
|
-
return {
|
|
948
|
-
position: {
|
|
949
|
-
x: pos.x,
|
|
950
|
-
y: pos.y,
|
|
951
|
-
z: pos.z
|
|
952
|
-
},
|
|
953
|
-
rotation: {
|
|
954
|
-
x: quat.x,
|
|
955
|
-
y: quat.y,
|
|
956
|
-
z: quat.z,
|
|
957
|
-
w: quat.w
|
|
958
|
-
},
|
|
959
|
-
scale: {
|
|
960
|
-
x: scale.x,
|
|
961
|
-
y: scale.y,
|
|
962
|
-
z: scale.z
|
|
963
|
-
}
|
|
964
|
-
};
|
|
965
|
-
}
|
|
966
|
-
getWorldTransform(obj) {
|
|
967
|
-
obj = obj || this.getObject() || this.getContainer();
|
|
968
|
-
if (!obj)
|
|
969
|
-
return null;
|
|
970
|
-
const pos = new Vector3();
|
|
971
|
-
obj.getWorldPosition(pos);
|
|
972
|
-
const quat = new Quaternion();
|
|
973
|
-
obj.getWorldQuaternion(quat);
|
|
974
|
-
const scale = new Vector3();
|
|
975
|
-
obj.getWorldScale(scale);
|
|
976
|
-
return {
|
|
977
|
-
position: {
|
|
978
|
-
x: pos.x,
|
|
979
|
-
y: pos.y,
|
|
980
|
-
z: pos.z
|
|
981
|
-
},
|
|
982
|
-
rotation: {
|
|
983
|
-
x: quat.x,
|
|
984
|
-
y: quat.y,
|
|
985
|
-
z: quat.z,
|
|
986
|
-
w: quat.w
|
|
987
|
-
},
|
|
988
|
-
scale: {
|
|
989
|
-
x: scale.x,
|
|
990
|
-
y: scale.y,
|
|
991
|
-
z: scale.z
|
|
992
|
-
}
|
|
993
|
-
};
|
|
994
|
-
}
|
|
995
|
-
setShadows(castShadow, receiveShadow) {
|
|
996
|
-
this.traverse(function (child) {
|
|
997
|
-
if (castShadow !== undefined)
|
|
998
|
-
child.castShadow = castShadow;
|
|
999
|
-
if (receiveShadow !== undefined)
|
|
1000
|
-
child.receiveShadow = receiveShadow;
|
|
1001
|
-
});
|
|
1002
|
-
}
|
|
1003
|
-
setName(value) {
|
|
1004
|
-
this.traverse(function (child) {
|
|
1005
|
-
child.userData.name = value;
|
|
1006
|
-
});
|
|
1007
|
-
}
|
|
1008
|
-
getContainer() {
|
|
1009
|
-
return this.container;
|
|
1010
|
-
}
|
|
1011
|
-
setContainer(container) {
|
|
1012
|
-
this.container = container;
|
|
1013
|
-
}
|
|
1014
|
-
getObject() {
|
|
1015
|
-
return null;
|
|
1016
|
-
}
|
|
1017
|
-
setObject(obj) {
|
|
1018
|
-
}
|
|
1019
|
-
// returns the actual mesh (most descendant object, ignoring containers)
|
|
1020
|
-
// if not overloaded, returns getObject()
|
|
1021
|
-
getMesh() {
|
|
1022
|
-
return this.getObject();
|
|
1023
|
-
}
|
|
1024
|
-
setIdAndName() {
|
|
1025
|
-
const obj = this.getObject();
|
|
1026
|
-
const name = this.getFieldValue("Name");
|
|
1027
|
-
if (!obj)
|
|
1028
|
-
return;
|
|
1029
|
-
obj.traverse((child) => {
|
|
1030
|
-
child.userData = {
|
|
1031
|
-
_isSgItem: true,
|
|
1032
|
-
id: this.block.id,
|
|
1033
|
-
name,
|
|
1034
|
-
};
|
|
1035
|
-
});
|
|
1036
|
-
}
|
|
1037
|
-
// Traverse the object and call the function on all children belonging to this sgnode.
|
|
1038
|
-
// Sub-sgnode children will not be traversed, because they have a different userData.id.
|
|
1039
|
-
traverse(func) {
|
|
1040
|
-
const obj = this.getObject();
|
|
1041
|
-
if (!obj || !obj.userData || !obj.userData.id)
|
|
1042
|
-
return;
|
|
1043
|
-
obj.traverse((child) => {
|
|
1044
|
-
if (child.userData.id === obj.userData.id)
|
|
1045
|
-
func(child);
|
|
1046
|
-
});
|
|
1047
|
-
}
|
|
1048
|
-
/**
|
|
1049
|
-
* Cullmode is layers but inverted. We define the layers we do NOT want to have instead of the ones we want
|
|
1050
|
-
* @param cullmode
|
|
1051
|
-
*/
|
|
1052
|
-
setCullmode(cullmode) {
|
|
1053
|
-
this.setLayers(cullmode, true);
|
|
1054
|
-
}
|
|
1055
|
-
/**
|
|
1056
|
-
* Set the layers in which the object should be visible. For cameras, use the invert parameters, since
|
|
1057
|
-
* cameras by default see everything unless layers are culled through the cullmode setting.
|
|
1058
|
-
* @param layers
|
|
1059
|
-
* @param invert
|
|
1060
|
-
*/
|
|
1061
|
-
setLayers(layers, invert = false) {
|
|
1062
|
-
if (!Array.isArray(layers)) {
|
|
1063
|
-
console.error("Layers must be an array!");
|
|
1064
|
-
return;
|
|
1065
|
-
}
|
|
1066
|
-
// detect old boolean[] format and correct to number[]
|
|
1067
|
-
if (layers.length > 0 && (layers[0] === true || layers[0] === false)) {
|
|
1068
|
-
let newLayers = [];
|
|
1069
|
-
for (const [i, v] of layers.entries()) {
|
|
1070
|
-
if (v)
|
|
1071
|
-
newLayers.push(i);
|
|
1072
|
-
}
|
|
1073
|
-
layers = newLayers;
|
|
1074
|
-
}
|
|
1075
|
-
this.traverse(function (child) {
|
|
1076
|
-
for (let i = 0; i < 32; i++) {
|
|
1077
|
-
let selected = layers.includes(i);
|
|
1078
|
-
if (invert)
|
|
1079
|
-
selected = !selected;
|
|
1080
|
-
if (selected)
|
|
1081
|
-
child.layers.enable(i);
|
|
1082
|
-
else
|
|
1083
|
-
child.layers.disable(i);
|
|
1084
|
-
}
|
|
1085
|
-
});
|
|
1086
|
-
}
|
|
1087
|
-
createHelpers() {
|
|
1088
|
-
const container = this.getContainer();
|
|
1089
|
-
if (!container)
|
|
1090
|
-
return;
|
|
1091
|
-
// Create box helper
|
|
1092
|
-
// ---------------------------------------------------------
|
|
1093
|
-
try {
|
|
1094
|
-
this.boxHelper = new BoxHelper(container, 0xffff00);
|
|
1095
|
-
this.boxHelper.name = "BoxHelper";
|
|
1096
|
-
this.boxHelper.layers.set(layerIndexHelper);
|
|
1097
|
-
}
|
|
1098
|
-
catch {
|
|
1099
|
-
console.error("Error creating box helper for object.", container);
|
|
1100
|
-
this.boxHelper = undefined;
|
|
1101
|
-
}
|
|
1102
|
-
// Create normals helpers
|
|
1103
|
-
// ---------------------------------------------------------
|
|
1104
|
-
this.normalsHelpers = [];
|
|
1105
|
-
container.traverse((object) => {
|
|
1106
|
-
if (!(object instanceof Mesh))
|
|
1107
|
-
return;
|
|
1108
|
-
try {
|
|
1109
|
-
const vertexNormalsHelper = new VertexNormalsHelper(object, 1.5, 0xff0000);
|
|
1110
|
-
vertexNormalsHelper.layers.set(LayerIndexNormalsHelper);
|
|
1111
|
-
this.normalsHelpers.push(vertexNormalsHelper);
|
|
1112
|
-
const faceNormalsHelper = new FaceNormalsHelper(object, 3.0, 0x0000FF);
|
|
1113
|
-
faceNormalsHelper.layers.set(LayerIndexNormalsHelper);
|
|
1114
|
-
this.normalsHelpers.push(faceNormalsHelper);
|
|
1115
|
-
}
|
|
1116
|
-
catch {
|
|
1117
|
-
console.error("Error creating normals helper for object!", object);
|
|
1118
|
-
}
|
|
1119
|
-
});
|
|
1120
|
-
}
|
|
1121
|
-
addHelpersToScene() {
|
|
1122
|
-
const obj = this.getContainer();
|
|
1123
|
-
if (this.boxHelper && this.selected) {
|
|
1124
|
-
this.renderer.addToScene(this.boxHelper);
|
|
1125
|
-
this.renderer.setTransformControlItems([this]);
|
|
1126
|
-
}
|
|
1127
|
-
if (this.normalsHelpers) {
|
|
1128
|
-
for (const helper of this.normalsHelpers) {
|
|
1129
|
-
obj.add(helper);
|
|
1130
|
-
}
|
|
1131
|
-
}
|
|
1132
|
-
this.updateHelpers();
|
|
1133
|
-
}
|
|
1134
|
-
updateBoxHelper(updateParents = true, updateChildren = true) {
|
|
1135
|
-
if (this.boxHelper) {
|
|
1136
|
-
this.boxHelper.update();
|
|
1137
|
-
}
|
|
1138
|
-
if (this.parent && updateParents)
|
|
1139
|
-
this.parent.updateBoxHelper(true, false);
|
|
1140
|
-
if (!updateChildren) {
|
|
1141
|
-
for (const child of this.children)
|
|
1142
|
-
child.updateBoxHelper(false, true);
|
|
1143
|
-
}
|
|
1144
|
-
}
|
|
1145
|
-
update(deltaTimeMs) {
|
|
1146
|
-
}
|
|
1147
|
-
updateHelpers() {
|
|
1148
|
-
const obj = this.getContainer();
|
|
1149
|
-
if (obj) {
|
|
1150
|
-
obj.updateMatrixWorld();
|
|
1151
|
-
}
|
|
1152
|
-
// only update helpers, if they're actually shown
|
|
1153
|
-
// ---------------------------------------------------------
|
|
1154
|
-
if (!this.engine.renderer.renderOptions.showHelpers)
|
|
1155
|
-
return;
|
|
1156
|
-
// update the items own helpers
|
|
1157
|
-
// ---------------------------------------------------------
|
|
1158
|
-
this.updateBoxHelper();
|
|
1159
|
-
if (this.normalsHelpers) {
|
|
1160
|
-
for (const helper of this.normalsHelpers) {
|
|
1161
|
-
helper.update();
|
|
1162
|
-
}
|
|
1163
|
-
}
|
|
1164
|
-
}
|
|
1165
|
-
updateSelection() {
|
|
1166
|
-
if (!this.boxHelper) {
|
|
1167
|
-
return;
|
|
1168
|
-
}
|
|
1169
|
-
this.updateHelpers();
|
|
1170
|
-
if (this.selected) {
|
|
1171
|
-
this.renderer.addToScene(this.boxHelper);
|
|
1172
|
-
}
|
|
1173
|
-
else {
|
|
1174
|
-
this.renderer.removeFromScene(this.boxHelper);
|
|
1175
|
-
}
|
|
1176
|
-
}
|
|
1177
|
-
showHelpers(value) {
|
|
1178
|
-
if (!value)
|
|
1179
|
-
this.renderer.setTransformControlItems([]);
|
|
1180
|
-
if (this.boxHelper) {
|
|
1181
|
-
this.boxHelper.visible = value;
|
|
1182
|
-
}
|
|
1183
|
-
if (this.normalsHelpers) {
|
|
1184
|
-
for (const helper of this.normalsHelpers) {
|
|
1185
|
-
helper.visible = value;
|
|
1186
|
-
}
|
|
1187
|
-
}
|
|
1188
|
-
}
|
|
1189
|
-
destroyHelpers() {
|
|
1190
|
-
const obj = this.getContainer();
|
|
1191
|
-
if (this.boxHelper) {
|
|
1192
|
-
this.renderer.removeFromScene(this.boxHelper);
|
|
1193
|
-
this.boxHelper = undefined;
|
|
1194
|
-
}
|
|
1195
|
-
if (this.normalsHelpers) {
|
|
1196
|
-
for (const helper of this.normalsHelpers) {
|
|
1197
|
-
obj.remove(helper);
|
|
1198
|
-
}
|
|
1199
|
-
this.normalsHelpers = [];
|
|
1200
|
-
}
|
|
1201
|
-
}
|
|
1202
|
-
setAutoRecreate(value) {
|
|
1203
|
-
this.autoRecreate = value;
|
|
1204
|
-
}
|
|
1205
|
-
getAutoRecreate() {
|
|
1206
|
-
return this.autoRecreate;
|
|
1207
|
-
}
|
|
1208
|
-
recreate = async (force = false) => {
|
|
1209
|
-
if (!this.autoRecreate && !force)
|
|
1210
|
-
return;
|
|
1211
|
-
// We're using a mutex here because it is quite possible that multiple changes will be done on an object
|
|
1212
|
-
// in short time, triggering multiple recreates. If that happens, we need to make sure only once recreation call
|
|
1213
|
-
// is initiated and the next one is done only after the first one has completed. Furthermore we never want to
|
|
1214
|
-
// queue more than one pending call to it since it would just not make any sense and just use the CPU unnecessarily.
|
|
1215
|
-
// Hence we call cancel first, to cancel any pending call before we add this new one.
|
|
1216
|
-
this.recreationMutex.cancel();
|
|
1217
|
-
return this.recreationMutex.runExclusive(() => this.create())
|
|
1218
|
-
.catch((error) => {
|
|
1219
|
-
if (error !== E_CANCELED) {
|
|
1220
|
-
console.error(error);
|
|
1221
|
-
}
|
|
1222
|
-
});
|
|
1223
|
-
};
|
|
1224
|
-
async recreateObject(creationFunc, noHelpers = false, noAddToPhysics = false) {
|
|
1225
|
-
const restartPlayback = this._isPlaying;
|
|
1226
|
-
const savedAutoRecreate = this.autoRecreate;
|
|
1227
|
-
if (restartPlayback)
|
|
1228
|
-
this.stop();
|
|
1229
|
-
this.destroy(false, false, true);
|
|
1230
|
-
this.visible = this.getFieldValue("Active");
|
|
1231
|
-
await creationFunc();
|
|
1232
|
-
const obj = this.getObject();
|
|
1233
|
-
this.addChildrenObjects();
|
|
1234
|
-
if (!noHelpers) {
|
|
1235
|
-
this.destroyHelpers();
|
|
1236
|
-
this.createHelpers();
|
|
1237
|
-
}
|
|
1238
|
-
this.container.visible = this.visible;
|
|
1239
|
-
if (obj) {
|
|
1240
|
-
this.container.add(obj);
|
|
1241
|
-
}
|
|
1242
|
-
if (this.parent)
|
|
1243
|
-
this.parent.addChild(this.container);
|
|
1244
|
-
if (!noHelpers) {
|
|
1245
|
-
this.addHelpersToScene();
|
|
1246
|
-
}
|
|
1247
|
-
await this._initScripts();
|
|
1248
|
-
if (!noAddToPhysics)
|
|
1249
|
-
this.updatePhysicsFromFields();
|
|
1250
|
-
if (restartPlayback) {
|
|
1251
|
-
this.play();
|
|
1252
|
-
this.autoRecreate = savedAutoRecreate;
|
|
1253
|
-
}
|
|
1254
|
-
this._sceneUpdated();
|
|
1255
|
-
this.setContentHookEnabled(true);
|
|
1256
|
-
this.$emit('sgitem:recreated');
|
|
1257
|
-
this.state = SgItemState.Created;
|
|
1258
|
-
}
|
|
1259
|
-
getPivot() {
|
|
1260
|
-
return null;
|
|
1261
|
-
}
|
|
1262
|
-
addChildrenObjects() {
|
|
1263
|
-
for (const child of this.children) {
|
|
1264
|
-
const container = child.getContainer();
|
|
1265
|
-
if (container) {
|
|
1266
|
-
this.addChild(container);
|
|
1267
|
-
}
|
|
1268
|
-
}
|
|
1269
|
-
}
|
|
1270
|
-
destroyChildren() {
|
|
1271
|
-
for (const child of this.children) {
|
|
1272
|
-
child.destroy(false, true);
|
|
1273
|
-
}
|
|
1274
|
-
}
|
|
1275
|
-
destroy(noDispose = false, withChildren = false, noRemoveUpdateListener = false) {
|
|
1276
|
-
// We mark this object as to destroyed
|
|
1277
|
-
// ----------------------------------------------------------------------
|
|
1278
|
-
this.state = SgItemState.ToDestroy;
|
|
1279
|
-
// we're no longer interested in any information about content updates regarding this object
|
|
1280
|
-
// ----------------------------------------------------------------------
|
|
1281
|
-
this.setContentHookEnabled(false);
|
|
1282
|
-
if (!noRemoveUpdateListener && this.updateListeners.block) {
|
|
1283
|
-
this.engine.removeUpdateListener(this.updateListeners.block);
|
|
1284
|
-
this.updateListeners.block = undefined;
|
|
1285
|
-
}
|
|
1286
|
-
// In case we also want to destroy children of this, do it now
|
|
1287
|
-
// ----------------------------------------------------------------------
|
|
1288
|
-
if (withChildren)
|
|
1289
|
-
this.destroyChildren();
|
|
1290
|
-
// Now destroy any helpers of this object
|
|
1291
|
-
// ----------------------------------------------------------------------
|
|
1292
|
-
this.destroyHelpers();
|
|
1293
|
-
// Grab the container of this object and if it has one (it should), remove
|
|
1294
|
-
// it from the parent and also remove the actual object from the container if one exists
|
|
1295
|
-
// ----------------------------------------------------------------------
|
|
1296
|
-
const container = this.getContainer();
|
|
1297
|
-
if (container) {
|
|
1298
|
-
this.engine.activeSceneGraphCollection.removeFromSelectedItems(this);
|
|
1299
|
-
if (this.parent)
|
|
1300
|
-
this.parent.removeChild(container);
|
|
1301
|
-
// only update box helpers if the parent is not to be deleted
|
|
1302
|
-
if (this.parent && this.state === SgItemState.ToDestroy && this.parent.state === SgItemState.Created) {
|
|
1303
|
-
this.parent.updateBoxHelper(true, false);
|
|
1304
|
-
}
|
|
1305
|
-
const obj = this.getObject();
|
|
1306
|
-
if (obj) {
|
|
1307
|
-
container.remove(obj);
|
|
1308
|
-
}
|
|
1309
|
-
this.setObject(undefined);
|
|
1310
|
-
}
|
|
1311
|
-
// Now dispose any of the additional resources that might still exist
|
|
1312
|
-
// ----------------------------------------------------------------------
|
|
1313
|
-
this._disposeOwnMaterial();
|
|
1314
|
-
this._destroyMaterial();
|
|
1315
|
-
this._destroyScripts();
|
|
1316
|
-
this.freeResources();
|
|
1317
|
-
// We're done with it. Mark it as destroyed
|
|
1318
|
-
// ----------------------------------------------------------------------
|
|
1319
|
-
this.state = SgItemState.Destroyed;
|
|
1320
|
-
}
|
|
1321
|
-
destroyAndRemove() {
|
|
1322
|
-
this.destroy(false, true);
|
|
1323
|
-
if (this.parent)
|
|
1324
|
-
this.parent.remove(this);
|
|
1325
|
-
}
|
|
1326
|
-
show(value) {
|
|
1327
|
-
if (this.visible === value)
|
|
1328
|
-
return;
|
|
1329
|
-
this.visible = value;
|
|
1330
|
-
const obj = this.getContainer();
|
|
1331
|
-
if (obj)
|
|
1332
|
-
obj.visible = value;
|
|
1333
|
-
this.updatePhysicsFromFields(true);
|
|
1334
|
-
this.updateParticleSystemPreview(true);
|
|
1335
|
-
return this._setScriptsEnabled(value);
|
|
1336
|
-
}
|
|
1337
|
-
allAncestorsAreActive() {
|
|
1338
|
-
let currNode = this.parent;
|
|
1339
|
-
while (currNode) {
|
|
1340
|
-
const parent = currNode.getParent();
|
|
1341
|
-
const isActive = currNode.isEnabled();
|
|
1342
|
-
if (!isActive) {
|
|
1343
|
-
return false;
|
|
1344
|
-
}
|
|
1345
|
-
if (!parent) {
|
|
1346
|
-
return true;
|
|
1347
|
-
}
|
|
1348
|
-
currNode = parent;
|
|
1349
|
-
}
|
|
1350
|
-
return true;
|
|
1351
|
-
}
|
|
1352
|
-
getLayerIndices() {
|
|
1353
|
-
const layers = this.getFieldValue("Layers");
|
|
1354
|
-
return layers || [];
|
|
1355
|
-
}
|
|
1356
|
-
takeSnapshot(recursive) {
|
|
1357
|
-
const data = this.block.createSnapshot(!recursive);
|
|
1358
|
-
return {
|
|
1359
|
-
data: data,
|
|
1360
|
-
recursive: recursive
|
|
1361
|
-
};
|
|
1362
|
-
}
|
|
1363
|
-
onBeforeRollback(recursive) {
|
|
1364
|
-
if (recursive) {
|
|
1365
|
-
for (const child of this.children) {
|
|
1366
|
-
child.onBeforeRollback(recursive);
|
|
1367
|
-
}
|
|
1368
|
-
}
|
|
1369
|
-
}
|
|
1370
|
-
onPostRollback(recursive) {
|
|
1371
|
-
if (recursive) {
|
|
1372
|
-
for (const child of this.children) {
|
|
1373
|
-
child.onPostRollback(recursive);
|
|
1374
|
-
}
|
|
1375
|
-
}
|
|
1376
|
-
}
|
|
1377
|
-
rollbackSnapshot(snapshot) {
|
|
1378
|
-
this.onBeforeRollback(snapshot.recursive);
|
|
1379
|
-
this.block.rollbackFromSnapshot(snapshot.data, !snapshot.recursive);
|
|
1380
|
-
this.onPostRollback(snapshot.recursive);
|
|
1381
|
-
}
|
|
1382
|
-
getWorldPosition() {
|
|
1383
|
-
const container = this.getContainer();
|
|
1384
|
-
if (!container)
|
|
1385
|
-
return null;
|
|
1386
|
-
return container.getWorldPosition(new Vector3());
|
|
1387
|
-
}
|
|
1388
|
-
getBoundingBox() {
|
|
1389
|
-
const obj = this.getObject();
|
|
1390
|
-
const type = this.getType();
|
|
1391
|
-
const box = new Box3();
|
|
1392
|
-
box.makeEmpty();
|
|
1393
|
-
// Sky is a special case, we should ignore it when creating scene bounding boxes since it
|
|
1394
|
-
// Is not really part of the scene
|
|
1395
|
-
// -------------------------------------------------------
|
|
1396
|
-
if (this.getType() === "Sky")
|
|
1397
|
-
return box;
|
|
1398
|
-
// Get bounding boxes of all children and unify them with our bounding box
|
|
1399
|
-
// -------------------------------------------------------
|
|
1400
|
-
for (const child of this.children) {
|
|
1401
|
-
const childBox = child.getBoundingBox();
|
|
1402
|
-
if (childBox) {
|
|
1403
|
-
box.union(childBox);
|
|
1404
|
-
}
|
|
1405
|
-
}
|
|
1406
|
-
// Now get a bounding box if there is one. Either from item properties or from geometry
|
|
1407
|
-
// -------------------------------------------------------
|
|
1408
|
-
if (type === "Prefab" || type === "Scene") {
|
|
1409
|
-
const sceneItem = this.getItem();
|
|
1410
|
-
if (sceneItem) {
|
|
1411
|
-
const sceneBbox = sceneItem.sceneGraph.getBoundingBox();
|
|
1412
|
-
box.union(sceneBbox);
|
|
1413
|
-
}
|
|
1414
|
-
}
|
|
1415
|
-
else if (obj) {
|
|
1416
|
-
const info = tools.getObject3DInfos(obj);
|
|
1417
|
-
if (!info.isHelper) {
|
|
1418
|
-
if (obj) {
|
|
1419
|
-
obj.updateMatrixWorld();
|
|
1420
|
-
box.expandByObject(obj, true);
|
|
1421
|
-
}
|
|
1422
|
-
}
|
|
1423
|
-
}
|
|
1424
|
-
return box;
|
|
1425
|
-
}
|
|
1426
|
-
}
|
|
1427
|
-
//# sourceMappingURL=SgItem.js.map
|