-
Notifications
You must be signed in to change notification settings - Fork 57
/
Copy pathTilemapGeometry.ts
89 lines (80 loc) · 2.47 KB
/
TilemapGeometry.ts
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
import { Buffer, BufferUsage, Geometry } from 'pixi.js';
// For some reason, ESLint goes mad with indentation in this file ^&^
/* eslint-disable no-mixed-spaces-and-tabs, indent */
export class TilemapGeometry extends Geometry
{
static vertSize = 13;
static vertPerQuad = 4;
static stride = this.vertSize * 4;
lastTimeAccess = 0;
vertSize = TilemapGeometry.vertSize;
vertPerQuad = TilemapGeometry.vertPerQuad;
stride = TilemapGeometry.stride;
constructor(indexBuffer: Buffer)
{
const buf = new Buffer({
data: new Float32Array(2),
label: 'tilemap-buffer',
usage: BufferUsage.VERTEX | BufferUsage.COPY_DST,
shrinkToFit: false,
});
const stride = TilemapGeometry.stride;
// TODO: why location is like that in webgl? ascending?
super({
indexBuffer,
attributes: {
aVertexPosition: {
buffer: buf,
format: 'float32x2',
stride,
offset: 0,
// location: 6,
},
aTextureCoord: {
buffer: buf,
format: 'float32x2',
stride,
offset: 2 * 4,
// location: 4,
},
aFrame: {
buffer: buf,
format: 'float32x4',
stride,
offset: 4 * 4,
// location: 3,
},
aAnim: {
buffer: buf,
format: 'float32x2',
stride,
offset: 8 * 4,
// location: 1,
},
aTextureId: {
buffer: buf,
format: 'sint32',
stride,
offset: 10 * 4,
// location: 5
},
aAnimDivisor: {
buffer: buf,
format: 'float32',
stride,
offset: 11 * 4,
// location: 2
},
aAlpha: {
buffer: buf,
format: 'float32',
stride,
offset: 12 * 4,
// location: 0
}
},
});
this.buf = buf;
}
buf: Buffer;
}