gl-draw 0.9.28 → 0.9.29

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.
@@ -67,6 +67,7 @@ export default class Pencil {
67
67
  getPlugin(name: 'loader'): Loader;
68
68
  getPlugin(name: 'cache'): Cache;
69
69
  get renderer(): THREE.WebGLRenderer;
70
+ get maxAnisotropy(): number;
70
71
  get cameraControls(): import("./CameraControls").default;
71
72
  get cameraPositon(): THREE.Vector3;
72
73
  get cameraTarget(): THREE.Vector3;
package/dist/index.js CHANGED
@@ -15,4 +15,4 @@
15
15
  vUv = position.xy * 0.5 + 0.5;
16
16
  gl_Position = vec4(position.xy, 1.0, 1.0);
17
17
  }
18
- `,toneMapped:!1,depthWrite:!1,depthTest:!1})}}class Ee extends b.Pass{constructor(){super("CrossFadePass"),this.fullscreenMaterial=new ge}render(t,e,s){const i=this.fullscreenMaterial;i.uniforms.inputBuffer.value=e.texture,t.setRenderTarget(this.renderToScreen?null:s),t.render(this.scene,this.camera)}}const kt={luminancePass:!1,luminanceThreshold:.4,luminanceSmoothing:.3,mipmapBlur:!0,intensity:3,mipmapBlurPassRadius:.85,blendFunction:b.BlendFunction.ADD,ignoreBackground:!0,epsilon:.001},ye={mode:b.ToneMappingMode.REINHARD2_ADAPTIVE,resolution:256,whitePoint:16,middleGrey:.6,minLuminance:.01,averageLuminance:.01,adaptationRate:1};class Ce{constructor(t){this.active=!0,this.options=t;const{renderer:e,scene:s,camera:i,composerParams:o}=t,{multisampling:r,frameBufferType:a}=o,{maxSamples:h}=e.capabilities,c=new b.EffectComposer(e,{multisampling:Math.min(r,h),frameBufferType:a});this.renderPass=new b.RenderPass(s,i),c.addPass(this.renderPass),this.finalComposer=c,this.renderer=e,this.scene=s,this.camera=i}setRenderPassCamera(t){this.renderPass.mainCamera=t}resetRenderPassCamera(){this.renderPass.mainCamera=this.camera}addCopyPass(){const t=new b.CopyPass;this.finalComposer.addPass(t),this.copyPass=t}addCrossFadePass(){const t=new Ee;this.finalComposer.addPass(t),this.crossFadePass=t}addFXAAPass(){const{camera:t}=this,e=new b.FXAAEffect({blendFunction:b.BlendFunction.NORMAL}),s=new b.EffectPass(t,e);this.finalComposer.addPass(s),this.fxaaPass=s}addToneMappingPass(t){const{camera:e}=this,s=new b.ToneMappingEffect(I({},t));this.toneMappingEffect=s;const i=new b.EffectPass(e,s);this.finalComposer.addPass(i),this.toneMappingPass=i}addToneMappingGui(t){if(!this.toneMappingEffect)return;new lt({toneMapping:{blendFunction:{value:this.toneMappingEffect.mode,items:b.ToneMappingMode,onChange:s=>{this.toneMappingEffect.mode=Number(s)}},exposure:{min:0,max:2,value:this.renderer.toneMappingExposure,step:.001,onChange:s=>{this.renderer.toneMappingExposure=s}}},"Reinhard (Modified)":{whitePoint:{min:2,max:32,step:.001,target:()=>this.toneMappingEffect},middleGrey:{min:0,max:1,step:1e-4,target:()=>this.toneMappingEffect},averageLuminance:{min:1e-4,max:1,step:1e-4,target:()=>this.toneMappingEffect}}}).showGui(t)}addBloomPass(t){const{camera:e,scene:s}=this,p=I(I({},kt),t),{epsilon:i,ignoreBackground:o,mipmapBlurPassRadius:r}=p,a=Tt(p,["epsilon","ignoreBackground","mipmapBlurPassRadius"]),h=new b.SelectiveBloomEffect(s,e,I({},a));o&&(h.ignoreBackground=o),r&&(h.mipmapBlurPass.radius=r),h.depthMaskMaterial.epsilon=i,h.luminancePass.enabled=!1,h.luminancePass.enabled=t.luminancePass;const c=new b.EffectPass(e,h);this.finalComposer.addPass(c),this.bloomPass=c,this.bloomEffect=h}addBloomGui(t){if(!this.bloomEffect)return;new lt({bloom:{intensity:{min:0,max:10,step:.01,target:()=>this.bloomEffect},radius:{min:0,max:1,step:.001,target:()=>this.bloomEffect.mipmapBlurPass},blendFunction:{value:this.bloomEffect.blendMode.blendFunction,items:b.BlendFunction,onChange:s=>{this.bloomEffect.blendMode.blendFunction=Number(s)}},ignoreBackground:{value:this.bloomEffect.ignoreBackground,onChange:s=>{this.bloomEffect.ignoreBackground=s}}},bloomLuminanceFilter:{enabled:{value:this.bloomEffect.luminancePass.enabled,onChange:s=>{this.bloomEffect.luminancePass.enabled=s}},threshold:{min:0,max:1,step:.01,target:()=>this.bloomEffect.luminanceMaterial},smoothing:{min:0,max:1,step:.01,target:()=>this.bloomEffect.luminanceMaterial}}}).showGui(t)}toggleBloomSelection(t,e){if(!this.bloomEffect||!this.bloomPass){console.warn("err:pencil.options.bloom");return}t?e===!0?this.bloomEffect.selection.add(t):e===!1?this.bloomEffect.selection.delete(t):this.bloomEffect.selection.toggle(t):this.bloomEffect.selection.clear()}getSize(){const{renderer:t}=this.options;return t.getSize(new x.Vector2)}enable(){this.active||(this.active=!0)}disable(){this.active&&(this.active=!1)}setSize(t,e){this.finalComposer.setSize(t,e)}render(){this.active&&this.finalComposer.render()}render2(){this.active}dispose(){this.finalComposer.dispose()}}const Oe=()=>{try{const d=document.createElement("canvas");return!!(window.WebGL2RenderingContext&&d.getContext("webgl2"))}catch(d){return!1}},$=!1,zt=Oe()!==!1,dt=class dt{constructor(t,e){this.raycaster=new x.Raycaster,this.installPlugins=new Map,this.event=new Ft.eventsExports.EventEmitter,this.clock=new x.Clock,this.userData={},this.pipViewportState=!1,this.options=jt(dt.options,t,{isMergeableObject:ie.isPlainObject}),this.event.setMaxListeners(1/0);const{container:s,stats:i,gui:o,resizeObserver:r}=this.options;if(o){const a=new Qt;a.open(!1),this.gui=a}if(i){const a=new Gt;a.showPanel(0),a.dom.style.position="absolute",s.appendChild(a.dom),this.stats=a}this.init(),this.initComposer(),this.initCSSRenderer(),this.initControls(),r&&this.initResizeObserver(),this.clock.getDelta(),this.clock.getElapsedTime(),e&&(Array.isArray(e)||(e=[e]),e.forEach(a=>{Array.isArray(a)||(a=[a]),this.use(a[0],a[1])}))}getPlugin(t){return this.installPlugins.get(t)}get renderer(){return this.rendererController.renderer}get cameraControls(){return this.controlsController.cameraControls}get cameraPositon(){return this.cameraControls.getPosition(new x.Vector3,!1)}get cameraTarget(){return this.cameraControls.getTarget(new x.Vector3,!1)}get camera(){return this.cameraController.camera}get scene(){return this.sceneController.scene}use(t,...e){this.installPlugins.has(t.pluginName)?console.log("plugin already installed"):typeof t.install=="function"&&(t.install(this,...e),this.installPlugins.set(t.pluginName,t))}init(){const{container:t,isdev:e,helper:s,renderer:i,scene:o,camera:r,control:a}=this.options,{width:h,height:c}=this.getSize(),p=new ce({isdev:e,width:h,height:c,cameraParams:r,cameraControls:a===!0});this.gui&&p.setGui(this.gui);const m=p.camera,E=new me({camera:m,sceneParams:o}),u=E.scene,D=new he({width:h,height:c,scene:u,camera:m,isdev:e,rendererParams:ot(I({},i),{antialias:!1})});if(s){const g=new _e({scene:u});g.add(u),this.helperController=g}this.sceneController=E,this.rendererController=D,this.cameraController=p,t.appendChild(D.renderer.domElement)}initComposer(){const{bloom:t,bloomParams:e,toneMapping:s,toneMappingParams:i,crossOpacity:o,renderer:r,multisampling:a,frameBufferType:h,passes:c}=this.options;let{antialias:p}=r;p==="msaa"&&!zt&&(p=!1,console.warn("MSAA is not supported on this browser"));const m=new Ce({renderer:this.renderer,scene:this.scene,camera:this.camera,composerParams:{multisampling:p==="msaa"?a:0,frameBufferType:s?x.HalfFloatType:h}});this.composerController=m,t&&(m.addBloomPass(e),this.gui&&m.addBloomGui(this.gui)),s&&(m.addToneMappingPass(i),this.gui&&m.addToneMappingGui(this.gui)),p==="fxaa"&&m.addFXAAPass(),o&&m.addCrossFadePass(),c&&c.forEach(E=>{m.finalComposer.addPass(E)}),m.finalComposer.passes.length===1&&m.addCopyPass()}get opacity(){const{crossFadePass:t}=this.composerController;return t?t.fullscreenMaterial.uniforms.ratio.value:1}set opacity(t){const{crossFadePass:e}=this.composerController;if(!e){console.warn("err:pencil.options.crossOpacity");return}e.fullscreenMaterial.uniforms.ratio.value=t}initCSSRenderer(){const{container:t,css2DRenderer:e,css3DRenderer:s,css2DRendererParams:i,css3DRendererParams:o}=this.options;if(e||s){const r=new fe(t);e&&r.addRenderer("css2d",i),s&&r.addRenderer("css3d",o),this.cssRendererController=r}}initControls(){const{control:t,controlParams:e,transformControls:s}=this.options;if(t){const i=new pe({camera:this.camera,controlsParams:{domElement:(e==null?void 0:e.domElement)||this.renderer.domElement},customControl:typeof t=="boolean"?void 0:t});this.controlsController=i}if(s){const i=new ue({camera:this.camera,renderer:this.renderer,scene:this.scene});i.event.on("mouseDown",()=>{var o;(o=this.controlsController)==null||o.disable()}),i.event.on("mouseUp",()=>{var o;(o=this.controlsController)==null||o.enable()}),this.transformController=i}}getSize(){const{container:t}=this.options;return{width:t.offsetWidth,height:t.offsetHeight}}initResizeObserver(){const{container:t}=this.options;if(this.resizeObserver)return;const e=new ResizeObserver(s=>{for(const i of s){const o=i.contentRect;this.handeleResize(o.width,o.height),this.render()}});e.observe(t),this.resizeObserver=e}handeleResize(t,e,s=!0){const{rendererController:i,cameraController:o,composerController:r,cssRendererController:a}=this;o==null||o.setSize(t,e),i==null||i.setSize(t,e),r==null||r.setSize(t,e),a==null||a.setSize(t,e),this.installPlugins.forEach(h=>{var c;(c=h.setSize)==null||c.call(h,t,e)}),s&&this.event.emit("resize",{width:t,height:e})}pick(t,e,s=!1){const{raycaster:i,options:o}=this,{container:r}=o,a=new x.Vector2,h=r.getBoundingClientRect();if(a.x=(t.clientX-h.left)/(h.right-h.left)*2-1,a.y=-((t.clientY-h.top)/(h.bottom-h.top))*2+1,this.camera&&this.scene){i.setFromCamera(a,this.camera);const c=i.intersectObjects(e||this.scene.children,s);if(c.length)return{object:c[0].object,intersects:c}}}render(){var r,a,h,c,p,m;const{scene:t,camera:e,clock:s}=this,i=s.getDelta(),o=s.getElapsedTime();Pt.update(),(r=this.controlsController)==null||r.update(i),this.installPlugins.forEach(E=>{var u;(u=E.update)==null||u.call(E,i,o)}),(a=this.helperController)==null||a.update(),(h=this.composerController)!=null&&h.active?this.cameraController.camera2?(this.composerController.resetRenderPassCamera(),this.setViewportFull(),this.composerController.render(),this.pipViewportState&&(this.setViewportPip(),this.composerController.setRenderPassCamera(this.cameraController.camera2),this.composerController.render())):this.composerController.render():(c=this.rendererController)==null||c.render(),(p=this.cssRendererController)==null||p.render(t,e),(m=this.stats)==null||m.update(),this.event.emit("render",{delta:i,elapsed:o})}start(){this.renderer.setAnimationLoop(this.render.bind(this)),this.event.emit("start")}stop(){this.renderer.setAnimationLoop(null),this.event.emit("stop")}autoRotate(t){this.controlsController.autoRotateSpeed=t}showPipViewport(t){if(t===!0){const e=this.getSize(),s=240,i=s/e.width,o=s/e.height,r=1-i,a=1-o;t={left:r,top:a,width:i,height:o}}if(this.pipViewportState=t,t){if(this.controlsController.cameraControls2)this.controlsController.cameraControls2.enabled=!0,this.cameraController.camera2.position.copy(this.cameraController.camera.position);else{const e=this.cameraController.addCamera2();this.controlsController.addCameraControls2(e)}this.controlsController.cameraControls2.interactiveArea=new DOMRect(t.left,t.top,t.width,t.height)}else this.controlsController.cameraControls2&&(this.controlsController.cameraControls2.enabled=!1)}setViewportFull(){const t=this.getSize(),e=0,s=0,i=t.width,o=t.height,r=i/o;this.camera.aspect!==r&&(this.camera.aspect=r,this.camera.updateProjectionMatrix()),this.renderer.setViewport(e,s,i,o),this.renderer.setScissor(e,s,i,o),this.renderer.setScissorTest(!0)}setViewportPip(){if(!this.pipViewportState)return;const t=this.pipViewportState,e=this.getSize(),s=e.width*t.left,i=(1-(t.top+t.height))*e.height,o=e.width*t.width,r=e.height*t.height,a=o/r,h=this.cameraController.camera2;h&&h.aspect!==a&&(h.aspect=a,h.updateProjectionMatrix()),this.renderer.setViewport(s,i,o,r),this.renderer.setScissor(s,i,o,r),this.renderer.setScissorTest(!0)}dispose(){var t,e,s,i,o,r,a,h,c,p,m;this.stop(),Pt.removeAll(),this.event.removeAllListeners(),(t=this.resizeObserver)==null||t.unobserve(this.options.container),this.handeleResize(0,0),this.installPlugins.forEach(E=>{var u;(u=E.dispose)==null||u.call(E)}),(e=this.controlsController)==null||e.dispose(),(s=this.transformController)==null||s.dispose(),(i=this.cssRendererController)==null||i.dispose(),(o=this.sceneController)==null||o.dispose(),(r=this.helperController)==null||r.dispose(),(a=this.composerController)==null||a.dispose(),(h=this.rendererController)==null||h.dispose(),this.cssRendererController=void 0,(c=this.gui)==null||c.destroy(),this.installPlugins.clear(),(p=this.stats)==null||p.dom.remove(),(m=this.renderer)==null||m.domElement.remove()}};dt.options={isdev:$,stats:$,gui:$,helper:$,control:!0,transformControls:$,resizeObserver:!0,renderer:ot(I({},ae),{antialias:zt?"msaa":"fxaa"}),multisampling:4,frameBufferType:x.UnsignedByteType,scene:de,camera:le,bloom:!1,bloomParams:kt,toneMapping:!1,toneMappingParams:ye,crossOpacity:!1,css2DRenderer:!1,css2DRendererParams:I({},bt),css3DRenderer:!1,css3DRendererParams:I({},bt)};let ct=dt;const Te=Z.ACTION;exports.BaseObject=oe.BaseObject;exports.GUIObject=lt;exports.Pencil=ct;exports.cameraControlsAction=Te;exports.default=ct;
18
+ `,toneMapped:!1,depthWrite:!1,depthTest:!1})}}class Ee extends b.Pass{constructor(){super("CrossFadePass"),this.fullscreenMaterial=new ge}render(t,e,s){const i=this.fullscreenMaterial;i.uniforms.inputBuffer.value=e.texture,t.setRenderTarget(this.renderToScreen?null:s),t.render(this.scene,this.camera)}}const kt={luminancePass:!1,luminanceThreshold:.4,luminanceSmoothing:.3,mipmapBlur:!0,intensity:3,mipmapBlurPassRadius:.85,blendFunction:b.BlendFunction.ADD,ignoreBackground:!0,epsilon:.001},ye={mode:b.ToneMappingMode.REINHARD2_ADAPTIVE,resolution:256,whitePoint:16,middleGrey:.6,minLuminance:.01,averageLuminance:.01,adaptationRate:1};class Ce{constructor(t){this.active=!0,this.options=t;const{renderer:e,scene:s,camera:i,composerParams:o}=t,{multisampling:r,frameBufferType:a}=o,{maxSamples:h}=e.capabilities,c=new b.EffectComposer(e,{multisampling:Math.min(r,h),frameBufferType:a});this.renderPass=new b.RenderPass(s,i),c.addPass(this.renderPass),this.finalComposer=c,this.renderer=e,this.scene=s,this.camera=i}setRenderPassCamera(t){this.renderPass.mainCamera=t}resetRenderPassCamera(){this.renderPass.mainCamera=this.camera}addCopyPass(){const t=new b.CopyPass;this.finalComposer.addPass(t),this.copyPass=t}addCrossFadePass(){const t=new Ee;this.finalComposer.addPass(t),this.crossFadePass=t}addFXAAPass(){const{camera:t}=this,e=new b.FXAAEffect({blendFunction:b.BlendFunction.NORMAL}),s=new b.EffectPass(t,e);this.finalComposer.addPass(s),this.fxaaPass=s}addToneMappingPass(t){const{camera:e}=this,s=new b.ToneMappingEffect(I({},t));this.toneMappingEffect=s;const i=new b.EffectPass(e,s);this.finalComposer.addPass(i),this.toneMappingPass=i}addToneMappingGui(t){if(!this.toneMappingEffect)return;new lt({toneMapping:{blendFunction:{value:this.toneMappingEffect.mode,items:b.ToneMappingMode,onChange:s=>{this.toneMappingEffect.mode=Number(s)}},exposure:{min:0,max:2,value:this.renderer.toneMappingExposure,step:.001,onChange:s=>{this.renderer.toneMappingExposure=s}}},"Reinhard (Modified)":{whitePoint:{min:2,max:32,step:.001,target:()=>this.toneMappingEffect},middleGrey:{min:0,max:1,step:1e-4,target:()=>this.toneMappingEffect},averageLuminance:{min:1e-4,max:1,step:1e-4,target:()=>this.toneMappingEffect}}}).showGui(t)}addBloomPass(t){const{camera:e,scene:s}=this,p=I(I({},kt),t),{epsilon:i,ignoreBackground:o,mipmapBlurPassRadius:r}=p,a=Tt(p,["epsilon","ignoreBackground","mipmapBlurPassRadius"]),h=new b.SelectiveBloomEffect(s,e,I({},a));o&&(h.ignoreBackground=o),r&&(h.mipmapBlurPass.radius=r),h.depthMaskMaterial.epsilon=i,h.luminancePass.enabled=!1,h.luminancePass.enabled=t.luminancePass;const c=new b.EffectPass(e,h);this.finalComposer.addPass(c),this.bloomPass=c,this.bloomEffect=h}addBloomGui(t){if(!this.bloomEffect)return;new lt({bloom:{intensity:{min:0,max:10,step:.01,target:()=>this.bloomEffect},radius:{min:0,max:1,step:.001,target:()=>this.bloomEffect.mipmapBlurPass},blendFunction:{value:this.bloomEffect.blendMode.blendFunction,items:b.BlendFunction,onChange:s=>{this.bloomEffect.blendMode.blendFunction=Number(s)}},ignoreBackground:{value:this.bloomEffect.ignoreBackground,onChange:s=>{this.bloomEffect.ignoreBackground=s}}},bloomLuminanceFilter:{enabled:{value:this.bloomEffect.luminancePass.enabled,onChange:s=>{this.bloomEffect.luminancePass.enabled=s}},threshold:{min:0,max:1,step:.01,target:()=>this.bloomEffect.luminanceMaterial},smoothing:{min:0,max:1,step:.01,target:()=>this.bloomEffect.luminanceMaterial}}}).showGui(t)}toggleBloomSelection(t,e){if(!this.bloomEffect||!this.bloomPass){console.warn("err:pencil.options.bloom");return}t?e===!0?this.bloomEffect.selection.add(t):e===!1?this.bloomEffect.selection.delete(t):this.bloomEffect.selection.toggle(t):this.bloomEffect.selection.clear()}getSize(){const{renderer:t}=this.options;return t.getSize(new x.Vector2)}enable(){this.active||(this.active=!0)}disable(){this.active&&(this.active=!1)}setSize(t,e){this.finalComposer.setSize(t,e)}render(){this.active&&this.finalComposer.render()}render2(){this.active}dispose(){this.finalComposer.dispose()}}const Oe=()=>{try{const d=document.createElement("canvas");return!!(window.WebGL2RenderingContext&&d.getContext("webgl2"))}catch(d){return!1}},$=!1,zt=Oe()!==!1,dt=class dt{constructor(t,e){this.raycaster=new x.Raycaster,this.installPlugins=new Map,this.event=new Ft.eventsExports.EventEmitter,this.clock=new x.Clock,this.userData={},this.pipViewportState=!1,this.options=jt(dt.options,t,{isMergeableObject:ie.isPlainObject}),this.event.setMaxListeners(1/0);const{container:s,stats:i,gui:o,resizeObserver:r}=this.options;if(o){const a=new Qt;a.open(!1),this.gui=a}if(i){const a=new Gt;a.showPanel(0),a.dom.style.position="absolute",s.appendChild(a.dom),this.stats=a}this.init(),this.initComposer(),this.initCSSRenderer(),this.initControls(),r&&this.initResizeObserver(),this.clock.getDelta(),this.clock.getElapsedTime(),e&&(Array.isArray(e)||(e=[e]),e.forEach(a=>{Array.isArray(a)||(a=[a]),this.use(a[0],a[1])}))}getPlugin(t){return this.installPlugins.get(t)}get renderer(){return this.rendererController.renderer}get maxAnisotropy(){return this.renderer.capabilities.getMaxAnisotropy()}get cameraControls(){return this.controlsController.cameraControls}get cameraPositon(){return this.cameraControls.getPosition(new x.Vector3,!1)}get cameraTarget(){return this.cameraControls.getTarget(new x.Vector3,!1)}get camera(){return this.cameraController.camera}get scene(){return this.sceneController.scene}use(t,...e){this.installPlugins.has(t.pluginName)?console.log("plugin already installed"):typeof t.install=="function"&&(t.install(this,...e),this.installPlugins.set(t.pluginName,t))}init(){const{container:t,isdev:e,helper:s,renderer:i,scene:o,camera:r,control:a}=this.options,{width:h,height:c}=this.getSize(),p=new ce({isdev:e,width:h,height:c,cameraParams:r,cameraControls:a===!0});this.gui&&p.setGui(this.gui);const m=p.camera,E=new me({camera:m,sceneParams:o}),u=E.scene,D=new he({width:h,height:c,scene:u,camera:m,isdev:e,rendererParams:ot(I({},i),{antialias:!1})});if(s){const g=new _e({scene:u});g.add(u),this.helperController=g}this.sceneController=E,this.rendererController=D,this.cameraController=p,t.appendChild(D.renderer.domElement)}initComposer(){const{bloom:t,bloomParams:e,toneMapping:s,toneMappingParams:i,crossOpacity:o,renderer:r,multisampling:a,frameBufferType:h,passes:c}=this.options;let{antialias:p}=r;p==="msaa"&&!zt&&(p=!1,console.warn("MSAA is not supported on this browser"));const m=new Ce({renderer:this.renderer,scene:this.scene,camera:this.camera,composerParams:{multisampling:p==="msaa"?a:0,frameBufferType:s?x.HalfFloatType:h}});this.composerController=m,t&&(m.addBloomPass(e),this.gui&&m.addBloomGui(this.gui)),s&&(m.addToneMappingPass(i),this.gui&&m.addToneMappingGui(this.gui)),p==="fxaa"&&m.addFXAAPass(),o&&m.addCrossFadePass(),c&&c.forEach(E=>{m.finalComposer.addPass(E)}),m.finalComposer.passes.length===1&&m.addCopyPass()}get opacity(){const{crossFadePass:t}=this.composerController;return t?t.fullscreenMaterial.uniforms.ratio.value:1}set opacity(t){const{crossFadePass:e}=this.composerController;if(!e){console.warn("err:pencil.options.crossOpacity");return}e.fullscreenMaterial.uniforms.ratio.value=t}initCSSRenderer(){const{container:t,css2DRenderer:e,css3DRenderer:s,css2DRendererParams:i,css3DRendererParams:o}=this.options;if(e||s){const r=new fe(t);e&&r.addRenderer("css2d",i),s&&r.addRenderer("css3d",o),this.cssRendererController=r}}initControls(){const{control:t,controlParams:e,transformControls:s}=this.options;if(t){const i=new pe({camera:this.camera,controlsParams:{domElement:(e==null?void 0:e.domElement)||this.renderer.domElement},customControl:typeof t=="boolean"?void 0:t});this.controlsController=i}if(s){const i=new ue({camera:this.camera,renderer:this.renderer,scene:this.scene});i.event.on("mouseDown",()=>{var o;(o=this.controlsController)==null||o.disable()}),i.event.on("mouseUp",()=>{var o;(o=this.controlsController)==null||o.enable()}),this.transformController=i}}getSize(){const{container:t}=this.options;return{width:t.offsetWidth,height:t.offsetHeight}}initResizeObserver(){const{container:t}=this.options;if(this.resizeObserver)return;const e=new ResizeObserver(s=>{for(const i of s){const o=i.contentRect;this.handeleResize(o.width,o.height),this.render()}});e.observe(t),this.resizeObserver=e}handeleResize(t,e,s=!0){const{rendererController:i,cameraController:o,composerController:r,cssRendererController:a}=this;o==null||o.setSize(t,e),i==null||i.setSize(t,e),r==null||r.setSize(t,e),a==null||a.setSize(t,e),this.installPlugins.forEach(h=>{var c;(c=h.setSize)==null||c.call(h,t,e)}),s&&this.event.emit("resize",{width:t,height:e})}pick(t,e,s=!1){const{raycaster:i,options:o}=this,{container:r}=o,a=new x.Vector2,h=r.getBoundingClientRect();if(a.x=(t.clientX-h.left)/(h.right-h.left)*2-1,a.y=-((t.clientY-h.top)/(h.bottom-h.top))*2+1,this.camera&&this.scene){i.setFromCamera(a,this.camera);const c=i.intersectObjects(e||this.scene.children,s);if(c.length)return{object:c[0].object,intersects:c}}}render(){var r,a,h,c,p,m;const{scene:t,camera:e,clock:s}=this,i=s.getDelta(),o=s.getElapsedTime();Pt.update(),(r=this.controlsController)==null||r.update(i),this.installPlugins.forEach(E=>{var u;(u=E.update)==null||u.call(E,i,o)}),(a=this.helperController)==null||a.update(),(h=this.composerController)!=null&&h.active?this.cameraController.camera2?(this.composerController.resetRenderPassCamera(),this.setViewportFull(),this.composerController.render(),this.pipViewportState&&(this.setViewportPip(),this.composerController.setRenderPassCamera(this.cameraController.camera2),this.composerController.render())):this.composerController.render():(c=this.rendererController)==null||c.render(),(p=this.cssRendererController)==null||p.render(t,e),(m=this.stats)==null||m.update(),this.event.emit("render",{delta:i,elapsed:o})}start(){this.renderer.setAnimationLoop(this.render.bind(this)),this.event.emit("start")}stop(){this.renderer.setAnimationLoop(null),this.event.emit("stop")}autoRotate(t){this.controlsController.autoRotateSpeed=t}showPipViewport(t){if(t===!0){const e=this.getSize(),s=240,i=s/e.width,o=s/e.height,r=1-i,a=1-o;t={left:r,top:a,width:i,height:o}}if(this.pipViewportState=t,t){if(this.controlsController.cameraControls2)this.controlsController.cameraControls2.enabled=!0,this.cameraController.camera2.position.copy(this.cameraController.camera.position);else{const e=this.cameraController.addCamera2();this.controlsController.addCameraControls2(e)}this.controlsController.cameraControls2.interactiveArea=new DOMRect(t.left,t.top,t.width,t.height)}else this.controlsController.cameraControls2&&(this.controlsController.cameraControls2.enabled=!1)}setViewportFull(){const t=this.getSize(),e=0,s=0,i=t.width,o=t.height,r=i/o;this.camera.aspect!==r&&(this.camera.aspect=r,this.camera.updateProjectionMatrix()),this.renderer.setViewport(e,s,i,o),this.renderer.setScissor(e,s,i,o),this.renderer.setScissorTest(!0)}setViewportPip(){if(!this.pipViewportState)return;const t=this.pipViewportState,e=this.getSize(),s=e.width*t.left,i=(1-(t.top+t.height))*e.height,o=e.width*t.width,r=e.height*t.height,a=o/r,h=this.cameraController.camera2;h&&h.aspect!==a&&(h.aspect=a,h.updateProjectionMatrix()),this.renderer.setViewport(s,i,o,r),this.renderer.setScissor(s,i,o,r),this.renderer.setScissorTest(!0)}dispose(){var t,e,s,i,o,r,a,h,c,p,m;this.stop(),Pt.removeAll(),this.event.removeAllListeners(),(t=this.resizeObserver)==null||t.unobserve(this.options.container),this.handeleResize(0,0),this.installPlugins.forEach(E=>{var u;(u=E.dispose)==null||u.call(E)}),(e=this.controlsController)==null||e.dispose(),(s=this.transformController)==null||s.dispose(),(i=this.cssRendererController)==null||i.dispose(),(o=this.sceneController)==null||o.dispose(),(r=this.helperController)==null||r.dispose(),(a=this.composerController)==null||a.dispose(),(h=this.rendererController)==null||h.dispose(),this.cssRendererController=void 0,(c=this.gui)==null||c.destroy(),this.installPlugins.clear(),(p=this.stats)==null||p.dom.remove(),(m=this.renderer)==null||m.domElement.remove()}};dt.options={isdev:$,stats:$,gui:$,helper:$,control:!0,transformControls:$,resizeObserver:!0,renderer:ot(I({},ae),{antialias:zt?"msaa":"fxaa"}),multisampling:4,frameBufferType:x.UnsignedByteType,scene:de,camera:le,bloom:!1,bloomParams:kt,toneMapping:!1,toneMappingParams:ye,crossOpacity:!1,css2DRenderer:!1,css2DRendererParams:I({},bt),css3DRenderer:!1,css3DRendererParams:I({},bt)};let ct=dt;const Te=Z.ACTION;exports.BaseObject=oe.BaseObject;exports.GUIObject=lt;exports.Pencil=ct;exports.cameraControlsAction=Te;exports.default=ct;
@@ -39,7 +39,7 @@ import { CSS2DRenderer as oe } from "three/examples/jsm/renderers/CSS2DRenderer"
39
39
  import { Pass as re, BlendFunction as ft, ToneMappingMode as Ht, EffectComposer as ne, RenderPass as ae, CopyPass as he, FXAAEffect as le, EffectPass as lt, ToneMappingEffect as ce, SelectiveBloomEffect as de } from "postprocessing";
