@babylonjs/core 5.5.6 → 5.7.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.
- package/Animations/animation.js +2 -1
- package/Animations/animation.js.map +1 -1
- package/Animations/easing.d.ts +14 -14
- package/Animations/easing.js +13 -13
- package/Animations/easing.js.map +1 -1
- package/Behaviors/Meshes/handConstraintBehavior.js +4 -3
- package/Behaviors/Meshes/handConstraintBehavior.js.map +1 -1
- package/Behaviors/Meshes/pointerDragBehavior.d.ts +5 -0
- package/Behaviors/Meshes/pointerDragBehavior.js +15 -2
- package/Behaviors/Meshes/pointerDragBehavior.js.map +1 -1
- package/Cameras/Inputs/freeCameraTouchInput.js +2 -2
- package/Cameras/Inputs/freeCameraTouchInput.js.map +1 -1
- package/Engines/Extensions/engine.multiRender.js +10 -1
- package/Engines/Extensions/engine.multiRender.js.map +1 -1
- package/Engines/Native/nativeInterfaces.d.ts +2 -0
- package/Engines/Native/nativeInterfaces.js.map +1 -1
- package/Engines/WebGPU/Extensions/engine.multiRender.js +7 -0
- package/Engines/WebGPU/Extensions/engine.multiRender.js.map +1 -1
- package/Engines/constants.d.ts +2 -0
- package/Engines/constants.js +2 -0
- package/Engines/constants.js.map +1 -1
- package/Engines/engine.d.ts +2 -2
- package/Engines/engine.js +2 -2
- package/Engines/engine.js.map +1 -1
- package/Engines/engineCapabilities.d.ts +2 -0
- package/Engines/engineCapabilities.js.map +1 -1
- package/Engines/engineFactory.d.ts +2 -2
- package/Engines/engineFactory.js.map +1 -1
- package/Engines/nativeEngine.js +3 -2
- package/Engines/nativeEngine.js.map +1 -1
- package/Engines/nullEngine.js +1 -0
- package/Engines/nullEngine.js.map +1 -1
- package/Engines/thinEngine.d.ts +1 -0
- package/Engines/thinEngine.js +18 -3
- package/Engines/thinEngine.js.map +1 -1
- package/Engines/webgpuEngine.js +5 -1
- package/Engines/webgpuEngine.js.map +1 -1
- package/Gizmos/boundingBoxGizmo.js +3 -0
- package/Gizmos/boundingBoxGizmo.js.map +1 -1
- package/Materials/Background/backgroundMaterial.js +1 -1
- package/Materials/Background/backgroundMaterial.js.map +1 -1
- package/Materials/Node/Blocks/Dual/index.d.ts +0 -1
- package/Materials/Node/Blocks/Dual/index.js +0 -1
- package/Materials/Node/Blocks/Dual/index.js.map +1 -1
- package/Materials/Node/Blocks/{Dual → Fragment}/TBNBlock.d.ts +0 -0
- package/Materials/Node/Blocks/{Dual → Fragment}/TBNBlock.js +7 -9
- package/Materials/Node/Blocks/Fragment/TBNBlock.js.map +1 -0
- package/Materials/Node/Blocks/Fragment/index.d.ts +1 -0
- package/Materials/Node/Blocks/Fragment/index.js +1 -0
- package/Materials/Node/Blocks/Fragment/index.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/perturbNormalBlock.js +1 -1
- package/Materials/Node/Blocks/Fragment/perturbNormalBlock.js.map +1 -1
- package/Materials/Node/Blocks/PBR/anisotropyBlock.js +1 -1
- package/Materials/Node/Blocks/PBR/anisotropyBlock.js.map +1 -1
- package/Materials/Node/Blocks/PBR/clearCoatBlock.js +1 -1
- package/Materials/Node/Blocks/PBR/clearCoatBlock.js.map +1 -1
- package/Materials/Node/Blocks/Vertex/morphTargetsBlock.js +9 -3
- package/Materials/Node/Blocks/Vertex/morphTargetsBlock.js.map +1 -1
- package/Materials/Node/nodeMaterial.js +1 -1
- package/Materials/Node/nodeMaterial.js.map +1 -1
- package/Materials/PBR/pbrBaseMaterial.js +1 -1
- package/Materials/PBR/pbrBaseMaterial.js.map +1 -1
- package/Materials/Textures/multiRenderTarget.d.ts +4 -0
- package/Materials/Textures/multiRenderTarget.js +16 -3
- package/Materials/Textures/multiRenderTarget.js.map +1 -1
- package/Materials/shaderMaterial.js +2 -1
- package/Materials/shaderMaterial.js.map +1 -1
- package/Materials/standardMaterial.js +2 -1
- package/Materials/standardMaterial.js.map +1 -1
- package/Meshes/Builders/linesBuilder.js +4 -0
- package/Meshes/Builders/linesBuilder.js.map +1 -1
- package/Meshes/abstractMesh.d.ts +15 -0
- package/Meshes/abstractMesh.js +45 -14
- package/Meshes/abstractMesh.js.map +1 -1
- package/Meshes/subMesh.js +1 -1
- package/Meshes/subMesh.js.map +1 -1
- package/Morph/morphTargetManager.js +2 -1
- package/Morph/morphTargetManager.js.map +1 -1
- package/Particles/particleHelper.js +3 -2
- package/Particles/particleHelper.js.map +1 -1
- package/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline.d.ts +1 -1
- package/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline.js +1 -1
- package/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline.js.map +1 -1
- package/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.js +3 -3
- package/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.js.map +1 -1
- package/Shaders/ShadersInclude/pbrBlockClearcoat.js +1 -1
- package/Shaders/ShadersInclude/pbrBlockClearcoat.js.map +1 -1
- package/Sprites/spriteManager.js +2 -1
- package/Sprites/spriteManager.js.map +1 -1
- package/XR/features/WebXRHandTracking.d.ts +2 -2
- package/XR/features/WebXRHandTracking.js +163 -76
- package/XR/features/WebXRHandTracking.js.map +1 -1
- package/package.json +1 -1
- package/scene.d.ts +1 -1
- package/scene.js +0 -3
- package/scene.js.map +1 -1
- package/Materials/Node/Blocks/Dual/TBNBlock.js.map +0 -1
package/Animations/easing.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* This represents the main contract an easing function should follow.
|
|
3
3
|
* Easing functions are used throughout the animation system.
|
|
4
|
-
* @see https://doc.babylonjs.com/
|
|
4
|
+
* @see https://doc.babylonjs.com/divingDeeper/animation/advanced_animations#easing-functions
|
|
5
5
|
*/
|
|
6
6
|
export interface IEasingFunction {
|
|
7
7
|
/**
|
|
@@ -16,7 +16,7 @@ export interface IEasingFunction {
|
|
|
16
16
|
}
|
|
17
17
|
/**
|
|
18
18
|
* Base class used for every default easing function.
|
|
19
|
-
* @see https://doc.babylonjs.com/
|
|
19
|
+
* @see https://doc.babylonjs.com/divingDeeper/animation/advanced_animations#easing-functions
|
|
20
20
|
*/
|
|
21
21
|
export declare class EasingFunction implements IEasingFunction {
|
|
22
22
|
/**
|
|
@@ -58,7 +58,7 @@ export declare class EasingFunction implements IEasingFunction {
|
|
|
58
58
|
/**
|
|
59
59
|
* Easing function with a circle shape (see link below).
|
|
60
60
|
* @see https://easings.net/#easeInCirc
|
|
61
|
-
* @see https://doc.babylonjs.com/
|
|
61
|
+
* @see https://doc.babylonjs.com/divingDeeper/animation/advanced_animations#easing-functions
|
|
62
62
|
*/
|
|
63
63
|
export declare class CircleEase extends EasingFunction implements IEasingFunction {
|
|
64
64
|
/**
|
|
@@ -70,7 +70,7 @@ export declare class CircleEase extends EasingFunction implements IEasingFunctio
|
|
|
70
70
|
/**
|
|
71
71
|
* Easing function with a ease back shape (see link below).
|
|
72
72
|
* @see https://easings.net/#easeInBack
|
|
73
|
-
* @see https://doc.babylonjs.com/
|
|
73
|
+
* @see https://doc.babylonjs.com/divingDeeper/animation/advanced_animations#easing-functions
|
|
74
74
|
*/
|
|
75
75
|
export declare class BackEase extends EasingFunction implements IEasingFunction {
|
|
76
76
|
/** Defines the amplitude of the function */
|
|
@@ -92,7 +92,7 @@ export declare class BackEase extends EasingFunction implements IEasingFunction
|
|
|
92
92
|
/**
|
|
93
93
|
* Easing function with a bouncing shape (see link below).
|
|
94
94
|
* @see https://easings.net/#easeInBounce
|
|
95
|
-
* @see https://doc.babylonjs.com/
|
|
95
|
+
* @see https://doc.babylonjs.com/divingDeeper/animation/advanced_animations#easing-functions
|
|
96
96
|
*/
|
|
97
97
|
export declare class BounceEase extends EasingFunction implements IEasingFunction {
|
|
98
98
|
/** Defines the number of bounces */
|
|
@@ -119,7 +119,7 @@ export declare class BounceEase extends EasingFunction implements IEasingFunctio
|
|
|
119
119
|
/**
|
|
120
120
|
* Easing function with a power of 3 shape (see link below).
|
|
121
121
|
* @see https://easings.net/#easeInCubic
|
|
122
|
-
* @see https://doc.babylonjs.com/
|
|
122
|
+
* @see https://doc.babylonjs.com/divingDeeper/animation/advanced_animations#easing-functions
|
|
123
123
|
*/
|
|
124
124
|
export declare class CubicEase extends EasingFunction implements IEasingFunction {
|
|
125
125
|
/**
|
|
@@ -131,7 +131,7 @@ export declare class CubicEase extends EasingFunction implements IEasingFunction
|
|
|
131
131
|
/**
|
|
132
132
|
* Easing function with an elastic shape (see link below).
|
|
133
133
|
* @see https://easings.net/#easeInElastic
|
|
134
|
-
* @see https://doc.babylonjs.com/
|
|
134
|
+
* @see https://doc.babylonjs.com/divingDeeper/animation/advanced_animations#easing-functions
|
|
135
135
|
*/
|
|
136
136
|
export declare class ElasticEase extends EasingFunction implements IEasingFunction {
|
|
137
137
|
/** Defines the number of oscillations*/
|
|
@@ -158,7 +158,7 @@ export declare class ElasticEase extends EasingFunction implements IEasingFuncti
|
|
|
158
158
|
/**
|
|
159
159
|
* Easing function with an exponential shape (see link below).
|
|
160
160
|
* @see https://easings.net/#easeInExpo
|
|
161
|
-
* @see https://doc.babylonjs.com/
|
|
161
|
+
* @see https://doc.babylonjs.com/divingDeeper/animation/advanced_animations#easing-functions
|
|
162
162
|
*/
|
|
163
163
|
export declare class ExponentialEase extends EasingFunction implements IEasingFunction {
|
|
164
164
|
/** Defines the exponent of the function */
|
|
@@ -180,7 +180,7 @@ export declare class ExponentialEase extends EasingFunction implements IEasingFu
|
|
|
180
180
|
/**
|
|
181
181
|
* Easing function with a power shape (see link below).
|
|
182
182
|
* @see https://easings.net/#easeInQuad
|
|
183
|
-
* @see https://doc.babylonjs.com/
|
|
183
|
+
* @see https://doc.babylonjs.com/divingDeeper/animation/advanced_animations#easing-functions
|
|
184
184
|
*/
|
|
185
185
|
export declare class PowerEase extends EasingFunction implements IEasingFunction {
|
|
186
186
|
/** Defines the power of the function */
|
|
@@ -202,7 +202,7 @@ export declare class PowerEase extends EasingFunction implements IEasingFunction
|
|
|
202
202
|
/**
|
|
203
203
|
* Easing function with a power of 2 shape (see link below).
|
|
204
204
|
* @see https://easings.net/#easeInQuad
|
|
205
|
-
* @see https://doc.babylonjs.com/
|
|
205
|
+
* @see https://doc.babylonjs.com/divingDeeper/animation/advanced_animations#easing-functions
|
|
206
206
|
*/
|
|
207
207
|
export declare class QuadraticEase extends EasingFunction implements IEasingFunction {
|
|
208
208
|
/**
|
|
@@ -214,7 +214,7 @@ export declare class QuadraticEase extends EasingFunction implements IEasingFunc
|
|
|
214
214
|
/**
|
|
215
215
|
* Easing function with a power of 4 shape (see link below).
|
|
216
216
|
* @see https://easings.net/#easeInQuart
|
|
217
|
-
* @see https://doc.babylonjs.com/
|
|
217
|
+
* @see https://doc.babylonjs.com/divingDeeper/animation/advanced_animations#easing-functions
|
|
218
218
|
*/
|
|
219
219
|
export declare class QuarticEase extends EasingFunction implements IEasingFunction {
|
|
220
220
|
/**
|
|
@@ -226,7 +226,7 @@ export declare class QuarticEase extends EasingFunction implements IEasingFuncti
|
|
|
226
226
|
/**
|
|
227
227
|
* Easing function with a power of 5 shape (see link below).
|
|
228
228
|
* @see https://easings.net/#easeInQuint
|
|
229
|
-
* @see https://doc.babylonjs.com/
|
|
229
|
+
* @see https://doc.babylonjs.com/divingDeeper/animation/advanced_animations#easing-functions
|
|
230
230
|
*/
|
|
231
231
|
export declare class QuinticEase extends EasingFunction implements IEasingFunction {
|
|
232
232
|
/**
|
|
@@ -238,7 +238,7 @@ export declare class QuinticEase extends EasingFunction implements IEasingFuncti
|
|
|
238
238
|
/**
|
|
239
239
|
* Easing function with a sin shape (see link below).
|
|
240
240
|
* @see https://easings.net/#easeInSine
|
|
241
|
-
* @see https://doc.babylonjs.com/
|
|
241
|
+
* @see https://doc.babylonjs.com/divingDeeper/animation/advanced_animations#easing-functions
|
|
242
242
|
*/
|
|
243
243
|
export declare class SineEase extends EasingFunction implements IEasingFunction {
|
|
244
244
|
/**
|
|
@@ -250,7 +250,7 @@ export declare class SineEase extends EasingFunction implements IEasingFunction
|
|
|
250
250
|
/**
|
|
251
251
|
* Easing function with a bezier shape (see link below).
|
|
252
252
|
* @see http://cubic-bezier.com/#.17,.67,.83,.67
|
|
253
|
-
* @see https://doc.babylonjs.com/
|
|
253
|
+
* @see https://doc.babylonjs.com/divingDeeper/animation/advanced_animations#easing-functions
|
|
254
254
|
*/
|
|
255
255
|
export declare class BezierCurveEase extends EasingFunction implements IEasingFunction {
|
|
256
256
|
/** Defines the x component of the start tangent in the bezier curve */
|
package/Animations/easing.js
CHANGED
|
@@ -2,7 +2,7 @@ import { __extends } from "tslib";
|
|
|
2
2
|
import { BezierCurve } from "../Maths/math.path.js";
|
|
3
3
|
/**
|
|
4
4
|
* Base class used for every default easing function.
|
|
5
|
-
* @see https://doc.babylonjs.com/
|
|
5
|
+
* @see https://doc.babylonjs.com/divingDeeper/animation/advanced_animations#easing-functions
|
|
6
6
|
*/
|
|
7
7
|
var EasingFunction = /** @class */ (function () {
|
|
8
8
|
function EasingFunction() {
|
|
@@ -67,7 +67,7 @@ export { EasingFunction };
|
|
|
67
67
|
/**
|
|
68
68
|
* Easing function with a circle shape (see link below).
|
|
69
69
|
* @see https://easings.net/#easeInCirc
|
|
70
|
-
* @see https://doc.babylonjs.com/
|
|
70
|
+
* @see https://doc.babylonjs.com/divingDeeper/animation/advanced_animations#easing-functions
|
|
71
71
|
*/
|
|
72
72
|
var CircleEase = /** @class */ (function (_super) {
|
|
73
73
|
__extends(CircleEase, _super);
|
|
@@ -88,7 +88,7 @@ export { CircleEase };
|
|
|
88
88
|
/**
|
|
89
89
|
* Easing function with a ease back shape (see link below).
|
|
90
90
|
* @see https://easings.net/#easeInBack
|
|
91
|
-
* @see https://doc.babylonjs.com/
|
|
91
|
+
* @see https://doc.babylonjs.com/divingDeeper/animation/advanced_animations#easing-functions
|
|
92
92
|
*/
|
|
93
93
|
var BackEase = /** @class */ (function (_super) {
|
|
94
94
|
__extends(BackEase, _super);
|
|
@@ -119,7 +119,7 @@ export { BackEase };
|
|
|
119
119
|
/**
|
|
120
120
|
* Easing function with a bouncing shape (see link below).
|
|
121
121
|
* @see https://easings.net/#easeInBounce
|
|
122
|
-
* @see https://doc.babylonjs.com/
|
|
122
|
+
* @see https://doc.babylonjs.com/divingDeeper/animation/advanced_animations#easing-functions
|
|
123
123
|
*/
|
|
124
124
|
var BounceEase = /** @class */ (function (_super) {
|
|
125
125
|
__extends(BounceEase, _super);
|
|
@@ -171,7 +171,7 @@ export { BounceEase };
|
|
|
171
171
|
/**
|
|
172
172
|
* Easing function with a power of 3 shape (see link below).
|
|
173
173
|
* @see https://easings.net/#easeInCubic
|
|
174
|
-
* @see https://doc.babylonjs.com/
|
|
174
|
+
* @see https://doc.babylonjs.com/divingDeeper/animation/advanced_animations#easing-functions
|
|
175
175
|
*/
|
|
176
176
|
var CubicEase = /** @class */ (function (_super) {
|
|
177
177
|
__extends(CubicEase, _super);
|
|
@@ -191,7 +191,7 @@ export { CubicEase };
|
|
|
191
191
|
/**
|
|
192
192
|
* Easing function with an elastic shape (see link below).
|
|
193
193
|
* @see https://easings.net/#easeInElastic
|
|
194
|
-
* @see https://doc.babylonjs.com/
|
|
194
|
+
* @see https://doc.babylonjs.com/divingDeeper/animation/advanced_animations#easing-functions
|
|
195
195
|
*/
|
|
196
196
|
var ElasticEase = /** @class */ (function (_super) {
|
|
197
197
|
__extends(ElasticEase, _super);
|
|
@@ -235,7 +235,7 @@ export { ElasticEase };
|
|
|
235
235
|
/**
|
|
236
236
|
* Easing function with an exponential shape (see link below).
|
|
237
237
|
* @see https://easings.net/#easeInExpo
|
|
238
|
-
* @see https://doc.babylonjs.com/
|
|
238
|
+
* @see https://doc.babylonjs.com/divingDeeper/animation/advanced_animations#easing-functions
|
|
239
239
|
*/
|
|
240
240
|
var ExponentialEase = /** @class */ (function (_super) {
|
|
241
241
|
__extends(ExponentialEase, _super);
|
|
@@ -268,7 +268,7 @@ export { ExponentialEase };
|
|
|
268
268
|
/**
|
|
269
269
|
* Easing function with a power shape (see link below).
|
|
270
270
|
* @see https://easings.net/#easeInQuad
|
|
271
|
-
* @see https://doc.babylonjs.com/
|
|
271
|
+
* @see https://doc.babylonjs.com/divingDeeper/animation/advanced_animations#easing-functions
|
|
272
272
|
*/
|
|
273
273
|
var PowerEase = /** @class */ (function (_super) {
|
|
274
274
|
__extends(PowerEase, _super);
|
|
@@ -299,7 +299,7 @@ export { PowerEase };
|
|
|
299
299
|
/**
|
|
300
300
|
* Easing function with a power of 2 shape (see link below).
|
|
301
301
|
* @see https://easings.net/#easeInQuad
|
|
302
|
-
* @see https://doc.babylonjs.com/
|
|
302
|
+
* @see https://doc.babylonjs.com/divingDeeper/animation/advanced_animations#easing-functions
|
|
303
303
|
*/
|
|
304
304
|
var QuadraticEase = /** @class */ (function (_super) {
|
|
305
305
|
__extends(QuadraticEase, _super);
|
|
@@ -319,7 +319,7 @@ export { QuadraticEase };
|
|
|
319
319
|
/**
|
|
320
320
|
* Easing function with a power of 4 shape (see link below).
|
|
321
321
|
* @see https://easings.net/#easeInQuart
|
|
322
|
-
* @see https://doc.babylonjs.com/
|
|
322
|
+
* @see https://doc.babylonjs.com/divingDeeper/animation/advanced_animations#easing-functions
|
|
323
323
|
*/
|
|
324
324
|
var QuarticEase = /** @class */ (function (_super) {
|
|
325
325
|
__extends(QuarticEase, _super);
|
|
@@ -339,7 +339,7 @@ export { QuarticEase };
|
|
|
339
339
|
/**
|
|
340
340
|
* Easing function with a power of 5 shape (see link below).
|
|
341
341
|
* @see https://easings.net/#easeInQuint
|
|
342
|
-
* @see https://doc.babylonjs.com/
|
|
342
|
+
* @see https://doc.babylonjs.com/divingDeeper/animation/advanced_animations#easing-functions
|
|
343
343
|
*/
|
|
344
344
|
var QuinticEase = /** @class */ (function (_super) {
|
|
345
345
|
__extends(QuinticEase, _super);
|
|
@@ -359,7 +359,7 @@ export { QuinticEase };
|
|
|
359
359
|
/**
|
|
360
360
|
* Easing function with a sin shape (see link below).
|
|
361
361
|
* @see https://easings.net/#easeInSine
|
|
362
|
-
* @see https://doc.babylonjs.com/
|
|
362
|
+
* @see https://doc.babylonjs.com/divingDeeper/animation/advanced_animations#easing-functions
|
|
363
363
|
*/
|
|
364
364
|
var SineEase = /** @class */ (function (_super) {
|
|
365
365
|
__extends(SineEase, _super);
|
|
@@ -379,7 +379,7 @@ export { SineEase };
|
|
|
379
379
|
/**
|
|
380
380
|
* Easing function with a bezier shape (see link below).
|
|
381
381
|
* @see http://cubic-bezier.com/#.17,.67,.83,.67
|
|
382
|
-
* @see https://doc.babylonjs.com/
|
|
382
|
+
* @see https://doc.babylonjs.com/divingDeeper/animation/advanced_animations#easing-functions
|
|
383
383
|
*/
|
|
384
384
|
var BezierCurveEase = /** @class */ (function (_super) {
|
|
385
385
|
__extends(BezierCurveEase, _super);
|
package/Animations/easing.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"easing.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Animations/easing.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAmBjD;;;GAGG;AACH;IAAA;QAgBY,gBAAW,GAAG,cAAc,CAAC,iBAAiB,CAAC;IA+C3D,CAAC;IA7CG;;;OAGG;IACI,sCAAa,GAApB,UAAqB,UAAkB;QACnC,IAAM,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,UAAU,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QAC/C,IAAI,CAAC,WAAW,GAAG,CAAC,CAAC;IACzB,CAAC;IACD;;;OAGG;IACI,sCAAa,GAApB;QACI,OAAO,IAAI,CAAC,WAAW,CAAC;IAC5B,CAAC;IAED;;;OAGG;IACH,6DAA6D;IACtD,mCAAU,GAAjB,UAAkB,QAAgB;QAC9B,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAC;IACtD,CAAC;IAED;;;;;OAKG;IACI,6BAAI,GAAX,UAAY,QAAgB;QACx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Q,GAAG,QAAQ,GAAG,QAAQ,GAAG,QAAQ,GAAG,QAAQ,CAAC;IAChE,CAAC;IACL,kBAAC;AAAD,CAAC,AARD,CAAiC,cAAc,GAQ9C;;AAED;;;;GAIG;AACH;IAA8B,4BAAc;IAA5C;;IAQA,CAAC;IAPG;;;OAGG;IACI,6BAAU,GAAjB,UAAkB,QAAgB;QAC9B,OAAO,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,kBAAkB,GAAG,CAAC,GAAG,GAAG,QAAQ,CAAC,CAAC,CAAC;IACjE,CAAC;IACL,eAAC;AAAD,CAAC,AARD,CAA8B,cAAc,GAQ3C;;AAED;;;;GAIG;AACH;IAAqC,mCAAc;IAC/C;;;;;;;OAOG;IACH;IACI,uEAAuE;IAChE,EAAc;IACrB,uEAAuE;IAChE,EAAc;IACrB,qEAAqE;IAC9D,EAAc;IACrB,qEAAqE;IAC9D,EAAc;QANd,mBAAA,EAAA,MAAc;QAEd,mBAAA,EAAA,MAAc;QAEd,mBAAA,EAAA,MAAc;QAEd,mBAAA,EAAA,MAAc;QARzB,YAUI,iBAAO,SACV;QATU,QAAE,GAAF,EAAE,CAAY;QAEd,QAAE,GAAF,EAAE,CAAY;QAEd,QAAE,GAAF,EAAE,CAAY;QAEd,QAAE,GAAF,EAAE,CAAY;;IAGzB,CAAC;IAED;;;OAGG;IACI,oCAAU,GAAjB,UAAkB,QAAgB;QAC9B,OAAO,WAAW,CAAC,WAAW,CAAC,QAAQ,EAAE,IAAI,CAAC,EAAE,EAAE,IAAI,CAAC,EAAE,EAAE,IAAI,CAAC,EAAE,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC;IACjF,CAAC;IACL,sBAAC;AAAD,CAAC,AA7BD,CAAqC,cAAc,GA6BlD","sourcesContent":["import { BezierCurve } from \"../Maths/math.path\";\r\n\r\n/**\r\n * This represents the main contract an easing function should follow.\r\n * Easing functions are used throughout the animation system.\r\n * @see https://doc.babylonjs.com/babylon101/animations#easing-functions\r\n */\r\nexport interface IEasingFunction {\r\n /**\r\n * Given an input gradient between 0 and 1, this returns the corresponding value\r\n * of the easing function.\r\n * The link below provides some of the most common examples of easing functions.\r\n * @see https://easings.net/\r\n * @param gradient Defines the value between 0 and 1 we want the easing value for\r\n * @returns the corresponding value on the curve defined by the easing function\r\n */\r\n ease(gradient: number): number;\r\n}\r\n\r\n/**\r\n * Base class used for every default easing function.\r\n * @see https://doc.babylonjs.com/babylon101/animations#easing-functions\r\n */\r\nexport class EasingFunction implements IEasingFunction {\r\n /**\r\n * Interpolation follows the mathematical formula associated with the easing function.\r\n */\r\n public static readonly EASINGMODE_EASEIN = 0;\r\n\r\n /**\r\n * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.\r\n */\r\n public static readonly EASINGMODE_EASEOUT = 1;\r\n\r\n /**\r\n * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.\r\n */\r\n public static readonly EASINGMODE_EASEINOUT = 2;\r\n\r\n private _easingMode = EasingFunction.EASINGMODE_EASEIN;\r\n\r\n /**\r\n * Sets the easing mode of the current function.\r\n * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)\r\n */\r\n public setEasingMode(easingMode: number) {\r\n const n = Math.min(Math.max(easingMode, 0), 2);\r\n this._easingMode = n;\r\n }\r\n /**\r\n * Gets the current easing mode.\r\n * @returns the easing mode\r\n */\r\n public getEasingMode(): number {\r\n return this._easingMode;\r\n }\r\n\r\n /**\r\n * @param gradient\r\n * @hidden\r\n */\r\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n public easeInCore(gradient: number): number {\r\n throw new Error(\"You must implement this method\");\r\n }\r\n\r\n /**\r\n * Given an input gradient between 0 and 1, this returns the corresponding value\r\n * of the easing function.\r\n * @param gradient Defines the value between 0 and 1 we want the easing value for\r\n * @returns the corresponding value on the curve defined by the easing function\r\n */\r\n public ease(gradient: number): number {\r\n switch (this._easingMode) {\r\n case EasingFunction.EASINGMODE_EASEIN:\r\n return this.easeInCore(gradient);\r\n case EasingFunction.EASINGMODE_EASEOUT:\r\n return 1 - this.easeInCore(1 - gradient);\r\n }\r\n\r\n if (gradient >= 0.5) {\r\n return (1 - this.easeInCore((1 - gradient) * 2)) * 0.5 + 0.5;\r\n }\r\n\r\n return this.easeInCore(gradient * 2) * 0.5;\r\n }\r\n}\r\n\r\n/**\r\n * Easing function with a circle shape (see link below).\r\n * @see https://easings.net/#easeInCirc\r\n * @see https://doc.babylonjs.com/babylon101/animations#easing-functions\r\n */\r\nexport class CircleEase extends EasingFunction implements IEasingFunction {\r\n /**\r\n * @param gradient\r\n * @hidden\r\n */\r\n public easeInCore(gradient: number): number {\r\n gradient = Math.max(0, Math.min(1, gradient));\r\n return 1.0 - Math.sqrt(1.0 - gradient * gradient);\r\n }\r\n}\r\n\r\n/**\r\n * Easing function with a ease back shape (see link below).\r\n * @see https://easings.net/#easeInBack\r\n * @see https://doc.babylonjs.com/babylon101/animations#easing-functions\r\n */\r\nexport class BackEase extends EasingFunction implements IEasingFunction {\r\n /**\r\n * Instantiates a back ease easing\r\n * @see https://easings.net/#easeInBack\r\n * @param amplitude Defines the amplitude of the function\r\n */\r\n constructor(\r\n /** Defines the amplitude of the function */\r\n public amplitude: number = 1\r\n ) {\r\n super();\r\n }\r\n\r\n /**\r\n * @param gradient\r\n * @hidden\r\n */\r\n public easeInCore(gradient: number): number {\r\n const num = Math.max(0, this.amplitude);\r\n return Math.pow(gradient, 3.0) - gradient * num * Math.sin(3.1415926535897931 * gradient);\r\n }\r\n}\r\n\r\n/**\r\n * Easing function with a bouncing shape (see link below).\r\n * @see https://easings.net/#easeInBounce\r\n * @see https://doc.babylonjs.com/babylon101/animations#easing-functions\r\n */\r\nexport class BounceEase extends EasingFunction implements IEasingFunction {\r\n /**\r\n * Instantiates a bounce easing\r\n * @see https://easings.net/#easeInBounce\r\n * @param bounces Defines the number of bounces\r\n * @param bounciness Defines the amplitude of the bounce\r\n */\r\n constructor(\r\n /** Defines the number of bounces */\r\n public bounces: number = 3,\r\n /** Defines the amplitude of the bounce */\r\n public bounciness: number = 2\r\n ) {\r\n super();\r\n }\r\n\r\n /**\r\n * @param gradient\r\n * @hidden\r\n */\r\n public easeInCore(gradient: number): number {\r\n const y = Math.max(0.0, this.bounces);\r\n let bounciness = this.bounciness;\r\n if (bounciness <= 1.0) {\r\n bounciness = 1.001;\r\n }\r\n const num9 = Math.pow(bounciness, y);\r\n const num5 = 1.0 - bounciness;\r\n const num4 = (1.0 - num9) / num5 + num9 * 0.5;\r\n const num15 = gradient * num4;\r\n const num65 = Math.log(-num15 * (1.0 - bounciness) + 1.0) / Math.log(bounciness);\r\n const num3 = Math.floor(num65);\r\n const num13 = num3 + 1.0;\r\n const num8 = (1.0 - Math.pow(bounciness, num3)) / (num5 * num4);\r\n const num12 = (1.0 - Math.pow(bounciness, num13)) / (num5 * num4);\r\n const num7 = (num8 + num12) * 0.5;\r\n const num6 = gradient - num7;\r\n const num2 = num7 - num8;\r\n return (-Math.pow(1.0 / bounciness, y - num3) / (num2 * num2)) * (num6 - num2) * (num6 + num2);\r\n }\r\n}\r\n\r\n/**\r\n * Easing function with a power of 3 shape (see link below).\r\n * @see https://easings.net/#easeInCubic\r\n * @see https://doc.babylonjs.com/babylon101/animations#easing-functions\r\n */\r\nexport class CubicEase extends EasingFunction implements IEasingFunction {\r\n /**\r\n * @param gradient\r\n * @hidden\r\n */\r\n public easeInCore(gradient: number): number {\r\n return gradient * gradient * gradient;\r\n }\r\n}\r\n\r\n/**\r\n * Easing function with an elastic shape (see link below).\r\n * @see https://easings.net/#easeInElastic\r\n * @see https://doc.babylonjs.com/babylon101/animations#easing-functions\r\n */\r\nexport class ElasticEase extends EasingFunction implements IEasingFunction {\r\n /**\r\n * Instantiates an elastic easing function\r\n * @see https://easings.net/#easeInElastic\r\n * @param oscillations Defines the number of oscillations\r\n * @param springiness Defines the amplitude of the oscillations\r\n */\r\n constructor(\r\n /** Defines the number of oscillations*/\r\n public oscillations: number = 3,\r\n /** Defines the amplitude of the oscillations*/\r\n public springiness: number = 3\r\n ) {\r\n super();\r\n }\r\n\r\n /**\r\n * @param gradient\r\n * @hidden\r\n */\r\n public easeInCore(gradient: number): number {\r\n let num2;\r\n const num3 = Math.max(0.0, this.oscillations);\r\n const num = Math.max(0.0, this.springiness);\r\n\r\n if (num == 0) {\r\n num2 = gradient;\r\n } else {\r\n num2 = (Math.exp(num * gradient) - 1.0) / (Math.exp(num) - 1.0);\r\n }\r\n return num2 * Math.sin((6.2831853071795862 * num3 + 1.5707963267948966) * gradient);\r\n }\r\n}\r\n\r\n/**\r\n * Easing function with an exponential shape (see link below).\r\n * @see https://easings.net/#easeInExpo\r\n * @see https://doc.babylonjs.com/babylon101/animations#easing-functions\r\n */\r\nexport class ExponentialEase extends EasingFunction implements IEasingFunction {\r\n /**\r\n * Instantiates an exponential easing function\r\n * @see https://easings.net/#easeInExpo\r\n * @param exponent Defines the exponent of the function\r\n */\r\n constructor(\r\n /** Defines the exponent of the function */\r\n public exponent: number = 2\r\n ) {\r\n super();\r\n }\r\n\r\n /**\r\n * @param gradient\r\n * @hidden\r\n */\r\n public easeInCore(gradient: number): number {\r\n if (this.exponent <= 0) {\r\n return gradient;\r\n }\r\n\r\n return (Math.exp(this.exponent * gradient) - 1.0) / (Math.exp(this.exponent) - 1.0);\r\n }\r\n}\r\n\r\n/**\r\n * Easing function with a power shape (see link below).\r\n * @see https://easings.net/#easeInQuad\r\n * @see https://doc.babylonjs.com/babylon101/animations#easing-functions\r\n */\r\nexport class PowerEase extends EasingFunction implements IEasingFunction {\r\n /**\r\n * Instantiates an power base easing function\r\n * @see https://easings.net/#easeInQuad\r\n * @param power Defines the power of the function\r\n */\r\n constructor(\r\n /** Defines the power of the function */\r\n public power: number = 2\r\n ) {\r\n super();\r\n }\r\n\r\n /**\r\n * @param gradient\r\n * @hidden\r\n */\r\n public easeInCore(gradient: number): number {\r\n const y = Math.max(0.0, this.power);\r\n return Math.pow(gradient, y);\r\n }\r\n}\r\n\r\n/**\r\n * Easing function with a power of 2 shape (see link below).\r\n * @see https://easings.net/#easeInQuad\r\n * @see https://doc.babylonjs.com/babylon101/animations#easing-functions\r\n */\r\nexport class QuadraticEase extends EasingFunction implements IEasingFunction {\r\n /**\r\n * @param gradient\r\n * @hidden\r\n */\r\n public easeInCore(gradient: number): number {\r\n return gradient * gradient;\r\n }\r\n}\r\n\r\n/**\r\n * Easing function with a power of 4 shape (see link below).\r\n * @see https://easings.net/#easeInQuart\r\n * @see https://doc.babylonjs.com/babylon101/animations#easing-functions\r\n */\r\nexport class QuarticEase extends EasingFunction implements IEasingFunction {\r\n /**\r\n * @param gradient\r\n * @hidden\r\n */\r\n public easeInCore(gradient: number): number {\r\n return gradient * gradient * gradient * gradient;\r\n }\r\n}\r\n\r\n/**\r\n * Easing function with a power of 5 shape (see link below).\r\n * @see https://easings.net/#easeInQuint\r\n * @see https://doc.babylonjs.com/babylon101/animations#easing-functions\r\n */\r\nexport class QuinticEase extends EasingFunction implements IEasingFunction {\r\n /**\r\n * @param gradient\r\n * @hidden\r\n */\r\n public easeInCore(gradient: number): number {\r\n return gradient * gradient * gradient * gradient * gradient;\r\n }\r\n}\r\n\r\n/**\r\n * Easing function with a sin shape (see link below).\r\n * @see https://easings.net/#easeInSine\r\n * @see https://doc.babylonjs.com/babylon101/animations#easing-functions\r\n */\r\nexport class SineEase extends EasingFunction implements IEasingFunction {\r\n /**\r\n * @param gradient\r\n * @hidden\r\n */\r\n public easeInCore(gradient: number): number {\r\n return 1.0 - Math.sin(1.5707963267948966 * (1.0 - gradient));\r\n }\r\n}\r\n\r\n/**\r\n * Easing function with a bezier shape (see link below).\r\n * @see http://cubic-bezier.com/#.17,.67,.83,.67\r\n * @see https://doc.babylonjs.com/babylon101/animations#easing-functions\r\n */\r\nexport class BezierCurveEase extends EasingFunction implements IEasingFunction {\r\n /**\r\n * Instantiates a bezier function\r\n * @see http://cubic-bezier.com/#.17,.67,.83,.67\r\n * @param x1 Defines the x component of the start tangent in the bezier curve\r\n * @param y1 Defines the y component of the start tangent in the bezier curve\r\n * @param x2 Defines the x component of the end tangent in the bezier curve\r\n * @param y2 Defines the y component of the end tangent in the bezier curve\r\n */\r\n constructor(\r\n /** Defines the x component of the start tangent in the bezier curve */\r\n public x1: number = 0,\r\n /** Defines the y component of the start tangent in the bezier curve */\r\n public y1: number = 0,\r\n /** Defines the x component of the end tangent in the bezier curve */\r\n public x2: number = 1,\r\n /** Defines the y component of the end tangent in the bezier curve */\r\n public y2: number = 1\r\n ) {\r\n super();\r\n }\r\n\r\n /**\r\n * @param gradient\r\n * @hidden\r\n */\r\n public easeInCore(gradient: number): number {\r\n return BezierCurve.Interpolate(gradient, this.x1, this.y1, this.x2, this.y2);\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"easing.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Animations/easing.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAmBjD;;;GAGG;AACH;IAAA;QAgBY,gBAAW,GAAG,cAAc,CAAC,iBAAiB,CAAC;IA+C3D,CAAC;IA7CG;;;OAGG;IACI,sCAAa,GAApB,UAAqB,UAAkB;QACnC,IAAM,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,UAAU,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QAC/C,IAAI,CAAC,WAAW,GAAG,CAAC,CAAC;IACzB,CAAC;IACD;;;OAGG;IACI,sCAAa,GAApB;QACI,OAAO,IAAI,CAAC,WAAW,CAAC;IAC5B,CAAC;IAED;;;OAGG;IACH,6DAA6D;IACtD,mCAAU,GAAjB,UAAkB,QAAgB;QAC9B,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAC;IACtD,CAAC;IAED;;;;;OAKG;IACI,6BAAI,GAAX,UAAY,QAAgB;QACxB,QAAQ,IAAI,CAAC,WAAW,EAAE;YACtB,K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,GAAG,QAAQ,CAAC;IAChE,CAAC;IACL,kBAAC;AAAD,CAAC,AARD,CAAiC,cAAc,GAQ9C;;AAED;;;;GAIG;AACH;IAA8B,4BAAc;IAA5C;;IAQA,CAAC;IAPG;;;OAGG;IACI,6BAAU,GAAjB,UAAkB,QAAgB;QAC9B,OAAO,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,kBAAkB,GAAG,CAAC,GAAG,GAAG,QAAQ,CAAC,CAAC,CAAC;IACjE,CAAC;IACL,eAAC;AAAD,CAAC,AARD,CAA8B,cAAc,GAQ3C;;AAED;;;;GAIG;AACH;IAAqC,mCAAc;IAC/C;;;;;;;OAOG;IACH;IACI,uEAAuE;IAChE,EAAc;IACrB,uEAAuE;IAChE,EAAc;IACrB,qEAAqE;IAC9D,EAAc;IACrB,qEAAqE;IAC9D,EAAc;QANd,mBAAA,EAAA,MAAc;QAEd,mBAAA,EAAA,MAAc;QAEd,mBAAA,EAAA,MAAc;QAEd,mBAAA,EAAA,MAAc;QARzB,YAUI,iBAAO,SACV;QATU,QAAE,GAAF,EAAE,CAAY;QAEd,QAAE,GAAF,EAAE,CAAY;QAEd,QAAE,GAAF,EAAE,CAAY;QAEd,QAAE,GAAF,EAAE,CAAY;;IAGzB,CAAC;IAED;;;OAGG;IACI,oCAAU,GAAjB,UAAkB,QAAgB;QAC9B,OAAO,WAAW,CAAC,WAAW,CAAC,QAAQ,EAAE,IAAI,CAAC,EAAE,EAAE,IAAI,CAAC,EAAE,EAAE,IAAI,CAAC,EAAE,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC;IACjF,CAAC;IACL,sBAAC;AAAD,CAAC,AA7BD,CAAqC,cAAc,GA6BlD","sourcesContent":["import { BezierCurve } from \"../Maths/math.path\";\r\n\r\n/**\r\n * This represents the main contract an easing function should follow.\r\n * Easing functions are used throughout the animation system.\r\n * @see https://doc.babylonjs.com/divingDeeper/animation/advanced_animations#easing-functions\r\n */\r\nexport interface IEasingFunction {\r\n /**\r\n * Given an input gradient between 0 and 1, this returns the corresponding value\r\n * of the easing function.\r\n * The link below provides some of the most common examples of easing functions.\r\n * @see https://easings.net/\r\n * @param gradient Defines the value between 0 and 1 we want the easing value for\r\n * @returns the corresponding value on the curve defined by the easing function\r\n */\r\n ease(gradient: number): number;\r\n}\r\n\r\n/**\r\n * Base class used for every default easing function.\r\n * @see https://doc.babylonjs.com/divingDeeper/animation/advanced_animations#easing-functions\r\n */\r\nexport class EasingFunction implements IEasingFunction {\r\n /**\r\n * Interpolation follows the mathematical formula associated with the easing function.\r\n */\r\n public static readonly EASINGMODE_EASEIN = 0;\r\n\r\n /**\r\n * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.\r\n */\r\n public static readonly EASINGMODE_EASEOUT = 1;\r\n\r\n /**\r\n * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.\r\n */\r\n public static readonly EASINGMODE_EASEINOUT = 2;\r\n\r\n private _easingMode = EasingFunction.EASINGMODE_EASEIN;\r\n\r\n /**\r\n * Sets the easing mode of the current function.\r\n * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)\r\n */\r\n public setEasingMode(easingMode: number) {\r\n const n = Math.min(Math.max(easingMode, 0), 2);\r\n this._easingMode = n;\r\n }\r\n /**\r\n * Gets the current easing mode.\r\n * @returns the easing mode\r\n */\r\n public getEasingMode(): number {\r\n return this._easingMode;\r\n }\r\n\r\n /**\r\n * @param gradient\r\n * @hidden\r\n */\r\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n public easeInCore(gradient: number): number {\r\n throw new Error(\"You must implement this method\");\r\n }\r\n\r\n /**\r\n * Given an input gradient between 0 and 1, this returns the corresponding value\r\n * of the easing function.\r\n * @param gradient Defines the value between 0 and 1 we want the easing value for\r\n * @returns the corresponding value on the curve defined by the easing function\r\n */\r\n public ease(gradient: number): number {\r\n switch (this._easingMode) {\r\n case EasingFunction.EASINGMODE_EASEIN:\r\n return this.easeInCore(gradient);\r\n case EasingFunction.EASINGMODE_EASEOUT:\r\n return 1 - this.easeInCore(1 - gradient);\r\n }\r\n\r\n if (gradient >= 0.5) {\r\n return (1 - this.easeInCore((1 - gradient) * 2)) * 0.5 + 0.5;\r\n }\r\n\r\n return this.easeInCore(gradient * 2) * 0.5;\r\n }\r\n}\r\n\r\n/**\r\n * Easing function with a circle shape (see link below).\r\n * @see https://easings.net/#easeInCirc\r\n * @see https://doc.babylonjs.com/divingDeeper/animation/advanced_animations#easing-functions\r\n */\r\nexport class CircleEase extends EasingFunction implements IEasingFunction {\r\n /**\r\n * @param gradient\r\n * @hidden\r\n */\r\n public easeInCore(gradient: number): number {\r\n gradient = Math.max(0, Math.min(1, gradient));\r\n return 1.0 - Math.sqrt(1.0 - gradient * gradient);\r\n }\r\n}\r\n\r\n/**\r\n * Easing function with a ease back shape (see link below).\r\n * @see https://easings.net/#easeInBack\r\n * @see https://doc.babylonjs.com/divingDeeper/animation/advanced_animations#easing-functions\r\n */\r\nexport class BackEase extends EasingFunction implements IEasingFunction {\r\n /**\r\n * Instantiates a back ease easing\r\n * @see https://easings.net/#easeInBack\r\n * @param amplitude Defines the amplitude of the function\r\n */\r\n constructor(\r\n /** Defines the amplitude of the function */\r\n public amplitude: number = 1\r\n ) {\r\n super();\r\n }\r\n\r\n /**\r\n * @param gradient\r\n * @hidden\r\n */\r\n public easeInCore(gradient: number): number {\r\n const num = Math.max(0, this.amplitude);\r\n return Math.pow(gradient, 3.0) - gradient * num * Math.sin(3.1415926535897931 * gradient);\r\n }\r\n}\r\n\r\n/**\r\n * Easing function with a bouncing shape (see link below).\r\n * @see https://easings.net/#easeInBounce\r\n * @see https://doc.babylonjs.com/divingDeeper/animation/advanced_animations#easing-functions\r\n */\r\nexport class BounceEase extends EasingFunction implements IEasingFunction {\r\n /**\r\n * Instantiates a bounce easing\r\n * @see https://easings.net/#easeInBounce\r\n * @param bounces Defines the number of bounces\r\n * @param bounciness Defines the amplitude of the bounce\r\n */\r\n constructor(\r\n /** Defines the number of bounces */\r\n public bounces: number = 3,\r\n /** Defines the amplitude of the bounce */\r\n public bounciness: number = 2\r\n ) {\r\n super();\r\n }\r\n\r\n /**\r\n * @param gradient\r\n * @hidden\r\n */\r\n public easeInCore(gradient: number): number {\r\n const y = Math.max(0.0, this.bounces);\r\n let bounciness = this.bounciness;\r\n if (bounciness <= 1.0) {\r\n bounciness = 1.001;\r\n }\r\n const num9 = Math.pow(bounciness, y);\r\n const num5 = 1.0 - bounciness;\r\n const num4 = (1.0 - num9) / num5 + num9 * 0.5;\r\n const num15 = gradient * num4;\r\n const num65 = Math.log(-num15 * (1.0 - bounciness) + 1.0) / Math.log(bounciness);\r\n const num3 = Math.floor(num65);\r\n const num13 = num3 + 1.0;\r\n const num8 = (1.0 - Math.pow(bounciness, num3)) / (num5 * num4);\r\n const num12 = (1.0 - Math.pow(bounciness, num13)) / (num5 * num4);\r\n const num7 = (num8 + num12) * 0.5;\r\n const num6 = gradient - num7;\r\n const num2 = num7 - num8;\r\n return (-Math.pow(1.0 / bounciness, y - num3) / (num2 * num2)) * (num6 - num2) * (num6 + num2);\r\n }\r\n}\r\n\r\n/**\r\n * Easing function with a power of 3 shape (see link below).\r\n * @see https://easings.net/#easeInCubic\r\n * @see https://doc.babylonjs.com/divingDeeper/animation/advanced_animations#easing-functions\r\n */\r\nexport class CubicEase extends EasingFunction implements IEasingFunction {\r\n /**\r\n * @param gradient\r\n * @hidden\r\n */\r\n public easeInCore(gradient: number): number {\r\n return gradient * gradient * gradient;\r\n }\r\n}\r\n\r\n/**\r\n * Easing function with an elastic shape (see link below).\r\n * @see https://easings.net/#easeInElastic\r\n * @see https://doc.babylonjs.com/divingDeeper/animation/advanced_animations#easing-functions\r\n */\r\nexport class ElasticEase extends EasingFunction implements IEasingFunction {\r\n /**\r\n * Instantiates an elastic easing function\r\n * @see https://easings.net/#easeInElastic\r\n * @param oscillations Defines the number of oscillations\r\n * @param springiness Defines the amplitude of the oscillations\r\n */\r\n constructor(\r\n /** Defines the number of oscillations*/\r\n public oscillations: number = 3,\r\n /** Defines the amplitude of the oscillations*/\r\n public springiness: number = 3\r\n ) {\r\n super();\r\n }\r\n\r\n /**\r\n * @param gradient\r\n * @hidden\r\n */\r\n public easeInCore(gradient: number): number {\r\n let num2;\r\n const num3 = Math.max(0.0, this.oscillations);\r\n const num = Math.max(0.0, this.springiness);\r\n\r\n if (num == 0) {\r\n num2 = gradient;\r\n } else {\r\n num2 = (Math.exp(num * gradient) - 1.0) / (Math.exp(num) - 1.0);\r\n }\r\n return num2 * Math.sin((6.2831853071795862 * num3 + 1.5707963267948966) * gradient);\r\n }\r\n}\r\n\r\n/**\r\n * Easing function with an exponential shape (see link below).\r\n * @see https://easings.net/#easeInExpo\r\n * @see https://doc.babylonjs.com/divingDeeper/animation/advanced_animations#easing-functions\r\n */\r\nexport class ExponentialEase extends EasingFunction implements IEasingFunction {\r\n /**\r\n * Instantiates an exponential easing function\r\n * @see https://easings.net/#easeInExpo\r\n * @param exponent Defines the exponent of the function\r\n */\r\n constructor(\r\n /** Defines the exponent of the function */\r\n public exponent: number = 2\r\n ) {\r\n super();\r\n }\r\n\r\n /**\r\n * @param gradient\r\n * @hidden\r\n */\r\n public easeInCore(gradient: number): number {\r\n if (this.exponent <= 0) {\r\n return gradient;\r\n }\r\n\r\n return (Math.exp(this.exponent * gradient) - 1.0) / (Math.exp(this.exponent) - 1.0);\r\n }\r\n}\r\n\r\n/**\r\n * Easing function with a power shape (see link below).\r\n * @see https://easings.net/#easeInQuad\r\n * @see https://doc.babylonjs.com/divingDeeper/animation/advanced_animations#easing-functions\r\n */\r\nexport class PowerEase extends EasingFunction implements IEasingFunction {\r\n /**\r\n * Instantiates an power base easing function\r\n * @see https://easings.net/#easeInQuad\r\n * @param power Defines the power of the function\r\n */\r\n constructor(\r\n /** Defines the power of the function */\r\n public power: number = 2\r\n ) {\r\n super();\r\n }\r\n\r\n /**\r\n * @param gradient\r\n * @hidden\r\n */\r\n public easeInCore(gradient: number): number {\r\n const y = Math.max(0.0, this.power);\r\n return Math.pow(gradient, y);\r\n }\r\n}\r\n\r\n/**\r\n * Easing function with a power of 2 shape (see link below).\r\n * @see https://easings.net/#easeInQuad\r\n * @see https://doc.babylonjs.com/divingDeeper/animation/advanced_animations#easing-functions\r\n */\r\nexport class QuadraticEase extends EasingFunction implements IEasingFunction {\r\n /**\r\n * @param gradient\r\n * @hidden\r\n */\r\n public easeInCore(gradient: number): number {\r\n return gradient * gradient;\r\n }\r\n}\r\n\r\n/**\r\n * Easing function with a power of 4 shape (see link below).\r\n * @see https://easings.net/#easeInQuart\r\n * @see https://doc.babylonjs.com/divingDeeper/animation/advanced_animations#easing-functions\r\n */\r\nexport class QuarticEase extends EasingFunction implements IEasingFunction {\r\n /**\r\n * @param gradient\r\n * @hidden\r\n */\r\n public easeInCore(gradient: number): number {\r\n return gradient * gradient * gradient * gradient;\r\n }\r\n}\r\n\r\n/**\r\n * Easing function with a power of 5 shape (see link below).\r\n * @see https://easings.net/#easeInQuint\r\n * @see https://doc.babylonjs.com/divingDeeper/animation/advanced_animations#easing-functions\r\n */\r\nexport class QuinticEase extends EasingFunction implements IEasingFunction {\r\n /**\r\n * @param gradient\r\n * @hidden\r\n */\r\n public easeInCore(gradient: number): number {\r\n return gradient * gradient * gradient * gradient * gradient;\r\n }\r\n}\r\n\r\n/**\r\n * Easing function with a sin shape (see link below).\r\n * @see https://easings.net/#easeInSine\r\n * @see https://doc.babylonjs.com/divingDeeper/animation/advanced_animations#easing-functions\r\n */\r\nexport class SineEase extends EasingFunction implements IEasingFunction {\r\n /**\r\n * @param gradient\r\n * @hidden\r\n */\r\n public easeInCore(gradient: number): number {\r\n return 1.0 - Math.sin(1.5707963267948966 * (1.0 - gradient));\r\n }\r\n}\r\n\r\n/**\r\n * Easing function with a bezier shape (see link below).\r\n * @see http://cubic-bezier.com/#.17,.67,.83,.67\r\n * @see https://doc.babylonjs.com/divingDeeper/animation/advanced_animations#easing-functions\r\n */\r\nexport class BezierCurveEase extends EasingFunction implements IEasingFunction {\r\n /**\r\n * Instantiates a bezier function\r\n * @see http://cubic-bezier.com/#.17,.67,.83,.67\r\n * @param x1 Defines the x component of the start tangent in the bezier curve\r\n * @param y1 Defines the y component of the start tangent in the bezier curve\r\n * @param x2 Defines the x component of the end tangent in the bezier curve\r\n * @param y2 Defines the y component of the end tangent in the bezier curve\r\n */\r\n constructor(\r\n /** Defines the x component of the start tangent in the bezier curve */\r\n public x1: number = 0,\r\n /** Defines the y component of the start tangent in the bezier curve */\r\n public y1: number = 0,\r\n /** Defines the x component of the end tangent in the bezier curve */\r\n public x2: number = 1,\r\n /** Defines the y component of the end tangent in the bezier curve */\r\n public y2: number = 1\r\n ) {\r\n super();\r\n }\r\n\r\n /**\r\n * @param gradient\r\n * @hidden\r\n */\r\n public easeInCore(gradient: number): number {\r\n return BezierCurve.Interpolate(gradient, this.x1, this.y1, this.x2, this.y2);\r\n }\r\n}\r\n"]}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { WebXRFeatureName } from "../../XR/webXRFeaturesManager.js";
|
|
2
|
+
import { XRHandJoint } from "../../XR/features/WebXRHandTracking.js";
|
|
2
3
|
import { Quaternion, TmpVectors, Vector3 } from "../../Maths/math.vector.js";
|
|
3
4
|
/**
|
|
4
5
|
* Zones around the hand
|
|
@@ -145,9 +146,9 @@ var HandConstraintBehavior = /** @class */ (function () {
|
|
|
145
146
|
hand = this._handTracking.getHandByHandedness(this.handedness);
|
|
146
147
|
}
|
|
147
148
|
if (hand) {
|
|
148
|
-
var pinkyMetacarpal = hand.getJointMesh(
|
|
149
|
-
var middleMetacarpal = hand.getJointMesh(
|
|
150
|
-
var wrist = hand.getJointMesh(
|
|
149
|
+
var pinkyMetacarpal = hand.getJointMesh(XRHandJoint.PINKY_FINGER_METACARPAL);
|
|
150
|
+
var middleMetacarpal = hand.getJointMesh(XRHandJoint.MIDDLE_FINGER_METACARPAL);
|
|
151
|
+
var wrist = hand.getJointMesh(XRHandJoint.WRIST);
|
|
151
152
|
if (wrist && middleMetacarpal && pinkyMetacarpal) {
|
|
152
153
|
var handPose = { position: middleMetacarpal.absolutePosition, quaternion: new Quaternion(), id: hand.xrController.uniqueId };
|
|
153
154
|
// palm forward
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handConstraintBehavior.js","sourceRoot":"","sources":["../../../../../../lts/core/generated/Behaviors/Meshes/handConstraintBehavior.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAQjE,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAG1E;;GAEG;AACH,MAAM,CAAN,IAAY,kBAiBX;AAjBD,WAAY,kBAAkB;IAC1B;;OAEG;IACH,qFAAiB,CAAA;IACjB;;OAEG;IACH,yEAAW,CAAA;IACX;;OAEG;IACH,uEAAU,CAAA;IACV;;OAEG;IACH,yEAAW,CAAA;AACf,CAAC,EAjBW,kBAAkB,KAAlB,kBAAkB,QAiB7B;AAED;;GAEG;AACH,MAAM,CAAN,IAAY,yBASX;AATD,WAAY,yBAAyB;IACjC;;OAEG;IACH,6FAAc,CAAA;IACd;;OAEG;IACH,2FAAa,CAAA;AACjB,CAAC,EATW,yBAAyB,KAAzB,yBAAyB,QASpC;AAED;;GAEG;AACH,MAAM,CAAN,IAAY,wBAkBX;AAlBD,WAAY,wBAAwB;IAChC;;OAEG;IACH,2FAAc,CAAA;IACd;;OAEG;IACH,6EAAO,CAAA;IACP;;;OAGG;IACH,mFAAU,CAAA;IACV;;OAEG;IACH,yFAAa,CAAA;AACjB,CAAC,EAlBW,wBAAwB,KAAxB,wBAAwB,QAkBnC;AAQD;;;GAGG;AACH;IAwDI;;OAEG;IACH;QAtDQ,yBAAoB,GAA8B,IAAI,CAAC;QACvD,cAAS,GAA8B,EAAE,CAAC;QAElD;;WAEG;QACI,6BAAwB,GAA6B,wBAAwB,CAAC,aAAa,C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,CAAC,yDAAyD,CAAC,CAAC;SACpE;IACL,CAAC;IACL,6BAAC;AAAD,CAAC,AAhRD,IAgRC","sourcesContent":["import type { TransformNode } from \"../../Meshes/transformNode\";\r\nimport type { Nullable } from \"../../types\";\r\nimport { WebXRFeatureName } from \"../../XR/webXRFeaturesManager\";\r\nimport type { WebXREyeTracking } from \"../../XR/features/WebXREyeTracking\";\r\nimport type { WebXRHandTracking } from \"../../XR/features/WebXRHandTracking\";\r\nimport { XRHandJoint } from \"../../XR/features/WebXRHandTracking\";\r\nimport type { WebXRExperienceHelper } from \"../../XR/webXRExperienceHelper\";\r\nimport type { Behavior } from \"../behavior\";\r\nimport type { Observer } from \"../../Misc/observable\";\r\nimport type { Scene } from \"../../scene\";\r\nimport { Quaternion, TmpVectors, Vector3 } from \"../../Maths/math.vector\";\r\nimport type { Ray } from \"../../Culling/ray\";\r\n\r\n/**\r\n * Zones around the hand\r\n */\r\nexport enum HandConstraintZone {\r\n /**\r\n * Above finger tips\r\n */\r\n ABOVE_FINGER_TIPS,\r\n /**\r\n * Next to the thumb\r\n */\r\n RADIAL_SIDE,\r\n /**\r\n * Next to the pinky finger\r\n */\r\n ULNAR_SIDE,\r\n /**\r\n * Below the wrist\r\n */\r\n BELOW_WRIST,\r\n}\r\n\r\n/**\r\n * Orientations for the hand zones and for the attached node\r\n */\r\nexport enum HandConstraintOrientation {\r\n /**\r\n * Orientation is towards the camera\r\n */\r\n LOOK_AT_CAMERA,\r\n /**\r\n * Orientation is determined by the rotation of the palm\r\n */\r\n HAND_ROTATION,\r\n}\r\n\r\n/**\r\n * Orientations for the hand zones and for the attached node\r\n */\r\nexport enum HandConstraintVisibility {\r\n /**\r\n * Constraint is always visible\r\n */\r\n ALWAYS_VISIBLE,\r\n /**\r\n * Constraint is only visible when the palm is up\r\n */\r\n PALM_UP,\r\n /**\r\n * Constraint is only visible when the user is looking at the constraint.\r\n * Uses XR Eye Tracking if enabled/available, otherwise uses camera direction\r\n */\r\n GAZE_FOCUS,\r\n /**\r\n * Constraint is only visible when the palm is up and the user is looking at it\r\n */\r\n PALM_AND_GAZE,\r\n}\r\n\r\ntype HandPoseInfo = {\r\n position: Vector3;\r\n quaternion: Quaternion;\r\n id: string;\r\n};\r\n\r\n/**\r\n * Hand constraint behavior that makes the attached `TransformNode` follow hands in XR experiences.\r\n * @since 5.0.0\r\n */\r\nexport class HandConstraintBehavior implements Behavior<TransformNode> {\r\n private _scene: Scene;\r\n private _node: TransformNode;\r\n private _eyeTracking: Nullable<WebXREyeTracking>;\r\n private _handTracking: Nullable<WebXRHandTracking>;\r\n private _sceneRenderObserver: Nullable<Observer<Scene>> = null;\r\n private _zoneAxis: { [id: number]: Vector3 } = {};\r\n\r\n /**\r\n * Sets the HandConstraintVisibility level for the hand constraint\r\n */\r\n public handConstraintVisibility: HandConstraintVisibility = HandConstraintVisibility.PALM_AND_GAZE;\r\n\r\n /**\r\n * A number from 0.0 to 1.0, marking how restricted the direction the palm faces is for the attached node to be enabled.\r\n * A 1 means the palm must be directly facing the user before the node is enabled, a 0 means it is always enabled.\r\n * Used with HandConstraintVisibility.PALM_UP\r\n */\r\n public palmUpStrictness: number = 0.95;\r\n\r\n /**\r\n * The radius in meters around the center of the hand that the user must gaze inside for the attached node to be enabled and appear.\r\n * Used with HandConstraintVisibility.GAZE_FOCUS\r\n */\r\n public gazeProximityRadius: number = 0.15;\r\n\r\n /**\r\n * Offset distance from the hand in meters\r\n */\r\n public targetOffset: number = 0.1;\r\n\r\n /**\r\n * Where to place the node regarding the center of the hand.\r\n */\r\n public targetZone: HandConstraintZone = HandConstraintZone.ULNAR_SIDE;\r\n\r\n /**\r\n * Orientation mode of the 4 zones around the hand\r\n */\r\n public zoneOrientationMode: HandConstraintOrientation = HandConstraintOrientation.HAND_ROTATION;\r\n /**\r\n * Orientation mode of the node attached to this behavior\r\n */\r\n public nodeOrientationMode: HandConstraintOrientation = HandConstraintOrientation.HAND_ROTATION;\r\n\r\n /**\r\n * Set the hand this behavior should follow. If set to \"none\", it will follow any visible hand (prioritising the left one).\r\n */\r\n public handedness: XRHandedness = \"none\";\r\n\r\n /**\r\n * Rate of interpolation of position and rotation of the attached node.\r\n * Higher values will give a slower interpolation.\r\n */\r\n public lerpTime = 100;\r\n\r\n /**\r\n * Builds a hand constraint behavior\r\n */\r\n constructor() {\r\n // For a right hand\r\n this._zoneAxis[HandConstraintZone.ABOVE_FINGER_TIPS] = new Vector3(0, 1, 0);\r\n this._zoneAxis[HandConstraintZone.RADIAL_SIDE] = new Vector3(-1, 0, 0);\r\n this._zoneAxis[HandConstraintZone.ULNAR_SIDE] = new Vector3(1, 0, 0);\r\n this._zoneAxis[HandConstraintZone.BELOW_WRIST] = new Vector3(0, -1, 0);\r\n }\r\n\r\n /** gets or sets behavior's name */\r\n public get name() {\r\n return \"HandConstraint\";\r\n }\r\n\r\n /** Enable the behavior */\r\n public enable() {\r\n this._node.setEnabled(true);\r\n }\r\n\r\n /** Disable the behavior */\r\n public disable() {\r\n this._node.setEnabled(false);\r\n }\r\n\r\n private _getHandPose(): Nullable<HandPoseInfo> {\r\n if (!this._handTracking) {\r\n return null;\r\n }\r\n\r\n // Retrieve any available hand, starting by the left\r\n let hand;\r\n if (this.handedness === \"none\") {\r\n hand = this._handTracking.getHandByHandedness(\"left\") || this._handTracking.getHandByHandedness(\"right\");\r\n } else {\r\n hand = this._handTracking.getHandByHandedness(this.handedness);\r\n }\r\n\r\n if (hand) {\r\n const pinkyMetacarpal = hand.getJointMesh(XRHandJoint.PINKY_FINGER_METACARPAL);\r\n const middleMetacarpal = hand.getJointMesh(XRHandJoint.MIDDLE_FINGER_METACARPAL);\r\n const wrist = hand.getJointMesh(XRHandJoint.WRIST);\r\n\r\n if (wrist && middleMetacarpal && pinkyMetacarpal) {\r\n const handPose: HandPoseInfo = { position: middleMetacarpal.absolutePosition, quaternion: new Quaternion(), id: hand.xrController.uniqueId };\r\n\r\n // palm forward\r\n const up = TmpVectors.Vector3[0];\r\n const forward = TmpVectors.Vector3[1];\r\n const left = TmpVectors.Vector3[2];\r\n up.copyFrom(middleMetacarpal.absolutePosition).subtractInPlace(wrist.absolutePosition).normalize();\r\n forward.copyFrom(pinkyMetacarpal.absolutePosition).subtractInPlace(middleMetacarpal.absolutePosition).normalize();\r\n\r\n // Create vectors for a rotation quaternion, where forward points out from the palm\r\n Vector3.CrossToRef(up, forward, forward);\r\n Vector3.CrossToRef(forward, up, left);\r\n\r\n Quaternion.FromLookDirectionLHToRef(forward, up, handPose.quaternion);\r\n\r\n return handPose;\r\n }\r\n }\r\n\r\n return null;\r\n }\r\n\r\n /**\r\n * Initializes the hand constraint behavior\r\n */\r\n public init() {}\r\n\r\n /**\r\n * Attaches the hand constraint to a `TransformNode`\r\n * @param node defines the node to attach the behavior to\r\n */\r\n public attach(node: TransformNode): void {\r\n this._node = node;\r\n this._scene = node.getScene();\r\n\r\n if (!this._node.rotationQuaternion) {\r\n this._node.rotationQuaternion = Quaternion.RotationYawPitchRoll(this._node.rotation.y, this._node.rotation.x, this._node.rotation.z);\r\n }\r\n\r\n let lastTick = Date.now();\r\n this._sceneRenderObserver = this._scene.onBeforeRenderObservable.add(() => {\r\n const pose = this._getHandPose();\r\n\r\n this._node.reservedDataStore = this._node.reservedDataStore || {};\r\n this._node.reservedDataStore.nearInteraction = this._node.reservedDataStore.nearInteraction || {};\r\n this._node.reservedDataStore.nearInteraction.excludedControllerId = null;\r\n\r\n if (pose) {\r\n const zoneOffset = TmpVectors.Vector3[0];\r\n const camera = this._scene.activeCamera;\r\n\r\n zoneOffset.copyFrom(this._zoneAxis[this.targetZone]);\r\n\r\n const cameraLookAtQuaternion = TmpVectors.Quaternion[0];\r\n if (camera && (this.zoneOrientationMode === HandConstraintOrientation.LOOK_AT_CAMERA || this.nodeOrientationMode === HandConstraintOrientation.LOOK_AT_CAMERA)) {\r\n const toCamera = TmpVectors.Vector3[1];\r\n toCamera.copyFrom(camera.position).subtractInPlace(pose.position).normalize();\r\n if (this._scene.useRightHandedSystem) {\r\n Quaternion.FromLookDirectionRHToRef(toCamera, Vector3.UpReadOnly, cameraLookAtQuaternion);\r\n } else {\r\n Quaternion.FromLookDirectionLHToRef(toCamera, Vector3.UpReadOnly, cameraLookAtQuaternion);\r\n }\r\n }\r\n\r\n if (this.zoneOrientationMode === HandConstraintOrientation.HAND_ROTATION) {\r\n pose.quaternion.toRotationMatrix(TmpVectors.Matrix[0]);\r\n } else {\r\n cameraLookAtQuaternion.toRotationMatrix(TmpVectors.Matrix[0]);\r\n }\r\n\r\n Vector3.TransformNormalToRef(zoneOffset, TmpVectors.Matrix[0], zoneOffset);\r\n zoneOffset.scaleInPlace(this.targetOffset);\r\n\r\n const targetPosition = TmpVectors.Vector3[2];\r\n const targetRotation = TmpVectors.Quaternion[1];\r\n targetPosition.copyFrom(pose.position).addInPlace(zoneOffset);\r\n\r\n if (this.nodeOrientationMode === HandConstraintOrientation.HAND_ROTATION) {\r\n targetRotation.copyFrom(pose.quaternion);\r\n } else {\r\n targetRotation.copyFrom(cameraLookAtQuaternion);\r\n }\r\n\r\n const elapsed = Date.now() - lastTick;\r\n\r\n Vector3.SmoothToRef(this._node.position, targetPosition, elapsed, this.lerpTime, this._node.position);\r\n Quaternion.SmoothToRef(this._node.rotationQuaternion!, targetRotation, elapsed, this.lerpTime, this._node.rotationQuaternion!);\r\n\r\n this._node.reservedDataStore.nearInteraction.excludedControllerId = pose.id;\r\n }\r\n\r\n this._setVisibility(pose);\r\n\r\n lastTick = Date.now();\r\n });\r\n }\r\n\r\n private _setVisibility(pose: Nullable<HandPoseInfo>) {\r\n let palmVisible = true;\r\n let gazeVisible = true;\r\n const camera = this._scene.activeCamera;\r\n\r\n if (camera) {\r\n const cameraForward = camera.getForwardRay();\r\n\r\n if (this.handConstraintVisibility === HandConstraintVisibility.GAZE_FOCUS || this.handConstraintVisibility === HandConstraintVisibility.PALM_AND_GAZE) {\r\n gazeVisible = false;\r\n let gaze: Ray | undefined;\r\n if (this._eyeTracking) {\r\n gaze = this._eyeTracking.getEyeGaze()!;\r\n }\r\n\r\n gaze = gaze || cameraForward;\r\n\r\n const gazeToBehavior = TmpVectors.Vector3[0];\r\n if (pose) {\r\n pose.position.subtractToRef(gaze.origin, gazeToBehavior);\r\n } else {\r\n this._node.getAbsolutePosition().subtractToRef(gaze.origin, gazeToBehavior);\r\n }\r\n\r\n const projectedDistance = Vector3.Dot(gazeToBehavior, gaze.direction);\r\n const projectedSquared = projectedDistance * projectedDistance;\r\n\r\n if (projectedDistance > 0) {\r\n const radiusSquared = gazeToBehavior.lengthSquared() - projectedSquared;\r\n if (radiusSquared < this.gazeProximityRadius * this.gazeProximityRadius) {\r\n gazeVisible = true;\r\n }\r\n }\r\n }\r\n\r\n if (this.handConstraintVisibility === HandConstraintVisibility.PALM_UP || this.handConstraintVisibility === HandConstraintVisibility.PALM_AND_GAZE) {\r\n palmVisible = false;\r\n\r\n if (pose) {\r\n const palmDirection = TmpVectors.Vector3[0];\r\n Vector3.LeftHandedForwardReadOnly.rotateByQuaternionToRef(pose.quaternion, palmDirection);\r\n\r\n if (Vector3.Dot(palmDirection, cameraForward.direction) > this.palmUpStrictness * 2 - 1) {\r\n palmVisible = true;\r\n }\r\n }\r\n }\r\n }\r\n\r\n this._node.setEnabled(palmVisible && gazeVisible);\r\n }\r\n\r\n /**\r\n * Detaches the behavior from the `TransformNode`\r\n */\r\n public detach(): void {\r\n this._scene.onBeforeRenderObservable.remove(this._sceneRenderObserver);\r\n }\r\n\r\n /**\r\n * Links the behavior to the XR experience in which to retrieve hand transform information.\r\n * @param xr xr experience\r\n */\r\n public linkToXRExperience(xr: WebXRExperienceHelper) {\r\n try {\r\n this._eyeTracking = xr.featuresManager.getEnabledFeature(WebXRFeatureName.EYE_TRACKING) as WebXREyeTracking;\r\n } catch {}\r\n\r\n try {\r\n this._handTracking = xr.featuresManager.getEnabledFeature(WebXRFeatureName.HAND_TRACKING) as WebXRHandTracking;\r\n } catch {\r\n alert(\"Hand tracking must be enabled for the Hand Menu to work\");\r\n }\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"handConstraintBehavior.js","sourceRoot":"","sources":["../../../../../../lts/core/generated/Behaviors/Meshes/handConstraintBehavior.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAGjE,OAAO,EAAE,WAAW,EAAE,MAAM,qCAAqC,CAAC;AAKlE,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAG1E;;GAEG;AACH,MAAM,CAAN,IAAY,kBAiBX;AAjBD,WAAY,kBAAkB;IAC1B;;OAEG;IACH,qFAAiB,CAAA;IACjB;;OAEG;IACH,yEAAW,CAAA;IACX;;OAEG;IACH,uEAAU,CAAA;IACV;;OAEG;IACH,yEAAW,CAAA;AACf,CAAC,EAjBW,kBAAkB,KAAlB,kBAAkB,QAiB7B;AAED;;GAEG;AACH,MAAM,CAAN,IAAY,yBASX;AATD,WAAY,yBAAyB;IACjC;;OAEG;IACH,6FAAc,CAAA;IACd;;OAEG;IACH,2FAAa,CAAA;AACjB,CAAC,EATW,yBAAyB,KAAzB,yBAAyB,QASpC;AAED;;GAEG;AACH,MAAM,CAAN,IAAY,wBAkBX;AAlBD,WAAY,wBAAwB;IAChC;;OAEG;IACH,2FAAc,CAAA;IACd;;OAEG;IACH,6EAAO,CAAA;IACP;;;OAGG;IACH,mFAAU,CAAA;IACV;;OAEG;IACH,yFAAa,CAAA;AACjB,CAAC,EAlBW,wBAAwB,KAAxB,wBAAwB,QAkBnC;AAQD;;;GAGG;AACH;IAwDI;;OAEG;IACH;QAtDQ,yBAAoB,GAA8B,IAAI,CAAC;QACvD,cAAS,GAA8B,EAAE,CAAC;QAElD;;WAEG;QACI,6BAAwB,GAA6B,wBAAwB,CAAC,aAAa,CAAC;QAEnG;;;;WAIG;QACI,qBAAgB,GAAW,IAAI,CAAC;QAEvC;;;WAGG;QACI,wBAAmB,GAAW,IAAI,CAAC;QA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;IACL,CAAC;IACL,6BAAC;AAAD,CAAC,AAhRD,IAgRC","sourcesContent":["import type { TransformNode } from \"../../Meshes/transformNode\";\r\nimport type { Nullable } from \"../../types\";\r\nimport { WebXRFeatureName } from \"../../XR/webXRFeaturesManager\";\r\nimport type { WebXREyeTracking } from \"../../XR/features/WebXREyeTracking\";\r\nimport type { WebXRHandTracking } from \"../../XR/features/WebXRHandTracking\";\r\nimport { XRHandJoint } from \"../../XR/features/WebXRHandTracking\";\r\nimport type { WebXRExperienceHelper } from \"../../XR/webXRExperienceHelper\";\r\nimport type { Behavior } from \"../behavior\";\r\nimport type { Observer } from \"../../Misc/observable\";\r\nimport type { Scene } from \"../../scene\";\r\nimport { Quaternion, TmpVectors, Vector3 } from \"../../Maths/math.vector\";\r\nimport type { Ray } from \"../../Culling/ray\";\r\n\r\n/**\r\n * Zones around the hand\r\n */\r\nexport enum HandConstraintZone {\r\n /**\r\n * Above finger tips\r\n */\r\n ABOVE_FINGER_TIPS,\r\n /**\r\n * Next to the thumb\r\n */\r\n RADIAL_SIDE,\r\n /**\r\n * Next to the pinky finger\r\n */\r\n ULNAR_SIDE,\r\n /**\r\n * Below the wrist\r\n */\r\n BELOW_WRIST,\r\n}\r\n\r\n/**\r\n * Orientations for the hand zones and for the attached node\r\n */\r\nexport enum HandConstraintOrientation {\r\n /**\r\n * Orientation is towards the camera\r\n */\r\n LOOK_AT_CAMERA,\r\n /**\r\n * Orientation is determined by the rotation of the palm\r\n */\r\n HAND_ROTATION,\r\n}\r\n\r\n/**\r\n * Orientations for the hand zones and for the attached node\r\n */\r\nexport enum HandConstraintVisibility {\r\n /**\r\n * Constraint is always visible\r\n */\r\n ALWAYS_VISIBLE,\r\n /**\r\n * Constraint is only visible when the palm is up\r\n */\r\n PALM_UP,\r\n /**\r\n * Constraint is only visible when the user is looking at the constraint.\r\n * Uses XR Eye Tracking if enabled/available, otherwise uses camera direction\r\n */\r\n GAZE_FOCUS,\r\n /**\r\n * Constraint is only visible when the palm is up and the user is looking at it\r\n */\r\n PALM_AND_GAZE,\r\n}\r\n\r\ntype HandPoseInfo = {\r\n position: Vector3;\r\n quaternion: Quaternion;\r\n id: string;\r\n};\r\n\r\n/**\r\n * Hand constraint behavior that makes the attached `TransformNode` follow hands in XR experiences.\r\n * @since 5.0.0\r\n */\r\nexport class HandConstraintBehavior implements Behavior<TransformNode> {\r\n private _scene: Scene;\r\n private _node: TransformNode;\r\n private _eyeTracking: Nullable<WebXREyeTracking>;\r\n private _handTracking: Nullable<WebXRHandTracking>;\r\n private _sceneRenderObserver: Nullable<Observer<Scene>> = null;\r\n private _zoneAxis: { [id: number]: Vector3 } = {};\r\n\r\n /**\r\n * Sets the HandConstraintVisibility level for the hand constraint\r\n */\r\n public handConstraintVisibility: HandConstraintVisibility = HandConstraintVisibility.PALM_AND_GAZE;\r\n\r\n /**\r\n * A number from 0.0 to 1.0, marking how restricted the direction the palm faces is for the attached node to be enabled.\r\n * A 1 means the palm must be directly facing the user before the node is enabled, a 0 means it is always enabled.\r\n * Used with HandConstraintVisibility.PALM_UP\r\n */\r\n public palmUpStrictness: number = 0.95;\r\n\r\n /**\r\n * The radius in meters around the center of the hand that the user must gaze inside for the attached node to be enabled and appear.\r\n * Used with HandConstraintVisibility.GAZE_FOCUS\r\n */\r\n public gazeProximityRadius: number = 0.15;\r\n\r\n /**\r\n * Offset distance from the hand in meters\r\n */\r\n public targetOffset: number = 0.1;\r\n\r\n /**\r\n * Where to place the node regarding the center of the hand.\r\n */\r\n public targetZone: HandConstraintZone = HandConstraintZone.ULNAR_SIDE;\r\n\r\n /**\r\n * Orientation mode of the 4 zones around the hand\r\n */\r\n public zoneOrientationMode: HandConstraintOrientation = HandConstraintOrientation.HAND_ROTATION;\r\n /**\r\n * Orientation mode of the node attached to this behavior\r\n */\r\n public nodeOrientationMode: HandConstraintOrientation = HandConstraintOrientation.HAND_ROTATION;\r\n\r\n /**\r\n * Set the hand this behavior should follow. If set to \"none\", it will follow any visible hand (prioritising the left one).\r\n */\r\n public handedness: XRHandedness = \"none\";\r\n\r\n /**\r\n * Rate of interpolation of position and rotation of the attached node.\r\n * Higher values will give a slower interpolation.\r\n */\r\n public lerpTime = 100;\r\n\r\n /**\r\n * Builds a hand constraint behavior\r\n */\r\n constructor() {\r\n // For a right hand\r\n this._zoneAxis[HandConstraintZone.ABOVE_FINGER_TIPS] = new Vector3(0, 1, 0);\r\n this._zoneAxis[HandConstraintZone.RADIAL_SIDE] = new Vector3(-1, 0, 0);\r\n this._zoneAxis[HandConstraintZone.ULNAR_SIDE] = new Vector3(1, 0, 0);\r\n this._zoneAxis[HandConstraintZone.BELOW_WRIST] = new Vector3(0, -1, 0);\r\n }\r\n\r\n /** gets or sets behavior's name */\r\n public get name() {\r\n return \"HandConstraint\";\r\n }\r\n\r\n /** Enable the behavior */\r\n public enable() {\r\n this._node.setEnabled(true);\r\n }\r\n\r\n /** Disable the behavior */\r\n public disable() {\r\n this._node.setEnabled(false);\r\n }\r\n\r\n private _getHandPose(): Nullable<HandPoseInfo> {\r\n if (!this._handTracking) {\r\n return null;\r\n }\r\n\r\n // Retrieve any available hand, starting by the left\r\n let hand;\r\n if (this.handedness === \"none\") {\r\n hand = this._handTracking.getHandByHandedness(\"left\") || this._handTracking.getHandByHandedness(\"right\");\r\n } else {\r\n hand = this._handTracking.getHandByHandedness(this.handedness);\r\n }\r\n\r\n if (hand) {\r\n const pinkyMetacarpal = hand.getJointMesh(XRHandJoint.PINKY_FINGER_METACARPAL);\r\n const middleMetacarpal = hand.getJointMesh(XRHandJoint.MIDDLE_FINGER_METACARPAL);\r\n const wrist = hand.getJointMesh(XRHandJoint.WRIST);\r\n\r\n if (wrist && middleMetacarpal && pinkyMetacarpal) {\r\n const handPose: HandPoseInfo = { position: middleMetacarpal.absolutePosition, quaternion: new Quaternion(), id: hand.xrController.uniqueId };\r\n\r\n // palm forward\r\n const up = TmpVectors.Vector3[0];\r\n const forward = TmpVectors.Vector3[1];\r\n const left = TmpVectors.Vector3[2];\r\n up.copyFrom(middleMetacarpal.absolutePosition).subtractInPlace(wrist.absolutePosition).normalize();\r\n forward.copyFrom(pinkyMetacarpal.absolutePosition).subtractInPlace(middleMetacarpal.absolutePosition).normalize();\r\n\r\n // Create vectors for a rotation quaternion, where forward points out from the palm\r\n Vector3.CrossToRef(up, forward, forward);\r\n Vector3.CrossToRef(forward, up, left);\r\n\r\n Quaternion.FromLookDirectionLHToRef(forward, up, handPose.quaternion);\r\n\r\n return handPose;\r\n }\r\n }\r\n\r\n return null;\r\n }\r\n\r\n /**\r\n * Initializes the hand constraint behavior\r\n */\r\n public init() {}\r\n\r\n /**\r\n * Attaches the hand constraint to a `TransformNode`\r\n * @param node defines the node to attach the behavior to\r\n */\r\n public attach(node: TransformNode): void {\r\n this._node = node;\r\n this._scene = node.getScene();\r\n\r\n if (!this._node.rotationQuaternion) {\r\n this._node.rotationQuaternion = Quaternion.RotationYawPitchRoll(this._node.rotation.y, this._node.rotation.x, this._node.rotation.z);\r\n }\r\n\r\n let lastTick = Date.now();\r\n this._sceneRenderObserver = this._scene.onBeforeRenderObservable.add(() => {\r\n const pose = this._getHandPose();\r\n\r\n this._node.reservedDataStore = this._node.reservedDataStore || {};\r\n this._node.reservedDataStore.nearInteraction = this._node.reservedDataStore.nearInteraction || {};\r\n this._node.reservedDataStore.nearInteraction.excludedControllerId = null;\r\n\r\n if (pose) {\r\n const zoneOffset = TmpVectors.Vector3[0];\r\n const camera = this._scene.activeCamera;\r\n\r\n zoneOffset.copyFrom(this._zoneAxis[this.targetZone]);\r\n\r\n const cameraLookAtQuaternion = TmpVectors.Quaternion[0];\r\n if (camera && (this.zoneOrientationMode === HandConstraintOrientation.LOOK_AT_CAMERA || this.nodeOrientationMode === HandConstraintOrientation.LOOK_AT_CAMERA)) {\r\n const toCamera = TmpVectors.Vector3[1];\r\n toCamera.copyFrom(camera.position).subtractInPlace(pose.position).normalize();\r\n if (this._scene.useRightHandedSystem) {\r\n Quaternion.FromLookDirectionRHToRef(toCamera, Vector3.UpReadOnly, cameraLookAtQuaternion);\r\n } else {\r\n Quaternion.FromLookDirectionLHToRef(toCamera, Vector3.UpReadOnly, cameraLookAtQuaternion);\r\n }\r\n }\r\n\r\n if (this.zoneOrientationMode === HandConstraintOrientation.HAND_ROTATION) {\r\n pose.quaternion.toRotationMatrix(TmpVectors.Matrix[0]);\r\n } else {\r\n cameraLookAtQuaternion.toRotationMatrix(TmpVectors.Matrix[0]);\r\n }\r\n\r\n Vector3.TransformNormalToRef(zoneOffset, TmpVectors.Matrix[0], zoneOffset);\r\n zoneOffset.scaleInPlace(this.targetOffset);\r\n\r\n const targetPosition = TmpVectors.Vector3[2];\r\n const targetRotation = TmpVectors.Quaternion[1];\r\n targetPosition.copyFrom(pose.position).addInPlace(zoneOffset);\r\n\r\n if (this.nodeOrientationMode === HandConstraintOrientation.HAND_ROTATION) {\r\n targetRotation.copyFrom(pose.quaternion);\r\n } else {\r\n targetRotation.copyFrom(cameraLookAtQuaternion);\r\n }\r\n\r\n const elapsed = Date.now() - lastTick;\r\n\r\n Vector3.SmoothToRef(this._node.position, targetPosition, elapsed, this.lerpTime, this._node.position);\r\n Quaternion.SmoothToRef(this._node.rotationQuaternion!, targetRotation, elapsed, this.lerpTime, this._node.rotationQuaternion!);\r\n\r\n this._node.reservedDataStore.nearInteraction.excludedControllerId = pose.id;\r\n }\r\n\r\n this._setVisibility(pose);\r\n\r\n lastTick = Date.now();\r\n });\r\n }\r\n\r\n private _setVisibility(pose: Nullable<HandPoseInfo>) {\r\n let palmVisible = true;\r\n let gazeVisible = true;\r\n const camera = this._scene.activeCamera;\r\n\r\n if (camera) {\r\n const cameraForward = camera.getForwardRay();\r\n\r\n if (this.handConstraintVisibility === HandConstraintVisibility.GAZE_FOCUS || this.handConstraintVisibility === HandConstraintVisibility.PALM_AND_GAZE) {\r\n gazeVisible = false;\r\n let gaze: Ray | undefined;\r\n if (this._eyeTracking) {\r\n gaze = this._eyeTracking.getEyeGaze()!;\r\n }\r\n\r\n gaze = gaze || cameraForward;\r\n\r\n const gazeToBehavior = TmpVectors.Vector3[0];\r\n if (pose) {\r\n pose.position.subtractToRef(gaze.origin, gazeToBehavior);\r\n } else {\r\n this._node.getAbsolutePosition().subtractToRef(gaze.origin, gazeToBehavior);\r\n }\r\n\r\n const projectedDistance = Vector3.Dot(gazeToBehavior, gaze.direction);\r\n const projectedSquared = projectedDistance * projectedDistance;\r\n\r\n if (projectedDistance > 0) {\r\n const radiusSquared = gazeToBehavior.lengthSquared() - projectedSquared;\r\n if (radiusSquared < this.gazeProximityRadius * this.gazeProximityRadius) {\r\n gazeVisible = true;\r\n }\r\n }\r\n }\r\n\r\n if (this.handConstraintVisibility === HandConstraintVisibility.PALM_UP || this.handConstraintVisibility === HandConstraintVisibility.PALM_AND_GAZE) {\r\n palmVisible = false;\r\n\r\n if (pose) {\r\n const palmDirection = TmpVectors.Vector3[0];\r\n Vector3.LeftHandedForwardReadOnly.rotateByQuaternionToRef(pose.quaternion, palmDirection);\r\n\r\n if (Vector3.Dot(palmDirection, cameraForward.direction) > this.palmUpStrictness * 2 - 1) {\r\n palmVisible = true;\r\n }\r\n }\r\n }\r\n }\r\n\r\n this._node.setEnabled(palmVisible && gazeVisible);\r\n }\r\n\r\n /**\r\n * Detaches the behavior from the `TransformNode`\r\n */\r\n public detach(): void {\r\n this._scene.onBeforeRenderObservable.remove(this._sceneRenderObserver);\r\n }\r\n\r\n /**\r\n * Links the behavior to the XR experience in which to retrieve hand transform information.\r\n * @param xr xr experience\r\n */\r\n public linkToXRExperience(xr: WebXRExperienceHelper) {\r\n try {\r\n this._eyeTracking = xr.featuresManager.getEnabledFeature(WebXRFeatureName.EYE_TRACKING) as WebXREyeTracking;\r\n } catch {}\r\n\r\n try {\r\n this._handTracking = xr.featuresManager.getEnabledFeature(WebXRFeatureName.HAND_TRACKING) as WebXRHandTracking;\r\n } catch {\r\n alert(\"Hand tracking must be enabled for the Hand Menu to work\");\r\n }\r\n }\r\n}\r\n"]}
|
|
@@ -18,10 +18,15 @@ export declare class PointerDragBehavior implements Behavior<AbstractMesh> {
|
|
|
18
18
|
private _beforeRenderObserver;
|
|
19
19
|
private static _PlaneScene;
|
|
20
20
|
private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
|
|
21
|
+
private _activeDragButton;
|
|
21
22
|
/**
|
|
22
23
|
* The maximum tolerated angle between the drag plane and dragging pointer rays to trigger pointer events. Set to 0 to allow any angle (default: 0)
|
|
23
24
|
*/
|
|
24
25
|
maxDragAngle: number;
|
|
26
|
+
/**
|
|
27
|
+
* Butttons that can be used to initiate a drag
|
|
28
|
+
*/
|
|
29
|
+
dragButtons: number[];
|
|
25
30
|
/**
|
|
26
31
|
* @hidden
|
|
27
32
|
*/
|
|
@@ -18,10 +18,15 @@ var PointerDragBehavior = /** @class */ (function () {
|
|
|
18
18
|
*/
|
|
19
19
|
function PointerDragBehavior(options) {
|
|
20
20
|
this._useAlternatePickedPointAboveMaxDragAngleDragSpeed = -1.1;
|
|
21
|
+
this._activeDragButton = -1;
|
|
21
22
|
/**
|
|
22
23
|
* The maximum tolerated angle between the drag plane and dragging pointer rays to trigger pointer events. Set to 0 to allow any angle (default: 0)
|
|
23
24
|
*/
|
|
24
25
|
this.maxDragAngle = 0;
|
|
26
|
+
/**
|
|
27
|
+
* Butttons that can be used to initiate a drag
|
|
28
|
+
*/
|
|
29
|
+
this.dragButtons = [0, 1, 2];
|
|
25
30
|
/**
|
|
26
31
|
* @hidden
|
|
27
32
|
*/
|
|
@@ -212,6 +217,7 @@ var PointerDragBehavior = /** @class */ (function () {
|
|
|
212
217
|
// If behavior is disabled before releaseDrag is ever called, call it now.
|
|
213
218
|
if (_this._attachedToElement) {
|
|
214
219
|
_this.releaseDrag();
|
|
220
|
+
_this._activeDragButton = -1;
|
|
215
221
|
}
|
|
216
222
|
return;
|
|
217
223
|
}
|
|
@@ -224,12 +230,18 @@ var PointerDragBehavior = /** @class */ (function () {
|
|
|
224
230
|
pointerInfo.pickInfo.pickedPoint &&
|
|
225
231
|
pointerInfo.pickInfo.ray &&
|
|
226
232
|
pickPredicate(pointerInfo.pickInfo.pickedMesh)) {
|
|
227
|
-
_this.
|
|
233
|
+
if (_this._activeDragButton === -1 && _this.dragButtons.indexOf(pointerInfo.event.button) !== -1) {
|
|
234
|
+
_this._activeDragButton = pointerInfo.event.button;
|
|
235
|
+
_this._startDrag(pointerInfo.event.pointerId, pointerInfo.pickInfo.ray, pointerInfo.pickInfo.pickedPoint);
|
|
236
|
+
}
|
|
228
237
|
}
|
|
229
238
|
}
|
|
230
239
|
else if (pointerInfo.type == PointerEventTypes.POINTERUP) {
|
|
231
|
-
if (_this.startAndReleaseDragOnPointerEvents &&
|
|
240
|
+
if (_this.startAndReleaseDragOnPointerEvents &&
|
|
241
|
+
_this.currentDraggingPointerId == pointerInfo.event.pointerId &&
|
|
242
|
+
_this._activeDragButton === pointerInfo.event.button) {
|
|
232
243
|
_this.releaseDrag();
|
|
244
|
+
_this._activeDragButton = -1;
|
|
233
245
|
}
|
|
234
246
|
}
|
|
235
247
|
else if (pointerInfo.type == PointerEventTypes.POINTERMOVE) {
|
|
@@ -495,6 +507,7 @@ var PointerDragBehavior = /** @class */ (function () {
|
|
|
495
507
|
this._dragPlane.dispose();
|
|
496
508
|
}
|
|
497
509
|
this.releaseDrag();
|
|
510
|
+
this._activeDragButton = -1;
|
|
498
511
|
};
|
|
499
512
|
PointerDragBehavior._AnyMouseId = -2;
|
|
500
513
|
return PointerDragBehavior;
|