Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

264
Views
Clone object in Forge Viewer

I'm trying to clone an object in Forge Viewer. I have tried using THREE.js and creating a clone but it has different structure to the base object.

sceneBuilder = viewer.loadExtension("Autodesk.Viewing.SceneBuilder");
let modelBuilder = await sceneBuilder.addNewModel({
    conserveMemory: false,
    modelNameOverride: `Custom model`,
  });

let renderProxy = viewer.impl.getRenderProxy(viewer.model, fragId);
let geom = new THREE.Geometry();
let VE = Autodesk.Viewing.Private.VertexEnumerator;
VE.enumMeshVertices(renderProxy.geometry, (v: any, i: any) => {
    geom.vertices.push(new THREE.Vector3(v.x, v.y, v.z));
  });

  VE.enumMeshIndices(renderProxy.geometry, (a, b, c) => {
    geom.faces.push(new THREE.Face3(a, b, c));
  });
geom.computeFaceNormals();
let mesh = new THREE.Mesh(
    new THREE.BufferGeometry().fromGeometry(geom),
    renderProxy.material
  );
(mesh as any).dbId = dbId;
modelBuilder.addMesh(mesh);

I found that renderProxy is also THREE.Mesh, but when I tried let clone = renderProxy.clone(); modelBuilder.addMesh(clone), it doesn't work. Anyway to clone an object in Viewer?

Another thing, when I add a mesh by modelBuilder, I see that the created Object has added to Browser tree, but I still can't use Viewer functions with it (such as Viewer.select(dbId); Viewer.fitToView();)

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Cloning the renderProxy directly probably won't work as Forge Viewer basically returns the same THREE.Mesh instance whenever you request the proxy, just with different internals (for performance reasons).

The code snippet you provided (extracting vertices and faces from the proxy) is a safer choice. Is that snippet working as expected, or is it also causing issues?

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!