40
40
  import { i as me } from "./isPlainObject.module.js";
41
41
  import { B as We } from "./BaseObject.module.js";
42
- const R = {
42
+ const A = {
43
43
  LEFT: 1,
44
44
  RIGHT: 2,
45
45
  MIDDLE: 4
@@ -112,8 +112,8 @@ function wt(d, t, e, s, i = 1 / 0, o, r) {
112
112
  u = u / ht * y, D = D / ht * y, g = g / ht * y;
113
113
  }
114
114
  p = d.x - u, m = d.y - D, E = d.z - g;
115
- const O = (e.x + a * u) * o, L = (e.y + a * D) * o, A = (e.z + a * g) * o;
116
- e.x = (e.x - a * O) * c, e.y = (e.y - a * L) * c, e.z = (e.z - a * A) * c, r.x = p + (u + O) * c, r.y = m + (D + L) * c, r.z = E + (g + A) * c;
115
+ const O = (e.x + a * u) * o, L = (e.y + a * D) * o, R = (e.z + a * g) * o;
116
+ e.x = (e.x - a * O) * c, e.y = (e.y - a * L) * c, e.z = (e.z - a * R) * c, r.x = p + (u + O) * c, r.y = m + (D + L) * c, r.z = E + (g + R) * c;
117
117
  const $ = U - d.x, tt = l - d.y, Vt = _ - d.z, Yt = r.x - U, Zt = r.y - l, Nt = r.z - _;
118
118
  return $ * Yt + tt * Zt + Vt * Nt > 0 && (r.x = U, r.y = l, r.z = _, e.x = (r.x - U) / o, e.y = (r.y - l) / o, e.z = (r.z - _) / o), r;
119
119
  }
@@ -190,7 +190,7 @@ class _e {
190
190
  }
191
191
  }
