@zcomponent/core 1.29.0 → 2.0.0-alpha.2
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/README.md +1 -0
- package/css/zcomponent.css +121 -122
- package/index.js +0 -3
- package/lib/actionbehavior.d.ts +3 -3
- package/lib/actionbehavior.js +20 -19
- package/lib/animation/animation.d.ts +13 -6
- package/lib/animation/animation.js +56 -43
- package/lib/animation/bezier.d.ts +6 -0
- package/lib/animation/bezier.js +8 -2
- package/lib/animation/clips/clip.d.ts +13 -1
- package/lib/animation/clips/clip.js +34 -14
- package/lib/animation/index.d.ts +4 -4
- package/lib/animation/index.js +4 -4
- package/lib/animation/layer.d.ts +9 -0
- package/lib/animation/layer.js +28 -12
- package/lib/animation/layerclip.d.ts +21 -0
- package/lib/animation/layerclip.js +82 -45
- package/lib/animation/tracks/cliptrack.d.ts +18 -0
- package/lib/animation/tracks/cliptrack.js +27 -6
- package/lib/animation/tracks/functiontrack.d.ts +9 -0
- package/lib/animation/tracks/functiontrack.js +16 -3
- package/lib/animation/tracks/propertytrack.d.ts +20 -1
- package/lib/animation/tracks/propertytrack.js +48 -11
- package/lib/animation/tracks/streamtrack.d.ts +18 -0
- package/lib/animation/tracks/streamtrack.js +32 -6
- package/lib/animation/tracks/track.d.ts +8 -2
- package/lib/animation/tracks/track.js +3 -2
- package/lib/behavior.js +13 -10
- package/lib/behaviors/ActivateState.d.ts +22 -24
- package/lib/behaviors/ActivateState.js +145 -35
- package/lib/behaviors/CallFunction.d.ts +2 -4
- package/lib/behaviors/CallFunction.js +69 -11
- package/lib/behaviors/ChangeRootScene.d.ts +35 -0
- package/lib/behaviors/ChangeRootScene.js +123 -0
- package/lib/behaviors/ConsoleLog.d.ts +6 -5
- package/lib/behaviors/ConsoleLog.js +95 -12
- package/lib/behaviors/DownloadSnapshot.d.ts +7 -12
- package/lib/behaviors/DownloadSnapshot.js +70 -19
- package/lib/behaviors/EmitComponentPropEvent.d.ts +1 -3
- package/lib/behaviors/EmitComponentPropEvent.js +80 -12
- package/lib/behaviors/LaunchURL.d.ts +5 -5
- package/lib/behaviors/LaunchURL.js +92 -10
- package/lib/behaviors/LogAnalyticsEvent.d.ts +10 -4
- package/lib/behaviors/LogAnalyticsEvent.js +88 -7
- package/lib/behaviors/PauseLayerClip.d.ts +7 -9
- package/lib/behaviors/PauseLayerClip.js +89 -21
- package/lib/behaviors/PlayLayerClip.d.ts +35 -32
- package/lib/behaviors/PlayLayerClip.js +202 -48
- package/lib/behaviors/PlaySound.d.ts +19 -25
- package/lib/behaviors/PlaySound.js +122 -28
- package/lib/behaviors/SetLayerOff.d.ts +7 -9
- package/lib/behaviors/SetLayerOff.js +88 -21
- package/lib/behaviors/ShareSnapshot.d.ts +5 -9
- package/lib/behaviors/ShareSnapshot.js +70 -17
- package/lib/behaviors/ShowTextAlert.d.ts +16 -29
- package/lib/behaviors/ShowTextAlert.js +116 -48
- package/lib/behaviors/TakeSnapshot.d.ts +22 -26
- package/lib/behaviors/TakeSnapshot.js +131 -56
- package/lib/behaviors/ToggleLayerClips.d.ts +45 -62
- package/lib/behaviors/ToggleLayerClips.js +233 -64
- package/lib/behaviors/stream/PauseStream.d.ts +5 -16
- package/lib/behaviors/stream/PauseStream.js +94 -34
- package/lib/behaviors/stream/PlayStream.d.ts +14 -27
- package/lib/behaviors/stream/PlayStream.js +123 -34
- package/lib/behaviors/stream/SeekStream.d.ts +8 -18
- package/lib/behaviors/stream/SeekStream.js +97 -31
- package/lib/behaviors/stream/StopStream.d.ts +6 -15
- package/lib/behaviors/stream/StopStream.js +89 -27
- package/lib/component.d.ts +36 -13
- package/lib/component.js +237 -151
- package/lib/components/AnimatedLoader.d.ts +51 -0
- package/lib/components/AnimatedLoader.js +159 -0
- package/lib/components/Audio.d.ts +35 -37
- package/lib/components/Audio.js +264 -151
- package/lib/components/AudioLayerSettings.d.ts +13 -11
- package/lib/components/AudioLayerSettings.js +76 -18
- package/lib/components/Children.d.ts +2 -1
- package/lib/components/Children.js +66 -13
- package/lib/components/ConditionalConstruct.d.ts +44 -0
- package/lib/components/ConditionalConstruct.js +142 -0
- package/lib/components/DefaultCookieConsent.d.ts +53 -73
- package/lib/components/DefaultCookieConsent.js +382 -264
- package/lib/components/DefaultLoader.d.ts +40 -28
- package/lib/components/DefaultLoader.js +198 -46
- package/lib/components/Gamepad.d.ts +5 -26
- package/lib/components/Gamepad.js +201 -65
- package/lib/components/LoaderScope.d.ts +15 -0
- package/lib/components/LoaderScope.js +71 -0
- package/lib/components/LongLoad.d.ts +11 -15
- package/lib/components/LongLoad.js +89 -34
- package/lib/components/SnapshotUI.d.ts +19 -24
- package/lib/components/SnapshotUI.js +202 -105
- package/lib/context.d.ts +23 -5
- package/lib/context.js +12 -6
- package/lib/contexts/analyticscontext.d.ts +12 -2
- package/lib/contexts/analyticscontext.js +68 -10
- package/lib/contexts/audiocontextcontext.d.ts +1 -1
- package/lib/contexts/audiocontextcontext.js +9 -8
- package/lib/contexts/canvascontext.d.ts +32 -18
- package/lib/contexts/canvascontext.js +195 -120
- package/lib/contexts/cookieconsentcontext.d.ts +38 -28
- package/lib/contexts/cookieconsentcontext.js +35 -32
- package/lib/contexts/documentflagmanager.js +15 -11
- package/lib/contexts/environmentcontext.d.ts +22 -6
- package/lib/contexts/environmentcontext.js +135 -21
- package/lib/contexts/gamepadcontext.d.ts +29 -26
- package/lib/contexts/gamepadcontext.js +46 -46
- package/lib/contexts/gesturecontext.d.ts +31 -6
- package/lib/contexts/gesturecontext.js +110 -85
- package/lib/contexts/globaltagcontext.d.ts +1 -1
- package/lib/contexts/globaltagcontext.js +8 -11
- package/lib/contexts/loadcontext.d.ts +45 -8
- package/lib/contexts/loadcontext.js +232 -82
- package/lib/contexts/orientationcontext.d.ts +13 -15
- package/lib/contexts/orientationcontext.js +150 -67
- package/lib/contexts/rootcomponentscontext.d.ts +16 -0
- package/lib/contexts/rootcomponentscontext.js +65 -0
- package/lib/contexts/snapshotContext.d.ts +0 -3
- package/lib/contexts/snapshotContext.js +78 -23
- package/lib/contexts/tagcontext.d.ts +5 -5
- package/lib/contexts/tagcontext.js +16 -16
- package/lib/contexts/textalertcontext.d.ts +1 -5
- package/lib/contexts/textalertcontext.js +1 -5
- package/lib/contexts/usereventcontext.d.ts +1 -1
- package/lib/contexts/usereventcontext.js +12 -12
- package/lib/data/animation.d.ts +10 -2
- package/lib/data/change.d.ts +1 -1
- package/lib/data/change.js +7 -0
- package/lib/data/core.d.ts +9 -1
- package/lib/data/index.d.ts +1 -1
- package/lib/data/index.js +1 -1
- package/lib/decorators.d.ts +348 -0
- package/lib/decorators.js +239 -0
- package/lib/decoratorutils.d.ts +3 -0
- package/lib/decoratorutils.js +8 -0
- package/lib/emitter.d.ts +15 -2
- package/lib/emitter.js +15 -6
- package/lib/entity.d.ts +43 -25
- package/lib/entity.js +104 -71
- package/lib/event.d.ts +2 -1
- package/lib/event.js +1 -4
- package/lib/groups.d.ts +18 -0
- package/lib/groups.js +19 -0
- package/lib/icons.d.ts +3372 -0
- package/lib/icons.js +1 -0
- package/lib/index.d.ts +18 -13
- package/lib/index.js +17 -13
- package/lib/inflate.d.ts +7 -7
- package/lib/inflate.js +5 -5
- package/lib/observable.d.ts +9 -2
- package/lib/observable.js +5 -4
- package/lib/observe.d.ts +18 -0
- package/lib/observe.js +177 -0
- package/lib/profile.d.ts +9 -5
- package/lib/profile.js +27 -17
- package/lib/selectors.d.ts +1 -1
- package/lib/selectors.js +5 -4
- package/lib/types.d.ts +161 -19
- package/lib/types.js +22 -1
- package/lib/values/values.d.ts +7 -8
- package/lib/values/values.js +1 -2
- package/lib/values/valuesmutator.d.ts +4 -1
- package/lib/values/valuesmutator.js +10 -8
- package/lib/zcomponent.d.ts +21 -10
- package/lib/zcomponent.js +717 -540
- package/package.json +22 -5
- package/lib/behaviors/ChangeCursor.d.ts +0 -39
- package/lib/behaviors/ChangeCursor.js +0 -44
|
@@ -4,72 +4,72 @@ import { isDesignTime } from './environmentcontext';
|
|
|
4
4
|
/**
|
|
5
5
|
* Represents the axes of a gamepad.
|
|
6
6
|
*/
|
|
7
|
-
export
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
7
|
+
export const GamepadAxis = {
|
|
8
|
+
LeftStickHorizontal: 'LeftStickHorizontal',
|
|
9
|
+
LeftStickVertical: 'LeftStickVertical',
|
|
10
|
+
RightStickHorizontal: 'RightStickHorizontal',
|
|
11
|
+
RightStickVertical: 'RightStickVertical',
|
|
12
|
+
};
|
|
13
|
+
Object.freeze(GamepadAxis);
|
|
14
14
|
/**
|
|
15
15
|
* Represents the buttons on a gamepad.
|
|
16
16
|
*/
|
|
17
|
-
export
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
17
|
+
export const GamepadButton = {
|
|
18
|
+
South: 'South',
|
|
19
|
+
East: 'East',
|
|
20
|
+
West: 'West',
|
|
21
|
+
North: 'North',
|
|
22
|
+
ShoulderLeft: 'ShoulderLeft',
|
|
23
|
+
ShoulderRight: 'ShoulderRight',
|
|
24
|
+
TriggerLeft: 'TriggerLeft',
|
|
25
|
+
TriggerRight: 'TriggerRight',
|
|
26
|
+
Select: 'Select',
|
|
27
|
+
Start: 'Start',
|
|
28
|
+
StickLeft: 'StickLeft',
|
|
29
|
+
StickRight: 'StickRight',
|
|
30
|
+
DUp: 'DUp',
|
|
31
|
+
DDown: 'DDown',
|
|
32
|
+
DLeft: 'DLeft',
|
|
33
|
+
DRight: 'DRight',
|
|
34
|
+
Center: 'Center',
|
|
35
|
+
};
|
|
36
|
+
Object.freeze(GamepadButton);
|
|
37
37
|
/**
|
|
38
38
|
* Manages and tracks gamepad connections and states.
|
|
39
39
|
* @zcontext
|
|
40
40
|
*/
|
|
41
41
|
export class GamepadContext extends Context {
|
|
42
|
+
onGamepadsChange = new Event();
|
|
43
|
+
activeGamepads = new Set();
|
|
44
|
+
_registeredGamepads = new Map();
|
|
42
45
|
/**
|
|
43
46
|
* Creates an instance of GamepadContext.
|
|
44
47
|
* @param contextManager - The current ContextManager
|
|
45
48
|
*/
|
|
46
49
|
constructor(contextManager) {
|
|
47
50
|
super(contextManager, {});
|
|
48
|
-
this.onGamepadsChange = new Event();
|
|
49
|
-
this.activeGamepads = new Set();
|
|
50
|
-
this._registeredGamepads = new Map();
|
|
51
|
-
this._update = () => {
|
|
52
|
-
const gamepads = navigator.getGamepads();
|
|
53
|
-
let changes = false;
|
|
54
|
-
for (let i = 0; i < gamepads.length; i++) {
|
|
55
|
-
if (gamepads[i] === null && this.activeGamepads.has(i)) {
|
|
56
|
-
this.activeGamepads.delete(i);
|
|
57
|
-
changes = true;
|
|
58
|
-
}
|
|
59
|
-
else if (gamepads[i] !== null && !this.activeGamepads.has(i)) {
|
|
60
|
-
this.activeGamepads.add(i);
|
|
61
|
-
changes = true;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
if (changes)
|
|
65
|
-
this.onGamepadsChange.emit();
|
|
66
|
-
};
|
|
67
51
|
if (!isDesignTime(contextManager) && typeof navigator.getGamepads === 'function') {
|
|
68
52
|
window.addEventListener('gamepadconnected', this._update);
|
|
69
53
|
window.addEventListener('gamepaddisconnected', this._update);
|
|
70
54
|
}
|
|
71
55
|
this._update();
|
|
72
56
|
}
|
|
57
|
+
_update = () => {
|
|
58
|
+
const gamepads = navigator.getGamepads();
|
|
59
|
+
let changes = false;
|
|
60
|
+
for (let i = 0; i < gamepads.length; i++) {
|
|
61
|
+
if (gamepads[i] === null && this.activeGamepads.has(i)) {
|
|
62
|
+
this.activeGamepads.delete(i);
|
|
63
|
+
changes = true;
|
|
64
|
+
}
|
|
65
|
+
else if (gamepads[i] !== null && !this.activeGamepads.has(i)) {
|
|
66
|
+
this.activeGamepads.add(i);
|
|
67
|
+
changes = true;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
if (changes)
|
|
71
|
+
this.onGamepadsChange.emit();
|
|
72
|
+
};
|
|
73
73
|
/**
|
|
74
74
|
* Retrieves a gamepad instance by its index.
|
|
75
75
|
* @param indx The index of the gamepad.
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import { Context, ContextManager, Event, Observable } from '../index';
|
|
1
|
+
import { Context, ContextManager, Event, Observable, ValueOf } from '../index';
|
|
2
2
|
/**
|
|
3
3
|
* Defines the modes for interpreting touch gestures.
|
|
4
4
|
*/
|
|
5
|
-
export declare
|
|
6
|
-
ScaleOnly
|
|
7
|
-
RotateOnly
|
|
8
|
-
ScaleRotate
|
|
9
|
-
}
|
|
5
|
+
export declare const GestureMode: {
|
|
6
|
+
readonly ScaleOnly: "Scale Only";
|
|
7
|
+
readonly RotateOnly: "Rotate Only";
|
|
8
|
+
readonly ScaleRotate: "Scale Rotate";
|
|
9
|
+
};
|
|
10
|
+
export type GestureModeValue = ValueOf<typeof GestureMode>;
|
|
10
11
|
/**
|
|
11
12
|
* Configuration options for GestureContext construction.
|
|
12
13
|
*/
|
|
@@ -24,12 +25,33 @@ interface ConstructionProps {
|
|
|
24
25
|
**/
|
|
25
26
|
export declare class GestureContext extends Context<ConstructionProps> {
|
|
26
27
|
private element;
|
|
28
|
+
/**
|
|
29
|
+
* @default true
|
|
30
|
+
*/
|
|
27
31
|
private canScale;
|
|
32
|
+
/**
|
|
33
|
+
* @default "Scale Rotate"
|
|
34
|
+
*/
|
|
28
35
|
private gestureMode;
|
|
36
|
+
/**
|
|
37
|
+
* @default true
|
|
38
|
+
*/
|
|
29
39
|
private canRotate;
|
|
40
|
+
/**
|
|
41
|
+
* @default null
|
|
42
|
+
*/
|
|
30
43
|
private initialDistance;
|
|
44
|
+
/**
|
|
45
|
+
* @default null
|
|
46
|
+
*/
|
|
31
47
|
private initialAngle;
|
|
48
|
+
/**
|
|
49
|
+
* @default true
|
|
50
|
+
*/
|
|
32
51
|
private oneFingerRotateMode;
|
|
52
|
+
/**
|
|
53
|
+
* @default null
|
|
54
|
+
*/
|
|
33
55
|
private initialTouchX;
|
|
34
56
|
/**
|
|
35
57
|
* Observable representing the current rotation value.
|
|
@@ -54,14 +76,17 @@ export declare class GestureContext extends Context<ConstructionProps> {
|
|
|
54
76
|
enabled: Observable<boolean, never>;
|
|
55
77
|
/**
|
|
56
78
|
* Minimum scale factor. Defaults to 0.5.
|
|
79
|
+
* @default 0.5
|
|
57
80
|
*/
|
|
58
81
|
minScale: number;
|
|
59
82
|
/**
|
|
60
83
|
* Maximum scale factor. Defaults to 2.
|
|
84
|
+
* @default 2
|
|
61
85
|
*/
|
|
62
86
|
maxScale: number;
|
|
63
87
|
/**
|
|
64
88
|
* Sensitivity of rotation. Defaults to 1.
|
|
89
|
+
* @default 1
|
|
65
90
|
*/
|
|
66
91
|
rotationSensitivity: number;
|
|
67
92
|
/**
|
|
@@ -1,19 +1,84 @@
|
|
|
1
|
-
import { Context, Event,
|
|
1
|
+
import { Context, Event, isDevelopmentBuild, isEditTime, Observable, useCanvas } from '../index';
|
|
2
2
|
/**
|
|
3
3
|
* Defines the modes for interpreting touch gestures.
|
|
4
4
|
*/
|
|
5
|
-
export
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
5
|
+
export const GestureMode = {
|
|
6
|
+
ScaleOnly: 'Scale Only',
|
|
7
|
+
RotateOnly: 'Rotate Only',
|
|
8
|
+
ScaleRotate: 'Scale Rotate',
|
|
9
|
+
};
|
|
10
|
+
Object.freeze(GestureMode);
|
|
11
11
|
/**
|
|
12
12
|
* Manages touch gestures for scaling and rotating elements.
|
|
13
13
|
* @deprecated Use the GestureTransform component instead. This context will be removed in the next major version.
|
|
14
14
|
* @zcontext
|
|
15
15
|
**/
|
|
16
16
|
export class GestureContext extends Context {
|
|
17
|
+
element;
|
|
18
|
+
/**
|
|
19
|
+
* @default true
|
|
20
|
+
*/
|
|
21
|
+
canScale = true;
|
|
22
|
+
/**
|
|
23
|
+
* @default "Scale Rotate"
|
|
24
|
+
*/
|
|
25
|
+
gestureMode = GestureMode.ScaleRotate;
|
|
26
|
+
/**
|
|
27
|
+
* @default true
|
|
28
|
+
*/
|
|
29
|
+
canRotate = true;
|
|
30
|
+
/**
|
|
31
|
+
* @default null
|
|
32
|
+
*/
|
|
33
|
+
initialDistance = null;
|
|
34
|
+
/**
|
|
35
|
+
* @default null
|
|
36
|
+
*/
|
|
37
|
+
initialAngle = null;
|
|
38
|
+
/**
|
|
39
|
+
* @default true
|
|
40
|
+
*/
|
|
41
|
+
oneFingerRotateMode = true;
|
|
42
|
+
/**
|
|
43
|
+
* @default null
|
|
44
|
+
*/
|
|
45
|
+
initialTouchX = null;
|
|
46
|
+
/**
|
|
47
|
+
* Observable representing the current rotation value.
|
|
48
|
+
*/
|
|
49
|
+
rotation = new Observable(0);
|
|
50
|
+
/**
|
|
51
|
+
* Observable representing the current scale value.
|
|
52
|
+
*/
|
|
53
|
+
scale = new Observable(0);
|
|
54
|
+
/**
|
|
55
|
+
* Event triggered when rotation occurs.
|
|
56
|
+
*/
|
|
57
|
+
onRotate = new Event();
|
|
58
|
+
/**
|
|
59
|
+
* Event triggered when scaling occurs.
|
|
60
|
+
*/
|
|
61
|
+
onScale = new Event();
|
|
62
|
+
/**
|
|
63
|
+
* Observable indicating whether gesture interactions are enabled.
|
|
64
|
+
* Defaults to true.
|
|
65
|
+
*/
|
|
66
|
+
enabled = new Observable(true);
|
|
67
|
+
/**
|
|
68
|
+
* Minimum scale factor. Defaults to 0.5.
|
|
69
|
+
* @default 0.5
|
|
70
|
+
*/
|
|
71
|
+
minScale = 0.5;
|
|
72
|
+
/**
|
|
73
|
+
* Maximum scale factor. Defaults to 2.
|
|
74
|
+
* @default 2
|
|
75
|
+
*/
|
|
76
|
+
maxScale = 2;
|
|
77
|
+
/**
|
|
78
|
+
* Sensitivity of rotation. Defaults to 1.
|
|
79
|
+
* @default 1
|
|
80
|
+
*/
|
|
81
|
+
rotationSensitivity = 1;
|
|
17
82
|
/**
|
|
18
83
|
* Creates an instance of GestureContext.
|
|
19
84
|
* @param contextManager - The current ContextManager
|
|
@@ -21,84 +86,6 @@ export class GestureContext extends Context {
|
|
|
21
86
|
*/
|
|
22
87
|
constructor(contextManager, constructorProps) {
|
|
23
88
|
super(contextManager, constructorProps);
|
|
24
|
-
this.canScale = true;
|
|
25
|
-
this.gestureMode = GestureMode.ScaleRotate;
|
|
26
|
-
this.canRotate = true;
|
|
27
|
-
this.initialDistance = null;
|
|
28
|
-
this.initialAngle = null;
|
|
29
|
-
this.oneFingerRotateMode = true;
|
|
30
|
-
this.initialTouchX = null;
|
|
31
|
-
/**
|
|
32
|
-
* Observable representing the current rotation value.
|
|
33
|
-
*/
|
|
34
|
-
this.rotation = new Observable(0);
|
|
35
|
-
/**
|
|
36
|
-
* Observable representing the current scale value.
|
|
37
|
-
*/
|
|
38
|
-
this.scale = new Observable(0);
|
|
39
|
-
/**
|
|
40
|
-
* Event triggered when rotation occurs.
|
|
41
|
-
*/
|
|
42
|
-
this.onRotate = new Event();
|
|
43
|
-
/**
|
|
44
|
-
* Event triggered when scaling occurs.
|
|
45
|
-
*/
|
|
46
|
-
this.onScale = new Event();
|
|
47
|
-
/**
|
|
48
|
-
* Observable indicating whether gesture interactions are enabled.
|
|
49
|
-
* Defaults to true.
|
|
50
|
-
*/
|
|
51
|
-
this.enabled = new Observable(true);
|
|
52
|
-
/**
|
|
53
|
-
* Minimum scale factor. Defaults to 0.5.
|
|
54
|
-
*/
|
|
55
|
-
this.minScale = 0.5;
|
|
56
|
-
/**
|
|
57
|
-
* Maximum scale factor. Defaults to 2.
|
|
58
|
-
*/
|
|
59
|
-
this.maxScale = 2;
|
|
60
|
-
/**
|
|
61
|
-
* Sensitivity of rotation. Defaults to 1.
|
|
62
|
-
*/
|
|
63
|
-
this.rotationSensitivity = 1;
|
|
64
|
-
this.onTouchStart = (event) => {
|
|
65
|
-
if (this.oneFingerRotateMode && event.touches.length === 1) {
|
|
66
|
-
this.initialTouchX = event.touches[0].pageX;
|
|
67
|
-
}
|
|
68
|
-
else if (event.touches.length === 2) {
|
|
69
|
-
this.initialDistance = this.getDistanceBetweenTouches(event.touches);
|
|
70
|
-
this.initialAngle = this.getAngleBetweenTouches(event.touches);
|
|
71
|
-
}
|
|
72
|
-
};
|
|
73
|
-
this.onTouchMove = (event) => {
|
|
74
|
-
switch (this.gestureMode) {
|
|
75
|
-
case GestureMode.ScaleOnly:
|
|
76
|
-
if (event.touches.length === 2) {
|
|
77
|
-
this.handleScale(event);
|
|
78
|
-
}
|
|
79
|
-
break;
|
|
80
|
-
case GestureMode.RotateOnly:
|
|
81
|
-
if (this.oneFingerRotateMode && event.touches.length === 1) {
|
|
82
|
-
this.handleOneFingerRotate(event);
|
|
83
|
-
}
|
|
84
|
-
else if (event.touches.length === 2) {
|
|
85
|
-
this.handleRotate(event);
|
|
86
|
-
}
|
|
87
|
-
break;
|
|
88
|
-
case GestureMode.ScaleRotate:
|
|
89
|
-
if (this.oneFingerRotateMode && event.touches.length === 1) {
|
|
90
|
-
this.handleOneFingerRotate(event);
|
|
91
|
-
}
|
|
92
|
-
else if (event.touches.length === 2) {
|
|
93
|
-
this.handleTwoFingerGestures(event);
|
|
94
|
-
}
|
|
95
|
-
break;
|
|
96
|
-
}
|
|
97
|
-
};
|
|
98
|
-
this.onTouchEnd = (event) => {
|
|
99
|
-
this.initialDistance = null;
|
|
100
|
-
this.initialAngle = null;
|
|
101
|
-
};
|
|
102
89
|
if (isDevelopmentBuild(contextManager) || isEditTime(contextManager)) {
|
|
103
90
|
console.warn('GestureContext is deprecated. Please use the GestureTransform component instead. GestureContext will be removed in the next major version.');
|
|
104
91
|
}
|
|
@@ -112,6 +99,40 @@ export class GestureContext extends Context {
|
|
|
112
99
|
}
|
|
113
100
|
}, undefined, true);
|
|
114
101
|
}
|
|
102
|
+
onTouchStart = (event) => {
|
|
103
|
+
if (this.oneFingerRotateMode && event.touches.length === 1) {
|
|
104
|
+
this.initialTouchX = event.touches[0].pageX;
|
|
105
|
+
}
|
|
106
|
+
else if (event.touches.length === 2) {
|
|
107
|
+
this.initialDistance = this.getDistanceBetweenTouches(event.touches);
|
|
108
|
+
this.initialAngle = this.getAngleBetweenTouches(event.touches);
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
onTouchMove = (event) => {
|
|
112
|
+
switch (this.gestureMode) {
|
|
113
|
+
case GestureMode.ScaleOnly:
|
|
114
|
+
if (event.touches.length === 2) {
|
|
115
|
+
this.handleScale(event);
|
|
116
|
+
}
|
|
117
|
+
break;
|
|
118
|
+
case GestureMode.RotateOnly:
|
|
119
|
+
if (this.oneFingerRotateMode && event.touches.length === 1) {
|
|
120
|
+
this.handleOneFingerRotate(event);
|
|
121
|
+
}
|
|
122
|
+
else if (event.touches.length === 2) {
|
|
123
|
+
this.handleRotate(event);
|
|
124
|
+
}
|
|
125
|
+
break;
|
|
126
|
+
case GestureMode.ScaleRotate:
|
|
127
|
+
if (this.oneFingerRotateMode && event.touches.length === 1) {
|
|
128
|
+
this.handleOneFingerRotate(event);
|
|
129
|
+
}
|
|
130
|
+
else if (event.touches.length === 2) {
|
|
131
|
+
this.handleTwoFingerGestures(event);
|
|
132
|
+
}
|
|
133
|
+
break;
|
|
134
|
+
}
|
|
135
|
+
};
|
|
115
136
|
handleOneFingerRotate(event) {
|
|
116
137
|
if (this.initialTouchX !== null) {
|
|
117
138
|
const currentTouchX = event.touches[0].pageX;
|
|
@@ -141,6 +162,10 @@ export class GestureContext extends Context {
|
|
|
141
162
|
this.rotation.value = -rotateAmount;
|
|
142
163
|
}
|
|
143
164
|
}
|
|
165
|
+
onTouchEnd = (event) => {
|
|
166
|
+
this.initialDistance = null;
|
|
167
|
+
this.initialAngle = null;
|
|
168
|
+
};
|
|
144
169
|
getDistanceBetweenTouches(touches) {
|
|
145
170
|
const dx = touches[0].pageX - touches[1].pageX;
|
|
146
171
|
const dy = touches[0].pageY - touches[1].pageY;
|
|
@@ -9,7 +9,7 @@ export declare class GlobalTagContext extends Context {
|
|
|
9
9
|
/**
|
|
10
10
|
* A map storing the relationship between global tags and sets of components.
|
|
11
11
|
*/
|
|
12
|
-
readonly componentsByGlobalTag: Map<string, Set<Component<any, import("
|
|
12
|
+
readonly componentsByGlobalTag: Map<string, Set<Component<any, import("..").ConstructorProps>>>;
|
|
13
13
|
/**
|
|
14
14
|
* An event that's emitted when the set of components that constitute a tag changes.
|
|
15
15
|
*/
|
|
@@ -5,15 +5,12 @@ import { Event } from '../event';
|
|
|
5
5
|
* @zcontext
|
|
6
6
|
*/
|
|
7
7
|
export class GlobalTagContext extends Context {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
*/
|
|
17
|
-
this.onTagChange = new Event();
|
|
18
|
-
}
|
|
8
|
+
/**
|
|
9
|
+
* A map storing the relationship between global tags and sets of components.
|
|
10
|
+
*/
|
|
11
|
+
componentsByGlobalTag = new Map();
|
|
12
|
+
/**
|
|
13
|
+
* An event that's emitted when the set of components that constitute a tag changes.
|
|
14
|
+
*/
|
|
15
|
+
onTagChange = new Event();
|
|
19
16
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Context, ContextManager } from '../context';
|
|
2
|
+
import { Entity } from '../entity';
|
|
2
3
|
import { Observable } from '../observable';
|
|
3
4
|
/**
|
|
4
5
|
* LoadContext exposes to components and behaviors key moments during the initialization of the experience,
|
|
@@ -31,31 +32,26 @@ export declare class LoadContext extends Context {
|
|
|
31
32
|
/**
|
|
32
33
|
* Observable indicating whether the root component's construction is complete.
|
|
33
34
|
* This is typically set to true immediately after the root component and its children are constructed.
|
|
34
|
-
* @zui
|
|
35
35
|
*/
|
|
36
36
|
readonly isConstructed: Observable<boolean, never>;
|
|
37
37
|
/**
|
|
38
38
|
* Observable indicating whether all loadable processes have completed.
|
|
39
39
|
* This is true when all assets and dependencies required for the experience are fully loaded.
|
|
40
|
-
* @zui
|
|
41
40
|
*/
|
|
42
41
|
readonly isLoaded: Observable<boolean, never>;
|
|
43
42
|
/**
|
|
44
43
|
* Observable indicating whether the experience has started.
|
|
45
44
|
* This becomes true at the point where the experience transitions from loading to active interaction.
|
|
46
|
-
* @zui
|
|
47
45
|
*/
|
|
48
46
|
readonly isStarted: Observable<boolean, never>;
|
|
49
47
|
/**
|
|
50
48
|
* Observable indicating whether the experience has been launched.
|
|
51
49
|
* This is set to true typically when the user interacts with a splash screen or an initial launch button.
|
|
52
|
-
* @zui
|
|
53
50
|
*/
|
|
54
51
|
readonly isLaunched: Observable<boolean, never>;
|
|
55
52
|
/**
|
|
56
53
|
* Observable representing the progress percentage of loadable processes.
|
|
57
54
|
* This provides a numerical value representing the completion percentage of all loading operations.
|
|
58
|
-
* @zui
|
|
59
55
|
*/
|
|
60
56
|
readonly progressPercent: Observable<number, never>;
|
|
61
57
|
private _startedResolved;
|
|
@@ -65,8 +61,17 @@ export declare class LoadContext extends Context {
|
|
|
65
61
|
private _launchedResolved;
|
|
66
62
|
readonly launched: Promise<void>;
|
|
67
63
|
private _loadables;
|
|
64
|
+
/**
|
|
65
|
+
* @default false
|
|
66
|
+
*/
|
|
68
67
|
private _startWhenLoaded;
|
|
68
|
+
/**
|
|
69
|
+
* @default 0
|
|
70
|
+
*/
|
|
69
71
|
private _totalLoadables;
|
|
72
|
+
/**
|
|
73
|
+
* @default 0
|
|
74
|
+
*/
|
|
70
75
|
private _loadedCount;
|
|
71
76
|
/**
|
|
72
77
|
* Start the experience.
|
|
@@ -88,7 +93,7 @@ export declare class LoadContext extends Context {
|
|
|
88
93
|
/**
|
|
89
94
|
* Register a loadable process.
|
|
90
95
|
*/
|
|
91
|
-
registerLoadable(p: Promise<any
|
|
96
|
+
registerLoadable(p: Promise<any>, entity?: Entity): void;
|
|
92
97
|
}
|
|
93
98
|
/**
|
|
94
99
|
* Returns an observable that indicates whether the experience is loaded.
|
|
@@ -129,7 +134,7 @@ export declare function useLoadPercent(mgr: ContextManager): Observable<number,
|
|
|
129
134
|
/**
|
|
130
135
|
* Register a loadable process.
|
|
131
136
|
*/
|
|
132
|
-
export declare function registerLoadable(mgr: ContextManager, p: Promise<any>): void;
|
|
137
|
+
export declare function registerLoadable(mgr: ContextManager | Entity, p: Promise<any>): void;
|
|
133
138
|
/**
|
|
134
139
|
* Starts the experience.
|
|
135
140
|
*/
|
|
@@ -159,3 +164,35 @@ export declare function launched(mgr: ContextManager): Promise<void>;
|
|
|
159
164
|
* Marks the root component's constructor (and thus any recursive children) as finished.
|
|
160
165
|
*/
|
|
161
166
|
export declare function constructionComplete(mgr: ContextManager): void;
|
|
167
|
+
/**
|
|
168
|
+
* A decorator that registers its decorated function as a loadable process, and
|
|
169
|
+
* (by default) invokes it automatically once the experience has finished constructing.
|
|
170
|
+
*
|
|
171
|
+
* The loader will wait for the returned promise to resolve before hiding itself.
|
|
172
|
+
* The loadable is registered synchronously during construction so that `isLoaded`
|
|
173
|
+
* reflects the pending work from the moment the entity exists; the actual method
|
|
174
|
+
* call is deferred until after the full construction tree settles, so any fields
|
|
175
|
+
* assigned in subclass constructor bodies are available when it runs.
|
|
176
|
+
*
|
|
177
|
+
* Mirrors the structure of {@link zOnConstructed}, {@link zOnStart}, and {@link zOnLaunch};
|
|
178
|
+
* the only difference is that `zLoad` also registers the deferred work as a loadable.
|
|
179
|
+
*
|
|
180
|
+
* @param autoInvoke - If true (default), the method fires automatically after construction.
|
|
181
|
+
* If false, the method must be called manually but will still register as a loadable.
|
|
182
|
+
*/
|
|
183
|
+
export declare function zLoad<EntityType extends Entity>(autoInvoke?: boolean): (originalMethod: (...args: any) => Promise<any>, context: ClassMethodDecoratorContext<EntityType, (this: EntityType, ...args: any[]) => Promise<any>>) => (this: EntityType, ...args: any[]) => Promise<any>;
|
|
184
|
+
/**
|
|
185
|
+
* A decorator that will automatically call its decorated function when the experience has been started.
|
|
186
|
+
*/
|
|
187
|
+
export declare function zOnStart<EntityType extends Entity>(): (originalMethod: (...args: [
|
|
188
|
+
]) => any, context: ClassMethodDecoratorContext<EntityType>) => any;
|
|
189
|
+
/**
|
|
190
|
+
* A decorator that will automatically call its decorated function when the experience has been constructed.
|
|
191
|
+
*/
|
|
192
|
+
export declare function zOnConstructed<EntityType extends Entity>(): (originalMethod: (...args: [
|
|
193
|
+
]) => any, context: ClassMethodDecoratorContext<EntityType>) => any;
|
|
194
|
+
/**
|
|
195
|
+
* A decorator that will automatically call its decorated function when the experience has been launched.
|
|
196
|
+
*/
|
|
197
|
+
export declare function zOnLaunch<EntityType extends Entity>(): (originalMethod: (...args: [
|
|
198
|
+
]) => any, context: ClassMethodDecoratorContext<EntityType>) => any;
|