Skip to content

Commit 55700b8

Browse files
committed
add 'anchor' to mimic gl-cone3d's coneOffset
1 parent db8222b commit 55700b8

File tree

8 files changed

+21
-3
lines changed

8 files changed

+21
-3
lines changed

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070
"es6-promise": "^3.0.2",
7171
"fast-isnumeric": "^1.1.1",
7272
"font-atlas-sdf": "^1.3.3",
73-
"gl-cone3d": "[email protected]:gl-vis/gl-cone3d#c675b25e5991e63d0ad23ed24d712c496c28cd72",
73+
"gl-cone3d": "[email protected]:gl-vis/gl-cone3d#cc6c768d844d0c7ad7dc4dd0d2cdd71eadf92620",
7474
"gl-contour2d": "^1.1.4",
7575
"gl-error3d": "^1.0.7",
7676
"gl-heatmap2d": "^1.0.4",

src/traces/cone/attributes.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,19 @@ var attrs = {
103103
description: 'Sets the cone size reference value.'
104104
},
105105

106+
anchor: {
107+
valType: 'enumerated',
108+
role: 'info',
109+
editType: 'calc',
110+
values: ['tip', 'tail', 'cm', 'center'],
111+
dflt: 'cm',
112+
description: [
113+
'Sets the cones\' anchor with respect to their x/y/z positions.',
114+
'Note that *cm* denote the cone\'s center of mass with corresponds to',
115+
'1/4 from the tail to tip.'
116+
].join(' ')
117+
},
118+
106119
text: {
107120
valType: 'string',
108121
role: 'info',

src/traces/cone/convert.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ function zip3(x, y, z) {
5656

5757
var axisName2scaleIndex = {xaxis: 0, yaxis: 1, zaxis: 2};
5858
var sizeMode2sizeKey = {scaled: 'coneSize', absolute: 'absoluteConeSize'};
59+
var anchor2coneOffset = {tip: 1, tail: 0, cm: 0.25, center: 0.5};
5960

6061
function convert(scene, trace) {
6162
var sceneLayout = scene.fullSceneLayout;
@@ -92,6 +93,7 @@ function convert(scene, trace) {
9293
coneOpts.vertexIntensityBounds = [trace.cmin / trace.cmax, 1];
9394

9495
coneOpts[sizeMode2sizeKey[trace.sizemode]] = trace.sizeref;
96+
coneOpts.coneOffset = anchor2coneOffset[trace.anchor];
9597

9698
var meshOpts = conePlot(coneOpts);
9799
meshOpts._pts = coneOpts.positions;

src/traces/cone/defaults.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout
4242
coerce('sizeref');
4343
coerce('sizemode');
4444

45+
coerce('anchor');
46+
4547
// TODO do these attributes work?
4648
coerce('lighting.ambient');
4749
coerce('lighting.diffuse');
-84 Bytes
Loading
-7 Bytes
Loading

test/image/mocks/gl3d_cone-simple.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
"v": [0, 3, 0],
1010
"w": [0, 0, 2],
1111
"sizemode": "absolute",
12-
"sizeref": 2
12+
"sizeref": 2,
13+
"anchor": "tip"
1314
},
1415
{
1516
"type": "cone",

0 commit comments

Comments
 (0)