1
0
Pārlūkot izejas kodu

Updated Wave to add Slicebox

Raghav Arora 6 gadi atpakaļ
vecāks
revīzija
70d227f1dd
1 mainītis faili ar 140 papildinājumiem un 6 dzēšanām
  1. 140 6
      nova/static/js/wave/volumeRaycaster.js

+ 140 - 6
nova/static/js/wave/volumeRaycaster.js

@@ -419,6 +419,16 @@ var Core = function(conf) {
     this.isStatsOn = false;
     this._isRotate = false;
 
+    // Zoom Box parameters
+    this._zoom_parameters = {
+        xmin: 0.0,
+        xmax: 1.0,
+        ymin: 0.0,
+        ymax: 1.0,
+        zmin: 0.0,
+        zmax: 1.0
+    }
+
     // USCT Parameters
     // Slowly need to deprecate this section; can be generalized into rgb.
     this.l = conf.l;
@@ -576,10 +586,10 @@ Core.prototype.init = function() {
     this._controls.panSpeed = 2.0;
 
     this._controls.noZoom = false;
-    this._controls.noPan = false;
+    this._controls.noPan = true;
 
     this._controls.staticMoving = true;
-    this._controls.dynamicDampingFactor = 0.3;
+    this._controls.dynamicDampingFactor = 0.1;
 
     this._controls.autoRotate = true;
 
@@ -700,7 +710,6 @@ Core.prototype.init = function() {
         this._sceneSecondPass.add(this._meshSecondPass);
         //this._sceneSecondPass.add(this._axes);
 
-
         var mesh = new THREE.Mesh(
             new THREE.BoxGeometry( 1, 1, 1 ),
             new THREE.MeshNormalMaterial()
@@ -709,6 +718,14 @@ Core.prototype.init = function() {
         this._wireframe.material.color.set( 0xe3e3e3 );
         this._sceneSecondPass.add( this._wireframe );
 
+        var mesh_zoom = new THREE.Mesh(
+            new THREE.BoxGeometry( 1.0, 1.0, 1.0 ),
+            new THREE.MeshNormalMaterial()
+        );
+        this._wireframe_zoom = new THREE.BoxHelper( mesh_zoom );
+        this._wireframe_zoom.material.color.set( 0x0000ff );
+        this._sceneSecondPass.add( this._wireframe_zoom );
+
         var sphere = new THREE.SphereGeometry( 0.1 );
         this._light1 = new THREE.PointLight( 0xff0040, 2, 50 );
         this._light1.add( new THREE.Mesh( sphere, new THREE.MeshBasicMaterial( { color: 0xff0040 } ) ) );
@@ -747,10 +764,11 @@ Core.prototype.init = function() {
     // TODO: only when transfer function is required.
     //this.setTransferFunctionByColors(this._transfer_function_colors);
 
-    // Arrow Helper
     /*
+    // Arrow Helper
     var xdir = new THREE.Vector3( 1, 0, 0 );
     var xorigin = new THREE.Vector3( -0.8, -0.5, 0.5 );
+    //var xorigin = new THREE.Vector3( 0.0, 0.0, 0.0 );
     var xlength = 0.2;
     var xhex = 0xff0000;
     var xarrowHelper = new THREE.ArrowHelper( xdir, xorigin, xlength, xhex );
@@ -835,6 +853,74 @@ Core.prototype.init = function() {
 };
 
 
+/**
+ * API
+ *
+ **/
+Core.prototype._setUpBox = function(parameters) {
+    width = parameters.xmax - parameters.xmin;
+    height = parameters.ymax - parameters.ymin;
+    depth = parameters.zmax - parameters.zmin;
+    this._wireframe_zoom.scale.x = width;
+    this._wireframe_zoom.scale.y = height;
+    this._wireframe_zoom.scale.z = depth;
+    this._wireframe_zoom.position.x = (parameters.xmax - 0.5) - (width / 2.0 );
+    this._wireframe_zoom.position.y = (parameters.ymax - 0.5) - (height / 2.0 );
+    this._wireframe_zoom.position.z = (parameters.zmax - 0.5) - (depth / 2.0 );
+};
+
+
+Core.prototype.setZoomColor = function(value) {
+    this._wireframe_zoom.material.color.set( value );
+};
+
+
+Core.prototype.setZoomXMinValue = function(value) {
+    this._zoom_parameters.xmin = value;
+    this._setUpBox( this._zoom_parameters );
+};
+
+
+Core.prototype.setZoomXMaxValue = function(value) {
+    this._zoom_parameters.xmax = value;
+    this._setUpBox( this._zoom_parameters );
+};
+
+
+Core.prototype.setZoomYMinValue = function(value) {
+    this._zoom_parameters.ymin = value;
+    this._setUpBox( this._zoom_parameters );
+};
+
+
+Core.prototype.setZoomYMaxValue = function(value) {
+    this._zoom_parameters.ymax = value;
+    this._setUpBox( this._zoom_parameters );
+};
+
+
+Core.prototype.setZoomZMinValue = function(value) {
+    this._zoom_parameters.zmin = value;
+    this._setUpBox( this._zoom_parameters );
+};
+
+
+Core.prototype.setZoomZMaxValue = function(value) {
+    this._zoom_parameters.zmax = value;
+    this._setUpBox( this._zoom_parameters );
+};
+
+
+Core.prototype.showZoomBox = function(value) {
+    if (value == true) {
+        this._sceneSecondPass.add( this._wireframe_zoom );
+    } else {
+        this._sceneSecondPass.remove( this._wireframe_zoom );
+    }
+    this._render.render( this._sceneSecondPass, this._camera );
+};
+
+
 Core.prototype._secondPassSetUniformValue = function(key, value) {
     this._materialSecondPass.uniforms[key].value = value;
 };
@@ -5062,6 +5148,7 @@ window.VRC.Core.prototype._shaders.secondPassStevenTri = {
         var me = {};
 
         me._token;
+        me._token_array = [];
 
         me._needRedraw = true;
 
@@ -5091,6 +5178,10 @@ window.VRC.Core.prototype._shaders.secondPassStevenTri = {
                 me._needRedraw = true;
                 me.isChange = true;
                 clearInterval(me._token);
+                for (i = 0; i < me._token_array.length; i++) {
+                    clearInterval(me._token_array[i]);
+                }
+                me._token_array = [];
             });
 
             me.addCallback("onCameraChangeEnd", function() {
@@ -5098,9 +5189,12 @@ window.VRC.Core.prototype._shaders.secondPassStevenTri = {
                     me._needRedraw = false;
                     me.isChange = false;
                     console.log("WAVE: stop()");
-                    clearInterval(me._token);
+                    for (i = 0; i < me._token_array.length; i++) {
+                        clearInterval(me._token_array[i]);
+                    }
+                    me._token_array = [];
                 }, 1000);
-
+                me._token_array.push(me._token);
             });
 
 
@@ -5520,6 +5614,46 @@ window.VRC.Core.prototype._shaders.secondPassStevenTri = {
 
         };
 
+        me.setZoomColor = function(value) {
+            me._core.setZoomColor(value);
+            me._needRedraw = true;
+        };
+
+        me.setZoomXMinValue = function(value) {
+            me._core.setZoomXMinValue(value);
+            me._needRedraw = true;
+        };
+
+        me.setZoomXMaxValue = function(value) {
+            me._core.setZoomXMaxValue(value);
+            me._needRedraw = true;
+        };
+
+        me.setZoomYMinValue = function(value) {
+            me._core.setZoomYMinValue(value);
+            me._needRedraw = true;
+        };
+
+        me.setZoomYMaxValue = function(value) {
+            me._core.setZoomYMaxValue(value);
+            me._needRedraw = true;
+        };
+
+        me.setZoomZMinValue = function(value) {
+            me._core.setZoomZMinValue(value);
+            me._needRedraw = true;
+        };
+
+        me.setZoomZMaxValue = function(value) {
+            me._core.setZoomZMaxValue(value);
+            me._needRedraw = true;
+        };
+
+        me.showZoomBox = function(value) {
+            me._core.showZoomBox(value);
+            me._needRedraw = true;
+        };
+
         me.setGrayMinValue = function(value) {
             if(value > 1.0 || value < 0.0) {
                 throw Error("Gray value should be in range [0.0 - 1.0] !");