Toggle visibility of assets

What would be the equivalent code for the ShapeDiver Viewer v3 to list assets, and toggle their visibility?
For v2 the code is as follows:

const toggleDimensions = function (api, val) {

  // look for dimension objects:

  var assets = api.scene.get(null, "CommPlugin_1").data

  let assetsScenePaths = [];

  for (let i = 0; i < assets.length; i++) {
    if (assets[i].name.includes("DIM - ")) {

  if (val == "hide") {
    api.scene.toggleGeometry([], assetsScenePaths);

  if (val == "show") {
    api.scene.toggleGeometry(assetsScenePaths, []);



Hello @post8

sure thing, I created an example for you where I create this behavior with one output. It should be relatively straightforward to adjust your code accordingly.

Cheers, Michael

Hi Michael,

Thanks, that surely got me in the right direction.
One issue: I’m also showing/hiding ‘dimension’ assets which have html-text linked to them.
With the previous viewer they would also disappear when I toggled them off, but now they won’t.

I found out that it’s the “tag2d” outputs that need to be toggled, but setting ‘visible’ to false won’t cut it there.
The code snippet I’ve been trying:

  session.getOutputByFormat("tag2d").forEach((item) => {
    if (!!item?.name.includes("DIM - ")) {
      if (typeof item?.node?.visible === "boolean")
        item.node.visible = false
          // setting this to false won't hide the text-items


Hello @post8
thank you for letting me know about this, there definitely seems to be something going on. I’ll get back to you with a solution!
Cheers, Michael

1 Like

Hello @post8,

this issue has been resolve with viewer version 2.5.0. Here is an example: visibility - html anchors - CodeSandbox

Cheers, Michael

That’s great, thanks!

I did find this flickering behaviour of the dimensions. Maybe you have a clue why this is?

We are aware of this issue and have it filed in our backlog. When Michael comes back he can give you a better estimation of when this fix can be released.

Another thing I’ve noticed is that when the geometry is updated (by updating a parameter), the dimension assets become visible again.
(I’m currently keeping those assets invisible with an always running interval, which is far from optimal.)

Hello @post8,

regarding your first issue, this happens due to an issue with the visibility check that we currently use. A planned restructuring for that is in our pipeline, but this might take a bit longer. As a workaround for now, you can look into creating more space for the dimensions tag, by creating a wider gap between the lines. That should help with the flickering.

For you second issue, how are you currently applying the visibility?
In this example we are using the updateCallback function to re-apply the visiblity of an object. I think this might already solve your problem.

Cheers, Michael