gl-draw 0.10.7 → 0.10.8
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/index.js +1 -1
- package/dist/index.module.js +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -11,4 +11,4 @@
|
|
|
11
11
|
void main() {
|
|
12
12
|
gl_FragColor = ( texture2D( baseTexture, vUv ) + vec4( 1.0 ) * texture2D( bloomTexture, vUv ) );
|
|
13
13
|
}
|
|
14
|
-
`,defines:{}}),"baseTexture");l.needsSwap=!0,this.bloomComposer=a,this.finalComposer.addPass(l),this.mixPass=l,this.bloomLayer.set(ut)}addBloomGui(t){if(!this.bloomComposer)return;new ft({bloom:{threshold:{min:0,max:1,step:.01,target:()=>this.bloomPass},radius:{min:0,max:1,step:.001,target:()=>this.bloomPass},strength:{min:0,max:10,step:.001,target:()=>this.bloomPass}}}).showGui(t)}toggleBloomSelection(t,e){if(!this.bloomComposer){console.warn("err:pencil.options.bloom");return}const{object3d:s}=t;if(!s)return;let i=e;e===void 0&&(i=!this.bloomSelection.has(s)),i?(this.bloomSelection.add(s),s.layers.enable(ut)):(this.bloomSelection.delete(s),s.layers.disable(ut)),this.bloomSelection.size===0?this.bloomComposerActive=!1:this.bloomComposerActive=!0}enable(){this.active||(this.active=!0)}disable(){this.active&&(this.active=!1)}setSize(t,e){var s;(s=this.bloomComposer)==null||s.setSize(t,e),this.finalComposer.setSize(t,e)}render(){this.active&&(this.bloomComposerActive&&this.bloomComposer?(this.mixPass.enabled=!0,this.scene.traverse(t=>{const e=t;e.isMesh&&this.bloomLayer.test(e.layers)===!1&&(this.bloomMaterials[e.uuid]=e.material,e.material=Ce)}),this.bloomComposer.render(),this.scene.traverse(t=>{const e=t;this.bloomMaterials[e.uuid]&&(e.material=this.bloomMaterials[e.uuid],delete this.bloomMaterials[e.uuid])})):this.mixPass&&(this.mixPass.enabled=!1),this.finalComposer.render())}render2(){this.active}dispose(){var t;this.bloomMaterials={},this.bloomSelection.clear(),this.finalComposer.dispose(),(t=this.bloomComposer)==null||t.dispose()}}const nt=class nt{constructor(t,e){this.raycaster=new x.Raycaster,this.installPlugins=new Map,this.event=new bt.eventsExports.EventEmitter,this.clock=new x.Clock,this.userData={},this.pipViewportState=!1,this.options=Nt(nt.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 jt;a.open(!1),this.gui=a}if(this.init(),i){const a=new qt({horizontal:!1});a.init(this.renderer),s.appendChild(a.dom),this.stats=a}this.options.WebGPUTHREE||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.options.WebGPUTHREE?0: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,WebGPUTHREE:s,helper:i,renderer:o,scene:r,camera:a,control:l}=this.options,{width:c,height:g}=this.getSize(),_=new me({isdev:e,width:c,height:g,cameraParams:a,cameraControls:l===!0});this.gui&&_.setGui(this.gui);const C=_.camera,p=new pe({camera:C,sceneParams:r}),P=p.scene,f=s?new ce({width:c,height:g,scene:P,camera:C,isdev:e,renderer:s.WebGPURenderer,rendererParams:le}):new he({width:c,height:g,scene:P,camera:C,isdev:e,rendererParams:ht(j({},o),{antialias:!1})});if(i){const D=new ue({scene:P});D.add(P),this.helperController=D}this.sceneController=p,this.rendererController=f,this.cameraController=_,t.appendChild(f.renderer.domElement)}initComposer(){const{bloom:t,bloomParams:e,multisampling:s}=this.options,i=new Oe({renderer:this.renderer,scene:this.scene,camera:this.camera,composerParams:{multisampling:s}});this.composerController=i,t&&(i.addBloomPass(e),this.gui&&i.addBloomGui(this.gui)),i.addOutputPass()}initCSSRenderer(){const{container:t,css2DRenderer:e,css3DRenderer:s,css2DRendererParams:i,css3DRendererParams:o}=this.options;if(e||s){const r=new ye(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 fe({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 ge({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=this.getSize(),s=new ResizeObserver(i=>{for(const o of i){const r=o.contentRect;(r.width!==e.width||r.height!==e.height)&&(e.width=r.width,e.height=r.height,this.handeleResize(r.width,r.height),this.render())}});s.observe(t),this.resizeObserver=s}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(l=>{var c;(c=l.setSize)==null||c.call(l,t,e)}),s&&this.event.emit("resize",{width:t,height:e})}pick(t,e,s=!0){const{raycaster:i,options:o}=this,{container:r}=o,a=new x.Vector2,l=r.getBoundingClientRect();if(a.x=(t.clientX-l.left)/(l.right-l.left)*2-1,a.y=-((t.clientY-l.top)/(l.bottom-l.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,l,c,g,_;const{scene:t,camera:e,clock:s}=this,i=s.getDelta(),o=s.getElapsedTime();Et.update(),(r=this.controlsController)==null||r.update(i),this.installPlugins.forEach(C=>{var p;(p=C.update)==null||p.call(C,i,o)}),(a=this.helperController)==null||a.update(),this.cameraController.syncCamera&&!(this.camera.matrixWorld.equals(this.cameraController.syncCamera.matrixWorld)&&this.camera.far===this.cameraController.syncCamera.far&&this.camera.near===this.cameraController.syncCamera.near&&this.camera.fov===this.cameraController.syncCamera.fov&&this.camera.aspect===this.cameraController.syncCamera.aspect)&&this.camera.copy(this.cameraController.syncCamera),(l=this.composerController)!=null&&l.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(),(g=this.cssRendererController)==null||g.render(t,e),(_=this.stats)==null||_.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,l=this.cameraController.camera2;l&&l.aspect!==a&&(l.aspect=a,l.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,l,c,g,_;this.stop(),Et.removeAll(),this.event.removeAllListeners(),(t=this.resizeObserver)==null||t.unobserve(this.options.container),this.installPlugins.forEach(C=>{var p;(p=C.dispose)==null||p.call(C)}),(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(),(l=this.rendererController)==null||l.dispose(),this.cssRendererController=void 0,(c=this.gui)==null||c.destroy(),this.installPlugins.clear(),(g=this.stats)==null||g.dom.remove(),(_=this.renderer)==null||_.domElement.remove()}};nt.options={isdev:J,stats:J,gui:J,helper:J,control:!0,transformControls:J,resizeObserver:!0,renderer:ae,multisampling:4,scene:_e,camera:de,bloom:!1,bloomParams:Ee,css2DRenderer:!1,css2DRendererParams:j({},Ut),css3DRenderer:!1,css3DRendererParams:j({},Ut)};let rt=nt;const Te=Y.ACTION;exports.BaseObject=oe.BaseObject;exports.GUIObject=ft;exports.Pencil=rt;exports.cameraControlsAction=Te;exports.default=rt;
|
|
14
|
+
`,defines:{}}),"baseTexture");l.needsSwap=!0,this.bloomComposer=a,this.finalComposer.addPass(l),this.mixPass=l,this.bloomLayer.set(ut)}addBloomGui(t){if(!this.bloomComposer)return;new ft({bloom:{threshold:{min:0,max:1,step:.01,target:()=>this.bloomPass},radius:{min:0,max:1,step:.001,target:()=>this.bloomPass},strength:{min:0,max:10,step:.001,target:()=>this.bloomPass}}}).showGui(t)}toggleBloomSelection(t,e){if(!this.bloomComposer){console.warn("err:pencil.options.bloom");return}const{object3d:s}=t;if(!s)return;let i=e;e===void 0&&(i=!this.bloomSelection.has(s)),i?(this.bloomSelection.add(s),s.layers.enable(ut)):(this.bloomSelection.delete(s),s.layers.disable(ut)),this.bloomSelection.size===0?this.bloomComposerActive=!1:this.bloomComposerActive=!0}enable(){this.active||(this.active=!0)}disable(){this.active&&(this.active=!1)}setSize(t,e){var s;(s=this.bloomComposer)==null||s.setSize(t,e),this.finalComposer.setSize(t,e)}render(){this.active&&(this.bloomComposerActive&&this.bloomComposer?(this.mixPass.enabled=!0,this.scene.traverse(t=>{const e=t;e.isMesh&&this.bloomLayer.test(e.layers)===!1&&(this.bloomMaterials[e.uuid]=e.material,e.material=Ce)}),this.bloomComposer.render(),this.scene.traverse(t=>{const e=t;this.bloomMaterials[e.uuid]&&(e.material=this.bloomMaterials[e.uuid],delete this.bloomMaterials[e.uuid])})):this.mixPass&&(this.mixPass.enabled=!1),this.finalComposer.render())}render2(){this.active}dispose(){var t;this.bloomMaterials={},this.bloomSelection.clear(),this.finalComposer.dispose(),(t=this.bloomComposer)==null||t.dispose()}}const nt=class nt{constructor(t,e){this.raycaster=new x.Raycaster,this.installPlugins=new Map,this.event=new bt.eventsExports.EventEmitter,this.clock=new x.Clock,this.userData={},this.pipViewportState=!1,this.options=Nt(nt.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 jt;a.open(!1),this.gui=a}if(this.init(),i){const a=new qt({horizontal:!1});a.init(this.renderer),a.dom.style.position="absolute",s.appendChild(a.dom),this.stats=a}this.options.WebGPUTHREE||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.options.WebGPUTHREE?0: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,WebGPUTHREE:s,helper:i,renderer:o,scene:r,camera:a,control:l}=this.options,{width:c,height:g}=this.getSize(),_=new me({isdev:e,width:c,height:g,cameraParams:a,cameraControls:l===!0});this.gui&&_.setGui(this.gui);const C=_.camera,p=new pe({camera:C,sceneParams:r}),P=p.scene,f=s?new ce({width:c,height:g,scene:P,camera:C,isdev:e,renderer:s.WebGPURenderer,rendererParams:le}):new he({width:c,height:g,scene:P,camera:C,isdev:e,rendererParams:ht(j({},o),{antialias:!1})});if(i){const D=new ue({scene:P});D.add(P),this.helperController=D}this.sceneController=p,this.rendererController=f,this.cameraController=_,t.appendChild(f.renderer.domElement)}initComposer(){const{bloom:t,bloomParams:e,multisampling:s}=this.options,i=new Oe({renderer:this.renderer,scene:this.scene,camera:this.camera,composerParams:{multisampling:s}});this.composerController=i,t&&(i.addBloomPass(e),this.gui&&i.addBloomGui(this.gui)),i.addOutputPass()}initCSSRenderer(){const{container:t,css2DRenderer:e,css3DRenderer:s,css2DRendererParams:i,css3DRendererParams:o}=this.options;if(e||s){const r=new ye(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 fe({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 ge({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=this.getSize(),s=new ResizeObserver(i=>{for(const o of i){const r=o.contentRect;(r.width!==e.width||r.height!==e.height)&&(e.width=r.width,e.height=r.height,this.handeleResize(r.width,r.height),this.render())}});s.observe(t),this.resizeObserver=s}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(l=>{var c;(c=l.setSize)==null||c.call(l,t,e)}),s&&this.event.emit("resize",{width:t,height:e})}pick(t,e,s=!0){const{raycaster:i,options:o}=this,{container:r}=o,a=new x.Vector2,l=r.getBoundingClientRect();if(a.x=(t.clientX-l.left)/(l.right-l.left)*2-1,a.y=-((t.clientY-l.top)/(l.bottom-l.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,l,c,g,_;const{scene:t,camera:e,clock:s}=this,i=s.getDelta(),o=s.getElapsedTime();Et.update(),(r=this.controlsController)==null||r.update(i),this.installPlugins.forEach(C=>{var p;(p=C.update)==null||p.call(C,i,o)}),(a=this.helperController)==null||a.update(),this.cameraController.syncCamera&&!(this.camera.matrixWorld.equals(this.cameraController.syncCamera.matrixWorld)&&this.camera.far===this.cameraController.syncCamera.far&&this.camera.near===this.cameraController.syncCamera.near&&this.camera.fov===this.cameraController.syncCamera.fov&&this.camera.aspect===this.cameraController.syncCamera.aspect)&&this.camera.copy(this.cameraController.syncCamera),(l=this.composerController)!=null&&l.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(),(g=this.cssRendererController)==null||g.render(t,e),(_=this.stats)==null||_.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,l=this.cameraController.camera2;l&&l.aspect!==a&&(l.aspect=a,l.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,l,c,g,_;this.stop(),Et.removeAll(),this.event.removeAllListeners(),(t=this.resizeObserver)==null||t.unobserve(this.options.container),this.installPlugins.forEach(C=>{var p;(p=C.dispose)==null||p.call(C)}),(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(),(l=this.rendererController)==null||l.dispose(),this.cssRendererController=void 0,(c=this.gui)==null||c.destroy(),this.installPlugins.clear(),(g=this.stats)==null||g.dom.remove(),(_=this.renderer)==null||_.domElement.remove()}};nt.options={isdev:J,stats:J,gui:J,helper:J,control:!0,transformControls:J,resizeObserver:!0,renderer:ae,multisampling:4,scene:_e,camera:de,bloom:!1,bloomParams:Ee,css2DRenderer:!1,css2DRendererParams:j({},Ut),css3DRenderer:!1,css3DRendererParams:j({},Ut)};let rt=nt;const Te=Y.ACTION;exports.BaseObject=oe.BaseObject;exports.GUIObject=ft;exports.Pencil=rt;exports.cameraControlsAction=Te;exports.default=rt;
|
package/dist/index.module.js
CHANGED
|
@@ -2268,7 +2268,7 @@ const rt = class rt {
|
|
|
2268
2268
|
}
|
|
2269
2269
|
if (this.init(), i) {
|
|
2270
2270
|
const a = new Bt({ horizontal: !1 });
|
|
2271
|
-
a.init(this.renderer), s.appendChild(a.dom), this.stats = a;
|
|
2271
|
+
a.init(this.renderer), a.dom.style.position = "absolute", s.appendChild(a.dom), this.stats = a;
|
|
2272
2272
|
}
|
|
2273
2273
|
this.options.WebGPUTHREE || this.initComposer(), this.initCSSRenderer(), this.initControls(), r && this.initResizeObserver(), this.clock.getDelta(), this.clock.getElapsedTime(), e && (Array.isArray(e) || (e = [e]), e.forEach((a) => {
|
|
2274
2274
|
Array.isArray(a) || (a = [a]), this.use(a[0], a[1]);
|