Przeglądaj źródła

small teleportation modification

Raanan Weber 5 lat temu
rodzic
commit
c11987a1fa

+ 15 - 2
src/Cameras/XR/features/WebXRControllerTeleportation.ts

@@ -21,6 +21,7 @@ import { PickingInfo } from '../../../Collisions/pickingInfo';
 import { Curve3 } from '../../../Maths/math.path';
 import { LinesBuilder } from '../../../Meshes/Builders/linesBuilder';
 import { WebXRAbstractFeature } from './WebXRAbstractFeature';
+import { Color3 } from '../../../Maths/math.color';
 
 /**
  * The options container for the teleportation module
@@ -64,6 +65,10 @@ export interface IWebXRTeleportationOptions {
          * Disable the mesh's animation sequence
          */
         disableAnimation?: boolean;
+        /**
+         * Disable lighting on the material or the ring and arrow
+         */
+        disableLighting?: boolean;
     };
 
     /**
@@ -461,7 +466,7 @@ export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
         let teleportationTarget = GroundBuilder.CreateGround("teleportationTarget", { width: 2, height: 2, subdivisions: 2 }, scene);
         teleportationTarget.isPickable = false;
         let length = 512;
-        let dynamicTexture = new DynamicTexture("DynamicTexture", length, scene, true);
+        let dynamicTexture = new DynamicTexture("teleportationPlaneDynamicTexture", length, scene, true);
         dynamicTexture.hasAlpha = true;
         let context = dynamicTexture.getContext();
         let centerX = length / 2;
@@ -476,7 +481,7 @@ export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
         context.stroke();
         context.closePath();
         dynamicTexture.update();
-        let teleportationCircleMaterial = new StandardMaterial("TextPlaneMaterial", scene);
+        const teleportationCircleMaterial = new StandardMaterial("teleportationPlaneMaterial", scene);
         teleportationCircleMaterial.diffuseTexture = dynamicTexture;
         teleportationTarget.material = teleportationCircleMaterial;
         let torus = TorusBuilder.CreateTorus("torusTeleportation", {
@@ -522,6 +527,14 @@ export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
         if (this._options.defaultTargetMeshOptions.torusArrowMaterial) {
             torus.material = this._options.defaultTargetMeshOptions.torusArrowMaterial;
             cone.material = this._options.defaultTargetMeshOptions.torusArrowMaterial;
+        } else {
+            const torusConeMaterial = new StandardMaterial("torusConsMat", scene);
+            torusConeMaterial.disableLighting = !!this._options.defaultTargetMeshOptions.disableLighting;
+            if (torusConeMaterial.disableLighting) {
+                torusConeMaterial.emissiveColor = Color3.Gray();
+            }
+            torus.material = torusConeMaterial;
+            cone.material = torusConeMaterial;
         }
 
         this._options.teleportationTargetMesh = teleportationTarget;