When i view my scene from far distance i see faces edges on the objects.example
At a certain angle i can see the lines clearly like wireframe.
How to remove these.
Thanks
Related
In order to stretch a 2D rounded rectangle without distortion, I repositioned the rectangle towards one direction (eg left) by the desired amount and added that amount to the right-most vertices to compensate and appear stretched.
The problem is that now raycaster is missing the right-half of the rectangle.
I made the following jsfiddle stretching a normal rectangle:
http://jsfiddle.net/vser1n2u/5/
If you hover the mouse on the rectangle you’ll see that raycaster works properly (“TRUE” indication). If you click on the rectangle, it will expand to the left. Now if you hover you’ll see that it works only half way (“FALSE” indication).
Am I missing something, or is this a three.js bug?
When you modify the vertices of a geometry after it has been rendered, you need to recompute the bounding sphere for raycasting and frustum culling to work correctly.
So in your case,
o.m.geometry.computeBoundingSphere();
Updated fiddle: http://jsfiddle.net/vser1n2u/6/
three.js r.98
I'm having trouble UV mapping each side of a cube. The cube was made as a BufferGeometry where each side is a rotated copy of one side (sort of a working template) and rotated accordingly by applying a quarternion. UVs are copied as well. I'll skip any vertex coordinate I've seen before and rely on indices.
This leaves me with a total of 8 vertices and 12 faces. But I think I'm running short on vertices when I have to set all of my UVs. As obvious on the screenshot I've "correctly" mapped each side of the cube. But the top and bottom is lacking. I don't know how to set the vertex UV top and bottom faces.
Can I in some way apply several UVs on the same vertex depending on which face it is used in or have I completely lost the plot?
I could solve the problem by applying 6 PlaneBufferGeometry but that would leave me with 4*6=24 vertices. That is a whole lot more than 8.
I haven't been able to figure this one out. Either I've complete misunderstood how it works or what I'm trying to accomplish is impossible given my constraints.
With BufferGeometry, vertices can only be reused if all the attributes for that vertex match. Since each corner of the cube has 3 perpendicular normals, there must be 3 copies of that vertex.
If you have uvs, it is the same issue -- vertices must be duplicated if the uvs are different.
Study BoxBufferGeometry, which is implemented as "indexed-BufferGeometry".
three.js r.90
Is there a way to resize the edges and faces of objects like cubes in three.js?
For example, I want to build the shape you see below without using Blender or a modelling tool. I want to scale the edge and faces of the cube to make the sharp edges as you see below.
I'm currently trying to get my head around a method to create roof-like structures on top of my extruded shapes in Three.js. Without delving into straight skeletons, the simplest approach I can think of is to extrude and scale the top face of my extruded mesh to look roof-like, or create a new mesh on top that is shaped to look like a roof.
This is the most basic style that I'm after, if applied to an extruded rectangle (a cube):
The shaded area of the roof is higher than the non-shaded area.
And the same style, if applied to a more complex extruded shape:
What I can't work out is how to create a roof structure like that, especially for complex shapes like the second example. I have the vertices for the building 'footprint' but I don't know how to extrude them while scaling the top face to give the slanted sides.
I could definitely work out the scaled vertex positions but them I'd have another problem in not know how to connect the top (scaled) face to the bottom face (ie. how to make the side faces).
Any ideas?
Sounds like you want to experiment with the bevel parameters in ExtrudeGeometry.
https://github.com/mrdoob/three.js/blob/master/src/extras/geometries/ExtrudeGeometry.js
As the top roof polygon will have the same number of verts as the bottom roof polygon isn't this just a case of looping through each top roof polygon vert and connecting it to it's bottom roof polygon vert?
And, any two verts on the top roof polygon along with their associated verts on the bottom roof polygon will give you all the verts for a side face.
* SOLVED *
It was not about 0,0,0 or distortion. It´s super weird but I found out that compute geometry as a Sphere worked! (even at the tiles corners, where you should think a sphere wouldnt cover it does)
http://threejs.org/docs/#Reference/Core/Geometry
computeBoundingSphere();
Problem desc. follows below.
Hey I'm building a webgl wall for my portfolio site, I need ray intersection to know both when user hovers over the wall and when they click what plane they're clicking on so I can redirect them to correct project.
http://www.martinlindelof.com
What i do is adding all planes on xyz(0,0,0) then I'm using dynamic geometry to place out their vertices on a point grid that's affected by a repelling particle (using traer)
now when I'm doing ray intersect (using examples from threejs r49) I get an empty array back, nothing hit.
could this be because all planes origins are in 0,0,0. should I maybe on each frame not only moving vertices but the entire plane?
or is something else.
(face normals seems to be pointing in the right direction, I see the texture on the plane and it's not inverted as it should be if it was the face backside with double sided planes. guess it's not by default in three.js when creating plane)
Ray got problems with object position 0,0,0 (because somewhere will be divided by position and will result in not dividable). Try another position.