📄 ktx-parse.module.js
¶
📊 Analysis Summary¶
Metric | Count |
---|---|
🔧 Functions | 14 |
🧱 Classes | 2 |
📊 Variables & Constants | 305 |
📚 Table of Contents¶
🛠️ File Location:¶
📂 examples/jsm/libs/ktx-parse.module.js
Variables & Constants¶
Name | Type | Kind | Value | Exported |
---|---|---|---|---|
t |
0 |
let/var | 0 |
✗ |
e |
1 |
let/var | 1 |
✗ |
n |
2 |
let/var | 2 |
✗ |
i |
3 |
let/var | 3 |
✗ |
s |
0 |
let/var | 0 |
✗ |
a |
0 |
let/var | 0 |
✗ |
r |
2 |
let/var | 2 |
✗ |
o |
0 |
let/var | 0 |
✗ |
l |
1 |
let/var | 1 |
✗ |
f |
160 |
let/var | 160 |
✗ |
h |
161 |
let/var | 161 |
✗ |
U |
162 |
let/var | 162 |
✗ |
c |
163 |
let/var | 163 |
✗ |
_ |
166 |
let/var | 166 |
✗ |
p |
0 |
let/var | 0 |
✗ |
g |
1 |
let/var | 1 |
✗ |
y |
0 |
let/var | 0 |
✗ |
x |
1 |
let/var | 1 |
✗ |
u |
2 |
let/var | 2 |
✗ |
b |
3 |
let/var | 3 |
✗ |
d |
4 |
let/var | 4 |
✗ |
w |
5 |
let/var | 5 |
✗ |
m |
6 |
let/var | 6 |
✗ |
D |
7 |
let/var | 7 |
✗ |
B |
8 |
let/var | 8 |
✗ |
L |
9 |
let/var | 9 |
✗ |
v |
10 |
let/var | 10 |
✗ |
A |
11 |
let/var | 11 |
✗ |
k |
12 |
let/var | 12 |
✗ |
V |
13 |
let/var | 13 |
✗ |
I |
14 |
let/var | 14 |
✗ |
S |
15 |
let/var | 15 |
✗ |
F |
16 |
let/var | 16 |
✗ |
O |
17 |
let/var | 17 |
✗ |
E |
18 |
let/var | 18 |
✗ |
T |
0 |
let/var | 0 |
✗ |
C |
1 |
let/var | 1 |
✗ |
M |
2 |
let/var | 2 |
✗ |
P |
3 |
let/var | 3 |
✗ |
z |
4 |
let/var | 4 |
✗ |
W |
5 |
let/var | 5 |
✗ |
H |
6 |
let/var | 6 |
✗ |
N |
7 |
let/var | 7 |
✗ |
K |
8 |
let/var | 8 |
✗ |
X |
9 |
let/var | 9 |
✗ |
R |
10 |
let/var | 10 |
✗ |
Y |
11 |
let/var | 11 |
✗ |
j |
0 |
let/var | 0 |
✗ |
q |
1 |
let/var | 1 |
✗ |
G |
2 |
let/var | 2 |
✗ |
J |
13 |
let/var | 13 |
✗ |
Q |
14 |
let/var | 14 |
✗ |
Z |
15 |
let/var | 15 |
✗ |
$ |
128 |
let/var | 128 |
✗ |
tt |
64 |
let/var | 64 |
✗ |
et |
32 |
let/var | 32 |
✗ |
nt |
16 |
let/var | 16 |
✗ |
it |
0 |
let/var | 0 |
✗ |
st |
1 |
let/var | 1 |
✗ |
at |
2 |
let/var | 2 |
✗ |
rt |
3 |
let/var | 3 |
✗ |
ot |
4 |
let/var | 4 |
✗ |
lt |
5 |
let/var | 5 |
✗ |
ft |
6 |
let/var | 6 |
✗ |
ht |
7 |
let/var | 7 |
✗ |
Ut |
8 |
let/var | 8 |
✗ |
ct |
9 |
let/var | 9 |
✗ |
_t |
10 |
let/var | 10 |
✗ |
pt |
13 |
let/var | 13 |
✗ |
gt |
14 |
let/var | 14 |
✗ |
yt |
15 |
let/var | 15 |
✗ |
xt |
16 |
let/var | 16 |
✗ |
ut |
17 |
let/var | 17 |
✗ |
bt |
20 |
let/var | 20 |
✗ |
dt |
21 |
let/var | 21 |
✗ |
wt |
22 |
let/var | 22 |
✗ |
mt |
23 |
let/var | 23 |
✗ |
Dt |
24 |
let/var | 24 |
✗ |
Bt |
27 |
let/var | 27 |
✗ |
Lt |
28 |
let/var | 28 |
✗ |
vt |
29 |
let/var | 29 |
✗ |
At |
30 |
let/var | 30 |
✗ |
kt |
31 |
let/var | 31 |
✗ |
Vt |
34 |
let/var | 34 |
✗ |
It |
35 |
let/var | 35 |
✗ |
St |
36 |
let/var | 36 |
✗ |
Ft |
37 |
let/var | 37 |
✗ |
Ot |
38 |
let/var | 38 |
✗ |
Et |
41 |
let/var | 41 |
✗ |
Tt |
42 |
let/var | 42 |
✗ |
Ct |
43 |
let/var | 43 |
✗ |
Mt |
44 |
let/var | 44 |
✗ |
Pt |
45 |
let/var | 45 |
✗ |
zt |
48 |
let/var | 48 |
✗ |
Wt |
49 |
let/var | 49 |
✗ |
Ht |
50 |
let/var | 50 |
✗ |
Nt |
58 |
let/var | 58 |
✗ |
Kt |
59 |
let/var | 59 |
✗ |
Xt |
62 |
let/var | 62 |
✗ |
Rt |
63 |
let/var | 63 |
✗ |
Yt |
64 |
let/var | 64 |
✗ |
jt |
65 |
let/var | 65 |
✗ |
qt |
68 |
let/var | 68 |
✗ |
Gt |
69 |
let/var | 69 |
✗ |
Jt |
70 |
let/var | 70 |
✗ |
Qt |
71 |
let/var | 71 |
✗ |
Zt |
74 |
let/var | 74 |
✗ |
$t |
75 |
let/var | 75 |
✗ |
te |
76 |
let/var | 76 |
✗ |
ee |
77 |
let/var | 77 |
✗ |
ne |
78 |
let/var | 78 |
✗ |
ie |
81 |
let/var | 81 |
✗ |
se |
82 |
let/var | 82 |
✗ |
ae |
83 |
let/var | 83 |
✗ |
re |
84 |
let/var | 84 |
✗ |
oe |
85 |
let/var | 85 |
✗ |
le |
88 |
let/var | 88 |
✗ |
fe |
89 |
let/var | 89 |
✗ |
he |
90 |
let/var | 90 |
✗ |
Ue |
91 |
let/var | 91 |
✗ |
ce |
92 |
let/var | 92 |
✗ |
_e |
95 |
let/var | 95 |
✗ |
pe |
96 |
let/var | 96 |
✗ |
ge |
97 |
let/var | 97 |
✗ |
ye |
98 |
let/var | 98 |
✗ |
xe |
99 |
let/var | 99 |
✗ |
ue |
100 |
let/var | 100 |
✗ |
be |
101 |
let/var | 101 |
✗ |
de |
102 |
let/var | 102 |
✗ |
we |
103 |
let/var | 103 |
✗ |
me |
104 |
let/var | 104 |
✗ |
De |
105 |
let/var | 105 |
✗ |
Be |
106 |
let/var | 106 |
✗ |
Le |
107 |
let/var | 107 |
✗ |
ve |
108 |
let/var | 108 |
✗ |
Ae |
109 |
let/var | 109 |
✗ |
ke |
110 |
let/var | 110 |
✗ |
Ve |
111 |
let/var | 111 |
✗ |
Ie |
112 |
let/var | 112 |
✗ |
Se |
113 |
let/var | 113 |
✗ |
Fe |
114 |
let/var | 114 |
✗ |
Oe |
115 |
let/var | 115 |
✗ |
Ee |
116 |
let/var | 116 |
✗ |
Te |
117 |
let/var | 117 |
✗ |
Ce |
118 |
let/var | 118 |
✗ |
Me |
119 |
let/var | 119 |
✗ |
Pe |
120 |
let/var | 120 |
✗ |
ze |
121 |
let/var | 121 |
✗ |
We |
122 |
let/var | 122 |
✗ |
He |
123 |
let/var | 123 |
✗ |
Ne |
124 |
let/var | 124 |
✗ |
Ke |
125 |
let/var | 125 |
✗ |
Xe |
126 |
let/var | 126 |
✗ |
Re |
127 |
let/var | 127 |
✗ |
Ye |
128 |
let/var | 128 |
✗ |
je |
129 |
let/var | 129 |
✗ |
qe |
130 |
let/var | 130 |
✗ |
Ge |
131 |
let/var | 131 |
✗ |
Je |
132 |
let/var | 132 |
✗ |
Qe |
133 |
let/var | 133 |
✗ |
Ze |
134 |
let/var | 134 |
✗ |
$e |
135 |
let/var | 135 |
✗ |
tn |
136 |
let/var | 136 |
✗ |
en |
137 |
let/var | 137 |
✗ |
nn |
138 |
let/var | 138 |
✗ |
sn |
139 |
let/var | 139 |
✗ |
an |
140 |
let/var | 140 |
✗ |
rn |
141 |
let/var | 141 |
✗ |
on |
142 |
let/var | 142 |
✗ |
ln |
143 |
let/var | 143 |
✗ |
fn |
144 |
let/var | 144 |
✗ |
hn |
145 |
let/var | 145 |
✗ |
Un |
146 |
let/var | 146 |
✗ |
cn |
147 |
let/var | 147 |
✗ |
_n |
148 |
let/var | 148 |
✗ |
pn |
149 |
let/var | 149 |
✗ |
gn |
150 |
let/var | 150 |
✗ |
yn |
151 |
let/var | 151 |
✗ |
xn |
152 |
let/var | 152 |
✗ |
un |
153 |
let/var | 153 |
✗ |
bn |
154 |
let/var | 154 |
✗ |
dn |
155 |
let/var | 155 |
✗ |
wn |
156 |
let/var | 156 |
✗ |
mn |
157 |
let/var | 157 |
✗ |
Dn |
158 |
let/var | 158 |
✗ |
Bn |
159 |
let/var | 159 |
✗ |
Ln |
160 |
let/var | 160 |
✗ |
vn |
161 |
let/var | 161 |
✗ |
An |
162 |
let/var | 162 |
✗ |
kn |
163 |
let/var | 163 |
✗ |
Vn |
164 |
let/var | 164 |
✗ |
In |
165 |
let/var | 165 |
✗ |
Sn |
166 |
let/var | 166 |
✗ |
Fn |
167 |
let/var | 167 |
✗ |
On |
168 |
let/var | 168 |
✗ |
En |
169 |
let/var | 169 |
✗ |
Tn |
170 |
let/var | 170 |
✗ |
Cn |
171 |
let/var | 171 |
✗ |
Mn |
172 |
let/var | 172 |
✗ |
Pn |
173 |
let/var | 173 |
✗ |
zn |
174 |
let/var | 174 |
✗ |
Wn |
175 |
let/var | 175 |
✗ |
Hn |
176 |
let/var | 176 |
✗ |
Nn |
177 |
let/var | 177 |
✗ |
Kn |
178 |
let/var | 178 |
✗ |
Xn |
179 |
let/var | 179 |
✗ |
Rn |
180 |
let/var | 180 |
✗ |
Yn |
181 |
let/var | 181 |
✗ |
jn |
182 |
let/var | 182 |
✗ |
qn |
183 |
let/var | 183 |
✗ |
Gn |
184 |
let/var | 184 |
✗ |
Jn |
1000156007 |
let/var | 1000156007 |
✗ |
Qn |
1000156008 |
let/var | 1000156008 |
✗ |
Zn |
1000156009 |
let/var | 1000156009 |
✗ |
$n |
1000156010 |
let/var | 1000156010 |
✗ |
ti |
1000156011 |
let/var | 1000156011 |
✗ |
ei |
1000156017 |
let/var | 1000156017 |
✗ |
ni |
1000156018 |
let/var | 1000156018 |
✗ |
ii |
1000156019 |
let/var | 1000156019 |
✗ |
si |
1000156020 |
let/var | 1000156020 |
✗ |
ai |
1000156021 |
let/var | 1000156021 |
✗ |
ri |
1000054000 |
let/var | 1000054e3 |
✗ |
oi |
1000054001 |
let/var | 1000054001 |
✗ |
li |
1000054002 |
let/var | 1000054002 |
✗ |
fi |
1000054003 |
let/var | 1000054003 |
✗ |
hi |
1000054004 |
let/var | 1000054004 |
✗ |
Ui |
1000054005 |
let/var | 1000054005 |
✗ |
ci |
1000054006 |
let/var | 1000054006 |
✗ |
_i |
1000054007 |
let/var | 1000054007 |
✗ |
pi |
1000066000 |
let/var | 1000066e3 |
✗ |
gi |
1000066001 |
let/var | 1000066001 |
✗ |
yi |
1000066002 |
let/var | 1000066002 |
✗ |
xi |
1000066003 |
let/var | 1000066003 |
✗ |
ui |
1000066004 |
let/var | 1000066004 |
✗ |
bi |
1000066005 |
let/var | 1000066005 |
✗ |
di |
1000066006 |
let/var | 1000066006 |
✗ |
wi |
1000066007 |
let/var | 1000066007 |
✗ |
mi |
1000066008 |
let/var | 1000066008 |
✗ |
Di |
1000066009 |
let/var | 1000066009 |
✗ |
Bi |
1000066010 |
let/var | 1000066010 |
✗ |
Li |
1000066011 |
let/var | 1000066011 |
✗ |
vi |
1000066012 |
let/var | 1000066012 |
✗ |
Ai |
1000066013 |
let/var | 1000066013 |
✗ |
ki |
1000340000 |
let/var | 100034e4 |
✗ |
Vi |
1000340001 |
let/var | 1000340001 |
✗ |
t |
number |
let/var | this._dataView.getUint32(this._offset,this._littleEndian)+2**32*this._dataVie... |
✗ |
e |
Uint8Array<any> |
let/var | new Uint8Array(this._dataView.buffer,this._dataView.byteOffset+this._offset,t) |
✗ |
n |
number |
let/var | this._offset |
✗ |
i |
number |
let/var | 0 |
✗ |
Fi |
Uint8Array<ArrayBuffer> |
let/var | new Uint8Array([0]) |
✗ |
Oi |
number[] |
let/var | [171,75,84,88,32,50,48,187,13,10,26,10] |
✗ |
e |
number |
let/var | 0 |
✗ |
n |
Uint8Array<ArrayBuffer> |
let/var | new Uint8Array(e) |
✗ |
i |
number |
let/var | 0 |
✗ |
e |
Uint8Array<any> |
let/var | new Uint8Array(t.buffer,t.byteOffset,Oi.length) |
✗ |
n |
Ii |
let/var | new Ii |
✗ |
i |
number |
let/var | 17*Uint32Array.BYTES_PER_ELEMENT |
✗ |
s |
Si |
let/var | new Si(t,Oi.length,i,!0) |
✗ |
c |
Si |
let/var | new Si(t,Oi.length+i,3*a*8,!0) |
✗ |
_ |
Si |
let/var | new Si(t,r,o,!0) |
✗ |
p |
{ vendorId: number; descriptorType: n... |
let/var | {vendorId:_._skip(4)._nextUint16(),descriptorType:_._nextUint16(),versionNumb... |
✗ |
g |
number |
let/var | (p.descriptorBlockSize/4-6)/4 |
✗ |
e |
{ bitOffset: number; bitLength: numbe... |
let/var | {bitOffset:_._nextUint16(),bitLength:_._nextUint8(),channelType:_._nextUint8(... |
✗ |
y |
Si |
let/var | new Si(t,l,f,!0) |
✗ |
x |
Si |
let/var | new Si(t,h,U,!0) |
✗ |
B |
any[] |
let/var | [] |
✗ |
L |
number |
let/var | h+x._offset |
✗ |
v |
number |
let/var | L+d |
✗ |
A |
number |
let/var | v+w |
✗ |
k |
number |
let/var | A+m |
✗ |
V |
Uint8Array<any> |
let/var | new Uint8Array(t.buffer,t.byteOffset+L,d) |
✗ |
I |
Uint8Array<any> |
let/var | new Uint8Array(t.buffer,t.byteOffset+v,w) |
✗ |
S |
Uint8Array<any> |
let/var | new Uint8Array(t.buffer,t.byteOffset+A,m) |
✗ |
F |
Uint8Array<any> |
let/var | new Uint8Array(t.buffer,t.byteOffset+k,D) |
✗ |
zi |
{ keepWriter: boolean; } |
let/var | {keepWriter:!1} |
✗ |
n |
ArrayBuffer |
let/var | new ArrayBuffer(0) |
✗ |
e |
ArrayBuffer |
let/var | new ArrayBuffer(20+5*t.globalData.imageDescs.length*4) |
✗ |
i |
DataView<ArrayBuffer> |
let/var | new DataView(e) |
✗ |
n |
any |
let/var | t.globalData.imageDescs[e] |
✗ |
i |
any[] |
let/var | [] |
✗ |
s |
any |
let/var | t.keyValue |
✗ |
e |
any |
let/var | s[t] |
✗ |
a |
any |
let/var | "string"==typeof e?Ci([Ei(e),Fi]):e |
✗ |
r |
any |
let/var | n.byteLength+1+a.byteLength |
✗ |
r |
any |
let/var | t.dataFormatDescriptor[0] |
✗ |
o |
ArrayBuffer |
let/var | new ArrayBuffer(28+16*r.samples.length) |
✗ |
l |
DataView<ArrayBuffer> |
let/var | new DataView(o) |
✗ |
f |
number |
let/var | 24+16*r.samples.length |
✗ |
e |
any |
let/var | r.samples[t] |
✗ |
n |
number |
let/var | 28+16*t |
✗ |
h |
number |
let/var | Oi.length+68+3*t.levels.length*8 |
✗ |
U |
number |
let/var | h+o.byteLength |
✗ |
c |
number |
let/var | n.byteLength>0?U+a.byteLength:0 |
✗ |
_ |
any[] |
let/var | [] |
✗ |
p |
DataView<ArrayBuffer> |
let/var | new DataView(new ArrayBuffer(3*t.levels.length*8)) |
✗ |
g |
Uint32Array<any> |
let/var | new Uint32Array(t.levels.length) |
✗ |
y |
number |
let/var | 0 |
✗ |
s |
number |
let/var | n |
✗ |
n |
number |
let/var | 1 |
✗ |
i |
any[] |
let/var | [t.pixelWidth,t.pixelHeight,t.pixelDepth] |
✗ |
x |
number |
let/var | (c\|\|U+a.byteLength)+n.byteLength |
✗ |
n |
any |
let/var | t.levels[e] |
✗ |
n |
any |
let/var | t.levels[e] |
✗ |
u |
ArrayBuffer |
let/var | new ArrayBuffer(68) |
✗ |
b |
DataView<ArrayBuffer> |
let/var | new DataView(u) |
✗ |
Functions¶
Si._nextUint8(): number
¶
Returns: number
Calls:
this._dataView.getUint8
Si._nextUint16(): number
¶
Returns: number
Calls:
this._dataView.getUint16
Code
Si._nextUint32(): number
¶
Returns: number
Calls:
this._dataView.getUint32
Code
Si._nextUint64(): number
¶
Returns: number
Calls:
this._dataView.getUint32
Code
Si._nextInt32(): number
¶
Returns: number
Calls:
this._dataView.getInt32
Code
Si._nextUint8Array(t: any): Uint8Array<any>
¶
Parameters:
t
any
Returns: Uint8Array<any>
Code
Si._skip(t: any): this
¶
Parameters:
t
any
Returns: this
Si._scan(t: any, e: any): Uint8Array<any>
¶
Parameters:
t
any
e
any
Returns: Uint8Array<any>
Calls:
this._dataView.getUint8
Code
Ei(t: any): Uint8Array<ArrayBufferLike>
¶
Parameters:
t
any
Returns: Uint8Array<ArrayBufferLike>
Calls:
(new TextEncoder).encode
Ti(t: any): string
¶
Parameters:
t
any
Returns: string
Calls:
(new TextDecoder).decode
Ci(t: any): Uint8Array<ArrayBuffer>
¶
Parameters:
t
any
Returns: Uint8Array<ArrayBuffer>
Calls:
n.set
Code
Mi(t: any, e: any): number
¶
Parameters:
t
any
e
any
Returns: number
Calls:
Math.ceil
Pi(t: any): Ii
¶
Parameters:
t
any
Returns: Ii
Calls:
s._nextUint32
s._nextUint64
n.levels.push
c._nextUint64
_._skip(4)._nextUint16
_._nextUint16
_._nextUint8
_._nextInt32
_._nextUint32
n.dataFormatDescriptor.push
y._nextUint32
y._scan
Ti
y._nextUint8Array
i.match
t.substring
t.lastIndexOf
y._skip
x._nextUint16
x._nextUint32
B.push
Code
function Pi(t){const e=new Uint8Array(t.buffer,t.byteOffset,Oi.length);if(e[0]!==Oi[0]||e[1]!==Oi[1]||e[2]!==Oi[2]||e[3]!==Oi[3]||e[4]!==Oi[4]||e[5]!==Oi[5]||e[6]!==Oi[6]||e[7]!==Oi[7]||e[8]!==Oi[8]||e[9]!==Oi[9]||e[10]!==Oi[10]||e[11]!==Oi[11])throw new Error("Missing KTX 2.0 identifier.");const n=new Ii,i=17*Uint32Array.BYTES_PER_ELEMENT,s=new Si(t,Oi.length,i,!0);n.vkFormat=s._nextUint32(),n.typeSize=s._nextUint32(),n.pixelWidth=s._nextUint32(),n.pixelHeight=s._nextUint32(),n.pixelDepth=s._nextUint32(),n.layerCount=s._nextUint32(),n.faceCount=s._nextUint32();const a=s._nextUint32();n.supercompressionScheme=s._nextUint32();const r=s._nextUint32(),o=s._nextUint32(),l=s._nextUint32(),f=s._nextUint32(),h=s._nextUint64(),U=s._nextUint64(),c=new Si(t,Oi.length+i,3*a*8,!0);for(let e=0;e<a;e++)n.levels.push({levelData:new Uint8Array(t.buffer,t.byteOffset+c._nextUint64(),c._nextUint64()),uncompressedByteLength:c._nextUint64()});const _=new Si(t,r,o,!0),p={vendorId:_._skip(4)._nextUint16(),descriptorType:_._nextUint16(),versionNumber:_._nextUint16(),descriptorBlockSize:_._nextUint16(),colorModel:_._nextUint8(),colorPrimaries:_._nextUint8(),transferFunction:_._nextUint8(),flags:_._nextUint8(),texelBlockDimension:[_._nextUint8(),_._nextUint8(),_._nextUint8(),_._nextUint8()],bytesPlane:[_._nextUint8(),_._nextUint8(),_._nextUint8(),_._nextUint8(),_._nextUint8(),_._nextUint8(),_._nextUint8(),_._nextUint8()],samples:[]},g=(p.descriptorBlockSize/4-6)/4;for(let t=0;t<g;t++){const e={bitOffset:_._nextUint16(),bitLength:_._nextUint8(),channelType:_._nextUint8(),samplePosition:[_._nextUint8(),_._nextUint8(),_._nextUint8(),_._nextUint8()],sampleLower:-Infinity,sampleUpper:Infinity};64&e.channelType?(e.sampleLower=_._nextInt32(),e.sampleUpper=_._nextInt32()):(e.sampleLower=_._nextUint32(),e.sampleUpper=_._nextUint32()),p.samples[t]=e}n.dataFormatDescriptor.length=0,n.dataFormatDescriptor.push(p);const y=new Si(t,l,f,!0);for(;y._offset<f;){const t=y._nextUint32(),e=y._scan(t),i=Ti(e);if(n.keyValue[i]=y._nextUint8Array(t-e.byteLength-1),i.match(/^ktx/i)){const t=Ti(n.keyValue[i]);n.keyValue[i]=t.substring(0,t.lastIndexOf("\0"))}y._skip(t%4?4-t%4:0)}if(U<=0)return n;const x=new Si(t,h,U,!0),u=x._nextUint16(),b=x._nextUint16(),d=x._nextUint32(),w=x._nextUint32(),m=x._nextUint32(),D=x._nextUint32(),B=[];for(let t=0;t<a;t++)B.push({imageFlags:x._nextUint32(),rgbSliceByteOffset:x._nextUint32(),rgbSliceByteLength:x._nextUint32(),alphaSliceByteOffset:x._nextUint32(),alphaSliceByteLength:x._nextUint32()});const L=h+x._offset,v=L+d,A=v+w,k=A+m,V=new Uint8Array(t.buffer,t.byteOffset+L,d),I=new Uint8Array(t.buffer,t.byteOffset+v,w),S=new Uint8Array(t.buffer,t.byteOffset+A,m),F=new Uint8Array(t.buffer,t.byteOffset+k,D);return n.globalData={endpointCount:u,selectorCount:b,imageDescs:B,endpointsData:V,selectorsData:I,tablesData:S,extendedData:F},n}
Wi(t: any, e: any): Uint8Array<ArrayBuffer>
¶
Parameters:
t
any
e
any
Returns: Uint8Array<ArrayBuffer>
Calls:
i.setUint16
i.setUint32
Ci
Ei
Mi
i.push
new Uint8Array(o).fill
l.setUint32
l.setUint16
l.setUint8
Array.isArray
l.setInt32
complex_call_9512
Math.max
Math.min
complex_call_9600
complex_call_9652
complex_call_9726
Math.ceil
Math.floor
Math.pow
_.push
p.setBigUint64
BigInt
b.setUint32
b.setBigUint64
Code
function Wi(t,e){void 0===e&&(e={}),e={...zi,...e};let n=new ArrayBuffer(0);if(t.globalData){const e=new ArrayBuffer(20+5*t.globalData.imageDescs.length*4),i=new DataView(e);i.setUint16(0,t.globalData.endpointCount,!0),i.setUint16(2,t.globalData.selectorCount,!0),i.setUint32(4,t.globalData.endpointsData.byteLength,!0),i.setUint32(8,t.globalData.selectorsData.byteLength,!0),i.setUint32(12,t.globalData.tablesData.byteLength,!0),i.setUint32(16,t.globalData.extendedData.byteLength,!0);for(let e=0;e<t.globalData.imageDescs.length;e++){const n=t.globalData.imageDescs[e];i.setUint32(20+5*e*4+0,n.imageFlags,!0),i.setUint32(20+5*e*4+4,n.rgbSliceByteOffset,!0),i.setUint32(20+5*e*4+8,n.rgbSliceByteLength,!0),i.setUint32(20+5*e*4+12,n.alphaSliceByteOffset,!0),i.setUint32(20+5*e*4+16,n.alphaSliceByteLength,!0)}n=Ci([e,t.globalData.endpointsData,t.globalData.selectorsData,t.globalData.tablesData,t.globalData.extendedData])}const i=[];let s=t.keyValue;e.keepWriter||(s={...t.keyValue,KTXwriter:"KTX-Parse v0.7.1"});for(const t in s){const e=s[t],n=Ei(t),a="string"==typeof e?Ci([Ei(e),Fi]):e,r=n.byteLength+1+a.byteLength,o=Mi(r,4);i.push(Ci([new Uint32Array([r]),n,Fi,a,new Uint8Array(o).fill(0)]))}const a=Ci(i);if(1!==t.dataFormatDescriptor.length||0!==t.dataFormatDescriptor[0].descriptorType)throw new Error("Only BASICFORMAT Data Format Descriptor output supported.");const r=t.dataFormatDescriptor[0],o=new ArrayBuffer(28+16*r.samples.length),l=new DataView(o),f=24+16*r.samples.length;if(l.setUint32(0,o.byteLength,!0),l.setUint16(4,r.vendorId,!0),l.setUint16(6,r.descriptorType,!0),l.setUint16(8,r.versionNumber,!0),l.setUint16(10,f,!0),l.setUint8(12,r.colorModel),l.setUint8(13,r.colorPrimaries),l.setUint8(14,r.transferFunction),l.setUint8(15,r.flags),!Array.isArray(r.texelBlockDimension))throw new Error("texelBlockDimension is now an array. For dimensionality `d`, set `d - 1`.");l.setUint8(16,r.texelBlockDimension[0]),l.setUint8(17,r.texelBlockDimension[1]),l.setUint8(18,r.texelBlockDimension[2]),l.setUint8(19,r.texelBlockDimension[3]);for(let t=0;t<8;t++)l.setUint8(20+t,r.bytesPlane[t]);for(let t=0;t<r.samples.length;t++){const e=r.samples[t],n=28+16*t;if(e.channelID)throw new Error("channelID has been renamed to channelType.");l.setUint16(n+0,e.bitOffset,!0),l.setUint8(n+2,e.bitLength),l.setUint8(n+3,e.channelType),l.setUint8(n+4,e.samplePosition[0]),l.setUint8(n+5,e.samplePosition[1]),l.setUint8(n+6,e.samplePosition[2]),l.setUint8(n+7,e.samplePosition[3]),64&e.channelType?(l.setInt32(n+8,e.sampleLower,!0),l.setInt32(n+12,e.sampleUpper,!0)):(l.setUint32(n+8,e.sampleLower,!0),l.setUint32(n+12,e.sampleUpper,!0))}const h=Oi.length+68+3*t.levels.length*8,U=h+o.byteLength;let c=n.byteLength>0?U+a.byteLength:0;c%8&&(c+=8-c%8);const _=[],p=new DataView(new ArrayBuffer(3*t.levels.length*8)),g=new Uint32Array(t.levels.length);let y=0;0===t.supercompressionScheme&&(y=function(t,e){const n=Math.max(t,4),i=Math.min(t,4);let s=n;for(;s%i!=0;)s+=n;return s}(function(t){return t.levels[0].levelData.byteLength/function(t,e){let n=1;const i=[t.pixelWidth,t.pixelHeight,t.pixelDepth],s=function(t){const[e,n,i]=t.dataFormatDescriptor[0].texelBlockDimension;return[e+1,n+1,i+1]}(t);for(let t=0;t<3;t++)if(i[t]>0){const e=Math.ceil(Math.floor(i[t]*Math.pow(2,-0))/s[t]);n*=Math.max(1,e)}return t.layerCount>0&&(n*=t.layerCount),t.faceCount>0&&(n*=t.faceCount),n}(t)}(t)));let x=(c||U+a.byteLength)+n.byteLength;for(let e=t.levels.length-1;e>=0;e--){if(x%y){const t=Mi(x,y);_.push(new Uint8Array(t)),x+=t}const n=t.levels[e];_.push(n.levelData),g[e]=x,x+=n.levelData.byteLength}for(let e=0;e<t.levels.length;e++){const n=t.levels[e];p.setBigUint64(24*e+0,BigInt(g[e]),!0),p.setBigUint64(24*e+8,BigInt(n.levelData.byteLength),!0),p.setBigUint64(24*e+16,BigInt(n.uncompressedByteLength),!0)}const u=new ArrayBuffer(68),b=new DataView(u);return b.setUint32(0,t.vkFormat,!0),b.setUint32(4,t.typeSize,!0),b.setUint32(8,t.pixelWidth,!0),b.setUint32(12,t.pixelHeight,!0),b.setUint32(16,t.pixelDepth,!0),b.setUint32(20,t.layerCount,!0),b.setUint32(24,t.faceCount,!0),b.setUint32(28,t.levels.length,!0),b.setUint32(32,t.supercompressionScheme,!0),b.setUint32(36,h,!0),b.setUint32(40,o.byteLength,!0),b.setUint32(44,U,!0),b.setUint32(48,a.byteLength,!0),b.setBigUint64(52,BigInt(n.byteLength>0?c:0),!0),b.setBigUint64(60,BigInt(n.byteLength),!0),new Uint8Array(Ci([new Uint8Array(Oi).buffer,u,p.buffer,o,a,c>0?new ArrayBuffer(c-(U+a.byteLength)):new ArrayBuffer(0),n,..._]))}
Classes¶
Ii
¶
Class Code
class Ii{constructor(){this.vkFormat=0,this.typeSize=1,this.pixelWidth=0,this.pixelHeight=0,this.pixelDepth=0,this.layerCount=0,this.faceCount=1,this.supercompressionScheme=0,this.levels=[],this.dataFormatDescriptor=[{vendorId:0,descriptorType:0,descriptorBlockSize:0,versionNumber:2,colorModel:0,colorPrimaries:1,transferFunction:2,flags:0,texelBlockDimension:[0,0,0,0],bytesPlane:[0,0,0,0,0,0,0,0],samples:[]}],this.keyValue={},this.globalData=null}}
Si
¶
Class Code
class Si{constructor(t,e,n,i){this._dataView=void 0,this._littleEndian=void 0,this._offset=void 0,this._dataView=new DataView(t.buffer,t.byteOffset+e,n),this._littleEndian=i,this._offset=0}_nextUint8(){const t=this._dataView.getUint8(this._offset);return this._offset+=1,t}_nextUint16(){const t=this._dataView.getUint16(this._offset,this._littleEndian);return this._offset+=2,t}_nextUint32(){const t=this._dataView.getUint32(this._offset,this._littleEndian);return this._offset+=4,t}_nextUint64(){const t=this._dataView.getUint32(this._offset,this._littleEndian)+2**32*this._dataView.getUint32(this._offset+4,this._littleEndian);return this._offset+=8,t}_nextInt32(){const t=this._dataView.getInt32(this._offset,this._littleEndian);return this._offset+=4,t}_nextUint8Array(t){const e=new Uint8Array(this._dataView.buffer,this._dataView.byteOffset+this._offset,t);return this._offset+=t,e}_skip(t){return this._offset+=t,this}_scan(t,e){void 0===e&&(e=0);const n=this._offset;let i=0;for(;this._dataView.getUint8(this._offset)!==e&&i<t;)i++,this._offset++;return i<t&&this._offset++,new Uint8Array(this._dataView.buffer,this._dataView.byteOffset+n,i)}}