@niivue/niivue 0.43.4 → 0.43.5
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/build/index.d.ts +2 -0
- package/build/index.js +38 -19
- package/build/index.js.map +1 -1
- package/build/index.min.js +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +38 -19
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +1 -1
- package/dist/niivue.umd.js +23 -23
- package/package.json +1 -1
- package/src/niivue/index.ts +9 -2
- package/src/nvmesh.ts +31 -0
- package/src/shader.ts +0 -22
package/build/index.d.ts
CHANGED
|
@@ -1176,6 +1176,7 @@ declare class NVMesh {
|
|
|
1176
1176
|
createFiberDensityMap(): void;
|
|
1177
1177
|
updateFibers(gl: WebGL2RenderingContext): void;
|
|
1178
1178
|
indexNearestXYZmm(Xmm: number, Ymm: number, Zmm: number): number[];
|
|
1179
|
+
unloadMesh(gl: WebGL2RenderingContext): void;
|
|
1179
1180
|
updateMesh(gl: WebGL2RenderingContext): void;
|
|
1180
1181
|
reverseFaces(gl: WebGL2RenderingContext): void;
|
|
1181
1182
|
setLayerProperty(id: number, key: keyof NVMeshLayer, val: number | string | boolean, gl: WebGL2RenderingContext): void;
|
|
@@ -1686,6 +1687,7 @@ declare class Niivue {
|
|
|
1686
1687
|
private resizeObserver;
|
|
1687
1688
|
syncOpts: Record<string, unknown>;
|
|
1688
1689
|
readyForSync: boolean;
|
|
1690
|
+
centerMosaic: boolean;
|
|
1689
1691
|
uiData: UIData;
|
|
1690
1692
|
back: NVImage | null;
|
|
1691
1693
|
overlays: NVImage[];
|
package/build/index.js
CHANGED
|
@@ -13,7 +13,7 @@ var __publicField = (obj, key, value) => {
|
|
|
13
13
|
import { mat4 as mat46, vec2, vec3 as vec311, vec4 as vec48 } from "gl-matrix";
|
|
14
14
|
|
|
15
15
|
// package.json
|
|
16
|
-
var version = "0.43.
|
|
16
|
+
var version = "0.43.5";
|
|
17
17
|
|
|
18
18
|
// src/logger.ts
|
|
19
19
|
var _Log = class _Log {
|
|
@@ -76,29 +76,12 @@ var log = new Log({ name: "niivue", level: "info" });
|
|
|
76
76
|
// src/shader.ts
|
|
77
77
|
var compileShader = function(gl, vert, frag) {
|
|
78
78
|
const vs = gl.createShader(gl.VERTEX_SHADER);
|
|
79
|
-
if (vs === null) {
|
|
80
|
-
throw new Error("could not create vertex shader");
|
|
81
|
-
}
|
|
82
79
|
gl.shaderSource(vs, vert);
|
|
83
80
|
gl.compileShader(vs);
|
|
84
|
-
if (!gl.getShaderParameter(vs, gl.COMPILE_STATUS)) {
|
|
85
|
-
log.error(gl.getShaderInfoLog(vs));
|
|
86
|
-
throw new Error("Vertex shader failed to compile, see console for log");
|
|
87
|
-
}
|
|
88
81
|
const fs = gl.createShader(gl.FRAGMENT_SHADER);
|
|
89
|
-
if (fs === null) {
|
|
90
|
-
throw new Error("could not create fragment shader");
|
|
91
|
-
}
|
|
92
82
|
gl.shaderSource(fs, frag);
|
|
93
83
|
gl.compileShader(fs);
|
|
94
|
-
if (!gl.getShaderParameter(fs, gl.COMPILE_STATUS)) {
|
|
95
|
-
log.error(gl.getShaderInfoLog(fs));
|
|
96
|
-
throw new Error("Fragment shader failed to compile, see console for log");
|
|
97
|
-
}
|
|
98
84
|
const program = gl.createProgram();
|
|
99
|
-
if (program === null) {
|
|
100
|
-
throw new Error("could not create GL program");
|
|
101
|
-
}
|
|
102
85
|
gl.attachShader(program, vs);
|
|
103
86
|
gl.attachShader(program, fs);
|
|
104
87
|
gl.linkProgram(program);
|
|
@@ -15649,6 +15632,34 @@ var NVMesh2 = class _NVMesh {
|
|
|
15649
15632
|
return [mnIdx, mnDx];
|
|
15650
15633
|
}
|
|
15651
15634
|
// indexNearestXYZmm()
|
|
15635
|
+
// internal function discards GPU resources
|
|
15636
|
+
unloadMesh(gl) {
|
|
15637
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, null);
|
|
15638
|
+
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, null);
|
|
15639
|
+
gl.bindVertexArray(null);
|
|
15640
|
+
gl.deleteBuffer(this.vertexBuffer);
|
|
15641
|
+
gl.deleteBuffer(this.indexBuffer);
|
|
15642
|
+
gl.deleteVertexArray(this.vao);
|
|
15643
|
+
gl.deleteVertexArray(this.vaoFiber);
|
|
15644
|
+
this.offsetPt0 = null;
|
|
15645
|
+
this.tris = null;
|
|
15646
|
+
this.pts = null;
|
|
15647
|
+
if (this.layers && this.layers.length > 0) {
|
|
15648
|
+
for (let i = 0; i < this.layers.length; i++) {
|
|
15649
|
+
this.layers[i].values = null;
|
|
15650
|
+
}
|
|
15651
|
+
}
|
|
15652
|
+
if (this.dpg && this.dpg.length > 0) {
|
|
15653
|
+
for (let i = 0; i < this.dpg.length; i++) {
|
|
15654
|
+
this.dpg[i].vals = null;
|
|
15655
|
+
}
|
|
15656
|
+
}
|
|
15657
|
+
if (this.dps && this.dps.length > 0) {
|
|
15658
|
+
for (let i = 0; i < this.dps.length; i++) {
|
|
15659
|
+
this.dps[i].vals = null;
|
|
15660
|
+
}
|
|
15661
|
+
}
|
|
15662
|
+
}
|
|
15652
15663
|
// internal function filters mesh to identify which color of triangulated mesh vertices
|
|
15653
15664
|
updateMesh(gl) {
|
|
15654
15665
|
if (this.offsetPt0) {
|
|
@@ -23768,6 +23779,7 @@ var Niivue = class _Niivue {
|
|
|
23768
23779
|
__publicField(this, "resizeObserver", null);
|
|
23769
23780
|
__publicField(this, "syncOpts", {});
|
|
23770
23781
|
__publicField(this, "readyForSync", false);
|
|
23782
|
+
__publicField(this, "centerMosaic", false);
|
|
23771
23783
|
// UI Data
|
|
23772
23784
|
__publicField(this, "uiData", {
|
|
23773
23785
|
mousedown: false,
|
|
@@ -26051,6 +26063,7 @@ var Niivue = class _Niivue {
|
|
|
26051
26063
|
* @see {@link https://niivue.github.io/niivue/features/multiuser.meshes.html | live demo usage}
|
|
26052
26064
|
*/
|
|
26053
26065
|
removeMesh(mesh) {
|
|
26066
|
+
mesh.unloadMesh(this.gl);
|
|
26054
26067
|
this.setMesh(mesh, -1);
|
|
26055
26068
|
if (this.mediaUrlMap.has(mesh)) {
|
|
26056
26069
|
const url = this.mediaUrlMap.get(mesh);
|
|
@@ -32128,6 +32141,8 @@ var Niivue = class _Niivue {
|
|
|
32128
32141
|
const items = mosaicStr.split(/\s+/);
|
|
32129
32142
|
let scale = 1;
|
|
32130
32143
|
const labelSize = this.opts.textHeight;
|
|
32144
|
+
let marginLeft = 0;
|
|
32145
|
+
let marginTop = 0;
|
|
32131
32146
|
for (let pass = 0; pass < 2; pass++) {
|
|
32132
32147
|
let isRender = false;
|
|
32133
32148
|
let isCrossLines = false;
|
|
@@ -32203,7 +32218,7 @@ var Niivue = class _Niivue {
|
|
|
32203
32218
|
}
|
|
32204
32219
|
}
|
|
32205
32220
|
} else {
|
|
32206
|
-
const ltwh = [scale * left, scale * top, scale * w, scale * h];
|
|
32221
|
+
const ltwh = [marginLeft + scale * left, marginTop + scale * top, scale * w, scale * h];
|
|
32207
32222
|
this.opts.textHeight = isLabel ? labelSize : 0;
|
|
32208
32223
|
if (isRender) {
|
|
32209
32224
|
let inf = sliceMM < 0 ? -Infinity : Infinity;
|
|
@@ -32231,6 +32246,10 @@ var Niivue = class _Niivue {
|
|
|
32231
32246
|
const scaleW = this.gl.canvas.width / mxRowWid;
|
|
32232
32247
|
const scaleH = this.effectiveCanvasHeight() / top;
|
|
32233
32248
|
scale = Math.min(scaleW, scaleH);
|
|
32249
|
+
if (this.centerMosaic) {
|
|
32250
|
+
marginLeft = Math.floor(0.5 * (this.gl.canvas.width - mxRowWid * scale));
|
|
32251
|
+
marginTop = Math.floor(0.5 * (this.effectiveCanvasHeight() - top * scale));
|
|
32252
|
+
}
|
|
32234
32253
|
}
|
|
32235
32254
|
this.opts.textHeight = labelSize;
|
|
32236
32255
|
}
|