gl-draw 0.15.0-beta.1 → 0.15.0-beta.3

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.
@@ -77,6 +77,7 @@ export default class {
77
77
  setPixelRatio(ratio: number): void;
78
78
  private darkenNonBloomed;
79
79
  private restoreNonBloomed;
80
+ bloomComposerRenderIng: boolean;
80
81
  finalComposerRender(): void;
81
82
  getSize(): Vector2;
82
83
  pipViewportState: null | {
@@ -7,7 +7,7 @@ export default class MaterialList {
7
7
  private materialBaseObjectMap;
8
8
  private fixBufferGeometry;
9
9
  constructor(pencil: Pencil);
10
- add(key: string, material: Material, baseObject?: IBaseObject): void;
10
+ add(key: string, material: Material): void;
11
11
  get(key: string): Material | undefined;
12
12
  getKey(material: Material): string | undefined;
13
13
  addMultiple(key: string, materialMap: Record<string, Material | null>): void;
@@ -17,9 +17,9 @@ export default class MaterialList {
17
17
  remove(key: string): void;
18
18
  removeByMaterial(material: Material): void;
19
19
  proxyBaseObject(object: IBaseObject): void;
20
- addByBaseObject(object: IBaseObject): void;
20
+ addBaseObjectMap(object: IBaseObject): void;
21
21
  rmBaseObjectMap(object: IBaseObject, targetMaterial?: Material): void;
22
- getBaseObjectByMaterial(material: Material): IBaseObject[] | null;
22
+ getBaseObjectMaterials(): Record<string, Material>;
23
23
  emitObject3dChange(): void;
24
24
  dispose(): void;
25
25
  }
package/dist/index.js CHANGED
@@ -95,4 +95,4 @@
95
95
  gl_FragColor = ( base_color + vec4( 1.0 ) * bloom_color );
96
96
  }
97
97
  }
98
- `,defines:{}}),"baseTexture");return e.needsSwap=!0,e},we=1,pe=!1,ls=new v.MeshBasicMaterial({color:"black"}),hs=new v.PointsMaterial({color:"black",sizeAttenuation:!1}),cs=new v.PointsMaterial({color:"black",sizeAttenuation:!0}),ds=new v.SpriteMaterial({color:"black",sizeAttenuation:!0}),ps=new v.SpriteMaterial({color:"black",sizeAttenuation:!1}),ms=new I.MeshLineMaterial({color:"black",sizeAttenuation:0,lineWidth:0}),us={kernelRadius:8,minDistance:.005,maxDistance:.1},fs={threshold:0,strength:.4,radius:.1,bloomAlphaType:0},_s={multisampling:4,premultiplieAlpha:!1};class gs{constructor(e){this.bloomComposerActive=!1,this.active=!0,this.bloomSelection=new Set,this.bloomLayer=new v.Layers,this.bloomMaterials={},this.bloomVisible={},this.pipViewportState=null,this.options=e;const{rendererController:t,sceneController:s,cameraController:i,composerParams:r}=e,{renderer:o}=t;this.renderer=o;const{multisampling:n}=r,{maxSamples:l}=o.capabilities,d=o.getDrawingBufferSize(new v.Vector2),_=new v.WebGLRenderTarget(d.width,d.height,{samples:Math.min(n,l),type:v.HalfFloatType}),p=new Re.EffectComposer(o,_),E=this.getSize();p.setSize(E.width,E.height);const y=new wt.RenderPass(s.scene,i.camera);p.addPass(y),this.scene=s.scene,this.camera=i.camera,this.finalComposer=p,this.renderPass=y,i.event.on("pageChange",m=>{this.changeCamera(m)}),s.event.on("pageChange",m=>{this.changeScene(m)})}changeCamera(e){this.renderPass.camera=e,this.camera=e}changeScene(e){this.renderPass.scene=e,this.ssaoPass&&(this.ssaoPass.scene=e),this.scene=e}addOutputPass(){const{premultiplieAlpha:e}=this.options.composerParams,t=new ns;this.outputPass=t,this.setPremultiplieAlpha(e),this.finalComposer.addPass(t)}setPremultiplieAlpha(e){this.outputPass&&(this.outputPass.uniforms.premultiplieAlpha.value=e?1:0)}addSSAOPass(e){const{scene:t,camera:s,renderer:i}=this,r=i.getSize(new v.Vector2),o=r.width,n=r.height,l=new Lt.SSAOPass(t,s,o,n);l.kernelRadius=e.kernelRadius,l.minDistance=e.minDistance,l.maxDistance=e.maxDistance,this.ssaoPass=l,this.finalComposer.addPass(l)}addBloomPass(e){const{renderer:t}=this,{threshold:s,strength:i,radius:r,bloomAlphaType:o}=e,n=new At.UnrealBloomPass(new v.Vector2(window.innerWidth,window.innerHeight),i,r,s);this.bloomPass=n;const l=new Re.EffectComposer(t);l.renderToScreen=!1,l.addPass(this.renderPass),l.addPass(n),this.bloomComposer=l;const d=as(l);d.uniforms.bloomAlphaType.value=o,this.bloomComposer=l,this.finalComposer.addPass(d),this.mixPass=d,this.bloomLayer.set(we)}setBloomSelection(e,t){if(!this.bloomComposer){console.warn("err:pencil.options.bloom");return}e.traverse(s=>{const{object3d:i}=s;i&&(t?(this.bloomSelection.add(s),i.layers.enable(we)):(this.bloomSelection.delete(s),i.layers.disable(we)))}),this.bloomSelection.size===0?this.bloomComposerActive=!1:this.bloomComposerActive=!0}enable(){this.active||(this.active=!0)}disable(){this.active&&(this.active=!1)}setSize(e,t){var s;(s=this.bloomComposer)==null||s.setSize(e,t),this.finalComposer.setSize(e,t)}setPixelRatio(e){var t;(t=this.bloomComposer)==null||t.setPixelRatio(e),this.finalComposer.setPixelRatio(e)}darkenNonBloomed(){const e=[],t=[];this.scene.children.forEach(s=>{s.isTransformControls||s.isTransformControlsRoot||s.type==="RectAreaLightHelper"?e.push(s):t.push(s)}),t.forEach(s=>{s.traverse(i=>{var l;const r=i,o=i,n=i;(l=r.material)!=null&&l.isShadowMaterial?e.push(r):r.material&&this.bloomLayer.test(r.layers)===!1&&(this.bloomMaterials[r.uuid]=r.material,o.isSprite?o.material.sizeAttenuation?o.material=ds:o.material=ps:r.material instanceof I.MeshLineMaterial?r.material=ms:n.isPoints?n.material.sizeAttenuation?n.material=cs:n.material=hs:r.material=ls)})}),e.forEach(s=>{this.bloomVisible[s.uuid]=s.visible,s.visible=!1})}restoreNonBloomed(){this.scene.traverse(e=>{const t=e;this.bloomMaterials[t.uuid]?(t.material=this.bloomMaterials[t.uuid],delete this.bloomMaterials[t.uuid]):this.bloomVisible[t.uuid]!==void 0&&(t.visible=this.bloomVisible[t.uuid],delete this.bloomVisible[t.uuid])})}finalComposerRender(){this.bloomComposerActive&&this.bloomComposer?(this.mixPass.enabled=!0,this.darkenNonBloomed(),this.bloomComposer.render(),this.restoreNonBloomed()):this.mixPass&&(this.mixPass.enabled=!1),this.finalComposer.render()}getSize(){return this.renderer.getSize(new v.Vector2)}render(){if(!this.active)return;const{cameraController:e,rendererController:t,sceneController:s}=this.options;if(this.finalComposerRender(),this.pipViewportState){e.setPageActive(31),e.setAspect(this.pipViewportState.width/this.pipViewportState.height),t.setViewport(ee(z({},this.pipViewportState),{scissor:!0,scissorTest:!0})),this.finalComposerRender(),e.setPageActive(s.activeIndex);const i=this.getSize();t.setViewport({x:0,y:0,width:i.width,height:i.height,scissor:!0,scissorTest:!1})}}dispose(){var e;this.bloomMaterials={},this.bloomVisible={},this.bloomSelection.clear(),this.finalComposer.dispose(),(e=this.bloomComposer)==null||e.dispose()}}class Qe extends v.Loader{constructor(e){super(e),this.options={type:"image"}}setOptions(e){return this.options=e,this}load(e,t,s,i){let r,o;this.options.type==="image"?(o=document.createElement("img"),r=new v.Texture(o)):this.options.type==="video"?(o=document.createElement("video"),o.preload="auto",o.autoplay=!1,o.loop=!1,o.muted=!0,o.setAttribute("webkit-playsinline","webkit-playsinline"),o.setAttribute("playsinline",""),r=new v.VideoTexture(o)):r=new v.Texture;const n=new v.FileLoader(this.manager);return n.setResponseType("blob"),n.setRequestHeader(this.requestHeader),n.setPath(this.path),n.setWithCredentials(this.withCredentials),n.load(e,l=>{let d=l;const _=e.split(".").pop(),p=this.options.type==="image"?`image/${_||"png"}`:`video/${_||"mp4"}`;d=d.slice(0,l.size,p);const E=()=>{o.removeEventListener("load",y,!1),o.removeEventListener("error",m,!1)},y=()=>{E(),r.needsUpdate=!0,t&&t(r)},m=f=>{E(),i&&i(f),this.manager.itemError(e),this.manager.itemEnd(e)};o.addEventListener("load",y,!1),o.addEventListener("error",m,!1);const u=window.URL.createObjectURL(d);o.src=u},s,i),r}}class ys extends v.Loader{constructor(e){super(e)}load(e,t,s,i){const r=new v.FileLoader(this.manager);r.setResponseType("blob"),r.setRequestHeader(this.requestHeader),r.setPath(this.path),r.setWithCredentials(this.withCredentials),r.load(e,o=>{const n=o,l=new DecompressionStream("gzip"),d=n.stream().pipeThrough(l);new Response(d).json().then(p=>{t==null||t(p)}).catch(p=>{i==null||i(p)})},s,i)}}const vs={images:["png","jpg","jpeg","ico","webp","avif"],media:["mp4","webm","ogg"],gltf:["gltf","glb"],json:["json","geojson"],gzipJson:["json.gzip"],exr:["exr"],lottie:["lottie.json"]};class Cs{constructor(e){this.loadObj=[],this.delLoadArr=[],this.assets=new Map,this.event=new ge.EventEmitter,this.options=z({simpleTexture4deleted:!1,prefix:""},e),this.loadingManager=new v.LoadingManager(()=>{},(t,s,i)=>{this.emit("progress",s,i)},t=>{console.warn(`Failed to load ${t}`)})}emit(e,...t){this.event.emit(e,...t)}on(e,t){this.event.on(e,t)}getAsset(e){const t=this.getAssetType(e);if(!t)return;const s=this.assets.get(e);if(!s){if((t==="images"||t==="media"||t==="exr")&&this.options.simpleTexture4deleted&&this.delLoadArr.includes(e))return new v.Texture;console.warn(`Asset ${e} not found`)}return s}getAssetType(e){var s;const t=(s=e.split(".").pop())==null?void 0:s.toLowerCase();if(t){if(e.endsWith("lottie.json"))return"lottie";if(e.endsWith("json.gzip"))return"gzipJson"}else return;for(const[i,r]of Object.entries(vs))if(r.includes(t))return i}getLoader(e,t){if(e==="images")return this.textureLoader||(this.textureLoader=new Qe(this.loadingManager),this.options.prefix&&this.textureLoader.setPath(this.options.prefix)),this.textureLoader;if(e==="media")return this.videoTextureLoader||(this.videoTextureLoader=new Qe(this.loadingManager),this.videoTextureLoader.setOptions({type:"video"}),this.options.prefix&&this.videoTextureLoader.setPath(this.options.prefix)),this.videoTextureLoader;if(e==="gltf"&&(t!=null&&t.dracoPath))return this.dracoGltfLoader||(this.dracoGltfLoader=new Ue.GLTFLoader(this.loadingManager),this.dracoLoader=new Mt.DRACOLoader,this.dracoLoader.setDecoderPath(t==null?void 0:t.dracoPath),this.dracoGltfLoader.setDRACOLoader(this.dracoLoader),this.options.prefix&&this.dracoGltfLoader.setPath(this.options.prefix)),this.dracoGltfLoader;if(e==="gltf")return this.gltfLoader||(this.gltfLoader=new Ue.GLTFLoader(this.loadingManager),this.options.prefix&&this.gltfLoader.setPath(this.options.prefix)),this.gltfLoader;if(e==="lottie")return this.lottieLoader||(this.lottieLoader=new Dt.LottieLoader(this.loadingManager),this.options.prefix&&this.lottieLoader.setPath(this.options.prefix)),this.lottieLoader;if(e==="gzipJson")return this.gzipJsonLoader||(this.gzipJsonLoader=new ys(this.loadingManager),this.options.prefix&&this.gzipJsonLoader.setPath(this.options.prefix)),this.gzipJsonLoader;if(e==="json")return this.jsonLoader||(this.jsonLoader=new v.FileLoader(this.loadingManager),this.jsonLoader.setResponseType("json"),this.options.prefix&&this.jsonLoader.setPath(this.options.prefix)),this.jsonLoader;if(e==="exr")return this.exrLoader||(this.exrLoader=new Rt.EXRLoader(this.loadingManager),this.options.prefix&&this.exrLoader.setPath(this.options.prefix)),this.exrLoader}add(e,t){typeof e=="string"&&(e=[e]),e.forEach(s=>{const i=z({src:s},t);this.loadObj.push(i)})}getSrcByAsset(e,t=this.assets){let s;return t.forEach((i,r)=>{i===e&&(s=r)}),s}get textureAssets(){const e=new Map;return this.assets.forEach((t,s)=>{(t instanceof v.Texture||t instanceof v.DataTexture||t instanceof v.VideoTexture)&&e.set(s,t)}),e}loadAll(){return te(this,null,function*(){const e=this.loadObj.filter(t=>!this.delLoadArr.includes(t.src));return yield Promise.all(e.map(t=>this.load(t.src,t)))})}load(e,t){return te(this,null,function*(){var n,l;const s=(n=t==null?void 0:t.type)!=null?n:this.getAssetType(e);if(!s)return;const i=(t==null?void 0:t.cache)!==!1,r=Le.makePromiseCreator();if(i){if(this.assets.has(e))return this.assets.get(e);this.assets.set(e,r.promise)}const o=this.getLoader(s,t);try{const d=yield o.loadAsync(e);if(this.assets.set(e,d),r.resolve(d),s==="images"||s==="media"||s==="exr"||s==="lottie"){(t==null?void 0:t.colorCorrection)!==!1&&Pe.colorCorrection({texture:d});const _=(l=t==null?void 0:t.anisotropy)!=null?l:this.options.anisotropy;d.anisotropy=_}return d}catch(d){r.reject(`Failed to load ${e}`);return}})}getUnusedAssets(){const{scene:e}=this.options;if(!e)return[...this.delLoadArr];const t=new Set,s=this.textureAssets;e.traverse(r=>{const o=r;o.material&&(Array.isArray(o.material)?o.material:[o.material]).forEach(l=>{[l.map,l.emissiveMap,l.normalMap,l.roughnessMap,l.metalnessMap,l.aoMap].forEach(d=>{if(d){const _=this.getSrcByAsset(d,s);_&&t.add(_)}})})});const i=new Set(this.textureAssets.keys());return t.forEach(r=>{i.delete(r)}),[...i,...this.delLoadArr]}dispose(){var e;this.assets.clear(),(e=this.dracoLoader)==null||e.dispose(),this.event.removeAllListeners(),this.delLoadArr.length=0,this.loadObj.length=0}}const Os={prefix:""};class Es extends J{get loader(){return this.controller}constructor(e){super(),this.options=e}addLoader(e,t){const{loaderParams:s}=this.options,i=new Cs(ee(z({},s),{scene:e}));return this.addController(i,t)}removePage(e){super.removePage(e,t=>{t.dispose()})}}class Ts extends I.BaseObject{constructor(e){super(),this.options=z({},e)}create(){var e;this.object3d=(e=this.options.scene)!=null?e:new v.Scene}}function Je(h){let e=!1,t=[];return function(...s){t=s,e||(e=!0,requestAnimationFrame(()=>{e=!1,h(...t)}))}}class bs{constructor(e){var t;this.enabled=!0,this.pickFunctionsMap=new Map,this.pickNodeFunctionsMap=new Map,this.pickFunctionsMapIndex=-1,this.pickNodeFunctionsMapIndex=-1,this.activeObjects=new Set,this.prevActiveObjects=new Set,this.objCallbackMap=new Map,this.pickListener={move:!1,down:!1},this.pencil=e,this.domElement=((t=e.options.controls)==null?void 0:t.domElement)||e.options.container}addPickListener(e){const t=new Set(["move","enter","leave"]),s=new Set(["down","downOutside","click"]),i=r=>{var y;if(!this.enabled)return;r.preventDefault();const o=e==="move"?t:s,n=[];if(this.pickFunctionsMap.forEach(m=>{o.has(m.type)&&n.push(ee(z({},m),{objArr:m.objArr instanceof Function?m.objArr():m.objArr}))}),n.length===0)return;this.activeObjects.clear(),this.objCallbackMap.clear();const l=this.objCallbackMap,d=[];for(const m of n)for(const u of m.objArr){if(!u.object3d||!u.visibleWithAncestors)continue;l.has(u)||(l.set(u,new Map),d.push(u));const f=l.get(u);f.has(m.type)||f.set(m.type,[]),f.get(m.type).push(m.cb)}if(d.length===0)return;const _=d.map(m=>m.object3d);_.forEach(m=>{m.isGroup&&m.traverse(u=>{u instanceof v.Mesh&&_.push(u)})});const p=(y=this.pencil.pick(r,_,!1))==null?void 0:y.intersects;if(!p||p.length===0)e==="down"?this.handleDownOutside(r):e==="move"&&this.handleLeaveEvents(r);else{this.sortIntersections(p);const m=p[0];this.processIntersection(m,r,e)}const E=this.prevActiveObjects;this.prevActiveObjects=this.activeObjects,this.activeObjects=E,this.activeObjects.clear()};this.domElement.addEventListener(`pointer${e}`,Je(i),{passive:!1})}sortIntersections(e){e.sort((t,s)=>t.distance===s.distance?t.object.getObjectById(s.object.id)?1:s.object.getObjectById(t.object.id)?-1:0:t.distance-s.distance)}processIntersection(e,t,s){const i=this.objCallbackMap,r=e.index||-1;let o=e.object;for(;o;){const n=this.pencil.lead.objMap.get(o);n&&i.has(n)&&this.activeObjects.add(n),o=o.parent}s==="move"?this.handleLeaveEvents(t):s==="down"&&this.handleDownOutside(t),this.processObjectHierarchy(t,s,r)}processObjectHierarchy(e,t,s){const i=this.objCallbackMap;let r=!1;const o=()=>{r=!0};for(const n of this.activeObjects){if(r)break;const l=i.get(n);if(l)if(t==="move"){const d=l.get("enter");if(d&&!this.prevActiveObjects.has(n))for(const p of d)p({baseObject:n,mouseEvent:e,sp:o,intersectionIndex:s});const _=l.get("move");if(_)for(const p of _)p({baseObject:n,mouseEvent:e,sp:o,intersectionIndex:s})}else{const d=l.get("down");if(d)for(const p of d)p({baseObject:n,mouseEvent:e,sp:o,intersectionIndex:s});const _=l.get("click");if(_){const p=E=>{E.preventDefault();const y=5;if(!r&&Math.abs(E.clientX-e.clientX)<=y&&Math.abs(E.clientY-e.clientY)<=y)for(const m of _)m({baseObject:n,mouseEvent:e,sp:o,intersectionIndex:s});this.domElement.removeEventListener("pointerup",p)};this.domElement.addEventListener("pointerup",p)}}}}handleLeaveEvents(e){this.objCallbackMap.forEach((s,i)=>{const r=s.get("leave");if(r&&this.prevActiveObjects.has(i)&&!this.activeObjects.has(i))for(const o of r)o({baseObject:i,mouseEvent:e})})}handleDownOutside(e){this.objCallbackMap.forEach((s,i)=>{const r=s.get("downOutside");if(r&&!this.activeObjects.has(i))for(const o of r)o({baseObject:i,mouseEvent:e})})}handlePick(e,t,s){let i=t;i==="mousemove"?i="move":i==="mouseenter"?i="enter":i==="mouseleave"&&(i="leave"),this.pickFunctionsMapIndex+=1;const r=this.pickFunctionsMapIndex;return this.pickFunctionsMap.set(r,{objArr:e,type:i,cb:s}),this.pickListener.move||Array.from(this.pickFunctionsMap.values()).some(n=>["move","enter","leave"].includes(n.type))&&(this.pickListener.move=!0,this.addPickListener("move")),this.pickListener.down||Array.from(this.pickFunctionsMap.values()).some(n=>["down","downOutside","click"].includes(n.type))&&(this.pickListener.down=!0,this.addPickListener("down")),r}removePick(e){this.pickFunctionsMap.delete(e)}handlePickNode(e,t,s){if(t==="downOutside")return console.warn("handlePickNode:err:不支持 downOutside"),-1;this.pickNodeFunctionsMapIndex+=1;const i=this.pickNodeFunctionsMapIndex,r=e instanceof Function?e():e,o=[];for(const n of r){const l=n;l.element.style.pointerEvents="auto";const d=p=>{this.enabled&&(p.preventDefault(),s({baseObject:l,mouseEvent:p}))},_=`pointer${t}`;l.element.addEventListener(_,Je(d),!1),o.push({arr:l,type:_,listener:d})}return this.pickNodeFunctionsMap.set(i,o),i}removePickNode(e){const t=this.pickNodeFunctionsMap.get(e);if(t){for(const s of t)s.arr.element.style.pointerEvents="none",s.arr.element.removeEventListener(s.type,s.listener,!1);this.pickNodeFunctionsMap.delete(e)}}dispose(){this.pickFunctionsMap.clear(),this.pickNodeFunctionsMap.clear(),this.activeObjects.clear(),this.prevActiveObjects.clear(),this.objCallbackMap.clear()}}class xs extends bs{constructor(e,t){super(e),this.objMap=new Map,this.objects=new Map,this.objectsPm=new Map,this.objectNamesToFactories=new Map,this.scene=new Ts({scene:t.scene}),this.mList=t.mList,this.scene.create(),this.scene.lead=this,this.scene.pencil=e,this.scene.mList=this.mList,this.scene.key="Scene",this.scene.object3d.name="场景",this.group=new I.Group,this.group.create(),this.group.lead=this,this.group.pencil=e,this.group.mList=this.mList,this.group.key="@Group",this.group.object3d.name="物体组",this.prefabGroup=new I.Group,this.prefabGroup.create(),this.prefabGroup.lead=this,this.prefabGroup.pencil=e,this.prefabGroup.mList=this.mList,this.prefabGroup.key="@PrefabGroup",this.prefabGroup.object3d.name="预制组",this.scene.add(this.group.object3d,this.prefabGroup.object3d),this.objects.set("@Scene",this.scene),this.objects.set("@Group",this.group),this.objects.set("@PrefabGroup",this.prefabGroup),this.objMap.set(this.scene.object3d,this.scene),this.objMap.set(this.group.object3d,this.group),this.objMap.set(this.prefabGroup.object3d,this.prefabGroup)}get objectsPromise(){return this.objectsPm.values()}init(e){return Object.keys(e).forEach(t=>{const s=class{create(r={}){return new e[t](r)}};this.objectNamesToFactories.set(t,s)}),this}getObject(e,t){e.includes("#")&&console.warn("getObject:err:不支持 #",e);const{key:s}=t||{},i=`${e}${s?`#${s}`:""}`;return this.objects.get(i)}getAllObject(e,t){e.includes("#")&&console.warn("getAllObject:err:不支持 #",e);const{key:s}=t||{},i=`${e}${s?`#${s}`:""}`,r=[];return this.objects.forEach((o,n)=>{(n.startsWith(s?i:`${i}#`)||n===i)&&r.push(o)}),r}draw(e,t,s){return te(this,null,function*(){var r,o,n,l;const i=this.objectNamesToFactories.get(e);if(i){t||(t={}),t.target===void 0&&(t.target=s);const d=t.target,_=(r=t.onTop)!=null?r:0,p=(o=t.prefab)!=null?o:!1,E=(n=t.create)!=null?n:!0,y=new i().create(t);let m;return d===null?m=null:typeof d=="string"?m=this.objects.get(d):(l=d==null?void 0:d.objectType)!=null&&l.startsWith("BaseObject")||d?m=d:p?m=this.prefabGroup:m=this.group,E===!1?y.create=()=>{}:E!==!0&&(y.create=()=>{E(y)}),y.pencil=this.pencil,y.lead=this,y.mList=this.mList,y.prefab=p,y.objectType=`BaseObject#${e}`,y.objectOptions=t,this.setBaseObjectKey(y,t.key?`$t:#${t.key}`:"$t:",m==null?void 0:m.key),this.objectsPm.set(y.key,this.addBaseObject(y,m,_)),yield this.objectsPm.get(y.key),this.objectsPm.delete(y.key),y}throw new Error(`Unrecognized:${e}`)})}setBaseObjectKey(e,t,s){const i=e.objectType,[,r]=i.split("#");let o=t.replace("$t:",r);if(s){const[,n]=s.split("#");o=o.replace("$p:",n)}return this.objects.has(o)&&(o.includes("#")?o+=`-${Le.generateUUID()}`:o+=`#${Le.generateUUID()}`),e.key=o,this.objects.set(o,e),o}updateBaseObjectKey(e,t){var o;let s;for(const[n,l]of this.objects.entries())if(l===e){s=n;break}const i=(o=e.parent)==null?void 0:o.key;if(!s)return this.setBaseObjectKey(e,t,i);this.objects.delete(s);const r=this.setBaseObjectKey(e,t,i);return this.pencil.event.emit("updateKey",e,r,s),r}addBaseObject(e,t,s){return te(this,null,function*(){yield e.create(),e.object3d&&(this.mList.proxyBaseObject(e),this.mList.addByBaseObject(e),s&&e.setTop(s),t!==null&&(t.add(e.object3d),this.objMap.set(e.object3d,e))),e.render(),this.pencil.event.emit("draw",e)})}erase(...e){[...e].forEach(t=>{const s=[];if(typeof t=="string"){const[i,r]=t.split("#");s.push(...this.getAllObject(i,{key:r}))}else s.push(t);s.forEach(i=>{i.dispose()})}),this.pencil.event.emit("erase",...e)}update(e,t){this.objects.forEach(s=>{s.update(e,t)})}setSize(e,t){this.objects.forEach(s=>{s.resize(e,t)})}eraseAll(){this.group&&(this.objects.forEach(e=>{e.key.startsWith("Node")&&this.erase(e)}),this.erase(this.group))}dispose(){super.dispose(),this.scene.erase(),this.objects.forEach(e=>{e.erase()}),this.objects.clear(),this.objectsPm.clear(),this.objMap.clear(),this.objectNamesToFactories.clear()}}class ws extends J{get lead(){return this.controller}constructor(e){super(),this.options=e}addLead(e,t,s){const{pencil:i}=this.options,r=new xs(i,{scene:e,mList:t});return this.addController(r,s)}removePage(e){super.removePage(e,t=>{t.dispose()})}setPageActive(e){super.setPageActive(e,(t,s)=>{t.enabled=s})}setSize(e,t){this.controllerMap.forEach((s,i)=>{i.setSize(e,t)})}}class Ls{constructor(e){this.materials=new Map,this.materialBaseObjectMap=new Map,this.fixBufferGeometry=new v.BufferGeometry,this.pencil=e}add(e,t,s){if(this.getKey(t)||this.materials.set(e,t),s){const i=this.materialBaseObjectMap.get(t);i&&!i.includes(s)?i.push(s):this.materialBaseObjectMap.set(t,[s])}this.emitObject3dChange()}get(e){const t=this.materials.get(e);return t||console.warn(`Material with key "${e}" not found.`),t}getKey(e){for(const[t,s]of this.materials.entries())if(s===e)return t}addMultiple(e,t){for(const[s,i]of Object.entries(t)){const r=`${e}#${s}`;i&&this.add(r,i)}}getMultiple(e){const t={},s=`${e}#`;let i=!1;for(const[r,o]of this.materials.entries())if(r.startsWith(s)){const n=r.substring(s.length);t[n]=o,i=!0}return i?t:null}copyMultiple(e,t){const s={},i=`${e}#`;for(const[r,o]of this.materials.entries())if(r.startsWith(i)){const n=r.substring(i.length),l=o.clone();s[n]=l;const d=`${t}#${n}`;this.add(d,l)}return s}disposeMaterial(e){const t=new I.ResourceTracker;t.track([e]),t.dispose()}remove(e){const t=this.materials.get(e);t&&(this.materialBaseObjectMap.delete(t),this.disposeMaterial(t)),this.materials.delete(e),this.emitObject3dChange()}removeByMaterial(e){[...this.materials.entries()].some(([t,s])=>s===e?(this.remove(t),!0):!1)}proxyBaseObject(e){const t=e.object3d,s=i=>new Proxy(i,{set:(r,o,n)=>{if(typeof o=="string"&&!isNaN(Number(o))){const l=Number(o);if(l>=0&&l<r.length){const d=r[l];return this.rmBaseObjectMap(e,d),r[l]=n,this.addByBaseObject(e),!0}}return Reflect.set(r,o,n)}});e.object3d=new Proxy(t,{set:(i,r,o)=>r==="material"?(this.rmBaseObjectMap(e),Array.isArray(o)?i.material=s(o):i.material=o,this.addByBaseObject(e),!0):Reflect.set(i,r,o),get:(i,r)=>{if(r==="material"){const o=i.material;if(Array.isArray(o)&&!o.hasOwnProperty("__isProxy")){const n=s(o);Object.defineProperty(n,"__isProxy",{value:!0,enumerable:!1}),i.material=n}}return Reflect.get(i,r)}})}addByBaseObject(e){const t=e.object3d;t.material&&(Array.isArray(t.material)?t.material:[t.material]).forEach(i=>{this.add(i.uuid,i,e)})}rmBaseObjectMap(e,t){this.materialBaseObjectMap.forEach((s,i)=>{if(t&&i!==t)return;const r=s.indexOf(e);r!==-1&&(s.splice(r,1),s.length===0&&(this.materialBaseObjectMap.delete(i),this.disposeMaterial(i)))})}getBaseObjectByMaterial(e){const t=this.materialBaseObjectMap.get(e);return t||null}emitObject3dChange(){var e;(e=this.pencil)==null||e.event.emit("baseObjectListChange")}dispose(){const e=new I.ResourceTracker;e.track([...this.materials.values()]),e.dispose(),this.fixBufferGeometry.dispose(),this.materials.clear(),this.materialBaseObjectMap.clear()}}class Ps extends J{get mList(){return this.controller}constructor(e){super(),this.options=e}addMList(e,t){const{pencil:s}=this.options,i=new Ls(s);return this.addController(i,t)}removePage(e){super.removePage(e,t=>{t.dispose()})}}const fe=class fe{constructor(e){var r,o;this.raycaster=new v.Raycaster,this.maxBackufferArea=5760*5760,this.installPlugins=new Map,this._cameraPositon=new v.Vector3,this._cameraTarget=new v.Vector3,this.event=new ge.EventEmitter,this.timer=new vt.Timer,this.userData={},this.pageActiveIndex=0,this.pageCountIndex=0,this.userSetDprCache=1,this.event.setMaxListeners(1/0),(o=(r=this.timer).connect)==null||o.call(r,document),this.options=Ot(fe.options,e,{isMergeableObject:Pe.isPlainObject}),this.userSetDprCache=this.options.renderer.devicePixelRatio;const{container:t,stats:s,transformControls:i}=this.options;if(this.init(),this.options.WebGPUTHREE||this.initComposer(),this.initCSSRenderer(),i&&this.initTransformControls(),s){const n=new Et({horizontal:!1});n.dom.style.position="absolute",n.init(this.renderer),t.appendChild(n.dom),this.stats=n}this.initResizeObserver(),this.tweenUpdateRaf()}getPlugin(e){return this.installPlugins.get(e)}get renderer(){return this.rendererController.renderer}get maxAnisotropy(){return this.options.WebGPUTHREE?0:this.renderer.capabilities.getMaxAnisotropy()}get controls(){return this.controlsController.cameraControls}get cameraPositon(){return this.controls.getPosition(this._cameraPositon,!1)}get cameraTarget(){return this.controls.getTarget(this._cameraTarget,!1)}get camera(){return this.cameraController.camera}get scene(){return this.sceneController.scene}get loader(){return this.loaderController.loader}get lead(){return this.leadController.lead}get mList(){return this.mListController.mList}tweenUpdateRaf(){ve.update(),this.TweenRaf=requestAnimationFrame(this.tweenUpdateRaf.bind(this))}use(e,...t){this.installPlugins.has(e.pluginName)?console.log("plugin already installed"):typeof e.install=="function"&&(e.install(this,...t),this.installPlugins.set(e.pluginName,e))}addPage({sceneOptions:e,cameraOptions:t}={}){const s=this.pageCountIndex+1,i=this.cameraController.addPerspectiveCamera(t,s),r=this.sceneController.addScene(e,s);r.add(i),this.controlsController.addCameraControls(i,s),this.loaderController.addLoader(r,s);const o=this.mListController.addMList(null,s);return this.leadController.addLead(r,o,s),this.pageCountIndex=s,s}removePage(e){this.cameraController.removePage(e),this.sceneController.removePage(e),this.controlsController.removePage(e),this.loaderController.removePage(e),this.mListController.removePage(e),this.leadController.removePage(e),this.pageCountIndex===e&&(this.pageCountIndex-=1),this.pageActiveIndex===e&&(this.render(),this.showPage(0))}showPage(e){var s;if(e===this.pageActiveIndex)return;const t=this.scene;this.sceneController.setPageActive(e),t&&((s=this.cssRendererController)==null||s.render(t,this.camera)),this.cameraController.setPageActive(e),this.controlsController.setPageActive(e),this.loaderController.setPageActive(e),this.mListController.setPageActive(e),this.leadController.setPageActive(e),this.pageActiveIndex=e}init(){var g;const{container:e,WebGPUTHREE:t,helper:s,viewHelper:i,renderer:r,controls:o,loader:n}=this.options,{width:l,height:d}=this.getSize(),_=t?new qt({width:l,height:d,renderer:t.WebGPURenderer,rendererParams:Zt}):new Yt({width:l,height:d,rendererParams:ee(z({},r),{antialias:!1})}),p=new Gt({width:l,height:d}),E=new Xt({}),y=new Qt({controlsParams:{domElement:(g=o==null?void 0:o.domElement)!=null?g:_.renderer.domElement}}),m=new Es({loaderParams:z({anisotropy:_.renderer.capabilities.getMaxAnisotropy()},n)}),u=new Ps({pencil:this}),f=new ws({pencil:this});this.sceneController=E,this.cameraController=p,this.controlsController=y,this.rendererController=_,this.loaderController=m,this.mListController=u,this.leadController=f;const a=this.addPage({sceneOptions:this.options.scene,cameraOptions:this.options.camera});if(this.showPage(a),s){const O=new $t({container:e,sceneController:E,cameraController:p});O.add(E.scene),this.helperController=O,i&&O.addViewHelper()}e.appendChild(_.renderer.domElement)}initComposer(){const{bloom:e,bloomParams:t,ssao:s,ssaoParams:i,composer:r}=this.options,o=new gs({rendererController:this.rendererController,sceneController:this.sceneController,cameraController:this.cameraController,composerParams:r});this.composerController=o,e&&o.addBloomPass(z({},t)),s&&o.addSSAOPass(z({},i)),o.addOutputPass()}initCSSRenderer(){const{container:e,css2DRenderer:t,css3DRenderer:s,css2DRendererParams:i,css3DRendererParams:r}=this.options;if(t||s){const o=new rs(e);t&&o.addRenderer("css2d",i),s&&o.addRenderer("css3d",r),this.cssRendererController=o}}initTransformControls(){const e=new Jt({camera:this.camera,renderer:this.renderer,scene:this.scene});e.event.on("mouseDown",()=>{var t;(t=this.controlsController)==null||t.disable()}),e.event.on("mouseUp",()=>{var t;(t=this.controlsController)==null||t.enable()}),this.transformController=e}getSize(){const{container:e}=this.options;return{width:e.offsetWidth,height:e.offsetHeight}}initResizeObserver(){const{container:e}=this.options;if(this.resizeObserver)return;const t=new ResizeObserver(s=>{for(const i of s){const r=i.contentRect;this.handeleResize(r.width,r.height),this.setDevicePixelRatio(this.userSetDprCache)}});t.observe(e),this.resizeObserver=t}handeleResize(e,t,s=!0){const{rendererController:i,cameraController:r,composerController:o,cssRendererController:n,leadController:l}=this,d=this.renderer.getSize(new v.Vector2);d.x===e&&d.y===t||(r.setSize(e,t),i.setSize(e,t),o==null||o.setSize(e,t),n==null||n.setSize(e,t),l.setSize(e,t),this.installPlugins.forEach(_=>{var p;(p=_.setSize)==null||p.call(_,e,t)}),this.render(),s&&this.event.emit("resize",{width:e,height:t}))}setDevicePixelRatio(e){var n;this.userSetDprCache=e;const{width:t,height:s}=this.getSize();let i=Math.sqrt(this.maxBackufferArea/(t*s));i=(i*100|0)/100;const r=Math.min(e,i);r!==e&&console.warn("maxBackufferArea:",this.maxBackufferArea," the pixel ratio is set to",r);const o=this.renderer.getPixelRatio();r!==o&&(this.rendererController.setPixelRatio(r),(n=this.composerController)==null||n.setPixelRatio(r))}pick(e,t,s=!0){const{raycaster:i,options:r}=this,{container:o}=r,n=new v.Vector2,l=o.getBoundingClientRect();if(n.x=(e.clientX-l.left)/(l.right-l.left)*2-1,n.y=-((e.clientY-l.top)/(l.bottom-l.top))*2+1,this.camera&&this.scene){i.setFromCamera(n,this.camera);const d=i.intersectObjects(t||this.scene.children,s);if(d.length)return{object:d[0].object,index:d[0].index,intersects:d}}}render(){var s,i,r,o,n,l;if(!this.camera||!this.scene)return;this.timer.update(),ve.update();const e=this.timer.getDelta(),t=this.timer.getElapsed();this.controlsController.update(e,t),this.leadController.update(e,t),this.installPlugins.forEach(d=>{var _;(_=d.update)==null||_.call(d,e,t)}),(s=this.helperController)==null||s.update(e,this.controlsController,this.cameraTarget),(i=this.composerController)!=null&&i.active?this.composerController.render():(r=this.rendererController)==null||r.render(this.scene,this.camera),(o=this.helperController)==null||o.renderViewHelper(this.renderer),(n=this.cssRendererController)==null||n.render(this.scene,this.camera),(l=this.stats)==null||l.update(),this.event.emit("render",{delta:e,elapsed:t})}start(){window.cancelAnimationFrame(this.TweenRaf),this.renderer.setAnimationLoop(this.render.bind(this)),this.event.emit("start")}stop(){this.tweenUpdateRaf(),this.renderer.setAnimationLoop(null),this.event.emit("stop")}autoRotate(e){this.controlsController.autoRotateSpeed=e}showPipViewport(e){this.composerController.pipViewportState=e;let t=this.pipCameraControls;if(e){const{width:s,height:i}=this.getSize(),r=new DOMRect(e.x/s,(i-e.y-e.height)/i,e.width/s,e.height/i);if(t)t.enabled=!0,t.camera.position.copy(this.camera.position);else{const o=this.cameraController.cloneCamera(31);o.aspect=e.width/e.height,o.updateProjectionMatrix(),t=this.controlsController.addCameraControls(o,this.sceneController.activeIndex),t.addEventListener("update",()=>{this.controls.enabled=!1}),t.addEventListener("sleep",()=>{this.controls.enabled=!0}),this.pipCameraControls=t}t.interactiveArea=r}}dispose(){var e,t,s,i,r,o,n,l,d,_,p,E,y,m;this.stop(),this.timer.dispose(),ve.removeAll(),this.event.removeAllListeners(),(e=this.resizeObserver)==null||e.unobserve(this.options.container),this.installPlugins.forEach(u=>{var f;(f=u.dispose)==null||f.call(u)}),(t=this.controlsController)==null||t.dispose(),(s=this.transformController)==null||s.dispose(),(i=this.cssRendererController)==null||i.dispose(),(r=this.sceneController)==null||r.dispose(),(o=this.cameraController)==null||o.dispose(),(n=this.helperController)==null||n.dispose(),(l=this.composerController)==null||l.dispose(),(d=this.rendererController)==null||d.dispose(),(_=this.loaderController)==null||_.dispose(),(p=this.leadController)==null||p.dispose(),(E=this.mListController)==null||E.dispose(),this.cssRendererController=void 0,this.installPlugins.clear(),(y=this.stats)==null||y.dom.remove(),(m=this.renderer)==null||m.domElement.remove()}};fe.options={stats:pe,helper:pe,viewHelper:pe,controls:!0,transformControls:pe,renderer:Vt,composer:_s,scene:Kt,camera:ht,bloom:!1,bloomParams:fs,ssao:!1,loader:Os,ssaoParams:us,css2DRenderer:!1,css2DRendererParams:z({},$e),css3DRenderer:!1,css3DRendererParams:z({},$e)};let ue=fe;const Ss=Q.ACTION;exports.BaseObject=I.BaseObject;exports.ResourceTracker=I.ResourceTracker;exports.Pencil=ue;exports.cameraControlsAction=Ss;exports.default=ue;
98
+ `,defines:{}}),"baseTexture");return e.needsSwap=!0,e},we=1,pe=!1,ls=new v.MeshBasicMaterial({color:"black"}),hs=new v.PointsMaterial({color:"black",sizeAttenuation:!1}),cs=new v.PointsMaterial({color:"black",sizeAttenuation:!0}),ds=new v.SpriteMaterial({color:"black",sizeAttenuation:!0}),ps=new v.SpriteMaterial({color:"black",sizeAttenuation:!1}),ms=new I.MeshLineMaterial({color:"black",sizeAttenuation:0,lineWidth:0}),us={kernelRadius:8,minDistance:.005,maxDistance:.1},fs={threshold:0,strength:.4,radius:.1,bloomAlphaType:0},_s={multisampling:4,premultiplieAlpha:!1};class gs{constructor(e){this.bloomComposerActive=!1,this.active=!0,this.bloomSelection=new Set,this.bloomLayer=new v.Layers,this.bloomMaterials={},this.bloomVisible={},this.bloomComposerRenderIng=!1,this.pipViewportState=null,this.options=e;const{rendererController:t,sceneController:s,cameraController:i,composerParams:r}=e,{renderer:o}=t;this.renderer=o;const{multisampling:n}=r,{maxSamples:l}=o.capabilities,d=o.getDrawingBufferSize(new v.Vector2),_=new v.WebGLRenderTarget(d.width,d.height,{samples:Math.min(n,l),type:v.HalfFloatType}),p=new Re.EffectComposer(o,_),E=this.getSize();p.setSize(E.width,E.height);const y=new wt.RenderPass(s.scene,i.camera);p.addPass(y),this.scene=s.scene,this.camera=i.camera,this.finalComposer=p,this.renderPass=y,i.event.on("pageChange",m=>{this.changeCamera(m)}),s.event.on("pageChange",m=>{this.changeScene(m)})}changeCamera(e){this.renderPass.camera=e,this.camera=e}changeScene(e){this.renderPass.scene=e,this.ssaoPass&&(this.ssaoPass.scene=e),this.scene=e}addOutputPass(){const{premultiplieAlpha:e}=this.options.composerParams,t=new ns;this.outputPass=t,this.setPremultiplieAlpha(e),this.finalComposer.addPass(t)}setPremultiplieAlpha(e){this.outputPass&&(this.outputPass.uniforms.premultiplieAlpha.value=e?1:0)}addSSAOPass(e){const{scene:t,camera:s,renderer:i}=this,r=i.getSize(new v.Vector2),o=r.width,n=r.height,l=new Lt.SSAOPass(t,s,o,n);l.kernelRadius=e.kernelRadius,l.minDistance=e.minDistance,l.maxDistance=e.maxDistance,this.ssaoPass=l,this.finalComposer.addPass(l)}addBloomPass(e){const{renderer:t}=this,{threshold:s,strength:i,radius:r,bloomAlphaType:o}=e,n=new At.UnrealBloomPass(new v.Vector2(window.innerWidth,window.innerHeight),i,r,s);this.bloomPass=n;const l=new Re.EffectComposer(t);l.renderToScreen=!1,l.addPass(this.renderPass),l.addPass(n),this.bloomComposer=l;const d=as(l);d.uniforms.bloomAlphaType.value=o,this.bloomComposer=l,this.finalComposer.addPass(d),this.mixPass=d,this.bloomLayer.set(we)}setBloomSelection(e,t){if(!this.bloomComposer){console.warn("err:pencil.options.bloom");return}e.traverse(s=>{const{object3d:i}=s;i&&(t?(this.bloomSelection.add(s),i.layers.enable(we)):(this.bloomSelection.delete(s),i.layers.disable(we)))}),this.bloomSelection.size===0?this.bloomComposerActive=!1:this.bloomComposerActive=!0}enable(){this.active||(this.active=!0)}disable(){this.active&&(this.active=!1)}setSize(e,t){var s;(s=this.bloomComposer)==null||s.setSize(e,t),this.finalComposer.setSize(e,t)}setPixelRatio(e){var t;(t=this.bloomComposer)==null||t.setPixelRatio(e),this.finalComposer.setPixelRatio(e)}darkenNonBloomed(){const e=[],t=[];this.scene.children.forEach(s=>{s.isTransformControls||s.isTransformControlsRoot||s.type==="RectAreaLightHelper"?e.push(s):t.push(s)}),t.forEach(s=>{s.traverse(i=>{var l;const r=i,o=i,n=i;(l=r.material)!=null&&l.isShadowMaterial?e.push(r):r.material&&this.bloomLayer.test(r.layers)===!1&&(this.bloomMaterials[r.uuid]=r.material,o.isSprite?o.material.sizeAttenuation?o.material=ds:o.material=ps:r.material instanceof I.MeshLineMaterial?r.material=ms:n.isPoints?n.material.sizeAttenuation?n.material=cs:n.material=hs:r.material=ls)})}),e.forEach(s=>{this.bloomVisible[s.uuid]=s.visible,s.visible=!1})}restoreNonBloomed(){this.scene.traverse(e=>{const t=e;this.bloomMaterials[t.uuid]?(t.material=this.bloomMaterials[t.uuid],delete this.bloomMaterials[t.uuid]):this.bloomVisible[t.uuid]!==void 0&&(t.visible=this.bloomVisible[t.uuid],delete this.bloomVisible[t.uuid])})}finalComposerRender(){this.bloomComposerActive&&this.bloomComposer?(this.bloomComposerRenderIng=!0,this.mixPass.enabled=!0,this.darkenNonBloomed(),this.bloomComposer.render(),this.restoreNonBloomed(),this.bloomComposerRenderIng=!1):this.mixPass&&(this.mixPass.enabled=!1),this.finalComposer.render()}getSize(){return this.renderer.getSize(new v.Vector2)}render(){if(!this.active)return;const{cameraController:e,rendererController:t,sceneController:s}=this.options;if(this.finalComposerRender(),this.pipViewportState){e.setPageActive(31),e.setAspect(this.pipViewportState.width/this.pipViewportState.height),t.setViewport(ee(z({},this.pipViewportState),{scissor:!0,scissorTest:!0})),this.finalComposerRender(),e.setPageActive(s.activeIndex);const i=this.getSize();t.setViewport({x:0,y:0,width:i.width,height:i.height,scissor:!0,scissorTest:!1})}}dispose(){var e;this.bloomMaterials={},this.bloomVisible={},this.bloomSelection.clear(),this.finalComposer.dispose(),(e=this.bloomComposer)==null||e.dispose()}}class Qe extends v.Loader{constructor(e){super(e),this.options={type:"image"}}setOptions(e){return this.options=e,this}load(e,t,s,i){let r,o;this.options.type==="image"?(o=document.createElement("img"),r=new v.Texture(o)):this.options.type==="video"?(o=document.createElement("video"),o.preload="auto",o.autoplay=!1,o.loop=!1,o.muted=!0,o.setAttribute("webkit-playsinline","webkit-playsinline"),o.setAttribute("playsinline",""),r=new v.VideoTexture(o)):r=new v.Texture;const n=new v.FileLoader(this.manager);return n.setResponseType("blob"),n.setRequestHeader(this.requestHeader),n.setPath(this.path),n.setWithCredentials(this.withCredentials),n.load(e,l=>{let d=l;const _=e.split(".").pop(),p=this.options.type==="image"?`image/${_||"png"}`:`video/${_||"mp4"}`;d=d.slice(0,l.size,p);const E=()=>{o.removeEventListener("load",y,!1),o.removeEventListener("error",m,!1)},y=()=>{E(),r.needsUpdate=!0,t&&t(r)},m=f=>{E(),i&&i(f),this.manager.itemError(e),this.manager.itemEnd(e)};o.addEventListener("load",y,!1),o.addEventListener("error",m,!1);const u=window.URL.createObjectURL(d);o.src=u},s,i),r}}class ys extends v.Loader{constructor(e){super(e)}load(e,t,s,i){const r=new v.FileLoader(this.manager);r.setResponseType("blob"),r.setRequestHeader(this.requestHeader),r.setPath(this.path),r.setWithCredentials(this.withCredentials),r.load(e,o=>{const n=o,l=new DecompressionStream("gzip"),d=n.stream().pipeThrough(l);new Response(d).json().then(p=>{t==null||t(p)}).catch(p=>{i==null||i(p)})},s,i)}}const vs={images:["png","jpg","jpeg","ico","webp","avif"],media:["mp4","webm","ogg"],gltf:["gltf","glb"],json:["json","geojson"],gzipJson:["json.gzip"],exr:["exr"],lottie:["lottie.json"]};class Cs{constructor(e){this.loadObj=[],this.delLoadArr=[],this.assets=new Map,this.event=new ge.EventEmitter,this.options=z({simpleTexture4deleted:!1,prefix:""},e),this.loadingManager=new v.LoadingManager(()=>{},(t,s,i)=>{this.emit("progress",s,i)},t=>{console.warn(`Failed to load ${t}`)})}emit(e,...t){this.event.emit(e,...t)}on(e,t){this.event.on(e,t)}getAsset(e){const t=this.getAssetType(e);if(!t)return;const s=this.assets.get(e);if(!s){if((t==="images"||t==="media"||t==="exr")&&this.options.simpleTexture4deleted&&this.delLoadArr.includes(e))return new v.Texture;console.warn(`Asset ${e} not found`)}return s}getAssetType(e){var s;const t=(s=e.split(".").pop())==null?void 0:s.toLowerCase();if(t){if(e.endsWith("lottie.json"))return"lottie";if(e.endsWith("json.gzip"))return"gzipJson"}else return;for(const[i,r]of Object.entries(vs))if(r.includes(t))return i}getLoader(e,t){if(e==="images")return this.textureLoader||(this.textureLoader=new Qe(this.loadingManager),this.options.prefix&&this.textureLoader.setPath(this.options.prefix)),this.textureLoader;if(e==="media")return this.videoTextureLoader||(this.videoTextureLoader=new Qe(this.loadingManager),this.videoTextureLoader.setOptions({type:"video"}),this.options.prefix&&this.videoTextureLoader.setPath(this.options.prefix)),this.videoTextureLoader;if(e==="gltf"&&(t!=null&&t.dracoPath))return this.dracoGltfLoader||(this.dracoGltfLoader=new Ue.GLTFLoader(this.loadingManager),this.dracoLoader=new Mt.DRACOLoader,this.dracoLoader.setDecoderPath(t==null?void 0:t.dracoPath),this.dracoGltfLoader.setDRACOLoader(this.dracoLoader),this.options.prefix&&this.dracoGltfLoader.setPath(this.options.prefix)),this.dracoGltfLoader;if(e==="gltf")return this.gltfLoader||(this.gltfLoader=new Ue.GLTFLoader(this.loadingManager),this.options.prefix&&this.gltfLoader.setPath(this.options.prefix)),this.gltfLoader;if(e==="lottie")return this.lottieLoader||(this.lottieLoader=new Dt.LottieLoader(this.loadingManager),this.options.prefix&&this.lottieLoader.setPath(this.options.prefix)),this.lottieLoader;if(e==="gzipJson")return this.gzipJsonLoader||(this.gzipJsonLoader=new ys(this.loadingManager),this.options.prefix&&this.gzipJsonLoader.setPath(this.options.prefix)),this.gzipJsonLoader;if(e==="json")return this.jsonLoader||(this.jsonLoader=new v.FileLoader(this.loadingManager),this.jsonLoader.setResponseType("json"),this.options.prefix&&this.jsonLoader.setPath(this.options.prefix)),this.jsonLoader;if(e==="exr")return this.exrLoader||(this.exrLoader=new Rt.EXRLoader(this.loadingManager),this.options.prefix&&this.exrLoader.setPath(this.options.prefix)),this.exrLoader}add(e,t){typeof e=="string"&&(e=[e]),e.forEach(s=>{const i=z({src:s},t);this.loadObj.push(i)})}getSrcByAsset(e,t=this.assets){let s;return t.forEach((i,r)=>{i===e&&(s=r)}),s}get textureAssets(){const e=new Map;return this.assets.forEach((t,s)=>{(t instanceof v.Texture||t instanceof v.DataTexture||t instanceof v.VideoTexture)&&e.set(s,t)}),e}loadAll(){return te(this,null,function*(){const e=this.loadObj.filter(t=>!this.delLoadArr.includes(t.src));return yield Promise.all(e.map(t=>this.load(t.src,t)))})}load(e,t){return te(this,null,function*(){var n,l;const s=(n=t==null?void 0:t.type)!=null?n:this.getAssetType(e);if(!s)return;const i=(t==null?void 0:t.cache)!==!1,r=Le.makePromiseCreator();if(i){if(this.assets.has(e))return this.assets.get(e);this.assets.set(e,r.promise)}const o=this.getLoader(s,t);try{const d=yield o.loadAsync(e);if(this.assets.set(e,d),r.resolve(d),s==="images"||s==="media"||s==="exr"||s==="lottie"){(t==null?void 0:t.colorCorrection)!==!1&&Pe.colorCorrection({texture:d});const _=(l=t==null?void 0:t.anisotropy)!=null?l:this.options.anisotropy;d.anisotropy=_}return d}catch(d){r.reject(`Failed to load ${e}`);return}})}getUnusedAssets(){const{scene:e}=this.options;if(!e)return[...this.delLoadArr];const t=new Set,s=this.textureAssets;e.traverse(r=>{const o=r;o.material&&(Array.isArray(o.material)?o.material:[o.material]).forEach(l=>{[l.map,l.emissiveMap,l.normalMap,l.roughnessMap,l.metalnessMap,l.aoMap].forEach(d=>{if(d){const _=this.getSrcByAsset(d,s);_&&t.add(_)}})})});const i=new Set(this.textureAssets.keys());return t.forEach(r=>{i.delete(r)}),[...i,...this.delLoadArr]}dispose(){var e;this.assets.clear(),(e=this.dracoLoader)==null||e.dispose(),this.event.removeAllListeners(),this.delLoadArr.length=0,this.loadObj.length=0}}const Os={prefix:""};class Es extends J{get loader(){return this.controller}constructor(e){super(),this.options=e}addLoader(e,t){const{loaderParams:s}=this.options,i=new Cs(ee(z({},s),{scene:e}));return this.addController(i,t)}removePage(e){super.removePage(e,t=>{t.dispose()})}}class Ts extends I.BaseObject{constructor(e){super(),this.options=z({},e)}create(){var e;this.object3d=(e=this.options.scene)!=null?e:new v.Scene}}function Je(h){let e=!1,t=[];return function(...s){t=s,e||(e=!0,requestAnimationFrame(()=>{e=!1,h(...t)}))}}class bs{constructor(e){var t;this.enabled=!0,this.pickFunctionsMap=new Map,this.pickNodeFunctionsMap=new Map,this.pickFunctionsMapIndex=-1,this.pickNodeFunctionsMapIndex=-1,this.activeObjects=new Set,this.prevActiveObjects=new Set,this.objCallbackMap=new Map,this.pickListener={move:!1,down:!1},this.pencil=e,this.domElement=((t=e.options.controls)==null?void 0:t.domElement)||e.options.container}addPickListener(e){const t=new Set(["move","enter","leave"]),s=new Set(["down","downOutside","click"]),i=r=>{var y;if(!this.enabled)return;r.preventDefault();const o=e==="move"?t:s,n=[];if(this.pickFunctionsMap.forEach(m=>{o.has(m.type)&&n.push(ee(z({},m),{objArr:m.objArr instanceof Function?m.objArr():m.objArr}))}),n.length===0)return;this.activeObjects.clear(),this.objCallbackMap.clear();const l=this.objCallbackMap,d=[];for(const m of n)for(const u of m.objArr){if(!u.object3d||!u.visibleWithAncestors)continue;l.has(u)||(l.set(u,new Map),d.push(u));const f=l.get(u);f.has(m.type)||f.set(m.type,[]),f.get(m.type).push(m.cb)}if(d.length===0)return;const _=d.map(m=>m.object3d);_.forEach(m=>{m.isGroup&&m.traverse(u=>{u instanceof v.Mesh&&_.push(u)})});const p=(y=this.pencil.pick(r,_,!1))==null?void 0:y.intersects;if(!p||p.length===0)e==="down"?this.handleDownOutside(r):e==="move"&&this.handleLeaveEvents(r);else{this.sortIntersections(p);const m=p[0];this.processIntersection(m,r,e)}const E=this.prevActiveObjects;this.prevActiveObjects=this.activeObjects,this.activeObjects=E,this.activeObjects.clear()};this.domElement.addEventListener(`pointer${e}`,Je(i),{passive:!1})}sortIntersections(e){e.sort((t,s)=>t.distance===s.distance?t.object.getObjectById(s.object.id)?1:s.object.getObjectById(t.object.id)?-1:0:t.distance-s.distance)}processIntersection(e,t,s){const i=this.objCallbackMap,r=e.index||-1;let o=e.object;for(;o;){const n=this.pencil.lead.objMap.get(o);n&&i.has(n)&&this.activeObjects.add(n),o=o.parent}s==="move"?this.handleLeaveEvents(t):s==="down"&&this.handleDownOutside(t),this.processObjectHierarchy(t,s,r)}processObjectHierarchy(e,t,s){const i=this.objCallbackMap;let r=!1;const o=()=>{r=!0};for(const n of this.activeObjects){if(r)break;const l=i.get(n);if(l)if(t==="move"){const d=l.get("enter");if(d&&!this.prevActiveObjects.has(n))for(const p of d)p({baseObject:n,mouseEvent:e,sp:o,intersectionIndex:s});const _=l.get("move");if(_)for(const p of _)p({baseObject:n,mouseEvent:e,sp:o,intersectionIndex:s})}else{const d=l.get("down");if(d)for(const p of d)p({baseObject:n,mouseEvent:e,sp:o,intersectionIndex:s});const _=l.get("click");if(_){const p=E=>{E.preventDefault();const y=5;if(!r&&Math.abs(E.clientX-e.clientX)<=y&&Math.abs(E.clientY-e.clientY)<=y)for(const m of _)m({baseObject:n,mouseEvent:e,sp:o,intersectionIndex:s});this.domElement.removeEventListener("pointerup",p)};this.domElement.addEventListener("pointerup",p)}}}}handleLeaveEvents(e){this.objCallbackMap.forEach((s,i)=>{const r=s.get("leave");if(r&&this.prevActiveObjects.has(i)&&!this.activeObjects.has(i))for(const o of r)o({baseObject:i,mouseEvent:e})})}handleDownOutside(e){this.objCallbackMap.forEach((s,i)=>{const r=s.get("downOutside");if(r&&!this.activeObjects.has(i))for(const o of r)o({baseObject:i,mouseEvent:e})})}handlePick(e,t,s){let i=t;i==="mousemove"?i="move":i==="mouseenter"?i="enter":i==="mouseleave"&&(i="leave"),this.pickFunctionsMapIndex+=1;const r=this.pickFunctionsMapIndex;return this.pickFunctionsMap.set(r,{objArr:e,type:i,cb:s}),this.pickListener.move||Array.from(this.pickFunctionsMap.values()).some(n=>["move","enter","leave"].includes(n.type))&&(this.pickListener.move=!0,this.addPickListener("move")),this.pickListener.down||Array.from(this.pickFunctionsMap.values()).some(n=>["down","downOutside","click"].includes(n.type))&&(this.pickListener.down=!0,this.addPickListener("down")),r}removePick(e){this.pickFunctionsMap.delete(e)}handlePickNode(e,t,s){if(t==="downOutside")return console.warn("handlePickNode:err:不支持 downOutside"),-1;this.pickNodeFunctionsMapIndex+=1;const i=this.pickNodeFunctionsMapIndex,r=e instanceof Function?e():e,o=[];for(const n of r){const l=n;l.element.style.pointerEvents="auto";const d=p=>{this.enabled&&(p.preventDefault(),s({baseObject:l,mouseEvent:p}))},_=`pointer${t}`;l.element.addEventListener(_,Je(d),!1),o.push({arr:l,type:_,listener:d})}return this.pickNodeFunctionsMap.set(i,o),i}removePickNode(e){const t=this.pickNodeFunctionsMap.get(e);if(t){for(const s of t)s.arr.element.style.pointerEvents="none",s.arr.element.removeEventListener(s.type,s.listener,!1);this.pickNodeFunctionsMap.delete(e)}}dispose(){this.pickFunctionsMap.clear(),this.pickNodeFunctionsMap.clear(),this.activeObjects.clear(),this.prevActiveObjects.clear(),this.objCallbackMap.clear()}}class xs extends bs{constructor(e,t){super(e),this.objMap=new Map,this.objects=new Map,this.objectsPm=new Map,this.objectNamesToFactories=new Map,this.scene=new Ts({scene:t.scene}),this.mList=t.mList,this.scene.create(),this.scene.lead=this,this.scene.pencil=e,this.scene.mList=this.mList,this.scene.key="Scene",this.scene.object3d.name="场景",this.group=new I.Group,this.group.create(),this.group.lead=this,this.group.pencil=e,this.group.mList=this.mList,this.group.key="@Group",this.group.object3d.name="物体组",this.prefabGroup=new I.Group,this.prefabGroup.create(),this.prefabGroup.lead=this,this.prefabGroup.pencil=e,this.prefabGroup.mList=this.mList,this.prefabGroup.key="@PrefabGroup",this.prefabGroup.object3d.name="预制组",this.scene.add(this.group.object3d,this.prefabGroup.object3d),this.objects.set("@Scene",this.scene),this.objects.set("@Group",this.group),this.objects.set("@PrefabGroup",this.prefabGroup),this.objMap.set(this.scene.object3d,this.scene),this.objMap.set(this.group.object3d,this.group),this.objMap.set(this.prefabGroup.object3d,this.prefabGroup)}get objectsPromise(){return this.objectsPm.values()}init(e){return Object.keys(e).forEach(t=>{const s=class{create(r={}){return new e[t](r)}};this.objectNamesToFactories.set(t,s)}),this}getObject(e,t){e.includes("#")&&console.warn("getObject:err:不支持 #",e);const{key:s}=t||{},i=`${e}${s?`#${s}`:""}`;return this.objects.get(i)}getAllObject(e,t){e.includes("#")&&console.warn("getAllObject:err:不支持 #",e);const{key:s}=t||{},i=`${e}${s?`#${s}`:""}`,r=[];return this.objects.forEach((o,n)=>{(n.startsWith(s?i:`${i}#`)||n===i)&&r.push(o)}),r}draw(e,t,s){return te(this,null,function*(){var r,o,n,l;const i=this.objectNamesToFactories.get(e);if(i){t||(t={}),t.target===void 0&&(t.target=s);const d=t.target,_=(r=t.onTop)!=null?r:0,p=(o=t.prefab)!=null?o:!1,E=(n=t.create)!=null?n:!0,y=new i().create(t);let m;return d===null?m=null:typeof d=="string"?m=this.objects.get(d):(l=d==null?void 0:d.objectType)!=null&&l.startsWith("BaseObject")||d?m=d:p?m=this.prefabGroup:m=this.group,E===!1?y.create=()=>{}:E!==!0&&(y.create=()=>{E(y)}),y.pencil=this.pencil,y.lead=this,y.mList=this.mList,y.prefab=p,y.objectType=`BaseObject#${e}`,y.objectOptions=t,this.setBaseObjectKey(y,t.key?`$t:#${t.key}`:"$t:",m==null?void 0:m.key),this.objectsPm.set(y.key,this.addBaseObject(y,m,_)),yield this.objectsPm.get(y.key),this.objectsPm.delete(y.key),y}throw new Error(`Unrecognized:${e}`)})}setBaseObjectKey(e,t,s){const i=e.objectType,[,r]=i.split("#");let o=t.replace("$t:",r);if(s){const[,n]=s.split("#");o=o.replace("$p:",n)}return this.objects.has(o)&&(o.includes("#")?o+=`-${Le.generateUUID()}`:o+=`#${Le.generateUUID()}`),e.key=o,this.objects.set(o,e),o}updateBaseObjectKey(e,t){var o;let s;for(const[n,l]of this.objects.entries())if(l===e){s=n;break}const i=(o=e.parent)==null?void 0:o.key,r=this.setBaseObjectKey(e,t,i);return s&&this.objects.delete(s),this.pencil.event.emit("updateKey",e,r,s),r}addBaseObject(e,t,s){return te(this,null,function*(){yield e.create(),e.object3d&&(this.mList.proxyBaseObject(e),this.mList.addBaseObjectMap(e),s&&e.setTop(s),t!==null&&(t.add(e.object3d),this.objMap.set(e.object3d,e))),e.render(),this.pencil.event.emit("draw",e)})}erase(...e){[...e].forEach(t=>{const s=[];if(typeof t=="string"){const[i,r]=t.split("#");s.push(...this.getAllObject(i,{key:r}))}else s.push(t);s.forEach(i=>{i.dispose()})}),this.pencil.event.emit("erase",...e)}update(e,t){this.objects.forEach(s=>{s.update(e,t)})}setSize(e,t){this.objects.forEach(s=>{s.resize(e,t)})}eraseAll(){this.group&&(this.objects.forEach(e=>{e.key.startsWith("Node")&&this.erase(e)}),this.erase(this.group))}dispose(){super.dispose(),this.scene.erase(),this.objects.forEach(e=>{e.erase()}),this.objects.clear(),this.objectsPm.clear(),this.objMap.clear(),this.objectNamesToFactories.clear()}}class ws extends J{get lead(){return this.controller}constructor(e){super(),this.options=e}addLead(e,t,s){const{pencil:i}=this.options,r=new xs(i,{scene:e,mList:t});return this.addController(r,s)}removePage(e){super.removePage(e,t=>{t.dispose()})}setPageActive(e){super.setPageActive(e,(t,s)=>{t.enabled=s})}setSize(e,t){this.controllerMap.forEach((s,i)=>{i.setSize(e,t)})}}class Ls{constructor(e){this.materials=new Map,this.materialBaseObjectMap=new Map,this.fixBufferGeometry=new v.BufferGeometry,this.pencil=e}add(e,t){this.materials.set(e,t),this.emitObject3dChange()}get(e){const t=this.materials.get(e);return t||console.warn(`Material with key "${e}" not found.`),t}getKey(e){for(const[t,s]of this.materials.entries())if(s===e)return t}addMultiple(e,t){for(const[s,i]of Object.entries(t)){const r=`${e}#${s}`;i&&this.add(r,i)}}getMultiple(e){const t={},s=`${e}#`;let i=!1;for(const[r,o]of this.materials.entries())if(r.startsWith(s)){const n=r.substring(s.length);t[n]=o,i=!0}return i?t:null}copyMultiple(e,t){const s={},i=`${e}#`;for(const[r,o]of this.materials.entries())if(r.startsWith(i)){const n=r.substring(i.length),l=o.clone();s[n]=l;const d=`${t}#${n}`;this.add(d,l)}return s}disposeMaterial(e){const t=new I.ResourceTracker;t.track([e]),t.dispose()}remove(e){const t=this.materials.get(e);t&&this.disposeMaterial(t),this.materials.delete(e),this.emitObject3dChange()}removeByMaterial(e){[...this.materials.entries()].some(([t,s])=>s===e?(this.remove(t),!0):!1)}proxyBaseObject(e){const t=e.object3d,s=i=>new Proxy(i,{set:(r,o,n)=>{if(typeof o=="string"&&!isNaN(Number(o))){const l=Number(o);if(l>=0&&l<r.length){const d=r[l];return this.rmBaseObjectMap(e,d),r[l]=n,this.addBaseObjectMap(e),!0}}return Reflect.set(r,o,n)}});e.object3d=new Proxy(t,{set:(i,r,o)=>{var n;return r==="material"&&!((n=this.pencil.composerController)!=null&&n.bloomComposerRenderIng)?(this.rmBaseObjectMap(e),i.material=o,this.addBaseObjectMap(e),!0):Reflect.set(i,r,o)},get:(i,r)=>{var o;if(r==="material"&&!((o=this.pencil.composerController)!=null&&o.bloomComposerRenderIng)){const n=i.material;if(Array.isArray(n)&&!n.hasOwnProperty("__isProxy")){const l=s(n);Object.defineProperty(l,"__isProxy",{value:!0,enumerable:!1}),i.material=l}}return Reflect.get(i,r)}})}addBaseObjectMap(e){const t=e.object3d;t.material&&(Array.isArray(t.material)?t.material:[t.material]).forEach(i=>{const r=this.materialBaseObjectMap.get(i);r?r.add(e):this.materialBaseObjectMap.set(i,new Set([e]))})}rmBaseObjectMap(e,t){this.materialBaseObjectMap.forEach((s,i)=>{t&&i!==t||s.has(e)&&(s.delete(e),s.size===0&&(this.materialBaseObjectMap.delete(i),this.disposeMaterial(i)))})}getBaseObjectMaterials(){const e={};return this.materialBaseObjectMap.forEach((t,s)=>{t.forEach(i=>{e[i.key]=s})}),e}emitObject3dChange(){var e;(e=this.pencil)==null||e.event.emit("baseObjectListChange")}dispose(){const e=new I.ResourceTracker;e.track([...this.materials.values()]),e.dispose(),this.fixBufferGeometry.dispose(),this.materials.clear(),this.materialBaseObjectMap.clear()}}class Ps extends J{get mList(){return this.controller}constructor(e){super(),this.options=e}addMList(e,t){const{pencil:s}=this.options,i=new Ls(s);return this.addController(i,t)}removePage(e){super.removePage(e,t=>{t.dispose()})}}const fe=class fe{constructor(e){var r,o;this.raycaster=new v.Raycaster,this.maxBackufferArea=5760*5760,this.installPlugins=new Map,this._cameraPositon=new v.Vector3,this._cameraTarget=new v.Vector3,this.event=new ge.EventEmitter,this.timer=new vt.Timer,this.userData={},this.pageActiveIndex=0,this.pageCountIndex=0,this.userSetDprCache=1,this.event.setMaxListeners(1/0),(o=(r=this.timer).connect)==null||o.call(r,document),this.options=Ot(fe.options,e,{isMergeableObject:Pe.isPlainObject}),this.userSetDprCache=this.options.renderer.devicePixelRatio;const{container:t,stats:s,transformControls:i}=this.options;if(this.init(),this.options.WebGPUTHREE||this.initComposer(),this.initCSSRenderer(),i&&this.initTransformControls(),s){const n=new Et({horizontal:!1});n.dom.style.position="absolute",n.init(this.renderer),t.appendChild(n.dom),this.stats=n}this.initResizeObserver(),this.tweenUpdateRaf()}getPlugin(e){return this.installPlugins.get(e)}get renderer(){return this.rendererController.renderer}get maxAnisotropy(){return this.options.WebGPUTHREE?0:this.renderer.capabilities.getMaxAnisotropy()}get controls(){return this.controlsController.cameraControls}get cameraPositon(){return this.controls.getPosition(this._cameraPositon,!1)}get cameraTarget(){return this.controls.getTarget(this._cameraTarget,!1)}get camera(){return this.cameraController.camera}get scene(){return this.sceneController.scene}get loader(){return this.loaderController.loader}get lead(){return this.leadController.lead}get mList(){return this.mListController.mList}tweenUpdateRaf(){ve.update(),this.TweenRaf=requestAnimationFrame(this.tweenUpdateRaf.bind(this))}use(e,...t){this.installPlugins.has(e.pluginName)?console.log("plugin already installed"):typeof e.install=="function"&&(e.install(this,...t),this.installPlugins.set(e.pluginName,e))}addPage({sceneOptions:e,cameraOptions:t}={}){const s=this.pageCountIndex+1,i=this.cameraController.addPerspectiveCamera(t,s),r=this.sceneController.addScene(e,s);r.add(i),this.controlsController.addCameraControls(i,s),this.loaderController.addLoader(r,s);const o=this.mListController.addMList(null,s);return this.leadController.addLead(r,o,s),this.pageCountIndex=s,s}removePage(e){this.cameraController.removePage(e),this.sceneController.removePage(e),this.controlsController.removePage(e),this.loaderController.removePage(e),this.mListController.removePage(e),this.leadController.removePage(e),this.pageCountIndex===e&&(this.pageCountIndex-=1),this.pageActiveIndex===e&&(this.render(),this.showPage(0))}showPage(e){var s;if(e===this.pageActiveIndex)return;const t=this.scene;this.sceneController.setPageActive(e),t&&((s=this.cssRendererController)==null||s.render(t,this.camera)),this.cameraController.setPageActive(e),this.controlsController.setPageActive(e),this.loaderController.setPageActive(e),this.mListController.setPageActive(e),this.leadController.setPageActive(e),this.pageActiveIndex=e}init(){var g;const{container:e,WebGPUTHREE:t,helper:s,viewHelper:i,renderer:r,controls:o,loader:n}=this.options,{width:l,height:d}=this.getSize(),_=t?new qt({width:l,height:d,renderer:t.WebGPURenderer,rendererParams:Zt}):new Yt({width:l,height:d,rendererParams:ee(z({},r),{antialias:!1})}),p=new Gt({width:l,height:d}),E=new Xt({}),y=new Qt({controlsParams:{domElement:(g=o==null?void 0:o.domElement)!=null?g:_.renderer.domElement}}),m=new Es({loaderParams:z({anisotropy:_.renderer.capabilities.getMaxAnisotropy()},n)}),u=new Ps({pencil:this}),f=new ws({pencil:this});this.sceneController=E,this.cameraController=p,this.controlsController=y,this.rendererController=_,this.loaderController=m,this.mListController=u,this.leadController=f;const a=this.addPage({sceneOptions:this.options.scene,cameraOptions:this.options.camera});if(this.showPage(a),s){const O=new $t({container:e,sceneController:E,cameraController:p});O.add(E.scene),this.helperController=O,i&&O.addViewHelper()}e.appendChild(_.renderer.domElement)}initComposer(){const{bloom:e,bloomParams:t,ssao:s,ssaoParams:i,composer:r}=this.options,o=new gs({rendererController:this.rendererController,sceneController:this.sceneController,cameraController:this.cameraController,composerParams:r});this.composerController=o,e&&o.addBloomPass(z({},t)),s&&o.addSSAOPass(z({},i)),o.addOutputPass()}initCSSRenderer(){const{container:e,css2DRenderer:t,css3DRenderer:s,css2DRendererParams:i,css3DRendererParams:r}=this.options;if(t||s){const o=new rs(e);t&&o.addRenderer("css2d",i),s&&o.addRenderer("css3d",r),this.cssRendererController=o}}initTransformControls(){const e=new Jt({camera:this.camera,renderer:this.renderer,scene:this.scene});e.event.on("mouseDown",()=>{var t;(t=this.controlsController)==null||t.disable()}),e.event.on("mouseUp",()=>{var t;(t=this.controlsController)==null||t.enable()}),this.transformController=e}getSize(){const{container:e}=this.options;return{width:e.offsetWidth,height:e.offsetHeight}}initResizeObserver(){const{container:e}=this.options;if(this.resizeObserver)return;const t=new ResizeObserver(s=>{for(const i of s){const r=i.contentRect;this.handeleResize(r.width,r.height),this.setDevicePixelRatio(this.userSetDprCache)}});t.observe(e),this.resizeObserver=t}handeleResize(e,t,s=!0){const{rendererController:i,cameraController:r,composerController:o,cssRendererController:n,leadController:l}=this,d=this.renderer.getSize(new v.Vector2);d.x===e&&d.y===t||(r.setSize(e,t),i.setSize(e,t),o==null||o.setSize(e,t),n==null||n.setSize(e,t),l.setSize(e,t),this.installPlugins.forEach(_=>{var p;(p=_.setSize)==null||p.call(_,e,t)}),this.render(),s&&this.event.emit("resize",{width:e,height:t}))}setDevicePixelRatio(e){var n;this.userSetDprCache=e;const{width:t,height:s}=this.getSize();let i=Math.sqrt(this.maxBackufferArea/(t*s));i=(i*100|0)/100;const r=Math.min(e,i);r!==e&&console.warn("maxBackufferArea:",this.maxBackufferArea," the pixel ratio is set to",r);const o=this.renderer.getPixelRatio();r!==o&&(this.rendererController.setPixelRatio(r),(n=this.composerController)==null||n.setPixelRatio(r))}pick(e,t,s=!0){const{raycaster:i,options:r}=this,{container:o}=r,n=new v.Vector2,l=o.getBoundingClientRect();if(n.x=(e.clientX-l.left)/(l.right-l.left)*2-1,n.y=-((e.clientY-l.top)/(l.bottom-l.top))*2+1,this.camera&&this.scene){i.setFromCamera(n,this.camera);const d=i.intersectObjects(t||this.scene.children,s);if(d.length)return{object:d[0].object,index:d[0].index,intersects:d}}}render(){var s,i,r,o,n,l;if(!this.camera||!this.scene)return;this.timer.update(),ve.update();const e=this.timer.getDelta(),t=this.timer.getElapsed();this.controlsController.update(e,t),this.leadController.update(e,t),this.installPlugins.forEach(d=>{var _;(_=d.update)==null||_.call(d,e,t)}),(s=this.helperController)==null||s.update(e,this.controlsController,this.cameraTarget),(i=this.composerController)!=null&&i.active?this.composerController.render():(r=this.rendererController)==null||r.render(this.scene,this.camera),(o=this.helperController)==null||o.renderViewHelper(this.renderer),(n=this.cssRendererController)==null||n.render(this.scene,this.camera),(l=this.stats)==null||l.update(),this.event.emit("render",{delta:e,elapsed:t})}start(){window.cancelAnimationFrame(this.TweenRaf),this.renderer.setAnimationLoop(this.render.bind(this)),this.event.emit("start")}stop(){this.tweenUpdateRaf(),this.renderer.setAnimationLoop(null),this.event.emit("stop")}autoRotate(e){this.controlsController.autoRotateSpeed=e}showPipViewport(e){this.composerController.pipViewportState=e;let t=this.pipCameraControls;if(e){const{width:s,height:i}=this.getSize(),r=new DOMRect(e.x/s,(i-e.y-e.height)/i,e.width/s,e.height/i);if(t)t.enabled=!0,t.camera.position.copy(this.camera.position);else{const o=this.cameraController.cloneCamera(31);o.aspect=e.width/e.height,o.updateProjectionMatrix(),t=this.controlsController.addCameraControls(o,this.sceneController.activeIndex),t.addEventListener("update",()=>{this.controls.enabled=!1}),t.addEventListener("sleep",()=>{this.controls.enabled=!0}),this.pipCameraControls=t}t.interactiveArea=r}}dispose(){var e,t,s,i,r,o,n,l,d,_,p,E,y,m;this.stop(),this.timer.dispose(),ve.removeAll(),this.event.removeAllListeners(),(e=this.resizeObserver)==null||e.unobserve(this.options.container),this.installPlugins.forEach(u=>{var f;(f=u.dispose)==null||f.call(u)}),(t=this.controlsController)==null||t.dispose(),(s=this.transformController)==null||s.dispose(),(i=this.cssRendererController)==null||i.dispose(),(r=this.sceneController)==null||r.dispose(),(o=this.cameraController)==null||o.dispose(),(n=this.helperController)==null||n.dispose(),(l=this.composerController)==null||l.dispose(),(d=this.rendererController)==null||d.dispose(),(_=this.loaderController)==null||_.dispose(),(p=this.leadController)==null||p.dispose(),(E=this.mListController)==null||E.dispose(),this.cssRendererController=void 0,this.installPlugins.clear(),(y=this.stats)==null||y.dom.remove(),(m=this.renderer)==null||m.domElement.remove()}};fe.options={stats:pe,helper:pe,viewHelper:pe,controls:!0,transformControls:pe,renderer:Vt,composer:_s,scene:Kt,camera:ht,bloom:!1,bloomParams:fs,ssao:!1,loader:Os,ssaoParams:us,css2DRenderer:!1,css2DRendererParams:z({},$e),css3DRenderer:!1,css3DRendererParams:z({},$e)};let ue=fe;const Ss=Q.ACTION;exports.BaseObject=I.BaseObject;exports.ResourceTracker=I.ResourceTracker;exports.Pencil=ue;exports.cameraControlsAction=Ss;exports.default=ue;
@@ -26,7 +26,7 @@ var se = (h, e, t) => new Promise((s, i) => {
26
26
  }, n = (l) => l.done ? s(l.value) : Promise.resolve(l.value).then(r, o);
27
27
  n((t = t.apply(h, e)).next());
28
28
  });
