Move multiple Geometries, locally and through parameters.updateAsync()

Hi,

I have some trouble solving the following problem using the API:

There are two Geometries - a simple volume/box and an external mesh being loaded from a remote server - which both are connected to an Input-Parameter (range slider) that affect the length of the box and/or position the mesh. I need to achieve the translation of the mesh simultaneously when changing the box-length through an parameter.updateAsync({name: “length-of-box”, value: rangeslider.value }). This works well, when I push another entry to the updateParameterObject - however, in order to save computation time, I want to make use of changing the SceneAsset of the mesh itself and move it locally.

I have tried two ways to change the SceneAsset of the mesh, which both cause different problems:

  1. api.scene.updateAsync({ id: mesh.id, content: …(translation included)… }, ‘CommPlugin_1’);
    The mesh jumps weirdly through the model while updating the parameter (visually bad solution).

  2. api.scene.updatePersistentAsync({ id: mesh.id, content: …(translation included)… }, ‘CommPlugin_1’);
    the parameter.updateAsync() is aborted, while the mesh has instantly moved.

Perhaps I didn’t fully understand the concept of both functions at all - or I simply mixed up something. Thanks for your help in advance.

Best,
anhelm

Have a look at the local transformations example below. The object is scaled in this case but you can replace the scaling with translations. I hope this helps and let us know if you have any issues.

1 Like

Thanks for your support. It was actually not the 100% issue I was looking, however your code gave me the right hint to finally succeed by putting the second updateAsync() into a callback function of the first updateAsync(), like:

api.parameters.updateAsync([{name: paramName, value: paramNewValue }]).then(function() {
api.scene.updatePersistentAsync(updateObject, ‘CommPlugin_1’); });

see results here: https://codepen.io/anhelmphono/pen/eYJxMrr

Best,
anhelmphono