@react-three/drei 9.74.13 → 9.74.14

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.
Files changed (189) hide show
  1. package/core/CatmullRomLine.js +0 -2
  2. package/core/Cloud.js +0 -3
  3. package/core/CubeCamera.js +0 -1
  4. package/core/CubicBezierLine.js +0 -2
  5. package/core/Environment.js +0 -1
  6. package/core/Example.js +0 -6
  7. package/core/FaceControls.cjs.js +1 -1
  8. package/core/FaceControls.js +0 -2
  9. package/core/FaceLandmarker.cjs.js +1 -1
  10. package/core/FaceLandmarker.js +2 -3
  11. package/core/Facemesh.js +0 -2
  12. package/core/GizmoHelper.js +0 -3
  13. package/core/GizmoViewcube.js +0 -4
  14. package/core/GizmoViewport.js +0 -4
  15. package/core/Gltf.js +0 -4
  16. package/core/MeshDiscardMaterial.js +0 -2
  17. package/core/MeshDistortMaterial.js +1 -2
  18. package/core/MeshReflectorMaterial.js +0 -1
  19. package/core/MeshRefractionMaterial.js +0 -2
  20. package/core/MeshTransmissionMaterial.js +0 -1
  21. package/core/OrthographicCamera.js +0 -1
  22. package/core/PerspectiveCamera.js +0 -1
  23. package/core/QuadraticBezierLine.js +0 -2
  24. package/core/Reflector.js +0 -1
  25. package/core/SpotLight.js +1 -2
  26. package/core/Stage.js +0 -7
  27. package/core/Text3D.js +0 -1
  28. package/core/Wireframe.js +0 -1
  29. package/core/index.cjs.js +1 -1
  30. package/core/index.js +1 -0
  31. package/core/useKTX2.js +0 -1
  32. package/core/useMatcapTexture.js +0 -2
  33. package/core/useNormalTexture.js +0 -1
  34. package/index.cjs.js +1 -1
  35. package/materials/DiscardMaterial.js +0 -1
  36. package/materials/MeshRefractionMaterial.js +1 -1
  37. package/native/index.cjs.js +1 -1
  38. package/native/index.js +1 -0
  39. package/package.json +2 -2
  40. package/web/Loader.js +0 -2
  41. package/web/index.cjs.js +1 -1
  42. package/web/index.js +1 -0
  43. package/web/pivotControls/AxisArrow.js +0 -3
  44. package/web/pivotControls/AxisRotator.js +0 -3
  45. package/web/pivotControls/PlaneSlider.js +0 -3
  46. package/web/pivotControls/index.js +0 -5
  47. package/src/core/AccumulativeShadows.js +0 -311
  48. package/src/core/AdaptiveDpr.js +0 -28
  49. package/src/core/AdaptiveEvents.js +0 -20
  50. package/src/core/ArcballControls.js +0 -67
  51. package/src/core/AsciiRenderer.js +0 -60
  52. package/src/core/BBAnchor.js +0 -37
  53. package/src/core/Backdrop.js +0 -36
  54. package/src/core/BakeShadows.js +0 -16
  55. package/src/core/Billboard.js +0 -41
  56. package/src/core/Bounds.js +0 -245
  57. package/src/core/CameraControls.js +0 -92
  58. package/src/core/CameraShake.js +0 -61
  59. package/src/core/CatmullRomLine.js +0 -44
  60. package/src/core/Caustics.js +0 -375
  61. package/src/core/Center.js +0 -66
  62. package/src/core/Clone.js +0 -102
  63. package/src/core/Cloud.js +0 -59
  64. package/src/core/ComputedAttribute.js +0 -34
  65. package/src/core/ContactShadows.js +0 -114
  66. package/src/core/CubeCamera.js +0 -43
  67. package/src/core/CubicBezierLine.js +0 -28
  68. package/src/core/CurveModifier.js +0 -34
  69. package/src/core/Decal.js +0 -92
  70. package/src/core/Detailed.js +0 -34
  71. package/src/core/DeviceOrientationControls.js +0 -51
  72. package/src/core/Edges.js +0 -36
  73. package/src/core/Effects.js +0 -93
  74. package/src/core/Environment.js +0 -132
  75. package/src/core/Example.js +0 -42
  76. package/src/core/FaceControls.js +0 -315
  77. package/src/core/FaceLandmarker.js +0 -43
  78. package/src/core/Facemesh.js +0 -4545
  79. package/src/core/FirstPersonControls.js +0 -38
  80. package/src/core/Float.js +0 -36
  81. package/src/core/FlyControls.js +0 -55
  82. package/src/core/GizmoHelper.js +0 -111
  83. package/src/core/GizmoViewcube.js +0 -152
  84. package/src/core/GizmoViewport.js +0 -152
  85. package/src/core/Gltf.js +0 -20
  86. package/src/core/GradientTexture.js +0 -33
  87. package/src/core/Grid.js +0 -112
  88. package/src/core/Hud.js +0 -58
  89. package/src/core/Image.js +0 -119
  90. package/src/core/Instances.js +0 -215
  91. package/src/core/Lightformer.js +0 -51
  92. package/src/core/Line.js +0 -68
  93. package/src/core/MapControls.js +0 -64
  94. package/src/core/MarchingCubes.js +0 -76
  95. package/src/core/Mask.js +0 -42
  96. package/src/core/MeshDiscardMaterial.js +0 -15
  97. package/src/core/MeshDistortMaterial.js +0 -79
  98. package/src/core/MeshPortalMaterial.js +0 -381
  99. package/src/core/MeshReflectorMaterial.js +0 -182
  100. package/src/core/MeshRefractionMaterial.js +0 -79
  101. package/src/core/MeshTransmissionMaterial.js +0 -395
  102. package/src/core/MeshWobbleMaterial.js +0 -65
  103. package/src/core/OrbitControls.js +0 -82
  104. package/src/core/OrthographicCamera.js +0 -77
  105. package/src/core/PerformanceMonitor.js +0 -121
  106. package/src/core/PerspectiveCamera.js +0 -73
  107. package/src/core/PointMaterial.js +0 -36
  108. package/src/core/PointerLockControls.js +0 -90
  109. package/src/core/Points.js +0 -227
  110. package/src/core/PositionalAudio.js +0 -51
  111. package/src/core/Preload.js +0 -45
  112. package/src/core/QuadraticBezierLine.js +0 -44
  113. package/src/core/Reflector.js +0 -182
  114. package/src/core/RenderTexture.js +0 -96
  115. package/src/core/Resize.js +0 -39
  116. package/src/core/RoundedBox.js +0 -52
  117. package/src/core/Sampler.js +0 -85
  118. package/src/core/ScreenQuad.js +0 -24
  119. package/src/core/ScreenSpace.js +0 -25
  120. package/src/core/Segments.js +0 -102
  121. package/src/core/Shadow.js +0 -42
  122. package/src/core/Sky.js +0 -39
  123. package/src/core/Sparkles.js +0 -139
  124. package/src/core/SpotLight.js +0 -231
  125. package/src/core/SpriteAnimator.js +0 -342
  126. package/src/core/Stage.js +0 -135
  127. package/src/core/Stars.js +0 -108
  128. package/src/core/Stats.js +0 -30
  129. package/src/core/Svg.js +0 -59
  130. package/src/core/Text.js +0 -58
  131. package/src/core/Text3D.js +0 -76
  132. package/src/core/TrackballControls.js +0 -72
  133. package/src/core/Trail.js +0 -161
  134. package/src/core/TransformControls.js +0 -106
  135. package/src/core/Wireframe.js +0 -185
  136. package/src/core/meshBounds.js +0 -38
  137. package/src/core/shaderMaterial.js +0 -39
  138. package/src/core/shapes.js +0 -68
  139. package/src/core/softShadows.js +0 -161
  140. package/src/core/useAnimations.js +0 -56
  141. package/src/core/useAspect.js +0 -10
  142. package/src/core/useBVH.js +0 -90
  143. package/src/core/useBoxProjectedEnv.js +0 -98
  144. package/src/core/useCamera.js +0 -27
  145. package/src/core/useContextBridge.js +0 -21
  146. package/src/core/useCubeCamera.js +0 -49
  147. package/src/core/useCubeTexture.js +0 -18
  148. package/src/core/useDepthBuffer.js +0 -38
  149. package/src/core/useDetectGPU.js +0 -6
  150. package/src/core/useEnvironment.js +0 -48
  151. package/src/core/useFBO.js +0 -53
  152. package/src/core/useFBX.js +0 -12
  153. package/src/core/useFont.js +0 -20
  154. package/src/core/useGLTF.js +0 -37
  155. package/src/core/useHelper.js +0 -31
  156. package/src/core/useIntersect.js +0 -39
  157. package/src/core/useKTX2.js +0 -38
  158. package/src/core/useMatcapTexture.js +0 -45
  159. package/src/core/useNormalTexture.js +0 -30
  160. package/src/core/useProgress.js +0 -50
  161. package/src/core/useTexture.js +0 -35
  162. package/src/core/useTrailTexture.js +0 -164
  163. package/src/core/useVideoTexture.js +0 -41
  164. package/src/helpers/environment-assets.js +0 -14
  165. package/src/helpers/useEffectfulState.js +0 -18
  166. package/src/materials/BlurPass.js +0 -75
  167. package/src/materials/ConvolutionMaterial.js +0 -99
  168. package/src/materials/DiscardMaterial.js +0 -5
  169. package/src/materials/MeshReflectorMaterial.js +0 -290
  170. package/src/materials/MeshRefractionMaterial.js +0 -171
  171. package/src/materials/SpotLightMaterial.js +0 -111
  172. package/src/materials/WireframeMaterial.js +0 -235
  173. package/src/web/CycleRaycast.js +0 -97
  174. package/src/web/Html.js +0 -417
  175. package/src/web/KeyboardControls.js +0 -101
  176. package/src/web/Loader.js +0 -98
  177. package/src/web/PresentationControls.js +0 -86
  178. package/src/web/ScrollControls.js +0 -246
  179. package/src/web/Select.js +0 -175
  180. package/src/web/View.js +0 -206
  181. package/src/web/pivotControls/AxisArrow.js +0 -202
  182. package/src/web/pivotControls/AxisRotator.js +0 -235
  183. package/src/web/pivotControls/PlaneSlider.js +0 -211
  184. package/src/web/pivotControls/context.js +0 -5
  185. package/src/web/pivotControls/index.js +0 -223
  186. package/src/web/useCursor.js +0 -12
  187. /package/{src/helpers → helpers}/glsl/DefaultSpotlightShadowShadows.glsl.js +0 -0
  188. /package/{src/helpers → helpers}/glsl/distort.vert.glsl.js +0 -0
  189. /package/{src/index.js → index.js} +0 -0
