@react-three/fiber 9.0.0-rc.8 → 9.0.0-rc.9

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.
@@ -56,6 +56,7 @@ export interface EventHandlers {
56
56
  onPointerMissed?: (event: MouseEvent) => void;
57
57
  onPointerCancel?: (event: ThreeEvent<PointerEvent>) => void;
58
58
  onWheel?: (event: ThreeEvent<WheelEvent>) => void;
59
+ onLostPointerCapture?: (event: ThreeEvent<PointerEvent>) => void;
59
60
  }
60
61
  export type FilterFunction = (items: THREE.Intersection[], state: RootState) => THREE.Intersection[];
61
62
  export type ComputeFunction = (event: DomEvent, root: RootState, previous?: RootState) => void;
@@ -27,6 +27,7 @@ export type Camera = (THREE.OrthographicCamera | THREE.PerspectiveCamera) & {
27
27
  };
28
28
  export declare const isOrthographicCamera: (def: Camera) => def is THREE.OrthographicCamera;
29
29
  export declare const isRef: (obj: any) => obj is React.RefObject<unknown>;
30
+ export declare const isColorRepresentation: (value: unknown) => value is THREE.ColorRepresentation;
30
31
  /**
31
32
  * An SSR-friendly useLayoutEffect.
32
33
  *
@@ -26,6 +26,7 @@ function findInitialRoot(instance) {
26
26
  const act = React.act;
27
27
  const isOrthographicCamera = def => def && def.isOrthographicCamera;
28
28
  const isRef = obj => obj && obj.hasOwnProperty('current');
29
+ const isColorRepresentation = value => value != null && (typeof value === 'string' || typeof value === 'number' || value.isColor);
29
30
 
30
31
  /**
31
32
  * An SSR-friendly useLayoutEffect.
@@ -369,6 +370,8 @@ function applyProps(object, props) {
369
370
  // Layers must be written to the mask property
370
371
  if (target instanceof THREE.Layers && value instanceof THREE.Layers) {
371
372
  target.mask = value.mask;
373
+ } else if (target instanceof THREE.Color && isColorRepresentation(value)) {
374
+ target.set(value);
372
375
  }
373
376
  // Copy if properties match signatures and implement math interface (likely read-only)
374
377
  else if (target && typeof target.set === 'function' && typeof target.copy === 'function' && value != null && value.constructor && target.constructor === value.constructor) {
@@ -380,9 +383,8 @@ function applyProps(object, props) {
380
383
  }
381
384
  // Set literal types
382
385
  else if (target && typeof target.set === 'function' && typeof value === 'number') {
383
- // Allow setting array scalars (don't call setScalar for Color since it skips conversions)
384
- const isColor = target.isColor;
385
- if (!isColor && typeof target.setScalar === 'function') target.setScalar(value);
386
+ // Allow setting array scalars
387
+ if (typeof target.setScalar === 'function') target.setScalar(value);
386
388
  // Otherwise just set single value
387
389
  else target.set(value);
388
390
  }
@@ -2296,7 +2298,7 @@ function createPointerEvents(store) {
2296
2298
  compute(event, state, previous) {
2297
2299
  // https://github.com/pmndrs/react-three-fiber/pull/782
2298
2300
  // Events trigger outside of canvas when moved, use offsetX/Y by default and allow overrides
2299
- state.pointer.set((event.offsetX - state.size.left) / state.size.width * 2 - 1, -((event.offsetY - state.size.top) / state.size.height) * 2 + 1);
2301
+ state.pointer.set(event.offsetX / state.size.width * 2 - 1, -(event.offsetY / state.size.height) * 2 + 1);
2300
2302
  state.raycaster.setFromCamera(state.pointer, state.camera);
2301
2303
  },
2302
2304
  connected: undefined,
@@ -52,6 +52,7 @@ function findInitialRoot(instance) {
52
52
  const act = React__namespace.act;
53
53
  const isOrthographicCamera = def => def && def.isOrthographicCamera;
54
54
  const isRef = obj => obj && obj.hasOwnProperty('current');
55
+ const isColorRepresentation = value => value != null && (typeof value === 'string' || typeof value === 'number' || value.isColor);
55
56
 
56
57
  /**
57
58
  * An SSR-friendly useLayoutEffect.
@@ -395,6 +396,8 @@ function applyProps(object, props) {
395
396
  // Layers must be written to the mask property
396
397
  if (target instanceof THREE__namespace.Layers && value instanceof THREE__namespace.Layers) {
397
398
  target.mask = value.mask;
399
+ } else if (target instanceof THREE__namespace.Color && isColorRepresentation(value)) {
400
+ target.set(value);
398
401
  }
399
402
  // Copy if properties match signatures and implement math interface (likely read-only)
400
403
  else if (target && typeof target.set === 'function' && typeof target.copy === 'function' && value != null && value.constructor && target.constructor === value.constructor) {
@@ -406,9 +409,8 @@ function applyProps(object, props) {
406
409
  }
407
410
  // Set literal types
408
411
  else if (target && typeof target.set === 'function' && typeof value === 'number') {
409
- // Allow setting array scalars (don't call setScalar for Color since it skips conversions)
410
- const isColor = target.isColor;
411
- if (!isColor && typeof target.setScalar === 'function') target.setScalar(value);
412
+ // Allow setting array scalars
413
+ if (typeof target.setScalar === 'function') target.setScalar(value);
412
414
  // Otherwise just set single value
413
415
  else target.set(value);
414
416
  }
@@ -2322,7 +2324,7 @@ function createPointerEvents(store) {
2322
2324
  compute(event, state, previous) {
2323
2325
  // https://github.com/pmndrs/react-three-fiber/pull/782
2324
2326
  // Events trigger outside of canvas when moved, use offsetX/Y by default and allow overrides
2325
- state.pointer.set((event.offsetX - state.size.left) / state.size.width * 2 - 1, -((event.offsetY - state.size.top) / state.size.height) * 2 + 1);
2327
+ state.pointer.set(event.offsetX / state.size.width * 2 - 1, -(event.offsetY / state.size.height) * 2 + 1);
2326
2328
  state.raycaster.setFromCamera(state.pointer, state.camera);
2327
2329
  },
2328
2330
  connected: undefined,
@@ -52,6 +52,7 @@ function findInitialRoot(instance) {
52
52
  const act = React__namespace.act;
53
53
  const isOrthographicCamera = def => def && def.isOrthographicCamera;
54
54
  const isRef = obj => obj && obj.hasOwnProperty('current');
55
+ const isColorRepresentation = value => value != null && (typeof value === 'string' || typeof value === 'number' || value.isColor);
55
56
 
56
57
  /**
57
58
  * An SSR-friendly useLayoutEffect.
@@ -395,6 +396,8 @@ function applyProps(object, props) {
395
396
  // Layers must be written to the mask property
396
397
  if (target instanceof THREE__namespace.Layers && value instanceof THREE__namespace.Layers) {
397
398
  target.mask = value.mask;
399
+ } else if (target instanceof THREE__namespace.Color && isColorRepresentation(value)) {
400
+ target.set(value);
398
401
  }
399
402
  // Copy if properties match signatures and implement math interface (likely read-only)
400
403
  else if (target && typeof target.set === 'function' && typeof target.copy === 'function' && value != null && value.constructor && target.constructor === value.constructor) {
@@ -406,9 +409,8 @@ function applyProps(object, props) {
406
409
  }
407
410
  // Set literal types
408
411
  else if (target && typeof target.set === 'function' && typeof value === 'number') {
409
- // Allow setting array scalars (don't call setScalar for Color since it skips conversions)
410
- const isColor = target.isColor;
411
- if (!isColor && typeof target.setScalar === 'function') target.setScalar(value);
412
+ // Allow setting array scalars
413
+ if (typeof target.setScalar === 'function') target.setScalar(value);
412
414
  // Otherwise just set single value
413
415
  else target.set(value);
414
416
  }
@@ -2322,7 +2324,7 @@ function createPointerEvents(store) {
2322
2324
  compute(event, state, previous) {
2323
2325
  // https://github.com/pmndrs/react-three-fiber/pull/782
2324
2326
  // Events trigger outside of canvas when moved, use offsetX/Y by default and allow overrides
2325
- state.pointer.set((event.offsetX - state.size.left) / state.size.width * 2 - 1, -((event.offsetY - state.size.top) / state.size.height) * 2 + 1);
2327
+ state.pointer.set(event.offsetX / state.size.width * 2 - 1, -(event.offsetY / state.size.height) * 2 + 1);
2326
2328
  state.raycaster.setFromCamera(state.pointer, state.camera);
2327
2329
  },
2328
2330
  connected: undefined,
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var events = require('./events-89dd614d.cjs.dev.js');
5
+ var events = require('./events-b02714fc.cjs.dev.js');
6
6
  var React = require('react');
7
7
  var THREE = require('three');
8
8
  var useMeasure = require('react-use-measure');
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var events = require('./events-b4105f71.cjs.prod.js');
5
+ var events = require('./events-bd708dc8.cjs.prod.js');
6
6
  var React = require('react');
7
7
  var THREE = require('three');
8
8
  var useMeasure = require('react-use-measure');
@@ -1,5 +1,5 @@
1
- import { e as extend, u as useBridge, a as useMutableCallback, b as useIsomorphicLayoutEffect, c as createRoot, i as isRef, E as ErrorBoundary, B as Block, d as unmountComponentAtNode, f as createPointerEvents } from './events-5b423474.esm.js';
2
- export { t as ReactThreeFiber, _ as _roots, w as act, k as addAfterEffect, j as addEffect, l as addTail, n as advance, q as applyProps, x as buildGraph, p as context, g as createEvents, o as createPortal, c as createRoot, v as dispose, f as events, e as extend, h as flushGlobalEffects, s as getRootState, m as invalidate, r as reconciler, d as unmountComponentAtNode, C as useFrame, D as useGraph, y as useInstanceHandle, F as useLoader, z as useStore, A as useThree } from './events-5b423474.esm.js';
1
+ import { e as extend, u as useBridge, a as useMutableCallback, b as useIsomorphicLayoutEffect, c as createRoot, i as isRef, E as ErrorBoundary, B as Block, d as unmountComponentAtNode, f as createPointerEvents } from './events-aba3c3d1.esm.js';
2
+ export { t as ReactThreeFiber, _ as _roots, w as act, k as addAfterEffect, j as addEffect, l as addTail, n as advance, q as applyProps, x as buildGraph, p as context, g as createEvents, o as createPortal, c as createRoot, v as dispose, f as events, e as extend, h as flushGlobalEffects, s as getRootState, m as invalidate, r as reconciler, d as unmountComponentAtNode, C as useFrame, D as useGraph, y as useInstanceHandle, F as useLoader, z as useStore, A as useThree } from './events-aba3c3d1.esm.js';
3
3
  import * as React from 'react';
4
4
  import * as THREE from 'three';
5
5
  import useMeasure from 'react-use-measure';
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var events = require('../../dist/events-89dd614d.cjs.dev.js');
5
+ var events = require('../../dist/events-b02714fc.cjs.dev.js');
6
6
  var React = require('react');
7
7
  var THREE = require('three');
8
8
  var reactNative = require('react-native');
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var events = require('../../dist/events-b4105f71.cjs.prod.js');
5
+ var events = require('../../dist/events-bd708dc8.cjs.prod.js');
6
6
  var React = require('react');
7
7
  var THREE = require('three');
8
8
  var reactNative = require('react-native');
@@ -1,5 +1,5 @@
1
- import { e as extend, u as useBridge, a as useMutableCallback, c as createRoot, b as useIsomorphicLayoutEffect, E as ErrorBoundary, B as Block, d as unmountComponentAtNode, f as createPointerEvents, g as createEvents } from '../../dist/events-5b423474.esm.js';
2
- export { t as ReactThreeFiber, _ as _roots, w as act, k as addAfterEffect, j as addEffect, l as addTail, n as advance, q as applyProps, x as buildGraph, p as context, g as createEvents, o as createPortal, c as createRoot, v as dispose, e as extend, h as flushGlobalEffects, s as getRootState, m as invalidate, r as reconciler, d as unmountComponentAtNode, C as useFrame, D as useGraph, y as useInstanceHandle, F as useLoader, z as useStore, A as useThree } from '../../dist/events-5b423474.esm.js';
1
+ import { e as extend, u as useBridge, a as useMutableCallback, c as createRoot, b as useIsomorphicLayoutEffect, E as ErrorBoundary, B as Block, d as unmountComponentAtNode, f as createPointerEvents, g as createEvents } from '../../dist/events-aba3c3d1.esm.js';
2
+ export { t as ReactThreeFiber, _ as _roots, w as act, k as addAfterEffect, j as addEffect, l as addTail, n as advance, q as applyProps, x as buildGraph, p as context, g as createEvents, o as createPortal, c as createRoot, v as dispose, e as extend, h as flushGlobalEffects, s as getRootState, m as invalidate, r as reconciler, d as unmountComponentAtNode, C as useFrame, D as useGraph, y as useInstanceHandle, F as useLoader, z as useStore, A as useThree } from '../../dist/events-aba3c3d1.esm.js';
3
3
  import * as React from 'react';
4
4
  import * as THREE from 'three';
5
5
  import { PanResponder, PixelRatio, StyleSheet, View, Platform, Image, NativeModules } from 'react-native';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-three/fiber",
3
- "version": "9.0.0-rc.8",
3
+ "version": "9.0.0-rc.9",
4
4
  "description": "A React renderer for Threejs",
5
5
  "keywords": [
6
6
  "react",