Reputation: 15
I need to create a ShapeGeometry that can take in a list of points that represent the shape boundary or faces and a list of textures to assign to each face. I have looked at the BoxBufferGeometry class and that would work as a base point, but I need guidance / examples of how to have (n) amount of points and working out vertices,indices,normals and uv's procedurally based on that list of points / vectors.
I have extended buildplane section to allow for 2 x cubes, which looks like it works as there are 2 cubes displayed one inside of the other, but I lack the knowledge of how to set the position or place the second list of shape vectors in relationship to the first. I have used merge mesh function but that causes the joining faces to display a line even though they are on the same "plane", also if i want custom angles I cannot use existing geometries.
buildPlane( 'z', 'y', 'x', - 1, - 1, basedepth, baseheight, basewidth, depthSegments, heightSegments, 0 ); // px
buildPlane( 'z', 'y', 'x', 1, - 1, basedepth, baseheight, - basewidth, depthSegments, heightSegments, 1 ); // nx
buildPlane( 'x', 'z', 'y', 1, 1, basewidth, basedepth, baseheight, widthSegments, depthSegments, 2 ); // py
buildPlane( 'x', 'z', 'y', 1, - 1, basewidth, basedepth, - baseheight, widthSegments, depthSegments, 3 ); // ny
buildPlane( 'x', 'y', 'z', 1, - 1, basewidth, baseheight, basedepth, widthSegments, heightSegments, 4 ); // pz
buildPlane( 'x', 'y', 'z', - 1, - 1, basewidth, baseheight, - basedepth, widthSegments, heightSegments, 5 ); // nz
buildPlane( 'z', 'y', 'x', - 1, - 1, facedepth, faceheight, facewidth, depthSegments, heightSegments, 6 ); // px
buildPlane( 'z', 'y', 'x', 1, - 1, facedepth, faceheight, - facewidth, depthSegments, heightSegments, 7 ); // nx
buildPlane( 'x', 'z', 'y', 1, 1, facewidth, facedepth, faceheight, widthSegments, depthSegments, 8 ); // py
buildPlane( 'x', 'z', 'y', 1, - 1, facewidth, facedepth, - faceheight, widthSegments, depthSegments, 9 ); // ny
buildPlane( 'x', 'y', 'z', 1, - 1, facewidth, faceheight, facedepth, widthSegments, heightSegments, 10 ); // pz
buildPlane( 'x', 'y', 'z', - 1, - 1, facewidth, faceheight, - facedepth, widthSegments, heightSegments, 11 ); // nz
I need to be able to plot vectors/points in 3d space, set faces and assign unique textures to each face as the shape gets generated at runtime from saved data (location, size, textures)
a representation of my issue
Upvotes: 1
Views: 263
Reputation: 2551
Just create helper function that creates buffer geometry from edge vertices by filling "position", "color", "uv" buffer attributes. I don't recommend to use indexed buffered geometry.
See examples here: Custom buffer geometry
Upvotes: 1