@react-three/fiber 8.11.2 → 8.11.3

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,11 @@
1
1
  # @react-three/fiber
2
2
 
3
+ ## 8.11.3
4
+
5
+ ### Patch Changes
6
+
7
+ - 2bce569c: fix: progressively set colormanagement
8
+
3
9
  ## 8.11.2
4
10
 
5
11
  ### Patch Changes
@@ -2,6 +2,12 @@ import * as THREE from 'three';
2
2
  import * as React from 'react';
3
3
  import { AttachType, Instance, InstanceProps, LocalState } from './renderer';
4
4
  import { Dpr, RootState, Size } from './store';
5
+ export declare type ColorManagementRepresentation = {
6
+ enabled: boolean | never;
7
+ } | {
8
+ legacyMode: boolean | never;
9
+ };
10
+ export declare const ColorManagement: ColorManagementRepresentation | null;
5
11
  export declare type Camera = THREE.OrthographicCamera | THREE.PerspectiveCamera;
6
12
  export declare const isOrthographicCamera: (def: Camera) => def is THREE.OrthographicCamera;
7
13
  export declare const isRef: (obj: any) => obj is React.MutableRefObject<unknown>;
@@ -81,4 +87,3 @@ export declare function updateInstance(instance: Instance): void;
81
87
  export declare function updateCamera(camera: Camera & {
82
88
  manual?: boolean;
83
89
  }, size: Size): void;
84
- export declare function setDeep(obj: any, value: any, keys: string[]): any;
@@ -11,6 +11,14 @@ var threeTypes = /*#__PURE__*/Object.freeze({
11
11
  });
12
12
 
13
13
  var _window$document, _window$navigator;
14
+ /**
15
+ * Safely accesses a deeply-nested value on an object to get around static bundler analysis.
16
+ */
17
+ const getDeep = (obj, ...keys) => keys.reduce((acc, key) => acc == null ? void 0 : acc[key], obj);
18
+ /**
19
+ * The current THREE.ColorManagement instance, if present.
20
+ */
21
+ const ColorManagement = 'ColorManagement' in THREE && getDeep(THREE, 'ColorManagement') || null;
14
22
  const isOrthographicCamera = def => def && def.isOrthographicCamera;
15
23
  const isRef = obj => obj && obj.hasOwnProperty('current');
16
24
 
@@ -336,8 +344,7 @@ function applyProps$1(instance, data) {
336
344
  // For versions of three which don't support THREE.ColorManagement,
337
345
  // Auto-convert sRGB colors
338
346
  // https://github.com/pmndrs/react-three-fiber/issues/344
339
- const supportsColorManagement = ('ColorManagement' in THREE);
340
- if (!supportsColorManagement && !rootState.linear && isColor) targetProp.convertSRGBToLinear();
347
+ if (!ColorManagement && !rootState.linear && isColor) targetProp.convertSRGBToLinear();
341
348
  }
342
349
  // Else, just overwrite the value
343
350
  } else {
@@ -393,15 +400,6 @@ function updateCamera(camera, size) {
393
400
  }
394
401
  }
395
402
 
396
- /**
397
- * Safely sets a deeply-nested value on an object.
398
- */
399
- function setDeep(obj, value, keys) {
400
- const key = keys.pop();
401
- const target = keys.reduce((acc, key) => acc[key], obj);
402
- return target[key] = value;
403
- }
404
-
405
403
  function makeId(event) {
406
404
  return (event.eventObject || event.object).uuid + '/' + event.index + event.instanceId;
407
405
  }
