x3dom / x3dom

X3DOM. A framework for integrating and manipulating X3D scenes as HTML5/DOM elements.
http://x3dom.org
Other
813 stars 271 forks source link

Removing a RenderedTexture throws an error. #1231

Open microaaron opened 1 year ago

microaaron commented 1 year ago

Here is an example, it comes from https://github.com/x3dom/x3dom/issues/362. I didn't find any tutorial about RenderedTexture. https://jsitor.com/zj0PlU9Md

Uncaught TypeError: Failed to execute 'deleteFramebuffer' on 'WebGL2RenderingContext': parameter 1 is not of type 'WebGLFramebuffer'. at rt_tex._cleanupGLObjects (x3dom.debug.js:16502:25) https://github.com/x3dom/x3dom/blob/d16543356b77465406d16f5b5c49e9b179522459/src/gfx_webgl.js#L3911

<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <script type="text/javascript" src="https://x3dom.netlify.app/x3dom.debug.js"></script>
    <link rel='stylesheet' type='text/css' href='https://x3dom.netlify.app/x3dom.css' />
    <title></title>
    <style type="text/css">
        body {
            font: 13px/18px Arial, sans-serif;
            background: black;
            color: white;
        }
    </style>
</head>

<body>
    <x3d id="x3d" showStat="false" showLog="true" x="0px" y="0px" width="900" height="900px">
        <scene id="SCENE" DEF="SCENE">
            <shape>
                <appearance sorttype="auto" alphaclipthreshold="0.1">
                    <RenderedTexture DEF="RenderedTexture" id="RenderedTexture" update="always" dimensions="256 256 4">
                        <Shape USE="shape" containerField="excludeNodes"></Shape>
                        <Viewpoint containerField="viewpoint" position="0 0 5"></Viewpoint>
                        <Group>
                            <Shape>
                                <Appearance>
                                    <Material diffuseColor="1 1 0" transparency="0.5"></Material>
                                </Appearance>
                                <Sphere></Sphere>
                            </Shape>
                        </Group>
                        <TextureProperties boundaryModeS="CLAMP_TO_EDGE" boundaryModeT="CLAMP_TO_EDGE"
                            magnificationFilter="NEAREST" minificationFilter="NEAREST" generateMipMaps="false">
                        </TextureProperties>
                        </RenderTexture>
                </appearance>
                <box solid="true" ccw="true" usegeocache="true" lit="true" size="2,2,2"></box>
            </shape>
        </scene>
    </x3d>

    <script>
        setTimeout(() => {
        document.getElementById("RenderedTexture").remove();
      }, 2000);

    </script>
</body>

</html>
microaaron commented 1 year ago

@andreasplesch this._webgl.fbo.rbo is a WebGLRenderbuffer.

Similar codes here. https://github.com/x3dom/x3dom/blob/d16543356b77465406d16f5b5c49e9b179522459/src/gfx_webgl.js#L3976