How to solve the mouse event problem caused by Babylon and cesium integration?

I use it to integrate Babylon and cesium, but the pick operation in Babylon cannot be clicked, how to solve it

window.addEventListener(“click”, function () {
// We try to pick an object
var pickResult = _this.scene.pick(_this.scene.pointerX, _this.scene.pointerY);
if (pickResult.hit) {
x = pickResult.pickedPoint.x;
y = pickResult.pickedPoint.y;
z = pickResult.pickedPoint.z;
box.position = new BABYLON.Vector3(x,y,z);
the pick _this.scene.pointerX Always 0

Welcome abroad!

pointerX and pointerY are always 0 because that example sets the babylon canvas’ pointer events to none. But you don’t need them in this case if you’re using a click event listener, you can use clientX and clientY from the event.

1 Like