Hii,
I want to create a line of 1 cm in THREE.Scene.I make a line by passing vertices value of {0,0,0} to {1,0,0}
which makes straight horizontal line,But I have a doubt is it a 1 mm or 1 cm line ?? or is it measure in Pixel.
But thatās just imaginaryā¦ or related to the bullet physics engine.
You can define any world scale you want, it might depend on your need for precision. From my experience i use 1 unit as 1 cm, this prevents precision loss that occurs pretty quickly on animations on mobile phones (the more distant you are from the origin). But i also use a multi-dimension coordinate system for theoretical āinfiniteā large coordinates. So it also might depend on your scene size. Engines like bullet offer an option for world scale.
There is no realworld unit relation anywhere besides the physics engine i guess. But using 1:1 meter doesnāt work well with phones and larger distances for the animations/GPU side.
I donāt want to hijack this poor persons threadā¦ but Fyrestar & prisoner849, do guys just work strictly with dynamic geo you are creating programmatically (and thus defining their measurements is a snap), or are you, like myself, working extensively with meshes created in your 3d apps and importing them into three? Those meshes I create are all in meters ā and if I have a one meter wide mesh and move it with mesh.position.set(1, 2, 0);, it will move it one meter (the equivalent of one width of itself) to the right and 2 meters off groundā¦ So I just canāt imagine how I could suddenly be working in some other measurement with theseā¦ Please elaborate if you can. I want to be well informed and have all options available.
You should export everything at the same unit system from your modelling software. Just to make everything proportional. It also might depend on this software, as some have a different system. If i import Blender in C4D the models can be rediculous large or small. The software probably offers a independent unit, just as THREE which will be the same.
As mentioned i use a 1 unit 1 centimeter world scale, just cause of the precision issues that will appear on some mobile at larger distances. But i also use a coordinate system that is independent of larger numbers beyond 32 or 64 bit, so if you use smaller units as 1 you could hit the upper limit ealier if that is relevant to you at all.
Export a cube at 1 cm or 1 meter, by just looking in the model file (text-format), if the cube has coordinates like -0.5, 0.5 etc., the cube will have a size of exactly 1 unit. Most software uses the international standard you probably mentioned (1 = 1 Meter)
Thank you very much for the explanation. I wonāt likely ever need to work with anything other than meters, but Iām glad I have deeper understanding of this nonetheless, should my needs change.
Notice that when you resize a Three.js application, the height of the viewport affect object sizing, so there isnāt really an absolute size for everything. Iām thinking of how to introduce absolute sizing to Three.js. For starters, figuring this out will begin to help understand how to do that. Ultimately, Three is drawing to the pixels on the screen, so there is for sure some way to map a size in Three to a number of pixels on the screen given that the camera is configured in a specific way and that obbjects are position on a specific plane perpendicular to the cameraās line of site.
Once I figure that out (Iām sure someone already knows), then in certain environments (f.e. Electron, Cordova) it is possible to get the physical dimensions of a display. Then it would be possible to specify that something is 1 inch wide, and for us to be able to place the object somewhere in the cameraās frustum so that the size we see on the display is actually 1 inch (measured with a ruler).
Being able to do this sort of thing is useful for display-independent sizing, which would be nice to have for cross-platform applications.
Yes I have, for example if you try the following demo and resize the window, youāll see the ābuttonsā stay the same size regardless of window size (the shadow and light is rendered with Three.js):
That example however uses infamous, which uses Three.js for WebGL rendering at the moment.
Hereās a simpler Three.js-only example showing absolute sizing:
In that example, the pink outline is a <div> element, and the skyblue background is a THREE.Mesh with THREE.PlaneGeometry, which is perfectly aligned behind the <div> element.
When you resize the window, the DIV element and the THREE.Mesh stay the same size and stay aligned. Both of them are sizes with āCSS pixelsā.
Thereās other better ways to do it too, but I havenāt posted the examples anywhere yet. That example may at least help you understand the math and how the camera is being positioned in order to make it happen.
That depends on your scene, graphics card, and the values of the near and far clipping plane.
If you need to make really tiny scenes, then itās OK to break this convention - just switch to using 1 unit = 1Ī¼m. Or, if you need to go from very tiny to very huge then use a logarithmic depth buffer instead: