Skip to content

Commit 6fd3174

Browse files
committed
Merge remote-tracking branch 'origin/main' into auth-server
# Conflicts: # test/snapshots/development-bundles/static-scene.test.ts.crdt # test/snapshots/development-bundles/testing-fw.test.ts.crdt # test/snapshots/development-bundles/two-way-crdt.test.ts.crdt # test/snapshots/production-bundles/append-value-crdt.ts.crdt # test/snapshots/production-bundles/billboard.ts.crdt # test/snapshots/production-bundles/cube-deleted.ts.crdt # test/snapshots/production-bundles/cube.ts.crdt # test/snapshots/production-bundles/cubes.ts.crdt # test/snapshots/production-bundles/pointer-events.ts.crdt # test/snapshots/production-bundles/schema-components.ts.crdt # test/snapshots/production-bundles/ui.ts.crdt # test/snapshots/production-bundles/with-main-function.ts.crdt
2 parents 34c867c + 9d0cc3a commit 6fd3174

27 files changed

Lines changed: 698 additions & 131 deletions

package-lock.json

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"bugs": "https://github.com/decentraland/js-sdk-toolchain/issues",
77
"dependencies": {
88
"@actions/core": "^1.10.0",
9-
"@dcl/protocol": "1.0.0-21519068572.commit-814b279",
9+
"@dcl/protocol": "1.0.0-22669986637.commit-fb11819",
1010
"@dcl/quickjs-emscripten": "^0.21.0-3680274614.commit-1808aa1",
1111
"@dcl/ts-proto": "1.153.0",
1212
"@types/fs-extra": "^9.0.12",

packages/@dcl/ecs/src/components/extended/Tween.ts

Lines changed: 112 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {
44
EasingFunction,
55
Move,
66
MoveContinuous,
7+
MoveRotateScale,
78
PBTween,
89
Rotate,
910
RotateContinuous,
@@ -14,6 +15,63 @@ import {
1415
Tween
1516
} from '../generated/index.gen'
1617

18+
/**
19+
* @public
20+
* Partial params for Tween.Mode.MoveRotateScale(). At least one of position, rotation, or scale must be provided.
21+
* Use this when building a mode for Tween.createOrReplace() or TweenSequence (e.g. only positionStart/positionEnd).
22+
*/
23+
export interface MoveRotateScaleModeParams {
24+
/** Position tween (start → end). Optional. */
25+
position?: { start: Vector3; end: Vector3 }
26+
/** Rotation tween (start → end). Optional. */
27+
rotation?: { start: Quaternion; end: Quaternion }
28+
/** Scale tween (start → end). Optional. */
29+
scale?: { start: Vector3; end: Vector3 }
30+
}
31+
32+
/**
33+
* @public
34+
* Parameters for setMoveRotateScale. At least one of position, rotation, or scale must be provided.
35+
*/
36+
export interface SetMoveRotateScaleParams extends MoveRotateScaleModeParams {
37+
/** Duration of the tween in milliseconds. */
38+
duration: number
39+
/** Easing function (defaults to EF_LINEAR). */
40+
easingFunction?: EasingFunction
41+
}
42+
43+
function assertDuration(duration: number, apiName: string): void {
44+
if (!Number.isFinite(duration) || duration < 0) {
45+
throw new Error(`${apiName}: duration must be a non-negative finite number`)
46+
}
47+
}
48+
49+
/** Shared validation for params that have optional position/rotation/scale with start & end. */
50+
function assertMoveRotateScaleAxesStartEnd(params: MoveRotateScaleModeParams, apiName: string): void {
51+
if (!params.position && !params.rotation && !params.scale) {
52+
throw new Error(`${apiName}: at least one of position, rotation, or scale must be provided`)
53+
}
54+
55+
if (params.position) {
56+
const pos = params.position!
57+
if (!pos.start || !pos.end) {
58+
throw new Error(`${apiName}: position must have both start and end`)
59+
}
60+
}
61+
if (params.rotation) {
62+
const rot = params.rotation!
63+
if (!rot.start || !rot.end) {
64+
throw new Error(`${apiName}: rotation must have both start and end`)
65+
}
66+
}
67+
if (params.scale) {
68+
const scl = params.scale!
69+
if (!scl.start || !scl.end) {
70+
throw new Error(`${apiName}: scale must have both start and end`)
71+
}
72+
}
73+
}
74+
1775
/**
1876
* @public
1977
*/
@@ -46,14 +104,19 @@ export interface TweenHelper {
46104
* @returns a texture-move-continuous mode tween
47105
*/
48106
TextureMoveContinuous: (textureMove: TextureMoveContinuous) => PBTween['mode']
107+
/**
108+
* @returns a move-rotate-scale mode tween
109+
* @param params - partial transform (at least one of position, rotation, scale); omit axes you don't need
110+
*/
111+
MoveRotateScale: (params: MoveRotateScaleModeParams) => PBTween['mode']
49112
}
50113

51114
/**
52115
* @public
53116
*/
54117
export interface TweenComponentDefinitionExtended extends LastWriteWinElementSetComponentDefinition<PBTween> {
55118
/**
56-
* Texture helpers with constructor
119+
* Helpers with constructor
57120
*/
58121
Mode: TweenHelper
59122

@@ -152,6 +215,17 @@ export interface TweenComponentDefinitionExtended extends LastWriteWinElementSet
152215
movementType?: TextureMovementType,
153216
duration?: number
154217
): void
218+
219+
/**
220+
* @public
221+
*
222+
* Creates or replaces a move-rotate-scale tween component that simultaneously animates
223+
* an entity's position, rotation, and/or scale from start to end. Provide only the
224+
* properties you need (at least one of position, rotation, or scale).
225+
* @param entity - entity to apply the tween to
226+
* @param params - object with optional position, rotation, scale (each with start/end), duration, and optional easingFunction
227+
*/
228+
setMoveRotateScale(entity: Entity, params: SetMoveRotateScaleParams): void
155229
}
156230

157231
const TweenHelper: TweenHelper = {
@@ -196,6 +270,21 @@ const TweenHelper: TweenHelper = {
196270
$case: 'textureMoveContinuous',
197271
textureMoveContinuous
198272
}
273+
},
274+
MoveRotateScale(params) {
275+
assertMoveRotateScaleAxesStartEnd(params, 'Tween.Mode.MoveRotateScale')
276+
const moveRotateScale: MoveRotateScale = {
277+
positionStart: params.position ? params.position.start : undefined,
278+
positionEnd: params.position ? params.position.end : undefined,
279+
rotationStart: params.rotation ? params.rotation.start : undefined,
280+
rotationEnd: params.rotation ? params.rotation.end : undefined,
281+
scaleStart: params.scale ? params.scale.start : undefined,
282+
scaleEnd: params.scale ? params.scale!.end : undefined
283+
}
284+
return {
285+
$case: 'moveRotateScale',
286+
moveRotateScale
287+
}
199288
}
200289
}
201290

