@react-three/fiber 8.0.0-alpha-07 → 8.0.0-beta-01

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.
Files changed (32) hide show
  1. package/CHANGELOG.md +67 -0
  2. package/dist/declarations/src/core/events.d.ts +63 -59
  3. package/dist/declarations/src/core/hooks.d.ts +21 -29
  4. package/dist/declarations/src/core/loop.d.ts +12 -12
  5. package/dist/declarations/src/core/renderer.d.ts +50 -52
  6. package/dist/declarations/src/core/store.d.ts +111 -106
  7. package/dist/declarations/src/core/utils.d.ts +43 -0
  8. package/dist/declarations/src/index.d.ts +7 -7
  9. package/dist/declarations/src/native/Canvas.d.ts +16 -0
  10. package/dist/declarations/src/native/events.d.ts +6 -0
  11. package/dist/declarations/src/native/hooks.d.ts +9 -0
  12. package/dist/declarations/src/native/index.d.ts +37 -0
  13. package/dist/declarations/src/native.d.ts +7 -0
  14. package/dist/declarations/src/three-types.d.ts +320 -319
  15. package/dist/declarations/src/web/Canvas.d.ts +13 -13
  16. package/dist/declarations/src/web/events.d.ts +5 -4
  17. package/dist/declarations/src/web/index.d.ts +34 -30
  18. package/dist/hooks-c89a6f88.esm.js +1455 -0
  19. package/dist/hooks-dd693347.cjs.dev.js +1501 -0
  20. package/dist/hooks-e01f12ec.cjs.prod.js +1501 -0
  21. package/dist/react-three-fiber.cjs.dev.js +142 -1554
  22. package/dist/react-three-fiber.cjs.prod.js +142 -1554
  23. package/dist/react-three-fiber.esm.js +123 -1532
  24. package/native/dist/react-three-fiber-native.cjs.d.ts +1 -0
  25. package/native/dist/react-three-fiber-native.cjs.dev.js +590 -0
  26. package/native/dist/react-three-fiber-native.cjs.js +7 -0
  27. package/native/dist/react-three-fiber-native.cjs.prod.js +590 -0
  28. package/native/dist/react-three-fiber-native.esm.js +538 -0
  29. package/native/package.json +5 -0
  30. package/package.json +15 -5
  31. package/__mocks__/react-use-measure/index.ts +0 -22
  32. package/dist/declarations/src/core/is.d.ts +0 -9
@@ -2,16 +2,18 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
+ var hooks = require('./hooks-dd693347.cjs.dev.js');
5
6
  var THREE = require('three');
6
7
  var React = require('react');
7
8
  var constants = require('react-reconciler/constants');
8
- var create = require('zustand');
9
- var shallow = require('zustand/shallow');
10
- var Reconciler = require('react-reconciler');
11
- var scheduler = require('scheduler');
12
- var useAsset = require('use-asset');
9
+ var _extends = require('@babel/runtime/helpers/extends');
13
10
  var mergeRefs = require('react-merge-refs');
14
11
  var useMeasure = require('react-use-measure');
12
+ var pick = require('lodash-es/pick');
13
+ var omit = require('lodash-es/omit');
14
+ require('react-reconciler');
15
+ require('suspend-react');
16
+ require('zustand');
15
17
 
16
18
  function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
17
19
 
@@ -24,1413 +26,77 @@ function _interopNamespace(e) {
24
26
  var d = Object.getOwnPropertyDescriptor(e, k);
25
27
  Object.defineProperty(n, k, d.get ? d : {
26
28
  enumerable: true,
27
- get: function () {
28
- return e[k];
29
- }
29
+ get: function () { return e[k]; }
30
30
  });
31
31
  }
32
32
  });
33
33
  }
34
- n['default'] = e;
34
+ n["default"] = e;
35
35
  return Object.freeze(n);
36
36
  }
37
37
 
38
38
  var THREE__namespace = /*#__PURE__*/_interopNamespace(THREE);
39
39
  var React__namespace = /*#__PURE__*/_interopNamespace(React);
40
- var create__default = /*#__PURE__*/_interopDefault(create);
41
- var shallow__default = /*#__PURE__*/_interopDefault(shallow);
42
- var Reconciler__default = /*#__PURE__*/_interopDefault(Reconciler);
43
40
  var mergeRefs__default = /*#__PURE__*/_interopDefault(mergeRefs);
44
41
  var useMeasure__default = /*#__PURE__*/_interopDefault(useMeasure);
