@react-three/fiber 8.0.24 → 8.0.25

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,9 +1,9 @@
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
- }
9
- 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
+ }
9
+ 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>;
@@ -1409,6 +1409,23 @@ const createStore = (invalidate, advance) => {
1409
1409
  oldSize = size;
1410
1410
  oldDpr = viewport.dpr;
1411
1411
  }
1412
+ }); // Update viewport once the camera changes
1413
+
1414
+ let oldCamera = state.camera;
1415
+ rootState.subscribe(() => {
1416
+ const {
1417
+ camera,
1418
+ set
1419
+ } = rootState.getState();
1420
+
1421
+ if (camera !== oldCamera) {
1422
+ set(state => ({
1423
+ viewport: { ...state.viewport,
1424
+ ...state.viewport.getCurrentViewport(camera)
1425
+ }
1426
+ }));
1427
+ oldCamera = camera;
1428
+ }
1412
1429
  }); // Invalidate on any change
1413
1430
 
1414
1431
  rootState.subscribe(state => invalidate(state)); // Return root state
@@ -1382,6 +1382,23 @@ const createStore = (invalidate, advance) => {
1382
1382
  oldSize = size;
1383
1383
  oldDpr = viewport.dpr;
1384
1384
  }
1385
+ }); // Update viewport once the camera changes
1386
+
1387
+ let oldCamera = state.camera;
1388
+ rootState.subscribe(() => {
1389
+ const {
1390
+ camera,
1391
+ set
1392
+ } = rootState.getState();
1393
+
1394
+ if (camera !== oldCamera) {
1395
+ set(state => ({
1396
+ viewport: { ...state.viewport,
1397
+ ...state.viewport.getCurrentViewport(camera)
1398
+ }
1399
+ }));
1400
+ oldCamera = camera;
1401
+ }
1385
1402
  }); // Invalidate on any change
1386
1403
 
1387
1404
  rootState.subscribe(state => invalidate(state)); // Return root state
@@ -1409,6 +1409,23 @@ const createStore = (invalidate, advance) => {
1409
1409
  oldSize = size;
1410
1410
  oldDpr = viewport.dpr;
1411
1411
  }
1412
+ }); // Update viewport once the camera changes
1413
+
1414
+ let oldCamera = state.camera;
1415
+ rootState.subscribe(() => {
1416
+ const {
1417
+ camera,
1418
+ set
1419
+ } = rootState.getState();
1420
+
1421
+ if (camera !== oldCamera) {
1422
+ set(state => ({
1423
+ viewport: { ...state.viewport,
1424
+ ...state.viewport.getCurrentViewport(camera)
1425
+ }
1426
+ }));
1427
+ oldCamera = camera;
1428
+ }
1412
1429
  }); // Invalidate on any change
1413
1430
 
1414
1431
  rootState.subscribe(state => invalidate(state)); // Return root state
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var index = require('./index-cc1b2b8b.cjs.dev.js');
5
+ var index = require('./index-63f47889.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-fbc2ae01.cjs.prod.js');
5
+ var index = require('./index-cd0062f1.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, b as useIsomorphicLayoutEffect, d as unmountComponentAtNode } from './index-d1db558e.esm.js';
2
- export { t as ReactThreeFiber, s as _roots, q as act, n as addAfterEffect, m as addEffect, o as addTail, l as advance, i as applyProps, f as context, g as createPortal, a as createRoot, j as dispose, e as extend, p as getRootState, k as invalidate, h as reconciler, r as render, d as unmountComponentAtNode, x as useFrame, y as useGraph, z as useLoader, v as useStore, w as useThree } from './index-d1db558e.esm.js';
1
+ import { c as createEvents, e as extend, u as useMutableCallback, a as createRoot, E as ErrorBoundary, B as Block, b as useIsomorphicLayoutEffect, d as unmountComponentAtNode } from './index-8d5cf4a3.esm.js';
2
+ export { t as ReactThreeFiber, s as _roots, q as act, n as addAfterEffect, m as addEffect, o as addTail, l as advance, i as applyProps, f as context, g as createPortal, a as createRoot, j as dispose, e as extend, p as getRootState, k as invalidate, h as reconciler, r as render, d as unmountComponentAtNode, x as useFrame, y as useGraph, z as useLoader, v as useStore, w as useThree } from './index-8d5cf4a3.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-cc1b2b8b.cjs.dev.js');
5
+ var index = require('../../dist/index-63f47889.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-fbc2ae01.cjs.prod.js');
5
+ var index = require('../../dist/index-cd0062f1.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-d1db558e.esm.js';
2
- export { t as ReactThreeFiber, s as _roots, q as act, n as addAfterEffect, m as addEffect, o as addTail, l as advance, i as applyProps, f as context, g as createPortal, a as createRoot, j as dispose, e as extend, p as getRootState, k as invalidate, h as reconciler, r as render, d as unmountComponentAtNode, x as useFrame, y as useGraph, z as useLoader, v as useStore, w as useThree } from '../../dist/index-d1db558e.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-8d5cf4a3.esm.js';
2
+ export { t as ReactThreeFiber, s as _roots, q as act, n as addAfterEffect, m as addEffect, o as addTail, l as advance, i as applyProps, f as context, g as createPortal, a as createRoot, j as dispose, e as extend, p as getRootState, k as invalidate, h as reconciler, r as render, d as unmountComponentAtNode, x as useFrame, y as useGraph, z as useLoader, v as useStore, w as useThree } from '../../dist/index-8d5cf4a3.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.0.24",
3
+ "version": "8.0.25",
4
4
  "description": "A React renderer for Threejs",
5
5
  "keywords": [
6
6
  "react",