Skip to content

Commit

Permalink
fix(Camera): Better support for initial camera position
Browse files Browse the repository at this point in the history
  • Loading branch information
jourdain committed Sep 25, 2018
1 parent 322450c commit 434e4c1
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 5 deletions.
4 changes: 2 additions & 2 deletions dist/Visualizer.js

Large diffs are not rendered by default.

20 changes: 17 additions & 3 deletions src/MainView.js
Expand Up @@ -31,6 +31,23 @@ export class Visualizer extends React.Component {
this.toggleMenu = this.toggleMenu.bind(this);
this.localImageReady = this.localImageReady.bind(this);
this.busyStatusUpdated = this.busyStatusUpdated.bind(this);

// Link resetCamera call to local renderer too
const resetCamera = () => {
if (this.renderer && this.renderer.resetCamera) {
this.renderer.resetCamera();
if (this.renderer.updateRenderWindowSize) {
this.renderer.updateRenderWindowSize();
}
}
};
actions.view.setResetCameraCallback(() => {
resetCamera();
// The client need the data to figure out the camera location
// Therefore we need to wait for the data to show up hoping 0.5s
// would be enough.
setTimeout(resetCamera, 500);
});
}

componentWillMount() {
Expand Down Expand Up @@ -80,9 +97,6 @@ export class Visualizer extends React.Component {

resetCamera() {
this.props.resetCamera();
if (this.renderer && this.renderer.resetCamera) {
this.renderer.resetCamera();
}
}

toggleMenu() {
Expand Down
8 changes: 8 additions & 0 deletions src/redux/ducks/view.js
Expand Up @@ -53,6 +53,13 @@ export default function reducer(state = initialState, action) {
}
}

// --- Bind UI callbacks ------------------------------------------------------

let resetCameraCallback = () => {};
export function setResetCameraCallback(fn) {
resetCameraCallback = fn;
}

// --- Action Creators --------------------------------------------------------

export function setRemoteRendering(remote) {
Expand Down Expand Up @@ -82,6 +89,7 @@ export function setServerMaxFPS(maxFPS) {
// --- Async actions ---

export function resetCamera() {
resetCameraCallback();
return (dispatch) => {
const netRequest = netActions.createRequest('Reset camera');
network
Expand Down

0 comments on commit 434e4c1

Please sign in to comment.