@react-three/fiber 8.15.5 → 8.15.7

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,17 @@
1
1
  # @react-three/fiber
2
2
 
3
+ ## 8.15.7
4
+
5
+ ### Patch Changes
6
+
7
+ - 07e39e2e: fix(types): remove use of Object3D generic
8
+
9
+ ## 8.15.6
10
+
11
+ ### Patch Changes
12
+
13
+ - 7bb2950b: experiment: stable object sort
14
+
3
15
  ## 8.15.5
4
16
 
5
17
  ### Patch Changes
@@ -86,7 +86,7 @@ export interface PointerCaptureTarget {
86
86
  intersection: Intersection;
87
87
  target: Element;
88
88
  }
89
- export declare function getEventPriority(): 1 | 16 | 4;
89
+ export declare function getEventPriority(): 1 | 4 | 16;
90
90
  export declare function removeInteractivity(store: UseBoundStore<RootState>, object: THREE.Object3D): void;
91
91
  export declare function createEvents(store: UseBoundStore<RootState>): {
92
92
  handlePointer: (name: string) => (event: DomEvent) => void;
@@ -10,7 +10,7 @@ export declare type _XRFrame = THREE.WebGLRenderTargetOptions extends {
10
10
  /**
11
11
  * Returns `true` with correct TS type inference if an object has a configurable color space (since r152).
12
12
  */
13
- export declare const hasColorSpace: <T extends object | Renderer | THREE.Texture, P = T extends Renderer ? {
13
+ export declare const hasColorSpace: <T extends object | THREE.Texture | Renderer, P = T extends Renderer ? {
14
14
  outputColorSpace: string;
15
15
  } : {
16
16
  colorSpace: string;
@@ -127,7 +127,11 @@ function createRenderer(_roots, _getEventPriority) {
127
127
  parentInstance.children = [...restSiblings.slice(0, index), child, ...restSiblings.slice(index)];
128
128
  added = true;
129
129
  }
130
- if (!added) (_parentInstance$__r3f2 = parentInstance.__r3f) == null ? void 0 : _parentInstance$__r3f2.objects.push(child);
130
+ const objects = (_parentInstance$__r3f2 = parentInstance.__r3f) == null ? void 0 : _parentInstance$__r3f2.objects;
131
+ if (!added && objects) {
132
+ const index = objects.indexOf(beforeChild);
133
+ if (index !== -1) objects.splice(index, 0, child);else objects.push(child);
134
+ }
131
135
  if (!child.__r3f) prepare(child, {});
132
136
  child.__r3f.parent = parentInstance;
133
137
  updateInstance(child);
@@ -143,7 +147,11 @@ function createRenderer(_roots, _getEventPriority) {
143
147
  // Clear the parent reference
144
148
  if (child.__r3f) child.__r3f.parent = null;
145
149
  // Remove child from the parents objects
146
- if ((_parentInstance$__r3f3 = parentInstance.__r3f) != null && _parentInstance$__r3f3.objects) parentInstance.__r3f.objects = parentInstance.__r3f.objects.filter(x => x !== child);
150
+ const objects = (_parentInstance$__r3f3 = parentInstance.__r3f) == null ? void 0 : _parentInstance$__r3f3.objects;
151
+ if (objects) {
152
+ const index = objects.indexOf(child);
153
+ if (index !== -1) objects.splice(index, 1);
154
+ }
147
155
  // Remove attachment
148
156
  if ((_child$__r3f3 = child.__r3f) != null && _child$__r3f3.attach) {
149
157
  detach(parentInstance, child, child.__r3f.attach);
@@ -209,13 +217,14 @@ function createRenderer(_roots, _getEventPriority) {
209
217
  }
210
218
  instance.__r3f.objects.forEach(child => appendChild(newInstance, child));
211
219
  instance.__r3f.objects = [];
220
+ const autoRemovedBeforeAppend = !!newInstance.parent;
212
221
  if (!instance.__r3f.autoRemovedBeforeAppend) {
222
+ insertBefore(parent, newInstance, instance);
213
223
  removeChild(parent, instance);
224
+ } else {
225
+ appendChild(parent, newInstance);
214
226
  }
215
- if (newInstance.parent) {
216
- newInstance.__r3f.autoRemovedBeforeAppend = true;
217
- }
218
- appendChild(parent, newInstance);
227
+ newInstance.__r3f.autoRemovedBeforeAppend = autoRemovedBeforeAppend;
219
228
 
220
229
  // Re-bind event handlers
221
230
  if (newInstance.raycast && newInstance.__r3f.eventCount) {
@@ -127,7 +127,11 @@ function createRenderer(_roots, _getEventPriority) {
127
127
  parentInstance.children = [...restSiblings.slice(0, index), child, ...restSiblings.slice(index)];
128
128
  added = true;
129
129
  }
130
- if (!added) (_parentInstance$__r3f2 = parentInstance.__r3f) == null ? void 0 : _parentInstance$__r3f2.objects.push(child);
130
+ const objects = (_parentInstance$__r3f2 = parentInstance.__r3f) == null ? void 0 : _parentInstance$__r3f2.objects;
131
+ if (!added && objects) {
132
+ const index = objects.indexOf(beforeChild);
133
+ if (index !== -1) objects.splice(index, 0, child);else objects.push(child);
134
+ }
131
135
  if (!child.__r3f) prepare(child, {});
132
136
  child.__r3f.parent = parentInstance;
133
137
  updateInstance(child);
@@ -143,7 +147,11 @@ function createRenderer(_roots, _getEventPriority) {
143
147
  // Clear the parent reference
144
148
  if (child.__r3f) child.__r3f.parent = null;
145
149
  // Remove child from the parents objects
146
- if ((_parentInstance$__r3f3 = parentInstance.__r3f) != null && _parentInstance$__r3f3.objects) parentInstance.__r3f.objects = parentInstance.__r3f.objects.filter(x => x !== child);
150
+ const objects = (_parentInstance$__r3f3 = parentInstance.__r3f) == null ? void 0 : _parentInstance$__r3f3.objects;
151
+ if (objects) {
152
+ const index = objects.indexOf(child);
153
+ if (index !== -1) objects.splice(index, 1);
154
+ }
147
155
  // Remove attachment
148
156
  if ((_child$__r3f3 = child.__r3f) != null && _child$__r3f3.attach) {
149
157
  detach(parentInstance, child, child.__r3f.attach);
@@ -209,13 +217,14 @@ function createRenderer(_roots, _getEventPriority) {
209
217
  }
210
218
  instance.__r3f.objects.forEach(child => appendChild(newInstance, child));
211
219
  instance.__r3f.objects = [];
220
+ const autoRemovedBeforeAppend = !!newInstance.parent;
212
221
  if (!instance.__r3f.autoRemovedBeforeAppend) {
222
+ insertBefore(parent, newInstance, instance);
213
223
  removeChild(parent, instance);
224
+ } else {
225
+ appendChild(parent, newInstance);
214
226
  }
215
- if (newInstance.parent) {
216
- newInstance.__r3f.autoRemovedBeforeAppend = true;
217
- }
218
- appendChild(parent, newInstance);
227
+ newInstance.__r3f.autoRemovedBeforeAppend = autoRemovedBeforeAppend;
219
228
 
220
229
  // Re-bind event handlers
221
230
  if (newInstance.raycast && newInstance.__r3f.eventCount) {
@@ -100,7 +100,11 @@ function createRenderer(_roots, _getEventPriority) {
100
100
  parentInstance.children = [...restSiblings.slice(0, index), child, ...restSiblings.slice(index)];
101
101
  added = true;
102
102
  }
103
- if (!added) (_parentInstance$__r3f2 = parentInstance.__r3f) == null ? void 0 : _parentInstance$__r3f2.objects.push(child);
103
+ const objects = (_parentInstance$__r3f2 = parentInstance.__r3f) == null ? void 0 : _parentInstance$__r3f2.objects;
104
+ if (!added && objects) {
105
+ const index = objects.indexOf(beforeChild);
106
+ if (index !== -1) objects.splice(index, 0, child);else objects.push(child);
107
+ }
104
108
  if (!child.__r3f) prepare(child, {});
105
109
  child.__r3f.parent = parentInstance;
106
110
  updateInstance(child);
@@ -116,7 +120,11 @@ function createRenderer(_roots, _getEventPriority) {
116
120
  // Clear the parent reference
117
121
  if (child.__r3f) child.__r3f.parent = null;
118
122
  // Remove child from the parents objects
119
- if ((_parentInstance$__r3f3 = parentInstance.__r3f) != null && _parentInstance$__r3f3.objects) parentInstance.__r3f.objects = parentInstance.__r3f.objects.filter(x => x !== child);
123
+ const objects = (_parentInstance$__r3f3 = parentInstance.__r3f) == null ? void 0 : _parentInstance$__r3f3.objects;
124
+ if (objects) {
125
+ const index = objects.indexOf(child);
126
+ if (index !== -1) objects.splice(index, 1);
127
+ }
120
128
  // Remove attachment
121
129
  if ((_child$__r3f3 = child.__r3f) != null && _child$__r3f3.attach) {
122
130
  detach(parentInstance, child, child.__r3f.attach);
@@ -182,13 +190,14 @@ function createRenderer(_roots, _getEventPriority) {
182
190
  }
183
191
  instance.__r3f.objects.forEach(child => appendChild(newInstance, child));
184
192
  instance.__r3f.objects = [];
193
+ const autoRemovedBeforeAppend = !!newInstance.parent;
185
194
  if (!instance.__r3f.autoRemovedBeforeAppend) {
195
+ insertBefore(parent, newInstance, instance);
186
196
  removeChild(parent, instance);
197
+ } else {
198
+ appendChild(parent, newInstance);
187
199
  }
188
- if (newInstance.parent) {
189
- newInstance.__r3f.autoRemovedBeforeAppend = true;
190
- }
191
- appendChild(parent, newInstance);
200
+ newInstance.__r3f.autoRemovedBeforeAppend = autoRemovedBeforeAppend;
192
201
 
193
202
  // Re-bind event handlers
194
203
  if (newInstance.raycast && newInstance.__r3f.eventCount) {
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var index = require('./index-d26c5c57.cjs.dev.js');
5
+ var index = require('./index-9bf2e8aa.cjs.dev.js');
6
6
  var _extends = require('@babel/runtime/helpers/extends');
7
7
  var React = require('react');
8
8
  var THREE = require('three');
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var index = require('./index-e6d64601.cjs.prod.js');
5
+ var index = require('./index-66b6e976.cjs.prod.js');
6
6
  var _extends = require('@babel/runtime/helpers/extends');
7
7
  var React = require('react');
8
8
  var THREE = require('three');
@@ -1,5 +1,5 @@
1
- import { c as createEvents, e as extend, u as useMutableCallback, a as useIsomorphicLayoutEffect, b as createRoot, i as isRef, E as ErrorBoundary, B as Block, d as unmountComponentAtNode } from './index-594193f5.esm.js';
2
- export { t as ReactThreeFiber, x as _roots, v as act, o as addAfterEffect, n as addEffect, p as addTail, m as advance, j as applyProps, w as buildGraph, f as context, c as createEvents, g as createPortal, b as createRoot, k as dispose, e as extend, q as flushGlobalEffects, s as getRootState, l as invalidate, h as reconciler, r as render, d as unmountComponentAtNode, C as useFrame, D as useGraph, y as useInstanceHandle, F as useLoader, z as useStore, A as useThree } from './index-594193f5.esm.js';
1
+ import { c as createEvents, e as extend, u as useMutableCallback, a as useIsomorphicLayoutEffect, b as createRoot, i as isRef, E as ErrorBoundary, B as Block, d as unmountComponentAtNode } from './index-a2103d81.esm.js';
2
+ export { t as ReactThreeFiber, x as _roots, v as act, o as addAfterEffect, n as addEffect, p as addTail, m as advance, j as applyProps, w as buildGraph, f as context, c as createEvents, g as createPortal, b as createRoot, k as dispose, e as extend, q as flushGlobalEffects, s as getRootState, l as invalidate, h as reconciler, r as render, d as unmountComponentAtNode, C as useFrame, D as useGraph, y as useInstanceHandle, F as useLoader, z as useStore, A as useThree } from './index-a2103d81.esm.js';
3
3
  import _extends from '@babel/runtime/helpers/esm/extends';
4
4
  import * as React from 'react';
5
5
  import * as THREE from 'three';
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var index = require('../../dist/index-d26c5c57.cjs.dev.js');
5
+ var index = require('../../dist/index-9bf2e8aa.cjs.dev.js');
6
6
  var _extends = require('@babel/runtime/helpers/extends');
7
7
  var React = require('react');
8
8
  var THREE = require('three');
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var index = require('../../dist/index-e6d64601.cjs.prod.js');
5
+ var index = require('../../dist/index-66b6e976.cjs.prod.js');
6
6
  var _extends = require('@babel/runtime/helpers/extends');
7
7
  var React = require('react');
8
8
  var THREE = require('three');
@@ -1,5 +1,5 @@
1
- import { c as createEvents, e as extend, u as useMutableCallback, b as createRoot, E as ErrorBoundary, B as Block, d as unmountComponentAtNode } from '../../dist/index-594193f5.esm.js';
2
- export { t as ReactThreeFiber, x as _roots, v as act, o as addAfterEffect, n as addEffect, p as addTail, m as advance, j as applyProps, w as buildGraph, f as context, c as createEvents, g as createPortal, b as createRoot, k as dispose, e as extend, q as flushGlobalEffects, s as getRootState, l as invalidate, h as reconciler, r as render, d as unmountComponentAtNode, C as useFrame, D as useGraph, y as useInstanceHandle, F as useLoader, z as useStore, A as useThree } from '../../dist/index-594193f5.esm.js';
1
+ import { c as createEvents, e as extend, u as useMutableCallback, b as createRoot, E as ErrorBoundary, B as Block, d as unmountComponentAtNode } from '../../dist/index-a2103d81.esm.js';
2
+ export { t as ReactThreeFiber, x as _roots, v as act, o as addAfterEffect, n as addEffect, p as addTail, m as advance, j as applyProps, w as buildGraph, f as context, c as createEvents, g as createPortal, b as createRoot, k as dispose, e as extend, q as flushGlobalEffects, s as getRootState, l as invalidate, h as reconciler, r as render, d as unmountComponentAtNode, C as useFrame, D as useGraph, y as useInstanceHandle, F as useLoader, z as useStore, A as useThree } from '../../dist/index-a2103d81.esm.js';
3
3
  import _extends from '@babel/runtime/helpers/esm/extends';
4
4
  import * as React from 'react';
5
5
  import * as THREE from 'three';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-three/fiber",
3
- "version": "8.15.5",
3
+ "version": "8.15.7",
4
4
  "description": "A React renderer for Threejs",
5
5
  "keywords": [
6
6
  "react",