Hi all,
So in my project I ran in to some screenToWorld problem.
It is not working like I am expecting.
I made a new empty project to test out a few simple lines of code.
There is a camera located at the world origin (0,0,0) and has no rotation (0,0,0).
This is the code attached to the camera entity:
// initialize code called once per entity
Camera.prototype.initialize = function () {
var center = this.entity.camera.screenToWorld(window.innerWidth / 2, window.innerHeight / 2, 10);
console.log(center);
// logs:
// "x": 7.820499677654496,
// "y": -5.661549388473711,
// "z": -2.6051186755460614
};
Could somebody explain why it logs those values and not:
// "x": 0,
// "y": 0,
// "z": -10
Maybe my understanding of screenToWorld() function is just all wrong.
Here is the project if you want to look around.
https://playcanvas.com/project/1021903/