react-three-game 0.0.70 → 0.0.71
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/dist/index.d.ts +10 -5
- package/dist/index.js +7 -2
- package/dist/tools/prefabeditor/EditorTree.js +2 -12
- package/dist/tools/prefabeditor/EditorTreeMenus.js +1 -19
- package/dist/tools/prefabeditor/EditorUI.js +2 -1
- package/dist/tools/prefabeditor/PrefabEditor.d.ts +1 -1
- package/dist/tools/prefabeditor/PrefabEditor.js +12 -21
- package/dist/tools/prefabeditor/PrefabRoot.d.ts +25 -12
- package/dist/tools/prefabeditor/PrefabRoot.js +61 -28
- package/dist/tools/prefabeditor/RefBridge.d.ts +24 -0
- package/dist/tools/prefabeditor/RefBridge.js +44 -0
- package/dist/tools/prefabeditor/components/AmbientLightComponent.js +10 -7
- package/dist/tools/prefabeditor/components/CameraComponent.js +8 -14
- package/dist/tools/prefabeditor/components/ClickComponent.js +2 -0
- package/dist/tools/prefabeditor/components/ComponentRegistry.d.ts +21 -1
- package/dist/tools/prefabeditor/components/DirectionalLightComponent.js +124 -52
- package/dist/tools/prefabeditor/components/EnvironmentComponent.js +5 -3
- package/dist/tools/prefabeditor/components/MaterialComponent.js +9 -6
- package/dist/tools/prefabeditor/components/ModelComponent.js +4 -2
- package/dist/tools/prefabeditor/components/PhysicsComponent.js +5 -3
- package/dist/tools/prefabeditor/components/PointLightComponent.d.ts +3 -0
- package/dist/tools/prefabeditor/components/PointLightComponent.js +55 -0
- package/dist/tools/prefabeditor/components/SoundComponent.js +20 -16
- package/dist/tools/prefabeditor/components/SpotLightComponent.js +48 -24
- package/dist/tools/prefabeditor/components/index.js +2 -0
- package/dist/tools/prefabeditor/components/lightUtils.d.ts +13 -0
- package/dist/tools/prefabeditor/components/lightUtils.js +64 -0
- package/dist/tools/prefabeditor/prefab.d.ts +37 -0
- package/dist/tools/prefabeditor/prefab.js +229 -0
- package/dist/tools/prefabeditor/prefabStore.d.ts +3 -16
- package/dist/tools/prefabeditor/prefabStore.js +29 -168
- package/dist/tools/prefabeditor/{sceneApi.js → scene.js} +3 -14
- package/dist/tools/prefabeditor/utils.d.ts +0 -4
- package/dist/tools/prefabeditor/utils.js +0 -37
- package/package.json +1 -1
- /package/dist/tools/prefabeditor/{sceneApi.d.ts → scene.d.ts} +0 -0
|
@@ -1,19 +1,8 @@
|
|
|
1
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
-
var t = {};
|
|
3
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
-
t[p] = s[p];
|
|
5
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
-
t[p[i]] = s[p[i]];
|
|
9
|
-
}
|
|
10
|
-
return t;
|
|
11
|
-
};
|
|
12
1
|
import { createContext, createElement, useContext } from "react";
|
|
13
2
|
import { subscribeWithSelector } from "zustand/middleware";
|
|
14
3
|
import { useStore } from "zustand";
|
|
15
4
|
import { createStore } from "zustand/vanilla";
|
|
16
|
-
import {
|
|
5
|
+
import { collectAssetRefsForIds, collectSubtreeAssetRefs, collectSubtreeIds, cloneSubtree, createPrefabPatch, denormalizePrefab, insertSubtree, isDescendant, normalizePrefab, updateAssetRefsForNodeChange, } from "./prefab";
|
|
17
6
|
const PrefabStoreContext = createContext(null);
|
|
18
7
|
const EMPTY_CHILD_IDS = [];
|
|
19
8
|
export function PrefabStoreProvider({ store, children, }) {
|
|
@@ -42,8 +31,8 @@ export function usePrefabChildIds(nodeId) {
|
|
|
42
31
|
return usePrefabStore(state => { var _a; return nodeId ? (_a = state.childIdsById[nodeId]) !== null && _a !== void 0 ? _a : EMPTY_CHILD_IDS : EMPTY_CHILD_IDS; });
|
|
43
32
|
}
|
|
44
33
|
export function createPrefabStore(prefab) {
|
|
45
|
-
return createStore()(subscribeWithSelector((set, get) => (Object.assign(Object.assign({},
|
|
46
|
-
set(
|
|
34
|
+
return createStore()(subscribeWithSelector((set, get) => (Object.assign(Object.assign({}, normalizePrefab(prefab)), { replacePrefab: (nextPrefab) => {
|
|
35
|
+
set(normalizePrefab(nextPrefab, get().revision + 1));
|
|
47
36
|
}, updateNode: (id, update) => {
|
|
48
37
|
const state = get();
|
|
49
38
|
const node = state.nodesById[id];
|
|
@@ -53,7 +42,7 @@ export function createPrefabStore(prefab) {
|
|
|
53
42
|
if (nextNode === node)
|
|
54
43
|
return;
|
|
55
44
|
const nextAssetRefCounts = updateAssetRefsForNodeChange(state.assetRefCounts, node, nextNode);
|
|
56
|
-
set(
|
|
45
|
+
set(createPrefabPatch(state, {
|
|
57
46
|
nodesById: Object.assign(Object.assign({}, state.nodesById), { [id]: nextNode }),
|
|
58
47
|
}, nextAssetRefCounts));
|
|
59
48
|
}, updateNodes: (updates) => {
|
|
@@ -75,7 +64,7 @@ export function createPrefabStore(prefab) {
|
|
|
75
64
|
}
|
|
76
65
|
if (!nextNodesById)
|
|
77
66
|
return;
|
|
78
|
-
set(
|
|
67
|
+
set(createPrefabPatch(state, { nodesById: nextNodesById }, nextAssetRefCounts));
|
|
79
68
|
}, addChild: (parentId, node) => {
|
|
80
69
|
var _a;
|
|
81
70
|
const state = get();
|
|
@@ -87,8 +76,11 @@ export function createPrefabStore(prefab) {
|
|
|
87
76
|
const nextAssetRefCounts = Object.assign({}, state.assetRefCounts);
|
|
88
77
|
insertSubtree(node, parentId, nextNodesById, nextChildIdsById, nextParentIdById);
|
|
89
78
|
nextChildIdsById[parentId] = [...((_a = nextChildIdsById[parentId]) !== null && _a !== void 0 ? _a : []), node.id];
|
|
90
|
-
|
|
91
|
-
|
|
79
|
+
collectSubtreeAssetRefs(node).forEach(ref => {
|
|
80
|
+
var _a;
|
|
81
|
+
nextAssetRefCounts[ref] = ((_a = nextAssetRefCounts[ref]) !== null && _a !== void 0 ? _a : 0) + 1;
|
|
82
|
+
});
|
|
83
|
+
set(createPrefabPatch(state, {
|
|
92
84
|
nodesById: nextNodesById,
|
|
93
85
|
childIdsById: nextChildIdsById,
|
|
94
86
|
parentIdById: nextParentIdById,
|
|
@@ -106,14 +98,22 @@ export function createPrefabStore(prefab) {
|
|
|
106
98
|
const nextChildIdsById = Object.assign({}, state.childIdsById);
|
|
107
99
|
const nextParentIdById = Object.assign({}, state.parentIdById);
|
|
108
100
|
const nextAssetRefCounts = Object.assign({}, state.assetRefCounts);
|
|
109
|
-
|
|
101
|
+
collectAssetRefsForIds(idsToDelete, state.nodesById).forEach(ref => {
|
|
102
|
+
var _a;
|
|
103
|
+
const nextCount = ((_a = nextAssetRefCounts[ref]) !== null && _a !== void 0 ? _a : 0) - 1;
|
|
104
|
+
if (nextCount > 0) {
|
|
105
|
+
nextAssetRefCounts[ref] = nextCount;
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
delete nextAssetRefCounts[ref];
|
|
109
|
+
});
|
|
110
110
|
idsToDelete.forEach(nodeId => {
|
|
111
111
|
delete nextNodesById[nodeId];
|
|
112
112
|
delete nextChildIdsById[nodeId];
|
|
113
113
|
delete nextParentIdById[nodeId];
|
|
114
114
|
});
|
|
115
115
|
nextChildIdsById[parentId] = ((_a = nextChildIdsById[parentId]) !== null && _a !== void 0 ? _a : []).filter(childId => childId !== id);
|
|
116
|
-
set(
|
|
116
|
+
set(createPrefabPatch(state, {
|
|
117
117
|
nodesById: nextNodesById,
|
|
118
118
|
childIdsById: nextChildIdsById,
|
|
119
119
|
parentIdById: nextParentIdById,
|
|
@@ -129,7 +129,7 @@ export function createPrefabStore(prefab) {
|
|
|
129
129
|
const nextNodesById = Object.assign({}, state.nodesById);
|
|
130
130
|
const nextChildIdsById = Object.assign({}, state.childIdsById);
|
|
131
131
|
const nextParentIdById = Object.assign({}, state.parentIdById);
|
|
132
|
-
const duplicatedRootId =
|
|
132
|
+
const duplicatedRootId = cloneSubtree(id, parentId, state, nextNodesById, nextChildIdsById, nextParentIdById);
|
|
133
133
|
if (!duplicatedRootId)
|
|
134
134
|
return null;
|
|
135
135
|
const siblings = [...((_a = nextChildIdsById[parentId]) !== null && _a !== void 0 ? _a : [])];
|
|
@@ -142,8 +142,11 @@ export function createPrefabStore(prefab) {
|
|
|
142
142
|
}
|
|
143
143
|
nextChildIdsById[parentId] = siblings;
|
|
144
144
|
const nextAssetRefCounts = Object.assign({}, state.assetRefCounts);
|
|
145
|
-
|
|
146
|
-
|
|
145
|
+
collectAssetRefsForIds(collectSubtreeIds(id, state.childIdsById), state.nodesById).forEach(ref => {
|
|
146
|
+
var _a;
|
|
147
|
+
nextAssetRefCounts[ref] = ((_a = nextAssetRefCounts[ref]) !== null && _a !== void 0 ? _a : 0) + 1;
|
|
148
|
+
});
|
|
149
|
+
set(createPrefabPatch(state, {
|
|
147
150
|
nodesById: nextNodesById,
|
|
148
151
|
childIdsById: nextChildIdsById,
|
|
149
152
|
parentIdById: nextParentIdById,
|
|
@@ -155,7 +158,7 @@ export function createPrefabStore(prefab) {
|
|
|
155
158
|
if (!node)
|
|
156
159
|
return;
|
|
157
160
|
const nextNode = Object.assign(Object.assign({}, node), { [key]: !node[key] });
|
|
158
|
-
set(
|
|
161
|
+
set(createPrefabPatch(state, {
|
|
159
162
|
nodesById: Object.assign(Object.assign({}, state.nodesById), { [id]: nextNode }),
|
|
160
163
|
}));
|
|
161
164
|
}, moveNode: (draggedId, targetId, position) => {
|
|
@@ -194,152 +197,10 @@ export function createPrefabStore(prefab) {
|
|
|
194
197
|
destinationChildren.splice(targetIndex, 0, draggedId);
|
|
195
198
|
nextChildIdsById[destinationParentId] = destinationChildren;
|
|
196
199
|
}
|
|
197
|
-
set(
|
|
200
|
+
set(createPrefabPatch(state, {
|
|
198
201
|
childIdsById: nextChildIdsById,
|
|
199
202
|
parentIdById: nextParentIdById,
|
|
200
203
|
}));
|
|
201
204
|
} }))));
|
|
202
205
|
}
|
|
203
|
-
export
|
|
204
|
-
return {
|
|
205
|
-
id: state.prefabId,
|
|
206
|
-
name: state.prefabName,
|
|
207
|
-
root: denormalizeNode(state.rootId, state.nodesById, state.childIdsById),
|
|
208
|
-
};
|
|
209
|
-
}
|
|
210
|
-
function createDocumentState(prefab, revision = 0) {
|
|
211
|
-
const nodesById = {};
|
|
212
|
-
const childIdsById = {};
|
|
213
|
-
const parentIdById = {};
|
|
214
|
-
insertSubtree(prefab.root, null, nodesById, childIdsById, parentIdById);
|
|
215
|
-
const assetRefCounts = createAssetRefCounts(nodesById);
|
|
216
|
-
return {
|
|
217
|
-
prefabId: prefab.id,
|
|
218
|
-
prefabName: prefab.name,
|
|
219
|
-
rootId: prefab.root.id,
|
|
220
|
-
nodesById,
|
|
221
|
-
childIdsById,
|
|
222
|
-
parentIdById,
|
|
223
|
-
revision,
|
|
224
|
-
assetManifestKey: getAssetManifestKey(assetRefCounts),
|
|
225
|
-
assetRefCounts,
|
|
226
|
-
};
|
|
227
|
-
}
|
|
228
|
-
function createMutationPatch(state, patch, nextAssetRefCounts = state.assetRefCounts) {
|
|
229
|
-
const assetRefsChanged = nextAssetRefCounts !== state.assetRefCounts;
|
|
230
|
-
return Object.assign(Object.assign(Object.assign({}, patch), { revision: state.revision + 1 }), (assetRefsChanged ? {
|
|
231
|
-
assetRefCounts: nextAssetRefCounts,
|
|
232
|
-
assetManifestKey: getAssetManifestKey(nextAssetRefCounts),
|
|
233
|
-
} : null));
|
|
234
|
-
}
|
|
235
|
-
function denormalizeNode(id, nodesById, childIdsById) {
|
|
236
|
-
var _a;
|
|
237
|
-
const node = nodesById[id];
|
|
238
|
-
return Object.assign(Object.assign({}, node), { children: ((_a = childIdsById[id]) !== null && _a !== void 0 ? _a : []).map(childId => denormalizeNode(childId, nodesById, childIdsById)) });
|
|
239
|
-
}
|
|
240
|
-
function collectSubtreeIds(id, childIdsById) {
|
|
241
|
-
var _a;
|
|
242
|
-
const ids = [id];
|
|
243
|
-
for (const childId of (_a = childIdsById[id]) !== null && _a !== void 0 ? _a : []) {
|
|
244
|
-
ids.push(...collectSubtreeIds(childId, childIdsById));
|
|
245
|
-
}
|
|
246
|
-
return ids;
|
|
247
|
-
}
|
|
248
|
-
function insertSubtree(node, parentId, nodesById, childIdsById, parentIdById) {
|
|
249
|
-
var _a;
|
|
250
|
-
const { children } = node, nodeRecord = __rest(node, ["children"]);
|
|
251
|
-
nodesById[node.id] = nodeRecord;
|
|
252
|
-
childIdsById[node.id] = (_a = children === null || children === void 0 ? void 0 : children.map(child => child.id)) !== null && _a !== void 0 ? _a : [];
|
|
253
|
-
parentIdById[node.id] = parentId;
|
|
254
|
-
children === null || children === void 0 ? void 0 : children.forEach(child => insertSubtree(child, node.id, nodesById, childIdsById, parentIdById));
|
|
255
|
-
}
|
|
256
|
-
function cloneSubtreeIntoMaps(id, parentId, source, nodesById, childIdsById, parentIdById) {
|
|
257
|
-
var _a, _b;
|
|
258
|
-
const originalNode = source.nodesById[id];
|
|
259
|
-
if (!originalNode)
|
|
260
|
-
return null;
|
|
261
|
-
const clonedId = crypto.randomUUID();
|
|
262
|
-
const clonedNode = Object.assign(Object.assign({}, originalNode), { id: clonedId, name: `${(_a = originalNode.name) !== null && _a !== void 0 ? _a : originalNode.id} Copy` });
|
|
263
|
-
nodesById[clonedId] = clonedNode;
|
|
264
|
-
parentIdById[clonedId] = parentId;
|
|
265
|
-
const clonedChildIds = ((_b = source.childIdsById[id]) !== null && _b !== void 0 ? _b : [])
|
|
266
|
-
.map(childId => cloneSubtreeIntoMaps(childId, clonedId, source, nodesById, childIdsById, parentIdById))
|
|
267
|
-
.filter((childId) => Boolean(childId));
|
|
268
|
-
childIdsById[clonedId] = clonedChildIds;
|
|
269
|
-
return clonedId;
|
|
270
|
-
}
|
|
271
|
-
function isDescendant(id, potentialAncestorId, parentIdById) {
|
|
272
|
-
let currentId = id;
|
|
273
|
-
while (currentId) {
|
|
274
|
-
if (currentId === potentialAncestorId)
|
|
275
|
-
return true;
|
|
276
|
-
currentId = parentIdById[currentId];
|
|
277
|
-
}
|
|
278
|
-
return false;
|
|
279
|
-
}
|
|
280
|
-
function createAssetRefCounts(nodesById) {
|
|
281
|
-
const assetRefCounts = {};
|
|
282
|
-
Object.values(nodesById).forEach(node => addAssetRefs(assetRefCounts, getAssetRefs(node)));
|
|
283
|
-
return assetRefCounts;
|
|
284
|
-
}
|
|
285
|
-
function updateAssetRefsForNodeChange(assetRefCounts, currentNode, nextNode) {
|
|
286
|
-
const currentRefs = getAssetRefs(currentNode);
|
|
287
|
-
const nextRefs = getAssetRefs(nextNode);
|
|
288
|
-
if (sameStringArrays(currentRefs, nextRefs)) {
|
|
289
|
-
return assetRefCounts;
|
|
290
|
-
}
|
|
291
|
-
const nextAssetRefCounts = Object.assign({}, assetRefCounts);
|
|
292
|
-
removeAssetRefs(nextAssetRefCounts, currentRefs);
|
|
293
|
-
addAssetRefs(nextAssetRefCounts, nextRefs);
|
|
294
|
-
return nextAssetRefCounts;
|
|
295
|
-
}
|
|
296
|
-
function collectSubtreeAssetRefs(node) {
|
|
297
|
-
var _a;
|
|
298
|
-
const refs = getAssetRefs(node);
|
|
299
|
-
(_a = node.children) === null || _a === void 0 ? void 0 : _a.forEach(child => refs.push(...collectSubtreeAssetRefs(child)));
|
|
300
|
-
return refs;
|
|
301
|
-
}
|
|
302
|
-
function collectAssetRefsForIds(ids, nodesById) {
|
|
303
|
-
return ids.reduce((refs, id) => {
|
|
304
|
-
refs.push(...getAssetRefs(nodesById[id]));
|
|
305
|
-
return refs;
|
|
306
|
-
}, []);
|
|
307
|
-
}
|
|
308
|
-
function getAssetRefs(node) {
|
|
309
|
-
var _a;
|
|
310
|
-
const refs = [];
|
|
311
|
-
Object.values((_a = node === null || node === void 0 ? void 0 : node.components) !== null && _a !== void 0 ? _a : {}).forEach(component => {
|
|
312
|
-
var _a;
|
|
313
|
-
if (!(component === null || component === void 0 ? void 0 : component.type))
|
|
314
|
-
return;
|
|
315
|
-
for (const ref of getComponentAssetRefs(component.type, (_a = component.properties) !== null && _a !== void 0 ? _a : {})) {
|
|
316
|
-
refs.push(`${ref.type}:${ref.path}`);
|
|
317
|
-
}
|
|
318
|
-
});
|
|
319
|
-
return refs.sort();
|
|
320
|
-
}
|
|
321
|
-
function addAssetRefs(assetRefCounts, refs) {
|
|
322
|
-
refs.forEach(ref => {
|
|
323
|
-
var _a;
|
|
324
|
-
assetRefCounts[ref] = ((_a = assetRefCounts[ref]) !== null && _a !== void 0 ? _a : 0) + 1;
|
|
325
|
-
});
|
|
326
|
-
}
|
|
327
|
-
function removeAssetRefs(assetRefCounts, refs) {
|
|
328
|
-
refs.forEach(ref => {
|
|
329
|
-
var _a;
|
|
330
|
-
const nextCount = ((_a = assetRefCounts[ref]) !== null && _a !== void 0 ? _a : 0) - 1;
|
|
331
|
-
if (nextCount > 0) {
|
|
332
|
-
assetRefCounts[ref] = nextCount;
|
|
333
|
-
return;
|
|
334
|
-
}
|
|
335
|
-
delete assetRefCounts[ref];
|
|
336
|
-
});
|
|
337
|
-
}
|
|
338
|
-
function getAssetManifestKey(assetRefCounts) {
|
|
339
|
-
return Object.keys(assetRefCounts).sort().join("|");
|
|
340
|
-
}
|
|
341
|
-
function sameStringArrays(left, right) {
|
|
342
|
-
if (left.length !== right.length)
|
|
343
|
-
return false;
|
|
344
|
-
return left.every((value, index) => value === right[index]);
|
|
345
|
-
}
|
|
206
|
+
export const prefabStoreToPrefab = denormalizePrefab;
|
|
@@ -10,7 +10,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
10
10
|
return t;
|
|
11
11
|
};
|
|
12
12
|
import { findComponentEntry } from "./types";
|
|
13
|
-
import {
|
|
13
|
+
import { createComponentData, createNode as createPrefabNode } from "./prefab";
|
|
14
14
|
function missingNode(id) {
|
|
15
15
|
throw new Error(`Scene node not found: ${id}`);
|
|
16
16
|
}
|
|
@@ -136,11 +136,8 @@ export function createScene(adapter) {
|
|
|
136
136
|
return createComponent(id, componentKey, component.type);
|
|
137
137
|
},
|
|
138
138
|
addComponent(type, properties) {
|
|
139
|
-
var _a;
|
|
140
|
-
const def = getComponentDef(type);
|
|
141
139
|
const key = type.toLowerCase();
|
|
142
|
-
|
|
143
|
-
adapter.updateNode(id, node => (Object.assign(Object.assign({}, node), { components: Object.assign(Object.assign({}, node.components), { [key]: { type, properties: props } }) })));
|
|
140
|
+
adapter.updateNode(id, node => (Object.assign(Object.assign({}, node), { components: Object.assign(Object.assign({}, node.components), { [key]: createComponentData(type, properties) }) })));
|
|
144
141
|
return createComponent(id, key, type);
|
|
145
142
|
},
|
|
146
143
|
removeComponent(name) {
|
|
@@ -177,7 +174,6 @@ export function createScene(adapter) {
|
|
|
177
174
|
return adapter.getRootId();
|
|
178
175
|
},
|
|
179
176
|
find(nameOrId) {
|
|
180
|
-
// Try by ID first, then by name
|
|
181
177
|
if (adapter.getNode(nameOrId))
|
|
182
178
|
return createNode(nameOrId);
|
|
183
179
|
const foundId = adapter.findByName(nameOrId);
|
|
@@ -185,14 +181,7 @@ export function createScene(adapter) {
|
|
|
185
181
|
},
|
|
186
182
|
get: getNode,
|
|
187
183
|
create(name, components, options) {
|
|
188
|
-
const node =
|
|
189
|
-
id: crypto.randomUUID(),
|
|
190
|
-
name,
|
|
191
|
-
components: Object.assign({ transform: {
|
|
192
|
-
type: "Transform",
|
|
193
|
-
properties: { position: [0, 0, 0], rotation: [0, 0, 0], scale: [1, 1, 1] },
|
|
194
|
-
} }, components),
|
|
195
|
-
};
|
|
184
|
+
const node = createPrefabNode(name, components);
|
|
196
185
|
return createNode(adapter.addNode(node, options));
|
|
197
186
|
},
|
|
198
187
|
update,
|
|
@@ -34,7 +34,3 @@ export declare function computeParentWorldMatrix(state: {
|
|
|
34
34
|
}, targetId: string): Matrix4;
|
|
35
35
|
/** Recursively update all IDs in a node tree */
|
|
36
36
|
export declare function regenerateIds(node: GameObject): GameObject;
|
|
37
|
-
/** Create a GameObject node for a 3D model file */
|
|
38
|
-
export declare function createModelNode(filename: string, name?: string): GameObject;
|
|
39
|
-
/** Create a GameObject node for an image as a textured plane */
|
|
40
|
-
export declare function createImageNode(texturePath: string, name?: string): GameObject;
|
|
@@ -155,40 +155,3 @@ export function regenerateIds(node) {
|
|
|
155
155
|
var _a;
|
|
156
156
|
return Object.assign(Object.assign({}, node), { id: crypto.randomUUID(), children: (_a = node.children) === null || _a === void 0 ? void 0 : _a.map(regenerateIds) });
|
|
157
157
|
}
|
|
158
|
-
function createNode(path, name, extraComponents) {
|
|
159
|
-
return {
|
|
160
|
-
id: crypto.randomUUID(),
|
|
161
|
-
name: name !== null && name !== void 0 ? name : path.replace(/^.*[\/]/, '').replace(/\.[^.]+$/, ''),
|
|
162
|
-
components: Object.assign({ transform: {
|
|
163
|
-
type: 'Transform',
|
|
164
|
-
properties: { position: [0, 0, 0], rotation: [0, 0, 0], scale: [1, 1, 1] }
|
|
165
|
-
} }, extraComponents)
|
|
166
|
-
};
|
|
167
|
-
}
|
|
168
|
-
/** Create a GameObject node for a 3D model file */
|
|
169
|
-
export function createModelNode(filename, name) {
|
|
170
|
-
return createNode(filename, name, {
|
|
171
|
-
model: {
|
|
172
|
-
type: 'Model',
|
|
173
|
-
properties: {
|
|
174
|
-
filename,
|
|
175
|
-
instanced: false,
|
|
176
|
-
repeat: false,
|
|
177
|
-
repeatAxes: [{ axis: 'x', count: 1, offset: 1 }]
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
});
|
|
181
|
-
}
|
|
182
|
-
/** Create a GameObject node for an image as a textured plane */
|
|
183
|
-
export function createImageNode(texturePath, name) {
|
|
184
|
-
return createNode(texturePath, name, {
|
|
185
|
-
geometry: {
|
|
186
|
-
type: 'Geometry',
|
|
187
|
-
properties: { geometryType: 'plane', args: [1, 1] }
|
|
188
|
-
},
|
|
189
|
-
material: {
|
|
190
|
-
type: 'Material',
|
|
191
|
-
properties: { color: '#ffffff', texture: texturePath }
|
|
192
|
-
}
|
|
193
|
-
});
|
|
194
|
-
}
|
package/package.json
CHANGED
|
File without changes
|