@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/Caustics.js
DELETED
|
@@ -1,388 +0,0 @@
|
|
|
1
|
-
import _extends from '@babel/runtime/helpers/esm/extends';
|
|
2
|
-
import * as THREE from 'three';
|
|
3
|
-
import * as React from 'react';
|
|
4
|
-
import { extend, useThree, useFrame } from '@react-three/fiber';
|
|
5
|
-
import { useFBO } from './Fbo.js';
|
|
6
|
-
import { useHelper } from './Helper.js';
|
|
7
|
-
import { shaderMaterial } from './shaderMaterial.js';
|
|
8
|
-
import { Edges } from './Edges.js';
|
|
9
|
-
import { FullScreenQuad } from 'three-stdlib';
|
|
10
|
-
import { version } from '../helpers/constants.js';
|
|
11
|
-
|
|
12
|
-
function createNormalMaterial(side = THREE.FrontSide) {
|
|
13
|
-
const viewMatrix = {
|
|
14
|
-
value: new THREE.Matrix4()
|
|
15
|
-
};
|
|
16
|
-
return Object.assign(new THREE.MeshNormalMaterial({
|
|
17
|
-
side
|
|
18
|
-
}), {
|
|
19
|
-
viewMatrix,
|
|
20
|
-
onBeforeCompile: shader => {
|
|
21
|
-
shader.uniforms.viewMatrix = viewMatrix;
|
|
22
|
-
shader.fragmentShader = `vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {
|
|
23
|
-
return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );
|
|
24
|
-
}\n` + shader.fragmentShader.replace('#include <normal_fragment_maps>', `#include <normal_fragment_maps>
|
|
25
|
-
normal = inverseTransformDirection( normal, viewMatrix );\n`);
|
|
26
|
-
}
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
const CausticsProjectionMaterial = /* @__PURE__ */shaderMaterial({
|
|
30
|
-
causticsTexture: null,
|
|
31
|
-
causticsTextureB: null,
|
|
32
|
-
color: /* @__PURE__ */new THREE.Color(),
|
|
33
|
-
lightProjMatrix: /* @__PURE__ */new THREE.Matrix4(),
|
|
34
|
-
lightViewMatrix: /* @__PURE__ */new THREE.Matrix4()
|
|
35
|
-
}, `varying vec3 vWorldPosition;
|
|
36
|
-
void main() {
|
|
37
|
-
gl_Position = projectionMatrix * viewMatrix * modelMatrix * vec4(position, 1.);
|
|
38
|
-
vec4 worldPosition = modelMatrix * vec4(position, 1.);
|
|
39
|
-
vWorldPosition = worldPosition.xyz;
|
|
40
|
-
}`, `varying vec3 vWorldPosition;
|
|
41
|
-
uniform vec3 color;
|
|
42
|
-
uniform sampler2D causticsTexture;
|
|
43
|
-
uniform sampler2D causticsTextureB;
|
|
44
|
-
uniform mat4 lightProjMatrix;
|
|
45
|
-
uniform mat4 lightViewMatrix;
|
|
46
|
-
void main() {
|
|
47
|
-
// Apply caustics
|
|
48
|
-
vec4 lightSpacePos = lightProjMatrix * lightViewMatrix * vec4(vWorldPosition, 1.0);
|
|
49
|
-
lightSpacePos.xyz /= lightSpacePos.w;
|
|
50
|
-
lightSpacePos.xyz = lightSpacePos.xyz * 0.5 + 0.5;
|
|
51
|
-
vec3 front = texture2D(causticsTexture, lightSpacePos.xy).rgb;
|
|
52
|
-
vec3 back = texture2D(causticsTextureB, lightSpacePos.xy).rgb;
|
|
53
|
-
gl_FragColor = vec4((front + back) * color, 1.0);
|
|
54
|
-
#include <tonemapping_fragment>
|
|
55
|
-
#include <${version >= 154 ? 'colorspace_fragment' : 'encodings_fragment'}>
|
|
56
|
-
}`);
|
|
57
|
-
const CausticsMaterial = /* @__PURE__ */shaderMaterial({
|
|
58
|
-
cameraMatrixWorld: /* @__PURE__ */new THREE.Matrix4(),
|
|
59
|
-
cameraProjectionMatrixInv: /* @__PURE__ */new THREE.Matrix4(),
|
|
60
|
-
normalTexture: null,
|
|
61
|
-
depthTexture: null,
|
|
62
|
-
lightDir: /* @__PURE__ */new THREE.Vector3(0, 1, 0),
|
|
63
|
-
lightPlaneNormal: /* @__PURE__ */new THREE.Vector3(0, 1, 0),
|
|
64
|
-
lightPlaneConstant: 0,
|
|
65
|
-
near: 0.1,
|
|
66
|
-
far: 100,
|
|
67
|
-
modelMatrix: /* @__PURE__ */new THREE.Matrix4(),
|
|
68
|
-
worldRadius: 1 / 40,
|
|
69
|
-
ior: 1.1,
|
|
70
|
-
bounces: 0,
|
|
71
|
-
resolution: 1024,
|
|
72
|
-
size: 10,
|
|
73
|
-
intensity: 0.5
|
|
74
|
-
}, /* glsl */`
|
|
75
|
-
varying vec2 vUv;
|
|
76
|
-
void main() {
|
|
77
|
-
vUv = uv;
|
|
78
|
-
gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
|
|
79
|
-
}`, /* glsl */`
|
|
80
|
-
uniform mat4 cameraMatrixWorld;
|
|
81
|
-
uniform mat4 cameraProjectionMatrixInv;
|
|
82
|
-
uniform vec3 lightDir;
|
|
83
|
-
uniform vec3 lightPlaneNormal;
|
|
84
|
-
uniform float lightPlaneConstant;
|
|
85
|
-
uniform float near;
|
|
86
|
-
uniform float far;
|
|
87
|
-
uniform float time;
|
|
88
|
-
uniform float worldRadius;
|
|
89
|
-
uniform float resolution;
|
|
90
|
-
uniform float size;
|
|
91
|
-
uniform float intensity;
|
|
92
|
-
uniform float ior;
|
|
93
|
-
precision highp isampler2D;
|
|
94
|
-
precision highp usampler2D;
|
|
95
|
-
uniform sampler2D normalTexture;
|
|
96
|
-
uniform sampler2D depthTexture;
|
|
97
|
-
uniform float bounces;
|
|
98
|
-
varying vec2 vUv;
|
|
99
|
-
vec3 WorldPosFromDepth(float depth, vec2 coord) {
|
|
100
|
-
float z = depth * 2.0 - 1.0;
|
|
101
|
-
vec4 clipSpacePosition = vec4(coord * 2.0 - 1.0, z, 1.0);
|
|
102
|
-
vec4 viewSpacePosition = cameraProjectionMatrixInv * clipSpacePosition;
|
|
103
|
-
// Perspective division
|
|
104
|
-
viewSpacePosition /= viewSpacePosition.w;
|
|
105
|
-
vec4 worldSpacePosition = cameraMatrixWorld * viewSpacePosition;
|
|
106
|
-
return worldSpacePosition.xyz;
|
|
107
|
-
}
|
|
108
|
-
float sdPlane( vec3 p, vec3 n, float h ) {
|
|
109
|
-
// n must be normalized
|
|
110
|
-
return dot(p,n) + h;
|
|
111
|
-
}
|
|
112
|
-
float planeIntersect( vec3 ro, vec3 rd, vec4 p ) {
|
|
113
|
-
return -(dot(ro,p.xyz)+p.w)/dot(rd,p.xyz);
|
|
114
|
-
}
|
|
115
|
-
vec3 totalInternalReflection(vec3 ro, vec3 rd, vec3 pos, vec3 normal, float ior, out vec3 rayOrigin, out vec3 rayDirection) {
|
|
116
|
-
rayOrigin = ro;
|
|
117
|
-
rayDirection = rd;
|
|
118
|
-
rayDirection = refract(rayDirection, normal, 1.0 / ior);
|
|
119
|
-
rayOrigin = pos + rayDirection * 0.1;
|
|
120
|
-
return rayDirection;
|
|
121
|
-
}
|
|
122
|
-
void main() {
|
|
123
|
-
// Each sample consists of random offset in the x and y direction
|
|
124
|
-
float caustic = 0.0;
|
|
125
|
-
float causticTexelSize = (1.0 / resolution) * size * 2.0;
|
|
126
|
-
float texelsNeeded = worldRadius / causticTexelSize;
|
|
127
|
-
float sampleRadius = texelsNeeded / resolution;
|
|
128
|
-
float sum = 0.0;
|
|
129
|
-
if (texture2D(depthTexture, vUv).x == 1.0) {
|
|
130
|
-
gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);
|
|
131
|
-
return;
|
|
132
|
-
}
|
|
133
|
-
vec2 offset1 = vec2(-0.5, -0.5);//vec2(rand() - 0.5, rand() - 0.5);
|
|
134
|
-
vec2 offset2 = vec2(-0.5, 0.5);//vec2(rand() - 0.5, rand() - 0.5);
|
|
135
|
-
vec2 offset3 = vec2(0.5, 0.5);//vec2(rand() - 0.5, rand() - 0.5);
|
|
136
|
-
vec2 offset4 = vec2(0.5, -0.5);//vec2(rand() - 0.5, rand() - 0.5);
|
|
137
|
-
vec2 uv1 = vUv + offset1 * sampleRadius;
|
|
138
|
-
vec2 uv2 = vUv + offset2 * sampleRadius;
|
|
139
|
-
vec2 uv3 = vUv + offset3 * sampleRadius;
|
|
140
|
-
vec2 uv4 = vUv + offset4 * sampleRadius;
|
|
141
|
-
vec3 normal1 = texture2D(normalTexture, uv1, -10.0).rgb * 2.0 - 1.0;
|
|
142
|
-
vec3 normal2 = texture2D(normalTexture, uv2, -10.0).rgb * 2.0 - 1.0;
|
|
143
|
-
vec3 normal3 = texture2D(normalTexture, uv3, -10.0).rgb * 2.0 - 1.0;
|
|
144
|
-
vec3 normal4 = texture2D(normalTexture, uv4, -10.0).rgb * 2.0 - 1.0;
|
|
145
|
-
float depth1 = texture2D(depthTexture, uv1, -10.0).x;
|
|
146
|
-
float depth2 = texture2D(depthTexture, uv2, -10.0).x;
|
|
147
|
-
float depth3 = texture2D(depthTexture, uv3, -10.0).x;
|
|
148
|
-
float depth4 = texture2D(depthTexture, uv4, -10.0).x;
|
|
149
|
-
// Sanity check the depths
|
|
150
|
-
if (depth1 == 1.0 || depth2 == 1.0 || depth3 == 1.0 || depth4 == 1.0) {
|
|
151
|
-
gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);
|
|
152
|
-
return;
|
|
153
|
-
}
|
|
154
|
-
vec3 pos1 = WorldPosFromDepth(depth1, uv1);
|
|
155
|
-
vec3 pos2 = WorldPosFromDepth(depth2, uv2);
|
|
156
|
-
vec3 pos3 = WorldPosFromDepth(depth3, uv3);
|
|
157
|
-
vec3 pos4 = WorldPosFromDepth(depth4, uv4);
|
|
158
|
-
vec3 originPos1 = WorldPosFromDepth(0.0, uv1);
|
|
159
|
-
vec3 originPos2 = WorldPosFromDepth(0.0, uv2);
|
|
160
|
-
vec3 originPos3 = WorldPosFromDepth(0.0, uv3);
|
|
161
|
-
vec3 originPos4 = WorldPosFromDepth(0.0, uv4);
|
|
162
|
-
vec3 endPos1, endPos2, endPos3, endPos4;
|
|
163
|
-
vec3 endDir1, endDir2, endDir3, endDir4;
|
|
164
|
-
totalInternalReflection(originPos1, lightDir, pos1, normal1, ior, endPos1, endDir1);
|
|
165
|
-
totalInternalReflection(originPos2, lightDir, pos2, normal2, ior, endPos2, endDir2);
|
|
166
|
-
totalInternalReflection(originPos3, lightDir, pos3, normal3, ior, endPos3, endDir3);
|
|
167
|
-
totalInternalReflection(originPos4, lightDir, pos4, normal4, ior, endPos4, endDir4);
|
|
168
|
-
float lightPosArea = length(cross(originPos2 - originPos1, originPos3 - originPos1)) + length(cross(originPos3 - originPos1, originPos4 - originPos1));
|
|
169
|
-
float t1 = planeIntersect(endPos1, endDir1, vec4(lightPlaneNormal, lightPlaneConstant));
|
|
170
|
-
float t2 = planeIntersect(endPos2, endDir2, vec4(lightPlaneNormal, lightPlaneConstant));
|
|
171
|
-
float t3 = planeIntersect(endPos3, endDir3, vec4(lightPlaneNormal, lightPlaneConstant));
|
|
172
|
-
float t4 = planeIntersect(endPos4, endDir4, vec4(lightPlaneNormal, lightPlaneConstant));
|
|
173
|
-
vec3 finalPos1 = endPos1 + endDir1 * t1;
|
|
174
|
-
vec3 finalPos2 = endPos2 + endDir2 * t2;
|
|
175
|
-
vec3 finalPos3 = endPos3 + endDir3 * t3;
|
|
176
|
-
vec3 finalPos4 = endPos4 + endDir4 * t4;
|
|
177
|
-
float finalArea = length(cross(finalPos2 - finalPos1, finalPos3 - finalPos1)) + length(cross(finalPos3 - finalPos1, finalPos4 - finalPos1));
|
|
178
|
-
caustic += intensity * (lightPosArea / finalArea);
|
|
179
|
-
// Calculate the area of the triangle in light spaces
|
|
180
|
-
gl_FragColor = vec4(vec3(max(caustic, 0.0)), 1.0);
|
|
181
|
-
}`);
|
|
182
|
-
const NORMALPROPS = {
|
|
183
|
-
depth: true,
|
|
184
|
-
minFilter: THREE.LinearFilter,
|
|
185
|
-
magFilter: THREE.LinearFilter,
|
|
186
|
-
type: THREE.UnsignedByteType
|
|
187
|
-
};
|
|
188
|
-
const CAUSTICPROPS = {
|
|
189
|
-
minFilter: THREE.LinearMipmapLinearFilter,
|
|
190
|
-
magFilter: THREE.LinearFilter,
|
|
191
|
-
type: THREE.FloatType,
|
|
192
|
-
generateMipmaps: true
|
|
193
|
-
};
|
|
194
|
-
const Caustics = /* @__PURE__ */React.forwardRef(({
|
|
195
|
-
debug,
|
|
196
|
-
children,
|
|
197
|
-
frames = 1,
|
|
198
|
-
ior = 1.1,
|
|
199
|
-
color = 'white',
|
|
200
|
-
causticsOnly = false,
|
|
201
|
-
backside = false,
|
|
202
|
-
backsideIOR = 1.1,
|
|
203
|
-
worldRadius = 0.3125,
|
|
204
|
-
intensity = 0.05,
|
|
205
|
-
resolution = 2024,
|
|
206
|
-
lightSource = [5, 5, 5],
|
|
207
|
-
...props
|
|
208
|
-
}, fref) => {
|
|
209
|
-
extend({
|
|
210
|
-
CausticsProjectionMaterial
|
|
211
|
-
});
|
|
212
|
-
const ref = React.useRef(null);
|
|
213
|
-
const camera = React.useRef(null);
|
|
214
|
-
const scene = React.useRef(null);
|
|
215
|
-
const plane = React.useRef(null);
|
|
216
|
-
const gl = useThree(state => state.gl);
|
|
217
|
-
const helper = useHelper(debug && camera, THREE.CameraHelper);
|
|
218
|
-
|
|
219
|
-
// Buffers for front and back faces
|
|
220
|
-
const normalTarget = useFBO(resolution, resolution, NORMALPROPS);
|
|
221
|
-
const normalTargetB = useFBO(resolution, resolution, NORMALPROPS);
|
|
222
|
-
const causticsTarget = useFBO(resolution, resolution, CAUSTICPROPS);
|
|
223
|
-
const causticsTargetB = useFBO(resolution, resolution, CAUSTICPROPS);
|
|
224
|
-
// Normal materials for front and back faces
|
|
225
|
-
const [normalMat] = React.useState(() => createNormalMaterial());
|
|
226
|
-
const [normalMatB] = React.useState(() => createNormalMaterial(THREE.BackSide));
|
|
227
|
-
// The quad that catches the caustics
|
|
228
|
-
const [causticsMaterial] = React.useState(() => new CausticsMaterial());
|
|
229
|
-
const [causticsQuad] = React.useState(() => new FullScreenQuad(causticsMaterial));
|
|
230
|
-
React.useLayoutEffect(() => {
|
|
231
|
-
ref.current.updateWorldMatrix(false, true);
|
|
232
|
-
});
|
|
233
|
-
let count = 0;
|
|
234
|
-
const v = new THREE.Vector3();
|
|
235
|
-
const lpF = new THREE.Frustum();
|
|
236
|
-
const lpM = new THREE.Matrix4();
|
|
237
|
-
const lpP = new THREE.Plane();
|
|
238
|
-
const lightDir = new THREE.Vector3();
|
|
239
|
-
const lightDirInv = new THREE.Vector3();
|
|
240
|
-
const bounds = new THREE.Box3();
|
|
241
|
-
const focusPos = new THREE.Vector3();
|
|
242
|
-
const boundsVertices = [];
|
|
243
|
-
const worldVerts = [];
|
|
244
|
-
const projectedVerts = [];
|
|
245
|
-
const lightDirs = [];
|
|
246
|
-
const cameraPos = new THREE.Vector3();
|
|
247
|
-
for (let i = 0; i < 8; i++) {
|
|
248
|
-
boundsVertices.push(new THREE.Vector3());
|
|
249
|
-
worldVerts.push(new THREE.Vector3());
|
|
250
|
-
projectedVerts.push(new THREE.Vector3());
|
|
251
|
-
lightDirs.push(new THREE.Vector3());
|
|
252
|
-
}
|
|
253
|
-
useFrame(() => {
|
|
254
|
-
if (frames === Infinity || count++ < frames) {
|
|
255
|
-
var _scene$current$parent, _helper$current;
|
|
256
|
-
if (Array.isArray(lightSource)) lightDir.fromArray(lightSource).normalize();else lightDir.copy(ref.current.worldToLocal(lightSource.current.getWorldPosition(v)).normalize());
|
|
257
|
-
lightDirInv.copy(lightDir).multiplyScalar(-1);
|
|
258
|
-
(_scene$current$parent = scene.current.parent) == null || _scene$current$parent.matrixWorld.identity();
|
|
259
|
-
bounds.setFromObject(scene.current, true);
|
|
260
|
-
boundsVertices[0].set(bounds.min.x, bounds.min.y, bounds.min.z);
|
|
261
|
-
boundsVertices[1].set(bounds.min.x, bounds.min.y, bounds.max.z);
|
|
262
|
-
boundsVertices[2].set(bounds.min.x, bounds.max.y, bounds.min.z);
|
|
263
|
-
boundsVertices[3].set(bounds.min.x, bounds.max.y, bounds.max.z);
|
|
264
|
-
boundsVertices[4].set(bounds.max.x, bounds.min.y, bounds.min.z);
|
|
265
|
-
boundsVertices[5].set(bounds.max.x, bounds.min.y, bounds.max.z);
|
|
266
|
-
boundsVertices[6].set(bounds.max.x, bounds.max.y, bounds.min.z);
|
|
267
|
-
boundsVertices[7].set(bounds.max.x, bounds.max.y, bounds.max.z);
|
|
268
|
-
for (let i = 0; i < 8; i++) {
|
|
269
|
-
worldVerts[i].copy(boundsVertices[i]);
|
|
270
|
-
}
|
|
271
|
-
bounds.getCenter(focusPos);
|
|
272
|
-
boundsVertices.map(v => v.sub(focusPos));
|
|
273
|
-
const lightPlane = lpP.set(lightDirInv, 0);
|
|
274
|
-
boundsVertices.map((v, i) => lightPlane.projectPoint(v, projectedVerts[i]));
|
|
275
|
-
const centralVert = projectedVerts.reduce((a, b) => a.add(b), v.set(0, 0, 0)).divideScalar(projectedVerts.length);
|
|
276
|
-
const radius = projectedVerts.map(v => v.distanceTo(centralVert)).reduce((a, b) => Math.max(a, b));
|
|
277
|
-
const dirLength = boundsVertices.map(x => x.dot(lightDir)).reduce((a, b) => Math.max(a, b));
|
|
278
|
-
// Shadows
|
|
279
|
-
camera.current.position.copy(cameraPos.copy(lightDir).multiplyScalar(dirLength).add(focusPos));
|
|
280
|
-
camera.current.lookAt(scene.current.localToWorld(focusPos));
|
|
281
|
-
const dirMatrix = lpM.lookAt(camera.current.position, focusPos, v.set(0, 1, 0));
|
|
282
|
-
camera.current.left = -radius;
|
|
283
|
-
camera.current.right = radius;
|
|
284
|
-
camera.current.top = radius;
|
|
285
|
-
camera.current.bottom = -radius;
|
|
286
|
-
const yOffset = v.set(0, radius, 0).applyMatrix4(dirMatrix);
|
|
287
|
-
const yTime = (camera.current.position.y + yOffset.y) / lightDir.y;
|
|
288
|
-
camera.current.near = 0.1;
|
|
289
|
-
camera.current.far = yTime;
|
|
290
|
-
camera.current.updateProjectionMatrix();
|
|
291
|
-
camera.current.updateMatrixWorld();
|
|
292
|
-
|
|
293
|
-
// Now find size of ground plane
|
|
294
|
-
const groundProjectedCoords = worldVerts.map((v, i) => v.add(lightDirs[i].copy(lightDir).multiplyScalar(-v.y / lightDir.y)));
|
|
295
|
-
const centerPos = groundProjectedCoords.reduce((a, b) => a.add(b), v.set(0, 0, 0)).divideScalar(groundProjectedCoords.length);
|
|
296
|
-
const maxSize = 2 * groundProjectedCoords.map(v => Math.hypot(v.x - centerPos.x, v.z - centerPos.z)).reduce((a, b) => Math.max(a, b));
|
|
297
|
-
plane.current.scale.setScalar(maxSize);
|
|
298
|
-
plane.current.position.copy(centerPos);
|
|
299
|
-
if (debug) (_helper$current = helper.current) == null || _helper$current.update();
|
|
300
|
-
|
|
301
|
-
// Inject uniforms
|
|
302
|
-
normalMatB.viewMatrix.value = normalMat.viewMatrix.value = camera.current.matrixWorldInverse;
|
|
303
|
-
const dirLightNearPlane = lpF.setFromProjectionMatrix(lpM.multiplyMatrices(camera.current.projectionMatrix, camera.current.matrixWorldInverse)).planes[4];
|
|
304
|
-
causticsMaterial.cameraMatrixWorld = camera.current.matrixWorld;
|
|
305
|
-
causticsMaterial.cameraProjectionMatrixInv = camera.current.projectionMatrixInverse;
|
|
306
|
-
causticsMaterial.lightDir = lightDirInv;
|
|
307
|
-
causticsMaterial.lightPlaneNormal = dirLightNearPlane.normal;
|
|
308
|
-
causticsMaterial.lightPlaneConstant = dirLightNearPlane.constant;
|
|
309
|
-
causticsMaterial.near = camera.current.near;
|
|
310
|
-
causticsMaterial.far = camera.current.far;
|
|
311
|
-
causticsMaterial.resolution = resolution;
|
|
312
|
-
causticsMaterial.size = radius;
|
|
313
|
-
causticsMaterial.intensity = intensity;
|
|
314
|
-
causticsMaterial.worldRadius = worldRadius;
|
|
315
|
-
|
|
316
|
-
// Switch the scene on
|
|
317
|
-
scene.current.visible = true;
|
|
318
|
-
|
|
319
|
-
// Render front face normals
|
|
320
|
-
gl.setRenderTarget(normalTarget);
|
|
321
|
-
gl.clear();
|
|
322
|
-
scene.current.overrideMaterial = normalMat;
|
|
323
|
-
gl.render(scene.current, camera.current);
|
|
324
|
-
|
|
325
|
-
// Render back face normals, if enabled
|
|
326
|
-
gl.setRenderTarget(normalTargetB);
|
|
327
|
-
gl.clear();
|
|
328
|
-
if (backside) {
|
|
329
|
-
scene.current.overrideMaterial = normalMatB;
|
|
330
|
-
gl.render(scene.current, camera.current);
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
// Remove the override material
|
|
334
|
-
scene.current.overrideMaterial = null;
|
|
335
|
-
|
|
336
|
-
// Render front face caustics
|
|
337
|
-
causticsMaterial.ior = ior;
|
|
338
|
-
plane.current.material.lightProjMatrix = camera.current.projectionMatrix;
|
|
339
|
-
plane.current.material.lightViewMatrix = camera.current.matrixWorldInverse;
|
|
340
|
-
causticsMaterial.normalTexture = normalTarget.texture;
|
|
341
|
-
causticsMaterial.depthTexture = normalTarget.depthTexture;
|
|
342
|
-
gl.setRenderTarget(causticsTarget);
|
|
343
|
-
gl.clear();
|
|
344
|
-
causticsQuad.render(gl);
|
|
345
|
-
|
|
346
|
-
// Render back face caustics, if enabled
|
|
347
|
-
causticsMaterial.ior = backsideIOR;
|
|
348
|
-
causticsMaterial.normalTexture = normalTargetB.texture;
|
|
349
|
-
causticsMaterial.depthTexture = normalTargetB.depthTexture;
|
|
350
|
-
gl.setRenderTarget(causticsTargetB);
|
|
351
|
-
gl.clear();
|
|
352
|
-
if (backside) causticsQuad.render(gl);
|
|
353
|
-
|
|
354
|
-
// Reset render target
|
|
355
|
-
gl.setRenderTarget(null);
|
|
356
|
-
|
|
357
|
-
// Switch the scene off if caustics is all that's wanted
|
|
358
|
-
if (causticsOnly) scene.current.visible = false;
|
|
359
|
-
}
|
|
360
|
-
});
|
|
361
|
-
React.useImperativeHandle(fref, () => ref.current, []);
|
|
362
|
-
return /*#__PURE__*/React.createElement("group", _extends({
|
|
363
|
-
ref: ref
|
|
364
|
-
}, props), /*#__PURE__*/React.createElement("scene", {
|
|
365
|
-
ref: scene
|
|
366
|
-
}, /*#__PURE__*/React.createElement("orthographicCamera", {
|
|
367
|
-
ref: camera,
|
|
368
|
-
up: [0, 1, 0]
|
|
369
|
-
}), children), /*#__PURE__*/React.createElement("mesh", {
|
|
370
|
-
renderOrder: 2,
|
|
371
|
-
ref: plane,
|
|
372
|
-
"rotation-x": -Math.PI / 2
|
|
373
|
-
}, /*#__PURE__*/React.createElement("planeGeometry", null), /*#__PURE__*/React.createElement("causticsProjectionMaterial", {
|
|
374
|
-
transparent: true,
|
|
375
|
-
color: color,
|
|
376
|
-
causticsTexture: causticsTarget.texture,
|
|
377
|
-
causticsTextureB: causticsTargetB.texture,
|
|
378
|
-
blending: THREE.CustomBlending,
|
|
379
|
-
blendSrc: THREE.OneFactor,
|
|
380
|
-
blendDst: THREE.SrcAlphaFactor,
|
|
381
|
-
depthWrite: false
|
|
382
|
-
}), debug && /*#__PURE__*/React.createElement(Edges, null, /*#__PURE__*/React.createElement("lineBasicMaterial", {
|
|
383
|
-
color: "#ffff00",
|
|
384
|
-
toneMapped: false
|
|
385
|
-
}))));
|
|
386
|
-
});
|
|
387
|
-
|
|
388
|
-
export { Caustics };
|
package/core/Center.cjs.js
DELETED
|
@@ -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");function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function u(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),i=u(r);const c=i.forwardRef((function({children:e,object:r,disable:n,disableX:u,disableY:c,disableZ:a,left:l,right:s,top:f,bottom:d,front:p,back:b,onCentered:m,precise:g=!0,cacheKey:h=0,...x},y){const j=i.useRef(null),O=i.useRef(null),v=i.useRef(null),[w]=i.useState((()=>new t.Box3)),[S]=i.useState((()=>new t.Vector3)),[z]=i.useState((()=>new t.Sphere));return i.useLayoutEffect((()=>{O.current.matrixWorld.identity(),w.setFromObject(null!=r?r:v.current,g);const e=w.max.x-w.min.x,t=w.max.y-w.min.y,o=w.max.z-w.min.z;w.getCenter(S),w.getBoundingSphere(z);const i=f?t/2:d?-t/2:0,h=l?-e/2:s?e/2:0,x=p?o/2:b?-o/2:0;O.current.position.set(n||u?0:-S.x+h,n||c?0:-S.y+i,n||a?0:-S.z+x),null==m||m({parent:j.current.parent,container:j.current,width:e,height:t,depth:o,boundingBox:w,boundingSphere:z,center:S,verticalAlignment:i,horizontalAlignment:h,depthAlignment:x})}),[h,m,f,l,p,n,u,c,a,r,g,s,d,b,w,S,z]),i.useImperativeHandle(y,(()=>j.current),[]),i.createElement("group",o.default({ref:j},x),i.createElement("group",{ref:O},i.createElement("group",{ref:v},e)))}));exports.Center=c;
|
package/core/Center.d.ts
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { Box3, Vector3, Sphere, Group, Object3D } from 'three';
|
|
2
|
-
import { ThreeElements } from '@react-three/fiber';
|
|
3
|
-
import { ForwardRefComponent } from '../helpers/ts-utils';
|
|
4
|
-
export type OnCenterCallbackProps = {
|
|
5
|
-
parent: Object3D;
|
|
6
|
-
container: Object3D;
|
|
7
|
-
width: number;
|
|
8
|
-
height: number;
|
|
9
|
-
depth: number;
|
|
10
|
-
boundingBox: Box3;
|
|
11
|
-
boundingSphere: Sphere;
|
|
12
|
-
center: Vector3;
|
|
13
|
-
verticalAlignment: number;
|
|
14
|
-
horizontalAlignment: number;
|
|
15
|
-
depthAlignment: number;
|
|
16
|
-
};
|
|
17
|
-
export type CenterProps = Omit<ThreeElements['group'], 'ref'> & {
|
|
18
|
-
top?: boolean;
|
|
19
|
-
right?: boolean;
|
|
20
|
-
bottom?: boolean;
|
|
21
|
-
left?: boolean;
|
|
22
|
-
front?: boolean;
|
|
23
|
-
back?: boolean;
|
|
24
|
-
disable?: boolean;
|
|
25
|
-
disableX?: boolean;
|
|
26
|
-
disableY?: boolean;
|
|
27
|
-
disableZ?: boolean;
|
|
28
|
-
object?: Object3D | null;
|
|
29
|
-
precise?: boolean;
|
|
30
|
-
onCentered?: (props: OnCenterCallbackProps) => void;
|
|
31
|
-
cacheKey?: any;
|
|
32
|
-
};
|
|
33
|
-
export declare const Center: ForwardRefComponent<CenterProps, Group>;
|
package/core/Center.js
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import _extends from '@babel/runtime/helpers/esm/extends';
|
|
2
|
-
import { Box3, Vector3, Sphere } from 'three';
|
|
3
|
-
import * as React from 'react';
|
|
4
|
-
|
|
5
|
-
const Center = /* @__PURE__ */React.forwardRef(function Center({
|
|
6
|
-
children,
|
|
7
|
-
object,
|
|
8
|
-
disable,
|
|
9
|
-
disableX,
|
|
10
|
-
disableY,
|
|
11
|
-
disableZ,
|
|
12
|
-
left,
|
|
13
|
-
right,
|
|
14
|
-
top,
|
|
15
|
-
bottom,
|
|
16
|
-
front,
|
|
17
|
-
back,
|
|
18
|
-
onCentered,
|
|
19
|
-
precise = true,
|
|
20
|
-
cacheKey = 0,
|
|
21
|
-
...props
|
|
22
|
-
}, fRef) {
|
|
23
|
-
const ref = React.useRef(null);
|
|
24
|
-
const outer = React.useRef(null);
|
|
25
|
-
const inner = React.useRef(null);
|
|
26
|
-
const [box3] = React.useState(() => new Box3());
|
|
27
|
-
const [center] = React.useState(() => new Vector3());
|
|
28
|
-
const [sphere] = React.useState(() => new Sphere());
|
|
29
|
-
React.useLayoutEffect(() => {
|
|
30
|
-
outer.current.matrixWorld.identity();
|
|
31
|
-
box3.setFromObject(object !== null && object !== void 0 ? object : inner.current, precise);
|
|
32
|
-
const width = box3.max.x - box3.min.x;
|
|
33
|
-
const height = box3.max.y - box3.min.y;
|
|
34
|
-
const depth = box3.max.z - box3.min.z;
|
|
35
|
-
box3.getCenter(center);
|
|
36
|
-
box3.getBoundingSphere(sphere);
|
|
37
|
-
const vAlign = top ? height / 2 : bottom ? -height / 2 : 0;
|
|
38
|
-
const hAlign = left ? -width / 2 : right ? width / 2 : 0;
|
|
39
|
-
const dAlign = front ? depth / 2 : back ? -depth / 2 : 0;
|
|
40
|
-
outer.current.position.set(disable || disableX ? 0 : -center.x + hAlign, disable || disableY ? 0 : -center.y + vAlign, disable || disableZ ? 0 : -center.z + dAlign);
|
|
41
|
-
|
|
42
|
-
// Only fire onCentered if the bounding box has changed
|
|
43
|
-
onCentered == null || onCentered({
|
|
44
|
-
parent: ref.current.parent,
|
|
45
|
-
container: ref.current,
|
|
46
|
-
width,
|
|
47
|
-
height,
|
|
48
|
-
depth,
|
|
49
|
-
boundingBox: box3,
|
|
50
|
-
boundingSphere: sphere,
|
|
51
|
-
center: center,
|
|
52
|
-
verticalAlignment: vAlign,
|
|
53
|
-
horizontalAlignment: hAlign,
|
|
54
|
-
depthAlignment: dAlign
|
|
55
|
-
});
|
|
56
|
-
}, [cacheKey, onCentered, top, left, front, disable, disableX, disableY, disableZ, object, precise, right, bottom, back, box3, center, sphere]);
|
|
57
|
-
React.useImperativeHandle(fRef, () => ref.current, []);
|
|
58
|
-
return /*#__PURE__*/React.createElement("group", _extends({
|
|
59
|
-
ref: ref
|
|
60
|
-
}, props), /*#__PURE__*/React.createElement("group", {
|
|
61
|
-
ref: outer
|
|
62
|
-
}, /*#__PURE__*/React.createElement("group", {
|
|
63
|
-
ref: inner
|
|
64
|
-
}, children)));
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
export { Center };
|
package/core/Clone.cjs.js
DELETED
|
@@ -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("three-stdlib");function a(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function i(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=a(e),c=i(t),l=i(r);const s=l.forwardRef((({isChild:e=!1,object:t,children:r,deep:a,castShadow:i,receiveShadow:d,inject:u,keys:f,...y},m)=>{const h={keys:f,deep:a,inject:u,castShadow:i,receiveShadow:d};if(t=l.useMemo((()=>{if(!1===e&&!Array.isArray(t)){let e=!1;if(t.traverse((t=>{t.isSkinnedMesh&&(e=!0)})),e)return n.SkeletonUtils.clone(t)}return t}),[t,e]),Array.isArray(t))return l.createElement("group",o.default({},y,{ref:m}),t.map((e=>l.createElement(s,o.default({key:e.uuid,object:e},h)))),r);const{children:p,...b}=function(e,{keys:t=["near","far","color","distance","decay","penumbra","angle","intensity","skeleton","visible","castShadow","receiveShadow","morphTargetDictionary","morphTargetInfluences","name","geometry","material","position","rotation","scale","up","userData","bindMode","bindMatrix","bindMatrixInverse","skeleton"],deep:r,inject:n,castShadow:a,receiveShadow:i}){let o={};for(const r of t)o[r]=e[r];return r&&(o.geometry&&"materialsOnly"!==r&&(o.geometry=o.geometry.clone()),o.material&&"geometriesOnly"!==r&&(o.material=o.material.clone())),n&&(o="function"==typeof n?{...o,children:n(e)}:l.isValidElement(n)?{...o,children:n}:{...o,...n}),e instanceof c.Mesh&&(a&&(o.castShadow=!0),i&&(o.receiveShadow=!0)),o}(t,h),j=t.type[0].toLowerCase()+t.type.slice(1);return l.createElement(j,o.default({},b,y,{ref:m}),t.children.map((e=>"Bone"===e.type?l.createElement("primitive",o.default({key:e.uuid,object:e},h)):l.createElement(s,o.default({key:e.uuid,object:e},h,{isChild:!0})))),r,p)}));exports.Clone=s;
|
package/core/Clone.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import * as THREE from 'three';
|
|
2
|
-
import * as React from 'react';
|
|
3
|
-
import { ForwardRefComponent } from '../helpers/ts-utils';
|
|
4
|
-
import { ThreeElements } from '@react-three/fiber';
|
|
5
|
-
export type CloneProps = Omit<ThreeElements['group'], 'ref' | 'children'> & {
|
|
6
|
-
object: THREE.Object3D | THREE.Object3D[];
|
|
7
|
-
children?: React.ReactNode;
|
|
8
|
-
deep?: boolean | 'materialsOnly' | 'geometriesOnly';
|
|
9
|
-
keys?: string[];
|
|
10
|
-
inject?: ThreeElements['mesh'] | React.ReactNode | ((object: THREE.Object3D) => React.ReactNode);
|
|
11
|
-
castShadow?: boolean;
|
|
12
|
-
receiveShadow?: boolean;
|
|
13
|
-
isChild?: boolean;
|
|
14
|
-
};
|
|
15
|
-
export declare const Clone: ForwardRefComponent<CloneProps, THREE.Group>;
|
package/core/Clone.js
DELETED
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
import _extends from '@babel/runtime/helpers/esm/extends';
|
|
2
|
-
import * as THREE from 'three';
|
|
3
|
-
import * as React from 'react';
|
|
4
|
-
import { SkeletonUtils } from 'three-stdlib';
|
|
5
|
-
|
|
6
|
-
function createSpread(child, {
|
|
7
|
-
keys = ['near', 'far', 'color', 'distance', 'decay', 'penumbra', 'angle', 'intensity', 'skeleton', 'visible', 'castShadow', 'receiveShadow', 'morphTargetDictionary', 'morphTargetInfluences', 'name', 'geometry', 'material', 'position', 'rotation', 'scale', 'up', 'userData', 'bindMode', 'bindMatrix', 'bindMatrixInverse', 'skeleton'],
|
|
8
|
-
deep,
|
|
9
|
-
inject,
|
|
10
|
-
castShadow,
|
|
11
|
-
receiveShadow
|
|
12
|
-
}) {
|
|
13
|
-
let spread = {};
|
|
14
|
-
for (const key of keys) {
|
|
15
|
-
spread[key] = child[key];
|
|
16
|
-
}
|
|
17
|
-
if (deep) {
|
|
18
|
-
if (spread.geometry && deep !== 'materialsOnly') spread.geometry = spread.geometry.clone();
|
|
19
|
-
if (spread.material && deep !== 'geometriesOnly') spread.material = spread.material.clone();
|
|
20
|
-
}
|
|
21
|
-
if (inject) {
|
|
22
|
-
if (typeof inject === 'function') spread = {
|
|
23
|
-
...spread,
|
|
24
|
-
children: inject(child)
|
|
25
|
-
};else if (/*#__PURE__*/React.isValidElement(inject)) spread = {
|
|
26
|
-
...spread,
|
|
27
|
-
children: inject
|
|
28
|
-
};else spread = {
|
|
29
|
-
...spread,
|
|
30
|
-
...inject
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
if (child instanceof THREE.Mesh) {
|
|
34
|
-
if (castShadow) spread.castShadow = true;
|
|
35
|
-
if (receiveShadow) spread.receiveShadow = true;
|
|
36
|
-
}
|
|
37
|
-
return spread;
|
|
38
|
-
}
|
|
39
|
-
const Clone = /* @__PURE__ */React.forwardRef(({
|
|
40
|
-
isChild = false,
|
|
41
|
-
object,
|
|
42
|
-
children,
|
|
43
|
-
deep,
|
|
44
|
-
castShadow,
|
|
45
|
-
receiveShadow,
|
|
46
|
-
inject,
|
|
47
|
-
keys,
|
|
48
|
-
...props
|
|
49
|
-
}, forwardRef) => {
|
|
50
|
-
const config = {
|
|
51
|
-
keys,
|
|
52
|
-
deep,
|
|
53
|
-
inject,
|
|
54
|
-
castShadow,
|
|
55
|
-
receiveShadow
|
|
56
|
-
};
|
|
57
|
-
object = React.useMemo(() => {
|
|
58
|
-
if (isChild === false && !Array.isArray(object)) {
|
|
59
|
-
let isSkinned = false;
|
|
60
|
-
object.traverse(object => {
|
|
61
|
-
if (object.isSkinnedMesh) isSkinned = true;
|
|
62
|
-
});
|
|
63
|
-
if (isSkinned) return SkeletonUtils.clone(object);
|
|
64
|
-
}
|
|
65
|
-
return object;
|
|
66
|
-
}, [object, isChild]);
|
|
67
|
-
|
|
68
|
-
// Deal with arrayed clones
|
|
69
|
-
if (Array.isArray(object)) {
|
|
70
|
-
return /*#__PURE__*/React.createElement("group", _extends({}, props, {
|
|
71
|
-
ref: forwardRef
|
|
72
|
-
}), object.map(o => /*#__PURE__*/React.createElement(Clone, _extends({
|
|
73
|
-
key: o.uuid,
|
|
74
|
-
object: o
|
|
75
|
-
}, config))), children);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
// Singleton clones
|
|
79
|
-
const {
|
|
80
|
-
children: injectChildren,
|
|
81
|
-
...spread
|
|
82
|
-
} = createSpread(object, config);
|
|
83
|
-
const Element = object.type[0].toLowerCase() + object.type.slice(1);
|
|
84
|
-
return /*#__PURE__*/React.createElement(Element, _extends({}, spread, props, {
|
|
85
|
-
ref: forwardRef
|
|
86
|
-
}), object.children.map(child => {
|
|
87
|
-
if (child.type === 'Bone') return /*#__PURE__*/React.createElement("primitive", _extends({
|
|
88
|
-
key: child.uuid,
|
|
89
|
-
object: child
|
|
90
|
-
}, config));
|
|
91
|
-
return /*#__PURE__*/React.createElement(Clone, _extends({
|
|
92
|
-
key: child.uuid,
|
|
93
|
-
object: child
|
|
94
|
-
}, config, {
|
|
95
|
-
isChild: true
|
|
96
|
-
}));
|
|
97
|
-
}), children, injectChildren);
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
export { Clone };
|
package/core/Cloud.cjs.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/extends"),t=require("react"),r=require("three"),n=require("@react-three/fiber"),a=require("./Texture.cjs.js"),o=require("../helpers/deprecated.cjs.js");function u(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function c(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 l=u(e),i=c(t);const s=new r.Matrix4,d=new r.Vector3,f=new r.Quaternion,m=new r.Vector3,p=new r.Quaternion,g=new r.Vector3,h=i.createContext(null),y=i.forwardRef((({children:e,material:t=r.MeshLambertMaterial,texture:u="https://rawcdn.githack.com/pmndrs/drei-assets/9225a9f1fbd449d9411125c2f419b843d0308c9f/cloud.png",range:c,limit:y=200,frustumCulled:x,...v},b)=>{var M,w;const C=i.useMemo((()=>class extends t{constructor(){super();const e=parseInt(r.REVISION.replace(/\D+/g,""))>=154?"opaque_fragment":"output_fragment";this.onBeforeCompile=t=>{t.vertexShader="attribute float cloudOpacity;\n varying float vOpacity;\n "+t.vertexShader.replace("#include <fog_vertex>","#include <fog_vertex>\n vOpacity = cloudOpacity;\n "),t.fragmentShader="varying float vOpacity;\n "+t.fragmentShader.replace(`#include <${e}>`,`#include <${e}>\n gl_FragColor = vec4(outgoingLight, diffuseColor.a * vOpacity);\n `)}}}),[t]);n.extend({CloudMaterial:C});const E=i.useRef(null),O=i.useRef([]),A=i.useMemo((()=>new Float32Array(Array.from({length:y},(()=>1)))),[y]),j=i.useMemo((()=>new Float32Array(Array.from({length:y},(()=>[1,1,1])).flat())),[y]),R=a.useTexture(u);let U,V=0,_=0;const q=new r.Quaternion,F=new r.Vector3(0,0,1),I=new r.Vector3;n.useFrame(((e,t)=>{for(V=e.clock.elapsedTime,s.copy(E.current.matrixWorld).invert(),e.camera.matrixWorld.decompose(m,p,g),_=0;_<O.current.length;_++)U=O.current[_],U.ref.current.matrixWorld.decompose(d,f,g),d.add(I.copy(U.position).applyQuaternion(f).multiply(g)),f.copy(p).multiply(q.setFromAxisAngle(F,U.rotation+=t*U.rotationFactor)),g.multiplyScalar(U.volume+(1+Math.sin(V*U.density*U.speed))/2*U.growth),U.matrix.compose(d,f,g).premultiply(s),U.dist=d.distanceTo(m);for(O.current.sort(((e,t)=>t.dist-e.dist)),_=0;_<O.current.length;_++)U=O.current[_],A[_]=U.opacity*(U.dist<U.fade-1?U.dist/U.fade:1),E.current.setMatrixAt(_,U.matrix),E.current.setColorAt(_,U.color);E.current.geometry.attributes.cloudOpacity.needsUpdate=!0,E.current.instanceMatrix.needsUpdate=!0,E.current.instanceColor&&(E.current.instanceColor.needsUpdate=!0)})),i.useLayoutEffect((()=>{const e=Math.min(y,void 0!==c?c:y,O.current.length);E.current.count=e,o.setUpdateRange(E.current.instanceMatrix,{start:0,count:16*e}),E.current.instanceColor&&o.setUpdateRange(E.current.instanceColor,{start:0,count:3*e}),o.setUpdateRange(E.current.geometry.attributes.cloudOpacity,{start:0,count:e})}));let D=[null!==(M=R.image.width)&&void 0!==M?M:1,null!==(w=R.image.height)&&void 0!==w?w:1];const P=Math.max(D[0],D[1]);return D=[D[0]/P,D[1]/P],i.createElement("group",l.default({ref:b},v),i.createElement(h.Provider,{value:O},e,i.createElement("instancedMesh",{matrixAutoUpdate:!1,ref:E,args:[null,null,y],frustumCulled:x},i.createElement("instancedBufferAttribute",{usage:r.DynamicDrawUsage,attach:"instanceColor",args:[j,3]}),i.createElement("planeGeometry",{args:[...D]},i.createElement("instancedBufferAttribute",{usage:r.DynamicDrawUsage,attach:"attributes-cloudOpacity",args:[A,1]})),i.createElement("cloudMaterial",{key:t.name,map:R,transparent:!0,depthWrite:!1}))))})),x=i.forwardRef((({opacity:e=1,speed:t=0,bounds:a=[5,1,1],segments:o=20,color:u="#ffffff",fade:c=10,volume:s=6,smallestVolume:d=.25,distribute:f=null,growth:m=4,concentrate:p="inside",seed:g=Math.random(),...y},x)=>{function v(){const e=1e4*Math.sin(g++);return e-Math.floor(e)}const b=i.useContext(h),M=i.useRef(null),w=i.useId(),C=i.useMemo((()=>[...new Array(o)].map(((e,t)=>({segments:o,bounds:new r.Vector3(1,1,1),position:new r.Vector3,uuid:w,index:t,ref:M,dist:0,matrix:new r.Matrix4,color:new r.Color,rotation:t*(Math.PI/o)})))),[o,w]);return i.useLayoutEffect((()=>{C.forEach(((r,l)=>{n.applyProps(r,{volume:s,color:u,speed:t,growth:m,opacity:e,fade:c,bounds:a,density:Math.max(.5,v()),rotationFactor:Math.max(.2,.5*v())*t});const i=null==f?void 0:f(r,l);var g;(i||o>1)&&r.position.copy(r.bounds).multiply(null!==(g=null==i?void 0:i.point)&&void 0!==g?g:{x:2*v()-1,y:2*v()-1,z:2*v()-1});const h=Math.abs(r.position.x),y=Math.abs(r.position.y),x=Math.abs(r.position.z),b=Math.max(h,y,x);r.length=1,h===b&&(r.length-=h/r.bounds.x),y===b&&(r.length-=y/r.bounds.y),x===b&&(r.length-=x/r.bounds.z),r.volume=(void 0!==(null==i?void 0:i.volume)?i.volume:Math.max(Math.max(0,d),"random"===p?v():"inside"===p?r.length:1-r.length))*s}))}),[p,a,c,u,e,m,s,g,o,t]),i.useLayoutEffect((()=>{const e=C;return b.current=[...b.current,...e],()=>{b.current=b.current.filter((e=>e.uuid!==w))}}),[C]),i.useImperativeHandle(x,(()=>M.current),[]),i.createElement("group",l.default({ref:M},y))})),v=i.forwardRef(((e,t)=>i.useContext(h)?i.createElement(x,l.default({ref:t},e)):i.createElement(y,null,i.createElement(x,l.default({ref:t},e)))));exports.Cloud=v,exports.CloudInstance=x,exports.Clouds=y;
|