Skip to content

Commit

Permalink
add hover emissive effect for feature map (#205)
Browse files Browse the repository at this point in the history
  • Loading branch information
syt123450 committed Feb 10, 2019
1 parent 50b2138 commit c167f9d
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/elements/FeatureMap.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ FeatureMap.prototype = {
cube.elementType = "featureMap";
cube.hoverable = true;
cube.draggable = true;
cube.emissiveable = true;

cube.context = this;

this.featureMap = cube;

Expand Down
2 changes: 2 additions & 0 deletions src/tsp-model/AbstractModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ function AbstractModel( container, config ) {
*/

this.configuration = new ModelConfiguration( config );

this.hoveredEmissive = undefined;

// Pass configuration to three.js scene.

Expand Down
16 changes: 15 additions & 1 deletion src/tsp-model/Model.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,13 @@ Model.prototype = Object.assign( Object.create( AbstractModel.prototype ), {
model.hoveredLayer = undefined;

}

if ( model.hoveredEmissive !== undefined ) {

model.hoveredEmissive.context.darken();
model.hoveredEmissive = undefined;

}

// Use Raycaster to capture hovered element.

Expand All @@ -231,7 +238,14 @@ Model.prototype = Object.assign( Object.create( AbstractModel.prototype ), {
let selectedElement = intersects[ i ].object;

if ( selectedElement.hoverable === true ) {


if ( selectedElement.emissiveable ) {

model.hoveredEmissive = selectedElement;
selectedElement.context.emissive();

}

let selectedLayer = this.layers[ selectedElement.layerIndex ];

// Let the layer to handle actual hover event.
Expand Down
14 changes: 14 additions & 0 deletions src/tsp-model/Sequential.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,13 @@ Sequential.prototype = Object.assign( Object.create( AbstractModel.prototype ),
model.hoveredLayer = undefined;

}

if ( model.hoveredEmissive !== undefined ) {

model.hoveredEmissive.context.darken();
model.hoveredEmissive = undefined;

}

// Use Raycaster to capture hovered element.

Expand All @@ -202,6 +209,13 @@ Sequential.prototype = Object.assign( Object.create( AbstractModel.prototype ),

if ( selectedElement.hoverable === true ) {

if ( selectedElement.emissiveable ) {

model.hoveredEmissive = selectedElement;
selectedElement.context.emissive();

}

let selectedLayer = this.layers[ selectedElement.layerIndex - 1 ];

// Let the layer to handle actual hover event.
Expand Down

0 comments on commit c167f9d

Please # to comment.