gl-draw 0.8.9 → 0.8.10

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