Skip to content

Commit c80aee1

Browse files
authored
Merge pull request #1686 from plotly/fix-mesh3d-vertexcolor
Get mesh3d vertexcolor in a working state!
2 parents 2e0cca1 + 14d0776 commit c80aee1

File tree

9 files changed

+91
-56
lines changed

9 files changed

+91
-56
lines changed

src/traces/mesh3d/attributes.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ module.exports = {
125125
description: 'Sets the color of the whole mesh'
126126
},
127127
vertexcolor: {
128-
valType: 'data_array', // FIXME: this should be a color array
128+
valType: 'data_array',
129129
role: 'style',
130130
description: [
131131
'Sets the color of each vertex',

src/traces/mesh3d/convert.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ proto.update = function(data) {
127127
config.colormap = parseColorScale(data.colorscale);
128128
}
129129
else if(data.vertexcolor) {
130-
this.color = data.vertexcolors[0];
130+
this.color = data.vertexcolor[0];
131131
config.vertexColors = parseColorArray(data.vertexcolor);
132132
}
133133
else if(data.facecolor) {

src/traces/mesh3d/defaults.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout
8282
else {
8383
traceOut.showscale = false;
8484

85-
if('vertexcolor' in traceIn) coerce('vertexcolor');
86-
else if('facecolor' in traceIn) coerce('facecolor');
85+
if('facecolor' in traceIn) coerce('facecolor');
86+
else if('vertexcolor' in traceIn) coerce('vertexcolor');
8787
else coerce('color', defaultColor);
8888
}
8989

test/image/baselines/gl3d_tet.png

-20.1 KB
Binary file not shown.
-41.5 KB
Binary file not shown.
48.4 KB
Loading

test/image/mocks/gl3d_tet.json

Lines changed: 0 additions & 30 deletions
This file was deleted.

test/image/mocks/gl3d_tet_colorscale.json

Lines changed: 0 additions & 22 deletions
This file was deleted.

test/image/mocks/gl3d_tetrahedra.json

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
{
2+
"data": [
3+
{
4+
"type":"mesh3d",
5+
"name": "colorscale + intensity",
6+
"x":[0, 1, 2, 0],
7+
"y":[0, 0, 1, 2],
8+
"z":[0, 2, 0, 1],
9+
"i":[0, 0, 0, 1],
10+
"j":[1, 2, 3, 2],
11+
"k":[2, 3, 1, 3],
12+
"colorscale": [
13+
[0, "rgb(0, 0, 0)"],
14+
[0.33, "rgb(255, 0, 0)"],
15+
[0.66, "rgb(0, 255, 0)"],
16+
[1, "rgb(0, 0, 255)"]
17+
],
18+
"intensity": [0, 0.33, 0.66, 1],
19+
"colorbar": {
20+
"x": 0,
21+
"title": "for colorscale + intensity tetrahedra",
22+
"titleside": "right"
23+
}
24+
},
25+
{
26+
"type":"mesh3d",
27+
"name": "facecolor",
28+
"x":[3, 4, 5, 3],
29+
"y":[0, 0, 1, 2],
30+
"z":[0, 2, 0, 1],
31+
"i":[0, 0, 0, 1],
32+
"j":[1, 2, 3, 2],
33+
"k":[2, 3, 1, 3],
34+
"facecolor": [
35+
"rgb(0, 0, 0)",
36+
"rgb(255, 0, 0)",
37+
"rgb(0, 255, 0)",
38+
"rgb(0, 0, 255)"
39+
]
40+
},
41+
{
42+
"type":"mesh3d",
43+
"name": "vertexcolor",
44+
"x":[6, 7, 8, 6],
45+
"y":[0, 0, 1, 2],
46+
"z":[0, 2, 0, 1],
47+
"i":[0, 0, 0, 1],
48+
"j":[1, 2, 3, 2],
49+
"k":[2, 3, 1, 3],
50+
"vertexcolor": [
51+
"rgb(0, 0, 0)",
52+
"rgb(255, 0, 0)",
53+
"rgb(0, 255, 0)",
54+
"rgb(0, 0, 255)"
55+
]
56+
},
57+
{
58+
"type":"mesh3d",
59+
"name": "color",
60+
"x":[9, 10, 11, 9],
61+
"y":[0, 0, 1, 2],
62+
"z":[0, 2, 0, 1],
63+
"i":[0, 0, 0, 1],
64+
"j":[1, 2, 3, 2],
65+
"k":[2, 3, 1, 3],
66+
"color": "rgb(0, 255, 0)"
67+
}
68+
],
69+
"layout": {
70+
"title": "Tetrahedra",
71+
"scene": {
72+
"aspectratio": {
73+
"x": 5,
74+
"y": 1,
75+
"z": 1
76+
},
77+
"camera": {
78+
"eye": {
79+
"x": 0,
80+
"y": -3,
81+
"z": 1.8
82+
}
83+
}
84+
},
85+
"width": 1000
86+
}
87+
}

0 commit comments

Comments
 (0)