first thing i did is rendered some sprite and then using Autodesk.DataVisualization.Core i have added an event listener onto viewer, of type DATAVIZ_OBJECT_CLICK, but when i am clicking on the sprite. the callback function passed when this event gets triggered is being called only once.I wonder why it can happend.
const dataVizCore = Autodesk.DataVisualization.Core;
function onSpriteClicked(event) {
console.log(event, 'sprite clicked');
const e = new Event('lol', { payload: 'payload' });
dispatchEvent(e);
}
console.log('event registered');
viewer.addEventListener(dataVizCore.MOUSE_CLICK, onSpriteClicked);
When you go to https://hyperion.autodesk.io, and run the following command in the console:
NOP_VIEWER.addEventListener(dataVizCore.MOUSE_CLICK, () => { console.log('Sprite clicked!'); });
You'll see that the callback function is actually called every time you click on a sprite. However, note that the callback is only triggered when you click and select a different sprite. I guess the method should be called SPRITE_SELECTED
or something like that instead of MOUSE_CLICK
. I will report this to the engineering team.