-
Notifications
You must be signed in to change notification settings - Fork 1
/
Vst.js
218 lines (191 loc) · 6.48 KB
/
Vst.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
// This is a generated file! Please edit source .ksy file and use kaitai-struct-compiler to rebuild
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
define(['kaitai-struct/KaitaiStream'], factory);
} else if (typeof module === 'object' && module.exports) {
module.exports = factory(require('kaitai-struct/KaitaiStream'));
} else {
root.Vst = factory(root.KaitaiStream);
}
}(this, function (KaitaiStream) {
var Vst = (function() {
function Vst(_io, _parent, _root) {
this._io = _io;
this._parent = _parent;
this._root = _root || this;
this._read();
}
Vst.prototype._read = function() {
this.vistaHeader = new VstHeader(this._io, this, this._root);
this.boundingBox = new BoundingBox(this._io, this, this._root);
this.textureRef = this._io.readBytes(2048);
this.coordinateSystem = this._io.readBytes(4096);
}
var VstHeader = Vst.VstHeader = (function() {
function VstHeader(_io, _parent, _root) {
this._io = _io;
this._parent = _parent;
this._root = _root || this;
this._read();
}
VstHeader.prototype._read = function() {
this.magic = this._io.readBytes(3);
if (!((KaitaiStream.byteArrayCompare(this.magic, [86, 83, 84]) == 0))) {
throw new KaitaiStream.ValidationNotEqualError([86, 83, 84], this.magic, this._io, "/types/vst_header/seq/0");
}
this.end = KaitaiStream.bytesToStr(this._io.readBytes(1), "ASCII");
this.endianness = this._io.readU4le();
this.major = this._io.readU4le();
this.minor = this._io.readU4le();
this.implId = this._io.readU4le();
this.res = this._io.readU8le();
this.texturesCount = this._io.readU4le();
this.vertexCount = this._io.readU4le();
this.lodsCount = this._io.readU4le();
}
return VstHeader;
})();
var Vertex = Vst.Vertex = (function() {
function Vertex(_io, _parent, _root) {
this._io = _io;
this._parent = _parent;
this._root = _root || this;
this._read();
}
Vertex.prototype._read = function() {
this.s = this._io.readF4le();
this.t = this._io.readF4le();
this.x = this._io.readF4le();
this.y = this._io.readF4le();
this.z = this._io.readF4le();
}
return Vertex;
})();
var LodHeader = Vst.LodHeader = (function() {
function LodHeader(_io, _parent, _root) {
this._io = _io;
this._parent = _parent;
this._root = _root || this;
this._read();
}
LodHeader.prototype._read = function() {
this.size = this._io.readU4le();
this.reserved = this._io.readU8le();
this.vertexCount = this._io.readU4le();
this.threshold = this._io.readF4le();
this.patchesCount = this._io.readU4le();
this.highestVertex = this._io.readU4le();
}
return LodHeader;
})();
var Lod = Vst.Lod = (function() {
function Lod(_io, _parent, _root) {
this._io = _io;
this._parent = _parent;
this._root = _root || this;
this._read();
}
Lod.prototype._read = function() {
this.header = new LodHeader(this._io, this, this._root);
this.boundingBox = new BoundingBox(this._io, this, this._root);
this.patches = new Array(this.header.patchesCount);
for (var i = 0; i < this.header.patchesCount; i++) {
this.patches[i] = new Patch(this._io, this, this._root);
}
}
return Lod;
})();
var VertexList = Vst.VertexList = (function() {
function VertexList(_io, _parent, _root) {
this._io = _io;
this._parent = _parent;
this._root = _root || this;
this._read();
}
VertexList.prototype._read = function() {
this.vertex = new Vertex(this._io, this, this._root);
}
return VertexList;
})();
var PatchHeader = Vst.PatchHeader = (function() {
function PatchHeader(_io, _parent, _root) {
this._io = _io;
this._parent = _parent;
this._root = _root || this;
this._read();
}
PatchHeader.prototype._read = function() {
this.reserved = this._io.readU8le();
this.patchType = this._io.readU4le();
this.textureIndex = this._io.readU4le();
this.stripsCount = this._io.readU4le();
this.indexCount = this._io.readU4le();
}
return PatchHeader;
})();
var BoundingBox = Vst.BoundingBox = (function() {
function BoundingBox(_io, _parent, _root) {
this._io = _io;
this._parent = _parent;
this._root = _root || this;
this._read();
}
BoundingBox.prototype._read = function() {
this.xmin = this._io.readF4le();
this.ymin = this._io.readF4le();
this.zmin = this._io.readF4le();
this.xmax = this._io.readF4le();
this.ymax = this._io.readF4le();
this.zmax = this._io.readF4le();
}
return BoundingBox;
})();
var Patch = Vst.Patch = (function() {
function Patch(_io, _parent, _root) {
this._io = _io;
this._parent = _parent;
this._root = _root || this;
this._read();
}
Patch.prototype._read = function() {
this.header = new PatchHeader(this._io, this, this._root);
this.trianglesStripsLengths = new Array(this.header.stripsCount);
for (var i = 0; i < this.header.stripsCount; i++) {
this.trianglesStripsLengths[i] = this._io.readU4le();
}
this.pointersToVertexOfFaces = new Array(this.header.indexCount);
for (var i = 0; i < this.header.indexCount; i++) {
this.pointersToVertexOfFaces[i] = this._io.readU4le();
}
}
return Patch;
})();
Object.defineProperty(Vst.prototype, 'vertices', {
get: function() {
if (this._m_vertices !== undefined)
return this._m_vertices;
this._m_vertices = new Array(this.vistaHeader.vertexCount);
for (var i = 0; i < this.vistaHeader.vertexCount; i++) {
this._m_vertices[i] = new Vertex(this._io, this, this._root);
}
return this._m_vertices;
}
});
Object.defineProperty(Vst.prototype, 'lods', {
get: function() {
if (this._m_lods !== undefined)
return this._m_lods;
var _pos = this._io.pos;
this._io.seek(((((40 + 24) + (this.textureRef.length * this.vistaHeader.texturesCount)) + this.coordinateSystem.length) + ((this.vistaHeader.vertexCount * 4) * 5)));
this._m_lods = new Array(this.vistaHeader.lodsCount);
for (var i = 0; i < this.vistaHeader.lodsCount; i++) {
this._m_lods[i] = new Lod(this._io, this, this._root);
}
this._io.seek(_pos);
return this._m_lods;
}
});
return Vst;
})();
return Vst;
}));