mirror of
https://github.com/xibyte/jsketcher
synced 2025-12-27 02:43:04 +01:00
update 3d viewport on switching from sketchers tabs
This commit is contained in:
parent
b3149f74bc
commit
64fee05995
3 changed files with 22 additions and 4 deletions
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -36,4 +36,8 @@ export default class View3d extends React.Component {
|
|||
</div>
|
||||
</UISystem>
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
throw 'big no-no';
|
||||
}
|
||||
}
|
||||
|
|
@ -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();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue