@onerjs/core 8.25.8 → 8.26.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -733,6 +733,11 @@ export declare class Vector2 implements Vector<Tuple<number, 2>, IVector2Like>,
733
733
  */
734
734
  static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
735
735
  }
736
+ type VectorInterceptor = (newValue: {
737
+ x?: number;
738
+ y?: number;
739
+ z?: number;
740
+ }) => boolean;
736
741
  /**
737
742
  * Class used to store (x,y,z) vector representation
738
743
  * A Vector3 is the main object used in 3D geometry
@@ -775,6 +780,8 @@ export declare class Vector3 implements Vector<Tuple<number, 3>, IVector3LikeInt
775
780
  _z: number;
776
781
  /** @internal */
777
782
  _isDirty: boolean;
783
+ /** @internal */
784
+ private _interceptor?;
778
785
  /** Gets or sets the x coordinate */
779
786
  get x(): number;
780
787
  set x(value: number);
@@ -789,8 +796,9 @@ export declare class Vector3 implements Vector<Tuple<number, 3>, IVector3LikeInt
789
796
  * @param x defines the first coordinates (on X axis)
790
797
  * @param y defines the second coordinates (on Y axis)
791
798
  * @param z defines the third coordinates (on Z axis)
799
+ * @param interceptor defines intercept the value change function
792
800
  */
793
- constructor(x?: number, y?: number, z?: number);
801
+ constructor(x?: number, y?: number, z?: number, interceptor?: VectorInterceptor);
794
802
  /**
795
803
  * Creates a string representation of the Vector3
796
804
  * Example Playground https://playground.babylonjs.com/#R1F8YU#67
@@ -829,6 +837,20 @@ export declare class Vector3 implements Vector<Tuple<number, 3>, IVector3LikeInt
829
837
  * @returns the current Vector3
830
838
  */
831
839
  fromArray(array: DeepImmutable<FloatArray>, offset?: number): this;
840
+ /**
841
+ * Intercept the x,y,z value change
842
+ * @param interceptor
843
+ */
844
+ setInterceptor(interceptor: (newValue: {
845
+ x?: number;
846
+ y?: number;
847
+ z?: number;
848
+ }) => boolean): void;
849
+ /**
850
+ * Get the current interceptor
851
+ * @returns the current vector interceptor
852
+ */
853
+ getInterceptor(): Nullable<VectorInterceptor> | undefined;
832
854
  /**
833
855
  * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
834
856
  * Example Playground https://playground.babylonjs.com/#R1F8YU#66
@@ -4373,3 +4395,4 @@ export declare class TmpVectors {
4373
4395
  /** 8 temp Matrices at once should be enough */
4374
4396
  static Matrix: [Matrix, Matrix, Matrix, Matrix, Matrix, Matrix, Matrix, Matrix];
4375
4397
  }
4398
+ export {};
@@ -967,6 +967,9 @@ export class Vector3 {
967
967
  return this._x;
968
968
  }
969
969
  set x(value) {
970
+ if (this._interceptor && this._interceptor({ x: value })) {
971
+ return;
972
+ }
970
973
  this._x = value;
971
974
  this._isDirty = true;
972
975
  }
@@ -975,6 +978,9 @@ export class Vector3 {
975
978
  return this._y;
976
979
  }
977
980
  set y(value) {
981
+ if (this._interceptor && this._interceptor({ y: value })) {
982
+ return;
983
+ }
978
984
  this._y = value;
979
985
  this._isDirty = true;
980
986
  }
@@ -983,6 +989,9 @@ export class Vector3 {
983
989
  return this._z;
984
990
  }
985
991
  set z(value) {
992
+ if (this._interceptor && this._interceptor({ z: value })) {
993
+ return;
994
+ }
986
995
  this._z = value;
987
996
  this._isDirty = true;
988
997
  }
@@ -991,13 +1000,19 @@ export class Vector3 {
991
1000
  * @param x defines the first coordinates (on X axis)
992
1001
  * @param y defines the second coordinates (on Y axis)
993
1002
  * @param z defines the third coordinates (on Z axis)
1003
+ * @param interceptor defines intercept the value change function
994
1004
  */
995
- constructor(x = 0, y = 0, z = 0) {
1005
+ constructor(x = 0, y = 0, z = 0, interceptor) {
996
1006
  /** @internal */
997
1007
  this._isDirty = true;
1008
+ /** @internal */
1009
+ this._interceptor = null;
998
1010
  this._x = x;
999
1011
  this._y = y;
1000
1012
  this._z = z;
1013
+ if (interceptor) {
1014
+ this._interceptor = interceptor;
1015
+ }
1001
1016
  }
1002
1017
  /**
1003
1018
  * Creates a string representation of the Vector3
@@ -1060,6 +1075,20 @@ export class Vector3 {
1060
1075
  Vector3.FromArrayToRef(array, offset, this);
1061
1076
  return this;
1062
1077
  }
1078
+ /**
1079
+ * Intercept the x,y,z value change
1080
+ * @param interceptor
1081
+ */
1082
+ setInterceptor(interceptor) {
1083
+ this._interceptor = interceptor;
1084
+ }
1085
+ /**
1086
+ * Get the current interceptor
1087
+ * @returns the current vector interceptor
1088
+ */
1089
+ getInterceptor() {
1090
+ return this._interceptor;
1091
+ }
1063
1092
  /**
1064
1093
  * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
1065
1094
  * Example Playground https://playground.babylonjs.com/#R1F8YU#66