Forráskód Böngészése

add new getForwardRay() to camera and controllers

David Catuhe 8 éve
szülő
commit
72fc60793d

+ 1 - 1
Playground/debug.html

@@ -150,7 +150,7 @@
             </div>
         </div>
         <div class="save-message" id="saveMessage">
-            This PG has no metadata. Click save to add them.
+            This PG has missing metadata. Click save to add them.
         </div>
     </div>
 

+ 1 - 1
Playground/index-local.html

@@ -116,7 +116,7 @@
             </div>
         </div>
         <div class="save-message" id="saveMessage">
-            This PG has no metadata. Click save to add them.
+            This PG has missing metadata. Click save to add them.
         </div>
     </div>
 

+ 1 - 1
Playground/index.html

@@ -149,7 +149,7 @@
             </div>
         </div>
         <div class="save-message" id="saveMessage">
-            This PG has no metadata. Click save to add them.
+            This PG has missing metadata. Click save to add them.
         </div>
     </div>
 

+ 1 - 1
Playground/index2_5.html

@@ -123,7 +123,7 @@
             </div>
         </div>
         <div class="save-message" id="saveMessage">
-            This PG has no metadata. Click save to add them.
+            This PG has missing metadata. Click save to add them.
         </div>
     </div>
 

+ 1 - 1
Playground/test.html

@@ -51,5 +51,5 @@
     </div>
 </div>
 <div class="save-message" id="saveMessage">
-    This PG has no metadata. Click save to add them.
+    This PG has missing metadata. Click save to add them.
 </div>

+ 19 - 0
src/Cameras/babylon.camera.ts

@@ -530,6 +530,25 @@
             return target.isCompletelyInFrustum(this._frustumPlanes);
         }
 
+        public getForwardRay(length = 100): Ray {
+            var m = this.getWorldMatrix();
+
+            var origin:Vector3;
+
+            if ((<any>this).devicePosition) {
+                origin = this.position.add((<any>this).devicePosition);
+            } else {
+                origin = this.position;
+            }
+
+            var forward = new BABYLON.Vector3(0, 0, 1);
+            var forwardWorld = BABYLON.Vector3.TransformNormal(forward, m);
+
+            var direction = BABYLON.Vector3.Normalize(forwardWorld);
+
+            return new Ray(origin, direction, length);
+        } 
+
         public dispose(): void {
             // Animations
             this.getScene().stopAnimation(this);

+ 12 - 0
src/Tools/babylon.extendedGamepad.ts

@@ -125,6 +125,18 @@ module BABYLON {
         public get mesh(): AbstractMesh {
             return this._mesh;
         }
+
+        public getForwardRay(length = 100): Ray {
+            var m = this.mesh.getWorldMatrix();
+            var origin = m.getTranslation();
+
+            var forward = new BABYLON.Vector3(0, 0, -1);
+            var forwardWorld = BABYLON.Vector3.TransformNormal(forward, m);
+
+            var direction = BABYLON.Vector3.Normalize(forwardWorld);            
+
+            return new Ray(origin, direction, length);
+        } 
     }
 
     export interface GamepadButtonChanges {