@dcl/ecs 7.12.3-19242573384.commit-09d14b4 → 7.12.3-19269914897.commit-1299cf2
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/TriggerArea.d.ts +22 -0
- package/dist/components/extended/TriggerArea.js +27 -0
- package/dist/components/extended/Tween.d.ts +94 -5
- package/dist/components/extended/Tween.js +119 -1
- package/dist/components/generated/CameraLayer.gen.js +1 -1
- package/dist/components/generated/component-names.gen.js +1 -1
- package/dist/components/generated/global.gen.d.ts +1 -1
- package/dist/components/generated/index.gen.d.ts +2 -2
- package/dist/components/generated/index.gen.js +4 -2
- package/dist/components/index.d.ts +4 -0
- package/dist/components/index.js +6 -0
- package/dist/components/manual/Tags.d.ts +34 -0
- package/dist/components/manual/Tags.js +37 -0
- package/dist/components/types.d.ts +3 -0
- package/dist/engine/index.js +10 -0
- package/dist/engine/types.d.ts +7 -0
- package/dist/index.d.ts +6 -5
- package/dist/index.js +4 -3
- package/dist/runtime/initialization/index.d.ts +7 -0
- package/dist/runtime/initialization/index.js +6 -0
- package/dist/systems/crdt/index.d.ts +1 -0
- package/dist/systems/crdt/index.js +17 -5
- package/dist/systems/triggerArea.d.ts +50 -0
- package/dist/systems/triggerArea.js +113 -0
- package/dist-cjs/components/extended/TriggerArea.d.ts +22 -0
- package/dist-cjs/components/extended/TriggerArea.js +31 -0
- package/dist-cjs/components/extended/Tween.d.ts +94 -5
- package/dist-cjs/components/extended/Tween.js +119 -1
- package/dist-cjs/components/generated/CameraLayer.gen.js +1 -1
- package/dist-cjs/components/generated/component-names.gen.js +1 -1
- package/dist-cjs/components/generated/global.gen.d.ts +1 -1
- package/dist-cjs/components/generated/index.gen.d.ts +2 -2
- package/dist-cjs/components/generated/index.gen.js +4 -2
- package/dist-cjs/components/index.d.ts +4 -0
- package/dist-cjs/components/index.js +9 -1
- package/dist-cjs/components/manual/Tags.d.ts +34 -0
- package/dist-cjs/components/manual/Tags.js +39 -0
- package/dist-cjs/components/types.d.ts +3 -0
- package/dist-cjs/engine/index.js +10 -0
- package/dist-cjs/engine/types.d.ts +7 -0
- package/dist-cjs/index.d.ts +6 -5
- package/dist-cjs/index.js +5 -4
- package/dist-cjs/runtime/initialization/index.d.ts +7 -0
- package/dist-cjs/runtime/initialization/index.js +7 -1
- package/dist-cjs/systems/crdt/index.d.ts +1 -0
- package/dist-cjs/systems/crdt/index.js +18 -6
- package/dist-cjs/systems/triggerArea.d.ts +50 -0
- package/dist-cjs/systems/triggerArea.js +140 -0
- package/package.json +2 -2
|
@@ -10,6 +10,7 @@ import { createRaycastSystem } from '../../systems/raycast';
|
|
|
10
10
|
import { createVideoEventsSystem } from '../../systems/videoEvents';
|
|
11
11
|
import { createTweenSystem } from '../../systems/tween';
|
|
12
12
|
import { pointerEventColliderChecker } from '../../systems/pointer-event-collider-checker';
|
|
13
|
+
import { createTriggerAreaEventsSystem } from '../../systems/triggerArea';
|
|
13
14
|
/**
|
|
14
15
|
* @public
|
|
15
16
|
* The engine is the part of the scene that sits in the middle and manages all of the other parts.
|
|
@@ -52,6 +53,11 @@ export const videoEventsSystem = /* @__PURE__ */ createVideoEventsSystem(engine)
|
|
|
52
53
|
* Register callback functions to a particular entity on video events.
|
|
53
54
|
*/
|
|
54
55
|
export const tweenSystem = createTweenSystem(engine);
|
|
56
|
+
/**
|
|
57
|
+
* @public
|
|
58
|
+
* Register callback functions for trigger area results.
|
|
59
|
+
*/
|
|
60
|
+
export const triggerAreaEventsSystem = /* @__PURE__ */ createTriggerAreaEventsSystem(engine);
|
|
55
61
|
/**
|
|
56
62
|
* Adds pointer event collider system only in DEV env
|
|
57
63
|
*/
|
|
@@ -8,6 +8,8 @@ import { CrdtMessageType } from '../../serialization/crdt/types';
|
|
|
8
8
|
import { PutNetworkComponentOperation } from '../../serialization/crdt/network/putComponentNetwork';
|
|
9
9
|
import { NetworkEntity as defineNetworkEntity, NetworkParent as defineNetworkParent, Transform as defineTransform } from '../../components';
|
|
10
10
|
import * as networkUtils from '../../serialization/crdt/network/utils';
|
|
11
|
+
// NetworkMessages can only have a MAX_SIZE of 12kb. So we need to send it in chunks.
|
|
12
|
+
export const LIVEKIT_MAX_SIZE = 12;
|
|
11
13
|
/**
|
|
12
14
|
* @internal
|
|
13
15
|
*/
|
|
@@ -206,8 +208,6 @@ export function crdtSceneSystem(engine, onProcessEntityComponentChange) {
|
|
|
206
208
|
// Send CRDT messages to transports
|
|
207
209
|
const transportBuffer = new ReadWriteByteBuffer();
|
|
208
210
|
for (const index in transports) {
|
|
209
|
-
// NetworkMessages can only have a MAX_SIZE of 13kb. So we need to send it in chunks.
|
|
210
|
-
const LIVEKIT_MAX_SIZE = 13;
|
|
211
211
|
const __NetworkMessagesBuffer = [];
|
|
212
212
|
const transportIndex = Number(index);
|
|
213
213
|
const transport = transports[transportIndex];
|
|
@@ -218,9 +218,21 @@ export function crdtSceneSystem(engine, onProcessEntityComponentChange) {
|
|
|
218
218
|
const buffer = new ReadWriteByteBuffer();
|
|
219
219
|
// Then we send all the new crdtMessages that the transport needs to process
|
|
220
220
|
for (const message of crdtMessages) {
|
|
221
|
-
if
|
|
222
|
-
|
|
223
|
-
|
|
221
|
+
// Check if adding this message would exceed the size limit
|
|
222
|
+
const currentBufferSize = transportBuffer.toBinary().byteLength;
|
|
223
|
+
const messageSize = message.messageBuffer.byteLength;
|
|
224
|
+
if (isNetworkTransport && (currentBufferSize + messageSize) / 1024 > LIVEKIT_MAX_SIZE) {
|
|
225
|
+
// If the current buffer has content, save it as a chunk
|
|
226
|
+
if (currentBufferSize > 0) {
|
|
227
|
+
__NetworkMessagesBuffer.push(transportBuffer.toCopiedBinary());
|
|
228
|
+
transportBuffer.resetBuffer();
|
|
229
|
+
}
|
|
230
|
+
// If the message itself is larger than the limit, we need to handle it specially
|
|
231
|
+
// For now, we'll skip it to prevent infinite loops
|
|
232
|
+
if (messageSize / 1024 > LIVEKIT_MAX_SIZE) {
|
|
233
|
+
console.error(`Message too large (${messageSize} bytes), skipping message for entity ${message.entityId}`);
|
|
234
|
+
continue;
|
|
235
|
+
}
|
|
224
236
|
}
|
|
225
237
|
// Avoid echo messages
|
|
226
238
|
if (message.transportId === transportIndex)
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { DeepReadonlyObject, Entity } from '../engine';
|
|
2
|
+
import { PBTriggerAreaResult } from '../components';
|
|
3
|
+
/**
|
|
4
|
+
* @public
|
|
5
|
+
*/
|
|
6
|
+
export type TriggerAreaEventSystemCallback = (result: DeepReadonlyObject<PBTriggerAreaResult>) => void;
|
|
7
|
+
/**
|
|
8
|
+
* @public
|
|
9
|
+
*/
|
|
10
|
+
export interface TriggerAreaEventsSystem {
|
|
11
|
+
/**
|
|
12
|
+
* @public
|
|
13
|
+
* Execute callback when an entity enters the Trigger Area
|
|
14
|
+
* @param entity - The entity that already has the TriggerArea component
|
|
15
|
+
* @param cb - Function to execute the 'Enter' type of result is detected
|
|
16
|
+
*/
|
|
17
|
+
onTriggerEnter(entity: Entity, cb: TriggerAreaEventSystemCallback): void;
|
|
18
|
+
/**
|
|
19
|
+
* @public
|
|
20
|
+
* Remove the callback for Trigger Area 'Enter' type of result
|
|
21
|
+
* @param entity - Entity where the Trigger Area was attached
|
|
22
|
+
*/
|
|
23
|
+
removeOnTriggerEnter(entity: Entity): void;
|
|
24
|
+
/**
|
|
25
|
+
* @public
|
|
26
|
+
* Execute callback when an entity stays in the Trigger Area
|
|
27
|
+
* @param entity - The entity that already has the TriggerArea component
|
|
28
|
+
* @param cb - Function to execute the 'Stay' type of result is detected
|
|
29
|
+
*/
|
|
30
|
+
onTriggerStay(entity: Entity, cb: TriggerAreaEventSystemCallback): void;
|
|
31
|
+
/**
|
|
32
|
+
* @public
|
|
33
|
+
* Remove the callback for Trigger Area 'Stay' type of result
|
|
34
|
+
* @param entity - Entity where the Trigger Area was attached
|
|
35
|
+
*/
|
|
36
|
+
removeOnTriggerStay(entity: Entity): void;
|
|
37
|
+
/**
|
|
38
|
+
* @public
|
|
39
|
+
* Execute callback when an entity exits the Trigger Area
|
|
40
|
+
* @param entity - The entity that already has the TriggerArea component
|
|
41
|
+
* @param cb - Function to execute the 'Exit' type of result is detected
|
|
42
|
+
*/
|
|
43
|
+
onTriggerExit(entity: Entity, cb: TriggerAreaEventSystemCallback): void;
|
|
44
|
+
/**
|
|
45
|
+
* @public
|
|
46
|
+
* Remove the callback for Trigger Area 'Exit' type of result
|
|
47
|
+
* @param entity - Entity where the Trigger Area was attached
|
|
48
|
+
*/
|
|
49
|
+
removeOnTriggerExit(entity: Entity): void;
|
|
50
|
+
}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import * as components from '../components';
|
|
2
|
+
import { EntityState } from '../engine/entity';
|
|
3
|
+
/**
|
|
4
|
+
* @internal
|
|
5
|
+
*/
|
|
6
|
+
export function createTriggerAreaEventsSystem(engine) {
|
|
7
|
+
const triggerAreaResultComponent = components.TriggerAreaResult(engine);
|
|
8
|
+
const entitiesMap = new Map();
|
|
9
|
+
function hasCallbacksMap(entity) {
|
|
10
|
+
return entitiesMap.has(entity) && entitiesMap.get(entity) !== undefined;
|
|
11
|
+
}
|
|
12
|
+
function addEntityCallback(entity, triggerType, callback) {
|
|
13
|
+
if (hasCallbacksMap(entity)) {
|
|
14
|
+
entitiesMap.get(entity).triggerCallbackMap.set(triggerType, callback);
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
entitiesMap.set(entity, {
|
|
18
|
+
triggerCallbackMap: new Map([[triggerType, callback]]),
|
|
19
|
+
lastConsumedTimestamp: -1
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
function removeEntityCallback(entity, triggerType) {
|
|
24
|
+
if (!entitiesMap.has(entity) || !entitiesMap.get(entity).triggerCallbackMap.has(triggerType))
|
|
25
|
+
return;
|
|
26
|
+
const triggerCallbackMap = entitiesMap.get(entity).triggerCallbackMap;
|
|
27
|
+
triggerCallbackMap.delete(triggerType);
|
|
28
|
+
// Remove entity if no more trigger callbacks are registered
|
|
29
|
+
if (triggerCallbackMap.size === 0)
|
|
30
|
+
entitiesMap.delete(entity);
|
|
31
|
+
}
|
|
32
|
+
function onTriggerEnter(entity, cb) {
|
|
33
|
+
addEntityCallback(entity, 0 /* TriggerAreaEventType.TAET_ENTER */, cb);
|
|
34
|
+
}
|
|
35
|
+
function removeOnTriggerEnter(entity) {
|
|
36
|
+
removeEntityCallback(entity, 0 /* TriggerAreaEventType.TAET_ENTER */);
|
|
37
|
+
}
|
|
38
|
+
function onTriggerStay(entity, cb) {
|
|
39
|
+
addEntityCallback(entity, 1 /* TriggerAreaEventType.TAET_STAY */, cb);
|
|
40
|
+
}
|
|
41
|
+
function removeOnTriggerStay(entity) {
|
|
42
|
+
removeEntityCallback(entity, 1 /* TriggerAreaEventType.TAET_STAY */);
|
|
43
|
+
}
|
|
44
|
+
function onTriggerExit(entity, cb) {
|
|
45
|
+
addEntityCallback(entity, 2 /* TriggerAreaEventType.TAET_EXIT */, cb);
|
|
46
|
+
}
|
|
47
|
+
function removeOnTriggerExit(entity) {
|
|
48
|
+
removeEntityCallback(entity, 2 /* TriggerAreaEventType.TAET_EXIT */);
|
|
49
|
+
}
|
|
50
|
+
engine.addSystem(function TriggerAreaResultSystem() {
|
|
51
|
+
const garbageEntries = [];
|
|
52
|
+
for (const [entity, data] of entitiesMap) {
|
|
53
|
+
if (engine.getEntityState(entity) === EntityState.Removed) {
|
|
54
|
+
garbageEntries.push(entity);
|
|
55
|
+
continue;
|
|
56
|
+
}
|
|
57
|
+
const result = triggerAreaResultComponent.get(entity);
|
|
58
|
+
// The Explorer may be taking time before the result component is put
|
|
59
|
+
if (result.size === 0)
|
|
60
|
+
continue;
|
|
61
|
+
const values = Array.from(result.values());
|
|
62
|
+
// determine starting index for new values (more than one could be added between System updates)
|
|
63
|
+
// search backwards to find the anchor at lastConsumedTimestamp
|
|
64
|
+
let startIndex = 0;
|
|
65
|
+
if (data.lastConsumedTimestamp >= 0) {
|
|
66
|
+
const newestTimestamp = values[values.length - 1].timestamp;
|
|
67
|
+
// if nothing new, skip processing
|
|
68
|
+
if (newestTimestamp <= data.lastConsumedTimestamp) {
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
// Find index of value with the lastConsumedTimestamp
|
|
72
|
+
let i = values.length - 2;
|
|
73
|
+
while (i >= 0 && values[i].timestamp > data.lastConsumedTimestamp)
|
|
74
|
+
i--;
|
|
75
|
+
// Mark the following value index as the starting point to trigger all the new value callbacks
|
|
76
|
+
startIndex = i + 1;
|
|
77
|
+
}
|
|
78
|
+
if (startIndex >= values.length)
|
|
79
|
+
continue;
|
|
80
|
+
// Trigger callbacks for all the new values
|
|
81
|
+
for (let i = startIndex; i < values.length; i++) {
|
|
82
|
+
switch (values[i].eventType) {
|
|
83
|
+
case 0 /* TriggerAreaEventType.TAET_ENTER */:
|
|
84
|
+
if (!data.triggerCallbackMap.has(0 /* TriggerAreaEventType.TAET_ENTER */))
|
|
85
|
+
continue;
|
|
86
|
+
data.triggerCallbackMap.get(0 /* TriggerAreaEventType.TAET_ENTER */)(values[i]);
|
|
87
|
+
break;
|
|
88
|
+
case 1 /* TriggerAreaEventType.TAET_STAY */:
|
|
89
|
+
if (!data.triggerCallbackMap.has(1 /* TriggerAreaEventType.TAET_STAY */))
|
|
90
|
+
continue;
|
|
91
|
+
data.triggerCallbackMap.get(1 /* TriggerAreaEventType.TAET_STAY */)(values[i]);
|
|
92
|
+
break;
|
|
93
|
+
case 2 /* TriggerAreaEventType.TAET_EXIT */:
|
|
94
|
+
if (!data.triggerCallbackMap.has(2 /* TriggerAreaEventType.TAET_EXIT */))
|
|
95
|
+
continue;
|
|
96
|
+
data.triggerCallbackMap.get(2 /* TriggerAreaEventType.TAET_EXIT */)(values[i]);
|
|
97
|
+
break;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
data.lastConsumedTimestamp = values[values.length - 1].timestamp;
|
|
101
|
+
}
|
|
102
|
+
// Clean up garbage entries
|
|
103
|
+
garbageEntries.forEach((garbageEntity) => entitiesMap.delete(garbageEntity));
|
|
104
|
+
});
|
|
105
|
+
return {
|
|
106
|
+
onTriggerEnter,
|
|
107
|
+
removeOnTriggerEnter,
|
|
108
|
+
onTriggerStay,
|
|
109
|
+
removeOnTriggerStay,
|
|
110
|
+
onTriggerExit,
|
|
111
|
+
removeOnTriggerExit
|
|
112
|
+
};
|
|
113
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Entity, IEngine, LastWriteWinElementSetComponentDefinition } from '../../engine';
|
|
2
|
+
import { ColliderLayer, PBTriggerArea } from '../generated/index.gen';
|
|
3
|
+
/**
|
|
4
|
+
* @public
|
|
5
|
+
*/
|
|
6
|
+
export interface TriggerAreaComponentDefinitionExtended extends LastWriteWinElementSetComponentDefinition<PBTriggerArea> {
|
|
7
|
+
/**
|
|
8
|
+
* @public
|
|
9
|
+
* Set a box in the MeshCollider component
|
|
10
|
+
* @param entity - entity to create or replace the TriggerArea component
|
|
11
|
+
* @param collisionMask - the collision layers mask for the trigger to react, default: Player
|
|
12
|
+
*/
|
|
13
|
+
setBox(entity: Entity, collisionMask?: ColliderLayer | ColliderLayer[]): void;
|
|
14
|
+
/**
|
|
15
|
+
* @public
|
|
16
|
+
* Set a sphere in the MeshCollider component
|
|
17
|
+
* @param entity - entity to create or replace the TriggerArea component
|
|
18
|
+
* @param collisionMask - the collision layers mask for the trigger to react, default: Player
|
|
19
|
+
*/
|
|
20
|
+
setSphere(entity: Entity, collisionMask?: ColliderLayer | ColliderLayer[]): void;
|
|
21
|
+
}
|
|
22
|
+
export declare function defineTriggerAreaComponent(engine: Pick<IEngine, 'defineComponentFromSchema'>): TriggerAreaComponentDefinitionExtended;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.defineTriggerAreaComponent = void 0;
|
|
4
|
+
const index_gen_1 = require("../generated/index.gen");
|
|
5
|
+
function defineTriggerAreaComponent(engine) {
|
|
6
|
+
const theComponent = (0, index_gen_1.TriggerArea)(engine);
|
|
7
|
+
function getCollisionMask(layers) {
|
|
8
|
+
if (Array.isArray(layers)) {
|
|
9
|
+
return layers.map((item) => item).reduce((prev, item) => prev | item, 0);
|
|
10
|
+
}
|
|
11
|
+
else if (layers) {
|
|
12
|
+
return layers;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
return {
|
|
16
|
+
...theComponent,
|
|
17
|
+
setBox(entity, collisionMask) {
|
|
18
|
+
theComponent.createOrReplace(entity, {
|
|
19
|
+
mesh: 0 /* TriggerAreaMeshType.TAMT_BOX */,
|
|
20
|
+
collisionMask: getCollisionMask(collisionMask)
|
|
21
|
+
});
|
|
22
|
+
},
|
|
23
|
+
setSphere(entity, collisionMask) {
|
|
24
|
+
theComponent.createOrReplace(entity, {
|
|
25
|
+
mesh: 1 /* TriggerAreaMeshType.TAMT_SPHERE */,
|
|
26
|
+
collisionMask: getCollisionMask(collisionMask)
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
exports.defineTriggerAreaComponent = defineTriggerAreaComponent;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { IEngine, LastWriteWinElementSetComponentDefinition } from '../../engine';
|
|
2
|
-
import {
|
|
1
|
+
import { Entity, IEngine, LastWriteWinElementSetComponentDefinition } from '../../engine';
|
|
2
|
+
import { Quaternion, Vector2, Vector3 } from '../generated/pb/decentraland/common/vectors.gen';
|
|
3
|
+
import { EasingFunction, Move, MoveContinuous, PBTween, Rotate, RotateContinuous, Scale, TextureMove, TextureMoveContinuous, TextureMovementType } from '../generated/index.gen';
|
|
3
4
|
/**
|
|
4
5
|
* @public
|
|
5
6
|
*/
|
|
@@ -9,17 +10,29 @@ export interface TweenHelper {
|
|
|
9
10
|
*/
|
|
10
11
|
Move: (move: Move) => PBTween['mode'];
|
|
11
12
|
/**
|
|
12
|
-
* @returns a move mode tween
|
|
13
|
+
* @returns a move-continuous mode tween
|
|
14
|
+
*/
|
|
15
|
+
MoveContinuous: (move: MoveContinuous) => PBTween['mode'];
|
|
16
|
+
/**
|
|
17
|
+
* @returns a rotate mode tween
|
|
13
18
|
*/
|
|
14
19
|
Rotate: (rotate: Rotate) => PBTween['mode'];
|
|
15
20
|
/**
|
|
16
|
-
* @returns a
|
|
21
|
+
* @returns a rotate-continuous mode tween
|
|
22
|
+
*/
|
|
23
|
+
RotateContinuous: (rotate: RotateContinuous) => PBTween['mode'];
|
|
24
|
+
/**
|
|
25
|
+
* @returns a scale mode tween
|
|
17
26
|
*/
|
|
18
27
|
Scale: (scale: Scale) => PBTween['mode'];
|
|
19
28
|
/**
|
|
20
|
-
* @returns a texture
|
|
29
|
+
* @returns a texture-move mode tween
|
|
21
30
|
*/
|
|
22
31
|
TextureMove: (textureMove: TextureMove) => PBTween['mode'];
|
|
32
|
+
/**
|
|
33
|
+
* @returns a texture-move-continuous mode tween
|
|
34
|
+
*/
|
|
35
|
+
TextureMoveContinuous: (textureMove: TextureMoveContinuous) => PBTween['mode'];
|
|
23
36
|
}
|
|
24
37
|
/**
|
|
25
38
|
* @public
|
|
@@ -29,5 +42,81 @@ export interface TweenComponentDefinitionExtended extends LastWriteWinElementSet
|
|
|
29
42
|
* Texture helpers with constructor
|
|
30
43
|
*/
|
|
31
44
|
Mode: TweenHelper;
|
|
45
|
+
/**
|
|
46
|
+
* @public
|
|
47
|
+
*
|
|
48
|
+
* Creates or replaces a move tween component that animates an entity's position from start to end
|
|
49
|
+
* @param entity - entity to apply the tween to
|
|
50
|
+
* @param start - starting position vector
|
|
51
|
+
* @param end - ending position vector
|
|
52
|
+
* @param duration - duration of the tween in milliseconds
|
|
53
|
+
* @param easingFunction - easing function to use (defaults to EF_LINEAR)
|
|
54
|
+
*/
|
|
55
|
+
setMove(entity: Entity, start: Vector3, end: Vector3, duration: number, easingFunction?: EasingFunction): void;
|
|
56
|
+
/**
|
|
57
|
+
* @public
|
|
58
|
+
*
|
|
59
|
+
* Creates or replaces a scale tween component that animates an entity's scale from start to end
|
|
60
|
+
* @param entity - entity to apply the tween to
|
|
61
|
+
* @param start - starting scale vector
|
|
62
|
+
* @param end - ending scale vector
|
|
63
|
+
* @param duration - duration of the tween in milliseconds
|
|
64
|
+
* @param easingFunction - easing function to use (defaults to EF_LINEAR)
|
|
65
|
+
*/
|
|
66
|
+
setScale(entity: Entity, start: Vector3, end: Vector3, duration: number, easingFunction?: EasingFunction): void;
|
|
67
|
+
/**
|
|
68
|
+
* @public
|
|
69
|
+
*
|
|
70
|
+
* Creates or replaces a rotation tween component that animates an entity's rotation from start to end
|
|
71
|
+
* @param entity - entity to apply the tween to
|
|
72
|
+
* @param start - starting rotation quaternion
|
|
73
|
+
* @param end - ending rotation quaternion
|
|
74
|
+
* @param duration - duration of the tween in milliseconds
|
|
75
|
+
* @param easingFunction - easing function to use (defaults to EF_LINEAR)
|
|
76
|
+
*/
|
|
77
|
+
setRotate(entity: Entity, start: Quaternion, end: Quaternion, duration: number, easingFunction?: EasingFunction): void;
|
|
78
|
+
/**
|
|
79
|
+
* @public
|
|
80
|
+
*
|
|
81
|
+
* Creates or replaces a texture move tween component that animates texture UV coordinates from start to end
|
|
82
|
+
* @param entity - entity to apply the tween to
|
|
83
|
+
* @param start - starting UV coordinates
|
|
84
|
+
* @param end - ending UV coordinates
|
|
85
|
+
* @param duration - duration of the tween in milliseconds
|
|
86
|
+
* @param movementType - type of texture movement (defaults to TMT_OFFSET)
|
|
87
|
+
* @param easingFunction - easing function to use (defaults to EF_LINEAR)
|
|
88
|
+
*/
|
|
89
|
+
setTextureMove(entity: Entity, start: Vector2, end: Vector2, duration: number, movementType?: TextureMovementType, easingFunction?: EasingFunction): void;
|
|
90
|
+
/**
|
|
91
|
+
* @public
|
|
92
|
+
*
|
|
93
|
+
* Creates or replaces a continuous move tween component that moves an entity continuously in a direction
|
|
94
|
+
* @param entity - entity to apply the tween to
|
|
95
|
+
* @param direction - direction vector to move towards
|
|
96
|
+
* @param speed - speed of movement per second
|
|
97
|
+
* @param duration - duration of the tween in milliseconds (defaults to 0 for infinite)
|
|
98
|
+
*/
|
|
99
|
+
setMoveContinuous(entity: Entity, direction: Vector3, speed: number, duration?: number): void;
|
|
100
|
+
/**
|
|
101
|
+
* @public
|
|
102
|
+
*
|
|
103
|
+
* Creates or replaces a continuous rotation tween component that rotates an entity continuously
|
|
104
|
+
* @param entity - entity to apply the tween to
|
|
105
|
+
* @param direction - rotation direction quaternion
|
|
106
|
+
* @param speed - speed of rotation per second
|
|
107
|
+
* @param duration - duration of the tween in milliseconds (defaults to 0 for infinite)
|
|
108
|
+
*/
|
|
109
|
+
setRotateContinuous(entity: Entity, direction: Quaternion, speed: number, duration?: number): void;
|
|
110
|
+
/**
|
|
111
|
+
* @public
|
|
112
|
+
*
|
|
113
|
+
* Creates or replaces a continuous texture move tween component that moves texture UV coordinates continuously
|
|
114
|
+
* @param entity - entity to apply the tween to
|
|
115
|
+
* @param direction - direction vector for UV movement
|
|
116
|
+
* @param speed - speed of UV movement per second
|
|
117
|
+
* @param movementType - type of texture movement (defaults to TMT_OFFSET)
|
|
118
|
+
* @param duration - duration of the tween in milliseconds (defaults to 0 for infinite)
|
|
119
|
+
*/
|
|
120
|
+
setTextureMoveContinuous(entity: Entity, direction: Vector2, speed: number, movementType?: TextureMovementType, duration?: number): void;
|
|
32
121
|
}
|
|
33
122
|
export declare function defineTweenComponent(engine: Pick<IEngine, 'defineComponentFromSchema'>): TweenComponentDefinitionExtended;
|
|
@@ -9,12 +9,24 @@ const TweenHelper = {
|
|
|
9
9
|
move
|
|
10
10
|
};
|
|
11
11
|
},
|
|
12
|
+
MoveContinuous(moveContinuous) {
|
|
13
|
+
return {
|
|
14
|
+
$case: 'moveContinuous',
|
|
15
|
+
moveContinuous
|
|
16
|
+
};
|
|
17
|
+
},
|
|
12
18
|
Rotate(rotate) {
|
|
13
19
|
return {
|
|
14
20
|
$case: 'rotate',
|
|
15
21
|
rotate
|
|
16
22
|
};
|
|
17
23
|
},
|
|
24
|
+
RotateContinuous(rotateContinuous) {
|
|
25
|
+
return {
|
|
26
|
+
$case: 'rotateContinuous',
|
|
27
|
+
rotateContinuous
|
|
28
|
+
};
|
|
29
|
+
},
|
|
18
30
|
Scale(scale) {
|
|
19
31
|
return {
|
|
20
32
|
$case: 'scale',
|
|
@@ -26,13 +38,119 @@ const TweenHelper = {
|
|
|
26
38
|
$case: 'textureMove',
|
|
27
39
|
textureMove
|
|
28
40
|
};
|
|
41
|
+
},
|
|
42
|
+
TextureMoveContinuous(textureMoveContinuous) {
|
|
43
|
+
return {
|
|
44
|
+
$case: 'textureMoveContinuous',
|
|
45
|
+
textureMoveContinuous
|
|
46
|
+
};
|
|
29
47
|
}
|
|
30
48
|
};
|
|
31
49
|
function defineTweenComponent(engine) {
|
|
32
50
|
const theComponent = (0, index_gen_1.Tween)(engine);
|
|
33
51
|
return {
|
|
34
52
|
...theComponent,
|
|
35
|
-
Mode: TweenHelper
|
|
53
|
+
Mode: TweenHelper,
|
|
54
|
+
setMove(entity, start, end, duration, easingFunction = 0 /* EasingFunction.EF_LINEAR */) {
|
|
55
|
+
theComponent.createOrReplace(entity, {
|
|
56
|
+
mode: {
|
|
57
|
+
$case: 'move',
|
|
58
|
+
move: {
|
|
59
|
+
start,
|
|
60
|
+
end
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
duration,
|
|
64
|
+
easingFunction,
|
|
65
|
+
playing: true
|
|
66
|
+
});
|
|
67
|
+
},
|
|
68
|
+
setScale(entity, start, end, duration, easingFunction = 0 /* EasingFunction.EF_LINEAR */) {
|
|
69
|
+
theComponent.createOrReplace(entity, {
|
|
70
|
+
mode: {
|
|
71
|
+
$case: 'scale',
|
|
72
|
+
scale: {
|
|
73
|
+
start,
|
|
74
|
+
end
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
duration,
|
|
78
|
+
easingFunction,
|
|
79
|
+
playing: true
|
|
80
|
+
});
|
|
81
|
+
},
|
|
82
|
+
setRotate(entity, start, end, duration, easingFunction = 0 /* EasingFunction.EF_LINEAR */) {
|
|
83
|
+
theComponent.createOrReplace(entity, {
|
|
84
|
+
mode: {
|
|
85
|
+
$case: 'rotate',
|
|
86
|
+
rotate: {
|
|
87
|
+
start,
|
|
88
|
+
end
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
duration,
|
|
92
|
+
easingFunction,
|
|
93
|
+
playing: true
|
|
94
|
+
});
|
|
95
|
+
},
|
|
96
|
+
setTextureMove(entity, start, end, duration, movementType = 0 /* TextureMovementType.TMT_OFFSET */, easingFunction = 0 /* EasingFunction.EF_LINEAR */) {
|
|
97
|
+
theComponent.createOrReplace(entity, {
|
|
98
|
+
mode: {
|
|
99
|
+
$case: 'textureMove',
|
|
100
|
+
textureMove: {
|
|
101
|
+
start,
|
|
102
|
+
end,
|
|
103
|
+
movementType
|
|
104
|
+
}
|
|
105
|
+
},
|
|
106
|
+
duration,
|
|
107
|
+
easingFunction,
|
|
108
|
+
playing: true
|
|
109
|
+
});
|
|
110
|
+
},
|
|
111
|
+
setMoveContinuous(entity, direction, speed, duration = 0) {
|
|
112
|
+
theComponent.createOrReplace(entity, {
|
|
113
|
+
mode: {
|
|
114
|
+
$case: 'moveContinuous',
|
|
115
|
+
moveContinuous: {
|
|
116
|
+
direction,
|
|
117
|
+
speed
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
duration,
|
|
121
|
+
easingFunction: 0 /* EasingFunction.EF_LINEAR */,
|
|
122
|
+
playing: true
|
|
123
|
+
});
|
|
124
|
+
},
|
|
125
|
+
setRotateContinuous(entity, direction, speed, duration = 0) {
|
|
126
|
+
theComponent.createOrReplace(entity, {
|
|
127
|
+
mode: {
|
|
128
|
+
$case: 'rotateContinuous',
|
|
129
|
+
rotateContinuous: {
|
|
130
|
+
direction,
|
|
131
|
+
speed
|
|
132
|
+
}
|
|
133
|
+
},
|
|
134
|
+
duration,
|
|
135
|
+
easingFunction: 0 /* EasingFunction.EF_LINEAR */,
|
|
136
|
+
playing: true
|
|
137
|
+
});
|
|
138
|
+
},
|
|
139
|
+
setTextureMoveContinuous(entity, direction, speed, movementType = 0 /* TextureMovementType.TMT_OFFSET */, duration = 0) {
|
|
140
|
+
theComponent.createOrReplace(entity, {
|
|
141
|
+
mode: {
|
|
142
|
+
$case: 'textureMoveContinuous',
|
|
143
|
+
textureMoveContinuous: {
|
|
144
|
+
direction,
|
|
145
|
+
speed,
|
|
146
|
+
movementType
|
|
147
|
+
}
|
|
148
|
+
},
|
|
149
|
+
duration,
|
|
150
|
+
easingFunction: 0 /* EasingFunction.EF_LINEAR */,
|
|
151
|
+
playing: true
|
|
152
|
+
});
|
|
153
|
+
}
|
|
36
154
|
};
|
|
37
155
|
}
|
|
38
156
|
exports.defineTweenComponent = defineTweenComponent;
|
|
@@ -6,7 +6,7 @@ const camera_layer_gen_1 = require("./pb/decentraland/sdk/components/camera_laye
|
|
|
6
6
|
* @internal
|
|
7
7
|
*/
|
|
8
8
|
exports.CameraLayerSchema = {
|
|
9
|
-
COMPONENT_ID:
|
|
9
|
+
COMPONENT_ID: 1211,
|
|
10
10
|
serialize(value, builder) {
|
|
11
11
|
const writer = camera_layer_gen_1.PBCameraLayer.encode(value);
|
|
12
12
|
const buffer = new Uint8Array(writer.finish(), 0, writer.len);
|
|
@@ -17,7 +17,7 @@ exports.coreComponentMappings = {
|
|
|
17
17
|
"core::AvatarModifierArea": 1070,
|
|
18
18
|
"core::AvatarShape": 1080,
|
|
19
19
|
"core::Billboard": 1090,
|
|
20
|
-
"core::CameraLayer":
|
|
20
|
+
"core::CameraLayer": 1211,
|
|
21
21
|
"core::CameraLayers": 1208,
|
|
22
22
|
"core::CameraMode": 1072,
|
|
23
23
|
"core::CameraModeArea": 1071,
|
|
@@ -91,7 +91,7 @@ import { PBVisibilityComponent } from './pb/decentraland/sdk/components/visibili
|
|
|
91
91
|
/** @public */ export declare const TextShape: LastWriteWinElementSetComponentDefinition<PBTextShape>;
|
|
92
92
|
/** @public */ export declare const TextureCamera: LastWriteWinElementSetComponentDefinition<PBTextureCamera>;
|
|
93
93
|
/** @public */ export declare const TriggerArea: LastWriteWinElementSetComponentDefinition<PBTriggerArea>;
|
|
94
|
-
/** @public */ export declare const TriggerAreaResult:
|
|
94
|
+
/** @public */ export declare const TriggerAreaResult: GrowOnlyValueSetComponentDefinition<PBTriggerAreaResult>;
|
|
95
95
|
/** @public */ export declare const TweenSequence: LastWriteWinElementSetComponentDefinition<PBTweenSequence>;
|
|
96
96
|
/** @public */ export declare const TweenState: LastWriteWinElementSetComponentDefinition<PBTweenState>;
|
|
97
97
|
/** @public */ export declare const UiBackground: LastWriteWinElementSetComponentDefinition<PBUiBackground>;
|
|
@@ -161,7 +161,7 @@ export type GSetComponentGetter<T extends GrowOnlyValueSetComponentDefinition<an
|
|
|
161
161
|
/** @public */ export declare const TextShape: LwwComponentGetter<LastWriteWinElementSetComponentDefinition<PBTextShape>>;
|
|
162
162
|
/** @public */ export declare const TextureCamera: LwwComponentGetter<LastWriteWinElementSetComponentDefinition<PBTextureCamera>>;
|
|
163
163
|
/** @public */ export declare const TriggerArea: LwwComponentGetter<LastWriteWinElementSetComponentDefinition<PBTriggerArea>>;
|
|
164
|
-
/** @public */ export declare const TriggerAreaResult:
|
|
164
|
+
/** @public */ export declare const TriggerAreaResult: GSetComponentGetter<GrowOnlyValueSetComponentDefinition<PBTriggerAreaResult>>;
|
|
165
165
|
/** @public */ export declare const Tween: LwwComponentGetter<LastWriteWinElementSetComponentDefinition<PBTween>>;
|
|
166
166
|
/** @public */ export declare const TweenSequence: LwwComponentGetter<LastWriteWinElementSetComponentDefinition<PBTweenSequence>>;
|
|
167
167
|
/** @public */ export declare const TweenState: LwwComponentGetter<LastWriteWinElementSetComponentDefinition<PBTweenState>>;
|
|
@@ -222,7 +222,7 @@ export declare const componentDefinitionByName: {
|
|
|
222
222
|
"core::TextShape": LwwComponentGetter<LastWriteWinElementSetComponentDefinition<PBTextShape>>;
|
|
223
223
|
"core::TextureCamera": LwwComponentGetter<LastWriteWinElementSetComponentDefinition<PBTextureCamera>>;
|
|
224
224
|
"core::TriggerArea": LwwComponentGetter<LastWriteWinElementSetComponentDefinition<PBTriggerArea>>;
|
|
225
|
-
"core::TriggerAreaResult":
|
|
225
|
+
"core::TriggerAreaResult": GSetComponentGetter<GrowOnlyValueSetComponentDefinition<PBTriggerAreaResult>>;
|
|
226
226
|
"core::Tween": LwwComponentGetter<LastWriteWinElementSetComponentDefinition<PBTween>>;
|
|
227
227
|
"core::TweenSequence": LwwComponentGetter<LastWriteWinElementSetComponentDefinition<PBTweenSequence>>;
|
|
228
228
|
"core::TweenState": LwwComponentGetter<LastWriteWinElementSetComponentDefinition<PBTweenState>>;
|
|
@@ -263,8 +263,10 @@ exports.TextureCamera = TextureCamera;
|
|
|
263
263
|
/** @public */ const TriggerArea = engine =>
|
|
264
264
|
/* @__PURE__ */ engine.defineComponentFromSchema("core::TriggerArea", TriggerArea_gen_1.TriggerAreaSchema);
|
|
265
265
|
exports.TriggerArea = TriggerArea;
|
|
266
|
-
/** @public */ const TriggerAreaResult = engine =>
|
|
267
|
-
|
|
266
|
+
/** @public */ const TriggerAreaResult = (engine) => /* @__PURE__ */ engine.defineValueSetComponentFromSchema("core::TriggerAreaResult", TriggerAreaResult_gen_1.TriggerAreaResultSchema, {
|
|
267
|
+
timestampFunction: (t) => t.timestamp,
|
|
268
|
+
maxElements: 100
|
|
269
|
+
});
|
|
268
270
|
exports.TriggerAreaResult = TriggerAreaResult;
|
|
269
271
|
/** @public */ const Tween = engine =>
|
|
270
272
|
/* @__PURE__ */ engine.defineComponentFromSchema("core::Tween", Tween_gen_1.TweenSchema);
|
|
@@ -19,6 +19,8 @@ import { INetowrkParentType } from './manual/NetworkParent';
|
|
|
19
19
|
import { ISyncComponentsType } from './manual/SyncComponents';
|
|
20
20
|
import { TransformComponentExtended } from './manual/Transform';
|
|
21
21
|
import { LightSourceComponentDefinitionExtended } from './extended/LightSource';
|
|
22
|
+
import { TriggerAreaComponentDefinitionExtended } from './extended/TriggerArea';
|
|
23
|
+
import { TagsComponentDefinitionExtended } from './manual/Tags';
|
|
22
24
|
export * from './generated/index.gen';
|
|
23
25
|
export type { GrowOnlyValueSetComponentDefinition, GSetComponentGetter, LastWriteWinElementSetComponentDefinition, LwwComponentGetter };
|
|
24
26
|
export declare const Transform: LwwComponentGetter<TransformComponentExtended>;
|
|
@@ -34,10 +36,12 @@ export declare const AvatarEquippedData: LwwComponentGetter<AvatarEquippedDataCo
|
|
|
34
36
|
export declare const VirtualCamera: LwwComponentGetter<VirtualCameraComponentDefinitionExtended>;
|
|
35
37
|
export declare const InputModifier: LwwComponentGetter<InputModifierComponentDefinitionExtended>;
|
|
36
38
|
export declare const LightSource: LwwComponentGetter<LightSourceComponentDefinitionExtended>;
|
|
39
|
+
export declare const TriggerArea: LwwComponentGetter<TriggerAreaComponentDefinitionExtended>;
|
|
37
40
|
/**
|
|
38
41
|
* @alpha
|
|
39
42
|
*/
|
|
40
43
|
export declare const Name: (engine: Pick<IEngine, 'defineComponent'>) => LastWriteWinElementSetComponentDefinition<NameType>;
|
|
44
|
+
export declare const Tags: (engine: Pick<IEngine, 'defineComponent'>) => TagsComponentDefinitionExtended;
|
|
41
45
|
/**
|
|
42
46
|
* @alpha
|
|
43
47
|
*/
|