192
192
  const ot = 1 / 8, pe = /Mac/.test(navigator.platform);
193
- let C, Ut, rt, mt, b, T, x, X, q, I, H, V, St, Lt, z, W, K, Rt, _t, At, pt, ut, nt;
193
+ let C, Ut, rt, mt, b, T, x, X, q, I, H, V, St, Lt, z, W, K, At, _t, Rt, pt, ut, nt;
194
194
  class Y extends _e {
195
195
  /**
196
196
  * Injects THREE as the dependency. You can then proceed to use CameraControls.
@@ -233,7 +233,7 @@ class Y extends _e {
233
233
  * @category Statics
234
234
  */
235
235
  static install(t) {
236
- C = t.THREE, Ut = Object.freeze(new C.Vector3(0, 0, 0)), rt = Object.freeze(new C.Vector3(0, 1, 0)), mt = Object.freeze(new C.Vector3(0, 0, 1)), b = new C.Vector2(), T = new C.Vector3(), x = new C.Vector3(), X = new C.Vector3(), q = new C.Vector3(), I = new C.Vector3(), H = new C.Vector3(), V = new C.Vector3(), St = new C.Vector3(), Lt = new C.Vector3(), z = new C.Spherical(), W = new C.Spherical(), K = new C.Box3(), Rt = new C.Box3(), _t = new C.Sphere(), At = new C.Quaternion(), pt = new C.Quaternion(), ut = new C.Matrix4(), nt = new C.Raycaster();
236
+ C = t.THREE, Ut = Object.freeze(new C.Vector3(0, 0, 0)), rt = Object.freeze(new C.Vector3(0, 1, 0)), mt = Object.freeze(new C.Vector3(0, 0, 1)), b = new C.Vector2(), T = new C.Vector3(), x = new C.Vector3(), X = new C.Vector3(), q = new C.Vector3(), I = new C.Vector3(), H = new C.Vector3(), V = new C.Vector3(), St = new C.Vector3(), Lt = new C.Vector3(), z = new C.Spherical(), W = new C.Spherical(), K = new C.Box3(), At = new C.Box3(), _t = new C.Sphere(), Rt = new C.Quaternion(), pt = new C.Quaternion(), ut = new C.Matrix4(), nt = new C.Raycaster();
237
237
  }
238
238
  /**
239
239
  * list all ACTIONs
@@ -264,8 +264,8 @@ class Y extends _e {
264
264
  }, this._enabled = !0, this._state = n.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 = Z.NONE, this._thetaVelocity = { value: 0 }, this._phiVelocity = { value: 0 }, this._radiusVelocity = { value: 0 }, this._targetVelocity = new C.Vector3(), this._focalOffsetVelocity = new C.Vector3(), this._zoomVelocity = { value: 0 }, this._truckInternal = (l, _, y) => {
265
265
  let f, v;
266
266
  if (B(this._camera)) {
267
- const O = T.copy(this._camera.position).sub(this._target), L = this._camera.getEffectiveFOV() * G, A = O.length() * Math.tan(L * 0.5);
268
- f = this.truckSpeed * l * A / this._elementRect.height, v = this.truckSpeed * _ * A / this._elementRect.height;
267
+ const O = T.copy(this._camera.position).sub(this._target), L = this._camera.getEffectiveFOV() * G, R = O.length() * Math.tan(L * 0.5);
268
+ f = this.truckSpeed * l * R / this._elementRect.height, v = this.truckSpeed * _ * R / this._elementRect.height;
269
269
  } else if (k(this._camera)) {
270
270
  const O = this._camera;
271
271
  f = l * (O.right - O.left) / O.zoom / this._elementRect.width, v = _ * (O.top - O.bottom) / O.zoom / this._elementRect.height;
@@ -290,8 +290,8 @@ class Y extends _e {
290
290
  O,
291
291
  this.minDistance,
292
292
  this.maxDistance
293
- ), A = L - O;
294
- this.infinityDolly && this.dollyToCursor ? this._dollyToNoClamp(O, !0) : this.infinityDolly && !this.dollyToCursor ? (this.dollyInFixed(A, !0), this._dollyToNoClamp(L, !0)) : this._dollyToNoClamp(L, !0), this.dollyToCursor && (this._changedDolly += (this.infinityDolly ? O : L) - v, this._dollyControlCoord.set(_, y)), this._lastDollyDirection = Math.sign(-l);
293
+ ), R = L - O;
294
+ this.infinityDolly && this.dollyToCursor ? this._dollyToNoClamp(O, !0) : this.infinityDolly && !this.dollyToCursor ? (this.dollyInFixed(R, !0), this._dollyToNoClamp(L, !0)) : this._dollyToNoClamp(L, !0), this.dollyToCursor && (this._changedDolly += (this.infinityDolly ? O : L) - v, this._dollyControlCoord.set(_, y)), this._lastDollyDirection = Math.sign(-l);
295
295
  }, this._zoomInternal = (l, _, y) => {
296
296
  const f = Math.pow(0.95, l * this.dollySpeed), v = this._zoom, O = this._zoom * f;
297
297
  this.zoomTo(O, !0), this.dollyToCursor && (this._changedZoom += O - v, this._dollyControlCoord.set(_, y));
@@ -327,12 +327,12 @@ class Y extends _e {
327
327
  if (v < this._interactiveArea.left || v > this._interactiveArea.right || O < this._interactiveArea.top || O > this._interactiveArea.bottom)
328
328
  return;
329
329
  }
330
- const _ = l.pointerType !== "mouse" ? null : (l.buttons & R.LEFT) === R.LEFT ? R.LEFT : (l.buttons & R.MIDDLE) === R.MIDDLE ? R.MIDDLE : (l.buttons & R.RIGHT) === R.RIGHT ? R.RIGHT : null;
330
+ const _ = l.pointerType !== "mouse" ? null : (l.buttons & A.LEFT) === A.LEFT ? A.LEFT : (l.buttons & A.MIDDLE) === A.MIDDLE ? A.MIDDLE : (l.buttons & A.RIGHT) === A.RIGHT ? A.RIGHT : null;
331
331
  if (_ !== null) {
332
332
  const f = this._findPointerByMouseButton(_);
333
333
  f && this._disposePointer(f);
334
334
  }
335
- if ((l.buttons & R.LEFT) === R.LEFT && this._lockedPointer)
335
+ if ((l.buttons & A.LEFT) === A.LEFT && this._lockedPointer)
336
336
  return;
337
337
  const y = {
338
338
  pointerId: l.pointerId,
@@ -371,7 +371,7 @@ class Y extends _e {
371
371
  break;
372
372
  }
373
373
  else
374
- (!this._isDragging && this._lockedPointer || this._isDragging && (l.buttons & R.LEFT) === R.LEFT) && (this._state = this._state | this.mouseButtons.left), this._isDragging && (l.buttons & R.MIDDLE) === R.MIDDLE && (this._state = this._state | this.mouseButtons.middle), this._isDragging && (l.buttons & R.RIGHT) === R.RIGHT && (this._state = this._state | this.mouseButtons.right);
374
+ (!this._isDragging && this._lockedPointer || this._isDragging && (l.buttons & A.LEFT) === A.LEFT) && (this._state = this._state | this.mouseButtons.left), this._isDragging && (l.buttons & A.MIDDLE) === A.MIDDLE && (this._state = this._state | this.mouseButtons.middle), this._isDragging && (l.buttons & A.RIGHT) === A.RIGHT && (this._state = this._state | this.mouseButtons.right);
375
375
  u();
376
376
  }
377
377
  }, h = (l) => {
@@ -401,8 +401,8 @@ class Y extends _e {
401
401
  const p = (l) => {
402
402
  if (!this._domElement || !this._enabled || this.mouseButtons.wheel === n.NONE) return;
403
403
  if (this._interactiveArea.left !== 0 || this._interactiveArea.top !== 0 || this._interactiveArea.width !== 1 || this._interactiveArea.height !== 1) {
404
- const O = this._domElement.getBoundingClientRect(), L = (l.clientX - O.left) / (O.right - O.left), A = (l.clientY - O.top) / (O.bottom - O.top);
405
- if (L < this._interactiveArea.left || L > this._interactiveArea.right || A < this._interactiveArea.top || A > this._interactiveArea.bottom)
404
+ const O = this._domElement.getBoundingClientRect(), L = (l.clientX - O.left) / (O.right - O.left), R = (l.clientY - O.top) / (O.bottom - O.top);
405
+ if (L < this._interactiveArea.left || L > this._interactiveArea.right || R < this._interactiveArea.top || R > this._interactiveArea.bottom)
406
406
  return;
407
407
  }
408
408
  if (l.preventDefault(), this.dollyToCursor || this.mouseButtons.wheel === n.ROTATE || this.mouseButtons.wheel === n.TRUCK) {
@@ -472,7 +472,7 @@ class Y extends _e {
472
472
  break;
473
473
  }
474
474
  else
475
- !this._lockedPointer && (l.buttons & R.LEFT) === R.LEFT && (this._state = this._state | this.mouseButtons.left), (l.buttons & R.MIDDLE) === R.MIDDLE && (this._state = this._state | this.mouseButtons.middle), (l.buttons & R.RIGHT) === R.RIGHT && (this._state = this._state | this.mouseButtons.right);
475
+ !this._lockedPointer && (l.buttons & A.LEFT) === A.LEFT && (this._state = this._state | this.mouseButtons.left), (l.buttons & A.MIDDLE) === A.MIDDLE && (this._state = this._state | this.mouseButtons.middle), (l.buttons & A.RIGHT) === A.RIGHT && (this._state = this._state | this.mouseButtons.right);
476
476
  ((this._state & n.ROTATE) === n.ROTATE || (this._state & n.TOUCH_ROTATE) === n.TOUCH_ROTATE || (this._state & n.TOUCH_DOLLY_ROTATE) === n.TOUCH_DOLLY_ROTATE || (this._state & n.TOUCH_ZOOM_ROTATE) === n.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 & n.TRUCK) === n.TRUCK || (this._state & n.TOUCH_TRUCK) === n.TOUCH_TRUCK || (this._state & n.TOUCH_DOLLY_TRUCK) === n.TOUCH_DOLLY_TRUCK || (this._state & n.TOUCH_ZOOM_TRUCK) === n.TOUCH_ZOOM_TRUCK) && (this._targetEnd.copy(this._target), this._targetVelocity.set(0, 0, 0)), ((this._state & n.DOLLY) === n.DOLLY || (this._state & n.TOUCH_DOLLY) === n.TOUCH_DOLLY || (this._state & n.TOUCH_DOLLY_TRUCK) === n.TOUCH_DOLLY_TRUCK || (this._state & n.TOUCH_DOLLY_OFFSET) === n.TOUCH_DOLLY_OFFSET || (this._state & n.TOUCH_DOLLY_ROTATE) === n.TOUCH_DOLLY_ROTATE) && (this._sphericalEnd.radius = this._spherical.radius, this._radiusVelocity.value = 0), ((this._state & n.ZOOM) === n.ZOOM || (this._state & n.TOUCH_ZOOM) === n.TOUCH_ZOOM || (this._state & n.TOUCH_ZOOM_TRUCK) === n.TOUCH_ZOOM_TRUCK || (this._state & n.TOUCH_ZOOM_OFFSET) === n.TOUCH_ZOOM_OFFSET || (this._state & n.TOUCH_ZOOM_ROTATE) === n.TOUCH_ZOOM_ROTATE) && (this._zoomEnd = this._zoom, this._zoomVelocity.value = 0), ((this._state & n.OFFSET) === n.OFFSET || (this._state & n.TOUCH_OFFSET) === n.TOUCH_OFFSET || (this._state & n.TOUCH_DOLLY_OFFSET) === n.TOUCH_DOLLY_OFFSET || (this._state & n.TOUCH_ZOOM_OFFSET) === n.TOUCH_ZOOM_OFFSET) && (this._focalOffsetEnd.copy(this._focalOffset), this._focalOffsetVelocity.set(0, 0, 0)), this.dispatchEvent({ type: "controlstart" });
477
477
  }, u = () => {
478
478
  if (!this._enabled || !this._dragNeedsUpdate) return;
@@ -491,10 +491,10 @@ class Y extends _e {
491
491
  ), this._isUserControllingZoom = !0);
492
492
  }
493
493
  if ((this._state & n.TOUCH_DOLLY) === n.TOUCH_DOLLY || (this._state & n.TOUCH_ZOOM) === n.TOUCH_ZOOM || (this._state & n.TOUCH_DOLLY_TRUCK) === n.TOUCH_DOLLY_TRUCK || (this._state & n.TOUCH_ZOOM_TRUCK) === n.TOUCH_ZOOM_TRUCK || (this._state & n.TOUCH_DOLLY_OFFSET) === n.TOUCH_DOLLY_OFFSET || (this._state & n.TOUCH_ZOOM_OFFSET) === n.TOUCH_ZOOM_OFFSET || (this._state & n.TOUCH_DOLLY_ROTATE) === n.TOUCH_DOLLY_ROTATE || (this._state & n.TOUCH_ZOOM_ROTATE) === n.TOUCH_ZOOM_ROTATE) {
494
- const v = b.x - this._activePointers[1].clientX, O = b.y - this._activePointers[1].clientY, L = Math.sqrt(v * v + O * O), A = o.y - L;
494
+ const v = b.x - this._activePointers[1].clientX, O = b.y - this._activePointers[1].clientY, L = Math.sqrt(v * v + O * O), R = o.y - L;
495
495
  o.set(0, L);
496
496
  const $ = this.dollyToCursor ? (i.x - this._elementRect.x) / this._elementRect.width * 2 - 1 : 0, tt = this.dollyToCursor ? (i.y - this._elementRect.y) / this._elementRect.height * -2 + 1 : 0;
497
- (this._state & n.TOUCH_DOLLY) === n.TOUCH_DOLLY || (this._state & n.TOUCH_DOLLY_ROTATE) === n.TOUCH_DOLLY_ROTATE || (this._state & n.TOUCH_DOLLY_TRUCK) === n.TOUCH_DOLLY_TRUCK || (this._state & n.TOUCH_DOLLY_OFFSET) === n.TOUCH_DOLLY_OFFSET ? (this._dollyInternal(A * ot, $, tt), this._isUserControllingDolly = !0) : (this._zoomInternal(A * ot, $, tt), this._isUserControllingZoom = !0);
497
+ (this._state & n.TOUCH_DOLLY) === n.TOUCH_DOLLY || (this._state & n.TOUCH_DOLLY_ROTATE) === n.TOUCH_DOLLY_ROTATE || (this._state & n.TOUCH_DOLLY_TRUCK) === n.TOUCH_DOLLY_TRUCK || (this._state & n.TOUCH_DOLLY_OFFSET) === n.TOUCH_DOLLY_OFFSET ? (this._dollyInternal(R * ot, $, tt), this._isUserControllingDolly = !0) : (this._zoomInternal(R * ot, $, tt), this._isUserControllingZoom = !0);
498
498
  }
499
499
  ((this._state & n.TRUCK) === n.TRUCK || (this._state & n.TOUCH_TRUCK) === n.TOUCH_TRUCK || (this._state & n.TOUCH_DOLLY_TRUCK) === n.TOUCH_DOLLY_TRUCK || (this._state & n.TOUCH_ZOOM_TRUCK) === n.TOUCH_ZOOM_TRUCK) && (this._truckInternal(y, f, !1), this._isUserControllingTruck = !0), ((this._state & n.OFFSET) === n.OFFSET || (this._state & n.TOUCH_OFFSET) === n.TOUCH_OFFSET || (this._state & n.TOUCH_DOLLY_OFFSET) === n.TOUCH_DOLLY_OFFSET || (this._state & n.TOUCH_ZOOM_OFFSET) === n.TOUCH_ZOOM_OFFSET) && (this._truckInternal(y, f, !0), this._isUserControllingOffset = !0), this.dispatchEvent({ type: "control" });
500
500
  }, D = () => {
@@ -1001,9 +1001,9 @@ class Y extends _e {
1001
1001
  ), Promise.resolve());
1002
1002
  const p = Dt(this._sphericalEnd.theta, Pt), m = Dt(this._sphericalEnd.phi, Pt);
1003
1003
  h.push(this.rotateTo(p, m, e));
1004
- const E = T.setFromSpherical(this._sphericalEnd).normalize(), u = At.setFromUnitVectors(E, mt), D = w(Math.abs(E.y), 1);
1004
+ const E = T.setFromSpherical(this._sphericalEnd).normalize(), u = Rt.setFromUnitVectors(E, mt), D = w(Math.abs(E.y), 1);
1005
1005
  D && u.multiply(pt.setFromAxisAngle(rt, p)), u.multiply(this._yAxisUpSpaceInverse);
1006
- const g = Rt.makeEmpty();
1006
+ const g = At.makeEmpty();
1007
1007
  x.copy(c.min).applyQuaternion(u), g.expandByPoint(x), x.copy(c.min).setX(c.max.x).applyQuaternion(u), g.expandByPoint(x), x.copy(c.min).setY(c.max.y).applyQuaternion(u), g.expandByPoint(x), x.copy(c.max).setZ(c.min.z).applyQuaternion(u), g.expandByPoint(x), x.copy(c.min).setZ(c.max.z).applyQuaternion(u), g.expandByPoint(x), x.copy(c.max).setY(c.min.y).applyQuaternion(u), g.expandByPoint(x), x.copy(c.max).setX(c.min.x).applyQuaternion(u), g.expandByPoint(x), x.copy(c.max).applyQuaternion(u), g.expandByPoint(x), g.min.x -= i, g.min.y -= r, g.max.x += o, g.max.y += a, u.setFromUnitVectors(mt, E), D && u.premultiply(pt.invert()), u.premultiply(this._yAxisUpSpace);
1008
1008
  const U = g.getSize(T), l = g.getCenter(x).applyQuaternion(u);
1009
1009
  if (B(this._camera)) {
@@ -1473,8 +1473,8 @@ class Y extends _e {
1473
1473
  ), f = T.copy(this._targetEnd).lerp(y, _), v = this._lastDollyDirection === Z.IN && this._spherical.radius <= this.minDistance, O = this._lastDollyDirection === Z.OUT && this.maxDistance <= this._spherical.radius;
1474
1474
  if (this.infinityDolly && (v || O)) {
1475
1475
  this._sphericalEnd.radius -= m, this._spherical.radius -= m;
1476
- const A = x.copy(u).multiplyScalar(-m);
1477
- f.add(A);
1476
+ const R = x.copy(u).multiplyScalar(-m);
1477
+ f.add(R);
1478
1478
  }
1479
1479
  this._boundary.clampPoint(f, f);
1480
1480
  const L = x.subVectors(f, this._targetEnd);
@@ -2390,6 +2390,9 @@ const Se = () => {
2390
2390
  get renderer() {
2391
2391
  return this.rendererController.renderer;
2392
2392
  }
2393
+ get maxAnisotropy() {
2394
+ return this.renderer.capabilities.getMaxAnisotropy();
2395
+ }
2393
2396
  get cameraControls() {
2394
2397
  return this.controlsController.cameraControls;
2395
2398
  }
@@ -1,6 +1,11 @@
1
1
  import * as THREE from 'three';
2
+ interface Options {
3
+ type: 'image' | 'video';
4
+ }
2
5
  export default class extends THREE.Loader {
6
+ options: Options;
3
7
  constructor(manager?: THREE.LoadingManager);
4
- load(url: string, onLoad?: (texture: THREE.Texture) => void, onProgress?: any, onError?: any): THREE.Texture;
5
- loadAsync(url: string, onProgress?: any): Promise<THREE.Texture>;
8
+ setOptions(options: Options): this;
9
+ load(url: string, onLoad?: (texture: THREE.Texture) => void, onProgress?: any, onError?: any): THREE.Texture | THREE.VideoTexture;
6
10
  }
11
+ export {};
@@ -3,10 +3,7 @@ import { EventEmitter } from 'events';
3
3
  import { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader';
4
4
  import { DRACOLoader } from 'three/examples/jsm/loaders/DRACOLoader';
5
5
  import { EXRLoader } from 'three/examples/jsm/loaders/EXRLoader';
6
- import { makePromiseCreator } from 'esus-lite';
7
- import VideoTextureLoader from './VideoTextureLoader';
8
6
  import TextureLoader from './TextureLoader';
9
- import CacheLoader from './CacheLoader';
10
7
  import Pencil from "../../core/Pencil";
11
8
  type ValuesOf<T extends readonly any[]> = T[number];
12
9
  export declare const KNOWN_ASSET_TYPES: {
@@ -21,60 +18,38 @@ type TypeMedia = ValuesOf<(typeof KNOWN_ASSET_TYPES)['media']>;
21
18
  type TypeGLTF = ValuesOf<(typeof KNOWN_ASSET_TYPES)['gltf']>;
22
19
  type TypeJSON = ValuesOf<(typeof KNOWN_ASSET_TYPES)['json']>;
23
20
  type TypeEXR = ValuesOf<(typeof KNOWN_ASSET_TYPES)['exr']>;
24
- type AssetType = keyof typeof KNOWN_ASSET_TYPES;
25
- type Asset = {
26
- src: string;
27
- progress: {
28
- loaded: number;
29
- total: number;
30
- lengthComputable: boolean;
31
- };
21
+ interface AssetOptions {
32
22
  cacheVersion?: string;
33
- draco?: boolean;
23
+ dracoPath?: string;
34
24
  colorCorrection?: boolean;
25
+ anisotropy?: number;
26
+ }
27
+ interface Asset extends AssetOptions {
28
+ src: string;
35
29
  cacheData?: any;
36
- };
30
+ }
37
31
  interface Options {
38
32
  prefix?: string;
39
- anisotropy?: number;
40
33
  }
41
34
  export default class Loader {
42
35
  pluginName: string;
43
36
  loadingManager: THREE.LoadingManager;
44
37
  textureLoader?: TextureLoader;
45
- videoTextureLoader?: VideoTextureLoader;
38
+ videoTextureLoader?: TextureLoader;
46
39
  gltfLoader?: GLTFLoader;
47
40
  dracoGltfLoader?: GLTFLoader;
48
41
  jsonLoader?: THREE.FileLoader;
49
- fileLoader: THREE.FileLoader;
50
- cacheLoader: CacheLoader;
51
42
  dracoLoader?: DRACOLoader;
52
- EXRLoader?: EXRLoader;
53
- dracoPath?: string;
54
- itemsLoaded: number;
55
- itemsTotal: number;
43
+ exrLoader?: EXRLoader;
56
44
  prefix?: string;
57
- get allStarted(): boolean | 0;
58
- get lengthComputable(): boolean;
59
- get loaded(): number;
60
- get total(): number;
61
- get assetsLength(): number;
62
- loadObjOrigin: {
63
- [s in AssetType]: Asset[];
64
- };
65
- loadObj: {
66
- [s in AssetType]: Asset[];
67
- };
45
+ loadObj: Asset[];
68
46
  delLoadObj: Record<string, boolean>;
69
- assets: {
70
- [s in AssetType]: Map<string, THREE.Texture | THREE.Object3D | any>;
71
- };
47
+ assets: Map<string, THREE.Texture | THREE.Object3D | any>;
72
48
  event: EventEmitter;
73
49
  pencil: Pencil;
74
50
  constructor(options?: Options);
75
51
  emit(eventName: string, ...args: any[]): void;
76
52
  on(eventName: string, listener: (...args: any[]) => void): void;
77
- pm: ReturnType<typeof makePromiseCreator>;
78
53
  getAsset(src: `${string}.${TypeImage}`): THREE.Texture;
79
54
  getAsset(src: `${string}.${TypeMedia}`): THREE.VideoTexture;
80
55
  getAsset(src: `${string}.${TypeGLTF}`): {
@@ -85,22 +60,14 @@ export default class Loader {
85
60
  getAsset(src: string): THREE.Texture;
86
61
  getAssetType(src: string): "json" | "gltf" | "exr" | "images" | "media" | undefined;
87
62
  install(pencil: Pencil): void;
88
- initLoadingManager(): void;
89
- add(src: string | string[], options?: {
63
+ getLoader(type: string, options?: {
90
64
  dracoPath?: string;
91
- cacheVersion?: string;
92
- colorCorrection?: boolean;
93
- }): void;
65
+ }): TextureLoader | THREE.FileLoader | GLTFLoader | EXRLoader | undefined;
66
+ add(src: string | string[], options?: AssetOptions): void;
94
67
  setDel(src: string, del: boolean): void;
95
68
  getSrcByAsset(asset: THREE.Texture | THREE.Object3D | any): string | undefined;
96
- colorCorrection(): void;
97
- setAnisotropy(anisotropy: number | 'max'): void;
98
- end: boolean;
99
- onprogress(): void;
100
- loadCount: number;
101
- load({ prefix }?: Options): Promise<any>;
102
- checkCache(): Promise<void>;
103
- loadAssets(assetArr: Asset[], save: Map<string, any>, loader?: THREE.TextureLoader | GLTFLoader | THREE.FileLoader): void;
69
+ loadAll(): Promise<(THREE.Texture | undefined)[]>;
70
+ load(src: string, options?: AssetOptions): Promise<THREE.Texture | undefined>;
104
71
  clearLoadObj(): void;
105
72
  dispose(): void;
106
73
  }