@@ -1,235 +0,0 @@
1
- import * as THREE from 'three';
2
- import * as React from 'react';
3
- import { shaderMaterial } from '../core/shaderMaterial.js';
4
-
5
- const WireframeMaterialShaders = {
6
- uniforms: {
7
- strokeOpacity: 1,
8
- fillOpacity: 0.25,
9
- fillMix: 0,
10
- thickness: 0.05,
11
- colorBackfaces: false,
12
- dashInvert: true,
13
- dash: false,
14
- dashRepeats: 4,
15
- dashLength: 0.5,
16
- squeeze: false,
17
- squeezeMin: 0.2,
18
- squeezeMax: 1,
19
- stroke: new THREE.Color('#ff0000'),
20
- backfaceStroke: new THREE.Color('#0000ff'),
21
- fill: new THREE.Color('#00ff00')
22
- },
23
- vertex:
24
- /* glsl */
25
- `
26
- attribute vec3 barycentric;
27
-
28
- varying vec3 v_edges_Barycentric;
29
- varying vec3 v_edges_Position;
30
-
31
- void initWireframe() {
32
- v_edges_Barycentric = barycentric;
33
- v_edges_Position = position.xyz;
34
- }
35
- `,
36
- fragment:
37
- /* glsl */
38
- `
39
- #ifndef PI
40
- #define PI 3.1415926535897932384626433832795
41
- #endif
42
-
43
- varying vec3 v_edges_Barycentric;
44
- varying vec3 v_edges_Position;
45
-
46
- uniform float strokeOpacity;
47
- uniform float fillOpacity;
48
- uniform float fillMix;
49
- uniform float thickness;
50
- uniform bool colorBackfaces;
51
-
52
- // Dash
53
- uniform bool dashInvert;
54
- uniform bool dash;
55
- uniform bool dashOnly;
56
- uniform float dashRepeats;
57
- uniform float dashLength;
58
-
59
- // Squeeze
60
- uniform bool squeeze;
61
- uniform float squeezeMin;
62
- uniform float squeezeMax;
63
-
64
- // Colors
65
- uniform vec3 stroke;
66
- uniform vec3 backfaceStroke;
67
- uniform vec3 fill;
68
-
69
- // This is like
70
- float wireframe_aastep(float threshold, float dist) {
71
- float afwidth = fwidth(dist) * 0.5;
72
- return smoothstep(threshold - afwidth, threshold + afwidth, dist);
73
- }
74
-
75
- float wireframe_map(float value, float min1, float max1, float min2, float max2) {
76
- return min2 + (value - min1) * (max2 - min2) / (max1 - min1);
77
- }
78
-
79
- float getWireframe() {
80
- vec3 barycentric = v_edges_Barycentric;
81
-
82
- // Distance from center of each triangle to its edges.
83
- float d = min(min(barycentric.x, barycentric.y), barycentric.z);
84
-
85
- // for dashed rendering, we can use this to get the 0 .. 1 value of the line length
86
- float positionAlong = max(barycentric.x, barycentric.y);
87
- if (barycentric.y < barycentric.x && barycentric.y < barycentric.z) {
88
- positionAlong = 1.0 - positionAlong;
89
- }
90
-
91
- // the thickness of the stroke
92
- float computedThickness = wireframe_map(thickness, 0.0, 1.0, 0.0, 0.34);
93
-
94
- // if we want to shrink the thickness toward the center of the line segment
95
- if (squeeze) {
96
- computedThickness *= mix(squeezeMin, squeezeMax, (1.0 - sin(positionAlong * PI)));
97
- }
98
-
99
- // Create dash pattern
100
- if (dash) {
101
- // here we offset the stroke position depending on whether it
102
- // should overlap or not
103
- float offset = 1.0 / dashRepeats * dashLength / 2.0;
104
- if (!dashInvert) {
105
- offset += 1.0 / dashRepeats / 2.0;
106
- }
107
-
108
- // if we should animate the dash or not
109
- // if (dashAnimate) {
110
- // offset += time * 0.22;
111
- // }
112
-
113
- // create the repeating dash pattern
114
- float pattern = fract((positionAlong + offset) * dashRepeats);
115
- computedThickness *= 1.0 - wireframe_aastep(dashLength, pattern);
116
- }
117
-
118
- // compute the anti-aliased stroke edge
119
- float edge = 1.0 - wireframe_aastep(computedThickness, d);
120
-
121
- return edge;
122
- }
123
- `
124
- };
125
- const WireframeMaterial = shaderMaterial(WireframeMaterialShaders.uniforms, WireframeMaterialShaders.vertex +
126
- /* glsl */
127
- `
128
- void main() {
129
- initWireframe();
130
- gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
131
- }
132
- `, WireframeMaterialShaders.fragment +
133
- /* glsl */
134
- `
135
- void main () {
136
- // Compute color
137
-
138
- float edge = getWireframe();
139
- vec4 colorStroke = vec4(stroke, edge);
140
-
141
- #ifdef FLIP_SIDED
142
- colorStroke.rgb = backfaceStroke;
143
- #endif
144
-
145
- vec4 colorFill = vec4(fill, fillOpacity);
146
- vec4 outColor = mix(colorFill, colorStroke, edge * strokeOpacity);
147
-
148
- gl_FragColor = outColor;
149
- }
150
- `);
151
- function setWireframeOverride(material, uniforms) {
152
- material.onBeforeCompile = shader => {
153
- shader.uniforms = { ...shader.uniforms,
154
- ...uniforms
155
- };
156
- shader.vertexShader = shader.vertexShader.replace('void main() {', `
157
- ${WireframeMaterialShaders.vertex}
158
- void main() {
159
- initWireframe();
160
- `);
161
- shader.fragmentShader = shader.fragmentShader.replace('void main() {', `
162
- ${WireframeMaterialShaders.fragment}
163
- void main() {
164
- `);
165
- shader.fragmentShader = shader.fragmentShader.replace('#include <color_fragment>',
166
- /* glsl */
167
- `
168
- #include <color_fragment>
169
- float edge = getWireframe();
170
- vec4 colorStroke = vec4(stroke, edge);
171
- #ifdef FLIP_SIDED
172
- colorStroke.rgb = backfaceStroke;
173
- #endif
174
- vec4 colorFill = vec4(mix(diffuseColor.rgb, fill, fillMix), mix(diffuseColor.a, fillOpacity, fillMix));
175
- vec4 outColor = mix(colorFill, colorStroke, edge * strokeOpacity);
176
-
177
- diffuseColor.rgb = outColor.rgb;
178
- diffuseColor.a *= outColor.a;
179
- `);
180
- };
181
-
182
- material.side = THREE.DoubleSide;
183
- material.transparent = true;
184
- }
185
- function useWireframeUniforms(uniforms, props) {
186
- React.useEffect(() => {
187
- var _props$fillOpacity;
188
-
189
- return void (uniforms.fillOpacity.value = (_props$fillOpacity = props.fillOpacity) !== null && _props$fillOpacity !== void 0 ? _props$fillOpacity : uniforms.fillOpacity.value);
190
- }, [props.fillOpacity]);
191
- React.useEffect(() => {
192
- var _props$fillMix;
193
-
194
- return void (uniforms.fillMix.value = (_props$fillMix = props.fillMix) !== null && _props$fillMix !== void 0 ? _props$fillMix : uniforms.fillMix.value);
195
- }, [props.fillMix]);
196
- React.useEffect(() => {
197
- var _props$strokeOpacity;
198
-
199
- return void (uniforms.strokeOpacity.value = (_props$strokeOpacity = props.strokeOpacity) !== null && _props$strokeOpacity !== void 0 ? _props$strokeOpacity : uniforms.strokeOpacity.value);
200
- }, [props.strokeOpacity]);
201
- React.useEffect(() => {
202
- var _props$thickness;
203
-
204
- return void (uniforms.thickness.value = (_props$thickness = props.thickness) !== null && _props$thickness !== void 0 ? _props$thickness : uniforms.thickness.value);
205
- }, [props.thickness]);
206
- React.useEffect(() => void (uniforms.colorBackfaces.value = !!props.colorBackfaces), [props.colorBackfaces]);
207
- React.useEffect(() => void (uniforms.dash.value = !!props.dash), [props.dash]);
208
- React.useEffect(() => void (uniforms.dashInvert.value = !!props.dashInvert), [props.dashInvert]);
209
- React.useEffect(() => {
210
- var _props$dashRepeats;
211
-
212
- return void (uniforms.dashRepeats.value = (_props$dashRepeats = props.dashRepeats) !== null && _props$dashRepeats !== void 0 ? _props$dashRepeats : uniforms.dashRepeats.value);
213
- }, [props.dashRepeats]);
214
- React.useEffect(() => {
215
- var _props$dashLength;
216
-
217
- return void (uniforms.dashLength.value = (_props$dashLength = props.dashLength) !== null && _props$dashLength !== void 0 ? _props$dashLength : uniforms.dashLength.value);
218
- }, [props.dashLength]);
219
- React.useEffect(() => void (uniforms.squeeze.value = !!props.squeeze), [props.squeeze]);
220
- React.useEffect(() => {
221
- var _props$squeezeMin;
222
-
223
- return void (uniforms.squeezeMin.value = (_props$squeezeMin = props.squeezeMin) !== null && _props$squeezeMin !== void 0 ? _props$squeezeMin : uniforms.squeezeMin.value);
224
- }, [props.squeezeMin]);
225
- React.useEffect(() => {
226
- var _props$squeezeMax;
227
-
228
- return void (uniforms.squeezeMax.value = (_props$squeezeMax = props.squeezeMax) !== null && _props$squeezeMax !== void 0 ? _props$squeezeMax : uniforms.squeezeMax.value);
229
- }, [props.squeezeMax]);
230
- React.useEffect(() => void (uniforms.stroke.value = props.stroke ? new THREE.Color(props.stroke) : uniforms.stroke.value), [props.stroke]);
231
- React.useEffect(() => void (uniforms.fill.value = props.fill ? new THREE.Color(props.fill) : uniforms.fill.value), [props.fill]);
232
- React.useEffect(() => void (uniforms.backfaceStroke.value = props.backfaceStroke ? new THREE.Color(props.backfaceStroke) : uniforms.backfaceStroke.value), [props.backfaceStroke]);
233
- }
234
-
235
- export { WireframeMaterial, WireframeMaterialShaders, setWireframeOverride, useWireframeUniforms };
@@ -1,97 +0,0 @@
1
- import * as React from 'react';
2
- import { useThree } from '@react-three/fiber';
3
-
4
- function CycleRaycast({
5
- onChanged,
6
- portal,
7
- preventDefault = true,
8
- scroll = true,
9
- keyCode = 9
10
- }) {
11
- const cycle = React.useRef(0);
12
- const setEvents = useThree(state => state.setEvents);
13
- const get = useThree(state => state.get);
14
- const gl = useThree(state => state.gl);
15
- React.useEffect(() => {
16
- var _portal$current;
17
-
18
- let hits = [];
19
- let lastEvent = undefined;
20
- const prev = get().events.filter;
21
- const target = (_portal$current = portal == null ? void 0 : portal.current) !== null && _portal$current !== void 0 ? _portal$current : gl.domElement.parentNode; // Render custom status
22
-
23
- const renderStatus = () => target && onChanged && onChanged(hits, Math.round(cycle.current) % hits.length); // Overwrite the raycasters custom filter (this only exists in r3f)
24
-
25
-
26
- setEvents({
27
- filter: (intersections, state) => {
28
- // Reset cycle when the intersections change
29
- let clone = [...intersections];
30
-
31
- if (clone.length !== hits.length || !hits.every(hit => clone.map(e => e.object.uuid).includes(hit.object.uuid))) {
32
- cycle.current = 0;
33
- hits = clone;
34
- renderStatus();
35
- } // Run custom filter if there is one
36
-
37
-
38
- if (prev) clone = prev(clone, state); // Cycle through the actual raycast intersects
39
-
40
- for (let i = 0; i < Math.round(cycle.current) % clone.length; i++) {
41
- const first = clone.shift();
42
- clone = [...clone, first];
43
- }
44
-
45
- return clone;
46
- }
47
- }); // Cycle, refresh events and render status
48
-
49
- const refresh = fn => {
50
- var _get$events$handlers, _get$events$handlers2;
51
-
52
- cycle.current = fn(cycle.current); // Cancel hovered elements and fake a pointer-move
53
-
54
- (_get$events$handlers = get().events.handlers) == null ? void 0 : _get$events$handlers.onPointerCancel(undefined);
55
- (_get$events$handlers2 = get().events.handlers) == null ? void 0 : _get$events$handlers2.onPointerMove(lastEvent);
56
- renderStatus();
57
- }; // Key events
58
-
59
-
60
- const tabEvent = event => {
61
- if (event.keyCode || event.which === keyCode) {
62
- if (preventDefault) event.preventDefault();
63
- if (hits.length > 1) refresh(current => current + 1);
64
- }
65
- }; // Wheel events
66
-
67
-
68
- const wheelEvent = event => {
69
- if (preventDefault) event.preventDefault();
70
- let delta = 0;
71
- if (!event) event = window.event;
72
- if (event.wheelDelta) delta = event.wheelDelta / 120;else if (event.detail) delta = -event.detail / 3;
73
- if (hits.length > 1) refresh(current => Math.abs(current - delta));
74
- }; // Catch last move event and position custom status
75
-
76
-
77
- const moveEvent = event => lastEvent = event;
78
-
79
- document.addEventListener('pointermove', moveEvent, {
80
- passive: true
81
- });
82
- if (scroll) document.addEventListener('wheel', wheelEvent);
83
- if (keyCode !== undefined) document.addEventListener('keydown', tabEvent);
84
- return () => {
85
- // Clean up
86
- setEvents({
87
- filter: prev
88
- });
89
- if (keyCode !== undefined) document.removeEventListener('keydown', tabEvent);
90
- if (scroll) document.removeEventListener('wheel', wheelEvent);
91
- document.removeEventListener('pointermove', moveEvent);
92
- };
93
- }, [gl, get, setEvents, preventDefault, scroll, keyCode]);
94
- return null;
95
- }
96
-
97
- export { CycleRaycast };