@tomorrowevening/hermes 0.0.37 → 0.0.39

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 (75) hide show
  1. package/dist/hermes.cjs.js +15 -15
  2. package/dist/hermes.esm.js +809 -811
  3. package/package.json +1 -5
  4. package/types/core/Application.d.ts +5 -4
  5. package/types/core/remote/BaseRemote.d.ts +4 -0
  6. package/types/core/remote/RemoteComponents.d.ts +1 -2
  7. package/types/core/remote/RemoteTheatre.d.ts +3 -4
  8. package/types/core/remote/RemoteThree.d.ts +2 -3
  9. package/types/core/remote/RemoteTweakpane.d.ts +1 -1
  10. package/types/editor/sidePanel/SidePanel.d.ts +1 -9
  11. package/dist/hermes.umd.js +0 -144
  12. package/src/core/Application.ts +0 -111
  13. package/src/core/RemoteController.ts +0 -60
  14. package/src/core/remote/BaseRemote.ts +0 -16
  15. package/src/core/remote/RemoteComponents.ts +0 -45
  16. package/src/core/remote/RemoteTheatre.ts +0 -300
  17. package/src/core/remote/RemoteThree.ts +0 -143
  18. package/src/core/remote/RemoteTweakpane.ts +0 -194
  19. package/src/core/types.ts +0 -56
  20. package/src/editor/Editor.tsx +0 -20
  21. package/src/editor/components/Draggable.tsx +0 -40
  22. package/src/editor/components/DraggableItem.tsx +0 -22
  23. package/src/editor/components/Dropdown.tsx +0 -38
  24. package/src/editor/components/DropdownItem.tsx +0 -64
  25. package/src/editor/components/NavButton.tsx +0 -11
  26. package/src/editor/components/content.ts +0 -2
  27. package/src/editor/components/icons/CloseIcon.tsx +0 -7
  28. package/src/editor/components/icons/DragIcon.tsx +0 -9
  29. package/src/editor/components/types.ts +0 -41
  30. package/src/editor/global.ts +0 -20
  31. package/src/editor/multiView/CameraWindow.tsx +0 -74
  32. package/src/editor/multiView/InfiniteGridHelper.ts +0 -24
  33. package/src/editor/multiView/InfiniteGridMaterial.ts +0 -127
  34. package/src/editor/multiView/MultiView.scss +0 -101
  35. package/src/editor/multiView/MultiView.tsx +0 -636
  36. package/src/editor/multiView/MultiViewData.ts +0 -59
  37. package/src/editor/multiView/UVMaterial.ts +0 -55
  38. package/src/editor/scss/_debug.scss +0 -58
  39. package/src/editor/scss/_draggable.scss +0 -43
  40. package/src/editor/scss/_dropdown.scss +0 -84
  41. package/src/editor/scss/_sidePanel.scss +0 -278
  42. package/src/editor/scss/_theme.scss +0 -9
  43. package/src/editor/scss/index.scss +0 -67
  44. package/src/editor/sidePanel/Accordion.tsx +0 -41
  45. package/src/editor/sidePanel/ChildObject.tsx +0 -57
  46. package/src/editor/sidePanel/ContainerObject.tsx +0 -11
  47. package/src/editor/sidePanel/SidePanel.tsx +0 -64
  48. package/src/editor/sidePanel/ToggleBtn.tsx +0 -27
  49. package/src/editor/sidePanel/inspector/Inspector.tsx +0 -119
  50. package/src/editor/sidePanel/inspector/InspectorField.tsx +0 -198
  51. package/src/editor/sidePanel/inspector/InspectorGroup.tsx +0 -50
  52. package/src/editor/sidePanel/inspector/SceneInspector.tsx +0 -84
  53. package/src/editor/sidePanel/inspector/inspector.scss +0 -161
  54. package/src/editor/sidePanel/inspector/utils/InspectAnimation.tsx +0 -102
  55. package/src/editor/sidePanel/inspector/utils/InspectCamera.tsx +0 -75
  56. package/src/editor/sidePanel/inspector/utils/InspectLight.tsx +0 -62
  57. package/src/editor/sidePanel/inspector/utils/InspectMaterial.tsx +0 -710
  58. package/src/editor/sidePanel/inspector/utils/InspectTransform.tsx +0 -113
  59. package/src/editor/sidePanel/types.ts +0 -130
  60. package/src/editor/sidePanel/utils.ts +0 -278
  61. package/src/editor/utils.ts +0 -117
  62. package/src/example/CustomEditor.tsx +0 -78
  63. package/src/example/components/App.css +0 -6
  64. package/src/example/components/App.tsx +0 -246
  65. package/src/example/constants.ts +0 -52
  66. package/src/example/index.scss +0 -45
  67. package/src/example/main.tsx +0 -37
  68. package/src/example/three/BaseScene.ts +0 -42
  69. package/src/example/three/CustomMaterial.ts +0 -72
  70. package/src/example/three/FBXAnimation.ts +0 -26
  71. package/src/example/three/Scene1.ts +0 -225
  72. package/src/example/three/Scene2.ts +0 -138
  73. package/src/example/three/loader.ts +0 -110
  74. package/src/index.ts +0 -27
  75. package/src/vite-env.d.ts +0 -1
