update 3d viewport on switching from sketchers tabs

This commit is contained in:
Val Erastov 2018-01-26 20:48:32 -08:00
parent b3149f74bc
commit 64fee05995
3 changed files with 22 additions and 4 deletions

View file

@ -57,13 +57,19 @@ export default class SceneSetUp {
this.container.appendChild( this.renderer.domElement );
window.addEventListener( 'resize', () => {
this.updateViewportSize();
}, false );
}
updateViewportSize() {
if (this.container.clientWidth > 0 && this.container.clientHeight > 0) {
this.updatePerspectiveCameraViewport();
this.updateOrthographicCameraViewport();
this.renderer.setSize( this.container.clientWidth, this.container.clientHeight );
this.render();
}, false );
}
}
updatePerspectiveCameraViewport() {
this.pCamera.aspect = this.aspect();
this.pCamera.updateProjectionMatrix();

View file

@ -36,4 +36,8 @@ export default class View3d extends React.Component {
</div>
</UISystem>
}
componentWillUnmount() {
throw 'big no-no';
}
}

View file

@ -1,6 +1,14 @@
export function activate(context) {
context.services.dom = {
import {TOKENS as APP_TABS_TOKENS} from "./appTabsPlugin";
export function activate({bus, services}) {
services.dom = {
viewerContainer: document.getElementById('viewer-container')
};
bus.subscribe(APP_TABS_TOKENS.TABS, ({activeTab}) => {
if (activeTab === 0) {
services.viewer.updateViewportSize();
}
});
}