|
@@ -163,6 +163,16 @@ export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
|
|
|
public selectionMeshPickedColor: Color3 = new Color3(0.3, 0.3, 1.0);
|
|
|
|
|
|
/**
|
|
|
+ * To be optionaly changed by user to define custom selection logic (after ray selection)
|
|
|
+ */
|
|
|
+ public meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * To be optionaly changed by user to define custom ray selection
|
|
|
+ */
|
|
|
+ public raySelectionPredicate: (mesh: AbstractMesh) => boolean;
|
|
|
+
|
|
|
+ /**
|
|
|
* constructs a new background remover module
|
|
|
* @param _xrSessionManager the session manager for this module
|
|
|
* @param _options read-only options to be used in this module
|
|
@@ -248,7 +258,7 @@ export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
|
|
|
|
|
|
// Every frame check collisions/input
|
|
|
controllerData.xrController.getWorldPointerRayToRef(controllerData.tmpRay);
|
|
|
- controllerData.pick = this._scene.pickWithRay(controllerData.tmpRay);
|
|
|
+ controllerData.pick = this._scene.pickWithRay(controllerData.tmpRay, this.raySelectionPredicate);
|
|
|
|
|
|
const pick = controllerData.pick;
|
|
|
|
|
@@ -273,7 +283,11 @@ export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
|
|
|
controllerData.selectionMesh.position.addInPlace(pickNormal.scale(deltaFighting));
|
|
|
}
|
|
|
controllerData.selectionMesh.isVisible = true && this.displaySelectionMesh;
|
|
|
- controllerData.meshUnderPointer = pick.pickedMesh;
|
|
|
+ if (this.meshSelectionPredicate && pick.pickedMesh && this.meshSelectionPredicate(pick.pickedMesh)) {
|
|
|
+ controllerData.meshUnderPointer = pick.pickedMesh;
|
|
|
+ } else {
|
|
|
+ controllerData.meshUnderPointer = pick.pickedMesh;
|
|
|
+ }
|
|
|
} else {
|
|
|
controllerData.selectionMesh.isVisible = false;
|
|
|
controllerData.meshUnderPointer = null;
|