@react-three/drei 9.101.0 → 9.102.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 +2 -0
- package/core/Cloud.d.ts +1 -1
- package/core/Edges.cjs.js +1 -1
- package/core/Edges.d.ts +10 -6
- package/core/Edges.js +33 -12
- package/index.cjs.js +1 -1
- package/package.json +1 -1
- package/react-three-drei-0.0.0-semantic-release.tgz +0 -0
package/README.md
CHANGED
|
@@ -4887,6 +4887,8 @@ type CloudsProps = JSX.IntrinsicElements['group'] & {
|
|
|
4887
4887
|
range?: number
|
|
4888
4888
|
/** Which material it will override, default: MeshLambertMaterial */
|
|
4889
4889
|
material?: typeof Material
|
|
4890
|
+
/** Frustum culling, default: true */
|
|
4891
|
+
frustumCulled?: boolean
|
|
4890
4892
|
}
|
|
4891
4893
|
|
|
4892
4894
|
type CloudProps = JSX.IntrinsicElements['group'] & {
|
package/core/Cloud.d.ts
CHANGED
|
@@ -33,6 +33,7 @@ type CloudsProps = JSX.IntrinsicElements['group'] & {
|
|
|
33
33
|
limit?: number;
|
|
34
34
|
range?: number;
|
|
35
35
|
material?: typeof Material;
|
|
36
|
+
frustumCulled?: boolean;
|
|
36
37
|
};
|
|
37
38
|
type CloudProps = JSX.IntrinsicElements['group'] & {
|
|
38
39
|
seed?: number;
|
|
@@ -51,7 +52,6 @@ type CloudProps = JSX.IntrinsicElements['group'] & {
|
|
|
51
52
|
fade?: number;
|
|
52
53
|
opacity?: number;
|
|
53
54
|
color?: ReactThreeFiber.Color;
|
|
54
|
-
frustumCulled?: boolean;
|
|
55
55
|
};
|
|
56
56
|
export declare const Clouds: React.ForwardRefExoticComponent<Omit<CloudsProps, "ref"> & React.RefAttributes<Group>>;
|
|
57
57
|
export declare const CloudInstance: React.ForwardRefExoticComponent<Omit<CloudProps, "ref"> & React.RefAttributes<Group>>;
|
package/core/Edges.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"),t=require("react"),r=require("three"),n=require("three-stdlib"),i=require("@react-three/fiber");function u(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function a(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 c=u(e),o=a(t),s=a(r);const l=o.forwardRef((({children:e,threshold:t=15,color:r="black",opacity:u=1,linewidth:a,lineWidth:l,...d},f)=>{var m;const b=o.useRef(null);o.useImperativeHandle(f,(()=>b.current),[]);const h=o.useMemo((()=>new n.LineSegmentsGeometry),[]),p=o.useMemo((()=>new n.LineMaterial),[]),y=i.useThree((e=>e.size)),g=o.useRef(),v=o.useRef();return o.useLayoutEffect((()=>{const e=b.current.parent;if(e){const r=e.geometry;if(r!==g.current||t!==v.current){g.current=r,v.current=t;const e=new s.EdgesGeometry(r,t).attributes.position.array;b.current.geometry.setPositions(e),b.current.geometry.attributes.instanceStart.needsUpdate=!0,b.current.geometry.attributes.instanceEnd.needsUpdate=!0}}})),o.createElement("mesh",c.default({ref:b,raycast:()=>null},d),o.createElement("primitive",{object:h,attach:"geometry"}),o.createElement("primitive",{object:p,attach:"material",color:r,opacity:u,transparent:u<1,resolution:[y.width,y.height],linewidth:null!==(m=null!=a?a:l)&&void 0!==m?m:1}),e)}));exports.Edges=l;
|
package/core/Edges.d.ts
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
|
-
import { ReactThreeFiber } from '@react-three/fiber';
|
|
2
1
|
import * as THREE from 'three';
|
|
2
|
+
import { LineSegmentsGeometry, LineMaterial } from 'three-stdlib';
|
|
3
3
|
import { ForwardRefComponent } from '../helpers/ts-utils';
|
|
4
|
-
type
|
|
4
|
+
import { type Color, type ThreeElements } from '@react-three/fiber';
|
|
5
|
+
export type EdgesRef = THREE.Mesh<LineSegmentsGeometry, LineMaterial>;
|
|
6
|
+
export interface EdgesProps extends Partial<ThreeElements['mesh']> {
|
|
7
|
+
color?: Color;
|
|
8
|
+
opacity?: number;
|
|
5
9
|
threshold?: number;
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
export
|
|
10
|
+
linewidth?: number;
|
|
11
|
+
lineWidth?: number;
|
|
12
|
+
}
|
|
13
|
+
export declare const Edges: ForwardRefComponent<EdgesProps, EdgesRef>;
|
package/core/Edges.js
CHANGED
|
@@ -1,34 +1,55 @@
|
|
|
1
1
|
import _extends from '@babel/runtime/helpers/esm/extends';
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import * as THREE from 'three';
|
|
4
|
+
import { LineSegmentsGeometry, LineMaterial } from 'three-stdlib';
|
|
5
|
+
import { useThree } from '@react-three/fiber';
|
|
4
6
|
|
|
5
7
|
const Edges = /* @__PURE__ */React.forwardRef(({
|
|
6
|
-
userData,
|
|
7
8
|
children,
|
|
8
|
-
geometry,
|
|
9
9
|
threshold = 15,
|
|
10
10
|
color = 'black',
|
|
11
|
+
opacity = 1,
|
|
12
|
+
linewidth,
|
|
13
|
+
lineWidth,
|
|
11
14
|
...props
|
|
12
15
|
}, fref) => {
|
|
16
|
+
var _ref;
|
|
13
17
|
const ref = React.useRef(null);
|
|
18
|
+
React.useImperativeHandle(fref, () => ref.current, []);
|
|
19
|
+
const geometry = React.useMemo(() => new LineSegmentsGeometry(), []);
|
|
20
|
+
const material = React.useMemo(() => new LineMaterial(), []);
|
|
21
|
+
const size = useThree(s => s.size);
|
|
22
|
+
const memoizedGeometry = React.useRef();
|
|
23
|
+
const memoizedThreshold = React.useRef();
|
|
14
24
|
React.useLayoutEffect(() => {
|
|
15
25
|
const parent = ref.current.parent;
|
|
16
26
|
if (parent) {
|
|
17
|
-
const
|
|
18
|
-
if (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
27
|
+
const geometry = parent.geometry;
|
|
28
|
+
if (geometry !== memoizedGeometry.current || threshold !== memoizedThreshold.current) {
|
|
29
|
+
memoizedGeometry.current = geometry;
|
|
30
|
+
memoizedThreshold.current = threshold;
|
|
31
|
+
const points = new THREE.EdgesGeometry(geometry, threshold).attributes.position.array;
|
|
32
|
+
ref.current.geometry.setPositions(points);
|
|
33
|
+
ref.current.geometry.attributes.instanceStart.needsUpdate = true;
|
|
34
|
+
ref.current.geometry.attributes.instanceEnd.needsUpdate = true;
|
|
22
35
|
}
|
|
23
36
|
}
|
|
24
37
|
});
|
|
25
|
-
React.
|
|
26
|
-
return /*#__PURE__*/React.createElement("lineSegments", _extends({
|
|
38
|
+
return /*#__PURE__*/React.createElement("mesh", _extends({
|
|
27
39
|
ref: ref,
|
|
28
40
|
raycast: () => null
|
|
29
|
-
}, props),
|
|
30
|
-
|
|
31
|
-
|
|
41
|
+
}, props), /*#__PURE__*/React.createElement("primitive", {
|
|
42
|
+
object: geometry,
|
|
43
|
+
attach: "geometry"
|
|
44
|
+
}), /*#__PURE__*/React.createElement("primitive", {
|
|
45
|
+
object: material,
|
|
46
|
+
attach: "material",
|
|
47
|
+
color: color,
|
|
48
|
+
opacity: opacity,
|
|
49
|
+
transparent: opacity < 1,
|
|
50
|
+
resolution: [size.width, size.height],
|
|
51
|
+
linewidth: (_ref = linewidth !== null && linewidth !== void 0 ? linewidth : lineWidth) !== null && _ref !== void 0 ? _ref : 1
|
|
52
|
+
}), children);
|
|
32
53
|
});
|
|
33
54
|
|
|
34
55
|
export { Edges };
|