chadautry Posted November 22, 2015 Share Posted November 22, 2015 I don't believe ArcRotateCamera correctly uses the upVector. Instead of getting into my use case, I've setup some playground demonstrations. Playground 1: This is the default. upVector is Y+. Behavior: Move the mouse left, spins clockwise around the Y axis. Move the mouse right, spins counter clockwise. Move the mouse up, pushes the Y+ axis away from the screen, move the mouse down, pulls the Y+ axis towards the screen.http://www.babylonjs-playground.com/#2K6AJC#2 This default works as expected. Playground 2: Set the upVector to Z+Expected Behavior: Move the mouse left and right should spin around the Z axis. Move the mouse up and down should pull the Z axis towards and away from the screen. Unfortunately, that is not the actual behavior.http://www.babylonjs-playground.com/#2K6AJC#3 Thanks Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted November 23, 2015 Share Posted November 23, 2015 upVector is used by arcRotateCamera (you can also allow upSide down with cam.allowUpsideDown = true) But I think that your problem is that controls are not changed based on upVector Quote Link to comment Share on other sites More sharing options...
chadautry Posted November 23, 2015 Author Share Posted November 23, 2015 That could be it. I'm trying browse the code to figure out where to change it to use upVector for the controls. But always hard looking at unfamiliar code. I'd definitely say it is an issue not using upVector in the controls as well as the drawing orientation. Kinda makes upVector pointless for the camera. Is there a suggested work around I'm not aware of?I'm trying to re-write an existing system to use Babylon.js, so changing the scene's co-ordinate system to work with the camera is quite a bit of re-work I don't want to do. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted November 23, 2015 Share Posted November 23, 2015 Nope unless adding support for the missing part what do you want to achieve? what is your ultimate goal? Quote Link to comment Share on other sites More sharing options...
chadautry Posted November 24, 2015 Author Share Posted November 24, 2015 Re-writting http://chad-autry.github.io/hex-grid-map/#/demo to use Babylon.js For that framework I have the cartesian co-ordinate system aligned with the screen co-ordinates, so that means the hex grid is flat on the Z=0 Basically the two world co-ordinate systems aren't the same. I'd like to get the nice behavior without re-writting my frameworks co-ordinate system. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted November 24, 2015 Share Posted November 24, 2015 ok got it. but the only thing you will have to do is: invert Y and Z Quote Link to comment Share on other sites More sharing options...
chadautry Posted November 24, 2015 Author Share Posted November 24, 2015 Hmm, not sure I'm seeing any "only" to do. It'd be a tedious deal to change in my code. The main difference is what the two frameworks consider up, and the only place I've hit a problem is with the ArcFollowCamera controls. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted November 24, 2015 Share Posted November 24, 2015 Perhaps you should check how arcrotatecamera is handling controls:https://github.com/BabylonJS/Babylon.js/blob/master/src/Cameras/babylon.arcRotateCamera.ts#L391 I did not check yet but integrating upVector should not be too complex Quote Link to comment Share on other sites More sharing options...
chadautry Posted November 24, 2015 Author Share Posted November 24, 2015 Yeah, I played around with it some. The controls are just changing the alpha and beta angles, I think the point of change is actually https://github.com/BabylonJS/Babylon.js/blob/master/src/Cameras/babylon.arcRotateCamera.ts#L521 Tried hacking it up a bit without total understanding and only managed to break it. I need to dig in and comprehend the trig there, I just swapped x --> y --> z --> x is obviously not what needs to happen. Quote Link to comment Share on other sites More sharing options...
chadautry Posted November 28, 2015 Author Share Posted November 28, 2015 Ok, by swapping Y and Z at lines https://github.com/BabylonJS/Babylon.js/blob/master/src/Cameras/babylon.arcRotateCamera.ts#L497https://github.com/BabylonJS/Babylon.js/blob/master/src/Cameras/babylon.arcRotateCamera.ts#L499https://github.com/BabylonJS/Babylon.js/blob/master/src/Cameras/babylon.arcRotateCamera.ts#L504https://github.com/BabylonJS/Babylon.js/blob/master/src/Cameras/babylon.arcRotateCamera.ts#L521 I'm getting the behavior I'm wanting. I'll try to get an official pull request going where it uses the upVector to set everything. (It may take quite some time, getting an equivalent re-write of my framework with rotation disabled takes priority for me) Of further interest: I notice that as I spin the scene with the mouse I get a very pronounced movement of my view point compared to the plane. At first I thought it was all about rounding errors (the target vector is being edited on every rotation increment) But interestingly it only happens with the mouse and not the keyboard. I'll have to investigate further. Quote Link to comment Share on other sites More sharing options...
chadautry Posted November 28, 2015 Author Share Posted November 28, 2015 Of course I now notice the lines mentioned above don't change the camera panning with the ctrl key. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted November 28, 2015 Share Posted November 28, 2015 Sounds good! Quote Link to comment Share on other sites More sharing options...
chadautry Posted November 30, 2015 Author Share Posted November 30, 2015 (edited) Wrote in the wrong thread. Edited December 1, 2015 by chadautry Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted November 30, 2015 Share Posted November 30, 2015 SOunds really promising man! Quote Link to comment Share on other sites More sharing options...
crn Posted May 3, 2018 Share Posted May 3, 2018 Has anything happened about this problem? I am currently facing pretty much the same problem and while I could (and will) try the patch by chadautry, it would be really nice to have a real fix for that issue. Quote Link to comment Share on other sites More sharing options...
Guest Posted May 3, 2018 Share Posted May 3, 2018 Not done yet (looking for volunteers :)) Quote Link to comment Share on other sites More sharing options...
crn Posted May 11, 2018 Share Posted May 11, 2018 I have tried to swap the controllers for keys, (please see: http://www.babylonjs-playground.com/#A83GX#30) but only succeeded partially. While rotating around the z axis (i.e. the new up vector) worked fine, rotation around the other axes lead to some strange effects. In the playground, this can be seen best by rotation around y by pressing the up/down keys. Rotation works fine until you cross the point where the up vector coincides with the view vector, after which the orientation of the y axis changes direction. While this is somewhat understandable mathematically, this seems to be handled consistently with the default up vector (0, 1, 0), where I can rotate in all directions without any such "discontinuities". I was looking for any special handling for this in the Babylon sources, but was not able to find anything. Any ideas, hints to where to look? 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.