@@ -337,6 +426,28 @@ export function defineTweenComponent(
337426
easingFunction: EasingFunction.EF_LINEAR,
338427
playing: true
339428
})
429+
},
430+
setMoveRotateScale(entity: Entity, params: SetMoveRotateScaleParams) {
431+
assertMoveRotateScaleAxesStartEnd(params, 'setMoveRotateScale')
432+
assertDuration(params.duration, 'setMoveRotateScale')
433+
const { position, rotation, scale, duration, easingFunction = EasingFunction.EF_LINEAR } = params
434+
const moveRotateScale: MoveRotateScale = {
435+
positionStart: position ? position.start : undefined,
436+
positionEnd: position ? position.end : undefined,
437+
rotationStart: rotation ? rotation.start : undefined,
438+
rotationEnd: rotation ? rotation.end : undefined,
439+
scaleStart: scale ? scale.start : undefined,
440+
scaleEnd: scale ? scale.end : undefined
441+
}
442+
theComponent.createOrReplace(entity, {
443+
mode: {
444+
$case: 'moveRotateScale',
445+
moveRotateScale
446+
},
447+
duration,
448+
easingFunction,
449+
playing: true
450+
})
340451
}
341452
}
342453
}

packages/@dcl/ecs/src/components/types.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,12 @@ export type {
1111
ReadonlyFlatTexture,
1212
FlatMaterial
1313
} from './extended/Material'
14-
export type { TweenHelper, TweenComponentDefinitionExtended } from './extended/Tween'
14+
export type {
15+
TweenHelper,
16+
TweenComponentDefinitionExtended,
17+
SetMoveRotateScaleParams,
18+
MoveRotateScaleModeParams
19+
} from './extended/Tween'
1520
export type { CameraTransitionHelper, VirtualCameraComponentDefinitionExtended } from './extended/VirtualCamera'
1621
export type { TransformComponentExtended, TransformTypeWithOptionals } from './manual/Transform'
1722
export type { NameComponent, NameType } from './manual/Name'

packages/@dcl/ecs/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// The order of the following imports matters. Please do not auto-sort
22
export * from './engine'
33
export * from './schemas'
4+
export * from './runtime/globals'
45
export * from './runtime/initialization'
56
export * from './runtime/types'
67
export * from './runtime/helpers'

packages/@dcl/ecs/src/runtime/globals.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44

55
/**
66
* Type-safe globalThis property access.
7-
* @internal
7+
* @public
88
*/
99
export function getGlobal<T>(key: string): T | undefined {
1010
return (globalThis as any)[key]
1111
}
1212

1313
/**
1414
* Sets a globalThis property as a polyfill (only if undefined/null).
15-
* @internal
15+
* @public
1616
*/
1717
export function setGlobalPolyfill<T>(key: string, value: T): void {
1818
;(globalThis as any)[key] = (globalThis as any)[key] ?? value

0 commit comments

Comments
 (0)