Skip to content

Commit f035859

Browse files
Enforce OrbitView orbitAxis prop (visgl#5962)
1 parent cab55e5 commit f035859

File tree

6 files changed

+18
-15
lines changed

6 files changed

+18
-15
lines changed

docs/upgrade-guide.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,12 @@ The module entry point is now only lightly transpiled for the most commonly used
4949

5050
`Deck`'s default `onError` callback is changed to `console.error`. Explicitly setting `onError` to `null` now silently ignores all errors, instead of logging them to console.
5151

52+
53+
### OrbitView
54+
55+
`OrbitView` no longer allows `orbitAxis` to be specified in the view state. Set `orbitAxis` in the `OrbitView` constructor instead.
56+
57+
5258
## Upgrading from deck.gl v8.3 to v8.4
5359

5460
### wrapLongitude

examples/website/point-cloud/app.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ const INITIAL_VIEW_STATE = {
1515
target: [0, 0, 0],
1616
rotationX: 0,
1717
rotationOrbit: 0,
18-
orbitAxis: 'Y',
19-
fov: 50,
2018
minZoom: 0,
2119
maxZoom: 10,
2220
zoom: 1
@@ -82,7 +80,7 @@ export default function App({onLoad}) {
8280

8381
return (
8482
<DeckGL
85-
views={new OrbitView()}
83+
views={new OrbitView({orbitAxis: 'Y', fov: 50})}
8684
viewState={viewState}
8785
controller={true}
8886
onViewStateChange={v => updateViewState(v.viewState)}

modules/core/src/controllers/orbit-controller.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import ViewState from './view-state';
44
import {mod} from '../utils/math-utils';
55

66
const DEFAULT_STATE = {
7-
orbitAxis: 'Z',
87
rotationX: 0,
98
rotationOrbit: 0,
109
zoom: 0,
@@ -24,7 +23,6 @@ export class OrbitState extends ViewState {
2423
/* Viewport arguments */
2524
width, // Width of viewport
2625
height, // Height of viewport
27-
orbitAxis = DEFAULT_STATE.orbitAxis,
2826
rotationX = DEFAULT_STATE.rotationX, // Rotation around x axis
2927
rotationOrbit = DEFAULT_STATE.rotationOrbit, // Rotation around orbit axis
3028
target = DEFAULT_STATE.target,
@@ -50,7 +48,6 @@ export class OrbitState extends ViewState {
5048
super({
5149
width,
5250
height,
53-
orbitAxis,
5451
rotationX,
5552
rotationOrbit,
5653
target,

modules/core/src/views/orbit-view.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ class OrbitViewport extends Viewport {
4141
constructor(props) {
4242
const {
4343
height,
44-
fovy = 50, // From eye position to lookAt
45-
orbitAxis = 'Z', // Orbit axis with 360 degrees rotating freedom, can only be 'Y' or 'Z'
44+
fovy, // For setting camera position
45+
orbitAxis, // Orbit axis with 360 degrees rotating freedom, can only be 'Y' or 'Z'
4646
target = [0, 0, 0], // Which point is camera looking at, default origin
4747

4848
rotationX = 0, // Rotating angle around X axis
@@ -94,9 +94,12 @@ class OrbitViewport extends Viewport {
9494
}
9595

9696
export default class OrbitView extends View {
97-
constructor(props) {
97+
constructor(props = {}) {
98+
const {orbitAxis = 'Z'} = props;
99+
98100
super({
99101
...props,
102+
orbitAxis,
100103
type: OrbitViewport
101104
});
102105
}

test/modules/core/views/view.spec.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ test('OrbitView', t => {
139139

140140
// eslint-disable-next-line complexity
141141
test('OrbitView#project', t => {
142-
const view = new OrbitView({id: '3d-view'});
142+
let view = new OrbitView({id: '3d-view', orbitAxis: 'Z'});
143143
let viewport;
144144
let p;
145145
let center;
@@ -161,7 +161,6 @@ test('OrbitView#project', t => {
161161
width: 100,
162162
height: 100,
163163
viewState: {
164-
orbitAxis: 'Z',
165164
target: [0, 0, 0],
166165
zoom: 1,
167166
rotationOrbit: 0,
@@ -176,11 +175,11 @@ test('OrbitView#project', t => {
176175
p = viewport.project([1, 0, 0]);
177176
t.ok(p[0] > 50 && p[1] === 50 && p[2] === center[2], 'x axis points right');
178177

178+
view = new OrbitView({id: '3d-view', orbitAxis: 'Y'});
179179
viewport = view.makeViewport({
180180
width: 100,
181181
height: 100,
182182
viewState: {
183-
orbitAxis: 'Y',
184183
target: [0, 0, 0],
185184
zoom: 1,
186185
rotationOrbit: 0,

test/render/test-cases/simple-mesh-layer.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,12 @@ export default [
6161
target: [0, 0, 0],
6262
rotationX: 0,
6363
rotationOrbit: 0,
64-
orbitAxis: 'Y',
6564
fov: 30,
6665
zoom: -1.5
6766
},
6867
views: [
6968
new OrbitView({
69+
orbitAxis: 'Y',
7070
near: 0.1,
7171
far: 2
7272
})
@@ -117,11 +117,11 @@ export default [
117117
target: [0, 0, 0],
118118
rotationX: 0,
119119
rotationOrbit: 0,
120-
orbitAxis: 'Y',
121120
zoom: 0
122121
},
123122
views: [
124123
new OrbitView({
124+
orbitAxis: 'Y',
125125
near: 0.1,
126126
far: 10
127127
})
@@ -148,11 +148,11 @@ export default [
148148
target: [0, 0, 0],
149149
rotationX: 0,
150150
rotationOrbit: 0,
151-
orbitAxis: 'Y',
152151
zoom: 0
153152
},
154153
views: [
155154
new OrbitView({
155+
orbitAxis: 'Y',
156156
near: 0.1,
157157
far: 10
158158
})

0 commit comments

Comments
 (0)