@tomorrowevening/hermes 0.0.0
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/LICENSE +674 -0
- package/README.md +10 -0
- package/dist/hermes.js +1202 -0
- package/dist/hermes.umd.cjs +29 -0
- package/dist/images/debug/icon_camera.png +0 -0
- package/dist/images/debug/icon_folder.png +0 -0
- package/dist/images/debug/icon_interactive.png +0 -0
- package/dist/images/debug/icon_lights.png +0 -0
- package/dist/images/debug/icon_refresh.png +0 -0
- package/dist/images/debug/icon_ui.png +0 -0
- package/dist/images/debug/icon_utils.png +0 -0
- package/dist/images/debug/icon_world.png +0 -0
- package/dist/style.css +1 -0
- package/package.json +63 -0
- package/src/core/Application.ts +69 -0
- package/src/core/RemoteController.ts +135 -0
- package/src/core/remote/BaseRemote.ts +16 -0
- package/src/core/remote/RemoteComponents.ts +32 -0
- package/src/core/remote/RemoteTheatre.ts +117 -0
- package/src/core/remote/RemoteTweakpane.ts +176 -0
- package/src/core/types.ts +43 -0
- package/src/editor/Editor.tsx +15 -0
- package/src/editor/components/Draggable.tsx +40 -0
- package/src/editor/components/DraggableItem.tsx +22 -0
- package/src/editor/components/Dropdown.tsx +30 -0
- package/src/editor/components/DropdownItem.tsx +64 -0
- package/src/editor/components/NavButton.tsx +11 -0
- package/src/editor/components/icons/CloseIcon.tsx +7 -0
- package/src/editor/components/icons/DragIcon.tsx +9 -0
- package/src/editor/components/types.ts +41 -0
- package/src/editor/global.ts +13 -0
- package/src/editor/sceneHierarchy/ChildObject.tsx +56 -0
- package/src/editor/sceneHierarchy/ContainerObject.tsx +12 -0
- package/src/editor/sceneHierarchy/SceneHierarchy.tsx +77 -0
- package/src/editor/sceneHierarchy/types.ts +10 -0
- package/src/editor/sceneHierarchy/utils.ts +25 -0
- package/src/editor/scss/_debug.scss +68 -0
- package/src/editor/scss/_draggable.scss +43 -0
- package/src/editor/scss/_dropdown.scss +83 -0
- package/src/editor/scss/_sceneHierarchy.scss +170 -0
- package/src/editor/scss/_theme.scss +9 -0
- package/src/editor/scss/index.scss +58 -0
- package/src/editor/utils.ts +20 -0
- package/src/example/App.css +6 -0
- package/src/example/App.tsx +88 -0
- package/src/example/constants.ts +13 -0
- package/src/example/index.scss +37 -0
- package/src/example/main.tsx +75 -0
- package/src/library.ts +16 -0
- package/src/vite-env.d.ts +1 -0
- package/types/core/Application.d.ts +21 -0
- package/types/core/RemoteController.d.ts +2 -0
- package/types/core/remote/BaseRemote.d.ts +6 -0
- package/types/core/remote/RemoteComponents.d.ts +7 -0
- package/types/core/remote/RemoteDebug.d.ts +23 -0
- package/types/core/remote/RemoteTheatre.d.ts +16 -0
- package/types/core/remote/RemoteTweakpane.d.ts +23 -0
- package/types/core/types.d.ts +13 -0
- package/types/debug/Editor.d.ts +8 -0
- package/types/debug/components/Draggable.d.ts +2 -0
- package/types/debug/components/DraggableItem.d.ts +2 -0
- package/types/debug/components/Dropdown.d.ts +2 -0
- package/types/debug/components/DropdownItem.d.ts +2 -0
- package/types/debug/components/NavButton.d.ts +5 -0
- package/types/debug/components/icons/CloseIcon.d.ts +2 -0
- package/types/debug/components/icons/DragIcon.d.ts +2 -0
- package/types/debug/components/types.d.ts +31 -0
- package/types/debug/global.d.ts +9 -0
- package/types/debug/sceneHierarchy/ChildObject.d.ts +2 -0
- package/types/debug/sceneHierarchy/ContainerObject.d.ts +2 -0
- package/types/debug/sceneHierarchy/SceneHierarchy.d.ts +13 -0
- package/types/debug/sceneHierarchy/types.d.ts +8 -0
- package/types/debug/sceneHierarchy/utils.d.ts +2 -0
- package/types/debug/utils.d.ts +4 -0
- package/types/editor/Editor.d.ts +8 -0
- package/types/editor/components/Draggable.d.ts +2 -0
- package/types/editor/components/DraggableItem.d.ts +2 -0
- package/types/editor/components/Dropdown.d.ts +2 -0
- package/types/editor/components/DropdownItem.d.ts +2 -0
- package/types/editor/components/NavButton.d.ts +5 -0
- package/types/editor/components/icons/CloseIcon.d.ts +2 -0
- package/types/editor/components/icons/DragIcon.d.ts +2 -0
- package/types/editor/components/types.d.ts +31 -0
- package/types/editor/global.d.ts +9 -0
- package/types/editor/sceneHierarchy/ChildObject.d.ts +2 -0
- package/types/editor/sceneHierarchy/ContainerObject.d.ts +2 -0
- package/types/editor/sceneHierarchy/SceneHierarchy.d.ts +13 -0
- package/types/editor/sceneHierarchy/types.d.ts +8 -0
- package/types/editor/sceneHierarchy/utils.d.ts +2 -0
- package/types/editor/utils.d.ts +4 -0
- package/types/example/App.d.ts +3 -0
- package/types/example/constants.d.ts +3 -0
- package/types/example/main.d.ts +1 -0
- package/types/library.d.ts +14 -0
@@ -0,0 +1,68 @@
|
|
1
|
+
$maxInput: 160px;
|
2
|
+
|
3
|
+
body {
|
4
|
+
|
5
|
+
.tp-dfwv,
|
6
|
+
.tp-dfwv button,
|
7
|
+
.tp-dfwv input {
|
8
|
+
text-transform: none;
|
9
|
+
}
|
10
|
+
}
|
11
|
+
|
12
|
+
.tp-ckbv {
|
13
|
+
float: right;
|
14
|
+
}
|
15
|
+
|
16
|
+
.tp-dfwv {
|
17
|
+
.tp-lblv {
|
18
|
+
position: relative;
|
19
|
+
}
|
20
|
+
|
21
|
+
.tp-lblv_v {
|
22
|
+
display: inline-block;
|
23
|
+
max-width: $maxInput;
|
24
|
+
|
25
|
+
.tp-ckbv {
|
26
|
+
width: 20px;
|
27
|
+
}
|
28
|
+
|
29
|
+
.tp-txtv,
|
30
|
+
.tp-sldtxtv {
|
31
|
+
max-width: $maxInput;
|
32
|
+
}
|
33
|
+
|
34
|
+
.tp-lstv {
|
35
|
+
width: $maxInput;
|
36
|
+
}
|
37
|
+
|
38
|
+
.tp-fpsv {
|
39
|
+
width: 280px;
|
40
|
+
}
|
41
|
+
}
|
42
|
+
|
43
|
+
.tp-lblv-nol {
|
44
|
+
.tp-btnv {
|
45
|
+
width: 280px;
|
46
|
+
}
|
47
|
+
}
|
48
|
+
|
49
|
+
.tp-btnv_b {
|
50
|
+
padding: 0 5px;
|
51
|
+
}
|
52
|
+
|
53
|
+
.tp-btngridv {
|
54
|
+
max-height: 100px;
|
55
|
+
overflow-x: hidden;
|
56
|
+
overflow-y: auto;
|
57
|
+
}
|
58
|
+
|
59
|
+
.tp-tabv {
|
60
|
+
max-height: 90vh;
|
61
|
+
overflow: hidden auto;
|
62
|
+
}
|
63
|
+
}
|
64
|
+
|
65
|
+
.tp-dfwv {
|
66
|
+
font-family: Roboto Mono, Source Code Pro, Menlo, Courier, monospace;
|
67
|
+
font-size: 10px;
|
68
|
+
}
|
@@ -0,0 +1,43 @@
|
|
1
|
+
@use 'theme';
|
2
|
+
|
3
|
+
.draggable {
|
4
|
+
li {
|
5
|
+
div {
|
6
|
+
background-color: $BAR_COLOR;
|
7
|
+
line-height: 14px;
|
8
|
+
padding: 5px 10px;
|
9
|
+
transition: background-color 0.25s linear;
|
10
|
+
&:hover {
|
11
|
+
background-color: $BTN_HOVER;
|
12
|
+
}
|
13
|
+
span {
|
14
|
+
font-size: 12px;
|
15
|
+
margin: 0px 15px 0 10px;
|
16
|
+
padding: 0px 5px;
|
17
|
+
}
|
18
|
+
.dragIcon {
|
19
|
+
position: absolute;
|
20
|
+
left: 10px;
|
21
|
+
}
|
22
|
+
.closeIcon {
|
23
|
+
background-color: transparent;
|
24
|
+
padding: 0;
|
25
|
+
position: absolute;
|
26
|
+
right: 5px;
|
27
|
+
top: 50%;
|
28
|
+
min-width: 14px;
|
29
|
+
width: 14px;
|
30
|
+
height: 14px;
|
31
|
+
transform: translateY(-50%);
|
32
|
+
&:hover {
|
33
|
+
background-color: transparent;
|
34
|
+
}
|
35
|
+
svg {
|
36
|
+
background-color: transparent;
|
37
|
+
left: 0px;
|
38
|
+
position: relative;
|
39
|
+
}
|
40
|
+
}
|
41
|
+
}
|
42
|
+
}
|
43
|
+
}
|
@@ -0,0 +1,83 @@
|
|
1
|
+
@use 'theme';
|
2
|
+
|
3
|
+
.dropdown {
|
4
|
+
color: #FFF;
|
5
|
+
display: inline-block;
|
6
|
+
margin-right: 1px;
|
7
|
+
text-align: left;
|
8
|
+
height: fit-content;
|
9
|
+
min-width: auto;
|
10
|
+
width: max-content;
|
11
|
+
|
12
|
+
button {
|
13
|
+
backdrop-filter: blur(2px);
|
14
|
+
background-color: $BAR_COLOR;
|
15
|
+
color: rgba($color: #FFF, $alpha: 0.5);
|
16
|
+
font-size: 12px;
|
17
|
+
padding: 5px 10px;
|
18
|
+
position: relative;
|
19
|
+
text-align: left;
|
20
|
+
min-width: $ROW_HEIGHT;
|
21
|
+
width: 100%;
|
22
|
+
height: $BTN_SIZE;
|
23
|
+
transition: all 0.2s linear;
|
24
|
+
|
25
|
+
&:hover {
|
26
|
+
background-color: $BTN_HOVER;
|
27
|
+
color: #FFF;
|
28
|
+
}
|
29
|
+
|
30
|
+
&.svg {
|
31
|
+
line-height: 0;
|
32
|
+
width: $BTN_SIZE;
|
33
|
+
}
|
34
|
+
}
|
35
|
+
|
36
|
+
p {
|
37
|
+
background-color: $BAR_COLOR;
|
38
|
+
display: inline-block;
|
39
|
+
height: $ROW_HEIGHT;
|
40
|
+
margin: 0;
|
41
|
+
min-width: $ROW_HEIGHT;
|
42
|
+
padding: 5px;
|
43
|
+
}
|
44
|
+
|
45
|
+
svg {
|
46
|
+
position: relative;
|
47
|
+
left: 50%;
|
48
|
+
transform: translate(-50%, 0);
|
49
|
+
}
|
50
|
+
|
51
|
+
ul {
|
52
|
+
list-style: none;
|
53
|
+
margin: 0;
|
54
|
+
margin-block: 0;
|
55
|
+
padding-inline: 0;
|
56
|
+
position: absolute;
|
57
|
+
width: max-content;
|
58
|
+
|
59
|
+
li {
|
60
|
+
border-top: 1px solid $BORDER_COLOR;
|
61
|
+
display: block;
|
62
|
+
position: relative;
|
63
|
+
|
64
|
+
&.selected button {
|
65
|
+
background-color: $BTN_SELECTED;
|
66
|
+
|
67
|
+
&:hover {
|
68
|
+
background-color: $BTN_SELECTED_HOVER;
|
69
|
+
}
|
70
|
+
}
|
71
|
+
}
|
72
|
+
}
|
73
|
+
|
74
|
+
&.subdropdown {
|
75
|
+
min-width: 100%;
|
76
|
+
|
77
|
+
ul {
|
78
|
+
border-left: 1px solid $BORDER_COLOR;
|
79
|
+
left: 100%;
|
80
|
+
top: -1px;
|
81
|
+
}
|
82
|
+
}
|
83
|
+
}
|
@@ -0,0 +1,170 @@
|
|
1
|
+
$barHeight: 20px;
|
2
|
+
$maxHeight: calc($barHeight * 10);
|
3
|
+
|
4
|
+
#SceneHierarchy {
|
5
|
+
background-color: #0d0d0d;
|
6
|
+
border-radius: 2px;
|
7
|
+
bottom: 0;
|
8
|
+
right: 0;
|
9
|
+
font-family: Roboto Mono, Source Code Pro, Menlo, Courier, monospace;
|
10
|
+
font-size: 10px;
|
11
|
+
min-height: $barHeight;
|
12
|
+
overflow: hidden;
|
13
|
+
pointer-events: visible;
|
14
|
+
position: absolute;
|
15
|
+
width: 250px;
|
16
|
+
z-index: 100;
|
17
|
+
|
18
|
+
button {
|
19
|
+
background-color: transparent;
|
20
|
+
border: none;
|
21
|
+
color: #FFF;
|
22
|
+
font-size: 12px;
|
23
|
+
margin: 0;
|
24
|
+
padding: 0;
|
25
|
+
text-align: left;
|
26
|
+
}
|
27
|
+
|
28
|
+
.header {
|
29
|
+
height: $barHeight;
|
30
|
+
position: relative;
|
31
|
+
|
32
|
+
span {
|
33
|
+
display: inline-block;
|
34
|
+
font-size: 12px;
|
35
|
+
line-height: $barHeight;
|
36
|
+
padding-left: 20px;
|
37
|
+
pointer-events: none;
|
38
|
+
}
|
39
|
+
|
40
|
+
button {
|
41
|
+
position: absolute;
|
42
|
+
right: 5px;
|
43
|
+
top: 50%;
|
44
|
+
width: $barHeight;
|
45
|
+
height: $barHeight;
|
46
|
+
}
|
47
|
+
|
48
|
+
.refresh {
|
49
|
+
background-color: transparent;
|
50
|
+
background-image: url("/images/debug/icon_refresh.png");
|
51
|
+
background-size: 20px 20px;
|
52
|
+
opacity: 0.7;
|
53
|
+
transform: translateY(-50%) scale(0.8);
|
54
|
+
|
55
|
+
&:hover {
|
56
|
+
opacity: 1;
|
57
|
+
}
|
58
|
+
}
|
59
|
+
|
60
|
+
.status {
|
61
|
+
left: 0;
|
62
|
+
transform: translateY(-50%) scale(0.8);
|
63
|
+
}
|
64
|
+
}
|
65
|
+
|
66
|
+
.status {
|
67
|
+
background-image: url("/images/debug/icon_folder.png");
|
68
|
+
background-position-x: 2px;
|
69
|
+
background-position-y: 2px;
|
70
|
+
background-size: 32px 16px;
|
71
|
+
transform: scale(0.8);
|
72
|
+
width: $barHeight;
|
73
|
+
height: $barHeight;
|
74
|
+
}
|
75
|
+
|
76
|
+
.childObject {
|
77
|
+
background-color: #111;
|
78
|
+
min-height: $barHeight;
|
79
|
+
overflow: hidden;
|
80
|
+
|
81
|
+
::-webkit-scrollbar {
|
82
|
+
width: 10px;
|
83
|
+
}
|
84
|
+
|
85
|
+
::-webkit-scrollbar-track {
|
86
|
+
background: #0d0d0d;
|
87
|
+
}
|
88
|
+
|
89
|
+
::-webkit-scrollbar-thumb {
|
90
|
+
background: #666;
|
91
|
+
}
|
92
|
+
|
93
|
+
::-webkit-scrollbar-thumb:hover {
|
94
|
+
background: #999;
|
95
|
+
}
|
96
|
+
|
97
|
+
.child {
|
98
|
+
background-color: #222;
|
99
|
+
border: none;
|
100
|
+
border-bottom: 1px solid #111;
|
101
|
+
height: $barHeight;
|
102
|
+
position: relative;
|
103
|
+
|
104
|
+
&:hover {
|
105
|
+
background-color: #333;
|
106
|
+
}
|
107
|
+
}
|
108
|
+
|
109
|
+
.name {
|
110
|
+
background-color: transparent;
|
111
|
+
max-lines: 1;
|
112
|
+
position: absolute;
|
113
|
+
left: 5px;
|
114
|
+
right: 0;
|
115
|
+
top: 50%;
|
116
|
+
transform: translateY(-50%);
|
117
|
+
white-space: nowrap;
|
118
|
+
}
|
119
|
+
|
120
|
+
.container {
|
121
|
+
padding-left: 5px;
|
122
|
+
height: auto;
|
123
|
+
overflow-x: hidden;
|
124
|
+
overflow-y: auto;
|
125
|
+
max-height: $maxHeight;
|
126
|
+
|
127
|
+
&.closed {
|
128
|
+
height: 0;
|
129
|
+
overflow: hidden;
|
130
|
+
}
|
131
|
+
}
|
132
|
+
|
133
|
+
.icon {
|
134
|
+
background-color: transparent;
|
135
|
+
background-image: url("/images/debug/icon_world.png");
|
136
|
+
background-size: 20px 20px;
|
137
|
+
display: inline-block;
|
138
|
+
position: absolute;
|
139
|
+
right: 5px;
|
140
|
+
top: 0;
|
141
|
+
width: $barHeight;
|
142
|
+
height: $barHeight;
|
143
|
+
transform: scale(0.8);
|
144
|
+
}
|
145
|
+
|
146
|
+
.obj3D {
|
147
|
+
background-image: url("/images/debug/icon_world.png");
|
148
|
+
}
|
149
|
+
|
150
|
+
.camera {
|
151
|
+
background-image: url("/images/debug/icon_camera.png");
|
152
|
+
}
|
153
|
+
|
154
|
+
.interactive {
|
155
|
+
background-image: url("/images/debug/icon_interactive.png");
|
156
|
+
}
|
157
|
+
|
158
|
+
.light {
|
159
|
+
background-image: url("/images/debug/icon_lights.png");
|
160
|
+
}
|
161
|
+
|
162
|
+
.ui {
|
163
|
+
background-image: url("/images/debug/icon_ui.png");
|
164
|
+
}
|
165
|
+
|
166
|
+
.utils {
|
167
|
+
background-image: url("/images/debug/icon_utils.png");
|
168
|
+
}
|
169
|
+
}
|
170
|
+
}
|
@@ -0,0 +1,9 @@
|
|
1
|
+
$ROW_HEIGHT: 22px;
|
2
|
+
$BAR_COLOR: rgba(34, 34, 34, 0.8);
|
3
|
+
$BORDER_COLOR: rgba(17, 17, 17, 0.9);
|
4
|
+
$BTN_SIZE: 32px;
|
5
|
+
$BTN_HOVER: rgba(51, 51, 51, 0.8);
|
6
|
+
$BTN_SELECTED: rgba(68, 68, 68, 0.8);
|
7
|
+
$BTN_SELECTED_HOVER: rgba(85, 85, 85, 0.8);
|
8
|
+
$PANEL: rgba(25, 25, 25, 0.8);
|
9
|
+
$PANEL_DARK: rgba(17, 17, 17, 0.8);
|
@@ -0,0 +1,58 @@
|
|
1
|
+
@import 'theme';
|
2
|
+
@import 'debug';
|
3
|
+
@import 'sceneHierarchy';
|
4
|
+
|
5
|
+
.editor {
|
6
|
+
font-family: 'Helvetica', 'Arial', sans-serif;
|
7
|
+
pointer-events: none;
|
8
|
+
position: absolute;
|
9
|
+
width: 100%;
|
10
|
+
height: 100%;
|
11
|
+
z-index: 101;
|
12
|
+
|
13
|
+
button {
|
14
|
+
background: none;
|
15
|
+
border: none;
|
16
|
+
color: white;
|
17
|
+
display: inline-block;
|
18
|
+
margin: 0;
|
19
|
+
padding: 0;
|
20
|
+
text-align: left;
|
21
|
+
}
|
22
|
+
|
23
|
+
.navBar {
|
24
|
+
display: inline-block;
|
25
|
+
pointer-events: visible;
|
26
|
+
position: relative;
|
27
|
+
left: 50px;
|
28
|
+
top: 12px;
|
29
|
+
}
|
30
|
+
|
31
|
+
@import 'dropdown';
|
32
|
+
@import 'draggable';
|
33
|
+
}
|
34
|
+
|
35
|
+
.fsAbsolute {
|
36
|
+
position: absolute;
|
37
|
+
left: 0;
|
38
|
+
right: 0;
|
39
|
+
top: 0;
|
40
|
+
bottom: 0;
|
41
|
+
}
|
42
|
+
|
43
|
+
.absoluteCenter {
|
44
|
+
position: absolute;
|
45
|
+
left: 50%;
|
46
|
+
top: 50%;
|
47
|
+
transform: translate(-50%, -50%);
|
48
|
+
}
|
49
|
+
|
50
|
+
.hidden {
|
51
|
+
display: none;
|
52
|
+
visibility: hidden;
|
53
|
+
}
|
54
|
+
|
55
|
+
.hideText {
|
56
|
+
text-indent: -9999px;
|
57
|
+
white-space: nowrap;
|
58
|
+
}
|
@@ -0,0 +1,20 @@
|
|
1
|
+
export function clamp(min: number, max: number, value: number) {
|
2
|
+
return Math.min(max, Math.max(min, value))
|
3
|
+
}
|
4
|
+
|
5
|
+
export function distance(x: number, y: number): number {
|
6
|
+
const d = x - y
|
7
|
+
return Math.sqrt(d * d)
|
8
|
+
}
|
9
|
+
|
10
|
+
export function randomID(): string {
|
11
|
+
return Math.round(Math.random() * 1000000).toString()
|
12
|
+
}
|
13
|
+
|
14
|
+
export function isColor(obj: any) {
|
15
|
+
return (
|
16
|
+
obj.r !== undefined &&
|
17
|
+
obj.g !== undefined &&
|
18
|
+
obj.b !== undefined
|
19
|
+
)
|
20
|
+
}
|
@@ -0,0 +1,88 @@
|
|
1
|
+
// Libs
|
2
|
+
import { CSSProperties, useEffect, useRef } from 'react'
|
3
|
+
import { types } from '@theatre/core'
|
4
|
+
// Models
|
5
|
+
import { app } from './constants'
|
6
|
+
// Components
|
7
|
+
import './App.css'
|
8
|
+
import { debugDispatcher, ToolEvents } from '../editor/global'
|
9
|
+
|
10
|
+
const elementStyle: CSSProperties = {
|
11
|
+
background: '#FF0000',
|
12
|
+
width: '100px',
|
13
|
+
height: '100px',
|
14
|
+
position: 'absolute',
|
15
|
+
}
|
16
|
+
|
17
|
+
function App() {
|
18
|
+
const elementRef = useRef<HTMLDivElement>(null!)
|
19
|
+
app.theatre?.sheet('App')
|
20
|
+
|
21
|
+
useEffect(() => {
|
22
|
+
const container = elementRef.current!
|
23
|
+
container.style.visibility = app.editor ? 'hidden' : 'inherit'
|
24
|
+
|
25
|
+
// GUI Example
|
26
|
+
const testFolder = app.debug?.addFolder('Test')
|
27
|
+
|
28
|
+
app.debug?.button('Test Button', () => {
|
29
|
+
console.log('Test button works!')
|
30
|
+
}, testFolder)
|
31
|
+
|
32
|
+
const test = { opacity: 1, rotation: 0 }
|
33
|
+
app.debug?.bind(test, 'opacity', {
|
34
|
+
min: 0,
|
35
|
+
max: 1,
|
36
|
+
onChange: (value: number) => {
|
37
|
+
container.style.opacity = value.toFixed(2)
|
38
|
+
}
|
39
|
+
}, testFolder)
|
40
|
+
|
41
|
+
app.debug?.bind(test, 'rotation', {
|
42
|
+
min: 0,
|
43
|
+
max: 360,
|
44
|
+
onChange: (value: number) => {
|
45
|
+
container.style.transform = `rotate(${value}deg)`
|
46
|
+
}
|
47
|
+
}, testFolder)
|
48
|
+
|
49
|
+
// Theatre Example
|
50
|
+
const sheetObj = app.theatre?.sheetObject(
|
51
|
+
'App',
|
52
|
+
'Box',
|
53
|
+
{
|
54
|
+
x: types.number(100, {range: [0, window.innerWidth]}),
|
55
|
+
y: types.number(100, {range: [0, window.innerHeight]}),
|
56
|
+
},
|
57
|
+
(values: any) => {
|
58
|
+
container.style.left = `${values.x}px`
|
59
|
+
container.style.top = `${values.y}px`
|
60
|
+
},
|
61
|
+
)
|
62
|
+
return () => {
|
63
|
+
if (sheetObj !== undefined) app.theatre?.unsubscribe(sheetObj)
|
64
|
+
app.dispose()
|
65
|
+
}
|
66
|
+
}, [])
|
67
|
+
|
68
|
+
useEffect(() => {
|
69
|
+
const selectDropdown = (evt: any) => {
|
70
|
+
console.log(`Dropdown: ${evt.value.dropdown}, value: ${evt.value.value}`)
|
71
|
+
}
|
72
|
+
const draglistUpdate = (evt: any) => {
|
73
|
+
console.log(`Dragged list updated: ${evt.value.dropdown}, value: ${evt.value.value.join(', ')}`)
|
74
|
+
}
|
75
|
+
debugDispatcher.addEventListener(ToolEvents.SELECT_DROPDOWN, selectDropdown)
|
76
|
+
debugDispatcher.addEventListener(ToolEvents.DRAG_UPDATE, draglistUpdate)
|
77
|
+
return () => {
|
78
|
+
debugDispatcher.removeEventListener(ToolEvents.SELECT_DROPDOWN, selectDropdown)
|
79
|
+
debugDispatcher.removeEventListener(ToolEvents.DRAG_UPDATE, draglistUpdate)
|
80
|
+
}
|
81
|
+
}, [])
|
82
|
+
|
83
|
+
return (
|
84
|
+
<div id='box' ref={elementRef} />
|
85
|
+
)
|
86
|
+
}
|
87
|
+
|
88
|
+
export default App
|
@@ -0,0 +1,13 @@
|
|
1
|
+
import Application from '../core/Application'
|
2
|
+
|
3
|
+
export const IS_DEV = import.meta.env.DEV
|
4
|
+
export const app = new Application(IS_DEV, 'editor')
|
5
|
+
|
6
|
+
// Initiation, etc should happen once the app gets loaded..
|
7
|
+
// TODO Pass in loaded JSON
|
8
|
+
app.setupTheatre('RemoteApp')
|
9
|
+
|
10
|
+
if (IS_DEV) {
|
11
|
+
app.setupComponents()
|
12
|
+
app.setupGUI()
|
13
|
+
}
|
@@ -0,0 +1,37 @@
|
|
1
|
+
:root {
|
2
|
+
font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;
|
3
|
+
line-height: 1.5;
|
4
|
+
font-weight: 400;
|
5
|
+
|
6
|
+
color-scheme: light dark;
|
7
|
+
color: rgba(255, 255, 255, 0.87);
|
8
|
+
background-color: #242424;
|
9
|
+
|
10
|
+
font-synthesis: none;
|
11
|
+
text-rendering: optimizeLegibility;
|
12
|
+
-webkit-font-smoothing: antialiased;
|
13
|
+
-moz-osx-font-smoothing: grayscale;
|
14
|
+
-webkit-text-size-adjust: 100%;
|
15
|
+
}
|
16
|
+
|
17
|
+
html, body {
|
18
|
+
min-width: 100%;
|
19
|
+
min-height: 100%;
|
20
|
+
width: 100%;
|
21
|
+
height: 100%;
|
22
|
+
}
|
23
|
+
|
24
|
+
body {
|
25
|
+
padding: 0;
|
26
|
+
margin: 0;
|
27
|
+
}
|
28
|
+
|
29
|
+
button {
|
30
|
+
&:focus {
|
31
|
+
outline: none;
|
32
|
+
}
|
33
|
+
|
34
|
+
&:hover {
|
35
|
+
cursor: pointer;
|
36
|
+
}
|
37
|
+
}
|
@@ -0,0 +1,75 @@
|
|
1
|
+
// Libs
|
2
|
+
import React from 'react'
|
3
|
+
import ReactDOM from 'react-dom/client'
|
4
|
+
import studio from '@theatre/studio'
|
5
|
+
// Models
|
6
|
+
import { app, IS_DEV } from './constants'
|
7
|
+
// Components
|
8
|
+
import './index.scss'
|
9
|
+
import App from './App'
|
10
|
+
import Editor from '../editor/Editor'
|
11
|
+
import Draggable from '../editor/components/Draggable'
|
12
|
+
import Dropdown from '../editor/components/Dropdown'
|
13
|
+
// Tools
|
14
|
+
import RemoteController from '../core/RemoteController'
|
15
|
+
import SceneHierarchy from '../editor/sceneHierarchy/SceneHierarchy'
|
16
|
+
|
17
|
+
// Debug tools
|
18
|
+
if (IS_DEV) {
|
19
|
+
studio.initialize()
|
20
|
+
RemoteController(app)
|
21
|
+
}
|
22
|
+
|
23
|
+
//
|
24
|
+
|
25
|
+
ReactDOM.createRoot(document.getElementById('root')!).render(
|
26
|
+
<>
|
27
|
+
{IS_DEV ? (
|
28
|
+
<>
|
29
|
+
<App />
|
30
|
+
{app.editor ? (
|
31
|
+
<Editor components={[
|
32
|
+
<SceneHierarchy key="SceneHierarchy" />
|
33
|
+
]}>
|
34
|
+
<Dropdown
|
35
|
+
title="Scenes"
|
36
|
+
options={[
|
37
|
+
{
|
38
|
+
type: 'option',
|
39
|
+
title: 'Option 1',
|
40
|
+
value: 'opt1',
|
41
|
+
},
|
42
|
+
{
|
43
|
+
type: 'option',
|
44
|
+
title: 'Option 2',
|
45
|
+
value: 'opt2',
|
46
|
+
},
|
47
|
+
]}
|
48
|
+
onSelect={(value: string) => {
|
49
|
+
app.components?.selectDropdown('Scenes', value)
|
50
|
+
}}
|
51
|
+
/>
|
52
|
+
|
53
|
+
<Draggable
|
54
|
+
title="Draggable Items"
|
55
|
+
options={[
|
56
|
+
'Item A',
|
57
|
+
'Item B',
|
58
|
+
'Item C',
|
59
|
+
'Item D',
|
60
|
+
'Item E',
|
61
|
+
]}
|
62
|
+
onDragComplete={(options: string[]) => {
|
63
|
+
app.components?.updateDropdown('Draggable Items', options)
|
64
|
+
}}
|
65
|
+
/>
|
66
|
+
</Editor>
|
67
|
+
) : null}
|
68
|
+
</>
|
69
|
+
) : (
|
70
|
+
<React.StrictMode>
|
71
|
+
<App />
|
72
|
+
</React.StrictMode>
|
73
|
+
)}
|
74
|
+
</>,
|
75
|
+
)
|
package/src/library.ts
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
// Core
|
2
|
+
export { default as Application } from './core/Application'
|
3
|
+
export { debugDispatcher, ToolEvents } from './editor/global'
|
4
|
+
export { default as BaseRemote } from './core/remote/BaseRemote'
|
5
|
+
export { default as RemoteComponents } from './core/remote/RemoteComponents'
|
6
|
+
export { default as RemoteTheatre } from './core/remote/RemoteTheatre'
|
7
|
+
export { default as RemoteTweakpane } from './core/remote/RemoteTweakpane'
|
8
|
+
// Components
|
9
|
+
export { default as NavButton } from './editor/components/NavButton'
|
10
|
+
export { default as DraggableItem } from './editor/components/DraggableItem'
|
11
|
+
export { default as Draggable } from './editor/components/Draggable'
|
12
|
+
export { default as DropdownItem } from './editor/components/DropdownItem'
|
13
|
+
export { default as Dropdown } from './editor/components/Dropdown'
|
14
|
+
export { default as RemoteController } from './core/RemoteController'
|
15
|
+
export { default as SceneHierarchy } from './editor/sceneHierarchy/SceneHierarchy'
|
16
|
+
export { default as Editor } from './editor/Editor'
|
@@ -0,0 +1 @@
|
|
1
|
+
/// <reference types="vite/client" />
|