Jump to content

Joystick Controls with ArcRotate Camera


hen
 Share

Recommended Posts

Im trying to add mobile support for our thirdperson camera wich is using the Arc Rotate cam.

Is it actually possible to control that camera using the joystick?
It seems like the cameras touch controls are disabled once the joystick is loaded.

Link to comment
Share on other sites

Hi Hen, good to see you again.  I'm not qualified to answer this, but this will serve to bump your topic upward a bit.

So, IN MY OPINION, the separation borders between device, user agent (browser), JS, and BabylonJS framework... become very important here.  I think that the issue of touchscreen being disabled after a joystick driver/redirector loads-in... happens on a DEVICE side of the border.  In other words, you will need to investigate why the device is doing that, and a fix/work-around might be rough water (difficult).  Your primary objective...  get your joystick (and/or touchscreen) to produce values in JS.  No need to attach a scene or a framework... just get your joystick/touchscreen event listeners activated in a simple JS demo.  Later, when all your event listeners are working per your liking... THEN hooking an arc rotate camera to those eventHandlers... might be easy.

There is a "library" called Gampad.js, but, according to its docs, it doesn't work with Internet Explorer, Opera, or Safari.  Crap, eh?

Let's take a browse to the W3C Gampad thing.  May I direct your attention to Section 3. - Scope area.  This area of the spec... speaks volumes (says a lot).  Mainly, it talks about NARROWING the scope... and why this spec is called "gamepad" and not "generalExternalController".  By the "feel" of that information in the Scope section, one might suspect that we will eventually see a W3C spec for "Joystick", eh?  http://h4ck3r.net/joystick/joystick.html

There it is, but we're not AT the W3C website anymore.  So let's hit that "latest public version" on the W3C site... http://www.w3.org/TR/joystick/

Oooh, flopped on its butt.  Ok, let's search the W3C site for "joystick".  https://www.google.com/search?q=site:w3.org+joystick

Got some returns, but the dates are OLD.  Quite discouraging, eh?  But BabylonJS DOES have gamepad features.  http://doc.babylonjs.com/search?q=gamepad 

So, once you solve your DEVICE-level joystick-disables-touchscreen issue, there appears to be some tools/code here to play-with.

When you get the issues solved on the other levels, then you SHOULD be able to operate one of our GamePad cameras with a joystick.  Get THAT far, if you please.  AFTER you have your joystick able to operate the GamepadCamera... that's when you/we will "borrow" some code from https://github.com/BabylonJS/Babylon.js/blob/master/src/Cameras/babylon.gamepadCamera.js and maybe extend ArcRotateCamera instead of FreeCamera.   In other words, you/we will modify gamepadCamera and make our own joystickArcCamera v1.0  :)

Gamepads and joysticks... it is all quite new to browsers, still.  The working draft date on the W3C Gamepad spec... is Dec 2015!  It's hot hot hot.  Gamepads and joysticks generally send the same values, so, joysticking an arcRotateCamera is likely possible.  It might be a hard-to-navigate trail to success, depending upon your expertise.  I believe Davrous wrote much of our GamePad camera stuff, so maybe he will visit and say wiser things than I can.  As I said before, I am not qualified to comment on this, but, I'm glad and honored to watch, listen, and learn.  :) 

Here's an interesting forum thread:  http://www.html5gamedevs.com/topic/9545-how-to-use-the-gamepad/

More comments welcome, of course.

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...