Skip to content

Commit 65a5806

Browse files
committed
revised code after 1st review 3369
1 parent e531e4e commit 65a5806

File tree

3 files changed

+37
-20
lines changed

3 files changed

+37
-20
lines changed

package-lock.json

Lines changed: 11 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/traces/mesh3d/convert.js

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -71,19 +71,21 @@ proto.update = function(data) {
7171
var positions = zip3(
7272
toDataCoords(layout.xaxis, data.x, scene.dataScale[0], data.xcalendar),
7373
toDataCoords(layout.yaxis, data.y, scene.dataScale[1], data.ycalendar),
74-
toDataCoords(layout.zaxis, data.z, scene.dataScale[2], data.zcalendar));
74+
toDataCoords(layout.zaxis, data.z, scene.dataScale[2], data.zcalendar)
75+
);
7576

7677
var cells;
7778
if(data.i && data.j && data.k) {
78-
cells = zip3(data.i, data.j, data.k);
79-
}
80-
else if(data.alphahull === 0) {
79+
cells = zip3(
80+
data.i.map(function(e) { return Math.round(e); }),
81+
data.j.map(function(e) { return Math.round(e); }),
82+
data.k.map(function(e) { return Math.round(e); })
83+
);
84+
} else if(data.alphahull === 0) {
8185
cells = convexHull(positions);
82-
}
83-
else if(data.alphahull > 0) {
86+
} else if(data.alphahull > 0) {
8487
cells = alphaShape(data.alphahull, positions);
85-
}
86-
else {
88+
} else {
8789
var d = ['x', 'y', 'z'].indexOf(data.delaunayaxis);
8890
cells = triangulate(positions.map(function(c) {
8991
return [c[(d + 1) % 3], c[(d + 2) % 3]];
@@ -113,16 +115,13 @@ proto.update = function(data) {
113115
config.vertexIntensity = data.intensity;
114116
config.vertexIntensityBounds = [data.cmin, data.cmax];
115117
config.colormap = parseColorScale(data.colorscale);
116-
}
117-
else if(data.vertexcolor) {
118+
} else if(data.vertexcolor) {
118119
this.color = data.vertexcolor[0];
119120
config.vertexColors = parseColorArray(data.vertexcolor);
120-
}
121-
else if(data.facecolor) {
121+
} else if(data.facecolor) {
122122
this.color = data.facecolor[0];
123123
config.cellColors = parseColorArray(data.facecolor);
124-
}
125-
else {
124+
} else {
126125
this.color = data.color;
127126
config.meshColor = str2RgbaArray(data.color);
128127
}

src/traces/mesh3d/defaults.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,23 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout
3434
}
3535

3636
var coords = readComponents(['x', 'y', 'z']);
37-
readComponents(['i', 'j', 'k']);
38-
3937
if(!coords) {
4038
traceOut.visible = false;
4139
return;
4240
}
41+
var numVertices = coords[0].length;
42+
43+
var indices = readComponents(['i', 'j', 'k']);
44+
if(indices) {
45+
indices.forEach(function(arr) {
46+
for(var i = 0; i < arr.length; ++i) {
47+
if(!Lib.isIndex(arr, numVertices)) {
48+
traceOut.visible = false;
49+
return;
50+
}
51+
}
52+
});
53+
}
4354

4455
var handleCalendarDefaults = Registry.getComponentMethod('calendars', 'handleTraceDefaults');
4556
handleCalendarDefaults(traceIn, traceOut, ['x', 'y', 'z'], layout);

0 commit comments

Comments
 (0)