@tomorrowevening/hermes 0.0.37 → 0.0.38
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/hermes.cjs.js +15 -15
- package/dist/hermes.esm.js +981 -971
- package/package.json +1 -5
- package/types/core/Application.d.ts +5 -4
- package/types/core/remote/BaseRemote.d.ts +4 -0
- package/types/core/remote/RemoteComponents.d.ts +1 -2
- package/types/core/remote/RemoteTheatre.d.ts +3 -4
- package/types/core/remote/RemoteThree.d.ts +2 -3
- package/types/core/remote/RemoteTweakpane.d.ts +1 -1
- package/dist/hermes.umd.js +0 -144
- package/src/core/Application.ts +0 -111
- package/src/core/RemoteController.ts +0 -60
- package/src/core/remote/BaseRemote.ts +0 -16
- package/src/core/remote/RemoteComponents.ts +0 -45
- package/src/core/remote/RemoteTheatre.ts +0 -300
- package/src/core/remote/RemoteThree.ts +0 -143
- package/src/core/remote/RemoteTweakpane.ts +0 -194
- package/src/core/types.ts +0 -56
- package/src/editor/Editor.tsx +0 -20
- package/src/editor/components/Draggable.tsx +0 -40
- package/src/editor/components/DraggableItem.tsx +0 -22
- package/src/editor/components/Dropdown.tsx +0 -38
- package/src/editor/components/DropdownItem.tsx +0 -64
- package/src/editor/components/NavButton.tsx +0 -11
- package/src/editor/components/content.ts +0 -2
- package/src/editor/components/icons/CloseIcon.tsx +0 -7
- package/src/editor/components/icons/DragIcon.tsx +0 -9
- package/src/editor/components/types.ts +0 -41
- package/src/editor/global.ts +0 -20
- package/src/editor/multiView/CameraWindow.tsx +0 -74
- package/src/editor/multiView/InfiniteGridHelper.ts +0 -24
- package/src/editor/multiView/InfiniteGridMaterial.ts +0 -127
- package/src/editor/multiView/MultiView.scss +0 -101
- package/src/editor/multiView/MultiView.tsx +0 -636
- package/src/editor/multiView/MultiViewData.ts +0 -59
- package/src/editor/multiView/UVMaterial.ts +0 -55
- package/src/editor/scss/_debug.scss +0 -58
- package/src/editor/scss/_draggable.scss +0 -43
- package/src/editor/scss/_dropdown.scss +0 -84
- package/src/editor/scss/_sidePanel.scss +0 -278
- package/src/editor/scss/_theme.scss +0 -9
- package/src/editor/scss/index.scss +0 -67
- package/src/editor/sidePanel/Accordion.tsx +0 -41
- package/src/editor/sidePanel/ChildObject.tsx +0 -57
- package/src/editor/sidePanel/ContainerObject.tsx +0 -11
- package/src/editor/sidePanel/SidePanel.tsx +0 -64
- package/src/editor/sidePanel/ToggleBtn.tsx +0 -27
- package/src/editor/sidePanel/inspector/Inspector.tsx +0 -119
- package/src/editor/sidePanel/inspector/InspectorField.tsx +0 -198
- package/src/editor/sidePanel/inspector/InspectorGroup.tsx +0 -50
- package/src/editor/sidePanel/inspector/SceneInspector.tsx +0 -84
- package/src/editor/sidePanel/inspector/inspector.scss +0 -161
- package/src/editor/sidePanel/inspector/utils/InspectAnimation.tsx +0 -102
- package/src/editor/sidePanel/inspector/utils/InspectCamera.tsx +0 -75
- package/src/editor/sidePanel/inspector/utils/InspectLight.tsx +0 -62
- package/src/editor/sidePanel/inspector/utils/InspectMaterial.tsx +0 -710
- package/src/editor/sidePanel/inspector/utils/InspectTransform.tsx +0 -113
- package/src/editor/sidePanel/types.ts +0 -130
- package/src/editor/sidePanel/utils.ts +0 -278
- package/src/editor/utils.ts +0 -117
- package/src/example/CustomEditor.tsx +0 -78
- package/src/example/components/App.css +0 -6
- package/src/example/components/App.tsx +0 -246
- package/src/example/constants.ts +0 -52
- package/src/example/index.scss +0 -45
- package/src/example/main.tsx +0 -37
- package/src/example/three/BaseScene.ts +0 -42
- package/src/example/three/CustomMaterial.ts +0 -72
- package/src/example/three/FBXAnimation.ts +0 -26
- package/src/example/three/Scene1.ts +0 -225
- package/src/example/three/Scene2.ts +0 -138
- package/src/example/three/loader.ts +0 -110
- package/src/index.ts +0 -27
- package/src/vite-env.d.ts +0 -1
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.38",
|
11
11
|
"homepage": "https://github.com/tomorrowevening/hermes#readme",
|
12
12
|
"bugs": {
|
13
13
|
"url": "https://github.com/tomorrowevening/hermes/issues"
|
@@ -22,17 +22,13 @@
|
|
22
22
|
"files": [
|
23
23
|
"dist/hermes.esm.js",
|
24
24
|
"dist/hermes.cjs.js",
|
25
|
-
"dist/hermes.umd.js",
|
26
25
|
"dist/style.css",
|
27
|
-
"src/",
|
28
26
|
"types/**/*.d.ts"
|
29
27
|
],
|
30
28
|
"exports": {
|
31
29
|
".": {
|
32
30
|
"import": "./dist/hermes.esm.js",
|
33
31
|
"require": "./dist/hermes.cjs.js",
|
34
|
-
"umd": "./dist/hermes.umd.js",
|
35
|
-
"default": "./dist/hermes.umd.js",
|
36
32
|
"types": "./types/index.d.ts"
|
37
33
|
},
|
38
34
|
"./dist/style.css": "./dist/style.css",
|
@@ -4,12 +4,13 @@ export default class Application {
|
|
4
4
|
components: Map<string, any>;
|
5
5
|
listen?: BroadcastCallback;
|
6
6
|
protected _debugEnabled: boolean;
|
7
|
-
protected
|
8
|
-
protected
|
7
|
+
protected _broadcastChannel?: BroadcastChannel | undefined;
|
8
|
+
protected _webSocket?: WebSocket | undefined;
|
9
9
|
protected _mode: ApplicationMode;
|
10
10
|
protected _connected: boolean;
|
11
|
-
protected
|
12
|
-
constructor(id: string, debugEnabled: boolean, useBC?: boolean
|
11
|
+
protected _useBC: boolean;
|
12
|
+
constructor(id: string, debugEnabled: boolean, useBC?: boolean);
|
13
|
+
init(): Promise<void>;
|
13
14
|
addComponent(name: string, component: BaseRemote): void;
|
14
15
|
dispose(): void;
|
15
16
|
send(data: BroadcastData): void;
|
@@ -1,6 +1,10 @@
|
|
1
1
|
import Application from '../Application';
|
2
|
+
import { BroadcastData } from '../types';
|
2
3
|
export default class BaseRemote {
|
3
4
|
protected app: Application;
|
4
5
|
constructor(app: Application);
|
5
6
|
dispose(): void;
|
7
|
+
handleApp(_: BroadcastData): void;
|
8
|
+
handleEditor(_: BroadcastData): void;
|
9
|
+
handleEditorApp(): void;
|
6
10
|
}
|
@@ -1,8 +1,7 @@
|
|
1
|
-
import Application from '../Application';
|
2
1
|
import BaseRemote from './BaseRemote';
|
3
2
|
import { BroadcastData } from '../types';
|
4
3
|
export default class RemoteComponents extends BaseRemote {
|
5
4
|
selectDropdown(dropdown: string, value: any): void;
|
6
5
|
updateDropdown(dropdown: string, list: string[]): void;
|
6
|
+
handleApp(msg: BroadcastData): void;
|
7
7
|
}
|
8
|
-
export declare function HandleAppRemoteComponents(_: Application, msg: BroadcastData): void;
|
@@ -1,5 +1,4 @@
|
|
1
1
|
import { IProject, IProjectConfig, IRafDriver, ISheet, ISheetObject } from '@theatre/core';
|
2
|
-
import Application from '../Application';
|
3
2
|
import BaseRemote from './BaseRemote';
|
4
3
|
import { BroadcastData, DataUpdateCallback, VoidCallback } from '../types';
|
5
4
|
export default class RemoteTheatre extends BaseRemote {
|
@@ -17,8 +16,8 @@ export default class RemoteTheatre extends BaseRemote {
|
|
17
16
|
clearSheetObjects(sheetName: string): void;
|
18
17
|
sheetObject(sheetName: string, key: string, props: any, onUpdate?: DataUpdateCallback): ISheetObject | undefined;
|
19
18
|
unsubscribe(sheetObject: ISheetObject): undefined;
|
19
|
+
handleApp(msg: BroadcastData): void;
|
20
|
+
handleEditor(msg: BroadcastData): void;
|
21
|
+
handleEditorApp(): void;
|
20
22
|
static getRafDriver(): IRafDriver;
|
21
23
|
}
|
22
|
-
export declare function HandleAppRemoteTheatre(app: Application, msg: BroadcastData): void;
|
23
|
-
export declare function UpdateRemoteTheatre(app: Application): void;
|
24
|
-
export declare function HandleEditorRemoteTheatre(app: Application, msg: BroadcastData): void;
|
@@ -1,6 +1,5 @@
|
|
1
1
|
import { Camera, Scene } from 'three';
|
2
2
|
import BaseRemote from './BaseRemote';
|
3
|
-
import Application from '../Application';
|
4
3
|
import { BroadcastData } from '../types';
|
5
4
|
export default class RemoteThree extends BaseRemote {
|
6
5
|
scene?: Scene;
|
@@ -12,6 +11,6 @@ export default class RemoteThree extends BaseRemote {
|
|
12
11
|
setScene(value: Scene): void;
|
13
12
|
addCamera(camera: Camera): void;
|
14
13
|
removeCamera(camera: Camera): void;
|
14
|
+
handleApp(msg: BroadcastData): void;
|
15
|
+
handleEditor(msg: BroadcastData): void;
|
15
16
|
}
|
16
|
-
export declare function HandleAppRemoteThree(_: Application, msg: BroadcastData): void;
|
17
|
-
export declare function HandleEditorRemoteThree(_: Application, msg: BroadcastData): void;
|
@@ -20,5 +20,5 @@ export default class RemoteTweakpane extends BaseRemote {
|
|
20
20
|
triggerButton(id: string): void;
|
21
21
|
createInspector(): void;
|
22
22
|
clearInspector(): void;
|
23
|
+
handleApp(msg: BroadcastData): void;
|
23
24
|
}
|
24
|
-
export declare function HandleAppRemoteTweakpane(app: Application, msg: BroadcastData): void;
|
package/dist/hermes.umd.js
DELETED
@@ -1,144 +0,0 @@
|
|
1
|
-
(function(S,c){typeof exports=="object"&&typeof module<"u"?c(exports,require("three"),require("@theatre/core"),require("@theatre/studio"),require("tweakpane"),require("@tweakpane/plugin-essentials"),require("react"),require("framer-motion")):typeof define=="function"&&define.amd?define(["exports","three","@theatre/core","@theatre/studio","tweakpane","@tweakpane/plugin-essentials","react","framer-motion"],c):(S=typeof globalThis<"u"?globalThis:S||self,c(S.Hermes={},S.three,S["@theatre/core"],S["@theatre/studio"],S.tweakpane,S["tweakpane-plugin-essentials"],S.react,S["framer-motion"]))})(this,function(S,c,Gt,Ke,Mn,Tn,A,Wt){"use strict";function Rn(t){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const a in t)if(a!=="default"){const e=Object.getOwnPropertyDescriptor(t,a);Object.defineProperty(n,a,e.get?e:{enumerable:!0,get:()=>t[a]})}}return n.default=t,Object.freeze(n)}const An=Rn(Tn);function Be(t){return t.substring(0,1).toUpperCase()+t.substring(1)}function Pn(t,n,a){return Math.min(n,Math.max(t,a))}function kn(t,n){const a=t-n;return Math.sqrt(a*a)}function Kt(){return Math.round(Math.random()*1e6).toString()}function Xt(t){return t.r!==void 0&&t.g!==void 0&&t.b!==void 0}function Zt(t){const n=Math.round(t.r*255),a=Math.round(t.g*255),e=Math.round(t.b*255),o=d=>{const f=d.toString(16);return f.length===1?"0"+f:f},s=o(n),m=o(a),l=o(e);return"#"+s+m+l}function lt(t,n=1){return Number(t.toFixed(n))}S.totalThreeObjects=0;const Jt=()=>{S.totalThreeObjects=0},Tt=t=>{if(!t)return;let n=t.name.replace(" ","");n.length===0&&(n=`obj_${S.totalThreeObjects}`,S.totalThreeObjects++),t.parent!==null&&(n=`${t.parent.uuid}.${n}`),t.uuid=n,t.children.forEach(a=>{Tt(a)})},_n=t=>{t?.dispose()},Qt=t=>{t&&(Array.isArray(t)?t.forEach(n=>n.dispose()):t.dispose())},Rt=t=>{if(t){for(;t.children.length>0;){const n=t.children[0];n instanceof c.PositionalAudio?(n.pause(),n.parent&&n.parent.remove(n)):Rt(n)}if(t.parent&&t.parent.remove(t),t.isMesh){const n=t;n.geometry?.dispose(),Qt(n.material)}t.dispose!==void 0&&t.dispose()}};class jn{components=new Map;listen;_debugEnabled;broadcastChannel=void 0;webSocket=void 0;_mode="app";_connected=!1;useBC=!1;constructor(n,a,e=!0,o="editor"){this.editor=a&&document.location.hash.search(o)>-1,this._debugEnabled=a,a&&(this.useBC=e,e?(this.broadcastChannel=new BroadcastChannel(n),this.broadcastChannel.addEventListener("message",this.messageHandler)):(this.webSocket=new WebSocket(n),this.webSocket.addEventListener("open",this.openHandler),this.webSocket.addEventListener("close",this.closeHandler),this.webSocket.addEventListener("message",this.messageHandler)))}addComponent(n,a){this.components.set(n,a)}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(n=>{n.dispose()}),this.components.clear()}send(n){this._mode!==n.target&&(this.useBC?this.broadcastChannel?.postMessage(n):this._connected&&this.webSocket?.send(JSON.stringify(n)))}messageHandler=n=>{this.listen!==void 0&&(this.useBC?this.listen(n.data):this.listen(JSON.parse(n.data)))};openHandler=()=>{this._connected=!0};closeHandler=()=>{this._connected=!1};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(n){n&&(this._mode="editor",document.title+=" - Editor")}}const D=new c.EventDispatcher,I={CUSTOM:"ToolEvents::custom",SELECT_DROPDOWN:"ToolEvents::selectDropdown",DRAG_UPDATE:"ToolEvents::dragUpdate",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"};class Xe{app;constructor(n){this.app=n}dispose(){}}class qt extends Xe{selectDropdown(n,a){this.app.send({event:"selectComponent",target:"app",data:{dropdown:n,value:a}})}updateDropdown(n,a){this.app.send({event:"draggableListUpdate",target:"app",data:{dropdown:n,value:a}})}}function Dn(t,n){switch(n.event){case"selectComponent":D.dispatchEvent({type:I.SELECT_DROPDOWN,value:n.data});break;case"draggableListUpdate":D.dispatchEvent({type:I.DRAG_UPDATE,value:n.data});break}}const $t=()=>{};class ve extends Xe{project;sheets=new Map;sheetObjects=new Map;sheetObjectCBs=new Map;sheetObjectUnsubscribe=new Map;static rafDriver=null;init(n,a){return this.project=Gt.getProject(n,a),this.project.ready}dispose(){this.project=void 0,this.sheets=new Map,this.sheetObjects=new Map,this.sheetObjectCBs=new Map,this.sheetObjectUnsubscribe=new Map}sheet(n){if(this.project===void 0){console.error("Theatre Project hasn't been created yet.");return}let a=this.sheets.get(n);return a!==void 0||(a=this.project?.sheet(n),this.sheets.set(n,a)),a}playSheet(n,a){this.sheet(n)?.sequence.play(a),this.app.send({event:"playSheet",target:"editor",data:{sheet:n,value:a}})}pauseSheet(n){this.sheet(n)?.sequence.pause(),this.app.send({event:"pauseSheet",target:"editor",data:{sheet:n}})}clearSheetObjects(n){this.sheetObjects.forEach((a,e)=>{e.search(`${n}_`)>-1&&this.unsubscribe(a)})}sheetObject(n,a,e,o){if(this.project===void 0){console.error("Theatre Project hasn't been created yet.");return}const s=this.sheet(n);if(s===void 0)return;const m=`${n}_${a}`;let l=this.sheetObjects.get(m);l!==void 0?l=s.object(a,{...e,...l.value},{reconfigure:!0}):l=s.object(a,e),this.sheetObjects.set(m,l),this.sheetObjectCBs.set(m,o!==void 0?o:$t);const d=l.onValuesChange(f=>{if(this.app.editor){for(const y in f){const C=f[y];typeof C=="object"&&Xt(C)&&(f[y]={r:C.r,g:C.g,b:C.b,a:C.a})}this.app.send({event:"updateSheetObject",target:"app",data:{sheet:n,sheetObject:m,values:f}})}const g=this.sheetObjectCBs.get(m);g!==void 0&&g(f)});return this.sheetObjectUnsubscribe.set(m,d),l}unsubscribe(n){if(this.project===void 0){console.error("Theatre Project hasn't been created yet.");return}const a=n.address.sheetId,e=n.address.objectKey;this.sheets.get(a)?.detachObject(e);const s=`${a}_${e}`,m=this.sheetObjectUnsubscribe.get(s);m!==void 0&&(this.sheetObjects.delete(s),this.sheetObjectCBs.delete(s),this.sheetObjectUnsubscribe.delete(s),m())}static getRafDriver(){return ve.rafDriver||(ve.rafDriver=Gt.createRafDriver()),ve.rafDriver}}let Ee;function In(t,n){t.components.forEach(a=>{if(a instanceof ve){let e;const o=a;switch(n.event){case"setSheet":e=o.sheets.get(n.data.sheet),e!==void 0&&(Ee=e,Ke.setSelection([e]));break;case"setSheetObject":e=o.sheetObjects.get(`${n.data.sheet}_${n.data.key}`),e!==void 0&&Ke.setSelection([e]);break;case"updateSheetObject":e=o.sheets.get(n.data.sheet),e!==void 0&&e.sequence.pause(),e=o.sheetObjectCBs.get(n.data.sheetObject),e!==void 0&&e(n.data.values);break;case"updateTimeline":e=o.sheets.get(n.data.sheet),Ee!==void 0&&(Ee.sequence.position=n.data.position);break}}})}function Nn(t){if(t.editor){let n;t.components.forEach(s=>{s instanceof ve&&(n=s)}),Ke.ui.restore(),Ke.onSelectionChange(s=>{s.length<1||s.forEach(m=>{let l=m.address.sheetId,d="setSheet",f={};switch(m.type){case"Theatre_Sheet_PublicAPI":d="setSheet",f={sheet:m.address.sheetId},Ee=n.sheets.get(m.address.sheetId);break;case"Theatre_SheetObject_PublicAPI":d="setSheetObject",l+=`_${m.address.objectKey}`,f={id:l,sheet:m.address.sheetId,key:m.address.objectKey};break}t.send({event:d,target:"app",data:f})})});let a=0;const e=()=>{if(Ee!==void 0&&a!==Ee.sequence.position){a=Ee.sequence.position;const s=Ee;t.send({event:"updateTimeline",target:"app",data:{position:a,sheet:s.address.sheetId}})}},o=()=>{e(),requestAnimationFrame(o)};e(),o()}else Ke.ui.hide()}function Ln(t,n){t.editor&&t.components.forEach(a=>{if(a instanceof ve){const e=a;switch(n.event){case"playSheet":e.sheet(n.data.sheet)?.sequence.play(n.data.value);break;case"pauseSheet":e.sheet(n.data.sheet)?.sequence.pause();break}return}})}function Fn(t){if(t.name==="cameras")return"camera";if(t.name==="interactive")return"interactive";if(t.name==="lights")return"light";if(t.name==="ui")return"ui";if(t.name==="utils")return"utils";const n=t.type;return n.search("Helper")>-1?"icon_utils":n.search("Camera")>-1?"camera":n.search("Light")>-1?"light":"obj3D"}function en(t){const n={name:t.name,type:t.type,uuid:t.uuid,children:[]};return t.children.forEach(a=>{n.children.push(en(a))}),n}function Un(t){const n={};for(const a in t){const e=t[a].value;n[a]={value:e},e===null?n[a].value={src:""}:e.isTexture&&(n[a].value={src:e.image.src})}return n}function Bn(t){switch(t){case"blendSrcAlpha":case"blendDstAlpha":case"blendEquationAlpha":case"clippingPlanes":case"shadowSide":case"precision":return!0}return!1}function Ve(t){const n={};for(const a in t){if(a.substring(0,1)==="_"||a.substring(0,2)==="is"||Bn(a))continue;const e=typeof t[a],o=t[a];switch(e){case"boolean":case"number":case"string":n[a]=o;break;case"object":if(o!==null)if(n[a]=o,o.isTexture)if(o instanceof c.Texture){const s=o.source.toJSON();n[a]={src:s.url}}else o instanceof c.CubeTexture&&(console.log("env map"),console.log(o.source.data),console.log(o.source.toJSON()),n[a]={src:""});else a==="uniforms"&&(n[a]=Un(n[a]));else n[a]={src:""};break}}return n}function At(t){t.updateMatrix();const n={name:t.name,type:t.type,uuid:t.uuid,visible:t.visible,matrix:t.matrix.elements,animations:[],material:void 0,perspectiveCameraInfo:void 0,orthographicCameraInfo:void 0,lightInfo:void 0};t.animations.forEach(e=>{n.animations.push({name:e.name,duration:e.duration,blendMode:e.blendMode})});const a=t.type.toLowerCase();if(a.search("mesh")>-1){const e=t;if(Array.isArray(e.material)){const o=[];e.material.forEach(s=>{o.push(Ve(s))}),n.material=o}else n.material=Ve(e.material)}else if(a.search("points")>-1){const e=t;if(Array.isArray(e.material)){const o=[];e.material.forEach(s=>{o.push(Ve(s))}),n.material=o}else n.material=Ve(e.material)}else if(a.search("line")>-1){const e=t;if(Array.isArray(e.material)){const o=[];e.material.forEach(s=>{o.push(Ve(s))}),n.material=o}else n.material=Ve(e.material)}else a.search("camera")>-1?t.type==="PerspectiveCamera"?n.perspectiveCameraInfo={fov:t.fov,zoom:t.zoom,near:t.near,far:t.far,focus:t.focus,aspect:t.aspect,filmGauge:t.filmGauge,filmOffset:t.filmOffset}:t.type==="OrthographicCamera"&&(n.orthographicCameraInfo={zoom:t.zoom,near:t.near,far:t.far,left:t.left,right:t.right,top:t.top,bottom:t.bottom}):a.search("light")>-1&&(n.lightInfo={color:t.color,intensity:t.intensity,decay:t.decay,distance:t.distance,angle:t.angle,penumbra:t.penumbra,groundColor:t.groundColor});return n}function Vn(t,n){const a=n.split(".");switch(a.length){case 1:return t[a[0]];case 2:return t[a[0]][a[1]];case 3:return t[a[0]][a[1]][a[2]];case 4:return t[a[0]][a[1]][a[2]][a[3]];case 5:return t[a[0]][a[1]][a[2]][a[3]][a[4]];case 6:return t[a[0]][a[1]][a[2]][a[3]][a[4]][a[5]]}}function ne(t,n,a){const e=n.split(".");switch(e.length){case 1:t[e[0]]=a;break;case 2:t[e[0]][e[1]]=a;break;case 3:t[e[0]][e[1]][e[2]]=a;break;case 4:t[e[0]][e[1]][e[2]][e[3]]=a;break;case 5:t[e[0]][e[1]][e[2]][e[3]][e[4]]=a;break}}function Pt(t){return new Promise((n,a)=>{const e=new Image;e.onload=()=>{const o=new c.Texture(e);o.wrapS=c.RepeatWrapping,o.wrapT=c.RepeatWrapping,o.needsUpdate=!0,n(o)},e.onerror=a,e.src=t})}class tn extends Xe{scene=void 0;getObject(n){this.app.debugEnabled&&this.app.send({event:"getObject",target:"app",data:n})}setObject(n){const a=At(n);this.app.send({event:"setObject",target:"editor",data:a})}requestMethod(n,a,e,o){this.app.send({event:"requestMethod",target:"app",data:{uuid:n,key:a,value:e,subitem:o}})}updateObject(n,a,e){this.app.send({event:"updateObject",target:"app",data:{uuid:n,key:a,value:e}})}createTexture(n,a,e){this.app.send({event:"createTexture",target:"app",data:{uuid:n,key:a,value:e}})}setScene(n){if(n===void 0||(this.scene=n,!this.app.debugEnabled))return;Jt(),Tt(this.scene);const a=en(this.scene);this.app.send({event:"setScene",target:"editor",data:a})}addCamera(n){if(!this.app.debugEnabled)return;const a=At(n);this.app.send({event:"addCamera",target:"editor",data:a})}removeCamera(n){if(!this.app.debugEnabled)return;const a=At(n);this.app.send({event:"removeCamera",target:"editor",data:a})}}function zn(t,n){switch(n.event){case"getObject":D.dispatchEvent({type:I.GET_OBJECT,value:n.data});break;case"updateObject":D.dispatchEvent({type:I.UPDATE_OBJECT,value:n.data});break;case"createTexture":D.dispatchEvent({type:I.CREATE_TEXTURE,value:n.data});break;case"requestMethod":D.dispatchEvent({type:I.REQUEST_METHOD,value:n.data});break}}function Hn(t,n){switch(n.event){case"setObject":D.dispatchEvent({type:I.SET_OBJECT,value:n.data});break;case"setScene":D.dispatchEvent({type:I.SET_SCENE,value:n.data});break;case"addCamera":D.dispatchEvent({type:I.ADD_CAMERA,value:n.data});break;case"removeCamera":D.dispatchEvent({type:I.REMOVE_CAMERA,value:n.data});break}}class kt extends Xe{bindCBs;buttonCBs;pane=void 0;appCallbacks=0;editorCallbacks=0;inspectorFolder=void 0;constructor(n){super(n),this.bindCBs=new Map,this.buttonCBs=new Map,n.editor&&this.createGUI()}createGUI(){this.pane=new Mn.Pane({title:"GUI"}),this.pane.registerPlugin(An)}dispose(){this.bindCBs.clear(),this.buttonCBs.clear(),this.appCallbacks=0,this.editorCallbacks=0,this.app.editor&&(this.pane?.dispose(),this.pane=void 0)}addFolder(n,a=void 0,e=void 0){if(this.app.editor)return this.pane===void 0&&this.createGUI(),(e!==void 0?e:this.pane).addFolder({title:n,...a});this.app.send({event:"addFolder",target:"app",data:{name:n,params:a,parent:e}})}get bindID(){return`debug_${Math.max(this.appCallbacks,this.editorCallbacks)}`}bind(n,a,e,o=void 0){const s=this.bindID,m=e.onChange!==void 0?e.onChange:$t;this.bindCBs.set(s,m),this.app.editor?(this.pane===void 0&&this.createGUI(),(o!==void 0?o:this.pane).addBinding(n,a,e).on("change",d=>{this.app.send({event:"updateBind",target:"app",data:{id:s,value:d.value}})}),this.editorCallbacks++):(this.app.send({event:"bindObject",target:"app",data:{id:s,name:a,params:e,parent:o}}),this.appCallbacks++)}triggerBind(n,a){const e=this.bindCBs.get(n);e!==void 0?e(a):console.warn(`No callback for: ${n}`,a)}button(n,a,e=void 0){const o=this.bindID;this.buttonCBs.set(o,a),this.app.editor?(this.pane===void 0&&this.createGUI(),(e!==void 0?e:this.pane).addButton({title:n}).on("click",()=>{this.app.send({event:"clickButton",target:"app",data:{id:o}})}),this.editorCallbacks++):(this.app.send({event:"addButton",target:"app",data:{id:o,name:n,callback:a,parent:e}}),this.appCallbacks++)}triggerButton(n){const a=this.buttonCBs.get(n);a!==void 0&&a()}createInspector(){this.inspectorFolder=this.addFolder("Inspector",this.pane)}clearInspector(){const n=this.inspectorFolder.children.length-1;for(let a=n;a>-1;--a)this.inspectorFolder.remove(this.inspectorFolder.children[a])}}function Yn(t,n){t.components.forEach(a=>{if(a instanceof kt){const e=a;switch(n.event){case"addFolder":e.addFolder(n.data.name,n.data.params,n.data.parent);break;case"bindObject":e.bind(n.data.name,n.data.params,n.data.parent);break;case"updateBind":e.triggerBind(n.data.id,n.data.value);break;case"addButton":e.button(n.data.name,n.data.callback,n.data.parent);break;case"clickButton":e.triggerButton(n.data.id);break}return}})}var _t={exports:{}},Ze={};/**
|
2
|
-
* @license React
|
3
|
-
* react-jsx-runtime.production.min.js
|
4
|
-
*
|
5
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
6
|
-
*
|
7
|
-
* This source code is licensed under the MIT license found in the
|
8
|
-
* LICENSE file in the root directory of this source tree.
|
9
|
-
*/var nn;function Gn(){if(nn)return Ze;nn=1;var t=A,n=Symbol.for("react.element"),a=Symbol.for("react.fragment"),e=Object.prototype.hasOwnProperty,o=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,s={key:!0,ref:!0,__self:!0,__source:!0};function m(l,d,f){var g,y={},C=null,O=null;f!==void 0&&(C=""+f),d.key!==void 0&&(C=""+d.key),d.ref!==void 0&&(O=d.ref);for(g in d)e.call(d,g)&&!s.hasOwnProperty(g)&&(y[g]=d[g]);if(l&&l.defaultProps)for(g in d=l.defaultProps,d)y[g]===void 0&&(y[g]=d[g]);return{$$typeof:n,type:l,key:C,ref:O,props:y,_owner:o.current}}return Ze.Fragment=a,Ze.jsx=m,Ze.jsxs=m,Ze}var Je={};/**
|
10
|
-
* @license React
|
11
|
-
* react-jsx-runtime.development.js
|
12
|
-
*
|
13
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
14
|
-
*
|
15
|
-
* This source code is licensed under the MIT license found in the
|
16
|
-
* LICENSE file in the root directory of this source tree.
|
17
|
-
*/var an;function Wn(){return an||(an=1,process.env.NODE_ENV!=="production"&&function(){var t=A,n=Symbol.for("react.element"),a=Symbol.for("react.portal"),e=Symbol.for("react.fragment"),o=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),m=Symbol.for("react.provider"),l=Symbol.for("react.context"),d=Symbol.for("react.forward_ref"),f=Symbol.for("react.suspense"),g=Symbol.for("react.suspense_list"),y=Symbol.for("react.memo"),C=Symbol.for("react.lazy"),O=Symbol.for("react.offscreen"),R=Symbol.iterator,N="@@iterator";function Z(i){if(i===null||typeof i!="object")return null;var h=R&&i[R]||i[N];return typeof h=="function"?h:null}var z=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function x(i){{for(var h=arguments.length,b=new Array(h>1?h-1:0),w=1;w<h;w++)b[w-1]=arguments[w];G("error",i,b)}}function G(i,h,b){{var w=z.ReactDebugCurrentFrame,L=w.getStackAddendum();L!==""&&(h+="%s",b=b.concat([L]));var V=b.map(function(j){return String(j)});V.unshift("Warning: "+h),Function.prototype.apply.call(console[i],console,V)}}var Ce=!1,ue=!1,ce=!1,p=!1,v=!1,M;M=Symbol.for("react.module.reference");function _(i){return!!(typeof i=="string"||typeof i=="function"||i===e||i===s||v||i===o||i===f||i===g||p||i===O||Ce||ue||ce||typeof i=="object"&&i!==null&&(i.$$typeof===C||i.$$typeof===y||i.$$typeof===m||i.$$typeof===l||i.$$typeof===d||i.$$typeof===M||i.getModuleId!==void 0))}function W(i,h,b){var w=i.displayName;if(w)return w;var L=h.displayName||h.name||"";return L!==""?b+"("+L+")":b}function H(i){return i.displayName||"Context"}function Y(i){if(i==null)return null;if(typeof i.tag=="number"&&x("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof i=="function")return i.displayName||i.name||null;if(typeof i=="string")return i;switch(i){case e:return"Fragment";case a:return"Portal";case s:return"Profiler";case o:return"StrictMode";case f:return"Suspense";case g:return"SuspenseList"}if(typeof i=="object")switch(i.$$typeof){case l:var h=i;return H(h)+".Consumer";case m:var b=i;return H(b._context)+".Provider";case d:return W(i,i.render,"ForwardRef");case y:var w=i.displayName||null;return w!==null?w:Y(i.type)||"Memo";case C:{var L=i,V=L._payload,j=L._init;try{return Y(j(V))}catch{return null}}}return null}var F=Object.assign,J=0,Q,P,B,ee,me,Se,vt;function tt(){}tt.__reactDisabledLog=!0;function Lt(){{if(J===0){Q=console.log,P=console.info,B=console.warn,ee=console.error,me=console.group,Se=console.groupCollapsed,vt=console.groupEnd;var i={configurable:!0,enumerable:!0,value:tt,writable:!0};Object.defineProperties(console,{info:i,log:i,warn:i,error:i,group:i,groupCollapsed:i,groupEnd:i})}J++}}function Ft(){{if(J--,J===0){var i={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:F({},i,{value:Q}),info:F({},i,{value:P}),warn:F({},i,{value:B}),error:F({},i,{value:ee}),group:F({},i,{value:me}),groupCollapsed:F({},i,{value:Se}),groupEnd:F({},i,{value:vt})})}J<0&&x("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var nt=z.ReactCurrentDispatcher,at;function He(i,h,b){{if(at===void 0)try{throw Error()}catch(L){var w=L.stack.trim().match(/\n( *(at )?)/);at=w&&w[1]||""}return`
|
18
|
-
`+at+i}}var Ye=!1,ke;{var gt=typeof WeakMap=="function"?WeakMap:Map;ke=new gt}function bt(i,h){if(!i||Ye)return"";{var b=ke.get(i);if(b!==void 0)return b}var w;Ye=!0;var L=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var V;V=nt.current,nt.current=null,Lt();try{if(h){var j=function(){throw Error()};if(Object.defineProperty(j.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(j,[])}catch(ye){w=ye}Reflect.construct(i,[],j)}else{try{j.call()}catch(ye){w=ye}i.call(j.prototype)}}else{try{throw Error()}catch(ye){w=ye}i()}}catch(ye){if(ye&&w&&typeof ye.stack=="string"){for(var k=ye.stack.split(`
|
19
|
-
`),le=w.stack.split(`
|
20
|
-
`),$=k.length-1,te=le.length-1;$>=1&&te>=0&&k[$]!==le[te];)te--;for(;$>=1&&te>=0;$--,te--)if(k[$]!==le[te]){if($!==1||te!==1)do if($--,te--,te<0||k[$]!==le[te]){var pe=`
|
21
|
-
`+k[$].replace(" at new "," at ");return i.displayName&&pe.includes("<anonymous>")&&(pe=pe.replace("<anonymous>",i.displayName)),typeof i=="function"&&ke.set(i,pe),pe}while($>=1&&te>=0);break}}}finally{Ye=!1,nt.current=V,Ft(),Error.prepareStackTrace=L}var We=i?i.displayName||i.name:"",xn=We?He(We):"";return typeof i=="function"&&ke.set(i,xn),xn}function Ut(i,h,b){return bt(i,!1)}function yt(i){var h=i.prototype;return!!(h&&h.isReactComponent)}function _e(i,h,b){if(i==null)return"";if(typeof i=="function")return bt(i,yt(i));if(typeof i=="string")return He(i);switch(i){case f:return He("Suspense");case g:return He("SuspenseList")}if(typeof i=="object")switch(i.$$typeof){case d:return Ut(i.render);case y:return _e(i.type,h,b);case C:{var w=i,L=w._payload,V=w._init;try{return _e(V(L),h,b)}catch{}}}return""}var je=Object.prototype.hasOwnProperty,Et={},Ct=z.ReactDebugCurrentFrame;function De(i){if(i){var h=i._owner,b=_e(i.type,i._source,h?h.type:null);Ct.setExtraStackFrame(b)}else Ct.setExtraStackFrame(null)}function it(i,h,b,w,L){{var V=Function.call.bind(je);for(var j in i)if(V(i,j)){var k=void 0;try{if(typeof i[j]!="function"){var le=Error((w||"React class")+": "+b+" type `"+j+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof i[j]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw le.name="Invariant Violation",le}k=i[j](h,j,w,b,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch($){k=$}k&&!(k instanceof Error)&&(De(L),x("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",w||"React class",b,j,typeof k),De(null)),k instanceof Error&&!(k.message in Et)&&(Et[k.message]=!0,De(L),x("Failed %s type: %s",b,k.message),De(null))}}}var Ie=Array.isArray;function rt(i){return Ie(i)}function Bt(i){{var h=typeof Symbol=="function"&&Symbol.toStringTag,b=h&&i[Symbol.toStringTag]||i.constructor.name||"Object";return b}}function St(i){try{return wt(i),!1}catch{return!0}}function wt(i){return""+i}function Ot(i){if(St(i))return x("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",Bt(i)),wt(i)}var we=z.ReactCurrentOwner,ot={key:!0,ref:!0,__self:!0,__source:!0},st,xt,Ge;Ge={};function Vt(i){if(je.call(i,"ref")){var h=Object.getOwnPropertyDescriptor(i,"ref").get;if(h&&h.isReactWarning)return!1}return i.ref!==void 0}function zt(i){if(je.call(i,"key")){var h=Object.getOwnPropertyDescriptor(i,"key").get;if(h&&h.isReactWarning)return!1}return i.key!==void 0}function Mt(i,h){if(typeof i.ref=="string"&&we.current&&h&&we.current.stateNode!==h){var b=Y(we.current.type);Ge[b]||(x('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref',Y(we.current.type),i.ref),Ge[b]=!0)}}function Oe(i,h){{var b=function(){st||(st=!0,x("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",h))};b.isReactWarning=!0,Object.defineProperty(i,"key",{get:b,configurable:!0})}}function On(i,h){{var b=function(){xt||(xt=!0,x("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",h))};b.isReactWarning=!0,Object.defineProperty(i,"ref",{get:b,configurable:!0})}}var r=function(i,h,b,w,L,V,j){var k={$$typeof:n,type:i,key:h,ref:b,props:j,_owner:V};return k._store={},Object.defineProperty(k._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(k,"_self",{configurable:!1,enumerable:!1,writable:!1,value:w}),Object.defineProperty(k,"_source",{configurable:!1,enumerable:!1,writable:!1,value:L}),Object.freeze&&(Object.freeze(k.props),Object.freeze(k)),k};function E(i,h,b,w,L){{var V,j={},k=null,le=null;b!==void 0&&(Ot(b),k=""+b),zt(h)&&(Ot(h.key),k=""+h.key),Vt(h)&&(le=h.ref,Mt(h,L));for(V in h)je.call(h,V)&&!ot.hasOwnProperty(V)&&(j[V]=h[V]);if(i&&i.defaultProps){var $=i.defaultProps;for(V in $)j[V]===void 0&&(j[V]=$[V])}if(k||le){var te=typeof i=="function"?i.displayName||i.name||"Unknown":i;k&&Oe(j,te),le&&On(j,te)}return r(i,k,le,L,w,we.current,j)}}var T=z.ReactCurrentOwner,U=z.ReactDebugCurrentFrame;function q(i){if(i){var h=i._owner,b=_e(i.type,i._source,h?h.type:null);U.setExtraStackFrame(b)}else U.setExtraStackFrame(null)}var de;de=!1;function se(i){return typeof i=="object"&&i!==null&&i.$$typeof===n}function Ht(){{if(T.current){var i=Y(T.current.type);if(i)return`
|
22
|
-
|
23
|
-
Check the render method of \``+i+"`."}return""}}function Yt(i){{if(i!==void 0){var h=i.fileName.replace(/^.*[\\\/]/,""),b=i.lineNumber;return`
|
24
|
-
|
25
|
-
Check your code at `+h+":"+b+"."}return""}}var ct={};function he(i){{var h=Ht();if(!h){var b=typeof i=="string"?i:i.displayName||i.name;b&&(h=`
|
26
|
-
|
27
|
-
Check the top-level render call using <`+b+">.")}return h}}function fe(i,h){{if(!i._store||i._store.validated||i.key!=null)return;i._store.validated=!0;var b=he(h);if(ct[b])return;ct[b]=!0;var w="";i&&i._owner&&i._owner!==T.current&&(w=" It was passed a child from "+Y(i._owner.type)+"."),q(i),x('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',b,w),q(null)}}function Ne(i,h){{if(typeof i!="object")return;if(rt(i))for(var b=0;b<i.length;b++){var w=i[b];se(w)&&fe(w,h)}else if(se(i))i._store&&(i._store.validated=!0);else if(i){var L=Z(i);if(typeof L=="function"&&L!==i.entries)for(var V=L.call(i),j;!(j=V.next()).done;)se(j.value)&&fe(j.value,h)}}}function Le(i){{var h=i.type;if(h==null||typeof h=="string")return;var b;if(typeof h=="function")b=h.propTypes;else if(typeof h=="object"&&(h.$$typeof===d||h.$$typeof===y))b=h.propTypes;else return;if(b){var w=Y(h);it(b,i.props,"prop",w,i)}else if(h.PropTypes!==void 0&&!de){de=!0;var L=Y(h);x("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",L||"Unknown")}typeof h.getDefaultProps=="function"&&!h.getDefaultProps.isReactClassApproved&&x("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function Fe(i){{for(var h=Object.keys(i.props),b=0;b<h.length;b++){var w=h[b];if(w!=="children"&&w!=="key"){q(i),x("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",w),q(null);break}}i.ref!==null&&(q(i),x("Invalid attribute `ref` supplied to `React.Fragment`."),q(null))}}function Ue(i,h,b,w,L,V){{var j=_(i);if(!j){var k="";(i===void 0||typeof i=="object"&&i!==null&&Object.keys(i).length===0)&&(k+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var le=Yt(L);le?k+=le:k+=Ht();var $;i===null?$="null":rt(i)?$="array":i!==void 0&&i.$$typeof===n?($="<"+(Y(i.type)||"Unknown")+" />",k=" Did you accidentally export a JSX literal instead of a component?"):$=typeof i,x("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",$,k)}var te=E(i,h,b,L,V);if(te==null)return te;if(j){var pe=h.children;if(pe!==void 0)if(w)if(rt(pe)){for(var We=0;We<pe.length;We++)Ne(pe[We],i);Object.freeze&&Object.freeze(pe)}else x("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else Ne(pe,i)}return i===e?Fe(te):Le(te),te}}function Pa(i,h,b){return Ue(i,h,b,!0)}function ka(i,h,b){return Ue(i,h,b,!1)}var _a=ka,ja=Pa;Je.Fragment=e,Je.jsx=_a,Je.jsxs=ja}()),Je}process.env.NODE_ENV==="production"?_t.exports=Gn():_t.exports=Wn();var u=_t.exports;function jt(t){return t.title.search("<")>-1?u.jsx("button",{className:"svg",dangerouslySetInnerHTML:{__html:t.title}}):u.jsx("button",{children:t.title})}const Kn=u.jsxs("svg",{className:"closeIcon",width:"14",height:"14",fill:"none",stroke:"#666666",strokeMiterlimit:"10",children:[u.jsx("circle",{cx:"7",cy:"7",r:"6"}),u.jsx("line",{x1:"4",y1:"4",x2:"10",y2:"10"}),u.jsx("line",{x1:"4",y1:"10",x2:"10",y2:"4"})]}),Xn=u.jsx("svg",{className:"dragIcon",width:"14",height:"14",fill:"#666666",stroke:"none",children:u.jsx("path",{d:`M10.43,4H3.57C3.26,4,3,4.22,3,4.5v1C3,5.78,3.26,6,3.57,6h6.86C10.74,6,11,5.78,11,5.5v-1
|
28
|
-
C11,4.22,10.74,4,10.43,4z M10.43,8H3.57C3.26,8,3,8.22,3,8.5v1C3,9.78,3.26,10,3.57,10h6.86C10.74,10,11,9.78,11,9.5v-1
|
29
|
-
C11,8.22,10.74,8,10.43,8z`})});function rn(t){return u.jsx(Wt.Reorder.Item,{value:t.title,children:u.jsxs("div",{children:[Xn,u.jsx("span",{children:t.title}),u.jsx("button",{className:"closeIcon",onClick:()=>{t.onDelete(t.index)},children:Kn})]})},t.title)}function on(t){const[n,a]=A.useState(!1),[e,o]=A.useState(t.options),s=f=>{t.onDragComplete(f),o(f)},m=f=>{const g=[...e];g.splice(f,1),s(g)},l=[];e.forEach((f,g)=>{l.push(u.jsx(rn,{index:g,title:f,onDelete:m},f))});let d="dropdown draggable";return t.subdropdown&&(d+=" subdropdown"),u.jsxs("div",{className:d,onMouseEnter:()=>a(!0),onMouseLeave:()=>a(!1),children:[u.jsx(jt,{title:t.title}),u.jsx(Wt.Reorder.Group,{axis:"y",values:e,onReorder:s,style:{visibility:n?"visible":"hidden"},children:l})]})}function sn(t){const[n,a]=A.useState(!1),e=[];t.options.map((s,m)=>{t.onSelect!==void 0&&(s.onSelect=t.onSelect),e.push(u.jsx(cn,{option:s},m))});let o="dropdown";return t.subdropdown&&(o+=" subdropdown"),u.jsxs("div",{className:o,onMouseEnter:()=>a(!0),onMouseLeave:()=>a(!1),children:[u.jsx(jt,{title:t.title}),u.jsx("ul",{style:{visibility:n?"visible":"hidden"},children:e})]})}function cn(t){const{option:n}=t,[a,e]=A.useState("");let o;switch(n.type){case"draggable":o=u.jsx(on,{title:n.title,options:n.value,onDragComplete:s=>{n.onDragComplete!==void 0&&n.onDragComplete(s)},subdropdown:!0});break;case"dropdown":o=u.jsx(sn,{title:n.title,options:n.value,onSelect:n.onSelect,subdropdown:!0});break;case"option":o=u.jsx("button",{onClick:()=>{n.onSelect!==void 0&&n.onSelect(n.value),n.selectable&&(a!==n.title?e(n.title):e(""))},children:n.title});break}return u.jsx("li",{className:a===n.title?"selected":"",children:o},Kt())}function Zn(t){const n=[],a=[];t.components.forEach(s=>{s instanceof qt?n.push(Dn):s instanceof ve?(n.push(In),a.push(Ln),Nn(t)):s instanceof tn?(n.push(zn),a.push(Hn)):s instanceof kt&&n.push(Yn)});function e(s){switch(n.forEach(m=>m(t,s)),s.event){case"custom":D.dispatchEvent({type:I.CUSTOM,value:s.data});break}}function o(s){switch(a.forEach(m=>m(t,s)),s.event){case"custom":D.dispatchEvent({type:I.CUSTOM,value:s.data});break}}t.listen=s=>{s.target==="editor"?o(s):e(s)}}const Jn=`out vec3 worldPosition;
|
30
|
-
uniform float uDistance;
|
31
|
-
|
32
|
-
void main() {
|
33
|
-
// Scale the plane by the drawing distance
|
34
|
-
worldPosition = position.xzy * uDistance;
|
35
|
-
worldPosition.xz += cameraPosition.xz;
|
36
|
-
|
37
|
-
gl_Position = projectionMatrix * modelViewMatrix * vec4(worldPosition, 1.0);
|
38
|
-
}`,Qn=`out vec4 fragColor;
|
39
|
-
in vec3 worldPosition;
|
40
|
-
|
41
|
-
uniform float uDivisions;
|
42
|
-
uniform float uScale;
|
43
|
-
uniform vec3 uColor;
|
44
|
-
uniform float uDistance;
|
45
|
-
uniform float uSubgridOpacity;
|
46
|
-
uniform float uGridOpacity;
|
47
|
-
|
48
|
-
float getGrid(float gapSize) {
|
49
|
-
vec2 worldPositionByDivision = worldPosition.xz / gapSize;
|
50
|
-
|
51
|
-
// Inverted, 0 where line, >1 where there's no line
|
52
|
-
// We use the worldPosition (which in this case we use similarly to UVs) differential to control the anti-aliasing
|
53
|
-
// We need to do the -0.5)-0.5 trick because the result fades out from 0 to 1, and we want both
|
54
|
-
// worldPositionByDivision == 0.3 and worldPositionByDivision == 0.7 to result in the same fade, i.e. 0.3,
|
55
|
-
// otherwise only one side of the line will be anti-aliased
|
56
|
-
vec2 grid = abs(fract(worldPositionByDivision-0.5)-0.5) / fwidth(worldPositionByDivision) / 2.0;
|
57
|
-
float gridLine = min(grid.x, grid.y);
|
58
|
-
|
59
|
-
// Uninvert and clamp
|
60
|
-
return 1.0 - min(gridLine, 1.0);
|
61
|
-
}
|
62
|
-
|
63
|
-
void main() {
|
64
|
-
float cameraDistanceToGridPlane = distance(cameraPosition.y, worldPosition.y);
|
65
|
-
float cameraDistanceToFragmentOnGridPlane = distance(cameraPosition.xz, worldPosition.xz);
|
66
|
-
|
67
|
-
// The size of the grid and subgrid are powers of each other and they are determined based on camera distance.
|
68
|
-
// The current grid will become the next subgrid when it becomes too small, and its next power becomes the new grid.
|
69
|
-
float subGridPower = pow(uDivisions, floor(log(cameraDistanceToGridPlane) / log(uDivisions)));
|
70
|
-
float gridPower = subGridPower * uDivisions;
|
71
|
-
|
72
|
-
// If we want to fade both the grid and its subgrid, we need to displays 3 different opacities, with the next grid being the third
|
73
|
-
float nextGridPower = gridPower * uDivisions;
|
74
|
-
|
75
|
-
// 1 where grid, 0 where no grid
|
76
|
-
float subgrid = getGrid(subGridPower * uScale);
|
77
|
-
float grid = getGrid(gridPower * uScale);
|
78
|
-
float nextGrid = getGrid(nextGridPower * uScale);
|
79
|
-
|
80
|
-
// Where we are between the introduction of the current grid power and when we switch to the next grid power
|
81
|
-
float stepPercentage = (cameraDistanceToGridPlane - subGridPower)/(gridPower - subGridPower);
|
82
|
-
|
83
|
-
// The last x percentage of the current step over which we want to fade
|
84
|
-
float fadeRange = 0.3;
|
85
|
-
|
86
|
-
// We calculate the fade percentage from the step percentage and the fade range
|
87
|
-
float fadePercentage = max(stepPercentage - 1.0 + fadeRange, 0.0) / fadeRange;
|
88
|
-
|
89
|
-
// Set base opacity based on how close we are to the drawing distance, with a cubic falloff
|
90
|
-
float baseOpacity = subgrid * pow(1.0 - min(cameraDistanceToFragmentOnGridPlane / uDistance, 1.0), 3.0);
|
91
|
-
|
92
|
-
// Shade the subgrid
|
93
|
-
fragColor = vec4(uColor.rgb, (baseOpacity - fadePercentage) * uSubgridOpacity);
|
94
|
-
|
95
|
-
// Somewhat arbitrary additional fade coefficient to counter anti-aliasing popping when switching between grid powers
|
96
|
-
float fadeCoefficient = 0.5;
|
97
|
-
|
98
|
-
// Shade the grid
|
99
|
-
fragColor.a = mix(fragColor.a, baseOpacity * uGridOpacity - fadePercentage * (uGridOpacity - uSubgridOpacity) * fadeCoefficient, grid);
|
100
|
-
|
101
|
-
// Shade the next grid
|
102
|
-
fragColor.a = mix(fragColor.a, baseOpacity * uGridOpacity, nextGrid);
|
103
|
-
|
104
|
-
if (fragColor.a <= 0.0) discard;
|
105
|
-
}`;class qn extends c.ShaderMaterial{constructor(n){super({extensions:{derivatives:!0},glslVersion:c.GLSL3,side:c.DoubleSide,transparent:!0,uniforms:{uScale:{value:n?.scale!==void 0?n?.scale:.1},uDivisions:{value:n?.divisions!==void 0?n?.divisions:10},uColor:{value:n?.color!==void 0?n?.color:new c.Color(16777215)},uDistance:{value:n?.distance!==void 0?n?.distance:1e4},uSubgridOpacity:{value:n?.subgridOpacity!==void 0?n?.subgridOpacity:.15},uGridOpacity:{value:n?.gridOpacity!==void 0?n?.gridOpacity:.25}},vertexShader:Jn,fragmentShader:Qn,name:"InfiniteGrid",depthWrite:!1})}}class ln extends c.Mesh{gridMaterial;constructor(){const n=new qn;super(new c.PlaneGeometry(2,2),n),this.gridMaterial=n,this.frustumCulled=!1,this.name="InfiniteGridHelper",this.position.y=.1}update(){this.gridMaterial.needsUpdate=!0}}const $n=`#include <common>
|
106
|
-
#include <batching_pars_vertex>
|
107
|
-
#include <uv_pars_vertex>
|
108
|
-
#include <color_pars_vertex>
|
109
|
-
#include <morphtarget_pars_vertex>
|
110
|
-
#include <skinning_pars_vertex>
|
111
|
-
#include <logdepthbuf_pars_vertex>
|
112
|
-
#include <clipping_planes_pars_vertex>
|
113
|
-
|
114
|
-
void main() {
|
115
|
-
#include <uv_vertex>
|
116
|
-
#include <color_vertex>
|
117
|
-
#include <morphcolor_vertex>
|
118
|
-
#include <batching_vertex>
|
119
|
-
|
120
|
-
#if defined ( USE_SKINNING )
|
121
|
-
#include <beginnormal_vertex>
|
122
|
-
#include <morphnormal_vertex>
|
123
|
-
#include <skinbase_vertex>
|
124
|
-
#include <skinnormal_vertex>
|
125
|
-
#include <defaultnormal_vertex>
|
126
|
-
#endif
|
127
|
-
|
128
|
-
#include <begin_vertex>
|
129
|
-
#include <morphtarget_vertex>
|
130
|
-
#include <skinning_vertex>
|
131
|
-
#include <project_vertex>
|
132
|
-
#include <logdepthbuf_vertex>
|
133
|
-
#include <clipping_planes_vertex>
|
134
|
-
#include <worldpos_vertex>
|
135
|
-
}`,ea=`
|
136
|
-
#include <common>
|
137
|
-
#include <uv_pars_fragment>
|
138
|
-
#include <clipping_planes_pars_fragment>
|
139
|
-
|
140
|
-
void main() {
|
141
|
-
#include <clipping_planes_fragment>
|
142
|
-
gl_FragColor = vec4(vec3(vUv, 0.0), 1.0);
|
143
|
-
}`;class un extends c.ShaderMaterial{constructor(){super({defines:{USE_UV:""},vertexShader:$n,fragmentShader:ea})}}const Da="";function ut(t){const[n,a]=A.useState(t.open!==void 0?t.open:!0),e=!n||t.children===void 0;return u.jsxs("div",{className:`accordion ${e?"hide":""}`,children:[u.jsxs("button",{className:"toggle",onClick:()=>{const o=!n;t.onToggle!==void 0&&t.onToggle(o),a(o)},children:[u.jsx("p",{className:`status ${n?"open":""}`,children:"Toggle"}),u.jsx("p",{className:"label",children:Be(t.label)})]}),t.button,u.jsx("div",{className:n?"open":"",children:u.jsx("div",{children:t.children})})]})}function Dt(t){const[n,a]=A.useState(!1),e=t.child.children.length>0,o=[];return t.child.children.length>0&&t.child.children.map(s=>{o.push(u.jsx(Dt,{child:s,three:t.three},Math.random()))}),u.jsxs("div",{className:"childObject",children:[u.jsxs("div",{className:"child",children:[e?u.jsx("button",{className:"status",style:{backgroundPositionX:n?"-14px":"2px"},onClick:()=>{a(!n)}}):null,u.jsx("button",{className:"name",style:{left:e?"20px":"5px"},onClick:()=>{t.three.getObject(t.child.uuid),n||a(!0)},children:t.child.name.length>0?`${t.child.name} (${t.child.type})`:`${t.child.type}::${t.child.uuid}`}),u.jsx("div",{className:`icon ${Fn(t.child)}`})]}),u.jsx("div",{className:n?"open":"",children:u.jsx("div",{className:"container",children:o})})]},Math.random())}function dn(t){const n=[];return t.child.children.map(a=>{n.push(u.jsx(Dt,{child:a,three:t.three},Math.random()))}),u.jsx("div",{className:`scene ${t.class!==void 0?t.class:""}`,children:n})}const Ia="",ta="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAACXBIWXMAAAsTAAALEwEAmpwYAAAA5klEQVRoge2Y0Q6EIAwE6cX//+X6cCFpSMEKVTdk501OpRNKiyelFC0b8Ps6gCwoggZF0KAIGhRBgyJoUAQNiqCxjciR9SLV//eZiAyvK3U8i/QVaQO2YyLSFVvlkdTKDjJCukh2ykR5ZEW+kHmlatl90RaBtDkK/w7CYhuRUEO0ee3l+J3m55Vm+17vtwjTnV1V3QA8qfbeUXCzRWDpiLLS+OyzvRW7IzW9R+okvclsqR09743bo0yUpc1+lSJvNsa002+Euk9GKzV7SmZDRIMiaFAEDYqgQRE0KIIGRdCgCBoUQeMEMERadX7YUz8AAAAASUVORK5CYII=";function na(t){return"items"in t}function xe(t){const n=[];return t.items.forEach(a=>{na(a)?n.push(u.jsx(xe,{title:Be(a.title),items:a.items},Math.random())):n.push(u.jsx(qe,{title:a.title,prop:a.prop,value:a.value,type:a.type,min:a.min,max:a.max,step:a.step,disabled:a.disabled,options:a.options,onChange:(e,o)=>{a.onChange!==void 0&&a.onChange(e,o)}},Math.random()))}),u.jsx(ut,{label:t.title,open:t.expanded===!0,children:n})}function aa(t){return!(t==="alphaHash"||t==="alphaToCoverage"||t==="attenuationDistance"||t==="blendDstAlpha"||t==="colorWrite"||t==="combine"||t==="defaultAttributeValues"||t==="depthFunc"||t==="forceSinglePass"||t==="glslVersion"||t==="linecap"||t==="linejoin"||t==="linewidth"||t==="normalMapType"||t==="precision"||t==="premultipliedAlpha"||t==="shadowSide"||t==="toneMapped"||t==="uniformsGroups"||t==="uniformsNeedUpdate"||t==="userData"||t==="vertexColors"||t==="version"||t==="wireframeLinecap"||t==="wireframeLinejoin"||t==="wireframeLinewidth"||t.slice(0,4)==="clip"||t.slice(0,7)==="polygon"||t.slice(0,7)==="stencil"||t.slice(0,2)==="is")}function Me(t){switch(t){case"alphaMap":return"Alpha Map";case"anisotropyMap":return"Anisotropy Map";case"anisotropyRotation":return"Anisotropy Rotation";case"aoMap":return"AO Map";case"aoMapIntensity":return"AO Map Intensity";case"attenuationColor":return"Attenuation Color";case"blendAlpha":return"Blend Alpha";case"blendColor":return"Blend Color";case"blendDst":return"Blend Dst";case"blendDstAlpha":return"Blend Dst Alha";case"blendEquation":return"Blend Equation";case"blendEquationAlpha":return"Blend Equation Alpha";case"blending":return"Blending";case"blendSrc":return"Blend Src";case"blendSrcAlpha":return"Blend Src Alpha";case"bumpMap":return"Bump Map";case"bumpScale":return"Bump Scale";case"clearcoatMap":return"Clearcoat Map";case"clearcoatNormalMap":return"Clearcoat Normal Map";case"clearcoatNormalScale":return"Clearcoat Normal Scale";case"clearcoatRoughness":return"Clearcoat Roughness";case"clearcoatRoughnessMap":return"Clearcoat Roughness Map";case"color":return"Color";case"defines":return"Defines";case"depthTest":return"Depth Test";case"depthWrite":return"Depth Write";case"displacementBias":return"Displacement Bias";case"displacementMap":return"Displacement Map";case"displacementScale":return"Displacement Scale";case"dithering":return"Dithering";case"emissive":return"Emissive";case"emissiveMap":return"Emissive Map";case"emissiveIntensity":return"Emissive Intensity";case"envMap":return"Environment Map";case"envMapIntensity":return"Environment Map Intensity";case"extensions":return"Extensions";case"flatShading":return"Flat Shading";case"fragmentShader":return"Fragment Shader";case"fog":return"Fog";case"gradientMap":return"Gradient Map";case"ior":return"IOR";case"iridescenceIOR":return"Iridescence IOR";case"iridescenceMap":return"Iridescence Map";case"iridescenceThicknessMap":return"Iridescence Thickness Map";case"iridescenceThicknessRange":return"Iridescence Thickness Range";case"lights":return"Lights";case"lightMap":return"Light Map";case"lightMapIntensity":return"Light Map Intensity";case"map":return"Map";case"matcap":return"Matcap";case"metalness":return"Metalness";case"metalnessMap":return"Metalness Map";case"name":return"Name";case"normalMap":return"Normal Map";case"normalScale":return"Normal Scale";case"opacity":return"Opacity";case"reflectivity":return"Reflectivity";case"refractionRatio":return"Refraction Ratio";case"roughness":return"Roughness";case"roughnessMap":return"Roughness Map";case"sheenColor":return"Sheen Color";case"sheenColorMap":return"Sheen Color Map";case"sheenRoughness":return"Sheen Roughness";case"sheenRoughnessMap":return"Sheen Roughness Map";case"shininess":return"Shininess";case"side":return"Side";case"size":return"Size";case"sizeAttenuation":return"Size Attenuation";case"specular":return"Specular";case"specularColor":return"Specular Color";case"specularColorMap":return"Specular Color Map";case"specularIntensity":return"Specular Intensity";case"specularIntensityMap":return"Specular Map Intensity";case"thickness":return"Thickness";case"thicknessMap":return"Thickness Map";case"transmission":return"Transmission";case"transmissionMap":return"Transmission Map";case"transparent":return"Transparent";case"type":return"Type";case"uuid":return"UUID";case"uniforms":return"Uniforms";case"vertexShader":return"Vertex Shader";case"visible":return"Visible";case"wireframe":return"Wireframe"}return t}function ia(t){return t.toLowerCase().search("intensity")>-1||t==="anisotropyRotation"||t==="blendAlpha"||t==="bumpScale"||t==="clearcoatRoughness"||t==="displacementBias"||t==="displacementScale"||t==="metalness"||t==="opacity"||t==="reflectivity"||t==="refractionRatio"||t==="roughness"||t==="sheenRoughness"||t==="thickness"}function ra(){const t=document.createElement("input");return t.type="file",new Promise((n,a)=>{t.addEventListener("change",function(){if(t.files===null)a();else{const e=t.files[0],o=new FileReader;o.onload=function(s){n(s.target.result)},o.readAsDataURL(e)}}),t.click()})}const oa=[{title:"Front",value:c.FrontSide},{title:"Back",value:c.BackSide},{title:"Double",value:c.DoubleSide}],sa=[{title:"No Blending",value:c.NoBlending},{title:"Normal",value:c.NormalBlending},{title:"Additive",value:c.AdditiveBlending},{title:"Subtractive",value:c.SubtractiveBlending},{title:"Multiply",value:c.MultiplyBlending},{title:"Custom",value:c.CustomBlending}],ca=[{title:"Add",value:c.AddEquation},{title:"Subtract",value:c.SubtractEquation},{title:"Reverse Subtract",value:c.ReverseSubtractEquation},{title:"Min",value:c.MinEquation},{title:"Max",value:c.MaxEquation}],la=[{title:"Zero",valye:c.ZeroFactor},{title:"One",valye:c.OneFactor},{title:"Src Color",valye:c.SrcColorFactor},{title:"One Minus Src Color",valye:c.OneMinusSrcColorFactor},{title:"Src Alpha",valye:c.SrcAlphaFactor},{title:"One Minus Src Alpha",valye:c.OneMinusSrcAlphaFactor},{title:"Dst Alpha",valye:c.DstAlphaFactor},{title:"One Minus Dst Alpha",valye:c.OneMinusDstAlphaFactor},{title:"Dst Color",valye:c.DstColorFactor},{title:"One Minus Dst Color",valye:c.OneMinusDstColorFactor},{title:"Src Alpha Saturate",valye:c.SrcAlphaSaturateFactor},{title:"Constant Color",valye:c.ConstantColorFactor},{title:"One Minus Constant Color",valye:c.OneMinusConstantColorFactor},{title:"Constant Alpha",valye:c.ConstantAlphaFactor},{title:"One Minus Constant Alpha",valye:c.OneMinusConstantAlphaFactor}],ua=[{title:"Zero",valye:c.ZeroFactor},{title:"One",valye:c.OneFactor},{title:"Src Color",valye:c.SrcColorFactor},{title:"One Minus Src Color",valye:c.OneMinusSrcColorFactor},{title:"Src Alpha",valye:c.SrcAlphaFactor},{title:"One Minus Src Alpha",valye:c.OneMinusSrcAlphaFactor},{title:"Dst Alpha",valye:c.DstAlphaFactor},{title:"One Minus Dst Alpha",valye:c.OneMinusDstAlphaFactor},{title:"Dst Color",valye:c.DstColorFactor},{title:"One Minus Dst Color",valye:c.OneMinusDstColorFactor},{title:"Constant Color",valye:c.ConstantColorFactor},{title:"One Minus Constant Color",valye:c.OneMinusConstantColorFactor},{title:"Constant Alpha",valye:c.ConstantAlphaFactor},{title:"One Minus Constant Alpha",valye:c.OneMinusConstantAlphaFactor}];function Qe(t,n){t.needsUpdate=!0,t.type="option",t.options=n}function fn(t,n,a){const e=[];for(const o in t){if(!aa(o))continue;const s=typeof t[o],m=t[o];if(s==="boolean"||s==="number"||s==="string"){const l={title:Me(o),prop:o,type:s,value:m,min:void 0,max:void 0,needsUpdate:s==="boolean",onChange:(f,g)=>{a.updateObject(n.uuid,`material.${f}`,g),l.needsUpdate&&a.updateObject(n.uuid,"material.needsUpdate",!0);const y=a.scene?.getObjectByProperty("uuid",n.uuid);y!==void 0&&ne(y,`material.${f}`,g)}};switch(o){case"blending":Qe(l,sa);break;case"blendDst":Qe(l,ua);break;case"blendEquation":Qe(l,ca);break;case"blendSrc":Qe(l,la);break;case"side":Qe(l,oa);break}ia(o)&&(l.value=Number(m),l.type="range",l.min=0,l.max=1,l.step=.01);const d=s==="string"&&(o==="vertexShader"||o==="fragmentShader");d&&(l.disabled=!1,l.latest=l.value,l.onChange=(f,g)=>{l.latest=g}),e.push(l),d&&e.push({title:`${Be(o)} - Update`,type:"button",onChange:()=>{a.updateObject(n.uuid,`material.${o}`,l.latest),a.updateObject(n.uuid,"material.needsUpdate",!0);const f=a.scene?.getObjectByProperty("uuid",n.uuid);f!==void 0&&(ne(f,`material.${o}`,l.latest),f.material.needsUpdate=!0)}})}else if(s==="object")if(m.isColor)e.push({title:Me(o),prop:o,type:"color",value:m,onChange:(l,d)=>{const f=new c.Color(d);a.updateObject(n.uuid,`material.${l}`,f);const g=a.scene?.getObjectByProperty("uuid",n.uuid);g!==void 0&&ne(g,`material.${l}`,f)}});else if(Array.isArray(m)){const l=[];for(const d in m)l.push({title:`${d}`,type:`${typeof m[d]}`,value:m[d],onChange:(f,g)=>{a.updateObject(n.uuid,`material.${o}`,g);const y=a.scene?.getObjectByProperty("uuid",n.uuid);y!==void 0&&ne(y,`material.${o}`,g)}});e.push({title:Me(o),items:l})}else{const l=[];for(const d in m){const f=m[d];switch(typeof f){case"boolean":case"number":case"string":d==="src"?e.push({title:Me(o),type:"image",value:f,onChange:(y,C)=>{a.createTexture(n.uuid,`material.${o}`,C);const O=a.scene?.getObjectByProperty("uuid",n.uuid);O!==void 0&&Pt(C).then(R=>{ne(O,`material.${o}`,R),ne(O,"material.needsUpdate",!0)})}}):l.push({title:`${Me(d)}`,prop:`material.${o}.${d}`,type:`${typeof t[o][d]}`,value:m[d],onChange:(y,C)=>{a.updateObject(n.uuid,`material.${o}.${d}`,C);const O=a.scene?.getObjectByProperty("uuid",n.uuid);O!==void 0&&ne(O,`material.${o}.${d}`,C)}});break;case"object":if(f.value!==void 0&&f.value.src!==void 0)l.push({title:Me(d),type:"image",value:f.value.src,onChange:(y,C)=>{a.createTexture(n.uuid,`material.${o}.${d}.value`,m);const O=a.scene?.getObjectByProperty("uuid",n.uuid);O!==void 0&&Pt(C).then(R=>{ne(O,`material.${o}.${d}.value`,R)})}});else if(o==="uniforms"){const y=f.value,C=(O,R,N)=>({title:O,type:"number",value:N,step:.01,onChange:(Z,z)=>{const x=`material.uniforms.${d}.value.${R}`;a.updateObject(n.uuid,x,z);const G=a.scene?.getObjectByProperty("uuid",n.uuid);G!==void 0&&ne(G,x,z)}});if(typeof f.value=="number")l.push({title:d,type:"number",value:f.value,onChange:(O,R)=>{const N=`material.${o}.${O}.value`;a.updateObject(n.uuid,N,R);const Z=a.scene?.getObjectByProperty("uuid",n.uuid);Z!==void 0&&ne(Z,N,R)}});else if(y.r!==void 0&&y.g!==void 0&&y.b!==void 0)l.push({title:d,type:"color",value:f.value,onChange:(O,R)=>{const N=new c.Color(R),Z=`material.${o}.${O}.value`;a.updateObject(n.uuid,Z,N);const z=a.scene?.getObjectByProperty("uuid",n.uuid);z!==void 0&&ne(z,Z,N)}});else if(y.x!==void 0&&y.y!==void 0&&y.z===void 0&&y.w===void 0)l.push({title:d,items:[C("X","x",f.value.x),C("Y","y",f.value.y)]});else if(y.x!==void 0&&y.y!==void 0&&y.z!==void 0&&y.w===void 0)l.push({title:d,items:[C("X","x",f.value.x),C("Y","y",f.value.y),C("Z","z",f.value.z)]});else if(y.x!==void 0&&y.y!==void 0&&y.z!==void 0&&y.w!==void 0)l.push({title:d,items:[C("X","x",f.value.x),C("Y","y",f.value.y),C("Z","z",f.value.z),C("W","w",f.value.w)]});else if(y.elements!==void 0){const O=y.elements,R=[];for(let N=0;N<O.length;N++)R.push(C(N.toString(),N.toString(),O[N]));l.push({title:d,items:R})}else console.log(">>> need to add this format:",d,y)}else l.push({title:d,type:`${typeof f.value}`,value:f.value,onChange:(y,C)=>{a.updateObject(n.uuid,`material.${o}.${d}.value`,C);const O=a.scene?.getObjectByProperty("uuid",n.uuid);O!==void 0&&ne(O,`material.${o}.${d}.value`,C)}});break}}l.length>0&&e.push({title:Me(o),items:l})}else m!==void 0&&console.log("other:",o,s,m)}return e.sort((o,s)=>o.title<s.title?-1:o.title>s.title?1:0),e.push({title:"Update Material",type:"button",onChange:()=>{a.updateObject(n.uuid,"material.needsUpdate",!0)}}),e}function da(t,n){const a=t.material;if(Array.isArray(a)){const e=[],o=a.length;for(let s=0;s<o;s++)e.push(u.jsx(xe,{title:`Material ${s}`,items:fn(a[s],t,n)},`Material ${s}`));return u.jsx(u.Fragment,{children:e})}else return u.jsx(xe,{title:"Material",items:fn(a,t,n)})}function qe(t){let n=t.value;n!==void 0&&n.isColor!==void 0&&(n=Zt(t.value));const[a,e]=A.useState(n),o=A.useRef(null),s=A.useRef(null),m=A.useRef(null);A.useEffect(()=>{let g=!1,y=-1,C=0,O=Number(a);const R=G=>{g=!0,C=O,y=G.clientX},N=G=>{if(!g)return;const Ce=t.step!==void 0?t.step:1,ue=(G.clientX-y)*Ce;O=Number((C+ue).toFixed(4)),s.current!==null&&(s.current.value=O.toString()),t.onChange!==void 0&&t.onChange(t.prop!==void 0?t.prop:t.title,O)},Z=()=>{g=!1},z=()=>{g=!1},x=t.type==="number";return x&&(o.current?.addEventListener("mousedown",R,!1),document.addEventListener("mouseup",Z,!1),document.addEventListener("mousemove",N,!1),document.addEventListener("contextmenu",z,!1)),()=>{x&&(o.current?.removeEventListener("mousedown",R),document.removeEventListener("mouseup",Z),document.removeEventListener("mousemove",N),document.removeEventListener("contextmenu",z))}},[a]);const l=t.type==="string"&&(a.length>100||a.search(`
|
144
|
-
`)>-1),d=l||t.type==="image",f=g=>{let y=g.target.value;t.type==="boolean"?y=g.target.checked:t.type==="option"&&(y=t.options[y].value),e(y),t.onChange!==void 0&&t.onChange(t.prop!==void 0?t.prop:t.title,y)};return u.jsxs("div",{className:`field ${d?"block":""}`,children:[t.type!=="button"&&u.jsx("label",{ref:o,children:Be(t.title)},"fieldLabel"),t.type==="string"&&!l&&u.jsx("input",{type:"text",disabled:t.disabled,onChange:f,value:a}),t.type==="string"&&l&&u.jsx("textarea",{cols:50,rows:10,disabled:t.disabled!==void 0?t.disabled:!0,onChange:f,value:a}),t.type==="boolean"&&u.jsx("input",{type:"checkbox",disabled:t.disabled,onChange:f,checked:a}),t.type==="number"&&u.jsx("input",{ref:s,type:"number",value:a,min:t.min,max:t.max,step:t.step,disabled:t.disabled,onChange:f}),t.type==="range"&&u.jsxs(u.Fragment,{children:[u.jsx("input",{type:"text",value:a.toString(),onChange:f,disabled:t.disabled,className:"min"}),u.jsx("input",{disabled:t.disabled,type:"range",value:a,min:t.min,max:t.max,step:t.step,onChange:f})]}),t.type==="color"&&u.jsxs(u.Fragment,{children:[u.jsx("input",{type:"text",value:a.toString(),onChange:f,disabled:t.disabled,className:"color"}),u.jsx("input",{type:"color",value:a,onChange:f,disabled:t.disabled})]}),t.type==="button"&&u.jsx("button",{disabled:t.disabled,onClick:()=>{t.onChange!==void 0&&t.onChange(t.prop!==void 0?t.prop:t.title,!0)},children:t.title}),t.type==="image"&&u.jsx("img",{ref:m,onClick:()=>{ra().then(g=>{m.current.src=g,t.onChange!==void 0&&t.onChange(t.prop!==void 0?t.prop:t.title,g)})},src:a.length>0?a:ta}),t.type==="option"&&u.jsx(u.Fragment,{children:u.jsx("select",{onChange:f,disabled:t.disabled,defaultValue:t.value,children:t.options?.map((g,y)=>u.jsx("option",{value:g.value,children:Be(g.title)},y))})})]})}function pn(t){switch(t){case"fov":return"FOV";case"zoom":return"Zoom";case"near":return"Near";case"far":return"Far";case"focus":return"Focus";case"aspect":return"Aspect";case"filmGauge":return"Film Gauge";case"filmOffset":return"Film Offset";case"left":return"Left";case"right":return"Right";case"top":return"Top";case"bottom":return"Bottom"}return t}function fa(t,n){const a=[];if(t.perspectiveCameraInfo!==void 0)for(const e in t.perspectiveCameraInfo)a.push({title:pn(e),prop:e,type:"number",step:.01,value:t.perspectiveCameraInfo[e],onChange:(o,s)=>{n.updateObject(t.uuid,o,s),n.requestMethod(t.uuid,"updateProjectionMatrix");const m=n.scene?.getObjectByProperty("uuid",t.uuid);m!==void 0&&(ne(m,o,s),m.updateProjectionMatrix())}});else if(t.orthographicCameraInfo!==void 0)for(const e in t.orthographicCameraInfo)a.push({title:pn(e),prop:e,type:"number",step:.01,value:t.perspectiveCameraInfo[e],onChange:(o,s)=>{n.updateObject(t.uuid,o,s),n.requestMethod(t.uuid,"updateProjectionMatrix");const m=n.scene?.getObjectByProperty("uuid",t.uuid);m!==void 0&&(ne(m,o,s),m.updateProjectionMatrix())}});return u.jsx(xe,{title:"Camera",items:a})}const pa=Math.PI/180,ha=180/Math.PI;function ze(t,n,a,e,o){return e+(t-n)*(o-e)/(a-n)}function ma(t){return t*pa}function It(t){return t*ha}function va(t,n){const a=new c.Matrix4;a.elements=t.matrix;const e=new c.Vector3,o=new c.Euler,s=new c.Vector3;t.uuid.length>0&&(e.setFromMatrixPosition(a),o.setFromRotationMatrix(a),s.setFromMatrixScale(a));const m=(d,f)=>{n.updateObject(t.uuid,d,f);const g=n.scene?.getObjectByProperty("uuid",t.uuid);g!==void 0&&ne(g,d,f)},l=(d,f)=>{m(d,ma(f))};return u.jsx(xe,{title:"Transform",items:[{title:"Position X",prop:"position.x",type:"number",value:e.x,onChange:m},{title:"Position Y",prop:"position.y",type:"number",value:e.y,onChange:m},{title:"Position Z",prop:"position.z",type:"number",value:e.z,onChange:m},{title:"Rotation X",prop:"rotation.x",type:"number",value:lt(It(o.x)),min:-360,max:360,step:.1,onChange:l},{title:"Rotation Y",prop:"rotation.y",type:"number",value:lt(It(o.y)),min:-360,max:360,step:.1,onChange:l},{title:"Rotation Z",prop:"rotation.z",type:"number",value:lt(It(o.z)),min:-360,max:360,step:.1,onChange:l},{title:"Scale X",prop:"scale.x",type:"number",value:s.x,step:.01,onChange:m},{title:"Scale Y",prop:"scale.y",type:"number",value:s.y,step:.01,onChange:m},{title:"Scale Z",prop:"scale.z",type:"number",value:s.z,step:.01,onChange:m}]})}function hn(t){switch(t){case"color":return"Color";case"intensity":return"Intensity";case"decay":return"Decay";case"distance":return"Distance";case"angle":return"Angle";case"penumbra":return"Penumbra";case"groundColor":return"Ground Color"}return t}function ga(t,n){const a=[];if(t.lightInfo!==void 0)for(const e in t.lightInfo){const o=t.lightInfo[e];o!==void 0&&(o.isColor!==void 0?a.push({title:hn(e),prop:e,type:"color",value:o,onChange:(s,m)=>{const l=new c.Color(m);n.updateObject(t.uuid,s,l);const d=n.scene?.getObjectByProperty("uuid",t.uuid);d!==void 0&&ne(d,s,l)}}):a.push({title:hn(e),prop:e,type:typeof o,value:o,step:typeof o=="number"?.01:void 0,onChange:(s,m)=>{n.updateObject(t.uuid,s,m);const l=n.scene?.getObjectByProperty("uuid",t.uuid);l!==void 0&&ne(l,s,m)}}))}return u.jsx(xe,{title:"Light",items:a})}function ba(t,n){const a=[],e=[];let o=0;t.animations.forEach(l=>{o=Math.max(o,l.duration),l.duration>0&&e.push({title:l.name,items:[{title:"Duration",type:"number",value:l.duration,disabled:!0},{title:"Blend Mode",type:"option",disabled:!0,options:[{title:"Normal",value:2500},{title:"Additive",value:2501}]}]})}),a.push({title:"Animations",items:e});const s=n.scene?.getObjectByProperty("uuid",t.uuid);let m=!1;if(s!==void 0){const l=s.mixer;if(m=l!==void 0,m){const d=[{title:"Time Scale",type:"range",value:l.timeScale,step:.01,min:-1,max:2,onChange:(f,g)=>{l.timeScale=g,n.updateObject(t.uuid,"mixer.timeScale",g)}}];d.push({title:"Stop All",type:"button",onChange:()=>{l.stopAllAction(),n.requestMethod(t.uuid,"stopAllAction",void 0,"mixer")}}),a.push({title:"Mixer",items:d})}}return u.jsx(xe,{title:"Animation",items:a})}const mn={name:"",uuid:"",type:"",visible:!1,matrix:[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],animations:[],material:void 0,perspectiveCameraInfo:void 0,orthographicCameraInfo:void 0,lightInfo:void 0};let ae={...mn};function vn(t){const[n,a]=A.useState(-1);A.useEffect(()=>{function m(d){ae={...d.value},a(Date.now())}function l(){ae={...mn},a(Date.now())}return D.addEventListener(I.SET_SCENE,l),D.addEventListener(I.SET_OBJECT,m),()=>{D.removeEventListener(I.SET_SCENE,l),D.removeEventListener(I.SET_OBJECT,m)}},[]);const e=ae.type.toLowerCase(),o=ae.animations.length>0||ae.mixer!==void 0,s=e.search("mesh")>-1||e.search("line")>-1||e.search("points")>-1;return u.jsx(ut,{label:"Inspector",children:u.jsx("div",{id:"Inspector",className:t.class,children:ae.uuid.length>0&&u.jsxs(u.Fragment,{children:[u.jsxs(u.Fragment,{children:[u.jsx(qe,{type:"string",title:"Name",prop:"name",value:ae.name,disabled:!0}),u.jsx(qe,{type:"string",title:"Type",prop:"type",value:ae.type,disabled:!0}),u.jsx(qe,{type:"string",title:"UUID",prop:"uuid",value:ae.uuid,disabled:!0}),u.jsx(qe,{type:"boolean",title:"Visible",prop:"visible",value:ae.visible,onChange:(m,l)=>{t.three.updateObject(ae.uuid,m,l);const d=t.three.scene?.getObjectByProperty("uuid",ae.uuid);d!==void 0&&ne(d,m,l)}})]}),u.jsxs(u.Fragment,{children:[va(ae,t.three),o?ba(ae,t.three):null,e.search("camera")>-1?fa(ae,t.three):null,e.search("light")>-1?ga(ae,t.three):null,s?da(ae,t.three):null]})]})},n)},"Inspector")}class ya extends A.Component{three;constructor(n){super(n),this.state={scene:n.scene!==void 0?n.scene:null},this.three=n.three,D.addEventListener(I.SET_SCENE,this.setScene)}componentWillUnmount(){D.removeEventListener(I.SET_SCENE,this.setScene)}render(){const n=this.componentState.scene!==null,a="Hierarchy - "+(n?`${this.componentState.scene?.name}`:"No Scene");return u.jsx("div",{id:"SidePanel",children:u.jsxs(u.Fragment,{children:[u.jsx(ut,{label:a,open:!0,children:u.jsx(u.Fragment,{children:n&&u.jsx(dn,{child:this.componentState.scene,three:this.three})})}),u.jsx(vn,{three:this.three})]})},"SidePanel")}setScene=n=>{this.setState(()=>({scene:n.value}))};get componentState(){return this.state}}function Ea(t){function n(){return t.three.scene===void 0?(console.log("No scene:",t.three),!1):!0}const a=l=>{if(!n())return;const d=t.three.scene?.getObjectByProperty("uuid",l.value);d!==void 0&&t.three.setObject(d)},e=(l,d,f)=>{if(!n())return;const g=t.three.scene?.getObjectByProperty("uuid",l);g!==void 0&&ne(g,d,f)},o=l=>{if(!n())return;const d=l.value,{key:f,value:g,uuid:y}=d;e(y,f,g)},s=l=>{if(!n())return;const d=l.value;Pt(d.value).then(f=>{e(d.uuid,d.key,f),e(d.uuid,"material.needsUpdate",!0)})},m=l=>{if(!n())return;const{key:d,uuid:f,value:g,subitem:y}=l.value,C=t.three.scene?.getObjectByProperty("uuid",f);if(C!==void 0)try{y!==void 0?Vn(C,y)[d](g):C[d](g)}catch(O){console.log("Error requesting method:"),console.log(O),console.log(d),console.log(g)}};return A.useEffect(()=>(D.addEventListener(I.GET_OBJECT,a),D.addEventListener(I.UPDATE_OBJECT,o),D.addEventListener(I.CREATE_TEXTURE,s),D.addEventListener(I.REQUEST_METHOD,m),()=>{D.removeEventListener(I.GET_OBJECT,a),D.removeEventListener(I.UPDATE_OBJECT,o),D.removeEventListener(I.CREATE_TEXTURE,s),D.removeEventListener(I.REQUEST_METHOD,m)}),[]),null}const gn={type:"change"},Nt={type:"start"},bn={type:"end"},dt=new c.Ray,yn=new c.Plane,Ca=Math.cos(70*c.MathUtils.DEG2RAD);class Sa extends c.EventDispatcher{constructor(n,a){super(),this.object=n,this.domElement=a,this.domElement.style.touchAction="none",this.enabled=!0,this.target=new c.Vector3,this.cursor=new c.Vector3,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:c.MOUSE.ROTATE,MIDDLE:c.MOUSE.DOLLY,RIGHT:c.MOUSE.PAN},this.touches={ONE:c.TOUCH.ROTATE,TWO:c.TOUCH.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this.getPolarAngle=function(){return l.phi},this.getAzimuthalAngle=function(){return l.theta},this.getDistance=function(){return this.object.position.distanceTo(this.target)},this.listenToKeyEvents=function(r){r.addEventListener("keydown",ot),this._domElementKeyEvents=r},this.stopListenToKeyEvents=function(){this._domElementKeyEvents.removeEventListener("keydown",ot),this._domElementKeyEvents=null},this.saveState=function(){e.target0.copy(e.target),e.position0.copy(e.object.position),e.zoom0=e.object.zoom},this.reset=function(){e.target.copy(e.target0),e.object.position.copy(e.position0),e.object.zoom=e.zoom0,e.object.updateProjectionMatrix(),e.dispatchEvent(gn),e.update(),s=o.NONE},this.update=function(){const r=new c.Vector3,E=new c.Quaternion().setFromUnitVectors(n.up,new c.Vector3(0,1,0)),T=E.clone().invert(),U=new c.Vector3,q=new c.Quaternion,de=new c.Vector3,se=2*Math.PI;return function(Yt=null){const ct=e.object.position;r.copy(ct).sub(e.target),r.applyQuaternion(E),l.setFromVector3(r),e.autoRotate&&s===o.NONE&&H(_(Yt)),e.enableDamping?(l.theta+=d.theta*e.dampingFactor,l.phi+=d.phi*e.dampingFactor):(l.theta+=d.theta,l.phi+=d.phi);let he=e.minAzimuthAngle,fe=e.maxAzimuthAngle;isFinite(he)&&isFinite(fe)&&(he<-Math.PI?he+=se:he>Math.PI&&(he-=se),fe<-Math.PI?fe+=se:fe>Math.PI&&(fe-=se),he<=fe?l.theta=Math.max(he,Math.min(fe,l.theta)):l.theta=l.theta>(he+fe)/2?Math.max(he,l.theta):Math.min(fe,l.theta)),l.phi=Math.max(e.minPolarAngle,Math.min(e.maxPolarAngle,l.phi)),l.makeSafe(),e.enableDamping===!0?e.target.addScaledVector(g,e.dampingFactor):e.target.add(g),e.target.sub(e.cursor),e.target.clampLength(e.minTargetRadius,e.maxTargetRadius),e.target.add(e.cursor),e.zoomToCursor&&ce||e.object.isOrthographicCamera?l.radius=me(l.radius):l.radius=me(l.radius*f),r.setFromSpherical(l),r.applyQuaternion(T),ct.copy(e.target).add(r),e.object.lookAt(e.target),e.enableDamping===!0?(d.theta*=1-e.dampingFactor,d.phi*=1-e.dampingFactor,g.multiplyScalar(1-e.dampingFactor)):(d.set(0,0,0),g.set(0,0,0));let Ne=!1;if(e.zoomToCursor&&ce){let Le=null;if(e.object.isPerspectiveCamera){const Fe=r.length();Le=me(Fe*f);const Ue=Fe-Le;e.object.position.addScaledVector(Ce,Ue),e.object.updateMatrixWorld()}else if(e.object.isOrthographicCamera){const Fe=new c.Vector3(ue.x,ue.y,0);Fe.unproject(e.object),e.object.zoom=Math.max(e.minZoom,Math.min(e.maxZoom,e.object.zoom/f)),e.object.updateProjectionMatrix(),Ne=!0;const Ue=new c.Vector3(ue.x,ue.y,0);Ue.unproject(e.object),e.object.position.sub(Ue).add(Fe),e.object.updateMatrixWorld(),Le=r.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),e.zoomToCursor=!1;Le!==null&&(this.screenSpacePanning?e.target.set(0,0,-1).transformDirection(e.object.matrix).multiplyScalar(Le).add(e.object.position):(dt.origin.copy(e.object.position),dt.direction.set(0,0,-1).transformDirection(e.object.matrix),Math.abs(e.object.up.dot(dt.direction))<Ca?n.lookAt(e.target):(yn.setFromNormalAndCoplanarPoint(e.object.up,e.target),dt.intersectPlane(yn,e.target))))}else e.object.isOrthographicCamera&&(Ne=f!==1,Ne&&(e.object.zoom=Math.max(e.minZoom,Math.min(e.maxZoom,e.object.zoom/f)),e.object.updateProjectionMatrix()));return f=1,ce=!1,Ne||U.distanceToSquared(e.object.position)>m||8*(1-q.dot(e.object.quaternion))>m||de.distanceToSquared(e.target)>0?(e.dispatchEvent(gn),U.copy(e.object.position),q.copy(e.object.quaternion),de.copy(e.target),!0):!1}}(),this.dispose=function(){e.domElement.removeEventListener("contextmenu",Ge),e.domElement.removeEventListener("pointerdown",De),e.domElement.removeEventListener("pointercancel",Ie),e.domElement.removeEventListener("wheel",St),e.domElement.removeEventListener("pointermove",it),e.domElement.removeEventListener("pointerup",Ie),e._domElementKeyEvents!==null&&(e._domElementKeyEvents.removeEventListener("keydown",ot),e._domElementKeyEvents=null)};const e=this,o={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6};let s=o.NONE;const m=1e-6,l=new c.Spherical,d=new c.Spherical;let f=1;const g=new c.Vector3,y=new c.Vector2,C=new c.Vector2,O=new c.Vector2,R=new c.Vector2,N=new c.Vector2,Z=new c.Vector2,z=new c.Vector2,x=new c.Vector2,G=new c.Vector2,Ce=new c.Vector3,ue=new c.Vector2;let ce=!1;const p=[],v={};let M=!1;function _(r){return r!==null?2*Math.PI/60*e.autoRotateSpeed*r:2*Math.PI/60/60*e.autoRotateSpeed}function W(r){const E=Math.abs(r*.01);return Math.pow(.95,e.zoomSpeed*E)}function H(r){d.theta-=r}function Y(r){d.phi-=r}const F=function(){const r=new c.Vector3;return function(T,U){r.setFromMatrixColumn(U,0),r.multiplyScalar(-T),g.add(r)}}(),J=function(){const r=new c.Vector3;return function(T,U){e.screenSpacePanning===!0?r.setFromMatrixColumn(U,1):(r.setFromMatrixColumn(U,0),r.crossVectors(e.object.up,r)),r.multiplyScalar(T),g.add(r)}}(),Q=function(){const r=new c.Vector3;return function(T,U){const q=e.domElement;if(e.object.isPerspectiveCamera){const de=e.object.position;r.copy(de).sub(e.target);let se=r.length();se*=Math.tan(e.object.fov/2*Math.PI/180),F(2*T*se/q.clientHeight,e.object.matrix),J(2*U*se/q.clientHeight,e.object.matrix)}else e.object.isOrthographicCamera?(F(T*(e.object.right-e.object.left)/e.object.zoom/q.clientWidth,e.object.matrix),J(U*(e.object.top-e.object.bottom)/e.object.zoom/q.clientHeight,e.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),e.enablePan=!1)}}();function P(r){e.object.isPerspectiveCamera||e.object.isOrthographicCamera?f/=r:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),e.enableZoom=!1)}function B(r){e.object.isPerspectiveCamera||e.object.isOrthographicCamera?f*=r:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),e.enableZoom=!1)}function ee(r,E){if(!e.zoomToCursor)return;ce=!0;const T=e.domElement.getBoundingClientRect(),U=r-T.left,q=E-T.top,de=T.width,se=T.height;ue.x=U/de*2-1,ue.y=-(q/se)*2+1,Ce.set(ue.x,ue.y,1).unproject(e.object).sub(e.object.position).normalize()}function me(r){return Math.max(e.minDistance,Math.min(e.maxDistance,r))}function Se(r){y.set(r.clientX,r.clientY)}function vt(r){ee(r.clientX,r.clientX),z.set(r.clientX,r.clientY)}function tt(r){R.set(r.clientX,r.clientY)}function Lt(r){C.set(r.clientX,r.clientY),O.subVectors(C,y).multiplyScalar(e.rotateSpeed);const E=e.domElement;H(2*Math.PI*O.x/E.clientHeight),Y(2*Math.PI*O.y/E.clientHeight),y.copy(C),e.update()}function Ft(r){x.set(r.clientX,r.clientY),G.subVectors(x,z),G.y>0?P(W(G.y)):G.y<0&&B(W(G.y)),z.copy(x),e.update()}function nt(r){N.set(r.clientX,r.clientY),Z.subVectors(N,R).multiplyScalar(e.panSpeed),Q(Z.x,Z.y),R.copy(N),e.update()}function at(r){ee(r.clientX,r.clientY),r.deltaY<0?B(W(r.deltaY)):r.deltaY>0&&P(W(r.deltaY)),e.update()}function He(r){let E=!1;switch(r.code){case e.keys.UP:r.ctrlKey||r.metaKey||r.shiftKey?Y(2*Math.PI*e.rotateSpeed/e.domElement.clientHeight):Q(0,e.keyPanSpeed),E=!0;break;case e.keys.BOTTOM:r.ctrlKey||r.metaKey||r.shiftKey?Y(-2*Math.PI*e.rotateSpeed/e.domElement.clientHeight):Q(0,-e.keyPanSpeed),E=!0;break;case e.keys.LEFT:r.ctrlKey||r.metaKey||r.shiftKey?H(2*Math.PI*e.rotateSpeed/e.domElement.clientHeight):Q(e.keyPanSpeed,0),E=!0;break;case e.keys.RIGHT:r.ctrlKey||r.metaKey||r.shiftKey?H(-2*Math.PI*e.rotateSpeed/e.domElement.clientHeight):Q(-e.keyPanSpeed,0),E=!0;break}E&&(r.preventDefault(),e.update())}function Ye(r){if(p.length===1)y.set(r.pageX,r.pageY);else{const E=Oe(r),T=.5*(r.pageX+E.x),U=.5*(r.pageY+E.y);y.set(T,U)}}function ke(r){if(p.length===1)R.set(r.pageX,r.pageY);else{const E=Oe(r),T=.5*(r.pageX+E.x),U=.5*(r.pageY+E.y);R.set(T,U)}}function gt(r){const E=Oe(r),T=r.pageX-E.x,U=r.pageY-E.y,q=Math.sqrt(T*T+U*U);z.set(0,q)}function bt(r){e.enableZoom&>(r),e.enablePan&&ke(r)}function Ut(r){e.enableZoom&>(r),e.enableRotate&&Ye(r)}function yt(r){if(p.length==1)C.set(r.pageX,r.pageY);else{const T=Oe(r),U=.5*(r.pageX+T.x),q=.5*(r.pageY+T.y);C.set(U,q)}O.subVectors(C,y).multiplyScalar(e.rotateSpeed);const E=e.domElement;H(2*Math.PI*O.x/E.clientHeight),Y(2*Math.PI*O.y/E.clientHeight),y.copy(C)}function _e(r){if(p.length===1)N.set(r.pageX,r.pageY);else{const E=Oe(r),T=.5*(r.pageX+E.x),U=.5*(r.pageY+E.y);N.set(T,U)}Z.subVectors(N,R).multiplyScalar(e.panSpeed),Q(Z.x,Z.y),R.copy(N)}function je(r){const E=Oe(r),T=r.pageX-E.x,U=r.pageY-E.y,q=Math.sqrt(T*T+U*U);x.set(0,q),G.set(0,Math.pow(x.y/z.y,e.zoomSpeed)),P(G.y),z.copy(x);const de=(r.pageX+E.x)*.5,se=(r.pageY+E.y)*.5;ee(de,se)}function Et(r){e.enableZoom&&je(r),e.enablePan&&_e(r)}function Ct(r){e.enableZoom&&je(r),e.enableRotate&&yt(r)}function De(r){e.enabled!==!1&&(p.length===0&&(e.domElement.setPointerCapture(r.pointerId),e.domElement.addEventListener("pointermove",it),e.domElement.addEventListener("pointerup",Ie)),Vt(r),r.pointerType==="touch"?st(r):rt(r))}function it(r){e.enabled!==!1&&(r.pointerType==="touch"?xt(r):Bt(r))}function Ie(r){switch(zt(r),p.length){case 0:e.domElement.releasePointerCapture(r.pointerId),e.domElement.removeEventListener("pointermove",it),e.domElement.removeEventListener("pointerup",Ie),e.dispatchEvent(bn),s=o.NONE;break;case 1:const E=p[0],T=v[E];st({pointerId:E,pageX:T.x,pageY:T.y});break}}function rt(r){let E;switch(r.button){case 0:E=e.mouseButtons.LEFT;break;case 1:E=e.mouseButtons.MIDDLE;break;case 2:E=e.mouseButtons.RIGHT;break;default:E=-1}switch(E){case c.MOUSE.DOLLY:if(e.enableZoom===!1)return;vt(r),s=o.DOLLY;break;case c.MOUSE.ROTATE:if(r.ctrlKey||r.metaKey||r.shiftKey){if(e.enablePan===!1)return;tt(r),s=o.PAN}else{if(e.enableRotate===!1)return;Se(r),s=o.ROTATE}break;case c.MOUSE.PAN:if(r.ctrlKey||r.metaKey||r.shiftKey){if(e.enableRotate===!1)return;Se(r),s=o.ROTATE}else{if(e.enablePan===!1)return;tt(r),s=o.PAN}break;default:s=o.NONE}s!==o.NONE&&e.dispatchEvent(Nt)}function Bt(r){switch(s){case o.ROTATE:if(e.enableRotate===!1)return;Lt(r);break;case o.DOLLY:if(e.enableZoom===!1)return;Ft(r);break;case o.PAN:if(e.enablePan===!1)return;nt(r);break}}function St(r){e.enabled===!1||e.enableZoom===!1||s!==o.NONE||(r.preventDefault(),e.dispatchEvent(Nt),at(wt(r)),e.dispatchEvent(bn))}function wt(r){const E=r.deltaMode,T={clientX:r.clientX,clientY:r.clientY,deltaY:r.deltaY};switch(E){case 1:T.deltaY*=16;break;case 2:T.deltaY*=100;break}return r.ctrlKey&&!M&&(T.deltaY*=10),T}function Ot(r){r.key==="Control"&&(M=!0,e.domElement.getRootNode().addEventListener("keyup",we,{passive:!0,capture:!0}))}function we(r){r.key==="Control"&&(M=!1,e.domElement.getRootNode().removeEventListener("keyup",we,{passive:!0,capture:!0}))}function ot(r){e.enabled===!1||e.enablePan===!1||He(r)}function st(r){switch(Mt(r),p.length){case 1:switch(e.touches.ONE){case c.TOUCH.ROTATE:if(e.enableRotate===!1)return;Ye(r),s=o.TOUCH_ROTATE;break;case c.TOUCH.PAN:if(e.enablePan===!1)return;ke(r),s=o.TOUCH_PAN;break;default:s=o.NONE}break;case 2:switch(e.touches.TWO){case c.TOUCH.DOLLY_PAN:if(e.enableZoom===!1&&e.enablePan===!1)return;bt(r),s=o.TOUCH_DOLLY_PAN;break;case c.TOUCH.DOLLY_ROTATE:if(e.enableZoom===!1&&e.enableRotate===!1)return;Ut(r),s=o.TOUCH_DOLLY_ROTATE;break;default:s=o.NONE}break;default:s=o.NONE}s!==o.NONE&&e.dispatchEvent(Nt)}function xt(r){switch(Mt(r),s){case o.TOUCH_ROTATE:if(e.enableRotate===!1)return;yt(r),e.update();break;case o.TOUCH_PAN:if(e.enablePan===!1)return;_e(r),e.update();break;case o.TOUCH_DOLLY_PAN:if(e.enableZoom===!1&&e.enablePan===!1)return;Et(r),e.update();break;case o.TOUCH_DOLLY_ROTATE:if(e.enableZoom===!1&&e.enableRotate===!1)return;Ct(r),e.update();break;default:s=o.NONE}}function Ge(r){e.enabled!==!1&&r.preventDefault()}function Vt(r){p.push(r.pointerId)}function zt(r){delete v[r.pointerId];for(let E=0;E<p.length;E++)if(p[E]==r.pointerId){p.splice(E,1);return}}function Mt(r){let E=v[r.pointerId];E===void 0&&(E=new c.Vector2,v[r.pointerId]=E),E.set(r.pageX,r.pageY)}function Oe(r){const E=r.pointerId===p[0]?p[1]:p[0];return v[E]}e.domElement.addEventListener("contextmenu",Ge),e.domElement.addEventListener("pointerdown",De),e.domElement.addEventListener("pointercancel",Ie),e.domElement.addEventListener("wheel",St,{passive:!1}),e.domElement.getRootNode().addEventListener("keydown",Ot,{passive:!0,capture:!0}),this.update()}}const ft=t=>{const[n,a]=A.useState(t.options[t.index]),e=()=>{t.onToggle(!t.open)},o=s=>{s!==n&&(t.onSelect(s),a(s)),t.onToggle(!1)};return u.jsxs("div",{className:`dropdown ${t.up===!0?"up":""}`,children:[u.jsx("div",{className:"dropdown-toggle",onClick:e,children:n}),t.open&&u.jsx("ul",{className:"dropdown-menu",children:t.options.map(s=>u.jsx("li",{onClick:()=>o(s),children:s},s))})]})},Te=A.forwardRef(function(n,a){const[e,o]=A.useState(!1),s=n.options.indexOf(n.camera.name);return u.jsxs("div",{className:"CameraWindow",children:[u.jsx("div",{ref:a,className:"clickable",onClick:()=>{e&&o(!1)}}),u.jsx(ft,{index:s,open:e,options:n.options,onSelect:n.onSelect,onToggle:m=>{o(m)},up:!0})]})}),En=["Single","Side by Side","Stacked","Quad"],ie=new Map,re=new Map,ge=new Map;function Re(t,n){const a=new c.OrthographicCamera(-100,100,100,-100,50,3e3);return a.name=t,a.position.copy(n),a.lookAt(0,0,0),ie.set(t,a),a}Re("Top",new c.Vector3(0,1e3,0)),Re("Bottom",new c.Vector3(0,-1e3,0)),Re("Left",new c.Vector3(-1e3,0,0)),Re("Right",new c.Vector3(1e3,0,0)),Re("Front",new c.Vector3(0,0,1e3)),Re("Back",new c.Vector3(0,0,-1e3)),Re("Orthographic",new c.Vector3(1e3,1e3,1e3));const pt=new c.PerspectiveCamera(60,1,50,3e3);pt.name="Debug",pt.position.set(500,500,500),pt.lookAt(0,0,0),ie.set("Debug",pt);const Cn=["Renderer","Depth","Normals","UVs","Wireframe"],wa=new c.MeshDepthMaterial,Oa=new c.MeshNormalMaterial,xa=new un,Ma=new c.MeshBasicMaterial({opacity:.33,transparent:!0,wireframe:!0}),Na="";let ht="Renderer";const K=new c.Scene;K.name="Debug Scene";let be=new c.Scene;K.add(be);const $e=new c.Group;$e.name="helpers",K.add($e);const Ta=new ln;$e.add(Ta);const Sn=new c.AxesHelper(500);Sn.name="axisHelper",$e.add(Sn);const et=new c.AxesHelper(100);et.name="interactionHelper",$e.add(et),et.visible=!1;let mt=!1,X=ie.get("Debug"),oe=ie.get("Orthographic"),Ae=ie.get("Front"),Pe=ie.get("Top"),wn=!1;function Ra(t){const[n,a]=A.useState(t.mode!==void 0?t.mode:"Single"),[e,o]=A.useState(null),[s,m]=A.useState(!1),[l,d]=A.useState(!1),[f,g]=A.useState(!1),[,y]=A.useState(Date.now()),C=A.useRef(null),O=A.useRef(null),R=A.useRef(null),N=A.useRef(null),Z=A.useRef(null),z=A.useRef(null),x=(p,v)=>{const M=re.get(p.name);M!==void 0&&M.dispose(),re.delete(p.name);const _=ge.get(p.name);_!==void 0&&(K.remove(_),_.dispose()),ge.delete(p.name);const W=new Sa(p,v);switch(W.enableDamping=!0,W.dampingFactor=.05,p.name){case"Top":case"Bottom":case"Left":case"Right":case"Front":case"Back":W.enableRotate=!1;break}if(re.set(p.name,W),p instanceof c.PerspectiveCamera){const H=new c.CameraHelper(p);ge.set(p.name,H),K.add(H)}},G=p=>{const v=ge.get(p.name);v!==void 0&&(K.remove(v),v.dispose(),ge.delete(p.name));const M=re.get(p.name);M!==void 0&&(M.dispose(),re.delete(p.name))},Ce=()=>{re.forEach((p,v)=>{p.dispose();const M=ge.get(v);M!==void 0&&(K.remove(M),M.dispose()),ge.delete(v),re.delete(v)}),re.clear(),ge.clear()},ue=()=>{switch(n){case"Single":x(X,R.current);break;case"Side by Side":case"Stacked":x(X,R.current),x(oe,N.current);break;case"Quad":x(X,R.current),x(oe,N.current),x(Ae,Z.current),x(Pe,z.current);break}};A.useEffect(()=>{const p=new c.WebGLRenderer({canvas:C.current,stencil:!1});p.autoClear=!1,p.shadowMap.enabled=!0,p.setPixelRatio(devicePixelRatio),p.setClearColor(0),o(p)},[]),A.useEffect(()=>{const p=_=>{Rt(be),K.remove(be);const W=t.scenes.get(_.value.name);if(W!==void 0){const H=new W;t.onSceneSet!==void 0&&t.onSceneSet(H),be=H,t.three.scene=be,K.add(be),wn=!0}},v=_=>{const W=_.value,H=t.three.scene?.getObjectByProperty("uuid",W.uuid);H!==void 0&&ie.set(W.name,H),y(Date.now())},M=_=>{ie.delete(_.value.name),y(Date.now())};return D.addEventListener(I.SET_SCENE,p),D.addEventListener(I.ADD_CAMERA,v),D.addEventListener(I.REMOVE_CAMERA,M),()=>{D.removeEventListener(I.SET_SCENE,p),D.removeEventListener(I.ADD_CAMERA,v),D.removeEventListener(I.REMOVE_CAMERA,M)}},[]),A.useEffect(()=>{if(e===null)return;let p=window.innerWidth,v=window.innerHeight,M=Math.floor(p/2),_=Math.floor(v/2),W=-1;const H=()=>{p=window.innerWidth-300,v=window.innerHeight,M=Math.floor(p/2),_=Math.floor(v/2),e.setSize(p,v);let P=p,B=v;switch(n){case"Side by Side":P=M,B=v;break;case"Stacked":P=p,B=_;break;case"Quad":P=M,B=_;break}ie.forEach(ee=>{ee instanceof c.OrthographicCamera?(ee.left=P/-2,ee.right=P/2,ee.top=B/2,ee.bottom=B/-2,ee.updateProjectionMatrix()):ee instanceof c.PerspectiveCamera&&(ee.aspect=P/B,ee.updateProjectionMatrix(),ge.get(ee.name)?.update())})},Y=()=>{e.setViewport(0,0,p,v),e.setScissor(0,0,p,v),e.render(K,X)},F=()=>{if(n==="Side by Side")e.setViewport(0,0,M,v),e.setScissor(0,0,M,v),e.render(K,X),e.setViewport(M,0,M,v),e.setScissor(M,0,M,v),e.render(K,oe);else{const P=v-_;e.setViewport(0,P,p,_),e.setScissor(0,P,p,_),e.render(K,X),e.setViewport(0,0,p,_),e.setScissor(0,0,p,_),e.render(K,oe)}},J=()=>{let P=0,B=0;B=v-_,P=0,e.setViewport(P,B,M,_),e.setScissor(P,B,M,_),e.render(K,X),P=M,e.setViewport(P,B,M,_),e.setScissor(P,B,M,_),e.render(K,oe),B=0,P=0,e.setViewport(P,B,M,_),e.setScissor(P,B,M,_),e.render(K,Ae),P=M,e.setViewport(P,B,M,_),e.setScissor(P,B,M,_),e.render(K,Pe)},Q=()=>{switch(re.forEach(P=>{P.update()}),t.onSceneUpdate!==void 0&&wn&&t.onSceneUpdate(be),e.clear(),n){case"Single":Y();break;case"Side by Side":case"Stacked":F();break;case"Quad":J();break}W=requestAnimationFrame(Q)};return ue(),window.addEventListener("resize",H),H(),Q(),()=>{window.removeEventListener("resize",H),cancelAnimationFrame(W),W=-1}},[n,e]),A.useEffect(()=>{if(e!==null){const p=new c.Raycaster,v=new c.Vector2,M=(Y,F,J,Q)=>{switch(n){case"Quad":Y<J?F<Q?p.setFromCamera(v,X):p.setFromCamera(v,Ae):F<Q?p.setFromCamera(v,oe):p.setFromCamera(v,Pe);break;case"Side by Side":Y<J?p.setFromCamera(v,X):p.setFromCamera(v,oe);break;case"Single":p.setFromCamera(v,X);break;case"Stacked":F<Q?p.setFromCamera(v,X):p.setFromCamera(v,oe);break}},_=Y=>{if(!mt)return;const F=new c.Vector2;e.getSize(F);const J=Math.min(Y.clientX,F.x),Q=Math.min(Y.clientY,F.y);v.x=ze(J,0,F.x,-1,1),v.y=ze(Q,0,F.y,1,-1);const P=F.x/2,B=F.y/2,ee=()=>{J<P?v.x=ze(J,0,P,-1,1):v.x=ze(J,P,F.x,-1,1)},me=()=>{Q<B?v.y=ze(Q,0,B,1,-1):v.y=ze(Q,B,F.y,1,-1)};switch(n){case"Quad":ee(),me();break;case"Side by Side":ee();break;case"Stacked":me(),me();break}M(J,Q,P,B);const Se=p.intersectObjects(be.children);Se.length>0&&et.position.copy(Se[0].point)},W=Y=>{if(!mt)return;const F=new c.Vector2;if(e.getSize(F),Y.clientX>=F.x)return;_(Y);const J=p.intersectObjects(be.children);J.length>0&&t.three.getObject(J[0].object.uuid)},H=O.current;return H.addEventListener("mousemove",_,!1),H.addEventListener("click",W,!1),()=>{H.removeEventListener("mousemove",_),H.removeEventListener("click",W)}}},[n,e]);const ce=[];return ie.forEach((p,v)=>{ce.push(v)}),u.jsxs("div",{className:"multiview",children:[u.jsx("canvas",{ref:C}),u.jsxs("div",{className:`cameras ${n==="Single"||n==="Stacked"?"single":""}`,ref:O,children:[n==="Single"&&u.jsx(u.Fragment,{children:u.jsx(Te,{camera:X,options:ce,ref:R,onSelect:p=>{re.get(X.name)?.dispose();const v=ie.get(p);v!==void 0&&(G(X),X=v,x(v,R.current))}})}),(n==="Side by Side"||n==="Stacked")&&u.jsxs(u.Fragment,{children:[u.jsx(Te,{camera:X,options:ce,ref:R,onSelect:p=>{re.get(X.name)?.dispose();const v=ie.get(p);v!==void 0&&(G(X),X=v,x(v,R.current))}}),u.jsx(Te,{camera:oe,options:ce,ref:N,onSelect:p=>{re.get(oe.name)?.dispose();const v=ie.get(p);v!==void 0&&(G(oe),oe=v,x(v,N.current))}})]}),n==="Quad"&&u.jsxs(u.Fragment,{children:[u.jsx(Te,{camera:X,options:ce,ref:R,onSelect:p=>{re.get(X.name)?.dispose();const v=ie.get(p);v!==void 0&&(G(X),X=v,x(v,R.current))}}),u.jsx(Te,{camera:oe,options:ce,ref:N,onSelect:p=>{re.get(oe.name)?.dispose();const v=ie.get(p);v!==void 0&&(G(oe),oe=v,x(v,N.current))}}),u.jsx(Te,{camera:Ae,options:ce,ref:Z,onSelect:p=>{re.get(Ae.name)?.dispose();const v=ie.get(p);v!==void 0&&(G(Ae),Ae=v,x(v,Z.current))}}),u.jsx(Te,{camera:Pe,options:ce,ref:z,onSelect:p=>{re.get(Pe.name)?.dispose();const v=ie.get(p);v!==void 0&&(G(Pe),Pe=v,x(v,z.current))}})]})]}),u.jsxs("div",{className:"settings",children:[u.jsx(ft,{index:En.indexOf(n),options:En,onSelect:p=>{p!==n&&(Ce(),a(p))},open:s,onToggle:p=>{m(p),l&&d(!1),f&&g(!1)}}),u.jsx(ft,{index:Cn.indexOf(ht),options:Cn,onSelect:p=>{if(p!==ht)switch(ht=p,ht){case"Depth":K.overrideMaterial=wa;break;case"Normals":K.overrideMaterial=Oa;break;default:case"Renderer":K.overrideMaterial=null;break;case"Wireframe":K.overrideMaterial=Ma;break;case"UVs":K.overrideMaterial=xa;break}},open:l,onToggle:p=>{s&&m(!1),d(p),f&&g(!1)}}),u.jsx(ft,{index:0,options:["Orbit Mode","Selection Mode"],onSelect:p=>{mt=p==="Selection Mode",et.visible=mt},open:f,onToggle:p=>{s&&m(!1),l&&d(!1),g(p)}})]})]})}const La="";function Aa(t){return u.jsxs("div",{className:"editor",ref:t.ref,style:t.style,children:[u.jsx("header",{children:t.header}),t.children,u.jsx("footer",{children:t.footer})]})}S.Accordion=ut,S.Application=jn,S.BaseRemote=Xe,S.ChildObject=Dt,S.ContainerObject=dn,S.Draggable=on,S.DraggableItem=rn,S.Dropdown=sn,S.DropdownItem=cn,S.Editor=Aa,S.InfiniteGridHelper=ln,S.Inspector=vn,S.MultiView=Ra,S.NavButton=jt,S.RemoteComponents=qt,S.RemoteController=Zn,S.RemoteTheatre=ve,S.RemoteThree=tn,S.RemoteTweakpane=kt,S.SceneInspector=Ea,S.SidePanel=ya,S.ToolEvents=I,S.UVMaterial=un,S.capitalize=Be,S.clamp=Pn,S.colorToHex=Zt,S.debugDispatcher=D,S.dispose=Rt,S.disposeMaterial=Qt,S.disposeTexture=_n,S.distance=kn,S.hierarchyUUID=Tt,S.isColor=Xt,S.randomID=Kt,S.resetThreeObjects=Jt,S.round=lt,Object.defineProperty(S,Symbol.toStringTag,{value:"Module"})});
|
package/src/core/Application.ts
DELETED
@@ -1,111 +0,0 @@
|
|
1
|
-
import BaseRemote from './remote/BaseRemote';
|
2
|
-
import { ApplicationMode, BroadcastCallback, BroadcastData } from './types';
|
3
|
-
|
4
|
-
export default class Application {
|
5
|
-
components: Map<string, any> = new Map();
|
6
|
-
listen?: BroadcastCallback;
|
7
|
-
|
8
|
-
// Protected
|
9
|
-
protected _debugEnabled: boolean;
|
10
|
-
protected broadcastChannel?: BroadcastChannel | undefined = undefined;
|
11
|
-
protected webSocket?: WebSocket | undefined = undefined;
|
12
|
-
protected _mode: ApplicationMode = 'app';
|
13
|
-
protected _connected = false;
|
14
|
-
protected useBC = false;
|
15
|
-
|
16
|
-
constructor(id: string, debugEnabled: boolean, useBC:boolean = true, editorHashtag: string = 'editor') {
|
17
|
-
this.editor = debugEnabled && document.location.hash.search(editorHashtag) > -1;
|
18
|
-
this._debugEnabled = debugEnabled;
|
19
|
-
|
20
|
-
if (debugEnabled) {
|
21
|
-
this.useBC = useBC;
|
22
|
-
if (useBC) {
|
23
|
-
this.broadcastChannel = new BroadcastChannel(id);
|
24
|
-
this.broadcastChannel.addEventListener('message', this.messageHandler);
|
25
|
-
} else {
|
26
|
-
this.webSocket = new WebSocket(id);
|
27
|
-
this.webSocket.addEventListener('open', this.openHandler);
|
28
|
-
this.webSocket.addEventListener('close', this.closeHandler);
|
29
|
-
this.webSocket.addEventListener('message', this.messageHandler);
|
30
|
-
}
|
31
|
-
}
|
32
|
-
}
|
33
|
-
|
34
|
-
addComponent(name: string, component: BaseRemote) {
|
35
|
-
this.components.set(name, component);
|
36
|
-
}
|
37
|
-
|
38
|
-
dispose() {
|
39
|
-
if (this.broadcastChannel !== undefined) {
|
40
|
-
this.broadcastChannel.removeEventListener('message', this.messageHandler);
|
41
|
-
}
|
42
|
-
if (this.webSocket !== undefined) {
|
43
|
-
this.webSocket.removeEventListener('open', this.openHandler);
|
44
|
-
this.webSocket.removeEventListener('close', this.closeHandler);
|
45
|
-
this.webSocket.removeEventListener('message', this.messageHandler);
|
46
|
-
}
|
47
|
-
this.components.forEach((value: BaseRemote) => {
|
48
|
-
value.dispose();
|
49
|
-
});
|
50
|
-
this.components.clear();
|
51
|
-
}
|
52
|
-
|
53
|
-
// Remote
|
54
|
-
|
55
|
-
send(data: BroadcastData) {
|
56
|
-
if (this._mode !== data.target) {
|
57
|
-
if (this.useBC) {
|
58
|
-
this.broadcastChannel?.postMessage(data);
|
59
|
-
} else if (this._connected) {
|
60
|
-
this.webSocket?.send(JSON.stringify(data));
|
61
|
-
}
|
62
|
-
}
|
63
|
-
}
|
64
|
-
|
65
|
-
private messageHandler = (evt: MessageEvent) => {
|
66
|
-
if (this.listen !== undefined) {
|
67
|
-
if (this.useBC) {
|
68
|
-
this.listen(evt.data);
|
69
|
-
} else {
|
70
|
-
this.listen(JSON.parse(evt.data));
|
71
|
-
}
|
72
|
-
}
|
73
|
-
};
|
74
|
-
|
75
|
-
private openHandler = () => {
|
76
|
-
this._connected = true;
|
77
|
-
};
|
78
|
-
|
79
|
-
private closeHandler = () => {
|
80
|
-
this._connected = false;
|
81
|
-
};
|
82
|
-
|
83
|
-
// Getters / Setters
|
84
|
-
|
85
|
-
get connected(): boolean {
|
86
|
-
return this._connected;
|
87
|
-
}
|
88
|
-
|
89
|
-
get debugEnabled(): boolean {
|
90
|
-
return this._debugEnabled;
|
91
|
-
}
|
92
|
-
|
93
|
-
get mode(): ApplicationMode {
|
94
|
-
return this._mode;
|
95
|
-
}
|
96
|
-
|
97
|
-
get isApp(): boolean {
|
98
|
-
return this._mode === 'app';
|
99
|
-
}
|
100
|
-
|
101
|
-
get editor(): boolean {
|
102
|
-
return this._mode === 'editor';
|
103
|
-
}
|
104
|
-
|
105
|
-
set editor(value: boolean) {
|
106
|
-
if (value) {
|
107
|
-
this._mode = 'editor';
|
108
|
-
document.title += ' - Editor';
|
109
|
-
}
|
110
|
-
}
|
111
|
-
}
|
@@ -1,60 +0,0 @@
|
|
1
|
-
// Core
|
2
|
-
import Application from './Application';
|
3
|
-
import { ToolEvents, debugDispatcher } from '@/editor/global';
|
4
|
-
import { BroadcastData } from './types';
|
5
|
-
import BaseRemote from './remote/BaseRemote';
|
6
|
-
import RemoteComponents, { HandleAppRemoteComponents } from './remote/RemoteComponents';
|
7
|
-
import RemoteTheatre, { HandleAppRemoteTheatre, HandleEditorRemoteTheatre, UpdateRemoteTheatre } from './remote/RemoteTheatre';
|
8
|
-
import RemoteThree, { HandleAppRemoteThree, HandleEditorRemoteThree } from './remote/RemoteThree';
|
9
|
-
import RemoteTweakpane, { HandleAppRemoteTweakpane } from './remote/RemoteTweakpane';
|
10
|
-
|
11
|
-
export default function RemoteController(app: Application) {
|
12
|
-
const appHandlers: any[] = [];
|
13
|
-
const editorHandlers: any[] = [];
|
14
|
-
|
15
|
-
// Correct handlers based on the App's components
|
16
|
-
app.components.forEach((value: BaseRemote) => {
|
17
|
-
if (value instanceof RemoteComponents) {
|
18
|
-
appHandlers.push(HandleAppRemoteComponents);
|
19
|
-
} else if (value instanceof RemoteTheatre) {
|
20
|
-
appHandlers.push(HandleAppRemoteTheatre);
|
21
|
-
editorHandlers.push(HandleEditorRemoteTheatre);
|
22
|
-
UpdateRemoteTheatre(app);
|
23
|
-
} else if (value instanceof RemoteThree) {
|
24
|
-
appHandlers.push(HandleAppRemoteThree);
|
25
|
-
editorHandlers.push(HandleEditorRemoteThree);
|
26
|
-
} else if (value instanceof RemoteTweakpane) {
|
27
|
-
appHandlers.push(HandleAppRemoteTweakpane);
|
28
|
-
}
|
29
|
-
});
|
30
|
-
|
31
|
-
function handleAppBroadcast(msg: BroadcastData) {
|
32
|
-
appHandlers.forEach((handler: any) => handler(app, msg));
|
33
|
-
switch (msg.event) {
|
34
|
-
case 'custom':
|
35
|
-
// @ts-ignore
|
36
|
-
debugDispatcher.dispatchEvent({ type: ToolEvents.CUSTOM, value: msg.data });
|
37
|
-
break;
|
38
|
-
}
|
39
|
-
}
|
40
|
-
|
41
|
-
function handleEditorBroadcast(msg: BroadcastData) {
|
42
|
-
editorHandlers.forEach((handler: any) => handler(app, msg));
|
43
|
-
switch (msg.event) {
|
44
|
-
case 'custom':
|
45
|
-
// @ts-ignore
|
46
|
-
debugDispatcher.dispatchEvent({ type: ToolEvents.CUSTOM, value: msg.data });
|
47
|
-
break;
|
48
|
-
}
|
49
|
-
}
|
50
|
-
|
51
|
-
// Begin app
|
52
|
-
|
53
|
-
app.listen = (msg: BroadcastData) => {
|
54
|
-
if (msg.target === 'editor') {
|
55
|
-
handleEditorBroadcast(msg);
|
56
|
-
} else {
|
57
|
-
handleAppBroadcast(msg);
|
58
|
-
}
|
59
|
-
};
|
60
|
-
}
|