66* LICENSE file in the root directory of this source tree.
77*/
88
9-
109'use strict' ;
1110
12- var createMesh = require ( 'gl-cone3d' ) . createConeMesh ;
11+ var createScatterPlot = require ( 'gl-scatter3d' ) ;
12+ var createConeMesh = require ( 'gl-cone3d' ) . createConeMesh ;
1313var cone2mesh = require ( './helpers' ) . cone2mesh ;
1414
15- function Mesh3DTrace ( scene , mesh , uid ) {
15+ function Cone ( scene , uid ) {
1616 this . scene = scene ;
1717 this . uid = uid ;
18- this . mesh = mesh ;
18+ this . mesh = null ;
19+ this . pts = null ;
1920 this . data = null ;
2021}
2122
22- var proto = Mesh3DTrace . prototype ;
23+ var proto = Cone . prototype ;
2324
2425proto . handlePick = function ( selection ) {
25- if ( selection . object === this . mesh ) {
26+ if ( selection . object === this . pts ) {
2627 var selectIndex = selection . index = selection . data . index ;
2728
2829 selection . traceCoordinate = [
@@ -48,25 +49,44 @@ function convert(scene, trace) {
4849
4950proto . update = function ( data ) {
5051 this . data = data ;
51- this . mesh . update ( convert ( this . scene , data ) ) ;
52+
53+ var meshData = convert ( this . scene , data ) ;
54+
55+ this . mesh . update ( meshData ) ;
56+ this . pts . update ( { position : meshData . _pts } ) ;
5257} ;
5358
5459proto . dispose = function ( ) {
60+ this . scene . glplot . remove ( this . pts ) ;
61+ this . pts . dispose ( ) ;
5562 this . scene . glplot . remove ( this . mesh ) ;
5663 this . mesh . dispose ( ) ;
5764} ;
5865
59- function createMesh3DTrace ( scene , data ) {
66+ function createConeTrace ( scene , data ) {
6067 var gl = scene . glplot . gl ;
61- var meshData = convert ( scene , data ) ;
62- var mesh = createMesh ( gl , meshData ) ;
63- var result = new Mesh3DTrace ( scene , mesh , data . uid ) ;
6468
65- result . data = data ;
66- mesh . _trace = result ;
69+ var meshData = convert ( scene , data ) ;
70+ var mesh = createConeMesh ( gl , meshData ) ;
71+
72+ var pts = createScatterPlot ( {
73+ gl : gl ,
74+ position : meshData . _pts ,
75+ project : false ,
76+ opacity : 0
77+ } ) ;
78+
79+ var cone = new Cone ( scene , data . uid ) ;
80+ cone . mesh = mesh ;
81+ cone . pts = pts ;
82+ cone . data = data ;
83+ mesh . _trace = cone ;
84+ pts . _trace = cone ;
85+
86+ scene . glplot . add ( pts ) ;
6787 scene . glplot . add ( mesh ) ;
6888
69- return result ;
89+ return cone ;
7090}
7191
72- module . exports = createMesh3DTrace ;
92+ module . exports = createConeTrace ;
0 commit comments