rw-parser-ng 2.0.0

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.
Files changed (72) hide show
  1. package/LICENSE +674 -0
  2. package/README.md +88 -0
  3. package/lib/index.d.ts +6 -0
  4. package/lib/index.js +26 -0
  5. package/lib/renderware/RwFile.d.ts +10 -0
  6. package/lib/renderware/RwFile.js +33 -0
  7. package/lib/renderware/RwSections.d.ts +20 -0
  8. package/lib/renderware/RwSections.js +29 -0
  9. package/lib/renderware/dff/DffModelType.d.ts +5 -0
  10. package/lib/renderware/dff/DffModelType.js +9 -0
  11. package/lib/renderware/dff/DffParser.d.ts +155 -0
  12. package/lib/renderware/dff/DffParser.js +418 -0
  13. package/lib/renderware/errors/RwParseError.d.ts +6 -0
  14. package/lib/renderware/errors/RwParseError.js +34 -0
  15. package/lib/renderware/txd/TxdParser.d.ts +38 -0
  16. package/lib/renderware/txd/TxdParser.js +185 -0
  17. package/lib/renderware/utils/ImageDecoder.d.ts +23 -0
  18. package/lib/renderware/utils/ImageDecoder.js +512 -0
  19. package/lib/renderware/utils/ImageFormatEnums.d.ts +25 -0
  20. package/lib/renderware/utils/ImageFormatEnums.js +32 -0
  21. package/lib/renderware/utils/RwVersion.d.ts +7 -0
  22. package/lib/renderware/utils/RwVersion.js +30 -0
  23. package/lib/scripts/sort_models.d.ts +1 -0
  24. package/lib/scripts/sort_models.js +185 -0
  25. package/lib/scripts/sort_worker.d.ts +1 -0
  26. package/lib/scripts/sort_worker.js +140 -0
  27. package/lib/src/index.d.ts +8 -0
  28. package/lib/src/index.js +28 -0
  29. package/lib/src/renderware/RwFile.d.ts +10 -0
  30. package/lib/src/renderware/RwFile.js +33 -0
  31. package/lib/src/renderware/RwSections.d.ts +20 -0
  32. package/lib/src/renderware/RwSections.js +29 -0
  33. package/lib/src/renderware/common/types.d.ts +50 -0
  34. package/lib/src/renderware/common/types.js +2 -0
  35. package/lib/src/renderware/dff/DffModelType.d.ts +5 -0
  36. package/lib/src/renderware/dff/DffModelType.js +9 -0
  37. package/lib/src/renderware/dff/DffParser.d.ts +112 -0
  38. package/lib/src/renderware/dff/DffParser.js +418 -0
  39. package/lib/src/renderware/errors/RwParseError.d.ts +6 -0
  40. package/lib/src/renderware/errors/RwParseError.js +34 -0
  41. package/lib/src/renderware/ifp/IfpData.d.ts +28 -0
  42. package/lib/src/renderware/ifp/IfpData.js +9 -0
  43. package/lib/src/renderware/ifp/IfpParser.d.ts +12 -0
  44. package/lib/src/renderware/ifp/IfpParser.js +196 -0
  45. package/lib/src/renderware/txd/TxdParser.d.ts +38 -0
  46. package/lib/src/renderware/txd/TxdParser.js +185 -0
  47. package/lib/src/renderware/utils/ImageDecoder.d.ts +23 -0
  48. package/lib/src/renderware/utils/ImageDecoder.js +512 -0
  49. package/lib/src/renderware/utils/ImageFormatEnums.d.ts +25 -0
  50. package/lib/src/renderware/utils/ImageFormatEnums.js +32 -0
  51. package/lib/src/renderware/utils/RwVersion.d.ts +7 -0
  52. package/lib/src/renderware/utils/RwVersion.js +30 -0
  53. package/lib/src/utils/ByteStream.d.ts +17 -0
  54. package/lib/src/utils/ByteStream.js +65 -0
  55. package/lib/utils/ByteStream.d.ts +16 -0
  56. package/lib/utils/ByteStream.js +60 -0
  57. package/package.json +64 -0
  58. package/src/index.ts +10 -0
  59. package/src/renderware/RwFile.ts +22 -0
  60. package/src/renderware/RwSections.ts +27 -0
  61. package/src/renderware/common/types.ts +59 -0
  62. package/src/renderware/dff/DffModelType.ts +5 -0
  63. package/src/renderware/dff/DffParser.ts +596 -0
  64. package/src/renderware/errors/RwParseError.ts +11 -0
  65. package/src/renderware/ifp/IfpData.ts +33 -0
  66. package/src/renderware/ifp/IfpParser.ts +203 -0
  67. package/src/renderware/txd/TxdParser.ts +234 -0
  68. package/src/renderware/utils/ImageDecoder.ts +571 -0
  69. package/src/renderware/utils/ImageFormatEnums.ts +28 -0
  70. package/src/renderware/utils/RwVersion.ts +28 -0
  71. package/src/utils/ByteStream.ts +75 -0
  72. package/tsconfig.json +68 -0
