@tomorrowevening/hermes 0.0.2 → 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.
Files changed (130) hide show
  1. package/README.md +7 -0
  2. package/dist/hermes.js +2530 -718
  3. package/dist/hermes.umd.cjs +88 -11
  4. package/dist/images/android-chrome-192x192.png +0 -0
  5. package/dist/images/android-chrome-512x512.png +0 -0
  6. package/dist/images/apple-touch-icon.png +0 -0
  7. package/dist/images/favicon-16x16.png +0 -0
  8. package/dist/images/favicon-32x32.png +0 -0
  9. package/dist/images/favicon.ico +0 -0
  10. package/dist/images/milkyWay/dark-s_nx.jpg +0 -0
  11. package/dist/images/milkyWay/dark-s_ny.jpg +0 -0
  12. package/dist/images/milkyWay/dark-s_nz.jpg +0 -0
  13. package/dist/images/milkyWay/dark-s_px.jpg +0 -0
  14. package/dist/images/milkyWay/dark-s_py.jpg +0 -0
  15. package/dist/images/milkyWay/dark-s_pz.jpg +0 -0
  16. package/dist/images/site.webmanifest +1 -0
  17. package/dist/images/uv_grid_opengl.jpg +0 -0
  18. package/dist/index-0a798fe4.js +6862 -0
  19. package/dist/index-7bad599d.css +1 -0
  20. package/dist/index.html +18 -0
  21. package/dist/models/Flair.fbx +0 -0
  22. package/dist/models/Thriller2.fbx +0 -0
  23. package/dist/models/Thriller4.fbx +0 -0
  24. package/dist/style.css +1 -1
  25. package/package.json +8 -3
  26. package/src/core/Application.ts +28 -36
  27. package/src/core/RemoteController.ts +148 -98
  28. package/src/core/remote/BaseRemote.ts +3 -3
  29. package/src/core/remote/RemoteComponents.ts +5 -8
  30. package/src/core/remote/RemoteTheatre.ts +56 -54
  31. package/src/core/remote/RemoteThree.ts +77 -0
  32. package/src/core/remote/RemoteTweakpane.ts +71 -78
  33. package/src/core/types.ts +14 -4
  34. package/src/editor/Editor.tsx +8 -6
  35. package/src/editor/components/Draggable.tsx +20 -20
  36. package/src/editor/components/DraggableItem.tsx +6 -6
  37. package/src/editor/components/Dropdown.tsx +22 -14
  38. package/src/editor/components/DropdownItem.tsx +19 -19
  39. package/src/editor/components/NavButton.tsx +1 -1
  40. package/src/editor/components/content.ts +2 -0
  41. package/src/editor/components/icons/CloseIcon.tsx +1 -1
  42. package/src/editor/components/icons/DragIcon.tsx +1 -1
  43. package/src/editor/global.ts +9 -4
  44. package/src/editor/sceneHierarchy/Accordion.tsx +40 -0
  45. package/src/editor/sceneHierarchy/ChildObject.tsx +17 -17
  46. package/src/editor/sceneHierarchy/ContainerObject.tsx +7 -8
  47. package/src/editor/sceneHierarchy/SceneHierarchy.tsx +52 -49
  48. package/src/editor/sceneHierarchy/ToggleBtn.tsx +26 -0
  49. package/src/editor/sceneHierarchy/inspector/Inspector.tsx +82 -0
  50. package/src/editor/sceneHierarchy/inspector/InspectorField.tsx +178 -0
  51. package/src/editor/sceneHierarchy/inspector/InspectorGroup.tsx +55 -0
  52. package/src/editor/sceneHierarchy/inspector/MultiView/CameraWindow.tsx +61 -0
  53. package/src/editor/sceneHierarchy/inspector/MultiView/InfiniteGridHelper.ts +24 -0
  54. package/src/editor/sceneHierarchy/inspector/MultiView/InfiniteGridMaterial.ts +127 -0
  55. package/src/editor/sceneHierarchy/inspector/MultiView/MultiView.scss +93 -0
  56. package/src/editor/sceneHierarchy/inspector/MultiView/MultiView.tsx +450 -0
  57. package/src/editor/sceneHierarchy/inspector/SceneInspector.tsx +72 -0
  58. package/src/editor/sceneHierarchy/inspector/inspector.scss +150 -0
  59. package/src/editor/sceneHierarchy/inspector/utils/InspectCamera.tsx +75 -0
  60. package/src/editor/sceneHierarchy/inspector/utils/InspectLight.tsx +62 -0
  61. package/src/editor/sceneHierarchy/inspector/utils/InspectMaterial.tsx +340 -0
  62. package/src/editor/sceneHierarchy/inspector/utils/InspectTransform.tsx +124 -0
  63. package/src/editor/sceneHierarchy/types.ts +116 -5
  64. package/src/editor/sceneHierarchy/utils.ts +207 -11
  65. package/src/editor/scss/_debug.scss +9 -19
  66. package/src/editor/scss/_dropdown.scss +1 -0
  67. package/src/editor/scss/_sceneHierarchy.scss +148 -48
  68. package/src/editor/scss/index.scss +13 -6
  69. package/src/editor/utils.ts +42 -5
  70. package/src/example/CustomEditor.tsx +40 -0
  71. package/src/example/components/App.tsx +164 -0
  72. package/src/example/constants.ts +40 -9
  73. package/src/example/main.tsx +5 -45
  74. package/src/example/three/CustomMaterial.ts +58 -0
  75. package/src/example/three/ExampleScene.ts +176 -0
  76. package/src/example/three/FBXAnimation.ts +39 -0
  77. package/src/index.ts +20 -14
  78. package/types/core/Application.d.ts +7 -13
  79. package/types/core/remote/RemoteComponents.d.ts +0 -2
  80. package/types/core/remote/RemoteThree.d.ts +12 -0
  81. package/types/core/remote/RemoteTweakpane.d.ts +3 -3
  82. package/types/core/types.d.ts +4 -3
  83. package/types/editor/Editor.d.ts +2 -1
  84. package/types/editor/components/content.d.ts +2 -0
  85. package/types/editor/global.d.ts +7 -2
  86. package/types/editor/sceneHierarchy/Accordion.d.ts +10 -0
  87. package/types/editor/sceneHierarchy/SceneHierarchy.d.ts +5 -5
  88. package/types/editor/sceneHierarchy/ToggleBtn.d.ts +7 -0
  89. package/types/editor/sceneHierarchy/inspector/Inspector.d.ts +3 -0
  90. package/types/editor/sceneHierarchy/inspector/InspectorField.d.ts +13 -0
  91. package/types/editor/sceneHierarchy/inspector/InspectorGroup.d.ts +7 -0
  92. package/types/editor/sceneHierarchy/inspector/MultiView/CameraWindow.d.ts +16 -0
  93. package/types/editor/sceneHierarchy/inspector/MultiView/InfiniteGridHelper.d.ts +7 -0
  94. package/types/editor/sceneHierarchy/inspector/MultiView/InfiniteGridMaterial.d.ts +13 -0
  95. package/types/editor/sceneHierarchy/inspector/MultiView/MultiView.d.ts +11 -0
  96. package/types/editor/sceneHierarchy/inspector/SceneInspector.d.ts +7 -0
  97. package/types/editor/sceneHierarchy/inspector/utils/InspectCamera.d.ts +3 -0
  98. package/types/editor/sceneHierarchy/inspector/utils/InspectLight.d.ts +3 -0
  99. package/types/editor/sceneHierarchy/inspector/utils/InspectMaterial.d.ts +8 -0
  100. package/types/editor/sceneHierarchy/inspector/utils/InspectTransform.d.ts +3 -0
  101. package/types/editor/sceneHierarchy/types.d.ts +98 -7
  102. package/types/editor/sceneHierarchy/utils.d.ts +7 -1
  103. package/types/editor/utils.d.ts +3 -0
  104. package/types/example/CustomEditor.d.ts +1 -0
  105. package/types/example/constants.d.ts +15 -3
  106. package/types/example/three/CustomMaterial.d.ts +5 -0
  107. package/types/example/three/ExampleScene.d.ts +18 -0
  108. package/types/example/three/FBXAnimation.d.ts +6 -0
  109. package/types/index.d.ts +5 -0
  110. package/src/example/App.tsx +0 -88
  111. package/types/core/remote/RemoteDebug.d.ts +0 -23
  112. package/types/debug/Editor.d.ts +0 -8
  113. package/types/debug/components/Draggable.d.ts +0 -2
  114. package/types/debug/components/DraggableItem.d.ts +0 -2
  115. package/types/debug/components/Dropdown.d.ts +0 -2
  116. package/types/debug/components/DropdownItem.d.ts +0 -2
  117. package/types/debug/components/NavButton.d.ts +0 -5
  118. package/types/debug/components/icons/CloseIcon.d.ts +0 -2
  119. package/types/debug/components/icons/DragIcon.d.ts +0 -2
  120. package/types/debug/components/types.d.ts +0 -31
  121. package/types/debug/global.d.ts +0 -9
  122. package/types/debug/sceneHierarchy/ChildObject.d.ts +0 -2
  123. package/types/debug/sceneHierarchy/ContainerObject.d.ts +0 -2
  124. package/types/debug/sceneHierarchy/SceneHierarchy.d.ts +0 -13
  125. package/types/debug/sceneHierarchy/types.d.ts +0 -8
  126. package/types/debug/sceneHierarchy/utils.d.ts +0 -2
  127. package/types/debug/utils.d.ts +0 -4
  128. package/types/library.d.ts +0 -14
  129. /package/src/example/{App.css → components/App.css} +0 -0
  130. /package/types/example/{App.d.ts → components/App.d.ts} +0 -0
@@ -1,176 +1,169 @@
1
1
  // Libs
2
- import { Pane } from 'tweakpane'
3
- import * as EssentialsPlugin from '@tweakpane/plugin-essentials'
2
+ import { Pane } from 'tweakpane';
3
+ import * as EssentialsPlugin from '@tweakpane/plugin-essentials';
4
4
  // Core
5
- import Application from '../Application'
6
- import BaseRemote from './BaseRemote'
7
- import { noop } from '../types'
8
- import type { DataUpdateCallback, VoidCallback } from '../types'
5
+ import Application from '../Application';
6
+ import BaseRemote from './BaseRemote';
7
+ import { noop } from '../types';
8
+ import type { DataUpdateCallback, VoidCallback } from '../types';
9
9
 
10
10
  export default class RemoteTweakpane extends BaseRemote {
11
- appTab: any = undefined
12
- systemTab: any = undefined
13
- utilsTab: any = undefined
14
- bindCBs: Map<string, DataUpdateCallback>
15
- buttonCBs: Map<string, VoidCallback>
11
+ bindCBs: Map<string, DataUpdateCallback>;
12
+ buttonCBs: Map<string, VoidCallback>;
16
13
 
17
- protected pane?: Pane | undefined = undefined
18
- protected appCallbacks = 0
19
- protected editorCallbacks = 0
14
+ protected pane?: Pane | undefined = undefined;
15
+ protected appCallbacks = 0;
16
+ protected editorCallbacks = 0;
17
+ protected inspectorFolder: any = undefined;
20
18
 
21
19
  constructor(app: Application) {
22
- super(app)
23
- this.bindCBs = new Map()
24
- this.buttonCBs = new Map()
20
+ super(app);
21
+ this.bindCBs = new Map();
22
+ this.buttonCBs = new Map();
25
23
 
26
- if (app.editor) this.createGUI()
24
+ if (app.editor) this.createGUI();
27
25
  }
28
26
 
29
27
  protected createGUI() {
30
- this.pane = new Pane({ title: 'GUI' })
31
- this.pane.registerPlugin(EssentialsPlugin)
32
- const guiElement = this.pane.element.parentElement as HTMLElement
33
- guiElement.style.left = '50%'
34
- guiElement.style.top = '0'
35
- guiElement.style.maxHeight = '100%'
36
- guiElement.style.overflowX = 'hidden'
37
- guiElement.style.overflowY = 'auto'
38
- guiElement.style.transform = 'translateX(-50%)'
39
- guiElement.style.width = '300px'
40
- guiElement.style.zIndex = '100'
41
-
42
- // @ts-ignore
43
- const tabs = this.pane.addTab({
44
- pages: [{ title: 'App' }, { title: 'System' }, { title: 'Tools' }],
45
- })
46
- this.appTab = tabs.pages[0]
47
- this.systemTab = tabs.pages[1]
48
- this.utilsTab = tabs.pages[2]
28
+ this.pane = new Pane({ title: 'GUI' });
29
+ this.pane.registerPlugin(EssentialsPlugin);
49
30
  }
50
31
 
51
32
  override dispose(): void {
52
- this.bindCBs.clear()
53
- this.buttonCBs.clear()
54
- this.appCallbacks = 0
55
- this.editorCallbacks = 0
33
+ this.bindCBs.clear();
34
+ this.buttonCBs.clear();
35
+ this.appCallbacks = 0;
36
+ this.editorCallbacks = 0;
56
37
 
57
38
  if (this.app.editor) {
58
- this.appTab?.dispose()
59
- this.systemTab?.dispose()
60
- this.utilsTab?.dispose()
61
- this.pane?.dispose()
62
- this.appTab = undefined
63
- this.systemTab = undefined
64
- this.utilsTab = undefined
65
- this.pane = undefined
39
+ this.pane?.dispose();
40
+ this.pane = undefined;
66
41
  }
67
42
  }
68
43
 
69
44
  addFolder(name: string, params: any = undefined, parent: any = undefined) {
70
45
  if (this.app.editor) {
71
- if (this.pane === undefined) this.createGUI()
46
+ if (this.pane === undefined) this.createGUI();
72
47
 
73
- const container = parent !== undefined ? parent : this.appTab
48
+ const container = parent !== undefined ? parent : this.pane;
74
49
  return container.addFolder({
75
50
  title: name,
76
51
  ...params,
77
- })
52
+ });
78
53
  } else {
79
54
  this.app.send({
80
55
  event: 'addFolder',
56
+ target: 'app',
81
57
  data: {
82
58
  name,
83
59
  params,
84
60
  parent
85
61
  }
86
- })
62
+ });
87
63
  }
