@react-three/fiber 8.14.4 → 8.14.6
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/native/polyfills.d.ts +1 -1
- package/dist/{index-a401adf5.cjs.prod.js → index-0ed4bbca.cjs.prod.js} +7 -1
- package/dist/{index-dc6125bc.esm.js → index-563322db.esm.js} +7 -1
- package/dist/{index-2f978f7b.cjs.dev.js → index-886811f8.cjs.dev.js} +7 -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 +22 -119
- package/native/dist/react-three-fiber-native.cjs.prod.js +22 -119
- package/native/dist/react-three-fiber-native.esm.js +24 -120
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @react-three/fiber
|
|
2
2
|
|
|
3
|
+
## 8.14.6
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 465fa0fb: fix(native): revert usage of networking stack
|
|
8
|
+
|
|
9
|
+
## 8.14.5
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- f372a5b5: fix(applyProps): loosen copy identity in dev
|
|
14
|
+
|
|
3
15
|
## 8.14.4
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function
|
|
1
|
+
export declare function _polyfills(): void;
|
|
@@ -643,6 +643,7 @@ function diffProps(instance, {
|
|
|
643
643
|
changes
|
|
644
644
|
};
|
|
645
645
|
}
|
|
646
|
+
const __DEV__ = typeof process !== 'undefined' && "production" !== 'production';
|
|
646
647
|
|
|
647
648
|
// This function applies a set of changes to the instance
|
|
648
649
|
function applyProps$1(instance, data) {
|
|
@@ -723,7 +724,12 @@ function applyProps$1(instance, data) {
|
|
|
723
724
|
if (targetProp.fromArray) targetProp.fromArray(value);else targetProp.set(...value);
|
|
724
725
|
}
|
|
725
726
|
// Test again target.copy(class) next ...
|
|
726
|
-
else if (targetProp.copy && value && value.constructor &&
|
|
727
|
+
else if (targetProp.copy && value && value.constructor && (
|
|
728
|
+
// Some environments may break strict identity checks by duplicating versions of three.js.
|
|
729
|
+
// Loosen to unminified names, ignoring descendents.
|
|
730
|
+
// https://github.com/pmndrs/react-three-fiber/issues/2856
|
|
731
|
+
// TODO: fix upstream and remove in v9
|
|
732
|
+
__DEV__ ? targetProp.constructor.name === value.constructor.name : targetProp.constructor === value.constructor)) {
|
|
727
733
|
targetProp.copy(value);
|
|
728
734
|
}
|
|
729
735
|
// If nothing else fits, just set the single value, ignore undefined
|
|
@@ -616,6 +616,7 @@ function diffProps(instance, {
|
|
|
616
616
|
changes
|
|
617
617
|
};
|
|
618
618
|
}
|
|
619
|
+
const __DEV__ = typeof process !== 'undefined' && process.env.NODE_ENV !== 'production';
|
|
619
620
|
|
|
620
621
|
// This function applies a set of changes to the instance
|
|
621
622
|
function applyProps$1(instance, data) {
|
|
@@ -696,7 +697,12 @@ function applyProps$1(instance, data) {
|
|
|
696
697
|
if (targetProp.fromArray) targetProp.fromArray(value);else targetProp.set(...value);
|
|
697
698
|
}
|
|
698
699
|
// Test again target.copy(class) next ...
|
|
699
|
-
else if (targetProp.copy && value && value.constructor &&
|
|
700
|
+
else if (targetProp.copy && value && value.constructor && (
|
|
701
|
+
// Some environments may break strict identity checks by duplicating versions of three.js.
|
|
702
|
+
// Loosen to unminified names, ignoring descendents.
|
|
703
|
+
// https://github.com/pmndrs/react-three-fiber/issues/2856
|
|
704
|
+
// TODO: fix upstream and remove in v9
|
|
705
|
+
__DEV__ ? targetProp.constructor.name === value.constructor.name : targetProp.constructor === value.constructor)) {
|
|
700
706
|
targetProp.copy(value);
|
|
701
707
|
}
|
|
702
708
|
// If nothing else fits, just set the single value, ignore undefined
|
|
@@ -643,6 +643,7 @@ function diffProps(instance, {
|
|
|
643
643
|
changes
|
|
644
644
|
};
|
|
645
645
|
}
|
|
646
|
+
const __DEV__ = typeof process !== 'undefined' && process.env.NODE_ENV !== 'production';
|
|
646
647
|
|
|
647
648
|
// This function applies a set of changes to the instance
|
|
648
649
|
function applyProps$1(instance, data) {
|
|
@@ -723,7 +724,12 @@ function applyProps$1(instance, data) {
|
|
|
723
724
|
if (targetProp.fromArray) targetProp.fromArray(value);else targetProp.set(...value);
|
|
724
725
|
}
|
|
725
726
|
// Test again target.copy(class) next ...
|
|
726
|
-
else if (targetProp.copy && value && value.constructor &&
|
|
727
|
+
else if (targetProp.copy && value && value.constructor && (
|
|
728
|
+
// Some environments may break strict identity checks by duplicating versions of three.js.
|
|
729
|
+
// Loosen to unminified names, ignoring descendents.
|
|
730
|
+
// https://github.com/pmndrs/react-three-fiber/issues/2856
|
|
731
|
+
// TODO: fix upstream and remove in v9
|
|
732
|
+
__DEV__ ? targetProp.constructor.name === value.constructor.name : targetProp.constructor === value.constructor)) {
|
|
727
733
|
targetProp.copy(value);
|
|
728
734
|
}
|
|
729
735
|
// If nothing else fits, just set the single value, ignore undefined
|
|
@@ -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-886811f8.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-0ed4bbca.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-563322db.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-563322db.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-886811f8.cjs.dev.js');
|
|
6
6
|
var _extends = require('@babel/runtime/helpers/extends');
|
|
7
7
|
var React = require('react');
|
|
8
8
|
var THREE = require('three');
|
|
@@ -10,8 +10,7 @@ var reactNative = require('react-native');
|
|
|
10
10
|
var expoGl = require('expo-gl');
|
|
11
11
|
var itsFine = require('its-fine');
|
|
12
12
|
var expoAsset = require('expo-asset');
|
|
13
|
-
var
|
|
14
|
-
var base64Js = require('base64-js');
|
|
13
|
+
var expoFileSystem = require('expo-file-system');
|
|
15
14
|
require('react-reconciler/constants');
|
|
16
15
|
require('zustand');
|
|
17
16
|
require('react-reconciler');
|
|
@@ -38,7 +37,6 @@ function _interopNamespace(e) {
|
|
|
38
37
|
|
|
39
38
|
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
40
39
|
var THREE__namespace = /*#__PURE__*/_interopNamespace(THREE);
|
|
41
|
-
var fs__namespace = /*#__PURE__*/_interopNamespace(fs);
|
|
42
40
|
|
|
43
41
|
/** Default R3F event manager for react-native */
|
|
44
42
|
function createTouchEvents(store) {
|
|
@@ -281,101 +279,22 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(function CanvasWrapper(p
|
|
|
281
279
|
})));
|
|
282
280
|
});
|
|
283
281
|
|
|
284
|
-
function
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
v = c == 'x' ? r : r & 0x3 | 0x8;
|
|
289
|
-
return v.toString(16);
|
|
290
|
-
});
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
// Patch Blob for ArrayBuffer if unsupported
|
|
294
|
-
if (reactNative.Platform.OS !== 'web') {
|
|
295
|
-
try {
|
|
296
|
-
new Blob([new ArrayBuffer(4)]);
|
|
297
|
-
} catch (_) {
|
|
298
|
-
const BlobManager = require('react-native/Libraries/Blob/BlobManager.js');
|
|
299
|
-
BlobManager.createFromParts = function createFromParts(parts, options) {
|
|
300
|
-
const blobId = uuidv4();
|
|
301
|
-
const items = parts.map(part => {
|
|
302
|
-
if (part instanceof ArrayBuffer || ArrayBuffer.isView(part)) {
|
|
303
|
-
const data = base64Js.fromByteArray(new Uint8Array(part));
|
|
304
|
-
return {
|
|
305
|
-
data,
|
|
306
|
-
type: 'string'
|
|
307
|
-
};
|
|
308
|
-
} else if (part instanceof Blob) {
|
|
309
|
-
return {
|
|
310
|
-
data: part.data,
|
|
311
|
-
type: 'blob'
|
|
312
|
-
};
|
|
313
|
-
} else {
|
|
314
|
-
return {
|
|
315
|
-
data: String(part),
|
|
316
|
-
type: 'string'
|
|
317
|
-
};
|
|
318
|
-
}
|
|
319
|
-
});
|
|
320
|
-
const size = items.reduce((acc, curr) => {
|
|
321
|
-
if (curr.type === 'string') {
|
|
322
|
-
return acc + global.unescape(encodeURI(curr.data)).length;
|
|
323
|
-
} else {
|
|
324
|
-
return acc + curr.data.size;
|
|
325
|
-
}
|
|
326
|
-
}, 0);
|
|
327
|
-
reactNative.NativeModules.BlobModule.createFromParts(items, blobId);
|
|
328
|
-
return BlobManager.createFromOptions({
|
|
329
|
-
blobId,
|
|
330
|
-
offset: 0,
|
|
331
|
-
size,
|
|
332
|
-
type: options ? options.type : '',
|
|
333
|
-
lastModified: options ? options.lastModified : Date.now()
|
|
334
|
-
});
|
|
335
|
-
};
|
|
336
|
-
}
|
|
337
|
-
}
|
|
338
|
-
async function getAsset(input) {
|
|
339
|
-
if (typeof input === 'string') {
|
|
340
|
-
// Don't process storage or data uris
|
|
341
|
-
if (input.startsWith('file:') || input.startsWith('data:')) return input;
|
|
342
|
-
|
|
343
|
-
// Unpack Blobs from react-native BlobManager
|
|
344
|
-
if (input.startsWith('blob:')) {
|
|
345
|
-
const blob = await new Promise((res, rej) => {
|
|
346
|
-
const xhr = new XMLHttpRequest();
|
|
347
|
-
xhr.open('GET', input);
|
|
348
|
-
xhr.responseType = 'blob';
|
|
349
|
-
xhr.onload = () => res(xhr.response);
|
|
350
|
-
xhr.onerror = rej;
|
|
351
|
-
xhr.send();
|
|
352
|
-
});
|
|
353
|
-
const data = await new Promise((res, rej) => {
|
|
354
|
-
const reader = new FileReader();
|
|
355
|
-
reader.onload = () => res(reader.result);
|
|
356
|
-
reader.onerror = rej;
|
|
357
|
-
reader.readAsText(blob);
|
|
358
|
-
});
|
|
359
|
-
return `data:${blob.type};base64,${data}`;
|
|
360
|
-
}
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
// Download bundler module or external URL
|
|
364
|
-
const asset = await expoAsset.Asset.fromModule(input).downloadAsync();
|
|
365
|
-
let uri = asset.localUri || asset.uri;
|
|
282
|
+
async function getAsset(input) {
|
|
283
|
+
const asset = typeof input === 'string' ? expoAsset.Asset.fromURI(input) : expoAsset.Asset.fromModule(input);
|
|
284
|
+
await asset.downloadAsync();
|
|
285
|
+
let localUri = asset.localUri || asset.uri;
|
|
366
286
|
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
uri = file;
|
|
375
|
-
}
|
|
376
|
-
return uri;
|
|
287
|
+
// Unpack assets in Android Release Mode
|
|
288
|
+
if (!localUri.includes('://')) {
|
|
289
|
+
localUri = `${expoFileSystem.cacheDirectory}ExponentAsset-${asset.hash}.${asset.type}`;
|
|
290
|
+
await expoFileSystem.copyAsync({
|
|
291
|
+
from: localUri,
|
|
292
|
+
to: localUri
|
|
293
|
+
});
|
|
377
294
|
}
|
|
378
|
-
|
|
295
|
+
return localUri;
|
|
296
|
+
}
|
|
297
|
+
function _polyfills() {
|
|
379
298
|
// Don't pre-process urls, let expo-asset generate an absolute URL
|
|
380
299
|
const extractUrlBase = THREE__namespace.LoaderUtils.extractUrlBase.bind(THREE__namespace.LoaderUtils);
|
|
381
300
|
THREE__namespace.LoaderUtils.extractUrlBase = url => typeof url === 'string' ? extractUrlBase(url) : './';
|
|
@@ -384,26 +303,17 @@ function polyfills() {
|
|
|
384
303
|
THREE__namespace.TextureLoader.prototype.load = function load(url, onLoad, onProgress, onError) {
|
|
385
304
|
if (this.path) url = this.path + url;
|
|
386
305
|
const texture = new THREE__namespace.Texture();
|
|
387
|
-
getAsset(url).then(async
|
|
388
|
-
// Create safe URI for JSI
|
|
389
|
-
if (uri.startsWith('data:')) {
|
|
390
|
-
const [header, data] = uri.split(',');
|
|
391
|
-
const [, type] = header.split('/');
|
|
392
|
-
uri = fs__namespace.cacheDirectory + uuidv4() + `.${type}`;
|
|
393
|
-
await fs__namespace.writeAsStringAsync(uri, data, {
|
|
394
|
-
encoding: fs__namespace.EncodingType.Base64
|
|
395
|
-
});
|
|
396
|
-
}
|
|
306
|
+
getAsset(url).then(async localUri => {
|
|
397
307
|
const {
|
|
398
308
|
width,
|
|
399
309
|
height
|
|
400
|
-
} = await new Promise((res, rej) => reactNative.Image.getSize(
|
|
310
|
+
} = await new Promise((res, rej) => reactNative.Image.getSize(localUri, (width, height) => res({
|
|
401
311
|
width,
|
|
402
312
|
height
|
|
403
313
|
}), rej));
|
|
404
314
|
texture.image = {
|
|
405
315
|
data: {
|
|
406
|
-
localUri
|
|
316
|
+
localUri
|
|
407
317
|
},
|
|
408
318
|
width,
|
|
409
319
|
height
|
|
@@ -424,15 +334,8 @@ function polyfills() {
|
|
|
424
334
|
THREE__namespace.FileLoader.prototype.load = function load(url, onLoad, onProgress, onError) {
|
|
425
335
|
if (this.path) url = this.path + url;
|
|
426
336
|
const request = new XMLHttpRequest();
|
|
427
|
-
getAsset(url).then(
|
|
428
|
-
|
|
429
|
-
if (uri.startsWith('file://')) {
|
|
430
|
-
const data = await fs__namespace.readAsStringAsync(uri, {
|
|
431
|
-
encoding: fs__namespace.EncodingType.Base64
|
|
432
|
-
});
|
|
433
|
-
uri = `data:application/octet-stream;base64,${data}`;
|
|
434
|
-
}
|
|
435
|
-
request.open('GET', uri, true);
|
|
337
|
+
getAsset(url).then(localUri => {
|
|
338
|
+
request.open('GET', localUri, true);
|
|
436
339
|
request.addEventListener('load', event => {
|
|
437
340
|
if (request.status === 200) {
|
|
438
341
|
onLoad == null ? void 0 : onLoad(request.response);
|
|
@@ -468,7 +371,7 @@ function polyfills() {
|
|
|
468
371
|
};
|
|
469
372
|
}
|
|
470
373
|
|
|
471
|
-
|
|
374
|
+
if (reactNative.Platform.OS !== 'web') _polyfills();
|
|
472
375
|
|
|
473
376
|
exports.ReactThreeFiber = index.threeTypes;
|
|
474
377
|
exports._roots = index.roots;
|
|
@@ -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-0ed4bbca.cjs.prod.js');
|
|
6
6
|
var _extends = require('@babel/runtime/helpers/extends');
|
|
7
7
|
var React = require('react');
|
|
8
8
|
var THREE = require('three');
|
|
@@ -10,8 +10,7 @@ var reactNative = require('react-native');
|
|
|
10
10
|
var expoGl = require('expo-gl');
|
|
11
11
|
var itsFine = require('its-fine');
|
|
12
12
|
var expoAsset = require('expo-asset');
|
|
13
|
-
var
|
|
14
|
-
var base64Js = require('base64-js');
|
|
13
|
+
var expoFileSystem = require('expo-file-system');
|
|
15
14
|
require('react-reconciler/constants');
|
|
16
15
|
require('zustand');
|
|
17
16
|
require('react-reconciler');
|
|
@@ -38,7 +37,6 @@ function _interopNamespace(e) {
|
|
|
38
37
|
|
|
39
38
|
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
40
39
|
var THREE__namespace = /*#__PURE__*/_interopNamespace(THREE);
|
|
41
|
-
var fs__namespace = /*#__PURE__*/_interopNamespace(fs);
|
|
42
40
|
|
|
43
41
|
/** Default R3F event manager for react-native */
|
|
44
42
|
function createTouchEvents(store) {
|
|
@@ -281,101 +279,22 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(function CanvasWrapper(p
|
|
|
281
279
|
})));
|
|
282
280
|
});
|
|
283
281
|
|
|
284
|
-
function
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
v = c == 'x' ? r : r & 0x3 | 0x8;
|
|
289
|
-
return v.toString(16);
|
|
290
|
-
});
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
// Patch Blob for ArrayBuffer if unsupported
|
|
294
|
-
if (reactNative.Platform.OS !== 'web') {
|
|
295
|
-
try {
|
|
296
|
-
new Blob([new ArrayBuffer(4)]);
|
|
297
|
-
} catch (_) {
|
|
298
|
-
const BlobManager = require('react-native/Libraries/Blob/BlobManager.js');
|
|
299
|
-
BlobManager.createFromParts = function createFromParts(parts, options) {
|
|
300
|
-
const blobId = uuidv4();
|
|
301
|
-
const items = parts.map(part => {
|
|
302
|
-
if (part instanceof ArrayBuffer || ArrayBuffer.isView(part)) {
|
|
303
|
-
const data = base64Js.fromByteArray(new Uint8Array(part));
|
|
304
|
-
return {
|
|
305
|
-
data,
|
|
306
|
-
type: 'string'
|
|
307
|
-
};
|
|
308
|
-
} else if (part instanceof Blob) {
|
|
309
|
-
return {
|
|
310
|
-
data: part.data,
|
|
311
|
-
type: 'blob'
|
|
312
|
-
};
|
|
313
|
-
} else {
|
|
314
|
-
return {
|
|
315
|
-
data: String(part),
|
|
316
|
-
type: 'string'
|
|
317
|
-
};
|
|
318
|
-
}
|
|
319
|
-
});
|
|
320
|
-
const size = items.reduce((acc, curr) => {
|
|
321
|
-
if (curr.type === 'string') {
|
|
322
|
-
return acc + global.unescape(encodeURI(curr.data)).length;
|
|
323
|
-
} else {
|
|
324
|
-
return acc + curr.data.size;
|
|
325
|
-
}
|
|
326
|
-
}, 0);
|
|
327
|
-
reactNative.NativeModules.BlobModule.createFromParts(items, blobId);
|
|
328
|
-
return BlobManager.createFromOptions({
|
|
329
|
-
blobId,
|
|
330
|
-
offset: 0,
|
|
331
|
-
size,
|
|
332
|
-
type: options ? options.type : '',
|
|
333
|
-
lastModified: options ? options.lastModified : Date.now()
|
|
334
|
-
});
|
|
335
|
-
};
|
|
336
|
-
}
|
|
337
|
-
}
|
|
338
|
-
async function getAsset(input) {
|
|
339
|
-
if (typeof input === 'string') {
|
|
340
|
-
// Don't process storage or data uris
|
|
341
|
-
if (input.startsWith('file:') || input.startsWith('data:')) return input;
|
|
342
|
-
|
|
343
|
-
// Unpack Blobs from react-native BlobManager
|
|
344
|
-
if (input.startsWith('blob:')) {
|
|
345
|
-
const blob = await new Promise((res, rej) => {
|
|
346
|
-
const xhr = new XMLHttpRequest();
|
|
347
|
-
xhr.open('GET', input);
|
|
348
|
-
xhr.responseType = 'blob';
|
|
349
|
-
xhr.onload = () => res(xhr.response);
|
|
350
|
-
xhr.onerror = rej;
|
|
351
|
-
xhr.send();
|
|
352
|
-
});
|
|
353
|
-
const data = await new Promise((res, rej) => {
|
|
354
|
-
const reader = new FileReader();
|
|
355
|
-
reader.onload = () => res(reader.result);
|
|
356
|
-
reader.onerror = rej;
|
|
357
|
-
reader.readAsText(blob);
|
|
358
|
-
});
|
|
359
|
-
return `data:${blob.type};base64,${data}`;
|
|
360
|
-
}
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
// Download bundler module or external URL
|
|
364
|
-
const asset = await expoAsset.Asset.fromModule(input).downloadAsync();
|
|
365
|
-
let uri = asset.localUri || asset.uri;
|
|
282
|
+
async function getAsset(input) {
|
|
283
|
+
const asset = typeof input === 'string' ? expoAsset.Asset.fromURI(input) : expoAsset.Asset.fromModule(input);
|
|
284
|
+
await asset.downloadAsync();
|
|
285
|
+
let localUri = asset.localUri || asset.uri;
|
|
366
286
|
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
uri = file;
|
|
375
|
-
}
|
|
376
|
-
return uri;
|
|
287
|
+
// Unpack assets in Android Release Mode
|
|
288
|
+
if (!localUri.includes('://')) {
|
|
289
|
+
localUri = `${expoFileSystem.cacheDirectory}ExponentAsset-${asset.hash}.${asset.type}`;
|
|
290
|
+
await expoFileSystem.copyAsync({
|
|
291
|
+
from: localUri,
|
|
292
|
+
to: localUri
|
|
293
|
+
});
|
|
377
294
|
}
|
|
378
|
-
|
|
295
|
+
return localUri;
|
|
296
|
+
}
|
|
297
|
+
function _polyfills() {
|
|
379
298
|
// Don't pre-process urls, let expo-asset generate an absolute URL
|
|
380
299
|
const extractUrlBase = THREE__namespace.LoaderUtils.extractUrlBase.bind(THREE__namespace.LoaderUtils);
|
|
381
300
|
THREE__namespace.LoaderUtils.extractUrlBase = url => typeof url === 'string' ? extractUrlBase(url) : './';
|
|
@@ -384,26 +303,17 @@ function polyfills() {
|
|
|
384
303
|
THREE__namespace.TextureLoader.prototype.load = function load(url, onLoad, onProgress, onError) {
|
|
385
304
|
if (this.path) url = this.path + url;
|
|
386
305
|
const texture = new THREE__namespace.Texture();
|
|
387
|
-
getAsset(url).then(async
|
|
388
|
-
// Create safe URI for JSI
|
|
389
|
-
if (uri.startsWith('data:')) {
|
|
390
|
-
const [header, data] = uri.split(',');
|
|
391
|
-
const [, type] = header.split('/');
|
|
392
|
-
uri = fs__namespace.cacheDirectory + uuidv4() + `.${type}`;
|
|
393
|
-
await fs__namespace.writeAsStringAsync(uri, data, {
|
|
394
|
-
encoding: fs__namespace.EncodingType.Base64
|
|
395
|
-
});
|
|
396
|
-
}
|
|
306
|
+
getAsset(url).then(async localUri => {
|
|
397
307
|
const {
|
|
398
308
|
width,
|
|
399
309
|
height
|
|
400
|
-
} = await new Promise((res, rej) => reactNative.Image.getSize(
|
|
310
|
+
} = await new Promise((res, rej) => reactNative.Image.getSize(localUri, (width, height) => res({
|
|
401
311
|
width,
|
|
402
312
|
height
|
|
403
313
|
}), rej));
|
|
404
314
|
texture.image = {
|
|
405
315
|
data: {
|
|
406
|
-
localUri
|
|
316
|
+
localUri
|
|
407
317
|
},
|
|
408
318
|
width,
|
|
409
319
|
height
|
|
@@ -424,15 +334,8 @@ function polyfills() {
|
|
|
424
334
|
THREE__namespace.FileLoader.prototype.load = function load(url, onLoad, onProgress, onError) {
|
|
425
335
|
if (this.path) url = this.path + url;
|
|
426
336
|
const request = new XMLHttpRequest();
|
|
427
|
-
getAsset(url).then(
|
|
428
|
-
|
|
429
|
-
if (uri.startsWith('file://')) {
|
|
430
|
-
const data = await fs__namespace.readAsStringAsync(uri, {
|
|
431
|
-
encoding: fs__namespace.EncodingType.Base64
|
|
432
|
-
});
|
|
433
|
-
uri = `data:application/octet-stream;base64,${data}`;
|
|
434
|
-
}
|
|
435
|
-
request.open('GET', uri, true);
|
|
337
|
+
getAsset(url).then(localUri => {
|
|
338
|
+
request.open('GET', localUri, true);
|
|
436
339
|
request.addEventListener('load', event => {
|
|
437
340
|
if (request.status === 200) {
|
|
438
341
|
onLoad == null ? void 0 : onLoad(request.response);
|
|
@@ -468,7 +371,7 @@ function polyfills() {
|
|
|
468
371
|
};
|
|
469
372
|
}
|
|
470
373
|
|
|
471
|
-
|
|
374
|
+
if (reactNative.Platform.OS !== 'web') _polyfills();
|
|
472
375
|
|
|
473
376
|
exports.ReactThreeFiber = index.threeTypes;
|
|
474
377
|
exports._roots = index.roots;
|
|
@@ -1,14 +1,13 @@
|
|
|
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-563322db.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-563322db.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';
|
|
6
|
-
import { PanResponder, PixelRatio, View, StyleSheet,
|
|
6
|
+
import { PanResponder, PixelRatio, View, StyleSheet, Image, Platform } from 'react-native';
|
|
7
7
|
import { GLView } from 'expo-gl';
|
|
8
8
|
import { FiberProvider, useContextBridge } from 'its-fine';
|
|
9
9
|
import { Asset } from 'expo-asset';
|
|
10
|
-
import
|
|
11
|
-
import { fromByteArray } from 'base64-js';
|
|
10
|
+
import { cacheDirectory, copyAsync } from 'expo-file-system';
|
|
12
11
|
import 'react-reconciler/constants';
|
|
13
12
|
import 'zustand';
|
|
14
13
|
import 'react-reconciler';
|
|
@@ -256,101 +255,22 @@ const Canvas = /*#__PURE__*/React.forwardRef(function CanvasWrapper(props, ref)
|
|
|
256
255
|
})));
|
|
257
256
|
});
|
|
258
257
|
|
|
259
|
-
function
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
v = c == 'x' ? r : r & 0x3 | 0x8;
|
|
264
|
-
return v.toString(16);
|
|
265
|
-
});
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
// Patch Blob for ArrayBuffer if unsupported
|
|
269
|
-
if (Platform.OS !== 'web') {
|
|
270
|
-
try {
|
|
271
|
-
new Blob([new ArrayBuffer(4)]);
|
|
272
|
-
} catch (_) {
|
|
273
|
-
const BlobManager = require('react-native/Libraries/Blob/BlobManager.js');
|
|
274
|
-
BlobManager.createFromParts = function createFromParts(parts, options) {
|
|
275
|
-
const blobId = uuidv4();
|
|
276
|
-
const items = parts.map(part => {
|
|
277
|
-
if (part instanceof ArrayBuffer || ArrayBuffer.isView(part)) {
|
|
278
|
-
const data = fromByteArray(new Uint8Array(part));
|
|
279
|
-
return {
|
|
280
|
-
data,
|
|
281
|
-
type: 'string'
|
|
282
|
-
};
|
|
283
|
-
} else if (part instanceof Blob) {
|
|
284
|
-
return {
|
|
285
|
-
data: part.data,
|
|
286
|
-
type: 'blob'
|
|
287
|
-
};
|
|
288
|
-
} else {
|
|
289
|
-
return {
|
|
290
|
-
data: String(part),
|
|
291
|
-
type: 'string'
|
|
292
|
-
};
|
|
293
|
-
}
|
|
294
|
-
});
|
|
295
|
-
const size = items.reduce((acc, curr) => {
|
|
296
|
-
if (curr.type === 'string') {
|
|
297
|
-
return acc + global.unescape(encodeURI(curr.data)).length;
|
|
298
|
-
} else {
|
|
299
|
-
return acc + curr.data.size;
|
|
300
|
-
}
|
|
301
|
-
}, 0);
|
|
302
|
-
NativeModules.BlobModule.createFromParts(items, blobId);
|
|
303
|
-
return BlobManager.createFromOptions({
|
|
304
|
-
blobId,
|
|
305
|
-
offset: 0,
|
|
306
|
-
size,
|
|
307
|
-
type: options ? options.type : '',
|
|
308
|
-
lastModified: options ? options.lastModified : Date.now()
|
|
309
|
-
});
|
|
310
|
-
};
|
|
311
|
-
}
|
|
312
|
-
}
|
|
313
|
-
async function getAsset(input) {
|
|
314
|
-
if (typeof input === 'string') {
|
|
315
|
-
// Don't process storage or data uris
|
|
316
|
-
if (input.startsWith('file:') || input.startsWith('data:')) return input;
|
|
317
|
-
|
|
318
|
-
// Unpack Blobs from react-native BlobManager
|
|
319
|
-
if (input.startsWith('blob:')) {
|
|
320
|
-
const blob = await new Promise((res, rej) => {
|
|
321
|
-
const xhr = new XMLHttpRequest();
|
|
322
|
-
xhr.open('GET', input);
|
|
323
|
-
xhr.responseType = 'blob';
|
|
324
|
-
xhr.onload = () => res(xhr.response);
|
|
325
|
-
xhr.onerror = rej;
|
|
326
|
-
xhr.send();
|
|
327
|
-
});
|
|
328
|
-
const data = await new Promise((res, rej) => {
|
|
329
|
-
const reader = new FileReader();
|
|
330
|
-
reader.onload = () => res(reader.result);
|
|
331
|
-
reader.onerror = rej;
|
|
332
|
-
reader.readAsText(blob);
|
|
333
|
-
});
|
|
334
|
-
return `data:${blob.type};base64,${data}`;
|
|
335
|
-
}
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
// Download bundler module or external URL
|
|
339
|
-
const asset = await Asset.fromModule(input).downloadAsync();
|
|
340
|
-
let uri = asset.localUri || asset.uri;
|
|
258
|
+
async function getAsset(input) {
|
|
259
|
+
const asset = typeof input === 'string' ? Asset.fromURI(input) : Asset.fromModule(input);
|
|
260
|
+
await asset.downloadAsync();
|
|
261
|
+
let localUri = asset.localUri || asset.uri;
|
|
341
262
|
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
uri = file;
|
|
350
|
-
}
|
|
351
|
-
return uri;
|
|
263
|
+
// Unpack assets in Android Release Mode
|
|
264
|
+
if (!localUri.includes('://')) {
|
|
265
|
+
localUri = `${cacheDirectory}ExponentAsset-${asset.hash}.${asset.type}`;
|
|
266
|
+
await copyAsync({
|
|
267
|
+
from: localUri,
|
|
268
|
+
to: localUri
|
|
269
|
+
});
|
|
352
270
|
}
|
|
353
|
-
|
|
271
|
+
return localUri;
|
|
272
|
+
}
|
|
273
|
+
function _polyfills() {
|
|
354
274
|
// Don't pre-process urls, let expo-asset generate an absolute URL
|
|
355
275
|
const extractUrlBase = THREE.LoaderUtils.extractUrlBase.bind(THREE.LoaderUtils);
|
|
356
276
|
THREE.LoaderUtils.extractUrlBase = url => typeof url === 'string' ? extractUrlBase(url) : './';
|
|
@@ -359,26 +279,17 @@ function polyfills() {
|
|
|
359
279
|
THREE.TextureLoader.prototype.load = function load(url, onLoad, onProgress, onError) {
|
|
360
280
|
if (this.path) url = this.path + url;
|
|
361
281
|
const texture = new THREE.Texture();
|
|
362
|
-
getAsset(url).then(async
|
|
363
|
-
// Create safe URI for JSI
|
|
364
|
-
if (uri.startsWith('data:')) {
|
|
365
|
-
const [header, data] = uri.split(',');
|
|
366
|
-
const [, type] = header.split('/');
|
|
367
|
-
uri = fs.cacheDirectory + uuidv4() + `.${type}`;
|
|
368
|
-
await fs.writeAsStringAsync(uri, data, {
|
|
369
|
-
encoding: fs.EncodingType.Base64
|
|
370
|
-
});
|
|
371
|
-
}
|
|
282
|
+
getAsset(url).then(async localUri => {
|
|
372
283
|
const {
|
|
373
284
|
width,
|
|
374
285
|
height
|
|
375
|
-
} = await new Promise((res, rej) => Image.getSize(
|
|
286
|
+
} = await new Promise((res, rej) => Image.getSize(localUri, (width, height) => res({
|
|
376
287
|
width,
|
|
377
288
|
height
|
|
378
289
|
}), rej));
|
|
379
290
|
texture.image = {
|
|
380
291
|
data: {
|
|
381
|
-
localUri
|
|
292
|
+
localUri
|
|
382
293
|
},
|
|
383
294
|
width,
|
|
384
295
|
height
|
|
@@ -399,15 +310,8 @@ function polyfills() {
|
|
|
399
310
|
THREE.FileLoader.prototype.load = function load(url, onLoad, onProgress, onError) {
|
|
400
311
|
if (this.path) url = this.path + url;
|
|
401
312
|
const request = new XMLHttpRequest();
|
|
402
|
-
getAsset(url).then(
|
|
403
|
-
|
|
404
|
-
if (uri.startsWith('file://')) {
|
|
405
|
-
const data = await fs.readAsStringAsync(uri, {
|
|
406
|
-
encoding: fs.EncodingType.Base64
|
|
407
|
-
});
|
|
408
|
-
uri = `data:application/octet-stream;base64,${data}`;
|
|
409
|
-
}
|
|
410
|
-
request.open('GET', uri, true);
|
|
313
|
+
getAsset(url).then(localUri => {
|
|
314
|
+
request.open('GET', localUri, true);
|
|
411
315
|
request.addEventListener('load', event => {
|
|
412
316
|
if (request.status === 200) {
|
|
413
317
|
onLoad == null ? void 0 : onLoad(request.response);
|
|
@@ -443,6 +347,6 @@ function polyfills() {
|
|
|
443
347
|
};
|
|
444
348
|
}
|
|
445
349
|
|
|
446
|
-
|
|
350
|
+
if (Platform.OS !== 'web') _polyfills();
|
|
447
351
|
|
|
448
352
|
export { Canvas, createTouchEvents as events };
|