@tomorrowevening/hermes 0.0.9 → 0.0.12
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/dist/hermes.js +1608 -1382
- package/dist/hermes.umd.cjs +16 -16
- package/dist/style.css +1 -1
- package/package.json +1 -1
- package/src/core/RemoteController.ts +7 -3
- package/src/core/remote/RemoteThree.ts +24 -11
- package/src/core/types.ts +2 -1
- package/src/editor/global.ts +3 -1
- package/src/editor/{sceneHierarchy/inspector/MultiView → multiView}/CameraWindow.tsx +20 -7
- package/src/editor/{sceneHierarchy/inspector/MultiView → multiView}/MultiView.scss +8 -0
- package/src/editor/{sceneHierarchy/inspector/MultiView → multiView}/MultiView.tsx +286 -56
- package/src/editor/{sceneHierarchy/inspector/MultiView → multiView}/MultiViewData.ts +7 -15
- package/src/editor/scss/{_sceneHierarchy.scss → _sidePanel.scss} +1 -1
- package/src/editor/scss/index.scss +1 -1
- package/src/editor/sidePanel/SidePanel.tsx +64 -0
- package/src/editor/sidePanel/inspector/Inspector.tsx +114 -0
- package/src/editor/{sceneHierarchy → sidePanel}/inspector/SceneInspector.tsx +16 -11
- package/src/editor/sidePanel/inspector/utils/InspectAnimation.tsx +51 -0
- package/src/editor/{sceneHierarchy → sidePanel}/inspector/utils/InspectMaterial.tsx +1 -0
- package/src/editor/{sceneHierarchy → sidePanel}/inspector/utils/InspectTransform.tsx +35 -46
- package/src/editor/{sceneHierarchy → sidePanel}/types.ts +10 -1
- package/src/editor/{sceneHierarchy → sidePanel}/utils.ts +11 -2
- package/src/editor/utils.ts +60 -4
- package/src/index.ts +9 -9
- package/types/core/remote/RemoteThree.d.ts +3 -2
- package/types/core/types.d.ts +1 -1
- package/types/editor/global.d.ts +2 -1
- package/types/editor/{sceneHierarchy/inspector/MultiView → multiView}/CameraWindow.d.ts +2 -0
- package/types/editor/{sceneHierarchy/inspector/MultiView → multiView}/MultiView.d.ts +2 -4
- package/types/editor/{sceneHierarchy/inspector/MultiView → multiView}/MultiViewData.d.ts +4 -4
- package/types/editor/sidePanel/SidePanel.d.ts +11 -0
- package/types/editor/{sceneHierarchy → sidePanel}/inspector/SceneInspector.d.ts +0 -2
- package/types/editor/sidePanel/inspector/utils/InspectAnimation.d.ts +3 -0
- package/types/editor/{sceneHierarchy → sidePanel}/types.d.ts +7 -1
- package/types/editor/utils.d.ts +7 -1
- package/types/index.d.ts +9 -9
- package/src/editor/sceneHierarchy/SceneHierarchy.tsx +0 -80
- package/src/editor/sceneHierarchy/inspector/Inspector.tsx +0 -97
- package/types/editor/sceneHierarchy/SceneHierarchy.d.ts +0 -13
- /package/src/editor/{sceneHierarchy/inspector/MultiView → multiView}/InfiniteGridHelper.ts +0 -0
- /package/src/editor/{sceneHierarchy/inspector/MultiView → multiView}/InfiniteGridMaterial.ts +0 -0
- /package/src/editor/{sceneHierarchy/inspector/MultiView → multiView}/UVMaterial.ts +0 -0
- /package/src/editor/{sceneHierarchy → sidePanel}/Accordion.tsx +0 -0
- /package/src/editor/{sceneHierarchy → sidePanel}/ChildObject.tsx +0 -0
- /package/src/editor/{sceneHierarchy → sidePanel}/ContainerObject.tsx +0 -0
- /package/src/editor/{sceneHierarchy → sidePanel}/ToggleBtn.tsx +0 -0
- /package/src/editor/{sceneHierarchy → sidePanel}/inspector/InspectorField.tsx +0 -0
- /package/src/editor/{sceneHierarchy → sidePanel}/inspector/InspectorGroup.tsx +0 -0
- /package/src/editor/{sceneHierarchy → sidePanel}/inspector/inspector.scss +0 -0
- /package/src/editor/{sceneHierarchy → sidePanel}/inspector/utils/InspectCamera.tsx +0 -0
- /package/src/editor/{sceneHierarchy → sidePanel}/inspector/utils/InspectLight.tsx +0 -0
- /package/types/editor/{sceneHierarchy/inspector/MultiView → multiView}/InfiniteGridHelper.d.ts +0 -0
- /package/types/editor/{sceneHierarchy/inspector/MultiView → multiView}/InfiniteGridMaterial.d.ts +0 -0
- /package/types/editor/{sceneHierarchy/inspector/MultiView → multiView}/UVMaterial.d.ts +0 -0
- /package/types/editor/{sceneHierarchy → sidePanel}/Accordion.d.ts +0 -0
- /package/types/editor/{sceneHierarchy → sidePanel}/ChildObject.d.ts +0 -0
- /package/types/editor/{sceneHierarchy → sidePanel}/ContainerObject.d.ts +0 -0
- /package/types/editor/{sceneHierarchy → sidePanel}/ToggleBtn.d.ts +0 -0
- /package/types/editor/{sceneHierarchy → sidePanel}/inspector/Inspector.d.ts +0 -0
- /package/types/editor/{sceneHierarchy → sidePanel}/inspector/InspectorField.d.ts +0 -0
- /package/types/editor/{sceneHierarchy → sidePanel}/inspector/InspectorGroup.d.ts +0 -0
- /package/types/editor/{sceneHierarchy → sidePanel}/inspector/utils/InspectCamera.d.ts +0 -0
- /package/types/editor/{sceneHierarchy → sidePanel}/inspector/utils/InspectLight.d.ts +0 -0
- /package/types/editor/{sceneHierarchy → sidePanel}/inspector/utils/InspectMaterial.d.ts +0 -0
- /package/types/editor/{sceneHierarchy → sidePanel}/inspector/utils/InspectTransform.d.ts +0 -0
- /package/types/editor/{sceneHierarchy → sidePanel}/utils.d.ts +0 -0
@@ -0,0 +1,114 @@
|
|
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 { AnimationMixer } from "three";
|
15
|
+
import InspectAnimation from "./utils/InspectAnimation";
|
16
|
+
|
17
|
+
export default function Inspector(props: CoreComponentProps) {
|
18
|
+
const [lastRefresh, setLastRefresh] = useState(-1);
|
19
|
+
const [currentObject, setCurrentObject] = useState<RemoteObject>({
|
20
|
+
name: '',
|
21
|
+
uuid: '',
|
22
|
+
type: '',
|
23
|
+
visible: false,
|
24
|
+
matrix: [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1],
|
25
|
+
animations: [],
|
26
|
+
material: undefined,
|
27
|
+
perspectiveCameraInfo: undefined,
|
28
|
+
orthographicCameraInfo: undefined,
|
29
|
+
lightInfo: undefined,
|
30
|
+
});
|
31
|
+
|
32
|
+
useEffect(() => {
|
33
|
+
function onSelectItem(evt: any) {
|
34
|
+
const obj = evt.value as RemoteObject;
|
35
|
+
setCurrentObject(obj);
|
36
|
+
setLastRefresh(Date.now());
|
37
|
+
if (props.three.scene !== undefined) {
|
38
|
+
const child = props.three.scene.getObjectByProperty('uuid', obj.uuid);
|
39
|
+
if (child !== undefined && child.animations.length > 0) {
|
40
|
+
const mixer = new AnimationMixer(child);
|
41
|
+
console.log(mixer);
|
42
|
+
console.log(child.animations);
|
43
|
+
}
|
44
|
+
}
|
45
|
+
}
|
46
|
+
|
47
|
+
debugDispatcher.addEventListener(ToolEvents.SET_OBJECT, onSelectItem);
|
48
|
+
return () => {
|
49
|
+
debugDispatcher.removeEventListener(ToolEvents.SET_OBJECT, onSelectItem);
|
50
|
+
};
|
51
|
+
}, []);
|
52
|
+
|
53
|
+
const objType = currentObject.type.toLowerCase();
|
54
|
+
|
55
|
+
return (
|
56
|
+
<Accordion label='Inspector' key='Inspector'>
|
57
|
+
<div id="Inspector" className={props.class} key={lastRefresh}>
|
58
|
+
{currentObject.uuid.length > 0 && (
|
59
|
+
<>
|
60
|
+
{/* Core */}
|
61
|
+
<>
|
62
|
+
<InspectorField
|
63
|
+
type="string"
|
64
|
+
title="Name"
|
65
|
+
prop="name"
|
66
|
+
value={currentObject.name}
|
67
|
+
disabled={true}
|
68
|
+
/>
|
69
|
+
<InspectorField
|
70
|
+
type="string"
|
71
|
+
title="Type"
|
72
|
+
prop="type"
|
73
|
+
value={currentObject.type}
|
74
|
+
disabled={true}
|
75
|
+
/>
|
76
|
+
<InspectorField
|
77
|
+
type="string"
|
78
|
+
title="UUID"
|
79
|
+
prop="uuid"
|
80
|
+
value={currentObject.uuid}
|
81
|
+
disabled={true}
|
82
|
+
/>
|
83
|
+
<InspectorField
|
84
|
+
type="boolean"
|
85
|
+
title="Visible"
|
86
|
+
prop="visible"
|
87
|
+
value={currentObject.visible}
|
88
|
+
onChange={(key: string, value: any) => {
|
89
|
+
props.three.updateObject(currentObject.uuid, key, value);
|
90
|
+
const child = props.three.scene?.getObjectByProperty('uuid', currentObject.uuid);
|
91
|
+
if (child !== undefined) setItemProps(child, key, value);
|
92
|
+
}}
|
93
|
+
/>
|
94
|
+
</>
|
95
|
+
|
96
|
+
{/* Data */}
|
97
|
+
<>
|
98
|
+
{/* Transform */}
|
99
|
+
{InspectTransform(currentObject, props.three)}
|
100
|
+
{/* Animations */}
|
101
|
+
{currentObject.animations.length > 0 ? InspectAnimation(currentObject, props.three) : null}
|
102
|
+
{/* Cameras */}
|
103
|
+
{objType.search('camera') > -1 ? InspectCamera(currentObject, props.three) : null}
|
104
|
+
{/* Lights */}
|
105
|
+
{objType.search('light') > -1 ? InspectLight(currentObject, props.three) : null}
|
106
|
+
{/* Material */}
|
107
|
+
{objType.search('mesh') > -1 ? InspectMaterial(currentObject, props.three) : null}
|
108
|
+
</>
|
109
|
+
</>
|
110
|
+
)}
|
111
|
+
</div>
|
112
|
+
</Accordion>
|
113
|
+
);
|
114
|
+
}
|
@@ -1,32 +1,42 @@
|
|
1
1
|
import RemoteThree from "@/core/remote/RemoteThree";
|
2
2
|
import { ToolEvents, debugDispatcher } from "@/editor/global";
|
3
3
|
import { useEffect } from "react";
|
4
|
-
import {
|
4
|
+
import { Texture } from "three";
|
5
5
|
import { setItemProps, textureFromSrc } from "../utils";
|
6
6
|
|
7
7
|
export interface SceneInspectorProps {
|
8
|
-
scene: Scene
|
9
8
|
three: RemoteThree
|
10
9
|
}
|
11
10
|
|
12
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
|
+
}
|
13
19
|
const onGetObject = (evt: any) => {
|
14
|
-
|
20
|
+
if (!hasScene()) return;
|
21
|
+
const child = props.three.scene?.getObjectByProperty('uuid', evt.value);
|
15
22
|
if (child !== undefined) props.three.setObject(child);
|
16
23
|
};
|
17
24
|
|
18
25
|
const setChildProps = (uuid: string, key: string, value: any) => {
|
19
|
-
|
26
|
+
if (!hasScene()) return;
|
27
|
+
const child = props.three.scene?.getObjectByProperty('uuid', uuid);
|
20
28
|
if (child !== undefined) setItemProps(child, key, value);
|
21
29
|
};
|
22
30
|
|
23
31
|
const onUpdateObject = (evt: any) => {
|
32
|
+
if (!hasScene()) return;
|
24
33
|
const msg = evt.value;
|
25
34
|
const { key, value, uuid } = msg;
|
26
35
|
setChildProps(uuid, key, value);
|
27
36
|
};
|
28
37
|
|
29
38
|
const onCreateTexture = (evt: any) => {
|
39
|
+
if (!hasScene()) return;
|
30
40
|
const data = evt.value;
|
31
41
|
textureFromSrc(data.value).then((texture: Texture) => {
|
32
42
|
setChildProps(data.uuid, data.key, texture);
|
@@ -34,13 +44,10 @@ export default function SceneInspector(props: SceneInspectorProps) {
|
|
34
44
|
});
|
35
45
|
};
|
36
46
|
|
37
|
-
const onGetScene = () => {
|
38
|
-
props.three.setScene(props.scene);
|
39
|
-
};
|
40
|
-
|
41
47
|
const onRequestMethod = (evt: any) => {
|
48
|
+
if (!hasScene()) return;
|
42
49
|
const { key, uuid, value } = evt.value;
|
43
|
-
const child = props.scene
|
50
|
+
const child = props.three.scene?.getObjectByProperty('uuid', uuid);
|
44
51
|
if (child !== undefined) {
|
45
52
|
try {
|
46
53
|
child[key](value);
|
@@ -55,13 +62,11 @@ export default function SceneInspector(props: SceneInspectorProps) {
|
|
55
62
|
|
56
63
|
useEffect(() => {
|
57
64
|
debugDispatcher.addEventListener(ToolEvents.GET_OBJECT, onGetObject);
|
58
|
-
debugDispatcher.addEventListener(ToolEvents.GET_SCENE, onGetScene);
|
59
65
|
debugDispatcher.addEventListener(ToolEvents.UPDATE_OBJECT, onUpdateObject);
|
60
66
|
debugDispatcher.addEventListener(ToolEvents.CREATE_TEXTURE, onCreateTexture);
|
61
67
|
debugDispatcher.addEventListener(ToolEvents.REQUEST_METHOD, onRequestMethod);
|
62
68
|
return () => {
|
63
69
|
debugDispatcher.removeEventListener(ToolEvents.GET_OBJECT, onGetObject);
|
64
|
-
debugDispatcher.removeEventListener(ToolEvents.GET_SCENE, onGetScene);
|
65
70
|
debugDispatcher.removeEventListener(ToolEvents.UPDATE_OBJECT, onUpdateObject);
|
66
71
|
debugDispatcher.removeEventListener(ToolEvents.CREATE_TEXTURE, onCreateTexture);
|
67
72
|
debugDispatcher.removeEventListener(ToolEvents.REQUEST_METHOD, onRequestMethod);
|
@@ -0,0 +1,51 @@
|
|
1
|
+
import RemoteThree from "@/core/remote/RemoteThree";
|
2
|
+
import InspectorGroup from "../InspectorGroup";
|
3
|
+
import { InspectorFieldProps } from '../InspectorField';
|
4
|
+
import { AnimationClipInfo, RemoteObject } from '../../types';
|
5
|
+
import { setItemProps } from "../../utils";
|
6
|
+
|
7
|
+
export default function InspectAnimation(obj: RemoteObject, three: RemoteThree) {
|
8
|
+
const items: InspectorFieldProps[] = [];
|
9
|
+
obj.animations.forEach((value: AnimationClipInfo) => {
|
10
|
+
// Add animation
|
11
|
+
items.push({
|
12
|
+
title: 'Name',
|
13
|
+
type: 'string',
|
14
|
+
prop: 'name',
|
15
|
+
value: value.name,
|
16
|
+
disabled: true,
|
17
|
+
onChange: (prop: string, value: any) => {
|
18
|
+
three.updateObject(obj.uuid, prop, value);
|
19
|
+
const child = three.scene?.getObjectByProperty('uuid', obj.uuid);
|
20
|
+
if (child !== undefined) setItemProps(child, prop, value);
|
21
|
+
},
|
22
|
+
});
|
23
|
+
items.push({
|
24
|
+
title: 'Duration',
|
25
|
+
type: 'number',
|
26
|
+
prop: 'duration',
|
27
|
+
value: value.duration,
|
28
|
+
disabled: true,
|
29
|
+
onChange: (prop: string, value: any) => {
|
30
|
+
three.updateObject(obj.uuid, prop, value);
|
31
|
+
const child = three.scene?.getObjectByProperty('uuid', obj.uuid);
|
32
|
+
if (child !== undefined) setItemProps(child, prop, value);
|
33
|
+
},
|
34
|
+
});
|
35
|
+
items.push({
|
36
|
+
title: 'Blend Mode',
|
37
|
+
type: 'number',
|
38
|
+
prop: 'blendMode',
|
39
|
+
value: value.blendMode,
|
40
|
+
disabled: true,
|
41
|
+
onChange: (prop: string, value: any) => {
|
42
|
+
three.updateObject(obj.uuid, prop, value);
|
43
|
+
const child = three.scene?.getObjectByProperty('uuid', obj.uuid);
|
44
|
+
if (child !== undefined) setItemProps(child, prop, value);
|
45
|
+
},
|
46
|
+
});
|
47
|
+
});
|
48
|
+
return (
|
49
|
+
<InspectorGroup title="Animations" items={items} />
|
50
|
+
);
|
51
|
+
}
|
@@ -1,8 +1,10 @@
|
|
1
1
|
import { Euler, Matrix4, Vector3 } from 'three';
|
2
|
+
import { degToRad, radToDeg } from 'three/src/math/MathUtils';
|
2
3
|
import InspectorGroup from '../InspectorGroup';
|
3
4
|
import { RemoteObject } from "../../types";
|
4
5
|
import RemoteThree from '@/core/remote/RemoteThree';
|
5
6
|
import { setItemProps } from '../../utils';
|
7
|
+
import { round } from '@/editor/utils';
|
6
8
|
|
7
9
|
export function InspectTransform(obj: RemoteObject, three: RemoteThree) {
|
8
10
|
const matrix = new Matrix4();
|
@@ -22,73 +24,67 @@ export function InspectTransform(obj: RemoteObject, three: RemoteThree) {
|
|
22
24
|
if (child !== undefined) setItemProps(child, prop, value);
|
23
25
|
};
|
24
26
|
|
25
|
-
const
|
26
|
-
|
27
|
-
|
28
|
-
|
27
|
+
const updateRotation = (prop: string, value: any) => {
|
28
|
+
updateTransform(prop, degToRad(value));
|
29
|
+
};
|
30
|
+
|
31
|
+
return (
|
32
|
+
<InspectorGroup
|
33
|
+
title="Transform"
|
34
|
+
items={[
|
29
35
|
{
|
30
|
-
title: 'X',
|
36
|
+
title: 'Position X',
|
31
37
|
prop: 'position.x',
|
32
38
|
type: 'number',
|
33
39
|
value: position.x,
|
34
40
|
onChange: updateTransform,
|
35
41
|
},
|
36
42
|
{
|
37
|
-
title: 'Y',
|
43
|
+
title: 'Position Y',
|
38
44
|
prop: 'position.y',
|
39
45
|
type: 'number',
|
40
46
|
value: position.y,
|
41
47
|
onChange: updateTransform,
|
42
48
|
},
|
43
49
|
{
|
44
|
-
title: 'Z',
|
50
|
+
title: 'Position Z',
|
45
51
|
prop: 'position.z',
|
46
52
|
type: 'number',
|
47
53
|
value: position.z,
|
48
54
|
onChange: updateTransform,
|
49
55
|
},
|
50
|
-
],
|
51
|
-
},
|
52
|
-
{
|
53
|
-
title: 'Rotation',
|
54
|
-
items: [
|
55
56
|
{
|
56
|
-
title: 'X',
|
57
|
+
title: 'Rotation X',
|
57
58
|
prop: 'rotation.x',
|
58
59
|
type: 'number',
|
59
|
-
value: rotation.x,
|
60
|
-
min: -
|
61
|
-
max:
|
62
|
-
step: 0.
|
63
|
-
onChange:
|
60
|
+
value: round(radToDeg(rotation.x)),
|
61
|
+
min: -360,
|
62
|
+
max: 360,
|
63
|
+
step: 0.1,
|
64
|
+
onChange: updateRotation,
|
64
65
|
},
|
65
66
|
{
|
66
|
-
title: 'Y',
|
67
|
+
title: 'Rotation Y',
|
67
68
|
prop: 'rotation.y',
|
68
69
|
type: 'number',
|
69
|
-
value: rotation.y,
|
70
|
-
min: -
|
71
|
-
max:
|
72
|
-
step: 0.
|
73
|
-
onChange:
|
70
|
+
value: round(radToDeg(rotation.y)),
|
71
|
+
min: -360,
|
72
|
+
max: 360,
|
73
|
+
step: 0.1,
|
74
|
+
onChange: updateRotation,
|
74
75
|
},
|
75
76
|
{
|
76
|
-
title: 'Z',
|
77
|
+
title: 'Rotation Z',
|
77
78
|
prop: 'rotation.z',
|
78
79
|
type: 'number',
|
79
|
-
value: rotation.z,
|
80
|
-
min: -
|
81
|
-
max:
|
82
|
-
step: 0.
|
83
|
-
onChange:
|
80
|
+
value: round(radToDeg(rotation.z)),
|
81
|
+
min: -360,
|
82
|
+
max: 360,
|
83
|
+
step: 0.1,
|
84
|
+
onChange: updateRotation,
|
84
85
|
},
|
85
|
-
],
|
86
|
-
},
|
87
|
-
{
|
88
|
-
title: 'Scale',
|
89
|
-
items: [
|
90
86
|
{
|
91
|
-
title: 'X',
|
87
|
+
title: 'Scale X',
|
92
88
|
prop: 'scale.x',
|
93
89
|
type: 'number',
|
94
90
|
value: scale.x,
|
@@ -96,7 +92,7 @@ export function InspectTransform(obj: RemoteObject, three: RemoteThree) {
|
|
96
92
|
onChange: updateTransform,
|
97
93
|
},
|
98
94
|
{
|
99
|
-
title: 'Y',
|
95
|
+
title: 'Scale Y',
|
100
96
|
prop: 'scale.y',
|
101
97
|
type: 'number',
|
102
98
|
value: scale.y,
|
@@ -104,21 +100,14 @@ export function InspectTransform(obj: RemoteObject, three: RemoteThree) {
|
|
104
100
|
onChange: updateTransform,
|
105
101
|
},
|
106
102
|
{
|
107
|
-
title: 'Z',
|
103
|
+
title: 'Scale Z',
|
108
104
|
prop: 'scale.z',
|
109
105
|
type: 'number',
|
110
106
|
value: scale.z,
|
111
107
|
step: 0.01,
|
112
108
|
onChange: updateTransform,
|
113
109
|
},
|
114
|
-
]
|
115
|
-
},
|
116
|
-
];
|
117
|
-
|
118
|
-
return (
|
119
|
-
<InspectorGroup
|
120
|
-
title="Transform"
|
121
|
-
items={items}
|
110
|
+
]}
|
122
111
|
/>
|
123
112
|
);
|
124
113
|
}
|
@@ -11,7 +11,7 @@ export interface ChildObjectProps extends CoreComponentProps {
|
|
11
11
|
three: RemoteThree
|
12
12
|
}
|
13
13
|
|
14
|
-
export interface
|
14
|
+
export interface SidePanelState {
|
15
15
|
scene?: Object3D
|
16
16
|
three: RemoteThree
|
17
17
|
}
|
@@ -71,6 +71,14 @@ export interface RemoteMaterial {
|
|
71
71
|
specularColor?: Color
|
72
72
|
}
|
73
73
|
|
74
|
+
// Animation Info
|
75
|
+
|
76
|
+
export interface AnimationClipInfo {
|
77
|
+
name: string;
|
78
|
+
duration: number;
|
79
|
+
blendMode: number;
|
80
|
+
}
|
81
|
+
|
74
82
|
// Camera Info
|
75
83
|
|
76
84
|
export interface PerspectiveCameraInfo {
|
@@ -114,6 +122,7 @@ export interface RemoteObject {
|
|
114
122
|
type: string
|
115
123
|
visible: boolean
|
116
124
|
matrix: number[] // based on Matrix4.elements
|
125
|
+
animations: AnimationClipInfo[]
|
117
126
|
material?: RemoteMaterial | RemoteMaterial[]
|
118
127
|
perspectiveCameraInfo?: PerspectiveCameraInfo
|
119
128
|
orthographicCameraInfo?: OrthographicCameraInfo
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { CubeTexture, Material, Mesh, Object3D, RepeatWrapping, Texture } from 'three';
|
1
|
+
import { AnimationClip, CubeTexture, Material, Mesh, Object3D, RepeatWrapping, Texture } from 'three';
|
2
2
|
import { MinimumObject, RemoteMaterial, RemoteObject } from './types';
|
3
3
|
|
4
4
|
export function determineIcon(obj: Object3D): string {
|
@@ -132,14 +132,23 @@ export function stripObject(obj: Object3D): RemoteObject {
|
|
132
132
|
uuid: obj.uuid,
|
133
133
|
visible: obj.visible,
|
134
134
|
matrix: obj.matrix.elements,
|
135
|
+
animations: [],
|
135
136
|
material: undefined,
|
136
137
|
perspectiveCameraInfo: undefined,
|
137
138
|
orthographicCameraInfo: undefined,
|
138
139
|
lightInfo: undefined,
|
139
140
|
};
|
140
141
|
|
141
|
-
|
142
|
+
// Animations
|
143
|
+
obj.animations.forEach((clip: AnimationClip) => {
|
144
|
+
stripped.animations.push({
|
145
|
+
name: clip.name,
|
146
|
+
duration: clip.duration,
|
147
|
+
blendMode: clip.blendMode,
|
148
|
+
});
|
149
|
+
});
|
142
150
|
|
151
|
+
const type = obj.type.toLowerCase();
|
143
152
|
if (type.search('mesh') > -1) {
|
144
153
|
const mesh = obj as Mesh;
|
145
154
|
if (Array.isArray(mesh.material)) {
|
package/src/editor/utils.ts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import { Object3D } from "three";
|
1
|
+
import { Material, Mesh, Object3D, PositionalAudio, Texture } from "three";
|
2
2
|
|
3
3
|
export function clamp(min: number, max: number, value: number) {
|
4
4
|
return Math.min(max, Math.max(min, value));
|
@@ -38,20 +38,76 @@ export function colorToHex(obj: any) {
|
|
38
38
|
return '#' + red + green + blue;
|
39
39
|
}
|
40
40
|
|
41
|
-
|
41
|
+
export function round(value: number, precision: number = 1): number {
|
42
|
+
return Number(value.toFixed(precision));
|
43
|
+
}
|
44
|
+
|
45
|
+
export let totalThreeObjects = 0;
|
46
|
+
export const resetThreeObjects = () => {
|
47
|
+
totalThreeObjects = 0;
|
48
|
+
};
|
42
49
|
export const hierarchyUUID = (object: Object3D): void => {
|
43
50
|
if (!object) return;
|
44
51
|
|
45
52
|
let uuid = object.name.replace(' ', '');
|
46
53
|
// fallback in case there's no name
|
47
|
-
if (uuid.length === 0)
|
54
|
+
if (uuid.length === 0) {
|
55
|
+
uuid = `obj_${totalThreeObjects}`;
|
56
|
+
totalThreeObjects++;
|
57
|
+
}
|
48
58
|
// inherit parent's UUID for hierarchy
|
49
59
|
if (object.parent !== null) uuid = `${object.parent.uuid}.${uuid}`;
|
50
60
|
object.uuid = uuid;
|
51
|
-
totalObjects++;
|
52
61
|
|
53
62
|
// Iterate children
|
54
63
|
object.children.forEach((child: Object3D) => {
|
55
64
|
hierarchyUUID(child);
|
56
65
|
});
|
57
66
|
};
|
67
|
+
|
68
|
+
// Dispose
|
69
|
+
|
70
|
+
export const disposeTexture = (texture?: Texture): void => {
|
71
|
+
texture?.dispose();
|
72
|
+
};
|
73
|
+
|
74
|
+
// Dispose material
|
75
|
+
export const disposeMaterial = (material?: Material | Material[]): void => {
|
76
|
+
if (!material) return;
|
77
|
+
|
78
|
+
if (Array.isArray(material)) {
|
79
|
+
material.forEach((mat: Material) => mat.dispose());
|
80
|
+
} else {
|
81
|
+
material.dispose();
|
82
|
+
}
|
83
|
+
};
|
84
|
+
|
85
|
+
// Dispose object
|
86
|
+
export const dispose = (object: Object3D): void => {
|
87
|
+
if (!object) return;
|
88
|
+
|
89
|
+
// Dispose children
|
90
|
+
while (object.children.length > 0) {
|
91
|
+
const child = object.children[0];
|
92
|
+
if (child instanceof PositionalAudio) {
|
93
|
+
child.pause();
|
94
|
+
if (child.parent) {
|
95
|
+
child.parent.remove(child);
|
96
|
+
}
|
97
|
+
} else {
|
98
|
+
dispose(child);
|
99
|
+
}
|
100
|
+
}
|
101
|
+
|
102
|
+
// Dispose object
|
103
|
+
if (object.parent) object.parent.remove(object);
|
104
|
+
// @ts-ignore
|
105
|
+
if (object.isMesh) {
|
106
|
+
const mesh = object as Mesh;
|
107
|
+
mesh.geometry?.dispose();
|
108
|
+
disposeMaterial(mesh.material);
|
109
|
+
}
|
110
|
+
|
111
|
+
// @ts-ignore
|
112
|
+
if (object.dispose !== undefined) object.dispose();
|
113
|
+
};
|
package/src/index.ts
CHANGED
@@ -15,13 +15,13 @@ export { default as DropdownItem } from './editor/components/DropdownItem';
|
|
15
15
|
export { default as Dropdown } from './editor/components/Dropdown';
|
16
16
|
export { default as RemoteController } from './core/RemoteController';
|
17
17
|
// RemoteThree
|
18
|
-
export { default as InfiniteGridHelper } from './editor/
|
19
|
-
export { default as UVMaterial } from './editor/
|
20
|
-
export { default as
|
21
|
-
export { default as Accordion } from './editor/
|
22
|
-
export { default as ChildObject } from './editor/
|
23
|
-
export { default as ContainerObject } from './editor/
|
24
|
-
export { default as Inspector } from './editor/
|
25
|
-
export { default as SceneInspector } from './editor/
|
26
|
-
export { default as MultiView } from './editor/
|
18
|
+
export { default as InfiniteGridHelper } from './editor/multiView/InfiniteGridHelper';
|
19
|
+
export { default as UVMaterial } from './editor/multiView/UVMaterial';
|
20
|
+
export { default as SidePanel } from './editor/sidePanel/SidePanel';
|
21
|
+
export { default as Accordion } from './editor/sidePanel/Accordion';
|
22
|
+
export { default as ChildObject } from './editor/sidePanel/ChildObject';
|
23
|
+
export { default as ContainerObject } from './editor/sidePanel/ContainerObject';
|
24
|
+
export { default as Inspector } from './editor/sidePanel/inspector/Inspector';
|
25
|
+
export { default as SceneInspector } from './editor/sidePanel/inspector/SceneInspector';
|
26
|
+
export { default as MultiView } from './editor/multiView/MultiView';
|
27
27
|
export { default as Editor } from './editor/Editor';
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { Scene } from 'three';
|
1
|
+
import { Camera, Scene } from 'three';
|
2
2
|
import BaseRemote from './BaseRemote';
|
3
3
|
export default class RemoteThree extends BaseRemote {
|
4
4
|
scene?: Scene;
|
@@ -7,6 +7,7 @@ export default class RemoteThree extends BaseRemote {
|
|
7
7
|
requestMethod(uuid: string, key: string, value?: any): void;
|
8
8
|
updateObject(uuid: string, key: string, value: any): void;
|
9
9
|
createTexture(uuid: string, key: string, value: any): void;
|
10
|
-
getScene(): void;
|
11
10
|
setScene(value: Scene): void;
|
11
|
+
addCamera(camera: Camera): void;
|
12
|
+
removeCamera(camera: Camera): void;
|
12
13
|
}
|
package/types/core/types.d.ts
CHANGED
@@ -6,7 +6,7 @@ export interface BroadcastData {
|
|
6
6
|
export type ApplicationMode = 'app' | 'editor';
|
7
7
|
export type VoidCallback = () => void;
|
8
8
|
export type DataUpdateCallback = (data: any) => void;
|
9
|
-
export type EditorEvent = 'custom' | 'setSheet' | 'setSheetObject' | 'updateSheetObject' | 'updateTimeline' | 'getObject' | 'setObject' | 'updateObject' | '
|
9
|
+
export type EditorEvent = 'custom' | 'setSheet' | 'setSheetObject' | 'updateSheetObject' | 'updateTimeline' | 'getObject' | 'setObject' | 'updateObject' | 'setScene' | 'createTexture' | 'requestMethod' | 'addCamera' | 'removeCamera' | 'addFolder' | 'bindObject' | 'updateBind' | 'addButton' | 'clickButton' | 'selectComponent' | 'draggableListUpdate';
|
10
10
|
export type VoidFunc = () => void;
|
11
11
|
export type BroadcastCallback = (data: BroadcastData) => void;
|
12
12
|
export type TheatreUpdateCallback = (data: any) => void;
|
package/types/editor/global.d.ts
CHANGED
@@ -4,11 +4,12 @@ export declare const ToolEvents: {
|
|
4
4
|
CUSTOM: string;
|
5
5
|
SELECT_DROPDOWN: string;
|
6
6
|
DRAG_UPDATE: string;
|
7
|
-
GET_SCENE: string;
|
8
7
|
SET_SCENE: string;
|
9
8
|
GET_OBJECT: string;
|
10
9
|
SET_OBJECT: string;
|
11
10
|
UPDATE_OBJECT: string;
|
12
11
|
CREATE_TEXTURE: string;
|
13
12
|
REQUEST_METHOD: string;
|
13
|
+
ADD_CAMERA: string;
|
14
|
+
REMOVE_CAMERA: string;
|
14
15
|
};
|
@@ -1,10 +1,8 @@
|
|
1
|
-
import { Camera, Scene, WebGLRenderer } from 'three';
|
2
1
|
import { MultiViewMode } from './MultiViewData';
|
3
2
|
import './MultiView.scss';
|
3
|
+
import RemoteThree from '@/core/remote/RemoteThree';
|
4
4
|
interface MultiViewProps {
|
5
|
-
|
6
|
-
renderer: WebGLRenderer;
|
7
|
-
cameras: Camera[];
|
5
|
+
three: RemoteThree;
|
8
6
|
mode?: MultiViewMode;
|
9
7
|
}
|
10
8
|
export default function MultiView(props: MultiViewProps): import("react/jsx-runtime").JSX.Element;
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { Camera, CameraHelper, MeshBasicMaterial, MeshNormalMaterial, OrthographicCamera, PerspectiveCamera, Vector3 } from 'three';
|
1
|
+
import { Camera, CameraHelper, MeshBasicMaterial, MeshDepthMaterial, MeshNormalMaterial, OrthographicCamera, PerspectiveCamera, Vector3 } from 'three';
|
2
2
|
import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls';
|
3
3
|
import UVMaterial from './UVMaterial';
|
4
4
|
export type MultiViewMode = 'Single' | 'Side by Side' | 'Stacked' | 'Quad';
|
@@ -6,11 +6,11 @@ export declare const ModeOptions: MultiViewMode[];
|
|
6
6
|
export declare const cameras: Map<string, Camera>;
|
7
7
|
export declare const controls: Map<string, OrbitControls>;
|
8
8
|
export declare const helpers: Map<string, CameraHelper>;
|
9
|
-
export declare const cameraOptions: string[];
|
10
9
|
export declare function createOrtho(name: string, position: Vector3): OrthographicCamera;
|
11
10
|
export declare const debugCamera: PerspectiveCamera;
|
12
|
-
export type RenderMode = '
|
11
|
+
export type RenderMode = 'Depth' | 'Normals' | 'Renderer' | 'UVs' | 'Wireframe';
|
13
12
|
export declare const renderOptions: RenderMode[];
|
13
|
+
export declare const depthMaterial: MeshDepthMaterial;
|
14
14
|
export declare const normalsMaterial: MeshNormalMaterial;
|
15
|
-
export declare const wireframeMaterial: MeshBasicMaterial;
|
16
15
|
export declare const uvMaterial: UVMaterial;
|
16
|
+
export declare const wireframeMaterial: MeshBasicMaterial;
|
@@ -0,0 +1,11 @@
|
|
1
|
+
import { Component, ReactNode } from 'react';
|
2
|
+
import '../scss/_sidePanel.scss';
|
3
|
+
import { SidePanelState } from './types';
|
4
|
+
export default class SidePanel extends Component<SidePanelState> {
|
5
|
+
private three;
|
6
|
+
constructor(props: SidePanelState);
|
7
|
+
componentWillUnmount(): void;
|
8
|
+
render(): ReactNode;
|
9
|
+
private setScene;
|
10
|
+
get componentState(): SidePanelState;
|
11
|
+
}
|