Skip to content

Commit 303fa71

Browse files
committed
scaling and lighting
1 parent e018e38 commit 303fa71

File tree

4 files changed

+76
-7
lines changed

4 files changed

+76
-7
lines changed

src/traces/streamtubes/convert.js

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ proto.update = function(data) {
285285
}
286286

287287
if(true) {
288-
var delaunayOptions = calculateMesh(this.data.x, this.data.y, this.data.z);
288+
var delaunayOptions = calculateMesh(this.data.x, this.data.y, this.data.z, this.scene.dataScale);
289289
if(this.delaunayMesh) {
290290
this.delaunayMesh.update(delaunayOptions);
291291
} else {
@@ -324,7 +324,7 @@ function createLineWithMarkers(scene, data) {
324324

325325
module.exports = createLineWithMarkers;
326326

327-
function calculateMesh(inputX, inputY, inputZ) {
327+
function calculateMesh(inputX, inputY, inputZ, scalingFactor) {
328328

329329
function addVertex(X, Y, Z, x, y, z) {
330330
X.push(x);
@@ -905,10 +905,21 @@ function calculateMesh(inputX, inputY, inputZ) {
905905
}
906906

907907
return {
908-
"positions": X.map(function(d, i) {return [X[i], Y[i], Z[i]]}),
909-
"cells":I.map(function(d, i) {return [I[i], J[i], K[i]]}),
910-
"meshColor": [0.12156862745098039,0.4666666666666667,0.9058823529411765,1],
911-
"opacity":1
908+
positions: X.map(function(d, i) {return [
909+
X[i] * scalingFactor[0],
910+
Y[i] * scalingFactor[1],
911+
Z[i] * scalingFactor[2]
912+
]}),
913+
cells:I.map(function(d, i) {return [I[i], J[i], K[i]]}),
914+
meshColor: [0.12156862745098039,0.4666666666666667,0.9058823529411765,1],
915+
opacity:1,
916+
lightPosition: [1e6 * scalingFactor[0], 1e6 * scalingFactor[1], 1e6 * scalingFactor[2]],
917+
ambient: 0.4,
918+
diffuse: 0.5,
919+
specular: 0.3,
920+
roughness: 0.1,
921+
fresnel: 0,
922+
vertexNormalsEpsilon: 1e-12
912923
}
913924

914925
return {
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
{
2+
"data": [
3+
{
4+
"type": "scatter3d",
5+
"x": [
6+
1,
7+
2,
8+
3
9+
],
10+
"y": [
11+
1,
12+
2,
13+
3
14+
],
15+
"z": [
16+
16,
17+
4,
18+
16
19+
],
20+
"surfaceaxis": 0
21+
}
22+
],
23+
"layout": {
24+
"title": "delaunay mesh for scatter3d",
25+
"scene": {
26+
"camera": {
27+
"eye": {
28+
"x": 1.5,
29+
"y": -1.5,
30+
"z": 1
31+
}
32+
},
33+
"aspectratio": {
34+
"x": 2,
35+
"y": 2,
36+
"z": 1
37+
}
38+
},
39+
"height": 450,
40+
"width": 1000,
41+
"autosize": true
42+
}
43+
}

test/image/mocks/gl3d_streamtubes_basic.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,19 @@
3535
"opacity": 1,
3636
"scale": 1
3737
}
38+
},
39+
"flatshading": false,
40+
"lightposition": {
41+
"x": 1000,
42+
"y": 1000,
43+
"z": 1000
44+
},
45+
"lighting": {
46+
"ambient": 0.4,
47+
"diffuse": 2,
48+
"specular": 0.5,
49+
"fresnel": 0,
50+
"roughness": 0.4
3851
}
3952
}
4053
],

test/jasmine/tests/gl_plot_interact_basic_test.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -561,7 +561,9 @@ describe('gl3d plots', function() {
561561

562562
fit('streamtubes', function(done) {
563563

564-
var mock = require('@mocks/gl3d_streamtubes_basic.json')
564+
//var mock = require('@mocks/gl3d_errorbars_sqrt.json')
565+
//var mock = require('@mocks/gl3d_scatter3d-with-delaunay.json')
566+
var mock = require('@mocks/gl3d_streamtubes_basic.json')
565567
//var mock = require('@mocks/gl3d_projection-traces.json')
566568

567569

0 commit comments

Comments
 (0)