MoonSilver
MoonSilver

Reputation: 43

Three JS size of objects(PlaneGeometry)?

I have question about the sizes:

    var geometry = new THREE.PlaneGeometry(50, 50);

    var plane = new THREE.Mesh(geometry, material);

    plane.doubleSided = true;
    plane.tile = tile;

So the question is : the sizes of PlaneGeometry, not in pixels right? When I have canvas aroun 500x500, it will be less than 50x50 in the end?

PS> One more question, how to get size of element when it's already added to scene? Thank you!

Upvotes: 4

Views: 7404

Answers (2)

mrdoob
mrdoob

Reputation: 19602

50x50 is not pixels. It's "units". Whatever you want a "unit" to be (it's relative to the size of other objects).

If you want to resize an object in a controlled way, you could do this:

var geometry = new THREE.PlaneGeometry(1, 1);
var plane = new THREE.Mesh(geometry, material);

plane.scale.x = 50;
plane.scale.y = 50;

Upvotes: 12

Mr.TK
Mr.TK

Reputation: 1836

PS> One more question, how to get size of element when it's already added to scene? Thank you!

I am using thingiview js plugin and i've noticed that if you have an object added to the scene, you can close it within cube with coordinates:

p0 = [minx, miny,minz], p1 =[minx,miny,maxz], ..., p7 =[maxx, maxy,maxz];

, where:

var minx = object.geometry.min_x; var maxz = object.geometry.max_z;

etc..

PS: I know that this question is kind of old, but I was looking for those params (trying to get the size of added object) but couldn't find that anywhere.

Upvotes: 0

Related Questions