Unable to set scene settings with constructor

Hi,

I’m not able to adjust the scene settings with the setting object from the getting started example code project (i have modified some from the example) Any help with this noob question would be great. I think that i may not be supplying the “containerSettings” with the correct element. I reference this documentation for the containerSettings

`

var initSdvApp = function(/*event*/) {            

        let settingSetup = {scene : {
              gridVisibility : false, 
              groundPlaneVisibility : false
            }}

        let _container = document.getElementById('sdv-container'); 

        let settings = {
            container: _container,
            ticket: "TICKET",
            modelViewUrl: "eu-central-1",

            containerSettings: settingSetup
          
        };

        window.api = new SDVApp.ParametricViewer(settings);

        };

I’m new to Javascript so this must just be me missing something.

Thanks

I don’t see a valid ticket in your code so before we go any further, can you try it again but with a ticket? Just copy the one from the JSFiddle example.

Hi Pavol,

Thanks for your reply. yes, it does work when i past in that ticket and it does load and display with my models. however, I’m not able to set any of the scene settings in that constructor’s option “containerSettings” such as the grid visibility and ground plane.

I am able to change the settings later in the code by calling the api.scene but then i have to attach them to an event and some action. I’m trying to have it load the settings i want from initializing the viewer.

I’m not sure that i understand how to input the right element for the “containerSettings” option.

From what I think you are trying I can tell you that I am pretty sure its not possible. You cant load it with the right settings straight away.

But what you can do is set the parameters at the first possible instance. So you just add an Eventlistener and do something on VISIBILITY_ON like:

api.scene.addEventListener(api.scene.EVENTTYPE.VISIBILITY_ON, function() {


      	  api.parameters.updateAsync([{name: "yourparametername1", value: "yourparametervalue1"}, {name: "yourparametername2", value: "yourparametervalue1"}]).then(
            function(response) {
              api.scene.camera.zoomAsync(); 
              // do more things here if needed
            }
          );

Took me a while to figure these things out. I was really hoping there would be a way to actually load it with the correct settings, but I dont think I ever got an answer on that part from Shapediver if it is planned or possible.

@seltzdesign ah ok this makes sense. I kept thinking i was just missing something in the init function but this works well.

thanks for you help!

@pavol if there has been an update to passing these settings to the init function please let me know. otherwise this solutions works.
Thanks again!