WebScene Slides not applying

2326
11
07-04-2021 10:32 PM
JethroLeevers
Occasional Contributor

Hi All,

 

I have been having issues with the WebScene slides.

It seems to be an issue with the visibleLayers properties of the slides not being populated.

Sometimes they work fine, other times the visibleLayers property contains no items and hence the slide does not appear to work when using the applyTo function.

 

Regards,

Jethro

Tags (3)
0 Kudos
11 Replies
JethroLeevers
Occasional Contributor

I have still had no luck getting to the cause of this issue 😓

Could this be related to any of the layers timing out on start up? (Australian Internet)

Would also like to add that this is using a dojo built deployment

0 Kudos
JohnGrayson
Esri Regular Contributor

Could it be that the web scene is not fully loaded before you try to call applyTo?  Do you have a very simple codepen showing the basic steps you're taking in your code?

JethroLeevers
Occasional Contributor

I don't think that is the case unless there is some other promise that i'm meant to be waiting for, I initialise my buttons to load the slides inside the view.when, this is also after map.when

I have made a pen that is similar to my setup but am unable to replicte the issue

https://codepen.io/leevers/pen/xxdgLBa

0 Kudos
JohnGrayson
Esri Regular Contributor

The 'when()' method tells us that the JS instance is ready to interact with in code.  You can use 'load()' or 'loadAll()' to ensure all of the resources that need to be loaded asynchronously are available.  Also, your code tries to create the SceneView outside of (before) the WebScene 'when()' call resolves.  In certain circumstances this will matter because even though the SceneView instance is ready, the WebScene resources you want to use might not be loaded.  Hopefully these small changes will help in your app.

https://codepen.io/john-grayson/pen/BaRpbzY

 

JethroLeevers
Occasional Contributor

Thanks John.

Really, this is the first time I've seen this, every example (https://developers.arcgis.com/javascript/latest/sample-code/intro-sceneview/) I've seen does exactly that.

Can you furthur clarify what setup I should be using to make sure everything is ready to use?

map = new WebScene({...})

map.when( ()=>{

 view = new SceneView({...})

 view.when( ()=>{

  map.loadAll().then( () => {

   // Should be good now?

  });

 });

});

 

is the loadAll called internally? or should I be using map.loadAll.then() instead of map.when(... or Promise.all([map.when(), map.loadAll()]).then(...

0 Kudos
RalucaNicola1
Esri Contributor

So if you create a webscene and then set it on the view, the api internally calls the `load` method once it's set on the map property of the view. If then you call `webscene.when` that should run the callback you're passing exactly when the load method resolves.

 

const webscene = new WebScene(...);

const view = new SceneView({
  ...
  map: webscene
});

webscene.when(() => {

// now you have access to layers, ground and basemap

});

 

The load method however, doesn't load all the loadable resources/sublayers etc. Slides might also not be ready depending on how heavy your scene is. So I'd advise you to use `loadAll()` to wait for all the resources like John showed in his example:

 

map.loadAll().then(() => {

// the scene is now fully loaded and you can create the view, the slides, set properties on layers etc.
// you don't need map.when() anymore
// you can use view.when() if you want to make sure that the view is ready. In case you make changes before this point, they might get overriden when the map is set on the view.
})
.catch((err) => console.log(err));

 

 

JohnGrayson
Esri Regular Contributor

'WebScene.when()' just tells you the JS instance is ready, so you can for example set it as the 'map' property of the SceneView.  It does not however tell us its internal properties that rely on asynchronous calls are ready, that is what the 'load()' and 'loadAll()' are for.  This follows the 'loadable' pattern in the JS API.  That specific example doesn't show this pattern because it doesn't try to use WebScene properties before they're ready.  In your use-case, you're looking to modify layer properties and access the slides, and for this use-case you need to wait until the WebScene has retrieved and set these internal properties correctly.

0 Kudos
RalucaNicola1
Esri Contributor

when you check the webscene json, are the visible layers in the slides or are they missing? For the example that you shared, they would look like this: https://aam-ags-demo-03.aamgeocloud.com/portal/sharing/rest/content/items/9a5c8855529c4109b53032084b...

 

{
  "id": "177ff571076-slide-2",
  "title": {
    "text": "Sydney 7.5cm Photo Mesh Model 2020"
  },
  ...,
  "visibleLayers": [
    {
      "id": "17964079d27-layer-17"
    },
    {
      "id": "177fc6aa2cb-layer-0"
    }
  ]
},

 

JethroLeevers
Occasional Contributor

Thanks Raluca,

The slides data always exist in the data url, they just dont seem to make it though to the slides.visibleLayers, the viewpoint, title and image are always populated.

Jethro

0 Kudos