@react-three/fiber 8.11.5 → 8.11.6

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.
@@ -1,11 +1,11 @@
1
- import * as React from 'react';
2
- import type { Options as ResizeOptions } from 'react-use-measure';
3
- import { RenderProps } from '../core';
4
- export interface Props extends Omit<RenderProps<HTMLCanvasElement>, 'size'>, React.HTMLAttributes<HTMLDivElement> {
5
- children: React.ReactNode;
6
- fallback?: React.ReactNode;
7
- resize?: ResizeOptions;
8
- eventSource?: HTMLElement | React.MutableRefObject<HTMLElement>;
9
- eventPrefix?: 'offset' | 'client' | 'page' | 'layer' | 'screen';
10
- }
11
- export declare const Canvas: React.ForwardRefExoticComponent<Props & React.RefAttributes<HTMLCanvasElement>>;
1
+ import * as React from 'react';
2
+ import type { Options as ResizeOptions } from 'react-use-measure';
3
+ import { RenderProps } from '../core';
4
+ export interface Props extends Omit<RenderProps<HTMLCanvasElement>, 'size'>, React.HTMLAttributes<HTMLDivElement> {
5
+ children: React.ReactNode;
6
+ fallback?: React.ReactNode;
7
+ resize?: ResizeOptions;
8
+ eventSource?: HTMLElement | React.MutableRefObject<HTMLElement>;
9
+ eventPrefix?: 'offset' | 'client' | 'page' | 'layer' | 'screen';
10
+ }
11
+ export declare const Canvas: React.ForwardRefExoticComponent<Props & React.RefAttributes<HTMLCanvasElement>>;
@@ -1,4 +1,4 @@
1
- import { UseBoundStore } from 'zustand';
2
- import { RootState } from '../core/store';
3
- import { EventManager } from '../core/events';
4
- export declare function createPointerEvents(store: UseBoundStore<RootState>): EventManager<HTMLElement>;
1
+ import { UseBoundStore } from 'zustand';
2
+ import { RootState } from '../core/store';
3
+ import { EventManager } from '../core/events';
4
+ export declare function createPointerEvents(store: UseBoundStore<RootState>): EventManager<HTMLElement>;
@@ -131,11 +131,24 @@ const is = {
131
131
  if ((isArr || isObj) && a === b) return true;
132
132
  // Last resort, go through keys
133
133
  let i;
134
+ // Check if a has all the keys of b
134
135
  for (i in a) if (!(i in b)) return false;
135
- for (i in strict ? b : a) if (a[i] !== b[i]) return false;
136
+ // Check if values between keys match
137
+ if (isObj && arrays === 'shallow' && objects === 'shallow') {
138
+ for (i in strict ? b : a) if (!is.equ(a[i], b[i], {
139
+ strict,
140
+ objects: 'reference'
141
+ })) return false;
142
+ } else {
143
+ for (i in strict ? b : a) if (a[i] !== b[i]) return false;
144
+ }
145
+ // If i is undefined
136
146
  if (is.und(i)) {
147
+ // If both arrays are empty we consider them equal
137
148
  if (isArr && a.length === 0 && b.length === 0) return true;
149
+ // If both objects are empty we consider them equal
138
150
  if (isObj && Object.keys(a).length === 0 && Object.keys(b).length === 0) return true;
151
+ // Otherwise match them by value
139
152
  if (a !== b) return false;
140
153
  }
141
154
  return true;
@@ -1734,6 +1747,7 @@ function createRoot(canvas) {
1734
1747
  // Locals
1735
1748
  let onCreated;
1736
1749
  let configured = false;
1750
+ let lastCamera;
1737
1751
  return {
1738
1752
  configure(props = {}) {
1739
1753
  let {
@@ -1782,15 +1796,16 @@ function createRoot(canvas) {
1782
1796
  }
1783
1797
  });
1784
1798
 
1785
- // Create default camera (one time only!)
1786
- if (!state.camera) {
1799
+ // Create default camera
1800
+ if (!is.equ(lastCamera, shallowLoose)) {
1801
+ lastCamera = cameraOptions;
1787
1802
  const isCamera = cameraOptions instanceof THREE__namespace.Camera;
1788
1803
  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);
1789
1804
  if (!isCamera) {
1790
1805
  camera.position.z = 5;
1791
1806
  if (cameraOptions) applyProps(camera, cameraOptions);
1792
1807
  // Always look at center by default
1793
- if (!(cameraOptions != null && cameraOptions.rotation)) camera.lookAt(0, 0, 0);
1808
+ if (!state.camera && !(cameraOptions != null && cameraOptions.rotation)) camera.lookAt(0, 0, 0);
1794
1809
  }
1795
1810
  state.set({
1796
1811
  camera
@@ -131,11 +131,24 @@ const is = {
131
131
  if ((isArr || isObj) && a === b) return true;
132
132
  // Last resort, go through keys
133
133
  let i;
134
+ // Check if a has all the keys of b
134
135
  for (i in a) if (!(i in b)) return false;
135
- for (i in strict ? b : a) if (a[i] !== b[i]) return false;
136
+ // Check if values between keys match
137
+ if (isObj && arrays === 'shallow' && objects === 'shallow') {
138
+ for (i in strict ? b : a) if (!is.equ(a[i], b[i], {
139
+ strict,
140
+ objects: 'reference'
141
+ })) return false;
142
+ } else {
143
+ for (i in strict ? b : a) if (a[i] !== b[i]) return false;
144
+ }
145
+ // If i is undefined
136
146
  if (is.und(i)) {
147
+ // If both arrays are empty we consider them equal
137
148
  if (isArr && a.length === 0 && b.length === 0) return true;
149
+ // If both objects are empty we consider them equal
138
150
  if (isObj && Object.keys(a).length === 0 && Object.keys(b).length === 0) return true;
151
+ // Otherwise match them by value
139
152
  if (a !== b) return false;
140
153
  }
141
154
  return true;
@@ -1734,6 +1747,7 @@ function createRoot(canvas) {
1734
1747
  // Locals
1735
1748
  let onCreated;
1736
1749
  let configured = false;
1750
+ let lastCamera;
1737
1751
  return {
1738
1752
  configure(props = {}) {
1739
1753
  let {
@@ -1782,15 +1796,16 @@ function createRoot(canvas) {
1782
1796
  }
1783
1797
  });
1784
1798
 
1785
- // Create default camera (one time only!)
1786
- if (!state.camera) {
1799
+ // Create default camera
1800
+ if (!is.equ(lastCamera, shallowLoose)) {
1801
+ lastCamera = cameraOptions;
1787
1802
  const isCamera = cameraOptions instanceof THREE__namespace.Camera;
1788
1803
  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);
1789
1804
  if (!isCamera) {
1790
1805
  camera.position.z = 5;
1791
1806
  if (cameraOptions) applyProps(camera, cameraOptions);
1792
1807
  // Always look at center by default
1793
- if (!(cameraOptions != null && cameraOptions.rotation)) camera.lookAt(0, 0, 0);
1808
+ if (!state.camera && !(cameraOptions != null && cameraOptions.rotation)) camera.lookAt(0, 0, 0);
1794
1809
  }
1795
1810
  state.set({
1796
1811
  camera
@@ -104,11 +104,24 @@ const is = {
104
104
  if ((isArr || isObj) && a === b) return true;
105
105
  // Last resort, go through keys
106
106
  let i;
107
+ // Check if a has all the keys of b
107
108
  for (i in a) if (!(i in b)) return false;
108
- for (i in strict ? b : a) if (a[i] !== b[i]) return false;
109
+ // Check if values between keys match
110
+ if (isObj && arrays === 'shallow' && objects === 'shallow') {
111
+ for (i in strict ? b : a) if (!is.equ(a[i], b[i], {
112
+ strict,
113
+ objects: 'reference'
114
+ })) return false;
115
+ } else {
116
+ for (i in strict ? b : a) if (a[i] !== b[i]) return false;
117
+ }
118
+ // If i is undefined
109
119
  if (is.und(i)) {
120
+ // If both arrays are empty we consider them equal
110
121
  if (isArr && a.length === 0 && b.length === 0) return true;
122
+ // If both objects are empty we consider them equal
111
123
  if (isObj && Object.keys(a).length === 0 && Object.keys(b).length === 0) return true;
124
+ // Otherwise match them by value
112
125
  if (a !== b) return false;
113
126
  }
114
127
  return true;
@@ -1707,6 +1720,7 @@ function createRoot(canvas) {
1707
1720
  // Locals
1708
1721
  let onCreated;
1709
1722
  let configured = false;
1723
+ let lastCamera;
1710
1724
  return {
1711
1725
  configure(props = {}) {
1712
1726
  let {
@@ -1755,15 +1769,16 @@ function createRoot(canvas) {
1755
1769
  }
1756
1770
  });
1757
1771
 
1758
- // Create default camera (one time only!)
1759
- if (!state.camera) {
1772
+ // Create default camera
1773
+ if (!is.equ(lastCamera, shallowLoose)) {
1774
+ lastCamera = cameraOptions;
1760
1775
  const isCamera = cameraOptions instanceof THREE.Camera;
1761
1776
  const camera = isCamera ? cameraOptions : orthographic ? new THREE.OrthographicCamera(0, 0, 0, 0, 0.1, 1000) : new THREE.PerspectiveCamera(75, 0, 0.1, 1000);
1762
1777
  if (!isCamera) {
1763
1778
  camera.position.z = 5;
1764
1779
  if (cameraOptions) applyProps(camera, cameraOptions);
1765
1780
  // Always look at center by default
1766
- if (!(cameraOptions != null && cameraOptions.rotation)) camera.lookAt(0, 0, 0);
1781
+ if (!state.camera && !(cameraOptions != null && cameraOptions.rotation)) camera.lookAt(0, 0, 0);
1767
1782
  }
1768
1783
  state.set({
1769
1784
  camera
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var index = require('./index-d1fc6689.cjs.dev.js');
5
+ var index = require('./index-e05083bb.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-17c44482.cjs.prod.js');
5
+ var index = require('./index-dc07c96b.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 createRoot, i as isRef, E as ErrorBoundary, B as Block, b as useIsomorphicLayoutEffect, d as unmountComponentAtNode } from './index-37bd4d5c.esm.js';
2
- export { t as ReactThreeFiber, w as _roots, v as act, o as addAfterEffect, n as addEffect, p as addTail, m as advance, j as applyProps, f as context, c as createEvents, g as createPortal, a 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, A as useFrame, C as useGraph, x as useInstanceHandle, D as useLoader, y as useStore, z as useThree } from './index-37bd4d5c.esm.js';
1
+ import { c as createEvents, e as extend, u as useMutableCallback, a as createRoot, i as isRef, E as ErrorBoundary, B as Block, b as useIsomorphicLayoutEffect, d as unmountComponentAtNode } from './index-e8ca37e1.esm.js';
2
+ export { t as ReactThreeFiber, w as _roots, v as act, o as addAfterEffect, n as addEffect, p as addTail, m as advance, j as applyProps, f as context, c as createEvents, g as createPortal, a 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, A as useFrame, C as useGraph, x as useInstanceHandle, D as useLoader, y as useStore, z as useThree } from './index-e8ca37e1.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-d1fc6689.cjs.dev.js');
5
+ var index = require('../../dist/index-e05083bb.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-17c44482.cjs.prod.js');
5
+ var index = require('../../dist/index-dc07c96b.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 createRoot, E as ErrorBoundary, B as Block, d as unmountComponentAtNode } from '../../dist/index-37bd4d5c.esm.js';
2
- export { t as ReactThreeFiber, w as _roots, v as act, o as addAfterEffect, n as addEffect, p as addTail, m as advance, j as applyProps, f as context, c as createEvents, g as createPortal, a 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, A as useFrame, C as useGraph, x as useInstanceHandle, D as useLoader, y as useStore, z as useThree } from '../../dist/index-37bd4d5c.esm.js';
1
+ import { c as createEvents, e as extend, u as useMutableCallback, a as createRoot, E as ErrorBoundary, B as Block, d as unmountComponentAtNode } from '../../dist/index-e8ca37e1.esm.js';
2
+ export { t as ReactThreeFiber, w as _roots, v as act, o as addAfterEffect, n as addEffect, p as addTail, m as advance, j as applyProps, f as context, c as createEvents, g as createPortal, a 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, A as useFrame, C as useGraph, x as useInstanceHandle, D as useLoader, y as useStore, z as useThree } from '../../dist/index-e8ca37e1.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.11.5",
3
+ "version": "8.11.6",
4
4
  "description": "A React renderer for Threejs",
5
5
  "keywords": [
6
6
  "react",