@babylonjs/core 5.17.1 → 5.20.0

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.
Files changed (159) hide show
  1. package/Debug/debugLayer.d.ts +36 -0
  2. package/Debug/debugLayer.js.map +1 -1
  3. package/DeviceInput/InputDevices/deviceSource.d.ts +1 -1
  4. package/DeviceInput/InputDevices/deviceSource.js.map +1 -1
  5. package/DeviceInput/InputDevices/deviceSourceManager.d.ts +1 -1
  6. package/DeviceInput/InputDevices/deviceSourceManager.js +1 -1
  7. package/DeviceInput/InputDevices/deviceSourceManager.js.map +1 -1
  8. package/DeviceInput/{Helpers/eventFactory.d.ts → eventFactory.d.ts} +4 -4
  9. package/DeviceInput/{Helpers/eventFactory.js → eventFactory.js} +2 -2
  10. package/DeviceInput/eventFactory.js.map +1 -0
  11. package/DeviceInput/{InputDevices/inputInterfaces.d.ts → inputInterfaces.d.ts} +2 -2
  12. package/DeviceInput/{InputDevices/inputInterfaces.js → inputInterfaces.js} +0 -0
  13. package/DeviceInput/inputInterfaces.js.map +1 -0
  14. package/DeviceInput/{InputDevices/internalDeviceSourceManager.d.ts → internalDeviceSourceManager.d.ts} +7 -7
  15. package/DeviceInput/{InputDevices/internalDeviceSourceManager.js → internalDeviceSourceManager.js} +2 -2
  16. package/DeviceInput/internalDeviceSourceManager.js.map +1 -0
  17. package/DeviceInput/{InputDevices/nativeDeviceInputSystem.d.ts → nativeDeviceInputSystem.d.ts} +2 -2
  18. package/DeviceInput/{InputDevices/nativeDeviceInputSystem.js → nativeDeviceInputSystem.js} +2 -2
  19. package/DeviceInput/nativeDeviceInputSystem.js.map +1 -0
  20. package/DeviceInput/{InputDevices/webDeviceInputSystem.d.ts → webDeviceInputSystem.d.ts} +3 -3
  21. package/DeviceInput/{InputDevices/webDeviceInputSystem.js → webDeviceInputSystem.js} +4 -4
  22. package/DeviceInput/webDeviceInputSystem.js.map +1 -0
  23. package/Engines/Extensions/engine.query.js +5 -1
  24. package/Engines/Extensions/engine.query.js.map +1 -1
  25. package/Engines/Extensions/engine.transformFeedback.js +5 -1
  26. package/Engines/Extensions/engine.transformFeedback.js.map +1 -1
  27. package/Engines/Extensions/engine.views.d.ts +13 -0
  28. package/Engines/Extensions/engine.views.js +16 -1
  29. package/Engines/Extensions/engine.views.js.map +1 -1
  30. package/Engines/Native/nativeInterfaces.d.ts +1 -1
  31. package/Engines/Native/nativeInterfaces.js.map +1 -1
  32. package/Engines/engine.d.ts +15 -240
  33. package/Engines/engineFeatures.d.ts +2 -0
  34. package/Engines/engineFeatures.js.map +1 -1
  35. package/Engines/nativeEngine.js +1 -0
  36. package/Engines/nativeEngine.js.map +1 -1
  37. package/Engines/nullEngine.js +1 -0
  38. package/Engines/nullEngine.js.map +1 -1
  39. package/Engines/thinEngine.d.ts +1 -1
  40. package/Engines/thinEngine.js +14 -4
  41. package/Engines/thinEngine.js.map +1 -1
  42. package/Engines/webgpuEngine.js +1 -0
  43. package/Engines/webgpuEngine.js.map +1 -1
  44. package/Gizmos/axisDragGizmo.d.ts +31 -9
  45. package/Gizmos/axisDragGizmo.js.map +1 -1
  46. package/Gizmos/axisScaleGizmo.d.ts +46 -14
  47. package/Gizmos/axisScaleGizmo.js.map +1 -1
  48. package/Gizmos/boundingBoxGizmo.d.ts +94 -19
  49. package/Gizmos/boundingBoxGizmo.js.map +1 -1
  50. package/Gizmos/cameraGizmo.d.ts +23 -6
  51. package/Gizmos/cameraGizmo.js.map +1 -1
  52. package/Gizmos/gizmo.d.ts +48 -6
  53. package/Gizmos/gizmo.js.map +1 -1
  54. package/Gizmos/gizmoManager.d.ts +25 -17
  55. package/Gizmos/gizmoManager.js.map +1 -1
  56. package/Gizmos/lightGizmo.d.ts +25 -8
  57. package/Gizmos/lightGizmo.js.map +1 -1
  58. package/Gizmos/planeDragGizmo.d.ts +30 -9
  59. package/Gizmos/planeDragGizmo.js.map +1 -1
  60. package/Gizmos/planeRotationGizmo.d.ts +45 -15
  61. package/Gizmos/planeRotationGizmo.js.map +1 -1
  62. package/Gizmos/positionGizmo.d.ts +53 -17
  63. package/Gizmos/positionGizmo.js +1 -1
  64. package/Gizmos/positionGizmo.js.map +1 -1
  65. package/Gizmos/rotationGizmo.d.ts +35 -10
  66. package/Gizmos/rotationGizmo.js.map +1 -1
  67. package/Gizmos/scaleGizmo.d.ts +49 -18
  68. package/Gizmos/scaleGizmo.js.map +1 -1
  69. package/Loading/Plugins/babylonFileLoader.js +16 -4
  70. package/Loading/Plugins/babylonFileLoader.js.map +1 -1
  71. package/Materials/Node/Blocks/Fragment/heightToNormalBlock.d.ts +39 -0
  72. package/Materials/Node/Blocks/Fragment/heightToNormalBlock.js +97 -0
  73. package/Materials/Node/Blocks/Fragment/heightToNormalBlock.js.map +1 -0
  74. package/Materials/Node/Blocks/Fragment/index.d.ts +1 -0
  75. package/Materials/Node/Blocks/Fragment/index.js +1 -0
  76. package/Materials/Node/Blocks/Fragment/index.js.map +1 -1
  77. package/Materials/Node/Blocks/Vertex/lightInformationBlock.d.ts +18 -0
  78. package/Materials/Node/Blocks/Vertex/lightInformationBlock.js +85 -1
  79. package/Materials/Node/Blocks/Vertex/lightInformationBlock.js.map +1 -1
  80. package/Materials/Node/nodeMaterial.d.ts +6 -0
  81. package/Materials/Node/nodeMaterial.js +11 -0
  82. package/Materials/Node/nodeMaterial.js.map +1 -1
  83. package/Materials/Textures/Procedurals/proceduralTexture.js +5 -1
  84. package/Materials/Textures/Procedurals/proceduralTexture.js.map +1 -1
  85. package/Materials/Textures/renderTargetTexture.js +3 -0
  86. package/Materials/Textures/renderTargetTexture.js.map +1 -1
  87. package/Materials/Textures/texture.js +9 -5
  88. package/Materials/Textures/texture.js.map +1 -1
  89. package/Materials/index.d.ts +1 -0
  90. package/Materials/index.js +1 -0
  91. package/Materials/index.js.map +1 -1
  92. package/Maths/math.vector.d.ts +134 -8
  93. package/Maths/math.vector.js +168 -36
  94. package/Maths/math.vector.js.map +1 -1
  95. package/Meshes/Compression/dracoCompression.js +1 -1
  96. package/Meshes/Compression/dracoCompression.js.map +1 -1
  97. package/Meshes/groundMesh.js +1 -1
  98. package/Meshes/groundMesh.js.map +1 -1
  99. package/Meshes/mesh.js +1 -0
  100. package/Meshes/mesh.js.map +1 -1
  101. package/Meshes/transformNode.js +1 -0
  102. package/Meshes/transformNode.js.map +1 -1
  103. package/Misc/assetsManager.d.ts +9 -0
  104. package/Misc/assetsManager.js +3 -1
  105. package/Misc/assetsManager.js.map +1 -1
  106. package/Misc/basis.js +10 -4
  107. package/Misc/basis.js.map +1 -1
  108. package/Misc/computePressure.d.ts +9 -3
  109. package/Misc/computePressure.js +13 -5
  110. package/Misc/computePressure.js.map +1 -1
  111. package/Misc/fileTools.js +2 -2
  112. package/Misc/fileTools.js.map +1 -1
  113. package/Misc/iInspectable.d.ts +12 -2
  114. package/Misc/iInspectable.js +4 -0
  115. package/Misc/iInspectable.js.map +1 -1
  116. package/Misc/khronosTextureContainer2.js +1 -1
  117. package/Misc/khronosTextureContainer2.js.map +1 -1
  118. package/Misc/sceneSerializer.js +1 -1
  119. package/Misc/sceneSerializer.js.map +1 -1
  120. package/Misc/tools.d.ts +2 -2
  121. package/Misc/tools.js +4 -1
  122. package/Misc/tools.js.map +1 -1
  123. package/Offline/database.js +6 -8
  124. package/Offline/database.js.map +1 -1
  125. package/Particles/solidParticleSystem.d.ts +1 -0
  126. package/Particles/solidParticleSystem.js +4 -1
  127. package/Particles/solidParticleSystem.js.map +1 -1
  128. package/Physics/Plugins/ammoJSPlugin.d.ts +2 -2
  129. package/Physics/Plugins/ammoJSPlugin.js +29 -29
  130. package/Physics/Plugins/ammoJSPlugin.js.map +1 -1
  131. package/Physics/Plugins/cannonJSPlugin.d.ts +2 -2
  132. package/Physics/Plugins/cannonJSPlugin.js +26 -26
  133. package/Physics/Plugins/cannonJSPlugin.js.map +1 -1
  134. package/Physics/Plugins/oimoJSPlugin.js +9 -11
  135. package/Physics/Plugins/oimoJSPlugin.js.map +1 -1
  136. package/Physics/physicsImpostor.d.ts +6 -6
  137. package/Physics/physicsImpostor.js +15 -8
  138. package/Physics/physicsImpostor.js.map +1 -1
  139. package/Shaders/sprites.fragment.js +1 -1
  140. package/Shaders/sprites.fragment.js.map +1 -1
  141. package/Sprites/spriteRenderer.js +1 -1
  142. package/Sprites/spriteRenderer.js.map +1 -1
  143. package/XR/webXRDefaultExperience.d.ts +10 -0
  144. package/XR/webXRDefaultExperience.js +2 -12
  145. package/XR/webXRDefaultExperience.js.map +1 -1
  146. package/XR/webXRExperienceHelper.js +12 -12
  147. package/XR/webXRExperienceHelper.js.map +1 -1
  148. package/node.d.ts +2 -0
  149. package/node.js +2 -0
  150. package/node.js.map +1 -1
  151. package/package.json +1 -1
  152. package/scene.d.ts +1 -1
  153. package/scene.js +5 -3
  154. package/scene.js.map +1 -1
  155. package/DeviceInput/Helpers/eventFactory.js.map +0 -1
  156. package/DeviceInput/InputDevices/inputInterfaces.js.map +0 -1
  157. package/DeviceInput/InputDevices/internalDeviceSourceManager.js.map +0 -1
  158. package/DeviceInput/InputDevices/nativeDeviceInputSystem.js.map +0 -1
  159. package/DeviceInput/InputDevices/webDeviceInputSystem.js.map +0 -1
