Sudoku Posted November 19, 2018 Share Posted November 19, 2018 Hi i am trying to write some tests to check if the pointerevents are processed correctly, but i have troubles triggering an onPointerObservable event. this._scene.onPointerObservable.add(() => { this.doSomething(); }, BABYLON.PointerEventTypes.POINTERMOVE); test doesn't call the soDomething() function: const pointerevent = new MouseEvent('click', {clientX: 500, clientY: 500}); scene._onPointerMove(pointerevent, new PickingInfo(), PointerEventTypes.POINTERMOVE); does someone have an idea what i am doing wrong? For the doSomething() i just need pointerX and pointerY, i do not need the picking info Quote Link to comment Share on other sites More sharing options...
ssaket Posted November 19, 2018 Share Posted November 19, 2018 2 hours ago, Sudoku said: this._scene.onPointerObservable.add(() => { this.doSomething(); }, BABYLON.PointerEventTypes.POINTERMOVE); PG please, meanwhile have you checked the context, this looks like window to me. Quote Link to comment Share on other sites More sharing options...
Sebavan Posted November 19, 2018 Share Posted November 19, 2018 onPointerMove is triggered only when smthg has been picked. you could use onPrePointerObservable to ensure you ll be called on every move. ssaket 1 Quote Link to comment Share on other sites More sharing options...
Sudoku Posted November 19, 2018 Author Share Posted November 19, 2018 thanks for your answers! the manual interaction with the observable works fine. this.doSomething() is called on every move actually as it seems, i printed some console statements to test that. I had only troubles with writing automatic tests for the doSomething() code because i could not push an pointerevent into the observable - so it is difficult to write a PG for that. but i FINALLY found out how to get my mouseevent in there const pointerevent = new MouseEvent('click', {clientX: 500, clientY: 500}); scene.onPointerObservable.notifyObservers(pointerevent); notifyObservers... it was too obvious ^^ .. well.. Thanks again, have a nice day! Quote Link to comment Share on other sites More sharing options...
Sudoku Posted November 19, 2018 Author Share Posted November 19, 2018 but i am just realizing - pointerX and pointerY in the babylon scene are still not overwritten using that code. i would expect those values to be 500 but both are set to 0 Quote Link to comment Share on other sites More sharing options...
Sebavan Posted November 20, 2018 Share Posted November 20, 2018 this gets only updated from real pointer events on the window. In order to simulate the full behavior you could call scene._onPointerMove which takes pointer event (the window ones). Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.