react-three-game 0.0.39 → 0.0.41

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.
Files changed (83) hide show
  1. package/.claude/settings.local.json +9 -0
  2. package/README.md +17 -0
  3. package/dist/index.umd.js +438 -0
  4. package/package.json +6 -3
  5. package/src/shared/GameCanvas.tsx +0 -2
  6. package/src/tools/assetviewer/page.tsx +31 -26
  7. package/src/tools/dragdrop/DragDropLoader.tsx +0 -1
  8. package/src/tools/prefabeditor/PrefabEditor.tsx +0 -2
  9. package/src/tools/prefabeditor/PrefabRoot.tsx +0 -2
  10. package/src/tools/prefabeditor/components/MaterialComponent.tsx +25 -9
  11. package/src/tools/prefabeditor/components/ModelComponent.tsx +25 -10
  12. package/src/tools/prefabeditor/styles.ts +0 -1
  13. package/vite.config.ts +34 -0
  14. package/dist/helpers/SoundManager.d.ts +0 -35
  15. package/dist/helpers/SoundManager.js +0 -93
  16. package/dist/helpers/index.d.ts +0 -35
  17. package/dist/helpers/index.js +0 -44
  18. package/dist/index.d.ts +0 -14
  19. package/dist/index.js +0 -14
  20. package/dist/shared/GameCanvas.d.ts +0 -9
  21. package/dist/shared/GameCanvas.js +0 -48
  22. package/dist/shared/extend-three.d.ts +0 -1
  23. package/dist/shared/extend-three.js +0 -13
  24. package/dist/tools/assetviewer/page.d.ts +0 -23
  25. package/dist/tools/assetviewer/page.js +0 -159
  26. package/dist/tools/dragdrop/DragDropLoader.d.ts +0 -9
  27. package/dist/tools/dragdrop/DragDropLoader.js +0 -79
  28. package/dist/tools/dragdrop/modelLoader.d.ts +0 -7
  29. package/dist/tools/dragdrop/modelLoader.js +0 -52
  30. package/dist/tools/dragdrop/page.d.ts +0 -1
  31. package/dist/tools/dragdrop/page.js +0 -11
  32. package/dist/tools/loading/GameWithLoader.d.ts +0 -6
  33. package/dist/tools/loading/GameWithLoader.js +0 -8
  34. package/dist/tools/loading/loading.d.ts +0 -2
  35. package/dist/tools/loading/loading.js +0 -38
  36. package/dist/tools/prefabeditor/EditorContext.d.ts +0 -11
  37. package/dist/tools/prefabeditor/EditorContext.js +0 -9
  38. package/dist/tools/prefabeditor/EditorTree.d.ts +0 -12
  39. package/dist/tools/prefabeditor/EditorTree.js +0 -150
  40. package/dist/tools/prefabeditor/EditorUI.d.ts +0 -14
  41. package/dist/tools/prefabeditor/EditorUI.js +0 -71
  42. package/dist/tools/prefabeditor/EventSystem.d.ts +0 -7
  43. package/dist/tools/prefabeditor/EventSystem.js +0 -23
  44. package/dist/tools/prefabeditor/ExportHelper.d.ts +0 -7
  45. package/dist/tools/prefabeditor/ExportHelper.js +0 -55
  46. package/dist/tools/prefabeditor/InstanceProvider.d.ts +0 -30
  47. package/dist/tools/prefabeditor/InstanceProvider.js +0 -254
  48. package/dist/tools/prefabeditor/PrefabEditor.d.ts +0 -16
  49. package/dist/tools/prefabeditor/PrefabEditor.js +0 -141
  50. package/dist/tools/prefabeditor/PrefabRoot.d.ts +0 -28
  51. package/dist/tools/prefabeditor/PrefabRoot.js +0 -294
  52. package/dist/tools/prefabeditor/components/ComponentRegistry.d.ts +0 -18
  53. package/dist/tools/prefabeditor/components/ComponentRegistry.js +0 -13
  54. package/dist/tools/prefabeditor/components/DirectionalLightComponent.d.ts +0 -3
  55. package/dist/tools/prefabeditor/components/DirectionalLightComponent.js +0 -78
  56. package/dist/tools/prefabeditor/components/GeometryComponent.d.ts +0 -3
  57. package/dist/tools/prefabeditor/components/GeometryComponent.js +0 -66
  58. package/dist/tools/prefabeditor/components/Input.d.ts +0 -20
  59. package/dist/tools/prefabeditor/components/Input.js +0 -129
  60. package/dist/tools/prefabeditor/components/MaterialComponent.d.ts +0 -3
  61. package/dist/tools/prefabeditor/components/MaterialComponent.js +0 -96
  62. package/dist/tools/prefabeditor/components/ModelComponent.d.ts +0 -3
  63. package/dist/tools/prefabeditor/components/ModelComponent.js +0 -53
  64. package/dist/tools/prefabeditor/components/PhysicsComponent.d.ts +0 -10
  65. package/dist/tools/prefabeditor/components/PhysicsComponent.js +0 -33
  66. package/dist/tools/prefabeditor/components/RotatorComponent.d.ts +0 -3
  67. package/dist/tools/prefabeditor/components/RotatorComponent.js +0 -42
  68. package/dist/tools/prefabeditor/components/SpotLightComponent.d.ts +0 -3
  69. package/dist/tools/prefabeditor/components/SpotLightComponent.js +0 -49
  70. package/dist/tools/prefabeditor/components/TransformComponent.d.ts +0 -3
  71. package/dist/tools/prefabeditor/components/TransformComponent.js +0 -42
  72. package/dist/tools/prefabeditor/components/index.d.ts +0 -2
  73. package/dist/tools/prefabeditor/components/index.js +0 -16
  74. package/dist/tools/prefabeditor/hooks/useModelLoader.d.ts +0 -10
  75. package/dist/tools/prefabeditor/hooks/useModelLoader.js +0 -40
  76. package/dist/tools/prefabeditor/page.d.ts +0 -1
  77. package/dist/tools/prefabeditor/page.js +0 -5
  78. package/dist/tools/prefabeditor/styles.d.ts +0 -1809
  79. package/dist/tools/prefabeditor/styles.js +0 -168
  80. package/dist/tools/prefabeditor/types.d.ts +0 -19
  81. package/dist/tools/prefabeditor/types.js +0 -1
  82. package/dist/tools/prefabeditor/utils.d.ts +0 -26
  83. package/dist/tools/prefabeditor/utils.js +0 -131
