Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 43e4a04

Browse files
committed
camera.projection.type
1 parent e1dff30 commit 43e4a04

9 files changed

+28
-21
lines changed

package-lock.json

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

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@
8080
"gl-mat4": "^1.2.0",
8181
"gl-mesh3d": "^2.0.7",
8282
"gl-plot2d": "^1.4.2",
83-
"gl-plot3d": "git://github.com/gl-vis/gl-plot3d.git#c7f8316a9c4182a2439fb45f3921a09405ac85a8",
83+
"gl-plot3d": "git://github.com/gl-vis/gl-plot3d.git#827c18c2510f678e91cc680d5886f9ca523051b4",
8484
"gl-pointcloud2d": "^1.0.2",
8585
"gl-scatter3d": "^1.1.6",
8686
"gl-select-box": "^1.0.3",

src/plots/gl3d/layout/defaults.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ function handleGl3dDefaults(sceneLayoutIn, sceneLayoutOut, coerce, opts) {
6868
coerce('camera.' + cameraKeys[j] + '.y');
6969
coerce('camera.' + cameraKeys[j] + '.z');
7070
}
71-
coerce('camera.ortho');
71+
72+
coerce('camera.projection.type');
7273

7374
/*
7475
* coerce to positive number (min 0) but also do not accept 0 (>0 not >=0)

src/plots/gl3d/layout/layout_attributes.js

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -72,16 +72,21 @@ module.exports = {
7272
'of this scene.'
7373
].join(' ')
7474
}),
75-
ortho: extendFlat({
76-
valType: 'boolean',
77-
role: 'info',
78-
dflt: false,
79-
editType: 'camera',
80-
description: [
81-
'Enable/disable orthographic camera.',
82-
'Default is perspective.'
83-
].join(' ')
84-
}),
75+
projection: {
76+
type: {
77+
valType: 'enumerated',
78+
role: 'info',
79+
values: ['perspective', 'orthographic'],
80+
dflt: 'perspective',
81+
editType: 'camera',
82+
description: [
83+
'Sets the projection type. The projection type could be',
84+
'either *perspective* or *orthographic*. The default is',
85+
'*perspective*.'
86+
].join(' ')
87+
},
88+
editType: 'camera'
89+
},
8590
editType: 'camera'
8691
},
8792
domain: domainAttrs({name: 'scene', editType: 'plot'}),

src/plots/gl3d/scene.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -350,12 +350,13 @@ var proto = Scene.prototype;
350350
proto.initializeGLCamera = function() {
351351

352352
var cameraData = this.fullSceneLayout.camera;
353+
var ortho = (cameraData.projection.type === 'orthographic');
353354

354355
this.camera = createCamera(this.container, {
355356
center: [cameraData.center.x, cameraData.center.y, cameraData.center.z],
356357
eye: [cameraData.eye.x, cameraData.eye.y, cameraData.eye.z],
357358
up: [cameraData.up.x, cameraData.up.y, cameraData.up.z],
358-
ortho: cameraData.ortho,
359+
ortho: ortho,
359360
zoomMin: 0.01,
360361
zoomMax: 100,
361362
mode: 'orbit'
@@ -750,7 +751,7 @@ function getLayoutCamera(camera) {
750751
up: {x: camera.up[0], y: camera.up[1], z: camera.up[2]},
751752
center: {x: camera.center[0], y: camera.center[1], z: camera.center[2]},
752753
eye: {x: camera.eye[0], y: camera.eye[1], z: camera.eye[2]},
753-
ortho: !!camera.ortho
754+
projection: {type: (camera.projection && camera.projection.type === 'orthographic') ? 'orthographic' : 'perspective'}
754755
};
755756
}
756757

@@ -790,7 +791,7 @@ proto.saveCamera = function saveCamera(layout) {
790791
}
791792
}
792793
}
793-
if(cameraData.ortho !== cameraDataLastSave.ortho) hasChanged = true;
794+
if(cameraData.projection.type !== cameraDataLastSave.projection.type) hasChanged = true;
794795
}
795796

796797
if(hasChanged) {

test/image/mocks/gl3d_annotations_orthographic.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"height": 600,
1111
"scene": {
1212
"camera": {
13-
"ortho": true,
13+
"projection": { "type": "orthographic" },
1414
"eye": {"x": 2.1, "y": 0.1, "z": 0.9}
1515
},
1616
"xaxis": {

test/image/mocks/gl3d_isosurface_9more-surfaces_between-ranges_orthographic.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2646,7 +2646,7 @@
26462646
"yaxis": { "nticks": 12 },
26472647
"zaxis": { "nticks": 12 },
26482648
"camera": {
2649-
"ortho": true,
2649+
"projection": { "type": "orthographic" },
26502650
"eye": {
26512651
"x": 1.5,
26522652
"y": 2.5,

test/image/mocks/gl3d_mesh3d_surface3d_scatter3d_orthographic.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@
124124
"zerolinewidth": 5
125125
},
126126
"camera": {
127-
"ortho": true,
127+
"projection": { "type": "orthographic" },
128128
"eye": {
129129
"x": -1.75,
130130
"y": -0.75,

test/jasmine/tests/gl_plot_interact_basic_test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ var failTest = require('../assets/fail_test');
1111

1212
// Expected shape of projection-related data
1313
var cameraStructure = {
14-
ortho: jasmine.any(Boolean),
14+
projection: {type: jasmine.any(String)},
1515
up: {x: jasmine.any(Number), y: jasmine.any(Number), z: jasmine.any(Number)},
1616
center: {x: jasmine.any(Number), y: jasmine.any(Number), z: jasmine.any(Number)},
1717
eye: {x: jasmine.any(Number), y: jasmine.any(Number), z: jasmine.any(Number)}

0 commit comments

Comments
 (0)