react-three-game 0.0.14 → 0.0.16

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.
@@ -15,8 +15,6 @@ const PrefabEditor = ({ basePath, initialPrefab, onPrefabChange, children }: { b
15
15
  "name": "New Prefab",
16
16
  "root": {
17
17
  "id": "root",
18
- "enabled": true,
19
- "visible": true,
20
18
  "components": {
21
19
  "transform": {
22
20
  "type": "Transform",
@@ -69,26 +67,88 @@ const PrefabEditor = ({ basePath, initialPrefab, onPrefabChange, children }: { b
69
67
  </Physics>
70
68
  </GameCanvas>
71
69
 
72
- <div style={{ position: "absolute", top: "0.5rem", left: "50%", transform: "translateX(-50%)" }} className="bg-black/70 backdrop-blur-sm border border-cyan-500/30 px-2 py-1 flex items-center gap-1">
70
+ <div
71
+ style={{
72
+ position: "absolute",
73
+ top: 8,
74
+ left: "50%",
75
+ transform: "translateX(-50%)",
76
+ display: "flex",
77
+ alignItems: "center",
78
+ gap: 6,
79
+ padding: "2px 4px",
80
+ background: "rgba(0,0,0,0.55)",
81
+ border: "1px solid rgba(255,255,255,0.12)",
82
+ borderRadius: 4,
83
+ color: "rgba(255,255,255,0.9)",
84
+ fontFamily: "ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace",
85
+ fontSize: 11,
86
+ lineHeight: 1,
87
+ WebkitUserSelect: "none",
88
+ userSelect: "none",
89
+ }}
90
+ >
73
91
  <button
74
- className="px-1 py-0.5 text-[10px] font-mono text-cyan-300 hover:bg-cyan-500/20 border border-cyan-500/30"
92
+ style={{
93
+ padding: "2px 6px",
94
+ font: "inherit",
95
+ background: "transparent",
96
+ color: "inherit",
97
+ border: "1px solid rgba(255,255,255,0.18)",
98
+ borderRadius: 3,
99
+ cursor: "pointer",
100
+ }}
75
101
  onClick={() => setEditMode(!editMode)}
102
+ onPointerEnter={(e) => {
103
+ (e.currentTarget as HTMLButtonElement).style.background = "rgba(255,255,255,0.08)";
104
+ }}
105
+ onPointerLeave={(e) => {
106
+ (e.currentTarget as HTMLButtonElement).style.background = "transparent";
107
+ }}
76
108
  >
77
109
  {editMode ? "▶" : "⏸"}
78
110
  </button>
79
- <span className="text-cyan-500/30 text-[10px]">|</span>
111
+ <span style={{ opacity: 0.35 }}>|</span>
80
112
  <button
81
- className="px-1 py-0.5 text-[10px] font-mono text-cyan-300 hover:bg-cyan-500/20 border border-cyan-500/30"
113
+ style={{
114
+ padding: "2px 6px",
115
+ font: "inherit",
116
+ background: "transparent",
117
+ color: "inherit",
118
+ border: "1px solid rgba(255,255,255,0.18)",
119
+ borderRadius: 3,
120
+ cursor: "pointer",
121
+ }}
82
122
  onClick={async () => {
83
123
  const prefab = await loadJson();
84
124
  if (prefab) setLoadedPrefab(prefab);
85
125
  }}
126
+ onPointerEnter={(e) => {
127
+ (e.currentTarget as HTMLButtonElement).style.background = "rgba(255,255,255,0.08)";
128
+ }}
129
+ onPointerLeave={(e) => {
130
+ (e.currentTarget as HTMLButtonElement).style.background = "transparent";
131
+ }}
86
132
  >
87
133
  📥
88
134
  </button>
89
135
  <button
90
- className="px-1 py-0.5 text-[10px] font-mono text-cyan-300 hover:bg-cyan-500/20 border border-cyan-500/30"
136
+ style={{
137
+ padding: "2px 6px",
138
+ font: "inherit",
139
+ background: "transparent",
140
+ color: "inherit",
141
+ border: "1px solid rgba(255,255,255,0.18)",
142
+ borderRadius: 3,
143
+ cursor: "pointer",
144
+ }}
91
145
  onClick={() => saveJson(loadedPrefab, "prefab")}
146
+ onPointerEnter={(e) => {
147
+ (e.currentTarget as HTMLButtonElement).style.background = "rgba(255,255,255,0.08)";
148
+ }}
149
+ onPointerLeave={(e) => {
150
+ (e.currentTarget as HTMLButtonElement).style.background = "transparent";
151
+ }}
92
152
  >
93
153
  💾
94
154
  </button>
@@ -59,15 +59,6 @@ export const PrefabRoot = forwardRef<Group, {
59
59
  }
60
60
  }, [selectedId]);
61
61
 
62
-
63
- // const [transformMode, setTransformMode] = useState<"translate" | "rotate" | "scale">("translate"); // Removed local state
64
-
65
- const updateNode = (updater: (node: GameObjectType) => GameObjectType) => {
66
- if (!selectedId || !onPrefabChange) return;
67
- const newRoot = updatePrefabNode(data.root, selectedId, updater);
68
- onPrefabChange({ ...data, root: newRoot });
69
- };
70
-
71
62
  const onTransformChange = () => {
72
63
  if (!selectedId || !onPrefabChange) return;
73
64
  const obj = objectRefs.current[selectedId];
@@ -167,7 +158,7 @@ export const PrefabRoot = forwardRef<Group, {
167
158
  loadedModels={loadedModels}
168
159
  loadedTextures={loadedTextures}
169
160
  editMode={editMode}
170
- parentMatrix={new Matrix4()} // 👈 identity = world root
161
+ parentMatrix={new Matrix4()}
171
162
  />
172
163
  </GameInstanceProvider>
173
164
 
@@ -242,7 +233,7 @@ function GameObjectRenderer({
242
233
  clickValid.current = false;
243
234
  };
244
235
 
245
- if (!gameObject.enabled || !gameObject.visible) return null;
236
+ if (gameObject.disabled === true || gameObject.hidden === true) return null;
246
237
 
247
238
  // --- 2. If instanced, short-circuit to a tiny clean branch ---
248
239
  const isInstanced = !!gameObject.components?.model?.properties?.instanced;
@@ -269,8 +260,6 @@ function GameObjectRenderer({
269
260
  ));
270
261
 
271
262
  // --- 4. Wrap with physics if needed ---
272
- // Only wrap the core content (geometry/model), not children
273
- // Children should be siblings, not inside the physics body
274
263
  const physicsWrapped = wrapPhysicsIfNeeded(gameObject, core, ctx);
275
264
 
276
265
  // --- 6. Final group wrapper ---
@@ -1,8 +1,8 @@
1
- import { ThreeElements } from "@react-three/fiber"
1
+ // import { ThreeElements } from "@react-three/fiber"
2
2
 
3
3
  export interface Prefab {
4
- id: string;
5
- name: string;
4
+ id?: string;
5
+ name?: string;
6
6
  description?: string;
7
7
  author?: string;
8
8
  version?: string;
@@ -13,8 +13,8 @@ export interface Prefab {
13
13
 
14
14
  export interface GameObject {
15
15
  id: string;
16
- enabled: boolean;
17
- visible: boolean;
16
+ disabled?: boolean;
17
+ hidden?: boolean;
18
18
  ref?: any;
19
19
  children?: GameObject[];
20
20
  components?: {