@dcl/playground-assets 7.0.6-3808797047.commit-ee7ea04 → 7.0.6-3808988484.commit-63d3e2c

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/alpha.d.ts CHANGED
@@ -1,5 +1,7 @@
1
1
  import _m0 from 'protobufjs/minimal';
2
2
 
3
+ export declare const AMOUNT_VERSION_AVAILABLE: number;
4
+
3
5
  export declare const Animator: AnimatorComponentDefinitionExtended;
4
6
 
5
7
  /**
@@ -981,8 +983,8 @@ export declare type Color4Type = {
981
983
  };
982
984
 
983
985
  export declare type CommonProps = {
984
- key: Key;
985
- children: Children;
986
+ key?: Key;
987
+ children?: Children;
986
988
  };
987
989
 
988
990
  /**
@@ -1170,9 +1172,20 @@ export declare type EngineEvent<T extends IEventNames = IEventNames, V = IEvents
1170
1172
  };
1171
1173
 
1172
1174
  /**
1173
- * @public
1175
+ * @public The Entity is a number type, the cast is only for typescript, the final javascript code treat as a number
1176
+ * version number
1177
+ * [31...16][15...0]
1178
+ *
1179
+ * Convertion from entity to its compound numbers:
1180
+ * To get the version => ((entity & MASK_UPPER_16_ON_32) >> 16) & MAX_U16
1181
+ * To get the number => entity & MAX_U16
1182
+ *
1183
+ * Convertion from its compound numbers to entity:
1184
+ * entity = (entityNumber & MAX_U16) | ((entityVersion & MAX_U16) << 16)
1174
1185
  */
1175
- export declare type Entity = unknown;
1186
+ export declare type Entity = uint32 & {
1187
+ __entity_type: '';
1188
+ };
1176
1189
 
