react-three-game 0.0.8 → 0.0.10
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/README.md +27 -0
- package/dist/tools/dragdrop/modelLoader.d.ts +1 -1
- package/dist/tools/dragdrop/modelLoader.js +4 -4
- package/dist/tools/prefabeditor/PrefabRoot.js +5 -2
- package/package.json +1 -1
- package/src/tools/dragdrop/modelLoader.ts +2 -3
- package/src/tools/prefabeditor/PrefabRoot.tsx +5 -2
- package/tsconfig.json +0 -18
package/README.md
CHANGED
|
@@ -30,6 +30,33 @@ Scenes are JSON prefabs. Components are registered modules. Hierarchy is declara
|
|
|
30
30
|
}} />
|
|
31
31
|
```
|
|
32
32
|
|
|
33
|
+
## Tailwind CSS Support
|
|
34
|
+
|
|
35
|
+
This library uses Tailwind CSS for styling its editor components. To ensure styles are correctly applied in your application, you need to configure Tailwind to scan the library's source files.
|
|
36
|
+
|
|
37
|
+
### Tailwind v4
|
|
38
|
+
|
|
39
|
+
Add the library path to your CSS entry point using the `@source` directive:
|
|
40
|
+
|
|
41
|
+
```css
|
|
42
|
+
@import "tailwindcss";
|
|
43
|
+
@source "../../node_modules/react-three-game/dist/**/*.{js,ts,jsx,tsx}";
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### Tailwind v3
|
|
47
|
+
|
|
48
|
+
Add the library path to your `tailwind.config.js`:
|
|
49
|
+
|
|
50
|
+
```js
|
|
51
|
+
module.exports = {
|
|
52
|
+
content: [
|
|
53
|
+
// ...
|
|
54
|
+
"./node_modules/react-three-game/dist/**/*.{js,ts,jsx,tsx}",
|
|
55
|
+
],
|
|
56
|
+
// ...
|
|
57
|
+
}
|
|
58
|
+
```
|
|
59
|
+
|
|
33
60
|
## Quick Start
|
|
34
61
|
|
|
35
62
|
```bash
|
|
@@ -4,4 +4,4 @@ export type ModelLoadResult = {
|
|
|
4
4
|
error?: any;
|
|
5
5
|
};
|
|
6
6
|
export type ProgressCallback = (filename: string, loaded: number, total: number) => void;
|
|
7
|
-
export declare function loadModel(filename: string,
|
|
7
|
+
export declare function loadModel(filename: string, onProgress?: ProgressCallback): Promise<ModelLoadResult>;
|
|
@@ -14,11 +14,11 @@ dracoLoader.setDecoderPath("https://www.gstatic.com/draco/v1/decoders/");
|
|
|
14
14
|
const gltfLoader = new GLTFLoader();
|
|
15
15
|
gltfLoader.setDRACOLoader(dracoLoader);
|
|
16
16
|
const fbxLoader = new FBXLoader();
|
|
17
|
-
export function loadModel(
|
|
18
|
-
return __awaiter(this,
|
|
17
|
+
export function loadModel(filename, onProgress) {
|
|
18
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
19
19
|
try {
|
|
20
|
-
//
|
|
21
|
-
const fullPath =
|
|
20
|
+
// Use filename directly (should already include leading /)
|
|
21
|
+
const fullPath = filename;
|
|
22
22
|
if (filename.endsWith('.glb') || filename.endsWith('.gltf')) {
|
|
23
23
|
return new Promise((resolve) => {
|
|
24
24
|
gltfLoader.load(fullPath, (gltf) => resolve({ success: true, model: gltf.scene }), (progressEvent) => {
|
|
@@ -108,7 +108,9 @@ export const PrefabRoot = forwardRef(({ editMode, data, onPrefabChange, selected
|
|
|
108
108
|
for (const filename of modelsToLoad) {
|
|
109
109
|
if (!loadedModels[filename] && !loadingRefs.current.has(filename)) {
|
|
110
110
|
loadingRefs.current.add(filename);
|
|
111
|
-
|
|
111
|
+
// Load model directly from public root, prepend "/" if not present
|
|
112
|
+
const modelPath = filename.startsWith('/') ? filename : `/${filename}`;
|
|
113
|
+
const result = yield loadModel(modelPath);
|
|
112
114
|
if (result.success && result.model) {
|
|
113
115
|
setLoadedModels(prev => (Object.assign(Object.assign({}, prev), { [filename]: result.model })));
|
|
114
116
|
}
|
|
@@ -118,7 +120,8 @@ export const PrefabRoot = forwardRef(({ editMode, data, onPrefabChange, selected
|
|
|
118
120
|
for (const filename of texturesToLoad) {
|
|
119
121
|
if (!loadedTextures[filename] && !loadingRefs.current.has(filename)) {
|
|
120
122
|
loadingRefs.current.add(filename);
|
|
121
|
-
|
|
123
|
+
// Load texture directly from public root, prepend "/" if not present
|
|
124
|
+
const texturePath = filename.startsWith('/') ? filename : `/${filename}`;
|
|
122
125
|
textureLoader.load(texturePath, (texture) => {
|
|
123
126
|
texture.colorSpace = SRGBColorSpace;
|
|
124
127
|
setLoadedTextures(prev => (Object.assign(Object.assign({}, prev), { [filename]: texture })));
|
package/package.json
CHANGED
|
@@ -19,12 +19,11 @@ const fbxLoader = new FBXLoader();
|
|
|
19
19
|
|
|
20
20
|
export async function loadModel(
|
|
21
21
|
filename: string,
|
|
22
|
-
resourcePath: string = "",
|
|
23
22
|
onProgress?: ProgressCallback
|
|
24
23
|
): Promise<ModelLoadResult> {
|
|
25
24
|
try {
|
|
26
|
-
//
|
|
27
|
-
const fullPath =
|
|
25
|
+
// Use filename directly (should already include leading /)
|
|
26
|
+
const fullPath = filename;
|
|
28
27
|
|
|
29
28
|
if (filename.endsWith('.glb') || filename.endsWith('.gltf')) {
|
|
30
29
|
return new Promise((resolve) => {
|
|
@@ -133,7 +133,9 @@ export const PrefabRoot = forwardRef<Group, {
|
|
|
133
133
|
for (const filename of modelsToLoad) {
|
|
134
134
|
if (!loadedModels[filename] && !loadingRefs.current.has(filename)) {
|
|
135
135
|
loadingRefs.current.add(filename);
|
|
136
|
-
|
|
136
|
+
// Load model directly from public root, prepend "/" if not present
|
|
137
|
+
const modelPath = filename.startsWith('/') ? filename : `/${filename}`;
|
|
138
|
+
const result = await loadModel(modelPath);
|
|
137
139
|
if (result.success && result.model) {
|
|
138
140
|
setLoadedModels(prev => ({ ...prev, [filename]: result.model }));
|
|
139
141
|
}
|
|
@@ -144,7 +146,8 @@ export const PrefabRoot = forwardRef<Group, {
|
|
|
144
146
|
for (const filename of texturesToLoad) {
|
|
145
147
|
if (!loadedTextures[filename] && !loadingRefs.current.has(filename)) {
|
|
146
148
|
loadingRefs.current.add(filename);
|
|
147
|
-
|
|
149
|
+
// Load texture directly from public root, prepend "/" if not present
|
|
150
|
+
const texturePath = filename.startsWith('/') ? filename : `/${filename}`;
|
|
148
151
|
textureLoader.load(texturePath, (texture) => {
|
|
149
152
|
texture.colorSpace = SRGBColorSpace;
|
|
150
153
|
setLoadedTextures(prev => ({ ...prev, [filename]: texture }));
|
package/tsconfig.json
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "ES6",
|
|
4
|
-
"lib": ["ES2017", "DOM"],
|
|
5
|
-
"module": "ESNext",
|
|
6
|
-
"jsx": "react-jsx",
|
|
7
|
-
"declaration": true,
|
|
8
|
-
"declarationDir": "dist",
|
|
9
|
-
"outDir": "dist",
|
|
10
|
-
"strict": true,
|
|
11
|
-
"esModuleInterop": true,
|
|
12
|
-
"skipLibCheck": true,
|
|
13
|
-
"moduleResolution": "bundler",
|
|
14
|
-
"allowSyntheticDefaultImports": true
|
|
15
|
-
},
|
|
16
|
-
"include": ["src"],
|
|
17
|
-
"exclude": ["node_modules", "dist"]
|
|
18
|
-
}
|