Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Fullscreen Mode #290

Merged
merged 5 commits into from
Jul 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,15 @@

<ul class="navbar-nav">

<!-- Fullscreen Button -->
<li class="nav-item">
<div class="ml-2 mt-1">
<button id="spacewalk-fullscreen-button" title="Fullscreen" type="button" class="btn nav-link">
Fullscreen
</button>
</div>
</li>

<!-- Spacewalk Files -->
<li class="nav-item">

Expand Down
2 changes: 1 addition & 1 deletion js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ const initializationHelper = async container => {

document.querySelector('.navbar').style.display = 'flex'

renderContainerController = new RenderContainerController(container, sceneManager)
renderContainerController = new RenderContainerController(container)

renderLoop()

Expand Down
19 changes: 1 addition & 18 deletions js/renderContainerController.js
Original file line number Diff line number Diff line change
@@ -1,31 +1,14 @@
import { configureRenderContainerDrag } from './renderContainerDrag.js'
import { traceNavigator } from './app.js'

class RenderContainerController {

constructor(rootContainer, sceneManager) {
constructor(rootContainer) {

this.rootContainer = rootContainer
this.threejsContainer = rootContainer.querySelector('#spacewalk-threejs-container')

this.setTopLeftPercentages(this.rootContainer, this.threejsContainer)


const config =
{
// handles: "w, sw, s, se, e",
handles: "se",
autoHide: true,
aspectRatio: true,
helper: "spacewalk-threejs-container-resizable-helper",
stop: () => {
sceneManager.resizeContainer()
traceNavigator.resize(sceneManager.container)
}
};

$(sceneManager.container).resizable(config)

const navbar = document.querySelector('.navbar')
const topConstraint = navbar.getBoundingClientRect().height

Expand Down
48 changes: 48 additions & 0 deletions js/sceneManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,54 @@ class SceneManager {
this.cameraLightingRig = cameraLightingRig;
this.cameraLightingRig.addToScene(this.scene);

const resizeableContainer = document.getElementById('spacewalk-threejs-trace-navigator-container')

this.resizeObserver = new ResizeObserver(entries => {
const { width, height } = container.getBoundingClientRect()
this.renderer.setSize(width, height)
this.cameraLightingRig.object.aspect = width / height
this.cameraLightingRig.object.updateProjectionMatrix()
this.renderer.render(this.scene, this.cameraLightingRig.object);
});

this.resizeObserver.observe(resizeableContainer)

const onWindowResize = () => {
const { width, height } = container.getBoundingClientRect()
this.renderer.setSize(width, height)
this.cameraLightingRig.object.aspect = width / height
this.cameraLightingRig.object.updateProjectionMatrix()
this.renderer.render(this.scene, this.cameraLightingRig.object);
}

window.addEventListener('resize', onWindowResize);

document.getElementById('spacewalk-fullscreen-button').addEventListener('click', () => {
if (!document.fullscreenElement) {
resizeableContainer.requestFullscreen().then(() => {
document.body.classList.add('fullscreen');
}).catch(err => {
alert(`Error attempting to enable full-screen mode: ${err.message} (${err.name})`);
});
} else {
document.exitFullscreen().then(() => {
document.body.classList.remove('fullscreen');
}).catch(err => {
alert(`Error attempting to exit full-screen mode: ${err.message} (${err.name})`);
});
}
});

document.addEventListener('fullscreenchange', () => {
if (!document.fullscreenElement) {
document.body.classList.remove('fullscreen');
}
});





SpacewalkEventBus.globalBus.subscribe('RenderStyleDidChange', this);
SpacewalkEventBus.globalBus.subscribe('DidSelectTrace', this);

Expand Down
64 changes: 36 additions & 28 deletions styles/app.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion styles/app.css.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading