@tomorrowevening/hermes 0.1.39 → 0.1.40
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-CB5dBR7Q.js} +1 -1
- 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 +442 -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 +22 -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-DepTXu6T.js} +454 -454
- 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/dist/.vite/manifest.json +0 -12
- package/dist/hermes.es.js +0 -8077
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var Uc=Object.defineProperty;var Vc=(r,t,e)=>t in r?Uc(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e;var b=(r,t,e)=>Vc(r,typeof t!="symbol"?t+"":t,e);import{r as I,j as T,L as Oe,B as Ks,F as Xn,a as Eo,M as F,b as ti,c as Yh,S as Hc,D as hr,G as jc,C as hi,P as Oo,N as Wc,u as Ms,v as Gc,d as wr,p as Yc,e as $c,f as on,g as Wt,h as Xc,i as ua,k as Zc,m as br,l as da,n as qc,o as pa,q as ma,s as Qc,t as fa,I as Jc,w as Kc,x as tu,y as eu,z as Zn,T as Y,A as Pt,E as su,H as ga,J as Ns,K as xe,O as go,Q as iu,R as xt,U as nu,V as ru,Z as $h,W as Xh,X as Zh,Y as qh,_ as Qh,$ as Jh,a0 as Kh,a1 as tl,a2 as el,a3 as sl,a4 as ou,a5 as il,a6 as nl,a7 as rl,a8 as ol,a9 as au,aa as hu,ab as lu,ac as cu,ad as uu,ae as du,af as pu,ag as mu,ah as fu,ai as gu,aj as yu,ak as ya,al as xu,am as lr,an as U,ao as al,ap as _u,aq as ge,ar as Wi,as as ei,at as Gt,au as zt,av as an,aw as mi,ax as hl,ay as Tu,az as is,aA as xa,aB as vu,aC as Zs,aD as wu,aE as bu,aF as Su,aG as Mu,aH as Nu,aI as Cu,aJ as Au,aK as _a,aL as hn,aM as Eu,aN as Ta,aO as va,aP as Ou,aQ as Ru,aR as Iu,aS as Pu,aT as Lu,aU as Fu,aV as zu,aW as Du,aX as Bu}from"./index-
|
|
1
|
+
var Uc=Object.defineProperty;var Vc=(r,t,e)=>t in r?Uc(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e;var b=(r,t,e)=>Vc(r,typeof t!="symbol"?t+"":t,e);import{r as I,j as T,L as Oe,B as Ks,F as Xn,a as Eo,M as F,b as ti,c as Yh,S as Hc,D as hr,G as jc,C as hi,P as Oo,N as Wc,u as Ms,v as Gc,d as wr,p as Yc,e as $c,f as on,g as Wt,h as Xc,i as ua,k as Zc,m as br,l as da,n as qc,o as pa,q as ma,s as Qc,t as fa,I as Jc,w as Kc,x as tu,y as eu,z as Zn,T as Y,A as Pt,E as su,H as ga,J as Ns,K as xe,O as go,Q as iu,R as xt,U as nu,V as ru,Z as $h,W as Xh,X as Zh,Y as qh,_ as Qh,$ as Jh,a0 as Kh,a1 as tl,a2 as el,a3 as sl,a4 as ou,a5 as il,a6 as nl,a7 as rl,a8 as ol,a9 as au,aa as hu,ab as lu,ac as cu,ad as uu,ae as du,af as pu,ag as mu,ah as fu,ai as gu,aj as yu,ak as ya,al as xu,am as lr,an as U,ao as al,ap as _u,aq as ge,ar as Wi,as as ei,at as Gt,au as zt,av as an,aw as mi,ax as hl,ay as Tu,az as is,aA as xa,aB as vu,aC as Zs,aD as wu,aE as bu,aF as Su,aG as Mu,aH as Nu,aI as Cu,aJ as Au,aK as _a,aL as hn,aM as Eu,aN as Ta,aO as va,aP as Ou,aQ as Ru,aR as Iu,aS as Pu,aT as Lu,aU as Fu,aV as zu,aW as Du,aX as Bu}from"./index-DepTXu6T.js";const ll=I.forwardRef((r,t)=>T.jsxs("div",{className:"editor",ref:t,style:r.style,children:[r.header&&T.jsx("div",{className:"header",children:r.header}),r.children,r.footer&&T.jsx("div",{className:"footer",children:r.footer})]}));ll.displayName="Editor";class ku extends Oe{constructor(t,e){const s=[1,1,0,-1,1,0,-1,-1,0,1,-1,0,1,1,0],i=new Ks;i.setAttribute("position",new Xn(s,3)),i.computeBoundingSphere();const n=new Eo({fog:!1});super(i,n),this.light=t,this.color=e,this.type="RectAreaLightHelper";const o=[1,1,0,-1,1,0,-1,-1,0,1,1,0,-1,-1,0,1,-1,0],a=new Ks;a.setAttribute("position",new Xn(o,3)),a.computeBoundingSphere(),this.add(new F(a,new ti({side:Yh,fog:!1})))}updateMatrixWorld(){if(this.scale.set(.5*this.light.width,.5*this.light.height,1),this.color!==void 0)this.material.color.set(this.color),this.children[0].material.color.set(this.color);else{this.material.color.copy(this.light.color).multiplyScalar(this.light.intensity);const t=this.material.color,e=Math.max(t.r,t.g,t.b);e>1&&t.multiplyScalar(1/e),this.children[0].material.color.copy(this.material.color)}this.matrixWorld.extractRotation(this.light.matrixWorld).scale(this.scale).copyPosition(this.light.matrixWorld),this.children[0].matrixWorld.copy(this.matrixWorld)}dispose(){this.geometry.dispose(),this.material.dispose(),this.children[0].geometry.dispose(),this.children[0].material.dispose()}}const yo=0,cr=1,Uu=2,Vu=0,wa=1,ba=100,Sa=204,Ma=205,Na=3,cl=0,Hu=1,ju=2,xo=0,ul=300,Ro=301,dl=302,pl=303,ml=304,Ca=1e3,Oi=1001,Aa=1002,as=1003,qn=1006,Io=1008,Wu=1009,Gu=1013,fl=1014,gl=1015,Yu=1016,$u=1023,Ea=1026,Xu=1027,Zu=1030,qu=37490,Qu=36285,Sr=0,Ju=1,Qn="",ye="srgb",Oa="srgb-linear",Ra="linear",Li="srgb",Mr="",yl="rg",Ku="ga",Cs=7680,Ia=519,td=513,si=35044,_o=35048,je=2e3,ii=2001,ed={TEXTURE_COMPARE:"depthTextureCompare"};function sd(r){for(let t=r.length-1;t>=0;--t)if(r[t]>=65535)return!0;return!1}function Pa(r){return document.createElementNS("http://www.w3.org/1999/xhtml",r)}const La={};function To(...r){const t="THREE."+r.shift();console.log(t,...r)}function xl(r){const t=r[0];if(typeof t=="string"&&t.startsWith("TSL:")){const e=r[1];e&&e.isStackTrace?r[0]+=" "+e.getLocation():r[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.'}return r}function W(...r){r=xl(r);const t="THREE."+r.shift();{const e=r[0];e&&e.isStackTrace?console.warn(e.getError(t)):console.warn(t,...r)}}function rt(...r){r=xl(r);const t="THREE."+r.shift();{const e=r[0];e&&e.isStackTrace?console.error(e.getError(t)):console.error(t,...r)}}function Gi(...r){const t=r.join(" ");t in La||(La[t]=!0,W(...r))}const Lt=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"];let Fa=1234567;const Fi=Math.PI/180,Jn=180/Math.PI;function Ge(){const r=Math.random()*4294967295|0,t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,s=Math.random()*4294967295|0;return(Lt[r&255]+Lt[r>>8&255]+Lt[r>>16&255]+Lt[r>>24&255]+"-"+Lt[t&255]+Lt[t>>8&255]+"-"+Lt[t>>16&15|64]+Lt[t>>24&255]+"-"+Lt[e&63|128]+Lt[e>>8&255]+"-"+Lt[e>>16&255]+Lt[e>>24&255]+Lt[s&255]+Lt[s>>8&255]+Lt[s>>16&255]+Lt[s>>24&255]).toLowerCase()}function X(r,t,e){return Math.max(t,Math.min(e,r))}function Po(r,t){return(r%t+t)%t}function ys(r,t,e,s,i){return s+(r-t)*(i-s)/(e-t)}function id(r,t,e){return r!==t?(e-r)/(t-r):0}function ns(r,t,e){return(1-e)*r+e*t}function nd(r,t,e,s){return ns(r,t,1-Math.exp(-e*s))}function rd(r,t=1){return t-Math.abs(Po(r,t*2)-t)}function od(r,t,e){return r<=t?0:r>=e?1:(r=(r-t)/(e-t),r*r*(3-2*r))}function ad(r,t,e){return r<=t?0:r>=e?1:(r=(r-t)/(e-t),r*r*r*(r*(r*6-15)+10))}function hd(r,t){return r+Math.floor(Math.random()*(t-r+1))}function ld(r,t){return r+Math.random()*(t-r)}function cd(r){return r*(.5-Math.random())}function ud(r){r!==void 0&&(Fa=r);let t=Fa+=1831565813;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}function Kn(r){return r*Fi}function _l(r){return r*Jn}function dd(r){return(r&r-1)===0&&r!==0}function pd(r){return Math.pow(2,Math.ceil(Math.log(r)/Math.LN2))}function md(r){return Math.pow(2,Math.floor(Math.log(r)/Math.LN2))}function fd(r,t,e,s,i){const n=Math.cos,o=Math.sin,a=n(e/2),h=o(e/2),l=n((t+s)/2),c=o((t+s)/2),u=n((t-s)/2),d=o((t-s)/2),p=n((s-t)/2),m=o((s-t)/2);switch(i){case"XYX":r.set(a*c,h*u,h*d,a*l);break;case"YZY":r.set(h*d,a*c,h*u,a*l);break;case"ZXZ":r.set(h*u,h*d,a*c,a*l);break;case"XZX":r.set(a*c,h*m,h*p,a*l);break;case"YXY":r.set(h*p,a*c,h*m,a*l);break;case"ZYZ":r.set(h*m,h*p,a*c,a*l);break;default:W("MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+i)}}function _e(r,t){switch(t.constructor){case Float32Array:return r;case Uint32Array:return r/4294967295;case Uint16Array:return r/65535;case Uint8Array:return r/255;case Int32Array:return Math.max(r/2147483647,-1);case Int16Array:return Math.max(r/32767,-1);case Int8Array:return Math.max(r/127,-1);default:throw new Error("Invalid component type.")}}function st(r,t){switch(t.constructor){case Float32Array:return r;case Uint32Array:return Math.round(r*4294967295);case Uint16Array:return Math.round(r*65535);case Uint8Array:return Math.round(r*255);case Int32Array:return Math.round(r*2147483647);case Int16Array:return Math.round(r*32767);case Int8Array:return Math.round(r*127);default:throw new Error("Invalid component type.")}}const gd={DEG2RAD:Fi,RAD2DEG:Jn,generateUUID:Ge,clamp:X,euclideanModulo:Po,mapLinear:ys,inverseLerp:id,lerp:ns,damp:nd,pingpong:rd,smoothstep:od,smootherstep:ad,randInt:hd,randFloat:ld,randFloatSpread:cd,seededRandom:ud,degToRad:Kn,radToDeg:_l,isPowerOfTwo:dd,ceilPowerOfTwo:pd,floorPowerOfTwo:md,setQuaternionFromProperEuler:fd,normalize:st,denormalize:_e};/*!
|
|
2
2
|
* camera-controls
|
|
3
3
|
* https://github.com/yomotsu/camera-controls
|
|
4
4
|
* (c) 2017 @yomotsu
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { detectSettings as s } from "../utils/detectSettings.js";
|
|
2
|
+
class n {
|
|
3
|
+
assets = {
|
|
4
|
+
audio: /* @__PURE__ */ new Map(),
|
|
5
|
+
image: /* @__PURE__ */ new Map(),
|
|
6
|
+
json: /* @__PURE__ */ new Map(),
|
|
7
|
+
model: /* @__PURE__ */ new Map(),
|
|
8
|
+
video: /* @__PURE__ */ new Map()
|
|
9
|
+
};
|
|
10
|
+
components = /* @__PURE__ */ new Map();
|
|
11
|
+
settings = {
|
|
12
|
+
dpr: 1,
|
|
13
|
+
fps: 30,
|
|
14
|
+
width: 0,
|
|
15
|
+
height: 0,
|
|
16
|
+
mobile: !1,
|
|
17
|
+
supportOffScreenCanvas: !1,
|
|
18
|
+
supportWebGPU: !1,
|
|
19
|
+
quality: "Low",
|
|
20
|
+
dev: !1,
|
|
21
|
+
editor: !1
|
|
22
|
+
};
|
|
23
|
+
onUpdateCallback;
|
|
24
|
+
// Protected
|
|
25
|
+
playing = !1;
|
|
26
|
+
rafID = -1;
|
|
27
|
+
constructor(t, e = !1) {
|
|
28
|
+
this.settings.dev = t, this.settings.editor = e;
|
|
29
|
+
}
|
|
30
|
+
dispose() {
|
|
31
|
+
this.pause(), this.components.forEach((t) => t.dispose()), this.components.clear();
|
|
32
|
+
}
|
|
33
|
+
detectSettings() {
|
|
34
|
+
return new Promise((t) => {
|
|
35
|
+
s(this.settings.dev, this.settings.editor).then((e) => {
|
|
36
|
+
this.settings = e, t();
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
// Playback
|
|
41
|
+
update() {
|
|
42
|
+
}
|
|
43
|
+
draw() {
|
|
44
|
+
}
|
|
45
|
+
play = () => {
|
|
46
|
+
this.playing || (this.playing = !0, this.onUpdate());
|
|
47
|
+
};
|
|
48
|
+
pause = () => {
|
|
49
|
+
this.playing && (this.playing = !1, cancelAnimationFrame(this.rafID), this.rafID = -1);
|
|
50
|
+
};
|
|
51
|
+
onUpdate = () => {
|
|
52
|
+
this.update(), this.isApp && this.draw(), this.onUpdateCallback && this.onUpdateCallback(), this.rafID = requestAnimationFrame(this.onUpdate);
|
|
53
|
+
};
|
|
54
|
+
// Remote Components
|
|
55
|
+
addComponent(t, e) {
|
|
56
|
+
this.components.set(t, e);
|
|
57
|
+
}
|
|
58
|
+
// Getters
|
|
59
|
+
get debugEnabled() {
|
|
60
|
+
return this.settings.dev;
|
|
61
|
+
}
|
|
62
|
+
get isApp() {
|
|
63
|
+
return !this.editor;
|
|
64
|
+
}
|
|
65
|
+
set isApp(t) {
|
|
66
|
+
this.editor = !t;
|
|
67
|
+
}
|
|
68
|
+
get editor() {
|
|
69
|
+
return this.settings.editor;
|
|
70
|
+
}
|
|
71
|
+
set editor(t) {
|
|
72
|
+
this.settings.editor = t;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
export {
|
|
76
|
+
n as default
|
|
77
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
class n {
|
|
2
|
+
name;
|
|
3
|
+
debug;
|
|
4
|
+
editor;
|
|
5
|
+
broadcastChannel;
|
|
6
|
+
onMessageHandler;
|
|
7
|
+
constructor(e, s = !1, a = !1) {
|
|
8
|
+
this.name = e, this.debug = s, this.editor = a, s && (this.broadcastChannel = new BroadcastChannel(e), this.onMessageHandler = this.messageHandler.bind(this), this.broadcastChannel.addEventListener("message", this.onMessageHandler));
|
|
9
|
+
}
|
|
10
|
+
dispose() {
|
|
11
|
+
this.broadcastChannel?.removeEventListener("message", this.onMessageHandler), this.broadcastChannel?.close();
|
|
12
|
+
}
|
|
13
|
+
// Broadcast
|
|
14
|
+
send(e) {
|
|
15
|
+
if (this.editor && e.target === "app" || !this.editor && e.target === "editor")
|
|
16
|
+
try {
|
|
17
|
+
this.broadcastChannel?.postMessage(e);
|
|
18
|
+
} catch (a) {
|
|
19
|
+
console.log("Hermes - Error sending message:"), console.log(a), console.log(e);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
messageHandler(e) {
|
|
23
|
+
const s = e.data;
|
|
24
|
+
s.target === "app" ? this.handleApp(s) : this.handleEditor(s);
|
|
25
|
+
}
|
|
26
|
+
handleApp(e) {
|
|
27
|
+
}
|
|
28
|
+
handleEditor(e) {
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
export {
|
|
32
|
+
n as default
|
|
33
|
+
};
|
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
import { getProject as _ } from "@tomorrowevening/theatre-core";
|
|
2
|
+
import $ from "./BaseRemote.js";
|
|
3
|
+
import { noop as g } from "../types.js";
|
|
4
|
+
import { isColor as w } from "../../editor/utils.js";
|
|
5
|
+
function P(n, e, t, i, h) {
|
|
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;
|
|
8
|
+
}
|
|
9
|
+
function q(n, e, t) {
|
|
10
|
+
if (n.type !== "bezier" || n.handles.length !== 4)
|
|
11
|
+
throw new Error("Invalid keyframe data for Bézier interpolation.");
|
|
12
|
+
const [i, h] = n.handles, s = (t - n.position) / (e.position - n.position);
|
|
13
|
+
return P(
|
|
14
|
+
s,
|
|
15
|
+
n.value,
|
|
16
|
+
n.value + i,
|
|
17
|
+
e.value + h,
|
|
18
|
+
e.value
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
class E extends $ {
|
|
22
|
+
project;
|
|
23
|
+
sheets = /* @__PURE__ */ new Map();
|
|
24
|
+
sheetObjects = /* @__PURE__ */ new Map();
|
|
25
|
+
sheetObjectCBs = /* @__PURE__ */ new Map();
|
|
26
|
+
sheetObjectUnsubscribe = /* @__PURE__ */ new Map();
|
|
27
|
+
activeSheet;
|
|
28
|
+
studio = void 0;
|
|
29
|
+
constructor(e = !1, t = !1) {
|
|
30
|
+
super("RemoteTheatre", e, t);
|
|
31
|
+
}
|
|
32
|
+
dispose() {
|
|
33
|
+
this.project = void 0, this.sheets = /* @__PURE__ */ new Map(), this.sheetObjects = /* @__PURE__ */ new Map(), this.sheetObjectCBs = /* @__PURE__ */ new Map(), this.sheetObjectUnsubscribe = /* @__PURE__ */ new Map();
|
|
34
|
+
}
|
|
35
|
+
loadProject(e, t) {
|
|
36
|
+
return this.project = _(e, { state: t }), new Promise((i, h) => {
|
|
37
|
+
this.project?.ready.then(() => {
|
|
38
|
+
if (t) {
|
|
39
|
+
const s = t.sheetsById;
|
|
40
|
+
for (const a in s) this.sheet(a);
|
|
41
|
+
}
|
|
42
|
+
i();
|
|
43
|
+
}).catch(() => h());
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
getSheetInstance(e, t) {
|
|
47
|
+
return t !== void 0 ? `${e}-${t}` : e;
|
|
48
|
+
}
|
|
49
|
+
sheet(e, t) {
|
|
50
|
+
if (this.project === void 0) {
|
|
51
|
+
console.error("Theatre Project hasn't been created yet.");
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
const i = this.getSheetInstance(e, t);
|
|
55
|
+
let h = this.sheets.get(i);
|
|
56
|
+
return h !== void 0 || (h = this.project?.sheet(e, t), this.sheets.set(i, h)), h;
|
|
57
|
+
}
|
|
58
|
+
playSheet(e, t, i) {
|
|
59
|
+
return new Promise((h) => {
|
|
60
|
+
this.sheet(e, i)?.sequence.play(t).then((s) => h(s)), this.send({
|
|
61
|
+
event: "playSheet",
|
|
62
|
+
target: "editor",
|
|
63
|
+
data: {
|
|
64
|
+
sheet: e,
|
|
65
|
+
instance: i,
|
|
66
|
+
value: t
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
pauseSheet(e, t) {
|
|
72
|
+
this.sheet(e, t)?.sequence.pause(), this.send({
|
|
73
|
+
event: "pauseSheet",
|
|
74
|
+
target: "editor",
|
|
75
|
+
data: {
|
|
76
|
+
sheet: e,
|
|
77
|
+
instance: t
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
clearSheetObjects(e) {
|
|
82
|
+
this.sheetObjects.forEach((t, i) => {
|
|
83
|
+
i.search(`${e}_`) > -1 && this.unsubscribe(t);
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
sheetObject(e, t, i, h, s) {
|
|
87
|
+
if (this.project === void 0) {
|
|
88
|
+
console.error("Theatre Project hasn't been created yet.");
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
const a = this.sheet(e, s);
|
|
92
|
+
if (a === void 0) return;
|
|
93
|
+
const u = `${this.getSheetInstance(e, s)}_${t}`;
|
|
94
|
+
let b = this.sheetObjects.get(u), j = i;
|
|
95
|
+
b !== void 0 && (j = { ...i, ...b.value }), b = a.object(t, j, { reconfigure: !0 }), this.sheetObjects.set(u, b), this.sheetObjectCBs.set(u, h !== void 0 ? h : g);
|
|
96
|
+
function v(d, p, o) {
|
|
97
|
+
if (typeof o == "object")
|
|
98
|
+
if (w(o))
|
|
99
|
+
d[p] = {
|
|
100
|
+
r: o.r,
|
|
101
|
+
g: o.g,
|
|
102
|
+
b: o.b,
|
|
103
|
+
a: o.a
|
|
104
|
+
};
|
|
105
|
+
else
|
|
106
|
+
for (const r in o) {
|
|
107
|
+
const l = o[r];
|
|
108
|
+
typeof l == "object" && v(o, r, l);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
const c = b.onValuesChange((d) => {
|
|
112
|
+
const p = this.sheetObjectCBs.get(u);
|
|
113
|
+
if (this.editor) {
|
|
114
|
+
for (const o in d) {
|
|
115
|
+
const r = d[o];
|
|
116
|
+
typeof r == "object" && v(d, o, r);
|
|
117
|
+
}
|
|
118
|
+
this.send({
|
|
119
|
+
event: "updateSheetObject",
|
|
120
|
+
target: "app",
|
|
121
|
+
data: {
|
|
122
|
+
sheet: e,
|
|
123
|
+
sheetObject: u,
|
|
124
|
+
values: d
|
|
125
|
+
}
|
|
126
|
+
}), p && p(d);
|
|
127
|
+
} else
|
|
128
|
+
p && p(d);
|
|
129
|
+
});
|
|
130
|
+
return this.sheetObjectUnsubscribe.set(u, c), b;
|
|
131
|
+
}
|
|
132
|
+
getSheetObjectKeyframes(e, t, i) {
|
|
133
|
+
const h = this.sheet(e);
|
|
134
|
+
if (h === void 0) return [];
|
|
135
|
+
const s = `${e}_${t}`, a = this.sheetObjects.get(s);
|
|
136
|
+
return a === void 0 ? [] : h.sequence.__experimental_getKeyframes(a.props[i]);
|
|
137
|
+
}
|
|
138
|
+
getSheetObjectVectors(e, t) {
|
|
139
|
+
const i = this.sheet(e);
|
|
140
|
+
if (i === void 0) return [];
|
|
141
|
+
const h = `${e}_${t}`, s = this.sheetObjects.get(h);
|
|
142
|
+
if (s === void 0) return [];
|
|
143
|
+
const a = [], 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
|
+
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
|
+
const d = (p, o) => {
|
|
146
|
+
const r = p.find((S, y) => S.position <= o && (p[y + 1]?.position || 1 / 0) > o), l = p.find((S) => S.position > o);
|
|
147
|
+
if (!r) return l?.value || 0;
|
|
148
|
+
if (!l || r.position === o) return r.value;
|
|
149
|
+
if (r.type === "bezier")
|
|
150
|
+
return q(r, l, o);
|
|
151
|
+
const O = (o - r.position) / (l.position - r.position);
|
|
152
|
+
return r.value + O * (l.value - r.value);
|
|
153
|
+
};
|
|
154
|
+
a.push({
|
|
155
|
+
position: c,
|
|
156
|
+
x: d(f, c),
|
|
157
|
+
y: d(u, c),
|
|
158
|
+
z: d(b, c)
|
|
159
|
+
});
|
|
160
|
+
}), a;
|
|
161
|
+
}
|
|
162
|
+
update(e) {
|
|
163
|
+
}
|
|
164
|
+
unsubscribe(e) {
|
|
165
|
+
if (this.project === void 0) {
|
|
166
|
+
console.error("Theatre Project hasn't been created yet.");
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
const t = e.address.sheetId, i = e.address.objectKey;
|
|
170
|
+
this.sheets.get(t)?.detachObject(i);
|
|
171
|
+
const s = `${t}_${i}`, a = this.sheetObjectUnsubscribe.get(s);
|
|
172
|
+
a !== void 0 && (this.sheetObjects.delete(s), this.sheetObjectCBs.delete(s), this.sheetObjectUnsubscribe.delete(s), a());
|
|
173
|
+
}
|
|
174
|
+
handleApp(e) {
|
|
175
|
+
let t;
|
|
176
|
+
switch (e.event) {
|
|
177
|
+
case "setSheet":
|
|
178
|
+
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);
|
|
179
|
+
break;
|
|
180
|
+
case "setSheetObject":
|
|
181
|
+
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);
|
|
182
|
+
break;
|
|
183
|
+
case "updateSheetObject":
|
|
184
|
+
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);
|
|
185
|
+
break;
|
|
186
|
+
case "updateTimeline":
|
|
187
|
+
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}`);
|
|
188
|
+
break;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
handleEditor(e) {
|
|
192
|
+
switch (e.event) {
|
|
193
|
+
case "playSheet":
|
|
194
|
+
this.sheet(e.data.sheet, e.data.instance)?.sequence.play(e.data.value);
|
|
195
|
+
break;
|
|
196
|
+
case "pauseSheet":
|
|
197
|
+
this.sheet(e.data.sheet, e.data.instance)?.sequence.pause();
|
|
198
|
+
break;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
getSheetNames() {
|
|
202
|
+
const e = [];
|
|
203
|
+
return this.sheets.forEach((t, i) => {
|
|
204
|
+
e.push(i);
|
|
205
|
+
}), e;
|
|
206
|
+
}
|
|
207
|
+
handleEditorApp() {
|
|
208
|
+
if (this.editor) {
|
|
209
|
+
this.studio?.ui.restore(), this.studio?.onSelectionChange((h) => {
|
|
210
|
+
h.length < 1 || h.forEach((s) => {
|
|
211
|
+
let a = s.address.sheetId, f = "setSheet", u = {};
|
|
212
|
+
switch (s.type) {
|
|
213
|
+
case "Theatre_Sheet_PublicAPI":
|
|
214
|
+
f = "setSheet", u = {
|
|
215
|
+
sheet: s.address.sheetId
|
|
216
|
+
}, this.activeSheet = this.sheets.get(s.address.sheetId);
|
|
217
|
+
break;
|
|
218
|
+
case "Theatre_SheetObject_PublicAPI":
|
|
219
|
+
f = "setSheetObject", a += `_${s.address.objectKey}`, u = {
|
|
220
|
+
id: a,
|
|
221
|
+
sheet: s.address.sheetId,
|
|
222
|
+
key: s.address.objectKey
|
|
223
|
+
}, this.activeSheet = this.sheets.get(s.address.sheetId);
|
|
224
|
+
break;
|
|
225
|
+
}
|
|
226
|
+
this.send({ event: f, target: "app", data: u });
|
|
227
|
+
});
|
|
228
|
+
});
|
|
229
|
+
let e = -1;
|
|
230
|
+
const t = () => {
|
|
231
|
+
if (this.activeSheet !== void 0 && e !== this.activeSheet.sequence.position) {
|
|
232
|
+
e = this.activeSheet.sequence.position;
|
|
233
|
+
const h = this.activeSheet;
|
|
234
|
+
this.send({
|
|
235
|
+
event: "updateTimeline",
|
|
236
|
+
target: "app",
|
|
237
|
+
data: {
|
|
238
|
+
position: e,
|
|
239
|
+
sheet: h.address.sheetId
|
|
240
|
+
}
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
}, i = () => {
|
|
244
|
+
t(), requestAnimationFrame(i);
|
|
245
|
+
};
|
|
246
|
+
t(), i();
|
|
247
|
+
} else
|
|
248
|
+
this.studio?.ui.hide();
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
export {
|
|
252
|
+
E as default
|
|
253
|
+
};
|