@babylonjs/core 7.27.2 → 7.27.3

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 (61) hide show
  1. package/Animations/animatable.core.d.ts +198 -0
  2. package/Animations/animatable.core.js +893 -0
  3. package/Animations/animatable.core.js.map +1 -0
  4. package/Animations/animatable.d.ts +4 -213
  5. package/Animations/animatable.js +5 -886
  6. package/Animations/animatable.js.map +1 -1
  7. package/Animations/animationGroup.d.ts +1 -1
  8. package/Animations/animationGroup.js.map +1 -1
  9. package/Animations/runtimeAnimation.d.ts +1 -0
  10. package/Animations/runtimeAnimation.js +25 -1
  11. package/Animations/runtimeAnimation.js.map +1 -1
  12. package/Audio/audioSceneComponent.d.ts +0 -4
  13. package/Audio/audioSceneComponent.js.map +1 -1
  14. package/Behaviors/Cameras/bouncingBehavior.js.map +1 -1
  15. package/Behaviors/Cameras/framingBehavior.js.map +1 -1
  16. package/Bones/skeleton.d.ts +1 -1
  17. package/Bones/skeleton.js.map +1 -1
  18. package/Culling/ray.core.d.ts +328 -0
  19. package/Culling/ray.core.js +934 -0
  20. package/Culling/ray.core.js.map +1 -0
  21. package/Culling/ray.d.ts +1 -220
  22. package/Culling/ray.js +12 -791
  23. package/Culling/ray.js.map +1 -1
  24. package/Engines/abstractEngine.js +2 -2
  25. package/Engines/abstractEngine.js.map +1 -1
  26. package/FlowGraph/Blocks/Execution/Animation/flowGraphPauseAnimationBlock.d.ts +1 -1
  27. package/FlowGraph/Blocks/Execution/Animation/flowGraphPauseAnimationBlock.js.map +1 -1
  28. package/FlowGraph/Blocks/Execution/Animation/flowGraphPlayAnimationBlock.d.ts +1 -1
  29. package/FlowGraph/Blocks/Execution/Animation/flowGraphPlayAnimationBlock.js.map +1 -1
  30. package/FlowGraph/Blocks/Execution/Animation/flowGraphStopAnimationBlock.d.ts +1 -1
  31. package/FlowGraph/Blocks/Execution/Animation/flowGraphStopAnimationBlock.js.map +1 -1
  32. package/Inputs/scene.inputManager.js +1 -1
  33. package/Inputs/scene.inputManager.js.map +1 -1
  34. package/Layers/effectLayerSceneComponent.d.ts +0 -6
  35. package/Layers/effectLayerSceneComponent.js +0 -1
  36. package/Layers/effectLayerSceneComponent.js.map +1 -1
  37. package/Layers/layerSceneComponent.d.ts +0 -9
  38. package/Layers/layerSceneComponent.js +0 -1
  39. package/Layers/layerSceneComponent.js.map +1 -1
  40. package/LensFlares/lensFlareSystemSceneComponent.d.ts +0 -5
  41. package/LensFlares/lensFlareSystemSceneComponent.js +0 -1
  42. package/LensFlares/lensFlareSystemSceneComponent.js.map +1 -1
  43. package/Lights/light.js.map +1 -1
  44. package/Materials/Textures/Procedurals/proceduralTextureSceneComponent.d.ts +0 -10
  45. package/Materials/Textures/Procedurals/proceduralTextureSceneComponent.js +0 -1
  46. package/Materials/Textures/Procedurals/proceduralTextureSceneComponent.js.map +1 -1
  47. package/Misc/assetsManager.d.ts +1 -1
  48. package/Misc/assetsManager.js.map +1 -1
  49. package/Misc/tools.js +1 -13
  50. package/Misc/tools.js.map +1 -1
  51. package/Sprites/spriteSceneComponent.d.ts +1 -1
  52. package/Sprites/spriteSceneComponent.js +4 -4
  53. package/Sprites/spriteSceneComponent.js.map +1 -1
  54. package/assetContainer.d.ts +1 -1
  55. package/assetContainer.js.map +1 -1
  56. package/node.d.ts +1 -1
  57. package/node.js.map +1 -1
  58. package/package.json +1 -1
  59. package/scene.d.ts +41 -4
  60. package/scene.js +25 -6
  61. package/scene.js.map +1 -1
