Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

camera rotation #93

Open
KilledByAPixel opened this issue Jul 28, 2024 · 3 comments
Open

camera rotation #93

KilledByAPixel opened this issue Jul 28, 2024 · 3 comments

Comments

@KilledByAPixel
Copy link
Owner

there should be a way to set the camera rotation angle.

@ejamshidiasl
Copy link

ejamshidiasl commented Jul 28, 2024

maybe fake it, add every thing to a game object and rotate, scale,... just that one.

import * as l from './littlejs.esm.js';

let fakeCam, obj;
const speed = 0.2;
const rotSpeed = 0.05;

function gameInit() {
  fakeCam = new l.EngineObject();
  obj = new l.EngineObject();
  fakeCam.addChild(obj, l.vec2(2));
}

function gameUpdate() {
  if (l.keyIsDown('KeyD')) fakeCam.pos.x -= speed;
  else if (l.keyIsDown('KeyA')) fakeCam.pos.x += speed;

  if (l.keyIsDown('KeyS')) fakeCam.pos.y += speed;
  else if (l.keyIsDown('KeyW')) fakeCam.pos.y -= speed;

  if (l.keyIsDown('KeyE')) fakeCam.angle += rotSpeed;
  else if (l.keyIsDown('KeyQ')) fakeCam.angle -= rotSpeed;
}

function gameUpdatePost() {
}

function gameRender() {
}

function gameRenderPost() {
}

l.engineInit(gameInit, gameUpdate, gameUpdatePost, gameRender, gameRenderPost);

@KilledByAPixel
Copy link
Owner Author

That's an interesting workaround but I was thinking we could support setting a camera angle natively in the engine.

This involves changing the webgl transformation matrix to include rotation as well the canvas 2d stuff. Also the functions screenToWorld, and worldToScreen will be updated.

@KumaWang
Copy link

That's an interesting workaround but I was thinking we could support setting a camera angle natively in the engine.这是一个有趣的解决方法,但我认为我们可以支持在引擎中本地设置相机角度。

This involves changing the webgl transformation matrix to include rotation as well the canvas 2d stuff. Also the functions screenToWorld, and worldToScreen will be updated.这涉及更改 webgl 变换矩阵以包括旋转以及画布 2d 内容。 screenToWorld 和 worldToScreen 函数也将更新。

i need it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants