gl-draw 0.8.13 → 0.8.15

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.
@@ -1 +1 @@
1
- (function(){var X={666:function(_){var g=function(v){"use strict";var C=Object.prototype,T=C.hasOwnProperty,d,O=typeof Symbol=="function"?Symbol:{},w=O.iterator||"@@iterator",L=O.asyncIterator||"@@asyncIterator",k=O.toStringTag||"@@toStringTag";function p(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{p({},"")}catch(e){p=function(t,n,l){return t[n]=l}}function R(e,t,n,l){var u=t&&t.prototype instanceof V?t:V,b=Object.create(u.prototype),S=new h(l||[]);return b._invoke=r(e,n,S),b}v.wrap=R;function x(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(l){return{type:"throw",arg:l}}}var z="suspendedStart",N="suspendedYield",Z="executing",H="completed",E={};function V(){}function y(){}function m(){}var P={};p(P,w,function(){return this});var D=Object.getPrototypeOf,G=D&&D(D(j([])));G&&G!==C&&T.call(G,w)&&(P=G);var a=m.prototype=V.prototype=Object.create(P);y.prototype=m,p(a,"constructor",m),p(m,"constructor",y),y.displayName=p(m,k,"GeneratorFunction");function i(e){["next","throw","return"].forEach(function(t){p(e,t,function(n){return this._invoke(t,n)})})}v.isGeneratorFunction=function(e){var t=typeof e=="function"&&e.constructor;return t?t===y||(t.displayName||t.name)==="GeneratorFunction":!1},v.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,m):(e.__proto__=m,p(e,k,"GeneratorFunction")),e.prototype=Object.create(a),e},v.awrap=function(e){return{__await:e}};function s(e,t){function n(b,S,A,B){var I=x(e[b],e,S);if(I.type==="throw")B(I.arg);else{var $=I.arg,F=$.value;return F&&typeof F=="object"&&T.call(F,"__await")?t.resolve(F.__await).then(function(W){n("next",W,A,B)},function(W){n("throw",W,A,B)}):t.resolve(F).then(function(W){$.value=W,A($)},function(W){return n("throw",W,A,B)})}}var l;function u(b,S){function A(){return new t(function(B,I){n(b,S,B,I)})}return l=l?l.then(A,A):A()}this._invoke=u}i(s.prototype),p(s.prototype,L,function(){return this}),v.AsyncIterator=s,v.async=function(e,t,n,l,u){u===void 0&&(u=Promise);var b=new s(R(e,t,n,l),u);return v.isGeneratorFunction(t)?b:b.next().then(function(S){return S.done?S.value:b.next()})};function r(e,t,n){var l=z;return function(b,S){if(l===Z)throw new Error("Generator is already running");if(l===H){if(b==="throw")throw S;return M()}for(n.method=b,n.arg=S;;){var A=n.delegate;if(A){var B=o(A,n);if(B){if(B===E)continue;return B}}if(n.method==="next")n.sent=n._sent=n.arg;else if(n.method==="throw"){if(l===z)throw l=H,n.arg;n.dispatchException(n.arg)}else n.method==="return"&&n.abrupt("return",n.arg);l=Z;var I=x(e,t,n);if(I.type==="normal"){if(l=n.done?H:N,I.arg===E)continue;return{value:I.arg,done:n.done}}else I.type==="throw"&&(l=H,n.method="throw",n.arg=I.arg)}}}function o(e,t){var n=e.iterator[t.method];if(n===d){if(t.delegate=null,t.method==="throw"){if(e.iterator.return&&(t.method="return",t.arg=d,o(e,t),t.method==="throw"))return E;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return E}var l=x(n,e.iterator,t.arg);if(l.type==="throw")return t.method="throw",t.arg=l.arg,t.delegate=null,E;var u=l.arg;if(!u)return t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,E;if(u.done)t[e.resultName]=u.value,t.next=e.nextLoc,t.method!=="return"&&(t.method="next",t.arg=d);else return u;return t.delegate=null,E}i(a),p(a,k,"Generator"),p(a,w,function(){return this}),p(a,"toString",function(){return"[object Generator]"});function f(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function c(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function h(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(f,this),this.reset(!0)}v.keys=function(e){var t=[];for(var n in e)t.push(n);return t.reverse(),function l(){for(;t.length;){var u=t.pop();if(u in e)return l.value=u,l.done=!1,l}return l.done=!0,l}};function j(e){if(e){var t=e[w];if(t)return t.call(e);if(typeof e.next=="function")return e;if(!isNaN(e.length)){var n=-1,l=function u(){for(;++n<e.length;)if(T.call(e,n))return u.value=e[n],u.done=!1,u;return u.value=d,u.done=!0,u};return l.next=l}}return{next:M}}v.values=j;function M(){return{value:d,done:!0}}return h.prototype={constructor:h,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=d,this.done=!1,this.delegate=null,this.method="next",this.arg=d,this.tryEntries.forEach(c),!e)for(var t in this)t.charAt(0)==="t"&&T.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=d)},stop:function(){this.done=!0;var e=this.tryEntries[0],t=e.completion;if(t.type==="throw")throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function n(B,I){return b.type="throw",b.arg=e,t.next=B,I&&(t.method="next",t.arg=d),!!I}for(var l=this.tryEntries.length-1;l>=0;--l){var u=this.tryEntries[l],b=u.completion;if(u.tryLoc==="root")return n("end");if(u.tryLoc<=this.prev){var S=T.call(u,"catchLoc"),A=T.call(u,"finallyLoc");if(S&&A){if(this.prev<u.catchLoc)return n(u.catchLoc,!0);if(this.prev<u.finallyLoc)return n(u.finallyLoc)}else if(S){if(this.prev<u.catchLoc)return n(u.catchLoc,!0)}else if(A){if(this.prev<u.finallyLoc)return n(u.finallyLoc)}else throw new Error("try statement without catch or finally")}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var l=this.tryEntries[n];if(l.tryLoc<=this.prev&&T.call(l,"finallyLoc")&&this.prev<l.finallyLoc){var u=l;break}}u&&(e==="break"||e==="continue")&&u.tryLoc<=t&&t<=u.finallyLoc&&(u=null);var b=u?u.completion:{};return b.type=e,b.arg=t,u?(this.method="next",this.next=u.finallyLoc,E):this.complete(b)},complete:function(e,t){if(e.type==="throw")throw e.arg;return e.type==="break"||e.type==="continue"?this.next=e.arg:e.type==="return"?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):e.type==="normal"&&t&&(this.next=t),E},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),c(n),E}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var l=n.completion;if(l.type==="throw"){var u=l.arg;c(n)}return u}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:j(e),resultName:t,nextLoc:n},this.method==="next"&&(this.arg=d),E}},v}(_.exports);try{regeneratorRuntime=g}catch(v){typeof globalThis=="object"?globalThis.regeneratorRuntime=g:Function("r","regeneratorRuntime = r")(g)}},584:function(_,g,v){"use strict";v.d(g,{makePromiseCreator:function(){return C.Z}});var C=v(282),T=v(666),d=v.n(T),O=null,w=v(644);function L(E){if(E.material){var V=Array.isArray(E.material)?E.material:[E.material];V.forEach(function(y){var m,P;(m=y.color)===null||m===void 0||m.convertSRGBToLinear(),(P=y.emissive)===null||P===void 0||P.convertSRGBToLinear(),y.map&&(y.map.encoding=THREE.sRGBEncoding),y.emissiveMap&&(y.emissiveMap.encoding=THREE.sRGBEncoding)})}}var k=v(568),p=v(924),R=v(360),x=v(484),z=null,N=null,Z=function(){var E=(0,k.Z)(d().mark(function V(y,m){var P,D,G,a,i,s,r,o,f;return d().wrap(function(h){for(;;)switch(h.prev=h.next){case 0:return P=m.type,D=P===void 0?"blob":P,G=m.version,a=G===void 0?"1":G,h.next=4,(0,R.get)(y);case 4:if(s=h.sent,!(s&&s[a])){h.next=9;break}i=s[a],h.next=15;break;case 9:return h.next=11,(0,x.Z)(fetch(y).then(function(j){if(j.ok)return j[D]();throw new Error}));case 11:r=h.sent,o=r.res,f=r.err,f||(i=o,(0,R.set)(y,(0,p.Z)({},a,o)));case 15:return h.abrupt("return",i?{url:D==="json"?y:URL.createObjectURL(i),store:i}:{url:y});case 16:case"end":return h.stop()}},V)}));return function(y,m){return E.apply(this,arguments)}}(),H=v(705)},282:function(_,g,v){"use strict";v.d(g,{Z:function(){return T}});var C=v(484);function T(){var d=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1,O=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},w={};return w.promise=new Promise(function(L,k){w.resolve=L,w.reject=k}),d&&(w.promise=(0,C.Z)(w.promise,O)),w}},484:function(_,g,v){"use strict";v.d(g,{Z:function(){return T}});var C=v(42);function T(d){var O=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return d.then(function(w){return(0,C.Z)({err:null,res:w},O)}).catch(function(w){return(0,C.Z)({err:w,res:void 0},O)})}},705:function(_,g,v){"use strict";var C=v(644),T=v.n(C),d=new Map,O=function(){var L=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return{generateTopUV:function(k,p,R,x,z){var N=p[R*3],Z=p[R*3+1],H=p[x*3],E=p[x*3+1],V=p[z*3],y=p[z*3+1],m;if(d.has(k))m=d.get(k);else{var P=L.box3||new THREE.Box3;if(!L.box3){var D=k.parameters.shapes.getPoints();P.setFromArray(D.map(function(r){return[r.x,r.y,0]}).flat())}var G=P.getSize(new THREE.Vector3);L.split&&(G.y/=L.split),m={box:P,size:G},d.set(k,m)}var a=m.box,i=m.size,s=L.split?1-L.split:0;return[new THREE.Vector2((N-a.min.x)/i.x,(Z-a.min.y)/i.y+s),new THREE.Vector2((H-a.min.x)/i.x,(E-a.min.y)/i.y+s),new THREE.Vector2((V-a.min.x)/i.x,(y-a.min.y)/i.y+s)]},generateSideWallUV:function(k,p,R,x,z,N){var Z=p[R*3],H=p[R*3+1],E=p[R*3+2],V=p[x*3],y=p[x*3+1],m=p[x*3+2],P=p[z*3],D=p[z*3+1],G=p[z*3+2],a=p[N*3],i=p[N*3+1],s=p[N*3+2],r;if(d.has(p))r=d.get(p);else{var o=new THREE.Box3;o.setFromArray(p);var f=o.getSize(new THREE.Vector3);L.split&&(f.z/=1-L.split),r={box:o,size:f},d.set(p,r)}var c=r.box,h=r.size;return Math.abs(H-y)<Math.abs(Z-V)?[new THREE.Vector2((Z-c.min.x)/h.x,(E-c.min.z)/h.z),new THREE.Vector2((V-c.min.x)/h.x,(m-c.min.z)/h.z),new THREE.Vector2((P-c.min.x)/h.x,(G-c.min.z)/h.z),new THREE.Vector2((a-c.min.x)/h.x,(s-c.min.z)/h.z)]:[new THREE.Vector2((H-c.min.y)/h.y,(E-c.min.z)/h.z),new THREE.Vector2((y-c.min.y)/h.y,(m-c.min.z)/h.z),new THREE.Vector2((D-c.min.y)/h.y,(G-c.min.z)/h.z),new THREE.Vector2((i-c.min.y)/h.y,(s-c.min.z)/h.z)]}}},w=function(){d.clear()}},360:function(_){"use strict";_.exports=require("idb-keyval")},644:function(_){"use strict";_.exports=require("three")},568:function(_,g,v){"use strict";v.d(g,{Z:function(){return T}});function C(d,O,w,L,k,p,R){try{var x=d[p](R),z=x.value}catch(N){w(N);return}x.done?O(z):Promise.resolve(z).then(L,k)}function T(d){return function(){var O=this,w=arguments;return new Promise(function(L,k){var p=d.apply(O,w);function R(z){C(p,L,k,R,x,"next",z)}function x(z){C(p,L,k,R,x,"throw",z)}R(void 0)})}}},924:function(_,g,v){"use strict";v.d(g,{Z:function(){return C}});function C(T,d,O){return d in T?Object.defineProperty(T,d,{value:O,enumerable:!0,configurable:!0,writable:!0}):T[d]=O,T}},42:function(_,g,v){"use strict";v.d(g,{Z:function(){return T}});var C=v(924);function T(d){for(var O=1;O<arguments.length;O++){var w=arguments[O]!=null?arguments[O]:{},L=Object.keys(w);typeof Object.getOwnPropertySymbols=="function"&&(L=L.concat(Object.getOwnPropertySymbols(w).filter(function(k){return Object.getOwnPropertyDescriptor(w,k).enumerable}))),L.forEach(function(k){(0,C.Z)(d,k,w[k])})}return d}}},Y={};function U(_){var g=Y[_];if(g!==void 0)return g.exports;var v=Y[_]={exports:{}};return X[_](v,v.exports,U),v.exports}(function(){U.n=function(_){var g=_&&_.__esModule?function(){return _.default}:function(){return _};return U.d(g,{a:g}),g}})(),function(){U.d=function(_,g){for(var v in g)U.o(g,v)&&!U.o(_,v)&&Object.defineProperty(_,v,{enumerable:!0,get:g[v]})}}(),function(){U.o=function(_,g){return Object.prototype.hasOwnProperty.call(_,g)}}(),function(){U.r=function(_){typeof Symbol!="undefined"&&Symbol.toStringTag&&Object.defineProperty(_,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(_,"__esModule",{value:!0})}}();var K={};(function(){"use strict";U.r(K),U.d(K,{Cache:function(){return v},Data:function(){return y},Draw:function(){return V},Wk:function(){return G}});function _(a,i){if(!(a instanceof i))throw new TypeError("Cannot call a class as a function")}var g=U(584),v=function(){"use strict";function a(){_(this,a),this.cache=new Map}var i=a.prototype;return i.install=function(){},i.init=function(r){var o=(0,g.makePromiseCreator)();this.cache.set(r,o)},i.get=function(r){var o;return(o=this.cache.get(r))===null||o===void 0?void 0:o.promise},i.set=function(r,o){var f=this.cache.get(r);f?f.resolve(o):console.warn("init cache first")},i.dispose=function(){this.cache.forEach(function(r,o){r.reject("stop set cache:".concat(o))}),this.cache.clear()},a}(),C=U(568);function T(a,i){for(var s=0;s<i.length;s++){var r=i[s];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(a,r.key,r)}}function d(a,i,s){return i&&T(a.prototype,i),s&&T(a,s),a}function O(a){if(Array.isArray(a))return a}function w(a){if(typeof Symbol!="undefined"&&a[Symbol.iterator]!=null||a["@@iterator"]!=null)return Array.from(a)}function L(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function k(a,i){(i==null||i>a.length)&&(i=a.length);for(var s=0,r=new Array(i);s<i;s++)r[s]=a[s];return r}function p(a,i){if(!!a){if(typeof a=="string")return k(a,i);var s=Object.prototype.toString.call(a).slice(8,-1);if(s==="Object"&&a.constructor&&(s=a.constructor.name),s==="Map"||s==="Set")return Array.from(s);if(s==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(s))return k(a,i)}}function R(a,i){return O(a)||w(a,i)||p(a,i)||L()}function x(a){if(Array.isArray(a))return k(a)}function z(){throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function N(a){return x(a)||w(a)||p(a)||z()}var Z=U(666),H=U.n(Z),E=U(644),V=function(){"use strict";function a(s){_(this,a),this.onTopBase=new Map,this.objectNamesToFactories=new Map,this.objects=new Map,this.objects_=s}var i=a.prototype;return i.install=function(r){this.pencil=r,this.initObjectFactories()},i.initObjectFactories=function(){var r=this,o=this.objects_;Object.keys(o).forEach(function(f){var c=function(){function h(){_(this,h)}var j=h.prototype;return j.create=function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return new o[f](e)},h}();r.objectNamesToFactories.set(f,c)})},i.getObject=function(r,o){r.includes("#")&&console.warn("getObject:err:\u4E0D\u652F\u6301 #",r);var f=(o||{}).key,c="".concat(r).concat(f?"#".concat(f):""),h=this.objects.get(c);return h},i.getAllObject=function(r,o){r.includes("#")&&console.warn("getAllObject:err:\u4E0D\u652F\u6301 #",r);var f=(o||{}).key,c="".concat(r).concat(f?"#".concat(f):""),h=[];return this.objects.forEach(function(j,M){(M.startsWith("".concat(c,"#"))||M===c)&&h.push(j)}),h},i.draw=function(r,o,f){var c=this;return(0,C.Z)(H().mark(function h(){var j,M,e,t,n,l,u,b;return H().wrap(function(A){for(;;)switch(A.prev=A.next){case 0:if(j=c.objectNamesToFactories.get(r),!j){A.next=16;break}return M=(o||{}).key,e="".concat(r).concat(M?"#".concat(M):""),c.objects.has(e)&&(t=E.MathUtils.generateUUID(),e+="#".concat(t)),n=(o==null?void 0:o.target)||f,l=(o==null?void 0:o.onTop)||0,typeof n=="string"?u=c.objects.get(n):(n==null?void 0:n.objecttype__)==="BaseObject"?u=n:u=c.pencil.scene,b=new j().create(o),b.pencil=c.pencil,b.key=e,c.objects.set(e,b),A.next=15,c.addMesh(b,u,l);case 15:return A.abrupt("return",b);case 16:throw new Error("Unrecognized:".concat(r));case 17:case"end":return A.stop()}},h)}))()},i.addMesh=function(r,o,f){var c=this;return(0,C.Z)(H().mark(function h(){var j,M;return H().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,r.create();case 2:r.object3d&&(r.object3d.userData.BaseObject_=r,f&&(j=1e3+f*2,c.onTopBase.has(j-1)||(M=new E.Points,M.renderOrder=j-1,r.object3d.onBeforeRender=function(){c.pencil.renderer.clearDepth()},c.onTopBase.set(j-1,!0),o.add(M)),r.object3d.renderOrder=j),o.add(r.object3d)),r.visible=!0,r.render(),r.pm.resolve();case 6:case"end":return t.stop()}},h)}))()},i.erase=function(){for(var r=arguments.length,o=new Array(r),f=0;f<r;f++)o[f]=arguments[f];var c=this;N(o).forEach(function(h){var j=[];if(typeof h=="string"){var M,e=R(h.split("#"),2),t=e[0],n=e[1];(M=j).push.apply(M,N(c.getAllObject(t,{key:n})))}else j.push(h);j.forEach(function(l){c.removeMesh(l)})})},i.removeMesh=function(r){var o=this,f=r.parent;r.object3d&&f.remove(r.object3d),r.traverse(function(c){c.visible=!1,c.dispose(),o.objects.delete(c.key)})},i.update=function(r,o){this.objects.forEach(function(f){f.update(r,o)})},i.setSize=function(r,o){this.objects.forEach(function(f){f.resize(r,o)})},i.dispose=function(){this.objects.forEach(function(r,o){r.dispose(),r.pm.reject("stop draw:".concat(o))}),this.objects.clear(),this.onTopBase.clear(),this.objectNamesToFactories.clear()},d(a,[{key:"objectsPromise",get:function(){var r=[];return this.objects.forEach(function(o){r.push(o.pm.promise)}),r}}]),a}(),y=function(){"use strict";function a(){_(this,a),this.data={}}var i=a.prototype;return i.install=function(){},i.setData=function(r,o){var f,c;this.data[r]=o,(c=(f=this).cb)===null||c===void 0||c.call(f,r)},i.runAll=function(){var r=this;Object.keys(this.data).forEach(function(o){var f,c;(c=(f=r).cb)===null||c===void 0||c.call(f,o)})},i.dispose=function(){this.data={},this.cb=void 0},a}(),m=U(924),P=U(42),D=U(360),G=function(){"use strict";function a(){var s=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};_(this,a),this.messageList=[],this.options=(0,P.Z)({},{cache:!1,cacheVersion:"1"},s)}var i=a.prototype;return i.install=function(){},i.init=function(r,o){var f=this,c=this.options,h=c.cache,j=c.cacheVersion;this.workerList=Array.from({length:o},function(M,e){var t=typeof r=="string"?new Worker(r):r();return t.onmessage=function(n){var l=n.data,u=l.res,b=l.uuid,S=f.messageList.find(function(B){var I=B.uuid;return b===I});if(S==null||S.options.cb(u),f.workerList[e].inUse=!1,f.checkMessage(),h){var A=(S==null?void 0:S.options.cacheVersion)||j;(0,D.set)(b,(0,m.Z)({},A,u))}},{worker:t,inUse:!1}})},i.postMessage=function(r,o){var f=this,c=this.options,h=c.cache,j=c.cacheVersion;if(h&&!r.workerKey){console.warn("worker cache need workerKey");return}if(h&&r.workerKey&&r.delCache){console.warn("worker cache del: ".concat(r.workerKey)),(0,D.del)(r.workerKey);return}var M=r.workerKey||E.MathUtils.generateUUID();(h?(0,D.get)(M):Promise.resolve()).then(function(e){var t=o.cacheVersion||j;e&&e[t]?o.cb(e[t]):(f.messageList.push({req:r,options:o,uuid:M,inUse:!1}),f.checkMessage())}).catch(function(){console.warn("err:worker cache"),f.messageList.push({req:r,options:o,uuid:M,inUse:!1}),f.checkMessage()})},i.checkMessage=function(){var r=this.workerList.find(function(f){var c=f.inUse;return!c});if(r){var o=this.messageList.find(function(f){var c=f.inUse;return!c});o&&(o.inUse=!0,r.inUse=!0,r.worker.postMessage({req:o.req,uuid:o.uuid}))}},i.dispose=function(){this.workerList.forEach(function(r){var o=r.worker;o.terminate()}),this.workerList=[],this.messageList=[]},a}()})(),module.exports=K})();
1
+ (function(){var X={666:function(_){var g=function(p){"use strict";var C=Object.prototype,T=C.hasOwnProperty,d,O=typeof Symbol=="function"?Symbol:{},E=O.iterator||"@@iterator",P=O.asyncIterator||"@@asyncIterator",k=O.toStringTag||"@@toStringTag";function v(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{v({},"")}catch(e){v=function(t,n,u){return t[n]=u}}function R(e,t,n,u){var f=t&&t.prototype instanceof D?t:D,w=Object.create(f.prototype),S=new l(u||[]);return w._invoke=r(e,n,S),w}p.wrap=R;function z(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(u){return{type:"throw",arg:u}}}var x="suspendedStart",N="suspendedYield",Z="executing",H="completed",b={};function D(){}function y(){}function m(){}var L={};v(L,E,function(){return this});var V=Object.getPrototypeOf,G=V&&V(V(j([])));G&&G!==C&&T.call(G,E)&&(L=G);var a=m.prototype=D.prototype=Object.create(L);y.prototype=m,v(a,"constructor",m),v(m,"constructor",y),y.displayName=v(m,k,"GeneratorFunction");function i(e){["next","throw","return"].forEach(function(t){v(e,t,function(n){return this._invoke(t,n)})})}p.isGeneratorFunction=function(e){var t=typeof e=="function"&&e.constructor;return t?t===y||(t.displayName||t.name)==="GeneratorFunction":!1},p.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,m):(e.__proto__=m,v(e,k,"GeneratorFunction")),e.prototype=Object.create(a),e},p.awrap=function(e){return{__await:e}};function s(e,t){function n(w,S,A,B){var I=z(e[w],e,S);if(I.type==="throw")B(I.arg);else{var $=I.arg,F=$.value;return F&&typeof F=="object"&&T.call(F,"__await")?t.resolve(F.__await).then(function(W){n("next",W,A,B)},function(W){n("throw",W,A,B)}):t.resolve(F).then(function(W){$.value=W,A($)},function(W){return n("throw",W,A,B)})}}var u;function f(w,S){function A(){return new t(function(B,I){n(w,S,B,I)})}return u=u?u.then(A,A):A()}this._invoke=f}i(s.prototype),v(s.prototype,P,function(){return this}),p.AsyncIterator=s,p.async=function(e,t,n,u,f){f===void 0&&(f=Promise);var w=new s(R(e,t,n,u),f);return p.isGeneratorFunction(t)?w:w.next().then(function(S){return S.done?S.value:w.next()})};function r(e,t,n){var u=x;return function(w,S){if(u===Z)throw new Error("Generator is already running");if(u===H){if(w==="throw")throw S;return M()}for(n.method=w,n.arg=S;;){var A=n.delegate;if(A){var B=o(A,n);if(B){if(B===b)continue;return B}}if(n.method==="next")n.sent=n._sent=n.arg;else if(n.method==="throw"){if(u===x)throw u=H,n.arg;n.dispatchException(n.arg)}else n.method==="return"&&n.abrupt("return",n.arg);u=Z;var I=z(e,t,n);if(I.type==="normal"){if(u=n.done?H:N,I.arg===b)continue;return{value:I.arg,done:n.done}}else I.type==="throw"&&(u=H,n.method="throw",n.arg=I.arg)}}}function o(e,t){var n=e.iterator[t.method];if(n===d){if(t.delegate=null,t.method==="throw"){if(e.iterator.return&&(t.method="return",t.arg=d,o(e,t),t.method==="throw"))return b;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return b}var u=z(n,e.iterator,t.arg);if(u.type==="throw")return t.method="throw",t.arg=u.arg,t.delegate=null,b;var f=u.arg;if(!f)return t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,b;if(f.done)t[e.resultName]=f.value,t.next=e.nextLoc,t.method!=="return"&&(t.method="next",t.arg=d);else return f;return t.delegate=null,b}i(a),v(a,k,"Generator"),v(a,E,function(){return this}),v(a,"toString",function(){return"[object Generator]"});function h(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function c(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function l(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(h,this),this.reset(!0)}p.keys=function(e){var t=[];for(var n in e)t.push(n);return t.reverse(),function u(){for(;t.length;){var f=t.pop();if(f in e)return u.value=f,u.done=!1,u}return u.done=!0,u}};function j(e){if(e){var t=e[E];if(t)return t.call(e);if(typeof e.next=="function")return e;if(!isNaN(e.length)){var n=-1,u=function f(){for(;++n<e.length;)if(T.call(e,n))return f.value=e[n],f.done=!1,f;return f.value=d,f.done=!0,f};return u.next=u}}return{next:M}}p.values=j;function M(){return{value:d,done:!0}}return l.prototype={constructor:l,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=d,this.done=!1,this.delegate=null,this.method="next",this.arg=d,this.tryEntries.forEach(c),!e)for(var t in this)t.charAt(0)==="t"&&T.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=d)},stop:function(){this.done=!0;var e=this.tryEntries[0],t=e.completion;if(t.type==="throw")throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function n(B,I){return w.type="throw",w.arg=e,t.next=B,I&&(t.method="next",t.arg=d),!!I}for(var u=this.tryEntries.length-1;u>=0;--u){var f=this.tryEntries[u],w=f.completion;if(f.tryLoc==="root")return n("end");if(f.tryLoc<=this.prev){var S=T.call(f,"catchLoc"),A=T.call(f,"finallyLoc");if(S&&A){if(this.prev<f.catchLoc)return n(f.catchLoc,!0);if(this.prev<f.finallyLoc)return n(f.finallyLoc)}else if(S){if(this.prev<f.catchLoc)return n(f.catchLoc,!0)}else if(A){if(this.prev<f.finallyLoc)return n(f.finallyLoc)}else throw new Error("try statement without catch or finally")}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var u=this.tryEntries[n];if(u.tryLoc<=this.prev&&T.call(u,"finallyLoc")&&this.prev<u.finallyLoc){var f=u;break}}f&&(e==="break"||e==="continue")&&f.tryLoc<=t&&t<=f.finallyLoc&&(f=null);var w=f?f.completion:{};return w.type=e,w.arg=t,f?(this.method="next",this.next=f.finallyLoc,b):this.complete(w)},complete:function(e,t){if(e.type==="throw")throw e.arg;return e.type==="break"||e.type==="continue"?this.next=e.arg:e.type==="return"?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):e.type==="normal"&&t&&(this.next=t),b},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),c(n),b}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var u=n.completion;if(u.type==="throw"){var f=u.arg;c(n)}return f}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:j(e),resultName:t,nextLoc:n},this.method==="next"&&(this.arg=d),b}},p}(_.exports);try{regeneratorRuntime=g}catch(p){typeof globalThis=="object"?globalThis.regeneratorRuntime=g:Function("r","regeneratorRuntime = r")(g)}},584:function(_,g,p){"use strict";p.d(g,{makePromiseCreator:function(){return C.Z}});var C=p(282),T=p(666),d=p.n(T),O=null,E=p(644);function P(b){if(b.material){var D=Array.isArray(b.material)?b.material:[b.material];D.forEach(function(y){var m,L;(m=y.color)===null||m===void 0||m.convertSRGBToLinear(),(L=y.emissive)===null||L===void 0||L.convertSRGBToLinear(),y.map&&(y.map.encoding=THREE.sRGBEncoding),y.emissiveMap&&(y.emissiveMap.encoding=THREE.sRGBEncoding)})}}var k=p(568),v=p(924),R=p(360),z=p(484),x=null,N=null,Z=function(){var b=(0,k.Z)(d().mark(function D(y,m){var L,V,G,a,i,s,r,o,h;return d().wrap(function(l){for(;;)switch(l.prev=l.next){case 0:return L=m.type,V=L===void 0?"blob":L,G=m.version,a=G===void 0?"1":G,l.next=4,(0,R.get)(y);case 4:if(s=l.sent,!(s&&s[a])){l.next=9;break}i=s[a],l.next=15;break;case 9:return l.next=11,(0,z.Z)(fetch(y).then(function(j){if(j.ok)return j[V]();throw new Error}));case 11:r=l.sent,o=r.res,h=r.err,h||(i=o,(0,R.set)(y,(0,v.Z)({},a,o)));case 15:return l.abrupt("return",i?{url:V==="json"?y:URL.createObjectURL(i),store:i}:{url:y});case 16:case"end":return l.stop()}},D)}));return function(y,m){return b.apply(this,arguments)}}(),H=p(705)},282:function(_,g,p){"use strict";p.d(g,{Z:function(){return T}});var C=p(484);function T(){var d=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1,O=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},E={};return E.promise=new Promise(function(P,k){E.resolve=P,E.reject=k}),d&&(E.promise=(0,C.Z)(E.promise,O)),E}},484:function(_,g,p){"use strict";p.d(g,{Z:function(){return T}});var C=p(42);function T(d){var O=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return d.then(function(E){return(0,C.Z)({err:null,res:E},O)}).catch(function(E){return(0,C.Z)({err:E,res:void 0},O)})}},705:function(_,g,p){"use strict";var C=p(644),T=p.n(C),d=new Map,O=function(){var P=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return{generateTopUV:function(k,v,R,z,x){var N=v[R*3],Z=v[R*3+1],H=v[z*3],b=v[z*3+1],D=v[x*3],y=v[x*3+1],m;if(d.has(k))m=d.get(k);else{var L=P.box3||new THREE.Box3;if(!P.box3){var V=k.parameters.shapes.getPoints();L.setFromArray(V.map(function(r){return[r.x,r.y,0]}).flat())}var G=L.getSize(new THREE.Vector3);P.split&&(G.y/=P.split),m={box:L,size:G},d.set(k,m)}var a=m.box,i=m.size,s=P.split?1-P.split:0;return[new THREE.Vector2((N-a.min.x)/i.x,(Z-a.min.y)/i.y+s),new THREE.Vector2((H-a.min.x)/i.x,(b-a.min.y)/i.y+s),new THREE.Vector2((D-a.min.x)/i.x,(y-a.min.y)/i.y+s)]},generateSideWallUV:function(k,v,R,z,x,N){var Z=v[R*3],H=v[R*3+1],b=v[R*3+2],D=v[z*3],y=v[z*3+1],m=v[z*3+2],L=v[x*3],V=v[x*3+1],G=v[x*3+2],a=v[N*3],i=v[N*3+1],s=v[N*3+2],r;if(d.has(v))r=d.get(v);else{var o=new THREE.Box3;o.setFromArray(v);var h=o.getSize(new THREE.Vector3);P.split&&(h.z/=1-P.split),r={box:o,size:h},d.set(v,r)}var c=r.box,l=r.size;return Math.abs(H-y)<Math.abs(Z-D)?[new THREE.Vector2((Z-c.min.x)/l.x,(b-c.min.z)/l.z),new THREE.Vector2((D-c.min.x)/l.x,(m-c.min.z)/l.z),new THREE.Vector2((L-c.min.x)/l.x,(G-c.min.z)/l.z),new THREE.Vector2((a-c.min.x)/l.x,(s-c.min.z)/l.z)]:[new THREE.Vector2((H-c.min.y)/l.y,(b-c.min.z)/l.z),new THREE.Vector2((y-c.min.y)/l.y,(m-c.min.z)/l.z),new THREE.Vector2((V-c.min.y)/l.y,(G-c.min.z)/l.z),new THREE.Vector2((i-c.min.y)/l.y,(s-c.min.z)/l.z)]}}},E=function(){d.clear()}},360:function(_){"use strict";_.exports=require("idb-keyval")},644:function(_){"use strict";_.exports=require("three")},568:function(_,g,p){"use strict";p.d(g,{Z:function(){return T}});function C(d,O,E,P,k,v,R){try{var z=d[v](R),x=z.value}catch(N){E(N);return}z.done?O(x):Promise.resolve(x).then(P,k)}function T(d){return function(){var O=this,E=arguments;return new Promise(function(P,k){var v=d.apply(O,E);function R(x){C(v,P,k,R,z,"next",x)}function z(x){C(v,P,k,R,z,"throw",x)}R(void 0)})}}},924:function(_,g,p){"use strict";p.d(g,{Z:function(){return C}});function C(T,d,O){return d in T?Object.defineProperty(T,d,{value:O,enumerable:!0,configurable:!0,writable:!0}):T[d]=O,T}},42:function(_,g,p){"use strict";p.d(g,{Z:function(){return T}});var C=p(924);function T(d){for(var O=1;O<arguments.length;O++){var E=arguments[O]!=null?arguments[O]:{},P=Object.keys(E);typeof Object.getOwnPropertySymbols=="function"&&(P=P.concat(Object.getOwnPropertySymbols(E).filter(function(k){return Object.getOwnPropertyDescriptor(E,k).enumerable}))),P.forEach(function(k){(0,C.Z)(d,k,E[k])})}return d}}},Y={};function U(_){var g=Y[_];if(g!==void 0)return g.exports;var p=Y[_]={exports:{}};return X[_](p,p.exports,U),p.exports}(function(){U.n=function(_){var g=_&&_.__esModule?function(){return _.default}:function(){return _};return U.d(g,{a:g}),g}})(),function(){U.d=function(_,g){for(var p in g)U.o(g,p)&&!U.o(_,p)&&Object.defineProperty(_,p,{enumerable:!0,get:g[p]})}}(),function(){U.o=function(_,g){return Object.prototype.hasOwnProperty.call(_,g)}}(),function(){U.r=function(_){typeof Symbol!="undefined"&&Symbol.toStringTag&&Object.defineProperty(_,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(_,"__esModule",{value:!0})}}();var K={};(function(){"use strict";U.r(K),U.d(K,{Cache:function(){return p},Data:function(){return y},Draw:function(){return D},Wk:function(){return G}});function _(a,i){if(!(a instanceof i))throw new TypeError("Cannot call a class as a function")}var g=U(584),p=function(){"use strict";function a(){_(this,a),this.cache=new Map}var i=a.prototype;return i.install=function(){},i.init=function(r){var o=(0,g.makePromiseCreator)();this.cache.set(r,o)},i.get=function(r){var o;return(o=this.cache.get(r))===null||o===void 0?void 0:o.promise},i.set=function(r,o){var h=this.cache.get(r);h?h.resolve(o):console.warn("init cache first")},i.dispose=function(){this.cache.forEach(function(r,o){r.reject("stop set cache:".concat(o))}),this.cache.clear()},a}(),C=U(568);function T(a,i){for(var s=0;s<i.length;s++){var r=i[s];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(a,r.key,r)}}function d(a,i,s){return i&&T(a.prototype,i),s&&T(a,s),a}function O(a){if(Array.isArray(a))return a}function E(a){if(typeof Symbol!="undefined"&&a[Symbol.iterator]!=null||a["@@iterator"]!=null)return Array.from(a)}function P(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function k(a,i){(i==null||i>a.length)&&(i=a.length);for(var s=0,r=new Array(i);s<i;s++)r[s]=a[s];return r}function v(a,i){if(!!a){if(typeof a=="string")return k(a,i);var s=Object.prototype.toString.call(a).slice(8,-1);if(s==="Object"&&a.constructor&&(s=a.constructor.name),s==="Map"||s==="Set")return Array.from(s);if(s==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(s))return k(a,i)}}function R(a,i){return O(a)||E(a,i)||v(a,i)||P()}function z(a){if(Array.isArray(a))return k(a)}function x(){throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function N(a){return z(a)||E(a)||v(a)||x()}var Z=U(666),H=U.n(Z),b=U(644),D=function(){"use strict";function a(s){_(this,a),this.onTopBase=new Map,this.objectNamesToFactories=new Map,this.objects=new Map,this.objects_=s}var i=a.prototype;return i.install=function(r){this.pencil=r,this.initObjectFactories()},i.initObjectFactories=function(){var r=this,o=this.objects_;Object.keys(o).forEach(function(h){var c=function(){function l(){_(this,l)}var j=l.prototype;return j.create=function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return new o[h](e)},l}();r.objectNamesToFactories.set(h,c)})},i.getObject=function(r,o){r.includes("#")&&console.warn("getObject:err:\u4E0D\u652F\u6301 #",r);var h=(o||{}).key,c="".concat(r).concat(h?"#".concat(h):""),l=this.objects.get(c);return l},i.getAllObject=function(r,o){r.includes("#")&&console.warn("getAllObject:err:\u4E0D\u652F\u6301 #",r);var h=(o||{}).key,c="".concat(r).concat(h?"#".concat(h):""),l=[];return this.objects.forEach(function(j,M){(M.startsWith("".concat(c,"#"))||M===c)&&l.push(j)}),l},i.draw=function(r,o,h){var c=this;return(0,C.Z)(H().mark(function l(){var j,M,e,t,n,u,f,w;return H().wrap(function(A){for(;;)switch(A.prev=A.next){case 0:if(j=c.objectNamesToFactories.get(r),!j){A.next=16;break}return M=(o||{}).key,e="".concat(r).concat(M?"#".concat(M):""),c.objects.has(e)&&(t=b.MathUtils.generateUUID(),e+="#".concat(t)),n=(o==null?void 0:o.target)||h,u=(o==null?void 0:o.onTop)||0,typeof n=="string"?f=c.objects.get(n):(n==null?void 0:n.objecttype__)==="BaseObject"?f=n:f=c.pencil.scene,w=new j().create(o),w.pencil=c.pencil,w.key=e,c.objects.set(e,w),A.next=15,c.addMesh(w,f,u);case 15:return A.abrupt("return",w);case 16:throw new Error("Unrecognized:".concat(r));case 17:case"end":return A.stop()}},l)}))()},i.addMesh=function(r,o,h){var c=this;return(0,C.Z)(H().mark(function l(){var j,M,e,t;return H().wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return u.next=2,r.create();case 2:r.object3d&&(r.object3d.userData.BaseObject_=r,h&&(j=1e3+h*2,c.onTopBase.has(j-1)||(M=new b.BufferGeometry,M.setFromPoints([new b.Vector3(0,0,0)]),e=new b.PointsMaterial({size:1,sizeAttenuation:!1,transparent:!0,opacity:.1}),t=new b.Points(M,e),t.renderOrder=j-1,t.onBeforeRender=function(){c.pencil.renderer.clearDepth()},c.onTopBase.set(j-1,!0),c.pencil.scene.add(t)),r.object3d.renderOrder=j),o.add(r.object3d)),r.visible=!0,r.render(),r.pm.resolve();case 6:case"end":return u.stop()}},l)}))()},i.erase=function(){for(var r=arguments.length,o=new Array(r),h=0;h<r;h++)o[h]=arguments[h];var c=this;N(o).forEach(function(l){var j=[];if(typeof l=="string"){var M,e=R(l.split("#"),2),t=e[0],n=e[1];(M=j).push.apply(M,N(c.getAllObject(t,{key:n})))}else j.push(l);j.forEach(function(u){c.removeMesh(u)})})},i.removeMesh=function(r){var o=this,h=r.parent;r.object3d&&h.remove(r.object3d),r.traverse(function(c){c.visible=!1,c.dispose(),o.objects.delete(c.key)})},i.update=function(r,o){this.objects.forEach(function(h){h.update(r,o)})},i.setSize=function(r,o){this.objects.forEach(function(h){h.resize(r,o)})},i.dispose=function(){this.objects.forEach(function(r,o){r.dispose(),r.pm.reject("stop draw:".concat(o))}),this.objects.clear(),this.onTopBase.clear(),this.objectNamesToFactories.clear()},d(a,[{key:"objectsPromise",get:function(){var r=[];return this.objects.forEach(function(o){r.push(o.pm.promise)}),r}}]),a}(),y=function(){"use strict";function a(){_(this,a),this.data={}}var i=a.prototype;return i.install=function(){},i.setData=function(r,o){var h,c;this.data[r]=o,(c=(h=this).cb)===null||c===void 0||c.call(h,r)},i.runAll=function(){var r=this;Object.keys(this.data).forEach(function(o){var h,c;(c=(h=r).cb)===null||c===void 0||c.call(h,o)})},i.dispose=function(){this.data={},this.cb=void 0},a}(),m=U(924),L=U(42),V=U(360),G=function(){"use strict";function a(){var s=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};_(this,a),this.messageList=[],this.options=(0,L.Z)({},{cache:!1,cacheVersion:"1"},s)}var i=a.prototype;return i.install=function(){},i.init=function(r,o){var h=this,c=this.options,l=c.cache,j=c.cacheVersion;this.workerList=Array.from({length:o},function(M,e){var t=typeof r=="string"?new Worker(r):r();return t.onmessage=function(n){var u=n.data,f=u.res,w=u.uuid,S=h.messageList.find(function(B){var I=B.uuid;return w===I});if(S==null||S.options.cb(f),h.workerList[e].inUse=!1,h.checkMessage(),l){var A=(S==null?void 0:S.options.cacheVersion)||j;(0,V.set)(w,(0,m.Z)({},A,f))}},{worker:t,inUse:!1}})},i.postMessage=function(r,o){var h=this,c=this.options,l=c.cache,j=c.cacheVersion;if(l&&!r.workerKey){console.warn("worker cache need workerKey");return}if(l&&r.workerKey&&r.delCache){console.warn("worker cache del: ".concat(r.workerKey)),(0,V.del)(r.workerKey);return}var M=r.workerKey||b.MathUtils.generateUUID();(l?(0,V.get)(M):Promise.resolve()).then(function(e){var t=o.cacheVersion||j;e&&e[t]?o.cb(e[t]):(h.messageList.push({req:r,options:o,uuid:M,inUse:!1}),h.checkMessage())}).catch(function(){console.warn("err:worker cache"),h.messageList.push({req:r,options:o,uuid:M,inUse:!1}),h.checkMessage()})},i.checkMessage=function(){var r=this.workerList.find(function(h){var c=h.inUse;return!c});if(r){var o=this.messageList.find(function(h){var c=h.inUse;return!c});o&&(o.inUse=!0,r.inUse=!0,r.worker.postMessage({req:o.req,uuid:o.uuid}))}},i.dispose=function(){this.workerList.forEach(function(r){var o=r.worker;o.terminate()}),this.workerList=[],this.messageList=[]},a}()})(),module.exports=K})();
@@ -1 +1 @@
1
- import*as X from"idb-keyval";import*as Y from"three";var Q={666:function(b){var g=function(h){"use strict";var O=Object.prototype,m=O.hasOwnProperty,v,w=typeof Symbol=="function"?Symbol:{},d=w.iterator||"@@iterator",x=w.asyncIterator||"@@asyncIterator",p=w.toStringTag||"@@toStringTag";function k(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{k({},"")}catch(e){k=function(t,n,l){return t[n]=l}}function R(e,t,n,l){var f=t&&t.prototype instanceof D?t:D,E=Object.create(f.prototype),M=new y(l||[]);return E._invoke=r(e,n,M),E}h.wrap=R;function U(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(l){return{type:"throw",arg:l}}}var G="suspendedStart",W="suspendedYield",B="executing",I="completed",T={};function D(){}function _(){}function j(){}var S={};k(S,d,function(){return this});var z=Object.getPrototypeOf,C=z&&z(z(L([])));C&&C!==O&&m.call(C,d)&&(S=C);var a=j.prototype=D.prototype=Object.create(S);_.prototype=j,k(a,"constructor",j),k(j,"constructor",_),_.displayName=k(j,p,"GeneratorFunction");function c(e){["next","throw","return"].forEach(function(t){k(e,t,function(n){return this._invoke(t,n)})})}h.isGeneratorFunction=function(e){var t=typeof e=="function"&&e.constructor;return t?t===_||(t.displayName||t.name)==="GeneratorFunction":!1},h.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,j):(e.__proto__=j,k(e,p,"GeneratorFunction")),e.prototype=Object.create(a),e},h.awrap=function(e){return{__await:e}};function i(e,t){function n(E,M,A,N){var V=U(e[E],e,M);if(V.type==="throw")N(V.arg);else{var $=V.arg,F=$.value;return F&&typeof F=="object"&&m.call(F,"__await")?t.resolve(F.__await).then(function(Z){n("next",Z,A,N)},function(Z){n("throw",Z,A,N)}):t.resolve(F).then(function(Z){$.value=Z,A($)},function(Z){return n("throw",Z,A,N)})}}var l;function f(E,M){function A(){return new t(function(N,V){n(E,M,N,V)})}return l=l?l.then(A,A):A()}this._invoke=f}c(i.prototype),k(i.prototype,x,function(){return this}),h.AsyncIterator=i,h.async=function(e,t,n,l,f){f===void 0&&(f=Promise);var E=new i(R(e,t,n,l),f);return h.isGeneratorFunction(t)?E:E.next().then(function(M){return M.done?M.value:E.next()})};function r(e,t,n){var l=G;return function(E,M){if(l===B)throw new Error("Generator is already running");if(l===I){if(E==="throw")throw M;return P()}for(n.method=E,n.arg=M;;){var A=n.delegate;if(A){var N=o(A,n);if(N){if(N===T)continue;return N}}if(n.method==="next")n.sent=n._sent=n.arg;else if(n.method==="throw"){if(l===G)throw l=I,n.arg;n.dispatchException(n.arg)}else n.method==="return"&&n.abrupt("return",n.arg);l=B;var V=U(e,t,n);if(V.type==="normal"){if(l=n.done?I:W,V.arg===T)continue;return{value:V.arg,done:n.done}}else V.type==="throw"&&(l=I,n.method="throw",n.arg=V.arg)}}}function o(e,t){var n=e.iterator[t.method];if(n===v){if(t.delegate=null,t.method==="throw"){if(e.iterator.return&&(t.method="return",t.arg=v,o(e,t),t.method==="throw"))return T;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return T}var l=U(n,e.iterator,t.arg);if(l.type==="throw")return t.method="throw",t.arg=l.arg,t.delegate=null,T;var f=l.arg;if(!f)return t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,T;if(f.done)t[e.resultName]=f.value,t.next=e.nextLoc,t.method!=="return"&&(t.method="next",t.arg=v);else return f;return t.delegate=null,T}c(a),k(a,p,"Generator"),k(a,d,function(){return this}),k(a,"toString",function(){return"[object Generator]"});function s(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function u(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function y(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(s,this),this.reset(!0)}h.keys=function(e){var t=[];for(var n in e)t.push(n);return t.reverse(),function l(){for(;t.length;){var f=t.pop();if(f in e)return l.value=f,l.done=!1,l}return l.done=!0,l}};function L(e){if(e){var t=e[d];if(t)return t.call(e);if(typeof e.next=="function")return e;if(!isNaN(e.length)){var n=-1,l=function f(){for(;++n<e.length;)if(m.call(e,n))return f.value=e[n],f.done=!1,f;return f.value=v,f.done=!0,f};return l.next=l}}return{next:P}}h.values=L;function P(){return{value:v,done:!0}}return y.prototype={constructor:y,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=v,this.done=!1,this.delegate=null,this.method="next",this.arg=v,this.tryEntries.forEach(u),!e)for(var t in this)t.charAt(0)==="t"&&m.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=v)},stop:function(){this.done=!0;var e=this.tryEntries[0],t=e.completion;if(t.type==="throw")throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function n(N,V){return E.type="throw",E.arg=e,t.next=N,V&&(t.method="next",t.arg=v),!!V}for(var l=this.tryEntries.length-1;l>=0;--l){var f=this.tryEntries[l],E=f.completion;if(f.tryLoc==="root")return n("end");if(f.tryLoc<=this.prev){var M=m.call(f,"catchLoc"),A=m.call(f,"finallyLoc");if(M&&A){if(this.prev<f.catchLoc)return n(f.catchLoc,!0);if(this.prev<f.finallyLoc)return n(f.finallyLoc)}else if(M){if(this.prev<f.catchLoc)return n(f.catchLoc,!0)}else if(A){if(this.prev<f.finallyLoc)return n(f.finallyLoc)}else throw new Error("try statement without catch or finally")}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var l=this.tryEntries[n];if(l.tryLoc<=this.prev&&m.call(l,"finallyLoc")&&this.prev<l.finallyLoc){var f=l;break}}f&&(e==="break"||e==="continue")&&f.tryLoc<=t&&t<=f.finallyLoc&&(f=null);var E=f?f.completion:{};return E.type=e,E.arg=t,f?(this.method="next",this.next=f.finallyLoc,T):this.complete(E)},complete:function(e,t){if(e.type==="throw")throw e.arg;return e.type==="break"||e.type==="continue"?this.next=e.arg:e.type==="return"?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):e.type==="normal"&&t&&(this.next=t),T},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),u(n),T}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var l=n.completion;if(l.type==="throw"){var f=l.arg;u(n)}return f}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:L(e),resultName:t,nextLoc:n},this.method==="next"&&(this.arg=v),T}},h}(b.exports);try{regeneratorRuntime=g}catch(h){typeof globalThis=="object"?globalThis.regeneratorRuntime=g:Function("r","regeneratorRuntime = r")(g)}},584:function(b,g,h){h.d(g,{Mf:function(){return O.Z}});var O=h(282),m=h(666),v=h.n(m),w=null,d=h(949);function x(T){if(T.material){var D=Array.isArray(T.material)?T.material:[T.material];D.forEach(function(_){var j,S;(j=_.color)===null||j===void 0||j.convertSRGBToLinear(),(S=_.emissive)===null||S===void 0||S.convertSRGBToLinear(),_.map&&(_.map.encoding=THREE.sRGBEncoding),_.emissiveMap&&(_.emissiveMap.encoding=THREE.sRGBEncoding)})}}var p=h(568),k=h(924),R=h(77),U=h(484),G=null,W=null,B=function(){var T=(0,p.Z)(v().mark(function D(_,j){var S,z,C,a,c,i,r,o,s;return v().wrap(function(y){for(;;)switch(y.prev=y.next){case 0:return S=j.type,z=S===void 0?"blob":S,C=j.version,a=C===void 0?"1":C,y.next=4,(0,R.get)(_);case 4:if(i=y.sent,!(i&&i[a])){y.next=9;break}c=i[a],y.next=15;break;case 9:return y.next=11,(0,U.Z)(fetch(_).then(function(L){if(L.ok)return L[z]();throw new Error}));case 11:r=y.sent,o=r.res,s=r.err,s||(c=o,(0,R.set)(_,(0,k.Z)({},a,o)));case 15:return y.abrupt("return",c?{url:z==="json"?_:URL.createObjectURL(c),store:c}:{url:_});case 16:case"end":return y.stop()}},D)}));return function(_,j){return T.apply(this,arguments)}}(),I=h(705)},282:function(b,g,h){h.d(g,{Z:function(){return m}});var O=h(484);function m(){var v=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1,w=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},d={};return d.promise=new Promise(function(x,p){d.resolve=x,d.reject=p}),v&&(d.promise=(0,O.Z)(d.promise,w)),d}},484:function(b,g,h){h.d(g,{Z:function(){return m}});var O=h(42);function m(v){var w=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return v.then(function(d){return(0,O.Z)({err:null,res:d},w)}).catch(function(d){return(0,O.Z)({err:d,res:void 0},w)})}},705:function(b,g,h){var O=h(949),m=new Map,v=function(){var d=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return{generateTopUV:function(x,p,k,R,U){var G=p[k*3],W=p[k*3+1],B=p[R*3],I=p[R*3+1],T=p[U*3],D=p[U*3+1],_;if(m.has(x))_=m.get(x);else{var j=d.box3||new THREE.Box3;if(!d.box3){var S=x.parameters.shapes.getPoints();j.setFromArray(S.map(function(i){return[i.x,i.y,0]}).flat())}var z=j.getSize(new THREE.Vector3);d.split&&(z.y/=d.split),_={box:j,size:z},m.set(x,_)}var C=_.box,a=_.size,c=d.split?1-d.split:0;return[new THREE.Vector2((G-C.min.x)/a.x,(W-C.min.y)/a.y+c),new THREE.Vector2((B-C.min.x)/a.x,(I-C.min.y)/a.y+c),new THREE.Vector2((T-C.min.x)/a.x,(D-C.min.y)/a.y+c)]},generateSideWallUV:function(x,p,k,R,U,G){var W=p[k*3],B=p[k*3+1],I=p[k*3+2],T=p[R*3],D=p[R*3+1],_=p[R*3+2],j=p[U*3],S=p[U*3+1],z=p[U*3+2],C=p[G*3],a=p[G*3+1],c=p[G*3+2],i;if(m.has(p))i=m.get(p);else{var r=new THREE.Box3;r.setFromArray(p);var o=r.getSize(new THREE.Vector3);d.split&&(o.z/=1-d.split),i={box:r,size:o},m.set(p,i)}var s=i.box,u=i.size;return Math.abs(B-D)<Math.abs(W-T)?[new THREE.Vector2((W-s.min.x)/u.x,(I-s.min.z)/u.z),new THREE.Vector2((T-s.min.x)/u.x,(_-s.min.z)/u.z),new THREE.Vector2((j-s.min.x)/u.x,(z-s.min.z)/u.z),new THREE.Vector2((C-s.min.x)/u.x,(c-s.min.z)/u.z)]:[new THREE.Vector2((B-s.min.y)/u.y,(I-s.min.z)/u.z),new THREE.Vector2((D-s.min.y)/u.y,(_-s.min.z)/u.z),new THREE.Vector2((S-s.min.y)/u.y,(z-s.min.z)/u.z),new THREE.Vector2((a-s.min.y)/u.y,(c-s.min.z)/u.z)]}}},w=function(){m.clear()}},77:function(b,g,h){var O=v=>{var w={};return h.d(w,v),w},m=v=>()=>v;b.exports=O({del:()=>X.del,get:()=>X.get,set:()=>X.set})},949:function(b,g,h){var O=v=>{var w={};return h.d(w,v),w},m=v=>()=>v;b.exports=O({MathUtils:()=>Y.MathUtils,Points:()=>Y.Points})},568:function(b,g,h){h.d(g,{Z:function(){return m}});function O(v,w,d,x,p,k,R){try{var U=v[k](R),G=U.value}catch(W){d(W);return}U.done?w(G):Promise.resolve(G).then(x,p)}function m(v){return function(){var w=this,d=arguments;return new Promise(function(x,p){var k=v.apply(w,d);function R(G){O(k,x,p,R,U,"next",G)}function U(G){O(k,x,p,R,U,"throw",G)}R(void 0)})}}},924:function(b,g,h){h.d(g,{Z:function(){return O}});function O(m,v,w){return v in m?Object.defineProperty(m,v,{value:w,enumerable:!0,configurable:!0,writable:!0}):m[v]=w,m}},42:function(b,g,h){h.d(g,{Z:function(){return m}});var O=h(924);function m(v){for(var w=1;w<arguments.length;w++){var d=arguments[w]!=null?arguments[w]:{},x=Object.keys(d);typeof Object.getOwnPropertySymbols=="function"&&(x=x.concat(Object.getOwnPropertySymbols(d).filter(function(p){return Object.getOwnPropertyDescriptor(d,p).enumerable}))),x.forEach(function(p){(0,O.Z)(v,p,d[p])})}return v}}},J={};function H(b){var g=J[b];if(g!==void 0)return g.exports;var h=J[b]={exports:{}};return Q[b](h,h.exports,H),h.exports}(function(){H.n=function(b){var g=b&&b.__esModule?function(){return b.default}:function(){return b};return H.d(g,{a:g}),g}})(),function(){H.d=function(b,g){for(var h in g)H.o(g,h)&&!H.o(b,h)&&Object.defineProperty(b,h,{enumerable:!0,get:g[h]})}}(),function(){H.o=function(b,g){return Object.prototype.hasOwnProperty.call(b,g)}}();var K={};(function(){H.d(K,{Ct:function(){return h},Vw:function(){return _},hG:function(){return D},Wk:function(){return C}});function b(a,c){if(!(a instanceof c))throw new TypeError("Cannot call a class as a function")}var g=H(584),h=function(){"use strict";function a(){b(this,a),this.cache=new Map}var c=a.prototype;return c.install=function(){},c.init=function(r){var o=(0,g.Mf)();this.cache.set(r,o)},c.get=function(r){var o;return(o=this.cache.get(r))===null||o===void 0?void 0:o.promise},c.set=function(r,o){var s=this.cache.get(r);s?s.resolve(o):console.warn("init cache first")},c.dispose=function(){this.cache.forEach(function(r,o){r.reject("stop set cache:".concat(o))}),this.cache.clear()},a}(),O=H(568);function m(a,c){for(var i=0;i<c.length;i++){var r=c[i];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(a,r.key,r)}}function v(a,c,i){return c&&m(a.prototype,c),i&&m(a,i),a}function w(a){if(Array.isArray(a))return a}function d(a){if(typeof Symbol!="undefined"&&a[Symbol.iterator]!=null||a["@@iterator"]!=null)return Array.from(a)}function x(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function p(a,c){(c==null||c>a.length)&&(c=a.length);for(var i=0,r=new Array(c);i<c;i++)r[i]=a[i];return r}function k(a,c){if(!!a){if(typeof a=="string")return p(a,c);var i=Object.prototype.toString.call(a).slice(8,-1);if(i==="Object"&&a.constructor&&(i=a.constructor.name),i==="Map"||i==="Set")return Array.from(i);if(i==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i))return p(a,c)}}function R(a,c){return w(a)||d(a,c)||k(a,c)||x()}function U(a){if(Array.isArray(a))return p(a)}function G(){throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function W(a){return U(a)||d(a)||k(a)||G()}var B=H(666),I=H.n(B),T=H(949),D=function(){"use strict";function a(i){b(this,a),this.onTopBase=new Map,this.objectNamesToFactories=new Map,this.objects=new Map,this.objects_=i}var c=a.prototype;return c.install=function(r){this.pencil=r,this.initObjectFactories()},c.initObjectFactories=function(){var r=this,o=this.objects_;Object.keys(o).forEach(function(s){var u=function(){function y(){b(this,y)}var L=y.prototype;return L.create=function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return new o[s](e)},y}();r.objectNamesToFactories.set(s,u)})},c.getObject=function(r,o){r.includes("#")&&console.warn("getObject:err:\u4E0D\u652F\u6301 #",r);var s=(o||{}).key,u="".concat(r).concat(s?"#".concat(s):""),y=this.objects.get(u);return y},c.getAllObject=function(r,o){r.includes("#")&&console.warn("getAllObject:err:\u4E0D\u652F\u6301 #",r);var s=(o||{}).key,u="".concat(r).concat(s?"#".concat(s):""),y=[];return this.objects.forEach(function(L,P){(P.startsWith("".concat(u,"#"))||P===u)&&y.push(L)}),y},c.draw=function(r,o,s){var u=this;return(0,O.Z)(I().mark(function y(){var L,P,e,t,n,l,f,E;return I().wrap(function(A){for(;;)switch(A.prev=A.next){case 0:if(L=u.objectNamesToFactories.get(r),!L){A.next=16;break}return P=(o||{}).key,e="".concat(r).concat(P?"#".concat(P):""),u.objects.has(e)&&(t=T.MathUtils.generateUUID(),e+="#".concat(t)),n=(o==null?void 0:o.target)||s,l=(o==null?void 0:o.onTop)||0,typeof n=="string"?f=u.objects.get(n):(n==null?void 0:n.objecttype__)==="BaseObject"?f=n:f=u.pencil.scene,E=new L().create(o),E.pencil=u.pencil,E.key=e,u.objects.set(e,E),A.next=15,u.addMesh(E,f,l);case 15:return A.abrupt("return",E);case 16:throw new Error("Unrecognized:".concat(r));case 17:case"end":return A.stop()}},y)}))()},c.addMesh=function(r,o,s){var u=this;return(0,O.Z)(I().mark(function y(){var L,P;return I().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,r.create();case 2:r.object3d&&(r.object3d.userData.BaseObject_=r,s&&(L=1e3+s*2,u.onTopBase.has(L-1)||(P=new T.Points,P.renderOrder=L-1,r.object3d.onBeforeRender=function(){u.pencil.renderer.clearDepth()},u.onTopBase.set(L-1,!0),o.add(P)),r.object3d.renderOrder=L),o.add(r.object3d)),r.visible=!0,r.render(),r.pm.resolve();case 6:case"end":return t.stop()}},y)}))()},c.erase=function(){for(var r=arguments.length,o=new Array(r),s=0;s<r;s++)o[s]=arguments[s];var u=this;W(o).forEach(function(y){var L=[];if(typeof y=="string"){var P,e=R(y.split("#"),2),t=e[0],n=e[1];(P=L).push.apply(P,W(u.getAllObject(t,{key:n})))}else L.push(y);L.forEach(function(l){u.removeMesh(l)})})},c.removeMesh=function(r){var o=this,s=r.parent;r.object3d&&s.remove(r.object3d),r.traverse(function(u){u.visible=!1,u.dispose(),o.objects.delete(u.key)})},c.update=function(r,o){this.objects.forEach(function(s){s.update(r,o)})},c.setSize=function(r,o){this.objects.forEach(function(s){s.resize(r,o)})},c.dispose=function(){this.objects.forEach(function(r,o){r.dispose(),r.pm.reject("stop draw:".concat(o))}),this.objects.clear(),this.onTopBase.clear(),this.objectNamesToFactories.clear()},v(a,[{key:"objectsPromise",get:function(){var r=[];return this.objects.forEach(function(o){r.push(o.pm.promise)}),r}}]),a}(),_=function(){"use strict";function a(){b(this,a),this.data={}}var c=a.prototype;return c.install=function(){},c.setData=function(r,o){var s,u;this.data[r]=o,(u=(s=this).cb)===null||u===void 0||u.call(s,r)},c.runAll=function(){var r=this;Object.keys(this.data).forEach(function(o){var s,u;(u=(s=r).cb)===null||u===void 0||u.call(s,o)})},c.dispose=function(){this.data={},this.cb=void 0},a}(),j=H(924),S=H(42),z=H(77),C=function(){"use strict";function a(){var i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};b(this,a),this.messageList=[],this.options=(0,S.Z)({},{cache:!1,cacheVersion:"1"},i)}var c=a.prototype;return c.install=function(){},c.init=function(r,o){var s=this,u=this.options,y=u.cache,L=u.cacheVersion;this.workerList=Array.from({length:o},function(P,e){var t=typeof r=="string"?new Worker(r):r();return t.onmessage=function(n){var l=n.data,f=l.res,E=l.uuid,M=s.messageList.find(function(N){var V=N.uuid;return E===V});if(M==null||M.options.cb(f),s.workerList[e].inUse=!1,s.checkMessage(),y){var A=(M==null?void 0:M.options.cacheVersion)||L;(0,z.set)(E,(0,j.Z)({},A,f))}},{worker:t,inUse:!1}})},c.postMessage=function(r,o){var s=this,u=this.options,y=u.cache,L=u.cacheVersion;if(y&&!r.workerKey){console.warn("worker cache need workerKey");return}if(y&&r.workerKey&&r.delCache){console.warn("worker cache del: ".concat(r.workerKey)),(0,z.del)(r.workerKey);return}var P=r.workerKey||T.MathUtils.generateUUID();(y?(0,z.get)(P):Promise.resolve()).then(function(e){var t=o.cacheVersion||L;e&&e[t]?o.cb(e[t]):(s.messageList.push({req:r,options:o,uuid:P,inUse:!1}),s.checkMessage())}).catch(function(){console.warn("err:worker cache"),s.messageList.push({req:r,options:o,uuid:P,inUse:!1}),s.checkMessage()})},c.checkMessage=function(){var r=this.workerList.find(function(s){var u=s.inUse;return!u});if(r){var o=this.messageList.find(function(s){var u=s.inUse;return!u});o&&(o.inUse=!0,r.inUse=!0,r.worker.postMessage({req:o.req,uuid:o.uuid}))}},c.dispose=function(){this.workerList.forEach(function(r){var o=r.worker;o.terminate()}),this.workerList=[],this.messageList=[]},a}()})();var q=K.Ct,tt=K.Vw,et=K.hG,rt=K.Wk;export{q as Cache,tt as Data,et as Draw,rt as Wk};
1
+ import*as Y from"idb-keyval";import*as K from"three";var Q={666:function(w){var g=function(l){"use strict";var O=Object.prototype,m=O.hasOwnProperty,v,E=typeof Symbol=="function"?Symbol:{},d=E.iterator||"@@iterator",x=E.asyncIterator||"@@asyncIterator",p=E.toStringTag||"@@toStringTag";function j(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{j({},"")}catch(e){j=function(t,n,f){return t[n]=f}}function R(e,t,n,f){var h=t&&t.prototype instanceof V?t:V,k=Object.create(h.prototype),A=new y(f||[]);return k._invoke=r(e,n,A),k}l.wrap=R;function z(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(f){return{type:"throw",arg:f}}}var U="suspendedStart",N="suspendedYield",W="executing",H="completed",b={};function V(){}function _(){}function T(){}var S={};j(S,d,function(){return this});var G=Object.getPrototypeOf,C=G&&G(G(L([])));C&&C!==O&&m.call(C,d)&&(S=C);var a=T.prototype=V.prototype=Object.create(S);_.prototype=T,j(a,"constructor",T),j(T,"constructor",_),_.displayName=j(T,p,"GeneratorFunction");function u(e){["next","throw","return"].forEach(function(t){j(e,t,function(n){return this._invoke(t,n)})})}l.isGeneratorFunction=function(e){var t=typeof e=="function"&&e.constructor;return t?t===_||(t.displayName||t.name)==="GeneratorFunction":!1},l.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,T):(e.__proto__=T,j(e,p,"GeneratorFunction")),e.prototype=Object.create(a),e},l.awrap=function(e){return{__await:e}};function o(e,t){function n(k,A,P,I){var D=z(e[k],e,A);if(D.type==="throw")I(D.arg);else{var X=D.arg,F=X.value;return F&&typeof F=="object"&&m.call(F,"__await")?t.resolve(F.__await).then(function(Z){n("next",Z,P,I)},function(Z){n("throw",Z,P,I)}):t.resolve(F).then(function(Z){X.value=Z,P(X)},function(Z){return n("throw",Z,P,I)})}}var f;function h(k,A){function P(){return new t(function(I,D){n(k,A,I,D)})}return f=f?f.then(P,P):P()}this._invoke=h}u(o.prototype),j(o.prototype,x,function(){return this}),l.AsyncIterator=o,l.async=function(e,t,n,f,h){h===void 0&&(h=Promise);var k=new o(R(e,t,n,f),h);return l.isGeneratorFunction(t)?k:k.next().then(function(A){return A.done?A.value:k.next()})};function r(e,t,n){var f=U;return function(k,A){if(f===W)throw new Error("Generator is already running");if(f===H){if(k==="throw")throw A;return M()}for(n.method=k,n.arg=A;;){var P=n.delegate;if(P){var I=i(P,n);if(I){if(I===b)continue;return I}}if(n.method==="next")n.sent=n._sent=n.arg;else if(n.method==="throw"){if(f===U)throw f=H,n.arg;n.dispatchException(n.arg)}else n.method==="return"&&n.abrupt("return",n.arg);f=W;var D=z(e,t,n);if(D.type==="normal"){if(f=n.done?H:N,D.arg===b)continue;return{value:D.arg,done:n.done}}else D.type==="throw"&&(f=H,n.method="throw",n.arg=D.arg)}}}function i(e,t){var n=e.iterator[t.method];if(n===v){if(t.delegate=null,t.method==="throw"){if(e.iterator.return&&(t.method="return",t.arg=v,i(e,t),t.method==="throw"))return b;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return b}var f=z(n,e.iterator,t.arg);if(f.type==="throw")return t.method="throw",t.arg=f.arg,t.delegate=null,b;var h=f.arg;if(!h)return t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,b;if(h.done)t[e.resultName]=h.value,t.next=e.nextLoc,t.method!=="return"&&(t.method="next",t.arg=v);else return h;return t.delegate=null,b}u(a),j(a,p,"Generator"),j(a,d,function(){return this}),j(a,"toString",function(){return"[object Generator]"});function s(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function c(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function y(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(s,this),this.reset(!0)}l.keys=function(e){var t=[];for(var n in e)t.push(n);return t.reverse(),function f(){for(;t.length;){var h=t.pop();if(h in e)return f.value=h,f.done=!1,f}return f.done=!0,f}};function L(e){if(e){var t=e[d];if(t)return t.call(e);if(typeof e.next=="function")return e;if(!isNaN(e.length)){var n=-1,f=function h(){for(;++n<e.length;)if(m.call(e,n))return h.value=e[n],h.done=!1,h;return h.value=v,h.done=!0,h};return f.next=f}}return{next:M}}l.values=L;function M(){return{value:v,done:!0}}return y.prototype={constructor:y,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=v,this.done=!1,this.delegate=null,this.method="next",this.arg=v,this.tryEntries.forEach(c),!e)for(var t in this)t.charAt(0)==="t"&&m.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=v)},stop:function(){this.done=!0;var e=this.tryEntries[0],t=e.completion;if(t.type==="throw")throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function n(I,D){return k.type="throw",k.arg=e,t.next=I,D&&(t.method="next",t.arg=v),!!D}for(var f=this.tryEntries.length-1;f>=0;--f){var h=this.tryEntries[f],k=h.completion;if(h.tryLoc==="root")return n("end");if(h.tryLoc<=this.prev){var A=m.call(h,"catchLoc"),P=m.call(h,"finallyLoc");if(A&&P){if(this.prev<h.catchLoc)return n(h.catchLoc,!0);if(this.prev<h.finallyLoc)return n(h.finallyLoc)}else if(A){if(this.prev<h.catchLoc)return n(h.catchLoc,!0)}else if(P){if(this.prev<h.finallyLoc)return n(h.finallyLoc)}else throw new Error("try statement without catch or finally")}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var f=this.tryEntries[n];if(f.tryLoc<=this.prev&&m.call(f,"finallyLoc")&&this.prev<f.finallyLoc){var h=f;break}}h&&(e==="break"||e==="continue")&&h.tryLoc<=t&&t<=h.finallyLoc&&(h=null);var k=h?h.completion:{};return k.type=e,k.arg=t,h?(this.method="next",this.next=h.finallyLoc,b):this.complete(k)},complete:function(e,t){if(e.type==="throw")throw e.arg;return e.type==="break"||e.type==="continue"?this.next=e.arg:e.type==="return"?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):e.type==="normal"&&t&&(this.next=t),b},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),c(n),b}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var f=n.completion;if(f.type==="throw"){var h=f.arg;c(n)}return h}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:L(e),resultName:t,nextLoc:n},this.method==="next"&&(this.arg=v),b}},l}(w.exports);try{regeneratorRuntime=g}catch(l){typeof globalThis=="object"?globalThis.regeneratorRuntime=g:Function("r","regeneratorRuntime = r")(g)}},584:function(w,g,l){l.d(g,{Mf:function(){return O.Z}});var O=l(282),m=l(666),v=l.n(m),E=null,d=l(949);function x(b){if(b.material){var V=Array.isArray(b.material)?b.material:[b.material];V.forEach(function(_){var T,S;(T=_.color)===null||T===void 0||T.convertSRGBToLinear(),(S=_.emissive)===null||S===void 0||S.convertSRGBToLinear(),_.map&&(_.map.encoding=THREE.sRGBEncoding),_.emissiveMap&&(_.emissiveMap.encoding=THREE.sRGBEncoding)})}}var p=l(568),j=l(924),R=l(77),z=l(484),U=null,N=null,W=function(){var b=(0,p.Z)(v().mark(function V(_,T){var S,G,C,a,u,o,r,i,s;return v().wrap(function(y){for(;;)switch(y.prev=y.next){case 0:return S=T.type,G=S===void 0?"blob":S,C=T.version,a=C===void 0?"1":C,y.next=4,(0,R.get)(_);case 4:if(o=y.sent,!(o&&o[a])){y.next=9;break}u=o[a],y.next=15;break;case 9:return y.next=11,(0,z.Z)(fetch(_).then(function(L){if(L.ok)return L[G]();throw new Error}));case 11:r=y.sent,i=r.res,s=r.err,s||(u=i,(0,R.set)(_,(0,j.Z)({},a,i)));case 15:return y.abrupt("return",u?{url:G==="json"?_:URL.createObjectURL(u),store:u}:{url:_});case 16:case"end":return y.stop()}},V)}));return function(_,T){return b.apply(this,arguments)}}(),H=l(705)},282:function(w,g,l){l.d(g,{Z:function(){return m}});var O=l(484);function m(){var v=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1,E=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},d={};return d.promise=new Promise(function(x,p){d.resolve=x,d.reject=p}),v&&(d.promise=(0,O.Z)(d.promise,E)),d}},484:function(w,g,l){l.d(g,{Z:function(){return m}});var O=l(42);function m(v){var E=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return v.then(function(d){return(0,O.Z)({err:null,res:d},E)}).catch(function(d){return(0,O.Z)({err:d,res:void 0},E)})}},705:function(w,g,l){var O=l(949),m=new Map,v=function(){var d=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return{generateTopUV:function(x,p,j,R,z){var U=p[j*3],N=p[j*3+1],W=p[R*3],H=p[R*3+1],b=p[z*3],V=p[z*3+1],_;if(m.has(x))_=m.get(x);else{var T=d.box3||new THREE.Box3;if(!d.box3){var S=x.parameters.shapes.getPoints();T.setFromArray(S.map(function(o){return[o.x,o.y,0]}).flat())}var G=T.getSize(new THREE.Vector3);d.split&&(G.y/=d.split),_={box:T,size:G},m.set(x,_)}var C=_.box,a=_.size,u=d.split?1-d.split:0;return[new THREE.Vector2((U-C.min.x)/a.x,(N-C.min.y)/a.y+u),new THREE.Vector2((W-C.min.x)/a.x,(H-C.min.y)/a.y+u),new THREE.Vector2((b-C.min.x)/a.x,(V-C.min.y)/a.y+u)]},generateSideWallUV:function(x,p,j,R,z,U){var N=p[j*3],W=p[j*3+1],H=p[j*3+2],b=p[R*3],V=p[R*3+1],_=p[R*3+2],T=p[z*3],S=p[z*3+1],G=p[z*3+2],C=p[U*3],a=p[U*3+1],u=p[U*3+2],o;if(m.has(p))o=m.get(p);else{var r=new THREE.Box3;r.setFromArray(p);var i=r.getSize(new THREE.Vector3);d.split&&(i.z/=1-d.split),o={box:r,size:i},m.set(p,o)}var s=o.box,c=o.size;return Math.abs(W-V)<Math.abs(N-b)?[new THREE.Vector2((N-s.min.x)/c.x,(H-s.min.z)/c.z),new THREE.Vector2((b-s.min.x)/c.x,(_-s.min.z)/c.z),new THREE.Vector2((T-s.min.x)/c.x,(G-s.min.z)/c.z),new THREE.Vector2((C-s.min.x)/c.x,(u-s.min.z)/c.z)]:[new THREE.Vector2((W-s.min.y)/c.y,(H-s.min.z)/c.z),new THREE.Vector2((V-s.min.y)/c.y,(_-s.min.z)/c.z),new THREE.Vector2((S-s.min.y)/c.y,(G-s.min.z)/c.z),new THREE.Vector2((a-s.min.y)/c.y,(u-s.min.z)/c.z)]}}},E=function(){m.clear()}},77:function(w,g,l){var O=v=>{var E={};return l.d(E,v),E},m=v=>()=>v;w.exports=O({del:()=>Y.del,get:()=>Y.get,set:()=>Y.set})},949:function(w,g,l){var O=v=>{var E={};return l.d(E,v),E},m=v=>()=>v;w.exports=O({BufferGeometry:()=>K.BufferGeometry,MathUtils:()=>K.MathUtils,Points:()=>K.Points,PointsMaterial:()=>K.PointsMaterial,Vector3:()=>K.Vector3})},568:function(w,g,l){l.d(g,{Z:function(){return m}});function O(v,E,d,x,p,j,R){try{var z=v[j](R),U=z.value}catch(N){d(N);return}z.done?E(U):Promise.resolve(U).then(x,p)}function m(v){return function(){var E=this,d=arguments;return new Promise(function(x,p){var j=v.apply(E,d);function R(U){O(j,x,p,R,z,"next",U)}function z(U){O(j,x,p,R,z,"throw",U)}R(void 0)})}}},924:function(w,g,l){l.d(g,{Z:function(){return O}});function O(m,v,E){return v in m?Object.defineProperty(m,v,{value:E,enumerable:!0,configurable:!0,writable:!0}):m[v]=E,m}},42:function(w,g,l){l.d(g,{Z:function(){return m}});var O=l(924);function m(v){for(var E=1;E<arguments.length;E++){var d=arguments[E]!=null?arguments[E]:{},x=Object.keys(d);typeof Object.getOwnPropertySymbols=="function"&&(x=x.concat(Object.getOwnPropertySymbols(d).filter(function(p){return Object.getOwnPropertyDescriptor(d,p).enumerable}))),x.forEach(function(p){(0,O.Z)(v,p,d[p])})}return v}}},J={};function B(w){var g=J[w];if(g!==void 0)return g.exports;var l=J[w]={exports:{}};return Q[w](l,l.exports,B),l.exports}(function(){B.n=function(w){var g=w&&w.__esModule?function(){return w.default}:function(){return w};return B.d(g,{a:g}),g}})(),function(){B.d=function(w,g){for(var l in g)B.o(g,l)&&!B.o(w,l)&&Object.defineProperty(w,l,{enumerable:!0,get:g[l]})}}(),function(){B.o=function(w,g){return Object.prototype.hasOwnProperty.call(w,g)}}();var $={};(function(){B.d($,{Ct:function(){return l},Vw:function(){return _},hG:function(){return V},Wk:function(){return C}});function w(a,u){if(!(a instanceof u))throw new TypeError("Cannot call a class as a function")}var g=B(584),l=function(){"use strict";function a(){w(this,a),this.cache=new Map}var u=a.prototype;return u.install=function(){},u.init=function(r){var i=(0,g.Mf)();this.cache.set(r,i)},u.get=function(r){var i;return(i=this.cache.get(r))===null||i===void 0?void 0:i.promise},u.set=function(r,i){var s=this.cache.get(r);s?s.resolve(i):console.warn("init cache first")},u.dispose=function(){this.cache.forEach(function(r,i){r.reject("stop set cache:".concat(i))}),this.cache.clear()},a}(),O=B(568);function m(a,u){for(var o=0;o<u.length;o++){var r=u[o];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(a,r.key,r)}}function v(a,u,o){return u&&m(a.prototype,u),o&&m(a,o),a}function E(a){if(Array.isArray(a))return a}function d(a){if(typeof Symbol!="undefined"&&a[Symbol.iterator]!=null||a["@@iterator"]!=null)return Array.from(a)}function x(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function p(a,u){(u==null||u>a.length)&&(u=a.length);for(var o=0,r=new Array(u);o<u;o++)r[o]=a[o];return r}function j(a,u){if(!!a){if(typeof a=="string")return p(a,u);var o=Object.prototype.toString.call(a).slice(8,-1);if(o==="Object"&&a.constructor&&(o=a.constructor.name),o==="Map"||o==="Set")return Array.from(o);if(o==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(o))return p(a,u)}}function R(a,u){return E(a)||d(a,u)||j(a,u)||x()}function z(a){if(Array.isArray(a))return p(a)}function U(){throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function N(a){return z(a)||d(a)||j(a)||U()}var W=B(666),H=B.n(W),b=B(949),V=function(){"use strict";function a(o){w(this,a),this.onTopBase=new Map,this.objectNamesToFactories=new Map,this.objects=new Map,this.objects_=o}var u=a.prototype;return u.install=function(r){this.pencil=r,this.initObjectFactories()},u.initObjectFactories=function(){var r=this,i=this.objects_;Object.keys(i).forEach(function(s){var c=function(){function y(){w(this,y)}var L=y.prototype;return L.create=function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return new i[s](e)},y}();r.objectNamesToFactories.set(s,c)})},u.getObject=function(r,i){r.includes("#")&&console.warn("getObject:err:\u4E0D\u652F\u6301 #",r);var s=(i||{}).key,c="".concat(r).concat(s?"#".concat(s):""),y=this.objects.get(c);return y},u.getAllObject=function(r,i){r.includes("#")&&console.warn("getAllObject:err:\u4E0D\u652F\u6301 #",r);var s=(i||{}).key,c="".concat(r).concat(s?"#".concat(s):""),y=[];return this.objects.forEach(function(L,M){(M.startsWith("".concat(c,"#"))||M===c)&&y.push(L)}),y},u.draw=function(r,i,s){var c=this;return(0,O.Z)(H().mark(function y(){var L,M,e,t,n,f,h,k;return H().wrap(function(P){for(;;)switch(P.prev=P.next){case 0:if(L=c.objectNamesToFactories.get(r),!L){P.next=16;break}return M=(i||{}).key,e="".concat(r).concat(M?"#".concat(M):""),c.objects.has(e)&&(t=b.MathUtils.generateUUID(),e+="#".concat(t)),n=(i==null?void 0:i.target)||s,f=(i==null?void 0:i.onTop)||0,typeof n=="string"?h=c.objects.get(n):(n==null?void 0:n.objecttype__)==="BaseObject"?h=n:h=c.pencil.scene,k=new L().create(i),k.pencil=c.pencil,k.key=e,c.objects.set(e,k),P.next=15,c.addMesh(k,h,f);case 15:return P.abrupt("return",k);case 16:throw new Error("Unrecognized:".concat(r));case 17:case"end":return P.stop()}},y)}))()},u.addMesh=function(r,i,s){var c=this;return(0,O.Z)(H().mark(function y(){var L,M,e,t;return H().wrap(function(f){for(;;)switch(f.prev=f.next){case 0:return f.next=2,r.create();case 2:r.object3d&&(r.object3d.userData.BaseObject_=r,s&&(L=1e3+s*2,c.onTopBase.has(L-1)||(M=new b.BufferGeometry,M.setFromPoints([new b.Vector3(0,0,0)]),e=new b.PointsMaterial({size:1,sizeAttenuation:!1,transparent:!0,opacity:.1}),t=new b.Points(M,e),t.renderOrder=L-1,t.onBeforeRender=function(){c.pencil.renderer.clearDepth()},c.onTopBase.set(L-1,!0),c.pencil.scene.add(t)),r.object3d.renderOrder=L),i.add(r.object3d)),r.visible=!0,r.render(),r.pm.resolve();case 6:case"end":return f.stop()}},y)}))()},u.erase=function(){for(var r=arguments.length,i=new Array(r),s=0;s<r;s++)i[s]=arguments[s];var c=this;N(i).forEach(function(y){var L=[];if(typeof y=="string"){var M,e=R(y.split("#"),2),t=e[0],n=e[1];(M=L).push.apply(M,N(c.getAllObject(t,{key:n})))}else L.push(y);L.forEach(function(f){c.removeMesh(f)})})},u.removeMesh=function(r){var i=this,s=r.parent;r.object3d&&s.remove(r.object3d),r.traverse(function(c){c.visible=!1,c.dispose(),i.objects.delete(c.key)})},u.update=function(r,i){this.objects.forEach(function(s){s.update(r,i)})},u.setSize=function(r,i){this.objects.forEach(function(s){s.resize(r,i)})},u.dispose=function(){this.objects.forEach(function(r,i){r.dispose(),r.pm.reject("stop draw:".concat(i))}),this.objects.clear(),this.onTopBase.clear(),this.objectNamesToFactories.clear()},v(a,[{key:"objectsPromise",get:function(){var r=[];return this.objects.forEach(function(i){r.push(i.pm.promise)}),r}}]),a}(),_=function(){"use strict";function a(){w(this,a),this.data={}}var u=a.prototype;return u.install=function(){},u.setData=function(r,i){var s,c;this.data[r]=i,(c=(s=this).cb)===null||c===void 0||c.call(s,r)},u.runAll=function(){var r=this;Object.keys(this.data).forEach(function(i){var s,c;(c=(s=r).cb)===null||c===void 0||c.call(s,i)})},u.dispose=function(){this.data={},this.cb=void 0},a}(),T=B(924),S=B(42),G=B(77),C=function(){"use strict";function a(){var o=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};w(this,a),this.messageList=[],this.options=(0,S.Z)({},{cache:!1,cacheVersion:"1"},o)}var u=a.prototype;return u.install=function(){},u.init=function(r,i){var s=this,c=this.options,y=c.cache,L=c.cacheVersion;this.workerList=Array.from({length:i},function(M,e){var t=typeof r=="string"?new Worker(r):r();return t.onmessage=function(n){var f=n.data,h=f.res,k=f.uuid,A=s.messageList.find(function(I){var D=I.uuid;return k===D});if(A==null||A.options.cb(h),s.workerList[e].inUse=!1,s.checkMessage(),y){var P=(A==null?void 0:A.options.cacheVersion)||L;(0,G.set)(k,(0,T.Z)({},P,h))}},{worker:t,inUse:!1}})},u.postMessage=function(r,i){var s=this,c=this.options,y=c.cache,L=c.cacheVersion;if(y&&!r.workerKey){console.warn("worker cache need workerKey");return}if(y&&r.workerKey&&r.delCache){console.warn("worker cache del: ".concat(r.workerKey)),(0,G.del)(r.workerKey);return}var M=r.workerKey||b.MathUtils.generateUUID();(y?(0,G.get)(M):Promise.resolve()).then(function(e){var t=i.cacheVersion||L;e&&e[t]?i.cb(e[t]):(s.messageList.push({req:r,options:i,uuid:M,inUse:!1}),s.checkMessage())}).catch(function(){console.warn("err:worker cache"),s.messageList.push({req:r,options:i,uuid:M,inUse:!1}),s.checkMessage()})},u.checkMessage=function(){var r=this.workerList.find(function(s){var c=s.inUse;return!c});if(r){var i=this.messageList.find(function(s){var c=s.inUse;return!c});i&&(i.inUse=!0,r.inUse=!0,r.worker.postMessage({req:i.req,uuid:i.uuid}))}},u.dispose=function(){this.workerList.forEach(function(r){var i=r.worker;i.terminate()}),this.workerList=[],this.messageList=[]},a}()})();var q=$.Ct,tt=$.Vw,et=$.hG,rt=$.Wk;export{q as Cache,tt as Data,et as Draw,rt as Wk};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gl-draw",
3
- "version": "0.8.13",
3
+ "version": "0.8.15",
4
4
  "author": "gitplus <hstits@gmail.com>",
5
5
  "scripts": {
6
6
  "start": "PORT=3003 bundler-dev",