I am trying to design a solid semi-sphere in three.js. So far, all I found online is how to design an open-ended convex semi-sphere. I do not want a convex semi-sphere. What I want is to design a solid and closed all around semi-sphere.
After creating an your open-ended convex semi-sphere you can create a CircleGeometry and place it at the bottom of your semi-sphere.
Then you can merge the two grometries.
Have a look at the merge() method of Geometry Class
Related
I'm developing a software that can display 3D IFC building models. I'm using Xbim, and Helix toolkit for that.
I managed to display the geometry correctly, but there is something off with the shading as far as I can tell.
Can I alter the calculation of shading either during Xbim triangulation, or in Helix toolkit? The goal is to have sharp edges, and remove the ugly shading lines from the flat surfaces which appear on the border between 2 triangles in the mesh.
I already did some research, and what I found out, that shading calculation may be based around the vertices: If they are shared by 2 polygons, the shading will be smooth, and if you have 2 vertices in the same place, each belonging to a separate polygon, there will be a hard edge. Is this theory correct?
EDIT: I think this may be more related to Xbim, and not to helix toolkit. So The question is, how to tell Xbim, that you want sharp edges, like the ones you get in Xbim.WindowsUI?
This question already has answers here:
90 degree field of view without distortion in THREE.PerspectiveCamera
(2 answers)
Closed 1 year ago.
Is this an FOV issue with my perspective camera? In my scene, spheres look like eggs/oval shaped rather than spheres when they reach the edges of the screen. Anyone know why this happens?
It sounds like you've encountered one of the unfortunate realities of 3D.
In any 3-dimensional scene, the view from a given point is most naturally thought of as a sphere. When we render a scene, we're rendering a piece of that sphere, but we need to somehow convert that piece of a sphere into a flat rectangle, since our computer screens are flat, not round.
So, in order to render a 3D scene as a rectangle, the software needs to use a projection. For 3D rendering, the most common projection is probably a rectilinear projection, also called a gnomonic projection. (On Wikipedia, see "Rectilinear lens" for a discussion of rectilinear projections in photography, and "Gnomonic projection" for a discussion of rectilinear projections in mapmaking.)
The biggest advantage of a rectilinear projection is that straight lines in the scene appear as straight lines in the rendering. A big disadvantage is that objects far from the center are distorted: small circles get turned into large ovals.
This phenomenon is an unalterable mathematical fact that no software will ever be able to overcome. However, there are things you may be able to do to mitigate the situation. One option is to use a narrower field of view. Another option is to use a different projection; the answers here have a few suggestions for how to do that: Three.js - Fisheye effect
The following 3d model-in stl format-is composed of cuboids and cylinders
How can I extract the dimensions and coordinates of these constituent solids from the composite, i.e. the dimensions and locations of cuboids/cylinders?
I have tried an approach based on constructive solid geometry, this is a bit too slow and unwieldy for me. Due to the lack of a dataset, machine learning or deep learning models are not an option.
If you refer to the STL format described in wikipedia, in this format, each STL solid is composed solely of triangles. The construction information you are looking for in not in the file anymore.
If, however, all the solids you are looking for are not merged into one STL solid, and each solid is a cube or a cylinder, you can easily
determine the bounding box of each solid,
determine if the solid is a cube or a cylinder by checking each point against the bounding box planes (if a point is not on the bounding box plane, the solid is a cylinder),
and the same to determine orientation of the cylinder.
With the bounding box and the type/orientation, you have the base attribute of the solids you're looking for.
I am using the Constructive Solid Geomery library for Three.js, made by Chandler Prall.
https://github.com/chandlerprall/ThreeCSG
The resulting meshes are accurate, but they are very fragmented (lots and lots of unnecessary triangles), and they break some functionality in Three.js, for example the EdgesHelper class is not able to find the edges anymore. This problem is also mentioned here:
http://moczys.com/2014/01/13/three-js-experiment-3-additive-geometry/
Is there a mesh simplification library for Three.js that can take care of this? Perhaps there already is a polygon union function (merge all co-planar adjacent triangles into a 2D Shape), which then can be triangulated back into 3D again?
Is it possible to remove or cut away sections of shapes in Three.js?
For example, if I made a CylinderGeometry and wanted to "shave" the front of it away, so that the front was flat and the back was curved, like a half cylinder. Is this possible?
I need to be able to do it to the front and back of a cylinder, so just the sides are curved.
It is possible. You can deal with triangles yourself, or use Boolean operations with a library like constructive solid geometry to do mesh subtraction.
Have a look here and here for some suggestions related to manipulating geometry.
There are other algorithms to slice a mesh that could be ported over, but it depends on how simple or complex you need this thing to be.