I have set up two different scenes and renders in my project. In addition, I have utilized Bootstrap 4 for the modal window functionality. One scene serves as the main display, while the other is displayed within the modal window. This is why I am employing two separate renders: one for the element on the main screen and another for the modal window.
Here is the code:
Main scene:
<div class="output3d" id="WebGL-output"></div>
function setMainScene() {
// Main scene setup goes here
}
Scene for modal window:
<div class="modal" data-backdrop="static" id="ObjectInfo" role="dialog" tabindex="-1">
<!-- Modal window setup code here -->
</div>
function setModalWindowScene() {
// Modal window scene setup goes here
}
Init:
function init() {
setMainScene()
setModalWindowScene()
// Adding objects to main scene
addRoom()
addRacks()
addExtinguishingCylinders()
addHotHalls()
addWires()
addLights()
window.addEventListener('resize', onWindowResize, false);
}
Rendering:
function animate() {
requestAnimationFrame(animate);
render();
}
function render() {
// Main rendering logic
}
function onWindowResize() {
// Window resize logic
}
HTML:
<script type="text/javascript">
init();
animate();
</script>
One issue that has been encountered is when a user opens the modal window for the first time, the object picture doesn't initially appear. However, upon resizing the window, the picture appears and remains visible. An interesting observation is that even when there is no picture in the modal window, the object can still be rotated using the controls associated with the modal scene.
You can see a demonstration of this issue below: Before resizing After resizing