88
64
  }
89
65
 
90
66
  get bindID(): string {
91
- return `debug_${Math.max(this.appCallbacks, this.editorCallbacks)}`
67
+ return `debug_${Math.max(this.appCallbacks, this.editorCallbacks)}`;
92
68
  }
93
69
 
94
70
  // Binding
95
71
 
96
72
  bind(obj: any, name: string, params: any, parent: any = undefined) {
97
- const bindID = this.bindID
98
- const callback = params.onChange !== undefined ? params.onChange : noop
99
- this.bindCBs.set(bindID, callback)
73
+ const bindID = this.bindID;
74
+ const callback = params.onChange !== undefined ? params.onChange : noop;
75
+ this.bindCBs.set(bindID, callback);
100
76
 
101
77
  if (this.app.editor) {
102
- if (this.pane === undefined) this.createGUI()
78
+ if (this.pane === undefined) this.createGUI();
103
79
 
104
- const container = parent !== undefined ? parent : this.appTab
80
+ const container = parent !== undefined ? parent : this.pane;
105
81
  container
106
82
  .addBinding(obj, name, params)
107
83
  .on('change', (evt: any) => {
108
84
  this.app.send({
109
85
  event: 'updateBind',
86
+ target: 'app',
110
87
  data: {
111
88
  id: bindID,
112
89
  value: evt.value,
113
90
  }
114
- })
115
- })
116
- this.editorCallbacks++
91
+ });
92
+ });
93
+ this.editorCallbacks++;
117
94
  } else {
118
95
  this.app.send({
119
96
  event: 'bindObject',
97
+ target: 'app',
120
98
  data: {
121
99
  id: bindID,
122
100
  name,
123
101
  params,
124
102
  parent
125
103
  }
126
- })
127
- this.appCallbacks++
104
+ });
105
+ this.appCallbacks++;
128
106
  }
