@chromatic-coherence/generative-charts-3d 0.13.0 → 0.13.1
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/index.d.ts +3 -0
- package/dist/index.js +14 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -166,6 +166,9 @@ export declare class World {
|
|
|
166
166
|
private resize;
|
|
167
167
|
private col;
|
|
168
168
|
private parseCol;
|
|
169
|
+
private inkCss;
|
|
170
|
+
/** Remap a recipe-supplied css colour for the ink edition's overlay labels (identity when dark). */
|
|
171
|
+
private themedCss;
|
|
169
172
|
private pushFace;
|
|
170
173
|
/** v0.2 — pass per-vertex normals (na, nb, nc) and shading interpolates SMOOTHLY across
|
|
171
174
|
* the face: the facets vanish. Omit them for flat shading, exactly as before. */
|
package/dist/index.js
CHANGED
|
@@ -300,6 +300,7 @@ export class World {
|
|
|
300
300
|
this.fw = v3();
|
|
301
301
|
this.focal = 0;
|
|
302
302
|
this.vp = new Float32Array(16);
|
|
303
|
+
this.inkCss = new Map();
|
|
303
304
|
this.canvas = o.canvas;
|
|
304
305
|
const gl = o.canvas.getContext("webgl", { alpha: true, antialias: true, premultipliedAlpha: true });
|
|
305
306
|
if (!gl)
|
|
@@ -430,6 +431,18 @@ export class World {
|
|
|
430
431
|
const m = /hsl\(\s*([\d.]+)[deg\s]*[, ]\s*([\d.]+)%[, ]\s*([\d.]+)%/.exec(c);
|
|
431
432
|
return m ? this.col(+m[1], +m[2], +m[3]) : (this.ink ? [0.18, 0.18, 0.28] : [0.9, 0.9, 1]);
|
|
432
433
|
}
|
|
434
|
+
/** Remap a recipe-supplied css colour for the ink edition's overlay labels (identity when dark). */
|
|
435
|
+
themedCss(color) {
|
|
436
|
+
if (!this.ink)
|
|
437
|
+
return color;
|
|
438
|
+
let c = this.inkCss.get(color);
|
|
439
|
+
if (!c) {
|
|
440
|
+
const m = /hsl\(\s*([\d.]+)(?:deg)?[\s,]+([\d.]+)%[\s,]+([\d.]+)%\s*\)/.exec(color);
|
|
441
|
+
c = m ? `hsl(${m[1]} ${m[2]}% ${clamp(100 - +m[3], 0, 100)}%)` : color;
|
|
442
|
+
this.inkCss.set(color, c);
|
|
443
|
+
}
|
|
444
|
+
return c;
|
|
445
|
+
}
|
|
433
446
|
// ── building the static world (same verbs as 2d) ──
|
|
434
447
|
pushFace(store, a, b, c, o, na, nb, nc) {
|
|
435
448
|
const n = na ? undefined : norm(cross(sub(b, a), sub(c, a)));
|
|
@@ -643,7 +656,7 @@ export class World {
|
|
|
643
656
|
if (!q)
|
|
644
657
|
continue;
|
|
645
658
|
this.og.globalAlpha = clamp(l.alpha, 0, 1);
|
|
646
|
-
this.og.fillStyle = l.color;
|
|
659
|
+
this.og.fillStyle = this.themedCss(l.color);
|
|
647
660
|
this.og.fillText(l.text, q.x, q.y + l.dy);
|
|
648
661
|
}
|
|
649
662
|
this.og.globalAlpha = 1;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chromatic-coherence/generative-charts-3d",
|
|
3
|
-
"version": "0.13.
|
|
3
|
+
"version": "0.13.1",
|
|
4
4
|
"description": "The second generative-charts engine — the same API as generative-charts-2d, rendered on WebGL: a real depth buffer (occlusion exact, always on, for solids and light) and per-pixel Lambert + point lights. Zero dependencies.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|