macaw-threejs
Version:
Macaw Three.js is ready to use library to connect Three.js with your project.<br/> Under the hood is a fully optimized, clean Three.js set up to make it easy to implement effects for images (future text, etc.). With effects out of the box, you don't even
2 lines (1 loc) • 1.15 kB
JavaScript
import{SCENE_DEFAULTS as e}from"../../constants.js";import{calculateCameraFov as s}from"../../utils/calculate_camera_fov.js";class i{constructor(e){const{core:s}=e;this._core=s}resize(){this._core.scene.dimensions.width=this._core.scene.container.offsetWidth,this._core.scene.dimensions.height=this._core.scene.container.offsetHeight,this._core.scene.camera.aspect=this._core.scene.dimensions.width/this._core.scene.dimensions.height,this._core.scene.camera.fov=s(this._core.scene.dimensions.height,e.positionZ),this._core.scene.camera.updateProjectionMatrix(),this._core.scene.renderer.setSize(this._core.scene.dimensions.width,this._core.scene.dimensions.height),this._core.composer.instance.setSize(this._core.scene.dimensions.width,this._core.scene.dimensions.height),this._core.controllers.general.setImagesPosition({resize:!0}),this._core.storage.effects.forEach((e=>{e.resize&&e.resize()})),this._core.controllers.render.shouldRender()||this._core.controllers.render.manualRender()}setup(){window.addEventListener("resize",this.resize.bind(this))}cleanUp(){window.removeEventListener("resize",this.resize.bind(this))}}export{i as MacawResize};