瀏覽代碼

navmesh moveAlong function

Cedric Guillemet 6 年之前
父節點
當前提交
e41ff2f14b

文件差異過大導致無法顯示
+ 8 - 8
dist/preview release/recast.js


+ 3 - 0
dist/preview release/what's new.md

@@ -99,6 +99,9 @@
 - Added `Container.maxLayoutCycle` and `Container.logLayoutCycleErrors` to get more control over layout cycles ([Deltakosh](https://github.com/deltakosh/))
 - Added `StackPanel.ignoreLayoutWarnings` to disable console warnings when controls with percentage size are added to a StackPanel ([Deltakosh](https://github.com/deltakosh/))
 
+### Navigation Mesh
+- Added moveAlong function to cast a segment on mavmesh ([CedricGuillemet](https://github.com/CedricGuillemet/))
+
 ### Documentation
 - Added a note on shallow bounding of getBoundingInfo ([tibotiber](https://github.com/tibotiber))
 

+ 8 - 0
src/Navigation/INavigationEngine.ts

@@ -42,6 +42,14 @@ export interface INavigationEnginePlugin {
     getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
 
     /**
+     * Compute the final position from a segment made of destination-position
+     * @param position world position
+     * @param destination world position
+     * @returns the resulting point along the navmesh
+     */
+    moveAlong(position: Vector3, destination: Vector3): Vector3;
+
+    /**
      * Compute a navigation path from start to end. Returns an empty array if no path can be computed
      * @param start world position
      * @param end world position

+ 14 - 0
src/Navigation/Plugins/recastJSPlugin.ts

@@ -175,6 +175,20 @@ export class RecastJSPlugin implements INavigationEnginePlugin {
     }
 
     /**
+     * Compute the final position from a segment made of destination-position
+     * @param position world position
+     * @param destination world position
+     * @returns the resulting point along the navmesh
+     */
+    moveAlong(position: Vector3, destination: Vector3): Vector3 {
+        var p = new this.bjsRECAST.Vec3(position.x, position.y, position.z);
+        var d = new this.bjsRECAST.Vec3(destination.x, destination.y, destination.z);
+        var ret = this.navMesh.moveAlong(p, d);
+        var pr = new Vector3(ret.x, ret.y, ret.z);
+        return pr;
+    }
+
+    /**
      * Compute a navigation path from start to end. Returns an empty array if no path can be computed
      * @param start world position
      * @param end world position