Skip to content

Commit

Permalink
update build
Browse files Browse the repository at this point in the history
  • Loading branch information
pchen66 committed May 7, 2020
1 parent 0762153 commit 5abb6c9
Show file tree
Hide file tree
Showing 3 changed files with 365 additions and 249 deletions.
95 changes: 76 additions & 19 deletions build/panolens.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
(global = global || self, factory(global.PANOLENS = {}, global.THREE));
}(this, (function (exports, THREE) { 'use strict';

const version="0.11.0";const devDependencies={"@rollup/plugin-commonjs":"^11.0.2","@rollup/plugin-inject":"^4.0.1","@rollup/plugin-json":"^4.0.2","@rollup/plugin-node-resolve":"^7.1.1","@tweenjs/tween.js":"^18.5.0",ava:"^3.5.0","browser-env":"^3.3.0",concurrently:"^5.1.0",coveralls:"^3.0.11",docdash:"^1.2.0",eslint:"^6.8.0",esm:"^3.2.25","google-closure-compiler":"^20200315.0.0","http-server":"^0.12.1",jsdoc:"^3.6.3","local-web-server":"^3.0.7",nyc:"^14.1.1",rollup:"^2.3.2",three:"^0.105.2",xmlhttprequest:"^1.8.0"};
const version="0.11.0";const devDependencies={"@rollup/plugin-commonjs":"^11.0.2","@rollup/plugin-inject":"^4.0.1","@rollup/plugin-json":"^4.0.2","@rollup/plugin-node-resolve":"^7.1.1","@tweenjs/tween.js":"^18.5.0",ava:"^3.5.0","babel-eslint":"^10.1.0","browser-env":"^3.3.0",concurrently:"^5.1.0",coveralls:"^3.0.11",docdash:"^1.2.0",eslint:"^6.8.0",esm:"^3.2.25","google-closure-compiler":"^20200315.0.0","http-server":"^0.12.3",jsdoc:"^3.6.3","local-web-server":"^3.0.7",nyc:"^14.1.1",rollup:"^2.3.2",three:"^0.105.2",xmlhttprequest:"^1.8.0"};

/**
* REVISION
Expand Down Expand Up @@ -7914,8 +7914,6 @@
this.object = object;
this.object.rotation.reorder( 'YXZ' );

this.thetaOffsetSum = 0;

this.enabled = true;

this.deviceOrientation = null;
Expand All @@ -7926,17 +7924,13 @@

const onDeviceOrientationChangeEvent = function ( { alpha, beta, gamma } ) {

if( isAndroid ) {

if( scope.initialOffset === null ) {
scope.initialOffset = alpha;
}

alpha = alpha - scope.initialOffset;
if( scope.initialOffset === null ) {
scope.initialOffset = alpha;
}

if(alpha < 0) alpha += 360;
alpha = alpha - scope.initialOffset;

}
if(alpha < 0) alpha += 360;

scope.deviceOrientation = { alpha, beta, gamma };

Expand Down Expand Up @@ -8020,10 +8014,12 @@
window.removeEventListener( 'deviceorientation', onDeviceOrientationChangeEvent, false );

scope.enabled = false;

scope.deviceOrientation = null;
scope.initialOffset = null;

};

this.update = function ({ theta } = {}) {
this.update = function ({ theta = 0 } = { theta: 0 }) {

if ( scope.enabled === false ) return;

Expand Down Expand Up @@ -8052,6 +8048,21 @@

};

this.getAlpha = function() {

const { deviceOrientation: device } = scope;

return device && device.alpha ? THREE.Math.degToRad( device.alpha ) + scope.alphaOffset : 0;

};

this.getBeta = function() {

const { deviceOrientation: device } = scope;

return device && device.beta ? THREE.Math.degToRad( device.beta ) : 0;

};

}
DeviceOrientationControls.prototype = Object.assign( Object.create( THREE.EventDispatcher.prototype), {
Expand Down Expand Up @@ -8343,10 +8354,14 @@
this.touchSupported = 'ontouchstart' in window || window.DocumentTouch && document instanceof DocumentTouch;
this.tweenLeftAnimation = new TWEEN.Tween();
this.tweenUpAnimation = new TWEEN.Tween();
this.tweenCanvasOpacityOut = new TWEEN.Tween();
this.tweenCanvasOpacityIn = new TWEEN.Tween();
this.outputEnabled = false;
this.viewIndicatorSize = indicatorSize;
this.tempEnableReticle = enableReticle;

this.setupTween();

this.handlerMouseUp = this.onMouseUp.bind( this );
this.handlerMouseDown = this.onMouseDown.bind( this );
this.handlerMouseMove = this.onMouseMove.bind( this );
Expand Down Expand Up @@ -8392,6 +8407,7 @@
renderer.autoClear = false;
renderer.domElement.classList.add( 'panolens-canvas' );
renderer.domElement.style.display = 'block';
renderer.domElement.style.transition = 'opacity 0.5s ease';
container.style.backgroundColor = '#000';
container.appendChild( renderer.domElement );

Expand Down Expand Up @@ -8472,6 +8488,15 @@

},

setupTween: function() {

this.tweenCanvasOpacityOut.to({}, 500).easing(TWEEN.Easing.Exponential.Out);
this.tweenCanvasOpacityIn.to({}, 500).easing(TWEEN.Easing.Exponential.Out);

this.tweenCanvasOpacityOut.chain(this.tweenCanvasOpacityIn);

},

/**
* Add an object to the scene
* Automatically hookup with panolens-viewer-handler listener
Expand Down Expand Up @@ -9243,25 +9268,57 @@
*/
enableControl: function ( index = CONTROLS.ORBIT ) {

const { control: { index: currentControlIndex }, DeviceOrientationControls } = this;
const { control: { index: currentControlIndex }, OrbitControls, DeviceOrientationControls, container } = this;
const canvas = container.querySelector('canvas');

if( index === currentControlIndex ) { // ignore

return;

} else if( index === CONTROLS.DEVICEORIENTATION ) { // device orientation

DeviceOrientationControls.connect();
this.tweenCanvasOpacityOut.onStart(() => {
OrbitControls.enabled = false;
DeviceOrientationControls.enabled = false;
canvas.style.opacity = 0;
});

this.tweenCanvasOpacityIn.onStart(() => {
OrbitControls.enabled = true;
DeviceOrientationControls.connect();
canvas.style.opacity = 1;
});

this.tweenCanvasOpacityOut.start();


} else {

DeviceOrientationControls.disconnect(); // orbit
const { getAlpha, getBeta } = DeviceOrientationControls;
const alpha = -getAlpha();
const beta = Math.PI / 2 - getBeta();
const center = this.getRaycastViewCenter();

this.tweenCanvasOpacityOut.onStart(() => {
OrbitControls.enabled = false;
DeviceOrientationControls.disconnect();
canvas.style.opacity = 0;
});

this.tweenCanvasOpacityIn.onStart(function() {
OrbitControls.enabled = true;
this.rotateControlLeft(alpha);
this.rotateControlUp(beta);
this.setControlCenter(center);
canvas.style.opacity = 1;
}.bind(this));

this.tweenCanvasOpacityOut.start();

}

this.control = this.controls[ index ];
this.activateWidgetItem( index, undefined );
this.onChange();

},

Expand Down Expand Up @@ -10022,7 +10079,7 @@
this.updateCallbacks.forEach( callback => callback() );

// Control Update
OrbitControls.update();
if ( OrbitControls.enabled ) OrbitControls.update();
if ( control === DeviceOrientationControls ) {
DeviceOrientationControls.update(OrbitControls.publicSphericalDelta.data);
}
Expand Down
Loading

0 comments on commit 5abb6c9

Please sign in to comment.