mirror of
https://github.com/xibyte/jsketcher
synced 2025-12-06 16:33:15 +01:00
fixing webgl component layout and fix resize issues
This commit is contained in:
parent
699512168a
commit
4d4ba7175a
3 changed files with 23 additions and 8 deletions
|
|
@ -55,12 +55,8 @@ export default class SceneSetUp {
|
|||
this.renderer.setClearColor(0x808080, 1);
|
||||
this.renderer.setSize( this.container.clientWidth, this.container.clientHeight );
|
||||
this.container.appendChild( this.renderer.domElement );
|
||||
|
||||
window.addEventListener( 'resize', () => {
|
||||
this.updateViewportSize();
|
||||
}, false );
|
||||
}
|
||||
|
||||
|
||||
updateViewportSize() {
|
||||
if (this.container.clientWidth > 0 && this.container.clientHeight > 0) {
|
||||
this.updatePerspectiveCameraViewport();
|
||||
|
|
@ -69,7 +65,16 @@ export default class SceneSetUp {
|
|||
this.render();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
updateViewportSizeIfNeeded() {
|
||||
if (this._prevContainerWidth !== this.container.clientWidth ||
|
||||
this._prevContainerHeight !== this.container.clientHeight) {
|
||||
this.updateViewportSize();
|
||||
this._prevContainerWidth = this.container.clientWidth;
|
||||
this._prevContainerHeight = this.container.clientHeight;
|
||||
}
|
||||
}
|
||||
|
||||
updatePerspectiveCameraViewport() {
|
||||
this.pCamera.aspect = this.aspect();
|
||||
this.pCamera.updateProjectionMatrix();
|
||||
|
|
@ -184,6 +189,7 @@ export default class SceneSetUp {
|
|||
animate() {
|
||||
requestAnimationFrame( () => this.animate() );
|
||||
this.updateControlsAndHelpers();
|
||||
this.updateViewportSizeIfNeeded();
|
||||
};
|
||||
|
||||
render() {
|
||||
|
|
|
|||
|
|
@ -21,7 +21,8 @@ export default class View3d extends React.Component {
|
|||
render() {
|
||||
return <UISystem className={ls.root}>
|
||||
<FloatView />
|
||||
<div className={ls.viewer} id='viewer-container'>
|
||||
<div className={ls.viewer} >
|
||||
<div id='viewer-container' />
|
||||
<Abs left='0.8em' top='0.8em'>
|
||||
<HeadsUpToolbar/>
|
||||
</Abs>
|
||||
|
|
|
|||
|
|
@ -8,5 +8,13 @@
|
|||
flex-direction: column;
|
||||
flex: 1;
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
:global(#viewer-container) {
|
||||
left: 0;
|
||||
top: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
overflow: hidden;
|
||||
position: absolute;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue