@realsee/five 6.4.0 → 6.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/docs/classes/five.Tile3DModel.html +1 -1
- package/five/index.js +4 -4
- package/five/index.mjs +6 -6
- package/gltf-loader/index.js +3 -3
- package/gltf-loader/index.mjs +3 -3
- package/line/index.js +3 -3
- package/line/index.mjs +3 -3
- package/package.json +1 -1
- package/plugins/index.js +2 -2
- package/plugins/index.mjs +2 -2
- package/react/index.js +2 -2
- package/react/index.mjs +2 -2
- package/shader-lib/index.js +34 -21
- package/shader-lib/index.mjs +140 -127
- package/sticker/index.js +3 -3
- package/sticker/index.mjs +3 -3
- package/umd/five-gltf-loader.js +3 -3
- package/umd/five-line.js +3 -3
- package/umd/five-plugins.js +2 -2
- package/umd/five-react.js +2 -2
- package/umd/five-shader-lib.js +34 -21
- package/umd/five-sticker.js +3 -3
- package/umd/five-vfx.js +2 -2
- package/umd/five-vue.js +2 -2
- package/umd/five.js +4 -4
- package/vfx/index.js +2 -2
- package/vfx/index.mjs +2 -2
- package/vue/index.js +2 -2
- package/vue/index.mjs +2 -2
- package/work-downloader/index.d.ts +1 -0
- package/work-downloader/index.js +3 -3
- package/work-downloader/index.mjs +230 -266
package/vfx/index.js
CHANGED
package/vfx/index.mjs
CHANGED
package/vue/index.js
CHANGED
package/vue/index.mjs
CHANGED
package/work-downloader/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
3
|
* @realsee/five
|
|
4
|
-
* Generated:
|
|
5
|
-
* Version: 6.4.
|
|
4
|
+
* Generated: 6/20/2025
|
|
5
|
+
* Version: 6.4.2
|
|
6
6
|
* Terms:
|
|
7
7
|
* Realsee SDK License Agreement
|
|
8
8
|
* Update: July 28, 2021
|
|
@@ -252,4 +252,4 @@
|
|
|
252
252
|
* No amendment to or modification of this Agreement will be binding unless in
|
|
253
253
|
* writing and signed by Realsee. You and Realsee hereto confirm that this
|
|
254
254
|
* Agreement and all related documents shall be drafted in English.
|
|
255
|
-
*/"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const q=require("node:fs"),I=require("node:fs/promises"),y=require("node:path"),H=require("node:stream"),K=require("sharp");var C=function(){return C=Object.assign||function(e){for(var r,i=1,s=arguments.length;i<s;i++){r=arguments[i];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},C.apply(this,arguments)};function P(t,e,r,i){function s(n){return n instanceof r?n:new r(function(o){o(n)})}return new(r||(r=Promise))(function(n,o){function u(c){try{a(i.next(c))}catch(f){o(f)}}function l(c){try{a(i.throw(c))}catch(f){o(f)}}function a(c){c.done?n(c.value):s(c.value).then(u,l)}a((i=i.apply(t,e||[])).next())})}function p(t,e){var r={label:0,sent:function(){if(n[0]&1)throw n[1];return n[1]},trys:[],ops:[]},i,s,n,o=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return o.next=u(0),o.throw=u(1),o.return=u(2),typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function u(a){return function(c){return l([a,c])}}function l(a){if(i)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(r=0)),r;)try{if(i=1,s&&(n=a[0]&2?s.return:a[0]?s.throw||((n=s.return)&&n.call(s),0):s.next)&&!(n=n.call(s,a[1])).done)return n;switch(s=0,n&&(a=[a[0]&2,n.value]),a[0]){case 0:case 1:n=a;break;case 4:return r.label++,{value:a[1],done:!1};case 5:r.label++,s=a[1],a=[0];continue;case 7:a=r.ops.pop(),r.trys.pop();continue;default:if(n=r.trys,!(n=n.length>0&&n[n.length-1])&&(a[0]===6||a[0]===2)){r=0;continue}if(a[0]===3&&(!n||a[1]>n[0]&&a[1]<n[3])){r.label=a[1];break}if(a[0]===6&&r.label<n[1]){r.label=n[1],n=a;break}if(n&&r.label<n[2]){r.label=n[2],r.ops.push(a);break}n[2]&&r.ops.pop(),r.trys.pop();continue}a=e.call(t,r)}catch(c){a=[6,c],s=0}finally{i=n=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}}function O(t,e){if(e&&e[e.length-1]!=="/"&&(e+="/"),t.length>e.length&&t.startsWith(e))return t.slice(e.length);throw new Error("".concat(t," is not starting with ").concat(e))}function Q(t){return new Promise(function(e){return setTimeout(e,t)})}function G(t,e){return P(this,void 0,void 0,function(){var r,i,s,n,o;return p(this,function(u){switch(u.label){case 0:return u.trys.push([0,2,,7]),[4,fetch(t,e)];case 1:if(r=u.sent(),r.ok)return[2,r];throw new Error(r.statusText);case 2:if(i=u.sent(),s=(o=e==null?void 0:e.tries)!==null&&o!==void 0?o:2,!(s<1))return[3,3];throw i;case 3:return n=Math.floor(Math.random()*1e3),[4,Q(n)];case 4:return u.sent(),[4,G(t,C(C({},e),{tries:s-1}))];case 5:return[2,u.sent()];case 6:return[3,7];case 7:return[2]}})})}function F(t,e){return P(this,void 0,void 0,function(){var r,i,s;return p(this,function(n){switch(n.label){case 0:return q.existsSync(e)?[2,e]:[4,G(t)];case 1:return r=n.sent(),r.ok&&r.body?(i=H.Readable.fromWeb(r.body),[4,I.mkdir(y.dirname(e),{recursive:!0})]):[3,3];case 2:return n.sent(),s=q.createWriteStream(e),[2,new Promise(function(o,u){i.pipe(s),i.on("error",u),s.on("finish",function(){return o(e)})})];case 3:throw new Error(r.statusText)}})})}function U(t,e){return P(this,void 0,void 0,function(){var r,i,s,n,o,u,l,a,c,f;return p(this,function(v){return r=y.extname(t).slice(1)||"jpg",i=e.cut,s=e.size,n=e.format,o=n===void 0?r:n,u=K(t),i&&(u=u.extract({left:i[0],top:i[1],width:i[2],height:i[3]})),s&&(u=u.resize(s)),o&&(u=u.toFormat(o)),l="",e.toFilename?l=e.toFilename(t,{cut:e.cut,size:e.size,format:e.format}):(a="",c="",f=o,i&&(a=i.join("x")),s&&(c="".concat(s,"x")),f===r&&!c&&!a&&(f=""),l=[t,a,c,f].filter(function(m){return m.length>0}).join(".")),l!==t&&!q.existsSync(l)?[2,u.toFile(l).then(function(){return l})]:[2,l]})})}function A(t){var e=[];if(t.content&&(t.content.uri?e.push(t.content.uri):t.content.url&&e.push(t.content.url)),t.children)for(var r=0,i=t.children;r<i.length;r++){var s=i[r],n=A(s);n.length>0&&e.push.apply(e,n)}return e}function V(t,e,r){return P(this,void 0,void 0,function(){var i,s,n;return p(this,function(o){switch(o.label){case 0:return i=new URL(t,e).href,s=y.join(r.distPath,O(i,r.baseURL)),n=F(i,s),r.log(function(u){return"download: ".concat(i," -> ").concat(u)},n),[4,n];case 1:return o.sent(),/\.json$/.test(t)?[4,B(i,r)]:[3,3];case 2:o.sent(),o.label=3;case 3:return[2]}})})}function B(t,e){return P(this,void 0,void 0,function(){var r,i,s,n,o,u,l,a,c,f,v,m,w,g,h,b,j,k;return p(this,function(d){switch(d.label){case 0:return r=y.join(e.distPath,O(t,e.baseURL)),i=F(t,r),e.log(function(z){return"download: ".concat(t," -> ").concat(z)},i),[4,i];case 1:return d.sent(),o=(n=JSON).parse,[4,I.readFile(r,"utf8")];case 2:return s=o.apply(n,[d.sent()]),s.asset.overview?(u=new URL(s.asset.overview.imageFile,t).href,l=y.join(e.distPath,O(u,e.baseURL)),a=F(u,l),e.log(function(z){return"download: ".concat(u," -> ").concat(z)},a),[4,a]):[3,4];case 3:d.sent(),d.label=4;case 4:if(!s.asset.trajectories)return[3,8];c=function(z){var _,S,T;return p(this,function($){switch($.label){case 0:return _=new URL(z.file,t).href,S=y.join(e.distPath,O(_,e.baseURL)),T=F(_,S),e.log(function(R){return"download: ".concat(_," -> ").concat(R)},T),[4,T];case 1:return $.sent(),[2]}})},f=0,v=s.asset.trajectories.list,d.label=5;case 5:return f<v.length?(m=v[f],[5,c(m)]):[3,8];case 6:d.sent(),d.label=7;case 7:return f++,[3,5];case 8:for(w=A(s.root),g=[],h=0,b=w;h<b.length;h++)j=b[h],k=V(j,t,e),g.push(k);return[4,Promise.all(g)];case 9:return d.sent(),[2]}})})}function X(t,e){return P(this,void 0,void 0,function(){var r,i,s,n,o,u,l,a,c,f,v,m,w,g;return p(this,function(h){switch(h.label){case 0:return e.log("process model"),t.model?(r=t.model,i=r.textures,s=r.layers,n=r.file,n?(e.log("process model file"),o=y.join(e.distPath,O(n,e.baseURL)),u=F(n,o),e.log(function(b){return"download: ".concat(n," -> ").concat(b)},u),[4,u]):[3,5]):[3,9];case 1:if(h.sent(),!i)return[3,5];l=function(b){var j,k,d,z,_,S,T,$,R,M,J,N;return p(this,function(W){switch(W.label){case 0:return j=y.join(e.distPath,O(b,e.baseURL)),k=F(b,j),e.log(function(D){return"download: ".concat(b," -> ").concat(D)},k),[4,k];case 1:for(W.sent(),d=e.imageOptions.format,d.length===0&&d.push(void 0),z=e.imageOptions.size,z.length===0&&z.push(void 0),_=[],S=0,T=d;S<T.length;S++)for($=T[S],R=0,M=z;R<M.length;R++)J=M[R],N=U(j,{format:$,size:J,toFilename:e.imageProcessingFilename}),e.log(function(D){return"imageProcessing: ".concat(j," -> ").concat(D)},N),_.push(N);return[4,Promise.all(_)];case 2:return W.sent(),[2]}})},a=0,c=i,h.label=2;case 2:return a<c.length?(f=c[a],[5,l(f)]):[3,5];case 3:h.sent(),h.label=4;case 4:return a++,[3,2];case 5:if(!s)return[3,9];v=0,m=s,h.label=6;case 6:return v<m.length?(w=m[v],g=w.tileset,e.log("process model layer"),[4,B(g,e)]):[3,9];case 7:h.sent(),h.label=8;case 8:return v++,[3,6];case 9:return[2]}})})}function E(t,e,r){return P(this,void 0,void 0,function(){var i,s,n,o,u,l,a,c,f,v,m,w,g;return p(this,function(h){switch(h.label){case 0:return i=y.join(r.distPath,O(t,r.baseURL)),s=F(t,i),r.log(function(b){return"download: ".concat(t," -> ").concat(b)},s),[4,s];case 1:if(h.sent(),n=Math.pow(2,e.level),o=r.imageOptions.format,o.length===0&&o.push(void 0),u=[],n>1)for(l=0;l<n;l++)for(a=0;a<n;a++)for(c=0,f=o;c<f.length;c++)v=f[c],m=[e.size/n*a,e.size/n*l,e.size/n,e.size/n],w=e.scale>=1?void 0:e.scale*e.size/n,e.level===1&&e.scale>=.5&&(v==="jpg"||/\.jpg$/.test(i))&&(w=void 0),g=U(i,{format:v,size:w,cut:m,toFilename:r.imageProcessingFilename}),r.log(function(b){return"imageProcessing: ".concat(i," -> ").concat(b)},g),u.push(g);return[4,Promise.all(u)];case 2:return h.sent(),[2]}})})}function Y(t,e){return P(this,void 0,void 0,function(){return p(this,function(r){switch(r.label){case 0:return[4,Promise.all([E(t.front,t,e),E(t.back,t,e),E(t.left,t,e),E(t.right,t,e),E(t.up,t,e),E(t.down,t,e)])];case 1:return r.sent(),[2]}})})}function L(t,e){return P(this,void 0,void 0,function(){var r,i,s,n,o,u,l,a,c,f,v,m;return p(this,function(w){switch(w.label){case 0:return r=y.join(e.distPath,O(t,e.baseURL)),i=F(t,r),e.log(function(g){return"download: ".concat(t," -> ").concat(g)},i),[4,i];case 1:for(w.sent(),s=e.imageOptions.format,s.length===0&&s.push(void 0),n=e.imageOptions.size,n.length===0&&n.push(void 0),o=[],u=0,l=s;u<l.length;u++)for(a=l[u],c=0,f=n;c<f.length;c++)v=f[c],m=U(r,{format:a,size:v,toFilename:e.imageProcessingFilename}),e.log(function(g){return"imageProcessing: ".concat(r," -> ").concat(g)},m),o.push(m);return[4,Promise.all(o)];case 2:return w.sent(),[2]}})})}function Z(t,e){return P(this,void 0,void 0,function(){var r;return p(this,function(i){switch(i.label){case 0:return r=t.images,[4,Promise.all([L(r.front,e),L(r.back,e),L(r.left,e),L(r.right,e),L(r.up,e),L(r.down,e)])];case 1:return i.sent(),r.tiles?[4,Promise.all(r.tiles.map(function(s){return Y(s,e)}))]:[3,3];case 2:i.sent(),i.label=3;case 3:return[2]}})})}function x(t,e){return P(this,void 0,void 0,function(){var r,i,s,n,o;return p(this,function(u){switch(u.label){case 0:r=t.observers,i=0,s=r,u.label=1;case 1:return i<s.length?(n=s[i],o=Z(n,e),e.log("process observer #".concat(n.index," derived: ").concat(n.derivedIdStr),o),[4,o]):[3,4];case 2:u.sent(),u.label=3;case 3:return i++,[3,1];case 4:return[2]}})})}function ee(t,e){if(e){var r=Date.now();e.then(function(s){var n=Date.now()-r,o=typeof t=="function"?t(s):t;console.log(o+"(".concat(n,"ms)"))}).catch(function(){})}else{var i=typeof t=="function"?t(null):t;console.log(i)}}function re(t){return P(this,arguments,void 0,function(e,r){var i,s,n,o,u,l,a,c,f,v,m,w,g,h,b,j,k;return r===void 0&&(r={}),p(this,function(d){switch(d.label){case 0:if(i=e.baseURL,s="",r.distPath)s=y.resolve(process.cwd(),r.distPath);else for(s=y.resolve(process.cwd(),(f=e.workCode)!==null&&f!==void 0?f:"work-".concat(Date.now()));q.existsSync(s);)/.-(\d+)$/.test(s)?s=s.replace(/.-(\d+)$/,function(z,_){return"-"+(Number(_)+1)}):s=s+"-1";return n={baseURL:i,distPath:s,imageOptions:{size:(m=(v=r.imageOptions)===null||v===void 0?void 0:v.size)!==null&&m!==void 0?m:[],format:(g=(w=r.imageOptions)===null||w===void 0?void 0:w.format)!==null&&g!==void 0?g:[]},textureOptions:{size:(b=(h=r.textureOptions)===null||h===void 0?void 0:h.size)!==null&&b!==void 0?b:[],format:(k=(j=r.textureOptions)===null||j===void 0?void 0:j.format)!==null&&k!==void 0?k:[]},log:r.log?ee:function(){return Promise.resolve()},imageProcessingFilename:r.imageProcessingFilename},n.log(JSON.stringify(n,null," ")),[4,I.mkdir(s,{recursive:!0})];case 1:d.sent(),o=0,d.label=2;case 2:return o<e.raw.works.length?(u=e.raw.works[o],l=o>0?"-".concat(o):"",a="work".concat(l,".json"),c=y.resolve(s,a),[4,I.writeFile(c,u)]):[3,5];case 3:d.sent(),d.label=4;case 4:return o++,[3,2];case 5:return[4,x(e,n)];case 6:return d.sent(),[4,X(e,n)];case 7:return d.sent(),[2]}})})}exports.download=re;
|
|
255
|
+
*/"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const q=require("node:fs"),$=require("node:fs/promises"),y=require("node:path"),A=require("node:stream"),G=require("sharp");function z(t,e,r,i){function s(n){return n instanceof r?n:new r(function(o){o(n)})}return new(r||(r=Promise))(function(n,o){function u(c){try{a(i.next(c))}catch(f){o(f)}}function l(c){try{a(i.throw(c))}catch(f){o(f)}}function a(c){c.done?n(c.value):s(c.value).then(u,l)}a((i=i.apply(t,e||[])).next())})}function P(t,e){var r={label:0,sent:function(){if(n[0]&1)throw n[1];return n[1]},trys:[],ops:[]},i,s,n,o=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return o.next=u(0),o.throw=u(1),o.return=u(2),typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function u(a){return function(c){return l([a,c])}}function l(a){if(i)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(r=0)),r;)try{if(i=1,s&&(n=a[0]&2?s.return:a[0]?s.throw||((n=s.return)&&n.call(s),0):s.next)&&!(n=n.call(s,a[1])).done)return n;switch(s=0,n&&(a=[a[0]&2,n.value]),a[0]){case 0:case 1:n=a;break;case 4:return r.label++,{value:a[1],done:!1};case 5:r.label++,s=a[1],a=[0];continue;case 7:a=r.ops.pop(),r.trys.pop();continue;default:if(n=r.trys,!(n=n.length>0&&n[n.length-1])&&(a[0]===6||a[0]===2)){r=0;continue}if(a[0]===3&&(!n||a[1]>n[0]&&a[1]<n[3])){r.label=a[1];break}if(a[0]===6&&r.label<n[1]){r.label=n[1],n=a;break}if(n&&r.label<n[2]){r.label=n[2],r.ops.push(a);break}n[2]&&r.ops.pop(),r.trys.pop();continue}a=e.call(t,r)}catch(c){a=[6,c],s=0}finally{i=n=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}}function O(t,e){if(e&&e[e.length-1]!=="/"&&(e+="/"),t.length>e.length&&t.startsWith(e))return t.slice(e.length);throw new Error("".concat(t," is not starting with ").concat(e))}var X=1024*1024*5;function S(t,e,r){return z(this,void 0,void 0,function(){var i,s,n,o;return P(this,function(u){switch(u.label){case 0:return q.existsSync(e)?[2,e]:[4,r(t)];case 1:return i=u.sent(),i.ok&&i.body?[4,$.mkdir(y.dirname(e),{recursive:!0})]:[3,6];case 2:return u.sent(),s=Number((o=i.headers.get("content-length"))!==null&&o!==void 0?o:"Infinity"),s>X?[2,new Promise(function(l,a){var c=A.Readable.fromWeb(i.body),f=q.createWriteStream(e);c.pipe(f),c.on("error",a),f.on("finish",function(){return l(e)})})]:[3,3];case 3:return[4,i.arrayBuffer()];case 4:return n=u.sent(),[4,$.writeFile(e,Buffer.from(n))];case 5:return u.sent(),[2,e];case 6:throw new Error("url: ".concat(t,"(").concat(i.statusText,")"))}})})}function D(t,e){return z(this,void 0,void 0,function(){var r,i,s,n,o,u,l,a,c,f;return P(this,function(h){return r=y.extname(t).slice(1)||"jpg",i=e.cut,s=e.size,n=e.format,o=n===void 0?r:n,u=G(t),i&&(u=u.extract({left:i[0],top:i[1],width:i[2],height:i[3]})),s&&(u=u.resize(s)),o&&(u=u.toFormat(o)),l="",e.toFilename?l=e.toFilename(t,{cut:e.cut,size:e.size,format:e.format}):(a="",c="",f=o,i&&(a=i.join("x")),s&&(c="".concat(s,"x")),f===r&&!c&&!a&&(f=""),l=[t,a,c,f].filter(function(v){return v.length>0}).join(".")),l!==t&&!q.existsSync(l)?[2,u.toFile(l).then(function(){return l})]:[2,l]})})}function W(t){var e=[];if(t.content&&(t.content.uri?e.push(t.content.uri):t.content.url&&e.push(t.content.url)),t.children)for(var r=0,i=t.children;r<i.length;r++){var s=i[r],n=W(s);n.length>0&&e.push.apply(e,n)}return e}function H(t,e,r){return z(this,void 0,void 0,function(){var i,s,n;return P(this,function(o){switch(o.label){case 0:return i=new URL(t,e).href,s=y.join(r.distPath,O(i,r.baseURL)),n=S(i,s,r.fetch),r.log(function(u){return"download: ".concat(i," -> ").concat(u)},n),[4,n];case 1:return o.sent(),/\.json$/.test(t)?[4,J(i,r)]:[3,3];case 2:o.sent(),o.label=3;case 3:return[2]}})})}function J(t,e){return z(this,void 0,void 0,function(){var r,i,s,n,o,u,l,a,c,f,h,v,w,m,d,p,k,j;return P(this,function(g){switch(g.label){case 0:return r=y.join(e.distPath,O(t,e.baseURL)),i=S(t,r,e.fetch),e.log(function(b){return"download: ".concat(t," -> ").concat(b)},i),[4,i];case 1:return g.sent(),o=(n=JSON).parse,[4,$.readFile(r,"utf8")];case 2:return s=o.apply(n,[g.sent()]),s.asset.overview?(u=new URL(s.asset.overview.imageFile,t).href,l=y.join(e.distPath,O(u,e.baseURL)),a=S(u,l,e.fetch),e.log(function(b){return"download: ".concat(u," -> ").concat(b)},a),[4,a]):[3,4];case 3:g.sent(),g.label=4;case 4:if(!s.asset.trajectories)return[3,8];c=function(b){var F,_,R;return P(this,function(I){switch(I.label){case 0:return F=new URL(b.file,t).href,_=y.join(e.distPath,O(F,e.baseURL)),R=S(F,_,e.fetch),e.log(function(T){return"download: ".concat(F," -> ").concat(T)},R),[4,R];case 1:return I.sent(),[2]}})},f=0,h=s.asset.trajectories.list,g.label=5;case 5:return f<h.length?(v=h[f],[5,c(v)]):[3,8];case 6:g.sent(),g.label=7;case 7:return f++,[3,5];case 8:for(w=W(s.root),m=[],d=0,p=w;d<p.length;d++)k=p[d],j=H(k,t,e),m.push(j);return[4,Promise.all(m)];case 9:return g.sent(),[2]}})})}function K(t,e){return z(this,void 0,void 0,function(){var r,i,s,n,o,u,l,a,c,f,h,v,w,m;return P(this,function(d){switch(d.label){case 0:return e.log("process model"),t.model?(r=t.model,i=r.textures,s=r.layers,n=r.file,n?(e.log("process model file"),o=y.join(e.distPath,O(n,e.baseURL)),u=S(n,o,e.fetch),e.log(function(p){return"download: ".concat(n," -> ").concat(p)},u),[4,u]):[3,5]):[3,9];case 1:if(d.sent(),!i)return[3,5];l=function(p){var k,j,g,b,F,_,R,I,T,N,M,C;return P(this,function(U){switch(U.label){case 0:return k=y.join(e.distPath,O(p,e.baseURL)),j=S(p,k,e.fetch),e.log(function(B){return"download: ".concat(p," -> ").concat(B)},j),[4,j];case 1:for(U.sent(),g=e.imageOptions.format,g.length===0&&g.push(void 0),b=e.imageOptions.size,b.length===0&&b.push(void 0),F=[],_=0,R=g;_<R.length;_++)for(I=R[_],T=0,N=b;T<N.length;T++)M=N[T],C=D(k,{format:I,size:M,toFilename:e.imageProcessingFilename}),e.log(function(B){return"imageProcessing: ".concat(k," -> ").concat(B)},C),F.push(C);return[4,Promise.all(F)];case 2:return U.sent(),[2]}})},a=0,c=i,d.label=2;case 2:return a<c.length?(f=c[a],[5,l(f)]):[3,5];case 3:d.sent(),d.label=4;case 4:return a++,[3,2];case 5:if(!s)return[3,9];h=0,v=s,d.label=6;case 6:return h<v.length?(w=v[h],m=w.tileset,e.log("process model layer"),[4,J(m,e)]):[3,9];case 7:d.sent(),d.label=8;case 8:return h++,[3,6];case 9:return[2]}})})}function E(t,e,r){return z(this,void 0,void 0,function(){var i,s,n,o,u,l,a,c,f,h,v,w,m;return P(this,function(d){switch(d.label){case 0:return i=y.join(r.distPath,O(t,r.baseURL)),s=S(t,i,r.fetch),r.log(function(p){return"download: ".concat(t," -> ").concat(p)},s),[4,s];case 1:if(d.sent(),n=Math.pow(2,e.level),o=r.imageOptions.format,o.length===0&&o.push(void 0),u=[],n>1)for(l=0;l<n;l++)for(a=0;a<n;a++)for(c=0,f=o;c<f.length;c++)h=f[c],v=[e.size/n*a,e.size/n*l,e.size/n,e.size/n],w=e.scale>=1?void 0:e.scale*e.size/n,e.level===1&&e.scale>=.5&&(h==="jpg"||/\.jpg$/.test(i))&&(w=void 0),m=D(i,{format:h,size:w,cut:v,toFilename:r.imageProcessingFilename}),r.log(function(p){return"imageProcessing: ".concat(i," -> ").concat(p)},m),u.push(m);return[4,Promise.all(u)];case 2:return d.sent(),[2]}})})}function Q(t,e){return z(this,void 0,void 0,function(){return P(this,function(r){switch(r.label){case 0:return[4,Promise.all([E(t.front,t,e),E(t.back,t,e),E(t.left,t,e),E(t.right,t,e),E(t.up,t,e),E(t.down,t,e)])];case 1:return r.sent(),[2]}})})}function L(t,e){return z(this,void 0,void 0,function(){var r,i,s,n,o,u,l,a,c,f,h,v;return P(this,function(w){switch(w.label){case 0:return r=y.join(e.distPath,O(t,e.baseURL)),i=S(t,r,e.fetch),e.log(function(m){return"download: ".concat(t," -> ").concat(m)},i),[4,i];case 1:for(w.sent(),s=e.imageOptions.format,s.length===0&&s.push(void 0),n=e.imageOptions.size,n.length===0&&n.push(void 0),o=[],u=0,l=s;u<l.length;u++)for(a=l[u],c=0,f=n;c<f.length;c++)h=f[c],v=D(r,{format:a,size:h,toFilename:e.imageProcessingFilename}),e.log(function(m){return"imageProcessing: ".concat(r," -> ").concat(m)},v),o.push(v);return[4,Promise.all(o)];case 2:return w.sent(),[2]}})})}function V(t,e){return z(this,void 0,void 0,function(){var r;return P(this,function(i){switch(i.label){case 0:return r=t.images,[4,Promise.all([L(r.front,e),L(r.back,e),L(r.left,e),L(r.right,e),L(r.up,e),L(r.down,e)])];case 1:return i.sent(),r.tiles?[4,Promise.all(r.tiles.map(function(s){return Q(s,e)}))]:[3,3];case 2:i.sent(),i.label=3;case 3:return[2]}})})}function Y(t,e){return z(this,void 0,void 0,function(){var r,i,s,n,o;return P(this,function(u){switch(u.label){case 0:r=t.observers,i=0,s=r,u.label=1;case 1:return i<s.length?(n=s[i],o=V(n,e),e.log("process observer #".concat(n.index," derived: ").concat(n.derivedIdStr),o),[4,o]):[3,4];case 2:u.sent(),u.label=3;case 3:return i++,[3,1];case 4:return[2]}})})}function Z(t,e){if(e){var r=Date.now();e.then(function(s){var n=Date.now()-r,o=typeof t=="function"?t(s):t;console.log(o+"(".concat(n,"ms)"))}).catch(function(){})}else{var i=typeof t=="function"?t(null):t;console.log(i)}}function x(t){return z(this,arguments,void 0,function(e,r){var i,s,n,o,u,l,a,c,f,h,v,w,m,d,p,k,j,g;return r===void 0&&(r={}),P(this,function(b){switch(b.label){case 0:if(i=e.baseURL,s="",r.distPath)s=y.resolve(process.cwd(),r.distPath);else for(s=y.resolve(process.cwd(),(f=e.workCode)!==null&&f!==void 0?f:"work-".concat(Date.now()));q.existsSync(s);)/.-(\d+)$/.test(s)?s=s.replace(/.-(\d+)$/,function(F,_){return"-"+(Number(_)+1)}):s=s+"-1";return n={baseURL:i,distPath:s,fetch:(h=r.fetch)!==null&&h!==void 0?h:fetch,imageOptions:{size:(w=(v=r.imageOptions)===null||v===void 0?void 0:v.size)!==null&&w!==void 0?w:[],format:(d=(m=r.imageOptions)===null||m===void 0?void 0:m.format)!==null&&d!==void 0?d:[]},textureOptions:{size:(k=(p=r.textureOptions)===null||p===void 0?void 0:p.size)!==null&&k!==void 0?k:[],format:(g=(j=r.textureOptions)===null||j===void 0?void 0:j.format)!==null&&g!==void 0?g:[]},log:r.log?Z:function(){return Promise.resolve()},imageProcessingFilename:r.imageProcessingFilename},n.log(JSON.stringify(n,null," ")),[4,$.mkdir(s,{recursive:!0})];case 1:b.sent(),o=0,b.label=2;case 2:return o<e.raw.works.length?(u=e.raw.works[o],l=o>0?"-".concat(o):"",a="work".concat(l,".json"),c=y.resolve(s,a),[4,$.writeFile(c,u)]):[3,5];case 3:b.sent(),b.label=4;case 4:return o++,[3,2];case 5:return[4,Y(e,n)];case 6:return b.sent(),[4,K(e,n)];case 7:return b.sent(),[2]}})})}exports.download=x;
|