129
107
  }
130
108
 
131
109
  triggerBind(id: string, data: any) {
132
- const cb = this.bindCBs.get(id)
133
- if (cb !== undefined) cb(data)
134
- else console.warn(`No callback for: ${id}`, data)
110
+ const cb = this.bindCBs.get(id);
111
+ if (cb !== undefined) cb(data);
112
+ else console.warn(`No callback for: ${id}`, data);
135
113
  }
136
114
 
137
115
  // Buttons
138
116
 
139
117
  button(name: string, callback: VoidCallback, parent: any = undefined) {
140
- const bindID = this.bindID
141
- this.buttonCBs.set(bindID, callback)
118
+ const bindID = this.bindID;
119
+ this.buttonCBs.set(bindID, callback);
142
120
 
143
121
  if (this.app.editor) {
144
- if (this.pane === undefined) this.createGUI()
122
+ if (this.pane === undefined) this.createGUI();
145
123
 
146
- const container = parent !== undefined ? parent : this.appTab
124
+ const container = parent !== undefined ? parent : this.pane;
147
125
  container
148
126
  .addButton({ title: name })
149
127
  .on('click', () => {
150
128
  this.app.send({
151
129
  event: 'clickButton',
130
+ target: 'app',
152
131
  data: {
153
132
  id: bindID,
154
133
  }
155
- })
156
- })
157
- this.editorCallbacks++
134
+ });
135
+ });
136
+ this.editorCallbacks++;
158
137
  } else {
159
138
  this.app.send({
160
139
  event: 'addButton',
140
+ target: 'app',
161
141
  data: {
162
142
  id: bindID,
163
143
  name,
164
144
  callback,
165
145
  parent
166
146
  }
167
- })
168
- this.appCallbacks++
147
+ });
148
+ this.appCallbacks++;
169
149
  }
170
150
  }
171
151
 
172
152
  triggerButton(id: string) {
173
- const cb = this.buttonCBs.get(id)
174
- if (cb !== undefined) cb()
153
+ const cb = this.buttonCBs.get(id);
154
+ if (cb !== undefined) cb();
155
+ }
156
+
157
+ // Inspector
158
+
159
+ createInspector() {
160
+ this.inspectorFolder = this.addFolder('Inspector', this.pane);
161
+ }
162
+
163
+ clearInspector() {
164
+ const total = this.inspectorFolder.children.length - 1;
165
+ for (let i = total; i > -1; --i) {
166
+ this.inspectorFolder.remove(this.inspectorFolder.children[i]);
167
+ }
175
168
  }
176
169
  }
package/src/core/types.ts CHANGED
@@ -1,24 +1,34 @@
1
1
  // Interfaces
2
2
 
3
3
  export interface BroadcastData {
4
+ target: ApplicationMode
4
5
  event: EditorEvent
5
- data: any
6
+ data?: any
6
7
  }
7
8
 
