Skip to content

Commit d81c352

Browse files
committed
Make vertexnormalsepsilon and facenormalsepsilon specific to mesh3d
Set a different default light position for surface vs mesh
1 parent 401d3c3 commit d81c352

File tree

3 files changed

+34
-19
lines changed

3 files changed

+34
-19
lines changed

src/traces/mesh3d/attributes.js

+23-2
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,29 @@ module.exports = {
124124
reversescale: colorscaleAttrs.reversescale,
125125
showscale: colorscaleAttrs.showscale,
126126

127-
lightposition: extendFlat({}, surfaceAtts.lightposition),
128-
lighting: extendFlat({}, surfaceAtts.lighting),
127+
lightposition: {
128+
'x': extendFlat({}, surfaceAtts.lightposition.x, {dflt: 1e5}),
129+
'y': extendFlat({}, surfaceAtts.lightposition.y, {dflt: 1e5}),
130+
'z': extendFlat({}, surfaceAtts.lightposition.z, {dflt: 0})
131+
},
132+
lighting: extendFlat({}, {
133+
vertexnormalsepsilon: {
134+
valType: 'number',
135+
role: 'style',
136+
min: 0.00,
137+
max: 1,
138+
dflt: 1e-12, // otherwise finely tessellated things eg. the brain will have no specular light reflection
139+
description: 'Epsilon for vertex normals calculation avoids math issues arising from degenerate geometry.'
140+
},
141+
facenormalsepsilon: {
142+
valType: 'number',
143+
role: 'style',
144+
min: 0.00,
145+
max: 1,
146+
dflt: 1e-6, // even the brain model doesn't appear to need finer than this
147+
description: 'Epsilon for face normals calculation avoids math issues arising from degenerate geometry.'
148+
}
149+
}, surfaceAtts.lighting),
129150

130151
_nestedModules: { // nested module coupling
131152
'colorbar': 'Colorbar'

src/traces/surface/attributes.js

+1-17
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ module.exports = {
153153
role: 'style',
154154
min: -1e5,
155155
max: 1e5,
156-
dflt: 1e5,
156+
dflt: 10,
157157
description: 'Numeric vector, representing the X coordinate for each vertex.'
158158
},
159159
y: {
@@ -217,22 +217,6 @@ module.exports = {
217217
'Represents the reflectance as a dependency of the viewing angle; e.g. paper is reflective',
218218
'when viewing it from the edge of the paper (almost 90 degrees), causing shine.'
219219
].join(' ')
220-
},
221-
vertexnormalsepsilon: {
222-
valType: 'number',
223-
role: 'style',
224-
min: 0.00,
225-
max: 1,
226-
dflt: 1e-12, // otherwise finely tessellated things eg. the brain will have no specular light reflection
227-
description: 'Epsilon for vertex normals calculation avoids math issues arising from degenerate geometry.'
228-
},
229-
facenormalsepsilon: {
230-
valType: 'number',
231-
role: 'style',
232-
min: 0.00,
233-
max: 1,
234-
dflt: 1e-6, // even the brain model doesn't appear to need finer than this
235-
description: 'Epsilon for face normals calculation avoids math issues arising from degenerate geometry.'
236220
}
237221
},
238222

src/traces/surface/convert.js

+10
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,16 @@ proto.update = function(data) {
334334
surface.fresnel = data.lighting.fresnel;
335335
}
336336

337+
if('lightposition' in data) {
338+
if(surface.lightPosition === void(0)) {
339+
surface.lightPosition = [data.lightposition.x, data.lightposition.y, data.lightposition.z];
340+
} else {
341+
surface.lightPosition.x = data.lightposition.x;
342+
surface.lightPosition.y = data.lightposition.y;
343+
surface.lightPosition.z = data.lightposition.z;
344+
}
345+
}
346+
337347
if(alpha && alpha < 1) {
338348
surface.supportsTransparency = true;
339349
}

0 commit comments

Comments
 (0)