@onerjs/core 8.30.9 → 8.31.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/Behaviors/Cameras/interpolatingBehavior.d.ts +52 -0
- package/Behaviors/Cameras/interpolatingBehavior.js +105 -0
- package/Behaviors/Cameras/interpolatingBehavior.js.map +1 -0
- package/Cameras/Inputs/arcRotateCameraPointersInput.d.ts +5 -20
- package/Cameras/Inputs/arcRotateCameraPointersInput.js +9 -69
- package/Cameras/Inputs/arcRotateCameraPointersInput.js.map +1 -1
- package/Cameras/Inputs/geospatialCameraPointersInput.d.ts +10 -2
- package/Cameras/Inputs/geospatialCameraPointersInput.js +20 -2
- package/Cameras/Inputs/geospatialCameraPointersInput.js.map +1 -1
- package/Cameras/Inputs/orbitCameraPointersInput.d.ts +49 -0
- package/Cameras/Inputs/orbitCameraPointersInput.js +105 -0
- package/Cameras/Inputs/orbitCameraPointersInput.js.map +1 -0
- package/Cameras/cameraMovement.d.ts +150 -0
- package/Cameras/cameraMovement.js +190 -0
- package/Cameras/cameraMovement.js.map +1 -0
- package/Particles/Node/Blocks/Update/basicColorUpdateBlock.d.ts +1 -1
- package/Particles/Node/Blocks/Update/basicColorUpdateBlock.js +1 -1
- package/Particles/Node/Blocks/Update/basicColorUpdateBlock.js.map +1 -1
- package/Particles/Node/Blocks/Update/basicPositionUpdateBlock.d.ts +1 -1
- package/Particles/Node/Blocks/Update/basicPositionUpdateBlock.js +1 -1
- package/Particles/Node/Blocks/Update/basicPositionUpdateBlock.js.map +1 -1
- package/Particles/Node/Blocks/Update/updateSizeBlock.d.ts +35 -0
- package/Particles/Node/Blocks/Update/updateSizeBlock.js +73 -0
- package/Particles/Node/Blocks/Update/updateSizeBlock.js.map +1 -0
- package/Particles/Node/Blocks/index.d.ts +1 -0
- package/Particles/Node/Blocks/index.js +1 -0
- package/Particles/Node/Blocks/index.js.map +1 -1
- package/Particles/Node/Blocks/particleInputBlock.js +1 -0
- package/Particles/Node/Blocks/particleInputBlock.js.map +1 -1
- package/Particles/Node/Blocks/particleRandomBlock.d.ts +5 -2
- package/Particles/Node/Blocks/particleRandomBlock.js +32 -14
- package/Particles/Node/Blocks/particleRandomBlock.js.map +1 -1
- package/Particles/Node/Blocks/systemBlock.d.ts +8 -0
- package/Particles/Node/Blocks/systemBlock.js +8 -0
- package/Particles/Node/Blocks/systemBlock.js.map +1 -1
- package/Particles/Node/Enums/nodeParticleContextualSources.d.ts +3 -1
- package/Particles/Node/Enums/nodeParticleContextualSources.js +2 -0
- package/Particles/Node/Enums/nodeParticleContextualSources.js.map +1 -1
- package/Particles/Node/nodeParticleBuildState.js +2 -0
- package/Particles/Node/nodeParticleBuildState.js.map +1 -1
- package/Particles/Node/nodeParticleSystemSet.helper.d.ts +0 -2
- package/Particles/Node/nodeParticleSystemSet.helper.js +162 -47
- package/Particles/Node/nodeParticleSystemSet.helper.js.map +1 -1
- package/Particles/thinParticleSystem.d.ts +3 -3
- package/Particles/thinParticleSystem.js +3 -3
- package/Particles/thinParticleSystem.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { __decorate } from "../../tslib.es6.js";
|
|
2
|
+
import { serialize } from "../../Misc/decorators.js";
|
|
3
|
+
import { BaseCameraPointersInput } from "./BaseCameraPointersInput.js";
|
|
4
|
+
/**
|
|
5
|
+
* Used by both arcrotatecamera and geospatialcamera, OrbitCameraPointersInputs handle pinchToZoom and multiTouchPanning
|
|
6
|
+
* as though you are orbiting around a target point
|
|
7
|
+
*/
|
|
8
|
+
export class OrbitCameraPointersInput extends BaseCameraPointersInput {
|
|
9
|
+
constructor() {
|
|
10
|
+
super(...arguments);
|
|
11
|
+
/**
|
|
12
|
+
* Defines whether zoom (2 fingers pinch) is enabled through multitouch
|
|
13
|
+
*/
|
|
14
|
+
this.pinchZoom = true;
|
|
15
|
+
/**
|
|
16
|
+
* Defines whether panning (2 fingers swipe) is enabled through multitouch.
|
|
17
|
+
*/
|
|
18
|
+
this.multiTouchPanning = true;
|
|
19
|
+
/**
|
|
20
|
+
* Defines whether panning is enabled for both pan (2 fingers swipe) and
|
|
21
|
+
* zoom (pinch) through multitouch.
|
|
22
|
+
*/
|
|
23
|
+
this.multiTouchPanAndZoom = true;
|
|
24
|
+
this._isPinching = false;
|
|
25
|
+
this._twoFingerActivityCount = 0;
|
|
26
|
+
this._shouldStartPinchZoom = false;
|
|
27
|
+
}
|
|
28
|
+
_computePinchZoom(_previousPinchSquaredDistance, _pinchSquaredDistance) { }
|
|
29
|
+
_computeMultiTouchPanning(_previousMultiTouchPanPosition, _multiTouchPanPosition) { }
|
|
30
|
+
/**
|
|
31
|
+
* Called on pointer POINTERMOVE event if multiple touches are active.
|
|
32
|
+
* Override this method to provide functionality.
|
|
33
|
+
* @param _pointA First point in the pair
|
|
34
|
+
* @param _pointB Second point in the pair
|
|
35
|
+
* @param previousPinchSquaredDistance Sqr Distance between the points the last time this event was fired (by this input)
|
|
36
|
+
* @param pinchSquaredDistance Sqr Distance between the points this time
|
|
37
|
+
* @param previousMultiTouchPanPosition Previous center point between the points
|
|
38
|
+
* @param multiTouchPanPosition Current center point between the points
|
|
39
|
+
*/
|
|
40
|
+
onMultiTouch(_pointA, _pointB, previousPinchSquaredDistance, pinchSquaredDistance, previousMultiTouchPanPosition, multiTouchPanPosition) {
|
|
41
|
+
if (previousPinchSquaredDistance === 0 && previousMultiTouchPanPosition === null) {
|
|
42
|
+
// First time this method is called for new pinch.
|
|
43
|
+
// Next time this is called there will be a
|
|
44
|
+
// previousPinchSquaredDistance and pinchSquaredDistance to compare.
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
if (pinchSquaredDistance === 0 && multiTouchPanPosition === null) {
|
|
48
|
+
// Last time this method is called at the end of a pinch.
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
// Zoom and panning enabled together
|
|
52
|
+
if (this.multiTouchPanAndZoom) {
|
|
53
|
+
this._computePinchZoom(previousPinchSquaredDistance, pinchSquaredDistance);
|
|
54
|
+
this._computeMultiTouchPanning(previousMultiTouchPanPosition, multiTouchPanPosition);
|
|
55
|
+
// Zoom and panning enabled but only one at a time
|
|
56
|
+
}
|
|
57
|
+
else if (this.multiTouchPanning && this.pinchZoom) {
|
|
58
|
+
this._twoFingerActivityCount++;
|
|
59
|
+
if (this._isPinching || this._shouldStartPinchZoom) {
|
|
60
|
+
// Since pinch has not been active long, assume we intend to zoom.
|
|
61
|
+
this._computePinchZoom(previousPinchSquaredDistance, pinchSquaredDistance);
|
|
62
|
+
// Since we are pinching, remain pinching on next iteration.
|
|
63
|
+
this._isPinching = true;
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
// Pause between pinch starting and moving implies not a zoom event. Pan instead.
|
|
67
|
+
this._computeMultiTouchPanning(previousMultiTouchPanPosition, multiTouchPanPosition);
|
|
68
|
+
}
|
|
69
|
+
// Panning enabled, zoom disabled
|
|
70
|
+
}
|
|
71
|
+
else if (this.multiTouchPanning) {
|
|
72
|
+
this._computeMultiTouchPanning(previousMultiTouchPanPosition, multiTouchPanPosition);
|
|
73
|
+
// Zoom enabled, panning disabled
|
|
74
|
+
}
|
|
75
|
+
else if (this.pinchZoom) {
|
|
76
|
+
this._computePinchZoom(previousPinchSquaredDistance, pinchSquaredDistance);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Called each time a new POINTERUP event occurs. Ie, for each button
|
|
81
|
+
* release.
|
|
82
|
+
* @param _evt Defines the event to track
|
|
83
|
+
*/
|
|
84
|
+
onButtonUp(_evt) {
|
|
85
|
+
this._twoFingerActivityCount = 0;
|
|
86
|
+
this._isPinching = false;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Called when window becomes inactive.
|
|
90
|
+
*/
|
|
91
|
+
onLostFocus() {
|
|
92
|
+
this._twoFingerActivityCount = 0;
|
|
93
|
+
this._isPinching = false;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
__decorate([
|
|
97
|
+
serialize()
|
|
98
|
+
], OrbitCameraPointersInput.prototype, "pinchZoom", void 0);
|
|
99
|
+
__decorate([
|
|
100
|
+
serialize()
|
|
101
|
+
], OrbitCameraPointersInput.prototype, "multiTouchPanning", void 0);
|
|
102
|
+
__decorate([
|
|
103
|
+
serialize()
|
|
104
|
+
], OrbitCameraPointersInput.prototype, "multiTouchPanAndZoom", void 0);
|
|
105
|
+
//# sourceMappingURL=orbitCameraPointersInput.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"orbitCameraPointersInput.js","sourceRoot":"","sources":["../../../../../dev/core/src/Cameras/Inputs/orbitCameraPointersInput.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAGlD,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAEpE;;;GAGG;AACH,MAAM,OAAgB,wBAAyB,SAAQ,uBAAuB;IAA9E;;QACI;;WAEG;QAEI,cAAS,GAAY,IAAI,CAAC;QAEjC;;WAEG;QAEI,sBAAiB,GAAY,IAAI,CAAC;QAEzC;;;WAGG;QAEI,yBAAoB,GAAY,IAAI,CAAC;QAElC,gBAAW,GAAY,KAAK,CAAC;QAC7B,4BAAuB,GAAW,CAAC,CAAC;QACpC,0BAAqB,GAAY,KAAK,CAAC;IAkFrD,CAAC;IAhFa,iBAAiB,CAAC,6BAAqC,EAAE,qBAA6B,IAAS,CAAC;IAEhG,yBAAyB,CAAC,8BAAsD,EAAE,sBAA8C,IAAS,CAAC;IAEpJ;;;;;;;;;OASG;IACa,YAAY,CACxB,OAA+B,EAC/B,OAA+B,EAC/B,4BAAoC,EACpC,oBAA4B,EAC5B,6BAAqD,EACrD,qBAA6C;QAE7C,IAAI,4BAA4B,KAAK,CAAC,IAAI,6BAA6B,KAAK,IAAI,EAAE,CAAC;YAC/E,kDAAkD;YAClD,2CAA2C;YAC3C,oEAAoE;YACpE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ED;;OAEG;IACa,WAAW;QACvB,IAAI,CAAC,uBAAuB,GAAG,CAAC,CAAC;QACjC,IAAI,CAAC,WAAW,GAAG,KAAK,CAAC;IAC7B,CAAC;CACJ;AAnGU;IADN,SAAS,EAAE;2DACqB;AAM1B;IADN,SAAS,EAAE;mEAC6B;AAOlC;IADN,SAAS,EAAE;sEACgC","sourcesContent":["import type { Nullable } from \"../../types\";\r\nimport { serialize } from \"../../Misc/decorators\";\r\nimport type { PointerTouch } from \"../../Events/pointerEvents\";\r\nimport type { IPointerEvent } from \"../../Events/deviceInputEvents\";\r\nimport { BaseCameraPointersInput } from \"./BaseCameraPointersInput\";\r\n\r\n/**\r\n * Used by both arcrotatecamera and geospatialcamera, OrbitCameraPointersInputs handle pinchToZoom and multiTouchPanning\r\n * as though you are orbiting around a target point\r\n */\r\nexport abstract class OrbitCameraPointersInput extends BaseCameraPointersInput {\r\n /**\r\n * Defines whether zoom (2 fingers pinch) is enabled through multitouch\r\n */\r\n @serialize()\r\n public pinchZoom: boolean = true;\r\n\r\n /**\r\n * Defines whether panning (2 fingers swipe) is enabled through multitouch.\r\n */\r\n @serialize()\r\n public multiTouchPanning: boolean = true;\r\n\r\n /**\r\n * Defines whether panning is enabled for both pan (2 fingers swipe) and\r\n * zoom (pinch) through multitouch.\r\n */\r\n @serialize()\r\n public multiTouchPanAndZoom: boolean = true;\r\n\r\n protected _isPinching: boolean = false;\r\n protected _twoFingerActivityCount: number = 0;\r\n protected _shouldStartPinchZoom: boolean = false;\r\n\r\n protected _computePinchZoom(_previousPinchSquaredDistance: number, _pinchSquaredDistance: number): void {}\r\n\r\n protected _computeMultiTouchPanning(_previousMultiTouchPanPosition: Nullable<PointerTouch>, _multiTouchPanPosition: Nullable<PointerTouch>): void {}\r\n\r\n /**\r\n * Called on pointer POINTERMOVE event if multiple touches are active.\r\n * Override this method to provide functionality.\r\n * @param _pointA First point in the pair\r\n * @param _pointB Second point in the pair\r\n * @param previousPinchSquaredDistance Sqr Distance between the points the last time this event was fired (by this input)\r\n * @param pinchSquaredDistance Sqr Distance between the points this time\r\n * @param previousMultiTouchPanPosition Previous center point between the points\r\n * @param multiTouchPanPosition Current center point between the points\r\n */\r\n public override onMultiTouch(\r\n _pointA: Nullable<PointerTouch>,\r\n _pointB: Nullable<PointerTouch>,\r\n previousPinchSquaredDistance: number,\r\n pinchSquaredDistance: number,\r\n previousMultiTouchPanPosition: Nullable<PointerTouch>,\r\n multiTouchPanPosition: Nullable<PointerTouch>\r\n ): void {\r\n if (previousPinchSquaredDistance === 0 && previousMultiTouchPanPosition === null) {\r\n // First time this method is called for new pinch.\r\n // Next time this is called there will be a\r\n // previousPinchSquaredDistance and pinchSquaredDistance to compare.\r\n return;\r\n }\r\n if (pinchSquaredDistance === 0 && multiTouchPanPosition === null) {\r\n // Last time this method is called at the end of a pinch.\r\n return;\r\n }\r\n\r\n // Zoom and panning enabled together\r\n if (this.multiTouchPanAndZoom) {\r\n this._computePinchZoom(previousPinchSquaredDistance, pinchSquaredDistance);\r\n this._computeMultiTouchPanning(previousMultiTouchPanPosition, multiTouchPanPosition);\r\n\r\n // Zoom and panning enabled but only one at a time\r\n } else if (this.multiTouchPanning && this.pinchZoom) {\r\n this._twoFingerActivityCount++;\r\n\r\n if (this._isPinching || this._shouldStartPinchZoom) {\r\n // Since pinch has not been active long, assume we intend to zoom.\r\n this._computePinchZoom(previousPinchSquaredDistance, pinchSquaredDistance);\r\n\r\n // Since we are pinching, remain pinching on next iteration.\r\n this._isPinching = true;\r\n } else {\r\n // Pause between pinch starting and moving implies not a zoom event. Pan instead.\r\n this._computeMultiTouchPanning(previousMultiTouchPanPosition, multiTouchPanPosition);\r\n }\r\n\r\n // Panning enabled, zoom disabled\r\n } else if (this.multiTouchPanning) {\r\n this._computeMultiTouchPanning(previousMultiTouchPanPosition, multiTouchPanPosition);\r\n\r\n // Zoom enabled, panning disabled\r\n } else if (this.pinchZoom) {\r\n this._computePinchZoom(previousPinchSquaredDistance, pinchSquaredDistance);\r\n }\r\n }\r\n\r\n /**\r\n * Called each time a new POINTERUP event occurs. Ie, for each button\r\n * release.\r\n * @param _evt Defines the event to track\r\n */\r\n public override onButtonUp(_evt: IPointerEvent): void {\r\n this._twoFingerActivityCount = 0;\r\n this._isPinching = false;\r\n }\r\n\r\n /**\r\n * Called when window becomes inactive.\r\n */\r\n public override onLostFocus(): void {\r\n this._twoFingerActivityCount = 0;\r\n this._isPinching = false;\r\n }\r\n}\r\n"]}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import type { Scene } from "../scene.js";
|
|
2
|
+
import { Vector3 } from "../Maths/math.vector.js";
|
|
3
|
+
import type { InterpolatingBehavior } from "../Behaviors/Cameras/interpolatingBehavior.js";
|
|
4
|
+
/**
|
|
5
|
+
* @experimental
|
|
6
|
+
* This class is subject to change as geospatial camera evolves.
|
|
7
|
+
*
|
|
8
|
+
* It is intended to hold all logic related to converting input pixel deltas into current frame deltas, taking speed / framerate into account
|
|
9
|
+
* to ensure smooth frame-rate-independent movement
|
|
10
|
+
*/
|
|
11
|
+
export declare class CameraMovement {
|
|
12
|
+
protected _cameraPosition: Vector3;
|
|
13
|
+
protected _behavior?: InterpolatingBehavior | undefined;
|
|
14
|
+
protected _scene: Scene;
|
|
15
|
+
/**
|
|
16
|
+
* Should be set by input classes to indicates whether there is active input this frame
|
|
17
|
+
* This helps us differentiate between 0 pixel delta due to no input vs user actively holding still
|
|
18
|
+
*/
|
|
19
|
+
activeInput: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* ------------ Speed ----------------
|
|
22
|
+
* Speed defines the amount of camera movement expected per input pixel movement
|
|
23
|
+
* -----------------------------------
|
|
24
|
+
*/
|
|
25
|
+
/**
|
|
26
|
+
* Desired coordinate unit movement per input pixel when zooming
|
|
27
|
+
*/
|
|
28
|
+
zoomSpeed: number;
|
|
29
|
+
/**
|
|
30
|
+
* Desired coordinate unit movement per input pixel when panning
|
|
31
|
+
*/
|
|
32
|
+
panSpeed: number;
|
|
33
|
+
/**
|
|
34
|
+
* Desired radians movement per input pixel when rotating along x axis
|
|
35
|
+
*/
|
|
36
|
+
rotationXSpeed: number;
|
|
37
|
+
/**
|
|
38
|
+
* Desired radians movement per input pixel when rotating along y axis
|
|
39
|
+
*/
|
|
40
|
+
rotationYSpeed: number;
|
|
41
|
+
/**
|
|
42
|
+
* ----------- Speed multipliers ---------------
|
|
43
|
+
* Multipliers allow movement classes to modify the effective speed dynamically per-frame
|
|
44
|
+
* (ex: scale zoom based on distance from target)
|
|
45
|
+
* -----------------------------------
|
|
46
|
+
*/
|
|
47
|
+
/**
|
|
48
|
+
* Multiplied atop zoom speed. Used to dynamically adjust zoom speed based on per-frame context (ex: zoom faster when further from target)
|
|
49
|
+
*/
|
|
50
|
+
protected _zoomSpeedMultiplier: number;
|
|
51
|
+
/**
|
|
52
|
+
* Multiplied atop pan speed. Used to dynamically adjust pan speed based on per-frame context (ex: pan slowly when close to target)
|
|
53
|
+
*/
|
|
54
|
+
protected _panSpeedMultiplier: number;
|
|
55
|
+
/**
|
|
56
|
+
* ---------- Inertia ----------------
|
|
57
|
+
* Inertia represents the decay factor per-frame applied to the velocity when there is no user input.
|
|
58
|
+
* 0 = No inertia, instant stop (velocity immediately becomes 0)
|
|
59
|
+
* 0.5 = Strong decay, velocity halves every frame at 60fps
|
|
60
|
+
* 0.9 = Moderate inertia, velocity retains 90% per frame at 60fps
|
|
61
|
+
* 0.95 = High inertia, smooth glide, velocity retains 95% per frame at 60fps
|
|
62
|
+
* 1 = Infinite inertia, never stops (velocity never decays)
|
|
63
|
+
* -----------------------------------
|
|
64
|
+
*/
|
|
65
|
+
/**
|
|
66
|
+
* Inertia applied to the zoom velocity when there is no user input.
|
|
67
|
+
* Higher inertia === slower decay, velocity retains more of its value each frame
|
|
68
|
+
*/
|
|
69
|
+
zoomInertia: number;
|
|
70
|
+
/**
|
|
71
|
+
* Inertia applied to the panning velocity when there is no user input.
|
|
72
|
+
* Higher inertia === slower decay, velocity retains more of its value each frame
|
|
73
|
+
*/
|
|
74
|
+
panInertia: number;
|
|
75
|
+
/**
|
|
76
|
+
* Inertia applied to the rotation velocity when there is no user input.
|
|
77
|
+
* Higher inertia === slower decay, velocity retains more of its value each frame
|
|
78
|
+
*/
|
|
79
|
+
rotationInertia: number;
|
|
80
|
+
/**
|
|
81
|
+
* ---------- Accumulated Pixel Deltas -----------
|
|
82
|
+
* Pixel inputs accumulated throughout the frame by input classes (reset each frame after processing)
|
|
83
|
+
* -----------------------------------
|
|
84
|
+
*/
|
|
85
|
+
/**
|
|
86
|
+
* Accumulated pixel delta (by input classes) for zoom this frame
|
|
87
|
+
* Read by computeCurrentFrameDeltas() function and converted into currentFrameTranslationDelta (taking speed into account)
|
|
88
|
+
* Reset to zero after each frame
|
|
89
|
+
*/
|
|
90
|
+
zoomAccumulatedPixels: number;
|
|
91
|
+
/**
|
|
92
|
+
* Accumulated pixel delta (by input classes) for panning this frame
|
|
93
|
+
* Read by computeCurrentFrameDeltas() function and converted into currentFrameTranslationDelta (taking speed into account)
|
|
94
|
+
* Reset to zero after each frame
|
|
95
|
+
*/
|
|
96
|
+
panAccumulatedPixels: Vector3;
|
|
97
|
+
/**
|
|
98
|
+
* Accumulated pixel delta (by input classes) for rotation this frame
|
|
99
|
+
* Read by computeCurrentFrameDeltas() function and converted into currentFrameTranslationDelta (taking speed into account)
|
|
100
|
+
* Reset to zero after each frame
|
|
101
|
+
*/
|
|
102
|
+
rotationAccumulatedPixels: Vector3;
|
|
103
|
+
/**
|
|
104
|
+
* ---------- Current Frame Movement Deltas -----------
|
|
105
|
+
* Deltas read on each frame by camera class in order to move the camera
|
|
106
|
+
* -----------------------------------
|
|
107
|
+
*/
|
|
108
|
+
/**
|
|
109
|
+
* Zoom delta to apply to camera this frame, computed by computeCurrentFrameDeltas() from zoomPixelDelta (taking speed into account)
|
|
110
|
+
*/
|
|
111
|
+
zoomDeltaCurrentFrame: number;
|
|
112
|
+
/**
|
|
113
|
+
* Pan delta to apply to camera this frame, computed by computeCurrentFrameDeltas() from panPixelDelta (taking speed into account)
|
|
114
|
+
*/
|
|
115
|
+
panDeltaCurrentFrame: Vector3;
|
|
116
|
+
/**
|
|
117
|
+
* Rotation delta to apply to camera this frame, computed by computeCurrentFrameDeltas() from rotationPixelDelta (taking speed into account)
|
|
118
|
+
*/
|
|
119
|
+
rotationDeltaCurrentFrame: Vector3;
|
|
120
|
+
/**
|
|
121
|
+
* ---------- Velocity -----------
|
|
122
|
+
* Used to track velocity between frames for inertia calculation
|
|
123
|
+
* -----------------------------------
|
|
124
|
+
*/
|
|
125
|
+
/**
|
|
126
|
+
* Zoom velocity used for inertia calculations (movement / time)
|
|
127
|
+
*/
|
|
128
|
+
protected _zoomVelocity: number;
|
|
129
|
+
/**
|
|
130
|
+
* Pan velocity used for inertia calculations (movement / time)
|
|
131
|
+
*/
|
|
132
|
+
private _panVelocity;
|
|
133
|
+
/**
|
|
134
|
+
* Rotation velocity used for inertia calculations (movement / time)
|
|
135
|
+
*/
|
|
136
|
+
private _rotationVelocity;
|
|
137
|
+
/**
|
|
138
|
+
* Used when calculating inertial decay. Default to 60fps
|
|
139
|
+
*/
|
|
140
|
+
private _prevFrameTimeMs;
|
|
141
|
+
constructor(scene: Scene, _cameraPosition: Vector3, _behavior?: InterpolatingBehavior | undefined);
|
|
142
|
+
/**
|
|
143
|
+
* When called, will take the accumulated pixel deltas set by input classes and convert them into current frame deltas, stored in currentFrameMovementDelta properties
|
|
144
|
+
* Takes speed, scaling, inertia, and framerate into account to ensure smooth movement
|
|
145
|
+
* Zeros out pixelDeltas before returning
|
|
146
|
+
*/
|
|
147
|
+
computeCurrentFrameDeltas(): void;
|
|
148
|
+
get isInterpolating(): boolean;
|
|
149
|
+
private _calculateCurrentVelocity;
|
|
150
|
+
}
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
import { Vector3 } from "../Maths/math.vector.js";
|
|
2
|
+
import { Epsilon } from "../Maths/math.constants.js";
|
|
3
|
+
const FrameDurationAt60FPS = 1000 / 60;
|
|
4
|
+
/**
|
|
5
|
+
* @experimental
|
|
6
|
+
* This class is subject to change as geospatial camera evolves.
|
|
7
|
+
*
|
|
8
|
+
* It is intended to hold all logic related to converting input pixel deltas into current frame deltas, taking speed / framerate into account
|
|
9
|
+
* to ensure smooth frame-rate-independent movement
|
|
10
|
+
*/
|
|
11
|
+
export class CameraMovement {
|
|
12
|
+
constructor(scene, _cameraPosition, _behavior) {
|
|
13
|
+
this._cameraPosition = _cameraPosition;
|
|
14
|
+
this._behavior = _behavior;
|
|
15
|
+
/**
|
|
16
|
+
* Should be set by input classes to indicates whether there is active input this frame
|
|
17
|
+
* This helps us differentiate between 0 pixel delta due to no input vs user actively holding still
|
|
18
|
+
*/
|
|
19
|
+
this.activeInput = false;
|
|
20
|
+
/**
|
|
21
|
+
* ------------ Speed ----------------
|
|
22
|
+
* Speed defines the amount of camera movement expected per input pixel movement
|
|
23
|
+
* -----------------------------------
|
|
24
|
+
*/
|
|
25
|
+
/**
|
|
26
|
+
* Desired coordinate unit movement per input pixel when zooming
|
|
27
|
+
*/
|
|
28
|
+
this.zoomSpeed = 1;
|
|
29
|
+
/**
|
|
30
|
+
* Desired coordinate unit movement per input pixel when panning
|
|
31
|
+
*/
|
|
32
|
+
this.panSpeed = 1;
|
|
33
|
+
/**
|
|
34
|
+
* Desired radians movement per input pixel when rotating along x axis
|
|
35
|
+
*/
|
|
36
|
+
this.rotationXSpeed = 1;
|
|
37
|
+
/**
|
|
38
|
+
* Desired radians movement per input pixel when rotating along y axis
|
|
39
|
+
*/
|
|
40
|
+
this.rotationYSpeed = 1;
|
|
41
|
+
/**
|
|
42
|
+
* ----------- Speed multipliers ---------------
|
|
43
|
+
* Multipliers allow movement classes to modify the effective speed dynamically per-frame
|
|
44
|
+
* (ex: scale zoom based on distance from target)
|
|
45
|
+
* -----------------------------------
|
|
46
|
+
*/
|
|
47
|
+
/**
|
|
48
|
+
* Multiplied atop zoom speed. Used to dynamically adjust zoom speed based on per-frame context (ex: zoom faster when further from target)
|
|
49
|
+
*/
|
|
50
|
+
this._zoomSpeedMultiplier = 1;
|
|
51
|
+
/**
|
|
52
|
+
* Multiplied atop pan speed. Used to dynamically adjust pan speed based on per-frame context (ex: pan slowly when close to target)
|
|
53
|
+
*/
|
|
54
|
+
this._panSpeedMultiplier = 1;
|
|
55
|
+
/**
|
|
56
|
+
* ---------- Inertia ----------------
|
|
57
|
+
* Inertia represents the decay factor per-frame applied to the velocity when there is no user input.
|
|
58
|
+
* 0 = No inertia, instant stop (velocity immediately becomes 0)
|
|
59
|
+
* 0.5 = Strong decay, velocity halves every frame at 60fps
|
|
60
|
+
* 0.9 = Moderate inertia, velocity retains 90% per frame at 60fps
|
|
61
|
+
* 0.95 = High inertia, smooth glide, velocity retains 95% per frame at 60fps
|
|
62
|
+
* 1 = Infinite inertia, never stops (velocity never decays)
|
|
63
|
+
* -----------------------------------
|
|
64
|
+
*/
|
|
65
|
+
/**
|
|
66
|
+
* Inertia applied to the zoom velocity when there is no user input.
|
|
67
|
+
* Higher inertia === slower decay, velocity retains more of its value each frame
|
|
68
|
+
*/
|
|
69
|
+
this.zoomInertia = 0.9;
|
|
70
|
+
/**
|
|
71
|
+
* Inertia applied to the panning velocity when there is no user input.
|
|
72
|
+
* Higher inertia === slower decay, velocity retains more of its value each frame
|
|
73
|
+
*/
|
|
74
|
+
this.panInertia = 0.9;
|
|
75
|
+
/**
|
|
76
|
+
* Inertia applied to the rotation velocity when there is no user input.
|
|
77
|
+
* Higher inertia === slower decay, velocity retains more of its value each frame
|
|
78
|
+
*/
|
|
79
|
+
this.rotationInertia = 0.9;
|
|
80
|
+
/**
|
|
81
|
+
* ---------- Accumulated Pixel Deltas -----------
|
|
82
|
+
* Pixel inputs accumulated throughout the frame by input classes (reset each frame after processing)
|
|
83
|
+
* -----------------------------------
|
|
84
|
+
*/
|
|
85
|
+
/**
|
|
86
|
+
* Accumulated pixel delta (by input classes) for zoom this frame
|
|
87
|
+
* Read by computeCurrentFrameDeltas() function and converted into currentFrameTranslationDelta (taking speed into account)
|
|
88
|
+
* Reset to zero after each frame
|
|
89
|
+
*/
|
|
90
|
+
this.zoomAccumulatedPixels = 0;
|
|
91
|
+
/**
|
|
92
|
+
* Accumulated pixel delta (by input classes) for panning this frame
|
|
93
|
+
* Read by computeCurrentFrameDeltas() function and converted into currentFrameTranslationDelta (taking speed into account)
|
|
94
|
+
* Reset to zero after each frame
|
|
95
|
+
*/
|
|
96
|
+
this.panAccumulatedPixels = new Vector3();
|
|
97
|
+
/**
|
|
98
|
+
* Accumulated pixel delta (by input classes) for rotation this frame
|
|
99
|
+
* Read by computeCurrentFrameDeltas() function and converted into currentFrameTranslationDelta (taking speed into account)
|
|
100
|
+
* Reset to zero after each frame
|
|
101
|
+
*/
|
|
102
|
+
this.rotationAccumulatedPixels = new Vector3();
|
|
103
|
+
/**
|
|
104
|
+
* ---------- Current Frame Movement Deltas -----------
|
|
105
|
+
* Deltas read on each frame by camera class in order to move the camera
|
|
106
|
+
* -----------------------------------
|
|
107
|
+
*/
|
|
108
|
+
/**
|
|
109
|
+
* Zoom delta to apply to camera this frame, computed by computeCurrentFrameDeltas() from zoomPixelDelta (taking speed into account)
|
|
110
|
+
*/
|
|
111
|
+
this.zoomDeltaCurrentFrame = 0;
|
|
112
|
+
/**
|
|
113
|
+
* Pan delta to apply to camera this frame, computed by computeCurrentFrameDeltas() from panPixelDelta (taking speed into account)
|
|
114
|
+
*/
|
|
115
|
+
this.panDeltaCurrentFrame = Vector3.Zero();
|
|
116
|
+
/**
|
|
117
|
+
* Rotation delta to apply to camera this frame, computed by computeCurrentFrameDeltas() from rotationPixelDelta (taking speed into account)
|
|
118
|
+
*/
|
|
119
|
+
this.rotationDeltaCurrentFrame = Vector3.Zero();
|
|
120
|
+
/**
|
|
121
|
+
* ---------- Velocity -----------
|
|
122
|
+
* Used to track velocity between frames for inertia calculation
|
|
123
|
+
* -----------------------------------
|
|
124
|
+
*/
|
|
125
|
+
/**
|
|
126
|
+
* Zoom velocity used for inertia calculations (movement / time)
|
|
127
|
+
*/
|
|
128
|
+
this._zoomVelocity = 0;
|
|
129
|
+
/**
|
|
130
|
+
* Pan velocity used for inertia calculations (movement / time)
|
|
131
|
+
*/
|
|
132
|
+
this._panVelocity = new Vector3();
|
|
133
|
+
/**
|
|
134
|
+
* Rotation velocity used for inertia calculations (movement / time)
|
|
135
|
+
*/
|
|
136
|
+
this._rotationVelocity = new Vector3();
|
|
137
|
+
/**
|
|
138
|
+
* Used when calculating inertial decay. Default to 60fps
|
|
139
|
+
*/
|
|
140
|
+
this._prevFrameTimeMs = FrameDurationAt60FPS;
|
|
141
|
+
this._scene = scene;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* When called, will take the accumulated pixel deltas set by input classes and convert them into current frame deltas, stored in currentFrameMovementDelta properties
|
|
145
|
+
* Takes speed, scaling, inertia, and framerate into account to ensure smooth movement
|
|
146
|
+
* Zeros out pixelDeltas before returning
|
|
147
|
+
*/
|
|
148
|
+
computeCurrentFrameDeltas() {
|
|
149
|
+
const deltaTimeMs = this._scene.getEngine().getDeltaTime();
|
|
150
|
+
this.panDeltaCurrentFrame.setAll(0);
|
|
151
|
+
this.rotationDeltaCurrentFrame.setAll(0);
|
|
152
|
+
this.zoomDeltaCurrentFrame = 0;
|
|
153
|
+
const hasUserInput = this.panAccumulatedPixels.length() > 0 || this.rotationAccumulatedPixels.length() > 0 || this.zoomAccumulatedPixels !== 0;
|
|
154
|
+
if (hasUserInput && this._behavior?.isInterpolating) {
|
|
155
|
+
this._behavior.stopAllAnimations();
|
|
156
|
+
}
|
|
157
|
+
this._panVelocity.copyFromFloats(this._calculateCurrentVelocity(this._panVelocity.x, this.panAccumulatedPixels.x, this.panSpeed * this._panSpeedMultiplier, this.panInertia), this._calculateCurrentVelocity(this._panVelocity.y, this.panAccumulatedPixels.y, this.panSpeed * this._panSpeedMultiplier, this.panInertia), this._calculateCurrentVelocity(this._panVelocity.z, this.panAccumulatedPixels.z, this.panSpeed * this._panSpeedMultiplier, this.panInertia));
|
|
158
|
+
this._panVelocity.scaleToRef(deltaTimeMs, this.panDeltaCurrentFrame);
|
|
159
|
+
this._rotationVelocity.copyFromFloats(this._calculateCurrentVelocity(this._rotationVelocity.x, this.rotationAccumulatedPixels.x, this.rotationXSpeed, this.rotationInertia), this._calculateCurrentVelocity(this._rotationVelocity.y, this.rotationAccumulatedPixels.y, this.rotationYSpeed, this.rotationInertia), this._calculateCurrentVelocity(this._rotationVelocity.z, this.rotationAccumulatedPixels.z, this.rotationYSpeed, this.rotationInertia));
|
|
160
|
+
this._rotationVelocity.scaleToRef(deltaTimeMs, this.rotationDeltaCurrentFrame);
|
|
161
|
+
this._zoomVelocity = this._calculateCurrentVelocity(this._zoomVelocity, this.zoomAccumulatedPixels, this.zoomSpeed * this._zoomSpeedMultiplier, this.zoomInertia);
|
|
162
|
+
this.zoomDeltaCurrentFrame = this._zoomVelocity * deltaTimeMs;
|
|
163
|
+
this._prevFrameTimeMs = deltaTimeMs;
|
|
164
|
+
this.zoomAccumulatedPixels = 0;
|
|
165
|
+
this.panAccumulatedPixels.setAll(0);
|
|
166
|
+
this.rotationAccumulatedPixels.setAll(0);
|
|
167
|
+
}
|
|
168
|
+
get isInterpolating() {
|
|
169
|
+
return !!this._behavior?.isInterpolating;
|
|
170
|
+
}
|
|
171
|
+
_calculateCurrentVelocity(velocityRef, pixelDelta, speedFactor, inertialDecayFactor) {
|
|
172
|
+
let inputVelocity = velocityRef;
|
|
173
|
+
const deltaTimeMs = this._scene.getEngine().getDeltaTime();
|
|
174
|
+
// If we are actively recieving input or have accumulated some pixel delta since last frame, calculate inputVelocity (inertia doesn't kickin yet)
|
|
175
|
+
if (pixelDelta !== 0 || this.activeInput) {
|
|
176
|
+
const pixelsPerMs = pixelDelta / deltaTimeMs;
|
|
177
|
+
inputVelocity = pixelsPerMs * speedFactor;
|
|
178
|
+
}
|
|
179
|
+
else if (!this.activeInput && inputVelocity !== 0) {
|
|
180
|
+
// If we are not receiving input and velocity isn't already zero, apply inertial decay to decelerate velocity
|
|
181
|
+
const frameIndependentDecay = Math.pow(inertialDecayFactor, this._prevFrameTimeMs / FrameDurationAt60FPS);
|
|
182
|
+
inputVelocity *= frameIndependentDecay;
|
|
183
|
+
if (Math.abs(inputVelocity) <= Epsilon) {
|
|
184
|
+
inputVelocity = 0;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
return inputVelocity;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
//# sourceMappingURL=cameraMovement.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cameraMovement.js","sourceRoot":"","sources":["../../../../dev/core/src/Cameras/cameraMovement.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAGlD,MAAM,oBAAoB,GAAG,IAAI,GAAG,EAAE,CAAC;AACvC;;;;;;GAMG;AACH,MAAM,OAAO,cAAc;IAyIvB,YACI,KAAY,EACF,eAAwB,EACxB,SAAiC;QADjC,oBAAe,GAAf,eAAe,CAAS;QACxB,cAAS,GAAT,SAAS,CAAwB;QAzI/C;;;WAGG;QACI,gBAAW,GAAY,KAAK,CAAC;QAEpC;;;;WAIG;QACH;;WAEG;QACI,cAAS,GAAW,CAAC,CAAC;QAC7B;;WAEG;QACI,aAAQ,GAAW,CAAC,CAAC;QAC5B;;WAEG;QACI,mBAAc,GAAW,CAAC,CAAC;QAClC;;WAEG;QACI,mBAAc,GAAW,CAAC,CAAC;QAElC;;;;;WAKG;QACH;;WAEG;QACO,yBAAoB,GAAW,CAAC,CAAC;QAC3C;;WAEG;QACO,wBAAmB,GAAW,CAAC,CAAC;QAE1C;;;;;;;;;WASG;QACH;;;WAGG;QACI,gBAAW,GAAW,GAAG,CAAC;QACjC;;;WAGG;QACI,eAAU,GAAW,GAAG,CAAC;QAChC;;;WAGG;QACI,oB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AC,CAAC;YAC1G,aAAa,IAAI,qBAAqB,CAAC;YACvC,IAAI,IAAI,CAAC,GAAG,CAAC,aAAa,CAAC,IAAI,OAAO,EAAE,CAAC;gBACrC,aAAa,GAAG,CAAC,CAAC;YACtB,CAAC;QACL,CAAC;QAED,OAAO,aAAa,CAAC;IACzB,CAAC;CACJ","sourcesContent":["import type { Scene } from \"../scene\";\r\nimport { Vector3 } from \"../Maths/math.vector\";\r\nimport { Epsilon } from \"../Maths/math.constants\";\r\nimport type { InterpolatingBehavior } from \"../Behaviors/Cameras/interpolatingBehavior\";\r\n\r\nconst FrameDurationAt60FPS = 1000 / 60;\r\n/**\r\n * @experimental\r\n * This class is subject to change as geospatial camera evolves.\r\n *\r\n * It is intended to hold all logic related to converting input pixel deltas into current frame deltas, taking speed / framerate into account\r\n * to ensure smooth frame-rate-independent movement\r\n */\r\nexport class CameraMovement {\r\n protected _scene: Scene;\r\n\r\n /**\r\n * Should be set by input classes to indicates whether there is active input this frame\r\n * This helps us differentiate between 0 pixel delta due to no input vs user actively holding still\r\n */\r\n public activeInput: boolean = false;\r\n\r\n /**\r\n * ------------ Speed ----------------\r\n * Speed defines the amount of camera movement expected per input pixel movement\r\n * -----------------------------------\r\n */\r\n /**\r\n * Desired coordinate unit movement per input pixel when zooming\r\n */\r\n public zoomSpeed: number = 1;\r\n /**\r\n * Desired coordinate unit movement per input pixel when panning\r\n */\r\n public panSpeed: number = 1;\r\n /**\r\n * Desired radians movement per input pixel when rotating along x axis\r\n */\r\n public rotationXSpeed: number = 1;\r\n /**\r\n * Desired radians movement per input pixel when rotating along y axis\r\n */\r\n public rotationYSpeed: number = 1;\r\n\r\n /**\r\n * ----------- Speed multipliers ---------------\r\n * Multipliers allow movement classes to modify the effective speed dynamically per-frame\r\n * (ex: scale zoom based on distance from target)\r\n * -----------------------------------\r\n */\r\n /**\r\n * Multiplied atop zoom speed. Used to dynamically adjust zoom speed based on per-frame context (ex: zoom faster when further from target)\r\n */\r\n protected _zoomSpeedMultiplier: number = 1;\r\n /**\r\n * Multiplied atop pan speed. Used to dynamically adjust pan speed based on per-frame context (ex: pan slowly when close to target)\r\n */\r\n protected _panSpeedMultiplier: number = 1;\r\n\r\n /**\r\n * ---------- Inertia ----------------\r\n * Inertia represents the decay factor per-frame applied to the velocity when there is no user input.\r\n * 0 = No inertia, instant stop (velocity immediately becomes 0)\r\n * 0.5 = Strong decay, velocity halves every frame at 60fps\r\n * 0.9 = Moderate inertia, velocity retains 90% per frame at 60fps\r\n * 0.95 = High inertia, smooth glide, velocity retains 95% per frame at 60fps\r\n * 1 = Infinite inertia, never stops (velocity never decays)\r\n * -----------------------------------\r\n */\r\n /**\r\n * Inertia applied to the zoom velocity when there is no user input.\r\n * Higher inertia === slower decay, velocity retains more of its value each frame\r\n */\r\n public zoomInertia: number = 0.9;\r\n /**\r\n * Inertia applied to the panning velocity when there is no user input.\r\n * Higher inertia === slower decay, velocity retains more of its value each frame\r\n */\r\n public panInertia: number = 0.9;\r\n /**\r\n * Inertia applied to the rotation velocity when there is no user input.\r\n * Higher inertia === slower decay, velocity retains more of its value each frame\r\n */\r\n public rotationInertia: number = 0.9;\r\n\r\n /**\r\n * ---------- Accumulated Pixel Deltas -----------\r\n * Pixel inputs accumulated throughout the frame by input classes (reset each frame after processing)\r\n * -----------------------------------\r\n */\r\n /**\r\n * Accumulated pixel delta (by input classes) for zoom this frame\r\n * Read by computeCurrentFrameDeltas() function and converted into currentFrameTranslationDelta (taking speed into account)\r\n * Reset to zero after each frame\r\n */\r\n public zoomAccumulatedPixels: number = 0;\r\n /**\r\n * Accumulated pixel delta (by input classes) for panning this frame\r\n * Read by computeCurrentFrameDeltas() function and converted into currentFrameTranslationDelta (taking speed into account)\r\n * Reset to zero after each frame\r\n */\r\n public panAccumulatedPixels: Vector3 = new Vector3();\r\n /**\r\n * Accumulated pixel delta (by input classes) for rotation this frame\r\n * Read by computeCurrentFrameDeltas() function and converted into currentFrameTranslationDelta (taking speed into account)\r\n * Reset to zero after each frame\r\n */\r\n public rotationAccumulatedPixels: Vector3 = new Vector3();\r\n\r\n /**\r\n * ---------- Current Frame Movement Deltas -----------\r\n * Deltas read on each frame by camera class in order to move the camera\r\n * -----------------------------------\r\n */\r\n /**\r\n * Zoom delta to apply to camera this frame, computed by computeCurrentFrameDeltas() from zoomPixelDelta (taking speed into account)\r\n */\r\n public zoomDeltaCurrentFrame: number = 0;\r\n /**\r\n * Pan delta to apply to camera this frame, computed by computeCurrentFrameDeltas() from panPixelDelta (taking speed into account)\r\n */\r\n public panDeltaCurrentFrame: Vector3 = Vector3.Zero();\r\n /**\r\n * Rotation delta to apply to camera this frame, computed by computeCurrentFrameDeltas() from rotationPixelDelta (taking speed into account)\r\n */\r\n public rotationDeltaCurrentFrame: Vector3 = Vector3.Zero();\r\n\r\n /**\r\n * ---------- Velocity -----------\r\n * Used to track velocity between frames for inertia calculation\r\n * -----------------------------------\r\n */\r\n /**\r\n * Zoom velocity used for inertia calculations (movement / time)\r\n */\r\n protected _zoomVelocity: number = 0;\r\n /**\r\n * Pan velocity used for inertia calculations (movement / time)\r\n */\r\n private _panVelocity: Vector3 = new Vector3();\r\n /**\r\n * Rotation velocity used for inertia calculations (movement / time)\r\n */\r\n private _rotationVelocity: Vector3 = new Vector3();\r\n\r\n /**\r\n * Used when calculating inertial decay. Default to 60fps\r\n */\r\n private _prevFrameTimeMs: number = FrameDurationAt60FPS;\r\n\r\n constructor(\r\n scene: Scene,\r\n protected _cameraPosition: Vector3,\r\n protected _behavior?: InterpolatingBehavior\r\n ) {\r\n this._scene = scene;\r\n }\r\n\r\n /**\r\n * When called, will take the accumulated pixel deltas set by input classes and convert them into current frame deltas, stored in currentFrameMovementDelta properties\r\n * Takes speed, scaling, inertia, and framerate into account to ensure smooth movement\r\n * Zeros out pixelDeltas before returning\r\n */\r\n public computeCurrentFrameDeltas(): void {\r\n const deltaTimeMs = this._scene.getEngine().getDeltaTime();\r\n\r\n this.panDeltaCurrentFrame.setAll(0);\r\n this.rotationDeltaCurrentFrame.setAll(0);\r\n this.zoomDeltaCurrentFrame = 0;\r\n\r\n const hasUserInput = this.panAccumulatedPixels.length() > 0 || this.rotationAccumulatedPixels.length() > 0 || this.zoomAccumulatedPixels !== 0;\r\n\r\n if (hasUserInput && this._behavior?.isInterpolating) {\r\n this._behavior.stopAllAnimations();\r\n }\r\n\r\n this._panVelocity.copyFromFloats(\r\n this._calculateCurrentVelocity(this._panVelocity.x, this.panAccumulatedPixels.x, this.panSpeed * this._panSpeedMultiplier, this.panInertia),\r\n this._calculateCurrentVelocity(this._panVelocity.y, this.panAccumulatedPixels.y, this.panSpeed * this._panSpeedMultiplier, this.panInertia),\r\n this._calculateCurrentVelocity(this._panVelocity.z, this.panAccumulatedPixels.z, this.panSpeed * this._panSpeedMultiplier, this.panInertia)\r\n );\r\n this._panVelocity.scaleToRef(deltaTimeMs, this.panDeltaCurrentFrame);\r\n\r\n this._rotationVelocity.copyFromFloats(\r\n this._calculateCurrentVelocity(this._rotationVelocity.x, this.rotationAccumulatedPixels.x, this.rotationXSpeed, this.rotationInertia),\r\n this._calculateCurrentVelocity(this._rotationVelocity.y, this.rotationAccumulatedPixels.y, this.rotationYSpeed, this.rotationInertia),\r\n this._calculateCurrentVelocity(this._rotationVelocity.z, this.rotationAccumulatedPixels.z, this.rotationYSpeed, this.rotationInertia)\r\n );\r\n this._rotationVelocity.scaleToRef(deltaTimeMs, this.rotationDeltaCurrentFrame);\r\n\r\n this._zoomVelocity = this._calculateCurrentVelocity(this._zoomVelocity, this.zoomAccumulatedPixels, this.zoomSpeed * this._zoomSpeedMultiplier, this.zoomInertia);\r\n this.zoomDeltaCurrentFrame = this._zoomVelocity * deltaTimeMs;\r\n\r\n this._prevFrameTimeMs = deltaTimeMs;\r\n this.zoomAccumulatedPixels = 0;\r\n this.panAccumulatedPixels.setAll(0);\r\n this.rotationAccumulatedPixels.setAll(0);\r\n }\r\n\r\n public get isInterpolating(): boolean {\r\n return !!this._behavior?.isInterpolating;\r\n }\r\n\r\n private _calculateCurrentVelocity(velocityRef: number, pixelDelta: number, speedFactor: number, inertialDecayFactor: number): number {\r\n let inputVelocity = velocityRef;\r\n const deltaTimeMs = this._scene.getEngine().getDeltaTime();\r\n\r\n // If we are actively recieving input or have accumulated some pixel delta since last frame, calculate inputVelocity (inertia doesn't kickin yet)\r\n if (pixelDelta !== 0 || this.activeInput) {\r\n const pixelsPerMs = pixelDelta / deltaTimeMs;\r\n inputVelocity = pixelsPerMs * speedFactor;\r\n } else if (!this.activeInput && inputVelocity !== 0) {\r\n // If we are not receiving input and velocity isn't already zero, apply inertial decay to decelerate velocity\r\n const frameIndependentDecay = Math.pow(inertialDecayFactor, this._prevFrameTimeMs / FrameDurationAt60FPS);\r\n inputVelocity *= frameIndependentDecay;\r\n if (Math.abs(inputVelocity) <= Epsilon) {\r\n inputVelocity = 0;\r\n }\r\n }\r\n\r\n return inputVelocity;\r\n }\r\n}\r\n"]}
|
|
@@ -6,7 +6,7 @@ import type { NodeParticleBuildState } from "../../nodeParticleBuildState.js";
|
|
|
6
6
|
*/
|
|
7
7
|
export declare class BasicColorUpdateBlock extends NodeParticleBlock {
|
|
8
8
|
/**
|
|
9
|
-
* Create a new
|
|
9
|
+
* Create a new BasicColorUpdateBlock
|
|
10
10
|
* @param name defines the block name
|
|
11
11
|
*/
|
|
12
12
|
constructor(name: string);
|
|
@@ -7,7 +7,7 @@ import { _ConnectAtTheEnd } from "../../../Queue/executionQueue.js";
|
|
|
7
7
|
*/
|
|
8
8
|
export class BasicColorUpdateBlock extends NodeParticleBlock {
|
|
9
9
|
/**
|
|
10
|
-
* Create a new
|
|
10
|
+
* Create a new BasicColorUpdateBlock
|
|
11
11
|
* @param name defines the block name
|
|
12
12
|
*/
|
|
13
13
|
constructor(name) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"basicColorUpdateBlock.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/Particles/Node/Blocks/Update/basicColorUpdateBlock.ts"],"names":[],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AC,GAAG,CAAC,EAAE,CAAC;gBACvB,QAAQ,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC;YACzB,CAAC;QACL,CAAC,CAAC;QAEF,MAAM,eAAe,GAAG;YACpB,OAAO,EAAE,YAAY;YACrB,YAAY,EAAE,IAAI;YAClB,QAAQ,EAAE,IAAI;SACjB,CAAC;QAEF,IAAI,MAAM,CAAC,iBAAiB,EAAE,CAAC;YAC3B,gBAAgB,CAAC,eAAe,EAAE,MAAM,CAAC,iBAAiB,CAAC,CAAC;QAChE,CAAC;aAAM,CAAC;YACJ,MAAM,CAAC,iBAAiB,GAAG,eAAe,CAAC;QAC/C,CAAC;QAED,IAAI,CAAC,MAAM,CAAC,YAAY,GAAG,MAAM,CAAC;IACtC,CAAC;CACJ;AAED,aAAa,CAAC,+BAA+B,EAAE,qBAAqB,CAAC,CAAC","sourcesContent":["import { RegisterClass } from \"../../../../Misc/typeStore\";\r\nimport { NodeParticleBlockConnectionPointTypes } from \"../../Enums/nodeParticleBlockConnectionPointTypes\";\r\nimport { NodeParticleBlock } from \"../../nodeParticleBlock\";\r\nimport type { NodeParticleConnectionPoint } from \"../../nodeParticleBlockConnectionPoint\";\r\nimport type { NodeParticleBuildState } from \"../../nodeParticleBuildState\";\r\nimport type { ThinParticleSystem } from \"core/Particles/thinParticleSystem\";\r\nimport type { Particle } from \"core/Particles/particle\";\r\nimport { _ConnectAtTheEnd } from \"core/Particles/Queue/executionQueue\";\r\n\r\n/**\r\n * Block used to provide the basic update functionality for particle colors.\r\n */\r\nexport class BasicColorUpdateBlock extends NodeParticleBlock {\r\n /**\r\n * Create a new
|
|
1
|
+
{"version":3,"file":"basicColorUpdateBlock.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/Particles/Node/Blocks/Update/basicColorUpdateBlock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,qCAAqC,EAAE,MAAM,mDAAmD,C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CAAC;QAEF,MAAM,eAAe,GAAG;YACpB,OAAO,EAAE,YAAY;YACrB,YAAY,EAAE,IAAI;YAClB,QAAQ,EAAE,IAAI;SACjB,CAAC;QAEF,IAAI,MAAM,CAAC,iBAAiB,EAAE,CAAC;YAC3B,gBAAgB,CAAC,eAAe,EAAE,MAAM,CAAC,iBAAiB,CAAC,CAAC;QAChE,CAAC;aAAM,CAAC;YACJ,MAAM,CAAC,iBAAiB,GAAG,eAAe,CAAC;QAC/C,CAAC;QAED,IAAI,CAAC,MAAM,CAAC,YAAY,GAAG,MAAM,CAAC;IACtC,CAAC;CACJ;AAED,aAAa,CAAC,+BAA+B,EAAE,qBAAqB,CAAC,CAAC","sourcesContent":["import { RegisterClass } from \"../../../../Misc/typeStore\";\r\nimport { NodeParticleBlockConnectionPointTypes } from \"../../Enums/nodeParticleBlockConnectionPointTypes\";\r\nimport { NodeParticleBlock } from \"../../nodeParticleBlock\";\r\nimport type { NodeParticleConnectionPoint } from \"../../nodeParticleBlockConnectionPoint\";\r\nimport type { NodeParticleBuildState } from \"../../nodeParticleBuildState\";\r\nimport type { ThinParticleSystem } from \"core/Particles/thinParticleSystem\";\r\nimport type { Particle } from \"core/Particles/particle\";\r\nimport { _ConnectAtTheEnd } from \"core/Particles/Queue/executionQueue\";\r\n\r\n/**\r\n * Block used to provide the basic update functionality for particle colors.\r\n */\r\nexport class BasicColorUpdateBlock extends NodeParticleBlock {\r\n /**\r\n * Create a new BasicColorUpdateBlock\r\n * @param name defines the block name\r\n */\r\n public constructor(name: string) {\r\n super(name);\r\n\r\n this.registerInput(\"particle\", NodeParticleBlockConnectionPointTypes.Particle);\r\n this.registerOutput(\"output\", NodeParticleBlockConnectionPointTypes.Particle);\r\n }\r\n\r\n /**\r\n * Gets the particle component\r\n */\r\n public get particle(): NodeParticleConnectionPoint {\r\n return this._inputs[0];\r\n }\r\n\r\n /**\r\n * Gets the output component\r\n */\r\n public get output(): NodeParticleConnectionPoint {\r\n return this._outputs[0];\r\n }\r\n\r\n /**\r\n * Gets the current class name\r\n * @returns the class name\r\n */\r\n public override getClassName() {\r\n return \"BasicColorUpdateBlock\";\r\n }\r\n\r\n /**\r\n * Builds the block\r\n * @param state defines the current build state\r\n */\r\n public override _build(state: NodeParticleBuildState) {\r\n const system = this.particle.getConnectedValue(state) as ThinParticleSystem;\r\n\r\n const processColor = (particle: Particle) => {\r\n state.particleContext = particle;\r\n state.systemContext = system;\r\n\r\n particle.colorStep.scaleToRef(system._scaledUpdateSpeed, system._scaledColorStep);\r\n particle.color.addInPlace(system._scaledColorStep);\r\n\r\n if (particle.color.a < 0) {\r\n particle.color.a = 0;\r\n }\r\n };\r\n\r\n const colorProcessing = {\r\n process: processColor,\r\n previousItem: null,\r\n nextItem: null,\r\n };\r\n\r\n if (system._updateQueueStart) {\r\n _ConnectAtTheEnd(colorProcessing, system._updateQueueStart);\r\n } else {\r\n system._updateQueueStart = colorProcessing;\r\n }\r\n\r\n this.output._storedValue = system;\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.BasicColorUpdateBlock\", BasicColorUpdateBlock);\r\n"]}
|
|
@@ -6,7 +6,7 @@ import type { NodeParticleBuildState } from "../../nodeParticleBuildState.js";
|
|
|
6
6
|
*/
|
|
7
7
|
export declare class BasicPositionUpdateBlock extends NodeParticleBlock {
|
|
8
8
|
/**
|
|
9
|
-
* Create a new
|
|
9
|
+
* Create a new BasicPositionUpdateBlock
|
|
10
10
|
* @param name defines the block name
|
|
11
11
|
*/
|
|
12
12
|
constructor(name: string);
|
|
@@ -7,7 +7,7 @@ import { _ConnectAtTheEnd } from "../../../Queue/executionQueue.js";
|
|
|
7
7
|
*/
|
|
8
8
|
export class BasicPositionUpdateBlock extends NodeParticleBlock {
|
|
9
9
|
/**
|
|
10
|
-
* Create a new
|
|
10
|
+
* Create a new BasicPositionUpdateBlock
|
|
11
11
|
* @param name defines the block name
|
|
12
12
|
*/
|
|
13
13
|
constructor(name) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"basicPositionUpdateBlock.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/Particles/Node/Blocks/Update/basicPositionUpdateBlock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,qCAAqC,EAAE,MAAM,mDAAmD,CAAC;AAC1G,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAK5D,OAAO,EAAE,gBAAgB,EAAE,yCAA4C;AAEvE;;GAEG;AACH,MAAM,OAAO,wBAAyB,SAAQ,iBAAiB;IAC3D;;;OAGG;IACH,YAAmB,IAAY;QAC3B,KAAK,CAAC,IAAI,CAAC,CAAC;QAEZ,IAAI,CAAC,aAAa,CAAC,UAAU,EAAE,qCAAqC,CAAC,QAAQ,CAAC,CAAC;QAC/E,IAAI,CAAC,cAAc,CAAC,QAAQ,EAAE,qCAAqC,CAAC,QAAQ,CAAC,CAAC;IAClF,CAAC;IAED;;OAEG;IACH,IAAW,QAAQ;QACf,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IAC3B,CAAC;IAED;;OAEG;IACH,IAAW,MAAM;QACb,OAAO,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;IAC5B,CAAC;IAED;;;OAGG;IACa,YAAY;QACxB,OAAO,0BAA0B,CAAC;IACtC,CAAC;IAED;;;OAGG;IACa,MAAM,CAAC,KAA6B;QAChD,MAAM,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAC,iBAAiB,CAAC,KAAK,CAAuB,CAAC;QAE5E,MAAM,eAAe,GAAG,CAAC,QAAkB,EAAE,EAAE;YAC3C,KAAK,CAAC,eAAe,GAAG,QAAQ,CAAC;YACjC,KAAK,CAAC,aAAa,GAAG,MAAM,CAAC;YAC7B,QAAQ,CAAC,SAAS,CAAC,UAAU,CAAC,MAAM,CAAC,eAAe,EAAE,MAAM,CAAC,gBAAgB,CAAC,CAAC;YAC/E,QAAQ,CAAC,QAAQ,CAAC,UAAU,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC;QAC1D,CAAC,CAAC;QAEF,MAAM,kBAAkB,GAAG;YACvB,OAAO,EAAE,eAAe;YACxB,YAAY,EAAE,IAAI;YAClB,QAAQ,EAAE,IAAI;SACjB,CAAC;QAEF,IAAI,MAAM,CAAC,iBAAiB,EAAE,CAAC;YAC3B,gBAAgB,CAAC,kBAAkB,EAAE,MAAM,CAAC,iBAAiB,CAAC,CAAC;QACnE,CAAC;aAAM,CAAC;YACJ,MAAM,CAAC,iBAAiB,GAAG,kBAAkB,CAAC;QAClD,CAAC;QAED,IAAI,CAAC,MAAM,CAAC,YAAY,GAAG,MAAM,CAAC;IACtC,CAAC;CACJ;AAED,aAAa,CAAC,kCAAkC,EAAE,wBAAwB,CAAC,CAAC","sourcesContent":["import { RegisterClass } from \"../../../../Misc/typeStore\";\r\nimport { NodeParticleBlockConnectionPointTypes } from \"../../Enums/nodeParticleBlockConnectionPointTypes\";\r\nimport { NodeParticleBlock } from \"../../nodeParticleBlock\";\r\nimport type { NodeParticleConnectionPoint } from \"../../nodeParticleBlockConnectionPoint\";\r\nimport type { NodeParticleBuildState } from \"../../nodeParticleBuildState\";\r\nimport type { ThinParticleSystem } from \"core/Particles/thinParticleSystem\";\r\nimport type { Particle } from \"core/Particles/particle\";\r\nimport { _ConnectAtTheEnd } from \"core/Particles/Queue/executionQueue\";\r\n\r\n/**\r\n * Block used to provide the basic update functionality for particles.\r\n */\r\nexport class BasicPositionUpdateBlock extends NodeParticleBlock {\r\n /**\r\n * Create a new
|
|
1
|
+
{"version":3,"file":"basicPositionUpdateBlock.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/Particles/Node/Blocks/Update/basicPositionUpdateBlock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,qCAAqC,EAAE,MAAM,mDAAmD,CAAC;AAC1G,O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AiB,EAAE,CAAC;YAC3B,gBAAgB,CAAC,kBAAkB,EAAE,MAAM,CAAC,iBAAiB,CAAC,CAAC;QACnE,CAAC;aAAM,CAAC;YACJ,MAAM,CAAC,iBAAiB,GAAG,kBAAkB,CAAC;QAClD,CAAC;QAED,IAAI,CAAC,MAAM,CAAC,YAAY,GAAG,MAAM,CAAC;IACtC,CAAC;CACJ;AAED,aAAa,CAAC,kCAAkC,EAAE,wBAAwB,CAAC,CAAC","sourcesContent":["import { RegisterClass } from \"../../../../Misc/typeStore\";\r\nimport { NodeParticleBlockConnectionPointTypes } from \"../../Enums/nodeParticleBlockConnectionPointTypes\";\r\nimport { NodeParticleBlock } from \"../../nodeParticleBlock\";\r\nimport type { NodeParticleConnectionPoint } from \"../../nodeParticleBlockConnectionPoint\";\r\nimport type { NodeParticleBuildState } from \"../../nodeParticleBuildState\";\r\nimport type { ThinParticleSystem } from \"core/Particles/thinParticleSystem\";\r\nimport type { Particle } from \"core/Particles/particle\";\r\nimport { _ConnectAtTheEnd } from \"core/Particles/Queue/executionQueue\";\r\n\r\n/**\r\n * Block used to provide the basic update functionality for particles.\r\n */\r\nexport class BasicPositionUpdateBlock extends NodeParticleBlock {\r\n /**\r\n * Create a new BasicPositionUpdateBlock\r\n * @param name defines the block name\r\n */\r\n public constructor(name: string) {\r\n super(name);\r\n\r\n this.registerInput(\"particle\", NodeParticleBlockConnectionPointTypes.Particle);\r\n this.registerOutput(\"output\", NodeParticleBlockConnectionPointTypes.Particle);\r\n }\r\n\r\n /**\r\n * Gets the particle component\r\n */\r\n public get particle(): NodeParticleConnectionPoint {\r\n return this._inputs[0];\r\n }\r\n\r\n /**\r\n * Gets the output component\r\n */\r\n public get output(): NodeParticleConnectionPoint {\r\n return this._outputs[0];\r\n }\r\n\r\n /**\r\n * Gets the current class name\r\n * @returns the class name\r\n */\r\n public override getClassName() {\r\n return \"BasicPositionUpdateBlock\";\r\n }\r\n\r\n /**\r\n * Builds the block\r\n * @param state defines the current build state\r\n */\r\n public override _build(state: NodeParticleBuildState) {\r\n const system = this.particle.getConnectedValue(state) as ThinParticleSystem;\r\n\r\n const processPosition = (particle: Particle) => {\r\n state.particleContext = particle;\r\n state.systemContext = system;\r\n particle.direction.scaleToRef(system._directionScale, system._scaledDirection);\r\n particle.position.addInPlace(system._scaledDirection);\r\n };\r\n\r\n const positionProcessing = {\r\n process: processPosition,\r\n previousItem: null,\r\n nextItem: null,\r\n };\r\n\r\n if (system._updateQueueStart) {\r\n _ConnectAtTheEnd(positionProcessing, system._updateQueueStart);\r\n } else {\r\n system._updateQueueStart = positionProcessing;\r\n }\r\n\r\n this.output._storedValue = system;\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.BasicPositionUpdateBlock\", BasicPositionUpdateBlock);\r\n"]}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { NodeParticleConnectionPoint } from "../../nodeParticleBlockConnectionPoint.js";
|
|
2
|
+
import type { NodeParticleBuildState } from "../../nodeParticleBuildState.js";
|
|
3
|
+
import { NodeParticleBlock } from "../../nodeParticleBlock.js";
|
|
4
|
+
/**
|
|
5
|
+
* Block used to update the size of a particle
|
|
6
|
+
*/
|
|
7
|
+
export declare class UpdateSizeBlock extends NodeParticleBlock {
|
|
8
|
+
/**
|
|
9
|
+
* Create a new UpdateSizeBlock
|
|
10
|
+
* @param name defines the block name
|
|
11
|
+
*/
|
|
12
|
+
constructor(name: string);
|
|
13
|
+
/**
|
|
14
|
+
* Gets the particle component
|
|
15
|
+
*/
|
|
16
|
+
get particle(): NodeParticleConnectionPoint;
|
|
17
|
+
/**
|
|
18
|
+
* Gets the size input component
|
|
19
|
+
*/
|
|
20
|
+
get size(): NodeParticleConnectionPoint;
|
|
21
|
+
/**
|
|
22
|
+
* Gets the output component
|
|
23
|
+
*/
|
|
24
|
+
get output(): NodeParticleConnectionPoint;
|
|
25
|
+
/**
|
|
26
|
+
* Gets the current class name
|
|
27
|
+
* @returns the class name
|
|
28
|
+
*/
|
|
29
|
+
getClassName(): string;
|
|
30
|
+
/**
|
|
31
|
+
* Builds the block
|
|
32
|
+
* @param state defines the current build state
|
|
33
|
+
*/
|
|
34
|
+
_build(state: NodeParticleBuildState): void;
|
|
35
|
+
}
|