8
9
  // Types
9
10
 
10
- export type ApplicationMode = 'listener' | 'editor'
11
+ export type ApplicationMode = 'app' | 'editor'
11
12
 
12
13
  export type VoidCallback = () => void
13
14
 
14
15
  export type DataUpdateCallback = (data: any) => void
15
16
 
16
17
  export type EditorEvent =
18
+ | 'custom'
17
19
  // Theatre
18
20
  | 'setSheet'
19
21
  | 'setSheetObject'
20
22
  | 'updateSheetObject'
21
23
  | 'updateTimeline'
24
+ // Three
25
+ | 'getObject'
26
+ | 'setObject'
27
+ | 'updateObject'
28
+ | 'getScene'
29
+ | 'setScene'
30
+ | 'createTexture'
31
+ | 'requestMethod'
22
32
  // GUI
23
33
  | 'addFolder'
24
34
  | 'bindObject'
@@ -37,7 +47,7 @@ export type TheatreUpdateCallback = (data: any) => void
37
47
 
38
48
  // Consts
39
49
 
40
- export const noop = () => {}
50
+ export const noop = () => {};
41
51
 
42
- export const defaultTheatreCallback: TheatreUpdateCallback = () => {}
52
+ export const defaultTheatreCallback: TheatreUpdateCallback = () => {};
43
53
 
@@ -1,9 +1,10 @@
1
- import { CSSProperties, Ref } from 'react'
2
- import './scss/index.scss'
1
+ import { CSSProperties, Ref } from 'react';
2
+ import './scss/index.scss';
3
3
 
4
4
  type EditorProps = {
5
- components?: JSX.Element | JSX.Element[]
5
+ header?: JSX.Element | JSX.Element[]
6
6
  children?: JSX.Element | JSX.Element[]
7
+ footer?: JSX.Element | JSX.Element[]
7
8
  ref?: Ref<any>
8
9
  style?: CSSProperties
9
10
  }
@@ -11,8 +12,9 @@ type EditorProps = {
11
12
  export default function Editor(props: EditorProps) {
12
13
  return (
13
14
  <div className="editor" ref={props.ref} style={props.style}>
14
- <div className="navBar">{props.children}</div>
15
- {props.components}
15
+ <header>{props.header}</header>
16
+ {props.children}
17
+ <footer>{props.footer}</footer>
16
18
  </div>
17
- )
19
+ );
18
20
  }
@@ -1,33 +1,33 @@
1
1
  // Libs
2
- import { useState } from 'react'
3
- import { Reorder } from 'framer-motion'
2
+ import { useState } from 'react';
3
+ import { Reorder } from 'framer-motion';
4
4
  // Components
5
- import NavButton from './NavButton'
6
- import DraggableItem from './DraggableItem'
7
- import { DraggableProps } from './types'
5
+ import NavButton from './NavButton';
6
+ import DraggableItem from './DraggableItem';
7
+ import { DraggableProps } from './types';
8
8
 
9
9
  export default function Draggable(props: DraggableProps) {
10
- const [expanded, setExpanded] = useState(false)
11
- const [list, setList] = useState<string[]>(props.options)
10
+ const [expanded, setExpanded] = useState(false);
11
+ const [list, setList] = useState<string[]>(props.options);
12
12
 
13
13
  const updateList = (updated: string[]) => {
14
- props.onDragComplete(updated)
15
- setList(updated)
16
- }
14
+ props.onDragComplete(updated);
15
+ setList(updated);
16
+ };
17
17
 
18
18
  const onDelete = (index: number) => {
19
- const newArray = [...list]
20
- newArray.splice(index, 1)
21
- updateList(newArray)
22
- }
19
+ const newArray = [...list];
20
+ newArray.splice(index, 1);
21
+ updateList(newArray);
22
+ };
23
23
 
24
- const elements: any[] = []
24
+ const elements: any[] = [];
25
25
  list.forEach((value: string, index: number) => {
26
- elements.push(<DraggableItem key={value} index={index} title={value} onDelete={onDelete} />)
27
- })
26
+ elements.push(<DraggableItem key={value} index={index} title={value} onDelete={onDelete} />);
27
+ });
28
28
 
29
- let ddClassName = 'dropdown draggable'
30
- if (props.subdropdown) ddClassName += ' subdropdown'
29
+ let ddClassName = 'dropdown draggable';
30
+ if (props.subdropdown) ddClassName += ' subdropdown';
31
31
 
32
32
  return (
33
33
  <div className={ddClassName} onMouseEnter={() => setExpanded(true)} onMouseLeave={() => setExpanded(false)}>
@@ -36,5 +36,5 @@ export default function Draggable(props: DraggableProps) {
36
36
  {elements}
37
37
  </Reorder.Group>
38
38
  </div>
39
- )
39
+ );
40
40
  }
