src/SceneHelper.js
/**
     * orthographic camera that can only view from one side. no orbit controls, just moving left/right up/down
     * will replace the camera in the scene upon calling
     * @param {string} dir "x" "y" or "z", which is the axis that is hidden because it's seen from the side
     */
orthographic camera that can only view from one side.
orthographic camera that can only view from one side .
createSideViewCamera(dir)
    {
        let width = this.width
        let height = this.height
        let near = 0 
        let far = 50 
        let a = Math.min(width, height)
        let camera = new THREE.OrthographicCamera(-width/a, width/a, height/a,-height/a, near, far)
        let controls = new (OrbitControls(THREE))(camera, this.renderer.domElement)
        controls.enableKeys = false
        this.onChangeCamera = this.render
        controls.addEventListener("change", ()=>{
            this.camera.position[dir] = this.camera["initial_"+dir]/this.camera.zoom
            this.render()
        })
        controls.enableDamping = true
        controls.dampingFactor = 0.25
        controls.enableZoom = true
        controls.enableRotate = false
        this.camera = camera
        this.cameraControls = controls
    }
createSideViewCamera ( dir ) { let width = this . width let height = this . height let near = 0 let far = 50 let a = Math . min ( width , height ) let camera = new THREE . OrthographicCamera ( - width / a , width / a , height / a , - height / a , near , far ) let controls = new ( OrbitControls ( THREE ) ) ( camera , this . renderer . domElement ) controls . enableKeys = false this . onChangeCamera = this . render controls . addEventListener ( "change" , ( ) => { this . camera . position [ dir ] = this . camera [ "initial_" + dir ] / this . camera . zoom this . render ( ) } ) controls . enableDamping = true controls . dampingFactor = 0.25 controls . enableZoom = true controls . enableRotate = false this . camera = camera this . cameraControls = controls }
orthographic camera that can only view from one side.
orthographic camera that can only view from one side .
// when objects start to disappear at zoom-in // when objects start to disappear at zoom-out // helps to control the sprite size to be roughly the same as in the default perspective mode camera // camera.scale.set(0.5, 0.5, 0.5) // the point of this is, that i can disable this by overwriting it // when doing animations no need to use the event listener anymore // change y position, so that the sprite size stays the same. Without the following // line the sprites maintain the same size on the screen in px despite zoom factor // controls.maxDistance = 5 // controls.minDistance = 0.3