@tomorrowevening/hermes 0.0.1 → 0.0.3
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 +7 -0
- package/dist/hermes.js +2530 -718
- package/dist/hermes.umd.cjs +88 -11
- package/dist/images/android-chrome-192x192.png +0 -0
- package/dist/images/android-chrome-512x512.png +0 -0
- package/dist/images/apple-touch-icon.png +0 -0
- package/dist/images/favicon-16x16.png +0 -0
- package/dist/images/favicon-32x32.png +0 -0
- package/dist/images/favicon.ico +0 -0
- package/dist/images/milkyWay/dark-s_nx.jpg +0 -0
- package/dist/images/milkyWay/dark-s_ny.jpg +0 -0
- package/dist/images/milkyWay/dark-s_nz.jpg +0 -0
- package/dist/images/milkyWay/dark-s_px.jpg +0 -0
- package/dist/images/milkyWay/dark-s_py.jpg +0 -0
- package/dist/images/milkyWay/dark-s_pz.jpg +0 -0
- package/dist/images/site.webmanifest +1 -0
- package/dist/images/uv_grid_opengl.jpg +0 -0
- package/dist/index-0a798fe4.js +6862 -0
- package/dist/index-7bad599d.css +1 -0
- package/dist/index.html +18 -0
- package/dist/models/Flair.fbx +0 -0
- package/dist/models/Thriller2.fbx +0 -0
- package/dist/models/Thriller4.fbx +0 -0
- package/dist/style.css +1 -1
- package/package.json +9 -4
- package/src/core/Application.ts +28 -36
- package/src/core/RemoteController.ts +148 -98
- package/src/core/remote/BaseRemote.ts +3 -3
- package/src/core/remote/RemoteComponents.ts +5 -8
- package/src/core/remote/RemoteTheatre.ts +56 -54
- package/src/core/remote/RemoteThree.ts +77 -0
- package/src/core/remote/RemoteTweakpane.ts +71 -78
- package/src/core/types.ts +14 -4
- package/src/editor/Editor.tsx +8 -6
- package/src/editor/components/Draggable.tsx +20 -20
- package/src/editor/components/DraggableItem.tsx +6 -6
- package/src/editor/components/Dropdown.tsx +22 -14
- package/src/editor/components/DropdownItem.tsx +19 -19
- package/src/editor/components/NavButton.tsx +1 -1
- package/src/editor/components/content.ts +2 -0
- package/src/editor/components/icons/CloseIcon.tsx +1 -1
- package/src/editor/components/icons/DragIcon.tsx +1 -1
- package/src/editor/global.ts +9 -4
- package/src/editor/sceneHierarchy/Accordion.tsx +40 -0
- package/src/editor/sceneHierarchy/ChildObject.tsx +17 -17
- package/src/editor/sceneHierarchy/ContainerObject.tsx +7 -8
- package/src/editor/sceneHierarchy/SceneHierarchy.tsx +52 -49
- package/src/editor/sceneHierarchy/ToggleBtn.tsx +26 -0
- package/src/editor/sceneHierarchy/inspector/Inspector.tsx +82 -0
- package/src/editor/sceneHierarchy/inspector/InspectorField.tsx +178 -0
- package/src/editor/sceneHierarchy/inspector/InspectorGroup.tsx +55 -0
- package/src/editor/sceneHierarchy/inspector/MultiView/CameraWindow.tsx +61 -0
- package/src/editor/sceneHierarchy/inspector/MultiView/InfiniteGridHelper.ts +24 -0
- package/src/editor/sceneHierarchy/inspector/MultiView/InfiniteGridMaterial.ts +127 -0
- package/src/editor/sceneHierarchy/inspector/MultiView/MultiView.scss +93 -0
- package/src/editor/sceneHierarchy/inspector/MultiView/MultiView.tsx +450 -0
- package/src/editor/sceneHierarchy/inspector/SceneInspector.tsx +72 -0
- package/src/editor/sceneHierarchy/inspector/inspector.scss +150 -0
- package/src/editor/sceneHierarchy/inspector/utils/InspectCamera.tsx +75 -0
- package/src/editor/sceneHierarchy/inspector/utils/InspectLight.tsx +62 -0
- package/src/editor/sceneHierarchy/inspector/utils/InspectMaterial.tsx +340 -0
- package/src/editor/sceneHierarchy/inspector/utils/InspectTransform.tsx +124 -0
- package/src/editor/sceneHierarchy/types.ts +116 -5
- package/src/editor/sceneHierarchy/utils.ts +207 -11
- package/src/editor/scss/_debug.scss +9 -19
- package/src/editor/scss/_dropdown.scss +1 -0
- package/src/editor/scss/_sceneHierarchy.scss +148 -48
- package/src/editor/scss/index.scss +13 -6
- package/src/editor/utils.ts +42 -5
- package/src/example/CustomEditor.tsx +40 -0
- package/src/example/components/App.tsx +164 -0
- package/src/example/constants.ts +40 -9
- package/src/example/main.tsx +5 -45
- package/src/example/three/CustomMaterial.ts +58 -0
- package/src/example/three/ExampleScene.ts +176 -0
- package/src/example/three/FBXAnimation.ts +39 -0
- package/src/index.ts +22 -0
- package/types/core/Application.d.ts +7 -13
- package/types/core/remote/RemoteComponents.d.ts +0 -2
- package/types/core/remote/RemoteThree.d.ts +12 -0
- package/types/core/remote/RemoteTweakpane.d.ts +3 -3
- package/types/core/types.d.ts +4 -3
- package/types/editor/Editor.d.ts +2 -1
- package/types/editor/components/content.d.ts +2 -0
- package/types/editor/global.d.ts +7 -2
- package/types/editor/sceneHierarchy/Accordion.d.ts +10 -0
- package/types/editor/sceneHierarchy/SceneHierarchy.d.ts +5 -5
- package/types/editor/sceneHierarchy/ToggleBtn.d.ts +7 -0
- package/types/editor/sceneHierarchy/inspector/Inspector.d.ts +3 -0
- package/types/editor/sceneHierarchy/inspector/InspectorField.d.ts +13 -0
- package/types/editor/sceneHierarchy/inspector/InspectorGroup.d.ts +7 -0
- package/types/editor/sceneHierarchy/inspector/MultiView/CameraWindow.d.ts +16 -0
- package/types/editor/sceneHierarchy/inspector/MultiView/InfiniteGridHelper.d.ts +7 -0
- package/types/editor/sceneHierarchy/inspector/MultiView/InfiniteGridMaterial.d.ts +13 -0
- package/types/editor/sceneHierarchy/inspector/MultiView/MultiView.d.ts +11 -0
- package/types/editor/sceneHierarchy/inspector/SceneInspector.d.ts +7 -0
- package/types/editor/sceneHierarchy/inspector/utils/InspectCamera.d.ts +3 -0
- package/types/editor/sceneHierarchy/inspector/utils/InspectLight.d.ts +3 -0
- package/types/editor/sceneHierarchy/inspector/utils/InspectMaterial.d.ts +8 -0
- package/types/editor/sceneHierarchy/inspector/utils/InspectTransform.d.ts +3 -0
- package/types/editor/sceneHierarchy/types.d.ts +98 -7
- package/types/editor/sceneHierarchy/utils.d.ts +7 -1
- package/types/editor/utils.d.ts +3 -0
- package/types/example/CustomEditor.d.ts +1 -0
- package/types/example/constants.d.ts +15 -3
- package/types/example/three/CustomMaterial.d.ts +5 -0
- package/types/example/three/ExampleScene.d.ts +18 -0
- package/types/example/three/FBXAnimation.d.ts +6 -0
- package/types/{library.d.ts → index.d.ts} +5 -0
- package/src/example/App.tsx +0 -88
- package/src/library.ts +0 -16
- package/types/core/remote/RemoteDebug.d.ts +0 -23
- package/types/debug/Editor.d.ts +0 -8
- package/types/debug/components/Draggable.d.ts +0 -2
- package/types/debug/components/DraggableItem.d.ts +0 -2
- package/types/debug/components/Dropdown.d.ts +0 -2
- package/types/debug/components/DropdownItem.d.ts +0 -2
- package/types/debug/components/NavButton.d.ts +0 -5
- package/types/debug/components/icons/CloseIcon.d.ts +0 -2
- package/types/debug/components/icons/DragIcon.d.ts +0 -2
- package/types/debug/components/types.d.ts +0 -31
- package/types/debug/global.d.ts +0 -9
- package/types/debug/sceneHierarchy/ChildObject.d.ts +0 -2
- package/types/debug/sceneHierarchy/ContainerObject.d.ts +0 -2
- package/types/debug/sceneHierarchy/SceneHierarchy.d.ts +0 -13
- package/types/debug/sceneHierarchy/types.d.ts +0 -8
- package/types/debug/sceneHierarchy/utils.d.ts +0 -2
- package/types/debug/utils.d.ts +0 -4
- /package/src/example/{App.css → components/App.css} +0 -0
- /package/types/example/{App.d.ts → components/App.d.ts} +0 -0
@@ -1,135 +1,185 @@
|
|
1
1
|
// Libs
|
2
|
-
import type { ISheet } from '@theatre/core'
|
3
|
-
import studio from '@theatre/studio'
|
2
|
+
import type { ISheet } from '@theatre/core';
|
3
|
+
import studio from '@theatre/studio';
|
4
4
|
// Core
|
5
|
-
import Application from './Application'
|
6
|
-
import { ToolEvents, debugDispatcher } from '
|
7
|
-
import type { BroadcastData, EditorEvent } from './types'
|
5
|
+
import Application from './Application';
|
6
|
+
import { ToolEvents, debugDispatcher } from '@/editor/global';
|
7
|
+
import type { BroadcastData, EditorEvent } from './types';
|
8
8
|
|
9
9
|
export default function RemoteController(app: Application) {
|
10
|
-
let activeSheet: ISheet | undefined = undefined
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
10
|
+
let activeSheet: ISheet | undefined = undefined;
|
11
|
+
const mode = app.editor ? 'editor' : 'app';
|
12
|
+
|
13
|
+
// Handlers
|
14
|
+
|
15
|
+
function handleAppBroadcast(msg: BroadcastData) {
|
16
|
+
let value = undefined;
|
17
|
+
|
18
|
+
switch (msg.event) {
|
19
|
+
case 'custom':
|
20
|
+
debugDispatcher.dispatchEvent({ type: ToolEvents.CUSTOM, value: msg.data });
|
21
|
+
break;
|
22
|
+
|
23
|
+
// Components
|
24
|
+
case 'selectComponent':
|
25
|
+
debugDispatcher.dispatchEvent({ type: ToolEvents.SELECT_DROPDOWN, value: msg.data });
|
26
|
+
break;
|
27
|
+
case 'draggableListUpdate':
|
28
|
+
debugDispatcher.dispatchEvent({ type: ToolEvents.DRAG_UPDATE, value: msg.data });
|
29
|
+
break;
|
30
|
+
|
31
|
+
// GUI
|
32
|
+
case 'addFolder':
|
33
|
+
app.components.get('debug')?.addFolder(msg.data.name, msg.data.params, msg.data.parent);
|
34
|
+
break;
|
35
|
+
case 'bindObject':
|
36
|
+
app.components.get('debug')?.bind(msg.data.name, msg.data.params, msg.data.parent);
|
37
|
+
break;
|
38
|
+
case 'updateBind':
|
39
|
+
app.components.get('debug')?.triggerBind(msg.data.id, msg.data.value);
|
40
|
+
break;
|
41
|
+
case 'addButton':
|
42
|
+
app.components.get('debug')?.button(msg.data.name, msg.data.callback, msg.data.parent);
|
43
|
+
break;
|
44
|
+
case 'clickButton':
|
45
|
+
app.components.get('debug')?.triggerButton(msg.data.id);
|
46
|
+
break;
|
47
|
+
|
48
|
+
// Theatre
|
49
|
+
case 'setSheet':
|
50
|
+
value = app.components.get('theatre')?.sheets.get(msg.data.sheet);
|
51
|
+
if (value !== undefined) {
|
52
|
+
activeSheet = value;
|
53
|
+
studio.setSelection([value]);
|
54
|
+
}
|
55
|
+
break;
|
56
|
+
case 'setSheetObject':
|
57
|
+
value = app.components.get('theatre')?.sheetObjects.get(`${msg.data.sheet}_${msg.data.key}`);
|
58
|
+
if (value !== undefined) {
|
59
|
+
studio.setSelection([value]);
|
60
|
+
}
|
61
|
+
break;
|
62
|
+
case 'updateSheetObject':
|
63
|
+
value = app.components.get('theatre')?.sheetObjectCBs.get(msg.data.sheetObject);
|
64
|
+
// @ts-ignore
|
65
|
+
if (value !== undefined) value(msg.data.values);
|
66
|
+
break;
|
67
|
+
case 'updateTimeline':
|
68
|
+
activeSheet = app.components.get('theatre')?.sheets.get(msg.data.sheet);
|
69
|
+
if (activeSheet !== undefined) {
|
70
|
+
activeSheet.sequence.position = msg.data.position;
|
71
|
+
}
|
72
|
+
break;
|
73
|
+
|
74
|
+
// Three
|
75
|
+
case 'getScene':
|
76
|
+
debugDispatcher.dispatchEvent({ type: ToolEvents.GET_SCENE });
|
77
|
+
break;
|
78
|
+
case 'getObject':
|
79
|
+
debugDispatcher.dispatchEvent({ type: ToolEvents.GET_OBJECT, value: msg.data });
|
80
|
+
break;
|
81
|
+
case 'updateObject':
|
82
|
+
debugDispatcher.dispatchEvent({ type: ToolEvents.UPDATE_OBJECT, value: msg.data });
|
83
|
+
break;
|
84
|
+
case 'createTexture':
|
85
|
+
debugDispatcher.dispatchEvent({ type: ToolEvents.CREATE_TEXTURE, value: msg.data });
|
86
|
+
break;
|
87
|
+
case 'requestMethod':
|
88
|
+
debugDispatcher.dispatchEvent({ type: ToolEvents.REQUEST_METHOD, value: msg.data });
|
89
|
+
break;
|
90
|
+
}
|
70
91
|
}
|
71
92
|
|
72
|
-
|
73
|
-
|
74
|
-
|
93
|
+
function handleEditorBroadcast(msg: BroadcastData) {
|
94
|
+
switch (msg.event) {
|
95
|
+
case 'custom':
|
96
|
+
debugDispatcher.dispatchEvent({ type: ToolEvents.CUSTOM, value: msg.data });
|
97
|
+
break;
|
75
98
|
|
76
|
-
|
77
|
-
|
99
|
+
// Three
|
100
|
+
case 'setObject':
|
101
|
+
debugDispatcher.dispatchEvent({ type: ToolEvents.SET_OBJECT, value: msg.data });
|
102
|
+
break;
|
103
|
+
case 'setScene':
|
104
|
+
debugDispatcher.dispatchEvent({ type: ToolEvents.SET_SCENE, value: msg.data });
|
105
|
+
break;
|
106
|
+
}
|
107
|
+
}
|
78
108
|
|
109
|
+
// App type
|
110
|
+
|
111
|
+
function AppControl() {
|
112
|
+
studio.ui.hide();
|
113
|
+
}
|
114
|
+
|
115
|
+
function EditorControl() {
|
116
|
+
studio.ui.restore();
|
117
|
+
studio.onSelectionChange((value: any[]) => {
|
118
|
+
if (value.length < 1) return;
|
119
|
+
|
79
120
|
value.forEach((obj: any) => {
|
80
|
-
let id = obj.address.sheetId
|
81
|
-
let type: EditorEvent = 'setSheet'
|
82
|
-
let data = {}
|
121
|
+
let id = obj.address.sheetId;
|
122
|
+
let type: EditorEvent = 'setSheet';
|
123
|
+
let data = {};
|
83
124
|
switch (obj.type) {
|
84
125
|
case 'Theatre_Sheet_PublicAPI':
|
85
|
-
type = 'setSheet'
|
126
|
+
type = 'setSheet';
|
86
127
|
data = {
|
87
128
|
sheet: obj.address.sheetId,
|
88
|
-
}
|
89
|
-
activeSheet = app.theatre?.sheets.get(obj.address.sheetId)
|
90
|
-
break
|
91
|
-
|
129
|
+
};
|
130
|
+
activeSheet = app.components.get('theatre')?.sheets.get(obj.address.sheetId);
|
131
|
+
break;
|
132
|
+
|
92
133
|
case 'Theatre_SheetObject_PublicAPI':
|
93
|
-
type = 'setSheetObject'
|
94
|
-
id += `_${obj.address.objectKey}
|
134
|
+
type = 'setSheetObject';
|
135
|
+
id += `_${obj.address.objectKey}`;
|
95
136
|
data = {
|
96
137
|
id: id,
|
97
138
|
sheet: obj.address.sheetId,
|
98
139
|
key: obj.address.objectKey,
|
99
|
-
}
|
100
|
-
break
|
140
|
+
};
|
141
|
+
break;
|
101
142
|
}
|
102
|
-
app.send({ event: type, data: data })
|
103
|
-
})
|
104
|
-
})
|
105
|
-
|
143
|
+
app.send({ event: type, target: 'app', data: data });
|
144
|
+
});
|
145
|
+
});
|
146
|
+
|
106
147
|
// Timeline
|
107
|
-
let position = 0
|
148
|
+
let position = 0;
|
108
149
|
const onRafUpdate = () => {
|
109
150
|
if (
|
110
151
|
activeSheet !== undefined &&
|
111
152
|
position !== activeSheet.sequence.position
|
112
153
|
) {
|
113
|
-
position = activeSheet.sequence.position
|
114
|
-
const t = activeSheet as ISheet
|
154
|
+
position = activeSheet.sequence.position;
|
155
|
+
const t = activeSheet as ISheet;
|
115
156
|
app.send({
|
116
157
|
event: 'updateTimeline',
|
158
|
+
target: 'app',
|
117
159
|
data: {
|
118
160
|
position: position,
|
119
161
|
sheet: t.address.sheetId,
|
120
162
|
},
|
121
|
-
})
|
163
|
+
});
|
122
164
|
}
|
123
|
-
}
|
165
|
+
};
|
124
166
|
const onRaf = () => {
|
125
|
-
onRafUpdate()
|
126
|
-
requestAnimationFrame(onRaf)
|
127
|
-
}
|
128
|
-
onRafUpdate() // Initial position
|
129
|
-
onRaf()
|
167
|
+
onRafUpdate();
|
168
|
+
requestAnimationFrame(onRaf);
|
169
|
+
};
|
170
|
+
onRafUpdate(); // Initial position
|
171
|
+
onRaf();
|
172
|
+
}
|
130
173
|
|
174
|
+
// Begin app
|
131
175
|
|
132
|
-
|
176
|
+
app.listen((msg: BroadcastData) => {
|
177
|
+
if (mode === 'app') {
|
178
|
+
handleAppBroadcast(msg);
|
179
|
+
} else {
|
180
|
+
handleEditorBroadcast(msg);
|
181
|
+
}
|
182
|
+
});
|
133
183
|
|
134
|
-
app.editor ?
|
184
|
+
app.editor ? EditorControl() : AppControl();
|
135
185
|
}
|
@@ -1,13 +1,13 @@
|
|
1
|
-
import Application from '../Application'
|
1
|
+
import Application from '../Application';
|
2
2
|
|
3
3
|
/**
|
4
4
|
* Base class for remote-related extensions
|
5
5
|
*/
|
6
6
|
export default class BaseRemote {
|
7
|
-
protected app: Application
|
7
|
+
protected app: Application;
|
8
8
|
|
9
9
|
constructor(app: Application) {
|
10
|
-
this.app = app
|
10
|
+
this.app = app;
|
11
11
|
}
|
12
12
|
|
13
13
|
dispose() {
|
@@ -1,32 +1,29 @@
|
|
1
1
|
// Core
|
2
|
-
import
|
3
|
-
import BaseRemote from './BaseRemote'
|
2
|
+
import BaseRemote from './BaseRemote';
|
4
3
|
|
5
4
|
/**
|
6
5
|
* Communicates between custom React Components
|
7
6
|
*/
|
8
7
|
export default class RemoteComponents extends BaseRemote {
|
9
|
-
constructor(app: Application) {
|
10
|
-
super(app)
|
11
|
-
}
|
12
|
-
|
13
8
|
selectDropdown(dropdown: string, value: any) {
|
14
9
|
this.app.send({
|
15
10
|
event: 'selectComponent',
|
11
|
+
target: 'app',
|
16
12
|
data: {
|
17
13
|
dropdown,
|
18
14
|
value
|
19
15
|
}
|
20
|
-
})
|
16
|
+
});
|
21
17
|
}
|
22
18
|
|
23
19
|
updateDropdown(dropdown: string, list: string[]) {
|
24
20
|
this.app.send({
|
25
21
|
event: 'draggableListUpdate',
|
22
|
+
target: 'app',
|
26
23
|
data: {
|
27
24
|
dropdown,
|
28
25
|
value: list
|
29
26
|
}
|
30
|
-
})
|
27
|
+
});
|
31
28
|
}
|
32
29
|
}
|
@@ -1,49 +1,50 @@
|
|
1
1
|
// Libs
|
2
|
-
import { getProject } from '@theatre/core'
|
3
|
-
import type { IProject, IProjectConfig, ISheet, ISheetObject } from '@theatre/core'
|
2
|
+
import { getProject } from '@theatre/core';
|
3
|
+
import type { IProject, IProjectConfig, ISheet, ISheetObject } from '@theatre/core';
|
4
|
+
import {} from '@theatre/studio';
|
4
5
|
// Core
|
5
|
-
import Application from '../Application'
|
6
|
-
import BaseRemote from './BaseRemote'
|
7
|
-
import { isColor } from '
|
8
|
-
import { noop } from '../types'
|
9
|
-
import type { DataUpdateCallback, VoidCallback } from '../types'
|
6
|
+
import Application from '../Application';
|
7
|
+
import BaseRemote from './BaseRemote';
|
8
|
+
import { isColor } from '@/editor/utils';
|
9
|
+
import { noop } from '../types';
|
10
|
+
import type { DataUpdateCallback, VoidCallback } from '../types';
|
10
11
|
|
11
12
|
export default class RemoteTheatre extends BaseRemote {
|
12
|
-
project: IProject | undefined
|
13
|
-
sheets: Map<string, ISheet
|
14
|
-
sheetObjects: Map<string, ISheetObject
|
15
|
-
sheetObjectCBs: Map<string, DataUpdateCallback
|
16
|
-
sheetObjectUnsubscribe: Map<string, VoidCallback
|
13
|
+
project: IProject | undefined;
|
14
|
+
sheets: Map<string, ISheet>;
|
15
|
+
sheetObjects: Map<string, ISheetObject>;
|
16
|
+
sheetObjectCBs: Map<string, DataUpdateCallback>;
|
17
|
+
sheetObjectUnsubscribe: Map<string, VoidCallback>;
|
17
18
|
|
18
19
|
constructor(app: Application, projectName: string, projectConfig?: IProjectConfig | undefined) {
|
19
|
-
super(app)
|
20
|
-
this.project = getProject(projectName, projectConfig)
|
21
|
-
this.sheets = new Map()
|
22
|
-
this.sheetObjects = new Map()
|
23
|
-
this.sheetObjectCBs = new Map()
|
24
|
-
this.sheetObjectUnsubscribe = new Map()
|
20
|
+
super(app);
|
21
|
+
this.project = getProject(projectName, projectConfig);
|
22
|
+
this.sheets = new Map();
|
23
|
+
this.sheetObjects = new Map();
|
24
|
+
this.sheetObjectCBs = new Map();
|
25
|
+
this.sheetObjectUnsubscribe = new Map();
|
25
26
|
}
|
26
27
|
|
27
28
|
override dispose(): void {
|
28
|
-
this.project = undefined
|
29
|
-
this.sheets = new Map()
|
30
|
-
this.sheetObjects = new Map()
|
31
|
-
this.sheetObjectCBs = new Map()
|
32
|
-
this.sheetObjectUnsubscribe = new Map()
|
29
|
+
this.project = undefined;
|
30
|
+
this.sheets = new Map();
|
31
|
+
this.sheetObjects = new Map();
|
32
|
+
this.sheetObjectCBs = new Map();
|
33
|
+
this.sheetObjectUnsubscribe = new Map();
|
33
34
|
}
|
34
35
|
|
35
36
|
sheet(name: string): ISheet | undefined {
|
36
37
|
if (this.project === undefined) {
|
37
|
-
console.error('Theatre Project hasn\'t been created yet.')
|
38
|
-
return undefined
|
38
|
+
console.error('Theatre Project hasn\'t been created yet.');
|
39
|
+
return undefined;
|
39
40
|
}
|
40
41
|
|
41
|
-
let sheet = this.sheets.get(name)
|
42
|
-
if (sheet !== undefined) return sheet
|
42
|
+
let sheet = this.sheets.get(name);
|
43
|
+
if (sheet !== undefined) return sheet;
|
43
44
|
|
44
|
-
sheet = this.project?.sheet(name)
|
45
|
-
this.sheets.set(name, sheet)
|
46
|
-
return sheet
|
45
|
+
sheet = this.project?.sheet(name);
|
46
|
+
this.sheets.set(name, sheet);
|
47
|
+
return sheet;
|
47
48
|
}
|
48
49
|
|
49
50
|
sheetObject(
|
@@ -53,27 +54,27 @@ export default class RemoteTheatre extends BaseRemote {
|
|
53
54
|
onUpdate?: DataUpdateCallback,
|
54
55
|
): ISheetObject | undefined {
|
55
56
|
if (this.project === undefined) {
|
56
|
-
console.error('Theatre Project hasn\'t been created yet.')
|
57
|
-
return undefined
|
57
|
+
console.error('Theatre Project hasn\'t been created yet.');
|
58
|
+
return undefined;
|
58
59
|
}
|
59
|
-
const sheet = this.sheets.get(sheetName)
|
60
|
-
if (sheet === undefined) return undefined
|
60
|
+
const sheet = this.sheets.get(sheetName);
|
61
|
+
if (sheet === undefined) return undefined;
|
61
62
|
|
62
|
-
const objName = `${sheetName}_${key}
|
63
|
-
let obj = this.sheetObjects.get(objName)
|
63
|
+
const objName = `${sheetName}_${key}`;
|
64
|
+
let obj = this.sheetObjects.get(objName);
|
64
65
|
if (obj !== undefined) {
|
65
|
-
obj = sheet.object(key, {...props, ...obj.value}, {reconfigure: true})
|
66
|
-
return obj
|
66
|
+
obj = sheet.object(key, {...props, ...obj.value}, {reconfigure: true});
|
67
|
+
return obj;
|
67
68
|
}
|
68
69
|
|
69
|
-
obj = sheet.object(key, props)
|
70
|
-
this.sheetObjects.set(objName, obj)
|
71
|
-
this.sheetObjectCBs.set(objName, onUpdate !== undefined ? onUpdate : noop)
|
70
|
+
obj = sheet.object(key, props);
|
71
|
+
this.sheetObjects.set(objName, obj);
|
72
|
+
this.sheetObjectCBs.set(objName, onUpdate !== undefined ? onUpdate : noop);
|
72
73
|
|
73
74
|
const unsubscribe = obj.onValuesChange((values: any) => {
|
74
75
|
if (this.app.editor) {
|
75
76
|
for (const i in values) {
|
76
|
-
const value = values[i]
|
77
|
+
const value = values[i];
|
77
78
|
if (typeof value === 'object') {
|
78
79
|
if (isColor(value)) {
|
79
80
|
values[i] = {
|
@@ -81,37 +82,38 @@ export default class RemoteTheatre extends BaseRemote {
|
|
81
82
|
g: value.g,
|
82
83
|
b: value.b,
|
83
84
|
a: value.a,
|
84
|
-
}
|
85
|
+
};
|
85
86
|
}
|
86
87
|
}
|
87
88
|
}
|
88
89
|
this.app.send({
|
89
90
|
event: 'updateSheetObject',
|
91
|
+
target: 'app',
|
90
92
|
data: {
|
91
93
|
sheetObject: objName,
|
92
94
|
values: values,
|
93
95
|
},
|
94
|
-
})
|
96
|
+
});
|
95
97
|
} else {
|
96
|
-
const callback = this.sheetObjectCBs.get(objName)
|
97
|
-
if (callback !== undefined) callback(values)
|
98
|
+
const callback = this.sheetObjectCBs.get(objName);
|
99
|
+
if (callback !== undefined) callback(values);
|
98
100
|
}
|
99
|
-
})
|
100
|
-
this.sheetObjectUnsubscribe.set(objName, unsubscribe)
|
101
|
+
});
|
102
|
+
this.sheetObjectUnsubscribe.set(objName, unsubscribe);
|
101
103
|
|
102
|
-
return obj
|
104
|
+
return obj;
|
103
105
|
}
|
104
106
|
|
105
107
|
unsubscribe(sheet: ISheetObject) {
|
106
108
|
if (this.project === undefined) {
|
107
|
-
console.error('Theatre Project hasn\'t been created yet.')
|
108
|
-
return undefined
|
109
|
+
console.error('Theatre Project hasn\'t been created yet.');
|
110
|
+
return undefined;
|
109
111
|
}
|
110
112
|
|
111
|
-
const id = `${sheet.address.sheetId}_${sheet.address.objectKey}
|
112
|
-
const unsubscribe = this.sheetObjectUnsubscribe.get(id)
|
113
|
+
const id = `${sheet.address.sheetId}_${sheet.address.objectKey}`;
|
114
|
+
const unsubscribe = this.sheetObjectUnsubscribe.get(id);
|
113
115
|
if (unsubscribe !== undefined) {
|
114
|
-
unsubscribe()
|
116
|
+
unsubscribe();
|
115
117
|
}
|
116
118
|
}
|
117
119
|
}
|
@@ -0,0 +1,77 @@
|
|
1
|
+
import { Scene } from 'three';
|
2
|
+
import BaseRemote from './BaseRemote';
|
3
|
+
import { stripObject, stripScene } from '@/editor/sceneHierarchy/utils';
|
4
|
+
|
5
|
+
export default class RemoteThree extends BaseRemote {
|
6
|
+
scene?: Scene = undefined;
|
7
|
+
|
8
|
+
getObject(uuid: string) {
|
9
|
+
this.app.send({
|
10
|
+
event: 'getObject',
|
11
|
+
target: 'app',
|
12
|
+
data: uuid,
|
13
|
+
});
|
14
|
+
}
|
15
|
+
|
16
|
+
setObject(value: any) {
|
17
|
+
const stripped = stripObject(value);
|
18
|
+
this.app.send({
|
19
|
+
event: 'setObject',
|
20
|
+
target: 'editor',
|
21
|
+
data: stripped,
|
22
|
+
});
|
23
|
+
}
|
24
|
+
|
25
|
+
requestMethod(uuid: string, key: string, value?: any) {
|
26
|
+
this.app.send({
|
27
|
+
event: 'requestMethod',
|
28
|
+
target: 'app',
|
29
|
+
data: {
|
30
|
+
uuid,
|
31
|
+
key,
|
32
|
+
value
|
33
|
+
},
|
34
|
+
});
|
35
|
+
}
|
36
|
+
|
37
|
+
updateObject(uuid: string, key: string, value: any) {
|
38
|
+
this.app.send({
|
39
|
+
event: 'updateObject',
|
40
|
+
target: 'app',
|
41
|
+
data: {
|
42
|
+
uuid,
|
43
|
+
key,
|
44
|
+
value
|
45
|
+
},
|
46
|
+
});
|
47
|
+
}
|
48
|
+
|
49
|
+
createTexture(uuid: string, key: string, value: any) {
|
50
|
+
this.app.send({
|
51
|
+
event: 'createTexture',
|
52
|
+
target: 'app',
|
53
|
+
data: {
|
54
|
+
uuid,
|
55
|
+
key,
|
56
|
+
value
|
57
|
+
},
|
58
|
+
});
|
59
|
+
}
|
60
|
+
|
61
|
+
getScene() {
|
62
|
+
this.app.send({
|
63
|
+
event: 'getScene',
|
64
|
+
target: 'app',
|
65
|
+
});
|
66
|
+
}
|
67
|
+
|
68
|
+
setScene(value: Scene) {
|
69
|
+
this.scene = value;
|
70
|
+
const stripped = stripScene(value);
|
71
|
+
this.app.send({
|
72
|
+
event: 'setScene',
|
73
|
+
target: 'editor',
|
74
|
+
data: stripped,
|
75
|
+
});
|
76
|
+
}
|
77
|
+
}
|