@react-three/fiber 8.12.0 → 8.12.1

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>;
@@ -619,7 +619,7 @@ function diffProps(instance, {
619
619
  // When props match bail out
620
620
  if (is.equ(value, previous[key])) return;
621
621
  // Collect handlers and bail out
622
- if (/^on(Pointer|Click|DoubleClick|ContextMenu|Wheel)/.test(key)) return changes.push([key, value, true, []]);
622
+ if (/^on(LostPointer|Pointer|Click|DoubleClick|ContextMenu|Wheel)/.test(key)) return changes.push([key, value, true, []]);
623
623
  // Split dashed props
624
624
  let entries = [];
625
625
  if (key.includes('-')) entries = key.split('-');
@@ -1086,25 +1086,6 @@ function createEvents(store) {
1086
1086
  case 'onPointerLeave':
1087
1087
  case 'onPointerCancel':
1088
1088
  return () => cancelPointer([]);
1089
- case 'onLostPointerCapture':
1090
- return event => {
1091
- const {
1092
- internal
1093
- } = store.getState();
1094
- if ('pointerId' in event && internal.capturedMap.has(event.pointerId)) {
1095
- // If the object event interface had onLostPointerCapture, we'd call it here on every
1096
- // object that's getting removed. We call it on the next frame because onLostPointerCapture
1097
- // fires before onPointerUp. Otherwise pointerUp would never be called if the event didn't
1098
- // happen in the object it originated from, leaving components in a in-between state.
1099
- requestAnimationFrame(() => {
1100
- // Only release if pointer-up didn't do it already
1101
- if (internal.capturedMap.has(event.pointerId)) {
1102
- internal.capturedMap.delete(event.pointerId);
1103
- cancelPointer([]);
1104
- }
1105
- });
1106
- }
1107
- };
1108
1089
  }
1109
1090
 
1110
1091
  // Any other pointer goes here ...
@@ -1119,6 +1100,7 @@ function createEvents(store) {
1119
1100
 
1120
1101
  // Get fresh intersects
1121
1102
  const isPointerMove = name === 'onPointerMove';
1103
+ const isLostPointerCapture = name === 'onLostPointerCapture';
1122
1104
  const isClickEvent = name === 'onClick' || name === 'onContextMenu' || name === 'onDoubleClick';
1123
1105
  const filter = isPointerMove ? filterPointerEvents : undefined;
1124
1106
  const hits = intersect(event, filter);
@@ -1138,6 +1120,7 @@ function createEvents(store) {
1138
1120
  if (onPointerMissed) onPointerMissed(event);
1139
1121
  }
1140
1122
  }
1123
+
1141
1124
  // Take care of unhover
1142
1125
  if (isPointerMove) cancelPointer(hits);
1143
1126
  function onIntersect(data) {
@@ -1181,6 +1164,24 @@ function createEvents(store) {
1181
1164
  }
1182
1165
  // Call mouse move
1183
1166
  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
+ }
1184
1185
  } else {
1185
1186
  // All other events ...
1186
1187
  const handler = handlers[name];
@@ -619,7 +619,7 @@ function diffProps(instance, {
619
619
  // When props match bail out
620
620
  if (is.equ(value, previous[key])) return;
621
621
  // Collect handlers and bail out
622
- if (/^on(Pointer|Click|DoubleClick|ContextMenu|Wheel)/.test(key)) return changes.push([key, value, true, []]);
622
+ if (/^on(LostPointer|Pointer|Click|DoubleClick|ContextMenu|Wheel)/.test(key)) return changes.push([key, value, true, []]);
623
623
  // Split dashed props
624
624
  let entries = [];
625
625
  if (key.includes('-')) entries = key.split('-');
@@ -1086,25 +1086,6 @@ function createEvents(store) {
1086
1086
  case 'onPointerLeave':
1087
1087
  case 'onPointerCancel':
1088
1088
  return () => cancelPointer([]);
1089
- case 'onLostPointerCapture':
1090
- return event => {
1091
- const {
1092
- internal
1093
- } = store.getState();
1094
- if ('pointerId' in event && internal.capturedMap.has(event.pointerId)) {
1095
- // If the object event interface had onLostPointerCapture, we'd call it here on every
1096
- // object that's getting removed. We call it on the next frame because onLostPointerCapture
1097
- // fires before onPointerUp. Otherwise pointerUp would never be called if the event didn't
1098
- // happen in the object it originated from, leaving components in a in-between state.
1099
- requestAnimationFrame(() => {
1100
- // Only release if pointer-up didn't do it already
1101
- if (internal.capturedMap.has(event.pointerId)) {
1102
- internal.capturedMap.delete(event.pointerId);
1103
- cancelPointer([]);
1104
- }
1105
- });
1106
- }
1107
- };
1108
1089
  }
1109
1090
 
1110
1091
  // Any other pointer goes here ...
@@ -1119,6 +1100,7 @@ function createEvents(store) {
1119
1100
 
1120
1101
  // Get fresh intersects
1121
1102
  const isPointerMove = name === 'onPointerMove';
1103
+ const isLostPointerCapture = name === 'onLostPointerCapture';
1122
1104
  const isClickEvent = name === 'onClick' || name === 'onContextMenu' || name === 'onDoubleClick';
1123
1105
  const filter = isPointerMove ? filterPointerEvents : undefined;
1124
1106
  const hits = intersect(event, filter);
@@ -1138,6 +1120,7 @@ function createEvents(store) {
1138
1120
  if (onPointerMissed) onPointerMissed(event);
1139
1121
  }
1140
1122
  }
1123
+
1141
1124
  // Take care of unhover
1142
1125
  if (isPointerMove) cancelPointer(hits);
1143
1126
  function onIntersect(data) {
@@ -1181,6 +1164,24 @@ function createEvents(store) {
1181
1164
  }
1182
1165
  // Call mouse move
1183
1166
  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
+ }
1184
1185
  } else {
1185
1186
  // All other events ...
1186
1187
  const handler = handlers[name];
@@ -592,7 +592,7 @@ function diffProps(instance, {
592
592
  // When props match bail out
593
593
  if (is.equ(value, previous[key])) return;
594
594
  // Collect handlers and bail out
595
- if (/^on(Pointer|Click|DoubleClick|ContextMenu|Wheel)/.test(key)) return changes.push([key, value, true, []]);
595
+ if (/^on(LostPointer|Pointer|Click|DoubleClick|ContextMenu|Wheel)/.test(key)) return changes.push([key, value, true, []]);
596
596
  // Split dashed props
597
597
  let entries = [];
598
598
  if (key.includes('-')) entries = key.split('-');
@@ -1059,25 +1059,6 @@ function createEvents(store) {
1059
1059
  case 'onPointerLeave':
1060
1060
  case 'onPointerCancel':
1061
1061
  return () => cancelPointer([]);
1062
- case 'onLostPointerCapture':
1063
- return event => {
1064
- const {
1065
- internal
1066
- } = store.getState();
1067
- if ('pointerId' in event && internal.capturedMap.has(event.pointerId)) {
1068
- // If the object event interface had onLostPointerCapture, we'd call it here on every
1069
- // object that's getting removed. We call it on the next frame because onLostPointerCapture
1070
- // fires before onPointerUp. Otherwise pointerUp would never be called if the event didn't
1071
- // happen in the object it originated from, leaving components in a in-between state.
1072
- requestAnimationFrame(() => {
1073
- // Only release if pointer-up didn't do it already
1074
- if (internal.capturedMap.has(event.pointerId)) {
1075
- internal.capturedMap.delete(event.pointerId);
1076
- cancelPointer([]);
1077
- }
1078
- });
1079
- }
1080
- };
1081
1062
  }
1082
1063
 
1083
1064
  // Any other pointer goes here ...
@@ -1092,6 +1073,7 @@ function createEvents(store) {
1092
1073
 
1093
1074
  // Get fresh intersects
1094
1075
  const isPointerMove = name === 'onPointerMove';
1076
+ const isLostPointerCapture = name === 'onLostPointerCapture';
1095
1077
  const isClickEvent = name === 'onClick' || name === 'onContextMenu' || name === 'onDoubleClick';
1096
1078
  const filter = isPointerMove ? filterPointerEvents : undefined;
1097
1079
  const hits = intersect(event, filter);
@@ -1111,6 +1093,7 @@ function createEvents(store) {
1111
1093
  if (onPointerMissed) onPointerMissed(event);
1112
1094
  }
1113
1095
  }
1096
+
1114
1097
  // Take care of unhover
1115
1098
  if (isPointerMove) cancelPointer(hits);
1116
1099
  function onIntersect(data) {
@@ -1154,6 +1137,24 @@ function createEvents(store) {
1154
1137
  }
1155
1138
  // Call mouse move
1156
1139
  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
+ }
1157
1158
  } else {
1158
1159
  // All other events ...
1159
1160
  const handler = handlers[name];
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var index = require('./index-8e3d9f5f.cjs.dev.js');
5
+ var index = require('./index-12cac964.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-7373fbbd.cjs.prod.js');
5
+ var index = require('./index-ca508128.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-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';
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-faa0fc56.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-faa0fc56.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-8e3d9f5f.cjs.dev.js');
5
+ var index = require('../../dist/index-12cac964.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-7373fbbd.cjs.prod.js');
5
+ var index = require('../../dist/index-ca508128.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-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';
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-faa0fc56.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-faa0fc56.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.12.0",
3
+ "version": "8.12.1",
4
4
  "description": "A React renderer for Threejs",
5
5
  "keywords": [
6
6
  "react",