@react-three/fiber 8.15.12 → 8.15.14
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 +919 -907
- package/dist/declarations/src/core/events.d.ts +93 -93
- package/dist/declarations/src/core/hooks.d.ts +57 -57
- package/dist/declarations/src/core/index.d.ts +87 -87
- package/dist/declarations/src/core/loop.d.ts +33 -33
- package/dist/declarations/src/core/renderer.d.ts +58 -58
- package/dist/declarations/src/core/store.d.ts +137 -137
- package/dist/declarations/src/core/utils.d.ts +130 -125
- package/dist/declarations/src/index.d.ts +12 -12
- package/dist/declarations/src/native/Canvas.d.ts +14 -14
- package/dist/declarations/src/native/events.d.ts +5 -5
- package/dist/declarations/src/native/polyfills.d.ts +1 -1
- package/dist/declarations/src/native.d.ts +12 -12
- package/dist/declarations/src/three-types.d.ts +392 -392
- package/dist/declarations/src/web/Canvas.d.ts +24 -24
- package/dist/declarations/src/web/events.d.ts +5 -5
- package/dist/{index-5bde93f1.esm.js → index-29b7121b.esm.js} +97 -85
- package/dist/{index-e9909912.cjs.dev.js → index-54c0bb16.cjs.dev.js} +97 -85
- package/dist/{index-710e63a4.cjs.prod.js → index-8eb7ac4a.cjs.prod.js} +97 -85
- package/dist/react-three-fiber.cjs.dev.js +4 -4
- package/dist/react-three-fiber.cjs.prod.js +4 -4
- package/dist/react-three-fiber.esm.js +5 -5
- package/native/dist/react-three-fiber-native.cjs.dev.js +15 -9
- package/native/dist/react-three-fiber-native.cjs.prod.js +15 -9
- package/native/dist/react-three-fiber-native.esm.js +16 -10
- package/native/package.json +5 -5
- package/package.json +1 -1
- package/readme.md +253 -253
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import type { Options as ResizeOptions } from 'react-use-measure';
|
|
3
|
-
import { RenderProps } from '../core';
|
|
4
|
-
export interface CanvasProps extends Omit<RenderProps<HTMLCanvasElement>, 'size'>, React.HTMLAttributes<HTMLDivElement> {
|
|
5
|
-
children: React.ReactNode;
|
|
6
|
-
/** Canvas fallback content, similar to img's alt prop */
|
|
7
|
-
fallback?: React.ReactNode;
|
|
8
|
-
/**
|
|
9
|
-
* Options to pass to useMeasure.
|
|
10
|
-
* @see https://github.com/pmndrs/react-use-measure#api
|
|
11
|
-
*/
|
|
12
|
-
resize?: ResizeOptions;
|
|
13
|
-
/** The target where events are being subscribed to, default: the div that wraps canvas */
|
|
14
|
-
eventSource?: HTMLElement | React.MutableRefObject<HTMLElement>;
|
|
15
|
-
/** The event prefix that is cast into canvas pointer x/y events, default: "offset" */
|
|
16
|
-
eventPrefix?: 'offset' | 'client' | 'page' | 'layer' | 'screen';
|
|
17
|
-
}
|
|
18
|
-
export interface Props extends CanvasProps {
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* A DOM canvas which accepts threejs elements as children.
|
|
22
|
-
* @see https://docs.pmnd.rs/react-three-fiber/api/canvas
|
|
23
|
-
*/
|
|
24
|
-
export declare const Canvas: React.ForwardRefExoticComponent<Props & React.RefAttributes<HTMLCanvasElement>>;
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { Options as ResizeOptions } from 'react-use-measure';
|
|
3
|
+
import { RenderProps } from '../core';
|
|
4
|
+
export interface CanvasProps extends Omit<RenderProps<HTMLCanvasElement>, 'size'>, React.HTMLAttributes<HTMLDivElement> {
|
|
5
|
+
children: React.ReactNode;
|
|
6
|
+
/** Canvas fallback content, similar to img's alt prop */
|
|
7
|
+
fallback?: React.ReactNode;
|
|
8
|
+
/**
|
|
9
|
+
* Options to pass to useMeasure.
|
|
10
|
+
* @see https://github.com/pmndrs/react-use-measure#api
|
|
11
|
+
*/
|
|
12
|
+
resize?: ResizeOptions;
|
|
13
|
+
/** The target where events are being subscribed to, default: the div that wraps canvas */
|
|
14
|
+
eventSource?: HTMLElement | React.MutableRefObject<HTMLElement>;
|
|
15
|
+
/** The event prefix that is cast into canvas pointer x/y events, default: "offset" */
|
|
16
|
+
eventPrefix?: 'offset' | 'client' | 'page' | 'layer' | 'screen';
|
|
17
|
+
}
|
|
18
|
+
export interface Props extends CanvasProps {
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* A DOM canvas which accepts threejs elements as children.
|
|
22
|
+
* @see https://docs.pmnd.rs/react-three-fiber/api/canvas
|
|
23
|
+
*/
|
|
24
|
+
export declare const Canvas: React.ForwardRefExoticComponent<Props & React.RefAttributes<HTMLCanvasElement>>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { UseBoundStore } from 'zustand';
|
|
2
|
-
import { RootState } from '../core/store';
|
|
3
|
-
import { EventManager } from '../core/events';
|
|
4
|
-
/** Default R3F event manager for web */
|
|
5
|
-
export declare function createPointerEvents(store: UseBoundStore<RootState>): EventManager<HTMLElement>;
|
|
1
|
+
import { UseBoundStore } from 'zustand';
|
|
2
|
+
import { RootState } from '../core/store';
|
|
3
|
+
import { EventManager } from '../core/events';
|
|
4
|
+
/** Default R3F event manager for web */
|
|
5
|
+
export declare function createPointerEvents(store: UseBoundStore<RootState>): EventManager<HTMLElement>;
|
|
@@ -123,9 +123,10 @@ function createRenderer(_roots, _getEventPriority) {
|
|
|
123
123
|
} else if (child.isObject3D && parentInstance.isObject3D) {
|
|
124
124
|
var _child$__r3f4;
|
|
125
125
|
parentInstance.remove(child);
|
|
126
|
-
//
|
|
126
|
+
// @ts-ignore
|
|
127
|
+
// Remove interactivity on the initial root
|
|
127
128
|
if ((_child$__r3f4 = child.__r3f) != null && _child$__r3f4.root) {
|
|
128
|
-
removeInteractivity(child
|
|
129
|
+
removeInteractivity(findInitialRoot(child), child);
|
|
129
130
|
}
|
|
130
131
|
}
|
|
131
132
|
|
|
@@ -197,9 +198,9 @@ function createRenderer(_roots, _getEventPriority) {
|
|
|
197
198
|
}
|
|
198
199
|
appendChild(parent, newInstance);
|
|
199
200
|
|
|
200
|
-
// Re-bind event handlers
|
|
201
|
+
// Re-bind event handlers on the initial root
|
|
201
202
|
if (newInstance.raycast && newInstance.__r3f.eventCount) {
|
|
202
|
-
const rootState = newInstance.
|
|
203
|
+
const rootState = findInitialRoot(newInstance).getState();
|
|
203
204
|
rootState.internal.interaction.push(newInstance);
|
|
204
205
|
}
|
|
205
206
|
[fiber, fiber.alternate].forEach(fiber => {
|
|
@@ -299,10 +300,10 @@ function createRenderer(_roots, _getEventPriority) {
|
|
|
299
300
|
commitMount(instance, _type, _props, _int) {
|
|
300
301
|
var _instance$__r3f4;
|
|
301
302
|
// https://github.com/facebook/react/issues/20271
|
|
302
|
-
// This will make sure events are only added once to the central container
|
|
303
|
+
// This will make sure events are only added once to the central container on the initial root
|
|
303
304
|
const localState = (_instance$__r3f4 = instance.__r3f) != null ? _instance$__r3f4 : {};
|
|
304
305
|
if (instance.raycast && localState.handlers && localState.eventCount) {
|
|
305
|
-
instance.
|
|
306
|
+
findInitialRoot(instance).getState().internal.interaction.push(instance);
|
|
306
307
|
}
|
|
307
308
|
},
|
|
308
309
|
getPublicInstance: instance => instance,
|
|
@@ -354,12 +355,12 @@ function createRenderer(_roots, _getEventPriority) {
|
|
|
354
355
|
}
|
|
355
356
|
|
|
356
357
|
var _window$document, _window$navigator;
|
|
357
|
-
/**
|
|
358
|
-
* Returns `true` with correct TS type inference if an object has a configurable color space (since r152).
|
|
358
|
+
/**
|
|
359
|
+
* Returns `true` with correct TS type inference if an object has a configurable color space (since r152).
|
|
359
360
|
*/
|
|
360
361
|
const hasColorSpace = object => 'colorSpace' in object || 'outputColorSpace' in object;
|
|
361
|
-
/**
|
|
362
|
-
* The current THREE.ColorManagement instance, if present.
|
|
362
|
+
/**
|
|
363
|
+
* The current THREE.ColorManagement instance, if present.
|
|
363
364
|
*/
|
|
364
365
|
const getColorManagement = () => {
|
|
365
366
|
var _ColorManagement;
|
|
@@ -368,14 +369,14 @@ const getColorManagement = () => {
|
|
|
368
369
|
const isOrthographicCamera = def => def && def.isOrthographicCamera;
|
|
369
370
|
const isRef = obj => obj && obj.hasOwnProperty('current');
|
|
370
371
|
|
|
371
|
-
/**
|
|
372
|
-
* An SSR-friendly useLayoutEffect.
|
|
373
|
-
*
|
|
374
|
-
* React currently throws a warning when using useLayoutEffect on the server.
|
|
375
|
-
* To get around it, we can conditionally useEffect on the server (no-op) and
|
|
376
|
-
* useLayoutEffect elsewhere.
|
|
377
|
-
*
|
|
378
|
-
* @see https://github.com/facebook/react/issues/14927
|
|
372
|
+
/**
|
|
373
|
+
* An SSR-friendly useLayoutEffect.
|
|
374
|
+
*
|
|
375
|
+
* React currently throws a warning when using useLayoutEffect on the server.
|
|
376
|
+
* To get around it, we can conditionally useEffect on the server (no-op) and
|
|
377
|
+
* useLayoutEffect elsewhere.
|
|
378
|
+
*
|
|
379
|
+
* @see https://github.com/facebook/react/issues/14927
|
|
379
380
|
*/
|
|
380
381
|
const useIsomorphicLayoutEffect = typeof window !== 'undefined' && ((_window$document = window.document) != null && _window$document.createElement || ((_window$navigator = window.navigator) == null ? void 0 : _window$navigator.product) === 'ReactNative') ? React.useLayoutEffect : React.useEffect;
|
|
381
382
|
function useMutableCallback(fn) {
|
|
@@ -420,13 +421,22 @@ function calculateDpr(dpr) {
|
|
|
420
421
|
return Array.isArray(dpr) ? Math.min(Math.max(dpr[0], target), dpr[1]) : dpr;
|
|
421
422
|
}
|
|
422
423
|
|
|
423
|
-
/**
|
|
424
|
-
* Returns instance root state
|
|
424
|
+
/**
|
|
425
|
+
* Returns instance root state
|
|
425
426
|
*/
|
|
426
427
|
const getRootState = obj => {
|
|
427
428
|
var _r3f;
|
|
428
429
|
return (_r3f = obj.__r3f) == null ? void 0 : _r3f.root.getState();
|
|
429
430
|
};
|
|
431
|
+
|
|
432
|
+
/**
|
|
433
|
+
* Returns the instances initial (outmost) root
|
|
434
|
+
*/
|
|
435
|
+
function findInitialRoot(child) {
|
|
436
|
+
let root = child.__r3f.root;
|
|
437
|
+
while (root.getState().previousRoot) root = root.getState().previousRoot;
|
|
438
|
+
return root;
|
|
439
|
+
}
|
|
430
440
|
// A collection of compare functions
|
|
431
441
|
const is = {
|
|
432
442
|
obj: a => a === Object(a) && !is.arr(a) && typeof a !== 'function',
|
|
@@ -477,8 +487,8 @@ const is = {
|
|
|
477
487
|
}
|
|
478
488
|
};
|
|
479
489
|
|
|
480
|
-
/**
|
|
481
|
-
* Collects nodes and materials from a THREE.Object3D.
|
|
490
|
+
/**
|
|
491
|
+
* Collects nodes and materials from a THREE.Object3D.
|
|
482
492
|
*/
|
|
483
493
|
function buildGraph(object) {
|
|
484
494
|
const data = {
|
|
@@ -744,12 +754,14 @@ function applyProps$1(instance, data) {
|
|
|
744
754
|
}
|
|
745
755
|
invalidateInstance(instance);
|
|
746
756
|
}
|
|
747
|
-
if (localState.parent &&
|
|
757
|
+
if (localState.parent && instance.raycast && prevHandlers !== localState.eventCount) {
|
|
758
|
+
// Get the initial root state's internals
|
|
759
|
+
const internal = findInitialRoot(instance).getState().internal;
|
|
748
760
|
// Pre-emptively remove the instance from the interaction manager
|
|
749
|
-
const index =
|
|
750
|
-
if (index > -1)
|
|
761
|
+
const index = internal.interaction.indexOf(instance);
|
|
762
|
+
if (index > -1) internal.interaction.splice(index, 1);
|
|
751
763
|
// Add the instance to the interaction manager only when it has handlers
|
|
752
|
-
if (localState.eventCount)
|
|
764
|
+
if (localState.eventCount) internal.interaction.push(instance);
|
|
753
765
|
}
|
|
754
766
|
|
|
755
767
|
// Call the update lifecycle when it is being updated, but only when it is part of the scene.
|
|
@@ -818,9 +830,9 @@ function getEventPriority() {
|
|
|
818
830
|
}
|
|
819
831
|
}
|
|
820
832
|
|
|
821
|
-
/**
|
|
822
|
-
* Release pointer captures.
|
|
823
|
-
* This is called by releasePointerCapture in the API, and when an object is removed.
|
|
833
|
+
/**
|
|
834
|
+
* Release pointer captures.
|
|
835
|
+
* This is called by releasePointerCapture in the API, and when an object is removed.
|
|
824
836
|
*/
|
|
825
837
|
function releaseInternalPointerCapture(capturedMap, obj, captures, pointerId) {
|
|
826
838
|
const captureData = captures.get(obj);
|
|
@@ -1155,19 +1167,19 @@ function createEvents(store) {
|
|
|
1155
1167
|
// Check presence of handlers
|
|
1156
1168
|
if (!(instance != null && instance.eventCount)) return;
|
|
1157
1169
|
|
|
1158
|
-
/*
|
|
1159
|
-
MAYBE TODO, DELETE IF NOT:
|
|
1160
|
-
Check if the object is captured, captured events should not have intersects running in parallel
|
|
1161
|
-
But wouldn't it be better to just replace capturedMap with a single entry?
|
|
1162
|
-
Also, are we OK with straight up making picking up multiple objects impossible?
|
|
1163
|
-
|
|
1164
|
-
const pointerId = (data as ThreeEvent<PointerEvent>).pointerId
|
|
1165
|
-
if (pointerId !== undefined) {
|
|
1166
|
-
const capturedMeshSet = internal.capturedMap.get(pointerId)
|
|
1167
|
-
if (capturedMeshSet) {
|
|
1168
|
-
const captured = capturedMeshSet.get(eventObject)
|
|
1169
|
-
if (captured && captured.localState.stopped) return
|
|
1170
|
-
}
|
|
1170
|
+
/*
|
|
1171
|
+
MAYBE TODO, DELETE IF NOT:
|
|
1172
|
+
Check if the object is captured, captured events should not have intersects running in parallel
|
|
1173
|
+
But wouldn't it be better to just replace capturedMap with a single entry?
|
|
1174
|
+
Also, are we OK with straight up making picking up multiple objects impossible?
|
|
1175
|
+
|
|
1176
|
+
const pointerId = (data as ThreeEvent<PointerEvent>).pointerId
|
|
1177
|
+
if (pointerId !== undefined) {
|
|
1178
|
+
const capturedMeshSet = internal.capturedMap.get(pointerId)
|
|
1179
|
+
if (capturedMeshSet) {
|
|
1180
|
+
const captured = capturedMeshSet.get(eventObject)
|
|
1181
|
+
if (captured && captured.localState.stopped) return
|
|
1182
|
+
}
|
|
1171
1183
|
}*/
|
|
1172
1184
|
|
|
1173
1185
|
if (isPointerMove) {
|
|
@@ -1473,21 +1485,21 @@ let globalEffects = new Set();
|
|
|
1473
1485
|
let globalAfterEffects = new Set();
|
|
1474
1486
|
let globalTailEffects = new Set();
|
|
1475
1487
|
|
|
1476
|
-
/**
|
|
1477
|
-
* Adds a global render callback which is called each frame.
|
|
1478
|
-
* @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#addEffect
|
|
1488
|
+
/**
|
|
1489
|
+
* Adds a global render callback which is called each frame.
|
|
1490
|
+
* @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#addEffect
|
|
1479
1491
|
*/
|
|
1480
1492
|
const addEffect = callback => createSubs(callback, globalEffects);
|
|
1481
1493
|
|
|
1482
|
-
/**
|
|
1483
|
-
* Adds a global after-render callback which is called each frame.
|
|
1484
|
-
* @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#addAfterEffect
|
|
1494
|
+
/**
|
|
1495
|
+
* Adds a global after-render callback which is called each frame.
|
|
1496
|
+
* @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#addAfterEffect
|
|
1485
1497
|
*/
|
|
1486
1498
|
const addAfterEffect = callback => createSubs(callback, globalAfterEffects);
|
|
1487
1499
|
|
|
1488
|
-
/**
|
|
1489
|
-
* Adds a global callback which is called when rendering stops.
|
|
1490
|
-
* @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#addTail
|
|
1500
|
+
/**
|
|
1501
|
+
* Adds a global callback which is called when rendering stops.
|
|
1502
|
+
* @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#addTail
|
|
1491
1503
|
*/
|
|
1492
1504
|
const addTail = callback => createSubs(callback, globalTailEffects);
|
|
1493
1505
|
function run(effects, timestamp) {
|
|
@@ -1586,24 +1598,24 @@ function createLoop(roots) {
|
|
|
1586
1598
|
}
|
|
1587
1599
|
return {
|
|
1588
1600
|
loop,
|
|
1589
|
-
/**
|
|
1590
|
-
* Invalidates the view, requesting a frame to be rendered. Will globally invalidate unless passed a root's state.
|
|
1591
|
-
* @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#invalidate
|
|
1601
|
+
/**
|
|
1602
|
+
* Invalidates the view, requesting a frame to be rendered. Will globally invalidate unless passed a root's state.
|
|
1603
|
+
* @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#invalidate
|
|
1592
1604
|
*/
|
|
1593
1605
|
invalidate,
|
|
1594
|
-
/**
|
|
1595
|
-
* Advances the frameloop and runs render effects, useful for when manually rendering via `frameloop="never"`.
|
|
1596
|
-
* @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#advance
|
|
1606
|
+
/**
|
|
1607
|
+
* Advances the frameloop and runs render effects, useful for when manually rendering via `frameloop="never"`.
|
|
1608
|
+
* @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#advance
|
|
1597
1609
|
*/
|
|
1598
1610
|
advance
|
|
1599
1611
|
};
|
|
1600
1612
|
}
|
|
1601
1613
|
|
|
1602
|
-
/**
|
|
1603
|
-
* Exposes an object's {@link LocalState}.
|
|
1604
|
-
* @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#useInstanceHandle
|
|
1605
|
-
*
|
|
1606
|
-
* **Note**: this is an escape hatch to react-internal fields. Expect this to change significantly between versions.
|
|
1614
|
+
/**
|
|
1615
|
+
* Exposes an object's {@link LocalState}.
|
|
1616
|
+
* @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#useInstanceHandle
|
|
1617
|
+
*
|
|
1618
|
+
* **Note**: this is an escape hatch to react-internal fields. Expect this to change significantly between versions.
|
|
1607
1619
|
*/
|
|
1608
1620
|
function useInstanceHandle(ref) {
|
|
1609
1621
|
const instance = React.useRef(null);
|
|
@@ -1616,18 +1628,18 @@ function useStore() {
|
|
|
1616
1628
|
return store;
|
|
1617
1629
|
}
|
|
1618
1630
|
|
|
1619
|
-
/**
|
|
1620
|
-
* Accesses R3F's internal state, containing renderer, canvas, scene, etc.
|
|
1621
|
-
* @see https://docs.pmnd.rs/react-three-fiber/api/hooks#usethree
|
|
1631
|
+
/**
|
|
1632
|
+
* Accesses R3F's internal state, containing renderer, canvas, scene, etc.
|
|
1633
|
+
* @see https://docs.pmnd.rs/react-three-fiber/api/hooks#usethree
|
|
1622
1634
|
*/
|
|
1623
1635
|
function useThree(selector = state => state, equalityFn) {
|
|
1624
1636
|
return useStore()(selector, equalityFn);
|
|
1625
1637
|
}
|
|
1626
1638
|
|
|
1627
|
-
/**
|
|
1628
|
-
* Executes a callback before render in a shared frame loop.
|
|
1629
|
-
* Can order effects with render priority or manually render with a positive priority.
|
|
1630
|
-
* @see https://docs.pmnd.rs/react-three-fiber/api/hooks#useframe
|
|
1639
|
+
/**
|
|
1640
|
+
* Executes a callback before render in a shared frame loop.
|
|
1641
|
+
* Can order effects with render priority or manually render with a positive priority.
|
|
1642
|
+
* @see https://docs.pmnd.rs/react-three-fiber/api/hooks#useframe
|
|
1631
1643
|
*/
|
|
1632
1644
|
function useFrame(callback, renderPriority = 0) {
|
|
1633
1645
|
const store = useStore();
|
|
@@ -1639,9 +1651,9 @@ function useFrame(callback, renderPriority = 0) {
|
|
|
1639
1651
|
return null;
|
|
1640
1652
|
}
|
|
1641
1653
|
|
|
1642
|
-
/**
|
|
1643
|
-
* Returns a node graph of an object with named nodes & materials.
|
|
1644
|
-
* @see https://docs.pmnd.rs/react-three-fiber/api/hooks#usegraph
|
|
1654
|
+
/**
|
|
1655
|
+
* Returns a node graph of an object with named nodes & materials.
|
|
1656
|
+
* @see https://docs.pmnd.rs/react-three-fiber/api/hooks#usegraph
|
|
1645
1657
|
*/
|
|
1646
1658
|
function useGraph(object) {
|
|
1647
1659
|
return React.useMemo(() => buildGraph(object), [object]);
|
|
@@ -1663,11 +1675,11 @@ function loadingFn(extensions, onProgress) {
|
|
|
1663
1675
|
}, onProgress, error => reject(new Error(`Could not load ${input}: ${error == null ? void 0 : error.message}`)))))).finally(() => loader.dispose == null ? void 0 : loader.dispose());
|
|
1664
1676
|
};
|
|
1665
1677
|
}
|
|
1666
|
-
/**
|
|
1667
|
-
* Synchronously loads and caches assets with a three loader.
|
|
1668
|
-
*
|
|
1669
|
-
* Note: this hook's caller must be wrapped with `React.Suspense`
|
|
1670
|
-
* @see https://docs.pmnd.rs/react-three-fiber/api/hooks#useloader
|
|
1678
|
+
/**
|
|
1679
|
+
* Synchronously loads and caches assets with a three loader.
|
|
1680
|
+
*
|
|
1681
|
+
* Note: this hook's caller must be wrapped with `React.Suspense`
|
|
1682
|
+
* @see https://docs.pmnd.rs/react-three-fiber/api/hooks#useloader
|
|
1671
1683
|
*/
|
|
1672
1684
|
function useLoader(Proto, input, extensions, onProgress) {
|
|
1673
1685
|
// Use suspense to load async assets
|
|
@@ -1679,16 +1691,16 @@ function useLoader(Proto, input, extensions, onProgress) {
|
|
|
1679
1691
|
return Array.isArray(input) ? results : results[0];
|
|
1680
1692
|
}
|
|
1681
1693
|
|
|
1682
|
-
/**
|
|
1683
|
-
* Preloads an asset into cache as a side-effect.
|
|
1694
|
+
/**
|
|
1695
|
+
* Preloads an asset into cache as a side-effect.
|
|
1684
1696
|
*/
|
|
1685
1697
|
useLoader.preload = function (Proto, input, extensions) {
|
|
1686
1698
|
const keys = Array.isArray(input) ? input : [input];
|
|
1687
1699
|
return preload(loadingFn(extensions), [Proto, ...keys]);
|
|
1688
1700
|
};
|
|
1689
1701
|
|
|
1690
|
-
/**
|
|
1691
|
-
* Removes a loaded asset from cache.
|
|
1702
|
+
/**
|
|
1703
|
+
* Removes a loaded asset from cache.
|
|
1692
1704
|
*/
|
|
1693
1705
|
useLoader.clear = function (Proto, input) {
|
|
1694
1706
|
const keys = Array.isArray(input) ? input : [input];
|
|
@@ -2084,10 +2096,10 @@ function Portal({
|
|
|
2084
2096
|
children,
|
|
2085
2097
|
container
|
|
2086
2098
|
}) {
|
|
2087
|
-
/** This has to be a component because it would not be able to call useThree/useStore otherwise since
|
|
2088
|
-
* if this is our environment, then we are not in r3f's renderer but in react-dom, it would trigger
|
|
2089
|
-
* the "R3F hooks can only be used within the Canvas component!" warning:
|
|
2090
|
-
* <Canvas>
|
|
2099
|
+
/** This has to be a component because it would not be able to call useThree/useStore otherwise since
|
|
2100
|
+
* if this is our environment, then we are not in r3f's renderer but in react-dom, it would trigger
|
|
2101
|
+
* the "R3F hooks can only be used within the Canvas component!" warning:
|
|
2102
|
+
* <Canvas>
|
|
2091
2103
|
* {createPortal(...)} */
|
|
2092
2104
|
const {
|
|
2093
2105
|
events,
|