Browse Source

Merge remote-tracking branch 'upstream/master' into libToModules

sebavan 6 năm trước cách đây
mục cha
commit
8cc5bd4499
2 tập tin đã thay đổi với 23 bổ sung0 xóa
  1. 1 0
      dist/preview release/what's new.md
  2. 22 0
      src/Particles/solidParticle.ts

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

@@ -87,6 +87,7 @@
 - Invert vScale of compressed ktx textures as they are inverted in the file and UNPACK_FLIP_Y_WEBGL is not supported by ktx ([TrevorDev](https://github.com/TrevorDev))
 - Enable dragging in boundingBoxGizmo without needing a parent ([TrevorDev](https://github.com/TrevorDev))
 - Added per mesh culling strategy ([jerome](https://github.com/jbousquie))
+- Added per solid particle culling possibility : `solidParticle.isInFrustum()`  ([jerome](https://github.com/jbousquie))
 
 ### OBJ Loader
 - Add color vertex support (not part of standard) ([brianzinn](https://github.com/brianzinn))

+ 22 - 0
src/Particles/solidParticle.ts

@@ -105,6 +105,18 @@ import { SolidParticleSystem } from "./solidParticleSystem";
          */
         public parentId: Nullable<number> = null;
         /**
+         * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
+         * The possible values are :
+         * - AbstractMesh.CULLINGSTRATEGY_STANDARD
+         * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
+         * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
+         * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
+         * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
+         * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
+         * */
+        public cullingStrategy = AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY;
+
+        /**
          * @hidden Internal global position in the SPS.
          */
         public _globalPosition: Vector3 = Vector3.Zero();
@@ -179,6 +191,16 @@ import { SolidParticleSystem } from "./solidParticleSystem";
         }
 
         /**
+         * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
+         * A particle is in the frustum if its bounding box intersects the frustum
+         * @param frustumPlanes defines the frustum to test
+         * @returns true if the particle is in the frustum planes
+         */
+        public isInFrustum(frustumPlanes: Plane[]): boolean {
+            return this._boundingInfo !== null && this._boundingInfo.isInFrustum(frustumPlanes, this.cullingStrategy);
+        }
+
+        /**
          * get the rotation matrix of the particle
          * @hidden
          */