@react-three/drei 9.109.0 → 9.109.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 +18 -18
- package/core/Line.cjs.js +1 -1
- package/core/Line.js +4 -1
- package/index.cjs.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -11,7 +11,7 @@ A growing collection of useful helpers and fully functional, ready-made abstract
|
|
|
11
11
|
npm install @react-three/drei
|
|
12
12
|
```
|
|
13
13
|
|
|
14
|
-
> [!IMPORTANT]
|
|
14
|
+
> [!IMPORTANT]
|
|
15
15
|
> 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).
|
|
16
16
|
|
|
17
17
|
### Basic usage:
|
|
@@ -49,7 +49,7 @@ The `native` route of the library **does not** export `Html` or `Loader`. The de
|
|
|
49
49
|
<li><a href="#controls">TrackballControls</a></li>
|
|
50
50
|
<li><a href="#controls">ArcballControls</a></li>
|
|
51
51
|
<li><a href="#controls">PointerLockControls</a></li>
|
|
52
|
-
<li><a href="#controls">FirstPersonControls</a></li>
|
|
52
|
+
<li><a href="#controls">FirstPersonControls</a></li>
|
|
53
53
|
<li><a href="#scrollcontrols">ScrollControls</a></li>
|
|
54
54
|
<li><a href="#presentationcontrols">PresentationControls</a></li>
|
|
55
55
|
<li><a href="#keyboardcontrols">KeyboardControls</a></li>
|
|
@@ -70,7 +70,7 @@ The `native` route of the library **does not** export `Html` or `Loader`. The de
|
|
|
70
70
|
<ul>
|
|
71
71
|
<li><a href="#image">Image</a></li>
|
|
72
72
|
<li><a href="#text">Text</a></li>
|
|
73
|
-
<li><a href="#text3d">Text3D</a></li>
|
|
73
|
+
<li><a href="#text3d">Text3D</a></li>
|
|
74
74
|
<li><a href="#positionalaudio">PositionalAudio</a></li>
|
|
75
75
|
<li><a href="#billboard">Billboard</a></li>
|
|
76
76
|
<li><a href="#screenspace">ScreenSpace</a></li>
|
|
@@ -122,7 +122,7 @@ The `native` route of the library **does not** export `Html` or `Loader`. The de
|
|
|
122
122
|
<li><a href="#fbo--usefbo">Fbo / useFBO</a></li>
|
|
123
123
|
<li><a href="#usecamera">useCamera</a></li>
|
|
124
124
|
<li><a href="#cubecamera--usecubecamera">CubeCamera / useCubeCamera</a></li>
|
|
125
|
-
<li><a href="#detectgpu--usedetectgpu">DetectGPU / useDetectGPU</a></li>
|
|
125
|
+
<li><a href="#detectgpu--usedetectgpu">DetectGPU / useDetectGPU</a></li>
|
|
126
126
|
<li><a href="#useaspect">useAspect</a></li>
|
|
127
127
|
<li><a href="#usecursor">useCursor</a></li>
|
|
128
128
|
<li><a href="#useintersect">useIntersect</a></li>
|
|
@@ -158,16 +158,16 @@ The `native` route of the library **does not** export `Html` or `Loader`. The de
|
|
|
158
158
|
<li><a href="#adaptivedpr">AdaptiveDpr</a></li>
|
|
159
159
|
<li><a href="#adaptiveevents">AdaptiveEvents</a></li>
|
|
160
160
|
<li><a href="#bvh">Bvh</a></li>
|
|
161
|
-
<li><a href="#performancemonitor">PerformanceMonitor</a></li>
|
|
161
|
+
<li><a href="#performancemonitor">PerformanceMonitor</a></li>
|
|
162
162
|
</ul>
|
|
163
|
-
<li><a href="#portals">Portals</a></li>
|
|
163
|
+
<li><a href="#portals">Portals</a></li>
|
|
164
164
|
<ul>
|
|
165
165
|
<li><a href="#hud">Hud</a></li>
|
|
166
166
|
<li><a href="#view">View</a></li>
|
|
167
167
|
<li><a href="#rendertexture">RenderTexture</a></li>
|
|
168
168
|
<li><a href="#rendercubetexture">RenderCubeTexture</a></li>
|
|
169
169
|
<li><a href="#fisheye">Fisheye</a></li>
|
|
170
|
-
<li><a href="#mask">Mask</a></li>
|
|
170
|
+
<li><a href="#mask">Mask</a></li>
|
|
171
171
|
<li><a href="#meshportalmaterial">MeshPortalMaterial</a></li>
|
|
172
172
|
</ul>
|
|
173
173
|
<li><a href="#modifiers">Modifiers</a></li>
|
|
@@ -210,7 +210,7 @@ The `native` route of the library **does not** export `Html` or `Loader`. The de
|
|
|
210
210
|
<ul>
|
|
211
211
|
<li><a href="#center">Center</a></li>
|
|
212
212
|
<li><a href="#resize">Resize</a></li>
|
|
213
|
-
<li><a href="#BBAnchor">BBAnchor</a></li>
|
|
213
|
+
<li><a href="#BBAnchor">BBAnchor</a></li>
|
|
214
214
|
<li><a href="#bounds">Bounds</a></li>
|
|
215
215
|
<li><a href="#camerashake">CameraShake</a></li>
|
|
216
216
|
<li><a href="#float">Float</a></li>
|
|
@@ -283,7 +283,7 @@ You can also drive it manually, it won't be responsive and you have to calculate
|
|
|
283
283
|
<PerspectiveCamera manual aspect={...} onUpdate={(c) => c.updateProjectionMatrix()}>
|
|
284
284
|
```
|
|
285
285
|
|
|
286
|
-
You can use the PerspectiveCamera to film contents into a RenderTarget, similar to CubeCamera. As a child you must provide a render-function which receives the texture as its first argument. The result of that function will _not follow the camera_, instead it will be set invisible while the
|
|
286
|
+
You can use the PerspectiveCamera to film contents into a RenderTarget, similar to CubeCamera. As a child you must provide a render-function which receives the texture as its first argument. The result of that function will _not follow the camera_, instead it will be set invisible while the FBO renders so as to avoid issues where the meshes that receive the texture are interrering.
|
|
287
287
|
|
|
288
288
|
```jsx
|
|
289
289
|
<PerspectiveCamera position={[0, 0, 10]}>
|
|
@@ -446,7 +446,7 @@ type ScrollControlsProps = {
|
|
|
446
446
|
}
|
|
447
447
|
```
|
|
448
448
|
|
|
449
|
-
Scroll controls create
|
|
449
|
+
Scroll controls create an HTML scroll container in front of the canvas. Everything you drop into the `<Scroll>` component will be affected.
|
|
450
450
|
|
|
451
451
|
You can listen and react to scroll with the `useScroll` hook which gives you useful data like the current scroll `offset`, `delta` and functions for range finding: `range`, `curve` and `visible`. The latter functions are especially useful if you want to react to the scroll offset, for instance if you wanted to fade things in and out if they are in or out of view.
|
|
452
452
|
|
|
@@ -623,7 +623,7 @@ The camera follows your face.
|
|
|
623
623
|
<a href="https://codesandbox.io/s/zhjbhy"><img width="20%" src="https://github-production-user-asset-6210df.s3.amazonaws.com/76580/244052845-5cc535d7-3c97-46e3-a267-52e707c2d9b2.png" alt="demo"/></a>
|
|
624
624
|
</p>
|
|
625
625
|
|
|
626
|
-
|
|
626
|
+
Prerequisite: wrap into a [`FaceLandmarker`](#facelandmarker) provider
|
|
627
627
|
|
|
628
628
|
```tsx
|
|
629
629
|
<FaceLandmarker>...</FaceLandmarker>
|
|
@@ -3872,7 +3872,7 @@ return (
|
|
|
3872
3872
|
#### RenderTexture
|
|
3873
3873
|
|
|
3874
3874
|
<p>
|
|
3875
|
-
<a href="https://codesandbox.io/s/0z8i2c"><img width="20%" src="https://codesandbox.io/api/v1/sandboxes/0z8i2c/screenshot.png" alt="Demo"/></a>
|
|
3875
|
+
<a href="https://codesandbox.io/s/0z8i2c"><img width="20%" src="https://codesandbox.io/api/v1/sandboxes/0z8i2c/screenshot.png" alt="Demo"/></a>
|
|
3876
3876
|
</p>
|
|
3877
3877
|
|
|
3878
3878
|
This component allows you to render a live scene into a texture which you can then apply to a material. The contents of it run inside a portal and are separate from the rest of the canvas, therefore you can have events in there, environment maps, etc.
|
|
@@ -3968,7 +3968,7 @@ const api = useRef<RenderCubeTextureApi>(null!)
|
|
|
3968
3968
|
### Fisheye
|
|
3969
3969
|
|
|
3970
3970
|
<p>
|
|
3971
|
-
<a href="https://codesandbox.io/s/7qytdw"><img width="20%" src="https://codesandbox.io/api/v1/sandboxes/7qytdw/screenshot.png" alt="Demo"/></a>
|
|
3971
|
+
<a href="https://codesandbox.io/s/7qytdw"><img width="20%" src="https://codesandbox.io/api/v1/sandboxes/7qytdw/screenshot.png" alt="Demo"/></a>
|
|
3972
3972
|
</p>
|
|
3973
3973
|
|
|
3974
3974
|
```tsx
|
|
@@ -4000,7 +4000,7 @@ This component will take over system rendering. It portals its children into a c
|
|
|
4000
4000
|
|
|
4001
4001
|
<p>
|
|
4002
4002
|
<a href="https://codesandbox.io/s/7n2yru"><img width="20%" src="https://codesandbox.io/api/v1/sandboxes/7n2yru/screenshot.png" alt="Demo"/></a>
|
|
4003
|
-
<a href="https://codesandbox.io/s/z3f2mw"><img width="20%" src="https://codesandbox.io/api/v1/sandboxes/z3f2mw/screenshot.png" alt="Demo"/></a>
|
|
4003
|
+
<a href="https://codesandbox.io/s/z3f2mw"><img width="20%" src="https://codesandbox.io/api/v1/sandboxes/z3f2mw/screenshot.png" alt="Demo"/></a>
|
|
4004
4004
|
</p>
|
|
4005
4005
|
|
|
4006
4006
|
Masks use the stencil buffer to cut out areas of the screen. This is usually cheaper as it doesn't require double renders or createPortal.
|
|
@@ -4058,8 +4058,8 @@ const stencil = useMask(1, true)
|
|
|
4058
4058
|
|
|
4059
4059
|
<p>
|
|
4060
4060
|
<a href="https://codesandbox.io/s/9m4tpc"><img width="20%" src="https://codesandbox.io/api/v1/sandboxes/9m4tpc/screenshot.png" alt="Demo"/></a>
|
|
4061
|
-
<a href="https://codesandbox.io/s/qvk72r"><img width="20%" src="https://codesandbox.io/api/v1/sandboxes/qvk72r/screenshot.png" alt="Demo"/></a>
|
|
4062
|
-
<a href="https://codesandbox.io/s/drc6qg"><img width="20%" src="https://codesandbox.io/api/v1/sandboxes/drc6qg/screenshot.png" alt="Demo"/></a>
|
|
4061
|
+
<a href="https://codesandbox.io/s/qvk72r"><img width="20%" src="https://codesandbox.io/api/v1/sandboxes/qvk72r/screenshot.png" alt="Demo"/></a>
|
|
4062
|
+
<a href="https://codesandbox.io/s/drc6qg"><img width="20%" src="https://codesandbox.io/api/v1/sandboxes/drc6qg/screenshot.png" alt="Demo"/></a>
|
|
4063
4063
|
<a href="https://codesandbox.io/s/ik11ln"><img width="20%" src="https://codesandbox.io/api/v1/sandboxes/ik11ln/screenshot.png" alt="Demo"/></a>
|
|
4064
4064
|
</p>
|
|
4065
4065
|
|
|
@@ -4312,7 +4312,7 @@ const config = {
|
|
|
4312
4312
|
maxYaw: 0.1, // Max amount camera can yaw in either direction
|
|
4313
4313
|
maxPitch: 0.1, // Max amount camera can pitch in either direction
|
|
4314
4314
|
maxRoll: 0.1, // Max amount camera can roll in either direction
|
|
4315
|
-
yawFrequency: 0.1, // Frequency of the
|
|
4315
|
+
yawFrequency: 0.1, // Frequency of the yaw rotation
|
|
4316
4316
|
pitchFrequency: 0.1, // Frequency of the pitch rotation
|
|
4317
4317
|
rollFrequency: 0.1, // Frequency of the roll rotation
|
|
4318
4318
|
intensity: 1, // initial intensity of the shake
|
|
@@ -4928,7 +4928,7 @@ attribute vec3 color;
|
|
|
4928
4928
|
<p>
|
|
4929
4929
|
<a href="https://codesandbox.io/s/gwthnh"><img width="20%" src="https://codesandbox.io/api/v1/sandboxes/gwthnh/screenshot.png" alt="Demo"/></a>
|
|
4930
4930
|
<a href="https://codesandbox.io/s/mbfzf"><img width="20%" src="https://codesandbox.io/api/v1/sandboxes/mbfzf/screenshot.png" alt="Demo"/></a>
|
|
4931
|
-
|
|
4931
|
+
|
|
4932
4932
|
</p>
|
|
4933
4933
|
|
|
4934
4934
|
Particle based cloud.
|
package/core/Line.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/extends"),t=require("react"),r=require("three"),n=require("@react-three/fiber"),i=require("three-stdlib");function o(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function s(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var a=o(e),c=s(t);const l=c.forwardRef((function({points:e,color:t=16777215,vertexColors:o,linewidth:s,lineWidth:l,segments:u,dashed:f,...d},m){var h,p;const b=n.useThree((e=>e.size)),y=c.useMemo((()=>u?new i.LineSegments2:new i.Line2),[u]),[v]=c.useState((()=>new i.LineMaterial)),g=4===(null==o||null==(h=o[0])?void 0:h.length)?4:3,j=c.useMemo((()=>{const n=u?new i.LineSegmentsGeometry:new i.LineGeometry,s=e.map((e=>{const t=Array.isArray(e);return e instanceof r.Vector3||e instanceof r.Vector4?[e.x,e.y,e.z]:e instanceof r.Vector2?[e.x,e.y,0]:t&&3===e.length?[e[0],e[1],e[2]]:t&&2===e.length?[e[0],e[1],0]:e}));if(n.setPositions(s.flat()),o){t=16777215;const e=o.map((e=>e instanceof r.Color?e.toArray():e));n.setColors(e.flat(),g)}return n}),[e,u,o,g]);return c.useLayoutEffect((()=>{y.computeLineDistances()}),[e,y]),c.useLayoutEffect((()=>{f?v.defines.USE_DASH="":delete v.defines.USE_DASH,v.needsUpdate=!0}),[f,v]),c.useEffect((()=>()=>j.dispose()),[j]),c.createElement("primitive",a.default({object:y,ref:m},d),c.createElement("primitive",{object:j,attach:"geometry"}),c.createElement("primitive",a.default({object:v,attach:"material",color:t,vertexColors:Boolean(o),resolution:[b.width,b.height],linewidth:null!==(p=null!=s?s:l)&&void 0!==p?p:1,dashed:f,transparent:4===g},d)))}));exports.Line=l;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/extends"),t=require("react"),r=require("three"),n=require("@react-three/fiber"),i=require("three-stdlib");function o(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function s(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var a=o(e),c=s(t);const l=c.forwardRef((function({points:e,color:t=16777215,vertexColors:o,linewidth:s,lineWidth:l,segments:u,dashed:f,...d},m){var h,p;const b=n.useThree((e=>e.size)),y=c.useMemo((()=>u?new i.LineSegments2:new i.Line2),[u]),[v]=c.useState((()=>new i.LineMaterial)),g=4===(null==o||null==(h=o[0])?void 0:h.length)?4:3,j=c.useMemo((()=>{const n=u?new i.LineSegmentsGeometry:new i.LineGeometry,s=e.map((e=>{const t=Array.isArray(e);return e instanceof r.Vector3||e instanceof r.Vector4?[e.x,e.y,e.z]:e instanceof r.Vector2?[e.x,e.y,0]:t&&3===e.length?[e[0],e[1],e[2]]:t&&2===e.length?[e[0],e[1],0]:e}));if(n.setPositions(s.flat()),o){t=16777215;const e=o.map((e=>e instanceof r.Color?e.toArray():e));n.setColors(e.flat(),g)}return n}),[e,u,o,g]);return c.useLayoutEffect((()=>{y.computeLineDistances()}),[e,y]),c.useLayoutEffect((()=>{f?v.defines.USE_DASH="":delete v.defines.USE_DASH,v.needsUpdate=!0}),[f,v]),c.useEffect((()=>()=>{j.dispose(),v.dispose()}),[j]),c.createElement("primitive",a.default({object:y,ref:m},d),c.createElement("primitive",{object:j,attach:"geometry"}),c.createElement("primitive",a.default({object:v,attach:"material",color:t,vertexColors:Boolean(o),resolution:[b.width,b.height],linewidth:null!==(p=null!=s?s:l)&&void 0!==p?p:1,dashed:f,transparent:4===g},d)))}));exports.Line=l;
|
package/core/Line.js
CHANGED
|
@@ -47,7 +47,10 @@ const Line = /* @__PURE__ */React.forwardRef(function Line({
|
|
|
47
47
|
lineMaterial.needsUpdate = true;
|
|
48
48
|
}, [dashed, lineMaterial]);
|
|
49
49
|
React.useEffect(() => {
|
|
50
|
-
return () =>
|
|
50
|
+
return () => {
|
|
51
|
+
lineGeom.dispose();
|
|
52
|
+
lineMaterial.dispose();
|
|
53
|
+
};
|
|
51
54
|
}, [lineGeom]);
|
|
52
55
|
return /*#__PURE__*/React.createElement("primitive", _extends({
|
|
53
56
|
object: line2,
|