@tomorrowevening/hermes 0.1.35 → 0.1.37
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 +60 -67
- package/dist/ThreeEditor-BIxyFFOU.js +111 -0
- package/dist/ThreeEditor-lbW0auGy.css +1 -0
- package/dist/hermes.cjs.js +10 -10
- package/dist/hermes.css +1 -1
- package/dist/hermes.es.js +597 -610
- package/dist/index-BlO94fgk.js +10226 -0
- package/dist/index-C92ji5gy.css +1 -0
- package/dist/index.html +2 -2
- package/package.json +1 -2
- package/types/core/Application.d.ts +1 -1
- package/types/core/remote/BaseRemote.d.ts +2 -4
- package/types/editor/HermesApp.d.ts +1 -6
- package/dist/index-CJkdxrd8.js +0 -10367
- package/dist/index-s97l09lN.css +0 -1
package/README.md
CHANGED
|
@@ -10,87 +10,80 @@ This example uses [React](https://react.dev/), [ThreeJS](https://threejs.org/),
|
|
|
10
10
|
|
|
11
11
|
### Create an `Application`
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
13
|
+
Instantiate your `Application` (or a custom subclass) outside the component tree, then wrap your app with `HermesApp`. It handles `detectSettings`, the loading gate, Theatre Studio initialisation, and automatically switches between editor and app rendering based on `IS_EDITOR`.
|
|
14
|
+
|
|
15
|
+
```tsx
|
|
16
|
+
import studio from '@tomorrowevening/theatre-studio';
|
|
17
|
+
import HermesApp from '@tomorrowevening/hermes/editor/HermesApp';
|
|
18
|
+
import ExampleApplication from './three/ExampleApplication';
|
|
19
|
+
import { loadAssets } from './three/loader';
|
|
20
|
+
import Scene1 from './three/scenes/Scene1';
|
|
21
|
+
import Scene2 from './three/scenes/Scene2';
|
|
22
|
+
import MyCanvas from './components/MyCanvas';
|
|
23
|
+
import { IS_DEV, IS_EDITOR } from './constants';
|
|
24
|
+
|
|
25
|
+
// Register scene classes so MultiView can instantiate them in the editor
|
|
26
|
+
const scenes = new Map<string, any>([
|
|
27
|
+
['Scene1', Scene1],
|
|
28
|
+
['Scene2', Scene2],
|
|
29
|
+
['RTTScene', RTTScene],
|
|
30
|
+
]);
|
|
31
|
+
|
|
32
|
+
// Create once outside the component — avoids re-instantiation on re-render
|
|
33
|
+
const app = new ExampleApplication('My Project', IS_DEV, IS_EDITOR);
|
|
34
|
+
if (IS_DEV && IS_EDITOR && studio) {
|
|
35
|
+
studio.initialize();
|
|
36
|
+
app.theatre.studio = studio;
|
|
37
|
+
app.theatre.handleEditorApp();
|
|
38
|
+
}
|
|
23
39
|
|
|
24
40
|
export default function AppWrapper() {
|
|
25
|
-
const [app, setApp] = useState<Application | null>(null);
|
|
26
|
-
|
|
27
|
-
useEffect(() => {
|
|
28
|
-
const instance = new Application();
|
|
29
|
-
instance.detectSettings(IS_DEV, IS_EDITOR).then(() => {
|
|
30
|
-
// TheatreJS
|
|
31
|
-
instance.addComponent('theatre', theatre);
|
|
32
|
-
|
|
33
|
-
// ThreeJS
|
|
34
|
-
instance.addComponent('three', three);
|
|
35
|
-
|
|
36
|
-
// Ready
|
|
37
|
-
setApp(instance);
|
|
38
|
-
});
|
|
39
|
-
}, []);
|
|
40
|
-
|
|
41
|
-
// MultiView requires you identify each scene so they can be instantiated by the editor
|
|
42
|
-
const scenes: Map<string, any> = new Map();
|
|
43
|
-
scenes.set('Scene1', Scene1);
|
|
44
|
-
scenes.set('Scene2', Scene2);
|
|
45
|
-
scenes.set('RTTScene', RTTScene);
|
|
46
|
-
|
|
47
41
|
return (
|
|
48
|
-
|
|
49
|
-
{app
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
/>
|
|
61
|
-
)}
|
|
62
|
-
</>
|
|
63
|
-
)}
|
|
64
|
-
</>
|
|
65
|
-
)}
|
|
66
|
-
</>
|
|
42
|
+
<HermesApp
|
|
43
|
+
app={app}
|
|
44
|
+
scenes={scenes}
|
|
45
|
+
onSceneAdd={(scene) => {
|
|
46
|
+
scene.setup(app);
|
|
47
|
+
scene.init();
|
|
48
|
+
}}
|
|
49
|
+
onSceneUpdate={(scene) => scene.update()}
|
|
50
|
+
onLoad={loadAssets}
|
|
51
|
+
>
|
|
52
|
+
{(app) => <MyCanvas app={app} />}
|
|
53
|
+
</HermesApp>
|
|
67
54
|
);
|
|
68
55
|
}
|
|
69
56
|
```
|
|
70
57
|
|
|
71
|
-
|
|
58
|
+
#### `HermesApp` props
|
|
72
59
|
|
|
73
|
-
|
|
60
|
+
| Prop | Type | Description |
|
|
61
|
+
| --- | --- | --- |
|
|
62
|
+
| `app` | `Application` | Application instance with RemoteTheatre + RemoteThree added as components |
|
|
63
|
+
| `scenes` | `Map<string, any>` | Scene name → scene class map, used by the editor's MultiView |
|
|
64
|
+
| `onSceneAdd` | `(scene) => void` | Called when MultiView instantiates a scene (setup + init) |
|
|
65
|
+
| `onSceneUpdate` | `(scene) => void` | Called every frame for the active scene in the editor |
|
|
66
|
+
| `onSceneResize` | `(scene, w, h) => void` | Called when MultiView resizes a scene |
|
|
67
|
+
| `onLoad` | `(app) => Promise<void>` | Asset loading function — `HermesApp` waits for this before rendering children |
|
|
68
|
+
| `renderLoading` | `ReactNode` | Shown while `detectSettings` or `onLoad` is pending |
|
|
69
|
+
| `children` | `(app) => ReactNode` | App content rendered after loading completes (not shown in editor mode) |
|
|
74
70
|
|
|
75
|
-
###
|
|
71
|
+
### Scene setup
|
|
76
72
|
|
|
77
|
-
|
|
73
|
+
After all object's have been added to your scene, run `hierarchyUUID(yourScene)` to update the UUIDs of every object. This helps communicate back and forth between the app and your editor.
|
|
78
74
|
|
|
79
|
-
|
|
75
|
+
### Theatre Studio integration
|
|
80
76
|
|
|
81
|
-
|
|
77
|
+
Theatre Studio is initialised before `HermesApp` is mounted. Wire it up on the `app` instance so `HermesApp` can hand it off to the editor automatically:
|
|
82
78
|
|
|
83
|
-
```
|
|
84
|
-
|
|
85
|
-
three: RemoteThree
|
|
86
|
-
theatre: RemoteTheatre
|
|
87
|
-
}
|
|
79
|
+
```tsx
|
|
80
|
+
import studio from '@tomorrowevening/theatre-studio';
|
|
88
81
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
82
|
+
const app = new ExampleApplication('My Project', IS_DEV, IS_EDITOR);
|
|
83
|
+
if (IS_DEV && IS_EDITOR && studio) {
|
|
84
|
+
studio.initialize();
|
|
85
|
+
app.theatre.studio = studio;
|
|
86
|
+
app.theatre.handleEditorApp();
|
|
94
87
|
}
|
|
95
88
|
```
|
|
96
89
|
|