@niivue/niivue 0.17.0 → 0.18.0
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 +1 -1
- package/dist/niivue.es.js +32 -9
- package/dist/niivue.umd.js +19 -13
- package/package.json +1 -1
- package/src/niivue.js +27 -0
- package/src/shader-srcs.js +11 -5
package/README.md
CHANGED
|
@@ -38,7 +38,7 @@ We host many NiiVue examples via github pages. These are updated and deployed au
|
|
|
38
38
|
|
|
39
39
|
## existing html page
|
|
40
40
|
```html
|
|
41
|
-
<script src="https://unpkg.com/@niivue/niivue@0.
|
|
41
|
+
<script src="https://unpkg.com/@niivue/niivue@0.18.0/dist/niivue.umd.js"></script>
|
|
42
42
|
|
|
43
43
|
<canvas id="gl" height=480 width=640></canvas>
|
|
44
44
|
|
package/dist/niivue.es.js
CHANGED
|
@@ -714,16 +714,22 @@ var fragSliceShader = `#version 300 es
|
|
|
714
714
|
precision highp int;
|
|
715
715
|
precision highp float;
|
|
716
716
|
uniform highp sampler3D volume, overlay;
|
|
717
|
+
uniform float overlays;
|
|
717
718
|
uniform float opacity;
|
|
718
719
|
in vec3 texPos;
|
|
719
720
|
out vec4 color;
|
|
720
721
|
void main() {
|
|
721
722
|
color = vec4(texture(volume, texPos).rgb, opacity);
|
|
722
|
-
vec4 ocolor =
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
723
|
+
vec4 ocolor = vec4(0.0);
|
|
724
|
+
if (overlays < 1.0) {
|
|
725
|
+
ocolor = vec4(0.0, 0.0, 0.0, 0.0);
|
|
726
|
+
} else {
|
|
727
|
+
ocolor = texture(overlay, texPos);
|
|
728
|
+
}
|
|
729
|
+
float aout = ocolor.a + (1.0 - ocolor.a) * color.a;
|
|
730
|
+
if (aout <= 0.0) return;
|
|
731
|
+
color.rgb = ((ocolor.rgb * ocolor.a) + (color.rgb * color.a * (1.0 - ocolor.a))) / aout;
|
|
732
|
+
color.a = aout;
|
|
727
733
|
}`;
|
|
728
734
|
var fragLineShader = `#version 300 es
|
|
729
735
|
#line 189
|
|
@@ -12854,22 +12860,37 @@ Niivue.prototype.getOverlayIndexByID = function(id) {
|
|
|
12854
12860
|
return -1;
|
|
12855
12861
|
};
|
|
12856
12862
|
Niivue.prototype.setVolume = function(volume, toIndex = 0) {
|
|
12863
|
+
this.volumes.map((v) => {
|
|
12864
|
+
log.debug(v.name);
|
|
12865
|
+
});
|
|
12857
12866
|
let numberOfLoadedImages = this.volumes.length;
|
|
12858
12867
|
if (toIndex > numberOfLoadedImages) {
|
|
12859
12868
|
return;
|
|
12860
12869
|
}
|
|
12861
|
-
|
|
12862
|
-
if (volIndex >= 0) {
|
|
12863
|
-
this.volumes.splice(volIndex, 1);
|
|
12864
|
-
}
|
|
12870
|
+
this.getVolumeIndexByID(volume.id);
|
|
12865
12871
|
if (toIndex === 0) {
|
|
12866
12872
|
this.volumes.unshift(volume);
|
|
12867
12873
|
this.back = this.volumes[0];
|
|
12874
|
+
this.overlays = this.volumes.slice(1);
|
|
12875
|
+
} else if (toIndex < 0) {
|
|
12876
|
+
this.volumes.splice(this.getVolumeIndexByID(volume.id), 1);
|
|
12877
|
+
this.back = this.volumes[0];
|
|
12878
|
+
if (this.volumes.length > 1) {
|
|
12879
|
+
this.overlays = this.volumes.slice(1);
|
|
12880
|
+
} else {
|
|
12881
|
+
this.overlays = [];
|
|
12882
|
+
}
|
|
12868
12883
|
} else {
|
|
12869
12884
|
this.volumes.splice(toIndex, 0, volume);
|
|
12870
12885
|
this.overlays = this.volumes.slice(1);
|
|
12871
12886
|
}
|
|
12872
12887
|
this.updateGLVolume();
|
|
12888
|
+
this.volumes.map((v) => {
|
|
12889
|
+
log.debug(v.name);
|
|
12890
|
+
});
|
|
12891
|
+
};
|
|
12892
|
+
Niivue.prototype.removeVolume = function(volume) {
|
|
12893
|
+
this.setVolume(volume, -1);
|
|
12873
12894
|
};
|
|
12874
12895
|
Niivue.prototype.moveVolumeToBottom = function(volume) {
|
|
12875
12896
|
this.setVolume(volume, 0);
|
|
@@ -13398,6 +13419,8 @@ Niivue.prototype.refreshLayers = function(overlayItem, layer, numLayers) {
|
|
|
13398
13419
|
this.gl.deleteTexture(blendTexture);
|
|
13399
13420
|
this.gl.viewport(0, 0, this.gl.canvas.width, this.gl.canvas.height);
|
|
13400
13421
|
this.gl.deleteFramebuffer(fb);
|
|
13422
|
+
this.sliceShader.use(this.gl);
|
|
13423
|
+
this.gl.uniform1f(this.sliceShader.uniforms["overlays"], this.overlays);
|
|
13401
13424
|
this.renderShader.use(this.gl);
|
|
13402
13425
|
let slicescl = this.sliceScale();
|
|
13403
13426
|
let vox = slicescl.vox;
|