pos.count is the number of vertices, they are non-indexed, thus the number of triangles is pos.count/3. See line 90, which converts some integer n to a valid number of triangle:
@PavelBoytchev Hum sorry to come back to you but I think I’ve found a problem with your solution. taking the example of 4 speakers as shown in my poor drawing this should make 2 triplets but with your solution I would get 3 meshes instead of 2.Any workarounds?Thanks. you can test in your code by replacing Nby 4.
I’d not consider there is a problem, as the demo represents my understanding, which is obviously different. Thus the demo is not a solution to your use case.
For example, I assume that the speakers encompass the sphere from all sides, so in addition to the two triangles in your diagram, there are other two triangles that “cover” the rest of the sphere, so it is completely wrapped (if you cast a ray from the center towards any direction, it will always intersect one of the triangles, as there are no holes).
Imagine 4 speakers are in the vertices of a regular tetrahedron, how would you pick only two triangles from all 4 triangles, as all triangles are identical in shape, size and relative orientation? It is possible that you might want speakers to cover part of a sphere, not wrap around the whole sphere. If this is the case, this is some new requirement I was not aware about. In any case, I cannot be of further help. It is OK to unmark the solution, so that other people know your are still looking for a solution.
OP you aren’t explaining what you’re trying to build, but only describing very small windows into the behavior that you need.
It’s like trying to assemble a jigsaw puzzle under a microscope.
You have lots of highly skilled people here spending their time for free trying to help you. Your main job here is to provide all the information they need to solve your problem.
Please describe what you are trying to build on a high level, and if possible, screenshots or examples of existing solutions to the same kind of problem.
From what I can tell… you’re building some kind of dome that you can hang audio speakers on for some reason?
But then you have specific, yet vague requirements like constructing shapes from sets of vectors?
Basically I’m developing a sound spacialisation app and I use THREE.js for parts of the UI.
So I’m implementing the VBAP algorithm from Ville Pulkki try searching ‘virtual sound source positioning using vector base amplitude panning’ on google and you will find the paper.
Here I’m using the 3D version.
I have a bit of difficulty to explain but basically an undefined numbers of loudspeakers are set on a convex hull and let’s say we want to position one audio source at a time, then this audio source will be played on a set of 3 loudspeakers then if we move the source maybe they will be played on the nearest other set ( other sets will be disabled).To do so I need to find speakers triplets (what I call set of 3 speakers) and this is usually done with simplices (don’t ask what it is) that I guess are usually found using delaunay triangulation.
I think Pavel have a great solution but I’m not sure it gives me the desired result (but I’m not entirely sure), based on the figures of the paper a set of 4 speakers gives two triplets (correct me if I’m wrong).
Hope it’s clearer now, I’m doing my best to be the clearest as I can…
@manthrax I don’t know if you can help me on this one but after searching on the net I got more informations. please see this link (it’s http). You have a more or less detailed explanation of the triangulation and on the second part you even have an explanation on how to detect triangles I should avoid using. They are talking about normals that points inward (and I honestly don’t understand what is a normal) also do you think I could use calculation plus Pavel’s solution to make that work.Thank you
alos I need to add the fact that a delaunay library exist on npm but it uses require so I haven’t been able to make it work, this is why I’m trying to find a more built-in solution
I didn’t read it. If this is academic paper, it might describe some very general case, which requires to split the space into simplex pieces.
The video above is oversimplified, because the three vertices are just the closest three vertices. With an almost regular net like the one that I used, this is sufficient. In the general case, where vertices could be distributed irregularly (e.g. in clusters), such approach may fail.
The bottom line is, if you analyze the exact properties of your input data, you may find that some simple solution will also work for you. Thus you do not need to jump into the most general solution, which is also much harder to implement.
Here is the code of the video. It is ugly code, as I don’t have time to make it beautiful.
The function that finds the three closest points is fireSpeakers( ) at lines 89-102.
Do not be confused by using simplex in the code, this is just a class that generates simplex-based noise. I use it to make ‘random’ trajectory and camera.
The bottom line of the bottom line is that this might not be what you need, especially if your distribution of speakers is very irregular.
@PavelBoytchev Thank you for sharing I will have a look at it for sure. But I think I need to implement the paper’s solution because the position of the source is activating the triplets from the inside of the convex hull.The speakers are meant to be always onto the convex hull but I guess they can have irregular positions even though it’s better to have an harmonious setup in order for the algorithm to work.Thanks again
If you see this as an ugly code, it shows the high standard.
When looking for examples for the collection, I often see very, very ugly code in comparison and I often have to see if I can make a copy without too much effort.
@PavelBoytchev yes I understand here I guess you are using distance bu I need to use angles and matric dot products in order to make the algorithm work.But thanks anyway