gl-draw 0.3.12 → 0.3.13

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