0

I followed the below example and able to draw custom mesh over Forge Viewer. https://forge.autodesk.com/blog/handling-custom-meshes-selection-along-model-components-forge-viewer

Extending it, I've added TransformControls tool to the custom object selected in handleSingleClick event;

if (selections.length) {
    console.log('Custom meshes selected:')
    console.log(selections)

    const control = new THREE.TransformControls(this.viewer.impl.camera, this.viewer.impl.canvas, 'translate');
    control.attach(selections[0].object);
    this.viewer.impl.addOverlay('myOverlay', control);

    this.viewer.impl.sceneUpdated(true);

    return true
}

Now, when I try to drag the transform tool, the custom object is not moving.

Is my approach to transform my custom object is correct?

ArunDhaJ
  • 621
  • 6
  • 18

1 Answers1

1

There is a lot more code needed to handle the dragging of the mesh, like handleButtonDown, handleButtonUp, handleMouseMove ... I wrote a tool that is handling transforms for the viewer components, you could use that as starting point to transform custom meshes as well with some tweaks:

Viewing.Extension.Transform

Also those articles:

Moving visually your components in the viewer using the TransformTool

Rotate Components Control for the Viewer

Felipe
  • 4,325
  • 1
  • 14
  • 19
  • Are these extensions in `Viewer.Extensions.Dynamic` folder not available by default? Should we copy these JS files and include in our project? – ArunDhaJ Feb 14 '18 at 05:36
  • This is a custom project, none of this code is available by default. It's not easy to just cut and paste those in your own project due to dependencies, ES6 and some of them have a UI implemented in React. The project source code is provided as-is for demo purpose. – Felipe Feb 14 '18 at 08:53