29
- import { WebGLRenderer as Ut, Vector2 as B, Vector3 as j, PerspectiveCamera as zt, Matrix4 as W, Scene as nt, AxesHelper as De, CameraHelper as kt, PointLightHelper as Ft, DirectionalLightHelper as Nt, SpotLightHelper as Ht, HemisphereLightHelper as jt, Box3 as at, Box3Helper as Ue, MathUtils as It, Vector4 as Bt, Quaternion as lt, Spherical as Vt, Sphere as Yt, Raycaster as ht, REVISION as Zt, Object3D as Wt, UniformsUtils as Gt, RawShaderMaterial as Kt, ShaderMaterial as Xt, MeshBasicMaterial as $t, PointsMaterial as ct, SpriteMaterial as dt, Layers as qt, WebGLRenderTarget as Qt, HalfFloatType as Jt, Loader as pt, Texture as fe, VideoTexture as mt, FileLoader as Se, LoadingManager as es, DataTexture as ts, Mesh as ss, BufferGeometry as is } from "three";
29
+ import { WebGLRenderer as Ut, Vector2 as B, Vector3 as I, PerspectiveCamera as zt, Matrix4 as W, Scene as nt, AxesHelper as De, CameraHelper as kt, PointLightHelper as Ft, DirectionalLightHelper as Nt, SpotLightHelper as Ht, HemisphereLightHelper as It, Box3 as at, Box3Helper as Ue, MathUtils as jt, Vector4 as Bt, Quaternion as lt, Spherical as Vt, Sphere as Yt, Raycaster as ht, REVISION as Zt, Object3D as Wt, UniformsUtils as Gt, RawShaderMaterial as Kt, ShaderMaterial as Xt, MeshBasicMaterial as $t, PointsMaterial as ct, SpriteMaterial as dt, Layers as qt, WebGLRenderTarget as Qt, HalfFloatType as Jt, Loader as pt, Texture as fe, VideoTexture as mt, FileLoader as Se, LoadingManager as es, DataTexture as ts, Mesh as ss, BufferGeometry as is } from "three";
30
30
  import { Timer as rs } from "three/examples/jsm/misc/Timer";
