@react-three/drei 10.7.6 → 10.8.0-alpha.1
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/README.md +49 -758
- package/_chunks/hls.mjs +3 -0
- package/_chunks/libs/@mediapipe/tasks-vision.mjs +4781 -0
- package/_chunks/libs/@monogrid/gainmap-js.mjs +1137 -0
- package/_chunks/libs/@use-gesture/core.mjs +1650 -0
- package/_chunks/libs/@use-gesture/react.mjs +207 -0
- package/_chunks/libs/camera-controls.mjs +2207 -0
- package/_chunks/libs/detect-gpu.mjs +515 -0
- package/_chunks/libs/hls.js.mjs +21925 -0
- package/_chunks/libs/maath.mjs +5200 -0
- package/_chunks/libs/stats-gl.mjs +301 -0
- package/_chunks/libs/stats.js.mjs +90 -0
- package/_chunks/libs/suspend-react.mjs +60 -0
- package/_chunks/libs/three.mjs +23169 -0
- package/_chunks/libs/tunnel-rat.mjs +458 -0
- package/_chunks/libs/zustand.mjs +104 -0
- package/_chunks/rolldown-runtime.mjs +47 -0
- package/_chunks/vision_bundle.mjs +3 -0
- package/core/_chunks/hls.mjs +3 -0
- package/core/_chunks/libs/@monogrid/gainmap-js.mjs +1137 -0
- package/core/_chunks/libs/@use-gesture/core.mjs +1650 -0
- package/core/_chunks/libs/@use-gesture/react.mjs +207 -0
- package/core/_chunks/libs/detect-gpu.mjs +515 -0
- package/core/_chunks/libs/hls.js.mjs +21925 -0
- package/core/_chunks/libs/maath.mjs +5200 -0
- package/core/_chunks/libs/stats-gl.mjs +301 -0
- package/core/_chunks/libs/stats.js.mjs +90 -0
- package/core/_chunks/libs/suspend-react.mjs +60 -0
- package/core/_chunks/libs/three.mjs +22457 -0
- package/core/_chunks/libs/tunnel-rat.mjs +458 -0
- package/core/_chunks/libs/zustand.mjs +104 -0
- package/core/_chunks/rolldown-runtime.mjs +47 -0
- package/core/core/index.d.mts +2232 -0
- package/core/core/index.mjs +11082 -0
- package/experimental/_chunks/libs/three.mjs +15386 -0
- package/experimental/experimental/index.d.mts +253 -0
- package/experimental/experimental/index.mjs +434 -0
- package/external/_chunks/hls.mjs +3 -0
- package/external/_chunks/libs/@mediapipe/tasks-vision.mjs +4781 -0
- package/external/_chunks/libs/camera-controls.mjs +2207 -0
- package/external/_chunks/libs/hls.js.mjs +21925 -0
- package/external/_chunks/libs/maath.mjs +5200 -0
- package/external/_chunks/libs/suspend-react.mjs +58 -0
- package/external/_chunks/libs/three.mjs +15387 -0
- package/external/_chunks/rolldown-runtime.mjs +32 -0
- package/external/_chunks/vision_bundle.mjs +3 -0
- package/external/external/index.d.mts +499 -0
- package/external/external/index.mjs +9422 -0
- package/index.d.mts +2567 -0
- package/index.mjs +20571 -0
- package/legacy/_chunks/hls.mjs +3 -0
- package/legacy/_chunks/libs/@monogrid/gainmap-js.mjs +1137 -0
- package/legacy/_chunks/libs/@use-gesture/core.mjs +1650 -0
- package/legacy/_chunks/libs/@use-gesture/react.mjs +207 -0
- package/legacy/_chunks/libs/bidi-js.mjs +675 -0
- package/legacy/_chunks/libs/detect-gpu.mjs +515 -0
- package/legacy/_chunks/libs/hls.js.mjs +21925 -0
- package/legacy/_chunks/libs/maath.mjs +5200 -0
- package/legacy/_chunks/libs/stats-gl.mjs +301 -0
- package/legacy/_chunks/libs/stats.js.mjs +90 -0
- package/legacy/_chunks/libs/suspend-react.mjs +60 -0
- package/legacy/_chunks/libs/three.mjs +26062 -0
- package/legacy/_chunks/libs/troika-three-text.mjs +6494 -0
- package/legacy/_chunks/libs/tunnel-rat.mjs +458 -0
- package/legacy/_chunks/libs/zustand.mjs +104 -0
- package/legacy/_chunks/rolldown-runtime.mjs +47 -0
- package/legacy/legacy/index.d.mts +2788 -0
- package/legacy/legacy/index.mjs +14984 -0
- package/native/_chunks/hls.mjs +3 -0
- package/native/_chunks/libs/@monogrid/gainmap-js.mjs +1137 -0
- package/native/_chunks/libs/@use-gesture/core.mjs +1650 -0
- package/native/_chunks/libs/@use-gesture/react.mjs +207 -0
- package/native/_chunks/libs/detect-gpu.mjs +515 -0
- package/native/_chunks/libs/hls.js.mjs +21925 -0
- package/native/_chunks/libs/maath.mjs +5200 -0
- package/native/_chunks/libs/stats-gl.mjs +301 -0
- package/native/_chunks/libs/stats.js.mjs +90 -0
- package/native/_chunks/libs/suspend-react.mjs +60 -0
- package/native/_chunks/libs/three.mjs +22592 -0
- package/native/_chunks/libs/tunnel-rat.mjs +458 -0
- package/native/_chunks/libs/zustand.mjs +104 -0
- package/native/_chunks/rolldown-runtime.mjs +47 -0
- package/native/native/index.d.mts +3168 -0
- package/native/native/index.mjs +14863 -0
- package/package.json +41 -10
- package/webgpu/_chunks/hls.mjs +3 -0
- package/webgpu/_chunks/libs/@monogrid/gainmap-js.mjs +1137 -0
- package/webgpu/_chunks/libs/@use-gesture/core.mjs +1650 -0
- package/webgpu/_chunks/libs/@use-gesture/react.mjs +207 -0
- package/webgpu/_chunks/libs/detect-gpu.mjs +515 -0
- package/webgpu/_chunks/libs/hls.js.mjs +21925 -0
- package/webgpu/_chunks/libs/maath.mjs +5200 -0
- package/webgpu/_chunks/libs/stats-gl.mjs +301 -0
- package/webgpu/_chunks/libs/stats.js.mjs +90 -0
- package/webgpu/_chunks/libs/suspend-react.mjs +60 -0
- package/webgpu/_chunks/libs/three.mjs +22592 -0
- package/webgpu/_chunks/libs/tunnel-rat.mjs +458 -0
- package/webgpu/_chunks/libs/zustand.mjs +104 -0
- package/webgpu/_chunks/rolldown-runtime.mjs +47 -0
- package/webgpu/webgpu/index.d.mts +3166 -0
- package/webgpu/webgpu/index.mjs +15015 -0
- package/core/AccumulativeShadows.cjs.js +0 -1
- package/core/AccumulativeShadows.d.ts +0 -59
- package/core/AccumulativeShadows.js +0 -310
- package/core/AdaptiveDpr.cjs.js +0 -1
- package/core/AdaptiveDpr.d.ts +0 -3
- package/core/AdaptiveDpr.js +0 -28
- package/core/AdaptiveEvents.cjs.js +0 -1
- package/core/AdaptiveEvents.d.ts +0 -1
- package/core/AdaptiveEvents.js +0 -20
- package/core/ArcballControls.cjs.js +0 -1
- package/core/ArcballControls.d.ts +0 -15
- package/core/ArcballControls.js +0 -67
- package/core/AsciiRenderer.cjs.js +0 -1
- package/core/AsciiRenderer.d.ts +0 -11
- package/core/AsciiRenderer.js +0 -66
- package/core/BBAnchor.cjs.js +0 -1
- package/core/BBAnchor.d.ts +0 -7
- package/core/BBAnchor.js +0 -37
- package/core/Backdrop.cjs.js +0 -1
- package/core/Backdrop.d.ts +0 -15
- package/core/Backdrop.js +0 -33
- package/core/BakeShadows.cjs.js +0 -1
- package/core/BakeShadows.d.ts +0 -1
- package/core/BakeShadows.js +0 -16
- package/core/Billboard.cjs.js +0 -1
- package/core/Billboard.d.ts +0 -10
- package/core/Billboard.js +0 -53
- package/core/Bounds.cjs.js +0 -1
- package/core/Bounds.d.ts +0 -36
- package/core/Bounds.js +0 -254
- package/core/Bvh.cjs.js +0 -1
- package/core/Bvh.d.ts +0 -19
- package/core/Bvh.js +0 -92
- package/core/CameraControls.cjs.js +0 -1
- package/core/CameraControls.d.ts +0 -48
- package/core/CameraControls.js +0 -151
- package/core/CameraShake.cjs.js +0 -1
- package/core/CameraShake.d.ts +0 -17
- package/core/CameraShake.js +0 -57
- package/core/CatmullRomLine.cjs.js +0 -1
- package/core/CatmullRomLine.d.ts +0 -10
- package/core/CatmullRomLine.js +0 -42
- package/core/Caustics.cjs.js +0 -1
- package/core/Caustics.d.ts +0 -32
- package/core/Caustics.js +0 -388
- package/core/Center.cjs.js +0 -1
- package/core/Center.d.ts +0 -33
- package/core/Center.js +0 -67
- package/core/Clone.cjs.js +0 -1
- package/core/Clone.d.ts +0 -15
- package/core/Clone.js +0 -100
- package/core/Cloud.cjs.js +0 -1
- package/core/Cloud.d.ts +0 -97
- package/core/Cloud.js +0 -231
- package/core/ComputedAttribute.cjs.js +0 -1
- package/core/ComputedAttribute.d.ts +0 -8
- package/core/ComputedAttribute.js +0 -33
- package/core/ContactShadows.cjs.js +0 -1
- package/core/ContactShadows.d.ts +0 -18
- package/core/ContactShadows.js +0 -114
- package/core/CubeCamera.cjs.js +0 -1
- package/core/CubeCamera.d.ts +0 -21
- package/core/CubeCamera.js +0 -86
- package/core/CubeTexture.cjs.js +0 -1
- package/core/CubeTexture.d.ts +0 -14
- package/core/CubeTexture.js +0 -25
- package/core/CubicBezierLine.cjs.js +0 -1
- package/core/CubicBezierLine.d.ts +0 -12
- package/core/CubicBezierLine.js +0 -28
- package/core/CurveModifier.cjs.js +0 -1
- package/core/CurveModifier.d.ts +0 -11
- package/core/CurveModifier.js +0 -27
- package/core/Decal.cjs.js +0 -1
- package/core/Decal.d.ts +0 -16
- package/core/Decal.js +0 -128
- package/core/Detailed.cjs.js +0 -1
- package/core/Detailed.d.ts +0 -10
- package/core/Detailed.js +0 -33
- package/core/DetectGPU.cjs.js +0 -1
- package/core/DetectGPU.d.ts +0 -7
- package/core/DetectGPU.js +0 -14
- package/core/DeviceOrientationControls.cjs.js +0 -1
- package/core/DeviceOrientationControls.d.ts +0 -10
- package/core/DeviceOrientationControls.js +0 -51
- package/core/Edges.cjs.js +0 -1
- package/core/Edges.d.ts +0 -13
- package/core/Edges.js +0 -38
- package/core/Effects.cjs.js +0 -1
- package/core/Effects.d.ts +0 -25
- package/core/Effects.js +0 -91
- package/core/Environment.cjs.js +0 -1
- package/core/Environment.d.ts +0 -37
- package/core/Environment.js +0 -189
- package/core/Example.cjs.js +0 -1
- package/core/Example.d.ts +0 -13
- package/core/Example.js +0 -46
- package/core/Fbo.cjs.js +0 -1
- package/core/Fbo.d.ts +0 -22
- package/core/Fbo.js +0 -63
- package/core/Fbx.cjs.js +0 -1
- package/core/Fbx.d.ts +0 -11
- package/core/Fbx.js +0 -23
- package/core/FirstPersonControls.cjs.js +0 -1
- package/core/FirstPersonControls.d.ts +0 -8
- package/core/FirstPersonControls.js +0 -38
- package/core/Fisheye.cjs.js +0 -1
- package/core/Fisheye.d.ts +0 -10
- package/core/Fisheye.js +0 -95
- package/core/Float.cjs.js +0 -1
- package/core/Float.d.ts +0 -14
- package/core/Float.js +0 -37
- package/core/FlyControls.cjs.js +0 -1
- package/core/FlyControls.d.ts +0 -10
- package/core/FlyControls.js +0 -55
- package/core/GizmoHelper.cjs.js +0 -1
- package/core/GizmoHelper.d.ts +0 -16
- package/core/GizmoHelper.js +0 -116
- package/core/GizmoViewcube.cjs.js +0 -1
- package/core/GizmoViewcube.d.ts +0 -14
- package/core/GizmoViewcube.js +0 -133
- package/core/GizmoViewport.cjs.js +0 -1
- package/core/GizmoViewport.d.ts +0 -16
- package/core/GizmoViewport.js +0 -140
- package/core/Gltf.cjs.js +0 -1
- package/core/Gltf.d.ts +0 -27
- package/core/Gltf.js +0 -52
- package/core/GradientTexture.cjs.js +0 -1
- package/core/GradientTexture.d.ts +0 -18
- package/core/GradientTexture.js +0 -54
- package/core/Grid.cjs.js +0 -1
- package/core/Grid.d.ts +0 -26
- package/core/Grid.js +0 -142
- package/core/Helper.cjs.js +0 -1
- package/core/Helper.d.ts +0 -16
- package/core/Helper.js +0 -47
- package/core/Hud.cjs.js +0 -1
- package/core/Hud.d.ts +0 -6
- package/core/Hud.js +0 -55
- package/core/Image.cjs.js +0 -1
- package/core/Image.d.ts +0 -38
- package/core/Image.js +0 -160
- package/core/Instances.cjs.js +0 -1
- package/core/Instances.d.ts +0 -64
- package/core/Instances.js +0 -313
- package/core/Ktx2.cjs.js +0 -1
- package/core/Ktx2.d.ts +0 -14
- package/core/Ktx2.js +0 -48
- package/core/Lightformer.cjs.js +0 -1
- package/core/Lightformer.d.ts +0 -15
- package/core/Lightformer.js +0 -63
- package/core/Line.cjs.js +0 -1
- package/core/Line.d.ts +0 -13
- package/core/Line.js +0 -73
- package/core/MapControls.cjs.js +0 -1
- package/core/MapControls.d.ts +0 -14
- package/core/MapControls.js +0 -63
- package/core/MarchingCubes.cjs.js +0 -1
- package/core/MarchingCubes.d.ts +0 -24
- package/core/MarchingCubes.js +0 -78
- package/core/Mask.cjs.js +0 -1
- package/core/Mask.d.ts +0 -17
- package/core/Mask.js +0 -42
- package/core/MatcapTexture.cjs.js +0 -1
- package/core/MatcapTexture.d.ts +0 -9
- package/core/MatcapTexture.js +0 -51
- package/core/MeshDiscardMaterial.cjs.js +0 -1
- package/core/MeshDiscardMaterial.d.ts +0 -10
- package/core/MeshDiscardMaterial.js +0 -15
- package/core/MeshDistortMaterial.cjs.js +0 -1
- package/core/MeshDistortMaterial.d.ts +0 -39
- package/core/MeshDistortMaterial.js +0 -72
- package/core/MeshPortalMaterial.cjs.js +0 -1
- package/core/MeshPortalMaterial.d.ts +0 -25
- package/core/MeshPortalMaterial.js +0 -467
- package/core/MeshReflectorMaterial.cjs.js +0 -1
- package/core/MeshReflectorMaterial.d.ts +0 -14
- package/core/MeshReflectorMaterial.js +0 -180
- package/core/MeshRefractionMaterial.cjs.js +0 -1
- package/core/MeshRefractionMaterial.d.ts +0 -19
- package/core/MeshRefractionMaterial.js +0 -73
- package/core/MeshTransmissionMaterial.cjs.js +0 -1
- package/core/MeshTransmissionMaterial.d.ts +0 -34
- package/core/MeshTransmissionMaterial.js +0 -402
- package/core/MeshWobbleMaterial.cjs.js +0 -1
- package/core/MeshWobbleMaterial.d.ts +0 -36
- package/core/MeshWobbleMaterial.js +0 -60
- package/core/MotionPathControls.cjs.js +0 -1
- package/core/MotionPathControls.d.ts +0 -33
- package/core/MotionPathControls.js +0 -121
- package/core/MultiMaterial.cjs.js +0 -1
- package/core/MultiMaterial.d.ts +0 -4
- package/core/MultiMaterial.js +0 -29
- package/core/NormalTexture.cjs.js +0 -1
- package/core/NormalTexture.d.ts +0 -14
- package/core/NormalTexture.js +0 -42
- package/core/OrbitControls.cjs.js +0 -1
- package/core/OrbitControls.d.ts +0 -22
- package/core/OrbitControls.js +0 -79
- package/core/OrthographicCamera.cjs.js +0 -1
- package/core/OrthographicCamera.d.ts +0 -14
- package/core/OrthographicCamera.js +0 -76
- package/core/Outlines.cjs.js +0 -1
- package/core/Outlines.d.ts +0 -17
- package/core/Outlines.js +0 -166
- package/core/PerformanceMonitor.cjs.js +0 -1
- package/core/PerformanceMonitor.d.ts +0 -36
- package/core/PerformanceMonitor.js +0 -116
- package/core/PerspectiveCamera.cjs.js +0 -1
- package/core/PerspectiveCamera.d.ts +0 -14
- package/core/PerspectiveCamera.js +0 -72
- package/core/PointMaterial.cjs.js +0 -1
- package/core/PointMaterial.d.ts +0 -8
- package/core/PointMaterial.js +0 -36
- package/core/PointerLockControls.cjs.js +0 -1
- package/core/PointerLockControls.d.ts +0 -15
- package/core/PointerLockControls.js +0 -89
- package/core/Points.cjs.js +0 -1
- package/core/Points.d.ts +0 -31
- package/core/Points.js +0 -202
- package/core/PositionalAudio.cjs.js +0 -1
- package/core/PositionalAudio.d.ts +0 -9
- package/core/PositionalAudio.js +0 -46
- package/core/Preload.cjs.js +0 -1
- package/core/Preload.d.ts +0 -7
- package/core/Preload.js +0 -44
- package/core/Progress.cjs.js +0 -1
- package/core/Progress.d.ts +0 -14
- package/core/Progress.js +0 -55
- package/core/QuadraticBezierLine.cjs.js +0 -1
- package/core/QuadraticBezierLine.d.ts +0 -14
- package/core/QuadraticBezierLine.js +0 -42
- package/core/RenderCubeTexture.cjs.js +0 -1
- package/core/RenderCubeTexture.d.ts +0 -30
- package/core/RenderCubeTexture.js +0 -96
- package/core/RenderTexture.cjs.js +0 -1
- package/core/RenderTexture.d.ts +0 -18
- package/core/RenderTexture.js +0 -105
- package/core/Resize.cjs.js +0 -1
- package/core/Resize.d.ts +0 -17
- package/core/Resize.js +0 -39
- package/core/RoundedBox.cjs.js +0 -1
- package/core/RoundedBox.d.ts +0 -14
- package/core/RoundedBox.js +0 -70
- package/core/Sampler.cjs.js +0 -1
- package/core/Sampler.d.ts +0 -28
- package/core/Sampler.js +0 -75
- package/core/ScreenQuad.cjs.js +0 -1
- package/core/ScreenQuad.d.ts +0 -5
- package/core/ScreenQuad.js +0 -25
- package/core/ScreenSizer.cjs.js +0 -1
- package/core/ScreenSizer.d.ts +0 -7
- package/core/ScreenSizer.js +0 -39
- package/core/ScreenSpace.cjs.js +0 -1
- package/core/ScreenSpace.d.ts +0 -7
- package/core/ScreenSpace.js +0 -25
- package/core/Segments.cjs.js +0 -1
- package/core/Segments.d.ts +0 -29
- package/core/Segments.js +0 -96
- package/core/Shadow.cjs.js +0 -1
- package/core/Shadow.d.ts +0 -12
- package/core/Shadow.js +0 -42
- package/core/ShadowAlpha.cjs.js +0 -1
- package/core/ShadowAlpha.d.ts +0 -7
- package/core/ShadowAlpha.js +0 -108
- package/core/Sky.cjs.js +0 -1
- package/core/Sky.d.ts +0 -16
- package/core/Sky.js +0 -39
- package/core/Sparkles.cjs.js +0 -1
- package/core/Sparkles.d.ts +0 -26
- package/core/Sparkles.js +0 -161
- package/core/Splat.cjs.js +0 -1
- package/core/Splat.d.ts +0 -56
- package/core/Splat.js +0 -506
- package/core/SpotLight.cjs.js +0 -1
- package/core/SpotLight.d.ts +0 -27
- package/core/SpotLight.js +0 -223
- package/core/SpriteAnimator.cjs.js +0 -1
- package/core/SpriteAnimator.d.ts +0 -88
- package/core/SpriteAnimator.js +0 -413
- package/core/Stage.cjs.js +0 -1
- package/core/Stage.d.ts +0 -27
- package/core/Stage.js +0 -133
- package/core/Stars.cjs.js +0 -1
- package/core/Stars.d.ts +0 -22
- package/core/Stars.js +0 -100
- package/core/Stats.cjs.js +0 -1
- package/core/Stats.d.ts +0 -7
- package/core/Stats.js +0 -32
- package/core/StatsGl.cjs.js +0 -1
- package/core/StatsGl.d.ts +0 -14
- package/core/StatsGl.js +0 -44
- package/core/Svg.cjs.js +0 -1
- package/core/Svg.d.ts +0 -13
- package/core/Svg.js +0 -62
- package/core/Text.cjs.js +0 -1
- package/core/Text.d.ts +0 -38
- package/core/Text.js +0 -57
- package/core/Text3D.cjs.js +0 -1
- package/core/Text3D.d.ts +0 -20
- package/core/Text3D.js +0 -74
- package/core/Texture.cjs.js +0 -1
- package/core/Texture.d.ts +0 -20
- package/core/Texture.js +0 -60
- package/core/TrackballControls.cjs.js +0 -1
- package/core/TrackballControls.d.ts +0 -15
- package/core/TrackballControls.js +0 -72
- package/core/Trail.cjs.js +0 -1
- package/core/Trail.d.ts +0 -21
- package/core/Trail.js +0 -150
- package/core/TrailTexture.cjs.js +0 -1
- package/core/TrailTexture.d.ts +0 -19
- package/core/TrailTexture.js +0 -159
- package/core/TransformControls.cjs.js +0 -1
- package/core/TransformControls.d.ts +0 -28
- package/core/TransformControls.js +0 -114
- package/core/VideoTexture.cjs.js +0 -1
- package/core/VideoTexture.d.ts +0 -26
- package/core/VideoTexture.js +0 -111
- package/core/Wireframe.cjs.js +0 -1
- package/core/Wireframe.d.ts +0 -15
- package/core/Wireframe.js +0 -157
- package/core/calculateScaleFactor.cjs.js +0 -1
- package/core/calculateScaleFactor.d.ts +0 -3
- package/core/calculateScaleFactor.js +0 -31
- package/core/index.cjs.js +0 -1
- package/core/index.d.ts +0 -122
- package/core/index.js +0 -150
- package/core/meshBounds.cjs.js +0 -1
- package/core/meshBounds.d.ts +0 -2
- package/core/meshBounds.js +0 -28
- package/core/shaderMaterial.cjs.js +0 -1
- package/core/shaderMaterial.d.ts +0 -9
- package/core/shaderMaterial.js +0 -29
- package/core/shapes.cjs.js +0 -1
- package/core/shapes.d.ts +0 -26
- package/core/shapes.js +0 -65
- package/core/softShadows.cjs.js +0 -1
- package/core/softShadows.d.ts +0 -6
- package/core/softShadows.js +0 -158
- package/core/useAnimations.cjs.js +0 -1
- package/core/useAnimations.d.ts +0 -13
- package/core/useAnimations.js +0 -52
- package/core/useAspect.cjs.js +0 -1
- package/core/useAspect.d.ts +0 -1
- package/core/useAspect.js +0 -10
- package/core/useBoxProjectedEnv.cjs.js +0 -1
- package/core/useBoxProjectedEnv.d.ts +0 -19
- package/core/useBoxProjectedEnv.js +0 -95
- package/core/useCamera.cjs.js +0 -1
- package/core/useCamera.d.ts +0 -3
- package/core/useCamera.js +0 -19
- package/core/useContextBridge.cjs.js +0 -1
- package/core/useContextBridge.d.ts +0 -4
- package/core/useContextBridge.js +0 -20
- package/core/useDepthBuffer.cjs.js +0 -1
- package/core/useDepthBuffer.d.ts +0 -6
- package/core/useDepthBuffer.js +0 -38
- package/core/useEnvironment.cjs.js +0 -1
- package/core/useEnvironment.d.ts +0 -17
- package/core/useEnvironment.js +0 -150
- package/core/useFont.cjs.js +0 -1
- package/core/useFont.d.ts +0 -24
- package/core/useFont.js +0 -24
- package/core/useIntersect.cjs.js +0 -1
- package/core/useIntersect.d.ts +0 -3
- package/core/useIntersect.js +0 -36
- package/core/useSpriteLoader.cjs.js +0 -1
- package/core/useSpriteLoader.d.ts +0 -57
- package/core/useSpriteLoader.js +0 -402
- package/helpers/constants.cjs.js +0 -1
- package/helpers/constants.d.ts +0 -1
- package/helpers/constants.js +0 -6
- package/helpers/deprecated.cjs.js +0 -1
- package/helpers/deprecated.d.ts +0 -5
- package/helpers/deprecated.js +0 -8
- package/helpers/environment-assets.cjs.js +0 -1
- package/helpers/environment-assets.d.ts +0 -13
- package/helpers/environment-assets.js +0 -14
- package/helpers/glsl/DefaultSpotlightShadowShadows.glsl.js +0 -3
- package/helpers/glsl/distort.vert.glsl.js +0 -3
- package/helpers/ts-utils.cjs.js +0 -1
- package/helpers/ts-utils.d.ts +0 -7
- package/helpers/ts-utils.js +0 -1
- package/helpers/useEffectfulState.cjs.js +0 -1
- package/helpers/useEffectfulState.d.ts +0 -4
- package/helpers/useEffectfulState.js +0 -17
- package/index.cjs.js +0 -1
- package/index.d.ts +0 -1
- package/index.js +0 -139
- package/materials/BlurPass.cjs.js +0 -1
- package/materials/BlurPass.d.ts +0 -23
- package/materials/BlurPass.js +0 -72
- package/materials/ConvolutionMaterial.cjs.js +0 -1
- package/materials/ConvolutionMaterial.d.ts +0 -7
- package/materials/ConvolutionMaterial.js +0 -97
- package/materials/DiscardMaterial.cjs.js +0 -1
- package/materials/DiscardMaterial.d.ts +0 -3
- package/materials/DiscardMaterial.js +0 -5
- package/materials/MeshReflectorMaterial.cjs.js +0 -1
- package/materials/MeshReflectorMaterial.d.ts +0 -50
- package/materials/MeshReflectorMaterial.js +0 -256
- package/materials/MeshRefractionMaterial.cjs.js +0 -1
- package/materials/MeshRefractionMaterial.d.ts +0 -18
- package/materials/MeshRefractionMaterial.js +0 -163
- package/materials/SpotLightMaterial.cjs.js +0 -1
- package/materials/SpotLightMaterial.d.ts +0 -4
- package/materials/SpotLightMaterial.js +0 -115
- package/materials/WireframeMaterial.cjs.js +0 -1
- package/materials/WireframeMaterial.d.ts +0 -64
- package/materials/WireframeMaterial.js +0 -217
- package/native/index.cjs.js +0 -1
- package/native/index.d.ts +0 -1
- package/native/index.js +0 -150
- package/web/CycleRaycast.cjs.js +0 -1
- package/web/CycleRaycast.d.ts +0 -10
- package/web/CycleRaycast.js +0 -93
- package/web/DragControls.cjs.js +0 -1
- package/web/DragControls.d.ts +0 -17
- package/web/DragControls.js +0 -127
- package/web/FaceControls.cjs.js +0 -1
- package/web/FaceControls.d.ts +0 -29
- package/web/FaceControls.js +0 -236
- package/web/FaceLandmarker.cjs.js +0 -1
- package/web/FaceLandmarker.d.ts +0 -14
- package/web/FaceLandmarker.js +0 -49
- package/web/Facemesh.cjs.js +0 -1
- package/web/Facemesh.d.ts +0 -118
- package/web/Facemesh.js +0 -4538
- package/web/Html.cjs.js +0 -1
- package/web/Html.d.ts +0 -34
- package/web/Html.js +0 -375
- package/web/KeyboardControls.cjs.js +0 -1
- package/web/KeyboardControls.d.ts +0 -37
- package/web/KeyboardControls.js +0 -104
- package/web/Loader.cjs.js +0 -1
- package/web/Loader.d.ts +0 -12
- package/web/Loader.js +0 -101
- package/web/PresentationControls.cjs.js +0 -1
- package/web/PresentationControls.d.ts +0 -16
- package/web/PresentationControls.js +0 -79
- package/web/ScreenVideoTexture.cjs.js +0 -1
- package/web/ScreenVideoTexture.d.ts +0 -17
- package/web/ScreenVideoTexture.js +0 -30
- package/web/ScrollControls.cjs.js +0 -1
- package/web/ScrollControls.d.ts +0 -45
- package/web/ScrollControls.js +0 -237
- package/web/Select.cjs.js +0 -1
- package/web/Select.d.ts +0 -14
- package/web/Select.js +0 -171
- package/web/View.cjs.js +0 -1
- package/web/View.d.ts +0 -34
- package/web/View.js +0 -259
- package/web/WebcamVideoTexture.cjs.js +0 -1
- package/web/WebcamVideoTexture.d.ts +0 -17
- package/web/WebcamVideoTexture.js +0 -33
- package/web/index.cjs.js +0 -1
- package/web/index.d.ts +0 -17
- package/web/index.js +0 -176
- package/web/pivotControls/AxisArrow.cjs.js +0 -1
- package/web/pivotControls/AxisArrow.d.ts +0 -7
- package/web/pivotControls/AxisArrow.js +0 -193
- package/web/pivotControls/AxisRotator.cjs.js +0 -1
- package/web/pivotControls/AxisRotator.d.ts +0 -7
- package/web/pivotControls/AxisRotator.js +0 -220
- package/web/pivotControls/PlaneSlider.cjs.js +0 -1
- package/web/pivotControls/PlaneSlider.d.ts +0 -7
- package/web/pivotControls/PlaneSlider.js +0 -202
- package/web/pivotControls/ScalingSphere.cjs.js +0 -1
- package/web/pivotControls/ScalingSphere.d.ts +0 -7
- package/web/pivotControls/ScalingSphere.js +0 -192
- package/web/pivotControls/context.cjs.js +0 -1
- package/web/pivotControls/context.d.ts +0 -33
- package/web/pivotControls/context.js +0 -5
- package/web/pivotControls/index.cjs.js +0 -1
- package/web/pivotControls/index.d.ts +0 -39
- package/web/pivotControls/index.js +0 -213
- package/web/useCursor.cjs.js +0 -1
- package/web/useCursor.d.ts +0 -1
- package/web/useCursor.js +0 -12
|
@@ -0,0 +1,1137 @@
|
|
|
1
|
+
import { ByteType, ClampToEdgeWrapping, DataTexture, FileLoader, FloatType, HalfFloatType, IntType, LinearFilter, LinearMipMapLinearFilter, LinearSRGBColorSpace, Loader, LoadingManager, Mesh, MeshBasicMaterial, NoBlending, OrthographicCamera, PlaneGeometry, RGBAFormat, SRGBColorSpace, Scene, ShaderMaterial, ShortType, Texture, UVMapping, UnsignedByteType, UnsignedIntType, Vector3, WebGLRenderTarget, WebGLRenderer } from "three";
|
|
2
|
+
|
|
3
|
+
//#region node_modules/@monogrid/gainmap-js/dist/QuadRenderer-B3h-sJtp.js
|
|
4
|
+
/**
|
|
5
|
+
* @monogrid/gainmap-js v3.0.6
|
|
6
|
+
* With ❤️, by MONOGRID <rnd@monogrid.com>
|
|
7
|
+
*/
|
|
8
|
+
const getBufferForType = (type, width, height) => {
|
|
9
|
+
let out;
|
|
10
|
+
switch (type) {
|
|
11
|
+
case UnsignedByteType:
|
|
12
|
+
out = new Uint8ClampedArray(width * height * 4);
|
|
13
|
+
break;
|
|
14
|
+
case HalfFloatType:
|
|
15
|
+
out = new Uint16Array(width * height * 4);
|
|
16
|
+
break;
|
|
17
|
+
case UnsignedIntType:
|
|
18
|
+
out = new Uint32Array(width * height * 4);
|
|
19
|
+
break;
|
|
20
|
+
case ByteType:
|
|
21
|
+
out = new Int8Array(width * height * 4);
|
|
22
|
+
break;
|
|
23
|
+
case ShortType:
|
|
24
|
+
out = new Int16Array(width * height * 4);
|
|
25
|
+
break;
|
|
26
|
+
case IntType:
|
|
27
|
+
out = new Int32Array(width * height * 4);
|
|
28
|
+
break;
|
|
29
|
+
case FloatType:
|
|
30
|
+
out = new Float32Array(width * height * 4);
|
|
31
|
+
break;
|
|
32
|
+
default: throw new Error("Unsupported data type");
|
|
33
|
+
}
|
|
34
|
+
return out;
|
|
35
|
+
};
|
|
36
|
+
let _canReadPixelsResult;
|
|
37
|
+
/**
|
|
38
|
+
* Test if this browser implementation can correctly read pixels from the specified
|
|
39
|
+
* Render target type.
|
|
40
|
+
*
|
|
41
|
+
* Runs only once
|
|
42
|
+
*
|
|
43
|
+
* @param type
|
|
44
|
+
* @param renderer
|
|
45
|
+
* @param camera
|
|
46
|
+
* @param renderTargetOptions
|
|
47
|
+
* @returns
|
|
48
|
+
*/
|
|
49
|
+
const canReadPixels = (type, renderer, camera, renderTargetOptions) => {
|
|
50
|
+
if (_canReadPixelsResult !== void 0) return _canReadPixelsResult;
|
|
51
|
+
const testRT = new WebGLRenderTarget(1, 1, renderTargetOptions);
|
|
52
|
+
renderer.setRenderTarget(testRT);
|
|
53
|
+
const mesh = new Mesh(new PlaneGeometry(), new MeshBasicMaterial({ color: 16777215 }));
|
|
54
|
+
renderer.render(mesh, camera);
|
|
55
|
+
renderer.setRenderTarget(null);
|
|
56
|
+
const out = getBufferForType(type, testRT.width, testRT.height);
|
|
57
|
+
renderer.readRenderTargetPixels(testRT, 0, 0, testRT.width, testRT.height, out);
|
|
58
|
+
testRT.dispose();
|
|
59
|
+
mesh.geometry.dispose();
|
|
60
|
+
mesh.material.dispose();
|
|
61
|
+
_canReadPixelsResult = out[0] !== 0;
|
|
62
|
+
return _canReadPixelsResult;
|
|
63
|
+
};
|
|
64
|
+
/**
|
|
65
|
+
* Utility class used for rendering a texture with a material
|
|
66
|
+
*
|
|
67
|
+
* @category Core
|
|
68
|
+
* @group Core
|
|
69
|
+
*/
|
|
70
|
+
var QuadRenderer = class QuadRenderer {
|
|
71
|
+
/**
|
|
72
|
+
* Constructs a new QuadRenderer
|
|
73
|
+
*
|
|
74
|
+
* @param options Parameters for this QuadRenderer
|
|
75
|
+
*/
|
|
76
|
+
constructor(options) {
|
|
77
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
|
78
|
+
this._rendererIsDisposable = false;
|
|
79
|
+
this._supportsReadPixels = true;
|
|
80
|
+
/**
|
|
81
|
+
* Renders the input texture using the specified material
|
|
82
|
+
*/
|
|
83
|
+
this.render = () => {
|
|
84
|
+
this._renderer.setRenderTarget(this._renderTarget);
|
|
85
|
+
try {
|
|
86
|
+
this._renderer.render(this._scene, this._camera);
|
|
87
|
+
} catch (e) {
|
|
88
|
+
this._renderer.setRenderTarget(null);
|
|
89
|
+
throw e;
|
|
90
|
+
}
|
|
91
|
+
this._renderer.setRenderTarget(null);
|
|
92
|
+
};
|
|
93
|
+
this._width = options.width;
|
|
94
|
+
this._height = options.height;
|
|
95
|
+
this._type = options.type;
|
|
96
|
+
this._colorSpace = options.colorSpace;
|
|
97
|
+
const rtOptions = {
|
|
98
|
+
format: RGBAFormat,
|
|
99
|
+
depthBuffer: false,
|
|
100
|
+
stencilBuffer: false,
|
|
101
|
+
type: this._type,
|
|
102
|
+
colorSpace: this._colorSpace,
|
|
103
|
+
anisotropy: ((_a = options.renderTargetOptions) === null || _a === void 0 ? void 0 : _a.anisotropy) !== void 0 ? (_b = options.renderTargetOptions) === null || _b === void 0 ? void 0 : _b.anisotropy : 1,
|
|
104
|
+
generateMipmaps: ((_c = options.renderTargetOptions) === null || _c === void 0 ? void 0 : _c.generateMipmaps) !== void 0 ? (_d = options.renderTargetOptions) === null || _d === void 0 ? void 0 : _d.generateMipmaps : false,
|
|
105
|
+
magFilter: ((_e = options.renderTargetOptions) === null || _e === void 0 ? void 0 : _e.magFilter) !== void 0 ? (_f = options.renderTargetOptions) === null || _f === void 0 ? void 0 : _f.magFilter : LinearFilter,
|
|
106
|
+
minFilter: ((_g = options.renderTargetOptions) === null || _g === void 0 ? void 0 : _g.minFilter) !== void 0 ? (_h = options.renderTargetOptions) === null || _h === void 0 ? void 0 : _h.minFilter : LinearFilter,
|
|
107
|
+
samples: ((_j = options.renderTargetOptions) === null || _j === void 0 ? void 0 : _j.samples) !== void 0 ? (_k = options.renderTargetOptions) === null || _k === void 0 ? void 0 : _k.samples : void 0,
|
|
108
|
+
wrapS: ((_l = options.renderTargetOptions) === null || _l === void 0 ? void 0 : _l.wrapS) !== void 0 ? (_m = options.renderTargetOptions) === null || _m === void 0 ? void 0 : _m.wrapS : ClampToEdgeWrapping,
|
|
109
|
+
wrapT: ((_o = options.renderTargetOptions) === null || _o === void 0 ? void 0 : _o.wrapT) !== void 0 ? (_p = options.renderTargetOptions) === null || _p === void 0 ? void 0 : _p.wrapT : ClampToEdgeWrapping
|
|
110
|
+
};
|
|
111
|
+
this._material = options.material;
|
|
112
|
+
if (options.renderer) this._renderer = options.renderer;
|
|
113
|
+
else {
|
|
114
|
+
this._renderer = QuadRenderer.instantiateRenderer();
|
|
115
|
+
this._rendererIsDisposable = true;
|
|
116
|
+
}
|
|
117
|
+
this._scene = new Scene();
|
|
118
|
+
this._camera = new OrthographicCamera();
|
|
119
|
+
this._camera.position.set(0, 0, 10);
|
|
120
|
+
this._camera.left = -.5;
|
|
121
|
+
this._camera.right = .5;
|
|
122
|
+
this._camera.top = .5;
|
|
123
|
+
this._camera.bottom = -.5;
|
|
124
|
+
this._camera.updateProjectionMatrix();
|
|
125
|
+
if (!canReadPixels(this._type, this._renderer, this._camera, rtOptions)) {
|
|
126
|
+
let alternativeType;
|
|
127
|
+
switch (this._type) {
|
|
128
|
+
case HalfFloatType:
|
|
129
|
+
alternativeType = this._renderer.extensions.has("EXT_color_buffer_float") ? FloatType : void 0;
|
|
130
|
+
break;
|
|
131
|
+
}
|
|
132
|
+
if (alternativeType !== void 0) {
|
|
133
|
+
console.warn(`This browser does not support reading pixels from ${this._type} RenderTargets, switching to ${FloatType}`);
|
|
134
|
+
this._type = alternativeType;
|
|
135
|
+
} else {
|
|
136
|
+
this._supportsReadPixels = false;
|
|
137
|
+
console.warn("This browser dos not support toArray or toDataTexture, calls to those methods will result in an error thrown");
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
this._quad = new Mesh(new PlaneGeometry(), this._material);
|
|
141
|
+
this._quad.geometry.computeBoundingBox();
|
|
142
|
+
this._scene.add(this._quad);
|
|
143
|
+
this._renderTarget = new WebGLRenderTarget(this.width, this.height, rtOptions);
|
|
144
|
+
this._renderTarget.texture.mapping = ((_q = options.renderTargetOptions) === null || _q === void 0 ? void 0 : _q.mapping) !== void 0 ? (_r = options.renderTargetOptions) === null || _r === void 0 ? void 0 : _r.mapping : UVMapping;
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Instantiates a temporary renderer
|
|
148
|
+
*
|
|
149
|
+
* @returns
|
|
150
|
+
*/
|
|
151
|
+
static instantiateRenderer() {
|
|
152
|
+
const renderer = new WebGLRenderer();
|
|
153
|
+
renderer.setSize(128, 128);
|
|
154
|
+
return renderer;
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Obtains a Buffer containing the rendered texture.
|
|
158
|
+
*
|
|
159
|
+
* @throws Error if the browser cannot read pixels from this RenderTarget type.
|
|
160
|
+
* @returns a TypedArray containing RGBA values from this renderer
|
|
161
|
+
*/
|
|
162
|
+
toArray() {
|
|
163
|
+
if (!this._supportsReadPixels) throw new Error("Can't read pixels in this browser");
|
|
164
|
+
const out = getBufferForType(this._type, this._width, this._height);
|
|
165
|
+
this._renderer.readRenderTargetPixels(this._renderTarget, 0, 0, this._width, this._height, out);
|
|
166
|
+
return out;
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Performs a readPixel operation in the renderTarget
|
|
170
|
+
* and returns a DataTexture containing the read data
|
|
171
|
+
*
|
|
172
|
+
* @param options options
|
|
173
|
+
* @returns
|
|
174
|
+
*/
|
|
175
|
+
toDataTexture(options) {
|
|
176
|
+
const returnValue = new DataTexture(this.toArray(), this.width, this.height, RGBAFormat, this._type, (options === null || options === void 0 ? void 0 : options.mapping) || UVMapping, (options === null || options === void 0 ? void 0 : options.wrapS) || ClampToEdgeWrapping, (options === null || options === void 0 ? void 0 : options.wrapT) || ClampToEdgeWrapping, (options === null || options === void 0 ? void 0 : options.magFilter) || LinearFilter, (options === null || options === void 0 ? void 0 : options.minFilter) || LinearFilter, (options === null || options === void 0 ? void 0 : options.anisotropy) || 1, LinearSRGBColorSpace);
|
|
177
|
+
returnValue.generateMipmaps = (options === null || options === void 0 ? void 0 : options.generateMipmaps) !== void 0 ? options === null || options === void 0 ? void 0 : options.generateMipmaps : false;
|
|
178
|
+
return returnValue;
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* If using a disposable renderer, it will dispose it.
|
|
182
|
+
*/
|
|
183
|
+
disposeOnDemandRenderer() {
|
|
184
|
+
this._renderer.setRenderTarget(null);
|
|
185
|
+
if (this._rendererIsDisposable) {
|
|
186
|
+
this._renderer.dispose();
|
|
187
|
+
this._renderer.forceContextLoss();
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Will dispose of **all** assets used by this renderer.
|
|
192
|
+
*
|
|
193
|
+
*
|
|
194
|
+
* @param disposeRenderTarget will dispose of the renderTarget which will not be usable later
|
|
195
|
+
* set this to true if you passed the `renderTarget.texture` to a `PMREMGenerator`
|
|
196
|
+
* or are otherwise done with it.
|
|
197
|
+
*
|
|
198
|
+
* @example
|
|
199
|
+
* ```js
|
|
200
|
+
* const loader = new HDRJPGLoader(renderer)
|
|
201
|
+
* const result = await loader.loadAsync('gainmap.jpeg')
|
|
202
|
+
* const mesh = new Mesh(geometry, new MeshBasicMaterial({ map: result.renderTarget.texture }) )
|
|
203
|
+
* // DO NOT dispose the renderTarget here,
|
|
204
|
+
* // it is used directly in the material
|
|
205
|
+
* result.dispose()
|
|
206
|
+
* ```
|
|
207
|
+
*
|
|
208
|
+
* @example
|
|
209
|
+
* ```js
|
|
210
|
+
* const loader = new HDRJPGLoader(renderer)
|
|
211
|
+
* const pmremGenerator = new PMREMGenerator( renderer );
|
|
212
|
+
* const result = await loader.loadAsync('gainmap.jpeg')
|
|
213
|
+
* const envMap = pmremGenerator.fromEquirectangular(result.renderTarget.texture)
|
|
214
|
+
* const mesh = new Mesh(geometry, new MeshStandardMaterial({ envMap }) )
|
|
215
|
+
* // renderTarget can be disposed here
|
|
216
|
+
* // because it was used to generate a PMREM texture
|
|
217
|
+
* result.dispose(true)
|
|
218
|
+
* ```
|
|
219
|
+
*/
|
|
220
|
+
dispose(disposeRenderTarget) {
|
|
221
|
+
this.disposeOnDemandRenderer();
|
|
222
|
+
if (disposeRenderTarget) this.renderTarget.dispose();
|
|
223
|
+
if (this.material instanceof ShaderMaterial) Object.values(this.material.uniforms).forEach((v) => {
|
|
224
|
+
if (v.value instanceof Texture) v.value.dispose();
|
|
225
|
+
});
|
|
226
|
+
Object.values(this.material).forEach((value) => {
|
|
227
|
+
if (value instanceof Texture) value.dispose();
|
|
228
|
+
});
|
|
229
|
+
this.material.dispose();
|
|
230
|
+
this._quad.geometry.dispose();
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* Width of the texture
|
|
234
|
+
*/
|
|
235
|
+
get width() {
|
|
236
|
+
return this._width;
|
|
237
|
+
}
|
|
238
|
+
set width(value) {
|
|
239
|
+
this._width = value;
|
|
240
|
+
this._renderTarget.setSize(this._width, this._height);
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* Height of the texture
|
|
244
|
+
*/
|
|
245
|
+
get height() {
|
|
246
|
+
return this._height;
|
|
247
|
+
}
|
|
248
|
+
set height(value) {
|
|
249
|
+
this._height = value;
|
|
250
|
+
this._renderTarget.setSize(this._width, this._height);
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* The renderer used
|
|
254
|
+
*/
|
|
255
|
+
get renderer() {
|
|
256
|
+
return this._renderer;
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* The `WebGLRenderTarget` used.
|
|
260
|
+
*/
|
|
261
|
+
get renderTarget() {
|
|
262
|
+
return this._renderTarget;
|
|
263
|
+
}
|
|
264
|
+
set renderTarget(value) {
|
|
265
|
+
this._renderTarget = value;
|
|
266
|
+
this._width = value.width;
|
|
267
|
+
this._height = value.height;
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* The `Material` used.
|
|
271
|
+
*/
|
|
272
|
+
get material() {
|
|
273
|
+
return this._material;
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
*
|
|
277
|
+
*/
|
|
278
|
+
get type() {
|
|
279
|
+
return this._type;
|
|
280
|
+
}
|
|
281
|
+
get colorSpace() {
|
|
282
|
+
return this._colorSpace;
|
|
283
|
+
}
|
|
284
|
+
};
|
|
285
|
+
|
|
286
|
+
//#endregion
|
|
287
|
+
//#region node_modules/@monogrid/gainmap-js/dist/decode.js
|
|
288
|
+
/**
|
|
289
|
+
* @monogrid/gainmap-js v3.0.6
|
|
290
|
+
* With ❤️, by MONOGRID <rnd@monogrid.com>
|
|
291
|
+
*/
|
|
292
|
+
const vertexShader = `
|
|
293
|
+
varying vec2 vUv;
|
|
294
|
+
|
|
295
|
+
void main() {
|
|
296
|
+
vUv = uv;
|
|
297
|
+
gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
|
|
298
|
+
}
|
|
299
|
+
`;
|
|
300
|
+
const fragmentShader = `
|
|
301
|
+
// min half float value
|
|
302
|
+
#define HALF_FLOAT_MIN vec3( -65504, -65504, -65504 )
|
|
303
|
+
// max half float value
|
|
304
|
+
#define HALF_FLOAT_MAX vec3( 65504, 65504, 65504 )
|
|
305
|
+
|
|
306
|
+
uniform sampler2D sdr;
|
|
307
|
+
uniform sampler2D gainMap;
|
|
308
|
+
uniform vec3 gamma;
|
|
309
|
+
uniform vec3 offsetHdr;
|
|
310
|
+
uniform vec3 offsetSdr;
|
|
311
|
+
uniform vec3 gainMapMin;
|
|
312
|
+
uniform vec3 gainMapMax;
|
|
313
|
+
uniform float weightFactor;
|
|
314
|
+
|
|
315
|
+
varying vec2 vUv;
|
|
316
|
+
|
|
317
|
+
void main() {
|
|
318
|
+
vec3 rgb = texture2D( sdr, vUv ).rgb;
|
|
319
|
+
vec3 recovery = texture2D( gainMap, vUv ).rgb;
|
|
320
|
+
vec3 logRecovery = pow( recovery, gamma );
|
|
321
|
+
vec3 logBoost = gainMapMin * ( 1.0 - logRecovery ) + gainMapMax * logRecovery;
|
|
322
|
+
vec3 hdrColor = (rgb + offsetSdr) * exp2( logBoost * weightFactor ) - offsetHdr;
|
|
323
|
+
vec3 clampedHdrColor = max( HALF_FLOAT_MIN, min( HALF_FLOAT_MAX, hdrColor ));
|
|
324
|
+
gl_FragColor = vec4( clampedHdrColor , 1.0 );
|
|
325
|
+
}
|
|
326
|
+
`;
|
|
327
|
+
/**
|
|
328
|
+
* A Material which is able to decode the Gainmap into a full HDR Representation
|
|
329
|
+
*
|
|
330
|
+
* @category Materials
|
|
331
|
+
* @group Materials
|
|
332
|
+
*/
|
|
333
|
+
var GainMapDecoderMaterial = class extends ShaderMaterial {
|
|
334
|
+
/**
|
|
335
|
+
*
|
|
336
|
+
* @param params
|
|
337
|
+
*/
|
|
338
|
+
constructor({ gamma, offsetHdr, offsetSdr, gainMapMin, gainMapMax, maxDisplayBoost, hdrCapacityMin, hdrCapacityMax, sdr, gainMap }) {
|
|
339
|
+
super({
|
|
340
|
+
name: "GainMapDecoderMaterial",
|
|
341
|
+
vertexShader,
|
|
342
|
+
fragmentShader,
|
|
343
|
+
uniforms: {
|
|
344
|
+
sdr: { value: sdr },
|
|
345
|
+
gainMap: { value: gainMap },
|
|
346
|
+
gamma: { value: new Vector3(1 / gamma[0], 1 / gamma[1], 1 / gamma[2]) },
|
|
347
|
+
offsetHdr: { value: new Vector3().fromArray(offsetHdr) },
|
|
348
|
+
offsetSdr: { value: new Vector3().fromArray(offsetSdr) },
|
|
349
|
+
gainMapMin: { value: new Vector3().fromArray(gainMapMin) },
|
|
350
|
+
gainMapMax: { value: new Vector3().fromArray(gainMapMax) },
|
|
351
|
+
weightFactor: { value: (Math.log2(maxDisplayBoost) - hdrCapacityMin) / (hdrCapacityMax - hdrCapacityMin) }
|
|
352
|
+
},
|
|
353
|
+
blending: NoBlending,
|
|
354
|
+
depthTest: false,
|
|
355
|
+
depthWrite: false
|
|
356
|
+
});
|
|
357
|
+
this._maxDisplayBoost = maxDisplayBoost;
|
|
358
|
+
this._hdrCapacityMin = hdrCapacityMin;
|
|
359
|
+
this._hdrCapacityMax = hdrCapacityMax;
|
|
360
|
+
this.needsUpdate = true;
|
|
361
|
+
this.uniformsNeedUpdate = true;
|
|
362
|
+
}
|
|
363
|
+
get sdr() {
|
|
364
|
+
return this.uniforms.sdr.value;
|
|
365
|
+
}
|
|
366
|
+
set sdr(value) {
|
|
367
|
+
this.uniforms.sdr.value = value;
|
|
368
|
+
}
|
|
369
|
+
get gainMap() {
|
|
370
|
+
return this.uniforms.gainMap.value;
|
|
371
|
+
}
|
|
372
|
+
set gainMap(value) {
|
|
373
|
+
this.uniforms.gainMap.value = value;
|
|
374
|
+
}
|
|
375
|
+
/**
|
|
376
|
+
* @see {@link GainMapMetadata.offsetHdr}
|
|
377
|
+
*/
|
|
378
|
+
get offsetHdr() {
|
|
379
|
+
return this.uniforms.offsetHdr.value.toArray();
|
|
380
|
+
}
|
|
381
|
+
set offsetHdr(value) {
|
|
382
|
+
this.uniforms.offsetHdr.value.fromArray(value);
|
|
383
|
+
}
|
|
384
|
+
/**
|
|
385
|
+
* @see {@link GainMapMetadata.offsetSdr}
|
|
386
|
+
*/
|
|
387
|
+
get offsetSdr() {
|
|
388
|
+
return this.uniforms.offsetSdr.value.toArray();
|
|
389
|
+
}
|
|
390
|
+
set offsetSdr(value) {
|
|
391
|
+
this.uniforms.offsetSdr.value.fromArray(value);
|
|
392
|
+
}
|
|
393
|
+
/**
|
|
394
|
+
* @see {@link GainMapMetadata.gainMapMin}
|
|
395
|
+
*/
|
|
396
|
+
get gainMapMin() {
|
|
397
|
+
return this.uniforms.gainMapMin.value.toArray();
|
|
398
|
+
}
|
|
399
|
+
set gainMapMin(value) {
|
|
400
|
+
this.uniforms.gainMapMin.value.fromArray(value);
|
|
401
|
+
}
|
|
402
|
+
/**
|
|
403
|
+
* @see {@link GainMapMetadata.gainMapMax}
|
|
404
|
+
*/
|
|
405
|
+
get gainMapMax() {
|
|
406
|
+
return this.uniforms.gainMapMax.value.toArray();
|
|
407
|
+
}
|
|
408
|
+
set gainMapMax(value) {
|
|
409
|
+
this.uniforms.gainMapMax.value.fromArray(value);
|
|
410
|
+
}
|
|
411
|
+
/**
|
|
412
|
+
* @see {@link GainMapMetadata.gamma}
|
|
413
|
+
*/
|
|
414
|
+
get gamma() {
|
|
415
|
+
const g = this.uniforms.gamma.value;
|
|
416
|
+
return [
|
|
417
|
+
1 / g.x,
|
|
418
|
+
1 / g.y,
|
|
419
|
+
1 / g.z
|
|
420
|
+
];
|
|
421
|
+
}
|
|
422
|
+
set gamma(value) {
|
|
423
|
+
const g = this.uniforms.gamma.value;
|
|
424
|
+
g.x = 1 / value[0];
|
|
425
|
+
g.y = 1 / value[1];
|
|
426
|
+
g.z = 1 / value[2];
|
|
427
|
+
}
|
|
428
|
+
/**
|
|
429
|
+
* @see {@link GainMapMetadata.hdrCapacityMin}
|
|
430
|
+
* @remarks Logarithmic space
|
|
431
|
+
*/
|
|
432
|
+
get hdrCapacityMin() {
|
|
433
|
+
return this._hdrCapacityMin;
|
|
434
|
+
}
|
|
435
|
+
set hdrCapacityMin(value) {
|
|
436
|
+
this._hdrCapacityMin = value;
|
|
437
|
+
this.calculateWeight();
|
|
438
|
+
}
|
|
439
|
+
/**
|
|
440
|
+
* @see {@link GainMapMetadata.hdrCapacityMin}
|
|
441
|
+
* @remarks Logarithmic space
|
|
442
|
+
*/
|
|
443
|
+
get hdrCapacityMax() {
|
|
444
|
+
return this._hdrCapacityMax;
|
|
445
|
+
}
|
|
446
|
+
set hdrCapacityMax(value) {
|
|
447
|
+
this._hdrCapacityMax = value;
|
|
448
|
+
this.calculateWeight();
|
|
449
|
+
}
|
|
450
|
+
/**
|
|
451
|
+
* @see {@link GainmapDecodingParameters.maxDisplayBoost}
|
|
452
|
+
* @remarks Non Logarithmic space
|
|
453
|
+
*/
|
|
454
|
+
get maxDisplayBoost() {
|
|
455
|
+
return this._maxDisplayBoost;
|
|
456
|
+
}
|
|
457
|
+
set maxDisplayBoost(value) {
|
|
458
|
+
this._maxDisplayBoost = Math.max(1, Math.min(65504, value));
|
|
459
|
+
this.calculateWeight();
|
|
460
|
+
}
|
|
461
|
+
calculateWeight() {
|
|
462
|
+
const val = (Math.log2(this._maxDisplayBoost) - this._hdrCapacityMin) / (this._hdrCapacityMax - this._hdrCapacityMin);
|
|
463
|
+
this.uniforms.weightFactor.value = Math.max(0, Math.min(1, val));
|
|
464
|
+
}
|
|
465
|
+
};
|
|
466
|
+
var GainMapNotFoundError = class extends Error {};
|
|
467
|
+
var XMPMetadataNotFoundError = class extends Error {};
|
|
468
|
+
const getAttribute = (description, name, defaultValue) => {
|
|
469
|
+
var _a;
|
|
470
|
+
let returnValue;
|
|
471
|
+
const parsedValue = (_a = description.attributes.getNamedItem(name)) === null || _a === void 0 ? void 0 : _a.nodeValue;
|
|
472
|
+
if (!parsedValue) {
|
|
473
|
+
const node = description.getElementsByTagName(name)[0];
|
|
474
|
+
if (node) {
|
|
475
|
+
const values = node.getElementsByTagName("rdf:li");
|
|
476
|
+
if (values.length === 3) returnValue = Array.from(values).map((v) => v.innerHTML);
|
|
477
|
+
else throw new Error(`Gainmap metadata contains an array of items for ${name} but its length is not 3`);
|
|
478
|
+
} else if (defaultValue) return defaultValue;
|
|
479
|
+
else throw new Error(`Can't find ${name} in gainmap metadata`);
|
|
480
|
+
} else returnValue = parsedValue;
|
|
481
|
+
return returnValue;
|
|
482
|
+
};
|
|
483
|
+
/**
|
|
484
|
+
*
|
|
485
|
+
* @param input
|
|
486
|
+
* @returns
|
|
487
|
+
*/
|
|
488
|
+
const extractXMP = (input) => {
|
|
489
|
+
var _a, _b;
|
|
490
|
+
let str;
|
|
491
|
+
if (typeof TextDecoder !== "undefined") str = new TextDecoder().decode(input);
|
|
492
|
+
else str = input.toString();
|
|
493
|
+
let start = str.indexOf("<x:xmpmeta");
|
|
494
|
+
const parser = new DOMParser();
|
|
495
|
+
while (start !== -1) {
|
|
496
|
+
const end = str.indexOf("x:xmpmeta>", start);
|
|
497
|
+
str.slice(start, end + 10);
|
|
498
|
+
const xmpBlock = str.slice(start, end + 10);
|
|
499
|
+
try {
|
|
500
|
+
const description = parser.parseFromString(xmpBlock, "text/xml").getElementsByTagName("rdf:Description")[0];
|
|
501
|
+
const gainMapMin = getAttribute(description, "hdrgm:GainMapMin", "0");
|
|
502
|
+
const gainMapMax = getAttribute(description, "hdrgm:GainMapMax");
|
|
503
|
+
const gamma = getAttribute(description, "hdrgm:Gamma", "1");
|
|
504
|
+
const offsetSDR = getAttribute(description, "hdrgm:OffsetSDR", "0.015625");
|
|
505
|
+
const offsetHDR = getAttribute(description, "hdrgm:OffsetHDR", "0.015625");
|
|
506
|
+
let hdrCapacityMin = (_a = description.attributes.getNamedItem("hdrgm:HDRCapacityMin")) === null || _a === void 0 ? void 0 : _a.nodeValue;
|
|
507
|
+
if (!hdrCapacityMin) hdrCapacityMin = "0";
|
|
508
|
+
const hdrCapacityMax = (_b = description.attributes.getNamedItem("hdrgm:HDRCapacityMax")) === null || _b === void 0 ? void 0 : _b.nodeValue;
|
|
509
|
+
if (!hdrCapacityMax) throw new Error("Incomplete gainmap metadata");
|
|
510
|
+
return {
|
|
511
|
+
gainMapMin: Array.isArray(gainMapMin) ? gainMapMin.map((v) => parseFloat(v)) : [
|
|
512
|
+
parseFloat(gainMapMin),
|
|
513
|
+
parseFloat(gainMapMin),
|
|
514
|
+
parseFloat(gainMapMin)
|
|
515
|
+
],
|
|
516
|
+
gainMapMax: Array.isArray(gainMapMax) ? gainMapMax.map((v) => parseFloat(v)) : [
|
|
517
|
+
parseFloat(gainMapMax),
|
|
518
|
+
parseFloat(gainMapMax),
|
|
519
|
+
parseFloat(gainMapMax)
|
|
520
|
+
],
|
|
521
|
+
gamma: Array.isArray(gamma) ? gamma.map((v) => parseFloat(v)) : [
|
|
522
|
+
parseFloat(gamma),
|
|
523
|
+
parseFloat(gamma),
|
|
524
|
+
parseFloat(gamma)
|
|
525
|
+
],
|
|
526
|
+
offsetSdr: Array.isArray(offsetSDR) ? offsetSDR.map((v) => parseFloat(v)) : [
|
|
527
|
+
parseFloat(offsetSDR),
|
|
528
|
+
parseFloat(offsetSDR),
|
|
529
|
+
parseFloat(offsetSDR)
|
|
530
|
+
],
|
|
531
|
+
offsetHdr: Array.isArray(offsetHDR) ? offsetHDR.map((v) => parseFloat(v)) : [
|
|
532
|
+
parseFloat(offsetHDR),
|
|
533
|
+
parseFloat(offsetHDR),
|
|
534
|
+
parseFloat(offsetHDR)
|
|
535
|
+
],
|
|
536
|
+
hdrCapacityMin: parseFloat(hdrCapacityMin),
|
|
537
|
+
hdrCapacityMax: parseFloat(hdrCapacityMax)
|
|
538
|
+
};
|
|
539
|
+
} catch (e) {}
|
|
540
|
+
start = str.indexOf("<x:xmpmeta", end);
|
|
541
|
+
}
|
|
542
|
+
};
|
|
543
|
+
/**
|
|
544
|
+
* MPF Extractor (Multi Picture Format Extractor)
|
|
545
|
+
* By Henrik S Nilsson 2019
|
|
546
|
+
*
|
|
547
|
+
* Extracts images stored in images based on the MPF format (found here: https://www.cipa.jp/e/std/std-sec.html
|
|
548
|
+
* under "CIPA DC-007-Translation-2021 Multi-Picture Format"
|
|
549
|
+
*
|
|
550
|
+
* Overly commented, and without intention of being complete or production ready.
|
|
551
|
+
* Created to extract depth maps from iPhone images, and to learn about image metadata.
|
|
552
|
+
* Kudos to: Phil Harvey (exiftool), Jaume Sanchez (android-lens-blur-depth-extractor)
|
|
553
|
+
*/
|
|
554
|
+
var MPFExtractor = class {
|
|
555
|
+
constructor(options) {
|
|
556
|
+
this.options = {
|
|
557
|
+
debug: options && options.debug !== void 0 ? options.debug : false,
|
|
558
|
+
extractFII: options && options.extractFII !== void 0 ? options.extractFII : true,
|
|
559
|
+
extractNonFII: options && options.extractNonFII !== void 0 ? options.extractNonFII : true
|
|
560
|
+
};
|
|
561
|
+
}
|
|
562
|
+
extract(imageArrayBuffer) {
|
|
563
|
+
return new Promise((resolve, reject) => {
|
|
564
|
+
const debug = this.options.debug;
|
|
565
|
+
const dataView = new DataView(imageArrayBuffer.buffer);
|
|
566
|
+
if (dataView.getUint16(0) !== 65496) {
|
|
567
|
+
reject(/* @__PURE__ */ new Error("Not a valid jpeg"));
|
|
568
|
+
return;
|
|
569
|
+
}
|
|
570
|
+
const length = dataView.byteLength;
|
|
571
|
+
let offset = 2;
|
|
572
|
+
let loops = 0;
|
|
573
|
+
let marker;
|
|
574
|
+
while (offset < length) {
|
|
575
|
+
if (++loops > 250) {
|
|
576
|
+
reject(/* @__PURE__ */ new Error(`Found no marker after ${loops} loops 😵`));
|
|
577
|
+
return;
|
|
578
|
+
}
|
|
579
|
+
if (dataView.getUint8(offset) !== 255) {
|
|
580
|
+
reject(/* @__PURE__ */ new Error(`Not a valid marker at offset 0x${offset.toString(16)}, found: 0x${dataView.getUint8(offset).toString(16)}`));
|
|
581
|
+
return;
|
|
582
|
+
}
|
|
583
|
+
marker = dataView.getUint8(offset + 1);
|
|
584
|
+
if (debug) console.log(`Marker: ${marker.toString(16)}`);
|
|
585
|
+
if (marker === 226) {
|
|
586
|
+
if (debug) console.log("Found APP2 marker (0xffe2)");
|
|
587
|
+
const formatPt = offset + 4;
|
|
588
|
+
if (dataView.getUint32(formatPt) === 1297106432) {
|
|
589
|
+
const tiffOffset = formatPt + 4;
|
|
590
|
+
let bigEnd;
|
|
591
|
+
if (dataView.getUint16(tiffOffset) === 18761) bigEnd = false;
|
|
592
|
+
else if (dataView.getUint16(tiffOffset) === 19789) bigEnd = true;
|
|
593
|
+
else {
|
|
594
|
+
reject(/* @__PURE__ */ new Error("No valid endianness marker found in TIFF header"));
|
|
595
|
+
return;
|
|
596
|
+
}
|
|
597
|
+
if (dataView.getUint16(tiffOffset + 2, !bigEnd) !== 42) {
|
|
598
|
+
reject(/* @__PURE__ */ new Error("Not valid TIFF data! (no 0x002A marker)"));
|
|
599
|
+
return;
|
|
600
|
+
}
|
|
601
|
+
const firstIFDOffset = dataView.getUint32(tiffOffset + 4, !bigEnd);
|
|
602
|
+
if (firstIFDOffset < 8) {
|
|
603
|
+
reject(/* @__PURE__ */ new Error("Not valid TIFF data! (First offset less than 8)"));
|
|
604
|
+
return;
|
|
605
|
+
}
|
|
606
|
+
const dirStart = tiffOffset + firstIFDOffset;
|
|
607
|
+
const count = dataView.getUint16(dirStart, !bigEnd);
|
|
608
|
+
const entriesStart = dirStart + 2;
|
|
609
|
+
let numberOfImages = 0;
|
|
610
|
+
for (let i = entriesStart; i < entriesStart + 12 * count; i += 12) if (dataView.getUint16(i, !bigEnd) === 45057) numberOfImages = dataView.getUint32(i + 8, !bigEnd);
|
|
611
|
+
const MPImageListValPt = dirStart + 2 + count * 12 + 4;
|
|
612
|
+
const images = [];
|
|
613
|
+
for (let i = MPImageListValPt; i < MPImageListValPt + numberOfImages * 16; i += 16) {
|
|
614
|
+
const image = {
|
|
615
|
+
MPType: dataView.getUint32(i, !bigEnd),
|
|
616
|
+
size: dataView.getUint32(i + 4, !bigEnd),
|
|
617
|
+
dataOffset: dataView.getUint32(i + 8, !bigEnd),
|
|
618
|
+
dependantImages: dataView.getUint32(i + 12, !bigEnd),
|
|
619
|
+
start: -1,
|
|
620
|
+
end: -1,
|
|
621
|
+
isFII: false
|
|
622
|
+
};
|
|
623
|
+
if (!image.dataOffset) {
|
|
624
|
+
image.start = 0;
|
|
625
|
+
image.isFII = true;
|
|
626
|
+
} else {
|
|
627
|
+
image.start = tiffOffset + image.dataOffset;
|
|
628
|
+
image.isFII = false;
|
|
629
|
+
}
|
|
630
|
+
image.end = image.start + image.size;
|
|
631
|
+
images.push(image);
|
|
632
|
+
}
|
|
633
|
+
if (this.options.extractNonFII && images.length) {
|
|
634
|
+
const bufferBlob = new Blob([dataView]);
|
|
635
|
+
const imgs = [];
|
|
636
|
+
for (const image of images) {
|
|
637
|
+
if (image.isFII && !this.options.extractFII) continue;
|
|
638
|
+
const imageBlob = bufferBlob.slice(image.start, image.end + 1, "image/jpeg");
|
|
639
|
+
imgs.push(imageBlob);
|
|
640
|
+
}
|
|
641
|
+
resolve(imgs);
|
|
642
|
+
}
|
|
643
|
+
}
|
|
644
|
+
}
|
|
645
|
+
offset += 2 + dataView.getUint16(offset + 2);
|
|
646
|
+
}
|
|
647
|
+
});
|
|
648
|
+
}
|
|
649
|
+
};
|
|
650
|
+
/**
|
|
651
|
+
* Extracts XMP Metadata and the gain map recovery image
|
|
652
|
+
* from a single JPEG file.
|
|
653
|
+
*
|
|
654
|
+
* @category Decoding Functions
|
|
655
|
+
* @group Decoding Functions
|
|
656
|
+
* @param jpegFile an `Uint8Array` containing and encoded JPEG file
|
|
657
|
+
* @returns an sdr `Uint8Array` compressed in JPEG, a gainMap `Uint8Array` compressed in JPEG and the XMP parsed XMP metadata
|
|
658
|
+
* @throws Error if XMP Metadata is not found
|
|
659
|
+
* @throws Error if Gain map image is not found
|
|
660
|
+
* @example
|
|
661
|
+
* import { FileLoader } from 'three'
|
|
662
|
+
* import { extractGainmapFromJPEG } from '@monogrid/gainmap-js'
|
|
663
|
+
*
|
|
664
|
+
* const jpegFile = await new FileLoader()
|
|
665
|
+
* .setResponseType('arraybuffer')
|
|
666
|
+
* .loadAsync('image.jpg')
|
|
667
|
+
*
|
|
668
|
+
* const { sdr, gainMap, metadata } = extractGainmapFromJPEG(jpegFile)
|
|
669
|
+
*/
|
|
670
|
+
const extractGainmapFromJPEG = async (jpegFile) => {
|
|
671
|
+
const metadata = extractXMP(jpegFile);
|
|
672
|
+
if (!metadata) throw new XMPMetadataNotFoundError("Gain map XMP metadata not found");
|
|
673
|
+
const images = await new MPFExtractor({
|
|
674
|
+
extractFII: true,
|
|
675
|
+
extractNonFII: true
|
|
676
|
+
}).extract(jpegFile);
|
|
677
|
+
if (images.length !== 2) throw new GainMapNotFoundError("Gain map recovery image not found");
|
|
678
|
+
return {
|
|
679
|
+
sdr: new Uint8Array(await images[0].arrayBuffer()),
|
|
680
|
+
gainMap: new Uint8Array(await images[1].arrayBuffer()),
|
|
681
|
+
metadata
|
|
682
|
+
};
|
|
683
|
+
};
|
|
684
|
+
/**
|
|
685
|
+
* private function, async get image from blob
|
|
686
|
+
*
|
|
687
|
+
* @param blob
|
|
688
|
+
* @returns
|
|
689
|
+
*/
|
|
690
|
+
const getHTMLImageFromBlob = (blob) => {
|
|
691
|
+
return new Promise((resolve, reject) => {
|
|
692
|
+
const img = document.createElement("img");
|
|
693
|
+
img.onload = () => {
|
|
694
|
+
resolve(img);
|
|
695
|
+
};
|
|
696
|
+
img.onerror = (e) => {
|
|
697
|
+
reject(e);
|
|
698
|
+
};
|
|
699
|
+
img.src = URL.createObjectURL(blob);
|
|
700
|
+
});
|
|
701
|
+
};
|
|
702
|
+
var LoaderBase = class extends Loader {
|
|
703
|
+
/**
|
|
704
|
+
*
|
|
705
|
+
* @param renderer
|
|
706
|
+
* @param manager
|
|
707
|
+
*/
|
|
708
|
+
constructor(renderer, manager) {
|
|
709
|
+
super(manager);
|
|
710
|
+
if (renderer) this._renderer = renderer;
|
|
711
|
+
this._internalLoadingManager = new LoadingManager();
|
|
712
|
+
}
|
|
713
|
+
/**
|
|
714
|
+
* Specify the renderer to use when rendering the gain map
|
|
715
|
+
*
|
|
716
|
+
* @param renderer
|
|
717
|
+
* @returns
|
|
718
|
+
*/
|
|
719
|
+
setRenderer(renderer) {
|
|
720
|
+
this._renderer = renderer;
|
|
721
|
+
return this;
|
|
722
|
+
}
|
|
723
|
+
/**
|
|
724
|
+
* Specify the renderTarget options to use when rendering the gain map
|
|
725
|
+
*
|
|
726
|
+
* @param options
|
|
727
|
+
* @returns
|
|
728
|
+
*/
|
|
729
|
+
setRenderTargetOptions(options) {
|
|
730
|
+
this._renderTargetOptions = options;
|
|
731
|
+
return this;
|
|
732
|
+
}
|
|
733
|
+
/**
|
|
734
|
+
* @private
|
|
735
|
+
* @returns
|
|
736
|
+
*/
|
|
737
|
+
prepareQuadRenderer() {
|
|
738
|
+
if (!this._renderer) console.warn("WARNING: An existing WebGL Renderer was not passed to this Loader constructor or in setRenderer, the result of this Loader will need to be converted to a Data Texture with toDataTexture() before you can use it in your renderer.");
|
|
739
|
+
return new QuadRenderer({
|
|
740
|
+
width: 16,
|
|
741
|
+
height: 16,
|
|
742
|
+
type: HalfFloatType,
|
|
743
|
+
colorSpace: LinearSRGBColorSpace,
|
|
744
|
+
material: new GainMapDecoderMaterial({
|
|
745
|
+
gainMapMax: [
|
|
746
|
+
1,
|
|
747
|
+
1,
|
|
748
|
+
1
|
|
749
|
+
],
|
|
750
|
+
gainMapMin: [
|
|
751
|
+
0,
|
|
752
|
+
0,
|
|
753
|
+
0
|
|
754
|
+
],
|
|
755
|
+
gamma: [
|
|
756
|
+
1,
|
|
757
|
+
1,
|
|
758
|
+
1
|
|
759
|
+
],
|
|
760
|
+
offsetHdr: [
|
|
761
|
+
1,
|
|
762
|
+
1,
|
|
763
|
+
1
|
|
764
|
+
],
|
|
765
|
+
offsetSdr: [
|
|
766
|
+
1,
|
|
767
|
+
1,
|
|
768
|
+
1
|
|
769
|
+
],
|
|
770
|
+
hdrCapacityMax: 1,
|
|
771
|
+
hdrCapacityMin: 0,
|
|
772
|
+
maxDisplayBoost: 1,
|
|
773
|
+
gainMap: new Texture(),
|
|
774
|
+
sdr: new Texture()
|
|
775
|
+
}),
|
|
776
|
+
renderer: this._renderer,
|
|
777
|
+
renderTargetOptions: this._renderTargetOptions
|
|
778
|
+
});
|
|
779
|
+
}
|
|
780
|
+
/**
|
|
781
|
+
* @private
|
|
782
|
+
* @param quadRenderer
|
|
783
|
+
* @param metadata
|
|
784
|
+
* @param sdrBuffer
|
|
785
|
+
* @param gainMapBuffer
|
|
786
|
+
*/
|
|
787
|
+
async render(quadRenderer, metadata, sdrBuffer, gainMapBuffer) {
|
|
788
|
+
const gainMapBlob = gainMapBuffer ? new Blob([gainMapBuffer], { type: "image/jpeg" }) : void 0;
|
|
789
|
+
const sdrBlob = new Blob([sdrBuffer], { type: "image/jpeg" });
|
|
790
|
+
let sdrImage;
|
|
791
|
+
let gainMapImage;
|
|
792
|
+
let needsFlip = false;
|
|
793
|
+
if (typeof createImageBitmap === "undefined") {
|
|
794
|
+
const res = await Promise.all([gainMapBlob ? getHTMLImageFromBlob(gainMapBlob) : Promise.resolve(void 0), getHTMLImageFromBlob(sdrBlob)]);
|
|
795
|
+
gainMapImage = res[0];
|
|
796
|
+
sdrImage = res[1];
|
|
797
|
+
needsFlip = true;
|
|
798
|
+
} else {
|
|
799
|
+
const res = await Promise.all([gainMapBlob ? createImageBitmap(gainMapBlob, { imageOrientation: "flipY" }) : Promise.resolve(void 0), createImageBitmap(sdrBlob, { imageOrientation: "flipY" })]);
|
|
800
|
+
gainMapImage = res[0];
|
|
801
|
+
sdrImage = res[1];
|
|
802
|
+
}
|
|
803
|
+
const gainMap = new Texture(gainMapImage || new ImageData(2, 2), UVMapping, ClampToEdgeWrapping, ClampToEdgeWrapping, LinearFilter, LinearMipMapLinearFilter, RGBAFormat, UnsignedByteType, 1, LinearSRGBColorSpace);
|
|
804
|
+
gainMap.flipY = needsFlip;
|
|
805
|
+
gainMap.needsUpdate = true;
|
|
806
|
+
const sdr = new Texture(sdrImage, UVMapping, ClampToEdgeWrapping, ClampToEdgeWrapping, LinearFilter, LinearMipMapLinearFilter, RGBAFormat, UnsignedByteType, 1, SRGBColorSpace);
|
|
807
|
+
sdr.flipY = needsFlip;
|
|
808
|
+
sdr.needsUpdate = true;
|
|
809
|
+
quadRenderer.width = sdrImage.width;
|
|
810
|
+
quadRenderer.height = sdrImage.height;
|
|
811
|
+
quadRenderer.material.gainMap = gainMap;
|
|
812
|
+
quadRenderer.material.sdr = sdr;
|
|
813
|
+
quadRenderer.material.gainMapMin = metadata.gainMapMin;
|
|
814
|
+
quadRenderer.material.gainMapMax = metadata.gainMapMax;
|
|
815
|
+
quadRenderer.material.offsetHdr = metadata.offsetHdr;
|
|
816
|
+
quadRenderer.material.offsetSdr = metadata.offsetSdr;
|
|
817
|
+
quadRenderer.material.gamma = metadata.gamma;
|
|
818
|
+
quadRenderer.material.hdrCapacityMin = metadata.hdrCapacityMin;
|
|
819
|
+
quadRenderer.material.hdrCapacityMax = metadata.hdrCapacityMax;
|
|
820
|
+
quadRenderer.material.maxDisplayBoost = Math.pow(2, metadata.hdrCapacityMax);
|
|
821
|
+
quadRenderer.material.needsUpdate = true;
|
|
822
|
+
quadRenderer.render();
|
|
823
|
+
}
|
|
824
|
+
};
|
|
825
|
+
/**
|
|
826
|
+
* A Three.js Loader for the gain map format.
|
|
827
|
+
*
|
|
828
|
+
* @category Loaders
|
|
829
|
+
* @group Loaders
|
|
830
|
+
*
|
|
831
|
+
* @example
|
|
832
|
+
* import { GainMapLoader } from '@monogrid/gainmap-js'
|
|
833
|
+
* import {
|
|
834
|
+
* EquirectangularReflectionMapping,
|
|
835
|
+
* LinearFilter,
|
|
836
|
+
* Mesh,
|
|
837
|
+
* MeshBasicMaterial,
|
|
838
|
+
* PerspectiveCamera,
|
|
839
|
+
* PlaneGeometry,
|
|
840
|
+
* Scene,
|
|
841
|
+
* WebGLRenderer
|
|
842
|
+
* } from 'three'
|
|
843
|
+
*
|
|
844
|
+
* const renderer = new WebGLRenderer()
|
|
845
|
+
*
|
|
846
|
+
* const loader = new GainMapLoader(renderer)
|
|
847
|
+
*
|
|
848
|
+
* const result = await loader.loadAsync(['sdr.jpeg', 'gainmap.jpeg', 'metadata.json'])
|
|
849
|
+
* // `result` can be used to populate a Texture
|
|
850
|
+
*
|
|
851
|
+
* const scene = new Scene()
|
|
852
|
+
* const mesh = new Mesh(
|
|
853
|
+
* new PlaneGeometry(),
|
|
854
|
+
* new MeshBasicMaterial({ map: result.renderTarget.texture })
|
|
855
|
+
* )
|
|
856
|
+
* scene.add(mesh)
|
|
857
|
+
* renderer.render(scene, new PerspectiveCamera())
|
|
858
|
+
*
|
|
859
|
+
* // Starting from three.js r159
|
|
860
|
+
* // `result.renderTarget.texture` can
|
|
861
|
+
* // also be used as Equirectangular scene background
|
|
862
|
+
* //
|
|
863
|
+
* // it was previously needed to convert it
|
|
864
|
+
* // to a DataTexture with `result.toDataTexture()`
|
|
865
|
+
* scene.background = result.renderTarget.texture
|
|
866
|
+
* scene.background.mapping = EquirectangularReflectionMapping
|
|
867
|
+
*
|
|
868
|
+
* // result must be manually disposed
|
|
869
|
+
* // when you are done using it
|
|
870
|
+
* result.dispose()
|
|
871
|
+
*
|
|
872
|
+
*/
|
|
873
|
+
var GainMapLoader = class extends LoaderBase {
|
|
874
|
+
/**
|
|
875
|
+
* Loads a gainmap using separate data
|
|
876
|
+
* * sdr image
|
|
877
|
+
* * gain map image
|
|
878
|
+
* * metadata json
|
|
879
|
+
*
|
|
880
|
+
* useful for webp gain maps
|
|
881
|
+
*
|
|
882
|
+
* @param urls An array in the form of [sdr.jpg, gainmap.jpg, metadata.json]
|
|
883
|
+
* @param onLoad Load complete callback, will receive the result
|
|
884
|
+
* @param onProgress Progress callback, will receive a {@link ProgressEvent}
|
|
885
|
+
* @param onError Error callback
|
|
886
|
+
* @returns
|
|
887
|
+
*/
|
|
888
|
+
load([sdrUrl, gainMapUrl, metadataUrl], onLoad, onProgress, onError) {
|
|
889
|
+
const quadRenderer = this.prepareQuadRenderer();
|
|
890
|
+
let sdr;
|
|
891
|
+
let gainMap;
|
|
892
|
+
let metadata;
|
|
893
|
+
const loadCheck = async () => {
|
|
894
|
+
if (sdr && gainMap && metadata) {
|
|
895
|
+
try {
|
|
896
|
+
await this.render(quadRenderer, metadata, sdr, gainMap);
|
|
897
|
+
} catch (error) {
|
|
898
|
+
this.manager.itemError(sdrUrl);
|
|
899
|
+
this.manager.itemError(gainMapUrl);
|
|
900
|
+
this.manager.itemError(metadataUrl);
|
|
901
|
+
if (typeof onError === "function") onError(error);
|
|
902
|
+
quadRenderer.disposeOnDemandRenderer();
|
|
903
|
+
return;
|
|
904
|
+
}
|
|
905
|
+
if (typeof onLoad === "function") onLoad(quadRenderer);
|
|
906
|
+
this.manager.itemEnd(sdrUrl);
|
|
907
|
+
this.manager.itemEnd(gainMapUrl);
|
|
908
|
+
this.manager.itemEnd(metadataUrl);
|
|
909
|
+
quadRenderer.disposeOnDemandRenderer();
|
|
910
|
+
}
|
|
911
|
+
};
|
|
912
|
+
let sdrLengthComputable = true;
|
|
913
|
+
let sdrTotal = 0;
|
|
914
|
+
let sdrLoaded = 0;
|
|
915
|
+
let gainMapLengthComputable = true;
|
|
916
|
+
let gainMapTotal = 0;
|
|
917
|
+
let gainMapLoaded = 0;
|
|
918
|
+
let metadataLengthComputable = true;
|
|
919
|
+
let metadataTotal = 0;
|
|
920
|
+
let metadataLoaded = 0;
|
|
921
|
+
const progressHandler = () => {
|
|
922
|
+
if (typeof onProgress === "function") {
|
|
923
|
+
const total = sdrTotal + gainMapTotal + metadataTotal;
|
|
924
|
+
const loaded = sdrLoaded + gainMapLoaded + metadataLoaded;
|
|
925
|
+
const lengthComputable = sdrLengthComputable && gainMapLengthComputable && metadataLengthComputable;
|
|
926
|
+
onProgress(new ProgressEvent("progress", {
|
|
927
|
+
lengthComputable,
|
|
928
|
+
loaded,
|
|
929
|
+
total
|
|
930
|
+
}));
|
|
931
|
+
}
|
|
932
|
+
};
|
|
933
|
+
this.manager.itemStart(sdrUrl);
|
|
934
|
+
this.manager.itemStart(gainMapUrl);
|
|
935
|
+
this.manager.itemStart(metadataUrl);
|
|
936
|
+
const sdrLoader = new FileLoader(this._internalLoadingManager);
|
|
937
|
+
sdrLoader.setResponseType("arraybuffer");
|
|
938
|
+
sdrLoader.setRequestHeader(this.requestHeader);
|
|
939
|
+
sdrLoader.setPath(this.path);
|
|
940
|
+
sdrLoader.setWithCredentials(this.withCredentials);
|
|
941
|
+
sdrLoader.load(sdrUrl, async (buffer) => {
|
|
942
|
+
/* istanbul ignore if
|
|
943
|
+
this condition exists only because of three.js types + strict mode
|
|
944
|
+
*/
|
|
945
|
+
if (typeof buffer === "string") throw new Error("Invalid sdr buffer");
|
|
946
|
+
sdr = buffer;
|
|
947
|
+
await loadCheck();
|
|
948
|
+
}, (e) => {
|
|
949
|
+
sdrLengthComputable = e.lengthComputable;
|
|
950
|
+
sdrLoaded = e.loaded;
|
|
951
|
+
sdrTotal = e.total;
|
|
952
|
+
progressHandler();
|
|
953
|
+
}, (error) => {
|
|
954
|
+
this.manager.itemError(sdrUrl);
|
|
955
|
+
if (typeof onError === "function") onError(error);
|
|
956
|
+
});
|
|
957
|
+
const gainMapLoader = new FileLoader(this._internalLoadingManager);
|
|
958
|
+
gainMapLoader.setResponseType("arraybuffer");
|
|
959
|
+
gainMapLoader.setRequestHeader(this.requestHeader);
|
|
960
|
+
gainMapLoader.setPath(this.path);
|
|
961
|
+
gainMapLoader.setWithCredentials(this.withCredentials);
|
|
962
|
+
gainMapLoader.load(gainMapUrl, async (buffer) => {
|
|
963
|
+
/* istanbul ignore if
|
|
964
|
+
this condition exists only because of three.js types + strict mode
|
|
965
|
+
*/
|
|
966
|
+
if (typeof buffer === "string") throw new Error("Invalid gainmap buffer");
|
|
967
|
+
gainMap = buffer;
|
|
968
|
+
await loadCheck();
|
|
969
|
+
}, (e) => {
|
|
970
|
+
gainMapLengthComputable = e.lengthComputable;
|
|
971
|
+
gainMapLoaded = e.loaded;
|
|
972
|
+
gainMapTotal = e.total;
|
|
973
|
+
progressHandler();
|
|
974
|
+
}, (error) => {
|
|
975
|
+
this.manager.itemError(gainMapUrl);
|
|
976
|
+
if (typeof onError === "function") onError(error);
|
|
977
|
+
});
|
|
978
|
+
const metadataLoader = new FileLoader(this._internalLoadingManager);
|
|
979
|
+
metadataLoader.setRequestHeader(this.requestHeader);
|
|
980
|
+
metadataLoader.setPath(this.path);
|
|
981
|
+
metadataLoader.setWithCredentials(this.withCredentials);
|
|
982
|
+
metadataLoader.load(metadataUrl, async (json) => {
|
|
983
|
+
/* istanbul ignore if
|
|
984
|
+
this condition exists only because of three.js types + strict mode
|
|
985
|
+
*/
|
|
986
|
+
if (typeof json !== "string") throw new Error("Invalid metadata string");
|
|
987
|
+
metadata = JSON.parse(json);
|
|
988
|
+
await loadCheck();
|
|
989
|
+
}, (e) => {
|
|
990
|
+
metadataLengthComputable = e.lengthComputable;
|
|
991
|
+
metadataLoaded = e.loaded;
|
|
992
|
+
metadataTotal = e.total;
|
|
993
|
+
progressHandler();
|
|
994
|
+
}, (error) => {
|
|
995
|
+
this.manager.itemError(metadataUrl);
|
|
996
|
+
if (typeof onError === "function") onError(error);
|
|
997
|
+
});
|
|
998
|
+
return quadRenderer;
|
|
999
|
+
}
|
|
1000
|
+
};
|
|
1001
|
+
/**
|
|
1002
|
+
* A Three.js Loader for a JPEG with embedded gainmap metadata.
|
|
1003
|
+
*
|
|
1004
|
+
* @category Loaders
|
|
1005
|
+
* @group Loaders
|
|
1006
|
+
*
|
|
1007
|
+
* @example
|
|
1008
|
+
* import { HDRJPGLoader } from '@monogrid/gainmap-js'
|
|
1009
|
+
* import {
|
|
1010
|
+
* EquirectangularReflectionMapping,
|
|
1011
|
+
* LinearFilter,
|
|
1012
|
+
* Mesh,
|
|
1013
|
+
* MeshBasicMaterial,
|
|
1014
|
+
* PerspectiveCamera,
|
|
1015
|
+
* PlaneGeometry,
|
|
1016
|
+
* Scene,
|
|
1017
|
+
* WebGLRenderer
|
|
1018
|
+
* } from 'three'
|
|
1019
|
+
*
|
|
1020
|
+
* const renderer = new WebGLRenderer()
|
|
1021
|
+
*
|
|
1022
|
+
* const loader = new HDRJPGLoader(renderer)
|
|
1023
|
+
*
|
|
1024
|
+
* const result = await loader.loadAsync('gainmap.jpeg')
|
|
1025
|
+
* // `result` can be used to populate a Texture
|
|
1026
|
+
*
|
|
1027
|
+
* const scene = new Scene()
|
|
1028
|
+
* const mesh = new Mesh(
|
|
1029
|
+
* new PlaneGeometry(),
|
|
1030
|
+
* new MeshBasicMaterial({ map: result.renderTarget.texture })
|
|
1031
|
+
* )
|
|
1032
|
+
* scene.add(mesh)
|
|
1033
|
+
* renderer.render(scene, new PerspectiveCamera())
|
|
1034
|
+
*
|
|
1035
|
+
* // Starting from three.js r159
|
|
1036
|
+
* // `result.renderTarget.texture` can
|
|
1037
|
+
* // also be used as Equirectangular scene background
|
|
1038
|
+
* //
|
|
1039
|
+
* // it was previously needed to convert it
|
|
1040
|
+
* // to a DataTexture with `result.toDataTexture()`
|
|
1041
|
+
* scene.background = result.renderTarget.texture
|
|
1042
|
+
* scene.background.mapping = EquirectangularReflectionMapping
|
|
1043
|
+
*
|
|
1044
|
+
* // result must be manually disposed
|
|
1045
|
+
* // when you are done using it
|
|
1046
|
+
* result.dispose()
|
|
1047
|
+
*
|
|
1048
|
+
*/
|
|
1049
|
+
var HDRJPGLoader = class extends LoaderBase {
|
|
1050
|
+
/**
|
|
1051
|
+
* Loads a JPEG containing gain map metadata
|
|
1052
|
+
* Renders a normal SDR image if gainmap data is not found
|
|
1053
|
+
*
|
|
1054
|
+
* @param url An array in the form of [sdr.jpg, gainmap.jpg, metadata.json]
|
|
1055
|
+
* @param onLoad Load complete callback, will receive the result
|
|
1056
|
+
* @param onProgress Progress callback, will receive a {@link ProgressEvent}
|
|
1057
|
+
* @param onError Error callback
|
|
1058
|
+
* @returns
|
|
1059
|
+
*/
|
|
1060
|
+
load(url, onLoad, onProgress, onError) {
|
|
1061
|
+
const quadRenderer = this.prepareQuadRenderer();
|
|
1062
|
+
const loader = new FileLoader(this._internalLoadingManager);
|
|
1063
|
+
loader.setResponseType("arraybuffer");
|
|
1064
|
+
loader.setRequestHeader(this.requestHeader);
|
|
1065
|
+
loader.setPath(this.path);
|
|
1066
|
+
loader.setWithCredentials(this.withCredentials);
|
|
1067
|
+
this.manager.itemStart(url);
|
|
1068
|
+
loader.load(url, async (jpeg) => {
|
|
1069
|
+
/* istanbul ignore if
|
|
1070
|
+
this condition exists only because of three.js types + strict mode
|
|
1071
|
+
*/
|
|
1072
|
+
if (typeof jpeg === "string") throw new Error("Invalid buffer, received [string], was expecting [ArrayBuffer]");
|
|
1073
|
+
const jpegBuffer = new Uint8Array(jpeg);
|
|
1074
|
+
let sdrJPEG;
|
|
1075
|
+
let gainMapJPEG;
|
|
1076
|
+
let metadata;
|
|
1077
|
+
try {
|
|
1078
|
+
const extractionResult = await extractGainmapFromJPEG(jpegBuffer);
|
|
1079
|
+
sdrJPEG = extractionResult.sdr;
|
|
1080
|
+
gainMapJPEG = extractionResult.gainMap;
|
|
1081
|
+
metadata = extractionResult.metadata;
|
|
1082
|
+
} catch (e) {
|
|
1083
|
+
if (e instanceof XMPMetadataNotFoundError || e instanceof GainMapNotFoundError) {
|
|
1084
|
+
console.warn(`Failure to reconstruct an HDR image from ${url}: Gain map metadata not found in the file, HDRJPGLoader will render the SDR jpeg`);
|
|
1085
|
+
metadata = {
|
|
1086
|
+
gainMapMin: [
|
|
1087
|
+
0,
|
|
1088
|
+
0,
|
|
1089
|
+
0
|
|
1090
|
+
],
|
|
1091
|
+
gainMapMax: [
|
|
1092
|
+
1,
|
|
1093
|
+
1,
|
|
1094
|
+
1
|
|
1095
|
+
],
|
|
1096
|
+
gamma: [
|
|
1097
|
+
1,
|
|
1098
|
+
1,
|
|
1099
|
+
1
|
|
1100
|
+
],
|
|
1101
|
+
hdrCapacityMin: 0,
|
|
1102
|
+
hdrCapacityMax: 1,
|
|
1103
|
+
offsetHdr: [
|
|
1104
|
+
0,
|
|
1105
|
+
0,
|
|
1106
|
+
0
|
|
1107
|
+
],
|
|
1108
|
+
offsetSdr: [
|
|
1109
|
+
0,
|
|
1110
|
+
0,
|
|
1111
|
+
0
|
|
1112
|
+
]
|
|
1113
|
+
};
|
|
1114
|
+
sdrJPEG = jpegBuffer;
|
|
1115
|
+
} else throw e;
|
|
1116
|
+
}
|
|
1117
|
+
try {
|
|
1118
|
+
await this.render(quadRenderer, metadata, sdrJPEG, gainMapJPEG);
|
|
1119
|
+
} catch (error) {
|
|
1120
|
+
this.manager.itemError(url);
|
|
1121
|
+
if (typeof onError === "function") onError(error);
|
|
1122
|
+
quadRenderer.disposeOnDemandRenderer();
|
|
1123
|
+
return;
|
|
1124
|
+
}
|
|
1125
|
+
if (typeof onLoad === "function") onLoad(quadRenderer);
|
|
1126
|
+
this.manager.itemEnd(url);
|
|
1127
|
+
quadRenderer.disposeOnDemandRenderer();
|
|
1128
|
+
}, onProgress, (error) => {
|
|
1129
|
+
this.manager.itemError(url);
|
|
1130
|
+
if (typeof onError === "function") onError(error);
|
|
1131
|
+
});
|
|
1132
|
+
return quadRenderer;
|
|
1133
|
+
}
|
|
1134
|
+
};
|
|
1135
|
+
|
|
1136
|
+
//#endregion
|
|
1137
|
+
export { HDRJPGLoader as n, GainMapLoader as t };
|