45
-
46
- var threeTypes = /*#__PURE__*/Object.freeze({
47
- __proto__: null
48
- });
49
-
50
- const is = {
51
- obj: a => a === Object(a) && !is.arr(a) && typeof a !== 'function',
52
- fun: a => typeof a === 'function',
53
- str: a => typeof a === 'string',
54
- num: a => typeof a === 'number',
55
- und: a => a === void 0,
56
- arr: a => Array.isArray(a),
57
-
58
- equ(a, b) {
59
- // Wrong type or one of the two undefined, doesn't match
60
- if (typeof a !== typeof b || !!a !== !!b) return false; // Atomic, just compare a against b
61
-
62
- if (is.str(a) || is.num(a) || is.obj(a)) return a === b; // Array, shallow compare first to see if it's a match
63
-
64
- if (is.arr(a) && a == b) return true; // Last resort, go through keys
65
-
66
- let i;
67
-
68
- for (i in a) if (!(i in b)) return false;
69
-
70
- for (i in b) if (a[i] !== b[i]) return false;
71
-
72
- return is.und(i) ? a === b : true;
73
- }
74
-
75
- };
76
-
77
- function makeId(event) {
78
- return (event.eventObject || event.object).uuid + '/' + event.index + event.instanceId;
79
- }
80
-
81
- function removeInteractivity(store, object) {
82
- const {
83
- internal
84
- } = store.getState(); // Removes every trace of an object from the data store
85
-
86
- internal.interaction = internal.interaction.filter(o => o !== object);
87
- internal.initialHits = internal.initialHits.filter(o => o !== object);
88
- internal.hovered.forEach((value, key) => {
89
- if (value.eventObject === object || value.object === object) {
90
- internal.hovered.delete(key);
91
- }
92
- });
93
- }
94
- function createEvents(store) {
95
- const temp = new THREE__namespace.Vector3();
96
- /** Sets up defaultRaycaster */
97
-
98
- function prepareRay(event) {
99
- var _raycaster$computeOff;
100
-
101
- const state = store.getState();
102
- const {
103
- raycaster,
104
- mouse,
105
- camera,
106
- size
107
- } = state; // https://github.com/pmndrs/react-three-fiber/pull/782
108
- // Events trigger outside of canvas when moved
109
-
110
- const {
111
- offsetX,
112
- offsetY
113
- } = (_raycaster$computeOff = raycaster.computeOffsets == null ? void 0 : raycaster.computeOffsets(event, state)) != null ? _raycaster$computeOff : event;
114
- const {
115
- width,
116
- height
117
- } = size;
118
- mouse.set(offsetX / width * 2 - 1, -(offsetY / height) * 2 + 1);
119
- raycaster.setFromCamera(mouse, camera);
120
- }
121
- /** Calculates delta */
122
-
123
-
124
- function calculateDistance(event) {
125
- const {
126
- internal
127
- } = store.getState();
128
- const dx = event.offsetX - internal.initialClick[0];
129
- const dy = event.offsetY - internal.initialClick[1];
130
- return Math.round(Math.sqrt(dx * dx + dy * dy));
131
- }
132
- /** Returns true if an instance has a valid pointer-event registered, this excludes scroll, clicks etc */
133
-
134
-
135
- function filterPointerEvents(objects) {
136
- return objects.filter(obj => ['Move', 'Over', 'Enter', 'Out', 'Leave'].some(name => {
137
- var _r3f$handlers;
138
-
139
- return (_r3f$handlers = obj.__r3f.handlers) == null ? void 0 : _r3f$handlers['onPointer' + name];
140
- }));
141
- }
142
-
143
- function intersect(filter) {
144
- const state = store.getState();
145
- const {
146
- raycaster,
147
- internal
148
- } = state; // Skip event handling when noEvents is set
149
-
150
- if (!raycaster.enabled) return [];
151
- const seen = new Set();
152
- const intersections = []; // Allow callers to eliminate event objects
153
-
154
- const eventsObjects = filter ? filter(internal.interaction) : internal.interaction; // Intersect known handler objects and filter against duplicates
155
-
156
- let intersects = raycaster.intersectObjects(eventsObjects, true).filter(item => {
157
- const id = makeId(item);
158
- if (seen.has(id)) return false;
159
- seen.add(id);
160
- return true;
161
- }); // https://github.com/mrdoob/three.js/issues/16031
162
- // Allow custom userland intersect sort order
163
-
164
- if (raycaster.filter) intersects = raycaster.filter(intersects, state);
165
-
166
- for (const intersect of intersects) {
167
- let eventObject = intersect.object; // Bubble event up
168
-
169
- while (eventObject) {
170
- var _r3f;
171
-
172
- const handlers = (_r3f = eventObject.__r3f) == null ? void 0 : _r3f.handlers;
173
- if (handlers) intersections.push({ ...intersect,
174
- eventObject
175
- });
176
- eventObject = eventObject.parent;
177
- }
178
- }
179
-
180
- return intersections;
181
- }
182
- /** Creates filtered intersects and returns an array of positive hits */
183
-
184
-
185
- function patchIntersects(intersections, event) {
186
- const {
187
- internal
188
- } = store.getState(); // If the interaction is captured, make all capturing targets part of the
189
- // intersect.
190
-
191
- if ('pointerId' in event && internal.capturedMap.has(event.pointerId)) {
192
- intersections.push(...internal.capturedMap.get(event.pointerId).values());
193
- }
194
-
195
- return intersections;
196
- }
197
- /** Handles intersections by forwarding them to handlers */
198
-
199
-
200
- function handleIntersects(intersections, event, callback) {
201
- const {
202
- raycaster,
203
- mouse,
204
- camera,
205
- internal
206
- } = store.getState(); // If anything has been found, forward it to the event listeners
207
-
208
- if (intersections.length) {
209
- const unprojectedPoint = temp.set(mouse.x, mouse.y, 0).unproject(camera);
210
- const delta = event.type === 'click' ? calculateDistance(event) : 0;
211
-
212
- const releasePointerCapture = id => event.target.releasePointerCapture(id);
213
-
214
- const localState = {
215
- stopped: false
216
- };
217
-
218
- for (const hit of intersections) {
219
- const hasPointerCapture = id => {
220
- var _internal$capturedMap, _internal$capturedMap2;
221
-
222
- return (_internal$capturedMap = (_internal$capturedMap2 = internal.capturedMap.get(id)) == null ? void 0 : _internal$capturedMap2.has(hit.eventObject)) != null ? _internal$capturedMap : false;
223
- };
224
-
225
- const setPointerCapture = id => {
226
- if (internal.capturedMap.has(id)) {
227
- // if the pointerId was previously captured, we add the hit to the
228
- // event capturedMap.
229
- internal.capturedMap.get(id).set(hit.eventObject, hit);
230
- } else {
231
- // if the pointerId was not previously captured, we create a map
232
- // containing the hitObject, and the hit. hitObject is used for
233
- // faster access.
234
- internal.capturedMap.set(id, new Map([[hit.eventObject, hit]]));
235
- } // Call the original event now
236
- event.target.setPointerCapture(id);
237
- }; // Add native event props
238
-
239
-
240
- let extractEventProps = {};
241
-
242
- for (let prop in Object.getPrototypeOf(event)) {
243
- let property = event[prop]; // Only copy over atomics, leave functions alone as these should be
244
- // called as event.nativeEvent.fn()
245
-
246
- if (typeof property !== 'function') extractEventProps[prop] = property;
247
- }
248
-
249
- let raycastEvent = { ...hit,
250
- ...extractEventProps,
251
- spaceX: mouse.x,
252
- spaceY: mouse.y,
253
- intersections,
254
- stopped: localState.stopped,
255
- delta,
256
- unprojectedPoint,
257
- ray: raycaster.ray,
258
- camera: camera,
259
- // Hijack stopPropagation, which just sets a flag
260
- stopPropagation: () => {
261
- // https://github.com/pmndrs/react-three-fiber/issues/596
262
- // Events are not allowed to stop propagation if the pointer has been captured
263
- const capturesForPointer = 'pointerId' in event && internal.capturedMap.get(event.pointerId); // We only authorize stopPropagation...
264
-
265
- if ( // ...if this pointer hasn't been captured
266
- !capturesForPointer || // ... or if the hit object is capturing the pointer
267
- capturesForPointer.has(hit.eventObject)) {
268
- raycastEvent.stopped = localState.stopped = true; // Propagation is stopped, remove all other hover records
269
- // An event handler is only allowed to flush other handlers if it is hovered itself
270
-
271
- if (internal.hovered.size && Array.from(internal.hovered.values()).find(i => i.eventObject === hit.eventObject)) {
272
- // Objects cannot flush out higher up objects that have already caught the event
273
- const higher = intersections.slice(0, intersections.indexOf(hit));
274
- cancelPointer([...higher, hit]);
275
- }
276
- }
277
- },
278
- // there should be a distinction between target and currentTarget
279
- target: {
280
- hasPointerCapture,
281
- setPointerCapture,
282
- releasePointerCapture
283
- },
284
- currentTarget: {
285
- hasPointerCapture,
286
- setPointerCapture,
287
- releasePointerCapture
288
- },
289
- sourceEvent: event,
290
- // deprecated
291
- nativeEvent: event
292
- }; // Call subscribers
293
-
294
- callback(raycastEvent); // Event bubbling may be interrupted by stopPropagation
295
-
296
- if (localState.stopped === true) break;
297
- }
298
- }
299
-
300
- return intersections;
301
- }
302
-
303
- function cancelPointer(hits) {
304
- const {
305
- internal
306
- } = store.getState();
307
- Array.from(internal.hovered.values()).forEach(hoveredObj => {
308
- // When no objects were hit or the the hovered object wasn't found underneath the cursor
309
- // we call onPointerOut and delete the object from the hovered-elements map
310
- if (!hits.length || !hits.find(hit => hit.object === hoveredObj.object && hit.index === hoveredObj.index && hit.instanceId === hoveredObj.instanceId)) {
311
- const eventObject = hoveredObj.eventObject;
312
- const handlers = eventObject.__r3f.handlers;
313
- internal.hovered.delete(makeId(hoveredObj));
314
-
315
- if (handlers) {
316
- // Clear out intersects, they are outdated by now
317
- const data = { ...hoveredObj,
318
- intersections: hits || []
319
- };
320
- handlers.onPointerOut == null ? void 0 : handlers.onPointerOut(data);
321
- handlers.onPointerLeave == null ? void 0 : handlers.onPointerLeave(data);
322
- }
323
- }
324
- });
325
- }
326
-
327
- const handlePointer = name => {
328
- // Deal with cancelation
329
- switch (name) {
330
- case 'onPointerLeave':
331
- case 'onPointerCancel':
332
- return () => cancelPointer([]);
333
-
334
- case 'onLostPointerCapture':
335
- return event => {
336
- if ('pointerId' in event) {
337
- // this will be a problem if one target releases the pointerId
338
- // and another one is still keeping it, as the line below
339
- // indifferently deletes all capturing references.
340
- store.getState().internal.capturedMap.delete(event.pointerId);
341
- }
342
-
343
- cancelPointer([]);
344
- };
345
- } // Any other pointer goes here ...
346
-
347
-
348
- return event => {
349
- const {
350
- onPointerMissed,
351
- internal
352
- } = store.getState();
353
- prepareRay(event); // Get fresh intersects
354
-
355
- const isPointerMove = name === 'onPointerMove';
356
- const filter = isPointerMove ? filterPointerEvents : undefined;
357
- const hits = patchIntersects(intersect(filter), event); // Take care of unhover
358
-
359
- if (isPointerMove) cancelPointer(hits);
360
- handleIntersects(hits, event, data => {
361
- const eventObject = data.eventObject;
362
- const handlers = eventObject.__r3f.handlers; // Check presence of handlers
363
-
364
- if (!handlers) return;
365
-
366
- if (isPointerMove) {
367
- // Move event ...
368
- if (handlers.onPointerOver || handlers.onPointerEnter || handlers.onPointerOut || handlers.onPointerLeave) {
369
- // When enter or out is present take care of hover-state
370
- const id = makeId(data);
371
- const hoveredItem = internal.hovered.get(id);
372
-
373
- if (!hoveredItem) {
374
- // If the object wasn't previously hovered, book it and call its handler
375
- internal.hovered.set(id, data);
376
- handlers.onPointerOver == null ? void 0 : handlers.onPointerOver(data);
377
- handlers.onPointerEnter == null ? void 0 : handlers.onPointerEnter(data);
378
- } else if (hoveredItem.stopped) {
379
- // If the object was previously hovered and stopped, we shouldn't allow other items to proceed
380
- data.stopPropagation();
381
- }
382
- } // Call mouse move
383
-
384
-
385
- handlers.onPointerMove == null ? void 0 : handlers.onPointerMove(data);
386
- } else {
387
- // All other events ...
388
- const handler = handlers == null ? void 0 : handlers[name];
389
-
390
- if (handler) {
391
- // Forward all events back to their respective handlers with the exception of click events,
392
- // which must use the initial target
393
- if (name !== 'onClick' && name !== 'onContextMenu' && name !== 'onDoubleClick' || internal.initialHits.includes(eventObject)) {
394
- handler(data);
395
- pointerMissed(event, internal.interaction.filter(object => object !== eventObject));
396
- }
397
- }
398
- }
399
- }); // Save initial coordinates on pointer-down
400
-
401
- if (name === 'onPointerDown') {
402
- internal.initialClick = [event.offsetX, event.offsetY];
403
- internal.initialHits = hits.map(hit => hit.eventObject);
404
- } // If a click yields no results, pass it back to the user as a miss
405
-
406
-
407
- if ((name === 'onClick' || name === 'onContextMenu' || name === 'onDoubleClick') && !hits.length) {
408
- if (calculateDistance(event) <= 2) {
409
- pointerMissed(event, internal.interaction);
410
- if (onPointerMissed) onPointerMissed(event);
411
- }
412
- }
413
- };
414
- };
415
-
416
- function pointerMissed(event, objects) {
417
- objects.forEach(object => {
418
- var _r3f$handlers2;
419
-
420
- return (_r3f$handlers2 = object.__r3f.handlers) == null ? void 0 : _r3f$handlers2.onPointerMissed == null ? void 0 : _r3f$handlers2.onPointerMissed(event);
421
- });
422
- }
423
-
424
- return {
425
- handlePointer
426
- };
427
- }
428
-
429
- // Type guard to tell a store from a portal
430
- const isStore = def => def && !!def.getState;
431
-
432
- const getContainer = (container, child) => {
433
- var _container$__r3f$root, _container$__r3f;
434
-
435
- return {
436
- // If the container is not a root-store then it must be a THREE.Object3D into which part of the
437
- // scene is portalled into. Now there can be two variants of this, either that object is part of
438
- // the regular jsx tree, in which case it already has __r3f with a valid root attached, or it lies
439
- // outside react, in which case we must take the root of the child that is about to be attached to it.
440
- root: isStore(container) ? container : (_container$__r3f$root = (_container$__r3f = container.__r3f) == null ? void 0 : _container$__r3f.root) != null ? _container$__r3f$root : child.__r3f.root,
441
- // The container is the eventual target into which objects are mounted, it has to be a THREE.Object3D
442
- container: isStore(container) ? container.getState().scene : container
443
- };
444
- };
445
-
446
- const DEFAULT = '__default';
447
- const EMPTY = {};
448
- const FILTER = ['children', 'key', 'ref'];
449
- let catalogue = {};
450
-
451
- let extend = objects => void (catalogue = { ...catalogue,
452
- ...objects
453
- }); // Each object in the scene carries a small LocalState descriptor
454
-
455
-
456
- function prepare(object, state) {
457
- const instance = object;
458
-
459
- if (state != null && state.instance || !instance.__r3f) {
460
- instance.__r3f = {
461
- root: null,
462
- memoizedProps: {},
463
- objects: [],
464
- ...state
465
- };
42
+ var pick__default = /*#__PURE__*/_interopDefault(pick);
43
+ var omit__default = /*#__PURE__*/_interopDefault(omit);
44
+
45
+ // @ts-ignore
46
+ const CLICK = 'click';
47
+ const CONTEXTMENU = 'contextmenu';
48
+ const DBLCLICK = 'dblclick';
49
+ const POINTERCANCEL = 'pointercancel';
50
+ const POINTERDOWN = 'pointerdown';
51
+ const POINTERUP = 'pointerup';
52
+ const POINTERMOVE = 'pointermove';
53
+ const POINTEROUT = 'pointerout';
54
+ const POINTEROVER = 'pointerover';
55
+ const POINTERENTER = 'pointerenter';
56
+ const POINTERLEAVE = 'pointerleave';
57
+ const WHEEL = 'wheel'; // https://github.com/facebook/react/tree/main/packages/react-reconciler#getcurrenteventpriority
58
+ // Gives React a clue as to how import the current interaction is
59
+
60
+ function getEventPriority() {
61
+ var _window, _window$event;
62
+
63
+ let name = (_window = window) == null ? void 0 : (_window$event = _window.event) == null ? void 0 : _window$event.type;
64
+
65
+ switch (name) {
66
+ case CLICK:
67
+ case CONTEXTMENU:
68
+ case DBLCLICK:
69
+ case POINTERCANCEL:
70
+ case POINTERDOWN:
71
+ case POINTERUP:
72
+ return constants.DiscreteEventPriority;
73
+
74
+ case POINTERMOVE:
75
+ case POINTEROUT:
76
+ case POINTEROVER:
77
+ case POINTERENTER:
78
+ case POINTERLEAVE:
79
+ case WHEEL:
80
+ return constants.ContinuousEventPriority;
81
+
82
+ default:
83
+ return constants.DefaultEventPriority;
466
84
  }
467
-
468
- return object;
469
85
  }
470
-
471
- function createRenderer(roots) {
472
- function applyProps(instance, newProps, oldProps = {}, accumulative = false) {
473
- var _instance$__r3f, _root$getState, _instance$__r3f2;
474
-
475
- // Filter equals, events and reserved props
476
- const localState = (_instance$__r3f = instance == null ? void 0 : instance.__r3f) != null ? _instance$__r3f : {};
477
- const root = localState.root;
478
- const rootState = (_root$getState = root == null ? void 0 : root.getState == null ? void 0 : root.getState()) != null ? _root$getState : {};
479
- const sameProps = [];
480
- const handlers = [];
481
- const newMemoizedProps = {};
482
- let i = 0;
483
- Object.entries(newProps).forEach(([key, entry]) => {
484
- // we don't want children, ref or key in the memoized props
485
- if (FILTER.indexOf(key) === -1) {
486
- newMemoizedProps[key] = entry;
487
- }
488
- });
489
-
490
- if (localState.memoizedProps && localState.memoizedProps.args) {
491
- newMemoizedProps.args = localState.memoizedProps.args;
492
- }
493
-
494
- if (localState.memoizedProps && localState.memoizedProps.attach) {
495
- newMemoizedProps.attach = localState.memoizedProps.attach;
496
- }
497
-
498
- if (instance.__r3f) {
499
- instance.__r3f.memoizedProps = newMemoizedProps;
500
- }
501
-
502
- let objectKeys = Object.keys(newProps);
503
-
504
- for (i = 0; i < objectKeys.length; i++) {
505
- if (is.equ(newProps[objectKeys[i]], oldProps[objectKeys[i]])) {
506
- sameProps.push(objectKeys[i]);
507
- } // Event-handlers ...
508
- // are functions, that
509
- // start with "on", and
510
- // contain the name "Pointer", "Click", "DoubleClick", "ContextMenu", or "Wheel"
511
-
512
-
513
- if (is.fun(newProps[objectKeys[i]]) && /^on(Pointer|Click|DoubleClick|ContextMenu|Wheel)/.test(objectKeys[i])) {
514
- handlers.push(objectKeys[i]);
515
- }
516
- } // Catch props that existed, but now exist no more ...
517
-
518
-
519
- const leftOvers = [];
520
-
521
- if (accumulative) {
522
- objectKeys = Object.keys(oldProps);
523
-
524
- for (i = 0; i < objectKeys.length; i++) {
525
- if (!newProps.hasOwnProperty(objectKeys[i])) {
526
- leftOvers.push(objectKeys[i]);
527
- }
528
- }
529
- }
530
-
531
- const toFilter = [...sameProps, ...FILTER]; // Instances use "object" as a reserved identifier
532
-
533
- if ((_instance$__r3f2 = instance.__r3f) != null && _instance$__r3f2.instance) toFilter.push('object');
534
- const filteredProps = { ...newProps
535
- }; // Removes sameProps and reserved props from newProps
536
-
537
- objectKeys = Object.keys(filteredProps);
538
-
539
- for (i = 0; i < objectKeys.length; i++) {
540
- if (toFilter.indexOf(objectKeys[i]) > -1) {
541
- delete filteredProps[objectKeys[i]];
542
- }
543
- } // Collect all new props
544
-
545
-
546
- const filteredPropsEntries = Object.entries(filteredProps); // Prepend left-overs so they can be reset or removed
547
- // Left-overs must come first!
548
-
549
- for (i = 0; i < leftOvers.length; i++) {
550
- if (leftOvers[i] !== 'children') {
551
- filteredPropsEntries.unshift([leftOvers[i], DEFAULT + 'remove']);
552
- }
553
- }
554
-
555
- if (filteredPropsEntries.length > 0) {
556
- filteredPropsEntries.forEach(([key, value]) => {
557
- if (!handlers.includes(key)) {
558
- let currentInstance = instance;
559
- let targetProp = currentInstance[key];
560
-
561
- if (key.includes('-')) {
562
- const entries = key.split('-');
563
- targetProp = entries.reduce((acc, key) => acc[key], instance); // If the target is atomic, it forces us to switch the root
564
-
565
- if (!(targetProp && targetProp.set)) {
566
- const [name, ...reverseEntries] = entries.reverse();
567
- currentInstance = reverseEntries.reverse().reduce((acc, key) => acc[key], instance);
568
- key = name;
569
- }
570
- } // https://github.com/mrdoob/three.js/issues/21209
571
- // HMR/fast-refresh relies on the ability to cancel out props, but threejs
572
- // has no means to do this. Hence we curate a small collection of value-classes
573
- // with their respective constructor/set arguments
574
- // For removed props, try to set default values, if possible
575
-
576
-
577
- if (value === DEFAULT + 'remove') {
578
- if (targetProp && targetProp.constructor) {
579
- // use the prop constructor to find the default it should be
580
- value = new targetProp.constructor(newMemoizedProps.args);
581
- } else if (currentInstance.constructor) {
582
- // create a blank slate of the instance and copy the particular parameter.
583
- // @ts-ignore
584
- const defaultClassCall = new currentInstance.constructor(currentInstance.__r3f.memoizedProps.args);
585
- value = defaultClassCall[targetProp]; // destory the instance
586
-
587
- if (defaultClassCall.dispose) {
588
- defaultClassCall.dispose();
589
- }
590
- } else {
591
- // instance does not have constructor, just set it to 0
592
- value = 0;
593
- }
594
- } // Special treatment for objects with support for set/copy, and layers
595
-
596
-
597
- if (targetProp && targetProp.set && (targetProp.copy || targetProp instanceof THREE__namespace.Layers)) {
598
- // If value is an array
599
- if (Array.isArray(value)) {
600
- if (targetProp.fromArray) {
601
- targetProp.fromArray(value);
602
- } else {
603
- targetProp.set(...value);
604
- }
605
- } // Test again target.copy(class) next ...
606
- else if (targetProp.copy && value && value.constructor && targetProp.constructor.name === value.constructor.name) {
607
- targetProp.copy(value);
608
- } // If nothing else fits, just set the single value, ignore undefined
609
- // https://github.com/react-spring/react-three-fiber/issues/274
610
- else if (value !== undefined) {
611
- const isColor = targetProp instanceof THREE__namespace.Color; // Allow setting array scalars
612
-
613
- if (!isColor && targetProp.setScalar) targetProp.setScalar(value); // Layers have no copy function, we must therefore copy the mask property
614
- else if (targetProp instanceof THREE__namespace.Layers && value instanceof THREE__namespace.Layers) targetProp.mask = value.mask; // Otherwise just set ...
615
- else targetProp.set(value); // Auto-convert sRGB colors, for now ...
616
- // https://github.com/react-spring/react-three-fiber/issues/344
617
-
618
- if (!rootState.linear && isColor) targetProp.convertSRGBToLinear();
619
- } // Else, just overwrite the value
620
-
621
- } else {
622
- currentInstance[key] = value; // Auto-convert sRGB textures, for now ...
623
- // https://github.com/react-spring/react-three-fiber/issues/344
624
-
625
- if (!rootState.linear && currentInstance[key] instanceof THREE__namespace.Texture) currentInstance[key].encoding = THREE__namespace.sRGBEncoding;
626
- }
627
-
628
- invalidateInstance(instance);
629
- }
630
- }); // Preemptively delete the instance from the containers interaction
631
-
632
- if (accumulative && root && instance.raycast && localState.handlers) {
633
- localState.handlers = undefined;
634
- const index = rootState.internal.interaction.indexOf(instance);
635
- if (index > -1) rootState.internal.interaction.splice(index, 1);
636
- } // Prep interaction handlers
637
-
638
-
639
- if (handlers.length) {
640
- if (accumulative && root && instance.raycast) {
641
- rootState.internal.interaction.push(instance);
642
- } // Add handlers to the instances handler-map
643
-
644
-
645
- localState.handlers = handlers.reduce((acc, key) => ({ ...acc,
646
- [key]: newProps[key]
647
- }), {});
648
- } // Call the update lifecycle when it is being updated, but only when it is part of the scene
649
-
650
-
651
- if (instance.parent) updateInstance(instance);
652
- }
653
- }
654
-
655
- function invalidateInstance(instance) {
656
- var _instance$__r3f3, _instance$__r3f3$root;
657
-
658
- const state = (_instance$__r3f3 = instance.__r3f) == null ? void 0 : (_instance$__r3f3$root = _instance$__r3f3.root) == null ? void 0 : _instance$__r3f3$root.getState == null ? void 0 : _instance$__r3f3$root.getState();
659
- if (state && state.internal.frames === 0) state.invalidate();
660
- }
661
-
662
- function updateInstance(instance) {
663
- instance.onUpdate == null ? void 0 : instance.onUpdate(instance);
664
- }
665
-
666
- function createInstance(type, {
667
- args = [],
668
- ...props
669
- }, root, hostContext, internalInstanceHandle) {
670
- let name = `${type[0].toUpperCase()}${type.slice(1)}`;
671
- let instance; // https://github.com/facebook/react/issues/17147
672
- // Portals do not give us a root, they are themselves treated as a root by the reconciler
673
- // In order to figure out the actual root we have to climb through fiber internals :(
674
-
675
- if (!isStore(root) && internalInstanceHandle) {
676
- const fn = node => {
677
- if (!node.return) return node.stateNode && node.stateNode.containerInfo;else return fn(node.return);
678
- };
679
-
680
- root = fn(internalInstanceHandle);
681
- } // Assert that by now we have a valid root
682
-
683
-
684
- if (!root || !isStore(root)) throw `No valid root for ${name}!`;
685
-
686
- if (type === 'primitive') {
687
- if (props.object === undefined) throw `Primitives without 'object' are invalid!`;
688
- const object = props.object;
689
- instance = prepare(object, {
690
- root,
691
- instance: true
692
- });
693
- } else {
694
- const target = catalogue[name] || THREE__namespace[name];
695
- if (!target) throw `${name} is not part of the THREE namespace! Did you forget to extend? See: https://github.com/pmndrs/react-three-fiber/blob/master/markdown/api.md#using-3rd-party-objects-declaratively`;
696
- const isArgsArr = is.arr(args); // Instanciate new object, link it to the root
697
-
698
- instance = prepare(isArgsArr ? new target(...args) : new target(args), {
699
- root,
700
- // append memoized props with args so it's not forgotten
701
- memoizedProps: {
702
- args: isArgsArr && args.length === 0 ? null : args
703
- }
704
- });
705
- } // Auto-attach geometries and materials
706
-
707
-
708
- if (!('attachFns' in props)) {
709
- if (name.endsWith('Geometry')) {
710
- props = {
711
- attach: 'geometry',
712
- ...props
713
- };
714
- } else if (name.endsWith('Material')) {
715
- props = {
716
- attach: 'material',
717
- ...props
718
- };
719
- }
720
- } // It should NOT call onUpdate on object instanciation, because it hasn't been added to the
721
- // view yet. If the callback relies on references for instance, they won't be ready yet, this is
722
- // why it passes "true" here
723
-
724
-
725
- applyProps(instance, props, {});
726
- return instance;
727
- }
728
-
729
- function appendChild(parentInstance, child) {
730
- let addedAsChild = false;
731
-
732
- if (child) {
733
- // The attach attribute implies that the object attaches itself on the parent
734
- if (child.attachArray) {
735
- if (!is.arr(parentInstance[child.attachArray])) parentInstance[child.attachArray] = [];
736
- parentInstance[child.attachArray].push(child);
737
- } else if (child.attachObject) {
738
- if (!is.obj(parentInstance[child.attachObject[0]])) parentInstance[child.attachObject[0]] = {};
739
- parentInstance[child.attachObject[0]][child.attachObject[1]] = child;
740
- } else if (child.attach && !is.fun(child.attach)) {
741
- parentInstance[child.attach] = child;
742
- } else if (is.arr(child.attachFns)) {
743
- const [attachFn] = child.attachFns;
744
-
745
- if (is.str(attachFn) && is.fun(parentInstance[attachFn])) {
746
- parentInstance[attachFn](child);
747
- } else if (is.fun(attachFn)) {
748
- attachFn(child, parentInstance);
749
- }
750
- } else if (child.isObject3D) {
751
- // add in the usual parent-child way
752
- parentInstance.add(child);
753
- addedAsChild = true;
754
- }
755
-
756
- if (!addedAsChild) {
757
- // This is for anything that used attach, and for non-Object3Ds that don't get attached to props;
758
- // that is, anything that's a child in React but not a child in the scenegraph.
759
- parentInstance.__r3f.objects.push(child);
760
-
761
- child.parent = parentInstance;
762
- }
763
-
764
- updateInstance(child);
765
- invalidateInstance(child);
766
- }
767
- }
768
-
769
- function insertBefore(parentInstance, child, beforeChild) {
770
- let added = false;
771
-
772
- if (child) {
773
- if (child.attachArray) {
774
- const array = parentInstance[child.attachArray];
775
- if (!is.arr(array)) parentInstance[child.attachArray] = [];
776
- array.splice(array.indexOf(beforeChild), 0, child);
777
- } else if (child.attachObject || child.attach && !is.fun(child.attach)) {
778
- // attach and attachObject don't have an order anyway, so just append
779
- return appendChild(parentInstance, child);
780
- } else if (child.isObject3D) {
781
- child.parent = parentInstance;
782
- child.dispatchEvent({
783
- type: 'added'
784
- });
785
- const restSiblings = parentInstance.children.filter(sibling => sibling !== child);
786
- const index = restSiblings.indexOf(beforeChild);
787
- parentInstance.children = [...restSiblings.slice(0, index), child, ...restSiblings.slice(index)];
788
- added = true;
789
- }
790
-
791
- if (!added) {
792
- parentInstance.__r3f.objects.push(child);
793
-
794
- child.parent = parentInstance;
795
- }
796
-
797
- updateInstance(child);
798
- invalidateInstance(child);
799
- }
800
- }
801
-
802
- function removeRecursive(array, parent, dispose = false) {
803
- if (array) [...array].forEach(child => removeChild(parent, child, dispose));
804
- }
805
-
806
- function removeChild(parentInstance, child, dispose) {
807
- if (child) {
808
- var _child$__r3f2;
809
-
810
- if (parentInstance.__r3f.objects) {
811
- const oldLength = parentInstance.__r3f.objects.length;
812
- parentInstance.__r3f.objects = parentInstance.__r3f.objects.filter(x => x !== child);
813
- const newLength = parentInstance.__r3f.objects.length; // was it in the list?
814
-
815
- if (newLength < oldLength) {
816
- // we had also set this, so we must clear it now
817
- child.parent = null;
818
- }
819
- } // Remove attachment
820
-
821
-
822
- if (child.attachArray) {
823
- parentInstance[child.attachArray] = parentInstance[child.attachArray].filter(x => x !== child);
824
- } else if (child.attachObject) {
825
- delete parentInstance[child.attachObject[0]][child.attachObject[1]];
826
- } else if (child.attach && !is.fun(child.attach)) {
827
- parentInstance[child.attach] = null;
828
- } else if (is.arr(child.attachFns)) {
829
- const [, detachFn] = child.attachFns;
830
-
831
- if (is.str(detachFn) && is.fun(parentInstance[detachFn])) {
832
- parentInstance[detachFn](child);
833
- } else if (is.fun(detachFn)) {
834
- detachFn(child, parentInstance);
835
- }
836
- } else if (child.isObject3D) {
837
- var _child$__r3f;
838
-
839
- parentInstance.remove(child); // Remove interactivity
840
-
841
- if ((_child$__r3f = child.__r3f) != null && _child$__r3f.root) {
842
- removeInteractivity(child.__r3f.root, child);
843
- }
844
- } // Allow objects to bail out of recursive dispose alltogether by passing dispose={null}
845
- // Never dispose of primitives because their state may be kept outside of React!
846
- // In order for an object to be able to dispose it has to have
847
- // - a dispose method,
848
- // - it cannot be a <primitive object={...} />
849
- // - it cannot be a THREE.Scene, because three has broken it's own api
850
- //
851
- // Since disposal is recursive, we can check the optional dispose arg, which will be undefined
852
- // when the reconciler calls it, but then carry our own check recursively
853
-
854
-
855
- const isInstance = (_child$__r3f2 = child.__r3f) == null ? void 0 : _child$__r3f2.instance;
856
- const shouldDispose = dispose === undefined ? child.dispose !== null && !isInstance : dispose; // Remove nested child objects. Primitives should not have objects and children that are
857
- // attached to them declaratively ...
858
-
859
- if (!isInstance) {
860
- var _child$__r3f3;
861
-
862
- removeRecursive((_child$__r3f3 = child.__r3f) == null ? void 0 : _child$__r3f3.objects, child, shouldDispose);
863
- removeRecursive(child.children, child, shouldDispose);
864
- } // Remove references
865
-
866
-
867
- if (child.__r3f) {
868
- delete child.__r3f.root;
869
- delete child.__r3f.objects;
870
- delete child.__r3f.handlers;
871
- delete child.__r3f.memoizedProps;
872
- if (!isInstance) delete child.__r3f;
873
- } // Dispose item whenever the reconciler feels like it
874
-
875
-
876
- if (shouldDispose && child.dispose && child.type !== 'Scene') {
877
- scheduler.unstable_runWithPriority(scheduler.unstable_IdlePriority, () => {
878
- try {
879
- child.dispose();
880
- } catch (e) {
881
- /* ... */
882
- }
883
- });
884
- }
885
-
886
- invalidateInstance(parentInstance);
887
- }
888
- }
889
-
890
- function switchInstance(instance, type, newProps, fiber) {
891
- const parent = instance.parent;
892
- if (!parent) return;
893
- const newInstance = createInstance(type, newProps, instance.__r3f.root); // https://github.com/pmndrs/react-three-fiber/issues/1348
894
- // When args change the instance has to be re-constructed, which then
895
- // forces r3f to re-parent the children and non-scene objects
896
-
897
- if (instance.children) {
898
- instance.children.forEach(child => appendChild(newInstance, child));
899
- instance.children = [];
900
- }
901
-
902
- instance.__r3f.objects.forEach(child => appendChild(newInstance, child));
903
-
904
- instance.__r3f.objects = [];
905
- removeChild(parent, instance);
906
- appendChild(parent, newInstance) // This evil hack switches the react-internal fiber node
907
- // https://github.com/facebook/react/issues/14983
908
- // https://github.com/facebook/react/pull/15021
909
- ;
910
- [fiber, fiber.alternate].forEach(fiber => {
911
- if (fiber !== null) {
912
- fiber.stateNode = newInstance;
913
-
914
- if (fiber.ref) {
915
- if (typeof fiber.ref === 'function') fiber.ref(newInstance);else fiber.ref.current = newInstance;
916
- }
917
- }
918
- });
919
- }
920
-
921
- const reconciler = Reconciler__default['default']({
922
- now: scheduler.unstable_now,
923
- createInstance,
924
- removeChild,
925
- appendChild,
926
- appendInitialChild: appendChild,
927
- insertBefore,
928
- warnsIfNotActing: true,
929
- supportsMutation: true,
930
- isPrimaryRenderer: false,
931
- getCurrentEventPriority: () => constants.DefaultEventPriority,
932
- // @ts-ignore
933
- scheduleTimeout: is.fun(setTimeout) ? setTimeout : undefined,
934
- // @ts-ignore
935
- cancelTimeout: is.fun(clearTimeout) ? clearTimeout : undefined,
936
- // @ts-ignore
937
- setTimeout: is.fun(setTimeout) ? setTimeout : undefined,
938
- // @ts-ignore
939
- clearTimeout: is.fun(clearTimeout) ? clearTimeout : undefined,
940
- noTimeout: -1,
941
- appendChildToContainer: (parentInstance, child) => {
942
- const {
943
- container,
944
- root
945
- } = getContainer(parentInstance, child); // Link current root to the default scene
946
-
947
- container.__r3f.root = root;
948
- appendChild(container, child);
949
- },
950
- removeChildFromContainer: (parentInstance, child) => {
951
- const {
952
- container
953
- } = getContainer(parentInstance, child);
954
- removeChild(container, child);
955
- },
956
- insertInContainerBefore: (parentInstance, child, beforeChild) => {
957
- const {
958
- container
959
- } = getContainer(parentInstance, child);
960
- insertBefore(container, child, beforeChild);
961
- },
962
-
963
- commitUpdate(instance, updatePayload, type, oldProps, newProps, fiber) {
964
- if (instance.__r3f.instance && newProps.object && newProps.object !== instance) {
965
- // <instance object={...} /> where the object reference has changed
966
- switchInstance(instance, type, newProps, fiber);
967
- } else {
968
- // This is a data object, let's extract critical information about it
969
- const {
970
- args: argsNew = [],
971
- ...restNew
972
- } = newProps;
973
- const {
974
- args: argsOld = [],
975
- ...restOld
976
- } = oldProps; // If it has new props or arguments, then it needs to be re-instanciated
977
-
978
- const hasNewArgs = argsNew.some((value, index) => is.obj(value) ? Object.entries(value).some(([key, val]) => val !== argsOld[index][key]) : value !== argsOld[index]);
979
-
980
- if (hasNewArgs) {
981
- // Next we create a new instance and append it again
982
- switchInstance(instance, type, newProps, fiber);
983
- } else {
984
- // Otherwise just overwrite props
985
- applyProps(instance, restNew, restOld, true);
986
- }
987
- }
988
- },
989
-
990
- hideInstance(instance) {
991
- if (instance.isObject3D) {
992
- instance.visible = false;
993
- invalidateInstance(instance);
994
- }
995
- },
996
-
997
- unhideInstance(instance, props) {
998
- if (instance.isObject3D && props.visible == null || props.visible) {
999
- instance.visible = true;
1000
- invalidateInstance(instance);
1001
- }
1002
- },
1003
-
1004
- hideTextInstance() {
1005
- throw new Error('Text is not allowed in the R3F tree.');
1006
- },
1007
-
1008
- getPublicInstance(instance) {
1009
- // TODO: might fix switchInstance (?)
1010
- return instance;
1011
- },
1012
-
1013
- getRootHostContext(rootContainer) {
1014
- return EMPTY;
1015
- },
1016
-
1017
- getChildHostContext(parentHostContext) {
1018
- return EMPTY;
1019
- },
1020
-
1021
- createTextInstance() {},
1022
-
1023
- finalizeInitialChildren(instance) {
1024
- // https://github.com/facebook/react/issues/20271
1025
- // Returning true will trigger commitMount
1026
- return !!instance.__r3f.handlers;
1027
- },
1028
-
1029
- commitMount(instance)
1030
- /*, type, props*/
1031
- {
1032
- // https://github.com/facebook/react/issues/20271
1033
- // This will make sure events are only added once to the central container
1034
- if (instance.raycast && instance.__r3f.handlers) instance.__r3f.root.getState().internal.interaction.push(instance);
1035
- },
1036
-
1037
- prepareUpdate() {
1038
- return EMPTY;
1039
- },
1040
-
1041
- shouldDeprioritizeSubtree() {
1042
- return false;
1043
- },
1044
-
1045
- prepareForCommit() {
1046
- return null;
1047
- },
1048
-
1049
- preparePortalMount(...args) {// noop
1050
- },
1051
-
1052
- resetAfterCommit() {// noop
1053
- },
1054
-
1055
- shouldSetTextContent() {
1056
- return false;
1057
- },
1058
-
1059
- clearContainer() {
1060
- return false;
1061
- },
1062
-
1063
- detachDeletedInstance() {// noop
1064
- }
1065
-
1066
- });
1067
- return {
1068
- reconciler,
1069
- applyProps
1070
- };
1071
- }
1072
-
1073
- const isRenderer = def => def && !!def.render;
1074
- const isOrthographicCamera = def => def && def.isOrthographicCamera;
1075
- const context = /*#__PURE__*/React__namespace.createContext(null);
1076
-
1077
- const createStore = (applyProps, invalidate, advance, props) => {
1078
- const {
1079
- gl,
1080
- size,
1081
- shadows = false,
1082
- linear = false,
1083
- flat = false,
1084
- vr = false,
1085
- orthographic = false,
1086
- frameloop = 'always',
1087
- dpr = 1,
1088
- performance,
1089
- clock = new THREE__namespace.Clock(),
1090
- raycaster: raycastOptions,
1091
- camera: cameraOptions,
1092
- onPointerMissed
1093
- } = props; // Set shadowmap
1094
-
1095
- if (shadows) {
1096
- gl.shadowMap.enabled = true;
1097
- if (typeof shadows === 'object') Object.assign(gl.shadowMap, shadows);else gl.shadowMap.type = THREE__namespace.PCFSoftShadowMap;
1098
- } // Set color management
1099
-
1100
-
1101
- if (!linear) gl.outputEncoding = THREE__namespace.sRGBEncoding;
1102
- if (!flat) gl.toneMapping = THREE__namespace.ACESFilmicToneMapping; // clock.elapsedTime is updated using advance(timestamp)
1103
-
1104
- if (frameloop === 'never') {
1105
- clock.stop();
1106
- clock.elapsedTime = 0;
1107
- }
1108
-
1109
- const rootState = create__default['default']((set, get) => {
1110
- // Create custom raycaster
1111
- const raycaster = new THREE__namespace.Raycaster();
1112
- const {
1113
- params,
1114
- ...options
1115
- } = raycastOptions || {};
1116
- applyProps(raycaster, {
1117
- enabled: true,
1118
- ...options,
1119
- params: { ...raycaster.params,
1120
- ...params
1121
- }
1122
- }, {}); // Create default camera
1123
-
1124
- const isCamera = cameraOptions instanceof THREE__namespace.Camera;
1125
- const camera = isCamera ? cameraOptions : orthographic ? new THREE__namespace.OrthographicCamera(0, 0, 0, 0, 0.1, 1000) : new THREE__namespace.PerspectiveCamera(75, 0, 0.1, 1000);
1126
-
1127
- if (!isCamera) {
1128
- camera.position.z = 5;
1129
- if (cameraOptions) applyProps(camera, cameraOptions, {}); // Always look at center by default
1130
-
1131
- camera.lookAt(0, 0, 0);
1132
- }
1133
-
1134
- function setDpr(dpr) {
1135
- return Array.isArray(dpr) ? Math.min(Math.max(dpr[0], window.devicePixelRatio), dpr[1]) : dpr;
1136
- }
1137
-
1138
- const initialDpr = setDpr(dpr);
1139
- const position = new THREE__namespace.Vector3();
1140
- const defaultTarget = new THREE__namespace.Vector3();
1141
-
1142
- function getCurrentViewport(camera = get().camera, target = defaultTarget, size = get().size) {
1143
- const {
1144
- width,
1145
- height
1146
- } = size;
1147
- const aspect = width / height;
1148
- const distance = camera.getWorldPosition(position).distanceTo(target);
1149
-
1150
- if (isOrthographicCamera(camera)) {
1151
- return {
1152
- width: width / camera.zoom,
1153
- height: height / camera.zoom,
1154
- factor: 1,
1155
- distance,
1156
- aspect
1157
- };
1158
- } else {
1159
- const fov = camera.fov * Math.PI / 180; // convert vertical fov to radians
1160
-
1161
- const h = 2 * Math.tan(fov / 2) * distance; // visible height
1162
-
1163
- const w = h * (width / height);
1164
- return {
1165
- width: w,
1166
- height: h,
1167
- factor: width / w,
1168
- distance,
1169
- aspect
1170
- };
1171
- }
1172
- }
1173
-
1174
- let performanceTimeout = undefined;
1175
-
1176
- const setPerformanceCurrent = current => set(state => ({
1177
- performance: { ...state.performance,
1178
- current
1179
- }
1180
- }));
1181
-
1182
- return {
1183
- gl,
1184
- set,
1185
- get,
1186
- invalidate: () => invalidate(get()),
1187
- advance: (timestamp, runGlobalEffects) => advance(timestamp, runGlobalEffects, get()),
1188
- linear,
1189
- flat,
1190
- scene: prepare(new THREE__namespace.Scene()),
1191
- camera,
1192
- controls: null,
1193
- raycaster,
1194
- clock,
1195
- mouse: new THREE__namespace.Vector2(),
1196
- vr,
1197
- frameloop,
1198
- onPointerMissed,
1199
- performance: {
1200
- current: 1,
1201
- min: 0.5,
1202
- max: 1,
1203
- debounce: 200,
1204
- ...performance,
1205
- regress: () => {
1206
- const state = get(); // Clear timeout
1207
-
1208
- if (performanceTimeout) clearTimeout(performanceTimeout); // Set lower bound performance
1209
-
1210
- if (state.performance.current !== state.performance.min) setPerformanceCurrent(state.performance.min); // Go back to upper bound performance after a while unless something regresses meanwhile
1211
-
1212
- performanceTimeout = setTimeout(() => setPerformanceCurrent(get().performance.max), state.performance.debounce);
1213
- }
1214
- },
1215
- size: {
1216
- width: 0,
1217
- height: 0
1218
- },
1219
- viewport: {
1220
- initialDpr,
1221
- dpr: initialDpr,
1222
- width: 0,
1223
- height: 0,
1224
- aspect: 0,
1225
- distance: 0,
1226
- factor: 0,
1227
- getCurrentViewport
1228
- },
1229
- setSize: (width, height) => {
1230
- const size = {
1231
- width,
1232
- height
1233
- };
1234
- set(state => ({
1235
- size,
1236
- viewport: { ...state.viewport,
1237
- ...getCurrentViewport(camera, defaultTarget, size)
1238
- }
1239
- }));
1240
- },
1241
- setDpr: dpr => set(state => ({
1242
- viewport: { ...state.viewport,
1243
- dpr: setDpr(dpr)
1244
- }
1245
- })),
1246
- events: {
1247
- connected: false
1248
- },
1249
- internal: {
1250
- active: false,
1251
- priority: 0,
1252
- frames: 0,
1253
- lastProps: props,
1254
- interaction: [],
1255
- hovered: new Map(),
1256
- subscribers: [],
1257
- initialClick: [0, 0],
1258
- initialHits: [],
1259
- capturedMap: new Map(),
1260
- subscribe: (ref, priority = 0) => {
1261
- set(({
1262
- internal
1263
- }) => ({
1264
- internal: { ...internal,
1265
- // If this subscription was given a priority, it takes rendering into its own hands
1266
- // For that reason we switch off automatic rendering and increase the manual flag
1267
- // As long as this flag is positive (there could be multiple render subscription)
1268
- // ..there can be no internal rendering at all
1269
- priority: internal.priority + (priority > 0 ? 1 : 0),
1270
- // Register subscriber and sort layers from lowest to highest, meaning,
1271
- // highest priority renders last (on top of the other frames)
1272
- subscribers: [...internal.subscribers, {
1273
- ref,
1274
- priority
1275
- }].sort((a, b) => a.priority - b.priority)
1276
- }
1277
- }));
1278
- return () => {
1279
- set(({
1280
- internal
1281
- }) => ({
1282
- internal: { ...internal,
1283
- // Decrease manual flag if this subscription had a priority
1284
- priority: internal.priority - (priority > 0 ? 1 : 0),
1285
- // Remove subscriber from list
1286
- subscribers: internal.subscribers.filter(s => s.ref !== ref)
1287
- }
1288
- }));
1289
- };
1290
- }
1291
- }
1292
- };
1293
- }); // Resize camera and renderer on changes to size and pixelratio
1294
-
1295
- rootState.subscribe(() => {
1296
- const {
1297
- camera,
1298
- size,
1299
- viewport,
1300
- internal
1301
- } = rootState.getState(); // https://github.com/pmndrs/react-three-fiber/issues/92
1302
- // Do not mess with the camera if it belongs to the user
1303
-
1304
- if (!(internal.lastProps.camera instanceof THREE__namespace.Camera)) {
1305
- if (isOrthographicCamera(camera)) {
1306
- camera.left = size.width / -2;
1307
- camera.right = size.width / 2;
1308
- camera.top = size.height / 2;
1309
- camera.bottom = size.height / -2;
1310
- } else {
1311
- camera.aspect = size.width / size.height;
1312
- }
1313
-
1314
- camera.updateProjectionMatrix(); // https://github.com/pmndrs/react-three-fiber/issues/178
1315
- // Update matrix world since the renderer is a frame late
1316
-
1317
- camera.updateMatrixWorld();
1318
- } // Update renderer
1319
-
1320
-
1321
- gl.setPixelRatio(viewport.dpr);
1322
- gl.setSize(size.width, size.height);
1323
- }, state => [state.viewport.dpr, state.size], shallow__default['default']);
1324
- const state = rootState.getState(); // Update size
1325
-
1326
- if (size) state.setSize(size.width, size.height); // Invalidate on any change
1327
-
1328
- rootState.subscribe(state => invalidate(state)); // Return root state
1329
-
1330
- return rootState;
1331
- };
1332
-
1333
- function createSubs(callback, subs) {
1334
- const index = subs.length;
1335
- subs.push(callback);
1336
- return () => void subs.splice(index, 1);
1337
- }
1338
-
1339
- let i;
1340
- let globalEffects = [];
1341
- let globalAfterEffects = [];
1342
- let globalTailEffects = [];
1343
- const addEffect = callback => createSubs(callback, globalEffects);
1344
- const addAfterEffect = callback => createSubs(callback, globalAfterEffects);
1345
- const addTail = callback => createSubs(callback, globalTailEffects);
1346
-
1347
- function run(effects, timestamp) {
1348
- for (i = 0; i < effects.length; i++) effects[i](timestamp);
1349
- }
1350
-
1351
- function render$1(timestamp, state) {
1352
- // Run local effects
1353
- let delta = state.clock.getDelta(); // In frameloop='never' mode, clock times are updated using the provided timestamp
1354
-
1355
- if (state.frameloop === 'never' && typeof timestamp === 'number') {
1356
- delta = timestamp - state.clock.elapsedTime;
1357
- state.clock.oldTime = state.clock.elapsedTime;
1358
- state.clock.elapsedTime = timestamp;
1359
- } // Call subscribers (useFrame)
1360
-
1361
-
1362
- for (i = 0; i < state.internal.subscribers.length; i++) state.internal.subscribers[i].ref.current(state, delta); // Render content
1363
-
1364
-
1365
- if (!state.internal.priority && state.gl.render) state.gl.render(state.scene, state.camera); // Decrease frame count
1366
-
1367
- state.internal.frames = Math.max(0, state.internal.frames - 1);
1368
- return state.frameloop === 'always' ? 1 : state.internal.frames;
1369
- }
1370
-
1371
- function createLoop(roots) {
1372
- let running = false;
1373
- let repeat;
1374
-
1375
- function loop(timestamp) {
1376
- running = true;
1377
- repeat = 0; // Run effects
1378
-
1379
- run(globalEffects, timestamp); // Render all roots
1380
-
1381
- roots.forEach(root => {
1382
- const state = root.store.getState(); // If the frameloop is invalidated, do not run another frame
1383
-
1384
- if (state.internal.active && (state.frameloop === 'always' || state.internal.frames > 0)) repeat += render$1(timestamp, state);
1385
- }); // Run after-effects
1386
-
1387
- run(globalAfterEffects, timestamp); // Keep on looping if anything invalidates the frameloop
1388
-
1389
- if (repeat > 0) return requestAnimationFrame(loop); // Tail call effects, they are called when rendering stops
1390
- else run(globalTailEffects, timestamp); // Flag end of operation
1391
-
1392
- running = false;
1393
- }
1394
-
1395
- function invalidate(state) {
1396
- if (!state) return roots.forEach(root => invalidate(root.store.getState()));
1397
- if (state.vr || !state.internal.active || state.frameloop === 'never') return; // Increase frames, do not go higher than 60
1398
-
1399
- state.internal.frames = Math.min(60, state.internal.frames + 1); // If the render-loop isn't active, start it
1400
-
1401
- if (!running) {
1402
- running = true;
1403
- requestAnimationFrame(loop);
1404
- }
1405
- }
1406
-
1407
- function advance(timestamp, runGlobalEffects = true, state) {
1408
- if (runGlobalEffects) run(globalEffects, timestamp);
1409
- if (!state) roots.forEach(root => render$1(timestamp, root.store.getState()));else render$1(timestamp, state);
1410
- if (runGlobalEffects) run(globalAfterEffects, timestamp);
1411
- }
1412
-
1413
- return {
1414
- loop,
1415
- invalidate,
1416
- advance
1417
- };
1418
- }
1419
-
1420
86
  function createPointerEvents(store) {
1421
87
  const {
1422
88
  handlePointer
1423
- } = createEvents(store);
89
+ } = hooks.createEvents(store);
1424
90
  const names = {
1425
- onClick: ['click', false],
1426
- onContextMenu: ['contextmenu', false],
1427
- onDoubleClick: ['dblclick', false],
1428
- onWheel: ['wheel', true],
1429
- onPointerDown: ['pointerdown', true],
1430
- onPointerUp: ['pointerup', true],
1431
- onPointerLeave: ['pointerleave', true],
1432
- onPointerMove: ['pointermove', true],
1433
- onPointerCancel: ['pointercancel', true],
91
+ onClick: [CLICK, false],
92
+ onContextMenu: [CONTEXTMENU, false],
93
+ onDoubleClick: [DBLCLICK, false],
94
+ onWheel: [WHEEL, true],
95
+ onPointerDown: [POINTERDOWN, true],
96
+ onPointerUp: [POINTERUP, true],
97
+ onPointerLeave: [POINTERLEAVE, true],
98
+ onPointerMove: [POINTERMOVE, true],
99
+ onPointerCancel: [POINTERCANCEL, true],
1434
100
  onLostPointerCapture: ['lostpointercapture', true]
1435
101
  };
1436
102
  return {
@@ -1483,9 +149,10 @@ function createPointerEvents(store) {
1483
149
  };
1484
150
  }
1485
151
 
1486
- // React currently throws a warning when using useLayoutEffect on the server.
152
+ const CANVAS_PROPS = ['gl', 'events', 'size', 'shadows', 'linear', 'flat', 'orthographic', 'frameloop', 'dpr', 'performance', 'clock', 'raycaster', 'camera', 'onPointerMissed', 'onCreated']; // React currently throws a warning when using useLayoutEffect on the server.
1487
153
  // To get around it, we can conditionally useEffect on the server (no-op) and
1488
154
  // useLayoutEffect in the browser.
155
+
1489
156
  const useIsomorphicLayoutEffect = typeof window !== 'undefined' ? React__namespace.useLayoutEffect : React__namespace.useEffect;
1490
157
 
1491
158
  function Block({
@@ -1523,15 +190,17 @@ ErrorBoundary.getDerivedStateFromError = () => ({
1523
190
  const Canvas = /*#__PURE__*/React__namespace.forwardRef(function Canvas({
1524
191
  children,
1525
192
  fallback,
1526
- tabIndex,
1527
193
  resize,
1528
- id,
1529
194
  style,
1530
- className,
1531
195
  events,
1532
196
  ...props
1533
197
  }, forwardedRef) {
1534
- const [containerRef, size] = useMeasure__default['default']({
198
+ const canvasProps = pick__default["default"](props, CANVAS_PROPS);
199
+ const divProps = omit__default["default"](props, CANVAS_PROPS);
200
+ const [containerRef, {
201
+ width,
202
+ height
203
+ }] = useMeasure__default["default"]({
1535
204
  scroll: true,
1536
205
  debounce: {
1537
206
  scroll: 50,
@@ -1548,28 +217,28 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(function Canvas({
1548
217
  if (error) throw error; // Execute JSX in the reconciler as a layout-effect
1549
218
 
1550
219
  useIsomorphicLayoutEffect(() => {
1551
- if (size.width > 0 && size.height > 0) {
220
+ if (width > 0 && height > 0) {
1552
221
  render( /*#__PURE__*/React__namespace.createElement(ErrorBoundary, {
1553
222
  set: setError
1554
223
  }, /*#__PURE__*/React__namespace.createElement(React__namespace.Suspense, {
1555
224
  fallback: /*#__PURE__*/React__namespace.createElement(Block, {
1556
225
  set: setBlock
1557
226
  })
1558
- }, children)), canvasRef.current, { ...props,
1559
- size,
227
+ }, children)), canvasRef.current, { ...canvasProps,
228
+ size: {
229
+ width,
230
+ height
231
+ },
1560
232
  events: events || createPointerEvents
1561
233
  });
1562
234
  }
1563
- }, [size, children]);
235
+ }, [width, height, children, canvasProps]);
1564
236
  React__namespace.useEffect(() => {
1565
237
  const container = canvasRef.current;
1566
238
  return () => unmountComponentAtNode(container);
1567
239
  }, []);
1568
- return /*#__PURE__*/React__namespace.createElement("div", {
240
+ return /*#__PURE__*/React__namespace.createElement("div", _extends({
1569
241
  ref: containerRef,
1570
- id: id,
1571
- className: className,
1572
- tabIndex: tabIndex,
1573
242
  style: {
1574
243
  position: 'relative',
1575
244
  width: '100%',
@@ -1577,110 +246,48 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(function Canvas({
1577
246
  overflow: 'hidden',
1578
247
  ...style
1579
248
  }
1580
- }, /*#__PURE__*/React__namespace.createElement("canvas", {
1581
- ref: mergeRefs__default['default']([canvasRef, forwardedRef]),
249
+ }, divProps), /*#__PURE__*/React__namespace.createElement("canvas", {
250
+ ref: mergeRefs__default["default"]([canvasRef, forwardedRef]),
1582
251
  style: {
1583
252
  display: 'block'
1584
253
  }
1585
254
  }, fallback));
1586
255
  });
1587
256
 
1588
- function useStore() {
1589
- const store = React__namespace.useContext(context);
1590
- if (!store) throw `R3F hooks can only be used within the Canvas component!`;
1591
- return store;
1592
- }
1593
- function useThree(selector = state => state, equalityFn) {
1594
- return useStore()(selector, equalityFn);
1595
- }
1596
- function useFrame(callback, renderPriority = 0) {
1597
- const {
1598
- subscribe
1599
- } = useStore().getState().internal; // Update ref
1600
-
1601
- const ref = React__namespace.useRef(callback);
1602
- React__namespace.useLayoutEffect(() => void (ref.current = callback), [callback]); // Subscribe/unsub
1603
-
1604
- React__namespace.useLayoutEffect(() => {
1605
- const unsubscribe = subscribe(ref, renderPriority);
1606
- return () => unsubscribe();
1607
- }, [renderPriority, subscribe]);
1608
- return null;
1609
- }
1610
-
1611
- function buildGraph(object) {
1612
- const data = {
1613
- nodes: {},
1614
- materials: {}
1615
- };
1616
-
1617
- if (object) {
1618
- object.traverse(obj => {
1619
- if (obj.name) {
1620
- data.nodes[obj.name] = obj;
1621
- }
1622
-
1623
- if (obj.material && !data.materials[obj.material.name]) {
1624
- data.materials[obj.material.name] = obj.material;
1625
- }
1626
- });
1627
- }
1628
-
1629
- return data;
1630
- }
1631
-
1632
- function useGraph(object) {
1633
- return React__namespace.useMemo(() => buildGraph(object), [object]);
1634
- }
1635
-
1636
- function loadingFn(extensions, onProgress) {
1637
- return function (Proto, ...input) {
1638
- // Construct new loader and run extensions
1639
- const loader = new Proto();
1640
- if (extensions) extensions(loader); // Go through the urls and load them
1641
-
1642
- return Promise.all(input.map(input => new Promise((res, reject) => loader.load(input, data => {
1643
- if (data.scene) Object.assign(data, buildGraph(data.scene));
1644
- res(data);
1645
- }, onProgress, error => reject(`Could not load ${input}: ${error.message}`)))));
1646
- };
1647
- }
1648
-
1649
- function useLoader(Proto, input, extensions, onProgress) {
1650
- // Use suspense to load async assets
1651
- const keys = Array.isArray(input) ? input : [input];
1652
- const results = useAsset.useAsset(loadingFn(extensions, onProgress), Proto, ...keys); // Return the object/s
1653
-
1654
- return Array.isArray(input) ? results : results[0];
1655
- }
1656
-
1657
- useLoader.preload = function (Proto, input, extensions) {
1658
- const keys = Array.isArray(input) ? input : [input];
1659
- return useAsset.useAsset.preload(loadingFn(extensions), Proto, ...keys);
1660
- };
1661
-
1662
- useLoader.clear = function (Proto, input) {
1663
- const keys = Array.isArray(input) ? input : [input];
1664
- return useAsset.useAsset.clear(Proto, ...keys);
1665
- };
1666
-
1667
257
  const roots = new Map();
1668
258
  const {
1669
259
  invalidate,
1670
260
  advance
1671
- } = createLoop(roots);
261
+ } = hooks.createLoop(roots);
1672
262
  const {
1673
263
  reconciler,
1674
264
  applyProps
1675
- } = createRenderer();
265
+ } = hooks.createRenderer(roots, getEventPriority);
266
+
267
+ const createRendererInstance = (gl, canvas) => {
268
+ const customRenderer = typeof gl === 'function' ? gl(canvas) : gl;
269
+ if (hooks.isRenderer(customRenderer)) return customRenderer;
270
+ const renderer = new THREE__namespace.WebGLRenderer({
271
+ powerPreference: 'high-performance',
272
+ canvas: canvas,
273
+ antialias: true,
274
+ alpha: true,
275
+ ...gl
276
+ }); // Set color management
277
+
278
+ renderer.outputEncoding = THREE__namespace.sRGBEncoding;
279
+ renderer.toneMapping = THREE__namespace.ACESFilmicToneMapping; // Set gl props
280
+
281
+ if (gl) applyProps(renderer, gl);
282
+ return renderer;
283
+ };
1676
284
 
1677
- const createRendererInstance = (gl, canvas) => isRenderer(gl) ? gl : new THREE__namespace.WebGLRenderer({
1678
- powerPreference: 'high-performance',
1679
- canvas: canvas,
1680
- antialias: true,
1681
- alpha: true,
1682
- ...gl
1683
- });
285
+ function createRoot(canvas, config) {
286
+ return {
287
+ render: element => render(element, canvas, config),
288
+ unmount: () => unmountComponentAtNode(canvas)
289
+ };
290
+ }
1684
291
 
1685
292
  function render(element, canvas, {
1686
293
  gl,
@@ -1707,15 +314,14 @@ function render(element, canvas, {
1707
314
  let state = (_store = store) == null ? void 0 : _store.getState();
1708
315
 
1709
316
  if (fiber && state) {
1710
- const lastProps = state.internal.lastProps; // When a root was found, see if any fundamental props must be changed or exchanged
317
+ // When a root was found, see if any fundamental props must be changed or exchanged
1711
318
  // Check pixelratio
319
+ if (props.dpr !== undefined && state.viewport.dpr !== hooks.calculateDpr(props.dpr)) state.setDpr(props.dpr); // Check size
1712
320
 
1713
- if (props.dpr !== undefined && !is.equ(lastProps.dpr, props.dpr)) state.setDpr(props.dpr); // Check size
1714
-
1715
- if (!is.equ(lastProps.size, size)) state.setSize(size.width, size.height); // For some props we want to reset the entire root
321
+ if (state.size.width !== size.width || state.size.height !== size.height) state.setSize(size.width, size.height); // For some props we want to reset the entire root
1716
322
  // Changes to the color-space
1717
323
 
1718
- const linearChanged = props.linear !== lastProps.linear;
324
+ const linearChanged = props.linear !== state.internal.lastProps.linear;
1719
325
 
1720
326
  if (linearChanged) {
1721
327
  unmountComponentAtNode(canvas);
@@ -1726,15 +332,9 @@ function render(element, canvas, {
1726
332
  if (!fiber) {
1727
333
  // If no root has been found, make one
1728
334
  // Create gl
1729
- const glRenderer = createRendererInstance(gl, canvas); // Enable VR if requested
1730
-
1731
- if (props.vr) {
1732
- glRenderer.xr.enabled = true;
1733
- glRenderer.setAnimationLoop(timestamp => advance(timestamp, true));
1734
- } // Create store
335
+ const glRenderer = createRendererInstance(gl, canvas); // Create store
1735
336
 
1736
-
1737
- store = createStore(applyProps, invalidate, advance, {
337
+ store = hooks.createStore(applyProps, invalidate, advance, {
1738
338
  gl: glRenderer,
1739
339
  size,
1740
340
  ...props
@@ -1783,9 +383,9 @@ function Provider({
1783
383
 
1784
384
  state.events.connect == null ? void 0 : state.events.connect(target); // Notifiy that init is completed, the scene graph exists, but nothing has yet rendered
1785
385
 
1786
- if (onCreated) onCreated(state);
386
+ if (onCreated) onCreated(state); // eslint-disable-next-line react-hooks/exhaustive-deps
1787
387
  }, []);
1788
- return /*#__PURE__*/React__namespace.createElement(context.Provider, {
388
+ return /*#__PURE__*/React__namespace.createElement(hooks.context.Provider, {
1789
389
  value: store
1790
390
  }, element);
1791
391
  }
@@ -1800,70 +400,58 @@ function unmountComponentAtNode(canvas, callback) {
1800
400
  reconciler.updateContainer(null, fiber, null, () => {
1801
401
  if (state) {
1802
402
  setTimeout(() => {
1803
- var _state$gl, _state$gl$renderLists, _state$gl2;
1804
-
1805
- state.events.disconnect == null ? void 0 : state.events.disconnect();
1806
- (_state$gl = state.gl) == null ? void 0 : (_state$gl$renderLists = _state$gl.renderLists) == null ? void 0 : _state$gl$renderLists.dispose == null ? void 0 : _state$gl$renderLists.dispose();
1807
- (_state$gl2 = state.gl) == null ? void 0 : _state$gl2.forceContextLoss == null ? void 0 : _state$gl2.forceContextLoss();
1808
- dispose(state);
1809
- roots.delete(canvas);
1810
- if (callback) callback(canvas);
403
+ try {
404
+ var _state$gl, _state$gl$renderLists, _state$gl2, _state$gl3;
405
+
406
+ state.events.disconnect == null ? void 0 : state.events.disconnect();
407
+ (_state$gl = state.gl) == null ? void 0 : (_state$gl$renderLists = _state$gl.renderLists) == null ? void 0 : _state$gl$renderLists.dispose == null ? void 0 : _state$gl$renderLists.dispose();
408
+ (_state$gl2 = state.gl) == null ? void 0 : _state$gl2.forceContextLoss == null ? void 0 : _state$gl2.forceContextLoss();
409
+ if ((_state$gl3 = state.gl) != null && _state$gl3.xr) state.internal.xr.disconnect();
410
+ hooks.dispose(state);
411
+ roots.delete(canvas);
412
+ if (callback) callback(canvas);
413
+ } catch (e) {
414
+ /* ... */
415
+ }
1811
416
  }, 500);
1812
417
  }
1813
418
  });
1814
419
  }
1815
420
  }
1816
421
 
1817
- function dispose(obj) {
1818
- if (obj.dispose && obj.type !== 'Scene') obj.dispose();
1819
-
1820
- for (const p in obj) {
1821
- var _dispose, _ref;
1822
- (_dispose = (_ref = p).dispose) == null ? void 0 : _dispose.call(_ref);
1823
- delete obj[p];
1824
- }
1825
- }
1826
-
1827
422
  const act = reconciler.act;
1828
- const hasSymbol = is.fun(Symbol) && Symbol.for;
1829
- const REACT_PORTAL_TYPE = hasSymbol ? Symbol.for('react.portal') : 0xeaca;
1830
423
 
1831
- function createPortal(children, container, implementation, key = null) {
1832
- return {
1833
- $$typeof: REACT_PORTAL_TYPE,
1834
- key: key == null ? null : '' + key,
1835
- children,
1836
- containerInfo: prepare(container),
1837
- implementation
1838
- };
424
+ function createPortal(children, container) {
425
+ return reconciler.createPortal(children, container, null, null);
1839
426
  }
1840
427
 
1841
428
  reconciler.injectIntoDevTools({
1842
429
  bundleType: process.env.NODE_ENV === 'production' ? 0 : 1,
1843
430
  rendererPackageName: '@react-three/fiber',
1844
- version: '17.0.2'
431
+ version: '18.0.0'
1845
432
  });
1846
433
 
434
+ exports.ReactThreeFiber = hooks.threeTypes;
435
+ exports.addAfterEffect = hooks.addAfterEffect;
436
+ exports.addEffect = hooks.addEffect;
437
+ exports.addTail = hooks.addTail;
438
+ exports.context = hooks.context;
439
+ exports.dispose = hooks.dispose;
440
+ exports.extend = hooks.extend;
441
+ exports.useFrame = hooks.useFrame;
442
+ exports.useGraph = hooks.useGraph;
443
+ exports.useLoader = hooks.useLoader;
444
+ exports.useStore = hooks.useStore;
445
+ exports.useThree = hooks.useThree;
1847
446
  exports.Canvas = Canvas;
1848
- exports.ReactThreeFiber = threeTypes;
1849
447
  exports._roots = roots;
1850
448
  exports.act = act;
1851
- exports.addAfterEffect = addAfterEffect;
1852
- exports.addEffect = addEffect;
1853
- exports.addTail = addTail;
1854
449
  exports.advance = advance;
1855
450
  exports.applyProps = applyProps;
1856
- exports.context = context;
1857
451
  exports.createPortal = createPortal;
1858
- exports.dispose = dispose;
452
+ exports.createRoot = createRoot;
1859
453
  exports.events = createPointerEvents;
1860
- exports.extend = extend;
1861
454
  exports.invalidate = invalidate;
1862
455
  exports.reconciler = reconciler;
1863
456
  exports.render = render;
1864
457
  exports.unmountComponentAtNode = unmountComponentAtNode;
1865
- exports.useFrame = useFrame;
1866
- exports.useGraph = useGraph;
1867
- exports.useLoader = useLoader;
1868
- exports.useStore = useStore;
1869
- exports.useThree = useThree;