three-text 0.4.2 → 0.4.3
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/dist/index.cjs +376 -150
- package/dist/index.js +376 -150
- package/dist/index.min.cjs +395 -353
- package/dist/index.min.js +392 -350
- package/dist/index.umd.js +376 -150
- package/dist/index.umd.min.js +480 -438
- package/dist/types/core/cache/GlyphGeometryBuilder.d.ts +3 -0
- package/dist/types/core/geometry/Tessellator.d.ts +4 -0
- package/package.json +1 -1
- package/dist/types/core/layout/LineBreakDelta.d.ts +0 -97
- package/dist/types/core/layout/LineBreakGood.d.ts +0 -100
- package/dist/types/core/layout/LineBreakHashMap.d.ts +0 -103
- package/dist/types/core/layout/LineBreakOriginal.d.ts +0 -103
package/dist/index.umd.min.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* three-text v0.4.
|
|
2
|
+
* three-text v0.4.3
|
|
3
3
|
* Copyright (C) 2025 Countertype LLC
|
|
4
4
|
*
|
|
5
5
|
* This program is free software: you can redistribute it and/or modify
|
|
@@ -57,7 +57,7 @@ this.start(t,i)
|
|
|
57
57
|
try{return e()}finally{this.end(t)}}async T(t,e,i){if(!h)return e()
|
|
58
58
|
this.start(t,i)
|
|
59
59
|
try{return await e()}finally{this.end(t)}}}
|
|
60
|
-
const
|
|
60
|
+
const l=800,c=100,u=0,f=1/3
|
|
61
61
|
var d,y;(t=>{t[t.BOX=0]="BOX",t[t.GLUE=1]="GLUE",t[t.PENALTY=2]="PENALTY",t[t.DISCRETIONARY=3]="DISCRETIONARY"})(d||(d={})),(t=>{t[t.VERY_LOOSE=0]="VERY_LOOSE",t[t.LOOSE=1]="LOOSE",t[t.DECENT=2]="DECENT",t[t.TIGHT=3]="TIGHT"})(y||(y={}))
|
|
62
62
|
class p{constructor(){this.M=new Map,this.I=[]}getKey(t,e){return t<<2|e}F(t){const e=this.getKey(t.position,t.L),i=this.M.get(e)
|
|
63
63
|
return i?i.G>t.G&&(i.G=t.G,i.O=t.O,i.k=t.k,i.line=t.line,i.D=t.D,i.N=t.N,i.U=t.U,!0):(t.active=!0,t.P=this.I.length,this.I.push(t),this.M.set(e,t),!0)}$(t){if(!t.active)return
|
|
@@ -78,56 +78,56 @@ if(!e.children||!e.children[n])break
|
|
|
78
78
|
if(e=e.children[n],e.V)for(let i=0;e.V.length>i;i++){const n=t+i
|
|
79
79
|
h.length>n&&(h[n]=Math.max(h[n],e.V[i]))}}}const a=[]
|
|
80
80
|
for(let t=2;o.length-2>t;t++)h[t]%2==1&&a.push(t-1)
|
|
81
|
-
return a.filter(e=>e>=n&&t.length-e>=s)}static q(t,e,i,n=!1,s="en-us",r,o=S,h=_,a,
|
|
82
|
-
return
|
|
81
|
+
return a.filter(e=>e>=n&&t.length-e>=s)}static q(t,e,i,n=!1,s="en-us",r,o=S,h=_,a,l){const c=[]
|
|
82
|
+
return c.push(...this.Y(t,e,i,n,s,r,o,h,a,l)),c.push({type:d.GLUE,width:0,stretch:1e7,J:0,text:"",K:t.length}),c.push({type:d.PENALTY,width:0,X:E,text:"",K:t.length}),c}static Z(t){const e=t.codePointAt(0)
|
|
83
83
|
return void 0!==e&&(e>=19968&&40959>=e||e>=13312&&19903>=e||e>=131072&&173791>=e||e>=173824&&177983>=e||e>=177984&&178207>=e||e>=178208&&183983>=e||e>=63744&&64255>=e||e>=12352&&12447>=e||e>=12448&&12543>=e||e>=44032&&55215>=e||e>=4352&&4607>=e||e>=12592&&12687>=e||e>=43360&&43391>=e||e>=55216&&55295>=e||e>=65440&&65500>=e)}static tt(t){const e=t.charCodeAt(0)
|
|
84
84
|
return 12289===e||12290===e||65292===e||65294===e||65306===e||65307===e||65281===e||65311===e||65289===e||12305===e||65373===e||12301===e||12303===e||12297===e||12299===e||12309===e||12311===e||12313===e||12315===e||12540===e||8212===e||8230===e||8229===e}static et(t){const e=t.charCodeAt(0)
|
|
85
85
|
return 65288===e||12304===e||65371===e||12300===e||12302===e||12296===e||12298===e||12308===e||12310===e||12312===e||12314===e}static it(t){return this.tt(t)||this.et(t)}static nt(t,e,i,n,s=0,r){const o=[],h=Array.from(t),a=i?i(t):null
|
|
86
|
-
let c,
|
|
87
|
-
if(r)
|
|
86
|
+
let l,c,u,y=s
|
|
87
|
+
if(r)l=r.width,c=r.stretch,u=r.J
|
|
88
88
|
else{const t=e("字")
|
|
89
|
-
|
|
89
|
+
l=0,c=.04*t,u=.04*t}for(let t=0;h.length>t;t++){const i=h[t],n=h.length-1>t?h[t+1]:null
|
|
90
90
|
if(/\s/.test(i)){const n=a?a[t]??e(i):e(i)
|
|
91
91
|
o.push({type:d.GLUE,width:n,stretch:.5*n,J:n*f,text:i,K:y}),y+=i.length
|
|
92
92
|
continue}if(o.push({type:d.BOX,width:a?a[t]??e(i):e(i),text:i,K:y}),y+=i.length,n&&!/\s/.test(n)){let t=!0
|
|
93
93
|
this.tt(n)&&(t=!1),this.et(i)&&(t=!1)
|
|
94
94
|
const e=this.it(i)&&this.it(n)
|
|
95
|
-
t&&!e&&o.push({type:d.GLUE,width:
|
|
95
|
+
t&&!e&&o.push({type:d.GLUE,width:l,stretch:c,J:u,text:"",K:y})}}return o}static Y(t,e,i,n,s,r,o,h,a,l){const c=[],u=Array.from(t)
|
|
96
96
|
let f,d="",y=0,p=null,w=0
|
|
97
|
-
const g=()=>{0!==d.length&&("cjk"===p?
|
|
98
|
-
f={width:0,stretch:.04*t,J:.04*t}}return f})())):
|
|
97
|
+
const g=()=>{0!==d.length&&("cjk"===p?c.push(...this.nt(d,e,i,a,y,(()=>{if(!f){const t=e("字")
|
|
98
|
+
f={width:0,stretch:.04*t,J:.04*t}}return f})())):c.push(...this.st(d,y,e,n,s,r,o,h,a,l)),d="",p=null)}
|
|
99
99
|
for(let t=0;u.length>t;t++){const e=u[t],i=this.Z(e)?"cjk":"word"
|
|
100
|
-
null!==p&&p!==i&&(g(),y=w),null===p&&(p=i,y=w),d+=e,w+=e.length}return g(),
|
|
100
|
+
null!==p&&p!==i&&(g(),y=w),null===p&&(p=i,y=w),d+=e,w+=e.length}return g(),c}static st(t,e,i,n,s,r,o,h,a,l){const c=[],u=t.match(/\S+|\s+/g)||[]
|
|
101
101
|
let y=0
|
|
102
102
|
for(const t of u){const u=e+y
|
|
103
103
|
if(/\s+/.test(t)){const e=i(t)
|
|
104
|
-
|
|
104
|
+
c.push({type:d.GLUE,width:e,stretch:.5*e,J:e*f,text:t,K:u}),y+=t.length}else{const e=t.split(/(-)/)
|
|
105
105
|
let f=u
|
|
106
|
-
for(const t of e)if(t){if("-"===t)
|
|
106
|
+
for(const t of e)if(t){if("-"===t)c.push({type:d.DISCRETIONARY,width:i("-"),rt:"-",ot:"",ht:"-",lt:i("-"),X:a?.ct??g,ut:!0,text:"-",K:f}),f+=1
|
|
107
107
|
else if(t.includes("")){const e=t.split("")
|
|
108
108
|
let n=0
|
|
109
109
|
for(let t=0;e.length>t;t++){const s=e[t]
|
|
110
|
-
s.length>0&&(
|
|
110
|
+
s.length>0&&(c.push({type:d.BOX,width:i(s),text:s,K:f+n}),n+=s.length),e.length-1>t&&(c.push({type:d.DISCRETIONARY,width:0,rt:"-",ot:"",ht:"",lt:i("-"),X:a?.ft??w,ut:!0,text:"",K:f+n}),n+=1)}}else if(n&&t.length>=o+h&&/^\p{L}+$/u.test(t)){const e=this.H(t,s,r,o,h)
|
|
111
111
|
if(e.length>0){let n=0
|
|
112
112
|
for(const s of e){const e=t.substring(n,s)
|
|
113
|
-
|
|
114
|
-
if(
|
|
115
|
-
for(let t=0;e.length>t;t++)
|
|
116
|
-
if(
|
|
117
|
-
for(let t=0;e.length>t;t++)
|
|
113
|
+
c.push({type:d.BOX,width:i(e),text:e,K:f+n}),c.push({type:d.DISCRETIONARY,width:0,rt:"-",ot:"",ht:"",lt:i("-"),X:a?.ft??w,ut:!0,text:"",K:f+s}),n=s}c.push({type:d.BOX,width:i(t.substring(n)),text:t.substring(n),K:f+n})}else{const e=i(t)
|
|
114
|
+
if(l&&e>l){const e=Array.from(t)
|
|
115
|
+
for(let t=0;e.length>t;t++)c.push({type:d.BOX,width:i(e[t]),text:e[t],K:f+t}),e.length-1>t&&c.push({type:d.PENALTY,width:0,X:5e3,K:f+t+1})}else c.push({type:d.BOX,width:e,text:t,K:f})}}else{const e=i(t)
|
|
116
|
+
if(l&&e>l){const e=Array.from(t)
|
|
117
|
+
for(let t=0;e.length>t;t++)c.push({type:d.BOX,width:i(e[t]),text:e[t],K:f+t}),e.length-1>t&&c.push({type:d.PENALTY,width:0,X:5e3,K:f+t+1})}else c.push({type:d.BOX,width:e,text:t,K:f})}f+=t.length}y+=t.length}}return c}static lineBreak(t,e,i,n,s){const r=new p
|
|
118
118
|
r.F({position:0,line:0,L:y.DECENT,G:0,O:null,k:!1,active:!0,P:0,D:0,N:0,U:0})
|
|
119
119
|
let o=0,h=0,a=0
|
|
120
|
-
for(let
|
|
121
|
-
if(!(
|
|
122
|
-
continue}let u=0,f=!1;(
|
|
120
|
+
for(let l=0;t.length>l;l++){const c=t[l]
|
|
121
|
+
if(!(c.type===d.PENALTY&&1e4>c.X||c.type===d.DISCRETIONARY||c.type===d.GLUE&&l>0&&t[l-1].type===d.BOX)){c.type===d.BOX?o+=c.width:c.type===d.GLUE?(o+=c.width,h+=c.stretch,a+=c.J):c.type===d.DISCRETIONARY&&(o+=c.width)
|
|
122
|
+
continue}let u=0,f=!1;(c.type===d.PENALTY||c.type===d.DISCRETIONARY)&&(u=c.X,f=c.ut||!1)
|
|
123
123
|
let y=0
|
|
124
|
-
|
|
124
|
+
c.type===d.DISCRETIONARY&&(y=c.lt)
|
|
125
125
|
const p=[null,null,null,null],w=[1/0,1/0,1/0,1/0],g=[],v=r.W()
|
|
126
|
-
for(let t=0;v.length>t;t++){const r=v[t],
|
|
126
|
+
for(let t=0;v.length>t;t++){const r=v[t],c=h-r.N,d=a-r.U,m=e-(o-r.D+y)
|
|
127
127
|
let x
|
|
128
|
-
if(m>0){const t=
|
|
128
|
+
if(m>0){const t=c+n
|
|
129
129
|
x=t>0?m/t:1/0}else x=0>m?d>0?m/d:-1/0:0
|
|
130
|
-
const b=this.R(m,m>0?
|
|
130
|
+
const b=this.R(m,m>0?c+n:d)
|
|
131
131
|
if(-1>x){g.push(r)
|
|
132
132
|
continue}if(u!==E&&b>i)continue
|
|
133
133
|
let S=s.dt+b
|
|
@@ -135,13 +135,13 @@ let S=s.dt+b
|
|
|
135
135
|
const _=this.j(x)
|
|
136
136
|
Math.abs(_-r.L)>1&&(S+=s.wt)
|
|
137
137
|
const T=r.G+S
|
|
138
|
-
w[_]>T&&(w[_]=T,p[_]={position:
|
|
138
|
+
w[_]>T&&(w[_]=T,p[_]={position:l,line:r.line+1,L:_,G:T,O:r,k:f,active:!0,P:-1,D:o,N:h,U:a})}for(const t of g)r.$(t)
|
|
139
139
|
for(let t=0;4>t;t++)p[t]&&r.F(p[t])
|
|
140
140
|
if(0===r.size()&&u!==E)return null
|
|
141
|
-
|
|
142
|
-
for(const t of r.W())
|
|
143
|
-
return
|
|
144
|
-
const{text:e,width:i,align:n="left",direction:s="ltr",vt:r=!1,language:o="en-us",xt:h=!0,measureText:f,bt:d,St:y,_t:p,letterSpacing:E=0,Et:T=
|
|
141
|
+
c.type===d.BOX?o+=c.width:c.type===d.GLUE?(o+=c.width,h+=c.stretch,a+=c.J):c.type===d.DISCRETIONARY&&(o+=c.width)}let l=null,c=1/0
|
|
142
|
+
for(const t of r.W())c>t.G&&(c=t.G,l=t)
|
|
143
|
+
return l}static gt(t){if(!t.text||0===t.text.length)return[]
|
|
144
|
+
const{text:e,width:i,align:n="left",direction:s="ltr",vt:r=!1,language:o="en-us",xt:h=!0,measureText:f,bt:d,St:y,_t:p,letterSpacing:E=0,Et:T=l,Tt:A=c,At:M=u,Mt:I,It:F=S,Ft:L=_,Lt:G=x,Gt:O=b,Ot:C=w,Ct:k=g,kt:D=v,Dt:B=m}=t
|
|
145
145
|
if(h&&e.includes("\n")){const i=e.split("\n"),n=[]
|
|
146
146
|
let s=0
|
|
147
147
|
for(const e of i){if(0===e.length)n.push({text:"",Bt:s,Nt:s,Ut:0,Pt:!0,naturalWidth:0,$t:!1})
|
|
@@ -150,7 +150,7 @@ i.forEach(t=>{t.Bt+=s,t.Nt+=s}),n.push(...i)}s+=e.length+1}return n}let N=r
|
|
|
150
150
|
!N||y&&y[o]||(a.warn(`Hyphenation patterns for ${o} not available`),N=!1)
|
|
151
151
|
let U=M
|
|
152
152
|
void 0!==I&&i&&(U=i*I)
|
|
153
|
-
const P={dt:G,wt:O,yt:D,zt:B,ft:
|
|
153
|
+
const P={dt:G,wt:O,yt:D,zt:B,ft:C,ct:k,Wt:n,_t:p,Rt:p?E*p:0}
|
|
154
154
|
if(!i||i===1/0){const t=f(e)
|
|
155
155
|
return[{text:e,Bt:0,Nt:e.length-1,Ut:0,Pt:!0,naturalWidth:t,$t:!1}]}let $=this.q(e,f,d,!1,o,y,F,L,P,i),z=this.lineBreak($,i,A,0,P)
|
|
156
156
|
if(!z&&N&&($=this.q(e,f,d,!0,o,y,F,L,P,i),z=this.lineBreak($,i,T,0,P)),!z){const t=5
|
|
@@ -161,27 +161,27 @@ for(;r&&r.position>0;)t.unshift(r.position),r=r.O
|
|
|
161
161
|
return this.jt(e,$,t,i,n,s,P)}return[{text:e,Bt:0,Nt:e.length-1,Ut:0,Ht:0,Pt:!0,naturalWidth:f(e),$t:!1}]}static jt(t,e,i,n,s,r,o){if(0===i.length)return[{text:t,Bt:0,Nt:t.length-1,Ut:0}]
|
|
162
162
|
const h=[]
|
|
163
163
|
let a=0
|
|
164
|
-
for(let t=0;i.length>t;t++){const
|
|
164
|
+
for(let t=0;i.length>t;t++){const l=i[t],c=!(e.length-1>i[i.length-1]+1)&&t===i.length-1,u=[]
|
|
165
165
|
let f=-1,y=-1,p=0,w=0,g=0
|
|
166
|
-
for(let t=a;
|
|
166
|
+
for(let t=a;l>t;t++){const i=e[t]
|
|
167
167
|
if((i.type!==d.PENALTY||i.text)&&(i.type!==d.DISCRETIONARY||i.ht)){if(void 0!==i.K){(-1===f||f>i.K)&&(f=i.K)
|
|
168
168
|
const t=i.K+(i.text?i.text.length:0)-1
|
|
169
|
-
t>y&&(y=t)}i.text?u.push(i.text):i.type===d.DISCRETIONARY&&i.ht&&u.push(i.ht),p+=i.width,i.type===d.GLUE&&(w+=i.stretch,g+=i.J)}}const v=e[
|
|
169
|
+
t>y&&(y=t)}i.text?u.push(i.text):i.type===d.DISCRETIONARY&&i.ht&&u.push(i.ht),p+=i.width,i.type===d.GLUE&&(w+=i.stretch,g+=i.J)}}const v=e[l]
|
|
170
170
|
let m=!1
|
|
171
|
-
if(e.length>
|
|
171
|
+
if(e.length>l)if(v.type===d.PENALTY&&v.ut)u.push("-"),p+=v.width,m=!0,void 0!==v.K&&(y=v.K-1)
|
|
172
172
|
else if(v.type===d.DISCRETIONARY){const t=v
|
|
173
|
-
t.rt&&(u.push(t.rt),p+=t.
|
|
173
|
+
t.rt&&(u.push(t.rt),p+=t.lt,m=t.ut||!1,void 0!==v.K&&(y=v.K-1))}const x=u.join("")
|
|
174
174
|
o?.Rt&&0!==p&&(p-=o.Rt)
|
|
175
175
|
let b=0,S=0,_=s
|
|
176
|
-
if("justify"===s&&
|
|
176
|
+
if("justify"===s&&c&&(_="rtl"===r?"right":"left"),"center"===_)b=(n-p)/2
|
|
177
177
|
else if("right"===_)b=n-p
|
|
178
|
-
else if("justify"===_&&!
|
|
179
|
-
t>0&&w>0?S=t/w:0>t&&g>0&&(S=t/g)}h.push({text:x,Bt:f,Nt:y,Ut:b,Ht:S,Pt:!1,naturalWidth:p,$t:m}),a=
|
|
180
|
-
let i=-1,
|
|
178
|
+
else if("justify"===_&&!c){const t=n-p
|
|
179
|
+
t>0&&w>0?S=t/w:0>t&&g>0&&(S=t/g)}h.push({text:x,Bt:f,Nt:y,Ut:b,Ht:S,Pt:!1,naturalWidth:p,$t:m}),a=l+1}if(e.length-1>a){const t=[]
|
|
180
|
+
let i=-1,l=-1,c=0
|
|
181
181
|
for(let n=a;e.length-1>n;n++){const s=e[n]
|
|
182
|
-
s.type!==d.PENALTY&&(void 0!==s.K&&((-1===i||i>s.K)&&(i=s.K),s.K>
|
|
182
|
+
s.type!==d.PENALTY&&(void 0!==s.K&&((-1===i||i>s.K)&&(i=s.K),s.K>l&&(l=s.K)),s.text&&t.push(s.text),c+=s.width)}o?.Rt&&0!==c&&(c-=o.Rt)
|
|
183
183
|
let u=0,f=s
|
|
184
|
-
"justify"===s&&(f="rtl"===r?"right":"left"),"center"===f?u=(n-
|
|
184
|
+
"justify"===s&&(f="rtl"===r?"right":"left"),"center"===f?u=(n-c)/2:"right"===f&&(u=n-c),h.push({text:t.join(""),Bt:i,Nt:l,Ut:u,Ht:0,Pt:!0,naturalWidth:c,$t:!1}),h.length>1&&(h[h.length-2].Pt=!1),h[h.length-1].Pt=!0}else h.length>0&&(h[h.length-1].Pt=!0)
|
|
185
185
|
return h}}const A=new WeakMap
|
|
186
186
|
class M{static bt(t,i,n=0){const s=Array.from(i)
|
|
187
187
|
if(0===s.length)return[]
|
|
@@ -192,20 +192,20 @@ const h=Array(s.length).fill(0),a=t.hb.createBuffer()
|
|
|
192
192
|
try{a.Vt(i),a.qt()
|
|
193
193
|
const s=e(t.Yt)
|
|
194
194
|
t.hb.shape(t.font,a,s)
|
|
195
|
-
const o=a.json(t.font),
|
|
195
|
+
const o=a.json(t.font),l=n*t.upem
|
|
196
196
|
for(let t=0;o.length>t;t++){const e=o[t],i=e.Jt??0
|
|
197
197
|
let n=r.get(i)
|
|
198
198
|
if(void 0===n)for(let t=i;t>=0;t--){const e=r.get(t)
|
|
199
199
|
if(void 0!==e){n=e
|
|
200
|
-
break}}void 0!==n&&(h[n]+=e.ax,0!==
|
|
200
|
+
break}}void 0!==n&&(h[n]+=e.ax,0!==l&&(h[n]+=l))}return h}finally{a.destroy()}}static measureTextWidth(t,i,n=0){const s=t.hb.createBuffer()
|
|
201
201
|
s.Vt(i),s.qt()
|
|
202
202
|
const r=e(t.Yt)
|
|
203
203
|
t.hb.shape(t.font,s,r)
|
|
204
204
|
const o=s.json(t.font),h=n*t.upem
|
|
205
205
|
let a=0
|
|
206
|
-
return o.forEach(t=>{a+=t.ax,0!==h&&(a+=h)}),s.destroy(),a}}class I{constructor(t){this.Kt=t}Qt(t){const{text:e,width:i,align:n,direction:s,vt:r,language:o,xt:h,Et:a,Tt:
|
|
206
|
+
return o.forEach(t=>{a+=t.ax,0!==h&&(a+=h)}),s.destroy(),a}}class I{constructor(t){this.Kt=t}Qt(t){const{text:e,width:i,align:n,direction:s,vt:r,language:o,xt:h,Et:a,Tt:l,At:c,Mt:u,St:f,It:d,Ft:y,Lt:p,Gt:w,Ot:g,Ct:v,kt:m,letterSpacing:x}=t
|
|
207
207
|
let b
|
|
208
|
-
if(i)b=T.gt({text:e,width:i,align:n,direction:s,vt:r,language:o,xt:h,Et:a,Tt:
|
|
208
|
+
if(i)b=T.gt({text:e,width:i,align:n,direction:s,vt:r,language:o,xt:h,Et:a,Tt:l,At:c,Mt:u,St:f,It:d,Ft:y,Lt:p,Gt:w,Ot:g,Ct:v,kt:m,_t:this.Kt.upem,letterSpacing:x,measureText:t=>M.measureTextWidth(this.Kt,t,x),bt:t=>M.bt(this.Kt,t,x)})
|
|
209
209
|
else{const t=e.split("\n")
|
|
210
210
|
b=[]
|
|
211
211
|
let i=0
|
|
@@ -214,33 +214,33 @@ if(0!==i)for(let e=0;t.length>e;e+=3)t[e]+=i
|
|
|
214
214
|
return{offset:i,Zt:n}}te(t){const{width:e,align:i,planeBounds:n}=t
|
|
215
215
|
let s=0
|
|
216
216
|
const r={min:{...n.min},max:{...n.max}}
|
|
217
|
-
return!e||"center"!==i&&"right"!==i||(s="center"===i?(e-(n.max.x-n.min.x))/2-n.min.x:e-n.max.x),0!==s&&(r.min.x+=s,r.max.x+=s),{offset:s,Zt:r}}}const F=65536,L=1330926671,G=2001684038,O=1751474532,
|
|
217
|
+
return!e||"center"!==i&&"right"!==i||(s="center"===i?(e-(n.max.x-n.min.x))/2-n.min.x:e-n.max.x),0!==s&&(r.min.x+=s,r.max.x+=s),{offset:s,Zt:r}}}const F=65536,L=1330926671,G=2001684038,O=1751474532,C=1751672161,k=1330851634,D=1719034226,B=1398030676,N=1851878757,U=1128678944,P=1128678962,$=1196643650,z=1196445523,W=new TextDecoder("utf-16be")
|
|
218
218
|
class R{static ee(t){if(!t||12>t.byteLength)throw Error("Invalid font buffer: too small to be a valid font file")
|
|
219
219
|
const e=new DataView(t),n=e.getUint32(0)
|
|
220
220
|
if(![F,L].includes(n))throw Error("Invalid font format. Expected TTF/OTF (or WOFF), got signature: 0x"+n.toString(16))
|
|
221
|
-
const s=i(e),r=s.has(U)||s.has(P),o=s.get(O)?.offset??0,h=s.get(
|
|
221
|
+
const s=i(e),r=s.has(U)||s.has(P),o=s.get(O)?.offset??0,h=s.get(C)?.offset??0,a=s.get(k)?.offset??0,l=s.get(D)?.offset??0,c=s.get(B)?.offset??0,u=s.get(N)?.offset??0,f=o?e.getUint16(o+18):1e3
|
|
222
222
|
let d=null
|
|
223
223
|
h&&(d={ie:e.getInt16(h+4),ne:e.getInt16(h+6),se:e.getInt16(h+8)})
|
|
224
224
|
let y=null
|
|
225
|
-
a&&(y={re:e.getInt16(a+68),oe:e.getInt16(a+70),he:e.getInt16(a+72),ae:e.getUint16(a+74),
|
|
225
|
+
a&&(y={re:e.getInt16(a+68),oe:e.getInt16(a+70),he:e.getInt16(a+72),ae:e.getUint16(a+74),le:e.getUint16(a+76)})
|
|
226
226
|
let p=null
|
|
227
|
-
return c&&
|
|
227
|
+
return l&&c&&u&&(p=this.ce(e,c,u)),{ue:r,_t:f,fe:d?.ie||null,de:d?.ne||null,ye:d?.se||null,re:y?.re||null,oe:y?.oe||null,he:y?.he||null,ae:y?.ae||null,le:y?.le||null,pe:p}}static we(t){const e=new DataView(t),n=i(e),s=n.get($)?.offset??0,r=n.get(z)?.offset??0,o=n.get(N)?.offset??0,h=new Set,a={}
|
|
228
228
|
try{if(s){const t=this.ge(e,s,o)
|
|
229
229
|
t.features.forEach(t=>h.add(t)),Object.assign(a,t.names)}if(r){const t=this.ge(e,r,o)
|
|
230
|
-
t.features.forEach(t=>h.add(t)),Object.assign(a,t.names)}}catch(t){return}const
|
|
231
|
-
if(0!==
|
|
230
|
+
t.features.forEach(t=>h.add(t)),Object.assign(a,t.names)}}catch(t){return}const l=Array.from(h).sort()
|
|
231
|
+
if(0!==l.length)return{tags:l,names:Object.keys(a).length>0?a:{}}}static ge(t,e,i){const n=e+t.getUint16(e+6),s=t.getUint16(n),r=[],o={}
|
|
232
232
|
for(let e=0;s>e;e++){const s=n+2+6*e,h=String.fromCharCode(t.getUint8(s),t.getUint8(s+1),t.getUint8(s+2),t.getUint8(s+3))
|
|
233
233
|
if(r.push(h),/^(ss\d{2}|cv\d{2})$/.test(h)&&i){const e=n+t.getUint16(s+4),r=t.getUint16(e)
|
|
234
234
|
if(0!==r){const n=e+r
|
|
235
235
|
if(0===t.getUint16(n)){const e=t.getUint16(n+2),s=this.ve(t,i,e)
|
|
236
|
-
s&&(o[h]=s)}}}}return{features:r,names:o}}static
|
|
236
|
+
s&&(o[h]=s)}}}}return{features:r,names:o}}static ce(t,e,i){try{if(1>t.getUint16(e))return null
|
|
237
237
|
const n=t.getUint16(e+4),s=t.getUint16(e+6),r=t.getUint32(e+8),o={}
|
|
238
|
-
for(let h=0;s>h;h++){const s=e+r+h*n,a=String.fromCharCode(t.getUint8(s),t.getUint8(s+1),t.getUint8(s+2),t.getUint8(s+3)),
|
|
239
|
-
|
|
240
|
-
for(let r=0;n>r;r++){const n=e+6+12*r,o=t.getUint16(n),h=t.getUint16(n+2),a=t.getUint16(n+4),
|
|
241
|
-
if(
|
|
238
|
+
for(let h=0;s>h;h++){const s=e+r+h*n,a=String.fromCharCode(t.getUint8(s),t.getUint8(s+1),t.getUint8(s+2),t.getUint8(s+3)),l=t.getUint16(s+4),c=this.ve(t,i,l)
|
|
239
|
+
c&&(o[a]=c)}return Object.keys(o).length>0?o:null}catch(t){return null}}static ve(t,e,i){try{const n=t.getUint16(e+2),s=t.getUint16(e+4)
|
|
240
|
+
for(let r=0;n>r;r++){const n=e+6+12*r,o=t.getUint16(n),h=t.getUint16(n+2),a=t.getUint16(n+4),l=t.getUint16(n+6),c=t.getUint16(n+8),u=t.getUint16(n+10)
|
|
241
|
+
if(l!==i)continue
|
|
242
242
|
if(0!==o&&(3!==o||1033!==a))continue
|
|
243
|
-
const f=new Uint8Array(t.buffer,e+s+u,
|
|
243
|
+
const f=new Uint8Array(t.buffer,e+s+u,c)
|
|
244
244
|
if(0===o||3===o&&1===h){let t=""
|
|
245
245
|
for(let e=0;f.length>e;e+=2)t+=String.fromCharCode(f[e]<<8|f[e+1])
|
|
246
246
|
return t}return new TextDecoder("ascii").decode(f)}return null}catch(t){return null}}static me(t){if(!t||12>t.byteLength)throw Error("Invalid font buffer: too small to be a valid font file")
|
|
@@ -248,37 +248,37 @@ const e=new DataView(t),n=e.getUint32(0)
|
|
|
248
248
|
if(![F,L].includes(n))throw Error("Invalid font format. Expected TTF/OTF (or WOFF), got signature: 0x"+n.toString(16))
|
|
249
249
|
const s=i(e),r=s.get(N)?.offset??0,o=r?this.xe(e,r):null
|
|
250
250
|
return{h:this.be(e,s,o),features:this.Se(e,s,o)}}static xe(t,e){const i=new Map,n=t.getUint16(e+2),s=t.getUint16(e+4)
|
|
251
|
-
for(let r=0;n>r;r++){const n=e+6+12*r,o=t.getUint16(n),h=t.getUint16(n+2),a=t.getUint16(n+4),
|
|
251
|
+
for(let r=0;n>r;r++){const n=e+6+12*r,o=t.getUint16(n),h=t.getUint16(n+2),a=t.getUint16(n+4),l=t.getUint16(n+6),c=t.getUint16(n+8),u=t.getUint16(n+10);(0===o||3===o&&1033===a)&&(i.has(l)||i.set(l,{offset:e+s+u,length:c,_e:o,Ee:h}))}return i}static Te(t,e,i){if(!e)return null
|
|
252
252
|
const n=e.get(i)
|
|
253
253
|
if(!n)return null
|
|
254
254
|
try{const e=new Uint8Array(t.buffer,n.offset,n.length)
|
|
255
|
-
return 0===n._e||3===n._e&&1===n.Ee?W.decode(e):new TextDecoder("ascii").decode(e)}catch{return null}}static be(t,e,i){const n=e.has(U)||e.has(P),s=e.get(O)?.offset??0,r=e.get(
|
|
256
|
-
let
|
|
257
|
-
r&&(
|
|
255
|
+
return 0===n._e||3===n._e&&1===n.Ee?W.decode(e):new TextDecoder("ascii").decode(e)}catch{return null}}static be(t,e,i){const n=e.has(U)||e.has(P),s=e.get(O)?.offset??0,r=e.get(C)?.offset??0,o=e.get(k)?.offset??0,h=e.get(D)?.offset??0,a=e.get(B)?.offset??0,l=s?t.getUint16(s+18):1e3
|
|
256
|
+
let c=null
|
|
257
|
+
r&&(c={ie:t.getInt16(r+4),ne:t.getInt16(r+6),se:t.getInt16(r+8)})
|
|
258
258
|
let u=null
|
|
259
|
-
o&&(u={re:t.getInt16(o+68),oe:t.getInt16(o+70),he:t.getInt16(o+72),ae:t.getUint16(o+74),
|
|
259
|
+
o&&(u={re:t.getInt16(o+68),oe:t.getInt16(o+70),he:t.getInt16(o+72),ae:t.getUint16(o+74),le:t.getUint16(o+76)})
|
|
260
260
|
let f=null
|
|
261
|
-
return h&&a&&i&&(f=this.Ae(t,a,i)),{ue:n,_t:
|
|
261
|
+
return h&&a&&i&&(f=this.Ae(t,a,i)),{ue:n,_t:l,fe:c?.ie||null,de:c?.ne||null,ye:c?.se||null,re:u?.re||null,oe:u?.oe||null,he:u?.he||null,ae:u?.ae||null,le:u?.le||null,pe:f}}static Ae(t,e,i){try{if(1>t.getUint16(e))return null
|
|
262
262
|
const n=t.getUint16(e+4),s=t.getUint16(e+6),r=t.getUint32(e+8),o={}
|
|
263
|
-
for(let h=0;s>h;h++){const s=e+r+h*n,a=String.fromCharCode(t.getUint8(s),t.getUint8(s+1),t.getUint8(s+2),t.getUint8(s+3)),
|
|
264
|
-
|
|
263
|
+
for(let h=0;s>h;h++){const s=e+r+h*n,a=String.fromCharCode(t.getUint8(s),t.getUint8(s+1),t.getUint8(s+2),t.getUint8(s+3)),l=t.getUint16(s+4),c=this.Te(t,i,l)
|
|
264
|
+
c&&(o[a]=c)}return Object.keys(o).length>0?o:null}catch{return null}}static Se(t,e,i){const n=e.get($)?.offset??0,s=e.get(z)?.offset??0,r=new Set,o={}
|
|
265
265
|
try{n&&this.Me(t,n,i,r,o),s&&this.Me(t,s,i,r,o)}catch{return}if(0!==r.size)return{tags:Array.from(r).sort((t,e)=>t-e).map(this.Ie),names:Object.keys(o).length>0?o:{}}}static Me(t,e,i,n,s){const r=e+t.getUint16(e+6),o=t.getUint16(r)
|
|
266
266
|
for(let e=0;o>e;e++){const o=r+2+6*e,h=t.getUint32(o)
|
|
267
267
|
n.add(h)
|
|
268
268
|
const a=h>>16&65535
|
|
269
269
|
if(!i)continue
|
|
270
270
|
if(29555!==a&&25462!==a)continue
|
|
271
|
-
const
|
|
272
|
-
if(48>
|
|
271
|
+
const l=h>>8&255,c=255&h
|
|
272
|
+
if(48>l||l>57||48>c||c>57)continue
|
|
273
273
|
const u=r+t.getUint16(o+4),f=t.getUint16(u)
|
|
274
274
|
if(0===f)continue
|
|
275
275
|
const d=u+f
|
|
276
276
|
if(0!==t.getUint16(d))continue
|
|
277
277
|
const y=t.getUint16(d+2),p=this.Te(t,i,y)
|
|
278
|
-
p&&(s[String.fromCharCode(h>>24&255,h>>16&255,h>>8&255,255&h)]=p)}}static Ie(t){return String.fromCharCode(t>>24&255,t>>16&255,t>>8&255,255&t)}static Fe(t){return null!==t.re&&null!==t.oe?{ie:t.re,ne:t.oe,se:0}:null!==t.fe&&null!==t.de?{ie:t.fe,ne:t.de,se:0}:null!==t.ae&&null!==t.
|
|
278
|
+
p&&(s[String.fromCharCode(h>>24&255,h>>16&255,h>>8&255,255&h)]=p)}}static Ie(t){return String.fromCharCode(t>>24&255,t>>16&255,t>>8&255,255&t)}static Fe(t){return null!==t.re&&null!==t.oe?{ie:t.re,ne:t.oe,se:0}:null!==t.fe&&null!==t.de?{ie:t.fe,ne:t.de,se:0}:null!==t.ae&&null!==t.le?{ie:t.ae,ne:-t.le,se:0}:{ie:Math.round(.8*t._t),ne:-Math.round(.2*t._t),se:0}}static Le(t){const e=R.Fe(t)
|
|
279
279
|
return{ie:e.ie,ne:e.ne,se:e.se,_t:t._t,Ge:e.ie-e.ne}}}class j{static Oe(t){if(4>t.byteLength)return"ttf/otf"
|
|
280
280
|
const e=new DataView(t).getUint32(0)
|
|
281
|
-
return e===G?"woff":2001684018===e?"woff2":"ttf/otf"}static async
|
|
281
|
+
return e===G?"woff":2001684018===e?"woff2":"ttf/otf"}static async Ce(t){const e=new DataView(t),i=new Uint8Array(t)
|
|
282
282
|
if(e.getUint32(0)!==G)throw Error("Not a valid WOFF font")
|
|
283
283
|
const n=e.getUint32(4),s=e.getUint16(12),r=e.getUint32(16)
|
|
284
284
|
if("undefined"==typeof DecompressionStream)throw Error("WOFF fonts require DecompressionStream API (Chrome 80+, Firefox 113+, Safari 16.4+). Please use TTF/OTF fonts or upgrade your browser.")
|
|
@@ -286,29 +286,29 @@ const o=new Uint8Array(r),h=new DataView(o.buffer)
|
|
|
286
286
|
h.setUint32(0,n),h.setUint16(4,s)
|
|
287
287
|
const a=2**Math.floor(Math.log2(s))*16
|
|
288
288
|
h.setUint16(6,a),h.setUint16(8,Math.floor(Math.log2(s))),h.setUint16(10,16*s-a)
|
|
289
|
-
let
|
|
290
|
-
const
|
|
289
|
+
let l=12+16*s
|
|
290
|
+
const c=[]
|
|
291
291
|
for(let t=0;s>t;t++){const i=44+20*t
|
|
292
|
-
|
|
293
|
-
const u=await Promise.all(
|
|
292
|
+
c.push({tag:e.getUint32(i),offset:e.getUint32(i+4),length:e.getUint32(i+8),ke:e.getUint32(i+12),t:e.getUint32(i+16)})}c.sort((t,e)=>t.tag-e.tag)
|
|
293
|
+
const u=await Promise.all(c.map(async t=>{if(t.length===t.ke)return i.subarray(t.offset,t.offset+t.length)
|
|
294
294
|
const e=i.subarray(t.offset,t.offset+t.length),n=await j.De(e)
|
|
295
|
-
if(n.byteLength!==t.
|
|
295
|
+
if(n.byteLength!==t.ke)throw Error(`Decompression failed: expected ${t.ke} bytes, got ${n.byteLength}`)
|
|
296
296
|
return new Uint8Array(n)}))
|
|
297
|
-
for(let t=0;s>t;t++){const e=
|
|
298
|
-
h.setUint32(i,e.tag),h.setUint32(i+4,e.t),h.setUint32(i+8,
|
|
297
|
+
for(let t=0;s>t;t++){const e=c[t],i=12+16*t
|
|
298
|
+
h.setUint32(i,e.tag),h.setUint32(i+4,e.t),h.setUint32(i+8,l),h.setUint32(i+12,e.ke),o.set(u[t],l),l+=e.ke,l+=(4-e.ke%4)%4}return o.buffer.slice(0,l)}static async De(t){const e=new ReadableStream({start(e){e.enqueue(t),e.close()}}).pipeThrough(new DecompressionStream("deflate"))
|
|
299
299
|
return new Response(e).arrayBuffer()}}class H{constructor(t){this.Be=t}async Ne(t,e){if(!t||12>t.byteLength)throw Error("Invalid font buffer: too small to be a valid font file")
|
|
300
300
|
const i=j.Oe(t)
|
|
301
|
-
if("woff"===i)t=await j.
|
|
301
|
+
if("woff"===i)t=await j.Ce(t)
|
|
302
302
|
else if("woff2"===i)throw Error("WOFF2 fonts are not yet supported. Please use WOFF or TTF/OTF format.")
|
|
303
303
|
const n=new DataView(t).getUint32(0)
|
|
304
304
|
if(![F,L].includes(n))throw Error("Invalid font format. Expected TTF/OTF (or WOFF), got signature: 0x"+n.toString(16))
|
|
305
305
|
const{hb:s,module:r}=await this.Be()
|
|
306
306
|
try{const i=s.Ue(new Uint8Array(t)),n=s.Pe(i,0),o=s.$e(n)
|
|
307
307
|
e&&o.ze(e)
|
|
308
|
-
const h=n.We(),a=Object.keys(h).length>0,{h:
|
|
308
|
+
const h=n.We(),a=Object.keys(h).length>0,{h:l,features:c}=R.me(t)
|
|
309
309
|
let u
|
|
310
310
|
if(a&&h){u={}
|
|
311
|
-
for(const[t,e]of Object.entries(h))u[t]={...e,name:
|
|
311
|
+
for(const[t,e]of Object.entries(h))u[t]={...e,name:l.pe?.[t]||null}}return{hb:s,fontBlob:i,face:n,font:o,module:r,upem:l._t,h:l,Re:e,je:a,He:u,Ve:c?.tags,qe:c?.names,Ye:t}}catch(t){throw a.error("Failed to load font:",t),t}}static Je(t){try{t.font&&"function"==typeof t.font.destroy&&t.font.destroy(),t.face&&"function"==typeof t.face.destroy&&t.face.destroy(),t.fontBlob&&"function"==typeof t.fontBlob.destroy&&t.fontBlob.destroy()}catch(t){a.error("Error destroying font resources:",t)}}}const V=/^[a-z]{2,3}(?:-[a-z0-9]{2,16})*$/i,q=new Set(["af","as","be","bg","bn","ca","cs","cy","da","de-1996","el-monoton","el-polyton","en-gb","en-us","eo","es","et","eu","fi","fr","fur","ga","gl","gu","hi","hr","hsb","hu","hy","ia","id","is","it","ka","kmr","kn","la","lt","lv","mk","ml","mn-cyrl","mr","mul-ethi","nb","nl","nn","oc","or","pa","pl","pms","pt","rm","ro","ru","sa","sh-cyrl","sh-latn","sk","sl","sq","sr-cyrl","sv","ta","te","th","tk","tr","uk","zh-latn-pinyin"])
|
|
312
312
|
class Y{constructor(t=0,e=0){this.x=t,this.y=e}set(t,e){return this.x=t,this.y=e,this}clone(){return new Y(this.x,this.y)}Ke(t){return this.x=t.x,this.y=t.y,this}add(t){return this.x+=t.x,this.y+=t.y,this}sub(t){return this.x-=t.x,this.y-=t.y,this}multiply(t){return this.x*=t,this.y*=t,this}Qe(t){return this.x/=t,this.y/=t,this}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}Xe(){return this.x*this.x+this.y*this.y}normalize(){const t=this.length()
|
|
313
313
|
return t>0&&this.Qe(t),this}Ze(t){return this.x*t.x+this.y*t.y}ti(t){const e=this.x-t.x,i=this.y-t.y
|
|
314
314
|
return Math.sqrt(e*e+i*i)}ei(t){const e=this.x-t.x,i=this.y-t.y
|
|
@@ -322,7 +322,7 @@ var et="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?wind
|
|
|
322
322
|
return n+s>0?s>n?e.a-t.a+n/(n+s)*(t.a-i.a):e.a-i.a+s/(n+s)*(i.a-t.a):0}function s(t,e,i){var n=e.b-t.b,s=i.b-e.b
|
|
323
323
|
return n+s>0?(e.a-i.a)*n+(e.a-t.a)*s:0}function r(t,e){return e.a>t.a||t.a===e.a&&e.b>=t.b}function o(t,e,i){var n=e.a-t.a,s=i.a-e.a
|
|
324
324
|
return n+s>0?s>n?e.b-t.b+n/(n+s)*(t.b-i.b):e.b-i.b+s/(n+s)*(i.b-t.b):0}function h(t,e,i){var n=e.a-t.a,s=i.a-e.a
|
|
325
|
-
return n+s>0?(e.b-i.b)*n+(e.b-t.b)*s:0}function a(t){return i(t.b.a,t.a)}function
|
|
325
|
+
return n+s>0?(e.b-i.b)*n+(e.b-t.b)*s:0}function a(t){return i(t.b.a,t.a)}function l(t){return i(t.a,t.b.a)}function c(t,e,i,n){return(t=0>t?0:t)>(i=0>i?0:i)?n+i/(t+i)*(e-n):0===i?(e+n)/2:e+t/(t+i)*(n-e)}function u(t){var e=w(t.b)
|
|
326
326
|
return v(e,t.c),v(e.b,t.c),m(e,t.a),e}function f(t,e){var i=!1,n=!1
|
|
327
327
|
t!==e&&(e.a!==t.a&&(n=!0,b(e.a,t.a)),e.d!==t.d&&(i=!0,S(e.d,t.d)),g(e,t),n||(v(e,t.a),t.a.c=t),i||(m(e,t.d),t.d.a=t))}function d(t){var e=t.b,i=!1
|
|
328
328
|
t.d!==t.b.d&&(i=!0,S(t.d,t.b.d)),t.c===t?b(t.a,null):(t.b.d.a=K(t),t.a.c=t.c,g(t,K(t)),i||m(t,t.d)),e.c===e?(b(e.a,null),S(e.d,null)):(t.d.a=K(e),e.a.c=e.c,g(e,K(e))),x(t)}function y(t){var e=w(t),i=e.b
|
|
@@ -341,55 +341,55 @@ return Math.abs(t[1])>Math.abs(t[0])&&(e=1),Math.abs(t[2])>Math.abs(t[e])&&(e=2)
|
|
|
341
341
|
var e=t.e
|
|
342
342
|
e.a.c=e.c,e.c.a=e.a,t.e=null}function M(t,e){d(t.a),t.c=!1,t.a=e,e.si=t}function I(t){var e=t.a.a
|
|
343
343
|
do{t=ut(t)}while(t.a.a===e)
|
|
344
|
-
return t.c&&(M(t,e=p(
|
|
344
|
+
return t.c&&(M(t,e=p(ct(t).a.b,t.a.e)),t=ut(t)),t}function F(t,e,i){var n=new lt
|
|
345
345
|
return n.a=i,n.e=R(t.f,e.e,n),i.si=n}function L(t,e){switch(t.s){case 100130:return!!(1&e)
|
|
346
346
|
case 100131:return 0!==e
|
|
347
347
|
case 100132:return e>0
|
|
348
348
|
case 100133:return 0>e
|
|
349
349
|
case 100134:return e>=2||-2>=e}return!1}function G(t){var e=t.a,i=e.d
|
|
350
350
|
i.c=t.d,i.a=e,A(t)}function O(t,e,i){for(t=e,e=e.a;t!==i;){t.c=!1
|
|
351
|
-
var n=
|
|
351
|
+
var n=ct(t),s=n.a
|
|
352
352
|
if(s.a!==e.a){if(!n.c){G(t)
|
|
353
|
-
break}M(n,s=p(e.c.b,s.b))}e.c!==s&&(f(K(s),s),f(e,s)),G(t),e=n.a,t=n}return e}function
|
|
353
|
+
break}M(n,s=p(e.c.b,s.b))}e.c!==s&&(f(K(s),s),f(e,s)),G(t),e=n.a,t=n}return e}function C(t,e,i,n,s,r){var o=!0
|
|
354
354
|
do{F(t,e,i.b),i=i.c}while(i!==n)
|
|
355
|
-
for(null===s&&(s=
|
|
356
|
-
e.b=!0,r&&P(t,e)}function
|
|
355
|
+
for(null===s&&(s=ct(e).a.b.c);(i=(n=ct(e)).a.b).a===s.a;)i.c!==s&&(f(K(i),i),f(K(s),i)),n.f=e.f-i.f,n.d=L(t,n.f),e.b=!0,!o&&N(t,e)&&(E(i,s),A(e),d(s)),o=!1,e=n,s=i
|
|
356
|
+
e.b=!0,r&&P(t,e)}function k(t,e,i,n,s){var r=[e.g[0],e.g[1],e.g[2]]
|
|
357
357
|
e.d=null,e.d=t.ri&&t.ri(r,i,n,t.c)||null,null===e.d&&(s?t.n||(q(t,100156),t.n=!0):e.d=i[0])}function D(t,e,i){var n=[null,null,null,null]
|
|
358
|
-
n[0]=e.a.d,n[1]=i.a.d,
|
|
359
|
-
n[s]=.5*o/(r+o),n[h]=.5*r/(r+o),t.g[0]+=n[s]*e.g[0]+n[h]*i.g[0],t.g[1]+=n[s]*e.g[1]+n[h]*i.g[1],t.g[2]+=n[s]*e.g[2]+n[h]*i.g[2]}function N(t,n){var r=
|
|
358
|
+
n[0]=e.a.d,n[1]=i.a.d,k(t,e.a,n,[.5,.5,0,0],!1),f(e,i)}function B(t,e,i,n,s){var r=Math.abs(e.b-t.b)+Math.abs(e.a-t.a),o=Math.abs(i.b-t.b)+Math.abs(i.a-t.a),h=s+1
|
|
359
|
+
n[s]=.5*o/(r+o),n[h]=.5*r/(r+o),t.g[0]+=n[s]*e.g[0]+n[h]*i.g[0],t.g[1]+=n[s]*e.g[1]+n[h]*i.g[1],t.g[2]+=n[s]*e.g[2]+n[h]*i.g[2]}function N(t,n){var r=ct(n),o=n.a,h=r.a
|
|
360
360
|
if(i(o.a,h.a)){if(s(h.b.a,o.a,h.a)>0)return!1
|
|
361
361
|
if(e(o.a,h.a)){if(o.a!==h.a){r=t.e
|
|
362
362
|
var a=o.a.ni
|
|
363
363
|
if(0>a)for(r.c[-(a+1)]=null;r.a>0&&null===r.c[r.d[r.a-1]];)--r.a
|
|
364
|
-
else{var
|
|
365
|
-
|
|
366
|
-
ut(n).b=n.b=!0,y(o.b),f(K(h),o)}return!0}function U(t,a){var
|
|
364
|
+
else{var l=(r=r.b).d,c=r.e,u=r.c,d=u[a]
|
|
365
|
+
l[d]=l[r.a],u[l[d]]=d,d<=--r.a&&(d>1?i(c[l[d>>1]],c[l[d]])?ht(r,d):at(r,d):ht(r,d)),c[a]=null,u[a]=r.b,r.b=a}D(t,K(h),o)}}else y(h.b),f(o,K(h)),n.b=r.b=!0}else{if(0>s(o.b.a,h.a,o.a))return!1
|
|
366
|
+
ut(n).b=n.b=!0,y(o.b),f(K(h),o)}return!0}function U(t,a){var l=ct(a),u=a.a,d=l.a,p=u.a,w=d.a,g=u.b.a,v=d.b.a,m=new X
|
|
367
367
|
if(s(g,t.a,p),s(v,t.a,w),p===w||Math.min(p.a,g.a)>Math.max(w.a,v.a))return!1
|
|
368
368
|
if(i(p,w)){if(s(v,p,w)>0)return!1}else if(0>s(g,w,p))return!1
|
|
369
369
|
var x,b,S=g,_=p,E=v,T=w
|
|
370
|
-
if(i(S,_)||(x=S,S=_,_=x),i(E,T)||(x=E,E=T,T=x),i(S,E)||(x=S,S=E,E=x,x=_,_=T,T=x),i(E,_)?i(_,T)?(0>(x=n(S,E,_))+(b=n(E,_,T))&&(x=-x,b=-b),m.b=
|
|
371
|
-
if(!e(g,t.a)&&s(g,t.a,m)>=0||!e(v,t.a)&&0>=s(v,t.a,m)){if(v===t.a)return y(u.b),f(d.b,u),u=
|
|
372
|
-
if(g===t.a){y(d.b),f(u.e,K(d)),w=(p=
|
|
370
|
+
if(i(S,_)||(x=S,S=_,_=x),i(E,T)||(x=E,E=T,T=x),i(S,E)||(x=S,S=E,E=x,x=_,_=T,T=x),i(E,_)?i(_,T)?(0>(x=n(S,E,_))+(b=n(E,_,T))&&(x=-x,b=-b),m.b=c(x,E.b,b,_.b)):(0>(x=s(S,E,_))+(b=-s(S,T,_))&&(x=-x,b=-b),m.b=c(x,E.b,b,T.b)):m.b=(E.b+_.b)/2,r(S,_)||(x=S,S=_,_=x),r(E,T)||(x=E,E=T,T=x),r(S,E)||(x=S,S=E,E=x,x=_,_=T,T=x),r(E,_)?r(_,T)?(0>(x=o(S,E,_))+(b=o(E,_,T))&&(x=-x,b=-b),m.a=c(x,E.a,b,_.a)):(0>(x=h(S,E,_))+(b=-h(S,T,_))&&(x=-x,b=-b),m.a=c(x,E.a,b,T.a)):m.a=(E.a+_.a)/2,i(m,t.a)&&(m.b=t.a.b,m.a=t.a.a),S=i(p,w)?p:w,i(S,m)&&(m.b=S.b,m.a=S.a),e(m,p)||e(m,w))return N(t,a),!1
|
|
371
|
+
if(!e(g,t.a)&&s(g,t.a,m)>=0||!e(v,t.a)&&0>=s(v,t.a,m)){if(v===t.a)return y(u.b),f(d.b,u),u=ct(a=I(a)).a,O(t,ct(a),l),C(t,a,K(u),u,u,!0),!0
|
|
372
|
+
if(g===t.a){y(d.b),f(u.e,K(d)),w=(p=l=a).a.b.a
|
|
373
373
|
do{p=ut(p)}while(p.a.b.a===w)
|
|
374
|
-
return p=
|
|
374
|
+
return p=ct(a=p).a.b.c,l.a=K(d),C(t,a,(d=O(t,l,null)).c,u.b.c,p,!0),!0}return s(g,t.a,m)>=0&&(ut(a).b=a.b=!0,y(u.b),u.a.b=t.a.b,u.a.a=t.a.a),0>=s(v,t.a,m)&&(a.b=l.b=!0,y(d.b),d.a.b=t.a.b,d.a.a=t.a.a),!1}return y(u.b),y(d.b),f(K(d),u),u.a.b=m.b,u.a.a=m.a,u.a.ni=tt(t.e,u.a),d=[0,0,0,0],m=[p.d,g.d,w.d,v.d],(u=u.a).g[0]=u.g[1]=u.g[2]=0,B(u,p,g,d,0),B(u,w,v,d,2),k(t,u,m,d,!0),ut(a).b=a.b=l.b=!0,!1}function P(t,e){for(var n=ct(e);;){for(;n.b;)e=n,n=ct(n)
|
|
375
375
|
if(!e.b&&(n=e,null===(e=ut(e))||!e.b))break
|
|
376
376
|
e.b=!1
|
|
377
377
|
var r,o=e.a,h=n.a
|
|
378
|
-
if(r=o.b.a!==h.b.a)t:{var a=
|
|
379
|
-
if(i(
|
|
380
|
-
break t}ut(r).b=r.b=!0,u=y(
|
|
381
|
-
break t}r.b=a.b=!0,u=y(
|
|
378
|
+
if(r=o.b.a!==h.b.a)t:{var a=ct(r=e),l=r.a,c=a.a,u=void 0
|
|
379
|
+
if(i(l.b.a,c.b.a)){if(0>s(l.b.a,c.b.a,l.a)){r=!1
|
|
380
|
+
break t}ut(r).b=r.b=!0,u=y(l),f(c.b,u),u.d.c=r.d}else{if(s(c.b.a,l.b.a,c.a)>0){r=!1
|
|
381
|
+
break t}r.b=a.b=!0,u=y(c),f(l.e,c.b),u.b.d.c=r.d}r=!0}if(r&&(n.c?(A(n),d(h),h=(n=ct(e)).a):e.c&&(A(e),d(o),o=(e=ut(n)).a)),o.a!==h.a)if(o.b.a===h.b.a||e.c||n.c||o.b.a!==t.a&&h.b.a!==t.a)N(t,e)
|
|
382
382
|
else if(U(t,e))break
|
|
383
383
|
o.a===h.a&&o.b.a===h.b.a&&(E(h,o),A(e),d(o),e=ut(n))}}function $(t,n){t.a=n
|
|
384
384
|
for(var r=n.c;null===r.si;)if((r=r.c)===n.c){r=t
|
|
385
|
-
var o=n;(u=new
|
|
386
|
-
var h=(
|
|
387
|
-
do{h=h.a}while(null!==h.b&&!
|
|
388
|
-
if(h=(
|
|
389
|
-
else{var a=i(h.b.a,u.b.a)?l
|
|
390
|
-
|
|
385
|
+
var o=n;(u=new lt).a=o.c.b
|
|
386
|
+
var h=(c=r.f).a
|
|
387
|
+
do{h=h.a}while(null!==h.b&&!c.c(c.b,u,h.b))
|
|
388
|
+
if(h=(l=ct(c=h.b)).a,0===s((u=c.a).b.a,o,u.a))e((u=c.a).a,o)||e(u.b.a,o)||(y(u.b),c.c&&(d(u.c),c.c=!1),f(o.c,u),$(r,o))
|
|
389
|
+
else{var a=i(h.b.a,u.b.a)?c:l,l=void 0
|
|
390
|
+
c.d||a.c?(l=a===c?p(o.c.b,u.e):p(h.b.c.b,o.c).b,a.c?M(a,l):(u=r,(c=F(r,c,l)).f=ut(c).f+c.a.f,c.d=L(u,c.f)),$(r,o)):C(r,c,o.c,o.c,null,!0)}return}if(c=(u=ct(r=I(r.si))).a,(u=O(t,u,null)).c===c){var c,u=(c=u).c,w=(h=ct(r),!1);(l=r.a).b.a!==(a=h.a).b.a&&U(t,r),e(l.a,t.a)&&(f(K(u),l),u=ct(r=I(r)).a,O(t,ct(r),h),w=!0),e(a.a,t.a)&&(f(c,K(a)),c=O(t,h,null),w=!0),w?C(t,r,c.c,u,u,!0):(o=i(a.a,l.a)?K(a):l,C(t,r,o=p(c.c.b,o),o.c,o.c,!1),o.b.si.c=!0,P(t,r))}else C(t,r,u.c,c,c,!0)}function z(t,e){var i=new lt,n=u(t.b)
|
|
391
391
|
n.a.b=dt,n.a.a=e,n.b.a.b=-dt,n.b.a.a=e,t.a=n.b.a,i.a=n,i.f=0,i.d=!1,i.c=!1,i.ni=!0,i.b=!1,n=R(n=t.f,n.a,i),i.e=n}function W(t){this.a=new j,this.b=t,this.c=T}function R(t,e,i){do{e=e.c}while(null!==e.b&&!t.c(t.b,e.b,i))
|
|
392
|
-
return t=new j(i,e.a,e),e.a.c=t,e.a=t}function j(t,e,i){this.b=t||null,this.a=e||this,this.c=i||this}function H(){this.d=yt,this.oi=this.b=this.hi=null,this.ai=[0,0,0],this.s=100130,this.n=!1,this.ri=this.a=this.e=this.f=null,this.
|
|
392
|
+
return t=new j(i,e.a,e),e.a.c=t,e.a=t}function j(t,e,i){this.b=t||null,this.a=e||this,this.c=i||this}function H(){this.d=yt,this.oi=this.b=this.hi=null,this.ai=[0,0,0],this.s=100130,this.n=!1,this.ri=this.a=this.e=this.f=null,this.li=!1,this.c=this.r=this.si=this.ci=this.ui=this.ni=null}function V(t,e){if(t.d!==e)for(;t.d!==e;)if(e>t.d)switch(t.d){case yt:q(t,100151),t.fi(null)
|
|
393
393
|
break
|
|
394
394
|
case 1:q(t,100152),t.di()}else switch(t.d){case 2:q(t,100154),t.yi()
|
|
395
395
|
break
|
|
@@ -403,22 +403,22 @@ for(;e>n;n++)i[n]=0
|
|
|
403
403
|
return i}function rt(t){return t.e[t.d[1]]}function ot(t){var e=t.d,i=t.e,n=t.c,s=e[1],r=i[s]
|
|
404
404
|
return t.a>0&&(e[1]=e[t.a],n[e[1]]=1,i[s]=null,n[s]=t.b,t.b=s,--t.a>0&&ht(t,1)),r}function ht(t,e){for(var n=t.d,s=t.e,r=t.c,o=e,h=n[o];;){var a=o<<1
|
|
405
405
|
t.a>a&&i(s[n[a+1]],s[n[a]])&&(a+=1)
|
|
406
|
-
var
|
|
407
|
-
if(a>t.a||i(s[h],s[
|
|
408
|
-
break}n[o]=
|
|
409
|
-
if(0===a||i(s[
|
|
410
|
-
break}n[o]=
|
|
406
|
+
var l=n[a]
|
|
407
|
+
if(a>t.a||i(s[h],s[l])){n[o]=h,r[h]=o
|
|
408
|
+
break}n[o]=l,r[l]=o,o=a}}function at(t,e){for(var n=t.d,s=t.e,r=t.c,o=e,h=n[o];;){var a=o>>1,l=n[a]
|
|
409
|
+
if(0===a||i(s[l],s[h])){n[o]=h,r[h]=o
|
|
410
|
+
break}n[o]=l,r[l]=o,o=a}}function lt(){this.e=this.a=null,this.f=0,this.c=this.b=this.ni=this.d=!1}function ct(t){return t.e.c.b}function ut(t){return t.e.a.b}var ft,dt=4e150,yt=0;(ft=H.prototype).x=function(){V(this,yt)},ft.B=function(t,e){switch(t){case 100142:return
|
|
411
411
|
case 100140:switch(e){case 100130:case 100131:case 100132:case 100133:case 100134:return void(this.s=e)}break
|
|
412
|
-
case 100141:return void(this.
|
|
412
|
+
case 100141:return void(this.li=!!e)
|
|
413
413
|
default:return void q(this,100900)}q(this,100901)},ft.y=function(t){switch(t){case 100142:return 0
|
|
414
414
|
case 100140:return this.s
|
|
415
|
-
case 100141:return this.
|
|
415
|
+
case 100141:return this.li
|
|
416
416
|
default:q(this,100900)}return!1},ft.A=function(t,e,i){this.ai[0]=t,this.ai[1]=e,this.ai[2]=i},ft.z=function(t,e){var i=e||null
|
|
417
417
|
switch(t){case 100100:case 100106:this.ni=i
|
|
418
418
|
break
|
|
419
419
|
case 100104:case 100110:this.ui=i
|
|
420
420
|
break
|
|
421
|
-
case 100101:case 100107:this.
|
|
421
|
+
case 100101:case 100107:this.ci=i
|
|
422
422
|
break
|
|
423
423
|
case 100102:case 100108:this.si=i
|
|
424
424
|
break
|
|
@@ -432,10 +432,10 @@ default:q(this,100900)}},ft.C=function(t,e){var i=!1,n=[0,0,0]
|
|
|
432
432
|
V(this,2)
|
|
433
433
|
for(var s=0;3>s;++s){var r=t[s];-1e150>r&&(r=-1e150,i=!0),r>1e150&&(r=1e150,i=!0),n[s]=r}i&&q(this,100155),null===(i=this.hi)?f(i=u(this.b),i.b):(y(i),i=i.e),i.a.d=e,i.a.g[0]=n[0],i.a.g[1]=n[1],i.a.g[2]=n[2],i.f=1,i.b.f=-1,this.hi=i},ft.fi=function(t){V(this,yt),this.d=1,this.b=new Q,this.c=t},ft.di=function(){V(this,1),this.d=2,this.hi=null},ft.yi=function(){V(this,2),this.d=1},ft.w=function(){V(this,1),this.d=yt
|
|
434
434
|
var t=!1,n=[u=this.ai[0],r=this.ai[1],h=this.ai[2]]
|
|
435
|
-
if(0===u&&0===r&&0===h){for(var r=[-2e150,-2e150,-2e150],o=[2e150,2e150,2e150],h=[],
|
|
436
|
-
o[f]>y&&(o[f]=y,
|
|
435
|
+
if(0===u&&0===r&&0===h){for(var r=[-2e150,-2e150,-2e150],o=[2e150,2e150,2e150],h=[],c=[],u=(t=this.b.c).e;u!==t;u=u.e)for(var f=0;3>f;++f){var y=u.g[f]
|
|
436
|
+
o[f]>y&&(o[f]=y,c[f]=u),y>r[f]&&(r[f]=y,h[f]=u)}if(u=0,r[1]-o[1]>r[0]-o[0]&&(u=1),r[2]-o[2]>r[u]-o[u]&&(u=2),r[u]>o[u]){for(r=0,o=c[u],c=[0,0,0],o=[o.g[0]-(h=h[u]).g[0],o.g[1]-h.g[1],o.g[2]-h.g[2]],f=[0,0,0],u=t.e;u!==t;u=u.e)f[0]=u.g[0]-h.g[0],f[1]=u.g[1]-h.g[1],f[2]=u.g[2]-h.g[2],c[0]=o[1]*f[2]-o[2]*f[1],c[1]=o[2]*f[0]-o[0]*f[2],c[2]=o[0]*f[1]-o[1]*f[0],(y=c[0]*c[0]+c[1]*c[1]+c[2]*c[2])>r&&(r=y,n[0]=c[0],n[1]=c[1],n[2]=c[2])
|
|
437
437
|
0>=r&&(n[0]=n[1]=n[2]=0,n[_(o)]=1)}else n[0]=0,n[1]=0,n[2]=1
|
|
438
|
-
t=!0}for(r=((
|
|
438
|
+
t=!0}for(r=((c=_(n))+1)%3,h=(c+2)%3,c=n[c]>0?1:-1,n=(u=this.b.c).e;n!==u;n=n.e)n.b=n.g[r],n.a=c*n.g[h]
|
|
439
439
|
if(t){for(n=0,u=(t=this.b.a).b;u!==t;u=u.b)if((r=u.a).f>0)do{n+=(r.a.b-r.b.a.b)*(r.a.a+r.b.a.a),r=r.e}while(r!==u.a)
|
|
440
440
|
if(0>n)for(t=(n=this.b.c).e;t!==n;t=t.e)t.a=-t.a}for(this.n=!1,u=(n=this.b.b).ni;u!==n;u=t)t=u.ni,r=u.e,e(u.a,u.b.a)&&u.e.e!==u&&(D(this,r,u),d(u),r=(u=r).e),r.e===u&&(r!==u&&(r!==t&&r!==t.b||(t=t.ni),d(r)),u!==t&&u!==t.b||(t=t.ni),d(u))
|
|
441
441
|
for(this.e=n=new Z,u=(t=this.b.c).e;u!==t;u=u.e)u.ni=tt(n,u)
|
|
@@ -447,31 +447,47 @@ else if(t=u.c[u.d[u.a-1]],0!==u.b.a&&(u=rt(u.b),i(u,t))){t=u
|
|
|
447
447
|
break t}if(null===t||!e(t,n))break
|
|
448
448
|
t=it(this.e),D(this,n.c,t.c)}$(this,n)}for(this.a=this.f.a.a.b.a.a,n=0;null!==(t=this.f.a.a.b);)t.ni||++n,A(t)
|
|
449
449
|
for(this.f=null,(n=this.e).b=null,n.d=null,this.e=n.c=null,u=(n=this.b).a.b;u!==n.a;u=t)t=u.b,(u=u.a).e.e===u&&(E(u.c,u),d(u))
|
|
450
|
-
if(!this.n){if(n=this.b,this.
|
|
450
|
+
if(!this.n){if(n=this.b,this.li)for(u=n.b.ni;u!==n.b;u=t)t=u.ni,u.b.d.c!==u.d.c?u.f=u.d.c?1:-1:d(u)
|
|
451
451
|
else for(u=n.a.b;u!==n.a;u=t)if(t=u.b,u.c){for(u=u.a;i(u.b.a,u.a);u=u.c.b);for(;i(u.a,u.b.a);u=u.e);for(r=u.c.b,h=void 0;u.e!==r;)if(i(u.b.a,r.a)){for(;r.e!==u&&(a(r.e)||0>=s(r.a,r.b.a,r.e.b.a));)r=(h=p(r.e,r)).b
|
|
452
|
-
r=r.c.b}else{for(;r.e!==u&&(
|
|
453
|
-
u=u.e}for(;r.e.e!==u;)r=(h=p(r.e,r)).b}if(this.ni||this.si||this.
|
|
454
|
-
do{this.
|
|
455
|
-
this.si&&this.si(this.c)}}else{for(t=!!this.ui,u=!1,r=-1,h=(n=this.b).a.d;h!==n.a;h=h.d)if(h.c){u||(this.ni&&this.ni(4,this.c),u=!0),
|
|
456
|
-
do{t&&r!==(o=
|
|
457
|
-
do{h=(
|
|
452
|
+
r=r.c.b}else{for(;r.e!==u&&(l(u.c.b)||s(u.b.a,u.a,u.c.b.a)>=0);)u=(h=p(u,u.c.b)).b
|
|
453
|
+
u=u.e}for(;r.e.e!==u;)r=(h=p(r.e,r)).b}if(this.ni||this.si||this.ci||this.ui)if(this.li){for(t=(n=this.b).a.b;t!==n.a;t=t.b)if(t.c){this.ni&&this.ni(2,this.c),u=t.a
|
|
454
|
+
do{this.ci&&this.ci(u.a.d,this.c),u=u.e}while(u!==t.a)
|
|
455
|
+
this.si&&this.si(this.c)}}else{for(t=!!this.ui,u=!1,r=-1,h=(n=this.b).a.d;h!==n.a;h=h.d)if(h.c){u||(this.ni&&this.ni(4,this.c),u=!0),c=h.a
|
|
456
|
+
do{t&&r!==(o=c.b.d.c?0:1)&&(r=o,this.ui&&this.ui(!!r,this.c)),this.ci&&this.ci(c.a.d,this.c),c=c.e}while(c!==h.a)}u&&this.si&&this.si(this.c)}if(this.r){for(u=(n=this.b).a.b;u!==n.a;u=t)if(t=u.b,!u.c){h=(r=u.a).e,c=void 0
|
|
457
|
+
do{h=(c=h).e,c.d=null,null===c.b.d&&(c.c===c?b(c.a,null):(c.a.c=c.c,g(c,K(c))),(o=c.b).c===o?b(o.a,null):(o.a.c=o.c,g(o,K(o))),x(c))}while(c!==r)
|
|
458
458
|
r=u.d,(u=u.b).d=r,r.b=u}return this.r(this.b),void(this.c=this.b=null)}}this.b=this.c=null},et.pi={GluTesselator:H,wi:{GLU_TESS_WINDING_ODD:100130,GLU_TESS_WINDING_NONZERO:100131,GLU_TESS_WINDING_POSITIVE:100132,GLU_TESS_WINDING_NEGATIVE:100133,GLU_TESS_WINDING_ABS_GEQ_TWO:100134},primitiveType:{GL_LINE_LOOP:2,GL_TRIANGLES:4,GL_TRIANGLE_STRIP:5,GL_TRIANGLE_FAN:6},gi:{GLU_TESS_MISSING_BEGIN_POLYGON:100151,GLU_TESS_MISSING_END_POLYGON:100153,GLU_TESS_MISSING_BEGIN_CONTOUR:100152,GLU_TESS_MISSING_END_CONTOUR:100154,GLU_TESS_COORD_TOO_LARGE:100155,GLU_TESS_NEED_COMBINE_CALLBACK:100156},mi:{GLU_TESS_MESH:100112,GLU_TESS_TOLERANCE:100142,GLU_TESS_WINDING_RULE:100140,GLU_TESS_BOUNDARY_ONLY:100141,GLU_INVALID_ENUM:100900,GLU_INVALID_VALUE:100901,GLU_TESS_BEGIN:100100,GLU_TESS_VERTEX:100101,GLU_TESS_END:100102,GLU_TESS_ERROR:100103,GLU_TESS_EDGE_FLAG:100104,GLU_TESS_COMBINE:100105,GLU_TESS_BEGIN_DATA:100106,GLU_TESS_VERTEX_DATA:100107,GLU_TESS_END_DATA:100108,GLU_TESS_ERROR_DATA:100109,GLU_TESS_EDGE_FLAG_DATA:100110,GLU_TESS_COMBINE_DATA:100111}},H.prototype.xi=H.prototype.x,H.prototype.bi=H.prototype.B,H.prototype.Si=H.prototype.y,H.prototype._i=H.prototype.A,H.prototype.Ei=H.prototype.z,H.prototype.Ti=H.prototype.C,H.prototype.Ai=H.prototype.fi,H.prototype.Mi=H.prototype.di,H.prototype.Ii=H.prototype.yi,H.prototype.Fi=H.prototype.w,t.exports=et.pi})(it)
|
|
459
459
|
var nt=it.exports
|
|
460
460
|
class st{process(t,e=!0,i=!1,n=!0){if(0===t.length)return{Li:{vertices:[],indices:[]},Gi:[]}
|
|
461
461
|
const s=t.filter(t=>t.points.length>=3)
|
|
462
|
-
return 0===s.length?{Li:{vertices:[],indices:[]},Gi:[]}:this.Oi(s,e,i,n)}Oi(t,e,i,n){const s=!i&&!e
|
|
462
|
+
return 0===s.length?{Li:{vertices:[],indices:[]},Gi:[]}:this.Oi(s,e,i,n)}Ci(t,e=!0,i=!1,n=!0){return 0===t.length?{Li:{vertices:[],indices:[]},Gi:[]}:this.ki(t,e,i,n)}Oi(t,e,i,n){const s=!i&&!e
|
|
463
463
|
let r,o
|
|
464
|
-
s?(o=this.
|
|
465
|
-
let h=n?s?o:r??this.
|
|
466
|
-
if(e){const t=this.
|
|
464
|
+
s?(o=this.Di(t,!0),(e||n)&&(r=this.Di(t))):(r=this.Di(t),o=r)
|
|
465
|
+
let h=n?s?o:r??this.Di(t):[]
|
|
466
|
+
if(e){const t=this.Bi(r,"boundary")
|
|
467
467
|
if(!t)return a.warn("libtess returned empty result from boundary pass"),{Li:{vertices:[],indices:[]},Gi:[]}
|
|
468
|
-
o=this.
|
|
469
|
-
return
|
|
468
|
+
o=this.Ni(t),n&&(h=o)}const l=this.Bi(o,"triangles")
|
|
469
|
+
return l?{Li:{vertices:l.vertices,indices:l.indices||[]},Gi:h}:(a.warn(e?"libtess returned empty result from triangulation pass":"libtess returned empty result from single-pass triangulation"),{Li:{vertices:[],indices:[]},Gi:h})}ki(t,e,i,n){const s=!i&&!e
|
|
470
|
+
let r,o
|
|
471
|
+
s?(o=this.Ui(t),(e||n)&&(r=t)):(r=t,o=t)
|
|
472
|
+
let h=n?s?o:r??t:[]
|
|
473
|
+
if(e){const t=this.Bi(r,"boundary")
|
|
474
|
+
if(!t)return a.warn("libtess returned empty result from boundary pass"),{Li:{vertices:[],indices:[]},Gi:[]}
|
|
475
|
+
o=this.Ni(t),n&&(h=o)}const l=this.Bi(o,"triangles")
|
|
476
|
+
return l?{Li:{vertices:l.vertices,indices:l.indices||[]},Gi:h}:(a.warn(e?"libtess returned empty result from triangulation pass":"libtess returned empty result from single-pass triangulation"),{Li:{vertices:[],indices:[]},Gi:h})}Di(t,e=!1){const i=Array(t.length)
|
|
470
477
|
for(let n=0;t.length>n;n++){const s=t[n].points,r=s.length,o=r>1&&s[0].x===s[r-1].x&&s[0].y===s[r-1].y?r-1:r,h=Array(2*(o+1))
|
|
471
478
|
let a=0
|
|
472
479
|
if(e)for(let t=o-1;t>=0;t--){const e=s[t]
|
|
473
480
|
h[a++]=e.x,h[a++]=e.y}else for(let t=0;o>t;t++){const e=s[t]
|
|
474
|
-
h[a++]=e.x,h[a++]=e.y}2>a||(h[a++]=h[0],h[a++]=h[1]),i[n]=h}return i}
|
|
481
|
+
h[a++]=e.x,h[a++]=e.y}2>a||(h[a++]=h[0],h[a++]=h[1]),i[n]=h}return i}Ui(t){const e=Array(t.length)
|
|
482
|
+
for(let i=0;t.length>i;i++)e[i]=this.Pi(t[i])
|
|
483
|
+
return e}Pi(t){const e=t.length
|
|
484
|
+
if(0===e)return[]
|
|
485
|
+
const i=4>e||t[0]!==t[e-2]||t[1]!==t[e-1]?e:e-2
|
|
486
|
+
if(0===i)return[]
|
|
487
|
+
const n=Array(i+2)
|
|
488
|
+
let s=0
|
|
489
|
+
for(let e=i-2;e>=0;e-=2)n[s++]=t[e],n[s++]=t[e+1]
|
|
490
|
+
return 2>s||(n[s++]=n[0],n[s++]=n[1]),n}Bi(t,e){const i=new nt.GluTesselator
|
|
475
491
|
i.bi(nt.mi.GLU_TESS_WINDING_RULE,nt.wi.GLU_TESS_WINDING_NONZERO)
|
|
476
492
|
const n=[],s=[],r=[]
|
|
477
493
|
let o=[]
|
|
@@ -479,450 +495,476 @@ let o=[]
|
|
|
479
495
|
return n.push(t[0],t[1]),e}),i.Ei(nt.mi.GLU_TESS_ERROR,t=>{a.warn("libtess error: "+t)}),i._i(0,0,1),i.Ai(null)
|
|
480
496
|
for(const e of t){i.Mi()
|
|
481
497
|
for(let t=0;e.length>t;t+=2){const s=n.length/2
|
|
482
|
-
n.push(e[t],e[t+1]),i.Ti([e[t],e[t+1],0],s)}i.Ii()}return i.Fi(),0===n.length?null:"triangles"===e?{vertices:n,indices:s}:{vertices:n
|
|
498
|
+
n.push(e[t],e[t+1]),i.Ti([e[t],e[t+1],0],s)}i.Ii()}return i.Fi(),0===n.length?null:"triangles"===e?{vertices:n,indices:s}:{vertices:n,$i:r}}Ni(t){if(!t.$i)return[]
|
|
483
499
|
const e=[]
|
|
484
|
-
for(const i of t
|
|
500
|
+
for(const i of t.$i){const n=[]
|
|
485
501
|
for(const e of i){const i=2*e
|
|
486
|
-
n.push(t.vertices[i],t.vertices[i+1])}n.length>2&&(n[0]===n[n.length-2]&&n[1]===n[n.length-1]||n.push(n[0],n[1])),e.push(n)}return e}
|
|
502
|
+
n.push(t.vertices[i],t.vertices[i+1])}n.length>2&&(n[0]===n[n.length-2]&&n[1]===n[n.length-1]||n.push(n[0],n[1])),e.push(n)}return e}zi(t){if(0===t.length)return!1
|
|
487
503
|
if(1===t.length)return!1
|
|
488
504
|
let e=null
|
|
489
|
-
for(const i of t){const t=0>this.
|
|
505
|
+
for(const i of t){const t=0>this.Wi(i)?-1:1
|
|
490
506
|
if(null===e)e=t
|
|
491
|
-
else if(t!==e)return!0}return!1}
|
|
507
|
+
else if(t!==e)return!0}return!1}Wi(t){let e=0
|
|
492
508
|
const i=t.length
|
|
493
509
|
if(6>i)return 0
|
|
494
510
|
for(let n=0;i>n;n+=2)e+=t[n]*t[(n+3)%i]-t[(n+2)%i]*t[n+1]
|
|
495
|
-
return e/2}}class rt{constructor(){}
|
|
496
|
-
let
|
|
497
|
-
if(0!==e)
|
|
511
|
+
return e/2}}class rt{constructor(){}Ri(t,e=0,i){const n=t.Li.vertices,s=t.Li.indices,r=t.Gi,o=n.length,h=o/2
|
|
512
|
+
let a=[],l=0,c=!1
|
|
513
|
+
if(0!==e)if(r.length>0){c=!0
|
|
514
|
+
for(const t of r){const e=t.length>>1
|
|
515
|
+
2>e||(l+=e-1)}}else{const t=new Map,e=s.length
|
|
498
516
|
for(let i=0;e>i;i+=3){const e=s[i],n=s[i+1],r=s[i+2]
|
|
499
|
-
let o,h
|
|
500
|
-
n>e?
|
|
501
|
-
let
|
|
502
|
-
|
|
503
|
-
for(const
|
|
504
|
-
|
|
505
|
-
for(let e=0;
|
|
506
|
-
return
|
|
507
|
-
for(let t=0,e=0;
|
|
508
|
-
|
|
509
|
-
const
|
|
510
|
-
|
|
511
|
-
for(let t=0;
|
|
512
|
-
for(let t=0;
|
|
513
|
-
let
|
|
514
|
-
const
|
|
515
|
-
for(let
|
|
516
|
-
let
|
|
517
|
-
if(
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
const
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
517
|
+
let o,h
|
|
518
|
+
o=n>e?e<<16|n:n<<16|e,h=e<<16|n
|
|
519
|
+
let a=t.get(o)
|
|
520
|
+
void 0===a?t.set(o,h):null!==a&&t.set(o,null),o=r>n?n<<16|r:r<<16|n,h=n<<16|r,a=t.get(o),void 0===a?t.set(o,h):null!==a&&t.set(o,null),o=e>r?r<<16|e:e<<16|r,h=r<<16|e,a=t.get(o),void 0===a?t.set(o,h):null!==a&&t.set(o,null)}a=[]
|
|
521
|
+
for(const e of t.values())null!==e&&a.push(e>>>16,65535&e)
|
|
522
|
+
l=a.length>>1}const u=(0===e?h:2*h)+4*l,f=new Float32Array(3*u),d=new Float32Array(3*u),y=new Uint32Array(0===e?s.length:2*s.length+6*l)
|
|
523
|
+
if(0===e){for(let t=0,e=0;o>t;t+=2,e+=3)f[e]=n[t],f[e+1]=n[t+1],f[e+2]=0,d[e]=0,d[e+1]=0,d[e+2]=1
|
|
524
|
+
return y.set(s),{vertices:f,normals:d,indices:y}}const p=25e-6*i,w=e>p?e:p,g=3*h
|
|
525
|
+
for(let t=0,e=0,i=0;o>t;t+=2,e++,i+=3){const e=n[t],s=n[t+1]
|
|
526
|
+
f[i]=e,f[i+1]=s,f[i+2]=0,d[i]=0,d[i+1]=0,d[i+2]=-1
|
|
527
|
+
const r=i+g
|
|
528
|
+
f[r]=e,f[r+1]=s,f[r+2]=w,d[r]=0,d[r+1]=0,d[r+2]=1}const v=s.length
|
|
529
|
+
for(let t=0;v>t;t++)y[t]=s[v-1-t]
|
|
530
|
+
for(let t=0;v>t;t++)y[v+t]=s[t]+h
|
|
531
|
+
let m=2*h,x=2*v
|
|
532
|
+
if(c)for(const t of r){const e=t.length
|
|
533
|
+
if(e>=4)for(let i=0;e-2>i;i+=2){const e=t[i],n=t[i+1],s=t[i+2],r=t[i+3],o=s-e,h=r-n,a=o*o+h*h
|
|
534
|
+
let l=0,c=0
|
|
535
|
+
if(a>1e-10){const t=1/Math.sqrt(a)
|
|
536
|
+
l=h*t,c=-o*t}const u=3*m
|
|
537
|
+
f[u]=e,f[u+1]=n,f[u+2]=0,f[u+3]=s,f[u+4]=r,f[u+5]=0,f[u+6]=e,f[u+7]=n,f[u+8]=w,f[u+9]=s,f[u+10]=r,f[u+11]=w,d[u]=l,d[u+1]=c,d[u+2]=0,d[u+3]=l,d[u+4]=c,d[u+5]=0,d[u+6]=l,d[u+7]=c,d[u+8]=0,d[u+9]=l,d[u+10]=c,d[u+11]=0
|
|
538
|
+
const p=m
|
|
539
|
+
y[x]=p,y[x+1]=p+1,y[x+2]=p+2,y[x+3]=p+1,y[x+4]=p+3,y[x+5]=p+2,x+=6,m+=4}}else for(let t=0;l>t;t++){const e=t<<1,i=a[e]<<1,s=a[e+1]<<1,r=n[i],o=n[i+1],h=n[s],l=n[s+1],c=h-r,u=l-o,p=c*c+u*u
|
|
540
|
+
let g=0,v=0
|
|
541
|
+
if(p>1e-10){const t=1/Math.sqrt(p)
|
|
542
|
+
g=u*t,v=-c*t}const b=3*m
|
|
543
|
+
f[b]=r,f[b+1]=o,f[b+2]=0,f[b+3]=h,f[b+4]=l,f[b+5]=0,f[b+6]=r,f[b+7]=o,f[b+8]=w,f[b+9]=h,f[b+10]=l,f[b+11]=w,d[b]=g,d[b+1]=v,d[b+2]=0,d[b+3]=g,d[b+4]=v,d[b+5]=0,d[b+6]=g,d[b+7]=v,d[b+8]=0,d[b+9]=g,d[b+10]=v,d[b+11]=0
|
|
544
|
+
const S=m
|
|
545
|
+
y[x]=S,y[x+1]=S+1,y[x+2]=S+2,y[x+3]=S+1,y[x+4]=S+3,y[x+5]=S+2,x+=6,m+=4}return{vertices:f,normals:d,indices:y}}}class ot{constructor(){}ji(t,e){const i=t.length
|
|
546
|
+
return 0===i?[]:1===i?[[0]]:this.Hi(t,e)}Hi(t,e){function i(t){return a[t]===t?t:a[t]=i(a[t])}function n(t,e){const n=i(t),s=i(e)
|
|
547
|
+
n!==s&&(l[s]>l[n]?a[n]=s:l[n]>l[s]?a[s]=n:(a[s]=n,l[n]++))}const s=t.length,r=Array(s),o=Array(2*s)
|
|
524
548
|
let h=0
|
|
525
|
-
for(let i=0;s>i;i++)r[i]=this.
|
|
549
|
+
for(let i=0;s>i;i++)r[i]=this.Vi(t[i],e[i]),o[h++]=[r[i].qi,0,i],o[h++]=[r[i].Yi,1,i]
|
|
526
550
|
o.sort((t,e)=>t[0]-e[0]||t[1]-e[1])
|
|
527
|
-
const a=Array.from({length:s},(t,e)=>e),
|
|
551
|
+
const a=Array.from({length:s},(t,e)=>e),l=Array(s).fill(0),c=new Set
|
|
528
552
|
for(const[,t,e]of o)if(0===t){const t=r[e]
|
|
529
|
-
for(const i of
|
|
530
|
-
s.
|
|
553
|
+
for(const i of c){const s=r[i]
|
|
554
|
+
s.Ji+.001>t.Ki&&t.Ji>s.Ki-.001&&n(e,i)}c.add(e)}else c.delete(e)
|
|
531
555
|
const u=new Map
|
|
532
556
|
for(let t=0;s>t;t++){const e=i(t)
|
|
533
557
|
let n=u.get(e)
|
|
534
|
-
n||(n=[],u.set(e,n)),n.push(t)}return Array.from(u.values())}
|
|
535
|
-
if(void 0!==e)return this.
|
|
536
|
-
const i=this.
|
|
537
|
-
this.
|
|
558
|
+
n||(n=[],u.set(e,n)),n.push(t)}return Array.from(u.values())}Vi(t,e){return{qi:t.bounds.min.x+e.x,Ki:t.bounds.min.y+e.y,Yi:t.bounds.max.x+e.x,Ji:t.bounds.max.y+e.y}}}class ht{constructor(t){this.Qi=[],this.Xi=new Map,this.compare=t}F(t){const e=this.Xi.get(t)
|
|
559
|
+
if(void 0!==e)return this.Zi(e),void this.tn(e)
|
|
560
|
+
const i=this.Qi.length
|
|
561
|
+
this.Qi.push(t),this.Xi.set(t,i),this.Zi(i)}en(){const t=this.Qi.length
|
|
538
562
|
if(!t)return
|
|
539
|
-
if(1===t){const t=this.
|
|
540
|
-
return this.
|
|
541
|
-
return this.
|
|
542
|
-
void 0!==e?(this.
|
|
543
|
-
this.
|
|
544
|
-
for(;t>0;){const i=t-1>>1,n=this.
|
|
563
|
+
if(1===t){const t=this.Qi.pop()
|
|
564
|
+
return this.Xi.clear(),t}const e=this.Qi[0],i=this.Qi.pop()
|
|
565
|
+
return this.Qi[0]=i,this.Xi.delete(e),this.Xi.set(i,0),this.tn(0),e}update(t){const e=this.Xi.get(t)
|
|
566
|
+
void 0!==e?(this.Zi(e),this.tn(e)):this.F(t)}nn(){return!this.Qi.length}sn(t,e){const i=this.Qi[t],n=this.Qi[e]
|
|
567
|
+
this.Qi[t]=n,this.Qi[e]=i,this.Xi.set(i,e),this.Xi.set(n,t)}Zi(t){const e=this.Qi[t]
|
|
568
|
+
for(;t>0;){const i=t-1>>1,n=this.Qi[i]
|
|
545
569
|
if(this.compare(e,n)>=0)break
|
|
546
|
-
this.
|
|
570
|
+
this.Qi[t]=n,this.Xi.set(n,t),t=i}this.Qi[t]=e,this.Xi.set(e,t)}tn(t){const e=this.Qi[t],i=this.Qi.length,n=i>>1
|
|
547
571
|
for(;n>t;){const n=1+(t<<1),s=n+1
|
|
548
572
|
let r=t,o=e
|
|
549
|
-
const h=this.
|
|
550
|
-
if(0>this.compare(h,o)&&(r=n,o=h),i>s){const t=this.
|
|
573
|
+
const h=this.Qi[n]
|
|
574
|
+
if(0>this.compare(h,o)&&(r=n,o=h),i>s){const t=this.Qi[s]
|
|
551
575
|
0>this.compare(t,o)&&(r=s,o=t)}if(r===t)break
|
|
552
|
-
this.
|
|
553
|
-
class
|
|
576
|
+
this.Qi[t]=o,this.Xi.set(o,t),t=r}this.Qi[t]=e,this.Xi.set(e,t)}}const at={enabled:!0,areaThreshold:1}
|
|
577
|
+
class lt{constructor(t){this.stats={pointsRemovedByVisvalingam:0,originalPointCount:0},this.config=t}rn(t){this.config=t}hn(t){if(2>=t.points.length)return t
|
|
554
578
|
if(!this.config.enabled)return t
|
|
555
579
|
this.stats.originalPointCount+=t.points.length
|
|
556
580
|
const e=t.points
|
|
557
581
|
if(5>e.length)return t
|
|
558
582
|
let i=e
|
|
559
|
-
return i=this.
|
|
560
|
-
const i=t.length,n=t.map((t,e)=>({index:e,
|
|
561
|
-
for(let t=0;n.length>t;t++)n[t].
|
|
562
|
-
const s=new ht((t,e)=>t.
|
|
583
|
+
return i=this.an(i,this.config.areaThreshold),3>i.length?t:{...t,points:i}}an(t,e){if(3>=t.length)return t
|
|
584
|
+
const i=t.length,n=t.map((t,e)=>({index:e,ln:1/0,cn:null,next:null}))
|
|
585
|
+
for(let t=0;n.length>t;t++)n[t].cn=n[t-1]||null,n[t].next=n[t+1]||null
|
|
586
|
+
const s=new ht((t,e)=>t.ln-e.ln)
|
|
563
587
|
for(let e=1;n.length-1>e;e++){const i=n[e]
|
|
564
|
-
i.
|
|
565
|
-
for(;!s.
|
|
566
|
-
if(!i||i.
|
|
567
|
-
i.
|
|
588
|
+
i.ln=this.un(t[i.cn.index],t[i.index],t[i.next.index]),s.F(i)}let r=i
|
|
589
|
+
for(;!s.nn()&&r>3;){const i=s.en()
|
|
590
|
+
if(!i||i.ln>e)break
|
|
591
|
+
i.cn&&(i.cn.next=i.next),i.next&&(i.next.cn=i.cn),r--,i.cn&&i.cn.cn&&(i.cn.ln=this.un(t[i.cn.cn.index],t[i.cn.index],t[i.next.index]),s.update(i.cn)),i.next&&i.next.next&&(i.next.ln=this.un(t[i.cn.index],t[i.next.index],t[i.next.next.index]),s.update(i.next))}const o=[]
|
|
568
592
|
let h=n[0]
|
|
569
593
|
for(;h;)o.push(t[h.index]),h=h.next
|
|
570
|
-
return this.stats.pointsRemovedByVisvalingam+=i-o.length,o}
|
|
571
|
-
class ft{constructor(t){this.curveSteps=null,this.
|
|
594
|
+
return this.stats.pointsRemovedByVisvalingam+=i-o.length,o}un(t,e,i){return Math.abs((t.x*(e.y-i.y)+e.x*(i.y-t.y)+i.x*(t.y-e.y))/2)}getStats(){return{...this.stats}}fn(){this.stats={pointsRemovedByVisvalingam:0,originalPointCount:0}}}const ct={distanceTolerance:.5,angleTolerance:.2},ut=1e-6
|
|
595
|
+
class ft{constructor(t){this.curveSteps=null,this.dn={...ct,...t}}yn(t){this.dn={...ct,...t}}pn(t){if(null==t)return void(this.curveSteps=null)
|
|
572
596
|
if(!Number.isFinite(t))return void(this.curveSteps=null)
|
|
573
597
|
const e=Math.round(t)
|
|
574
|
-
this.curveSteps=1>e?null:e}
|
|
598
|
+
this.curveSteps=1>e?null:e}wn(t,e,i){if(null!==this.curveSteps)return this.gn(t,e,i,this.curveSteps)
|
|
575
599
|
const n=[]
|
|
576
|
-
return this.
|
|
600
|
+
return this.vn(t.x,t.y,e.x,e.y,i.x,i.y,n),this.mn(i.x,i.y,n),n}xn(t,e,i,n){if(null!==this.curveSteps)return this.bn(t,e,i,n,this.curveSteps)
|
|
577
601
|
const s=[]
|
|
578
|
-
return this.
|
|
579
|
-
for(let r=1;n>=r;r++){const o=r/n,h=this.
|
|
580
|
-
this.
|
|
581
|
-
for(let o=1;s>=o;o++){const h=o/s,a=this.
|
|
582
|
-
this.
|
|
583
|
-
const a=(t+i)/2,
|
|
584
|
-
if(w>ut){if(v*(y*y+p*p)>=w*w){const h=this.
|
|
585
|
-
if(0>=h)return void this.
|
|
586
|
-
{const a=i-t,
|
|
587
|
-
if(h>Math.abs(Math.atan2(a*u-c
|
|
588
|
-
if(0===s){if(v>=(i-t)*(i-t)+(n-e)*(n-e))return void this.
|
|
589
|
-
if(r>0&&1>r&&v*s>=w*w)return void this.
|
|
590
|
-
const
|
|
602
|
+
return this.Sn(t.x,t.y,e.x,e.y,i.x,i.y,n.x,n.y,s),this.mn(n.x,n.y,s),s}_n(t,e,i){return t+(e-t)*i}gn(t,e,i,n){const s=[]
|
|
603
|
+
for(let r=1;n>=r;r++){const o=r/n,h=this._n(t.x,e.x,o),a=this._n(t.y,e.y,o),l=this._n(e.x,i.x,o),c=this._n(e.y,i.y,o),u=this._n(h,l,o),f=this._n(a,c,o)
|
|
604
|
+
this.mn(u,f,s)}return s}bn(t,e,i,n,s){const r=[]
|
|
605
|
+
for(let o=1;s>=o;o++){const h=o/s,a=this._n(t.x,e.x,h),l=this._n(t.y,e.y,h),c=this._n(e.x,i.x,h),u=this._n(e.y,i.y,h),f=this._n(i.x,n.x,h),d=this._n(i.y,n.y,h),y=this._n(a,c,h),p=this._n(l,u,h),w=this._n(c,f,h),g=this._n(u,d,h),v=this._n(y,w,h),m=this._n(p,g,h)
|
|
606
|
+
this.mn(v,m,r)}return r}vn(t,e,i,n,s,r,o,h=0){if(h>16)return
|
|
607
|
+
const a=(t+i)/2,l=(e+n)/2,c=(i+s)/2,u=(n+r)/2,f=(a+c)/2,d=(l+u)/2,y=s-t,p=r-e,w=Math.abs((i-s)*p-(n-r)*y),g=this.dn.distanceTolerance??ct.distanceTolerance,v=g*g
|
|
608
|
+
if(w>ut){if(v*(y*y+p*p)>=w*w){const h=this.dn.angleTolerance??ct.angleTolerance
|
|
609
|
+
if(0>=h)return void this.mn(i,n,o)
|
|
610
|
+
{const a=i-t,l=n-e,c=s-i,u=r-n
|
|
611
|
+
if(h>Math.abs(Math.atan2(a*u-l*c,a*c+l*u)))return void this.mn(i,n,o)}}}else{const s=y*y+p*p
|
|
612
|
+
if(0===s){if(v>=(i-t)*(i-t)+(n-e)*(n-e))return void this.mn(i,n,o)}else{const r=((i-t)*y+(n-e)*p)/s
|
|
613
|
+
if(r>0&&1>r&&v*s>=w*w)return void this.mn(i,n,o)}}this.vn(t,e,a,l,f,d,o,h+1),this.vn(f,d,c,u,s,r,o,h+1)}Sn(t,e,i,n,s,r,o,h,a,l=0){if(l>16)return
|
|
614
|
+
const c=(t+i)/2,u=(e+n)/2,f=(i+s)/2,d=(n+r)/2,y=(s+o)/2,p=(r+h)/2,w=(c+f)/2,g=(u+d)/2,v=(f+y)/2,m=(d+p)/2,x=(w+v)/2,b=(g+m)/2,S=o-t,_=h-e,E=Math.abs((i-o)*_-(n-h)*S),T=Math.abs((s-o)*_-(r-h)*S),A=this.dn.distanceTolerance??ct.distanceTolerance,M=A*A
|
|
591
615
|
let I=0
|
|
592
|
-
switch(E>ut&&(I|=1),T>ut&&(I|=2),I){case 0:const
|
|
593
|
-
if(0===
|
|
594
|
-
if(o>0&&1>o&&h>0&&1>h&&M*
|
|
595
|
-
case 1:if(M*(S*S+_*_)>=T*T){const t=this.
|
|
596
|
-
if(0>=t)return this.
|
|
597
|
-
{const e=s-i,
|
|
598
|
-
if(t>Math.abs(Math.atan2(e*u-c
|
|
599
|
-
case 2:if(M*(S*S+_*_)>=E*E){const o=this.
|
|
600
|
-
if(0>=o)return this.
|
|
601
|
-
{const h=i-t,
|
|
602
|
-
if(o>Math.abs(Math.atan2(h*u-c
|
|
603
|
-
case 3:if(M*(S*S+_*_)>=(E+T)*(E+T)){const
|
|
604
|
-
if(0>=
|
|
605
|
-
{const
|
|
606
|
-
if(
|
|
616
|
+
switch(E>ut&&(I|=1),T>ut&&(I|=2),I){case 0:const l=S*S+_*_
|
|
617
|
+
if(0===l){if(M>=(i-t)*(i-t)+(n-e)*(n-e)&&M>=(s-t)*(s-t)+(r-e)*(r-e))return this.mn(i,n,a),void this.mn(s,r,a)}else{const o=((i-t)*S+(n-e)*_)/l,h=((s-t)*S+(r-e)*_)/l
|
|
618
|
+
if(o>0&&1>o&&h>0&&1>h&&M*l>=(E+T)*(E+T))return this.mn(i,n,a),void this.mn(s,r,a)}break
|
|
619
|
+
case 1:if(M*(S*S+_*_)>=T*T){const t=this.dn.angleTolerance??ct.angleTolerance
|
|
620
|
+
if(0>=t)return this.mn(i,n,a),void this.mn(s,r,a)
|
|
621
|
+
{const e=s-i,l=r-n,c=o-s,u=h-r
|
|
622
|
+
if(t>Math.abs(Math.atan2(e*u-l*c,e*c+l*u)))return this.mn(i,n,a),void this.mn(s,r,a)}}break
|
|
623
|
+
case 2:if(M*(S*S+_*_)>=E*E){const o=this.dn.angleTolerance??ct.angleTolerance
|
|
624
|
+
if(0>=o)return this.mn(i,n,a),void this.mn(s,r,a)
|
|
625
|
+
{const h=i-t,l=n-e,c=s-i,u=r-n
|
|
626
|
+
if(o>Math.abs(Math.atan2(h*u-l*c,h*c+l*u)))return this.mn(i,n,a),void this.mn(s,r,a)}}break
|
|
627
|
+
case 3:if(M*(S*S+_*_)>=(E+T)*(E+T)){const l=this.dn.angleTolerance??ct.angleTolerance
|
|
628
|
+
if(0>=l)return this.mn(i,n,a),void this.mn(s,r,a)
|
|
629
|
+
{const c=i-t,u=n-e,f=s-i,d=r-n,y=o-s,p=h-r
|
|
630
|
+
if(l>Math.abs(Math.atan2(c*d-u*f,c*f+u*d))+Math.abs(Math.atan2(f*p-d*y,f*y+d*p)))return this.mn(i,n,a),void this.mn(s,r,a)}}}this.Sn(t,e,c,u,w,g,x,b,a,l+1),this.Sn(x,b,v,m,y,p,o,h,a,l+1)}mn(t,e,i){const n=new Y(t,e)
|
|
607
631
|
if(0===i.length)return void i.push(n)
|
|
608
632
|
const s=i[i.length-1],r=n.x-s.x,o=n.y-s.y
|
|
609
|
-
r*r+o*o>1e-12&&i.push(n)}}class dt{constructor(t,e){this.
|
|
633
|
+
r*r+o*o>1e-12&&i.push(n)}}class dt{constructor(t,e){this.En=0,this.Tn=0,this.An=[],this.Mn=null,this.In=null,this.Fn={min:new Y(1/0,1/0),max:new Y(-1/0,-1/0)},this.Ln=[],this.Gn=[],this.On=[],this.Cn=new Y(0,0),this.kn=new ft(t),this.Dn=new lt({...at,...e})}setPosition(t,e){this.Cn.set(t,e)}Bn(t,e){this.Cn.x+=t,this.Cn.y+=e}Nn(t,e){this.An.length>0&&this.Un(),this.En=t,this.Tn=e,this.An=[],this.Fn.min.set(1/0,1/0),this.Fn.max.set(-1/0,-1/0),this.Gn.push(this.Cn.clone())}Un(){this.Mn&&this.Pn(),this.An.length>0&&(this.Ln.push({$n:this.En,zn:this.An,bounds:{min:{x:this.Fn.min.x,y:this.Fn.min.y},max:{x:this.Fn.max.x,y:this.Fn.max.y}}}),this.On.push(this.Tn)),this.An=[]}Wn(t,e){this.Mn&&this.Pn(),this.In=new Y(t,e),this.Rn(this.In),this.Mn={points:[this.In],glyphIndex:this.En}}jn(t,e){if(!this.Mn||!this.In)return
|
|
610
634
|
const i=new Y(t,e)
|
|
611
|
-
this.
|
|
612
|
-
const s=this.
|
|
613
|
-
if(ut>Math.abs((r.x-o.x)*(o.y-s.y)-(r.y-o.y)*(o.x-s.x)))return void this
|
|
614
|
-
const h=this.
|
|
635
|
+
this.Rn(i),this.Mn.points.push(i),this.In=i}Hn(t,e,i,n){if(!this.Mn||!this.In)return
|
|
636
|
+
const s=this.In,r=new Y(t,e),o=new Y(i,n)
|
|
637
|
+
if(ut>Math.abs((r.x-o.x)*(o.y-s.y)-(r.y-o.y)*(o.x-s.x)))return void this.jn(i,n)
|
|
638
|
+
const h=this.kn.wn(s,r,o)
|
|
615
639
|
for(let t=0;h.length>t;t++){const e=h[t]
|
|
616
|
-
this.
|
|
617
|
-
const o=this.
|
|
618
|
-
if(ut>Math.abs((h.x-
|
|
619
|
-
const f=this.
|
|
640
|
+
this.Rn(e),this.Mn.points.push(e)}this.In=o}Vn(t,e,i,n,s,r){if(!this.Mn||!this.In)return
|
|
641
|
+
const o=this.In,h=new Y(t,e),a=new Y(i,n),l=new Y(s,r),c=l.x-o.x,u=l.y-o.y
|
|
642
|
+
if(ut>Math.abs((h.x-l.x)*u-(h.y-l.y)*c)&&ut>Math.abs((a.x-l.x)*u-(a.y-l.y)*c))return void this.jn(s,r)
|
|
643
|
+
const f=this.kn.xn(o,h,a,l)
|
|
620
644
|
for(let t=0;f.length>t;t++){const e=f[t]
|
|
621
|
-
this.
|
|
622
|
-
const t=this.
|
|
623
|
-
this.
|
|
624
|
-
this.
|
|
625
|
-
if(this.
|
|
645
|
+
this.Rn(e),this.Mn.points.push(e)}this.In=l}qn(){if(!this.Mn||!this.In)return
|
|
646
|
+
const t=this.Mn.points[0]
|
|
647
|
+
this.In.equals(t)||this.Mn.points.push(t),this.Pn()}Pn(){if(this.Mn){const t=this.Dn.hn(this.Mn)
|
|
648
|
+
this.An.push(t),this.Mn=null,this.In=null}}Rn(t){this.Fn.min.x=Math.min(this.Fn.min.x,t.x),this.Fn.min.y=Math.min(this.Fn.min.y,t.y),this.Fn.max.x=Math.max(this.Fn.max.x,t.x),this.Fn.max.y=Math.max(this.Fn.max.y,t.y)}Yn(){return this.An.length>0&&this.Un(),this.Ln}Jn(){return this.Gn}Kn(){return this.On}reset(){this.Ln=[],this.Gn=[],this.On=[],this.An=[],this.Mn=null,this.In=null,this.En=0,this.Tn=0,this.Cn.set(0,0),this.Fn={min:new Y(1/0,1/0),max:new Y(-1/0,-1/0)}}yn(t){this.kn.yn(t)}pn(t){this.kn.pn(t)}Qn(t){this.Dn.rn({...at,...t})}Xn(){return this.Dn.getStats()}}class yt{constructor(){this.Zn=null,this.ts=null,this.es=null,this.ns=null,this.ss=null,this.rs=0,this.position={x:0,y:0}}setPosition(t,e){this.position.x=t,this.position.y=e,this.hs&&this.hs.setPosition(t,e)}Bn(t,e){this.position.x+=t,this.position.y+=e,this.hs&&this.hs.Bn(t,e)}ls(t){this.hs=t}cs(t,e){if(!t||!t.module||!t.hb)throw Error("Invalid font object")
|
|
649
|
+
if(this.hs=e,this.rs)return
|
|
626
650
|
const i=t.module
|
|
627
|
-
this.
|
|
628
|
-
return this.
|
|
651
|
+
this.Zn=i.us((t,e,i,n,s)=>{this.hs?.Wn(n,s)},"viiiffi"),this.ts=i.us((t,e,i,n,s)=>{this.hs?.jn(n,s)},"viiiffi"),this.es=i.us((t,e,i,n,s,r,o)=>{this.hs?.Hn(n,s,r,o)},"viiiffffi"),this.ns=i.us((t,e,i,n,s,r,o,h,a)=>{this.hs?.Vn(n,s,r,o,h,a)},"viiiffffffi"),this.ss=i.us(()=>{this.hs?.qn()},"viiii"),this.rs=i.exports.fs(),i.exports.ds(this.rs,this.Zn,0,0),i.exports.ys(this.rs,this.ts,0,0),i.exports.ps(this.rs,this.es,0,0),i.exports.ws(this.rs,this.ns,0,0),i.exports.gs(this.rs,this.ss,0,0)}vs(){if(!this.rs)throw Error("Draw functions not initialized")
|
|
652
|
+
return this.rs}destroy(t){if(!t||!t.module||!t.hb)return
|
|
629
653
|
const e=t.module
|
|
630
|
-
try{this.
|
|
631
|
-
class wt{constructor(t,e){this.
|
|
654
|
+
try{this.rs&&(e.exports.xs(this.rs),this.rs=0),null!==this.Zn&&(e.bs(this.Zn),this.Zn=null),null!==this.ts&&(e.bs(this.ts),this.ts=null),null!==this.es&&(e.bs(this.es),this.es=null),null!==this.ns&&(e.bs(this.ns),this.ns=null),null!==this.ss&&(e.bs(this.ss),this.ss=null)}catch(t){a.warn("Error destroying draw callbacks:",t)}this.hs=void 0}}const pt=new WeakMap
|
|
655
|
+
class wt{constructor(t,e){this.Ss="default",this._s="default",this.Es=new Set,this.Ts=[],this.As=[],this.Ms=[],this.cache=t,this.Kt=e,this.tessellator=new st,this.Is=new rt,this.Fs=new ot,this.hs=new dt,this.Ls=(()=>{const t=this.Kt.module,e=pt.get(t)
|
|
632
656
|
if(e)return e
|
|
633
657
|
const i=new yt
|
|
634
|
-
return pt.set(t,i),i})(),this.
|
|
658
|
+
return pt.set(t,i),i})(),this.Ls.cs(this.Kt,this.hs),this.Gs=X,this.Os=Z,this.Cs=tt}Xn(){return this.hs.Xn()}yn(t){this.dn=t,this.hs.yn(t),this.ks()}pn(t){if(null==t)this.curveSteps=void 0
|
|
635
659
|
else if(Number.isFinite(t)){const e=Math.round(t)
|
|
636
660
|
this.curveSteps=1>e?void 0:e}else this.curveSteps=void 0
|
|
637
|
-
this.
|
|
638
|
-
const t=this.
|
|
639
|
-
return`cf:${t.toFixed(4)},${e.toFixed(4)}`})(),`opt:${this.
|
|
640
|
-
for(let i=0;t.length>i;i++)e+=t[i].length}const
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
661
|
+
this.hs.pn(this.curveSteps),this.ks()}Qn(t){this.Ds=t,this.hs.Qn(t),this.ks()}Bs(t){this.Ss=t,this.ks()}ks(){this._s=`${this.Ss}__${this.Ns()}`}Ns(){return[(()=>{if(void 0!==this.curveSteps)return"cf:steps:"+this.curveSteps
|
|
662
|
+
const t=this.dn?.distanceTolerance??ct.distanceTolerance,e=this.dn?.angleTolerance??ct.angleTolerance
|
|
663
|
+
return`cf:${t.toFixed(4)},${e.toFixed(4)}`})(),`opt:${this.Ds?.enabled??1?1:0},${(this.Ds?.areaThreshold??1).toFixed(4)}`].join("|")}Us(t,e,i,n,r,o=!1,a){if(h){let e=0
|
|
664
|
+
for(let i=0;t.length>i;i++)e+=t[i].length}const l=this.Ms
|
|
665
|
+
l.length=0
|
|
666
|
+
let c=0,u=0,f=0,d=0,y=0
|
|
667
|
+
const p=(t,e,i,n)=>{const s=y
|
|
668
|
+
let r=l[c]
|
|
669
|
+
return r?(r.data=t,r.px=e,r.Ps=i,r.$s=n,r.zs=s):(r={data:t,px:e,Ps:i,$s:n,zs:s},l[c]=r),c++,u+=t.vertices.length,f+=t.normals.length,d+=t.indices.length,y+=t.vertices.length/3,s},w=[],g={min:{x:1/0,y:1/0,z:0},max:{x:-1/0,y:-1/0,z:e}}
|
|
644
670
|
for(let r=0;t.length>r;r++){const h=t[r]
|
|
645
|
-
for(const t of h){const r=t.position.x,h=t.position.y,
|
|
646
|
-
for(const e of t.glyphs)
|
|
671
|
+
for(const t of h){const r=t.position.x,h=t.position.y,l=t.position.z,c=[]
|
|
672
|
+
for(const e of t.glyphs)c.push(this.Ws(e.g))
|
|
647
673
|
let u
|
|
648
|
-
if(t.glyphs.length>1){const e=`${this.
|
|
674
|
+
if(t.glyphs.length>1){const e=`${this._s}_${t.text}`,i=this.Cs.get(e)
|
|
649
675
|
let n=!1
|
|
650
|
-
if(i&&i.
|
|
651
|
-
for(let e=0;t.glyphs.length>e;e++){const s=t.glyphs[e],r=i.
|
|
652
|
-
if(i.
|
|
676
|
+
if(i&&i.Rs.length===t.glyphs.length){n=!0
|
|
677
|
+
for(let e=0;t.glyphs.length>e;e++){const s=t.glyphs[e],r=i.js[e]
|
|
678
|
+
if(i.Rs[e]!==s.g||r.x!==(s.x??0)||r.y!==(s.y??0)){n=!1
|
|
653
679
|
break}}}if(n&&i)u=i.groups
|
|
654
|
-
else{const i=t.glyphs.
|
|
655
|
-
|
|
680
|
+
else{const i=t.glyphs.length
|
|
681
|
+
if(i>this.Ts.length)for(let t=this.Ts.length;i>t;t++)this.Ts.push(new J(0,0,0))
|
|
682
|
+
this.Ts.length=i
|
|
683
|
+
for(let e=0;i>e;e++){const i=t.glyphs[e],n=this.Ts[e]
|
|
684
|
+
n.x=i.x??0,n.y=i.y??0,n.z=0}u=this.Fs.ji(c,this.Ts),this.Cs.set(e,{Rs:t.glyphs.map(t=>t.g),js:t.glyphs.map(t=>({x:t.x??0,y:t.y??0})),groups:u})}}else u=[[0]]
|
|
656
685
|
const f=o
|
|
657
686
|
let d=u
|
|
658
687
|
if(a&&a.size>0){d=[]
|
|
659
688
|
for(const e of u)if(e.length>1){const i=[],n=[]
|
|
660
|
-
for(const s of e)a.has(t.glyphs[s].
|
|
661
|
-
i.length>0&&d.push(i),n.length>0&&d.push(n)}else d.push(e)}for(const o of d)if(o.length>1&&!f){const s=o.map(e=>t.glyphs[e]),a=this.
|
|
662
|
-
let u=this.
|
|
663
|
-
if(!u){const i=
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
for(let
|
|
667
|
-
|
|
668
|
-
if(
|
|
669
|
-
|
|
670
|
-
|
|
689
|
+
for(const s of e)a.has(t.glyphs[s].Hs)?i.push(s):n.push(s)
|
|
690
|
+
i.length>0&&d.push(i),n.length>0&&d.push(n)}else d.push(e)}for(const o of d)if(o.length>1&&!f){const s=o.map(e=>t.glyphs[e]),a=this.Vs(s,e,i)
|
|
691
|
+
let u=this.Os.get(a)
|
|
692
|
+
if(!u){const i=this.As
|
|
693
|
+
let r=0
|
|
694
|
+
const h=s[0].x??0,l=s[0].y??0
|
|
695
|
+
for(let e=0;o.length>e;e++){const n=o[e],s=c[n],a=t.glyphs[n],u=(a.x??0)-h,f=(a.y??0)-l
|
|
696
|
+
for(const t of s.zn){const e=t.points,n=e.length
|
|
697
|
+
if(3>n)continue
|
|
698
|
+
const s=n>1&&e[0].x===e[n-1].x&&e[0].y===e[n-1].y?n-1:n,o=2*(s+1)
|
|
699
|
+
let h=i[r]
|
|
700
|
+
!h||o>h.length?(h=Array(o),i[r]=h):h.length=o
|
|
701
|
+
let a=0
|
|
702
|
+
for(let t=0;s>t;t++){const i=e[t]
|
|
703
|
+
h[a++]=i.x+u,h[a++]=i.y+f}2>a||(h[a++]=h[0],h[a++]=h[1]),r++}}i.length=r,u=this.qs(i,e,n),this.Os.set(a,u)}const f=s[0],d=p(u,r+(f.x??0),h+(f.y??0),l),y=u.vertices.length/3
|
|
704
|
+
for(let i=0;o.length>i;i++){const n=o[i],s=t.glyphs[n],a=this.Ys(s,d,y,r+(s.x??0),h+(s.y??0),l,c[n],e)
|
|
705
|
+
w.push(a),this.Js(a.bounds,g)}}else for(const a of o){const o=t.glyphs[a],u=c[a],f=r+(o.x??0),d=h+(o.y??0),y=l
|
|
706
|
+
if(0===u.zn.length){const t=this.Ys(o,0,0,f,d,y,u,e)
|
|
707
|
+
w.push(t)
|
|
708
|
+
continue}const v=s(this._s,o.g,e,i)
|
|
671
709
|
let m=this.cache.get(v)
|
|
672
|
-
m?m.
|
|
673
|
-
const x=
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
for(let t=0;
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
710
|
+
m?m.Ks++:(m=this.Qs(u,e,i,n),this.cache.set(v,m))
|
|
711
|
+
const x=p(m,f,d,y),b=this.Ys(o,x,m.vertices.length/3,f,d,y,u,e)
|
|
712
|
+
w.push(b),this.Js(b.bounds,g)}}}l.length=c
|
|
713
|
+
const v=new Float32Array(u),m=new Float32Array(f),x=new Uint32Array(d)
|
|
714
|
+
let b=0,S=0,_=0
|
|
715
|
+
for(let t=0;l.length>t;t++){const e=l[t],i=e.data.vertices,n=e.data.normals,s=e.data.indices,o=e.px*r,h=e.Ps*r,a=e.$s*r,c=i.length
|
|
716
|
+
let u=b
|
|
717
|
+
for(let t=0;c>t;t+=3)v[u]=i[t]*r+o,v[u+1]=i[t+1]*r+h,v[u+2]=i[t+2]*r+a,u+=3
|
|
718
|
+
b=u,m.set(n,S),S+=n.length
|
|
719
|
+
const f=e.zs,d=s.length
|
|
720
|
+
let y=_
|
|
721
|
+
for(let t=0;d>t;t++)x[y++]=s[t]+f
|
|
722
|
+
_=y}g.min.x*=r,g.min.y*=r,g.min.z*=r,g.max.x*=r,g.max.y*=r,g.max.z*=r
|
|
723
|
+
for(let t=0;w.length>t;t++)w[t].bounds.min.x*=r,w[t].bounds.min.y*=r,w[t].bounds.min.z*=r,w[t].bounds.max.x*=r,w[t].bounds.max.y*=r,w[t].bounds.max.z*=r
|
|
724
|
+
return{vertices:v,normals:m,indices:x,Xs:w,planeBounds:g}}Vs(t,e,i){if(0===t.length)return""
|
|
683
725
|
const n=t[0].x??0,s=t[0].y??0,r=t.map(t=>`${t.g}:${(t.x??0)-n},${(t.y??0)-s}`).join("|")
|
|
684
|
-
return`${this.
|
|
685
|
-
const e=`${this.
|
|
726
|
+
return`${this._s}_${r}_${Math.round(1e3*e)/1e3}_${i}`}Ys(t,e,i,n,s,r,o,h){return{Zs:t.Hs,tr:t.tr,zs:e,er:i,bounds:{min:{x:o.bounds.min.x+n,y:o.bounds.min.y+s,z:r},max:{x:o.bounds.max.x+n,y:o.bounds.max.y+s,z:r+h}}}}Ws(t){if(this.Es.has(t))return{$n:t,zn:[],bounds:{min:{x:0,y:0},max:{x:0,y:0}}}
|
|
727
|
+
const e=`${this._s}_${t}`,i=this.Gs.get(e)
|
|
686
728
|
if(i)return i
|
|
687
|
-
this.
|
|
688
|
-
const n=this.
|
|
689
|
-
return 0===n.
|
|
690
|
-
return this.
|
|
691
|
-
let s=1/0,r=1/0,o=1/0,h=-1/0,a=-1/0,
|
|
692
|
-
for(let t=0;n.length>t;t+=3){const e=n[t],i=n[t+1],
|
|
693
|
-
s>e&&(s=e),e>h&&(h=e),r>i&&(r=i),i>a&&(a=i),o>
|
|
694
|
-
return{geometry:t,vertices:i.vertices,normals:i.normals,indices:i.indices,bounds:{min:
|
|
695
|
-
return this.
|
|
696
|
-
i.x>s.x&&(i.x=s.x),i.y>s.y&&(i.y=s.y),i.z>s.z&&(i.z=s.z),r.x>n.x&&(n.x=r.x),r.y>n.y&&(n.y=r.y),r.z>n.z&&(n.z=r.z)}
|
|
697
|
-
return t.forEach((t,o)=>{const h=this.
|
|
698
|
-
r.push(h)}),r}finally{}}
|
|
699
|
-
"rtl"===o&&h.
|
|
729
|
+
this.Ls.ls(this.hs),this.hs.reset(),this.hs.Nn(t,0),this.Kt.module.exports.ir(this.Kt.font.nr,t,this.Ls.vs(),0),this.hs.Un()
|
|
730
|
+
const n=this.hs.Yn()[0]||{$n:t,zn:[],bounds:{min:{x:0,y:0},max:{x:0,y:0}}}
|
|
731
|
+
return 0===n.zn.length&&this.Es.add(t),this.Gs.set(e,n),n}qs(t,e,i){const n=this.tessellator.Ci(t,!0,i,0!==e)
|
|
732
|
+
return this.sr(n,e)}sr(t,e){const i=this.Is.Ri(t,e,this.Kt.upem),n=i.vertices
|
|
733
|
+
let s=1/0,r=1/0,o=1/0,h=-1/0,a=-1/0,l=-1/0
|
|
734
|
+
for(let t=0;n.length>t;t+=3){const e=n[t],i=n[t+1],c=n[t+2]
|
|
735
|
+
s>e&&(s=e),e>h&&(h=e),r>i&&(r=i),i>a&&(a=i),o>c&&(o=c),c>l&&(l=c)}const c=new J(s,r,o),u=new J(h,a,l)
|
|
736
|
+
return{geometry:t,vertices:i.vertices,normals:i.normals,indices:i.indices,bounds:{min:c,max:u},Ks:1}}Qs(t,e,i,n){const s=this.tessellator.process(t.zn,i,n,0!==e)
|
|
737
|
+
return this.sr(s,e)}Js(t,e){const i=e.min,n=e.max,s=t.min,r=t.max
|
|
738
|
+
i.x>s.x&&(i.x=s.x),i.y>s.y&&(i.y=s.y),i.z>s.z&&(i.z=s.z),r.x>n.x&&(n.x=r.x),r.y>n.y&&(n.y=r.y),r.z>n.z&&(n.z=r.z)}rr(){return this.cache.getStats()}clearCache(){this.cache.clear(),this.Os.clear(),this.Cs.clear(),this.Gs.clear()}}class gt{constructor(t,e){this.hr=new Map,this.Kt=t,this.ar=e}lr(t,e,i,n,s,r,o){try{const r=[]
|
|
739
|
+
return t.forEach((t,o)=>{const h=this.cr(t,o,e,i,n,s)
|
|
740
|
+
r.push(h)}),r}finally{}}cr(t,i,n,s,r,o){const h=this.Kt.hb.createBuffer()
|
|
741
|
+
"rtl"===o&&h.ur("rtl"),h.Vt(t.text),h.qt()
|
|
700
742
|
const a=e(this.Kt.Yt)
|
|
701
743
|
this.Kt.hb.shape(this.Kt.font,h,a)
|
|
702
|
-
const
|
|
744
|
+
const l=h.json(this.Kt.font)
|
|
703
745
|
h.destroy()
|
|
704
|
-
const
|
|
746
|
+
const c=[]
|
|
705
747
|
let u=[],f=[],d=0,y=0,p=t.Ut,w=-i*n
|
|
706
|
-
const g=s*this.Kt.upem,v=this.
|
|
748
|
+
const g=s*this.Kt.upem,v=this.dr(t,r,s),m=this.yr(t,r),x=t.text,b=x.length,S=l.length
|
|
707
749
|
let _
|
|
708
|
-
for(let e=0;S>e;e++){const n=
|
|
709
|
-
n.
|
|
750
|
+
for(let e=0;S>e;e++){const n=l[e],s=n.Jt,r=x[s],o=r.charCodeAt(0),h=32===o||9===o||10===o||13===o
|
|
751
|
+
n.Hs=t.$t&&s===b-1&&"-"===r?t.Nt:t.Bt+s,n.tr=i,h&&u.length>0&&(c.push({text:f.join(""),glyphs:u,position:new J(d,y,0)}),u=[],f=[])
|
|
710
752
|
const a=p+n.dx,E=w+n.dy
|
|
711
|
-
if(h||(0===u.length&&(d=a,y=E),n.x=a-d,n.y=E-y,u.push(n),f.push(r)),p+=n.ax,w+=n.ay,0!==g&&S-1>e&&(p+=g),h&&(p+=v),0!==m&&S-1>e&&!h){const t=x[
|
|
753
|
+
if(h||(0===u.length&&(d=a,y=E),n.x=a-d,n.y=E-y,u.push(n),f.push(r)),p+=n.ax,w+=n.ay,0!==g&&S-1>e&&(p+=g),h&&(p+=v),0!==m&&S-1>e&&!h){const t=x[l[e+1].Jt],i=void 0!==_?_:T.Z(r)
|
|
712
754
|
if(_=!!t&&T.Z(t),i&&_){let e=!0
|
|
713
|
-
T.tt(t)&&(e=!1),T.et(r)&&(e=!1),T.it(r)&&T.it(t)&&(e=!1),e&&(p+=m)}}else _=void 0}return u.length>0&&
|
|
714
|
-
if(void 0!==t.Ht&&"justify"===e&&!t.Pt){let e=this.
|
|
715
|
-
void 0===e&&(e=M.measureTextWidth(this.Kt," ",i),this.
|
|
716
|
-
return t.Ht>0||0>t.Ht?.04*t.Ht*this.Kt.upem:0}clearCache(){this.
|
|
717
|
-
if("function"==typeof e)return e("fs").
|
|
755
|
+
T.tt(t)&&(e=!1),T.et(r)&&(e=!1),T.it(r)&&T.it(t)&&(e=!1),e&&(p+=m)}}else _=void 0}return u.length>0&&c.push({text:f.join(""),glyphs:u,position:new J(d,y,0)}),c}dr(t,e,i){let n=0
|
|
756
|
+
if(void 0!==t.Ht&&"justify"===e&&!t.Pt){let e=this.hr.get(i)
|
|
757
|
+
void 0===e&&(e=M.measureTextWidth(this.Kt," ",i),this.hr.set(i,e)),t.Ht>0?n=t.Ht*e*.5:0>t.Ht&&(n=t.Ht*e*f)}return n}yr(t,e){if(void 0===t.Ht||"justify"!==e||t.Pt)return 0
|
|
758
|
+
return t.Ht>0||0>t.Ht?.04*t.Ht*this.Kt.upem:0}clearCache(){this.ar.clearCache()}rr(){return this.ar.rr()}}var vt={exports:{}},mt=o({__proto__:null,default:{},pr(...t){const e="undefined"!=typeof globalThis?globalThis.require:void 0
|
|
759
|
+
if("function"==typeof e)return e("fs").pr(...t)
|
|
718
760
|
throw Error("fs not available in this environment")}})
|
|
719
761
|
!(function(t){var e,i=(e="undefined"!=typeof document?document.currentScript?.src:void 0,async function(t={}){function i(){var t=g.buffer
|
|
720
|
-
s.HEAP8=new Int8Array(t),s.HEAPU8=v=new Uint8Array(t),s.HEAP32=new Int32Array(t),s.HEAPU32=new Uint32Array(t),s.HEAPF32=new Float32Array(t),new BigInt64Array(t),new BigUint64Array(t)}function n(t){s.
|
|
762
|
+
s.HEAP8=new Int8Array(t),s.HEAPU8=v=new Uint8Array(t),s.HEAP32=new Int32Array(t),s.HEAPU32=new Uint32Array(t),s.HEAPF32=new Float32Array(t),new BigInt64Array(t),new BigUint64Array(t)}function n(t){s.wr?.(t),x(t="Aborted("+t+")"),b=!0,t+=". Build with -sASSERTIONS for more info."
|
|
721
763
|
var e=new WebAssembly.RuntimeError(t)
|
|
722
764
|
throw w?.(e),e}var s=t,r="object"==typeof window,o="undefined"!=typeof WorkerGlobalScope,h="object"==typeof process&&process.versions?.node&&"renderer"!=process.type,a=(t,e)=>{throw e}
|
|
723
765
|
"undefined"!=typeof __filename?e=__filename:o&&(e=self.location.href)
|
|
724
|
-
var c,
|
|
766
|
+
var l,c,u=""
|
|
725
767
|
if(h){var f=mt
|
|
726
|
-
u="undefined"!=typeof __dirname?__dirname+"/":"",
|
|
727
|
-
return e.open("GET",t,!1),e.responseType="arraybuffer",e.send(null),new Uint8Array(e.response)}),
|
|
768
|
+
u="undefined"!=typeof __dirname?__dirname+"/":"",c=t=>(t=S(t)?new URL(t):t,f.pr(t)),l=async(t,e=!0)=>(t=S(t)?new URL(t):t,f.pr(t,e?void 0:"utf8")),process.argv.length>1&&process.argv[1].replace(/\\/g,"/"),process.argv.slice(2),a=(t,e)=>{throw process.exitCode=t,e}}else if(r||o){try{u=new URL(".",e).href}catch{}o&&(c=t=>{var e=new XMLHttpRequest
|
|
769
|
+
return e.open("GET",t,!1),e.responseType="arraybuffer",e.send(null),new Uint8Array(e.response)}),l=async t=>{if(S(t))return new Promise((e,i)=>{var n=new XMLHttpRequest
|
|
728
770
|
n.open("GET",t,!0),n.responseType="arraybuffer",n.onload=()=>{200==n.status||0==n.status&&n.response?e(n.response):i(n.status)},n.onerror=i,n.send(null)})
|
|
729
771
|
var e=await fetch(t,{credentials:"same-origin"})
|
|
730
772
|
if(e.ok)return e.arrayBuffer()
|
|
731
773
|
throw Error(e.status+" : "+e.url)}}console.log.bind(console)
|
|
732
774
|
var d,y,p,w,g,v,m,x=console.error.bind(console),b=!1,S=t=>t.startsWith("file://"),_=!1,E=0,T=null
|
|
733
775
|
class A{name="ExitStatus"
|
|
734
|
-
constructor(t){this.message=`Program terminated with exit(${t})`,this.status=t}}var M,I,F,L=t=>{for(;t.length>0;)t.shift()(s)},G=[],O=t=>G.push(t),
|
|
735
|
-
a(1,t)},P=()=>D||B>0,$=t=>{y=t,P()||(s.
|
|
776
|
+
constructor(t){this.message=`Program terminated with exit(${t})`,this.status=t}}var M,I,F,L=t=>{for(;t.length>0;)t.shift()(s)},G=[],O=t=>G.push(t),C=[],k=t=>C.push(t),D=!0,B=0,N={},U=t=>{if(t instanceof A||"unwind"==t)return y
|
|
777
|
+
a(1,t)},P=()=>D||B>0,$=t=>{y=t,P()||(s.gr?.(t),b=!0),a(t,new A(t))},z=(t,e)=>Math.ceil(t/e)*e,W=t=>{var e=(t-g.buffer.byteLength+65535)/65536|0
|
|
736
778
|
try{return g.grow(e),i(),1}catch(t){}},R=t=>{const e=t.length
|
|
737
779
|
return[e%128|128,e>>7,...t]},j={si:127,oi:127,ai:126,f:125,d:124,e:111},H=t=>R(Array.from(t,t=>j[t])),V=t=>M.get(t),q=[],Y=(t,e)=>M.set(t,e)
|
|
738
|
-
s.
|
|
780
|
+
s.vr&&(D=s.vr),s.mr&&(x=s.mr),s.br&&(d=s.br),s.Sr=g,s._r=K,s.us=(t,e)=>{var i=(t=>(I||(I=new WeakMap,((t,e)=>{if(I)for(var i=0;0+e>i;i++){var n=V(i)
|
|
739
781
|
n&&I.set(n,i)}})(0,M.length)),I.get(t)||0))(t)
|
|
740
782
|
if(i)return i
|
|
741
783
|
var n=q.length?q.pop():M.grow(1)
|
|
742
784
|
try{Y(n,t)}catch(i){if(!(i instanceof TypeError))throw i
|
|
743
785
|
var s=((t,e)=>{var i=Uint8Array.of(0,97,115,109,1,0,0,0,1,...R([1,96,...H(e.slice(1)),...H("v"===e[0]?"":e[0])]),2,7,1,1,101,1,102,0,0,7,5,1,1,102,0,0),n=new WebAssembly.Module(i)
|
|
744
786
|
return new WebAssembly.Instance(n,{e:{f:t}}).exports.f})(t,e)
|
|
745
|
-
Y(n,s)}return I.set(t,n),n},s.
|
|
746
|
-
var J={
|
|
787
|
+
Y(n,s)}return I.set(t,n),n},s.bs=t=>{I.delete(V(t)),Y(t,null),q.push(t)}
|
|
788
|
+
var J={Er:()=>n(""),Tr(){D=!1,B=0},Ar(t,e){if(N[t]&&(clearTimeout(N[t].id),delete N[t]),!e)return 0
|
|
747
789
|
var i=setTimeout(()=>{delete N[t],(t=>{if(!b)try{t(),(()=>{if(!P())try{y=t=y,$(t)}catch(t){U(t)}var t})()}catch(t){U(t)}})(()=>F(t,performance.now()))},e)
|
|
748
|
-
return N[t]={id:i,
|
|
790
|
+
return N[t]={id:i,Mr:e},0},Ir(t){var e=v.length,i=2147483648
|
|
749
791
|
if((t>>>=0)>i)return!1
|
|
750
792
|
for(var n=1;4>=n;n*=2){var s=e*(1+.2/n),r=Math.min(i,z(Math.max(t,s=Math.min(s,t+100663296)),65536))
|
|
751
|
-
if(W(r))return!0}return!1},
|
|
752
|
-
T=null,t()}})(),K}E++,s.
|
|
753
|
-
var e,r={o:J,
|
|
754
|
-
return s.
|
|
755
|
-
return await WebAssembly.instantiateStreaming(s,i)}catch(t){x("wasm streaming compile failed: "+t),x("falling back to ArrayBuffer instantiation")}return(async(t,e)=>{try{var i=await(async t=>{if(!d)try{var e=await
|
|
793
|
+
if(W(r))return!0}return!1},Fr:$},K=await(async()=>{function t(t){return s._r=K=t.exports,s.Sr=g=K.memory,i(),M=K.Lr,(t=>{s.Gr=t.Or,s.Cr=t.kr,s.Dr=t.Br,s.Nr=t.Ur,s.Pr=t.$r,s.zr=t.Wr,s.Rr=t.jr,s.Hr=t.Vr,s.qr=t.Yr,s.Jr=t.Kr,s.Qr=t.Xr,s.Zr=t.eo,s.io=t.no,s.so=t.ro,s.oo=t.ho,s.ao=t.lo,s.co=t.uo,s.fo=t.do,s.yo=t.po,s.wo=t.vo,s.mo=t.xo,s.bo=t.So,s._o=t.Eo,s.To=t.Ao,s.Mo=t.Io,s.Fo=t.Lo,s.Go=t.Oo,s.Co=t.ko,s.Do=t.ds,s.Bo=t.ys,s.No=t.ps,s.Uo=t.ws,s.Po=t.gs,s.$o=t.fs,s.zo=t.xs,s.Wo=t.Ro,s.jo=t.Ho,s.Vo=t.qo,s.Yo=t.Jo,s.Ko=t.Qo,s.Xo=t.ir,s.Zo=t.th,s.eh=t.ih,s.nh=t.sh,s.rh=t.oh,s.hh=t.ah,s.uh=t.fh,s.dh=t.yh,s.ph=t.wh,s.gh=t.mh,s.xh=t.bh,s.Sh=t._h,F=t.Eh})(K),(()=>{if(E--,s.Th?.(E),0==E&&T){var t=T
|
|
794
|
+
T=null,t()}})(),K}E++,s.Th?.(E)
|
|
795
|
+
var e,r={o:J,Ah:J}
|
|
796
|
+
return s.Mh?new Promise(e=>{s.Mh(r,i=>{e(t(i))})}):(m??=(e="hb.wasm",s.Ih?s.Ih(e,u):u+e),t((await(async function(t,e,i){if(!t&&!S(e)&&!h)try{var s=fetch(e,{credentials:"same-origin"})
|
|
797
|
+
return await WebAssembly.instantiateStreaming(s,i)}catch(t){x("wasm streaming compile failed: "+t),x("falling back to ArrayBuffer instantiation")}return(async(t,e)=>{try{var i=await(async t=>{if(!d)try{var e=await l(t)
|
|
756
798
|
return new Uint8Array(e)}catch{}return(t=>{if(t==m&&d)return new Uint8Array(d)
|
|
757
|
-
if(
|
|
799
|
+
if(c)return c(t)
|
|
758
800
|
throw"both async and sync fetching of the wasm failed"})(t)})(t)
|
|
759
|
-
return await WebAssembly.instantiate(i,e)}catch(t){x("failed to asynchronously prepare wasm: "+t),n(t)}})(e,i)})(d,m,r)).
|
|
760
|
-
return(()=>{if(s.
|
|
761
|
-
L(G)})())}E>0?T=t:((()=>{if(s.
|
|
762
|
-
L(
|
|
801
|
+
return await WebAssembly.instantiate(i,e)}catch(t){x("failed to asynchronously prepare wasm: "+t),n(t)}})(e,i)})(d,m,r)).Fh))})()
|
|
802
|
+
return(()=>{if(s.Lh)for("function"==typeof s.Lh&&(s.Lh=[s.Lh]);s.Lh.length>0;)s.Lh.shift()()})(),(function t(){function e(){s.Gh=!0,b||(_=!0,K.Oh(),p?.(s),s.Ch?.(),(()=>{if(s.kh)for("function"==typeof s.kh&&(s.kh=[s.kh]);s.kh.length;)O(s.kh.shift())
|
|
803
|
+
L(G)})())}E>0?T=t:((()=>{if(s.Dh)for("function"==typeof s.Dh&&(s.Dh=[s.Dh]);s.Dh.length;)k(s.Dh.shift())
|
|
804
|
+
L(C)})(),E>0?T=t:s.setStatus?(s.setStatus("Running..."),setTimeout(()=>{setTimeout(()=>s.setStatus(""),1),e()},1)):e())})(),_?s:new Promise((t,e)=>{p=t,w=e})})
|
|
763
805
|
t.exports=i,t.exports.default=i})(vt)
|
|
764
806
|
var xt=r(vt.exports),bt={exports:{}}
|
|
765
|
-
try{bt.exports=t=>{function e(t){return(255&t.charCodeAt(0))<<24|(255&t.charCodeAt(1))<<16|(255&t.charCodeAt(2))<<8|255&t.charCodeAt(3)}function i(e){var i=s.
|
|
807
|
+
try{bt.exports=t=>{function e(t){return(255&t.charCodeAt(0))<<24|(255&t.charCodeAt(1))<<16|(255&t.charCodeAt(2))<<8|255&t.charCodeAt(3)}function i(e){var i=s.Oo(e.length+1)
|
|
766
808
|
for(let n=0;e.length>n;++n){const s=e.charCodeAt(n)
|
|
767
809
|
if(s>127)throw Error("Expected ASCII text")
|
|
768
|
-
t.HEAPU8[i+n]=s}return t.HEAPU8[i+e.length]=0,{
|
|
769
|
-
n&&(n=n.split(","),r=s.
|
|
770
|
-
s.
|
|
771
|
-
let o=t.
|
|
772
|
-
var a=o(t=>{s.
|
|
773
|
-
return{Ue(e){var i=s.
|
|
810
|
+
t.HEAPU8[i+n]=s}return t.HEAPU8[i+e.length]=0,{nr:i,length:e.length,ko(){s.ko(i)}}}function n(t,e,n){var r=0,o=0
|
|
811
|
+
n&&(n=n.split(","),r=s.Oo(16*n.length),n.forEach(t=>{var e=i(t)
|
|
812
|
+
s.Lo(e.nr,-1,r+16*o)&&o++,e.ko()})),s._h(t.nr,e.nr,r,o),r&&s.ko(r)}var s=t._r,r=new TextDecoder("utf8")
|
|
813
|
+
let o=t.us,h=t.bs
|
|
814
|
+
var a=o(t=>{s.ko(t)},"vi"),l=e("JSON"),c="",u=s.Oo(256)
|
|
815
|
+
return{Ue(e){var i=s.Oo(e.byteLength)
|
|
774
816
|
t.HEAPU8.set(new Uint8Array(e),i)
|
|
775
|
-
var n=s.
|
|
776
|
-
return{
|
|
777
|
-
const o=s.
|
|
778
|
-
return{
|
|
779
|
-
if(o){var h=s.
|
|
780
|
-
return t.HEAPU8.subarray(h,h+o)}},We(){var e=s.
|
|
781
|
-
t.HEAPU32[i/4]=64,s.
|
|
817
|
+
var n=s.Or(i,e.byteLength,2,i,a)
|
|
818
|
+
return{nr:n,destroy(){s.kr(n)}}},Pe(i,n){var r=s.Ro(i.nr,n)
|
|
819
|
+
const o=s.Jo(r)
|
|
820
|
+
return{nr:r,upem:o,Bh(i){var n=s.qo(r,e(i)),o=s.Br(n)
|
|
821
|
+
if(o){var h=s.Ur(n,null)
|
|
822
|
+
return t.HEAPU8.subarray(h,h+o)}},We(){var e=s.Oo(2048),i=s.Oo(4)
|
|
823
|
+
t.HEAPU32[i/4]=64,s.wh(r,0,i,e)
|
|
782
824
|
var n={}
|
|
783
825
|
return Array.from({length:t.HEAPU32[i/4]}).forEach((i,s)=>{var r
|
|
784
|
-
n[(r=t.HEAPU32[e/4+8*s+1],""+String.fromCharCode(r>>24&255)+String.fromCharCode(r>>16&255)+String.fromCharCode(r>>8&255)+String.fromCharCode(255&r))]={min:t.HEAPF32[e/4+8*s+4],default:t.HEAPF32[e/4+8*s+5],max:t.HEAPF32[e/4+8*s+6]}}),s.
|
|
785
|
-
s.
|
|
786
|
-
var i=(e=>{const i=s.
|
|
787
|
-
return t.HEAPU32.set(o,r),s.
|
|
788
|
-
return s.
|
|
789
|
-
return{
|
|
826
|
+
n[(r=t.HEAPU32[e/4+8*s+1],""+String.fromCharCode(r>>24&255)+String.fromCharCode(r>>16&255)+String.fromCharCode(r>>8&255)+String.fromCharCode(255&r))]={min:t.HEAPF32[e/4+8*s+4],default:t.HEAPF32[e/4+8*s+5],max:t.HEAPF32[e/4+8*s+6]}}),s.ko(i),s.ko(e),n},Nh(){var e=s.fh()
|
|
827
|
+
s.Qo(r,e)
|
|
828
|
+
var i=(e=>{const i=s.mh(e),n=s.Oo(i<<2),r=n>>2,o=t.HEAPU32.subarray(r,r+i)
|
|
829
|
+
return t.HEAPU32.set(o,r),s.bh(e,-1,n,i),o})(e)
|
|
830
|
+
return s.yh(e),i},destroy(){s.Ho(r)}}},$e(i){function n(t){return l||(f=o((t,e,i,n,s)=>{c+=`M${n},${s}`},"viiiffi"),d=o((t,e,i,n,s)=>{c+=`L${n},${s}`},"viiiffi"),y=o((t,e,i,n,s,r,o,h,a)=>{c+=`C${n},${s} ${r},${o} ${h},${a}`},"viiiffffffi"),p=o((t,e,i,n,s,r,o)=>{c+=`Q${n},${s} ${r},${o}`},"viiiffffi"),w=o(()=>{c+="Z"},"viiii"),l=s.fs(),s.ds(l,f,0,0),s.ys(l,d,0,0),s.ws(l,y,0,0),s.ps(l,p,0,0),s.gs(l,w,0,0)),c="",s.ir(a,t,l,0),c}var a=s.ih(i.nr),l=null,f=null,d=null,y=null,p=null,w=null
|
|
831
|
+
return{nr:a,Uh(e){s.th(a,e,u,256)
|
|
790
832
|
var i=t.HEAPU8.subarray(u,u+256)
|
|
791
|
-
return r.decode(i.slice(0,i.indexOf(0)))},
|
|
792
|
-
return{type:e[0],values:e.slice(1).filter(t=>t.length).map(t=>+t)}}),setScale(t,e){s.
|
|
793
|
-
n.forEach((i,n)=>{t.HEAPU32[r/4+2*n+0]=e(i[0]),t.HEAPF32[r/4+2*n+1]=i[1]}),s.
|
|
794
|
-
return{
|
|
833
|
+
return r.decode(i.slice(0,i.indexOf(0)))},Ph:n,$h:t=>n(t).replace(/([MLQCZ])/g,"|$1 ").split("|").filter(t=>t.length).map(t=>{var e=t.split(/[ ,]/g)
|
|
834
|
+
return{type:e[0],values:e.slice(1).filter(t=>t.length).map(t=>+t)}}),setScale(t,e){s.ah(a,t,e)},ze(i){var n=Object.entries(i),r=s.Oo(8*n.length)
|
|
835
|
+
n.forEach((i,n)=>{t.HEAPU32[r/4+2*n+0]=e(i[0]),t.HEAPF32[r/4+2*n+1]=i[1]}),s.sh(a,r,n.length),s.ko(r)},destroy(){s.oh(a),l&&(s.xs(l),l=null,h(f),h(d),h(y),h(p),h(w))}}},createBuffer(){var e=s.Wr()
|
|
836
|
+
return{nr:e,Vt(i){const n=(e=>{const i=s.Oo(2*e.length),n=new Uint16Array(t.Sr.buffer,i,e.length)
|
|
795
837
|
for(let t=0;n.length>t;++t)n[t]=e.charCodeAt(t)
|
|
796
|
-
return{
|
|
797
|
-
s.
|
|
798
|
-
t.forEach(t=>{i|=(t=>"BOT"==t?1:"EOT"==t?2:"PRESERVE_DEFAULT_IGNORABLES"==t?4:"REMOVE_DEFAULT_IGNORABLES"==t?8:"DO_NOT_INSERT_DOTTED_CIRCLE"==t?16:"PRODUCE_UNSAFE_TO_CONCAT"==t?64:0)(t)}),s.
|
|
799
|
-
s.
|
|
800
|
-
s.
|
|
801
|
-
return n},destroy(){s.
|
|
802
|
-
return o.startsWith("start table GSUB")?d=1:o.startsWith("start table GPOS")&&(d=2),d!=u&&(y=!1),0!=u&&d==u&&o.startsWith("end lookup "+
|
|
803
|
-
return s.
|
|
804
|
-
s.
|
|
805
|
-
var i={
|
|
806
|
-
return s.
|
|
838
|
+
return{nr:i,length:n.length,ko(){s.ko(i)}}})(i)
|
|
839
|
+
s.vo(e,n.nr,n.length,0,n.length),n.ko()},qt:()=>s.do(e),ur(t){s.Yr(e,{zh:4,Wh:5,Rh:6,jh:7}[t]||0)},Hh(t){var i=0
|
|
840
|
+
t.forEach(t=>{i|=(t=>"BOT"==t?1:"EOT"==t?2:"PRESERVE_DEFAULT_IGNORABLES"==t?4:"REMOVE_DEFAULT_IGNORABLES"==t?8:"DO_NOT_INSERT_DOTTED_CIRCLE"==t?16:"PRODUCE_UNSAFE_TO_CONCAT"==t?64:0)(t)}),s.eo(e,i)},Vh(t){var n=i(t)
|
|
841
|
+
s.Xr(e,s.So(n.nr,-1)),n.ko()},qh(t){var n=i(t)
|
|
842
|
+
s.Kr(e,s.Eo(n.nr,-1)),n.ko()},Yh(t){s.no(e,t)},json(){for(var i=s.ro(e),n=[],r=s.ho(e,0),o=r/4,h=s.lo(e,0)/4,a=t.HEAPU32.subarray(o,o+5*i),l=t.HEAP32.subarray(h,h+5*i),c=0;i>c;++c)n.push({g:a[5*c+0],Jt:a[5*c+2],ax:l[5*c+0],ay:l[5*c+1],dx:l[5*c+2],dy:l[5*c+3],flags:s.uo(r+20*c)})
|
|
843
|
+
return n},destroy(){s.jr(e)}}},shape:n,Jh(e,i,a,c,u){var f=[],d=0,y=!1,p=1048576,w=s.Oo(p),g=o((e,i,n)=>{var o=r.decode(t.HEAPU8.subarray(n,t.HEAPU8.indexOf(0,n)))
|
|
844
|
+
return o.startsWith("start table GSUB")?d=1:o.startsWith("start table GPOS")&&(d=2),d!=u&&(y=!1),0!=u&&d==u&&o.startsWith("end lookup "+c)&&(y=!0),y?0:(s.$r(e,0,s.ro(e),w,p,0,i,l,4),f.push({li:o,di:JSON.parse(r.decode(t.HEAPU8.subarray(w,t.HEAPU8.indexOf(0,w)))),glyphs:2==s.Vr(e)}),1)},"iiiii")
|
|
845
|
+
return s.xo(i.nr,g,0,0),n(e,i,a),s.ko(w),h(g),f},version(){var e=s.Oo(12)
|
|
846
|
+
s.Ao(e,e+4,e+8)
|
|
847
|
+
var i={Kh:t.HEAPU32[e/4],Qh:t.HEAPU32[(e+4)/4],Xh:t.HEAPU32[(e+8)/4]}
|
|
848
|
+
return s.ko(e),i},Zh(){var e=s.Io()
|
|
807
849
|
return r.decode(t.HEAPU8.subarray(e,t.HEAPU8.indexOf(0,e)))}}}}catch(t){}var St=r(bt.exports)
|
|
808
850
|
let _t=null,Et=null,Tt=null
|
|
809
|
-
const At={
|
|
810
|
-
if(Tt)e.
|
|
851
|
+
const At={ta(t){Et=t,Tt=null,_t=null},ea(t){Tt=t,Et=null,_t=null},ia:async()=>_t||(_t=new Promise(async(t,e)=>{try{const e={}
|
|
852
|
+
if(Tt)e.br=Tt
|
|
811
853
|
else{if(!Et)throw Error("HarfBuzz WASM path or buffer must be set before initialization.")
|
|
812
|
-
e.
|
|
813
|
-
t({hb:St(i),module:{
|
|
814
|
-
class Mt{constructor(t,e){this.text=t,this.
|
|
815
|
-
e.push(t),this.
|
|
816
|
-
return t.
|
|
854
|
+
e.Ih=(t,e)=>t.endsWith(".wasm")?Et:e+t}const i=await xt(e)
|
|
855
|
+
t({hb:St(i),module:{us:i.us,exports:i._r,bs:i.bs}})}catch(t){e(Error("Failed to initialize HarfBuzz: "+t))}}),_t)}
|
|
856
|
+
class Mt{constructor(t,e){this.text=t,this.na=new Map,e.forEach(t=>{const e=this.na.get(t.Zs)||[]
|
|
857
|
+
e.push(t),this.na.set(t.Zs,e)})}sa(t){const e=[]
|
|
858
|
+
return t.ra&&e.push(...this.oa(t.ra)),t.ha&&e.push(...this.aa(t.ha)),e}oa(t){const e=[]
|
|
817
859
|
for(const i of t){let t=0
|
|
818
|
-
for(;-1!==(t=this.text.indexOf(i,t));)e.push(this.createTextRange(t,t+i.length,i)),t+=i.length}return e}
|
|
860
|
+
for(;-1!==(t=this.text.indexOf(i,t));)e.push(this.createTextRange(t,t+i.length,i)),t+=i.length}return e}aa(t){return t.map(t=>{const e=this.text.slice(t.start,t.end)
|
|
819
861
|
return this.createTextRange(t.start,t.end,e)})}createTextRange(t,e,i){const n=[],s=new Map
|
|
820
|
-
for(let i=t;e>i;i++){const t=this.
|
|
862
|
+
for(let i=t;e>i;i++){const t=this.na.get(i)
|
|
821
863
|
if(t)for(const e of t){n.push(e)
|
|
822
|
-
const t=s.get(e.
|
|
823
|
-
t.push(e),s.set(e.
|
|
864
|
+
const t=s.get(e.tr)||[]
|
|
865
|
+
t.push(e),s.set(e.tr,t)}}return{start:t,end:e,la:i,bounds:Array.from(s.values()).map(t=>this.ca(t)),glyphs:n,ua:Array.from(s.keys()).sort((t,e)=>t-e)}}ca(t){if(0===t.length)return{min:{x:0,y:0,z:0},max:{x:0,y:0,z:0}}
|
|
824
866
|
let e=1/0,i=1/0,n=1/0,s=-1/0,r=-1/0,o=-1/0
|
|
825
867
|
for(const h of t)e>h.bounds.min.x&&(e=h.bounds.min.x),i>h.bounds.min.y&&(i=h.bounds.min.y),n>h.bounds.min.z&&(n=h.bounds.min.z),h.bounds.max.x>s&&(s=h.bounds.max.x),h.bounds.max.y>r&&(r=h.bounds.max.y),h.bounds.max.z>o&&(o=h.bounds.max.z)
|
|
826
868
|
return{min:{x:e,y:i,z:n},max:{x:s,y:r,z:o}}}}const It=72
|
|
827
|
-
class Ft{static{this.
|
|
869
|
+
class Ft{static{this.fa=new Map}static{this.da=null}static{this.ya=new Map}static{this.pa=0}static{this.wa=1/0}static{this.ga=0}static va(t){const e=Object.keys(t).sort()
|
|
828
870
|
let i=""
|
|
829
871
|
for(let n=0;e.length>n;n++)n>0&&(i+=","),i+=e[n]+":"+t[e[n]]
|
|
830
|
-
return i}constructor(){this.
|
|
831
|
-
Ft.
|
|
832
|
-
const e=await Ft.
|
|
833
|
-
i.
|
|
834
|
-
const n=await i.
|
|
872
|
+
return i}constructor(){this.ma="",Ft.da||(Ft.da=At.ia()),this.xa=new H(()=>Ft.da)}static ba(t){At.ta(t),Ft.da=null}static Sa(t){At.ea(t),Ft.da=null}static init(){return Ft.da||(Ft.da=At.ia()),Ft.da}static async create(t){if(!t.font)throw Error("Font is required. Specify options.font as a URL string or ArrayBuffer.")
|
|
873
|
+
Ft.da||(Ft.da=At.ia())
|
|
874
|
+
const e=await Ft._a(t),i=new Ft
|
|
875
|
+
i.Ea(e)
|
|
876
|
+
const n=await i.Ta(t),s=async e=>{const n={...t}
|
|
835
877
|
for(const t in e){const i=e[t]
|
|
836
|
-
void 0!==i&&(n[t]=i)}if(void 0!==e.font||void 0!==e.Re||void 0!==e.Yt){const t=await Ft.
|
|
837
|
-
i.
|
|
838
|
-
return{...n,getLoadedFont(){return i.getLoadedFont()},getCacheSize(){return i.getCacheSize()},clearCache(){return i.clearCache()},measureTextWidth(t,e){return i.measureTextWidth(t,e)},update:s}}static async
|
|
839
|
-
t.Re&&(e+="_var_"+Ft.
|
|
840
|
-
let i=Ft.
|
|
841
|
-
return i||(i=await Ft.
|
|
878
|
+
void 0!==i&&(n[t]=i)}if(void 0!==e.font||void 0!==e.Re||void 0!==e.Yt){const t=await Ft._a(n)
|
|
879
|
+
i.Ea(t),i.Aa()}return t=n,{...await i.Ta(t),getLoadedFont(){return i.getLoadedFont()},getCacheSize(){return i.getCacheSize()},clearCache(){return i.clearCache()},measureTextWidth(t,e){return i.measureTextWidth(t,e)},update:s}}
|
|
880
|
+
return{...n,getLoadedFont(){return i.getLoadedFont()},getCacheSize(){return i.getCacheSize()},clearCache(){return i.clearCache()},measureTextWidth(t,e){return i.measureTextWidth(t,e)},update:s}}static async _a(t){let e="string"==typeof t.font?t.font:"buffer-"+Ft.Ma(t.font)
|
|
881
|
+
t.Re&&(e+="_var_"+Ft.va(t.Re)),t.Yt&&(e+="_feat_"+Ft.va(t.Yt))
|
|
882
|
+
let i=Ft.ya.get(e)
|
|
883
|
+
return i||(i=await Ft.Ia(e,t.font,t.Re,t.Yt)),i}static async Ia(t,e,i,n){const s=new Ft
|
|
842
884
|
await s.Ne(e,i,n)
|
|
843
885
|
const r=s.getLoadedFont()
|
|
844
|
-
return Ft.
|
|
845
|
-
e&&(Ft.
|
|
886
|
+
return Ft.ya.set(t,r),Ft.Fa(r),Ft.La(),r}static Fa(t){Ft.pa+=t.Ye?.byteLength??0}static Ga(t){const e=Ft.ya.get(t)
|
|
887
|
+
e&&(Ft.pa-=e.Ye?.byteLength??0,0>Ft.pa&&(Ft.pa=0))}static La(){if(Ft.wa!==1/0)for(;Ft.pa>Ft.wa&&Ft.ya.size>0;){const t=Ft.ya.keys().next().value
|
|
846
888
|
if(void 0===t)break
|
|
847
|
-
Ft.
|
|
889
|
+
Ft.Ga(t),Ft.ya.delete(t)}}static Ma(t){if(t){const e=new Uint8Array(t)
|
|
848
890
|
let i=2166136261
|
|
849
891
|
const n=Math.min(32,e.length),s=Math.floor(e.length/n)
|
|
850
892
|
for(let t=0;n>t;t++)i^=e[t*s],i=Math.imul(i,16777619)
|
|
851
|
-
return i^=e.length,i=Math.imul(i,16777619),(i>>>0).toString(36)}return"c"+ ++Ft.
|
|
852
|
-
const e=Ft.
|
|
853
|
-
this.
|
|
893
|
+
return i^=e.length,i=Math.imul(i,16777619),(i>>>0).toString(36)}return"c"+ ++Ft.ga}Ea(t){this.Kt=t
|
|
894
|
+
const e=Ft.Ma(t.Ye)
|
|
895
|
+
this.ma="font_"+e,t.Re&&(this.ma+="_var_"+Ft.va(t.Re)),t.Yt&&(this.ma+="_feat_"+Ft.va(t.Yt))}async Ne(t,e,i){Ft.da||(Ft.da=At.ia()),await Ft.da
|
|
854
896
|
const n="string"==typeof t?await fetch(t).then(e=>{if(!e.ok)throw Error(`Failed to load font from ${t}: HTTP ${e.status} ${e.statusText}`)
|
|
855
897
|
return e.arrayBuffer()}):t
|
|
856
|
-
try{this.Kt&&this.destroy(),this.Kt=await this.
|
|
857
|
-
const t=Ft.
|
|
858
|
-
this.
|
|
859
|
-
const e=await this.
|
|
860
|
-
this.
|
|
898
|
+
try{this.Kt&&this.destroy(),this.Kt=await this.xa.Ne(n,e),i&&(this.Kt.Yt=i)
|
|
899
|
+
const t=Ft.Ma(n)
|
|
900
|
+
this.ma="font_"+t,e&&(this.ma+="_var_"+Ft.va(e)),i&&(this.ma+="_feat_"+Ft.va(i))}catch(t){throw a.error("Failed to load font:",t),t}}async Ta(t){try{if(!this.Kt)throw Error("Font not loaded. Use Text.create() with a font option.")
|
|
901
|
+
const e=await this.Oa(t)
|
|
902
|
+
this.Ca(e),this.ka(t=e),this.ar||(this.ar=new wt(Q,this.Kt),this.ar.Bs(this.ma))
|
|
861
903
|
const i=null!=t.curveSteps&&t.curveSteps>0
|
|
862
|
-
this.
|
|
863
|
-
const n=this.
|
|
904
|
+
this.ar.pn(t.curveSteps),this.ar.yn(i?void 0:t.curveFidelity),this.ar.Qn(t.geometryOptimization),this.Kt.font.setScale(this.Kt.upem,this.Kt.upem),this.Da||(this.Da=new gt(this.Kt,this.ar))
|
|
905
|
+
const n=this.Ba(t),s=t.Na??this.Kt.je??!1,r=this.Da.lr(n.lines,n.Ua,n.letterSpacing,n.align,n.direction,t.color,t.text)
|
|
864
906
|
let o,h
|
|
865
|
-
if(t.color&&"object"==typeof t.color&&!Array.isArray(t.color)&&(t.color.
|
|
866
|
-
for(const e of Object.keys(t.color.
|
|
907
|
+
if(t.color&&"object"==typeof t.color&&!Array.isArray(t.color)&&(t.color.ra||t.color.ha)){if(o=new Set,t.color.ra){h=[]
|
|
908
|
+
for(const e of Object.keys(t.color.ra)){let i=0
|
|
867
909
|
for(;-1!==(i=t.text.indexOf(e,i));){h.push({pattern:e,start:i,end:i+e.length})
|
|
868
910
|
for(let t=i;i+e.length>t;t++)o.add(t)
|
|
869
|
-
i+=e.length}}}if(t.color.
|
|
870
|
-
if(t.perGlyphAttributes){const t=this.
|
|
871
|
-
|
|
872
|
-
if(!t.layout?.St?.[e])try{if(!Ft.
|
|
873
|
-
Ft.
|
|
874
|
-
const e=t.
|
|
875
|
-
if(t.text.length>e)throw Error(`Text exceeds ${e} character limit`)}
|
|
876
|
-
const{text:e,size:i=It,depth:n=0,lineHeight:s=1,letterSpacing:r=0,layout:o={}}=t,{width:h,direction:a="ltr",align:f=("rtl"===a?"right":"left"),xt:d=!0,vt:y=!0,language:p="en-us",Et:w=
|
|
911
|
+
i+=e.length}}}if(t.color.ha)for(const e of t.color.ha)for(let t=e.start;e.end>t;t++)o.add(t)}const a=this.ar.Us(r,n.depth,s,this.Kt.h.ue,n.Pa,t.perGlyphAttributes??!1,o),l=this.$a(a.vertices,a.normals,a.indices,a.Xs,a.planeBounds,t,t.text,h)
|
|
912
|
+
if(t.perGlyphAttributes){const t=this.za(l.vertices.length/3,l.glyphs)
|
|
913
|
+
l.glyphAttributes=t}return l}finally{}}async Oa(t){if(!1!==t.layout?.vt&&t.layout?.width){const e=t.layout?.language||"en-us"
|
|
914
|
+
if(!t.layout?.St?.[e])try{if(!Ft.fa.has(e)){const i=await n(e,t.layout?.Wa)
|
|
915
|
+
Ft.fa.set(e,i)}return{...t,layout:{...t.layout,St:{...t.layout?.St,[e]:Ft.fa.get(e)}}}}catch(i){return a.warn(`Failed to load patterns for ${e}: ${i}`),{...t,layout:{...t.layout,vt:!1}}}}return t}Ca(t){if(!t.text)throw Error("Text content is required")
|
|
916
|
+
const e=t.Ra??1e5
|
|
917
|
+
if(t.text.length>e)throw Error(`Text exceeds ${e} character limit`)}ka(t){t.Re&&this.Kt&&Ft.va(t.Re)!==Ft.va(this.Kt.Re||{})&&(this.Kt.font.ze(t.Re),this.Kt.Re=t.Re)}Ba(t){if(!this.Kt)throw Error("Font not loaded. Use Text.create() with a font option")
|
|
918
|
+
const{text:e,size:i=It,depth:n=0,lineHeight:s=1,letterSpacing:r=0,layout:o={}}=t,{width:h,direction:a="ltr",align:f=("rtl"===a?"right":"left"),xt:d=!0,vt:y=!0,language:p="en-us",Et:w=l,Tt:g=c,At:v=u,Mt:m,St:x,It:b,Ft:S,Lt:_,Gt:E,Ot:T,Ct:A,kt:M}=o,F=this.Kt.upem/i
|
|
877
919
|
let L
|
|
878
920
|
void 0!==h&&(L=h*F)
|
|
879
921
|
const G=n*F,O=G>0?Math.max(G,25e-6*this.Kt.upem):0
|
|
880
|
-
this.
|
|
881
|
-
const
|
|
882
|
-
return{lines:
|
|
922
|
+
this.ja||(this.ja=new I(this.Kt))
|
|
923
|
+
const C=this.ja.Qt({text:e,width:L,align:f,direction:a,vt:y,language:p,xt:d,Et:w,Tt:g,At:v,Mt:m,St:x,It:b,Ft:S,Lt:_,Gt:E,Ot:T,Ct:A,kt:M,letterSpacing:r}),k=R.Fe(this.Kt.h)
|
|
924
|
+
return{lines:C.lines,Ua:(k.ie-k.ne)*s,letterSpacing:r,align:f,direction:a,depth:O,size:i,Pa:1/F}}Ha(t,e,i,n,s){const r=t.length/3,o=new Float32Array(3*r),h=[]
|
|
883
925
|
if(Array.isArray(i)){for(let t=0;r>t;t++){const e=3*t
|
|
884
|
-
o[e]=i[0],o[e+1]=i[1],o[e+2]=i[2]}h.push({start:0,end:n.length,
|
|
926
|
+
o[e]=i[0],o[e+1]=i[1],o[e+2]=i[2]}h.push({start:0,end:n.length,la:n,color:i,bounds:[],glyphs:e,ua:[...new Set(e.map(t=>t.tr))]})}else{const t=i.default||[1,1,1]
|
|
885
927
|
for(let e=0;o.length>e;e+=3)o[e]=t[0],o[e+1]=t[1],o[e+2]=t[2]
|
|
886
928
|
let r
|
|
887
|
-
if(i.
|
|
888
|
-
for(const t of e){const e=r.get(t.
|
|
889
|
-
e?e.push(t):r.set(t.
|
|
929
|
+
if(i.ra&&s||i.ha){r=new Map
|
|
930
|
+
for(const t of e){const e=r.get(t.Zs)
|
|
931
|
+
e?e.push(t):r.set(t.Zs,[t])}}if(i.ra&&s&&r)for(const t of s){const e=i.ra[t.pattern]
|
|
890
932
|
if(!e)continue
|
|
891
933
|
const n=[],s=new Map
|
|
892
934
|
for(let i=t.start;t.end>i;i++){const t=r.get(i)
|
|
893
935
|
if(t)for(const i of t){n.push(i)
|
|
894
|
-
const t=s.get(i.
|
|
895
|
-
t?t.push(i):s.set(i.
|
|
896
|
-
for(let t=0;i.
|
|
897
|
-
n>=0&&o.length>n&&(o[n]=e[0],o[n+1]=e[1],o[n+2]=e[2])}}}const a=Array.from(s.values()).map(t=>this.
|
|
898
|
-
h.push({start:t.start,end:t.end,
|
|
936
|
+
const t=s.get(i.tr)
|
|
937
|
+
t?t.push(i):s.set(i.tr,[i])
|
|
938
|
+
for(let t=0;i.er>t;t++){const n=3*(i.zs+t)
|
|
939
|
+
n>=0&&o.length>n&&(o[n]=e[0],o[n+1]=e[1],o[n+2]=e[2])}}}const a=Array.from(s.values()).map(t=>this.Va(t))
|
|
940
|
+
h.push({start:t.start,end:t.end,la:t.pattern,color:e,bounds:a,glyphs:n,ua:Array.from(s.keys()).sort((t,e)=>t-e)})}if(i.ha&&r)for(const t of i.ha){const e=[],i=new Map
|
|
899
941
|
for(let n=t.start;t.end>n;n++){const s=r.get(n)
|
|
900
942
|
if(s)for(const n of s){e.push(n)
|
|
901
|
-
const s=i.get(n.
|
|
902
|
-
s?s.push(n):i.set(n.
|
|
903
|
-
for(let e=0;n.
|
|
904
|
-
i>=0&&o.length>i&&(o[i]=t.color[0],o[i+1]=t.color[1],o[i+2]=t.color[2])}}}const s=Array.from(i.values()).map(t=>this.
|
|
905
|
-
h.push({start:t.start,end:t.end,
|
|
943
|
+
const s=i.get(n.tr)
|
|
944
|
+
s?s.push(n):i.set(n.tr,[n])
|
|
945
|
+
for(let e=0;n.er>e;e++){const i=3*(n.zs+e)
|
|
946
|
+
i>=0&&o.length>i&&(o[i]=t.color[0],o[i+1]=t.color[1],o[i+2]=t.color[2])}}}const s=Array.from(i.values()).map(t=>this.Va(t))
|
|
947
|
+
h.push({start:t.start,end:t.end,la:n.slice(t.start,t.end),color:t.color,bounds:s,glyphs:e,ua:Array.from(i.keys()).sort((t,e)=>t-e)})}}return{colors:o,qa:h}}Va(t){if(0===t.length)return{min:{x:0,y:0,z:0},max:{x:0,y:0,z:0}}
|
|
906
948
|
let e=1/0,i=1/0,n=1/0,s=-1/0,r=-1/0,o=-1/0
|
|
907
949
|
for(const h of t)e>h.bounds.min.x&&(e=h.bounds.min.x),i>h.bounds.min.y&&(i=h.bounds.min.y),n>h.bounds.min.z&&(n=h.bounds.min.z),h.bounds.max.x>s&&(s=h.bounds.max.x),h.bounds.max.y>r&&(r=h.bounds.max.y),h.bounds.max.z>o&&(o=h.bounds.max.z)
|
|
908
|
-
return{min:{x:e,y:i,z:n},max:{x:s,y:r,z:o}}}
|
|
909
|
-
this.
|
|
910
|
-
const u=this.
|
|
950
|
+
return{min:{x:e,y:i,z:n},max:{x:s,y:r,z:o}}}$a(t,e,i,n,s,r,o,h){const{layout:a={}}=r,{width:l,align:c=("rtl"===a.direction?"right":"left")}=a
|
|
951
|
+
this.ja||(this.ja=new I(this.Kt))
|
|
952
|
+
const u=this.ja.te({width:l,align:c,planeBounds:s}),f=u.offset
|
|
911
953
|
if(s.min.x=u.Zt.min.x,s.max.x=u.Zt.max.x,0!==f){for(let e=0;t.length>e;e+=3)t[e]+=f
|
|
912
954
|
for(let t=0;n.length>t;t++)n[t].bounds.min.x+=f,n[t].bounds.max.x+=f}let d,y
|
|
913
|
-
if(r.color){const e=this.
|
|
914
|
-
d=e.colors,y=e
|
|
955
|
+
if(r.color){const e=this.Ha(t,n,r.color,r.text,h)
|
|
956
|
+
d=e.colors,y=e.qa}const p=this.ar.Xn()
|
|
915
957
|
return{vertices:t,normals:e,indices:i,colors:d,glyphs:n,planeBounds:s,stats:{trianglesGenerated:i.length/3,verticesGenerated:t.length/3,pointsRemovedByVisvalingam:p.pointsRemovedByVisvalingam,originalPointCount:p.originalPointCount},query:(()=>{let t=null
|
|
916
958
|
return e=>{if(!o)throw Error("Original text not available for querying")
|
|
917
|
-
return t||(t=new Mt(o,n)),t.
|
|
918
|
-
return R.Le(this.Kt.h)}static async
|
|
919
|
-
Ft.
|
|
920
|
-
return M.measureTextWidth(this.Kt,t,e)}getCacheSize(){return this.
|
|
959
|
+
return t||(t=new Mt(o,n)),t.sa(e)}})(),qa:y,glyphAttributes:void 0}}Le(){if(!this.Kt)throw Error("Font not loaded. Call loadFont() first")
|
|
960
|
+
return R.Le(this.Kt.h)}static async Ya(t,e){await Promise.all(t.map(async t=>{if(!Ft.fa.has(t))try{const i=await n(t,e)
|
|
961
|
+
Ft.fa.set(t,i)}catch(e){a.warn(`Failed to pre-load patterns for ${t}: ${e}`)}}))}static Ja(t,e){Ft.fa.set(t,e)}static Ka(t){Ft.wa=t===1/0?1/0:1048576*Math.max(1,Math.floor(t)),Ft.La()}getLoadedFont(){return this.Kt}measureTextWidth(t,e=0){if(!this.Kt)throw Error("Font not loaded. Call loadFont() first")
|
|
962
|
+
return M.measureTextWidth(this.Kt,t,e)}getCacheSize(){return this.ar?this.ar.rr().size:0}clearCache(){this.ar&&this.ar.clearCache()}za(t,e){const i=new Float32Array(3*t),n=new Float32Array(t),s=new Float32Array(t),r=new Float32Array(t),o=new Float32Array(t)
|
|
921
963
|
let h=1/0,a=-1/0
|
|
922
964
|
for(let t=0;e.length>t;t++){const i=(e[t].bounds.min.x+e[t].bounds.max.x)/2
|
|
923
|
-
h>i&&(h=i),i>a&&(a=i)}const
|
|
924
|
-
for(let a=0;e.length>a;a++){const
|
|
925
|
-
if(g>w){n.fill(a,w,g),s.fill(
|
|
926
|
-
for(let t=3*w;3*g>t;t+=3)i[t]=u,i[t+1]=f,i[t+2]=d}}return{glyphCenter:i,glyphIndex:n,glyphLineIndex:s,glyphProgress:r,glyphBaselineY:o}}
|
|
965
|
+
h>i&&(h=i),i>a&&(a=i)}const l=a-h
|
|
966
|
+
for(let a=0;e.length>a;a++){const c=e[a],u=(c.bounds.min.x+c.bounds.max.x)/2,f=(c.bounds.min.y+c.bounds.max.y)/2,d=(c.bounds.min.z+c.bounds.max.z)/2,y=c.bounds.min.y,p=l>0?(u-h)/l:0,w=c.zs,g=Math.min(w+c.er,t)
|
|
967
|
+
if(g>w){n.fill(a,w,g),s.fill(c.tr,w,g),r.fill(p,w,g),o.fill(y,w,g)
|
|
968
|
+
for(let t=3*w;3*g>t;t+=3)i[t]=u,i[t+1]=f,i[t+2]=d}}return{glyphCenter:i,glyphIndex:n,glyphLineIndex:s,glyphProgress:r,glyphBaselineY:o}}Aa(){this.ar=void 0,this.Da=void 0,this.ja=void 0}destroy(){if(!this.Kt)return
|
|
927
969
|
const t=this.Kt
|
|
928
|
-
try{H.Je(t)}catch(t){a.warn("Error destroying HarfBuzz objects:",t)}finally{this.Kt=void 0,this.
|
|
970
|
+
try{H.Je(t)}catch(t){a.warn("Error destroying HarfBuzz objects:",t)}finally{this.Kt=void 0,this.ja=void 0,this.Da=void 0}}}t.DEFAULT_CURVE_FIDELITY=ct,t.FontMetadataExtractor=R,t.Text=Ft,t.Qa=()=>new K,t.Xa=Q})
|