@vectojs/core 1.23.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.
@@ -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 FLOATS_PER_RECT_VERT = 6;
926
- var RECT_VERT_STRIDE = FLOATS_PER_RECT_VERT * 4;
927
- var FLOATS_PER_SPRITE_VERT = 8;
928
- var SPRITE_VERT_STRIDE = FLOATS_PER_SPRITE_VERT * 4;
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, o, x, y, width, height, u0, v0, u1, v1, r, g, b, al, rotation) {
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
- out[o] = x;
1099
- out[o + 1] = y;
1100
- out[o + 2] = u0;
1101
- out[o + 3] = v0;
1102
- out[o + 4] = r;
1103
- out[o + 5] = g;
1104
- out[o + 6] = b;
1105
- out[o + 7] = al;
1106
- out[o + 8] = x1;
1107
- out[o + 9] = y1;
1108
- out[o + 10] = u1;
1109
- out[o + 11] = v0;
1110
- out[o + 12] = r;
1111
- out[o + 13] = g;
1112
- out[o + 14] = b;
1113
- out[o + 15] = al;
1114
- out[o + 16] = x2;
1115
- out[o + 17] = y2;
1116
- out[o + 18] = u1;
1117
- out[o + 19] = v1;
1118
- out[o + 20] = r;
1119
- out[o + 21] = g;
1120
- out[o + 22] = b;
1121
- out[o + 23] = al;
1122
- out[o + 24] = x3;
1123
- out[o + 25] = y3;
1124
- out[o + 26] = u0;
1125
- out[o + 27] = v1;
1126
- out[o + 28] = r;
1127
- out[o + 29] = g;
1128
- out[o + 30] = b;
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, o, x, y, width, height, r, g, b, al, rotation) {
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
- out[o] = x;
1160
- out[o + 1] = y;
1161
- out[o + 2] = r;
1162
- out[o + 3] = g;
1163
- out[o + 4] = b;
1164
- out[o + 5] = al;
1165
- out[o + 6] = x1;
1166
- out[o + 7] = y1;
1167
- out[o + 8] = r;
1168
- out[o + 9] = g;
1169
- out[o + 10] = b;
1170
- out[o + 11] = al;
1171
- out[o + 12] = x2;
1172
- out[o + 13] = y2;
1173
- out[o + 14] = r;
1174
- out[o + 15] = g;
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, RECT_VERT_STRIDE, 0);
1250
+ gl.vertexAttribPointer(rAPos, 2, gl.FLOAT, false, PACKED_RECT_VERT_STRIDE, 0);
1230
1251
  gl.enableVertexAttribArray(rAColor);
1231
- gl.vertexAttribPointer(rAColor, 4, gl.FLOAT, false, RECT_VERT_STRIDE, 8);
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, SPRITE_VERT_STRIDE, 0);
1270
+ gl.vertexAttribPointer(sAPos, 2, gl.FLOAT, false, PACKED_QUAD_VERT_STRIDE, 0);
1243
1271
  gl.enableVertexAttribArray(sAUv);
1244
- gl.vertexAttribPointer(sAUv, 2, gl.FLOAT, false, SPRITE_VERT_STRIDE, 8);
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(sATint, 4, gl.FLOAT, false, SPRITE_VERT_STRIDE, 16);
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, SPRITE_VERT_STRIDE, 0);
1300
+ gl.vertexAttribPointer(gAPos, 2, gl.FLOAT, false, PACKED_QUAD_VERT_STRIDE, 0);
1259
1301
  gl.enableVertexAttribArray(gAUv);
1260
- gl.vertexAttribPointer(gAUv, 2, gl.FLOAT, false, SPRITE_VERT_STRIDE, 8);
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(gATint, 4, gl.FLOAT, false, SPRITE_VERT_STRIDE, 16);
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, SPRITE_VERT_STRIDE, 0);
1328
+ gl.vertexAttribPointer(cAPos, 2, gl.FLOAT, false, PACKED_QUAD_VERT_STRIDE, 0);
1273
1329
  gl.enableVertexAttribArray(cAUv);
1274
- gl.vertexAttribPointer(cAUv, 2, gl.FLOAT, false, SPRITE_VERT_STRIDE, 8);
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(cATint, 4, gl.FLOAT, false, SPRITE_VERT_STRIDE, 16);
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 = new Float32Array(FLOATS_PER_RECT_VERT * VERTS_PER_QUAD * 256);
1370
+ let rectData = createPackedBuffer(PACKED_RECT_VERT_STRIDE * VERTS_PER_QUAD * 256);
1302
1371
  let rectCount = 0;
1303
- let spriteData = new Float32Array(FLOATS_PER_SPRITE_VERT * VERTS_PER_QUAD * 256);
1372
+ let spriteData = createPackedBuffer(PACKED_QUAD_VERT_STRIDE * VERTS_PER_QUAD * 256);
1304
1373
  let spriteCount = 0;
1305
- let glyphData = new Float32Array(FLOATS_PER_SPRITE_VERT * VERTS_PER_QUAD * 1024);
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 = new Float32Array(FLOATS_PER_SPRITE_VERT * VERTS_PER_QUAD * 64);
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 floats = glyphCount * VERTS_PER_QUAD * FLOATS_PER_SPRITE_VERT;
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, floats), gl.DYNAMIC_DRAW);
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 = FLOATS_PER_SPRITE_VERT * VERTS_PER_QUAD;
1395
- spriteData = grow(spriteData, (spriteCount + 1) * stride);
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 = FLOATS_PER_SPRITE_VERT * VERTS_PER_QUAD;
1440
- glyphData = grow(glyphData, (glyphCount + 1) * stride);
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 = FLOATS_PER_SPRITE_VERT * VERTS_PER_QUAD;
1466
- circleQuadData = grow(circleQuadData, (circleQuadCount + 1) * stride);
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 = FLOATS_PER_RECT_VERT * VERTS_PER_QUAD;
1504
- rectData = grow(rectData, (rectCount + 1) * stride);
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 floats = rectCount * VERTS_PER_QUAD * FLOATS_PER_RECT_VERT;
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, floats), gl.DYNAMIC_DRAW);
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 floats = circleQuadCount * VERTS_PER_QUAD * FLOATS_PER_SPRITE_VERT;
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, floats), gl.DYNAMIC_DRAW);
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 floats = spriteCount * VERTS_PER_QUAD * FLOATS_PER_SPRITE_VERT;
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, floats), gl.DYNAMIC_DRAW);
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';