Create a Mesh out of a list of vertices #179
-
Hello 👋 Here is how I tried to make the geometry (I also tried without indices): const debug = rapierWorld.debugRender();
// Since it is a list of lines, I assume the triangles should be p1 -> p2 -> p1
// Therefore, I generate a list of indices like [0, 1, 0, 2, 3, 2, 4, 5, 4,...]
const indices = new Uint16Array(debug.vertices.length/2)
for(let i = 0, j = 0; j<debug.vertices.length/3; i+=3, j+=2){
indices[i]=j
indices[i+1]=j+1
indices[i+2]=j
}
const geometry = Object.assign(new PIXI3D.MeshGeometry3D(), {
positions: {buffer: debug.vertices},
indices: {buffer: indices},
colors: {buffer: debug.colors}
});
const mesh = new PIXI3D.Mesh3D(geometry);
addPIXIObjectToStage(mesh); Have I done something fundamentally wrong? Is there a better way to do this? Thanks in advance for anyone that'll help me out 🥰 |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Hello! Looks like you forgot to give the mesh a material. Try:
|
Beta Was this translation helpful? Give feedback.
-
Shaderless mesh, don't remember why I made that decision actually 🥇 |
Beta Was this translation helpful? Give feedback.
Hello!
Looks like you forgot to give the mesh a material. Try:
new PIXI3D.Mesh3D(geometry, new StandardMaterial());