Borut 6 lat temu
rodzic
commit
3cdf241f2b

+ 1 - 1
src/Physics/Plugins/ammoJSPlugin.ts

@@ -796,7 +796,7 @@ export class AmmoJSPlugin implements IPhysicsEnginePlugin {
      * @param from when should the ray start?
      * @param to when should the ray end?
      */
-    public raycast(from: Vector3, to: Vector3) {
+    public raycast(from: Vector3, to: Vector3): PhysicsRaycastResult {
         this._tmpAmmoVectorRCA = new this.bjsAMMO.btVector3(from.x, from.y, from.z);
         this._tmpAmmoVectorRCB = new this.bjsAMMO.btVector3(to.x, to.y, to.z);
 

+ 1 - 1
src/Physics/Plugins/cannonJSPlugin.ts

@@ -684,7 +684,7 @@ export class CannonJSPlugin implements IPhysicsEnginePlugin {
      * @param from when should the ray start?
      * @param to when should the ray end?
      */
-    public raycast(from: Vector3, to: Vector3) {
+    public raycast(from: Vector3, to: Vector3): PhysicsRaycastResult {
         this._cannonRaycastResult.reset();
         this.world.raycastClosest(from, to, {}, this._cannonRaycastResult);
 

+ 8 - 1
src/Physics/Plugins/oimoJSPlugin.ts

@@ -6,6 +6,7 @@ import { AbstractMesh } from "../../Meshes/abstractMesh";
 import { Vector3, Quaternion } from "../../Maths/math";
 import { Nullable } from "../../types";
 import { Logger } from "../../Misc/logger";
+import { PhysicsRaycastResult } from "../physicsRaycastResult";
 
 declare var OIMO: any;
 
@@ -15,6 +16,7 @@ export class OimoJSPlugin implements IPhysicsEnginePlugin {
     public world: any;
     public name: string = "OimoJSPlugin";
     public BJSOIMO: any;
+    private _raycastResult: PhysicsRaycastResult;
 
     constructor(iterations?: number, oimoInjection = OIMO) {
         this.BJSOIMO = oimoInjection;
@@ -22,6 +24,7 @@ export class OimoJSPlugin implements IPhysicsEnginePlugin {
             iterations: iterations
         });
         this.world.clear();
+        this._raycastResult = new PhysicsRaycastResult();
     }
 
     public setGravity(gravity: Vector3) {
@@ -479,7 +482,11 @@ export class OimoJSPlugin implements IPhysicsEnginePlugin {
      * @param from when should the ray start?
      * @param to when should the ray end?
      */
-    public raycast(from: Vector3, to: Vector3) {
+    public raycast(from: Vector3, to: Vector3): PhysicsRaycastResult {
         Logger.Warn("raycast is not currently supported by the Oimo physics plugin");
+
+        this._raycastResult.reset(from, to);
+
+        return this._raycastResult;
     }
 }