I am using Autodesk.Viewing.ModelBuilder to add a clickable model in the Autodesk Viewer. While attempting to modify the shape of the added model, I used the changeGeometry method. Although the shape was successfully updated, I encountered an issue where the highlight indicating the selected state of the model does not disappear after clicking on it.
Code Example
if (hit) {
let geom = new THREE.BufferGeometry().fromGeometry(
new THREE.BoxGeometry(10, 10, 60)
);
const material = new THREE.MeshBasicMaterial({
color: 0xff0000,
transparent: true,
opacity: 0.5
});
const pillarMesh = new THREE.Mesh(geom, material);
pillarMesh.matrix = new THREE.Matrix4().compose(
new THREE.Vector3(hit.point.x, hit.point.y, hit.point.z),
new THREE.Quaternion(0, 0, 0, 1),
new THREE.Vector3(1, 1, 1)
);
//model add
await viewer3D.loadExtension('Autodesk.Viewing.SceneBuilder');
const ext = viewer3D.getExtension('Autodesk.Viewing.SceneBuilder');
const modelBuilder = await ext.addNewModel({
conserveMemory: false,
modelNameOverride: 'My Model Name'
});
modelBuilder.addMesh(pillarMesh);
let newGeom = new THREE.BufferGeometry().fromGeometry(
new THREE.CylinderGeometry(5, 5, 60, 50)
);
console.log("changeGeometry", modelBuilder.changeGeometry(pillarMesh.geometry, newGeom));
}
Problem Description
Once the geometry is changed, the highlight persists, even after attempting to deselect the model.
What I Have Tried
Attempted to clear the selection using these methods:
viewer.clearSelection();
viewer.select([]);
viewer.toggleSelect(dbid, ModelBuilder.model);
None of these methods resolved the issue. The highlight remains.
Used changeFragmentGeometry instead:
I replaced changeGeometry with changeFragmentGeometry to modify the geometry. However, the same issue persists, where the highlight does not disappear.
Expected Outcome
I want to modify the geometry of the model dynamically and ensure that the selection state behaves correctly. The highlight should disappear when the selection is cleared or toggled off.