Sfoglia il codice sorgente

Docs: Improve Raycaster page. (#23132)

Michael Herzog 3 anni fa
parent
commit
61a4d5c900

+ 8 - 8
docs/api/en/core/Raycaster.html

@@ -18,22 +18,22 @@
 		<h2>Code Example</h2>
 		<h2>Code Example</h2>
 		<code>
 		<code>
 		const raycaster = new THREE.Raycaster();
 		const raycaster = new THREE.Raycaster();
-		const mouse = new THREE.Vector2();
+		const pointer = new THREE.Vector2();
 
 
-		function onMouseMove( event ) {
+		function onPointerMove( event ) {
 
 
-			// calculate mouse position in normalized device coordinates
+			// calculate pointer position in normalized device coordinates
 			// (-1 to +1) for both components
 			// (-1 to +1) for both components
 
 
-			mouse.x = ( event.clientX / window.innerWidth ) * 2 - 1;
-			mouse.y = - ( event.clientY / window.innerHeight ) * 2 + 1;
+			pointer.x = ( event.clientX / window.innerWidth ) * 2 - 1;
+			pointer.y = - ( event.clientY / window.innerHeight ) * 2 + 1;
 
 
 		}
 		}
 
 
 		function render() {
 		function render() {
 
 
-			// update the picking ray with the camera and mouse position
-			raycaster.setFromCamera( mouse, camera );
+			// update the picking ray with the camera and pointer position
+			raycaster.setFromCamera( pointer, camera );
 
 
 			// calculate objects intersecting the picking ray
 			// calculate objects intersecting the picking ray
 			const intersects = raycaster.intersectObjects( scene.children );
 			const intersects = raycaster.intersectObjects( scene.children );
@@ -48,7 +48,7 @@
 
 
 		}
 		}
 
 
-		window.addEventListener( 'mousemove', onMouseMove, false );
+		window.addEventListener( 'pointermove', onPointerMove );
 
 
 		window.requestAnimationFrame(render);
 		window.requestAnimationFrame(render);
 
 

+ 8 - 8
docs/api/ko/core/Raycaster.html

@@ -17,22 +17,22 @@
 		<h2>코드 예제</h2>
 		<h2>코드 예제</h2>
 		<code>
 		<code>
 		const raycaster = new THREE.Raycaster();
 		const raycaster = new THREE.Raycaster();
-		const mouse = new THREE.Vector2();
+		const pointer = new THREE.Vector2();
 
 
-		function onMouseMove( event ) {
+		function onPointerMove( event ) {
 
 
-			// calculate mouse position in normalized device coordinates
+			// calculate pointer position in normalized device coordinates
 			// (-1 to +1) for both components
 			// (-1 to +1) for both components
 
 
-			mouse.x = ( event.clientX / window.innerWidth ) * 2 - 1;
-			mouse.y = - ( event.clientY / window.innerHeight ) * 2 + 1;
+			pointer.x = ( event.clientX / window.innerWidth ) * 2 - 1;
+			pointer.y = - ( event.clientY / window.innerHeight ) * 2 + 1;
 
 
 		}
 		}
 
 
 		function render() {
 		function render() {
 
 
-			// update the picking ray with the camera and mouse position
-			raycaster.setFromCamera( mouse, camera );
+			// update the picking ray with the camera and pointer position
+			raycaster.setFromCamera( pointer, camera );
 
 
 			// calculate objects intersecting the picking ray
 			// calculate objects intersecting the picking ray
 			const intersects = raycaster.intersectObjects( scene.children );
 			const intersects = raycaster.intersectObjects( scene.children );
@@ -47,7 +47,7 @@
 
 
 		}
 		}
 
 
-		window.addEventListener( 'mousemove', onMouseMove, false );
+		window.addEventListener( 'pointermove', onPointerMove );
 
 
 		window.requestAnimationFrame(render);
 		window.requestAnimationFrame(render);
 
 

+ 6 - 6
docs/api/zh/core/Raycaster.html

@@ -17,21 +17,21 @@
 		<h2>代码示例</h2>
 		<h2>代码示例</h2>
 		<code>
 		<code>
 		const raycaster = new THREE.Raycaster();
 		const raycaster = new THREE.Raycaster();
-		const mouse = new THREE.Vector2();
+		const pointer = new THREE.Vector2();
 
 
-		function onMouseMove( event ) {
+		function onPointerMove( event ) {
 
 
 			// 将鼠标位置归一化为设备坐标。x 和 y 方向的取值范围是 (-1 to +1)
 			// 将鼠标位置归一化为设备坐标。x 和 y 方向的取值范围是 (-1 to +1)
 
 
-			mouse.x = ( event.clientX / window.innerWidth ) * 2 - 1;
-			mouse.y = - ( event.clientY / window.innerHeight ) * 2 + 1;
+			pointer.x = ( event.clientX / window.innerWidth ) * 2 - 1;
+			pointer.y = - ( event.clientY / window.innerHeight ) * 2 + 1;
 
 
 		}
 		}
 
 
 		function render() {
 		function render() {
 
 
 			// 通过摄像机和鼠标位置更新射线
 			// 通过摄像机和鼠标位置更新射线
-			raycaster.setFromCamera( mouse, camera );
+			raycaster.setFromCamera( pointer, camera );
 
 
 			// 计算物体和射线的焦点
 			// 计算物体和射线的焦点
 			const intersects = raycaster.intersectObjects( scene.children );
 			const intersects = raycaster.intersectObjects( scene.children );
@@ -46,7 +46,7 @@
 
 
 		}
 		}
 
 
-		window.addEventListener( 'mousemove', onMouseMove, false );
+		window.addEventListener( 'pointermove', onPointerMove );
 
 
 		window.requestAnimationFrame(render);
 		window.requestAnimationFrame(render);