@react-three/fiber 8.14.1 → 8.14.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.
@@ -1,13 +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 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
+ 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>;
@@ -1672,7 +1672,7 @@ function loadingFn(extensions, onProgress) {
1672
1672
  return Promise.all(input.map(input => new Promise((res, reject) => loader.load(input, data => {
1673
1673
  if (data.scene) Object.assign(data, buildGraph(data.scene));
1674
1674
  res(data);
1675
- }, onProgress, error => reject(new Error(`Could not load ${input}: ${error.message}`)))))).finally(() => loader.dispose == null ? void 0 : loader.dispose());
1675
+ }, onProgress, error => reject(new Error(`Could not load ${input}: ${error == null ? void 0 : error.message}`)))))).finally(() => loader.dispose == null ? void 0 : loader.dispose());
1676
1676
  };
1677
1677
  }
1678
1678
 
@@ -1672,7 +1672,7 @@ function loadingFn(extensions, onProgress) {
1672
1672
  return Promise.all(input.map(input => new Promise((res, reject) => loader.load(input, data => {
1673
1673
  if (data.scene) Object.assign(data, buildGraph(data.scene));
1674
1674
  res(data);
1675
- }, onProgress, error => reject(new Error(`Could not load ${input}: ${error.message}`)))))).finally(() => loader.dispose == null ? void 0 : loader.dispose());
1675
+ }, onProgress, error => reject(new Error(`Could not load ${input}: ${error == null ? void 0 : error.message}`)))))).finally(() => loader.dispose == null ? void 0 : loader.dispose());
1676
1676
  };
1677
1677
  }
1678
1678
 
@@ -1645,7 +1645,7 @@ function loadingFn(extensions, onProgress) {
1645
1645
  return Promise.all(input.map(input => new Promise((res, reject) => loader.load(input, data => {
1646
1646
  if (data.scene) Object.assign(data, buildGraph(data.scene));
1647
1647
  res(data);
1648
- }, onProgress, error => reject(new Error(`Could not load ${input}: ${error.message}`)))))).finally(() => loader.dispose == null ? void 0 : loader.dispose());
1648
+ }, onProgress, error => reject(new Error(`Could not load ${input}: ${error == null ? void 0 : error.message}`)))))).finally(() => loader.dispose == null ? void 0 : loader.dispose());
1649
1649
  };
1650
1650
  }
1651
1651
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var index = require('./index-be1f7f7b.cjs.dev.js');
5
+ var index = require('./index-2f978f7b.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-dad7ba86.cjs.prod.js');
5
+ var index = require('./index-a401adf5.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-6662eaf2.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-6662eaf2.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-dc6125bc.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-dc6125bc.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-be1f7f7b.cjs.dev.js');
5
+ var index = require('../../dist/index-2f978f7b.cjs.dev.js');
6
6
  var _extends = require('@babel/runtime/helpers/extends');
7
7
  var React = require('react');
8
8
  var THREE = require('three');
@@ -265,6 +265,7 @@ const CanvasImpl = /*#__PURE__*/React__namespace.forwardRef(({
265
265
  ...style
266
266
  }
267
267
  }, bind), width > 0 && /*#__PURE__*/React__namespace.createElement(expoGl.GLView, {
268
+ msaaSamples: 0,
268
269
  onContextCreate: onContextCreate,
269
270
  style: reactNative.StyleSheet.absoluteFill
270
271
  }));
@@ -305,10 +306,8 @@ function polyfills() {
305
306
  }
306
307
  async function getAsset(input) {
307
308
  if (typeof input === 'string') {
308
- // Point to storage if preceded with fs path
309
- if (input.startsWith('file:')) return {
310
- localUri: input
311
- };
309
+ // Don't process storage or data uris
310
+ if (input.startsWith('file:') || input.startsWith('data:')) return input;
312
311
 
313
312
  // Unpack Blobs from react-native BlobManager
314
313
  if (input.startsWith('blob:')) {
@@ -326,40 +325,24 @@ function polyfills() {
326
325
  reader.onerror = rej;
327
326
  reader.readAsText(blob);
328
327
  });
329
- input = `data:${blob.type};base64,${data}`;
330
- }
331
-
332
- // Create safe URI for JSI
333
- if (input.startsWith('data:')) {
334
- const [header, data] = input.split(',');
335
- const [, type] = header.split('/');
336
- const localUri = fs__namespace.cacheDirectory + uuidv4() + `.${type}`;
337
- await fs__namespace.writeAsStringAsync(localUri, data, {
338
- encoding: fs__namespace.EncodingType.Base64
339
- });
340
- return {
341
- localUri
342
- };
328
+ return `data:${blob.type};base64,${data}`;
343
329
  }
344
330
  }
345
331
 
