Wireframes extension unload lines on every update

狂风中的少年 提交于 2019-12-11 15:19:04

问题


I'm using this wireframe extension https://autodeskviewer.com/viewers/latest/extensions/Wireframes/Wireframes.js which I slightly modified its colors.

If I slightly move the camera, all the lines disappear and since our app constantly get input from the sensor, we end up with the lines always not showing.

I can't find what is making those lines disappear. How can I make those to always be visible?

It also happens in this example which you can reproduce:


回答1:


Another way to avoid this issue after my research. Instead of using impl.scene and impl.sceneAfter, you can add those wireframe geometries into the viewer overlay. Here are the snippets of a workaround:

//!-- 1. Add this two line in the `load` function.
if( this.viewer.impl.overlayScenes[this.overlayName] === undefined )
    this.viewer.impl.createOverlayScene( this.overlayName );

//!-- 2. Modified `addWireframes` with overlay functions
function addWireframes(viewer, overlayName, groups) {
    var groupsCount = groups.length;
    for (var i = 0; i < groupsCount; ++i) {
        viewer.impl.addOverlay( overlayName, groups[i] );
    }
    viewer.impl.invalidate(false, true, true);
}

//!-- 3. Modified `revertWireframes` with overlay functions
function revertWireframes(viewer, overlayName, groups) {
    var groupsCount = groups.length;
    for (var i = 0; i < groupsCount; ++i) {
        viewer.impl.removeOverlay( overlayName, groups[i] );
    }
    viewer.impl.invalidate(false, true, true);
}

//!-- 4 Update `impl.invalidate` function calls
viewer.impl.invalidate(false, true, true);

//!-- 5. Update function calls of both `addWireframes` and `revertWireframes`, for example:
addWireframes(this.viewer, this.overlayName, this.groups);
revertWireframes(this.viewer, this.overlayName, this.groups);

P.S. Since this is just a workaround, not the formal solution. You would have to use it at your own risk.

=== Old Answer

This might caused by the progressive rendering, you can turn it off via viewer.setProgressiveRendering( false ). But it will hurt the performance while viewing a large model in the Forge Viewer.

Progressive rendering is the way how the viewer render large models. And it's no way to prevent and be fixed now unfortunately.

Here is what it looks like on my side:

https://imgur.com/a/TnlzW



来源:https://stackoverflow.com/questions/45960907/wireframes-extension-unload-lines-on-every-update

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!