@react-three/drei 9.109.0 → 9.109.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 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 the FBO renders so as to avoid issues where the meshes that receive the texture are interrering.
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 a HTML scroll container in front of the canvas. Everything you drop into the `<Scroll>` component will be affected.
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
- Pre-requisite: wrap into a [`FaceLandmarker`](#facelandmarker) provider
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 the yaw rotation
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.
@@ -5097,9 +5097,13 @@ Makes an object's shadow respect its opacity and alphaMap.
5097
5097
  To run visual tests in the same environment as the CI:
5098
5098
 
5099
5099
  ```sh
5100
+ $ yarn build
5100
5101
  $ docker run --init --rm -v $(pwd):/app -w /app ghcr.io/pmndrs/playwright:main yarn test
5101
5102
  ```
5102
5103
 
5103
- NB: if running on mac m-series, you'll need to add `--platform linux/arm64` to the docker command.
5104
+ > [!TIP]
5105
+ > If running on mac m-series, you may need to add `--platform linux/arm64` to the docker command.
5106
+
5107
+ To update a snapshot, simply remove it and relaunch the test command.
5104
5108
 
5105
5109
  </details>
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 () => lineGeom.dispose();
50
+ return () => {
51
+ lineGeom.dispose();
52
+ lineMaterial.dispose();
53
+ };
51
54
  }, [lineGeom]);