31
31
  import * as Ce from "@tweenjs/tween.js";
32
32
  import os from "deepmerge";
@@ -42,7 +42,7 @@ import { SSAOPass as fs } from "three/examples/jsm/postprocessing/SSAOPass";
42
42
  import { FullScreenQuad as Fe } from "three/examples/jsm/postprocessing/Pass";
43
43
  import { OutputPass as _s } from "three/examples/jsm/postprocessing/OutputPass";
44
44
  import { ShaderPass as gs } from "three/examples/jsm/postprocessing/ShaderPass";
45
- import { UnrealBloomPass as ys } from "three/examples/jsm/postprocessing/UnrealBloomPass";
45
+ import { UnrealBloomPass as vs } from "three/examples/jsm/postprocessing/UnrealBloomPass";
46
46
  import "three/examples/jsm/renderers/CSS2DRenderer";
47
47
  import "three/examples/jsm/renderers/CSS3DRenderer";
48
48
  import "d3-geo";
@@ -54,7 +54,7 @@ import "three/examples/jsm/lines/LineSegmentsGeometry";
54
54
  import "three/examples/jsm/lines/LineMaterial";
55
55
  import "three-bvh-csg";
56
56
  import { GLTFLoader as Ne } from "three/examples/jsm/loaders/GLTFLoader";
