|
@@ -19,6 +19,7 @@ import { quad_vert } from '../../../mol-gl/shader/quad.vert';
|
|
|
import { isosurface_frag } from '../../../mol-gl/shader/marching-cubes/isosurface.frag';
|
|
|
import { calcActiveVoxels } from './active-voxels';
|
|
|
import { isWebGL2 } from '../../webgl/compat';
|
|
|
+import { Scheduler } from '../../../mol-task';
|
|
|
|
|
|
const IsosurfaceSchema = {
|
|
|
...QuadSchema,
|
|
@@ -185,26 +186,36 @@ export function createIsosurfaceBuffers(ctx: WebGLContext, activeVoxelsBase: Tex
|
|
|
gl.clear(gl.COLOR_BUFFER_BIT);
|
|
|
renderable.render();
|
|
|
|
|
|
- gl.flush();
|
|
|
+ gl.finish();
|
|
|
|
|
|
return { vertexTexture, groupTexture, normalTexture, vertexCount: count };
|
|
|
}
|
|
|
|
|
|
//
|
|
|
|
|
|
-export function extractIsosurface(ctx: WebGLContext, volumeData: Texture, gridDim: Vec3, gridTexDim: Vec3, gridTexScale: Vec2, transform: Mat4, isoValue: number, packedGroup: boolean, vertexTexture?: Texture, groupTexture?: Texture, normalTexture?: Texture) {
|
|
|
+function delay() {
|
|
|
+ return new Promise(r => Scheduler.setImmediate(r));
|
|
|
+}
|
|
|
+
|
|
|
+export async function extractIsosurface(ctx: WebGLContext, volumeData: Texture, gridDim: Vec3, gridTexDim: Vec3, gridTexScale: Vec2, transform: Mat4, isoValue: number, packedGroup: boolean, vertexTexture?: Texture, groupTexture?: Texture, normalTexture?: Texture) {
|
|
|
// console.time('calcActiveVoxels');
|
|
|
const activeVoxelsTex = calcActiveVoxels(ctx, volumeData, gridDim, gridTexDim, isoValue, gridTexScale);
|
|
|
- // ctx.waitForGpuCommandsCompleteSync();
|
|
|
- // console.timeEnd('calcActiveVoxels');
|
|
|
+ // apply advanced magic to solve incomplete buffer rendering issue
|
|
|
+ await delay();
|
|
|
|
|
|
// console.time('createHistogramPyramid');
|
|
|
const compacted = createHistogramPyramid(ctx, activeVoxelsTex, gridTexScale, gridTexDim);
|
|
|
+ // apply advanced magic to solve incomplete buffer rendering issue
|
|
|
+ await delay();
|
|
|
+
|
|
|
// ctx.waitForGpuCommandsCompleteSync();
|
|
|
// console.timeEnd('createHistogramPyramid');
|
|
|
|
|
|
// console.time('createIsosurfaceBuffers');
|
|
|
const gv = createIsosurfaceBuffers(ctx, activeVoxelsTex, volumeData, compacted, gridDim, gridTexDim, transform, isoValue, packedGroup, vertexTexture, groupTexture, normalTexture);
|
|
|
+ // apply advanced magic to solve incomplete buffer rendering issue
|
|
|
+ await delay();
|
|
|
+
|
|
|
// ctx.waitForGpuCommandsCompleteSync();
|
|
|
// console.timeEnd('createIsosurfaceBuffers');
|
|
|
|