react-three-game 0.0.41 → 0.0.42

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 (63) hide show
  1. package/README.md +0 -17
  2. package/dist/helpers/SoundManager.d.ts +35 -0
  3. package/dist/helpers/SoundManager.js +93 -0
  4. package/dist/helpers/index.d.ts +35 -0
  5. package/dist/helpers/index.js +44 -0
  6. package/dist/index.d.ts +14 -0
  7. package/dist/index.js +14 -0
  8. package/dist/index.umd.js +4347 -163
  9. package/dist/shared/GameCanvas.d.ts +9 -0
  10. package/dist/shared/GameCanvas.js +47 -0
  11. package/dist/tools/assetviewer/page.d.ts +35 -0
  12. package/dist/tools/assetviewer/page.js +166 -0
  13. package/dist/tools/dragdrop/DragDropLoader.d.ts +9 -0
  14. package/dist/tools/dragdrop/DragDropLoader.js +78 -0
  15. package/dist/tools/dragdrop/modelLoader.d.ts +7 -0
  16. package/dist/tools/dragdrop/modelLoader.js +52 -0
  17. package/dist/tools/dragdrop/page.d.ts +1 -0
  18. package/dist/tools/dragdrop/page.js +11 -0
  19. package/dist/tools/prefabeditor/EditorContext.d.ts +11 -0
  20. package/dist/tools/prefabeditor/EditorContext.js +9 -0
  21. package/dist/tools/prefabeditor/EditorTree.d.ts +12 -0
  22. package/dist/tools/prefabeditor/EditorTree.js +150 -0
  23. package/dist/tools/prefabeditor/EditorUI.d.ts +14 -0
  24. package/dist/tools/prefabeditor/EditorUI.js +71 -0
  25. package/dist/tools/prefabeditor/EventSystem.d.ts +7 -0
  26. package/dist/tools/prefabeditor/EventSystem.js +23 -0
  27. package/dist/tools/prefabeditor/InstanceProvider.d.ts +30 -0
  28. package/dist/tools/prefabeditor/InstanceProvider.js +254 -0
  29. package/dist/tools/prefabeditor/PrefabEditor.d.ts +16 -0
  30. package/dist/tools/prefabeditor/PrefabEditor.js +140 -0
  31. package/dist/tools/prefabeditor/PrefabRoot.d.ts +28 -0
  32. package/dist/tools/prefabeditor/PrefabRoot.js +293 -0
  33. package/dist/tools/prefabeditor/components/ComponentRegistry.d.ts +18 -0
  34. package/dist/tools/prefabeditor/components/ComponentRegistry.js +13 -0
  35. package/dist/tools/prefabeditor/components/DirectionalLightComponent.d.ts +3 -0
  36. package/dist/tools/prefabeditor/components/DirectionalLightComponent.js +78 -0
  37. package/dist/tools/prefabeditor/components/GeometryComponent.d.ts +3 -0
  38. package/dist/tools/prefabeditor/components/GeometryComponent.js +66 -0
  39. package/dist/tools/prefabeditor/components/Input.d.ts +20 -0
  40. package/dist/tools/prefabeditor/components/Input.js +129 -0
  41. package/dist/tools/prefabeditor/components/MaterialComponent.d.ts +3 -0
  42. package/dist/tools/prefabeditor/components/MaterialComponent.js +100 -0
  43. package/dist/tools/prefabeditor/components/ModelComponent.d.ts +3 -0
  44. package/dist/tools/prefabeditor/components/ModelComponent.js +57 -0
  45. package/dist/tools/prefabeditor/components/PhysicsComponent.d.ts +10 -0
  46. package/dist/tools/prefabeditor/components/PhysicsComponent.js +33 -0
  47. package/dist/tools/prefabeditor/components/SpotLightComponent.d.ts +3 -0
  48. package/dist/tools/prefabeditor/components/SpotLightComponent.js +49 -0
  49. package/dist/tools/prefabeditor/components/TransformComponent.d.ts +3 -0
  50. package/dist/tools/prefabeditor/components/TransformComponent.js +42 -0
  51. package/dist/tools/prefabeditor/components/index.d.ts +2 -0
  52. package/dist/tools/prefabeditor/components/index.js +16 -0
  53. package/dist/tools/prefabeditor/page.d.ts +1 -0
  54. package/dist/tools/prefabeditor/page.js +5 -0
  55. package/dist/tools/prefabeditor/styles.d.ts +1809 -0
  56. package/dist/tools/prefabeditor/styles.js +167 -0
  57. package/dist/tools/prefabeditor/types.d.ts +19 -0
  58. package/dist/tools/prefabeditor/types.js +1 -0
  59. package/dist/tools/prefabeditor/utils.d.ts +26 -0
  60. package/dist/tools/prefabeditor/utils.js +131 -0
  61. package/package.json +2 -4
  62. package/.claude/settings.local.json +0 -9
  63. package/vite.config.ts +0 -34
