Add fullscreen button to threejs-server (#446)
* Add fullscreen button to threejs-server * Simplify wrapper: pass app instance directly instead of useCallback wrappers * Update examples/threejs-server/src/threejs-app.tsx Co-authored-by: Jonathan Hefner <jonathan@hefner.pro> * Update examples/threejs-server/src/threejs-app.tsx Co-authored-by: Jonathan Hefner <jonathan@hefner.pro> * prettier --------- Co-authored-by: Jonathan Hefner <jonathan@hefner.pro>
This commit is contained in:
parent
8cad9f04c0
commit
37e127034f
1 changed files with 129 additions and 39 deletions
|
|
@ -6,7 +6,8 @@
|
|||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
html, body {
|
||||
html,
|
||||
body {
|
||||
font-family: var(--font-sans, system-ui, -apple-system, sans-serif);
|
||||
font-size: 1rem;
|
||||
margin: 0;
|
||||
|
|
@ -45,3 +46,61 @@ html, body {
|
|||
font-family: var(--font-sans, system-ui);
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
/* Fullscreen button */
|
||||
.fullscreen-btn {
|
||||
position: absolute;
|
||||
top: 10px;
|
||||
right: 10px;
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
border: none;
|
||||
border-radius: 8px;
|
||||
background: rgba(0, 0, 0, 0.6);
|
||||
color: white;
|
||||
cursor: pointer;
|
||||
display: none; /* Hidden by default, shown when fullscreen available */
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
transition:
|
||||
background 0.2s,
|
||||
opacity 0.2s;
|
||||
opacity: 0; /* Initially invisible, shown on hover */
|
||||
z-index: 100;
|
||||
}
|
||||
|
||||
.fullscreen-btn:hover {
|
||||
background: rgba(0, 0, 0, 0.8);
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.fullscreen-btn svg {
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
}
|
||||
|
||||
.fullscreen-btn .collapse-icon {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.fullscreen-btn.available {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
/* Show button on container hover */
|
||||
.threejs-container:hover .fullscreen-btn.available {
|
||||
opacity: 0.7;
|
||||
}
|
||||
|
||||
/* Fullscreen mode: swap icons and remove border radius */
|
||||
.threejs-container.fullscreen .fullscreen-btn .expand-icon {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.threejs-container.fullscreen .fullscreen-btn .collapse-icon {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.threejs-container.fullscreen canvas {
|
||||
border-radius: 0 !important;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue