Trying to use environmental maps in ShapeDiver v3

Hello !

I am trying to upgrade our ShapeDiver viewer from v2 to v3. Everything is going well so far, except for the background image and I can’t find much in the documentation on that topic.

Before the code was

var sceneSettings = {
        scene : {
          material : {
            environmentMapAsBackground : true,
            environmentMap : pluginOptions.SD_env_map
          },
        }
      };

[...]

api.parameters.updateAsync([
        {name: 'PATTERN', value: patternID}
      ]).then(function(response) {
        // Need to do it when first updateAsync is finished.
        api.updateSettingsAsync(sceneSettings);
      });
    });

Now the new code is

let _container = document.getElementById('sdv-container');
  const viewport = await SDV.api.createViewer({
    canvas: _container,
    id: "myViewer"
  });
  
  viewport.environmentMapAsBackground = true;
  viewport.environmentMap = pluginOptions.SD_env_map;

I can see that the images are correctly loaded in the network tab of the browser, but nothing is showing in the viewport (white background).

Any help would be greatly appreciated :slight_smile:

Loïc

Hello @Loïc_Hall,

I tried to recreate your issue but everything seems to work just well. See here

On which exact version are you at the moment?

Cheers, Michael

Thanks for your reply.

I’m a running this version : ShapeDiver-Viewer version: 3.1.15.7

Maybe there’s a difference when creating the Viewport ? When I try with my textures in your snippet, it works, but I am using SDV.api.createViewer and you are using createViewport.

Hello @Loïc_Hall,

the difference in naming is explained here. As we are improving Viewer 3 all the time, some breaking changes were necessary. This was mostly just renaming though, so it should be easy to adapt in your code.

I would ask you to update to the newest version (2.2.1) and see if it works there. If that is not the case, we have to do some further investigation.

Cheers, Michael