-
Notifications
You must be signed in to change notification settings - Fork 16
/
group.js
104 lines (90 loc) · 2.29 KB
/
group.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
import r from 'restructure';
import Chunk from '../chunked/chunk';
import Chunked from '../chunked';
import SkipChunk from '../chunked/skip-chunk';
import { Vec3Float, float32array2, float32array3 } from '../types';
const MOGP = Chunk({
nameOffset: r.uint32le,
descriptionOffset: r.uint32le,
flags: r.uint32le,
minBoundingBox: Vec3Float,
maxBoundingBox: Vec3Float,
portalOffset: r.uint16le,
aBatchCount: r.uint16le,
interiorBatchCount: r.uint16le,
exteriorBatchCount: r.uint16le,
fogOffsets: new r.Array(r.uint8, 4),
unknown: new r.Reserved(r.uint32le),
groupID: r.uint32le,
unknowns: new r.Reserved(r.uint32le, 3),
});
const MOPY = Chunk({
triangles: new r.Array(new r.Struct({
flags: r.uint8,
materialID: r.int8,
}), 'size', 'bytes'),
});
const MOVI = Chunk({
triangles: new r.Array(r.uint16le, 'size', 'bytes'),
});
const MOVT = Chunk({
vertices: new r.Array(float32array3, 'size', 'bytes'),
});
const MONR = Chunk({
normals: new r.Array(float32array3, 'size', 'bytes'),
});
const MOTV = Chunk({
textureCoords: new r.Array(float32array2, 'size', 'bytes'),
});
const MOCV = Chunk({
colors: new r.Array(new r.Struct({
b: r.uint8,
g: r.uint8,
r: r.uint8,
a: r.uint8,
}), 'size', 'bytes'),
});
const MOBA = Chunk({
batches: new r.Array(new r.Struct({
skips: new r.Reserved(r.int16le, 2 * 3),
firstIndex: r.uint32le,
indexCount: r.uint16le,
firstVertex: r.uint16le,
lastVertex: r.uint16le,
skip: new r.Reserved(r.uint8),
materialID: r.uint8,
}), 'size', 'bytes'),
});
const MODR = Chunk({
doodadIndices: new r.Array(r.int16le, 'size', 'bytes'),
});
export default Chunked({
MOGP: MOGP,
MOPY: MOPY,
MOVI: MOVI,
MOVT: MOVT,
MONR: MONR,
MOTV: MOTV,
MOBA: MOBA,
flags: function () {
return this.MOGP.flags;
},
MOLR: new r.Optional(SkipChunk, function () {
return this.flags & 0x200;
}),
MODR: new r.Optional(MODR, function () {
return this.flags & 0x800;
}),
MOBN: new r.Optional(SkipChunk, function () {
return this.flags & 0x1;
}),
MOBR: new r.Optional(SkipChunk, function () {
return this.flags & 0x1;
}),
MOCV: new r.Optional(MOCV, function () {
return this.flags & 0x4;
}),
indoor: function () {
return (this.flags & 0x2000) !== 0 && (this.flags & 0x8) === 0;
},
});