This seems to give me the objects as full JS objects, and not as the viewer’s interactive objects, on which to call the “on” function. I get this error: error = Uncaught (in promise) TypeError: sketch.on is not a function
What would be the correct way to get an object on which to call the ViewerEvent function?
While it’s possible to access nodes straight from the tree like you do, it’s discouraged. Generally you want to search by specific ids, or if ids are not known, by specific property values. If you let me know how you can identify topSolidAllElements nodes I can show you how to fetch them in a more elegant way
Regarding double-clicking, I believe you misunderstood how the event works. Nodes do not emit events. The ViewerEvent you are looking for is ViewerEvent.ObjectDoubleClicked which you can listen for on the viewer instance itself. The event’s payload will be a SelectionEvent which will hold all the nodes you clicked on, ordered by distance to the camera
viewer.on(ViewerEvent.ObjectDoubleClicked, (event: SelectionEvent | null) => {
if(!event) return
const doubleClickedNode = event.hits[0].node
// Do something with the node
})
Thanks a lot @alex !
I’m trying to implement it. Your code works really well, now I understand the concept of ViewerEvent.
I have a subsidiary question. I need the double-click to show/hide dimensions of sketches. In TopSolid, dimensions are displayed as lines and a number. The sketch is sent to speckle as one object. So the normal lines (red on the screenshot) and the dimensions lines (black on the picture) are together in the same object, as different profiles of the sketch
My question is : does filtering.hideObjects also works on parts of an object? (it seems not) Or should we send to speckle the sketch and its dimensions separately as two objects?
Thank you