@@ -0,0 +1,418 @@
1
+ "use strict";
2
+ var __extends = (this && this.__extends) || (function () {
3
+ var extendStatics = function (d, b) {
4
+ extendStatics = Object.setPrototypeOf ||
5
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
+ return extendStatics(d, b);
8
+ };
9
+ return function (d, b) {
10
+ if (typeof b !== "function" && b !== null)
11
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
+ extendStatics(d, b);
13
+ function __() { this.constructor = d; }
14
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
+ };
16
+ })();
17
+ var __importDefault = (this && this.__importDefault) || function (mod) {
18
+ return (mod && mod.__esModule) ? mod : { "default": mod };
19
+ };
20
+ Object.defineProperty(exports, "__esModule", { value: true });
21
+ exports.DffParser = void 0;
22
+ var RwFile_1 = require("../RwFile");
23
+ var RwSections_1 = require("../RwSections");
24
+ var RwParseError_1 = require("../errors/RwParseError");
25
+ var RwVersion_1 = __importDefault(require("../utils/RwVersion"));
26
+ var DffModelType_1 = require("./DffModelType");
27
+ var DffParser = /** @class */ (function (_super) {
28
+ __extends(DffParser, _super);
29
+ function DffParser(buffer) {
30
+ return _super.call(this, buffer) || this;
31
+ }
32
+ DffParser.prototype.parse = function () {
33
+ var version;
34
+ var versionNumber;
35
+ var atomics = [];
36
+ var dummies = [];
37
+ var animNodes = [];
38
+ var geometryList = null;
39
+ var frameList = null;
40
+ while (this.getPosition() < this.getSize()) {
41
+ var header = this.readSectionHeader();
42
+ if (header.sectionType === 0) {
43
+ break;
44
+ }
45
+ if (header.sectionSize == 0) {
46
+ continue;
47
+ }
48
+ switch (header.sectionType) {
49
+ case RwSections_1.RwSections.RwClump:
50
+ // Multiple clumps are used in SA player models, so we should eventually support it
51
+ versionNumber = RwVersion_1.default.unpackVersion(header.versionNumber);
52
+ version = RwVersion_1.default.versions[versionNumber];
53
+ break;
54
+ case RwSections_1.RwSections.RwFrameList:
55
+ frameList = this.readFrameList();
56
+ break;
57
+ case RwSections_1.RwSections.RwExtension:
58
+ var extensionHeader = this.readSectionHeader();
59
+ switch (extensionHeader.sectionType) {
60
+ case RwSections_1.RwSections.RwNodeName:
61
+ dummies.push(this.readString(extensionHeader.sectionSize));
62
+ break;
63
+ case RwSections_1.RwSections.RwAnim:
64
+ animNodes.push(this.readAnimNode());
65
+ break;
66
+ default:
67
+ console.debug("Extension type ".concat(extensionHeader.sectionType, " (").concat(extensionHeader.sectionType.toString(16), ") not found at offset (").concat(this.getPosition().toString(16), "). Skipping ").concat(extensionHeader.sectionSize, " bytes."));
68
+ this.skip(extensionHeader.sectionSize);
69
+ break;
70
+ }
71
+ break;
72
+ case RwSections_1.RwSections.RwGeometryList:
73
+ geometryList = this.readGeometryList();
74
+ break;
75
+ case RwSections_1.RwSections.RwAtomic:
76
+ var atomic = this.readAtomic();
77
+ atomics[atomic.geometryIndex] = atomic.frameIndex;
78
+ break;
79
+ case RwSections_1.RwSections.RwNodeName:
80
+ // For some reason, this frame is outside RwExtension.
81
+ dummies.push(this.readString(header.sectionSize));
82
+ break;
83
+ case RwSections_1.RwSections.RwAnim:
84
+ // For III / VC models
85
+ animNodes.push(this.readAnimNode());
86
+ break;
87
+ default:
88
+ console.debug("Section type ".concat(header.sectionType, " (").concat(header.sectionType.toString(16), ") not found at offset (").concat(this.getPosition().toString(16), "). Skipping ").concat(header.sectionSize, " bytes."));
89
+ this.skip(header.sectionSize);
90
+ break;
91
+ }
92
+ }
93
+ if (!version || !versionNumber) {
94
+ throw new RwParseError_1.RwParseStructureNotFoundError('version');
95
+ }
96
+ var modelType = DffModelType_1.DffModelType.GENERIC;
97
+ if (geometryList === null || geometryList === void 0 ? void 0 : geometryList.geometries.some(function (g) { return g.skin; })) {
98
+ modelType = DffModelType_1.DffModelType.SKIN;
99
+ }
100
+ else if (dummies.some(function (d) { return d.toLowerCase().includes('wheel') || d.toLowerCase().includes('chassis'); })) {
101
+ modelType = DffModelType_1.DffModelType.VEHICLE;
102
+ }
103
+ return {
104
+ modelType: modelType,
105
+ version: version,
106
+ versionNumber: versionNumber,
107
+ geometryList: geometryList,
108
+ frameList: frameList,
109
+ atomics: atomics,
110
+ dummies: dummies,
111
+ animNodes: animNodes,
112
+ };
113
+ };
114
+ DffParser.prototype.readClump = function () {
115
+ var versionNumber = this.readSectionHeader().versionNumber;
116
+ var atomicCount = this.readUint32();
117
+ var lightCount;
118
+ var cameraCount;
119
+ if (versionNumber > 0x33000) {
120
+ lightCount = this.readUint32();
121
+ cameraCount = this.readUint32();
122
+ }
123
+ return { atomicCount: atomicCount, lightCount: lightCount, cameraCount: cameraCount };
124
+ };
125
+ DffParser.prototype.readFrameList = function () {
126
+ this.readSectionHeader();
127
+ var frameCount = this.readUint32();
128
+ var frames = [];
129
+ for (var i = 0; i < frameCount; i++) {
130
+ // All these could probably be moved to readFrameData()
131
+ var rotationMatrix = {
132
+ right: { x: this.readFloat(), y: this.readFloat(), z: this.readFloat() },
133
+ up: { x: this.readFloat(), y: this.readFloat(), z: this.readFloat() },
134
+ at: { x: this.readFloat(), y: this.readFloat(), z: this.readFloat() },
135
+ };
136
+ var coordinatesOffset = { x: this.readFloat(), y: this.readFloat(), z: this.readFloat() };
137
+ var parentFrame = this.readInt32();
138
+ // Skip matrix creation internal flags
139
+ // They are read by the game but are not used
140
+ this.skip(4);
141
+ frames.push({ rotationMatrix: rotationMatrix, coordinatesOffset: coordinatesOffset, parentFrame: parentFrame });
142
+ }
143
+ return { frameCount: frameCount, frames: frames };
144
+ };
145
+ DffParser.prototype.readGeometryList = function () {
146
+ var header = this.readSectionHeader();
147
+ var geometricObjectCount = this.readUint32();
148
+ var geometries = [];
149
+ for (var i = 0; i < geometricObjectCount; i++) {
150
+ this.readSectionHeader();
151
+ this.readSectionHeader();
152
+ var versionNumber = RwVersion_1.default.unpackVersion(header.versionNumber);
153
+ var geometryData = this.readGeometry(versionNumber);
154
+ geometries.push(geometryData);
155
+ }
156
+ return { geometricObjectCount: geometricObjectCount, geometries: geometries };
157
+ };
158
+ DffParser.prototype.readGeometry = function (versionNumber) {
159
+ var flags = this.readUint16();
160
+ var textureCoordinatesCount = this.readUint8();
161
+ var _nativeGeometryFlags = this.readUint8();
162
+ var triangleCount = this.readUint32();
163
+ var vertexCount = this.readUint32();
164
+ var _morphTargetCount = this.readUint32();
165
+ // Surface properties
166
+ var _ambient;
167
+ var _specular;
168
+ var _diffuse;
169
+ if (versionNumber < 0x34000) {
170
+ _ambient = this.readFloat();
171
+ _specular = this.readFloat();
172
+ _diffuse = this.readFloat();
173
+ }
174
+ var _isTriangleStrip = (flags & (1 << 0)) !== 0;
175
+ var _vertexTranslation = (flags & (1 << 1)) !== 0;
176
+ var isTexturedUV1 = (flags & (1 << 2)) !== 0;
177
+ var isGeometryPrelit = (flags & (1 << 3)) !== 0;
178
+ var _hasNormals = (flags & (1 << 4)) !== 0;
179
+ var _isGeometryLit = (flags & (1 << 5)) !== 0;
180
+ var _shouldModulateMaterialColor = (flags & (1 << 6)) !== 0;
181
+ var isTexturedUV2 = (flags & (1 << 7)) !== 0;
182
+ var vertexColorInformation = [];
183
+ var textureMappingInformation = [];
184
+ var triangleInformation = [];
185
+ // Geometry is marked as prelit
186
+ if (isGeometryPrelit) {
187
+ for (var i = 0; i < vertexCount; i++) {
188
+ vertexColorInformation[i] = { r: this.readUint8(), g: this.readUint8(), b: this.readUint8(), a: this.readUint8() };
189
+ }
190
+ }
191
+ // Geometry either has first or second texture
192
+ if (isTexturedUV1 || isTexturedUV2) {
193
+ for (var textureCoordinateIndex = 0; textureCoordinateIndex < textureCoordinatesCount; textureCoordinateIndex++) {
194
+ textureMappingInformation[textureCoordinateIndex] = [];
195
+ for (var vertexIndex = 0; vertexIndex < vertexCount; vertexIndex++) {
196
+ textureMappingInformation[textureCoordinateIndex][vertexIndex] = { u: this.readFloat(), v: this.readFloat() };
197
+ }
198
+ }
199
+ }
200
+ for (var i = 0; i < triangleCount; i++) {
201
+ // Information is written in this order
202
+ var vertex2 = this.readUint16();
203
+ var vertex1 = this.readUint16();
204
+ var materialId = this.readUint16();
205
+ var vertex3 = this.readUint16();
206
+ triangleInformation[i] = { vector: { x: vertex1, y: vertex2, z: vertex3 }, materialId: materialId };
207
+ }
208
+ // We are sure that there's only one morph target, but if
209
+ // we are wrong, we have to loop these through morphTargetCount
210
+ var boundingSphere = {
211
+ vector: { x: this.readFloat(), y: this.readFloat(), z: this.readFloat() },
212
+ radius: this.readFloat(),
213
+ };
214
+ var hasVertices = !!this.readUint32();
215
+ var hasNormals = !!this.readUint32();
216
+ var vertexInformation = [];
217
+ if (hasVertices) {
218
+ for (var i = 0; i < vertexCount; i++) {
219
+ vertexInformation[i] = { x: this.readFloat(), y: this.readFloat(), z: this.readFloat() };
220
+ }
221
+ }
222
+ var normalInformation = [];
223
+ if (hasNormals) {
224
+ for (var i = 0; i < vertexCount; i++) {
225
+ normalInformation[i] = { x: this.readFloat(), y: this.readFloat(), z: this.readFloat() };
226
+ }
227
+ }
228
+ var materialList = this.readMaterialList();
229
+ var sectionSize = this.readSectionHeader().sectionSize;
230
+ var position = this.getPosition();
231
+ var binMesh = this.readBinMesh();
232
+ var skin = undefined;
233
+ if (this.readSectionHeader().sectionType == RwSections_1.RwSections.RwSkin) {
234
+ skin = this.readSkin(vertexCount);
235
+ }
236
+ this.setPosition(position + sectionSize);
237
+ return {
238
+ textureCoordinatesCount: textureCoordinatesCount,
239
+ textureMappingInformation: textureMappingInformation,
240
+ boundingSphere: boundingSphere,
241
+ hasVertices: hasVertices,
242
+ hasNormals: hasNormals,
243
+ vertexColorInformation: vertexColorInformation,
244
+ vertexInformation: vertexInformation,
245
+ normalInformation: normalInformation,
246
+ triangleInformation: triangleInformation,
247
+ materialList: materialList,
248
+ binMesh: binMesh,
249
+ skin: skin,
250
+ };
251
+ };
252
+ DffParser.prototype.readBinMesh = function () {
253
+ this.readSectionHeader();
254
+ // Flags (0: triangle list, 1: triangle strip)
255
+ this.skip(4);
256
+ var meshCount = this.readUint32();
257
+ // Total number of indices
258
+ this.skip(4);
259
+ var meshes = [];
260
+ for (var i = 0; i < meshCount; i++) {
261
+ meshes.push(this.readMesh());
262
+ }
263
+ return {
264
+ meshCount: meshCount,
265
+ meshes: meshes
266
+ };
267
+ };
268
+ DffParser.prototype.readSkin = function (vertexCount) {
269
+ var boneCount = this.readUint8();
270
+ var usedBoneCount = this.readUint8();
271
+ var maxWeightsPerVertex = this.readUint8();
272
+ this.skip(1); // Padding
273
+ this.skip(usedBoneCount); // Skipping special indices
274
+ var boneVertexIndices = [];
275
+ var vertexWeights = [];
276
+ var inverseBoneMatrices = [];
277
+ for (var i = 0; i < vertexCount; i++) {
278
+ var indices = [];
279
+ for (var j = 0; j < 4; j++) {
280
+ indices.push(this.readUint8());
281
+ }
282
+ boneVertexIndices.push(indices);
283
+ }
284
+ for (var i = 0; i < vertexCount; i++) {
285
+ var weights = [];
286
+ for (var j = 0; j < 4; j++) {
287
+ weights.push(this.readFloat());
288
+ }
289
+ vertexWeights.push(weights);
290
+ }
291
+ for (var i = 0; i < boneCount; i++) {
292
+ var matrix4x4 = {
293
+ right: { x: this.readFloat(), y: this.readFloat(), z: this.readFloat(), t: this.readFloat() },
294
+ up: { x: this.readFloat(), y: this.readFloat(), z: this.readFloat(), t: this.readFloat() },
295
+ at: { x: this.readFloat(), y: this.readFloat(), z: this.readFloat(), t: this.readFloat() },
296
+ transform: { x: this.readFloat(), y: this.readFloat(), z: this.readFloat(), t: this.readFloat() },
297
+ };
298
+ inverseBoneMatrices.push(matrix4x4);
299
+ }
300
+ return {
301
+ boneCount: boneCount,
302
+ usedBoneCount: usedBoneCount,
303
+ maxWeightsPerVertex: maxWeightsPerVertex,
304
+ boneVertexIndices: boneVertexIndices,
305
+ vertexWeights: vertexWeights,
306
+ inverseBoneMatrices: inverseBoneMatrices,
307
+ };
308
+ };
309
+ DffParser.prototype.readAnimNode = function () {
310
+ this.skip(4); // Skipping AnimVersion property (0x100)
311
+ var boneId = this.readInt32();
312
+ var boneCount = this.readInt32();
313
+ var bones = [];
314
+ if (boneId == 0) {
315
+ this.skip(8); // Skipping flags and keyFrameSize properties
316
+ }
317
+ if (boneCount > 0) {
318
+ for (var i = 0; i < boneCount; i++) {
319
+ bones.push({
320
+ boneId: this.readInt32(),
321
+ boneIndex: this.readInt32(),
322
+ flags: this.readInt32()
323
+ });
324
+ }
325
+ }
326
+ return {
327
+ boneId: boneId,
328
+ bonesCount: boneCount,
329
+ bones: bones
330
+ };
331
+ };
332
+ DffParser.prototype.readMesh = function () {
333
+ var indexCount = this.readUint32();
334
+ var materialIndex = this.readUint32();
335
+ var indices = [];
336
+ for (var i = 0; i < indexCount; i++) {
337
+ indices.push(this.readUint32());
338
+ }
339
+ return {
340
+ indexCount: indexCount,
341
+ materialIndex: materialIndex,
342
+ indices: indices
343
+ };
344
+ };
345
+ DffParser.prototype.readMaterialList = function () {
346
+ this.readSectionHeader();
347
+ this.readSectionHeader();
348
+ var materialInstanceCount = this.readUint32();
349
+ var materialIndices = [];
350
+ for (var i = 0; i < materialInstanceCount; i++) {
351
+ var materialIndex = this.readInt32();
352
+ materialIndices.push(materialIndex);
353
+ }
354
+ var materialData = [];
355
+ for (var i = 0; i < materialInstanceCount; i++) {
356
+ var materialIndex = materialIndices[i];
357
+ if (materialIndex == -1) {
358
+ materialData.push(this.readMaterial());
359
+ }
360
+ else {
361
+ materialData.push(materialData[materialIndex]);
362
+ }
363
+ }
364
+ return { materialInstanceCount: materialInstanceCount, materialData: materialData };
365
+ };
366
+ DffParser.prototype.readMaterial = function () {
367
+ this.readSectionHeader();
368
+ var header = this.readSectionHeader();
369
+ // Flags - not used
370
+ this.skip(4);
371
+ var color = { r: this.readUint8(), g: this.readUint8(), b: this.readUint8(), a: this.readUint8() };
372
+ // Unknown - not used
373
+ this.skip(4);
374
+ var isTextured = this.readUint32() > 0;
375
+ // Surface properties
376
+ var ambient;
377
+ var specular;
378
+ var diffuse;
379
+ if (header.versionNumber > 0x30400) {
380
+ ambient = this.readFloat();
381
+ specular = this.readFloat();
382
+ diffuse = this.readFloat();
383
+ }
384
+ var texture;
385
+ if (isTextured) {
386
+ texture = this.readTexture();
387
+ }
388
+ // Skip various unused extensions
389
+ this.skip(this.readSectionHeader().sectionSize);
390
+ return { color: color, isTextured: isTextured, ambient: ambient, specular: specular, diffuse: diffuse, texture: texture };
391
+ };
392
+ DffParser.prototype.readTexture = function () {
393
+ this.readSectionHeader();
394
+ this.readSectionHeader();
395
+ var textureData = this.readUint32();
396
+ var textureFiltering = (textureData & 0xFF);
397
+ var uAddressing = (textureData & 0xF00) >> 8;
398
+ var vAddressing = (textureData & 0xF000) >> 12;
399
+ var usesMipLevels = (textureData & (1 << 16)) !== 0;
400
+ var textureNameSize = this.readSectionHeader().sectionSize;
401
+ var textureName = this.readString(textureNameSize);
402
+ // Skip various unused extensions
403
+ this.skip(this.readSectionHeader().sectionSize);
404
+ this.skip(this.readSectionHeader().sectionSize);
405
+ return { textureFiltering: textureFiltering, uAddressing: uAddressing, vAddressing: vAddressing, usesMipLevels: usesMipLevels, textureName: textureName };
406
+ };
407
+ DffParser.prototype.readAtomic = function () {
408
+ this.readSectionHeader();
409
+ var frameIndex = this.readUint32();
410
+ var geometryIndex = this.readUint32();
411
+ var flags = this.readUint32();
412
+ // Skip unused bytes
413
+ this.skip(4);
414
+ return { frameIndex: frameIndex, geometryIndex: geometryIndex, flags: flags };
415
+ };
416
+ return DffParser;
417
+ }(RwFile_1.RwFile));
418
+ exports.DffParser = DffParser;
@@ -0,0 +1,6 @@
1
+ export declare class RwParseError extends Error {
2
+ constructor(message?: string);
3
+ }
4
+ export declare class RwParseStructureNotFoundError extends RwParseError {
5
+ constructor(structureName: string);
6
+ }
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ var __extends = (this && this.__extends) || (function () {
3
+ var extendStatics = function (d, b) {
4
+ extendStatics = Object.setPrototypeOf ||
5
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
+ return extendStatics(d, b);
8
+ };
9
+ return function (d, b) {
10
+ if (typeof b !== "function" && b !== null)
11
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
+ extendStatics(d, b);
13
+ function __() { this.constructor = d; }
14
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
+ };
16
+ })();
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.RwParseStructureNotFoundError = exports.RwParseError = void 0;
19
+ var RwParseError = /** @class */ (function (_super) {
20
+ __extends(RwParseError, _super);
21
+ function RwParseError(message) {
22
+ return _super.call(this, message) || this;
23
+ }
24
+ return RwParseError;
25
+ }(Error));
26
+ exports.RwParseError = RwParseError;
27
+ var RwParseStructureNotFoundError = /** @class */ (function (_super) {
28
+ __extends(RwParseStructureNotFoundError, _super);
29
+ function RwParseStructureNotFoundError(structureName) {
30
+ return _super.call(this, "Structure ".concat(structureName, " not found.")) || this;
31
+ }
32
+ return RwParseStructureNotFoundError;
33
+ }(RwParseError));
34
+ exports.RwParseStructureNotFoundError = RwParseStructureNotFoundError;
@@ -0,0 +1,28 @@
1
+ import { RwQuaternion, RwVector3 } from "../common/types";
2
+ export declare enum IfpVersion {
3
+ ANP3 = 0,
4
+ ANPK = 1,
5
+ UNSUPPORTED = 2
6
+ }
7
+ export interface RwIfp {
8
+ version: IfpVersion;
9
+ name: string;
10
+ animations: RwIfpAnimation[];
11
+ }
12
+ export interface RwIfpAnimation {
13
+ name: string;
14
+ bones: RwIfpBone[];
15
+ }
16
+ export interface RwIfpBone {
17
+ name: string;
18
+ keyframeType: string;
19
+ useBoneId: boolean;
20
+ boneId: number;
21
+ keyframes: RwIfpKeyframe[];
22
+ }
23
+ export interface RwIfpKeyframe {
24
+ time: number;
25
+ position: RwVector3;
26
+ rotation: RwQuaternion;
27
+ scale: RwVector3;
28
+ }
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.IfpVersion = void 0;
4
+ var IfpVersion;
5
+ (function (IfpVersion) {
6
+ IfpVersion[IfpVersion["ANP3"] = 0] = "ANP3";
7
+ IfpVersion[IfpVersion["ANPK"] = 1] = "ANPK";
8
+ IfpVersion[IfpVersion["UNSUPPORTED"] = 2] = "UNSUPPORTED";
9
+ })(IfpVersion || (exports.IfpVersion = IfpVersion = {}));
@@ -0,0 +1,12 @@
1
+ import { RwFile } from '../RwFile';
2
+ import { RwIfp } from './IfpData';
3
+ export declare class IfpParser extends RwFile {
4
+ constructor(buffer: Buffer);
5
+ parse(): RwIfp;
6
+ private readAnp3;
7
+ private readAnp3Animation;
8
+ private readAnp3Bone;
9
+ private readAnpk;
10
+ private readAnpkAnimation;
11
+ private readAnpkBone;
12
+ }