52
55
  return /*#__PURE__*/React.createElement("primitive", _extends({
53
56
  object: line2,
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/extends"),n=require("three"),t=require("react"),r=require("./shaderMaterial.cjs.js"),i=require("@react-three/fiber"),o=require("three-stdlib"),c=require("../helpers/constants.cjs.js");function s(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function a(e){if(e&&e.__esModule)return e;var n=Object.create(null);return e&&Object.keys(e).forEach((function(t){if("default"!==t){var r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,r.get?r:{enumerable:!0,get:function(){return e[t]}})}})),n.default=e,Object.freeze(n)}var l=s(e),u=a(n),d=a(t);const f=r.shaderMaterial({screenspace:!1,color:new u.Color("black"),opacity:1,thickness:.05,size:new u.Vector2},"#include <common>\n #include <morphtarget_pars_vertex>\n #include <skinning_pars_vertex>\n uniform float thickness;\n uniform float screenspace;\n uniform vec2 size;\n void main() {\n #if defined (USE_SKINNING)\n\t #include <beginnormal_vertex>\n #include <morphnormal_vertex>\n #include <skinbase_vertex>\n #include <skinnormal_vertex>\n #include <defaultnormal_vertex>\n #endif\n #include <begin_vertex>\n\t #include <morphtarget_vertex>\n\t #include <skinning_vertex>\n #include <project_vertex>\n vec4 tNormal = vec4(normal, 0.0);\n vec4 tPosition = vec4(transformed, 1.0);\n #ifdef USE_INSTANCING\n tNormal = instanceMatrix * tNormal;\n tPosition = instanceMatrix * tPosition;\n #endif\n if (screenspace == 0.0) {\n vec3 newPosition = tPosition.xyz + tNormal.xyz * thickness;\n gl_Position = projectionMatrix * modelViewMatrix * vec4(newPosition, 1.0); \n } else {\n vec4 clipPosition = projectionMatrix * modelViewMatrix * tPosition;\n vec4 clipNormal = projectionMatrix * modelViewMatrix * tNormal;\n vec2 offset = normalize(clipNormal.xy) * thickness / size * clipPosition.w * 2.0;\n clipPosition.xy += offset;\n gl_Position = clipPosition;\n }\n }",`uniform vec3 color;\n uniform float opacity;\n void main(){\n gl_FragColor = vec4(color, opacity);\n #include <tonemapping_fragment>\n #include <${c.version>=154?"colorspace_fragment":"encodings_fragment"}>\n }`);exports.Outlines=function({color:e="black",opacity:n=1,transparent:t=!1,screenspace:r=!1,toneMapped:c=!0,polygonOffset:s=!1,polygonOffsetFactor:a=0,renderOrder:p=0,thickness:m=.05,angle:g=Math.PI,...v}){const x=d.useRef(),[y]=d.useState((()=>new f({side:u.BackSide}))),{gl:h}=i.useThree(),_=h.getDrawingBufferSize(new u.Vector2);d.useMemo((()=>i.extend({OutlinesMaterial:f})),[]);const M=d.useRef(0),b=d.useRef();return d.useLayoutEffect((()=>{const e=x.current;if(!e)return;const n=e.parent;if(n&&n.geometry&&(M.current!==g||b.current!==n.geometry)){var t;M.current=g,b.current=n.geometry;let r=null==(t=e.children)?void 0:t[0];r&&(g&&r.geometry.dispose(),e.remove(r)),n.skeleton?(r=new u.SkinnedMesh,r.material=y,r.bind(n.skeleton,n.bindMatrix),e.add(r)):n.isInstancedMesh?(r=new u.InstancedMesh(n.geometry,y,n.count),r.instanceMatrix=n.instanceMatrix,e.add(r)):(r=new u.Mesh,r.material=y,e.add(r)),r.geometry=g?o.toCreasedNormals(n.geometry,g):n.geometry}})),d.useLayoutEffect((()=>{const o=x.current;if(!o)return;const l=o.children[0];l&&(l.renderOrder=p,i.applyProps(l.material,{transparent:t,thickness:m,color:e,opacity:n,size:_,screenspace:r,toneMapped:c,polygonOffset:s,polygonOffsetFactor:a}))})),d.useEffect((()=>()=>{const e=x.current;if(!e)return;const n=e.children[0];n&&(g&&n.geometry.dispose(),e.remove(n))}),[]),d.createElement("group",l.default({ref:x},v))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/extends"),n=require("three"),t=require("react"),r=require("./shaderMaterial.cjs.js"),i=require("@react-three/fiber"),o=require("three-stdlib"),c=require("../helpers/constants.cjs.js");function s(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function a(e){if(e&&e.__esModule)return e;var n=Object.create(null);return e&&Object.keys(e).forEach((function(t){if("default"!==t){var r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,r.get?r:{enumerable:!0,get:function(){return e[t]}})}})),n.default=e,Object.freeze(n)}var l=s(e),u=a(n),d=a(t);const f=r.shaderMaterial({screenspace:!1,color:new u.Color("black"),opacity:1,thickness:.05,size:new u.Vector2},"#include <common>\n #include <morphtarget_pars_vertex>\n #include <skinning_pars_vertex>\n uniform float thickness;\n uniform bool screenspace;\n uniform vec2 size;\n void main() {\n #if defined (USE_SKINNING)\n\t #include <beginnormal_vertex>\n #include <morphnormal_vertex>\n #include <skinbase_vertex>\n #include <skinnormal_vertex>\n #include <defaultnormal_vertex>\n #endif\n #include <begin_vertex>\n\t #include <morphtarget_vertex>\n\t #include <skinning_vertex>\n #include <project_vertex>\n vec4 tNormal = vec4(normal, 0.0);\n vec4 tPosition = vec4(transformed, 1.0);\n #ifdef USE_INSTANCING\n tNormal = instanceMatrix * tNormal;\n tPosition = instanceMatrix * tPosition;\n #endif\n if (screenspace) {\n vec3 newPosition = tPosition.xyz + tNormal.xyz * thickness;\n gl_Position = projectionMatrix * modelViewMatrix * vec4(newPosition, 1.0); \n } else {\n vec4 clipPosition = projectionMatrix * modelViewMatrix * tPosition;\n vec4 clipNormal = projectionMatrix * modelViewMatrix * tNormal;\n vec2 offset = normalize(clipNormal.xy) * thickness / size * clipPosition.w * 2.0;\n clipPosition.xy += offset;\n gl_Position = clipPosition;\n }\n }",`uniform vec3 color;\n uniform float opacity;\n void main(){\n gl_FragColor = vec4(color, opacity);\n #include <tonemapping_fragment>\n #include <${c.version>=154?"colorspace_fragment":"encodings_fragment"}>\n }`);exports.Outlines=function({color:e="black",opacity:n=1,transparent:t=!1,screenspace:r=!1,toneMapped:c=!0,polygonOffset:s=!1,polygonOffsetFactor:a=0,renderOrder:p=0,thickness:m=.05,angle:g=Math.PI,...v}){const x=d.useRef(),[y]=d.useState((()=>new f({side:u.BackSide}))),{gl:h}=i.useThree(),_=h.getDrawingBufferSize(new u.Vector2);d.useMemo((()=>i.extend({OutlinesMaterial:f})),[]);const M=d.useRef(0),b=d.useRef();return d.useLayoutEffect((()=>{const e=x.current;if(!e)return;const n=e.parent;if(n&&n.geometry&&(M.current!==g||b.current!==n.geometry)){var t;M.current=g,b.current=n.geometry;let r=null==(t=e.children)?void 0:t[0];r&&(g&&r.geometry.dispose(),e.remove(r)),n.skeleton?(r=new u.SkinnedMesh,r.material=y,r.bind(n.skeleton,n.bindMatrix),e.add(r)):n.isInstancedMesh?(r=new u.InstancedMesh(n.geometry,y,n.count),r.instanceMatrix=n.instanceMatrix,e.add(r)):(r=new u.Mesh,r.material=y,e.add(r)),r.geometry=g?o.toCreasedNormals(n.geometry,g):n.geometry}})),d.useLayoutEffect((()=>{const o=x.current;if(!o)return;const l=o.children[0];l&&(l.renderOrder=p,i.applyProps(l.material,{transparent:t,thickness:m,color:e,opacity:n,size:_,screenspace:r,toneMapped:c,polygonOffset:s,polygonOffsetFactor:a}))})),d.useEffect((()=>()=>{const e=x.current;if(!e)return;const n=e.children[0];n&&(g&&n.geometry.dispose(),e.remove(n))}),[]),d.createElement("group",l.default({ref:x},v))};
package/core/Outlines.js CHANGED
@@ -16,7 +16,7 @@ const OutlinesMaterial = /* @__PURE__ */shaderMaterial({
16
16
  #include <morphtarget_pars_vertex>
17
17
  #include <skinning_pars_vertex>
18
18
  uniform float thickness;
19
- uniform float screenspace;
19
+ uniform bool screenspace;
20
20
  uniform vec2 size;
21
21
  void main() {
22
22
  #if defined (USE_SKINNING)
@@ -36,7 +36,7 @@ const OutlinesMaterial = /* @__PURE__ */shaderMaterial({
36
36
  tNormal = instanceMatrix * tNormal;
37
37
  tPosition = instanceMatrix * tPosition;
38
38
  #endif
39
- if (screenspace == 0.0) {
39
+ if (screenspace) {
40
40
  vec3 newPosition = tPosition.xyz + tNormal.xyz * thickness;
41
41
  gl_Position = projectionMatrix * modelViewMatrix * vec4(newPosition, 1.0);
42
42
  } else {