xeokit / xeokit-sdk

Open source JavaScript SDK for viewing high-detail, full-precision 3D BIM and AEC models in the Web browser.
https://xeokit.io
Other
728 stars 287 forks source link

[ViewCulling] Visual bug on some elements #371

Closed Amoki closed 3 years ago

Amoki commented 4 years ago

Some faces aren't shown when they should be.

culling problem

xeolabs commented 4 years ago

Could I get that model to debug with?

Amoki commented 4 years ago

Sent in private!

xeolabs commented 4 years ago

I haven't been able to reproduce this bug, at least using this viewer setup: https://gist.github.com/xeolabs/8047d833b2699098ff251868053a556c

Could you post a minimal HTML page that shows this issue?

Amoki commented 4 years ago

I just retried on commit (https://github.com/xeokit/xeokit-sdk/commit/cbde67749e34242259d046d02e8a43eac51794d1) with the following code and the bug is still here:

<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
    <meta charset="utf-8">
</head>
<body>
    <div>
        <canvas id="app" style="height: 100vh;width: 100vw"></canvas>
    </div>
    <script type="module">
        import { Viewer } from "./node_modules/@xeokit/xeokit-sdk/src/viewer/Viewer.js";
        import {ViewCullPlugin} from "./node_modules/@xeokit/xeokit-sdk/src/plugins/ViewCullPlugin/ViewCullPlugin.js";
        import { XKTLoaderPlugin } from "./node_modules/@xeokit/xeokit-sdk/src/plugins/XKTLoaderPlugin/XKTLoaderPlugin.js";

        const viewer = new Viewer({
            canvasId: "app",
            transparent: true
        });
        new ViewCullPlugin(viewer, {
            maxTreeDepth: 20
        });
        const xktLoader = new XKTLoaderPlugin(viewer);

        const model = xktLoader.load({
            src: "./model.xkt",
            edges: true,
        });
        model.once("loaded", () => viewer.cameraFlight.flyTo(model));
    </script>
</body>
</html>
xeolabs commented 3 years ago

I found the reason :-

After hacking the renderer to disabler backface culling, the faces appear:

Screenshot from 2020-12-20 14-39-01

We don't want to enable backfaces to work around these kinds of meshes - it would reduce rendering performance too much.