@react-three/fiber 7.0.26 → 7.0.29
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/CHANGELOG.md +19 -1
- package/dist/declarations/src/core/events.d.ts +3 -3
- package/dist/declarations/src/core/hooks.d.ts +4 -1
- package/dist/declarations/src/core/renderer.d.ts +3 -3
- package/dist/declarations/src/core/store.d.ts +3 -3
- package/dist/declarations/src/index.d.ts +1 -0
- package/dist/declarations/src/three-types.d.ts +18 -0
- package/dist/declarations/src/web/Canvas.d.ts +2 -2
- package/dist/declarations/src/web/events.d.ts +2 -2
- package/dist/declarations/src/web/index.d.ts +4 -4
- package/dist/react-three-fiber.cjs.dev.js +45 -37
- package/dist/react-three-fiber.cjs.prod.js +45 -37
- package/dist/react-three-fiber.esm.js +39 -30
- package/native/dist/react-three-fiber-native.cjs.d.ts +11 -1
- package/native/dist/react-three-fiber-native.cjs.js +15 -6
- package/package.json +2 -2
- package/native/dist/react-three-fiber-native.cjs.dev.js +0 -358
- package/native/dist/react-three-fiber-native.cjs.prod.js +0 -358
- package/native/dist/react-three-fiber-native.esm.js +0 -306
package/CHANGELOG.md
CHANGED
|
@@ -1,10 +1,28 @@
|
|
|
1
1
|
# @react-three/fiber
|
|
2
2
|
|
|
3
|
+
## 7.0.29
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- c99a175: fix native entrypoint
|
|
8
|
+
|
|
9
|
+
## 7.0.28
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 462615e7: bump version
|
|
14
|
+
|
|
15
|
+
## 7.0.27
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- 44bb35ab: insertBefore supports attachArray
|
|
20
|
+
|
|
3
21
|
## 7.0.26
|
|
4
22
|
|
|
5
23
|
### Patch Changes
|
|
6
24
|
|
|
7
|
-
-
|
|
25
|
+
- 13dde9b8: insertBefore supports attachArray
|
|
8
26
|
|
|
9
27
|
## 7.0.25
|
|
10
28
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as THREE from 'three';
|
|
2
|
-
import type {
|
|
2
|
+
import type { UseBoundStore } from 'zustand';
|
|
3
3
|
import type { RootState } from './store';
|
|
4
4
|
export interface Intersection extends THREE.Intersection {
|
|
5
5
|
eventObject: THREE.Object3D;
|
|
@@ -57,7 +57,7 @@ export interface PointerCaptureTarget {
|
|
|
57
57
|
intersection: Intersection;
|
|
58
58
|
target: Element;
|
|
59
59
|
}
|
|
60
|
-
export declare function removeInteractivity(store:
|
|
61
|
-
export declare function createEvents(store:
|
|
60
|
+
export declare function removeInteractivity(store: UseBoundStore<RootState>, object: THREE.Object3D): void;
|
|
61
|
+
export declare function createEvents(store: UseBoundStore<RootState>): {
|
|
62
62
|
handlePointer: (name: string) => (event: DomEvent) => void;
|
|
63
63
|
};
|
|
@@ -9,6 +9,8 @@ declare type Extensions = (loader: THREE.Loader) => void;
|
|
|
9
9
|
declare type LoaderResult<T> = T extends any[] ? Loader<T[number]> : Loader<T>;
|
|
10
10
|
declare type ConditionalType<Child, Parent, Truthy, Falsy> = Child extends Parent ? Truthy : Falsy;
|
|
11
11
|
declare type BranchingReturn<T, Parent, Coerced> = ConditionalType<T, Parent, Coerced, T>;
|
|
12
|
+
declare type noop = (...args: any[]) => any;
|
|
13
|
+
declare type PickFunction<T extends noop> = (...args: Parameters<T>) => ReturnType<T>;
|
|
12
14
|
export declare type ObjectMap = {
|
|
13
15
|
nodes: {
|
|
14
16
|
[name: string]: THREE.Object3D;
|
|
@@ -17,10 +19,11 @@ export declare type ObjectMap = {
|
|
|
17
19
|
[name: string]: THREE.Material;
|
|
18
20
|
};
|
|
19
21
|
};
|
|
20
|
-
export declare function useStore(): import("zustand").
|
|
22
|
+
export declare function useStore(): import("zustand").UseBoundStore<RootState, import("zustand").StoreApi<RootState>>;
|
|
21
23
|
export declare function useThree<T = RootState>(selector?: StateSelector<RootState, T>, equalityFn?: EqualityChecker<T>): T;
|
|
22
24
|
export declare function useFrame(callback: RenderCallback, renderPriority?: number): null;
|
|
23
25
|
export declare function useGraph(object: THREE.Object3D): ObjectMap;
|
|
26
|
+
export declare function useMemoizedFn<T extends noop>(fn?: T): PickFunction<T>;
|
|
24
27
|
export declare function useLoader<T, U extends string | string[]>(Proto: new () => LoaderResult<T>, input: U, extensions?: Extensions, onProgress?: (event: ProgressEvent<EventTarget>) => void): U extends any[] ? BranchingReturn<T, GLTF, GLTF & ObjectMap>[] : BranchingReturn<T, GLTF, GLTF & ObjectMap>;
|
|
25
28
|
export declare namespace useLoader {
|
|
26
29
|
var preload: <T, U extends string | string[]>(Proto: new () => LoaderResult<T>, input: U, extensions?: Extensions | undefined) => undefined;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import * as THREE from 'three';
|
|
2
2
|
import Reconciler from 'react-reconciler';
|
|
3
|
-
import {
|
|
3
|
+
import { UseBoundStore } from 'zustand';
|
|
4
4
|
import { RootState } from './store';
|
|
5
5
|
import { EventHandlers } from './events';
|
|
6
6
|
export declare type Root = {
|
|
7
7
|
fiber: Reconciler.FiberRoot;
|
|
8
|
-
store:
|
|
8
|
+
store: UseBoundStore<RootState>;
|
|
9
9
|
};
|
|
10
10
|
export declare type LocalState = {
|
|
11
|
-
root:
|
|
11
|
+
root: UseBoundStore<RootState>;
|
|
12
12
|
objects: Instance[];
|
|
13
13
|
parent: Instance | null;
|
|
14
14
|
primitive?: boolean;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as THREE from 'three';
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import * as ReactThreeFiber from '../three-types';
|
|
4
|
-
import { GetState, SetState,
|
|
4
|
+
import { GetState, SetState, UseBoundStore } from 'zustand';
|
|
5
5
|
import { Instance, InstanceProps } from './renderer';
|
|
6
6
|
import { DomEvent, EventManager, PointerCaptureTarget, ThreeEvent } from './events';
|
|
7
7
|
export interface Intersection extends THREE.Intersection {
|
|
@@ -113,6 +113,6 @@ export declare type StoreProps = {
|
|
|
113
113
|
};
|
|
114
114
|
export declare type ApplyProps = (instance: Instance, newProps: InstanceProps) => void;
|
|
115
115
|
export declare function calculateDpr(dpr: Dpr): number;
|
|
116
|
-
declare const context: React.Context<
|
|
117
|
-
declare const createStore: (applyProps: ApplyProps, invalidate: (state?: RootState | undefined) => void, advance: (timestamp: number, runGlobalEffects?: boolean | undefined, state?: RootState | undefined) => void, props: StoreProps) =>
|
|
116
|
+
declare const context: React.Context<UseBoundStore<RootState, import("zustand").StoreApi<RootState>>>;
|
|
117
|
+
declare const createStore: (applyProps: ApplyProps, invalidate: (state?: RootState | undefined) => void, advance: (timestamp: number, runGlobalEffects?: boolean | undefined, state?: RootState | undefined) => void, props: StoreProps) => UseBoundStore<RootState>;
|
|
118
118
|
export { createStore, context };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export * from './three-types';
|
|
2
2
|
import * as ReactThreeFiber from './three-types';
|
|
3
3
|
export { ReactThreeFiber };
|
|
4
|
+
export type { BaseInstance, LocalState } from './core/renderer';
|
|
4
5
|
export type { Intersection, Subscription, Dpr, Size, Viewport, Camera, RenderCallback, Performance, RootState, } from './core/store';
|
|
5
6
|
export type { ThreeEvent, Events, EventManager } from './core/events';
|
|
6
7
|
export type { Props } from './web/Canvas';
|
|
@@ -44,6 +44,7 @@ export declare type Object3DNode<T, P> = Overwrite<Node<T, P>, {
|
|
|
44
44
|
export declare type BufferGeometryNode<T extends THREE.BufferGeometry, P> = Node<T, P>;
|
|
45
45
|
export declare type MaterialNode<T extends THREE.Material, P> = Node<T, P>;
|
|
46
46
|
export declare type LightNode<T extends THREE.Light, P> = Object3DNode<T, P>;
|
|
47
|
+
export declare type Object3DProps = Object3DNode<THREE.Object3D, typeof THREE.Object3D>;
|
|
47
48
|
export declare type AudioListenerProps = Object3DNode<THREE.AudioListener, typeof THREE.AudioListener>;
|
|
48
49
|
export declare type PositionalAudioProps = Object3DNode<THREE.PositionalAudio, typeof THREE.PositionalAudio>;
|
|
49
50
|
export declare type MeshProps = Object3DNode<THREE.Mesh, typeof THREE.Mesh>;
|
|
@@ -169,7 +170,15 @@ export declare type Matrix3Props = Node<THREE.Matrix3, typeof THREE.Matrix3>;
|
|
|
169
170
|
export declare type Matrix4Props = Node<THREE.Matrix4, typeof THREE.Matrix4>;
|
|
170
171
|
export declare type QuaternionProps = Node<THREE.Quaternion, typeof THREE.Quaternion>;
|
|
171
172
|
export declare type BufferAttributeProps = Node<THREE.BufferAttribute, typeof THREE.BufferAttribute>;
|
|
173
|
+
export declare type Float16BufferAttributeProps = Node<THREE.Float16BufferAttribute, typeof THREE.Float16BufferAttribute>;
|
|
172
174
|
export declare type Float32BufferAttributeProps = Node<THREE.Float32BufferAttribute, typeof THREE.Float32BufferAttribute>;
|
|
175
|
+
export declare type Float64BufferAttributeProps = Node<THREE.Float64BufferAttribute, typeof THREE.Float64BufferAttribute>;
|
|
176
|
+
export declare type Int8BufferAttributeProps = Node<THREE.Int8BufferAttribute, typeof THREE.Int8BufferAttribute>;
|
|
177
|
+
export declare type Int16BufferAttributeProps = Node<THREE.Int16BufferAttribute, typeof THREE.Int16BufferAttribute>;
|
|
178
|
+
export declare type Int32BufferAttributeProps = Node<THREE.Int32BufferAttribute, typeof THREE.Int32BufferAttribute>;
|
|
179
|
+
export declare type Uint8BufferAttributeProps = Node<THREE.Uint8BufferAttribute, typeof THREE.Uint8BufferAttribute>;
|
|
180
|
+
export declare type Uint16BufferAttributeProps = Node<THREE.Uint16BufferAttribute, typeof THREE.Uint16BufferAttribute>;
|
|
181
|
+
export declare type Uint32BufferAttributeProps = Node<THREE.Uint32BufferAttribute, typeof THREE.Uint32BufferAttribute>;
|
|
173
182
|
export declare type InstancedBufferAttributeProps = Node<THREE.InstancedBufferAttribute, typeof THREE.InstancedBufferAttribute>;
|
|
174
183
|
export declare type ColorProps = Node<THREE.Color, ColorArray>;
|
|
175
184
|
export declare type FogProps = Node<THREE.Fog, typeof THREE.Fog>;
|
|
@@ -178,6 +187,7 @@ export declare type ShapeProps = Node<THREE.Shape, typeof THREE.Shape>;
|
|
|
178
187
|
declare global {
|
|
179
188
|
namespace JSX {
|
|
180
189
|
interface IntrinsicElements {
|
|
190
|
+
object3D: Object3DProps;
|
|
181
191
|
audioListener: AudioListenerProps;
|
|
182
192
|
positionalAudio: PositionalAudioProps;
|
|
183
193
|
mesh: MeshProps;
|
|
@@ -299,7 +309,15 @@ declare global {
|
|
|
299
309
|
matrix4: Matrix4Props;
|
|
300
310
|
quaternion: QuaternionProps;
|
|
301
311
|
bufferAttribute: BufferAttributeProps;
|
|
312
|
+
float16BufferAttribute: Float16BufferAttributeProps;
|
|
302
313
|
float32BufferAttribute: Float32BufferAttributeProps;
|
|
314
|
+
float64BufferAttribute: Float64BufferAttributeProps;
|
|
315
|
+
int8BufferAttribute: Int8BufferAttributeProps;
|
|
316
|
+
int16BufferAttribute: Int16BufferAttributeProps;
|
|
317
|
+
int32BufferAttribute: Int32BufferAttributeProps;
|
|
318
|
+
uint8BufferAttribute: Uint8BufferAttributeProps;
|
|
319
|
+
uint16BufferAttribute: Uint16BufferAttributeProps;
|
|
320
|
+
uint32BufferAttribute: Uint32BufferAttributeProps;
|
|
303
321
|
instancedBufferAttribute: InstancedBufferAttributeProps;
|
|
304
322
|
color: ColorProps;
|
|
305
323
|
fog: FogProps;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { Options as ResizeOptions } from 'react-use-measure';
|
|
3
3
|
import { RenderProps } from './index';
|
|
4
|
-
import {
|
|
4
|
+
import { UseBoundStore } from 'zustand';
|
|
5
5
|
import { RootState } from '../core/store';
|
|
6
6
|
import { EventManager } from '../core/events';
|
|
7
7
|
export interface Props extends Omit<RenderProps<HTMLCanvasElement>, 'size' | 'events'>, React.HTMLAttributes<HTMLDivElement> {
|
|
8
8
|
children: React.ReactNode;
|
|
9
9
|
fallback?: React.ReactNode;
|
|
10
10
|
resize?: ResizeOptions;
|
|
11
|
-
events?: (store:
|
|
11
|
+
events?: (store: UseBoundStore<RootState>) => EventManager<any>;
|
|
12
12
|
}
|
|
13
13
|
export declare const Canvas: React.ForwardRefExoticComponent<Props & React.RefAttributes<HTMLCanvasElement>>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { UseBoundStore } from 'zustand';
|
|
2
2
|
import { RootState } from '../core/store';
|
|
3
3
|
import type { EventManager } from '../core/events';
|
|
4
|
-
export declare function createPointerEvents(store:
|
|
4
|
+
export declare function createPointerEvents(store: UseBoundStore<RootState>): EventManager<HTMLElement>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="react-reconciler" />
|
|
2
2
|
import * as THREE from 'three';
|
|
3
3
|
import * as React from 'react';
|
|
4
|
-
import {
|
|
4
|
+
import { UseBoundStore } from 'zustand';
|
|
5
5
|
import { Renderer, StoreProps, context, RootState, Size } from '../core/store';
|
|
6
6
|
import { extend, Root } from '../core/renderer';
|
|
7
7
|
import { addEffect, addAfterEffect, addTail } from '../core/loop';
|
|
@@ -11,19 +11,19 @@ import { EventManager } from '../core/events';
|
|
|
11
11
|
declare const roots: Map<Element, Root>;
|
|
12
12
|
declare const modes: readonly ["legacy", "blocking", "concurrent"];
|
|
13
13
|
declare const invalidate: (state?: RootState | undefined) => void, advance: (timestamp: number, runGlobalEffects?: boolean, state?: RootState | undefined) => void;
|
|
14
|
-
declare const reconciler: import("react-reconciler").Reconciler<unknown, unknown, unknown, unknown, unknown>, applyProps: (instance: import("../core/renderer").Instance, data: import("../core/renderer").
|
|
14
|
+
declare const reconciler: import("react-reconciler").Reconciler<unknown, unknown, unknown, unknown, unknown>, applyProps: (instance: import("../core/renderer").Instance, data: import("../core/renderer").DiffSet | import("../core/renderer").InstanceProps) => import("../core/renderer").Instance;
|
|
15
15
|
declare type Properties<T> = Pick<T, {
|
|
16
16
|
[K in keyof T]: T[K] extends (_: any) => any ? never : K;
|
|
17
17
|
}[keyof T]>;
|
|
18
18
|
declare type GLProps = Renderer | ((canvas: HTMLCanvasElement) => Renderer) | Partial<Properties<THREE.WebGLRenderer> | THREE.WebGLRendererParameters> | undefined;
|
|
19
19
|
export declare type RenderProps<TCanvas extends Element> = Omit<StoreProps, 'gl' | 'events' | 'size'> & {
|
|
20
20
|
gl?: GLProps;
|
|
21
|
-
events?: (store:
|
|
21
|
+
events?: (store: UseBoundStore<RootState>) => EventManager<TCanvas>;
|
|
22
22
|
size?: Size;
|
|
23
23
|
mode?: typeof modes[number];
|
|
24
24
|
onCreated?: (state: RootState) => void;
|
|
25
25
|
};
|
|
26
|
-
declare function render<TCanvas extends Element>(element: React.ReactNode, canvas: TCanvas, { gl, size, mode, events, onCreated, ...props }?: RenderProps<TCanvas>):
|
|
26
|
+
declare function render<TCanvas extends Element>(element: React.ReactNode, canvas: TCanvas, { gl, size, mode, events, onCreated, ...props }?: RenderProps<TCanvas>): UseBoundStore<RootState>;
|
|
27
27
|
declare function unmountComponentAtNode<TElement extends Element>(canvas: TElement, callback?: (canvas: TElement) => void): void;
|
|
28
28
|
declare function dispose<TObj extends {
|
|
29
29
|
dispose?: () => void;
|
|
@@ -22,14 +22,12 @@ function _interopNamespace(e) {
|
|
|
22
22
|
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
23
23
|
Object.defineProperty(n, k, d.get ? d : {
|
|
24
24
|
enumerable: true,
|
|
25
|
-
get: function () {
|
|
26
|
-
return e[k];
|
|
27
|
-
}
|
|
25
|
+
get: function () { return e[k]; }
|
|
28
26
|
});
|
|
29
27
|
}
|
|
30
28
|
});
|
|
31
29
|
}
|
|
32
|
-
n[
|
|
30
|
+
n["default"] = e;
|
|
33
31
|
return Object.freeze(n);
|
|
34
32
|
}
|
|
35
33
|
|
|
@@ -626,29 +624,29 @@ function createRenderer(roots) {
|
|
|
626
624
|
localState.eventCount = Object.keys(localState.handlers).length;
|
|
627
625
|
} // Special treatment for objects with support for set/copy, and layers
|
|
628
626
|
else if (targetProp && targetProp.set && (targetProp.copy || targetProp instanceof THREE__namespace.Layers)) {
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
// https://github.com/pmndrs/react-three-fiber/issues/344
|
|
642
|
-
|
|
643
|
-
if (!isLinear && isColor) targetProp.convertSRGBToLinear();
|
|
644
|
-
} // Else, just overwrite the value
|
|
645
|
-
|
|
646
|
-
} else {
|
|
647
|
-
currentInstance[key] = value; // Auto-convert sRGB textures, for now ...
|
|
627
|
+
// If value is an array
|
|
628
|
+
if (Array.isArray(value)) {
|
|
629
|
+
if (targetProp.fromArray) targetProp.fromArray(value);else targetProp.set(...value);
|
|
630
|
+
} // Test again target.copy(class) next ...
|
|
631
|
+
else if (targetProp.copy && value && value.constructor && targetProp.constructor.name === value.constructor.name) targetProp.copy(value); // If nothing else fits, just set the single value, ignore undefined
|
|
632
|
+
// https://github.com/pmndrs/react-three-fiber/issues/274
|
|
633
|
+
else if (value !== undefined) {
|
|
634
|
+
const isColor = targetProp instanceof THREE__namespace.Color; // Allow setting array scalars
|
|
635
|
+
|
|
636
|
+
if (!isColor && targetProp.setScalar) targetProp.setScalar(value); // Layers have no copy function, we must therefore copy the mask property
|
|
637
|
+
else if (targetProp instanceof THREE__namespace.Layers && value instanceof THREE__namespace.Layers) targetProp.mask = value.mask; // Otherwise just set ...
|
|
638
|
+
else targetProp.set(value); // Auto-convert sRGB colors, for now ...
|
|
648
639
|
// https://github.com/pmndrs/react-three-fiber/issues/344
|
|
649
640
|
|
|
650
|
-
if (!isLinear &&
|
|
651
|
-
}
|
|
641
|
+
if (!isLinear && isColor) targetProp.convertSRGBToLinear();
|
|
642
|
+
} // Else, just overwrite the value
|
|
643
|
+
|
|
644
|
+
} else {
|
|
645
|
+
currentInstance[key] = value; // Auto-convert sRGB textures, for now ...
|
|
646
|
+
// https://github.com/pmndrs/react-three-fiber/issues/344
|
|
647
|
+
|
|
648
|
+
if (!isLinear && currentInstance[key] instanceof THREE__namespace.Texture) currentInstance[key].encoding = THREE__namespace.sRGBEncoding;
|
|
649
|
+
}
|
|
652
650
|
|
|
653
651
|
invalidateInstance(instance);
|
|
654
652
|
});
|
|
@@ -789,8 +787,13 @@ function createRenderer(roots) {
|
|
|
789
787
|
|
|
790
788
|
if (child) {
|
|
791
789
|
if (child.attachArray) {
|
|
792
|
-
|
|
793
|
-
|
|
790
|
+
let array = parentInstance[child.attachArray];
|
|
791
|
+
|
|
792
|
+
if (!is.arr(array)) {
|
|
793
|
+
parentInstance[child.attachArray] = [];
|
|
794
|
+
array = parentInstance[child.attachArray];
|
|
795
|
+
}
|
|
796
|
+
|
|
794
797
|
array.splice(array.indexOf(beforeChild), 0, child);
|
|
795
798
|
} else if (child.attachObject || child.attach && !is.fun(child.attach)) {
|
|
796
799
|
// attach and attachObject don't have an order anyway, so just append
|
|
@@ -942,7 +945,7 @@ function createRenderer(roots) {
|
|
|
942
945
|
});
|
|
943
946
|
}
|
|
944
947
|
|
|
945
|
-
const reconciler = Reconciler__default[
|
|
948
|
+
const reconciler = Reconciler__default["default"]({
|
|
946
949
|
now: scheduler.unstable_now,
|
|
947
950
|
createInstance,
|
|
948
951
|
removeChild,
|
|
@@ -1056,9 +1059,7 @@ function createRenderer(roots) {
|
|
|
1056
1059
|
return !!localState.handlers;
|
|
1057
1060
|
},
|
|
1058
1061
|
|
|
1059
|
-
commitMount(instance)
|
|
1060
|
-
/*, type, props*/
|
|
1061
|
-
{
|
|
1062
|
+
commitMount(instance) {
|
|
1062
1063
|
var _instance$__r3f8;
|
|
1063
1064
|
|
|
1064
1065
|
// https://github.com/facebook/react/issues/20271
|
|
@@ -1136,7 +1137,7 @@ const createStore = (applyProps, invalidate, advance, props) => {
|
|
|
1136
1137
|
clock.elapsedTime = 0;
|
|
1137
1138
|
}
|
|
1138
1139
|
|
|
1139
|
-
const rootState = create__default[
|
|
1140
|
+
const rootState = create__default["default"]((set, get) => {
|
|
1140
1141
|
// Create custom raycaster
|
|
1141
1142
|
const raycaster = new THREE__namespace.Raycaster();
|
|
1142
1143
|
const {
|
|
@@ -1570,10 +1571,11 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(function Canvas({
|
|
|
1570
1571
|
events,
|
|
1571
1572
|
...props
|
|
1572
1573
|
}, forwardedRef) {
|
|
1574
|
+
const onPointerMissed = useMemoizedFn(props.onPointerMissed);
|
|
1573
1575
|
const [containerRef, {
|
|
1574
1576
|
width,
|
|
1575
1577
|
height
|
|
1576
|
-
}] = useMeasure__default[
|
|
1578
|
+
}] = useMeasure__default["default"]({
|
|
1577
1579
|
scroll: true,
|
|
1578
1580
|
debounce: {
|
|
1579
1581
|
scroll: 50,
|
|
@@ -1602,10 +1604,11 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(function Canvas({
|
|
|
1602
1604
|
width,
|
|
1603
1605
|
height
|
|
1604
1606
|
},
|
|
1607
|
+
onPointerMissed,
|
|
1605
1608
|
events: events || createPointerEvents
|
|
1606
1609
|
});
|
|
1607
1610
|
}
|
|
1608
|
-
}, [width, height, children]);
|
|
1611
|
+
}, [width, height, children, onPointerMissed]);
|
|
1609
1612
|
useIsomorphicLayoutEffect(() => {
|
|
1610
1613
|
const container = canvasRef.current;
|
|
1611
1614
|
return () => unmountComponentAtNode(container);
|
|
@@ -1623,7 +1626,7 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(function Canvas({
|
|
|
1623
1626
|
...style
|
|
1624
1627
|
}
|
|
1625
1628
|
}, /*#__PURE__*/React__namespace.createElement("canvas", {
|
|
1626
|
-
ref: mergeRefs__default[
|
|
1629
|
+
ref: mergeRefs__default["default"]([canvasRef, forwardedRef]),
|
|
1627
1630
|
style: {
|
|
1628
1631
|
display: 'block'
|
|
1629
1632
|
}
|
|
@@ -1686,6 +1689,11 @@ function loadingFn(extensions, onProgress) {
|
|
|
1686
1689
|
};
|
|
1687
1690
|
}
|
|
1688
1691
|
|
|
1692
|
+
function useMemoizedFn(fn) {
|
|
1693
|
+
const fnRef = React__namespace.useRef(fn);
|
|
1694
|
+
React__namespace.useLayoutEffect(() => void (fnRef.current = fn), [fn]);
|
|
1695
|
+
return (...args) => fnRef.current == null ? void 0 : fnRef.current(...args);
|
|
1696
|
+
}
|
|
1689
1697
|
function useLoader(Proto, input, extensions, onProgress) {
|
|
1690
1698
|
// Use suspense to load async assets
|
|
1691
1699
|
const keys = Array.isArray(input) ? input : [input];
|
|
@@ -1871,8 +1879,7 @@ function dispose(obj) {
|
|
|
1871
1879
|
if (obj.dispose && obj.type !== 'Scene') obj.dispose();
|
|
1872
1880
|
|
|
1873
1881
|
for (const p in obj) {
|
|
1874
|
-
|
|
1875
|
-
(_dispose = (_ref = p).dispose) == null ? void 0 : _dispose.call(_ref);
|
|
1882
|
+
p.dispose == null ? void 0 : p.dispose();
|
|
1876
1883
|
delete obj[p];
|
|
1877
1884
|
}
|
|
1878
1885
|
}
|
|
@@ -1910,5 +1917,6 @@ exports.unmountComponentAtNode = unmountComponentAtNode;
|
|
|
1910
1917
|
exports.useFrame = useFrame;
|
|
1911
1918
|
exports.useGraph = useGraph;
|
|
1912
1919
|
exports.useLoader = useLoader;
|
|
1920
|
+
exports.useMemoizedFn = useMemoizedFn;
|
|
1913
1921
|
exports.useStore = useStore;
|
|
1914
1922
|
exports.useThree = useThree;
|
|
@@ -22,14 +22,12 @@ function _interopNamespace(e) {
|
|
|
22
22
|
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
23
23
|
Object.defineProperty(n, k, d.get ? d : {
|
|
24
24
|
enumerable: true,
|
|
25
|
-
get: function () {
|
|
26
|
-
return e[k];
|
|
27
|
-
}
|
|
25
|
+
get: function () { return e[k]; }
|
|
28
26
|
});
|
|
29
27
|
}
|
|
30
28
|
});
|
|
31
29
|
}
|
|
32
|
-
n[
|
|
30
|
+
n["default"] = e;
|
|
33
31
|
return Object.freeze(n);
|
|
34
32
|
}
|
|
35
33
|
|
|
@@ -626,29 +624,29 @@ function createRenderer(roots) {
|
|
|
626
624
|
localState.eventCount = Object.keys(localState.handlers).length;
|
|
627
625
|
} // Special treatment for objects with support for set/copy, and layers
|
|
628
626
|
else if (targetProp && targetProp.set && (targetProp.copy || targetProp instanceof THREE__namespace.Layers)) {
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
// https://github.com/pmndrs/react-three-fiber/issues/344
|
|
642
|
-
|
|
643
|
-
if (!isLinear && isColor) targetProp.convertSRGBToLinear();
|
|
644
|
-
} // Else, just overwrite the value
|
|
645
|
-
|
|
646
|
-
} else {
|
|
647
|
-
currentInstance[key] = value; // Auto-convert sRGB textures, for now ...
|
|
627
|
+
// If value is an array
|
|
628
|
+
if (Array.isArray(value)) {
|
|
629
|
+
if (targetProp.fromArray) targetProp.fromArray(value);else targetProp.set(...value);
|
|
630
|
+
} // Test again target.copy(class) next ...
|
|
631
|
+
else if (targetProp.copy && value && value.constructor && targetProp.constructor.name === value.constructor.name) targetProp.copy(value); // If nothing else fits, just set the single value, ignore undefined
|
|
632
|
+
// https://github.com/pmndrs/react-three-fiber/issues/274
|
|
633
|
+
else if (value !== undefined) {
|
|
634
|
+
const isColor = targetProp instanceof THREE__namespace.Color; // Allow setting array scalars
|
|
635
|
+
|
|
636
|
+
if (!isColor && targetProp.setScalar) targetProp.setScalar(value); // Layers have no copy function, we must therefore copy the mask property
|
|
637
|
+
else if (targetProp instanceof THREE__namespace.Layers && value instanceof THREE__namespace.Layers) targetProp.mask = value.mask; // Otherwise just set ...
|
|
638
|
+
else targetProp.set(value); // Auto-convert sRGB colors, for now ...
|
|
648
639
|
// https://github.com/pmndrs/react-three-fiber/issues/344
|
|
649
640
|
|
|
650
|
-
if (!isLinear &&
|
|
651
|
-
}
|
|
641
|
+
if (!isLinear && isColor) targetProp.convertSRGBToLinear();
|
|
642
|
+
} // Else, just overwrite the value
|
|
643
|
+
|
|
644
|
+
} else {
|
|
645
|
+
currentInstance[key] = value; // Auto-convert sRGB textures, for now ...
|
|
646
|
+
// https://github.com/pmndrs/react-three-fiber/issues/344
|
|
647
|
+
|
|
648
|
+
if (!isLinear && currentInstance[key] instanceof THREE__namespace.Texture) currentInstance[key].encoding = THREE__namespace.sRGBEncoding;
|
|
649
|
+
}
|
|
652
650
|
|
|
653
651
|
invalidateInstance(instance);
|
|
654
652
|
});
|
|
@@ -789,8 +787,13 @@ function createRenderer(roots) {
|
|
|
789
787
|
|
|
790
788
|
if (child) {
|
|
791
789
|
if (child.attachArray) {
|
|
792
|
-
|
|
793
|
-
|
|
790
|
+
let array = parentInstance[child.attachArray];
|
|
791
|
+
|
|
792
|
+
if (!is.arr(array)) {
|
|
793
|
+
parentInstance[child.attachArray] = [];
|
|
794
|
+
array = parentInstance[child.attachArray];
|
|
795
|
+
}
|
|
796
|
+
|
|
794
797
|
array.splice(array.indexOf(beforeChild), 0, child);
|
|
795
798
|
} else if (child.attachObject || child.attach && !is.fun(child.attach)) {
|
|
796
799
|
// attach and attachObject don't have an order anyway, so just append
|
|
@@ -942,7 +945,7 @@ function createRenderer(roots) {
|
|
|
942
945
|
});
|
|
943
946
|
}
|
|
944
947
|
|
|
945
|
-
const reconciler = Reconciler__default[
|
|
948
|
+
const reconciler = Reconciler__default["default"]({
|
|
946
949
|
now: scheduler.unstable_now,
|
|
947
950
|
createInstance,
|
|
948
951
|
removeChild,
|
|
@@ -1056,9 +1059,7 @@ function createRenderer(roots) {
|
|
|
1056
1059
|
return !!localState.handlers;
|
|
1057
1060
|
},
|
|
1058
1061
|
|
|
1059
|
-
commitMount(instance)
|
|
1060
|
-
/*, type, props*/
|
|
1061
|
-
{
|
|
1062
|
+
commitMount(instance) {
|
|
1062
1063
|
var _instance$__r3f8;
|
|
1063
1064
|
|
|
1064
1065
|
// https://github.com/facebook/react/issues/20271
|
|
@@ -1136,7 +1137,7 @@ const createStore = (applyProps, invalidate, advance, props) => {
|
|
|
1136
1137
|
clock.elapsedTime = 0;
|
|
1137
1138
|
}
|
|
1138
1139
|
|
|
1139
|
-
const rootState = create__default[
|
|
1140
|
+
const rootState = create__default["default"]((set, get) => {
|
|
1140
1141
|
// Create custom raycaster
|
|
1141
1142
|
const raycaster = new THREE__namespace.Raycaster();
|
|
1142
1143
|
const {
|
|
@@ -1570,10 +1571,11 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(function Canvas({
|
|
|
1570
1571
|
events,
|
|
1571
1572
|
...props
|
|
1572
1573
|
}, forwardedRef) {
|
|
1574
|
+
const onPointerMissed = useMemoizedFn(props.onPointerMissed);
|
|
1573
1575
|
const [containerRef, {
|
|
1574
1576
|
width,
|
|
1575
1577
|
height
|
|
1576
|
-
}] = useMeasure__default[
|
|
1578
|
+
}] = useMeasure__default["default"]({
|
|
1577
1579
|
scroll: true,
|
|
1578
1580
|
debounce: {
|
|
1579
1581
|
scroll: 50,
|
|
@@ -1602,10 +1604,11 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(function Canvas({
|
|
|
1602
1604
|
width,
|
|
1603
1605
|
height
|
|
1604
1606
|
},
|
|
1607
|
+
onPointerMissed,
|
|
1605
1608
|
events: events || createPointerEvents
|
|
1606
1609
|
});
|
|
1607
1610
|
}
|
|
1608
|
-
}, [width, height, children]);
|
|
1611
|
+
}, [width, height, children, onPointerMissed]);
|
|
1609
1612
|
useIsomorphicLayoutEffect(() => {
|
|
1610
1613
|
const container = canvasRef.current;
|
|
1611
1614
|
return () => unmountComponentAtNode(container);
|
|
@@ -1623,7 +1626,7 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(function Canvas({
|
|
|
1623
1626
|
...style
|
|
1624
1627
|
}
|
|
1625
1628
|
}, /*#__PURE__*/React__namespace.createElement("canvas", {
|
|
1626
|
-
ref: mergeRefs__default[
|
|
1629
|
+
ref: mergeRefs__default["default"]([canvasRef, forwardedRef]),
|
|
1627
1630
|
style: {
|
|
1628
1631
|
display: 'block'
|
|
1629
1632
|
}
|
|
@@ -1686,6 +1689,11 @@ function loadingFn(extensions, onProgress) {
|
|
|
1686
1689
|
};
|
|
1687
1690
|
}
|
|
1688
1691
|
|
|
1692
|
+
function useMemoizedFn(fn) {
|
|
1693
|
+
const fnRef = React__namespace.useRef(fn);
|
|
1694
|
+
React__namespace.useLayoutEffect(() => void (fnRef.current = fn), [fn]);
|
|
1695
|
+
return (...args) => fnRef.current == null ? void 0 : fnRef.current(...args);
|
|
1696
|
+
}
|
|
1689
1697
|
function useLoader(Proto, input, extensions, onProgress) {
|
|
1690
1698
|
// Use suspense to load async assets
|
|
1691
1699
|
const keys = Array.isArray(input) ? input : [input];
|
|
@@ -1871,8 +1879,7 @@ function dispose(obj) {
|
|
|
1871
1879
|
if (obj.dispose && obj.type !== 'Scene') obj.dispose();
|
|
1872
1880
|
|
|
1873
1881
|
for (const p in obj) {
|
|
1874
|
-
|
|
1875
|
-
(_dispose = (_ref = p).dispose) == null ? void 0 : _dispose.call(_ref);
|
|
1882
|
+
p.dispose == null ? void 0 : p.dispose();
|
|
1876
1883
|
delete obj[p];
|
|
1877
1884
|
}
|
|
1878
1885
|
}
|
|
@@ -1910,5 +1917,6 @@ exports.unmountComponentAtNode = unmountComponentAtNode;
|
|
|
1910
1917
|
exports.useFrame = useFrame;
|
|
1911
1918
|
exports.useGraph = useGraph;
|
|
1912
1919
|
exports.useLoader = useLoader;
|
|
1920
|
+
exports.useMemoizedFn = useMemoizedFn;
|
|
1913
1921
|
exports.useStore = useStore;
|
|
1914
1922
|
exports.useThree = useThree;
|