@vectojs/core 1.22.0 → 1.24.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.
- package/dist/{chunk-LHONR3GO.js → chunk-KEBYJVD6.js} +163 -94
- package/dist/{chunk-UPULSLKA.mjs → chunk-ME4LB2HB.mjs} +163 -94
- package/dist/index.d.ts +1 -0
- package/dist/index.js +805 -419
- package/dist/index.mjs +570 -184
- package/dist/performance/UserTiming.d.ts +44 -0
- package/dist/renderer.js +2 -2
- package/dist/renderer.mjs +1 -1
- package/dist/tree/ComputeParticleEntity.d.ts +5 -1
- package/dist/tree/Scene.d.ts +138 -1
- package/dist/wasm/anim-backend.d.ts +21 -4
- package/dist/wasm/backend.d.ts +9 -4
- package/dist/wasm/particle-backend.d.ts +12 -1
- package/dist/wasm/vectojs_core.wasm +0 -0
- package/package.json +2 -1
|
@@ -922,10 +922,11 @@ var FLOATS_PER_POINT = 7;
|
|
|
922
922
|
var POINT_STRIDE = FLOATS_PER_POINT * 4;
|
|
923
923
|
var VERTS_PER_QUAD = 4;
|
|
924
924
|
var INDICES_PER_QUAD = 6;
|
|
925
|
-
var
|
|
926
|
-
var
|
|
927
|
-
var
|
|
928
|
-
var
|
|
925
|
+
var PACKED_QUAD_VERT_STRIDE = 16;
|
|
926
|
+
var PACKED_RECT_VERT_STRIDE = 12;
|
|
927
|
+
var PACKED_UV_OFFSET = 8;
|
|
928
|
+
var PACKED_TINT_OFFSET = 12;
|
|
929
|
+
var PACKED_RECT_TINT_OFFSET = 8;
|
|
929
930
|
function buildQuadIndices(quads) {
|
|
930
931
|
const out = new Uint32Array(quads * INDICES_PER_QUAD);
|
|
931
932
|
for (let i = 0; i < quads; i++) {
|
|
@@ -940,6 +941,35 @@ function buildQuadIndices(quads) {
|
|
|
940
941
|
}
|
|
941
942
|
return out;
|
|
942
943
|
}
|
|
944
|
+
function encodeUnorm(v, max) {
|
|
945
|
+
return v <= 0 ? 0 : v >= 1 ? max : v * max + 0.5 | 0;
|
|
946
|
+
}
|
|
947
|
+
var LITTLE_ENDIAN = new Uint8Array(new Uint32Array([1]).buffer)[0] === 1;
|
|
948
|
+
function packTint(r, g, b, a) {
|
|
949
|
+
const ri = encodeUnorm(r, 255);
|
|
950
|
+
const gi = encodeUnorm(g, 255);
|
|
951
|
+
const bi = encodeUnorm(b, 255);
|
|
952
|
+
const ai = encodeUnorm(a, 255);
|
|
953
|
+
return LITTLE_ENDIAN ? ai << 24 | bi << 16 | gi << 8 | ri : ri << 24 | gi << 16 | bi << 8 | ai;
|
|
954
|
+
}
|
|
955
|
+
function createPackedBuffer(byteLength) {
|
|
956
|
+
const bytes = new ArrayBuffer(byteLength);
|
|
957
|
+
return {
|
|
958
|
+
bytes,
|
|
959
|
+
f32: new Float32Array(bytes),
|
|
960
|
+
u16: new Uint16Array(bytes),
|
|
961
|
+
u32: new Uint32Array(bytes),
|
|
962
|
+
u8: new Uint8Array(bytes)
|
|
963
|
+
};
|
|
964
|
+
}
|
|
965
|
+
function growPacked(buf, neededBytes) {
|
|
966
|
+
if (neededBytes <= buf.bytes.byteLength) return buf;
|
|
967
|
+
let cap = buf.bytes.byteLength;
|
|
968
|
+
while (cap < neededBytes) cap *= 2;
|
|
969
|
+
const grown = createPackedBuffer(cap);
|
|
970
|
+
grown.u8.set(buf.u8);
|
|
971
|
+
return grown;
|
|
972
|
+
}
|
|
943
973
|
var POINT_VERT = `#version 300 es
|
|
944
974
|
in vec2 a_pos;
|
|
945
975
|
in float a_radius;
|
|
@@ -1067,7 +1097,7 @@ function link(gl, vsSrc, fsSrc) {
|
|
|
1067
1097
|
}
|
|
1068
1098
|
return program;
|
|
1069
1099
|
}
|
|
1070
|
-
function writeQuad(out,
|
|
1100
|
+
function writeQuad(out, byteOffset, x, y, width, height, u0, v0, u1, v1, r, g, b, al, rotation) {
|
|
1071
1101
|
let x1;
|
|
1072
1102
|
let y1;
|
|
1073
1103
|
let x2;
|
|
@@ -1095,40 +1125,39 @@ function writeQuad(out, o, x, y, width, height, u0, v0, u1, v1, r, g, b, al, rot
|
|
|
1095
1125
|
x3 = x - hs;
|
|
1096
1126
|
y3 = y + hc;
|
|
1097
1127
|
}
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
out[o + 31] = al;
|
|
1128
|
+
const iu0 = encodeUnorm(u0, 65535);
|
|
1129
|
+
const iv0 = encodeUnorm(v0, 65535);
|
|
1130
|
+
const iu1 = encodeUnorm(u1, 65535);
|
|
1131
|
+
const iv1 = encodeUnorm(v1, 65535);
|
|
1132
|
+
const tint = packTint(r, g, b, al);
|
|
1133
|
+
const f32 = out.f32;
|
|
1134
|
+
const u16 = out.u16;
|
|
1135
|
+
const u32 = out.u32;
|
|
1136
|
+
const fi = byteOffset >> 2;
|
|
1137
|
+
const si = byteOffset + PACKED_UV_OFFSET >> 1;
|
|
1138
|
+
const ti = byteOffset + PACKED_TINT_OFFSET >> 2;
|
|
1139
|
+
f32[fi] = x;
|
|
1140
|
+
f32[fi + 1] = y;
|
|
1141
|
+
u16[si] = iu0;
|
|
1142
|
+
u16[si + 1] = iv0;
|
|
1143
|
+
u32[ti] = tint;
|
|
1144
|
+
f32[fi + 4] = x1;
|
|
1145
|
+
f32[fi + 5] = y1;
|
|
1146
|
+
u16[si + 8] = iu1;
|
|
1147
|
+
u16[si + 9] = iv0;
|
|
1148
|
+
u32[ti + 4] = tint;
|
|
1149
|
+
f32[fi + 8] = x2;
|
|
1150
|
+
f32[fi + 9] = y2;
|
|
1151
|
+
u16[si + 16] = iu1;
|
|
1152
|
+
u16[si + 17] = iv1;
|
|
1153
|
+
u32[ti + 8] = tint;
|
|
1154
|
+
f32[fi + 12] = x3;
|
|
1155
|
+
f32[fi + 13] = y3;
|
|
1156
|
+
u16[si + 24] = iu0;
|
|
1157
|
+
u16[si + 25] = iv1;
|
|
1158
|
+
u32[ti + 12] = tint;
|
|
1130
1159
|
}
|
|
1131
|
-
function writeRectQuad(out,
|
|
1160
|
+
function writeRectQuad(out, byteOffset, x, y, width, height, r, g, b, al, rotation) {
|
|
1132
1161
|
let x1;
|
|
1133
1162
|
let y1;
|
|
1134
1163
|
let x2;
|
|
@@ -1156,30 +1185,22 @@ function writeRectQuad(out, o, x, y, width, height, r, g, b, al, rotation) {
|
|
|
1156
1185
|
x3 = x - hs;
|
|
1157
1186
|
y3 = y + hc;
|
|
1158
1187
|
}
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
out[o + 16] = b;
|
|
1176
|
-
out[o + 17] = al;
|
|
1177
|
-
out[o + 18] = x3;
|
|
1178
|
-
out[o + 19] = y3;
|
|
1179
|
-
out[o + 20] = r;
|
|
1180
|
-
out[o + 21] = g;
|
|
1181
|
-
out[o + 22] = b;
|
|
1182
|
-
out[o + 23] = al;
|
|
1188
|
+
const tint = packTint(r, g, b, al);
|
|
1189
|
+
const f32 = out.f32;
|
|
1190
|
+
const u32 = out.u32;
|
|
1191
|
+
const fi = byteOffset >> 2;
|
|
1192
|
+
f32[fi] = x;
|
|
1193
|
+
f32[fi + 1] = y;
|
|
1194
|
+
u32[fi + 2] = tint;
|
|
1195
|
+
f32[fi + 3] = x1;
|
|
1196
|
+
f32[fi + 4] = y1;
|
|
1197
|
+
u32[fi + 5] = tint;
|
|
1198
|
+
f32[fi + 6] = x2;
|
|
1199
|
+
f32[fi + 7] = y2;
|
|
1200
|
+
u32[fi + 8] = tint;
|
|
1201
|
+
f32[fi + 9] = x3;
|
|
1202
|
+
f32[fi + 10] = y3;
|
|
1203
|
+
u32[fi + 11] = tint;
|
|
1183
1204
|
}
|
|
1184
1205
|
function grow(data, needed) {
|
|
1185
1206
|
if (needed <= data.length) return data;
|
|
@@ -1226,9 +1247,16 @@ function createWebGLPointRenderer(canvas) {
|
|
|
1226
1247
|
gl.bindVertexArray(rectVAO);
|
|
1227
1248
|
gl.bindBuffer(gl.ARRAY_BUFFER, rectBuffer);
|
|
1228
1249
|
gl.enableVertexAttribArray(rAPos);
|
|
1229
|
-
gl.vertexAttribPointer(rAPos, 2, gl.FLOAT, false,
|
|
1250
|
+
gl.vertexAttribPointer(rAPos, 2, gl.FLOAT, false, PACKED_RECT_VERT_STRIDE, 0);
|
|
1230
1251
|
gl.enableVertexAttribArray(rAColor);
|
|
1231
|
-
gl.vertexAttribPointer(
|
|
1252
|
+
gl.vertexAttribPointer(
|
|
1253
|
+
rAColor,
|
|
1254
|
+
4,
|
|
1255
|
+
gl.UNSIGNED_BYTE,
|
|
1256
|
+
true,
|
|
1257
|
+
PACKED_RECT_VERT_STRIDE,
|
|
1258
|
+
PACKED_RECT_TINT_OFFSET
|
|
1259
|
+
);
|
|
1232
1260
|
const sAPos = gl.getAttribLocation(spriteProgram, "a_pos");
|
|
1233
1261
|
const sAUv = gl.getAttribLocation(spriteProgram, "a_uv");
|
|
1234
1262
|
const sATint = gl.getAttribLocation(spriteProgram, "a_tint");
|
|
@@ -1239,11 +1267,25 @@ function createWebGLPointRenderer(canvas) {
|
|
|
1239
1267
|
gl.bindVertexArray(spriteVAO);
|
|
1240
1268
|
gl.bindBuffer(gl.ARRAY_BUFFER, spriteBuffer);
|
|
1241
1269
|
gl.enableVertexAttribArray(sAPos);
|
|
1242
|
-
gl.vertexAttribPointer(sAPos, 2, gl.FLOAT, false,
|
|
1270
|
+
gl.vertexAttribPointer(sAPos, 2, gl.FLOAT, false, PACKED_QUAD_VERT_STRIDE, 0);
|
|
1243
1271
|
gl.enableVertexAttribArray(sAUv);
|
|
1244
|
-
gl.vertexAttribPointer(
|
|
1272
|
+
gl.vertexAttribPointer(
|
|
1273
|
+
sAUv,
|
|
1274
|
+
2,
|
|
1275
|
+
gl.UNSIGNED_SHORT,
|
|
1276
|
+
true,
|
|
1277
|
+
PACKED_QUAD_VERT_STRIDE,
|
|
1278
|
+
PACKED_UV_OFFSET
|
|
1279
|
+
);
|
|
1245
1280
|
gl.enableVertexAttribArray(sATint);
|
|
1246
|
-
gl.vertexAttribPointer(
|
|
1281
|
+
gl.vertexAttribPointer(
|
|
1282
|
+
sATint,
|
|
1283
|
+
4,
|
|
1284
|
+
gl.UNSIGNED_BYTE,
|
|
1285
|
+
true,
|
|
1286
|
+
PACKED_QUAD_VERT_STRIDE,
|
|
1287
|
+
PACKED_TINT_OFFSET
|
|
1288
|
+
);
|
|
1247
1289
|
const gAPos = gl.getAttribLocation(msdfProgram, "a_pos");
|
|
1248
1290
|
const gAUv = gl.getAttribLocation(msdfProgram, "a_uv");
|
|
1249
1291
|
const gATint = gl.getAttribLocation(msdfProgram, "a_tint");
|
|
@@ -1255,11 +1297,25 @@ function createWebGLPointRenderer(canvas) {
|
|
|
1255
1297
|
gl.bindVertexArray(glyphVAO);
|
|
1256
1298
|
gl.bindBuffer(gl.ARRAY_BUFFER, glyphBuffer);
|
|
1257
1299
|
gl.enableVertexAttribArray(gAPos);
|
|
1258
|
-
gl.vertexAttribPointer(gAPos, 2, gl.FLOAT, false,
|
|
1300
|
+
gl.vertexAttribPointer(gAPos, 2, gl.FLOAT, false, PACKED_QUAD_VERT_STRIDE, 0);
|
|
1259
1301
|
gl.enableVertexAttribArray(gAUv);
|
|
1260
|
-
gl.vertexAttribPointer(
|
|
1302
|
+
gl.vertexAttribPointer(
|
|
1303
|
+
gAUv,
|
|
1304
|
+
2,
|
|
1305
|
+
gl.UNSIGNED_SHORT,
|
|
1306
|
+
true,
|
|
1307
|
+
PACKED_QUAD_VERT_STRIDE,
|
|
1308
|
+
PACKED_UV_OFFSET
|
|
1309
|
+
);
|
|
1261
1310
|
gl.enableVertexAttribArray(gATint);
|
|
1262
|
-
gl.vertexAttribPointer(
|
|
1311
|
+
gl.vertexAttribPointer(
|
|
1312
|
+
gATint,
|
|
1313
|
+
4,
|
|
1314
|
+
gl.UNSIGNED_BYTE,
|
|
1315
|
+
true,
|
|
1316
|
+
PACKED_QUAD_VERT_STRIDE,
|
|
1317
|
+
PACKED_TINT_OFFSET
|
|
1318
|
+
);
|
|
1263
1319
|
const cAPos = gl.getAttribLocation(circleQuadProgram, "a_pos");
|
|
1264
1320
|
const cAUv = gl.getAttribLocation(circleQuadProgram, "a_uv");
|
|
1265
1321
|
const cATint = gl.getAttribLocation(circleQuadProgram, "a_tint");
|
|
@@ -1269,11 +1325,25 @@ function createWebGLPointRenderer(canvas) {
|
|
|
1269
1325
|
gl.bindVertexArray(circleQuadVAO);
|
|
1270
1326
|
gl.bindBuffer(gl.ARRAY_BUFFER, circleQuadBuffer);
|
|
1271
1327
|
gl.enableVertexAttribArray(cAPos);
|
|
1272
|
-
gl.vertexAttribPointer(cAPos, 2, gl.FLOAT, false,
|
|
1328
|
+
gl.vertexAttribPointer(cAPos, 2, gl.FLOAT, false, PACKED_QUAD_VERT_STRIDE, 0);
|
|
1273
1329
|
gl.enableVertexAttribArray(cAUv);
|
|
1274
|
-
gl.vertexAttribPointer(
|
|
1330
|
+
gl.vertexAttribPointer(
|
|
1331
|
+
cAUv,
|
|
1332
|
+
2,
|
|
1333
|
+
gl.UNSIGNED_SHORT,
|
|
1334
|
+
true,
|
|
1335
|
+
PACKED_QUAD_VERT_STRIDE,
|
|
1336
|
+
PACKED_UV_OFFSET
|
|
1337
|
+
);
|
|
1275
1338
|
gl.enableVertexAttribArray(cATint);
|
|
1276
|
-
gl.vertexAttribPointer(
|
|
1339
|
+
gl.vertexAttribPointer(
|
|
1340
|
+
cATint,
|
|
1341
|
+
4,
|
|
1342
|
+
gl.UNSIGNED_BYTE,
|
|
1343
|
+
true,
|
|
1344
|
+
PACKED_QUAD_VERT_STRIDE,
|
|
1345
|
+
PACKED_TINT_OFFSET
|
|
1346
|
+
);
|
|
1277
1347
|
gl.bindVertexArray(null);
|
|
1278
1348
|
const quadIndexBuffer = gl.createBuffer();
|
|
1279
1349
|
let quadIndexCapacity = 0;
|
|
@@ -1283,7 +1353,6 @@ function createWebGLPointRenderer(canvas) {
|
|
|
1283
1353
|
while (cap < quads) cap *= 2;
|
|
1284
1354
|
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, quadIndexBuffer);
|
|
1285
1355
|
gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, buildQuadIndices(cap), gl.STATIC_DRAW);
|
|
1286
|
-
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, null);
|
|
1287
1356
|
quadIndexCapacity = cap;
|
|
1288
1357
|
};
|
|
1289
1358
|
for (const vao of [rectVAO, spriteVAO, glyphVAO, circleQuadVAO]) {
|
|
@@ -1298,11 +1367,11 @@ function createWebGLPointRenderer(canvas) {
|
|
|
1298
1367
|
let distanceRange = 4;
|
|
1299
1368
|
let pointData = new Float32Array(FLOATS_PER_POINT * 1024);
|
|
1300
1369
|
let pointCount = 0;
|
|
1301
|
-
let rectData =
|
|
1370
|
+
let rectData = createPackedBuffer(PACKED_RECT_VERT_STRIDE * VERTS_PER_QUAD * 256);
|
|
1302
1371
|
let rectCount = 0;
|
|
1303
|
-
let spriteData =
|
|
1372
|
+
let spriteData = createPackedBuffer(PACKED_QUAD_VERT_STRIDE * VERTS_PER_QUAD * 256);
|
|
1304
1373
|
let spriteCount = 0;
|
|
1305
|
-
let glyphData =
|
|
1374
|
+
let glyphData = createPackedBuffer(PACKED_QUAD_VERT_STRIDE * VERTS_PER_QUAD * 1024);
|
|
1306
1375
|
let glyphCount = 0;
|
|
1307
1376
|
let frameDrawCalls = 0;
|
|
1308
1377
|
let lastFrameDrawCalls = 0;
|
|
@@ -1310,7 +1379,7 @@ function createWebGLPointRenderer(canvas) {
|
|
|
1310
1379
|
let atlasSwitches = 0;
|
|
1311
1380
|
let circleQuadFallbacks = 0;
|
|
1312
1381
|
let circlePoints = 0;
|
|
1313
|
-
let circleQuadData =
|
|
1382
|
+
let circleQuadData = createPackedBuffer(PACKED_QUAD_VERT_STRIDE * VERTS_PER_QUAD * 64);
|
|
1314
1383
|
let circleQuadCount = 0;
|
|
1315
1384
|
let logicalW = 0;
|
|
1316
1385
|
let logicalH = 0;
|
|
@@ -1320,11 +1389,11 @@ function createWebGLPointRenderer(canvas) {
|
|
|
1320
1389
|
const maxPointSize = pointSizeRange ? pointSizeRange[1] : Infinity;
|
|
1321
1390
|
const drawGlyphs = () => {
|
|
1322
1391
|
if (glyphCount === 0 || !msdfTexture) return;
|
|
1323
|
-
const
|
|
1392
|
+
const bytes = glyphCount * VERTS_PER_QUAD * PACKED_QUAD_VERT_STRIDE;
|
|
1324
1393
|
gl.useProgram(msdfProgram);
|
|
1325
1394
|
gl.bindVertexArray(glyphVAO);
|
|
1326
1395
|
gl.bindBuffer(gl.ARRAY_BUFFER, glyphBuffer);
|
|
1327
|
-
gl.bufferData(gl.ARRAY_BUFFER, glyphData.subarray(0,
|
|
1396
|
+
gl.bufferData(gl.ARRAY_BUFFER, glyphData.u8.subarray(0, bytes), gl.DYNAMIC_DRAW);
|
|
1328
1397
|
gl.activeTexture(gl.TEXTURE0);
|
|
1329
1398
|
gl.bindTexture(gl.TEXTURE_2D, msdfTexture);
|
|
1330
1399
|
gl.uniform1i(gUTex, 0);
|
|
@@ -1391,8 +1460,8 @@ function createWebGLPointRenderer(canvas) {
|
|
|
1391
1460
|
},
|
|
1392
1461
|
addSprite(x, y, width, height, u0, v0, u1, v1, color = "#ffffff", alpha = 1, rotation = 0) {
|
|
1393
1462
|
if (!texture) return;
|
|
1394
|
-
const stride =
|
|
1395
|
-
spriteData =
|
|
1463
|
+
const stride = PACKED_QUAD_VERT_STRIDE * VERTS_PER_QUAD;
|
|
1464
|
+
spriteData = growPacked(spriteData, (spriteCount + 1) * stride);
|
|
1396
1465
|
const rgba = parseColorToRGBA(color);
|
|
1397
1466
|
writeQuad(
|
|
1398
1467
|
spriteData,
|
|
@@ -1436,8 +1505,8 @@ function createWebGLPointRenderer(canvas) {
|
|
|
1436
1505
|
},
|
|
1437
1506
|
addGlyph(x, y, width, height, u0, v0, u1, v1, color = "#ffffff", alpha = 1, rotation = 0) {
|
|
1438
1507
|
if (!msdfTexture) return;
|
|
1439
|
-
const stride =
|
|
1440
|
-
glyphData =
|
|
1508
|
+
const stride = PACKED_QUAD_VERT_STRIDE * VERTS_PER_QUAD;
|
|
1509
|
+
glyphData = growPacked(glyphData, (glyphCount + 1) * stride);
|
|
1441
1510
|
const rgba = parseColorToRGBA(color);
|
|
1442
1511
|
writeQuad(
|
|
1443
1512
|
glyphData,
|
|
@@ -1462,8 +1531,8 @@ function createWebGLPointRenderer(canvas) {
|
|
|
1462
1531
|
const needsQuad = logicalW > 0 && (x < radius || y < radius || x > logicalW - radius || y > logicalH - radius) || radius * 2 * dpr > maxPointSize;
|
|
1463
1532
|
if (needsQuad) {
|
|
1464
1533
|
circleQuadFallbacks++;
|
|
1465
|
-
const stride =
|
|
1466
|
-
circleQuadData =
|
|
1534
|
+
const stride = PACKED_QUAD_VERT_STRIDE * VERTS_PER_QUAD;
|
|
1535
|
+
circleQuadData = growPacked(circleQuadData, (circleQuadCount + 1) * stride);
|
|
1467
1536
|
const rgba = parseColorToRGBA(color);
|
|
1468
1537
|
const d = radius * 2;
|
|
1469
1538
|
writeQuad(
|
|
@@ -1500,8 +1569,8 @@ function createWebGLPointRenderer(canvas) {
|
|
|
1500
1569
|
pointCount++;
|
|
1501
1570
|
},
|
|
1502
1571
|
addRect(x, y, width, height, color, alpha = 1, rotation = 0) {
|
|
1503
|
-
const stride =
|
|
1504
|
-
rectData =
|
|
1572
|
+
const stride = PACKED_RECT_VERT_STRIDE * VERTS_PER_QUAD;
|
|
1573
|
+
rectData = growPacked(rectData, (rectCount + 1) * stride);
|
|
1505
1574
|
const rgba = parseColorToRGBA(color);
|
|
1506
1575
|
writeRectQuad(
|
|
1507
1576
|
rectData,
|
|
@@ -1520,11 +1589,11 @@ function createWebGLPointRenderer(canvas) {
|
|
|
1520
1589
|
},
|
|
1521
1590
|
flush() {
|
|
1522
1591
|
if (rectCount > 0) {
|
|
1523
|
-
const
|
|
1592
|
+
const bytes = rectCount * VERTS_PER_QUAD * PACKED_RECT_VERT_STRIDE;
|
|
1524
1593
|
gl.useProgram(rectProgram);
|
|
1525
1594
|
gl.bindVertexArray(rectVAO);
|
|
1526
1595
|
gl.bindBuffer(gl.ARRAY_BUFFER, rectBuffer);
|
|
1527
|
-
gl.bufferData(gl.ARRAY_BUFFER, rectData.subarray(0,
|
|
1596
|
+
gl.bufferData(gl.ARRAY_BUFFER, rectData.u8.subarray(0, bytes), gl.DYNAMIC_DRAW);
|
|
1528
1597
|
gl.uniform2f(rURes, logicalW, logicalH);
|
|
1529
1598
|
ensureQuadIndices(rectCount);
|
|
1530
1599
|
gl.drawElements(gl.TRIANGLES, rectCount * INDICES_PER_QUAD, gl.UNSIGNED_INT, 0);
|
|
@@ -1545,22 +1614,22 @@ function createWebGLPointRenderer(canvas) {
|
|
|
1545
1614
|
frameDrawCalls++;
|
|
1546
1615
|
}
|
|
1547
1616
|
if (circleQuadCount > 0) {
|
|
1548
|
-
const
|
|
1617
|
+
const bytes = circleQuadCount * VERTS_PER_QUAD * PACKED_QUAD_VERT_STRIDE;
|
|
1549
1618
|
gl.useProgram(circleQuadProgram);
|
|
1550
1619
|
gl.bindVertexArray(circleQuadVAO);
|
|
1551
1620
|
gl.bindBuffer(gl.ARRAY_BUFFER, circleQuadBuffer);
|
|
1552
|
-
gl.bufferData(gl.ARRAY_BUFFER, circleQuadData.subarray(0,
|
|
1621
|
+
gl.bufferData(gl.ARRAY_BUFFER, circleQuadData.u8.subarray(0, bytes), gl.DYNAMIC_DRAW);
|
|
1553
1622
|
gl.uniform2f(cURes, logicalW, logicalH);
|
|
1554
1623
|
ensureQuadIndices(circleQuadCount);
|
|
1555
1624
|
gl.drawElements(gl.TRIANGLES, circleQuadCount * INDICES_PER_QUAD, gl.UNSIGNED_INT, 0);
|
|
1556
1625
|
frameDrawCalls++;
|
|
1557
1626
|
}
|
|
1558
1627
|
if (spriteCount > 0 && texture) {
|
|
1559
|
-
const
|
|
1628
|
+
const bytes = spriteCount * VERTS_PER_QUAD * PACKED_QUAD_VERT_STRIDE;
|
|
1560
1629
|
gl.useProgram(spriteProgram);
|
|
1561
1630
|
gl.bindVertexArray(spriteVAO);
|
|
1562
1631
|
gl.bindBuffer(gl.ARRAY_BUFFER, spriteBuffer);
|
|
1563
|
-
gl.bufferData(gl.ARRAY_BUFFER, spriteData.subarray(0,
|
|
1632
|
+
gl.bufferData(gl.ARRAY_BUFFER, spriteData.u8.subarray(0, bytes), gl.DYNAMIC_DRAW);
|
|
1564
1633
|
gl.activeTexture(gl.TEXTURE0);
|
|
1565
1634
|
gl.bindTexture(gl.TEXTURE_2D, texture);
|
|
1566
1635
|
gl.uniform1i(sUTex, 0);
|
package/dist/index.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ export * from './renderer/colorParse';
|
|
|
7
7
|
export * from './renderer/url';
|
|
8
8
|
export * from './renderer/GlyphRasterAtlas';
|
|
9
9
|
export * from './renderer/TextRasterCache';
|
|
10
|
+
export * from './performance/UserTiming';
|
|
10
11
|
export * from './tree/Entity';
|
|
11
12
|
export * from './tree/Scene';
|
|
12
13
|
export * from './components/TextEntity';
|