Spaces:
Running
Running
add to config
Browse files- config.js +2 -1
- index.html +3 -4
config.js
CHANGED
@@ -5,5 +5,6 @@ export const config = {
|
|
5 |
glyphWidth: 32,
|
6 |
glyphHeight: 40,
|
7 |
maxGlyphs: 100,
|
8 |
-
vertsPerGlyph: 6
|
|
|
9 |
};
|
|
|
5 |
glyphWidth: 32,
|
6 |
glyphHeight: 40,
|
7 |
maxGlyphs: 100,
|
8 |
+
vertsPerGlyph: 6,
|
9 |
+
floatsPerVertex: 8
|
10 |
};
|
index.html
CHANGED
@@ -54,8 +54,7 @@
|
|
54 |
const glyphCanvas = generateGlyphTextureAtlas();
|
55 |
document.body.appendChild(glyphCanvas);
|
56 |
glyphCanvas.style.backgroundColor = '#222';
|
57 |
-
const
|
58 |
-
const vertexSize = floatsPerVertex * 4;
|
59 |
const vertexBufferSize = config.maxGlyphs * config.vertsPerGlyph * vertexSize;
|
60 |
const vertexBuffer = device.createBuffer({
|
61 |
label: 'vertices',
|
@@ -75,7 +74,7 @@
|
|
75 |
device.queue.writeBuffer(indexBuffer, 0, new Uint32Array(indices));
|
76 |
|
77 |
function generateGlyphVerticesForText(s, colors = [[1, 1, 1, 1]]) {
|
78 |
-
const vertexData = new Float32Array(config.maxGlyphs * floatsPerVertex * config.vertsPerGlyph);
|
79 |
const glyphUVWidth = config.glyphWidth / glyphCanvas.width;
|
80 |
const glyphUVHeight = config.glyphHeight / glyphCanvas.height;
|
81 |
let offset = 0, x0 = 0, y0 = 0, x1 = 1, y1 = 1, width = 0;
|
@@ -111,7 +110,7 @@
|
|
111 |
}
|
112 |
x0 += 0.55; x1 = x0 + 1;
|
113 |
}
|
114 |
-
return { vertexData, numGlyphs: offset / floatsPerVertex, width, height: y1 };
|
115 |
}
|
116 |
|
117 |
const colors = [
|
|
|
54 |
const glyphCanvas = generateGlyphTextureAtlas();
|
55 |
document.body.appendChild(glyphCanvas);
|
56 |
glyphCanvas.style.backgroundColor = '#222';
|
57 |
+
const vertexSize = config.floatsPerVertex * 4;
|
|
|
58 |
const vertexBufferSize = config.maxGlyphs * config.vertsPerGlyph * vertexSize;
|
59 |
const vertexBuffer = device.createBuffer({
|
60 |
label: 'vertices',
|
|
|
74 |
device.queue.writeBuffer(indexBuffer, 0, new Uint32Array(indices));
|
75 |
|
76 |
function generateGlyphVerticesForText(s, colors = [[1, 1, 1, 1]]) {
|
77 |
+
const vertexData = new Float32Array(config.maxGlyphs * config.floatsPerVertex * config.vertsPerGlyph);
|
78 |
const glyphUVWidth = config.glyphWidth / glyphCanvas.width;
|
79 |
const glyphUVHeight = config.glyphHeight / glyphCanvas.height;
|
80 |
let offset = 0, x0 = 0, y0 = 0, x1 = 1, y1 = 1, width = 0;
|
|
|
110 |
}
|
111 |
x0 += 0.55; x1 = x0 + 1;
|
112 |
}
|
113 |
+
return { vertexData, numGlyphs: offset / config.floatsPerVertex, width, height: y1 };
|
114 |
}
|
115 |
|
116 |
const colors = [
|