Warm tip: This article is reproduced from stackoverflow.com, please click
autodesk-forge autodesk-viewer

Autodesk forge viewer update three js geometries scale

发布于 2020-05-04 09:28:56

I have a basic viewer set up with a model that I am adding some spheres to. The actual adding of the spheres works fine.

var geometry = new THREE.SphereGeometry( 50, 50, 50 );
viewer.impl.createOverlayScene('TestOverlay' , material)
var cube = new THREE.Mesh(geometry, material)
viewer.impl.addOverlay('TestOverlay', cube);

I am trying to get the added spheres to change size triggered by a button outside of the viewer by setting the scale.

scale.set(2, 2, 2)

technically this works but the sphere will only change scale the next time the user interacts with the viewer in some way e.g. something as simple as the users mouse entering the viewer will cause it to update.

I have tried setting the needs update fields on the three js geometry object but that didnt change anything and I could not find anything in the forge documentation about manually updating it.

is there a way to force the update from Javascript

Questioner
wolfman1001
Viewed
52
Bryan Huang 2020-02-18 12:09

Try trigger re-rendering when the scene needs updating to reflect the changes immediately with:

viewer.impl.invalidate(needsClear, needsRender, overlayDirty) // e.g. viewer.impl.invalidate(true)