Skip to content

Commit 3dd6cf5

Browse files
committed
pass gl-mesh3d lighting params
1 parent 5a59bc7 commit 3dd6cf5

File tree

6 files changed

+129
-5
lines changed

6 files changed

+129
-5
lines changed

src/traces/cone/attributes.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ extendFlat(attrs, colorAttrs('', 'calc', true), {
161161
});
162162
delete attrs.color;
163163

164-
var fromMesh3d = ['opacity', 'flatshading', 'lightposition', 'lighting'];
164+
var fromMesh3d = ['opacity', 'lightposition', 'lighting'];
165165

166166
fromMesh3d.forEach(function(k) {
167167
attrs[k] = mesh3dAttrs[k];

src/traces/cone/convert.js

+9
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,15 @@ function convert(scene, trace) {
9898
// stash positions for gl-scatter3d 'hover' trace
9999
meshData._pts = coneOpts.positions;
100100

101+
// pass gl-mesh3d lighting attributes
102+
meshData.lightPosition = [trace.lightposition.x, trace.lightposition.y, trace.lightposition.z];
103+
meshData.ambient = trace.lighting.ambient;
104+
meshData.diffuse = trace.lighting.diffuse;
105+
meshData.specular = trace.lighting.specular;
106+
meshData.roughness = trace.lighting.roughness;
107+
meshData.fresnel = trace.lighting.fresnel;
108+
meshData.opacity = trace.opacity;
109+
101110
return meshData;
102111
}
103112

src/traces/cone/defaults.js

-3
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,11 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout
4040

4141
coerce('anchor');
4242

43-
// TODO do these attributes work?
4443
coerce('lighting.ambient');
4544
coerce('lighting.diffuse');
4645
coerce('lighting.specular');
4746
coerce('lighting.roughness');
4847
coerce('lighting.fresnel');
49-
coerce('lighting.vertexnormalsepsilon');
50-
coerce('lighting.facenormalsepsilon');
5148
coerce('lightposition.x');
5249
coerce('lightposition.y');
5350
coerce('lightposition.z');

src/traces/cone/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ module.exports = {
1212
moduleType: 'trace',
1313
name: 'cone',
1414
basePlotModule: require('../../plots/gl3d'),
15-
categories: ['gl3d', '2dMap', 'noOpacity'],
15+
categories: ['gl3d'],
1616

1717
attributes: require('./attributes'),
1818
supplyDefaults: require('./defaults'),
35.6 KB
Loading
+118
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
{
2+
"data": [
3+
{
4+
"type": "cone",
5+
"name": "base",
6+
"x": [1, 1, 1],
7+
"y": [1, 2, 3],
8+
"z": [1, 1, 1],
9+
"u": [1, 2, 3],
10+
"v": [1, 1, 2],
11+
"w": [4, 4, 1],
12+
"hoverinfo": "u+v+w+name",
13+
"showscale": false
14+
},
15+
{
16+
"type": "cone",
17+
"name": "opacity:0.3",
18+
"x": [2, 2, 2],
19+
"y": [1, 2, 3],
20+
"z": [1, 1, 1],
21+
"u": [1, 2, 3],
22+
"v": [1, 1, 2],
23+
"w": [4, 4, 1],
24+
"hoverinfo": "u+v+w+name",
25+
"showscale": false,
26+
"opacity": 0.3
27+
},
28+
{
29+
"type": "cone",
30+
"name": "lighting.ambient:0.3",
31+
"x": [3, 3, 3],
32+
"y": [1, 2, 3],
33+
"z": [1, 1, 1],
34+
"u": [1, 2, 3],
35+
"v": [1, 1, 2],
36+
"w": [4, 4, 1],
37+
"hoverinfo": "u+v+w+name",
38+
"showscale": false,
39+
"lighting": {"ambient": 0.3}
40+
},
41+
{
42+
"type": "cone",
43+
"name": "lighting.diffuse:0.3",
44+
"x": [4, 4, 4],
45+
"y": [1, 2, 3],
46+
"z": [1, 1, 1],
47+
"u": [1, 2, 3],
48+
"v": [1, 1, 2],
49+
"w": [4, 4, 1],
50+
"hoverinfo": "u+v+w+name",
51+
"showscale": false,
52+
"lighting": {"diffuse": 0.3}
53+
},
54+
{
55+
"type": "cone",
56+
"name": "lighting.specular:2",
57+
"x": [5, 5, 5],
58+
"y": [1, 2, 3],
59+
"z": [1, 1, 1],
60+
"u": [1, 2, 3],
61+
"v": [1, 1, 2],
62+
"w": [4, 4, 1],
63+
"hoverinfo": "u+v+w+name",
64+
"showscale": false,
65+
"lighting": {"specular": 2}
66+
},
67+
{
68+
"type": "cone",
69+
"name": "lighting.roughness:1",
70+
"x": [6, 6, 6],
71+
"y": [1, 2, 3],
72+
"z": [1, 1, 1],
73+
"u": [1, 2, 3],
74+
"v": [1, 1, 2],
75+
"w": [4, 4, 1],
76+
"hoverinfo": "u+v+w+name",
77+
"showscale": false,
78+
"lighting": {"roughness": 1}
79+
},
80+
{
81+
"type": "cone",
82+
"name": "lighting.fresnel:2",
83+
"x": [7, 7, 7],
84+
"y": [1, 2, 3],
85+
"z": [1, 1, 1],
86+
"u": [1, 2, 3],
87+
"v": [1, 1, 2],
88+
"w": [4, 4, 1],
89+
"hoverinfo": "u+v+w+name",
90+
"showscale": false,
91+
"lighting": {"fresnel": 2}
92+
},
93+
{
94+
"type": "cone",
95+
"name": "lighting.position x:0,y:0,z:1e5",
96+
"x": [8, 8, 8],
97+
"y": [1, 2, 3],
98+
"z": [1, 1, 1],
99+
"u": [1, 2, 3],
100+
"v": [1, 1, 2],
101+
"w": [4, 4, 1],
102+
"hoverinfo": "u+v+w+name",
103+
"showscale": false,
104+
"lightposition": {"x": 0, "y": 0, "z": 1e5}
105+
}
106+
],
107+
"layout": {
108+
"scene": {
109+
"aspectmode": "data",
110+
"camera": {
111+
"eye": {"x": 0.05, "y": -2.6, "z": 2}
112+
}
113+
},
114+
"width": 500,
115+
"height": 500,
116+
"margin": {"t": 0, "b": 0, "l": 0, "r": 0}
117+
}
118+
}

0 commit comments

Comments
 (0)