346
332
  // Download bundler module or external URL
347
- const asset = expoAsset.Asset.fromModule(input);
333
+ const asset = await expoAsset.Asset.fromModule(input).downloadAsync();
334
+ let uri = asset.localUri || asset.uri;
348
335
 
349
336
  // Unpack assets in Android Release Mode
350
- if (!asset.uri.includes(':')) {
351
- const localUri = `${fs__namespace.cacheDirectory}ExponentAsset-${asset.hash}.${asset.type}`;
337
+ if (!uri.includes(':')) {
338
+ const file = `${fs__namespace.cacheDirectory}ExponentAsset-${asset.hash}.${asset.type}`;
352
339
  await fs__namespace.copyAsync({
353
- from: asset.uri,
354
- to: localUri
340
+ from: uri,
341
+ to: file
355
342
  });
356
- return {
357
- localUri
358
- };
343
+ uri = file;
359
344
  }
360
-
361
- // Otherwise, resolve from registry
362
- return asset.downloadAsync();
345
+ return uri;
363
346
  }
364
347
 
365
348
  // Don't pre-process urls, let expo-asset generate an absolute URL
@@ -370,25 +353,29 @@ function polyfills() {
370
353
  THREE__namespace.TextureLoader.prototype.load = function load(url, onLoad, onProgress, onError) {
371
354
  if (this.path) url = this.path + url;
372
355
  const texture = new THREE__namespace.Texture();
373
- getAsset(url).then(async asset => {
374
- const uri = asset.localUri || asset.uri;
375
- if (!asset.width || !asset.height) {
376
- const {
377
- width,
378
- height
379
- } = await new Promise((res, rej) => reactNative.Image.getSize(uri, (width, height) => res({
380
- width,
381
- height
382
- }), rej));
383
- asset.width = width;
384
- asset.height = height;
356
+ getAsset(url).then(async uri => {
357
+ // Create safe URI for JSI
358
+ if (uri.startsWith('data:')) {
359
+ const [header, data] = uri.split(',');
360
+ const [, type] = header.split('/');
361
+ uri = fs__namespace.cacheDirectory + uuidv4() + `.${type}`;
362
+ await fs__namespace.writeAsStringAsync(uri, data, {
363
+ encoding: fs__namespace.EncodingType.Base64
364
+ });
385
365
  }
366
+ const {
367
+ width,
368
+ height
369
+ } = await new Promise((res, rej) => reactNative.Image.getSize(uri, (width, height) => res({
370
+ width,
371
+ height
372
+ }), rej));
386
373
  texture.image = {
387
374
  data: {
388
375
  localUri: uri
389
376
  },
390
- width: asset.width,
391
- height: asset.height
377
+ width,
378
+ height
392
379
  };
393
380
  texture.flipY = true;
394
381
  texture.unpackAlignment = 1;
@@ -406,9 +393,7 @@ function polyfills() {
406
393
  THREE__namespace.FileLoader.prototype.load = function load(url, onLoad, onProgress, onError) {
407
394
  if (this.path) url = this.path + url;
408
395
  const request = new XMLHttpRequest();
409
- getAsset(url).then(async asset => {
410
- let uri = asset.localUri || asset.uri;
411
-
396
+ getAsset(url).then(async uri => {
412
397
  // Make FS paths web-safe
413
398
  if (uri.startsWith('file://')) {
414
399
  const data = await fs__namespace.readAsStringAsync(uri, {
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var index = require('../../dist/index-dad7ba86.cjs.prod.js');
5
+ var index = require('../../dist/index-a401adf5.cjs.prod.js');
6
6
  var _extends = require('@babel/runtime/helpers/extends');
7
7
  var React = require('react');
8
8
  var THREE = require('three');
@@ -265,6 +265,7 @@ const CanvasImpl = /*#__PURE__*/React__namespace.forwardRef(({
265
265
  ...style
266
266
  }
267
267
  }, bind), width > 0 && /*#__PURE__*/React__namespace.createElement(expoGl.GLView, {
268
+ msaaSamples: 0,
268
269
  onContextCreate: onContextCreate,
269
270
  style: reactNative.StyleSheet.absoluteFill
270
271
  }));
@@ -305,10 +306,8 @@ function polyfills() {
305
306
  }
306
307
  async function getAsset(input) {
307
308
  if (typeof input === 'string') {
308
- // Point to storage if preceded with fs path
309
- if (input.startsWith('file:')) return {
310
- localUri: input
311
- };
309
+ // Don't process storage or data uris
310
+ if (input.startsWith('file:') || input.startsWith('data:')) return input;
312
311
 
313
312
  // Unpack Blobs from react-native BlobManager
314
313
  if (input.startsWith('blob:')) {
@@ -326,40 +325,24 @@ function polyfills() {
326
325
  reader.onerror = rej;
327
326
  reader.readAsText(blob);
328
327
  });
329
- input = `data:${blob.type};base64,${data}`;
330
- }
331
-
332
- // Create safe URI for JSI
333
- if (input.startsWith('data:')) {
334
- const [header, data] = input.split(',');
335
- const [, type] = header.split('/');
336
- const localUri = fs__namespace.cacheDirectory + uuidv4() + `.${type}`;
337
- await fs__namespace.writeAsStringAsync(localUri, data, {
338
- encoding: fs__namespace.EncodingType.Base64
339
- });
340
- return {
341
- localUri
342
- };
328
+ return `data:${blob.type};base64,${data}`;
343
329
  }
344
330
  }
345
331
 
346
332
  // Download bundler module or external URL
347
- const asset = expoAsset.Asset.fromModule(input);
333
+ const asset = await expoAsset.Asset.fromModule(input).downloadAsync();
334
+ let uri = asset.localUri || asset.uri;
348
335
 
349
336
  // Unpack assets in Android Release Mode
350
- if (!asset.uri.includes(':')) {
351
- const localUri = `${fs__namespace.cacheDirectory}ExponentAsset-${asset.hash}.${asset.type}`;
337
+ if (!uri.includes(':')) {
338
+ const file = `${fs__namespace.cacheDirectory}ExponentAsset-${asset.hash}.${asset.type}`;
352
339
  await fs__namespace.copyAsync({
353
- from: asset.uri,
354
- to: localUri
340
+ from: uri,
341
+ to: file
355
342
  });
356
- return {
357
- localUri
358
- };
343
+ uri = file;
359
344
  }
360
-
361
- // Otherwise, resolve from registry
362
- return asset.downloadAsync();
345
+ return uri;
363
346
  }
364
347
 
365
348
  // Don't pre-process urls, let expo-asset generate an absolute URL
@@ -370,25 +353,29 @@ function polyfills() {
370
353
  THREE__namespace.TextureLoader.prototype.load = function load(url, onLoad, onProgress, onError) {
371
354
  if (this.path) url = this.path + url;
372
355
  const texture = new THREE__namespace.Texture();
373
- getAsset(url).then(async asset => {
374
- const uri = asset.localUri || asset.uri;
375
- if (!asset.width || !asset.height) {
376
- const {
377
- width,
378
- height
379
- } = await new Promise((res, rej) => reactNative.Image.getSize(uri, (width, height) => res({
380
- width,
381
- height
382
- }), rej));
383
- asset.width = width;
384
- asset.height = height;
356
+ getAsset(url).then(async uri => {
357
+ // Create safe URI for JSI
358
+ if (uri.startsWith('data:')) {
359
+ const [header, data] = uri.split(',');
360
+ const [, type] = header.split('/');
361
+ uri = fs__namespace.cacheDirectory + uuidv4() + `.${type}`;
362
+ await fs__namespace.writeAsStringAsync(uri, data, {
363
+ encoding: fs__namespace.EncodingType.Base64
364
+ });
385
365
  }
366
+ const {
367
+ width,
368
+ height
369
+ } = await new Promise((res, rej) => reactNative.Image.getSize(uri, (width, height) => res({
370
+ width,
371
+ height
372
+ }), rej));
386
373
  texture.image = {
387
374
  data: {
388
375
  localUri: uri
389
376
  },
390
- width: asset.width,
391
- height: asset.height
377
+ width,
378
+ height
392
379
  };
393
380
  texture.flipY = true;
394
381
  texture.unpackAlignment = 1;
@@ -406,9 +393,7 @@ function polyfills() {
406
393
  THREE__namespace.FileLoader.prototype.load = function load(url, onLoad, onProgress, onError) {
407
394
  if (this.path) url = this.path + url;
408
395
  const request = new XMLHttpRequest();
409
- getAsset(url).then(async asset => {
410
- let uri = asset.localUri || asset.uri;
411
-
396
+ getAsset(url).then(async uri => {
412
397
  // Make FS paths web-safe
413
398
  if (uri.startsWith('file://')) {
414
399
  const data = await fs__namespace.readAsStringAsync(uri, {
@@ -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-6662eaf2.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-6662eaf2.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-dc6125bc.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-dc6125bc.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';
@@ -240,6 +240,7 @@ const CanvasImpl = /*#__PURE__*/React.forwardRef(({
240
240
  ...style
241
241
  }
242
242
  }, bind), width > 0 && /*#__PURE__*/React.createElement(GLView, {
243
+ msaaSamples: 0,
243
244
  onContextCreate: onContextCreate,
244
245
  style: StyleSheet.absoluteFill
245
246
  }));
@@ -280,10 +281,8 @@ function polyfills() {
280
281
  }
281
282
  async function getAsset(input) {
282
283
  if (typeof input === 'string') {
283
- // Point to storage if preceded with fs path
284
- if (input.startsWith('file:')) return {
285
- localUri: input
286
- };
284
+ // Don't process storage or data uris
285
+ if (input.startsWith('file:') || input.startsWith('data:')) return input;
287
286
 
288
287
  // Unpack Blobs from react-native BlobManager
289
288
  if (input.startsWith('blob:')) {
@@ -301,40 +300,24 @@ function polyfills() {
301
300
  reader.onerror = rej;
302
301
  reader.readAsText(blob);
303
302
  });
304
- input = `data:${blob.type};base64,${data}`;
305
- }
306
-
307
- // Create safe URI for JSI
308
- if (input.startsWith('data:')) {
309
- const [header, data] = input.split(',');
310
- const [, type] = header.split('/');
311
- const localUri = fs.cacheDirectory + uuidv4() + `.${type}`;
312
- await fs.writeAsStringAsync(localUri, data, {
313
- encoding: fs.EncodingType.Base64
314
- });
315
- return {
316
- localUri
317
- };
303
+ return `data:${blob.type};base64,${data}`;
318
304
  }
319
305
  }
320
306
 
321
307
  // Download bundler module or external URL
322
- const asset = Asset.fromModule(input);
308
+ const asset = await Asset.fromModule(input).downloadAsync();
309
+ let uri = asset.localUri || asset.uri;
323
310
 
324
311
  // Unpack assets in Android Release Mode
325
- if (!asset.uri.includes(':')) {
326
- const localUri = `${fs.cacheDirectory}ExponentAsset-${asset.hash}.${asset.type}`;
312
+ if (!uri.includes(':')) {
313
+ const file = `${fs.cacheDirectory}ExponentAsset-${asset.hash}.${asset.type}`;
327
314
  await fs.copyAsync({
328
- from: asset.uri,
329
- to: localUri
315
+ from: uri,
316
+ to: file
330
317
  });
331
- return {
332
- localUri
333
- };
318
+ uri = file;
334
319
  }
335
-
336
- // Otherwise, resolve from registry
337
- return asset.downloadAsync();
320
+ return uri;
338
321
  }
339
322
 
340
323
  // Don't pre-process urls, let expo-asset generate an absolute URL
@@ -345,25 +328,29 @@ function polyfills() {
345
328
  THREE.TextureLoader.prototype.load = function load(url, onLoad, onProgress, onError) {
346
329
  if (this.path) url = this.path + url;
347
330
  const texture = new THREE.Texture();
348
- getAsset(url).then(async asset => {
349
- const uri = asset.localUri || asset.uri;
350
- if (!asset.width || !asset.height) {
351
- const {
352
- width,
353
- height
354
- } = await new Promise((res, rej) => Image.getSize(uri, (width, height) => res({
355
- width,
356
- height
357
- }), rej));
358
- asset.width = width;
359
- asset.height = height;
331
+ getAsset(url).then(async uri => {
332
+ // Create safe URI for JSI
333
+ if (uri.startsWith('data:')) {
334
+ const [header, data] = uri.split(',');
335
+ const [, type] = header.split('/');
336
+ uri = fs.cacheDirectory + uuidv4() + `.${type}`;
337
+ await fs.writeAsStringAsync(uri, data, {
338
+ encoding: fs.EncodingType.Base64
339
+ });
360
340
  }
341
+ const {
342
+ width,
343
+ height
344
+ } = await new Promise((res, rej) => Image.getSize(uri, (width, height) => res({
345
+ width,
346
+ height
347
+ }), rej));
361
348
  texture.image = {
362
349
  data: {
363
350
  localUri: uri
364
351
  },
365
- width: asset.width,
366
- height: asset.height
352
+ width,
353
+ height
367
354
  };
368
355
  texture.flipY = true;
369
356
  texture.unpackAlignment = 1;
@@ -381,9 +368,7 @@ function polyfills() {
381
368
  THREE.FileLoader.prototype.load = function load(url, onLoad, onProgress, onError) {
382
369
  if (this.path) url = this.path + url;
383
370
  const request = new XMLHttpRequest();
384
- getAsset(url).then(async asset => {
385
- let uri = asset.localUri || asset.uri;
386
-
371
+ getAsset(url).then(async uri => {
387
372
  // Make FS paths web-safe
388
373
  if (uri.startsWith('file://')) {
389
374
  const data = await fs.readAsStringAsync(uri, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-three/fiber",
3
- "version": "8.14.1",
3
+ "version": "8.14.3",
4
4
  "description": "A React renderer for Threejs",
5
5
  "keywords": [
6
6
  "react",