ArunDhaJ
ArunDhaJ

Reputation: 631

TransformControls for custom mesh

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?

Upvotes: 0

Views: 229

Answers (1)

Felipe
Felipe

Reputation: 4375

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

Upvotes: 1

Related Questions