@tomorrowevening/hermes 0.1.42 → 0.1.44
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/core/Application.cjs +1 -0
- package/dist/core/Application.js +0 -1
- package/dist/core/remote/BaseRemote.cjs +1 -0
- package/dist/core/remote/RemoteTheatre.cjs +1 -0
- package/dist/core/remote/RemoteTheatre.js +59 -29
- package/dist/core/remote/RemoteThree.cjs +1 -0
- package/dist/core/remote/RemoteThree.js +4 -3
- package/dist/core/types.cjs +1 -0
- package/dist/editor/Editor.cjs +1 -0
- package/dist/editor/HermesApp.cjs +1 -0
- package/dist/editor/ThreeEditor.cjs +1 -0
- package/dist/editor/components/Draggable.cjs +1 -0
- package/dist/editor/components/DraggableItem.cjs +1 -0
- package/dist/editor/components/Dropdown.cjs +1 -0
- package/dist/editor/components/DropdownItem.cjs +1 -0
- package/dist/editor/components/NavButton.cjs +1 -0
- package/dist/editor/components/content.cjs +1 -0
- package/dist/editor/components/icons/CloseIcon.cjs +1 -0
- package/dist/editor/components/icons/DragIcon.cjs +3 -0
- package/dist/editor/index.cjs +1 -0
- package/dist/editor/index.js +65 -0
- package/dist/editor/multiView/CameraWindow.cjs +1 -0
- package/dist/editor/multiView/DepthNodeMaterial.cjs +1 -0
- package/dist/editor/multiView/InfiniteGridHelper.cjs +1 -0
- package/dist/editor/multiView/InfiniteGridHelperGPU.cjs +1 -0
- package/dist/editor/multiView/InfiniteGridMaterial.cjs +78 -0
- package/dist/editor/multiView/InfiniteGridNodeMaterial.cjs +1 -0
- package/dist/editor/multiView/MultiView.cjs +1 -0
- package/dist/editor/multiView/Toggle.cjs +1 -0
- package/dist/editor/multiView/UVMaterial.cjs +41 -0
- package/dist/editor/multiView/UVNodeMaterial.cjs +1 -0
- package/dist/editor/sidePanel/Accordion.cjs +1 -0
- package/dist/editor/sidePanel/ChildObject.cjs +1 -0
- package/dist/editor/sidePanel/ContainerObject.cjs +1 -0
- package/dist/editor/sidePanel/DebugData.cjs +1 -0
- package/dist/editor/sidePanel/SidePanel.cjs +1 -0
- package/dist/editor/sidePanel/inspector/InspectGrid3.cjs +1 -0
- package/dist/editor/sidePanel/inspector/InspectGrid4.cjs +1 -0
- package/dist/editor/sidePanel/inspector/InspectImage.cjs +1 -0
- package/dist/editor/sidePanel/inspector/InspectNumber.cjs +1 -0
- package/dist/editor/sidePanel/inspector/InspectVector2.cjs +1 -0
- package/dist/editor/sidePanel/inspector/Inspector.cjs +1 -0
- package/dist/editor/sidePanel/inspector/InspectorField.cjs +2 -0
- package/dist/editor/sidePanel/inspector/InspectorGroup.cjs +1 -0
- package/dist/editor/sidePanel/inspector/utils/DragNumber.cjs +1 -0
- package/dist/editor/sidePanel/inspector/utils/InspectAnimation.cjs +1 -0
- package/dist/editor/sidePanel/inspector/utils/InspectCamera.cjs +1 -0
- package/dist/editor/sidePanel/inspector/utils/InspectLight.cjs +1 -0
- package/dist/editor/sidePanel/inspector/utils/InspectMaterial.cjs +1 -0
- package/dist/editor/sidePanel/inspector/utils/InspectTransform.cjs +1 -0
- package/dist/editor/sidePanel/utils.cjs +1 -0
- package/dist/editor/sidePanel/utils.js +1 -1
- package/dist/editor/tools/Transform.cjs +1 -0
- package/dist/editor/tools/splineEditor/Spline.cjs +1 -0
- package/dist/editor/tools/splineEditor/index.cjs +1 -0
- package/dist/editor/utils.cjs +1 -0
- package/dist/index.cjs +1 -0
- package/dist/index.js +61 -129
- package/dist/utils/ImageSequenceCapturer.cjs +13 -0
- package/dist/utils/detectSettings.cjs +1 -0
- package/dist/utils/detectSettings.js +11 -29
- package/dist/utils/math.cjs +1 -0
- package/dist/utils/theatre.cjs +1 -0
- package/dist/utils/theatre.js +60 -82
- package/dist/utils/three.cjs +1 -0
- package/dist/utils/threeDispose.cjs +1 -0
- package/dist/utils/threeDispose.js +40 -0
- package/dist/utils/threeEditorDebug.cjs +1 -0
- package/dist/utils/threeEditorDebug.js +69 -0
- package/dist/webworkers/EventHandling.cjs +1 -0
- package/dist/webworkers/ProxyManager.cjs +1 -0
- package/package.json +23 -7
- package/types/core/types.d.ts +1 -1
- package/types/editor/index.d.ts +26 -0
- package/types/index.d.ts +0 -26
- package/types/utils/detectSettings.d.ts +0 -2
- package/types/utils/theatre.d.ts +0 -1
- package/types/utils/threeDispose.d.ts +4 -0
- package/types/utils/threeEditorDebug.d.ts +17 -0
- package/dist/ThreeEditor-B4bS88iZ.js +0 -111
- package/dist/ThreeEditor-lbW0auGy.css +0 -1
- package/dist/hermes.cjs.js +0 -133
- package/dist/images/android-chrome-192x192.png +0 -0
- package/dist/images/android-chrome-512x512.png +0 -0
- package/dist/images/apple-touch-icon.png +0 -0
- package/dist/images/favicon-16x16.png +0 -0
- package/dist/images/favicon-32x32.png +0 -0
- package/dist/images/favicon.ico +0 -0
- package/dist/images/milkyWay/dark-s_nx.jpg +0 -0
- package/dist/images/milkyWay/dark-s_ny.jpg +0 -0
- package/dist/images/milkyWay/dark-s_nz.jpg +0 -0
- package/dist/images/milkyWay/dark-s_px.jpg +0 -0
- package/dist/images/milkyWay/dark-s_py.jpg +0 -0
- package/dist/images/milkyWay/dark-s_pz.jpg +0 -0
- package/dist/images/site.webmanifest +0 -1
- package/dist/images/uv_grid_opengl.jpg +0 -0
- package/dist/index-C92ji5gy.css +0 -1
- package/dist/index-XMQFdKEt.js +0 -10226
- package/dist/index.html +0 -17
- package/dist/json/animation.json +0 -235
- package/dist/models/Flair.fbx +0 -0
- package/dist/utils/post.js +0 -206
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const s=require("../utils/detectSettings.cjs");class i{assets={audio:new Map,image:new Map,json:new Map,model:new Map,video:new Map};components=new Map;settings={dpr:1,width:0,height:0,mobile:!1,supportOffScreenCanvas:!1,supportWebGPU:!1,quality:"Low",dev:!1,editor:!1};onUpdateCallback;playing=!1;rafID=-1;constructor(t,e=!1){this.settings.dev=t,this.settings.editor=e}dispose(){this.pause(),this.components.forEach(t=>t.dispose()),this.components.clear()}detectSettings(){return new Promise(t=>{s.detectSettings(this.settings.dev,this.settings.editor).then(e=>{this.settings=e,t()})})}update(){}draw(){}play=()=>{this.playing||(this.playing=!0,this.onUpdate())};pause=()=>{this.playing&&(this.playing=!1,cancelAnimationFrame(this.rafID),this.rafID=-1)};onUpdate=()=>{this.update(),this.isApp&&this.draw(),this.onUpdateCallback&&this.onUpdateCallback(),this.rafID=requestAnimationFrame(this.onUpdate)};addComponent(t,e){this.components.set(t,e)}get debugEnabled(){return this.settings.dev}get isApp(){return!this.editor}set isApp(t){this.editor=!t}get editor(){return this.settings.editor}set editor(t){this.settings.editor=t}}module.exports=i;
|
package/dist/core/Application.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";class a{name;debug;editor;broadcastChannel;onMessageHandler;constructor(e,s=!1,t=!1){this.name=e,this.debug=s,this.editor=t,s&&(this.broadcastChannel=new BroadcastChannel(e),this.onMessageHandler=this.messageHandler.bind(this),this.broadcastChannel.addEventListener("message",this.onMessageHandler))}dispose(){this.broadcastChannel?.removeEventListener("message",this.onMessageHandler),this.broadcastChannel?.close()}send(e){if(this.editor&&e.target==="app"||!this.editor&&e.target==="editor")try{this.broadcastChannel?.postMessage(e)}catch(t){console.log("Hermes - Error sending message:"),console.log(t),console.log(e)}}messageHandler(e){const s=e.data;s.target==="app"?this.handleApp(s):this.handleEditor(s)}handleApp(e){}handleEditor(e){}}module.exports=a;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const _=require("@tomorrowevening/theatre-core"),$=require("./BaseRemote.cjs"),g=require("../types.cjs");function q(a){return a!=null&&a.r!==void 0&&a.g!==void 0&&a.b!==void 0}function w(a,e,t,i,h){const s=1-a;return s*s*s*e+3*s*s*a*t+3*s*a*a*i+a*a*a*h}function k(a,e,t){if(a.type!=="bezier"||a.handles.length!==4)throw new Error("Invalid keyframe data for Bézier interpolation.");const[i,h]=a.handles,s=(t-a.position)/(e.position-a.position);return w(s,a.value,a.value+i,e.value+h,e.value)}class C extends ${project;sheets=new Map;sheetObjects=new Map;sheetObjectCBs=new Map;sheetObjectUnsubscribe=new Map;activeSheet;studio=void 0;constructor(e=!1,t=!1){super("RemoteTheatre",e,t)}dispose(){this.project=void 0,this.sheets=new Map,this.sheetObjects=new Map,this.sheetObjectCBs=new Map,this.sheetObjectUnsubscribe=new Map}loadProject(e,t){return this.project=_.getProject(e,{state:t}),new Promise((i,h)=>{this.project?.ready.then(()=>{if(t){const s=t.sheetsById;for(const n in s)this.sheet(n)}i()}).catch(()=>h())})}getSheetInstance(e,t){return t!==void 0?`${e}-${t}`:e}sheet(e,t){if(this.project===void 0){console.error("Theatre Project hasn't been created yet.");return}const i=this.getSheetInstance(e,t);let h=this.sheets.get(i);return h!==void 0||(h=this.project?.sheet(e,t),this.sheets.set(i,h),this.send({event:"createSheet",target:"editor",data:{sheet:e,instance:t}})),h}playSheet(e,t,i){return new Promise(h=>{this.sheet(e,i)?.sequence.play(t).then(s=>h(s)),this.send({event:"playSheet",target:"editor",data:{sheet:e,instance:i,value:t}})})}pauseSheet(e,t){this.sheet(e,t)?.sequence.pause(),this.send({event:"pauseSheet",target:"editor",data:{sheet:e,instance:t}})}clearSheetObjects(e){this.sheetObjects.forEach((t,i)=>{i.search(`${e}_`)>-1&&this.unsubscribe(t)})}sheetObject(e,t,i,h,s){if(this.project===void 0){console.error("Theatre Project hasn't been created yet.");return}const n=this.sheet(e,s);if(n===void 0)return;const u=`${this.getSheetInstance(e,s)}_${t}`;let b=this.sheetObjects.get(u),j=i;b!==void 0&&(j={...i,...b.value}),b=n.object(t,j,{reconfigure:!0}),this.sheetObjects.set(u,b),this.sheetObjectCBs.set(u,h!==void 0?h:g.noop);function v(d,p,o){if(typeof o=="object")if(q(o))d[p]={r:o.r,g:o.g,b:o.b,a:o.a};else for(const r in o){const l=o[r];typeof l=="object"&&v(o,r,l)}}const c=b.onValuesChange(d=>{const p=this.sheetObjectCBs.get(u);if(this.editor){for(const o in d){const r=d[o];typeof r=="object"&&v(d,o,r)}this.send({event:"updateSheetObject",target:"app",data:{sheet:e,sheetObject:u,values:d}}),p&&p(d)}else p&&p(d)});return this.sheetObjectUnsubscribe.set(u,c),this.send({event:"createSheetObject",target:"editor",data:{sheet:e,instance:s,key:t,props:JSON.stringify(i)}}),b}getSheetObjectKeyframes(e,t,i){const h=this.sheet(e);if(h===void 0)return[];const s=`${e}_${t}`,n=this.sheetObjects.get(s);return n===void 0?[]:h.sequence.__experimental_getKeyframes(n.props[i])}getSheetObjectVectors(e,t){const i=this.sheet(e);if(i===void 0)return[];const h=`${e}_${t}`,s=this.sheetObjects.get(h);if(s===void 0)return[];const n=[],f=i.sequence.__experimental_getKeyframes(s.props.x),u=i.sequence.__experimental_getKeyframes(s.props.y),b=i.sequence.__experimental_getKeyframes(s.props.z),j=new Set;return f.forEach(c=>j.add(c.position)),u.forEach(c=>j.add(c.position)),b.forEach(c=>j.add(c.position)),Array.from(j).sort((c,d)=>c-d).forEach(c=>{const d=(p,o)=>{const r=p.find((S,y)=>S.position<=o&&(p[y+1]?.position||1/0)>o),l=p.find(S=>S.position>o);if(!r)return l?.value||0;if(!l||r.position===o)return r.value;if(r.type==="bezier")return k(r,l,o);const O=(o-r.position)/(l.position-r.position);return r.value+O*(l.value-r.value)};n.push({position:c,x:d(f,c),y:d(u,c),z:d(b,c)})}),n}update(e){}unsubscribe(e){if(this.project===void 0){console.error("Theatre Project hasn't been created yet.");return}const t=e.address.sheetId,i=e.address.objectKey;this.sheets.get(t)?.detachObject(i);const s=`${t}_${i}`,n=this.sheetObjectUnsubscribe.get(s);n!==void 0&&(this.sheetObjects.delete(s),this.sheetObjectCBs.delete(s),this.sheetObjectUnsubscribe.delete(s),n())}handleApp(e){let t;switch(e.event){case"setSheet":t=this.sheets.get(e.data.sheet),t!==void 0?this.studio?.setSelection([t]):console.log(`Hermes - Can't set Sheet: ${e.data.sheet}`,t);break;case"setSheetObject":t=this.sheetObjects.get(`${e.data.sheet}_${e.data.key}`),t!==void 0?this.studio?.setSelection([t]):console.log(`Hermes - Can't set Sheet Object: ${e.data.sheet}, ${e.data.key}: ${e.data.sheet}_${e.data.key}`,t);break;case"updateSheetObject":t=this.sheets.get(e.data.sheet),t!==void 0&&t.sequence.pause(),t=this.sheetObjectCBs.get(e.data.sheetObject),t!==void 0?t(e.data.values):console.log(`Hermes - Can't update Sheet Object: ${e.data.sheetObject}, ${e.data.sheet}`,t);break;case"updateTimeline":t=this.sheets.get(e.data.sheet),t!==void 0?t.sequence.position=e.data.position:console.log(`Hermes - Can't update sheet position: ${e.data.sheet}, ${e.data.position}`);break}}handleEditor(e){switch(e.event){case"createSheet":this.sheet(e.data.sheet,e.data.instance);break;case"playSheet":this.sheet(e.data.sheet,e.data.instance)?.sequence.play(e.data.value);break;case"pauseSheet":this.sheet(e.data.sheet,e.data.instance)?.sequence.pause();break;case"createSheetObject":this.sheetObject(e.data.sheet,e.data.key,JSON.parse(e.data.props),void 0,e.data.instanceId);break}}getSheetNames(){const e=[];return this.sheets.forEach((t,i)=>{e.push(i)}),e}handleEditorApp(){if(this.editor){this.studio?.ui.restore(),this.studio?.onSelectionChange(h=>{h.length<1||h.forEach(s=>{let n=s.address.sheetId,f="setSheet",u={};switch(s.type){case"Theatre_Sheet_PublicAPI":f="setSheet",u={sheet:s.address.sheetId},this.activeSheet=this.sheets.get(s.address.sheetId);break;case"Theatre_SheetObject_PublicAPI":f="setSheetObject",n+=`_${s.address.objectKey}`,u={id:n,sheet:s.address.sheetId,key:s.address.objectKey},this.activeSheet=this.sheets.get(s.address.sheetId);break}this.send({event:f,target:"app",data:u})})});let e=-1;const t=()=>{if(this.activeSheet!==void 0&&e!==this.activeSheet.sequence.position){e=this.activeSheet.sequence.position;const h=this.activeSheet;this.send({event:"updateTimeline",target:"app",data:{position:e,sheet:h.address.sheetId}})}},i=()=>{t(),requestAnimationFrame(i)};t(),i()}else this.studio?.ui.hide()}}module.exports=C;
|
|
@@ -1,24 +1,26 @@
|
|
|
1
1
|
import { getProject as _ } from "@tomorrowevening/theatre-core";
|
|
2
2
|
import $ from "./BaseRemote.js";
|
|
3
3
|
import { noop as g } from "../types.js";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const s = 1 - n;
|
|
7
|
-
return s * s * s * e + 3 * s * s * n * t + 3 * s * n * n * i + n * n * n * h;
|
|
4
|
+
function w(a) {
|
|
5
|
+
return a != null && a.r !== void 0 && a.g !== void 0 && a.b !== void 0;
|
|
8
6
|
}
|
|
9
|
-
function
|
|
10
|
-
|
|
7
|
+
function k(a, e, t, i, h) {
|
|
8
|
+
const s = 1 - a;
|
|
9
|
+
return s * s * s * e + 3 * s * s * a * t + 3 * s * a * a * i + a * a * a * h;
|
|
10
|
+
}
|
|
11
|
+
function P(a, e, t) {
|
|
12
|
+
if (a.type !== "bezier" || a.handles.length !== 4)
|
|
11
13
|
throw new Error("Invalid keyframe data for Bézier interpolation.");
|
|
12
|
-
const [i, h] =
|
|
13
|
-
return
|
|
14
|
+
const [i, h] = a.handles, s = (t - a.position) / (e.position - a.position);
|
|
15
|
+
return k(
|
|
14
16
|
s,
|
|
15
|
-
|
|
16
|
-
|
|
17
|
+
a.value,
|
|
18
|
+
a.value + i,
|
|
17
19
|
e.value + h,
|
|
18
20
|
e.value
|
|
19
21
|
);
|
|
20
22
|
}
|
|
21
|
-
class
|
|
23
|
+
class B extends $ {
|
|
22
24
|
project;
|
|
23
25
|
sheets = /* @__PURE__ */ new Map();
|
|
24
26
|
sheetObjects = /* @__PURE__ */ new Map();
|
|
@@ -37,7 +39,7 @@ class E extends $ {
|
|
|
37
39
|
this.project?.ready.then(() => {
|
|
38
40
|
if (t) {
|
|
39
41
|
const s = t.sheetsById;
|
|
40
|
-
for (const
|
|
42
|
+
for (const n in s) this.sheet(n);
|
|
41
43
|
}
|
|
42
44
|
i();
|
|
43
45
|
}).catch(() => h());
|
|
@@ -53,7 +55,14 @@ class E extends $ {
|
|
|
53
55
|
}
|
|
54
56
|
const i = this.getSheetInstance(e, t);
|
|
55
57
|
let h = this.sheets.get(i);
|
|
56
|
-
return h !== void 0 || (h = this.project?.sheet(e, t), this.sheets.set(i, h)
|
|
58
|
+
return h !== void 0 || (h = this.project?.sheet(e, t), this.sheets.set(i, h), this.send({
|
|
59
|
+
event: "createSheet",
|
|
60
|
+
target: "editor",
|
|
61
|
+
data: {
|
|
62
|
+
sheet: e,
|
|
63
|
+
instance: t
|
|
64
|
+
}
|
|
65
|
+
})), h;
|
|
57
66
|
}
|
|
58
67
|
playSheet(e, t, i) {
|
|
59
68
|
return new Promise((h) => {
|
|
@@ -88,11 +97,11 @@ class E extends $ {
|
|
|
88
97
|
console.error("Theatre Project hasn't been created yet.");
|
|
89
98
|
return;
|
|
90
99
|
}
|
|
91
|
-
const
|
|
92
|
-
if (
|
|
100
|
+
const n = this.sheet(e, s);
|
|
101
|
+
if (n === void 0) return;
|
|
93
102
|
const u = `${this.getSheetInstance(e, s)}_${t}`;
|
|
94
103
|
let b = this.sheetObjects.get(u), j = i;
|
|
95
|
-
b !== void 0 && (j = { ...i, ...b.value }), b =
|
|
104
|
+
b !== void 0 && (j = { ...i, ...b.value }), b = n.object(t, j, { reconfigure: !0 }), this.sheetObjects.set(u, b), this.sheetObjectCBs.set(u, h !== void 0 ? h : g);
|
|
96
105
|
function v(d, p, o) {
|
|
97
106
|
if (typeof o == "object")
|
|
98
107
|
if (w(o))
|
|
@@ -127,37 +136,46 @@ class E extends $ {
|
|
|
127
136
|
} else
|
|
128
137
|
p && p(d);
|
|
129
138
|
});
|
|
130
|
-
return this.sheetObjectUnsubscribe.set(u, c),
|
|
139
|
+
return this.sheetObjectUnsubscribe.set(u, c), this.send({
|
|
140
|
+
event: "createSheetObject",
|
|
141
|
+
target: "editor",
|
|
142
|
+
data: {
|
|
143
|
+
sheet: e,
|
|
144
|
+
instance: s,
|
|
145
|
+
key: t,
|
|
146
|
+
props: JSON.stringify(i)
|
|
147
|
+
}
|
|
148
|
+
}), b;
|
|
131
149
|
}
|
|
132
150
|
getSheetObjectKeyframes(e, t, i) {
|
|
133
151
|
const h = this.sheet(e);
|
|
134
152
|
if (h === void 0) return [];
|
|
135
|
-
const s = `${e}_${t}`,
|
|
136
|
-
return
|
|
153
|
+
const s = `${e}_${t}`, n = this.sheetObjects.get(s);
|
|
154
|
+
return n === void 0 ? [] : h.sequence.__experimental_getKeyframes(n.props[i]);
|
|
137
155
|
}
|
|
138
156
|
getSheetObjectVectors(e, t) {
|
|
139
157
|
const i = this.sheet(e);
|
|
140
158
|
if (i === void 0) return [];
|
|
141
159
|
const h = `${e}_${t}`, s = this.sheetObjects.get(h);
|
|
142
160
|
if (s === void 0) return [];
|
|
143
|
-
const
|
|
161
|
+
const n = [], f = i.sequence.__experimental_getKeyframes(s.props.x), u = i.sequence.__experimental_getKeyframes(s.props.y), b = i.sequence.__experimental_getKeyframes(s.props.z), j = /* @__PURE__ */ new Set();
|
|
144
162
|
return f.forEach((c) => j.add(c.position)), u.forEach((c) => j.add(c.position)), b.forEach((c) => j.add(c.position)), Array.from(j).sort((c, d) => c - d).forEach((c) => {
|
|
145
163
|
const d = (p, o) => {
|
|
146
164
|
const r = p.find((S, y) => S.position <= o && (p[y + 1]?.position || 1 / 0) > o), l = p.find((S) => S.position > o);
|
|
147
165
|
if (!r) return l?.value || 0;
|
|
148
166
|
if (!l || r.position === o) return r.value;
|
|
149
167
|
if (r.type === "bezier")
|
|
150
|
-
return
|
|
168
|
+
return P(r, l, o);
|
|
151
169
|
const O = (o - r.position) / (l.position - r.position);
|
|
152
170
|
return r.value + O * (l.value - r.value);
|
|
153
171
|
};
|
|
154
|
-
|
|
172
|
+
n.push({
|
|
155
173
|
position: c,
|
|
156
174
|
x: d(f, c),
|
|
157
175
|
y: d(u, c),
|
|
158
176
|
z: d(b, c)
|
|
159
177
|
});
|
|
160
|
-
}),
|
|
178
|
+
}), n;
|
|
161
179
|
}
|
|
162
180
|
update(e) {
|
|
163
181
|
}
|
|
@@ -168,8 +186,8 @@ class E extends $ {
|
|
|
168
186
|
}
|
|
169
187
|
const t = e.address.sheetId, i = e.address.objectKey;
|
|
170
188
|
this.sheets.get(t)?.detachObject(i);
|
|
171
|
-
const s = `${t}_${i}`,
|
|
172
|
-
|
|
189
|
+
const s = `${t}_${i}`, n = this.sheetObjectUnsubscribe.get(s);
|
|
190
|
+
n !== void 0 && (this.sheetObjects.delete(s), this.sheetObjectCBs.delete(s), this.sheetObjectUnsubscribe.delete(s), n());
|
|
173
191
|
}
|
|
174
192
|
handleApp(e) {
|
|
175
193
|
let t;
|
|
@@ -190,12 +208,24 @@ class E extends $ {
|
|
|
190
208
|
}
|
|
191
209
|
handleEditor(e) {
|
|
192
210
|
switch (e.event) {
|
|
211
|
+
case "createSheet":
|
|
212
|
+
this.sheet(e.data.sheet, e.data.instance);
|
|
213
|
+
break;
|
|
193
214
|
case "playSheet":
|
|
194
215
|
this.sheet(e.data.sheet, e.data.instance)?.sequence.play(e.data.value);
|
|
195
216
|
break;
|
|
196
217
|
case "pauseSheet":
|
|
197
218
|
this.sheet(e.data.sheet, e.data.instance)?.sequence.pause();
|
|
198
219
|
break;
|
|
220
|
+
case "createSheetObject":
|
|
221
|
+
this.sheetObject(
|
|
222
|
+
e.data.sheet,
|
|
223
|
+
e.data.key,
|
|
224
|
+
JSON.parse(e.data.props),
|
|
225
|
+
void 0,
|
|
226
|
+
e.data.instanceId
|
|
227
|
+
);
|
|
228
|
+
break;
|
|
199
229
|
}
|
|
200
230
|
}
|
|
201
231
|
getSheetNames() {
|
|
@@ -208,7 +238,7 @@ class E extends $ {
|
|
|
208
238
|
if (this.editor) {
|
|
209
239
|
this.studio?.ui.restore(), this.studio?.onSelectionChange((h) => {
|
|
210
240
|
h.length < 1 || h.forEach((s) => {
|
|
211
|
-
let
|
|
241
|
+
let n = s.address.sheetId, f = "setSheet", u = {};
|
|
212
242
|
switch (s.type) {
|
|
213
243
|
case "Theatre_Sheet_PublicAPI":
|
|
214
244
|
f = "setSheet", u = {
|
|
@@ -216,8 +246,8 @@ class E extends $ {
|
|
|
216
246
|
}, this.activeSheet = this.sheets.get(s.address.sheetId);
|
|
217
247
|
break;
|
|
218
248
|
case "Theatre_SheetObject_PublicAPI":
|
|
219
|
-
f = "setSheetObject",
|
|
220
|
-
id:
|
|
249
|
+
f = "setSheetObject", n += `_${s.address.objectKey}`, u = {
|
|
250
|
+
id: n,
|
|
221
251
|
sheet: s.address.sheetId,
|
|
222
252
|
key: s.address.objectKey
|
|
223
253
|
}, this.activeSheet = this.sheets.get(s.address.sheetId);
|
|
@@ -249,5 +279,5 @@ class E extends $ {
|
|
|
249
279
|
}
|
|
250
280
|
}
|
|
251
281
|
export {
|
|
252
|
-
|
|
282
|
+
B as default
|
|
253
283
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const h=require("three/webgpu"),l=require("./BaseRemote.cjs"),u=require("../../utils/math.cjs"),c=require("../../utils/threeDispose.cjs"),o=require("../../utils/threeEditorDebug.cjs");var p=(a=>(a.CUSTOM="ToolEvents::custom",a.SELECT_DROPDOWN="ToolEvents::selectDropdown",a.DRAG_UPDATE="ToolEvents::dragUpdate",a.ADD_SCENE="ToolEvents::addScene",a.REFRESH_SCENE="ToolEvents::refreshScene",a.REMOVE_SCENE="ToolEvents::removeScene",a.SET_SCENE="ToolEvents::setScene",a.SET_OBJECT="ToolEvents::setObject",a.CLEAR_OBJECT="ToolEvents::clearObject",a.ADD_CAMERA="ToolEvents::addCamera",a.REMOVE_CAMERA="ToolEvents::removeCamera",a.ADD_GROUP="ToolEvents::addGroup",a.REMOVE_GROUP="ToolEvents::removeGroup",a.ADD_SPLINE="ToolEvents::addSpline",a.ADD_RENDERER="ToolEvents::addRenderer",a.UPDATE_RENDERER="ToolEvents::updateRenderer",a))(p||{});class g extends l{name;canvas=null;inputElement=null;scene=void 0;scenes=new Map;renderer=void 0;renderTargets=new Map;renderTargetsResize=new Map;groups=new Map;_listeners={};editorUtils;constructor(e,t=!1,r=!1){super("RemoteThree",t,r),this.name=e}setEditorUtils(e){this.editorUtils=e}dispose(){this.scenes.forEach(e=>{c.dispose(e)}),this.scenes.clear(),this.scene&&c.dispose(this.scene),this.renderTargets.forEach(e=>{e.dispose()}),this.renderTargets.clear(),this.renderer?.dispose()}addEventListener(e,t){this._listeners===void 0&&(this._listeners={});const r=this._listeners;r[e]===void 0&&(r[e]=[]),r[e].indexOf(t)===-1&&r[e].push(t)}hasEventListener(e,t){const r=this._listeners;return r===void 0?!1:r[e]!==void 0&&r[e].indexOf(t)!==-1}removeEventListener(e,t){const r=this._listeners;if(r===void 0)return;const s=r[e];if(s!==void 0){const d=s.indexOf(t);d!==-1&&s.splice(d,1)}}dispatchEvent(e){const t=this._listeners;if(t===void 0)return;const r=t[e.type];if(r!==void 0){const s={...e,target:this},d=r.slice(0);for(let i=0,n=d.length;i<n;i++)d[i].call(this,s)}}getObjectByUUID(e){const t=e.split(".")[0],r=this.scenes.get(t);if(r!==void 0)return r.getObjectByProperty("uuid",e)}getObject(e){if(!this.debug)return;this.renderer!==void 0&&(o.ExportTexture.renderer=this.renderer);const t=this.getObjectByUUID(e);t&&this.setObject(t)}setObject(e){if(!this.editorUtils)return;this.renderer!==void 0&&(o.ExportTexture.renderer=this.renderer);const t=this.editorUtils.stripObject(e);this.dispatchEvent({type:"ToolEvents::setObject",value:t})}requestMethod(e,t,r,s){const d=this.getObjectByUUID(e);if(d)try{if(s!==void 0){const i=this.editorUtils?.getSubItem(d,s);i!==void 0&&i[t](r)}else d[t](r)}catch(i){console.log("Hermes - Error requesting method:",e,t,r),console.log(i)}}updateObject(e,t,r){this.send({event:"updateObject",target:"app",data:{uuid:e,key:t,value:r}})}createTexture(e,t,r){this.send({event:"createTexture",target:"app",data:{uuid:e,key:t,value:r}})}onUpdateObject(e,t,r){const s=this.getObjectByUUID(e);s&&this.editorUtils?.setItemProps(s,t,r)}onCreateTexture(e,t,r){if(!this.editorUtils)return;const s=this.getObjectByUUID(e);if(s){const d=i=>{const n=t.split(".");switch(n.length){case 1:s[n[0]]=i;break;case 2:s[n[0]][n[1]]=i;break;case 3:s[n[0]][n[1]][n[2]]=i;break;case 4:s[n[0]][n[1]][n[2]][n[3]]=i;break;case 5:s[n[0]][n[1]][n[2]][n[3]][n[4]]=i;break}s.material.needsUpdate=!0};r.src.length>0?this.editorUtils.textureFromSrc(r.src).then(i=>{i.offset.set(r.offset[0],r.offset[1]),i.repeat.set(r.repeat[0],r.repeat[1]),d(i)}):d(null)}}addGroup(e){this.groups.get(e.title)===void 0&&(this.groups.set(e.title,{title:e.title,onUpdate:e.onUpdate}),this.send({event:"addGroup",target:"editor",data:JSON.stringify(e)}))}removeGroup(e){this.groups.get(e)!==void 0&&(this.groups.delete(e),this.send({event:"removeGroup",target:"editor",data:e}))}updateGroup(e,t,r){this.send({event:"updateGroup",target:"app",data:JSON.stringify({group:e,prop:t,value:r})})}addSplineCurve(e){setTimeout(()=>{this.send({event:"addSpline",target:"editor",data:JSON.stringify(e.toJSON())})},1)}addSplineObject(e){setTimeout(()=>{this.send({event:"addSpline",target:"editor",data:JSON.stringify(e)})},1)}setRenderer(e,t=null){if(this.renderer=e,this.canvas=e.domElement,this.inputElement=t!==null?t:this.canvas,!this.debug)return;const r=`#${e.getClearColor(new h.Color).getHexString()}`;this.send({event:"addRenderer",target:"editor",data:{autoClearColor:e.autoClearColor,outputColorSpace:e.outputColorSpace,clearColor:r,clearAlpha:e.getClearAlpha(),colorManagement:h.ColorManagement.enabled,toneMapping:e.toneMapping,toneMappingExposure:e.toneMappingExposure,type:e.isWebGLRenderer?"WebGLRenderer":"WebGPURenderer"}})}updateRenderer(e){this.send({event:"updateRenderer",target:"app",data:e})}addScene(e){if(e===void 0||(this.scenes.set(e.name,e),!this.debug||!this.editorUtils))return;o.resetThreeObjects(),o.hierarchyUUID(e);const t=this.editorUtils.stripScene(e);this.send({event:"addScene",target:"editor",data:t})}refreshScene(e){if(!this.debug||!this.editorUtils)return;const t=this.scenes.get(e);if(t!==void 0){const r=this.editorUtils.stripScene(t);this.send({event:"refreshScene",target:"app",data:r})}}removeScene(e){if(e===void 0||(this.scenes.delete(e.name),!this.debug||!this.editorUtils))return;const t=this.editorUtils.stripScene(e);this.send({event:"removeScene",target:"editor",data:t})}removeAllScenes(){this.scenes.forEach(e=>this.removeScene(e))}getScene(e){let t=null;return this.scene!==void 0&&this.scene.uuid.search(e)>-1?this.scene:(this.scenes.forEach((r,s)=>{e.search(s)>-1&&(t=r)}),t)}setScene(e){if(e===void 0||(this.scene=e,!this.debug||!this.editorUtils))return;this.renderer!==void 0&&(o.ExportTexture.renderer=this.renderer),o.resetThreeObjects(),o.hierarchyUUID(e);const t=this.editorUtils.stripScene(e);this.send({event:"setScene",target:"editor",data:t})}requestSize(){this.send({event:"requestSize",target:"app"})}requestRenderer(){this.send({event:"requestRenderer",target:"app"})}requestScene(){this.send({event:"requestScene",target:"app"})}addCamera(e){if(!this.debug||!this.editorUtils)return;const t=this.editorUtils.stripObject(e);this.send({event:"addCamera",target:"editor",data:t})}removeCamera(e){if(!this.debug||!this.editorUtils)return;const t=this.editorUtils.stripObject(e);this.send({event:"removeCamera",target:"editor",data:t})}handleApp(e){switch(e.event){case"refreshScene":this.editorUtils&&this.send({event:"refreshScene",target:"editor",data:this.editorUtils.stripScene(this.scenes.get(e.data.name))});break;case"updateRenderer":this.renderer&&(this.renderer.autoClearColor=e.data.autoClearColor,this.renderer.outputColorSpace=e.data.outputColorSpace,this.renderer.setClearColor(e.data.clearColor,e.data.clearAlpha),this.renderer.toneMapping=e.data.toneMapping,this.renderer.toneMappingExposure=e.data.toneMappingExposure,h.ColorManagement.enabled=e.data.colorManagement);break;case"requestRenderer":if(this.renderer!==void 0){const t=`#${this.renderer.getClearColor(new h.Color).getHexString()}`;this.send({event:"addRenderer",target:"editor",data:{autoClearColor:this.renderer.autoClearColor,outputColorSpace:this.renderer.outputColorSpace,clearColor:t,clearAlpha:this.renderer.getClearAlpha(),colorManagement:h.ColorManagement.enabled,toneMapping:this.renderer.toneMapping,toneMappingExposure:this.renderer.toneMappingExposure,type:this.renderer.isWebGLRenderer?"WebGLRenderer":"WebGPURenderer"}})}break;case"requestScene":this.editorUtils&&(this.scenes.forEach(t=>{o.resetThreeObjects(),o.hierarchyUUID(t),this.send({event:"addScene",target:"editor",data:this.editorUtils.stripScene(t)})}),this.scene!==void 0&&(this.renderer!==void 0&&(o.ExportTexture.renderer=this.renderer),o.resetThreeObjects(),o.hierarchyUUID(this.scene),this.send({event:"setScene",target:"editor",data:this.editorUtils.stripScene(this.scene)})));break}if(e.event==="updateGroup"){const t=JSON.parse(e.data);this.groups.get(t.group)?.onUpdate(t.prop,t.value)}}handleEditor(e){switch(e.event){case"addScene":this.dispatchEvent({type:"ToolEvents::addScene",value:e.data});break;case"refreshScene":this.dispatchEvent({type:"ToolEvents::refreshScene",value:e.data});break;case"removeScene":this.dispatchEvent({type:"ToolEvents::removeScene",value:e.data});break;case"setScene":this.dispatchEvent({type:"ToolEvents::setScene",value:e.data});break;case"addCamera":this.dispatchEvent({type:"ToolEvents::addCamera",value:e.data});break;case"removeCamera":this.dispatchEvent({type:"ToolEvents::removeCamera",value:e.data});break;case"addGroup":this.dispatchEvent({type:"ToolEvents::addGroup",value:e.data});break;case"removeGroup":this.dispatchEvent({type:"ToolEvents::removeGroup",value:e.data});break;case"addSpline":this.dispatchEvent({type:"ToolEvents::addSpline",value:e.data});break;case"addRenderer":this.dispatchEvent({type:"ToolEvents::addRenderer",value:e.data})}}messageHandler(e){const t=e.data;if(t.event==="updateObject"){this.onUpdateObject(t.data.uuid,t.data.key,t.data.value);return}else if(t.event==="createTexture"){this.onCreateTexture(t.data.uuid,t.data.key,t.data.value);return}else if(t.event==="requestSize"){t.target==="app"?this.send({event:"requestSize",target:"editor",data:{width:this.width,height:this.height}}):this.scenes.forEach(r=>{r.resize!==void 0&&r.resize(t.data.width,t.data.height)});return}t.target==="app"?this.handleApp(t):this.handleEditor(t)}addRT(e,t=!0,r){if(!this.renderer)return;let s;this.renderer instanceof h.WebGPURenderer?s=new h.RenderTarget(32,32,r):s=new h.WebGLRenderTarget(32,32,r),s.texture.name=e,this.renderTargets.set(e,s),this.renderTargetsResize.set(e,t)}removeRT(e){this.renderTargets.delete(e),this.renderTargetsResize.delete(e)}resize(e,t){const r=this.dpr;this.renderTargets.forEach((d,i)=>{this.renderTargetsResize.get(i)&&d.setSize(e*r,t*r)});const s=!(this.renderer?.domElement instanceof OffscreenCanvas);this.renderer?.setSize(e,t,s)}set dpr(e){this.renderer?.setPixelRatio(u.clamp(1,2,e))}get dpr(){return this.renderer!==void 0?this.renderer?.getPixelRatio():1}get width(){return this.renderer!==void 0?this.renderer.domElement.width/this.dpr:0}get height(){return this.renderer!==void 0?this.renderer.domElement.height/this.dpr:0}}exports.ToolEvents=p;exports.default=g;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { Color as l, ColorManagement as p, WebGPURenderer as g, RenderTarget as v, WebGLRenderTarget as f } from "three/webgpu";
|
|
2
2
|
import E from "./BaseRemote.js";
|
|
3
3
|
import { clamp as S } from "../../utils/math.js";
|
|
4
|
-
import { dispose as u
|
|
4
|
+
import { dispose as u } from "../../utils/threeDispose.js";
|
|
5
|
+
import { hierarchyUUID as o, ExportTexture as h, resetThreeObjects as c } from "../../utils/threeEditorDebug.js";
|
|
5
6
|
var b = /* @__PURE__ */ ((a) => (a.CUSTOM = "ToolEvents::custom", a.SELECT_DROPDOWN = "ToolEvents::selectDropdown", a.DRAG_UPDATE = "ToolEvents::dragUpdate", a.ADD_SCENE = "ToolEvents::addScene", a.REFRESH_SCENE = "ToolEvents::refreshScene", a.REMOVE_SCENE = "ToolEvents::removeScene", a.SET_SCENE = "ToolEvents::setScene", a.SET_OBJECT = "ToolEvents::setObject", a.CLEAR_OBJECT = "ToolEvents::clearObject", a.ADD_CAMERA = "ToolEvents::addCamera", a.REMOVE_CAMERA = "ToolEvents::removeCamera", a.ADD_GROUP = "ToolEvents::addGroup", a.REMOVE_GROUP = "ToolEvents::removeGroup", a.ADD_SPLINE = "ToolEvents::addSpline", a.ADD_RENDERER = "ToolEvents::addRenderer", a.UPDATE_RENDERER = "ToolEvents::updateRenderer", a))(b || {});
|
|
6
|
-
class
|
|
7
|
+
class y extends E {
|
|
7
8
|
name;
|
|
8
9
|
canvas = null;
|
|
9
10
|
// Canvas or OffscreenCanvas
|
|
@@ -447,5 +448,5 @@ class O extends E {
|
|
|
447
448
|
}
|
|
448
449
|
export {
|
|
449
450
|
b as ToolEvents,
|
|
450
|
-
|
|
451
|
+
y as default
|
|
451
452
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=()=>{},t=()=>{};exports.defaultTheatreCallback=t;exports.noop=e;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const r=require("react/jsx-runtime"),d=require("react");;/* empty css */const t=d.forwardRef((e,i)=>r.jsxs("div",{className:"editor",ref:i,style:e.style,children:[e.header&&r.jsx("div",{className:"header",children:e.header}),e.children,e.footer&&r.jsx("div",{className:"footer",children:e.footer})]}));t.displayName="Editor";module.exports=t;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const e=require("react/jsx-runtime"),i=require("react");function h(c){const{app:t,renderEditor:r,onLoad:n,renderLoading:o=null,children:d}=c,[u,s]=i.useState(!1);if(i.useEffect(()=>{t.detectSettings().then(()=>{n?n(t).then(()=>s(!0)):s(!0)})},[]),!u)return e.jsx(e.Fragment,{children:o});if(t.editor&&r){const a=t.components.get("three");return e.jsx(e.Fragment,{children:r(a)})}return e.jsx(e.Fragment,{children:d?.(t)})}module.exports=h;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const r=require("react/jsx-runtime"),n=require("react"),i=require("./Editor.cjs"),s=require("./multiView/MultiView.cjs"),c=require("./sidePanel/SidePanel.cjs"),t=require("./sidePanel/utils.cjs"),u={stripObject:t.stripObject,stripScene:t.stripScene,getSubItem:t.getSubItem,setItemProps:t.setItemProps,textureFromSrc:t.textureFromSrc};function o(e){return n.useEffect(()=>(e.three.setEditorUtils(u),()=>e.three.setEditorUtils(void 0)),[e.three]),r.jsxs(i,{children:[r.jsx(s,{three:e.three,scenes:e.scenes,onSceneAdd:e.onSceneAdd,onSceneResize:e.onSceneResize,onSceneUpdate:e.onSceneUpdate}),r.jsx(c,{three:e.three})]})}module.exports=o;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const r=require("react/jsx-runtime"),l=require("react"),f=require("./NavButton.cjs"),j=require("./DraggableItem.cjs");function I(s){const[u,c]=l.useState(!1),[n,d]=l.useState(s.options),[o,a]=l.useState(null),g=e=>{s.onDragComplete(e),d(e)},m=e=>{const t=[...n];t.splice(e,1),g(t)},D=e=>{a(e)},x=e=>{if(o===e||o===null)return;const t=[...n],b=t.splice(o,1)[0];t.splice(e,0,b),a(e),d(t)},p=()=>{s.onDragComplete(n),a(null)};let i="dropdown draggable";return s.subdropdown&&(i+=" subdropdown"),r.jsxs("div",{className:i,onMouseEnter:()=>c(!0),onMouseLeave:()=>c(!1),children:[r.jsx(f,{title:s.title}),r.jsx("ul",{className:"reorder-list",style:{display:u?"block":"none"},children:n.map((e,t)=>r.jsx(j,{title:e,index:t,draggingIndex:o,onDelete:m,onDragStart:D,onDragOver:x,onDragEnd:p},e))})]})}module.exports=I;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const n=require("react/jsx-runtime"),t=require("./icons/CloseIcon.cjs"),a=require("./icons/DragIcon.cjs");function i(e){return n.jsx("li",{className:`reorder-item ${e.draggingIndex===e.index?"dragging":""}`,draggable:!0,onDragStart:()=>e.onDragStart(e.index),onDragOver:r=>{r.preventDefault(),e.onDragOver(e.index)},onDragEnd:e.onDragEnd,children:n.jsxs("div",{children:[a,n.jsx("span",{children:e.title}),n.jsx("button",{className:"closeIcon",onClick:()=>e.onDelete(e.index),children:t})]})})}module.exports=i;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const t=require("react/jsx-runtime"),l=require("react"),u=require("./NavButton.cjs"),c=require("./DropdownItem.cjs");function a(e){const[d,s]=l.useState(!1),n=[];e.options.map((o,r)=>{e.onSelect!==void 0&&(o.onSelect=e.onSelect),n.push(t.jsx(c,{option:o},r))});let i="dropdown";return e.subdropdown&&(i+=" subdropdown"),t.jsxs("div",{className:i,onMouseEnter:()=>s(!0),onMouseLeave:()=>s(!1),children:[t.jsx(u,{title:e.title}),t.jsx("ul",{style:{visibility:d?"visible":"hidden"},children:n})]})}module.exports=a;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const o=require("react/jsx-runtime"),s=require("react"),c=require("./Draggable.cjs"),a=require("./Dropdown.cjs"),u=require("../utils.cjs");function d(r){const{option:e}=r,[l,n]=s.useState("");let t;switch(e.type){case"draggable":t=o.jsx(c,{title:e.title,options:e.value,onDragComplete:i=>{e.onDragComplete!==void 0&&e.onDragComplete(i)},subdropdown:!0});break;case"dropdown":t=o.jsx(a,{title:e.title,options:e.value,onSelect:e.onSelect,subdropdown:!0});break;case"option":t=o.jsx("button",{onClick:()=>{e.onSelect!==void 0&&e.onSelect(e.value),e.selectable&&(l!==e.title?n(e.title):n(""))},children:e.title});break}return o.jsx("li",{className:l===e.title?"selected":"",children:t},u.randomID())}module.exports=d;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const e=require("react/jsx-runtime");function n(t){return t.title.search("<")>-1?e.jsx("button",{className:"svg",dangerouslySetInnerHTML:{__html:t.title}}):e.jsx("button",{children:t.title})}module.exports=n;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const A="data:image/gif;base64,R0lGODlhDgFkAIAAAP///wAAACH/C1hNUCBEYXRhWE1QPD94cGFja2V0IGJlZ2luPSLvu78iIGlkPSJXNU0wTXBDZWhpSHpyZVN6TlRjemtjOWQiPz4gPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iQWRvYmUgWE1QIENvcmUgOS4xLWMwMDIgNzkuZGJhM2RhM2I1LCAyMDIzLzEyLzE1LTEwOjQyOjM3ICAgICAgICAiPiA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPiA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIiB4bWxuczp4bXA9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8iIHhtbG5zOnhtcE1NPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvbW0vIiB4bWxuczpzdFJlZj0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL3NUeXBlL1Jlc291cmNlUmVmIyIgeG1wOkNyZWF0b3JUb29sPSJBZG9iZSBQaG90b3Nob3AgMjUuNiAoTWFjaW50b3NoKSIgeG1wTU06SW5zdGFuY2VJRD0ieG1wLmlpZDoyMDk3M0NEODAxQjQxMUVGODVGNENDMkUyMUExNDk1NSIgeG1wTU06RG9jdW1lbnRJRD0ieG1wLmRpZDoyMDk3M0NEOTAxQjQxMUVGODVGNENDMkUyMUExNDk1NSI+IDx4bXBNTTpEZXJpdmVkRnJvbSBzdFJlZjppbnN0YW5jZUlEPSJ4bXAuaWlkOkE4ODc3Qzg5MDFCMzExRUY4NUY0Q0MyRTIxQTE0OTU1IiBzdFJlZjpkb2N1bWVudElEPSJ4bXAuZGlkOkE4ODc3QzhBMDFCMzExRUY4NUY0Q0MyRTIxQTE0OTU1Ii8+IDwvcmRmOkRlc2NyaXB0aW9uPiA8L3JkZjpSREY+IDwveDp4bXBtZXRhPiA8P3hwYWNrZXQgZW5kPSJyIj8+Af/+/fz7+vn49/b19PPy8fDv7u3s6+rp6Ofm5eTj4uHg397d3Nva2djX1tXU09LR0M/OzczLysnIx8bFxMPCwcC/vr28u7q5uLe2tbSzsrGwr66trKuqqainpqWko6KhoJ+enZybmpmYl5aVlJOSkZCPjo2Mi4qJiIeGhYSDgoGAf359fHt6eXh3dnV0c3JxcG9ubWxramloZ2ZlZGNiYWBfXl1cW1pZWFdWVVRTUlFQT05NTEtKSUhHRkVEQ0JBQD8+PTw7Ojk4NzY1NDMyMTAvLi0sKyopKCcmJSQjIiEgHx4dHBsaGRgXFhUUExIREA8ODQwLCgkIBwYFBAMCAQAAIfkEAAAAAAAsAAAAAA4BZAAAAv+Mj6nL7Q+jnLTai7PevPsPhuJIluaJpurKtu4Lx/JM1/aN5/rO9/4PDAqHxKLxiEwql8ym8wmNSqfUqvWKzWq33K73Cw6Lx+Sy+YxOq9fstvsNj8vn9Lr9js/r9/y+/w8YKDhIWGh4iJiouMjY6PgIGSk5SVlpeYmZqTkJAGDQ+dnpuekmGgAKejpKuiZqmprKqoZKGyrbOlqrejub6xvLGyw8TFzcprurGuvqybxq7ETbrItsCz0l7Zpc+6p9/cS967w9/S2FTF0u/mzehK4Oqz3eTl9vf4+fr7/P3+//DzCgwIEECxo8iDChwoUMGzp8CDGixIkUK1q8iDGjxo0XHDt6/AgypMiRJEuaPIkypcqVLFt+KwAAOw==";exports.noImage=A;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const s=require("react/jsx-runtime"),e=s.jsxs("svg",{className:"closeIcon",width:"14",height:"14",fill:"none",stroke:"#666666",strokeMiterlimit:"10",children:[s.jsx("circle",{cx:"7",cy:"7",r:"6"}),s.jsx("line",{x1:"4",y1:"4",x2:"10",y2:"10"}),s.jsx("line",{x1:"4",y1:"10",x2:"10",y2:"4"})]});module.exports=e;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
"use strict";const s=require("react/jsx-runtime"),e=s.jsx("svg",{className:"dragIcon",width:"14",height:"14",fill:"#666666",stroke:"none",children:s.jsx("path",{d:`M10.43,4H3.57C3.26,4,3,4.22,3,4.5v1C3,5.78,3.26,6,3.57,6h6.86C10.74,6,11,5.78,11,5.5v-1\r
|
|
2
|
+
C11,4.22,10.74,4,10.43,4z M10.43,8H3.57C3.26,8,3,8.22,3,8.5v1C3,9.78,3.26,10,3.57,10h6.86C10.74,10,11,9.78,11,9.5v-1\r
|
|
3
|
+
C11,8.22,10.74,8,10.43,8z`})});module.exports=e;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./sidePanel/utils.cjs"),r=require("./utils.cjs"),t=require("./components/NavButton.cjs"),i=require("./components/DraggableItem.cjs"),o=require("./components/Draggable.cjs"),n=require("./components/DropdownItem.cjs"),c=require("./components/Dropdown.cjs"),a=require("./sidePanel/SidePanel.cjs"),s=require("./sidePanel/Accordion.cjs"),l=require("./sidePanel/ChildObject.cjs"),u=require("./sidePanel/ContainerObject.cjs"),d=require("./sidePanel/inspector/Inspector.cjs"),p=require("./multiView/MultiView.cjs"),I=require("./Editor.cjs"),q=require("./ThreeEditor.cjs"),m=require("./HermesApp.cjs"),b=require("./tools/Transform.cjs"),S=require("./tools/splineEditor/Spline.cjs"),T=require("./tools/splineEditor/index.cjs"),g=require("./multiView/InfiniteGridMaterial.cjs"),D=require("./multiView/InfiniteGridNodeMaterial.cjs"),M=require("./multiView/InfiniteGridHelper.cjs"),f=require("./multiView/InfiniteGridHelperGPU.cjs"),G=require("./multiView/DepthNodeMaterial.cjs"),O=require("./multiView/UVMaterial.cjs"),C=require("./multiView/UVNodeMaterial.cjs");exports.EDITOR_UTILS=e.EDITOR_UTILS;exports.convertImageToBase64=e.convertImageToBase64;exports.determineIcon=e.determineIcon;exports.getSubItem=e.getSubItem;exports.setItemProps=e.setItemProps;exports.stripObject=e.stripObject;exports.stripScene=e.stripScene;exports.textureFromSrc=e.textureFromSrc;exports.capitalize=r.capitalize;exports.colorToHex=r.colorToHex;exports.copyToClipboard=r.copyToClipboard;exports.isColor=r.isColor;exports.randomID=r.randomID;exports.NavButton=t;exports.DraggableItem=i;exports.Draggable=o;exports.DropdownItem=n;exports.Dropdown=c;exports.SidePanel=a;exports.Accordion=s;exports.ChildObject=l;exports.ContainerObject=u;exports.Inspector=d;exports.MultiView=p;exports.Editor=I;exports.ThreeEditor=q;exports.HermesApp=m;exports.Transform=b;exports.Spline=S;exports.SplineEditor=T;exports.InfiniteGridMaterial=g;exports.InfiniteGridNodeMaterial=D;exports.InfiniteGridHelper=M;exports.InfiniteGridHelperGPU=f;exports.DepthNodeMaterial=G;exports.UVMaterial=O;exports.UVNodeMaterial=C;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { EDITOR_UTILS as t, convertImageToBase64 as o, determineIcon as a, getSubItem as f, setItemProps as d, stripObject as l, stripScene as p, textureFromSrc as m } from "./sidePanel/utils.js";
|
|
2
|
+
import { capitalize as s, colorToHex as u, copyToClipboard as x, isColor as n, randomID as I } from "./utils.js";
|
|
3
|
+
import { default as b } from "./components/NavButton.js";
|
|
4
|
+
import { default as S } from "./components/DraggableItem.js";
|
|
5
|
+
import { default as g } from "./components/Draggable.js";
|
|
6
|
+
import { default as G } from "./components/DropdownItem.js";
|
|
7
|
+
import { default as E } from "./components/Dropdown.js";
|
|
8
|
+
import { default as N } from "./sidePanel/SidePanel.js";
|
|
9
|
+
import { default as U } from "./sidePanel/Accordion.js";
|
|
10
|
+
import { default as j } from "./sidePanel/ChildObject.js";
|
|
11
|
+
import { default as P } from "./sidePanel/ContainerObject.js";
|
|
12
|
+
import { default as v } from "./sidePanel/inspector/Inspector.js";
|
|
13
|
+
import { default as B } from "./multiView/MultiView.js";
|
|
14
|
+
import { default as z } from "./Editor.js";
|
|
15
|
+
import { default as L } from "./ThreeEditor.js";
|
|
16
|
+
import { default as _ } from "./HermesApp.js";
|
|
17
|
+
import { default as q } from "./tools/Transform.js";
|
|
18
|
+
import { default as K } from "./tools/splineEditor/Spline.js";
|
|
19
|
+
import { default as W } from "./tools/splineEditor/index.js";
|
|
20
|
+
import { default as Y } from "./multiView/InfiniteGridMaterial.js";
|
|
21
|
+
import { default as $ } from "./multiView/InfiniteGridNodeMaterial.js";
|
|
22
|
+
import { default as re } from "./multiView/InfiniteGridHelper.js";
|
|
23
|
+
import { default as oe } from "./multiView/InfiniteGridHelperGPU.js";
|
|
24
|
+
import { default as fe } from "./multiView/DepthNodeMaterial.js";
|
|
25
|
+
import { default as le } from "./multiView/UVMaterial.js";
|
|
26
|
+
import { default as me } from "./multiView/UVNodeMaterial.js";
|
|
27
|
+
export {
|
|
28
|
+
U as Accordion,
|
|
29
|
+
j as ChildObject,
|
|
30
|
+
P as ContainerObject,
|
|
31
|
+
fe as DepthNodeMaterial,
|
|
32
|
+
g as Draggable,
|
|
33
|
+
S as DraggableItem,
|
|
34
|
+
E as Dropdown,
|
|
35
|
+
G as DropdownItem,
|
|
36
|
+
t as EDITOR_UTILS,
|
|
37
|
+
z as Editor,
|
|
38
|
+
_ as HermesApp,
|
|
39
|
+
re as InfiniteGridHelper,
|
|
40
|
+
oe as InfiniteGridHelperGPU,
|
|
41
|
+
Y as InfiniteGridMaterial,
|
|
42
|
+
$ as InfiniteGridNodeMaterial,
|
|
43
|
+
v as Inspector,
|
|
44
|
+
B as MultiView,
|
|
45
|
+
b as NavButton,
|
|
46
|
+
N as SidePanel,
|
|
47
|
+
K as Spline,
|
|
48
|
+
W as SplineEditor,
|
|
49
|
+
L as ThreeEditor,
|
|
50
|
+
q as Transform,
|
|
51
|
+
le as UVMaterial,
|
|
52
|
+
me as UVNodeMaterial,
|
|
53
|
+
s as capitalize,
|
|
54
|
+
u as colorToHex,
|
|
55
|
+
o as convertImageToBase64,
|
|
56
|
+
x as copyToClipboard,
|
|
57
|
+
a as determineIcon,
|
|
58
|
+
f as getSubItem,
|
|
59
|
+
n as isColor,
|
|
60
|
+
I as randomID,
|
|
61
|
+
d as setItemProps,
|
|
62
|
+
l as stripObject,
|
|
63
|
+
p as stripScene,
|
|
64
|
+
m as textureFromSrc
|
|
65
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const o=require("react/jsx-runtime"),d=require("react"),f=e=>{const[n,i]=d.useState(e.options[e.index]),l=()=>{e.onToggle(!e.open)},a=t=>{t!==n&&(e.onSelect(t),i(t)),e.onToggle(!1)},c=e.open?`${e.options.length*31-1}px`:"0px";return o.jsxs("div",{className:`dropdown ${e.up===!0?"up":""}`,children:[o.jsx("div",{className:"dropdown-toggle",onClick:l,children:`${e.title}: ${n}`}),o.jsx("ul",{className:"dropdown-menu",style:{height:c},children:e.options.map(t=>o.jsx("li",{onClick:()=>a(t),children:t},t))})]})},h=d.forwardRef(function(n,i){const l=["Renderer","Depth","Normals","UVs","Wireframe"],[a,c]=d.useState("Renderer"),[t,S]=d.useState(!1),[m,x]=d.useState(!1),[r,u]=d.useState(!1);return o.jsxs("div",{className:`CameraWindow ${n.name}`,children:[o.jsx("div",{ref:i,className:"clickable",onClick:()=>{r&&u(!1)}}),o.jsxs("div",{className:"options",children:[n.camera!==null&&o.jsx(f,{title:"Camera",index:n.options.indexOf(n.camera.name),open:r,options:n.options,onSelect:n.onSelectCamera,onToggle:s=>{s&&m&&x(!1),u(s)},up:!0}),o.jsx(f,{title:"Mode",index:l.indexOf(a),open:m,options:l,onSelect:s=>{if(s===a)return;const g=s;n.onSelectRenderMode(g),c(g)},onToggle:s=>{s&&r&&u(!1),t&&S(!1),x(s)},up:!0})]})]})});exports.Dropdown=f;exports.default=h;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const r=require("three/src/materials/nodes/MeshBasicNodeMaterial.js"),s=require("three/src/nodes/TSL.js");class t extends r{constructor(){super();const e=s.remapClamp(s.linearDepth(),.1,.5,0,1).oneMinus();this.colorNode=s.vec4(e,e,e,1)}}module.exports=t;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const t=require("three"),e=require("./InfiniteGridMaterial.cjs");class a extends t.Mesh{gridMaterial;constructor(i){const r=new e(i);super(new t.PlaneGeometry,r),this.gridMaterial=r,this.frustumCulled=!1,this.name="InfiniteGridHelper"}get color(){return this.gridMaterial.color}set color(i){this.gridMaterial.color=i}get gridOpacity(){return this.gridMaterial.gridOpacity}set gridOpacity(i){this.gridMaterial.gridOpacity=i}get subgridOpacity(){return this.gridMaterial.subgridOpacity}set subgridOpacity(i){this.gridMaterial.subgridOpacity=i}}module.exports=a;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const t=require("three/webgpu"),e=require("./InfiniteGridNodeMaterial.cjs");class a extends t.Mesh{gridMaterial;constructor(i){const r=new e(i);super(new t.PlaneGeometry,r),this.gridMaterial=r,this.frustumCulled=!1,this.name="InfiniteGridHelper"}get color(){return this.gridMaterial.color}set color(i){this.gridMaterial.color=i}get gridOpacity(){return this.gridMaterial.gridOpacity}set gridOpacity(i){this.gridMaterial.gridOpacity=i}get subgridOpacity(){return this.gridMaterial.subgridOpacity}set subgridOpacity(i){this.gridMaterial.subgridOpacity=i}}module.exports=a;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";const i=require("three"),t=`out vec3 worldPosition;
|
|
2
|
+
uniform float uDistance;
|
|
3
|
+
|
|
4
|
+
void main() {
|
|
5
|
+
// Scale the plane by the drawing distance
|
|
6
|
+
worldPosition = position.xzy * uDistance;
|
|
7
|
+
worldPosition.xz += cameraPosition.xz;
|
|
8
|
+
|
|
9
|
+
gl_Position = projectionMatrix * modelViewMatrix * vec4(worldPosition, 1.0);
|
|
10
|
+
}`,a=`out vec4 fragColor;
|
|
11
|
+
in vec3 worldPosition;
|
|
12
|
+
uniform float uDivisions;
|
|
13
|
+
uniform float uScale;
|
|
14
|
+
uniform vec3 uColor;
|
|
15
|
+
uniform float uDistance;
|
|
16
|
+
uniform float uGridOpacity;
|
|
17
|
+
uniform float uSubgridOpacity;
|
|
18
|
+
|
|
19
|
+
#define minAlpha 0.00784313725490196
|
|
20
|
+
|
|
21
|
+
float getGrid(float gapSize) {
|
|
22
|
+
vec2 worldPositionByDivision = worldPosition.xz / gapSize;
|
|
23
|
+
|
|
24
|
+
// Inverted, 0 where line, >1 where there's no line
|
|
25
|
+
// We use the worldPosition (which in this case we use similarly to UVs) differential to control the anti-aliasing
|
|
26
|
+
// We need to do the -0.5)-0.5 trick because the result fades out from 0 to 1, and we want both
|
|
27
|
+
// worldPositionByDivision == 0.3 and worldPositionByDivision == 0.7 to result in the same fade, i.e. 0.3,
|
|
28
|
+
// otherwise only one side of the line will be anti-aliased
|
|
29
|
+
vec2 grid = abs(fract(worldPositionByDivision-0.5)-0.5) / fwidth(worldPositionByDivision) / 2.0;
|
|
30
|
+
float gridLine = min(grid.x, grid.y);
|
|
31
|
+
|
|
32
|
+
// Uninvert and clamp
|
|
33
|
+
return 1.0 - min(gridLine, 1.0);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
void main() {
|
|
37
|
+
float cameraDistanceToGridPlane = max(200.0, distance(cameraPosition.y, worldPosition.y));
|
|
38
|
+
float cameraDistanceToFragmentOnGridPlane = distance(cameraPosition.xyz, worldPosition.xyz);
|
|
39
|
+
|
|
40
|
+
// The size of the grid and subgrid are powers of each other and they are determined based on camera distance.
|
|
41
|
+
// The current grid will become the next subgrid when it becomes too small, and its next power becomes the new grid.
|
|
42
|
+
float subGridPower = pow(uDivisions, floor(log(cameraDistanceToGridPlane) / log(uDivisions)));
|
|
43
|
+
float gridPower = subGridPower * uDivisions;
|
|
44
|
+
|
|
45
|
+
// If we want to fade both the grid and its subgrid, we need to displays 3 different opacities, with the next grid being the third
|
|
46
|
+
float nextGridPower = gridPower * uDivisions;
|
|
47
|
+
|
|
48
|
+
// 1 where grid, 0 where no grid
|
|
49
|
+
float subgrid = getGrid(subGridPower * uScale);
|
|
50
|
+
float grid = getGrid(gridPower * uScale);
|
|
51
|
+
float nextGrid = getGrid(nextGridPower * uScale);
|
|
52
|
+
|
|
53
|
+
// Where we are between the introduction of the current grid power and when we switch to the next grid power
|
|
54
|
+
float stepPercentage = (cameraDistanceToGridPlane - subGridPower)/(gridPower - subGridPower);
|
|
55
|
+
|
|
56
|
+
// The last x percentage of the current step over which we want to fade
|
|
57
|
+
float fadeRange = 0.3;
|
|
58
|
+
|
|
59
|
+
// We calculate the fade percentage from the step percentage and the fade range
|
|
60
|
+
float fadePercentage = max(stepPercentage - 1.0 + fadeRange, 0.0) / fadeRange;
|
|
61
|
+
|
|
62
|
+
// Set base opacity based on how close we are to the drawing distance, with a cubic falloff
|
|
63
|
+
float baseOpacity = subgrid * pow(1.0 - min(cameraDistanceToFragmentOnGridPlane / uDistance, 1.0), 3.0);
|
|
64
|
+
|
|
65
|
+
// Shade the subgrid
|
|
66
|
+
fragColor = vec4(uColor.rgb, (baseOpacity - fadePercentage) * uSubgridOpacity);
|
|
67
|
+
|
|
68
|
+
// Somewhat arbitrary additional fade coefficient to counter anti-aliasing popping when switching between grid powers
|
|
69
|
+
float fadeCoefficient = 0.5;
|
|
70
|
+
|
|
71
|
+
// Shade the grid
|
|
72
|
+
fragColor.a = mix(fragColor.a, baseOpacity * uGridOpacity - fadePercentage * (uGridOpacity - uSubgridOpacity) * fadeCoefficient, grid);
|
|
73
|
+
|
|
74
|
+
// Shade the next grid
|
|
75
|
+
fragColor.a = mix(fragColor.a, baseOpacity * uGridOpacity, nextGrid);
|
|
76
|
+
|
|
77
|
+
if (fragColor.a <= minAlpha) discard;
|
|
78
|
+
}`;class o extends i.ShaderMaterial{constructor(e){super({extensions:{derivatives:!0},uniforms:{uScale:{value:e?.scale!==void 0?e?.scale:.1},uDivisions:{value:e?.divisions!==void 0?e?.divisions:10},uColor:{value:e?.color!==void 0?e?.color:new i.Color(16777215)},uDistance:{value:e?.distance!==void 0?e?.distance:1e4},uSubgridOpacity:{value:e?.subgridOpacity!==void 0?e?.subgridOpacity:.15},uGridOpacity:{value:e?.gridOpacity!==void 0?e?.gridOpacity:.25}},glslVersion:i.GLSL3,side:i.DoubleSide,transparent:!0,name:"InfiniteGrid",vertexShader:t,fragmentShader:a})}get color(){return this.uniforms.uColor.value}set color(e){this.uniforms.uColor.value=e}get gridOpacity(){return this.uniforms.uGridOpacity.value}set gridOpacity(e){this.uniforms.uGridOpacity.value=e}get subgridOpacity(){return this.uniforms.uSubgridOpacity.value}set subgridOpacity(e){this.uniforms.uSubgridOpacity.value=e}}module.exports=o;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const g=require("three/webgpu"),i=require("three/tsl");class N extends g.NodeMaterial{uScale;uDivisions;uColor;uDistance;uSubgridOpacity;uGridOpacity;constructor(t){super(),this.name="InfiniteGrid",this.side=g.DoubleSide,this.transparent=!0,this.uScale=i.uniform(t?.scale??.1),this.uDivisions=i.uniform(t?.divisions??10),this.uColor=i.uniform(t?.color??new g.Color(16777215)),this.uDistance=i.uniform(t?.distance??1e4),this.uSubgridOpacity=i.uniform(t?.subgridOpacity??.15),this.uGridOpacity=i.uniform(t?.gridOpacity??.25);const{uScale:e,uDivisions:u,uColor:O,uDistance:b,uSubgridOpacity:p,uGridOpacity:r}=this,c=i.varyingProperty("vec3","vWorldPosition");this.positionNode=i.Fn(()=>{const o=i.positionLocal.xzy.mul(b).add(i.vec3(i.cameraPosition.x,i.float(0),i.cameraPosition.z));return c.assign(o),o})();const l=i.Fn(([o])=>{const a=c.xz.div(o),d=i.fwidth(a),n=i.abs(i.fract(a.sub(.5)).sub(.5)).div(d).div(2),s=i.min(n.x,n.y);return i.float(1).sub(i.min(s,i.float(1)))});this.outputNode=i.Fn(()=>{const o=c,a=i.max(i.float(200),i.abs(i.cameraPosition.y.sub(o.y))),d=i.float(i.distance(i.cameraPosition,o)),n=i.log(a).div(i.log(u)),s=i.pow(u,i.floor(n)),f=s.mul(u),P=f.mul(u),w=l(s.mul(e)),x=l(f.mul(e)),G=l(P.mul(e)),D=a.sub(s).div(f.sub(s)),v=i.float(.3),h=i.max(D.sub(i.float(1)).add(v),i.float(0)).div(v),m=w.mul(i.pow(i.float(1).sub(i.min(d.div(b),i.float(1))),i.float(3))),S=i.float(.5),C=m.sub(h).mul(p),F=i.mix(C,m.mul(r).sub(h.mul(r.sub(p)).mul(S)),x),y=i.float(i.mix(F,m.mul(r),G));return i.If(i.lessThanEqual(y,i.float(1/127)),()=>{i.Discard()}),i.vec4(O,y)})()}get color(){return this.uColor.value}set color(t){this.uColor.value=t}get gridOpacity(){return this.uGridOpacity.value}set gridOpacity(t){this.uGridOpacity.value=t}get subgridOpacity(){return this.uSubgridOpacity.value}set subgridOpacity(t){this.uSubgridOpacity.value=t}}module.exports=N;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const o=require("react/jsx-runtime"),C=require("react"),a=require("three/webgpu"),S=require("three"),y=require("three/examples/jsm/helpers/RectAreaLightHelper.js"),R=require("three/examples/jsm/controls/OrbitControls.js"),p=require("three/src/math/MathUtils.js"),g=require("camera-controls"),c=require("../../core/remote/RemoteThree.cjs"),d=require("./CameraWindow.cjs"),E=require("./InfiniteGridHelper.cjs"),M=require("./InfiniteGridHelperGPU.cjs");;/* empty css */const b=require("../sidePanel/DebugData.cjs"),T=require("../sidePanel/inspector/utils/InspectTransform.cjs"),w=require("./Toggle.cjs"),V=require("./DepthNodeMaterial.cjs"),H=require("./UVNodeMaterial.cjs"),x=require("../tools/splineEditor/index.cjs"),u=require("../tools/Transform.cjs"),W=require("../../utils/math.cjs"),v=require("../../utils/three.cjs"),I=["Single","Side by Side","Stacked","Quad"],L="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",O="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==",k="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABUAAAAVCAYAAACpF6WWAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAQ0lEQVQ4jWP8////fwYqAxYozUhFM/8zkaKYWIWkGEq0b0ZdSjQY5i79TyWagRGaTUdzFEEw6lLqGzqwLoVVJ1StpwA9sBwbUqAh5gAAAABJRU5ErkJggg==";class A extends C.Component{static instance=null;scene;renderer;currentScene;scenes=new Map;cameras=new Map;controls=new Map;currentCamera;currentWindow;helpersContainer=new a.Group;grid;cameraHelpers=new Map;lightHelpers=new Map;interactionHelper=new a.AxesHelper(25);currentTransform;splineEditor;depthMaterial;normalsMaterial;uvMaterial;wireframeMaterial=new a.MeshBasicMaterial({opacity:.33,transparent:!0,wireframe:!0});playing=!1;rafID=-1;cameraControlsRafID=-1;width=0;height=0;tlCam=null;trCam=null;blCam=null;brCam=null;tlRender="Renderer";trRender="Renderer";blRender="Renderer";brRender="Renderer";cameraVisibility=!0;lightVisibility=!0;gridVisibility=!0;rendererReady=!1;selectedItem=void 0;cameraControlsStartTime=0;cameraControlsLastTime=0;debugCamera;raycaster=new a.Raycaster;pointer=new a.Vector2;cameraControls=void 0;canvasRef;containerRef;tlWindow;trWindow;blWindow;brWindow;editorCameras=["Top","Bottom","Left","Right","Front","Back","Orthographic","UI","Debug"];constructor(i){super(i),this.props.three.addEventListener(c.ToolEvents.ADD_RENDERER,this.setupRenderer),this.scene=new a.Scene,this.scene.name=this.scene.uuid="",this.canvasRef=C.createRef(),this.containerRef=C.createRef(),this.tlWindow=C.createRef(),this.trWindow=C.createRef(),this.blWindow=C.createRef(),this.brWindow=C.createRef();const e=i.three.name,t=localStorage,s=t.getItem(`${e}_mode`);this.state={mode:s!==null?s:"Single",modeOpen:!1,renderModeOpen:!1,interactionMode:"Orbit",interactionModeOpen:!1,lastUpdate:Date.now()},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");const n={Vector2:a.Vector2,Vector3:a.Vector3,Vector4:a.Vector4,Quaternion:a.Quaternion,Matrix4:a.Matrix4,Spherical:a.Spherical,Box3:a.Box3,Sphere:a.Sphere,Raycaster:a.Raycaster};g.install({THREE:n});const r=localStorage.getItem(this.expandedCameraVisibility);r!==null&&(this.cameraVisibility=r==="open"),this.saveExpandedCameraVisibility();const h=localStorage.getItem(this.expandedLightVisibility);h!==null&&(this.lightVisibility=h==="open"),this.saveExpandedLightVisibility();const m=localStorage.getItem(this.expandedGridVisibility);m!==null&&(this.gridVisibility=m==="open"),this.grid&&(this.grid.visible=this.gridVisibility),this.saveExpandedGridVisibility(),A.instance=this}componentDidMount(){this.setupScene(),this.setupTools(),this.enable(),this.assignControls(),this.resize(),this.play(),u.instance.setApp(this.props.three),u.instance.activeCamera=this.debugCamera,this.props.three.requestRenderer()}componentDidUpdate(i,e,t){e.mode!==this.state.mode&&(this.assignControls(),this.resize())}componentWillUnmount(){this.disable(),this.clear(),b.removeEditorGroup("View Settings")}render(){const i=[];return this.cameras.forEach((e,t)=>{i.push(t)}),o.jsxs("div",{className:"multiview",children:[o.jsx("canvas",{ref:this.canvasRef}),o.jsxs("div",{className:`cameras ${this.state.mode==="Single"||this.state.mode==="Stacked"?"single":""}`,ref:this.containerRef,children:[this.state.mode==="Single"&&o.jsx(o.Fragment,{children:o.jsx(d.default,{name:"tl",camera:this.tlCam,options:i,ref:this.tlWindow,onSelectCamera:e=>{this.controls.get(this.tlCam.name)?.dispose();const t=this.cameras.get(e);t!==void 0&&(this.clearCamera(this.tlCam),this.tlCam=t,localStorage.setItem(`${this.appID}_tlCam`,t.name),this.createControls(t,this.tlWindow.current))},onSelectRenderMode:e=>{this.tlRender=e,localStorage.setItem(`${this.appID}_tlRender`,e)}})}),(this.state.mode==="Side by Side"||this.state.mode==="Stacked")&&o.jsxs(o.Fragment,{children:[o.jsx(d.default,{name:"tl",camera:this.tlCam,options:i,ref:this.tlWindow,onSelectCamera:e=>{this.controls.get(this.tlCam.name)?.dispose();const t=this.cameras.get(e);t!==void 0&&(this.clearCamera(this.tlCam),this.tlCam=t,localStorage.setItem(`${this.appID}_tlCam`,t.name),this.createControls(t,this.tlWindow.current))},onSelectRenderMode:e=>{this.tlRender=e,localStorage.setItem(`${this.appID}_tlRender`,e)}}),o.jsx(d.default,{name:"tr",camera:this.trCam,options:i,ref:this.trWindow,onSelectCamera:e=>{this.controls.get(this.trCam.name)?.dispose();const t=this.cameras.get(e);t!==void 0&&(this.clearCamera(this.trCam),this.trCam=t,localStorage.setItem(`${this.appID}_trCam`,t.name),this.createControls(t,this.trWindow.current))},onSelectRenderMode:e=>{this.trRender=e,localStorage.setItem(`${this.appID}_trRender`,e)}})]}),this.state.mode==="Quad"&&o.jsxs(o.Fragment,{children:[o.jsx(d.default,{name:"tl",camera:this.tlCam,options:i,ref:this.tlWindow,onSelectCamera:e=>{this.controls.get(this.tlCam.name)?.dispose();const t=this.cameras.get(e);t!==void 0&&(this.clearCamera(this.tlCam),this.tlCam=t,localStorage.setItem(`${this.appID}_tlCam`,t.name),this.createControls(t,this.tlWindow.current))},onSelectRenderMode:e=>{this.tlRender=e,localStorage.setItem(`${this.appID}_tlRender`,e)}}),o.jsx(d.default,{name:"tr",camera:this.trCam,options:i,ref:this.trWindow,onSelectCamera:e=>{this.controls.get(this.trCam.name)?.dispose();const t=this.cameras.get(e);t!==void 0&&(this.clearCamera(this.trCam),this.trCam=t,localStorage.setItem(`${this.appID}_trCam`,t.name),this.createControls(t,this.trWindow.current))},onSelectRenderMode:e=>{this.trRender=e,localStorage.setItem(`${this.appID}_trRender`,e)}}),o.jsx(d.default,{name:"bl",camera:this.blCam,options:i,ref:this.blWindow,onSelectCamera:e=>{this.controls.get(this.blCam.name)?.dispose();const t=this.cameras.get(e);t!==void 0&&(this.clearCamera(this.blCam),this.blCam=t,localStorage.setItem(`${this.appID}_blCam`,t.name),this.createControls(t,this.blWindow.current))},onSelectRenderMode:e=>{this.blRender=e,localStorage.setItem(`${this.appID}_blRender`,e)}}),o.jsx(d.default,{name:"br",camera:this.brCam,options:i,ref:this.brWindow,onSelectCamera:e=>{this.controls.get(this.brCam.name)?.dispose();const t=this.cameras.get(e);t!==void 0&&(this.clearCamera(this.brCam),this.brCam=t,localStorage.setItem(`${this.appID}_brCam`,t.name),this.createControls(t,this.brWindow.current))},onSelectRenderMode:e=>{this.brRender=e,localStorage.setItem(`${this.appID}_brRender`,e)}})]})]}),o.jsxs("div",{className:"settings",children:[o.jsx(d.Dropdown,{title:"View",index:I.indexOf(this.state.mode),options:I,onSelect:e=>{e!==this.state.mode&&(this.killControls(),this.setState({mode:e}),localStorage.setItem(`${this.appID}_mode`,e))},open:this.state.modeOpen,onToggle:e=>{this.setState({modeOpen:e,renderModeOpen:!1,interactionModeOpen:!1})}}),o.jsx(d.Dropdown,{title:"Interact",index:this.state.interactionMode==="Orbit"?0:1,options:["Orbit Mode","Selection Mode"],onSelect:e=>{this.interactionHelper.visible=e==="Selection Mode",this.setState({interactionMode:this.interactionHelper.visible?"Selection":"Orbit"})},open:this.state.interactionModeOpen,onToggle:e=>{this.setState({modeOpen:!1,renderModeOpen:!1,interactionModeOpen:e})}}),o.jsx(w,{name:"cameraHelper",icon:L,selected:this.cameraVisibility,height:24,top:2,onClick:e=>{if(this.cameraVisibility=e,this.saveExpandedCameraVisibility(),this.cameraHelpers.forEach(t=>{t.visible=e}),this.selectedItem!==void 0&&!e){const t=this.cameraHelpers.get(this.selectedItem.name);t!==void 0&&(t.visible=!0)}}}),o.jsx(w,{name:"lightHelper",icon:O,selected:this.lightVisibility,height:24,top:4,onClick:e=>{if(this.lightVisibility=e,this.saveExpandedLightVisibility(),this.lightHelpers.forEach(t=>{t.visible=e}),this.selectedItem!==void 0&&!e&&this.selectedItem.isLight===!0){const t=this.lightHelpers.get(this.selectedItem.name);t!==void 0&&(t.visible=!0)}}}),o.jsx(w,{name:"gridHelper",icon:k,selected:this.gridVisibility,height:21,width:21,onClick:e=>{this.setGridVisibility(e)}})]},this.state.lastUpdate)]})}setupRenderer=i=>{const e=i.value;if(this.renderer){if(this.renderer instanceof S.WebGLRenderer&&e.type==="WebGLRenderer"||this.renderer instanceof a.WebGPURenderer&&e.type==="WebGPURenderer")return;this.renderer.dispose()}this.rendererReady=!1;const t=this.canvasRef.current;if(t===null){setTimeout(()=>this.props.three.requestRenderer(),100);return}this.props.three.canvas=t,e.type==="WebGLRenderer"?(this.renderer=new S.WebGLRenderer({canvas:t,stencil:!1}),this.grid&&(this.scene.remove(this.grid),v.dispose(this.grid)),this.grid=new E,this.scene.add(this.grid),this.rendererReady=!0):e.type==="WebGPURenderer"&&(this.renderer=new a.WebGPURenderer({canvas:t,stencil:!1}),this.grid&&(this.scene.remove(this.grid),v.dispose(this.grid)),this.grid=new M,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 V,this.normalsMaterial=new a.MeshNormalNodeMaterial,this.uvMaterial=new H,e.type==="WebGPURenderer"?this.renderer.init().then(()=>{this.rendererReady=!0,this.props.three.requestScene()}):this.props.three.requestScene())};setupScene(){this.helpersContainer.name="helpers",this.scene.add(this.helpersContainer),this.interactionHelper.name="interactionHelper",this.interactionHelper.visible=!1,this.helpersContainer.add(this.interactionHelper);const i=(n,r)=>{const h=new a.OrthographicCamera(-100,100,100,-100,0,3e3);return h.name=n,h.position.copy(r),h.lookAt(0,0,0),this.cameras.set(n,h),h},e=1e3;i("Top",new a.Vector3(0,e,0)),i("Bottom",new a.Vector3(0,-e,0)),i("Left",new a.Vector3(-e,0,0)),i("Right",new a.Vector3(e,0,0)),i("Front",new a.Vector3(0,0,e)),i("Back",new a.Vector3(0,0,-e)),i("Orthographic",new a.Vector3(e,e,e)),i("UI",new a.Vector3),this.debugCamera=new a.PerspectiveCamera(60,1,.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;const t=localStorage,s=this.props.three.name;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")),b.addEditorGroup({title:"Editor",items:[{type:"button",prop:"Hide All Transforms"},{type:"button",prop:"Resize"}],onUpdate:(n,r)=>{switch(n){case"Hide All Transforms":u.instance.hide();break;case"Resize":this.resize();break}},subgroups:[{title:"Debug Camera",items:[{type:"range",prop:"Near",step:1e-4,min:.001,max:1e3,value:this.debugCamera.near},{type:"range",prop:"Far",step:.001,min:.001,max:1e4,value:this.debugCamera.far}],onUpdate:(n,r)=>{switch(n){case"Near":this.debugCamera.near=r,this.debugCamera.updateProjectionMatrix();break;case"Far":this.debugCamera.far=r,this.debugCamera.updateProjectionMatrix();break}}},{title:"Grid",items:[{type:"number",prop:"Position",value:0},{type:"color",prop:"Color",value:"#FFFFFF"},{type:"range",prop:"Grid Opacity",value:.25,min:0,max:1,step:.01},{type:"range",prop:"Subgrid Opacity",value:.15,min:0,max:1,step:.01}],onUpdate:(n,r)=>{switch(n){case"Position":this.grid&&(this.grid.position.y=r);break;case"Color":this.grid&&this.grid.color.setStyle(r);break;case"Grid Opacity":this.grid&&(this.grid.gridOpacity=r);break;case"Subgrid Opacity":this.grid&&(this.grid.subgridOpacity=r);break}}}]})}setupTools(){this.splineEditor=new x(this.currentCamera,this.three),this.splineEditor.initDebug(),this.helpersContainer.add(this.splineEditor)}play(){this.playing=!0,this.onUpdate()}pause(){this.playing=!1,cancelAnimationFrame(this.rafID),this.rafID=-1}toggleOrbitControls(i){this.controls.forEach(e=>{e.enabled=!i})}clear(){this.three.dispatchEvent({type:c.ToolEvents.CLEAR_OBJECT}),b.removeAllGroups(),this.clearLightHelpers(),this.clearControls(),this.currentTransform!==void 0&&(this.currentTransform.removeEventListener("objectChange",this.onUpdateTransform),u.instance.remove(this.currentTransform.getHelper().name)),this.currentTransform=void 0,u.instance.clear(),this.cameras.forEach(i=>{this.editorCameras.indexOf(i.name)<0&&this.three.dispatchEvent({type:c.ToolEvents.REMOVE_CAMERA,value:i})}),this.currentCamera=this.debugCamera,this.currentScene=void 0,this.scenes.forEach(i=>{this.three.dispatchEvent({type:c.ToolEvents.REMOVE_SCENE,value:i})}),this.scenes.clear()}setGridVisibility(i){this.gridVisibility=i,this.saveExpandedGridVisibility(),this.grid&&(this.grid.visible=i)}update(){this.controls.forEach(i=>i.update()),this.cameraHelpers.forEach(i=>i.update()),this.lightHelpers.forEach(i=>{i.update!==void 0&&i.update()}),this.props.onSceneUpdate!==void 0&&this.currentScene!==void 0&&this.props.onSceneUpdate(this.currentScene)}draw(){if(this.rendererReady)switch(this.renderer&&this.renderer?.clear(),this.state.mode){case"Single":this.drawSingle();break;case"Side by Side":case"Stacked":this.drawDouble();break;case"Quad":this.drawQuad();break}}onUpdate=()=>{this.playing&&(this.update(),this.draw(),this.rafID=requestAnimationFrame(this.onUpdate))};enable(){const i=this.containerRef.current;i.addEventListener("mousemove",this.onMouseMove),i.addEventListener("click",this.onClick),window.addEventListener("keydown",this.onKey),window.addEventListener("resize",this.resize),this.three.addEventListener(c.ToolEvents.ADD_SCENE,this.addScene),this.three.addEventListener(c.ToolEvents.SET_SCENE,this.sceneUpdate),this.three.addEventListener(c.ToolEvents.REMOVE_SCENE,this.removeScene),this.three.addEventListener(c.ToolEvents.ADD_CAMERA,this.addCamera),this.three.addEventListener(c.ToolEvents.REMOVE_CAMERA,this.removeCamera),this.three.addEventListener(c.ToolEvents.SET_OBJECT,this.onSetSelectedItem)}disable(){const i=this.containerRef.current;i.removeEventListener("mousemove",this.onMouseMove),i.removeEventListener("click",this.onClick),window.removeEventListener("keydown",this.onKey),window.removeEventListener("resize",this.resize),this.three.removeEventListener(c.ToolEvents.ADD_SCENE,this.addScene),this.three.removeEventListener(c.ToolEvents.SET_SCENE,this.sceneUpdate),this.three.removeEventListener(c.ToolEvents.REMOVE_SCENE,this.removeScene),this.three.removeEventListener(c.ToolEvents.ADD_CAMERA,this.addCamera),this.three.removeEventListener(c.ToolEvents.REMOVE_CAMERA,this.removeCamera),this.three.removeEventListener(c.ToolEvents.SET_OBJECT,this.onSetSelectedItem)}resize=()=>{this.width=window.innerWidth-300,this.height=window.innerHeight,this.renderer?.setSize(this.width,this.height);const i=Math.floor(this.width/2),e=Math.floor(this.height/2);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);let t=this.width,s=this.height;switch(this.state.mode){case"Side by Side":t=i,s=this.height;break;case"Stacked":t=this.width,s=e;break;case"Quad":t=i,s=e;break}const n=t/s;this.cameras.forEach(r=>{r instanceof a.OrthographicCamera?(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 a.PerspectiveCamera&&(r.aspect=n,r.updateProjectionMatrix()),this.cameraHelpers.get(r.name)?.update()})};addScene=i=>{const e=this.props.scenes.get(i.value.name);if(e!==void 0){const t=this.scenes.get(i.value.name);if(t!==void 0){this.props.onSceneAdd!==void 0&&this.props.onSceneAdd(t),this.props.three.scene=t;return}const s=new e;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)}else console.log("Hermes - Scene not found:",i.value.name,this.props.scenes)};sceneUpdate=i=>{this.currentScene!==void 0&&(this.currentScene.visible=!1,this.clearLightHelpers());const e=this.scene.getObjectByName(i.value.name);e!==void 0&&(this.currentScene=e,this.currentScene.visible=!0,this.addLightHelpers(this.currentScene)),this.cameraHelpers.forEach((t,s)=>{const n=this.currentScene!==void 0&&this.currentScene.getObjectByProperty("uuid",s)!==void 0;t.visible=this.cameraVisibility&&n})};removeScene=i=>{const e=i.value.name;this.scenes.delete(e);const t=this.scene.getObjectByName(e);t&&setTimeout(()=>{v.dispose(t)},100),this.clearLightHelpers()};addCamera=i=>{const e=i.value,t=e.uuid,s=this.props.three.scene?.getObjectByProperty("uuid",e.uuid);if(s!==void 0){const n=s;this.cameras.set(t,n);const r=new a.CameraHelper(n),h=this.currentScene!==void 0&&this.currentScene.getObjectByProperty("uuid",t)!==void 0;r.visible=this.cameraVisibility&&h,this.cameraHelpers.set(t,r),this.helpersContainer.add(r),this.setState({lastUpdate:Date.now()})}};removeCamera=i=>{const t=i.value.uuid,s=this.cameraHelpers.get(t);s!==void 0&&(this.helpersContainer.remove(s),s.dispose()),this.cameras.delete(t),this.setState({lastUpdate:Date.now()})};onMouseMove=i=>{const e=new a.Vector2;this.renderer?.getSize(e);const t=Math.min(i.clientX,e.x),s=Math.min(i.clientY,e.y);this.pointer.x=p.mapLinear(t,0,e.x,-1,1),this.pointer.y=p.mapLinear(s,0,e.y,1,-1);const n=e.x/2,r=e.y/2,h=()=>{t<n?this.pointer.x=p.mapLinear(t,0,n,-1,1):this.pointer.x=p.mapLinear(t,n,e.x,-1,1)},m=()=>{s<r?this.pointer.y=p.mapLinear(s,0,r,1,-1):this.pointer.y=p.mapLinear(s,r,e.y,1,-1)};switch(this.state.mode){case"Quad":h(),m();break;case"Side by Side":h();break;case"Stacked":m(),m();break}if(this.updateCamera(t,s,n,r),this.state.interactionMode==="Orbit"||this.currentScene===void 0)return;const l=this.raycaster.intersectObjects(this.currentScene.children);l.length>0&&this.interactionHelper.position.copy(l[0].point)};onClick=i=>{if(this.state.interactionMode==="Orbit"||this.currentScene===void 0)return;const e=new a.Vector2;if(this.renderer.getSize(e),i.clientX>=e.x)return;this.onMouseMove(i);const t=this.raycaster.intersectObjects(this.currentScene.children);t.length>0&&(this.props.three.getObject(t[0].object.uuid),this.interactionHelper.visible=!1,this.setState({interactionMode:"Orbit",lastUpdate:Date.now()}))};onKey=i=>{if(this.selectedItem!==void 0){if(i.ctrlKey){if(this.currentCamera.name==="UI")return;const e=this.controls.get(this.currentCamera.name);i.key==="0"?(i.preventDefault(),this.clearControls(),this.cameraControls=new g(this.currentCamera,this.currentWindow.current),this.selectedItem instanceof a.Mesh||this.selectedItem instanceof a.SkinnedMesh?(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 g(this.currentCamera,this.currentWindow.current),this.cameraControls.rotateTo(0,Math.PI*.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 g(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 g(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 g(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 g(this.currentCamera,this.currentWindow.current),this.cameraControls.rotateTo(p.degToRad(45),p.degToRad(45),!0),this.updateCameraControls(e))}else if(this.currentTransform!==void 0)switch(i.key){case"r":this.currentTransform.setMode("rotate");break;case"s":this.currentTransform.setMode("scale");break;case"t":this.currentTransform.setMode("translate");break;case"q":this.currentTransform.setSpace(this.currentTransform.space==="local"?"world":"local");break}}};onSetSelectedItem=i=>{this.selectedItem!==void 0&&this.updateSelectedItemHelper(!1),this.selectedItem=void 0;const e=i.value.uuid;if(this.scenes.forEach(t=>{e.search(t.uuid)>-1&&(this.selectedItem=t.getObjectByProperty("uuid",e))}),this.selectedItem===void 0){console.log(`Hermes - Can't find selected item: ${i.value.uuid}, ${i.value.name}`);return}this.currentTransform!==void 0&&(this.currentTransform.removeEventListener("objectChange",this.onUpdateTransform),u.instance.remove(this.currentTransform.getHelper().name)),this.currentTransform=u.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)};updateSelectedItemHelper(i){if(this.selectedItem!==void 0)if(this.cameraVisibility){if(this.selectedItem.isLight===!0&&!this.lightVisibility){const e=this.lightHelpers.get(this.selectedItem.name);e!==void 0&&(e.visible=i)}}else{const e=this.cameraHelpers.get(this.selectedItem.name);e!==void 0&&(e.visible=i)}}onUpdateTransform=()=>{this.selectedItem!==void 0&&(this.props.three.updateObject(this.selectedItem.uuid,"position",this.selectedItem.position),this.props.three.updateObject(this.selectedItem.uuid,"rotation",{x:this.selectedItem.rotation.x,y:this.selectedItem.rotation.y,z:this.selectedItem.rotation.z}),this.props.three.updateObject(this.selectedItem.uuid,"scale",this.selectedItem.scale),T.InspectTransform.instance.update())};clearLightHelpers=()=>{this.lightHelpers.forEach(i=>{this.helpersContainer.remove(i),i.dispose()}),this.lightHelpers.clear()};addLightHelpers=i=>{i.traverse(e=>{if(e.type.search("Light")>-1){let t;switch(e.type){case"DirectionalLight":t=new a.DirectionalLightHelper(e,100),t.name=`${e.name}Helper`,t.visible=this.lightVisibility,this.lightHelpers.set(e.name,t),this.helpersContainer.add(t);break;case"HemisphereLight":t=new a.HemisphereLightHelper(e,250),t.name=`${e.name}Helper`,t.visible=this.lightVisibility,this.lightHelpers.set(e.name,t),this.helpersContainer.add(t);break;case"RectAreaLight":t=new y.RectAreaLightHelper(e),t.name=`${e.name}Helper`,t.visible=this.lightVisibility,this.lightHelpers.set(e.name,t),this.helpersContainer.add(t);break;case"PointLight":t=new a.PointLightHelper(e,100),t.name=`${e.name}Helper`,t.visible=this.lightVisibility,this.lightHelpers.set(e.name,t),this.helpersContainer.add(t);break;case"SpotLight":t=new a.SpotLightHelper(e),t.name=`${e.name}Helper`,t.visible=this.lightVisibility,this.lightHelpers.set(e.name,t),this.helpersContainer.add(t);break}}})};createControls(i,e){const t=this.controls.get(i.name);if(t!==void 0&&t.dispose(),this.controls.delete(i.name),i.name==="UI")return;const s=new R.OrbitControls(i,e);switch(s.enableDamping=!0,s.dampingFactor=.1,i.name){case"Top":case"Bottom":case"Left":case"Right":case"Front":case"Back":s.enableRotate=!1;break}this.controls.set(i.name,s)}clearCamera(i){const e=this.cameraHelpers.get(i.name);e!==void 0&&(this.helpersContainer.remove(e),e.dispose(),this.cameraHelpers.delete(i.name));const t=this.controls.get(i.name);t!==void 0&&(t.dispose(),this.controls.delete(i.name))}killControls(){this.controls.forEach((i,e)=>{i.dispose();const t=this.cameraHelpers.get(e);t!==void 0&&(this.helpersContainer.remove(t),t.dispose()),this.cameraHelpers.delete(e),this.controls.delete(e)}),this.controls.clear(),this.cameraHelpers.clear()}assignControls(){switch(this.state.mode){case"Single":this.createControls(this.tlCam,this.tlWindow.current);break;case"Side by Side":case"Stacked":this.createControls(this.tlCam,this.tlWindow.current),this.createControls(this.trCam,this.trWindow.current);break;case"Quad":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);break}}updateCamera=(i,e,t,s)=>{switch(this.state.mode){case"Quad":e<s?i<t?this.currentCamera=this.tlCam:this.currentCamera=this.trCam:i<t?this.currentCamera=this.blCam:this.currentCamera=this.brCam;break;case"Side by Side":i<t?this.currentCamera=this.tlCam:this.currentCamera=this.trCam;break;case"Single":this.currentCamera=this.tlCam;break;case"Stacked":e<s?this.currentCamera=this.tlCam:this.currentCamera=this.trCam;break}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),u.instance.updateCamera(this.currentCamera,this.currentWindow.current)};updateCameraControls=(i,e=!1)=>{if(this.selectedItem===void 0)return;cancelAnimationFrame(this.cameraControlsRafID),this.cameraControlsRafID=-1,this.cameraControls&&(this.cameraControls.smoothTime=.1);const t=.15;this.cameraControlsStartTime=performance.now(),this.cameraControlsLastTime=this.cameraControlsStartTime,this.selectedItem.getWorldPosition(i.target0);const s=()=>{const n=performance.now(),r=(n-this.cameraControlsLastTime)/1e3;this.cameraControlsLastTime=n,this.cameraControls&&this.cameraControls.update(r),e&&(i.target.lerp(i.target0,t),i.object.position.lerp(i.position0,t),i.object.zoom=W.mix(i.object.zoom,i.zoom0,t),i.object.updateProjectionMatrix(),i.dispatchEvent({type:"change"})),(n-this.cameraControlsStartTime)/1e3>=.5?(cancelAnimationFrame(this.cameraControlsRafID),this.cameraControlsRafID=-1,this.clearControls()):this.cameraControlsRafID=requestAnimationFrame(s)};s()};clearControls=()=>{this.cameraControls!==void 0&&(this.cameraControls.disconnect(),this.cameraControls.dispose(),this.cameraControls=void 0)};saveExpandedCameraVisibility(){localStorage.setItem(this.expandedCameraVisibility,this.cameraVisibility?"open":"closed")}saveExpandedLightVisibility(){localStorage.setItem(this.expandedLightVisibility,this.lightVisibility?"open":"closed")}saveExpandedGridVisibility(){localStorage.setItem(this.expandedGridVisibility,this.gridVisibility?"open":"closed")}getSceneOverride(i){switch(i){case"Depth":return this.depthMaterial;case"Normals":return this.normalsMaterial;case"Renderer":return null;case"UVs":return this.uvMaterial;case"Wireframe":return this.wireframeMaterial}return null}drawTo(i,e,t,s,n,r){switch(n.name){case"Left":case"Right":this.grid&&(this.grid.rotation.z=Math.PI/2);break;case"Front":case"Back":this.grid&&(this.grid.rotation.x=Math.PI/2);break}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,n)),this.grid&&this.grid.rotation.set(0,0,0)}drawSingle(){const i=this.getSceneOverride(this.tlRender);this.drawTo(0,0,this.width,this.height,this.tlCam,i)}drawDouble=()=>{const i=this.getSceneOverride(this.tlRender),e=this.getSceneOverride(this.trRender),t=Math.floor(this.width/2),s=Math.floor(this.height/2),n=this.renderer instanceof a.WebGPURenderer;if(this.state.mode==="Side by Side")this.drawTo(0,0,t,this.height,this.tlCam,i),this.drawTo(t,0,t,this.height,this.trCam,e);else{const r=this.height-s;n?(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))}};drawQuad=()=>{const i=this.renderer instanceof a.WebGPURenderer,e=this.getSceneOverride(this.tlRender),t=this.getSceneOverride(this.trRender),s=this.getSceneOverride(this.blRender),n=this.getSceneOverride(this.brRender),r=Math.floor(this.width/2),h=Math.floor(this.height/2),m=this.height-h;let l=0,f=i?0:this.height-h;l=0,this.drawTo(l,f,r,h,this.tlCam,e),l=r,this.drawTo(l,f,r,h,this.trCam,t),f=i?m:0,l=0,this.scene.overrideMaterial=s,this.drawTo(l,f,r,h,this.blCam,s),l=r,this.drawTo(l,f,r,h,this.brCam,n)};get appID(){return this.props.three.name}get mode(){return this.state.mode}get three(){return this.props.three}get expandedCameraVisibility(){return`${this.appID}_multiviewCameraVisibility`}get expandedLightVisibility(){return`${this.appID}_multiviewLightVisibility`}get expandedGridVisibility(){return`${this.appID}_multiviewGridVisibility`}}module.exports=A;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const o=require("react/jsx-runtime"),u=require("react");function d(e){const[t,n]=u.useState(e.selected),i="toggle"+(t?" selected":"");return o.jsx("button",{className:i,onClick:()=>{const c=!t;n(c),e.onClick(c)},style:{backgroundImage:`url(${e.icon})`,backgroundPositionX:"center",backgroundPositionY:e.top!==void 0?`${e.top}px`:"center",backgroundSize:`${e.width!==void 0?`${e.width}px`:"26px"} ${e.height}px`}},e.name)}module.exports=d;
|