1177
1190
  export declare type EntityComponents = {
1178
1191
  uiTransform: PBUiTransform;
@@ -1185,10 +1198,13 @@ export declare type EntityComponents = {
1185
1198
  };
1186
1199
 
1187
1200
  export declare function EntityContainer(): {
1188
- generateEntity(dynamic?: boolean): Entity;
1201
+ generateEntity(): Entity;
1189
1202
  removeEntity(entity: Entity): boolean;
1190
1203
  entityExists(entity: Entity): boolean;
1191
1204
  getExistingEntities(): Set<Entity>;
1205
+ entityVersion: (entity: Entity) => number;
1206
+ entityNumber: (entity: Entity) => number;
1207
+ entityId: (entityNumber: number, entityVersion: number) => Entity;
1192
1208
  };
1193
1209
 
1194
1210
  /**
@@ -1197,7 +1213,7 @@ export declare function EntityContainer(): {
1197
1213
  export declare type EntityPropTypes = {
1198
1214
  uiTransform?: UiTransformProps;
1199
1215
  uiBackground?: UiBackgroundProps;
1200
- } & Listeners;
1216
+ } & Listeners & Pick<CommonProps, 'key'>;
1201
1217
 
1202
1218
  /**
1203
1219
  * Constant used to define the minimal number value in Babylon.js
@@ -1683,6 +1699,8 @@ export declare type MapResult<T extends Spec> = ToOptional<{
1683
1699
  [K in keyof T]: T[K] extends ISchema ? ReturnType<T[K]['deserialize']> : T[K] extends Spec ? MapResult<T[K]> : never;
1684
1700
  }>;
1685
1701
 
1702
+ export declare const MASK_UPPER_16_ON_32 = 4294901760;
1703
+
1686
1704
  export declare const Material: MaterialComponentDefinitionExtended;
1687
1705
 
1688
1706
  /**
@@ -2451,6 +2469,13 @@ export declare namespace Matrix {
2451
2469
  export function toggleProjectionMatrixHandInPlace(self: MutableMatrix): void;
2452
2470
  }
2453
2471
 
2472
+ /**
2473
+ * @public
2474
+ */
2475
+ export declare const MAX_ENTITY_NUMBER = 65535;
2476
+
2477
+ export declare const MAX_U16 = 65535;
2478
+
2454
2479
  export declare const MeshCollider: MeshColliderComponentDefinitionExtended;
2455
2480
 
2456
2481
  /**
@@ -3687,12 +3712,12 @@ export declare const PointerEventsResult: ComponentDefinition<PBPointerEventsRes
3687
3712
  export declare type PointerEventsSystem = ReturnType<typeof createPointerEventSystem>;
3688
3713
 
3689
3714
  export declare const pointerEventsSystem: {
3690
- removeOnClick(entity: unknown): void;
3691
- removeOnPointerDown(entity: unknown): void;
3692
- removeOnPointerUp(entity: unknown): void;
3693
- onClick(entity: unknown, cb: EventSystemCallback, opts?: Partial<EventSystemOptions> | undefined): void;
3694
- onPointerDown(entity: unknown, cb: EventSystemCallback, opts?: Partial<EventSystemOptions> | undefined): void;
3695
- onPointerUp(entity: unknown, cb: EventSystemCallback, opts?: Partial<EventSystemOptions> | undefined): void;
3715
+ removeOnClick(entity: Entity): void;
3716
+ removeOnPointerDown(entity: Entity): void;
3717
+ removeOnPointerUp(entity: Entity): void;
3718
+ onClick(entity: Entity, cb: EventSystemCallback, opts?: Partial<EventSystemOptions> | undefined): void;
3719
+ onPointerDown(entity: Entity, cb: EventSystemCallback, opts?: Partial<EventSystemOptions> | undefined): void;
3720
+ onPointerUp(entity: Entity, cb: EventSystemCallback, opts?: Partial<EventSystemOptions> | undefined): void;
3696
3721
  };
3697
3722
 
3698
3723
  export declare const enum PointerEventType {
@@ -4055,6 +4080,11 @@ export declare type ReceiveMessage = {
4055
4080
  messageBuffer: Uint8Array;
4056
4081
  };
4057
4082
 
4083
+ /**
4084
+ * @public This first 512 entities are reserved by the renderer
4085
+ */
4086
+ export declare const RESERVED_STATIC_ENTITIES = 512;
4087
+
4058
4088
  export declare type RPCSendableMessage = {
4059
4089
  jsonrpc: '2.0';
4060
4090
  id: number;
@@ -4495,6 +4525,11 @@ export declare type UiInputProps = PBUiInput & {
4495
4525
  /** @public */
4496
4526
  export declare const UiInputResult: ComponentDefinition<PBUiInputResult>;
4497
4527
 
4528
+ /**
4529
+ * @public It only defines the type explicitly, no effects.
4530
+ */
4531
+ export declare type uint32 = number;
4532
+
4498
4533
  /** @public */
4499
4534
  export declare const UiText: ComponentDefinition<PBUiText>;
4500
4535
 
package/dist/beta.d.ts CHANGED
@@ -1,5 +1,7 @@
1
1
  import _m0 from 'protobufjs/minimal';
2
2
 
3
+ export declare const AMOUNT_VERSION_AVAILABLE: number;
4
+
3
5
  export declare const Animator: AnimatorComponentDefinitionExtended;
4
6
 
5
7
  /**
@@ -981,8 +983,8 @@ export declare type Color4Type = {
981
983
  };
982
984
 
983
985
  export declare type CommonProps = {
984
- key: Key;
985
- children: Children;
986
+ key?: Key;
987
+ children?: Children;
986
988
  };
987
989
 
988
990
  /**
@@ -1170,9 +1172,20 @@ export declare type EngineEvent<T extends IEventNames = IEventNames, V = IEvents
1170
1172
  };
1171
1173
 
1172
1174
  /**
1173
- * @public
1175
+ * @public The Entity is a number type, the cast is only for typescript, the final javascript code treat as a number
1176
+ * version number
1177
+ * [31...16][15...0]
1178
+ *
1179
+ * Convertion from entity to its compound numbers:
1180
+ * To get the version => ((entity & MASK_UPPER_16_ON_32) >> 16) & MAX_U16
1181
+ * To get the number => entity & MAX_U16
1182
+ *
1183
+ * Convertion from its compound numbers to entity:
1184
+ * entity = (entityNumber & MAX_U16) | ((entityVersion & MAX_U16) << 16)
1174
1185
  */
1175
- export declare type Entity = unknown;
1186
+ export declare type Entity = uint32 & {
1187
+ __entity_type: '';
1188
+ };
1176
1189
 
1177
1190
  export declare type EntityComponents = {
1178
1191
  uiTransform: PBUiTransform;
@@ -1185,10 +1198,13 @@ export declare type EntityComponents = {
1185
1198
  };
1186
1199
 
1187
1200
  export declare function EntityContainer(): {
1188
- generateEntity(dynamic?: boolean): Entity;
1201
+ generateEntity(): Entity;
1189
1202
  removeEntity(entity: Entity): boolean;
1190
1203
  entityExists(entity: Entity): boolean;
1191
1204
  getExistingEntities(): Set<Entity>;
1205
+ entityVersion: (entity: Entity) => number;
1206
+ entityNumber: (entity: Entity) => number;
1207
+ entityId: (entityNumber: number, entityVersion: number) => Entity;
1192
1208
  };
1193
1209
 
1194
1210
  /**
@@ -1197,7 +1213,7 @@ export declare function EntityContainer(): {
1197
1213
  export declare type EntityPropTypes = {
1198
1214
  uiTransform?: UiTransformProps;
1199
1215
  uiBackground?: UiBackgroundProps;
1200
- } & Listeners;
1216
+ } & Listeners & Pick<CommonProps, 'key'>;
1201
1217
 
1202
1218
  /**
1203
1219
  * Constant used to define the minimal number value in Babylon.js
@@ -1683,6 +1699,8 @@ export declare type MapResult<T extends Spec> = ToOptional<{
1683
1699
  [K in keyof T]: T[K] extends ISchema ? ReturnType<T[K]['deserialize']> : T[K] extends Spec ? MapResult<T[K]> : never;
1684
1700
  }>;
1685
1701
 
1702
+ export declare const MASK_UPPER_16_ON_32 = 4294901760;
1703
+
1686
1704
  export declare const Material: MaterialComponentDefinitionExtended;
1687
1705
 
1688
1706
  /**
@@ -2451,6 +2469,13 @@ export declare namespace Matrix {
2451
2469
  export function toggleProjectionMatrixHandInPlace(self: MutableMatrix): void;
2452
2470
  }
2453
2471
 
2472
+ /**
2473
+ * @public
2474
+ */
2475
+ export declare const MAX_ENTITY_NUMBER = 65535;
2476
+
2477
+ export declare const MAX_U16 = 65535;
2478
+
2454
2479
  export declare const MeshCollider: MeshColliderComponentDefinitionExtended;
2455
2480
 
2456
2481
  /**
@@ -3687,12 +3712,12 @@ export declare const PointerEventsResult: ComponentDefinition<PBPointerEventsRes
3687
3712
  export declare type PointerEventsSystem = ReturnType<typeof createPointerEventSystem>;
3688
3713
 
3689
3714
  export declare const pointerEventsSystem: {
3690
- removeOnClick(entity: unknown): void;
3691
- removeOnPointerDown(entity: unknown): void;
3692
- removeOnPointerUp(entity: unknown): void;
3693
- onClick(entity: unknown, cb: EventSystemCallback, opts?: Partial<EventSystemOptions> | undefined): void;
3694
- onPointerDown(entity: unknown, cb: EventSystemCallback, opts?: Partial<EventSystemOptions> | undefined): void;
3695
- onPointerUp(entity: unknown, cb: EventSystemCallback, opts?: Partial<EventSystemOptions> | undefined): void;
3715
+ removeOnClick(entity: Entity): void;
3716
+ removeOnPointerDown(entity: Entity): void;
3717
+ removeOnPointerUp(entity: Entity): void;
3718
+ onClick(entity: Entity, cb: EventSystemCallback, opts?: Partial<EventSystemOptions> | undefined): void;
3719
+ onPointerDown(entity: Entity, cb: EventSystemCallback, opts?: Partial<EventSystemOptions> | undefined): void;
3720
+ onPointerUp(entity: Entity, cb: EventSystemCallback, opts?: Partial<EventSystemOptions> | undefined): void;
3696
3721
  };
3697
3722
 
3698
3723
  export declare const enum PointerEventType {
@@ -4055,6 +4080,11 @@ export declare type ReceiveMessage = {
4055
4080
  messageBuffer: Uint8Array;
4056
4081
  };
4057
4082
 
4083
+ /**
4084
+ * @public This first 512 entities are reserved by the renderer
4085
+ */
4086
+ export declare const RESERVED_STATIC_ENTITIES = 512;
4087
+
4058
4088
  export declare type RPCSendableMessage = {
4059
4089
  jsonrpc: '2.0';
4060
4090
  id: number;
@@ -4495,6 +4525,11 @@ export declare type UiInputProps = PBUiInput & {
4495
4525
  /** @public */
4496
4526
  export declare const UiInputResult: ComponentDefinition<PBUiInputResult>;
4497
4527
 
4528
+ /**
4529
+ * @public It only defines the type explicitly, no effects.
4530
+ */
4531
+ export declare type uint32 = number;
4532
+
4498
4533
  /** @public */
4499
4534
  export declare const UiText: ComponentDefinition<PBUiText>;
4500
4535
 
@@ -1,5 +1,7 @@
1
1
  import _m0 from 'protobufjs/minimal';
2
2
 
3
+ export declare const AMOUNT_VERSION_AVAILABLE: number;
4
+
3
5
  export declare const Animator: AnimatorComponentDefinitionExtended;
4
6
 
5
7
  /**
@@ -981,8 +983,8 @@ export declare type Color4Type = {
981
983
  };
982
984
 
983
985
  export declare type CommonProps = {
984
- key: Key;
985
- children: Children;
986
+ key?: Key;
987
+ children?: Children;
986
988
  };
987
989
 
988
990
  /**
@@ -1170,9 +1172,20 @@ export declare type EngineEvent<T extends IEventNames = IEventNames, V = IEvents
1170
1172
  };
1171
1173
 
1172
1174
  /**
1173
- * @public
1175
+ * @public The Entity is a number type, the cast is only for typescript, the final javascript code treat as a number
1176
+ * version number
1177
+ * [31...16][15...0]
1178
+ *
1179
+ * Convertion from entity to its compound numbers:
1180
+ * To get the version => ((entity & MASK_UPPER_16_ON_32) >> 16) & MAX_U16
1181
+ * To get the number => entity & MAX_U16
1182
+ *
1183
+ * Convertion from its compound numbers to entity:
1184
+ * entity = (entityNumber & MAX_U16) | ((entityVersion & MAX_U16) << 16)
1174
1185
  */
1175
- export declare type Entity = unknown;
1186
+ export declare type Entity = uint32 & {
1187
+ __entity_type: '';
1188
+ };
1176
1189
 
1177
1190
  export declare type EntityComponents = {
1178
1191
  uiTransform: PBUiTransform;
@@ -1185,10 +1198,13 @@ export declare type EntityComponents = {
1185
1198
  };
1186
1199
 
1187
1200
  export declare function EntityContainer(): {
1188
- generateEntity(dynamic?: boolean): Entity;
1201
+ generateEntity(): Entity;
1189
1202
  removeEntity(entity: Entity): boolean;
1190
1203
  entityExists(entity: Entity): boolean;
1191
1204
  getExistingEntities(): Set<Entity>;
1205
+ entityVersion: (entity: Entity) => number;
1206
+ entityNumber: (entity: Entity) => number;
1207
+ entityId: (entityNumber: number, entityVersion: number) => Entity;
1192
1208
  };
1193
1209
 
1194
1210
  /**
@@ -1197,7 +1213,7 @@ export declare function EntityContainer(): {
1197
1213
  export declare type EntityPropTypes = {
1198
1214
  uiTransform?: UiTransformProps;
1199
1215
  uiBackground?: UiBackgroundProps;
1200
- } & Listeners;
1216
+ } & Listeners & Pick<CommonProps, 'key'>;
1201
1217
 
1202
1218
  /**
1203
1219
  * Constant used to define the minimal number value in Babylon.js
@@ -1683,6 +1699,8 @@ export declare type MapResult<T extends Spec> = ToOptional<{
1683
1699
  [K in keyof T]: T[K] extends ISchema ? ReturnType<T[K]['deserialize']> : T[K] extends Spec ? MapResult<T[K]> : never;
1684
1700
  }>;
1685
1701
 
1702
+ export declare const MASK_UPPER_16_ON_32 = 4294901760;
1703
+
1686
1704
  export declare const Material: MaterialComponentDefinitionExtended;
1687
1705
 
1688
1706
  /**
@@ -2451,6 +2469,13 @@ export declare namespace Matrix {
2451
2469
  export function toggleProjectionMatrixHandInPlace(self: MutableMatrix): void;
2452
2470
  }
2453
2471
 
2472
+ /**
2473
+ * @public
2474
+ */
2475
+ export declare const MAX_ENTITY_NUMBER = 65535;
2476
+
2477
+ export declare const MAX_U16 = 65535;
2478
+
2454
2479
  export declare const MeshCollider: MeshColliderComponentDefinitionExtended;
2455
2480
 
2456
2481
  /**
@@ -3687,12 +3712,12 @@ export declare const PointerEventsResult: ComponentDefinition<PBPointerEventsRes
3687
3712
  export declare type PointerEventsSystem = ReturnType<typeof createPointerEventSystem>;
3688
3713
 
3689
3714
  export declare const pointerEventsSystem: {
3690
- removeOnClick(entity: unknown): void;
3691
- removeOnPointerDown(entity: unknown): void;
3692
- removeOnPointerUp(entity: unknown): void;
3693
- onClick(entity: unknown, cb: EventSystemCallback, opts?: Partial<EventSystemOptions> | undefined): void;
3694
- onPointerDown(entity: unknown, cb: EventSystemCallback, opts?: Partial<EventSystemOptions> | undefined): void;
3695
- onPointerUp(entity: unknown, cb: EventSystemCallback, opts?: Partial<EventSystemOptions> | undefined): void;
3715
+ removeOnClick(entity: Entity): void;
3716
+ removeOnPointerDown(entity: Entity): void;
3717
+ removeOnPointerUp(entity: Entity): void;
3718
+ onClick(entity: Entity, cb: EventSystemCallback, opts?: Partial<EventSystemOptions> | undefined): void;
3719
+ onPointerDown(entity: Entity, cb: EventSystemCallback, opts?: Partial<EventSystemOptions> | undefined): void;
3720
+ onPointerUp(entity: Entity, cb: EventSystemCallback, opts?: Partial<EventSystemOptions> | undefined): void;
3696
3721
  };
3697
3722
 
3698
3723
  export declare const enum PointerEventType {
@@ -4055,6 +4080,11 @@ export declare type ReceiveMessage = {
4055
4080
  messageBuffer: Uint8Array;
4056
4081
  };
4057
4082
 
4083
+ /**
4084
+ * @public This first 512 entities are reserved by the renderer
4085
+ */
4086
+ export declare const RESERVED_STATIC_ENTITIES = 512;
4087
+
4058
4088
  export declare type RPCSendableMessage = {
4059
4089
  jsonrpc: '2.0';
4060
4090
  id: number;
@@ -4495,6 +4525,11 @@ export declare type UiInputProps = PBUiInput & {
4495
4525
  /** @public */
4496
4526
  export declare const UiInputResult: ComponentDefinition<PBUiInputResult>;
4497
4527
 
4528
+ /**
4529
+ * @public It only defines the type explicitly, no effects.
4530
+ */
4531
+ export declare type uint32 = number;
4532
+
4498
4533
  /** @public */
4499
4534
  export declare const UiText: ComponentDefinition<PBUiText>;
4500
4535
 
package/dist/index.js CHANGED
@@ -14055,98 +14055,76 @@
14055
14055
  };
14056
14056
  }
14057
14057
 
14058
- var EntityUtils;
14059
- (function (EntityUtils) {
14060
- EntityUtils.MAX_ENTITIES = 0xffffffff;
14061
- EntityUtils.DYNAMIC_ENTITIES_START_AT = 100e3;
14062
- EntityUtils.RESERVED_STATIC_ENTITIES = 512;
14063
- EntityUtils.RESERVED_ENTITIES_RANGE = [
14064
- 0,
14065
- EntityUtils.RESERVED_STATIC_ENTITIES - 1
14066
- ];
14067
- EntityUtils.STATIC_ENTITIES_RANGE = [
14068
- EntityUtils.RESERVED_STATIC_ENTITIES,
14069
- EntityUtils.MAX_ENTITIES
14070
- // DYNAMIC_ENTITIES_START_AT - 1
14071
- ];
14072
- EntityUtils.DYNAMIC_ENTITIES_RANGE = [
14073
- EntityUtils.DYNAMIC_ENTITIES_START_AT,
14074
- EntityUtils.MAX_ENTITIES
14075
- ];
14076
- function isInRange(entity, range) {
14077
- return entity >= range[0] && entity <= range[1];
14078
- }
14079
- // @internal
14080
- function isDynamicEntity(entity) {
14081
- return isInRange(entity, EntityUtils.DYNAMIC_ENTITIES_RANGE);
14058
+ const MAX_U16 = 0xffff;
14059
+ const MASK_UPPER_16_ON_32 = 0xffff0000;
14060
+ const AMOUNT_VERSION_AVAILABLE = MAX_U16 + 1;
14061
+ /**
14062
+ * @public This first 512 entities are reserved by the renderer
14063
+ */
14064
+ const RESERVED_STATIC_ENTITIES = 512;
14065
+ /**
14066
+ * @public
14067
+ */
14068
+ const MAX_ENTITY_NUMBER = MAX_U16;
14069
+ function EntityContainer() {
14070
+ let entityCounter = RESERVED_STATIC_ENTITIES;
14071
+ const usedEntities = new Set();
14072
+ const removedEntities = new Map();
14073
+ function entityVersion(entity) {
14074
+ return (((entity & MASK_UPPER_16_ON_32) >> 16) & MAX_U16) >>> 0;
14082
14075
  }
14083
- EntityUtils.isDynamicEntity = isDynamicEntity;
14084
- function isStaticEntity(entity) {
14085
- return isInRange(entity, EntityUtils.STATIC_ENTITIES_RANGE);
14076
+ function entityNumber(entity) {
14077
+ return (entity & MAX_U16) >>> 0;
14086
14078
  }
14087
- EntityUtils.isStaticEntity = isStaticEntity;
14088
- function isReservedEntity(entity) {
14089
- return isInRange(entity, EntityUtils.RESERVED_ENTITIES_RANGE);
14079
+ function entityId(entityNumber, entityVersion) {
14080
+ return (((entityNumber & MAX_U16) | ((entityVersion & MAX_U16) << 16)) >>>
14081
+ 0);
14090
14082
  }
14091
- EntityUtils.isReservedEntity = isReservedEntity;
14092
- })(EntityUtils || (EntityUtils = {}));
14093
-
14094
- function EntityContainer() {
14095
- const staticEntity = Entity(EntityUtils.STATIC_ENTITIES_RANGE);
14096
- const dynamicEntity = Entity(EntityUtils.DYNAMIC_ENTITIES_RANGE);
14097
- return {
14098
- generateEntity(dynamic = false) {
14099
- /* istanbul ignore next */
14100
- if (dynamic) {
14101
- // Dynamic entities are not being used, but since we dont know the future of the dynamic entities
14102
- // I prefer to comment the code instead of removing all the logic
14103
- /* istanbul ignore next */
14104
- return dynamicEntity.generateEntity();
14105
- }
14106
- else {
14107
- return staticEntity.generateEntity();
14108
- }
14109
- },
14110
- removeEntity(entity) {
14111
- return (staticEntity.removeEntity(entity) || dynamicEntity.removeEntity(entity));
14112
- },
14113
- entityExists(entity) {
14114
- return (EntityUtils.isReservedEntity(entity) ||
14115
- staticEntity.getExistingEntities().has(entity) ||
14116
- dynamicEntity.getExistingEntities().has(entity));
14117
- },
14118
- getExistingEntities() {
14119
- return new Set([
14120
- ...staticEntity.getExistingEntities(),
14121
- ...dynamicEntity.getExistingEntities()
14122
- ]);
14083
+ function generateNewEntity() {
14084
+ if (entityCounter > MAX_ENTITY_NUMBER - 1) {
14085
+ throw new Error(`It fails trying to generate an entity out of range ${MAX_ENTITY_NUMBER}.`);
14123
14086
  }
14124
- };
14125
- }
14126
- function Entity(range) {
14127
- function createEntity(entity) {
14087
+ const entity = entityCounter++;
14088
+ usedEntities.add(entity);
14128
14089
  return entity;
14129
14090
  }
14130
- let entityCounter = range[0];
14131
- const usedEntities = new Set();
14132
14091
  function generateEntity() {
14133
- if (entityCounter >= range[1]) {
14134
- throw new Error(`It fails trying to generate an entity out of range [${range[0]}, ${range[1]}].`);
14092
+ if (usedEntities.size + RESERVED_STATIC_ENTITIES >= entityCounter) {
14093
+ return generateNewEntity();
14094
+ }
14095
+ for (const [number, version] of removedEntities) {
14096
+ if (version < MAX_U16) {
14097
+ const entity = entityId(number, version + 1);
14098
+ usedEntities.add(entity);
14099
+ removedEntities.delete(number);
14100
+ return entity;
14101
+ }
14135
14102
  }
14136
- const entity = createEntity(entityCounter);
14137
- entityCounter++;
14138
- usedEntities.add(entity);
14139
- return entity;
14103
+ return generateNewEntity();
14140
14104
  }
14141
14105
  function removeEntity(entity) {
14142
- return usedEntities.delete(entity);
14106
+ const deleted = usedEntities.delete(entity);
14107
+ if (deleted) {
14108
+ removedEntities.set(entityNumber(entity), entityVersion(entity));
14109
+ }
14110
+ return deleted;
14143
14111
  }
14144
14112
  return {
14113
+ generateEntity() {
14114
+ return generateEntity();
14115
+ },
14116
+ removeEntity(entity) {
14117
+ return removeEntity(entity);
14118
+ },
14119
+ entityExists(entity) {
14120
+ return entity < RESERVED_STATIC_ENTITIES || usedEntities.has(entity);
14121
+ },
14145
14122
  getExistingEntities() {
14146
14123
  return new Set(usedEntities);
14147
14124
  },
14148
- generateEntity,
14149
- removeEntity
14125
+ entityVersion,
14126
+ entityNumber,
14127
+ entityId
14150
14128
  };
14151
14129
  }
14152
14130
 
@@ -41180,6 +41158,7 @@
41180
41158
  await pollEvents(EngineApi.sendBatch);
41181
41159
  }
41182
41160
 
41161
+ exports.AMOUNT_VERSION_AVAILABLE = AMOUNT_VERSION_AVAILABLE;
41183
41162
  exports.Animator = Animator;
41184
41163
  exports.AudioSource = AudioSource;
41185
41164
  exports.AudioStream = AudioStream;
@@ -41201,6 +41180,9 @@
41201
41180
  exports.GltfContainer = GltfContainer;
41202
41181
  exports.Input = Input;
41203
41182
  exports.Label = Label;
41183
+ exports.MASK_UPPER_16_ON_32 = MASK_UPPER_16_ON_32;
41184
+ exports.MAX_ENTITY_NUMBER = MAX_ENTITY_NUMBER;
41185
+ exports.MAX_U16 = MAX_U16;
41204
41186
  exports.Material = Material;
41205
41187
  exports.MeshCollider = MeshCollider;
41206
41188
  exports.MeshRenderer = MeshRenderer;
@@ -41255,6 +41237,7 @@
41255
41237
  exports.PointerEventsResult = PointerEventsResult;
41256
41238
  exports.PointerLock = PointerLock;
41257
41239
  exports.RAD2DEG = RAD2DEG;
41240
+ exports.RESERVED_STATIC_ENTITIES = RESERVED_STATIC_ENTITIES;
41258
41241
  exports.Raycast = Raycast;
41259
41242
  exports.RaycastHit = RaycastHit;
41260
41243
  exports.RaycastResult = RaycastResult;