@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
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import * as THREE from 'three';
|
|
2
|
-
import * as React from 'react';
|
|
3
|
-
import { ReactThreeFiber, ThreeElements } from '@react-three/fiber';
|
|
4
|
-
import { MeshRefractionMaterial as MeshRefractionMaterial_ } from '../materials/MeshRefractionMaterial';
|
|
5
|
-
declare module '@react-three/fiber' {
|
|
6
|
-
interface ThreeElements {
|
|
7
|
-
meshRefractionMaterial: typeof MeshRefractionMaterial_;
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
export type MeshRefractionMaterialProps = ThreeElements['shaderMaterial'] & {
|
|
11
|
-
envMap: THREE.CubeTexture | THREE.Texture;
|
|
12
|
-
bounces?: number;
|
|
13
|
-
ior?: number;
|
|
14
|
-
fresnel?: number;
|
|
15
|
-
aberrationStrength?: number;
|
|
16
|
-
color?: ReactThreeFiber.Color;
|
|
17
|
-
fastChroma?: boolean;
|
|
18
|
-
};
|
|
19
|
-
export declare function MeshRefractionMaterial({ aberrationStrength, fastChroma, envMap, ...props }: MeshRefractionMaterialProps): React.JSX.Element;
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import _extends from '@babel/runtime/helpers/esm/extends';
|
|
2
|
-
import * as React from 'react';
|
|
3
|
-
import { useRef, useMemo, useLayoutEffect } from 'react';
|
|
4
|
-
import { extend, useThree, useFrame } from '@react-three/fiber';
|
|
5
|
-
import { MeshBVHUniformStruct, MeshBVH, SAH } from 'three-mesh-bvh';
|
|
6
|
-
import { MeshRefractionMaterial as MeshRefractionMaterial$1 } from '../materials/MeshRefractionMaterial.js';
|
|
7
|
-
|
|
8
|
-
const isCubeTexture = def => def && def.isCubeTexture;
|
|
9
|
-
function MeshRefractionMaterial({
|
|
10
|
-
aberrationStrength = 0,
|
|
11
|
-
fastChroma = true,
|
|
12
|
-
envMap,
|
|
13
|
-
...props
|
|
14
|
-
}) {
|
|
15
|
-
extend({
|
|
16
|
-
MeshRefractionMaterial: MeshRefractionMaterial$1
|
|
17
|
-
});
|
|
18
|
-
const material = useRef(null);
|
|
19
|
-
const {
|
|
20
|
-
size
|
|
21
|
-
} = useThree();
|
|
22
|
-
const defines = useMemo(() => {
|
|
23
|
-
var _ref, _envMap$image$;
|
|
24
|
-
const temp = {};
|
|
25
|
-
// Sampler2D and SamplerCube need different defines
|
|
26
|
-
const isCubeMap = isCubeTexture(envMap);
|
|
27
|
-
const w = (_ref = isCubeMap ? (_envMap$image$ = envMap.image[0]) == null ? void 0 : _envMap$image$.width : envMap.image.width) !== null && _ref !== void 0 ? _ref : 1024;
|
|
28
|
-
const cubeSize = w / 4;
|
|
29
|
-
const _lodMax = Math.floor(Math.log2(cubeSize));
|
|
30
|
-
const _cubeSize = Math.pow(2, _lodMax);
|
|
31
|
-
const width = 3 * Math.max(_cubeSize, 16 * 7);
|
|
32
|
-
const height = 4 * _cubeSize;
|
|
33
|
-
if (isCubeMap) temp.ENVMAP_TYPE_CUBEM = '';
|
|
34
|
-
temp.CUBEUV_TEXEL_WIDTH = `${1.0 / width}`;
|
|
35
|
-
temp.CUBEUV_TEXEL_HEIGHT = `${1.0 / height}`;
|
|
36
|
-
temp.CUBEUV_MAX_MIP = `${_lodMax}.0`;
|
|
37
|
-
// Add defines from chromatic aberration
|
|
38
|
-
if (aberrationStrength > 0) temp.CHROMATIC_ABERRATIONS = '';
|
|
39
|
-
if (fastChroma) temp.FAST_CHROMA = '';
|
|
40
|
-
return temp;
|
|
41
|
-
}, [aberrationStrength, fastChroma]);
|
|
42
|
-
useLayoutEffect(() => {
|
|
43
|
-
var _material$current;
|
|
44
|
-
// Get the geometry of this materials parent
|
|
45
|
-
const geometry = (_material$current = material.current) == null || (_material$current = _material$current.__r3f) == null || (_material$current = _material$current.parent) == null || (_material$current = _material$current.object) == null ? void 0 : _material$current.geometry;
|
|
46
|
-
// Update the BVH
|
|
47
|
-
if (geometry) {
|
|
48
|
-
material.current.bvh = new MeshBVHUniformStruct();
|
|
49
|
-
material.current.bvh.updateFrom(new MeshBVH(geometry.clone().toNonIndexed(), {
|
|
50
|
-
strategy: SAH
|
|
51
|
-
}));
|
|
52
|
-
}
|
|
53
|
-
}, []);
|
|
54
|
-
useFrame(({
|
|
55
|
-
camera
|
|
56
|
-
}) => {
|
|
57
|
-
material.current.viewMatrixInverse = camera.matrixWorld;
|
|
58
|
-
material.current.projectionMatrixInverse = camera.projectionMatrixInverse;
|
|
59
|
-
});
|
|
60
|
-
return /*#__PURE__*/React.createElement("meshRefractionMaterial", _extends({
|
|
61
|
-
// @ts-ignore
|
|
62
|
-
key: JSON.stringify(defines)
|
|
63
|
-
// @ts-ignore
|
|
64
|
-
,
|
|
65
|
-
defines: defines,
|
|
66
|
-
ref: material,
|
|
67
|
-
resolution: [size.width, size.height],
|
|
68
|
-
aberrationStrength: aberrationStrength,
|
|
69
|
-
envMap: envMap
|
|
70
|
-
}, props));
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
export { MeshRefractionMaterial };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var n=require("@babel/runtime/helpers/extends"),e=require("three"),t=require("react"),a=require("@react-three/fiber"),r=require("./Fbo.cjs.js"),o=require("../materials/DiscardMaterial.cjs.js");function i(n){return n&&"object"==typeof n&&"default"in n?n:{default:n}}function s(n){if(n&&n.__esModule)return n;var e=Object.create(null);return n&&Object.keys(n).forEach((function(t){if("default"!==t){var a=Object.getOwnPropertyDescriptor(n,t);Object.defineProperty(e,t,a.get?a:{enumerable:!0,get:function(){return n[t]}})}})),e.default=n,Object.freeze(e)}require("./shaderMaterial.cjs.js");var l=i(n),c=s(e),m=s(t);class u extends c.MeshPhysicalMaterial{constructor(n=6,e=!1){super(),this.uniforms={chromaticAberration:{value:.05},transmission:{value:0},_transmission:{value:1},transmissionMap:{value:null},roughness:{value:0},thickness:{value:0},thicknessMap:{value:null},attenuationDistance:{value:1/0},attenuationColor:{value:new c.Color("white")},anisotropicBlur:{value:.1},time:{value:0},distortion:{value:0},distortionScale:{value:.5},temporalDistortion:{value:0},buffer:{value:null}},this.onBeforeCompile=t=>{t.uniforms={...t.uniforms,...this.uniforms},this.anisotropy>0&&(t.defines.USE_ANISOTROPY=""),e?t.defines.USE_SAMPLER="":t.defines.USE_TRANSMISSION="",t.fragmentShader="\n uniform float chromaticAberration; \n uniform float anisotropicBlur; \n uniform float time;\n uniform float distortion;\n uniform float distortionScale;\n uniform float temporalDistortion;\n uniform sampler2D buffer;\n\n vec3 random3(vec3 c) {\n float j = 4096.0*sin(dot(c,vec3(17.0, 59.4, 15.0)));\n vec3 r;\n r.z = fract(512.0*j);\n j *= .125;\n r.x = fract(512.0*j);\n j *= .125;\n r.y = fract(512.0*j);\n return r-0.5;\n }\n\n uint hash( uint x ) {\n x += ( x << 10u );\n x ^= ( x >> 6u );\n x += ( x << 3u );\n x ^= ( x >> 11u );\n x += ( x << 15u );\n return x;\n }\n\n // Compound versions of the hashing algorithm I whipped together.\n uint hash( uvec2 v ) { return hash( v.x ^ hash(v.y) ); }\n uint hash( uvec3 v ) { return hash( v.x ^ hash(v.y) ^ hash(v.z) ); }\n uint hash( uvec4 v ) { return hash( v.x ^ hash(v.y) ^ hash(v.z) ^ hash(v.w) ); }\n\n // Construct a float with half-open range [0:1] using low 23 bits.\n // All zeroes yields 0.0, all ones yields the next smallest representable value below 1.0.\n float floatConstruct( uint m ) {\n const uint ieeeMantissa = 0x007FFFFFu; // binary32 mantissa bitmask\n const uint ieeeOne = 0x3F800000u; // 1.0 in IEEE binary32\n m &= ieeeMantissa; // Keep only mantissa bits (fractional part)\n m |= ieeeOne; // Add fractional part to 1.0\n float f = uintBitsToFloat( m ); // Range [1:2]\n return f - 1.0; // Range [0:1]\n }\n\n // Pseudo-random value in half-open range [0:1].\n float randomBase( float x ) { return floatConstruct(hash(floatBitsToUint(x))); }\n float randomBase( vec2 v ) { return floatConstruct(hash(floatBitsToUint(v))); }\n float randomBase( vec3 v ) { return floatConstruct(hash(floatBitsToUint(v))); }\n float randomBase( vec4 v ) { return floatConstruct(hash(floatBitsToUint(v))); }\n float rand(float seed) {\n float result = randomBase(vec3(gl_FragCoord.xy, seed));\n return result;\n }\n\n const float F3 = 0.3333333;\n const float G3 = 0.1666667;\n\n float snoise(vec3 p) {\n vec3 s = floor(p + dot(p, vec3(F3)));\n vec3 x = p - s + dot(s, vec3(G3));\n vec3 e = step(vec3(0.0), x - x.yzx);\n vec3 i1 = e*(1.0 - e.zxy);\n vec3 i2 = 1.0 - e.zxy*(1.0 - e);\n vec3 x1 = x - i1 + G3;\n vec3 x2 = x - i2 + 2.0*G3;\n vec3 x3 = x - 1.0 + 3.0*G3;\n vec4 w, d;\n w.x = dot(x, x);\n w.y = dot(x1, x1);\n w.z = dot(x2, x2);\n w.w = dot(x3, x3);\n w = max(0.6 - w, 0.0);\n d.x = dot(random3(s), x);\n d.y = dot(random3(s + i1), x1);\n d.z = dot(random3(s + i2), x2);\n d.w = dot(random3(s + 1.0), x3);\n w *= w;\n w *= w;\n d *= w;\n return dot(d, vec4(52.0));\n }\n\n float snoiseFractal(vec3 m) {\n return 0.5333333* snoise(m)\n +0.2666667* snoise(2.0*m)\n +0.1333333* snoise(4.0*m)\n +0.0666667* snoise(8.0*m);\n }\n"+t.fragmentShader,t.fragmentShader=t.fragmentShader.replace("#include <transmission_pars_fragment>","\n #ifdef USE_TRANSMISSION\n // Transmission code is based on glTF-Sampler-Viewer\n // https://github.com/KhronosGroup/glTF-Sample-Viewer\n uniform float _transmission;\n uniform float thickness;\n uniform float attenuationDistance;\n uniform vec3 attenuationColor;\n #ifdef USE_TRANSMISSIONMAP\n uniform sampler2D transmissionMap;\n #endif\n #ifdef USE_THICKNESSMAP\n uniform sampler2D thicknessMap;\n #endif\n uniform vec2 transmissionSamplerSize;\n uniform sampler2D transmissionSamplerMap;\n uniform mat4 modelMatrix;\n uniform mat4 projectionMatrix;\n varying vec3 vWorldPosition;\n vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {\n // Direction of refracted light.\n vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );\n // Compute rotation-independant scaling of the model matrix.\n vec3 modelScale;\n modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );\n modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );\n modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );\n // The thickness is specified in local space.\n return normalize( refractionVector ) * thickness * modelScale;\n }\n float applyIorToRoughness( const in float roughness, const in float ior ) {\n // Scale roughness with IOR so that an IOR of 1.0 results in no microfacet refraction and\n // an IOR of 1.5 results in the default amount of microfacet refraction.\n return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );\n }\n vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {\n float framebufferLod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior ); \n #ifdef USE_SAMPLER\n #ifdef texture2DLodEXT\n return texture2DLodEXT(transmissionSamplerMap, fragCoord.xy, framebufferLod);\n #else\n return texture2D(transmissionSamplerMap, fragCoord.xy, framebufferLod);\n #endif\n #else\n return texture2D(buffer, fragCoord.xy);\n #endif\n }\n vec3 applyVolumeAttenuation( const in vec3 radiance, const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {\n if ( isinf( attenuationDistance ) ) {\n // Attenuation distance is +∞, i.e. the transmitted color is not attenuated at all.\n return radiance;\n } else {\n // Compute light attenuation using Beer's law.\n vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;\n vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); // Beer's law\n return transmittance * radiance;\n }\n }\n vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,\n const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,\n const in mat4 viewMatrix, const in mat4 projMatrix, const in float ior, const in float thickness,\n const in vec3 attenuationColor, const in float attenuationDistance ) {\n vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );\n vec3 refractedRayExit = position + transmissionRay;\n // Project refracted vector on the framebuffer, while mapping to normalized device coordinates.\n vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );\n vec2 refractionCoords = ndcPos.xy / ndcPos.w;\n refractionCoords += 1.0;\n refractionCoords /= 2.0;\n // Sample framebuffer to get pixel the refracted ray hits.\n vec4 transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );\n vec3 attenuatedColor = applyVolumeAttenuation( transmittedLight.rgb, length( transmissionRay ), attenuationColor, attenuationDistance );\n // Get the specular component.\n vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );\n return vec4( ( 1.0 - F ) * attenuatedColor * diffuseColor, transmittedLight.a );\n }\n #endif\n"),t.fragmentShader=t.fragmentShader.replace("#include <transmission_fragment>",` \n // Improve the refraction to use the world pos\n material.transmission = _transmission;\n material.transmissionAlpha = 1.0;\n material.thickness = thickness;\n material.attenuationDistance = attenuationDistance;\n material.attenuationColor = attenuationColor;\n #ifdef USE_TRANSMISSIONMAP\n material.transmission *= texture2D( transmissionMap, vUv ).r;\n #endif\n #ifdef USE_THICKNESSMAP\n material.thickness *= texture2D( thicknessMap, vUv ).g;\n #endif\n \n vec3 pos = vWorldPosition;\n float runningSeed = 0.0;\n vec3 v = normalize( cameraPosition - pos );\n vec3 n = inverseTransformDirection( normal, viewMatrix );\n vec3 transmission = vec3(0.0);\n float transmissionR, transmissionB, transmissionG;\n float randomCoords = rand(runningSeed++);\n float thickness_smear = thickness * max(pow(roughnessFactor, 0.33), anisotropicBlur);\n vec3 distortionNormal = vec3(0.0);\n vec3 temporalOffset = vec3(time, -time, -time) * temporalDistortion;\n if (distortion > 0.0) {\n distortionNormal = distortion * vec3(snoiseFractal(vec3((pos * distortionScale + temporalOffset))), snoiseFractal(vec3(pos.zxy * distortionScale - temporalOffset)), snoiseFractal(vec3(pos.yxz * distortionScale + temporalOffset)));\n }\n for (float i = 0.0; i < ${n}.0; i ++) {\n vec3 sampleNorm = normalize(n + roughnessFactor * roughnessFactor * 2.0 * normalize(vec3(rand(runningSeed++) - 0.5, rand(runningSeed++) - 0.5, rand(runningSeed++) - 0.5)) * pow(rand(runningSeed++), 0.33) + distortionNormal);\n transmissionR = getIBLVolumeRefraction(\n sampleNorm, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,\n pos, modelMatrix, viewMatrix, projectionMatrix, material.ior, material.thickness + thickness_smear * (i + randomCoords) / float(${n}),\n material.attenuationColor, material.attenuationDistance\n ).r;\n transmissionG = getIBLVolumeRefraction(\n sampleNorm, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,\n pos, modelMatrix, viewMatrix, projectionMatrix, material.ior * (1.0 + chromaticAberration * (i + randomCoords) / float(${n})) , material.thickness + thickness_smear * (i + randomCoords) / float(${n}),\n material.attenuationColor, material.attenuationDistance\n ).g;\n transmissionB = getIBLVolumeRefraction(\n sampleNorm, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,\n pos, modelMatrix, viewMatrix, projectionMatrix, material.ior * (1.0 + 2.0 * chromaticAberration * (i + randomCoords) / float(${n})), material.thickness + thickness_smear * (i + randomCoords) / float(${n}),\n material.attenuationColor, material.attenuationDistance\n ).b;\n transmission.r += transmissionR;\n transmission.g += transmissionG;\n transmission.b += transmissionB;\n }\n transmission /= ${n}.0;\n totalDiffuse = mix( totalDiffuse, transmission.rgb, material.transmission );\n`)},Object.keys(this.uniforms).forEach((n=>Object.defineProperty(this,n,{get:()=>this.uniforms[n].value,set:e=>this.uniforms[n].value=e})))}}const f=m.forwardRef((({buffer:n,transmissionSampler:e=!1,backside:t=!1,side:i=c.FrontSide,transmission:s=1,thickness:f=0,backsideThickness:d=0,backsideEnvMapIntensity:v=1,samples:h=10,resolution:p,backsideResolution:x,background:g,anisotropy:S,anisotropicBlur:M,...b},C)=>{a.extend({MeshTransmissionMaterial:u});const y=m.useRef(null),[w]=m.useState((()=>new o.DiscardMaterial)),k=r.useFBO(x||p),D=r.useFBO(p);let R,T,F,j;return a.useFrame((n=>{var a;(y.current.time=n.clock.elapsedTime,y.current.buffer!==D.texture||e)||(j=null==(a=y.current.__r3f.parent)?void 0:a.object,j&&(F=n.gl.toneMapping,R=n.scene.background,T=y.current.envMapIntensity,n.gl.toneMapping=c.NoToneMapping,g&&(n.scene.background=g),j.material=w,t&&(n.gl.setRenderTarget(k),n.gl.render(n.scene,n.camera),j.material=y.current,j.material.buffer=k.texture,j.material.thickness=d,j.material.side=c.BackSide,j.material.envMapIntensity=v),n.gl.setRenderTarget(D),n.gl.render(n.scene,n.camera),j.material=y.current,j.material.thickness=f,j.material.side=i,j.material.buffer=D.texture,j.material.envMapIntensity=T,n.scene.background=R,n.gl.setRenderTarget(null),n.gl.toneMapping=F))})),m.useImperativeHandle(C,(()=>y.current),[]),m.createElement("meshTransmissionMaterial",l.default({args:[h,e],ref:y},b,{buffer:n||D.texture,_transmission:s,anisotropicBlur:null!=M?M:S,transmission:e?s:0,thickness:f,side:i}))}));exports.MeshTransmissionMaterial=f;
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import * as THREE from 'three';
|
|
2
|
-
import { ThreeElements } from '@react-three/fiber';
|
|
3
|
-
import { ForwardRefComponent } from '../helpers/ts-utils';
|
|
4
|
-
type MeshTransmissionMaterialType = Omit<ThreeElements['meshPhysicalMaterial'], 'args' | 'roughness' | 'thickness' | 'transmission'> & {
|
|
5
|
-
transmission?: number;
|
|
6
|
-
thickness?: number;
|
|
7
|
-
roughness?: number;
|
|
8
|
-
chromaticAberration?: number;
|
|
9
|
-
anisotropy?: number;
|
|
10
|
-
anisotropicBlur?: number;
|
|
11
|
-
distortion?: number;
|
|
12
|
-
distortionScale?: number;
|
|
13
|
-
temporalDistortion?: number;
|
|
14
|
-
buffer?: THREE.Texture;
|
|
15
|
-
time?: number;
|
|
16
|
-
args?: [samples: number, transmissionSampler: boolean];
|
|
17
|
-
};
|
|
18
|
-
export type MeshTransmissionMaterialProps = Omit<MeshTransmissionMaterialType, 'ref' | 'args'> & {
|
|
19
|
-
transmissionSampler?: boolean;
|
|
20
|
-
backside?: boolean;
|
|
21
|
-
backsideThickness?: number;
|
|
22
|
-
backsideEnvMapIntensity?: number;
|
|
23
|
-
resolution?: number;
|
|
24
|
-
backsideResolution?: number;
|
|
25
|
-
samples?: number;
|
|
26
|
-
background?: THREE.Texture | THREE.Color;
|
|
27
|
-
};
|
|
28
|
-
declare module '@react-three/fiber' {
|
|
29
|
-
interface ThreeElements {
|
|
30
|
-
meshTransmissionMaterial: MeshTransmissionMaterialType;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
export declare const MeshTransmissionMaterial: ForwardRefComponent<MeshTransmissionMaterialProps, ThreeElements['meshTransmissionMaterial']>;
|
|
34
|
-
export {};
|
|
@@ -1,402 +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, useFrame } from '@react-three/fiber';
|
|
5
|
-
import { useFBO } from './Fbo.js';
|
|
6
|
-
import { DiscardMaterial } from '../materials/DiscardMaterial.js';
|
|
7
|
-
|
|
8
|
-
class MeshTransmissionMaterialImpl extends THREE.MeshPhysicalMaterial {
|
|
9
|
-
constructor(samples = 6, transmissionSampler = false) {
|
|
10
|
-
super();
|
|
11
|
-
this.uniforms = {
|
|
12
|
-
chromaticAberration: {
|
|
13
|
-
value: 0.05
|
|
14
|
-
},
|
|
15
|
-
// Transmission must always be 0, unless transmissionSampler is being used
|
|
16
|
-
transmission: {
|
|
17
|
-
value: 0
|
|
18
|
-
},
|
|
19
|
-
// Instead a workaround is used, see below for reasons why
|
|
20
|
-
_transmission: {
|
|
21
|
-
value: 1
|
|
22
|
-
},
|
|
23
|
-
transmissionMap: {
|
|
24
|
-
value: null
|
|
25
|
-
},
|
|
26
|
-
// Roughness is 1 in THREE.MeshPhysicalMaterial but it makes little sense in a transmission material
|
|
27
|
-
roughness: {
|
|
28
|
-
value: 0
|
|
29
|
-
},
|
|
30
|
-
thickness: {
|
|
31
|
-
value: 0
|
|
32
|
-
},
|
|
33
|
-
thicknessMap: {
|
|
34
|
-
value: null
|
|
35
|
-
},
|
|
36
|
-
attenuationDistance: {
|
|
37
|
-
value: Infinity
|
|
38
|
-
},
|
|
39
|
-
attenuationColor: {
|
|
40
|
-
value: new THREE.Color('white')
|
|
41
|
-
},
|
|
42
|
-
anisotropicBlur: {
|
|
43
|
-
value: 0.1
|
|
44
|
-
},
|
|
45
|
-
time: {
|
|
46
|
-
value: 0
|
|
47
|
-
},
|
|
48
|
-
distortion: {
|
|
49
|
-
value: 0.0
|
|
50
|
-
},
|
|
51
|
-
distortionScale: {
|
|
52
|
-
value: 0.5
|
|
53
|
-
},
|
|
54
|
-
temporalDistortion: {
|
|
55
|
-
value: 0.0
|
|
56
|
-
},
|
|
57
|
-
buffer: {
|
|
58
|
-
value: null
|
|
59
|
-
}
|
|
60
|
-
};
|
|
61
|
-
this.onBeforeCompile = shader => {
|
|
62
|
-
shader.uniforms = {
|
|
63
|
-
...shader.uniforms,
|
|
64
|
-
...this.uniforms
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
// Fix for r153-r156 anisotropy chunks
|
|
68
|
-
// https://github.com/mrdoob/three.js/pull/26716
|
|
69
|
-
if (this.anisotropy > 0) shader.defines.USE_ANISOTROPY = '';
|
|
70
|
-
|
|
71
|
-
// If the transmission sampler is active inject a flag
|
|
72
|
-
if (transmissionSampler) shader.defines.USE_SAMPLER = '';
|
|
73
|
-
// Otherwise we do use use .transmission and must therefore force USE_TRANSMISSION
|
|
74
|
-
// because threejs won't inject it for us
|
|
75
|
-
else shader.defines.USE_TRANSMISSION = '';
|
|
76
|
-
|
|
77
|
-
// Head
|
|
78
|
-
shader.fragmentShader = /*glsl*/`
|
|
79
|
-
uniform float chromaticAberration;
|
|
80
|
-
uniform float anisotropicBlur;
|
|
81
|
-
uniform float time;
|
|
82
|
-
uniform float distortion;
|
|
83
|
-
uniform float distortionScale;
|
|
84
|
-
uniform float temporalDistortion;
|
|
85
|
-
uniform sampler2D buffer;
|
|
86
|
-
|
|
87
|
-
vec3 random3(vec3 c) {
|
|
88
|
-
float j = 4096.0*sin(dot(c,vec3(17.0, 59.4, 15.0)));
|
|
89
|
-
vec3 r;
|
|
90
|
-
r.z = fract(512.0*j);
|
|
91
|
-
j *= .125;
|
|
92
|
-
r.x = fract(512.0*j);
|
|
93
|
-
j *= .125;
|
|
94
|
-
r.y = fract(512.0*j);
|
|
95
|
-
return r-0.5;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
uint hash( uint x ) {
|
|
99
|
-
x += ( x << 10u );
|
|
100
|
-
x ^= ( x >> 6u );
|
|
101
|
-
x += ( x << 3u );
|
|
102
|
-
x ^= ( x >> 11u );
|
|
103
|
-
x += ( x << 15u );
|
|
104
|
-
return x;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
// Compound versions of the hashing algorithm I whipped together.
|
|
108
|
-
uint hash( uvec2 v ) { return hash( v.x ^ hash(v.y) ); }
|
|
109
|
-
uint hash( uvec3 v ) { return hash( v.x ^ hash(v.y) ^ hash(v.z) ); }
|
|
110
|
-
uint hash( uvec4 v ) { return hash( v.x ^ hash(v.y) ^ hash(v.z) ^ hash(v.w) ); }
|
|
111
|
-
|
|
112
|
-
// Construct a float with half-open range [0:1] using low 23 bits.
|
|
113
|
-
// All zeroes yields 0.0, all ones yields the next smallest representable value below 1.0.
|
|
114
|
-
float floatConstruct( uint m ) {
|
|
115
|
-
const uint ieeeMantissa = 0x007FFFFFu; // binary32 mantissa bitmask
|
|
116
|
-
const uint ieeeOne = 0x3F800000u; // 1.0 in IEEE binary32
|
|
117
|
-
m &= ieeeMantissa; // Keep only mantissa bits (fractional part)
|
|
118
|
-
m |= ieeeOne; // Add fractional part to 1.0
|
|
119
|
-
float f = uintBitsToFloat( m ); // Range [1:2]
|
|
120
|
-
return f - 1.0; // Range [0:1]
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
// Pseudo-random value in half-open range [0:1].
|
|
124
|
-
float randomBase( float x ) { return floatConstruct(hash(floatBitsToUint(x))); }
|
|
125
|
-
float randomBase( vec2 v ) { return floatConstruct(hash(floatBitsToUint(v))); }
|
|
126
|
-
float randomBase( vec3 v ) { return floatConstruct(hash(floatBitsToUint(v))); }
|
|
127
|
-
float randomBase( vec4 v ) { return floatConstruct(hash(floatBitsToUint(v))); }
|
|
128
|
-
float rand(float seed) {
|
|
129
|
-
float result = randomBase(vec3(gl_FragCoord.xy, seed));
|
|
130
|
-
return result;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
const float F3 = 0.3333333;
|
|
134
|
-
const float G3 = 0.1666667;
|
|
135
|
-
|
|
136
|
-
float snoise(vec3 p) {
|
|
137
|
-
vec3 s = floor(p + dot(p, vec3(F3)));
|
|
138
|
-
vec3 x = p - s + dot(s, vec3(G3));
|
|
139
|
-
vec3 e = step(vec3(0.0), x - x.yzx);
|
|
140
|
-
vec3 i1 = e*(1.0 - e.zxy);
|
|
141
|
-
vec3 i2 = 1.0 - e.zxy*(1.0 - e);
|
|
142
|
-
vec3 x1 = x - i1 + G3;
|
|
143
|
-
vec3 x2 = x - i2 + 2.0*G3;
|
|
144
|
-
vec3 x3 = x - 1.0 + 3.0*G3;
|
|
145
|
-
vec4 w, d;
|
|
146
|
-
w.x = dot(x, x);
|
|
147
|
-
w.y = dot(x1, x1);
|
|
148
|
-
w.z = dot(x2, x2);
|
|
149
|
-
w.w = dot(x3, x3);
|
|
150
|
-
w = max(0.6 - w, 0.0);
|
|
151
|
-
d.x = dot(random3(s), x);
|
|
152
|
-
d.y = dot(random3(s + i1), x1);
|
|
153
|
-
d.z = dot(random3(s + i2), x2);
|
|
154
|
-
d.w = dot(random3(s + 1.0), x3);
|
|
155
|
-
w *= w;
|
|
156
|
-
w *= w;
|
|
157
|
-
d *= w;
|
|
158
|
-
return dot(d, vec4(52.0));
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
float snoiseFractal(vec3 m) {
|
|
162
|
-
return 0.5333333* snoise(m)
|
|
163
|
-
+0.2666667* snoise(2.0*m)
|
|
164
|
-
+0.1333333* snoise(4.0*m)
|
|
165
|
-
+0.0666667* snoise(8.0*m);
|
|
166
|
-
}\n` + shader.fragmentShader;
|
|
167
|
-
|
|
168
|
-
// Remove transmission
|
|
169
|
-
shader.fragmentShader = shader.fragmentShader.replace('#include <transmission_pars_fragment>', /*glsl*/`
|
|
170
|
-
#ifdef USE_TRANSMISSION
|
|
171
|
-
// Transmission code is based on glTF-Sampler-Viewer
|
|
172
|
-
// https://github.com/KhronosGroup/glTF-Sample-Viewer
|
|
173
|
-
uniform float _transmission;
|
|
174
|
-
uniform float thickness;
|
|
175
|
-
uniform float attenuationDistance;
|
|
176
|
-
uniform vec3 attenuationColor;
|
|
177
|
-
#ifdef USE_TRANSMISSIONMAP
|
|
178
|
-
uniform sampler2D transmissionMap;
|
|
179
|
-
#endif
|
|
180
|
-
#ifdef USE_THICKNESSMAP
|
|
181
|
-
uniform sampler2D thicknessMap;
|
|
182
|
-
#endif
|
|
183
|
-
uniform vec2 transmissionSamplerSize;
|
|
184
|
-
uniform sampler2D transmissionSamplerMap;
|
|
185
|
-
uniform mat4 modelMatrix;
|
|
186
|
-
uniform mat4 projectionMatrix;
|
|
187
|
-
varying vec3 vWorldPosition;
|
|
188
|
-
vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {
|
|
189
|
-
// Direction of refracted light.
|
|
190
|
-
vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );
|
|
191
|
-
// Compute rotation-independant scaling of the model matrix.
|
|
192
|
-
vec3 modelScale;
|
|
193
|
-
modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );
|
|
194
|
-
modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );
|
|
195
|
-
modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );
|
|
196
|
-
// The thickness is specified in local space.
|
|
197
|
-
return normalize( refractionVector ) * thickness * modelScale;
|
|
198
|
-
}
|
|
199
|
-
float applyIorToRoughness( const in float roughness, const in float ior ) {
|
|
200
|
-
// Scale roughness with IOR so that an IOR of 1.0 results in no microfacet refraction and
|
|
201
|
-
// an IOR of 1.5 results in the default amount of microfacet refraction.
|
|
202
|
-
return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );
|
|
203
|
-
}
|
|
204
|
-
vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {
|
|
205
|
-
float framebufferLod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );
|
|
206
|
-
#ifdef USE_SAMPLER
|
|
207
|
-
#ifdef texture2DLodEXT
|
|
208
|
-
return texture2DLodEXT(transmissionSamplerMap, fragCoord.xy, framebufferLod);
|
|
209
|
-
#else
|
|
210
|
-
return texture2D(transmissionSamplerMap, fragCoord.xy, framebufferLod);
|
|
211
|
-
#endif
|
|
212
|
-
#else
|
|
213
|
-
return texture2D(buffer, fragCoord.xy);
|
|
214
|
-
#endif
|
|
215
|
-
}
|
|
216
|
-
vec3 applyVolumeAttenuation( const in vec3 radiance, const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {
|
|
217
|
-
if ( isinf( attenuationDistance ) ) {
|
|
218
|
-
// Attenuation distance is +∞, i.e. the transmitted color is not attenuated at all.
|
|
219
|
-
return radiance;
|
|
220
|
-
} else {
|
|
221
|
-
// Compute light attenuation using Beer's law.
|
|
222
|
-
vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;
|
|
223
|
-
vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); // Beer's law
|
|
224
|
-
return transmittance * radiance;
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,
|
|
228
|
-
const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,
|
|
229
|
-
const in mat4 viewMatrix, const in mat4 projMatrix, const in float ior, const in float thickness,
|
|
230
|
-
const in vec3 attenuationColor, const in float attenuationDistance ) {
|
|
231
|
-
vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );
|
|
232
|
-
vec3 refractedRayExit = position + transmissionRay;
|
|
233
|
-
// Project refracted vector on the framebuffer, while mapping to normalized device coordinates.
|
|
234
|
-
vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
|
|
235
|
-
vec2 refractionCoords = ndcPos.xy / ndcPos.w;
|
|
236
|
-
refractionCoords += 1.0;
|
|
237
|
-
refractionCoords /= 2.0;
|
|
238
|
-
// Sample framebuffer to get pixel the refracted ray hits.
|
|
239
|
-
vec4 transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );
|
|
240
|
-
vec3 attenuatedColor = applyVolumeAttenuation( transmittedLight.rgb, length( transmissionRay ), attenuationColor, attenuationDistance );
|
|
241
|
-
// Get the specular component.
|
|
242
|
-
vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );
|
|
243
|
-
return vec4( ( 1.0 - F ) * attenuatedColor * diffuseColor, transmittedLight.a );
|
|
244
|
-
}
|
|
245
|
-
#endif\n`);
|
|
246
|
-
|
|
247
|
-
// Add refraction
|
|
248
|
-
shader.fragmentShader = shader.fragmentShader.replace('#include <transmission_fragment>', /*glsl*/`
|
|
249
|
-
// Improve the refraction to use the world pos
|
|
250
|
-
material.transmission = _transmission;
|
|
251
|
-
material.transmissionAlpha = 1.0;
|
|
252
|
-
material.thickness = thickness;
|
|
253
|
-
material.attenuationDistance = attenuationDistance;
|
|
254
|
-
material.attenuationColor = attenuationColor;
|
|
255
|
-
#ifdef USE_TRANSMISSIONMAP
|
|
256
|
-
material.transmission *= texture2D( transmissionMap, vUv ).r;
|
|
257
|
-
#endif
|
|
258
|
-
#ifdef USE_THICKNESSMAP
|
|
259
|
-
material.thickness *= texture2D( thicknessMap, vUv ).g;
|
|
260
|
-
#endif
|
|
261
|
-
|
|
262
|
-
vec3 pos = vWorldPosition;
|
|
263
|
-
float runningSeed = 0.0;
|
|
264
|
-
vec3 v = normalize( cameraPosition - pos );
|
|
265
|
-
vec3 n = inverseTransformDirection( normal, viewMatrix );
|
|
266
|
-
vec3 transmission = vec3(0.0);
|
|
267
|
-
float transmissionR, transmissionB, transmissionG;
|
|
268
|
-
float randomCoords = rand(runningSeed++);
|
|
269
|
-
float thickness_smear = thickness * max(pow(roughnessFactor, 0.33), anisotropicBlur);
|
|
270
|
-
vec3 distortionNormal = vec3(0.0);
|
|
271
|
-
vec3 temporalOffset = vec3(time, -time, -time) * temporalDistortion;
|
|
272
|
-
if (distortion > 0.0) {
|
|
273
|
-
distortionNormal = distortion * vec3(snoiseFractal(vec3((pos * distortionScale + temporalOffset))), snoiseFractal(vec3(pos.zxy * distortionScale - temporalOffset)), snoiseFractal(vec3(pos.yxz * distortionScale + temporalOffset)));
|
|
274
|
-
}
|
|
275
|
-
for (float i = 0.0; i < ${samples}.0; i ++) {
|
|
276
|
-
vec3 sampleNorm = normalize(n + roughnessFactor * roughnessFactor * 2.0 * normalize(vec3(rand(runningSeed++) - 0.5, rand(runningSeed++) - 0.5, rand(runningSeed++) - 0.5)) * pow(rand(runningSeed++), 0.33) + distortionNormal);
|
|
277
|
-
transmissionR = getIBLVolumeRefraction(
|
|
278
|
-
sampleNorm, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,
|
|
279
|
-
pos, modelMatrix, viewMatrix, projectionMatrix, material.ior, material.thickness + thickness_smear * (i + randomCoords) / float(${samples}),
|
|
280
|
-
material.attenuationColor, material.attenuationDistance
|
|
281
|
-
).r;
|
|
282
|
-
transmissionG = getIBLVolumeRefraction(
|
|
283
|
-
sampleNorm, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,
|
|
284
|
-
pos, modelMatrix, viewMatrix, projectionMatrix, material.ior * (1.0 + chromaticAberration * (i + randomCoords) / float(${samples})) , material.thickness + thickness_smear * (i + randomCoords) / float(${samples}),
|
|
285
|
-
material.attenuationColor, material.attenuationDistance
|
|
286
|
-
).g;
|
|
287
|
-
transmissionB = getIBLVolumeRefraction(
|
|
288
|
-
sampleNorm, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,
|
|
289
|
-
pos, modelMatrix, viewMatrix, projectionMatrix, material.ior * (1.0 + 2.0 * chromaticAberration * (i + randomCoords) / float(${samples})), material.thickness + thickness_smear * (i + randomCoords) / float(${samples}),
|
|
290
|
-
material.attenuationColor, material.attenuationDistance
|
|
291
|
-
).b;
|
|
292
|
-
transmission.r += transmissionR;
|
|
293
|
-
transmission.g += transmissionG;
|
|
294
|
-
transmission.b += transmissionB;
|
|
295
|
-
}
|
|
296
|
-
transmission /= ${samples}.0;
|
|
297
|
-
totalDiffuse = mix( totalDiffuse, transmission.rgb, material.transmission );\n`);
|
|
298
|
-
};
|
|
299
|
-
Object.keys(this.uniforms).forEach(name => Object.defineProperty(this, name, {
|
|
300
|
-
get: () => this.uniforms[name].value,
|
|
301
|
-
set: v => this.uniforms[name].value = v
|
|
302
|
-
}));
|
|
303
|
-
}
|
|
304
|
-
}
|
|
305
|
-
const MeshTransmissionMaterial = /* @__PURE__ */React.forwardRef(({
|
|
306
|
-
buffer,
|
|
307
|
-
transmissionSampler = false,
|
|
308
|
-
backside = false,
|
|
309
|
-
side = THREE.FrontSide,
|
|
310
|
-
transmission = 1,
|
|
311
|
-
thickness = 0,
|
|
312
|
-
backsideThickness = 0,
|
|
313
|
-
backsideEnvMapIntensity = 1,
|
|
314
|
-
samples = 10,
|
|
315
|
-
resolution,
|
|
316
|
-
backsideResolution,
|
|
317
|
-
background,
|
|
318
|
-
anisotropy,
|
|
319
|
-
anisotropicBlur,
|
|
320
|
-
...props
|
|
321
|
-
}, fref) => {
|
|
322
|
-
extend({
|
|
323
|
-
MeshTransmissionMaterial: MeshTransmissionMaterialImpl
|
|
324
|
-
});
|
|
325
|
-
const ref = React.useRef(null);
|
|
326
|
-
const [discardMaterial] = React.useState(() => new DiscardMaterial());
|
|
327
|
-
const fboBack = useFBO(backsideResolution || resolution);
|
|
328
|
-
const fboMain = useFBO(resolution);
|
|
329
|
-
let oldBg;
|
|
330
|
-
let oldEnvMapIntensity;
|
|
331
|
-
let oldTone;
|
|
332
|
-
let parent;
|
|
333
|
-
useFrame(state => {
|
|
334
|
-
ref.current.time = state.clock.elapsedTime;
|
|
335
|
-
// Render only if the buffer matches the built-in and no transmission sampler is set
|
|
336
|
-
if (ref.current.buffer === fboMain.texture && !transmissionSampler) {
|
|
337
|
-
var _r3f$parent;
|
|
338
|
-
parent = (_r3f$parent = ref.current.__r3f.parent) == null ? void 0 : _r3f$parent.object;
|
|
339
|
-
if (parent) {
|
|
340
|
-
// Save defaults
|
|
341
|
-
oldTone = state.gl.toneMapping;
|
|
342
|
-
oldBg = state.scene.background;
|
|
343
|
-
oldEnvMapIntensity = ref.current.envMapIntensity;
|
|
344
|
-
|
|
345
|
-
// Switch off tonemapping lest it double tone maps
|
|
346
|
-
// Save the current background and set the HDR as the new BG
|
|
347
|
-
// Use discardmaterial, the parent will be invisible, but it's shadows will still be cast
|
|
348
|
-
state.gl.toneMapping = THREE.NoToneMapping;
|
|
349
|
-
if (background) state.scene.background = background;
|
|
350
|
-
parent.material = discardMaterial;
|
|
351
|
-
if (backside) {
|
|
352
|
-
// Render into the backside buffer
|
|
353
|
-
state.gl.setRenderTarget(fboBack);
|
|
354
|
-
state.gl.render(state.scene, state.camera);
|
|
355
|
-
// And now prepare the material for the main render using the backside buffer
|
|
356
|
-
parent.material = ref.current;
|
|
357
|
-
parent.material.buffer = fboBack.texture;
|
|
358
|
-
parent.material.thickness = backsideThickness;
|
|
359
|
-
parent.material.side = THREE.BackSide;
|
|
360
|
-
parent.material.envMapIntensity = backsideEnvMapIntensity;
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
// Render into the main buffer
|
|
364
|
-
state.gl.setRenderTarget(fboMain);
|
|
365
|
-
state.gl.render(state.scene, state.camera);
|
|
366
|
-
parent.material = ref.current;
|
|
367
|
-
parent.material.thickness = thickness;
|
|
368
|
-
parent.material.side = side;
|
|
369
|
-
parent.material.buffer = fboMain.texture;
|
|
370
|
-
parent.material.envMapIntensity = oldEnvMapIntensity;
|
|
371
|
-
|
|
372
|
-
// Set old state back
|
|
373
|
-
state.scene.background = oldBg;
|
|
374
|
-
state.gl.setRenderTarget(null);
|
|
375
|
-
state.gl.toneMapping = oldTone;
|
|
376
|
-
}
|
|
377
|
-
}
|
|
378
|
-
});
|
|
379
|
-
|
|
380
|
-
// Forward ref
|
|
381
|
-
React.useImperativeHandle(fref, () => ref.current, []);
|
|
382
|
-
return /*#__PURE__*/React.createElement("meshTransmissionMaterial", _extends({
|
|
383
|
-
// Samples must re-compile the shader so we memoize it
|
|
384
|
-
args: [samples, transmissionSampler],
|
|
385
|
-
ref: ref
|
|
386
|
-
}, props, {
|
|
387
|
-
buffer: buffer || fboMain.texture
|
|
388
|
-
// @ts-ignore
|
|
389
|
-
,
|
|
390
|
-
_transmission: transmission
|
|
391
|
-
// In order for this to not incur extra cost "transmission" must be set to 0 and treated as a reserved prop.
|
|
392
|
-
// This is because THREE.WebGLRenderer will check for transmission > 0 and execute extra renders.
|
|
393
|
-
// The exception is when transmissionSampler is set, in which case we are using three's built in sampler.
|
|
394
|
-
,
|
|
395
|
-
anisotropicBlur: anisotropicBlur !== null && anisotropicBlur !== void 0 ? anisotropicBlur : anisotropy,
|
|
396
|
-
transmission: transmissionSampler ? transmission : 0,
|
|
397
|
-
thickness: thickness,
|
|
398
|
-
side: side
|
|
399
|
-
}));
|
|
400
|
-
});
|
|
401
|
-
|
|
402
|
-
export { MeshTransmissionMaterial };
|
|
@@ -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"),a=require("@react-three/fiber");function i(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function o(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var a=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,a.get?a:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var n=i(e),s=o(t);class c extends r.MeshStandardMaterial{constructor(e={}){super(e),this.setValues(e),this._time={value:0},this._factor={value:1}}onBeforeCompile(e){e.uniforms.time=this._time,e.uniforms.factor=this._factor,e.vertexShader=`\n uniform float time;\n uniform float factor;\n ${e.vertexShader}\n `,e.vertexShader=e.vertexShader.replace("#include <begin_vertex>","float theta = sin( time + position.y ) / 2.0 * factor;\n float c = cos( theta );\n float s = sin( theta );\n mat3 m = mat3( c, 0, s, 0, 1, 0, -s, 0, c );\n vec3 transformed = vec3( position ) * m;\n vNormal = vNormal * m;")}get time(){return this._time.value}set time(e){this._time.value=e}get factor(){return this._factor.value}set factor(e){this._factor.value=e}}const u=s.forwardRef((({speed:e=1,...t},r)=>{const[i]=s.useState((()=>new c));return a.useFrame((t=>i&&(i.time=t.clock.elapsedTime*e))),s.createElement("primitive",n.default({object:i,ref:r,attach:"material"},t))}));exports.MeshWobbleMaterial=u;
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { IUniform, MeshStandardMaterial, MeshStandardMaterialParameters } from 'three';
|
|
2
|
-
import { ThreeElements } from '@react-three/fiber';
|
|
3
|
-
import { ForwardRefComponent } from '../helpers/ts-utils';
|
|
4
|
-
interface Uniform<T> {
|
|
5
|
-
value: T;
|
|
6
|
-
}
|
|
7
|
-
declare class WobbleMaterialImpl extends MeshStandardMaterial {
|
|
8
|
-
_time: Uniform<number>;
|
|
9
|
-
_factor: Uniform<number>;
|
|
10
|
-
constructor(parameters?: MeshStandardMaterialParameters);
|
|
11
|
-
onBeforeCompile(shader: {
|
|
12
|
-
vertexShader: string;
|
|
13
|
-
uniforms: {
|
|
14
|
-
[uniform: string]: IUniform;
|
|
15
|
-
};
|
|
16
|
-
}): void;
|
|
17
|
-
get time(): number;
|
|
18
|
-
set time(v: number);
|
|
19
|
-
get factor(): number;
|
|
20
|
-
set factor(v: number);
|
|
21
|
-
}
|
|
22
|
-
declare module '@react-three/fiber' {
|
|
23
|
-
interface ThreeElements {
|
|
24
|
-
wobbleMaterialImpl: ThreeElements['meshStandardMaterial'] & {
|
|
25
|
-
time?: number;
|
|
26
|
-
factor?: number;
|
|
27
|
-
speed?: number;
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
export type WobbleMaterialProps = Omit<ThreeElements['meshStandardMaterial'], 'ref'> & {
|
|
32
|
-
speed?: number;
|
|
33
|
-
factor?: number;
|
|
34
|
-
};
|
|
35
|
-
export declare const MeshWobbleMaterial: ForwardRefComponent<WobbleMaterialProps, WobbleMaterialImpl>;
|
|
36
|
-
export {};
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import _extends from '@babel/runtime/helpers/esm/extends';
|
|
2
|
-
import * as React from 'react';
|
|
3
|
-
import { MeshStandardMaterial } from 'three';
|
|
4
|
-
import { useFrame } from '@react-three/fiber';
|
|
5
|
-
|
|
6
|
-
class WobbleMaterialImpl extends MeshStandardMaterial {
|
|
7
|
-
constructor(parameters = {}) {
|
|
8
|
-
super(parameters);
|
|
9
|
-
this.setValues(parameters);
|
|
10
|
-
this._time = {
|
|
11
|
-
value: 0
|
|
12
|
-
};
|
|
13
|
-
this._factor = {
|
|
14
|
-
value: 1
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
// FIXME Use `THREE.WebGLProgramParametersWithUniforms` type when able to target @types/three@0.160.0
|
|
19
|
-
onBeforeCompile(shader) {
|
|
20
|
-
shader.uniforms.time = this._time;
|
|
21
|
-
shader.uniforms.factor = this._factor;
|
|
22
|
-
shader.vertexShader = `
|
|
23
|
-
uniform float time;
|
|
24
|
-
uniform float factor;
|
|
25
|
-
${shader.vertexShader}
|
|
26
|
-
`;
|
|
27
|
-
shader.vertexShader = shader.vertexShader.replace('#include <begin_vertex>', `float theta = sin( time + position.y ) / 2.0 * factor;
|
|
28
|
-
float c = cos( theta );
|
|
29
|
-
float s = sin( theta );
|
|
30
|
-
mat3 m = mat3( c, 0, s, 0, 1, 0, -s, 0, c );
|
|
31
|
-
vec3 transformed = vec3( position ) * m;
|
|
32
|
-
vNormal = vNormal * m;`);
|
|
33
|
-
}
|
|
34
|
-
get time() {
|
|
35
|
-
return this._time.value;
|
|
36
|
-
}
|
|
37
|
-
set time(v) {
|
|
38
|
-
this._time.value = v;
|
|
39
|
-
}
|
|
40
|
-
get factor() {
|
|
41
|
-
return this._factor.value;
|
|
42
|
-
}
|
|
43
|
-
set factor(v) {
|
|
44
|
-
this._factor.value = v;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
const MeshWobbleMaterial = /* @__PURE__ */React.forwardRef(({
|
|
48
|
-
speed = 1,
|
|
49
|
-
...props
|
|
50
|
-
}, ref) => {
|
|
51
|
-
const [material] = React.useState(() => new WobbleMaterialImpl());
|
|
52
|
-
useFrame(state => material && (material.time = state.clock.elapsedTime * speed));
|
|
53
|
-
return /*#__PURE__*/React.createElement("primitive", _extends({
|
|
54
|
-
object: material,
|
|
55
|
-
ref: ref,
|
|
56
|
-
attach: "material"
|
|
57
|
-
}, props));
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
export { MeshWobbleMaterial };
|