@dcl/ecs 7.20.5-22670537517.commit-a403a9f → 7.20.5-22673942652.commit-fcc5752
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/dist/components/extended/Tween.d.ts +48 -1
- package/dist/components/extended/Tween.js +66 -0
- package/dist/components/generated/pb/decentraland/sdk/components/tween.gen.d.ts +21 -0
- package/dist/components/generated/pb/decentraland/sdk/components/tween.gen.js +99 -0
- package/dist/components/types.d.ts +1 -1
- package/dist-cjs/components/extended/Tween.d.ts +48 -1
- package/dist-cjs/components/extended/Tween.js +66 -0
- package/dist-cjs/components/generated/pb/decentraland/sdk/components/tween.gen.d.ts +21 -0
- package/dist-cjs/components/generated/pb/decentraland/sdk/components/tween.gen.js +100 -1
- package/dist-cjs/components/types.d.ts +1 -1
- package/package.json +2 -2
|
@@ -1,6 +1,38 @@
|
|
|
1
1
|
import { Entity, IEngine, LastWriteWinElementSetComponentDefinition } from '../../engine';
|
|
2
2
|
import { Quaternion, Vector2, Vector3 } from '../generated/pb/decentraland/common/vectors.gen';
|
|
3
3
|
import { EasingFunction, Move, MoveContinuous, PBTween, Rotate, RotateContinuous, Scale, TextureMove, TextureMoveContinuous, TextureMovementType } from '../generated/index.gen';
|
|
4
|
+
/**
|
|
5
|
+
* @public
|
|
6
|
+
* Partial params for Tween.Mode.MoveRotateScale(). At least one of position, rotation, or scale must be provided.
|
|
7
|
+
* Use this when building a mode for Tween.createOrReplace() or TweenSequence (e.g. only positionStart/positionEnd).
|
|
8
|
+
*/
|
|
9
|
+
export interface MoveRotateScaleModeParams {
|
|
10
|
+
/** Position tween (start → end). Optional. */
|
|
11
|
+
position?: {
|
|
12
|
+
start: Vector3;
|
|
13
|
+
end: Vector3;
|
|
14
|
+
};
|
|
15
|
+
/** Rotation tween (start → end). Optional. */
|
|
16
|
+
rotation?: {
|
|
17
|
+
start: Quaternion;
|
|
18
|
+
end: Quaternion;
|
|
19
|
+
};
|
|
20
|
+
/** Scale tween (start → end). Optional. */
|
|
21
|
+
scale?: {
|
|
22
|
+
start: Vector3;
|
|
23
|
+
end: Vector3;
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* @public
|
|
28
|
+
* Parameters for setMoveRotateScale. At least one of position, rotation, or scale must be provided.
|
|
29
|
+
*/
|
|
30
|
+
export interface SetMoveRotateScaleParams extends MoveRotateScaleModeParams {
|
|
31
|
+
/** Duration of the tween in milliseconds. */
|
|
32
|
+
duration: number;
|
|
33
|
+
/** Easing function (defaults to EF_LINEAR). */
|
|
34
|
+
easingFunction?: EasingFunction;
|
|
35
|
+
}
|
|
4
36
|
/**
|
|
5
37
|
* @public
|
|
6
38
|
*/
|
|
@@ -33,13 +65,18 @@ export interface TweenHelper {
|
|
|
33
65
|
* @returns a texture-move-continuous mode tween
|
|
34
66
|
*/
|
|
35
67
|
TextureMoveContinuous: (textureMove: TextureMoveContinuous) => PBTween['mode'];
|
|
68
|
+
/**
|
|
69
|
+
* @returns a move-rotate-scale mode tween
|
|
70
|
+
* @param params - partial transform (at least one of position, rotation, scale); omit axes you don't need
|
|
71
|
+
*/
|
|
72
|
+
MoveRotateScale: (params: MoveRotateScaleModeParams) => PBTween['mode'];
|
|
36
73
|
}
|
|
37
74
|
/**
|
|
38
75
|
* @public
|
|
39
76
|
*/
|
|
40
77
|
export interface TweenComponentDefinitionExtended extends LastWriteWinElementSetComponentDefinition<PBTween> {
|
|
41
78
|
/**
|
|
42
|
-
*
|
|
79
|
+
* Helpers with constructor
|
|
43
80
|
*/
|
|
44
81
|
Mode: TweenHelper;
|
|
45
82
|
/**
|
|
@@ -118,5 +155,15 @@ export interface TweenComponentDefinitionExtended extends LastWriteWinElementSet
|
|
|
118
155
|
* @param duration - duration of the tween in milliseconds (defaults to 0 for infinite)
|
|
119
156
|
*/
|
|
120
157
|
setTextureMoveContinuous(entity: Entity, direction: Vector2, speed: number, movementType?: TextureMovementType, duration?: number): void;
|
|
158
|
+
/**
|
|
159
|
+
* @public
|
|
160
|
+
*
|
|
161
|
+
* Creates or replaces a move-rotate-scale tween component that simultaneously animates
|
|
162
|
+
* an entity's position, rotation, and/or scale from start to end. Provide only the
|
|
163
|
+
* properties you need (at least one of position, rotation, or scale).
|
|
164
|
+
* @param entity - entity to apply the tween to
|
|
165
|
+
* @param params - object with optional position, rotation, scale (each with start/end), duration, and optional easingFunction
|
|
166
|
+
*/
|
|
167
|
+
setMoveRotateScale(entity: Entity, params: SetMoveRotateScaleParams): void;
|
|
121
168
|
}
|
|
122
169
|
export declare function defineTweenComponent(engine: Pick<IEngine, 'defineComponentFromSchema'>): TweenComponentDefinitionExtended;
|
|
@@ -1,4 +1,33 @@
|
|
|
1
1
|
import { Tween } from '../generated/index.gen';
|
|
2
|
+
function assertDuration(duration, apiName) {
|
|
3
|
+
if (!Number.isFinite(duration) || duration < 0) {
|
|
4
|
+
throw new Error(`${apiName}: duration must be a non-negative finite number`);
|
|
5
|
+
}
|
|
6
|
+
}
|
|
7
|
+
/** Shared validation for params that have optional position/rotation/scale with start & end. */
|
|
8
|
+
function assertMoveRotateScaleAxesStartEnd(params, apiName) {
|
|
9
|
+
if (!params.position && !params.rotation && !params.scale) {
|
|
10
|
+
throw new Error(`${apiName}: at least one of position, rotation, or scale must be provided`);
|
|
11
|
+
}
|
|
12
|
+
if (params.position) {
|
|
13
|
+
const pos = params.position;
|
|
14
|
+
if (!pos.start || !pos.end) {
|
|
15
|
+
throw new Error(`${apiName}: position must have both start and end`);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
if (params.rotation) {
|
|
19
|
+
const rot = params.rotation;
|
|
20
|
+
if (!rot.start || !rot.end) {
|
|
21
|
+
throw new Error(`${apiName}: rotation must have both start and end`);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
if (params.scale) {
|
|
25
|
+
const scl = params.scale;
|
|
26
|
+
if (!scl.start || !scl.end) {
|
|
27
|
+
throw new Error(`${apiName}: scale must have both start and end`);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
2
31
|
const TweenHelper = {
|
|
3
32
|
Move(move) {
|
|
4
33
|
return {
|
|
@@ -41,6 +70,21 @@ const TweenHelper = {
|
|
|
41
70
|
$case: 'textureMoveContinuous',
|
|
42
71
|
textureMoveContinuous
|
|
43
72
|
};
|
|
73
|
+
},
|
|
74
|
+
MoveRotateScale(params) {
|
|
75
|
+
assertMoveRotateScaleAxesStartEnd(params, 'Tween.Mode.MoveRotateScale');
|
|
76
|
+
const moveRotateScale = {
|
|
77
|
+
positionStart: params.position ? params.position.start : undefined,
|
|
78
|
+
positionEnd: params.position ? params.position.end : undefined,
|
|
79
|
+
rotationStart: params.rotation ? params.rotation.start : undefined,
|
|
80
|
+
rotationEnd: params.rotation ? params.rotation.end : undefined,
|
|
81
|
+
scaleStart: params.scale ? params.scale.start : undefined,
|
|
82
|
+
scaleEnd: params.scale ? params.scale.end : undefined
|
|
83
|
+
};
|
|
84
|
+
return {
|
|
85
|
+
$case: 'moveRotateScale',
|
|
86
|
+
moveRotateScale
|
|
87
|
+
};
|
|
44
88
|
}
|
|
45
89
|
};
|
|
46
90
|
export function defineTweenComponent(engine) {
|
|
@@ -147,6 +191,28 @@ export function defineTweenComponent(engine) {
|
|
|
147
191
|
easingFunction: 0 /* EasingFunction.EF_LINEAR */,
|
|
148
192
|
playing: true
|
|
149
193
|
});
|
|
194
|
+
},
|
|
195
|
+
setMoveRotateScale(entity, params) {
|
|
196
|
+
assertMoveRotateScaleAxesStartEnd(params, 'setMoveRotateScale');
|
|
197
|
+
assertDuration(params.duration, 'setMoveRotateScale');
|
|
198
|
+
const { position, rotation, scale, duration, easingFunction = 0 /* EasingFunction.EF_LINEAR */ } = params;
|
|
199
|
+
const moveRotateScale = {
|
|
200
|
+
positionStart: position ? position.start : undefined,
|
|
201
|
+
positionEnd: position ? position.end : undefined,
|
|
202
|
+
rotationStart: rotation ? rotation.start : undefined,
|
|
203
|
+
rotationEnd: rotation ? rotation.end : undefined,
|
|
204
|
+
scaleStart: scale ? scale.start : undefined,
|
|
205
|
+
scaleEnd: scale ? scale.end : undefined
|
|
206
|
+
};
|
|
207
|
+
theComponent.createOrReplace(entity, {
|
|
208
|
+
mode: {
|
|
209
|
+
$case: 'moveRotateScale',
|
|
210
|
+
moveRotateScale
|
|
211
|
+
},
|
|
212
|
+
duration,
|
|
213
|
+
easingFunction,
|
|
214
|
+
playing: true
|
|
215
|
+
});
|
|
150
216
|
}
|
|
151
217
|
};
|
|
152
218
|
}
|
|
@@ -77,6 +77,9 @@ export interface PBTween {
|
|
|
77
77
|
} | {
|
|
78
78
|
$case: "textureMoveContinuous";
|
|
79
79
|
textureMoveContinuous: TextureMoveContinuous;
|
|
80
|
+
} | {
|
|
81
|
+
$case: "moveRotateScale";
|
|
82
|
+
moveRotateScale: MoveRotateScale;
|
|
80
83
|
} | undefined;
|
|
81
84
|
/** default true (pause or running) */
|
|
82
85
|
playing?: boolean | undefined;
|
|
@@ -105,6 +108,17 @@ export interface Scale {
|
|
|
105
108
|
start: Vector3 | undefined;
|
|
106
109
|
end: Vector3 | undefined;
|
|
107
110
|
}
|
|
111
|
+
/**
|
|
112
|
+
* @public
|
|
113
|
+
*/
|
|
114
|
+
export interface MoveRotateScale {
|
|
115
|
+
positionStart: Vector3 | undefined;
|
|
116
|
+
positionEnd: Vector3 | undefined;
|
|
117
|
+
rotationStart: Quaternion | undefined;
|
|
118
|
+
rotationEnd: Quaternion | undefined;
|
|
119
|
+
scaleStart: Vector3 | undefined;
|
|
120
|
+
scaleEnd: Vector3 | undefined;
|
|
121
|
+
}
|
|
108
122
|
/**
|
|
109
123
|
* This tween mode allows to move the texture of a PbrMaterial or UnlitMaterial.
|
|
110
124
|
* You can also specify the movement type (offset or tiling)
|
|
@@ -169,6 +183,13 @@ export declare namespace Scale {
|
|
|
169
183
|
function encode(message: Scale, writer?: _m0.Writer): _m0.Writer;
|
|
170
184
|
function decode(input: _m0.Reader | Uint8Array, length?: number): Scale;
|
|
171
185
|
}
|
|
186
|
+
/**
|
|
187
|
+
* @public
|
|
188
|
+
*/
|
|
189
|
+
export declare namespace MoveRotateScale {
|
|
190
|
+
function encode(message: MoveRotateScale, writer?: _m0.Writer): _m0.Writer;
|
|
191
|
+
function decode(input: _m0.Reader | Uint8Array, length?: number): MoveRotateScale;
|
|
192
|
+
}
|
|
172
193
|
/**
|
|
173
194
|
* @public
|
|
174
195
|
*/
|
|
@@ -90,6 +90,9 @@ export var PBTween;
|
|
|
90
90
|
case "textureMoveContinuous":
|
|
91
91
|
TextureMoveContinuous.encode(message.mode.textureMoveContinuous, writer.uint32(90).fork()).ldelim();
|
|
92
92
|
break;
|
|
93
|
+
case "moveRotateScale":
|
|
94
|
+
MoveRotateScale.encode(message.mode.moveRotateScale, writer.uint32(98).fork()).ldelim();
|
|
95
|
+
break;
|
|
93
96
|
}
|
|
94
97
|
if (message.playing !== undefined) {
|
|
95
98
|
writer.uint32(48).bool(message.playing);
|
|
@@ -167,6 +170,12 @@ export var PBTween;
|
|
|
167
170
|
textureMoveContinuous: TextureMoveContinuous.decode(reader, reader.uint32()),
|
|
168
171
|
};
|
|
169
172
|
continue;
|
|
173
|
+
case 12:
|
|
174
|
+
if (tag !== 98) {
|
|
175
|
+
break;
|
|
176
|
+
}
|
|
177
|
+
message.mode = { $case: "moveRotateScale", moveRotateScale: MoveRotateScale.decode(reader, reader.uint32()) };
|
|
178
|
+
continue;
|
|
170
179
|
case 6:
|
|
171
180
|
if (tag !== 48) {
|
|
172
181
|
break;
|
|
@@ -339,6 +348,96 @@ export var Scale;
|
|
|
339
348
|
}
|
|
340
349
|
Scale.decode = decode;
|
|
341
350
|
})(Scale || (Scale = {}));
|
|
351
|
+
function createBaseMoveRotateScale() {
|
|
352
|
+
return {
|
|
353
|
+
positionStart: undefined,
|
|
354
|
+
positionEnd: undefined,
|
|
355
|
+
rotationStart: undefined,
|
|
356
|
+
rotationEnd: undefined,
|
|
357
|
+
scaleStart: undefined,
|
|
358
|
+
scaleEnd: undefined,
|
|
359
|
+
};
|
|
360
|
+
}
|
|
361
|
+
/**
|
|
362
|
+
* @public
|
|
363
|
+
*/
|
|
364
|
+
export var MoveRotateScale;
|
|
365
|
+
(function (MoveRotateScale) {
|
|
366
|
+
function encode(message, writer = _m0.Writer.create()) {
|
|
367
|
+
if (message.positionStart !== undefined) {
|
|
368
|
+
Vector3.encode(message.positionStart, writer.uint32(10).fork()).ldelim();
|
|
369
|
+
}
|
|
370
|
+
if (message.positionEnd !== undefined) {
|
|
371
|
+
Vector3.encode(message.positionEnd, writer.uint32(18).fork()).ldelim();
|
|
372
|
+
}
|
|
373
|
+
if (message.rotationStart !== undefined) {
|
|
374
|
+
Quaternion.encode(message.rotationStart, writer.uint32(26).fork()).ldelim();
|
|
375
|
+
}
|
|
376
|
+
if (message.rotationEnd !== undefined) {
|
|
377
|
+
Quaternion.encode(message.rotationEnd, writer.uint32(34).fork()).ldelim();
|
|
378
|
+
}
|
|
379
|
+
if (message.scaleStart !== undefined) {
|
|
380
|
+
Vector3.encode(message.scaleStart, writer.uint32(42).fork()).ldelim();
|
|
381
|
+
}
|
|
382
|
+
if (message.scaleEnd !== undefined) {
|
|
383
|
+
Vector3.encode(message.scaleEnd, writer.uint32(50).fork()).ldelim();
|
|
384
|
+
}
|
|
385
|
+
return writer;
|
|
386
|
+
}
|
|
387
|
+
MoveRotateScale.encode = encode;
|
|
388
|
+
function decode(input, length) {
|
|
389
|
+
const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
|
|
390
|
+
let end = length === undefined ? reader.len : reader.pos + length;
|
|
391
|
+
const message = createBaseMoveRotateScale();
|
|
392
|
+
while (reader.pos < end) {
|
|
393
|
+
const tag = reader.uint32();
|
|
394
|
+
switch (tag >>> 3) {
|
|
395
|
+
case 1:
|
|
396
|
+
if (tag !== 10) {
|
|
397
|
+
break;
|
|
398
|
+
}
|
|
399
|
+
message.positionStart = Vector3.decode(reader, reader.uint32());
|
|
400
|
+
continue;
|
|
401
|
+
case 2:
|
|
402
|
+
if (tag !== 18) {
|
|
403
|
+
break;
|
|
404
|
+
}
|
|
405
|
+
message.positionEnd = Vector3.decode(reader, reader.uint32());
|
|
406
|
+
continue;
|
|
407
|
+
case 3:
|
|
408
|
+
if (tag !== 26) {
|
|
409
|
+
break;
|
|
410
|
+
}
|
|
411
|
+
message.rotationStart = Quaternion.decode(reader, reader.uint32());
|
|
412
|
+
continue;
|
|
413
|
+
case 4:
|
|
414
|
+
if (tag !== 34) {
|
|
415
|
+
break;
|
|
416
|
+
}
|
|
417
|
+
message.rotationEnd = Quaternion.decode(reader, reader.uint32());
|
|
418
|
+
continue;
|
|
419
|
+
case 5:
|
|
420
|
+
if (tag !== 42) {
|
|
421
|
+
break;
|
|
422
|
+
}
|
|
423
|
+
message.scaleStart = Vector3.decode(reader, reader.uint32());
|
|
424
|
+
continue;
|
|
425
|
+
case 6:
|
|
426
|
+
if (tag !== 50) {
|
|
427
|
+
break;
|
|
428
|
+
}
|
|
429
|
+
message.scaleEnd = Vector3.decode(reader, reader.uint32());
|
|
430
|
+
continue;
|
|
431
|
+
}
|
|
432
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
433
|
+
break;
|
|
434
|
+
}
|
|
435
|
+
reader.skipType(tag & 7);
|
|
436
|
+
}
|
|
437
|
+
return message;
|
|
438
|
+
}
|
|
439
|
+
MoveRotateScale.decode = decode;
|
|
440
|
+
})(MoveRotateScale || (MoveRotateScale = {}));
|
|
342
441
|
function createBaseTextureMove() {
|
|
343
442
|
return { start: undefined, end: undefined, movementType: undefined };
|
|
344
443
|
}
|
|
@@ -4,7 +4,7 @@ export type { AudioStreamComponentDefinitionExtended } from './extended/AudioStr
|
|
|
4
4
|
export type { MeshRendererComponentDefinitionExtended } from './extended/MeshRenderer';
|
|
5
5
|
export type { MeshColliderComponentDefinitionExtended } from './extended/MeshCollider';
|
|
6
6
|
export type { TextureHelper, MaterialComponentDefinitionExtended, FlatTexture, ReadonlyFlatMaterial, ReadonlyFlatTexture, FlatMaterial } from './extended/Material';
|
|
7
|
-
export type { TweenHelper, TweenComponentDefinitionExtended } from './extended/Tween';
|
|
7
|
+
export type { TweenHelper, TweenComponentDefinitionExtended, SetMoveRotateScaleParams, MoveRotateScaleModeParams } from './extended/Tween';
|
|
8
8
|
export type { CameraTransitionHelper, VirtualCameraComponentDefinitionExtended } from './extended/VirtualCamera';
|
|
9
9
|
export type { TransformComponentExtended, TransformTypeWithOptionals } from './manual/Transform';
|
|
10
10
|
export type { NameComponent, NameType } from './manual/Name';
|
|
@@ -1,6 +1,38 @@
|
|
|
1
1
|
import { Entity, IEngine, LastWriteWinElementSetComponentDefinition } from '../../engine';
|
|
2
2
|
import { Quaternion, Vector2, Vector3 } from '../generated/pb/decentraland/common/vectors.gen';
|
|
3
3
|
import { EasingFunction, Move, MoveContinuous, PBTween, Rotate, RotateContinuous, Scale, TextureMove, TextureMoveContinuous, TextureMovementType } from '../generated/index.gen';
|
|
4
|
+
/**
|
|
5
|
+
* @public
|
|
6
|
+
* Partial params for Tween.Mode.MoveRotateScale(). At least one of position, rotation, or scale must be provided.
|
|
7
|
+
* Use this when building a mode for Tween.createOrReplace() or TweenSequence (e.g. only positionStart/positionEnd).
|
|
8
|
+
*/
|
|
9
|
+
export interface MoveRotateScaleModeParams {
|
|
10
|
+
/** Position tween (start → end). Optional. */
|
|
11
|
+
position?: {
|
|
12
|
+
start: Vector3;
|
|
13
|
+
end: Vector3;
|
|
14
|
+
};
|
|
15
|
+
/** Rotation tween (start → end). Optional. */
|
|
16
|
+
rotation?: {
|
|
17
|
+
start: Quaternion;
|
|
18
|
+
end: Quaternion;
|
|
19
|
+
};
|
|
20
|
+
/** Scale tween (start → end). Optional. */
|
|
21
|
+
scale?: {
|
|
22
|
+
start: Vector3;
|
|
23
|
+
end: Vector3;
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* @public
|
|
28
|
+
* Parameters for setMoveRotateScale. At least one of position, rotation, or scale must be provided.
|
|
29
|
+
*/
|
|
30
|
+
export interface SetMoveRotateScaleParams extends MoveRotateScaleModeParams {
|
|
31
|
+
/** Duration of the tween in milliseconds. */
|
|
32
|
+
duration: number;
|
|
33
|
+
/** Easing function (defaults to EF_LINEAR). */
|
|
34
|
+
easingFunction?: EasingFunction;
|
|
35
|
+
}
|
|
4
36
|
/**
|
|
5
37
|
* @public
|
|
6
38
|
*/
|
|
@@ -33,13 +65,18 @@ export interface TweenHelper {
|
|
|
33
65
|
* @returns a texture-move-continuous mode tween
|
|
34
66
|
*/
|
|
35
67
|
TextureMoveContinuous: (textureMove: TextureMoveContinuous) => PBTween['mode'];
|
|
68
|
+
/**
|
|
69
|
+
* @returns a move-rotate-scale mode tween
|
|
70
|
+
* @param params - partial transform (at least one of position, rotation, scale); omit axes you don't need
|
|
71
|
+
*/
|
|
72
|
+
MoveRotateScale: (params: MoveRotateScaleModeParams) => PBTween['mode'];
|
|
36
73
|
}
|
|
37
74
|
/**
|
|
38
75
|
* @public
|
|
39
76
|
*/
|
|
40
77
|
export interface TweenComponentDefinitionExtended extends LastWriteWinElementSetComponentDefinition<PBTween> {
|
|
41
78
|
/**
|
|
42
|
-
*
|
|
79
|
+
* Helpers with constructor
|
|
43
80
|
*/
|
|
44
81
|
Mode: TweenHelper;
|
|
45
82
|
/**
|
|
@@ -118,5 +155,15 @@ export interface TweenComponentDefinitionExtended extends LastWriteWinElementSet
|
|
|
118
155
|
* @param duration - duration of the tween in milliseconds (defaults to 0 for infinite)
|
|
119
156
|
*/
|
|
120
157
|
setTextureMoveContinuous(entity: Entity, direction: Vector2, speed: number, movementType?: TextureMovementType, duration?: number): void;
|
|
158
|
+
/**
|
|
159
|
+
* @public
|
|
160
|
+
*
|
|
161
|
+
* Creates or replaces a move-rotate-scale tween component that simultaneously animates
|
|
162
|
+
* an entity's position, rotation, and/or scale from start to end. Provide only the
|
|
163
|
+
* properties you need (at least one of position, rotation, or scale).
|
|
164
|
+
* @param entity - entity to apply the tween to
|
|
165
|
+
* @param params - object with optional position, rotation, scale (each with start/end), duration, and optional easingFunction
|
|
166
|
+
*/
|
|
167
|
+
setMoveRotateScale(entity: Entity, params: SetMoveRotateScaleParams): void;
|
|
121
168
|
}
|
|
122
169
|
export declare function defineTweenComponent(engine: Pick<IEngine, 'defineComponentFromSchema'>): TweenComponentDefinitionExtended;
|
|
@@ -2,6 +2,35 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.defineTweenComponent = void 0;
|
|
4
4
|
const index_gen_1 = require("../generated/index.gen");
|
|
5
|
+
function assertDuration(duration, apiName) {
|
|
6
|
+
if (!Number.isFinite(duration) || duration < 0) {
|
|
7
|
+
throw new Error(`${apiName}: duration must be a non-negative finite number`);
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
/** Shared validation for params that have optional position/rotation/scale with start & end. */
|
|
11
|
+
function assertMoveRotateScaleAxesStartEnd(params, apiName) {
|
|
12
|
+
if (!params.position && !params.rotation && !params.scale) {
|
|
13
|
+
throw new Error(`${apiName}: at least one of position, rotation, or scale must be provided`);
|
|
14
|
+
}
|
|
15
|
+
if (params.position) {
|
|
16
|
+
const pos = params.position;
|
|
17
|
+
if (!pos.start || !pos.end) {
|
|
18
|
+
throw new Error(`${apiName}: position must have both start and end`);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
if (params.rotation) {
|
|
22
|
+
const rot = params.rotation;
|
|
23
|
+
if (!rot.start || !rot.end) {
|
|
24
|
+
throw new Error(`${apiName}: rotation must have both start and end`);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
if (params.scale) {
|
|
28
|
+
const scl = params.scale;
|
|
29
|
+
if (!scl.start || !scl.end) {
|
|
30
|
+
throw new Error(`${apiName}: scale must have both start and end`);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
5
34
|
const TweenHelper = {
|
|
6
35
|
Move(move) {
|
|
7
36
|
return {
|
|
@@ -44,6 +73,21 @@ const TweenHelper = {
|
|
|
44
73
|
$case: 'textureMoveContinuous',
|
|
45
74
|
textureMoveContinuous
|
|
46
75
|
};
|
|
76
|
+
},
|
|
77
|
+
MoveRotateScale(params) {
|
|
78
|
+
assertMoveRotateScaleAxesStartEnd(params, 'Tween.Mode.MoveRotateScale');
|
|
79
|
+
const moveRotateScale = {
|
|
80
|
+
positionStart: params.position ? params.position.start : undefined,
|
|
81
|
+
positionEnd: params.position ? params.position.end : undefined,
|
|
82
|
+
rotationStart: params.rotation ? params.rotation.start : undefined,
|
|
83
|
+
rotationEnd: params.rotation ? params.rotation.end : undefined,
|
|
84
|
+
scaleStart: params.scale ? params.scale.start : undefined,
|
|
85
|
+
scaleEnd: params.scale ? params.scale.end : undefined
|
|
86
|
+
};
|
|
87
|
+
return {
|
|
88
|
+
$case: 'moveRotateScale',
|
|
89
|
+
moveRotateScale
|
|
90
|
+
};
|
|
47
91
|
}
|
|
48
92
|
};
|
|
49
93
|
function defineTweenComponent(engine) {
|
|
@@ -150,6 +194,28 @@ function defineTweenComponent(engine) {
|
|
|
150
194
|
easingFunction: 0 /* EasingFunction.EF_LINEAR */,
|
|
151
195
|
playing: true
|
|
152
196
|
});
|
|
197
|
+
},
|
|
198
|
+
setMoveRotateScale(entity, params) {
|
|
199
|
+
assertMoveRotateScaleAxesStartEnd(params, 'setMoveRotateScale');
|
|
200
|
+
assertDuration(params.duration, 'setMoveRotateScale');
|
|
201
|
+
const { position, rotation, scale, duration, easingFunction = 0 /* EasingFunction.EF_LINEAR */ } = params;
|
|
202
|
+
const moveRotateScale = {
|
|
203
|
+
positionStart: position ? position.start : undefined,
|
|
204
|
+
positionEnd: position ? position.end : undefined,
|
|
205
|
+
rotationStart: rotation ? rotation.start : undefined,
|
|
206
|
+
rotationEnd: rotation ? rotation.end : undefined,
|
|
207
|
+
scaleStart: scale ? scale.start : undefined,
|
|
208
|
+
scaleEnd: scale ? scale.end : undefined
|
|
209
|
+
};
|
|
210
|
+
theComponent.createOrReplace(entity, {
|
|
211
|
+
mode: {
|
|
212
|
+
$case: 'moveRotateScale',
|
|
213
|
+
moveRotateScale
|
|
214
|
+
},
|
|
215
|
+
duration,
|
|
216
|
+
easingFunction,
|
|
217
|
+
playing: true
|
|
218
|
+
});
|
|
153
219
|
}
|
|
154
220
|
};
|
|
155
221
|
}
|
|
@@ -77,6 +77,9 @@ export interface PBTween {
|
|
|
77
77
|
} | {
|
|
78
78
|
$case: "textureMoveContinuous";
|
|
79
79
|
textureMoveContinuous: TextureMoveContinuous;
|
|
80
|
+
} | {
|
|
81
|
+
$case: "moveRotateScale";
|
|
82
|
+
moveRotateScale: MoveRotateScale;
|
|
80
83
|
} | undefined;
|
|
81
84
|
/** default true (pause or running) */
|
|
82
85
|
playing?: boolean | undefined;
|
|
@@ -105,6 +108,17 @@ export interface Scale {
|
|
|
105
108
|
start: Vector3 | undefined;
|
|
106
109
|
end: Vector3 | undefined;
|
|
107
110
|
}
|
|
111
|
+
/**
|
|
112
|
+
* @public
|
|
113
|
+
*/
|
|
114
|
+
export interface MoveRotateScale {
|
|
115
|
+
positionStart: Vector3 | undefined;
|
|
116
|
+
positionEnd: Vector3 | undefined;
|
|
117
|
+
rotationStart: Quaternion | undefined;
|
|
118
|
+
rotationEnd: Quaternion | undefined;
|
|
119
|
+
scaleStart: Vector3 | undefined;
|
|
120
|
+
scaleEnd: Vector3 | undefined;
|
|
121
|
+
}
|
|
108
122
|
/**
|
|
109
123
|
* This tween mode allows to move the texture of a PbrMaterial or UnlitMaterial.
|
|
110
124
|
* You can also specify the movement type (offset or tiling)
|
|
@@ -169,6 +183,13 @@ export declare namespace Scale {
|
|
|
169
183
|
function encode(message: Scale, writer?: _m0.Writer): _m0.Writer;
|
|
170
184
|
function decode(input: _m0.Reader | Uint8Array, length?: number): Scale;
|
|
171
185
|
}
|
|
186
|
+
/**
|
|
187
|
+
* @public
|
|
188
|
+
*/
|
|
189
|
+
export declare namespace MoveRotateScale {
|
|
190
|
+
function encode(message: MoveRotateScale, writer?: _m0.Writer): _m0.Writer;
|
|
191
|
+
function decode(input: _m0.Reader | Uint8Array, length?: number): MoveRotateScale;
|
|
192
|
+
}
|
|
172
193
|
/**
|
|
173
194
|
* @public
|
|
174
195
|
*/
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.TextureMoveContinuous = exports.MoveContinuous = exports.RotateContinuous = exports.TextureMove = exports.Scale = exports.Rotate = exports.Move = exports.PBTween = exports.EasingFunction = exports.TextureMovementType = void 0;
|
|
6
|
+
exports.TextureMoveContinuous = exports.MoveContinuous = exports.RotateContinuous = exports.TextureMove = exports.MoveRotateScale = exports.Scale = exports.Rotate = exports.Move = exports.PBTween = exports.EasingFunction = exports.TextureMovementType = void 0;
|
|
7
7
|
/* eslint-disable */
|
|
8
8
|
const minimal_1 = __importDefault(require("protobufjs/minimal"));
|
|
9
9
|
const vectors_gen_1 = require("../../common/vectors.gen");
|
|
@@ -96,6 +96,9 @@ var PBTween;
|
|
|
96
96
|
case "textureMoveContinuous":
|
|
97
97
|
TextureMoveContinuous.encode(message.mode.textureMoveContinuous, writer.uint32(90).fork()).ldelim();
|
|
98
98
|
break;
|
|
99
|
+
case "moveRotateScale":
|
|
100
|
+
MoveRotateScale.encode(message.mode.moveRotateScale, writer.uint32(98).fork()).ldelim();
|
|
101
|
+
break;
|
|
99
102
|
}
|
|
100
103
|
if (message.playing !== undefined) {
|
|
101
104
|
writer.uint32(48).bool(message.playing);
|
|
@@ -173,6 +176,12 @@ var PBTween;
|
|
|
173
176
|
textureMoveContinuous: TextureMoveContinuous.decode(reader, reader.uint32()),
|
|
174
177
|
};
|
|
175
178
|
continue;
|
|
179
|
+
case 12:
|
|
180
|
+
if (tag !== 98) {
|
|
181
|
+
break;
|
|
182
|
+
}
|
|
183
|
+
message.mode = { $case: "moveRotateScale", moveRotateScale: MoveRotateScale.decode(reader, reader.uint32()) };
|
|
184
|
+
continue;
|
|
176
185
|
case 6:
|
|
177
186
|
if (tag !== 48) {
|
|
178
187
|
break;
|
|
@@ -345,6 +354,96 @@ var Scale;
|
|
|
345
354
|
}
|
|
346
355
|
Scale.decode = decode;
|
|
347
356
|
})(Scale = exports.Scale || (exports.Scale = {}));
|
|
357
|
+
function createBaseMoveRotateScale() {
|
|
358
|
+
return {
|
|
359
|
+
positionStart: undefined,
|
|
360
|
+
positionEnd: undefined,
|
|
361
|
+
rotationStart: undefined,
|
|
362
|
+
rotationEnd: undefined,
|
|
363
|
+
scaleStart: undefined,
|
|
364
|
+
scaleEnd: undefined,
|
|
365
|
+
};
|
|
366
|
+
}
|
|
367
|
+
/**
|
|
368
|
+
* @public
|
|
369
|
+
*/
|
|
370
|
+
var MoveRotateScale;
|
|
371
|
+
(function (MoveRotateScale) {
|
|
372
|
+
function encode(message, writer = minimal_1.default.Writer.create()) {
|
|
373
|
+
if (message.positionStart !== undefined) {
|
|
374
|
+
vectors_gen_1.Vector3.encode(message.positionStart, writer.uint32(10).fork()).ldelim();
|
|
375
|
+
}
|
|
376
|
+
if (message.positionEnd !== undefined) {
|
|
377
|
+
vectors_gen_1.Vector3.encode(message.positionEnd, writer.uint32(18).fork()).ldelim();
|
|
378
|
+
}
|
|
379
|
+
if (message.rotationStart !== undefined) {
|
|
380
|
+
vectors_gen_1.Quaternion.encode(message.rotationStart, writer.uint32(26).fork()).ldelim();
|
|
381
|
+
}
|
|
382
|
+
if (message.rotationEnd !== undefined) {
|
|
383
|
+
vectors_gen_1.Quaternion.encode(message.rotationEnd, writer.uint32(34).fork()).ldelim();
|
|
384
|
+
}
|
|
385
|
+
if (message.scaleStart !== undefined) {
|
|
386
|
+
vectors_gen_1.Vector3.encode(message.scaleStart, writer.uint32(42).fork()).ldelim();
|
|
387
|
+
}
|
|
388
|
+
if (message.scaleEnd !== undefined) {
|
|
389
|
+
vectors_gen_1.Vector3.encode(message.scaleEnd, writer.uint32(50).fork()).ldelim();
|
|
390
|
+
}
|
|
391
|
+
return writer;
|
|
392
|
+
}
|
|
393
|
+
MoveRotateScale.encode = encode;
|
|
394
|
+
function decode(input, length) {
|
|
395
|
+
const reader = input instanceof minimal_1.default.Reader ? input : minimal_1.default.Reader.create(input);
|
|
396
|
+
let end = length === undefined ? reader.len : reader.pos + length;
|
|
397
|
+
const message = createBaseMoveRotateScale();
|
|
398
|
+
while (reader.pos < end) {
|
|
399
|
+
const tag = reader.uint32();
|
|
400
|
+
switch (tag >>> 3) {
|
|
401
|
+
case 1:
|
|
402
|
+
if (tag !== 10) {
|
|
403
|
+
break;
|
|
404
|
+
}
|
|
405
|
+
message.positionStart = vectors_gen_1.Vector3.decode(reader, reader.uint32());
|
|
406
|
+
continue;
|
|
407
|
+
case 2:
|
|
408
|
+
if (tag !== 18) {
|
|
409
|
+
break;
|
|
410
|
+
}
|
|
411
|
+
message.positionEnd = vectors_gen_1.Vector3.decode(reader, reader.uint32());
|
|
412
|
+
continue;
|
|
413
|
+
case 3:
|
|
414
|
+
if (tag !== 26) {
|
|
415
|
+
break;
|
|
416
|
+
}
|
|
417
|
+
message.rotationStart = vectors_gen_1.Quaternion.decode(reader, reader.uint32());
|
|
418
|
+
continue;
|
|
419
|
+
case 4:
|
|
420
|
+
if (tag !== 34) {
|
|
421
|
+
break;
|
|
422
|
+
}
|
|
423
|
+
message.rotationEnd = vectors_gen_1.Quaternion.decode(reader, reader.uint32());
|
|
424
|
+
continue;
|
|
425
|
+
case 5:
|
|
426
|
+
if (tag !== 42) {
|
|
427
|
+
break;
|
|
428
|
+
}
|
|
429
|
+
message.scaleStart = vectors_gen_1.Vector3.decode(reader, reader.uint32());
|
|
430
|
+
continue;
|
|
431
|
+
case 6:
|
|
432
|
+
if (tag !== 50) {
|
|
433
|
+
break;
|
|
434
|
+
}
|
|
435
|
+
message.scaleEnd = vectors_gen_1.Vector3.decode(reader, reader.uint32());
|
|
436
|
+
continue;
|
|
437
|
+
}
|
|
438
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
439
|
+
break;
|
|
440
|
+
}
|
|
441
|
+
reader.skipType(tag & 7);
|
|
442
|
+
}
|
|
443
|
+
return message;
|
|
444
|
+
}
|
|
445
|
+
MoveRotateScale.decode = decode;
|
|
446
|
+
})(MoveRotateScale = exports.MoveRotateScale || (exports.MoveRotateScale = {}));
|
|
348
447
|
function createBaseTextureMove() {
|
|
349
448
|
return { start: undefined, end: undefined, movementType: undefined };
|
|
350
449
|
}
|
|
@@ -4,7 +4,7 @@ export type { AudioStreamComponentDefinitionExtended } from './extended/AudioStr
|
|
|
4
4
|
export type { MeshRendererComponentDefinitionExtended } from './extended/MeshRenderer';
|
|
5
5
|
export type { MeshColliderComponentDefinitionExtended } from './extended/MeshCollider';
|
|
6
6
|
export type { TextureHelper, MaterialComponentDefinitionExtended, FlatTexture, ReadonlyFlatMaterial, ReadonlyFlatTexture, FlatMaterial } from './extended/Material';
|
|
7
|
-
export type { TweenHelper, TweenComponentDefinitionExtended } from './extended/Tween';
|
|
7
|
+
export type { TweenHelper, TweenComponentDefinitionExtended, SetMoveRotateScaleParams, MoveRotateScaleModeParams } from './extended/Tween';
|
|
8
8
|
export type { CameraTransitionHelper, VirtualCameraComponentDefinitionExtended } from './extended/VirtualCamera';
|
|
9
9
|
export type { TransformComponentExtended, TransformTypeWithOptionals } from './manual/Transform';
|
|
10
10
|
export type { NameComponent, NameType } from './manual/Name';
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dcl/ecs",
|
|
3
3
|
"description": "Decentraland ECS",
|
|
4
|
-
"version": "7.20.5-
|
|
4
|
+
"version": "7.20.5-22673942652.commit-fcc5752",
|
|
5
5
|
"author": "DCL",
|
|
6
6
|
"bugs": "https://github.com/decentraland/ecs/issues",
|
|
7
7
|
"files": [
|
|
@@ -33,5 +33,5 @@
|
|
|
33
33
|
},
|
|
34
34
|
"types": "./dist/index.d.ts",
|
|
35
35
|
"typings": "./dist/index.d.ts",
|
|
36
|
-
"commit": "
|
|
36
|
+
"commit": "fcc5752c5ba7b1945aff1898e7989b4cb91e94b1"
|
|
37
37
|
}
|