Skip to content

Commit

Permalink
KJSL: v2.1.2 Android can use native cardboaard support instead
Browse files Browse the repository at this point in the history
  • Loading branch information
Kevin Staunton-Lambert committed Aug 19, 2024
1 parent 0c90edc commit cea8a83
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -657,7 +657,7 @@ void main() {
}

this.animationFrameId_ = this.requestAnimationFrame(this.animate_);
if (this.orbitcontrols.update()) {
if (this.orbitcontrols && this.orbitcontrols.update()) {
this.renderer.render(this.scene, this.camera);
if (this.webVREffect) {
this.webVREffect.isPresenting = false;
Expand Down Expand Up @@ -708,11 +708,18 @@ void main() {
this.defaultProjection_ = projection;
}

isAndroidNativeCardboardSupport() {
return (/android/i.test(window.navigator.userAgent));
}

init() {
this.reset();

this.camera = new THREE.PerspectiveCamera(70, this.player_.currentWidth() / this.player_.currentHeight(), 1, 2000);
this.orbitcontrols = new DeviceOrientationControls(this.camera);

if (!this.isAndroidNativeCardboardSupport) {
this.orbitcontrols = new DeviceOrientationControls(this.camera);
}
this.camera.layers.enable(1);

// Store vector representing the direction in which the camera is looking, in world space.
Expand Down

0 comments on commit cea8a83

Please sign in to comment.