@@ -1,168 +0,0 @@
1
- // Shared editor styles - single source of truth for all prefab editor UI
2
- export const colors = {
3
- bg: 'rgba(0,0,0,0.6)',
4
- bgLight: 'rgba(255,255,255,0.06)',
5
- bgHover: 'rgba(255,255,255,0.1)',
6
- border: 'rgba(255,255,255,0.15)',
7
- borderLight: 'rgba(255,255,255,0.1)',
8
- borderFaint: 'rgba(255,255,255,0.05)',
9
- text: '#fff',
10
- textMuted: 'rgba(255,255,255,0.7)',
11
- danger: '#ffaaaa',
12
- dangerBg: 'rgba(255,80,80,0.2)',
13
- dangerBorder: 'rgba(255,80,80,0.4)',
14
- };
15
- export const fonts = {
16
- family: 'system-ui, sans-serif',
17
- size: 11,
18
- sizeSm: 10,
19
- };
20
- // Base component styles
21
- export const base = {
22
- panel: {
23
- background: colors.bg,
24
- color: colors.text,
25
- border: `1px solid ${colors.border}`,
26
- borderRadius: 4,
27
- overflow: 'hidden',
28
- backdropFilter: 'blur(8px)',
29
- fontFamily: fonts.family,
30
- fontSize: fonts.size,
31
- },
32
- header: {
33
- padding: '6px 8px',
34
- display: 'flex',
35
- alignItems: 'center',
36
- justifyContent: 'space-between',
37
- cursor: 'pointer',
38
- background: colors.bgLight,
39
- borderBottom: `1px solid ${colors.borderLight}`,
40
- fontSize: fonts.size,
41
- fontWeight: 500,
42
- textTransform: 'uppercase',
43
- letterSpacing: 0.5,
44
- },
45
- input: {
46
- width: '100%',
47
- background: colors.bgHover,
48
- border: `1px solid ${colors.border}`,
49
- borderRadius: 3,
50
- padding: '4px 6px',
51
- color: colors.text,
52
- fontSize: fonts.size,
53
- outline: 'none',
54
- },
55
- btn: {
56
- background: colors.bgHover,
57
- border: `1px solid ${colors.border}`,
58
- borderRadius: 3,
59
- padding: '4px 8px',
60
- color: colors.text,
61
- fontSize: fonts.size,
62
- cursor: 'pointer',
63
- outline: 'none',
64
- },
65
- btnDanger: {
66
- background: colors.dangerBg,
67
- borderColor: colors.dangerBorder,
68
- color: colors.danger,
69
- },
70
- label: {
71
- fontSize: fonts.sizeSm,
72
- opacity: 0.7,
73
- marginBottom: 4,
74
- textTransform: 'uppercase',
75
- letterSpacing: 0.5,
76
- },
77
- row: {
78
- display: 'flex',
79
- gap: 6,
80
- },
81
- section: {
82
- paddingBottom: 8,
83
- borderBottom: `1px solid ${colors.borderLight}`,
84
- },
85
- };
86
- // Specific panel styles
87
- export const inspector = {
88
- panel: Object.assign(Object.assign({}, base.panel), { position: 'absolute', top: 8, right: 8, zIndex: 20, width: 260 }),
89
- content: {
90
- padding: 8,
91
- maxHeight: '80vh',
92
- overflowY: 'auto',
93
- display: 'flex',
94
- flexDirection: 'column',
95
- gap: 8,
96
- },
97
- };
98
- export const tree = {
99
- panel: Object.assign(Object.assign({}, base.panel), { maxHeight: '85vh', display: 'flex', flexDirection: 'column', userSelect: 'none' }),
100
- scroll: {
101
- overflowY: 'auto',
102
- padding: 4,
103
- },
104
- row: {
105
- display: 'flex',
106
- alignItems: 'center',
107
- padding: '3px 6px',
108
- borderBottom: `1px solid ${colors.borderFaint}`,
109
- cursor: 'pointer',
110
- whiteSpace: 'nowrap',
111
- },
112
- selected: {
113
- background: 'rgba(255,255,255,0.12)',
114
- },
115
- };
116
- export const menu = {
117
- container: {
118
- position: 'fixed',
119
- zIndex: 50,
120
- minWidth: 120,
121
- background: 'rgba(0,0,0,0.85)',
122
- border: `1px solid ${colors.border}`,
123
- borderRadius: 4,
124
- overflow: 'hidden',
125
- boxShadow: '0 8px 24px rgba(0,0,0,0.5)',
126
- backdropFilter: 'blur(8px)',
127
- },
128
- item: {
129
- width: '100%',
130
- textAlign: 'left',
131
- padding: '6px 8px',
132
- background: 'transparent',
133
- border: 'none',
134
- color: colors.text,
135
- fontSize: fonts.size,
136
- cursor: 'pointer',
137
- outline: 'none',
138
- },
139
- danger: {
140
- color: colors.danger,
141
- },
142
- };
143
- export const toolbar = {
144
- panel: {
145
- position: 'absolute',
146
- top: 8,
147
- left: '50%',
148
- transform: 'translateX(-50%)',
149
- display: 'flex',
150
- gap: 6,
151
- padding: '4px 6px',
152
- background: colors.bg,
153
- border: `1px solid ${colors.border}`,
154
- borderRadius: 4,
155
- color: colors.text,
156
- fontFamily: fonts.family,
157
- fontSize: fonts.size,
158
- backdropFilter: 'blur(8px)',
159
- },
160
- divider: {
161
- width: 1,
162
- background: 'rgba(255,255,255,0.2)',
163
- },
164
- disabled: {
165
- opacity: 0.4,
166
- cursor: 'not-allowed',
167
- },
168
- };
@@ -1,19 +0,0 @@
1
- export interface Prefab {
2
- id?: string;
3
- name?: string;
4
- root: GameObject;
5
- }
6
- export interface GameObject {
7
- id: string;
8
- name?: string;
9
- disabled?: boolean;
10
- hidden?: boolean;
11
- children?: GameObject[];
12
- components?: {
13
- [key: string]: ComponentData | undefined;
14
- };
15
- }
16
- export interface ComponentData {
17
- type: string;
18
- properties: Record<string, any>;
19
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,26 +0,0 @@
1
- import { GameObject, Prefab } from "./types";
2
- /** Save a prefab as JSON file */
3
- export declare function saveJson(data: Prefab, filename: string): void;
4
- /** Load a prefab from JSON file */
5
- export declare function loadJson(): Promise<Prefab | undefined>;
6
- /** Find a node by ID in the tree */
7
- export declare function findNode(root: GameObject, id: string): GameObject | null;
8
- /** Find the parent of a node by ID */
9
- export declare function findParent(root: GameObject, id: string): GameObject | null;
10
- /** Find all nodes matching a predicate */
11
- export declare function findAll(root: GameObject, predicate: (node: GameObject) => boolean): GameObject[];
12
- /** Find all nodes that have a specific component type */
13
- export declare function findByComponent(root: GameObject, componentType: string): GameObject[];
14
- /** Get a flattened list of all nodes */
15
- export declare function flatten(root: GameObject): GameObject[];
16
- /** Immutably update a node by ID */
17
- export declare function updateNode(root: GameObject, id: string, update: (node: GameObject) => GameObject): GameObject;
18
- /** Immutably delete a node by ID */
19
- export declare function deleteNode(root: GameObject, id: string): GameObject | null;
20
- /** Deep clone a node with new IDs */
21
- export declare function cloneNode(node: GameObject): GameObject;
22
- /** Recursively update all IDs in a node tree */
23
- export declare function regenerateIds(node: GameObject): GameObject;
24
- /** Get component data from a node */
25
- export declare function getComponent<T = any>(node: GameObject, type: string): T | undefined;
26
- export declare function updateNodeById(root: GameObject, id: string, updater: (node: GameObject) => GameObject): GameObject;
@@ -1,131 +0,0 @@
1
- /** Save a prefab as JSON file */
2
- export function saveJson(data, filename) {
3
- const a = document.createElement('a');
4
- a.href = "data:text/json;charset=utf-8," + encodeURIComponent(JSON.stringify(data, null, 2));
5
- a.download = `${filename || 'prefab'}.json`;
6
- a.click();
7
- }
8
- /** Load a prefab from JSON file */
9
- export function loadJson() {
10
- return new Promise(resolve => {
11
- const input = document.createElement('input');
12
- input.type = 'file';
13
- input.accept = '.json,application/json';
14
- input.onchange = e => {
15
- var _a;
16
- const file = (_a = e.target.files) === null || _a === void 0 ? void 0 : _a[0];
17
- if (!file)
18
- return resolve(undefined);
19
- const reader = new FileReader();
20
- reader.onload = e => {
21
- var _a;
22
- try {
23
- const text = (_a = e.target) === null || _a === void 0 ? void 0 : _a.result;
24
- if (typeof text === 'string')
25
- resolve(JSON.parse(text));
26
- }
27
- catch (err) {
28
- console.error('Error parsing prefab JSON:', err);
29
- resolve(undefined);
30
- }
31
- };
32
- reader.readAsText(file);
33
- };
34
- input.click();
35
- });
36
- }
37
- /** Find a node by ID in the tree */
38
- export function findNode(root, id) {
39
- var _a;
40
- if (root.id === id)
41
- return root;
42
- for (const child of (_a = root.children) !== null && _a !== void 0 ? _a : []) {
43
- const found = findNode(child, id);
44
- if (found)
45
- return found;
46
- }
47
- return null;
48
- }
49
- /** Find the parent of a node by ID */
50
- export function findParent(root, id) {
51
- var _a;
52
- for (const child of (_a = root.children) !== null && _a !== void 0 ? _a : []) {
53
- if (child.id === id)
54
- return root;
55
- const found = findParent(child, id);
56
- if (found)
57
- return found;
58
- }
59
- return null;
60
- }
61
- /** Find all nodes matching a predicate */
62
- export function findAll(root, predicate) {
63
- var _a;
64
- const results = [];
65
- if (predicate(root))
66
- results.push(root);
67
- for (const child of (_a = root.children) !== null && _a !== void 0 ? _a : []) {
68
- results.push(...findAll(child, predicate));
69
- }
70
- return results;
71
- }
72
- /** Find all nodes that have a specific component type */
73
- export function findByComponent(root, componentType) {
74
- return findAll(root, node => { var _a; return Object.values((_a = node.components) !== null && _a !== void 0 ? _a : {}).some(c => (c === null || c === void 0 ? void 0 : c.type) === componentType); });
75
- }
76
- /** Get a flattened list of all nodes */
77
- export function flatten(root) {
78
- return findAll(root, () => true);
79
- }
80
- /** Immutably update a node by ID */
81
- export function updateNode(root, id, update) {
82
- if (root.id === id)
83
- return update(root);
84
- if (!root.children)
85
- return root;
86
- return Object.assign(Object.assign({}, root), { children: root.children.map(child => updateNode(child, id, update)) });
87
- }
88
- /** Immutably delete a node by ID */
89
- export function deleteNode(root, id) {
90
- if (root.id === id)
91
- return null;
92
- if (!root.children)
93
- return root;
94
- return Object.assign(Object.assign({}, root), { children: root.children
95
- .map(child => deleteNode(child, id))
96
- .filter((child) => child !== null) });
97
- }
98
- /** Deep clone a node with new IDs */
99
- export function cloneNode(node) {
100
- var _a, _b;
101
- return Object.assign(Object.assign({}, node), { id: crypto.randomUUID(), name: `${(_a = node.name) !== null && _a !== void 0 ? _a : "Node"} Copy`, children: (_b = node.children) === null || _b === void 0 ? void 0 : _b.map(cloneNode) });
102
- }
103
- /** Recursively update all IDs in a node tree */
104
- export function regenerateIds(node) {
105
- var _a;
106
- return Object.assign(Object.assign({}, node), { id: crypto.randomUUID(), children: (_a = node.children) === null || _a === void 0 ? void 0 : _a.map(regenerateIds) });
107
- }
108
- /** Get component data from a node */
109
- export function getComponent(node, type) {
110
- var _a;
111
- const comp = Object.values((_a = node.components) !== null && _a !== void 0 ? _a : {}).find(c => (c === null || c === void 0 ? void 0 : c.type) === type);
112
- return comp === null || comp === void 0 ? void 0 : comp.properties;
113
- }
114
- export function updateNodeById(root, id, updater) {
115
- if (root.id === id) {
116
- return updater(root);
117
- }
118
- if (!root.children) {
119
- return root;
120
- }
121
- let didChange = false;
122
- const newChildren = root.children.map(child => {
123
- const updated = updateNodeById(child, id, updater);
124
- if (updated !== child)
125
- didChange = true;
126
- return updated;
127
- });
128
- if (!didChange)
129
- return root;
130
- return Object.assign(Object.assign({}, root), { children: newChildren });
131
- }