@niivue/niivue 0.12.0 → 0.12.4
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 +5 -1
- package/dist/niivue.es.js +36 -17
- package/dist/niivue.umd.js +9 -9
- package/package.json +7 -5
- package/src/index.html +2 -1
- package/src/niivue.js +322 -60
- package/src/nvimage.js +87 -6
package/README.md
CHANGED
|
@@ -4,6 +4,10 @@ NiiVue is a WebGL 2.0 medical image viewer. This repository contains the **core
|
|
|
4
4
|
|
|
5
5
|
The NiiVue package is intented to be used by individuals developing interactive web pages related to showing [nifti](https://nifti.nimh.nih.gov) images. NiiVue includes many mouse and keyboard interactions that enable browsing and manipulating images displayed in the canvas. This core package does not include a comprehensive user interface outside of the canvas (e.g. buttons, and other widgets). However, developers who wish to build custom user interfaces around the NiiVue canvas can manipulate the rendered images and change settings via the API. Our [web-based user interface implementation](https://github.com/niivue/niivue-ui) (under development) will demonstrate how to integrate NiiVue into a more comprehensive [VueJS](https://vuejs.org/) UI.
|
|
6
6
|
|
|
7
|
+
# Getting started Docs and References
|
|
8
|
+
|
|
9
|
+
[click here to go to the docs web page](https://niivue.github.io/niivue/devdocs/)
|
|
10
|
+
|
|
7
11
|
# Active Projects
|
|
8
12
|
|
|
9
13
|
[See our active projects here](https://github.com/orgs/niivue/projects)
|
|
@@ -34,7 +38,7 @@ We host many NiiVue examples via github pages. These are updated and deployed au
|
|
|
34
38
|
|
|
35
39
|
## existing html page
|
|
36
40
|
```html
|
|
37
|
-
<script src="https://unpkg.com/@niivue/niivue@0.12.
|
|
41
|
+
<script src="https://unpkg.com/@niivue/niivue@0.12.4/dist/niivue.umd.js"></script>
|
|
38
42
|
|
|
39
43
|
<canvas id="gl" height=480 width=640></canvas>
|
|
40
44
|
|
package/dist/niivue.es.js
CHANGED
|
@@ -12283,7 +12283,7 @@ var defaultFontMetrics = {
|
|
|
12283
12283
|
glyphs,
|
|
12284
12284
|
kerning
|
|
12285
12285
|
};
|
|
12286
|
-
const Niivue = function(
|
|
12286
|
+
const Niivue = function(options = {}) {
|
|
12287
12287
|
this.opts = {};
|
|
12288
12288
|
this.defaults = {
|
|
12289
12289
|
textHeight: 0.03,
|
|
@@ -12294,12 +12294,11 @@ const Niivue = function(opts = {}) {
|
|
|
12294
12294
|
selectionBoxColor: [1, 1, 1, 0.5],
|
|
12295
12295
|
clipPlaneColor: [1, 1, 1, 0.5],
|
|
12296
12296
|
colorBarMargin: 0.05,
|
|
12297
|
-
briStep: 1,
|
|
12298
|
-
conStep: 1,
|
|
12299
12297
|
trustCalMinMax: true,
|
|
12300
12298
|
clipPlaneHotKey: "KeyC",
|
|
12301
12299
|
viewModeHotKey: "KeyV",
|
|
12302
|
-
keyDebounceTime: 50
|
|
12300
|
+
keyDebounceTime: 50,
|
|
12301
|
+
isRadiologicalConvention: false
|
|
12303
12302
|
};
|
|
12304
12303
|
this.canvas = null;
|
|
12305
12304
|
this.gl = null;
|
|
@@ -12347,7 +12346,6 @@ const Niivue = function(opts = {}) {
|
|
|
12347
12346
|
this.volumes = [];
|
|
12348
12347
|
this.backTexture = [];
|
|
12349
12348
|
this.objectsToRender3D = [];
|
|
12350
|
-
this.isRadiologicalConvention = false;
|
|
12351
12349
|
this.volScaleMultiplier = 1;
|
|
12352
12350
|
this.volScale = [];
|
|
12353
12351
|
this.vox = [];
|
|
@@ -12369,6 +12367,8 @@ const Niivue = function(opts = {}) {
|
|
|
12369
12367
|
this.clipPlaneObject3D = null;
|
|
12370
12368
|
this.intensityRange$ = new Subject();
|
|
12371
12369
|
this.scene.location$ = new Subject();
|
|
12370
|
+
this.scene.loading$ = new Subject();
|
|
12371
|
+
this.loadingText = "drag and drop to start";
|
|
12372
12372
|
this.currentClipPlaneIndex = 0;
|
|
12373
12373
|
this.lastCalled = new Date().getTime();
|
|
12374
12374
|
this.multiTouchGesture = false;
|
|
@@ -12379,10 +12379,11 @@ const Niivue = function(opts = {}) {
|
|
|
12379
12379
|
this.DISTANCE_FROM_CAMERA = -0.54;
|
|
12380
12380
|
this.initialized = false;
|
|
12381
12381
|
for (let prop in this.defaults) {
|
|
12382
|
-
this.opts[prop] =
|
|
12382
|
+
this.opts[prop] = options[prop] === void 0 ? this.defaults[prop] : options[prop];
|
|
12383
12383
|
}
|
|
12384
12384
|
this.eventsToSubjects = {
|
|
12385
|
-
location: this.scene.location
|
|
12385
|
+
location: this.scene.location$,
|
|
12386
|
+
loading: this.scene.loading$
|
|
12386
12387
|
};
|
|
12387
12388
|
this.subscriptions = [];
|
|
12388
12389
|
};
|
|
@@ -12733,6 +12734,12 @@ Niivue.prototype.dropListener = async function(e) {
|
|
|
12733
12734
|
}
|
|
12734
12735
|
}
|
|
12735
12736
|
};
|
|
12737
|
+
Niivue.prototype.setRadiologicalConvention = function(isRadiologicalConvention) {
|
|
12738
|
+
this.opts.isRadiologicalConvention = isRadiologicalConvention;
|
|
12739
|
+
};
|
|
12740
|
+
Niivue.prototype.getRadiologicalConvention = function() {
|
|
12741
|
+
return this.opts.isRadiologicalConvention;
|
|
12742
|
+
};
|
|
12736
12743
|
Niivue.prototype.addVolume = function(volume) {
|
|
12737
12744
|
if (this.volumes.length > 1) {
|
|
12738
12745
|
this.overlays.push(volume);
|
|
@@ -12823,11 +12830,11 @@ Niivue.prototype.sph2cartDeg = function sph2cartDeg(azimuth, elevation) {
|
|
|
12823
12830
|
ret[2] /= len;
|
|
12824
12831
|
return ret;
|
|
12825
12832
|
};
|
|
12826
|
-
Niivue.prototype.clipPlaneUpdate = function(
|
|
12833
|
+
Niivue.prototype.clipPlaneUpdate = function(azimuthElevation) {
|
|
12827
12834
|
if (this.sliceType != this.sliceTypeRender)
|
|
12828
12835
|
return;
|
|
12829
|
-
let v = this.sph2cartDeg(
|
|
12830
|
-
this.scene.clipPlane = [v[0], v[1], v[2],
|
|
12836
|
+
let v = this.sph2cartDeg(azimuthElevation[0], azimuthElevation[1]);
|
|
12837
|
+
this.scene.clipPlane = [v[0], v[1], v[2], azimuthElevation[2]];
|
|
12831
12838
|
this.drawScene();
|
|
12832
12839
|
};
|
|
12833
12840
|
Niivue.prototype.setCrosshairColor = function(color) {
|
|
@@ -12860,6 +12867,7 @@ Niivue.prototype.setScale = function(scale2) {
|
|
|
12860
12867
|
};
|
|
12861
12868
|
Niivue.prototype.setClipPlaneColor = function(color) {
|
|
12862
12869
|
this.opts.clipPlaneColor = color;
|
|
12870
|
+
this.drawScene();
|
|
12863
12871
|
};
|
|
12864
12872
|
Niivue.prototype.overlayRGBA = function(volume) {
|
|
12865
12873
|
let hdr = volume.hdr;
|
|
@@ -12901,14 +12909,24 @@ Niivue.prototype.cloneVolume = function(index) {
|
|
|
12901
12909
|
return this.volumes[index].clone();
|
|
12902
12910
|
};
|
|
12903
12911
|
Niivue.prototype.loadVolumes = async function(volumeList) {
|
|
12912
|
+
this.on("loading", (isLoading) => {
|
|
12913
|
+
if (isLoading) {
|
|
12914
|
+
this.loadingText = "loading...";
|
|
12915
|
+
this.drawScene();
|
|
12916
|
+
} else {
|
|
12917
|
+
this.loadingText = "drag and drop to start";
|
|
12918
|
+
}
|
|
12919
|
+
});
|
|
12904
12920
|
if (!this.initialized) {
|
|
12905
12921
|
await this.init();
|
|
12906
12922
|
}
|
|
12907
12923
|
this.volumes = [];
|
|
12908
12924
|
this.gl.clearColor(0, 0, 0, 1);
|
|
12909
12925
|
this.gl.clear(this.gl.COLOR_BUFFER_BIT);
|
|
12926
|
+
this.scene.loading$.next(true);
|
|
12910
12927
|
for (let i = 0; i < volumeList.length; i++) {
|
|
12911
12928
|
let volume = await NVImage.loadFromUrl(volumeList[i].url, volumeList[i].name, volumeList[i].colorMap, volumeList[i].opacity, this.opts.trustCalMinMax);
|
|
12929
|
+
this.scene.loading$.next(false);
|
|
12912
12930
|
this.volumes.push(volume);
|
|
12913
12931
|
if (i === 0) {
|
|
12914
12932
|
this.back = volume;
|
|
@@ -13014,7 +13032,7 @@ Niivue.prototype.initText = async function() {
|
|
|
13014
13032
|
this.fontShader = new Shader(this.gl, vertFontShader, fragFontShader);
|
|
13015
13033
|
this.fontShader.use(this.gl);
|
|
13016
13034
|
await this.loadDefaultFont();
|
|
13017
|
-
this.drawLoadingText(
|
|
13035
|
+
this.drawLoadingText(this.loadingText);
|
|
13018
13036
|
};
|
|
13019
13037
|
Niivue.prototype.init = async function() {
|
|
13020
13038
|
this.gl.enable(this.gl.CULL_FACE);
|
|
@@ -13309,6 +13327,11 @@ Niivue.prototype.colorMaps = function(sort = true) {
|
|
|
13309
13327
|
}
|
|
13310
13328
|
return sort === true ? cm.sort() : cm;
|
|
13311
13329
|
};
|
|
13330
|
+
Niivue.prototype.setColorMap = function(id, colorMap) {
|
|
13331
|
+
let idx = this.getVolumeIndexByID(id);
|
|
13332
|
+
this.volumes[idx].colorMap = colorMap;
|
|
13333
|
+
this.updateGLVolume();
|
|
13334
|
+
};
|
|
13312
13335
|
Niivue.prototype.colormapFromKey = function(name) {
|
|
13313
13336
|
let availMaps = this.colorMaps();
|
|
13314
13337
|
for (let i = 0; i < availMaps.length; i++) {
|
|
@@ -13572,7 +13595,7 @@ Niivue.prototype.draw2D = function(leftTopWidthHeight, axCorSag) {
|
|
|
13572
13595
|
this.scene.crosshairPos[2],
|
|
13573
13596
|
this.scene.crosshairPos[0]
|
|
13574
13597
|
];
|
|
13575
|
-
let isMirrorLR = this.isRadiologicalConvention && axCorSag < this.sliceTypeSagittal;
|
|
13598
|
+
let isMirrorLR = this.opts.isRadiologicalConvention && axCorSag < this.sliceTypeSagittal;
|
|
13576
13599
|
this.sliceShader.use(this.gl);
|
|
13577
13600
|
this.gl.uniform1f(this.sliceShader.uniforms["opacity"], this.backOpacity);
|
|
13578
13601
|
this.gl.uniform1i(this.sliceShader.uniforms["axCorSag"], axCorSag);
|
|
@@ -13866,11 +13889,7 @@ Niivue.prototype.drawScene = function() {
|
|
|
13866
13889
|
this.gl.clear(this.gl.COLOR_BUFFER_BIT);
|
|
13867
13890
|
let posString = "";
|
|
13868
13891
|
if (!this.back.dims) {
|
|
13869
|
-
|
|
13870
|
-
this.drawLoadingText("loading");
|
|
13871
|
-
} else {
|
|
13872
|
-
this.drawLoadingText("drag and drop a file to start");
|
|
13873
|
-
}
|
|
13892
|
+
this.drawLoadingText(this.loadingText);
|
|
13874
13893
|
return;
|
|
13875
13894
|
}
|
|
13876
13895
|
if (this.sliceType === this.sliceTypeRender)
|