@react-three/drei 9.93.1 → 9.94.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 +36 -12
- package/core/Instances.d.ts +1 -21
- package/core/Instances.js +4 -1
- package/core/MeshPortalMaterial.d.ts +1 -9
- package/index.cjs.js +1 -1
- package/package.json +3 -2
- package/react-three-drei-0.0.0-semantic-release.tgz +0 -0
- package/web/View.cjs.js +1 -1
- package/web/View.d.ts +11 -2
- package/web/View.js +145 -59
- package/web/index.cjs.js +1 -1
- package/web/index.js +1 -0
package/README.md
CHANGED
|
@@ -3623,6 +3623,7 @@ type HudProps = {
|
|
|
3623
3623
|
|
|
3624
3624
|
<p>
|
|
3625
3625
|
<a href="https://codesandbox.io/s/v5i9wl"><img width="20%" src="https://codesandbox.io/api/v1/sandboxes/v5i9wl/screenshot.png" alt="Demo"/></a>
|
|
3626
|
+
<a href="https://codesandbox.io/s/r9w2ob"><img width="20%" src="https://codesandbox.io/api/v1/sandboxes/r9w2ob/screenshot.png" alt="Demo"/></a>
|
|
3626
3627
|
<a href="https://codesandbox.io/s/bp6tmc"><img width="20%" src="https://codesandbox.io/api/v1/sandboxes/bp6tmc/screenshot.png" alt="Demo"/></a>
|
|
3627
3628
|
<a href="https://codesandbox.io/s/1wmlew"><img width="20%" src="https://codesandbox.io/api/v1/sandboxes/1wmlew/screenshot.png" alt="Demo"/></a>
|
|
3628
3629
|
</p>
|
|
@@ -3638,30 +3639,53 @@ integrations into your view.
|
|
|
3638
3639
|
> versions of `@react-three/fiber`.
|
|
3639
3640
|
|
|
3640
3641
|
```tsx
|
|
3641
|
-
|
|
3642
|
-
/**
|
|
3643
|
-
|
|
3642
|
+
export type ViewProps = {
|
|
3643
|
+
/** Root element type, default: div */
|
|
3644
|
+
as?: string
|
|
3645
|
+
/** CSS id prop */
|
|
3646
|
+
id?: string
|
|
3647
|
+
/** CSS classname prop */
|
|
3648
|
+
className?: string
|
|
3649
|
+
/** CSS style prop */
|
|
3650
|
+
style?: React.CSSProperties
|
|
3651
|
+
/** If the view is visible or not, default: true */
|
|
3652
|
+
visible?: boolean
|
|
3644
3653
|
/** Views take over the render loop, optional render index (1 by default) */
|
|
3645
3654
|
index?: number
|
|
3646
|
-
/** If you know your view is always at the same place set this to 1 to avoid needless getBoundingClientRect overhead
|
|
3655
|
+
/** If you know your view is always at the same place set this to 1 to avoid needless getBoundingClientRect overhead */
|
|
3647
3656
|
frames?: number
|
|
3648
3657
|
/** The scene to render, if you leave this undefined it will render the default scene */
|
|
3649
3658
|
children?: React.ReactNode
|
|
3650
|
-
|
|
3659
|
+
/** The tracking element, the view will be cut according to its whereabouts
|
|
3660
|
+
* @deprecated
|
|
3661
|
+
*/
|
|
3662
|
+
track: React.MutableRefObject<HTMLElement>
|
|
3663
|
+
}
|
|
3664
|
+
|
|
3665
|
+
export type ViewportProps = { Port: () => React.ReactNode } & React.ForwardRefExoticComponent<
|
|
3666
|
+
ViewProps & React.RefAttributes<HTMLElement | THREE.Group>
|
|
3667
|
+
>
|
|
3651
3668
|
```
|
|
3652
3669
|
|
|
3670
|
+
You can define as many views as you like, directly mix them into your dom graph, right where you want them to appear. `View` is an unstyled HTML DOM element (by default a div, and it takes the same properties as one). Use `View.Port` inside the canvas to output them. The canvas should ideally fill the entire screen with absolute positioning, underneath HTML or on top of it, as you prefer.
|
|
3671
|
+
|
|
3653
3672
|
```jsx
|
|
3654
|
-
const container = useRef()
|
|
3655
|
-
const tracking = useRef()
|
|
3656
3673
|
return (
|
|
3657
3674
|
<main ref={container}>
|
|
3658
3675
|
<h1>Html content here</h1>
|
|
3659
|
-
<
|
|
3676
|
+
<View style={{ width: 200, height: 200 }}>
|
|
3677
|
+
<mesh geometry={foo} />
|
|
3678
|
+
<OrbitControls />
|
|
3679
|
+
</View>
|
|
3680
|
+
<View className="canvas-view">
|
|
3681
|
+
<mesh geometry={bar} />
|
|
3682
|
+
<CameraControls />
|
|
3683
|
+
</View>
|
|
3660
3684
|
<Canvas eventSource={container}>
|
|
3661
|
-
<View
|
|
3662
|
-
|
|
3663
|
-
|
|
3664
|
-
|
|
3685
|
+
<View.Port />
|
|
3686
|
+
</Canvas>
|
|
3687
|
+
</main>
|
|
3688
|
+
)
|
|
3665
3689
|
```
|
|
3666
3690
|
|
|
3667
3691
|
#### RenderTexture
|
package/core/Instances.d.ts
CHANGED
|
@@ -33,27 +33,7 @@ declare class PositionMesh extends THREE.Group {
|
|
|
33
33
|
get geometry(): THREE.BufferGeometry | undefined;
|
|
34
34
|
raycast(raycaster: THREE.Raycaster, intersects: THREE.Intersection[]): void;
|
|
35
35
|
}
|
|
36
|
-
export declare const Instance: React.ForwardRefExoticComponent<Omit<
|
|
37
|
-
position?: ReactThreeFiber.Vector3 | undefined;
|
|
38
|
-
up?: ReactThreeFiber.Vector3 | undefined;
|
|
39
|
-
scale?: ReactThreeFiber.Vector3 | undefined;
|
|
40
|
-
rotation?: ReactThreeFiber.Euler | undefined;
|
|
41
|
-
matrix?: ReactThreeFiber.Matrix4 | undefined;
|
|
42
|
-
quaternion?: ReactThreeFiber.Quaternion | undefined;
|
|
43
|
-
layers?: ReactThreeFiber.Layers | undefined;
|
|
44
|
-
dispose?: (() => void) | null | undefined;
|
|
45
|
-
}>> & {
|
|
46
|
-
position?: ReactThreeFiber.Vector3 | undefined;
|
|
47
|
-
up?: ReactThreeFiber.Vector3 | undefined;
|
|
48
|
-
scale?: ReactThreeFiber.Vector3 | undefined;
|
|
49
|
-
rotation?: ReactThreeFiber.Euler | undefined;
|
|
50
|
-
matrix?: ReactThreeFiber.Matrix4 | undefined;
|
|
51
|
-
quaternion?: ReactThreeFiber.Quaternion | undefined;
|
|
52
|
-
layers?: ReactThreeFiber.Layers | undefined;
|
|
53
|
-
dispose?: (() => void) | null | undefined;
|
|
54
|
-
} & import("@react-three/fiber/dist/declarations/src/core/events").EventHandlers & {
|
|
55
|
-
context?: React.Context<Api> | undefined;
|
|
56
|
-
}, "ref"> & React.RefAttributes<unknown>>;
|
|
36
|
+
export declare const Instance: React.ForwardRefExoticComponent<Omit<InstanceProps, "ref"> & React.RefAttributes<unknown>>;
|
|
57
37
|
export declare const Instances: ForwardRefComponent<InstancesProps, InstancedMesh>;
|
|
58
38
|
export interface MergedProps extends InstancesProps {
|
|
59
39
|
meshes: THREE.Mesh[];
|
package/core/Instances.js
CHANGED
|
@@ -6,6 +6,9 @@ import mergeRefs from 'react-merge-refs';
|
|
|
6
6
|
import Composer from 'react-composer';
|
|
7
7
|
import { setUpdateRange } from '../helpers/deprecated.js';
|
|
8
8
|
|
|
9
|
+
function isFunctionChild(value) {
|
|
10
|
+
return typeof value === 'function';
|
|
11
|
+
}
|
|
9
12
|
const _instanceLocalMatrix = /* @__PURE__ */new THREE.Matrix4();
|
|
10
13
|
const _instanceWorldMatrix = /* @__PURE__ */new THREE.Matrix4();
|
|
11
14
|
const _instanceIntersects = [];
|
|
@@ -173,7 +176,7 @@ const Instances = /* @__PURE__ */React.forwardRef(({
|
|
|
173
176
|
array: colors,
|
|
174
177
|
itemSize: 3,
|
|
175
178
|
usage: THREE.DynamicDrawUsage
|
|
176
|
-
}),
|
|
179
|
+
}), isFunctionChild(children) ? /*#__PURE__*/React.createElement(context.Provider, {
|
|
177
180
|
value: api
|
|
178
181
|
}, children(instance)) : /*#__PURE__*/React.createElement(globalContext.Provider, {
|
|
179
182
|
value: api
|
|
@@ -25,12 +25,4 @@ export type PortalProps = JSX.IntrinsicElements['shaderMaterial'] & {
|
|
|
25
25
|
renderPriority?: number;
|
|
26
26
|
events?: boolean;
|
|
27
27
|
};
|
|
28
|
-
export declare const MeshPortalMaterial: React.ForwardRefExoticComponent<Omit<
|
|
29
|
-
blend?: number | undefined;
|
|
30
|
-
blur?: number | undefined;
|
|
31
|
-
resolution?: number | undefined;
|
|
32
|
-
worldUnits?: boolean | undefined;
|
|
33
|
-
eventPriority?: number | undefined;
|
|
34
|
-
renderPriority?: number | undefined;
|
|
35
|
-
events?: boolean | undefined;
|
|
36
|
-
}, "ref"> & React.RefAttributes<PortalMaterialType>>;
|
|
28
|
+
export declare const MeshPortalMaterial: React.ForwardRefExoticComponent<Omit<PortalProps, "ref"> & React.RefAttributes<PortalMaterialType>>;
|