Search code examples
javascriptautodesk-forgepoint-clouds

autodesk forge potree problem-BufferGeometry.addAttribute() is deprecated. Use BufferGeometry.setAttribute() instead


I am going to proceed with importing point cloud through potree with the following example file. https://github.com/Autodesk-Forge/forge-extensions

I was working with the example file, but I got an error "BufferGeometry.addAttribute() is deprecated. Use BufferGeometry.setAttribute() instead". This problem also occurs in the example file driven site. It happens on other computers as well. Here is the error I got:

enter image description here

If this extension works normally, you should see the point cloud converted from the port tree.


Solution

  • Thank you for the heads-up. The Potree library was ported to the viewer couple years ago, when the viewer was still using WebGL. Now the viewer is using WebGL2 which is why the port is causing issues. In order to get it working again, I'd suggest that you disable WebGL2 support in the viewer by passing the following options to viewer.start (the first four params can be ignored):

    viewer.start(undefined, undefined, undefined, undefined, {
        webglInitParams: {
            useWebGL2: false
        }
    });
    

    After that I was able to load the point cloud again. Here's a branch of one of our code samples with this modification: https://github.com/autodesk-platform-services/aps-simple-viewer-nodejs/tree/sample/potree.

    Also, note that the addAttribute vs setAttribute are just deprecation warnings, not errors. In the code branch above I've updated the potree.js script as well so that the warnings do not appear anymore.