@react-three/drei 8.18.9 → 9.0.0-beta.2
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 +61 -254
- package/core/ArcballControls.cjs.js +1 -1
- package/core/ArcballControls.js +26 -17
- package/core/Billboard.d.ts +2 -2
- package/core/Bounds.cjs.js +1 -1
- package/core/Bounds.d.ts +1 -2
- package/core/Bounds.js +15 -26
- package/core/Center.d.ts +1 -1
- package/core/ContactShadows.cjs.js +1 -1
- package/core/ContactShadows.d.ts +1 -1
- package/core/ContactShadows.js +1 -2
- package/core/CubeCamera.cjs.js +1 -1
- package/core/CubeCamera.js +7 -7
- package/core/Detailed.d.ts +2 -2
- package/core/DeviceOrientationControls.cjs.js +1 -1
- package/core/DeviceOrientationControls.d.ts +1 -1
- package/core/DeviceOrientationControls.js +6 -2
- package/core/Effects.cjs.js +1 -1
- package/core/Effects.d.ts +2 -2
- package/core/Effects.js +2 -2
- package/core/Environment.cjs.js +1 -1
- package/core/Environment.d.ts +3 -13
- package/core/Environment.js +30 -95
- package/core/FirstPersonControls.cjs.js +1 -1
- package/core/FirstPersonControls.d.ts +1 -1
- package/core/FirstPersonControls.js +6 -2
- package/core/Float.cjs.js +1 -1
- package/core/Float.d.ts +1 -1
- package/core/Float.js +4 -5
- package/core/FlyControls.d.ts +1 -1
- package/core/GizmoHelper.cjs.js +1 -1
- package/core/GizmoHelper.d.ts +1 -2
- package/core/GizmoHelper.js +41 -31
- package/core/GizmoViewcube.cjs.js +1 -1
- package/core/GizmoViewcube.d.ts +2 -2
- package/core/GizmoViewcube.js +1 -1
- package/core/GizmoViewport.d.ts +2 -2
- package/core/Image.cjs.js +1 -1
- package/core/Image.d.ts +2 -4
- package/core/Image.js +1 -6
- package/core/Instances.cjs.js +1 -1
- package/core/Instances.d.ts +3 -3
- package/core/Instances.js +11 -5
- package/core/Line.d.ts +1 -1
- package/core/MapControls.d.ts +1 -1
- package/core/MeshDistortMaterial.d.ts +2 -4
- package/core/MeshReflectorMaterial.cjs.js +1 -1
- package/core/MeshReflectorMaterial.d.ts +2 -1
- package/core/MeshReflectorMaterial.js +3 -1
- package/core/MeshWobbleMaterial.d.ts +2 -4
- package/core/OrbitControls.cjs.js +1 -1
- package/core/OrbitControls.js +32 -22
- package/core/OrthographicCamera.d.ts +2 -2
- package/core/PerspectiveCamera.d.ts +2 -2
- package/core/PointMaterial.cjs.js +1 -1
- package/core/PointMaterial.d.ts +7 -3
- package/core/PointMaterial.js +32 -14
- package/core/PointerLockControls.cjs.js +1 -1
- package/core/PointerLockControls.d.ts +1 -2
- package/core/PointerLockControls.js +22 -35
- package/core/Points.cjs.js +1 -1
- package/core/Points.d.ts +3 -3
- package/core/Points.js +36 -17
- package/core/PositionalAudio.d.ts +2 -2
- package/core/Reflector.d.ts +1 -1
- package/core/RoundedBox.d.ts +1 -1
- package/core/ScreenQuad.d.ts +1 -1
- package/core/Segments.d.ts +1 -1
- package/core/Shadow.d.ts +2 -2
- package/core/SpotLight.d.ts +20 -4
- package/core/Stage.cjs.js +1 -1
- package/core/Stage.js +2 -1
- package/core/Stars.cjs.js +1 -1
- package/core/Stars.js +3 -6
- package/core/Text.cjs.js +1 -1
- package/core/Text.d.ts +2 -3
- package/core/Text.js +2 -3
- package/core/TrackballControls.cjs.js +1 -1
- package/core/TrackballControls.d.ts +1 -1
- package/core/TrackballControls.js +6 -11
- package/core/TransformControls.cjs.js +1 -1
- package/core/TransformControls.d.ts +1 -1
- package/core/TransformControls.js +12 -4
- package/core/index.cjs.js +1 -1
- package/core/index.d.ts +0 -4
- package/core/index.js +2 -7
- package/core/shapes.d.ts +17 -17
- package/core/useFBX.d.ts +1 -1
- package/core/useFBX.js +1 -2
- package/core/useGLTF.d.ts +1 -1
- package/core/useGLTF.js +1 -2
- package/core/useHelper.d.ts +1 -3
- package/core/useKTX2.d.ts +1 -1
- package/core/useKTX2.js +1 -2
- package/core/useTexture.d.ts +1 -1
- package/core/useTexture.js +1 -2
- package/index.cjs.js +1 -1
- package/index.js +1 -5
- package/materials/ConvolutionMaterial.cjs.js +1 -1
- package/materials/ConvolutionMaterial.js +0 -2
- package/materials/MeshReflectorMaterial.cjs.js +1 -1
- package/materials/MeshReflectorMaterial.d.ts +3 -0
- package/materials/MeshReflectorMaterial.js +27 -1
- package/materials/SpotLightMaterial.cjs.js +1 -1
- package/materials/SpotLightMaterial.js +0 -3
- package/native/index.cjs.js +1 -1
- package/native/index.js +2 -7
- package/package.json +6 -7
- package/web/Html.cjs.js +1 -1
- package/web/Html.js +6 -4
- package/web/Select.js +0 -1
- package/web/index.cjs.js +1 -1
- package/web/index.js +2 -7
- package/core/Clone.cjs.js +0 -1
- package/core/Clone.d.ts +0 -11
- package/core/Clone.js +0 -89
- package/core/Lightformer.cjs.js +0 -1
- package/core/Lightformer.d.ts +0 -41
- package/core/Lightformer.js +0 -51
- package/core/Trail.cjs.js +0 -1
- package/core/Trail.d.ts +0 -20
- package/core/Trail.js +0 -160
- package/core/useBoxProjectedEnv.cjs.js +0 -1
- package/core/useBoxProjectedEnv.d.ts +0 -8
- package/core/useBoxProjectedEnv.js +0 -98
package/README.md
CHANGED
|
@@ -4,13 +4,13 @@
|
|
|
4
4
|
[](https://www.npmjs.com/package/@react-three/drei)
|
|
5
5
|
[](https://discord.gg/poimandres)
|
|
6
6
|
|
|
7
|
-
A growing collection of useful helpers and fully functional, ready-made abstractions for [react-three
|
|
7
|
+
A growing collection of useful helpers and fully functional, ready-made abstractions for [@react-three/fiber](https://github.com/pmndrs/react-three-fiber). If you make a component that is generic enough to be useful to others, think about making it available here through a PR!
|
|
8
8
|
|
|
9
9
|
```bash
|
|
10
10
|
npm install @react-three/drei
|
|
11
11
|
```
|
|
12
12
|
|
|
13
|
-
:point_right: this package is using the stand-alone [`three-stdlib`](https://github.com/pmndrs/three-stdlib) instead of [`three/examples/jsm`](https://github.com/mrdoob/three.js/tree/
|
|
13
|
+
:point_right: this package is using the stand-alone [`three-stdlib`](https://github.com/pmndrs/three-stdlib) instead of [`three/examples/jsm`](https://github.com/mrdoob/three.js/tree/master/examples/jsm). :point_left:
|
|
14
14
|
|
|
15
15
|
### Basic usage:
|
|
16
16
|
|
|
@@ -65,8 +65,6 @@ The `native` route of the library **does not** export `Html` or `Loader`. The de
|
|
|
65
65
|
<li><a href="#effects">Effects</a></li>
|
|
66
66
|
<li><a href="#gradienttexture">GradientTexture</a></li>
|
|
67
67
|
<li><a href="#edges">Edges</a></li>
|
|
68
|
-
<li><a href="#trail">Trail</a></li>
|
|
69
|
-
<li><a href="#clone">Clone</a></li>
|
|
70
68
|
<li><a href="#useanimations">useAnimations</a></li>
|
|
71
69
|
</ul>
|
|
72
70
|
<li><a href="#shaders">Shaders</a></li>
|
|
@@ -101,8 +99,6 @@ The `native` route of the library **does not** export `Html` or `Loader`. The de
|
|
|
101
99
|
<li><a href="#useaspect">useAspect</a></li>
|
|
102
100
|
<li><a href="#usecursor">useCursor</a></li>
|
|
103
101
|
<li><a href="#useintersect">useIntersect</a></li>
|
|
104
|
-
<li><a href="#useboxprojectedenv">useBoxProjectedEnv</a></li>
|
|
105
|
-
<li><a href="#useTrail">useTrail</a></li>
|
|
106
102
|
</ul>
|
|
107
103
|
<li><a href="#loading">Loaders</a></li>
|
|
108
104
|
<ul>
|
|
@@ -163,7 +159,6 @@ The `native` route of the library **does not** export `Html` or `Loader`. The de
|
|
|
163
159
|
<li><a href="#stage">Stage</a></li>
|
|
164
160
|
<li><a href="#backdrop">Backdrop</a></li>
|
|
165
161
|
<li><a href="#environment">Environment</a></li>
|
|
166
|
-
<li><a href="#lightformer">Lightformer</a></li>
|
|
167
162
|
<li><a href="#spotlight">SpotLight</a></li>
|
|
168
163
|
<li><a href="#shadow">Shadow</a></li>
|
|
169
164
|
<li><a href="#contactshadows">ContactShadows</a></li>
|
|
@@ -184,7 +179,7 @@ The `native` route of the library **does not** export `Html` or `Loader`. The de
|
|
|
184
179
|
|
|
185
180
|
[](https://drei.vercel.app/?path=/story/camera-perspectivecamera--perspective-camera-scene-st)
|
|
186
181
|
|
|
187
|
-
A responsive [THREE.PerspectiveCamera](https://threejs.org/docs
|
|
182
|
+
A responsive [THREE.PerspectiveCamera](https://threejs.org/docs/#api/en/cameras/PerspectiveCamera) that can set itself as the default.
|
|
188
183
|
|
|
189
184
|
```jsx
|
|
190
185
|
<PerspectiveCamera makeDefault {...props} />
|
|
@@ -209,7 +204,7 @@ You can also drive it manually, it won't be responsive and you have to calculate
|
|
|
209
204
|
|
|
210
205
|
[](https://drei.vercel.app/?path=/story/camera-orthographiccamera--orthographic-camera-scene-st)
|
|
211
206
|
|
|
212
|
-
A responsive [THREE.OrthographicCamera](https://threejs.org/docs
|
|
207
|
+
A responsive [THREE.OrthographicCamera](https://threejs.org/docs/#api/en/cameras/OrthographicCamera) that can set itself as the default.
|
|
213
208
|
|
|
214
209
|
```jsx
|
|
215
210
|
<OrthographicCamera makeDefault {...props}>
|
|
@@ -221,7 +216,7 @@ A responsive [THREE.OrthographicCamera](https://threejs.org/docs/index.html#api/
|
|
|
221
216
|
|
|
222
217
|
[](https://drei.pmnd.rs/?path=/story/camera-cubecamera--default-story)
|
|
223
218
|
|
|
224
|
-
A [THREE.CubeCamera](https://threejs.org/docs
|
|
219
|
+
A [THREE.CubeCamera](https://threejs.org/docs/#api/en/cameras/CubeCamera) that returns its texture as a render-prop. It makes children invisible while rendering to the internal buffer so that they are not included in the reflection.
|
|
225
220
|
|
|
226
221
|
Using the `frames` prop you can control if this camera renders indefinitively or statically (a given number of times).
|
|
227
222
|
If you have two static objects in the scene, make it `frames={2}` for instance, so that both objects get to "see" one another in the reflections, which takes multiple renders.
|
|
@@ -240,15 +235,15 @@ If you have moving objects, unset the prop and use a smaller `resolution` instea
|
|
|
240
235
|
|
|
241
236
|
# Controls
|
|
242
237
|
|
|
243
|
-
If available controls have damping enabled by default, they manage their own updates, remove themselves on unmount, are compatible with the `invalidateFrameloop` canvas-flag. They inherit all props from their underlying [THREE controls](https://github.com/mrdoob/three.js/tree/
|
|
238
|
+
If available controls have damping enabled by default, they manage their own updates, remove themselves on unmount, are compatible with the `invalidateFrameloop` canvas-flag. They inherit all props from their underlying [THREE controls](https://github.com/mrdoob/three.js/tree/master/examples/jsm/controls).
|
|
244
239
|
|
|
245
|
-
Some controls allow you to set `makeDefault`, similar to, for instance, PerspectiveCamera. This will set react-three
|
|
240
|
+
Some controls allow you to set `makeDefault`, similar to, for instance, PerspectiveCamera. This will set @react-three/fiber's `controls` field in the root store. This can make it easier in situations where you want controls to be known and other parts of the app could respond to it. Some drei controls already take it into account, like CameraShake, Gizmo and TransformControls.
|
|
246
241
|
|
|
247
242
|
Drei currently exports OrbitControls [](https://drei.vercel.app/?path=/story/controls-orbitcontrols--orbit-controls-story), MapControls [](https://drei.vercel.app/?path=/story/controls-mapcontrols--map-controls-scene-st), TrackballControls, ArcballControls, FlyControls, DeviceOrientationControls, PointerLockControls [](https://drei.vercel.app/?path=/story/controls-pointerlockcontrols--pointer-lock-controls-scene-st), FirstPersonControls [](https://drei.vercel.app/?path=/story/controls-firstpersoncontrols--first-person-controls-story)
|
|
248
243
|
|
|
249
244
|
All controls react to the default camera. If you have a `<PerspectiveCamera makeDefault />` in your scene, they will control it. If you need to inject an imperative camera or one that isn't the default, use the `camera` prop: `<OrbitControls camera={MyCamera} />`.
|
|
250
245
|
|
|
251
|
-
PointerLockControls additionally supports a `selector` prop, which enables the binding of `click` event handlers for control activation to other elements than `document` (e.g. a 'Click here to play' button). All elements matching the `selector` prop will activate the controls.
|
|
246
|
+
PointerLockControls additionally supports a `selector` prop, which enables the binding of `click` event handlers for control activation to other elements than `document` (e.g. a 'Click here to play' button). All elements matching the `selector` prop will activate the controls.
|
|
252
247
|
|
|
253
248
|
# TransformControls
|
|
254
249
|
|
|
@@ -258,7 +253,7 @@ PointerLockControls additionally supports a `selector` prop, which enables the b
|
|
|
258
253
|
<a href="https://codesandbox.io/s/btsbj"><img width="20%" src="https://codesandbox.io/api/v1/sandboxes/btsbj/screenshot.png" alt="Tranform controls"/></a>
|
|
259
254
|
</p>
|
|
260
255
|
|
|
261
|
-
An abstraction around [THREE.TransformControls](https://threejs.org/docs
|
|
256
|
+
An abstraction around [THREE.TransformControls](https://threejs.org/docs/#examples/en/controls/TransformControls).
|
|
262
257
|
|
|
263
258
|
You can wrap objects which then receive a transform gizmo.
|
|
264
259
|
|
|
@@ -369,7 +364,7 @@ Semi-OrbitControls with spring-physics, polar zoom and snap-back, for presentati
|
|
|
369
364
|
rotation={[0, 0, 0]} // Default rotation
|
|
370
365
|
polar={[0, Math.PI / 2]} // Vertical limits
|
|
371
366
|
azimuth={[-Infinity, Infinity]} // Horizontal limits
|
|
372
|
-
config={
|
|
367
|
+
config = { mass: 1, tension: 170, friction: 26 } // Spring config
|
|
373
368
|
>
|
|
374
369
|
<mesh />
|
|
375
370
|
</PresentationControls>
|
|
@@ -377,12 +372,12 @@ Semi-OrbitControls with spring-physics, polar zoom and snap-back, for presentati
|
|
|
377
372
|
|
|
378
373
|
# Shapes
|
|
379
374
|
|
|
380
|
-
[Buffer-geometry](https://threejs.org/docs
|
|
375
|
+
[Buffer-geometry](https://threejs.org/docs/#api/en/core/BufferGeometry) short-cuts for Plane, Box, Sphere, Circle, Cone, Cylinder, Tube, Torus, TorusKnot, Ring, Tetrahedron, Polyhedron, Icosahedron, Octahedron, Dodecahedron, Extrude, Lathe.
|
|
381
376
|
|
|
382
377
|
```jsx
|
|
383
378
|
<Plane args={[2, 2]} />
|
|
384
379
|
<Sphere>
|
|
385
|
-
<meshBasicMaterial
|
|
380
|
+
<meshBasicMaterial color="hotpink" />
|
|
386
381
|
</Sphere>
|
|
387
382
|
```
|
|
388
383
|
|
|
@@ -392,7 +387,7 @@ A box buffer geometry with rounded corners, done with extrusion.
|
|
|
392
387
|
|
|
393
388
|
```jsx
|
|
394
389
|
<RoundedBox args={[1, 1, 1]} radius={0.05} smoothness={4} {...meshProps}>
|
|
395
|
-
<meshPhongMaterial
|
|
390
|
+
<meshPhongMaterial color="#f3f3f3" wireframe />
|
|
396
391
|
</RoundedBox>
|
|
397
392
|
```
|
|
398
393
|
|
|
@@ -440,7 +435,7 @@ function Foo() {
|
|
|
440
435
|
<a href="https://codesandbox.io/s/yup2o"><img width="20%" src="https://codesandbox.io/api/v1/sandboxes/yup2o/screenshot.png" alt="Demo"/></a>
|
|
441
436
|
</p>
|
|
442
437
|
|
|
443
|
-
Hi-quality text rendering w/ signed distance fields (SDF) and antialiasing, using [troika-3d-text](https://github.com/protectwise/troika/tree/master/packages/troika-3d-text). All of troikas props are valid!
|
|
438
|
+
Hi-quality text rendering w/ signed distance fields (SDF) and antialiasing, using [troika-3d-text](https://github.com/protectwise/troika/tree/master/packages/troika-3d-text). All of troikas props are valid! Text is suspense-based!
|
|
444
439
|
|
|
445
440
|
```jsx
|
|
446
441
|
<Text color="black" anchorX="center" anchorY="middle">
|
|
@@ -448,14 +443,6 @@ Hi-quality text rendering w/ signed distance fields (SDF) and antialiasing, usin
|
|
|
448
443
|
</Text>
|
|
449
444
|
```
|
|
450
445
|
|
|
451
|
-
Text will suspend while loading the font data, but in order to completely avoid FOUC you can pass the characters it needs to render.
|
|
452
|
-
|
|
453
|
-
```jsx
|
|
454
|
-
<Text font={fontUrl} characters="abcdefghijklmnopqrstuvwxyz0123456789!">
|
|
455
|
-
hello world!
|
|
456
|
-
</Text>
|
|
457
|
-
```
|
|
458
|
-
|
|
459
446
|
#### Line
|
|
460
447
|
|
|
461
448
|
[](https://drei.vercel.app/?path=/story/abstractions-line--basic-line)
|
|
@@ -542,7 +529,7 @@ Renders a THREE.Line2 using THREE.CubicBezierCurve3 for interpolation.
|
|
|
542
529
|
|
|
543
530
|
[](https://drei.vercel.app/?path=/story/abstractions-positionalaudio--positional-audio-scene-st) 
|
|
544
531
|
|
|
545
|
-
A wrapper around [THREE.PositionalAudio](https://threejs.org/docs
|
|
532
|
+
A wrapper around [THREE.PositionalAudio](https://threejs.org/docs/#api/en/audio/PositionalAudio). Add this to groups or meshes to tie them to a sound that plays when the camera comes near.
|
|
546
533
|
|
|
547
534
|
```jsx
|
|
548
535
|
<PositionalAudio
|
|
@@ -595,11 +582,11 @@ Make sure to set the `makeDefault` prop on your controls, in that case you do no
|
|
|
595
582
|
|
|
596
583
|
#### Effects
|
|
597
584
|
|
|
598
|
-
Abstraction around threes own [EffectComposer](https://threejs.org/docs
|
|
585
|
+
Abstraction around threes own [EffectComposer](https://threejs.org/docs/#examples/en/postprocessing/EffectComposer).
|
|
599
586
|
|
|
600
587
|
```jsx
|
|
601
588
|
<Effects multisamping={8} renderIndex={1} disableGamma={false} disableRenderPass={false}>
|
|
602
|
-
<lUTPass
|
|
589
|
+
<lUTPass attach="passes" lut={texture3D} />
|
|
603
590
|
</Effects>
|
|
604
591
|
```
|
|
605
592
|
|
|
@@ -630,7 +617,7 @@ A declarative THREE.Texture which attaches to "map" by default. You can use this
|
|
|
630
617
|
<a href="https://codesandbox.io/s/ny3p4"><img width="20%" src="https://codesandbox.io/api/v1/sandboxes/ny3p4/screenshot.png" alt="Demo"/></a>
|
|
631
618
|
</p>
|
|
632
619
|
|
|
633
|
-
Abstracts [THREE.EdgesGeometry](https://threejs.org/docs
|
|
620
|
+
Abstracts [THREE.EdgesGeometry](https://threejs.org/docs/#api/en/geometries/EdgesGeometry). It pulls the geometry automatically from its parent, optionally you can ungroup it and give it a `geometry` prop. You can give it children, for instance a custom material.
|
|
634
621
|
|
|
635
622
|
```jsx
|
|
636
623
|
<mesh>
|
|
@@ -644,94 +631,6 @@ Abstracts [THREE.EdgesGeometry](https://threejs.org/docs/index.html?q=EdgesGeome
|
|
|
644
631
|
</mesh>
|
|
645
632
|
```
|
|
646
633
|
|
|
647
|
-
#### Trail
|
|
648
|
-
|
|
649
|
-
[](https://drei.vercel.app/?path=/story/misc-trail--use-trail-st)
|
|
650
|
-
|
|
651
|
-
A declarative, `three.MeshLine` based Trails implementation. You can attach it to any mesh and it will give it a beautiful trail.
|
|
652
|
-
|
|
653
|
-
Props defined bellow with their default values.
|
|
654
|
-
|
|
655
|
-
```jsx
|
|
656
|
-
<Trail
|
|
657
|
-
width={0.2} // Width of the line
|
|
658
|
-
color={'hotpink'} // Color of the line
|
|
659
|
-
length={1} // Length of the line
|
|
660
|
-
decay={1} // How fast the line fades away
|
|
661
|
-
local={false} // Wether to use the target's world or local positions
|
|
662
|
-
stride={0} // Min distance between previous and current point
|
|
663
|
-
interval={1} // Number of frames to wait before next calculation
|
|
664
|
-
target={undefined} // Optional target. This object will produce the trail.
|
|
665
|
-
attenuation={(width) => width} // A function to define the width in each point along it.
|
|
666
|
-
>
|
|
667
|
-
{/* If `target` is not defined, Trail will use the first `Object3D` child as the target. */}
|
|
668
|
-
<mesh>
|
|
669
|
-
<sphereGeometry />
|
|
670
|
-
<meshBasicMaterial />
|
|
671
|
-
</mesh>
|
|
672
|
-
|
|
673
|
-
{/* You can optionally define a custom meshLineMaterial to use. */}
|
|
674
|
-
{/* <meshLineMaterial color={"red"} /> */}
|
|
675
|
-
</Trail>
|
|
676
|
-
```
|
|
677
|
-
|
|
678
|
-
👉 Inspired by [TheSpite's Codevember 2021 #9](https://spite.github.io/codevember-2021/9/)
|
|
679
|
-
|
|
680
|
-
#### Clone
|
|
681
|
-
|
|
682
|
-
<p>
|
|
683
|
-
<a href="https://codesandbox.io/s/42glz0"><img width="20%" src="https://codesandbox.io/api/v1/sandboxes/42glz0/screenshot.png" alt="Demo"/></a>
|
|
684
|
-
</p>
|
|
685
|
-
|
|
686
|
-
Declarative abstraction around THREE.Object3D.clone. This is useful when you want to create a shallow copy of an existing fragment (and Object3D, Groups, etc) into your scene, for instance a group from a loaded GLTF. This clone is now re-usable, but it will still refer to the original geometries and materials.
|
|
687
|
-
|
|
688
|
-
```ts
|
|
689
|
-
<Clone
|
|
690
|
-
/** Any pre-existing THREE.Object3D (groups, meshes, ...), or an array of objects */
|
|
691
|
-
object: THREE.Object3D | THREE.Object3D[]
|
|
692
|
-
/** Children will be placed within the object, or within the group that holds arrayed objects */
|
|
693
|
-
children?: React.ReactNode
|
|
694
|
-
/** Can clone materials and/or geometries deeply (default: false) */
|
|
695
|
-
deep?: boolean | 'materialsOnly' | 'geometriesOnly'
|
|
696
|
-
/** The property keys it will shallow-clone (material, geometry, visible, ...) */
|
|
697
|
-
keys?: string[]
|
|
698
|
-
/** Can either spread over props or fill in JSX children, applies to every mesh within */
|
|
699
|
-
inject?: MeshProps | React.ReactNode | ((object: THREE.Object3D) => React.ReactNode)
|
|
700
|
-
/** Short access castShadow, applied to every mesh within */
|
|
701
|
-
castShadow?: boolean
|
|
702
|
-
/** Short access receiveShadow, applied to every mesh within */
|
|
703
|
-
receiveShadow?: boolean
|
|
704
|
-
/>
|
|
705
|
-
```
|
|
706
|
-
|
|
707
|
-
You create a shallow clone by passing a pre-existing object to the `object` prop.
|
|
708
|
-
|
|
709
|
-
```jsx
|
|
710
|
-
const { nodes } = useGLTF(url)
|
|
711
|
-
return (
|
|
712
|
-
<Clone object={nodes.table} />
|
|
713
|
-
```
|
|
714
|
-
|
|
715
|
-
Or, multiple objects:
|
|
716
|
-
|
|
717
|
-
```jsx
|
|
718
|
-
<Clone object={[nodes.foo, nodes.bar]} />
|
|
719
|
-
```
|
|
720
|
-
|
|
721
|
-
You can dynamically insert objects, these will apply to anything that isn't a group or a plain object3d (meshes, lines, etc):
|
|
722
|
-
|
|
723
|
-
```jsx
|
|
724
|
-
<Clone object={nodes.table} inject={<meshStandardMaterial color="green" />} />
|
|
725
|
-
```
|
|
726
|
-
|
|
727
|
-
Or make inserts conditional:
|
|
728
|
-
|
|
729
|
-
```jsx
|
|
730
|
-
<Clone object={nodes.table} inject={
|
|
731
|
-
{(object) => (object.name === 'table' ? <meshStandardMaterial color="green" /> : null)}
|
|
732
|
-
} />
|
|
733
|
-
```
|
|
734
|
-
|
|
735
634
|
#### useAnimations
|
|
736
635
|
|
|
737
636
|
[](https://drei.pmnd.rs/?path=/story/abstractions-useanimations--use-animations-st)
|
|
@@ -740,7 +639,7 @@ Or make inserts conditional:
|
|
|
740
639
|
<a href="https://codesandbox.io/s/pecl6"><img width="20%" src="https://codesandbox.io/api/v1/sandboxes/pecl6/screenshot.png" alt="Demo"/></a>
|
|
741
640
|
</p>
|
|
742
641
|
|
|
743
|
-
A hook that abstracts [AnimationMixer](https://threejs.org/docs
|
|
642
|
+
A hook that abstracts [AnimationMixer](https://threejs.org/docs/#api/en/animation/AnimationMixer).
|
|
744
643
|
|
|
745
644
|
```jsx
|
|
746
645
|
const { nodes, materials, animations } = useGLTF(url)
|
|
@@ -771,7 +670,7 @@ return <primitive object={scene} />
|
|
|
771
670
|
<a href="https://codesandbox.io/s/l900i"><img width="20%" src="https://codesandbox.io/api/v1/sandboxes/l900i/screenshot.png" alt="Demo"/></a>
|
|
772
671
|
</p>
|
|
773
672
|
|
|
774
|
-
Easily add reflections and/or blur to any mesh. It takes surface roughness into account for a more realistic effect. This material extends from [THREE.MeshStandardMaterial](https://threejs.org/docs
|
|
673
|
+
Easily add reflections and/or blur to any mesh. It takes surface roughness into account for a more realistic effect. This material extends from [THREE.MeshStandardMaterial](https://threejs.org/docs/#api/en/materials/MeshStandardMaterial) and accepts all its props.
|
|
775
674
|
|
|
776
675
|
```jsx
|
|
777
676
|
<mesh>
|
|
@@ -809,8 +708,8 @@ This material makes your geometry wobble and wave around. It was taken from the
|
|
|
809
708
|
|
|
810
709
|
```jsx
|
|
811
710
|
<mesh>
|
|
812
|
-
<
|
|
813
|
-
<MeshWobbleMaterial
|
|
711
|
+
<boxGeometry />
|
|
712
|
+
<MeshWobbleMaterial factor={1} speed={10} />
|
|
814
713
|
</mesh>
|
|
815
714
|
```
|
|
816
715
|
|
|
@@ -826,14 +725,14 @@ This material makes your geometry distort following simplex noise.
|
|
|
826
725
|
|
|
827
726
|
```jsx
|
|
828
727
|
<mesh>
|
|
829
|
-
<
|
|
830
|
-
<MeshDistortMaterial
|
|
728
|
+
<boxGeometry />
|
|
729
|
+
<MeshDistortMaterial distort={1} speed={10} />
|
|
831
730
|
</mesh>
|
|
832
731
|
```
|
|
833
732
|
|
|
834
733
|
#### PointMaterial
|
|
835
734
|
|
|
836
|
-
|
|
735
|
+
An antialiased round dot that always keeps the same size.
|
|
837
736
|
|
|
838
737
|
```jsx
|
|
839
738
|
<points>
|
|
@@ -849,7 +748,7 @@ Antialiased round dots. It takes the same props as regular THREE.PointsMaterial
|
|
|
849
748
|
<a href="https://codesandbox.io/s/dh2jc"><img width="20%" src="https://codesandbox.io/api/v1/sandboxes/dh2jc/screenshot.png" alt="Demo"/></a>
|
|
850
749
|
</p>
|
|
851
750
|
|
|
852
|
-
Injects [percent closer soft shadows (pcss)](https://threejs.org/examples
|
|
751
|
+
Injects [percent closer soft shadows (pcss)](https://threejs.org/examples/#webgl_shadowmap_pcss) into threes shader chunk.
|
|
853
752
|
|
|
854
753
|
```jsx
|
|
855
754
|
softShadows({
|
|
@@ -872,7 +771,7 @@ softShadows({
|
|
|
872
771
|
Creates a THREE.ShaderMaterial for you with easier handling of uniforms, which are also automatically declared as setter/getters on the object.
|
|
873
772
|
|
|
874
773
|
```jsx
|
|
875
|
-
import { extend } from 'react-three
|
|
774
|
+
import { extend } from '@react-three/fiber'
|
|
876
775
|
import glsl from 'babel-plugin-glsl/macro'
|
|
877
776
|
|
|
878
777
|
const ColorShiftMaterial = shaderMaterial(
|
|
@@ -900,7 +799,7 @@ extend({ ColorShiftMaterial })
|
|
|
900
799
|
|
|
901
800
|
// in your component
|
|
902
801
|
<mesh>
|
|
903
|
-
<colorShiftMaterial
|
|
802
|
+
<colorShiftMaterial color="hotpink" time={1} />
|
|
904
803
|
</mesh>
|
|
905
804
|
```
|
|
906
805
|
|
|
@@ -910,7 +809,7 @@ extend({ ColorShiftMaterial })
|
|
|
910
809
|
|
|
911
810
|
[](https://drei.pmnd.rs/?path=/story/modifiers-curvemodifier)
|
|
912
811
|
|
|
913
|
-
Given a curve will replace the children of this component with a mesh that move along said curve calling the property `moveAlongCurve` on the passed ref. Uses [three's Curve Modifier](https://threejs.org/examples
|
|
812
|
+
Given a curve will replace the children of this component with a mesh that move along said curve calling the property `moveAlongCurve` on the passed ref. Uses [three's Curve Modifier](https://threejs.org/examples/#webgl_modifier_curve)
|
|
914
813
|
|
|
915
814
|
```jsx
|
|
916
815
|
const curveRef = useRef()
|
|
@@ -920,7 +819,7 @@ const curve = React.useMemo(() => new THREE.CatmullRomCurve3([...handlePos], tru
|
|
|
920
819
|
return (
|
|
921
820
|
<CurveModifier ref={curveRef} curve={curve}>
|
|
922
821
|
<mesh>
|
|
923
|
-
<
|
|
822
|
+
<boxGeometry args={[10, 10]} />
|
|
924
823
|
</mesh>
|
|
925
824
|
</CurveModifier>
|
|
926
825
|
)
|
|
@@ -1147,7 +1046,7 @@ useHelper(condition && mesh, BoxHelper, 'red') // you can passe false instead of
|
|
|
1147
1046
|
|
|
1148
1047
|
This hook uses [DetectGPU by @TimvanScherpenzeel](https://github.com/TimvanScherpenzeel/detect-gpu), wrapped into suspense, to determine what tier should be assigned to the user's GPU.
|
|
1149
1048
|
|
|
1150
|
-
👉 This hook CAN be used outside the react-three
|
|
1049
|
+
👉 This hook CAN be used outside the @react-three/fiber `Canvas`.
|
|
1151
1050
|
|
|
1152
1051
|
```jsx
|
|
1153
1052
|
function App() {
|
|
@@ -1174,7 +1073,7 @@ const scale = useAspect(
|
|
|
1174
1073
|
)
|
|
1175
1074
|
return (
|
|
1176
1075
|
<mesh scale={scale}>
|
|
1177
|
-
<
|
|
1076
|
+
<planeGeometry />
|
|
1178
1077
|
<meshBasicMaterial map={imageTexture} />
|
|
1179
1078
|
```
|
|
1180
1079
|
|
|
@@ -1197,63 +1096,13 @@ return (
|
|
|
1197
1096
|
<a href="https://codesandbox.io/s/gsm1y"><img width="20%" src="https://codesandbox.io/api/v1/sandboxes/gsm1y/screenshot.png" alt="Demo"/></a>
|
|
1198
1097
|
</p>
|
|
1199
1098
|
|
|
1200
|
-
A very cheap frustum check that gives you a reference you can observe in order to know if the object has entered the view or is outside of it. This relies on [THREE.Object3D.onBeforeRender](https://threejs.org/docs
|
|
1099
|
+
A very cheap frustum check that gives you a reference you can observe in order to know if the object has entered the view or is outside of it. This relies on [THREE.Object3D.onBeforeRender](https://threejs.org/docs/#api/en/core/Object3D.onBeforeRender) so it only works on objects that are effectively rendered, like meshes, lines, sprites. It won't work on groups, object3d's, bones, etc.
|
|
1201
1100
|
|
|
1202
1101
|
```jsx
|
|
1203
1102
|
const ref = useIntersect((visible) => console.log('object is visible', visible))
|
|
1204
1103
|
return <mesh ref={ref} />
|
|
1205
1104
|
```
|
|
1206
1105
|
|
|
1207
|
-
#### useBoxProjectedEnv
|
|
1208
|
-
|
|
1209
|
-
<p>
|
|
1210
|
-
<a href="https://codesandbox.io/s/s006f"><img width="20%" src="https://codesandbox.io/api/v1/sandboxes/s006f/screenshot.png" alt="Demo"/></a>
|
|
1211
|
-
</p>
|
|
1212
|
-
|
|
1213
|
-
The cheapest possible way of getting reflections in threejs. This will box-project the current environment map onto a plane. It returns an object that you need to spread over its material. The spread object contains a ref, onBeforeCompile and customProgramCacheKey. If you combine it with drei/CubeCamera you can "film" a single frame of the environment and feed it to the material, thereby getting realistic reflections at no cost. Align it with the position and scale properties.
|
|
1214
|
-
|
|
1215
|
-
```jsx
|
|
1216
|
-
const projection = useBoxProjectedEnv(
|
|
1217
|
-
[0, 0, 0], // Position
|
|
1218
|
-
[1, 1, 1] // Scale
|
|
1219
|
-
)
|
|
1220
|
-
|
|
1221
|
-
<CubeCamera frames={1}>
|
|
1222
|
-
{(texture) => (
|
|
1223
|
-
<mesh>
|
|
1224
|
-
<planeGeometry />
|
|
1225
|
-
<meshStandardMaterial envMap={texture} {...projection} />
|
|
1226
|
-
</mesh>
|
|
1227
|
-
)}
|
|
1228
|
-
</CubeCamera>
|
|
1229
|
-
```
|
|
1230
|
-
|
|
1231
|
-
#### useTrail
|
|
1232
|
-
|
|
1233
|
-
[](https://drei.vercel.app/?path=/story/misc-trail--use-trail-st)
|
|
1234
|
-
|
|
1235
|
-
A hook to obtain an array of points that make up a [Trail](#trail). You can use this array to drive your own `MeshLine` or make a trail out of anything you please.
|
|
1236
|
-
|
|
1237
|
-
Note: The hook returns a ref (`MutableRefObject<Vector3[]>`) this means updates to it will not trigger a re-draw, thus keeping this cheap.
|
|
1238
|
-
|
|
1239
|
-
```js
|
|
1240
|
-
const points = useTrail(
|
|
1241
|
-
target, // Required target object. This object will produce the trail.
|
|
1242
|
-
{
|
|
1243
|
-
length, // Length of the line
|
|
1244
|
-
decay, // How fast the line fades away
|
|
1245
|
-
local, // Wether to use the target's world or local positions
|
|
1246
|
-
stride, // Min distance between previous and current point
|
|
1247
|
-
interval, // Number of frames to wait before next calculation
|
|
1248
|
-
}
|
|
1249
|
-
)
|
|
1250
|
-
|
|
1251
|
-
// To use...
|
|
1252
|
-
useFrame(() => {
|
|
1253
|
-
meshLineRef.current.position.setPoints(points.current)
|
|
1254
|
-
})
|
|
1255
|
-
```
|
|
1256
|
-
|
|
1257
1106
|
# Loading
|
|
1258
1107
|
|
|
1259
1108
|
#### Loader
|
|
@@ -1397,7 +1246,7 @@ const envMap = useCubeTexture(['px.png', 'nx.png', 'py.png', 'ny.png', 'pz.png',
|
|
|
1397
1246
|
<a href="https://codesandbox.io/s/i6t0j"><img width="20%" src="https://codesandbox.io/api/v1/sandboxes/i6t0j/screenshot.png" alt="Demo"/></a>
|
|
1398
1247
|
</p>
|
|
1399
1248
|
|
|
1400
|
-
A wrapper around [THREE.InstancedMesh](https://threejs.org/docs
|
|
1249
|
+
A wrapper around [THREE.InstancedMesh](https://threejs.org/docs/#api/en/objects/InstancedMesh). This allows you to define hundreds of thousands of objects in a single draw call, but declaratively!
|
|
1401
1250
|
|
|
1402
1251
|
```jsx
|
|
1403
1252
|
<Instances
|
|
@@ -1482,19 +1331,34 @@ function Model({ url }) {
|
|
|
1482
1331
|
|
|
1483
1332
|
#### Points
|
|
1484
1333
|
|
|
1485
|
-
A wrapper around [THREE.Points](https://threejs.org/docs
|
|
1334
|
+
A wrapper around [THREE.Points](https://threejs.org/docs/#api/en/objects/Points). It has the same api and properties as Instances.
|
|
1486
1335
|
|
|
1487
1336
|
```jsx
|
|
1488
1337
|
<Points
|
|
1489
1338
|
limit={1000} // Optional: max amount of items (for calculating buffer size)
|
|
1490
1339
|
range={1000} // Optional: draw-range
|
|
1491
1340
|
>
|
|
1492
|
-
<pointsMaterial
|
|
1341
|
+
<pointsMaterial />
|
|
1493
1342
|
<Point position={[1, 2, 3]} color="red" onClick={onClick} onPointerOver={onPointerOver} ... />
|
|
1494
1343
|
// As many as you want, make them conditional, mount/unmount them, lazy load them, etc ...
|
|
1495
1344
|
</Points>
|
|
1496
1345
|
```
|
|
1497
1346
|
|
|
1347
|
+
If you have a material that supports vertex colors (like drei/PointMaterial) you can have individual colors!
|
|
1348
|
+
|
|
1349
|
+
```jsx
|
|
1350
|
+
<Points>
|
|
1351
|
+
<PointMaterial />
|
|
1352
|
+
<Point color="hotpink" />
|
|
1353
|
+
```
|
|
1354
|
+
|
|
1355
|
+
Otherwise use any material you like:
|
|
1356
|
+
|
|
1357
|
+
```jsx
|
|
1358
|
+
<Points>
|
|
1359
|
+
<pointsMaterial vertexColors size={10} />
|
|
1360
|
+
```
|
|
1361
|
+
|
|
1498
1362
|
If you just want to use buffers for position, color and size, you can use the alternative API:
|
|
1499
1363
|
|
|
1500
1364
|
```jsx
|
|
@@ -1546,7 +1410,7 @@ useFrame(() => {
|
|
|
1546
1410
|
<a href="https://codesandbox.io/s/12nmp"><img width="20%" src="https://codesandbox.io/api/v1/sandboxes/12nmp/screenshot.png" alt="Demo"/></a>
|
|
1547
1411
|
</p>
|
|
1548
1412
|
|
|
1549
|
-
A wrapper around [THREE.LOD](https://threejs.org/docs
|
|
1413
|
+
A wrapper around [THREE.LOD](https://threejs.org/docs/#api/en/objects/LOD) (Level of detail).
|
|
1550
1414
|
|
|
1551
1415
|
```jsx
|
|
1552
1416
|
<Detailed distances={[0, 10, 20]} {...props}>
|
|
@@ -1558,7 +1422,7 @@ A wrapper around [THREE.LOD](https://threejs.org/docs/index.html#api/en/objects/
|
|
|
1558
1422
|
|
|
1559
1423
|
#### Preload
|
|
1560
1424
|
|
|
1561
|
-
The WebGLRenderer will compile materials only when they hit the frustrum, which can cause jank. This component precompiles the scene using [gl.compile](https://threejs.org/docs
|
|
1425
|
+
The WebGLRenderer will compile materials only when they hit the frustrum, which can cause jank. This component precompiles the scene using [gl.compile](https://threejs.org/docs/#api/en/renderers/WebGLRenderer.compile) which makes sure that your app is responsive from the get go.
|
|
1562
1426
|
|
|
1563
1427
|
By default gl.compile will only preload visible objects, if you supply the `all` prop, it will circumvent that. With the `scene` and `camera` props you could also use it in portals.
|
|
1564
1428
|
|
|
@@ -1592,7 +1456,7 @@ A very fast, but often good-enough bounds-only raycast for meshes. You can use t
|
|
|
1592
1456
|
|
|
1593
1457
|
#### AdaptiveDpr
|
|
1594
1458
|
|
|
1595
|
-
Drop this component into your scene and it will cut the pixel-ratio on regress according to the
|
|
1459
|
+
Drop this component into your scene and it will cut the pixel-ratio on [regress](#) according to the canvases perrformance min/max settings. This allows you to temporarily reduce visuals for more performance, for instance when the camera moves (look into drei's controls `regress` flag). Optionally you can set the canvas to a pixelated filter, which would be even faster.
|
|
1596
1460
|
|
|
1597
1461
|
```jsx
|
|
1598
1462
|
<AdaptiveDpr pixelated />
|
|
@@ -1625,7 +1489,7 @@ useBVH(mesh)
|
|
|
1625
1489
|
|
|
1626
1490
|
[](https://drei.pmnd.rs/?path=/story/staging-center--default-story)
|
|
1627
1491
|
|
|
1628
|
-
Calculates a boundary box and centers its children accordingly. `alignTop` adjusts it so that it sits flush on y=0.
|
|
1492
|
+
Calculates a boundary box and centers its children accordingly. `alignTop` makes adjusts it so that it's sits flush on y=0.
|
|
1629
1493
|
|
|
1630
1494
|
```jsx
|
|
1631
1495
|
<Center alignTop>
|
|
@@ -1639,10 +1503,10 @@ Calculates a boundary box and centers its children accordingly. `alignTop` adjus
|
|
|
1639
1503
|
<a href="https://codesandbox.io/s/rz2g0"><img width="20%" src="https://codesandbox.io/api/v1/sandboxes/rz2g0/screenshot.png" alt="Demo"/></a>
|
|
1640
1504
|
</p>
|
|
1641
1505
|
|
|
1642
|
-
Calculates a boundary box and centers the camera accordingly. If you are using controls, make sure to pass them the `makeDefault` prop. `fit` fits the current view on first render. `clip` sets the cameras near/far planes.
|
|
1506
|
+
Calculates a boundary box and centers the camera accordingly. If you are using controls, make sure to pass them the `makeDefault` prop. `fit` fits the current view on first render. `clip` sets the cameras near/far planes.
|
|
1643
1507
|
|
|
1644
1508
|
```jsx
|
|
1645
|
-
<Bounds fit clip
|
|
1509
|
+
<Bounds fit clip damping={6} margin={1.2}>
|
|
1646
1510
|
<mesh />
|
|
1647
1511
|
</Bounds>
|
|
1648
1512
|
```
|
|
@@ -1772,7 +1636,7 @@ A cheap canvas-texture-based circular gradient.
|
|
|
1772
1636
|
<a href="https://codesandbox.io/s/qxjoj"><img width="20%" src="https://codesandbox.io/api/v1/sandboxes/qxjoj/screenshot.png" alt="Demo"/></a>
|
|
1773
1637
|
</p>
|
|
1774
1638
|
|
|
1775
|
-
A [contact shadow](https://threejs.org/examples
|
|
1639
|
+
A [contact shadow](https://threejs.org/examples/#webgl_shadow_contact) implementation, facing upwards (positive Y) by default. `scale` can be a positive number or a 2D array `[x: number, y: number]`.
|
|
1776
1640
|
|
|
1777
1641
|
```jsx
|
|
1778
1642
|
<ContactShadows opacity={1} scale={10} blur={1} far={10} resolution={256} />
|
|
@@ -1816,9 +1680,6 @@ function Foo() {
|
|
|
1816
1680
|
|
|
1817
1681
|
<p>
|
|
1818
1682
|
<a href="https://codesandbox.io/s/t4l0f"><img width="20%" src="https://codesandbox.io/api/v1/sandboxes/t4l0f/screenshot.png" alt="Demo"/></a>
|
|
1819
|
-
<a href="https://codesandbox.io/s/mih0lx"><img width="20%" src="https://codesandbox.io/api/v1/sandboxes/mih0lx/screenshot.png" alt="Demo"/></a>
|
|
1820
|
-
<a href="https://codesandbox.io/s/e662p3"><img width="20%" src="https://codesandbox.io/api/v1/sandboxes/e662p3/screenshot.png" alt="Demo"/></a>
|
|
1821
|
-
<a href="https://codesandbox.io/s/lwo219"><img width="20%" src="https://codesandbox.io/api/v1/sandboxes/lwo219/screenshot.png" alt="Demo"/></a>
|
|
1822
1683
|
</p>
|
|
1823
1684
|
|
|
1824
1685
|
Sets up a global cubemap, which affects the default `scene.environment`, and optionally `scene.background`, unless a custom scene has been passed. A selection of [presets](src/helpers/environment-assets.ts) from [HDRI Haven](https://hdrihaven.com/) are available for convenience. If you pass an array of files it will use THREE.CubeTextureLoader.
|
|
@@ -1827,11 +1688,11 @@ Sets up a global cubemap, which affects the default `scene.environment`, and opt
|
|
|
1827
1688
|
|
|
1828
1689
|
```jsx
|
|
1829
1690
|
<Environment
|
|
1830
|
-
background={false}
|
|
1691
|
+
background={false}
|
|
1831
1692
|
files={['px.png', 'nx.png', 'py.png', 'ny.png', 'pz.png', 'nz.png']}
|
|
1832
1693
|
path="/"
|
|
1833
1694
|
preset={null}
|
|
1834
|
-
scene={undefined} // adds the ability to pass a custom THREE.Scene
|
|
1695
|
+
scene={undefined} // adds the ability to pass a custom THREE.Scene
|
|
1835
1696
|
/>
|
|
1836
1697
|
```
|
|
1837
1698
|
|
|
@@ -1841,60 +1702,6 @@ If you provide a single string it will use THREE.RGBELoader.
|
|
|
1841
1702
|
<Environment files="file.hdr" />
|
|
1842
1703
|
```
|
|
1843
1704
|
|
|
1844
|
-
If you already have a cube texture you can pass it directly:
|
|
1845
|
-
|
|
1846
|
-
```jsx
|
|
1847
|
-
<CubeCamera>{(texture) => <Environment map={texture} />}</CubeCamera>
|
|
1848
|
-
```
|
|
1849
|
-
|
|
1850
|
-
If you provide children you can even render a custom environment. It will render the contents into an off-buffer and film a single frame with a cube camera (whose props you can configure: near=1, far=1000, resolution=256).
|
|
1851
|
-
|
|
1852
|
-
```jsx
|
|
1853
|
-
<Environment background near={1} far={1000} resolution={256}>
|
|
1854
|
-
<mesh scale={100}>
|
|
1855
|
-
<sphereGeometry args={[1, 64, 64]} />
|
|
1856
|
-
<meshBasicMaterial map={texture} side={THREE.BackSide} />
|
|
1857
|
-
</mesh>
|
|
1858
|
-
</Environment>
|
|
1859
|
-
```
|
|
1860
|
-
|
|
1861
|
-
You can even mix a generic HDRI environment into a custom one with either the `preset` or the `files` prop.
|
|
1862
|
-
|
|
1863
|
-
```jsx
|
|
1864
|
-
return (
|
|
1865
|
-
<Environment background near={1} far={1000} resolution={256} preset="warehouse">
|
|
1866
|
-
<mesh />
|
|
1867
|
-
```
|
|
1868
|
-
|
|
1869
|
-
Declarative environment content can also animate with the `frames` prop, the envmap can be live. Give it a low resolution and this will happen at very little cost
|
|
1870
|
-
|
|
1871
|
-
```jsx
|
|
1872
|
-
return (
|
|
1873
|
-
<Environment frames={Infinity} resolution={256}>
|
|
1874
|
-
<Float>
|
|
1875
|
-
<mesh />
|
|
1876
|
-
</Float>
|
|
1877
|
-
```
|
|
1878
|
-
|
|
1879
|
-
#### Lightformer
|
|
1880
|
-
|
|
1881
|
-
<p>
|
|
1882
|
-
<a href="https://codesandbox.io/s/lwo219"><img width="20%" src="https://codesandbox.io/api/v1/sandboxes/lwo219/screenshot.png" alt="Demo"/></a>
|
|
1883
|
-
</p>
|
|
1884
|
-
|
|
1885
|
-
This component draws flat rectangles, circles or rings, mimicking the look of a light-former. You can set the output `intensity`, which will effect emissiveness once you put it into an HDRI `<Environment>`, where it mostly belong. It will act like a real light without the expense, you can have as many as you want.
|
|
1886
|
-
|
|
1887
|
-
```jsx
|
|
1888
|
-
<Environment>
|
|
1889
|
-
<Lightformer
|
|
1890
|
-
form="rect" // circle | ring | rect (optional, default = rect)
|
|
1891
|
-
intensity={1} // power level (optional = 1)
|
|
1892
|
-
color="white" // (optional = white)
|
|
1893
|
-
scale={[10, 5]} // Scale it any way you prefer (optional = [1, 1])
|
|
1894
|
-
target={[0, 0, 0]} // Target position (optional = undefined)
|
|
1895
|
-
/>
|
|
1896
|
-
```
|
|
1897
|
-
|
|
1898
1705
|
#### Sky
|
|
1899
1706
|
|
|
1900
1707
|
[](https://drei.pmnd.rs/?path=/story/staging-sky--sky-st)
|
|
@@ -1903,7 +1710,7 @@ This component draws flat rectangles, circles or rings, mimicking the look of a
|
|
|
1903
1710
|
<a href="https://codesandbox.io/s/vkgi6"><img width="20%" src="https://codesandbox.io/api/v1/sandboxes/vkgi6/screenshot.png" alt="Demo"/></a>
|
|
1904
1711
|
</p>
|
|
1905
1712
|
|
|
1906
|
-
Adds a [sky](https://threejs.org/examples
|
|
1713
|
+
Adds a [sky](https://threejs.org/examples/#webgl_shaders_sky) to your scene.
|
|
1907
1714
|
|
|
1908
1715
|
```jsx
|
|
1909
1716
|
<Sky distance={450000} sunPosition={[0, 1, 0]} inclination={0} azimuth={0.25} {...props} />
|