|
@@ -144,7 +144,7 @@ function Volume( xLength, yLength, zLength, type, arrayBuffer ) {
|
|
|
* @member {number} lowerThreshold The voxels with values under this threshold won't appear in the slices.
|
|
|
* If changed, geometryNeedsUpdate is automatically set to true on all the slices associated to this volume
|
|
|
*/
|
|
|
- var lowerThreshold = - Infinity;
|
|
|
+ let lowerThreshold = - Infinity;
|
|
|
Object.defineProperty( this, 'lowerThreshold', {
|
|
|
get: function () {
|
|
|
|
|
@@ -166,7 +166,7 @@ function Volume( xLength, yLength, zLength, type, arrayBuffer ) {
|
|
|
* @member {number} upperThreshold The voxels with values over this threshold won't appear in the slices.
|
|
|
* If changed, geometryNeedsUpdate is automatically set to true on all the slices associated to this volume
|
|
|
*/
|
|
|
- var upperThreshold = Infinity;
|
|
|
+ let upperThreshold = Infinity;
|
|
|
Object.defineProperty( this, 'upperThreshold', {
|
|
|
get: function () {
|
|
|
|
|
@@ -238,9 +238,9 @@ Volume.prototype = {
|
|
|
*/
|
|
|
reverseAccess: function ( index ) {
|
|
|
|
|
|
- var z = Math.floor( index / ( this.yLength * this.xLength ) );
|
|
|
- var y = Math.floor( ( index - z * this.yLength * this.xLength ) / this.xLength );
|
|
|
- var x = index - z * this.yLength * this.xLength - y * this.xLength;
|
|
|
+ const z = Math.floor( index / ( this.yLength * this.xLength ) );
|
|
|
+ const y = Math.floor( ( index - z * this.yLength * this.xLength ) / this.xLength );
|
|
|
+ const x = index - z * this.yLength * this.xLength - y * this.xLength;
|
|
|
return [ x, y, z ];
|
|
|
|
|
|
},
|
|
@@ -257,10 +257,10 @@ Volume.prototype = {
|
|
|
*/
|
|
|
map: function ( functionToMap, context ) {
|
|
|
|
|
|
- var length = this.data.length;
|
|
|
+ const length = this.data.length;
|
|
|
context = context || this;
|
|
|
|
|
|
- for ( var i = 0; i < length; i ++ ) {
|
|
|
+ for ( let i = 0; i < length; i ++ ) {
|
|
|
|
|
|
this.data[ i ] = functionToMap.call( context, this.data[ i ], i, this.data );
|
|
|
|
|
@@ -279,23 +279,18 @@ Volume.prototype = {
|
|
|
*/
|
|
|
extractPerpendicularPlane: function ( axis, RASIndex ) {
|
|
|
|
|
|
- var iLength,
|
|
|
- jLength,
|
|
|
- sliceAccess,
|
|
|
- planeMatrix = ( new Matrix4() ).identity(),
|
|
|
- volume = this,
|
|
|
- planeWidth,
|
|
|
- planeHeight,
|
|
|
- firstSpacing,
|
|
|
+ let firstSpacing,
|
|
|
secondSpacing,
|
|
|
positionOffset,
|
|
|
IJKIndex;
|
|
|
|
|
|
- var axisInIJK = new Vector3(),
|
|
|
+ const axisInIJK = new Vector3(),
|
|
|
firstDirection = new Vector3(),
|
|
|
- secondDirection = new Vector3();
|
|
|
+ secondDirection = new Vector3(),
|
|
|
+ planeMatrix = ( new Matrix4() ).identity(),
|
|
|
+ volume = this;
|
|
|
|
|
|
- var dimensions = new Vector3( this.xLength, this.yLength, this.zLength );
|
|
|
+ const dimensions = new Vector3( this.xLength, this.yLength, this.zLength );
|
|
|
|
|
|
|
|
|
switch ( axis ) {
|
|
@@ -340,50 +335,48 @@ Volume.prototype = {
|
|
|
}
|
|
|
|
|
|
firstDirection.applyMatrix4( volume.inverseMatrix ).normalize();
|
|
|
- firstDirection.argVar = 'i';
|
|
|
+ firstDirection.arglet = 'i';
|
|
|
secondDirection.applyMatrix4( volume.inverseMatrix ).normalize();
|
|
|
- secondDirection.argVar = 'j';
|
|
|
+ secondDirection.arglet = 'j';
|
|
|
axisInIJK.applyMatrix4( volume.inverseMatrix ).normalize();
|
|
|
- iLength = Math.floor( Math.abs( firstDirection.dot( dimensions ) ) );
|
|
|
- jLength = Math.floor( Math.abs( secondDirection.dot( dimensions ) ) );
|
|
|
- planeWidth = Math.abs( iLength * firstSpacing );
|
|
|
- planeHeight = Math.abs( jLength * secondSpacing );
|
|
|
+ const iLength = Math.floor( Math.abs( firstDirection.dot( dimensions ) ) );
|
|
|
+ const jLength = Math.floor( Math.abs( secondDirection.dot( dimensions ) ) );
|
|
|
+ const planeWidth = Math.abs( iLength * firstSpacing );
|
|
|
+ const planeHeight = Math.abs( jLength * secondSpacing );
|
|
|
|
|
|
IJKIndex = Math.abs( Math.round( IJKIndex.applyMatrix4( volume.inverseMatrix ).dot( axisInIJK ) ) );
|
|
|
- var base = [ new Vector3( 1, 0, 0 ), new Vector3( 0, 1, 0 ), new Vector3( 0, 0, 1 ) ];
|
|
|
- var iDirection = [ firstDirection, secondDirection, axisInIJK ].find( function ( x ) {
|
|
|
+ const base = [ new Vector3( 1, 0, 0 ), new Vector3( 0, 1, 0 ), new Vector3( 0, 0, 1 ) ];
|
|
|
+ const iDirection = [ firstDirection, secondDirection, axisInIJK ].find( function ( x ) {
|
|
|
|
|
|
return Math.abs( x.dot( base[ 0 ] ) ) > 0.9;
|
|
|
|
|
|
} );
|
|
|
- var jDirection = [ firstDirection, secondDirection, axisInIJK ].find( function ( x ) {
|
|
|
+ const jDirection = [ firstDirection, secondDirection, axisInIJK ].find( function ( x ) {
|
|
|
|
|
|
return Math.abs( x.dot( base[ 1 ] ) ) > 0.9;
|
|
|
|
|
|
} );
|
|
|
- var kDirection = [ firstDirection, secondDirection, axisInIJK ].find( function ( x ) {
|
|
|
+ const kDirection = [ firstDirection, secondDirection, axisInIJK ].find( function ( x ) {
|
|
|
|
|
|
return Math.abs( x.dot( base[ 2 ] ) ) > 0.9;
|
|
|
|
|
|
} );
|
|
|
|
|
|
- sliceAccess = function ( i, j ) {
|
|
|
-
|
|
|
- var accessI, accessJ, accessK;
|
|
|
+ function sliceAccess( i, j ) {
|
|
|
|
|
|
- var si = ( iDirection === axisInIJK ) ? IJKIndex : ( iDirection.argVar === 'i' ? i : j );
|
|
|
- var sj = ( jDirection === axisInIJK ) ? IJKIndex : ( jDirection.argVar === 'i' ? i : j );
|
|
|
- var sk = ( kDirection === axisInIJK ) ? IJKIndex : ( kDirection.argVar === 'i' ? i : j );
|
|
|
+ const si = ( iDirection === axisInIJK ) ? IJKIndex : ( iDirection.arglet === 'i' ? i : j );
|
|
|
+ const sj = ( jDirection === axisInIJK ) ? IJKIndex : ( jDirection.arglet === 'i' ? i : j );
|
|
|
+ const sk = ( kDirection === axisInIJK ) ? IJKIndex : ( kDirection.arglet === 'i' ? i : j );
|
|
|
|
|
|
// invert indices if necessary
|
|
|
|
|
|
- var accessI = ( iDirection.dot( base[ 0 ] ) > 0 ) ? si : ( volume.xLength - 1 ) - si;
|
|
|
- var accessJ = ( jDirection.dot( base[ 1 ] ) > 0 ) ? sj : ( volume.yLength - 1 ) - sj;
|
|
|
- var accessK = ( kDirection.dot( base[ 2 ] ) > 0 ) ? sk : ( volume.zLength - 1 ) - sk;
|
|
|
+ const accessI = ( iDirection.dot( base[ 0 ] ) > 0 ) ? si : ( volume.xLength - 1 ) - si;
|
|
|
+ const accessJ = ( jDirection.dot( base[ 1 ] ) > 0 ) ? sj : ( volume.yLength - 1 ) - sj;
|
|
|
+ const accessK = ( kDirection.dot( base[ 2 ] ) > 0 ) ? sk : ( volume.zLength - 1 ) - sk;
|
|
|
|
|
|
return volume.access( accessI, accessJ, accessK );
|
|
|
|
|
|
- };
|
|
|
+ }
|
|
|
|
|
|
return {
|
|
|
iLength: iLength,
|
|
@@ -406,7 +399,7 @@ Volume.prototype = {
|
|
|
*/
|
|
|
extractSlice: function ( axis, index ) {
|
|
|
|
|
|
- var slice = new VolumeSlice( this, index, axis );
|
|
|
+ const slice = new VolumeSlice( this, index, axis );
|
|
|
this.sliceList.push( slice );
|
|
|
return slice;
|
|
|
|
|
@@ -437,19 +430,19 @@ Volume.prototype = {
|
|
|
*/
|
|
|
computeMinMax: function () {
|
|
|
|
|
|
- var min = Infinity;
|
|
|
- var max = - Infinity;
|
|
|
+ let min = Infinity;
|
|
|
+ let max = - Infinity;
|
|
|
|
|
|
// buffer the length
|
|
|
- var datasize = this.data.length;
|
|
|
+ const datasize = this.data.length;
|
|
|
|
|
|
- var i = 0;
|
|
|
+ let i = 0;
|
|
|
|
|
|
for ( i = 0; i < datasize; i ++ ) {
|
|
|
|
|
|
if ( ! isNaN( this.data[ i ] ) ) {
|
|
|
|
|
|
- var value = this.data[ i ];
|
|
|
+ const value = this.data[ i ];
|
|
|
min = Math.min( min, value );
|
|
|
max = Math.max( max, value );
|
|
|
|