@@ -40,6 +40,7 @@ export default class ModelsStack extends ModelsBase{
4040 this . _numberOfChannels = 1 ;
4141 this . _bitsAllocated = 8 ;
4242 this . _pixelType = 0 ;
43+ this . _pixelRepresentation = 0 ;
4344
4445 this . _textureSize = 4096 ;
4546 this . _nbTextures = 7 ; // HIGH RES..
@@ -476,6 +477,14 @@ export default class ModelsStack extends ModelsBase{
476477 data : null
477478 } ;
478479
480+ // transform signed to unsigned for convenience
481+ let offset = 0 ;
482+ if ( this . _minMax [ 0 ] < 0 ) {
483+
484+ offset -= this . _minMax [ 0 ] ;
485+
486+ }
487+
479488 let packIndex = 0 ;
480489 let frameIndex = 0 ;
481490 let inFrameIndex = 0 ;
@@ -492,12 +501,13 @@ export default class ModelsStack extends ModelsBase{
492501 inFrameIndex = i % ( frameDimension ) ;
493502 /*jshint bitwise: true*/
494503
495- data [ packIndex ] = frame [ frameIndex ] . pixelData [ inFrameIndex ] ;
504+ data [ packIndex ] = offset + frame [ frameIndex ] . pixelData [ inFrameIndex ] ;
496505 packIndex ++ ;
497506
498507 }
499508 packed . textureType = THREE . LuminanceFormat ;
500509 packed . data = data ;
510+ console . log ( data ) ;
501511
502512 } else if ( bits === 16 && channels === 1 ) {
503513
@@ -512,7 +522,7 @@ export default class ModelsStack extends ModelsBase{
512522 inFrameIndex = i % ( frameDimension ) ;
513523 /*jshint bitwise: true*/
514524
515- let raw = frame [ frameIndex ] . pixelData [ inFrameIndex ] ;
525+ let raw = offset + frame [ frameIndex ] . pixelData [ inFrameIndex ] ;
516526 data [ 4 * coordinate + 2 * channelOffset ] = raw & 0x00FF ;
517527 data [ 4 * coordinate + 2 * channelOffset + 1 ] = ( raw >>> 8 ) & 0x00FF ;
518528
@@ -537,7 +547,7 @@ export default class ModelsStack extends ModelsBase{
537547
538548 // slow!
539549 //let asb = VJS.core.pack.uint16ToAlphaLuminance(frame[frameIndex].pixelData[inFrameIndex]);
540- let raw = frame [ frameIndex ] . pixelData [ inFrameIndex ] ;
550+ let raw = offset + frame [ frameIndex ] . pixelData [ inFrameIndex ] ;
541551 data [ 4 * packIndex ] = raw & 0x000000FF ;
542552 data [ 4 * packIndex + 1 ] = ( raw >>> 8 ) & 0x000000FF ;
543553 data [ 4 * packIndex + 2 ] = ( raw >>> 8 ) & 0x000000FF ;
@@ -561,7 +571,7 @@ export default class ModelsStack extends ModelsBase{
561571
562572 // slow!
563573 //let asb = VJS.core.pack.uint16ToAlphaLuminance(frame[frameIndex].pixelData[inFrameIndex]);
564- let raw = frame [ frameIndex ] . pixelData [ inFrameIndex ] ;
574+ let raw = offset + frame [ frameIndex ] . pixelData [ inFrameIndex ] ;
565575 let bitString = binaryString ( raw ) ;
566576 let bitStringArray = bitString . match ( / .{ 1 , 8 } / g) ;
567577
@@ -956,6 +966,14 @@ export default class ModelsStack extends ModelsBase{
956966 this . _pixelType = pixelType ;
957967 }
958968
969+ get pixelRepresentation ( ) {
970+ return this . _pixelRepresentation ;
971+ }
972+
973+ set pixelRepresentation ( pixelRepresentation ) {
974+ this . _pixelRepresentation = pixelRepresentation ;
975+ }
976+
959977 set invert ( invert ) {
960978 this . _invert = invert ;
961979 }
0 commit comments