@@ -1,9 +1,9 @@
1
1
  // Libs
2
- import { Reorder } from 'framer-motion'
2
+ import { Reorder } from 'framer-motion';
3
3
  // Components
4
- import CloseIcon from './icons/CloseIcon'
5
- import DragIcon from './icons/DragIcon'
6
- import { DraggableItemProps } from './types'
4
+ import CloseIcon from './icons/CloseIcon';
5
+ import DragIcon from './icons/DragIcon';
6
+ import { DraggableItemProps } from './types';
7
7
 
8
8
  export default function DraggableItem(props: DraggableItemProps) {
9
9
  return (
@@ -12,11 +12,11 @@ export default function DraggableItem(props: DraggableItemProps) {
12
12
  {DragIcon}
13
13
  <span>{props.title}</span>
14
14
  <button className="closeIcon" onClick={() => {
15
- props.onDelete(props.index)
15
+ props.onDelete(props.index);
16
16
  }}>
17
17
  {CloseIcon}
18
18
  </button>
19
19
  </div>
20
20
  </Reorder.Item>
21
- )
21
+ );
22
22
  }
@@ -1,30 +1,38 @@
1
1
  // Libs
2
- import { useState } from 'react'
2
+ import { useState } from 'react';
3
3
  // Views
4
- import NavButton from './NavButton'
5
- import DropdownItem from './DropdownItem'
6
- import { DropdownOption, DropdownProps } from './types'
4
+ import NavButton from './NavButton';
5
+ import DropdownItem from './DropdownItem';
6
+ import { DropdownOption, DropdownProps } from './types';
7
7
 
8
8
  export default function Dropdown(props: DropdownProps) {
9
- const [expanded, setExpanded] = useState(false)
9
+ const [expanded, setExpanded] = useState(false);
10
10
 
11
- const list: Array<any> = []
11
+ const list: Array<any> = [];
12
12
  {
13
13
  props.options.map((option: DropdownOption, index: number) => {
14
14
  if (props.onSelect !== undefined) {
15
- option.onSelect = props.onSelect
15
+ option.onSelect = props.onSelect;
16
16
  }
17
- list.push(<DropdownItem option={option} key={index} />)
18
- })
17
+ list.push(<DropdownItem option={option} key={index} />);
18
+ });
19
19
  }
20
20
 
21
- let ddClassName = 'dropdown'
22
- if (props.subdropdown) ddClassName += ' subdropdown'
21
+ let ddClassName = 'dropdown';
22
+ if (props.subdropdown) ddClassName += ' subdropdown';
23
23
 
24
24
  return (
25
- <div className={ddClassName} onMouseEnter={() => setExpanded(true)} onMouseLeave={() => setExpanded(false)}>
25
+ <div
26
+ className={ddClassName}
27
+ onMouseEnter={() => setExpanded(true)}
28
+ onMouseLeave={() => setExpanded(false)}
29
+ >
26
30
  <NavButton title={props.title} />
27
- <ul style={{ visibility: expanded ? 'visible' : 'hidden' }}>{list}</ul>
31
+ <ul
32
+ style={{ visibility: expanded ? 'visible' : 'hidden' }}
33
+ >
34
+ {list}
35
+ </ul>
28
36
  </div>
29
- )
37
+ );
30
38
  }
@@ -1,17 +1,17 @@
1
1
  // Libs
2
- import { useState } from 'react'
2
+ import { useState } from 'react';
3
3
  // Components
4
- import Draggable from './Draggable'
5
- import Dropdown from './Dropdown'
6
- import type { DropdownItemProps, DropdownOption } from './types'
4
+ import Draggable from './Draggable';
5
+ import Dropdown from './Dropdown';
6
+ import type { DropdownItemProps, DropdownOption } from './types';
7
7
  // Utils
8
- import { randomID } from '../utils'
8
+ import { randomID } from '../utils';
9
9
 
