react-three-game 0.0.102 → 0.0.103
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.
|
@@ -139,15 +139,12 @@ function TextureSphere({ url, onError }) {
|
|
|
139
139
|
const onErrorRef = useRef(onError);
|
|
140
140
|
onErrorRef.current = onError;
|
|
141
141
|
useEffect(() => {
|
|
142
|
-
var _a;
|
|
143
142
|
let cancelled = false;
|
|
144
|
-
(_a = textureRef.current) === null || _a === void 0 ? void 0 : _a.dispose();
|
|
145
143
|
textureRef.current = null;
|
|
146
144
|
setTexture(null);
|
|
147
145
|
const loader = new TextureLoader();
|
|
148
146
|
loader.load(url, loadedTexture => {
|
|
149
147
|
if (cancelled) {
|
|
150
|
-
loadedTexture.dispose();
|
|
151
148
|
return;
|
|
152
149
|
}
|
|
153
150
|
textureRef.current = loadedTexture;
|
|
@@ -159,9 +156,7 @@ function TextureSphere({ url, onError }) {
|
|
|
159
156
|
}
|
|
160
157
|
});
|
|
161
158
|
return () => {
|
|
162
|
-
var _a;
|
|
163
159
|
cancelled = true;
|
|
164
|
-
(_a = textureRef.current) === null || _a === void 0 ? void 0 : _a.dispose();
|
|
165
160
|
textureRef.current = null;
|
|
166
161
|
};
|
|
167
162
|
}, [url]);
|
|
@@ -10,7 +10,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
10
10
|
return t;
|
|
11
11
|
};
|
|
12
12
|
import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
-
import { createContext, useContext,
|
|
13
|
+
import { createContext, useContext, useLayoutEffect, useMemo, useRef } from 'react';
|
|
14
14
|
import { extend } from '@react-three/fiber';
|
|
15
15
|
import { useFrame } from '@react-three/fiber';
|
|
16
16
|
import { assetRef, assetRefs } from './ComponentRegistry';
|
|
@@ -57,32 +57,28 @@ function configureTexture(texture, options) {
|
|
|
57
57
|
texture.magFilter = options.magFilter;
|
|
58
58
|
texture.needsUpdate = true;
|
|
59
59
|
}
|
|
60
|
-
function cloneConfiguredTexture(texture, options) {
|
|
61
|
-
if (!texture)
|
|
62
|
-
return undefined;
|
|
63
|
-
const nextTexture = texture.clone();
|
|
64
|
-
configureTexture(nextTexture, options);
|
|
65
|
-
return nextTexture;
|
|
66
|
-
}
|
|
67
60
|
function useConfiguredTexture(texture, options) {
|
|
68
|
-
|
|
69
|
-
const configuredTexture = useMemo(() =>
|
|
70
|
-
useEffect(() => {
|
|
71
|
-
return () => configuredTexture === null || configuredTexture === void 0 ? void 0 : configuredTexture.dispose();
|
|
72
|
-
}, [configuredTexture]);
|
|
61
|
+
const { colorSpace, repeat, repeatCount, offset, generateMipmaps, minFilter, magFilter, } = options;
|
|
62
|
+
const configuredTexture = useMemo(() => texture === null || texture === void 0 ? void 0 : texture.clone(), [texture]);
|
|
73
63
|
useLayoutEffect(() => {
|
|
74
|
-
configureTexture(configuredTexture,
|
|
64
|
+
configureTexture(configuredTexture, {
|
|
65
|
+
colorSpace,
|
|
66
|
+
repeat,
|
|
67
|
+
repeatCount,
|
|
68
|
+
offset,
|
|
69
|
+
generateMipmaps,
|
|
70
|
+
minFilter,
|
|
71
|
+
magFilter,
|
|
72
|
+
});
|
|
75
73
|
}, [
|
|
76
74
|
configuredTexture,
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
options.minFilter,
|
|
85
|
-
options.magFilter,
|
|
75
|
+
colorSpace,
|
|
76
|
+
repeat,
|
|
77
|
+
repeatCount,
|
|
78
|
+
offset,
|
|
79
|
+
generateMipmaps,
|
|
80
|
+
minFilter,
|
|
81
|
+
magFilter,
|
|
86
82
|
]);
|
|
87
83
|
return configuredTexture;
|
|
88
84
|
}
|