Explorar o código

Merge pull request #8024 from RaananW/handedness

[XR] fixing a typo with back-compat
David Catuhe %!s(int64=5) %!d(string=hai) anos
pai
achega
13aa0e3293

+ 1 - 0
dist/preview release/what's new.md

@@ -99,6 +99,7 @@
 - Added `Vector3.projectOnPlaneToRef` ([Deltakosh](https://github.com/deltakosh))
 
 ### Particles
+
 - Added local space support for GPU particles ([CraigFeldpsar](https://github.com/craigfeldspar))
 
 ### Build

+ 16 - 9
src/XR/motionController/webXRAbstractMotionController.ts

@@ -9,9 +9,9 @@ import { Quaternion, Vector3 } from '../../Maths/math.vector';
 import { Mesh } from '../../Meshes/mesh';
 
 /**
- * Handness type in xrInput profiles. These can be used to define layouts in the Layout Map.
+ * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  */
-export type MotionControllerHandness = "none" | "left" | "right";
+export type MotionControllerHandedness = "none" | "left" | "right";
 /**
  * The type of components available in motion controllers.
  * This is not the name of the component.
@@ -122,9 +122,9 @@ export interface IMotionControllerLayout {
  */
 export interface IMotionControllerLayoutMap {
     /**
-     * Layouts with handness type as a key
+     * Layouts with handedness type as a key
      */
-    [handness: string /* handness */]: IMotionControllerLayout;
+    [handedness: string /* handedness */]: IMotionControllerLayout;
 }
 
 /**
@@ -138,7 +138,7 @@ export interface IMotionControllerProfile {
      */
     fallbackProfileIds: string[];
     /**
-     * The layout map, with handness as key
+     * The layout map, with handedness as key
      */
     layouts: IMotionControllerLayoutMap;
     /**
@@ -268,7 +268,7 @@ export abstract class WebXRAbstractMotionController implements IDisposable {
      * @param scene the scene to which the model of the controller will be added
      * @param layout The profile layout to load
      * @param gamepadObject The gamepad object correlating to this controller
-     * @param handness handness (left/right/none) of this controller
+     * @param handedness handedness (left/right/none) of this controller
      * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
      */
     constructor(protected scene: Scene, protected layout: IMotionControllerLayout,
@@ -277,9 +277,9 @@ export abstract class WebXRAbstractMotionController implements IDisposable {
          */
         public gamepadObject: IMinimalMotionControllerObject,
         /**
-         * handness (left/right/none) of this controller
+         * handedness (left/right/none) of this controller
          */
-        public handness: MotionControllerHandness,
+        public handedness: MotionControllerHandedness,
         _doNotLoadControllerMesh: boolean = false) {
         // initialize the components
         if (layout.components) {
@@ -383,6 +383,13 @@ export abstract class WebXRAbstractMotionController implements IDisposable {
         this.updateModel(xrFrame);
     }
 
+    /**
+     * Backwards compatibility due to a deeply-integrated typo
+     */
+    public get handness() {
+        return this.handedness;
+    }
+
     // Look through all children recursively. This will return null if no mesh exists with the given name.
     protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh {
         return <AbstractMesh>node.getChildren((n) => n.name === name, false)[0];
@@ -470,7 +477,7 @@ export abstract class WebXRAbstractMotionController implements IDisposable {
     }
 
     private _getGenericParentMesh(meshes: AbstractMesh[]): void {
-        this.rootMesh = new Mesh(this.profileId + " " + this.handness, this.scene);
+        this.rootMesh = new Mesh(this.profileId + " " + this.handedness, this.scene);
 
         meshes.forEach((mesh) => {
             if (!mesh.parent) {

+ 4 - 4
src/XR/motionController/webXRGenericMotionController.ts

@@ -1,7 +1,7 @@
 import {
     WebXRAbstractMotionController,
     IMinimalMotionControllerObject,
-    MotionControllerHandness,
+    MotionControllerHandedness,
     IMotionControllerLayoutMap
 } from "./webXRAbstractMotionController";
 import { AbstractMesh } from '../../Meshes/abstractMesh';
@@ -20,8 +20,8 @@ export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionCont
 
     public profileId = WebXRGenericTriggerMotionController.ProfileId;
 
-    constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness) {
-        super(scene, GenericTriggerLayout[handness], gamepadObject, handness);
+    constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness) {
+        super(scene, GenericTriggerLayout[handedness], gamepadObject, handedness);
     }
 
     protected _getFilenameAndPath(): { filename: string; path: string; } {
@@ -40,7 +40,7 @@ export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionCont
     }
 
     protected _setRootMesh(meshes: AbstractMesh[]): void {
-        this.rootMesh = new Mesh(this.profileId + " " + this.handness, this.scene);
+        this.rootMesh = new Mesh(this.profileId + " " + this.handedness, this.scene);
 
         meshes.forEach((mesh) => {
             mesh.isPickable = false;

+ 5 - 5
src/XR/motionController/webXRHTCViveMotionController.ts

@@ -1,7 +1,7 @@
 import {
     IMotionControllerLayoutMap,
     IMinimalMotionControllerObject,
-    MotionControllerHandness,
+    MotionControllerHandedness,
     WebXRAbstractMotionController
 } from "./webXRAbstractMotionController";
 import { Scene } from '../../scene';
@@ -31,12 +31,12 @@ export class WebXRHTCViveMotionController extends WebXRAbstractMotionController
      * Create a new Vive motion controller object
      * @param scene the scene to use to create this controller
      * @param gamepadObject the corresponding gamepad object
-     * @param handness the handness of the controller
+     * @param handedness the handedness of the controller
      */
     constructor(scene: Scene,
         gamepadObject: IMinimalMotionControllerObject,
-        handness: MotionControllerHandness) {
-        super(scene, HTCViveLayout[handness], gamepadObject, handness);
+        handedness: MotionControllerHandedness) {
+        super(scene, HTCViveLayout[handedness], gamepadObject, handedness);
     }
 
     protected _getFilenameAndPath(): { filename: string; path: string; } {
@@ -75,7 +75,7 @@ export class WebXRHTCViveMotionController extends WebXRAbstractMotionController
     }
 
     protected _setRootMesh(meshes: AbstractMesh[]): void {
-        this.rootMesh = new Mesh(this.profileId + " " + this.handness, this.scene);
+        this.rootMesh = new Mesh(this.profileId + " " + this.handedness, this.scene);
 
         meshes.forEach((mesh) => { mesh.isPickable = false; });
         this._modelRootNode = meshes[1];

+ 5 - 5
src/XR/motionController/webXRMicrosoftMixedRealityController.ts

@@ -1,7 +1,7 @@
 import {
     WebXRAbstractMotionController,
     IMinimalMotionControllerObject,
-    MotionControllerHandness,
+    MotionControllerHandedness,
     IMotionControllerLayoutMap
 } from "./webXRAbstractMotionController";
 import { WebXRMotionControllerManager } from './webXRMotionControllerManager';
@@ -85,13 +85,13 @@ export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionCon
 
     public profileId = "microsoft-mixed-reality";
 
-    constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness) {
-        super(scene, MixedRealityProfile["left-right"], gamepadObject, handness);
+    constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness) {
+        super(scene, MixedRealityProfile["left-right"], gamepadObject, handedness);
     }
 
     protected _getFilenameAndPath(): { filename: string; path: string; } {
         let filename = "";
-        if (this.handness === 'left') {
+        if (this.handedness === 'left') {
             filename = WebXRMicrosoftMixedRealityController.MODEL_LEFT_FILENAME;
         }
         else { // Right is the default if no hand is specified
@@ -194,7 +194,7 @@ export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionCon
     }
 
     protected _setRootMesh(meshes: AbstractMesh[]): void {
-        this.rootMesh = new Mesh(this.profileId + " " + this.handness, this.scene);
+        this.rootMesh = new Mesh(this.profileId + " " + this.handedness, this.scene);
         this.rootMesh.isPickable = false;
         let rootMesh;
         // Find the root node in the loaded glTF scene, and attach it as a child of 'parentMesh'

+ 6 - 6
src/XR/motionController/webXROculusTouchMotionController.ts

@@ -1,7 +1,7 @@
 import {
     WebXRAbstractMotionController,
     IMinimalMotionControllerObject,
-    MotionControllerHandness,
+    MotionControllerHandedness,
     IMotionControllerLayoutMap
 } from "./webXRAbstractMotionController";
 import { WebXRMotionControllerManager } from './webXRMotionControllerManager';
@@ -38,15 +38,15 @@ export class WebXROculusTouchMotionController extends WebXRAbstractMotionControl
 
     constructor(scene: Scene,
         gamepadObject: IMinimalMotionControllerObject,
-        handness: MotionControllerHandness,
+        handedness: MotionControllerHandedness,
         legacyMapping: boolean = false,
         private _forceLegacyControllers: boolean = false) {
-        super(scene, OculusTouchLayouts[handness], gamepadObject, handness);
+        super(scene, OculusTouchLayouts[handedness], gamepadObject, handedness);
     }
 
     protected _getFilenameAndPath(): { filename: string; path: string; } {
         let filename = "";
-        if (this.handness === 'left') {
+        if (this.handedness === 'left') {
             filename = WebXROculusTouchMotionController.MODEL_LEFT_FILENAME;
         }
         else { // Right is the default if no hand is specified
@@ -66,7 +66,7 @@ export class WebXROculusTouchMotionController extends WebXRAbstractMotionControl
 
     protected _processLoadedModel(_meshes: AbstractMesh[]): void {
         const isQuest = this._isQuest();
-        const triggerDirection = this.handness === 'right' ? -1 : 1;
+        const triggerDirection = this.handedness === 'right' ? -1 : 1;
 
         this.getComponentIds().forEach((id) => {
             const comp = id && this.getComponent(id);
@@ -118,7 +118,7 @@ export class WebXROculusTouchMotionController extends WebXRAbstractMotionControl
     }
 
     protected _setRootMesh(meshes: AbstractMesh[]): void {
-        this.rootMesh = new Mesh(this.profileId + " " + this.handness, this.scene);
+        this.rootMesh = new Mesh(this.profileId + " " + this.handedness, this.scene);
         this.rootMesh.rotationQuaternion = Quaternion.FromEulerAngles(0, Math.PI, 0);
 
         meshes.forEach((mesh) => { mesh.isPickable = false; });

+ 1 - 1
src/XR/motionController/webXRProfiledMotionController.ts

@@ -96,7 +96,7 @@ export class WebXRProfiledMotionController extends WebXRAbstractMotionController
     }
 
     protected _setRootMesh(meshes: AbstractMesh[]): void {
-        this.rootMesh = new Mesh(this.profileId + "-" + this.handness, this.scene);
+        this.rootMesh = new Mesh(this.profileId + "-" + this.handedness, this.scene);
         this.rootMesh.isPickable = false;
         let rootMesh;
         // Find the root node in the loaded glTF scene, and attach it as a child of 'parentMesh'