Parcourir la source

Examples: Fixed webxr_xr_dragging and webxr_xr_paint in mobile-ar.

Mr.doob il y a 2 ans
Parent
commit
f3b52a9b22
2 fichiers modifiés avec 16 ajouts et 5 suppressions
  1. 8 1
      examples/webxr_xr_dragging.html
  2. 8 4
      examples/webxr_xr_paint.html

+ 8 - 1
examples/webxr_xr_dragging.html

@@ -201,6 +201,8 @@
 
 				}
 
+				controller.userData.targetRayMode = event.data.targetRayMode;
+
 			}
 
 			function onSelectEnd( event ) {
@@ -217,11 +219,12 @@
 
 				}
 
-
 			}
 
 			function getIntersections( controller ) {
 
+				controller.updateMatrixWorld();
+
 				tempMatrix.identity().extractRotation( controller.matrixWorld );
 
 				raycaster.ray.origin.setFromMatrixPosition( controller.matrixWorld );
@@ -233,6 +236,10 @@
 
 			function intersectObjects( controller ) {
 
+				// Do not highlight in mobile-ar
+
+				if ( controller.userData.targetRayMode === 'screen' ) return;
+
 				// Do not highlight when already selected
 
 				if ( controller.userData.selected !== undefined ) return;

+ 8 - 4
examples/webxr_xr_paint.html

@@ -88,6 +88,14 @@
 
 				function onSelectStart() {
 
+					this.updateMatrixWorld( true );
+
+					const pivot = this.getObjectByName( 'pivot' );
+					cursor.setFromMatrixPosition( pivot.matrixWorld );
+
+					const painter = this.userData.painter;
+					painter.moveTo( cursor );
+
 					this.userData.isSelecting = true;
 
 				}
@@ -181,10 +189,6 @@
 					painter.lineTo( cursor );
 					painter.update();
 
-				} else {
-
-					painter.moveTo( cursor );
-
 				}
 
 			}