@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,57 +0,0 @@
1
- // Libs
2
- import { useState } from 'react';
3
- import { Object3D } from 'three';
4
- // Models
5
- import { ChildObjectProps } from './types';
6
- // Utils
7
- import { determineIcon } from './utils';
8
-
9
- export default function ChildObject(props: ChildObjectProps) {
10
- const [open, setOpen] = useState(false);
11
-
12
- const hasChildren = props.child.children.length > 0;
13
- const children: Array<any> = [];
14
- if (props.child.children.length > 0) {
15
- props.child.children.map((child: Object3D) => {
16
- children.push(<ChildObject child={child} key={Math.random()} three={props.three} />);
17
- });
18
- }
19
-
20
- return (
21
- <div className='childObject' key={Math.random()}>
22
- <div className='child'>
23
- {hasChildren ? (
24
- <button
25
- className='status'
26
- style={{
27
- backgroundPositionX: open ? '-14px' : '2px',
28
- }}
29
- onClick={() => {
30
- setOpen(!open);
31
- }}
32
- ></button>
33
- ) : null}
34
- <button
35
- className='name'
36
- style={{
37
- left: hasChildren ? '20px' : '5px',
38
- }}
39
- onClick={() => {
40
- props.three.getObject(props.child.uuid);
41
- if (!open) setOpen(true);
42
- }}
43
- >
44
- {props.child.name.length > 0
45
- ? `${props.child.name} (${props.child.type})`
46
- : `${props.child.type}::${props.child.uuid}`}
47
- </button>
48
- <div className={`icon ${determineIcon(props.child)}`}></div>
49
- </div>
50
- <div className={open ? 'open' : ''}>
51
- <div className='container'>
52
- {children}
53
- </div>
54
- </div>
55
- </div>
56
- );
57
- }
@@ -1,11 +0,0 @@
1
- import { Object3D } from 'three';
2
- import ChildObject from './ChildObject';
3
- import { ChildObjectProps } from './types';
4
-
5
- export default function ContainerObject(props: ChildObjectProps) {
6
- const children: Array<any> = [];
7
- props.child.children.map((child: Object3D) => {
8
- children.push(<ChildObject child={child} key={Math.random()} three={props.three} />);
9
- });
10
- return <div className={`scene ${props.class !== undefined ? props.class : ''}`}>{children}</div>;
11
- }
@@ -1,64 +0,0 @@
1
- // Libs
2
- import { Component, ReactNode } from 'react';
3
- // Models
4
- import { debugDispatcher, ToolEvents } from '../global';
5
- // Components
6
- import '../scss/_sidePanel.scss';
7
- import Accordion from './Accordion';
8
- import ContainerObject from './ContainerObject';
9
- import Inspector from './inspector/Inspector';
10
- import { SidePanelState } from './types';
11
- import RemoteThree from '@/core/remote/RemoteThree';
12
-
13
- export default class SidePanel extends Component<SidePanelState> {
14
- private three: RemoteThree;
15
-
16
- constructor(props: SidePanelState) {
17
- super(props);
18
- this.state = {
19
- scene: props.scene !== undefined ? props.scene : null,
20
- };
21
- this.three = props.three;
22
- debugDispatcher.addEventListener(ToolEvents.SET_SCENE, this.setScene);
23
- }
24
-
25
- componentWillUnmount(): void {
26
- debugDispatcher.removeEventListener(ToolEvents.SET_SCENE, this.setScene);
27
- }
28
-
29
- render(): ReactNode {
30
- const hasScene = this.componentState.scene !== null;
31
- const HierarchyName = 'Hierarchy - ' + (hasScene ? `${this.componentState.scene?.name}` : 'No Scene');
32
- return (
33
- <div id='SidePanel' key='SidePanel'>
34
- {(
35
- <>
36
- <Accordion label={HierarchyName} open={true}>
37
- <>
38
- {hasScene && (
39
- <ContainerObject child={this.componentState.scene!} three={this.three} />
40
- )}
41
- </>
42
- </Accordion>
43
-
44
- <Inspector three={this.three} />
45
- </>
46
- )}
47
- </div>
48
- );
49
- }
50
-
51
- // Private
52
-
53
- private setScene = (evt: any) => {
54
- this.setState(() => ({
55
- scene: evt.value
56
- }));
57
- };
58
-
59
- // Getters / Setters
60
-
61
- get componentState(): SidePanelState {
62
- return this.state as SidePanelState;
63
- }
64
- }
@@ -1,27 +0,0 @@
1
- import { useState } from 'react';
2
- import { capitalize } from '@/editor/utils';
3
-
4
- type ToggleBtnProps = {
5
- expanded: boolean
6
- label: string
7
- onClick: (expanded: boolean) => void;
8
- }
9
-
10
- export default function ToggleBtn(props: ToggleBtnProps) {
11
- const [expanded, setExpanded] = useState(props.expanded);
12
- return (
13
- <button
14
- className='toggleBtn'
15
- onClick={() => {
16
- const value = !expanded;
17
- props.onClick(value);
18
- setExpanded(value);
19
- }}
20
- style={{
21
- backgroundPositionY: `${expanded ? 1 : -10}px`
22
- }}
23
- >
24
- <p>{capitalize(props.label)}</p>
25
- </button>
26
- );
27
- }
@@ -1,119 +0,0 @@
1
- import { useEffect, useState } from 'react';
2
- import { CoreComponentProps, RemoteObject } from '../types';
3
- import { ToolEvents, debugDispatcher } from '../../global';
4
- // Components
5
- import './inspector.scss';
6
- import Accordion from '../Accordion';
7
- import InspectorField from './InspectorField';
8
- // Utils
9
- import { InspectCamera } from './utils/InspectCamera';
10
- import { InspectMaterial } from './utils/InspectMaterial';
11
- import { InspectTransform } from './utils/InspectTransform';
12
- import { InspectLight } from './utils/InspectLight';
13
- import { setItemProps } from '../utils';
14
- import InspectAnimation from './utils/InspectAnimation';
15
-
16
- const defaultObject: RemoteObject = {
17
- name: '',
18
- uuid: '',
19
- type: '',
20
- visible: false,
21
- matrix: [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1],
22
- animations: [],
23
- material: undefined,
24
- perspectiveCameraInfo: undefined,
25
- orthographicCameraInfo: undefined,
26
- lightInfo: undefined,
27
- };
28
- let currentObject = {...defaultObject};
29
-
30
- export default function Inspector(props: CoreComponentProps) {
31
- const [lastUpdated, setLastUpdated] = useState<number>(-1);
32
-
33
- useEffect(() => {
34
- function onSelectItem(evt: any) {
35
- const obj = evt.value as RemoteObject;
36
- currentObject = {...obj};
37
- setLastUpdated(Date.now());
38
- }
39
-
40
- function setScene() {
41
- currentObject = {...defaultObject};
42
- setLastUpdated(Date.now());
43
- }
44
-
45
- debugDispatcher.addEventListener(ToolEvents.SET_SCENE, setScene);
46
- debugDispatcher.addEventListener(ToolEvents.SET_OBJECT, onSelectItem);
47
- return () => {
48
- debugDispatcher.removeEventListener(ToolEvents.SET_SCENE, setScene);
49
- debugDispatcher.removeEventListener(ToolEvents.SET_OBJECT, onSelectItem);
50
- };
51
- }, []);
52
-
53
- const objType = currentObject.type.toLowerCase();
54
- const hasAnimation = currentObject.animations.length > 0
55
- || currentObject['mixer'] !== undefined;
56
- const hasMaterial = objType.search('mesh') > -1
57
- || objType.search('line') > -1
58
- || objType.search('points') > -1;
59
-
60
- return (
61
- <Accordion label='Inspector' key='Inspector'>
62
- <div id='Inspector' className={props.class} key={lastUpdated}>
63
- {currentObject.uuid.length > 0 && (
64
- <>
65
- {/* Core */}
66
- <>
67
- <InspectorField
68
- type='string'
69
- title='Name'
70
- prop='name'
71
- value={currentObject.name}
72
- disabled={true}
73
- />
74
- <InspectorField
75
- type='string'
76
- title='Type'
77
- prop='type'
78
- value={currentObject.type}
79
- disabled={true}
80
- />
81
- <InspectorField
82
- type='string'
83
- title='UUID'
84
- prop='uuid'
85
- value={currentObject.uuid}
86
- disabled={true}
87
- />
88
- <InspectorField
89
- type='boolean'
90
- title='Visible'
91
- prop='visible'
92
- value={currentObject.visible}
93
- onChange={(key: string, value: any) => {
94
- props.three.updateObject(currentObject.uuid, key, value);
95
- const child = props.three.scene?.getObjectByProperty('uuid', currentObject.uuid);
96
- if (child !== undefined) setItemProps(child, key, value);
97
- }}
98
- />
99
- </>
100
-
101
- {/* Data */}
102
- <>
103
- {/* Transform */}
104
- {InspectTransform(currentObject, props.three)}
105
- {/* Animations */}
106
- {hasAnimation ? InspectAnimation(currentObject, props.three) : null}
107
- {/* Cameras */}
108
- {objType.search('camera') > -1 ? InspectCamera(currentObject, props.three) : null}
109
- {/* Lights */}
110
- {objType.search('light') > -1 ? InspectLight(currentObject, props.three) : null}
111
- {/* Material */}
112
- {hasMaterial ? InspectMaterial(currentObject, props.three) : null}
113
- </>
114
- </>
115
- )}
116
- </div>
117
- </Accordion>
118
- );
119
- }
@@ -1,198 +0,0 @@
1
- import { colorToHex } from '@/editor/utils';
2
- import { useEffect, useRef, useState } from 'react';
3
- import { noImage } from '@/editor/components/content';
4
- import { uploadLocalImage } from './utils/InspectMaterial';
5
- import { capitalize } from '@/editor/utils';
6
-
7
- export type InspectorFieldType = 'string' | 'number' | 'boolean' | 'range' | 'color' | 'button' | 'image' | 'option'
8
-
9
- export interface InspectorFieldProps {
10
- title: string
11
- type: InspectorFieldType
12
- prop?: string
13
- value?: any
14
- min?: number
15
- max?: number
16
- step?: number
17
- disabled?: boolean
18
- options?: any[]
19
- onChange?: (prop: string, value: any) => void
20
- }
21
-
22
- export default function InspectorField(props: InspectorFieldProps) {
23
- let propsValue = props.value;
24
- if (propsValue !== undefined) {
25
- if (propsValue.isColor !== undefined) {
26
- propsValue = colorToHex(props.value);
27
- }
28
- }
29
-
30
- const [fieldValue, setFieldValue] = useState(propsValue);
31
- const labelRef = useRef<HTMLLabelElement>(null);
32
- const inputRef = useRef<HTMLInputElement>(null);
33
- const imgRefRef = useRef<HTMLImageElement>(null);
34
-
35
- // Mouse dragging
36
- useEffect(() => {
37
- let mouseDown = false;
38
- let mouseStart = -1;
39
- let valueStart = 0;
40
- let value = Number(fieldValue);
41
-
42
- const onMouseDown = (evt: MouseEvent) => {
43
- mouseDown = true;
44
- valueStart = value;
45
- mouseStart = evt.clientX;
46
- };
47
-
48
- const onMouseMove = (evt: MouseEvent) => {
49
- if (!mouseDown) return;
50
- const deltaAmt = props.step !== undefined ? props.step : 1;
51
- const delta = (evt.clientX - mouseStart) * deltaAmt;
52
- value = Number((valueStart + delta).toFixed(4));
53
- if (inputRef.current !== null) inputRef.current.value = value.toString();
54
- if (props.onChange !== undefined) props.onChange(props.prop !== undefined ? props.prop : props.title, value);
55
- };
56
-
57
- const onMouseUp = () => {
58
- mouseDown = false;
59
- };
60
-
61
- const onRightClick = () => {
62
- mouseDown = false;
63
- };
64
-
65
- const useMouse = props.type === 'number';
66
- if (useMouse) {
67
- labelRef.current?.addEventListener('mousedown', onMouseDown, false);
68
- document.addEventListener('mouseup', onMouseUp, false);
69
- document.addEventListener('mousemove', onMouseMove, false);
70
- document.addEventListener('contextmenu', onRightClick, false);
71
- }
72
- return () => {
73
- if (useMouse) {
74
- labelRef.current?.removeEventListener('mousedown', onMouseDown);
75
- document.removeEventListener('mouseup', onMouseUp);
76
- document.removeEventListener('mousemove', onMouseMove);
77
- document.removeEventListener('contextmenu', onRightClick);
78
- }
79
- };
80
- }, [fieldValue]);
81
-
82
- const textfield = props.type === 'string' && (fieldValue.length > 100 || fieldValue.search('\n') > -1);
83
- const block = textfield || props.type === 'image';
84
-
85
- const onChange = (evt: any) => {
86
- let value = evt.target.value;
87
- if (props.type === 'boolean') {
88
- value = evt.target.checked;
89
- } else if (props.type === 'option') {
90
- // @ts-ignore
91
- value = props.options[value].value;
92
- }
93
- setFieldValue(value);
94
- if (props.onChange !== undefined) props.onChange(props.prop !== undefined ? props.prop : props.title, value);
95
- };
96
-
97
- return (
98
- <div className={`field ${block ? 'block' : ''}`}>
99
- {props.type !== 'button' && (
100
- <label key='fieldLabel' ref={labelRef}>{capitalize(props.title)}</label>
101
- )}
102
-
103
- {props.type === 'string' && !textfield && (
104
- <input
105
- type='text'
106
- disabled={props.disabled}
107
- onChange={onChange}
108
- value={fieldValue}
109
- />
110
- )}
111
-
112
- {props.type === 'string' && textfield && (
113
- <textarea
114
- cols={50}
115
- rows={10}
116
- disabled={props.disabled !== undefined ? props.disabled : true}
117
- onChange={onChange}
118
- value={fieldValue}
119
- />
120
- )}
121
-
122
- {props.type === 'boolean' && (
123
- <input
124
- type='checkbox'
125
- disabled={props.disabled}
126
- onChange={onChange}
127
- checked={fieldValue}
128
- />
129
- )}
130
-
131
- {props.type === 'number' && (
132
- <input
133
- ref={inputRef}
134
- type='number'
135
- value={fieldValue}
136
- min={props.min}
137
- max={props.max}
138
- step={props.step}
139
- disabled={props.disabled}
140
- onChange={onChange}
141
- />
142
- )}
143
-
144
- {props.type === 'range' && (
145
- <>
146
- <input type='text' value={fieldValue.toString()} onChange={onChange} disabled={props.disabled} className='min' />
147
- <input
148
- disabled={props.disabled}
149
- type='range'
150
- value={fieldValue}
151
- min={props.min}
152
- max={props.max}
153
- step={props.step}
154
- onChange={onChange}
155
- />
156
- </>
157
- )}
158
-
159
- {props.type === 'color' && (
160
- <>
161
- <input type='text' value={fieldValue.toString()} onChange={onChange} disabled={props.disabled} className='color' />
162
- <input type='color' value={fieldValue} onChange={onChange} disabled={props.disabled} />
163
- </>
164
- )}
165
-
166
- {props.type === 'button' && (
167
- <button
168
- disabled={props.disabled}
169
- onClick={() => {
170
- if (props.onChange !== undefined) props.onChange(props.prop !== undefined ? props.prop : props.title, true);
171
- }}
172
- >
173
- {props.title}
174
- </button>
175
- )}
176
-
177
- {props.type === 'image' && (
178
- <img ref={imgRefRef} onClick={() => {
179
- uploadLocalImage()
180
- .then((value: string) => {
181
- imgRefRef.current!.src = value;
182
- if (props.onChange !== undefined) props.onChange(props.prop !== undefined ? props.prop : props.title, value);
183
- });
184
- }} src={fieldValue.length > 0 ? fieldValue : noImage} />
185
- )}
186
-
187
- {props.type === 'option' && (
188
- <>
189
- <select onChange={onChange} disabled={props.disabled} defaultValue={props.value}>
190
- {props.options?.map((option, index) => (
191
- <option key={index} value={option.value}>{capitalize(option.title)}</option>
192
- ))}
193
- </select>
194
- </>
195
- )}
196
- </div>
197
- );
198
- }
@@ -1,50 +0,0 @@
1
- import Accordion from '../Accordion';
2
- import InspectorField, { InspectorFieldProps } from './InspectorField';
3
- import { capitalize } from '@/editor/utils';
4
-
5
- export interface InspectorGroupProps {
6
- title: string
7
- expanded?: boolean
8
- items: InspectorFieldProps[] | InspectorGroupProps[]
9
- }
10
-
11
- function isGroup(obj: any): obj is InspectorGroupProps {
12
- return 'items' in obj;
13
- }
14
-
15
- export default function InspectorGroup(props: InspectorGroupProps) {
16
- const children: any[] = [];
17
- props.items.forEach((child: InspectorFieldProps | InspectorGroupProps) => {
18
- if (isGroup(child)) {
19
- children.push(
20
- <InspectorGroup title={capitalize(child.title)} items={child.items} key={Math.random()} />
21
- );
22
- } else {
23
- children.push(
24
- <InspectorField
25
- key={Math.random()}
26
- title={child.title}
27
- prop={child.prop}
28
- value={child.value}
29
- type={child.type}
30
- min={child.min}
31
- max={child.max}
32
- step={child.step}
33
- disabled={child.disabled}
34
- options={child.options}
35
- onChange={(prop: string, value: any) => {
36
- if (child.onChange !== undefined) {
37
- child.onChange(prop, value);
38
- }
39
- }}
40
- />
41
- );
42
- }
43
- });
44
-
45
- return (
46
- <Accordion label={props.title} open={props.expanded === true}>
47
- {children}
48
- </Accordion>
49
- );
50
- }
@@ -1,84 +0,0 @@
1
- import RemoteThree from '@/core/remote/RemoteThree';
2
- import { ToolEvents, debugDispatcher } from '@/editor/global';
3
- import { useEffect } from 'react';
4
- import { Texture } from 'three';
5
- import { getSubItem, setItemProps, textureFromSrc } from '../utils';
6
-
7
- export interface SceneInspectorProps {
8
- three: RemoteThree
9
- }
10
-
11
- export default function SceneInspector(props: SceneInspectorProps) {
12
- function hasScene() {
13
- if (props.three.scene === undefined) {
14
- console.log('No scene:', props.three);
15
- return false;
16
- }
17
- return true;
18
- }
19
- const onGetObject = (evt: any) => {
20
- if (!hasScene()) return;
21
- const child = props.three.scene?.getObjectByProperty('uuid', evt.value);
22
- if (child !== undefined) props.three.setObject(child);
23
- };
24
-
25
- const setChildProps = (uuid: string, key: string, value: any) => {
26
- if (!hasScene()) return;
27
- const child = props.three.scene?.getObjectByProperty('uuid', uuid);
28
- if (child !== undefined) {
29
- setItemProps(child, key, value);
30
- }
31
- };
32
-
33
- const onUpdateObject = (evt: any) => {
34
- if (!hasScene()) return;
35
- const msg = evt.value;
36
- const { key, value, uuid } = msg;
37
- setChildProps(uuid, key, value);
38
- };
39
-
40
- const onCreateTexture = (evt: any) => {
41
- if (!hasScene()) return;
42
- const data = evt.value;
43
- textureFromSrc(data.value).then((texture: Texture) => {
44
- setChildProps(data.uuid, data.key, texture);
45
- setChildProps(data.uuid, `material.needsUpdate`, true);
46
- });
47
- };
48
-
49
- const onRequestMethod = (evt: any) => {
50
- if (!hasScene()) return;
51
- const { key, uuid, value, subitem } = evt.value;
52
- const child = props.three.scene?.getObjectByProperty('uuid', uuid);
53
- if (child !== undefined) {
54
- try {
55
- if (subitem !== undefined) {
56
- const target = getSubItem(child, subitem);
57
- target[key](value);
58
- } else {
59
- child[key](value);
60
- }
61
- } catch (err: any) {
62
- console.log('Error requesting method:');
63
- console.log(err);
64
- console.log(key);
65
- console.log(value);
66
- }
67
- }
68
- };
69
-
70
- useEffect(() => {
71
- debugDispatcher.addEventListener(ToolEvents.GET_OBJECT, onGetObject);
72
- debugDispatcher.addEventListener(ToolEvents.UPDATE_OBJECT, onUpdateObject);
73
- debugDispatcher.addEventListener(ToolEvents.CREATE_TEXTURE, onCreateTexture);
74
- debugDispatcher.addEventListener(ToolEvents.REQUEST_METHOD, onRequestMethod);
75
- return () => {
76
- debugDispatcher.removeEventListener(ToolEvents.GET_OBJECT, onGetObject);
77
- debugDispatcher.removeEventListener(ToolEvents.UPDATE_OBJECT, onUpdateObject);
78
- debugDispatcher.removeEventListener(ToolEvents.CREATE_TEXTURE, onCreateTexture);
79
- debugDispatcher.removeEventListener(ToolEvents.REQUEST_METHOD, onRequestMethod);
80
- };
81
- }, []);
82
-
83
- return null;
84
- }