Weird things happening sometimes after detaching and reattaching camera controls

@MarkBevels @mawa @PirateJC
I have good news, I think i fixed the problem with a simple change:

from
camera.inputs.attached[‘pointers’].attachControl(canvas);
to
camera.attachControl(canvas);

and
camera.inputs.attached[‘pointers’].detachControl(canvas);
to
camera.detachControl(canvas);

and now, so far, seems that problem doesnt happen!

now explain me why this change helps :slight_smile:

@MarkBevels @mawa @PirateJC
so yes, I have been unable to find the problem again since I made that change:
camera.attachControl(canvas);
instead of camera.inputs.attached[‘pointers’].attachControl(canvas);
and
camera.detachControl(canvas)
instead of camera.inputs.attached[‘pointers’].detachControl(canvas);

my theory is that I am also in my app doing:
canvas.addEventListener(“pointermove”, onPointerMove, false);
canvas.addEventListener(“pointerdown”, onPointerDown, false);
canvas.addEventListener(“pointerup”, onPointerUp, false);
and
canvas.removeEventListener(“pointermove”, onPointerMove);
canvas.removeEventListener(“pointerdown”, onPointerDown);
canvas.removeEventListener(“pointerup”, onPointerUp);

and maybe there was a collision between both things regarding ‘pointers’
its still odd because I assume that the generic simpler “camera.attachControl(canvas);” also must include the pointers and all, but in any case, it seems to solve the problem

if you have an explanation for why this seems to be a solution let me know, I would be curious :slight_smile:

I’m not sure to follow here. Did it work (differently) or not?
I believe there is an explanation for it to work differently. There’s a default handling for pointers. I believe the default is also a safer option if there is not a necessity to change it.

@mawa
What i mean is that the problem has dissappeared and it does not happen again after switching those statements to the simpler ones:
camera.detachControl(canvas)
camera.attachControl(canvas)

using those simpler ones, the problem dissapears :slight_smile: (at least so far I have not seen it again)

I’m happy to hear that :smiley: I got this as your last post :thinking:

So I thought may be you realized only later that it was not working (or incomplete) - I do this sometimes. I quickly check, I think it’s all good and later on I realize it is not;)
In fact, I’m having one of these with SSAO and multicam just right now:(
I will also shortly post about it.

Edit: I believe I also self-translated ‘unable to find the problem’ to ‘unable to find the solution’. Isn’t it so that on these kind of topics where you think you loose your head, when you finally find the solution and then, the solution is so simple, you nearly cannot believe it really is solved :grin:

@mawa yes you are right mawa :wink: I was expecting that it would be massively complicated to solve the issue, so I couldn’t believe that just switching those statements apparently made it go away

on the other hand, as a software engineer myself I have seen sooooooo many weird bugs and murphy law madness over the years that nothing surprises me so much anymore in that sense, everything is possible when we deal with a mixture of libraries, frameworks, environments etc, wild west :wink:

1 Like

Ya know, this is why I simply luv the philosophy, method and skills of the ENGs here in BJS. This framework is solid and well thought. :smiley:

@mawa absolutely I have to tell you, I have used a lot of frameworks over the years but I really love babylon.js, first of all the community and forum is the best I have ever seen, the documentation is fantastic, the playground, sandbox etc all these tools are fabulous, and the framework itself of course is really great; when I had to take my choice I did research and read a lot of good things about babylon.js vs three.js and other options and I am so happy that I chose babylon.js finally! :wink:

2 Likes

I’m glad you agree with me on that. I have also seen many frameworks in my career, though I mostly hand over the true dev parts to the true ENGs, like you. It could have been you :smiley:
… but then, I don’t think we need to choose between BJS or three.js. (or oppose them). We have only two for webGL*+. I think there should be enough space for both. But then yes, personally, BJS is clearly my favorite - for all of the reasons you mentioned above.

1 Like

@mawa you are totally right that we don’t need to oppose them etc, however at the end of the day one has to pick one of them to start coding so unfortunately in life choices are inevitable I guess :wink: but yes I agree that there is space for not only both of them but more as well, as you say there are very few choices at the moment and competition as we know is very good and makes the whole area grow in any field yeah

1 Like