@react-three/fiber 7.0.12 → 7.0.13

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 CHANGED
@@ -1,5 +1,12 @@
1
1
  # @react-three/fiber
2
2
 
3
+ ## 7.0.13
4
+
5
+ ### Patch Changes
6
+
7
+ - f256558: fix(core): don't overwrite camera rotation
8
+ - 51e6fc9: fix(core): safely handle external instances
9
+
3
10
  ## 7.0.12
4
11
 
5
12
  ### Patch Changes
@@ -133,7 +133,11 @@ function createEvents(store) {
133
133
 
134
134
 
135
135
  function filterPointerEvents(objects) {
136
- return objects.filter(obj => ['Move', 'Over', 'Enter', 'Out', 'Leave'].some(name => obj.__r3f.handlers['onPointer' + name]));
136
+ return objects.filter(obj => ['Move', 'Over', 'Enter', 'Out', 'Leave'].some(name => {
137
+ var _r3f;
138
+
139
+ return (_r3f = obj.__r3f) == null ? void 0 : _r3f.handlers['onPointer' + name];
140
+ }));
137
141
  }
138
142
 
139
143
  function intersect(filter) {
@@ -163,7 +167,9 @@ function createEvents(store) {
163
167
  let eventObject = intersect.object; // Bubble event up
164
168
 
165
169
  while (eventObject) {
166
- if (eventObject.__r3f.handlers.count) intersections.push({ ...intersect,
170
+ var _r3f2;
171
+
172
+ if ((_r3f2 = eventObject.__r3f) != null && _r3f2.handlers.count) intersections.push({ ...intersect,
167
173
  eventObject
168
174
  });
169
175
  eventObject = eventObject.parent;
@@ -300,11 +306,13 @@ function createEvents(store) {
300
306
  // When no objects were hit or the the hovered object wasn't found underneath the cursor
301
307
  // we call onPointerOut and delete the object from the hovered-elements map
302
308
  if (!hits.length || !hits.find(hit => hit.object === hoveredObj.object && hit.index === hoveredObj.index && hit.instanceId === hoveredObj.instanceId)) {
309
+ var _r3f3;
310
+
303
311
  const eventObject = hoveredObj.eventObject;
304
- const handlers = eventObject.__r3f.handlers;
312
+ const handlers = (_r3f3 = eventObject.__r3f) == null ? void 0 : _r3f3.handlers;
305
313
  internal.hovered.delete(makeId(hoveredObj));
306
314
 
307
- if (handlers.count) {
315
+ if (handlers != null && handlers.count) {
308
316
  // Clear out intersects, they are outdated by now
309
317
  const data = { ...hoveredObj,
310
318
  intersections: hits || []
@@ -367,10 +375,12 @@ function createEvents(store) {
367
375
 
368
376
  if (isPointerMove) cancelPointer(hits);
369
377
  handleIntersects(hits, event, delta, data => {
378
+ var _r3f4;
379
+
370
380
  const eventObject = data.eventObject;
371
- const handlers = eventObject.__r3f.handlers; // Check presence of handlers
381
+ const handlers = (_r3f4 = eventObject.__r3f) == null ? void 0 : _r3f4.handlers; // Check presence of handlers
372
382
 
373
- if (!handlers.count) return;
383
+ if (!(handlers != null && handlers.count)) return;
374
384
 
375
385
  if (isPointerMove) {
376
386
  // Move event ...
@@ -413,9 +423,9 @@ function createEvents(store) {
413
423
 
414
424
  function pointerMissed(event, objects) {
415
425
  objects.forEach(object => {
416
- var _r3f$handlers$onPoin, _r3f$handlers;
426
+ var _r3f5;
417
427
 
418
- return (_r3f$handlers$onPoin = (_r3f$handlers = object.__r3f.handlers).onPointerMissed) == null ? void 0 : _r3f$handlers$onPoin.call(_r3f$handlers, event);
428
+ return (_r3f5 = object.__r3f) == null ? void 0 : _r3f5.handlers.onPointerMissed == null ? void 0 : _r3f5.handlers.onPointerMissed(event);
419
429
  });
420
430
  }
421
431
 
@@ -779,13 +789,13 @@ function createRenderer(roots) {
779
789
 
780
790
  function removeChild(parentInstance, child, dispose) {
781
791
  if (child) {
782
- var _child$__r3f2;
792
+ var _parentInstance$__r3f, _child$__r3f2;
783
793
 
784
794
  if (child.__r3f) {
785
795
  child.__r3f.parent = null;
786
796
  }
787
797
 
788
- if (parentInstance.__r3f.objects) {
798
+ if ((_parentInstance$__r3f = parentInstance.__r3f) != null && _parentInstance$__r3f.objects) {
789
799
  parentInstance.__r3f.objects = parentInstance.__r3f.objects.filter(x => x !== child);
790
800
  } // Remove attachment
791
801
 
@@ -1083,7 +1093,7 @@ const createStore = (applyProps, invalidate, advance, props) => {
1083
1093
  camera.position.z = 5;
1084
1094
  if (cameraOptions) applyProps(camera, cameraOptions); // Always look at center by default
1085
1095
 
1086
- camera.lookAt(0, 0, 0);
1096
+ if (!(cameraOptions != null && cameraOptions.rotation)) camera.lookAt(0, 0, 0);
1087
1097
  }
1088
1098
 
1089
1099
  const initialDpr = calculateDpr(dpr);
@@ -133,7 +133,11 @@ function createEvents(store) {
133
133
 
134
134
 
135
135
  function filterPointerEvents(objects) {
136
- return objects.filter(obj => ['Move', 'Over', 'Enter', 'Out', 'Leave'].some(name => obj.__r3f.handlers['onPointer' + name]));
136
+ return objects.filter(obj => ['Move', 'Over', 'Enter', 'Out', 'Leave'].some(name => {
137
+ var _r3f;
138
+
139
+ return (_r3f = obj.__r3f) == null ? void 0 : _r3f.handlers['onPointer' + name];
140
+ }));
137
141
  }
138
142
 
139
143
  function intersect(filter) {
@@ -163,7 +167,9 @@ function createEvents(store) {
163
167
  let eventObject = intersect.object; // Bubble event up
164
168
 
165
169
  while (eventObject) {
166
- if (eventObject.__r3f.handlers.count) intersections.push({ ...intersect,
170
+ var _r3f2;
171
+
172
+ if ((_r3f2 = eventObject.__r3f) != null && _r3f2.handlers.count) intersections.push({ ...intersect,
167
173
  eventObject
168
174
  });
169
175
  eventObject = eventObject.parent;
@@ -300,11 +306,13 @@ function createEvents(store) {
300
306
  // When no objects were hit or the the hovered object wasn't found underneath the cursor
301
307
  // we call onPointerOut and delete the object from the hovered-elements map
302
308
  if (!hits.length || !hits.find(hit => hit.object === hoveredObj.object && hit.index === hoveredObj.index && hit.instanceId === hoveredObj.instanceId)) {
309
+ var _r3f3;
310
+
303
311
  const eventObject = hoveredObj.eventObject;
304
- const handlers = eventObject.__r3f.handlers;
312
+ const handlers = (_r3f3 = eventObject.__r3f) == null ? void 0 : _r3f3.handlers;
305
313
  internal.hovered.delete(makeId(hoveredObj));
306
314
 
307
- if (handlers.count) {
315
+ if (handlers != null && handlers.count) {
308
316
  // Clear out intersects, they are outdated by now
309
317
  const data = { ...hoveredObj,
310
318
  intersections: hits || []
@@ -367,10 +375,12 @@ function createEvents(store) {
367
375
 
368
376
  if (isPointerMove) cancelPointer(hits);
369
377
  handleIntersects(hits, event, delta, data => {
378
+ var _r3f4;
379
+
370
380
  const eventObject = data.eventObject;
371
- const handlers = eventObject.__r3f.handlers; // Check presence of handlers
381
+ const handlers = (_r3f4 = eventObject.__r3f) == null ? void 0 : _r3f4.handlers; // Check presence of handlers
372
382
 
373
- if (!handlers.count) return;
383
+ if (!(handlers != null && handlers.count)) return;
374
384
 
375
385
  if (isPointerMove) {
376
386
  // Move event ...
@@ -413,9 +423,9 @@ function createEvents(store) {
413
423
 
414
424
  function pointerMissed(event, objects) {
415
425
  objects.forEach(object => {
416
- var _r3f$handlers$onPoin, _r3f$handlers;
426
+ var _r3f5;
417
427
 
418
- return (_r3f$handlers$onPoin = (_r3f$handlers = object.__r3f.handlers).onPointerMissed) == null ? void 0 : _r3f$handlers$onPoin.call(_r3f$handlers, event);
428
+ return (_r3f5 = object.__r3f) == null ? void 0 : _r3f5.handlers.onPointerMissed == null ? void 0 : _r3f5.handlers.onPointerMissed(event);
419
429
  });
420
430
  }
421
431
 
@@ -779,13 +789,13 @@ function createRenderer(roots) {
779
789
 
780
790
  function removeChild(parentInstance, child, dispose) {
781
791
  if (child) {
782
- var _child$__r3f2;
792
+ var _parentInstance$__r3f, _child$__r3f2;
783
793
 
784
794
  if (child.__r3f) {
785
795
  child.__r3f.parent = null;
786
796
  }
787
797
 
788
- if (parentInstance.__r3f.objects) {
798
+ if ((_parentInstance$__r3f = parentInstance.__r3f) != null && _parentInstance$__r3f.objects) {
789
799
  parentInstance.__r3f.objects = parentInstance.__r3f.objects.filter(x => x !== child);
790
800
  } // Remove attachment
791
801
 
@@ -1083,7 +1093,7 @@ const createStore = (applyProps, invalidate, advance, props) => {
1083
1093
  camera.position.z = 5;
1084
1094
  if (cameraOptions) applyProps(camera, cameraOptions); // Always look at center by default
1085
1095
 
1086
- camera.lookAt(0, 0, 0);
1096
+ if (!(cameraOptions != null && cameraOptions.rotation)) camera.lookAt(0, 0, 0);
1087
1097
  }
1088
1098
 
1089
1099
  const initialDpr = calculateDpr(dpr);
@@ -99,7 +99,11 @@ function createEvents(store) {
99
99
 
100
100
 
101
101
  function filterPointerEvents(objects) {
102
- return objects.filter(obj => ['Move', 'Over', 'Enter', 'Out', 'Leave'].some(name => obj.__r3f.handlers['onPointer' + name]));
102
+ return objects.filter(obj => ['Move', 'Over', 'Enter', 'Out', 'Leave'].some(name => {
103
+ var _r3f;
104
+
105
+ return (_r3f = obj.__r3f) == null ? void 0 : _r3f.handlers['onPointer' + name];
106
+ }));
103
107
  }
104
108
 
105
109
  function intersect(filter) {
@@ -129,7 +133,9 @@ function createEvents(store) {
129
133
  let eventObject = intersect.object; // Bubble event up
130
134
 
131
135
  while (eventObject) {
132
- if (eventObject.__r3f.handlers.count) intersections.push({ ...intersect,
136
+ var _r3f2;
137
+
138
+ if ((_r3f2 = eventObject.__r3f) != null && _r3f2.handlers.count) intersections.push({ ...intersect,
133
139
  eventObject
134
140
  });
135
141
  eventObject = eventObject.parent;
@@ -266,11 +272,13 @@ function createEvents(store) {
266
272
  // When no objects were hit or the the hovered object wasn't found underneath the cursor
267
273
  // we call onPointerOut and delete the object from the hovered-elements map
268
274
  if (!hits.length || !hits.find(hit => hit.object === hoveredObj.object && hit.index === hoveredObj.index && hit.instanceId === hoveredObj.instanceId)) {
275
+ var _r3f3;
276
+
269
277
  const eventObject = hoveredObj.eventObject;
270
- const handlers = eventObject.__r3f.handlers;
278
+ const handlers = (_r3f3 = eventObject.__r3f) == null ? void 0 : _r3f3.handlers;
271
279
  internal.hovered.delete(makeId(hoveredObj));
272
280
 
273
- if (handlers.count) {
281
+ if (handlers != null && handlers.count) {
274
282
  // Clear out intersects, they are outdated by now
275
283
  const data = { ...hoveredObj,
276
284
  intersections: hits || []
@@ -333,10 +341,12 @@ function createEvents(store) {
333
341
 
334
342
  if (isPointerMove) cancelPointer(hits);
335
343
  handleIntersects(hits, event, delta, data => {
344
+ var _r3f4;
345
+
336
346
  const eventObject = data.eventObject;
337
- const handlers = eventObject.__r3f.handlers; // Check presence of handlers
347
+ const handlers = (_r3f4 = eventObject.__r3f) == null ? void 0 : _r3f4.handlers; // Check presence of handlers
338
348
 
339
- if (!handlers.count) return;
349
+ if (!(handlers != null && handlers.count)) return;
340
350
 
341
351
  if (isPointerMove) {
342
352
  // Move event ...
@@ -379,9 +389,9 @@ function createEvents(store) {
379
389
 
380
390
  function pointerMissed(event, objects) {
381
391
  objects.forEach(object => {
382
- var _r3f$handlers$onPoin, _r3f$handlers;
392
+ var _r3f5;
383
393
 
384
- return (_r3f$handlers$onPoin = (_r3f$handlers = object.__r3f.handlers).onPointerMissed) == null ? void 0 : _r3f$handlers$onPoin.call(_r3f$handlers, event);
394
+ return (_r3f5 = object.__r3f) == null ? void 0 : _r3f5.handlers.onPointerMissed == null ? void 0 : _r3f5.handlers.onPointerMissed(event);
385
395
  });
386
396
  }
387
397
 
@@ -745,13 +755,13 @@ function createRenderer(roots) {
745
755
 
746
756
  function removeChild(parentInstance, child, dispose) {
747
757
  if (child) {
748
- var _child$__r3f2;
758
+ var _parentInstance$__r3f, _child$__r3f2;
749
759
 
750
760
  if (child.__r3f) {
751
761
  child.__r3f.parent = null;
752
762
  }
753
763
 
754
- if (parentInstance.__r3f.objects) {
764
+ if ((_parentInstance$__r3f = parentInstance.__r3f) != null && _parentInstance$__r3f.objects) {
755
765
  parentInstance.__r3f.objects = parentInstance.__r3f.objects.filter(x => x !== child);
756
766
  } // Remove attachment
757
767
 
@@ -1049,7 +1059,7 @@ const createStore = (applyProps, invalidate, advance, props) => {
1049
1059
  camera.position.z = 5;
1050
1060
  if (cameraOptions) applyProps(camera, cameraOptions); // Always look at center by default
1051
1061
 
1052
- camera.lookAt(0, 0, 0);
1062
+ if (!(cameraOptions != null && cameraOptions.rotation)) camera.lookAt(0, 0, 0);
1053
1063
  }
1054
1064
 
1055
1065
  const initialDpr = calculateDpr(dpr);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-three/fiber",
3
- "version": "7.0.12",
3
+ "version": "7.0.13",
4
4
  "description": "A React renderer for Threejs",
5
5
  "keywords": [
6
6
  "react",