@@ -1830,8 +1828,8 @@ function createRoot(canvas) {
1830
1828
 
1831
1829
  // Safely set color management if available.
1832
1830
  // Avoid accessing THREE.ColorManagement to play nice with older versions
1833
- if ('ColorManagement' in THREE) {
1834
- setDeep(THREE, legacy, ['ColorManagement', 'legacyMode']);
1831
+ if (ColorManagement) {
1832
+ if ('enabled' in ColorManagement) ColorManagement.enabled = !legacy;else if ('legacyMode' in ColorManagement) ColorManagement.legacyMode = legacy;
1835
1833
  }
1836
1834
  const outputEncoding = linear ? THREE.LinearEncoding : THREE.sRGBEncoding;
1837
1835
  const toneMapping = flat ? THREE.NoToneMapping : THREE.ACESFilmicToneMapping;
@@ -38,6 +38,14 @@ var threeTypes = /*#__PURE__*/Object.freeze({
38
38
  });
39
39
 
40
40
  var _window$document, _window$navigator;
41
+ /**
42
+ * Safely accesses a deeply-nested value on an object to get around static bundler analysis.
43
+ */
44
+ const getDeep = (obj, ...keys) => keys.reduce((acc, key) => acc == null ? void 0 : acc[key], obj);
45
+ /**
46
+ * The current THREE.ColorManagement instance, if present.
47
+ */
48
+ const ColorManagement = 'ColorManagement' in THREE__namespace && getDeep(THREE__namespace, 'ColorManagement') || null;
41
49
  const isOrthographicCamera = def => def && def.isOrthographicCamera;
42
50
  const isRef = obj => obj && obj.hasOwnProperty('current');
43
51
 
@@ -363,8 +371,7 @@ function applyProps$1(instance, data) {
363
371
  // For versions of three which don't support THREE.ColorManagement,
364
372
  // Auto-convert sRGB colors
365
373
  // https://github.com/pmndrs/react-three-fiber/issues/344
366
- const supportsColorManagement = ('ColorManagement' in THREE__namespace);
367
- if (!supportsColorManagement && !rootState.linear && isColor) targetProp.convertSRGBToLinear();
374
+ if (!ColorManagement && !rootState.linear && isColor) targetProp.convertSRGBToLinear();
368
375
  }
369
376
  // Else, just overwrite the value
370
377
  } else {
@@ -420,15 +427,6 @@ function updateCamera(camera, size) {
420
427
  }
421
428
  }
422
429
 
423
- /**
424
- * Safely sets a deeply-nested value on an object.
425
- */
426
- function setDeep(obj, value, keys) {
427
- const key = keys.pop();
428
- const target = keys.reduce((acc, key) => acc[key], obj);
429
- return target[key] = value;
430
- }
431
-
432
430
  function makeId(event) {
433
431
  return (event.eventObject || event.object).uuid + '/' + event.index + event.instanceId;
434
432
  }
@@ -1857,8 +1855,8 @@ function createRoot(canvas) {
1857
1855
 
1858
1856
  // Safely set color management if available.
1859
1857
  // Avoid accessing THREE.ColorManagement to play nice with older versions
1860
- if ('ColorManagement' in THREE__namespace) {
1861
- setDeep(THREE__namespace, legacy, ['ColorManagement', 'legacyMode']);
1858
+ if (ColorManagement) {
1859
+ if ('enabled' in ColorManagement) ColorManagement.enabled = !legacy;else if ('legacyMode' in ColorManagement) ColorManagement.legacyMode = legacy;
1862
1860
  }
1863
1861
  const outputEncoding = linear ? THREE__namespace.LinearEncoding : THREE__namespace.sRGBEncoding;
1864
1862
  const toneMapping = flat ? THREE__namespace.NoToneMapping : THREE__namespace.ACESFilmicToneMapping;
@@ -38,6 +38,14 @@ var threeTypes = /*#__PURE__*/Object.freeze({
38
38
  });
39
39
 
40
40
  var _window$document, _window$navigator;
41
+ /**
42
+ * Safely accesses a deeply-nested value on an object to get around static bundler analysis.
43
+ */
44
+ const getDeep = (obj, ...keys) => keys.reduce((acc, key) => acc == null ? void 0 : acc[key], obj);
45
+ /**
46
+ * The current THREE.ColorManagement instance, if present.
47
+ */
48
+ const ColorManagement = 'ColorManagement' in THREE__namespace && getDeep(THREE__namespace, 'ColorManagement') || null;
41
49
  const isOrthographicCamera = def => def && def.isOrthographicCamera;
42
50
  const isRef = obj => obj && obj.hasOwnProperty('current');
43
51
 
@@ -363,8 +371,7 @@ function applyProps$1(instance, data) {
363
371
  // For versions of three which don't support THREE.ColorManagement,
364
372
  // Auto-convert sRGB colors
365
373
  // https://github.com/pmndrs/react-three-fiber/issues/344
366
- const supportsColorManagement = ('ColorManagement' in THREE__namespace);
367
- if (!supportsColorManagement && !rootState.linear && isColor) targetProp.convertSRGBToLinear();
374
+ if (!ColorManagement && !rootState.linear && isColor) targetProp.convertSRGBToLinear();
368
375
  }
369
376
  // Else, just overwrite the value
370
377
  } else {
@@ -420,15 +427,6 @@ function updateCamera(camera, size) {
420
427
  }
421
428
  }
422
429
 
423
- /**
424
- * Safely sets a deeply-nested value on an object.
425
- */
426
- function setDeep(obj, value, keys) {
427
- const key = keys.pop();
428
- const target = keys.reduce((acc, key) => acc[key], obj);
429
- return target[key] = value;
430
- }
431
-
432
430
  function makeId(event) {
433
431
  return (event.eventObject || event.object).uuid + '/' + event.index + event.instanceId;
434
432
  }
@@ -1857,8 +1855,8 @@ function createRoot(canvas) {
1857
1855
 
1858
1856
  // Safely set color management if available.
1859
1857
  // Avoid accessing THREE.ColorManagement to play nice with older versions
1860
- if ('ColorManagement' in THREE__namespace) {
1861
- setDeep(THREE__namespace, legacy, ['ColorManagement', 'legacyMode']);
1858
+ if (ColorManagement) {
1859
+ if ('enabled' in ColorManagement) ColorManagement.enabled = !legacy;else if ('legacyMode' in ColorManagement) ColorManagement.legacyMode = legacy;
1862
1860
  }
1863
1861
  const outputEncoding = linear ? THREE__namespace.LinearEncoding : THREE__namespace.sRGBEncoding;
1864
1862
  const toneMapping = flat ? THREE__namespace.NoToneMapping : THREE__namespace.ACESFilmicToneMapping;
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var index = require('./index-b2f18198.cjs.dev.js');
5
+ var index = require('./index-e172420e.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-ce6281d5.cjs.prod.js');
5
+ var index = require('./index-e8867c70.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-3c94c6e9.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-3c94c6e9.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-606e613e.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-606e613e.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-b2f18198.cjs.dev.js');
5
+ var index = require('../../dist/index-e172420e.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-ce6281d5.cjs.prod.js');
5
+ var index = require('../../dist/index-e8867c70.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-3c94c6e9.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-3c94c6e9.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-606e613e.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-606e613e.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.2",
3
+ "version": "8.11.3",
4
4
  "description": "A React renderer for Threejs",
5
5
  "keywords": [
6
6
  "react",