@niivue/niivue 0.26.3 → 0.27.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/dist/niivue.es.js +1361 -125
- package/dist/niivue.umd.js +83 -61
- package/package.json +2 -2
- package/src/indexMM.html +1 -1
- package/src/indexOrient.html +206 -0
- package/src/niivue.js +392 -153
- package/src/orientCube.js +64 -0
- package/src/shader-srcs.js +52 -41
package/dist/niivue.es.js
CHANGED
|
@@ -364,6 +364,26 @@ function translate(out, a, v) {
|
|
|
364
364
|
}
|
|
365
365
|
return out;
|
|
366
366
|
}
|
|
367
|
+
function scale$1(out, a, v) {
|
|
368
|
+
var x2 = v[0], y = v[1], z = v[2];
|
|
369
|
+
out[0] = a[0] * x2;
|
|
370
|
+
out[1] = a[1] * x2;
|
|
371
|
+
out[2] = a[2] * x2;
|
|
372
|
+
out[3] = a[3] * x2;
|
|
373
|
+
out[4] = a[4] * y;
|
|
374
|
+
out[5] = a[5] * y;
|
|
375
|
+
out[6] = a[6] * y;
|
|
376
|
+
out[7] = a[7] * y;
|
|
377
|
+
out[8] = a[8] * z;
|
|
378
|
+
out[9] = a[9] * z;
|
|
379
|
+
out[10] = a[10] * z;
|
|
380
|
+
out[11] = a[11] * z;
|
|
381
|
+
out[12] = a[12];
|
|
382
|
+
out[13] = a[13];
|
|
383
|
+
out[14] = a[14];
|
|
384
|
+
out[15] = a[15];
|
|
385
|
+
return out;
|
|
386
|
+
}
|
|
367
387
|
function rotateX(out, a, rad) {
|
|
368
388
|
var s = Math.sin(rad);
|
|
369
389
|
var c2 = Math.cos(rad);
|
|
@@ -747,7 +767,20 @@ vec4 applyClip (vec3 dir, inout vec4 samplePos, inout float len, inout bool isCl
|
|
|
747
767
|
samplePos = vec4(samplePos.xyz+dir * disBackFace, disBackFace);
|
|
748
768
|
}
|
|
749
769
|
return samplePos;
|
|
750
|
-
}
|
|
770
|
+
}
|
|
771
|
+
float frac2ndc(vec3 frac) {
|
|
772
|
+
//https://stackoverflow.com/questions/7777913/how-to-render-depth-linearly-in-modern-opengl-with-gl-fragcoord-z-in-fragment-sh
|
|
773
|
+
vec4 pos = vec4(frac.xyz, 1.0); //fraction
|
|
774
|
+
vec4 dim = vec4(vec3(textureSize(volume, 0)), 1.0);
|
|
775
|
+
pos = pos * dim;
|
|
776
|
+
vec4 shim = vec4(-0.5, -0.5, -0.5, 0.0);
|
|
777
|
+
pos += shim;
|
|
778
|
+
vec4 mm = transpose(matRAS) * pos;
|
|
779
|
+
float z_ndc = (mvpMtx * vec4(mm.xyz, 1.0)).z;
|
|
780
|
+
return (z_ndc + 1.0) / 2.0;
|
|
781
|
+
|
|
782
|
+
}
|
|
783
|
+
`;
|
|
751
784
|
var fragRenderShader = `#version 300 es
|
|
752
785
|
#line 14
|
|
753
786
|
precision highp int;
|
|
@@ -765,20 +798,7 @@ uniform mat4 matRAS;
|
|
|
765
798
|
uniform vec4 clipPlaneColor;
|
|
766
799
|
in vec3 vColor;
|
|
767
800
|
out vec4 fColor;
|
|
768
|
-
` + kRenderFunc + `
|
|
769
|
-
float frac2ndc(vec3 frac) {
|
|
770
|
-
//https://stackoverflow.com/questions/7777913/how-to-render-depth-linearly-in-modern-opengl-with-gl-fragcoord-z-in-fragment-sh
|
|
771
|
-
vec4 pos = vec4(frac.xyz, 1.0); //fraction
|
|
772
|
-
vec4 dim = vec4(vec3(textureSize(volume, 0)), 1.0);
|
|
773
|
-
pos = pos * dim;
|
|
774
|
-
vec4 shim = vec4(-0.5, -0.5, -0.5, 0.0);
|
|
775
|
-
pos += shim;
|
|
776
|
-
vec4 mm = transpose(matRAS) * pos;
|
|
777
|
-
float z_ndc = (mvpMtx * vec4(mm.xyz, 1.0)).z;
|
|
778
|
-
return (z_ndc + 1.0) / 2.0;
|
|
779
|
-
|
|
780
|
-
}
|
|
781
|
-
void main() {
|
|
801
|
+
` + kRenderFunc + `void main() {
|
|
782
802
|
if (fColor.x > 2.0) {
|
|
783
803
|
fColor = vec4(1.0, 0.0, 0.0, 0.5);
|
|
784
804
|
return;
|
|
@@ -1529,7 +1549,6 @@ precision highp float;
|
|
|
1529
1549
|
uniform float opacity;
|
|
1530
1550
|
out vec4 color;
|
|
1531
1551
|
vec4 packFloatToVec4i(const float value) {
|
|
1532
|
-
//this Papaya function uses BSD 3-clause license Copyright (c) 2012-2015, RII-UTHSCSA
|
|
1533
1552
|
const vec4 bitSh = vec4(256.0*256.0*256.0, 256.0*256.0, 256.0, 1.0);
|
|
1534
1553
|
const vec4 bitMsk = vec4(0.0, 1.0/256.0, 1.0/256.0, 1.0/256.0);
|
|
1535
1554
|
vec4 res = fract(value * bitSh);
|
|
@@ -1734,15 +1753,6 @@ void main() {
|
|
|
1734
1753
|
vec3 d = vClr.rgb * diffuse * SH(-reflect(n, vec3(l.x, l.y, -l.z)) );
|
|
1735
1754
|
color = vec4(a + d + s, opacity);
|
|
1736
1755
|
}`;
|
|
1737
|
-
var fragDepthPickingShader = `#version 300 es
|
|
1738
|
-
precision highp int;
|
|
1739
|
-
precision highp float;
|
|
1740
|
-
uniform int id;
|
|
1741
|
-
in vec3 vColor;
|
|
1742
|
-
out vec4 color;
|
|
1743
|
-
void main() {
|
|
1744
|
-
color = vec4(vColor, float(id & 255) / 255.0);
|
|
1745
|
-
}`;
|
|
1746
1756
|
var fragVolumePickingShader = `#version 300 es
|
|
1747
1757
|
#line 506
|
|
1748
1758
|
//precision highp int;
|
|
@@ -1753,12 +1763,15 @@ uniform vec3 texVox;
|
|
|
1753
1763
|
uniform vec4 clipPlane;
|
|
1754
1764
|
uniform highp sampler3D volume, overlay;
|
|
1755
1765
|
uniform float overlays;
|
|
1756
|
-
uniform
|
|
1766
|
+
uniform mat4 matRAS;
|
|
1767
|
+
uniform mat4 mvpMtx;
|
|
1757
1768
|
in vec3 vColor;
|
|
1758
1769
|
out vec4 fColor;
|
|
1759
1770
|
` + kRenderFunc + `
|
|
1760
1771
|
void main() {
|
|
1772
|
+
int id = 254;
|
|
1761
1773
|
vec3 start = vColor;
|
|
1774
|
+
gl_FragDepth = 0.0;
|
|
1762
1775
|
fColor = vec4(0.0, 0.0, 0.0, 0.0); //assume no hit: ID = 0
|
|
1763
1776
|
float fid = float(id & 255)/ 255.0;
|
|
1764
1777
|
vec3 backPosition = GetBackPosition(start);
|
|
@@ -1782,6 +1795,7 @@ void main() {
|
|
|
1782
1795
|
float val = texture(volume, samplePos.xyz).a;
|
|
1783
1796
|
if (val > 0.01) {
|
|
1784
1797
|
fColor = vec4(samplePos.rgb, fid);
|
|
1798
|
+
gl_FragDepth = frac2ndc(samplePos.xyz);
|
|
1785
1799
|
break;
|
|
1786
1800
|
}
|
|
1787
1801
|
samplePos += deltaDirFast; //advance ray position
|
|
@@ -1798,6 +1812,7 @@ void main() {
|
|
|
1798
1812
|
float val = texture(overlay, samplePos.xyz).a;
|
|
1799
1813
|
if (val > 0.01) {
|
|
1800
1814
|
fColor = vec4(samplePos.rgb, fid);
|
|
1815
|
+
gl_FragDepth = frac2ndc(samplePos.xyz);
|
|
1801
1816
|
return;
|
|
1802
1817
|
}
|
|
1803
1818
|
samplePos += deltaDirFast; //advance ray position
|
|
@@ -1805,6 +1820,34 @@ void main() {
|
|
|
1805
1820
|
//if (fColor.a == 0.0) discard; //no hit in either background or overlays
|
|
1806
1821
|
//you only get here if there is a hit with the background that is closer than any overlay
|
|
1807
1822
|
}`;
|
|
1823
|
+
var vertOrientCubeShader = `#version 300 es
|
|
1824
|
+
// an attribute is an input (in) to a vertex shader.
|
|
1825
|
+
// It will receive data from a buffer
|
|
1826
|
+
layout(location=0) in vec3 a_position;
|
|
1827
|
+
layout(location=1) in vec3 a_color;
|
|
1828
|
+
// A matrix to transform the positions by
|
|
1829
|
+
uniform mat4 u_matrix;
|
|
1830
|
+
out vec3 vColor;
|
|
1831
|
+
// all shaders have a main function
|
|
1832
|
+
void main() {
|
|
1833
|
+
// Multiply the position by the matrix.
|
|
1834
|
+
vec4 pos = vec4(a_position, 1.0);
|
|
1835
|
+
gl_Position = u_matrix * vec4(pos);
|
|
1836
|
+
vColor = a_color;
|
|
1837
|
+
}
|
|
1838
|
+
`;
|
|
1839
|
+
var fragOrientCubeShader = `#version 300 es
|
|
1840
|
+
precision highp float;
|
|
1841
|
+
|
|
1842
|
+
uniform vec4 u_color;
|
|
1843
|
+
in vec3 vColor;
|
|
1844
|
+
// we need to declare an output for the fragment shader
|
|
1845
|
+
out vec4 outColor;
|
|
1846
|
+
|
|
1847
|
+
void main() {
|
|
1848
|
+
outColor = vec4(vColor, 1.0);
|
|
1849
|
+
}
|
|
1850
|
+
`;
|
|
1808
1851
|
/*! *****************************************************************************
|
|
1809
1852
|
Copyright (c) Microsoft Corporation.
|
|
1810
1853
|
|
|
@@ -2844,6 +2887,1016 @@ function interval(period, scheduler) {
|
|
|
2844
2887
|
}
|
|
2845
2888
|
return timer(period, period, scheduler);
|
|
2846
2889
|
}
|
|
2890
|
+
const orientCube = new Float32Array([
|
|
2891
|
+
-1,
|
|
2892
|
+
-1,
|
|
2893
|
+
-1,
|
|
2894
|
+
0.28,
|
|
2895
|
+
0.28,
|
|
2896
|
+
0.28,
|
|
2897
|
+
-1,
|
|
2898
|
+
-1,
|
|
2899
|
+
-1,
|
|
2900
|
+
0.28,
|
|
2901
|
+
0.28,
|
|
2902
|
+
0.28,
|
|
2903
|
+
-1,
|
|
2904
|
+
1,
|
|
2905
|
+
-1,
|
|
2906
|
+
0.28,
|
|
2907
|
+
0.28,
|
|
2908
|
+
0.28,
|
|
2909
|
+
1,
|
|
2910
|
+
-1,
|
|
2911
|
+
-1,
|
|
2912
|
+
0.28,
|
|
2913
|
+
0.28,
|
|
2914
|
+
0.28,
|
|
2915
|
+
1,
|
|
2916
|
+
1,
|
|
2917
|
+
-1,
|
|
2918
|
+
0.28,
|
|
2919
|
+
0.28,
|
|
2920
|
+
0.28,
|
|
2921
|
+
1,
|
|
2922
|
+
1,
|
|
2923
|
+
-1,
|
|
2924
|
+
0.28,
|
|
2925
|
+
0.28,
|
|
2926
|
+
0.28,
|
|
2927
|
+
-1,
|
|
2928
|
+
-1,
|
|
2929
|
+
1,
|
|
2930
|
+
0.8,
|
|
2931
|
+
0.8,
|
|
2932
|
+
0.8,
|
|
2933
|
+
-1,
|
|
2934
|
+
-1,
|
|
2935
|
+
1,
|
|
2936
|
+
0.8,
|
|
2937
|
+
0.8,
|
|
2938
|
+
0.8,
|
|
2939
|
+
1,
|
|
2940
|
+
-1,
|
|
2941
|
+
1,
|
|
2942
|
+
0.8,
|
|
2943
|
+
0.8,
|
|
2944
|
+
0.8,
|
|
2945
|
+
-1,
|
|
2946
|
+
1,
|
|
2947
|
+
1,
|
|
2948
|
+
0.8,
|
|
2949
|
+
0.8,
|
|
2950
|
+
0.8,
|
|
2951
|
+
1,
|
|
2952
|
+
1,
|
|
2953
|
+
1,
|
|
2954
|
+
0.8,
|
|
2955
|
+
0.8,
|
|
2956
|
+
0.8,
|
|
2957
|
+
1,
|
|
2958
|
+
1,
|
|
2959
|
+
1,
|
|
2960
|
+
0.8,
|
|
2961
|
+
0.8,
|
|
2962
|
+
0.8,
|
|
2963
|
+
-1,
|
|
2964
|
+
1,
|
|
2965
|
+
-1,
|
|
2966
|
+
0,
|
|
2967
|
+
0,
|
|
2968
|
+
0.74,
|
|
2969
|
+
-1,
|
|
2970
|
+
1,
|
|
2971
|
+
-1,
|
|
2972
|
+
0,
|
|
2973
|
+
0,
|
|
2974
|
+
0.74,
|
|
2975
|
+
-1,
|
|
2976
|
+
1,
|
|
2977
|
+
1,
|
|
2978
|
+
0,
|
|
2979
|
+
0,
|
|
2980
|
+
0.74,
|
|
2981
|
+
1,
|
|
2982
|
+
1,
|
|
2983
|
+
-1,
|
|
2984
|
+
0,
|
|
2985
|
+
0,
|
|
2986
|
+
0.74,
|
|
2987
|
+
1,
|
|
2988
|
+
1,
|
|
2989
|
+
1,
|
|
2990
|
+
0,
|
|
2991
|
+
0,
|
|
2992
|
+
0.74,
|
|
2993
|
+
1,
|
|
2994
|
+
1,
|
|
2995
|
+
1,
|
|
2996
|
+
0,
|
|
2997
|
+
0,
|
|
2998
|
+
0.74,
|
|
2999
|
+
-1,
|
|
3000
|
+
-1,
|
|
3001
|
+
-1,
|
|
3002
|
+
0.42,
|
|
3003
|
+
0,
|
|
3004
|
+
0.42,
|
|
3005
|
+
-1,
|
|
3006
|
+
-1,
|
|
3007
|
+
-1,
|
|
3008
|
+
0.42,
|
|
3009
|
+
0,
|
|
3010
|
+
0.42,
|
|
3011
|
+
1,
|
|
3012
|
+
-1,
|
|
3013
|
+
-1,
|
|
3014
|
+
0.42,
|
|
3015
|
+
0,
|
|
3016
|
+
0.42,
|
|
3017
|
+
-1,
|
|
3018
|
+
-1,
|
|
3019
|
+
1,
|
|
3020
|
+
0.42,
|
|
3021
|
+
0,
|
|
3022
|
+
0.42,
|
|
3023
|
+
1,
|
|
3024
|
+
-1,
|
|
3025
|
+
1,
|
|
3026
|
+
0.42,
|
|
3027
|
+
0,
|
|
3028
|
+
0.42,
|
|
3029
|
+
1,
|
|
3030
|
+
-1,
|
|
3031
|
+
1,
|
|
3032
|
+
0.42,
|
|
3033
|
+
0,
|
|
3034
|
+
0.42,
|
|
3035
|
+
-1,
|
|
3036
|
+
-1,
|
|
3037
|
+
-1,
|
|
3038
|
+
0.64,
|
|
3039
|
+
0,
|
|
3040
|
+
0,
|
|
3041
|
+
-1,
|
|
3042
|
+
-1,
|
|
3043
|
+
-1,
|
|
3044
|
+
0.64,
|
|
3045
|
+
0,
|
|
3046
|
+
0,
|
|
3047
|
+
-1,
|
|
3048
|
+
-1,
|
|
3049
|
+
1,
|
|
3050
|
+
0.64,
|
|
3051
|
+
0,
|
|
3052
|
+
0,
|
|
3053
|
+
-1,
|
|
3054
|
+
1,
|
|
3055
|
+
-1,
|
|
3056
|
+
0.64,
|
|
3057
|
+
0,
|
|
3058
|
+
0,
|
|
3059
|
+
-1,
|
|
3060
|
+
1,
|
|
3061
|
+
1,
|
|
3062
|
+
0.64,
|
|
3063
|
+
0,
|
|
3064
|
+
0,
|
|
3065
|
+
-1,
|
|
3066
|
+
1,
|
|
3067
|
+
1,
|
|
3068
|
+
0.64,
|
|
3069
|
+
0,
|
|
3070
|
+
0,
|
|
3071
|
+
1,
|
|
3072
|
+
-1,
|
|
3073
|
+
-1,
|
|
3074
|
+
0,
|
|
3075
|
+
0.5,
|
|
3076
|
+
0,
|
|
3077
|
+
1,
|
|
3078
|
+
-1,
|
|
3079
|
+
-1,
|
|
3080
|
+
0,
|
|
3081
|
+
0.5,
|
|
3082
|
+
0,
|
|
3083
|
+
1,
|
|
3084
|
+
1,
|
|
3085
|
+
-1,
|
|
3086
|
+
0,
|
|
3087
|
+
0.5,
|
|
3088
|
+
0,
|
|
3089
|
+
1,
|
|
3090
|
+
-1,
|
|
3091
|
+
1,
|
|
3092
|
+
0,
|
|
3093
|
+
0.5,
|
|
3094
|
+
0,
|
|
3095
|
+
1,
|
|
3096
|
+
1,
|
|
3097
|
+
1,
|
|
3098
|
+
0,
|
|
3099
|
+
0.5,
|
|
3100
|
+
0,
|
|
3101
|
+
1,
|
|
3102
|
+
1,
|
|
3103
|
+
1,
|
|
3104
|
+
0,
|
|
3105
|
+
0.5,
|
|
3106
|
+
0,
|
|
3107
|
+
-0.45,
|
|
3108
|
+
1,
|
|
3109
|
+
-0.8,
|
|
3110
|
+
0,
|
|
3111
|
+
0,
|
|
3112
|
+
0,
|
|
3113
|
+
-0.45,
|
|
3114
|
+
1,
|
|
3115
|
+
-0.8,
|
|
3116
|
+
0,
|
|
3117
|
+
0,
|
|
3118
|
+
0,
|
|
3119
|
+
-0.45,
|
|
3120
|
+
1,
|
|
3121
|
+
0.8,
|
|
3122
|
+
0,
|
|
3123
|
+
0,
|
|
3124
|
+
0,
|
|
3125
|
+
-0.25,
|
|
3126
|
+
1,
|
|
3127
|
+
-0.8,
|
|
3128
|
+
0,
|
|
3129
|
+
0,
|
|
3130
|
+
0,
|
|
3131
|
+
-0.25,
|
|
3132
|
+
1,
|
|
3133
|
+
0.8,
|
|
3134
|
+
0,
|
|
3135
|
+
0,
|
|
3136
|
+
0,
|
|
3137
|
+
-0.25,
|
|
3138
|
+
1,
|
|
3139
|
+
0.8,
|
|
3140
|
+
0,
|
|
3141
|
+
0,
|
|
3142
|
+
0,
|
|
3143
|
+
-0.25,
|
|
3144
|
+
1,
|
|
3145
|
+
0.6,
|
|
3146
|
+
0,
|
|
3147
|
+
0,
|
|
3148
|
+
0,
|
|
3149
|
+
-0.25,
|
|
3150
|
+
1,
|
|
3151
|
+
0.6,
|
|
3152
|
+
0,
|
|
3153
|
+
0,
|
|
3154
|
+
0,
|
|
3155
|
+
-0.25,
|
|
3156
|
+
1,
|
|
3157
|
+
0.8,
|
|
3158
|
+
0,
|
|
3159
|
+
0,
|
|
3160
|
+
0,
|
|
3161
|
+
0.45,
|
|
3162
|
+
1,
|
|
3163
|
+
0.6,
|
|
3164
|
+
0,
|
|
3165
|
+
0,
|
|
3166
|
+
0,
|
|
3167
|
+
0.25,
|
|
3168
|
+
1,
|
|
3169
|
+
0.8,
|
|
3170
|
+
0,
|
|
3171
|
+
0,
|
|
3172
|
+
0,
|
|
3173
|
+
0.25,
|
|
3174
|
+
1,
|
|
3175
|
+
0.8,
|
|
3176
|
+
0,
|
|
3177
|
+
0,
|
|
3178
|
+
0,
|
|
3179
|
+
0.25,
|
|
3180
|
+
1,
|
|
3181
|
+
0.1,
|
|
3182
|
+
0,
|
|
3183
|
+
0,
|
|
3184
|
+
0,
|
|
3185
|
+
0.25,
|
|
3186
|
+
1,
|
|
3187
|
+
0.1,
|
|
3188
|
+
0,
|
|
3189
|
+
0,
|
|
3190
|
+
0,
|
|
3191
|
+
0.25,
|
|
3192
|
+
1,
|
|
3193
|
+
0.6,
|
|
3194
|
+
0,
|
|
3195
|
+
0,
|
|
3196
|
+
0,
|
|
3197
|
+
0.45,
|
|
3198
|
+
1,
|
|
3199
|
+
0.1,
|
|
3200
|
+
0,
|
|
3201
|
+
0,
|
|
3202
|
+
0,
|
|
3203
|
+
0.45,
|
|
3204
|
+
1,
|
|
3205
|
+
0.6,
|
|
3206
|
+
0,
|
|
3207
|
+
0,
|
|
3208
|
+
0,
|
|
3209
|
+
0.45,
|
|
3210
|
+
1,
|
|
3211
|
+
0.6,
|
|
3212
|
+
0,
|
|
3213
|
+
0,
|
|
3214
|
+
0,
|
|
3215
|
+
-0.25,
|
|
3216
|
+
1,
|
|
3217
|
+
-0.1,
|
|
3218
|
+
0,
|
|
3219
|
+
0,
|
|
3220
|
+
0,
|
|
3221
|
+
-0.25,
|
|
3222
|
+
1,
|
|
3223
|
+
-0.1,
|
|
3224
|
+
0,
|
|
3225
|
+
0,
|
|
3226
|
+
0,
|
|
3227
|
+
-0.25,
|
|
3228
|
+
1,
|
|
3229
|
+
0.1,
|
|
3230
|
+
0,
|
|
3231
|
+
0,
|
|
3232
|
+
0,
|
|
3233
|
+
0.25,
|
|
3234
|
+
1,
|
|
3235
|
+
-0.1,
|
|
3236
|
+
0,
|
|
3237
|
+
0,
|
|
3238
|
+
0,
|
|
3239
|
+
0.45,
|
|
3240
|
+
1,
|
|
3241
|
+
0.1,
|
|
3242
|
+
0,
|
|
3243
|
+
0,
|
|
3244
|
+
0,
|
|
3245
|
+
0.45,
|
|
3246
|
+
1,
|
|
3247
|
+
0.1,
|
|
3248
|
+
0,
|
|
3249
|
+
0,
|
|
3250
|
+
0,
|
|
3251
|
+
0.45,
|
|
3252
|
+
-1,
|
|
3253
|
+
-0.8,
|
|
3254
|
+
0,
|
|
3255
|
+
0,
|
|
3256
|
+
0,
|
|
3257
|
+
0.45,
|
|
3258
|
+
-1,
|
|
3259
|
+
-0.8,
|
|
3260
|
+
0,
|
|
3261
|
+
0,
|
|
3262
|
+
0,
|
|
3263
|
+
0.05,
|
|
3264
|
+
-1,
|
|
3265
|
+
0.8,
|
|
3266
|
+
0,
|
|
3267
|
+
0,
|
|
3268
|
+
0,
|
|
3269
|
+
0.25,
|
|
3270
|
+
-1,
|
|
3271
|
+
-0.8,
|
|
3272
|
+
0,
|
|
3273
|
+
0,
|
|
3274
|
+
0,
|
|
3275
|
+
-0.15,
|
|
3276
|
+
-1,
|
|
3277
|
+
0.8,
|
|
3278
|
+
0,
|
|
3279
|
+
0,
|
|
3280
|
+
0,
|
|
3281
|
+
-0.15,
|
|
3282
|
+
-1,
|
|
3283
|
+
0.8,
|
|
3284
|
+
0,
|
|
3285
|
+
0,
|
|
3286
|
+
0,
|
|
3287
|
+
-0.25,
|
|
3288
|
+
-1,
|
|
3289
|
+
-0.8,
|
|
3290
|
+
0,
|
|
3291
|
+
0,
|
|
3292
|
+
0,
|
|
3293
|
+
-0.25,
|
|
3294
|
+
-1,
|
|
3295
|
+
-0.8,
|
|
3296
|
+
0,
|
|
3297
|
+
0,
|
|
3298
|
+
0,
|
|
3299
|
+
0.05,
|
|
3300
|
+
-1,
|
|
3301
|
+
0.8,
|
|
3302
|
+
0,
|
|
3303
|
+
0,
|
|
3304
|
+
0,
|
|
3305
|
+
-0.45,
|
|
3306
|
+
-1,
|
|
3307
|
+
-0.8,
|
|
3308
|
+
0,
|
|
3309
|
+
0,
|
|
3310
|
+
0,
|
|
3311
|
+
-0.15,
|
|
3312
|
+
-1,
|
|
3313
|
+
0.8,
|
|
3314
|
+
0,
|
|
3315
|
+
0,
|
|
3316
|
+
0,
|
|
3317
|
+
-0.15,
|
|
3318
|
+
-1,
|
|
3319
|
+
0.8,
|
|
3320
|
+
0,
|
|
3321
|
+
0,
|
|
3322
|
+
0,
|
|
3323
|
+
0.13,
|
|
3324
|
+
-1,
|
|
3325
|
+
-0.3,
|
|
3326
|
+
0,
|
|
3327
|
+
0,
|
|
3328
|
+
0,
|
|
3329
|
+
0.13,
|
|
3330
|
+
-1,
|
|
3331
|
+
-0.3,
|
|
3332
|
+
0,
|
|
3333
|
+
0,
|
|
3334
|
+
0,
|
|
3335
|
+
0.07,
|
|
3336
|
+
-1,
|
|
3337
|
+
-0.1,
|
|
3338
|
+
0,
|
|
3339
|
+
0,
|
|
3340
|
+
0,
|
|
3341
|
+
-0.33,
|
|
3342
|
+
-1,
|
|
3343
|
+
-0.3,
|
|
3344
|
+
0,
|
|
3345
|
+
0,
|
|
3346
|
+
0,
|
|
3347
|
+
-0.27,
|
|
3348
|
+
-1,
|
|
3349
|
+
-0.1,
|
|
3350
|
+
0,
|
|
3351
|
+
0,
|
|
3352
|
+
0,
|
|
3353
|
+
-0.27,
|
|
3354
|
+
-1,
|
|
3355
|
+
-0.1,
|
|
3356
|
+
0,
|
|
3357
|
+
0,
|
|
3358
|
+
0,
|
|
3359
|
+
-0.45,
|
|
3360
|
+
0.6,
|
|
3361
|
+
1,
|
|
3362
|
+
0,
|
|
3363
|
+
0,
|
|
3364
|
+
0,
|
|
3365
|
+
-0.45,
|
|
3366
|
+
0.6,
|
|
3367
|
+
1,
|
|
3368
|
+
0,
|
|
3369
|
+
0,
|
|
3370
|
+
0,
|
|
3371
|
+
-0.45,
|
|
3372
|
+
0.4,
|
|
3373
|
+
1,
|
|
3374
|
+
0,
|
|
3375
|
+
0,
|
|
3376
|
+
0,
|
|
3377
|
+
-0.25,
|
|
3378
|
+
0.8,
|
|
3379
|
+
1,
|
|
3380
|
+
0,
|
|
3381
|
+
0,
|
|
3382
|
+
0,
|
|
3383
|
+
-0.25,
|
|
3384
|
+
0.4,
|
|
3385
|
+
1,
|
|
3386
|
+
0,
|
|
3387
|
+
0,
|
|
3388
|
+
0,
|
|
3389
|
+
-0.25,
|
|
3390
|
+
0.4,
|
|
3391
|
+
1,
|
|
3392
|
+
0,
|
|
3393
|
+
0,
|
|
3394
|
+
0,
|
|
3395
|
+
-0.25,
|
|
3396
|
+
0.8,
|
|
3397
|
+
1,
|
|
3398
|
+
0,
|
|
3399
|
+
0,
|
|
3400
|
+
0,
|
|
3401
|
+
-0.25,
|
|
3402
|
+
0.8,
|
|
3403
|
+
1,
|
|
3404
|
+
0,
|
|
3405
|
+
0,
|
|
3406
|
+
0,
|
|
3407
|
+
-0.25,
|
|
3408
|
+
0.6,
|
|
3409
|
+
1,
|
|
3410
|
+
0,
|
|
3411
|
+
0,
|
|
3412
|
+
0,
|
|
3413
|
+
0.25,
|
|
3414
|
+
0.8,
|
|
3415
|
+
1,
|
|
3416
|
+
0,
|
|
3417
|
+
0,
|
|
3418
|
+
0,
|
|
3419
|
+
0.45,
|
|
3420
|
+
0.6,
|
|
3421
|
+
1,
|
|
3422
|
+
0,
|
|
3423
|
+
0,
|
|
3424
|
+
0,
|
|
3425
|
+
0.45,
|
|
3426
|
+
0.6,
|
|
3427
|
+
1,
|
|
3428
|
+
0,
|
|
3429
|
+
0,
|
|
3430
|
+
0,
|
|
3431
|
+
0.25,
|
|
3432
|
+
0.8,
|
|
3433
|
+
1,
|
|
3434
|
+
0,
|
|
3435
|
+
0,
|
|
3436
|
+
0,
|
|
3437
|
+
0.25,
|
|
3438
|
+
0.8,
|
|
3439
|
+
1,
|
|
3440
|
+
0,
|
|
3441
|
+
0,
|
|
3442
|
+
0,
|
|
3443
|
+
0.25,
|
|
3444
|
+
-0.1,
|
|
3445
|
+
1,
|
|
3446
|
+
0,
|
|
3447
|
+
0,
|
|
3448
|
+
0,
|
|
3449
|
+
0.45,
|
|
3450
|
+
0.6,
|
|
3451
|
+
1,
|
|
3452
|
+
0,
|
|
3453
|
+
0,
|
|
3454
|
+
0,
|
|
3455
|
+
0.45,
|
|
3456
|
+
0.1,
|
|
3457
|
+
1,
|
|
3458
|
+
0,
|
|
3459
|
+
0,
|
|
3460
|
+
0,
|
|
3461
|
+
0.45,
|
|
3462
|
+
0.1,
|
|
3463
|
+
1,
|
|
3464
|
+
0,
|
|
3465
|
+
0,
|
|
3466
|
+
0,
|
|
3467
|
+
-0.25,
|
|
3468
|
+
0.1,
|
|
3469
|
+
1,
|
|
3470
|
+
0,
|
|
3471
|
+
0,
|
|
3472
|
+
0,
|
|
3473
|
+
-0.25,
|
|
3474
|
+
0.1,
|
|
3475
|
+
1,
|
|
3476
|
+
0,
|
|
3477
|
+
0,
|
|
3478
|
+
0,
|
|
3479
|
+
-0.45,
|
|
3480
|
+
-0.1,
|
|
3481
|
+
1,
|
|
3482
|
+
0,
|
|
3483
|
+
0,
|
|
3484
|
+
0,
|
|
3485
|
+
0.25,
|
|
3486
|
+
0.1,
|
|
3487
|
+
1,
|
|
3488
|
+
0,
|
|
3489
|
+
0,
|
|
3490
|
+
0,
|
|
3491
|
+
0.25,
|
|
3492
|
+
-0.1,
|
|
3493
|
+
1,
|
|
3494
|
+
0,
|
|
3495
|
+
0,
|
|
3496
|
+
0,
|
|
3497
|
+
0.25,
|
|
3498
|
+
-0.1,
|
|
3499
|
+
1,
|
|
3500
|
+
0,
|
|
3501
|
+
0,
|
|
3502
|
+
0,
|
|
3503
|
+
-0.45,
|
|
3504
|
+
-0.1,
|
|
3505
|
+
1,
|
|
3506
|
+
0,
|
|
3507
|
+
0,
|
|
3508
|
+
0,
|
|
3509
|
+
-0.45,
|
|
3510
|
+
-0.1,
|
|
3511
|
+
1,
|
|
3512
|
+
0,
|
|
3513
|
+
0,
|
|
3514
|
+
0,
|
|
3515
|
+
-0.45,
|
|
3516
|
+
-0.6,
|
|
3517
|
+
1,
|
|
3518
|
+
0,
|
|
3519
|
+
0,
|
|
3520
|
+
0,
|
|
3521
|
+
-0.25,
|
|
3522
|
+
-0.1,
|
|
3523
|
+
1,
|
|
3524
|
+
0,
|
|
3525
|
+
0,
|
|
3526
|
+
0,
|
|
3527
|
+
-0.25,
|
|
3528
|
+
-0.8,
|
|
3529
|
+
1,
|
|
3530
|
+
0,
|
|
3531
|
+
0,
|
|
3532
|
+
0,
|
|
3533
|
+
-0.25,
|
|
3534
|
+
-0.8,
|
|
3535
|
+
1,
|
|
3536
|
+
0,
|
|
3537
|
+
0,
|
|
3538
|
+
0,
|
|
3539
|
+
-0.25,
|
|
3540
|
+
-0.6,
|
|
3541
|
+
1,
|
|
3542
|
+
0,
|
|
3543
|
+
0,
|
|
3544
|
+
0,
|
|
3545
|
+
-0.25,
|
|
3546
|
+
-0.6,
|
|
3547
|
+
1,
|
|
3548
|
+
0,
|
|
3549
|
+
0,
|
|
3550
|
+
0,
|
|
3551
|
+
-0.25,
|
|
3552
|
+
-0.8,
|
|
3553
|
+
1,
|
|
3554
|
+
0,
|
|
3555
|
+
0,
|
|
3556
|
+
0,
|
|
3557
|
+
0.45,
|
|
3558
|
+
-0.6,
|
|
3559
|
+
1,
|
|
3560
|
+
0,
|
|
3561
|
+
0,
|
|
3562
|
+
0,
|
|
3563
|
+
0.25,
|
|
3564
|
+
-0.8,
|
|
3565
|
+
1,
|
|
3566
|
+
0,
|
|
3567
|
+
0,
|
|
3568
|
+
0,
|
|
3569
|
+
0.25,
|
|
3570
|
+
-0.8,
|
|
3571
|
+
1,
|
|
3572
|
+
0,
|
|
3573
|
+
0,
|
|
3574
|
+
0,
|
|
3575
|
+
0.25,
|
|
3576
|
+
-0.4,
|
|
3577
|
+
1,
|
|
3578
|
+
0,
|
|
3579
|
+
0,
|
|
3580
|
+
0,
|
|
3581
|
+
0.25,
|
|
3582
|
+
-0.4,
|
|
3583
|
+
1,
|
|
3584
|
+
0,
|
|
3585
|
+
0,
|
|
3586
|
+
0,
|
|
3587
|
+
0.25,
|
|
3588
|
+
-0.6,
|
|
3589
|
+
1,
|
|
3590
|
+
0,
|
|
3591
|
+
0,
|
|
3592
|
+
0,
|
|
3593
|
+
0.45,
|
|
3594
|
+
-0.4,
|
|
3595
|
+
1,
|
|
3596
|
+
0,
|
|
3597
|
+
0,
|
|
3598
|
+
0,
|
|
3599
|
+
0.45,
|
|
3600
|
+
-0.6,
|
|
3601
|
+
1,
|
|
3602
|
+
0,
|
|
3603
|
+
0,
|
|
3604
|
+
0,
|
|
3605
|
+
0.45,
|
|
3606
|
+
-0.6,
|
|
3607
|
+
1,
|
|
3608
|
+
0,
|
|
3609
|
+
0,
|
|
3610
|
+
0,
|
|
3611
|
+
-0.1,
|
|
3612
|
+
-0.8,
|
|
3613
|
+
-1,
|
|
3614
|
+
0,
|
|
3615
|
+
0,
|
|
3616
|
+
0,
|
|
3617
|
+
-0.1,
|
|
3618
|
+
-0.8,
|
|
3619
|
+
-1,
|
|
3620
|
+
0,
|
|
3621
|
+
0,
|
|
3622
|
+
0,
|
|
3623
|
+
-0.1,
|
|
3624
|
+
0.8,
|
|
3625
|
+
-1,
|
|
3626
|
+
0,
|
|
3627
|
+
0,
|
|
3628
|
+
0,
|
|
3629
|
+
0.1,
|
|
3630
|
+
-0.8,
|
|
3631
|
+
-1,
|
|
3632
|
+
0,
|
|
3633
|
+
0,
|
|
3634
|
+
0,
|
|
3635
|
+
0.1,
|
|
3636
|
+
0.8,
|
|
3637
|
+
-1,
|
|
3638
|
+
0,
|
|
3639
|
+
0,
|
|
3640
|
+
0,
|
|
3641
|
+
0.1,
|
|
3642
|
+
0.8,
|
|
3643
|
+
-1,
|
|
3644
|
+
0,
|
|
3645
|
+
0,
|
|
3646
|
+
0,
|
|
3647
|
+
-1,
|
|
3648
|
+
-0.45,
|
|
3649
|
+
-0.8,
|
|
3650
|
+
0,
|
|
3651
|
+
0,
|
|
3652
|
+
0,
|
|
3653
|
+
-1,
|
|
3654
|
+
-0.45,
|
|
3655
|
+
-0.8,
|
|
3656
|
+
0,
|
|
3657
|
+
0,
|
|
3658
|
+
0,
|
|
3659
|
+
-1,
|
|
3660
|
+
-0.45,
|
|
3661
|
+
0.8,
|
|
3662
|
+
0,
|
|
3663
|
+
0,
|
|
3664
|
+
0,
|
|
3665
|
+
-1,
|
|
3666
|
+
-0.25,
|
|
3667
|
+
-0.8,
|
|
3668
|
+
0,
|
|
3669
|
+
0,
|
|
3670
|
+
0,
|
|
3671
|
+
-1,
|
|
3672
|
+
-0.25,
|
|
3673
|
+
0.8,
|
|
3674
|
+
0,
|
|
3675
|
+
0,
|
|
3676
|
+
0,
|
|
3677
|
+
-1,
|
|
3678
|
+
-0.25,
|
|
3679
|
+
0.8,
|
|
3680
|
+
0,
|
|
3681
|
+
0,
|
|
3682
|
+
0,
|
|
3683
|
+
-1,
|
|
3684
|
+
-0.25,
|
|
3685
|
+
-0.8,
|
|
3686
|
+
0,
|
|
3687
|
+
0,
|
|
3688
|
+
0,
|
|
3689
|
+
-1,
|
|
3690
|
+
-0.25,
|
|
3691
|
+
-0.8,
|
|
3692
|
+
0,
|
|
3693
|
+
0,
|
|
3694
|
+
0,
|
|
3695
|
+
-1,
|
|
3696
|
+
-0.25,
|
|
3697
|
+
-0.6,
|
|
3698
|
+
0,
|
|
3699
|
+
0,
|
|
3700
|
+
0,
|
|
3701
|
+
-1,
|
|
3702
|
+
0.45,
|
|
3703
|
+
-0.8,
|
|
3704
|
+
0,
|
|
3705
|
+
0,
|
|
3706
|
+
0,
|
|
3707
|
+
-1,
|
|
3708
|
+
0.45,
|
|
3709
|
+
-0.6,
|
|
3710
|
+
0,
|
|
3711
|
+
0,
|
|
3712
|
+
0,
|
|
3713
|
+
-1,
|
|
3714
|
+
0.45,
|
|
3715
|
+
-0.6,
|
|
3716
|
+
0,
|
|
3717
|
+
0,
|
|
3718
|
+
0,
|
|
3719
|
+
1,
|
|
3720
|
+
0.45,
|
|
3721
|
+
-0.8,
|
|
3722
|
+
0,
|
|
3723
|
+
0,
|
|
3724
|
+
0,
|
|
3725
|
+
1,
|
|
3726
|
+
0.45,
|
|
3727
|
+
-0.8,
|
|
3728
|
+
0,
|
|
3729
|
+
0,
|
|
3730
|
+
0,
|
|
3731
|
+
1,
|
|
3732
|
+
0.45,
|
|
3733
|
+
0.8,
|
|
3734
|
+
0,
|
|
3735
|
+
0,
|
|
3736
|
+
0,
|
|
3737
|
+
1,
|
|
3738
|
+
0.25,
|
|
3739
|
+
-0.8,
|
|
3740
|
+
0,
|
|
3741
|
+
0,
|
|
3742
|
+
0,
|
|
3743
|
+
1,
|
|
3744
|
+
0.25,
|
|
3745
|
+
0.8,
|
|
3746
|
+
0,
|
|
3747
|
+
0,
|
|
3748
|
+
0,
|
|
3749
|
+
1,
|
|
3750
|
+
0.25,
|
|
3751
|
+
0.8,
|
|
3752
|
+
0,
|
|
3753
|
+
0,
|
|
3754
|
+
0,
|
|
3755
|
+
1,
|
|
3756
|
+
0.25,
|
|
3757
|
+
0.6,
|
|
3758
|
+
0,
|
|
3759
|
+
0,
|
|
3760
|
+
0,
|
|
3761
|
+
1,
|
|
3762
|
+
0.25,
|
|
3763
|
+
0.6,
|
|
3764
|
+
0,
|
|
3765
|
+
0,
|
|
3766
|
+
0,
|
|
3767
|
+
1,
|
|
3768
|
+
0.25,
|
|
3769
|
+
0.8,
|
|
3770
|
+
0,
|
|
3771
|
+
0,
|
|
3772
|
+
0,
|
|
3773
|
+
1,
|
|
3774
|
+
-0.45,
|
|
3775
|
+
0.6,
|
|
3776
|
+
0,
|
|
3777
|
+
0,
|
|
3778
|
+
0,
|
|
3779
|
+
1,
|
|
3780
|
+
-0.25,
|
|
3781
|
+
0.8,
|
|
3782
|
+
0,
|
|
3783
|
+
0,
|
|
3784
|
+
0,
|
|
3785
|
+
1,
|
|
3786
|
+
-0.25,
|
|
3787
|
+
0.8,
|
|
3788
|
+
0,
|
|
3789
|
+
0,
|
|
3790
|
+
0,
|
|
3791
|
+
1,
|
|
3792
|
+
-0.25,
|
|
3793
|
+
0.1,
|
|
3794
|
+
0,
|
|
3795
|
+
0,
|
|
3796
|
+
0,
|
|
3797
|
+
1,
|
|
3798
|
+
-0.25,
|
|
3799
|
+
0.1,
|
|
3800
|
+
0,
|
|
3801
|
+
0,
|
|
3802
|
+
0,
|
|
3803
|
+
1,
|
|
3804
|
+
-0.25,
|
|
3805
|
+
0.6,
|
|
3806
|
+
0,
|
|
3807
|
+
0,
|
|
3808
|
+
0,
|
|
3809
|
+
1,
|
|
3810
|
+
-0.45,
|
|
3811
|
+
0.1,
|
|
3812
|
+
0,
|
|
3813
|
+
0,
|
|
3814
|
+
0,
|
|
3815
|
+
1,
|
|
3816
|
+
-0.45,
|
|
3817
|
+
0.6,
|
|
3818
|
+
0,
|
|
3819
|
+
0,
|
|
3820
|
+
0,
|
|
3821
|
+
1,
|
|
3822
|
+
-0.45,
|
|
3823
|
+
0.6,
|
|
3824
|
+
0,
|
|
3825
|
+
0,
|
|
3826
|
+
0,
|
|
3827
|
+
1,
|
|
3828
|
+
0.25,
|
|
3829
|
+
-0.1,
|
|
3830
|
+
0,
|
|
3831
|
+
0,
|
|
3832
|
+
0,
|
|
3833
|
+
1,
|
|
3834
|
+
0.25,
|
|
3835
|
+
-0.1,
|
|
3836
|
+
0,
|
|
3837
|
+
0,
|
|
3838
|
+
0,
|
|
3839
|
+
1,
|
|
3840
|
+
0.25,
|
|
3841
|
+
0.1,
|
|
3842
|
+
0,
|
|
3843
|
+
0,
|
|
3844
|
+
0,
|
|
3845
|
+
1,
|
|
3846
|
+
-0.25,
|
|
3847
|
+
-0.1,
|
|
3848
|
+
0,
|
|
3849
|
+
0,
|
|
3850
|
+
0,
|
|
3851
|
+
1,
|
|
3852
|
+
-0.45,
|
|
3853
|
+
0.1,
|
|
3854
|
+
0,
|
|
3855
|
+
0,
|
|
3856
|
+
0,
|
|
3857
|
+
1,
|
|
3858
|
+
-0.45,
|
|
3859
|
+
0.1,
|
|
3860
|
+
0,
|
|
3861
|
+
0,
|
|
3862
|
+
0,
|
|
3863
|
+
1,
|
|
3864
|
+
-0.25,
|
|
3865
|
+
-0.8,
|
|
3866
|
+
0,
|
|
3867
|
+
0,
|
|
3868
|
+
0,
|
|
3869
|
+
1,
|
|
3870
|
+
-0.25,
|
|
3871
|
+
-0.8,
|
|
3872
|
+
0,
|
|
3873
|
+
0,
|
|
3874
|
+
0,
|
|
3875
|
+
1,
|
|
3876
|
+
-0.05,
|
|
3877
|
+
-0.1,
|
|
3878
|
+
0,
|
|
3879
|
+
0,
|
|
3880
|
+
0,
|
|
3881
|
+
1,
|
|
3882
|
+
-0.45,
|
|
3883
|
+
-0.8,
|
|
3884
|
+
0,
|
|
3885
|
+
0,
|
|
3886
|
+
0,
|
|
3887
|
+
1,
|
|
3888
|
+
-0.25,
|
|
3889
|
+
-0.1,
|
|
3890
|
+
0,
|
|
3891
|
+
0,
|
|
3892
|
+
0,
|
|
3893
|
+
1,
|
|
3894
|
+
-0.25,
|
|
3895
|
+
-0.1,
|
|
3896
|
+
0,
|
|
3897
|
+
0,
|
|
3898
|
+
0
|
|
3899
|
+
]);
|
|
2847
3900
|
var NiivueObject3D = function(id, vertexBuffer, mode, indexCount, indexBuffer = null, vao = null) {
|
|
2848
3901
|
this.BLEND = 1;
|
|
2849
3902
|
this.CULL_FACE = 2;
|
|
@@ -110428,14 +111481,19 @@ function Niivue(options = {}) {
|
|
|
110428
111481
|
trustCalMinMax: true,
|
|
110429
111482
|
clipPlaneHotKey: "KeyC",
|
|
110430
111483
|
viewModeHotKey: "KeyV",
|
|
111484
|
+
doubleTouchTimeout: 500,
|
|
111485
|
+
longTouchTimeout: 1e3,
|
|
110431
111486
|
keyDebounceTime: 50,
|
|
110432
111487
|
isNearestInterpolation: false,
|
|
110433
111488
|
isAtlasOutline: false,
|
|
110434
111489
|
isRuler: false,
|
|
110435
111490
|
isColorbar: false,
|
|
111491
|
+
isOrientCube: false,
|
|
111492
|
+
multiplanarPadPixels: 0,
|
|
110436
111493
|
isRadiologicalConvention: false,
|
|
110437
111494
|
meshThicknessOn2D: Infinity,
|
|
110438
111495
|
isDragShowsMeasurementTool: false,
|
|
111496
|
+
isDepthPickMesh: false,
|
|
110439
111497
|
isCornerOrientationText: false,
|
|
110440
111498
|
sagittalNoseLeft: false,
|
|
110441
111499
|
isSliceMM: false,
|
|
@@ -110446,11 +111504,20 @@ function Niivue(options = {}) {
|
|
|
110446
111504
|
penValue: 1,
|
|
110447
111505
|
isFilledPen: false,
|
|
110448
111506
|
thumbnail: "",
|
|
111507
|
+
maxDrawUndoBitmaps: 8,
|
|
110449
111508
|
onLocationChange: () => {
|
|
110450
111509
|
},
|
|
110451
111510
|
onIntensityChange: () => {
|
|
110452
111511
|
},
|
|
110453
111512
|
onImageLoaded: () => {
|
|
111513
|
+
},
|
|
111514
|
+
onError: () => {
|
|
111515
|
+
},
|
|
111516
|
+
onInfo: () => {
|
|
111517
|
+
},
|
|
111518
|
+
onWarn: () => {
|
|
111519
|
+
},
|
|
111520
|
+
onDebug: () => {
|
|
110454
111521
|
}
|
|
110455
111522
|
};
|
|
110456
111523
|
this.canvas = null;
|
|
@@ -110459,8 +111526,6 @@ function Niivue(options = {}) {
|
|
|
110459
111526
|
this.volumeTexture = null;
|
|
110460
111527
|
this.drawTexture = null;
|
|
110461
111528
|
this.drawBitmap = null;
|
|
110462
|
-
this.maxDrawUndoBitmaps = 8;
|
|
110463
|
-
this.currentDrawUndoBitmap = this.maxDrawUndoBitmaps;
|
|
110464
111529
|
this.drawUndoBitmaps = [];
|
|
110465
111530
|
this.drawOpacity = 0.8;
|
|
110466
111531
|
this.colorbarHeight = 0;
|
|
@@ -110472,10 +111537,13 @@ function Niivue(options = {}) {
|
|
|
110472
111537
|
this.overlayTextureID = [];
|
|
110473
111538
|
this.sliceShader = null;
|
|
110474
111539
|
this.sliceMMShader = null;
|
|
111540
|
+
this.orientCubeShader = null;
|
|
111541
|
+
this.orientCubeShaderVAO = null;
|
|
110475
111542
|
this.rectShader = null;
|
|
110476
111543
|
this.graphShader = null;
|
|
110477
111544
|
this.renderShader = null;
|
|
110478
|
-
this.
|
|
111545
|
+
this.pickingMeshShader = null;
|
|
111546
|
+
this.pickingImageShader = null;
|
|
110479
111547
|
this.colorbarShader = null;
|
|
110480
111548
|
this.fontShader = null;
|
|
110481
111549
|
this.fontTexture = null;
|
|
@@ -110495,7 +111563,6 @@ function Niivue(options = {}) {
|
|
|
110495
111563
|
this.genericVAO = null;
|
|
110496
111564
|
this.unusedVAO = null;
|
|
110497
111565
|
this.crosshairs3D = null;
|
|
110498
|
-
this.pickingSurfaceShader = null;
|
|
110499
111566
|
this.DEFAULT_FONT_GLYPH_SHEET = defaultFontPNG;
|
|
110500
111567
|
this.DEFAULT_FONT_METRICS = defaultFontMetrics;
|
|
110501
111568
|
this.fontMets = null;
|
|
@@ -110528,6 +111595,10 @@ function Niivue(options = {}) {
|
|
|
110528
111595
|
this.scene.prevY = 0;
|
|
110529
111596
|
this.scene.currX = 0;
|
|
110530
111597
|
this.scene.currY = 0;
|
|
111598
|
+
this.currentTouchTime = 0;
|
|
111599
|
+
this.lastTouchTime = 0;
|
|
111600
|
+
this.touchTimer = null;
|
|
111601
|
+
this.doubleTouch = false;
|
|
110531
111602
|
this.back = {};
|
|
110532
111603
|
this.overlays = [];
|
|
110533
111604
|
this.volumes = [];
|
|
@@ -110604,6 +111675,7 @@ function Niivue(options = {}) {
|
|
|
110604
111675
|
for (let prop in this.defaults) {
|
|
110605
111676
|
this.opts[prop] = options[prop] === void 0 ? this.defaults[prop] : options[prop];
|
|
110606
111677
|
}
|
|
111678
|
+
this.currentDrawUndoBitmap = this.opts.maxDrawUndoBitmaps;
|
|
110607
111679
|
if (this.opts.drawingEnabled) {
|
|
110608
111680
|
this.createEmptyDrawing();
|
|
110609
111681
|
}
|
|
@@ -110939,7 +112011,27 @@ Niivue.prototype.checkMultitouch = function(e) {
|
|
|
110939
112011
|
};
|
|
110940
112012
|
Niivue.prototype.touchStartListener = function(e) {
|
|
110941
112013
|
e.preventDefault();
|
|
112014
|
+
if (!this.touchTimer) {
|
|
112015
|
+
this.touchTimer = setTimeout(() => {
|
|
112016
|
+
this.resetBriCon(e);
|
|
112017
|
+
}, this.opts.longTouchTimeout);
|
|
112018
|
+
}
|
|
110942
112019
|
this.scene.touchdown = true;
|
|
112020
|
+
this.currentTouchTime = new Date().getTime();
|
|
112021
|
+
let timeSinceTouch = this.currentTouchTime - this.lastTouchTime;
|
|
112022
|
+
if (timeSinceTouch < this.opts.doubleTouchTimeout && timeSinceTouch > 0) {
|
|
112023
|
+
this.doubleTouch = true;
|
|
112024
|
+
this.dragStart[0] = e.targetTouches[0].clientX - e.target.getBoundingClientRect().left;
|
|
112025
|
+
this.dragStart[1] = e.targetTouches[0].clientY - e.target.getBoundingClientRect().top;
|
|
112026
|
+
this.resetBriCon(e);
|
|
112027
|
+
this.lastTouchTime = this.currentTouchTime;
|
|
112028
|
+
return;
|
|
112029
|
+
} else {
|
|
112030
|
+
this.doubleTouch = false;
|
|
112031
|
+
this.dragStart = [0, 0];
|
|
112032
|
+
this.dragEnd = [0, 0];
|
|
112033
|
+
this.lastTouchTime = this.currentTouchTime;
|
|
112034
|
+
}
|
|
110943
112035
|
if (this.scene.touchdown && e.touches.length < 2) {
|
|
110944
112036
|
this.multiTouchGesture = false;
|
|
110945
112037
|
} else {
|
|
@@ -110947,10 +112039,23 @@ Niivue.prototype.touchStartListener = function(e) {
|
|
|
110947
112039
|
}
|
|
110948
112040
|
setTimeout(this.checkMultitouch.bind(this), 1, e);
|
|
110949
112041
|
};
|
|
110950
|
-
Niivue.prototype.touchEndListener = function() {
|
|
112042
|
+
Niivue.prototype.touchEndListener = function(e) {
|
|
112043
|
+
e.preventDefault();
|
|
110951
112044
|
this.scene.touchdown = false;
|
|
110952
112045
|
this.lastTwoTouchDistance = 0;
|
|
110953
112046
|
this.multiTouchGesture = false;
|
|
112047
|
+
if (this.touchTimer) {
|
|
112048
|
+
clearTimeout(this.touchTimer);
|
|
112049
|
+
this.touchTimer = null;
|
|
112050
|
+
}
|
|
112051
|
+
if (this.isDragging) {
|
|
112052
|
+
this.isDragging = false;
|
|
112053
|
+
if (this.opts.isDragShowsMeasurementTool)
|
|
112054
|
+
return;
|
|
112055
|
+
this.calculateNewRange();
|
|
112056
|
+
this.refreshLayers(this.volumes[0], 0, this.volumes.length);
|
|
112057
|
+
}
|
|
112058
|
+
this.drawScene();
|
|
110954
112059
|
};
|
|
110955
112060
|
Niivue.prototype.mouseMoveListener = function(e) {
|
|
110956
112061
|
if (this.scene.mousedown) {
|
|
@@ -110969,11 +112074,19 @@ Niivue.prototype.mouseMoveListener = function(e) {
|
|
|
110969
112074
|
};
|
|
110970
112075
|
Niivue.prototype.resetBriCon = function(msg2 = null) {
|
|
110971
112076
|
let isRender = false;
|
|
110972
|
-
if (this.sliceType === this.sliceTypeRender)
|
|
112077
|
+
if (this.sliceType === this.sliceTypeRender)
|
|
110973
112078
|
isRender = true;
|
|
110974
|
-
|
|
112079
|
+
let x2 = 0;
|
|
112080
|
+
let y = 0;
|
|
110975
112081
|
if (msg2 !== null) {
|
|
110976
|
-
if (
|
|
112082
|
+
if (msg2.targetTouches !== void 0) {
|
|
112083
|
+
x2 = msg2.targetTouches[0].clientX - msg2.target.getBoundingClientRect().left;
|
|
112084
|
+
y = msg2.targetTouches[0].clientY - msg2.target.getBoundingClientRect().top;
|
|
112085
|
+
} else {
|
|
112086
|
+
x2 = msg2.offsetX;
|
|
112087
|
+
y = msg2.offsetY;
|
|
112088
|
+
}
|
|
112089
|
+
if (this.inRenderTile(x2, y) >= 0)
|
|
110977
112090
|
isRender = true;
|
|
110978
112091
|
}
|
|
110979
112092
|
if (isRender) {
|
|
@@ -110982,6 +112095,8 @@ Niivue.prototype.resetBriCon = function(msg2 = null) {
|
|
|
110982
112095
|
this.drawScene();
|
|
110983
112096
|
return;
|
|
110984
112097
|
}
|
|
112098
|
+
if (this.doubleTouch)
|
|
112099
|
+
return;
|
|
110985
112100
|
this.volumes[0].cal_min = this.volumes[0].robust_min;
|
|
110986
112101
|
this.volumes[0].cal_max = this.volumes[0].robust_max;
|
|
110987
112102
|
this.opts.onIntensityChange(this.volumes[0]);
|
|
@@ -110991,6 +112106,12 @@ Niivue.prototype.resetBriCon = function(msg2 = null) {
|
|
|
110991
112106
|
Niivue.prototype.touchMoveListener = function(e) {
|
|
110992
112107
|
if (this.scene.touchdown && e.touches.length < 2) {
|
|
110993
112108
|
var rect = this.canvas.getBoundingClientRect();
|
|
112109
|
+
this.isDragging = true;
|
|
112110
|
+
if (this.doubleTouch && this.isDragging) {
|
|
112111
|
+
this.dragEnd[0] = e.targetTouches[0].clientX - e.target.getBoundingClientRect().left;
|
|
112112
|
+
this.dragEnd[1] = e.targetTouches[0].clientY - e.target.getBoundingClientRect().top;
|
|
112113
|
+
return;
|
|
112114
|
+
}
|
|
110994
112115
|
this.mouseClick(e.touches[0].clientX - rect.left, e.touches[0].clientY - rect.top);
|
|
110995
112116
|
this.mouseMove(e.touches[0].clientX - rect.left, e.touches[0].clientY - rect.top);
|
|
110996
112117
|
} else {
|
|
@@ -111090,6 +112211,9 @@ Niivue.prototype.keyDownListener = function(e) {
|
|
|
111090
112211
|
Niivue.prototype.wheelListener = function(e) {
|
|
111091
112212
|
e.preventDefault();
|
|
111092
112213
|
e.stopPropagation();
|
|
112214
|
+
if (this.thumbnailVisible) {
|
|
112215
|
+
return;
|
|
112216
|
+
}
|
|
111093
112217
|
var rect = this.canvas.getBoundingClientRect();
|
|
111094
112218
|
if (e.deltaY < 0) {
|
|
111095
112219
|
this.sliceScroll2D(-0.01, e.clientX - rect.left, e.clientY - rect.top);
|
|
@@ -111332,12 +112456,12 @@ Niivue.prototype.drawAddUndoBitmap = async function(fnm) {
|
|
|
111332
112456
|
return false;
|
|
111333
112457
|
}
|
|
111334
112458
|
this.currentDrawUndoBitmap++;
|
|
111335
|
-
if (this.currentDrawUndoBitmap >= this.maxDrawUndoBitmaps)
|
|
112459
|
+
if (this.currentDrawUndoBitmap >= this.opts.maxDrawUndoBitmaps)
|
|
111336
112460
|
this.currentDrawUndoBitmap = 0;
|
|
111337
112461
|
this.drawUndoBitmaps[this.currentDrawUndoBitmap] = encodeRLE(this.drawBitmap);
|
|
111338
112462
|
};
|
|
111339
112463
|
Niivue.prototype.drawClearAllUndoBitmaps = async function() {
|
|
111340
|
-
this.currentDrawUndoBitmap = this.maxDrawUndoBitmaps;
|
|
112464
|
+
this.currentDrawUndoBitmap = this.opts.maxDrawUndoBitmaps;
|
|
111341
112465
|
if (this.drawUndoBitmaps.length < 1)
|
|
111342
112466
|
return;
|
|
111343
112467
|
for (let i2 = this.drawUndoBitmaps.length - 1; i2 >= 0; i2--)
|
|
@@ -112551,13 +113675,14 @@ Niivue.prototype.init = async function() {
|
|
|
112551
113675
|
this.gl.enableVertexAttribArray(0);
|
|
112552
113676
|
this.gl.vertexAttribPointer(0, 3, this.gl.FLOAT, false, 0, 0);
|
|
112553
113677
|
this.gl.bindVertexArray(this.unusedVAO);
|
|
112554
|
-
this.
|
|
112555
|
-
this.
|
|
112556
|
-
this.
|
|
112557
|
-
this.gl.uniform1i(this.
|
|
112558
|
-
this.
|
|
112559
|
-
this.
|
|
112560
|
-
this.
|
|
113678
|
+
this.pickingMeshShader = new Shader(this.gl, vertMeshShader, fragMeshDepthShader);
|
|
113679
|
+
this.pickingImageShader = new Shader(this.gl, vertRenderShader, fragVolumePickingShader);
|
|
113680
|
+
this.pickingImageShader.use(this.gl);
|
|
113681
|
+
this.gl.uniform1i(this.pickingImageShader.uniforms["volume"], 0);
|
|
113682
|
+
this.gl.uniform1i(this.pickingImageShader.uniforms["overlay"], 2);
|
|
113683
|
+
this.pickingImageShader.mvpUniformLoc = this.pickingImageShader.uniforms["mvpMtx"];
|
|
113684
|
+
this.pickingImageShader.rayDirUniformLoc = this.pickingImageShader.uniforms["rayDir"];
|
|
113685
|
+
this.pickingImageShader.clipPlaneUniformLoc = this.pickingImageShader.uniforms["clipPlane"];
|
|
112561
113686
|
this.sliceShader = new Shader(this.gl, vertSliceShader, fragSliceShader);
|
|
112562
113687
|
this.sliceShader.use(this.gl);
|
|
112563
113688
|
this.gl.uniform1i(this.sliceShader.uniforms["volume"], 0);
|
|
@@ -112570,6 +113695,21 @@ Niivue.prototype.init = async function() {
|
|
|
112570
113695
|
this.gl.uniform1i(this.sliceMMShader.uniforms["overlay"], 2);
|
|
112571
113696
|
this.gl.uniform1i(this.sliceMMShader.uniforms["drawing"], 7);
|
|
112572
113697
|
this.gl.uniform1f(this.sliceMMShader.uniforms["drawOpacity"], this.drawOpacity);
|
|
113698
|
+
this.orientCubeShader = new Shader(this.gl, vertOrientCubeShader, fragOrientCubeShader);
|
|
113699
|
+
let gl = this.gl;
|
|
113700
|
+
this.orientCubeShaderVAO = gl.createVertexArray();
|
|
113701
|
+
gl.bindVertexArray(this.orientCubeShaderVAO);
|
|
113702
|
+
let program = this.orientCubeShader.program;
|
|
113703
|
+
this.orientCubeMtxLoc = gl.getUniformLocation(program, "u_matrix");
|
|
113704
|
+
var positionBuffer = gl.createBuffer();
|
|
113705
|
+
gl.enableVertexAttribArray(0);
|
|
113706
|
+
gl.enableVertexAttribArray(1);
|
|
113707
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, positionBuffer);
|
|
113708
|
+
gl.bufferData(gl.ARRAY_BUFFER, orientCube, gl.STATIC_DRAW);
|
|
113709
|
+
gl.vertexAttribPointer(0, 3, gl.FLOAT, false, 24, 0);
|
|
113710
|
+
gl.enableVertexAttribArray(1);
|
|
113711
|
+
gl.vertexAttribPointer(1, 3, gl.FLOAT, false, 24, 12);
|
|
113712
|
+
gl.bindVertexArray(this.unusedVAO);
|
|
112573
113713
|
this.rectShader = new Shader(this.gl, vertRectShader, fragRectShader);
|
|
112574
113714
|
this.lineShader = new Shader(this.gl, vertLineShader, fragRectShader);
|
|
112575
113715
|
this.graphShader = new Shader(this.gl, vertGraphShader, fragRectShader);
|
|
@@ -112588,7 +113728,6 @@ Niivue.prototype.init = async function() {
|
|
|
112588
113728
|
this.orientShaderI = new Shader(this.gl, vertOrientShader, fragOrientShaderI.concat(fragOrientShader));
|
|
112589
113729
|
this.orientShaderF = new Shader(this.gl, vertOrientShader, fragOrientShaderF.concat(fragOrientShader));
|
|
112590
113730
|
this.orientShaderRGBU = new Shader(this.gl, vertOrientShader, fragOrientShaderU.concat(fragRGBOrientShader));
|
|
112591
|
-
this.pickingSurfaceShader = new Shader(this.gl, vertRenderShader, fragDepthPickingShader);
|
|
112592
113731
|
this.surfaceShader = new Shader(this.gl, vertSurfaceShader, fragSurfaceShader);
|
|
112593
113732
|
this.fiberShader = new Shader(this.gl, vertFiberShader, fragFiberShader);
|
|
112594
113733
|
this.meshShader = new Shader(this.gl, vertMeshShader, this.meshShaders[0].Frag);
|
|
@@ -112711,8 +113850,7 @@ Niivue.prototype.refreshLayers = function(overlayItem, layer, numLayers) {
|
|
|
112711
113850
|
this.renderShader.use(this.gl);
|
|
112712
113851
|
this.gl.uniform3fv(this.renderShader.uniforms["texVox"], vox2);
|
|
112713
113852
|
this.gl.uniform3fv(this.renderShader.uniforms["volScale"], volScale2);
|
|
112714
|
-
this.
|
|
112715
|
-
let pickingShader = this.pickingShader;
|
|
113853
|
+
let pickingShader = this.pickingImageShader;
|
|
112716
113854
|
pickingShader.use(this.gl);
|
|
112717
113855
|
this.gl.uniform1i(pickingShader.uniforms["volume"], 0);
|
|
112718
113856
|
this.gl.uniform1i(pickingShader.uniforms["colormap"], 1);
|
|
@@ -112899,9 +114037,9 @@ Niivue.prototype.refreshLayers = function(overlayItem, layer, numLayers) {
|
|
|
112899
114037
|
this.gl.uniform4fv(this.renderShader.uniforms["clipPlane"], this.scene.clipPlane);
|
|
112900
114038
|
this.gl.uniform3fv(this.renderShader.uniforms["texVox"], vox);
|
|
112901
114039
|
this.gl.uniform3fv(this.renderShader.uniforms["volScale"], volScale);
|
|
112902
|
-
this.
|
|
112903
|
-
this.gl.uniform1f(this.
|
|
112904
|
-
this.gl.uniform3fv(this.
|
|
114040
|
+
this.pickingImageShader.use(this.gl);
|
|
114041
|
+
this.gl.uniform1f(this.pickingImageShader.uniforms["overlays"], this.overlays.length);
|
|
114042
|
+
this.gl.uniform3fv(this.pickingImageShader.uniforms["texVox"], vox);
|
|
112905
114043
|
this.sliceMMShader.use(this.gl);
|
|
112906
114044
|
this.gl.uniform1f(this.sliceMMShader.uniforms["overlays"], this.overlays.length);
|
|
112907
114045
|
this.gl.uniform1f(this.sliceMMShader.uniforms["drawOpacity"], this.drawOpacity);
|
|
@@ -113925,7 +115063,7 @@ Niivue.prototype.calculateRayDirection = function(azimuth, elevation) {
|
|
|
113925
115063
|
rayDir[2] = tiny;
|
|
113926
115064
|
return rayDir;
|
|
113927
115065
|
};
|
|
113928
|
-
Niivue.prototype.
|
|
115066
|
+
Niivue.prototype.sceneExtentsMinMax = function() {
|
|
113929
115067
|
let mn = fromValues$1(0, 0, 0);
|
|
113930
115068
|
let mx = fromValues$1(0, 0, 0);
|
|
113931
115069
|
if (this.volumes.length > 0) {
|
|
@@ -113943,6 +115081,12 @@ Niivue.prototype.setPivot3D = function() {
|
|
|
113943
115081
|
max$T(mx, mx, v);
|
|
113944
115082
|
}
|
|
113945
115083
|
}
|
|
115084
|
+
let range = create$1();
|
|
115085
|
+
subtract(range, mx, mn);
|
|
115086
|
+
return [mn, mx, range];
|
|
115087
|
+
};
|
|
115088
|
+
Niivue.prototype.setPivot3D = function() {
|
|
115089
|
+
let [mn, mx] = this.sceneExtentsMinMax();
|
|
113946
115090
|
let pivot = create$1();
|
|
113947
115091
|
add$1(pivot, mn, mx);
|
|
113948
115092
|
scale(pivot, pivot, 0.5);
|
|
@@ -114138,7 +115282,7 @@ Niivue.prototype.drawGraph = function() {
|
|
|
114138
115282
|
if (i2 % 2 === 1) {
|
|
114139
115283
|
thick *= 0.5;
|
|
114140
115284
|
this.drawGraphLine([x2, plotLTWH[1], x2, plotLTWH[1] + plotLTWH[3]], thinColor, thick);
|
|
114141
|
-
} else
|
|
115285
|
+
} else {
|
|
114142
115286
|
let str = humanize(i2);
|
|
114143
115287
|
if (fntSize > 0)
|
|
114144
115288
|
this.drawTextBelow([x2, 2 + plotLTWH[1] + plotLTWH[3]], str, fntScale, graph.textColor);
|
|
@@ -114181,6 +115325,113 @@ function isRadiological(mtx) {
|
|
|
114181
115325
|
transformMat4(vRotated, vRight, mtx);
|
|
114182
115326
|
return vRotated[0];
|
|
114183
115327
|
}
|
|
115328
|
+
function unProject(winX, winY, winZ, mvpMatrix) {
|
|
115329
|
+
let inp = fromValues(winX, winY, winZ, 1);
|
|
115330
|
+
let finalMatrix = clone$1(mvpMatrix);
|
|
115331
|
+
invert(finalMatrix, finalMatrix);
|
|
115332
|
+
inp[0] = inp[0] * 2 - 1;
|
|
115333
|
+
inp[1] = inp[1] * 2 - 1;
|
|
115334
|
+
inp[2] = inp[2] * 2 - 1;
|
|
115335
|
+
let out = create();
|
|
115336
|
+
transformMat4(out, inp, finalMatrix);
|
|
115337
|
+
if (out[3] === 0)
|
|
115338
|
+
return out;
|
|
115339
|
+
out[0] /= out[3];
|
|
115340
|
+
out[1] /= out[3];
|
|
115341
|
+
out[2] /= out[3];
|
|
115342
|
+
return out;
|
|
115343
|
+
}
|
|
115344
|
+
function unpackFloatFromVec4i(val) {
|
|
115345
|
+
var bitSh = [
|
|
115346
|
+
1 / (256 * 256 * 256),
|
|
115347
|
+
1 / (256 * 256),
|
|
115348
|
+
1 / 256,
|
|
115349
|
+
1
|
|
115350
|
+
];
|
|
115351
|
+
return (val[0] * bitSh[0] + val[1] * bitSh[1] + val[2] * bitSh[2] + val[3] * bitSh[3]) / 255;
|
|
115352
|
+
}
|
|
115353
|
+
Niivue.prototype.depthPicker = function(leftTopWidthHeight, mvpMatrix) {
|
|
115354
|
+
if (!this.scene.mouseDepthPicker)
|
|
115355
|
+
return;
|
|
115356
|
+
this.scene.mouseDepthPicker = false;
|
|
115357
|
+
let gl = this.gl;
|
|
115358
|
+
const pixelX = this.mousePos[0] * leftTopWidthHeight[2] / leftTopWidthHeight[2];
|
|
115359
|
+
const pixelY = gl.canvas.height - this.mousePos[1] * leftTopWidthHeight[3] / leftTopWidthHeight[3] - 1;
|
|
115360
|
+
console.log(pixelX + "/" + pixelY);
|
|
115361
|
+
const rgbaPixel = new Uint8Array(4);
|
|
115362
|
+
gl.readPixels(pixelX, pixelY, 1, 1, gl.RGBA, gl.UNSIGNED_BYTE, rgbaPixel);
|
|
115363
|
+
this.selectedObjectId = rgbaPixel[3];
|
|
115364
|
+
if (this.selectedObjectId === this.VOLUME_ID) {
|
|
115365
|
+
this.scene.crosshairPos = new Float32Array(rgbaPixel.slice(0, 3)).map((x2) => x2 / 255);
|
|
115366
|
+
return;
|
|
115367
|
+
}
|
|
115368
|
+
let depthZ = unpackFloatFromVec4i(rgbaPixel);
|
|
115369
|
+
if (depthZ > 1)
|
|
115370
|
+
return;
|
|
115371
|
+
let fracX = (this.mousePos[0] - leftTopWidthHeight[0]) / leftTopWidthHeight[2];
|
|
115372
|
+
let fracY = (gl.canvas.height - this.mousePos[1] - leftTopWidthHeight[1]) / leftTopWidthHeight[3];
|
|
115373
|
+
let mm = unProject(fracX, fracY, depthZ, mvpMatrix);
|
|
115374
|
+
let frac = this.mm2frac(mm);
|
|
115375
|
+
if (frac[0] < 0 || frac[0] > 1 || frac[1] < 0 || frac[1] > 1 || frac[2] < 0 || frac[2] > 1)
|
|
115376
|
+
return;
|
|
115377
|
+
this.scene.crosshairPos = this.mm2frac(mm);
|
|
115378
|
+
};
|
|
115379
|
+
Niivue.prototype.drawImage3D = function(mvpMatrix, azimuth, elevation) {
|
|
115380
|
+
if (this.volumes.length === 0)
|
|
115381
|
+
return;
|
|
115382
|
+
let gl = this.gl;
|
|
115383
|
+
const rayDir = this.calculateRayDirection(azimuth, elevation);
|
|
115384
|
+
let object3D = this.volumeObject3D;
|
|
115385
|
+
if (object3D) {
|
|
115386
|
+
gl.enable(gl.BLEND);
|
|
115387
|
+
gl.blendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA);
|
|
115388
|
+
gl.enable(gl.CULL_FACE);
|
|
115389
|
+
gl.cullFace(gl.FRONT);
|
|
115390
|
+
let shader = this.renderShader;
|
|
115391
|
+
if (this.scene.mouseDepthPicker)
|
|
115392
|
+
shader = this.pickingImageShader;
|
|
115393
|
+
shader.use(this.gl);
|
|
115394
|
+
gl.uniform1i(shader.uniforms["backgroundMasksOverlays"], this.backgroundMasksOverlays);
|
|
115395
|
+
gl.uniformMatrix4fv(shader.mvpUniformLoc, false, mvpMatrix);
|
|
115396
|
+
gl.uniformMatrix4fv(shader.mvpMatRASLoc, false, this.back.matRAS);
|
|
115397
|
+
gl.uniform3fv(shader.rayDirUniformLoc, rayDir);
|
|
115398
|
+
gl.uniform4fv(shader.clipPlaneUniformLoc, this.scene.clipPlane);
|
|
115399
|
+
gl.bindVertexArray(object3D.vao);
|
|
115400
|
+
gl.drawElements(object3D.mode, object3D.indexCount, gl.UNSIGNED_SHORT, 0);
|
|
115401
|
+
gl.bindVertexArray(this.unusedVAO);
|
|
115402
|
+
}
|
|
115403
|
+
};
|
|
115404
|
+
Niivue.prototype.drawOrientationCube = function(leftTopWidthHeight, azimuth = 0, elevation = 0) {
|
|
115405
|
+
if (!this.opts.isOrientCube)
|
|
115406
|
+
return;
|
|
115407
|
+
let sz = 0.05 * Math.min(leftTopWidthHeight[2], leftTopWidthHeight[3]);
|
|
115408
|
+
if (sz < 5)
|
|
115409
|
+
return;
|
|
115410
|
+
let gl = this.gl;
|
|
115411
|
+
gl.enable(gl.CULL_FACE);
|
|
115412
|
+
gl.cullFace(gl.BACK);
|
|
115413
|
+
this.orientCubeShader.use(this.gl);
|
|
115414
|
+
gl.bindVertexArray(this.orientCubeShaderVAO);
|
|
115415
|
+
function deg2rad2(deg) {
|
|
115416
|
+
return deg * (Math.PI / 180);
|
|
115417
|
+
}
|
|
115418
|
+
let modelMatrix = create$2();
|
|
115419
|
+
let projectionMatrix = create$2();
|
|
115420
|
+
ortho(projectionMatrix, 0, gl.canvas.width, 0, gl.canvas.height, -10 * sz, 10 * sz);
|
|
115421
|
+
translate(modelMatrix, modelMatrix, [
|
|
115422
|
+
1.8 * sz + leftTopWidthHeight[0],
|
|
115423
|
+
1.8 * sz + leftTopWidthHeight[1],
|
|
115424
|
+
0
|
|
115425
|
+
]);
|
|
115426
|
+
scale$1(modelMatrix, modelMatrix, [sz, sz, sz]);
|
|
115427
|
+
rotateX(modelMatrix, modelMatrix, deg2rad2(270 - elevation));
|
|
115428
|
+
rotateZ(modelMatrix, modelMatrix, deg2rad2(-azimuth));
|
|
115429
|
+
let modelViewProjectionMatrix = create$2();
|
|
115430
|
+
multiply(modelViewProjectionMatrix, projectionMatrix, modelMatrix);
|
|
115431
|
+
gl.uniformMatrix4fv(this.orientCubeMtxLoc, false, modelViewProjectionMatrix);
|
|
115432
|
+
gl.drawArrays(gl.TRIANGLE_STRIP, 0, 168);
|
|
115433
|
+
gl.bindVertexArray(this.unusedVAO);
|
|
115434
|
+
};
|
|
114184
115435
|
Niivue.prototype.draw3D = function(leftTopWidthHeight = [0, 0, 0, 0], mvpMatrix = null, modelMatrix, normalMatrix, azimuth = null, elevation) {
|
|
114185
115436
|
let isMosaic = azimuth !== null;
|
|
114186
115437
|
this.setPivot3D();
|
|
@@ -114216,62 +115467,20 @@ Niivue.prototype.draw3D = function(leftTopWidthHeight = [0, 0, 0, 0], mvpMatrix
|
|
|
114216
115467
|
gl.enable(gl.DEPTH_TEST);
|
|
114217
115468
|
gl.depthFunc(gl.ALWAYS);
|
|
114218
115469
|
gl.clearDepth(0);
|
|
114219
|
-
if (this.volumes.length
|
|
114220
|
-
|
|
114221
|
-
this.drawMesh3D(true, 1, mvpMatrix, modelMatrix, normalMatrix);
|
|
114222
|
-
gl.viewport(0, 0, gl.canvas.width, gl.canvas.height);
|
|
114223
|
-
return;
|
|
114224
|
-
}
|
|
114225
|
-
const rayDir = this.calculateRayDirection(azimuth, elevation);
|
|
114226
|
-
let object3D = this.volumeObject3D;
|
|
114227
|
-
if (this.scene.mouseDepthPicker) {
|
|
114228
|
-
gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
|
|
114229
|
-
this.scene.mouseDepthPicker = false;
|
|
114230
|
-
if (object3D.isVisible && object3D.isPickable) {
|
|
114231
|
-
let shader = this.pickingShader;
|
|
114232
|
-
shader.use(this.gl);
|
|
114233
|
-
gl.enable(gl.CULL_FACE);
|
|
114234
|
-
gl.cullFace(gl.FRONT);
|
|
114235
|
-
gl.uniformMatrix4fv(shader.mvpUniformLoc, false, mvpMatrix);
|
|
114236
|
-
gl.uniform3fv(shader.rayDirUniformLoc, rayDir);
|
|
114237
|
-
gl.uniform4fv(shader.clipPlaneUniformLoc, this.scene.clipPlane);
|
|
114238
|
-
gl.uniform1i(shader.uniforms["id"], object3D.id);
|
|
114239
|
-
gl.bindVertexArray(object3D.vao);
|
|
114240
|
-
gl.drawElements(object3D.mode, object3D.indexCount, gl.UNSIGNED_SHORT, 0);
|
|
114241
|
-
gl.bindVertexArray(this.unusedVAO);
|
|
114242
|
-
}
|
|
114243
|
-
const pixelX = this.mousePos[0] * leftTopWidthHeight[2] / leftTopWidthHeight[2];
|
|
114244
|
-
const pixelY = gl.canvas.height - this.mousePos[1] * leftTopWidthHeight[3] / leftTopWidthHeight[3] - 1;
|
|
114245
|
-
const rgbaPixel = new Uint8Array(4);
|
|
114246
|
-
gl.readPixels(pixelX, pixelY, 1, 1, gl.RGBA, gl.UNSIGNED_BYTE, rgbaPixel);
|
|
114247
|
-
this.selectedObjectId = rgbaPixel[3];
|
|
114248
|
-
if (this.selectedObjectId === this.VOLUME_ID) {
|
|
114249
|
-
this.scene.crosshairPos = new Float32Array(rgbaPixel.slice(0, 3)).map((x2) => x2 / 255);
|
|
114250
|
-
}
|
|
114251
|
-
}
|
|
114252
|
-
if (this.volumeObject3D.isVisible) {
|
|
114253
|
-
gl.enable(gl.BLEND);
|
|
114254
|
-
gl.blendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA);
|
|
114255
|
-
gl.enable(gl.CULL_FACE);
|
|
114256
|
-
gl.cullFace(gl.FRONT);
|
|
114257
|
-
let shader = this.renderShader;
|
|
114258
|
-
shader.use(this.gl);
|
|
114259
|
-
gl.uniform1i(shader.uniforms["backgroundMasksOverlays"], this.backgroundMasksOverlays);
|
|
114260
|
-
gl.uniformMatrix4fv(shader.mvpUniformLoc, false, mvpMatrix);
|
|
114261
|
-
gl.uniformMatrix4fv(shader.mvpMatRASLoc, false, this.back.matRAS);
|
|
114262
|
-
gl.uniform3fv(shader.rayDirUniformLoc, rayDir);
|
|
114263
|
-
gl.uniform4fv(shader.clipPlaneUniformLoc, this.scene.clipPlane);
|
|
114264
|
-
gl.bindVertexArray(object3D.vao);
|
|
114265
|
-
gl.drawElements(object3D.mode, object3D.indexCount, gl.UNSIGNED_SHORT, 0);
|
|
114266
|
-
gl.bindVertexArray(this.unusedVAO);
|
|
114267
|
-
}
|
|
115470
|
+
if (this.volumes.length > 0)
|
|
115471
|
+
this.drawImage3D(mvpMatrix, azimuth, elevation);
|
|
114268
115472
|
if (!isMosaic)
|
|
114269
115473
|
this.drawCrosshairs3D(true, 1, mvpMatrix);
|
|
114270
115474
|
this.drawMesh3D(true, 1, mvpMatrix, modelMatrix, normalMatrix);
|
|
115475
|
+
if (this.scene.mouseDepthPicker) {
|
|
115476
|
+
this.depthPicker(leftTopWidthHeight, mvpMatrix, true);
|
|
115477
|
+
return;
|
|
115478
|
+
}
|
|
114271
115479
|
this.drawMesh3D(false, 0.02, mvpMatrix, modelMatrix, normalMatrix);
|
|
114272
115480
|
if (!isMosaic)
|
|
114273
115481
|
this.drawCrosshairs3D(false, 0.15, mvpMatrix);
|
|
114274
115482
|
gl.viewport(0, 0, gl.canvas.width, gl.canvas.height);
|
|
115483
|
+
this.drawOrientationCube(leftTopWidthHeight, azimuth, elevation);
|
|
114275
115484
|
let posString = "azimuth: " + this.scene.renderAzimuth.toFixed(0) + " elevation: " + this.scene.renderElevation.toFixed(0);
|
|
114276
115485
|
this.drawGraph();
|
|
114277
115486
|
this.readyForSync = true;
|
|
@@ -114296,11 +115505,14 @@ Niivue.prototype.drawMesh3D = function(isDepthTest = true, alpha = 1, m, modelMt
|
|
|
114296
115505
|
gl.depthFunc(gl.ALWAYS);
|
|
114297
115506
|
}
|
|
114298
115507
|
gl.disable(gl.CULL_FACE);
|
|
114299
|
-
this.meshShader
|
|
114300
|
-
|
|
114301
|
-
|
|
114302
|
-
|
|
114303
|
-
gl.
|
|
115508
|
+
let shader = this.meshShader;
|
|
115509
|
+
if (this.scene.mouseDepthPicker)
|
|
115510
|
+
shader = this.pickingMeshShader;
|
|
115511
|
+
shader.use(this.gl);
|
|
115512
|
+
gl.uniformMatrix4fv(shader.uniforms["mvpMtx"], false, m);
|
|
115513
|
+
gl.uniformMatrix4fv(shader.uniforms["modelMtx"], false, modelMtx);
|
|
115514
|
+
gl.uniformMatrix4fv(shader.uniforms["normMtx"], false, normMtx);
|
|
115515
|
+
gl.uniform1f(shader.uniforms["opacity"], alpha);
|
|
114304
115516
|
let hasFibers = false;
|
|
114305
115517
|
for (let i2 = 0; i2 < this.meshes.length; i2++) {
|
|
114306
115518
|
if (this.meshes[i2].indexCount < 3)
|
|
@@ -114318,7 +115530,7 @@ Niivue.prototype.drawMesh3D = function(isDepthTest = true, alpha = 1, m, modelMt
|
|
|
114318
115530
|
gl.depthFunc(gl.ALWAYS);
|
|
114319
115531
|
return;
|
|
114320
115532
|
}
|
|
114321
|
-
|
|
115533
|
+
shader = this.fiberShader;
|
|
114322
115534
|
shader.use(this.gl);
|
|
114323
115535
|
gl.uniformMatrix4fv(shader.uniforms["mvpMtx"], false, m);
|
|
114324
115536
|
gl.uniform1f(shader.uniforms["opacity"], alpha);
|
|
@@ -114345,8 +115557,13 @@ Niivue.prototype.drawCrosshairs3D = function(isDepthTest = true, alpha = 1, mvpM
|
|
|
114345
115557
|
gl.deleteBuffer(this.crosshairs3D.indexBuffer);
|
|
114346
115558
|
gl.deleteBuffer(this.crosshairs3D.vertexBuffer);
|
|
114347
115559
|
}
|
|
114348
|
-
let
|
|
114349
|
-
|
|
115560
|
+
let [mn, mx, range] = this.sceneExtentsMinMax();
|
|
115561
|
+
let radius = 1;
|
|
115562
|
+
if (this.volumes.length > 0)
|
|
115563
|
+
radius = 0.5 * Math.min(Math.min(this.back.pixDims[1], this.back.pixDims[2]), this.back.pixDims[3]);
|
|
115564
|
+
else if (range[0] < 50 || range[0] > 1e3)
|
|
115565
|
+
radius = range[0] * 0.02;
|
|
115566
|
+
this.crosshairs3D = NiivueObject3D.generateCrosshairs(this.gl, 1, mm, mn, mx, radius);
|
|
114350
115567
|
this.crosshairs3D.mm = mm;
|
|
114351
115568
|
}
|
|
114352
115569
|
let crosshairsShader = this.surfaceShader;
|
|
@@ -114373,6 +115590,14 @@ Niivue.prototype.drawCrosshairs3D = function(isDepthTest = true, alpha = 1, mvpM
|
|
|
114373
115590
|
gl.bindVertexArray(this.unusedVAO);
|
|
114374
115591
|
};
|
|
114375
115592
|
Niivue.prototype.mm2frac = function(mm, volIdx = 0) {
|
|
115593
|
+
if (this.volumes.length < 1) {
|
|
115594
|
+
let frac2 = [0.1, 0.5, 0.5];
|
|
115595
|
+
let [mn, mx, range] = this.sceneExtentsMinMax();
|
|
115596
|
+
frac2[0] = (mm[0] - mn[0]) / range[0];
|
|
115597
|
+
frac2[1] = (mm[1] - mn[1]) / range[1];
|
|
115598
|
+
frac2[2] = (mm[2] - mn[2]) / range[2];
|
|
115599
|
+
return frac2;
|
|
115600
|
+
}
|
|
114376
115601
|
let mm4 = fromValues(mm[0], mm[1], mm[2], 1);
|
|
114377
115602
|
let d = this.volumes[volIdx].dimsRAS;
|
|
114378
115603
|
let frac = [0, 0, 0];
|
|
@@ -114416,7 +115641,15 @@ Niivue.prototype.moveCrosshairInVox = function(x2, y, z) {
|
|
|
114416
115641
|
};
|
|
114417
115642
|
Niivue.prototype.frac2mm = function(frac, volIdx = 0) {
|
|
114418
115643
|
let pos = fromValues(frac[0], frac[1], frac[2], 1);
|
|
114419
|
-
|
|
115644
|
+
if (this.volumes.length > 0)
|
|
115645
|
+
transformMat4(pos, pos, this.volumes[volIdx].frac2mm);
|
|
115646
|
+
else {
|
|
115647
|
+
let [mn, mx] = this.sceneExtentsMinMax();
|
|
115648
|
+
const lerp2 = (x2, y, a) => x2 * (1 - a) + y * a;
|
|
115649
|
+
pos[0] = lerp2(mn[0], mx[0], frac[0]);
|
|
115650
|
+
pos[1] = lerp2(mn[1], mx[1], frac[1]);
|
|
115651
|
+
pos[2] = lerp2(mn[2], mx[2], frac[2]);
|
|
115652
|
+
}
|
|
114420
115653
|
return pos;
|
|
114421
115654
|
};
|
|
114422
115655
|
Niivue.prototype.screenXY2TextureFrac = function(x2, y, i2) {
|
|
@@ -114478,15 +115711,17 @@ Niivue.prototype.canvasPos2frac = function(canvasPos) {
|
|
|
114478
115711
|
}
|
|
114479
115712
|
return [-1, -1, -1];
|
|
114480
115713
|
};
|
|
114481
|
-
Niivue.prototype.scaleSlice = function(w, h) {
|
|
114482
|
-
let
|
|
114483
|
-
|
|
114484
|
-
|
|
115714
|
+
Niivue.prototype.scaleSlice = function(w, h, widthPadPixels = 0, heightPadPixels = 0) {
|
|
115715
|
+
let canvasW = this.gl.canvas.clientWidth - widthPadPixels;
|
|
115716
|
+
let canvasH = this.effectiveCanvasHeight() - heightPadPixels;
|
|
115717
|
+
let scalePix = canvasW / w;
|
|
115718
|
+
if (h * scalePix > canvasH)
|
|
115719
|
+
scalePix = canvasH / h;
|
|
114485
115720
|
let wPix = w * scalePix;
|
|
114486
115721
|
let hPix = h * scalePix;
|
|
114487
115722
|
let leftTopWidthHeight = [
|
|
114488
|
-
(
|
|
114489
|
-
(
|
|
115723
|
+
(canvasW - wPix) * 0.5,
|
|
115724
|
+
(canvasH - hPix) * 0.5,
|
|
114490
115725
|
wPix,
|
|
114491
115726
|
hPix
|
|
114492
115727
|
];
|
|
@@ -114825,7 +116060,7 @@ Niivue.prototype.drawScene = function() {
|
|
|
114825
116060
|
}
|
|
114826
116061
|
this.colorbarHeight = 0;
|
|
114827
116062
|
this.gl.clearColor(this.opts.backColor[0], this.opts.backColor[1], this.opts.backColor[2], this.opts.backColor[3]);
|
|
114828
|
-
this.gl.clear(this.gl.COLOR_BUFFER_BIT);
|
|
116063
|
+
this.gl.clear(this.gl.COLOR_BUFFER_BIT | this.gl.DEPTH_BUFFER_BIT);
|
|
114829
116064
|
if (this.bmpTexture) {
|
|
114830
116065
|
this.drawThumbnail();
|
|
114831
116066
|
return;
|
|
@@ -114876,11 +116111,12 @@ Niivue.prototype.drawScene = function() {
|
|
|
114876
116111
|
this.draw2D([0, 0, 0, 0], 2);
|
|
114877
116112
|
} else {
|
|
114878
116113
|
let { volScale, vox, longestAxis } = this.sliceScale();
|
|
114879
|
-
let
|
|
116114
|
+
let pad = this.opts.multiplanarPadPixels;
|
|
116115
|
+
let ltwh = this.scaleSlice(volScale[0] + volScale[1], volScale[1] + volScale[2], pad * 1, pad * 1);
|
|
114880
116116
|
let wX = ltwh[2] * volScale[0] / (volScale[0] + volScale[1]);
|
|
114881
|
-
let ltwh3x1 = this.scaleSlice(volScale[0] + volScale[0] + volScale[1], Math.max(volScale[1], volScale[2]));
|
|
116117
|
+
let ltwh3x1 = this.scaleSlice(volScale[0] + volScale[0] + volScale[1], Math.max(volScale[1], volScale[2]), pad * 2);
|
|
114882
116118
|
let mx = Math.max(Math.max(volScale[1], volScale[2]), volScale[0]);
|
|
114883
|
-
let ltwh4x1 = this.scaleSlice(volScale[0] + volScale[0] + volScale[1] + mx, mx);
|
|
116119
|
+
let ltwh4x1 = this.scaleSlice(volScale[0] + volScale[0] + volScale[1] + mx, mx, pad * 3);
|
|
114884
116120
|
let wX1 = ltwh3x1[2] * volScale[0] / (volScale[0] + volScale[0] + volScale[1]);
|
|
114885
116121
|
if (wX1 > wX && !this.graph.autoSizeMultiplanar) {
|
|
114886
116122
|
let pixScale = wX1 / volScale[0];
|
|
@@ -114889,24 +116125,24 @@ Niivue.prototype.drawScene = function() {
|
|
|
114889
116125
|
if (ltwh3x1[3] === ltwh4x1[3]) {
|
|
114890
116126
|
ltwh3x1 = ltwh4x1;
|
|
114891
116127
|
this.draw3D([
|
|
114892
|
-
ltwh3x1[0] + wX1 + wX1 + hY1,
|
|
116128
|
+
ltwh3x1[0] + wX1 + wX1 + hY1 + pad * 3,
|
|
114893
116129
|
ltwh3x1[1],
|
|
114894
116130
|
ltwh4x1[3],
|
|
114895
116131
|
ltwh4x1[3]
|
|
114896
116132
|
]);
|
|
114897
116133
|
}
|
|
114898
116134
|
this.draw2D([ltwh3x1[0], ltwh3x1[1], wX1, hY1], 0);
|
|
114899
|
-
this.draw2D([ltwh3x1[0] + wX1, ltwh3x1[1], wX1, hZ1], 1);
|
|
114900
|
-
this.draw2D([ltwh3x1[0] + wX1 + wX1, ltwh3x1[1], hY1, hZ1], 2);
|
|
116135
|
+
this.draw2D([ltwh3x1[0] + wX1 + pad, ltwh3x1[1], wX1, hZ1], 1);
|
|
116136
|
+
this.draw2D([ltwh3x1[0] + wX1 + wX1 + pad * 2, ltwh3x1[1], hY1, hZ1], 2);
|
|
114901
116137
|
} else {
|
|
114902
116138
|
let wY = ltwh[2] - wX;
|
|
114903
116139
|
let hY = ltwh[3] * volScale[1] / (volScale[1] + volScale[2]);
|
|
114904
116140
|
let hZ = ltwh[3] - hY;
|
|
114905
|
-
this.draw2D([ltwh[0], ltwh[1] + hZ, wX, hY], 0);
|
|
116141
|
+
this.draw2D([ltwh[0], ltwh[1] + hZ + pad, wX, hY], 0);
|
|
114906
116142
|
this.draw2D([ltwh[0], ltwh[1], wX, hZ], 1);
|
|
114907
|
-
this.draw2D([ltwh[0] + wX, ltwh[1], wY, hZ], 2);
|
|
116143
|
+
this.draw2D([ltwh[0] + wX + pad, ltwh[1], wY, hZ], 2);
|
|
114908
116144
|
if (!this.graph.autoSizeMultiplanar)
|
|
114909
|
-
this.draw3D([ltwh[0] + wX, ltwh[1] + hZ, wY, hY]);
|
|
116145
|
+
this.draw3D([ltwh[0] + wX + pad, ltwh[1] + hZ + pad, wY, hY]);
|
|
114910
116146
|
}
|
|
114911
116147
|
}
|
|
114912
116148
|
}
|