API V3 + Parameters are reset when session.customize() is used

Hello there,

We are currently using version 3 of the api. I am going to explain step by step how we start the viewer and the session:

  1. The session and the viewer are loaded in parallel.
  2. The result of each promise is saved as a global variable, so that it can be accessed later through window.session and window.viewer.
    2A. First error found: the parameters that we add to “InitialParameters” (api.createSession) do not load correctly, but if after the creation is finished the session TreeNode is used and session.customize() is used, these parameters do load.
  3. The first parameters are updated and then window.session.customize() is executed.
  4. When we try to update a parameter other than the ones we first updated, for some strange reason the first parameters are reset, forcing us to update their values again. The above should not reset other values.
    4A. The second bug is that whenever we update a parameter it resets the value of another parameter.

Note: the parameters that generates the failures is when we are hiding/showing objects, if need more details please let me know.

Thank you!

Thank you for reporting those issues. Could you create a codepen/codesandbox showcasing 2A and 4A (two separate pens if needed)? That would help our developers investigate potential bugs or clarify documentation.

Hello, I’m trying to replicate my error, but it was not possible, I will explain it step by step:

  1. When I changed the visibility of an Output for example:
    session.getOutputByName('doorNumbers').find(({ material })=> material).node.children.forEach((children) => { children.visible = false; })

The output has 1-9 elements. We always need to hide all or show some elements and update parameters before/after.

The problem happen when I try to modify the visibility and update a parameter at same time.

The parameter update it’s loaded correctly, but the visibility of the outputs is reset to the default value (in this case: visible = true);

Our temporary solution was:
A. we update the parameter
B. run session.customize()
C. when the promise is completed then update the visibility of the outputs.
D. run session.updateOutputs()

The final result it’s okay, but the model first update the parameter, after show the elements that previously are hidden, after the model hide that elements and finally the model is loaded with the new parameters and the visibility of the outputs loads correctly.

I think the error is at session.customize(), because in the docs said:
Customize the session. All parameter changes will be sent to the server. The server computes the results, sends the results back. The results are put into the scene tree and the viewers are updated.

I believe that when the parameters are sent to the server via session.customize(), the server resets the outputs content to the default values, these new results overwrite the content of the local outputs.

I hope this help to solve the problem. Thank you!

hello @mathieu1 it was possible to see my message, we are blocked by this problem

Today I see a new related problem, when we change the texture of an output, this is reset when we use session.customize(). I think this method resets all values that are not calculated on the server, after this it overwrites local changes. In V2 this did not happen!

Unfortunately, there is no easy way to apply this type of permanent updates in viewer 3 yet. We are currently discussing the best way to approach this and implement a solution soon. I will update let you know when a new version is released.

in the V2 the function scene.updatePersistentAsync get the result that we need, maybe there is a similar one in V3?

The viewer 3 API currently does not offer an equivalent to updatePersistentAsync. The viewer will soon be updated with this functionality (although it might work a little differently). I will update this thread once the new version is released.