@crysound/crychart 1.0.5 → 1.0.6
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/README.md +2 -2
- package/README.zh-CN.md +2 -2
- package/dist/crychart.cjs +90 -20
- package/dist/crychart.global.js +90 -20
- package/dist/crychart.js +90 -20
- package/dist/types/index.d.ts +1 -1
- package/dist/types/mesh3d.d.ts +1 -0
- package/docs/npm-usage.md +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -6,12 +6,12 @@ CRYChart is a **frontend rendering library built by CRYSOUND for OpenTest**, wri
|
|
|
6
6
|
|
|
7
7
|
Designed for OpenTest's data visualization needs, CRYChart provides streaming data rendering, interactive axes, cursors, and 2D and 3D charts. It uses WebGL2 for rendering, with a Canvas fallback.
|
|
8
8
|
|
|
9
|
-
Version `1.0.
|
|
9
|
+
Version `1.0.6` reduces 3D mesh and wireframe allocations by reusing unchanged topology while preserving sample values and ordered geometry.
|
|
10
10
|
|
|
11
11
|
## Install in an application
|
|
12
12
|
|
|
13
13
|
```powershell
|
|
14
|
-
pnpm add --save-exact @crysound/crychart@1.0.
|
|
14
|
+
pnpm add --save-exact @crysound/crychart@1.0.6 --registry=https://registry.npmjs.org/
|
|
15
15
|
```
|
|
16
16
|
|
|
17
17
|
Commit the application's lockfile and use `pnpm install --frozen-lockfile` for repeatable installs. See the [npm usage guide](docs/npm-usage.md) for package entry points and migration from the old `crychart` name.
|
package/README.zh-CN.md
CHANGED
|
@@ -6,12 +6,12 @@ CRYChart 是 **CRYSOUND 为 OpenTest 定制的前端渲染库**,基于 TypeScr
|
|
|
6
6
|
|
|
7
7
|
CRYChart 面向 OpenTest 的数据可视化场景,提供流式数据绘制、交互坐标轴、游标、二维和三维图表。绘图使用 WebGL2,并提供 Canvas 回退。
|
|
8
8
|
|
|
9
|
-
`1.0.
|
|
9
|
+
`1.0.6` 通过复用未变化的拓扑,减少三维网格和线框绘制的内存分配,保留原始采样值及几何遍历顺序。
|
|
10
10
|
|
|
11
11
|
## 在应用中安装
|
|
12
12
|
|
|
13
13
|
```powershell
|
|
14
|
-
pnpm add --save-exact @crysound/crychart@1.0.
|
|
14
|
+
pnpm add --save-exact @crysound/crychart@1.0.6 --registry=https://registry.npmjs.org/
|
|
15
15
|
```
|
|
16
16
|
|
|
17
17
|
提交应用的锁文件,后续执行 `pnpm install --frozen-lockfile`。包入口和旧 `crychart` 包名的迁移方式见 [npm 使用说明](docs/npm-usage.md)。
|
package/dist/crychart.cjs
CHANGED
|
@@ -19035,6 +19035,35 @@ var integer = (value, minimum = 0) => {
|
|
|
19035
19035
|
var rgba = (color2) => [color2.r, color2.g, color2.b, color2.a];
|
|
19036
19036
|
var meshFillColor = (fill, fallback) => fill.kind === "empty" ? ColorRGBA(0, 0, 0, 0) : fill.getColor?.() ?? fallback;
|
|
19037
19037
|
var finiteVertex2 = (values, index) => Number.isFinite(values[index * 3]) && Number.isFinite(values[index * 3 + 1]) && Number.isFinite(values[index * 3 + 2]);
|
|
19038
|
+
function structuredWireEdges(indices, count) {
|
|
19039
|
+
const columns = indices[1], rows = count / columns;
|
|
19040
|
+
if (!Number.isInteger(columns) || columns < 2 || !Number.isInteger(rows) || rows < 2 || indices.length !== (rows - 1) * (columns - 1) * 6) return void 0;
|
|
19041
|
+
let offset = 0;
|
|
19042
|
+
for (let row = 0; row + 1 < rows; row++) for (let col = 0; col + 1 < columns; col++, offset += 6) {
|
|
19043
|
+
const i = row * columns + col, below = i + columns;
|
|
19044
|
+
if (indices[offset] !== i || indices[offset + 1] !== below || indices[offset + 2] !== i + 1 || indices[offset + 3] !== i + 1 || indices[offset + 4] !== below || indices[offset + 5] !== below + 1) return void 0;
|
|
19045
|
+
}
|
|
19046
|
+
const pairs = new Uint32Array((rows * (columns - 1) + (rows - 1) * columns + (rows - 1) * (columns - 1)) * 2);
|
|
19047
|
+
let length = 0;
|
|
19048
|
+
for (let row = 0; row + 1 < rows; row++) for (let col = 0; col + 1 < columns; col++) {
|
|
19049
|
+
const i = row * columns + col, below = i + columns;
|
|
19050
|
+
if (col === 0) {
|
|
19051
|
+
pairs[length++] = i;
|
|
19052
|
+
pairs[length++] = below;
|
|
19053
|
+
}
|
|
19054
|
+
pairs[length++] = below;
|
|
19055
|
+
pairs[length++] = i + 1;
|
|
19056
|
+
if (row === 0) {
|
|
19057
|
+
pairs[length++] = i + 1;
|
|
19058
|
+
pairs[length++] = i;
|
|
19059
|
+
}
|
|
19060
|
+
pairs[length++] = below;
|
|
19061
|
+
pairs[length++] = below + 1;
|
|
19062
|
+
pairs[length++] = below + 1;
|
|
19063
|
+
pairs[length++] = i + 1;
|
|
19064
|
+
}
|
|
19065
|
+
return pairs;
|
|
19066
|
+
}
|
|
19038
19067
|
function mergedRanges(ranges, width = 1) {
|
|
19039
19068
|
const sorted = ranges.filter((range) => range.count > 0).map((range) => ({ start: range.start, count: range.count })).sort((a, b) => a.start - b.start), out = [];
|
|
19040
19069
|
for (const range of sorted) {
|
|
@@ -19261,28 +19290,34 @@ var MeshSeries3D = class extends Series3DBase {
|
|
|
19261
19290
|
dirty = [];
|
|
19262
19291
|
styleDirty = true;
|
|
19263
19292
|
compiled;
|
|
19293
|
+
wireTopology;
|
|
19264
19294
|
boundsCache;
|
|
19265
19295
|
setGeometry(input) {
|
|
19266
19296
|
this.assertAlive();
|
|
19267
19297
|
if (!input?.positions || input.positions.length % 3) throw new RangeError("Mesh positions require complete XYZ vertices");
|
|
19268
19298
|
const positions = Float64Array.from(input.positions), count = positions.length / 3;
|
|
19269
|
-
const
|
|
19270
|
-
|
|
19271
|
-
|
|
19272
|
-
|
|
19299
|
+
const unsignedIndices = input.indices instanceof Uint32Array;
|
|
19300
|
+
if (input.indices) for (let i = 0; i < input.indices.length; i++) {
|
|
19301
|
+
const index = input.indices[i];
|
|
19302
|
+
if (index >= count || !unsignedIndices && (!Number.isSafeInteger(index) || index < 0)) throw new RangeError("Mesh index outside vertex range");
|
|
19303
|
+
}
|
|
19304
|
+
const indices = input.indices ? Uint32Array.from(input.indices) : Uint32Array.from({ length: Math.floor(count / 3) * 3 }, (_, index) => index);
|
|
19273
19305
|
if (indices.length % 3) throw new RangeError("Mesh indices require complete triangles");
|
|
19274
19306
|
if (input.values && input.values.length !== count || input.colors && input.colors.length !== count * 4) throw new RangeError("Mesh values/colors do not match vertex count");
|
|
19275
19307
|
const colors = input.colors ? Float32Array.from(input.colors) : void 0;
|
|
19276
19308
|
if (colors && !colors.every((value) => Number.isFinite(value) && value >= 0 && value <= 1)) throw new RangeError("Mesh colors require normalized finite RGBA");
|
|
19309
|
+
const sameTopology = positions.length === this.vertices.length && indices.length === this.indices.length && indices.every((value, index) => value === this.indices[index]);
|
|
19277
19310
|
this.vertices = positions;
|
|
19278
|
-
|
|
19311
|
+
if (!sameTopology) {
|
|
19312
|
+
this.indices = indices;
|
|
19313
|
+
this.topologyRevision++;
|
|
19314
|
+
this.compiled = void 0;
|
|
19315
|
+
}
|
|
19279
19316
|
this.scalarValues = input.values ? Float32Array.from(input.values) : void 0;
|
|
19280
19317
|
this.vertexColors = colors;
|
|
19281
|
-
this.topologyRevision++;
|
|
19282
19318
|
this.geometryRevision++;
|
|
19283
19319
|
this.dirty = [{ start: 0, count }];
|
|
19284
19320
|
this.styleDirty = true;
|
|
19285
|
-
this.compiled = void 0;
|
|
19286
19321
|
this.changed();
|
|
19287
19322
|
return this;
|
|
19288
19323
|
}
|
|
@@ -19371,28 +19406,62 @@ var MeshSeries3D = class extends Series3DBase {
|
|
|
19371
19406
|
for (const range of ranges) for (let i = range.start; i < range.start + range.count; i++) {
|
|
19372
19407
|
if (!all && !finiteVertex2(positions, i)) invalidVertices--;
|
|
19373
19408
|
const point = this.normalizedVertex(i, normalize);
|
|
19374
|
-
positions
|
|
19409
|
+
positions[i * 3] = point.x;
|
|
19410
|
+
positions[i * 3 + 1] = point.y;
|
|
19411
|
+
positions[i * 3 + 2] = point.z;
|
|
19375
19412
|
if (!finiteVertex2(positions, i)) invalidVertices++;
|
|
19376
19413
|
}
|
|
19377
19414
|
const colorRanges = all || this.styleDirty ? [{ start: 0, count }] : ranges;
|
|
19378
|
-
for (const range of colorRanges) for (let i = range.start; i < range.start + range.count; i++)
|
|
19415
|
+
for (const range of colorRanges) for (let i = range.start; i < range.start + range.count; i++) {
|
|
19416
|
+
const color2 = this.colorAt(i);
|
|
19417
|
+
colors[i * 4] = color2.r;
|
|
19418
|
+
colors[i * 4 + 1] = color2.g;
|
|
19419
|
+
colors[i * 4 + 2] = color2.b;
|
|
19420
|
+
colors[i * 4 + 3] = color2.a;
|
|
19421
|
+
}
|
|
19379
19422
|
const normal = ranges.length ? this.updateNormals(positions, all ? void 0 : previous?.packet.normals, ranges) : { values: previous?.packet.normals ?? meshNormals(positions, this.indices), ranges: [] };
|
|
19380
19423
|
const packet = { id: this.id, revision: ++this.packetRevision, previousRevision: previous?.packet.revision, count, mode: "triangles", positions, colors, normals: normal.values, indices: this.indices, indexRevision: this.topologyRevision, allFinite: invalidVertices === 0, lighting: this.lighting, ...this.renderingState(), color: [1, 1, 1, 1], thickness: 0, pointSize: 0, positionUpdateRanges: all ? void 0 : mergedRanges(ranges, 3), colorUpdateRanges: all ? void 0 : mergedRanges(colorRanges, 4), normalUpdateRanges: all ? void 0 : normal.ranges };
|
|
19381
19424
|
const packets = [packet];
|
|
19382
19425
|
let wire;
|
|
19383
19426
|
if (this.wireframe.getThickness() > 0 && meshFillColor(this.wireframe.getFillStyle(), ColorRGBA(0, 0, 0)).a > 0) {
|
|
19384
|
-
const
|
|
19385
|
-
|
|
19386
|
-
|
|
19387
|
-
|
|
19388
|
-
|
|
19389
|
-
|
|
19390
|
-
|
|
19391
|
-
|
|
19392
|
-
|
|
19427
|
+
const valid2 = new Uint8Array(this.indices.length / 3);
|
|
19428
|
+
if (invalidVertices === 0) valid2.fill(1);
|
|
19429
|
+
else for (let i = 0; i < this.indices.length; i += 3) valid2[i / 3] = finiteVertex2(positions, this.indices[i]) && finiteVertex2(positions, this.indices[i + 1]) && finiteVertex2(positions, this.indices[i + 2]) ? 1 : 0;
|
|
19430
|
+
let topology = this.wireTopology;
|
|
19431
|
+
if (!topology || topology.indices.length !== this.indices.length || !this.indices.every((value, index) => value === topology.indices[index]) || !valid2.every((value, index) => value === topology.valid[index])) {
|
|
19432
|
+
const gridPairs = invalidVertices === 0 ? structuredWireEdges(this.indices, count) : void 0;
|
|
19433
|
+
if (gridPairs) topology = this.wireTopology = { indices: this.indices.slice(), valid: valid2, pairs: gridPairs };
|
|
19434
|
+
else {
|
|
19435
|
+
const edges = /* @__PURE__ */ new Set(), pairs = new Uint32Array(this.indices.length * 2);
|
|
19436
|
+
const numericKeys = Number.isSafeInteger(count * count);
|
|
19437
|
+
let length = 0;
|
|
19438
|
+
for (let i = 0; i < this.indices.length; i += 3) {
|
|
19439
|
+
if (!valid2[i / 3]) continue;
|
|
19440
|
+
for (let j = 0; j < 3; j++) {
|
|
19441
|
+
const a = this.indices[i + j], b = this.indices[i + (j + 1) % 3];
|
|
19442
|
+
const low = Math.min(a, b), high = Math.max(a, b);
|
|
19443
|
+
const key = numericKeys ? low * count + high : `${low}:${high}`;
|
|
19444
|
+
if (edges.has(key)) continue;
|
|
19445
|
+
edges.add(key);
|
|
19446
|
+
pairs[length++] = a;
|
|
19447
|
+
pairs[length++] = b;
|
|
19448
|
+
}
|
|
19449
|
+
}
|
|
19450
|
+
topology = this.wireTopology = { indices: this.indices.slice(), valid: valid2, pairs: pairs.subarray(0, length) };
|
|
19393
19451
|
}
|
|
19394
19452
|
}
|
|
19395
|
-
|
|
19453
|
+
const values = new Float32Array(topology.pairs.length / 2 * 9);
|
|
19454
|
+
for (let i = 0, out = 0; i < topology.pairs.length; i += 2, out += 9) {
|
|
19455
|
+
const a = topology.pairs[i] * 3, b = topology.pairs[i + 1] * 3;
|
|
19456
|
+
values[out] = positions[a];
|
|
19457
|
+
values[out + 1] = positions[a + 1];
|
|
19458
|
+
values[out + 2] = positions[a + 2];
|
|
19459
|
+
values[out + 3] = positions[b];
|
|
19460
|
+
values[out + 4] = positions[b + 1];
|
|
19461
|
+
values[out + 5] = positions[b + 2];
|
|
19462
|
+
values[out + 6] = values[out + 7] = values[out + 8] = NaN;
|
|
19463
|
+
}
|
|
19464
|
+
wire = { id: -this.id, revision: packet.revision, count: values.length / 3, mode: "line", positions: values, ...this.renderingState(), color: rgba(meshFillColor(this.wireframe.getFillStyle(), ColorRGBA(0, 0, 0))), thickness: this.wireframe.getThickness(), pointSize: 0 };
|
|
19396
19465
|
packets.push(wire);
|
|
19397
19466
|
}
|
|
19398
19467
|
this.compiled = { key: axisKey, revision: this.revision, packet, wire, packets, invalidVertices };
|
|
@@ -19402,6 +19471,7 @@ var MeshSeries3D = class extends Series3DBase {
|
|
|
19402
19471
|
}
|
|
19403
19472
|
dispose() {
|
|
19404
19473
|
this.compiled = void 0;
|
|
19474
|
+
this.wireTopology = void 0;
|
|
19405
19475
|
this.vertices = new Float64Array(0);
|
|
19406
19476
|
this.indices = new Uint32Array(0);
|
|
19407
19477
|
this.scalarValues = void 0;
|
|
@@ -25168,7 +25238,7 @@ function cryChart(_options = {}) {
|
|
|
25168
25238
|
getChartCount: () => owned2.size
|
|
25169
25239
|
};
|
|
25170
25240
|
}
|
|
25171
|
-
var version = "1.0.
|
|
25241
|
+
var version = "1.0.6";
|
|
25172
25242
|
var Dashboard = class {
|
|
25173
25243
|
root;
|
|
25174
25244
|
cells = /* @__PURE__ */ new Map();
|
package/dist/crychart.global.js
CHANGED
|
@@ -19035,6 +19035,35 @@ void main() {
|
|
|
19035
19035
|
var rgba = (color2) => [color2.r, color2.g, color2.b, color2.a];
|
|
19036
19036
|
var meshFillColor = (fill, fallback) => fill.kind === "empty" ? ColorRGBA(0, 0, 0, 0) : fill.getColor?.() ?? fallback;
|
|
19037
19037
|
var finiteVertex2 = (values, index) => Number.isFinite(values[index * 3]) && Number.isFinite(values[index * 3 + 1]) && Number.isFinite(values[index * 3 + 2]);
|
|
19038
|
+
function structuredWireEdges(indices, count) {
|
|
19039
|
+
const columns = indices[1], rows = count / columns;
|
|
19040
|
+
if (!Number.isInteger(columns) || columns < 2 || !Number.isInteger(rows) || rows < 2 || indices.length !== (rows - 1) * (columns - 1) * 6) return void 0;
|
|
19041
|
+
let offset = 0;
|
|
19042
|
+
for (let row = 0; row + 1 < rows; row++) for (let col = 0; col + 1 < columns; col++, offset += 6) {
|
|
19043
|
+
const i = row * columns + col, below = i + columns;
|
|
19044
|
+
if (indices[offset] !== i || indices[offset + 1] !== below || indices[offset + 2] !== i + 1 || indices[offset + 3] !== i + 1 || indices[offset + 4] !== below || indices[offset + 5] !== below + 1) return void 0;
|
|
19045
|
+
}
|
|
19046
|
+
const pairs = new Uint32Array((rows * (columns - 1) + (rows - 1) * columns + (rows - 1) * (columns - 1)) * 2);
|
|
19047
|
+
let length = 0;
|
|
19048
|
+
for (let row = 0; row + 1 < rows; row++) for (let col = 0; col + 1 < columns; col++) {
|
|
19049
|
+
const i = row * columns + col, below = i + columns;
|
|
19050
|
+
if (col === 0) {
|
|
19051
|
+
pairs[length++] = i;
|
|
19052
|
+
pairs[length++] = below;
|
|
19053
|
+
}
|
|
19054
|
+
pairs[length++] = below;
|
|
19055
|
+
pairs[length++] = i + 1;
|
|
19056
|
+
if (row === 0) {
|
|
19057
|
+
pairs[length++] = i + 1;
|
|
19058
|
+
pairs[length++] = i;
|
|
19059
|
+
}
|
|
19060
|
+
pairs[length++] = below;
|
|
19061
|
+
pairs[length++] = below + 1;
|
|
19062
|
+
pairs[length++] = below + 1;
|
|
19063
|
+
pairs[length++] = i + 1;
|
|
19064
|
+
}
|
|
19065
|
+
return pairs;
|
|
19066
|
+
}
|
|
19038
19067
|
function mergedRanges(ranges, width = 1) {
|
|
19039
19068
|
const sorted = ranges.filter((range) => range.count > 0).map((range) => ({ start: range.start, count: range.count })).sort((a, b) => a.start - b.start), out = [];
|
|
19040
19069
|
for (const range of sorted) {
|
|
@@ -19261,28 +19290,34 @@ void main() {
|
|
|
19261
19290
|
dirty = [];
|
|
19262
19291
|
styleDirty = true;
|
|
19263
19292
|
compiled;
|
|
19293
|
+
wireTopology;
|
|
19264
19294
|
boundsCache;
|
|
19265
19295
|
setGeometry(input) {
|
|
19266
19296
|
this.assertAlive();
|
|
19267
19297
|
if (!input?.positions || input.positions.length % 3) throw new RangeError("Mesh positions require complete XYZ vertices");
|
|
19268
19298
|
const positions = Float64Array.from(input.positions), count = positions.length / 3;
|
|
19269
|
-
const
|
|
19270
|
-
|
|
19271
|
-
|
|
19272
|
-
|
|
19299
|
+
const unsignedIndices = input.indices instanceof Uint32Array;
|
|
19300
|
+
if (input.indices) for (let i = 0; i < input.indices.length; i++) {
|
|
19301
|
+
const index = input.indices[i];
|
|
19302
|
+
if (index >= count || !unsignedIndices && (!Number.isSafeInteger(index) || index < 0)) throw new RangeError("Mesh index outside vertex range");
|
|
19303
|
+
}
|
|
19304
|
+
const indices = input.indices ? Uint32Array.from(input.indices) : Uint32Array.from({ length: Math.floor(count / 3) * 3 }, (_, index) => index);
|
|
19273
19305
|
if (indices.length % 3) throw new RangeError("Mesh indices require complete triangles");
|
|
19274
19306
|
if (input.values && input.values.length !== count || input.colors && input.colors.length !== count * 4) throw new RangeError("Mesh values/colors do not match vertex count");
|
|
19275
19307
|
const colors = input.colors ? Float32Array.from(input.colors) : void 0;
|
|
19276
19308
|
if (colors && !colors.every((value) => Number.isFinite(value) && value >= 0 && value <= 1)) throw new RangeError("Mesh colors require normalized finite RGBA");
|
|
19309
|
+
const sameTopology = positions.length === this.vertices.length && indices.length === this.indices.length && indices.every((value, index) => value === this.indices[index]);
|
|
19277
19310
|
this.vertices = positions;
|
|
19278
|
-
|
|
19311
|
+
if (!sameTopology) {
|
|
19312
|
+
this.indices = indices;
|
|
19313
|
+
this.topologyRevision++;
|
|
19314
|
+
this.compiled = void 0;
|
|
19315
|
+
}
|
|
19279
19316
|
this.scalarValues = input.values ? Float32Array.from(input.values) : void 0;
|
|
19280
19317
|
this.vertexColors = colors;
|
|
19281
|
-
this.topologyRevision++;
|
|
19282
19318
|
this.geometryRevision++;
|
|
19283
19319
|
this.dirty = [{ start: 0, count }];
|
|
19284
19320
|
this.styleDirty = true;
|
|
19285
|
-
this.compiled = void 0;
|
|
19286
19321
|
this.changed();
|
|
19287
19322
|
return this;
|
|
19288
19323
|
}
|
|
@@ -19371,28 +19406,62 @@ void main() {
|
|
|
19371
19406
|
for (const range of ranges) for (let i = range.start; i < range.start + range.count; i++) {
|
|
19372
19407
|
if (!all && !finiteVertex2(positions, i)) invalidVertices--;
|
|
19373
19408
|
const point = this.normalizedVertex(i, normalize);
|
|
19374
|
-
positions
|
|
19409
|
+
positions[i * 3] = point.x;
|
|
19410
|
+
positions[i * 3 + 1] = point.y;
|
|
19411
|
+
positions[i * 3 + 2] = point.z;
|
|
19375
19412
|
if (!finiteVertex2(positions, i)) invalidVertices++;
|
|
19376
19413
|
}
|
|
19377
19414
|
const colorRanges = all || this.styleDirty ? [{ start: 0, count }] : ranges;
|
|
19378
|
-
for (const range of colorRanges) for (let i = range.start; i < range.start + range.count; i++)
|
|
19415
|
+
for (const range of colorRanges) for (let i = range.start; i < range.start + range.count; i++) {
|
|
19416
|
+
const color2 = this.colorAt(i);
|
|
19417
|
+
colors[i * 4] = color2.r;
|
|
19418
|
+
colors[i * 4 + 1] = color2.g;
|
|
19419
|
+
colors[i * 4 + 2] = color2.b;
|
|
19420
|
+
colors[i * 4 + 3] = color2.a;
|
|
19421
|
+
}
|
|
19379
19422
|
const normal = ranges.length ? this.updateNormals(positions, all ? void 0 : previous?.packet.normals, ranges) : { values: previous?.packet.normals ?? meshNormals(positions, this.indices), ranges: [] };
|
|
19380
19423
|
const packet = { id: this.id, revision: ++this.packetRevision, previousRevision: previous?.packet.revision, count, mode: "triangles", positions, colors, normals: normal.values, indices: this.indices, indexRevision: this.topologyRevision, allFinite: invalidVertices === 0, lighting: this.lighting, ...this.renderingState(), color: [1, 1, 1, 1], thickness: 0, pointSize: 0, positionUpdateRanges: all ? void 0 : mergedRanges(ranges, 3), colorUpdateRanges: all ? void 0 : mergedRanges(colorRanges, 4), normalUpdateRanges: all ? void 0 : normal.ranges };
|
|
19381
19424
|
const packets = [packet];
|
|
19382
19425
|
let wire;
|
|
19383
19426
|
if (this.wireframe.getThickness() > 0 && meshFillColor(this.wireframe.getFillStyle(), ColorRGBA(0, 0, 0)).a > 0) {
|
|
19384
|
-
const
|
|
19385
|
-
|
|
19386
|
-
|
|
19387
|
-
|
|
19388
|
-
|
|
19389
|
-
|
|
19390
|
-
|
|
19391
|
-
|
|
19392
|
-
|
|
19427
|
+
const valid2 = new Uint8Array(this.indices.length / 3);
|
|
19428
|
+
if (invalidVertices === 0) valid2.fill(1);
|
|
19429
|
+
else for (let i = 0; i < this.indices.length; i += 3) valid2[i / 3] = finiteVertex2(positions, this.indices[i]) && finiteVertex2(positions, this.indices[i + 1]) && finiteVertex2(positions, this.indices[i + 2]) ? 1 : 0;
|
|
19430
|
+
let topology = this.wireTopology;
|
|
19431
|
+
if (!topology || topology.indices.length !== this.indices.length || !this.indices.every((value, index) => value === topology.indices[index]) || !valid2.every((value, index) => value === topology.valid[index])) {
|
|
19432
|
+
const gridPairs = invalidVertices === 0 ? structuredWireEdges(this.indices, count) : void 0;
|
|
19433
|
+
if (gridPairs) topology = this.wireTopology = { indices: this.indices.slice(), valid: valid2, pairs: gridPairs };
|
|
19434
|
+
else {
|
|
19435
|
+
const edges = /* @__PURE__ */ new Set(), pairs = new Uint32Array(this.indices.length * 2);
|
|
19436
|
+
const numericKeys = Number.isSafeInteger(count * count);
|
|
19437
|
+
let length = 0;
|
|
19438
|
+
for (let i = 0; i < this.indices.length; i += 3) {
|
|
19439
|
+
if (!valid2[i / 3]) continue;
|
|
19440
|
+
for (let j = 0; j < 3; j++) {
|
|
19441
|
+
const a = this.indices[i + j], b = this.indices[i + (j + 1) % 3];
|
|
19442
|
+
const low = Math.min(a, b), high = Math.max(a, b);
|
|
19443
|
+
const key = numericKeys ? low * count + high : `${low}:${high}`;
|
|
19444
|
+
if (edges.has(key)) continue;
|
|
19445
|
+
edges.add(key);
|
|
19446
|
+
pairs[length++] = a;
|
|
19447
|
+
pairs[length++] = b;
|
|
19448
|
+
}
|
|
19449
|
+
}
|
|
19450
|
+
topology = this.wireTopology = { indices: this.indices.slice(), valid: valid2, pairs: pairs.subarray(0, length) };
|
|
19393
19451
|
}
|
|
19394
19452
|
}
|
|
19395
|
-
|
|
19453
|
+
const values = new Float32Array(topology.pairs.length / 2 * 9);
|
|
19454
|
+
for (let i = 0, out = 0; i < topology.pairs.length; i += 2, out += 9) {
|
|
19455
|
+
const a = topology.pairs[i] * 3, b = topology.pairs[i + 1] * 3;
|
|
19456
|
+
values[out] = positions[a];
|
|
19457
|
+
values[out + 1] = positions[a + 1];
|
|
19458
|
+
values[out + 2] = positions[a + 2];
|
|
19459
|
+
values[out + 3] = positions[b];
|
|
19460
|
+
values[out + 4] = positions[b + 1];
|
|
19461
|
+
values[out + 5] = positions[b + 2];
|
|
19462
|
+
values[out + 6] = values[out + 7] = values[out + 8] = NaN;
|
|
19463
|
+
}
|
|
19464
|
+
wire = { id: -this.id, revision: packet.revision, count: values.length / 3, mode: "line", positions: values, ...this.renderingState(), color: rgba(meshFillColor(this.wireframe.getFillStyle(), ColorRGBA(0, 0, 0))), thickness: this.wireframe.getThickness(), pointSize: 0 };
|
|
19396
19465
|
packets.push(wire);
|
|
19397
19466
|
}
|
|
19398
19467
|
this.compiled = { key: axisKey, revision: this.revision, packet, wire, packets, invalidVertices };
|
|
@@ -19402,6 +19471,7 @@ void main() {
|
|
|
19402
19471
|
}
|
|
19403
19472
|
dispose() {
|
|
19404
19473
|
this.compiled = void 0;
|
|
19474
|
+
this.wireTopology = void 0;
|
|
19405
19475
|
this.vertices = new Float64Array(0);
|
|
19406
19476
|
this.indices = new Uint32Array(0);
|
|
19407
19477
|
this.scalarValues = void 0;
|
|
@@ -25168,7 +25238,7 @@ ${sample.position[0].toFixed(4)}, ${sample.position[1].toFixed(4)}`, contains: (
|
|
|
25168
25238
|
getChartCount: () => owned2.size
|
|
25169
25239
|
};
|
|
25170
25240
|
}
|
|
25171
|
-
var version = "1.0.
|
|
25241
|
+
var version = "1.0.6";
|
|
25172
25242
|
var Dashboard = class {
|
|
25173
25243
|
root;
|
|
25174
25244
|
cells = /* @__PURE__ */ new Map();
|
package/dist/crychart.js
CHANGED
|
@@ -18851,6 +18851,35 @@ var integer = (value, minimum = 0) => {
|
|
|
18851
18851
|
var rgba = (color2) => [color2.r, color2.g, color2.b, color2.a];
|
|
18852
18852
|
var meshFillColor = (fill, fallback) => fill.kind === "empty" ? ColorRGBA(0, 0, 0, 0) : fill.getColor?.() ?? fallback;
|
|
18853
18853
|
var finiteVertex2 = (values, index) => Number.isFinite(values[index * 3]) && Number.isFinite(values[index * 3 + 1]) && Number.isFinite(values[index * 3 + 2]);
|
|
18854
|
+
function structuredWireEdges(indices, count) {
|
|
18855
|
+
const columns = indices[1], rows = count / columns;
|
|
18856
|
+
if (!Number.isInteger(columns) || columns < 2 || !Number.isInteger(rows) || rows < 2 || indices.length !== (rows - 1) * (columns - 1) * 6) return void 0;
|
|
18857
|
+
let offset = 0;
|
|
18858
|
+
for (let row = 0; row + 1 < rows; row++) for (let col = 0; col + 1 < columns; col++, offset += 6) {
|
|
18859
|
+
const i = row * columns + col, below = i + columns;
|
|
18860
|
+
if (indices[offset] !== i || indices[offset + 1] !== below || indices[offset + 2] !== i + 1 || indices[offset + 3] !== i + 1 || indices[offset + 4] !== below || indices[offset + 5] !== below + 1) return void 0;
|
|
18861
|
+
}
|
|
18862
|
+
const pairs = new Uint32Array((rows * (columns - 1) + (rows - 1) * columns + (rows - 1) * (columns - 1)) * 2);
|
|
18863
|
+
let length = 0;
|
|
18864
|
+
for (let row = 0; row + 1 < rows; row++) for (let col = 0; col + 1 < columns; col++) {
|
|
18865
|
+
const i = row * columns + col, below = i + columns;
|
|
18866
|
+
if (col === 0) {
|
|
18867
|
+
pairs[length++] = i;
|
|
18868
|
+
pairs[length++] = below;
|
|
18869
|
+
}
|
|
18870
|
+
pairs[length++] = below;
|
|
18871
|
+
pairs[length++] = i + 1;
|
|
18872
|
+
if (row === 0) {
|
|
18873
|
+
pairs[length++] = i + 1;
|
|
18874
|
+
pairs[length++] = i;
|
|
18875
|
+
}
|
|
18876
|
+
pairs[length++] = below;
|
|
18877
|
+
pairs[length++] = below + 1;
|
|
18878
|
+
pairs[length++] = below + 1;
|
|
18879
|
+
pairs[length++] = i + 1;
|
|
18880
|
+
}
|
|
18881
|
+
return pairs;
|
|
18882
|
+
}
|
|
18854
18883
|
function mergedRanges(ranges, width = 1) {
|
|
18855
18884
|
const sorted = ranges.filter((range) => range.count > 0).map((range) => ({ start: range.start, count: range.count })).sort((a, b) => a.start - b.start), out = [];
|
|
18856
18885
|
for (const range of sorted) {
|
|
@@ -19077,28 +19106,34 @@ var MeshSeries3D = class extends Series3DBase {
|
|
|
19077
19106
|
dirty = [];
|
|
19078
19107
|
styleDirty = true;
|
|
19079
19108
|
compiled;
|
|
19109
|
+
wireTopology;
|
|
19080
19110
|
boundsCache;
|
|
19081
19111
|
setGeometry(input) {
|
|
19082
19112
|
this.assertAlive();
|
|
19083
19113
|
if (!input?.positions || input.positions.length % 3) throw new RangeError("Mesh positions require complete XYZ vertices");
|
|
19084
19114
|
const positions = Float64Array.from(input.positions), count = positions.length / 3;
|
|
19085
|
-
const
|
|
19086
|
-
|
|
19087
|
-
|
|
19088
|
-
|
|
19115
|
+
const unsignedIndices = input.indices instanceof Uint32Array;
|
|
19116
|
+
if (input.indices) for (let i = 0; i < input.indices.length; i++) {
|
|
19117
|
+
const index = input.indices[i];
|
|
19118
|
+
if (index >= count || !unsignedIndices && (!Number.isSafeInteger(index) || index < 0)) throw new RangeError("Mesh index outside vertex range");
|
|
19119
|
+
}
|
|
19120
|
+
const indices = input.indices ? Uint32Array.from(input.indices) : Uint32Array.from({ length: Math.floor(count / 3) * 3 }, (_, index) => index);
|
|
19089
19121
|
if (indices.length % 3) throw new RangeError("Mesh indices require complete triangles");
|
|
19090
19122
|
if (input.values && input.values.length !== count || input.colors && input.colors.length !== count * 4) throw new RangeError("Mesh values/colors do not match vertex count");
|
|
19091
19123
|
const colors = input.colors ? Float32Array.from(input.colors) : void 0;
|
|
19092
19124
|
if (colors && !colors.every((value) => Number.isFinite(value) && value >= 0 && value <= 1)) throw new RangeError("Mesh colors require normalized finite RGBA");
|
|
19125
|
+
const sameTopology = positions.length === this.vertices.length && indices.length === this.indices.length && indices.every((value, index) => value === this.indices[index]);
|
|
19093
19126
|
this.vertices = positions;
|
|
19094
|
-
|
|
19127
|
+
if (!sameTopology) {
|
|
19128
|
+
this.indices = indices;
|
|
19129
|
+
this.topologyRevision++;
|
|
19130
|
+
this.compiled = void 0;
|
|
19131
|
+
}
|
|
19095
19132
|
this.scalarValues = input.values ? Float32Array.from(input.values) : void 0;
|
|
19096
19133
|
this.vertexColors = colors;
|
|
19097
|
-
this.topologyRevision++;
|
|
19098
19134
|
this.geometryRevision++;
|
|
19099
19135
|
this.dirty = [{ start: 0, count }];
|
|
19100
19136
|
this.styleDirty = true;
|
|
19101
|
-
this.compiled = void 0;
|
|
19102
19137
|
this.changed();
|
|
19103
19138
|
return this;
|
|
19104
19139
|
}
|
|
@@ -19187,28 +19222,62 @@ var MeshSeries3D = class extends Series3DBase {
|
|
|
19187
19222
|
for (const range of ranges) for (let i = range.start; i < range.start + range.count; i++) {
|
|
19188
19223
|
if (!all && !finiteVertex2(positions, i)) invalidVertices--;
|
|
19189
19224
|
const point = this.normalizedVertex(i, normalize);
|
|
19190
|
-
positions
|
|
19225
|
+
positions[i * 3] = point.x;
|
|
19226
|
+
positions[i * 3 + 1] = point.y;
|
|
19227
|
+
positions[i * 3 + 2] = point.z;
|
|
19191
19228
|
if (!finiteVertex2(positions, i)) invalidVertices++;
|
|
19192
19229
|
}
|
|
19193
19230
|
const colorRanges = all || this.styleDirty ? [{ start: 0, count }] : ranges;
|
|
19194
|
-
for (const range of colorRanges) for (let i = range.start; i < range.start + range.count; i++)
|
|
19231
|
+
for (const range of colorRanges) for (let i = range.start; i < range.start + range.count; i++) {
|
|
19232
|
+
const color2 = this.colorAt(i);
|
|
19233
|
+
colors[i * 4] = color2.r;
|
|
19234
|
+
colors[i * 4 + 1] = color2.g;
|
|
19235
|
+
colors[i * 4 + 2] = color2.b;
|
|
19236
|
+
colors[i * 4 + 3] = color2.a;
|
|
19237
|
+
}
|
|
19195
19238
|
const normal = ranges.length ? this.updateNormals(positions, all ? void 0 : previous?.packet.normals, ranges) : { values: previous?.packet.normals ?? meshNormals(positions, this.indices), ranges: [] };
|
|
19196
19239
|
const packet = { id: this.id, revision: ++this.packetRevision, previousRevision: previous?.packet.revision, count, mode: "triangles", positions, colors, normals: normal.values, indices: this.indices, indexRevision: this.topologyRevision, allFinite: invalidVertices === 0, lighting: this.lighting, ...this.renderingState(), color: [1, 1, 1, 1], thickness: 0, pointSize: 0, positionUpdateRanges: all ? void 0 : mergedRanges(ranges, 3), colorUpdateRanges: all ? void 0 : mergedRanges(colorRanges, 4), normalUpdateRanges: all ? void 0 : normal.ranges };
|
|
19197
19240
|
const packets = [packet];
|
|
19198
19241
|
let wire;
|
|
19199
19242
|
if (this.wireframe.getThickness() > 0 && meshFillColor(this.wireframe.getFillStyle(), ColorRGBA(0, 0, 0)).a > 0) {
|
|
19200
|
-
const
|
|
19201
|
-
|
|
19202
|
-
|
|
19203
|
-
|
|
19204
|
-
|
|
19205
|
-
|
|
19206
|
-
|
|
19207
|
-
|
|
19208
|
-
|
|
19243
|
+
const valid2 = new Uint8Array(this.indices.length / 3);
|
|
19244
|
+
if (invalidVertices === 0) valid2.fill(1);
|
|
19245
|
+
else for (let i = 0; i < this.indices.length; i += 3) valid2[i / 3] = finiteVertex2(positions, this.indices[i]) && finiteVertex2(positions, this.indices[i + 1]) && finiteVertex2(positions, this.indices[i + 2]) ? 1 : 0;
|
|
19246
|
+
let topology = this.wireTopology;
|
|
19247
|
+
if (!topology || topology.indices.length !== this.indices.length || !this.indices.every((value, index) => value === topology.indices[index]) || !valid2.every((value, index) => value === topology.valid[index])) {
|
|
19248
|
+
const gridPairs = invalidVertices === 0 ? structuredWireEdges(this.indices, count) : void 0;
|
|
19249
|
+
if (gridPairs) topology = this.wireTopology = { indices: this.indices.slice(), valid: valid2, pairs: gridPairs };
|
|
19250
|
+
else {
|
|
19251
|
+
const edges = /* @__PURE__ */ new Set(), pairs = new Uint32Array(this.indices.length * 2);
|
|
19252
|
+
const numericKeys = Number.isSafeInteger(count * count);
|
|
19253
|
+
let length = 0;
|
|
19254
|
+
for (let i = 0; i < this.indices.length; i += 3) {
|
|
19255
|
+
if (!valid2[i / 3]) continue;
|
|
19256
|
+
for (let j = 0; j < 3; j++) {
|
|
19257
|
+
const a = this.indices[i + j], b = this.indices[i + (j + 1) % 3];
|
|
19258
|
+
const low = Math.min(a, b), high = Math.max(a, b);
|
|
19259
|
+
const key = numericKeys ? low * count + high : `${low}:${high}`;
|
|
19260
|
+
if (edges.has(key)) continue;
|
|
19261
|
+
edges.add(key);
|
|
19262
|
+
pairs[length++] = a;
|
|
19263
|
+
pairs[length++] = b;
|
|
19264
|
+
}
|
|
19265
|
+
}
|
|
19266
|
+
topology = this.wireTopology = { indices: this.indices.slice(), valid: valid2, pairs: pairs.subarray(0, length) };
|
|
19209
19267
|
}
|
|
19210
19268
|
}
|
|
19211
|
-
|
|
19269
|
+
const values = new Float32Array(topology.pairs.length / 2 * 9);
|
|
19270
|
+
for (let i = 0, out = 0; i < topology.pairs.length; i += 2, out += 9) {
|
|
19271
|
+
const a = topology.pairs[i] * 3, b = topology.pairs[i + 1] * 3;
|
|
19272
|
+
values[out] = positions[a];
|
|
19273
|
+
values[out + 1] = positions[a + 1];
|
|
19274
|
+
values[out + 2] = positions[a + 2];
|
|
19275
|
+
values[out + 3] = positions[b];
|
|
19276
|
+
values[out + 4] = positions[b + 1];
|
|
19277
|
+
values[out + 5] = positions[b + 2];
|
|
19278
|
+
values[out + 6] = values[out + 7] = values[out + 8] = NaN;
|
|
19279
|
+
}
|
|
19280
|
+
wire = { id: -this.id, revision: packet.revision, count: values.length / 3, mode: "line", positions: values, ...this.renderingState(), color: rgba(meshFillColor(this.wireframe.getFillStyle(), ColorRGBA(0, 0, 0))), thickness: this.wireframe.getThickness(), pointSize: 0 };
|
|
19212
19281
|
packets.push(wire);
|
|
19213
19282
|
}
|
|
19214
19283
|
this.compiled = { key: axisKey, revision: this.revision, packet, wire, packets, invalidVertices };
|
|
@@ -19218,6 +19287,7 @@ var MeshSeries3D = class extends Series3DBase {
|
|
|
19218
19287
|
}
|
|
19219
19288
|
dispose() {
|
|
19220
19289
|
this.compiled = void 0;
|
|
19290
|
+
this.wireTopology = void 0;
|
|
19221
19291
|
this.vertices = new Float64Array(0);
|
|
19222
19292
|
this.indices = new Uint32Array(0);
|
|
19223
19293
|
this.scalarValues = void 0;
|
|
@@ -24984,7 +25054,7 @@ function cryChart(_options = {}) {
|
|
|
24984
25054
|
getChartCount: () => owned2.size
|
|
24985
25055
|
};
|
|
24986
25056
|
}
|
|
24987
|
-
var version = "1.0.
|
|
25057
|
+
var version = "1.0.6";
|
|
24988
25058
|
var Dashboard = class {
|
|
24989
25059
|
root;
|
|
24990
25060
|
cells = /* @__PURE__ */ new Map();
|
package/dist/types/index.d.ts
CHANGED
|
@@ -51,7 +51,7 @@ export declare function cryChart(_options?: Record<string, unknown>): {
|
|
|
51
51
|
/** Live charts owned by this context; disposed charts are released immediately. */
|
|
52
52
|
getChartCount: () => number;
|
|
53
53
|
};
|
|
54
|
-
export declare const version = "1.0.
|
|
54
|
+
export declare const version = "1.0.6";
|
|
55
55
|
export declare class Dashboard {
|
|
56
56
|
readonly root: HTMLDivElement;
|
|
57
57
|
private cells;
|
package/dist/types/mesh3d.d.ts
CHANGED
|
@@ -115,6 +115,7 @@ export declare class MeshSeries3D extends Series3DBase {
|
|
|
115
115
|
protected dirty: DirtyRange[];
|
|
116
116
|
protected styleDirty: boolean;
|
|
117
117
|
private compiled?;
|
|
118
|
+
private wireTopology?;
|
|
118
119
|
private boundsCache?;
|
|
119
120
|
setGeometry(input: MeshGeometry3D): this;
|
|
120
121
|
setData(input: MeshGeometry3D | readonly MeshVertex3D[]): this;
|
package/docs/npm-usage.md
CHANGED