@dcl/ecs 7.22.5-24836126953.commit-ddc8da1 → 7.22.5
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/ParticleSystem.d.ts +24 -0
- package/dist/components/extended/ParticleSystem.js +23 -0
- package/dist/components/generated/ParticleSystem.gen.d.ts +1 -0
- package/dist/components/generated/ParticleSystem.gen.js +25 -0
- package/dist/components/generated/component-names.gen.js +1 -0
- package/dist/components/generated/global.gen.d.ts +2 -0
- package/dist/components/generated/global.gen.js +1 -0
- package/dist/components/generated/index.gen.d.ts +4 -0
- package/dist/components/generated/index.gen.js +5 -0
- package/dist/components/generated/pb/decentraland/common/colors.gen.d.ts +15 -0
- package/dist/components/generated/pb/decentraland/common/colors.gen.js +47 -0
- package/dist/components/generated/pb/decentraland/common/floats.gen.d.ts +16 -0
- package/dist/components/generated/pb/decentraland/common/floats.gen.js +50 -0
- package/dist/components/generated/pb/decentraland/sdk/components/common/input_action.gen.d.ts +10 -1
- package/dist/components/generated/pb/decentraland/sdk/components/common/input_action.gen.js +10 -0
- package/dist/components/generated/pb/decentraland/sdk/components/particle_system.gen.d.ts +241 -0
- package/dist/components/generated/pb/decentraland/sdk/components/particle_system.gen.js +717 -0
- package/dist/components/generated/pb/decentraland/sdk/components/pointer_events.gen.d.ts +5 -1
- package/dist/components/generated/pb/decentraland/sdk/components/pointer_events.gen.js +20 -1
- package/dist/components/generated/types.gen.d.ts +2 -0
- package/dist/components/generated/types.gen.js +3 -0
- package/dist/components/index.d.ts +2 -5
- package/dist/components/index.js +5 -5
- package/dist/components/manual/Transform.d.ts +13 -9
- package/dist/components/manual/Transform.js +11 -3
- package/dist/components/types.d.ts +1 -1
- package/dist/engine/component.d.ts +1 -52
- package/dist/engine/grow-only-value-set-component-definition.js +2 -45
- package/dist/engine/lww-element-set-component-definition.d.ts +3 -5
- package/dist/engine/lww-element-set-component-definition.js +35 -70
- package/dist/index.d.ts +3 -2
- package/dist/index.js +3 -1
- package/dist/runtime/helpers/index.d.ts +1 -0
- package/dist/runtime/helpers/index.js +1 -0
- package/dist/runtime/helpers/tree.d.ts +6 -0
- package/dist/runtime/helpers/tree.js +2 -2
- package/dist/runtime/helpers/vectors.d.ts +1 -0
- package/dist/runtime/helpers/vectors.js +36 -0
- package/dist/runtime/initialization/index.d.ts +7 -0
- package/dist/runtime/initialization/index.js +6 -0
- package/dist/serialization/crdt/index.d.ts +0 -1
- package/dist/serialization/crdt/index.js +0 -1
- package/dist/serialization/crdt/network/utils.d.ts +9 -0
- package/dist/serialization/crdt/network/utils.js +60 -0
- package/dist/serialization/crdt/types.d.ts +3 -25
- package/dist/serialization/crdt/types.js +1 -3
- package/dist/systems/crdt/index.d.ts +1 -0
- package/dist/systems/crdt/index.js +146 -55
- package/dist/systems/events.d.ts +65 -0
- package/dist/systems/events.js +70 -8
- package/dist/systems/physics-force.d.ts +1 -0
- package/dist/systems/physics-force.js +140 -0
- package/dist/systems/physics-impulse.d.ts +12 -0
- package/dist/systems/physics-impulse.js +85 -0
- package/dist/systems/physics.d.ts +77 -0
- package/dist/systems/physics.js +18 -0
- package/dist-cjs/components/extended/ParticleSystem.d.ts +24 -0
- package/dist-cjs/components/extended/ParticleSystem.js +28 -0
- package/dist-cjs/components/generated/ParticleSystem.gen.d.ts +1 -0
- package/dist-cjs/components/generated/ParticleSystem.gen.js +28 -0
- package/dist-cjs/components/generated/component-names.gen.js +1 -0
- package/dist-cjs/components/generated/global.gen.d.ts +2 -0
- package/dist-cjs/components/generated/global.gen.js +3 -1
- package/dist-cjs/components/generated/index.gen.d.ts +4 -0
- package/dist-cjs/components/generated/index.gen.js +8 -2
- package/dist-cjs/components/generated/pb/decentraland/common/colors.gen.d.ts +15 -0
- package/dist-cjs/components/generated/pb/decentraland/common/colors.gen.js +48 -1
- package/dist-cjs/components/generated/pb/decentraland/common/floats.gen.d.ts +16 -0
- package/dist-cjs/components/generated/pb/decentraland/common/floats.gen.js +56 -0
- package/dist-cjs/components/generated/pb/decentraland/sdk/components/common/input_action.gen.d.ts +10 -1
- package/dist-cjs/components/generated/pb/decentraland/sdk/components/common/input_action.gen.js +11 -1
- package/dist-cjs/components/generated/pb/decentraland/sdk/components/particle_system.gen.d.ts +241 -0
- package/dist-cjs/components/generated/pb/decentraland/sdk/components/particle_system.gen.js +723 -0
- package/dist-cjs/components/generated/pb/decentraland/sdk/components/pointer_events.gen.d.ts +5 -1
- package/dist-cjs/components/generated/pb/decentraland/sdk/components/pointer_events.gen.js +20 -1
- package/dist-cjs/components/generated/types.gen.d.ts +2 -0
- package/dist-cjs/components/generated/types.gen.js +5 -0
- package/dist-cjs/components/index.d.ts +2 -5
- package/dist-cjs/components/index.js +7 -7
- package/dist-cjs/components/manual/Transform.d.ts +13 -9
- package/dist-cjs/components/manual/Transform.js +34 -3
- package/dist-cjs/components/types.d.ts +1 -1
- package/dist-cjs/engine/component.d.ts +1 -52
- package/dist-cjs/engine/grow-only-value-set-component-definition.js +1 -44
- package/dist-cjs/engine/lww-element-set-component-definition.d.ts +3 -5
- package/dist-cjs/engine/lww-element-set-component-definition.js +36 -73
- package/dist-cjs/index.d.ts +3 -2
- package/dist-cjs/index.js +4 -2
- package/dist-cjs/runtime/helpers/index.d.ts +1 -0
- package/dist-cjs/runtime/helpers/index.js +1 -0
- package/dist-cjs/runtime/helpers/tree.d.ts +6 -0
- package/dist-cjs/runtime/helpers/tree.js +3 -2
- package/dist-cjs/runtime/helpers/vectors.d.ts +1 -0
- package/dist-cjs/runtime/helpers/vectors.js +39 -0
- package/dist-cjs/runtime/initialization/index.d.ts +7 -0
- package/dist-cjs/runtime/initialization/index.js +7 -1
- package/dist-cjs/serialization/crdt/index.d.ts +0 -1
- package/dist-cjs/serialization/crdt/index.js +0 -1
- package/dist-cjs/serialization/crdt/network/utils.d.ts +9 -0
- package/dist-cjs/serialization/crdt/network/utils.js +67 -0
- package/dist-cjs/serialization/crdt/types.d.ts +3 -25
- package/dist-cjs/serialization/crdt/types.js +1 -3
- package/dist-cjs/systems/crdt/index.d.ts +1 -0
- package/dist-cjs/systems/crdt/index.js +169 -55
- package/dist-cjs/systems/events.d.ts +65 -0
- package/dist-cjs/systems/events.js +70 -8
- package/dist-cjs/systems/physics-force.d.ts +1 -0
- package/dist-cjs/systems/physics-force.js +167 -0
- package/dist-cjs/systems/physics-impulse.d.ts +12 -0
- package/dist-cjs/systems/physics-impulse.js +112 -0
- package/dist-cjs/systems/physics.d.ts +77 -0
- package/dist-cjs/systems/physics.js +23 -0
- package/package.json +3 -2
- package/dist/components/manual/CreatedBy.d.ts +0 -9
- package/dist/components/manual/CreatedBy.js +0 -8
- package/dist/serialization/crdt/authoritativePutComponent.d.ts +0 -15
- package/dist/serialization/crdt/authoritativePutComponent.js +0 -47
- package/dist-cjs/components/manual/CreatedBy.d.ts +0 -9
- package/dist-cjs/components/manual/CreatedBy.js +0 -10
- package/dist-cjs/serialization/crdt/authoritativePutComponent.d.ts +0 -15
- package/dist-cjs/serialization/crdt/authoritativePutComponent.js +0 -50
package/dist/systems/events.d.ts
CHANGED
|
@@ -17,6 +17,7 @@ export type EventSystemOptions = {
|
|
|
17
17
|
showFeedback?: boolean;
|
|
18
18
|
showHighlight?: boolean;
|
|
19
19
|
maxPlayerDistance?: number;
|
|
20
|
+
priority?: number;
|
|
20
21
|
};
|
|
21
22
|
export declare const getDefaultOpts: (opts?: Partial<EventSystemOptions>) => EventSystemOptions;
|
|
22
23
|
/**
|
|
@@ -47,6 +48,30 @@ export interface PointerEventsSystem {
|
|
|
47
48
|
* @param entity - Entity where the callback was attached
|
|
48
49
|
*/
|
|
49
50
|
removeOnPointerHoverLeave(entity: Entity): void;
|
|
51
|
+
/**
|
|
52
|
+
* @public
|
|
53
|
+
* Remove the callback for onProximityDown event
|
|
54
|
+
* @param entity - Entity where the callback was attached
|
|
55
|
+
*/
|
|
56
|
+
removeOnProximityDown(entity: Entity): void;
|
|
57
|
+
/**
|
|
58
|
+
* @public
|
|
59
|
+
* Remove the callback for onProximityUp event
|
|
60
|
+
* @param entity - Entity where the callback was attached
|
|
61
|
+
*/
|
|
62
|
+
removeOnProximityUp(entity: Entity): void;
|
|
63
|
+
/**
|
|
64
|
+
* @public
|
|
65
|
+
* Remove the callback for onProximityEnter event
|
|
66
|
+
* @param entity - Entity where the callback was attached
|
|
67
|
+
*/
|
|
68
|
+
removeOnProximityEnter(entity: Entity): void;
|
|
69
|
+
/**
|
|
70
|
+
* @public
|
|
71
|
+
* Remove the callback for onProximityLeave event
|
|
72
|
+
* @param entity - Entity where the callback was attached
|
|
73
|
+
*/
|
|
74
|
+
removeOnProximityLeave(entity: Entity): void;
|
|
50
75
|
/**
|
|
51
76
|
* @public
|
|
52
77
|
* Execute callback when the user press the InputButton pointing at the entity
|
|
@@ -101,6 +126,46 @@ export interface PointerEventsSystem {
|
|
|
101
126
|
entity: Entity;
|
|
102
127
|
opts?: Partial<EventSystemOptions>;
|
|
103
128
|
}, cb: EventSystemCallback): void;
|
|
129
|
+
/**
|
|
130
|
+
* @public
|
|
131
|
+
* Execute callback when the user presses the proximity button on the entity
|
|
132
|
+
* @param pointerData - Entity to attach the callback - Opts to trigger Feedback and Button
|
|
133
|
+
* @param cb - Function to execute when click fires
|
|
134
|
+
*/
|
|
135
|
+
onProximityDown(pointerData: {
|
|
136
|
+
entity: Entity;
|
|
137
|
+
opts?: Partial<EventSystemOptions>;
|
|
138
|
+
}, cb: EventSystemCallback): void;
|
|
139
|
+
/**
|
|
140
|
+
* @public
|
|
141
|
+
* Execute callback when the user releases the proximity button on the entity
|
|
142
|
+
* @param pointerData - Entity to attach the callback - Opts to trigger Feedback and Button
|
|
143
|
+
* @param cb - Function to execute when event fires
|
|
144
|
+
*/
|
|
145
|
+
onProximityUp(pointerData: {
|
|
146
|
+
entity: Entity;
|
|
147
|
+
opts?: Partial<EventSystemOptions>;
|
|
148
|
+
}, cb: EventSystemCallback): void;
|
|
149
|
+
/**
|
|
150
|
+
* @public
|
|
151
|
+
* Execute callback when the entity enters the proximity zone of the user
|
|
152
|
+
* @param pointerData - Entity to attach the callback - Opts to trigger Feedback and Button
|
|
153
|
+
* @param cb - Function to execute when event fires
|
|
154
|
+
*/
|
|
155
|
+
onProximityEnter(pointerData: {
|
|
156
|
+
entity: Entity;
|
|
157
|
+
opts?: Partial<EventSystemOptions>;
|
|
158
|
+
}, cb: EventSystemCallback): void;
|
|
159
|
+
/**
|
|
160
|
+
* @public
|
|
161
|
+
* Execute callback when the entity leaves the proximity zone of the user
|
|
162
|
+
* @param pointerData - Entity to attach the callback - Opts to trigger Feedback and Button
|
|
163
|
+
* @param cb - Function to execute when event fires
|
|
164
|
+
*/
|
|
165
|
+
onProximityLeave(pointerData: {
|
|
166
|
+
entity: Entity;
|
|
167
|
+
opts?: Partial<EventSystemOptions>;
|
|
168
|
+
}, cb: EventSystemCallback): void;
|
|
104
169
|
}
|
|
105
170
|
/**
|
|
106
171
|
* @public
|
package/dist/systems/events.js
CHANGED
|
@@ -18,12 +18,14 @@ export function createPointerEventsSystem(engine, inputSystem) {
|
|
|
18
18
|
EventType[EventType["Up"] = 2] = "Up";
|
|
19
19
|
EventType[EventType["HoverEnter"] = 3] = "HoverEnter";
|
|
20
20
|
EventType[EventType["HoverLeave"] = 4] = "HoverLeave";
|
|
21
|
+
EventType[EventType["ProximityEnter"] = 5] = "ProximityEnter";
|
|
22
|
+
EventType[EventType["ProximityLeave"] = 6] = "ProximityLeave";
|
|
21
23
|
})(EventType || (EventType = {}));
|
|
22
24
|
const eventsMap = new Map();
|
|
23
25
|
function getEvent(entity) {
|
|
24
26
|
return eventsMap.get(entity) || eventsMap.set(entity, new Map()).get(entity);
|
|
25
27
|
}
|
|
26
|
-
function setPointerEvent(entity, type, opts) {
|
|
28
|
+
function setPointerEvent(entity, type, opts, interactionType = 0 /* InteractionType.CURSOR */) {
|
|
27
29
|
const pointerEvent = PointerEvents.getMutableOrNull(entity) || PointerEvents.create(entity);
|
|
28
30
|
pointerEvent.pointerEvents.push({
|
|
29
31
|
eventType: type,
|
|
@@ -33,15 +35,19 @@ export function createPointerEventsSystem(engine, inputSystem) {
|
|
|
33
35
|
showHighlight: opts.showHighlight,
|
|
34
36
|
hoverText: opts.hoverText,
|
|
35
37
|
maxDistance: opts.maxDistance,
|
|
36
|
-
maxPlayerDistance: opts.maxPlayerDistance
|
|
37
|
-
|
|
38
|
+
maxPlayerDistance: opts.maxPlayerDistance,
|
|
39
|
+
priority: opts.priority
|
|
40
|
+
},
|
|
41
|
+
interactionType: interactionType ?? 0 /* InteractionType.CURSOR */
|
|
38
42
|
});
|
|
39
43
|
}
|
|
40
|
-
function removePointerEvent(entity, type, button) {
|
|
44
|
+
function removePointerEvent(entity, type, button, interactionType = 0 /* InteractionType.CURSOR */) {
|
|
41
45
|
const pointerEvent = PointerEvents.getMutableOrNull(entity);
|
|
42
46
|
if (!pointerEvent)
|
|
43
47
|
return;
|
|
44
|
-
pointerEvent.pointerEvents = pointerEvent.pointerEvents.filter((pointer) => !(pointer.eventInfo?.button === button &&
|
|
48
|
+
pointerEvent.pointerEvents = pointerEvent.pointerEvents.filter((pointer) => !(pointer.eventInfo?.button === button &&
|
|
49
|
+
pointer.eventType === type &&
|
|
50
|
+
pointer.interactionType === interactionType));
|
|
45
51
|
}
|
|
46
52
|
function getPointerEvent(eventType) {
|
|
47
53
|
if (eventType === EventType.Up) {
|
|
@@ -53,9 +59,15 @@ export function createPointerEventsSystem(engine, inputSystem) {
|
|
|
53
59
|
else if (eventType === EventType.HoverEnter) {
|
|
54
60
|
return 2 /* PointerEventType.PET_HOVER_ENTER */;
|
|
55
61
|
}
|
|
62
|
+
else if (eventType === EventType.ProximityEnter) {
|
|
63
|
+
return 4 /* PointerEventType.PET_PROXIMITY_ENTER */;
|
|
64
|
+
}
|
|
65
|
+
else if (eventType === EventType.ProximityLeave) {
|
|
66
|
+
return 5 /* PointerEventType.PET_PROXIMITY_LEAVE */;
|
|
67
|
+
}
|
|
56
68
|
return 1 /* PointerEventType.PET_DOWN */;
|
|
57
69
|
}
|
|
58
|
-
function removeEvent(entity, type) {
|
|
70
|
+
function removeEvent(entity, type, interactionType = 0 /* InteractionType.CURSOR */) {
|
|
59
71
|
const event = getEvent(entity);
|
|
60
72
|
const pointerEvent = event.get(type);
|
|
61
73
|
if (pointerEvent?.opts.hoverText) {
|
|
@@ -78,7 +90,9 @@ export function createPointerEventsSystem(engine, inputSystem) {
|
|
|
78
90
|
if (eventType === EventType.Down ||
|
|
79
91
|
eventType === EventType.Up ||
|
|
80
92
|
eventType === EventType.HoverEnter ||
|
|
81
|
-
eventType === EventType.HoverLeave
|
|
93
|
+
eventType === EventType.HoverLeave ||
|
|
94
|
+
eventType === EventType.ProximityEnter ||
|
|
95
|
+
eventType === EventType.ProximityLeave) {
|
|
82
96
|
const command = inputSystem.getInputCommand(opts.button, getPointerEvent(eventType), entity);
|
|
83
97
|
if (command) {
|
|
84
98
|
checkNotThenable(cb(command), 'Event handler returned a thenable. Only synchronous functions are allowed');
|
|
@@ -125,6 +139,38 @@ export function createPointerEventsSystem(engine, inputSystem) {
|
|
|
125
139
|
getEvent(entity).set(EventType.HoverLeave, { cb, opts: options });
|
|
126
140
|
setPointerEvent(entity, 3 /* PointerEventType.PET_HOVER_LEAVE */, options);
|
|
127
141
|
};
|
|
142
|
+
const onProximityDown = (...args) => {
|
|
143
|
+
const [data, cb] = args;
|
|
144
|
+
const { entity, opts } = data;
|
|
145
|
+
const options = getDefaultOpts(opts);
|
|
146
|
+
removeEvent(entity, EventType.Down, 1 /* InteractionType.PROXIMITY */);
|
|
147
|
+
getEvent(entity).set(EventType.Down, { cb, opts: options });
|
|
148
|
+
setPointerEvent(entity, 1 /* PointerEventType.PET_DOWN */, options, 1 /* InteractionType.PROXIMITY */);
|
|
149
|
+
};
|
|
150
|
+
const onProximityUp = (...args) => {
|
|
151
|
+
const [data, cb] = args;
|
|
152
|
+
const { entity, opts } = data;
|
|
153
|
+
const options = getDefaultOpts(opts);
|
|
154
|
+
removeEvent(entity, EventType.Up, 1 /* InteractionType.PROXIMITY */);
|
|
155
|
+
getEvent(entity).set(EventType.Up, { cb, opts: options });
|
|
156
|
+
setPointerEvent(entity, 0 /* PointerEventType.PET_UP */, options, 1 /* InteractionType.PROXIMITY */);
|
|
157
|
+
};
|
|
158
|
+
const onProximityEnter = (...args) => {
|
|
159
|
+
const [data, cb] = args;
|
|
160
|
+
const { entity, opts } = data;
|
|
161
|
+
const options = getDefaultOpts(opts);
|
|
162
|
+
removeEvent(entity, EventType.ProximityEnter, 1 /* InteractionType.PROXIMITY */);
|
|
163
|
+
getEvent(entity).set(EventType.ProximityEnter, { cb, opts: options });
|
|
164
|
+
setPointerEvent(entity, 4 /* PointerEventType.PET_PROXIMITY_ENTER */, options, 1 /* InteractionType.PROXIMITY */);
|
|
165
|
+
};
|
|
166
|
+
const onProximityLeave = (...args) => {
|
|
167
|
+
const [data, cb] = args;
|
|
168
|
+
const { entity, opts } = data;
|
|
169
|
+
const options = getDefaultOpts(opts);
|
|
170
|
+
removeEvent(entity, EventType.ProximityLeave, 1 /* InteractionType.PROXIMITY */);
|
|
171
|
+
getEvent(entity).set(EventType.ProximityLeave, { cb, opts: options });
|
|
172
|
+
setPointerEvent(entity, 5 /* PointerEventType.PET_PROXIMITY_LEAVE */, options, 1 /* InteractionType.PROXIMITY */);
|
|
173
|
+
};
|
|
128
174
|
return {
|
|
129
175
|
removeOnClick(entity) {
|
|
130
176
|
removeEvent(entity, EventType.Click);
|
|
@@ -141,6 +187,18 @@ export function createPointerEventsSystem(engine, inputSystem) {
|
|
|
141
187
|
removeOnPointerHoverLeave(entity) {
|
|
142
188
|
removeEvent(entity, EventType.HoverLeave);
|
|
143
189
|
},
|
|
190
|
+
removeOnProximityDown(entity) {
|
|
191
|
+
removeEvent(entity, EventType.Down, 1 /* InteractionType.PROXIMITY */);
|
|
192
|
+
},
|
|
193
|
+
removeOnProximityUp(entity) {
|
|
194
|
+
removeEvent(entity, EventType.Up, 1 /* InteractionType.PROXIMITY */);
|
|
195
|
+
},
|
|
196
|
+
removeOnProximityEnter(entity) {
|
|
197
|
+
removeEvent(entity, EventType.ProximityEnter, 1 /* InteractionType.PROXIMITY */);
|
|
198
|
+
},
|
|
199
|
+
removeOnProximityLeave(entity) {
|
|
200
|
+
removeEvent(entity, EventType.ProximityLeave, 1 /* InteractionType.PROXIMITY */);
|
|
201
|
+
},
|
|
144
202
|
onClick(value, cb) {
|
|
145
203
|
const { entity } = value;
|
|
146
204
|
const options = getDefaultOpts(value.opts);
|
|
@@ -153,6 +211,10 @@ export function createPointerEventsSystem(engine, inputSystem) {
|
|
|
153
211
|
onPointerDown,
|
|
154
212
|
onPointerUp,
|
|
155
213
|
onPointerHoverEnter,
|
|
156
|
-
onPointerHoverLeave
|
|
214
|
+
onPointerHoverLeave,
|
|
215
|
+
onProximityDown,
|
|
216
|
+
onProximityUp,
|
|
217
|
+
onProximityEnter,
|
|
218
|
+
onProximityLeave
|
|
157
219
|
};
|
|
158
220
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import * as components from '../components';
|
|
2
|
+
import { Vector3, createTimers } from '../runtime/helpers';
|
|
3
|
+
import { KnockbackFalloff } from './physics-impulse';
|
|
4
|
+
/** @internal */
|
|
5
|
+
export function createPhysicsForceHelper(engine) {
|
|
6
|
+
const PhysicsCombinedForce = components.PhysicsCombinedForce(engine);
|
|
7
|
+
const Transform = components.Transform(engine);
|
|
8
|
+
const timers = createTimers(engine);
|
|
9
|
+
const durationTimers = new Map();
|
|
10
|
+
// Key = source entity producing the force (not the target); all forces target PlayerEntity.
|
|
11
|
+
const forceSources = new Map();
|
|
12
|
+
const repulsionSources = new Map();
|
|
13
|
+
let lastWrittenForceVector = null;
|
|
14
|
+
function recalcForce() {
|
|
15
|
+
if (forceSources.size === 0) {
|
|
16
|
+
if (PhysicsCombinedForce.has(engine.PlayerEntity)) {
|
|
17
|
+
PhysicsCombinedForce.deleteFrom(engine.PlayerEntity);
|
|
18
|
+
}
|
|
19
|
+
lastWrittenForceVector = null;
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
const current = PhysicsCombinedForce.getOrNull(engine.PlayerEntity);
|
|
23
|
+
if (current && lastWrittenForceVector && current.vector) {
|
|
24
|
+
if (!Vector3.equals(current.vector, lastWrittenForceVector)) {
|
|
25
|
+
console.error('PBPhysicsCombinedForce was modified externally.', 'Expected:', lastWrittenForceVector, 'Found:', current.vector, '-- overwriting with local state.');
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
let sum = { x: 0, y: 0, z: 0 };
|
|
29
|
+
for (const v of forceSources.values()) {
|
|
30
|
+
sum = Vector3.add(sum, v);
|
|
31
|
+
}
|
|
32
|
+
PhysicsCombinedForce.createOrReplace(engine.PlayerEntity, { vector: sum });
|
|
33
|
+
lastWrittenForceVector = sum;
|
|
34
|
+
}
|
|
35
|
+
function applyForceToPlayer(source, vector, magnitude) {
|
|
36
|
+
let finalVector;
|
|
37
|
+
if (Vector3.equalsToFloats(vector, 0, 0, 0))
|
|
38
|
+
return;
|
|
39
|
+
if (typeof magnitude === 'number') {
|
|
40
|
+
finalVector = Vector3.scale(Vector3.normalize(vector), magnitude);
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
finalVector = vector;
|
|
44
|
+
}
|
|
45
|
+
forceSources.set(source, finalVector);
|
|
46
|
+
recalcForce();
|
|
47
|
+
}
|
|
48
|
+
function removeForceFromPlayer(source) {
|
|
49
|
+
repulsionSources.delete(source);
|
|
50
|
+
const timerId = durationTimers.get(source);
|
|
51
|
+
if (timerId !== undefined) {
|
|
52
|
+
timers.clearTimeout(timerId);
|
|
53
|
+
durationTimers.delete(source);
|
|
54
|
+
}
|
|
55
|
+
if (!forceSources.has(source))
|
|
56
|
+
return;
|
|
57
|
+
forceSources.delete(source);
|
|
58
|
+
recalcForce();
|
|
59
|
+
}
|
|
60
|
+
function scheduleForceDuration(source, seconds) {
|
|
61
|
+
const existing = durationTimers.get(source);
|
|
62
|
+
if (existing !== undefined) {
|
|
63
|
+
timers.clearTimeout(existing);
|
|
64
|
+
}
|
|
65
|
+
const timerId = timers.setTimeout(() => {
|
|
66
|
+
durationTimers.delete(source);
|
|
67
|
+
removeForceFromPlayer(source);
|
|
68
|
+
}, seconds * 1000);
|
|
69
|
+
durationTimers.set(source, timerId);
|
|
70
|
+
}
|
|
71
|
+
function applyForceToPlayerForDuration(source, duration, vector, magnitude) {
|
|
72
|
+
applyForceToPlayer(source, vector, magnitude);
|
|
73
|
+
scheduleForceDuration(source, duration);
|
|
74
|
+
}
|
|
75
|
+
function computeRepulsionVector(fromPosition, magnitude, radius, falloff) {
|
|
76
|
+
const diff = Vector3.subtract(Transform.get(engine.PlayerEntity).position, fromPosition);
|
|
77
|
+
if (Vector3.equalsToFloats(diff, 0, 0, 0))
|
|
78
|
+
return { x: 0, y: magnitude, z: 0 };
|
|
79
|
+
// Fast path: default params — no need to compute distance
|
|
80
|
+
if (radius === Infinity && falloff === KnockbackFalloff.CONSTANT) {
|
|
81
|
+
return Vector3.scale(Vector3.normalize(diff), magnitude);
|
|
82
|
+
}
|
|
83
|
+
const distance = Vector3.length(diff);
|
|
84
|
+
if (distance > radius)
|
|
85
|
+
return null;
|
|
86
|
+
let effectiveMagnitude;
|
|
87
|
+
switch (falloff) {
|
|
88
|
+
case KnockbackFalloff.LINEAR:
|
|
89
|
+
effectiveMagnitude = magnitude * (1 - distance / radius);
|
|
90
|
+
break;
|
|
91
|
+
case KnockbackFalloff.INVERSE_SQUARE:
|
|
92
|
+
effectiveMagnitude = magnitude / (distance * distance + 1);
|
|
93
|
+
break;
|
|
94
|
+
case KnockbackFalloff.CONSTANT:
|
|
95
|
+
default:
|
|
96
|
+
effectiveMagnitude = magnitude;
|
|
97
|
+
break;
|
|
98
|
+
}
|
|
99
|
+
if (effectiveMagnitude === 0)
|
|
100
|
+
return null;
|
|
101
|
+
// normalize(diff) * effectiveMagnitude in one step
|
|
102
|
+
return Vector3.scale(diff, effectiveMagnitude / distance);
|
|
103
|
+
}
|
|
104
|
+
function applyRepulsionForceToPlayer(source, fromPosition, magnitude, radius = Infinity, falloff = KnockbackFalloff.CONSTANT) {
|
|
105
|
+
repulsionSources.set(source, { fromPosition, magnitude, radius, falloff });
|
|
106
|
+
const vector = computeRepulsionVector(fromPosition, magnitude, radius, falloff);
|
|
107
|
+
if (vector) {
|
|
108
|
+
forceSources.set(source, vector);
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
forceSources.delete(source);
|
|
112
|
+
}
|
|
113
|
+
recalcForce();
|
|
114
|
+
}
|
|
115
|
+
// Background system: recalculate repulsion vectors and clean up stale forces every tick.
|
|
116
|
+
// Stale forces can appear when CRDT sync from another client writes PhysicsCombinedForce
|
|
117
|
+
// externally (entity-1 ambiguity: each client interprets entity 1 as its own player).
|
|
118
|
+
engine.addSystem(() => {
|
|
119
|
+
// Repulsion forces need per-tick direction recalculation as the player moves
|
|
120
|
+
if (repulsionSources.size > 0) {
|
|
121
|
+
for (const [source, { fromPosition, magnitude, radius, falloff }] of repulsionSources) {
|
|
122
|
+
const vector = computeRepulsionVector(fromPosition, magnitude, radius, falloff);
|
|
123
|
+
if (vector) {
|
|
124
|
+
forceSources.set(source, vector);
|
|
125
|
+
}
|
|
126
|
+
else {
|
|
127
|
+
forceSources.delete(source);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
recalcForce();
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
// No local sources — clean up any externally-created component (e.g. from CRDT sync)
|
|
134
|
+
if (forceSources.size === 0 && PhysicsCombinedForce.has(engine.PlayerEntity)) {
|
|
135
|
+
PhysicsCombinedForce.deleteFrom(engine.PlayerEntity);
|
|
136
|
+
lastWrittenForceVector = null;
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
return { applyForceToPlayer, removeForceFromPlayer, applyForceToPlayerForDuration, applyRepulsionForceToPlayer };
|
|
140
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @public
|
|
3
|
+
* Falloff mode for knockback force over distance.
|
|
4
|
+
*/
|
|
5
|
+
export declare enum KnockbackFalloff {
|
|
6
|
+
/** Same force at any distance within radius */
|
|
7
|
+
CONSTANT = 0,
|
|
8
|
+
/** Smooth linear decrease to 0 at radius edge: F = magnitude * (1 - distance / radius) */
|
|
9
|
+
LINEAR = 1,
|
|
10
|
+
/** Sharp drop-off, physically realistic: F = magnitude / (distance^2 + 1) */
|
|
11
|
+
INVERSE_SQUARE = 2
|
|
12
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import * as components from '../components';
|
|
2
|
+
import { Vector3 } from '../runtime/helpers';
|
|
3
|
+
/**
|
|
4
|
+
* @public
|
|
5
|
+
* Falloff mode for knockback force over distance.
|
|
6
|
+
*/
|
|
7
|
+
export var KnockbackFalloff;
|
|
8
|
+
(function (KnockbackFalloff) {
|
|
9
|
+
/** Same force at any distance within radius */
|
|
10
|
+
KnockbackFalloff[KnockbackFalloff["CONSTANT"] = 0] = "CONSTANT";
|
|
11
|
+
/** Smooth linear decrease to 0 at radius edge: F = magnitude * (1 - distance / radius) */
|
|
12
|
+
KnockbackFalloff[KnockbackFalloff["LINEAR"] = 1] = "LINEAR";
|
|
13
|
+
/** Sharp drop-off, physically realistic: F = magnitude / (distance^2 + 1) */
|
|
14
|
+
KnockbackFalloff[KnockbackFalloff["INVERSE_SQUARE"] = 2] = "INVERSE_SQUARE";
|
|
15
|
+
})(KnockbackFalloff || (KnockbackFalloff = {}));
|
|
16
|
+
/** @internal */
|
|
17
|
+
export function createPhysicsImpulseHelper(engine) {
|
|
18
|
+
const PhysicsCombinedImpulse = components.PhysicsCombinedImpulse(engine);
|
|
19
|
+
const Transform = components.Transform(engine);
|
|
20
|
+
const EngineInfo = components.EngineInfo(engine);
|
|
21
|
+
let impulseEventId = 0;
|
|
22
|
+
let lastWrittenEventId = 0;
|
|
23
|
+
let lastWrittenTick = -1;
|
|
24
|
+
function applyImpulseToPlayer(vector, magnitude) {
|
|
25
|
+
let finalVector;
|
|
26
|
+
if (typeof magnitude === 'number') {
|
|
27
|
+
if (Vector3.equalsToFloats(vector, 0, 0, 0))
|
|
28
|
+
return;
|
|
29
|
+
finalVector = Vector3.scale(Vector3.normalize(vector), magnitude);
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
if (Vector3.equalsToFloats(vector, 0, 0, 0))
|
|
33
|
+
return;
|
|
34
|
+
finalVector = vector;
|
|
35
|
+
}
|
|
36
|
+
const currentTick = EngineInfo.getOrNull(engine.RootEntity)?.tickNumber ?? 0;
|
|
37
|
+
const existing = PhysicsCombinedImpulse.getOrNull(engine.PlayerEntity);
|
|
38
|
+
if (existing && existing.eventId !== lastWrittenEventId && lastWrittenEventId !== 0) {
|
|
39
|
+
throw new Error('PBPhysicsCombinedImpulse was modified outside Physics helper. ' +
|
|
40
|
+
'Do not mix direct component access with Physics.applyImpulseToPlayer().');
|
|
41
|
+
}
|
|
42
|
+
if (lastWrittenTick === currentTick && existing) {
|
|
43
|
+
finalVector = Vector3.add(existing.vector ?? { x: 0, y: 0, z: 0 }, finalVector);
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
lastWrittenEventId = ++impulseEventId;
|
|
47
|
+
}
|
|
48
|
+
lastWrittenTick = currentTick;
|
|
49
|
+
PhysicsCombinedImpulse.createOrReplace(engine.PlayerEntity, {
|
|
50
|
+
vector: finalVector,
|
|
51
|
+
eventId: lastWrittenEventId
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
function applyKnockbackToPlayer(fromPosition, magnitude, radius = Infinity, falloff = KnockbackFalloff.CONSTANT) {
|
|
55
|
+
const diff = Vector3.subtract(Transform.get(engine.PlayerEntity).position, fromPosition);
|
|
56
|
+
if (Vector3.equalsToFloats(diff, 0, 0, 0)) {
|
|
57
|
+
applyImpulseToPlayer({ x: 0, y: magnitude, z: 0 });
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
// Fast path: default params — no need to compute distance
|
|
61
|
+
if (radius === Infinity && falloff === KnockbackFalloff.CONSTANT) {
|
|
62
|
+
applyImpulseToPlayer(Vector3.scale(Vector3.normalize(diff), magnitude));
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
const distance = Vector3.length(diff);
|
|
66
|
+
if (distance > radius)
|
|
67
|
+
return;
|
|
68
|
+
let effectiveMagnitude;
|
|
69
|
+
switch (falloff) {
|
|
70
|
+
case KnockbackFalloff.LINEAR:
|
|
71
|
+
effectiveMagnitude = magnitude * (1 - distance / radius);
|
|
72
|
+
break;
|
|
73
|
+
case KnockbackFalloff.INVERSE_SQUARE:
|
|
74
|
+
effectiveMagnitude = magnitude / (distance * distance + 1);
|
|
75
|
+
break;
|
|
76
|
+
case KnockbackFalloff.CONSTANT:
|
|
77
|
+
default:
|
|
78
|
+
effectiveMagnitude = magnitude;
|
|
79
|
+
break;
|
|
80
|
+
}
|
|
81
|
+
// normalize(diff) * effectiveMagnitude in one step
|
|
82
|
+
applyImpulseToPlayer(Vector3.scale(diff, effectiveMagnitude / distance));
|
|
83
|
+
}
|
|
84
|
+
return { applyImpulseToPlayer, applyKnockbackToPlayer };
|
|
85
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { Entity } from '../engine';
|
|
2
|
+
import { Vector3Type } from '../schemas';
|
|
3
|
+
import { KnockbackFalloff } from './physics-impulse';
|
|
4
|
+
export { KnockbackFalloff } from './physics-impulse';
|
|
5
|
+
/**
|
|
6
|
+
* @public
|
|
7
|
+
*/
|
|
8
|
+
export interface PhysicsSystem {
|
|
9
|
+
/**
|
|
10
|
+
* Apply a one-shot impulse to the player entity.
|
|
11
|
+
* Multiple calls within the same frame are accumulated (summed).
|
|
12
|
+
*
|
|
13
|
+
* @param vector - a single `vector` whose length encodes the strength.
|
|
14
|
+
* or use overload for `direction` with a separate `magnitude` — the direction will be normalized before scaling.
|
|
15
|
+
*/
|
|
16
|
+
applyImpulseToPlayer(vector: Vector3Type): void;
|
|
17
|
+
applyImpulseToPlayer(direction: Vector3Type, magnitude: number): void;
|
|
18
|
+
/**
|
|
19
|
+
* Apply a continuous force to the player from a given source entity.
|
|
20
|
+
* Multiple sources are accumulated: the registry sums all active forces
|
|
21
|
+
* and writes a single PBPhysicsCombinedForce component.
|
|
22
|
+
* Calling again with the same source replaces its previous force.
|
|
23
|
+
*
|
|
24
|
+
* @param source - Entity key identifying this force source
|
|
25
|
+
* @param vector - single `vector` whose length encodes the strength
|
|
26
|
+
* or use overload for `direction` with a separate `magnitude` — the direction will be normalized before scaling.
|
|
27
|
+
*/
|
|
28
|
+
applyForceToPlayer(source: Entity, vector: Vector3Type): void;
|
|
29
|
+
applyForceToPlayer(source: Entity, direction: Vector3Type, magnitude: number): void;
|
|
30
|
+
/**
|
|
31
|
+
* Remove a continuous force from the player. Remaining sources are
|
|
32
|
+
* re-summed; if none remain the force is cleared. No-op if the source
|
|
33
|
+
* is not registered.
|
|
34
|
+
*
|
|
35
|
+
* @param source - Entity key identifying the force source to remove
|
|
36
|
+
*/
|
|
37
|
+
removeForceFromPlayer(source: Entity): void;
|
|
38
|
+
/**
|
|
39
|
+
* Push the player away from a point. Computes direction from
|
|
40
|
+
* `fromPosition` to the player, applies falloff, and delegates
|
|
41
|
+
* to applyImpulseToPlayer.
|
|
42
|
+
*
|
|
43
|
+
* If the player is exactly at `fromPosition`, pushes upward.
|
|
44
|
+
*
|
|
45
|
+
* @param fromPosition - world-space origin of the knockback (explosion center, enemy position, etc.)
|
|
46
|
+
* @param magnitude - base impulse strength
|
|
47
|
+
* @param radius - max distance of effect (default: Infinity)
|
|
48
|
+
* @param falloff - how force decreases with distance (default: CONSTANT)
|
|
49
|
+
*/
|
|
50
|
+
applyKnockbackToPlayer(fromPosition: Vector3Type, magnitude: number, radius?: number, falloff?: KnockbackFalloff): void;
|
|
51
|
+
/**
|
|
52
|
+
* Apply a continuous force to the player for a limited duration.
|
|
53
|
+
* After `duration` seconds the force is automatically removed.
|
|
54
|
+
* Calling again with the same source resets the timer.
|
|
55
|
+
*
|
|
56
|
+
* @param source - Entity key identifying this force source
|
|
57
|
+
* @param duration - how long the force lasts, in seconds
|
|
58
|
+
* @param vector - single `vector` whose length encodes the strength
|
|
59
|
+
* or use overload for `direction` with a separate `magnitude` — the direction will be normalized before scaling.
|
|
60
|
+
*/
|
|
61
|
+
applyForceToPlayerForDuration(source: Entity, duration: number, vector: Vector3Type): void;
|
|
62
|
+
applyForceToPlayerForDuration(source: Entity, duration: number, direction: Vector3Type, magnitude: number): void;
|
|
63
|
+
/**
|
|
64
|
+
* Apply a continuous repulsion force that pushes the player away from a point,
|
|
65
|
+
* recalculating direction every tick as the player moves.
|
|
66
|
+
* Remove with `removeForceFromPlayer(source)`.
|
|
67
|
+
*
|
|
68
|
+
* Negative magnitude = attraction (pulls toward the source).
|
|
69
|
+
*
|
|
70
|
+
* @param source - Entity key identifying this force source
|
|
71
|
+
* @param fromPosition - world-space origin of repulsion
|
|
72
|
+
* @param magnitude - base force strength
|
|
73
|
+
* @param radius - max distance of effect (default: Infinity)
|
|
74
|
+
* @param falloff - how force decreases with distance (default: CONSTANT)
|
|
75
|
+
*/
|
|
76
|
+
applyRepulsionForceToPlayer(source: Entity, fromPosition: Vector3Type, magnitude: number, radius?: number, falloff?: KnockbackFalloff): void;
|
|
77
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { createPhysicsImpulseHelper } from './physics-impulse';
|
|
2
|
+
import { createPhysicsForceHelper } from './physics-force';
|
|
3
|
+
export { KnockbackFalloff } from './physics-impulse';
|
|
4
|
+
/**
|
|
5
|
+
* @internal
|
|
6
|
+
*/
|
|
7
|
+
export function createPhysicsSystem(engine) {
|
|
8
|
+
const impulse = createPhysicsImpulseHelper(engine);
|
|
9
|
+
const force = createPhysicsForceHelper(engine);
|
|
10
|
+
return {
|
|
11
|
+
applyImpulseToPlayer: impulse.applyImpulseToPlayer,
|
|
12
|
+
applyForceToPlayer: force.applyForceToPlayer,
|
|
13
|
+
removeForceFromPlayer: force.removeForceFromPlayer,
|
|
14
|
+
applyKnockbackToPlayer: impulse.applyKnockbackToPlayer,
|
|
15
|
+
applyForceToPlayerForDuration: force.applyForceToPlayerForDuration,
|
|
16
|
+
applyRepulsionForceToPlayer: force.applyRepulsionForceToPlayer
|
|
17
|
+
};
|
|
18
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { IEngine, LastWriteWinElementSetComponentDefinition } from '../../engine';
|
|
2
|
+
import { PBParticleSystem, PBParticleSystem_BlendMode, PBParticleSystem_PlaybackState, PBParticleSystem_Point, PBParticleSystem_Sphere, PBParticleSystem_Cone, PBParticleSystem_Box } from '../generated/index.gen';
|
|
3
|
+
export { PBParticleSystem_BlendMode as ParticleSystemBlendMode, PBParticleSystem_PlaybackState as ParticleSystemPlaybackState };
|
|
4
|
+
/**
|
|
5
|
+
* @public
|
|
6
|
+
*/
|
|
7
|
+
export interface ParticleSystemHelper {
|
|
8
|
+
/** Emit from a single point */
|
|
9
|
+
Point: (point?: PBParticleSystem_Point) => PBParticleSystem['shape'];
|
|
10
|
+
/** Emit from the surface or volume of a sphere */
|
|
11
|
+
Sphere: (sphere?: PBParticleSystem_Sphere) => PBParticleSystem['shape'];
|
|
12
|
+
/** Emit from the base of a cone, projecting outward */
|
|
13
|
+
Cone: (cone?: PBParticleSystem_Cone) => PBParticleSystem['shape'];
|
|
14
|
+
/** Emit from the surface or volume of a box */
|
|
15
|
+
Box: (box?: PBParticleSystem_Box) => PBParticleSystem['shape'];
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* @public
|
|
19
|
+
*/
|
|
20
|
+
export interface ParticleSystemComponentDefinitionExtended extends LastWriteWinElementSetComponentDefinition<PBParticleSystem> {
|
|
21
|
+
/** Helpers for constructing emitter shapes */
|
|
22
|
+
Shape: ParticleSystemHelper;
|
|
23
|
+
}
|
|
24
|
+
export declare function defineParticleSystemComponent(engine: Pick<IEngine, 'defineComponentFromSchema'>): ParticleSystemComponentDefinitionExtended;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.defineParticleSystemComponent = exports.ParticleSystemPlaybackState = exports.ParticleSystemBlendMode = void 0;
|
|
4
|
+
const index_gen_1 = require("../generated/index.gen");
|
|
5
|
+
Object.defineProperty(exports, "ParticleSystemBlendMode", { enumerable: true, get: function () { return index_gen_1.PBParticleSystem_BlendMode; } });
|
|
6
|
+
Object.defineProperty(exports, "ParticleSystemPlaybackState", { enumerable: true, get: function () { return index_gen_1.PBParticleSystem_PlaybackState; } });
|
|
7
|
+
const ParticleSystemShapeHelper = {
|
|
8
|
+
Point(point = {}) {
|
|
9
|
+
return { $case: 'point', point };
|
|
10
|
+
},
|
|
11
|
+
Sphere(sphere = {}) {
|
|
12
|
+
return { $case: 'sphere', sphere };
|
|
13
|
+
},
|
|
14
|
+
Cone(cone = {}) {
|
|
15
|
+
return { $case: 'cone', cone };
|
|
16
|
+
},
|
|
17
|
+
Box(box = {}) {
|
|
18
|
+
return { $case: 'box', box };
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
function defineParticleSystemComponent(engine) {
|
|
22
|
+
const theComponent = (0, index_gen_1.ParticleSystem)(engine);
|
|
23
|
+
return {
|
|
24
|
+
...theComponent,
|
|
25
|
+
Shape: ParticleSystemShapeHelper
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
exports.defineParticleSystemComponent = defineParticleSystemComponent;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ParticleSystemSchema = void 0;
|
|
4
|
+
const particle_system_gen_1 = require("./pb/decentraland/sdk/components/particle_system.gen");
|
|
5
|
+
/**
|
|
6
|
+
* @internal
|
|
7
|
+
*/
|
|
8
|
+
exports.ParticleSystemSchema = {
|
|
9
|
+
COMPONENT_ID: 1217,
|
|
10
|
+
serialize(value, builder) {
|
|
11
|
+
const writer = particle_system_gen_1.PBParticleSystem.encode(value);
|
|
12
|
+
const buffer = new Uint8Array(writer.finish(), 0, writer.len);
|
|
13
|
+
builder.writeBuffer(buffer, false);
|
|
14
|
+
},
|
|
15
|
+
deserialize(reader) {
|
|
16
|
+
return particle_system_gen_1.PBParticleSystem.decode(reader.buffer(), reader.remainingBytes());
|
|
17
|
+
},
|
|
18
|
+
create() {
|
|
19
|
+
// TODO: this is a hack.
|
|
20
|
+
return particle_system_gen_1.PBParticleSystem.decode(new Uint8Array());
|
|
21
|
+
},
|
|
22
|
+
jsonSchema: {
|
|
23
|
+
type: "object",
|
|
24
|
+
properties: {},
|
|
25
|
+
serializationType: "protocol-buffer",
|
|
26
|
+
protocolBuffer: "PBParticleSystem"
|
|
27
|
+
}
|
|
28
|
+
};
|
|
@@ -33,6 +33,7 @@ exports.coreComponentMappings = {
|
|
|
33
33
|
"core::MeshCollider": 1019,
|
|
34
34
|
"core::MeshRenderer": 1018,
|
|
35
35
|
"core::NftShape": 1040,
|
|
36
|
+
"core::ParticleSystem": 1217,
|
|
36
37
|
"core::PhysicsCombinedForce": 1216,
|
|
37
38
|
"core::PhysicsCombinedImpulse": 1215,
|
|
38
39
|
"core::PlayerIdentityData": 1089,
|