@tomorrowevening/hermes 0.0.35 → 0.0.37
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 +144 -0
- package/dist/hermes.esm.js +3849 -0
- package/dist/hermes.umd.js +144 -0
- package/dist/style.css +1 -1
- package/package.json +20 -16
- package/src/core/Application.ts +111 -0
- package/src/core/RemoteController.ts +60 -0
- package/src/core/remote/BaseRemote.ts +16 -0
- package/src/core/remote/RemoteComponents.ts +45 -0
- package/src/core/remote/RemoteTheatre.ts +300 -0
- package/src/core/remote/RemoteThree.ts +143 -0
- package/src/core/remote/RemoteTweakpane.ts +194 -0
- package/src/core/types.ts +56 -0
- package/src/editor/Editor.tsx +20 -0
- package/src/editor/components/Draggable.tsx +40 -0
- package/src/editor/components/DraggableItem.tsx +22 -0
- package/src/editor/components/Dropdown.tsx +38 -0
- package/src/editor/components/DropdownItem.tsx +64 -0
- package/src/editor/components/NavButton.tsx +11 -0
- package/src/editor/components/content.ts +2 -0
- package/src/editor/components/icons/CloseIcon.tsx +7 -0
- package/src/editor/components/icons/DragIcon.tsx +9 -0
- package/src/editor/components/types.ts +41 -0
- package/src/editor/global.ts +20 -0
- package/src/editor/multiView/CameraWindow.tsx +74 -0
- package/src/editor/multiView/InfiniteGridHelper.ts +24 -0
- package/src/editor/multiView/InfiniteGridMaterial.ts +127 -0
- package/src/editor/multiView/MultiView.scss +101 -0
- package/src/editor/multiView/MultiView.tsx +636 -0
- package/src/editor/multiView/MultiViewData.ts +59 -0
- package/src/editor/multiView/UVMaterial.ts +55 -0
- package/src/editor/scss/_debug.scss +58 -0
- package/src/editor/scss/_draggable.scss +43 -0
- package/src/editor/scss/_dropdown.scss +84 -0
- package/src/editor/scss/_sidePanel.scss +278 -0
- package/src/editor/scss/_theme.scss +9 -0
- package/src/editor/scss/index.scss +67 -0
- package/src/editor/sidePanel/Accordion.tsx +41 -0
- package/src/editor/sidePanel/ChildObject.tsx +57 -0
- package/src/editor/sidePanel/ContainerObject.tsx +11 -0
- package/src/editor/sidePanel/SidePanel.tsx +64 -0
- package/src/editor/sidePanel/ToggleBtn.tsx +27 -0
- package/src/editor/sidePanel/inspector/Inspector.tsx +119 -0
- package/src/editor/sidePanel/inspector/InspectorField.tsx +198 -0
- package/src/editor/sidePanel/inspector/InspectorGroup.tsx +50 -0
- package/src/editor/sidePanel/inspector/SceneInspector.tsx +84 -0
- package/src/editor/sidePanel/inspector/inspector.scss +161 -0
- package/src/editor/sidePanel/inspector/utils/InspectAnimation.tsx +102 -0
- package/src/editor/sidePanel/inspector/utils/InspectCamera.tsx +75 -0
- package/src/editor/sidePanel/inspector/utils/InspectLight.tsx +62 -0
- package/src/editor/sidePanel/inspector/utils/InspectMaterial.tsx +710 -0
- package/src/editor/sidePanel/inspector/utils/InspectTransform.tsx +113 -0
- package/src/editor/sidePanel/types.ts +130 -0
- package/src/editor/sidePanel/utils.ts +278 -0
- package/src/editor/utils.ts +117 -0
- package/src/example/CustomEditor.tsx +78 -0
- package/src/example/components/App.css +6 -0
- package/src/example/components/App.tsx +246 -0
- package/src/example/constants.ts +52 -0
- package/src/example/index.scss +45 -0
- package/src/example/main.tsx +37 -0
- package/src/example/three/BaseScene.ts +42 -0
- package/src/example/three/CustomMaterial.ts +72 -0
- package/src/example/three/FBXAnimation.ts +26 -0
- package/src/example/three/Scene1.ts +225 -0
- package/src/example/three/Scene2.ts +138 -0
- package/src/example/three/loader.ts +110 -0
- package/src/index.ts +27 -0
- package/src/vite-env.d.ts +1 -0
- package/dist/hermes.js +0 -3901
- package/dist/hermes.umd.cjs +0 -144
@@ -0,0 +1,144 @@
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("three"),Wt=require("@theatre/core"),it=require("@theatre/studio"),An=require("tweakpane"),Pn=require("@tweakpane/plugin-essentials"),P=require("react"),rn=require("framer-motion");function kn(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 _n=kn(Pn);function Ge(t){return t.substring(0,1).toUpperCase()+t.substring(1)}function jn(t,n,a){return Math.min(n,Math.max(t,a))}function Dn(t,n){const a=t-n;return Math.sqrt(a*a)}function on(){return Math.round(Math.random()*1e6).toString()}function sn(t){return t.r!==void 0&&t.g!==void 0&&t.b!==void 0}function cn(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 St(t,n=1){return Number(t.toFixed(n))}exports.totalThreeObjects=0;const ln=()=>{exports.totalThreeObjects=0},Ut=t=>{if(!t)return;let n=t.name.replace(" ","");n.length===0&&(n=`obj_${exports.totalThreeObjects}`,exports.totalThreeObjects++),t.parent!==null&&(n=`${t.parent.uuid}.${n}`),t.uuid=n,t.children.forEach(a=>{Ut(a)})},In=t=>{t?.dispose()},un=t=>{t&&(Array.isArray(t)?t.forEach(n=>n.dispose()):t.dispose())},Bt=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)):Bt(n)}if(t.parent&&t.parent.remove(t),t.isMesh){const n=t;n.geometry?.dispose(),un(n.material)}t.dispose!==void 0&&t.dispose()}};class Nn{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 ot{app;constructor(n){this.app=n}dispose(){}}class dn extends ot{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 Ln(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 fn=()=>{};class be extends ot{project;sheets=new Map;sheetObjects=new Map;sheetObjectCBs=new Map;sheetObjectUnsubscribe=new Map;static rafDriver=null;init(n,a){return this.project=Wt.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:fn);const d=l.onValuesChange(f=>{if(this.app.editor){for(const y in f){const C=f[y];typeof C=="object"&&sn(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 be.rafDriver||(be.rafDriver=Wt.createRafDriver()),be.rafDriver}}let xe;function Fn(t,n){t.components.forEach(a=>{if(a instanceof be){let e;const o=a;switch(n.event){case"setSheet":e=o.sheets.get(n.data.sheet),e!==void 0&&(xe=e,it.setSelection([e]));break;case"setSheetObject":e=o.sheetObjects.get(`${n.data.sheet}_${n.data.key}`),e!==void 0&&it.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),xe!==void 0&&(xe.sequence.position=n.data.position);break}}})}function Un(t){if(t.editor){let n;t.components.forEach(s=>{s instanceof be&&(n=s)}),it.ui.restore(),it.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},xe=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(xe!==void 0&&a!==xe.sequence.position){a=xe.sequence.position;const s=xe;t.send({event:"updateTimeline",target:"app",data:{position:a,sheet:s.address.sheetId}})}},o=()=>{e(),requestAnimationFrame(o)};e(),o()}else it.ui.hide()}function Bn(t,n){t.editor&&t.components.forEach(a=>{if(a instanceof be){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 Vn(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 hn(t){const n={name:t.name,type:t.type,uuid:t.uuid,children:[]};return t.children.forEach(a=>{n.children.push(hn(a))}),n}function zn(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 Hn(t){switch(t){case"blendSrcAlpha":case"blendDstAlpha":case"blendEquationAlpha":case"clippingPlanes":case"shadowSide":case"precision":return!0}return!1}function He(t){const n={};for(const a in t){if(a.substring(0,1)==="_"||a.substring(0,2)==="is"||Hn(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]=zn(n[a]));else n[a]={src:""};break}}return n}function Dt(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(He(s))}),n.material=o}else n.material=He(e.material)}else if(a.search("points")>-1){const e=t;if(Array.isArray(e.material)){const o=[];e.material.forEach(s=>{o.push(He(s))}),n.material=o}else n.material=He(e.material)}else if(a.search("line")>-1){const e=t;if(Array.isArray(e.material)){const o=[];e.material.forEach(s=>{o.push(He(s))}),n.material=o}else n.material=He(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 Yn(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 te(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 Lt(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 pn extends ot{scene=void 0;getObject(n){this.app.debugEnabled&&this.app.send({event:"getObject",target:"app",data:n})}setObject(n){const a=Dt(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;ln(),Ut(this.scene);const a=hn(this.scene);this.app.send({event:"setScene",target:"editor",data:a})}addCamera(n){if(!this.app.debugEnabled)return;const a=Dt(n);this.app.send({event:"addCamera",target:"editor",data:a})}removeCamera(n){if(!this.app.debugEnabled)return;const a=Dt(n);this.app.send({event:"removeCamera",target:"editor",data:a})}}function Gn(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 Wn(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 Vt extends ot{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 An.Pane({title:"GUI"}),this.pane.registerPlugin(_n)}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:fn;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 $n(t,n){t.components.forEach(a=>{if(a instanceof Vt){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 Ft={exports:{}},et={};/**
|
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 $t;function qn(){if($t)return et;$t=1;var t=P,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,x=null;f!==void 0&&(C=""+f),d.key!==void 0&&(C=""+d.key),d.ref!==void 0&&(x=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:x,props:y,_owner:o.current}}return et.Fragment=a,et.jsx=m,et.jsxs=m,et}var tt={};/**
|
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 qt;function Kn(){return qt||(qt=1,process.env.NODE_ENV!=="production"&&function(){var t=P,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"),x=Symbol.for("react.offscreen"),T=Symbol.iterator,j="@@iterator";function q(i){if(i===null||typeof i!="object")return null;var p=T&&i[T]||i[j];return typeof p=="function"?p:null}var V=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function w(i){{for(var p=arguments.length,b=new Array(p>1?p-1:0),S=1;S<p;S++)b[S-1]=arguments[S];Y("error",i,b)}}function Y(i,p,b){{var S=V.ReactDebugCurrentFrame,N=S.getStackAddendum();N!==""&&(p+="%s",b=b.concat([N]));var B=b.map(function(_){return String(_)});B.unshift("Warning: "+p),Function.prototype.apply.call(console[i],console,B)}}var ye=!1,le=!1,se=!1,h=!1,v=!1,O;O=Symbol.for("react.module.reference");function k(i){return!!(typeof i=="string"||typeof i=="function"||i===e||i===s||v||i===o||i===f||i===g||h||i===x||ye||le||se||typeof i=="object"&&i!==null&&(i.$$typeof===C||i.$$typeof===y||i.$$typeof===m||i.$$typeof===l||i.$$typeof===d||i.$$typeof===O||i.getModuleId!==void 0))}function G(i,p,b){var S=i.displayName;if(S)return S;var N=p.displayName||p.name||"";return N!==""?b+"("+N+")":b}function z(i){return i.displayName||"Context"}function H(i){if(i==null)return null;if(typeof i.tag=="number"&&w("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 p=i;return z(p)+".Consumer";case m:var b=i;return z(b._context)+".Provider";case d:return G(i,i.render,"ForwardRef");case y:var S=i.displayName||null;return S!==null?S:H(i.type)||"Memo";case C:{var N=i,B=N._payload,_=N._init;try{return H(_(B))}catch{return null}}}return null}var L=Object.assign,K=0,X,R,U,Q,pe,Ee,ct;function We(){}We.__reactDisabledLog=!0;function Mt(){{if(K===0){X=console.log,R=console.info,U=console.warn,Q=console.error,pe=console.group,Ee=console.groupCollapsed,ct=console.groupEnd;var i={configurable:!0,enumerable:!0,value:We,writable:!0};Object.defineProperties(console,{info:i,log:i,warn:i,error:i,group:i,groupCollapsed:i,groupEnd:i})}K++}}function Tt(){{if(K--,K===0){var i={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:L({},i,{value:X}),info:L({},i,{value:R}),warn:L({},i,{value:U}),error:L({},i,{value:Q}),group:L({},i,{value:pe}),groupCollapsed:L({},i,{value:Ee}),groupEnd:L({},i,{value:ct})})}K<0&&w("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var $e=V.ReactCurrentDispatcher,qe;function Ue(i,p,b){{if(qe===void 0)try{throw Error()}catch(N){var S=N.stack.trim().match(/\n( *(at )?)/);qe=S&&S[1]||""}return`
|
18
|
+
`+qe+i}}var Be=!1,we;{var lt=typeof WeakMap=="function"?WeakMap:Map;we=new lt}function ut(i,p){if(!i||Be)return"";{var b=we.get(i);if(b!==void 0)return b}var S;Be=!0;var N=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var B;B=$e.current,$e.current=null,Mt();try{if(p){var _=function(){throw Error()};if(Object.defineProperty(_.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(_,[])}catch(me){S=me}Reflect.construct(i,[],_)}else{try{_.call()}catch(me){S=me}i.call(_.prototype)}}else{try{throw Error()}catch(me){S=me}i()}}catch(me){if(me&&S&&typeof me.stack=="string"){for(var A=me.stack.split(`
|
19
|
+
`),ce=S.stack.split(`
|
20
|
+
`),J=A.length-1,ee=ce.length-1;J>=1&&ee>=0&&A[J]!==ce[ee];)ee--;for(;J>=1&&ee>=0;J--,ee--)if(A[J]!==ce[ee]){if(J!==1||ee!==1)do if(J--,ee--,ee<0||A[J]!==ce[ee]){var fe=`
|
21
|
+
`+A[J].replace(" at new "," at ");return i.displayName&&fe.includes("<anonymous>")&&(fe=fe.replace("<anonymous>",i.displayName)),typeof i=="function"&&we.set(i,fe),fe}while(J>=1&&ee>=0);break}}}finally{Be=!1,$e.current=B,Tt(),Error.prepareStackTrace=N}var ze=i?i.displayName||i.name:"",Gt=ze?Ue(ze):"";return typeof i=="function"&&we.set(i,Gt),Gt}function Rt(i,p,b){return ut(i,!1)}function dt(i){var p=i.prototype;return!!(p&&p.isReactComponent)}function Oe(i,p,b){if(i==null)return"";if(typeof i=="function")return ut(i,dt(i));if(typeof i=="string")return Ue(i);switch(i){case f:return Ue("Suspense");case g:return Ue("SuspenseList")}if(typeof i=="object")switch(i.$$typeof){case d:return Rt(i.render);case y:return Oe(i.type,p,b);case C:{var S=i,N=S._payload,B=S._init;try{return Oe(B(N),p,b)}catch{}}}return""}var Me=Object.prototype.hasOwnProperty,ft={},ht=V.ReactDebugCurrentFrame;function Te(i){if(i){var p=i._owner,b=Oe(i.type,i._source,p?p.type:null);ht.setExtraStackFrame(b)}else ht.setExtraStackFrame(null)}function Ke(i,p,b,S,N){{var B=Function.call.bind(Me);for(var _ in i)if(B(i,_)){var A=void 0;try{if(typeof i[_]!="function"){var ce=Error((S||"React class")+": "+b+" type `"+_+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof i[_]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw ce.name="Invariant Violation",ce}A=i[_](p,_,S,b,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(J){A=J}A&&!(A instanceof Error)&&(Te(N),w("%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).",S||"React class",b,_,typeof A),Te(null)),A instanceof Error&&!(A.message in ft)&&(ft[A.message]=!0,Te(N),w("Failed %s type: %s",b,A.message),Te(null))}}}var Re=Array.isArray;function Xe(i){return Re(i)}function At(i){{var p=typeof Symbol=="function"&&Symbol.toStringTag,b=p&&i[Symbol.toStringTag]||i.constructor.name||"Object";return b}}function pt(i){try{return mt(i),!1}catch{return!0}}function mt(i){return""+i}function vt(i){if(pt(i))return w("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",At(i)),mt(i)}var Ce=V.ReactCurrentOwner,Ze={key:!0,ref:!0,__self:!0,__source:!0},Je,gt,Ve;Ve={};function Pt(i){if(Me.call(i,"ref")){var p=Object.getOwnPropertyDescriptor(i,"ref").get;if(p&&p.isReactWarning)return!1}return i.ref!==void 0}function kt(i){if(Me.call(i,"key")){var p=Object.getOwnPropertyDescriptor(i,"key").get;if(p&&p.isReactWarning)return!1}return i.key!==void 0}function bt(i,p){if(typeof i.ref=="string"&&Ce.current&&p&&Ce.current.stateNode!==p){var b=H(Ce.current.type);Ve[b]||(w('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',H(Ce.current.type),i.ref),Ve[b]=!0)}}function Se(i,p){{var b=function(){Je||(Je=!0,w("%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)",p))};b.isReactWarning=!0,Object.defineProperty(i,"key",{get:b,configurable:!0})}}function Yt(i,p){{var b=function(){gt||(gt=!0,w("%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)",p))};b.isReactWarning=!0,Object.defineProperty(i,"ref",{get:b,configurable:!0})}}var r=function(i,p,b,S,N,B,_){var A={$$typeof:n,type:i,key:p,ref:b,props:_,_owner:B};return A._store={},Object.defineProperty(A._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(A,"_self",{configurable:!1,enumerable:!1,writable:!1,value:S}),Object.defineProperty(A,"_source",{configurable:!1,enumerable:!1,writable:!1,value:N}),Object.freeze&&(Object.freeze(A.props),Object.freeze(A)),A};function E(i,p,b,S,N){{var B,_={},A=null,ce=null;b!==void 0&&(vt(b),A=""+b),kt(p)&&(vt(p.key),A=""+p.key),Pt(p)&&(ce=p.ref,bt(p,N));for(B in p)Me.call(p,B)&&!Ze.hasOwnProperty(B)&&(_[B]=p[B]);if(i&&i.defaultProps){var J=i.defaultProps;for(B in J)_[B]===void 0&&(_[B]=J[B])}if(A||ce){var ee=typeof i=="function"?i.displayName||i.name||"Unknown":i;A&&Se(_,ee),ce&&Yt(_,ee)}return r(i,A,ce,N,S,Ce.current,_)}}var M=V.ReactCurrentOwner,F=V.ReactDebugCurrentFrame;function Z(i){if(i){var p=i._owner,b=Oe(i.type,i._source,p?p.type:null);F.setExtraStackFrame(b)}else F.setExtraStackFrame(null)}var ue;ue=!1;function ie(i){return typeof i=="object"&&i!==null&&i.$$typeof===n}function _t(){{if(M.current){var i=H(M.current.type);if(i)return`
|
22
|
+
|
23
|
+
Check the render method of \``+i+"`."}return""}}function jt(i){{if(i!==void 0){var p=i.fileName.replace(/^.*[\\\/]/,""),b=i.lineNumber;return`
|
24
|
+
|
25
|
+
Check your code at `+p+":"+b+"."}return""}}var Qe={};function he(i){{var p=_t();if(!p){var b=typeof i=="string"?i:i.displayName||i.name;b&&(p=`
|
26
|
+
|
27
|
+
Check the top-level render call using <`+b+">.")}return p}}function de(i,p){{if(!i._store||i._store.validated||i.key!=null)return;i._store.validated=!0;var b=he(p);if(Qe[b])return;Qe[b]=!0;var S="";i&&i._owner&&i._owner!==M.current&&(S=" It was passed a child from "+H(i._owner.type)+"."),Z(i),w('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',b,S),Z(null)}}function Ae(i,p){{if(typeof i!="object")return;if(Xe(i))for(var b=0;b<i.length;b++){var S=i[b];ie(S)&&de(S,p)}else if(ie(i))i._store&&(i._store.validated=!0);else if(i){var N=q(i);if(typeof N=="function"&&N!==i.entries)for(var B=N.call(i),_;!(_=B.next()).done;)ie(_.value)&&de(_.value,p)}}}function Pe(i){{var p=i.type;if(p==null||typeof p=="string")return;var b;if(typeof p=="function")b=p.propTypes;else if(typeof p=="object"&&(p.$$typeof===d||p.$$typeof===y))b=p.propTypes;else return;if(b){var S=H(p);Ke(b,i.props,"prop",S,i)}else if(p.PropTypes!==void 0&&!ue){ue=!0;var N=H(p);w("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",N||"Unknown")}typeof p.getDefaultProps=="function"&&!p.getDefaultProps.isReactClassApproved&&w("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function ke(i){{for(var p=Object.keys(i.props),b=0;b<p.length;b++){var S=p[b];if(S!=="children"&&S!=="key"){Z(i),w("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",S),Z(null);break}}i.ref!==null&&(Z(i),w("Invalid attribute `ref` supplied to `React.Fragment`."),Z(null))}}function _e(i,p,b,S,N,B){{var _=k(i);if(!_){var A="";(i===void 0||typeof i=="object"&&i!==null&&Object.keys(i).length===0)&&(A+=" 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 ce=jt(N);ce?A+=ce:A+=_t();var J;i===null?J="null":Xe(i)?J="array":i!==void 0&&i.$$typeof===n?(J="<"+(H(i.type)||"Unknown")+" />",A=" Did you accidentally export a JSX literal instead of a component?"):J=typeof i,w("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",J,A)}var ee=E(i,p,b,N,B);if(ee==null)return ee;if(_){var fe=p.children;if(fe!==void 0)if(S)if(Xe(fe)){for(var ze=0;ze<fe.length;ze++)Ae(fe[ze],i);Object.freeze&&Object.freeze(fe)}else w("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 Ae(fe,i)}return i===e?ke(ee):Pe(ee),ee}}function On(i,p,b){return _e(i,p,b,!0)}function Mn(i,p,b){return _e(i,p,b,!1)}var Tn=Mn,Rn=On;tt.Fragment=e,tt.jsx=Tn,tt.jsxs=Rn}()),tt}process.env.NODE_ENV==="production"?Ft.exports=qn():Ft.exports=Kn();var u=Ft.exports;function zt(t){return t.title.search("<")>-1?u.jsx("button",{className:"svg",dangerouslySetInnerHTML:{__html:t.title}}):u.jsx("button",{children:t.title})}const Xn=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"})]}),Zn=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 mn(t){return u.jsx(rn.Reorder.Item,{value:t.title,children:u.jsxs("div",{children:[Zn,u.jsx("span",{children:t.title}),u.jsx("button",{className:"closeIcon",onClick:()=>{t.onDelete(t.index)},children:Xn})]})},t.title)}function vn(t){const[n,a]=P.useState(!1),[e,o]=P.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(mn,{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(zt,{title:t.title}),u.jsx(rn.Reorder.Group,{axis:"y",values:e,onReorder:s,style:{visibility:n?"visible":"hidden"},children:l})]})}function gn(t){const[n,a]=P.useState(!1),e=[];t.options.map((s,m)=>{t.onSelect!==void 0&&(s.onSelect=t.onSelect),e.push(u.jsx(bn,{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(zt,{title:t.title}),u.jsx("ul",{style:{visibility:n?"visible":"hidden"},children:e})]})}function bn(t){const{option:n}=t,[a,e]=P.useState("");let o;switch(n.type){case"draggable":o=u.jsx(vn,{title:n.title,options:n.value,onDragComplete:s=>{n.onDragComplete!==void 0&&n.onDragComplete(s)},subdropdown:!0});break;case"dropdown":o=u.jsx(gn,{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},on())}function Jn(t){const n=[],a=[];t.components.forEach(s=>{s instanceof dn?n.push(Ln):s instanceof be?(n.push(Fn),a.push(Bn),Un(t)):s instanceof pn?(n.push(Gn),a.push(Wn)):s instanceof Vt&&n.push($n)});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 Qn=`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
|
+
}`,ea=`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 ta 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:Qn,fragmentShader:ea,name:"InfiniteGrid",depthWrite:!1})}}class yn extends c.Mesh{gridMaterial;constructor(){const n=new ta;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 na=`#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
|
+
}`,aa=`
|
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 En extends c.ShaderMaterial{constructor(){super({defines:{USE_UV:""},vertexShader:na,fragmentShader:aa})}}function wt(t){const[n,a]=P.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:Ge(t.label)})]}),t.button,u.jsx("div",{className:n?"open":"",children:u.jsx("div",{children:t.children})})]})}function Ht(t){const[n,a]=P.useState(!1),e=t.child.children.length>0,o=[];return t.child.children.length>0&&t.child.children.map(s=>{o.push(u.jsx(Ht,{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 ${Vn(t.child)}`})]}),u.jsx("div",{className:n?"open":"",children:u.jsx("div",{className:"container",children:o})})]},Math.random())}function Cn(t){const n=[];return t.child.children.map(a=>{n.push(u.jsx(Ht,{child:a,three:t.three},Math.random()))}),u.jsx("div",{className:`scene ${t.class!==void 0?t.class:""}`,children:n})}const ia="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAACXBIWXMAAAsTAAALEwEAmpwYAAAA5klEQVRoge2Y0Q6EIAwE6cX//+X6cCFpSMEKVTdk501OpRNKiyelFC0b8Ps6gCwoggZF0KAIGhRBgyJoUAQNiqCxjciR9SLV//eZiAyvK3U8i/QVaQO2YyLSFVvlkdTKDjJCukh2ykR5ZEW+kHmlatl90RaBtDkK/w7CYhuRUEO0ee3l+J3m55Vm+17vtwjTnV1V3QA8qfbeUXCzRWDpiLLS+OyzvRW7IzW9R+okvclsqR09743bo0yUpc1+lSJvNsa002+Euk9GKzV7SmZDRIMiaFAEDYqgQRE0KIIGRdCgCBoUQeMEMERadX7YUz8AAAAASUVORK5CYII=";function ra(t){return"items"in t}function Le(t){const n=[];return t.items.forEach(a=>{ra(a)?n.push(u.jsx(Le,{title:Ge(a.title),items:a.items},Math.random())):n.push(u.jsx(at,{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(wt,{label:t.title,open:t.expanded===!0,children:n})}function oa(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 je(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 sa(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 ca(){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 la=[{title:"Front",value:c.FrontSide},{title:"Back",value:c.BackSide},{title:"Double",value:c.DoubleSide}],ua=[{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}],da=[{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}],fa=[{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}],ha=[{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 nt(t,n){t.needsUpdate=!0,t.type="option",t.options=n}function Kt(t,n,a){const e=[];for(const o in t){if(!oa(o))continue;const s=typeof t[o],m=t[o];if(s==="boolean"||s==="number"||s==="string"){const l={title:je(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&&te(y,`material.${f}`,g)}};switch(o){case"blending":nt(l,ua);break;case"blendDst":nt(l,ha);break;case"blendEquation":nt(l,da);break;case"blendSrc":nt(l,fa);break;case"side":nt(l,la);break}sa(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:`${Ge(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&&(te(f,`material.${o}`,l.latest),f.material.needsUpdate=!0)}})}else if(s==="object")if(m.isColor)e.push({title:je(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&&te(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&&te(y,`material.${o}`,g)}});e.push({title:je(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:je(o),type:"image",value:f,onChange:(y,C)=>{a.createTexture(n.uuid,`material.${o}`,C);const x=a.scene?.getObjectByProperty("uuid",n.uuid);x!==void 0&&Lt(C).then(T=>{te(x,`material.${o}`,T),te(x,"material.needsUpdate",!0)})}}):l.push({title:`${je(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 x=a.scene?.getObjectByProperty("uuid",n.uuid);x!==void 0&&te(x,`material.${o}.${d}`,C)}});break;case"object":if(f.value!==void 0&&f.value.src!==void 0)l.push({title:je(d),type:"image",value:f.value.src,onChange:(y,C)=>{a.createTexture(n.uuid,`material.${o}.${d}.value`,m);const x=a.scene?.getObjectByProperty("uuid",n.uuid);x!==void 0&&Lt(C).then(T=>{te(x,`material.${o}.${d}.value`,T)})}});else if(o==="uniforms"){const y=f.value,C=(x,T,j)=>({title:x,type:"number",value:j,step:.01,onChange:(q,V)=>{const w=`material.uniforms.${d}.value.${T}`;a.updateObject(n.uuid,w,V);const Y=a.scene?.getObjectByProperty("uuid",n.uuid);Y!==void 0&&te(Y,w,V)}});if(typeof f.value=="number")l.push({title:d,type:"number",value:f.value,onChange:(x,T)=>{const j=`material.${o}.${x}.value`;a.updateObject(n.uuid,j,T);const q=a.scene?.getObjectByProperty("uuid",n.uuid);q!==void 0&&te(q,j,T)}});else if(y.r!==void 0&&y.g!==void 0&&y.b!==void 0)l.push({title:d,type:"color",value:f.value,onChange:(x,T)=>{const j=new c.Color(T),q=`material.${o}.${x}.value`;a.updateObject(n.uuid,q,j);const V=a.scene?.getObjectByProperty("uuid",n.uuid);V!==void 0&&te(V,q,j)}});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 x=y.elements,T=[];for(let j=0;j<x.length;j++)T.push(C(j.toString(),j.toString(),x[j]));l.push({title:d,items:T})}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 x=a.scene?.getObjectByProperty("uuid",n.uuid);x!==void 0&&te(x,`material.${o}.${d}.value`,C)}});break}}l.length>0&&e.push({title:je(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 pa(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(Le,{title:`Material ${s}`,items:Kt(a[s],t,n)},`Material ${s}`));return u.jsx(u.Fragment,{children:e})}else return u.jsx(Le,{title:"Material",items:Kt(a,t,n)})}function at(t){let n=t.value;n!==void 0&&n.isColor!==void 0&&(n=cn(t.value));const[a,e]=P.useState(n),o=P.useRef(null),s=P.useRef(null),m=P.useRef(null);P.useEffect(()=>{let g=!1,y=-1,C=0,x=Number(a);const T=Y=>{g=!0,C=x,y=Y.clientX},j=Y=>{if(!g)return;const ye=t.step!==void 0?t.step:1,le=(Y.clientX-y)*ye;x=Number((C+le).toFixed(4)),s.current!==null&&(s.current.value=x.toString()),t.onChange!==void 0&&t.onChange(t.prop!==void 0?t.prop:t.title,x)},q=()=>{g=!1},V=()=>{g=!1},w=t.type==="number";return w&&(o.current?.addEventListener("mousedown",T,!1),document.addEventListener("mouseup",q,!1),document.addEventListener("mousemove",j,!1),document.addEventListener("contextmenu",V,!1)),()=>{w&&(o.current?.removeEventListener("mousedown",T),document.removeEventListener("mouseup",q),document.removeEventListener("mousemove",j),document.removeEventListener("contextmenu",V))}},[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:Ge(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:()=>{ca().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:ia}),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:Ge(g.title)},y))})})]})}function Xt(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 ma(t,n){const a=[];if(t.perspectiveCameraInfo!==void 0)for(const e in t.perspectiveCameraInfo)a.push({title:Xt(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&&(te(m,o,s),m.updateProjectionMatrix())}});else if(t.orthographicCameraInfo!==void 0)for(const e in t.orthographicCameraInfo)a.push({title:Xt(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&&(te(m,o,s),m.updateProjectionMatrix())}});return u.jsx(Le,{title:"Camera",items:a})}const va=Math.PI/180,ga=180/Math.PI;function Ye(t,n,a,e,o){return e+(t-n)*(o-e)/(a-n)}function ba(t){return t*va}function It(t){return t*ga}function ya(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&&te(g,d,f)},l=(d,f)=>{m(d,ba(f))};return u.jsx(Le,{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:St(It(o.x)),min:-360,max:360,step:.1,onChange:l},{title:"Rotation Y",prop:"rotation.y",type:"number",value:St(It(o.y)),min:-360,max:360,step:.1,onChange:l},{title:"Rotation Z",prop:"rotation.z",type:"number",value:St(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 Zt(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 Ea(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:Zt(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&&te(d,s,l)}}):a.push({title:Zt(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&&te(l,s,m)}}))}return u.jsx(Le,{title:"Light",items:a})}function Ca(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(Le,{title:"Animation",items:a})}const Sn={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 ne={...Sn};function xn(t){const[n,a]=P.useState(-1);P.useEffect(()=>{function m(d){ne={...d.value},a(Date.now())}function l(){ne={...Sn},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=ne.type.toLowerCase(),o=ne.animations.length>0||ne.mixer!==void 0,s=e.search("mesh")>-1||e.search("line")>-1||e.search("points")>-1;return u.jsx(wt,{label:"Inspector",children:u.jsx("div",{id:"Inspector",className:t.class,children:ne.uuid.length>0&&u.jsxs(u.Fragment,{children:[u.jsxs(u.Fragment,{children:[u.jsx(at,{type:"string",title:"Name",prop:"name",value:ne.name,disabled:!0}),u.jsx(at,{type:"string",title:"Type",prop:"type",value:ne.type,disabled:!0}),u.jsx(at,{type:"string",title:"UUID",prop:"uuid",value:ne.uuid,disabled:!0}),u.jsx(at,{type:"boolean",title:"Visible",prop:"visible",value:ne.visible,onChange:(m,l)=>{t.three.updateObject(ne.uuid,m,l);const d=t.three.scene?.getObjectByProperty("uuid",ne.uuid);d!==void 0&&te(d,m,l)}})]}),u.jsxs(u.Fragment,{children:[ya(ne,t.three),o?Ca(ne,t.three):null,e.search("camera")>-1?ma(ne,t.three):null,e.search("light")>-1?Ea(ne,t.three):null,s?pa(ne,t.three):null]})]})},n)},"Inspector")}class Sa extends P.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(wt,{label:a,open:!0,children:u.jsx(u.Fragment,{children:n&&u.jsx(Cn,{child:this.componentState.scene,three:this.three})})}),u.jsx(xn,{three:this.three})]})},"SidePanel")}setScene=n=>{this.setState(()=>({scene:n.value}))};get componentState(){return this.state}}function xa(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&&te(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;Lt(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?Yn(C,y)[d](g):C[d](g)}catch(x){console.log("Error requesting method:"),console.log(x),console.log(d),console.log(g)}};return P.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 Jt={type:"change"},Nt={type:"start"},Qt={type:"end"},yt=new c.Ray,en=new c.Plane,wa=Math.cos(70*c.MathUtils.DEG2RAD);class Oa 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",Ze),this._domElementKeyEvents=r},this.stopListenToKeyEvents=function(){this._domElementKeyEvents.removeEventListener("keydown",Ze),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(Jt),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)),M=E.clone().invert(),F=new c.Vector3,Z=new c.Quaternion,ue=new c.Vector3,ie=2*Math.PI;return function(jt=null){const Qe=e.object.position;r.copy(Qe).sub(e.target),r.applyQuaternion(E),l.setFromVector3(r),e.autoRotate&&s===o.NONE&&z(k(jt)),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,de=e.maxAzimuthAngle;isFinite(he)&&isFinite(de)&&(he<-Math.PI?he+=ie:he>Math.PI&&(he-=ie),de<-Math.PI?de+=ie:de>Math.PI&&(de-=ie),he<=de?l.theta=Math.max(he,Math.min(de,l.theta)):l.theta=l.theta>(he+de)/2?Math.max(he,l.theta):Math.min(de,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&&se||e.object.isOrthographicCamera?l.radius=pe(l.radius):l.radius=pe(l.radius*f),r.setFromSpherical(l),r.applyQuaternion(M),Qe.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 Ae=!1;if(e.zoomToCursor&&se){let Pe=null;if(e.object.isPerspectiveCamera){const ke=r.length();Pe=pe(ke*f);const _e=ke-Pe;e.object.position.addScaledVector(ye,_e),e.object.updateMatrixWorld()}else if(e.object.isOrthographicCamera){const ke=new c.Vector3(le.x,le.y,0);ke.unproject(e.object),e.object.zoom=Math.max(e.minZoom,Math.min(e.maxZoom,e.object.zoom/f)),e.object.updateProjectionMatrix(),Ae=!0;const _e=new c.Vector3(le.x,le.y,0);_e.unproject(e.object),e.object.position.sub(_e).add(ke),e.object.updateMatrixWorld(),Pe=r.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),e.zoomToCursor=!1;Pe!==null&&(this.screenSpacePanning?e.target.set(0,0,-1).transformDirection(e.object.matrix).multiplyScalar(Pe).add(e.object.position):(yt.origin.copy(e.object.position),yt.direction.set(0,0,-1).transformDirection(e.object.matrix),Math.abs(e.object.up.dot(yt.direction))<wa?n.lookAt(e.target):(en.setFromNormalAndCoplanarPoint(e.object.up,e.target),yt.intersectPlane(en,e.target))))}else e.object.isOrthographicCamera&&(Ae=f!==1,Ae&&(e.object.zoom=Math.max(e.minZoom,Math.min(e.maxZoom,e.object.zoom/f)),e.object.updateProjectionMatrix()));return f=1,se=!1,Ae||F.distanceToSquared(e.object.position)>m||8*(1-Z.dot(e.object.quaternion))>m||ue.distanceToSquared(e.target)>0?(e.dispatchEvent(Jt),F.copy(e.object.position),Z.copy(e.object.quaternion),ue.copy(e.target),!0):!1}}(),this.dispose=function(){e.domElement.removeEventListener("contextmenu",Ve),e.domElement.removeEventListener("pointerdown",Te),e.domElement.removeEventListener("pointercancel",Re),e.domElement.removeEventListener("wheel",pt),e.domElement.removeEventListener("pointermove",Ke),e.domElement.removeEventListener("pointerup",Re),e._domElementKeyEvents!==null&&(e._domElementKeyEvents.removeEventListener("keydown",Ze),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,x=new c.Vector2,T=new c.Vector2,j=new c.Vector2,q=new c.Vector2,V=new c.Vector2,w=new c.Vector2,Y=new c.Vector2,ye=new c.Vector3,le=new c.Vector2;let se=!1;const h=[],v={};let O=!1;function k(r){return r!==null?2*Math.PI/60*e.autoRotateSpeed*r:2*Math.PI/60/60*e.autoRotateSpeed}function G(r){const E=Math.abs(r*.01);return Math.pow(.95,e.zoomSpeed*E)}function z(r){d.theta-=r}function H(r){d.phi-=r}const L=function(){const r=new c.Vector3;return function(M,F){r.setFromMatrixColumn(F,0),r.multiplyScalar(-M),g.add(r)}}(),K=function(){const r=new c.Vector3;return function(M,F){e.screenSpacePanning===!0?r.setFromMatrixColumn(F,1):(r.setFromMatrixColumn(F,0),r.crossVectors(e.object.up,r)),r.multiplyScalar(M),g.add(r)}}(),X=function(){const r=new c.Vector3;return function(M,F){const Z=e.domElement;if(e.object.isPerspectiveCamera){const ue=e.object.position;r.copy(ue).sub(e.target);let ie=r.length();ie*=Math.tan(e.object.fov/2*Math.PI/180),L(2*M*ie/Z.clientHeight,e.object.matrix),K(2*F*ie/Z.clientHeight,e.object.matrix)}else e.object.isOrthographicCamera?(L(M*(e.object.right-e.object.left)/e.object.zoom/Z.clientWidth,e.object.matrix),K(F*(e.object.top-e.object.bottom)/e.object.zoom/Z.clientHeight,e.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),e.enablePan=!1)}}();function R(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 U(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 Q(r,E){if(!e.zoomToCursor)return;se=!0;const M=e.domElement.getBoundingClientRect(),F=r-M.left,Z=E-M.top,ue=M.width,ie=M.height;le.x=F/ue*2-1,le.y=-(Z/ie)*2+1,ye.set(le.x,le.y,1).unproject(e.object).sub(e.object.position).normalize()}function pe(r){return Math.max(e.minDistance,Math.min(e.maxDistance,r))}function Ee(r){y.set(r.clientX,r.clientY)}function ct(r){Q(r.clientX,r.clientX),V.set(r.clientX,r.clientY)}function We(r){T.set(r.clientX,r.clientY)}function Mt(r){C.set(r.clientX,r.clientY),x.subVectors(C,y).multiplyScalar(e.rotateSpeed);const E=e.domElement;z(2*Math.PI*x.x/E.clientHeight),H(2*Math.PI*x.y/E.clientHeight),y.copy(C),e.update()}function Tt(r){w.set(r.clientX,r.clientY),Y.subVectors(w,V),Y.y>0?R(G(Y.y)):Y.y<0&&U(G(Y.y)),V.copy(w),e.update()}function $e(r){j.set(r.clientX,r.clientY),q.subVectors(j,T).multiplyScalar(e.panSpeed),X(q.x,q.y),T.copy(j),e.update()}function qe(r){Q(r.clientX,r.clientY),r.deltaY<0?U(G(r.deltaY)):r.deltaY>0&&R(G(r.deltaY)),e.update()}function Ue(r){let E=!1;switch(r.code){case e.keys.UP:r.ctrlKey||r.metaKey||r.shiftKey?H(2*Math.PI*e.rotateSpeed/e.domElement.clientHeight):X(0,e.keyPanSpeed),E=!0;break;case e.keys.BOTTOM:r.ctrlKey||r.metaKey||r.shiftKey?H(-2*Math.PI*e.rotateSpeed/e.domElement.clientHeight):X(0,-e.keyPanSpeed),E=!0;break;case e.keys.LEFT:r.ctrlKey||r.metaKey||r.shiftKey?z(2*Math.PI*e.rotateSpeed/e.domElement.clientHeight):X(e.keyPanSpeed,0),E=!0;break;case e.keys.RIGHT:r.ctrlKey||r.metaKey||r.shiftKey?z(-2*Math.PI*e.rotateSpeed/e.domElement.clientHeight):X(-e.keyPanSpeed,0),E=!0;break}E&&(r.preventDefault(),e.update())}function Be(r){if(h.length===1)y.set(r.pageX,r.pageY);else{const E=Se(r),M=.5*(r.pageX+E.x),F=.5*(r.pageY+E.y);y.set(M,F)}}function we(r){if(h.length===1)T.set(r.pageX,r.pageY);else{const E=Se(r),M=.5*(r.pageX+E.x),F=.5*(r.pageY+E.y);T.set(M,F)}}function lt(r){const E=Se(r),M=r.pageX-E.x,F=r.pageY-E.y,Z=Math.sqrt(M*M+F*F);V.set(0,Z)}function ut(r){e.enableZoom&<(r),e.enablePan&&we(r)}function Rt(r){e.enableZoom&<(r),e.enableRotate&&Be(r)}function dt(r){if(h.length==1)C.set(r.pageX,r.pageY);else{const M=Se(r),F=.5*(r.pageX+M.x),Z=.5*(r.pageY+M.y);C.set(F,Z)}x.subVectors(C,y).multiplyScalar(e.rotateSpeed);const E=e.domElement;z(2*Math.PI*x.x/E.clientHeight),H(2*Math.PI*x.y/E.clientHeight),y.copy(C)}function Oe(r){if(h.length===1)j.set(r.pageX,r.pageY);else{const E=Se(r),M=.5*(r.pageX+E.x),F=.5*(r.pageY+E.y);j.set(M,F)}q.subVectors(j,T).multiplyScalar(e.panSpeed),X(q.x,q.y),T.copy(j)}function Me(r){const E=Se(r),M=r.pageX-E.x,F=r.pageY-E.y,Z=Math.sqrt(M*M+F*F);w.set(0,Z),Y.set(0,Math.pow(w.y/V.y,e.zoomSpeed)),R(Y.y),V.copy(w);const ue=(r.pageX+E.x)*.5,ie=(r.pageY+E.y)*.5;Q(ue,ie)}function ft(r){e.enableZoom&&Me(r),e.enablePan&&Oe(r)}function ht(r){e.enableZoom&&Me(r),e.enableRotate&&dt(r)}function Te(r){e.enabled!==!1&&(h.length===0&&(e.domElement.setPointerCapture(r.pointerId),e.domElement.addEventListener("pointermove",Ke),e.domElement.addEventListener("pointerup",Re)),Pt(r),r.pointerType==="touch"?Je(r):Xe(r))}function Ke(r){e.enabled!==!1&&(r.pointerType==="touch"?gt(r):At(r))}function Re(r){switch(kt(r),h.length){case 0:e.domElement.releasePointerCapture(r.pointerId),e.domElement.removeEventListener("pointermove",Ke),e.domElement.removeEventListener("pointerup",Re),e.dispatchEvent(Qt),s=o.NONE;break;case 1:const E=h[0],M=v[E];Je({pointerId:E,pageX:M.x,pageY:M.y});break}}function Xe(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;ct(r),s=o.DOLLY;break;case c.MOUSE.ROTATE:if(r.ctrlKey||r.metaKey||r.shiftKey){if(e.enablePan===!1)return;We(r),s=o.PAN}else{if(e.enableRotate===!1)return;Ee(r),s=o.ROTATE}break;case c.MOUSE.PAN:if(r.ctrlKey||r.metaKey||r.shiftKey){if(e.enableRotate===!1)return;Ee(r),s=o.ROTATE}else{if(e.enablePan===!1)return;We(r),s=o.PAN}break;default:s=o.NONE}s!==o.NONE&&e.dispatchEvent(Nt)}function At(r){switch(s){case o.ROTATE:if(e.enableRotate===!1)return;Mt(r);break;case o.DOLLY:if(e.enableZoom===!1)return;Tt(r);break;case o.PAN:if(e.enablePan===!1)return;$e(r);break}}function pt(r){e.enabled===!1||e.enableZoom===!1||s!==o.NONE||(r.preventDefault(),e.dispatchEvent(Nt),qe(mt(r)),e.dispatchEvent(Qt))}function mt(r){const E=r.deltaMode,M={clientX:r.clientX,clientY:r.clientY,deltaY:r.deltaY};switch(E){case 1:M.deltaY*=16;break;case 2:M.deltaY*=100;break}return r.ctrlKey&&!O&&(M.deltaY*=10),M}function vt(r){r.key==="Control"&&(O=!0,e.domElement.getRootNode().addEventListener("keyup",Ce,{passive:!0,capture:!0}))}function Ce(r){r.key==="Control"&&(O=!1,e.domElement.getRootNode().removeEventListener("keyup",Ce,{passive:!0,capture:!0}))}function Ze(r){e.enabled===!1||e.enablePan===!1||Ue(r)}function Je(r){switch(bt(r),h.length){case 1:switch(e.touches.ONE){case c.TOUCH.ROTATE:if(e.enableRotate===!1)return;Be(r),s=o.TOUCH_ROTATE;break;case c.TOUCH.PAN:if(e.enablePan===!1)return;we(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;ut(r),s=o.TOUCH_DOLLY_PAN;break;case c.TOUCH.DOLLY_ROTATE:if(e.enableZoom===!1&&e.enableRotate===!1)return;Rt(r),s=o.TOUCH_DOLLY_ROTATE;break;default:s=o.NONE}break;default:s=o.NONE}s!==o.NONE&&e.dispatchEvent(Nt)}function gt(r){switch(bt(r),s){case o.TOUCH_ROTATE:if(e.enableRotate===!1)return;dt(r),e.update();break;case o.TOUCH_PAN:if(e.enablePan===!1)return;Oe(r),e.update();break;case o.TOUCH_DOLLY_PAN:if(e.enableZoom===!1&&e.enablePan===!1)return;ft(r),e.update();break;case o.TOUCH_DOLLY_ROTATE:if(e.enableZoom===!1&&e.enableRotate===!1)return;ht(r),e.update();break;default:s=o.NONE}}function Ve(r){e.enabled!==!1&&r.preventDefault()}function Pt(r){h.push(r.pointerId)}function kt(r){delete v[r.pointerId];for(let E=0;E<h.length;E++)if(h[E]==r.pointerId){h.splice(E,1);return}}function bt(r){let E=v[r.pointerId];E===void 0&&(E=new c.Vector2,v[r.pointerId]=E),E.set(r.pageX,r.pageY)}function Se(r){const E=r.pointerId===h[0]?h[1]:h[0];return v[E]}e.domElement.addEventListener("contextmenu",Ve),e.domElement.addEventListener("pointerdown",Te),e.domElement.addEventListener("pointercancel",Re),e.domElement.addEventListener("wheel",pt,{passive:!1}),e.domElement.getRootNode().addEventListener("keydown",vt,{passive:!0,capture:!0}),this.update()}}const xt=t=>{const[n,a]=P.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))})]})},De=P.forwardRef(function(n,a){const[e,o]=P.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(xt,{index:s,open:e,options:n.options,onSelect:n.onSelect,onToggle:m=>{o(m)},up:!0})]})}),tn=["Single","Side by Side","Stacked","Quad"],ae=new Map,re=new Map,ve=new Map;function Fe(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),ae.set(t,a),a}Fe("Top",new c.Vector3(0,1e3,0));Fe("Bottom",new c.Vector3(0,-1e3,0));Fe("Left",new c.Vector3(-1e3,0,0));Fe("Right",new c.Vector3(1e3,0,0));Fe("Front",new c.Vector3(0,0,1e3));Fe("Back",new c.Vector3(0,0,-1e3));Fe("Orthographic",new c.Vector3(1e3,1e3,1e3));const Ot=new c.PerspectiveCamera(60,1,50,3e3);Ot.name="Debug";Ot.position.set(500,500,500);Ot.lookAt(0,0,0);ae.set("Debug",Ot);const nn=["Renderer","Depth","Normals","UVs","Wireframe"],Ma=new c.MeshDepthMaterial,Ta=new c.MeshNormalMaterial,Ra=new En,Aa=new c.MeshBasicMaterial({opacity:.33,transparent:!0,wireframe:!0});let Et="Renderer";const $=new c.Scene;$.name="Debug Scene";let ge=new c.Scene;$.add(ge);const st=new c.Group;st.name="helpers";$.add(st);const Pa=new yn;st.add(Pa);const wn=new c.AxesHelper(500);wn.name="axisHelper";st.add(wn);const rt=new c.AxesHelper(100);rt.name="interactionHelper";st.add(rt);rt.visible=!1;let Ct=!1,W=ae.get("Debug"),oe=ae.get("Orthographic"),Ie=ae.get("Front"),Ne=ae.get("Top"),an=!1;function ka(t){const[n,a]=P.useState(t.mode!==void 0?t.mode:"Single"),[e,o]=P.useState(null),[s,m]=P.useState(!1),[l,d]=P.useState(!1),[f,g]=P.useState(!1),[,y]=P.useState(Date.now()),C=P.useRef(null),x=P.useRef(null),T=P.useRef(null),j=P.useRef(null),q=P.useRef(null),V=P.useRef(null),w=(h,v)=>{const O=re.get(h.name);O!==void 0&&O.dispose(),re.delete(h.name);const k=ve.get(h.name);k!==void 0&&($.remove(k),k.dispose()),ve.delete(h.name);const G=new Oa(h,v);switch(G.enableDamping=!0,G.dampingFactor=.05,h.name){case"Top":case"Bottom":case"Left":case"Right":case"Front":case"Back":G.enableRotate=!1;break}if(re.set(h.name,G),h instanceof c.PerspectiveCamera){const z=new c.CameraHelper(h);ve.set(h.name,z),$.add(z)}},Y=h=>{const v=ve.get(h.name);v!==void 0&&($.remove(v),v.dispose(),ve.delete(h.name));const O=re.get(h.name);O!==void 0&&(O.dispose(),re.delete(h.name))},ye=()=>{re.forEach((h,v)=>{h.dispose();const O=ve.get(v);O!==void 0&&($.remove(O),O.dispose()),ve.delete(v),re.delete(v)}),re.clear(),ve.clear()},le=()=>{switch(n){case"Single":w(W,T.current);break;case"Side by Side":case"Stacked":w(W,T.current),w(oe,j.current);break;case"Quad":w(W,T.current),w(oe,j.current),w(Ie,q.current),w(Ne,V.current);break}};P.useEffect(()=>{const h=new c.WebGLRenderer({canvas:C.current,stencil:!1});h.autoClear=!1,h.shadowMap.enabled=!0,h.setPixelRatio(devicePixelRatio),h.setClearColor(0),o(h)},[]),P.useEffect(()=>{const h=k=>{Bt(ge),$.remove(ge);const G=t.scenes.get(k.value.name);if(G!==void 0){const z=new G;t.onSceneSet!==void 0&&t.onSceneSet(z),ge=z,t.three.scene=ge,$.add(ge),an=!0}},v=k=>{const G=k.value,z=t.three.scene?.getObjectByProperty("uuid",G.uuid);z!==void 0&&ae.set(G.name,z),y(Date.now())},O=k=>{ae.delete(k.value.name),y(Date.now())};return D.addEventListener(I.SET_SCENE,h),D.addEventListener(I.ADD_CAMERA,v),D.addEventListener(I.REMOVE_CAMERA,O),()=>{D.removeEventListener(I.SET_SCENE,h),D.removeEventListener(I.ADD_CAMERA,v),D.removeEventListener(I.REMOVE_CAMERA,O)}},[]),P.useEffect(()=>{if(e===null)return;let h=window.innerWidth,v=window.innerHeight,O=Math.floor(h/2),k=Math.floor(v/2),G=-1;const z=()=>{h=window.innerWidth-300,v=window.innerHeight,O=Math.floor(h/2),k=Math.floor(v/2),e.setSize(h,v);let R=h,U=v;switch(n){case"Side by Side":R=O,U=v;break;case"Stacked":R=h,U=k;break;case"Quad":R=O,U=k;break}ae.forEach(Q=>{Q instanceof c.OrthographicCamera?(Q.left=R/-2,Q.right=R/2,Q.top=U/2,Q.bottom=U/-2,Q.updateProjectionMatrix()):Q instanceof c.PerspectiveCamera&&(Q.aspect=R/U,Q.updateProjectionMatrix(),ve.get(Q.name)?.update())})},H=()=>{e.setViewport(0,0,h,v),e.setScissor(0,0,h,v),e.render($,W)},L=()=>{if(n==="Side by Side")e.setViewport(0,0,O,v),e.setScissor(0,0,O,v),e.render($,W),e.setViewport(O,0,O,v),e.setScissor(O,0,O,v),e.render($,oe);else{const R=v-k;e.setViewport(0,R,h,k),e.setScissor(0,R,h,k),e.render($,W),e.setViewport(0,0,h,k),e.setScissor(0,0,h,k),e.render($,oe)}},K=()=>{let R=0,U=0;U=v-k,R=0,e.setViewport(R,U,O,k),e.setScissor(R,U,O,k),e.render($,W),R=O,e.setViewport(R,U,O,k),e.setScissor(R,U,O,k),e.render($,oe),U=0,R=0,e.setViewport(R,U,O,k),e.setScissor(R,U,O,k),e.render($,Ie),R=O,e.setViewport(R,U,O,k),e.setScissor(R,U,O,k),e.render($,Ne)},X=()=>{switch(re.forEach(R=>{R.update()}),t.onSceneUpdate!==void 0&&an&&t.onSceneUpdate(ge),e.clear(),n){case"Single":H();break;case"Side by Side":case"Stacked":L();break;case"Quad":K();break}G=requestAnimationFrame(X)};return le(),window.addEventListener("resize",z),z(),X(),()=>{window.removeEventListener("resize",z),cancelAnimationFrame(G),G=-1}},[n,e]),P.useEffect(()=>{if(e!==null){const h=new c.Raycaster,v=new c.Vector2,O=(H,L,K,X)=>{switch(n){case"Quad":H<K?L<X?h.setFromCamera(v,W):h.setFromCamera(v,Ie):L<X?h.setFromCamera(v,oe):h.setFromCamera(v,Ne);break;case"Side by Side":H<K?h.setFromCamera(v,W):h.setFromCamera(v,oe);break;case"Single":h.setFromCamera(v,W);break;case"Stacked":L<X?h.setFromCamera(v,W):h.setFromCamera(v,oe);break}},k=H=>{if(!Ct)return;const L=new c.Vector2;e.getSize(L);const K=Math.min(H.clientX,L.x),X=Math.min(H.clientY,L.y);v.x=Ye(K,0,L.x,-1,1),v.y=Ye(X,0,L.y,1,-1);const R=L.x/2,U=L.y/2,Q=()=>{K<R?v.x=Ye(K,0,R,-1,1):v.x=Ye(K,R,L.x,-1,1)},pe=()=>{X<U?v.y=Ye(X,0,U,1,-1):v.y=Ye(X,U,L.y,1,-1)};switch(n){case"Quad":Q(),pe();break;case"Side by Side":Q();break;case"Stacked":pe(),pe();break}O(K,X,R,U);const Ee=h.intersectObjects(ge.children);Ee.length>0&&rt.position.copy(Ee[0].point)},G=H=>{if(!Ct)return;const L=new c.Vector2;if(e.getSize(L),H.clientX>=L.x)return;k(H);const K=h.intersectObjects(ge.children);K.length>0&&t.three.getObject(K[0].object.uuid)},z=x.current;return z.addEventListener("mousemove",k,!1),z.addEventListener("click",G,!1),()=>{z.removeEventListener("mousemove",k),z.removeEventListener("click",G)}}},[n,e]);const se=[];return ae.forEach((h,v)=>{se.push(v)}),u.jsxs("div",{className:"multiview",children:[u.jsx("canvas",{ref:C}),u.jsxs("div",{className:`cameras ${n==="Single"||n==="Stacked"?"single":""}`,ref:x,children:[n==="Single"&&u.jsx(u.Fragment,{children:u.jsx(De,{camera:W,options:se,ref:T,onSelect:h=>{re.get(W.name)?.dispose();const v=ae.get(h);v!==void 0&&(Y(W),W=v,w(v,T.current))}})}),(n==="Side by Side"||n==="Stacked")&&u.jsxs(u.Fragment,{children:[u.jsx(De,{camera:W,options:se,ref:T,onSelect:h=>{re.get(W.name)?.dispose();const v=ae.get(h);v!==void 0&&(Y(W),W=v,w(v,T.current))}}),u.jsx(De,{camera:oe,options:se,ref:j,onSelect:h=>{re.get(oe.name)?.dispose();const v=ae.get(h);v!==void 0&&(Y(oe),oe=v,w(v,j.current))}})]}),n==="Quad"&&u.jsxs(u.Fragment,{children:[u.jsx(De,{camera:W,options:se,ref:T,onSelect:h=>{re.get(W.name)?.dispose();const v=ae.get(h);v!==void 0&&(Y(W),W=v,w(v,T.current))}}),u.jsx(De,{camera:oe,options:se,ref:j,onSelect:h=>{re.get(oe.name)?.dispose();const v=ae.get(h);v!==void 0&&(Y(oe),oe=v,w(v,j.current))}}),u.jsx(De,{camera:Ie,options:se,ref:q,onSelect:h=>{re.get(Ie.name)?.dispose();const v=ae.get(h);v!==void 0&&(Y(Ie),Ie=v,w(v,q.current))}}),u.jsx(De,{camera:Ne,options:se,ref:V,onSelect:h=>{re.get(Ne.name)?.dispose();const v=ae.get(h);v!==void 0&&(Y(Ne),Ne=v,w(v,V.current))}})]})]}),u.jsxs("div",{className:"settings",children:[u.jsx(xt,{index:tn.indexOf(n),options:tn,onSelect:h=>{h!==n&&(ye(),a(h))},open:s,onToggle:h=>{m(h),l&&d(!1),f&&g(!1)}}),u.jsx(xt,{index:nn.indexOf(Et),options:nn,onSelect:h=>{if(h!==Et)switch(Et=h,Et){case"Depth":$.overrideMaterial=Ma;break;case"Normals":$.overrideMaterial=Ta;break;default:case"Renderer":$.overrideMaterial=null;break;case"Wireframe":$.overrideMaterial=Aa;break;case"UVs":$.overrideMaterial=Ra;break}},open:l,onToggle:h=>{s&&m(!1),d(h),f&&g(!1)}}),u.jsx(xt,{index:0,options:["Orbit Mode","Selection Mode"],onSelect:h=>{Ct=h==="Selection Mode",rt.visible=Ct},open:f,onToggle:h=>{s&&m(!1),l&&d(!1),g(h)}})]})]})}function _a(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})]})}exports.Accordion=wt;exports.Application=Nn;exports.BaseRemote=ot;exports.ChildObject=Ht;exports.ContainerObject=Cn;exports.Draggable=vn;exports.DraggableItem=mn;exports.Dropdown=gn;exports.DropdownItem=bn;exports.Editor=_a;exports.InfiniteGridHelper=yn;exports.Inspector=xn;exports.MultiView=ka;exports.NavButton=zt;exports.RemoteComponents=dn;exports.RemoteController=Jn;exports.RemoteTheatre=be;exports.RemoteThree=pn;exports.RemoteTweakpane=Vt;exports.SceneInspector=xa;exports.SidePanel=Sa;exports.ToolEvents=I;exports.UVMaterial=En;exports.capitalize=Ge;exports.clamp=jn;exports.colorToHex=cn;exports.debugDispatcher=D;exports.dispose=Bt;exports.disposeMaterial=un;exports.disposeTexture=In;exports.distance=Dn;exports.hierarchyUUID=Ut;exports.isColor=sn;exports.randomID=on;exports.resetThreeObjects=ln;exports.round=St;
|