Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getTarget stopped working - now fixed #1847

Merged
merged 3 commits into from Mar 8, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 11 additions & 3 deletions src/Cameras/VR/babylon.webVRCamera.ts
Expand Up @@ -64,9 +64,6 @@ module BABYLON {
this.rotationQuaternion = new Quaternion();
this.deviceRotationQuaternion = new Quaternion();

//using the position provided as the current position offset
this._positionOffset = position;

if (this.webVROptions && this.webVROptions.positionScale) {
this.deviceScaleFactor = this.webVROptions.positionScale;
}
Expand Down Expand Up @@ -240,9 +237,20 @@ module BABYLON {
this._tempMatrix.multiplyToRef(this._webvrViewMatrix, this._webvrViewMatrix);
}

this._updateCameraRotationMatrix();
Vector3.TransformCoordinatesToRef(this._referencePoint, this._cameraRotationMatrix, this._transformedReferencePoint);

// Computing target for getTarget()
this._webvrViewMatrix.getTranslationToRef(this._positionOffset);
this._positionOffset.addToRef(this._transformedReferencePoint, this._currentTarget);

return this._webvrViewMatrix;
}

protected _updateCameraRotationMatrix() {
this._webvrViewMatrix.getRotationMatrixToRef(this._cameraRotationMatrix);
}

public _isSynchronizedViewMatrix() {
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Cameras/babylon.targetCamera.ts
Expand Up @@ -219,7 +219,7 @@ module BABYLON {
super._checkInputs();
}

private _updateCameraRotationMatrix() {
protected _updateCameraRotationMatrix() {
if (this.rotationQuaternion) {
this.rotationQuaternion.toRotationMatrix(this._cameraRotationMatrix);
//update the up vector!
Expand Down
2 changes: 1 addition & 1 deletion src/Tools/babylon.extendedGamepad.ts
Expand Up @@ -57,7 +57,7 @@ module BABYLON {
public update() {
super.update();
// update this device's offset position from the attached camera, if provided
if (this._poseControlledCamera) {
if (this._poseControlledCamera && this._poseControlledCamera.deviceScaleFactor) {
//this.position.copyFrom(this._poseControlledCamera.position);
//this.rotationQuaternion.copyFrom(this._poseControlledCamera.rotationQuaternion);
this.deviceScaleFactor = this._poseControlledCamera.deviceScaleFactor;
Expand Down