@tomorrowevening/hermes 0.1.43 → 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.
@@ -1 +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,fps:30,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;
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;
@@ -10,7 +10,6 @@ class n {
10
10
  components = /* @__PURE__ */ new Map();
11
11
  settings = {
12
12
  dpr: 1,
13
- fps: 30,
14
13
  width: 0,
15
14
  height: 0,
16
15
  mobile: !1,
@@ -1 +1 @@
1
- "use strict";const _=require("@tomorrowevening/theatre-core"),$=require("./BaseRemote.cjs"),g=require("../types.cjs");function q(o){return o!=null&&o.r!==void 0&&o.g!==void 0&&o.b!==void 0}function w(o,e,t,i,h){const s=1-o;return s*s*s*e+3*s*s*o*t+3*s*o*o*i+o*o*o*h}function C(o,e,t){if(o.type!=="bezier"||o.handles.length!==4)throw new Error("Invalid keyframe data for Bézier interpolation.");const[i,h]=o.handles,s=(t-o.position)/(e.position-o.position);return w(s,o.value,o.value+i,e.value+h,e.value)}class P 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 a in s)this.sheet(a)}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)),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 a=this.sheet(e,s);if(a===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=a.object(t,j,{reconfigure:!0}),this.sheetObjects.set(u,b),this.sheetObjectCBs.set(u,h!==void 0?h:g.noop);function v(d,p,n){if(typeof n=="object")if(q(n))d[p]={r:n.r,g:n.g,b:n.b,a:n.a};else for(const r in n){const l=n[r];typeof l=="object"&&v(n,r,l)}}const c=b.onValuesChange(d=>{const p=this.sheetObjectCBs.get(u);if(this.editor){for(const n in d){const r=d[n];typeof r=="object"&&v(d,n,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),b}getSheetObjectKeyframes(e,t,i){const h=this.sheet(e);if(h===void 0)return[];const s=`${e}_${t}`,a=this.sheetObjects.get(s);return a===void 0?[]:h.sequence.__experimental_getKeyframes(a.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 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=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,n)=>{const r=p.find((S,y)=>S.position<=n&&(p[y+1]?.position||1/0)>n),l=p.find(S=>S.position>n);if(!r)return l?.value||0;if(!l||r.position===n)return r.value;if(r.type==="bezier")return C(r,l,n);const O=(n-r.position)/(l.position-r.position);return r.value+O*(l.value-r.value)};a.push({position:c,x:d(f,c),y:d(u,c),z:d(b,c)})}),a}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}`,a=this.sheetObjectUnsubscribe.get(s);a!==void 0&&(this.sheetObjects.delete(s),this.sheetObjectCBs.delete(s),this.sheetObjectUnsubscribe.delete(s),a())}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"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}}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 a=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",a+=`_${s.address.objectKey}`,u={id:a,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=P;
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,21 +1,21 @@
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
- function w(o) {
5
- return o != null && o.r !== void 0 && o.g !== void 0 && o.b !== void 0;
4
+ function w(a) {
5
+ return a != null && a.r !== void 0 && a.g !== void 0 && a.b !== void 0;
6
6
  }
7
- function P(o, e, t, i, h) {
8
- const s = 1 - o;
9
- return s * s * s * e + 3 * s * s * o * t + 3 * s * o * o * i + o * o * o * h;
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
10
  }
11
- function q(o, e, t) {
12
- if (o.type !== "bezier" || o.handles.length !== 4)
11
+ function P(a, e, t) {
12
+ if (a.type !== "bezier" || a.handles.length !== 4)
13
13
  throw new Error("Invalid keyframe data for Bézier interpolation.");
14
- const [i, h] = o.handles, s = (t - o.position) / (e.position - o.position);
15
- return P(
14
+ const [i, h] = a.handles, s = (t - a.position) / (e.position - a.position);
15
+ return k(
16
16
  s,
17
- o.value,
18
- o.value + i,
17
+ a.value,
18
+ a.value + i,
19
19
  e.value + h,
20
20
  e.value
21
21
  );
@@ -39,7 +39,7 @@ class B extends $ {
39
39
  this.project?.ready.then(() => {
40
40
  if (t) {
41
41
  const s = t.sheetsById;
42
- for (const a in s) this.sheet(a);
42
+ for (const n in s) this.sheet(n);
43
43
  }
44
44
  i();
45
45
  }).catch(() => h());
@@ -55,7 +55,14 @@ class B extends $ {
55
55
  }
56
56
  const i = this.getSheetInstance(e, t);
57
57
  let h = this.sheets.get(i);
58
- return h !== void 0 || (h = this.project?.sheet(e, t), this.sheets.set(i, h)), 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;
59
66
  }
60
67
  playSheet(e, t, i) {
61
68
  return new Promise((h) => {
@@ -90,32 +97,32 @@ class B extends $ {
90
97
  console.error("Theatre Project hasn't been created yet.");
91
98
  return;
92
99
  }
93
- const a = this.sheet(e, s);
94
- if (a === void 0) return;
100
+ const n = this.sheet(e, s);
101
+ if (n === void 0) return;
95
102
  const u = `${this.getSheetInstance(e, s)}_${t}`;
96
103
  let b = this.sheetObjects.get(u), j = i;
97
- 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);
98
- function v(d, p, n) {
99
- if (typeof n == "object")
100
- if (w(n))
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);
105
+ function v(d, p, o) {
106
+ if (typeof o == "object")
107
+ if (w(o))
101
108
  d[p] = {
102
- r: n.r,
103
- g: n.g,
104
- b: n.b,
105
- a: n.a
109
+ r: o.r,
110
+ g: o.g,
111
+ b: o.b,
112
+ a: o.a
106
113
  };
107
114
  else
108
- for (const r in n) {
109
- const l = n[r];
110
- typeof l == "object" && v(n, r, l);
115
+ for (const r in o) {
116
+ const l = o[r];
117
+ typeof l == "object" && v(o, r, l);
111
118
  }
112
119
  }
113
120
  const c = b.onValuesChange((d) => {
114
121
  const p = this.sheetObjectCBs.get(u);
115
122
  if (this.editor) {
116
- for (const n in d) {
117
- const r = d[n];
118
- typeof r == "object" && v(d, n, r);
123
+ for (const o in d) {
124
+ const r = d[o];
125
+ typeof r == "object" && v(d, o, r);
119
126
  }
120
127
  this.send({
121
128
  event: "updateSheetObject",
@@ -129,37 +136,46 @@ class B extends $ {
129
136
  } else
130
137
  p && p(d);
131
138
  });
132
- return this.sheetObjectUnsubscribe.set(u, c), b;
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;
133
149
  }
134
150
  getSheetObjectKeyframes(e, t, i) {
135
151
  const h = this.sheet(e);
136
152
  if (h === void 0) return [];
137
- const s = `${e}_${t}`, a = this.sheetObjects.get(s);
138
- return a === void 0 ? [] : h.sequence.__experimental_getKeyframes(a.props[i]);
153
+ const s = `${e}_${t}`, n = this.sheetObjects.get(s);
154
+ return n === void 0 ? [] : h.sequence.__experimental_getKeyframes(n.props[i]);
139
155
  }
140
156
  getSheetObjectVectors(e, t) {
141
157
  const i = this.sheet(e);
142
158
  if (i === void 0) return [];
143
159
  const h = `${e}_${t}`, s = this.sheetObjects.get(h);
144
160
  if (s === void 0) return [];
145
- 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();
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();
146
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) => {
147
- const d = (p, n) => {
148
- const r = p.find((S, y) => S.position <= n && (p[y + 1]?.position || 1 / 0) > n), l = p.find((S) => S.position > n);
163
+ const d = (p, o) => {
164
+ const r = p.find((S, y) => S.position <= o && (p[y + 1]?.position || 1 / 0) > o), l = p.find((S) => S.position > o);
149
165
  if (!r) return l?.value || 0;
150
- if (!l || r.position === n) return r.value;
166
+ if (!l || r.position === o) return r.value;
151
167
  if (r.type === "bezier")
152
- return q(r, l, n);
153
- const O = (n - r.position) / (l.position - r.position);
168
+ return P(r, l, o);
169
+ const O = (o - r.position) / (l.position - r.position);
154
170
  return r.value + O * (l.value - r.value);
155
171
  };
156
- a.push({
172
+ n.push({
157
173
  position: c,
158
174
  x: d(f, c),
159
175
  y: d(u, c),
160
176
  z: d(b, c)
161
177
  });
162
- }), a;
178
+ }), n;
163
179
  }
164
180
  update(e) {
165
181
  }
@@ -170,8 +186,8 @@ class B extends $ {
170
186
  }
171
187
  const t = e.address.sheetId, i = e.address.objectKey;
172
188
  this.sheets.get(t)?.detachObject(i);
173
- const s = `${t}_${i}`, a = this.sheetObjectUnsubscribe.get(s);
174
- a !== void 0 && (this.sheetObjects.delete(s), this.sheetObjectCBs.delete(s), this.sheetObjectUnsubscribe.delete(s), a());
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());
175
191
  }
176
192
  handleApp(e) {
177
193
  let t;
@@ -192,12 +208,24 @@ class B extends $ {
192
208
  }
193
209
  handleEditor(e) {
194
210
  switch (e.event) {
211
+ case "createSheet":
212
+ this.sheet(e.data.sheet, e.data.instance);
213
+ break;
195
214
  case "playSheet":
196
215
  this.sheet(e.data.sheet, e.data.instance)?.sequence.play(e.data.value);
197
216
  break;
198
217
  case "pauseSheet":
199
218
  this.sheet(e.data.sheet, e.data.instance)?.sequence.pause();
200
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;
201
229
  }
202
230
  }
203
231
  getSheetNames() {
@@ -210,7 +238,7 @@ class B extends $ {
210
238
  if (this.editor) {
211
239
  this.studio?.ui.restore(), this.studio?.onSelectionChange((h) => {
212
240
  h.length < 1 || h.forEach((s) => {
213
- let a = s.address.sheetId, f = "setSheet", u = {};
241
+ let n = s.address.sheetId, f = "setSheet", u = {};
214
242
  switch (s.type) {
215
243
  case "Theatre_Sheet_PublicAPI":
216
244
  f = "setSheet", u = {
@@ -218,8 +246,8 @@ class B extends $ {
218
246
  }, this.activeSheet = this.sheets.get(s.address.sheetId);
219
247
  break;
220
248
  case "Theatre_SheetObject_PublicAPI":
221
- f = "setSheetObject", a += `_${s.address.objectKey}`, u = {
222
- id: a,
249
+ f = "setSheetObject", n += `_${s.address.objectKey}`, u = {
250
+ id: n,
223
251
  sheet: s.address.sheetId,
224
252
  key: s.address.objectKey
225
253
  }, this.activeSheet = this.sheets.get(s.address.sheetId);
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./core/types.cjs"),s=require("./utils/detectSettings.cjs"),c=require("./utils/ImageSequenceCapturer.cjs"),t=require("./utils/math.cjs"),r=require("./utils/theatre.cjs"),e=require("./utils/three.cjs"),a=require("./utils/post.cjs"),n=require("./webworkers/EventHandling.cjs"),i=require("./webworkers/ProxyManager.cjs"),l=require("./core/Application.cjs"),p=require("./core/remote/BaseRemote.cjs"),m=require("./core/remote/RemoteTheatre.cjs"),u=require("./core/remote/RemoteThree.cjs"),d=require("./editor/HermesApp.cjs");exports.defaultTheatreCallback=o.defaultTheatreCallback;exports.noop=o.noop;exports.detectMaxFrameRate=s.detectMaxFrameRate;exports.detectSettings=s.detectSettings;exports.ImageSequenceCapturer=c.ImageSequenceCapturer;exports.clamp=t.clamp;exports.cubicBezier=t.cubicBezier;exports.damp=t.damp;exports.distance=t.distance;exports.getAngle=t.getAngle;exports.map=t.map;exports.mix=t.mix;exports.normalize=t.normalize;exports.rgbaToHex=t.rgbaToHex;exports.roundTo=t.roundTo;exports.animateObjectMaterial=r.animateObjectMaterial;exports.animateObjectTransform=r.animateObjectTransform;exports.applyObjectMaterial=r.applyObjectMaterial;exports.customizeTheatreElements=r.customizeTheatreElements;exports.getObjectMaterialObject=r.getObjectMaterialObject;exports.getObjectMaterialProps=r.getObjectMaterialProps;exports.useStudio=r.useStudio;exports.ExportTexture=e.ExportTexture;exports.anchorGeometry=e.anchorGeometry;exports.anchorGeometryTL=e.anchorGeometryTL;exports.createMask=e.createMask;exports.dispose=e.dispose;exports.disposeMaterial=e.disposeMaterial;exports.disposeTexture=e.disposeTexture;exports.hierarchyUUID=e.hierarchyUUID;exports.orthoCamera=e.orthoCamera;exports.parseModelLite=e.parseModelLite;exports.renderToTexture=e.renderToTexture;exports.resetThreeObjects=e.resetThreeObjects;exports.setMaterialBlendAdd=e.setMaterialBlendAdd;exports.setMaterialBlendMultiply=e.setMaterialBlendMultiply;exports.setMaterialBlendNormal=e.setMaterialBlendNormal;exports.setMaterialBlendScreen=e.setMaterialBlendScreen;exports.supportsOffscreenCanvas=e.supportsOffscreenCanvas;Object.defineProperty(exports,"totalThreeObjects",{enumerable:!0,get:()=>e.totalThreeObjects});exports.triangle=e.triangle;exports.updateCameraOrtho=e.updateCameraOrtho;exports.updateCameraOrtho16x9=e.updateCameraOrtho16x9;exports.useMask=e.useMask;exports.clearComposerGroups=a.clearComposerGroups;exports.generateCubemap=a.generateCubemap;exports.inspectComposer=a.inspectComposer;exports.inspectComposerPass=a.inspectComposerPass;exports.ElementProxy=n.ElementProxy;exports.WebworkerEventHandlers=n.WebworkerEventHandlers;exports.ElementProxyReceiver=i.ElementProxyReceiver;exports.ProxyManager=i.ProxyManager;exports.Application=l;exports.BaseRemote=p;exports.RemoteTheatre=m;exports.RemoteThree=u.default;exports.HermesApp=d;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("./core/types.cjs"),i=require("./utils/detectSettings.cjs"),s=require("./utils/ImageSequenceCapturer.cjs"),t=require("./utils/math.cjs"),r=require("./utils/theatre.cjs"),e=require("./utils/three.cjs"),o=require("./webworkers/EventHandling.cjs"),n=require("./webworkers/ProxyManager.cjs"),l=require("./core/Application.cjs"),c=require("./core/remote/BaseRemote.cjs"),u=require("./core/remote/RemoteTheatre.cjs"),p=require("./core/remote/RemoteThree.cjs"),d=require("./editor/HermesApp.cjs");exports.defaultTheatreCallback=a.defaultTheatreCallback;exports.noop=a.noop;exports.detectSettings=i.detectSettings;exports.ImageSequenceCapturer=s.ImageSequenceCapturer;exports.clamp=t.clamp;exports.cubicBezier=t.cubicBezier;exports.damp=t.damp;exports.distance=t.distance;exports.getAngle=t.getAngle;exports.map=t.map;exports.mix=t.mix;exports.normalize=t.normalize;exports.rgbaToHex=t.rgbaToHex;exports.roundTo=t.roundTo;exports.animateObjectMaterial=r.animateObjectMaterial;exports.animateObjectTransform=r.animateObjectTransform;exports.applyObjectMaterial=r.applyObjectMaterial;exports.getObjectMaterialObject=r.getObjectMaterialObject;exports.getObjectMaterialProps=r.getObjectMaterialProps;exports.useStudio=r.useStudio;exports.ExportTexture=e.ExportTexture;exports.anchorGeometry=e.anchorGeometry;exports.anchorGeometryTL=e.anchorGeometryTL;exports.createMask=e.createMask;exports.dispose=e.dispose;exports.disposeMaterial=e.disposeMaterial;exports.disposeTexture=e.disposeTexture;exports.hierarchyUUID=e.hierarchyUUID;exports.orthoCamera=e.orthoCamera;exports.parseModelLite=e.parseModelLite;exports.renderToTexture=e.renderToTexture;exports.resetThreeObjects=e.resetThreeObjects;exports.setMaterialBlendAdd=e.setMaterialBlendAdd;exports.setMaterialBlendMultiply=e.setMaterialBlendMultiply;exports.setMaterialBlendNormal=e.setMaterialBlendNormal;exports.setMaterialBlendScreen=e.setMaterialBlendScreen;exports.supportsOffscreenCanvas=e.supportsOffscreenCanvas;Object.defineProperty(exports,"totalThreeObjects",{enumerable:!0,get:()=>e.totalThreeObjects});exports.triangle=e.triangle;exports.updateCameraOrtho=e.updateCameraOrtho;exports.updateCameraOrtho16x9=e.updateCameraOrtho16x9;exports.useMask=e.useMask;exports.ElementProxy=o.ElementProxy;exports.WebworkerEventHandlers=o.WebworkerEventHandlers;exports.ElementProxyReceiver=n.ElementProxyReceiver;exports.ProxyManager=n.ProxyManager;exports.Application=l;exports.BaseRemote=c;exports.RemoteTheatre=u;exports.RemoteThree=p.default;exports.HermesApp=d;
package/dist/index.js CHANGED
@@ -1,73 +1,66 @@
1
1
  import { defaultTheatreCallback as t, noop as a } from "./core/types.js";
2
- import { detectMaxFrameRate as s, detectSettings as p } from "./utils/detectSettings.js";
3
- import { ImageSequenceCapturer as l } from "./utils/ImageSequenceCapturer.js";
4
- import { clamp as n, cubicBezier as c, damp as d, distance as x, getAngle as f, map as u, mix as M, normalize as T, rgbaToHex as b, roundTo as h } from "./utils/math.js";
5
- import { animateObjectMaterial as g, animateObjectTransform as C, applyObjectMaterial as j, customizeTheatreElements as y, getObjectMaterialObject as B, getObjectMaterialProps as E, useStudio as P } from "./utils/theatre.js";
6
- import { ExportTexture as k, anchorGeometry as A, anchorGeometryTL as S, createMask as v, dispose as z, disposeMaterial as G, disposeTexture as H, hierarchyUUID as I, orthoCamera as L, parseModelLite as U, renderToTexture as q, resetThreeObjects as w, setMaterialBlendAdd as D, setMaterialBlendMultiply as F, setMaterialBlendNormal as N, setMaterialBlendScreen as W, supportsOffscreenCanvas as J, totalThreeObjects as K, triangle as Q, updateCameraOrtho as V, updateCameraOrtho16x9 as X, useMask as Y } from "./utils/three.js";
7
- import { clearComposerGroups as _, generateCubemap as $, inspectComposer as ee, inspectComposerPass as re } from "./utils/post.js";
8
- import { ElementProxy as ae, WebworkerEventHandlers as oe } from "./webworkers/EventHandling.js";
9
- import { ElementProxyReceiver as pe, ProxyManager as me } from "./webworkers/ProxyManager.js";
10
- import { default as ie } from "./core/Application.js";
11
- import { default as ce } from "./core/remote/BaseRemote.js";
12
- import { default as xe } from "./core/remote/RemoteTheatre.js";
13
- import { default as ue } from "./core/remote/RemoteThree.js";
14
- import { default as Te } from "./editor/HermesApp.js";
2
+ import { detectSettings as l } from "./utils/detectSettings.js";
3
+ import { ImageSequenceCapturer as m } from "./utils/ImageSequenceCapturer.js";
4
+ import { clamp as i, cubicBezier as n, damp as d, distance as c, getAngle as x, map as f, mix as u, normalize as M, rgbaToHex as T, roundTo as b } from "./utils/math.js";
5
+ import { animateObjectMaterial as O, animateObjectTransform as g, applyObjectMaterial as j, getObjectMaterialObject as y, getObjectMaterialProps as B, useStudio as C } from "./utils/theatre.js";
6
+ import { ExportTexture as A, anchorGeometry as E, anchorGeometryTL as P, createMask as R, dispose as S, disposeMaterial as v, disposeTexture as H, hierarchyUUID as z, orthoCamera as G, parseModelLite as I, renderToTexture as L, resetThreeObjects as U, setMaterialBlendAdd as q, setMaterialBlendMultiply as w, setMaterialBlendNormal as D, setMaterialBlendScreen as N, supportsOffscreenCanvas as W, totalThreeObjects as F, triangle as J, updateCameraOrtho as K, updateCameraOrtho16x9 as Q, useMask as V } from "./utils/three.js";
7
+ import { ElementProxy as Y, WebworkerEventHandlers as Z } from "./webworkers/EventHandling.js";
8
+ import { ElementProxyReceiver as $, ProxyManager as ee } from "./webworkers/ProxyManager.js";
9
+ import { default as te } from "./core/Application.js";
10
+ import { default as oe } from "./core/remote/BaseRemote.js";
11
+ import { default as pe } from "./core/remote/RemoteTheatre.js";
12
+ import { default as se } from "./core/remote/RemoteThree.js";
13
+ import { default as ne } from "./editor/HermesApp.js";
15
14
  export {
16
- ie as Application,
17
- ce as BaseRemote,
18
- ae as ElementProxy,
19
- pe as ElementProxyReceiver,
20
- k as ExportTexture,
21
- Te as HermesApp,
22
- l as ImageSequenceCapturer,
23
- me as ProxyManager,
24
- xe as RemoteTheatre,
25
- ue as RemoteThree,
26
- oe as WebworkerEventHandlers,
27
- A as anchorGeometry,
28
- S as anchorGeometryTL,
29
- g as animateObjectMaterial,
30
- C as animateObjectTransform,
15
+ te as Application,
16
+ oe as BaseRemote,
17
+ Y as ElementProxy,
18
+ $ as ElementProxyReceiver,
19
+ A as ExportTexture,
20
+ ne as HermesApp,
21
+ m as ImageSequenceCapturer,
22
+ ee as ProxyManager,
23
+ pe as RemoteTheatre,
24
+ se as RemoteThree,
25
+ Z as WebworkerEventHandlers,
26
+ E as anchorGeometry,
27
+ P as anchorGeometryTL,
28
+ O as animateObjectMaterial,
29
+ g as animateObjectTransform,
31
30
  j as applyObjectMaterial,
32
- n as clamp,
33
- _ as clearComposerGroups,
34
- v as createMask,
35
- c as cubicBezier,
36
- y as customizeTheatreElements,
31
+ i as clamp,
32
+ R as createMask,
33
+ n as cubicBezier,
37
34
  d as damp,
38
35
  t as defaultTheatreCallback,
39
- s as detectMaxFrameRate,
40
- p as detectSettings,
41
- z as dispose,
42
- G as disposeMaterial,
36
+ l as detectSettings,
37
+ S as dispose,
38
+ v as disposeMaterial,
43
39
  H as disposeTexture,
44
- x as distance,
45
- $ as generateCubemap,
46
- f as getAngle,
47
- B as getObjectMaterialObject,
48
- E as getObjectMaterialProps,
49
- I as hierarchyUUID,
50
- ee as inspectComposer,
51
- re as inspectComposerPass,
52
- u as map,
53
- M as mix,
40
+ c as distance,
41
+ x as getAngle,
42
+ y as getObjectMaterialObject,
43
+ B as getObjectMaterialProps,
44
+ z as hierarchyUUID,
45
+ f as map,
46
+ u as mix,
54
47
  a as noop,
55
- T as normalize,
56
- L as orthoCamera,
57
- U as parseModelLite,
58
- q as renderToTexture,
59
- w as resetThreeObjects,
60
- b as rgbaToHex,
61
- h as roundTo,
62
- D as setMaterialBlendAdd,
63
- F as setMaterialBlendMultiply,
64
- N as setMaterialBlendNormal,
65
- W as setMaterialBlendScreen,
66
- J as supportsOffscreenCanvas,
67
- K as totalThreeObjects,
68
- Q as triangle,
69
- V as updateCameraOrtho,
70
- X as updateCameraOrtho16x9,
71
- Y as useMask,
72
- P as useStudio
48
+ M as normalize,
49
+ G as orthoCamera,
50
+ I as parseModelLite,
51
+ L as renderToTexture,
52
+ U as resetThreeObjects,
53
+ T as rgbaToHex,
54
+ b as roundTo,
55
+ q as setMaterialBlendAdd,
56
+ w as setMaterialBlendMultiply,
57
+ D as setMaterialBlendNormal,
58
+ N as setMaterialBlendScreen,
59
+ W as supportsOffscreenCanvas,
60
+ F as totalThreeObjects,
61
+ J as triangle,
62
+ K as updateCameraOrtho,
63
+ Q as updateCameraOrtho16x9,
64
+ V as useMask,
65
+ C as useStudio
73
66
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("detect-gpu");function f(s){let n=0;const i=performance.now();function e(){n++;const t=performance.now();if(t-i>=100){const o=n/((t-i)/1e3),c=Math.round(o/30)*30;s(c)}else requestAnimationFrame(e)}requestAnimationFrame(e)}function m(s=!1,n=!1){return new Promise(i=>{u.getGPUTier().then(e=>{let t=!1;const o=document.createElement("canvas"),c=/^((?!chrome|android).)*safari/i.test(navigator.userAgent);if(t="transferControlToOffscreen"in o,c){const a=navigator.userAgent.match(/version\/(\d+)/i);t=(a?parseInt(a[1]):0)>=17}const r={dpr:devicePixelRatio,fps:30,width:innerWidth,height:innerHeight,mobile:e.isMobile!==void 0?e.isMobile:!1,supportOffScreenCanvas:t,supportWebGPU:!!navigator.gpu,quality:"Low",dev:s,editor:n};e.tier===3?r.quality="High":e.tier===2&&(r.quality="Medium"),f(a=>{r.fps=a,i(r)})})})}exports.detectMaxFrameRate=f;exports.detectSettings=m;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("detect-gpu");function l(s=!1,r=!1){return new Promise(a=>{f.getGPUTier().then(e=>{let t=!1;const o=document.createElement("canvas"),c=/^((?!chrome|android).)*safari/i.test(navigator.userAgent);if(t="transferControlToOffscreen"in o,c){const n=navigator.userAgent.match(/version\/(\d+)/i);t=(n?parseInt(n[1]):0)>=17}const i={dpr:devicePixelRatio,width:innerWidth,height:innerHeight,mobile:e.isMobile!==void 0?e.isMobile:!1,supportOffScreenCanvas:t,supportWebGPU:!!navigator.gpu,quality:"Low",dev:s,editor:r};e.tier===3?i.quality="High":e.tier===2&&(i.quality="Medium"),a(i)})})}exports.detectSettings=l;
@@ -1,46 +1,28 @@
1
1
  import { getGPUTier as c } from "detect-gpu";
2
- function m(o) {
3
- let n = 0;
4
- const i = performance.now();
5
- function e() {
6
- n++;
7
- const t = performance.now();
8
- if (t - i >= 100) {
9
- const s = n / ((t - i) / 1e3), f = Math.round(s / 30) * 30;
10
- o(f);
11
- } else
12
- requestAnimationFrame(e);
13
- }
14
- requestAnimationFrame(e);
15
- }
16
- function d(o = !1, n = !1) {
17
- return new Promise((i) => {
2
+ function h(s = !1, r = !1) {
3
+ return new Promise((a) => {
18
4
  c().then((e) => {
19
5
  let t = !1;
20
- const s = document.createElement("canvas"), f = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
21
- if (t = "transferControlToOffscreen" in s, f) {
22
- const a = navigator.userAgent.match(/version\/(\d+)/i);
23
- t = (a ? parseInt(a[1]) : 0) >= 17;
6
+ const o = document.createElement("canvas"), f = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
7
+ if (t = "transferControlToOffscreen" in o, f) {
8
+ const n = navigator.userAgent.match(/version\/(\d+)/i);
9
+ t = (n ? parseInt(n[1]) : 0) >= 17;
24
10
  }
25
- const r = {
11
+ const i = {
26
12
  dpr: devicePixelRatio,
27
- fps: 30,
28
13
  width: innerWidth,
29
14
  height: innerHeight,
30
15
  mobile: e.isMobile !== void 0 ? e.isMobile : !1,
31
16
  supportOffScreenCanvas: t,
32
17
  supportWebGPU: !!navigator.gpu,
33
18
  quality: "Low",
34
- dev: o,
35
- editor: n
19
+ dev: s,
20
+ editor: r
36
21
  };
37
- e.tier === 3 ? r.quality = "High" : e.tier === 2 && (r.quality = "Medium"), m((a) => {
38
- r.fps = a, i(r);
39
- });
22
+ e.tier === 3 ? i.quality = "High" : e.tier === 2 && (i.quality = "Medium"), a(i);
40
23
  });
41
24
  });
42
25
  }
43
26
  export {
44
- m as detectMaxFrameRate,
45
- d as detectSettings
27
+ h as detectSettings
46
28
  };
@@ -1 +1 @@
1
- "use strict";var g=Object.create;var b=Object.defineProperty;var O=Object.getOwnPropertyDescriptor;var M=Object.getOwnPropertyNames;var w=Object.getPrototypeOf,v=Object.prototype.hasOwnProperty;var A=(n,i,e,s)=>{if(i&&typeof i=="object"||typeof i=="function")for(let t of M(i))!v.call(n,t)&&t!==e&&b(n,t,{get:()=>i[t],enumerable:!(s=O(i,t))||s.enumerable});return n};var E=(n,i,e)=>(e=n!=null?g(w(n)):{},A(i||!n||!n.__esModule?b(e,"default",{value:n,enumerable:!0}):e,n));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("@tomorrowevening/theatre-core"),y=require("react");let u;function P(){const[n,i]=y.useState(u);return y.useEffect(()=>{u||import("@tomorrowevening/theatre-studio").then(e=>{u=e.default,u.initialize(),u.ui.hide(),i(u)})},[]),n}async function T(){for(;!document.getElementById("theatrejs-studio-root");)await new Promise(s=>setTimeout(s,100));const n=document.getElementById("theatrejs-studio-root");if(n===null||n.shadowRoot===null)return;const i=n.shadowRoot.getElementById("pointer-root");if(i===null)return;const e=i.children[0];if(e!==null){try{const t=e.children[1].children[1];t.parentElement?.removeChild(t)}catch{}try{const s=e.children[3];s.style.top="0",s.style.right="300px"}catch{}}}function k(n,i,e,s){s.sheetObject(n,i,{transform:{position:{x:e.position.x,y:e.position.y,z:e.position.z},rotation:{x:e.rotation.x,y:e.rotation.y,z:e.rotation.z},scale:{x:e.scale.x,y:e.scale.y,z:e.scale.z},visible:e.visible}},t=>{const a=t.transform;e.position.copy(a.position),e.rotation.copy(a.rotation),e.scale.copy(a.scale),e.visible=a.visible})}const z=["allowOverride","alphaHash","alphaTest","alphaToCoverage","blendAlpha","blendColor","blendDst","blendDstAlpha","blendEquation","blendEquationAlpha","blendSrc","blendSrcAlpha","blending","clipIntersection","clipShadows","clipping","clippingPlanes","colorWrite","combine","defaultAttributeValues","defines","depthFunc","depthTest","depthWrite","dithering","extensions","fog","forceSinglePass","fragmentShader","glslVersion","id","index0AttributeName","index1AttributeName","index2AttributeName","index3AttributeName","index4AttributeName","isMaterial","lights","linewidth","name","needsUpdate","polygonOffset","polygonOffsetFactor","polygonOffsetUnits","precision","premultipliedAlpha","shadowSide","side","stencilFail","stencilFunc","stencilFuncMask","stencilRef","stencilWrite","stencilWriteMask","stencilZFail","stencilZPass","toneMapped","transparent","type","uniformsGroups","uniformsNeedUpdate","userData","uuid","version","vertexColors","vertexShader","visible","wireframe","wireframeLinewidth","wireframeLinecap","wireframeLinejoin"];function f(n){const i=typeof n;if(n===null||n.isTexture)return"texture";if(i==="boolean")return"boolean";if(i==="number")return"number";if(i==="string")return"string";if(i==="object"){if(n.isColor)return"color";if(n.isVector2)return"vector2";if(n.isVector3)return"vector3";if(n.isVector4)return"vector4";if(n.isMatrix2)return"matrix2";if(n.isMatrix3)return"matrix3";if(n.isMatrix4)return"matrix4";if(n.isEuler)return"euler";if(Array.isArray(n))return"array"}return"object"}function d(n){const i=[];for(const s in n){const t=z.find(o=>o===s),a=s.indexOf("_")===0||s.indexOf("is")===0;if(!(t||a))if(s==="uniforms"){const o=n.uniforms;for(const c in o){const p=o[c].value,m=f(p);m==="array"||m==="object"||i.push({name:`uniforms.${c}.value`,type:m,value:p})}}else{const o=f(n[s]);i.push({name:s,type:o,value:n[s]})}}return i.filter(s=>s.type!=="array"&&s.type!=="object"&&s.type!=="texture")}function h(n){const i={},e={nudgeMultiplier:.01};return n.forEach(s=>{let t=s.value;switch(s.type){case"color":t=r.types.rgba({r:t.r,g:t.g,b:t.b,a:1});break;case"number":t=r.types.number(t,e);break;case"euler":case"vector3":t={x:r.types.number(t.x,e),y:r.types.number(t.y,e),z:r.types.number(t.z,e)};break;case"vector2":t={x:r.types.number(t.x,e),y:r.types.number(t.y,e)};break;case"vector4":t={x:r.types.number(t.x,e),y:r.types.number(t.y,e),z:r.types.number(t.z,e),w:r.types.number(t.w,e)};break;case"matrix2":t={0:r.types.number(t.elements[0],e),1:r.types.number(t.elements[1],e),2:r.types.number(t.elements[2],e),3:r.types.number(t.elements[3],e)};break;case"matrix3":t={0:r.types.number(t.elements[0],e),1:r.types.number(t.elements[1],e),2:r.types.number(t.elements[2],e),3:r.types.number(t.elements[3],e),4:r.types.number(t.elements[4],e),5:r.types.number(t.elements[5],e),6:r.types.number(t.elements[6],e),7:r.types.number(t.elements[7],e),8:r.types.number(t.elements[8],e)};break;case"matrix4":t={0:r.types.number(t.elements[0],e),1:r.types.number(t.elements[1],e),2:r.types.number(t.elements[2],e),3:r.types.number(t.elements[3],e),4:r.types.number(t.elements[4],e),5:r.types.number(t.elements[5],e),6:r.types.number(t.elements[6],e),7:r.types.number(t.elements[7],e),8:r.types.number(t.elements[8],e),9:r.types.number(t.elements[9],e),10:r.types.number(t.elements[10],e),11:r.types.number(t.elements[11],e),12:r.types.number(t.elements[12],e),13:r.types.number(t.elements[13],e),14:r.types.number(t.elements[14],e),15:r.types.number(t.elements[15],e)};break}if(s.name.includes(".")){const a=s.name.split(".");let l=i;for(let o=0;o<a.length-1;o++){const c=a[o];l[c]||(l[c]={}),l=l[c]}l[a[a.length-1]]=t}else i[s.name]=t}),i}function x(n,i,e){i.forEach(s=>{if(n[s.name]!==void 0)switch(s.type){case"boolean":case"number":n[s.name]=e.material[s.name];break;case"color":case"euler":case"matrix2":case"matrix3":case"matrix4":case"vector2":case"vector3":case"vector4":n[s.name].copy(e.material[s.name]);break}})}function S(n,i,e,s){if(!e.isMaterial)return;const t=d(e),a=h(t);s.sheetObject(n,i,{material:a},l=>{x(e,t,l)})}exports.animateObjectMaterial=S;exports.animateObjectTransform=k;exports.applyObjectMaterial=x;exports.customizeTheatreElements=T;exports.getObjectMaterialObject=h;exports.getObjectMaterialProps=d;exports.useStudio=P;
1
+ "use strict";var g=Object.create;var b=Object.defineProperty;var O=Object.getOwnPropertyDescriptor;var M=Object.getOwnPropertyNames;var A=Object.getPrototypeOf,v=Object.prototype.hasOwnProperty;var P=(n,i,e,s)=>{if(i&&typeof i=="object"||typeof i=="function")for(let t of M(i))!v.call(n,t)&&t!==e&&b(n,t,{get:()=>i[t],enumerable:!(s=O(i,t))||s.enumerable});return n};var k=(n,i,e)=>(e=n!=null?g(A(n)):{},P(i||!n||!n.__esModule?b(e,"default",{value:n,enumerable:!0}):e,n));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("@tomorrowevening/theatre-core"),y=require("react");let m;function w(){const[n,i]=y.useState(m);return y.useEffect(()=>{m||import("@tomorrowevening/theatre-studio").then(e=>{m=e.default,m.initialize(),m.ui.hide(),i(m)})},[]),n}function S(n,i,e,s){s.sheetObject(n,i,{transform:{position:{x:e.position.x,y:e.position.y,z:e.position.z},rotation:{x:e.rotation.x,y:e.rotation.y,z:e.rotation.z},scale:{x:e.scale.x,y:e.scale.y,z:e.scale.z},visible:e.visible}},t=>{const a=t.transform;e.position.copy(a.position),e.rotation.copy(a.rotation),e.scale.copy(a.scale),e.visible=a.visible})}const z=["allowOverride","alphaHash","alphaTest","alphaToCoverage","blendAlpha","blendColor","blendDst","blendDstAlpha","blendEquation","blendEquationAlpha","blendSrc","blendSrcAlpha","blending","clipIntersection","clipShadows","clipping","clippingPlanes","colorWrite","combine","defaultAttributeValues","defines","depthFunc","depthTest","depthWrite","dithering","extensions","fog","forceSinglePass","fragmentShader","glslVersion","id","index0AttributeName","index1AttributeName","index2AttributeName","index3AttributeName","index4AttributeName","isMaterial","lights","linewidth","name","needsUpdate","polygonOffset","polygonOffsetFactor","polygonOffsetUnits","precision","premultipliedAlpha","shadowSide","side","stencilFail","stencilFunc","stencilFuncMask","stencilRef","stencilWrite","stencilWriteMask","stencilZFail","stencilZPass","toneMapped","transparent","type","uniformsGroups","uniformsNeedUpdate","userData","uuid","version","vertexColors","vertexShader","visible","wireframe","wireframeLinewidth","wireframeLinecap","wireframeLinejoin"];function f(n){const i=typeof n;if(n===null||n.isTexture)return"texture";if(i==="boolean")return"boolean";if(i==="number")return"number";if(i==="string")return"string";if(i==="object"){if(n.isColor)return"color";if(n.isVector2)return"vector2";if(n.isVector3)return"vector3";if(n.isVector4)return"vector4";if(n.isMatrix2)return"matrix2";if(n.isMatrix3)return"matrix3";if(n.isMatrix4)return"matrix4";if(n.isEuler)return"euler";if(Array.isArray(n))return"array"}return"object"}function d(n){const i=[];for(const s in n){const t=z.find(o=>o===s),a=s.indexOf("_")===0||s.indexOf("is")===0;if(!(t||a))if(s==="uniforms"){const o=n.uniforms;for(const c in o){const p=o[c].value,u=f(p);u==="array"||u==="object"||i.push({name:`uniforms.${c}.value`,type:u,value:p})}}else{const o=f(n[s]);i.push({name:s,type:o,value:n[s]})}}return i.filter(s=>s.type!=="array"&&s.type!=="object"&&s.type!=="texture")}function x(n){const i={},e={nudgeMultiplier:.01};return n.forEach(s=>{let t=s.value;switch(s.type){case"color":t=r.types.rgba({r:t.r,g:t.g,b:t.b,a:1});break;case"number":t=r.types.number(t,e);break;case"euler":case"vector3":t={x:r.types.number(t.x,e),y:r.types.number(t.y,e),z:r.types.number(t.z,e)};break;case"vector2":t={x:r.types.number(t.x,e),y:r.types.number(t.y,e)};break;case"vector4":t={x:r.types.number(t.x,e),y:r.types.number(t.y,e),z:r.types.number(t.z,e),w:r.types.number(t.w,e)};break;case"matrix2":t={0:r.types.number(t.elements[0],e),1:r.types.number(t.elements[1],e),2:r.types.number(t.elements[2],e),3:r.types.number(t.elements[3],e)};break;case"matrix3":t={0:r.types.number(t.elements[0],e),1:r.types.number(t.elements[1],e),2:r.types.number(t.elements[2],e),3:r.types.number(t.elements[3],e),4:r.types.number(t.elements[4],e),5:r.types.number(t.elements[5],e),6:r.types.number(t.elements[6],e),7:r.types.number(t.elements[7],e),8:r.types.number(t.elements[8],e)};break;case"matrix4":t={0:r.types.number(t.elements[0],e),1:r.types.number(t.elements[1],e),2:r.types.number(t.elements[2],e),3:r.types.number(t.elements[3],e),4:r.types.number(t.elements[4],e),5:r.types.number(t.elements[5],e),6:r.types.number(t.elements[6],e),7:r.types.number(t.elements[7],e),8:r.types.number(t.elements[8],e),9:r.types.number(t.elements[9],e),10:r.types.number(t.elements[10],e),11:r.types.number(t.elements[11],e),12:r.types.number(t.elements[12],e),13:r.types.number(t.elements[13],e),14:r.types.number(t.elements[14],e),15:r.types.number(t.elements[15],e)};break}if(s.name.includes(".")){const a=s.name.split(".");let l=i;for(let o=0;o<a.length-1;o++){const c=a[o];l[c]||(l[c]={}),l=l[c]}l[a[a.length-1]]=t}else i[s.name]=t}),i}function h(n,i,e){i.forEach(s=>{if(n[s.name]!==void 0)switch(s.type){case"boolean":case"number":n[s.name]=e.material[s.name];break;case"color":case"euler":case"matrix2":case"matrix3":case"matrix4":case"vector2":case"vector3":case"vector4":n[s.name].copy(e.material[s.name]);break}})}function T(n,i,e,s){if(!e.isMaterial)return;const t=d(e),a=x(t);s.sheetObject(n,i,{material:a},l=>{h(e,t,l)})}exports.animateObjectMaterial=T;exports.animateObjectTransform=S;exports.applyObjectMaterial=h;exports.getObjectMaterialObject=x;exports.getObjectMaterialProps=d;exports.useStudio=w;
@@ -1,37 +1,16 @@
1
1
  import { types as n } from "@tomorrowevening/theatre-core";
2
2
  import { useState as d, useEffect as p } from "react";
3
- let m;
3
+ let c;
4
4
  function v() {
5
- const [i, s] = d(m);
5
+ const [r, s] = d(c);
6
6
  return p(() => {
7
- m || import("@tomorrowevening/theatre-studio").then((e) => {
8
- m = e.default, m.initialize(), m.ui.hide(), s(m);
7
+ c || import("@tomorrowevening/theatre-studio").then((e) => {
8
+ c = e.default, c.initialize(), c.ui.hide(), s(c);
9
9
  });
10
- }, []), i;
10
+ }, []), r;
11
11
  }
12
- async function E() {
13
- for (; !document.getElementById("theatrejs-studio-root"); )
14
- await new Promise((r) => setTimeout(r, 100));
15
- const i = document.getElementById("theatrejs-studio-root");
16
- if (i === null || i.shadowRoot === null) return;
17
- const s = i.shadowRoot.getElementById("pointer-root");
18
- if (s === null) return;
19
- const e = s.children[0];
20
- if (e !== null) {
21
- try {
22
- const t = e.children[1].children[1];
23
- t.parentElement?.removeChild(t);
24
- } catch {
25
- }
26
- try {
27
- const r = e.children[3];
28
- r.style.top = "0", r.style.right = "300px";
29
- } catch {
30
- }
31
- }
32
- }
33
- function O(i, s, e, r) {
34
- r.sheetObject(i, s, {
12
+ function M(r, s, e, i) {
13
+ i.sheetObject(r, s, {
35
14
  transform: {
36
15
  position: {
37
16
  x: e.position.x,
@@ -51,11 +30,11 @@ function O(i, s, e, r) {
51
30
  visible: e.visible
52
31
  }
53
32
  }, (t) => {
54
- const o = t.transform;
55
- e.position.copy(o.position), e.rotation.copy(o.rotation), e.scale.copy(o.scale), e.visible = o.visible;
33
+ const a = t.transform;
34
+ e.position.copy(a.position), e.rotation.copy(a.rotation), e.scale.copy(a.scale), e.visible = a.visible;
56
35
  });
57
36
  }
58
- const h = [
37
+ const x = [
59
38
  "allowOverride",
60
39
  "alphaHash",
61
40
  "alphaTest",
@@ -128,9 +107,9 @@ const h = [
128
107
  "wireframeLinecap",
129
108
  "wireframeLinejoin"
130
109
  ];
131
- function f(i) {
132
- const s = typeof i;
133
- if (i === null || i.isTexture)
110
+ function f(r) {
111
+ const s = typeof r;
112
+ if (r === null || r.isTexture)
134
113
  return "texture";
135
114
  if (s === "boolean")
136
115
  return "boolean";
@@ -139,60 +118,60 @@ function f(i) {
139
118
  if (s === "string")
140
119
  return "string";
141
120
  if (s === "object") {
142
- if (i.isColor)
121
+ if (r.isColor)
143
122
  return "color";
144
- if (i.isVector2)
123
+ if (r.isVector2)
145
124
  return "vector2";
146
- if (i.isVector3)
125
+ if (r.isVector3)
147
126
  return "vector3";
148
- if (i.isVector4)
127
+ if (r.isVector4)
149
128
  return "vector4";
150
- if (i.isMatrix2)
129
+ if (r.isMatrix2)
151
130
  return "matrix2";
152
- if (i.isMatrix3)
131
+ if (r.isMatrix3)
153
132
  return "matrix3";
154
- if (i.isMatrix4)
133
+ if (r.isMatrix4)
155
134
  return "matrix4";
156
- if (i.isEuler)
135
+ if (r.isEuler)
157
136
  return "euler";
158
- if (Array.isArray(i))
137
+ if (Array.isArray(r))
159
138
  return "array";
160
139
  }
161
140
  return "object";
162
141
  }
163
- function y(i) {
142
+ function y(r) {
164
143
  const s = [];
165
- for (const r in i) {
166
- const t = h.find((a) => a === r), o = r.indexOf("_") === 0 || r.indexOf("is") === 0;
167
- if (!(t || o))
168
- if (r === "uniforms") {
169
- const a = i.uniforms;
170
- for (const c in a) {
171
- const b = a[c].value, u = f(b);
144
+ for (const i in r) {
145
+ const t = x.find((o) => o === i), a = i.indexOf("_") === 0 || i.indexOf("is") === 0;
146
+ if (!(t || a))
147
+ if (i === "uniforms") {
148
+ const o = r.uniforms;
149
+ for (const m in o) {
150
+ const b = o[m].value, u = f(b);
172
151
  u === "array" || u === "object" || s.push({
173
- name: `uniforms.${c}.value`,
152
+ name: `uniforms.${m}.value`,
174
153
  type: u,
175
154
  value: b
176
155
  });
177
156
  }
178
157
  } else {
179
- const a = f(i[r]);
158
+ const o = f(r[i]);
180
159
  s.push({
181
- name: r,
182
- type: a,
183
- value: i[r]
160
+ name: i,
161
+ type: o,
162
+ value: r[i]
184
163
  });
185
164
  }
186
165
  }
187
166
  return s.filter(
188
- (r) => r.type !== "array" && r.type !== "object" && r.type !== "texture"
167
+ (i) => i.type !== "array" && i.type !== "object" && i.type !== "texture"
189
168
  );
190
169
  }
191
- function x(i) {
170
+ function h(r) {
192
171
  const s = {}, e = { nudgeMultiplier: 0.01 };
193
- return i.forEach((r) => {
194
- let t = r.value;
195
- switch (r.type) {
172
+ return r.forEach((i) => {
173
+ let t = i.value;
174
+ switch (i.type) {
196
175
  case "color":
197
176
  t = n.rgba({ r: t.r, g: t.g, b: t.b, a: 1 });
198
177
  break;
@@ -263,25 +242,25 @@ function x(i) {
263
242
  };
264
243
  break;
265
244
  }
266
- if (r.name.includes(".")) {
267
- const o = r.name.split(".");
245
+ if (i.name.includes(".")) {
246
+ const a = i.name.split(".");
268
247
  let l = s;
269
- for (let a = 0; a < o.length - 1; a++) {
270
- const c = o[a];
271
- l[c] || (l[c] = {}), l = l[c];
248
+ for (let o = 0; o < a.length - 1; o++) {
249
+ const m = a[o];
250
+ l[m] || (l[m] = {}), l = l[m];
272
251
  }
273
- l[o[o.length - 1]] = t;
252
+ l[a[a.length - 1]] = t;
274
253
  } else
275
- s[r.name] = t;
254
+ s[i.name] = t;
276
255
  }), s;
277
256
  }
278
- function g(i, s, e) {
279
- s.forEach((r) => {
280
- if (i[r.name] !== void 0)
281
- switch (r.type) {
257
+ function g(r, s, e) {
258
+ s.forEach((i) => {
259
+ if (r[i.name] !== void 0)
260
+ switch (i.type) {
282
261
  case "boolean":
283
262
  case "number":
284
- i[r.name] = e.material[r.name];
263
+ r[i.name] = e.material[i.name];
285
264
  break;
286
265
  case "color":
287
266
  case "euler":
@@ -291,26 +270,25 @@ function g(i, s, e) {
291
270
  case "vector2":
292
271
  case "vector3":
293
272
  case "vector4":
294
- i[r.name].copy(e.material[r.name]);
273
+ r[i.name].copy(e.material[i.name]);
295
274
  break;
296
275
  }
297
276
  });
298
277
  }
299
- function M(i, s, e, r) {
278
+ function k(r, s, e, i) {
300
279
  if (!e.isMaterial) return;
301
- const t = y(e), o = x(t);
302
- r.sheetObject(i, s, {
303
- material: o
280
+ const t = y(e), a = h(t);
281
+ i.sheetObject(r, s, {
282
+ material: a
304
283
  }, (l) => {
305
284
  g(e, t, l);
306
285
  });
307
286
  }
308
287
  export {
309
- M as animateObjectMaterial,
310
- O as animateObjectTransform,
288
+ k as animateObjectMaterial,
289
+ M as animateObjectTransform,
311
290
  g as applyObjectMaterial,
312
- E as customizeTheatreElements,
313
- x as getObjectMaterialObject,
291
+ h as getObjectMaterialObject,
314
292
  y as getObjectMaterialProps,
315
293
  v as useStudio
316
294
  };
package/package.json CHANGED
@@ -8,7 +8,7 @@
8
8
  "types": "./types/index.d.ts",
9
9
  "type": "module",
10
10
  "sideEffects": ["**/*.css"],
11
- "version": "0.1.43",
11
+ "version": "0.1.44",
12
12
  "homepage": "https://github.com/tomorrowevening/hermes#readme",
13
13
  "bugs": {
14
14
  "url": "https://github.com/tomorrowevening/hermes/issues"
@@ -33,7 +33,7 @@ export interface GroupCallback {
33
33
  export type ApplicationMode = 'app' | 'editor';
34
34
  export type VoidCallback = () => void;
35
35
  export type DataUpdateCallback = (data: any) => void;
36
- export type EditorEvent = 'custom' | 'setSheet' | 'setSheetObject' | 'updateSheetObject' | 'updateTimeline' | 'playSheet' | 'pauseSheet' | 'updateObject' | 'addScene' | 'refreshScene' | 'removeScene' | 'setScene' | 'createTexture' | 'addCamera' | 'removeCamera' | 'addSpline' | 'addRenderer' | 'updateRenderer' | 'requestSize' | 'requestRenderer' | 'requestScene' | 'addFolder' | 'bindObject' | 'updateBind' | 'addButton' | 'clickButton' | 'addGroup' | 'removeGroup' | 'updateGroup';
36
+ export type EditorEvent = 'custom' | 'createSheet' | 'setSheet' | 'createSheetObject' | 'setSheetObject' | 'updateSheetObject' | 'updateTimeline' | 'playSheet' | 'pauseSheet' | 'updateObject' | 'addScene' | 'refreshScene' | 'removeScene' | 'setScene' | 'createTexture' | 'addCamera' | 'removeCamera' | 'addSpline' | 'addRenderer' | 'updateRenderer' | 'requestSize' | 'requestRenderer' | 'requestScene' | 'addFolder' | 'bindObject' | 'updateBind' | 'addButton' | 'clickButton' | 'addGroup' | 'removeGroup' | 'updateGroup';
37
37
  export type VoidFunc = () => void;
38
38
  export type BroadcastCallback = (data: BroadcastData) => void;
39
39
  export type TheatreUpdateCallback = (data: any) => void;
package/types/index.d.ts CHANGED
@@ -4,7 +4,6 @@ export * from './utils/ImageSequenceCapturer';
4
4
  export * from './utils/math';
5
5
  export * from './utils/theatre';
6
6
  export * from './utils/three';
7
- export * from './utils/post';
8
7
  export * from './webworkers/types';
9
8
  export * from './webworkers/EventHandling';
10
9
  export * from './webworkers/ProxyManager';
@@ -1,7 +1,6 @@
1
1
  export type QualityType = 'High' | 'Medium' | 'Low';
2
2
  export type AppSettings = {
3
3
  dpr: number;
4
- fps: number;
5
4
  width: number;
6
5
  height: number;
7
6
  mobile: boolean;
@@ -11,5 +10,4 @@ export type AppSettings = {
11
10
  dev: boolean;
12
11
  editor: boolean;
13
12
  };
14
- export declare function detectMaxFrameRate(callback: (fps: number) => void): void;
15
13
  export declare function detectSettings(dev?: boolean, editor?: boolean): Promise<AppSettings>;
@@ -1,6 +1,5 @@
1
1
  import RemoteTheatre from '../core/remote/RemoteTheatre';
2
2
  export declare function useStudio(): any;
3
- export declare function customizeTheatreElements(): Promise<void>;
4
3
  export declare function animateObjectTransform(sheet: string, key: string, obj: any, theatre: RemoteTheatre): void;
5
4
  type PropType = 'array' | 'boolean' | 'color' | 'euler' | 'matrix2' | 'matrix3' | 'matrix4' | 'number' | 'object' | 'string' | 'texture' | 'vector2' | 'vector3' | 'vector4';
6
5
  type PropToAdd = {
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const y=require("three"),g=require("./three.cjs");let b=[];function x(s,n,a=!0){g.ExportTexture.renderer=n.renderer;const r=[];r.push({type:"boolean",prop:"Enabled",value:s.enabled});let f=(u,e)=>{console.log("Default Handle Pass:",u,e)};if(s.name==="EffectPass")s.effects.forEach(u=>{u.uniforms.size>0&&u.uniforms.forEach((e,o)=>{if(o==="map")return;const t=`${u.name.replace("Effect","")} ${o}`;if(e.value===null&&a)r.push({prop:o,title:t,type:"image",value:{offset:[0,0],repeat:[1,1],src:""}});else if(e.value.isTexture&&a){const p=e.value,i=g.ExportTexture.renderToBlob(p);r.push({prop:o,title:t,type:"image",value:{offset:[p.offset.x,p.offset.y],repeat:[p.repeat.x,p.repeat.y],src:i}})}else typeof e.value=="number"?r.push({prop:o,title:t,type:"number",value:e.value,step:.01}):typeof e.value=="string"?r.push({prop:o,title:t,type:"string",value:e.value}):typeof e.value=="boolean"&&r.push({prop:o,title:t,type:"boolean",value:e.value})})}),f=(u,e)=>{s.effects.forEach(o=>{o.uniforms.size>0&&o.uniforms.forEach((t,p)=>{p===u&&(t.value=e)})})};else if(s.name==="ShaderPass"){const u=s.fullscreenMaterial;for(const e in u.uniforms){if(e==="inputBuffer"||e==="map")continue;const o=u.uniforms[e],t=`${u.name.replace("Material","")} ${e}`;if(o.value===null&&a)r.push({title:t,prop:e,type:"image",value:{offset:[0,0],repeat:[1,1],src:""}});else if(o.value.isTexture&&a){const p=o.value,i=g.ExportTexture.renderToBlob(p);r.push({title:t,prop:e,type:"image",value:{offset:[p.offset.x,p.offset.y],repeat:[p.repeat.x,p.repeat.y],src:i}})}else typeof o.value=="number"?r.push({title:t,prop:e,type:"number",value:o.value,step:.01}):typeof o.value=="string"?r.push({title:t,prop:e,type:"string",value:o.value}):typeof o.value=="boolean"&&r.push({title:t,prop:e,type:"boolean",value:o.value})}f=(e,o)=>{const t=u.uniforms[e];t.value=o}}else return;const l=`${s.name}: ${s.scene.name}`;n.addGroup({title:l,items:r,onUpdate:(u,e)=>{u==="Enabled"?s.enabled=e:f(u,e)}}),b.push(l)}function E(s,n){s.passes.forEach(a=>{x(a,n)})}function P(s){b.forEach(n=>{s.removeGroup(n)}),b=[]}function C(s,n,a,r=1024){return new Promise(f=>{const l=n.aspect,u=n.fov,e=n.rotation.clone(),o=a.outputBuffer;n.aspect=1,n.fov=90,n.updateProjectionMatrix();const t=new y.WebGLRenderTarget(r,r,{format:y.RGBAFormat,depthBuffer:!0,stencilBuffer:!1});a.outputBuffer=t,c(s,t,n,"nx",a,r).then(()=>{c(s,t,n,"ny",a,r).then(()=>{c(s,t,n,"nz",a,r).then(()=>{c(s,t,n,"px",a,r).then(()=>{c(s,t,n,"py",a,r).then(()=>{c(s,t,n,"pz",a,r).then(()=>{n.aspect=l,n.fov=u,n.rotation.copy(e),n.updateMatrixWorld(),n.updateProjectionMatrix(),a.outputBuffer=o,t.dispose(),f()})})})})})})})}function c(s,n,a,r,f,l){return new Promise(u=>{const e=Math.PI/2;switch(r){case"nx":a.rotation.set(0,-e,0);break;case"ny":a.rotation.set(-e,0,Math.PI);break;case"nz":a.rotation.set(0,0,0);break;case"px":a.rotation.set(0,e,0);break;case"py":a.rotation.set(e,0,Math.PI);break;case"pz":a.rotation.set(0,Math.PI,0);break}a.updateMatrixWorld(),f.render();const o=new Uint8Array(l*l*4);s.readRenderTargetPixels(n,0,0,l,l,o);const t=document.createElement("canvas");t.width=t.height=l;const p=t.getContext("2d"),i=p.createImageData(l,l);i.data.set(o),p.putImageData(i,0,0);const d=document.createElement("canvas");d.width=d.height=l;const h=d.getContext("2d");h.translate(0,l),h.scale(1,-1),h.drawImage(t,0,0);const m=d.toDataURL("image/png"),v=document.createElement("a");v.href=m,v.download=`${a.name}_${r}.png`,document.body.appendChild(v),v.click(),v.remove(),u()})}exports.clearComposerGroups=P;exports.generateCubemap=C;exports.inspectComposer=E;exports.inspectComposerPass=x;
@@ -1,206 +0,0 @@
1
- import { WebGLRenderTarget as x, RGBAFormat as m } from "three";
2
- import { ExportTexture as g } from "./three.js";
3
- let b = [];
4
- function E(r, n, a = !0) {
5
- g.renderer = n.renderer;
6
- const p = [];
7
- p.push({
8
- type: "boolean",
9
- prop: "Enabled",
10
- value: r.enabled
11
- });
12
- let f = (u, e) => {
13
- console.log("Default Handle Pass:", u, e);
14
- };
15
- if (r.name === "EffectPass")
16
- r.effects.forEach((u) => {
17
- u.uniforms.size > 0 && u.uniforms.forEach((e, o) => {
18
- if (o === "map") return;
19
- const t = `${u.name.replace("Effect", "")} ${o}`;
20
- if (e.value === null && a)
21
- p.push({
22
- prop: o,
23
- title: t,
24
- type: "image",
25
- value: {
26
- offset: [0, 0],
27
- repeat: [1, 1],
28
- src: ""
29
- }
30
- });
31
- else if (e.value.isTexture && a) {
32
- const s = e.value, i = g.renderToBlob(s);
33
- p.push({
34
- prop: o,
35
- title: t,
36
- type: "image",
37
- value: {
38
- offset: [s.offset.x, s.offset.y],
39
- repeat: [s.repeat.x, s.repeat.y],
40
- src: i
41
- }
42
- });
43
- } else typeof e.value == "number" ? p.push({
44
- prop: o,
45
- title: t,
46
- type: "number",
47
- value: e.value,
48
- step: 0.01
49
- }) : typeof e.value == "string" ? p.push({
50
- prop: o,
51
- title: t,
52
- type: "string",
53
- value: e.value
54
- }) : typeof e.value == "boolean" && p.push({
55
- prop: o,
56
- title: t,
57
- type: "boolean",
58
- value: e.value
59
- });
60
- });
61
- }), f = (u, e) => {
62
- r.effects.forEach((o) => {
63
- o.uniforms.size > 0 && o.uniforms.forEach((t, s) => {
64
- s === u && (t.value = e);
65
- });
66
- });
67
- };
68
- else if (r.name === "ShaderPass") {
69
- const u = r.fullscreenMaterial;
70
- for (const e in u.uniforms) {
71
- if (e === "inputBuffer" || e === "map") continue;
72
- const o = u.uniforms[e], t = `${u.name.replace("Material", "")} ${e}`;
73
- if (o.value === null && a)
74
- p.push({
75
- title: t,
76
- prop: e,
77
- type: "image",
78
- value: {
79
- offset: [0, 0],
80
- repeat: [1, 1],
81
- src: ""
82
- }
83
- });
84
- else if (o.value.isTexture && a) {
85
- const s = o.value, i = g.renderToBlob(s);
86
- p.push({
87
- title: t,
88
- prop: e,
89
- type: "image",
90
- value: {
91
- offset: [s.offset.x, s.offset.y],
92
- repeat: [s.repeat.x, s.repeat.y],
93
- src: i
94
- }
95
- });
96
- } else typeof o.value == "number" ? p.push({
97
- title: t,
98
- prop: e,
99
- type: "number",
100
- value: o.value,
101
- step: 0.01
102
- }) : typeof o.value == "string" ? p.push({
103
- title: t,
104
- prop: e,
105
- type: "string",
106
- value: o.value
107
- }) : typeof o.value == "boolean" && p.push({
108
- title: t,
109
- prop: e,
110
- type: "boolean",
111
- value: o.value
112
- });
113
- }
114
- f = (e, o) => {
115
- const t = u.uniforms[e];
116
- t.value = o;
117
- };
118
- } else
119
- return;
120
- const l = `${r.name}: ${r.scene.name}`;
121
- n.addGroup({
122
- title: l,
123
- items: p,
124
- onUpdate: (u, e) => {
125
- u === "Enabled" ? r.enabled = e : f(u, e);
126
- }
127
- }), b.push(l);
128
- }
129
- function M(r, n) {
130
- r.passes.forEach((a) => {
131
- E(a, n);
132
- });
133
- }
134
- function B(r) {
135
- b.forEach((n) => {
136
- r.removeGroup(n);
137
- }), b = [];
138
- }
139
- function C(r, n, a, p = 1024) {
140
- return new Promise((f) => {
141
- const l = n.aspect, u = n.fov, e = n.rotation.clone(), o = a.outputBuffer;
142
- n.aspect = 1, n.fov = 90, n.updateProjectionMatrix();
143
- const t = new x(p, p, {
144
- format: m,
145
- depthBuffer: !0,
146
- stencilBuffer: !1
147
- });
148
- a.outputBuffer = t, c(r, t, n, "nx", a, p).then(() => {
149
- c(r, t, n, "ny", a, p).then(() => {
150
- c(r, t, n, "nz", a, p).then(() => {
151
- c(r, t, n, "px", a, p).then(() => {
152
- c(r, t, n, "py", a, p).then(() => {
153
- c(r, t, n, "pz", a, p).then(() => {
154
- n.aspect = l, n.fov = u, n.rotation.copy(e), n.updateMatrixWorld(), n.updateProjectionMatrix(), a.outputBuffer = o, t.dispose(), f();
155
- });
156
- });
157
- });
158
- });
159
- });
160
- });
161
- });
162
- }
163
- function c(r, n, a, p, f, l) {
164
- return new Promise((u) => {
165
- const e = Math.PI / 2;
166
- switch (p) {
167
- case "nx":
168
- a.rotation.set(0, -e, 0);
169
- break;
170
- case "ny":
171
- a.rotation.set(-e, 0, Math.PI);
172
- break;
173
- case "nz":
174
- a.rotation.set(0, 0, 0);
175
- break;
176
- case "px":
177
- a.rotation.set(0, e, 0);
178
- break;
179
- case "py":
180
- a.rotation.set(e, 0, Math.PI);
181
- break;
182
- case "pz":
183
- a.rotation.set(0, Math.PI, 0);
184
- break;
185
- }
186
- a.updateMatrixWorld(), f.render();
187
- const o = new Uint8Array(l * l * 4);
188
- r.readRenderTargetPixels(n, 0, 0, l, l, o);
189
- const t = document.createElement("canvas");
190
- t.width = t.height = l;
191
- const s = t.getContext("2d"), i = s.createImageData(l, l);
192
- i.data.set(o), s.putImageData(i, 0, 0);
193
- const d = document.createElement("canvas");
194
- d.width = d.height = l;
195
- const h = d.getContext("2d");
196
- h.translate(0, l), h.scale(1, -1), h.drawImage(t, 0, 0);
197
- const y = d.toDataURL("image/png"), v = document.createElement("a");
198
- v.href = y, v.download = `${a.name}_${p}.png`, document.body.appendChild(v), v.click(), v.remove(), u();
199
- });
200
- }
201
- export {
202
- B as clearComposerGroups,
203
- C as generateCubemap,
204
- M as inspectComposer,
205
- E as inspectComposerPass
206
- };