@react-three/fiber 8.12.1 → 8.13.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.
- package/CHANGELOG.md +13 -1
- package/dist/declarations/src/core/events.d.ts +71 -72
- package/dist/declarations/src/core/hooks.d.ts +29 -29
- package/dist/declarations/src/core/index.d.ts +58 -58
- package/dist/declarations/src/core/loop.d.ts +14 -14
- package/dist/declarations/src/core/renderer.d.ts +58 -58
- package/dist/declarations/src/core/store.d.ts +95 -95
- package/dist/declarations/src/core/utils.d.ts +94 -89
- package/dist/declarations/src/index.d.ts +12 -12
- package/dist/declarations/src/native/Canvas.d.ts +10 -8
- package/dist/declarations/src/native/events.d.ts +4 -4
- package/dist/declarations/src/native/polyfills.d.ts +1 -1
- package/dist/declarations/src/native.d.ts +12 -12
- package/dist/declarations/src/three-types.d.ts +335 -335
- package/dist/declarations/src/web/Canvas.d.ts +13 -11
- package/dist/declarations/src/web/events.d.ts +4 -4
- package/dist/{index-faa0fc56.esm.js → index-22ee0173.esm.js} +55 -28
- package/dist/{index-ca508128.cjs.prod.js → index-ed22818c.cjs.prod.js} +55 -28
- package/dist/{index-12cac964.cjs.dev.js → index-f4b96a62.cjs.dev.js} +55 -28
- package/dist/react-three-fiber.cjs.dev.js +1 -1
- package/dist/react-three-fiber.cjs.prod.js +1 -1
- package/dist/react-three-fiber.esm.js +2 -2
- package/native/dist/react-three-fiber-native.cjs.dev.js +1 -1
- package/native/dist/react-three-fiber-native.cjs.prod.js +1 -1
- package/native/dist/react-three-fiber-native.esm.js +2 -2
- package/package.json +1 -1
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import type { Options as ResizeOptions } from 'react-use-measure';
|
|
3
|
-
import { RenderProps } from '../core';
|
|
4
|
-
export interface
|
|
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
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { Options as ResizeOptions } from 'react-use-measure';
|
|
3
|
+
import { RenderProps } from '../core';
|
|
4
|
+
export interface CanvasProps 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 interface Props extends CanvasProps {
|
|
12
|
+
}
|
|
13
|
+
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>;
|
|
@@ -350,6 +350,10 @@ function createRenderer(_roots, _getEventPriority) {
|
|
|
350
350
|
}
|
|
351
351
|
|
|
352
352
|
var _window$document, _window$navigator;
|
|
353
|
+
/**
|
|
354
|
+
* Returns `true` with correct TS type inference if an object has a configurable color space (since r152).
|
|
355
|
+
*/
|
|
356
|
+
const hasColorSpace = object => 'colorSpace' in object || 'outputColorSpace' in object;
|
|
353
357
|
/**
|
|
354
358
|
* The current THREE.ColorManagement instance, if present.
|
|
355
359
|
*/
|
|
@@ -405,7 +409,10 @@ const DEFAULT = '__default';
|
|
|
405
409
|
const DEFAULTS = new Map();
|
|
406
410
|
const isDiffSet = def => def && !!def.memoized && !!def.changes;
|
|
407
411
|
function calculateDpr(dpr) {
|
|
408
|
-
|
|
412
|
+
var _window$devicePixelRa;
|
|
413
|
+
// Err on the side of progress by assuming 2x dpr if we can't detect it
|
|
414
|
+
// This will happen in workers where window is defined but dpr isn't.
|
|
415
|
+
const target = typeof window !== 'undefined' ? (_window$devicePixelRa = window.devicePixelRatio) != null ? _window$devicePixelRa : 2 : 1;
|
|
409
416
|
return Array.isArray(dpr) ? Math.min(Math.max(dpr[0], target), dpr[1]) : dpr;
|
|
410
417
|
}
|
|
411
418
|
|
|
@@ -592,7 +599,7 @@ function diffProps(instance, {
|
|
|
592
599
|
// When props match bail out
|
|
593
600
|
if (is.equ(value, previous[key])) return;
|
|
594
601
|
// Collect handlers and bail out
|
|
595
|
-
if (/^on(
|
|
602
|
+
if (/^on(Pointer|Click|DoubleClick|ContextMenu|Wheel)/.test(key)) return changes.push([key, value, true, []]);
|
|
596
603
|
// Split dashed props
|
|
597
604
|
let entries = [];
|
|
598
605
|
if (key.includes('-')) entries = key.split('-');
|
|
@@ -632,6 +639,21 @@ function applyProps$1(instance, data) {
|
|
|
632
639
|
if (instance.__r3f) instance.__r3f.memoizedProps = memoized;
|
|
633
640
|
for (let i = 0; i < changes.length; i++) {
|
|
634
641
|
let [key, value, isEvent, keys] = changes[i];
|
|
642
|
+
|
|
643
|
+
// Alias (output)encoding => (output)colorSpace (since r152)
|
|
644
|
+
// https://github.com/pmndrs/react-three-fiber/pull/2829
|
|
645
|
+
if (hasColorSpace(instance)) {
|
|
646
|
+
const sRGBEncoding = 3001;
|
|
647
|
+
const SRGBColorSpace = 'srgb';
|
|
648
|
+
const LinearSRGBColorSpace = 'srgb-linear';
|
|
649
|
+
if (key === 'encoding') {
|
|
650
|
+
key = 'colorSpace';
|
|
651
|
+
value = value === sRGBEncoding ? SRGBColorSpace : LinearSRGBColorSpace;
|
|
652
|
+
} else if (key === 'outputEncoding') {
|
|
653
|
+
key = 'outputColorSpace';
|
|
654
|
+
value = value === sRGBEncoding ? SRGBColorSpace : LinearSRGBColorSpace;
|
|
655
|
+
}
|
|
656
|
+
}
|
|
635
657
|
let currentInstance = instance;
|
|
636
658
|
let targetProp = currentInstance[key];
|
|
637
659
|
|
|
@@ -700,12 +722,14 @@ function applyProps$1(instance, data) {
|
|
|
700
722
|
// Else, just overwrite the value
|
|
701
723
|
} else {
|
|
702
724
|
currentInstance[key] = value;
|
|
725
|
+
|
|
703
726
|
// Auto-convert sRGB textures, for now ...
|
|
704
727
|
// https://github.com/pmndrs/react-three-fiber/issues/344
|
|
705
|
-
if (
|
|
728
|
+
if (currentInstance[key] instanceof THREE.Texture &&
|
|
706
729
|
// sRGB textures must be RGBA8 since r137 https://github.com/mrdoob/three.js/pull/23129
|
|
707
730
|
currentInstance[key].format === THREE.RGBAFormat && currentInstance[key].type === THREE.UnsignedByteType) {
|
|
708
|
-
currentInstance[key]
|
|
731
|
+
const texture = currentInstance[key];
|
|
732
|
+
if (hasColorSpace(texture) && hasColorSpace(rootState.gl)) texture.colorSpace = rootState.gl.outputColorSpace;else texture.encoding = rootState.gl.outputEncoding;
|
|
709
733
|
}
|
|
710
734
|
}
|
|
711
735
|
invalidateInstance(instance);
|
|
@@ -1059,6 +1083,25 @@ function createEvents(store) {
|
|
|
1059
1083
|
case 'onPointerLeave':
|
|
1060
1084
|
case 'onPointerCancel':
|
|
1061
1085
|
return () => cancelPointer([]);
|
|
1086
|
+
case 'onLostPointerCapture':
|
|
1087
|
+
return event => {
|
|
1088
|
+
const {
|
|
1089
|
+
internal
|
|
1090
|
+
} = store.getState();
|
|
1091
|
+
if ('pointerId' in event && internal.capturedMap.has(event.pointerId)) {
|
|
1092
|
+
// If the object event interface had onLostPointerCapture, we'd call it here on every
|
|
1093
|
+
// object that's getting removed. We call it on the next frame because onLostPointerCapture
|
|
1094
|
+
// fires before onPointerUp. Otherwise pointerUp would never be called if the event didn't
|
|
1095
|
+
// happen in the object it originated from, leaving components in a in-between state.
|
|
1096
|
+
requestAnimationFrame(() => {
|
|
1097
|
+
// Only release if pointer-up didn't do it already
|
|
1098
|
+
if (internal.capturedMap.has(event.pointerId)) {
|
|
1099
|
+
internal.capturedMap.delete(event.pointerId);
|
|
1100
|
+
cancelPointer([]);
|
|
1101
|
+
}
|
|
1102
|
+
});
|
|
1103
|
+
}
|
|
1104
|
+
};
|
|
1062
1105
|
}
|
|
1063
1106
|
|
|
1064
1107
|
// Any other pointer goes here ...
|
|
@@ -1073,7 +1116,6 @@ function createEvents(store) {
|
|
|
1073
1116
|
|
|
1074
1117
|
// Get fresh intersects
|
|
1075
1118
|
const isPointerMove = name === 'onPointerMove';
|
|
1076
|
-
const isLostPointerCapture = name === 'onLostPointerCapture';
|
|
1077
1119
|
const isClickEvent = name === 'onClick' || name === 'onContextMenu' || name === 'onDoubleClick';
|
|
1078
1120
|
const filter = isPointerMove ? filterPointerEvents : undefined;
|
|
1079
1121
|
const hits = intersect(event, filter);
|
|
@@ -1093,7 +1135,6 @@ function createEvents(store) {
|
|
|
1093
1135
|
if (onPointerMissed) onPointerMissed(event);
|
|
1094
1136
|
}
|
|
1095
1137
|
}
|
|
1096
|
-
|
|
1097
1138
|
// Take care of unhover
|
|
1098
1139
|
if (isPointerMove) cancelPointer(hits);
|
|
1099
1140
|
function onIntersect(data) {
|
|
@@ -1137,24 +1178,6 @@ function createEvents(store) {
|
|
|
1137
1178
|
}
|
|
1138
1179
|
// Call mouse move
|
|
1139
1180
|
handlers.onPointerMove == null ? void 0 : handlers.onPointerMove(data);
|
|
1140
|
-
} else if (isLostPointerCapture) {
|
|
1141
|
-
const {
|
|
1142
|
-
internal
|
|
1143
|
-
} = store.getState();
|
|
1144
|
-
if ('pointerId' in event && internal.capturedMap.has(event.pointerId)) {
|
|
1145
|
-
// If the object event interface had onLostPointerCapture, we'd call it here on every
|
|
1146
|
-
// object that's getting removed. We call it on the next frame because onLostPointerCapture
|
|
1147
|
-
// fires before onPointerUp. Otherwise pointerUp would never be called if the event didn't
|
|
1148
|
-
// happen in the object it originated from, leaving components in a in-between state.
|
|
1149
|
-
requestAnimationFrame(() => {
|
|
1150
|
-
// Only release if pointer-up didn't do it already
|
|
1151
|
-
if (internal.capturedMap.has(event.pointerId)) {
|
|
1152
|
-
internal.capturedMap.delete(event.pointerId);
|
|
1153
|
-
cancelPointer([]);
|
|
1154
|
-
handlers.onLostPointerCapture == null ? void 0 : handlers.onLostPointerCapture(data);
|
|
1155
|
-
}
|
|
1156
|
-
});
|
|
1157
|
-
}
|
|
1158
1181
|
} else {
|
|
1159
1182
|
// All other events ...
|
|
1160
1183
|
const handler = handlers[name];
|
|
@@ -1886,10 +1909,14 @@ function createRoot(canvas) {
|
|
|
1886
1909
|
if (ColorManagement) {
|
|
1887
1910
|
if ('enabled' in ColorManagement) ColorManagement.enabled = !legacy;else if ('legacyMode' in ColorManagement) ColorManagement.legacyMode = legacy;
|
|
1888
1911
|
}
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1912
|
+
|
|
1913
|
+
// Set color space and tonemapping preferences
|
|
1914
|
+
const LinearEncoding = 3000;
|
|
1915
|
+
const sRGBEncoding = 3001;
|
|
1916
|
+
applyProps(gl, {
|
|
1917
|
+
outputEncoding: linear ? LinearEncoding : sRGBEncoding,
|
|
1918
|
+
toneMapping: flat ? THREE.NoToneMapping : THREE.ACESFilmicToneMapping
|
|
1919
|
+
});
|
|
1893
1920
|
|
|
1894
1921
|
// Update color management state
|
|
1895
1922
|
if (state.legacy !== legacy) state.set(() => ({
|
|
@@ -377,6 +377,10 @@ function createRenderer(_roots, _getEventPriority) {
|
|
|
377
377
|
}
|
|
378
378
|
|
|
379
379
|
var _window$document, _window$navigator;
|
|
380
|
+
/**
|
|
381
|
+
* Returns `true` with correct TS type inference if an object has a configurable color space (since r152).
|
|
382
|
+
*/
|
|
383
|
+
const hasColorSpace = object => 'colorSpace' in object || 'outputColorSpace' in object;
|
|
380
384
|
/**
|
|
381
385
|
* The current THREE.ColorManagement instance, if present.
|
|
382
386
|
*/
|
|
@@ -432,7 +436,10 @@ const DEFAULT = '__default';
|
|
|
432
436
|
const DEFAULTS = new Map();
|
|
433
437
|
const isDiffSet = def => def && !!def.memoized && !!def.changes;
|
|
434
438
|
function calculateDpr(dpr) {
|
|
435
|
-
|
|
439
|
+
var _window$devicePixelRa;
|
|
440
|
+
// Err on the side of progress by assuming 2x dpr if we can't detect it
|
|
441
|
+
// This will happen in workers where window is defined but dpr isn't.
|
|
442
|
+
const target = typeof window !== 'undefined' ? (_window$devicePixelRa = window.devicePixelRatio) != null ? _window$devicePixelRa : 2 : 1;
|
|
436
443
|
return Array.isArray(dpr) ? Math.min(Math.max(dpr[0], target), dpr[1]) : dpr;
|
|
437
444
|
}
|
|
438
445
|
|
|
@@ -619,7 +626,7 @@ function diffProps(instance, {
|
|
|
619
626
|
// When props match bail out
|
|
620
627
|
if (is.equ(value, previous[key])) return;
|
|
621
628
|
// Collect handlers and bail out
|
|
622
|
-
if (/^on(
|
|
629
|
+
if (/^on(Pointer|Click|DoubleClick|ContextMenu|Wheel)/.test(key)) return changes.push([key, value, true, []]);
|
|
623
630
|
// Split dashed props
|
|
624
631
|
let entries = [];
|
|
625
632
|
if (key.includes('-')) entries = key.split('-');
|
|
@@ -659,6 +666,21 @@ function applyProps$1(instance, data) {
|
|
|
659
666
|
if (instance.__r3f) instance.__r3f.memoizedProps = memoized;
|
|
660
667
|
for (let i = 0; i < changes.length; i++) {
|
|
661
668
|
let [key, value, isEvent, keys] = changes[i];
|
|
669
|
+
|
|
670
|
+
// Alias (output)encoding => (output)colorSpace (since r152)
|
|
671
|
+
// https://github.com/pmndrs/react-three-fiber/pull/2829
|
|
672
|
+
if (hasColorSpace(instance)) {
|
|
673
|
+
const sRGBEncoding = 3001;
|
|
674
|
+
const SRGBColorSpace = 'srgb';
|
|
675
|
+
const LinearSRGBColorSpace = 'srgb-linear';
|
|
676
|
+
if (key === 'encoding') {
|
|
677
|
+
key = 'colorSpace';
|
|
678
|
+
value = value === sRGBEncoding ? SRGBColorSpace : LinearSRGBColorSpace;
|
|
679
|
+
} else if (key === 'outputEncoding') {
|
|
680
|
+
key = 'outputColorSpace';
|
|
681
|
+
value = value === sRGBEncoding ? SRGBColorSpace : LinearSRGBColorSpace;
|
|
682
|
+
}
|
|
683
|
+
}
|
|
662
684
|
let currentInstance = instance;
|
|
663
685
|
let targetProp = currentInstance[key];
|
|
664
686
|
|
|
@@ -727,12 +749,14 @@ function applyProps$1(instance, data) {
|
|
|
727
749
|
// Else, just overwrite the value
|
|
728
750
|
} else {
|
|
729
751
|
currentInstance[key] = value;
|
|
752
|
+
|
|
730
753
|
// Auto-convert sRGB textures, for now ...
|
|
731
754
|
// https://github.com/pmndrs/react-three-fiber/issues/344
|
|
732
|
-
if (
|
|
755
|
+
if (currentInstance[key] instanceof THREE__namespace.Texture &&
|
|
733
756
|
// sRGB textures must be RGBA8 since r137 https://github.com/mrdoob/three.js/pull/23129
|
|
734
757
|
currentInstance[key].format === THREE__namespace.RGBAFormat && currentInstance[key].type === THREE__namespace.UnsignedByteType) {
|
|
735
|
-
currentInstance[key]
|
|
758
|
+
const texture = currentInstance[key];
|
|
759
|
+
if (hasColorSpace(texture) && hasColorSpace(rootState.gl)) texture.colorSpace = rootState.gl.outputColorSpace;else texture.encoding = rootState.gl.outputEncoding;
|
|
736
760
|
}
|
|
737
761
|
}
|
|
738
762
|
invalidateInstance(instance);
|
|
@@ -1086,6 +1110,25 @@ function createEvents(store) {
|
|
|
1086
1110
|
case 'onPointerLeave':
|
|
1087
1111
|
case 'onPointerCancel':
|
|
1088
1112
|
return () => cancelPointer([]);
|
|
1113
|
+
case 'onLostPointerCapture':
|
|
1114
|
+
return event => {
|
|
1115
|
+
const {
|
|
1116
|
+
internal
|
|
1117
|
+
} = store.getState();
|
|
1118
|
+
if ('pointerId' in event && internal.capturedMap.has(event.pointerId)) {
|
|
1119
|
+
// If the object event interface had onLostPointerCapture, we'd call it here on every
|
|
1120
|
+
// object that's getting removed. We call it on the next frame because onLostPointerCapture
|
|
1121
|
+
// fires before onPointerUp. Otherwise pointerUp would never be called if the event didn't
|
|
1122
|
+
// happen in the object it originated from, leaving components in a in-between state.
|
|
1123
|
+
requestAnimationFrame(() => {
|
|
1124
|
+
// Only release if pointer-up didn't do it already
|
|
1125
|
+
if (internal.capturedMap.has(event.pointerId)) {
|
|
1126
|
+
internal.capturedMap.delete(event.pointerId);
|
|
1127
|
+
cancelPointer([]);
|
|
1128
|
+
}
|
|
1129
|
+
});
|
|
1130
|
+
}
|
|
1131
|
+
};
|
|
1089
1132
|
}
|
|
1090
1133
|
|
|
1091
1134
|
// Any other pointer goes here ...
|
|
@@ -1100,7 +1143,6 @@ function createEvents(store) {
|
|
|
1100
1143
|
|
|
1101
1144
|
// Get fresh intersects
|
|
1102
1145
|
const isPointerMove = name === 'onPointerMove';
|
|
1103
|
-
const isLostPointerCapture = name === 'onLostPointerCapture';
|
|
1104
1146
|
const isClickEvent = name === 'onClick' || name === 'onContextMenu' || name === 'onDoubleClick';
|
|
1105
1147
|
const filter = isPointerMove ? filterPointerEvents : undefined;
|
|
1106
1148
|
const hits = intersect(event, filter);
|
|
@@ -1120,7 +1162,6 @@ function createEvents(store) {
|
|
|
1120
1162
|
if (onPointerMissed) onPointerMissed(event);
|
|
1121
1163
|
}
|
|
1122
1164
|
}
|
|
1123
|
-
|
|
1124
1165
|
// Take care of unhover
|
|
1125
1166
|
if (isPointerMove) cancelPointer(hits);
|
|
1126
1167
|
function onIntersect(data) {
|
|
@@ -1164,24 +1205,6 @@ function createEvents(store) {
|
|
|
1164
1205
|
}
|
|
1165
1206
|
// Call mouse move
|
|
1166
1207
|
handlers.onPointerMove == null ? void 0 : handlers.onPointerMove(data);
|
|
1167
|
-
} else if (isLostPointerCapture) {
|
|
1168
|
-
const {
|
|
1169
|
-
internal
|
|
1170
|
-
} = store.getState();
|
|
1171
|
-
if ('pointerId' in event && internal.capturedMap.has(event.pointerId)) {
|
|
1172
|
-
// If the object event interface had onLostPointerCapture, we'd call it here on every
|
|
1173
|
-
// object that's getting removed. We call it on the next frame because onLostPointerCapture
|
|
1174
|
-
// fires before onPointerUp. Otherwise pointerUp would never be called if the event didn't
|
|
1175
|
-
// happen in the object it originated from, leaving components in a in-between state.
|
|
1176
|
-
requestAnimationFrame(() => {
|
|
1177
|
-
// Only release if pointer-up didn't do it already
|
|
1178
|
-
if (internal.capturedMap.has(event.pointerId)) {
|
|
1179
|
-
internal.capturedMap.delete(event.pointerId);
|
|
1180
|
-
cancelPointer([]);
|
|
1181
|
-
handlers.onLostPointerCapture == null ? void 0 : handlers.onLostPointerCapture(data);
|
|
1182
|
-
}
|
|
1183
|
-
});
|
|
1184
|
-
}
|
|
1185
1208
|
} else {
|
|
1186
1209
|
// All other events ...
|
|
1187
1210
|
const handler = handlers[name];
|
|
@@ -1913,10 +1936,14 @@ function createRoot(canvas) {
|
|
|
1913
1936
|
if (ColorManagement) {
|
|
1914
1937
|
if ('enabled' in ColorManagement) ColorManagement.enabled = !legacy;else if ('legacyMode' in ColorManagement) ColorManagement.legacyMode = legacy;
|
|
1915
1938
|
}
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1939
|
+
|
|
1940
|
+
// Set color space and tonemapping preferences
|
|
1941
|
+
const LinearEncoding = 3000;
|
|
1942
|
+
const sRGBEncoding = 3001;
|
|
1943
|
+
applyProps(gl, {
|
|
1944
|
+
outputEncoding: linear ? LinearEncoding : sRGBEncoding,
|
|
1945
|
+
toneMapping: flat ? THREE__namespace.NoToneMapping : THREE__namespace.ACESFilmicToneMapping
|
|
1946
|
+
});
|
|
1920
1947
|
|
|
1921
1948
|
// Update color management state
|
|
1922
1949
|
if (state.legacy !== legacy) state.set(() => ({
|
|
@@ -377,6 +377,10 @@ function createRenderer(_roots, _getEventPriority) {
|
|
|
377
377
|
}
|
|
378
378
|
|
|
379
379
|
var _window$document, _window$navigator;
|
|
380
|
+
/**
|
|
381
|
+
* Returns `true` with correct TS type inference if an object has a configurable color space (since r152).
|
|
382
|
+
*/
|
|
383
|
+
const hasColorSpace = object => 'colorSpace' in object || 'outputColorSpace' in object;
|
|
380
384
|
/**
|
|
381
385
|
* The current THREE.ColorManagement instance, if present.
|
|
382
386
|
*/
|
|
@@ -432,7 +436,10 @@ const DEFAULT = '__default';
|
|
|
432
436
|
const DEFAULTS = new Map();
|
|
433
437
|
const isDiffSet = def => def && !!def.memoized && !!def.changes;
|
|
434
438
|
function calculateDpr(dpr) {
|
|
435
|
-
|
|
439
|
+
var _window$devicePixelRa;
|
|
440
|
+
// Err on the side of progress by assuming 2x dpr if we can't detect it
|
|
441
|
+
// This will happen in workers where window is defined but dpr isn't.
|
|
442
|
+
const target = typeof window !== 'undefined' ? (_window$devicePixelRa = window.devicePixelRatio) != null ? _window$devicePixelRa : 2 : 1;
|
|
436
443
|
return Array.isArray(dpr) ? Math.min(Math.max(dpr[0], target), dpr[1]) : dpr;
|
|
437
444
|
}
|
|
438
445
|
|
|
@@ -619,7 +626,7 @@ function diffProps(instance, {
|
|
|
619
626
|
// When props match bail out
|
|
620
627
|
if (is.equ(value, previous[key])) return;
|
|
621
628
|
// Collect handlers and bail out
|
|
622
|
-
if (/^on(
|
|
629
|
+
if (/^on(Pointer|Click|DoubleClick|ContextMenu|Wheel)/.test(key)) return changes.push([key, value, true, []]);
|
|
623
630
|
// Split dashed props
|
|
624
631
|
let entries = [];
|
|
625
632
|
if (key.includes('-')) entries = key.split('-');
|
|
@@ -659,6 +666,21 @@ function applyProps$1(instance, data) {
|
|
|
659
666
|
if (instance.__r3f) instance.__r3f.memoizedProps = memoized;
|
|
660
667
|
for (let i = 0; i < changes.length; i++) {
|
|
661
668
|
let [key, value, isEvent, keys] = changes[i];
|
|
669
|
+
|
|
670
|
+
// Alias (output)encoding => (output)colorSpace (since r152)
|
|
671
|
+
// https://github.com/pmndrs/react-three-fiber/pull/2829
|
|
672
|
+
if (hasColorSpace(instance)) {
|
|
673
|
+
const sRGBEncoding = 3001;
|
|
674
|
+
const SRGBColorSpace = 'srgb';
|
|
675
|
+
const LinearSRGBColorSpace = 'srgb-linear';
|
|
676
|
+
if (key === 'encoding') {
|
|
677
|
+
key = 'colorSpace';
|
|
678
|
+
value = value === sRGBEncoding ? SRGBColorSpace : LinearSRGBColorSpace;
|
|
679
|
+
} else if (key === 'outputEncoding') {
|
|
680
|
+
key = 'outputColorSpace';
|
|
681
|
+
value = value === sRGBEncoding ? SRGBColorSpace : LinearSRGBColorSpace;
|
|
682
|
+
}
|
|
683
|
+
}
|
|
662
684
|
let currentInstance = instance;
|
|
663
685
|
let targetProp = currentInstance[key];
|
|
664
686
|
|
|
@@ -727,12 +749,14 @@ function applyProps$1(instance, data) {
|
|
|
727
749
|
// Else, just overwrite the value
|
|
728
750
|
} else {
|
|
729
751
|
currentInstance[key] = value;
|
|
752
|
+
|
|
730
753
|
// Auto-convert sRGB textures, for now ...
|
|
731
754
|
// https://github.com/pmndrs/react-three-fiber/issues/344
|
|
732
|
-
if (
|
|
755
|
+
if (currentInstance[key] instanceof THREE__namespace.Texture &&
|
|
733
756
|
// sRGB textures must be RGBA8 since r137 https://github.com/mrdoob/three.js/pull/23129
|
|
734
757
|
currentInstance[key].format === THREE__namespace.RGBAFormat && currentInstance[key].type === THREE__namespace.UnsignedByteType) {
|
|
735
|
-
currentInstance[key]
|
|
758
|
+
const texture = currentInstance[key];
|
|
759
|
+
if (hasColorSpace(texture) && hasColorSpace(rootState.gl)) texture.colorSpace = rootState.gl.outputColorSpace;else texture.encoding = rootState.gl.outputEncoding;
|
|
736
760
|
}
|
|
737
761
|
}
|
|
738
762
|
invalidateInstance(instance);
|
|
@@ -1086,6 +1110,25 @@ function createEvents(store) {
|
|
|
1086
1110
|
case 'onPointerLeave':
|
|
1087
1111
|
case 'onPointerCancel':
|
|
1088
1112
|
return () => cancelPointer([]);
|
|
1113
|
+
case 'onLostPointerCapture':
|
|
1114
|
+
return event => {
|
|
1115
|
+
const {
|
|
1116
|
+
internal
|
|
1117
|
+
} = store.getState();
|
|
1118
|
+
if ('pointerId' in event && internal.capturedMap.has(event.pointerId)) {
|
|
1119
|
+
// If the object event interface had onLostPointerCapture, we'd call it here on every
|
|
1120
|
+
// object that's getting removed. We call it on the next frame because onLostPointerCapture
|
|
1121
|
+
// fires before onPointerUp. Otherwise pointerUp would never be called if the event didn't
|
|
1122
|
+
// happen in the object it originated from, leaving components in a in-between state.
|
|
1123
|
+
requestAnimationFrame(() => {
|
|
1124
|
+
// Only release if pointer-up didn't do it already
|
|
1125
|
+
if (internal.capturedMap.has(event.pointerId)) {
|
|
1126
|
+
internal.capturedMap.delete(event.pointerId);
|
|
1127
|
+
cancelPointer([]);
|
|
1128
|
+
}
|
|
1129
|
+
});
|
|
1130
|
+
}
|
|
1131
|
+
};
|
|
1089
1132
|
}
|
|
1090
1133
|
|
|
1091
1134
|
// Any other pointer goes here ...
|
|
@@ -1100,7 +1143,6 @@ function createEvents(store) {
|
|
|
1100
1143
|
|
|
1101
1144
|
// Get fresh intersects
|
|
1102
1145
|
const isPointerMove = name === 'onPointerMove';
|
|
1103
|
-
const isLostPointerCapture = name === 'onLostPointerCapture';
|
|
1104
1146
|
const isClickEvent = name === 'onClick' || name === 'onContextMenu' || name === 'onDoubleClick';
|
|
1105
1147
|
const filter = isPointerMove ? filterPointerEvents : undefined;
|
|
1106
1148
|
const hits = intersect(event, filter);
|
|
@@ -1120,7 +1162,6 @@ function createEvents(store) {
|
|
|
1120
1162
|
if (onPointerMissed) onPointerMissed(event);
|
|
1121
1163
|
}
|
|
1122
1164
|
}
|
|
1123
|
-
|
|
1124
1165
|
// Take care of unhover
|
|
1125
1166
|
if (isPointerMove) cancelPointer(hits);
|
|
1126
1167
|
function onIntersect(data) {
|
|
@@ -1164,24 +1205,6 @@ function createEvents(store) {
|
|
|
1164
1205
|
}
|
|
1165
1206
|
// Call mouse move
|
|
1166
1207
|
handlers.onPointerMove == null ? void 0 : handlers.onPointerMove(data);
|
|
1167
|
-
} else if (isLostPointerCapture) {
|
|
1168
|
-
const {
|
|
1169
|
-
internal
|
|
1170
|
-
} = store.getState();
|
|
1171
|
-
if ('pointerId' in event && internal.capturedMap.has(event.pointerId)) {
|
|
1172
|
-
// If the object event interface had onLostPointerCapture, we'd call it here on every
|
|
1173
|
-
// object that's getting removed. We call it on the next frame because onLostPointerCapture
|
|
1174
|
-
// fires before onPointerUp. Otherwise pointerUp would never be called if the event didn't
|
|
1175
|
-
// happen in the object it originated from, leaving components in a in-between state.
|
|
1176
|
-
requestAnimationFrame(() => {
|
|
1177
|
-
// Only release if pointer-up didn't do it already
|
|
1178
|
-
if (internal.capturedMap.has(event.pointerId)) {
|
|
1179
|
-
internal.capturedMap.delete(event.pointerId);
|
|
1180
|
-
cancelPointer([]);
|
|
1181
|
-
handlers.onLostPointerCapture == null ? void 0 : handlers.onLostPointerCapture(data);
|
|
1182
|
-
}
|
|
1183
|
-
});
|
|
1184
|
-
}
|
|
1185
1208
|
} else {
|
|
1186
1209
|
// All other events ...
|
|
1187
1210
|
const handler = handlers[name];
|
|
@@ -1913,10 +1936,14 @@ function createRoot(canvas) {
|
|
|
1913
1936
|
if (ColorManagement) {
|
|
1914
1937
|
if ('enabled' in ColorManagement) ColorManagement.enabled = !legacy;else if ('legacyMode' in ColorManagement) ColorManagement.legacyMode = legacy;
|
|
1915
1938
|
}
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1939
|
+
|
|
1940
|
+
// Set color space and tonemapping preferences
|
|
1941
|
+
const LinearEncoding = 3000;
|
|
1942
|
+
const sRGBEncoding = 3001;
|
|
1943
|
+
applyProps(gl, {
|
|
1944
|
+
outputEncoding: linear ? LinearEncoding : sRGBEncoding,
|
|
1945
|
+
toneMapping: flat ? THREE__namespace.NoToneMapping : THREE__namespace.ACESFilmicToneMapping
|
|
1946
|
+
});
|
|
1920
1947
|
|
|
1921
1948
|
// Update color management state
|
|
1922
1949
|
if (state.legacy !== legacy) state.set(() => ({
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var index = require('./index-
|
|
5
|
+
var index = require('./index-f4b96a62.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-
|
|
5
|
+
var index = require('./index-ed22818c.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-
|
|
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-
|
|
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-22ee0173.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-22ee0173.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-
|
|
5
|
+
var index = require('../../dist/index-f4b96a62.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-
|
|
5
|
+
var index = require('../../dist/index-ed22818c.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-
|
|
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-
|
|
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-22ee0173.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-22ee0173.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';
|