@@ -406,6 +406,16 @@ var Vector2 = /** @class */ (function () {
406
406
  Vector2.One = function () {
407
407
  return new Vector2(1, 1);
408
408
  };
409
+ Object.defineProperty(Vector2, "ZeroReadOnly", {
410
+ /**
411
+ * Gets a zero Vector2 that must not be updated
412
+ */
413
+ get: function () {
414
+ return Vector2._ZeroReadOnly;
415
+ },
416
+ enumerable: false,
417
+ configurable: true
418
+ });
409
419
  /**
410
420
  * Gets a new Vector2 set from the given index element of the given array
411
421
  * @param array defines the data source
@@ -677,6 +687,7 @@ var Vector2 = /** @class */ (function () {
677
687
  var proj = segA.add(v.multiplyByFloats(t, t));
678
688
  return Vector2.Distance(p, proj);
679
689
  };
690
+ Vector2._ZeroReadOnly = Vector2.Zero();
680
691
  return Vector2;
681
692
  }());
682
693
  export { Vector2 };
@@ -685,6 +696,7 @@ export { Vector2 };
685
696
  * A Vector3 is the main object used in 3D geometry
686
697
  * It can represent either the coordinates of a point the space, either a direction
687
698
  * Reminder: js uses a left handed forward facing system
699
+ * Example Playground - Overview - https://playground.babylonjs.com/#R1F8YU
688
700
  */
689
701
  var Vector3 = /** @class */ (function () {
690
702
  /**
@@ -741,6 +753,7 @@ var Vector3 = /** @class */ (function () {
741
753
  });
742
754
  /**
743
755
  * Creates a string representation of the Vector3
756
+ * Example Playground https://playground.babylonjs.com/#R1F8YU#67
744
757
  * @returns a string with the Vector3 coordinates.
745
758
  */
746
759
  Vector3.prototype.toString = function () {
@@ -769,6 +782,7 @@ var Vector3 = /** @class */ (function () {
769
782
  // Operators
770
783
  /**
771
784
  * Creates an array containing three elements : the coordinates of the Vector3
785
+ * Example Playground https://playground.babylonjs.com/#R1F8YU#10
772
786
  * @returns a new array of numbers
773
787
  */
774
788
  Vector3.prototype.asArray = function () {
@@ -778,6 +792,7 @@ var Vector3 = /** @class */ (function () {
778
792
  };
779
793
  /**
780
794
  * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
795
+ * Example Playground https://playground.babylonjs.com/#R1F8YU#65
781
796
  * @param array defines the destination array
782
797
  * @param index defines the offset in the destination array
783
798
  * @returns the current Vector3
@@ -791,6 +806,7 @@ var Vector3 = /** @class */ (function () {
791
806
  };
792
807
  /**
793
808
  * Update the current vector from an array
809
+ * Example Playground https://playground.babylonjs.com/#R1F8YU#24
794
810
  * @param array defines the destination array
795
811
  * @param index defines the offset in the destination array
796
812
  * @returns the current Vector3
@@ -802,6 +818,7 @@ var Vector3 = /** @class */ (function () {
802
818
  };
803
819
  /**
804
820
  * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
821
+ * Example Playground https://playground.babylonjs.com/#R1F8YU#66
805
822
  * @returns a new Quaternion object, computed from the Vector3 coordinates
806
823
  */
807
824
  Vector3.prototype.toQuaternion = function () {
@@ -809,6 +826,7 @@ var Vector3 = /** @class */ (function () {
809
826
  };
810
827
  /**
811
828
  * Adds the given vector to the current Vector3
829
+ * Example Playground https://playground.babylonjs.com/#R1F8YU#4
812
830
  * @param otherVector defines the second operand
813
831
  * @returns the current updated Vector3
814
832
  */
@@ -817,6 +835,7 @@ var Vector3 = /** @class */ (function () {
817
835
  };
818
836
  /**
819
837
  * Adds the given coordinates to the current Vector3
838
+ * Example Playground https://playground.babylonjs.com/#R1F8YU#5
820
839
  * @param x defines the x coordinate of the operand
821
840
  * @param y defines the y coordinate of the operand
822
841
  * @param z defines the z coordinate of the operand
@@ -830,6 +849,7 @@ var Vector3 = /** @class */ (function () {
830
849
  };
831
850
  /**
832
851
  * Gets a new Vector3, result of the addition the current Vector3 and the given vector
852
+ * Example Playground https://playground.babylonjs.com/#R1F8YU#3
833
853
  * @param otherVector defines the second operand
834
854
  * @returns the resulting Vector3
835
855
  */
@@ -838,6 +858,7 @@ var Vector3 = /** @class */ (function () {
838
858
  };
839
859
  /**
840
860
  * Adds the current Vector3 to the given one and stores the result in the vector "result"
861
+ * Example Playground https://playground.babylonjs.com/#R1F8YU#6
841
862
  * @param otherVector defines the second operand
842
863
  * @param result defines the Vector3 object where to store the result
843
864
  * @returns the current Vector3
@@ -847,6 +868,7 @@ var Vector3 = /** @class */ (function () {
847
868
  };
848
869
  /**
849
870
  * Subtract the given vector from the current Vector3
871
+ * Example Playground https://playground.babylonjs.com/#R1F8YU#61
850
872
  * @param otherVector defines the second operand
851
873
  * @returns the current updated Vector3
852
874
  */
@@ -858,6 +880,7 @@ var Vector3 = /** @class */ (function () {
858
880
  };
859
881
  /**
860
882
  * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
883
+ * Example Playground https://playground.babylonjs.com/#R1F8YU#60
861
884
  * @param otherVector defines the second operand
862
885
  * @returns the resulting Vector3
863
886
  */
@@ -866,6 +889,7 @@ var Vector3 = /** @class */ (function () {
866
889
  };
867
890
  /**
868
891
  * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
892
+ * Example Playground https://playground.babylonjs.com/#R1F8YU#63
869
893
  * @param otherVector defines the second operand
870
894
  * @param result defines the Vector3 object where to store the result
871
895
  * @returns the current Vector3
@@ -875,6 +899,7 @@ var Vector3 = /** @class */ (function () {
875
899
  };
876
900
  /**
877
901
  * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
902
+ * Example Playground https://playground.babylonjs.com/#R1F8YU#62
878
903
  * @param x defines the x coordinate of the operand
879
904
  * @param y defines the y coordinate of the operand
880
905
  * @param z defines the z coordinate of the operand
@@ -885,6 +910,7 @@ var Vector3 = /** @class */ (function () {
885
910
  };
886
911
  /**
887
912
  * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
913
+ * Example Playground https://playground.babylonjs.com/#R1F8YU#64
888
914
  * @param x defines the x coordinate of the operand
889
915
  * @param y defines the y coordinate of the operand
890
916
  * @param z defines the z coordinate of the operand
@@ -896,6 +922,7 @@ var Vector3 = /** @class */ (function () {
896
922
  };
897
923
  /**
898
924
  * Gets a new Vector3 set with the current Vector3 negated coordinates
925
+ * Example Playground https://playground.babylonjs.com/#R1F8YU#35
899
926
  * @returns a new Vector3
900
927
  */
901
928
  Vector3.prototype.negate = function () {
@@ -903,6 +930,7 @@ var Vector3 = /** @class */ (function () {
903
930
  };
904
931
  /**
905
932
  * Negate this vector in place
933
+ * Example Playground https://playground.babylonjs.com/#R1F8YU#36
906
934
  * @returns this
907
935
  */
908
936
  Vector3.prototype.negateInPlace = function () {
@@ -913,6 +941,7 @@ var Vector3 = /** @class */ (function () {
913
941
  };
914
942
  /**
915
943
  * Negate the current Vector3 and stores the result in the given vector "result" coordinates
944
+ * Example Playground https://playground.babylonjs.com/#R1F8YU#37
916
945
  * @param result defines the Vector3 object where to store the result
917
946
  * @returns the current Vector3
918
947
  */
@@ -921,6 +950,7 @@ var Vector3 = /** @class */ (function () {
921
950
  };
922
951
  /**
923
952
  * Multiplies the Vector3 coordinates by the float "scale"
953
+ * Example Playground https://playground.babylonjs.com/#R1F8YU#56
924
954
  * @param scale defines the multiplier factor
925
955
  * @returns the current updated Vector3
926
956
  */
@@ -932,6 +962,7 @@ var Vector3 = /** @class */ (function () {
932
962
  };
933
963
  /**
934
964
  * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
965
+ * Example Playground https://playground.babylonjs.com/#R1F8YU#53
935
966
  * @param scale defines the multiplier factor
936
967
  * @returns a new Vector3
937
968
  */
@@ -940,6 +971,7 @@ var Vector3 = /** @class */ (function () {
940
971
  };
941
972
  /**
942
973
  * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
974
+ * Example Playground https://playground.babylonjs.com/#R1F8YU#57
943
975
  * @param scale defines the multiplier factor
944
976
  * @param result defines the Vector3 object where to store the result
945
977
  * @returns the current Vector3
@@ -949,6 +981,7 @@ var Vector3 = /** @class */ (function () {
949
981
  };
950
982
  /**
951
983
  * Rotates the vector using the given unit quaternion and stores the new vector in result
984
+ * Example Playground https://playground.babylonjs.com/#R1F8YU#9
952
985
  * @param q the unit quaternion representing the rotation
953
986
  * @param result the output vector
954
987
  * @returns the current Vector3
@@ -965,6 +998,7 @@ var Vector3 = /** @class */ (function () {
965
998
  };
966
999
  /**
967
1000
  * Rotates the vector in place using the given unit quaternion
1001
+ * Example Playground https://playground.babylonjs.com/#R1F8YU#8
968
1002
  * @param q the unit quaternion representing the rotation
969
1003
  * @returns the current updated Vector3
970
1004
  */
@@ -973,6 +1007,7 @@ var Vector3 = /** @class */ (function () {
973
1007
  };
974
1008
  /**
975
1009
  * Rotates the vector using the given unit quaternion and returns the new vector
1010
+ * Example Playground https://playground.babylonjs.com/#R1F8YU#7
976
1011
  * @param q the unit quaternion representing the rotation
977
1012
  * @returns a new Vector3
978
1013
  */
@@ -981,6 +1016,7 @@ var Vector3 = /** @class */ (function () {
981
1016
  };
982
1017
  /**
983
1018
  * Scale the current Vector3 values by a factor and add the result to a given Vector3
1019
+ * Example Playground https://playground.babylonjs.com/#R1F8YU#55
984
1020
  * @param scale defines the scale factor
985
1021
  * @param result defines the Vector3 object where to store the result
986
1022
  * @returns the unmodified current Vector3
@@ -989,7 +1025,8 @@ var Vector3 = /** @class */ (function () {
989
1025
  return result.addInPlaceFromFloats(this._x * scale, this._y * scale, this._z * scale);
990
1026
  };
991
1027
  /**
992
- * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
1028
+ * Projects the current point Vector3 to a plane along a ray starting from a specified origin and passing through the current point Vector3.
1029
+ * Example Playground https://playground.babylonjs.com/#R1F8YU#48
993
1030
  * @param plane defines the plane to project to
994
1031
  * @param origin defines the origin of the projection ray
995
1032
  * @returns the projected vector3
@@ -1000,44 +1037,34 @@ var Vector3 = /** @class */ (function () {
1000
1037
  return result;
1001
1038
  };
1002
1039
  /**
1003
- * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
1040
+ * Projects the current point Vector3 to a plane along a ray starting from a specified origin and passing through the current point Vector3.
1041
+ * Example Playground https://playground.babylonjs.com/#R1F8YU#49
1004
1042
  * @param plane defines the plane to project to
1005
1043
  * @param origin defines the origin of the projection ray
1006
1044
  * @param result defines the Vector3 where to store the result
1007
1045
  */
1008
1046
  Vector3.prototype.projectOnPlaneToRef = function (plane, origin, result) {
1009
- // Use the normal scaled to the plane offset as the origin for the formula
1010
- var planeOrigin = MathTmp.Vector3[0];
1011
- plane.normal.scaleToRef(-plane.d, planeOrigin);
1012
- // Since the normal in Babylon should point toward the viewer, invert it for the dot product
1013
- var inverseNormal = MathTmp.Vector3[1];
1014
- plane.normal.negateToRef(inverseNormal);
1015
- // This vector is the direction
1016
- var _a = this, x = _a.x, y = _a.y, z = _a.z;
1017
- // Calculate how close the direction is to the normal of the plane
1018
- var dotProduct = Vector3.Dot(inverseNormal, this);
1019
- /*
1020
- * Early out in case the direction will never hit the plane.
1021
- *
1022
- * Epsilon is used to avoid issues with rays very near to parallel with the
1023
- * plane, and squared because as of writing the value is not sufficiently
1024
- * small for this use case.
1025
- */
1026
- if (dotProduct <= Epsilon * Epsilon) {
1027
- // No good option for setting the result vector here, so just take the origin of the ray
1028
- result.copyFrom(origin);
1029
- return;
1047
+ var n = plane.normal;
1048
+ var d = plane.d;
1049
+ var V = MathTmp.Vector3[0];
1050
+ // ray direction
1051
+ this.subtractToRef(origin, V);
1052
+ V.normalize();
1053
+ var denom = Vector3.Dot(V, n);
1054
+ //When the ray is close to parallel to the plane return infinity vector
1055
+ if (Math.abs(denom) < Math.pow(10, -10)) {
1056
+ result.setAll(Infinity);
1057
+ }
1058
+ else {
1059
+ var t = -(Vector3.Dot(origin, n) + d) / denom;
1060
+ // P = P0 + t*V
1061
+ var scaledV = V.scaleInPlace(t);
1062
+ origin.addToRef(scaledV, result);
1030
1063
  }
1031
- // Calculate the offset
1032
- var relativeOrigin = MathTmp.Vector3[2];
1033
- planeOrigin.subtractToRef(origin, relativeOrigin);
1034
- // Calculate the length along the direction vector to the hit point
1035
- var hitDistance = Vector3.Dot(relativeOrigin, inverseNormal) / dotProduct;
1036
- // Apply the hit point by adding the direction scaled by the distance to the origin
1037
- result.set(origin.x + x * hitDistance, origin.y + y * hitDistance, origin.z + z * hitDistance);
1038
1064
  };
1039
1065
  /**
1040
1066
  * Returns true if the current Vector3 and the given vector coordinates are strictly equal
1067
+ * Example Playground https://playground.babylonjs.com/#R1F8YU#19
1041
1068
  * @param otherVector defines the second operand
1042
1069
  * @returns true if both vectors are equals
1043
1070
  */
@@ -1046,6 +1073,7 @@ var Vector3 = /** @class */ (function () {
1046
1073
  };
1047
1074
  /**
1048
1075
  * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
1076
+ * Example Playground https://playground.babylonjs.com/#R1F8YU#21
1049
1077
  * @param otherVector defines the second operand
1050
1078
  * @param epsilon defines the minimal distance to define values as equals
1051
1079
  * @returns true if both vectors are distant less than epsilon
@@ -1059,16 +1087,18 @@ var Vector3 = /** @class */ (function () {
1059
1087
  };
1060
1088
  /**
1061
1089
  * Returns true if the current Vector3 coordinates equals the given floats
1090
+ * Example Playground https://playground.babylonjs.com/#R1F8YU#20
1062
1091
  * @param x defines the x coordinate of the operand
1063
1092
  * @param y defines the y coordinate of the operand
1064
1093
  * @param z defines the z coordinate of the operand
1065
- * @returns true if both vectors are equals
1094
+ * @returns true if both vectors are equal
1066
1095
  */
1067
1096
  Vector3.prototype.equalsToFloats = function (x, y, z) {
1068
1097
  return this._x === x && this._y === y && this._z === z;
1069
1098
  };
1070
1099
  /**
1071
1100
  * Multiplies the current Vector3 coordinates by the given ones
1101
+ * Example Playground https://playground.babylonjs.com/#R1F8YU#32
1072
1102
  * @param otherVector defines the second operand
1073
1103
  * @returns the current updated Vector3
1074
1104
  */
@@ -1080,6 +1110,7 @@ var Vector3 = /** @class */ (function () {
1080
1110
  };
1081
1111
  /**
1082
1112
  * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
1113
+ * Example Playground https://playground.babylonjs.com/#R1F8YU#31
1083
1114
  * @param otherVector defines the second operand
1084
1115
  * @returns the new Vector3
1085
1116
  */
@@ -1088,6 +1119,7 @@ var Vector3 = /** @class */ (function () {
1088
1119
  };
1089
1120
  /**
1090
1121
  * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
1122
+ * Example Playground https://playground.babylonjs.com/#R1F8YU#33
1091
1123
  * @param otherVector defines the second operand
1092
1124
  * @param result defines the Vector3 object where to store the result
1093
1125
  * @returns the current Vector3
@@ -1097,6 +1129,7 @@ var Vector3 = /** @class */ (function () {
1097
1129
  };
1098
1130
  /**
1099
1131
  * Returns a new Vector3 set with the result of the multiplication of the current Vector3 coordinates by the given floats
1132
+ * Example Playground https://playground.babylonjs.com/#R1F8YU#34
1100
1133
  * @param x defines the x coordinate of the operand
1101
1134
  * @param y defines the y coordinate of the operand
1102
1135
  * @param z defines the z coordinate of the operand
@@ -1107,6 +1140,7 @@ var Vector3 = /** @class */ (function () {
1107
1140
  };
1108
1141
  /**
1109
1142
  * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
1143
+ * Example Playground https://playground.babylonjs.com/#R1F8YU#16
1110
1144
  * @param otherVector defines the second operand
1111
1145
  * @returns the new Vector3
1112
1146
  */
@@ -1115,6 +1149,7 @@ var Vector3 = /** @class */ (function () {
1115
1149
  };
1116
1150
  /**
1117
1151
  * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
1152
+ * Example Playground https://playground.babylonjs.com/#R1F8YU#18
1118
1153
  * @param otherVector defines the second operand
1119
1154
  * @param result defines the Vector3 object where to store the result
1120
1155
  * @returns the current Vector3
@@ -1124,6 +1159,7 @@ var Vector3 = /** @class */ (function () {
1124
1159
  };
1125
1160
  /**
1126
1161
  * Divides the current Vector3 coordinates by the given ones.
1162
+ * Example Playground https://playground.babylonjs.com/#R1F8YU#17
1127
1163
  * @param otherVector defines the second operand
1128
1164
  * @returns the current updated Vector3
1129
1165
  */
@@ -1132,6 +1168,7 @@ var Vector3 = /** @class */ (function () {
1132
1168
  };
1133
1169
  /**
1134
1170
  * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
1171
+ * Example Playground https://playground.babylonjs.com/#R1F8YU#29
1135
1172
  * @param other defines the second operand
1136
1173
  * @returns the current updated Vector3
1137
1174
  */
@@ -1140,6 +1177,7 @@ var Vector3 = /** @class */ (function () {
1140
1177
  };
1141
1178
  /**
1142
1179
  * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
1180
+ * Example Playground https://playground.babylonjs.com/#R1F8YU#27
1143
1181
  * @param other defines the second operand
1144
1182
  * @returns the current updated Vector3
1145
1183
  */
@@ -1148,6 +1186,7 @@ var Vector3 = /** @class */ (function () {
1148
1186
  };
1149
1187
  /**
1150
1188
  * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
1189
+ * Example Playground https://playground.babylonjs.com/#R1F8YU#30
1151
1190
  * @param x defines the x coordinate of the operand
1152
1191
  * @param y defines the y coordinate of the operand
1153
1192
  * @param z defines the z coordinate of the operand
@@ -1167,6 +1206,7 @@ var Vector3 = /** @class */ (function () {
1167
1206
  };
1168
1207
  /**
1169
1208
  * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
1209
+ * Example Playground https://playground.babylonjs.com/#R1F8YU#28
1170
1210
  * @param x defines the x coordinate of the operand
1171
1211
  * @param y defines the y coordinate of the operand
1172
1212
  * @param z defines the z coordinate of the operand
@@ -1226,13 +1266,15 @@ var Vector3 = /** @class */ (function () {
1226
1266
  });
1227
1267
  /**
1228
1268
  * Gets a new Vector3 from current Vector3 floored values
1269
+ * Example Playground https://playground.babylonjs.com/#R1F8YU#22
1229
1270
  * @returns a new Vector3
1230
1271
  */
1231
1272
  Vector3.prototype.floor = function () {
1232
1273
  return new Vector3(Math.floor(this._x), Math.floor(this._y), Math.floor(this._z));
1233
1274
  };
1234
1275
  /**
1235
- * Gets a new Vector3 from current Vector3 floored values
1276
+ * Gets a new Vector3 from current Vector3 fractional values
1277
+ * Example Playground https://playground.babylonjs.com/#R1F8YU#23
1236
1278
  * @returns a new Vector3
1237
1279
  */
1238
1280
  Vector3.prototype.fract = function () {
@@ -1241,6 +1283,7 @@ var Vector3 = /** @class */ (function () {
1241
1283
  // Properties
1242
1284
  /**
1243
1285
  * Gets the length of the Vector3
1286
+ * Example Playground https://playground.babylonjs.com/#R1F8YU#25
1244
1287
  * @returns the length of the Vector3
1245
1288
  */
1246
1289
  Vector3.prototype.length = function () {
@@ -1248,6 +1291,7 @@ var Vector3 = /** @class */ (function () {
1248
1291
  };
1249
1292
  /**
1250
1293
  * Gets the squared length of the Vector3
1294
+ * Example Playground https://playground.babylonjs.com/#R1F8YU#26
1251
1295
  * @returns squared length of the Vector3
1252
1296
  */
1253
1297
  Vector3.prototype.lengthSquared = function () {
@@ -1256,6 +1300,7 @@ var Vector3 = /** @class */ (function () {
1256
1300
  Object.defineProperty(Vector3.prototype, "hasAZeroComponent", {
1257
1301
  /**
1258
1302
  * Gets a boolean indicating if the vector contains a zero in one of its components
1303
+ * Example Playground https://playground.babylonjs.com/#R1F8YU#1
1259
1304
  */
1260
1305
  get: function () {
1261
1306
  return this._x * this._y * this._z === 0;
@@ -1266,6 +1311,7 @@ var Vector3 = /** @class */ (function () {
1266
1311
  /**
1267
1312
  * Normalize the current Vector3.
1268
1313
  * Please note that this is an in place operation.
1314
+ * Example Playground https://playground.babylonjs.com/#R1F8YU#122
1269
1315
  * @returns the current updated Vector3
1270
1316
  */
1271
1317
  Vector3.prototype.normalize = function () {
@@ -1273,6 +1319,7 @@ var Vector3 = /** @class */ (function () {
1273
1319
  };
1274
1320
  /**
1275
1321
  * Reorders the x y z properties of the vector in place
1322
+ * Example Playground https://playground.babylonjs.com/#R1F8YU#44
1276
1323
  * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
1277
1324
  * @returns the current updated vector
1278
1325
  */
@@ -1290,6 +1337,7 @@ var Vector3 = /** @class */ (function () {
1290
1337
  };
1291
1338
  /**
1292
1339
  * Rotates the vector around 0,0,0 by a quaternion
1340
+ * Example Playground https://playground.babylonjs.com/#R1F8YU#47
1293
1341
  * @param quaternion the rotation quaternion
1294
1342
  * @param result vector to store the result
1295
1343
  * @returns the resulting vector
@@ -1301,6 +1349,7 @@ var Vector3 = /** @class */ (function () {
1301
1349
  };
1302
1350
  /**
1303
1351
  * Rotates a vector around a given point
1352
+ * Example Playground https://playground.babylonjs.com/#R1F8YU#46
1304
1353
  * @param quaternion the rotation quaternion
1305
1354
  * @param point the point to rotate around
1306
1355
  * @param result vector to store the result
@@ -1315,6 +1364,7 @@ var Vector3 = /** @class */ (function () {
1315
1364
  /**
1316
1365
  * Returns a new Vector3 as the cross product of the current vector and the "other" one
1317
1366
  * The cross product is then orthogonal to both current and "other"
1367
+ * Example Playground https://playground.babylonjs.com/#R1F8YU#14
1318
1368
  * @param other defines the right operand
1319
1369
  * @returns the cross product
1320
1370
  */
@@ -1324,6 +1374,7 @@ var Vector3 = /** @class */ (function () {
1324
1374
  /**
1325
1375
  * Normalize the current Vector3 with the given input length.
1326
1376
  * Please note that this is an in place operation.
1377
+ * Example Playground https://playground.babylonjs.com/#R1F8YU#123
1327
1378
  * @param len the length of the vector
1328
1379
  * @returns the current updated Vector3
1329
1380
  */
@@ -1335,6 +1386,7 @@ var Vector3 = /** @class */ (function () {
1335
1386
  };
1336
1387
  /**
1337
1388
  * Normalize the current Vector3 to a new vector
1389
+ * Example Playground https://playground.babylonjs.com/#R1F8YU#124
1338
1390
  * @returns the new Vector3
1339
1391
  */
1340
1392
  Vector3.prototype.normalizeToNew = function () {
@@ -1344,6 +1396,7 @@ var Vector3 = /** @class */ (function () {
1344
1396
  };
1345
1397
  /**
1346
1398
  * Normalize the current Vector3 to the reference
1399
+ * Example Playground https://playground.babylonjs.com/#R1F8YU#125
1347
1400
  * @param reference define the Vector3 to update
1348
1401
  * @returns the updated Vector3
1349
1402
  */
@@ -1356,6 +1409,7 @@ var Vector3 = /** @class */ (function () {
1356
1409
  };
1357
1410
  /**
1358
1411
  * Creates a new Vector3 copied from the current Vector3
1412
+ * Example Playground https://playground.babylonjs.com/#R1F8YU#11
1359
1413
  * @returns the new Vector3
1360
1414
  */
1361
1415
  Vector3.prototype.clone = function () {
@@ -1363,6 +1417,7 @@ var Vector3 = /** @class */ (function () {
1363
1417
  };
1364
1418
  /**
1365
1419
  * Copies the given vector coordinates to the current Vector3 ones
1420
+ * Example Playground https://playground.babylonjs.com/#R1F8YU#12
1366
1421
  * @param source defines the source Vector3
1367
1422
  * @returns the current updated Vector3
1368
1423
  */
@@ -1371,6 +1426,7 @@ var Vector3 = /** @class */ (function () {
1371
1426
  };
1372
1427
  /**
1373
1428
  * Copies the given floats to the current Vector3 coordinates
1429
+ * Example Playground https://playground.babylonjs.com/#R1F8YU#13
1374
1430
  * @param x defines the x coordinate of the operand
1375
1431
  * @param y defines the y coordinate of the operand
1376
1432
  * @param z defines the z coordinate of the operand
@@ -1384,6 +1440,7 @@ var Vector3 = /** @class */ (function () {
1384
1440
  };
1385
1441
  /**
1386
1442
  * Copies the given floats to the current Vector3 coordinates
1443
+ * Example Playground https://playground.babylonjs.com/#R1F8YU#58
1387
1444
  * @param x defines the x coordinate of the operand
1388
1445
  * @param y defines the y coordinate of the operand
1389
1446
  * @param z defines the z coordinate of the operand
@@ -1394,6 +1451,7 @@ var Vector3 = /** @class */ (function () {
1394
1451
  };
1395
1452
  /**
1396
1453
  * Copies the given float to the current Vector3 coordinates
1454
+ * Example Playground https://playground.babylonjs.com/#R1F8YU#59
1397
1455
  * @param v defines the x, y and z coordinates of the operand
1398
1456
  * @returns the current updated Vector3
1399
1457
  */
@@ -1404,6 +1462,7 @@ var Vector3 = /** @class */ (function () {
1404
1462
  // Statics
1405
1463
  /**
1406
1464
  * Get the clip factor between two vectors
1465
+ * Example Playground https://playground.babylonjs.com/#R1F8YU#126
1407
1466
  * @param vector0 defines the first operand
1408
1467
  * @param vector1 defines the second operand
1409
1468
  * @param axis defines the axis to use
@@ -1418,6 +1477,7 @@ var Vector3 = /** @class */ (function () {
1418
1477
  };
1419
1478
  /**
1420
1479
  * Get angle between two vectors
1480
+ * Example Playground https://playground.babylonjs.com/#R1F8YU#86
1421
1481
  * @param vector0 angle between vector0 and vector1
1422
1482
  * @param vector1 angle between vector0 and vector1
1423
1483
  * @param normal direction of the normal
@@ -1439,6 +1499,7 @@ var Vector3 = /** @class */ (function () {
1439
1499
  };
1440
1500
  /**
1441
1501
  * Get angle between two vectors projected on a plane
1502
+ * Example Playground https://playground.babylonjs.com/#R1F8YU#87
1442
1503
  * @param vector0 angle between vector0 and vector1
1443
1504
  * @param vector1 angle between vector0 and vector1
1444
1505
  * @param normal Normal of the projection plane
@@ -1463,6 +1524,10 @@ var Vector3 = /** @class */ (function () {
1463
1524
  };
1464
1525
  /**
1465
1526
  * Slerp between two vectors. See also `SmoothToRef`
1527
+ * Slerp is a spherical linear interpolation
1528
+ * giving a slow in and out effect
1529
+ * Example Playground 1 https://playground.babylonjs.com/#R1F8YU#108
1530
+ * Example Playground 2 https://playground.babylonjs.com/#R1F8YU#109
1466
1531
  * @param vector0 Start vector
1467
1532
  * @param vector1 End vector
1468
1533
  * @param slerp amount (will be clamped between 0 and 1)
@@ -1499,6 +1564,7 @@ var Vector3 = /** @class */ (function () {
1499
1564
  };
1500
1565
  /**
1501
1566
  * Smooth interpolation between two vectors using Slerp
1567
+ * Example Playground https://playground.babylonjs.com/#R1F8YU#110
1502
1568
  * @param source source vector
1503
1569
  * @param goal goal vector
1504
1570
  * @param deltaTime current interpolation frame
@@ -1510,6 +1576,7 @@ var Vector3 = /** @class */ (function () {
1510
1576
  };
1511
1577
  /**
1512
1578
  * Returns a new Vector3 set from the index "offset" of the given array
1579
+ * Example Playground https://playground.babylonjs.com/#R1F8YU#83
1513
1580
  * @param array defines the source array
1514
1581
  * @param offset defines the offset in the source array
1515
1582
  * @returns the new Vector3
@@ -1530,6 +1597,7 @@ var Vector3 = /** @class */ (function () {
1530
1597
  };
1531
1598
  /**
1532
1599
  * Sets the given vector "result" with the element values from the index "offset" of the given array
1600
+ * Example Playground https://playground.babylonjs.com/#R1F8YU#84
1533
1601
  * @param array defines the source array
1534
1602
  * @param offset defines the offset in the source array
1535
1603
  * @param result defines the Vector3 where to store the result
@@ -1551,6 +1619,7 @@ var Vector3 = /** @class */ (function () {
1551
1619
  };
1552
1620
  /**
1553
1621
  * Sets the given vector "result" with the given floats.
1622
+ * Example Playground https://playground.babylonjs.com/#R1F8YU#85
1554
1623
  * @param x defines the x coordinate of the source
1555
1624
  * @param y defines the y coordinate of the source
1556
1625
  * @param z defines the z coordinate of the source
@@ -1568,13 +1637,14 @@ var Vector3 = /** @class */ (function () {
1568
1637
  };
1569
1638
  /**
1570
1639
  * Returns a new Vector3 set to (1.0, 1.0, 1.0)
1571
- * @returns a new unit Vector3
1640
+ * @returns a new Vector3
1572
1641
  */
1573
1642
  Vector3.One = function () {
1574
1643
  return new Vector3(1.0, 1.0, 1.0);
1575
1644
  };
1576
1645
  /**
1577
1646
  * Returns a new Vector3 set to (0.0, 1.0, 0.0)
1647
+ * Example Playground https://playground.babylonjs.com/#R1F8YU#71
1578
1648
  * @returns a new up Vector3
1579
1649
  */
1580
1650
  Vector3.Up = function () {
@@ -1582,7 +1652,7 @@ var Vector3 = /** @class */ (function () {
1582
1652
  };
1583
1653
  Object.defineProperty(Vector3, "UpReadOnly", {
1584
1654
  /**
1585
- * Gets a up Vector3 that must not be updated
1655
+ * Gets an up Vector3 that must not be updated
1586
1656
  */
1587
1657
  get: function () {
1588
1658
  return Vector3._UpReadOnly;
@@ -1590,6 +1660,16 @@ var Vector3 = /** @class */ (function () {
1590
1660
  enumerable: false,
1591
1661
  configurable: true
1592
1662
  });
1663
+ Object.defineProperty(Vector3, "DownReadOnly", {
1664
+ /**
1665
+ * Gets a down Vector3 that must not be updated
1666
+ */
1667
+ get: function () {
1668
+ return Vector3._DownReadOnly;
1669
+ },
1670
+ enumerable: false,
1671
+ configurable: true
1672
+ });
1593
1673
  Object.defineProperty(Vector3, "RightReadOnly", {
1594
1674
  /**
1595
1675
  * Gets a right Vector3 that must not be updated
@@ -1642,6 +1722,7 @@ var Vector3 = /** @class */ (function () {
1642
1722
  });
1643
1723
  /**
1644
1724
  * Returns a new Vector3 set to (0.0, -1.0, 0.0)
1725
+ * Example Playground https://playground.babylonjs.com/#R1F8YU#71
1645
1726
  * @returns a new down Vector3
1646
1727
  */
1647
1728
  Vector3.Down = function () {
@@ -1649,6 +1730,7 @@ var Vector3 = /** @class */ (function () {
1649
1730
  };
1650
1731
  /**
1651
1732
  * Returns a new Vector3 set to (0.0, 0.0, 1.0)
1733
+ * Example Playground https://playground.babylonjs.com/#R1F8YU#71
1652
1734
  * @param rightHandedSystem is the scene right-handed (negative z)
1653
1735
  * @returns a new forward Vector3
1654
1736
  */
@@ -1658,8 +1740,9 @@ var Vector3 = /** @class */ (function () {
1658
1740
  };
1659
1741
  /**
1660
1742
  * Returns a new Vector3 set to (0.0, 0.0, -1.0)
1743
+ * Example Playground https://playground.babylonjs.com/#R1F8YU#71
1661
1744
  * @param rightHandedSystem is the scene right-handed (negative-z)
1662
- * @returns a new forward Vector3
1745
+ * @returns a new Backward Vector3
1663
1746
  */
1664
1747
  Vector3.Backward = function (rightHandedSystem) {
1665
1748
  if (rightHandedSystem === void 0) { rightHandedSystem = false; }
@@ -1667,6 +1750,7 @@ var Vector3 = /** @class */ (function () {
1667
1750
  };
1668
1751
  /**
1669
1752
  * Returns a new Vector3 set to (1.0, 0.0, 0.0)
1753
+ * Example Playground https://playground.babylonjs.com/#R1F8YU#71
1670
1754
  * @returns a new right Vector3
1671
1755
  */
1672
1756
  Vector3.Right = function () {
@@ -1674,6 +1758,7 @@ var Vector3 = /** @class */ (function () {
1674
1758
  };
1675
1759
  /**
1676
1760
  * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
1761
+ * Example Playground https://playground.babylonjs.com/#R1F8YU#71
1677
1762
  * @returns a new left Vector3
1678
1763
  */
1679
1764
  Vector3.Left = function () {
@@ -1682,6 +1767,7 @@ var Vector3 = /** @class */ (function () {
1682
1767
  /**
1683
1768
  * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
1684
1769
  * This method computes transformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
1770
+ * Example Playground https://playground.babylonjs.com/#R1F8YU#111
1685
1771
  * @param vector defines the Vector3 to transform
1686
1772
  * @param transformation defines the transformation matrix
1687
1773
  * @returns the transformed Vector3
@@ -1694,6 +1780,7 @@ var Vector3 = /** @class */ (function () {
1694
1780
  /**
1695
1781
  * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
1696
1782
  * This method computes transformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
1783
+ * Example Playground https://playground.babylonjs.com/#R1F8YU#113
1697
1784
  * @param vector defines the Vector3 to transform
1698
1785
  * @param transformation defines the transformation matrix
1699
1786
  * @param result defines the Vector3 where to store the result
@@ -1704,6 +1791,7 @@ var Vector3 = /** @class */ (function () {
1704
1791
  /**
1705
1792
  * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
1706
1793
  * This method computes transformed coordinates only, not transformed direction vectors
1794
+ * Example Playground https://playground.babylonjs.com/#R1F8YU#115
1707
1795
  * @param x define the x coordinate of the source vector
1708
1796
  * @param y define the y coordinate of the source vector
1709
1797
  * @param z define the z coordinate of the source vector
@@ -1723,6 +1811,7 @@ var Vector3 = /** @class */ (function () {
1723
1811
  /**
1724
1812
  * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
1725
1813
  * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
1814
+ * Example Playground https://playground.babylonjs.com/#R1F8YU#112
1726
1815
  * @param vector defines the Vector3 to transform
1727
1816
  * @param transformation defines the transformation matrix
1728
1817
  * @returns the new Vector3
@@ -1735,6 +1824,7 @@ var Vector3 = /** @class */ (function () {
1735
1824
  /**
1736
1825
  * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
1737
1826
  * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
1827
+ * Example Playground https://playground.babylonjs.com/#R1F8YU#114
1738
1828
  * @param vector defines the Vector3 to transform
1739
1829
  * @param transformation defines the transformation matrix
1740
1830
  * @param result defines the Vector3 where to store the result
@@ -1745,6 +1835,7 @@ var Vector3 = /** @class */ (function () {
1745
1835
  /**
1746
1836
  * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
1747
1837
  * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
1838
+ * Example Playground https://playground.babylonjs.com/#R1F8YU#116
1748
1839
  * @param x define the x coordinate of the source vector
1749
1840
  * @param y define the y coordinate of the source vector
1750
1841
  * @param z define the z coordinate of the source vector
@@ -1759,6 +1850,7 @@ var Vector3 = /** @class */ (function () {
1759
1850
  };
1760
1851
  /**
1761
1852
  * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
1853
+ * Example Playground https://playground.babylonjs.com/#R1F8YU#69
1762
1854
  * @param value1 defines the first control point
1763
1855
  * @param value2 defines the second control point
1764
1856
  * @param value3 defines the third control point
@@ -1790,6 +1882,7 @@ var Vector3 = /** @class */ (function () {
1790
1882
  * Returns a new Vector3 set with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
1791
1883
  * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
1792
1884
  * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
1885
+ * Example Playground https://playground.babylonjs.com/#R1F8YU#76
1793
1886
  * @param value defines the current value
1794
1887
  * @param min defines the lower range value
1795
1888
  * @param max defines the upper range value
@@ -1804,6 +1897,7 @@ var Vector3 = /** @class */ (function () {
1804
1897
  * Sets the given vector "result" with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
1805
1898
  * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
1806
1899
  * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
1900
+ * Example Playground https://playground.babylonjs.com/#R1F8YU#77
1807
1901
  * @param value defines the current value
1808
1902
  * @param min defines the lower range value
1809
1903
  * @param max defines the upper range value
@@ -1823,6 +1917,7 @@ var Vector3 = /** @class */ (function () {
1823
1917
  };
1824
1918
  /**
1825
1919
  * Checks if a given vector is inside a specific range
1920
+ * Example Playground https://playground.babylonjs.com/#R1F8YU#75
1826
1921
  * @param v defines the vector to test
1827
1922
  * @param min defines the minimum range
1828
1923
  * @param max defines the maximum range
@@ -1833,6 +1928,7 @@ var Vector3 = /** @class */ (function () {
1833
1928
  };
1834
1929
  /**
1835
1930
  * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
1931
+ * Example Playground https://playground.babylonjs.com/#R1F8YU#89
1836
1932
  * @param value1 defines the first control point
1837
1933
  * @param tangent1 defines the first tangent vector
1838
1934
  * @param value2 defines the second control point
@@ -1854,6 +1950,7 @@ var Vector3 = /** @class */ (function () {
1854
1950
  };
1855
1951
  /**
1856
1952
  * Returns a new Vector3 which is the 1st derivative of the Hermite spline defined by the vectors "value1", "value2", "tangent1", "tangent2".
1953
+ * Example Playground https://playground.babylonjs.com/#R1F8YU#90
1857
1954
  * @param value1 defines the first control point
1858
1955
  * @param tangent1 defines the first tangent
1859
1956
  * @param value2 defines the second control point
@@ -1868,6 +1965,7 @@ var Vector3 = /** @class */ (function () {
1868
1965
  };
1869
1966
  /**
1870
1967
  * Update a Vector3 with the 1st derivative of the Hermite spline defined by the vectors "value1", "value2", "tangent1", "tangent2".
1968
+ * Example Playground https://playground.babylonjs.com/#R1F8YU#91
1871
1969
  * @param value1 defines the first control point
1872
1970
  * @param tangent1 defines the first tangent
1873
1971
  * @param value2 defines the second control point
@@ -1883,6 +1981,7 @@ var Vector3 = /** @class */ (function () {
1883
1981
  };
1884
1982
  /**
1885
1983
  * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
1984
+ * Example Playground https://playground.babylonjs.com/#R1F8YU#95
1886
1985
  * @param start defines the start value
1887
1986
  * @param end defines the end value
1888
1987
  * @param amount max defines amount between both (between 0 and 1)
@@ -1895,6 +1994,7 @@ var Vector3 = /** @class */ (function () {
1895
1994
  };
1896
1995
  /**
1897
1996
  * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
1997
+ * Example Playground https://playground.babylonjs.com/#R1F8YU#93
1898
1998
  * @param start defines the start value
1899
1999
  * @param end defines the end value
1900
2000
  * @param amount max defines amount between both (between 0 and 1)
@@ -1907,6 +2007,7 @@ var Vector3 = /** @class */ (function () {
1907
2007
  };
1908
2008
  /**
1909
2009
  * Returns the dot product (float) between the vectors "left" and "right"
2010
+ * Example Playground https://playground.babylonjs.com/#R1F8YU#82
1910
2011
  * @param left defines the left operand
1911
2012
  * @param right defines the right operand
1912
2013
  * @returns the dot product
@@ -1917,6 +2018,7 @@ var Vector3 = /** @class */ (function () {
1917
2018
  /**
1918
2019
  * Returns a new Vector3 as the cross product of the vectors "left" and "right"
1919
2020
  * The cross product is then orthogonal to both "left" and "right"
2021
+ * Example Playground https://playground.babylonjs.com/#R1F8YU#15
1920
2022
  * @param left defines the left operand
1921
2023
  * @param right defines the right operand
1922
2024
  * @returns the cross product
@@ -1929,6 +2031,7 @@ var Vector3 = /** @class */ (function () {
1929
2031
  /**
1930
2032
  * Sets the given vector "result" with the cross product of "left" and "right"
1931
2033
  * The cross product is then orthogonal to both "left" and "right"
2034
+ * Example Playground https://playground.babylonjs.com/#R1F8YU#78
1932
2035
  * @param left defines the left operand
1933
2036
  * @param right defines the right operand
1934
2037
  * @param result defines the Vector3 where to store the result
@@ -1941,6 +2044,7 @@ var Vector3 = /** @class */ (function () {
1941
2044
  };
1942
2045
  /**
1943
2046
  * Returns a new Vector3 as the normalization of the given vector
2047
+ * Example Playground https://playground.babylonjs.com/#R1F8YU#98
1944
2048
  * @param vector defines the Vector3 to normalize
1945
2049
  * @returns the new Vector3
1946
2050
  */
@@ -1951,6 +2055,7 @@ var Vector3 = /** @class */ (function () {
1951
2055
  };
1952
2056
  /**
1953
2057
  * Sets the given vector "result" with the normalization of the given first vector
2058
+ * Example Playground https://playground.babylonjs.com/#R1F8YU#98
1954
2059
  * @param vector defines the Vector3 to normalize
1955
2060
  * @param result defines the Vector3 where to store the result
1956
2061
  */
@@ -1959,6 +2064,7 @@ var Vector3 = /** @class */ (function () {
1959
2064
  };
1960
2065
  /**
1961
2066
  * Project a Vector3 onto screen space
2067
+ * Example Playground https://playground.babylonjs.com/#R1F8YU#101
1962
2068
  * @param vector defines the Vector3 to project
1963
2069
  * @param world defines the world matrix to use
1964
2070
  * @param transform defines the transform (view x projection) matrix to use
@@ -1972,6 +2078,7 @@ var Vector3 = /** @class */ (function () {
1972
2078
  };
1973
2079
  /**
1974
2080
  * Project a Vector3 onto screen space to reference
2081
+ * Example Playground https://playground.babylonjs.com/#R1F8YU#102
1975
2082
  * @param vector defines the Vector3 to project
1976
2083
  * @param world defines the world matrix to use
1977
2084
  * @param transform defines the transform (view x projection) matrix to use
@@ -2008,6 +2115,7 @@ var Vector3 = /** @class */ (function () {
2008
2115
  };
2009
2116
  /**
2010
2117
  * Unproject from screen space to object space
2118
+ * Example Playground https://playground.babylonjs.com/#R1F8YU#121
2011
2119
  * @param source defines the screen space Vector3 to use
2012
2120
  * @param viewportWidth defines the current width of the viewport
2013
2121
  * @param viewportHeight defines the current height of the viewport
@@ -2020,6 +2128,7 @@ var Vector3 = /** @class */ (function () {
2020
2128
  };
2021
2129
  /**
2022
2130
  * Unproject from screen space to object space
2131
+ * Example Playground https://playground.babylonjs.com/#R1F8YU#117
2023
2132
  * @param source defines the screen space Vector3 to use
2024
2133
  * @param viewportWidth defines the current width of the viewport
2025
2134
  * @param viewportHeight defines the current height of the viewport
@@ -2035,6 +2144,7 @@ var Vector3 = /** @class */ (function () {
2035
2144
  };
2036
2145
  /**
2037
2146
  * Unproject from screen space to object space
2147
+ * Example Playground https://playground.babylonjs.com/#R1F8YU#119
2038
2148
  * @param source defines the screen space Vector3 to use
2039
2149
  * @param viewportWidth defines the current width of the viewport
2040
2150
  * @param viewportHeight defines the current height of the viewport
@@ -2048,6 +2158,7 @@ var Vector3 = /** @class */ (function () {
2048
2158
  };
2049
2159
  /**
2050
2160
  * Unproject from screen space to object space
2161
+ * Example Playground https://playground.babylonjs.com/#R1F8YU#120
2051
2162
  * @param sourceX defines the screen space x coordinate to use
2052
2163
  * @param sourceY defines the screen space y coordinate to use
2053
2164
  * @param sourceZ defines the screen space z coordinate to use
@@ -2077,6 +2188,7 @@ var Vector3 = /** @class */ (function () {
2077
2188
  };
2078
2189
  /**
2079
2190
  * Gets the minimal coordinate values between two Vector3
2191
+ * Example Playground https://playground.babylonjs.com/#R1F8YU#97
2080
2192
  * @param left defines the first operand
2081
2193
  * @param right defines the second operand
2082
2194
  * @returns the new Vector3
@@ -2088,6 +2200,7 @@ var Vector3 = /** @class */ (function () {
2088
2200
  };
2089
2201
  /**
2090
2202
  * Gets the maximal coordinate values between two Vector3
2203
+ * Example Playground https://playground.babylonjs.com/#R1F8YU#96
2091
2204
  * @param left defines the first operand
2092
2205
  * @param right defines the second operand
2093
2206
  * @returns the new Vector3
@@ -2099,6 +2212,7 @@ var Vector3 = /** @class */ (function () {
2099
2212
  };
2100
2213
  /**
2101
2214
  * Returns the distance between the vectors "value1" and "value2"
2215
+ * Example Playground https://playground.babylonjs.com/#R1F8YU#81
2102
2216
  * @param value1 defines the first operand
2103
2217
  * @param value2 defines the second operand
2104
2218
  * @returns the distance
@@ -2108,6 +2222,7 @@ var Vector3 = /** @class */ (function () {
2108
2222
  };
2109
2223
  /**
2110
2224
  * Returns the squared distance between the vectors "value1" and "value2"
2225
+ * Example Playground https://playground.babylonjs.com/#R1F8YU#80
2111
2226
  * @param value1 defines the first operand
2112
2227
  * @param value2 defines the second operand
2113
2228
  * @returns the squared distance
@@ -2121,6 +2236,7 @@ var Vector3 = /** @class */ (function () {
2121
2236
  /**
2122
2237
  * Projects "vector" on the triangle determined by its extremities "p0", "p1" and "p2", stores the result in "ref"
2123
2238
  * and returns the distance to the projected point.
2239
+ * Example Playground https://playground.babylonjs.com/#R1F8YU#104
2124
2240
  * From http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.104.4264&rep=rep1&type=pdf
2125
2241
  *
2126
2242
  * @param vector the vector to get distance from
@@ -2259,6 +2375,7 @@ var Vector3 = /** @class */ (function () {
2259
2375
  };
2260
2376
  /**
2261
2377
  * Returns a new Vector3 located at the center between "value1" and "value2"
2378
+ * Example Playground https://playground.babylonjs.com/#R1F8YU#72
2262
2379
  * @param value1 defines the first operand
2263
2380
  * @param value2 defines the second operand
2264
2381
  * @returns the new Vector3
@@ -2268,6 +2385,7 @@ var Vector3 = /** @class */ (function () {
2268
2385
  };
2269
2386
  /**
2270
2387
  * Gets the center of the vectors "value1" and "value2" and stores the result in the vector "ref"
2388
+ * Example Playground https://playground.babylonjs.com/#R1F8YU#73
2271
2389
  * @param value1 defines first vector
2272
2390
  * @param value2 defines second vector
2273
2391
  * @param ref defines third vector
@@ -2281,6 +2399,7 @@ var Vector3 = /** @class */ (function () {
2281
2399
  * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
2282
2400
  * to something in order to rotate it from its local system to the given target system
2283
2401
  * Note: axis1, axis2 and axis3 are normalized during this operation
2402
+ * Example Playground https://playground.babylonjs.com/#R1F8YU#106
2284
2403
  * @param axis1 defines the first axis
2285
2404
  * @param axis2 defines the second axis
2286
2405
  * @param axis3 defines the third axis
@@ -2294,6 +2413,7 @@ var Vector3 = /** @class */ (function () {
2294
2413
  };
2295
2414
  /**
2296
2415
  * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
2416
+ * Example Playground https://playground.babylonjs.com/#R1F8YU#107
2297
2417
  * @param axis1 defines the first axis
2298
2418
  * @param axis2 defines the second axis
2299
2419
  * @param axis3 defines the third axis
@@ -2305,6 +2425,7 @@ var Vector3 = /** @class */ (function () {
2305
2425
  quat.toEulerAnglesToRef(ref);
2306
2426
  };
2307
2427
  Vector3._UpReadOnly = Vector3.Up();
2428
+ Vector3._DownReadOnly = Vector3.Down();
2308
2429
  Vector3._LeftHandedForwardReadOnly = Vector3.Forward(false);
2309
2430
  Vector3._RightHandedForwardReadOnly = Vector3.Forward(true);
2310
2431
  Vector3._RightReadOnly = Vector3.Right();
@@ -2726,7 +2847,7 @@ var Vector4 = /** @class */ (function () {
2726
2847
  return new Vector4(Math.floor(this.x), Math.floor(this.y), Math.floor(this.z), Math.floor(this.w));
2727
2848
  };
2728
2849
  /**
2729
- * Gets a new Vector4 from current Vector3 floored values
2850
+ * Gets a new Vector4 from current Vector4 fractional values
2730
2851
  * @returns a new Vector4
2731
2852
  */
2732
2853
  Vector4.prototype.fract = function () {
@@ -2882,6 +3003,16 @@ var Vector4 = /** @class */ (function () {
2882
3003
  Vector4.One = function () {
2883
3004
  return new Vector4(1.0, 1.0, 1.0, 1.0);
2884
3005
  };
3006
+ Object.defineProperty(Vector4, "ZeroReadOnly", {
3007
+ /**
3008
+ * Gets a zero Vector4 that must not be updated
3009
+ */
3010
+ get: function () {
3011
+ return Vector4._ZeroReadOnly;
3012
+ },
3013
+ enumerable: false,
3014
+ configurable: true
3015
+ });
2885
3016
  /**
2886
3017
  * Returns a new normalized Vector4 from the given one.
2887
3018
  * @param vector the vector to normalize
@@ -3065,6 +3196,7 @@ var Vector4 = /** @class */ (function () {
3065
3196
  if (w === void 0) { w = 0; }
3066
3197
  return new Vector4(source._x, source._y, source._z, w);
3067
3198
  };
3199
+ Vector4._ZeroReadOnly = Vector4.Zero();
3068
3200
  return Vector4;
3069
3201
  }());
3070
3202
  export { Vector4 };