Implementing ThreeJS Transform control to Autodesk Forge Viewer

Viewed 185

I'm trying to include ThreeJS Transform control into my Forge Viewer, using this tutorial:

https://adndevblog.typepad.com/cloud_and_mobile/2015/08/moving-visually-your-components-in-the-viewer-using-the-transformtool.html

Currently I am able to insert the Transform Control into the viewer, but cannot interact with it. In my code, I have to change a bit from the tutorial. Instead of adding overlay, I'm adding a scene and then add the Transform Control using viewer.impl.addMesh(TransformControl). For some reason unknown, add overlay doesn't work.

Are extra steps required to interact with meshes in different scene than the main scene? Here is my code snippet:

const transformControlTx: TransformControls =
      new THREE.TransformControls(viewer.impl.camera, viewer.impl.canvas, "scale");
transformControlTx.setSize(cube.geometry.boundingSphere.radius * 5);
transformControlTx.addEventListener('change', reRender);
if (!viewer.overlays.hasScene('CubeTranformScene')) {
      viewer.overlays.addScene('CubeTranformScene');
}
transformControlTx.attach(cube);
viewer.overlays.addMesh(transformControlTx, 'CubeTranformScene');

I would like to have this transform control to be able to control the scale of the cube I attached, which is also a custom ThreeJS Mesh

1 Answers
Related