gl-draw 0.15.0-beta.3 → 0.15.0-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core/MList/MList.d.ts +2 -1
- package/dist/index.js +1 -1
- package/dist/index.module.js +188 -176
- package/package.json +1 -1
|
@@ -3,9 +3,10 @@ import { IBaseObject } from "../BaseObject";
|
|
|
3
3
|
import Pencil from "../Pencil";
|
|
4
4
|
export default class MaterialList {
|
|
5
5
|
pencil: Pencil;
|
|
6
|
+
private fixBufferGeometry;
|
|
6
7
|
private materials;
|
|
8
|
+
private fixBaseObjects;
|
|
7
9
|
private materialBaseObjectMap;
|
|
8
|
-
private fixBufferGeometry;
|
|
9
10
|
constructor(pencil: Pencil);
|
|
10
11
|
add(key: string, material: Material): void;
|
|
11
12
|
get(key: string): Material | undefined;
|
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.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;
|
|
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.fixBufferGeometry=new v.BufferGeometry,this.materials=new Map,this.fixBaseObjects=new Map,this.materialBaseObjectMap=new Map,this.pencil=e}add(e,t){this.materials.set(e,t);const s={key:e,userData:{},children:[],object3d:new Proxy(new v.Mesh(this.fixBufferGeometry,t),{set:(i,r,o)=>{var n;return r==="material"&&!((n=this.pencil.composerController)!=null&&n.bloomComposerRenderIng)?(i.material=o,this.materials.set(e,o),!0):Reflect.set(i,r,o)}})};this.fixBaseObjects.set(e,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.disposeMaterial(t),this.materials.delete(e),this.fixBaseObjects.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.materials.clear(),this.fixBaseObjects.clear(),this.materialBaseObjectMap.clear(),this.fixBufferGeometry.dispose()}}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;
|
package/dist/index.module.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
1
|
+
var At = Object.defineProperty, Mt = Object.defineProperties;
|
|
2
|
+
var Rt = Object.getOwnPropertyDescriptors;
|
|
3
3
|
var Me = Object.getOwnPropertySymbols;
|
|
4
|
-
var
|
|
5
|
-
var Re = (h, e, t) => e in h ?
|
|
4
|
+
var Dt = Object.prototype.hasOwnProperty, Ut = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var Re = (h, e, t) => e in h ? At(h, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : h[e] = t, U = (h, e) => {
|
|
6
6
|
for (var t in e || (e = {}))
|
|
7
|
-
|
|
7
|
+
Dt.call(e, t) && Re(h, t, e[t]);
|
|
8
8
|
if (Me)
|
|
9
9
|
for (var t of Me(e))
|
|
10
|
-
|
|
10
|
+
Ut.call(e, t) && Re(h, t, e[t]);
|
|
11
11
|
return h;
|
|
12
|
-
}, te = (h, e) =>
|
|
12
|
+
}, te = (h, e) => Mt(h, Rt(e));
|
|
13
13
|
var se = (h, e, t) => new Promise((s, i) => {
|
|
14
14
|
var r = (l) => {
|
|
15
15
|
try {
|
|
@@ -26,13 +26,13 @@ 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
|
|
29
|
+
import { WebGLRenderer as zt, Vector2 as B, Vector3 as I, PerspectiveCamera as kt, Matrix4 as W, Scene as nt, AxesHelper as De, CameraHelper as Ft, PointLightHelper as Nt, DirectionalLightHelper as jt, SpotLightHelper as It, HemisphereLightHelper as Ht, Box3 as at, Box3Helper as Ue, MathUtils as Bt, Vector4 as Vt, Quaternion as lt, Spherical as Yt, Sphere as Zt, Raycaster as ht, REVISION as Wt, Object3D as Gt, UniformsUtils as Kt, RawShaderMaterial as Xt, ShaderMaterial as $t, MeshBasicMaterial as qt, PointsMaterial as ct, SpriteMaterial as dt, Layers as Qt, WebGLRenderTarget as Jt, HalfFloatType as es, Loader as pt, Texture as fe, VideoTexture as mt, FileLoader as Se, LoadingManager as ts, DataTexture as ss, Mesh as ut, 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";
|
|
33
33
|
import ns from "stats-gl";
|
|
34
34
|
import { C as as, c as ls, i as hs } from "./isPlainObject.module.js";
|
|
35
|
-
import { R as Pe, M as
|
|
35
|
+
import { R as Pe, M as ft, B as cs, G as ze } from "./index.module2.js";
|
|
36
36
|
import { RectAreaLightHelper as ds } from "three/examples/jsm/helpers/RectAreaLightHelper";
|
|
37
37
|
import { ViewHelper as ps } from "three/examples/jsm/helpers/ViewHelper";
|
|
38
38
|
import { TransformControls as ms } from "three/examples/jsm/controls/TransformControls";
|
|
@@ -56,8 +56,8 @@ import "three-bvh-csg";
|
|
|
56
56
|
import { GLTFLoader as Ne } from "three/examples/jsm/loaders/GLTFLoader";
|
|
57
57
|
import { DRACOLoader as ys } from "three/examples/jsm/loaders/DRACOLoader";
|
|
58
58
|
import { EXRLoader as Cs } from "three/examples/jsm/loaders/EXRLoader";
|
|
59
|
-
import { LottieLoader as
|
|
60
|
-
import { makePromiseCreator as
|
|
59
|
+
import { LottieLoader as Os } from "three/examples/jsm/loaders/LottieLoader";
|
|
60
|
+
import { makePromiseCreator as Es, generateUUID as je } from "esus-lite";
|
|
61
61
|
const M = {
|
|
62
62
|
LEFT: 1,
|
|
63
63
|
RIGHT: 2,
|
|
@@ -92,20 +92,20 @@ const M = {
|
|
|
92
92
|
function Y(h) {
|
|
93
93
|
return h.isPerspectiveCamera;
|
|
94
94
|
}
|
|
95
|
-
function
|
|
95
|
+
function H(h) {
|
|
96
96
|
return h.isOrthographicCamera;
|
|
97
97
|
}
|
|
98
|
-
const K = Math.PI * 2, Ie = Math.PI / 2,
|
|
98
|
+
const K = Math.PI * 2, Ie = Math.PI / 2, _t = 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
|
}
|
|
102
|
-
function A(h, e =
|
|
102
|
+
function A(h, e = _t) {
|
|
103
103
|
return Math.abs(h) < e;
|
|
104
104
|
}
|
|
105
|
-
function P(h, e, t =
|
|
105
|
+
function P(h, e, t = _t) {
|
|
106
106
|
return A(h - e, t);
|
|
107
107
|
}
|
|
108
|
-
function
|
|
108
|
+
function He(h, e) {
|
|
109
109
|
return Math.round(h / e) * e;
|
|
110
110
|
}
|
|
111
111
|
function re(h) {
|
|
@@ -120,33 +120,33 @@ function he(h, e, t, s, i = 1 / 0, r) {
|
|
|
120
120
|
let d = h - e;
|
|
121
121
|
const _ = e, p = i * s;
|
|
122
122
|
d = k(d, -p, p), e = h - d;
|
|
123
|
-
const
|
|
124
|
-
t.value = (t.value - o *
|
|
125
|
-
let v = e + (d +
|
|
123
|
+
const O = (t.value + o * d) * r;
|
|
124
|
+
t.value = (t.value - o * O) * l;
|
|
125
|
+
let v = e + (d + O) * l;
|
|
126
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,
|
|
132
|
-
const f = _, a = p, g =
|
|
131
|
+
let _ = e.x, p = e.y, O = e.z, v = h.x - _, m = h.y - p, u = h.z - O;
|
|
132
|
+
const f = _, a = p, g = O, C = i * s, y = C * C, b = v * v + m * m + u * u;
|
|
133
133
|
if (b > y) {
|
|
134
134
|
const ye = Math.sqrt(b);
|
|
135
135
|
v = v / ye * C, m = m / ye * C, u = u / ye * C;
|
|
136
136
|
}
|
|
137
|
-
_ = h.x - v, p = h.y - m,
|
|
138
|
-
const
|
|
139
|
-
t.x = (t.x - n *
|
|
140
|
-
const V = f - h.x, le = a - h.y,
|
|
141
|
-
return V *
|
|
137
|
+
_ = h.x - v, p = h.y - m, O = h.z - u;
|
|
138
|
+
const E = (t.x + n * v) * r, x = (t.y + n * m) * r, R = (t.z + n * u) * r;
|
|
139
|
+
t.x = (t.x - n * E) * d, t.y = (t.y - n * x) * d, t.z = (t.z - n * R) * d, o.x = _ + (v + E) * d, o.y = p + (m + x) * d, o.z = O + (u + R) * d;
|
|
140
|
+
const V = f - h.x, le = a - h.y, xt = g - h.z, Lt = o.x - f, Pt = o.y - a, St = o.z - g;
|
|
141
|
+
return V * Lt + le * Pt + xt * St > 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
|
}
|
|
143
|
-
function
|
|
143
|
+
function Oe(h, e) {
|
|
144
144
|
e.set(0, 0), h.forEach((t) => {
|
|
145
145
|
e.x += t.clientX, e.y += t.clientY;
|
|
146
146
|
}), e.x /= h.length, e.y /= h.length;
|
|
147
147
|
}
|
|
148
|
-
function
|
|
149
|
-
return
|
|
148
|
+
function Ee(h, e) {
|
|
149
|
+
return H(h) ? (console.warn(`${e} is not supported in OrthographicCamera`), !0) : !1;
|
|
150
150
|
}
|
|
151
151
|
class Ts {
|
|
152
152
|
constructor() {
|
|
@@ -245,13 +245,13 @@ class J extends Ts {
|
|
|
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
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
|
-
let b,
|
|
248
|
+
let b, E;
|
|
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
|
-
b = this.truckSpeed * a * V / this._elementRect.height,
|
|
252
|
-
} else if (
|
|
251
|
+
b = this.truckSpeed * a * V / this._elementRect.height, E = this.truckSpeed * g * V / this._elementRect.height;
|
|
252
|
+
} else if (H(this._camera)) {
|
|
253
253
|
const x = this._camera;
|
|
254
|
-
b = this.truckSpeed * a * (x.right - x.left) / x.zoom / this._elementRect.width,
|
|
254
|
+
b = this.truckSpeed * a * (x.right - x.left) / x.zoom / this._elementRect.width, E = this.truckSpeed * g * (x.top - x.bottom) / x.zoom / this._elementRect.height;
|
|
255
255
|
} else
|
|
256
256
|
return;
|
|
257
257
|
y ? (C ? this.setFocalOffset(
|
|
@@ -259,25 +259,25 @@ class J extends Ts {
|
|
|
259
259
|
this._focalOffsetEnd.y,
|
|
260
260
|
this._focalOffsetEnd.z,
|
|
261
261
|
!0
|
|
262
|
-
) : this.truck(b, 0, !0), this.forward(-
|
|
262
|
+
) : this.truck(b, 0, !0), this.forward(-E, !0)) : C ? this.setFocalOffset(
|
|
263
263
|
this._focalOffsetEnd.x + b,
|
|
264
|
-
this._focalOffsetEnd.y +
|
|
264
|
+
this._focalOffsetEnd.y + E,
|
|
265
265
|
this._focalOffsetEnd.z,
|
|
266
266
|
!0
|
|
267
|
-
) : this.truck(b,
|
|
267
|
+
) : this.truck(b, E, !0);
|
|
268
268
|
}, this._rotateInternal = (a, g) => {
|
|
269
269
|
const C = K * this.azimuthRotateSpeed * a / this._elementRect.height, y = K * this.polarRotateSpeed * g / this._elementRect.height;
|
|
270
270
|
this.rotate(C, y, !0);
|
|
271
271
|
}, this._dollyInternal = (a, g, C) => {
|
|
272
|
-
const y = Math.pow(0.95, -a * this.dollySpeed), b = this._sphericalEnd.radius,
|
|
273
|
-
|
|
272
|
+
const y = Math.pow(0.95, -a * this.dollySpeed), b = this._sphericalEnd.radius, E = this._sphericalEnd.radius * y, x = k(
|
|
273
|
+
E,
|
|
274
274
|
this.minDistance,
|
|
275
275
|
this.maxDistance
|
|
276
|
-
), R = x -
|
|
277
|
-
this.infinityDolly && this.dollyToCursor ? this._dollyToNoClamp(
|
|
276
|
+
), R = x - E;
|
|
277
|
+
this.infinityDolly && this.dollyToCursor ? this._dollyToNoClamp(E, !0) : this.infinityDolly && !this.dollyToCursor ? (this.dollyInFixed(R, !0), this._dollyToNoClamp(x, !0)) : this._dollyToNoClamp(x, !0), this.dollyToCursor && (this._changedDolly += (this.infinityDolly ? E : x) - b, this._dollyControlCoord.set(g, C)), this._lastDollyDirection = Math.sign(-a);
|
|
278
278
|
}, this._zoomInternal = (a, g, C) => {
|
|
279
|
-
const y = Math.pow(0.95, a * this.dollySpeed), b = this._zoom,
|
|
280
|
-
this.zoomTo(
|
|
279
|
+
const y = Math.pow(0.95, a * this.dollySpeed), b = this._zoom, E = this._zoom * y;
|
|
280
|
+
this.zoomTo(E, !0), this.dollyToCursor && (this._changedZoom += E - 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."
|
|
283
283
|
), this._camera = e, this._yAxisUpSpace = new T.Quaternion().setFromUnitVectors(
|
|
@@ -297,17 +297,17 @@ 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 :
|
|
300
|
+
wheel: Y(this._camera) ? c.DOLLY : H(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 :
|
|
303
|
+
two: Y(this._camera) ? c.TOUCH_DOLLY_TRUCK : H(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 y = this._domElement.getBoundingClientRect(), b = (a.clientX - y.left) / (y.right - y.left),
|
|
310
|
-
if (b < this._interactiveArea.left || b > this._interactiveArea.right ||
|
|
309
|
+
const y = this._domElement.getBoundingClientRect(), b = (a.clientX - y.left) / (y.right - y.left), E = (a.clientY - y.top) / (y.bottom - y.top);
|
|
310
|
+
if (b < this._interactiveArea.left || b > this._interactiveArea.right || E < this._interactiveArea.top || E > 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;
|
|
@@ -336,7 +336,7 @@ class J extends Ts {
|
|
|
336
336
|
"pointermove",
|
|
337
337
|
n,
|
|
338
338
|
{ passive: !1 }
|
|
339
|
-
), this._domElement.ownerDocument.addEventListener("pointerup", l), this._isDragging = !0,
|
|
339
|
+
), this._domElement.ownerDocument.addEventListener("pointerup", l), this._isDragging = !0, O(a);
|
|
340
340
|
}, n = (a) => {
|
|
341
341
|
a.cancelable && a.preventDefault();
|
|
342
342
|
const g = a.pointerId, C = this._lockedPointer || this._findPointerById(g);
|
|
@@ -384,13 +384,13 @@ class J extends Ts {
|
|
|
384
384
|
const _ = (a) => {
|
|
385
385
|
if (!this._domElement || !this._enabled || this.mouseButtons.wheel === c.NONE) return;
|
|
386
386
|
if (this._interactiveArea.left !== 0 || this._interactiveArea.top !== 0 || this._interactiveArea.width !== 1 || this._interactiveArea.height !== 1) {
|
|
387
|
-
const
|
|
387
|
+
const E = this._domElement.getBoundingClientRect(), x = (a.clientX - E.left) / (E.right - E.left), R = (a.clientY - E.top) / (E.bottom - E.top);
|
|
388
388
|
if (x < this._interactiveArea.left || x > this._interactiveArea.right || R < this._interactiveArea.top || R > this._interactiveArea.bottom)
|
|
389
389
|
return;
|
|
390
390
|
}
|
|
391
391
|
if (a.preventDefault(), this.dollyToCursor || this.mouseButtons.wheel === c.ROTATE || this.mouseButtons.wheel === c.TRUCK) {
|
|
392
|
-
const
|
|
393
|
-
d -
|
|
392
|
+
const E = performance.now();
|
|
393
|
+
d - E < 1e3 && this._getClientRect(this._elementRect), d = E;
|
|
394
394
|
}
|
|
395
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) {
|
|
@@ -436,13 +436,13 @@ class J extends Ts {
|
|
|
436
436
|
}
|
|
437
437
|
a.preventDefault();
|
|
438
438
|
}
|
|
439
|
-
},
|
|
439
|
+
}, O = (a) => {
|
|
440
440
|
if (!this._enabled) return;
|
|
441
|
-
if (
|
|
441
|
+
if (Oe(this._activePointers, D), this._getClientRect(this._elementRect), s.copy(D), i.copy(D), this._activePointers.length >= 2) {
|
|
442
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
|
-
const
|
|
445
|
-
i.set(
|
|
444
|
+
const E = (this._activePointers[0].clientX + this._activePointers[1].clientX) * 0.5, x = (this._activePointers[0].clientY + this._activePointers[1].clientY) * 0.5;
|
|
445
|
+
i.set(E, x);
|
|
446
446
|
}
|
|
447
447
|
if (this._state = 0, !a)
|
|
448
448
|
this._lockedPointer && (this._state = this._state | this.mouseButtons.left);
|
|
@@ -463,29 +463,29 @@ class J extends Ts {
|
|
|
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
464
|
}, v = () => {
|
|
465
465
|
if (!this._enabled || !this._dragNeedsUpdate) return;
|
|
466
|
-
this._dragNeedsUpdate = !1,
|
|
466
|
+
this._dragNeedsUpdate = !1, Oe(this._activePointers, D);
|
|
467
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
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
|
-
const b = this.dollyToCursor ? (s.x - this._elementRect.x) / this._elementRect.width * 2 - 1 : 0,
|
|
469
|
+
const b = this.dollyToCursor ? (s.x - this._elementRect.x) / this._elementRect.width * 2 - 1 : 0, E = 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
471
|
x * y * ce,
|
|
472
472
|
b,
|
|
473
|
-
|
|
473
|
+
E
|
|
474
474
|
), this._isUserControllingDolly = !0) : (this._zoomInternal(
|
|
475
475
|
x * y * ce,
|
|
476
476
|
b,
|
|
477
|
-
|
|
477
|
+
E
|
|
478
478
|
), this._isUserControllingZoom = !0);
|
|
479
479
|
}
|
|
480
480
|
if ((this._state & c.TOUCH_DOLLY) === c.TOUCH_DOLLY || (this._state & c.TOUCH_ZOOM) === c.TOUCH_ZOOM || (this._state & c.TOUCH_DOLLY_TRUCK) === c.TOUCH_DOLLY_TRUCK || (this._state & c.TOUCH_ZOOM_TRUCK) === c.TOUCH_ZOOM_TRUCK || (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._state & c.TOUCH_DOLLY_OFFSET) === c.TOUCH_DOLLY_OFFSET || (this._state & c.TOUCH_ZOOM_OFFSET) === c.TOUCH_ZOOM_OFFSET || (this._state & c.TOUCH_DOLLY_ROTATE) === c.TOUCH_DOLLY_ROTATE || (this._state & c.TOUCH_ZOOM_ROTATE) === c.TOUCH_ZOOM_ROTATE) {
|
|
481
|
-
const b = D.x - this._activePointers[1].clientX,
|
|
481
|
+
const b = D.x - this._activePointers[1].clientX, E = D.y - this._activePointers[1].clientY, x = Math.sqrt(b * b + E * E), R = r.y - x;
|
|
482
482
|
r.set(0, x);
|
|
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
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
|
+
Oe(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",
|
|
490
490
|
n,
|
|
491
491
|
{ passive: !1 }
|
|
@@ -519,7 +519,7 @@ class J extends Ts {
|
|
|
519
519
|
"pointermove",
|
|
520
520
|
n,
|
|
521
521
|
{ passive: !1 }
|
|
522
|
-
), this._domElement.ownerDocument.addEventListener("pointerup", l),
|
|
522
|
+
), this._domElement.ownerDocument.addEventListener("pointerup", l), O());
|
|
523
523
|
}, this.unlockPointer = () => {
|
|
524
524
|
var a, g, C;
|
|
525
525
|
this._lockedPointer !== null && (this._disposePointer(this._lockedPointer), this._lockedPointer = null), (a = this._domElement) === null || a === void 0 || a.ownerDocument.exitPointerLock(), (g = this._domElement) === null || g === void 0 || g.ownerDocument.removeEventListener(
|
|
@@ -986,12 +986,12 @@ 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 _ =
|
|
989
|
+
const _ = He(this._sphericalEnd.theta, Ie), p = He(this._sphericalEnd.phi, Ie);
|
|
990
990
|
l.push(this.rotateTo(_, p, t));
|
|
991
|
-
const
|
|
991
|
+
const O = w.setFromSpherical(this._sphericalEnd).normalize(), v = Ge.setFromUnitVectors(O, Te), m = P(Math.abs(O.y), 1);
|
|
992
992
|
m && v.multiply(we.setFromAxisAngle(de, _)), v.multiply(this._yAxisUpSpaceInverse);
|
|
993
993
|
const u = We.makeEmpty();
|
|
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,
|
|
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, O), m && v.premultiply(we.invert()), v.premultiply(this._yAxisUpSpace);
|
|
995
995
|
const f = u.getSize(w), a = u.getCenter(L).applyQuaternion(v);
|
|
996
996
|
if (Y(this._camera)) {
|
|
997
997
|
const g = this.getDistanceToFitBox(
|
|
@@ -1003,7 +1003,7 @@ 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 (
|
|
1006
|
+
} else if (H(this._camera)) {
|
|
1007
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)
|
|
@@ -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 (
|
|
1032
|
+
} else if (H(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,13 +1085,13 @@ 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,
|
|
1088
|
+
lerpLookAt(e, t, s, i, r, o, n, l, d, _, p, O, 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(
|
|
1092
1092
|
f.sub(u).applyQuaternion(this._yAxisUpSpace)
|
|
1093
1093
|
);
|
|
1094
|
-
const a = X.set(_, p,
|
|
1094
|
+
const a = X.set(_, p, O), g = L.set(n, l, d);
|
|
1095
1095
|
ae.setFromVector3(
|
|
1096
1096
|
g.sub(a).applyQuaternion(this._yAxisUpSpace)
|
|
1097
1097
|
), this._targetEnd.copy(u.lerp(a, v));
|
|
@@ -1101,7 +1101,7 @@ class J extends Ts {
|
|
|
1101
1101
|
z.phi + y * v,
|
|
1102
1102
|
z.theta + C * v
|
|
1103
1103
|
), this.normalizeRotations(), this._needsUpdate = !0, m || (this._target.copy(this._targetEnd), this._spherical.copy(this._sphericalEnd));
|
|
1104
|
-
const
|
|
1104
|
+
const E = !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,
|
|
1106
1106
|
this._sphericalEnd.theta,
|
|
1107
1107
|
this.restThreshold
|
|
@@ -1114,7 +1114,7 @@ class J extends Ts {
|
|
|
1114
1114
|
this._sphericalEnd.radius,
|
|
1115
1115
|
this.restThreshold
|
|
1116
1116
|
);
|
|
1117
|
-
return this._createOnRestPromise(
|
|
1117
|
+
return this._createOnRestPromise(E);
|
|
1118
1118
|
}
|
|
1119
1119
|
/**
|
|
1120
1120
|
* Set angle and distance by given position.
|
|
@@ -1236,7 +1236,7 @@ class J extends Ts {
|
|
|
1236
1236
|
* @category Methods
|
|
1237
1237
|
*/
|
|
1238
1238
|
getDistanceToFitBox(e, t, s, i = !1) {
|
|
1239
|
-
if (
|
|
1239
|
+
if (Ee(this._camera, "getDistanceToFitBox"))
|
|
1240
1240
|
return this._spherical.radius;
|
|
1241
1241
|
const r = e / t, o = this._camera.getEffectiveFOV() * ie, n = this._camera.aspect;
|
|
1242
1242
|
return ((i ? r > n : r < n) ? t : e / n) * 0.5 / Math.tan(o * 0.5) + s * 0.5;
|
|
@@ -1248,7 +1248,7 @@ class J extends Ts {
|
|
|
1248
1248
|
* @category Methods
|
|
1249
1249
|
*/
|
|
1250
1250
|
getDistanceToFitSphere(e) {
|
|
1251
|
-
if (
|
|
1251
|
+
if (Ee(this._camera, "getDistanceToFitSphere"))
|
|
1252
1252
|
return this._spherical.radius;
|
|
1253
1253
|
const t = this._camera.getEffectiveFOV() * ie, s = Math.atan(Math.tan(t * 0.5) * this._camera.aspect) * 2, i = 1 < this._camera.aspect ? t : s;
|
|
1254
1254
|
return e / Math.sin(i * 0.5);
|
|
@@ -1455,16 +1455,16 @@ 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,
|
|
1458
|
+
const p = this._spherical.radius - this._lastDistance, O = this._camera, v = this._getCameraDirection(ne), m = w.copy(v).cross(O.up).normalize();
|
|
1459
1459
|
m.lengthSq() === 0 && (m.x = 1);
|
|
1460
|
-
const u = L.crossVectors(m, v), f = this._sphericalEnd.radius * Math.tan(
|
|
1460
|
+
const u = L.crossVectors(m, v), f = this._sphericalEnd.radius * Math.tan(O.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
|
-
this._dollyControlCoord.x * f *
|
|
1462
|
+
this._dollyControlCoord.x * f * O.aspect
|
|
1463
1463
|
)
|
|
1464
1464
|
).add(
|
|
1465
1465
|
u.multiplyScalar(this._dollyControlCoord.y * f)
|
|
1466
|
-
), y = w.copy(this._targetEnd).lerp(C, g), b = this._lastDollyDirection === G.IN && this._spherical.radius <= this.minDistance,
|
|
1467
|
-
if (this.infinityDolly && (b ||
|
|
1466
|
+
), y = w.copy(this._targetEnd).lerp(C, g), b = this._lastDollyDirection === G.IN && this._spherical.radius <= this.minDistance, E = this._lastDollyDirection === G.OUT && this.maxDistance <= this._spherical.radius;
|
|
1467
|
+
if (this.infinityDolly && (b || E)) {
|
|
1468
1468
|
this._sphericalEnd.radius -= p, this._spherical.radius -= p;
|
|
1469
1469
|
const R = L.copy(v).multiplyScalar(-p);
|
|
1470
1470
|
y.add(R);
|
|
@@ -1472,15 +1472,15 @@ class J extends Ts {
|
|
|
1472
1472
|
this._boundary.clampPoint(y, y);
|
|
1473
1473
|
const x = L.subVectors(y, this._targetEnd);
|
|
1474
1474
|
this._targetEnd.copy(y), this._target.add(x), this._changedDolly -= p, A(this._changedDolly) && (this._changedDolly = 0);
|
|
1475
|
-
} else if (
|
|
1476
|
-
const p = this._zoom - this._lastZoom,
|
|
1475
|
+
} else if (H(this._camera) && this._changedZoom !== 0) {
|
|
1476
|
+
const p = this._zoom - this._lastZoom, O = this._camera, v = w.set(
|
|
1477
1477
|
this._dollyControlCoord.x,
|
|
1478
1478
|
this._dollyControlCoord.y,
|
|
1479
|
-
(
|
|
1480
|
-
).unproject(
|
|
1479
|
+
(O.near + O.far) / (O.near - O.far)
|
|
1480
|
+
).unproject(O), m = L.set(0, 0, -1).applyQuaternion(O.quaternion), u = X.copy(v).add(m.multiplyScalar(-v.dot(O.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), E = g.multiplyScalar(
|
|
1481
1481
|
b - C
|
|
1482
1482
|
);
|
|
1483
|
-
y.sub(
|
|
1483
|
+
y.sub(E), this._boundary.clampPoint(y, y);
|
|
1484
1484
|
const x = L.subVectors(y, this._targetEnd);
|
|
1485
1485
|
this._targetEnd.copy(y), this._target.add(x), this._changedZoom -= p, A(this._changedZoom) && (this._changedZoom = 0);
|
|
1486
1486
|
}
|
|
@@ -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 (
|
|
1610
|
+
} else if (H(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
|
}
|
|
@@ -1615,7 +1615,7 @@ class J extends Ts {
|
|
|
1615
1615
|
// lateUpdate
|
|
1616
1616
|
_collisionTest() {
|
|
1617
1617
|
let e = 1 / 0;
|
|
1618
|
-
if (!(this.colliderMeshes.length >= 1) ||
|
|
1618
|
+
if (!(this.colliderMeshes.length >= 1) || Ee(this._camera, "_collisionTest"))
|
|
1619
1619
|
return e;
|
|
1620
1620
|
const s = this._getTargetDirection(ne);
|
|
1621
1621
|
xe.lookAt(Ve, s, this._camera.up);
|
|
@@ -1703,7 +1703,7 @@ class J extends Ts {
|
|
|
1703
1703
|
const l = n.geometry.clone();
|
|
1704
1704
|
l.applyMatrix4(n.matrixWorld);
|
|
1705
1705
|
const _ = l.attributes.position;
|
|
1706
|
-
for (let p = 0,
|
|
1706
|
+
for (let p = 0, O = _.count; p < O; p++)
|
|
1707
1707
|
w.fromBufferAttribute(_, p), r = Math.max(r, i.distanceToSquared(w));
|
|
1708
1708
|
}), s.radius = Math.sqrt(r), s;
|
|
1709
1709
|
}
|
|
@@ -1719,7 +1719,7 @@ Q && typeof Q.ownKeys == "function" ? ue = Q.ownKeys : Object.getOwnPropertySymb
|
|
|
1719
1719
|
function ws(h) {
|
|
1720
1720
|
console && console.warn && console.warn(h);
|
|
1721
1721
|
}
|
|
1722
|
-
var
|
|
1722
|
+
var gt = Number.isNaN || function(e) {
|
|
1723
1723
|
return e !== e;
|
|
1724
1724
|
};
|
|
1725
1725
|
function S() {
|
|
@@ -1742,7 +1742,7 @@ Object.defineProperty(S, "defaultMaxListeners", {
|
|
|
1742
1742
|
return Xe;
|
|
1743
1743
|
},
|
|
1744
1744
|
set: function(h) {
|
|
1745
|
-
if (typeof h != "number" || h < 0 ||
|
|
1745
|
+
if (typeof h != "number" || h < 0 || gt(h))
|
|
1746
1746
|
throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received ' + h + ".");
|
|
1747
1747
|
Xe = h;
|
|
1748
1748
|
}
|
|
@@ -1751,15 +1751,15 @@ S.init = function() {
|
|
|
1751
1751
|
(this._events === void 0 || this._events === Object.getPrototypeOf(this)._events) && (this._events = /* @__PURE__ */ Object.create(null), this._eventsCount = 0), this._maxListeners = this._maxListeners || void 0;
|
|
1752
1752
|
};
|
|
1753
1753
|
S.prototype.setMaxListeners = function(e) {
|
|
1754
|
-
if (typeof e != "number" || e < 0 ||
|
|
1754
|
+
if (typeof e != "number" || e < 0 || gt(e))
|
|
1755
1755
|
throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received ' + e + ".");
|
|
1756
1756
|
return this._maxListeners = e, this;
|
|
1757
1757
|
};
|
|
1758
|
-
function
|
|
1758
|
+
function vt(h) {
|
|
1759
1759
|
return h._maxListeners === void 0 ? S.defaultMaxListeners : h._maxListeners;
|
|
1760
1760
|
}
|
|
1761
1761
|
S.prototype.getMaxListeners = function() {
|
|
1762
|
-
return
|
|
1762
|
+
return vt(this);
|
|
1763
1763
|
};
|
|
1764
1764
|
S.prototype.emit = function(e) {
|
|
1765
1765
|
for (var t = [], s = 1; s < arguments.length; s++) t.push(arguments[s]);
|
|
@@ -1781,11 +1781,11 @@ S.prototype.emit = function(e) {
|
|
|
1781
1781
|
if (typeof l == "function")
|
|
1782
1782
|
Ke(l, this, t);
|
|
1783
1783
|
else
|
|
1784
|
-
for (var d = l.length, _ =
|
|
1784
|
+
for (var d = l.length, _ = Tt(l, d), s = 0; s < d; ++s)
|
|
1785
1785
|
Ke(_[s], this, t);
|
|
1786
1786
|
return !0;
|
|
1787
1787
|
};
|
|
1788
|
-
function
|
|
1788
|
+
function yt(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",
|
|
@@ -1793,7 +1793,7 @@ function vt(h, e, t, s) {
|
|
|
1793
1793
|
t.listener ? t.listener : t
|
|
1794
1794
|
), r = h._events), o = r[e]), o === void 0)
|
|
1795
1795
|
o = r[e] = t, ++h._eventsCount;
|
|
1796
|
-
else if (typeof o == "function" ? o = r[e] = s ? [t, o] : [o, t] : s ? o.unshift(t) : o.push(t), i =
|
|
1796
|
+
else if (typeof o == "function" ? o = r[e] = s ? [t, o] : [o, t] : s ? o.unshift(t) : o.push(t), i = vt(h), i > 0 && o.length > i && !o.warned) {
|
|
1797
1797
|
o.warned = !0;
|
|
1798
1798
|
var n = new Error("Possible EventEmitter memory leak detected. " + o.length + " " + String(e) + " listeners added. Use emitter.setMaxListeners() to increase limit");
|
|
1799
1799
|
n.name = "MaxListenersExceededWarning", n.emitter = h, n.type = e, n.count = o.length, ws(n);
|
|
@@ -1801,25 +1801,25 @@ function vt(h, e, t, s) {
|
|
|
1801
1801
|
return h;
|
|
1802
1802
|
}
|
|
1803
1803
|
S.prototype.addListener = function(e, t) {
|
|
1804
|
-
return
|
|
1804
|
+
return yt(this, e, t, !1);
|
|
1805
1805
|
};
|
|
1806
1806
|
S.prototype.on = S.prototype.addListener;
|
|
1807
1807
|
S.prototype.prependListener = function(e, t) {
|
|
1808
|
-
return
|
|
1808
|
+
return yt(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
|
|
1814
|
+
function Ct(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,
|
|
1819
|
+
return ge(t), this.on(e, Ct(this, e, t)), this;
|
|
1820
1820
|
};
|
|
1821
1821
|
S.prototype.prependOnceListener = function(e, t) {
|
|
1822
|
-
return ge(t), this.prependListener(e,
|
|
1822
|
+
return ge(t), this.prependListener(e, Ct(this, e, t)), this;
|
|
1823
1823
|
};
|
|
1824
1824
|
S.prototype.removeListener = function(e, t) {
|
|
1825
1825
|
var s, i, r, o, n;
|
|
@@ -1861,18 +1861,18 @@ S.prototype.removeAllListeners = function(e) {
|
|
|
1861
1861
|
this.removeListener(e, t[i]);
|
|
1862
1862
|
return this;
|
|
1863
1863
|
};
|
|
1864
|
-
function
|
|
1864
|
+
function Ot(h, e, t) {
|
|
1865
1865
|
var s = h._events;
|
|
1866
1866
|
if (s === void 0)
|
|
1867
1867
|
return [];
|
|
1868
1868
|
var i = s[e];
|
|
1869
|
-
return i === void 0 ? [] : typeof i == "function" ? t ? [i.listener || i] : [i] : t ? Ps(i) :
|
|
1869
|
+
return i === void 0 ? [] : typeof i == "function" ? t ? [i.listener || i] : [i] : t ? Ps(i) : Tt(i, i.length);
|
|
1870
1870
|
}
|
|
1871
1871
|
S.prototype.listeners = function(e) {
|
|
1872
|
-
return
|
|
1872
|
+
return Ot(this, e, !0);
|
|
1873
1873
|
};
|
|
1874
1874
|
S.prototype.rawListeners = function(e) {
|
|
1875
|
-
return
|
|
1875
|
+
return Ot(this, e, !1);
|
|
1876
1876
|
};
|
|
1877
1877
|
S.listenerCount = function(h, e) {
|
|
1878
1878
|
return typeof h.listenerCount == "function" ? h.listenerCount(e) : Et.call(h, e);
|
|
@@ -1892,7 +1892,7 @@ function Et(h) {
|
|
|
1892
1892
|
S.prototype.eventNames = function() {
|
|
1893
1893
|
return this._eventsCount > 0 ? ue(this._events) : [];
|
|
1894
1894
|
};
|
|
1895
|
-
function
|
|
1895
|
+
function Tt(h, e) {
|
|
1896
1896
|
for (var t = new Array(e), s = 0; s < e; ++s)
|
|
1897
1897
|
t[s] = h[s];
|
|
1898
1898
|
return t;
|
|
@@ -1915,13 +1915,13 @@ function Ss(h, e) {
|
|
|
1915
1915
|
function r() {
|
|
1916
1916
|
typeof h.removeListener == "function" && h.removeListener("error", i), t([].slice.call(arguments));
|
|
1917
1917
|
}
|
|
1918
|
-
|
|
1918
|
+
bt(h, e, r, { once: !0 }), e !== "error" && As(h, i, { once: !0 });
|
|
1919
1919
|
});
|
|
1920
1920
|
}
|
|
1921
1921
|
function As(h, e, t) {
|
|
1922
|
-
typeof h.on == "function" &&
|
|
1922
|
+
typeof h.on == "function" && bt(h, "error", e, t);
|
|
1923
1923
|
}
|
|
1924
|
-
function
|
|
1924
|
+
function bt(h, e, t, s) {
|
|
1925
1925
|
if (typeof h.on == "function")
|
|
1926
1926
|
s.once ? h.once(e, t) : h.on(e, t);
|
|
1927
1927
|
else if (typeof h.addEventListener == "function")
|
|
@@ -1955,15 +1955,15 @@ class Rs {
|
|
|
1955
1955
|
toneMappingExposure: d,
|
|
1956
1956
|
outputColorSpace: _,
|
|
1957
1957
|
logarithmicDepthBuffer: p,
|
|
1958
|
-
preserveDrawingBuffer:
|
|
1958
|
+
preserveDrawingBuffer: O,
|
|
1959
1959
|
stencil: v,
|
|
1960
1960
|
depth: m
|
|
1961
|
-
} = i, u = new
|
|
1961
|
+
} = i, u = new zt({
|
|
1962
1962
|
alpha: r,
|
|
1963
1963
|
antialias: n,
|
|
1964
1964
|
powerPreference: l,
|
|
1965
1965
|
logarithmicDepthBuffer: p,
|
|
1966
|
-
preserveDrawingBuffer:
|
|
1966
|
+
preserveDrawingBuffer: O,
|
|
1967
1967
|
stencil: v,
|
|
1968
1968
|
depth: m
|
|
1969
1969
|
});
|
|
@@ -2079,7 +2079,7 @@ class ee {
|
|
|
2079
2079
|
}), this.removePage(0), this.controllerMap.clear(), this.event.removeAllListeners(), this.activeControllerSet.clear();
|
|
2080
2080
|
}
|
|
2081
2081
|
}
|
|
2082
|
-
const
|
|
2082
|
+
const wt = {
|
|
2083
2083
|
fov: 45,
|
|
2084
2084
|
near: 1,
|
|
2085
2085
|
far: 1e3,
|
|
@@ -2092,8 +2092,8 @@ class ks extends ee {
|
|
|
2092
2092
|
get camera() {
|
|
2093
2093
|
return this.controller;
|
|
2094
2094
|
}
|
|
2095
|
-
addPerspectiveCamera(e =
|
|
2096
|
-
const { fov: s, far: i, near: r, up: o, aspect: n } = e, l = n != null ? n : this.width / this.height, d = new
|
|
2095
|
+
addPerspectiveCamera(e = wt, t) {
|
|
2096
|
+
const { fov: s, far: i, near: r, up: o, aspect: n } = e, l = n != null ? n : this.width / this.height, d = new kt(s, l, r, i);
|
|
2097
2097
|
return d.up = o, this.addController(d, t);
|
|
2098
2098
|
}
|
|
2099
2099
|
setPageActive(e) {
|
|
@@ -2191,7 +2191,7 @@ class Ns extends ee {
|
|
|
2191
2191
|
});
|
|
2192
2192
|
}
|
|
2193
2193
|
}
|
|
2194
|
-
class
|
|
2194
|
+
class js {
|
|
2195
2195
|
constructor(e) {
|
|
2196
2196
|
this.helpers = {}, this.options = e;
|
|
2197
2197
|
}
|
|
@@ -2202,15 +2202,15 @@ class Hs {
|
|
|
2202
2202
|
if (e.isScene)
|
|
2203
2203
|
i = new De(100);
|
|
2204
2204
|
else if (e.isCamera)
|
|
2205
|
-
i = new
|
|
2205
|
+
i = new Ft(e);
|
|
2206
2206
|
else if (e.isPointLight)
|
|
2207
|
-
i = new Ft(e, 1);
|
|
2208
|
-
else if (e.isDirectionalLight)
|
|
2209
2207
|
i = new Nt(e, 1);
|
|
2208
|
+
else if (e.isDirectionalLight)
|
|
2209
|
+
i = new jt(e, 1);
|
|
2210
2210
|
else if (e.isSpotLight)
|
|
2211
|
-
i = new
|
|
2211
|
+
i = new It(e);
|
|
2212
2212
|
else if (e.isHemisphereLight)
|
|
2213
|
-
i = new
|
|
2213
|
+
i = new Ht(e, 10);
|
|
2214
2214
|
else if (e.isRectAreaLight)
|
|
2215
2215
|
i = new ds(e);
|
|
2216
2216
|
else {
|
|
@@ -2282,12 +2282,12 @@ class Is extends ee {
|
|
|
2282
2282
|
const t = {
|
|
2283
2283
|
Vector2: B,
|
|
2284
2284
|
Vector3: I,
|
|
2285
|
-
Vector4:
|
|
2285
|
+
Vector4: Vt,
|
|
2286
2286
|
Quaternion: lt,
|
|
2287
2287
|
Matrix4: W,
|
|
2288
|
-
Spherical:
|
|
2288
|
+
Spherical: Yt,
|
|
2289
2289
|
Box3: at,
|
|
2290
|
-
Sphere:
|
|
2290
|
+
Sphere: Zt,
|
|
2291
2291
|
Raycaster: ht
|
|
2292
2292
|
};
|
|
2293
2293
|
J.install({ THREE: t });
|
|
@@ -2320,10 +2320,10 @@ class Is 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 *
|
|
2323
|
+
super.update(e, t), this.autoRotateSpeed && this.cameraControls && (this.cameraControls.azimuthAngle += this.autoRotateSpeed * e * Bt.DEG2RAD);
|
|
2324
2324
|
}
|
|
2325
2325
|
}
|
|
2326
|
-
class
|
|
2326
|
+
class Hs {
|
|
2327
2327
|
constructor(e) {
|
|
2328
2328
|
this.event = new ve.EventEmitter();
|
|
2329
2329
|
const { renderer: t, scene: s, camera: i } = e, r = new ms(
|
|
@@ -2332,7 +2332,7 @@ class js {
|
|
|
2332
2332
|
);
|
|
2333
2333
|
if (r.getHelper) {
|
|
2334
2334
|
const o = r.getHelper();
|
|
2335
|
-
if (s.add(o), +
|
|
2335
|
+
if (s.add(o), +Wt < 170) {
|
|
2336
2336
|
const n = r._root;
|
|
2337
2337
|
n.dispose = () => {
|
|
2338
2338
|
n.traverse((l) => {
|
|
@@ -2342,7 +2342,7 @@ class js {
|
|
|
2342
2342
|
r.disconnect(), n.dispose();
|
|
2343
2343
|
};
|
|
2344
2344
|
}
|
|
2345
|
-
} else r instanceof
|
|
2345
|
+
} else r instanceof Gt && s.add(r);
|
|
2346
2346
|
this.controls = r, this.addEvent();
|
|
2347
2347
|
}
|
|
2348
2348
|
get detach() {
|
|
@@ -2392,7 +2392,7 @@ class js {
|
|
|
2392
2392
|
this.event.removeAllListeners(), (e = this.controls) == null || e.dispose();
|
|
2393
2393
|
}
|
|
2394
2394
|
}
|
|
2395
|
-
const $e = new I(), Bs = new lt(), qe = new I(),
|
|
2395
|
+
const $e = new I(), Bs = new lt(), qe = new I(), j = new W(), Vs = new W();
|
|
2396
2396
|
class Ys {
|
|
2397
2397
|
/**
|
|
2398
2398
|
* Constructs a new CSS3D renderer.
|
|
@@ -2420,7 +2420,7 @@ class Ys {
|
|
|
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
2421
|
let C, y;
|
|
2422
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,
|
|
2423
|
+
const b = a.view && a.view.enabled ? a.view.height / a.view.fullHeight : 1, E = a.isOrthographicCamera ? `scale( ${b} )scale(` + g + ")translate(" + p(C) + "px," + p(y) + "px)" + O(a.matrixWorldInverse) : `scale( ${b} )translateZ(` + g + "px)" + O(a.matrixWorldInverse), R = (a.isPerspectiveCamera ? "perspective(" + g + "px) " : "") + E + "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";
|
|
@@ -2428,7 +2428,7 @@ class Ys {
|
|
|
2428
2428
|
function p(f) {
|
|
2429
2429
|
return Math.abs(f) < 1e-10 ? 0 : f;
|
|
2430
2430
|
}
|
|
2431
|
-
function
|
|
2431
|
+
function O(f) {
|
|
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
|
}
|
|
@@ -2450,12 +2450,12 @@ class Ys {
|
|
|
2450
2450
|
const y = f.layers.test(g.layers) === !0, b = f.element;
|
|
2451
2451
|
if (b.style.display = y === !0 ? "" : "none", y === !0) {
|
|
2452
2452
|
f.onBeforeRender(t, a, g);
|
|
2453
|
-
let
|
|
2454
|
-
f.isCSS3DSprite ? (
|
|
2453
|
+
let E;
|
|
2454
|
+
f.isCSS3DSprite ? (j.copy(g.matrixWorldInverse), j.transpose(), f.rotation2D !== 0 && j.multiply(Vs.makeRotationZ(f.rotation2D)), f.matrixWorld.decompose($e, Bs, qe), j.setPosition($e), j.scale(qe), j.elements[3] = 0, j.elements[7] = 0, j.elements[11] = 0, j.elements[15] = 1, E = v(j)) : E = v(f.matrixWorld);
|
|
2455
2455
|
const x = n.objects.get(f);
|
|
2456
|
-
if (x === void 0 || x.style !==
|
|
2457
|
-
b.style.transform =
|
|
2458
|
-
const R = { style:
|
|
2456
|
+
if (x === void 0 || x.style !== E) {
|
|
2457
|
+
b.style.transform = E;
|
|
2458
|
+
const R = { style: E };
|
|
2459
2459
|
n.objects.set(f, R);
|
|
2460
2460
|
}
|
|
2461
2461
|
b.parentNode !== _ && _.appendChild(b), f.onAfterRender(t, a, g);
|
|
@@ -2514,14 +2514,14 @@ class Zs {
|
|
|
2514
2514
|
function p(m, u) {
|
|
2515
2515
|
return et.setFromMatrixPosition(m.matrixWorld), tt.setFromMatrixPosition(u.matrixWorld), et.distanceToSquared(tt);
|
|
2516
2516
|
}
|
|
2517
|
-
function
|
|
2517
|
+
function O(m) {
|
|
2518
2518
|
const u = [];
|
|
2519
2519
|
return m.traverseVisible(function(f) {
|
|
2520
2520
|
f.isCSS2DObject && u.push(f);
|
|
2521
2521
|
}), u;
|
|
2522
2522
|
}
|
|
2523
2523
|
function v(m) {
|
|
2524
|
-
const u =
|
|
2524
|
+
const u = O(m).sort(function(a, g) {
|
|
2525
2525
|
if (a.renderOrder !== g.renderOrder)
|
|
2526
2526
|
return g.renderOrder - a.renderOrder;
|
|
2527
2527
|
const C = n.objects.get(a).distanceToCameraSquared, y = n.objects.get(g).distanceToCameraSquared;
|
|
@@ -2654,7 +2654,7 @@ class Ks extends _s {
|
|
|
2654
2654
|
constructor() {
|
|
2655
2655
|
super();
|
|
2656
2656
|
const e = Gs;
|
|
2657
|
-
this.uniforms =
|
|
2657
|
+
this.uniforms = Kt.clone(e.uniforms), this.material = new Xt({
|
|
2658
2658
|
name: e.name,
|
|
2659
2659
|
uniforms: this.uniforms,
|
|
2660
2660
|
vertexShader: e.vertexShader,
|
|
@@ -2664,7 +2664,7 @@ class Ks extends _s {
|
|
|
2664
2664
|
}
|
|
2665
2665
|
const Xs = (h) => {
|
|
2666
2666
|
const e = new gs(
|
|
2667
|
-
new
|
|
2667
|
+
new $t({
|
|
2668
2668
|
uniforms: {
|
|
2669
2669
|
baseTexture: { value: null },
|
|
2670
2670
|
bloomTexture: { value: h.renderTarget2.texture },
|
|
@@ -2698,7 +2698,7 @@ const Xs = (h) => {
|
|
|
2698
2698
|
"baseTexture"
|
|
2699
2699
|
);
|
|
2700
2700
|
return e.needsSwap = !0, e;
|
|
2701
|
-
}, Le = 1, me = !1, $s = new
|
|
2701
|
+
}, Le = 1, me = !1, $s = new qt({ color: "black" }), qs = new ct({
|
|
2702
2702
|
color: "black",
|
|
2703
2703
|
sizeAttenuation: !1
|
|
2704
2704
|
}), Qs = new ct({
|
|
@@ -2710,7 +2710,7 @@ const Xs = (h) => {
|
|
|
2710
2710
|
}), ei = new dt({
|
|
2711
2711
|
color: "black",
|
|
2712
2712
|
sizeAttenuation: !1
|
|
2713
|
-
}), ti = new
|
|
2713
|
+
}), ti = new ft({
|
|
2714
2714
|
color: "black",
|
|
2715
2715
|
sizeAttenuation: 0,
|
|
2716
2716
|
lineWidth: 0
|
|
@@ -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
|
|
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,
|
|
@@ -2737,15 +2737,15 @@ class oi {
|
|
|
2737
2737
|
composerParams: r
|
|
2738
2738
|
} = e, { renderer: o } = t;
|
|
2739
2739
|
this.renderer = o;
|
|
2740
|
-
const { multisampling: n } = r, { maxSamples: l } = o.capabilities, d = o.getDrawingBufferSize(new B()), _ = new
|
|
2740
|
+
const { multisampling: n } = r, { maxSamples: l } = o.capabilities, d = o.getDrawingBufferSize(new B()), _ = new Jt(
|
|
2741
2741
|
d.width,
|
|
2742
2742
|
d.height,
|
|
2743
2743
|
{
|
|
2744
2744
|
samples: Math.min(n, l),
|
|
2745
|
-
type:
|
|
2745
|
+
type: es
|
|
2746
2746
|
}
|
|
2747
|
-
), p = new ke(o, _),
|
|
2748
|
-
p.setSize(
|
|
2747
|
+
), p = new ke(o, _), O = this.getSize();
|
|
2748
|
+
p.setSize(O.width, O.height);
|
|
2749
2749
|
const v = new us(
|
|
2750
2750
|
s.scene,
|
|
2751
2751
|
i.camera
|
|
@@ -2818,7 +2818,7 @@ class oi {
|
|
|
2818
2818
|
s.traverse((i) => {
|
|
2819
2819
|
var l;
|
|
2820
2820
|
const r = i, o = i, n = i;
|
|
2821
|
-
(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 = Js : o.material = ei : r.material instanceof
|
|
2821
|
+
(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 = Js : o.material = ei : r.material instanceof ft ? r.material = ti : n.isPoints ? n.material.sizeAttenuation ? n.material = Qs : n.material = qs : r.material = $s);
|
|
2822
2822
|
});
|
|
2823
2823
|
}), e.forEach((s) => {
|
|
2824
2824
|
this.bloomVisible[s.uuid] = s.visible, s.visible = !1;
|
|
@@ -2879,12 +2879,12 @@ class it extends pt {
|
|
|
2879
2879
|
let d = l;
|
|
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
|
-
const
|
|
2882
|
+
const O = () => {
|
|
2883
2883
|
o.removeEventListener("load", v, !1), o.removeEventListener("error", m, !1);
|
|
2884
2884
|
}, v = () => {
|
|
2885
|
-
|
|
2885
|
+
O(), r.needsUpdate = !0, t && t(r);
|
|
2886
2886
|
}, m = (f) => {
|
|
2887
|
-
|
|
2887
|
+
O(), i && i(f), this.manager.itemError(e), this.manager.itemEnd(e);
|
|
2888
2888
|
};
|
|
2889
2889
|
o.addEventListener("load", v, !1), o.addEventListener("error", m, !1);
|
|
2890
2890
|
const u = window.URL.createObjectURL(d);
|
|
@@ -2930,7 +2930,7 @@ class li {
|
|
|
2930
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
|
-
}, e), this.loadingManager = new
|
|
2933
|
+
}, e), this.loadingManager = new ts(
|
|
2934
2934
|
() => {
|
|
2935
2935
|
},
|
|
2936
2936
|
(t, s, i) => {
|
|
@@ -2982,7 +2982,7 @@ class li {
|
|
|
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")
|
|
2985
|
-
return this.lottieLoader || (this.lottieLoader = new
|
|
2985
|
+
return this.lottieLoader || (this.lottieLoader = new Os(this.loadingManager), this.options.prefix && this.lottieLoader.setPath(this.options.prefix)), this.lottieLoader;
|
|
2986
2986
|
if (e === "gzipJson")
|
|
2987
2987
|
return this.gzipJsonLoader || (this.gzipJsonLoader = new ni(this.loadingManager), this.options.prefix && this.gzipJsonLoader.setPath(this.options.prefix)), this.gzipJsonLoader;
|
|
2988
2988
|
if (e === "json")
|
|
@@ -3007,7 +3007,7 @@ class li {
|
|
|
3007
3007
|
get textureAssets() {
|
|
3008
3008
|
const e = /* @__PURE__ */ new Map();
|
|
3009
3009
|
return this.assets.forEach((t, s) => {
|
|
3010
|
-
(t instanceof fe || t instanceof
|
|
3010
|
+
(t instanceof fe || t instanceof ss || t instanceof mt) && e.set(s, t);
|
|
3011
3011
|
}), e;
|
|
3012
3012
|
}
|
|
3013
3013
|
loadAll() {
|
|
@@ -3024,7 +3024,7 @@ class li {
|
|
|
3024
3024
|
const s = (n = t == null ? void 0 : t.type) != null ? n : this.getAssetType(e);
|
|
3025
3025
|
if (!s)
|
|
3026
3026
|
return;
|
|
3027
|
-
const i = (t == null ? void 0 : t.cache) !== !1, r =
|
|
3027
|
+
const i = (t == null ? void 0 : t.cache) !== !1, r = Es();
|
|
3028
3028
|
if (i) {
|
|
3029
3029
|
if (this.assets.has(e))
|
|
3030
3030
|
return this.assets.get(e);
|
|
@@ -3150,7 +3150,7 @@ class pi {
|
|
|
3150
3150
|
const _ = d.map((m) => m.object3d);
|
|
3151
3151
|
_.forEach((m) => {
|
|
3152
3152
|
m.isGroup && m.traverse((u) => {
|
|
3153
|
-
u instanceof
|
|
3153
|
+
u instanceof ut && _.push(u);
|
|
3154
3154
|
});
|
|
3155
3155
|
});
|
|
3156
3156
|
const p = (v = this.pencil.pick(r, _, !1)) == null ? void 0 : v.intersects;
|
|
@@ -3161,8 +3161,8 @@ class pi {
|
|
|
3161
3161
|
const m = p[0];
|
|
3162
3162
|
this.processIntersection(m, r, e);
|
|
3163
3163
|
}
|
|
3164
|
-
const
|
|
3165
|
-
this.prevActiveObjects = this.activeObjects, this.activeObjects =
|
|
3164
|
+
const O = this.prevActiveObjects;
|
|
3165
|
+
this.prevActiveObjects = this.activeObjects, this.activeObjects = O, this.activeObjects.clear();
|
|
3166
3166
|
};
|
|
3167
3167
|
this.domElement.addEventListener(
|
|
3168
3168
|
`pointer${e}`,
|
|
@@ -3223,10 +3223,10 @@ class pi {
|
|
|
3223
3223
|
});
|
|
3224
3224
|
const _ = l.get("click");
|
|
3225
3225
|
if (_) {
|
|
3226
|
-
const p = (
|
|
3227
|
-
|
|
3226
|
+
const p = (O) => {
|
|
3227
|
+
O.preventDefault();
|
|
3228
3228
|
const v = 5;
|
|
3229
|
-
if (!r && Math.abs(
|
|
3229
|
+
if (!r && Math.abs(O.clientX - e.clientX) <= v && Math.abs(O.clientY - e.clientY) <= v)
|
|
3230
3230
|
for (const m of _)
|
|
3231
3231
|
m({
|
|
3232
3232
|
baseObject: n,
|
|
@@ -3347,11 +3347,11 @@ 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,
|
|
3350
|
+
const d = t.target, _ = (r = t.onTop) != null ? r : 0, p = (o = t.prefab) != null ? o : !1, O = (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,
|
|
3353
|
-
} :
|
|
3354
|
-
|
|
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, O === !1 ? v.create = () => {
|
|
3353
|
+
} : O !== !0 && (v.create = () => {
|
|
3354
|
+
O(v);
|
|
3355
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
3356
|
v,
|
|
3357
3357
|
t.key ? `$t:#${t.key}` : "$t:",
|
|
@@ -3371,7 +3371,7 @@ class mi extends pi {
|
|
|
3371
3371
|
const [, n] = s.split("#");
|
|
3372
3372
|
o = o.replace("$p:", n);
|
|
3373
3373
|
}
|
|
3374
|
-
return this.objects.has(o) && (o.includes("#") ? o += `-${
|
|
3374
|
+
return this.objects.has(o) && (o.includes("#") ? o += `-${je()}` : o += `#${je()}`), e.key = o, this.objects.set(o, e), o;
|
|
3375
3375
|
}
|
|
3376
3376
|
updateBaseObjectKey(e, t) {
|
|
3377
3377
|
var o;
|
|
@@ -3455,10 +3455,22 @@ class ui extends ee {
|
|
|
3455
3455
|
}
|
|
3456
3456
|
class fi {
|
|
3457
3457
|
constructor(e) {
|
|
3458
|
-
this.materials = /* @__PURE__ */ new Map(), this.
|
|
3458
|
+
this.fixBufferGeometry = new is(), this.materials = /* @__PURE__ */ new Map(), this.fixBaseObjects = /* @__PURE__ */ new Map(), this.materialBaseObjectMap = /* @__PURE__ */ new Map(), this.pencil = e;
|
|
3459
3459
|
}
|
|
3460
3460
|
add(e, t) {
|
|
3461
|
-
this.materials.set(e, t)
|
|
3461
|
+
this.materials.set(e, t);
|
|
3462
|
+
const s = {
|
|
3463
|
+
key: e,
|
|
3464
|
+
userData: {},
|
|
3465
|
+
children: [],
|
|
3466
|
+
object3d: new Proxy(new ut(this.fixBufferGeometry, t), {
|
|
3467
|
+
set: (i, r, o) => {
|
|
3468
|
+
var n;
|
|
3469
|
+
return r === "material" && !((n = this.pencil.composerController) != null && n.bloomComposerRenderIng) ? (i.material = o, this.materials.set(e, o), !0) : Reflect.set(i, r, o);
|
|
3470
|
+
}
|
|
3471
|
+
})
|
|
3472
|
+
};
|
|
3473
|
+
this.fixBaseObjects.set(e, s), this.emitObject3dChange();
|
|
3462
3474
|
}
|
|
3463
3475
|
get(e) {
|
|
3464
3476
|
const t = this.materials.get(e);
|
|
@@ -3502,7 +3514,7 @@ class fi {
|
|
|
3502
3514
|
}
|
|
3503
3515
|
remove(e) {
|
|
3504
3516
|
const t = this.materials.get(e);
|
|
3505
|
-
t && this.disposeMaterial(t), this.materials.delete(e), this.emitObject3dChange();
|
|
3517
|
+
t && this.disposeMaterial(t), this.materials.delete(e), this.fixBaseObjects.delete(e), this.emitObject3dChange();
|
|
3506
3518
|
}
|
|
3507
3519
|
removeByMaterial(e) {
|
|
3508
3520
|
[...this.materials.entries()].some(([t, s]) => s === e ? (this.remove(t), !0) : !1);
|
|
@@ -3567,7 +3579,7 @@ class fi {
|
|
|
3567
3579
|
}
|
|
3568
3580
|
dispose() {
|
|
3569
3581
|
const e = new Pe();
|
|
3570
|
-
e.track([...this.materials.values()]), e.dispose(), this.
|
|
3582
|
+
e.track([...this.materials.values()]), e.dispose(), this.materials.clear(), this.fixBaseObjects.clear(), this.materialBaseObjectMap.clear(), this.fixBufferGeometry.dispose();
|
|
3571
3583
|
}
|
|
3572
3584
|
}
|
|
3573
3585
|
class _i extends ee {
|
|
@@ -3690,7 +3702,7 @@ const _e = class _e {
|
|
|
3690
3702
|
}), p = new ks({
|
|
3691
3703
|
width: l,
|
|
3692
3704
|
height: d
|
|
3693
|
-
}),
|
|
3705
|
+
}), O = new Ns({}), v = new Is({
|
|
3694
3706
|
controlsParams: {
|
|
3695
3707
|
domElement: (g = o == null ? void 0 : o.domElement) != null ? g : _.renderer.domElement
|
|
3696
3708
|
}
|
|
@@ -3703,18 +3715,18 @@ const _e = class _e {
|
|
|
3703
3715
|
}), f = new ui({
|
|
3704
3716
|
pencil: this
|
|
3705
3717
|
});
|
|
3706
|
-
this.sceneController =
|
|
3718
|
+
this.sceneController = O, this.cameraController = p, this.controlsController = v, this.rendererController = _, this.loaderController = m, this.mListController = u, this.leadController = f;
|
|
3707
3719
|
const a = this.addPage({
|
|
3708
3720
|
sceneOptions: this.options.scene,
|
|
3709
3721
|
cameraOptions: this.options.camera
|
|
3710
3722
|
});
|
|
3711
3723
|
if (this.showPage(a), s) {
|
|
3712
|
-
const C = new
|
|
3724
|
+
const C = new js({
|
|
3713
3725
|
container: e,
|
|
3714
|
-
sceneController:
|
|
3726
|
+
sceneController: O,
|
|
3715
3727
|
cameraController: p
|
|
3716
3728
|
});
|
|
3717
|
-
C.add(
|
|
3729
|
+
C.add(O.scene), this.helperController = C, i && C.addViewHelper();
|
|
3718
3730
|
}
|
|
3719
3731
|
e.appendChild(_.renderer.domElement);
|
|
3720
3732
|
}
|
|
@@ -3747,7 +3759,7 @@ const _e = class _e {
|
|
|
3747
3759
|
}
|
|
3748
3760
|
}
|
|
3749
3761
|
initTransformControls() {
|
|
3750
|
-
const e = new
|
|
3762
|
+
const e = new Hs({
|
|
3751
3763
|
camera: this.camera,
|
|
3752
3764
|
renderer: this.renderer,
|
|
3753
3765
|
scene: this.scene
|
|
@@ -3874,11 +3886,11 @@ const _e = class _e {
|
|
|
3874
3886
|
}
|
|
3875
3887
|
}
|
|
3876
3888
|
dispose() {
|
|
3877
|
-
var e, t, s, i, r, o, n, l, d, _, p,
|
|
3889
|
+
var e, t, s, i, r, o, n, l, d, _, p, O, v, m;
|
|
3878
3890
|
this.stop(), this.timer.dispose(), Ce.removeAll(), this.event.removeAllListeners(), (e = this.resizeObserver) == null || e.unobserve(this.options.container), this.installPlugins.forEach((u) => {
|
|
3879
3891
|
var f;
|
|
3880
3892
|
(f = u.dispose) == null || f.call(u);
|
|
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(), (
|
|
3893
|
+
}), (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(), (O = this.mListController) == null || O.dispose(), this.cssRendererController = void 0, this.installPlugins.clear(), (v = this.stats) == null || v.dom.remove(), (m = this.renderer) == null || m.domElement.remove();
|
|
3882
3894
|
}
|
|
3883
3895
|
};
|
|
3884
3896
|
_e.options = {
|
|
@@ -3890,7 +3902,7 @@ _e.options = {
|
|
|
3890
3902
|
renderer: Ms,
|
|
3891
3903
|
composer: ri,
|
|
3892
3904
|
scene: Fs,
|
|
3893
|
-
camera:
|
|
3905
|
+
camera: wt,
|
|
3894
3906
|
bloom: !1,
|
|
3895
3907
|
bloomParams: ii,
|
|
3896
3908
|
ssao: !1,
|