How to use the webvr-polyfill/src/math-util.Vector3 function in webvr-polyfill

To help you get started, we’ve selected a few webvr-polyfill examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github naver / egjs-view360 / src / YawPitchControl / input / FusionPoseSensor.js View on Github external
this.filterToWorldQ = new MathUtil.Quaternion();

		this.isFirefoxAndroid = Util.isFirefoxAndroid();
		this.isIOS = Util.isIOS();

		// Ref https://github.com/immersive-web/cardboard-vr-display/issues/18
		this.isChromeUsingDegrees = agentInfo.browser.name === "chrome" &&
			parseInt(agentInfo.browser.version, 10) >= 66;

		this._isEnabled = false;

		// Set the filter to world transform, depending on OS.
		if (this.isIOS) {
			this.filterToWorldQ.setFromAxisAngle(new MathUtil.Vector3(1, 0, 0), Math.PI / 2);
		} else {
			this.filterToWorldQ.setFromAxisAngle(new MathUtil.Vector3(1, 0, 0), -Math.PI / 2);
		}

		this.inverseWorldToScreenQ = new MathUtil.Quaternion();
		this.worldToScreenQ = new MathUtil.Quaternion();
		this.originalPoseAdjustQ = new MathUtil.Quaternion();
		this.originalPoseAdjustQ.setFromAxisAngle(new MathUtil.Vector3(0, 0, 1),
			-window.orientation * Math.PI / 180);

		this._setScreenTransform();
		// Adjust this filter for being in landscape mode.
		if (Util.isLandscapeMode()) {
			this.filterToWorldQ.multiply(this.inverseWorldToScreenQ);
		}

		// Keep track of a reset transform for resetSensor.
		this.resetQ = new MathUtil.Quaternion();
github naver / egjs-view360 / src / YawPitchControl / input / FusionPoseSensor.js View on Github external
constructor() {
		super();

		this.deviceMotion = new DeviceMotion();

		this.accelerometer = new MathUtil.Vector3();
		this.gyroscope = new MathUtil.Vector3();

		this._onDeviceMotionChange = this._onDeviceMotionChange.bind(this);
		this._onScreenOrientationChange = this._onScreenOrientationChange.bind(this);

		this.filter = new ComplementaryFilter(K_FILTER);
		this.posePredictor = new PosePredictor(PREDICTION_TIME_S);

		this.filterToWorldQ = new MathUtil.Quaternion();

		this.isFirefoxAndroid = Util.isFirefoxAndroid();
		this.isIOS = Util.isIOS();

		// Ref https://github.com/immersive-web/cardboard-vr-display/issues/18
		this.isChromeUsingDegrees = agentInfo.browser.name === "chrome" &&
			parseInt(agentInfo.browser.version, 10) >= 66;
github naver / egjs-view360 / src / YawPitchControl / input / FusionPoseSensor.js View on Github external
this.isChromeUsingDegrees = agentInfo.browser.name === "chrome" &&
			parseInt(agentInfo.browser.version, 10) >= 66;

		this._isEnabled = false;

		// Set the filter to world transform, depending on OS.
		if (this.isIOS) {
			this.filterToWorldQ.setFromAxisAngle(new MathUtil.Vector3(1, 0, 0), Math.PI / 2);
		} else {
			this.filterToWorldQ.setFromAxisAngle(new MathUtil.Vector3(1, 0, 0), -Math.PI / 2);
		}

		this.inverseWorldToScreenQ = new MathUtil.Quaternion();
		this.worldToScreenQ = new MathUtil.Quaternion();
		this.originalPoseAdjustQ = new MathUtil.Quaternion();
		this.originalPoseAdjustQ.setFromAxisAngle(new MathUtil.Vector3(0, 0, 1),
			-window.orientation * Math.PI / 180);

		this._setScreenTransform();
		// Adjust this filter for being in landscape mode.
		if (Util.isLandscapeMode()) {
			this.filterToWorldQ.multiply(this.inverseWorldToScreenQ);
		}

		// Keep track of a reset transform for resetSensor.
		this.resetQ = new MathUtil.Quaternion();

		this.deviceMotion.on("devicemotion", this._onDeviceMotionChange);
		this.enable();
	}
	enable() {
github naver / egjs-view360 / src / YawPitchControl / input / FusionPoseSensor.js View on Github external
constructor() {
		super();

		this.deviceMotion = new DeviceMotion();

		this.accelerometer = new MathUtil.Vector3();
		this.gyroscope = new MathUtil.Vector3();

		this._onDeviceMotionChange = this._onDeviceMotionChange.bind(this);
		this._onScreenOrientationChange = this._onScreenOrientationChange.bind(this);

		this.filter = new ComplementaryFilter(K_FILTER);
		this.posePredictor = new PosePredictor(PREDICTION_TIME_S);

		this.filterToWorldQ = new MathUtil.Quaternion();

		this.isFirefoxAndroid = Util.isFirefoxAndroid();
		this.isIOS = Util.isIOS();

		// Ref https://github.com/immersive-web/cardboard-vr-display/issues/18
		this.isChromeUsingDegrees = agentInfo.browser.name === "chrome" &&
			parseInt(agentInfo.browser.version, 10) >= 66;
github naver / egjs-view360 / src / YawPitchControl / input / FusionPoseSensor.js View on Github external
_setScreenTransform() {
		this.worldToScreenQ.set(0, 0, 0, 1);
		switch (window.orientation) {
			case 0:
				break;
			case 90:
				this.worldToScreenQ.setFromAxisAngle(new MathUtil.Vector3(0, 0, 1), 90 / -180 * Math.PI);
				break;
			case -90:
				this.worldToScreenQ.setFromAxisAngle(new MathUtil.Vector3(0, 0, 1), -90 / -180 * Math.PI);
				break;
			case 180:
				this.worldToScreenQ.setFromAxisAngle(new MathUtil.Vector3(0, 0, 1), 180 / -180 * Math.PI);
				break;
			default:
				break;
		}
		this.inverseWorldToScreenQ.copy(this.worldToScreenQ);
		this.inverseWorldToScreenQ.inverse();
	}
}
github naver / egjs-view360 / src / YawPitchControl / input / FusionPoseSensor.js View on Github external
this.deviceOrientationFixQ = this.deviceOrientationFixQ || (function() {
				const y =
					new MathUtil.Quaternion().setFromAxisAngle(
						new MathUtil.Vector3(0, 1, 0), -this._alpha);

				return y;
			}).bind(this)();