1

I'm following this answer to calculate the Size of my Sphere Geometryin three.js. But I'm somehow missing something as the calculated result is just not correct, when I measure the size through a screenshot.

I generated the setting like this:

this.cubeGeometry = new THREE.SphereGeometry(210, 60, 60);
this.camera = new THREE.PerspectiveCamera(45, this.size.w / this.size.h, 1, 20000);
this.camera.position.z = 1000;

Then I calculate the size like this

var vFOV = THREE.Math.degToRad( this.camera.fov ); // => 0.7853981633974483
var height = 2 * Math.tan( vFOV / 2 ) * 1000; // => 828.4271247461901
var fraction = 210 / height; // => 0.253492424049175
var finalSize = this.size.h * fraction // => 242.33875739101128

The screenshoted size is about 500px. What am I missing?

Thanks!

vinni
  • 633
  • 2
  • 8
  • 32
  • For starters, you're not following the formula/steps in the linked answer.. (see last two lines in this Q). –  Dec 05 '17 at 15:39
  • @K3N you're right, the last two lines come from a different answer, that references the answer I linked: https://stackoverflow.com/questions/15331358/three-js-get-object-size-with-respect-to-camera-and-object-position-on-screen Still `height`and `finalSize` don't give any results near what I see :/ – vinni Dec 05 '17 at 15:48
  • https://stackoverflow.com/questions/15331358/three-js-get-object-size-with-respect-to-camera-and-object-position-on-screen – vinni Dec 05 '17 at 15:48
  • Try using the front face distance. Right now the distance is to the *center* of the sphere. If you subtract the radius from the distance so that instead of using 1000 with height=, use (1000-210), does that comes closer to what you expect? –  Dec 05 '17 at 16:11
  • In that case the `height` becomes `654`. Which is still not right. I think it's right to use `1000`as distance, because I want to get the full diameter of the ball. – vinni Dec 05 '17 at 16:17
  • Ok, I found an apparent answer. First I need to take the radius x2: `var fraction = 420 / height`. Then the `finalSize` gets 10px close to the relative appearance. Then I realized, the 10 px discrepancy is due to the 60 segments I apply to the `Sphere`. I'm wondering if this is a bug or a feature. (The Issue got closed on Github thoug...) I'd need to calculate the exact size. Is there a way I can calculate the size increasement? – vinni Dec 05 '17 at 18:00

0 Answers0