@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
package/core/BBAnchor.js
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import _extends from '@babel/runtime/helpers/esm/extends';
|
|
2
|
-
import * as React from 'react';
|
|
3
|
-
import * as THREE from 'three';
|
|
4
|
-
import { useFrame } from '@react-three/fiber';
|
|
5
|
-
|
|
6
|
-
const boundingBox = /* @__PURE__ */new THREE.Box3();
|
|
7
|
-
const boundingBoxSize = /* @__PURE__ */new THREE.Vector3();
|
|
8
|
-
const BBAnchor = ({
|
|
9
|
-
anchor,
|
|
10
|
-
...props
|
|
11
|
-
}) => {
|
|
12
|
-
const ref = React.useRef(null);
|
|
13
|
-
const parentRef = React.useRef(null);
|
|
14
|
-
|
|
15
|
-
// Reattach group created by this component to the parent's parent,
|
|
16
|
-
// so it becomes a sibling of its initial parent.
|
|
17
|
-
// We do that so the children have no impact on a bounding box of a parent.
|
|
18
|
-
React.useEffect(() => {
|
|
19
|
-
var _ref$current;
|
|
20
|
-
if ((_ref$current = ref.current) != null && (_ref$current = _ref$current.parent) != null && _ref$current.parent) {
|
|
21
|
-
parentRef.current = ref.current.parent;
|
|
22
|
-
ref.current.parent.parent.add(ref.current);
|
|
23
|
-
}
|
|
24
|
-
}, []);
|
|
25
|
-
useFrame(() => {
|
|
26
|
-
if (parentRef.current) {
|
|
27
|
-
boundingBox.setFromObject(parentRef.current);
|
|
28
|
-
boundingBox.getSize(boundingBoxSize);
|
|
29
|
-
ref.current.position.set(parentRef.current.position.x + boundingBoxSize.x * (Array.isArray(anchor) ? anchor[0] : anchor.x) / 2, parentRef.current.position.y + boundingBoxSize.y * (Array.isArray(anchor) ? anchor[1] : anchor.y) / 2, parentRef.current.position.z + boundingBoxSize.z * (Array.isArray(anchor) ? anchor[2] : anchor.z) / 2);
|
|
30
|
-
}
|
|
31
|
-
});
|
|
32
|
-
return /*#__PURE__*/React.createElement("group", _extends({
|
|
33
|
-
ref: ref
|
|
34
|
-
}, props));
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
export { BBAnchor };
|
package/core/Backdrop.cjs.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";function e(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var o=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,o.get?o:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}Object.defineProperty(exports,"__esModule",{value:!0});var t=e(require("react"));const r=e=>0===e?0:Math.pow(2,10*e-10);exports.Backdrop=function({children:e,floor:o=.25,segments:n=20,receiveShadow:c,...a}){const u=t.useRef(null);return t.useLayoutEffect((()=>{let e=0;const t=n/n/2,c=u.current.attributes.position;for(let a=0;a<n+1;a++)for(let u=0;u<n+1;u++)c.setXYZ(e++,a/n-t+(0===a?-o:0),u/n-t,r(a/n));c.needsUpdate=!0,u.current.computeVertexNormals()}),[n,o]),t.createElement("group",a,t.createElement("mesh",{receiveShadow:c,rotation:[-Math.PI/2,0,Math.PI/2]},t.createElement("planeGeometry",{ref:u,args:[1,1,n,n]}),e))};
|
package/core/Backdrop.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { ThreeElements } from '@react-three/fiber';
|
|
2
|
-
import * as React from 'react';
|
|
3
|
-
export type BackdropProps = ThreeElements['group'] & {
|
|
4
|
-
floor?: number;
|
|
5
|
-
segments?: number;
|
|
6
|
-
receiveShadow?: boolean;
|
|
7
|
-
children?: React.ReactNode;
|
|
8
|
-
};
|
|
9
|
-
export declare function Backdrop({ children, floor, segments, receiveShadow, ...props }: {
|
|
10
|
-
[x: string]: any;
|
|
11
|
-
children: any;
|
|
12
|
-
floor?: number | undefined;
|
|
13
|
-
segments?: number | undefined;
|
|
14
|
-
receiveShadow: any;
|
|
15
|
-
}): React.JSX.Element;
|
package/core/Backdrop.js
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
|
|
3
|
-
const easeInExpo = x => x === 0 ? 0 : Math.pow(2, 10 * x - 10);
|
|
4
|
-
function Backdrop({
|
|
5
|
-
children,
|
|
6
|
-
floor = 0.25,
|
|
7
|
-
segments = 20,
|
|
8
|
-
receiveShadow,
|
|
9
|
-
...props
|
|
10
|
-
}) {
|
|
11
|
-
const ref = React.useRef(null);
|
|
12
|
-
React.useLayoutEffect(() => {
|
|
13
|
-
let i = 0;
|
|
14
|
-
const offset = segments / segments / 2;
|
|
15
|
-
const position = ref.current.attributes.position;
|
|
16
|
-
for (let x = 0; x < segments + 1; x++) {
|
|
17
|
-
for (let y = 0; y < segments + 1; y++) {
|
|
18
|
-
position.setXYZ(i++, x / segments - offset + (x === 0 ? -floor : 0), y / segments - offset, easeInExpo(x / segments));
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
position.needsUpdate = true;
|
|
22
|
-
ref.current.computeVertexNormals();
|
|
23
|
-
}, [segments, floor]);
|
|
24
|
-
return /*#__PURE__*/React.createElement("group", props, /*#__PURE__*/React.createElement("mesh", {
|
|
25
|
-
receiveShadow: receiveShadow,
|
|
26
|
-
rotation: [-Math.PI / 2, 0, Math.PI / 2]
|
|
27
|
-
}, /*#__PURE__*/React.createElement("planeGeometry", {
|
|
28
|
-
ref: ref,
|
|
29
|
-
args: [1, 1, segments, segments]
|
|
30
|
-
}), children));
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export { Backdrop };
|
package/core/BakeShadows.cjs.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),a=require("@react-three/fiber");exports.BakeShadows=function(){const t=a.useThree((e=>e.gl));return e.useEffect((()=>(t.shadowMap.autoUpdate=!1,t.shadowMap.needsUpdate=!0,()=>{t.shadowMap.autoUpdate=t.shadowMap.needsUpdate=!0})),[t.shadowMap]),null};
|
package/core/BakeShadows.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function BakeShadows(): null;
|
package/core/BakeShadows.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { useEffect } from 'react';
|
|
2
|
-
import { useThree } from '@react-three/fiber';
|
|
3
|
-
|
|
4
|
-
function BakeShadows() {
|
|
5
|
-
const gl = useThree(state => state.gl);
|
|
6
|
-
useEffect(() => {
|
|
7
|
-
gl.shadowMap.autoUpdate = false;
|
|
8
|
-
gl.shadowMap.needsUpdate = true;
|
|
9
|
-
return () => {
|
|
10
|
-
gl.shadowMap.autoUpdate = gl.shadowMap.needsUpdate = true;
|
|
11
|
-
};
|
|
12
|
-
}, [gl.shadowMap]);
|
|
13
|
-
return null;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export { BakeShadows };
|
package/core/Billboard.cjs.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/extends"),r=require("react"),t=require("three"),n=require("@react-three/fiber");function u(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function o(e){if(e&&e.__esModule)return e;var r=Object.create(null);return e&&Object.keys(e).forEach((function(t){if("default"!==t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})}})),r.default=e,Object.freeze(r)}var c=u(e),a=o(r);const i=a.forwardRef((function({children:e,follow:r=!0,lockX:u=!1,lockY:o=!1,lockZ:i=!1,...l},f){const d=a.useRef(null),s=a.useRef(null),p=new t.Quaternion;return n.useFrame((({camera:e})=>{if(!r||!s.current)return;const t=d.current.rotation.clone();s.current.updateMatrix(),s.current.updateWorldMatrix(!1,!1),s.current.getWorldQuaternion(p),e.getWorldQuaternion(d.current.quaternion).premultiply(p.invert()),u&&(d.current.rotation.x=t.x),o&&(d.current.rotation.y=t.y),i&&(d.current.rotation.z=t.z)})),a.useImperativeHandle(f,(()=>s.current),[]),a.createElement("group",c.default({ref:s},l),a.createElement("group",{ref:d},e))}));exports.Billboard=i;
|
package/core/Billboard.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { Group } from 'three';
|
|
2
|
-
import { ThreeElements } from '@react-three/fiber';
|
|
3
|
-
import { ForwardRefComponent } from '../helpers/ts-utils';
|
|
4
|
-
export type BillboardProps = Omit<ThreeElements['group'], 'ref'> & {
|
|
5
|
-
follow?: boolean;
|
|
6
|
-
lockX?: boolean;
|
|
7
|
-
lockY?: boolean;
|
|
8
|
-
lockZ?: boolean;
|
|
9
|
-
};
|
|
10
|
-
export declare const Billboard: ForwardRefComponent<BillboardProps, Group>;
|
package/core/Billboard.js
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import _extends from '@babel/runtime/helpers/esm/extends';
|
|
2
|
-
import * as React from 'react';
|
|
3
|
-
import { Quaternion } from 'three';
|
|
4
|
-
import { useFrame } from '@react-three/fiber';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Wraps children in a billboarded group. Sample usage:
|
|
8
|
-
*
|
|
9
|
-
* ```js
|
|
10
|
-
* <Billboard>
|
|
11
|
-
* <Text>hi</Text>
|
|
12
|
-
* </Billboard>
|
|
13
|
-
* ```
|
|
14
|
-
*/
|
|
15
|
-
const Billboard = /* @__PURE__ */React.forwardRef(function Billboard({
|
|
16
|
-
children,
|
|
17
|
-
follow = true,
|
|
18
|
-
lockX = false,
|
|
19
|
-
lockY = false,
|
|
20
|
-
lockZ = false,
|
|
21
|
-
...props
|
|
22
|
-
}, fref) {
|
|
23
|
-
const inner = React.useRef(null);
|
|
24
|
-
const localRef = React.useRef(null);
|
|
25
|
-
const q = new Quaternion();
|
|
26
|
-
useFrame(({
|
|
27
|
-
camera
|
|
28
|
-
}) => {
|
|
29
|
-
if (!follow || !localRef.current) return;
|
|
30
|
-
|
|
31
|
-
// save previous rotation in case we're locking an axis
|
|
32
|
-
const prevRotation = inner.current.rotation.clone();
|
|
33
|
-
|
|
34
|
-
// always face the camera
|
|
35
|
-
localRef.current.updateMatrix();
|
|
36
|
-
localRef.current.updateWorldMatrix(false, false);
|
|
37
|
-
localRef.current.getWorldQuaternion(q);
|
|
38
|
-
camera.getWorldQuaternion(inner.current.quaternion).premultiply(q.invert());
|
|
39
|
-
|
|
40
|
-
// readjust any axis that is locked
|
|
41
|
-
if (lockX) inner.current.rotation.x = prevRotation.x;
|
|
42
|
-
if (lockY) inner.current.rotation.y = prevRotation.y;
|
|
43
|
-
if (lockZ) inner.current.rotation.z = prevRotation.z;
|
|
44
|
-
});
|
|
45
|
-
React.useImperativeHandle(fref, () => localRef.current, []);
|
|
46
|
-
return /*#__PURE__*/React.createElement("group", _extends({
|
|
47
|
-
ref: localRef
|
|
48
|
-
}, props), /*#__PURE__*/React.createElement("group", {
|
|
49
|
-
ref: inner
|
|
50
|
-
}, children));
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
export { Billboard };
|
package/core/Bounds.cjs.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("three"),r=require("@react-three/fiber");function n(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var o=n(e),c=n(t),a=function(e){return e[e.NONE=0]="NONE",e[e.START=1]="START",e[e.ACTIVE=2]="ACTIVE",e}(a||{});const u=e=>e&&e.isOrthographicCamera,i=e=>1-Math.exp(-5*e)+.007*e,s=o.createContext(null);exports.Bounds=function({children:e,maxDuration:t=1,margin:n=1.2,observe:m,fit:p,clip:l,interpolateFunc:x=i,onFit:d}){const f=o.useRef(null),{camera:y,size:h,invalidate:g}=r.useThree(),v=r.useThree((e=>e.controls)),R=o.useRef(d);R.current=d;const M=o.useRef({camPos:new c.Vector3,camRot:new c.Quaternion,camZoom:1}),P=o.useRef({camPos:void 0,camRot:void 0,camZoom:void 0,camUp:void 0,target:void 0}),w=o.useRef(a.NONE),T=o.useRef(0),[V]=o.useState((()=>new c.Box3)),A=o.useMemo((()=>{function e(){const e=V.getSize(new c.Vector3),t=V.getCenter(new c.Vector3),r=Math.max(e.x,e.y,e.z),o=u(y)?4*r:r/(2*Math.atan(Math.PI*y.fov/360)),a=u(y)?4*r:o/y.aspect,i=n*Math.max(o,a);return{box:V,size:e,center:t,distance:i}}return{getSize:e,refresh(e){if((t=e)&&t.isBox3)V.copy(e);else{const t=e||f.current;if(!t)return this;t.updateWorldMatrix(!0,!0),V.setFromObject(t)}var t;if(V.isEmpty()){const e=y.position.length()||10;V.setFromCenterAndSize(new c.Vector3,new c.Vector3(e,e,e))}return M.current.camPos.copy(y.position),M.current.camRot.copy(y.quaternion),u(y)&&(M.current.camZoom=y.zoom),P.current.camPos=void 0,P.current.camRot=void 0,P.current.camZoom=void 0,P.current.camUp=void 0,P.current.target=void 0,this},reset(){const{center:t,distance:r}=e(),n=y.position.clone().sub(t).normalize();P.current.camPos=t.clone().addScaledVector(n,r),P.current.target=t.clone();const o=(new c.Matrix4).lookAt(P.current.camPos,P.current.target,y.up);return P.current.camRot=(new c.Quaternion).setFromRotationMatrix(o),w.current=a.START,T.current=0,this},moveTo(e){return P.current.camPos=Array.isArray(e)?new c.Vector3(...e):e.clone(),w.current=a.START,T.current=0,this},lookAt({target:e,up:t}){P.current.target=Array.isArray(e)?new c.Vector3(...e):e.clone(),P.current.camUp=t?Array.isArray(t)?new c.Vector3(...t):t.clone():y.up.clone();const r=(new c.Matrix4).lookAt(P.current.camPos||y.position,P.current.target,P.current.camUp);return P.current.camRot=(new c.Quaternion).setFromRotationMatrix(r),w.current=a.START,T.current=0,this},to({position:e,target:t}){return this.moveTo(e).lookAt({target:t})},fit(){if(!u(y))return this.reset();let e=0,t=0;const r=[new c.Vector3(V.min.x,V.min.y,V.min.z),new c.Vector3(V.min.x,V.max.y,V.min.z),new c.Vector3(V.min.x,V.min.y,V.max.z),new c.Vector3(V.min.x,V.max.y,V.max.z),new c.Vector3(V.max.x,V.max.y,V.max.z),new c.Vector3(V.max.x,V.max.y,V.min.z),new c.Vector3(V.max.x,V.min.y,V.max.z),new c.Vector3(V.max.x,V.min.y,V.min.z)],o=P.current.camPos||y.position,i=P.current.target||(null==v?void 0:v.target),s=P.current.camUp||y.up,m=i?(new c.Matrix4).lookAt(o,i,s).setPosition(o).invert():y.matrixWorldInverse;for(const n of r)n.applyMatrix4(m),e=Math.max(e,Math.abs(n.y)),t=Math.max(t,Math.abs(n.x));e*=2,t*=2;const p=(y.top-y.bottom)/e,l=(y.right-y.left)/t;return P.current.camZoom=Math.min(p,l)/n,w.current=a.START,T.current=0,R.current&&R.current(this.getSize()),this},clip(){const{distance:t}=e();return y.near=t/100,y.far=100*t,y.updateProjectionMatrix(),v&&(v.maxDistance=10*t,v.update()),g(),this}}}),[V,y,v,n,g]);o.useLayoutEffect((()=>{if(v){const e=()=>{if(v&&P.current.target&&w.current!==a.NONE){const e=(new c.Vector3).setFromMatrixColumn(y.matrix,2),t=M.current.camPos.distanceTo(v.target),r=(P.current.camPos||M.current.camPos).distanceTo(P.current.target),n=(1-T.current)*t+T.current*r;v.target.copy(y.position).addScaledVector(e,-n),v.update()}w.current=a.NONE};return v.addEventListener("start",e),()=>v.removeEventListener("start",e)}}),[v]);const z=o.useRef(0);return o.useLayoutEffect((()=>{(m||0==z.current++)&&(A.refresh(),p&&A.reset().fit(),l&&A.clip())}),[h,l,p,m,y,v]),r.useFrame(((e,r)=>{if(w.current===a.START)w.current=a.ACTIVE,g();else if(w.current===a.ACTIVE){if(T.current+=r/t,T.current>=1)P.current.camPos&&y.position.copy(P.current.camPos),P.current.camRot&&y.quaternion.copy(P.current.camRot),P.current.camUp&&y.up.copy(P.current.camUp),P.current.camZoom&&u(y)&&(y.zoom=P.current.camZoom),y.updateMatrixWorld(),y.updateProjectionMatrix(),v&&P.current.target&&(v.target.copy(P.current.target),v.update()),w.current=a.NONE;else{const e=x(T.current);P.current.camPos&&y.position.lerpVectors(M.current.camPos,P.current.camPos,e),P.current.camRot&&y.quaternion.slerpQuaternions(M.current.camRot,P.current.camRot,e),P.current.camUp&&y.up.set(0,1,0).applyQuaternion(y.quaternion),P.current.camZoom&&u(y)&&(y.zoom=(1-e)*M.current.camZoom+e*P.current.camZoom),y.updateMatrixWorld(),y.updateProjectionMatrix()}g()}})),o.createElement("group",{ref:f},o.createElement(s.Provider,{value:A},e))},exports.useBounds=function(){return o.useContext(s)};
|
package/core/Bounds.d.ts
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import * as THREE from 'three';
|
|
3
|
-
import { ThreeElements } from '@react-three/fiber';
|
|
4
|
-
export type SizeProps = {
|
|
5
|
-
box: THREE.Box3;
|
|
6
|
-
size: THREE.Vector3;
|
|
7
|
-
center: THREE.Vector3;
|
|
8
|
-
distance: number;
|
|
9
|
-
};
|
|
10
|
-
export type BoundsApi = {
|
|
11
|
-
getSize: () => SizeProps;
|
|
12
|
-
refresh(object?: THREE.Object3D | THREE.Box3): BoundsApi;
|
|
13
|
-
reset(): BoundsApi;
|
|
14
|
-
moveTo(position: THREE.Vector3 | [number, number, number]): BoundsApi;
|
|
15
|
-
lookAt({ target, up, }: {
|
|
16
|
-
target?: THREE.Vector3 | [number, number, number];
|
|
17
|
-
up?: THREE.Vector3 | [number, number, number];
|
|
18
|
-
}): BoundsApi;
|
|
19
|
-
to({ position, target }: {
|
|
20
|
-
position: [number, number, number];
|
|
21
|
-
target: [number, number, number];
|
|
22
|
-
}): BoundsApi;
|
|
23
|
-
fit(): BoundsApi;
|
|
24
|
-
clip(): BoundsApi;
|
|
25
|
-
};
|
|
26
|
-
export type BoundsProps = Omit<ThreeElements['group'], 'ref'> & {
|
|
27
|
-
maxDuration?: number;
|
|
28
|
-
margin?: number;
|
|
29
|
-
observe?: boolean;
|
|
30
|
-
fit?: boolean;
|
|
31
|
-
clip?: boolean;
|
|
32
|
-
interpolateFunc?: (t: number) => number;
|
|
33
|
-
onFit?: (data: SizeProps) => void;
|
|
34
|
-
};
|
|
35
|
-
export declare function Bounds({ children, maxDuration, margin, observe, fit, clip, interpolateFunc, onFit, }: BoundsProps): React.JSX.Element;
|
|
36
|
-
export declare function useBounds(): BoundsApi;
|
package/core/Bounds.js
DELETED
|
@@ -1,254 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import * as THREE from 'three';
|
|
3
|
-
import { useThree, useFrame } from '@react-three/fiber';
|
|
4
|
-
|
|
5
|
-
var AnimationState = /*#__PURE__*/function (AnimationState) {
|
|
6
|
-
AnimationState[AnimationState["NONE"] = 0] = "NONE";
|
|
7
|
-
AnimationState[AnimationState["START"] = 1] = "START";
|
|
8
|
-
AnimationState[AnimationState["ACTIVE"] = 2] = "ACTIVE";
|
|
9
|
-
return AnimationState;
|
|
10
|
-
}(AnimationState || {});
|
|
11
|
-
const isOrthographic = def => def && def.isOrthographicCamera;
|
|
12
|
-
const isBox3 = def => def && def.isBox3;
|
|
13
|
-
const interpolateFuncDefault = t => {
|
|
14
|
-
// Imitates the previously used THREE.MathUtils.damp
|
|
15
|
-
return 1 - Math.exp(-5 * t) + 0.007 * t;
|
|
16
|
-
};
|
|
17
|
-
const context = /*#__PURE__*/React.createContext(null);
|
|
18
|
-
function Bounds({
|
|
19
|
-
children,
|
|
20
|
-
maxDuration = 1.0,
|
|
21
|
-
margin = 1.2,
|
|
22
|
-
observe,
|
|
23
|
-
fit,
|
|
24
|
-
clip,
|
|
25
|
-
interpolateFunc = interpolateFuncDefault,
|
|
26
|
-
onFit
|
|
27
|
-
}) {
|
|
28
|
-
const ref = React.useRef(null);
|
|
29
|
-
const {
|
|
30
|
-
camera,
|
|
31
|
-
size,
|
|
32
|
-
invalidate
|
|
33
|
-
} = useThree();
|
|
34
|
-
const controls = useThree(state => state.controls);
|
|
35
|
-
const onFitRef = React.useRef(onFit);
|
|
36
|
-
onFitRef.current = onFit;
|
|
37
|
-
const origin = React.useRef({
|
|
38
|
-
camPos: new THREE.Vector3(),
|
|
39
|
-
camRot: new THREE.Quaternion(),
|
|
40
|
-
camZoom: 1
|
|
41
|
-
});
|
|
42
|
-
const goal = React.useRef({
|
|
43
|
-
camPos: undefined,
|
|
44
|
-
camRot: undefined,
|
|
45
|
-
camZoom: undefined,
|
|
46
|
-
camUp: undefined,
|
|
47
|
-
target: undefined
|
|
48
|
-
});
|
|
49
|
-
const animationState = React.useRef(AnimationState.NONE);
|
|
50
|
-
const t = React.useRef(0); // represent animation state from 0 to 1
|
|
51
|
-
|
|
52
|
-
const [box] = React.useState(() => new THREE.Box3());
|
|
53
|
-
const api = React.useMemo(() => {
|
|
54
|
-
function getSize() {
|
|
55
|
-
const boxSize = box.getSize(new THREE.Vector3());
|
|
56
|
-
const center = box.getCenter(new THREE.Vector3());
|
|
57
|
-
const maxSize = Math.max(boxSize.x, boxSize.y, boxSize.z);
|
|
58
|
-
const fitHeightDistance = isOrthographic(camera) ? maxSize * 4 : maxSize / (2 * Math.atan(Math.PI * camera.fov / 360));
|
|
59
|
-
const fitWidthDistance = isOrthographic(camera) ? maxSize * 4 : fitHeightDistance / camera.aspect;
|
|
60
|
-
const distance = margin * Math.max(fitHeightDistance, fitWidthDistance);
|
|
61
|
-
return {
|
|
62
|
-
box,
|
|
63
|
-
size: boxSize,
|
|
64
|
-
center,
|
|
65
|
-
distance
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
return {
|
|
69
|
-
getSize,
|
|
70
|
-
refresh(object) {
|
|
71
|
-
if (isBox3(object)) box.copy(object);else {
|
|
72
|
-
const target = object || ref.current;
|
|
73
|
-
if (!target) return this;
|
|
74
|
-
target.updateWorldMatrix(true, true);
|
|
75
|
-
box.setFromObject(target);
|
|
76
|
-
}
|
|
77
|
-
if (box.isEmpty()) {
|
|
78
|
-
const max = camera.position.length() || 10;
|
|
79
|
-
box.setFromCenterAndSize(new THREE.Vector3(), new THREE.Vector3(max, max, max));
|
|
80
|
-
}
|
|
81
|
-
origin.current.camPos.copy(camera.position);
|
|
82
|
-
origin.current.camRot.copy(camera.quaternion);
|
|
83
|
-
isOrthographic(camera) && (origin.current.camZoom = camera.zoom);
|
|
84
|
-
goal.current.camPos = undefined;
|
|
85
|
-
goal.current.camRot = undefined;
|
|
86
|
-
goal.current.camZoom = undefined;
|
|
87
|
-
goal.current.camUp = undefined;
|
|
88
|
-
goal.current.target = undefined;
|
|
89
|
-
return this;
|
|
90
|
-
},
|
|
91
|
-
reset() {
|
|
92
|
-
const {
|
|
93
|
-
center,
|
|
94
|
-
distance
|
|
95
|
-
} = getSize();
|
|
96
|
-
const direction = camera.position.clone().sub(center).normalize();
|
|
97
|
-
goal.current.camPos = center.clone().addScaledVector(direction, distance);
|
|
98
|
-
goal.current.target = center.clone();
|
|
99
|
-
const mCamRot = new THREE.Matrix4().lookAt(goal.current.camPos, goal.current.target, camera.up);
|
|
100
|
-
goal.current.camRot = new THREE.Quaternion().setFromRotationMatrix(mCamRot);
|
|
101
|
-
animationState.current = AnimationState.START;
|
|
102
|
-
t.current = 0;
|
|
103
|
-
return this;
|
|
104
|
-
},
|
|
105
|
-
moveTo(position) {
|
|
106
|
-
goal.current.camPos = Array.isArray(position) ? new THREE.Vector3(...position) : position.clone();
|
|
107
|
-
animationState.current = AnimationState.START;
|
|
108
|
-
t.current = 0;
|
|
109
|
-
return this;
|
|
110
|
-
},
|
|
111
|
-
lookAt({
|
|
112
|
-
target,
|
|
113
|
-
up
|
|
114
|
-
}) {
|
|
115
|
-
goal.current.target = Array.isArray(target) ? new THREE.Vector3(...target) : target.clone();
|
|
116
|
-
if (up) {
|
|
117
|
-
goal.current.camUp = Array.isArray(up) ? new THREE.Vector3(...up) : up.clone();
|
|
118
|
-
} else {
|
|
119
|
-
goal.current.camUp = camera.up.clone();
|
|
120
|
-
}
|
|
121
|
-
const mCamRot = new THREE.Matrix4().lookAt(goal.current.camPos || camera.position, goal.current.target, goal.current.camUp);
|
|
122
|
-
goal.current.camRot = new THREE.Quaternion().setFromRotationMatrix(mCamRot);
|
|
123
|
-
animationState.current = AnimationState.START;
|
|
124
|
-
t.current = 0;
|
|
125
|
-
return this;
|
|
126
|
-
},
|
|
127
|
-
/**
|
|
128
|
-
* @deprecated Use moveTo and lookAt instead
|
|
129
|
-
*/
|
|
130
|
-
to({
|
|
131
|
-
position,
|
|
132
|
-
target
|
|
133
|
-
}) {
|
|
134
|
-
return this.moveTo(position).lookAt({
|
|
135
|
-
target
|
|
136
|
-
});
|
|
137
|
-
},
|
|
138
|
-
fit() {
|
|
139
|
-
if (!isOrthographic(camera)) {
|
|
140
|
-
// For non-orthographic cameras, fit should behave exactly like reset
|
|
141
|
-
return this.reset();
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
// For orthographic cameras, fit should only modify the zoom value
|
|
145
|
-
let maxHeight = 0,
|
|
146
|
-
maxWidth = 0;
|
|
147
|
-
const vertices = [new THREE.Vector3(box.min.x, box.min.y, box.min.z), new THREE.Vector3(box.min.x, box.max.y, box.min.z), new THREE.Vector3(box.min.x, box.min.y, box.max.z), new THREE.Vector3(box.min.x, box.max.y, box.max.z), new THREE.Vector3(box.max.x, box.max.y, box.max.z), new THREE.Vector3(box.max.x, box.max.y, box.min.z), new THREE.Vector3(box.max.x, box.min.y, box.max.z), new THREE.Vector3(box.max.x, box.min.y, box.min.z)];
|
|
148
|
-
|
|
149
|
-
// Transform the center and each corner to camera space
|
|
150
|
-
const pos = goal.current.camPos || camera.position;
|
|
151
|
-
const target = goal.current.target || (controls == null ? void 0 : controls.target);
|
|
152
|
-
const up = goal.current.camUp || camera.up;
|
|
153
|
-
const mCamWInv = target ? new THREE.Matrix4().lookAt(pos, target, up).setPosition(pos).invert() : camera.matrixWorldInverse;
|
|
154
|
-
for (const v of vertices) {
|
|
155
|
-
v.applyMatrix4(mCamWInv);
|
|
156
|
-
maxHeight = Math.max(maxHeight, Math.abs(v.y));
|
|
157
|
-
maxWidth = Math.max(maxWidth, Math.abs(v.x));
|
|
158
|
-
}
|
|
159
|
-
maxHeight *= 2;
|
|
160
|
-
maxWidth *= 2;
|
|
161
|
-
const zoomForHeight = (camera.top - camera.bottom) / maxHeight;
|
|
162
|
-
const zoomForWidth = (camera.right - camera.left) / maxWidth;
|
|
163
|
-
goal.current.camZoom = Math.min(zoomForHeight, zoomForWidth) / margin;
|
|
164
|
-
animationState.current = AnimationState.START;
|
|
165
|
-
t.current = 0;
|
|
166
|
-
onFitRef.current && onFitRef.current(this.getSize());
|
|
167
|
-
return this;
|
|
168
|
-
},
|
|
169
|
-
clip() {
|
|
170
|
-
const {
|
|
171
|
-
distance
|
|
172
|
-
} = getSize();
|
|
173
|
-
camera.near = distance / 100;
|
|
174
|
-
camera.far = distance * 100;
|
|
175
|
-
camera.updateProjectionMatrix();
|
|
176
|
-
if (controls) {
|
|
177
|
-
controls.maxDistance = distance * 10;
|
|
178
|
-
controls.update();
|
|
179
|
-
}
|
|
180
|
-
invalidate();
|
|
181
|
-
return this;
|
|
182
|
-
}
|
|
183
|
-
};
|
|
184
|
-
}, [box, camera, controls, margin, invalidate]);
|
|
185
|
-
React.useLayoutEffect(() => {
|
|
186
|
-
if (controls) {
|
|
187
|
-
// Try to prevent drag hijacking
|
|
188
|
-
const callback = () => {
|
|
189
|
-
if (controls && goal.current.target && animationState.current !== AnimationState.NONE) {
|
|
190
|
-
const front = new THREE.Vector3().setFromMatrixColumn(camera.matrix, 2);
|
|
191
|
-
const d0 = origin.current.camPos.distanceTo(controls.target);
|
|
192
|
-
const d1 = (goal.current.camPos || origin.current.camPos).distanceTo(goal.current.target);
|
|
193
|
-
const d = (1 - t.current) * d0 + t.current * d1;
|
|
194
|
-
controls.target.copy(camera.position).addScaledVector(front, -d);
|
|
195
|
-
controls.update();
|
|
196
|
-
}
|
|
197
|
-
animationState.current = AnimationState.NONE;
|
|
198
|
-
};
|
|
199
|
-
controls.addEventListener('start', callback);
|
|
200
|
-
return () => controls.removeEventListener('start', callback);
|
|
201
|
-
}
|
|
202
|
-
}, [controls]);
|
|
203
|
-
|
|
204
|
-
// Scale pointer on window resize
|
|
205
|
-
const count = React.useRef(0);
|
|
206
|
-
React.useLayoutEffect(() => {
|
|
207
|
-
if (observe || count.current++ === 0) {
|
|
208
|
-
api.refresh();
|
|
209
|
-
if (fit) api.reset().fit();
|
|
210
|
-
if (clip) api.clip();
|
|
211
|
-
}
|
|
212
|
-
}, [size, clip, fit, observe, camera, controls]);
|
|
213
|
-
useFrame((state, delta) => {
|
|
214
|
-
// This [additional animation step START] is needed to guarantee that delta used in animation isn't absurdly high (2-3 seconds) which is actually possible if rendering happens on demand...
|
|
215
|
-
if (animationState.current === AnimationState.START) {
|
|
216
|
-
animationState.current = AnimationState.ACTIVE;
|
|
217
|
-
invalidate();
|
|
218
|
-
} else if (animationState.current === AnimationState.ACTIVE) {
|
|
219
|
-
t.current += delta / maxDuration;
|
|
220
|
-
if (t.current >= 1) {
|
|
221
|
-
goal.current.camPos && camera.position.copy(goal.current.camPos);
|
|
222
|
-
goal.current.camRot && camera.quaternion.copy(goal.current.camRot);
|
|
223
|
-
goal.current.camUp && camera.up.copy(goal.current.camUp);
|
|
224
|
-
goal.current.camZoom && isOrthographic(camera) && (camera.zoom = goal.current.camZoom);
|
|
225
|
-
camera.updateMatrixWorld();
|
|
226
|
-
camera.updateProjectionMatrix();
|
|
227
|
-
if (controls && goal.current.target) {
|
|
228
|
-
controls.target.copy(goal.current.target);
|
|
229
|
-
controls.update();
|
|
230
|
-
}
|
|
231
|
-
animationState.current = AnimationState.NONE;
|
|
232
|
-
} else {
|
|
233
|
-
const k = interpolateFunc(t.current);
|
|
234
|
-
goal.current.camPos && camera.position.lerpVectors(origin.current.camPos, goal.current.camPos, k);
|
|
235
|
-
goal.current.camRot && camera.quaternion.slerpQuaternions(origin.current.camRot, goal.current.camRot, k);
|
|
236
|
-
goal.current.camUp && camera.up.set(0, 1, 0).applyQuaternion(camera.quaternion);
|
|
237
|
-
goal.current.camZoom && isOrthographic(camera) && (camera.zoom = (1 - k) * origin.current.camZoom + k * goal.current.camZoom);
|
|
238
|
-
camera.updateMatrixWorld();
|
|
239
|
-
camera.updateProjectionMatrix();
|
|
240
|
-
}
|
|
241
|
-
invalidate();
|
|
242
|
-
}
|
|
243
|
-
});
|
|
244
|
-
return /*#__PURE__*/React.createElement("group", {
|
|
245
|
-
ref: ref
|
|
246
|
-
}, /*#__PURE__*/React.createElement(context.Provider, {
|
|
247
|
-
value: api
|
|
248
|
-
}, children));
|
|
249
|
-
}
|
|
250
|
-
function useBounds() {
|
|
251
|
-
return React.useContext(context);
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
export { Bounds, useBounds };
|
package/core/Bvh.cjs.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/extends"),r=require("@react-three/fiber"),t=require("react"),s=require("three"),o=require("three-mesh-bvh");function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function u(e){if(e&&e.__esModule)return e;var r=Object.create(null);return e&&Object.keys(e).forEach((function(t){if("default"!==t){var s=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,s.get?s:{enumerable:!0,get:function(){return e[t]}})}})),r.default=e,Object.freeze(r)}var a=n(e),c=u(t);const i=e=>e.isMesh;const d=c.forwardRef((({enabled:e=!0,firstHitOnly:t=!1,children:n,strategy:u=o.SAH,verbose:d=!1,setBoundingBox:f=!0,maxDepth:p=40,maxLeafTris:y=10,indirect:l=!1,...m},B)=>{const b=c.useRef(null),T=r.useThree((e=>e.raycaster));return c.useImperativeHandle(B,(()=>b.current),[]),c.useEffect((()=>{if(e){const e={strategy:u,verbose:d,setBoundingBox:f,maxDepth:p,maxLeafTris:y,indirect:l},r=b.current;return T.firstHitOnly=t,r.traverse((r=>{i(r)&&!r.geometry.boundsTree&&r.raycast===s.Mesh.prototype.raycast&&(r.raycast=o.acceleratedRaycast,r.geometry.computeBoundsTree=o.computeBoundsTree,r.geometry.disposeBoundsTree=o.disposeBoundsTree,r.geometry.computeBoundsTree(e))})),()=>{delete T.firstHitOnly,r.traverse((e=>{i(e)&&e.geometry.boundsTree&&(e.geometry.disposeBoundsTree(),e.raycast=s.Mesh.prototype.raycast)}))}}}),[]),c.createElement("group",a.default({ref:b},m),n)}));exports.Bvh=d,exports.useBVH=function(e,r){r={strategy:o.SAH,verbose:!1,setBoundingBox:!0,maxDepth:40,maxLeafTris:10,indirect:!1,...r},c.useEffect((()=>{if(e.current){e.current.raycast=o.acceleratedRaycast;const t=e.current.geometry;return t.computeBoundsTree=o.computeBoundsTree,t.disposeBoundsTree=o.disposeBoundsTree,t.computeBoundsTree(r),()=>{t.boundsTree&&t.disposeBoundsTree()}}}),[e,JSON.stringify(r)])};
|
package/core/Bvh.d.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { ThreeElements } from '@react-three/fiber';
|
|
2
|
-
import * as React from 'react';
|
|
3
|
-
import { Mesh, Group } from 'three';
|
|
4
|
-
import { SplitStrategy } from 'three-mesh-bvh';
|
|
5
|
-
import { ForwardRefComponent } from '../helpers/ts-utils';
|
|
6
|
-
export interface BVHOptions {
|
|
7
|
-
strategy?: SplitStrategy;
|
|
8
|
-
verbose?: boolean;
|
|
9
|
-
setBoundingBox?: boolean;
|
|
10
|
-
maxDepth?: number;
|
|
11
|
-
maxLeafTris?: number;
|
|
12
|
-
indirect?: boolean;
|
|
13
|
-
}
|
|
14
|
-
export type BvhProps = BVHOptions & ThreeElements['group'] & {
|
|
15
|
-
enabled?: boolean;
|
|
16
|
-
firstHitOnly?: boolean;
|
|
17
|
-
};
|
|
18
|
-
export declare function useBVH(mesh: React.RefObject<Mesh | undefined>, options?: BVHOptions): void;
|
|
19
|
-
export declare const Bvh: ForwardRefComponent<BvhProps, Group>;
|
package/core/Bvh.js
DELETED
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
import _extends from '@babel/runtime/helpers/esm/extends';
|
|
2
|
-
import { useThree } from '@react-three/fiber';
|
|
3
|
-
import * as React from 'react';
|
|
4
|
-
import { Mesh } from 'three';
|
|
5
|
-
import { SAH, acceleratedRaycast, computeBoundsTree, disposeBoundsTree } from 'three-mesh-bvh';
|
|
6
|
-
|
|
7
|
-
const isMesh = child => child.isMesh;
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* @deprecated Use the Bvh component instead
|
|
11
|
-
*/
|
|
12
|
-
function useBVH(mesh, options) {
|
|
13
|
-
options = {
|
|
14
|
-
strategy: SAH,
|
|
15
|
-
verbose: false,
|
|
16
|
-
setBoundingBox: true,
|
|
17
|
-
maxDepth: 40,
|
|
18
|
-
maxLeafTris: 10,
|
|
19
|
-
indirect: false,
|
|
20
|
-
...options
|
|
21
|
-
};
|
|
22
|
-
React.useEffect(() => {
|
|
23
|
-
if (mesh.current) {
|
|
24
|
-
mesh.current.raycast = acceleratedRaycast;
|
|
25
|
-
const geometry = mesh.current.geometry;
|
|
26
|
-
geometry.computeBoundsTree = computeBoundsTree;
|
|
27
|
-
geometry.disposeBoundsTree = disposeBoundsTree;
|
|
28
|
-
geometry.computeBoundsTree(options);
|
|
29
|
-
return () => {
|
|
30
|
-
if (geometry.boundsTree) {
|
|
31
|
-
geometry.disposeBoundsTree();
|
|
32
|
-
}
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
}, [mesh, JSON.stringify(options)]);
|
|
36
|
-
}
|
|
37
|
-
const Bvh = /* @__PURE__ */React.forwardRef(({
|
|
38
|
-
enabled = true,
|
|
39
|
-
firstHitOnly = false,
|
|
40
|
-
children,
|
|
41
|
-
strategy = SAH,
|
|
42
|
-
verbose = false,
|
|
43
|
-
setBoundingBox = true,
|
|
44
|
-
maxDepth = 40,
|
|
45
|
-
maxLeafTris = 10,
|
|
46
|
-
indirect = false,
|
|
47
|
-
...props
|
|
48
|
-
}, fref) => {
|
|
49
|
-
const ref = React.useRef(null);
|
|
50
|
-
const raycaster = useThree(state => state.raycaster);
|
|
51
|
-
React.useImperativeHandle(fref, () => ref.current, []);
|
|
52
|
-
React.useEffect(() => {
|
|
53
|
-
if (enabled) {
|
|
54
|
-
const options = {
|
|
55
|
-
strategy,
|
|
56
|
-
verbose,
|
|
57
|
-
setBoundingBox,
|
|
58
|
-
maxDepth,
|
|
59
|
-
maxLeafTris,
|
|
60
|
-
indirect
|
|
61
|
-
};
|
|
62
|
-
const group = ref.current;
|
|
63
|
-
// This can only safely work if the component is used once, but there is no alternative.
|
|
64
|
-
// Hijacking the raycast method to do it for individual meshes is not an option as it would
|
|
65
|
-
// cost too much memory ...
|
|
66
|
-
raycaster.firstHitOnly = firstHitOnly;
|
|
67
|
-
group.traverse(child => {
|
|
68
|
-
// Only include meshes that do not yet have a boundsTree and whose raycast is standard issue
|
|
69
|
-
if (isMesh(child) && !child.geometry.boundsTree && child.raycast === Mesh.prototype.raycast) {
|
|
70
|
-
child.raycast = acceleratedRaycast;
|
|
71
|
-
child.geometry.computeBoundsTree = computeBoundsTree;
|
|
72
|
-
child.geometry.disposeBoundsTree = disposeBoundsTree;
|
|
73
|
-
child.geometry.computeBoundsTree(options);
|
|
74
|
-
}
|
|
75
|
-
});
|
|
76
|
-
return () => {
|
|
77
|
-
delete raycaster.firstHitOnly;
|
|
78
|
-
group.traverse(child => {
|
|
79
|
-
if (isMesh(child) && child.geometry.boundsTree) {
|
|
80
|
-
child.geometry.disposeBoundsTree();
|
|
81
|
-
child.raycast = Mesh.prototype.raycast;
|
|
82
|
-
}
|
|
83
|
-
});
|
|
84
|
-
};
|
|
85
|
-
}
|
|
86
|
-
}, []);
|
|
87
|
-
return /*#__PURE__*/React.createElement("group", _extends({
|
|
88
|
-
ref: ref
|
|
89
|
-
}, props), children);
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
export { Bvh, useBVH };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/extends"),t=require("three"),r=require("react"),n=require("@react-three/fiber"),o=require("camera-controls");function l(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function a(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var s=l(e),u=a(r),c=l(o);const i=r.forwardRef(((e,o)=>{const{impl:l,camera:a,domElement:i,makeDefault:d,onControlStart:f,onControl:m,onControlEnd:v,onTransitionStart:p,onUpdate:E,onWake:h,onRest:L,onSleep:b,onStart:C,onEnd:T,onChange:g,regress:j,...x}=e,y=null!=l?l:c.default;r.useMemo((()=>{const e={Box3:t.Box3,MathUtils:{clamp:t.MathUtils.clamp},Matrix4:t.Matrix4,Quaternion:t.Quaternion,Raycaster:t.Raycaster,Sphere:t.Sphere,Spherical:t.Spherical,Vector2:t.Vector2,Vector3:t.Vector3,Vector4:t.Vector4};y.install({THREE:e}),n.extend({CameraControlsImpl:y})}),[y]);const M=n.useThree((e=>e.camera)),O=n.useThree((e=>e.gl)),S=n.useThree((e=>e.invalidate)),V=n.useThree((e=>e.events)),k=n.useThree((e=>e.setEvents)),q=n.useThree((e=>e.set)),w=n.useThree((e=>e.get)),R=n.useThree((e=>e.performance)),P=a||M,_=i||V.connected||O.domElement,U=r.useMemo((()=>new y(P)),[y,P]);return n.useFrame(((e,t)=>{U.update(t)}),-1),r.useEffect((()=>(U.connect(_),()=>{U.disconnect()})),[_,U]),r.useEffect((()=>{function e(){S(),j&&R.regress()}const t=t=>{e(),null==f||f(t),null==C||C(t)},r=t=>{e(),null==m||m(t),null==g||g(t)},n=e=>{null==v||v(e),null==T||T(e)},o=t=>{e(),null==p||p(t),null==g||g(t)},l=t=>{e(),null==E||E(t),null==g||g(t)},a=t=>{e(),null==h||h(t),null==g||g(t)},s=e=>{null==L||L(e)},u=e=>{null==b||b(e)};return U.addEventListener("controlstart",t),U.addEventListener("control",r),U.addEventListener("controlend",n),U.addEventListener("transitionstart",o),U.addEventListener("update",l),U.addEventListener("wake",a),U.addEventListener("rest",s),U.addEventListener("sleep",u),()=>{U.removeEventListener("controlstart",t),U.removeEventListener("control",r),U.removeEventListener("controlend",n),U.removeEventListener("transitionstart",o),U.removeEventListener("update",l),U.removeEventListener("wake",a),U.removeEventListener("rest",s),U.removeEventListener("sleep",u)}}),[U,S,k,j,R,f,m,v,p,E,h,L,b,g,C,T]),r.useEffect((()=>{if(d){const e=w().controls;return q({controls:U}),()=>q({controls:e})}}),[d,U]),u.createElement("primitive",s.default({ref:o,object:U},x))}));Object.defineProperty(exports,"CameraControlsImpl",{enumerable:!0,get:function(){return c.default}}),exports.CameraControls=i;
|
package/core/CameraControls.d.ts
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { EventDispatcher, OrthographicCamera, PerspectiveCamera } from 'three';
|
|
2
|
-
import { ThreeElement } from '@react-three/fiber';
|
|
3
|
-
import CameraControlsImpl from 'camera-controls';
|
|
4
|
-
import { ForwardRefComponent, Overwrite } from '../helpers/ts-utils';
|
|
5
|
-
export type CameraControlsProps = Omit<Overwrite<ThreeElement<typeof CameraControlsImpl>, {
|
|
6
|
-
impl?: typeof CameraControlsImpl;
|
|
7
|
-
camera?: PerspectiveCamera | OrthographicCamera;
|
|
8
|
-
domElement?: HTMLElement;
|
|
9
|
-
makeDefault?: boolean;
|
|
10
|
-
onControlStart?: (e?: {
|
|
11
|
-
type: 'controlstart';
|
|
12
|
-
}) => void;
|
|
13
|
-
onControl?: (e?: {
|
|
14
|
-
type: 'control';
|
|
15
|
-
}) => void;
|
|
16
|
-
onControlEnd?: (e?: {
|
|
17
|
-
type: 'controlend';
|
|
18
|
-
}) => void;
|
|
19
|
-
onTransitionStart?: (e?: {
|
|
20
|
-
type: 'transitionstart';
|
|
21
|
-
}) => void;
|
|
22
|
-
onUpdate?: (e?: {
|
|
23
|
-
type: 'update';
|
|
24
|
-
}) => void;
|
|
25
|
-
onWake?: (e?: {
|
|
26
|
-
type: 'wake';
|
|
27
|
-
}) => void;
|
|
28
|
-
onRest?: (e?: {
|
|
29
|
-
type: 'rest';
|
|
30
|
-
}) => void;
|
|
31
|
-
onSleep?: (e?: {
|
|
32
|
-
type: 'sleep';
|
|
33
|
-
}) => void;
|
|
34
|
-
onStart?: (e?: {
|
|
35
|
-
type: 'controlstart';
|
|
36
|
-
}) => void;
|
|
37
|
-
onEnd?: (e?: {
|
|
38
|
-
type: 'controlend';
|
|
39
|
-
}) => void;
|
|
40
|
-
onChange?: (e?: {
|
|
41
|
-
type: string;
|
|
42
|
-
}) => void;
|
|
43
|
-
events?: boolean;
|
|
44
|
-
regress?: boolean;
|
|
45
|
-
}>, 'ref' | 'args' | keyof EventDispatcher>;
|
|
46
|
-
export declare const CameraControls: ForwardRefComponent<CameraControlsProps, CameraControlsImpl>;
|
|
47
|
-
export type CameraControls = CameraControlsImpl;
|
|
48
|
-
export { CameraControlsImpl };
|