@needle-tools/engine 4.13.0 → 4.13.1-next.6cb1b73
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/CHANGELOG.md +8 -1
- package/README.md +37 -0
- package/components.needle.json +1 -1
- package/custom-elements.json +138 -4
- package/dist/gltf-progressive-BTd714P0.min.js +9 -0
- package/dist/gltf-progressive-CrHduHPm.umd.cjs +9 -0
- package/dist/{gltf-progressive-eiJCrjLb.js → gltf-progressive-CsyU_5lc.js} +364 -287
- package/dist/{needle-engine.bundle-CxaKFQVS.min.js → needle-engine.bundle-DRSn34Va.min.js} +109 -109
- package/dist/{needle-engine.bundle-J4k4znv8.umd.cjs → needle-engine.bundle-qTjHpin6.umd.cjs} +110 -110
- package/dist/{needle-engine.bundle-Dl3TFYyv.js → needle-engine.bundle-wB3o8RB6.js} +2655 -2130
- package/dist/needle-engine.d.ts +4202 -423
- package/dist/needle-engine.js +3 -3
- package/dist/needle-engine.min.js +1 -1
- package/dist/needle-engine.umd.cjs +1 -1
- package/lib/engine/engine_context.d.ts +16 -0
- package/lib/engine/engine_context.js +28 -2
- package/lib/engine/engine_context.js.map +1 -1
- package/lib/engine/engine_gameobject.d.ts +72 -0
- package/lib/engine/engine_gameobject.js +38 -0
- package/lib/engine/engine_gameobject.js.map +1 -1
- package/lib/engine/engine_input.d.ts +80 -4
- package/lib/engine/engine_input.js +78 -2
- package/lib/engine/engine_input.js.map +1 -1
- package/lib/engine/engine_math.d.ts +81 -2
- package/lib/engine/engine_math.js +68 -2
- package/lib/engine/engine_math.js.map +1 -1
- package/lib/engine/engine_networking.d.ts +181 -14
- package/lib/engine/engine_networking.js +181 -14
- package/lib/engine/engine_networking.js.map +1 -1
- package/lib/engine/engine_networking_auto.d.ts +35 -8
- package/lib/engine/engine_networking_auto.js +35 -8
- package/lib/engine/engine_networking_auto.js.map +1 -1
- package/lib/engine/engine_physics.d.ts +37 -1
- package/lib/engine/engine_physics.js +37 -1
- package/lib/engine/engine_physics.js.map +1 -1
- package/lib/engine/engine_physics_rapier.d.ts +78 -0
- package/lib/engine/engine_physics_rapier.js +78 -0
- package/lib/engine/engine_physics_rapier.js.map +1 -1
- package/lib/engine/engine_serialization_decorator.d.ts +28 -2
- package/lib/engine/engine_serialization_decorator.js +28 -2
- package/lib/engine/engine_serialization_decorator.js.map +1 -1
- package/lib/engine/engine_time.d.ts +23 -3
- package/lib/engine/engine_time.js +23 -3
- package/lib/engine/engine_time.js.map +1 -1
- package/lib/engine/engine_util_decorator.d.ts +31 -1
- package/lib/engine/engine_util_decorator.js +31 -1
- package/lib/engine/engine_util_decorator.js.map +1 -1
- package/lib/engine/engine_utils.d.ts +22 -5
- package/lib/engine/engine_utils.js +22 -5
- package/lib/engine/engine_utils.js.map +1 -1
- package/lib/engine/engine_utils_screenshot.d.ts +171 -14
- package/lib/engine/engine_utils_screenshot.js +65 -0
- package/lib/engine/engine_utils_screenshot.js.map +1 -1
- package/lib/engine/engine_utils_screenshot.xr.d.ts +1 -1
- package/lib/engine/engine_utils_screenshot.xr.js +1 -1
- package/lib/engine/extensions/NEEDLE_materialx.d.ts +2 -2
- package/lib/engine/extensions/NEEDLE_materialx.js +2 -2
- package/lib/engine/extensions/NEEDLE_materialx.js.map +1 -1
- package/lib/engine/extensions/NEEDLE_techniques_webgl.js +3 -0
- package/lib/engine/extensions/NEEDLE_techniques_webgl.js.map +1 -1
- package/lib/engine/extensions/index.d.ts +1 -1
- package/lib/engine/extensions/index.js +1 -1
- package/lib/engine/extensions/index.js.map +1 -1
- package/lib/engine/xr/NeedleXRSession.d.ts +5 -0
- package/lib/engine/xr/NeedleXRSession.js +5 -0
- package/lib/engine/xr/NeedleXRSession.js.map +1 -1
- package/lib/engine-components/AlignmentConstraint.d.ts +23 -3
- package/lib/engine-components/AlignmentConstraint.js +23 -3
- package/lib/engine-components/AlignmentConstraint.js.map +1 -1
- package/lib/engine-components/Animation.d.ts +42 -0
- package/lib/engine-components/Animation.js +36 -0
- package/lib/engine-components/Animation.js.map +1 -1
- package/lib/engine-components/Animator.d.ts +37 -4
- package/lib/engine-components/Animator.js +37 -4
- package/lib/engine-components/Animator.js.map +1 -1
- package/lib/engine-components/AudioListener.d.ts +1 -1
- package/lib/engine-components/AudioListener.js +1 -1
- package/lib/engine-components/AudioSource.d.ts +32 -10
- package/lib/engine-components/AudioSource.js +32 -10
- package/lib/engine-components/AudioSource.js.map +1 -1
- package/lib/engine-components/AxesHelper.d.ts +22 -3
- package/lib/engine-components/AxesHelper.js +22 -3
- package/lib/engine-components/AxesHelper.js.map +1 -1
- package/lib/engine-components/BasicIKConstraint.d.ts +27 -4
- package/lib/engine-components/BasicIKConstraint.js +27 -4
- package/lib/engine-components/BasicIKConstraint.js.map +1 -1
- package/lib/engine-components/Camera.d.ts +32 -2
- package/lib/engine-components/Camera.js +32 -2
- package/lib/engine-components/Camera.js.map +1 -1
- package/lib/engine-components/CharacterController.d.ts +68 -4
- package/lib/engine-components/CharacterController.js +68 -4
- package/lib/engine-components/CharacterController.js.map +1 -1
- package/lib/engine-components/Collider.d.ts +69 -12
- package/lib/engine-components/Collider.js +69 -12
- package/lib/engine-components/Collider.js.map +1 -1
- package/lib/engine-components/ContactShadows.d.ts +28 -6
- package/lib/engine-components/ContactShadows.js +33 -8
- package/lib/engine-components/ContactShadows.js.map +1 -1
- package/lib/engine-components/DeleteBox.d.ts +43 -2
- package/lib/engine-components/DeleteBox.js +43 -2
- package/lib/engine-components/DeleteBox.js.map +1 -1
- package/lib/engine-components/DeviceFlag.d.ts +21 -2
- package/lib/engine-components/DeviceFlag.js +21 -2
- package/lib/engine-components/DeviceFlag.js.map +1 -1
- package/lib/engine-components/DragControls.d.ts +32 -2
- package/lib/engine-components/DragControls.js +32 -2
- package/lib/engine-components/DragControls.js.map +1 -1
- package/lib/engine-components/DropListener.d.ts +33 -21
- package/lib/engine-components/DropListener.js +33 -21
- package/lib/engine-components/DropListener.js.map +1 -1
- package/lib/engine-components/Duplicatable.d.ts +36 -5
- package/lib/engine-components/Duplicatable.js +36 -5
- package/lib/engine-components/Duplicatable.js.map +1 -1
- package/lib/engine-components/EventList.d.ts +38 -10
- package/lib/engine-components/EventList.js +40 -12
- package/lib/engine-components/EventList.js.map +1 -1
- package/lib/engine-components/EventTrigger.d.ts +1 -1
- package/lib/engine-components/EventTrigger.js +1 -1
- package/lib/engine-components/Fog.d.ts +23 -1
- package/lib/engine-components/Fog.js +23 -1
- package/lib/engine-components/Fog.js.map +1 -1
- package/lib/engine-components/GridHelper.d.ts +18 -2
- package/lib/engine-components/GridHelper.js +18 -2
- package/lib/engine-components/GridHelper.js.map +1 -1
- package/lib/engine-components/GroundProjection.d.ts +24 -2
- package/lib/engine-components/GroundProjection.js +24 -2
- package/lib/engine-components/GroundProjection.js.map +1 -1
- package/lib/engine-components/Interactable.d.ts +17 -2
- package/lib/engine-components/Interactable.js +17 -2
- package/lib/engine-components/Interactable.js.map +1 -1
- package/lib/engine-components/Joints.d.ts +50 -7
- package/lib/engine-components/Joints.js +50 -7
- package/lib/engine-components/Joints.js.map +1 -1
- package/lib/engine-components/LODGroup.d.ts +36 -14
- package/lib/engine-components/LODGroup.js +43 -11
- package/lib/engine-components/LODGroup.js.map +1 -1
- package/lib/engine-components/Light.d.ts +30 -5
- package/lib/engine-components/Light.js +30 -5
- package/lib/engine-components/Light.js.map +1 -1
- package/lib/engine-components/LookAtConstraint.d.ts +22 -7
- package/lib/engine-components/LookAtConstraint.js +22 -7
- package/lib/engine-components/LookAtConstraint.js.map +1 -1
- package/lib/engine-components/NeedleMenu.d.ts +27 -5
- package/lib/engine-components/NeedleMenu.js +27 -5
- package/lib/engine-components/NeedleMenu.js.map +1 -1
- package/lib/engine-components/NestedGltf.d.ts +39 -4
- package/lib/engine-components/NestedGltf.js +42 -4
- package/lib/engine-components/NestedGltf.js.map +1 -1
- package/lib/engine-components/OffsetConstraint.d.ts +27 -3
- package/lib/engine-components/OffsetConstraint.js +27 -3
- package/lib/engine-components/OffsetConstraint.js.map +1 -1
- package/lib/engine-components/OrbitControls.d.ts +41 -3
- package/lib/engine-components/OrbitControls.js +41 -3
- package/lib/engine-components/OrbitControls.js.map +1 -1
- package/lib/engine-components/PlayerColor.d.ts +1 -1
- package/lib/engine-components/PlayerColor.js +1 -1
- package/lib/engine-components/ReflectionProbe.d.ts +17 -2
- package/lib/engine-components/ReflectionProbe.js +17 -3
- package/lib/engine-components/ReflectionProbe.js.map +1 -1
- package/lib/engine-components/Renderer.d.ts +35 -0
- package/lib/engine-components/Renderer.js +36 -2
- package/lib/engine-components/Renderer.js.map +1 -1
- package/lib/engine-components/RigidBody.d.ts +57 -5
- package/lib/engine-components/RigidBody.js +57 -5
- package/lib/engine-components/RigidBody.js.map +1 -1
- package/lib/engine-components/SceneSwitcher.d.ts +11 -0
- package/lib/engine-components/SceneSwitcher.js +11 -0
- package/lib/engine-components/SceneSwitcher.js.map +1 -1
- package/lib/engine-components/ScreenCapture.d.ts +39 -6
- package/lib/engine-components/ScreenCapture.js +39 -6
- package/lib/engine-components/ScreenCapture.js.map +1 -1
- package/lib/engine-components/SeeThrough.d.ts +70 -5
- package/lib/engine-components/SeeThrough.js +70 -5
- package/lib/engine-components/SeeThrough.js.map +1 -1
- package/lib/engine-components/ShadowCatcher.d.ts +56 -4
- package/lib/engine-components/ShadowCatcher.js +56 -4
- package/lib/engine-components/ShadowCatcher.js.map +1 -1
- package/lib/engine-components/Skybox.d.ts +43 -7
- package/lib/engine-components/Skybox.js +43 -7
- package/lib/engine-components/Skybox.js.map +1 -1
- package/lib/engine-components/SmoothFollow.d.ts +66 -7
- package/lib/engine-components/SmoothFollow.js +66 -7
- package/lib/engine-components/SmoothFollow.js.map +1 -1
- package/lib/engine-components/SpatialTrigger.d.ts +48 -1
- package/lib/engine-components/SpatialTrigger.js +48 -1
- package/lib/engine-components/SpatialTrigger.js.map +1 -1
- package/lib/engine-components/SpectatorCamera.d.ts +21 -3
- package/lib/engine-components/SpectatorCamera.js +21 -3
- package/lib/engine-components/SpectatorCamera.js.map +1 -1
- package/lib/engine-components/SyncedRoom.d.ts +7 -1
- package/lib/engine-components/SyncedRoom.js +7 -1
- package/lib/engine-components/SyncedRoom.js.map +1 -1
- package/lib/engine-components/SyncedTransform.d.ts +55 -6
- package/lib/engine-components/SyncedTransform.js +55 -6
- package/lib/engine-components/SyncedTransform.js.map +1 -1
- package/lib/engine-components/TransformGizmo.d.ts +30 -3
- package/lib/engine-components/TransformGizmo.js +30 -3
- package/lib/engine-components/TransformGizmo.js.map +1 -1
- package/lib/engine-components/VideoPlayer.d.ts +33 -6
- package/lib/engine-components/VideoPlayer.js +51 -6
- package/lib/engine-components/VideoPlayer.js.map +1 -1
- package/lib/engine-components/Voip.d.ts +33 -2
- package/lib/engine-components/Voip.js +33 -2
- package/lib/engine-components/Voip.js.map +1 -1
- package/lib/engine-components/export/usdz/USDZExporter.d.ts +47 -13
- package/lib/engine-components/export/usdz/USDZExporter.js +47 -13
- package/lib/engine-components/export/usdz/USDZExporter.js.map +1 -1
- package/lib/engine-components/particlesystem/ParticleSystem.d.ts +82 -3
- package/lib/engine-components/particlesystem/ParticleSystem.js +82 -3
- package/lib/engine-components/particlesystem/ParticleSystem.js.map +1 -1
- package/lib/engine-components/postprocessing/Effects/Antialiasing.d.ts +1 -0
- package/lib/engine-components/postprocessing/Effects/Antialiasing.js +1 -0
- package/lib/engine-components/postprocessing/Effects/Antialiasing.js.map +1 -1
- package/lib/engine-components/postprocessing/Effects/BloomEffect.d.ts +1 -1
- package/lib/engine-components/postprocessing/Effects/BloomEffect.js +1 -1
- package/lib/engine-components/postprocessing/Effects/ChromaticAberration.d.ts +1 -1
- package/lib/engine-components/postprocessing/Effects/ChromaticAberration.js +1 -1
- package/lib/engine-components/postprocessing/Effects/ColorAdjustments.d.ts +1 -1
- package/lib/engine-components/postprocessing/Effects/ColorAdjustments.js +1 -1
- package/lib/engine-components/postprocessing/Effects/DepthOfField.d.ts +1 -1
- package/lib/engine-components/postprocessing/Effects/DepthOfField.js +1 -1
- package/lib/engine-components/postprocessing/Effects/EffectWrapper.d.ts +1 -0
- package/lib/engine-components/postprocessing/Effects/EffectWrapper.js +1 -0
- package/lib/engine-components/postprocessing/Effects/EffectWrapper.js.map +1 -1
- package/lib/engine-components/postprocessing/Effects/Pixelation.d.ts +1 -1
- package/lib/engine-components/postprocessing/Effects/Pixelation.js +1 -1
- package/lib/engine-components/postprocessing/Effects/ScreenspaceAmbientOcclusion.d.ts +1 -1
- package/lib/engine-components/postprocessing/Effects/ScreenspaceAmbientOcclusion.js +1 -1
- package/lib/engine-components/postprocessing/Effects/ScreenspaceAmbientOcclusionN8.d.ts +1 -1
- package/lib/engine-components/postprocessing/Effects/ScreenspaceAmbientOcclusionN8.js +1 -1
- package/lib/engine-components/postprocessing/Effects/Sharpening.d.ts +1 -1
- package/lib/engine-components/postprocessing/Effects/Sharpening.js +1 -1
- package/lib/engine-components/postprocessing/Effects/TiltShiftEffect.d.ts +1 -1
- package/lib/engine-components/postprocessing/Effects/TiltShiftEffect.js +1 -1
- package/lib/engine-components/postprocessing/Effects/Tonemapping.d.ts +1 -1
- package/lib/engine-components/postprocessing/Effects/Tonemapping.js +1 -1
- package/lib/engine-components/postprocessing/Effects/Vignette.d.ts +1 -1
- package/lib/engine-components/postprocessing/Effects/Vignette.js +1 -1
- package/lib/engine-components/postprocessing/PostProcessingHandler.d.ts +1 -1
- package/lib/engine-components/postprocessing/PostProcessingHandler.js +1 -1
- package/lib/engine-components/postprocessing/Volume.d.ts +1 -1
- package/lib/engine-components/postprocessing/Volume.js +1 -1
- package/lib/engine-components/splines/Spline.d.ts +409 -12
- package/lib/engine-components/splines/Spline.js +409 -12
- package/lib/engine-components/splines/Spline.js.map +1 -1
- package/lib/engine-components/splines/SplineUtils.d.ts +1 -0
- package/lib/engine-components/splines/SplineUtils.js +1 -0
- package/lib/engine-components/splines/SplineUtils.js.map +1 -1
- package/lib/engine-components/splines/SplineWalker.d.ts +3 -1
- package/lib/engine-components/splines/SplineWalker.js +3 -1
- package/lib/engine-components/splines/SplineWalker.js.map +1 -1
- package/lib/engine-components/timeline/PlayableDirector.d.ts +103 -14
- package/lib/engine-components/timeline/PlayableDirector.js +95 -25
- package/lib/engine-components/timeline/PlayableDirector.js.map +1 -1
- package/lib/engine-components/timeline/TimelineModels.d.ts +14 -0
- package/lib/engine-components/timeline/TimelineModels.js +4 -0
- package/lib/engine-components/timeline/TimelineModels.js.map +1 -1
- package/lib/engine-components/ui/Button.d.ts +29 -3
- package/lib/engine-components/ui/Button.js +29 -3
- package/lib/engine-components/ui/Button.js.map +1 -1
- package/lib/engine-components/ui/Canvas.d.ts +29 -4
- package/lib/engine-components/ui/Canvas.js +29 -4
- package/lib/engine-components/ui/Canvas.js.map +1 -1
- package/lib/engine-components/ui/CanvasGroup.d.ts +1 -1
- package/lib/engine-components/ui/CanvasGroup.js +1 -1
- package/lib/engine-components/ui/EventSystem.d.ts +1 -1
- package/lib/engine-components/ui/EventSystem.js +1 -1
- package/lib/engine-components/ui/Graphic.d.ts +1 -0
- package/lib/engine-components/ui/Graphic.js +1 -0
- package/lib/engine-components/ui/Graphic.js.map +1 -1
- package/lib/engine-components/ui/Image.d.ts +22 -3
- package/lib/engine-components/ui/Image.js +22 -3
- package/lib/engine-components/ui/Image.js.map +1 -1
- package/lib/engine-components/ui/InputField.d.ts +1 -1
- package/lib/engine-components/ui/InputField.js +1 -1
- package/lib/engine-components/ui/Layout.d.ts +3 -0
- package/lib/engine-components/ui/Layout.js +3 -0
- package/lib/engine-components/ui/Layout.js.map +1 -1
- package/lib/engine-components/ui/Outline.d.ts +1 -1
- package/lib/engine-components/ui/Outline.js +1 -1
- package/lib/engine-components/ui/PointerEvents.d.ts +1 -1
- package/lib/engine-components/ui/PointerEvents.js +1 -1
- package/lib/engine-components/ui/Raycaster.d.ts +55 -6
- package/lib/engine-components/ui/Raycaster.js +55 -6
- package/lib/engine-components/ui/Raycaster.js.map +1 -1
- package/lib/engine-components/ui/RectTransform.d.ts +1 -1
- package/lib/engine-components/ui/RectTransform.js +1 -1
- package/lib/engine-components/ui/SpatialHtml.d.ts +1 -1
- package/lib/engine-components/ui/SpatialHtml.js +1 -1
- package/lib/engine-components/ui/Text.d.ts +23 -1
- package/lib/engine-components/ui/Text.js +23 -1
- package/lib/engine-components/ui/Text.js.map +1 -1
- package/lib/engine-components/utils/LookAt.d.ts +1 -1
- package/lib/engine-components/utils/LookAt.js +1 -1
- package/lib/engine-components/utils/OpenURL.d.ts +2 -1
- package/lib/engine-components/utils/OpenURL.js +2 -1
- package/lib/engine-components/utils/OpenURL.js.map +1 -1
- package/lib/engine-components/web/Clickthrough.d.ts +116 -7
- package/lib/engine-components/web/Clickthrough.js +116 -7
- package/lib/engine-components/web/Clickthrough.js.map +1 -1
- package/lib/engine-components/web/CursorFollow.d.ts +172 -7
- package/lib/engine-components/web/CursorFollow.js +172 -7
- package/lib/engine-components/web/CursorFollow.js.map +1 -1
- package/lib/engine-components/web/HoverAnimation.d.ts +140 -11
- package/lib/engine-components/web/HoverAnimation.js +140 -11
- package/lib/engine-components/web/HoverAnimation.js.map +1 -1
- package/lib/engine-components/web/ScrollFollow.d.ts +5 -1
- package/lib/engine-components/web/ScrollFollow.js +5 -1
- package/lib/engine-components/web/ScrollFollow.js.map +1 -1
- package/lib/engine-components/web/ViewBox.d.ts +116 -16
- package/lib/engine-components/web/ViewBox.js +110 -16
- package/lib/engine-components/web/ViewBox.js.map +1 -1
- package/lib/engine-components/webxr/TeleportTarget.d.ts +21 -2
- package/lib/engine-components/webxr/TeleportTarget.js +21 -2
- package/lib/engine-components/webxr/TeleportTarget.js.map +1 -1
- package/lib/engine-components/webxr/WebARCameraBackground.d.ts +9 -0
- package/lib/engine-components/webxr/WebARCameraBackground.js +9 -0
- package/lib/engine-components/webxr/WebARCameraBackground.js.map +1 -1
- package/lib/engine-components/webxr/WebXR.d.ts +11 -2
- package/lib/engine-components/webxr/WebXR.js +11 -2
- package/lib/engine-components/webxr/WebXR.js.map +1 -1
- package/lib/engine-components/webxr/WebXRAvatar.d.ts +39 -2
- package/lib/engine-components/webxr/WebXRAvatar.js +35 -3
- package/lib/engine-components/webxr/WebXRAvatar.js.map +1 -1
- package/lib/engine-components/webxr/WebXRImageTracking.d.ts +266 -30
- package/lib/engine-components/webxr/WebXRImageTracking.js +266 -30
- package/lib/engine-components/webxr/WebXRImageTracking.js.map +1 -1
- package/lib/engine-components/webxr/WebXRPlaneTracking.d.ts +1 -1
- package/lib/engine-components/webxr/WebXRPlaneTracking.js +1 -1
- package/lib/engine-components/webxr/XRFlag.d.ts +29 -2
- package/lib/engine-components/webxr/XRFlag.js +29 -2
- package/lib/engine-components/webxr/XRFlag.js.map +1 -1
- package/package.json +3 -3
- package/plugins/vite/custom-element-data.js +128 -19
- package/src/engine/engine_context.ts +33 -3
- package/src/engine/engine_gameobject.ts +73 -0
- package/src/engine/engine_input.ts +83 -7
- package/src/engine/engine_math.ts +81 -2
- package/src/engine/engine_networking.ts +186 -17
- package/src/engine/engine_networking_auto.ts +36 -9
- package/src/engine/engine_physics.ts +41 -1
- package/src/engine/engine_physics_rapier.ts +81 -0
- package/src/engine/engine_serialization_decorator.ts +28 -2
- package/src/engine/engine_time.ts +23 -3
- package/src/engine/engine_util_decorator.ts +31 -1
- package/src/engine/engine_utils.ts +22 -5
- package/src/engine/engine_utils_screenshot.ts +241 -17
- package/src/engine/engine_utils_screenshot.xr.ts +1 -1
- package/src/engine/extensions/NEEDLE_materialx.ts +5 -4
- package/src/engine/extensions/NEEDLE_techniques_webgl.ts +3 -0
- package/src/engine/extensions/index.ts +2 -2
- package/src/engine/xr/NeedleXRSession.ts +5 -0
- package/src/engine-components/AlignmentConstraint.ts +24 -4
- package/src/engine-components/Animation.ts +44 -2
- package/src/engine-components/Animator.ts +40 -7
- package/src/engine-components/AudioListener.ts +1 -1
- package/src/engine-components/AudioSource.ts +37 -15
- package/src/engine-components/AxesHelper.ts +23 -4
- package/src/engine-components/BasicIKConstraint.ts +28 -5
- package/src/engine-components/Camera.ts +33 -3
- package/src/engine-components/CharacterController.ts +74 -7
- package/src/engine-components/Collider.ts +78 -21
- package/src/engine-components/ContactShadows.ts +41 -11
- package/src/engine-components/DeleteBox.ts +43 -2
- package/src/engine-components/DeviceFlag.ts +22 -3
- package/src/engine-components/DragControls.ts +32 -2
- package/src/engine-components/DropListener.ts +41 -29
- package/src/engine-components/Duplicatable.ts +37 -6
- package/src/engine-components/EventList.ts +43 -15
- package/src/engine-components/EventTrigger.ts +1 -1
- package/src/engine-components/Fog.ts +23 -1
- package/src/engine-components/GridHelper.ts +18 -2
- package/src/engine-components/GroundProjection.ts +25 -3
- package/src/engine-components/Interactable.ts +17 -2
- package/src/engine-components/Joints.ts +51 -8
- package/src/engine-components/LODGroup.ts +45 -11
- package/src/engine-components/Light.ts +35 -13
- package/src/engine-components/LookAtConstraint.ts +26 -8
- package/src/engine-components/NeedleMenu.ts +29 -7
- package/src/engine-components/NestedGltf.ts +40 -4
- package/src/engine-components/OffsetConstraint.ts +27 -3
- package/src/engine-components/OrbitControls.ts +41 -3
- package/src/engine-components/PlayerColor.ts +1 -1
- package/src/engine-components/ReflectionProbe.ts +19 -5
- package/src/engine-components/Renderer.ts +35 -1
- package/src/engine-components/RigidBody.ts +64 -8
- package/src/engine-components/SceneSwitcher.ts +11 -0
- package/src/engine-components/ScreenCapture.ts +42 -9
- package/src/engine-components/SeeThrough.ts +76 -9
- package/src/engine-components/ShadowCatcher.ts +61 -6
- package/src/engine-components/Skybox.ts +48 -12
- package/src/engine-components/SmoothFollow.ts +68 -7
- package/src/engine-components/SpatialTrigger.ts +51 -4
- package/src/engine-components/SpectatorCamera.ts +23 -5
- package/src/engine-components/SyncedRoom.ts +8 -2
- package/src/engine-components/SyncedTransform.ts +59 -10
- package/src/engine-components/TransformGizmo.ts +31 -4
- package/src/engine-components/VideoPlayer.ts +54 -6
- package/src/engine-components/Voip.ts +33 -2
- package/src/engine-components/export/usdz/USDZExporter.ts +47 -13
- package/src/engine-components/particlesystem/ParticleSystem.ts +84 -5
- package/src/engine-components/postprocessing/Effects/Antialiasing.ts +1 -0
- package/src/engine-components/postprocessing/Effects/BloomEffect.ts +1 -1
- package/src/engine-components/postprocessing/Effects/ChromaticAberration.ts +1 -1
- package/src/engine-components/postprocessing/Effects/ColorAdjustments.ts +1 -1
- package/src/engine-components/postprocessing/Effects/DepthOfField.ts +1 -1
- package/src/engine-components/postprocessing/Effects/EffectWrapper.ts +1 -0
- package/src/engine-components/postprocessing/Effects/Pixelation.ts +1 -1
- package/src/engine-components/postprocessing/Effects/ScreenspaceAmbientOcclusion.ts +1 -1
- package/src/engine-components/postprocessing/Effects/ScreenspaceAmbientOcclusionN8.ts +1 -1
- package/src/engine-components/postprocessing/Effects/Sharpening.ts +1 -1
- package/src/engine-components/postprocessing/Effects/TiltShiftEffect.ts +1 -1
- package/src/engine-components/postprocessing/Effects/Tonemapping.ts +1 -1
- package/src/engine-components/postprocessing/Effects/Vignette.ts +1 -1
- package/src/engine-components/postprocessing/PostProcessingHandler.ts +1 -1
- package/src/engine-components/postprocessing/Volume.ts +1 -1
- package/src/engine-components/splines/Spline.ts +412 -14
- package/src/engine-components/splines/SplineUtils.ts +1 -0
- package/src/engine-components/splines/SplineWalker.ts +4 -2
- package/src/engine-components/timeline/PlayableDirector.ts +108 -27
- package/src/engine-components/timeline/SignalAsset.ts +1 -1
- package/src/engine-components/timeline/TimelineModels.ts +18 -2
- package/src/engine-components/ui/Button.ts +29 -3
- package/src/engine-components/ui/Canvas.ts +29 -4
- package/src/engine-components/ui/CanvasGroup.ts +2 -2
- package/src/engine-components/ui/EventSystem.ts +1 -1
- package/src/engine-components/ui/Graphic.ts +1 -0
- package/src/engine-components/ui/Image.ts +22 -3
- package/src/engine-components/ui/InputField.ts +2 -2
- package/src/engine-components/ui/Layout.ts +3 -0
- package/src/engine-components/ui/Outline.ts +1 -1
- package/src/engine-components/ui/PointerEvents.ts +1 -1
- package/src/engine-components/ui/Raycaster.ts +57 -8
- package/src/engine-components/ui/RectTransform.ts +2 -2
- package/src/engine-components/ui/SpatialHtml.ts +1 -1
- package/src/engine-components/ui/Text.ts +24 -2
- package/src/engine-components/utils/LookAt.ts +1 -1
- package/src/engine-components/utils/OpenURL.ts +2 -1
- package/src/engine-components/web/Clickthrough.ts +119 -10
- package/src/engine-components/web/CursorFollow.ts +175 -9
- package/src/engine-components/web/HoverAnimation.ts +142 -13
- package/src/engine-components/web/ScrollFollow.ts +5 -1
- package/src/engine-components/web/ViewBox.ts +118 -18
- package/src/engine-components/webxr/TeleportTarget.ts +23 -4
- package/src/engine-components/webxr/WebARCameraBackground.ts +12 -3
- package/src/engine-components/webxr/WebXR.ts +12 -3
- package/src/engine-components/webxr/WebXRAvatar.ts +41 -4
- package/src/engine-components/webxr/WebXRImageTracking.ts +282 -38
- package/src/engine-components/webxr/WebXRPlaneTracking.ts +1 -1
- package/src/engine-components/webxr/XRFlag.ts +30 -3
- package/dist/gltf-progressive-BURrJW0U.umd.cjs +0 -8
- package/dist/gltf-progressive-DHLDFNvQ.min.js +0 -8
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { BufferGeometry as
|
|
1
|
+
import { BufferGeometry as q, Mesh as V, Box3 as ge, Vector3 as C, Sphere as Oe, CompressedTexture as Ge, Texture as F, Matrix3 as Fe, InterleavedBuffer as We, InterleavedBufferAttribute as Ue, BufferAttribute as ze, TextureLoader as Ne, Matrix4 as _e, Clock as Ee, MeshStandardMaterial as qe } from "./three-VvRoMeIN.js";
|
|
2
2
|
import { DRACOLoader as Ve, KTX2Loader as Xe, MeshoptDecoder as je, GLTFLoader as xe } from "./three-examples-BhfOE7NG.js";
|
|
3
3
|
const Ke = "";
|
|
4
4
|
globalThis.GLTF_PROGRESSIVE_VERSION = Ke;
|
|
5
5
|
console.debug("[gltf-progressive] version -");
|
|
6
|
-
let
|
|
7
|
-
const Ye =
|
|
6
|
+
let R = "https://www.gstatic.com/draco/versioned/decoders/1.5.7/", X = "https://cdn.needle.tools/static/three/0.179.1/basis2/";
|
|
7
|
+
const Ye = R, He = X, Se = new URL(R + "draco_decoder.js");
|
|
8
8
|
Se.searchParams.append("range", "true");
|
|
9
9
|
fetch(Se, {
|
|
10
10
|
method: "GET",
|
|
@@ -12,30 +12,30 @@ fetch(Se, {
|
|
|
12
12
|
Range: "bytes=0-1"
|
|
13
13
|
}
|
|
14
14
|
}).catch((i) => {
|
|
15
|
-
console.debug(`Failed to fetch remote Draco decoder from ${
|
|
15
|
+
console.debug(`Failed to fetch remote Draco decoder from ${R} (offline: ${typeof navigator < "u" ? navigator.onLine : "unknown"})`), R === Ye && Je("./include/draco/"), X === He && Ze("./include/ktx2/");
|
|
16
16
|
}).finally(() => {
|
|
17
|
-
|
|
17
|
+
Te();
|
|
18
18
|
});
|
|
19
19
|
const Qe = () => ({
|
|
20
|
-
dracoDecoderPath:
|
|
21
|
-
ktx2TranscoderPath:
|
|
20
|
+
dracoDecoderPath: R,
|
|
21
|
+
ktx2TranscoderPath: X
|
|
22
22
|
});
|
|
23
23
|
function Je(i) {
|
|
24
|
-
|
|
24
|
+
R = i, A && A[pe] != R ? (console.debug("Updating Draco decoder path to " + i), A[pe] = R, A.setDecoderPath(R), A.preload()) : console.debug("Setting Draco decoder path to " + i);
|
|
25
25
|
}
|
|
26
26
|
function Ze(i) {
|
|
27
|
-
|
|
27
|
+
X = i, $ && $.transcoderPath != X ? (console.debug("Updating KTX2 transcoder path to " + i), $.setTranscoderPath(X), $.init()) : console.debug("Setting KTX2 transcoder path to " + i);
|
|
28
28
|
}
|
|
29
29
|
function we(i) {
|
|
30
|
-
return
|
|
30
|
+
return Te(), i ? $.detectSupport(i) : i !== null && console.warn("No renderer provided to detect ktx2 support - loading KTX2 textures might fail"), { dracoLoader: A, ktx2Loader: $, meshoptDecoder: ne };
|
|
31
31
|
}
|
|
32
|
-
function
|
|
33
|
-
i.dracoLoader || i.setDRACOLoader(
|
|
32
|
+
function Pe(i) {
|
|
33
|
+
i.dracoLoader || i.setDRACOLoader(A), i.ktx2Loader || i.setKTX2Loader($), i.meshoptDecoder || i.setMeshoptDecoder(ne);
|
|
34
34
|
}
|
|
35
35
|
const pe = /* @__PURE__ */ Symbol("dracoDecoderPath");
|
|
36
|
-
let
|
|
37
|
-
function
|
|
38
|
-
|
|
36
|
+
let A, ne, $;
|
|
37
|
+
function Te() {
|
|
38
|
+
A || (A = new Ve(), A[pe] = R, A.setDecoderPath(R), A.setDecoderConfig({ type: "js" }), A.preload()), $ || ($ = new Xe(), $.setTranscoderPath(X), $.init()), ne || (ne = je);
|
|
39
39
|
}
|
|
40
40
|
const me = /* @__PURE__ */ new WeakMap();
|
|
41
41
|
function Ae(i, t) {
|
|
@@ -54,8 +54,8 @@ function tt(...i) {
|
|
|
54
54
|
return i[0] = e, et?.call(this, ...i);
|
|
55
55
|
}
|
|
56
56
|
xe.prototype.load = tt;
|
|
57
|
-
|
|
58
|
-
function
|
|
57
|
+
j("debugprogressive");
|
|
58
|
+
function j(i) {
|
|
59
59
|
if (typeof window > "u") return !1;
|
|
60
60
|
const e = new URL(window.location.href).searchParams.get(i);
|
|
61
61
|
return e == null || e === "0" || e === "false" ? !1 : e === "" ? !0 : e;
|
|
@@ -71,10 +71,10 @@ function st(i, t) {
|
|
|
71
71
|
}
|
|
72
72
|
return t;
|
|
73
73
|
}
|
|
74
|
-
function
|
|
75
|
-
return
|
|
74
|
+
function Ce() {
|
|
75
|
+
return Y !== void 0 || (Y = /iPhone|iPad|iPod|Android|IEMobile/i.test(navigator.userAgent), j("debugprogressive") && console.log("[glTF Progressive]: isMobileDevice", Y)), Y;
|
|
76
76
|
}
|
|
77
|
-
let
|
|
77
|
+
let Y;
|
|
78
78
|
function Me() {
|
|
79
79
|
if (typeof window > "u") return !1;
|
|
80
80
|
const i = new URL(window.location.href), t = i.hostname === "localhost" || /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(i.hostname);
|
|
@@ -116,7 +116,7 @@ class rt {
|
|
|
116
116
|
}
|
|
117
117
|
const nt = typeof window > "u" && typeof document > "u", ye = /* @__PURE__ */ Symbol("needle:raycast-mesh");
|
|
118
118
|
function Z(i) {
|
|
119
|
-
return i?.[ye] instanceof
|
|
119
|
+
return i?.[ye] instanceof q ? i[ye] : null;
|
|
120
120
|
}
|
|
121
121
|
function ot(i, t) {
|
|
122
122
|
if ((i.type === "Mesh" || i.type === "SkinnedMesh") && !Z(i)) {
|
|
@@ -126,56 +126,56 @@ function ot(i, t) {
|
|
|
126
126
|
}
|
|
127
127
|
function it(i = !0) {
|
|
128
128
|
if (i) {
|
|
129
|
-
if (
|
|
130
|
-
const t =
|
|
131
|
-
|
|
129
|
+
if (H) return;
|
|
130
|
+
const t = H = V.prototype.raycast;
|
|
131
|
+
V.prototype.raycast = function(e, s) {
|
|
132
132
|
const n = this, r = Z(n);
|
|
133
133
|
let o;
|
|
134
134
|
r && n.isMesh && (o = n.geometry, n.geometry = r), t.call(this, e, s), o && (n.geometry = o);
|
|
135
135
|
};
|
|
136
136
|
} else {
|
|
137
|
-
if (!
|
|
138
|
-
|
|
137
|
+
if (!H) return;
|
|
138
|
+
V.prototype.raycast = H, H = null;
|
|
139
139
|
}
|
|
140
140
|
}
|
|
141
|
-
let
|
|
141
|
+
let H = null;
|
|
142
142
|
function at(i) {
|
|
143
|
-
const t = new
|
|
143
|
+
const t = new q();
|
|
144
144
|
for (const e in i.attributes)
|
|
145
145
|
t.setAttribute(e, i.getAttribute(e));
|
|
146
146
|
return t.setIndex(i.getIndex()), t;
|
|
147
147
|
}
|
|
148
|
-
const
|
|
149
|
-
let
|
|
150
|
-
if (
|
|
148
|
+
const z = new Array(), h = j("debugprogressive");
|
|
149
|
+
let J, E = -1;
|
|
150
|
+
if (h) {
|
|
151
151
|
let i = function() {
|
|
152
|
-
|
|
152
|
+
E += 1, E >= t && (E = -1), console.log(`Toggle LOD level [${E}]`);
|
|
153
153
|
}, t = 6;
|
|
154
154
|
window.addEventListener("keyup", (e) => {
|
|
155
|
-
e.key === "p" && i(), e.key === "w" && (
|
|
155
|
+
e.key === "p" && i(), e.key === "w" && (J = !J, console.log(`Toggle wireframe [${J}]`));
|
|
156
156
|
const s = parseInt(e.key);
|
|
157
|
-
!isNaN(s) && s >= 0 && (
|
|
157
|
+
!isNaN(s) && s >= 0 && (E = s, console.log(`Set LOD level to [${E}]`));
|
|
158
158
|
});
|
|
159
159
|
}
|
|
160
|
-
function
|
|
161
|
-
if (
|
|
160
|
+
function ke(i) {
|
|
161
|
+
if (h && J !== void 0)
|
|
162
162
|
if (Array.isArray(i))
|
|
163
163
|
for (const t of i)
|
|
164
|
-
|
|
165
|
-
else i && "wireframe" in i && (i.wireframe =
|
|
164
|
+
ke(t);
|
|
165
|
+
else i && "wireframe" in i && (i.wireframe = J === !0);
|
|
166
166
|
}
|
|
167
|
-
const
|
|
167
|
+
const Q = new Array();
|
|
168
168
|
let lt = 0;
|
|
169
|
-
const ut =
|
|
169
|
+
const ut = Ce() ? 2 : 10;
|
|
170
170
|
function dt(i) {
|
|
171
|
-
if (
|
|
172
|
-
const s =
|
|
173
|
-
|
|
171
|
+
if (Q.length < ut) {
|
|
172
|
+
const s = Q.length;
|
|
173
|
+
h && console.warn(`[Worker] Creating new worker #${s}`);
|
|
174
174
|
const n = Le.createWorker(i || {});
|
|
175
|
-
return
|
|
175
|
+
return Q.push(n), n;
|
|
176
176
|
}
|
|
177
|
-
const t = lt++ %
|
|
178
|
-
return
|
|
177
|
+
const t = lt++ % Q.length;
|
|
178
|
+
return Q[t];
|
|
179
179
|
}
|
|
180
180
|
class Le {
|
|
181
181
|
constructor(t, e) {
|
|
@@ -231,7 +231,7 @@ class Le {
|
|
|
231
231
|
}
|
|
232
232
|
function ct(i) {
|
|
233
233
|
for (const t of i.geometries) {
|
|
234
|
-
const e = t.geometry, s = new
|
|
234
|
+
const e = t.geometry, s = new q();
|
|
235
235
|
if (s.name = e.name || "", e.index) {
|
|
236
236
|
const n = e.index;
|
|
237
237
|
s.setIndex(le(n));
|
|
@@ -245,16 +245,16 @@ function ct(i) {
|
|
|
245
245
|
const o = e.morphAttributes[n].map((l) => le(l));
|
|
246
246
|
s.morphAttributes[n] = o;
|
|
247
247
|
}
|
|
248
|
-
if (s.morphTargetsRelative = e.morphTargetsRelative ?? !1, s.boundingBox = new ge(), s.boundingBox.min = new
|
|
248
|
+
if (s.morphTargetsRelative = e.morphTargetsRelative ?? !1, s.boundingBox = new ge(), s.boundingBox.min = new C(
|
|
249
249
|
e.boundingBox?.min.x,
|
|
250
250
|
e.boundingBox?.min.y,
|
|
251
251
|
e.boundingBox?.min.z
|
|
252
|
-
), s.boundingBox.max = new
|
|
252
|
+
), s.boundingBox.max = new C(
|
|
253
253
|
e.boundingBox?.max.x,
|
|
254
254
|
e.boundingBox?.max.y,
|
|
255
255
|
e.boundingBox?.max.z
|
|
256
256
|
), s.boundingSphere = new Oe(
|
|
257
|
-
new
|
|
257
|
+
new C(
|
|
258
258
|
e.boundingSphere?.center.x,
|
|
259
259
|
e.boundingSphere?.center.y,
|
|
260
260
|
e.boundingSphere?.center.z
|
|
@@ -285,7 +285,7 @@ function ct(i) {
|
|
|
285
285
|
e.colorSpace
|
|
286
286
|
);
|
|
287
287
|
} else
|
|
288
|
-
s = new
|
|
288
|
+
s = new F(
|
|
289
289
|
e.image,
|
|
290
290
|
e.mapping,
|
|
291
291
|
e.wrapS,
|
|
@@ -313,11 +313,11 @@ function le(i) {
|
|
|
313
313
|
} else "isBufferAttribute" in i && i.isBufferAttribute && (t = new ze(i.array, i.itemSize, i.normalized), t.usage = i.usage, t.gpuType = i.gpuType, t.updateRanges = i.updateRanges);
|
|
314
314
|
return t;
|
|
315
315
|
}
|
|
316
|
-
const ft =
|
|
317
|
-
class
|
|
316
|
+
const ft = j("gltf-progressive-worker"), ht = j("gltf-progressive-reduce-mipmaps"), ue = /* @__PURE__ */ Symbol("needle-progressive-texture"), W = "NEEDLE_progressive";
|
|
317
|
+
class m {
|
|
318
318
|
/** The name of the extension */
|
|
319
319
|
get name() {
|
|
320
|
-
return
|
|
320
|
+
return W;
|
|
321
321
|
}
|
|
322
322
|
// #region PUBLIC API
|
|
323
323
|
static getMeshLODExtension(t) {
|
|
@@ -340,7 +340,7 @@ class y {
|
|
|
340
340
|
this.getMaterialMinMaxLODsCount(l, e);
|
|
341
341
|
return t[n] = e, e;
|
|
342
342
|
}
|
|
343
|
-
if (
|
|
343
|
+
if (h === "verbose" && console.log("getMaterialMinMaxLODsCount", t), t.type === "ShaderMaterial" || t.type === "RawShaderMaterial") {
|
|
344
344
|
const l = t;
|
|
345
345
|
for (const a of Object.keys(l.uniforms)) {
|
|
346
346
|
const u = l.uniforms[a].value;
|
|
@@ -352,7 +352,7 @@ class y {
|
|
|
352
352
|
a?.isTexture === !0 && o(a, e);
|
|
353
353
|
}
|
|
354
354
|
else
|
|
355
|
-
|
|
355
|
+
h && console.warn(`[getMaterialMinMaxLODsCount] Unsupported material type: ${t.type}`);
|
|
356
356
|
return t[n] = e, e;
|
|
357
357
|
function o(l, a) {
|
|
358
358
|
const u = s.getAssignedLODInformation(l);
|
|
@@ -360,9 +360,9 @@ class y {
|
|
|
360
360
|
const d = s.lodInfos.get(u.key);
|
|
361
361
|
if (d && d.lods) {
|
|
362
362
|
a.min_count = Math.min(a.min_count, d.lods.length), a.max_count = Math.max(a.max_count, d.lods.length);
|
|
363
|
-
for (let
|
|
364
|
-
const
|
|
365
|
-
|
|
363
|
+
for (let y = 0; y < d.lods.length; y++) {
|
|
364
|
+
const w = d.lods[y];
|
|
365
|
+
w.width && (a.lods[y] = a.lods[y] || { min_height: 1 / 0, max_height: 0 }, a.lods[y].min_height = Math.min(a.lods[y].min_height, w.height), a.lods[y].max_height = Math.max(a.lods[y].max_height, w.height));
|
|
366
366
|
}
|
|
367
367
|
}
|
|
368
368
|
}
|
|
@@ -416,20 +416,20 @@ class y {
|
|
|
416
416
|
*/
|
|
417
417
|
static assignMeshLOD(t, e) {
|
|
418
418
|
if (!t) return Promise.resolve(null);
|
|
419
|
-
if (t instanceof
|
|
419
|
+
if (t instanceof V || t.isMesh === !0) {
|
|
420
420
|
const s = t.geometry, n = this.getAssignedLODInformation(s);
|
|
421
421
|
if (!n)
|
|
422
422
|
return Promise.resolve(null);
|
|
423
|
-
for (const r of
|
|
423
|
+
for (const r of z)
|
|
424
424
|
r.onBeforeGetLODMesh?.(t, e);
|
|
425
|
-
return t["LOD:requested level"] = e,
|
|
425
|
+
return t["LOD:requested level"] = e, m.getOrLoadLOD(s, e).then((r) => {
|
|
426
426
|
if (Array.isArray(r)) {
|
|
427
427
|
const o = n.index || 0;
|
|
428
428
|
r = r[o];
|
|
429
429
|
}
|
|
430
|
-
return t["LOD:requested level"] === e && (delete t["LOD:requested level"], r && s != r && (r?.isBufferGeometry ? t.geometry = r :
|
|
430
|
+
return t["LOD:requested level"] === e && (delete t["LOD:requested level"], r && s != r && (r?.isBufferGeometry ? t.geometry = r : h && console.error("Invalid LOD geometry", r))), r;
|
|
431
431
|
}).catch((r) => (console.error("Error loading mesh LOD", t, r), null));
|
|
432
|
-
} else
|
|
432
|
+
} else h && console.error("Invalid call to assignMeshLOD: Request mesh LOD but the object is not a mesh", t);
|
|
433
433
|
return Promise.resolve(null);
|
|
434
434
|
}
|
|
435
435
|
static assignTextureLOD(t, e = 0) {
|
|
@@ -479,7 +479,7 @@ class y {
|
|
|
479
479
|
return l;
|
|
480
480
|
});
|
|
481
481
|
}
|
|
482
|
-
if (t instanceof
|
|
482
|
+
if (t instanceof F || t.isTexture === !0) {
|
|
483
483
|
const s = t;
|
|
484
484
|
return this.assignTextureLODForSlot(s, e, null, null);
|
|
485
485
|
}
|
|
@@ -487,25 +487,25 @@ class y {
|
|
|
487
487
|
}
|
|
488
488
|
// #region INTERNAL
|
|
489
489
|
static assignTextureLODForSlot(t, e, s, n) {
|
|
490
|
-
return t?.isTexture !== !0 ? Promise.resolve(null) : n === "glyphMap" ? Promise.resolve(t) :
|
|
490
|
+
return t?.isTexture !== !0 ? Promise.resolve(null) : n === "glyphMap" ? Promise.resolve(t) : m.getOrLoadLOD(t, e).then((r) => {
|
|
491
491
|
if (Array.isArray(r))
|
|
492
492
|
return console.warn("Progressive: Got an array of textures for a texture slot, this should not happen..."), null;
|
|
493
493
|
if (r?.isTexture === !0) {
|
|
494
494
|
if (r != t && s && n) {
|
|
495
495
|
const o = s[n];
|
|
496
|
-
if (o && !
|
|
496
|
+
if (o && !h) {
|
|
497
497
|
const l = this.getAssignedLODInformation(o);
|
|
498
498
|
if (l && l?.level < e)
|
|
499
|
-
return
|
|
499
|
+
return h === "verbose" && console.warn("Assigned texture level is already higher: ", l.level, e, s, o, r), null;
|
|
500
500
|
}
|
|
501
501
|
if (ht && r.mipmaps) {
|
|
502
502
|
const l = r.mipmaps.length;
|
|
503
|
-
r.mipmaps.length = Math.min(r.mipmaps.length, 3), l !== r.mipmaps.length &&
|
|
503
|
+
r.mipmaps.length = Math.min(r.mipmaps.length, 3), l !== r.mipmaps.length && h && console.debug(`Reduced mipmap count from ${l} to ${r.mipmaps.length} for ${r.uuid}: ${r.image?.width}x${r.image?.height}.`);
|
|
504
504
|
}
|
|
505
505
|
s[n] = r;
|
|
506
506
|
}
|
|
507
507
|
return r;
|
|
508
|
-
} else
|
|
508
|
+
} else h == "verbose" && console.warn("No LOD found for", t, e);
|
|
509
509
|
return null;
|
|
510
510
|
}).catch((r) => (console.error("Error loading LOD", t, r), null));
|
|
511
511
|
}
|
|
@@ -513,13 +513,13 @@ class y {
|
|
|
513
513
|
url;
|
|
514
514
|
constructor(t) {
|
|
515
515
|
const e = t.options.path;
|
|
516
|
-
|
|
516
|
+
h && console.log("Progressive extension registered for", e), this.parser = t, this.url = e;
|
|
517
517
|
}
|
|
518
518
|
_isLoadingMesh;
|
|
519
519
|
loadMesh = (t) => {
|
|
520
520
|
if (this._isLoadingMesh) return null;
|
|
521
|
-
const e = this.parser.json.meshes[t]?.extensions?.[
|
|
522
|
-
return e ? (this._isLoadingMesh = !0, this.parser.getDependency("mesh", t).then((s) => (this._isLoadingMesh = !1, s &&
|
|
521
|
+
const e = this.parser.json.meshes[t]?.extensions?.[W];
|
|
522
|
+
return e ? (this._isLoadingMesh = !0, this.parser.getDependency("mesh", t).then((s) => (this._isLoadingMesh = !1, s && m.registerMesh(this.url, e.guid, s, e.lods?.length, 0, e), s))) : null;
|
|
523
523
|
};
|
|
524
524
|
// private _isLoadingTexture;
|
|
525
525
|
// loadTexture = (textureIndex: number) => {
|
|
@@ -536,30 +536,30 @@ class y {
|
|
|
536
536
|
// });
|
|
537
537
|
// }
|
|
538
538
|
afterRoot(t) {
|
|
539
|
-
return
|
|
539
|
+
return h && console.log("AFTER", this.url, t), this.parser.json.textures?.forEach((e, s) => {
|
|
540
540
|
if (e?.extensions) {
|
|
541
|
-
const n = e?.extensions[
|
|
541
|
+
const n = e?.extensions[W];
|
|
542
542
|
if (n) {
|
|
543
543
|
if (!n.lods) {
|
|
544
|
-
|
|
544
|
+
h && console.warn("Texture has no LODs", n);
|
|
545
545
|
return;
|
|
546
546
|
}
|
|
547
547
|
let r = !1;
|
|
548
548
|
for (const o of this.parser.associations.keys())
|
|
549
|
-
o.isTexture === !0 && this.parser.associations.get(o)?.textures === s && (r = !0,
|
|
549
|
+
o.isTexture === !0 && this.parser.associations.get(o)?.textures === s && (r = !0, m.registerTexture(this.url, o, n.lods?.length, s, n));
|
|
550
550
|
r || this.parser.getDependency("texture", s).then((o) => {
|
|
551
|
-
o &&
|
|
551
|
+
o && m.registerTexture(this.url, o, n.lods?.length, s, n);
|
|
552
552
|
});
|
|
553
553
|
}
|
|
554
554
|
}
|
|
555
555
|
}), this.parser.json.meshes?.forEach((e, s) => {
|
|
556
556
|
if (e?.extensions) {
|
|
557
|
-
const n = e?.extensions[
|
|
557
|
+
const n = e?.extensions[W];
|
|
558
558
|
if (n && n.lods) {
|
|
559
559
|
for (const r of this.parser.associations.keys())
|
|
560
560
|
if (r.isMesh) {
|
|
561
561
|
const o = this.parser.associations.get(r);
|
|
562
|
-
o?.meshes === s &&
|
|
562
|
+
o?.meshes === s && m.registerMesh(this.url, n.guid, r, n.lods.length, o.primitives, n);
|
|
563
563
|
}
|
|
564
564
|
}
|
|
565
565
|
}
|
|
@@ -570,16 +570,16 @@ class y {
|
|
|
570
570
|
*/
|
|
571
571
|
static registerTexture = (t, e, s, n, r) => {
|
|
572
572
|
if (!e) {
|
|
573
|
-
|
|
573
|
+
h && console.error("!! gltf-progressive: Called register texture without texture");
|
|
574
574
|
return;
|
|
575
575
|
}
|
|
576
|
-
if (
|
|
576
|
+
if (h) {
|
|
577
577
|
const l = e.image?.width || e.source?.data?.width || 0, a = e.image?.height || e.source?.data?.height || 0;
|
|
578
578
|
console.log(`> gltf-progressive: register texture[${n}] "${e.name || e.uuid}", Current: ${l}x${a}, Max: ${r.lods[0]?.width}x${r.lods[0]?.height}, uuid: ${e.uuid}`, r, e);
|
|
579
579
|
}
|
|
580
580
|
e.source && (e.source[ue] = r);
|
|
581
581
|
const o = r.guid;
|
|
582
|
-
|
|
582
|
+
m.assignLODInformation(t, e, o, s, n), m.lodInfos.set(o, r), m.lowresCache.set(o, new WeakRef(e));
|
|
583
583
|
};
|
|
584
584
|
/**
|
|
585
585
|
* Register a mesh with LOD information
|
|
@@ -587,151 +587,228 @@ class y {
|
|
|
587
587
|
static registerMesh = (t, e, s, n, r, o) => {
|
|
588
588
|
const l = s.geometry;
|
|
589
589
|
if (!l) {
|
|
590
|
-
|
|
590
|
+
h && console.warn("gltf-progressive: Register mesh without geometry");
|
|
591
591
|
return;
|
|
592
592
|
}
|
|
593
|
-
l.userData || (l.userData = {}),
|
|
594
|
-
let
|
|
595
|
-
|
|
596
|
-
for (const
|
|
597
|
-
|
|
593
|
+
l.userData || (l.userData = {}), h && console.log("> Progressive: register mesh " + s.name, { index: r, uuid: s.uuid }, o, s), m.assignLODInformation(t, l, e, n, r), m.lodInfos.set(e, o);
|
|
594
|
+
let u = m.lowresCache.get(e)?.deref();
|
|
595
|
+
u ? u.push(s.geometry) : u = [s.geometry], m.lowresCache.set(e, new WeakRef(u)), n > 0 && !Z(s) && ot(s, l);
|
|
596
|
+
for (const d of z)
|
|
597
|
+
d.onRegisteredNewMesh?.(s, o);
|
|
598
598
|
};
|
|
599
|
+
/**
|
|
600
|
+
* Dispose cached resources to free memory.
|
|
601
|
+
* Call this when a model is removed from the scene to allow garbage collection of its LOD resources.
|
|
602
|
+
* Calls three.js `.dispose()` on cached Textures and BufferGeometries to free GPU memory.
|
|
603
|
+
* @param guid Optional GUID to dispose resources for a specific model. If omitted, all cached resources are cleared.
|
|
604
|
+
*/
|
|
605
|
+
static dispose(t) {
|
|
606
|
+
if (t) {
|
|
607
|
+
this.lodInfos.delete(t);
|
|
608
|
+
const e = this.lowresCache.get(t);
|
|
609
|
+
if (e) {
|
|
610
|
+
const s = e.deref();
|
|
611
|
+
if (s) {
|
|
612
|
+
if (s.isTexture)
|
|
613
|
+
s.dispose();
|
|
614
|
+
else if (Array.isArray(s))
|
|
615
|
+
for (const n of s) n.dispose();
|
|
616
|
+
}
|
|
617
|
+
this.lowresCache.delete(t);
|
|
618
|
+
}
|
|
619
|
+
for (const [s, n] of this.cache)
|
|
620
|
+
s.includes(t) && (this._disposeCacheEntry(n), this.cache.delete(s));
|
|
621
|
+
} else {
|
|
622
|
+
this.lodInfos.clear();
|
|
623
|
+
for (const [, e] of this.lowresCache) {
|
|
624
|
+
const s = e.deref();
|
|
625
|
+
if (s) {
|
|
626
|
+
if (s.isTexture)
|
|
627
|
+
s.dispose();
|
|
628
|
+
else if (Array.isArray(s))
|
|
629
|
+
for (const n of s) n.dispose();
|
|
630
|
+
}
|
|
631
|
+
}
|
|
632
|
+
this.lowresCache.clear();
|
|
633
|
+
for (const [, e] of this.cache)
|
|
634
|
+
this._disposeCacheEntry(e);
|
|
635
|
+
this.cache.clear();
|
|
636
|
+
}
|
|
637
|
+
}
|
|
638
|
+
/** Dispose a single cache entry's three.js resource(s) to free GPU memory. */
|
|
639
|
+
static _disposeCacheEntry(t) {
|
|
640
|
+
t instanceof WeakRef ? t.deref()?.dispose() : t.then((e) => {
|
|
641
|
+
if (e)
|
|
642
|
+
if (Array.isArray(e))
|
|
643
|
+
for (const s of e) s.dispose();
|
|
644
|
+
else
|
|
645
|
+
e.dispose();
|
|
646
|
+
}).catch(() => {
|
|
647
|
+
});
|
|
648
|
+
}
|
|
599
649
|
/** A map of key = asset uuid and value = LOD information */
|
|
600
650
|
static lodInfos = /* @__PURE__ */ new Map();
|
|
601
|
-
/** cache of already loaded mesh lods */
|
|
602
|
-
static
|
|
603
|
-
/** this contains the geometry/textures that were originally loaded */
|
|
651
|
+
/** cache of already loaded mesh lods. Uses WeakRef for single resources to allow garbage collection when unused. */
|
|
652
|
+
static cache = /* @__PURE__ */ new Map();
|
|
653
|
+
/** this contains the geometry/textures that were originally loaded. Uses WeakRef to allow garbage collection when unused. */
|
|
604
654
|
static lowresCache = /* @__PURE__ */ new Map();
|
|
655
|
+
/**
|
|
656
|
+
* FinalizationRegistry to automatically clean up `previouslyLoaded` cache entries
|
|
657
|
+
* when their associated three.js resources are garbage collected by the browser.
|
|
658
|
+
* The held value is the cache key string used in `previouslyLoaded`.
|
|
659
|
+
*/
|
|
660
|
+
static _resourceRegistry = new FinalizationRegistry((t) => {
|
|
661
|
+
const e = m.cache.get(t);
|
|
662
|
+
h && console.debug(`[gltf-progressive] Resource GC'd
|
|
663
|
+
${t}`), e instanceof WeakRef && (e.deref() || (m.cache.delete(t), h && console.log(`[gltf-progressive] Cache entry auto-cleaned (GC'd): ${t}`)));
|
|
664
|
+
});
|
|
605
665
|
static workers = [];
|
|
606
666
|
static _workersIndex = 0;
|
|
607
667
|
static async getOrLoadLOD(t, e) {
|
|
608
|
-
const s =
|
|
668
|
+
const s = h == "verbose", n = this.getAssignedLODInformation(t);
|
|
609
669
|
if (!n)
|
|
610
|
-
return
|
|
670
|
+
return h && console.warn(`[gltf-progressive] No LOD information found: ${t.name}, uuid: ${t.uuid}, type: ${t.type}`, t), null;
|
|
611
671
|
const r = n?.key;
|
|
612
672
|
let o;
|
|
613
673
|
if (t.isTexture === !0) {
|
|
614
674
|
const a = t;
|
|
615
675
|
a.source && a.source[ue] && (o = a.source[ue]);
|
|
616
676
|
}
|
|
617
|
-
if (o || (o =
|
|
618
|
-
|
|
677
|
+
if (o || (o = m.lodInfos.get(r)), !o)
|
|
678
|
+
h && console.warn(`Can not load LOD ${e}: no LOD info found for "${r}" ${t.name}`, t.type, m.lodInfos);
|
|
619
679
|
else {
|
|
620
680
|
if (e > 0) {
|
|
621
681
|
let d = !1;
|
|
622
|
-
const
|
|
623
|
-
if (
|
|
624
|
-
|
|
682
|
+
const y = Array.isArray(o.lods);
|
|
683
|
+
if (y && e >= o.lods.length ? d = !0 : y || (d = !0), d) {
|
|
684
|
+
const w = this.lowresCache.get(r);
|
|
685
|
+
if (w) {
|
|
686
|
+
const L = w.deref();
|
|
687
|
+
if (L) return L;
|
|
688
|
+
this.lowresCache.delete(r), h && console.log(`[gltf-progressive] Lowres cache entry was GC'd: ${r}`);
|
|
689
|
+
}
|
|
690
|
+
return null;
|
|
691
|
+
}
|
|
625
692
|
}
|
|
626
693
|
const a = Array.isArray(o.lods) ? o.lods[e]?.path : o.lods;
|
|
627
694
|
if (!a)
|
|
628
|
-
return
|
|
695
|
+
return h && !o["missing:uri"] && (o["missing:uri"] = !0, console.warn("Missing uri for progressive asset for LOD " + e, o)), null;
|
|
629
696
|
const u = st(n.url, a);
|
|
630
697
|
if (u.endsWith(".glb") || u.endsWith(".gltf")) {
|
|
631
698
|
if (!o.guid)
|
|
632
699
|
return console.warn("missing pointer for glb/gltf texture", o), null;
|
|
633
|
-
const d = u + "_" + o.guid,
|
|
634
|
-
if (
|
|
635
|
-
s && console.log(`LOD ${e} was already loading/loaded: ${d}`)
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
700
|
+
const d = u + "_" + o.guid, y = await this.queue.slot(u), w = this.cache.get(d);
|
|
701
|
+
if (w !== void 0)
|
|
702
|
+
if (s && console.log(`LOD ${e} was already loading/loaded: ${d}`), w instanceof WeakRef) {
|
|
703
|
+
const c = w.deref();
|
|
704
|
+
if (c) {
|
|
705
|
+
let g = c, M = !1;
|
|
706
|
+
if (g instanceof F && t instanceof F ? g.image?.data || g.source?.data ? g = this.copySettings(t, g) : M = !0 : g instanceof q && t instanceof q && (g.attributes.position?.array || (M = !0)), !M)
|
|
707
|
+
return g;
|
|
708
|
+
}
|
|
709
|
+
this.cache.delete(d), h && console.log(`[gltf-progressive] Re-loading GC'd/disposed resource: ${d}`);
|
|
710
|
+
} else {
|
|
711
|
+
let c = await w.catch((M) => (console.error(`Error loading LOD ${e} from ${u}
|
|
712
|
+
`, M), null)), g = !1;
|
|
713
|
+
if (c == null || (c instanceof F && t instanceof F ? c.image?.data || c.source?.data ? c = this.copySettings(t, c) : (g = !0, this.cache.delete(d)) : c instanceof q && t instanceof q && (c.attributes.position?.array || (g = !0, this.cache.delete(d)))), !g)
|
|
714
|
+
return c;
|
|
715
|
+
}
|
|
716
|
+
if (!y.use)
|
|
717
|
+
return h && console.log(`LOD ${e} was aborted: ${u}`), null;
|
|
718
|
+
const L = o, k = new Promise(async (c, g) => {
|
|
644
719
|
if (ft) {
|
|
645
|
-
const
|
|
646
|
-
if (
|
|
647
|
-
for (const f of
|
|
648
|
-
let
|
|
649
|
-
return
|
|
720
|
+
const x = await (await dt({})).load(u);
|
|
721
|
+
if (x.textures.length > 0)
|
|
722
|
+
for (const f of x.textures) {
|
|
723
|
+
let p = f.texture;
|
|
724
|
+
return m.assignLODInformation(n.url, p, r, e, void 0), t instanceof F && (p = this.copySettings(t, p)), p && (p.guid = L.guid), c(p);
|
|
650
725
|
}
|
|
651
|
-
if (
|
|
726
|
+
if (x.geometries.length > 0) {
|
|
652
727
|
const f = new Array();
|
|
653
|
-
for (const
|
|
654
|
-
const
|
|
655
|
-
|
|
728
|
+
for (const p of x.geometries) {
|
|
729
|
+
const D = p.geometry;
|
|
730
|
+
m.assignLODInformation(n.url, D, r, e, p.primitiveIndex), f.push(D);
|
|
656
731
|
}
|
|
657
732
|
return c(f);
|
|
658
733
|
}
|
|
659
734
|
return c(null);
|
|
660
735
|
}
|
|
661
|
-
const
|
|
662
|
-
|
|
736
|
+
const M = new xe();
|
|
737
|
+
Pe(M), h && (await new Promise((_) => setTimeout(_, 1e3)), s && console.warn("Start loading (delayed) " + u, L.guid));
|
|
663
738
|
let B = u;
|
|
664
|
-
if (
|
|
665
|
-
const
|
|
666
|
-
|
|
739
|
+
if (L && Array.isArray(L.lods)) {
|
|
740
|
+
const _ = L.lods[e];
|
|
741
|
+
_.hash && (B += "?v=" + _.hash);
|
|
667
742
|
}
|
|
668
|
-
const
|
|
669
|
-
`,
|
|
670
|
-
if (!
|
|
743
|
+
const b = await M.loadAsync(B).catch((_) => (console.error(`Error loading LOD ${e} from ${u}
|
|
744
|
+
`, _), c(null)));
|
|
745
|
+
if (!b)
|
|
671
746
|
return c(null);
|
|
672
|
-
const
|
|
673
|
-
s && console.log("Loading finished " + u,
|
|
674
|
-
let
|
|
675
|
-
if (
|
|
676
|
-
let
|
|
677
|
-
for (const
|
|
678
|
-
if (
|
|
679
|
-
const f =
|
|
680
|
-
if (f?.guid && f.guid ===
|
|
681
|
-
|
|
747
|
+
const N = b.parser;
|
|
748
|
+
s && console.log("Loading finished " + u, L.guid);
|
|
749
|
+
let P = 0;
|
|
750
|
+
if (b.parser.json.textures) {
|
|
751
|
+
let _ = !1;
|
|
752
|
+
for (const x of b.parser.json.textures) {
|
|
753
|
+
if (x?.extensions) {
|
|
754
|
+
const f = x?.extensions[W];
|
|
755
|
+
if (f?.guid && f.guid === L.guid) {
|
|
756
|
+
_ = !0;
|
|
682
757
|
break;
|
|
683
758
|
}
|
|
684
759
|
}
|
|
685
|
-
|
|
760
|
+
P++;
|
|
686
761
|
}
|
|
687
|
-
if (
|
|
688
|
-
let
|
|
689
|
-
return
|
|
690
|
-
} else
|
|
762
|
+
if (_) {
|
|
763
|
+
let x = await N.getDependency("texture", P);
|
|
764
|
+
return x && m.assignLODInformation(n.url, x, r, e, void 0), s && console.log('change "' + t.name + '" → "' + x.name + '"', u, P, x, d), t instanceof F && (x = this.copySettings(t, x)), x && (x.guid = L.guid), c(x);
|
|
765
|
+
} else h && console.warn("Could not find texture with guid", L.guid, b.parser.json);
|
|
691
766
|
}
|
|
692
|
-
if (
|
|
693
|
-
let
|
|
694
|
-
for (const
|
|
695
|
-
if (
|
|
696
|
-
const f =
|
|
697
|
-
if (f?.guid && f.guid ===
|
|
698
|
-
|
|
767
|
+
if (P = 0, b.parser.json.meshes) {
|
|
768
|
+
let _ = !1;
|
|
769
|
+
for (const x of b.parser.json.meshes) {
|
|
770
|
+
if (x?.extensions) {
|
|
771
|
+
const f = x?.extensions[W];
|
|
772
|
+
if (f?.guid && f.guid === L.guid) {
|
|
773
|
+
_ = !0;
|
|
699
774
|
break;
|
|
700
775
|
}
|
|
701
776
|
}
|
|
702
|
-
|
|
777
|
+
P++;
|
|
703
778
|
}
|
|
704
|
-
if (
|
|
705
|
-
const
|
|
706
|
-
if (s && console.log(`Loaded Mesh "${
|
|
707
|
-
const f =
|
|
708
|
-
return
|
|
779
|
+
if (_) {
|
|
780
|
+
const x = await N.getDependency("mesh", P);
|
|
781
|
+
if (s && console.log(`Loaded Mesh "${x.name}"`, u, P, x, d), x.isMesh === !0) {
|
|
782
|
+
const f = x.geometry;
|
|
783
|
+
return m.assignLODInformation(n.url, f, r, e, 0), c(f);
|
|
709
784
|
} else {
|
|
710
785
|
const f = new Array();
|
|
711
|
-
for (let
|
|
712
|
-
const
|
|
713
|
-
if (
|
|
714
|
-
const
|
|
715
|
-
|
|
786
|
+
for (let p = 0; p < x.children.length; p++) {
|
|
787
|
+
const D = x.children[p];
|
|
788
|
+
if (D.isMesh === !0) {
|
|
789
|
+
const S = D.geometry;
|
|
790
|
+
m.assignLODInformation(n.url, S, r, e, p), f.push(S);
|
|
716
791
|
}
|
|
717
792
|
}
|
|
718
793
|
return c(f);
|
|
719
794
|
}
|
|
720
|
-
} else
|
|
795
|
+
} else h && console.warn("Could not find mesh with guid", L.guid, b.parser.json);
|
|
721
796
|
}
|
|
722
797
|
return c(null);
|
|
723
798
|
});
|
|
724
|
-
|
|
725
|
-
|
|
799
|
+
this.cache.set(d, k), y.use(k);
|
|
800
|
+
const v = await k;
|
|
801
|
+
return v != null ? v instanceof F ? (this.cache.set(d, new WeakRef(v)), m._resourceRegistry.register(v, d)) : Array.isArray(v) ? this.cache.set(d, Promise.resolve(v)) : this.cache.set(d, Promise.resolve(v)) : this.cache.set(d, Promise.resolve(null)), v;
|
|
802
|
+
} else if (t instanceof F) {
|
|
726
803
|
s && console.log("Load texture from uri: " + u);
|
|
727
|
-
const
|
|
728
|
-
return
|
|
804
|
+
const y = await new Ne().loadAsync(u);
|
|
805
|
+
return y ? (y.guid = o.guid, y.flipY = !1, y.needsUpdate = !0, y.colorSpace = t.colorSpace, s && console.log(o, y)) : h && console.warn("failed loading", u), y;
|
|
729
806
|
}
|
|
730
807
|
}
|
|
731
808
|
return null;
|
|
732
809
|
}
|
|
733
810
|
static maxConcurrent = 50;
|
|
734
|
-
static queue = new rt(
|
|
811
|
+
static queue = new rt(m.maxConcurrent, { debug: h != !1 });
|
|
735
812
|
static assignLODInformation(t, e, s, n, r) {
|
|
736
813
|
if (!e) return;
|
|
737
814
|
e.userData || (e.userData = {});
|
|
@@ -743,7 +820,7 @@ class y {
|
|
|
743
820
|
}
|
|
744
821
|
// private static readonly _copiedTextures: WeakMap<Texture, Texture> = new Map();
|
|
745
822
|
static copySettings(t, e) {
|
|
746
|
-
return e ? (
|
|
823
|
+
return e ? (h === "verbose" && console.debug(`Copy texture settings
|
|
747
824
|
`, t.uuid, `
|
|
748
825
|
`, e.uuid), e = e.clone(), e.offset = t.offset, e.repeat = t.repeat, e.colorSpace = t.colorSpace, e.magFilter = t.magFilter, e.minFilter = t.minFilter, e.wrapS = t.wrapS, e.wrapT = t.wrapT, e.flipY = t.flipY, e.anisotropy = t.anisotropy, e.mipmaps || (e.generateMipmaps = t.generateMipmaps), e) : t;
|
|
749
826
|
}
|
|
@@ -808,7 +885,7 @@ class de {
|
|
|
808
885
|
_seen = /* @__PURE__ */ new WeakMap();
|
|
809
886
|
add(t, e, s) {
|
|
810
887
|
if (this._resolved) {
|
|
811
|
-
|
|
888
|
+
h && console.warn("PromiseGroup: Trying to add a promise to a resolved group, ignoring.");
|
|
812
889
|
return;
|
|
813
890
|
}
|
|
814
891
|
if (!(this._frame_start !== void 0 && this._currentFrame > this._frame_start + this._frames_to_capture)) {
|
|
@@ -816,7 +893,7 @@ class de {
|
|
|
816
893
|
if (this._seen.has(e)) {
|
|
817
894
|
let n = this._seen.get(e);
|
|
818
895
|
if (n >= this._maxPromisesPerObject) {
|
|
819
|
-
|
|
896
|
+
h && console.warn("PromiseGroup: Already awaiting object ignoring new promise for it.");
|
|
820
897
|
return;
|
|
821
898
|
}
|
|
822
899
|
this._seen.set(e, n + 1);
|
|
@@ -835,8 +912,8 @@ class de {
|
|
|
835
912
|
});
|
|
836
913
|
}
|
|
837
914
|
}
|
|
838
|
-
const
|
|
839
|
-
let oe = class
|
|
915
|
+
const I = j("debugprogressive"), pt = j("noprogressive"), ce = /* @__PURE__ */ Symbol("Needle:LODSManager"), fe = /* @__PURE__ */ Symbol("Needle:LODState"), U = /* @__PURE__ */ Symbol("Needle:CurrentLOD"), T = { mesh_lod: -1, texture_lod: -1 };
|
|
916
|
+
let oe = class O {
|
|
840
917
|
/**
|
|
841
918
|
* Assign a function to draw debug lines for the LODs. This function will be called with the start and end position of the line and the color of the line when the `debugprogressive` query parameter is set.
|
|
842
919
|
*/
|
|
@@ -846,11 +923,11 @@ let oe = class D {
|
|
|
846
923
|
return t[fe];
|
|
847
924
|
}
|
|
848
925
|
static addPlugin(t) {
|
|
849
|
-
|
|
926
|
+
z.push(t);
|
|
850
927
|
}
|
|
851
928
|
static removePlugin(t) {
|
|
852
|
-
const e =
|
|
853
|
-
e >= 0 &&
|
|
929
|
+
const e = z.indexOf(t);
|
|
930
|
+
e >= 0 && z.splice(e, 1);
|
|
854
931
|
}
|
|
855
932
|
/**
|
|
856
933
|
* Gets the LODsManager for the given renderer. If the LODsManager does not exist yet, it will be created.
|
|
@@ -860,7 +937,7 @@ let oe = class D {
|
|
|
860
937
|
static get(t, e) {
|
|
861
938
|
if (t[ce])
|
|
862
939
|
return console.debug("[gltf-progressive] LODsManager already exists for this renderer"), t[ce];
|
|
863
|
-
const s = new
|
|
940
|
+
const s = new O(t, {
|
|
864
941
|
engine: "unknown",
|
|
865
942
|
...e
|
|
866
943
|
});
|
|
@@ -871,7 +948,7 @@ let oe = class D {
|
|
|
871
948
|
projectionScreenMatrix = new _e();
|
|
872
949
|
/** @deprecated use static `LODsManager.addPlugin()` method. This getter will be removed in later versions */
|
|
873
950
|
get plugins() {
|
|
874
|
-
return
|
|
951
|
+
return z;
|
|
875
952
|
}
|
|
876
953
|
/**
|
|
877
954
|
* Force override the LOD level for all objects (meshes + textures) rendered in the scene
|
|
@@ -943,7 +1020,7 @@ let oe = class D {
|
|
|
943
1020
|
this.renderer = t, this.context = { ...e };
|
|
944
1021
|
}
|
|
945
1022
|
#t;
|
|
946
|
-
#o = new
|
|
1023
|
+
#o = new Ee();
|
|
947
1024
|
#r = 0;
|
|
948
1025
|
#n = 0;
|
|
949
1026
|
#i = 0;
|
|
@@ -960,7 +1037,7 @@ let oe = class D {
|
|
|
960
1037
|
const e = this;
|
|
961
1038
|
we(this.renderer), this.renderer.render = function(s, n) {
|
|
962
1039
|
const r = e.renderer.getRenderTarget();
|
|
963
|
-
(r == null || "isXRRenderTarget" in r && r.isXRRenderTarget) && (t = 0, e.#r += 1, e.#n = e.#o.getDelta(), e.#i += e.#n, e._fpsBuffer.shift(), e._fpsBuffer.push(1 / e.#n), e.#s = e._fpsBuffer.reduce((l, a) => l + a) / e._fpsBuffer.length,
|
|
1040
|
+
(r == null || "isXRRenderTarget" in r && r.isXRRenderTarget) && (t = 0, e.#r += 1, e.#n = e.#o.getDelta(), e.#i += e.#n, e._fpsBuffer.shift(), e._fpsBuffer.push(1 / e.#n), e.#s = e._fpsBuffer.reduce((l, a) => l + a) / e._fpsBuffer.length, I && e.#r % 200 === 0 && console.log("FPS", Math.round(e.#s), "Interval:", e.#e));
|
|
964
1041
|
const o = t++;
|
|
965
1042
|
e.#t.call(this, s, n), e.onAfterRender(s, n, o);
|
|
966
1043
|
};
|
|
@@ -980,7 +1057,7 @@ let oe = class D {
|
|
|
980
1057
|
(l.name === "EffectMaterial" || l.name === "CopyShader") && (o = !1);
|
|
981
1058
|
}
|
|
982
1059
|
if ((e.parent && e.parent.type === "CubeCamera" || s >= 1 && e.type === "OrthographicCamera") && (o = !1), o) {
|
|
983
|
-
if (pt || (this.updateInterval === "auto" ? this.#s < 40 && this.#e < 10 ? (this.#e += 1,
|
|
1060
|
+
if (pt || (this.updateInterval === "auto" ? this.#s < 40 && this.#e < 10 ? (this.#e += 1, I && console.warn("↓ Reducing LOD updates", this.#e, this.#s.toFixed(0))) : this.#s >= 60 && this.#e > 1 && (this.#e -= 1, I && console.warn("↑ Increasing LOD updates", this.#e, this.#s.toFixed(0))) : this.#e = this.updateInterval, this.#e > 0 && this.#r % this.#e != 0))
|
|
984
1061
|
return;
|
|
985
1062
|
this.internalUpdate(t, e), this._postprocessPromiseGroups();
|
|
986
1063
|
}
|
|
@@ -994,7 +1071,7 @@ let oe = class D {
|
|
|
994
1071
|
const r = this.targetTriangleDensity;
|
|
995
1072
|
for (const a of n) {
|
|
996
1073
|
if (a.material && (a.geometry?.type === "BoxGeometry" || a.geometry?.type === "BufferGeometry") && (a.material.name === "SphericalGaussianBlur" || a.material.name == "BackgroundCubeMaterial" || a.material.name === "CubemapFromEquirect" || a.material.name === "EquirectangularToCubeUV")) {
|
|
997
|
-
|
|
1074
|
+
I && (a.material["NEEDLE_PROGRESSIVE:IGNORE-WARNING"] || (a.material["NEEDLE_PROGRESSIVE:IGNORE-WARNING"] = !0, console.warn("Ignoring skybox or BLIT object", a, a.material.name, a.material.type)));
|
|
998
1075
|
continue;
|
|
999
1076
|
}
|
|
1000
1077
|
switch (a.material.type) {
|
|
@@ -1006,23 +1083,23 @@ let oe = class D {
|
|
|
1006
1083
|
case "MeshDepthMaterial":
|
|
1007
1084
|
continue;
|
|
1008
1085
|
}
|
|
1009
|
-
if (
|
|
1086
|
+
if (I === "color" && a.material && !a.object.progressive_debug_color) {
|
|
1010
1087
|
a.object.progressive_debug_color = !0;
|
|
1011
|
-
const d = Math.random() * 16777215,
|
|
1012
|
-
a.object.material =
|
|
1088
|
+
const d = Math.random() * 16777215, y = new qe({ color: d });
|
|
1089
|
+
a.object.material = y;
|
|
1013
1090
|
}
|
|
1014
1091
|
const u = a.object;
|
|
1015
|
-
(u instanceof
|
|
1092
|
+
(u instanceof V || u.isMesh) && this.updateLODs(t, e, u, r);
|
|
1016
1093
|
}
|
|
1017
1094
|
const o = s.transparent;
|
|
1018
1095
|
for (const a of o) {
|
|
1019
1096
|
const u = a.object;
|
|
1020
|
-
(u instanceof
|
|
1097
|
+
(u instanceof V || u.isMesh) && this.updateLODs(t, e, u, r);
|
|
1021
1098
|
}
|
|
1022
1099
|
const l = s.transmissive;
|
|
1023
1100
|
for (const a of l) {
|
|
1024
1101
|
const u = a.object;
|
|
1025
|
-
(u instanceof
|
|
1102
|
+
(u instanceof V || u.isMesh) && this.updateLODs(t, e, u, r);
|
|
1026
1103
|
}
|
|
1027
1104
|
}
|
|
1028
1105
|
/** Update the LOD levels for the renderer. */
|
|
@@ -1031,11 +1108,11 @@ let oe = class D {
|
|
|
1031
1108
|
let r = s[fe];
|
|
1032
1109
|
if (r || (r = new mt(), s[fe] = r), r.frames++ < 2)
|
|
1033
1110
|
return;
|
|
1034
|
-
for (const l of
|
|
1111
|
+
for (const l of z)
|
|
1035
1112
|
l.onBeforeUpdateLOD?.(this.renderer, t, e, s);
|
|
1036
|
-
const o = this.overrideLodLevel !== void 0 ? this.overrideLodLevel :
|
|
1037
|
-
o >= 0 ? (T.mesh_lod = o, T.texture_lod = o) : (this.calculateLodLevel(e, s, r, n, T), T.mesh_lod = Math.round(T.mesh_lod), T.texture_lod = Math.round(T.texture_lod)), T.mesh_lod >= 0 && this.loadProgressiveMeshes(s, T.mesh_lod), s.material && T.texture_lod >= 0 && this.loadProgressiveTextures(s.material, T.texture_lod, o),
|
|
1038
|
-
for (const l of
|
|
1113
|
+
const o = this.overrideLodLevel !== void 0 ? this.overrideLodLevel : E;
|
|
1114
|
+
o >= 0 ? (T.mesh_lod = o, T.texture_lod = o) : (this.calculateLodLevel(e, s, r, n, T), T.mesh_lod = Math.round(T.mesh_lod), T.texture_lod = Math.round(T.texture_lod)), T.mesh_lod >= 0 && this.loadProgressiveMeshes(s, T.mesh_lod), s.material && T.texture_lod >= 0 && this.loadProgressiveTextures(s.material, T.texture_lod, o), h && s.material && !s.isGizmo && ke(s.material);
|
|
1115
|
+
for (const l of z)
|
|
1039
1116
|
l.onAfterUpdatedLOD?.(this.renderer, t, e, s, T);
|
|
1040
1117
|
r.lastLodLevel_Mesh = T.mesh_lod, r.lastLodLevel_Texture = T.texture_lod;
|
|
1041
1118
|
}
|
|
@@ -1052,9 +1129,9 @@ let oe = class D {
|
|
|
1052
1129
|
return;
|
|
1053
1130
|
}
|
|
1054
1131
|
let n = !1;
|
|
1055
|
-
if ((t[
|
|
1056
|
-
t[
|
|
1057
|
-
const r =
|
|
1132
|
+
if ((t[U] === void 0 || e < t[U]) && (n = !0), s !== void 0 && s >= 0 && (n = t[U] != s, e = s), n) {
|
|
1133
|
+
t[U] = e;
|
|
1134
|
+
const r = m.assignTextureLOD(t, e).then((o) => {
|
|
1058
1135
|
this._lodchangedlisteners.forEach((l) => l({ type: "texture", level: e, object: t }));
|
|
1059
1136
|
});
|
|
1060
1137
|
de.addPromise("texture", t, r, this._newPromiseGroups);
|
|
@@ -1068,11 +1145,11 @@ let oe = class D {
|
|
|
1068
1145
|
*/
|
|
1069
1146
|
loadProgressiveMeshes(t, e) {
|
|
1070
1147
|
if (!t) return Promise.resolve(null);
|
|
1071
|
-
let s = t[
|
|
1148
|
+
let s = t[U] !== e;
|
|
1072
1149
|
const n = t["DEBUG:LOD"];
|
|
1073
|
-
if (n != null && (s = t[
|
|
1074
|
-
t[
|
|
1075
|
-
const r = t.geometry, o =
|
|
1150
|
+
if (n != null && (s = t[U] != n, e = n), s) {
|
|
1151
|
+
t[U] = e;
|
|
1152
|
+
const r = t.geometry, o = m.assignMeshLOD(t, e).then((l) => (l && t[U] == e && r != t.geometry && this._lodchangedlisteners.forEach((a) => a({ type: "mesh", level: e, object: t })), l));
|
|
1076
1153
|
return de.addPromise("mesh", t, o, this._newPromiseGroups), o;
|
|
1077
1154
|
}
|
|
1078
1155
|
return Promise.resolve(null);
|
|
@@ -1082,14 +1159,14 @@ let oe = class D {
|
|
|
1082
1159
|
_tempBox = new ge();
|
|
1083
1160
|
_tempBox2 = new ge();
|
|
1084
1161
|
tempMatrix = new _e();
|
|
1085
|
-
_tempWorldPosition = new
|
|
1086
|
-
_tempBoxSize = new
|
|
1087
|
-
_tempBox2Size = new
|
|
1088
|
-
static corner0 = new
|
|
1089
|
-
static corner1 = new
|
|
1090
|
-
static corner2 = new
|
|
1091
|
-
static corner3 = new
|
|
1092
|
-
static _tempPtInside = new
|
|
1162
|
+
_tempWorldPosition = new C();
|
|
1163
|
+
_tempBoxSize = new C();
|
|
1164
|
+
_tempBox2Size = new C();
|
|
1165
|
+
static corner0 = new C();
|
|
1166
|
+
static corner1 = new C();
|
|
1167
|
+
static corner2 = new C();
|
|
1168
|
+
static corner3 = new C();
|
|
1169
|
+
static _tempPtInside = new C();
|
|
1093
1170
|
static isInside(t, e) {
|
|
1094
1171
|
const s = t.min, n = t.max, r = (s.x + n.x) * 0.5, o = (s.y + n.y) * 0.5;
|
|
1095
1172
|
return this._tempPtInside.set(r, o, s.z).applyMatrix4(e).z < 0;
|
|
@@ -1107,34 +1184,34 @@ let oe = class D {
|
|
|
1107
1184
|
return;
|
|
1108
1185
|
}
|
|
1109
1186
|
let l = 10 + 1, a = !1;
|
|
1110
|
-
if (
|
|
1187
|
+
if (I && e["DEBUG:LOD"] != null)
|
|
1111
1188
|
return e["DEBUG:LOD"];
|
|
1112
|
-
const u =
|
|
1113
|
-
if (!
|
|
1189
|
+
const u = m.getMeshLODExtension(e.geometry)?.lods, d = m.getPrimitiveIndex(e.geometry), y = u && u.length > 0, w = m.getMaterialMinMaxLODsCount(e.material), L = w.min_count !== 1 / 0 && w.min_count >= 0 && w.max_count >= 0;
|
|
1190
|
+
if (!y && !L) {
|
|
1114
1191
|
r.mesh_lod = 0, r.texture_lod = 0;
|
|
1115
1192
|
return;
|
|
1116
1193
|
}
|
|
1117
|
-
|
|
1118
|
-
const
|
|
1119
|
-
let
|
|
1194
|
+
y || (a = !0, l = 0);
|
|
1195
|
+
const k = this.renderer.domElement.clientHeight || this.renderer.domElement.height;
|
|
1196
|
+
let v = e.geometry.boundingBox;
|
|
1120
1197
|
if (e.type === "SkinnedMesh") {
|
|
1121
1198
|
const c = e;
|
|
1122
1199
|
if (!c.boundingBox)
|
|
1123
1200
|
c.computeBoundingBox();
|
|
1124
1201
|
else if (this.skinnedMeshAutoUpdateBoundsInterval > 0) {
|
|
1125
|
-
if (!c[
|
|
1126
|
-
const
|
|
1127
|
-
c[
|
|
1202
|
+
if (!c[O.$skinnedMeshBoundsOffset]) {
|
|
1203
|
+
const M = O.skinnedMeshBoundsFrameOffsetCounter++;
|
|
1204
|
+
c[O.$skinnedMeshBoundsOffset] = M;
|
|
1128
1205
|
}
|
|
1129
|
-
const
|
|
1130
|
-
if ((s.frames +
|
|
1131
|
-
const
|
|
1132
|
-
|
|
1206
|
+
const g = c[O.$skinnedMeshBoundsOffset];
|
|
1207
|
+
if ((s.frames + g) % this.skinnedMeshAutoUpdateBoundsInterval === 0) {
|
|
1208
|
+
const M = Z(c), B = c.geometry;
|
|
1209
|
+
M && (c.geometry = M), c.computeBoundingBox(), c.geometry = B;
|
|
1133
1210
|
}
|
|
1134
1211
|
}
|
|
1135
|
-
|
|
1212
|
+
v = c.boundingBox;
|
|
1136
1213
|
}
|
|
1137
|
-
if (
|
|
1214
|
+
if (v) {
|
|
1138
1215
|
const c = t;
|
|
1139
1216
|
if (e.geometry.attributes.color && e.geometry.attributes.color.count < 100 && e.geometry.boundingSphere) {
|
|
1140
1217
|
this._sphere.copy(e.geometry.boundingSphere), this._sphere.applyMatrix4(e.matrixWorld);
|
|
@@ -1144,67 +1221,67 @@ let oe = class D {
|
|
|
1144
1221
|
return;
|
|
1145
1222
|
}
|
|
1146
1223
|
}
|
|
1147
|
-
if (this._tempBox.copy(
|
|
1224
|
+
if (this._tempBox.copy(v), this._tempBox.applyMatrix4(e.matrixWorld), c.isPerspectiveCamera && O.isInside(this._tempBox, this.projectionScreenMatrix)) {
|
|
1148
1225
|
r.mesh_lod = 0, r.texture_lod = 0;
|
|
1149
1226
|
return;
|
|
1150
1227
|
}
|
|
1151
1228
|
if (this._tempBox.applyMatrix4(this.projectionScreenMatrix), this.renderer.xr.enabled && c.isPerspectiveCamera && c.fov > 70) {
|
|
1152
|
-
const f = this._tempBox.min,
|
|
1153
|
-
let
|
|
1154
|
-
const ee = 2, ie = 1.5, te = (f.x +
|
|
1155
|
-
|
|
1156
|
-
const
|
|
1229
|
+
const f = this._tempBox.min, p = this._tempBox.max;
|
|
1230
|
+
let D = f.x, S = f.y, G = p.x, K = p.y;
|
|
1231
|
+
const ee = 2, ie = 1.5, te = (f.x + p.x) * 0.5, se = (f.y + p.y) * 0.5;
|
|
1232
|
+
D = (D - te) * ee + te, S = (S - se) * ee + se, G = (G - te) * ee + te, K = (K - se) * ee + se;
|
|
1233
|
+
const $e = D < 0 && G > 0 ? 0 : Math.min(Math.abs(f.x), Math.abs(p.x)), Be = S < 0 && K > 0 ? 0 : Math.min(Math.abs(f.y), Math.abs(p.y)), ae = Math.max($e, Be);
|
|
1157
1234
|
s.lastCentrality = (ie - ae) * (ie - ae) * (ie - ae);
|
|
1158
1235
|
} else
|
|
1159
1236
|
s.lastCentrality = 1;
|
|
1160
|
-
const
|
|
1161
|
-
|
|
1162
|
-
const
|
|
1163
|
-
B.copy(
|
|
1164
|
-
const
|
|
1165
|
-
if (Math.max(
|
|
1237
|
+
const g = this._tempBox.getSize(this._tempBoxSize);
|
|
1238
|
+
g.multiplyScalar(0.5), screen.availHeight > 0 && k > 0 && g.multiplyScalar(k / screen.availHeight), t.isPerspectiveCamera ? g.x *= t.aspect : t.isOrthographicCamera;
|
|
1239
|
+
const M = t.matrixWorldInverse, B = this._tempBox2;
|
|
1240
|
+
B.copy(v), B.applyMatrix4(e.matrixWorld), B.applyMatrix4(M);
|
|
1241
|
+
const b = B.getSize(this._tempBox2Size), N = Math.max(b.x, b.y);
|
|
1242
|
+
if (Math.max(g.x, g.y) != 0 && N != 0 && (g.z = b.z / Math.max(b.x, b.y) * Math.max(g.x, g.y)), s.lastScreenCoverage = Math.max(g.x, g.y, g.z), s.lastScreenspaceVolume.copy(g), s.lastScreenCoverage *= s.lastCentrality, I && O.debugDrawLine) {
|
|
1166
1243
|
const f = this.tempMatrix.copy(this.projectionScreenMatrix);
|
|
1167
1244
|
f.invert();
|
|
1168
|
-
const
|
|
1169
|
-
|
|
1170
|
-
const
|
|
1171
|
-
|
|
1245
|
+
const p = O.corner0, D = O.corner1, S = O.corner2, G = O.corner3;
|
|
1246
|
+
p.copy(this._tempBox.min), D.copy(this._tempBox.max), D.x = p.x, S.copy(this._tempBox.max), S.y = p.y, G.copy(this._tempBox.max);
|
|
1247
|
+
const K = (p.z + G.z) * 0.5;
|
|
1248
|
+
p.z = D.z = S.z = G.z = K, p.applyMatrix4(f), D.applyMatrix4(f), S.applyMatrix4(f), G.applyMatrix4(f), O.debugDrawLine(p, D, 255), O.debugDrawLine(p, S, 255), O.debugDrawLine(D, G, 255), O.debugDrawLine(S, G, 255);
|
|
1172
1249
|
}
|
|
1173
|
-
let
|
|
1250
|
+
let _ = 999;
|
|
1174
1251
|
if (u && s.lastScreenCoverage > 0)
|
|
1175
1252
|
for (let f = 0; f < u.length; f++) {
|
|
1176
|
-
const
|
|
1177
|
-
if (d > 0 && Me() && !
|
|
1178
|
-
|
|
1253
|
+
const p = u[f], S = (p.densities?.[d] || p.density || 1e-5) / s.lastScreenCoverage;
|
|
1254
|
+
if (d > 0 && Me() && !p.densities && !globalThis["NEEDLE:MISSING_LOD_PRIMITIVE_DENSITIES"] && (window["NEEDLE:MISSING_LOD_PRIMITIVE_DENSITIES"] = !0, console.warn("[Needle Progressive] Detected usage of mesh without primitive densities. This might cause incorrect LOD level selection: Consider re-optimizing your model by updating your Needle Integration, Needle glTF Pipeline or running optimization again on Needle Cloud.")), S < n) {
|
|
1255
|
+
_ = f;
|
|
1179
1256
|
break;
|
|
1180
1257
|
}
|
|
1181
1258
|
}
|
|
1182
|
-
|
|
1259
|
+
_ < l && (l = _, a = !0);
|
|
1183
1260
|
}
|
|
1184
|
-
if (a ? r.mesh_lod = l : r.mesh_lod = s.lastLodLevel_Mesh,
|
|
1185
|
-
const
|
|
1186
|
-
|
|
1261
|
+
if (a ? r.mesh_lod = l : r.mesh_lod = s.lastLodLevel_Mesh, I && r.mesh_lod != s.lastLodLevel_Mesh) {
|
|
1262
|
+
const g = u?.[r.mesh_lod];
|
|
1263
|
+
g && console.log(`Mesh LOD changed: ${s.lastLodLevel_Mesh} → ${r.mesh_lod} (density: ${g.densities?.[d].toFixed(0)}) | ${e.name}`);
|
|
1187
1264
|
}
|
|
1188
|
-
if (
|
|
1265
|
+
if (L) {
|
|
1189
1266
|
const c = "saveData" in globalThis.navigator && globalThis.navigator.saveData === !0;
|
|
1190
1267
|
if (s.lastLodLevel_Texture < 0) {
|
|
1191
|
-
if (r.texture_lod =
|
|
1192
|
-
const
|
|
1193
|
-
|
|
1268
|
+
if (r.texture_lod = w.max_count - 1, I) {
|
|
1269
|
+
const g = w.lods[w.max_count - 1];
|
|
1270
|
+
I && console.log(`First Texture LOD ${r.texture_lod} (${g.max_height}px) - ${e.name}`);
|
|
1194
1271
|
}
|
|
1195
1272
|
} else {
|
|
1196
|
-
const
|
|
1197
|
-
let
|
|
1198
|
-
this.context?.engine === "model-viewer" && (
|
|
1199
|
-
const
|
|
1200
|
-
let
|
|
1201
|
-
for (let
|
|
1202
|
-
const
|
|
1203
|
-
if (!(c &&
|
|
1204
|
-
if (
|
|
1205
|
-
const
|
|
1206
|
-
console.log(`Texture LOD changed: ${s.lastLodLevel_Texture} → ${r.texture_lod} = ${
|
|
1207
|
-
Screensize: ${
|
|
1273
|
+
const g = s.lastScreenspaceVolume.x + s.lastScreenspaceVolume.y + s.lastScreenspaceVolume.z;
|
|
1274
|
+
let M = s.lastScreenCoverage * 4;
|
|
1275
|
+
this.context?.engine === "model-viewer" && (M *= 1.5);
|
|
1276
|
+
const b = k / window.devicePixelRatio * M;
|
|
1277
|
+
let N = !1;
|
|
1278
|
+
for (let P = w.lods.length - 1; P >= 0; P--) {
|
|
1279
|
+
const _ = w.lods[P];
|
|
1280
|
+
if (!(c && _.max_height >= 2048) && !(Ce() && _.max_height > 4096) && (_.max_height > b || !N && P === 0)) {
|
|
1281
|
+
if (N = !0, r.texture_lod = P, I && r.texture_lod < s.lastLodLevel_Texture) {
|
|
1282
|
+
const x = _.max_height;
|
|
1283
|
+
console.log(`Texture LOD changed: ${s.lastLodLevel_Texture} → ${r.texture_lod} = ${x}px
|
|
1284
|
+
Screensize: ${b.toFixed(0)}px, Coverage: ${(100 * s.lastScreenCoverage).toFixed(2)}%, Volume ${g.toFixed(1)}
|
|
1208
1285
|
${e.name}`);
|
|
1209
1286
|
}
|
|
1210
1287
|
break;
|
|
@@ -1220,16 +1297,16 @@ class mt {
|
|
|
1220
1297
|
lastLodLevel_Mesh = -1;
|
|
1221
1298
|
lastLodLevel_Texture = -1;
|
|
1222
1299
|
lastScreenCoverage = 0;
|
|
1223
|
-
lastScreenspaceVolume = new
|
|
1300
|
+
lastScreenspaceVolume = new C();
|
|
1224
1301
|
lastCentrality = 0;
|
|
1225
1302
|
}
|
|
1226
1303
|
const ve = /* @__PURE__ */ Symbol("NEEDLE_mesh_lod"), re = /* @__PURE__ */ Symbol("NEEDLE_texture_lod");
|
|
1227
1304
|
let he = null;
|
|
1228
|
-
function
|
|
1305
|
+
function Ie() {
|
|
1229
1306
|
const i = yt();
|
|
1230
1307
|
i && (i.mapURLs(function(t) {
|
|
1231
|
-
return
|
|
1232
|
-
}),
|
|
1308
|
+
return be(), t;
|
|
1309
|
+
}), be(), he?.disconnect(), he = new MutationObserver((t) => {
|
|
1233
1310
|
t.forEach((e) => {
|
|
1234
1311
|
e.addedNodes.forEach((s) => {
|
|
1235
1312
|
s instanceof HTMLElement && s.tagName.toLowerCase() === "model-viewer" && Re(s);
|
|
@@ -1241,21 +1318,21 @@ function yt() {
|
|
|
1241
1318
|
if (typeof customElements > "u") return null;
|
|
1242
1319
|
const i = customElements.get("model-viewer");
|
|
1243
1320
|
return i || (customElements.whenDefined("model-viewer").then(() => {
|
|
1244
|
-
console.debug("[gltf-progressive] model-viewer defined"),
|
|
1321
|
+
console.debug("[gltf-progressive] model-viewer defined"), Ie();
|
|
1245
1322
|
}), null);
|
|
1246
1323
|
}
|
|
1247
|
-
function
|
|
1324
|
+
function be() {
|
|
1248
1325
|
if (typeof document > "u") return;
|
|
1249
1326
|
document.querySelectorAll("model-viewer").forEach((t) => {
|
|
1250
1327
|
Re(t);
|
|
1251
1328
|
});
|
|
1252
1329
|
}
|
|
1253
|
-
const
|
|
1330
|
+
const De = /* @__PURE__ */ new WeakSet();
|
|
1254
1331
|
let xt = 0;
|
|
1255
1332
|
function Re(i) {
|
|
1256
|
-
if (!i ||
|
|
1333
|
+
if (!i || De.has(i))
|
|
1257
1334
|
return null;
|
|
1258
|
-
|
|
1335
|
+
De.add(i), console.debug("[gltf-progressive] found new model-viewer..." + ++xt + `
|
|
1259
1336
|
`, i.getAttribute("src"));
|
|
1260
1337
|
let t = null, e = null, s = null;
|
|
1261
1338
|
for (let n = i; n != null; n = Object.getPrototypeOf(n)) {
|
|
@@ -1315,18 +1392,18 @@ class wt {
|
|
|
1315
1392
|
a[re] = !0, a.userData && (a.userData.LOD = -1);
|
|
1316
1393
|
const u = Object.keys(a);
|
|
1317
1394
|
for (let d = 0; d < u.length; d++) {
|
|
1318
|
-
const
|
|
1319
|
-
if (
|
|
1320
|
-
const
|
|
1321
|
-
if (
|
|
1322
|
-
const
|
|
1323
|
-
if (!
|
|
1324
|
-
console.warn("Texture data not found for texture index " +
|
|
1395
|
+
const y = u[d], w = a[y];
|
|
1396
|
+
if (w?.isTexture === !0) {
|
|
1397
|
+
const L = w.userData?.associations?.textures;
|
|
1398
|
+
if (L == null) continue;
|
|
1399
|
+
const k = s.parser.json.textures[L];
|
|
1400
|
+
if (!k) {
|
|
1401
|
+
console.warn("Texture data not found for texture index " + L);
|
|
1325
1402
|
continue;
|
|
1326
1403
|
}
|
|
1327
|
-
if (
|
|
1328
|
-
const
|
|
1329
|
-
|
|
1404
|
+
if (k?.extensions?.[W]) {
|
|
1405
|
+
const v = k.extensions[W];
|
|
1406
|
+
v && r && m.registerTexture(r, w, v.lods.length, L, v);
|
|
1330
1407
|
}
|
|
1331
1408
|
}
|
|
1332
1409
|
}
|
|
@@ -1342,10 +1419,10 @@ class wt {
|
|
|
1342
1419
|
const s = this.tryGetCurrentModelViewer(t), n = this.getUrl(s);
|
|
1343
1420
|
if (!n)
|
|
1344
1421
|
return;
|
|
1345
|
-
const r = e.userData?.gltfExtensions?.[
|
|
1422
|
+
const r = e.userData?.gltfExtensions?.[W];
|
|
1346
1423
|
if (r && n) {
|
|
1347
1424
|
const o = e.uuid;
|
|
1348
|
-
|
|
1425
|
+
m.registerMesh(n, o, e, 0, r.lods.length, r);
|
|
1349
1426
|
}
|
|
1350
1427
|
}
|
|
1351
1428
|
}
|
|
@@ -1364,14 +1441,14 @@ function Lt(...i) {
|
|
|
1364
1441
|
default:
|
|
1365
1442
|
throw new Error("Invalid arguments");
|
|
1366
1443
|
}
|
|
1367
|
-
we(e),
|
|
1444
|
+
we(e), Pe(s), Ae(s, {
|
|
1368
1445
|
progressive: !0,
|
|
1369
1446
|
...n?.hints
|
|
1370
|
-
}), s.register((o) => new
|
|
1447
|
+
}), s.register((o) => new m(o));
|
|
1371
1448
|
const r = oe.get(e);
|
|
1372
1449
|
return n?.enableLODsManager !== !1 && r.enable(), r;
|
|
1373
1450
|
}
|
|
1374
|
-
|
|
1451
|
+
Ie();
|
|
1375
1452
|
if (!nt) {
|
|
1376
1453
|
const i = {
|
|
1377
1454
|
gltfProgressive: {
|
|
@@ -1390,8 +1467,8 @@ if (!nt) {
|
|
|
1390
1467
|
}
|
|
1391
1468
|
export {
|
|
1392
1469
|
oe as LODsManager,
|
|
1393
|
-
|
|
1394
|
-
|
|
1470
|
+
m as NEEDLE_progressive,
|
|
1471
|
+
Pe as addDracoAndKTX2Loaders,
|
|
1395
1472
|
Ae as configureLoader,
|
|
1396
1473
|
we as createLoaders,
|
|
1397
1474
|
Z as getRaycastMesh,
|