Skip to content

Commit

Permalink
use gl-cone3d picking instead of gl-scatter3d overlay
Browse files Browse the repository at this point in the history
  • Loading branch information
etpinard committed Jun 11, 2018
1 parent 3c7f125 commit 44093f3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 21 deletions.
20 changes: 1 addition & 19 deletions src/traces/cone/convert.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

'use strict';

var createScatterPlot = require('gl-scatter3d');
var conePlot = require('gl-cone3d');
var createConeMesh = require('gl-cone3d').createConeMesh;

Expand All @@ -19,14 +18,13 @@ function Cone(scene, uid) {
this.scene = scene;
this.uid = uid;
this.mesh = null;
this.pts = null;
this.data = null;
}

var proto = Cone.prototype;

proto.handlePick = function(selection) {
if(selection.object === this.pts) {
if(selection.object === this.mesh) {
var selectIndex = selection.index = selection.data.index;
var xx = this.data.x[selectIndex];
var yy = this.data.y[selectIndex];
Expand Down Expand Up @@ -96,8 +94,6 @@ function convert(scene, trace) {

var meshData = conePlot(coneOpts);

// stash positions for gl-scatter3d 'hover' trace
meshData._pts = coneOpts.positions;

// pass gl-mesh3d lighting attributes
meshData.lightPosition = [trace.lightposition.x, trace.lightposition.y, trace.lightposition.z];
Expand All @@ -119,14 +115,10 @@ proto.update = function(data) {
this.data = data;

var meshData = convert(this.scene, data);

this.mesh.update(meshData);
this.pts.update({position: meshData._pts});
};

proto.dispose = function() {
this.scene.glplot.remove(this.pts);
this.pts.dispose();
this.scene.glplot.remove(this.mesh);
this.mesh.dispose();
};
Expand All @@ -137,21 +129,11 @@ function createConeTrace(scene, data) {
var meshData = convert(scene, data);
var mesh = createConeMesh(gl, meshData);

var pts = createScatterPlot({
gl: gl,
position: meshData._pts,
project: false,
opacity: 0
});

var cone = new Cone(scene, data.uid);
cone.mesh = mesh;
cone.pts = pts;
cone.data = data;
mesh._trace = cone;
pts._trace = cone;

scene.glplot.add(pts);
scene.glplot.add(mesh);

return cone;
Expand Down
4 changes: 2 additions & 2 deletions test/jasmine/tests/cone_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,15 +209,15 @@ describe('@gl Test cone interactions', function() {
var scene = gd._fullLayout.scene._scene;
var objs = scene.glplot.objects;

expect(objs.length).toBe(4);
expect(objs.length).toBe(2);

return Plotly.deleteTraces(gd, [0]);
})
.then(function() {
var scene = gd._fullLayout.scene._scene;
var objs = scene.glplot.objects;

expect(objs.length).toBe(2);
expect(objs.length).toBe(1);

return Plotly.deleteTraces(gd, [0]);
})
Expand Down

0 comments on commit 44093f3

Please sign in to comment.