So here is what I’m trying to do,
I want to scale an object to be the same visual size across any device, like, I want it to be x cm in size no matter what the screen size/dpi/resolution is.
Currently, I’m using the following code
PointToUnit.convert = function (point) {
var value = point * window.devicePixelRatio;
var camera = pc.app.root.findByName('Camera').camera;
var a = camera.screenToWorld(0 ,0 ,0);
var b = camera.screenToWorld(value ,0 ,0);
return b.x - a.x;
};
But it’s ever-so-slightly off, it’s particularly visible between high and low DPI devices.
Is there a way to do what I want ?
Oh and I must use 3D objects, it can’t be a UI or 2D element, and I use a Camera in orthographic projection.
I’ve not done this before but what I imagine I would have to do is get the DPI of the screen which is dots per inch and scale the entity based on that.
Device Pixel Ratio is not relative to real world measurements.