package/README.md CHANGED
@@ -6,23 +6,6 @@ JSON-first 3D game engine. React Three Fiber + WebGPU + Rapier Physics.
6
6
  npm i react-three-game @react-three/fiber @react-three/rapier three
7
7
  ```
8
8
 
9
- ### CDN / UMD Build
10
-
11
- For use with script tags (no build tools):
12
-
13
- ```html
14
- <script src="https://unpkg.com/react@18/umd/react.production.min.js"></script>
15
- <script src="https://unpkg.com/react-dom@18/umd/react-dom.production.min.js"></script>
16
- <script src="https://unpkg.com/react-three-game@0.0.41/dist/index.umd.js"></script>
17
-
18
- <script>
19
- const { ModelListViewer, SharedCanvas, TextureListViewer } = window.ReactThreeGame;
20
- // Use components...
21
- </script>
22
- ```
23
-
24
- See [docs/public/test-umd.html](docs/public/test-umd.html) for a complete example.
25
-
26
9
  ![Prefab Editor](assets/editor.gif)
27
10
  ![Architecture](assets/architecture.png)
28
11
 
@@ -0,0 +1,35 @@
1
+ declare class SoundManager {
2
+ private static _instance;
3
+ context: AudioContext;
4
+ private buffers;
5
+ private masterGain;
6
+ private sfxGain;
7
+ private musicGain;
8
+ private constructor();
9
+ /** Singleton accessor */
10
+ static get instance(): SoundManager;
11
+ /** Required once after user gesture (browser) */
12
+ resume(): void;
13
+ /** Preload a sound from URL */
14
+ load(path: string, url: string): Promise<void>;
15
+ /** Play from already-loaded buffer (fails silently if not loaded) */
16
+ playSync(path: string, { volume, playbackRate, detune, pitch, }?: {
17
+ volume?: number;
18
+ playbackRate?: number;
19
+ detune?: number;
20
+ pitch?: number;
21
+ }): void;
22
+ /** Load and play SFX - accepts file path directly */
23
+ play(path: string, options?: {
24
+ volume?: number;
25
+ playbackRate?: number;
26
+ detune?: number;
27
+ pitch?: number;
28
+ }): Promise<void>;
29
+ /** Volume controls */
30
+ setMasterVolume(v: number): void;
31
+ setSfxVolume(v: number): void;
32
+ setMusicVolume(v: number): void;
33
+ }
34
+ export declare const sound: SoundManager;
35
+ export {};
@@ -0,0 +1,93 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ class SoundManager {
11
+ constructor() {
12
+ this.buffers = new Map();
13
+ const AudioCtx = window.AudioContext || window.webkitAudioContext;
14
+ this.context = new AudioCtx();
15
+ this.masterGain = this.context.createGain();
16
+ this.sfxGain = this.context.createGain();
17
+ this.musicGain = this.context.createGain();
18
+ this.sfxGain.connect(this.masterGain);
19
+ this.musicGain.connect(this.masterGain);
20
+ this.masterGain.connect(this.context.destination);
21
+ this.masterGain.gain.value = 1;
22
+ this.sfxGain.gain.value = 1;
23
+ this.musicGain.gain.value = 1;
24
+ }
25
+ /** Singleton accessor */
26
+ static get instance() {
27
+ if (typeof window === 'undefined') {
28
+ // Return a dummy instance for SSR
29
+ return new Proxy({}, {
30
+ get: () => () => { }
31
+ });
32
+ }
33
+ if (!SoundManager._instance) {
34
+ SoundManager._instance = new SoundManager();
35
+ }
36
+ return SoundManager._instance;
37
+ }
38
+ /** Required once after user gesture (browser) */
39
+ resume() {
40
+ if (this.context.state !== "running") {
41
+ this.context.resume();
42
+ }
43
+ }
44
+ /** Preload a sound from URL */
45
+ load(path, url) {
46
+ return __awaiter(this, void 0, void 0, function* () {
47
+ if (this.buffers.has(path))
48
+ return;
49
+ const res = yield fetch(url);
50
+ const arrayBuffer = yield res.arrayBuffer();
51
+ const buffer = yield this.context.decodeAudioData(arrayBuffer);
52
+ this.buffers.set(path, buffer);
53
+ });
54
+ }
55
+ /** Play from already-loaded buffer (fails silently if not loaded) */
56
+ playSync(path, { volume = 1, playbackRate = 1, detune = 0, pitch = 1, } = {}) {
57
+ this.resume();
58
+ const buffer = this.buffers.get(path);
59
+ if (!buffer)
60
+ return;
61
+ const src = this.context.createBufferSource();
62
+ const gain = this.context.createGain();
63
+ src.buffer = buffer;
64
+ src.playbackRate.value = playbackRate * pitch;
65
+ src.detune.value = detune;
66
+ gain.gain.value = volume;
67
+ src.connect(gain);
68
+ gain.connect(this.sfxGain);
69
+ src.start();
70
+ }
71
+ /** Load and play SFX - accepts file path directly */
72
+ play(path, options) {
73
+ return __awaiter(this, void 0, void 0, function* () {
74
+ // Auto-load from path if not already loaded
75
+ if (!this.buffers.has(path)) {
76
+ yield this.load(path, path);
77
+ }
78
+ this.playSync(path, options);
79
+ });
80
+ }
81
+ /** Volume controls */
82
+ setMasterVolume(v) {
83
+ this.masterGain.gain.value = v;
84
+ }
85
+ setSfxVolume(v) {
86
+ this.sfxGain.gain.value = v;
87
+ }
88
+ setMusicVolume(v) {
89
+ this.musicGain.gain.value = v;
90
+ }
91
+ }
92
+ SoundManager._instance = null;
93
+ export const sound = SoundManager.instance;
@@ -0,0 +1,35 @@
1
+ import type { GameObject } from "../tools/prefabeditor/types";
2
+ export type Vec3 = [number, number, number];
3
+ export interface GroundOptions {
4
+ /** GameObject id. Defaults to "ground". */
5
+ id?: string;
6
+ /** Plane size. Defaults to 50. */
7
+ size?: number;
8
+ /** Transform overrides. */
9
+ position?: Vec3;
10
+ rotation?: Vec3;
11
+ scale?: Vec3;
12
+ /** Material overrides. */
13
+ color?: string;
14
+ texture?: string;
15
+ /** When true, set repeat wrapping. Defaults to true if texture is provided. */
16
+ repeat?: boolean;
17
+ /** Texture repeat counts when repeat=true. Defaults to [25,25]. */
18
+ repeatCount?: [number, number];
19
+ /** Physics body type. Defaults to "fixed". */
20
+ physicsType?: "fixed" | "dynamic" | "kinematic";
21
+ /** Set true to hide the node. */
22
+ hidden?: boolean;
23
+ /** Set true to disable the node. */
24
+ disabled?: boolean;
25
+ }
26
+ /**
27
+ * Create a ready-to-use plane ground GameObject.
28
+ *
29
+ * Designed to reduce prefab boilerplate:
30
+ * - Transform (rotated to lie flat)
31
+ * - Geometry (plane)
32
+ * - Material (optional texture + repeat)
33
+ * - Physics (fixed by default)
34
+ */
35
+ export declare function ground(options?: GroundOptions): GameObject;
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Create a ready-to-use plane ground GameObject.
3
+ *
4
+ * Designed to reduce prefab boilerplate:
5
+ * - Transform (rotated to lie flat)
6
+ * - Geometry (plane)
7
+ * - Material (optional texture + repeat)
8
+ * - Physics (fixed by default)
9
+ */
10
+ export function ground(options = {}) {
11
+ const { id = "ground", size = 50, position = [0, 0, 0], rotation = [-Math.PI / 2, 0, 0], scale = [1, 1, 1], color = "white", texture, repeat = texture ? true : false, repeatCount = [25, 25], physicsType = "fixed", hidden = false, disabled = false, } = options;
12
+ return {
13
+ id,
14
+ disabled,
15
+ hidden,
16
+ components: {
17
+ transform: {
18
+ type: "Transform",
19
+ properties: {
20
+ position,
21
+ rotation,
22
+ scale,
23
+ },
24
+ },
25
+ geometry: {
26
+ type: "Geometry",
27
+ properties: {
28
+ geometryType: "plane",
29
+ args: [size, size],
30
+ },
31
+ },
32
+ material: {
33
+ type: "Material",
34
+ properties: Object.assign(Object.assign({ color }, (texture ? { texture } : {})), (repeat ? { repeat: true, repeatCount } : {})),
35
+ },
36
+ physics: {
37
+ type: "Physics",
38
+ properties: {
39
+ type: physicsType,
40
+ },
41
+ },
42
+ },
43
+ };
44
+ }
@@ -0,0 +1,14 @@
1
+ export { default as GameCanvas } from './shared/GameCanvas';
2
+ export { default as PrefabEditor } from './tools/prefabeditor/PrefabEditor';
3
+ export type { PrefabEditorRef } from './tools/prefabeditor/PrefabEditor';
4
+ export { default as PrefabRoot } from './tools/prefabeditor/PrefabRoot';
5
+ export type { PrefabRootRef } from './tools/prefabeditor/PrefabRoot';
6
+ export { registerComponent } from './tools/prefabeditor/components/ComponentRegistry';
7
+ export type { Component } from './tools/prefabeditor/components/ComponentRegistry';
8
+ export type { Prefab, GameObject, ComponentData } from './tools/prefabeditor/types';
9
+ export * as editorStyles from './tools/prefabeditor/styles';
10
+ export * from './tools/prefabeditor/utils';
11
+ export { DragDropLoader } from './tools/dragdrop/DragDropLoader';
12
+ export { TextureListViewer, ModelListViewer, SoundListViewer, SharedCanvas, } from './tools/assetviewer/page';
13
+ export { sound as soundManager } from './helpers/SoundManager';
14
+ export * from './helpers';
package/dist/index.js ADDED
@@ -0,0 +1,14 @@
1
+ // Core Components
2
+ export { default as GameCanvas } from './shared/GameCanvas';
3
+ // Prefab Editor
4
+ export { default as PrefabEditor } from './tools/prefabeditor/PrefabEditor';
5
+ export { default as PrefabRoot } from './tools/prefabeditor/PrefabRoot';
6
+ export { registerComponent } from './tools/prefabeditor/components/ComponentRegistry';
7
+ export * as editorStyles from './tools/prefabeditor/styles';
8
+ export * from './tools/prefabeditor/utils';
9
+ // Asset Tools
10
+ export { DragDropLoader } from './tools/dragdrop/DragDropLoader';
11
+ export { TextureListViewer, ModelListViewer, SoundListViewer, SharedCanvas, } from './tools/assetviewer/page';
12
+ export { sound as soundManager } from './helpers/SoundManager';
13
+ // Helpers
14
+ export * from './helpers';