@tomorrowevening/hermes 0.0.92 → 0.0.93
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/hermes.cjs.js +1 -1
- package/dist/hermes.es.js +1 -1
- package/package.json +1 -1
package/dist/hermes.cjs.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("three"),gn=require("tweakpane"),_n=require("@tweakpane/plugin-essentials"),T=require("react"),qi=require("framer-motion");function vn(i){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(i){for(const n in i)if(n!=="default"){const t=Object.getOwnPropertyDescriptor(i,n);Object.defineProperty(e,n,t.get?t:{enumerable:!0,get:()=>i[n]})}}return e.default=i,Object.freeze(e)}const yn=vn(_n),ni=()=>{},En=()=>{};function Nt(i){return i.substring(0,1).toUpperCase()+i.substring(1)}function ct(i,e,n){return Math.min(e,Math.max(i,n))}function vi(i,e,n){return(n-i)/(e-i)}function ei(i,e,n){return i*(1-n)+e*n}function bn(i,e){const n=i-e;return Math.sqrt(n*n)}function Ji(){return Math.round(Math.random()*1e6).toString()}function Qi(i){return i.r!==void 0&&i.g!==void 0&&i.b!==void 0}function yi(i){const e=Math.round(i.r*255),n=Math.round(i.g*255),t=Math.round(i.b*255),s=h=>{const c=h.toString(16);return c.length===1?"0"+c:c},a=s(e),o=s(n),r=s(t);return"#"+a+o+r}function Ei(i,e=1){return Number(i.toFixed(e))}exports.totalThreeObjects=0;const bi=()=>{exports.totalThreeObjects=0},ti=i=>{if(!i)return;let e=i.name.replaceAll(" ","").replaceAll("/",".");if(e.length===0&&(e=`obj_${exports.totalThreeObjects}`,exports.totalThreeObjects++),i.parent!==null&&i.parent.uuid.length>0&&(e=`${i.parent.uuid}.${e}`),i.uuid=e,i.isMesh!==void 0){const n=i;if(Array.isArray(n.material))n.material.forEach((t,s)=>{t.uuid=`${e}.material.${s}`});else{const t=n.material;t.uuid=`${e}.material`}}i.children.forEach(n=>ti(n))},On=i=>{i?.dispose()},en=i=>{i&&(Array.isArray(i)?i.forEach(e=>e.dispose()):i.dispose())},zt=i=>{if(i){for(;i.children.length>0;){const e=i.children[0];e.type==="Audio"?(e.pause(),e.parent&&e.parent.remove(e)):zt(e)}if(i.parent&&i.parent.remove(i),i.isMesh){const e=i;e.geometry?.dispose(),en(e.material)}i.dispose!==void 0&&i.dispose()}};class jt{static renderer;static canvas;static context=null;static scene=null;static camera=null;static material=null;static inited=!1;static width=100;static height=100;static init(){this.inited||(this.canvas=document.createElement("canvas"),this.canvas.width=this.width,this.canvas.height=this.height,this.context=this.canvas.getContext("2d"),this.inited=!0)}static renderToBlob(e){this.init();const n=e.repeat.clone(),t=e.offset.clone();if(e.repeat.set(1,1),e.offset.set(0,0),this.context!==null){this.context.clearRect(0,0,this.width,this.height);const s=e.image;if(s!=null&&s.width>0){this.canvas.title=e.sourceFile;const a=this.canvas.width/s.width,o=this.renderToCanvas(e);this.context.drawImage(o,0,0,s.width*a,s.height*a)}}return e.repeat.copy(n),e.offset.copy(t),this.canvas.toDataURL("image/png")}static renderToCanvas(e){if(this.material===null){this.camera=new p.OrthographicCamera(-.5,.5,.5,-.5,0,100),this.scene=new p.Scene,this.material=new p.MeshBasicMaterial;const n=new p.BufferGeometry;n.setAttribute("position",new p.Float32BufferAttribute([-.5,-.5,0,1.5,-.5,0,-.5,1.5,0],3)),n.setAttribute("normal",new p.Float32BufferAttribute([0,0,1,0,0,1],3)),n.setAttribute("uv",new p.Float32BufferAttribute([0,0,2,0,0,2],2));const t=new p.Mesh(n,this.material);this.scene.add(t)}if(e.isRenderTargetTexture)this.material.map=e,this.renderer.render(this.scene,this.camera);else{const n=this.renderer.outputColorSpace,t=e.colorSpace;this.renderer.outputColorSpace=p.LinearSRGBColorSpace,e.colorSpace=p.LinearSRGBColorSpace,this.material.map=e,this.renderer.render(this.scene,this.camera),this.renderer.outputColorSpace=n,e.colorSpace=t}return this.renderer.domElement}}class Cn{components=new Map;listen;_appID="";_debugEnabled;_broadcastChannel=void 0;_webSocket=void 0;_mode="app";_connected=!1;_useBC=!1;constructor(e,n,t=!0){this._appID=e,this._debugEnabled=n,n&&(this._useBC=t,t?(this._broadcastChannel=new BroadcastChannel(e),this._broadcastChannel.addEventListener("message",this.messageHandler)):(this._webSocket=new WebSocket(e),this._webSocket.addEventListener("open",this.openHandler),this._webSocket.addEventListener("close",this.closeHandler),this._webSocket.addEventListener("message",this.messageHandler)))}addComponent(e,n){this.components.set(e,n)}dispose(){this._broadcastChannel!==void 0&&this._broadcastChannel.removeEventListener("message",this.messageHandler),this._webSocket!==void 0&&(this._webSocket.removeEventListener("open",this.openHandler),this._webSocket.removeEventListener("close",this.closeHandler),this._webSocket.removeEventListener("message",this.messageHandler)),this.components.forEach(e=>{e.dispose()}),this.components.clear()}send(e){this._mode!==e.target&&(this._useBC?this._broadcastChannel?.postMessage(e):this._connected&&this._webSocket?.send(JSON.stringify(e)))}messageHandler=e=>{this.listen!==void 0&&(this._useBC?this.listen(e.data):this.listen(JSON.parse(e.data)))};openHandler=()=>{this._connected=!0};closeHandler=()=>{this._connected=!1};get appID(){return this._appID}get connected(){return this._connected}get debugEnabled(){return this._debugEnabled}get mode(){return this._mode}get isApp(){return this._mode==="app"}get editor(){return this._mode==="editor"}set editor(e){e&&(this._mode="editor")}}const z=new p.EventDispatcher,B={CUSTOM:"ToolEvents::custom",SELECT_DROPDOWN:"ToolEvents::selectDropdown",DRAG_UPDATE:"ToolEvents::dragUpdate",ADD_SCENE:"ToolEvents::addScene",REFRESH_SCENE:"ToolEvents::refreshScene",REMOVE_SCENE:"ToolEvents::removeScene",SET_SCENE:"ToolEvents::setScene",GET_OBJECT:"ToolEvents::getObject",SET_OBJECT:"ToolEvents::setObject",UPDATE_OBJECT:"ToolEvents::updateObject",CREATE_TEXTURE:"ToolEvents::createTexture",REQUEST_METHOD:"ToolEvents::requestMethod",ADD_CAMERA:"ToolEvents::addCamera",REMOVE_CAMERA:"ToolEvents::removeCamera",ADD_GROUP:"ToolEvents::addGroup",REMOVE_GROUP:"ToolEvents::removeGroup"};class Ht{app;constructor(e){this.app=e}dispose(){}handleApp(e,n,t){}handleEditor(e,n,t){}}class Tn extends Ht{selectDropdown(e,n){this.app.send({event:"selectComponent",target:"app",data:{dropdown:e,value:n}})}updateDropdown(e,n){this.app.send({event:"draggableListUpdate",target:"app",data:{dropdown:e,value:n}})}handleApp(e,n,t){switch(t.event){case"selectComponent":z.dispatchEvent({type:B.SELECT_DROPDOWN,value:t.data});break;case"draggableListUpdate":z.dispatchEvent({type:B.DRAG_UPDATE,value:t.data});break}}}class si extends Ht{project;sheets=new Map;sheetObjects=new Map;sheetObjectCBs=new Map;sheetObjectUnsubscribe=new Map;activeSheet;studio=void 0;static rafDriver=void 0;dispose(){this.project=void 0,this.sheets=new Map,this.sheetObjects=new Map,this.sheetObjectCBs=new Map,this.sheetObjectUnsubscribe=new Map}getSheetInstance(e,n){return n!==void 0?`${e}-${n}`:e}sheet(e,n){if(this.project===void 0){console.error("Theatre Project hasn't been created yet.");return}const t=this.getSheetInstance(e,n);let s=this.sheets.get(t);return s!==void 0||(s=this.project?.sheet(e,n),this.sheets.set(t,s)),s}playSheet(e,n,t){this.sheet(e,t)?.sequence.play(n),this.app.send({event:"playSheet",target:"editor",data:{sheet:e,instance:t,value:n}})}pauseSheet(e,n){this.sheet(e)?.sequence.pause(),this.app.send({event:"pauseSheet",target:"editor",data:{sheet:e,instance:n}})}clearSheetObjects(e){this.sheetObjects.forEach((n,t)=>{t.search(`${e}_`)>-1&&this.unsubscribe(n)})}sheetObject(e,n,t,s,a){if(this.project===void 0){console.error("Theatre Project hasn't been created yet.");return}const o=this.sheet(e,a);if(o===void 0)return;const h=`${this.getSheetInstance(e,a)}_${n}`;let c=this.sheetObjects.get(h);c!==void 0?c=o.object(n,{...t,...c.value},{reconfigure:!0}):c=o.object(n,t),this.sheetObjects.set(h,c),this.sheetObjectCBs.set(h,s!==void 0?s:ni);const m=c.onValuesChange(f=>{if(this.app.editor){for(const y in f){const A=f[y];typeof A=="object"&&Qi(A)&&(f[y]={r:A.r,g:A.g,b:A.b,a:A.a})}this.app.send({event:"updateSheetObject",target:"app",data:{sheet:e,sheetObject:h,values:f}})}const v=this.sheetObjectCBs.get(h);v!==void 0&&v(f)});return this.sheetObjectUnsubscribe.set(h,m),c}unsubscribe(e){if(this.project===void 0){console.error("Theatre Project hasn't been created yet.");return}const n=e.address.sheetId,t=e.address.objectKey;this.sheets.get(n)?.detachObject(t);const a=`${n}_${t}`,o=this.sheetObjectUnsubscribe.get(a);o!==void 0&&(this.sheetObjects.delete(a),this.sheetObjectCBs.delete(a),this.sheetObjectUnsubscribe.delete(a),o())}handleApp(e,n,t){const s=n;let a;switch(t.event){case"setSheet":a=s.sheets.get(t.data.sheet),a!==void 0&&(s.activeSheet=a,this.studio?.setSelection([a]));break;case"setSheetObject":a=s.sheetObjects.get(`${t.data.sheet}_${t.data.key}`),a!==void 0&&this.studio?.setSelection([a]);break;case"updateSheetObject":a=s.sheets.get(t.data.sheet),a!==void 0&&a.sequence.pause(),a=s.sheetObjectCBs.get(t.data.sheetObject),a!==void 0&&a(t.data.values);break;case"updateTimeline":a=s.sheets.get(t.data.sheet),s.activeSheet!==void 0&&(s.activeSheet.sequence.position=t.data.position);break}}handleEditor(e,n,t){if(e.editor){const s=n;switch(t.event){case"playSheet":s.sheet(t.data.sheet,t.data.instance)?.sequence.play(t.data.value);break;case"pauseSheet":s.sheet(t.data.sheet,t.data.instance)?.sequence.pause();break}}}handleEditorApp(e,n){if(e.editor){this.studio?.ui.restore(),this.studio?.onSelectionChange(o=>{o.length<1||o.forEach(r=>{let h=r.address.sheetId,c="setSheet",m={};switch(r.type){case"Theatre_Sheet_PublicAPI":c="setSheet",m={sheet:r.address.sheetId},n.activeSheet=n.sheets.get(r.address.sheetId);break;case"Theatre_SheetObject_PublicAPI":c="setSheetObject",h+=`_${r.address.objectKey}`,m={id:h,sheet:r.address.sheetId,key:r.address.objectKey},n.activeSheet=n.sheets.get(r.address.sheetId);break}e.send({event:c,target:"app",data:m})})});let t=-1;const s=()=>{if(si.rafDriver?.tick(performance.now()),n.activeSheet!==void 0&&t!==n.activeSheet.sequence.position){t=n.activeSheet.sequence.position;const o=n.activeSheet;e.send({event:"updateTimeline",target:"app",data:{position:t,sheet:o.address.sheetId}})}},a=()=>{s(),requestAnimationFrame(a)};s(),a()}else this.studio?.ui.hide()}}function xn(i,e,n){if(i.editor){n.ui.restore(),n.onSelectionChange(o=>{o.length<1||o.forEach(r=>{let h=r.address.sheetId,c="setSheet",m={};switch(r.type){case"Theatre_Sheet_PublicAPI":c="setSheet",m={sheet:r.address.sheetId},e.activeSheet=e.sheets.get(r.address.sheetId);break;case"Theatre_SheetObject_PublicAPI":c="setSheetObject",h+=`_${r.address.objectKey}`,m={id:h,sheet:r.address.sheetId,key:r.address.objectKey},e.activeSheet=e.sheets.get(r.address.sheetId);break}i.send({event:c,target:"app",data:m})})});let t=-1;const s=()=>{if(si.rafDriver?.tick(performance.now()),e.activeSheet!==void 0&&t!==e.activeSheet.sequence.position){t=e.activeSheet.sequence.position;const o=e.activeSheet;i.send({event:"updateTimeline",target:"app",data:{position:t,sheet:o.address.sheetId}})}},a=()=>{s(),requestAnimationFrame(a)};s(),a()}else n.ui.hide()}function Sn(){const i=document.getElementById("theatrejs-studio-root")?.shadowRoot?.getElementById("pointer-root")?.children[0],e=i?.children[1];e.style.justifyContent="left";const n=e.children[1];n.style.transform="translateX(10px)",n.removeChild(n.children[0]),n.removeChild(n.children[0]);const t=i?.children[3];t.style.top="0",t.style.right="300px"}function wn(i){if(i.name==="cameras")return"camera";if(i.name==="interactive")return"interactive";if(i.name==="lights")return"light";if(i.name==="ui")return"ui";if(i.name==="utils")return"utils";const e=i.type;return e.search("Helper")>-1?"icon_utils":e.search("Camera")>-1?"camera":e.search("Light")>-1?"light":"obj3D"}function wt(i){const e={name:i.name,type:i.type,uuid:i.uuid,children:[]};return i.children.forEach(n=>{e.children.push(wt(n))}),e}function Mn(i){const e={};for(const n in i){const t=i[n].value;e[n]={value:t},t===null?e[n].value={src:"",offset:[0,0],repeat:[1,1]}:t!==void 0&&t.isTexture&&(e[n].value={src:t.image.src,offset:[t.offset.x,t.offset.y],repeat:[t.repeat.x,t.repeat.y]})}return e}function Rn(i){switch(i){case"blendSrcAlpha":case"blendDstAlpha":case"blendEquationAlpha":case"clippingPlanes":case"shadowSide":case"precision":return!0}return!1}function Et(i){const e={};for(const n in i){if(n.substring(0,1)==="_"||n.substring(0,2)==="is"||Rn(n))continue;const t=typeof i[n],s=i[n];switch(t){case"boolean":case"number":case"string":e[n]=s;break;case"object":s!==null?(e[n]=s,s.isTexture?e[n]={src:jt.renderToBlob(s),offset:[s.offset.x,s.offset.y],repeat:[s.repeat.x,s.repeat.y]}:n==="uniforms"&&(e[n]=Mn(e[n]))):n==="glslVersion"?e[n]="":e[n]={src:"",offset:[0,0],repeat:[1,1]};break}}return e}function ci(i){i.updateMatrix();const e={name:i.name,type:i.type,uuid:i.uuid,visible:i.visible,matrix:i.matrix.elements,animations:[],material:void 0,perspectiveCameraInfo:void 0,orthographicCameraInfo:void 0,lightInfo:void 0,children:[]};i.animations.forEach(t=>{e.animations.push({name:t.name,duration:t.duration,blendMode:t.blendMode})});const n=i.type.toLowerCase();if(n.search("mesh")>-1){const t=i;if(Array.isArray(t.material)){const s=[];t.material.forEach(a=>{s.push(Et(a))}),e.material=s}else e.material=Et(t.material)}else if(n.search("points")>-1){const t=i;if(Array.isArray(t.material)){const s=[];t.material.forEach(a=>{s.push(Et(a))}),e.material=s}else e.material=Et(t.material)}else if(n.search("line")>-1){const t=i;if(Array.isArray(t.material)){const s=[];t.material.forEach(a=>{s.push(Et(a))}),e.material=s}else e.material=Et(t.material)}else n.search("camera")>-1?i.type==="PerspectiveCamera"?e.perspectiveCameraInfo={fov:i.fov,zoom:i.zoom,near:i.near,far:i.far,focus:i.focus,aspect:i.aspect,filmGauge:i.filmGauge,filmOffset:i.filmOffset}:i.type==="OrthographicCamera"&&(e.orthographicCameraInfo={zoom:i.zoom,near:i.near,far:i.far,left:i.left,right:i.right,top:i.top,bottom:i.bottom}):n.search("light")>-1&&(e.lightInfo={color:i.color,intensity:i.intensity,decay:i.decay,distance:i.distance,angle:i.angle,penumbra:i.penumbra,groundColor:i.groundColor,width:i.width,height:i.height});return e}function Dn(i,e){const n=e.split(".");switch(n.length){case 1:return i[n[0]];case 2:return i[n[0]][n[1]];case 3:return i[n[0]][n[1]][n[2]];case 4:return i[n[0]][n[1]][n[2]][n[3]];case 5:return i[n[0]][n[1]][n[2]][n[3]][n[4]];case 6:return i[n[0]][n[1]][n[2]][n[3]][n[4]][n[5]]}}function An(i,e){for(const n in e)i[n]=e[n]}function fe(i,e,n){if(i===void 0)return;const t=e.split("."),s=t.length;if(typeof n!="object")switch(s){case 1:i[t[0]]=n;break;case 2:i[t[0]][t[1]]=n;break;case 3:i[t[0]][t[1]][t[2]]=n;break;case 4:i[t[0]][t[1]][t[2]][t[3]]=n;break;case 5:i[t[0]][t[1]][t[2]][t[3]][t[4]]=n;break}else{let o;switch(s){case 1:o=i[t[0]];break;case 2:o=i[t[0]][t[1]];break;case 3:o=i[t[0]][t[1]][t[2]];break;case 4:o=i[t[0]][t[1]][t[2]][t[3]];break;case 5:o=i[t[0]][t[1]][t[2]][t[3]][t[4]];break}o!=null&&An(o,n)}}function tn(i){return new Promise((e,n)=>{const t=new Image;t.onload=()=>{const s=new p.Texture(t);s.wrapS=p.RepeatWrapping,s.wrapT=p.RepeatWrapping,s.needsUpdate=!0,e(s)},t.onerror=n,t.src=i})}class Pn extends Ht{scene=void 0;scenes=new Map;renderer=void 0;renderTargets=new Map;groups=new Map;dispose(){this.scenes.forEach(e=>{zt(e)}),this.scenes.clear(),this.scene&&zt(this.scene),this.renderTargets.forEach(e=>{e.dispose()}),this.renderTargets.clear(),this.renderer?.dispose()}getObject(e){this.app.debugEnabled&&(this.renderer!==void 0&&(jt.renderer=this.renderer),this.app.send({event:"getObject",target:"app",data:e}))}setObject(e){this.renderer!==void 0&&(jt.renderer=this.renderer);const n=ci(e);this.app.send({event:"setObject",target:"editor",data:n})}requestMethod(e,n,t,s){this.app.send({event:"requestMethod",target:"app",data:{uuid:e,key:n,value:t,subitem:s}})}updateObject(e,n,t){this.app.send({event:"updateObject",target:"app",data:{uuid:e,key:n,value:t}})}createTexture(e,n,t){this.app.send({event:"createTexture",target:"app",data:{uuid:e,key:n,value:t}})}addGroup(e){this.groups.get(e.title)===void 0&&(this.groups.set(e.title,{title:e.title,onUpdate:e.onUpdate}),this.app.send({event:"addGroup",target:"editor",data:JSON.stringify(e)}))}removeGroup(e){this.groups.get(e)!==void 0&&(this.groups.delete(e),this.app.send({event:"removeGroup",target:"editor",data:e}))}updateGroup(e,n,t){this.app.send({event:"updateGroup",target:"app",data:JSON.stringify({group:e,prop:n,value:t})})}removeAllGroups(){this.groups.forEach(e=>{const n=e.title;this.groups.delete(n),this.app.send({event:"removeGroup",target:"editor",data:n})}),this.groups.clear()}addScene(e){if(e===void 0||(this.scenes.set(e.name,e),!this.app.debugEnabled))return;bi(),ti(e);const n=wt(e);this.app.send({event:"addScene",target:"editor",data:n})}refreshScene(e){if(!this.app.debugEnabled)return;const n=this.scenes.get(e);if(n!==void 0){const t=wt(n);this.app.send({event:"refreshScene",target:"app",data:t})}}removeScene(e){if(e===void 0||(this.scenes.delete(e.name),!this.app.debugEnabled))return;const n=wt(e);this.app.send({event:"removeScene",target:"editor",data:n})}removeAllScenes(){this.scenes.forEach(e=>this.removeScene(e))}getScene(e){let n=null;return this.scenes.forEach((t,s)=>{e.search(s)>-1&&(n=t)}),n}setScene(e){if(e===void 0||(this.scene=e,!this.app.debugEnabled))return;this.renderer!==void 0&&(jt.renderer=this.renderer),bi(),ti(e);const n=wt(e);this.app.send({event:"setScene",target:"editor",data:n})}addCamera(e){if(!this.app.debugEnabled)return;const n=ci(e);this.app.send({event:"addCamera",target:"editor",data:n})}removeCamera(e){if(!this.app.debugEnabled)return;const n=ci(e);this.app.send({event:"removeCamera",target:"editor",data:n})}handleApp(e,n,t){const s=n;switch(t.event){case"getObject":z.dispatchEvent({type:B.GET_OBJECT,value:t.data});break;case"updateObject":z.dispatchEvent({type:B.UPDATE_OBJECT,value:t.data});break;case"createTexture":z.dispatchEvent({type:B.CREATE_TEXTURE,value:t.data});break;case"requestMethod":z.dispatchEvent({type:B.REQUEST_METHOD,value:t.data});break;case"refreshScene":e.send({event:"refreshScene",target:"editor",data:wt(s.scenes.get(t.data.name))});break}if(t.event==="updateGroup"){const a=JSON.parse(t.data);s.groups.get(a.group)?.onUpdate(a.prop,a.value)}}handleEditor(e,n,t){switch(t.event){case"setObject":z.dispatchEvent({type:B.SET_OBJECT,value:t.data});break;case"addScene":z.dispatchEvent({type:B.ADD_SCENE,value:t.data});break;case"refreshScene":z.dispatchEvent({type:B.REFRESH_SCENE,value:t.data});break;case"removeScene":z.dispatchEvent({type:B.REMOVE_SCENE,value:t.data});break;case"setScene":z.dispatchEvent({type:B.SET_SCENE,value:t.data});break;case"addCamera":z.dispatchEvent({type:B.ADD_CAMERA,value:t.data});break;case"removeCamera":z.dispatchEvent({type:B.REMOVE_CAMERA,value:t.data});break;case"addGroup":z.dispatchEvent({type:B.ADD_GROUP,value:t.data});break;case"removeGroup":z.dispatchEvent({type:B.REMOVE_GROUP,value:t.data});break}}rendererWidth=300;rendererHeight=150;addRT(e,n){const t=new p.WebGLRenderTarget(32,32,n);t.texture.name=e,this.renderTargets.set(e,t)}resize(e,n){const t=this.dpr;this.rendererWidth=e,this.rendererHeight=n,this.renderTargets.forEach(s=>{s.setSize(e*t,n*t)}),this.renderer?.setSize(e,n)}set dpr(e){this.renderer?.setPixelRatio(ct(1,2,e))}get dpr(){return this.renderer!==void 0?this.renderer?.getPixelRatio():1}get width(){return this.rendererWidth}get height(){return this.rendererHeight}get canvas(){return this.renderer!==void 0?this.renderer?.domElement:null}}class Ln extends Ht{bindCBs;buttonCBs;pane=void 0;appCallbacks=0;editorCallbacks=0;inspectorFolder=void 0;constructor(e){super(e),this.bindCBs=new Map,this.buttonCBs=new Map,e.editor&&this.createGUI()}createGUI(){this.pane=new gn.Pane({title:"GUI"}),this.pane.registerPlugin(yn)}dispose(){this.bindCBs.clear(),this.buttonCBs.clear(),this.appCallbacks=0,this.editorCallbacks=0,this.app.editor&&(this.pane?.dispose(),this.pane=void 0)}addFolder(e,n=void 0,t=void 0){if(this.app.editor)return this.pane===void 0&&this.createGUI(),(t!==void 0?t:this.pane).addFolder({title:e,...n});this.app.send({event:"addFolder",target:"app",data:{name:e,params:n,parent:t}})}get bindID(){return`debug_${Math.max(this.appCallbacks,this.editorCallbacks)}`}bind(e,n,t,s=void 0){const a=this.bindID,o=t.onChange!==void 0?t.onChange:ni;this.bindCBs.set(a,o),this.app.editor?(this.pane===void 0&&this.createGUI(),(s!==void 0?s:this.pane).addBinding(e,n,t).on("change",h=>{this.app.send({event:"updateBind",target:"app",data:{id:a,value:h.value}})}),this.editorCallbacks++):(this.app.send({event:"bindObject",target:"app",data:{id:a,name:n,params:t,parent:s}}),this.appCallbacks++)}triggerBind(e,n){const t=this.bindCBs.get(e);t!==void 0?t(n):console.warn(`No callback for: ${e}`,n)}button(e,n,t=void 0){const s=this.bindID;this.buttonCBs.set(s,n),this.app.editor?(this.pane===void 0&&this.createGUI(),(t!==void 0?t:this.pane).addButton({title:e}).on("click",()=>{this.app.send({event:"clickButton",target:"app",data:{id:s}})}),this.editorCallbacks++):(this.app.send({event:"addButton",target:"app",data:{id:s,name:e,callback:n,parent:t}}),this.appCallbacks++)}triggerButton(e){const n=this.buttonCBs.get(e);n!==void 0&&n()}createInspector(){this.inspectorFolder=this.addFolder("Inspector",this.pane)}clearInspector(){const e=this.inspectorFolder.children.length-1;for(let n=e;n>-1;--n)this.inspectorFolder.remove(this.inspectorFolder.children[n])}handleApp(e,n,t){const s=n;switch(t.event){case"addFolder":s.addFolder(t.data.name,t.data.params,t.data.parent);break;case"bindObject":s.bind(t.data.name,t.data.params,t.data.parent);break;case"updateBind":s.triggerBind(t.data.id,t.data.value);break;case"addButton":s.button(t.data.name,t.data.callback,t.data.parent);break;case"clickButton":s.triggerButton(t.data.id);break}}}var Oi={exports:{}},Rt={};/**
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("three"),gn=require("tweakpane"),_n=require("@tweakpane/plugin-essentials"),T=require("react"),qi=require("framer-motion");function vn(i){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(i){for(const n in i)if(n!=="default"){const t=Object.getOwnPropertyDescriptor(i,n);Object.defineProperty(e,n,t.get?t:{enumerable:!0,get:()=>i[n]})}}return e.default=i,Object.freeze(e)}const yn=vn(_n),ni=()=>{},En=()=>{};function Nt(i){return i.substring(0,1).toUpperCase()+i.substring(1)}function ct(i,e,n){return Math.min(e,Math.max(i,n))}function vi(i,e,n){return(n-i)/(e-i)}function ei(i,e,n){return i*(1-n)+e*n}function bn(i,e){const n=i-e;return Math.sqrt(n*n)}function Ji(){return Math.round(Math.random()*1e6).toString()}function Qi(i){return i.r!==void 0&&i.g!==void 0&&i.b!==void 0}function yi(i){const e=Math.round(i.r*255),n=Math.round(i.g*255),t=Math.round(i.b*255),s=h=>{const c=h.toString(16);return c.length===1?"0"+c:c},a=s(e),o=s(n),r=s(t);return"#"+a+o+r}function Ei(i,e=1){return Number(i.toFixed(e))}exports.totalThreeObjects=0;const bi=()=>{exports.totalThreeObjects=0},ti=i=>{if(!i)return;let e=i.name.replaceAll(" ","").replaceAll("/",".");if(e.length===0&&(e=`obj_${exports.totalThreeObjects}`,exports.totalThreeObjects++),i.parent!==null&&i.parent.uuid.length>0&&(e=`${i.parent.uuid}.${e}`),i.uuid=e,i.isMesh!==void 0){const n=i;if(Array.isArray(n.material))n.material.forEach((t,s)=>{t.uuid=`${e}.material.${s}`});else{const t=n.material;t.uuid=`${e}.material`}}i.children.forEach(n=>ti(n))},On=i=>{i?.dispose()},en=i=>{i&&(Array.isArray(i)?i.forEach(e=>e.dispose()):i.dispose())},zt=i=>{if(i){for(;i.children.length>0;){const e=i.children[0];e.type==="Audio"?(e.pause(),e.parent&&e.parent.remove(e)):zt(e)}if(i.parent&&i.parent.remove(i),i.isMesh){const e=i;e.geometry?.dispose(),en(e.material)}i.dispose!==void 0&&i.dispose()}};class jt{static renderer;static canvas;static context=null;static scene=null;static camera=null;static material=null;static inited=!1;static width=100;static height=100;static init(){this.inited||(this.canvas=document.createElement("canvas"),this.canvas.width=this.width,this.canvas.height=this.height,this.context=this.canvas.getContext("2d"),this.inited=!0)}static renderToBlob(e){this.init();const n=e.repeat.clone(),t=e.offset.clone();if(e.repeat.set(1,1),e.offset.set(0,0),this.context!==null){this.context.clearRect(0,0,this.width,this.height);const s=e.image;if(s!=null&&s.width>0){this.canvas.title=e.sourceFile;const a=this.canvas.width/s.width,o=this.renderToCanvas(e);this.context.drawImage(o,0,0,s.width*a,s.height*a)}}return e.repeat.copy(n),e.offset.copy(t),this.canvas.toDataURL("image/png")}static renderToCanvas(e){if(this.material===null){this.camera=new p.OrthographicCamera(-.5,.5,.5,-.5,0,100),this.scene=new p.Scene,this.material=new p.MeshBasicMaterial;const n=new p.BufferGeometry;n.setAttribute("position",new p.Float32BufferAttribute([-.5,-.5,0,1.5,-.5,0,-.5,1.5,0],3)),n.setAttribute("normal",new p.Float32BufferAttribute([0,0,1,0,0,1],3)),n.setAttribute("uv",new p.Float32BufferAttribute([0,0,2,0,0,2],2));const t=new p.Mesh(n,this.material);this.scene.add(t)}if(e.isRenderTargetTexture)this.material.map=e,this.renderer.render(this.scene,this.camera);else{const n=this.renderer.outputColorSpace,t=e.colorSpace;this.renderer.outputColorSpace=p.LinearSRGBColorSpace,e.colorSpace=p.LinearSRGBColorSpace,this.material.map=e,this.renderer.render(this.scene,this.camera),this.renderer.outputColorSpace=n,e.colorSpace=t}return this.renderer.domElement}}class Cn{components=new Map;listen;_appID="";_debugEnabled;_broadcastChannel=void 0;_webSocket=void 0;_mode="app";_connected=!1;_useBC=!1;constructor(e,n,t=!0){this._appID=e,this._debugEnabled=n,n&&(this._useBC=t,t?(this._broadcastChannel=new BroadcastChannel(e),this._broadcastChannel.addEventListener("message",this.messageHandler)):(this._webSocket=new WebSocket(e),this._webSocket.addEventListener("open",this.openHandler),this._webSocket.addEventListener("close",this.closeHandler),this._webSocket.addEventListener("message",this.messageHandler)))}addComponent(e,n){this.components.set(e,n)}dispose(){this._broadcastChannel!==void 0&&this._broadcastChannel.removeEventListener("message",this.messageHandler),this._webSocket!==void 0&&(this._webSocket.removeEventListener("open",this.openHandler),this._webSocket.removeEventListener("close",this.closeHandler),this._webSocket.removeEventListener("message",this.messageHandler)),this.components.forEach(e=>{e.dispose()}),this.components.clear()}send(e){this._mode!==e.target&&(this._useBC?this._broadcastChannel?.postMessage(e):this._connected&&this._webSocket?.send(JSON.stringify(e)))}messageHandler=e=>{this.listen!==void 0&&(this._useBC?this.listen(e.data):this.listen(JSON.parse(e.data)))};openHandler=()=>{this._connected=!0};closeHandler=()=>{this._connected=!1};get appID(){return this._appID}get connected(){return this._connected}get debugEnabled(){return this._debugEnabled}get mode(){return this._mode}get isApp(){return this._mode==="app"}get editor(){return this._mode==="editor"}set editor(e){e&&(this._mode="editor")}}const z=new p.EventDispatcher,B={CUSTOM:"ToolEvents::custom",SELECT_DROPDOWN:"ToolEvents::selectDropdown",DRAG_UPDATE:"ToolEvents::dragUpdate",ADD_SCENE:"ToolEvents::addScene",REFRESH_SCENE:"ToolEvents::refreshScene",REMOVE_SCENE:"ToolEvents::removeScene",SET_SCENE:"ToolEvents::setScene",GET_OBJECT:"ToolEvents::getObject",SET_OBJECT:"ToolEvents::setObject",UPDATE_OBJECT:"ToolEvents::updateObject",CREATE_TEXTURE:"ToolEvents::createTexture",REQUEST_METHOD:"ToolEvents::requestMethod",ADD_CAMERA:"ToolEvents::addCamera",REMOVE_CAMERA:"ToolEvents::removeCamera",ADD_GROUP:"ToolEvents::addGroup",REMOVE_GROUP:"ToolEvents::removeGroup"};class Ht{app;constructor(e){this.app=e}dispose(){}handleApp(e,n,t){}handleEditor(e,n,t){}}class Tn extends Ht{selectDropdown(e,n){this.app.send({event:"selectComponent",target:"app",data:{dropdown:e,value:n}})}updateDropdown(e,n){this.app.send({event:"draggableListUpdate",target:"app",data:{dropdown:e,value:n}})}handleApp(e,n,t){switch(t.event){case"selectComponent":z.dispatchEvent({type:B.SELECT_DROPDOWN,value:t.data});break;case"draggableListUpdate":z.dispatchEvent({type:B.DRAG_UPDATE,value:t.data});break}}}class si extends Ht{project;sheets=new Map;sheetObjects=new Map;sheetObjectCBs=new Map;sheetObjectUnsubscribe=new Map;activeSheet;studio=void 0;static rafDriver=void 0;dispose(){this.project=void 0,this.sheets=new Map,this.sheetObjects=new Map,this.sheetObjectCBs=new Map,this.sheetObjectUnsubscribe=new Map}getSheetInstance(e,n){return n!==void 0?`${e}-${n}`:e}sheet(e,n){if(this.project===void 0){console.error("Theatre Project hasn't been created yet.");return}const t=this.getSheetInstance(e,n);let s=this.sheets.get(t);return s!==void 0||(s=this.project?.sheet(e,n),this.sheets.set(t,s)),s}playSheet(e,n,t){this.sheet(e,t)?.sequence.play(n),this.app.send({event:"playSheet",target:"editor",data:{sheet:e,instance:t,value:n}})}pauseSheet(e,n){this.sheet(e)?.sequence.pause(),this.app.send({event:"pauseSheet",target:"editor",data:{sheet:e,instance:n}})}clearSheetObjects(e){this.sheetObjects.forEach((n,t)=>{t.search(`${e}_`)>-1&&this.unsubscribe(n)})}sheetObject(e,n,t,s,a){if(this.project===void 0){console.error("Theatre Project hasn't been created yet.");return}const o=this.sheet(e,a);if(o===void 0)return;const h=`${this.getSheetInstance(e,a)}_${n}`;let c=this.sheetObjects.get(h);c!==void 0?c=o.object(n,{...t,...c.value},{reconfigure:!0}):c=o.object(n,t),this.sheetObjects.set(h,c),this.sheetObjectCBs.set(h,s!==void 0?s:ni);const m=c.onValuesChange(f=>{if(this.app.editor){for(const y in f){const A=f[y];typeof A=="object"&&Qi(A)&&(f[y]={r:A.r,g:A.g,b:A.b,a:A.a})}this.app.send({event:"updateSheetObject",target:"app",data:{sheet:e,sheetObject:h,values:f}})}const v=this.sheetObjectCBs.get(h);v!==void 0&&v(f)});return this.sheetObjectUnsubscribe.set(h,m),c}unsubscribe(e){if(this.project===void 0){console.error("Theatre Project hasn't been created yet.");return}const n=e.address.sheetId,t=e.address.objectKey;this.sheets.get(n)?.detachObject(t);const a=`${n}_${t}`,o=this.sheetObjectUnsubscribe.get(a);o!==void 0&&(this.sheetObjects.delete(a),this.sheetObjectCBs.delete(a),this.sheetObjectUnsubscribe.delete(a),o())}handleApp(e,n,t){const s=n;let a;switch(t.event){case"setSheet":a=s.sheets.get(t.data.sheet),a!==void 0&&(s.activeSheet=a,this.studio?.setSelection([a]));break;case"setSheetObject":a=s.sheetObjects.get(`${t.data.sheet}_${t.data.key}`),a!==void 0&&this.studio?.setSelection([a]);break;case"updateSheetObject":a=s.sheets.get(t.data.sheet),a!==void 0&&a.sequence.pause(),a=s.sheetObjectCBs.get(t.data.sheetObject),a!==void 0&&a(t.data.values);break;case"updateTimeline":a=s.sheets.get(t.data.sheet),s.activeSheet!==void 0&&(s.activeSheet.sequence.position=t.data.position);break}}handleEditor(e,n,t){if(e.editor){const s=n;switch(t.event){case"playSheet":s.sheet(t.data.sheet,t.data.instance)?.sequence.play(t.data.value);break;case"pauseSheet":s.sheet(t.data.sheet,t.data.instance)?.sequence.pause();break}}}handleEditorApp(e,n){if(e.editor){this.studio?.ui.restore(),this.studio?.onSelectionChange(o=>{o.length<1||o.forEach(r=>{let h=r.address.sheetId,c="setSheet",m={};switch(r.type){case"Theatre_Sheet_PublicAPI":c="setSheet",m={sheet:r.address.sheetId},n.activeSheet=n.sheets.get(r.address.sheetId);break;case"Theatre_SheetObject_PublicAPI":c="setSheetObject",h+=`_${r.address.objectKey}`,m={id:h,sheet:r.address.sheetId,key:r.address.objectKey},n.activeSheet=n.sheets.get(r.address.sheetId);break}e.send({event:c,target:"app",data:m})})});let t=-1;const s=()=>{if(si.rafDriver?.tick(performance.now()),n.activeSheet!==void 0&&t!==n.activeSheet.sequence.position){t=n.activeSheet.sequence.position;const o=n.activeSheet;e.send({event:"updateTimeline",target:"app",data:{position:t,sheet:o.address.sheetId}})}},a=()=>{s(),requestAnimationFrame(a)};s(),a()}else this.studio?.ui.hide()}}function xn(i,e,n){if(i.editor){n.ui.restore(),n.onSelectionChange(o=>{o.length<1||o.forEach(r=>{let h=r.address.sheetId,c="setSheet",m={};switch(r.type){case"Theatre_Sheet_PublicAPI":c="setSheet",m={sheet:r.address.sheetId},e.activeSheet=e.sheets.get(r.address.sheetId);break;case"Theatre_SheetObject_PublicAPI":c="setSheetObject",h+=`_${r.address.objectKey}`,m={id:h,sheet:r.address.sheetId,key:r.address.objectKey},e.activeSheet=e.sheets.get(r.address.sheetId);break}i.send({event:c,target:"app",data:m})})});let t=-1;const s=()=>{if(si.rafDriver?.tick(performance.now()),e.activeSheet!==void 0&&t!==e.activeSheet.sequence.position){t=e.activeSheet.sequence.position;const o=e.activeSheet;i.send({event:"updateTimeline",target:"app",data:{position:t,sheet:o.address.sheetId}})}},a=()=>{s(),requestAnimationFrame(a)};s(),a()}else n.ui.hide()}function Sn(){const i=document.getElementById("theatrejs-studio-root")?.shadowRoot?.getElementById("pointer-root")?.children[0],e=i?.children[1];e.style.justifyContent="left";const n=e.children[1];n.style.transform="translateX(10px)",n.removeChild(n.children[0]),n.removeChild(n.children[0]);const t=i?.children[3];t.style.top="0",t.style.right="300px"}function wn(i){if(i.name==="cameras")return"camera";if(i.name==="interactive")return"interactive";if(i.name==="lights")return"light";if(i.name==="ui")return"ui";if(i.name==="utils")return"utils";const e=i.type;return e.search("Helper")>-1?"icon_utils":e.search("Camera")>-1?"camera":e.search("Light")>-1?"light":"obj3D"}function wt(i){const e={name:i.name,type:i.type,uuid:i.uuid,children:[]};return i.children.forEach(n=>{e.children.push(wt(n))}),e}function Mn(i){const e={};for(const n in i){const t=i[n].value;e[n]={value:t},t===null?e[n].value={src:"",offset:[0,0],repeat:[1,1]}:t!==void 0&&t.isTexture&&(e[n].value={src:t.image.src,offset:[t.offset.x,t.offset.y],repeat:[t.repeat.x,t.repeat.y]})}return e}function Rn(i){switch(i){case"blendSrcAlpha":case"blendDstAlpha":case"blendEquationAlpha":case"clippingPlanes":case"shadowSide":case"precision":return!0}return!1}function Et(i){const e={};for(const n in i){if(n.substring(0,1)==="_"||n.substring(0,2)==="is"||Rn(n))continue;const t=typeof i[n],s=i[n];switch(t){case"boolean":case"number":case"string":e[n]=s;break;case"object":s!==null?(e[n]=s,s.isTexture?e[n]={src:jt.renderToBlob(s),offset:[s.offset.x,s.offset.y],repeat:[s.repeat.x,s.repeat.y]}:n==="uniforms"&&(e[n]=Mn(e[n]))):n==="glslVersion"?e[n]="":e[n]={src:"",offset:[0,0],repeat:[1,1]};break}}return i.anisotropy!==void 0&&(e.anisotropy=i.anisotropy),i.clearcoat!==void 0&&(e.clearcoat=i.clearcoat),i.iridescence!==void 0&&(e.iridescence=i.iridescence),i.dispersion!==void 0&&(e.dispersion=i.dispersion),i.sheen!==void 0&&(e.sheen=i.sheen),i.transmission!==void 0&&(e.transmission=i.transmission),i.transmission!==void 0&&(e.transmission=i.transmission),e}function ci(i){i.updateMatrix();const e={name:i.name,type:i.type,uuid:i.uuid,visible:i.visible,matrix:i.matrix.elements,animations:[],material:void 0,perspectiveCameraInfo:void 0,orthographicCameraInfo:void 0,lightInfo:void 0,children:[]};i.animations.forEach(t=>{e.animations.push({name:t.name,duration:t.duration,blendMode:t.blendMode})});const n=i.type.toLowerCase();if(n.search("mesh")>-1){const t=i;if(Array.isArray(t.material)){const s=[];t.material.forEach(a=>{s.push(Et(a))}),e.material=s}else e.material=Et(t.material)}else if(n.search("points")>-1){const t=i;if(Array.isArray(t.material)){const s=[];t.material.forEach(a=>{s.push(Et(a))}),e.material=s}else e.material=Et(t.material)}else if(n.search("line")>-1){const t=i;if(Array.isArray(t.material)){const s=[];t.material.forEach(a=>{s.push(Et(a))}),e.material=s}else e.material=Et(t.material)}else n.search("camera")>-1?i.type==="PerspectiveCamera"?e.perspectiveCameraInfo={fov:i.fov,zoom:i.zoom,near:i.near,far:i.far,focus:i.focus,aspect:i.aspect,filmGauge:i.filmGauge,filmOffset:i.filmOffset}:i.type==="OrthographicCamera"&&(e.orthographicCameraInfo={zoom:i.zoom,near:i.near,far:i.far,left:i.left,right:i.right,top:i.top,bottom:i.bottom}):n.search("light")>-1&&(e.lightInfo={color:i.color,intensity:i.intensity,decay:i.decay,distance:i.distance,angle:i.angle,penumbra:i.penumbra,groundColor:i.groundColor,width:i.width,height:i.height});return e}function Dn(i,e){const n=e.split(".");switch(n.length){case 1:return i[n[0]];case 2:return i[n[0]][n[1]];case 3:return i[n[0]][n[1]][n[2]];case 4:return i[n[0]][n[1]][n[2]][n[3]];case 5:return i[n[0]][n[1]][n[2]][n[3]][n[4]];case 6:return i[n[0]][n[1]][n[2]][n[3]][n[4]][n[5]]}}function An(i,e){for(const n in e)i[n]=e[n]}function fe(i,e,n){if(i===void 0)return;const t=e.split("."),s=t.length;if(typeof n!="object")switch(s){case 1:i[t[0]]=n;break;case 2:i[t[0]][t[1]]=n;break;case 3:i[t[0]][t[1]][t[2]]=n;break;case 4:i[t[0]][t[1]][t[2]][t[3]]=n;break;case 5:i[t[0]][t[1]][t[2]][t[3]][t[4]]=n;break}else{let o;switch(s){case 1:o=i[t[0]];break;case 2:o=i[t[0]][t[1]];break;case 3:o=i[t[0]][t[1]][t[2]];break;case 4:o=i[t[0]][t[1]][t[2]][t[3]];break;case 5:o=i[t[0]][t[1]][t[2]][t[3]][t[4]];break}o!=null&&An(o,n)}}function tn(i){return new Promise((e,n)=>{const t=new Image;t.onload=()=>{const s=new p.Texture(t);s.wrapS=p.RepeatWrapping,s.wrapT=p.RepeatWrapping,s.needsUpdate=!0,e(s)},t.onerror=n,t.src=i})}class Pn extends Ht{scene=void 0;scenes=new Map;renderer=void 0;renderTargets=new Map;groups=new Map;dispose(){this.scenes.forEach(e=>{zt(e)}),this.scenes.clear(),this.scene&&zt(this.scene),this.renderTargets.forEach(e=>{e.dispose()}),this.renderTargets.clear(),this.renderer?.dispose()}getObject(e){this.app.debugEnabled&&(this.renderer!==void 0&&(jt.renderer=this.renderer),this.app.send({event:"getObject",target:"app",data:e}))}setObject(e){this.renderer!==void 0&&(jt.renderer=this.renderer);const n=ci(e);this.app.send({event:"setObject",target:"editor",data:n})}requestMethod(e,n,t,s){this.app.send({event:"requestMethod",target:"app",data:{uuid:e,key:n,value:t,subitem:s}})}updateObject(e,n,t){this.app.send({event:"updateObject",target:"app",data:{uuid:e,key:n,value:t}})}createTexture(e,n,t){this.app.send({event:"createTexture",target:"app",data:{uuid:e,key:n,value:t}})}addGroup(e){this.groups.get(e.title)===void 0&&(this.groups.set(e.title,{title:e.title,onUpdate:e.onUpdate}),this.app.send({event:"addGroup",target:"editor",data:JSON.stringify(e)}))}removeGroup(e){this.groups.get(e)!==void 0&&(this.groups.delete(e),this.app.send({event:"removeGroup",target:"editor",data:e}))}updateGroup(e,n,t){this.app.send({event:"updateGroup",target:"app",data:JSON.stringify({group:e,prop:n,value:t})})}removeAllGroups(){this.groups.forEach(e=>{const n=e.title;this.groups.delete(n),this.app.send({event:"removeGroup",target:"editor",data:n})}),this.groups.clear()}addScene(e){if(e===void 0||(this.scenes.set(e.name,e),!this.app.debugEnabled))return;bi(),ti(e);const n=wt(e);this.app.send({event:"addScene",target:"editor",data:n})}refreshScene(e){if(!this.app.debugEnabled)return;const n=this.scenes.get(e);if(n!==void 0){const t=wt(n);this.app.send({event:"refreshScene",target:"app",data:t})}}removeScene(e){if(e===void 0||(this.scenes.delete(e.name),!this.app.debugEnabled))return;const n=wt(e);this.app.send({event:"removeScene",target:"editor",data:n})}removeAllScenes(){this.scenes.forEach(e=>this.removeScene(e))}getScene(e){let n=null;return this.scenes.forEach((t,s)=>{e.search(s)>-1&&(n=t)}),n}setScene(e){if(e===void 0||(this.scene=e,!this.app.debugEnabled))return;this.renderer!==void 0&&(jt.renderer=this.renderer),bi(),ti(e);const n=wt(e);this.app.send({event:"setScene",target:"editor",data:n})}addCamera(e){if(!this.app.debugEnabled)return;const n=ci(e);this.app.send({event:"addCamera",target:"editor",data:n})}removeCamera(e){if(!this.app.debugEnabled)return;const n=ci(e);this.app.send({event:"removeCamera",target:"editor",data:n})}handleApp(e,n,t){const s=n;switch(t.event){case"getObject":z.dispatchEvent({type:B.GET_OBJECT,value:t.data});break;case"updateObject":z.dispatchEvent({type:B.UPDATE_OBJECT,value:t.data});break;case"createTexture":z.dispatchEvent({type:B.CREATE_TEXTURE,value:t.data});break;case"requestMethod":z.dispatchEvent({type:B.REQUEST_METHOD,value:t.data});break;case"refreshScene":e.send({event:"refreshScene",target:"editor",data:wt(s.scenes.get(t.data.name))});break}if(t.event==="updateGroup"){const a=JSON.parse(t.data);s.groups.get(a.group)?.onUpdate(a.prop,a.value)}}handleEditor(e,n,t){switch(t.event){case"setObject":z.dispatchEvent({type:B.SET_OBJECT,value:t.data});break;case"addScene":z.dispatchEvent({type:B.ADD_SCENE,value:t.data});break;case"refreshScene":z.dispatchEvent({type:B.REFRESH_SCENE,value:t.data});break;case"removeScene":z.dispatchEvent({type:B.REMOVE_SCENE,value:t.data});break;case"setScene":z.dispatchEvent({type:B.SET_SCENE,value:t.data});break;case"addCamera":z.dispatchEvent({type:B.ADD_CAMERA,value:t.data});break;case"removeCamera":z.dispatchEvent({type:B.REMOVE_CAMERA,value:t.data});break;case"addGroup":z.dispatchEvent({type:B.ADD_GROUP,value:t.data});break;case"removeGroup":z.dispatchEvent({type:B.REMOVE_GROUP,value:t.data});break}}rendererWidth=300;rendererHeight=150;addRT(e,n){const t=new p.WebGLRenderTarget(32,32,n);t.texture.name=e,this.renderTargets.set(e,t)}resize(e,n){const t=this.dpr;this.rendererWidth=e,this.rendererHeight=n,this.renderTargets.forEach(s=>{s.setSize(e*t,n*t)}),this.renderer?.setSize(e,n)}set dpr(e){this.renderer?.setPixelRatio(ct(1,2,e))}get dpr(){return this.renderer!==void 0?this.renderer?.getPixelRatio():1}get width(){return this.rendererWidth}get height(){return this.rendererHeight}get canvas(){return this.renderer!==void 0?this.renderer?.domElement:null}}class Ln extends Ht{bindCBs;buttonCBs;pane=void 0;appCallbacks=0;editorCallbacks=0;inspectorFolder=void 0;constructor(e){super(e),this.bindCBs=new Map,this.buttonCBs=new Map,e.editor&&this.createGUI()}createGUI(){this.pane=new gn.Pane({title:"GUI"}),this.pane.registerPlugin(yn)}dispose(){this.bindCBs.clear(),this.buttonCBs.clear(),this.appCallbacks=0,this.editorCallbacks=0,this.app.editor&&(this.pane?.dispose(),this.pane=void 0)}addFolder(e,n=void 0,t=void 0){if(this.app.editor)return this.pane===void 0&&this.createGUI(),(t!==void 0?t:this.pane).addFolder({title:e,...n});this.app.send({event:"addFolder",target:"app",data:{name:e,params:n,parent:t}})}get bindID(){return`debug_${Math.max(this.appCallbacks,this.editorCallbacks)}`}bind(e,n,t,s=void 0){const a=this.bindID,o=t.onChange!==void 0?t.onChange:ni;this.bindCBs.set(a,o),this.app.editor?(this.pane===void 0&&this.createGUI(),(s!==void 0?s:this.pane).addBinding(e,n,t).on("change",h=>{this.app.send({event:"updateBind",target:"app",data:{id:a,value:h.value}})}),this.editorCallbacks++):(this.app.send({event:"bindObject",target:"app",data:{id:a,name:n,params:t,parent:s}}),this.appCallbacks++)}triggerBind(e,n){const t=this.bindCBs.get(e);t!==void 0?t(n):console.warn(`No callback for: ${e}`,n)}button(e,n,t=void 0){const s=this.bindID;this.buttonCBs.set(s,n),this.app.editor?(this.pane===void 0&&this.createGUI(),(t!==void 0?t:this.pane).addButton({title:e}).on("click",()=>{this.app.send({event:"clickButton",target:"app",data:{id:s}})}),this.editorCallbacks++):(this.app.send({event:"addButton",target:"app",data:{id:s,name:e,callback:n,parent:t}}),this.appCallbacks++)}triggerButton(e){const n=this.buttonCBs.get(e);n!==void 0&&n()}createInspector(){this.inspectorFolder=this.addFolder("Inspector",this.pane)}clearInspector(){const e=this.inspectorFolder.children.length-1;for(let n=e;n>-1;--n)this.inspectorFolder.remove(this.inspectorFolder.children[n])}handleApp(e,n,t){const s=n;switch(t.event){case"addFolder":s.addFolder(t.data.name,t.data.params,t.data.parent);break;case"bindObject":s.bind(t.data.name,t.data.params,t.data.parent);break;case"updateBind":s.triggerBind(t.data.id,t.data.value);break;case"addButton":s.button(t.data.name,t.data.callback,t.data.parent);break;case"clickButton":s.triggerButton(t.data.id);break}}}var Oi={exports:{}},Rt={};/**
|
2
2
|
* @license React
|
3
3
|
* react-jsx-runtime.production.min.js
|
4
4
|
*
|
package/dist/hermes.es.js
CHANGED
@@ -543,7 +543,7 @@ function St(i) {
|
|
543
543
|
break;
|
544
544
|
}
|
545
545
|
}
|
546
|
-
return e;
|
546
|
+
return i.anisotropy !== void 0 && (e.anisotropy = i.anisotropy), i.clearcoat !== void 0 && (e.clearcoat = i.clearcoat), i.iridescence !== void 0 && (e.iridescence = i.iridescence), i.dispersion !== void 0 && (e.dispersion = i.dispersion), i.sheen !== void 0 && (e.sheen = i.sheen), i.transmission !== void 0 && (e.transmission = i.transmission), i.transmission !== void 0 && (e.transmission = i.transmission), e;
|
547
547
|
}
|
548
548
|
function gi(i) {
|
549
549
|
i.updateMatrix();
|
package/package.json
CHANGED
@@ -7,7 +7,7 @@
|
|
7
7
|
"module": "./dist/hermes.esm.js",
|
8
8
|
"types": "./types/index.d.ts",
|
9
9
|
"type": "module",
|
10
|
-
"version": "0.0.
|
10
|
+
"version": "0.0.93",
|
11
11
|
"homepage": "https://github.com/tomorrowevening/hermes#readme",
|
12
12
|
"bugs": {
|
13
13
|
"url": "https://github.com/tomorrowevening/hermes/issues"
|