Procházet zdrojové kódy

Removed DeviceOrientationControls. (#22654)

Michael Herzog před 3 roky
rodič
revize
1642cdf719

+ 0 - 95
docs/examples/en/controls/DeviceOrientationControls.html

@@ -1,95 +0,0 @@
-<!DOCTYPE html>
-<html lang="en">
-	<head>
-		<meta charset="utf-8" />
-		<base href="../../../" />
-		<script src="page.js"></script>
-		<link type="text/css" rel="stylesheet" href="page.css" />
-	</head>
-	<body>
-
-		<h1>[name]</h1>
-
-		<p class="desc">
-			Can be used to orient the camera based on the mobile device's orientation.
-		</p>
-
-		<h2>Examples</h2>
-
-		<p>[example:misc_controls_deviceorientation misc / controls / deviceorientation ]</p>
-
-		<h2>Constructor</h2>
-
-		<h3>[name]( [param:Camera object] )</h3>
-		<p>
-			<p>
-				[page:Camera object]: The camera to be controlled.
-			</p>
-			<p>
-				Creates a new instance of [name].
-			</p>
-		</p>
-
-		<h2>Events</h2>
-
-		<h3>change</h3>
-		<p>
-			Fires when the camera has been transformed by the controls.
-		</p>
-
-		<h2>Properties</h2>
-
-		<h3>[property:Number alphaOffset]</h3>
-		<p>
-			The alpha offset in radians. Default is *0*.
-		</p>
-
-		<h3>[property:Object deviceOrientation]</h3>
-		<p>
-			The current *deviceorientation* event object.
-		</p>
-
-		<h3>[property:Boolean enabled]</h3>
-		<p>
-			Whether or not the controls are enabled.
-		</p>
-
-		<h3>[property:Camera object]</h3>
-		<p>
-			The camera to be controlled.
-		</p>
-
-		<h3>[property:Number screenOrientation]</h3>
-		<p>
-			The orientation in degrees (in 90-degree increments) of the viewport relative to the device's natural orientation. Default is *0*.
-		</p>
-
-		<h2>Methods</h2>
-
-		<h3>[method:null connect] ()</h3>
-		<p>
-			Adds the event listeners of the controls and enables it.
-		</p>
-
-		<h3>[method:null disconnect] ()</h3>
-		<p>
-			Removes the event listeners of the controls and disables it.
-		</p>
-
-		<h3>[method:null dispose] ()</h3>
-		<p>
-			Should be called if the controls is no longer required.
-		</p>
-
-		<h3>[method:null update] ()</h3>
-		<p>
-			Updates the controls. Usually called in the animation loop.
-		</p>
-
-		<h2>Source</h2>
-
-		<p>
-			[link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/controls/DeviceOrientationControls.js examples/jsm/controls/DeviceOrientationControls.js]
-		</p>
-	</body>
-</html>

+ 0 - 95
docs/examples/ko/controls/DeviceOrientationControls.html

@@ -1,95 +0,0 @@
-<!DOCTYPE html>
-<html lang="ko">
-	<head>
-		<meta charset="utf-8" />
-		<base href="../../../" />
-		<script src="page.js"></script>
-		<link type="text/css" rel="stylesheet" href="page.css" />
-	</head>
-	<body>
-
-		<h1>[name]</h1>
-
-		<p class="desc">
-			모바일 장치의 방향에 따라 카메라 방향을 조정하는 데 사용 됩니다.
-		</p>
-
-		<h2>예시</h2>
-
-		<p>[example:misc_controls_deviceorientation misc / controls / deviceorientation ]</p>
-
-		<h2>생성자</h2>
-
-		<h3>[name]( [param:Camera object] )</h3>
-		<p>
-			<p>
-				[page:Camera object]: 제어 할 카메라 객체 입니다.
-			</p>
-			<p>
-				 새로운 [name] 객체를 생성합니다.
-			</p>
-		</p>
-
-		<h2>이벤트</h2>
-
-		<h3>change</h3>
-		<p>
-			컨트롤에 의해 카메라가 변환되면 실행합니다.
-		</p>
-
-		<h2>속성</h2>
-
-		<h3>[property:Number alphaOffset]</h3>
-		<p>
-			알파 값의 오프셋의 단위는 라디안 입니다. 초기값은 0으로 지정됩니다.
-		</p>
-
-		<h3>[property:Object deviceOrientation]</h3>
-		<p>
-			현재 deviceorientation 이벤트 객체입니다.
-		</p>
-
-		<h3>[property:Boolean enabled]</h3>
-		<p>
-			컨트롤의 활성화 여부를 지정합니다.
-		</p>
-
-		<h3>[property:Camera object]</h3>
-		<p>
-			제어 할 카메라입니다.
-		</p>
-
-		<h3>[property:Number screenOrientation]</h3>
-		<p>
-			장치의 실제 방향을 기준으로 뷰포트의 방향을 지정합니다(90도 단위 기준). 초기값은 *0* 입니다.
-		</p>
-
-		<h2>메소드</h2>
-
-		<h3>[method:null connect] ()</h3>
-		<p>
-			컨트롤의 이벤트 리스너에 추가한 다음 활성화 합니다.
-		</p>
-
-		<h3>[method:null disconnect] ()</h3>
-		<p>
-			컨트롤의 이벤트 리스너에 제거한 다음 비활성화 합니다.
-		</p>
-
-		<h3>[method:null dispose] ()</h3>
-		<p>
-			컨트롤을 더이상 필요하지 않을 경우 호출해야 합니다.
-		</p>
-
-		<h3>[method:null update] ()</h3>
-		<p>
-			컨트롤을 업데이트 합니다. 보통 애니메이션 루프에서 호출 됩니다.
-		</p>
-
-		<h2>Source</h2>
-
-		<p>
-			[link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/controls/DeviceOrientationControls.js examples/jsm/controls/DeviceOrientationControls.js]
-		</p>
-	</body>
-</html>

+ 0 - 95
docs/examples/zh/controls/DeviceOrientationControls.html

@@ -1,95 +0,0 @@
-<!DOCTYPE html>
-<html lang="zh">
-	<head>
-		<meta charset="utf-8" />
-		<base href="../../../" />
-		<script src="page.js"></script>
-		<link type="text/css" rel="stylesheet" href="page.css" />
-	</head>
-	<body>
-
-		<h1>设备朝向控制器([name])</h1>
-
-		<p class="desc">
-			通过使用设备朝向来确定摄像机的朝向。
-		</p>
-
-		<h2>例子</h2>
-
-		<p>[example:misc_controls_deviceorientation misc / controls / deviceorientation ]</p>
-
-		<h2>构造函数</h2>
-
-		<h3>[name]( [param:Camera object] )</h3>
-		<p>
-			<p>
-				[page:Camera object]: 被控制的摄像机。
-			</p>
-			<p>
-				创建一个新的 [name] 实例。
-			</p>
-		</p>
-
-		<h2>Events</h2>
-
-		<h3>change</h3>
-		<p>
-			Fires when the camera has been transformed by the controls.
-		</p>
-
-		<h2>属性</h2>
-
-		<h3>[property:Number alphaOffset]</h3>
-		<p>
-			alpha角偏移量,以弧度表示,默认为*0*。
-		</p>
-
-		<h3>[property:Object deviceOrientation]</h3>
-		<p>
-			当前 *deviceorientation* 事件的对象。
-		</p>
-
-		<h3>[property:Boolean enabled]</h3>
-		<p>
-			是否启用控制器。
-		</p>
-
-		<h3>[property:Camera object]</h3>
-		<p>
-			被控制的摄像机。
-		</p>
-
-		<h3>[property:Number screenOrientation]</h3>
-		<p>
-			相对于设备自然朝向的视口朝向,以角度表示(增量为90)。默认为*0*。
-		</p>
-
-		<h2>方法</h2>
-
-		<h3>[method:null connect] ()</h3>
-		<p>
-			增加控制器的事件监听,并启用控制器。
-		</p>
-
-		<h3>[method:null disconnect] ()</h3>
-		<p>
-			移除控制器的事件监听,并禁用控制器。
-		</p>
-
-		<h3>[method:null dispose] ()</h3>
-		<p>
-			若不再需要该控制器,则应当调用此函数。
-		</p>
-
-		<h3>[method:null update] ()</h3>
-		<p>
-			更新控制器,常被用在动画循环中。
-		</p>
-
-		<h2>源代码</h2>
-
-		<p>
-			[link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/controls/DeviceOrientationControls.js examples/jsm/controls/DeviceOrientationControls.js]
-		</p>
-	</body>
-</html>

+ 0 - 3
docs/list.json

@@ -331,7 +331,6 @@
 
 			"Controls": {
 				"ArcballControls": "examples/en/controls/ArcballControls",
-				"DeviceOrientationControls": "examples/en/controls/DeviceOrientationControls",
 				"DragControls": "examples/en/controls/DragControls",
 				"FirstPersonControls": "examples/en/controls/FirstPersonControls",
 				"FlyControls": "examples/en/controls/FlyControls",
@@ -835,7 +834,6 @@
 			},
 
 			"控制": {
-				"DeviceOrientationControls": "examples/zh/controls/DeviceOrientationControls",
 				"DragControls": "examples/zh/controls/DragControls",
 				"FirstPersonControls": "examples/zh/controls/FirstPersonControls",
 				"FlyControls": "examples/zh/controls/FlyControls",
@@ -1021,7 +1019,6 @@
 		"예제": {
 
 			"컨트롤": {
-				"DeviceOrientationControls": "examples/ko/controls/DeviceOrientationControls",
 				"DragControls": "examples/ko/controls/DragControls",
 				"FirstPersonControls": "examples/ko/controls/FirstPersonControls",
 				"FlyControls": "examples/ko/controls/FlyControls",

+ 0 - 1
examples/files.json

@@ -372,7 +372,6 @@
 		"misc_animation_keys",
 		"misc_boxselection",
 		"misc_controls_arcball",
-		"misc_controls_deviceorientation",
 		"misc_controls_drag",
 		"misc_controls_fly",
 		"misc_controls_map",

+ 0 - 147
examples/js/controls/DeviceOrientationControls.js

@@ -1,147 +0,0 @@
-( function () {
-
-	const _zee = new THREE.Vector3( 0, 0, 1 );
-
-	const _euler = new THREE.Euler();
-
-	const _q0 = new THREE.Quaternion();
-
-	const _q1 = new THREE.Quaternion( - Math.sqrt( 0.5 ), 0, 0, Math.sqrt( 0.5 ) ); // - PI/2 around the x-axis
-
-
-	const _changeEvent = {
-		type: 'change'
-	};
-
-	class DeviceOrientationControls extends THREE.EventDispatcher {
-
-		constructor( object ) {
-
-			super();
-
-			if ( window.isSecureContext === false ) {
-
-				console.error( 'THREE.DeviceOrientationControls: DeviceOrientationEvent is only available in secure contexts (https)' );
-
-			}
-
-			const scope = this;
-			const EPS = 0.000001;
-			const lastQuaternion = new THREE.Quaternion();
-			this.object = object;
-			this.object.rotation.reorder( 'YXZ' );
-			this.enabled = true;
-			this.deviceOrientation = {};
-			this.screenOrientation = 0;
-			this.alphaOffset = 0; // radians
-
-			const onDeviceOrientationChangeEvent = function ( event ) {
-
-				scope.deviceOrientation = event;
-
-			};
-
-			const onScreenOrientationChangeEvent = function () {
-
-				scope.screenOrientation = window.orientation || 0;
-
-			}; // The angles alpha, beta and gamma form a set of intrinsic Tait-Bryan angles of type Z-X'-Y''
-
-
-			const setObjectQuaternion = function ( quaternion, alpha, beta, gamma, orient ) {
-
-				_euler.set( beta, alpha, - gamma, 'YXZ' ); // 'ZXY' for the device, but 'YXZ' for us
-
-
-				quaternion.setFromEuler( _euler ); // orient the device
-
-				quaternion.multiply( _q1 ); // camera looks out the back of the device, not the top
-
-				quaternion.multiply( _q0.setFromAxisAngle( _zee, - orient ) ); // adjust for screen orientation
-
-			};
-
-			this.connect = function () {
-
-				onScreenOrientationChangeEvent(); // run once on load
-				// iOS 13+
-
-				if ( window.DeviceOrientationEvent !== undefined && typeof window.DeviceOrientationEvent.requestPermission === 'function' ) {
-
-					window.DeviceOrientationEvent.requestPermission().then( function ( response ) {
-
-						if ( response == 'granted' ) {
-
-							window.addEventListener( 'orientationchange', onScreenOrientationChangeEvent );
-							window.addEventListener( 'deviceorientation', onDeviceOrientationChangeEvent );
-
-						}
-
-					} ).catch( function ( error ) {
-
-						console.error( 'THREE.DeviceOrientationControls: Unable to use DeviceOrientation API:', error );
-
-					} );
-
-				} else {
-
-					window.addEventListener( 'orientationchange', onScreenOrientationChangeEvent );
-					window.addEventListener( 'deviceorientation', onDeviceOrientationChangeEvent );
-
-				}
-
-				scope.enabled = true;
-
-			};
-
-			this.disconnect = function () {
-
-				window.removeEventListener( 'orientationchange', onScreenOrientationChangeEvent );
-				window.removeEventListener( 'deviceorientation', onDeviceOrientationChangeEvent );
-				scope.enabled = false;
-
-			};
-
-			this.update = function () {
-
-				if ( scope.enabled === false ) return;
-				const device = scope.deviceOrientation;
-
-				if ( device ) {
-
-					const alpha = device.alpha ? THREE.MathUtils.degToRad( device.alpha ) + scope.alphaOffset : 0; // Z
-
-					const beta = device.beta ? THREE.MathUtils.degToRad( device.beta ) : 0; // X'
-
-					const gamma = device.gamma ? THREE.MathUtils.degToRad( device.gamma ) : 0; // Y''
-
-					const orient = scope.screenOrientation ? THREE.MathUtils.degToRad( scope.screenOrientation ) : 0; // O
-
-					setObjectQuaternion( scope.object.quaternion, alpha, beta, gamma, orient );
-
-					if ( 8 * ( 1 - lastQuaternion.dot( scope.object.quaternion ) ) > EPS ) {
-
-						lastQuaternion.copy( scope.object.quaternion );
-						scope.dispatchEvent( _changeEvent );
-
-					}
-
-				}
-
-			};
-
-			this.dispose = function () {
-
-				scope.disconnect();
-
-			};
-
-			this.connect();
-
-		}
-
-	}
-
-	THREE.DeviceOrientationControls = DeviceOrientationControls;
-
-} )();

+ 0 - 153
examples/jsm/controls/DeviceOrientationControls.js

@@ -1,153 +0,0 @@
-import {
-	Euler,
-	EventDispatcher,
-	MathUtils,
-	Quaternion,
-	Vector3
-} from '../../../build/three.module.js';
-
-const _zee = new Vector3( 0, 0, 1 );
-const _euler = new Euler();
-const _q0 = new Quaternion();
-const _q1 = new Quaternion( - Math.sqrt( 0.5 ), 0, 0, Math.sqrt( 0.5 ) ); // - PI/2 around the x-axis
-
-const _changeEvent = { type: 'change' };
-
-class DeviceOrientationControls extends EventDispatcher {
-
-	constructor( object ) {
-
-		super();
-
-		if ( window.isSecureContext === false ) {
-
-			console.error( 'THREE.DeviceOrientationControls: DeviceOrientationEvent is only available in secure contexts (https)' );
-
-		}
-
-		const scope = this;
-
-		const EPS = 0.000001;
-		const lastQuaternion = new Quaternion();
-
-		this.object = object;
-		this.object.rotation.reorder( 'YXZ' );
-
-		this.enabled = true;
-
-		this.deviceOrientation = {};
-		this.screenOrientation = 0;
-
-		this.alphaOffset = 0; // radians
-
-		const onDeviceOrientationChangeEvent = function ( event ) {
-
-			scope.deviceOrientation = event;
-
-		};
-
-		const onScreenOrientationChangeEvent = function () {
-
-			scope.screenOrientation = window.orientation || 0;
-
-		};
-
-		// The angles alpha, beta and gamma form a set of intrinsic Tait-Bryan angles of type Z-X'-Y''
-
-		const setObjectQuaternion = function ( quaternion, alpha, beta, gamma, orient ) {
-
-			_euler.set( beta, alpha, - gamma, 'YXZ' ); // 'ZXY' for the device, but 'YXZ' for us
-
-			quaternion.setFromEuler( _euler ); // orient the device
-
-			quaternion.multiply( _q1 ); // camera looks out the back of the device, not the top
-
-			quaternion.multiply( _q0.setFromAxisAngle( _zee, - orient ) ); // adjust for screen orientation
-
-		};
-
-		this.connect = function () {
-
-			onScreenOrientationChangeEvent(); // run once on load
-
-			// iOS 13+
-
-			if ( window.DeviceOrientationEvent !== undefined && typeof window.DeviceOrientationEvent.requestPermission === 'function' ) {
-
-				window.DeviceOrientationEvent.requestPermission().then( function ( response ) {
-
-					if ( response == 'granted' ) {
-
-						window.addEventListener( 'orientationchange', onScreenOrientationChangeEvent );
-						window.addEventListener( 'deviceorientation', onDeviceOrientationChangeEvent );
-
-					}
-
-				} ).catch( function ( error ) {
-
-					console.error( 'THREE.DeviceOrientationControls: Unable to use DeviceOrientation API:', error );
-
-				} );
-
-			} else {
-
-				window.addEventListener( 'orientationchange', onScreenOrientationChangeEvent );
-				window.addEventListener( 'deviceorientation', onDeviceOrientationChangeEvent );
-
-			}
-
-			scope.enabled = true;
-
-		};
-
-		this.disconnect = function () {
-
-			window.removeEventListener( 'orientationchange', onScreenOrientationChangeEvent );
-			window.removeEventListener( 'deviceorientation', onDeviceOrientationChangeEvent );
-
-			scope.enabled = false;
-
-		};
-
-		this.update = function () {
-
-			if ( scope.enabled === false ) return;
-
-			const device = scope.deviceOrientation;
-
-			if ( device ) {
-
-				const alpha = device.alpha ? MathUtils.degToRad( device.alpha ) + scope.alphaOffset : 0; // Z
-
-				const beta = device.beta ? MathUtils.degToRad( device.beta ) : 0; // X'
-
-				const gamma = device.gamma ? MathUtils.degToRad( device.gamma ) : 0; // Y''
-
-				const orient = scope.screenOrientation ? MathUtils.degToRad( scope.screenOrientation ) : 0; // O
-
-				setObjectQuaternion( scope.object.quaternion, alpha, beta, gamma, orient );
-
-				if ( 8 * ( 1 - lastQuaternion.dot( scope.object.quaternion ) ) > EPS ) {
-
-					lastQuaternion.copy( scope.object.quaternion );
-					scope.dispatchEvent( _changeEvent );
-
-				}
-
-			}
-
-		};
-
-		this.dispose = function () {
-
-			scope.disconnect();
-
-		};
-
-		this.connect();
-
-	}
-
-}
-
-export { DeviceOrientationControls };

+ 0 - 95
examples/misc_controls_deviceorientation.html

@@ -1,95 +0,0 @@
-<!DOCTYPE html>
-<html lang="en">
-	<head>
-		<title>three.js webgl - controls - deviceorientation</title>
-		<meta charset="utf-8">
-		<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
-		<link type="text/css" rel="stylesheet" href="main.css">
-	</head>
-	<body>
-		<div id="overlay">
-			<button id="startButton">Start Demo</button>
-		</div>
-		<div id="info">
-			<a href="https://threejs.org" target="_blank" rel="noopener">three.js</a> - equirectangular panorama demo with DeviceOrientation controls.<br/>
-			photo by <a href="http://www.flickr.com/photos/jonragnarsson/2294472375/" target="_blank" rel="noopener">Jón Ragnarsson</a>.
-		</div>
-
-		<script type="module">
-
-			import * as THREE from '../build/three.module.js';
-
-			import { DeviceOrientationControls } from './jsm/controls/DeviceOrientationControls.js';
-
-			let camera, scene, renderer, controls;
-
-			const startButton = document.getElementById( 'startButton' );
-			startButton.addEventListener( 'click', function () {
-
-				init();
-				animate();
-
-			} );
-
-			function init() {
-
-				const overlay = document.getElementById( 'overlay' );
-				overlay.remove();
-
-				camera = new THREE.PerspectiveCamera( 75, window.innerWidth / window.innerHeight, 1, 1100 );
-
-				controls = new DeviceOrientationControls( camera );
-
-				scene = new THREE.Scene();
-
-				const geometry = new THREE.SphereGeometry( 500, 60, 40 );
-				// invert the geometry on the x-axis so that all of the faces point inward
-				geometry.scale( - 1, 1, 1 );
-
-				const material = new THREE.MeshBasicMaterial( {
-					map: new THREE.TextureLoader().load( 'textures/2294472375_24a3b8ef46_o.jpg' )
-				} );
-
-				const mesh = new THREE.Mesh( geometry, material );
-				scene.add( mesh );
-
-				const helperGeometry = new THREE.BoxGeometry( 100, 100, 100, 4, 4, 4 );
-				const helperMaterial = new THREE.MeshBasicMaterial( { color: 0xff00ff, wireframe: true } );
-				const helper = new THREE.Mesh( helperGeometry, helperMaterial );
-				scene.add( helper );
-
-				//
-
-				renderer = new THREE.WebGLRenderer( { antialias: true } );
-				renderer.setPixelRatio( window.devicePixelRatio );
-				renderer.setSize( window.innerWidth, window.innerHeight );
-				document.body.appendChild( renderer.domElement );
-
-				//
-
-				window.addEventListener( 'resize', onWindowResize );
-
-
-			}
-
-			function animate() {
-
-				window.requestAnimationFrame( animate );
-
-				controls.update();
-				renderer.render( scene, camera );
-
-			}
-
-			function onWindowResize() {
-
-				camera.aspect = window.innerWidth / window.innerHeight;
-				camera.updateProjectionMatrix();
-
-				renderer.setSize( window.innerWidth, window.innerHeight );
-
-			}
-
-		</script>
-	</body>
-</html>

binární
examples/screenshots/misc_controls_deviceorientation.jpg


+ 0 - 1
examples/tags.json

@@ -93,7 +93,6 @@
 	"webgl2_multisampled_renderbuffers": [ "msaa" ],
 	"physics_ammo_cloth": [ "integration" ],
 	"misc_controls_arcball": [ "rotation" ],
-	"misc_controls_deviceorientation": [ "accelerometer", "sensors" ],
 	"misc_controls_drag": [ "translate" ],
 	"misc_controls_map": [ "drag" ],
 	"misc_controls_orbit": [ "rotation" ],