API

Interface IWebXRHandTrackingOptions

Configuration interface for the hand tracking feature

interface IWebXRHandTrackingOptions {
    handMeshes?: {
        customColors?: {
            base?: Color3;
            fingerColor?: Color3;
            fresnel?: Color3;
            tipFresnel?: Color3;
        };
        customMeshes?: { left: AbstractMesh; right: AbstractMesh };
        customRigMappings?: {
            left: XRHandMeshRigMapping;
            right: XRHandMeshRigMapping;
        };
        disableDefaultMeshes?: boolean;
        disableHandShader?: boolean;
        disposeOnSessionEnd?: boolean;
        meshesUseLeftHandedCoordinates?: boolean;
    };
    jointMeshes?: {
        enablePhysics?: boolean;
        invisible?: boolean;
        keepOriginalVisible?: boolean;
        onHandJointMeshGenerated?: (
            meshInstance: InstancedMesh,
            jointId: number,
            hand: XRHandedness,
        ) => AbstractMesh | undefined;
        physicsProps?: {
            friction?: number;
            impostorType?: number;
            restitution?: number;
        };
        scaleFactor?: number;
        sourceMesh?: Mesh;
    };
    xrInput: WebXRInput;
}
Index
handMeshes?: {
    customColors?: {
        base?: Color3;
        fingerColor?: Color3;
        fresnel?: Color3;
        tipFresnel?: Color3;
    };
    customMeshes?: { left: AbstractMesh; right: AbstractMesh };
    customRigMappings?: {
        left: XRHandMeshRigMapping;
        right: XRHandMeshRigMapping;
    };
    disableDefaultMeshes?: boolean;
    disableHandShader?: boolean;
    disposeOnSessionEnd?: boolean;
    meshesUseLeftHandedCoordinates?: boolean;
}

Configuration object for the hand meshes.

Type Declaration

  • OptionalcustomColors?: { base?: Color3; fingerColor?: Color3; fresnel?: Color3; tipFresnel?: Color3 }

    Override the colors of the hand meshes.

  • OptionalcustomMeshes?: { left: AbstractMesh; right: AbstractMesh }

    Rigged hand meshes that will be tracked to the user's hands. This will override the default hand mesh.

  • OptionalcustomRigMappings?: { left: XRHandMeshRigMapping; right: XRHandMeshRigMapping }

    If a hand mesh was provided, this array will define what axis will update which node. This will override the default hand mesh

  • OptionaldisableDefaultMeshes?: boolean

    Should the default hand mesh be disabled. In this case, the spheres will be visible (unless set invisible).

  • OptionaldisableHandShader?: boolean

    Setting this will allow the developer to avoid loading the NME material and use the standard material instead.

  • OptionaldisposeOnSessionEnd?: boolean

    Define whether or not the hand meshes should be disposed on just invisible when the session ends. Not setting, or setting to false, will maintain the hand meshes in the scene after the session ends, which will allow q quicker re-entry into XR.

  • OptionalmeshesUseLeftHandedCoordinates?: boolean

    Are the meshes prepared for a left-handed system. Default hand meshes are right-handed.

jointMeshes?: {
    enablePhysics?: boolean;
    invisible?: boolean;
    keepOriginalVisible?: boolean;
    onHandJointMeshGenerated?: (
        meshInstance: InstancedMesh,
        jointId: number,
        hand: XRHandedness,
    ) => AbstractMesh | undefined;
    physicsProps?: {
        friction?: number;
        impostorType?: number;
        restitution?: number;
    };
    scaleFactor?: number;
    sourceMesh?: Mesh;
}

Configuration object for the joint meshes.

Type Declaration

  • OptionalenablePhysics?: boolean

    Should each instance have its own physics impostor

  • Optionalinvisible?: boolean

    Should the meshes created be invisible (defaults to false).

  • OptionalkeepOriginalVisible?: boolean

    Should the source mesh stay visible (defaults to false).

  • OptionalonHandJointMeshGenerated?: (
        meshInstance: InstancedMesh,
        jointId: number,
        hand: XRHandedness,
    ) => AbstractMesh | undefined

    This function will be called after a mesh was created for a specific joint. Using this function you can either manipulate the instance or return a new mesh. When returning a new mesh the instance created before will be disposed.

  • OptionalphysicsProps?: { friction?: number; impostorType?: number; restitution?: number }

    If enabled, override default physics properties

  • OptionalscaleFactor?: number

    Scale factor for all joint meshes (defaults to 1)

  • OptionalsourceMesh?: Mesh

    A source mesh to be used to create instances. Defaults to an icosphere with two subdivisions and smooth lighting. This mesh will be the source for all other (25) meshes. It should have the general size of a single unit, as the instances will be scaled according to the provided radius.

xrInput: WebXRInput

The xrInput that will be used as source for new hands