10
10
  export default function DropdownItem(props: DropdownItemProps) {
11
- const { option } = props
12
- const [selected, setSelected] = useState('')
11
+ const { option } = props;
12
+ const [selected, setSelected] = useState('');
13
13
 
14
- let element = null
14
+ let element;
15
15
  switch (option.type) {
16
16
  case 'draggable':
17
17
  element = (
@@ -19,12 +19,12 @@ export default function DropdownItem(props: DropdownItemProps) {
19
19
  title={option.title}
20
20
  options={option.value as Array<string>}
21
21
  onDragComplete={(options: string[]) => {
22
- if (option.onDragComplete !== undefined) option.onDragComplete(options)
22
+ if (option.onDragComplete !== undefined) option.onDragComplete(options);
23
23
  }}
24
24
  subdropdown={true}
25
25
  />
26
- )
27
- break
26
+ );
27
+ break;
28
28
  case 'dropdown':
29
29
  element = (
30
30
  <Dropdown
@@ -33,32 +33,32 @@ export default function DropdownItem(props: DropdownItemProps) {
33
33
  onSelect={option.onSelect}
34
34
  subdropdown={true}
35
35
  />
36
- )
37
- break
36
+ );
37
+ break;
38
38
  case 'option':
39
39
  element = (
40
40
  <button
41
41
  onClick={() => {
42
- if (option.onSelect !== undefined) option.onSelect(option.value)
42
+ if (option.onSelect !== undefined) option.onSelect(option.value);
43
43
  // Toggle selectable
44
44
  if (option.selectable) {
45
45
  if (selected !== option.title) {
46
- setSelected(option.title)
46
+ setSelected(option.title);
47
47
  } else {
48
- setSelected('')
48
+ setSelected('');
49
49
  }
50
50
  }
51
51
  }}
52
52
  >
53
53
  {option.title}
54
54
  </button>
55
- )
56
- break
55
+ );
56
+ break;
57
57
  }
58
58
 
59
59
  return (
60
60
  <li className={selected === option.title ? 'selected' : ''} key={randomID()}>
61
61
  {element}
62
62
  </li>
63
- )
63
+ );
64
64
  }
@@ -7,5 +7,5 @@ export default function NavButton(props: NavButtonProps) {
7
7
  <button className="svg" dangerouslySetInnerHTML={{ __html: props.title }}></button>
8
8
  ) : (
9
9
  <button>{props.title}</button>
10
- )
10
+ );
11
11
  }
@@ -0,0 +1,2 @@
1
+ export const gridImage = `data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAASwAAABkCAYAAAA8AQ3AAAAACXBIWXMAAAsTAAALEwEAmpwYAAAEoklEQVR4nO3aQc4aMRAFYR+AOQv3Px3ZRYoSoh8YxvX61YJdSdPuD++81lqPZ7/b7fa43++P4zieNnbPu+M40PO1dXqwujc9WIeY0nk5WJ0erO4DD84hpnReDlanB6v70INxiCmdl4PV6cHqTvDYf4gpnZeD1enB6k7yyDgsvfNysDo9WN2JHvzD0jsvB6vTg9Wd6kE/LL3zcrA6PVjd2R6LfFh65+VgdXqwum94LOph6Z2Xg9Xpweq+5bGIh6V3Xg5Wpwer+7IH67D0zsvB6vRgdRd4cA5L77wcrE4PVneRB+Ow9M7Lwer0YHUXeuw/LL3zcrA6PVjdxR4ZSynBsNMjqtvgwV9KEYadHjHdFg/6Uqow7PQI6XZ5+NIdhGGnR0K308OX7iAMOz3o3W6PRVxKK4adHuQO4sFaSjmGnR7IDuTBWYoYdnrwOpgHYyli2OnB64Ae+5cihp0evA7qkbG8EozaTg9WB/bgL68Io7LTg9WhPejLq8Io7PRgdXSPqpfudIy2Tg9Wl+BR89J9F0bCn6BpL3qw9vLqdxdxebuXkv5deqcHqwvzYC0PspTY79I7PVhdoAdneaClRH6X3unB6kI9GMuDLSXuu/ROD1YX7LF/ecClRH2X3unB6sI9MpZcgjGu04PVDfDgL7kIY1SnB6sb4UFfchXGoE4PVjfFY8RL9ykYUzo9WN0kj/iX7pMwJnR6sLppHou45N1LoX6X3unB6oZ6sJYMWQruu/ROD1Y32IOzZNBSUN+ld3qwuuEejCXTOy8Hq9OD1V3osf+w9M7Lwer0YHUXe2QspQTDTo+oboMHfylFGHZ6xHRbPOhLqcKw0yOk2+Ux4qX7FAw7PRK6nR7xL90nYdjpQe92eyziUlox7PQgdxAP1lLKMez0QHYgD85SxLDTg9fBPBhLEcNOD14H9Ni/FDHs9OB1UI+M5ZVg1HZ6sDqwB395RRiVnR6sDu1BX14VRmGnB6uje1S9dKdjtHV6sLoEj5qX7gkYTZ0erC7FY5GHa8No6fRgdWEe6OHaMMZ3erC6QA/0cG0Yozs9WF2oB3q4NoyxnR6sLtgDPVwbxshOD1YX7oEerg1jXKcHqxvggR6uDWNUpwerG+GBHq4NY1CnB6ub4jHipfsUjCmdHqxukkf8S/dJGBM6PVjdNI9FHq4NI73Tg9UN9UAP14YR2+nB6gZ7oIdrw4js9GB1wz3Qw7VhxHV6sLoCD/RwbRhRnR6srsQDPVwbRkynB6sr8kAP14YR0enB6qo80MO1YQR0erC6Ng/0S/c2DHqnB6tr9MC+dG/EIHd6sLpWj0UcrhWD2unB6so9WMOVY+A6PVidHqDhxGB1erA6PdZjUYYTg9Xpwer0+P3bP5wYrE4PVqfHHz8x7PSgdnr89RPDTg9ip8c/fmLY6cHr9HjyE8NOD1anx/Pu8pfuYrA6PVidHv/vlhi9nR6sTo8fdWI0dnqwOj1+3InR1unB6vR4qROjqdOD1enxcidGS6cHq9PjrU6Mhk4PVqfH250Y0zs9WJ0eH3RizO70YHV6fNad+tJdDFanB6vT4/PutJfuYrA6PVidHud0vwA7LKl1AiiR5gAAAABJRU5ErkJggg==`;
2
+ export const noImage = `data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAACXBIWXMAAAsTAAALEwEAmpwYAAAA5klEQVRoge2Y0Q6EIAwE6cX//+X6cCFpSMEKVTdk501OpRNKiyelFC0b8Ps6gCwoggZF0KAIGhRBgyJoUAQNiqCxjciR9SLV//eZiAyvK3U8i/QVaQO2YyLSFVvlkdTKDjJCukh2ykR5ZEW+kHmlatl90RaBtDkK/w7CYhuRUEO0ee3l+J3m55Vm+17vtwjTnV1V3QA8qfbeUXCzRWDpiLLS+OyzvRW7IzW9R+okvclsqR09743bo0yUpc1+lSJvNsa002+Euk9GKzV7SmZDRIMiaFAEDYqgQRE0KIIGRdCgCBoUQeMEMERadX7YUz8AAAAASUVORK5CYII=`;
@@ -4,4 +4,4 @@ export default (
4
4
  <line x1="4" y1="4" x2="10" y2="10" />
5
5
  <line x1="4" y1="10" x2="10" y2="4" />
6
6
  </svg>
7
- )
7
+ );
@@ -6,4 +6,4 @@ C11,4.22,10.74,4,10.43,4z M10.43,8H3.57C3.26,8,3,8.22,3,8.5v1C3,9.78,3.26,10,3.5
6
6
  C11,8.22,10.74,8,10.43,8z"
