gl-draw 0.4.7 → 0.4.8

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