@@ -0,0 +1,328 @@
1
+ import { Matrix, Vector3 } from "../Maths/math.vector.js";
2
+ import { IntersectionInfo } from "../Collisions/intersectionInfo";
3
+ import type { BoundingBox } from "./boundingBox";
4
+ import type { BoundingSphere } from "./boundingSphere";
5
+ import type { DeepImmutable, float, Nullable } from "../types.js";
6
+ import type { Plane } from "../Maths/math.plane.js";
7
+ import type { AbstractMesh } from "../Meshes/abstractMesh.js";
8
+ import { PickingInfo } from "../Collisions/pickingInfo.js";
9
+ import type { Scene } from "../scene.js";
10
+ import type { Camera } from "../Cameras/camera.js";
11
+ /**
12
+ * Type used to define predicate for selecting meshes and instances (if exist)
13
+ */
14
+ export type MeshPredicate = (mesh: AbstractMesh, thinInstanceIndex: number) => boolean;
15
+ /**
16
+ * Type used to define predicate used to select faces when a mesh intersection is detected
17
+ */
18
+ export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray, i0: number, i1: number, i2: number) => boolean;
19
+ /**
20
+ * Class representing a ray with position and direction
21
+ */
22
+ export declare class Ray {
23
+ /** origin point */
24
+ origin: Vector3;
25
+ /** direction */
26
+ direction: Vector3;
27
+ /** [Number.MAX_VALUE] length of the ray */
28
+ length: number;
29
+ /** [Epsilon] The epsilon value to use when calculating the ray/triangle intersection (default: Epsilon from math constants) */
30
+ epsilon: number;
31
+ private static readonly _TmpVector3;
32
+ private static _RayDistant;
33
+ private _tmpRay;
34
+ /**
35
+ * Creates a new ray
36
+ * @param origin origin point
37
+ * @param direction direction
38
+ * @param length length of the ray
39
+ * @param epsilon The epsilon value to use when calculating the ray/triangle intersection (default: 0)
40
+ */
41
+ constructor(
42
+ /** origin point */
43
+ origin: Vector3,
44
+ /** direction */
45
+ direction: Vector3,
46
+ /** [Number.MAX_VALUE] length of the ray */
47
+ length?: number,
48
+ /** [Epsilon] The epsilon value to use when calculating the ray/triangle intersection (default: Epsilon from math constants) */
49
+ epsilon?: number);
50
+ /**
51
+ * Clone the current ray
52
+ * @returns a new ray
53
+ */
54
+ clone(): Ray;
55
+ /**
56
+ * Checks if the ray intersects a box
57
+ * This does not account for the ray length by design to improve perfs.
58
+ * @param minimum bound of the box
59
+ * @param maximum bound of the box
60
+ * @param intersectionTreshold extra extend to be added to the box in all direction
61
+ * @returns if the box was hit
62
+ */
63
+ intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
64
+ /**
65
+ * Checks if the ray intersects a box
66
+ * This does not account for the ray lenght by design to improve perfs.
67
+ * @param box the bounding box to check
68
+ * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
69
+ * @returns if the box was hit
70
+ */
71
+ intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
72
+ /**
73
+ * If the ray hits a sphere
74
+ * @param sphere the bounding sphere to check
75
+ * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
76
+ * @returns true if it hits the sphere
77
+ */
78
+ intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
79
+ /**
80
+ * If the ray hits a triange
81
+ * @param vertex0 triangle vertex
82
+ * @param vertex1 triangle vertex
83
+ * @param vertex2 triangle vertex
84
+ * @returns intersection information if hit
85
+ */
86
+ intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
87
+ /**
88
+ * Checks if ray intersects a plane
89
+ * @param plane the plane to check
90
+ * @returns the distance away it was hit
91
+ */
92
+ intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
93
+ /**
94
+ * Calculate the intercept of a ray on a given axis
95
+ * @param axis to check 'x' | 'y' | 'z'
96
+ * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
97
+ * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
98
+ */
99
+ intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
100
+ /**
101
+ * Checks if ray intersects a mesh. The ray is defined in WORLD space. A mesh triangle can be picked both from its front and back sides,
102
+ * irrespective of orientation.
103
+ * @param mesh the mesh to check
104
+ * @param fastCheck defines if the first intersection will be used (and not the closest)
105
+ * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
106
+ * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
107
+ * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
108
+ * @param skipBoundingInfo a boolean indicating if we should skip the bounding info check
109
+ * @returns picking info of the intersection
110
+ */
111
+ intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix, skipBoundingInfo?: boolean): PickingInfo;
112
+ /**
113
+ * Checks if ray intersects a mesh
114
+ * @param meshes the meshes to check
115
+ * @param fastCheck defines if the first intersection will be used (and not the closest)
116
+ * @param results array to store result in
117
+ * @returns Array of picking infos
118
+ */
119
+ intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
120
+ private _comparePickingInfo;
121
+ private static _Smallnum;
122
+ private static _Rayl;
123
+ /**
124
+ * Intersection test between the ray and a given segment within a given tolerance (threshold)
125
+ * @param sega the first point of the segment to test the intersection against
126
+ * @param segb the second point of the segment to test the intersection against
127
+ * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
128
+ * @returns the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
129
+ */
130
+ intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
131
+ /**
132
+ * Update the ray from viewport position
133
+ * @param x position
134
+ * @param y y position
135
+ * @param viewportWidth viewport width
136
+ * @param viewportHeight viewport height
137
+ * @param world world matrix
138
+ * @param view view matrix
139
+ * @param projection projection matrix
140
+ * @param enableDistantPicking defines if picking should handle large values for mesh position/scaling (false by default)
141
+ * @returns this ray updated
142
+ */
143
+ update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, enableDistantPicking?: boolean): Ray;
144
+ /**
145
+ * Creates a ray with origin and direction of 0,0,0
146
+ * @returns the new ray
147
+ */
148
+ static Zero(): Ray;
149
+ /**
150
+ * Creates a new ray from screen space and viewport
151
+ * @param x position
152
+ * @param y y position
153
+ * @param viewportWidth viewport width
154
+ * @param viewportHeight viewport height
155
+ * @param world world matrix
156
+ * @param view view matrix
157
+ * @param projection projection matrix
158
+ * @returns new ray
159
+ */
160
+ static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
161
+ /**
162
+ * Function will create a new transformed ray starting from origin and ending at the end point. Ray's length will be set, and ray will be
163
+ * transformed to the given world matrix.
164
+ * @param origin The origin point
165
+ * @param end The end point
166
+ * @param world a matrix to transform the ray to. Default is the identity matrix.
167
+ * @returns the new ray
168
+ */
169
+ static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
170
+ /**
171
+ * Function will update a transformed ray starting from origin and ending at the end point. Ray's length will be set, and ray will be
172
+ * transformed to the given world matrix.
173
+ * @param origin The origin point
174
+ * @param end The end point
175
+ * @param result the object to store the result
176
+ * @param world a matrix to transform the ray to. Default is the identity matrix.
177
+ * @returns the ref ray
178
+ */
179
+ static CreateFromToToRef(origin: Vector3, end: Vector3, result: Ray, world?: DeepImmutable<Matrix>): Ray;
180
+ /**
181
+ * Transforms a ray by a matrix
182
+ * @param ray ray to transform
183
+ * @param matrix matrix to apply
184
+ * @returns the resulting new ray
185
+ */
186
+ static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
187
+ /**
188
+ * Transforms a ray by a matrix
189
+ * @param ray ray to transform
190
+ * @param matrix matrix to apply
191
+ * @param result ray to store result in
192
+ * @returns the updated result ray
193
+ */
194
+ static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): Ray;
195
+ /**
196
+ * Unproject a ray from screen space to object space
197
+ * @param sourceX defines the screen space x coordinate to use
198
+ * @param sourceY defines the screen space y coordinate to use
199
+ * @param viewportWidth defines the current width of the viewport
200
+ * @param viewportHeight defines the current height of the viewport
201
+ * @param world defines the world matrix to use (can be set to Identity to go to world space)
202
+ * @param view defines the view matrix to use
203
+ * @param projection defines the projection matrix to use
204
+ */
205
+ unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
206
+ }
207
+ /**
208
+ * Creates a ray that can be used to pick in the scene
209
+ * @param scene defines the scene to use for the picking
210
+ * @param x defines the x coordinate of the origin (on-screen)
211
+ * @param y defines the y coordinate of the origin (on-screen)
212
+ * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
213
+ * @param camera defines the camera to use for the picking
214
+ * @param cameraViewSpace defines if picking will be done in view space (false by default)
215
+ * @returns a Ray
216
+ */
217
+ export declare function CreatePickingRay(scene: Scene, x: number, y: number, world: Nullable<Matrix>, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
218
+ /**
219
+ * Creates a ray that can be used to pick in the scene
220
+ * @param scene defines the scene to use for the picking
221
+ * @param x defines the x coordinate of the origin (on-screen)
222
+ * @param y defines the y coordinate of the origin (on-screen)
223
+ * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
224
+ * @param result defines the ray where to store the picking ray
225
+ * @param camera defines the camera to use for the picking
226
+ * @param cameraViewSpace defines if picking will be done in view space (false by default)
227
+ * @param enableDistantPicking defines if picking should handle large values for mesh position/scaling (false by default)
228
+ * @returns the current scene
229
+ */
230
+ export declare function CreatePickingRayToRef(scene: Scene, x: number, y: number, world: Nullable<Matrix>, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean, enableDistantPicking?: boolean): Scene;
231
+ /**
232
+ * Creates a ray that can be used to pick in the scene
233
+ * @param scene defines the scene to use for the picking
234
+ * @param x defines the x coordinate of the origin (on-screen)
235
+ * @param y defines the y coordinate of the origin (on-screen)
236
+ * @param camera defines the camera to use for the picking
237
+ * @returns a Ray
238
+ */
239
+ export declare function CreatePickingRayInCameraSpace(scene: Scene, x: number, y: number, camera?: Camera): Ray;
240
+ /**
241
+ * Creates a ray that can be used to pick in the scene
242
+ * @param scene defines the scene to use for the picking
243
+ * @param x defines the x coordinate of the origin (on-screen)
244
+ * @param y defines the y coordinate of the origin (on-screen)
245
+ * @param result defines the ray where to store the picking ray
246
+ * @param camera defines the camera to use for the picking
247
+ * @returns the current scene
248
+ */
249
+ export declare function CreatePickingRayInCameraSpaceToRef(scene: Scene, x: number, y: number, result: Ray, camera?: Camera): Scene;
250
+ /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
251
+ * @param scene defines the scene to use for the picking
252
+ * @param x position on screen
253
+ * @param y position on screen
254
+ * @param predicate Predicate function used to determine eligible meshes. Can be set to null. In this case, a mesh must be enabled, visible and with isPickable set to true. thinInstanceIndex is -1 when the mesh is non-instanced
255
+ * @param fastCheck defines if the first intersection will be used (and not the closest)
256
+ * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
257
+ * @returns a PickingInfo (Please note that some info will not be set like distance, bv, bu and everything that cannot be capture by only using bounding infos)
258
+ */
259
+ export declare function PickWithBoundingInfo(scene: Scene, x: number, y: number, predicate?: MeshPredicate, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
260
+ /** Launch a ray to try to pick a mesh in the scene
261
+ * @param scene defines the scene to use for the picking
262
+ * @param x position on screen
263
+ * @param y position on screen
264
+ * @param predicate Predicate function used to determine eligible meshes. Can be set to null. In this case, a mesh must be enabled, visible and with isPickable set to true. thinInstanceIndex is -1 when the mesh is non-instanced
265
+ * @param fastCheck defines if the first intersection will be used (and not the closest)
266
+ * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
267
+ * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
268
+ * @param _enableDistantPicking defines if picking should handle large values for mesh position/scaling (false by default)
269
+ * @returns a PickingInfo
270
+ */
271
+ export declare function Pick(scene: Scene, x: number, y: number, predicate?: MeshPredicate, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate, _enableDistantPicking?: boolean): PickingInfo;
272
+ /**
273
+ * Use the given ray to pick a mesh in the scene. A mesh triangle can be picked both from its front and back sides,
274
+ * irrespective of orientation.
275
+ * @param scene defines the scene to use for the picking
276
+ * @param ray The ray to use to pick meshes
277
+ * @param predicate Predicate function used to determine eligible meshes. Can be set to null. In this case, a mesh must have isPickable set to true. thinInstanceIndex is -1 when the mesh is non-instanced
278
+ * @param fastCheck defines if the first intersection will be used (and not the closest)
279
+ * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
280
+ * @returns a PickingInfo
281
+ */
282
+ export declare function PickWithRay(scene: Scene, ray: Ray, predicate?: MeshPredicate, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
283
+ /**
284
+ * Launch a ray to try to pick a mesh in the scene. A mesh triangle can be picked both from its front and back sides,
285
+ * irrespective of orientation.
286
+ * @param scene defines the scene to use for the picking
287
+ * @param x X position on screen
288
+ * @param y Y position on screen
289
+ * @param predicate Predicate function used to determine eligible meshes and instances. Can be set to null. In this case, a mesh must be enabled, visible and with isPickable set to true. thinInstanceIndex is -1 when the mesh is non-instanced
290
+ * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
291
+ * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
292
+ * @returns an array of PickingInfo
293
+ */
294
+ export declare function MultiPick(scene: Scene, x: number, y: number, predicate?: MeshPredicate, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
295
+ /**
296
+ * Launch a ray to try to pick a mesh in the scene
297
+ * @param scene defines the scene to use for the picking
298
+ * @param ray Ray to use
299
+ * @param predicate Predicate function used to determine eligible meshes and instances. Can be set to null. In this case, a mesh must be enabled, visible and with isPickable set to true. thinInstanceIndex is -1 when the mesh is non-instanced
300
+ * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
301
+ * @returns an array of PickingInfo
302
+ */
303
+ export declare function MultiPickWithRay(scene: Scene, ray: Ray, predicate?: MeshPredicate, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
304
+ /**
305
+ * Gets a ray in the forward direction from the camera.
306
+ * @param camera Defines the camera to use to get the ray from
307
+ * @param length Defines the length of the ray to create
308
+ * @param transform Defines the transform to apply to the ray, by default the world matrix is used to create a workd space ray
309
+ * @param origin Defines the start point of the ray which defaults to the camera position
310
+ * @returns the forward ray
311
+ */
312
+ export declare function GetForwardRay(camera: Camera, length?: number, transform?: Matrix, origin?: Vector3): Ray;
313
+ /**
314
+ * Gets a ray in the forward direction from the camera.
315
+ * @param camera Defines the camera to use to get the ray from
316
+ * @param refRay the ray to (re)use when setting the values
317
+ * @param length Defines the length of the ray to create
318
+ * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
319
+ * @param origin Defines the start point of the ray which defaults to the camera position
320
+ * @returns the forward ray
321
+ */
322
+ export declare function GetForwardRayToRef(camera: Camera, refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
323
+ /**
324
+ * Initialize the minimal interdependecies between the Ray and Scene and Camera
325
+ * @param sceneClass defines the scene prototype to use
326
+ * @param cameraClass defines the camera prototype to use
327
+ */
328
+ export declare function AddRayExtensions(sceneClass: typeof Scene, cameraClass: typeof Camera): void;