19 lines
114 KiB
JavaScript
19 lines
114 KiB
JavaScript
|
!function(e,t){"use strict";function r(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function n(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var a=n(e),o=r(t);function i(){var e=Object.create(null);function t(n,a){var o=n.id,i=n.name,s=n.dependencies;void 0===s&&(s=[]);var l=n.init;void 0===l&&(l=function(){});var u=n.getTransferables;if(void 0===u&&(u=null),!e[o])try{s=s.map((function(r){return r&&r.isWorkerModule&&(t(r,(function(e){if(e instanceof Error)throw e})),r=e[r.id].value),r})),l=r("<"+i+">.init",l),u&&(u=r("<"+i+">.getTransferables",u));var f=null;"function"==typeof l?f=l.apply(void 0,s):console.error("worker module init function failed to rehydrate"),e[o]={id:o,value:f,getTransferables:u},a(f)}catch(e){e&&e.noLog||console.error(e),a(e)}}function r(e,t){var r=void 0;self.troikaDefine=function(e){return r=e};var n=URL.createObjectURL(new Blob(["/** "+e.replace(/\*/g,"")+" **/\n\ntroikaDefine(\n"+t+"\n)"],{type:"application/javascript"}));try{importScripts(n)}catch(e){console.error(e)}return URL.revokeObjectURL(n),delete self.troikaDefine,r}self.addEventListener("message",(function(r){var n=r.data,a=n.messageId,o=n.action,i=n.data;try{"registerModule"===o&&t(i,(function(e){e instanceof Error?postMessage({messageId:a,success:!1,error:e.message}):postMessage({messageId:a,success:!0,result:{isCallable:"function"==typeof e}})})),"callModule"===o&&function(t,r){var n,a=t.id,o=t.args;e[a]&&"function"==typeof e[a].value||r(new Error("Worker module "+a+": not found or its 'init' did not return a function"));try{var i=(n=e[a]).value.apply(n,o);i&&"function"==typeof i.then?i.then(s,(function(e){return r(e instanceof Error?e:new Error(""+e))})):s(i)}catch(e){r(e)}function s(t){try{var n=e[a].getTransferables&&e[a].getTransferables(t);n&&Array.isArray(n)&&n.length||(n=void 0),r(t,n)}catch(e){console.error(e),r(e)}}}(i,(function(e,t){e instanceof Error?postMessage({messageId:a,success:!1,error:e.message}):postMessage({messageId:a,success:!0,result:e},t||void 0)}))}catch(e){postMessage({messageId:a,success:!1,error:e.stack})}}))}var s=function(){var e=!1;if("undefined"!=typeof window&&void 0!==window.document)try{new Worker(URL.createObjectURL(new Blob([""],{type:"application/javascript"}))).terminate(),e=!0}catch(e){"undefined"!=typeof process&&"test"===process.env.NODE_ENV||console.log("Troika createWorkerModule: web workers not allowed; falling back to main thread execution. Cause: ["+e.message+"]")}return s=function(){return e},e},l=0,u=0,f=!1,c=Object.create(null),h=Object.create(null),d=Object.create(null);function p(e){if(!(e&&"function"==typeof e.init||f))throw new Error("requires `options.init` function");var t=e.dependencies,r=e.init,n=e.getTransferables,a=e.workerId;if(!s())return function(e){var t=function(){for(var e=[],r=arguments.length;r--;)e[r]=arguments[r];return t._getInitResult().then((function(t){if("function"==typeof t)return t.apply(void 0,e);throw new Error("Worker module function was called but `init` did not return a callable function")}))};return t._getInitResult=function(){var r=e.dependencies,n=e.init;r=Array.isArray(r)?r.map((function(e){return e&&e._getInitResult?e._getInitResult():e})):[];var a=Promise.all(r).then((function(e){return n.apply(null,e)}));return t._getInitResult=function(){return a},a},t}(e);null==a&&(a="#default");var o="workerModule"+ ++l,i=e.name||o,u=null;function c(){for(var e=[],t=arguments.length;t--;)e[t]=arguments[t];if(!u){u=g(a,"registerModule",c.workerModuleData);var r=function(){u=null,h[a].delete(r)};(h[a]||(h[a]=new Set)).add(r)}return u.then((function(t){if(t.isCallable)return g(a,"callModule",{id:o,args:e});throw new Error("Worker module function was called but `init` did not return a callable function")}))}return t=t&&t.map((function(e){return"function"!=typeof e||e.workerModuleData||(f=!0,e=p({workerId:a,name:"<"+i+"> f
|
||
|
/*!
|
||
|
Custom build of Typr.ts (https://github.com/fredli74/Typr.ts) for use in Troika text rendering.
|
||
|
Original MIT license applies: https://github.com/fredli74/Typr.ts/blob/master/LICENSE
|
||
|
*/(r);let a=k.get(t);if(a||k.set(t,a=Object.create(null)),a[n])return new a[n];const o=`_onBeforeCompile${n}`,i=function(e,a){t.onBeforeCompile.call(this,e,a);const i=this.customProgramCacheKey()+"|"+e.vertexShader+"|"+e.fragmentShader;let s=w[i];if(!s){const t=function(e,{vertexShader:t,fragmentShader:r},n,a){let{vertexDefs:o,vertexMainIntro:i,vertexMainOutro:s,vertexTransform:l,fragmentDefs:u,fragmentMainIntro:f,fragmentMainOutro:c,fragmentColorTransform:h,customRewriter:d,timeUniform:p}=n;o=o||"",i=i||"",s=s||"",u=u||"",f=f||"",c=c||"",(l||d)&&(t=b(t));(h||d)&&(r=b(r=r.replace(/^[ \t]*#include <((?:tonemapping|encodings|fog|premultiplied_alpha|dithering)_fragment)>/gm,"\n//!BEGIN_POST_CHUNK $1\n$&\n//!END_POST_CHUNK\n")));if(d){let e=d({vertexShader:t,fragmentShader:r});t=e.vertexShader,r=e.fragmentShader}if(h){let e=[];r=r.replace(/^\/\/!BEGIN_POST_CHUNK[^]+?^\/\/!END_POST_CHUNK/gm,(t=>(e.push(t),""))),c=`${h}\n${e.join("\n")}\n${c}`}if(p){const e=`\nuniform float ${p};\n`;o=e+o,u=e+u}l&&(o=`${o}\nvoid troikaVertexTransform${a}(inout vec3 position, inout vec3 normal, inout vec2 uv) {\n ${l}\n}\n`,i=`\ntroika_position_${a} = vec3(position);\ntroika_normal_${a} = vec3(normal);\ntroika_uv_${a} = vec2(uv);\ntroikaVertexTransform${a}(troika_position_${a}, troika_normal_${a}, troika_uv_${a});\n${i}\n`,t=(t=`vec3 troika_position_${a};\nvec3 troika_normal_${a};\nvec2 troika_uv_${a};\n${t}\n`).replace(/\b(position|normal|uv)\b/g,((e,t,r,n)=>/\battribute\s+vec[23]\s+$/.test(n.substr(0,r))?t:`troika_${t}_${a}`)),e.map&&e.map.channel>0||(t=t.replace(/\bMAP_UV\b/g,`troika_uv_${a}`)));return t=F(t,a,o,i,s),r=F(r,a,u,f,c),{vertexShader:t,fragmentShader:r}}(this,e,r,n);s=w[i]=t}e.vertexShader=s.vertexShader,e.fragmentShader=s.fragmentShader,S(e.uniforms,this.uniforms),r.timeUniform&&(e.uniforms[r.timeUniform]={get value(){return Date.now()-U}}),this[o]&&this[o](e)},s=function(){return l(r.chained?t:t.clone())},l=function(e){const a=Object.create(e,u);return Object.defineProperty(a,"baseMaterial",{value:t}),Object.defineProperty(a,"id",{value:T++}),a.uuid=function(){const e=4294967295*Math.random()|0,t=4294967295*Math.random()|0,r=4294967295*Math.random()|0,n=4294967295*Math.random()|0;return(x[255&e]+x[e>>8&255]+x[e>>16&255]+x[e>>24&255]+"-"+x[255&t]+x[t>>8&255]+"-"+x[t>>16&15|64]+x[t>>24&255]+"-"+x[63&r|128]+x[r>>8&255]+"-"+x[r>>16&255]+x[r>>24&255]+x[255&n]+x[n>>8&255]+x[n>>16&255]+x[n>>24&255]).toUpperCase()}(),a.uniforms=S({},e.uniforms,r.uniforms),a.defines=S({},e.defines,r.defines),a.defines[`TROIKA_DERIVED_MATERIAL_${n}`]="",a.extensions=S({},e.extensions,r.extensions),a._listeners=void 0,a},u={constructor:{value:s},isDerivedMaterial:{value:!0},customProgramCacheKey:{writable:!0,configurable:!0,value:function(){return t.customProgramCacheKey()+"|"+n}},onBeforeCompile:{get:()=>i,set(e){this[o]=e}},copy:{writable:!0,configurable:!0,value:function(r){return t.copy.call(this,r),t.isShaderMaterial||t.isDerivedMaterial||(S(this.extensions,r.extensions),S(this.defines,r.defines),S(this.uniforms,e.UniformsUtils.clone(r.uniforms))),this}},clone:{writable:!0,configurable:!0,value:function(){const e=new t.constructor;return l(e).copy(this)}},getDepthMaterial:{writable:!0,configurable:!0,value:function(){let n=this._depthMaterial;return n||(n=this._depthMaterial=_(t.isDerivedMaterial?t.getDepthMaterial():new e.MeshDepthMaterial({depthPacking:e.RGBADepthPacking}),r),n.defines.IS_DEPTH_MATERIAL="",n.uniforms=this.uniforms),n}},getDistanceMaterial:{writable:!0,configurable:!0,value:function(){let n=this._distanceMaterial;return n||(n=this._distanceMaterial=_(t.isDerivedMaterial?t.getDistanceMaterial():new e.MeshDistanceMaterial,r),n.defines.IS_DISTANCE_MATERIAL="",n.uniforms=this.uniforms),n}},dispose:{writable:!0,configurable:!0,value(){const{_depthMaterial:e,_distanceMaterial:r}=this;e&&e.dispose(),r&&r.dispose(),t.dispose.call(this)}}};return a[n]=s,new s}function F(e,t,r,n,a){return(n||a||r)&&(e=e.replace(y,`\n${r}\nvoid troikaOrigMain${t}() {`),e+=`\nvoid main() {\n ${n}\n troikaOrigMain${t}();\n ${a}\n}`),e}function C(e,t){retu
|
||
|
/*!
|
||
|
Custom bundle of woff2otf (https://github.com/arty-name/woff2otf) with fflate
|
||
|
(https://github.com/101arrowz/fflate) for use in Troika text rendering.
|
||
|
Original licenses apply:
|
||
|
- fflate: https://github.com/101arrowz/fflate/blob/master/LICENSE (MIT)
|
||
|
- woff2otf.js: https://github.com/arty-name/woff2otf/blob/master/woff2otf.js (Apache2)
|
||
|
*/,function(){return function(e){var t=Uint8Array,r=Uint16Array,n=Uint32Array,a=new t([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),o=new t([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),i=new t([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),s=function(e,t){for(var a=new r(31),o=0;o<31;++o)a[o]=t+=1<<e[o-1];var i=new n(a[30]);for(o=1;o<30;++o)for(var s=a[o];s<a[o+1];++s)i[s]=s-a[o]<<5|o;return[a,i]},l=s(a,2),u=l[0],f=l[1];u[28]=258,f[258]=28;for(var c=s(o,0)[0],h=new r(32768),d=0;d<32768;++d){var p=(43690&d)>>>1|(21845&d)<<1;p=(61680&(p=(52428&p)>>>2|(13107&p)<<2))>>>4|(3855&p)<<4,h[d]=((65280&p)>>>8|(255&p)<<8)>>>1}var v=function(e,t,n){for(var a=e.length,o=0,i=new r(t);o<a;++o)++i[e[o]-1];var s,l=new r(t);for(o=0;o<t;++o)l[o]=l[o-1]+i[o-1]<<1;if(n){s=new r(1<<t);var u=15-t;for(o=0;o<a;++o)if(e[o])for(var f=o<<4|e[o],c=t-e[o],d=l[e[o]-1]++<<c,p=d|(1<<c)-1;d<=p;++d)s[h[d]>>>u]=f}else for(s=new r(a),o=0;o<a;++o)e[o]&&(s[o]=h[l[e[o]-1]++]>>>15-e[o]);return s},g=new t(288);for(d=0;d<144;++d)g[d]=8;for(d=144;d<256;++d)g[d]=9;for(d=256;d<280;++d)g[d]=7;for(d=280;d<288;++d)g[d]=8;var m=new t(32);for(d=0;d<32;++d)m[d]=5;var y=v(g,9,1),b=v(m,5,1),x=function(e){for(var t=e[0],r=1;r<e.length;++r)e[r]>t&&(t=e[r]);return t},S=function(e,t,r){var n=t/8|0;return(e[n]|e[n+1]<<8)>>(7&t)&r},U=function(e,t){var r=t/8|0;return(e[r]|e[r+1]<<8|e[r+2]<<16)>>(7&t)},k=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],w=function(e,t,r){var n=new Error(t||k[e]);if(n.code=e,Error.captureStackTrace&&Error.captureStackTrace(n,w),!r)throw n;return n},T=function(e,s,l){var f=e.length;if(!f||l&&!l.l&&f<5)return s||new t(0);var h=!s||l,d=!l||l.i;l||(l={}),s||(s=new t(3*f));var p,g=function(e){var r=s.length;if(e>r){var n=new t(Math.max(2*r,e));n.set(s),s=n}},m=l.f||0,k=l.p||0,T=l.b||0,_=l.l,F=l.d,C=l.m,D=l.n,A=8*f;do{if(!_){l.f=m=S(e,k,1);var O=S(e,k+1,3);if(k+=3,!O){var R=e[(N=((p=k)/8|0)+(7&p&&1)+4)-4]|e[N-3]<<8,E=N+R;if(E>f){d&&w(0);break}h&&g(T+R),s.set(e.subarray(N,E),T),l.b=T+=R,l.p=k=8*E;continue}if(1==O)_=y,F=b,C=9,D=5;else if(2==O){var M=S(e,k,31)+257,I=S(e,k+10,15)+4,P=M+S(e,k+5,31)+1;k+=14;for(var B=new t(P),G=new t(19),L=0;L<I;++L)G[i[L]]=S(e,k+3*L,7);k+=3*I;var W=x(G),j=(1<<W)-1,z=v(G,W,1);for(L=0;L<P;){var N,V=z[S(e,k,j)];if(k+=15&V,(N=V>>>4)<16)B[L++]=N;else{var X=0,q=0;for(16==N?(q=3+S(e,k,3),k+=2,X=B[L-1]):17==N?(q=3+S(e,k,7),k+=3):18==N&&(q=11+S(e,k,127),k+=7);q--;)B[L++]=X}}var H=B.subarray(0,M),$=B.subarray(M);C=x(H),D=x($),_=v(H,C,1),F=v($,D,1)}else w(1);if(k>A){d&&w(0);break}}h&&g(T+131072);for(var Y=(1<<C)-1,Z=(1<<D)-1,K=k;;K=k){var J=(X=_[U(e,k)&Y])>>>4;if((k+=15&X)>A){d&&w(0);break}if(X||w(2),J<256)s[T++]=J;else{if(256==J){K=k,_=null;break}var Q=J-254;if(J>264){var ee=a[L=J-257];Q=S(e,k,(1<<ee)-1)+u[L],k+=ee}var te=F[U(e,k)&Z],re=te>>>4;if(te||w(3),k+=15&te,$=c[re],re>3&&(ee=o[re],$+=U(e,k)&(1<<ee)-1,k+=ee),k>A){d&&w(0);break}h&&g(T+131072);for(var ne=T+Q;T<ne;T+=4)s[T]=s[T-$],s[T+1]=s[T+1-$],s[T+2]=s[T+2-$],s[T+3]=s[T+3-$];T=ne}}l.l=_,l.p=K,l.b=T,_&&(m=1,l.m=C,l.d=F,l.n=D)}while(!m);return T==s.length?s:function(e,a,o){(null==a||a<0)&&(a=0),(null==o||o>e.length)&&(o=e.length);var i=new(e instanceof r?r:e instanceof n?n:t)(o-a);return i.set(e.subarray(a,o)),i}(s,0,T)},_=new t(0),F="undefined"!=typeof TextDecoder&&new TextDecoder;try{F.decode(_,{stream:!0})}catch(e){}return e.convert_streams=function(e){var t=new DataView(e),r=0;function n(){var e=t.getUint16(r);return r+=2,e}function a(){var e=t.getUint32(r);return r+=4,e}function o(e){m.setUint16(y,e),y+=2}function i(e){m.setUint32(y,e),y+=4}for(var s={signature:a(),flavor:a(),length:a(),numTables:n(),reserved:n(),totalSfntSize:a(),majorVersion:n(),minorVersion:n(),metaOffset:a(),metaLength:a(),metaOrigLength:a(),privOffset:a(),privLength:a()},l=0;Math.pow(2,l)<=s.numTables;)l++;l--;for(var u=16*Math.pow(2,l)
|
||
|
/*!
|
||
|
Custom bundle of @unicode-font-resolver/client v1.0.0 (https://github.com/lojjic/unicode-font-resolver)
|
||
|
for use in Troika text rendering.
|
||
|
Original MIT license applies
|
||
|
*/const R=p({name:"FontResolver",dependencies:[function(e,t){const r=Object.create(null),n=Object.create(null);function a(t,a){let o=r[t];o?a(o):n[t]?n[t].push(a):(n[t]=[a],function(t,r){const n=e=>{console.error(`Failure loading font ${t}`,e)};try{const a=new XMLHttpRequest;a.open("get",t,!0),a.responseType="arraybuffer",a.onload=function(){if(a.status>=400)n(new Error(a.statusText));else if(a.status>0)try{const n=e(a.response);n.src=t,r(n)}catch(e){n(e)}},a.onerror=n,a.send()}catch(e){n(e)}}(t,(e=>{e.src=t,r[t]=e,n[t].forEach((t=>t(e))),delete n[t]})))}return function(e,n,{lang:o,fonts:i=[],style:s="normal",weight:l="normal",unicodeFontsURL:u}={}){const f=new Uint8Array(e.length),c=[];e.length||v();const h=new Map,d=[];if("italic"!==s&&(s="normal"),"number"!=typeof l&&(l="bold"===l?700:400),i&&!Array.isArray(i)&&(i=[i]),(i=i.slice().filter((e=>!e.lang||e.lang.test(o))).reverse()).length){const t=1,n=2;let o=0;!function s(l=0){for(let u=l,p=e.length;u<p;u++){const l=e.codePointAt(u);if(o===t&&c[f[u-1]].supportsCodePoint(l)||/\s/.test(e[u]))f[u]=f[u-1],o===n&&(d[d.length-1][1]=u);else for(let e=f[u],p=i.length;e<=p;e++)if(e===p){(o===n?d[d.length-1]:d[d.length]=[u,u])[1]=u,o=n}else{f[u]=e;const{src:n,unicodeRange:d}=i[e];if(!d||g(l,d)){const e=r[n];if(!e)return void a(n,(()=>{s(u)}));if(e.supportsCodePoint(l)){let r=h.get(e);"number"!=typeof r&&(r=c.length,c.push(e),h.set(e,r)),f[u]=r,o=t;break}}}l>65535&&u+1<p&&(f[u+1]=f[u],u++,o===n&&(d[d.length-1][1]=u))}p()}()}else d.push([0,e.length-1]),p();function p(){if(d.length){const r=d.map((t=>e.substring(t[0],t[1]+1))).join("\n");t.getFontsForString(r,{lang:o,style:s,weight:l,dataUrl:u}).then((({fontUrls:e,chars:t})=>{const r=c.length;let n=0;d.forEach((e=>{for(let a=0,o=e[1]-e[0];a<=o;a++)f[e[0]+a]=t[n++]+r;n++}));let o=0;e.forEach(((t,n)=>{a(t,(t=>{c[n+r]=t,++o===e.length&&v()}))}))}))}else v()}function v(){n({chars:f,fonts:c})}function g(e,t){for(let r=0;r<t.length;r++){const[n,a=n]=t[r];if(n<=e&&e<=a)return!0}return!1}}},O,function(){return function(e){var t=function(){this.buckets=new Map};t.prototype.add=function(e){var t=e>>5;this.buckets.set(t,(this.buckets.get(t)||0)|1<<(31&e))},t.prototype.has=function(e){var t=this.buckets.get(e>>5);return void 0!==t&&0!=(t&1<<(31&e))},t.prototype.serialize=function(){var e=[];return this.buckets.forEach((function(t,r){e.push((+r).toString(36)+":"+t.toString(36))})),e.join(",")},t.prototype.deserialize=function(e){var t=this;this.buckets.clear(),e.split(",").forEach((function(e){var r=e.split(":");t.buckets.set(parseInt(r[0],36),parseInt(r[1],36))}))};var r=Math.pow(2,8),n=r-1,a=~n;function o(e){var t=function(e){return e&a}(e).toString(16),n=function(e){return(e&a)+r-1}(e).toString(16);return"codepoint-index/plane"+(e>>16)+"/"+t+"-"+n+".json"}function i(e,t){var r=e&n,a=t.codePointAt(r/6|0);return 0!=((a=(a||48)-48)&1<<r%6)}function s(e,t){!function(e,t){var r;(r=e,r.replace(/U\+/gi,"").replace(/^,+|,+$/g,"").split(/,+/).map((function(e){return e.split("-").map((function(e){return parseInt(e.trim(),16)}))}))).forEach((function(e){var r=e[0],n=e[1];void 0===n&&(n=r),t(r,n)}))}(e,(function(e,r){for(var n=e;n<=r;n++)t(n)}))}var l={},u={},f=new WeakMap,c="https://cdn.jsdelivr.net/gh/lojjic/unicode-font-resolver@v1.0.0/packages/data";function h(e){var r=f.get(e);return r||(r=new t,s(e.ranges,(function(e){return r.add(e)})),f.set(e,r)),r}var d,p=new Map;function v(e,t,r){return e[t]?t:e[r]?r:function(e){for(var t in e)return t}(e)}function g(e,t){var r=t;if(!e.includes(r)){r=1/0;for(var n=0;n<e.length;n++)Math.abs(e[n]-t)<Math.abs(r-t)&&(r=e[n])}return r}function m(e){return d||(d=new Set,s("9-D,20,85,A0,1680,2000-200A,2028-202F,205F,3000",(function(e){d.add(e)}))),d.has(e)}return e.CodePointSet=t,e.clearCache=function(){l={},u={}},e.getFontsForString=function(e,t){void 0===t&&(t={});var r=t.lang;void 0===r&&(r="en");var n=t.category;void 0===n&&(n="sans-serif");var a=t.style;void 0===a&&(a="normal");var s=t.weight;void 0===s&&(s=400);var f=(t.dataUrl||c).replace(/\/$/g,""),d=new Map,y=new Uint8Array(e.length),b={},x={},S=new Array(
|
||
|
//# sourceMappingURL=aframe-troika-text.min.js.map
|