Skip to content
Advertisement

Forge Viewer – How to access (or get render/fragment proxy of) cloned Meshes in scene?

I have a problem with Forge Viewer when i add a cloned object to scene i can see it, but not select it or make any changes to it.

I have this pseudo-code.

// get first selected Mesh
let selected = Object.values(viewer.impl.selectionMeshes)[0];

// clone it
let clone = selected.clone();

// add it to scene
viewer.impl.scene.add(clone);

// update scene
viewer.impl.sceneUpdated(true);

Did i miss something? Or do i need to make cloned object a part of the model?

Advertisement

Answer

You can add custom meshes to Forge Viewer in various ways, for example:

  • as you did, by inserting three.js meshes into viewer.impl.scene or viewer.impl.sceneAfter
  • using the overlay manager
  • using the new scene builder extension

Note that the first two approaches are typically only used for “overlays”, meaning that the meshes don’t behave (interact with the viewer) in the same way as the actual loaded model. With the scene builder however the custom meshes can be hovered, selected, etc.

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement