You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It seems to me that when a subscriber to an event is created on a component, the callback to this subscriber is instantaneously resolved if said component had previously fired the event.
Context
In my application, I tried to implement a button to create a sectionPlane from a surface :
my application fires the 'picked' event on the Viewer's SectionPlanePlugin when a element is clicked in the Scene:
handleSelectionClick(pickResult=null){if(!pickResult){return;}console.log('Firing "picked" event');this.sectionPlanesPlugin.fire('picked',pickResult);// Do other stuff related to picking viewer elements}
When my user clicks the "create a section plane from a surface" button, I create a subscriber to the SectionPlanePlugin 'picked' event, using the once() function :
prepareSectionPlaneFromSurface(){this.sectionPlanesPlugin.once('picked',this.createSectionPlaneFromSurface);console.log("Ready to pick surface");}
The callback to this subscriber creates a SectionPlane :
createSectionPlaneFromSurface(pickResult){console.log("Creating plane from picked surface");letplane=this.sectionPlanesPlugin.createSectionPlane({pos: pickResult.worldPos,dir: pickResult.worldNormal});this.sectionPlanesPlugin.showControl(plane.id);}
Current behavior
When clicking the "create a section plane from a surface" button for the first time, then clicking the model, a section plane is successfully created.
When clicking the "create a section plane from a surface" button a second time, a section plane is immediately created, and another section plane is created when the model is clicked.
On a fresh Viewer/SectionPlanePlugin, if the user clicked a model, and a 'picked' event was fired, a section plane is immediately created when the user clicks the "create a section plane from a surface" button.
Expected behavior
Resolving the callback to a subscriber on its creation if the event is "already" in the Component seems like a strange behavior to me.
Local correction
I managed to correct this behaviour by deleting the registered 'picked' event from the SectionPlanesPlugin :
Description
It seems to me that when a subscriber to an event is created on a component, the callback to this subscriber is instantaneously resolved if said component had previously fired the event.
Context
In my application, I tried to implement a button to create a sectionPlane from a surface :
'picked'
event on the Viewer's SectionPlanePlugin when a element is clicked in the Scene:'picked'
event, using theonce()
function :Current behavior
'picked'
event was fired, a section plane is immediately created when the user clicks the "create a section plane from a surface" button.Expected behavior
Resolving the callback to a subscriber on its creation if the event is "already" in the Component seems like a strange behavior to me.
Local correction
I managed to correct this behaviour by deleting the registered
'picked'
event from the SectionPlanesPlugin :** Xeokit Version :**
2.6.69
Desktop :
The text was updated successfully, but these errors were encountered: