Options
All
  • Public
  • Public/Protected
  • All
Menu

Version 4.0.0

List of all changes

Added new functions for Shapediver control

Problem with asynchronous Shapediver update functions

Some of the asynchronous update functions of the Shapediver API can interrupt each other and therefore abort previously executed updates.
Here is an example of the scene asset update.

// get Shapediver API and assets which should be added in the scene
const sdApi = SdvCtrlUtils.getSDApiSync();
const cornerHotspots = getCornerHotspotAssets();
const edgeHotspots = getEdgeHotspotAssets();

// start update of corner hotspot assets
sdApi.scene.updateAsync(cornerHotspots);

// start upate of edge hotspot assets
sdApi.scene.updateAsync(edgeHotspots);

The update of the corner hotspot assets was still pending when the new update of the edge hotspots was triggered.
Therefore the update of the corner hotspots was aborted and so only the edge hotspots will be visible in the scene.

In this case the issue could easily be solved by combining the two asset arrays into one and call one combined update.
But in praxis different scene asset updates could be triggered by different events and therefore combining all required assets into one update call can be very difficult.

Shapediver update queue

One strategy to solve this issue is to introduce a wrapper around the Shapediver API, which only passes update calls if no other update function is pending anymore. In this case some kind of waiting queue will be produced, therefore this new feature is called Shapediver update queue.

Update queues have been introduced for the following Shapediver API functions:

Type Function
Parameter api.parameters.updateAsync
Update Scene Asset api.scene.updateAsync
Remove Scene Asset api.scene.removeAsync
Move Camera api.scene.camera.updateAsync
Zoom Camera api.scene.camera.zoomAsync

Each of these functions is represented in the SdvCtrlUtils and can be executed in "queued" and "unqueued" mode.
Furthermore there are additional convenience functions for creating a queue before sending all updates combined as one.

// standalone parameter update in "queued" mode
const resQueued = await SdvCtrlUtils.setParamValue('Color', 'red', sdvInstance, true);
// standalone parameter update in "unqueued" mode
const resUnqueued = await SdvCtrlUtils.setParamValue('Color', 'red', sdvInstance);

// accumulation of parameters and combined updated
SdvCtrlUtils.addToParamQueue('Color', 'red');
SdvCtrlUtils.addToParamQueue('Height', 100);
SdvCtrlUtils.addToParamQueue('Width', 200);
const resAccumulated = await SdvCtrlUtils.processParamQueue(sdvInstance);

Here is an overview over all new functions:

Parameter

Scene Assets

Camera Movement

Remove various system code typings

Some of the system code typings inside the Shapediver control have been removed in favor of the new wrapper functions.
These functions are:

  • Cbn.ctrls.ShapeDiver3dEmbedded.getSDApi
  • Cbn.ctrls.ShapeDiver3dEmbedded.setParamValue
  • Cbn.ctrls.ShapeDiver3dEmbedded.setCameraPos

This is a breaking change!
All occurences of the functions mentioned above have to be replaced with their corresponding wrapper functions in the SdvCtrlUtils class.

Generated using TypeDoc