7
7
  />
8
8
  </svg>
9
- )
9
+ );
@@ -1,13 +1,18 @@
1
1
  import { EventDispatcher } from 'three';
2
2
 
3
- export const debugDispatcher = new EventDispatcher()
3
+ export const debugDispatcher = new EventDispatcher();
4
4
 
5
5
  export const ToolEvents = {
6
+ CUSTOM: 'ToolEvents::custom',
6
7
  // Components
7
8
  SELECT_DROPDOWN: 'ToolEvents::selectDropdown',
8
9
  DRAG_UPDATE: 'ToolEvents::dragUpdate',
9
10
  // SceneHierarchy
10
- INSPECT_ITEM: 'ToolEvents::inspectItem',
11
- REFRESH_SCENE: 'ToolEvents::refreshScene',
11
+ GET_SCENE: 'ToolEvents::getScene',
12
12
  SET_SCENE: 'ToolEvents::setScene',
13
- }
13
+ GET_OBJECT: 'ToolEvents::getObject',
14
+ SET_OBJECT: 'ToolEvents::setObject',
15
+ UPDATE_OBJECT: 'ToolEvents::updateObject',
16
+ CREATE_TEXTURE: 'ToolEvents::createTexture',
17
+ REQUEST_METHOD: 'ToolEvents::requestMethod',
18
+ };
@@ -0,0 +1,40 @@
1
+ import { useState } from "react";
2
+
3
+ type AccordionProps = {
4
+ label: string
5
+ button?: JSX.Element
6
+ children?: JSX.Element | JSX.Element[]
7
+ open?: boolean
8
+ onToggle?: (value: boolean) => void
9
+ }
10
+
11
+ export default function Accordion(props: AccordionProps) {
12
+ const [open, setOpen] = useState(props.open !== undefined ? props.open : true);
13
+ const hide = !open || props.children === undefined;
14
+
15
+ return (
16
+ <div className={`accordion ${hide ? 'hide' : ''}`}>
17
+ <button
18
+ className="toggle"
19
+ onClick={() => {
20
+ const value = !open;
21
+ if (props.onToggle !== undefined) props.onToggle(value);
22
+ setOpen(value);
23
+ }}
24
+ >
25
+ <p
26
+ className={`status ${open ? 'open' : ''}`}
27
+ >
28
+ Toggle
29
+ </p>
30
+ <p className="label">{props.label}</p>
31
+ </button>
32
+ {props.button}
33
+ <div className={open ? 'open' : ''}>
34
+ <div>
35
+ {props.children}
36
+ </div>
37
+ </div>
38
+ </div>
39
+ );
40
+ }