|
@@ -35,6 +35,7 @@ module BABYLON {
|
|
public onExitingVR: () => void;
|
|
public onExitingVR: () => void;
|
|
public onControllerMeshLoaded: (controller: WebVRController) => void;
|
|
public onControllerMeshLoaded: (controller: WebVRController) => void;
|
|
|
|
|
|
|
|
+ private _rayLength: number;
|
|
private _useCustomVRButton: boolean = false;
|
|
private _useCustomVRButton: boolean = false;
|
|
private _teleportationRequested: boolean = false;
|
|
private _teleportationRequested: boolean = false;
|
|
private _teleportationEnabledOnLeftController: boolean = false;
|
|
private _teleportationEnabledOnLeftController: boolean = false;
|
|
@@ -62,9 +63,18 @@ module BABYLON {
|
|
private _currentMeshSelected: Nullable<AbstractMesh>;
|
|
private _currentMeshSelected: Nullable<AbstractMesh>;
|
|
public onNewMeshSelected = new Observable<AbstractMesh>();
|
|
public onNewMeshSelected = new Observable<AbstractMesh>();
|
|
|
|
|
|
- private _meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
|
|
|
|
- public meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
|
|
|
|
|
|
+ private _raySelectionPredicate: (mesh: AbstractMesh) => boolean;
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * To be optionaly changed by user to define custom ray selection
|
|
|
|
+ */
|
|
|
|
+ public raySelectionPredicate: (mesh: AbstractMesh) => boolean;
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * To be optionaly changed by user to define custom selection logic (after ray selection)
|
|
|
|
+ */
|
|
|
|
+ public meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
|
|
|
|
+
|
|
private _currentHit: Nullable<PickingInfo>;
|
|
private _currentHit: Nullable<PickingInfo>;
|
|
private _pointerDownOnMeshAsked = false;
|
|
private _pointerDownOnMeshAsked = false;
|
|
private _isActionableMesh = false;
|
|
private _isActionableMesh = false;
|
|
@@ -117,6 +127,10 @@ module BABYLON {
|
|
this._btnVR = webVROptions.customVRButton;
|
|
this._btnVR = webVROptions.customVRButton;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ if (webVROptions.rayLength) {
|
|
|
|
+ this._rayLength = webVROptions.rayLength
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
if (!this._useCustomVRButton) {
|
|
if (!this._useCustomVRButton) {
|
|
@@ -404,17 +418,20 @@ module BABYLON {
|
|
this._createGazeTracker();
|
|
this._createGazeTracker();
|
|
this._createTeleportationCircles();
|
|
this._createTeleportationCircles();
|
|
|
|
|
|
- // To be optionnaly changed by user to define his custom selection logic
|
|
|
|
|
|
+ this.raySelectionPredicate = (mesh) => {
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
|
|
+
|
|
this.meshSelectionPredicate = (mesh) => {
|
|
this.meshSelectionPredicate = (mesh) => {
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
|
|
|
|
- this._meshSelectionPredicate = (mesh) => {
|
|
|
|
|
|
+ this._raySelectionPredicate = (mesh) => {
|
|
if (mesh.name.indexOf(this._floorMeshName) !== -1 || (mesh.isVisible && mesh.name.indexOf("gazeTracker") === -1
|
|
if (mesh.name.indexOf(this._floorMeshName) !== -1 || (mesh.isVisible && mesh.name.indexOf("gazeTracker") === -1
|
|
&& mesh.name.indexOf("teleportationCircle") === -1
|
|
&& mesh.name.indexOf("teleportationCircle") === -1
|
|
&& mesh.name.indexOf("torusTeleportation") === -1
|
|
&& mesh.name.indexOf("torusTeleportation") === -1
|
|
&& mesh.name.indexOf("laserPointer") === -1)) {
|
|
&& mesh.name.indexOf("laserPointer") === -1)) {
|
|
- return true;
|
|
|
|
|
|
+ return this.raySelectionPredicate(mesh);
|
|
}
|
|
}
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
@@ -906,18 +923,18 @@ module BABYLON {
|
|
(this._leftLaserPointer && !this._leftLaserPointer.isVisible && !this._rightLaserPointer) ||
|
|
(this._leftLaserPointer && !this._leftLaserPointer.isVisible && !this._rightLaserPointer) ||
|
|
(this._rightLaserPointer && !this._rightLaserPointer.isVisible && !this._leftLaserPointer) ||
|
|
(this._rightLaserPointer && !this._rightLaserPointer.isVisible && !this._leftLaserPointer) ||
|
|
(this._rightLaserPointer && this._leftLaserPointer && !this._rightLaserPointer.isVisible && !this._leftLaserPointer.isVisible)) {
|
|
(this._rightLaserPointer && this._leftLaserPointer && !this._rightLaserPointer.isVisible && !this._leftLaserPointer.isVisible)) {
|
|
- ray = this.currentVRCamera.getForwardRay();
|
|
|
|
|
|
+ ray = this.currentVRCamera.getForwardRay(this._rayLength);
|
|
|
|
|
|
} else {
|
|
} else {
|
|
if (this._leftLaserPointer && this._leftLaserPointer.isVisible) {
|
|
if (this._leftLaserPointer && this._leftLaserPointer.isVisible) {
|
|
- ray = (<any>this.currentVRCamera).leftController.getForwardRay();
|
|
|
|
|
|
+ ray = (<any>this.currentVRCamera).leftController.getForwardRay(this._rayLength);
|
|
}
|
|
}
|
|
else {
|
|
else {
|
|
- ray = (<any>this.currentVRCamera).rightController.getForwardRay();
|
|
|
|
|
|
+ ray = (<any>this.currentVRCamera).rightController.getForwardRay(this._rayLength);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- var hit = this._scene.pickWithRay(ray, this._meshSelectionPredicate);
|
|
|
|
|
|
+ var hit = this._scene.pickWithRay(ray, this._raySelectionPredicate);
|
|
|
|
|
|
// Moving the gazeTracker on the mesh face targetted
|
|
// Moving the gazeTracker on the mesh face targetted
|
|
if (hit && hit.pickedPoint) {
|
|
if (hit && hit.pickedPoint) {
|