Created
March 9, 2022 01:57
-
-
Save sonygod/98e6b15f46420dc1baf98c99431fe141 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import three.Camera; | |
import js.html.Event; | |
import three.WebGLRenderer; | |
import three.Scene; | |
import js.Browser; | |
import js.html.Window; | |
import three.PerspectiveCamera; | |
class Camera2D { | |
public function new(scene:Scene, render:WebGLRenderer) { | |
this.scene = scene; | |
this.render = render; | |
} | |
static var WIDTH = Browser.window.innerWidth; | |
static var HEIGHT = Browser.window.innerHeight; | |
public function OnInit() { | |
mCamera = new PerspectiveCamera(70, WIDTH / HEIGHT, 1, 5000); | |
Browser.window.addEventListener('resize', onWindowResize, false); | |
reset(); | |
} | |
function setCamera2D_z(fValue:Float) { | |
mCamera.position.z = fValue; | |
mCamera.updateProjectionMatrix(); | |
} | |
function reset() { | |
mCamera.position.x = 0; | |
mCamera.position.y = 0; | |
mCamera.position.z =800; | |
} | |
function onWindowResize(e:Event) { | |
WIDTH = Browser.window.innerWidth; | |
HEIGHT = Browser.window.innerHeight; | |
mCamera.aspect = WIDTH / HEIGHT; | |
mCamera.updateProjectionMatrix(); | |
render.setSize(WIDTH, HEIGHT); | |
} | |
public var mCamera:PerspectiveCamera; | |
var scene:Scene; | |
var render:WebGLRenderer; | |
} |
Author
sonygod
commented
Mar 9, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment