# Calculate the ratio of 1 unit to how many pixels?

**URL:** <https://discourse.threejs.org/t/calculate-the-ratio-of-1-unit-to-how-many-pixels/7329>\
**Category:** Questions\
**Tags:** transform\
**Created:** [May 1, 2019, 3:30pm UTC](https://discourse.threejs.org/t/calculate-the-ratio-of-1-unit-to-how-many-pixels/7329 "2019-05-01T15:30:52Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![looeee](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/looeee/32/59_2.png) [@looeee](https://discourse.threejs.org/u/looeee)\
**Post date:** [May 2, 2019, 1:13am UTC](https://discourse.threejs.org/t/calculate-the-ratio-of-1-unit-to-how-many-pixels/7329/3 "2019-05-02T01:13:35Z")

</div>

You might find my functions from this post useful:

> [@Functions to calculate the visible width / height at a given z-depth from a perspective camera](https://discourse.threejs.org/t/functions-to-calculate-the-visible-width-height-at-a-given-z-depth-from-a-perspective-camera/269):
>
> These two functions will give you the visible height and width in your scene at a given distance from a PerspectiveCamera. It’s useful if you want to create an object that is the full width / height of the scene, or want to place objects at screen edges etc. Here’s the code (ES6): const visibleHeightAtZDepth = ( depth, camera ) =\> { // compensate for cameras not positioned at z=0 const cameraOffset = camera.position.z; if ( depth \< cameraOffset ) depth -= cameraOffset; else depth += c…

They’ll give you the full width of the screen in three.js units at a given z-depth. You can then use that to create objects that are a given percentage width, or do some more calculations to make them a particular amount of pixels wide. However, it’s probably best not to size things in pixels since on HDPI screens they will get very tiny.

---

_[View the full topic](https://discourse.threejs.org/t/calculate-the-ratio-of-1-unit-to-how-many-pixels/7329)._
