gl-draw 0.9.0-beta.2 → 0.9.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/index.js +1 -1
- package/dist/index.module.js +86 -84
- package/dist/utils/index.js +1 -1
- package/dist/utils/index.module.js +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var K=Object.defineProperty,X=Object.defineProperties;var Y=Object.getOwnPropertyDescriptors;var j=Object.getOwnPropertySymbols;var Z=Object.prototype.hasOwnProperty,$=Object.prototype.propertyIsEnumerable;var z=(n,e,t)=>e in n?K(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,P=(n,e)=>{for(var t in e||(e={}))Z.call(e,t)&&z(n,t,e[t]);if(j)for(var t of j(e))$.call(e,t)&&z(n,t,e[t]);return n},M=(n,e)=>X(n,Y(e));Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const J=require("three"),Q=require("deepmerge"),ee=require("three/examples/jsm/libs/stats.module"),te=require("lil-gui"),ne=require("./disposeMesh.js");require("idb-keyval");const se=require("three/examples/jsm/controls/OrbitControls"),re=require("three/examples/jsm/renderers/CSS3DRenderer"),ie=require("three/examples/jsm/renderers/CSS2DRenderer"),C=require("postprocessing"),oe=require("./isPlainObject.js"),ae=require("./BaseObject.js");require("./makePromiseCreator.js");function ce(n){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const t in n)if(t!=="default"){const s=Object.getOwnPropertyDescriptor(n,t);Object.defineProperty(e,t,s.get?s:{enumerable:!0,get:()=>n[t]})}}return e.default=n,Object.freeze(e)}const d=ce(J);var x={},le={get exports(){return x},set exports(n){x=n}},y=typeof Reflect=="object"?Reflect:null,A=y&&typeof y.apply=="function"?y.apply:function(e,t,s){return Function.prototype.apply.call(e,t,s)},L;y&&typeof y.ownKeys=="function"?L=y.ownKeys:Object.getOwnPropertySymbols?L=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:L=function(e){return Object.getOwnPropertyNames(e)};function de(n){console&&console.warn&&console.warn(n)}var G=Number.isNaN||function(e){return e!==e};function l(){l.init.call(this)}le.exports=l;x.once=me;l.EventEmitter=l;l.prototype._events=void 0;l.prototype._eventsCount=0;l.prototype._maxListeners=void 0;var D=10;function R(n){if(typeof n!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof n)}Object.defineProperty(l,"defaultMaxListeners",{enumerable:!0,get:function(){return D},set:function(n){if(typeof n!="number"||n<0||G(n))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+n+".");D=n}});l.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0};l.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||G(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this};function I(n){return n._maxListeners===void 0?l.defaultMaxListeners:n._maxListeners}l.prototype.getMaxListeners=function(){return I(this)};l.prototype.emit=function(e){for(var t=[],s=1;s<arguments.length;s++)t.push(arguments[s]);var r=e==="error",o=this._events;if(o!==void 0)r=r&&o.error===void 0;else if(!r)return!1;if(r){var i;if(t.length>0&&(i=t[0]),i instanceof Error)throw i;var a=new Error("Unhandled error."+(i?" ("+i.message+")":""));throw a.context=i,a}var c=o[e];if(c===void 0)return!1;if(typeof c=="function")A(c,this,t);else for(var u=c.length,f=V(c,u),s=0;s<u;++s)A(f[s],this,t);return!0};function N(n,e,t,s){var r,o,i;if(R(t),o=n._events,o===void 0?(o=n._events=Object.create(null),n._eventsCount=0):(o.newListener!==void 0&&(n.emit("newListener",e,t.listener?t.listener:t),o=n._events),i=o[e]),i===void 0)i=o[e]=t,++n._eventsCount;else if(typeof i=="function"?i=o[e]=s?[t,i]:[i,t]:s?i.unshift(t):i.push(t),r=I(n),r>0&&i.length>r&&!i.warned){i.warned=!0;var a=new Error("Possible EventEmitter memory leak detected. "+i.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");a.name="MaxListenersExceededWarning",a.emitter=n,a.type=e,a.count=i.length,de(a)}return n}l.prototype.addListener=function(e,t){return N(this,e,t,!1)};l.prototype.on=l.prototype.addListener;l.prototype.prependListener=function(e,t){return N(this,e,t,!0)};function fe(){if(!this.fired)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)}function F(n,e,t){var s={fired:!1,wrapFn:void 0,target:n,type:e,listener:t},r=fe.bind(s);return r.listener=t,s.wrapFn=r,r}l.prototype.once=function(e,t){return R(t),this.on(e,F(this,e,t)),this};l.prototype.prependOnceListener=function(e,t){return R(t),this.prependListener(e,F(this,e,t)),this};l.prototype.removeListener=function(e,t){var s,r,o,i,a;if(R(t),r=this._events,r===void 0)return this;if(s=r[e],s===void 0)return this;if(s===t||s.listener===t)--this._eventsCount===0?this._events=Object.create(null):(delete r[e],r.removeListener&&this.emit("removeListener",e,s.listener||t));else if(typeof s!="function"){for(o=-1,i=s.length-1;i>=0;i--)if(s[i]===t||s[i].listener===t){a=s[i].listener,o=i;break}if(o<0)return this;o===0?s.shift():ue(s,o),s.length===1&&(r[e]=s[0]),r.removeListener!==void 0&&this.emit("removeListener",e,a||t)}return this};l.prototype.off=l.prototype.removeListener;l.prototype.removeAllListeners=function(e){var t,s,r;if(s=this._events,s===void 0)return this;if(s.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):s[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete s[e]),this;if(arguments.length===0){var o=Object.keys(s),i;for(r=0;r<o.length;++r)i=o[r],i!=="removeListener"&&this.removeAllListeners(i);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(t=s[e],typeof t=="function")this.removeListener(e,t);else if(t!==void 0)for(r=t.length-1;r>=0;r--)this.removeListener(e,t[r]);return this};function q(n,e,t){var s=n._events;if(s===void 0)return[];var r=s[e];return r===void 0?[]:typeof r=="function"?t?[r.listener||r]:[r]:t?he(r):V(r,r.length)}l.prototype.listeners=function(e){return q(this,e,!0)};l.prototype.rawListeners=function(e){return q(this,e,!1)};l.listenerCount=function(n,e){return typeof n.listenerCount=="function"?n.listenerCount(e):k.call(n,e)};l.prototype.listenerCount=k;function k(n){var e=this._events;if(e!==void 0){var t=e[n];if(typeof t=="function")return 1;if(t!==void 0)return t.length}return 0}l.prototype.eventNames=function(){return this._eventsCount>0?L(this._events):[]};function V(n,e){for(var t=new Array(e),s=0;s<e;++s)t[s]=n[s];return t}function ue(n,e){for(;e+1<n.length;e++)n[e]=n[e+1];n.pop()}function he(n){for(var e=new Array(n.length),t=0;t<e.length;++t)e[t]=n[t].listener||n[t];return e}function me(n,e){return new Promise(function(t,s){function r(i){n.removeListener(e,o),s(i)}function o(){typeof n.removeListener=="function"&&n.removeListener("error",r),t([].slice.call(arguments))}H(n,e,o,{once:!0}),e!=="error"&&pe(n,r,{once:!0})})}function pe(n,e,t){typeof n.on=="function"&&H(n,"error",e,t)}function H(n,e,t,s){if(typeof n.on=="function")s.once?n.once(e,t):n.on(e,t);else if(typeof n.addEventListener=="function")n.addEventListener(e,function r(o){s.once&&n.removeEventListener(e,r),t(o)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof n)}class S{constructor(e){this.guiParams={},e&&(this.guiParams=e)}showGui(e){e&&Object.keys(this.guiParams).forEach(t=>{const s=e.addFolder(t),r=this.guiParams[t];Object.keys(r).forEach(o=>{const{min:i,max:a,step:c,name:u,paramMap:f,items:m,value:p,target:g}=r[o],O=o.toLowerCase().indexOf("color")>-1;let h;const w=typeof p=="undefined"&&g,b=w?g():r[o],v=w?o:"value";m?h=s.add(b,v,m):O?h=s.addColor(b,v):h=s.add(b,v),h=h.name(u||o),typeof i!="undefined"&&(h=h.min(i)),typeof a!="undefined"&&(h=h.max(a)),typeof c!="undefined"&&(h=h.step(c)),h=h.onChange(()=>{this.setTargetValue(t,o,b[v],f)}),w&&h.listen()})})}setTargetValue(e,t,s,r){const{onChange:o,target:i,value:a}=this.guiParams[e][t],c=t.toLowerCase().indexOf("color")>-1;if(i&&!(typeof a=="undefined"&&i)){let f=i();Array.isArray(f)||(f=[f]),f.forEach(m=>{if(m)if(c)try{m[r||t].set(s)}catch(p){t!=="color"&&!r&&console.warn(`${t} is not a color,set paramMap`)}else m[r||t]=s})}o&&o(s)}setTargetValueByParams(){Object.keys(this.guiParams).forEach(e=>{Object.keys(this.guiParams[e]).forEach(t=>{const s=this.guiParams[e][t];typeof s.value!="undefined"&&this.setTargetValue(e,t,s.value,s.paramMap)})})}}const T={None:d.NoToneMapping,Linear:d.LinearToneMapping,Reinhard:d.ReinhardToneMapping,Cineon:d.CineonToneMapping,ACESFilmic:d.ACESFilmicToneMapping},ve={antialias:!1,devicePixelRatio:window.devicePixelRatio,powerPreference:"high-performance",toneMapping:"None",toneMappingExposure:1,alpha:!1,outputEncoding:d.LinearEncoding,logarithmicDepthBuffer:!1,preserveDrawingBuffer:!1,context:null,stencil:!1,depth:!1,physicallyCorrectLights:!1};class ge{constructor(e){this.options=e;const{width:t,height:s,rendererParams:r}=e,{context:o,alpha:i,devicePixelRatio:a,antialias:c,powerPreference:u,toneMapping:f,toneMappingExposure:m,outputEncoding:p,logarithmicDepthBuffer:g,preserveDrawingBuffer:O,stencil:h,depth:w,physicallyCorrectLights:b}=r,v=new d.WebGLRenderer({context:o,alpha:i,antialias:c,powerPreference:u,logarithmicDepthBuffer:g,preserveDrawingBuffer:O,stencil:h,depth:w});v.setSize(t,s),v.setPixelRatio(a),v.toneMapping=T[f],v.toneMappingExposure=m,v.outputEncoding=p,v.physicallyCorrectLights=b,this.renderer=v}setSize(e,t){this.renderer.setSize(e,t)}render(){const{scene:e,camera:t}=this.options;this.renderer.render(e,t)}setGui(e){new S({renderer:{toneMapping:{value:this.options.rendererParams.toneMapping,items:T,target:()=>this.renderer},toneMappingExposure:{value:this.options.rendererParams.toneMappingExposure,min:0,max:16,target:()=>this.renderer}}}).showGui(e)}dispose(){var e,t,s;(e=this.renderer)==null||e.clear(),(t=this.renderer)==null||t.dispose(),(s=this.renderer)==null||s.renderLists.dispose()}}const Ce={fov:45,near:1,far:1e3};class be{constructor(e){this.oldCameraPosition=new d.Vector3,this.oldCameraRotation=new d.Euler,this.customCamera=!1,this.options=e;const{width:t,height:s,cameraParams:r}=e;if(r instanceof d.Camera)this.camera=r,this.customCamera=!0;else{const{fov:o,far:i,near:a}=r,c=new d.PerspectiveCamera(o,t/s,a,i);c.position.set(0,0,400),c.lookAt(0,0,0),this.camera=c}}checkCameraChange(){const e=this.camera,t=this.oldCameraPosition.equals(e.position)&&this.oldCameraRotation.equals(e.rotation);return this.oldCameraPosition=e.position.clone(),this.oldCameraRotation=e.rotation.clone(),!t}setSize(e,t){this.camera instanceof d.PerspectiveCamera&&(this.camera.aspect=e/t),this.camera.updateProjectionMatrix()}setGui(e){const t=new S({camera:{x:{min:-1e4,max:1e4,step:1,target:()=>this.camera.position},y:{min:-1e4,max:1e4,step:1,target:()=>this.camera.position},z:{min:-1e4,max:1e4,step:1,target:()=>this.camera.position},near:{min:0,max:1e3,step:1,target:()=>this.camera,onChange:s=>{this.camera.updateProjectionMatrix()}},far:{min:0,max:2e4,step:1,target:()=>this.camera,onChange:s=>{this.camera.updateProjectionMatrix()}}}});this.camera instanceof d.PerspectiveCamera&&(t.guiParams.camera.fov={min:0,max:90,step:1,target:()=>this.camera,onChange:s=>{this.camera.updateProjectionMatrix()}}),t.showGui(e)}}const Pe={background:null};class ye{constructor(e){this.options=e;const{camera:t,sceneParams:s}=e,{background:r}=s,o=new d.Scene;r&&(o.background=r),o.add(t),this.scene=o}addAxesHelper(){var t;const e=new d.AxesHelper(100);(t=this.scene)==null||t.add(e)}dispose(){var e;(e=this.scene)==null||e.traverse(t=>{ne.disposeMesh(t)})}}class we{constructor(e){this.options=e;const{camera:t,controlParams:s,customControl:r}=e,{domElement:o}=s,i=r?new r(t,o):new se.OrbitControls(t,o);i.minPolarAngle=Math.PI*.15,i.maxPolarAngle=Math.PI*.85,i.enableDamping=!0,i.dampingFactor=.063,i.autoRotate=!1,i.autoRotateSpeed=-60,i.enableZoom=!0,i.zoomSpeed=.2,this.control=i}limitPan({maxX:e=1/0,minX:t=-1/0,maxZ:s=1/0,minZ:r=-1/0,maxY:o=1/0,minY:i=-1/0}){const a=this.limitPanV||new d.Vector3,c=this.control,{camera:u}=this.options,f=new d.Vector3(t,i,r),m=new d.Vector3(e,o,s);this.limitPanV=a,a.copy(c.target),c.target.clamp(f,m),a.sub(c.target),u.position.sub(a)}update(){this.control.update()}dispose(){this.control.dispose()}}const B={zIndex:"auto"};class Ee{constructor(e){this.container=e}addRenderer(e,t){const{container:s}=this,r=s.offsetWidth,o=s.offsetHeight,i=e==="css2d"?new ie.CSS2DRenderer:new re.CSS3DRenderer;i.domElement.style.position="absolute",i.domElement.style.top="0",i.domElement.style.pointerEvents="none",i.domElement.style.zIndex=t.zIndex,i.setSize(r,o),s.appendChild(i.domElement),e==="css2d"?this.css2Drenderer=i:e==="css3d"&&(this.css3Drenderer=i)}setSize(e,t){var s,r;(s=this.css2Drenderer)==null||s.setSize(e,t),(r=this.css3Drenderer)==null||r.setSize(e,t)}render(e,t){var s,r;(s=this.css2Drenderer)==null||s.render(e,t),(r=this.css3Drenderer)==null||r.render(e,t)}dispose(){this.css2Drenderer=void 0,this.css3Drenderer=void 0}}const Le={luminanceThreshold:.1,luminanceSmoothing:.3,mipmapBlur:!0,intensity:4};class xe{constructor(e){this.active=!0,this.options=e;const{renderer:t,scene:s,camera:r,composerParams:o}=e,{multisampling:i}=o,{maxSamples:a}=t.capabilities,c=new C.EffectComposer(t,{multisampling:Math.min(i,a)});c.addPass(new C.RenderPass(s,r)),this.finalComposer=c,this.renderer=t,this.scene=s,this.camera=r}addCopyPass(){const e=new C.CopyPass;e.renderToScreen=!0,this.finalComposer.addPass(e),this.copyPass=e}addFXAAPass(){const{camera:e}=this,t=new C.FXAAEffect({blendFunction:C.BlendFunction.NORMAL}),s=new C.EffectPass(e,t);this.finalComposer.addPass(s),this.fxaaPass=s}addBloomPass(e){const{camera:t,scene:s}=this,r=new C.SelectiveBloomEffect(s,t,P({},e)),o=new C.EffectPass(t,r);o.enabled=!1,this.finalComposer.addPass(o),this.bloomPass=o,this.bloomEffect=r}addBloomGui(e){if(!this.bloomEffect)return;new S({bloom:{intensity:{min:0,max:10,step:.01,target:()=>this.bloomEffect}},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(e)}toggleBloomSelection(e){if(!this.bloomEffect||!this.bloomPass){console.warn("err:pencil.options.bloom");return}this.bloomEffect.selection.toggle(e),this.bloomPass.enabled=!!this.bloomEffect.selection.size}getSize(){const{renderer:e}=this.options;return e.getSize(new d.Vector2)}enable(){this.active||(this.active=!0)}disable(){this.active&&(this.active=!1)}setSize(e,t){this.finalComposer.setSize(e,t)}render(){this.active&&this.finalComposer.render()}dispose(){this.finalComposer.dispose()}}const Re=()=>{try{const n=document.createElement("canvas");return!!(window.WebGL2RenderingContext&&n.getContext("webgl2"))}catch(n){return!1}},E=!1,W=Re()!==!1,U=class{constructor(n){this.raycaster=new d.Raycaster,this.installPlugins=new Map,this.event=new x.EventEmitter,this.clock=new d.Clock,this.userData={},this.options=Q(U.options,n,{isMergeableObject:oe.isPlainObject});const{container:e,stats:t,gui:s,resizeObserver:r}=this.options;if(s){const o=new te;o.open(!1),this.gui=o}if(t){const o=new ee;o.showPanel(0),o.dom.style.position="absolute",e.appendChild(o.dom),this.stats=o}this.init(),this.initComposer(),this.initCSSRenderer(),this.initControl(),r&&this.initResizeObserver(),this.clock.getDelta(),this.clock.getElapsedTime()}get renderer(){return this.rendererController.renderer}get control(){var n;return(n=this.controlController)==null?void 0:n.control}get camera(){return this.cameraController.camera}get scene(){return this.sceneController.scene}use(n,...e){this.installPlugins.has(n)?console.log("plugin already installed"):typeof n.install=="function"&&(n.install(this,...e),this.installPlugins.set(n,!0))}init(){const{container:n,isdev:e,axesHelper:t,renderer:s,scene:r,camera:o}=this.options,{width:i,height:a}=this.getSize(),c=new be({isdev:e,width:i,height:a,cameraParams:o});this.gui&&c.setGui(this.gui);const u=c.camera,f=new ye({camera:u,sceneParams:r}),m=f.scene,p=new ge({width:i,height:a,scene:m,camera:u,isdev:e,rendererParams:M(P({},s),{antialias:!1})});this.gui&&p.setGui(this.gui);const g=p.renderer;t&&f.addAxesHelper(),this.sceneController=f,this.rendererController=p,this.cameraController=c,n.appendChild(g.domElement)}initComposer(){const{bloom:n,bloomParams:e,renderer:t,multisampling:s,passes:r}=this.options;let{antialias:o}=t;o==="msaa"&&!W&&(o=!1,console.warn("MSAA is not supported on this browser"));const i=new xe({renderer:this.renderer,scene:this.scene,camera:this.camera,composerParams:{multisampling:o==="msaa"?s:0,type:d.UnsignedByteType,encoding:t.outputEncoding}});this.composerController=i,n&&(i.addBloomPass(e),this.gui&&i.addBloomGui(this.gui)),o==="fxaa"&&i.addFXAAPass(),r&&r.forEach(a=>{i.finalComposer.addPass(a)}),i.addCopyPass()}initCSSRenderer(){const{container:n,css2DRenderer:e,css3DRenderer:t,css2DRendererParams:s,css3DRendererParams:r}=this.options;if(e||t){const o=new Ee(n);e&&o.addRenderer("css2d",s),t&&o.addRenderer("css3d",r),this.cssRendererController=o}}initControl(){const{control:n,controlParams:e}=this.options;if(n){const t=new we({camera:this.camera,controlParams:{domElement:(e==null?void 0:e.domElement)||this.renderer.domElement},customControl:typeof n=="boolean"?void 0:n});this.controlController=t}}getSize(){const{container:n}=this.options;return{width:n.offsetWidth,height:n.offsetHeight}}initResizeObserver(){const{container:n}=this.options;if(this.resizeObserver)return;const e=new ResizeObserver(t=>{for(const s of t){const r=s.contentRect;this.handeleResize(r.width,r.height),this.render()}});e.observe(n),this.resizeObserver=e}handeleResize(n,e){const{rendererController:t,cameraController:s,composerController:r,cssRendererController:o}=this;s==null||s.setSize(n,e),t==null||t.setSize(n,e),r==null||r.setSize(n,e),o==null||o.setSize(n,e),this.installPlugins.forEach((i,a)=>{var c;(c=a.setSize)==null||c.call(a,n,e)}),this.event.emit("resize",{width:n,height:e})}pick(n,e,t=!1){const{raycaster:s,options:r}=this,{container:o}=r,i=new d.Vector2,a=o.getBoundingClientRect();if(i.x=(n.clientX-a.left)/(a.right-a.left)*2-1,i.y=-((n.clientY-a.top)/(a.bottom-a.top))*2+1,this.camera&&this.scene){s.setFromCamera(i,this.camera);const c=s.intersectObjects(e||this.scene.children,t);if(c.length)return{object:c[0].object,intersects:c}}}render(){var i,a,c,u,f;const{renderer:n,scene:e,camera:t,clock:s}=this;if(!n||!e||!t||this.options.staticRender&&!this.cameraController.checkCameraChange())return;const r=s.getDelta(),o=s.getElapsedTime();(i=this.controlController)==null||i.update(),this.installPlugins.forEach((m,p)=>{var g;(g=p.update)==null||g.call(p,r,o)}),(a=this.composerController)!=null&&a.active?this.composerController.render():(c=this.rendererController)==null||c.render(),(u=this.cssRendererController)==null||u.render(e,t),(f=this.stats)==null||f.update(),this.event.emit("render",{delta:r,elapsed:o})}start(){this.renderer.setAnimationLoop(this.render.bind(this)),this.event.emit("start")}stop(){this.renderer.setAnimationLoop(null),this.event.emit("stop")}dispose(){var n,e,t,s,r,o,i;this.stop(),this.handeleResize(0,0),(n=this.resizeObserver)==null||n.unobserve(this.options.container),this.installPlugins.forEach((a,c)=>{var u;(u=c.dispose)==null||u.call(c)}),(e=this.controlController)==null||e.dispose(),(t=this.cssRendererController)==null||t.dispose(),(s=this.sceneController)==null||s.dispose(),(r=this.composerController)==null||r.dispose(),(o=this.rendererController)==null||o.dispose(),this.controlController=void 0,this.cssRendererController=void 0,(i=this.gui)==null||i.destroy(),this.event.removeAllListeners(),this.installPlugins.clear()}};let _=U;_.options={isdev:E,stats:E,gui:E,axesHelper:E,control:E,resizeObserver:!0,renderer:M(P({},ve),{antialias:W?"msaa":"fxaa"}),staticRender:!1,multisampling:4,scene:Pe,camera:Ce,bloom:!1,bloomParams:Le,css2DRenderer:!1,css2DRendererParams:P({},B),css3DRenderer:!1,css3DRendererParams:P({},B)};exports.BaseObject=ae.BaseObject;exports.GUIObject=S;exports.Pencil=_;exports.default=_;
|
|
1
|
+
"use strict";var X=Object.defineProperty,Y=Object.defineProperties;var Z=Object.getOwnPropertyDescriptors;var j=Object.getOwnPropertySymbols;var $=Object.prototype.hasOwnProperty,J=Object.prototype.propertyIsEnumerable;var z=(n,e,t)=>e in n?X(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,y=(n,e)=>{for(var t in e||(e={}))$.call(e,t)&&z(n,t,e[t]);if(j)for(var t of j(e))J.call(e,t)&&z(n,t,e[t]);return n},M=(n,e)=>Y(n,Z(e));Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const Q=require("three"),ee=require("deepmerge"),te=require("three/examples/jsm/libs/stats.module"),ne=require("lil-gui"),se=require("./disposeMesh.js");require("idb-keyval");const re=require("three/examples/jsm/controls/OrbitControls"),ie=require("three/examples/jsm/renderers/CSS3DRenderer"),oe=require("three/examples/jsm/renderers/CSS2DRenderer"),C=require("postprocessing"),ae=require("./isPlainObject.js"),ce=require("./BaseObject.js");require("./makePromiseCreator.js");function le(n){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const t in n)if(t!=="default"){const s=Object.getOwnPropertyDescriptor(n,t);Object.defineProperty(e,t,s.get?s:{enumerable:!0,get:()=>n[t]})}}return e.default=n,Object.freeze(e)}const d=le(Q);var x={},de={get exports(){return x},set exports(n){x=n}},P=typeof Reflect=="object"?Reflect:null,A=P&&typeof P.apply=="function"?P.apply:function(e,t,s){return Function.prototype.apply.call(e,t,s)},L;P&&typeof P.ownKeys=="function"?L=P.ownKeys:Object.getOwnPropertySymbols?L=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:L=function(e){return Object.getOwnPropertyNames(e)};function fe(n){console&&console.warn&&console.warn(n)}var B=Number.isNaN||function(e){return e!==e};function l(){l.init.call(this)}de.exports=l;x.once=pe;l.EventEmitter=l;l.prototype._events=void 0;l.prototype._eventsCount=0;l.prototype._maxListeners=void 0;var D=10;function R(n){if(typeof n!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof n)}Object.defineProperty(l,"defaultMaxListeners",{enumerable:!0,get:function(){return D},set:function(n){if(typeof n!="number"||n<0||B(n))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+n+".");D=n}});l.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0};l.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||B(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this};function G(n){return n._maxListeners===void 0?l.defaultMaxListeners:n._maxListeners}l.prototype.getMaxListeners=function(){return G(this)};l.prototype.emit=function(e){for(var t=[],s=1;s<arguments.length;s++)t.push(arguments[s]);var r=e==="error",o=this._events;if(o!==void 0)r=r&&o.error===void 0;else if(!r)return!1;if(r){var i;if(t.length>0&&(i=t[0]),i instanceof Error)throw i;var a=new Error("Unhandled error."+(i?" ("+i.message+")":""));throw a.context=i,a}var c=o[e];if(c===void 0)return!1;if(typeof c=="function")A(c,this,t);else for(var u=c.length,f=k(c,u),s=0;s<u;++s)A(f[s],this,t);return!0};function N(n,e,t,s){var r,o,i;if(R(t),o=n._events,o===void 0?(o=n._events=Object.create(null),n._eventsCount=0):(o.newListener!==void 0&&(n.emit("newListener",e,t.listener?t.listener:t),o=n._events),i=o[e]),i===void 0)i=o[e]=t,++n._eventsCount;else if(typeof i=="function"?i=o[e]=s?[t,i]:[i,t]:s?i.unshift(t):i.push(t),r=G(n),r>0&&i.length>r&&!i.warned){i.warned=!0;var a=new Error("Possible EventEmitter memory leak detected. "+i.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");a.name="MaxListenersExceededWarning",a.emitter=n,a.type=e,a.count=i.length,fe(a)}return n}l.prototype.addListener=function(e,t){return N(this,e,t,!1)};l.prototype.on=l.prototype.addListener;l.prototype.prependListener=function(e,t){return N(this,e,t,!0)};function ue(){if(!this.fired)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)}function F(n,e,t){var s={fired:!1,wrapFn:void 0,target:n,type:e,listener:t},r=ue.bind(s);return r.listener=t,s.wrapFn=r,r}l.prototype.once=function(e,t){return R(t),this.on(e,F(this,e,t)),this};l.prototype.prependOnceListener=function(e,t){return R(t),this.prependListener(e,F(this,e,t)),this};l.prototype.removeListener=function(e,t){var s,r,o,i,a;if(R(t),r=this._events,r===void 0)return this;if(s=r[e],s===void 0)return this;if(s===t||s.listener===t)--this._eventsCount===0?this._events=Object.create(null):(delete r[e],r.removeListener&&this.emit("removeListener",e,s.listener||t));else if(typeof s!="function"){for(o=-1,i=s.length-1;i>=0;i--)if(s[i]===t||s[i].listener===t){a=s[i].listener,o=i;break}if(o<0)return this;o===0?s.shift():he(s,o),s.length===1&&(r[e]=s[0]),r.removeListener!==void 0&&this.emit("removeListener",e,a||t)}return this};l.prototype.off=l.prototype.removeListener;l.prototype.removeAllListeners=function(e){var t,s,r;if(s=this._events,s===void 0)return this;if(s.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):s[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete s[e]),this;if(arguments.length===0){var o=Object.keys(s),i;for(r=0;r<o.length;++r)i=o[r],i!=="removeListener"&&this.removeAllListeners(i);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(t=s[e],typeof t=="function")this.removeListener(e,t);else if(t!==void 0)for(r=t.length-1;r>=0;r--)this.removeListener(e,t[r]);return this};function q(n,e,t){var s=n._events;if(s===void 0)return[];var r=s[e];return r===void 0?[]:typeof r=="function"?t?[r.listener||r]:[r]:t?me(r):k(r,r.length)}l.prototype.listeners=function(e){return q(this,e,!0)};l.prototype.rawListeners=function(e){return q(this,e,!1)};l.listenerCount=function(n,e){return typeof n.listenerCount=="function"?n.listenerCount(e):V.call(n,e)};l.prototype.listenerCount=V;function V(n){var e=this._events;if(e!==void 0){var t=e[n];if(typeof t=="function")return 1;if(t!==void 0)return t.length}return 0}l.prototype.eventNames=function(){return this._eventsCount>0?L(this._events):[]};function k(n,e){for(var t=new Array(e),s=0;s<e;++s)t[s]=n[s];return t}function he(n,e){for(;e+1<n.length;e++)n[e]=n[e+1];n.pop()}function me(n){for(var e=new Array(n.length),t=0;t<e.length;++t)e[t]=n[t].listener||n[t];return e}function pe(n,e){return new Promise(function(t,s){function r(i){n.removeListener(e,o),s(i)}function o(){typeof n.removeListener=="function"&&n.removeListener("error",r),t([].slice.call(arguments))}H(n,e,o,{once:!0}),e!=="error"&&ve(n,r,{once:!0})})}function ve(n,e,t){typeof n.on=="function"&&H(n,"error",e,t)}function H(n,e,t,s){if(typeof n.on=="function")s.once?n.once(e,t):n.on(e,t);else if(typeof n.addEventListener=="function")n.addEventListener(e,function r(o){s.once&&n.removeEventListener(e,r),t(o)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof n)}class S{constructor(e){this.guiParams={},e&&(this.guiParams=e)}showGui(e){e&&Object.keys(this.guiParams).forEach(t=>{const s=e.addFolder(t),r=this.guiParams[t];Object.keys(r).forEach(o=>{const{min:i,max:a,step:c,name:u,paramMap:f,items:m,value:p,target:g}=r[o],O=o.toLowerCase().indexOf("color")>-1;let h;const w=typeof p=="undefined"&&g,b=w?g():r[o],v=w?o:"value";m?h=s.add(b,v,m):O?h=s.addColor(b,v):h=s.add(b,v),h=h.name(u||o),typeof i!="undefined"&&(h=h.min(i)),typeof a!="undefined"&&(h=h.max(a)),typeof c!="undefined"&&(h=h.step(c)),h=h.onChange(()=>{this.setTargetValue(t,o,b[v],f)}),w&&h.listen()})})}setTargetValue(e,t,s,r){const{onChange:o,target:i,value:a}=this.guiParams[e][t],c=t.toLowerCase().indexOf("color")>-1;if(i&&!(typeof a=="undefined"&&i)){let f=i();Array.isArray(f)||(f=[f]),f.forEach(m=>{if(m)if(c)try{m[r||t].set(s)}catch(p){t!=="color"&&!r&&console.warn(`${t} is not a color,set paramMap`)}else m[r||t]=s})}o&&o(s)}setTargetValueByParams(){Object.keys(this.guiParams).forEach(e=>{Object.keys(this.guiParams[e]).forEach(t=>{const s=this.guiParams[e][t];typeof s.value!="undefined"&&this.setTargetValue(e,t,s.value,s.paramMap)})})}}const T={None:d.NoToneMapping,Linear:d.LinearToneMapping,Reinhard:d.ReinhardToneMapping,Cineon:d.CineonToneMapping,ACESFilmic:d.ACESFilmicToneMapping},ge={antialias:!1,devicePixelRatio:window.devicePixelRatio,powerPreference:"high-performance",toneMapping:"None",toneMappingExposure:1,alpha:!1,outputEncoding:d.LinearEncoding,logarithmicDepthBuffer:!1,preserveDrawingBuffer:!1,context:null,stencil:!1,depth:!1,physicallyCorrectLights:!1};class Ce{constructor(e){this.options=e;const{width:t,height:s,rendererParams:r}=e,{context:o,alpha:i,devicePixelRatio:a,antialias:c,powerPreference:u,toneMapping:f,toneMappingExposure:m,outputEncoding:p,logarithmicDepthBuffer:g,preserveDrawingBuffer:O,stencil:h,depth:w,physicallyCorrectLights:b}=r,v=new d.WebGLRenderer({context:o,alpha:i,antialias:c,powerPreference:u,logarithmicDepthBuffer:g,preserveDrawingBuffer:O,stencil:h,depth:w});v.setSize(t,s),v.setPixelRatio(a),v.toneMapping=T[f],v.toneMappingExposure=m,v.outputEncoding=p;const K=+d.REVISION<150?"physicallyCorrectLights":"useLegacyLights";v[K]=b,this.renderer=v}setSize(e,t){this.renderer.setSize(e,t)}render(){const{scene:e,camera:t}=this.options;this.renderer.render(e,t)}setGui(e){new S({renderer:{toneMapping:{value:this.options.rendererParams.toneMapping,items:T,target:()=>this.renderer},toneMappingExposure:{value:this.options.rendererParams.toneMappingExposure,min:0,max:16,target:()=>this.renderer}}}).showGui(e)}dispose(){var e,t,s;(e=this.renderer)==null||e.clear(),(t=this.renderer)==null||t.dispose(),(s=this.renderer)==null||s.renderLists.dispose()}}const be={fov:45,near:1,far:1e3};class ye{constructor(e){this.oldCameraPosition=new d.Vector3,this.oldCameraRotation=new d.Euler,this.customCamera=!1,this.options=e;const{width:t,height:s,cameraParams:r}=e;if(r instanceof d.Camera)this.camera=r,this.customCamera=!0;else{const{fov:o,far:i,near:a}=r,c=new d.PerspectiveCamera(o,t/s,a,i);c.position.set(0,0,400),c.lookAt(0,0,0),this.camera=c}}checkCameraChange(){const e=this.camera,t=this.oldCameraPosition.equals(e.position)&&this.oldCameraRotation.equals(e.rotation);return this.oldCameraPosition=e.position.clone(),this.oldCameraRotation=e.rotation.clone(),!t}setSize(e,t){this.camera instanceof d.PerspectiveCamera&&(this.camera.aspect=e/t),this.camera.updateProjectionMatrix()}setGui(e){const t=new S({camera:{x:{min:-1e4,max:1e4,step:1,target:()=>this.camera.position},y:{min:-1e4,max:1e4,step:1,target:()=>this.camera.position},z:{min:-1e4,max:1e4,step:1,target:()=>this.camera.position},near:{min:0,max:1e3,step:1,target:()=>this.camera,onChange:s=>{this.camera.updateProjectionMatrix()}},far:{min:0,max:2e4,step:1,target:()=>this.camera,onChange:s=>{this.camera.updateProjectionMatrix()}}}});this.camera instanceof d.PerspectiveCamera&&(t.guiParams.camera.fov={min:0,max:90,step:1,target:()=>this.camera,onChange:s=>{this.camera.updateProjectionMatrix()}}),t.showGui(e)}}const Pe={background:null};class we{constructor(e){this.options=e;const{camera:t,sceneParams:s}=e,{background:r}=s,o=new d.Scene;r&&(o.background=r),o.add(t),this.scene=o}addAxesHelper(){var t;const e=new d.AxesHelper(100);(t=this.scene)==null||t.add(e)}dispose(){var e;(e=this.scene)==null||e.traverse(t=>{se.disposeMesh(t)})}}class Ee{constructor(e){this.options=e;const{camera:t,controlParams:s,customControl:r}=e,{domElement:o}=s,i=r?new r(t,o):new re.OrbitControls(t,o);i.minPolarAngle=Math.PI*.15,i.maxPolarAngle=Math.PI*.85,i.enableDamping=!0,i.dampingFactor=.063,i.autoRotate=!1,i.autoRotateSpeed=-60,i.enableZoom=!0,i.zoomSpeed=.2,this.control=i}limitPan({maxX:e=1/0,minX:t=-1/0,maxZ:s=1/0,minZ:r=-1/0,maxY:o=1/0,minY:i=-1/0}){const a=this.limitPanV||new d.Vector3,c=this.control,{camera:u}=this.options,f=new d.Vector3(t,i,r),m=new d.Vector3(e,o,s);this.limitPanV=a,a.copy(c.target),c.target.clamp(f,m),a.sub(c.target),u.position.sub(a)}update(){this.control.update()}dispose(){this.control.dispose()}}const I={zIndex:"auto"};class Le{constructor(e){this.container=e}addRenderer(e,t){const{container:s}=this,r=s.offsetWidth,o=s.offsetHeight,i=e==="css2d"?new oe.CSS2DRenderer:new ie.CSS3DRenderer;i.domElement.style.position="absolute",i.domElement.style.top="0",i.domElement.style.pointerEvents="none",i.domElement.style.zIndex=t.zIndex,i.setSize(r,o),s.appendChild(i.domElement),e==="css2d"?this.css2Drenderer=i:e==="css3d"&&(this.css3Drenderer=i)}setSize(e,t){var s,r;(s=this.css2Drenderer)==null||s.setSize(e,t),(r=this.css3Drenderer)==null||r.setSize(e,t)}render(e,t){var s,r;(s=this.css2Drenderer)==null||s.render(e,t),(r=this.css3Drenderer)==null||r.render(e,t)}dispose(){this.css2Drenderer=void 0,this.css3Drenderer=void 0}}const xe={luminanceThreshold:.1,luminanceSmoothing:.3,mipmapBlur:!0,intensity:4};class Re{constructor(e){this.active=!0,this.options=e;const{renderer:t,scene:s,camera:r,composerParams:o}=e,{multisampling:i}=o,{maxSamples:a}=t.capabilities,c=new C.EffectComposer(t,{multisampling:Math.min(i,a)});c.addPass(new C.RenderPass(s,r)),this.finalComposer=c,this.renderer=t,this.scene=s,this.camera=r}addCopyPass(){const e=new C.CopyPass;e.renderToScreen=!0,this.finalComposer.addPass(e),this.copyPass=e}addFXAAPass(){const{camera:e}=this,t=new C.FXAAEffect({blendFunction:C.BlendFunction.NORMAL}),s=new C.EffectPass(e,t);this.finalComposer.addPass(s),this.fxaaPass=s}addBloomPass(e){const{camera:t,scene:s}=this,r=new C.SelectiveBloomEffect(s,t,y({},e)),o=new C.EffectPass(t,r);o.enabled=!1,this.finalComposer.addPass(o),this.bloomPass=o,this.bloomEffect=r}addBloomGui(e){if(!this.bloomEffect)return;new S({bloom:{intensity:{min:0,max:10,step:.01,target:()=>this.bloomEffect}},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(e)}toggleBloomSelection(e){if(!this.bloomEffect||!this.bloomPass){console.warn("err:pencil.options.bloom");return}this.bloomEffect.selection.toggle(e),this.bloomPass.enabled=!!this.bloomEffect.selection.size}getSize(){const{renderer:e}=this.options;return e.getSize(new d.Vector2)}enable(){this.active||(this.active=!0)}disable(){this.active&&(this.active=!1)}setSize(e,t){this.finalComposer.setSize(e,t)}render(){this.active&&this.finalComposer.render()}dispose(){this.finalComposer.dispose()}}const Se=()=>{try{const n=document.createElement("canvas");return!!(window.WebGL2RenderingContext&&n.getContext("webgl2"))}catch(n){return!1}},E=!1,W=Se()!==!1,U=class{constructor(n){this.raycaster=new d.Raycaster,this.installPlugins=new Map,this.event=new x.EventEmitter,this.clock=new d.Clock,this.userData={},this.options=ee(U.options,n,{isMergeableObject:ae.isPlainObject});const{container:e,stats:t,gui:s,resizeObserver:r}=this.options;if(s){const o=new ne;o.open(!1),this.gui=o}if(t){const o=new te;o.showPanel(0),o.dom.style.position="absolute",e.appendChild(o.dom),this.stats=o}this.init(),this.initComposer(),this.initCSSRenderer(),this.initControl(),r&&this.initResizeObserver(),this.clock.getDelta(),this.clock.getElapsedTime()}get renderer(){return this.rendererController.renderer}get control(){var n;return(n=this.controlController)==null?void 0:n.control}get camera(){return this.cameraController.camera}get scene(){return this.sceneController.scene}use(n,...e){this.installPlugins.has(n)?console.log("plugin already installed"):typeof n.install=="function"&&(n.install(this,...e),this.installPlugins.set(n,!0))}init(){const{container:n,isdev:e,axesHelper:t,renderer:s,scene:r,camera:o}=this.options,{width:i,height:a}=this.getSize(),c=new ye({isdev:e,width:i,height:a,cameraParams:o});this.gui&&c.setGui(this.gui);const u=c.camera,f=new we({camera:u,sceneParams:r}),m=f.scene,p=new Ce({width:i,height:a,scene:m,camera:u,isdev:e,rendererParams:M(y({},s),{antialias:!1})});this.gui&&p.setGui(this.gui);const g=p.renderer;t&&f.addAxesHelper(),this.sceneController=f,this.rendererController=p,this.cameraController=c,n.appendChild(g.domElement)}initComposer(){const{bloom:n,bloomParams:e,renderer:t,multisampling:s,passes:r}=this.options;let{antialias:o}=t;o==="msaa"&&!W&&(o=!1,console.warn("MSAA is not supported on this browser"));const i=new Re({renderer:this.renderer,scene:this.scene,camera:this.camera,composerParams:{multisampling:o==="msaa"?s:0,type:d.UnsignedByteType,encoding:t.outputEncoding}});this.composerController=i,n&&(i.addBloomPass(e),this.gui&&i.addBloomGui(this.gui)),o==="fxaa"&&i.addFXAAPass(),r&&r.forEach(a=>{i.finalComposer.addPass(a)}),i.addCopyPass()}initCSSRenderer(){const{container:n,css2DRenderer:e,css3DRenderer:t,css2DRendererParams:s,css3DRendererParams:r}=this.options;if(e||t){const o=new Le(n);e&&o.addRenderer("css2d",s),t&&o.addRenderer("css3d",r),this.cssRendererController=o}}initControl(){const{control:n,controlParams:e}=this.options;if(n){const t=new Ee({camera:this.camera,controlParams:{domElement:(e==null?void 0:e.domElement)||this.renderer.domElement},customControl:typeof n=="boolean"?void 0:n});this.controlController=t}}getSize(){const{container:n}=this.options;return{width:n.offsetWidth,height:n.offsetHeight}}initResizeObserver(){const{container:n}=this.options;if(this.resizeObserver)return;const e=new ResizeObserver(t=>{for(const s of t){const r=s.contentRect;this.handeleResize(r.width,r.height),this.render()}});e.observe(n),this.resizeObserver=e}handeleResize(n,e){const{rendererController:t,cameraController:s,composerController:r,cssRendererController:o}=this;s==null||s.setSize(n,e),t==null||t.setSize(n,e),r==null||r.setSize(n,e),o==null||o.setSize(n,e),this.installPlugins.forEach((i,a)=>{var c;(c=a.setSize)==null||c.call(a,n,e)}),this.event.emit("resize",{width:n,height:e})}pick(n,e,t=!1){const{raycaster:s,options:r}=this,{container:o}=r,i=new d.Vector2,a=o.getBoundingClientRect();if(i.x=(n.clientX-a.left)/(a.right-a.left)*2-1,i.y=-((n.clientY-a.top)/(a.bottom-a.top))*2+1,this.camera&&this.scene){s.setFromCamera(i,this.camera);const c=s.intersectObjects(e||this.scene.children,t);if(c.length)return{object:c[0].object,intersects:c}}}render(){var i,a,c,u,f;const{renderer:n,scene:e,camera:t,clock:s}=this;if(!n||!e||!t||this.options.staticRender&&!this.cameraController.checkCameraChange())return;const r=s.getDelta(),o=s.getElapsedTime();(i=this.controlController)==null||i.update(),this.installPlugins.forEach((m,p)=>{var g;(g=p.update)==null||g.call(p,r,o)}),(a=this.composerController)!=null&&a.active?this.composerController.render():(c=this.rendererController)==null||c.render(),(u=this.cssRendererController)==null||u.render(e,t),(f=this.stats)==null||f.update(),this.event.emit("render",{delta:r,elapsed:o})}start(){this.renderer.setAnimationLoop(this.render.bind(this)),this.event.emit("start")}stop(){this.renderer.setAnimationLoop(null),this.event.emit("stop")}dispose(){var n,e,t,s,r,o,i;this.stop(),this.handeleResize(0,0),(n=this.resizeObserver)==null||n.unobserve(this.options.container),this.installPlugins.forEach((a,c)=>{var u;(u=c.dispose)==null||u.call(c)}),(e=this.controlController)==null||e.dispose(),(t=this.cssRendererController)==null||t.dispose(),(s=this.sceneController)==null||s.dispose(),(r=this.composerController)==null||r.dispose(),(o=this.rendererController)==null||o.dispose(),this.controlController=void 0,this.cssRendererController=void 0,(i=this.gui)==null||i.destroy(),this.event.removeAllListeners(),this.installPlugins.clear()}};let _=U;_.options={isdev:E,stats:E,gui:E,axesHelper:E,control:E,resizeObserver:!0,renderer:M(y({},ge),{antialias:W?"msaa":"fxaa"}),staticRender:!1,multisampling:4,scene:Pe,camera:be,bloom:!1,bloomParams:xe,css2DRenderer:!1,css2DRendererParams:y({},I),css3DRenderer:!1,css3DRendererParams:y({},I)};exports.BaseObject=ce.BaseObject;exports.GUIObject=S;exports.Pencil=_;exports.default=_;
|
package/dist/index.module.js
CHANGED
|
@@ -1,54 +1,54 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
1
|
+
var X = Object.defineProperty, q = Object.defineProperties;
|
|
2
|
+
var Y = Object.getOwnPropertyDescriptors;
|
|
3
3
|
var M = Object.getOwnPropertySymbols;
|
|
4
|
-
var
|
|
5
|
-
var _ = (n, e, t) => e in n ?
|
|
4
|
+
var Z = Object.prototype.hasOwnProperty, $ = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var _ = (n, e, t) => e in n ? X(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t, b = (n, e) => {
|
|
6
6
|
for (var t in e || (e = {}))
|
|
7
|
-
|
|
7
|
+
Z.call(e, t) && _(n, t, e[t]);
|
|
8
8
|
if (M)
|
|
9
9
|
for (var t of M(e))
|
|
10
|
-
|
|
10
|
+
$.call(e, t) && _(n, t, e[t]);
|
|
11
11
|
return n;
|
|
12
|
-
}, S = (n, e) =>
|
|
12
|
+
}, S = (n, e) => q(n, Y(e));
|
|
13
13
|
import * as f from "three";
|
|
14
|
-
import
|
|
15
|
-
import
|
|
16
|
-
import
|
|
17
|
-
import { d as
|
|
14
|
+
import J from "deepmerge";
|
|
15
|
+
import Q from "three/examples/jsm/libs/stats.module";
|
|
16
|
+
import ee from "lil-gui";
|
|
17
|
+
import { d as te } from "./disposeMesh.module.js";
|
|
18
18
|
import "idb-keyval";
|
|
19
|
-
import { OrbitControls as
|
|
20
|
-
import { CSS3DRenderer as
|
|
21
|
-
import { CSS2DRenderer as
|
|
22
|
-
import { EffectComposer as
|
|
23
|
-
import { i as
|
|
24
|
-
import { B as
|
|
19
|
+
import { OrbitControls as ne } from "three/examples/jsm/controls/OrbitControls";
|
|
20
|
+
import { CSS3DRenderer as se } from "three/examples/jsm/renderers/CSS3DRenderer";
|
|
21
|
+
import { CSS2DRenderer as re } from "three/examples/jsm/renderers/CSS2DRenderer";
|
|
22
|
+
import { EffectComposer as ie, RenderPass as oe, CopyPass as ae, FXAAEffect as ce, BlendFunction as le, EffectPass as z, SelectiveBloomEffect as fe } from "postprocessing";
|
|
23
|
+
import { i as de } from "./isPlainObject.module.js";
|
|
24
|
+
import { B as Ke } from "./BaseObject.module.js";
|
|
25
25
|
import "./makePromiseCreator.module.js";
|
|
26
|
-
var L = {},
|
|
26
|
+
var L = {}, he = {
|
|
27
27
|
get exports() {
|
|
28
28
|
return L;
|
|
29
29
|
},
|
|
30
30
|
set exports(n) {
|
|
31
31
|
L = n;
|
|
32
32
|
}
|
|
33
|
-
},
|
|
33
|
+
}, y = typeof Reflect == "object" ? Reflect : null, A = y && typeof y.apply == "function" ? y.apply : function(e, t, s) {
|
|
34
34
|
return Function.prototype.apply.call(e, t, s);
|
|
35
35
|
}, E;
|
|
36
|
-
|
|
36
|
+
y && typeof y.ownKeys == "function" ? E = y.ownKeys : Object.getOwnPropertySymbols ? E = function(e) {
|
|
37
37
|
return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e));
|
|
38
38
|
} : E = function(e) {
|
|
39
39
|
return Object.getOwnPropertyNames(e);
|
|
40
40
|
};
|
|
41
|
-
function
|
|
41
|
+
function ue(n) {
|
|
42
42
|
console && console.warn && console.warn(n);
|
|
43
43
|
}
|
|
44
|
-
var
|
|
44
|
+
var I = Number.isNaN || function(e) {
|
|
45
45
|
return e !== e;
|
|
46
46
|
};
|
|
47
47
|
function l() {
|
|
48
48
|
l.init.call(this);
|
|
49
49
|
}
|
|
50
|
-
|
|
51
|
-
L.once =
|
|
50
|
+
he.exports = l;
|
|
51
|
+
L.once = ge;
|
|
52
52
|
l.EventEmitter = l;
|
|
53
53
|
l.prototype._events = void 0;
|
|
54
54
|
l.prototype._eventsCount = 0;
|
|
@@ -64,7 +64,7 @@ Object.defineProperty(l, "defaultMaxListeners", {
|
|
|
64
64
|
return j;
|
|
65
65
|
},
|
|
66
66
|
set: function(n) {
|
|
67
|
-
if (typeof n != "number" || n < 0 ||
|
|
67
|
+
if (typeof n != "number" || n < 0 || I(n))
|
|
68
68
|
throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received ' + n + ".");
|
|
69
69
|
j = n;
|
|
70
70
|
}
|
|
@@ -73,15 +73,15 @@ l.init = function() {
|
|
|
73
73
|
(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;
|
|
74
74
|
};
|
|
75
75
|
l.prototype.setMaxListeners = function(e) {
|
|
76
|
-
if (typeof e != "number" || e < 0 ||
|
|
76
|
+
if (typeof e != "number" || e < 0 || I(e))
|
|
77
77
|
throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received ' + e + ".");
|
|
78
78
|
return this._maxListeners = e, this;
|
|
79
79
|
};
|
|
80
|
-
function
|
|
80
|
+
function B(n) {
|
|
81
81
|
return n._maxListeners === void 0 ? l.defaultMaxListeners : n._maxListeners;
|
|
82
82
|
}
|
|
83
83
|
l.prototype.getMaxListeners = function() {
|
|
84
|
-
return
|
|
84
|
+
return B(this);
|
|
85
85
|
};
|
|
86
86
|
l.prototype.emit = function(e) {
|
|
87
87
|
for (var t = [], s = 1; s < arguments.length; s++)
|
|
@@ -108,7 +108,7 @@ l.prototype.emit = function(e) {
|
|
|
108
108
|
A(d[s], this, t);
|
|
109
109
|
return !0;
|
|
110
110
|
};
|
|
111
|
-
function
|
|
111
|
+
function G(n, e, t, s) {
|
|
112
112
|
var r, o, i;
|
|
113
113
|
if (x(t), o = n._events, o === void 0 ? (o = n._events = /* @__PURE__ */ Object.create(null), n._eventsCount = 0) : (o.newListener !== void 0 && (n.emit(
|
|
114
114
|
"newListener",
|
|
@@ -116,26 +116,26 @@ function I(n, e, t, s) {
|
|
|
116
116
|
t.listener ? t.listener : t
|
|
117
117
|
), o = n._events), i = o[e]), i === void 0)
|
|
118
118
|
i = o[e] = t, ++n._eventsCount;
|
|
119
|
-
else if (typeof i == "function" ? i = o[e] = s ? [t, i] : [i, t] : s ? i.unshift(t) : i.push(t), r =
|
|
119
|
+
else if (typeof i == "function" ? i = o[e] = s ? [t, i] : [i, t] : s ? i.unshift(t) : i.push(t), r = B(n), r > 0 && i.length > r && !i.warned) {
|
|
120
120
|
i.warned = !0;
|
|
121
121
|
var a = new Error("Possible EventEmitter memory leak detected. " + i.length + " " + String(e) + " listeners added. Use emitter.setMaxListeners() to increase limit");
|
|
122
|
-
a.name = "MaxListenersExceededWarning", a.emitter = n, a.type = e, a.count = i.length,
|
|
122
|
+
a.name = "MaxListenersExceededWarning", a.emitter = n, a.type = e, a.count = i.length, ue(a);
|
|
123
123
|
}
|
|
124
124
|
return n;
|
|
125
125
|
}
|
|
126
126
|
l.prototype.addListener = function(e, t) {
|
|
127
|
-
return
|
|
127
|
+
return G(this, e, t, !1);
|
|
128
128
|
};
|
|
129
129
|
l.prototype.on = l.prototype.addListener;
|
|
130
130
|
l.prototype.prependListener = function(e, t) {
|
|
131
|
-
return
|
|
131
|
+
return G(this, e, t, !0);
|
|
132
132
|
};
|
|
133
|
-
function
|
|
133
|
+
function me() {
|
|
134
134
|
if (!this.fired)
|
|
135
135
|
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);
|
|
136
136
|
}
|
|
137
137
|
function N(n, e, t) {
|
|
138
|
-
var s = { fired: !1, wrapFn: void 0, target: n, type: e, listener: t }, r =
|
|
138
|
+
var s = { fired: !1, wrapFn: void 0, target: n, type: e, listener: t }, r = me.bind(s);
|
|
139
139
|
return r.listener = t, s.wrapFn = r, r;
|
|
140
140
|
}
|
|
141
141
|
l.prototype.once = function(e, t) {
|
|
@@ -160,7 +160,7 @@ l.prototype.removeListener = function(e, t) {
|
|
|
160
160
|
}
|
|
161
161
|
if (o < 0)
|
|
162
162
|
return this;
|
|
163
|
-
o === 0 ? s.shift() :
|
|
163
|
+
o === 0 ? s.shift() : pe(s, o), s.length === 1 && (r[e] = s[0]), r.removeListener !== void 0 && this.emit("removeListener", e, a || t);
|
|
164
164
|
}
|
|
165
165
|
return this;
|
|
166
166
|
};
|
|
@@ -189,7 +189,7 @@ function F(n, e, t) {
|
|
|
189
189
|
if (s === void 0)
|
|
190
190
|
return [];
|
|
191
191
|
var r = s[e];
|
|
192
|
-
return r === void 0 ? [] : typeof r == "function" ? t ? [r.listener || r] : [r] : t ?
|
|
192
|
+
return r === void 0 ? [] : typeof r == "function" ? t ? [r.listener || r] : [r] : t ? ve(r) : k(r, r.length);
|
|
193
193
|
}
|
|
194
194
|
l.prototype.listeners = function(e) {
|
|
195
195
|
return F(this, e, !0);
|
|
@@ -220,17 +220,17 @@ function k(n, e) {
|
|
|
220
220
|
t[s] = n[s];
|
|
221
221
|
return t;
|
|
222
222
|
}
|
|
223
|
-
function
|
|
223
|
+
function pe(n, e) {
|
|
224
224
|
for (; e + 1 < n.length; e++)
|
|
225
225
|
n[e] = n[e + 1];
|
|
226
226
|
n.pop();
|
|
227
227
|
}
|
|
228
|
-
function
|
|
228
|
+
function ve(n) {
|
|
229
229
|
for (var e = new Array(n.length), t = 0; t < e.length; ++t)
|
|
230
230
|
e[t] = n[t].listener || n[t];
|
|
231
231
|
return e;
|
|
232
232
|
}
|
|
233
|
-
function
|
|
233
|
+
function ge(n, e) {
|
|
234
234
|
return new Promise(function(t, s) {
|
|
235
235
|
function r(i) {
|
|
236
236
|
n.removeListener(e, o), s(i);
|
|
@@ -238,10 +238,10 @@ function ve(n, e) {
|
|
|
238
238
|
function o() {
|
|
239
239
|
typeof n.removeListener == "function" && n.removeListener("error", r), t([].slice.call(arguments));
|
|
240
240
|
}
|
|
241
|
-
H(n, e, o, { once: !0 }), e !== "error" &&
|
|
241
|
+
H(n, e, o, { once: !0 }), e !== "error" && Ce(n, r, { once: !0 });
|
|
242
242
|
});
|
|
243
243
|
}
|
|
244
|
-
function
|
|
244
|
+
function Ce(n, e, t) {
|
|
245
245
|
typeof n.on == "function" && H(n, "error", e, t);
|
|
246
246
|
}
|
|
247
247
|
function H(n, e, t, s) {
|
|
@@ -273,10 +273,10 @@ class O {
|
|
|
273
273
|
target: g
|
|
274
274
|
} = r[o], R = o.toLowerCase().indexOf("color") > -1;
|
|
275
275
|
let u;
|
|
276
|
-
const
|
|
276
|
+
const P = typeof p == "undefined" && g, C = P ? g() : r[o], v = P ? o : "value";
|
|
277
277
|
m ? u = s.add(C, v, m) : R ? u = s.addColor(C, v) : u = s.add(C, v), u = u.name(h || o), typeof i != "undefined" && (u = u.min(i)), typeof a != "undefined" && (u = u.max(a)), typeof c != "undefined" && (u = u.step(c)), u = u.onChange(() => {
|
|
278
278
|
this.setTargetValue(t, o, C[v], d);
|
|
279
|
-
}),
|
|
279
|
+
}), P && u.listen();
|
|
280
280
|
});
|
|
281
281
|
});
|
|
282
282
|
}
|
|
@@ -317,7 +317,7 @@ const D = {
|
|
|
317
317
|
Reinhard: f.ReinhardToneMapping,
|
|
318
318
|
Cineon: f.CineonToneMapping,
|
|
319
319
|
ACESFilmic: f.ACESFilmicToneMapping
|
|
320
|
-
},
|
|
320
|
+
}, be = {
|
|
321
321
|
antialias: !1,
|
|
322
322
|
devicePixelRatio: window.devicePixelRatio,
|
|
323
323
|
powerPreference: "high-performance",
|
|
@@ -332,7 +332,7 @@ const D = {
|
|
|
332
332
|
depth: !1,
|
|
333
333
|
physicallyCorrectLights: !1
|
|
334
334
|
};
|
|
335
|
-
class
|
|
335
|
+
class ye {
|
|
336
336
|
constructor(e) {
|
|
337
337
|
this.options = e;
|
|
338
338
|
const { width: t, height: s, rendererParams: r } = e, {
|
|
@@ -347,7 +347,7 @@ class be {
|
|
|
347
347
|
logarithmicDepthBuffer: g,
|
|
348
348
|
preserveDrawingBuffer: R,
|
|
349
349
|
stencil: u,
|
|
350
|
-
depth:
|
|
350
|
+
depth: P,
|
|
351
351
|
physicallyCorrectLights: C
|
|
352
352
|
} = r, v = new f.WebGLRenderer({
|
|
353
353
|
context: o,
|
|
@@ -357,9 +357,11 @@ class be {
|
|
|
357
357
|
logarithmicDepthBuffer: g,
|
|
358
358
|
preserveDrawingBuffer: R,
|
|
359
359
|
stencil: u,
|
|
360
|
-
depth:
|
|
360
|
+
depth: P
|
|
361
361
|
});
|
|
362
|
-
v.setSize(t, s), v.setPixelRatio(a), v.toneMapping = D[d], v.toneMappingExposure = m, v.outputEncoding = p
|
|
362
|
+
v.setSize(t, s), v.setPixelRatio(a), v.toneMapping = D[d], v.toneMappingExposure = m, v.outputEncoding = p;
|
|
363
|
+
const U = +f.REVISION < 150 ? "physicallyCorrectLights" : "useLegacyLights";
|
|
364
|
+
v[U] = C, this.renderer = v;
|
|
363
365
|
}
|
|
364
366
|
setSize(e, t) {
|
|
365
367
|
this.renderer.setSize(e, t);
|
|
@@ -395,7 +397,7 @@ const Pe = {
|
|
|
395
397
|
near: 1,
|
|
396
398
|
far: 1e3
|
|
397
399
|
};
|
|
398
|
-
class
|
|
400
|
+
class we {
|
|
399
401
|
constructor(e) {
|
|
400
402
|
this.oldCameraPosition = new f.Vector3(), this.oldCameraRotation = new f.Euler(), this.customCamera = !1, this.options = e;
|
|
401
403
|
const { width: t, height: s, cameraParams: r } = e;
|
|
@@ -471,10 +473,10 @@ class ye {
|
|
|
471
473
|
}), t.showGui(e);
|
|
472
474
|
}
|
|
473
475
|
}
|
|
474
|
-
const
|
|
476
|
+
const Ee = {
|
|
475
477
|
background: null
|
|
476
478
|
};
|
|
477
|
-
class
|
|
479
|
+
class Le {
|
|
478
480
|
constructor(e) {
|
|
479
481
|
this.options = e;
|
|
480
482
|
const { camera: t, sceneParams: s } = e, { background: r } = s, o = new f.Scene();
|
|
@@ -488,14 +490,14 @@ class Ee {
|
|
|
488
490
|
dispose() {
|
|
489
491
|
var e;
|
|
490
492
|
(e = this.scene) == null || e.traverse((t) => {
|
|
491
|
-
|
|
493
|
+
te(t);
|
|
492
494
|
});
|
|
493
495
|
}
|
|
494
496
|
}
|
|
495
|
-
class
|
|
497
|
+
class xe {
|
|
496
498
|
constructor(e) {
|
|
497
499
|
this.options = e;
|
|
498
|
-
const { camera: t, controlParams: s, customControl: r } = e, { domElement: o } = s, i = r ? new r(t, o) : new
|
|
500
|
+
const { camera: t, controlParams: s, customControl: r } = e, { domElement: o } = s, i = r ? new r(t, o) : new ne(t, o);
|
|
499
501
|
i.minPolarAngle = Math.PI * 0.15, i.maxPolarAngle = Math.PI * 0.85, i.enableDamping = !0, i.dampingFactor = 0.063, i.autoRotate = !1, i.autoRotateSpeed = -60, i.enableZoom = !0, i.zoomSpeed = 0.2, this.control = i;
|
|
500
502
|
}
|
|
501
503
|
limitPan({
|
|
@@ -519,12 +521,12 @@ class Le {
|
|
|
519
521
|
const T = {
|
|
520
522
|
zIndex: "auto"
|
|
521
523
|
};
|
|
522
|
-
class
|
|
524
|
+
class Re {
|
|
523
525
|
constructor(e) {
|
|
524
526
|
this.container = e;
|
|
525
527
|
}
|
|
526
528
|
addRenderer(e, t) {
|
|
527
|
-
const { container: s } = this, r = s.offsetWidth, o = s.offsetHeight, i = e === "css2d" ? new
|
|
529
|
+
const { container: s } = this, r = s.offsetWidth, o = s.offsetHeight, i = e === "css2d" ? new re() : new se();
|
|
528
530
|
i.domElement.style.position = "absolute", i.domElement.style.top = "0", i.domElement.style.pointerEvents = "none", i.domElement.style.zIndex = t.zIndex, i.setSize(r, o), s.appendChild(i.domElement), e === "css2d" ? this.css2Drenderer = i : e === "css3d" && (this.css3Drenderer = i);
|
|
529
531
|
}
|
|
530
532
|
setSize(e, t) {
|
|
@@ -539,30 +541,30 @@ class xe {
|
|
|
539
541
|
this.css2Drenderer = void 0, this.css3Drenderer = void 0;
|
|
540
542
|
}
|
|
541
543
|
}
|
|
542
|
-
const
|
|
544
|
+
const Se = {
|
|
543
545
|
luminanceThreshold: 0.1,
|
|
544
546
|
luminanceSmoothing: 0.3,
|
|
545
547
|
mipmapBlur: !0,
|
|
546
548
|
intensity: 4
|
|
547
549
|
};
|
|
548
|
-
class
|
|
550
|
+
class Oe {
|
|
549
551
|
constructor(e) {
|
|
550
552
|
this.active = !0, this.options = e;
|
|
551
|
-
const { renderer: t, scene: s, camera: r, composerParams: o } = e, { multisampling: i } = o, { maxSamples: a } = t.capabilities, c = new
|
|
553
|
+
const { renderer: t, scene: s, camera: r, composerParams: o } = e, { multisampling: i } = o, { maxSamples: a } = t.capabilities, c = new ie(t, {
|
|
552
554
|
multisampling: Math.min(i, a)
|
|
553
555
|
});
|
|
554
|
-
c.addPass(new
|
|
556
|
+
c.addPass(new oe(s, r)), this.finalComposer = c, this.renderer = t, this.scene = s, this.camera = r;
|
|
555
557
|
}
|
|
556
558
|
addCopyPass() {
|
|
557
|
-
const e = new
|
|
559
|
+
const e = new ae();
|
|
558
560
|
e.renderToScreen = !0, this.finalComposer.addPass(e), this.copyPass = e;
|
|
559
561
|
}
|
|
560
562
|
addFXAAPass() {
|
|
561
|
-
const { camera: e } = this, t = new
|
|
563
|
+
const { camera: e } = this, t = new ce({ blendFunction: le.NORMAL }), s = new z(e, t);
|
|
562
564
|
this.finalComposer.addPass(s), this.fxaaPass = s;
|
|
563
565
|
}
|
|
564
566
|
addBloomPass(e) {
|
|
565
|
-
const { camera: t, scene: s } = this, r = new
|
|
567
|
+
const { camera: t, scene: s } = this, r = new fe(s, t, b({}, e)), o = new z(t, r);
|
|
566
568
|
o.enabled = !1, this.finalComposer.addPass(o), this.bloomPass = o, this.bloomEffect = r;
|
|
567
569
|
}
|
|
568
570
|
addBloomGui(e) {
|
|
@@ -640,17 +642,17 @@ class Se {
|
|
|
640
642
|
this.finalComposer.dispose();
|
|
641
643
|
}
|
|
642
644
|
}
|
|
643
|
-
const
|
|
645
|
+
const Me = () => {
|
|
644
646
|
try {
|
|
645
647
|
const n = document.createElement("canvas");
|
|
646
648
|
return !!(window.WebGL2RenderingContext && n.getContext("webgl2"));
|
|
647
649
|
} catch (n) {
|
|
648
650
|
return !1;
|
|
649
651
|
}
|
|
650
|
-
}, w = !1, W =
|
|
652
|
+
}, w = !1, W = Me() !== !1, K = class {
|
|
651
653
|
constructor(n) {
|
|
652
|
-
this.raycaster = new f.Raycaster(), this.installPlugins = /* @__PURE__ */ new Map(), this.event = new L.EventEmitter(), this.clock = new f.Clock(), this.userData = {}, this.options =
|
|
653
|
-
isMergeableObject:
|
|
654
|
+
this.raycaster = new f.Raycaster(), this.installPlugins = /* @__PURE__ */ new Map(), this.event = new L.EventEmitter(), this.clock = new f.Clock(), this.userData = {}, this.options = J(K.options, n, {
|
|
655
|
+
isMergeableObject: de
|
|
654
656
|
});
|
|
655
657
|
const {
|
|
656
658
|
container: e,
|
|
@@ -659,11 +661,11 @@ const Oe = () => {
|
|
|
659
661
|
resizeObserver: r
|
|
660
662
|
} = this.options;
|
|
661
663
|
if (s) {
|
|
662
|
-
const o = new
|
|
664
|
+
const o = new ee();
|
|
663
665
|
o.open(!1), this.gui = o;
|
|
664
666
|
}
|
|
665
667
|
if (t) {
|
|
666
|
-
const o = new
|
|
668
|
+
const o = new Q();
|
|
667
669
|
o.showPanel(0), o.dom.style.position = "absolute", e.appendChild(o.dom), this.stats = o;
|
|
668
670
|
}
|
|
669
671
|
this.init(), this.initComposer(), this.initCSSRenderer(), this.initControl(), r && this.initResizeObserver(), this.clock.getDelta(), this.clock.getElapsedTime();
|
|
@@ -692,17 +694,17 @@ const Oe = () => {
|
|
|
692
694
|
renderer: s,
|
|
693
695
|
scene: r,
|
|
694
696
|
camera: o
|
|
695
|
-
} = this.options, { width: i, height: a } = this.getSize(), c = new
|
|
697
|
+
} = this.options, { width: i, height: a } = this.getSize(), c = new we({
|
|
696
698
|
isdev: e,
|
|
697
699
|
width: i,
|
|
698
700
|
height: a,
|
|
699
701
|
cameraParams: o
|
|
700
702
|
});
|
|
701
703
|
this.gui && c.setGui(this.gui);
|
|
702
|
-
const h = c.camera, d = new
|
|
704
|
+
const h = c.camera, d = new Le({
|
|
703
705
|
camera: h,
|
|
704
706
|
sceneParams: r
|
|
705
|
-
}), m = d.scene, p = new
|
|
707
|
+
}), m = d.scene, p = new ye({
|
|
706
708
|
width: i,
|
|
707
709
|
height: a,
|
|
708
710
|
scene: m,
|
|
@@ -726,7 +728,7 @@ const Oe = () => {
|
|
|
726
728
|
} = this.options;
|
|
727
729
|
let { antialias: o } = t;
|
|
728
730
|
o === "msaa" && !W && (o = !1, console.warn("MSAA is not supported on this browser"));
|
|
729
|
-
const i = new
|
|
731
|
+
const i = new Oe({
|
|
730
732
|
renderer: this.renderer,
|
|
731
733
|
scene: this.scene,
|
|
732
734
|
camera: this.camera,
|
|
@@ -749,14 +751,14 @@ const Oe = () => {
|
|
|
749
751
|
css3DRendererParams: r
|
|
750
752
|
} = this.options;
|
|
751
753
|
if (e || t) {
|
|
752
|
-
const o = new
|
|
754
|
+
const o = new Re(n);
|
|
753
755
|
e && o.addRenderer("css2d", s), t && o.addRenderer("css3d", r), this.cssRendererController = o;
|
|
754
756
|
}
|
|
755
757
|
}
|
|
756
758
|
initControl() {
|
|
757
759
|
const { control: n, controlParams: e } = this.options;
|
|
758
760
|
if (n) {
|
|
759
|
-
const t = new
|
|
761
|
+
const t = new xe({
|
|
760
762
|
camera: this.camera,
|
|
761
763
|
controlParams: {
|
|
762
764
|
domElement: (e == null ? void 0 : e.domElement) || this.renderer.domElement
|
|
@@ -837,31 +839,31 @@ const Oe = () => {
|
|
|
837
839
|
}), (e = this.controlController) == null || e.dispose(), (t = this.cssRendererController) == null || t.dispose(), (s = this.sceneController) == null || s.dispose(), (r = this.composerController) == null || r.dispose(), (o = this.rendererController) == null || o.dispose(), this.controlController = void 0, this.cssRendererController = void 0, (i = this.gui) == null || i.destroy(), this.event.removeAllListeners(), this.installPlugins.clear();
|
|
838
840
|
}
|
|
839
841
|
};
|
|
840
|
-
let
|
|
841
|
-
|
|
842
|
+
let _e = K;
|
|
843
|
+
_e.options = {
|
|
842
844
|
isdev: w,
|
|
843
845
|
stats: w,
|
|
844
846
|
gui: w,
|
|
845
847
|
axesHelper: w,
|
|
846
848
|
control: w,
|
|
847
849
|
resizeObserver: !0,
|
|
848
|
-
renderer: S(b({},
|
|
850
|
+
renderer: S(b({}, be), {
|
|
849
851
|
antialias: W ? "msaa" : "fxaa"
|
|
850
852
|
}),
|
|
851
853
|
staticRender: !1,
|
|
852
854
|
multisampling: 4,
|
|
853
|
-
scene:
|
|
855
|
+
scene: Ee,
|
|
854
856
|
camera: Pe,
|
|
855
857
|
bloom: !1,
|
|
856
|
-
bloomParams:
|
|
858
|
+
bloomParams: Se,
|
|
857
859
|
css2DRenderer: !1,
|
|
858
860
|
css2DRendererParams: b({}, T),
|
|
859
861
|
css3DRenderer: !1,
|
|
860
862
|
css3DRendererParams: b({}, T)
|
|
861
863
|
};
|
|
862
864
|
export {
|
|
863
|
-
|
|
865
|
+
Ke as BaseObject,
|
|
864
866
|
O as GUIObject,
|
|
865
|
-
|
|
866
|
-
|
|
867
|
+
_e as Pencil,
|
|
868
|
+
_e as default
|
|
867
869
|
};
|
package/dist/utils/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var P=Object.defineProperty;var
|
|
1
|
+
"use strict";var P=Object.defineProperty;var m=Object.getOwnPropertySymbols;var w=Object.prototype.hasOwnProperty,C=Object.prototype.propertyIsEnumerable;var g=(i,e,t)=>e in i?P(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,k=(i,e)=>{for(var t in e||(e={}))w.call(e,t)&&g(i,t,e[t]);if(m)for(var t of m(e))C.call(e,t)&&g(i,t,e[t]);return i};var u=(i,e,t)=>new Promise((s,n)=>{var o=r=>{try{c(t.next(r))}catch(a){n(a)}},l=r=>{try{c(t.throw(r))}catch(a){n(a)}},c=r=>r.done?s(r.value):Promise.resolve(r.value).then(o,l);c((t=t.apply(i,e)).next())});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("../makePromiseCreator.js"),p=require("../uvGenerator.js"),_=require("../disposeMesh.js"),b=require("three"),E=require("../isPlainObject.js"),h=require("idb-keyval");function L(i){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(i){for(const t in i)if(t!=="default"){const s=Object.getOwnPropertyDescriptor(i,t);Object.defineProperty(e,t,s.get?s:{enumerable:!0,get:()=>i[t]})}}return e.default=i,Object.freeze(e)}const T=L(b);class y{constructor(e){this.onTick_=e,this.cancelPending_=null}tickAfter(e){this.stop();let t=!0,s;this.cancelPending_=()=>{clearTimeout(s),t=!1};const n=()=>{t&&this.onTick_()};return s=window.setTimeout(n,e),this}stop(){this.cancelPending_&&(this.cancelPending_(),this.cancelPending_=null)}}class v{constructor(e){this.onTick_=e,this.ticker_=null}tickNow(){return this.stop(),this.onTick_(),this}tickAfter(e){return this.stop(),this.ticker_=new y(()=>{this.onTick_()}).tickAfter(e),this}tickEvery(e){return this.stop(),this.ticker_=new y(()=>{var t;(t=this.ticker_)==null||t.tickAfter(e),this.onTick_()}).tickAfter(e),this}stop(){this.ticker_&&(this.ticker_.stop(),this.ticker_=null)}}class d{constructor(e={}){this.index=0,this.repeatCount=0,this.repeatNum=0,this.isPlaying=!1,this.chainedList=[],this.children=[],this.options=k({isdev:!1},e)}start(){return this.isPlaying?this:(this.index=0,this.isPlaying=!0,this.play())}stop1(){return this.isPlaying?(this.isPlaying=!1,this.repeatCount=0,this):this}stop(){return this.traverse(e=>e.stop1()),this}dispose(){return this.stop(),this.chainedList=[],this.children=[],this}play(){return u(this,null,function*(){const e=this.chainedList[this.index];e&&this.isPlaying?(yield Promise.all(e.map(t=>typeof t=="function"?t(this.repeatCount):t.start())),this.index+=1,yield this.play()):!e&&this.isPlaying&&this.repeatCount<this.repeatNum?(this.repeatCount+=1,this.index=0,yield this.play()):!e&&this.isPlaying&&this.repeatCount===this.repeatNum&&this.stop()})}chain(...e){return[...e].forEach(t=>{t instanceof d&&this.children.push(t)}),this.chainedList.push([...e]),this}repeat(e){return this.repeatNum=e,this}timeout(e){return this.chain(()=>new Promise(t=>setTimeout(t,e))),this}traverse(e){e(this),this.children.forEach(t=>{t.traverse(e)})}}function j(i){i.material&&(Array.isArray(i.material)?i.material:[i.material]).forEach(t=>{var s,n;(s=t.color)==null||s.convertSRGBToLinear(),(n=t.emissive)==null||n.convertSRGBToLinear(),t.map&&(t.map.encoding=T.sRGBEncoding),t.emissiveMap&&(t.emissiveMap.encoding=T.sRGBEncoding)})}const A=h.del,O=h.clear,G=(s,n)=>u(exports,[s,n],function*(i,{type:e="blob",version:t="1"}){let o;const l=yield h.get(i);if(l&&l[t])o=l[t];else{const{res:c,err:r}=yield f.to(window.fetch(i).then(a=>{if(a.ok)return a[e]();throw new Error}));r||(o=c,h.set(i,{[t]:c}))}return o?{url:e==="json"?i:URL.createObjectURL(o),store:o}:{url:i}}),M=i=>{let e=i.offsetLeft,t=i.offsetParent;for(;t!==null;)e+=t.offsetLeft,t=t.offsetParent;let s;return document.compatMode==="BackCompat"||document.documentElement.scrollTop===0?s=document.body.scrollLeft:s=document.documentElement.scrollLeft,e-s},R=i=>{let e=i.offsetTop,t=i.offsetParent;for(;t!==null;)e+=t.offsetTop,t=t.offsetParent;let s;return document.compatMode==="BackCompat"||document.documentElement.scrollTop===0?s=document.body.scrollTop:s=document.documentElement.scrollTop,e-s};exports.makePromiseCreator=f.makePromiseCreator;exports.to=f.to;exports.claerUVGenerator=p.claerUVGenerator;exports.getUVGenerator=p.getUVGenerator;exports.polar2Cartesian=p.polar2Cartesian;exports.disposeMesh=_.disposeMesh;exports.isPlainObject=E.isPlainObject;exports.Chain=d;exports.Timer=v;exports.clearAllCache=O;exports.clearCache=A;exports.colorCorrection=j;exports.getCache=G;exports.getElementViewLeft=M;exports.getElementViewTop=R;
|