@@ -1,60 +0,0 @@
1
- // Core
2
- import Application from './Application';
3
- import { ToolEvents, debugDispatcher } from '@/editor/global';
4
- import { BroadcastData } from './types';
5
- import BaseRemote from './remote/BaseRemote';
6
- import RemoteComponents, { HandleAppRemoteComponents } from './remote/RemoteComponents';
7
- import RemoteTheatre, { HandleAppRemoteTheatre, HandleEditorRemoteTheatre, UpdateRemoteTheatre } from './remote/RemoteTheatre';
8
- import RemoteThree, { HandleAppRemoteThree, HandleEditorRemoteThree } from './remote/RemoteThree';
9
- import RemoteTweakpane, { HandleAppRemoteTweakpane } from './remote/RemoteTweakpane';
10
-
11
- export default function RemoteController(app: Application) {
12
- const appHandlers: any[] = [];
13
- const editorHandlers: any[] = [];
14
-
15
- // Correct handlers based on the App's components
16
- app.components.forEach((value: BaseRemote) => {
17
- if (value instanceof RemoteComponents) {
18
- appHandlers.push(HandleAppRemoteComponents);
19
- } else if (value instanceof RemoteTheatre) {
20
- appHandlers.push(HandleAppRemoteTheatre);
21
- editorHandlers.push(HandleEditorRemoteTheatre);
22
- UpdateRemoteTheatre(app);
23
- } else if (value instanceof RemoteThree) {
24
- appHandlers.push(HandleAppRemoteThree);
25
- editorHandlers.push(HandleEditorRemoteThree);
26
- } else if (value instanceof RemoteTweakpane) {
27
- appHandlers.push(HandleAppRemoteTweakpane);
28
- }
29
- });
30
-
31
- function handleAppBroadcast(msg: BroadcastData) {
32
- appHandlers.forEach((handler: any) => handler(app, msg));
33
- switch (msg.event) {
34
- case 'custom':
35
- // @ts-ignore
36
- debugDispatcher.dispatchEvent({ type: ToolEvents.CUSTOM, value: msg.data });
37
- break;
38
- }
39
- }
40
-
41
- function handleEditorBroadcast(msg: BroadcastData) {
42
- editorHandlers.forEach((handler: any) => handler(app, msg));
43
- switch (msg.event) {
44
- case 'custom':
45
- // @ts-ignore
46
- debugDispatcher.dispatchEvent({ type: ToolEvents.CUSTOM, value: msg.data });
47
- break;
48
- }
49
- }
50
-
51
- // Begin app
52
-
53
- app.listen = (msg: BroadcastData) => {
54
- if (msg.target === 'editor') {
55
- handleEditorBroadcast(msg);
56
- } else {
57
- handleAppBroadcast(msg);
58
- }
59
- };
60
- }
@@ -1,16 +0,0 @@
1
- import Application from '../Application';
2
-
3
- /**
4
- * Base class for remote-related extensions
5
- */
6
- export default class BaseRemote {
7
- protected app: Application;
8
-
9
- constructor(app: Application) {
10
- this.app = app;
11
- }
12
-
13
- dispose() {
14
- //
15
- }
16
- }
@@ -1,45 +0,0 @@
1
- // Core
2
- import { ToolEvents, debugDispatcher } from '@/editor/global';
3
- import Application from '../Application';
4
- import BaseRemote from './BaseRemote';
5
- import { BroadcastData } from '../types';
6
-
7
- /**
8
- * Communicates between custom React Components
9
- */
10
- export default class RemoteComponents extends BaseRemote {
11
- selectDropdown(dropdown: string, value: any) {
12
- this.app.send({
13
- event: 'selectComponent',
14
- target: 'app',
15
- data: {
16
- dropdown,
17
- value
18
- }
19
- });
20
- }
21
-
22
- updateDropdown(dropdown: string, list: string[]) {
23
- this.app.send({
24
- event: 'draggableListUpdate',
25
- target: 'app',
26
- data: {
27
- dropdown,
28
- value: list
29
- }
30
- });
31
- }
32
- }
33
-
34
- export function HandleAppRemoteComponents(_: Application, msg: BroadcastData) {
35
- switch (msg.event) {
36
- case 'selectComponent':
37
- // @ts-ignore
38
- debugDispatcher.dispatchEvent({ type: ToolEvents.SELECT_DROPDOWN, value: msg.data });
39
- break;
40
- case 'draggableListUpdate':
41
- // @ts-ignore
42
- debugDispatcher.dispatchEvent({ type: ToolEvents.DRAG_UPDATE, value: msg.data });
43
- break;
44
- }
45
- }
@@ -1,300 +0,0 @@
1
- // Libs
2
- import { createRafDriver, getProject } from '@theatre/core';
3
- import { IProject, IProjectConfig, IRafDriver, ISheet, ISheetObject } from '@theatre/core';
4
- import studio from '@theatre/studio';
5
- // Core
6
- import Application from '../Application';
7
- import BaseRemote from './BaseRemote';
8
- import { isColor } from '@/editor/utils';
9
- import { BroadcastData, DataUpdateCallback, EditorEvent, VoidCallback, noop } from '../types';
10
-
11
- export default class RemoteTheatre extends BaseRemote {
12
- project: IProject | undefined;
13
- sheets: Map<string, ISheet> = new Map();
14
- sheetObjects: Map<string, ISheetObject> = new Map();
15
- sheetObjectCBs: Map<string, DataUpdateCallback> = new Map();
16
- sheetObjectUnsubscribe: Map<string, VoidCallback> = new Map();
17
-
18
- private static rafDriver: IRafDriver | null = null;
19
-
20
- init(projectName: string, projectConfig?: IProjectConfig | undefined): Promise<void> {
21
- this.project = getProject(projectName, projectConfig);
22
- return this.project.ready;
23
- }
24
-
25
- override dispose(): void {
26
- this.project = undefined;
27
- this.sheets = new Map();
28
- this.sheetObjects = new Map();
29
- this.sheetObjectCBs = new Map();
30
- this.sheetObjectUnsubscribe = new Map();
31
- }
32
-
33
- sheet(name: string): ISheet | undefined {
34
- if (this.project === undefined) {
35
- console.error('Theatre Project hasn\'t been created yet.');
36
- return undefined;
37
- }
38
-
39
- let sheet = this.sheets.get(name);
40
- if (sheet !== undefined) return sheet;
41
-
42
- sheet = this.project?.sheet(name);
43
- this.sheets.set(name, sheet);
44
- return sheet;
45
- }
46
-
47
- playSheet(name: string, params?: any) {
48
- this.sheet(name)?.sequence.play(params);
49
-
50
- this.app.send({
51
- event: 'playSheet',
52
- target: 'editor',
53
- data: {
54
- sheet: name,
55
- value: params,
56
- },
57
- });
58
- }
59
-
60
- pauseSheet(name: string) {
61
- this.sheet(name)?.sequence.pause();
62
-
63
- this.app.send({
64
- event: 'pauseSheet',
65
- target: 'editor',
66
- data: {
67
- sheet: name,
68
- },
69
- });
70
- }
71
-
72
- clearSheetObjects(sheetName: string) {
73
- this.sheetObjects.forEach((value: ISheetObject, key: string) => {
74
- const sameSheet = key.search(`${sheetName}_`) > -1;
75
- if (sameSheet) this.unsubscribe(value);
76
- });
77
- }
78
-
79
- sheetObject(
80
- sheetName: string,
81
- key: string,
82
- props: any,
83
- onUpdate?: DataUpdateCallback,
84
- ): ISheetObject | undefined {
85
- if (this.project === undefined) {
86
- console.error('Theatre Project hasn\'t been created yet.');
87
- return undefined;
88
- }
89
- const sheet = this.sheet(sheetName);
90
- if (sheet === undefined) return undefined;
91
-
92
- const objName = `${sheetName}_${key}`;
93
- let obj = this.sheetObjects.get(objName);
94
- if (obj !== undefined) {
95
- obj = sheet.object(key, {...props, ...obj.value}, {reconfigure: true});
96
- } else {
97
- obj = sheet.object(key, props);
98
- }
99
-
100
- this.sheetObjects.set(objName, obj);
101
- this.sheetObjectCBs.set(objName, onUpdate !== undefined ? onUpdate : noop);
102
-
103
- const unsubscribe = obj.onValuesChange((values: any) => {
104
- if (this.app.editor) {
105
- for (const i in values) {
106
- const value = values[i];
107
- if (typeof value === 'object') {
108
- if (isColor(value)) {
109
- values[i] = {
110
- r: value.r,
111
- g: value.g,
112
- b: value.b,
113
- a: value.a,
114
- };
115
- }
116
- }
117
- }
118
- this.app.send({
119
- event: 'updateSheetObject',
120
- target: 'app',
121
- data: {
122
- sheet: sheetName,
123
- sheetObject: objName,
124
- values: values,
125
- },
126
- });
127
- }
128
-
129
- const callback = this.sheetObjectCBs.get(objName);
130
- if (callback !== undefined) callback(values);
131
- });
132
- this.sheetObjectUnsubscribe.set(objName, unsubscribe);
133
-
134
- return obj;
135
- }
136
-
137
- unsubscribe(sheetObject: ISheetObject) {
138
- if (this.project === undefined) {
139
- console.error('Theatre Project hasn\'t been created yet.');
140
- return undefined;
141
- }
142
-
143
- const sheetName = sheetObject.address.sheetId;
144
- const sheetObjectName = sheetObject.address.objectKey;
145
- const sheet = this.sheets.get(sheetName);
146
- sheet?.detachObject(sheetObjectName);
147
-
148
- const id = `${sheetName}_${sheetObjectName}`;
149
- const unsubscribe = this.sheetObjectUnsubscribe.get(id);
150
- if (unsubscribe !== undefined) {
151
- this.sheetObjects.delete(id);
152
- this.sheetObjectCBs.delete(id);
153
- this.sheetObjectUnsubscribe.delete(id);
154
- unsubscribe();
155
- }
156
- }
157
-
158
- public static getRafDriver(): IRafDriver {
159
- if (!RemoteTheatre.rafDriver) {
160
- RemoteTheatre.rafDriver = createRafDriver();
161
- }
162
- return RemoteTheatre.rafDriver;
163
- }
164
- }
165
-
166
- let activeSheet: ISheet | undefined;
167
-
168
- export function HandleAppRemoteTheatre(app: Application, msg: BroadcastData) {
169
- app.components.forEach((component: any) => {
170
- if (component instanceof RemoteTheatre) {
171
- let value = undefined;
172
- const theatre = component as RemoteTheatre;
173
- switch (msg.event) {
174
- case 'setSheet':
175
- // @ts-ignore
176
- value = theatre.sheets.get(msg.data.sheet);
177
- if (value !== undefined) {
178
- activeSheet = value as ISheet;
179
- studio.setSelection([value]);
180
- }
181
- break;
182
- case 'setSheetObject':
183
- // @ts-ignore
184
- value = theatre.sheetObjects.get(`${msg.data.sheet}_${msg.data.key}`);
185
- if (value !== undefined) {
186
- studio.setSelection([value]);
187
- }
188
- break;
189
- case 'updateSheetObject':
190
- // @ts-ignore
191
- value = theatre.sheets.get(msg.data.sheet); // pause current animation
192
- // @ts-ignore
193
- if (value !== undefined) value.sequence.pause();
194
- // @ts-ignore
195
- value = theatre.sheetObjectCBs.get(msg.data.sheetObject);
196
- // @ts-ignore
197
- if (value !== undefined) value(msg.data.values);
198
- break;
199
- case 'updateTimeline':
200
- // @ts-ignore
201
- value = theatre.sheets.get(msg.data.sheet);
202
- if (activeSheet !== undefined) {
203
- (activeSheet as ISheet).sequence.position = msg.data.position;
204
- }
205
- break;
206
- }
207
- }
208
- });
209
- }
210
-
211
- export function UpdateRemoteTheatre(app: Application) {
212
- if (app.editor) {
213
- let theatre: RemoteTheatre;
214
- app.components.forEach((component: any) => {
215
- if (component instanceof RemoteTheatre) {
216
- theatre = component;
217
- }
218
- });
219
-
220
- studio.ui.restore();
221
- studio.onSelectionChange((value: any[]) => {
222
- if (value.length < 1) return;
223
-
224
- value.forEach((obj: any) => {
225
- let id = obj.address.sheetId;
226
- let type: EditorEvent = 'setSheet';
227
- let data = {};
228
- switch (obj.type) {
229
- case 'Theatre_Sheet_PublicAPI':
230
- type = 'setSheet';
231
- data = {
232
- sheet: obj.address.sheetId,
233
- };
234
- activeSheet = theatre.sheets.get(obj.address.sheetId);
235
- break;
236
-
237
- case 'Theatre_SheetObject_PublicAPI':
238
- type = 'setSheetObject';
239
- id += `_${obj.address.objectKey}`;
240
- data = {
241
- id: id,
242
- sheet: obj.address.sheetId,
243
- key: obj.address.objectKey,
244
- };
245
- break;
246
- }
247
- app.send({ event: type, target: 'app', data: data });
248
- });
249
- });
250
-
251
- // Timeline
252
- let position = 0;
253
- const onRafUpdate = () => {
254
- // RemoteTheatre.getRafDriver().tick(performance.now());
255
-
256
- if (
257
- activeSheet !== undefined &&
258
- position !== activeSheet.sequence.position
259
- ) {
260
- position = activeSheet.sequence.position;
261
- const t = activeSheet as ISheet;
262
- app.send({
263
- event: 'updateTimeline',
264
- target: 'app',
265
- data: {
266
- position: position,
267
- sheet: t.address.sheetId,
268
- },
269
- });
270
- }
271
- };
272
- const onRaf = () => {
273
- onRafUpdate();
274
- requestAnimationFrame(onRaf);
275
- };
276
- onRafUpdate(); // Initial position
277
- onRaf();
278
- } else {
279
- studio.ui.hide();
280
- }
281
- }
282
-
283
- export function HandleEditorRemoteTheatre(app: Application, msg: BroadcastData) {
284
- if (app.editor) {
285
- app.components.forEach((component: any) => {
286
- if (component instanceof RemoteTheatre) {
287
- const theatre = component;
288
- switch (msg.event) {
289
- case 'playSheet':
290
- theatre.sheet(msg.data.sheet)?.sequence.play(msg.data.value);
291
- break;
292
- case 'pauseSheet':
293
- theatre.sheet(msg.data.sheet)?.sequence.pause();
294
- break;
295
- }
296
- return;
297
- }
298
- });
299
- }
300
- }
@@ -1,143 +0,0 @@
1
- import { Camera, Scene } from 'three';
2
- import BaseRemote from './BaseRemote';
3
- import { stripObject, stripScene } from '@/editor/sidePanel/utils';
4
- import { hierarchyUUID, resetThreeObjects } from '@/editor/utils';
5
- import Application from '../Application';
6
- import { BroadcastData } from '../types';
7
- import { ToolEvents, debugDispatcher } from '@/editor/global';
8
-
9
- export default class RemoteThree extends BaseRemote {
10
- scene?: Scene = undefined;
11
-
12
- getObject(uuid: string) {
13
- if (!this.app.debugEnabled) return;
14
- this.app.send({
15
- event: 'getObject',
16
- target: 'app',
17
- data: uuid,
18
- });
19
- }
20
-
21
- setObject(value: any) {
22
- const stripped = stripObject(value);
23
- this.app.send({
24
- event: 'setObject',
25
- target: 'editor',
26
- data: stripped,
27
- });
28
- }
29
-
30
- requestMethod(uuid: string, key: string, value?: any, subitem?: string) {
31
- this.app.send({
32
- event: 'requestMethod',
33
- target: 'app',
34
- data: {
35
- uuid,
36
- key,
37
- value,
38
- subitem,
39
- },
40
- });
41
- }
42
-
43
- updateObject(uuid: string, key: string, value: any) {
44
- this.app.send({
45
- event: 'updateObject',
46
- target: 'app',
47
- data: {
48
- uuid,
49
- key,
50
- value
51
- },
52
- });
53
- }
54
-
55
- createTexture(uuid: string, key: string, value: any) {
56
- this.app.send({
57
- event: 'createTexture',
58
- target: 'app',
59
- data: {
60
- uuid,
61
- key,
62
- value
63
- },
64
- });
65
- }
66
-
67
- setScene(value: Scene) {
68
- if (value === undefined) return;
69
- this.scene = value;
70
-
71
- if (!this.app.debugEnabled) return;
72
- resetThreeObjects();
73
- hierarchyUUID(this.scene);
74
- const stripped = stripScene(this.scene);
75
- this.app.send({
76
- event: 'setScene',
77
- target: 'editor',
78
- data: stripped,
79
- });
80
- }
81
-
82
- addCamera(camera: Camera) {
83
- if (!this.app.debugEnabled) return;
84
- const stripped = stripObject(camera);
85
- this.app.send({
86
- event: 'addCamera',
87
- target: 'editor',
88
- data: stripped,
89
- });
90
- }
91
-
92
- removeCamera(camera: Camera) {
93
- if (!this.app.debugEnabled) return;
94
- const stripped = stripObject(camera);
95
- this.app.send({
96
- event: 'removeCamera',
97
- target: 'editor',
98
- data: stripped,
99
- });
100
- }
101
- }
102
-
103
- export function HandleAppRemoteThree(_: Application, msg: BroadcastData) {
104
- switch (msg.event) {
105
- case 'getObject':
106
- // @ts-ignore
107
- debugDispatcher.dispatchEvent({ type: ToolEvents.GET_OBJECT, value: msg.data });
108
- break;
109
- case 'updateObject':
110
- // @ts-ignore
111
- debugDispatcher.dispatchEvent({ type: ToolEvents.UPDATE_OBJECT, value: msg.data });
112
- break;
113
- case 'createTexture':
114
- // @ts-ignore
115
- debugDispatcher.dispatchEvent({ type: ToolEvents.CREATE_TEXTURE, value: msg.data });
116
- break;
117
- case 'requestMethod':
118
- // @ts-ignore
119
- debugDispatcher.dispatchEvent({ type: ToolEvents.REQUEST_METHOD, value: msg.data });
120
- break;
121
- }
122
- }
123
-
124
- export function HandleEditorRemoteThree(_: Application, msg: BroadcastData) {
125
- switch (msg.event) {
126
- case 'setObject':
127
- // @ts-ignore
128
- debugDispatcher.dispatchEvent({ type: ToolEvents.SET_OBJECT, value: msg.data });
129
- break;
130
- case 'setScene':
131
- // @ts-ignore
132
- debugDispatcher.dispatchEvent({ type: ToolEvents.SET_SCENE, value: msg.data });
133
- break;
134
- case 'addCamera':
135
- // @ts-ignore
136
- debugDispatcher.dispatchEvent({ type: ToolEvents.ADD_CAMERA, value: msg.data });
137
- break;
138
- case 'removeCamera':
139
- // @ts-ignore
140
- debugDispatcher.dispatchEvent({ type: ToolEvents.REMOVE_CAMERA, value: msg.data });
141
- break;
142
- }
143
- }