Closed risacher closed 11 years ago
Interestingly, Chrome's WebGL implementation displays a partial mesh, while Firefox displays nothing.
As it turns out, the CSG that I'm trying to model actually only has about 22k vertices, but in csgToMesh() [around openjscad.js:291] each vertex is copied into the mesh vertex list separately for each polygon it is in - which multiplies my vertex count to 130k - well above the WebGL 16bit-index limit. If I set smoothlighting = true, then the vertexes are not copied multiple times, but the normals get interpolated and it no longer looks like the real shape.
Perhaps a different shader would solve the problem? I don't know anything about WebGL shaders yet.
Rather than mess with the shaders, I implemented splitting a CSG into multiple meshes.
Close with Pull Request #23
WebGL can apparently only handle 16-bit indexes into the Vertex array, so if you try to draw something with more than 64k vertices, it doesn't work. This can be worked around by splitting the draw call up so not all the polygons get drawn at once.
Would be cool if OpenJsCad could separate the mesh somehow to work around this limitation.