@react-three/drei 9.104.0 → 9.105.0
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 +7 -3
- package/core/Environment.cjs.js +1 -1
- package/core/Environment.d.ts +9 -4
- package/core/Environment.js +63 -17
- package/core/Outlines.cjs.js +1 -1
- package/core/Outlines.js +2 -1
- package/index.cjs.js +1 -1
- package/package.json +2 -2
- package/react-three-drei-0.0.0-semantic-release.tgz +0 -0
package/README.md
CHANGED
|
@@ -4722,7 +4722,11 @@ Sets up a global cubemap, which affects the default `scene.environment`, and opt
|
|
|
4722
4722
|
```jsx
|
|
4723
4723
|
<Environment
|
|
4724
4724
|
background={false} // can be true, false or "only" (which only sets the background) (default: false)
|
|
4725
|
-
|
|
4725
|
+
backgroundBlurriness={0} // optional blur factor between 0 and 1 (default: 0, only works with three 0.146 and up)
|
|
4726
|
+
backgroundIntensity={1} // optional intensity factor (default: 1, only works with three 0.163 and up)
|
|
4727
|
+
backgroundRotation={[0, Math.PI / 2, 0]} // optional rotation (default: 0, only works with three 0.163 and up)
|
|
4728
|
+
environmentIntensity={1} // optional intensity factor (default: 1, only works with three 0.163 and up)
|
|
4729
|
+
environmentRotation={[0, Math.PI / 2, 0]} // optional rotation (default: 0, only works with three 0.163 and up)
|
|
4726
4730
|
files={['px.png', 'nx.png', 'py.png', 'ny.png', 'pz.png', 'nz.png']}
|
|
4727
4731
|
path="/"
|
|
4728
4732
|
preset={null}
|
|
@@ -4756,8 +4760,8 @@ Otherwise use the files property. It will use RGBELoader for _.hdr, EXRLoader fo
|
|
|
4756
4760
|
<Environment files="file.hdr" />
|
|
4757
4761
|
<Environment files="file.exr" />
|
|
4758
4762
|
<Environment files="file.jpg" />
|
|
4759
|
-
<Environment files=
|
|
4760
|
-
<Environment files={['px.png', 'nx.png', 'py.png', 'ny.png', 'pz.png', 'nz.png']}
|
|
4763
|
+
<Environment files={['file.webp', 'file-gainmap.webp', 'file.json']} />
|
|
4764
|
+
<Environment files={['px.png', 'nx.png', 'py.png', 'ny.png', 'pz.png', 'nz.png']} />
|
|
4761
4765
|
```
|
|
4762
4766
|
|
|
4763
4767
|
You can also use [@pmndrs/assets](https://github.com/pmndrs/assets) to easily self host common assets. Always use dynamic imports to avoid making this part of your main bundle.
|
package/core/Environment.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/extends"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/extends"),n=require("react"),t=require("@react-three/fiber"),r=require("three"),o=require("three-stdlib"),u=require("./useEnvironment.cjs.js");function a(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function i(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)}require("@monogrid/gainmap-js"),require("../helpers/environment-assets.cjs.js"),require("../helpers/deprecated.cjs.js");var c=a(e),s=i(n);const l=e=>{return(n=e).current&&n.current.isScene?e.current:e;var n};function d(e,n,r,o,u={}){var a,i,c,s,d;u={backgroundBlurriness:null!==(a=u.blur)&&void 0!==a?a:0,backgroundIntensity:1,backgroundRotation:[0,0,0],environmentIntensity:1,environmentRotation:[0,0,0],...u};const m=l(n||r),b=m.background,g=m.environment,v={backgroundBlurriness:m.backgroundBlurriness,backgroundIntensity:m.backgroundIntensity,backgroundRotation:null!==(i=null==(c=m.backgroundRotation)||null==c.clone?void 0:c.clone())&&void 0!==i?i:[0,0,0],environmentIntensity:m.environmentIntensity,environmentRotation:null!==(s=null==(d=m.environmentRotation)||null==d.clone?void 0:d.clone())&&void 0!==s?s:[0,0,0]};return"only"!==e&&(m.environment=o),e&&(m.background=o,t.applyProps(m,u)),()=>{"only"!==e&&(m.environment=g),e&&(m.background=b,t.applyProps(m,v))}}function m({scene:e,background:n=!1,map:r,...o}){const u=t.useThree((e=>e.scene));return s.useLayoutEffect((()=>{if(r)return d(n,e,u,r,o)})),null}function b({background:e=!1,scene:n,blur:r,backgroundBlurriness:o,backgroundIntensity:a,backgroundRotation:i,environmentIntensity:c,environmentRotation:l,...m}){const b=u.useEnvironment(m),g=t.useThree((e=>e.scene));return s.useLayoutEffect((()=>d(e,n,g,b,{blur:r,backgroundBlurriness:o,backgroundIntensity:a,backgroundRotation:i,environmentIntensity:c,environmentRotation:l}))),null}function g({children:e,near:n=1,far:o=1e3,resolution:u=256,frames:a=1,map:i,background:c=!1,blur:l,backgroundBlurriness:g,backgroundIntensity:v,backgroundRotation:p,environmentIntensity:f,environmentRotation:k,scene:y,files:E,path:h,preset:j,extensions:I}){const R=t.useThree((e=>e.gl)),x=t.useThree((e=>e.scene)),P=s.useRef(null),[q]=s.useState((()=>new r.Scene)),B=s.useMemo((()=>{const e=new r.WebGLCubeRenderTarget(u);return e.texture.type=r.HalfFloatType,e}),[u]);s.useLayoutEffect((()=>(1===a&&P.current.update(R,q),d(c,y,x,B.texture,{blur:l,backgroundBlurriness:g,backgroundIntensity:v,backgroundRotation:p,environmentIntensity:f,environmentRotation:k}))),[e,q,B.texture,y,x,c,a,R]);let O=1;return t.useFrame((()=>{(a===1/0||O<a)&&(P.current.update(R,q),O++)})),s.createElement(s.Fragment,null,t.createPortal(s.createElement(s.Fragment,null,e,s.createElement("cubeCamera",{ref:P,args:[n,o,B]}),E||j?s.createElement(b,{background:!0,files:E,preset:j,path:h,extensions:I}):i?s.createElement(m,{background:!0,map:i,extensions:I}):null),q))}function v(e){var n,r,a,i;const l=u.useEnvironment(e),d=e.map||l;s.useMemo((()=>t.extend({GroundProjectedEnvImpl:o.GroundProjectedEnv})),[]);const b=s.useMemo((()=>[d]),[d]),g=null==(n=e.ground)?void 0:n.height,v=null==(r=e.ground)?void 0:r.radius,p=null!==(a=null==(i=e.ground)?void 0:i.scale)&&void 0!==a?a:1e3;return s.createElement(s.Fragment,null,s.createElement(m,c.default({},e,{map:d})),s.createElement("groundProjectedEnvImpl",{args:b,scale:p,height:g,radius:v}))}exports.Environment=function(e){return e.ground?s.createElement(v,e):e.map?s.createElement(m,e):e.children?s.createElement(g,e):s.createElement(b,e)},exports.EnvironmentCube=b,exports.EnvironmentMap=m,exports.EnvironmentPortal=g;
|
package/core/Environment.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { Object3DNode } from '@react-three/fiber';
|
|
2
|
+
import { Object3DNode, Vector3 } from '@react-three/fiber';
|
|
3
3
|
import { Texture, Scene } from 'three';
|
|
4
4
|
import { GroundProjectedEnv as GroundProjectedEnvImpl } from 'three-stdlib';
|
|
5
5
|
import { PresetsType } from '../helpers/environment-assets';
|
|
@@ -12,6 +12,11 @@ export type EnvironmentProps = {
|
|
|
12
12
|
resolution?: number;
|
|
13
13
|
background?: boolean | 'only';
|
|
14
14
|
blur?: number;
|
|
15
|
+
backgroundBlurriness?: number;
|
|
16
|
+
backgroundIntensity?: number;
|
|
17
|
+
backgroundRotation?: Vector3;
|
|
18
|
+
environmentIntensity?: number;
|
|
19
|
+
environmentRotation?: Vector3;
|
|
15
20
|
map?: Texture;
|
|
16
21
|
preset?: PresetsType;
|
|
17
22
|
scene?: Scene | React.MutableRefObject<Scene>;
|
|
@@ -21,9 +26,9 @@ export type EnvironmentProps = {
|
|
|
21
26
|
scale?: number;
|
|
22
27
|
};
|
|
23
28
|
} & EnvironmentLoaderProps;
|
|
24
|
-
export declare function EnvironmentMap({ scene, background,
|
|
25
|
-
export declare function EnvironmentCube({ background, scene, blur, ...rest }: EnvironmentProps): null;
|
|
26
|
-
export declare function EnvironmentPortal({ children, near, far, resolution, frames, map, background, blur, scene, files, path, preset, extensions, }: EnvironmentProps): React.JSX.Element;
|
|
29
|
+
export declare function EnvironmentMap({ scene, background, map, ...config }: EnvironmentProps): null;
|
|
30
|
+
export declare function EnvironmentCube({ background, scene, blur, backgroundBlurriness, backgroundIntensity, backgroundRotation, environmentIntensity, environmentRotation, ...rest }: EnvironmentProps): null;
|
|
31
|
+
export declare function EnvironmentPortal({ children, near, far, resolution, frames, map, background, blur, backgroundBlurriness, backgroundIntensity, backgroundRotation, environmentIntensity, environmentRotation, scene, files, path, preset, extensions, }: EnvironmentProps): React.JSX.Element;
|
|
27
32
|
declare global {
|
|
28
33
|
namespace JSX {
|
|
29
34
|
interface IntrinsicElements {
|
package/core/Environment.js
CHANGED
|
@@ -1,52 +1,86 @@
|
|
|
1
1
|
import _extends from '@babel/runtime/helpers/esm/extends';
|
|
2
2
|
import * as React from 'react';
|
|
3
|
-
import { useThree, useFrame, createPortal, extend } from '@react-three/fiber';
|
|
3
|
+
import { useThree, useFrame, createPortal, applyProps, extend } from '@react-three/fiber';
|
|
4
4
|
import { Scene, WebGLCubeRenderTarget, HalfFloatType } from 'three';
|
|
5
5
|
import { GroundProjectedEnv } from 'three-stdlib';
|
|
6
6
|
import { useEnvironment } from './useEnvironment.js';
|
|
7
7
|
|
|
8
8
|
const isRef = obj => obj.current && obj.current.isScene;
|
|
9
9
|
const resolveScene = scene => isRef(scene) ? scene.current : scene;
|
|
10
|
-
function setEnvProps(background, scene, defaultScene, texture,
|
|
10
|
+
function setEnvProps(background, scene, defaultScene, texture, sceneProps = {}) {
|
|
11
|
+
var _sceneProps$blur, _target$backgroundRot, _target$backgroundRot2, _target$environmentRo, _target$environmentRo2;
|
|
12
|
+
// defaults
|
|
13
|
+
sceneProps = {
|
|
14
|
+
backgroundBlurriness: (_sceneProps$blur = sceneProps.blur) !== null && _sceneProps$blur !== void 0 ? _sceneProps$blur : 0,
|
|
15
|
+
backgroundIntensity: 1,
|
|
16
|
+
backgroundRotation: [0, 0, 0],
|
|
17
|
+
environmentIntensity: 1,
|
|
18
|
+
environmentRotation: [0, 0, 0],
|
|
19
|
+
...sceneProps
|
|
20
|
+
};
|
|
11
21
|
const target = resolveScene(scene || defaultScene);
|
|
12
22
|
const oldbg = target.background;
|
|
13
23
|
const oldenv = target.environment;
|
|
14
|
-
|
|
15
|
-
|
|
24
|
+
const oldSceneProps = {
|
|
25
|
+
// @ts-ignore
|
|
26
|
+
backgroundBlurriness: target.backgroundBlurriness,
|
|
27
|
+
// @ts-ignore
|
|
28
|
+
backgroundIntensity: target.backgroundIntensity,
|
|
29
|
+
// @ts-ignore
|
|
30
|
+
backgroundRotation: (_target$backgroundRot = (_target$backgroundRot2 = target.backgroundRotation) == null || _target$backgroundRot2.clone == null ? void 0 : _target$backgroundRot2.clone()) !== null && _target$backgroundRot !== void 0 ? _target$backgroundRot : [0, 0, 0],
|
|
31
|
+
// @ts-ignore
|
|
32
|
+
environmentIntensity: target.environmentIntensity,
|
|
33
|
+
// @ts-ignore
|
|
34
|
+
environmentRotation: (_target$environmentRo = (_target$environmentRo2 = target.environmentRotation) == null || _target$environmentRo2.clone == null ? void 0 : _target$environmentRo2.clone()) !== null && _target$environmentRo !== void 0 ? _target$environmentRo : [0, 0, 0]
|
|
35
|
+
};
|
|
16
36
|
if (background !== 'only') target.environment = texture;
|
|
17
|
-
if (background)
|
|
18
|
-
|
|
19
|
-
|
|
37
|
+
if (background) {
|
|
38
|
+
target.background = texture;
|
|
39
|
+
applyProps(target, sceneProps);
|
|
40
|
+
}
|
|
20
41
|
return () => {
|
|
21
42
|
if (background !== 'only') target.environment = oldenv;
|
|
22
|
-
if (background)
|
|
23
|
-
|
|
24
|
-
|
|
43
|
+
if (background) {
|
|
44
|
+
target.background = oldbg;
|
|
45
|
+
applyProps(target, oldSceneProps);
|
|
46
|
+
}
|
|
25
47
|
};
|
|
26
48
|
}
|
|
27
49
|
function EnvironmentMap({
|
|
28
50
|
scene,
|
|
29
51
|
background = false,
|
|
30
|
-
|
|
31
|
-
|
|
52
|
+
map,
|
|
53
|
+
...config
|
|
32
54
|
}) {
|
|
33
55
|
const defaultScene = useThree(state => state.scene);
|
|
34
56
|
React.useLayoutEffect(() => {
|
|
35
|
-
if (map) return setEnvProps(background, scene, defaultScene, map,
|
|
36
|
-
}
|
|
57
|
+
if (map) return setEnvProps(background, scene, defaultScene, map, config);
|
|
58
|
+
});
|
|
37
59
|
return null;
|
|
38
60
|
}
|
|
39
61
|
function EnvironmentCube({
|
|
40
62
|
background = false,
|
|
41
63
|
scene,
|
|
42
64
|
blur,
|
|
65
|
+
backgroundBlurriness,
|
|
66
|
+
backgroundIntensity,
|
|
67
|
+
backgroundRotation,
|
|
68
|
+
environmentIntensity,
|
|
69
|
+
environmentRotation,
|
|
43
70
|
...rest
|
|
44
71
|
}) {
|
|
45
72
|
const texture = useEnvironment(rest);
|
|
46
73
|
const defaultScene = useThree(state => state.scene);
|
|
47
74
|
React.useLayoutEffect(() => {
|
|
48
|
-
return setEnvProps(background, scene, defaultScene, texture,
|
|
49
|
-
|
|
75
|
+
return setEnvProps(background, scene, defaultScene, texture, {
|
|
76
|
+
blur,
|
|
77
|
+
backgroundBlurriness,
|
|
78
|
+
backgroundIntensity,
|
|
79
|
+
backgroundRotation,
|
|
80
|
+
environmentIntensity,
|
|
81
|
+
environmentRotation
|
|
82
|
+
});
|
|
83
|
+
});
|
|
50
84
|
return null;
|
|
51
85
|
}
|
|
52
86
|
function EnvironmentPortal({
|
|
@@ -58,6 +92,11 @@ function EnvironmentPortal({
|
|
|
58
92
|
map,
|
|
59
93
|
background = false,
|
|
60
94
|
blur,
|
|
95
|
+
backgroundBlurriness,
|
|
96
|
+
backgroundIntensity,
|
|
97
|
+
backgroundRotation,
|
|
98
|
+
environmentIntensity,
|
|
99
|
+
environmentRotation,
|
|
61
100
|
scene,
|
|
62
101
|
files,
|
|
63
102
|
path,
|
|
@@ -75,7 +114,14 @@ function EnvironmentPortal({
|
|
|
75
114
|
}, [resolution]);
|
|
76
115
|
React.useLayoutEffect(() => {
|
|
77
116
|
if (frames === 1) camera.current.update(gl, virtualScene);
|
|
78
|
-
return setEnvProps(background, scene, defaultScene, fbo.texture,
|
|
117
|
+
return setEnvProps(background, scene, defaultScene, fbo.texture, {
|
|
118
|
+
blur,
|
|
119
|
+
backgroundBlurriness,
|
|
120
|
+
backgroundIntensity,
|
|
121
|
+
backgroundRotation,
|
|
122
|
+
environmentIntensity,
|
|
123
|
+
environmentRotation
|
|
124
|
+
});
|
|
79
125
|
}, [children, virtualScene, fbo.texture, scene, defaultScene, background, frames, gl]);
|
|
80
126
|
let count = 1;
|
|
81
127
|
useFrame(() => {
|
package/core/Outlines.cjs.js
CHANGED
|
@@ -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)){M.current=g,b.current=n.geometry;let t=e.children[0];
|
|
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))};
|
package/core/Outlines.js
CHANGED
|
@@ -85,11 +85,12 @@ function Outlines({
|
|
|
85
85
|
const parent = group.parent;
|
|
86
86
|
if (parent && parent.geometry) {
|
|
87
87
|
if (oldAngle.current !== angle || oldGeometry.current !== parent.geometry) {
|
|
88
|
+
var _group$children;
|
|
88
89
|
oldAngle.current = angle;
|
|
89
90
|
oldGeometry.current = parent.geometry;
|
|
90
91
|
|
|
91
92
|
// Remove old mesh
|
|
92
|
-
let mesh = group.children[0];
|
|
93
|
+
let mesh = (_group$children = group.children) == null ? void 0 : _group$children[0];
|
|
93
94
|
if (mesh) {
|
|
94
95
|
if (angle) mesh.geometry.dispose();
|
|
95
96
|
group.remove(mesh);
|