The Viewer3D class exposes many useful methods such as getSelection()
, select(ids)
, or fitToView(ids)
that can be used for what you need. Most of these methods work with ids or dbids which are numerical identifiers representing individual objects.
Try opening one of the existing Forge apps (for example https://forge-basic-app.herokuapp.com), open one of the models, select one or more objects in the model, open the browser console, and type in NOP_VIEWER.getSelection()
. This should return an array of IDs representing the selected objects. Then, try typing NOP_VIEWER.fitToView(...)
passing in the same array of numbers as the first argument (for example, NOP_VIEWER.fitToView([123, 456, 789])
). This should bring the selected objects into camera focus.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…