@react-three/fiber 8.11.10 → 8.12.0

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>;
@@ -1274,12 +1274,12 @@ const createStore = (invalidate, advance) => {
1274
1274
  connected: false
1275
1275
  },
1276
1276
  xr: null,
1277
+ scene: null,
1277
1278
  invalidate: (frames = 1) => invalidate(get(), frames),
1278
1279
  advance: (timestamp, runGlobalEffects) => advance(timestamp, runGlobalEffects, get()),
1279
1280
  legacy: false,
1280
1281
  linear: false,
1281
1282
  flat: false,
1282
- scene: prepare(new THREE__namespace.Scene()),
1283
1283
  controls: null,
1284
1284
  clock: new THREE__namespace.Clock(),
1285
1285
  pointer,
@@ -1772,6 +1772,7 @@ function createRoot(canvas) {
1772
1772
  let {
1773
1773
  gl: glConfig,
1774
1774
  size: propsSize,
1775
+ scene: sceneOptions,
1775
1776
  events,
1776
1777
  onCreated: onCreatedCallback,
1777
1778
  shadows = false,
@@ -1831,6 +1832,20 @@ function createRoot(canvas) {
1831
1832
  });
1832
1833
  }
1833
1834
 
1835
+ // Set up scene (one time only!)
1836
+ if (!state.scene) {
1837
+ let scene;
1838
+ if (sceneOptions instanceof THREE__namespace.Scene) {
1839
+ scene = sceneOptions;
1840
+ } else {
1841
+ scene = new THREE__namespace.Scene();
1842
+ if (sceneOptions) applyProps(scene, sceneOptions);
1843
+ }
1844
+ state.set({
1845
+ scene: prepare(scene)
1846
+ });
1847
+ }
1848
+
1834
1849
  // Set up XR (one time only!)
1835
1850
  if (!state.xr) {
1836
1851
  // Handle frame behavior in WebXR
@@ -1274,12 +1274,12 @@ const createStore = (invalidate, advance) => {
1274
1274
  connected: false
1275
1275
  },
1276
1276
  xr: null,
1277
+ scene: null,
1277
1278
  invalidate: (frames = 1) => invalidate(get(), frames),
1278
1279
  advance: (timestamp, runGlobalEffects) => advance(timestamp, runGlobalEffects, get()),
1279
1280
  legacy: false,
1280
1281
  linear: false,
1281
1282
  flat: false,
1282
- scene: prepare(new THREE__namespace.Scene()),
1283
1283
  controls: null,
1284
1284
  clock: new THREE__namespace.Clock(),
1285
1285
  pointer,
@@ -1772,6 +1772,7 @@ function createRoot(canvas) {
1772
1772
  let {
1773
1773
  gl: glConfig,
1774
1774
  size: propsSize,
1775
+ scene: sceneOptions,
1775
1776
  events,
1776
1777
  onCreated: onCreatedCallback,
1777
1778
  shadows = false,
@@ -1831,6 +1832,20 @@ function createRoot(canvas) {
1831
1832
  });
1832
1833
  }
1833
1834
 
1835
+ // Set up scene (one time only!)
1836
+ if (!state.scene) {
1837
+ let scene;
1838
+ if (sceneOptions instanceof THREE__namespace.Scene) {
1839
+ scene = sceneOptions;
1840
+ } else {
1841
+ scene = new THREE__namespace.Scene();
1842
+ if (sceneOptions) applyProps(scene, sceneOptions);
1843
+ }
1844
+ state.set({
1845
+ scene: prepare(scene)
1846
+ });
1847
+ }
1848
+
1834
1849
  // Set up XR (one time only!)
1835
1850
  if (!state.xr) {
1836
1851
  // Handle frame behavior in WebXR
@@ -1247,12 +1247,12 @@ const createStore = (invalidate, advance) => {
1247
1247
  connected: false
1248
1248
  },
1249
1249
  xr: null,
1250
+ scene: null,
1250
1251
  invalidate: (frames = 1) => invalidate(get(), frames),
1251
1252
  advance: (timestamp, runGlobalEffects) => advance(timestamp, runGlobalEffects, get()),
1252
1253
  legacy: false,
1253
1254
  linear: false,
1254
1255
  flat: false,
1255
- scene: prepare(new THREE.Scene()),
1256
1256
  controls: null,
1257
1257
  clock: new THREE.Clock(),
1258
1258
  pointer,
@@ -1745,6 +1745,7 @@ function createRoot(canvas) {
1745
1745
  let {
1746
1746
  gl: glConfig,
1747
1747
  size: propsSize,
1748
+ scene: sceneOptions,
1748
1749
  events,
1749
1750
  onCreated: onCreatedCallback,
1750
1751
  shadows = false,
@@ -1804,6 +1805,20 @@ function createRoot(canvas) {
1804
1805
  });
1805
1806
  }
1806
1807
 
1808
+ // Set up scene (one time only!)
1809
+ if (!state.scene) {
1810
+ let scene;
1811
+ if (sceneOptions instanceof THREE.Scene) {
1812
+ scene = sceneOptions;
1813
+ } else {
1814
+ scene = new THREE.Scene();
1815
+ if (sceneOptions) applyProps(scene, sceneOptions);
1816
+ }
1817
+ state.set({
1818
+ scene: prepare(scene)
1819
+ });
1820
+ }
1821
+
1807
1822
  // Set up XR (one time only!)
1808
1823
  if (!state.xr) {
1809
1824
  // Handle frame behavior in WebXR
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var index = require('./index-cf981775.cjs.dev.js');
5
+ var index = require('./index-8e3d9f5f.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-c5f9584c.cjs.prod.js');
5
+ var index = require('./index-7373fbbd.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-9cc932ed.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, 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, A as useFrame, C as useGraph, x as useInstanceHandle, D as useLoader, y as useStore, z as useThree } from './index-9cc932ed.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-bb759d07.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, 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, A as useFrame, C as useGraph, x as useInstanceHandle, D as useLoader, y as useStore, z as useThree } from './index-bb759d07.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-cf981775.cjs.dev.js');
5
+ var index = require('../../dist/index-8e3d9f5f.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-c5f9584c.cjs.prod.js');
5
+ var index = require('../../dist/index-7373fbbd.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-9cc932ed.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, 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, A as useFrame, C as useGraph, x as useInstanceHandle, D as useLoader, y as useStore, z as useThree } from '../../dist/index-9cc932ed.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-bb759d07.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, 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, A as useFrame, C as useGraph, x as useInstanceHandle, D as useLoader, y as useStore, z as useThree } from '../../dist/index-bb759d07.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.10",
3
+ "version": "8.12.0",
4
4
  "description": "A React renderer for Threejs",
5
5
  "keywords": [
6
6
  "react",