Skip to content

Get mesh3d vertexcolor in a working state! #1686

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 16, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/traces/mesh3d/attributes.js
Original file line number Diff line number Diff line change
@@ -125,7 +125,7 @@ module.exports = {
description: 'Sets the color of the whole mesh'
},
vertexcolor: {
valType: 'data_array', // FIXME: this should be a color array
valType: 'data_array',
role: 'style',
description: [
'Sets the color of each vertex',
2 changes: 1 addition & 1 deletion src/traces/mesh3d/convert.js
Original file line number Diff line number Diff line change
@@ -127,7 +127,7 @@ proto.update = function(data) {
config.colormap = parseColorScale(data.colorscale);
}
else if(data.vertexcolor) {
this.color = data.vertexcolors[0];
this.color = data.vertexcolor[0];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😮

config.vertexColors = parseColorArray(data.vertexcolor);
}
else if(data.facecolor) {
4 changes: 2 additions & 2 deletions src/traces/mesh3d/defaults.js
Original file line number Diff line number Diff line change
@@ -82,8 +82,8 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout
else {
traceOut.showscale = false;

if('vertexcolor' in traceIn) coerce('vertexcolor');
else if('facecolor' in traceIn) coerce('facecolor');
if('facecolor' in traceIn) coerce('facecolor');
else if('vertexcolor' in traceIn) coerce('vertexcolor');
else coerce('color', defaultColor);
}

Binary file removed test/image/baselines/gl3d_tet.png
Binary file not shown.
Binary file removed test/image/baselines/gl3d_tet_colorscale.png
Binary file not shown.
Binary file added test/image/baselines/gl3d_tetrahedra.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
30 changes: 0 additions & 30 deletions test/image/mocks/gl3d_tet.json

This file was deleted.

22 changes: 0 additions & 22 deletions test/image/mocks/gl3d_tet_colorscale.json

This file was deleted.

87 changes: 87 additions & 0 deletions test/image/mocks/gl3d_tetrahedra.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
{
"data": [
{
"type":"mesh3d",
"name": "colorscale + intensity",
"x":[0, 1, 2, 0],
"y":[0, 0, 1, 2],
"z":[0, 2, 0, 1],
"i":[0, 0, 0, 1],
"j":[1, 2, 3, 2],
"k":[2, 3, 1, 3],
"colorscale": [
[0, "rgb(0, 0, 0)"],
[0.33, "rgb(255, 0, 0)"],
[0.66, "rgb(0, 255, 0)"],
[1, "rgb(0, 0, 255)"]
],
"intensity": [0, 0.33, 0.66, 1],
"colorbar": {
"x": 0,
"title": "for colorscale + intensity tetrahedra",
"titleside": "right"
}
},
{
"type":"mesh3d",
"name": "facecolor",
"x":[3, 4, 5, 3],
"y":[0, 0, 1, 2],
"z":[0, 2, 0, 1],
"i":[0, 0, 0, 1],
"j":[1, 2, 3, 2],
"k":[2, 3, 1, 3],
"facecolor": [
"rgb(0, 0, 0)",
"rgb(255, 0, 0)",
"rgb(0, 255, 0)",
"rgb(0, 0, 255)"
]
},
{
"type":"mesh3d",
"name": "vertexcolor",
"x":[6, 7, 8, 6],
"y":[0, 0, 1, 2],
"z":[0, 2, 0, 1],
"i":[0, 0, 0, 1],
"j":[1, 2, 3, 2],
"k":[2, 3, 1, 3],
"vertexcolor": [
"rgb(0, 0, 0)",
"rgb(255, 0, 0)",
"rgb(0, 255, 0)",
"rgb(0, 0, 255)"
]
},
{
"type":"mesh3d",
"name": "color",
"x":[9, 10, 11, 9],
"y":[0, 0, 1, 2],
"z":[0, 2, 0, 1],
"i":[0, 0, 0, 1],
"j":[1, 2, 3, 2],
"k":[2, 3, 1, 3],
"color": "rgb(0, 255, 0)"
}
],
"layout": {
"title": "Tetrahedra",
"scene": {
"aspectratio": {
"x": 5,
"y": 1,
"z": 1
},
"camera": {
"eye": {
"x": 0,
"y": -3,
"z": 1.8
}
}
},
"width": 1000
}
}