Skip to content

Commit ad218ba

Browse files
committed
Adding light source configurability
1 parent ff82577 commit ad218ba

File tree

6 files changed

+45
-9
lines changed

6 files changed

+45
-9
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
"gl-line2d": "^1.3.0",
6262
"gl-line3d": "^1.1.0",
6363
"gl-mat4": "^1.1.2",
64-
"gl-mesh3d": "^1.1.0",
64+
"gl-mesh3d": "^1.2.0",
6565
"gl-plot2d": "^1.1.6",
6666
"gl-plot3d": "^1.5.0",
6767
"gl-scatter2d": "^1.0.5",

src/traces/mesh3d/attributes.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ module.exports = {
125125
showscale: colorscaleAttrs.showscale,
126126

127127
lighting: extendFlat({}, surfaceAtts.lighting),
128+
lightposition: extendFlat({}, surfaceAtts.lightposition),
128129

129130
_nestedModules: { // nested module coupling
130131
'colorbar': 'Colorbar'

src/traces/mesh3d/convert.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ proto.update = function(data) {
106106
var config = {
107107
positions: positions,
108108
cells: cells,
109+
lightPosition: [data.lightposition.x, data.lightposition.y, data.lightposition.z],
109110
ambient: data.lighting.ambient,
110111
diffuse: data.lighting.diffuse,
111112
specular: data.lighting.specular,

src/traces/mesh3d/defaults.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,17 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout
4949
}
5050

5151
//Coerce remaining properties
52-
['lighting.ambient',
52+
[
53+
'lighting.ambient',
5354
'lighting.diffuse',
5455
'lighting.specular',
5556
'lighting.roughness',
5657
'lighting.fresnel',
5758
'lighting.vertexnormalsepsilon',
5859
'lighting.facenormalsepsilon',
60+
'lightposition.x',
61+
'lightposition.y',
62+
'lightposition.z',
5963
'contour.show',
6064
'contour.color',
6165
'contour.width',

src/traces/surface/attributes.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,30 @@ module.exports = {
147147
].join(' ')
148148
},
149149

150+
lightposition: {
151+
x: {
152+
valType: 'number',
153+
role: 'style',
154+
min: -1e5,
155+
max: 1e5,
156+
dflt: 1e5
157+
},
158+
y: {
159+
valType: 'number',
160+
role: 'style',
161+
min: -1e5,
162+
max: 1e5,
163+
dflt: 1e5
164+
},
165+
z: {
166+
valType: 'number',
167+
role: 'style',
168+
min: -1e5,
169+
max: 1e5,
170+
dflt: 0
171+
}
172+
},
173+
150174
lighting: {
151175
ambient: {
152176
valType: 'number',

src/traces/surface/defaults.js

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,19 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout
5050
}
5151
}
5252

53-
coerce('lighting.ambient');
54-
coerce('lighting.diffuse');
55-
coerce('lighting.specular');
56-
coerce('lighting.roughness');
57-
coerce('lighting.fresnel');
58-
coerce('hidesurface');
59-
coerce('opacity');
53+
//Coerce remaining properties
54+
[
55+
'lighting.ambient',
56+
'lighting.diffuse',
57+
'lighting.specular',
58+
'lighting.roughness',
59+
'lighting.fresnel',
60+
'lightposition.x',
61+
'lightposition.y',
62+
'lightposition.z',
63+
'hidesurface',
64+
'opacity'
65+
].forEach(function(x) { coerce(x); });
6066

6167
var surfaceColor = coerce('surfacecolor');
6268

0 commit comments

Comments
 (0)