@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.
- package/CHANGELOG.md +12 -0
- package/dist/declarations/src/core/events.d.ts +71 -71
- package/dist/declarations/src/core/hooks.d.ts +29 -29
- package/dist/declarations/src/core/index.d.ts +57 -57
- 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 -94
- package/dist/declarations/src/index.d.ts +12 -12
- package/dist/declarations/src/native/Canvas.d.ts +10 -10
- 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 +334 -334
- package/dist/declarations/src/web/Canvas.d.ts +13 -13
- package/dist/declarations/src/web/events.d.ts +4 -4
- package/dist/{index-be1f7f7b.cjs.dev.js → index-2f978f7b.cjs.dev.js} +1 -1
- package/dist/{index-dad7ba86.cjs.prod.js → index-a401adf5.cjs.prod.js} +1 -1
- package/dist/{index-6662eaf2.esm.js → index-dc6125bc.esm.js} +1 -1
- 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 +32 -47
- package/native/dist/react-three-fiber-native.cjs.prod.js +32 -47
- package/native/dist/react-three-fiber-native.esm.js +33 -48
- package/package.json +1 -1
|
@@ -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-
|
|
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-
|
|
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-
|
|
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-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-
|
|
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
|
-
//
|
|
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
|
-
|
|
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 (!
|
|
351
|
-
const
|
|
337
|
+
if (!uri.includes(':')) {
|
|
338
|
+
const file = `${fs__namespace.cacheDirectory}ExponentAsset-${asset.hash}.${asset.type}`;
|
|
352
339
|
await fs__namespace.copyAsync({
|
|
353
|
-
from:
|
|
354
|
-
to:
|
|
340
|
+
from: uri,
|
|
341
|
+
to: file
|
|
355
342
|
});
|
|
356
|
-
|
|
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
|
|
374
|
-
|
|
375
|
-
if (
|
|
376
|
-
const
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
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
|
|
391
|
-
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
|
|
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-
|
|
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
|
-
//
|
|
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
|
-
|
|
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 (!
|
|
351
|
-
const
|
|
337
|
+
if (!uri.includes(':')) {
|
|
338
|
+
const file = `${fs__namespace.cacheDirectory}ExponentAsset-${asset.hash}.${asset.type}`;
|
|
352
339
|
await fs__namespace.copyAsync({
|
|
353
|
-
from:
|
|
354
|
-
to:
|
|
340
|
+
from: uri,
|
|
341
|
+
to: file
|
|
355
342
|
});
|
|
356
|
-
|
|
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
|
|
374
|
-
|
|
375
|
-
if (
|
|
376
|
-
const
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
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
|
|
391
|
-
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
|
|
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-
|
|
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-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
|
-
//
|
|
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
|
-
|
|
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 (!
|
|
326
|
-
const
|
|
312
|
+
if (!uri.includes(':')) {
|
|
313
|
+
const file = `${fs.cacheDirectory}ExponentAsset-${asset.hash}.${asset.type}`;
|
|
327
314
|
await fs.copyAsync({
|
|
328
|
-
from:
|
|
329
|
-
to:
|
|
315
|
+
from: uri,
|
|
316
|
+
to: file
|
|
330
317
|
});
|
|
331
|
-
|
|
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
|
|
349
|
-
|
|
350
|
-
if (
|
|
351
|
-
const
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
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
|
|
366
|
-
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
|
|
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, {
|