-
Notifications
You must be signed in to change notification settings - Fork 18
/
builder.ts
70 lines (57 loc) · 1.41 KB
/
builder.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
/*
* Copyright (C) 2019 Toshiba Corporation
* SPDX-License-Identifier: Apache-2.0
*/
import { EShape } from "../e-shape";
import { EShapeBufferUnitBuilder } from "../e-shape-buffer-unit-builder";
const NONE = 0;
const VERTEX = 1;
const STEP = 2;
const COLOR = 4;
const UV = 8;
const INDEX = 16;
const VERTEX_AND_STEP = VERTEX | STEP;
const VERTEX_STEP_AND_UV = VERTEX_AND_STEP | UV;
const ALL = VERTEX | STEP | COLOR | UV | INDEX;
export const BuilderFlag = {
NONE,
VERTEX,
STEP,
COLOR,
UV,
INDEX,
VERTEX_AND_STEP,
VERTEX_STEP_AND_UV,
ALL
} as const;
export type BuilderFlag = number;
export interface BuilderBuffer {
readonly vertices: Float32Array;
readonly steps: Float32Array;
readonly colors: Float32Array;
readonly uvs: Float32Array;
readonly indices: Uint16Array | Uint32Array;
check(vindex: number, ioffset: number, vcount: number, icount: number): boolean;
updateVertices(): void;
updateSteps(): void;
updateColors(): void;
updateUvs(): void;
updateIndices(): void;
}
export interface Builder {
readonly buffer: BuilderBuffer;
readonly vertexOffset: number;
readonly indexOffset: number;
readonly vertexCount: number;
readonly indexCount: number;
init(): void;
reinit(
buffer: BuilderBuffer,
shape: EShape,
vertexOffset: number,
indexOffset: number
): boolean;
isCompatible(shape: EShape): boolean;
update(shape: EShape): void;
buildUnit(builder: EShapeBufferUnitBuilder): void;
}