57
- import { DRACOLoader as vs } from "three/examples/jsm/loaders/DRACOLoader";
57
+ import { DRACOLoader as ys } from "three/examples/jsm/loaders/DRACOLoader";
58
58
  import { EXRLoader as Cs } from "three/examples/jsm/loaders/EXRLoader";
59
59
  import { LottieLoader as Es } from "three/examples/jsm/loaders/LottieLoader";
60
60
  import { makePromiseCreator as Os, generateUUID as He } from "esus-lite";
@@ -92,10 +92,10 @@ const M = {
92
92
  function Y(h) {
93
93
  return h.isPerspectiveCamera;
94
94
  }
95
- function I(h) {
95
+ function j(h) {
96
96
  return h.isOrthographicCamera;
97
97
  }
98
- const K = Math.PI * 2, je = Math.PI / 2, ft = 1e-5, ie = Math.PI / 180;
98
+ const K = Math.PI * 2, Ie = Math.PI / 2, ft = 1e-5, ie = Math.PI / 180;
99
99
  function k(h, e, t) {
100
100
  return Math.max(e, Math.min(t, h));
101
101
  }
@@ -105,7 +105,7 @@ function A(h, e = ft) {
105
105
  function P(h, e, t = ft) {
106
106
  return A(h - e, t);
107
107
  }
108
- function Ie(h, e) {
108
+ function je(h, e) {
109
109
  return Math.round(h / e) * e;
110
110
  }
111
111
  function re(h) {
@@ -122,21 +122,21 @@ function he(h, e, t, s, i = 1 / 0, r) {
122
122
  d = k(d, -p, p), e = h - d;
123
123
  const E = (t.value + o * d) * r;
124
124
  t.value = (t.value - o * E) * l;
125
- let y = e + (d + E) * l;
126
- return _ - h > 0 == y > _ && (y = _, t.value = (y - _) / r), y;
125
+ let v = e + (d + E) * l;
126
+ return _ - h > 0 == v > _ && (v = _, t.value = (v - _) / r), v;
127
127
  }
128
128
  function Be(h, e, t, s, i = 1 / 0, r, o) {
129
129
  s = Math.max(1e-4, s);
130
130
  const n = 2 / s, l = n * r, d = 1 / (1 + l + 0.48 * l * l + 0.235 * l * l * l);
131
- let _ = e.x, p = e.y, E = e.z, y = h.x - _, m = h.y - p, u = h.z - E;
132
- const f = _, a = p, g = E, C = i * s, v = C * C, b = y * y + m * m + u * u;
133
- if (b > v) {
134
- const ve = Math.sqrt(b);
135
- y = y / ve * C, m = m / ve * C, u = u / ve * C;
136
- }
137
- _ = h.x - y, p = h.y - m, E = h.z - u;
138
- const O = (t.x + n * y) * r, x = (t.y + n * m) * r, R = (t.z + n * u) * r;
139
- t.x = (t.x - n * O) * d, t.y = (t.y - n * x) * d, t.z = (t.z - n * R) * d, o.x = _ + (y + O) * d, o.y = p + (m + x) * d, o.z = E + (u + R) * d;
131
+ let _ = e.x, p = e.y, E = e.z, v = h.x - _, m = h.y - p, u = h.z - E;
132
+ const f = _, a = p, g = E, C = i * s, y = C * C, b = v * v + m * m + u * u;
133
+ if (b > y) {
134
+ const ye = Math.sqrt(b);
135
+ v = v / ye * C, m = m / ye * C, u = u / ye * C;
136
+ }
137
+ _ = h.x - v, p = h.y - m, E = h.z - u;
138
+ const O = (t.x + n * v) * r, x = (t.y + n * m) * r, R = (t.z + n * u) * r;
139
+ t.x = (t.x - n * O) * d, t.y = (t.y - n * x) * d, t.z = (t.z - n * R) * d, o.x = _ + (v + O) * d, o.y = p + (m + x) * d, o.z = E + (u + R) * d;
140
140
  const V = f - h.x, le = a - h.y, wt = g - h.z, xt = o.x - f, Lt = o.y - a, Pt = o.z - g;
141
141
  return V * xt + le * Lt + wt * Pt > 0 && (o.x = f, o.y = a, o.z = g, t.x = (o.x - f) / r, t.y = (o.y - a) / r, t.z = (o.z - g) / r), o;
142
142
  }
@@ -146,7 +146,7 @@ function Ee(h, e) {
146
146
  }), e.x /= h.length, e.y /= h.length;
147
147
  }
148
148
  function Oe(h, e) {
149
- return I(h) ? (console.warn(`${e} is not supported in OrthographicCamera`), !0) : !1;
149
+ return j(h) ? (console.warn(`${e} is not supported in OrthographicCamera`), !0) : !1;
150
150
  }
151
151
  class Ts {
152
152
  constructor() {
@@ -244,17 +244,17 @@ class J extends Ts {
244
244
  */
245
245
  constructor(e, t) {
246
246
  super(), this.minPolarAngle = 0, this.maxPolarAngle = Math.PI, this.minAzimuthAngle = -1 / 0, this.maxAzimuthAngle = 1 / 0, this.minDistance = Number.EPSILON, this.maxDistance = 1 / 0, this.infinityDolly = !1, this.minZoom = 0.01, this.maxZoom = 1 / 0, this.smoothTime = 0.25, this.draggingSmoothTime = 0.125, this.maxSpeed = 1 / 0, this.azimuthRotateSpeed = 1, this.polarRotateSpeed = 1, this.dollySpeed = 1, this.dollyDragInverted = !1, this.truckSpeed = 2, this.dollyToCursor = !1, this.dragToOffset = !1, this.boundaryFriction = 0, this.restThreshold = 0.01, this.colliderMeshes = [], this.cancel = () => {
247
- }, this._enabled = !0, this._state = c.NONE, this._viewport = null, this._changedDolly = 0, this._changedZoom = 0, this._hasRested = !0, this._boundaryEnclosesCamera = !1, this._needsUpdate = !0, this._updatedLastTime = !1, this._elementRect = new DOMRect(), this._isDragging = !1, this._dragNeedsUpdate = !0, this._activePointers = [], this._lockedPointer = null, this._interactiveArea = new DOMRect(0, 0, 1, 1), this._isUserControllingRotate = !1, this._isUserControllingDolly = !1, this._isUserControllingTruck = !1, this._isUserControllingOffset = !1, this._isUserControllingZoom = !1, this._lastDollyDirection = G.NONE, this._thetaVelocity = { value: 0 }, this._phiVelocity = { value: 0 }, this._radiusVelocity = { value: 0 }, this._targetVelocity = new T.Vector3(), this._focalOffsetVelocity = new T.Vector3(), this._zoomVelocity = { value: 0 }, this._truckInternal = (a, g, C, v) => {
247
+ }, this._enabled = !0, this._state = c.NONE, this._viewport = null, this._changedDolly = 0, this._changedZoom = 0, this._hasRested = !0, this._boundaryEnclosesCamera = !1, this._needsUpdate = !0, this._updatedLastTime = !1, this._elementRect = new DOMRect(), this._isDragging = !1, this._dragNeedsUpdate = !0, this._activePointers = [], this._lockedPointer = null, this._interactiveArea = new DOMRect(0, 0, 1, 1), this._isUserControllingRotate = !1, this._isUserControllingDolly = !1, this._isUserControllingTruck = !1, this._isUserControllingOffset = !1, this._isUserControllingZoom = !1, this._lastDollyDirection = G.NONE, this._thetaVelocity = { value: 0 }, this._phiVelocity = { value: 0 }, this._radiusVelocity = { value: 0 }, this._targetVelocity = new T.Vector3(), this._focalOffsetVelocity = new T.Vector3(), this._zoomVelocity = { value: 0 }, this._truckInternal = (a, g, C, y) => {
248
248
  let b, O;
249
249
  if (Y(this._camera)) {
250
250
  const x = w.copy(this._camera.position).sub(this._target), R = this._camera.getEffectiveFOV() * ie, V = x.length() * Math.tan(R * 0.5);
251
251
  b = this.truckSpeed * a * V / this._elementRect.height, O = this.truckSpeed * g * V / this._elementRect.height;
252
- } else if (I(this._camera)) {
252
+ } else if (j(this._camera)) {
253
253
  const x = this._camera;
254
254
  b = this.truckSpeed * a * (x.right - x.left) / x.zoom / this._elementRect.width, O = this.truckSpeed * g * (x.top - x.bottom) / x.zoom / this._elementRect.height;
255
255
  } else
256
256
  return;
257
- v ? (C ? this.setFocalOffset(
257
+ y ? (C ? this.setFocalOffset(
258
258
  this._focalOffsetEnd.x + b,
259
259
  this._focalOffsetEnd.y,
260
260
  this._focalOffsetEnd.z,
@@ -266,17 +266,17 @@ class J extends Ts {
266
266
  !0
267
267
  ) : this.truck(b, O, !0);
268
268
  }, this._rotateInternal = (a, g) => {
269
- const C = K * this.azimuthRotateSpeed * a / this._elementRect.height, v = K * this.polarRotateSpeed * g / this._elementRect.height;
270
- this.rotate(C, v, !0);
269
+ const C = K * this.azimuthRotateSpeed * a / this._elementRect.height, y = K * this.polarRotateSpeed * g / this._elementRect.height;
270
+ this.rotate(C, y, !0);
271
271
  }, this._dollyInternal = (a, g, C) => {
272
- const v = Math.pow(0.95, -a * this.dollySpeed), b = this._sphericalEnd.radius, O = this._sphericalEnd.radius * v, x = k(
272
+ const y = Math.pow(0.95, -a * this.dollySpeed), b = this._sphericalEnd.radius, O = this._sphericalEnd.radius * y, x = k(
273
273
  O,
274
274
  this.minDistance,
275
275
  this.maxDistance
276
276
  ), R = x - O;
277
277
  this.infinityDolly && this.dollyToCursor ? this._dollyToNoClamp(O, !0) : this.infinityDolly && !this.dollyToCursor ? (this.dollyInFixed(R, !0), this._dollyToNoClamp(x, !0)) : this._dollyToNoClamp(x, !0), this.dollyToCursor && (this._changedDolly += (this.infinityDolly ? O : x) - b, this._dollyControlCoord.set(g, C)), this._lastDollyDirection = Math.sign(-a);
278
278
  }, this._zoomInternal = (a, g, C) => {
279
- const v = Math.pow(0.95, a * this.dollySpeed), b = this._zoom, O = this._zoom * v;
279
+ const y = Math.pow(0.95, a * this.dollySpeed), b = this._zoom, O = this._zoom * y;
280
280
  this.zoomTo(O, !0), this.dollyToCursor && (this._changedZoom += O - b, this._dollyControlCoord.set(g, C));
281
281
  }, typeof T == "undefined" && console.error(
282
282
  "camera-controls: `THREE` is undefined. You must first run `CameraControls.install( { THREE: THREE } )`. Check the docs for further information."
@@ -297,23 +297,23 @@ class J extends Ts {
297
297
  left: c.ROTATE,
298
298
  middle: c.DOLLY,
299
299
  right: c.TRUCK,
300
- wheel: Y(this._camera) ? c.DOLLY : I(this._camera) ? c.ZOOM : c.NONE
300
+ wheel: Y(this._camera) ? c.DOLLY : j(this._camera) ? c.ZOOM : c.NONE
301
301
  }, this.touches = {
302
302
  one: c.TOUCH_ROTATE,
303
- two: Y(this._camera) ? c.TOUCH_DOLLY_TRUCK : I(this._camera) ? c.TOUCH_ZOOM_TRUCK : c.NONE,
303
+ two: Y(this._camera) ? c.TOUCH_DOLLY_TRUCK : j(this._camera) ? c.TOUCH_ZOOM_TRUCK : c.NONE,
304
304
  three: c.TOUCH_TRUCK
305
305
  };
306
306
  const s = new T.Vector2(), i = new T.Vector2(), r = new T.Vector2(), o = (a) => {
307
307
  if (!this._enabled || !this._domElement) return;
308
308
  if (this._interactiveArea.left !== 0 || this._interactiveArea.top !== 0 || this._interactiveArea.width !== 1 || this._interactiveArea.height !== 1) {
309
- const v = this._domElement.getBoundingClientRect(), b = (a.clientX - v.left) / (v.right - v.left), O = (a.clientY - v.top) / (v.bottom - v.top);
309
+ const y = this._domElement.getBoundingClientRect(), b = (a.clientX - y.left) / (y.right - y.left), O = (a.clientY - y.top) / (y.bottom - y.top);
310
310
  if (b < this._interactiveArea.left || b > this._interactiveArea.right || O < this._interactiveArea.top || O > this._interactiveArea.bottom)
311
311
  return;
312
312
  }
313
313
  const g = a.pointerType !== "mouse" ? null : (a.buttons & M.LEFT) === M.LEFT ? M.LEFT : (a.buttons & M.MIDDLE) === M.MIDDLE ? M.MIDDLE : (a.buttons & M.RIGHT) === M.RIGHT ? M.RIGHT : null;
314
314
  if (g !== null) {
315
- const v = this._findPointerByMouseButton(g);
316
- v && this._disposePointer(v);
315
+ const y = this._findPointerByMouseButton(g);
316
+ y && this._disposePointer(y);
317
317
  }
318
318
  if ((a.buttons & M.LEFT) === M.LEFT && this._lockedPointer)
319
319
  return;
@@ -355,7 +355,7 @@ class J extends Ts {
355
355
  }
356
356
  else
357
357
  (!this._isDragging && this._lockedPointer || this._isDragging && (a.buttons & M.LEFT) === M.LEFT) && (this._state = this._state | this.mouseButtons.left), this._isDragging && (a.buttons & M.MIDDLE) === M.MIDDLE && (this._state = this._state | this.mouseButtons.middle), this._isDragging && (a.buttons & M.RIGHT) === M.RIGHT && (this._state = this._state | this.mouseButtons.right);
358
- y();
358
+ v();
359
359
  }
360
360
  }, l = (a) => {
361
361
  const g = this._findPointerById(a.pointerId);
@@ -392,7 +392,7 @@ class J extends Ts {
392
392
  const O = performance.now();
393
393
  d - O < 1e3 && this._getClientRect(this._elementRect), d = O;
394
394
  }
395
- const g = bs ? -1 : -3, C = a.deltaMode === 1 || a.ctrlKey ? a.deltaY / g : a.deltaY / (g * 10), v = this.dollyToCursor ? (a.clientX - this._elementRect.x) / this._elementRect.width * 2 - 1 : 0, b = this.dollyToCursor ? (a.clientY - this._elementRect.y) / this._elementRect.height * -2 + 1 : 0;
395
+ const g = bs ? -1 : -3, C = a.deltaMode === 1 || a.ctrlKey ? a.deltaY / g : a.deltaY / (g * 10), y = this.dollyToCursor ? (a.clientX - this._elementRect.x) / this._elementRect.width * 2 - 1 : 0, b = this.dollyToCursor ? (a.clientY - this._elementRect.y) / this._elementRect.height * -2 + 1 : 0;
396
396
  switch (this.mouseButtons.wheel) {
397
397
  case c.ROTATE: {
398
398
  this._rotateInternal(a.deltaX, a.deltaY), this._isUserControllingRotate = !0;
@@ -411,11 +411,11 @@ class J extends Ts {
411
411
  break;
412
412
  }
413
413
  case c.DOLLY: {
414
- this._dollyInternal(-C, v, b), this._isUserControllingDolly = !0;
414
+ this._dollyInternal(-C, y, b), this._isUserControllingDolly = !0;
415
415
  break;
416
416
  }
417
417
  case c.ZOOM: {
418
- this._zoomInternal(-C, v, b), this._isUserControllingZoom = !0;
418
+ this._zoomInternal(-C, y, b), this._isUserControllingZoom = !0;
419
419
  break;
420
420
  }
421
421
  }
@@ -439,7 +439,7 @@ class J extends Ts {
439
439
  }, E = (a) => {
440
440
  if (!this._enabled) return;
441
441
  if (Ee(this._activePointers, D), this._getClientRect(this._elementRect), s.copy(D), i.copy(D), this._activePointers.length >= 2) {
442
- const C = D.x - this._activePointers[1].clientX, v = D.y - this._activePointers[1].clientY, b = Math.sqrt(C * C + v * v);
442
+ const C = D.x - this._activePointers[1].clientX, y = D.y - this._activePointers[1].clientY, b = Math.sqrt(C * C + y * y);
443
443
  r.set(0, b);
444
444
  const O = (this._activePointers[0].clientX + this._activePointers[1].clientX) * 0.5, x = (this._activePointers[0].clientY + this._activePointers[1].clientY) * 0.5;
445
445
  i.set(O, x);
@@ -461,18 +461,18 @@ class J extends Ts {
461
461
  else
462
462
  !this._lockedPointer && (a.buttons & M.LEFT) === M.LEFT && (this._state = this._state | this.mouseButtons.left), (a.buttons & M.MIDDLE) === M.MIDDLE && (this._state = this._state | this.mouseButtons.middle), (a.buttons & M.RIGHT) === M.RIGHT && (this._state = this._state | this.mouseButtons.right);
463
463
  ((this._state & c.ROTATE) === c.ROTATE || (this._state & c.TOUCH_ROTATE) === c.TOUCH_ROTATE || (this._state & c.TOUCH_DOLLY_ROTATE) === c.TOUCH_DOLLY_ROTATE || (this._state & c.TOUCH_ZOOM_ROTATE) === c.TOUCH_ZOOM_ROTATE) && (this._sphericalEnd.theta = this._spherical.theta, this._sphericalEnd.phi = this._spherical.phi, this._thetaVelocity.value = 0, this._phiVelocity.value = 0), ((this._state & c.TRUCK) === c.TRUCK || (this._state & c.SCREEN_PAN) === c.SCREEN_PAN || (this._state & c.TOUCH_TRUCK) === c.TOUCH_TRUCK || (this._state & c.TOUCH_SCREEN_PAN) === c.TOUCH_SCREEN_PAN || (this._state & c.TOUCH_DOLLY_TRUCK) === c.TOUCH_DOLLY_TRUCK || (this._state & c.TOUCH_DOLLY_SCREEN_PAN) === c.TOUCH_DOLLY_SCREEN_PAN || (this._state & c.TOUCH_ZOOM_TRUCK) === c.TOUCH_ZOOM_TRUCK || (this._state & c.TOUCH_ZOOM_SCREEN_PAN) === c.TOUCH_DOLLY_SCREEN_PAN) && (this._targetEnd.copy(this._target), this._targetVelocity.set(0, 0, 0)), ((this._state & c.DOLLY) === c.DOLLY || (this._state & c.TOUCH_DOLLY) === c.TOUCH_DOLLY || (this._state & c.TOUCH_DOLLY_TRUCK) === c.TOUCH_DOLLY_TRUCK || (this._state & c.TOUCH_DOLLY_SCREEN_PAN) === c.TOUCH_DOLLY_SCREEN_PAN || (this._state & c.TOUCH_DOLLY_OFFSET) === c.TOUCH_DOLLY_OFFSET || (this._state & c.TOUCH_DOLLY_ROTATE) === c.TOUCH_DOLLY_ROTATE) && (this._sphericalEnd.radius = this._spherical.radius, this._radiusVelocity.value = 0), ((this._state & c.ZOOM) === c.ZOOM || (this._state & c.TOUCH_ZOOM) === c.TOUCH_ZOOM || (this._state & c.TOUCH_ZOOM_TRUCK) === c.TOUCH_ZOOM_TRUCK || (this._state & c.TOUCH_ZOOM_SCREEN_PAN) === c.TOUCH_ZOOM_SCREEN_PAN || (this._state & c.TOUCH_ZOOM_OFFSET) === c.TOUCH_ZOOM_OFFSET || (this._state & c.TOUCH_ZOOM_ROTATE) === c.TOUCH_ZOOM_ROTATE) && (this._zoomEnd = this._zoom, this._zoomVelocity.value = 0), ((this._state & c.OFFSET) === c.OFFSET || (this._state & c.TOUCH_OFFSET) === c.TOUCH_OFFSET || (this._state & c.TOUCH_DOLLY_OFFSET) === c.TOUCH_DOLLY_OFFSET || (this._state & c.TOUCH_ZOOM_OFFSET) === c.TOUCH_ZOOM_OFFSET) && (this._focalOffsetEnd.copy(this._focalOffset), this._focalOffsetVelocity.set(0, 0, 0)), this.dispatchEvent({ type: "controlstart" });
464
- }, y = () => {
464
+ }, v = () => {
465
465
  if (!this._enabled || !this._dragNeedsUpdate) return;
466
466
  this._dragNeedsUpdate = !1, Ee(this._activePointers, D);
467
- const g = this._domElement && this._domElement.ownerDocument.pointerLockElement === this._domElement ? this._lockedPointer || this._activePointers[0] : null, C = g ? -g.deltaX : i.x - D.x, v = g ? -g.deltaY : i.y - D.y;
468
- if (i.copy(D), ((this._state & c.ROTATE) === c.ROTATE || (this._state & c.TOUCH_ROTATE) === c.TOUCH_ROTATE || (this._state & c.TOUCH_DOLLY_ROTATE) === c.TOUCH_DOLLY_ROTATE || (this._state & c.TOUCH_ZOOM_ROTATE) === c.TOUCH_ZOOM_ROTATE) && (this._rotateInternal(C, v), this._isUserControllingRotate = !0), (this._state & c.DOLLY) === c.DOLLY || (this._state & c.ZOOM) === c.ZOOM) {
467
+ const g = this._domElement && this._domElement.ownerDocument.pointerLockElement === this._domElement ? this._lockedPointer || this._activePointers[0] : null, C = g ? -g.deltaX : i.x - D.x, y = g ? -g.deltaY : i.y - D.y;
468
+ if (i.copy(D), ((this._state & c.ROTATE) === c.ROTATE || (this._state & c.TOUCH_ROTATE) === c.TOUCH_ROTATE || (this._state & c.TOUCH_DOLLY_ROTATE) === c.TOUCH_DOLLY_ROTATE || (this._state & c.TOUCH_ZOOM_ROTATE) === c.TOUCH_ZOOM_ROTATE) && (this._rotateInternal(C, y), this._isUserControllingRotate = !0), (this._state & c.DOLLY) === c.DOLLY || (this._state & c.ZOOM) === c.ZOOM) {
469
469
  const b = this.dollyToCursor ? (s.x - this._elementRect.x) / this._elementRect.width * 2 - 1 : 0, O = this.dollyToCursor ? (s.y - this._elementRect.y) / this._elementRect.height * -2 + 1 : 0, x = this.dollyDragInverted ? -1 : 1;
470
470
  (this._state & c.DOLLY) === c.DOLLY ? (this._dollyInternal(
471
- x * v * ce,
471
+ x * y * ce,
472
472
  b,
473
473
  O
474
474
  ), this._isUserControllingDolly = !0) : (this._zoomInternal(
475
- x * v * ce,
475
+ x * y * ce,
476
476
  b,
477
477
  O
478
478
  ), this._isUserControllingZoom = !0);
@@ -483,7 +483,7 @@ class J extends Ts {
483
483
  const V = this.dollyToCursor ? (i.x - this._elementRect.x) / this._elementRect.width * 2 - 1 : 0, le = this.dollyToCursor ? (i.y - this._elementRect.y) / this._elementRect.height * -2 + 1 : 0;
484
484
  (this._state & c.TOUCH_DOLLY) === c.TOUCH_DOLLY || (this._state & c.TOUCH_DOLLY_ROTATE) === c.TOUCH_DOLLY_ROTATE || (this._state & c.TOUCH_DOLLY_TRUCK) === c.TOUCH_DOLLY_TRUCK || (this._state & c.TOUCH_DOLLY_SCREEN_PAN) === c.TOUCH_DOLLY_SCREEN_PAN || (this._state & c.TOUCH_DOLLY_OFFSET) === c.TOUCH_DOLLY_OFFSET ? (this._dollyInternal(R * ce, V, le), this._isUserControllingDolly = !0) : (this._zoomInternal(R * ce, V, le), this._isUserControllingZoom = !0);
485
485
  }
486
- ((this._state & c.TRUCK) === c.TRUCK || (this._state & c.TOUCH_TRUCK) === c.TOUCH_TRUCK || (this._state & c.TOUCH_DOLLY_TRUCK) === c.TOUCH_DOLLY_TRUCK || (this._state & c.TOUCH_ZOOM_TRUCK) === c.TOUCH_ZOOM_TRUCK) && (this._truckInternal(C, v, !1, !1), this._isUserControllingTruck = !0), ((this._state & c.SCREEN_PAN) === c.SCREEN_PAN || (this._state & c.TOUCH_SCREEN_PAN) === c.TOUCH_SCREEN_PAN || (this._state & c.TOUCH_DOLLY_SCREEN_PAN) === c.TOUCH_DOLLY_SCREEN_PAN || (this._state & c.TOUCH_ZOOM_SCREEN_PAN) === c.TOUCH_ZOOM_SCREEN_PAN) && (this._truckInternal(C, v, !1, !0), this._isUserControllingTruck = !0), ((this._state & c.OFFSET) === c.OFFSET || (this._state & c.TOUCH_OFFSET) === c.TOUCH_OFFSET || (this._state & c.TOUCH_DOLLY_OFFSET) === c.TOUCH_DOLLY_OFFSET || (this._state & c.TOUCH_ZOOM_OFFSET) === c.TOUCH_ZOOM_OFFSET) && (this._truckInternal(C, v, !0, !1), this._isUserControllingOffset = !0), this.dispatchEvent({ type: "control" });
486
+ ((this._state & c.TRUCK) === c.TRUCK || (this._state & c.TOUCH_TRUCK) === c.TOUCH_TRUCK || (this._state & c.TOUCH_DOLLY_TRUCK) === c.TOUCH_DOLLY_TRUCK || (this._state & c.TOUCH_ZOOM_TRUCK) === c.TOUCH_ZOOM_TRUCK) && (this._truckInternal(C, y, !1, !1), this._isUserControllingTruck = !0), ((this._state & c.SCREEN_PAN) === c.SCREEN_PAN || (this._state & c.TOUCH_SCREEN_PAN) === c.TOUCH_SCREEN_PAN || (this._state & c.TOUCH_DOLLY_SCREEN_PAN) === c.TOUCH_DOLLY_SCREEN_PAN || (this._state & c.TOUCH_ZOOM_SCREEN_PAN) === c.TOUCH_ZOOM_SCREEN_PAN) && (this._truckInternal(C, y, !1, !0), this._isUserControllingTruck = !0), ((this._state & c.OFFSET) === c.OFFSET || (this._state & c.TOUCH_OFFSET) === c.TOUCH_OFFSET || (this._state & c.TOUCH_DOLLY_OFFSET) === c.TOUCH_DOLLY_OFFSET || (this._state & c.TOUCH_ZOOM_OFFSET) === c.TOUCH_ZOOM_OFFSET) && (this._truckInternal(C, y, !0, !1), this._isUserControllingOffset = !0), this.dispatchEvent({ type: "control" });
487
487
  }, m = () => {
488
488
  Ee(this._activePointers, D), i.copy(D), this._dragNeedsUpdate = !1, (this._activePointers.length === 0 || this._activePointers.length === 1 && this._activePointers[0] === this._lockedPointer) && (this._isDragging = !1), this._activePointers.length === 0 && this._domElement && (this._domElement.ownerDocument.removeEventListener(
489
489
  "pointermove",
@@ -986,13 +986,13 @@ class J extends Ts {
986
986
  d.isEmpty() && (console.warn(
987
987
  "camera-controls: fitTo() cannot be used with an empty box. Aborting"
988
988
  ), Promise.resolve());
989
- const _ = Ie(this._sphericalEnd.theta, je), p = Ie(this._sphericalEnd.phi, je);
989
+ const _ = je(this._sphericalEnd.theta, Ie), p = je(this._sphericalEnd.phi, Ie);
990
990
  l.push(this.rotateTo(_, p, t));
991
- const E = w.setFromSpherical(this._sphericalEnd).normalize(), y = Ge.setFromUnitVectors(E, Te), m = P(Math.abs(E.y), 1);
992
- m && y.multiply(we.setFromAxisAngle(de, _)), y.multiply(this._yAxisUpSpaceInverse);
991
+ const E = w.setFromSpherical(this._sphericalEnd).normalize(), v = Ge.setFromUnitVectors(E, Te), m = P(Math.abs(E.y), 1);
992
+ m && v.multiply(we.setFromAxisAngle(de, _)), v.multiply(this._yAxisUpSpaceInverse);
993
993
  const u = We.makeEmpty();
994
- L.copy(d.min).applyQuaternion(y), u.expandByPoint(L), L.copy(d.min).setX(d.max.x).applyQuaternion(y), u.expandByPoint(L), L.copy(d.min).setY(d.max.y).applyQuaternion(y), u.expandByPoint(L), L.copy(d.max).setZ(d.min.z).applyQuaternion(y), u.expandByPoint(L), L.copy(d.min).setZ(d.max.z).applyQuaternion(y), u.expandByPoint(L), L.copy(d.max).setY(d.min.y).applyQuaternion(y), u.expandByPoint(L), L.copy(d.max).setX(d.min.x).applyQuaternion(y), u.expandByPoint(L), L.copy(d.max).applyQuaternion(y), u.expandByPoint(L), u.min.x -= i, u.min.y -= o, u.max.x += r, u.max.y += n, y.setFromUnitVectors(Te, E), m && y.premultiply(we.invert()), y.premultiply(this._yAxisUpSpace);
995
- const f = u.getSize(w), a = u.getCenter(L).applyQuaternion(y);
994
+ L.copy(d.min).applyQuaternion(v), u.expandByPoint(L), L.copy(d.min).setX(d.max.x).applyQuaternion(v), u.expandByPoint(L), L.copy(d.min).setY(d.max.y).applyQuaternion(v), u.expandByPoint(L), L.copy(d.max).setZ(d.min.z).applyQuaternion(v), u.expandByPoint(L), L.copy(d.min).setZ(d.max.z).applyQuaternion(v), u.expandByPoint(L), L.copy(d.max).setY(d.min.y).applyQuaternion(v), u.expandByPoint(L), L.copy(d.max).setX(d.min.x).applyQuaternion(v), u.expandByPoint(L), L.copy(d.max).applyQuaternion(v), u.expandByPoint(L), u.min.x -= i, u.min.y -= o, u.max.x += r, u.max.y += n, v.setFromUnitVectors(Te, E), m && v.premultiply(we.invert()), v.premultiply(this._yAxisUpSpace);
995
+ const f = u.getSize(w), a = u.getCenter(L).applyQuaternion(v);
996
996
  if (Y(this._camera)) {
997
997
  const g = this.getDistanceToFitBox(
998
998
  f.x,
@@ -1003,8 +1003,8 @@ class J extends Ts {
1003
1003
  l.push(
1004
1004
  this.moveTo(a.x, a.y, a.z, t)
1005
1005
  ), l.push(this.dollyTo(g, t)), l.push(this.setFocalOffset(0, 0, 0, t));
1006
- } else if (I(this._camera)) {
1007
- const g = this._camera, C = g.right - g.left, v = g.top - g.bottom, b = s ? Math.max(C / f.x, v / f.y) : Math.min(C / f.x, v / f.y);
1006
+ } else if (j(this._camera)) {
1007
+ const g = this._camera, C = g.right - g.left, y = g.top - g.bottom, b = s ? Math.max(C / f.x, y / f.y) : Math.min(C / f.x, y / f.y);
1008
1008
  l.push(
1009
1009
  this.moveTo(a.x, a.y, a.z, t)
1010
1010
  ), l.push(this.zoomTo(b, t)), l.push(this.setFocalOffset(0, 0, 0, t));
@@ -1029,7 +1029,7 @@ class J extends Ts {
1029
1029
  ), Y(this._camera)) {
1030
1030
  const o = this.getDistanceToFitSphere(r.radius);
1031
1031
  s.push(this.dollyTo(o, t));
1032
- } else if (I(this._camera)) {
1032
+ } else if (j(this._camera)) {
1033
1033
  const o = this._camera.right - this._camera.left, n = this._camera.top - this._camera.bottom, l = 2 * r.radius, d = Math.min(o / l, n / l);
1034
1034
  s.push(this.zoomTo(d, t));
1035
1035
  }
@@ -1085,7 +1085,7 @@ class J extends Ts {
1085
1085
  * @param enableTransition
1086
1086
  * @category Methods
1087
1087
  */
1088
- lerpLookAt(e, t, s, i, r, o, n, l, d, _, p, E, y, m = !1) {
1088
+ lerpLookAt(e, t, s, i, r, o, n, l, d, _, p, E, v, m = !1) {
1089
1089
  this._isUserControllingRotate = !1, this._isUserControllingDolly = !1, this._isUserControllingTruck = !1, this._lastDollyDirection = G.NONE, this._changedDolly = 0;
1090
1090
  const u = w.set(i, r, o), f = L.set(e, t, s);
1091
1091
  z.setFromVector3(
@@ -1094,12 +1094,12 @@ class J extends Ts {
1094
1094
  const a = X.set(_, p, E), g = L.set(n, l, d);
1095
1095
  ae.setFromVector3(
1096
1096
  g.sub(a).applyQuaternion(this._yAxisUpSpace)
1097
- ), this._targetEnd.copy(u.lerp(a, y));
1098
- const C = ae.theta - z.theta, v = ae.phi - z.phi, b = ae.radius - z.radius;
1097
+ ), this._targetEnd.copy(u.lerp(a, v));
1098
+ const C = ae.theta - z.theta, y = ae.phi - z.phi, b = ae.radius - z.radius;
1099
1099
  this._sphericalEnd.set(
1100
- z.radius + b * y,
1101
- z.phi + v * y,
1102
- z.theta + C * y
1100
+ z.radius + b * v,
1101
+ z.phi + y * v,
1102
+ z.theta + C * v
1103
1103
  ), this.normalizeRotations(), this._needsUpdate = !0, m || (this._target.copy(this._targetEnd), this._spherical.copy(this._sphericalEnd));
1104
1104
  const O = !m || P(this._target.x, this._targetEnd.x, this.restThreshold) && P(this._target.y, this._targetEnd.y, this.restThreshold) && P(this._target.z, this._targetEnd.z, this.restThreshold) && P(
1105
1105
  this._spherical.theta,
@@ -1455,34 +1455,34 @@ class J extends Ts {
1455
1455
  }
1456
1456
  if (this.dollyToCursor) {
1457
1457
  if (Y(this._camera) && this._changedDolly !== 0) {
1458
- const p = this._spherical.radius - this._lastDistance, E = this._camera, y = this._getCameraDirection(ne), m = w.copy(y).cross(E.up).normalize();
1458
+ const p = this._spherical.radius - this._lastDistance, E = this._camera, v = this._getCameraDirection(ne), m = w.copy(v).cross(E.up).normalize();
1459
1459
  m.lengthSq() === 0 && (m.x = 1);
1460
- const u = L.crossVectors(m, y), f = this._sphericalEnd.radius * Math.tan(E.getEffectiveFOV() * ie * 0.5), g = (this._sphericalEnd.radius - p - this._sphericalEnd.radius) / this._sphericalEnd.radius, C = X.copy(this._targetEnd).add(
1460
+ const u = L.crossVectors(m, v), f = this._sphericalEnd.radius * Math.tan(E.getEffectiveFOV() * ie * 0.5), g = (this._sphericalEnd.radius - p - this._sphericalEnd.radius) / this._sphericalEnd.radius, C = X.copy(this._targetEnd).add(
1461
1461
  m.multiplyScalar(
1462
1462
  this._dollyControlCoord.x * f * E.aspect
1463
1463
  )
1464
1464
  ).add(
1465
1465
  u.multiplyScalar(this._dollyControlCoord.y * f)
1466
- ), v = w.copy(this._targetEnd).lerp(C, g), b = this._lastDollyDirection === G.IN && this._spherical.radius <= this.minDistance, O = this._lastDollyDirection === G.OUT && this.maxDistance <= this._spherical.radius;
1466
+ ), y = w.copy(this._targetEnd).lerp(C, g), b = this._lastDollyDirection === G.IN && this._spherical.radius <= this.minDistance, O = this._lastDollyDirection === G.OUT && this.maxDistance <= this._spherical.radius;
1467
1467
  if (this.infinityDolly && (b || O)) {
1468
1468
  this._sphericalEnd.radius -= p, this._spherical.radius -= p;
1469
- const R = L.copy(y).multiplyScalar(-p);
1470
- v.add(R);
1469
+ const R = L.copy(v).multiplyScalar(-p);
1470
+ y.add(R);
1471
1471
  }
1472
- this._boundary.clampPoint(v, v);
1473
- const x = L.subVectors(v, this._targetEnd);
1474
- this._targetEnd.copy(v), this._target.add(x), this._changedDolly -= p, A(this._changedDolly) && (this._changedDolly = 0);
1475
- } else if (I(this._camera) && this._changedZoom !== 0) {
1476
- const p = this._zoom - this._lastZoom, E = this._camera, y = w.set(
1472
+ this._boundary.clampPoint(y, y);
1473
+ const x = L.subVectors(y, this._targetEnd);
1474
+ this._targetEnd.copy(y), this._target.add(x), this._changedDolly -= p, A(this._changedDolly) && (this._changedDolly = 0);
1475
+ } else if (j(this._camera) && this._changedZoom !== 0) {
1476
+ const p = this._zoom - this._lastZoom, E = this._camera, v = w.set(
1477
1477
  this._dollyControlCoord.x,
1478
1478
  this._dollyControlCoord.y,
1479
1479
  (E.near + E.far) / (E.near - E.far)
1480
- ).unproject(E), m = L.set(0, 0, -1).applyQuaternion(E.quaternion), u = X.copy(y).add(m.multiplyScalar(-y.dot(E.up))), a = -(this._zoom - p - this._zoom) / this._zoom, g = this._getCameraDirection(ne), C = this._targetEnd.dot(g), v = w.copy(this._targetEnd).lerp(u, a), b = v.dot(g), O = g.multiplyScalar(
1480
+ ).unproject(E), m = L.set(0, 0, -1).applyQuaternion(E.quaternion), u = X.copy(v).add(m.multiplyScalar(-v.dot(E.up))), a = -(this._zoom - p - this._zoom) / this._zoom, g = this._getCameraDirection(ne), C = this._targetEnd.dot(g), y = w.copy(this._targetEnd).lerp(u, a), b = y.dot(g), O = g.multiplyScalar(
1481
1481
  b - C
1482
1482
  );
1483
- v.sub(O), this._boundary.clampPoint(v, v);
1484
- const x = L.subVectors(v, this._targetEnd);
1485
- this._targetEnd.copy(v), this._target.add(x), this._changedZoom -= p, A(this._changedZoom) && (this._changedZoom = 0);
1483
+ y.sub(O), this._boundary.clampPoint(y, y);
1484
+ const x = L.subVectors(y, this._targetEnd);
1485
+ this._targetEnd.copy(y), this._target.add(x), this._changedZoom -= p, A(this._changedZoom) && (this._changedZoom = 0);
1486
1486
  }
1487
1487
  }
1488
1488
  this._camera.zoom !== this._zoom && (this._camera.zoom = this._zoom, this._camera.updateProjectionMatrix(), this._updateNearPlaneCorners(), this._needsUpdate = !0), this._dragNeedsUpdate = !0;
@@ -1607,7 +1607,7 @@ class J extends Ts {
1607
1607
  if (Y(this._camera)) {
1608
1608
  const e = this._camera, t = e.near, s = e.getEffectiveFOV() * ie, i = Math.tan(s * 0.5) * t, r = i * e.aspect;
1609
1609
  this._nearPlaneCorners[0].set(-r, -i, 0), this._nearPlaneCorners[1].set(r, -i, 0), this._nearPlaneCorners[2].set(r, i, 0), this._nearPlaneCorners[3].set(-r, i, 0);
1610
- } else if (I(this._camera)) {
1610
+ } else if (j(this._camera)) {
1611
1611
  const e = this._camera, t = 1 / e.zoom, s = e.left * t, i = e.right * t, r = e.top * t, o = e.bottom * t;
1612
1612
  this._nearPlaneCorners[0].set(s, r, 0), this._nearPlaneCorners[1].set(i, r, 0), this._nearPlaneCorners[2].set(i, o, 0), this._nearPlaneCorners[3].set(s, o, 0);
1613
1613
  }
@@ -1785,7 +1785,7 @@ S.prototype.emit = function(e) {
1785
1785
  Ke(_[s], this, t);
1786
1786
  return !0;
1787
1787
  };
1788
- function yt(h, e, t, s) {
1788
+ function vt(h, e, t, s) {
1789
1789
  var i, r, o;
1790
1790
  if (ge(t), r = h._events, r === void 0 ? (r = h._events = /* @__PURE__ */ Object.create(null), h._eventsCount = 0) : (r.newListener !== void 0 && (h.emit(
1791
1791
  "newListener",
@@ -1801,25 +1801,25 @@ function yt(h, e, t, s) {
1801
1801
  return h;
1802
1802
  }
1803
1803
  S.prototype.addListener = function(e, t) {
1804
- return yt(this, e, t, !1);
1804
+ return vt(this, e, t, !1);
1805
1805
  };
1806
1806
  S.prototype.on = S.prototype.addListener;
1807
1807
  S.prototype.prependListener = function(e, t) {
1808
- return yt(this, e, t, !0);
1808
+ return vt(this, e, t, !0);
1809
1809
  };
1810
1810
  function xs() {
1811
1811
  if (!this.fired)
1812
1812
  return this.target.removeListener(this.type, this.wrapFn), this.fired = !0, arguments.length === 0 ? this.listener.call(this.target) : this.listener.apply(this.target, arguments);
1813
1813
  }
1814
- function vt(h, e, t) {
1814
+ function yt(h, e, t) {
1815
1815
  var s = { fired: !1, wrapFn: void 0, target: h, type: e, listener: t }, i = xs.bind(s);
1816
1816
  return i.listener = t, s.wrapFn = i, i;
1817
1817
  }
1818
1818
  S.prototype.once = function(e, t) {
1819
- return ge(t), this.on(e, vt(this, e, t)), this;
1819
+ return ge(t), this.on(e, yt(this, e, t)), this;
1820
1820
  };
1821
1821
  S.prototype.prependOnceListener = function(e, t) {
1822
- return ge(t), this.prependListener(e, vt(this, e, t)), this;
1822
+ return ge(t), this.prependListener(e, yt(this, e, t)), this;
1823
1823
  };
1824
1824
  S.prototype.removeListener = function(e, t) {
1825
1825
  var s, i, r, o, n;
@@ -1931,7 +1931,7 @@ function Tt(h, e, t, s) {
1931
1931
  else
1932
1932
  throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type ' + typeof h);
1933
1933
  }
1934
- var ye = Ae.exports;
1934
+ var ve = Ae.exports;
1935
1935
  const Ms = {
1936
1936
  antialias: !1,
1937
1937
  devicePixelRatio: window.devicePixelRatio,
@@ -1956,7 +1956,7 @@ class Rs {
1956
1956
  outputColorSpace: _,
1957
1957
  logarithmicDepthBuffer: p,
1958
1958
  preserveDrawingBuffer: E,
1959
- stencil: y,
1959
+ stencil: v,
1960
1960
  depth: m
1961
1961
  } = i, u = new Ut({
1962
1962
  alpha: r,
@@ -1964,7 +1964,7 @@ class Rs {
1964
1964
  powerPreference: l,
1965
1965
  logarithmicDepthBuffer: p,
1966
1966
  preserveDrawingBuffer: E,
1967
- stencil: y,
1967
+ stencil: v,
1968
1968
  depth: m
1969
1969
  });
1970
1970
  u.setSize(t, s), u.setPixelRatio(o), u.toneMappingExposure = d, u.outputColorSpace = _, this.renderer = u;
@@ -2048,7 +2048,7 @@ let zs = class {
2048
2048
  };
2049
2049
  class ee {
2050
2050
  constructor() {
2051
- this.event = new ye.EventEmitter(), this.controllerMap = /* @__PURE__ */ new Map(), this.activeIndex = -1, this.activeControllerSet = /* @__PURE__ */ new Set();
2051
+ this.event = new ve.EventEmitter(), this.controllerMap = /* @__PURE__ */ new Map(), this.activeIndex = -1, this.activeControllerSet = /* @__PURE__ */ new Set();
2052
2052
  }
2053
2053
  addController(e, t) {
2054
2054
  const s = new zs();
@@ -2083,7 +2083,7 @@ const bt = {
2083
2083
  fov: 45,
2084
2084
  near: 1,
2085
2085
  far: 1e3,
2086
- up: new j(0, 1, 0)
2086
+ up: new I(0, 1, 0)
2087
2087
  };
2088
2088
  class ks extends ee {
2089
2089
  constructor(e) {
@@ -2210,7 +2210,7 @@ class Hs {
2210
2210
  else if (e.isSpotLight)
2211
2211
  i = new Ht(e);
2212
2212
  else if (e.isHemisphereLight)
2213
- i = new jt(e, 10);
2213
+ i = new It(e, 10);
2214
2214
  else if (e.isRectAreaLight)
2215
2215
  i = new ds(e);
2216
2216
  else {
@@ -2276,12 +2276,12 @@ class Hs {
2276
2276
  this.helpers = {}, (e = this.viewHelper) == null || e.dispose();
2277
2277
  }
2278
2278
  }
2279
- class js extends ee {
2279
+ class Is extends ee {
2280
2280
  constructor(e) {
2281
2281
  super(), this.autoRotateSpeed = 0, this.options = e;
2282
2282
  const t = {
2283
2283
  Vector2: B,
2284
- Vector3: j,
2284
+ Vector3: I,
2285
2285
  Vector4: Bt,
2286
2286
  Quaternion: lt,
2287
2287
  Matrix4: W,
@@ -2320,12 +2320,12 @@ class js extends ee {
2320
2320
  });
2321
2321
  }
2322
2322
  update(e, t) {
2323
- super.update(e, t), this.autoRotateSpeed && this.cameraControls && (this.cameraControls.azimuthAngle += this.autoRotateSpeed * e * It.DEG2RAD);
2323
+ super.update(e, t), this.autoRotateSpeed && this.cameraControls && (this.cameraControls.azimuthAngle += this.autoRotateSpeed * e * jt.DEG2RAD);
2324
2324
  }
2325
2325
  }
2326
- class Is {
2326
+ class js {
2327
2327
  constructor(e) {
2328
- this.event = new ye.EventEmitter();
2328
+ this.event = new ve.EventEmitter();
2329
2329
  const { renderer: t, scene: s, camera: i } = e, r = new ms(
2330
2330
  i,
2331
2331
  t.domElement
@@ -2392,7 +2392,7 @@ class Is {
2392
2392
  this.event.removeAllListeners(), (e = this.controls) == null || e.dispose();
2393
2393
  }
2394
2394
  }
2395
- const $e = new j(), Bs = new lt(), qe = new j(), H = new W(), Vs = new W();
2395
+ const $e = new I(), Bs = new lt(), qe = new I(), H = new W(), Vs = new W();
2396
2396
  class Ys {
2397
2397
  /**
2398
2398
  * Constructs a new CSS3D renderer.
@@ -2418,9 +2418,9 @@ class Ys {
2418
2418
  }, this.render = function(f, a) {
2419
2419
  const g = a.projectionMatrix.elements[5] * o;
2420
2420
  a.view && a.view.enabled ? (d.style.transform = `translate( ${-a.view.offsetX * (s / a.view.width)}px, ${-a.view.offsetY * (i / a.view.height)}px )`, d.style.transform += `scale( ${a.view.fullWidth / a.view.width}, ${a.view.fullHeight / a.view.height} )`) : d.style.transform = "", f.matrixWorldAutoUpdate === !0 && f.updateMatrixWorld(), a.parent === null && a.matrixWorldAutoUpdate === !0 && a.updateMatrixWorld();
2421
- let C, v;
2422
- a.isOrthographicCamera && (C = -(a.right + a.left) / 2, v = (a.top + a.bottom) / 2);
2423
- const b = a.view && a.view.enabled ? a.view.height / a.view.fullHeight : 1, O = a.isOrthographicCamera ? `scale( ${b} )scale(` + g + ")translate(" + p(C) + "px," + p(v) + "px)" + E(a.matrixWorldInverse) : `scale( ${b} )translateZ(` + g + "px)" + E(a.matrixWorldInverse), R = (a.isPerspectiveCamera ? "perspective(" + g + "px) " : "") + O + "translate(" + r + "px," + o + "px)";
2421
+ let C, y;
2422
+ a.isOrthographicCamera && (C = -(a.right + a.left) / 2, y = (a.top + a.bottom) / 2);
2423
+ const b = a.view && a.view.enabled ? a.view.height / a.view.fullHeight : 1, O = a.isOrthographicCamera ? `scale( ${b} )scale(` + g + ")translate(" + p(C) + "px," + p(y) + "px)" + E(a.matrixWorldInverse) : `scale( ${b} )translateZ(` + g + "px)" + E(a.matrixWorldInverse), R = (a.isPerspectiveCamera ? "perspective(" + g + "px) " : "") + O + "translate(" + r + "px," + o + "px)";
2424
2424
  n.camera.style !== R && (_.style.transform = R, n.camera.style = R), u(f, f, a);
2425
2425
  }, this.setSize = function(f, a) {
2426
2426
  s = f, i = a, r = s / 2, o = i / 2, l.style.width = f + "px", l.style.height = a + "px", d.style.width = f + "px", d.style.height = a + "px", _.style.width = f + "px", _.style.height = a + "px";
@@ -2432,7 +2432,7 @@ class Ys {
2432
2432
  const a = f.elements;
2433
2433
  return "matrix3d(" + p(a[0]) + "," + p(-a[1]) + "," + p(a[2]) + "," + p(a[3]) + "," + p(a[4]) + "," + p(-a[5]) + "," + p(a[6]) + "," + p(a[7]) + "," + p(a[8]) + "," + p(-a[9]) + "," + p(a[10]) + "," + p(a[11]) + "," + p(a[12]) + "," + p(-a[13]) + "," + p(a[14]) + "," + p(a[15]) + ")";
2434
2434
  }
2435
- function y(f) {
2435
+ function v(f) {
2436
2436
  const a = f.elements;
2437
2437
  return "translate(-50%,-50%)" + ("matrix3d(" + p(a[0]) + "," + p(a[1]) + "," + p(a[2]) + "," + p(a[3]) + "," + p(-a[4]) + "," + p(-a[5]) + "," + p(-a[6]) + "," + p(-a[7]) + "," + p(a[8]) + "," + p(a[9]) + "," + p(a[10]) + "," + p(a[11]) + "," + p(a[12]) + "," + p(a[13]) + "," + p(a[14]) + "," + p(a[15]) + ")");
2438
2438
  }
@@ -2447,11 +2447,11 @@ class Ys {
2447
2447
  return;
2448
2448
  }
2449
2449
  if (f.isCSS3DObject) {
2450
- const v = f.layers.test(g.layers) === !0, b = f.element;
2451
- if (b.style.display = v === !0 ? "" : "none", v === !0) {
2450
+ const y = f.layers.test(g.layers) === !0, b = f.element;
2451
+ if (b.style.display = y === !0 ? "" : "none", y === !0) {
2452
2452
  f.onBeforeRender(t, a, g);
2453
2453
  let O;
2454
- f.isCSS3DSprite ? (H.copy(g.matrixWorldInverse), H.transpose(), f.rotation2D !== 0 && H.multiply(Vs.makeRotationZ(f.rotation2D)), f.matrixWorld.decompose($e, Bs, qe), H.setPosition($e), H.scale(qe), H.elements[3] = 0, H.elements[7] = 0, H.elements[11] = 0, H.elements[15] = 1, O = y(H)) : O = y(f.matrixWorld);
2454
+ f.isCSS3DSprite ? (H.copy(g.matrixWorldInverse), H.transpose(), f.rotation2D !== 0 && H.multiply(Vs.makeRotationZ(f.rotation2D)), f.matrixWorld.decompose($e, Bs, qe), H.setPosition($e), H.scale(qe), H.elements[3] = 0, H.elements[7] = 0, H.elements[11] = 0, H.elements[15] = 1, O = v(H)) : O = v(f.matrixWorld);
2455
2455
  const x = n.objects.get(f);
2456
2456
  if (x === void 0 || x.style !== O) {
2457
2457
  b.style.transform = O;
@@ -2461,12 +2461,12 @@ class Ys {
2461
2461
  b.parentNode !== _ && _.appendChild(b), f.onAfterRender(t, a, g);
2462
2462
  }
2463
2463
  }
2464
- for (let v = 0, b = f.children.length; v < b; v++)
2465
- u(f.children[v], a, g);
2464
+ for (let y = 0, b = f.children.length; y < b; y++)
2465
+ u(f.children[y], a, g);
2466
2466
  }
2467
2467
  }
2468
2468
  }
2469
- const q = new j(), Qe = new W(), Je = new W(), et = new j(), tt = new j();
2469
+ const q = new I(), Qe = new W(), Je = new W(), et = new I(), tt = new I();
2470
2470
  class Zs {
2471
2471
  /**
2472
2472
  * Constructs a new CSS2D renderer.
@@ -2485,7 +2485,7 @@ class Zs {
2485
2485
  height: i
2486
2486
  };
2487
2487
  }, this.render = function(m, u) {
2488
- m.matrixWorldAutoUpdate === !0 && m.updateMatrixWorld(), u.parent === null && u.matrixWorldAutoUpdate === !0 && u.updateMatrixWorld(), Qe.copy(u.matrixWorldInverse), Je.multiplyMatrices(u.projectionMatrix, Qe), _(m, m, u), y(m);
2488
+ m.matrixWorldAutoUpdate === !0 && m.updateMatrixWorld(), u.parent === null && u.matrixWorldAutoUpdate === !0 && u.updateMatrixWorld(), Qe.copy(u.matrixWorldInverse), Je.multiplyMatrices(u.projectionMatrix, Qe), _(m, m, u), v(m);
2489
2489
  }, this.setSize = function(m, u) {
2490
2490
  s = m, i = u, r = s / 2, o = i / 2, l.style.width = m + "px", l.style.height = u + "px";
2491
2491
  };
@@ -2520,12 +2520,12 @@ class Zs {
2520
2520
  f.isCSS2DObject && u.push(f);
2521
2521
  }), u;
2522
2522
  }
2523
- function y(m) {
2523
+ function v(m) {
2524
2524
  const u = E(m).sort(function(a, g) {
2525
2525
  if (a.renderOrder !== g.renderOrder)
2526
2526
  return g.renderOrder - a.renderOrder;
2527
- const C = n.objects.get(a).distanceToCameraSquared, v = n.objects.get(g).distanceToCameraSquared;
2528
- return C - v;
2527
+ const C = n.objects.get(a).distanceToCameraSquared, y = n.objects.get(g).distanceToCameraSquared;
2528
+ return C - y;
2529
2529
  }), f = u.length;
2530
2530
  for (let a = 0, g = u.length; a < g; a++)
2531
2531
  u[a].element.style.zIndex = f - a;
@@ -2729,7 +2729,7 @@ const Xs = (h) => {
2729
2729
  };
2730
2730
  class oi {
2731
2731
  constructor(e) {
2732
- this.bloomComposerActive = !1, this.active = !0, this.bloomSelection = /* @__PURE__ */ new Set(), this.bloomLayer = new qt(), this.bloomMaterials = {}, this.bloomVisible = {}, this.pipViewportState = null, this.options = e;
2732
+ this.bloomComposerActive = !1, this.active = !0, this.bloomSelection = /* @__PURE__ */ new Set(), this.bloomLayer = new qt(), this.bloomMaterials = {}, this.bloomVisible = {}, this.bloomComposerRenderIng = !1, this.pipViewportState = null, this.options = e;
2733
2733
  const {
2734
2734
  rendererController: t,
2735
2735
  sceneController: s,
@@ -2746,11 +2746,11 @@ class oi {
2746
2746
  }
2747
2747
  ), p = new ke(o, _), E = this.getSize();
2748
2748
  p.setSize(E.width, E.height);
2749
- const y = new us(
2749
+ const v = new us(
2750
2750
  s.scene,
2751
2751
  i.camera
2752
2752
  );
2753
- p.addPass(y), this.scene = s.scene, this.camera = i.camera, this.finalComposer = p, this.renderPass = y, i.event.on("pageChange", (m) => {
2753
+ p.addPass(v), this.scene = s.scene, this.camera = i.camera, this.finalComposer = p, this.renderPass = v, i.event.on("pageChange", (m) => {
2754
2754
  this.changeCamera(m);
2755
2755
  }), s.event.on("pageChange", (m) => {
2756
2756
  this.changeScene(m);
@@ -2774,7 +2774,7 @@ class oi {
2774
2774
  l.kernelRadius = e.kernelRadius, l.minDistance = e.minDistance, l.maxDistance = e.maxDistance, this.ssaoPass = l, this.finalComposer.addPass(l);
2775
2775
  }
2776
2776
  addBloomPass(e) {
2777
- const { renderer: t } = this, { threshold: s, strength: i, radius: r, bloomAlphaType: o } = e, n = new ys(
2777
+ const { renderer: t } = this, { threshold: s, strength: i, radius: r, bloomAlphaType: o } = e, n = new vs(
2778
2778
  new B(window.innerWidth, window.innerHeight),
2779
2779
  i,
2780
2780
  r,
@@ -2831,7 +2831,7 @@ class oi {
2831
2831
  });
2832
2832
  }
2833
2833
  finalComposerRender() {
2834
- this.bloomComposerActive && this.bloomComposer ? (this.mixPass.enabled = !0, this.darkenNonBloomed(), this.bloomComposer.render(), this.restoreNonBloomed()) : this.mixPass && (this.mixPass.enabled = !1), this.finalComposer.render();
2834
+ this.bloomComposerActive && this.bloomComposer ? (this.bloomComposerRenderIng = !0, this.mixPass.enabled = !0, this.darkenNonBloomed(), this.bloomComposer.render(), this.restoreNonBloomed(), this.bloomComposerRenderIng = !1) : this.mixPass && (this.mixPass.enabled = !1), this.finalComposer.render();
2835
2835
  }
2836
2836
  getSize() {
2837
2837
  return this.renderer.getSize(new B());
@@ -2880,13 +2880,13 @@ class it extends pt {
2880
2880
  const _ = e.split(".").pop(), p = this.options.type === "image" ? `image/${_ || "png"}` : `video/${_ || "mp4"}`;
2881
2881
  d = d.slice(0, l.size, p);
2882
2882
  const E = () => {
2883
- o.removeEventListener("load", y, !1), o.removeEventListener("error", m, !1);
2884
- }, y = () => {
2883
+ o.removeEventListener("load", v, !1), o.removeEventListener("error", m, !1);
2884
+ }, v = () => {
2885
2885
  E(), r.needsUpdate = !0, t && t(r);
2886
2886
  }, m = (f) => {
2887
2887
  E(), i && i(f), this.manager.itemError(e), this.manager.itemEnd(e);
2888
2888
  };
2889
- o.addEventListener("load", y, !1), o.addEventListener("error", m, !1);
2889
+ o.addEventListener("load", v, !1), o.addEventListener("error", m, !1);
2890
2890
  const u = window.URL.createObjectURL(d);
2891
2891
  o.src = u;
2892
2892
  },
@@ -2927,7 +2927,7 @@ const ai = {
2927
2927
  };
2928
2928
  class li {
2929
2929
  constructor(e) {
2930
- this.loadObj = [], this.delLoadArr = [], this.assets = /* @__PURE__ */ new Map(), this.event = new ye.EventEmitter(), this.options = U({
2930
+ this.loadObj = [], this.delLoadArr = [], this.assets = /* @__PURE__ */ new Map(), this.event = new ve.EventEmitter(), this.options = U({
2931
2931
  simpleTexture4deleted: !1,
2932
2932
  prefix: ""
2933
2933
  }, e), this.loadingManager = new es(
@@ -2978,7 +2978,7 @@ class li {
2978
2978
  if (e === "media")
2979
2979
  return this.videoTextureLoader || (this.videoTextureLoader = new it(this.loadingManager), this.videoTextureLoader.setOptions({ type: "video" }), this.options.prefix && this.videoTextureLoader.setPath(this.options.prefix)), this.videoTextureLoader;
2980
2980
  if (e === "gltf" && (t != null && t.dracoPath))
2981
- return this.dracoGltfLoader || (this.dracoGltfLoader = new Ne(this.loadingManager), this.dracoLoader = new vs(), this.dracoLoader.setDecoderPath(t == null ? void 0 : t.dracoPath), this.dracoGltfLoader.setDRACOLoader(this.dracoLoader), this.options.prefix && this.dracoGltfLoader.setPath(this.options.prefix)), this.dracoGltfLoader;
2981
+ return this.dracoGltfLoader || (this.dracoGltfLoader = new Ne(this.loadingManager), this.dracoLoader = new ys(), this.dracoLoader.setDecoderPath(t == null ? void 0 : t.dracoPath), this.dracoGltfLoader.setDRACOLoader(this.dracoLoader), this.options.prefix && this.dracoGltfLoader.setPath(this.options.prefix)), this.dracoGltfLoader;
2982
2982
  if (e === "gltf")
2983
2983
  return this.gltfLoader || (this.gltfLoader = new Ne(this.loadingManager), this.options.prefix && this.gltfLoader.setPath(this.options.prefix)), this.gltfLoader;
2984
2984
  if (e === "lottie")
@@ -3127,7 +3127,7 @@ class pi {
3127
3127
  }
3128
3128
  addPickListener(e) {
3129
3129
  const t = /* @__PURE__ */ new Set(["move", "enter", "leave"]), s = /* @__PURE__ */ new Set(["down", "downOutside", "click"]), i = (r) => {
3130
- var y;
3130
+ var v;
3131
3131
  if (!this.enabled)
3132
3132
  return;
3133
3133
  r.preventDefault();
@@ -3153,7 +3153,7 @@ class pi {
3153
3153
  u instanceof ss && _.push(u);
3154
3154
  });
3155
3155
  });
3156
- const p = (y = this.pencil.pick(r, _, !1)) == null ? void 0 : y.intersects;
3156
+ const p = (v = this.pencil.pick(r, _, !1)) == null ? void 0 : v.intersects;
3157
3157
  if (!p || p.length === 0)
3158
3158
  e === "down" ? this.handleDownOutside(r) : e === "move" && this.handleLeaveEvents(r);
3159
3159
  else {
@@ -3225,8 +3225,8 @@ class pi {
3225
3225
  if (_) {
3226
3226
  const p = (E) => {
3227
3227
  E.preventDefault();
3228
- const y = 5;
3229
- if (!r && Math.abs(E.clientX - e.clientX) <= y && Math.abs(E.clientY - e.clientY) <= y)
3228
+ const v = 5;
3229
+ if (!r && Math.abs(E.clientX - e.clientX) <= v && Math.abs(E.clientY - e.clientY) <= v)
3230
3230
  for (const m of _)
3231
3231
  m({
3232
3232
  baseObject: n,
@@ -3347,19 +3347,19 @@ class mi extends pi {
3347
3347
  const i = this.objectNamesToFactories.get(e);
3348
3348
  if (i) {
3349
3349
  t || (t = {}), t.target === void 0 && (t.target = s);
3350
- const d = t.target, _ = (r = t.onTop) != null ? r : 0, p = (o = t.prefab) != null ? o : !1, E = (n = t.create) != null ? n : !0, y = new i().create(t);
3350
+ const d = t.target, _ = (r = t.onTop) != null ? r : 0, p = (o = t.prefab) != null ? o : !1, E = (n = t.create) != null ? n : !0, v = new i().create(t);
3351
3351
  let m;
3352
- return d === null ? m = null : typeof d == "string" ? m = this.objects.get(d) : (l = d == null ? void 0 : d.objectType) != null && l.startsWith("BaseObject") || d ? m = d : p ? m = this.prefabGroup : m = this.group, E === !1 ? y.create = () => {
3353
- } : E !== !0 && (y.create = () => {
3354
- E(y);
3355
- }), y.pencil = this.pencil, y.lead = this, y.mList = this.mList, y.prefab = p, y.objectType = `BaseObject#${e}`, y.objectOptions = t, this.setBaseObjectKey(
3356
- y,
3352
+ return d === null ? m = null : typeof d == "string" ? m = this.objects.get(d) : (l = d == null ? void 0 : d.objectType) != null && l.startsWith("BaseObject") || d ? m = d : p ? m = this.prefabGroup : m = this.group, E === !1 ? v.create = () => {
3353
+ } : E !== !0 && (v.create = () => {
3354
+ E(v);
3355
+ }), v.pencil = this.pencil, v.lead = this, v.mList = this.mList, v.prefab = p, v.objectType = `BaseObject#${e}`, v.objectOptions = t, this.setBaseObjectKey(
3356
+ v,
3357
3357
  t.key ? `$t:#${t.key}` : "$t:",
3358
3358
  m == null ? void 0 : m.key
3359
3359
  ), this.objectsPm.set(
3360
- y.key,
3361
- this.addBaseObject(y, m, _)
3362
- ), yield this.objectsPm.get(y.key), this.objectsPm.delete(y.key), y;
3360
+ v.key,
3361
+ this.addBaseObject(v, m, _)
3362
+ ), yield this.objectsPm.get(v.key), this.objectsPm.delete(v.key), v;
3363
3363
  }
3364
3364
  throw new Error(`Unrecognized:${e}`);
3365
3365
  });
@@ -3381,16 +3381,12 @@ class mi extends pi {
3381
3381
  s = n;
3382
3382
  break;
3383
3383
  }
3384
- const i = (o = e.parent) == null ? void 0 : o.key;
3385
- if (!s)
3386
- return this.setBaseObjectKey(e, t, i);
3387
- this.objects.delete(s);
3388
- const r = this.setBaseObjectKey(e, t, i);
3389
- return this.pencil.event.emit("updateKey", e, r, s), r;
3384
+ const i = (o = e.parent) == null ? void 0 : o.key, r = this.setBaseObjectKey(e, t, i);
3385
+ return s && this.objects.delete(s), this.pencil.event.emit("updateKey", e, r, s), r;
3390
3386
  }
3391
3387
  addBaseObject(e, t, s) {
3392
3388
  return se(this, null, function* () {
3393
- yield e.create(), e.object3d && (this.mList.proxyBaseObject(e), this.mList.addByBaseObject(e), s && e.setTop(s), t !== null && (t.add(e.object3d), this.objMap.set(e.object3d, e))), e.render(), this.pencil.event.emit("draw", e);
3389
+ yield e.create(), e.object3d && (this.mList.proxyBaseObject(e), this.mList.addBaseObjectMap(e), s && e.setTop(s), t !== null && (t.add(e.object3d), this.objMap.set(e.object3d, e))), e.render(), this.pencil.event.emit("draw", e);
3394
3390
  });
3395
3391
  }
3396
3392
  erase(...e) {
@@ -3461,12 +3457,8 @@ class fi {
3461
3457
  constructor(e) {
3462
3458
  this.materials = /* @__PURE__ */ new Map(), this.materialBaseObjectMap = /* @__PURE__ */ new Map(), this.fixBufferGeometry = new is(), this.pencil = e;
3463
3459
  }
3464
- add(e, t, s) {
3465
- if (this.getKey(t) || this.materials.set(e, t), s) {
3466
- const i = this.materialBaseObjectMap.get(t);
3467
- i && !i.includes(s) ? i.push(s) : this.materialBaseObjectMap.set(t, [s]);
3468
- }
3469
- this.emitObject3dChange();
3460
+ add(e, t) {
3461
+ this.materials.set(e, t), this.emitObject3dChange();
3470
3462
  }
3471
3463
  get(e) {
3472
3464
  const t = this.materials.get(e);
@@ -3510,7 +3502,7 @@ class fi {
3510
3502
  }
3511
3503
  remove(e) {
3512
3504
  const t = this.materials.get(e);
3513
- t && (this.materialBaseObjectMap.delete(t), this.disposeMaterial(t)), this.materials.delete(e), this.emitObject3dChange();
3505
+ t && this.disposeMaterial(t), this.materials.delete(e), this.emitObject3dChange();
3514
3506
  }
3515
3507
  removeByMaterial(e) {
3516
3508
  [...this.materials.entries()].some(([t, s]) => s === e ? (this.remove(t), !0) : !1);
@@ -3522,46 +3514,52 @@ class fi {
3522
3514
  const l = Number(o);
3523
3515
  if (l >= 0 && l < r.length) {
3524
3516
  const d = r[l];
3525
- return this.rmBaseObjectMap(e, d), r[l] = n, this.addByBaseObject(e), !0;
3517
+ return this.rmBaseObjectMap(e, d), r[l] = n, this.addBaseObjectMap(e), !0;
3526
3518
  }
3527
3519
  }
3528
3520
  return Reflect.set(r, o, n);
3529
3521
  }
3530
3522
  });
3531
3523
  e.object3d = new Proxy(t, {
3532
- set: (i, r, o) => r === "material" ? (this.rmBaseObjectMap(e), Array.isArray(o) ? i.material = s(o) : i.material = o, this.addByBaseObject(e), !0) : Reflect.set(i, r, o),
3524
+ set: (i, r, o) => {
3525
+ var n;
3526
+ return r === "material" && !((n = this.pencil.composerController) != null && n.bloomComposerRenderIng) ? (this.rmBaseObjectMap(e), i.material = o, this.addBaseObjectMap(e), !0) : Reflect.set(i, r, o);
3527
+ },
3533
3528
  get: (i, r) => {
3534
- if (r === "material") {
3535
- const o = i.material;
3536
- if (Array.isArray(o) && !o.hasOwnProperty("__isProxy")) {
3537
- const n = s(o);
3538
- Object.defineProperty(n, "__isProxy", {
3529
+ var o;
3530
+ if (r === "material" && !((o = this.pencil.composerController) != null && o.bloomComposerRenderIng)) {
3531
+ const n = i.material;
3532
+ if (Array.isArray(n) && !n.hasOwnProperty("__isProxy")) {
3533
+ const l = s(n);
3534
+ Object.defineProperty(l, "__isProxy", {
3539
3535
  value: !0,
3540
3536
  enumerable: !1
3541
- }), i.material = n;
3537
+ }), i.material = l;
3542
3538
  }
3543
3539
  }
3544
3540
  return Reflect.get(i, r);
3545
3541
  }
3546
3542
  });
3547
3543
  }
3548
- addByBaseObject(e) {
3544
+ addBaseObjectMap(e) {
3549
3545
  const t = e.object3d;
3550
3546
  t.material && (Array.isArray(t.material) ? t.material : [t.material]).forEach((i) => {
3551
- this.add(i.uuid, i, e);
3547
+ const r = this.materialBaseObjectMap.get(i);
3548
+ r ? r.add(e) : this.materialBaseObjectMap.set(i, /* @__PURE__ */ new Set([e]));
3552
3549
  });
3553
3550
  }
3554
3551
  rmBaseObjectMap(e, t) {
3555
3552
  this.materialBaseObjectMap.forEach((s, i) => {
3556
- if (t && i !== t)
3557
- return;
3558
- const r = s.indexOf(e);
3559
- r !== -1 && (s.splice(r, 1), s.length === 0 && (this.materialBaseObjectMap.delete(i), this.disposeMaterial(i)));
3553
+ t && i !== t || s.has(e) && (s.delete(e), s.size === 0 && (this.materialBaseObjectMap.delete(i), this.disposeMaterial(i)));
3560
3554
  });
3561
3555
  }
3562
- getBaseObjectByMaterial(e) {
3563
- const t = this.materialBaseObjectMap.get(e);
3564
- return t || null;
3556
+ getBaseObjectMaterials() {
3557
+ const e = {};
3558
+ return this.materialBaseObjectMap.forEach((t, s) => {
3559
+ t.forEach((i) => {
3560
+ e[i.key] = s;
3561
+ });
3562
+ }), e;
3565
3563
  }
3566
3564
  emitObject3dChange() {
3567
3565
  var e;
@@ -3592,7 +3590,7 @@ class _i extends ee {
3592
3590
  const _e = class _e {
3593
3591
  constructor(e) {
3594
3592
  var r, o;
3595
- this.raycaster = new ht(), this.maxBackufferArea = 5760 * 5760, this.installPlugins = /* @__PURE__ */ new Map(), this._cameraPositon = new j(), this._cameraTarget = new j(), this.event = new ye.EventEmitter(), this.timer = new rs(), this.userData = {}, this.pageActiveIndex = 0, this.pageCountIndex = 0, this.userSetDprCache = 1, this.event.setMaxListeners(1 / 0), (o = (r = this.timer).connect) == null || o.call(r, document), this.options = os(_e.options, e, {
3593
+ this.raycaster = new ht(), this.maxBackufferArea = 5760 * 5760, this.installPlugins = /* @__PURE__ */ new Map(), this._cameraPositon = new I(), this._cameraTarget = new I(), this.event = new ve.EventEmitter(), this.timer = new rs(), this.userData = {}, this.pageActiveIndex = 0, this.pageCountIndex = 0, this.userSetDprCache = 1, this.event.setMaxListeners(1 / 0), (o = (r = this.timer).connect) == null || o.call(r, document), this.options = os(_e.options, e, {
3596
3594
  isMergeableObject: hs
3597
3595
  }), this.userSetDprCache = this.options.renderer.devicePixelRatio;
3598
3596
  const {
@@ -3692,7 +3690,7 @@ const _e = class _e {
3692
3690
  }), p = new ks({
3693
3691
  width: l,
3694
3692
  height: d
3695
- }), E = new Ns({}), y = new js({
3693
+ }), E = new Ns({}), v = new Is({
3696
3694
  controlsParams: {
3697
3695
  domElement: (g = o == null ? void 0 : o.domElement) != null ? g : _.renderer.domElement
3698
3696
  }
@@ -3705,7 +3703,7 @@ const _e = class _e {
3705
3703
  }), f = new ui({
3706
3704
  pencil: this
3707
3705
  });
3708
- this.sceneController = E, this.cameraController = p, this.controlsController = y, this.rendererController = _, this.loaderController = m, this.mListController = u, this.leadController = f;
3706
+ this.sceneController = E, this.cameraController = p, this.controlsController = v, this.rendererController = _, this.loaderController = m, this.mListController = u, this.leadController = f;
3709
3707
  const a = this.addPage({
3710
3708
  sceneOptions: this.options.scene,
3711
3709
  cameraOptions: this.options.camera
@@ -3749,7 +3747,7 @@ const _e = class _e {
3749
3747
  }
3750
3748
  }
3751
3749
  initTransformControls() {
3752
- const e = new Is({
3750
+ const e = new js({
3753
3751
  camera: this.camera,
3754
3752
  renderer: this.renderer,
3755
3753
  scene: this.scene
@@ -3876,11 +3874,11 @@ const _e = class _e {
3876
3874
  }
3877
3875
  }
3878
3876
  dispose() {
3879
- var e, t, s, i, r, o, n, l, d, _, p, E, y, m;
3877
+ var e, t, s, i, r, o, n, l, d, _, p, E, v, m;
3880
3878
  this.stop(), this.timer.dispose(), Ce.removeAll(), this.event.removeAllListeners(), (e = this.resizeObserver) == null || e.unobserve(this.options.container), this.installPlugins.forEach((u) => {
3881
3879
  var f;
3882
3880
  (f = u.dispose) == null || f.call(u);
3883
- }), (t = this.controlsController) == null || t.dispose(), (s = this.transformController) == null || s.dispose(), (i = this.cssRendererController) == null || i.dispose(), (r = this.sceneController) == null || r.dispose(), (o = this.cameraController) == null || o.dispose(), (n = this.helperController) == null || n.dispose(), (l = this.composerController) == null || l.dispose(), (d = this.rendererController) == null || d.dispose(), (_ = this.loaderController) == null || _.dispose(), (p = this.leadController) == null || p.dispose(), (E = this.mListController) == null || E.dispose(), this.cssRendererController = void 0, this.installPlugins.clear(), (y = this.stats) == null || y.dom.remove(), (m = this.renderer) == null || m.domElement.remove();
3881
+ }), (t = this.controlsController) == null || t.dispose(), (s = this.transformController) == null || s.dispose(), (i = this.cssRendererController) == null || i.dispose(), (r = this.sceneController) == null || r.dispose(), (o = this.cameraController) == null || o.dispose(), (n = this.helperController) == null || n.dispose(), (l = this.composerController) == null || l.dispose(), (d = this.rendererController) == null || d.dispose(), (_ = this.loaderController) == null || _.dispose(), (p = this.leadController) == null || p.dispose(), (E = this.mListController) == null || E.dispose(), this.cssRendererController = void 0, this.installPlugins.clear(), (v = this.stats) == null || v.dom.remove(), (m = this.renderer) == null || m.domElement.remove();
3884
3882
  }
3885
3883
  };
3886
3884
  _e.options = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gl-draw",
3
- "version": "0.15.0-beta.1",
3
+ "version": "0.15.0-beta.3",
4
4
  "author": "gitplus <hstits@gmail.com>",
5
5
  "scripts": {
6
6
  "start": "bundler-dev",