@tomorrowevening/hermes 0.1.39 → 0.1.41
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/{ThreeEditor-CTkjs-SY.js → ThreeEditor-jkqfXLb4.js} +16 -16
- package/dist/core/Application.js +77 -0
- package/dist/core/remote/BaseRemote.js +33 -0
- package/dist/core/remote/RemoteTheatre.js +253 -0
- package/dist/core/remote/RemoteThree.js +451 -0
- package/dist/core/types.js +7 -0
- package/dist/editor/Editor.js +12 -0
- package/dist/editor/HermesApp.js +24 -0
- package/dist/editor/ThreeEditor.js +25 -0
- package/dist/editor/components/Draggable.js +40 -0
- package/dist/editor/components/DraggableItem.js +25 -0
- package/dist/editor/components/Dropdown.js +32 -0
- package/dist/editor/components/DropdownItem.js +50 -0
- package/dist/editor/components/NavButton.js +7 -0
- package/dist/editor/components/content.js +4 -0
- package/dist/editor/components/icons/CloseIcon.js +9 -0
- package/dist/editor/components/icons/DragIcon.js +12 -0
- package/dist/editor/multiView/CameraWindow.js +64 -0
- package/dist/editor/multiView/DepthNodeMaterial.js +12 -0
- package/dist/editor/multiView/InfiniteGridHelper.js +31 -0
- package/dist/editor/multiView/InfiniteGridHelperGPU.js +31 -0
- package/dist/editor/multiView/InfiniteGridMaterial.js +137 -0
- package/dist/editor/multiView/InfiniteGridNodeMaterial.js +63 -0
- package/dist/editor/multiView/MultiView.js +890 -0
- package/dist/editor/multiView/Toggle.js +25 -0
- package/dist/editor/multiView/UVMaterial.js +60 -0
- package/dist/editor/multiView/UVNodeMaterial.js +10 -0
- package/dist/editor/sidePanel/Accordion.js +56 -0
- package/dist/editor/sidePanel/ChildObject.js +78 -0
- package/dist/editor/sidePanel/ContainerObject.js +11 -0
- package/dist/editor/sidePanel/DebugData.js +133 -0
- package/dist/editor/sidePanel/SidePanel.js +91 -0
- package/dist/editor/sidePanel/inspector/InspectGrid3.js +82 -0
- package/dist/editor/sidePanel/inspector/InspectGrid4.js +58 -0
- package/dist/editor/sidePanel/inspector/InspectImage.js +100 -0
- package/dist/editor/sidePanel/inspector/InspectNumber.js +76 -0
- package/dist/editor/sidePanel/inspector/InspectVector2.js +154 -0
- package/dist/editor/sidePanel/inspector/Inspector.js +95 -0
- package/dist/editor/sidePanel/inspector/InspectorField.js +128 -0
- package/dist/editor/sidePanel/inspector/InspectorGroup.js +110 -0
- package/dist/editor/sidePanel/inspector/utils/DragNumber.js +27 -0
- package/dist/editor/sidePanel/inspector/utils/InspectAnimation.js +99 -0
- package/dist/editor/sidePanel/inspector/utils/InspectCamera.js +91 -0
- package/dist/editor/sidePanel/inspector/utils/InspectLight.js +85 -0
- package/dist/editor/sidePanel/inspector/utils/InspectMaterial.js +861 -0
- package/dist/editor/sidePanel/inspector/utils/InspectTransform.js +93 -0
- package/dist/editor/sidePanel/utils.js +259 -0
- package/dist/editor/tools/Transform.js +77 -0
- package/dist/editor/tools/splineEditor/Spline.js +348 -0
- package/dist/editor/tools/splineEditor/index.js +193 -0
- package/dist/editor/utils.js +27 -0
- package/dist/hermes.cjs.js +8 -30
- package/dist/{index-BpKOzCuX.js → index-DZmiM5y-.js} +617 -617
- package/dist/index.html +1 -1
- package/dist/index.js +125 -0
- package/dist/utils/ImageSequenceCapturer.js +148 -0
- package/dist/utils/detectSettings.js +46 -0
- package/dist/utils/math.js +68 -0
- package/dist/utils/post.js +206 -0
- package/dist/utils/theatre.js +316 -0
- package/dist/utils/three.js +199 -0
- package/dist/webworkers/EventHandling.js +115 -0
- package/dist/webworkers/ProxyManager.js +76 -0
- package/package.json +13 -7
- package/types/core/remote/RemoteThree.d.ts +10 -1
- package/dist/.vite/manifest.json +0 -12
- package/dist/hermes.es.js +0 -8077
|
@@ -0,0 +1,890 @@
|
|
|
1
|
+
import { jsxs as b, jsx as h, Fragment as v } from "react/jsx-runtime";
|
|
2
|
+
import { Component as O, createRef as C } from "react";
|
|
3
|
+
import { Group as L, AxesHelper as D, MeshBasicMaterial as x, Raycaster as R, Vector2 as w, Scene as U, Sphere as B, Box3 as F, Spherical as G, Matrix4 as P, Quaternion as z, Vector4 as _, Vector3 as c, WebGPURenderer as A, MeshNormalNodeMaterial as Q, PerspectiveCamera as E, OrthographicCamera as M, CameraHelper as q, Mesh as K, SkinnedMesh as N, SpotLightHelper as $, PointLightHelper as Y, HemisphereLightHelper as J, DirectionalLightHelper as X } from "three/webgpu";
|
|
4
|
+
import { WebGLRenderer as T } from "three";
|
|
5
|
+
import { RectAreaLightHelper as j } from "three/examples/jsm/helpers/RectAreaLightHelper.js";
|
|
6
|
+
import { OrbitControls as Z } from "three/examples/jsm/controls/OrbitControls.js";
|
|
7
|
+
import { mapLinear as g, degToRad as H } from "three/src/math/MathUtils.js";
|
|
8
|
+
import p from "camera-controls";
|
|
9
|
+
import { ToolEvents as o } from "../../core/remote/RemoteThree.js";
|
|
10
|
+
import u, { Dropdown as V } from "./CameraWindow.js";
|
|
11
|
+
import ee from "./InfiniteGridHelper.js";
|
|
12
|
+
import te from "./InfiniteGridHelperGPU.js";
|
|
13
|
+
/* empty css */
|
|
14
|
+
import S from "../sidePanel/DebugData.js";
|
|
15
|
+
import { InspectTransform as ie } from "../sidePanel/inspector/utils/InspectTransform.js";
|
|
16
|
+
import I from "./Toggle.js";
|
|
17
|
+
import se from "./DepthNodeMaterial.js";
|
|
18
|
+
import re from "./UVNodeMaterial.js";
|
|
19
|
+
import ae from "../tools/splineEditor/index.js";
|
|
20
|
+
import m from "../tools/Transform.js";
|
|
21
|
+
import { mix as ne } from "../../utils/math.js";
|
|
22
|
+
import { dispose as y } from "../../utils/three.js";
|
|
23
|
+
const W = [
|
|
24
|
+
"Single",
|
|
25
|
+
"Side by Side",
|
|
26
|
+
"Stacked",
|
|
27
|
+
"Quad"
|
|
28
|
+
], oe = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAYAAACM/rhtAAAACXBIWXMAAAsTAAALEwEAmpwYAAAC60lEQVRYhe2YT4hNcRTHP48xpmYaNAvRyEQxEhnKQljYsRm9/EmSyJiMFAsMZWNhJYoNIUVJ2VGiyb9ZzIpMpkQSahbGv9GMYWrM+1rc2zjvzvvdd+99rzdvMd+6de75nd+5387vnN/v/G5KEuWMKRNNIB8mCRaKiiL5qQb2ApuBuUAV0Ad0AJeB3sSeJRX6LJbULTf6JTUn9Z+KWMUpPyp/Avoa4CNQZ3Sj/lNpdL/xottR7AjOkHRUUpekN5I6JbVLavDH75lIfZN0UFKTpCWS0pJem/HeJBEMG6yV1ONYtgFJbZJ+GF1jDh+zJb03NuliEuwMkMo4yErS2RA/LcbuYVyCrm1mA7Dal/8Cu4FG4JD/HsTTkCy6a+SVMTPQuc1sBKb78nHghi+/A+YBxwL2lbhRY+ThuARdEVxu5JdGFvACr0otdoZ8Y4+Rn0Sn5sFFsMvI6YB9MzA1YJ8mN8k1wAHzfj4uQVdyrpI0aJL7oqTtkq4FiqPLyCOSbktqlbRL0jlJQ2b8QdwCUZ4qvhRStZL0XFK1pMd57CRvq5mfhKBriRfiFUMY6oD7eOdwPlQAN4G10dfWg+uouwXsiOssAj4AC+JMcEWwvnAuOTEr7gTXPmg34zagOwkbIIOXAo9CbDYBrcBXYN+4UUdy2sRflyS5zVNlfPX7ugpJW5V9nI7mmh+lYU0lCZ2B3TOnAVuAk0BTwC5nuhWro46KauBOQJch5OpRaoIW34GreGf+YZdRqS9NAj4Bp4ClQDvwOWxCqSM4ADQEdKE5XvbXzlITrAVe4TW+M6NMKDXBFLAMuAD0ACfIc7pMZBXXA2cY3/xmodQRHAL2A2+NLtj8ZiEKwUL/z2WMPAJcAVYALWSf8dZuDFGWeBHwKxm3sWYhiGG8Tfo6sA2vSfiSy4GrH3wGrDcfKSSKKf6v1E9yF0XK9Q1XBPuMXMw8HXTonQFwETwNzMFr64v1jzgFHIk9ybHEZYPJo65QlD3Bf2/Q/eaHPiSWAAAAAElFTkSuQmCC", he = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAYAAACM/rhtAAAACXBIWXMAAAsTAAALEwEAmpwYAAAETklEQVRYhe2YXYhVVRTHf3d0/JhyUrMpFbImM+whSa3Mynww+4AeIgiKoozooQ+KyMyXIAujF6OXqHyI6iEKKYgIP/owsjSFqCkprdDUTEcjbWZ0HHV+Pex1ucfb9Z57Z9REXHA4Z++99l7/s/ZZ/7X2KaiczNLwfwPIk9MA+yunNMAG4DHgV+BvoB3YFff2TPstYEyfrajVroI6Sr1GvahsbJC63HzZq04pmztSvU5tVRuqYRiYg78JeBR4HPg5ntdmxovz9wJfA3uAxuibDLQCA+IqynnAQuBuYCnwMLC1rx48U12U8cZqdWqMDcx4cI16qTpYbVKHqa+ovWUeHKsujn7VL9ULq2HI+wY7gVeBJdGeFu3J4ZUiy/cAXeHRRuAQsC/GC0B3eG4BcH/0tUV7czUAeVsMsBF4Kha9HZgCvAncAuwPnXHA0wFuGLANuDrGuoGDwFxgTqzzQ7RX5FrP2eLsdb76vnogtme6+nE8H1YPlQXHwbi3q9eqn0e7Tb25VrsF68vFY0lb1AGcDTwItGQ8tQM4AIwGmqP/EPAu8A0wElgJfFGzxTo8mKWXu9Rd4ZF96jvqjSbauEC9Sn1O3R463epLaku99voCsFXdkAH3kNpcQW+IiT/bQne3eufxBtioPqP2mKhioXpWzpxb1T8C5Ifh4ZptVoriRmAIKdrI3Lujf3bobAPeJpF0NVkKrAFuI9HTOBIxnxFrF4OgQKKr/dnJlQA+AcwABgOHA4zAamA5cE7orQL+zAEHiWI+A2bFC7aSguheYCgpqAphZz3wSB7AecCICv2TgH8oFRib4gVqka0k0h8CXAxMBW6ooDejFoCvA9OBQUAvKWM0kDz4XUZvNKXtyZMWUl7vBbaQXq457PeEziDgx/KJlQAuIPFdMcEXv5OdYWBP9M8k8VpnDQCvB4aTSrCNJB5cSdrW3tBpIJVnR0qdUTxAfdGUOVTnmwqEanNmqltC/9OgqePKg5eom8PgdvW+oJ9Kupera0O3U50TL3lcAaI+oHaF4R3qa6Z822wq0Saq89T1lmSxOrxeW/Xm4uGkiqQDmECKuKHxHW0HdpMiewSpvGqKeR8Ay0iBsYIjg6261PE2o9Q3Yqv+MqWxO9R1Hl12qs+q49Vlppy82pSr+5xJKsko4AXgHlJ0t5NIeg3wLXAlqZhtIUV8J6nmWwX8QiLjdhL5TwMWkY4R6/rrwYKlMr1Y321QZ/vfwBijPqm+rF4Wc7PjE9QllurGVeoV5gRNHsAm9fnMom3qrKPoTjKdMXaYyrFygEWQ72XWW24qhPu8xcUc2UU6O8wFPjmK7jhgPHAuMJGUGQ6U6WwE5sfzTXGvei7KA9hFOiR9D/wOfFVFt4dS2tpfRe83Ur7/CPiJakfOGgBCypubatArl2r8VfOax/LfzABKtePAzHO/5FgC7KBEzB2kOrDfUm8mOeFySv9+OyFyGmB/5aQH+C9BVKmVCNuMZgAAAABJRU5ErkJggg==", le = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABUAAAAVCAYAAACpF6WWAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAQ0lEQVQ4jWP8////fwYqAxYozUhFM/8zkaKYWIWkGEq0b0ZdSjQY5i79TyWagRGaTUdzFEEw6lLqGzqwLoVVJ1StpwA9sBwbUqAh5gAAAABJRU5ErkJggg==";
|
|
29
|
+
class k extends O {
|
|
30
|
+
static instance = null;
|
|
31
|
+
scene;
|
|
32
|
+
renderer;
|
|
33
|
+
currentScene;
|
|
34
|
+
scenes = /* @__PURE__ */ new Map();
|
|
35
|
+
cameras = /* @__PURE__ */ new Map();
|
|
36
|
+
controls = /* @__PURE__ */ new Map();
|
|
37
|
+
currentCamera;
|
|
38
|
+
currentWindow;
|
|
39
|
+
// RefObject to one of the "windows"
|
|
40
|
+
helpersContainer = new L();
|
|
41
|
+
grid;
|
|
42
|
+
cameraHelpers = /* @__PURE__ */ new Map();
|
|
43
|
+
lightHelpers = /* @__PURE__ */ new Map();
|
|
44
|
+
interactionHelper = new D(25);
|
|
45
|
+
currentTransform;
|
|
46
|
+
// Tools
|
|
47
|
+
splineEditor;
|
|
48
|
+
// Override Materials
|
|
49
|
+
depthMaterial;
|
|
50
|
+
normalsMaterial;
|
|
51
|
+
uvMaterial;
|
|
52
|
+
wireframeMaterial = new x({
|
|
53
|
+
opacity: 0.33,
|
|
54
|
+
transparent: !0,
|
|
55
|
+
wireframe: !0
|
|
56
|
+
});
|
|
57
|
+
// Playback
|
|
58
|
+
playing = !1;
|
|
59
|
+
rafID = -1;
|
|
60
|
+
cameraControlsRafID = -1;
|
|
61
|
+
width = 0;
|
|
62
|
+
height = 0;
|
|
63
|
+
// Windows
|
|
64
|
+
tlCam = null;
|
|
65
|
+
trCam = null;
|
|
66
|
+
blCam = null;
|
|
67
|
+
brCam = null;
|
|
68
|
+
tlRender = "Renderer";
|
|
69
|
+
trRender = "Renderer";
|
|
70
|
+
blRender = "Renderer";
|
|
71
|
+
brRender = "Renderer";
|
|
72
|
+
cameraVisibility = !0;
|
|
73
|
+
lightVisibility = !0;
|
|
74
|
+
gridVisibility = !0;
|
|
75
|
+
rendererReady = !1;
|
|
76
|
+
// Interactions
|
|
77
|
+
selectedItem = void 0;
|
|
78
|
+
cameraControlsStartTime = 0;
|
|
79
|
+
cameraControlsLastTime = 0;
|
|
80
|
+
debugCamera;
|
|
81
|
+
raycaster = new R();
|
|
82
|
+
pointer = new w();
|
|
83
|
+
cameraControls = void 0;
|
|
84
|
+
// References
|
|
85
|
+
canvasRef;
|
|
86
|
+
containerRef;
|
|
87
|
+
tlWindow;
|
|
88
|
+
trWindow;
|
|
89
|
+
blWindow;
|
|
90
|
+
brWindow;
|
|
91
|
+
editorCameras = [
|
|
92
|
+
"Top",
|
|
93
|
+
"Bottom",
|
|
94
|
+
"Left",
|
|
95
|
+
"Right",
|
|
96
|
+
"Front",
|
|
97
|
+
"Back",
|
|
98
|
+
"Orthographic",
|
|
99
|
+
"UI",
|
|
100
|
+
"Debug"
|
|
101
|
+
];
|
|
102
|
+
constructor(i) {
|
|
103
|
+
super(i), this.props.three.addEventListener(o.ADD_RENDERER, this.setupRenderer), this.scene = new U(), this.scene.name = this.scene.uuid = "", this.canvasRef = C(), this.containerRef = C(), this.tlWindow = C(), this.trWindow = C(), this.blWindow = C(), this.brWindow = C();
|
|
104
|
+
const e = i.three.name, t = localStorage, s = t.getItem(`${e}_mode`);
|
|
105
|
+
this.state = {
|
|
106
|
+
mode: s !== null ? s : "Single",
|
|
107
|
+
modeOpen: !1,
|
|
108
|
+
renderModeOpen: !1,
|
|
109
|
+
interactionMode: "Orbit",
|
|
110
|
+
interactionModeOpen: !1,
|
|
111
|
+
lastUpdate: Date.now()
|
|
112
|
+
}, t.setItem(`${e}_mode`, this.state.mode), t.setItem(`${e}_tlCam`, t.getItem(`${e}_tlCam`) !== null ? t.getItem(`${e}_tlCam`) : "Debug"), t.setItem(`${e}_trCam`, t.getItem(`${e}_trCam`) !== null ? t.getItem(`${e}_trCam`) : "Orthographic"), t.setItem(`${e}_blCam`, t.getItem(`${e}_blCam`) !== null ? t.getItem(`${e}_blCam`) : "Front"), t.setItem(`${e}_brCam`, t.getItem(`${e}_brCam`) !== null ? t.getItem(`${e}_brCam`) : "Top"), t.setItem(`${e}_tlRender`, t.getItem(`${e}_tlRender`) !== null ? t.getItem(`${e}_tlRender`) : "Renderer"), t.setItem(`${e}_trRender`, t.getItem(`${e}_trRender`) !== null ? t.getItem(`${e}_trRender`) : "Renderer"), t.setItem(`${e}_blRender`, t.getItem(`${e}_blRender`) !== null ? t.getItem(`${e}_blRender`) : "Renderer"), t.setItem(`${e}_brRender`, t.getItem(`${e}_brRender`) !== null ? t.getItem(`${e}_brRender`) : "Renderer");
|
|
113
|
+
const a = {
|
|
114
|
+
Vector2: w,
|
|
115
|
+
Vector3: c,
|
|
116
|
+
Vector4: _,
|
|
117
|
+
Quaternion: z,
|
|
118
|
+
Matrix4: P,
|
|
119
|
+
Spherical: G,
|
|
120
|
+
Box3: F,
|
|
121
|
+
Sphere: B,
|
|
122
|
+
Raycaster: R
|
|
123
|
+
};
|
|
124
|
+
p.install({ THREE: a });
|
|
125
|
+
const r = localStorage.getItem(this.expandedCameraVisibility);
|
|
126
|
+
r !== null && (this.cameraVisibility = r === "open"), this.saveExpandedCameraVisibility();
|
|
127
|
+
const n = localStorage.getItem(this.expandedLightVisibility);
|
|
128
|
+
n !== null && (this.lightVisibility = n === "open"), this.saveExpandedLightVisibility();
|
|
129
|
+
const d = localStorage.getItem(this.expandedGridVisibility);
|
|
130
|
+
d !== null && (this.gridVisibility = d === "open"), this.grid && (this.grid.visible = this.gridVisibility), this.saveExpandedGridVisibility(), k.instance = this;
|
|
131
|
+
}
|
|
132
|
+
componentDidMount() {
|
|
133
|
+
this.setupScene(), this.setupTools(), this.enable(), this.assignControls(), this.resize(), this.play(), m.instance.setApp(this.props.three), m.instance.activeCamera = this.debugCamera, this.props.three.requestRenderer();
|
|
134
|
+
}
|
|
135
|
+
componentDidUpdate(i, e, t) {
|
|
136
|
+
e.mode !== this.state.mode && (this.assignControls(), this.resize());
|
|
137
|
+
}
|
|
138
|
+
componentWillUnmount() {
|
|
139
|
+
this.disable(), this.clear(), S.removeEditorGroup("View Settings");
|
|
140
|
+
}
|
|
141
|
+
render() {
|
|
142
|
+
const i = [];
|
|
143
|
+
return this.cameras.forEach((e, t) => {
|
|
144
|
+
i.push(t);
|
|
145
|
+
}), /* @__PURE__ */ b("div", { className: "multiview", children: [
|
|
146
|
+
/* @__PURE__ */ h("canvas", { ref: this.canvasRef }),
|
|
147
|
+
/* @__PURE__ */ b("div", { className: `cameras ${this.state.mode === "Single" || this.state.mode === "Stacked" ? "single" : ""}`, ref: this.containerRef, children: [
|
|
148
|
+
this.state.mode === "Single" && /* @__PURE__ */ h(v, { children: /* @__PURE__ */ h(
|
|
149
|
+
u,
|
|
150
|
+
{
|
|
151
|
+
name: "tl",
|
|
152
|
+
camera: this.tlCam,
|
|
153
|
+
options: i,
|
|
154
|
+
ref: this.tlWindow,
|
|
155
|
+
onSelectCamera: (e) => {
|
|
156
|
+
this.controls.get(this.tlCam.name)?.dispose();
|
|
157
|
+
const t = this.cameras.get(e);
|
|
158
|
+
t !== void 0 && (this.clearCamera(this.tlCam), this.tlCam = t, localStorage.setItem(`${this.appID}_tlCam`, t.name), this.createControls(t, this.tlWindow.current));
|
|
159
|
+
},
|
|
160
|
+
onSelectRenderMode: (e) => {
|
|
161
|
+
this.tlRender = e, localStorage.setItem(`${this.appID}_tlRender`, e);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
) }),
|
|
165
|
+
(this.state.mode === "Side by Side" || this.state.mode === "Stacked") && /* @__PURE__ */ b(v, { children: [
|
|
166
|
+
/* @__PURE__ */ h(
|
|
167
|
+
u,
|
|
168
|
+
{
|
|
169
|
+
name: "tl",
|
|
170
|
+
camera: this.tlCam,
|
|
171
|
+
options: i,
|
|
172
|
+
ref: this.tlWindow,
|
|
173
|
+
onSelectCamera: (e) => {
|
|
174
|
+
this.controls.get(this.tlCam.name)?.dispose();
|
|
175
|
+
const t = this.cameras.get(e);
|
|
176
|
+
t !== void 0 && (this.clearCamera(this.tlCam), this.tlCam = t, localStorage.setItem(`${this.appID}_tlCam`, t.name), this.createControls(t, this.tlWindow.current));
|
|
177
|
+
},
|
|
178
|
+
onSelectRenderMode: (e) => {
|
|
179
|
+
this.tlRender = e, localStorage.setItem(`${this.appID}_tlRender`, e);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
),
|
|
183
|
+
/* @__PURE__ */ h(
|
|
184
|
+
u,
|
|
185
|
+
{
|
|
186
|
+
name: "tr",
|
|
187
|
+
camera: this.trCam,
|
|
188
|
+
options: i,
|
|
189
|
+
ref: this.trWindow,
|
|
190
|
+
onSelectCamera: (e) => {
|
|
191
|
+
this.controls.get(this.trCam.name)?.dispose();
|
|
192
|
+
const t = this.cameras.get(e);
|
|
193
|
+
t !== void 0 && (this.clearCamera(this.trCam), this.trCam = t, localStorage.setItem(`${this.appID}_trCam`, t.name), this.createControls(t, this.trWindow.current));
|
|
194
|
+
},
|
|
195
|
+
onSelectRenderMode: (e) => {
|
|
196
|
+
this.trRender = e, localStorage.setItem(`${this.appID}_trRender`, e);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
)
|
|
200
|
+
] }),
|
|
201
|
+
this.state.mode === "Quad" && /* @__PURE__ */ b(v, { children: [
|
|
202
|
+
/* @__PURE__ */ h(
|
|
203
|
+
u,
|
|
204
|
+
{
|
|
205
|
+
name: "tl",
|
|
206
|
+
camera: this.tlCam,
|
|
207
|
+
options: i,
|
|
208
|
+
ref: this.tlWindow,
|
|
209
|
+
onSelectCamera: (e) => {
|
|
210
|
+
this.controls.get(this.tlCam.name)?.dispose();
|
|
211
|
+
const t = this.cameras.get(e);
|
|
212
|
+
t !== void 0 && (this.clearCamera(this.tlCam), this.tlCam = t, localStorage.setItem(`${this.appID}_tlCam`, t.name), this.createControls(t, this.tlWindow.current));
|
|
213
|
+
},
|
|
214
|
+
onSelectRenderMode: (e) => {
|
|
215
|
+
this.tlRender = e, localStorage.setItem(`${this.appID}_tlRender`, e);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
),
|
|
219
|
+
/* @__PURE__ */ h(
|
|
220
|
+
u,
|
|
221
|
+
{
|
|
222
|
+
name: "tr",
|
|
223
|
+
camera: this.trCam,
|
|
224
|
+
options: i,
|
|
225
|
+
ref: this.trWindow,
|
|
226
|
+
onSelectCamera: (e) => {
|
|
227
|
+
this.controls.get(this.trCam.name)?.dispose();
|
|
228
|
+
const t = this.cameras.get(e);
|
|
229
|
+
t !== void 0 && (this.clearCamera(this.trCam), this.trCam = t, localStorage.setItem(`${this.appID}_trCam`, t.name), this.createControls(t, this.trWindow.current));
|
|
230
|
+
},
|
|
231
|
+
onSelectRenderMode: (e) => {
|
|
232
|
+
this.trRender = e, localStorage.setItem(`${this.appID}_trRender`, e);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
),
|
|
236
|
+
/* @__PURE__ */ h(
|
|
237
|
+
u,
|
|
238
|
+
{
|
|
239
|
+
name: "bl",
|
|
240
|
+
camera: this.blCam,
|
|
241
|
+
options: i,
|
|
242
|
+
ref: this.blWindow,
|
|
243
|
+
onSelectCamera: (e) => {
|
|
244
|
+
this.controls.get(this.blCam.name)?.dispose();
|
|
245
|
+
const t = this.cameras.get(e);
|
|
246
|
+
t !== void 0 && (this.clearCamera(this.blCam), this.blCam = t, localStorage.setItem(`${this.appID}_blCam`, t.name), this.createControls(t, this.blWindow.current));
|
|
247
|
+
},
|
|
248
|
+
onSelectRenderMode: (e) => {
|
|
249
|
+
this.blRender = e, localStorage.setItem(`${this.appID}_blRender`, e);
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
),
|
|
253
|
+
/* @__PURE__ */ h(
|
|
254
|
+
u,
|
|
255
|
+
{
|
|
256
|
+
name: "br",
|
|
257
|
+
camera: this.brCam,
|
|
258
|
+
options: i,
|
|
259
|
+
ref: this.brWindow,
|
|
260
|
+
onSelectCamera: (e) => {
|
|
261
|
+
this.controls.get(this.brCam.name)?.dispose();
|
|
262
|
+
const t = this.cameras.get(e);
|
|
263
|
+
t !== void 0 && (this.clearCamera(this.brCam), this.brCam = t, localStorage.setItem(`${this.appID}_brCam`, t.name), this.createControls(t, this.brWindow.current));
|
|
264
|
+
},
|
|
265
|
+
onSelectRenderMode: (e) => {
|
|
266
|
+
this.brRender = e, localStorage.setItem(`${this.appID}_brRender`, e);
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
)
|
|
270
|
+
] })
|
|
271
|
+
] }),
|
|
272
|
+
/* @__PURE__ */ b("div", { className: "settings", children: [
|
|
273
|
+
/* @__PURE__ */ h(
|
|
274
|
+
V,
|
|
275
|
+
{
|
|
276
|
+
title: "View",
|
|
277
|
+
index: W.indexOf(this.state.mode),
|
|
278
|
+
options: W,
|
|
279
|
+
onSelect: (e) => {
|
|
280
|
+
e !== this.state.mode && (this.killControls(), this.setState({ mode: e }), localStorage.setItem(`${this.appID}_mode`, e));
|
|
281
|
+
},
|
|
282
|
+
open: this.state.modeOpen,
|
|
283
|
+
onToggle: (e) => {
|
|
284
|
+
this.setState({
|
|
285
|
+
modeOpen: e,
|
|
286
|
+
renderModeOpen: !1,
|
|
287
|
+
interactionModeOpen: !1
|
|
288
|
+
});
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
),
|
|
292
|
+
/* @__PURE__ */ h(
|
|
293
|
+
V,
|
|
294
|
+
{
|
|
295
|
+
title: "Interact",
|
|
296
|
+
index: this.state.interactionMode === "Orbit" ? 0 : 1,
|
|
297
|
+
options: [
|
|
298
|
+
"Orbit Mode",
|
|
299
|
+
"Selection Mode"
|
|
300
|
+
],
|
|
301
|
+
onSelect: (e) => {
|
|
302
|
+
this.interactionHelper.visible = e === "Selection Mode", this.setState({ interactionMode: this.interactionHelper.visible ? "Selection" : "Orbit" });
|
|
303
|
+
},
|
|
304
|
+
open: this.state.interactionModeOpen,
|
|
305
|
+
onToggle: (e) => {
|
|
306
|
+
this.setState({
|
|
307
|
+
modeOpen: !1,
|
|
308
|
+
renderModeOpen: !1,
|
|
309
|
+
interactionModeOpen: e
|
|
310
|
+
});
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
),
|
|
314
|
+
/* @__PURE__ */ h(
|
|
315
|
+
I,
|
|
316
|
+
{
|
|
317
|
+
name: "cameraHelper",
|
|
318
|
+
icon: oe,
|
|
319
|
+
selected: this.cameraVisibility,
|
|
320
|
+
height: 24,
|
|
321
|
+
top: 2,
|
|
322
|
+
onClick: (e) => {
|
|
323
|
+
if (this.cameraVisibility = e, this.saveExpandedCameraVisibility(), this.cameraHelpers.forEach((t) => {
|
|
324
|
+
t.visible = e;
|
|
325
|
+
}), this.selectedItem !== void 0 && !e) {
|
|
326
|
+
const t = this.cameraHelpers.get(this.selectedItem.name);
|
|
327
|
+
t !== void 0 && (t.visible = !0);
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
),
|
|
332
|
+
/* @__PURE__ */ h(
|
|
333
|
+
I,
|
|
334
|
+
{
|
|
335
|
+
name: "lightHelper",
|
|
336
|
+
icon: he,
|
|
337
|
+
selected: this.lightVisibility,
|
|
338
|
+
height: 24,
|
|
339
|
+
top: 4,
|
|
340
|
+
onClick: (e) => {
|
|
341
|
+
if (this.lightVisibility = e, this.saveExpandedLightVisibility(), this.lightHelpers.forEach((t) => {
|
|
342
|
+
t.visible = e;
|
|
343
|
+
}), this.selectedItem !== void 0 && !e && this.selectedItem.isLight === !0) {
|
|
344
|
+
const t = this.lightHelpers.get(this.selectedItem.name);
|
|
345
|
+
t !== void 0 && (t.visible = !0);
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
),
|
|
350
|
+
/* @__PURE__ */ h(
|
|
351
|
+
I,
|
|
352
|
+
{
|
|
353
|
+
name: "gridHelper",
|
|
354
|
+
icon: le,
|
|
355
|
+
selected: this.gridVisibility,
|
|
356
|
+
height: 21,
|
|
357
|
+
width: 21,
|
|
358
|
+
onClick: (e) => {
|
|
359
|
+
this.setGridVisibility(e);
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
)
|
|
363
|
+
] }, this.state.lastUpdate)
|
|
364
|
+
] });
|
|
365
|
+
}
|
|
366
|
+
// Setup
|
|
367
|
+
setupRenderer = (i) => {
|
|
368
|
+
const e = i.value;
|
|
369
|
+
if (this.renderer) {
|
|
370
|
+
if (this.renderer instanceof T && e.type === "WebGLRenderer" || this.renderer instanceof A && e.type === "WebGPURenderer") return;
|
|
371
|
+
this.renderer.dispose();
|
|
372
|
+
}
|
|
373
|
+
this.rendererReady = !1;
|
|
374
|
+
const t = this.canvasRef.current;
|
|
375
|
+
if (t === null) {
|
|
376
|
+
setTimeout(() => this.props.three.requestRenderer(), 100);
|
|
377
|
+
return;
|
|
378
|
+
}
|
|
379
|
+
this.props.three.canvas = t, e.type === "WebGLRenderer" ? (this.renderer = new T({
|
|
380
|
+
canvas: t,
|
|
381
|
+
stencil: !1
|
|
382
|
+
}), this.grid && (this.scene.remove(this.grid), y(this.grid)), this.grid = new ee(), this.scene.add(this.grid), this.rendererReady = !0) : e.type === "WebGPURenderer" && (this.renderer = new A({
|
|
383
|
+
canvas: t,
|
|
384
|
+
stencil: !1
|
|
385
|
+
}), this.grid && (this.scene.remove(this.grid), y(this.grid)), this.grid = new te(), this.scene.add(this.grid)), this.renderer && (this.renderer.autoClear = !1, this.renderer.shadowMap.enabled = !0, this.renderer.setClearColor(0), this.renderer.setPixelRatio(devicePixelRatio), this.renderer.setScissorTest(!0), this.resize(), this.props.three.renderer = this.renderer, this.depthMaterial?.dispose(), this.normalsMaterial?.dispose(), this.uvMaterial?.dispose(), this.depthMaterial = new se(), this.normalsMaterial = new Q(), this.uvMaterial = new re(), e.type === "WebGPURenderer" ? this.renderer.init().then(() => {
|
|
386
|
+
this.rendererReady = !0, this.props.three.requestScene();
|
|
387
|
+
}) : this.props.three.requestScene());
|
|
388
|
+
};
|
|
389
|
+
setupScene() {
|
|
390
|
+
this.helpersContainer.name = "helpers", this.scene.add(this.helpersContainer), this.interactionHelper.name = "interactionHelper", this.interactionHelper.visible = !1, this.helpersContainer.add(this.interactionHelper);
|
|
391
|
+
const i = (a, r) => {
|
|
392
|
+
const n = new M(-100, 100, 100, -100, 0, 3e3);
|
|
393
|
+
return n.name = a, n.position.copy(r), n.lookAt(0, 0, 0), this.cameras.set(a, n), n;
|
|
394
|
+
}, e = 1e3;
|
|
395
|
+
i("Top", new c(0, e, 0)), i("Bottom", new c(0, -e, 0)), i("Left", new c(-e, 0, 0)), i("Right", new c(e, 0, 0)), i("Front", new c(0, 0, e)), i("Back", new c(0, 0, -e)), i("Orthographic", new c(e, e, e)), i("UI", new c()), this.debugCamera = new E(60, 1, 0.01, 3e3), this.debugCamera.name = "Debug", this.debugCamera.position.set(300, 300, 300), this.debugCamera.lookAt(0, 0, 0), this.cameras.set("Debug", this.debugCamera), this.currentCamera = this.debugCamera;
|
|
396
|
+
const t = localStorage, s = this.props.three.name;
|
|
397
|
+
this.tlCam = this.cameras.get(t.getItem(`${s}_tlCam`)), this.trCam = this.cameras.get(t.getItem(`${s}_trCam`)), this.blCam = this.cameras.get(t.getItem(`${s}_blCam`)), this.brCam = this.cameras.get(t.getItem(`${s}_brCam`)), this.tlCam === void 0 && (this.tlCam = this.cameras.get("Debug")), this.trCam === void 0 && (this.trCam = this.cameras.get("Orthographic")), this.blCam === void 0 && (this.blCam = this.cameras.get("Front")), this.brCam === void 0 && (this.brCam = this.cameras.get("Top")), S.addEditorGroup({
|
|
398
|
+
title: "Editor",
|
|
399
|
+
items: [
|
|
400
|
+
{
|
|
401
|
+
type: "button",
|
|
402
|
+
prop: "Hide All Transforms"
|
|
403
|
+
},
|
|
404
|
+
{
|
|
405
|
+
type: "button",
|
|
406
|
+
prop: "Resize"
|
|
407
|
+
}
|
|
408
|
+
],
|
|
409
|
+
onUpdate: (a, r) => {
|
|
410
|
+
switch (a) {
|
|
411
|
+
case "Hide All Transforms":
|
|
412
|
+
m.instance.hide();
|
|
413
|
+
break;
|
|
414
|
+
case "Resize":
|
|
415
|
+
this.resize();
|
|
416
|
+
break;
|
|
417
|
+
}
|
|
418
|
+
},
|
|
419
|
+
subgroups: [
|
|
420
|
+
{
|
|
421
|
+
title: "Debug Camera",
|
|
422
|
+
items: [
|
|
423
|
+
{
|
|
424
|
+
type: "range",
|
|
425
|
+
prop: "Near",
|
|
426
|
+
step: 1e-4,
|
|
427
|
+
min: 1e-3,
|
|
428
|
+
max: 1e3,
|
|
429
|
+
value: this.debugCamera.near
|
|
430
|
+
},
|
|
431
|
+
{
|
|
432
|
+
type: "range",
|
|
433
|
+
prop: "Far",
|
|
434
|
+
step: 1e-3,
|
|
435
|
+
min: 1e-3,
|
|
436
|
+
max: 1e4,
|
|
437
|
+
value: this.debugCamera.far
|
|
438
|
+
}
|
|
439
|
+
],
|
|
440
|
+
onUpdate: (a, r) => {
|
|
441
|
+
switch (a) {
|
|
442
|
+
case "Near":
|
|
443
|
+
this.debugCamera.near = r, this.debugCamera.updateProjectionMatrix();
|
|
444
|
+
break;
|
|
445
|
+
case "Far":
|
|
446
|
+
this.debugCamera.far = r, this.debugCamera.updateProjectionMatrix();
|
|
447
|
+
break;
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
},
|
|
451
|
+
{
|
|
452
|
+
title: "Grid",
|
|
453
|
+
items: [
|
|
454
|
+
{
|
|
455
|
+
type: "number",
|
|
456
|
+
prop: "Position",
|
|
457
|
+
value: 0
|
|
458
|
+
},
|
|
459
|
+
{
|
|
460
|
+
type: "color",
|
|
461
|
+
prop: "Color",
|
|
462
|
+
value: "#FFFFFF"
|
|
463
|
+
},
|
|
464
|
+
{
|
|
465
|
+
type: "range",
|
|
466
|
+
prop: "Grid Opacity",
|
|
467
|
+
value: 0.25,
|
|
468
|
+
min: 0,
|
|
469
|
+
max: 1,
|
|
470
|
+
step: 0.01
|
|
471
|
+
},
|
|
472
|
+
{
|
|
473
|
+
type: "range",
|
|
474
|
+
prop: "Subgrid Opacity",
|
|
475
|
+
value: 0.15,
|
|
476
|
+
min: 0,
|
|
477
|
+
max: 1,
|
|
478
|
+
step: 0.01
|
|
479
|
+
}
|
|
480
|
+
],
|
|
481
|
+
onUpdate: (a, r) => {
|
|
482
|
+
switch (a) {
|
|
483
|
+
case "Position":
|
|
484
|
+
this.grid && (this.grid.position.y = r);
|
|
485
|
+
break;
|
|
486
|
+
case "Color":
|
|
487
|
+
this.grid && this.grid.color.setStyle(r);
|
|
488
|
+
break;
|
|
489
|
+
case "Grid Opacity":
|
|
490
|
+
this.grid && (this.grid.gridOpacity = r);
|
|
491
|
+
break;
|
|
492
|
+
case "Subgrid Opacity":
|
|
493
|
+
this.grid && (this.grid.subgridOpacity = r);
|
|
494
|
+
break;
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
]
|
|
499
|
+
});
|
|
500
|
+
}
|
|
501
|
+
setupTools() {
|
|
502
|
+
this.splineEditor = new ae(this.currentCamera, this.three), this.splineEditor.initDebug(), this.helpersContainer.add(this.splineEditor);
|
|
503
|
+
}
|
|
504
|
+
// Public
|
|
505
|
+
play() {
|
|
506
|
+
this.playing = !0, this.onUpdate();
|
|
507
|
+
}
|
|
508
|
+
pause() {
|
|
509
|
+
this.playing = !1, cancelAnimationFrame(this.rafID), this.rafID = -1;
|
|
510
|
+
}
|
|
511
|
+
toggleOrbitControls(i) {
|
|
512
|
+
this.controls.forEach((e) => {
|
|
513
|
+
e.enabled = !i;
|
|
514
|
+
});
|
|
515
|
+
}
|
|
516
|
+
clear() {
|
|
517
|
+
this.three.dispatchEvent({ type: o.CLEAR_OBJECT }), S.removeAllGroups(), this.clearLightHelpers(), this.clearControls(), this.currentTransform !== void 0 && (this.currentTransform.removeEventListener("objectChange", this.onUpdateTransform), m.instance.remove(this.currentTransform.getHelper().name)), this.currentTransform = void 0, m.instance.clear(), this.cameras.forEach((i) => {
|
|
518
|
+
this.editorCameras.indexOf(i.name) < 0 && this.three.dispatchEvent({ type: o.REMOVE_CAMERA, value: i });
|
|
519
|
+
}), this.currentCamera = this.debugCamera, this.currentScene = void 0, this.scenes.forEach((i) => {
|
|
520
|
+
this.three.dispatchEvent({ type: o.REMOVE_SCENE, value: i });
|
|
521
|
+
}), this.scenes.clear();
|
|
522
|
+
}
|
|
523
|
+
setGridVisibility(i) {
|
|
524
|
+
this.gridVisibility = i, this.saveExpandedGridVisibility(), this.grid && (this.grid.visible = i);
|
|
525
|
+
}
|
|
526
|
+
// Playback
|
|
527
|
+
update() {
|
|
528
|
+
this.controls.forEach((i) => i.update()), this.cameraHelpers.forEach((i) => i.update()), this.lightHelpers.forEach((i) => {
|
|
529
|
+
i.update !== void 0 && i.update();
|
|
530
|
+
}), this.props.onSceneUpdate !== void 0 && this.currentScene !== void 0 && this.props.onSceneUpdate(this.currentScene);
|
|
531
|
+
}
|
|
532
|
+
draw() {
|
|
533
|
+
if (this.rendererReady)
|
|
534
|
+
switch (this.renderer && this.renderer?.clear(), this.state.mode) {
|
|
535
|
+
case "Single":
|
|
536
|
+
this.drawSingle();
|
|
537
|
+
break;
|
|
538
|
+
case "Side by Side":
|
|
539
|
+
case "Stacked":
|
|
540
|
+
this.drawDouble();
|
|
541
|
+
break;
|
|
542
|
+
case "Quad":
|
|
543
|
+
this.drawQuad();
|
|
544
|
+
break;
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
onUpdate = () => {
|
|
548
|
+
this.playing && (this.update(), this.draw(), this.rafID = requestAnimationFrame(this.onUpdate));
|
|
549
|
+
};
|
|
550
|
+
// Events
|
|
551
|
+
enable() {
|
|
552
|
+
const i = this.containerRef.current;
|
|
553
|
+
i.addEventListener("mousemove", this.onMouseMove), i.addEventListener("click", this.onClick), window.addEventListener("keydown", this.onKey), window.addEventListener("resize", this.resize), this.three.addEventListener(o.ADD_SCENE, this.addScene), this.three.addEventListener(o.SET_SCENE, this.sceneUpdate), this.three.addEventListener(o.REMOVE_SCENE, this.removeScene), this.three.addEventListener(o.ADD_CAMERA, this.addCamera), this.three.addEventListener(o.REMOVE_CAMERA, this.removeCamera), this.three.addEventListener(o.SET_OBJECT, this.onSetSelectedItem);
|
|
554
|
+
}
|
|
555
|
+
disable() {
|
|
556
|
+
const i = this.containerRef.current;
|
|
557
|
+
i.removeEventListener("mousemove", this.onMouseMove), i.removeEventListener("click", this.onClick), window.removeEventListener("keydown", this.onKey), window.removeEventListener("resize", this.resize), this.three.removeEventListener(o.ADD_SCENE, this.addScene), this.three.removeEventListener(o.SET_SCENE, this.sceneUpdate), this.three.removeEventListener(o.REMOVE_SCENE, this.removeScene), this.three.removeEventListener(o.ADD_CAMERA, this.addCamera), this.three.removeEventListener(o.REMOVE_CAMERA, this.removeCamera), this.three.removeEventListener(o.SET_OBJECT, this.onSetSelectedItem);
|
|
558
|
+
}
|
|
559
|
+
resize = () => {
|
|
560
|
+
this.width = window.innerWidth - 300, this.height = window.innerHeight, this.renderer?.setSize(this.width, this.height);
|
|
561
|
+
const i = Math.floor(this.width / 2), e = Math.floor(this.height / 2);
|
|
562
|
+
this.props.three.resize(this.width, this.height), this.props.onSceneResize !== void 0 && this.currentScene !== void 0 && this.props.onSceneResize(this.currentScene, this.width, this.height);
|
|
563
|
+
let t = this.width, s = this.height;
|
|
564
|
+
switch (this.state.mode) {
|
|
565
|
+
case "Side by Side":
|
|
566
|
+
t = i, s = this.height;
|
|
567
|
+
break;
|
|
568
|
+
case "Stacked":
|
|
569
|
+
t = this.width, s = e;
|
|
570
|
+
break;
|
|
571
|
+
case "Quad":
|
|
572
|
+
t = i, s = e;
|
|
573
|
+
break;
|
|
574
|
+
}
|
|
575
|
+
const a = t / s;
|
|
576
|
+
this.cameras.forEach((r) => {
|
|
577
|
+
r instanceof M ? (r.left = t / -2, r.right = t / 2, r.top = s / 2, r.bottom = s / -2, r.name === "UI" && (r.position.x = this.width / 2, r.position.y = this.height / -2, r.position.z = 100), r.updateProjectionMatrix()) : r instanceof E && (r.aspect = a, r.updateProjectionMatrix()), this.cameraHelpers.get(r.name)?.update();
|
|
578
|
+
});
|
|
579
|
+
};
|
|
580
|
+
addScene = (i) => {
|
|
581
|
+
const e = this.props.scenes.get(i.value.name);
|
|
582
|
+
if (e !== void 0) {
|
|
583
|
+
const t = this.scenes.get(i.value.name);
|
|
584
|
+
if (t !== void 0) {
|
|
585
|
+
this.props.onSceneAdd !== void 0 && this.props.onSceneAdd(t), this.props.three.scene = t;
|
|
586
|
+
return;
|
|
587
|
+
}
|
|
588
|
+
const s = new e();
|
|
589
|
+
s.visible = !1, this.props.onSceneAdd !== void 0 && this.props.onSceneAdd(s), this.props.three.scene = s, this.scenes.set(i.value.name, s), this.scene.add(s);
|
|
590
|
+
} else
|
|
591
|
+
console.log("Hermes - Scene not found:", i.value.name, this.props.scenes);
|
|
592
|
+
};
|
|
593
|
+
sceneUpdate = (i) => {
|
|
594
|
+
this.currentScene !== void 0 && (this.currentScene.visible = !1, this.clearLightHelpers());
|
|
595
|
+
const e = this.scene.getObjectByName(i.value.name);
|
|
596
|
+
e !== void 0 && (this.currentScene = e, this.currentScene.visible = !0, this.addLightHelpers(this.currentScene)), this.cameraHelpers.forEach((t, s) => {
|
|
597
|
+
const a = this.currentScene !== void 0 && this.currentScene.getObjectByProperty("uuid", s) !== void 0;
|
|
598
|
+
t.visible = this.cameraVisibility && a;
|
|
599
|
+
});
|
|
600
|
+
};
|
|
601
|
+
removeScene = (i) => {
|
|
602
|
+
const e = i.value.name;
|
|
603
|
+
this.scenes.delete(e);
|
|
604
|
+
const t = this.scene.getObjectByName(e);
|
|
605
|
+
t && setTimeout(() => {
|
|
606
|
+
y(t);
|
|
607
|
+
}, 100), this.clearLightHelpers();
|
|
608
|
+
};
|
|
609
|
+
addCamera = (i) => {
|
|
610
|
+
const e = i.value, t = e.uuid, s = this.props.three.scene?.getObjectByProperty("uuid", e.uuid);
|
|
611
|
+
if (s !== void 0) {
|
|
612
|
+
const a = s;
|
|
613
|
+
this.cameras.set(t, a);
|
|
614
|
+
const r = new q(a), n = this.currentScene !== void 0 && this.currentScene.getObjectByProperty("uuid", t) !== void 0;
|
|
615
|
+
r.visible = this.cameraVisibility && n, this.cameraHelpers.set(t, r), this.helpersContainer.add(r), this.setState({ lastUpdate: Date.now() });
|
|
616
|
+
}
|
|
617
|
+
};
|
|
618
|
+
removeCamera = (i) => {
|
|
619
|
+
const t = i.value.uuid, s = this.cameraHelpers.get(t);
|
|
620
|
+
s !== void 0 && (this.helpersContainer.remove(s), s.dispose()), this.cameras.delete(t), this.setState({ lastUpdate: Date.now() });
|
|
621
|
+
};
|
|
622
|
+
onMouseMove = (i) => {
|
|
623
|
+
const e = new w();
|
|
624
|
+
this.renderer?.getSize(e);
|
|
625
|
+
const t = Math.min(i.clientX, e.x), s = Math.min(i.clientY, e.y);
|
|
626
|
+
this.pointer.x = g(t, 0, e.x, -1, 1), this.pointer.y = g(s, 0, e.y, 1, -1);
|
|
627
|
+
const a = e.x / 2, r = e.y / 2, n = () => {
|
|
628
|
+
t < a ? this.pointer.x = g(t, 0, a, -1, 1) : this.pointer.x = g(t, a, e.x, -1, 1);
|
|
629
|
+
}, d = () => {
|
|
630
|
+
s < r ? this.pointer.y = g(s, 0, r, 1, -1) : this.pointer.y = g(s, r, e.y, 1, -1);
|
|
631
|
+
};
|
|
632
|
+
switch (this.state.mode) {
|
|
633
|
+
case "Quad":
|
|
634
|
+
n(), d();
|
|
635
|
+
break;
|
|
636
|
+
case "Side by Side":
|
|
637
|
+
n();
|
|
638
|
+
break;
|
|
639
|
+
case "Stacked":
|
|
640
|
+
d(), d();
|
|
641
|
+
break;
|
|
642
|
+
}
|
|
643
|
+
if (this.updateCamera(t, s, a, r), this.state.interactionMode === "Orbit" || this.currentScene === void 0) return;
|
|
644
|
+
const l = this.raycaster.intersectObjects(this.currentScene.children);
|
|
645
|
+
l.length > 0 && this.interactionHelper.position.copy(l[0].point);
|
|
646
|
+
};
|
|
647
|
+
onClick = (i) => {
|
|
648
|
+
if (this.state.interactionMode === "Orbit" || this.currentScene === void 0) return;
|
|
649
|
+
const e = new w();
|
|
650
|
+
if (this.renderer.getSize(e), i.clientX >= e.x) return;
|
|
651
|
+
this.onMouseMove(i);
|
|
652
|
+
const t = this.raycaster.intersectObjects(this.currentScene.children);
|
|
653
|
+
t.length > 0 && (this.props.three.getObject(t[0].object.uuid), this.interactionHelper.visible = !1, this.setState({ interactionMode: "Orbit", lastUpdate: Date.now() }));
|
|
654
|
+
};
|
|
655
|
+
onKey = (i) => {
|
|
656
|
+
if (this.selectedItem !== void 0) {
|
|
657
|
+
if (i.ctrlKey) {
|
|
658
|
+
if (this.currentCamera.name === "UI") return;
|
|
659
|
+
const e = this.controls.get(this.currentCamera.name);
|
|
660
|
+
i.key === "0" ? (i.preventDefault(), this.clearControls(), this.cameraControls = new p(this.currentCamera, this.currentWindow.current), this.selectedItem instanceof K || this.selectedItem instanceof N ? (this.selectedItem.geometry.computeBoundingBox(), this.cameraControls.fitToBox(this.selectedItem.geometry.boundingBox, !0)) : this.cameraControls.fitToSphere(this.selectedItem, !0), this.updateCameraControls(e, !0)) : i.key === "1" ? (i.preventDefault(), this.clearControls(), this.cameraControls = new p(this.currentCamera, this.currentWindow.current), this.cameraControls.rotateTo(0, Math.PI * 0.5, !0), this.cameraControls.moveTo(this.selectedItem.position.x, this.selectedItem.position.y, 0, !0), this.updateCameraControls(e)) : i.key === "2" ? (i.preventDefault(), this.clearControls(), this.cameraControls = new p(this.currentCamera, this.currentWindow.current), this.cameraControls.rotateTo(0, 0, !0), this.cameraControls.moveTo(this.selectedItem.position.x, 0, this.selectedItem.position.z, !0), this.updateCameraControls(e)) : i.key === "3" ? (i.preventDefault(), this.clearControls(), this.cameraControls = new p(this.currentCamera, this.currentWindow.current), this.cameraControls.rotateTo(Math.PI / 2, Math.PI / 2, !0), this.cameraControls.moveTo(0, this.selectedItem.position.y, this.selectedItem.position.z, !0), this.updateCameraControls(e)) : i.key === "4" ? (i.preventDefault(), this.clearControls(), this.cameraControls = new p(this.currentCamera, this.currentWindow.current), this.cameraControls.rotateTo(Math.PI, Math.PI / 2, !0), this.cameraControls.moveTo(this.selectedItem.position.x, this.selectedItem.position.y, 0, !0), this.updateCameraControls(e)) : i.key === "5" && (i.preventDefault(), this.clearControls(), this.cameraControls = new p(this.currentCamera, this.currentWindow.current), this.cameraControls.rotateTo(H(45), H(45), !0), this.updateCameraControls(e));
|
|
661
|
+
} else if (this.currentTransform !== void 0)
|
|
662
|
+
switch (i.key) {
|
|
663
|
+
case "r":
|
|
664
|
+
this.currentTransform.setMode("rotate");
|
|
665
|
+
break;
|
|
666
|
+
case "s":
|
|
667
|
+
this.currentTransform.setMode("scale");
|
|
668
|
+
break;
|
|
669
|
+
case "t":
|
|
670
|
+
this.currentTransform.setMode("translate");
|
|
671
|
+
break;
|
|
672
|
+
case "q":
|
|
673
|
+
this.currentTransform.setSpace(this.currentTransform.space === "local" ? "world" : "local");
|
|
674
|
+
break;
|
|
675
|
+
}
|
|
676
|
+
}
|
|
677
|
+
};
|
|
678
|
+
onSetSelectedItem = (i) => {
|
|
679
|
+
this.selectedItem !== void 0 && this.updateSelectedItemHelper(!1), this.selectedItem = void 0;
|
|
680
|
+
const e = i.value.uuid;
|
|
681
|
+
if (this.scenes.forEach((t) => {
|
|
682
|
+
e.search(t.uuid) > -1 && (this.selectedItem = t.getObjectByProperty("uuid", e));
|
|
683
|
+
}), this.selectedItem === void 0) {
|
|
684
|
+
console.log(`Hermes - Can't find selected item: ${i.value.uuid}, ${i.value.name}`);
|
|
685
|
+
return;
|
|
686
|
+
}
|
|
687
|
+
this.currentTransform !== void 0 && (this.currentTransform.removeEventListener("objectChange", this.onUpdateTransform), m.instance.remove(this.currentTransform.getHelper().name)), this.currentTransform = m.instance.add(i.value.name), this.currentTransform && (this.currentTransform.attach(this.selectedItem), this.helpersContainer.add(this.currentTransform.getHelper()), this.currentTransform.addEventListener("objectChange", this.onUpdateTransform)), this.updateSelectedItemHelper(!0);
|
|
688
|
+
};
|
|
689
|
+
updateSelectedItemHelper(i) {
|
|
690
|
+
if (this.selectedItem !== void 0)
|
|
691
|
+
if (this.cameraVisibility) {
|
|
692
|
+
if (this.selectedItem.isLight === !0 && !this.lightVisibility) {
|
|
693
|
+
const e = this.lightHelpers.get(this.selectedItem.name);
|
|
694
|
+
e !== void 0 && (e.visible = i);
|
|
695
|
+
}
|
|
696
|
+
} else {
|
|
697
|
+
const e = this.cameraHelpers.get(this.selectedItem.name);
|
|
698
|
+
e !== void 0 && (e.visible = i);
|
|
699
|
+
}
|
|
700
|
+
}
|
|
701
|
+
onUpdateTransform = () => {
|
|
702
|
+
this.selectedItem !== void 0 && (this.props.three.updateObject(this.selectedItem.uuid, "position", this.selectedItem.position), this.props.three.updateObject(this.selectedItem.uuid, "rotation", {
|
|
703
|
+
x: this.selectedItem.rotation.x,
|
|
704
|
+
y: this.selectedItem.rotation.y,
|
|
705
|
+
z: this.selectedItem.rotation.z
|
|
706
|
+
}), this.props.three.updateObject(this.selectedItem.uuid, "scale", this.selectedItem.scale), ie.instance.update());
|
|
707
|
+
};
|
|
708
|
+
// Utils
|
|
709
|
+
clearLightHelpers = () => {
|
|
710
|
+
this.lightHelpers.forEach((i) => {
|
|
711
|
+
this.helpersContainer.remove(i), i.dispose();
|
|
712
|
+
}), this.lightHelpers.clear();
|
|
713
|
+
};
|
|
714
|
+
addLightHelpers = (i) => {
|
|
715
|
+
i.traverse((e) => {
|
|
716
|
+
if (e.type.search("Light") > -1) {
|
|
717
|
+
let t;
|
|
718
|
+
switch (e.type) {
|
|
719
|
+
case "DirectionalLight":
|
|
720
|
+
t = new X(e, 100), t.name = `${e.name}Helper`, t.visible = this.lightVisibility, this.lightHelpers.set(e.name, t), this.helpersContainer.add(t);
|
|
721
|
+
break;
|
|
722
|
+
case "HemisphereLight":
|
|
723
|
+
t = new J(e, 250), t.name = `${e.name}Helper`, t.visible = this.lightVisibility, this.lightHelpers.set(e.name, t), this.helpersContainer.add(t);
|
|
724
|
+
break;
|
|
725
|
+
case "RectAreaLight":
|
|
726
|
+
t = new j(e), t.name = `${e.name}Helper`, t.visible = this.lightVisibility, this.lightHelpers.set(e.name, t), this.helpersContainer.add(t);
|
|
727
|
+
break;
|
|
728
|
+
case "PointLight":
|
|
729
|
+
t = new Y(e, 100), t.name = `${e.name}Helper`, t.visible = this.lightVisibility, this.lightHelpers.set(e.name, t), this.helpersContainer.add(t);
|
|
730
|
+
break;
|
|
731
|
+
case "SpotLight":
|
|
732
|
+
t = new $(e), t.name = `${e.name}Helper`, t.visible = this.lightVisibility, this.lightHelpers.set(e.name, t), this.helpersContainer.add(t);
|
|
733
|
+
break;
|
|
734
|
+
}
|
|
735
|
+
}
|
|
736
|
+
});
|
|
737
|
+
};
|
|
738
|
+
createControls(i, e) {
|
|
739
|
+
const t = this.controls.get(i.name);
|
|
740
|
+
if (t !== void 0 && t.dispose(), this.controls.delete(i.name), i.name === "UI") return;
|
|
741
|
+
const s = new Z(i, e);
|
|
742
|
+
switch (s.enableDamping = !0, s.dampingFactor = 0.1, i.name) {
|
|
743
|
+
case "Top":
|
|
744
|
+
case "Bottom":
|
|
745
|
+
case "Left":
|
|
746
|
+
case "Right":
|
|
747
|
+
case "Front":
|
|
748
|
+
case "Back":
|
|
749
|
+
s.enableRotate = !1;
|
|
750
|
+
break;
|
|
751
|
+
}
|
|
752
|
+
this.controls.set(i.name, s);
|
|
753
|
+
}
|
|
754
|
+
clearCamera(i) {
|
|
755
|
+
const e = this.cameraHelpers.get(i.name);
|
|
756
|
+
e !== void 0 && (this.helpersContainer.remove(e), e.dispose(), this.cameraHelpers.delete(i.name));
|
|
757
|
+
const t = this.controls.get(i.name);
|
|
758
|
+
t !== void 0 && (t.dispose(), this.controls.delete(i.name));
|
|
759
|
+
}
|
|
760
|
+
killControls() {
|
|
761
|
+
this.controls.forEach((i, e) => {
|
|
762
|
+
i.dispose();
|
|
763
|
+
const t = this.cameraHelpers.get(e);
|
|
764
|
+
t !== void 0 && (this.helpersContainer.remove(t), t.dispose()), this.cameraHelpers.delete(e), this.controls.delete(e);
|
|
765
|
+
}), this.controls.clear(), this.cameraHelpers.clear();
|
|
766
|
+
}
|
|
767
|
+
assignControls() {
|
|
768
|
+
switch (this.state.mode) {
|
|
769
|
+
case "Single":
|
|
770
|
+
this.createControls(this.tlCam, this.tlWindow.current);
|
|
771
|
+
break;
|
|
772
|
+
case "Side by Side":
|
|
773
|
+
case "Stacked":
|
|
774
|
+
this.createControls(this.tlCam, this.tlWindow.current), this.createControls(this.trCam, this.trWindow.current);
|
|
775
|
+
break;
|
|
776
|
+
case "Quad":
|
|
777
|
+
this.createControls(this.tlCam, this.tlWindow.current), this.createControls(this.trCam, this.trWindow.current), this.createControls(this.blCam, this.blWindow.current), this.createControls(this.brCam, this.brWindow.current);
|
|
778
|
+
break;
|
|
779
|
+
}
|
|
780
|
+
}
|
|
781
|
+
updateCamera = (i, e, t, s) => {
|
|
782
|
+
switch (this.state.mode) {
|
|
783
|
+
case "Quad":
|
|
784
|
+
e < s ? i < t ? this.currentCamera = this.tlCam : this.currentCamera = this.trCam : i < t ? this.currentCamera = this.blCam : this.currentCamera = this.brCam;
|
|
785
|
+
break;
|
|
786
|
+
case "Side by Side":
|
|
787
|
+
i < t ? this.currentCamera = this.tlCam : this.currentCamera = this.trCam;
|
|
788
|
+
break;
|
|
789
|
+
case "Single":
|
|
790
|
+
this.currentCamera = this.tlCam;
|
|
791
|
+
break;
|
|
792
|
+
case "Stacked":
|
|
793
|
+
e < s ? this.currentCamera = this.tlCam : this.currentCamera = this.trCam;
|
|
794
|
+
break;
|
|
795
|
+
}
|
|
796
|
+
this.splineEditor.camera = this.currentCamera, this.raycaster.setFromCamera(this.pointer, this.currentCamera), this.currentCamera === this.tlCam ? this.currentWindow = this.tlWindow : this.currentCamera === this.trCam ? this.currentWindow = this.trWindow : this.currentCamera === this.blCam ? this.currentWindow = this.blWindow : this.currentCamera === this.brCam && (this.currentWindow = this.brWindow), m.instance.updateCamera(this.currentCamera, this.currentWindow.current);
|
|
797
|
+
};
|
|
798
|
+
updateCameraControls = (i, e = !1) => {
|
|
799
|
+
if (this.selectedItem === void 0) return;
|
|
800
|
+
cancelAnimationFrame(this.cameraControlsRafID), this.cameraControlsRafID = -1, this.cameraControls && (this.cameraControls.smoothTime = 0.1);
|
|
801
|
+
const t = 0.15;
|
|
802
|
+
this.cameraControlsStartTime = performance.now(), this.cameraControlsLastTime = this.cameraControlsStartTime, this.selectedItem.getWorldPosition(i.target0);
|
|
803
|
+
const s = () => {
|
|
804
|
+
const a = performance.now(), r = (a - this.cameraControlsLastTime) / 1e3;
|
|
805
|
+
this.cameraControlsLastTime = a, this.cameraControls && this.cameraControls.update(r), e && (i.target.lerp(i.target0, t), i.object.position.lerp(i.position0, t), i.object.zoom = ne(i.object.zoom, i.zoom0, t), i.object.updateProjectionMatrix(), i.dispatchEvent({ type: "change" })), (a - this.cameraControlsStartTime) / 1e3 >= 0.5 ? (cancelAnimationFrame(this.cameraControlsRafID), this.cameraControlsRafID = -1, this.clearControls()) : this.cameraControlsRafID = requestAnimationFrame(s);
|
|
806
|
+
};
|
|
807
|
+
s();
|
|
808
|
+
};
|
|
809
|
+
clearControls = () => {
|
|
810
|
+
this.cameraControls !== void 0 && (this.cameraControls.disconnect(), this.cameraControls.dispose(), this.cameraControls = void 0);
|
|
811
|
+
};
|
|
812
|
+
saveExpandedCameraVisibility() {
|
|
813
|
+
localStorage.setItem(this.expandedCameraVisibility, this.cameraVisibility ? "open" : "closed");
|
|
814
|
+
}
|
|
815
|
+
saveExpandedLightVisibility() {
|
|
816
|
+
localStorage.setItem(this.expandedLightVisibility, this.lightVisibility ? "open" : "closed");
|
|
817
|
+
}
|
|
818
|
+
saveExpandedGridVisibility() {
|
|
819
|
+
localStorage.setItem(this.expandedGridVisibility, this.gridVisibility ? "open" : "closed");
|
|
820
|
+
}
|
|
821
|
+
// Drawing
|
|
822
|
+
getSceneOverride(i) {
|
|
823
|
+
switch (i) {
|
|
824
|
+
case "Depth":
|
|
825
|
+
return this.depthMaterial;
|
|
826
|
+
case "Normals":
|
|
827
|
+
return this.normalsMaterial;
|
|
828
|
+
case "Renderer":
|
|
829
|
+
return null;
|
|
830
|
+
case "UVs":
|
|
831
|
+
return this.uvMaterial;
|
|
832
|
+
case "Wireframe":
|
|
833
|
+
return this.wireframeMaterial;
|
|
834
|
+
}
|
|
835
|
+
return null;
|
|
836
|
+
}
|
|
837
|
+
drawTo(i, e, t, s, a, r) {
|
|
838
|
+
switch (a.name) {
|
|
839
|
+
case "Left":
|
|
840
|
+
case "Right":
|
|
841
|
+
this.grid && (this.grid.rotation.z = Math.PI / 2);
|
|
842
|
+
break;
|
|
843
|
+
case "Front":
|
|
844
|
+
case "Back":
|
|
845
|
+
this.grid && (this.grid.rotation.x = Math.PI / 2);
|
|
846
|
+
break;
|
|
847
|
+
}
|
|
848
|
+
this.scene.overrideMaterial = r, this.renderer && (this.renderer?.setScissor(i, e, t, s), this.renderer?.setViewport(i, e, t, s), this.renderer?.render(this.scene, a)), this.grid && this.grid.rotation.set(0, 0, 0);
|
|
849
|
+
}
|
|
850
|
+
drawSingle() {
|
|
851
|
+
const i = this.getSceneOverride(this.tlRender);
|
|
852
|
+
this.drawTo(0, 0, this.width, this.height, this.tlCam, i);
|
|
853
|
+
}
|
|
854
|
+
drawDouble = () => {
|
|
855
|
+
const i = this.getSceneOverride(this.tlRender), e = this.getSceneOverride(this.trRender), t = Math.floor(this.width / 2), s = Math.floor(this.height / 2), a = this.renderer instanceof A;
|
|
856
|
+
if (this.state.mode === "Side by Side")
|
|
857
|
+
this.drawTo(0, 0, t, this.height, this.tlCam, i), this.drawTo(t, 0, t, this.height, this.trCam, e);
|
|
858
|
+
else {
|
|
859
|
+
const r = this.height - s;
|
|
860
|
+
a ? (this.drawTo(0, 0, this.width, s, this.tlCam, i), this.drawTo(0, r, this.width, s, this.trCam, e)) : (this.drawTo(0, r, this.width, s, this.tlCam, i), this.drawTo(0, 0, this.width, s, this.trCam, e));
|
|
861
|
+
}
|
|
862
|
+
};
|
|
863
|
+
drawQuad = () => {
|
|
864
|
+
const i = this.renderer instanceof A, e = this.getSceneOverride(this.tlRender), t = this.getSceneOverride(this.trRender), s = this.getSceneOverride(this.blRender), a = this.getSceneOverride(this.brRender), r = Math.floor(this.width / 2), n = Math.floor(this.height / 2), d = this.height - n;
|
|
865
|
+
let l = 0, f = i ? 0 : this.height - n;
|
|
866
|
+
l = 0, this.drawTo(l, f, r, n, this.tlCam, e), l = r, this.drawTo(l, f, r, n, this.trCam, t), f = i ? d : 0, l = 0, this.scene.overrideMaterial = s, this.drawTo(l, f, r, n, this.blCam, s), l = r, this.drawTo(l, f, r, n, this.brCam, a);
|
|
867
|
+
};
|
|
868
|
+
// Getters
|
|
869
|
+
get appID() {
|
|
870
|
+
return this.props.three.name;
|
|
871
|
+
}
|
|
872
|
+
get mode() {
|
|
873
|
+
return this.state.mode;
|
|
874
|
+
}
|
|
875
|
+
get three() {
|
|
876
|
+
return this.props.three;
|
|
877
|
+
}
|
|
878
|
+
get expandedCameraVisibility() {
|
|
879
|
+
return `${this.appID}_multiviewCameraVisibility`;
|
|
880
|
+
}
|
|
881
|
+
get expandedLightVisibility() {
|
|
882
|
+
return `${this.appID}_multiviewLightVisibility`;
|
|
883
|
+
}
|
|
884
|
+
get expandedGridVisibility() {
|
|
885
|
+
return `${this.appID}_multiviewGridVisibility`;
|
|
886
|
+
}
|
|
887
|
+
}
|
|
888
|
+
export {
|
|
889
|
+
k as default
|
|
890
|
+
};
|