Jump to content

VR Helper


brianzinn
 Share

Recommended Posts

Just trying out the new VR helper on an older phone to see what it would look like using Cardboard: http://www.babylonjs-playground.com/#IHY77X#16

Uncaught TypeError: Cannot read property 'rotationQuaternion' of null
    at t.set [as camera] (babylon.js:38)
    at i.t.detachElement (babylon.js:19)
    at i.t.clear (babylon.js:19)
    at i.dispose (babylon.js:20)
    at t.enterVR (babylon.js:39)
    at HTMLButtonElement.<anonymous> (babylon.js:39)

I can look at it more later - that's the output from remote debugging console once I click on the glasses button.  Is there a way to run playground under babylon-max?  Otherwise I will need to update my current project with latest version, which would be good anyway!  Thanks.

Link to comment
Share on other sites

Thanks for the debug link.  I can reproduce quite easy.  Communicating my debug experience presents more of a challenge.

in the enterVR function my active Camera is a DeviceOrientationCamera and is working with phone movements.  There is a loop in CameraInputsManager.prototype.detachElement:

for (var cam in this.attached) {
                var input = this.attached[cam];
                this.attached[cam].detachControl(element);
                if (disconnect) {
                    this.attached[cam].camera = null;
                }
            }

The loop works with "keyboard" and "mouse".  The third item in the attached array is "deviceOrientation" and the input is a FreeCameraDeviceOrientationInput.

Object.defineProperty(FreeCameraDeviceOrientationInput.prototype, "camera", {
            get: function () {
                return this._camera;
            },
            set: function (camera) {
                this._camera = camera;
                if (!this._camera.rotationQuaternion)
                    this._camera.rotationQuaternion = new BABYLON.Quaternion();
            },
            enumerable: true,
            configurable: true
        });

 As you can see in the loop the camera is being set to NULL.  The set function will be passed NULL, so this._camera will be null and this._camera.rotationQuaternion throws an exception.

https://github.com/BabylonJS/Babylon.js/blob/deefbcdbae137661f3ba4472ed3f7c54940b0337/src/Cameras/Inputs/babylon.freeCameraDeviceOrientationInput.ts#L23

I think the other camera properties in the loop are member variables as I couldn't step into them.  I would say there should be a guard statement in the setter. ie:

public set camera(camera: FreeCamera) {
            this._camera = camera;
            if (this._camera != null && !this._camera.rotationQuaternion) this._camera.rotationQuaternion = new Quaternion();
        }

 

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...