@caspertech/node-metaverse 0.6.4 → 0.6.6

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.
Files changed (69) hide show
  1. package/dist/lib/classes/LLGLTFMaterial.spec.js +47 -17
  2. package/dist/lib/classes/LLGLTFMaterial.spec.js.map +1 -1
  3. package/dist/lib/classes/LLGLTFMaterialData.d.ts +180 -21
  4. package/dist/lib/classes/LLGLTFMaterialOverride.d.ts +16 -0
  5. package/dist/lib/classes/LLGLTFMaterialOverride.js +7 -0
  6. package/dist/lib/classes/LLGLTFMaterialOverride.js.map +1 -0
  7. package/dist/lib/classes/ObjectStoreFull.js +86 -58
  8. package/dist/lib/classes/ObjectStoreFull.js.map +1 -1
  9. package/dist/lib/classes/ObjectStoreLite.d.ts +38 -15
  10. package/dist/lib/classes/ObjectStoreLite.js +229 -116
  11. package/dist/lib/classes/ObjectStoreLite.js.map +1 -1
  12. package/dist/lib/classes/TextureEntry.d.ts +2 -0
  13. package/dist/lib/classes/TextureEntry.js +1 -0
  14. package/dist/lib/classes/TextureEntry.js.map +1 -1
  15. package/dist/lib/classes/commands/CommunicationsCommands.js +21 -0
  16. package/dist/lib/classes/commands/CommunicationsCommands.js.map +1 -1
  17. package/dist/lib/classes/commands/FriendCommands.js +3 -0
  18. package/dist/lib/classes/commands/FriendCommands.js.map +1 -1
  19. package/dist/lib/classes/commands/GroupCommands.js +9 -0
  20. package/dist/lib/classes/commands/GroupCommands.js.map +1 -1
  21. package/dist/lib/classes/llsd/LLSDArray.d.ts +5 -0
  22. package/dist/lib/classes/llsd/LLSDArray.js +45 -0
  23. package/dist/lib/classes/llsd/LLSDArray.js.map +1 -0
  24. package/dist/lib/classes/llsd/LLSDMap.d.ts +10 -0
  25. package/dist/lib/classes/llsd/LLSDMap.js +94 -0
  26. package/dist/lib/classes/llsd/LLSDMap.js.map +1 -0
  27. package/dist/lib/classes/llsd/LLSDNotationParser.d.ts +9 -0
  28. package/dist/lib/classes/llsd/LLSDNotationParser.js +174 -0
  29. package/dist/lib/classes/llsd/LLSDNotationParser.js.map +1 -0
  30. package/dist/lib/classes/llsd/LLSDNotationParser.spec.d.ts +1 -0
  31. package/dist/lib/classes/llsd/LLSDNotationParser.spec.js +167 -0
  32. package/dist/lib/classes/llsd/LLSDNotationParser.spec.js.map +1 -0
  33. package/dist/lib/classes/llsd/LLSDObject.d.ts +4 -0
  34. package/dist/lib/classes/llsd/LLSDObject.js +10 -0
  35. package/dist/lib/classes/llsd/LLSDObject.js.map +1 -0
  36. package/dist/lib/classes/llsd/LLSDToken.d.ts +10 -0
  37. package/dist/lib/classes/llsd/LLSDToken.js +3 -0
  38. package/dist/lib/classes/llsd/LLSDToken.js.map +1 -0
  39. package/dist/lib/classes/llsd/LLSDTokenContainer.d.ts +7 -0
  40. package/dist/lib/classes/llsd/LLSDTokenContainer.js +3 -0
  41. package/dist/lib/classes/llsd/LLSDTokenContainer.js.map +1 -0
  42. package/dist/lib/classes/llsd/LLSDTokenGenerator.d.ts +2 -0
  43. package/dist/lib/classes/llsd/LLSDTokenGenerator.js +3 -0
  44. package/dist/lib/classes/llsd/LLSDTokenGenerator.js.map +1 -0
  45. package/dist/lib/classes/llsd/LLSDTokenSpec.d.ts +5 -0
  46. package/dist/lib/classes/llsd/LLSDTokenSpec.js +3 -0
  47. package/dist/lib/classes/llsd/LLSDTokenSpec.js.map +1 -0
  48. package/dist/lib/classes/llsd/LLSDTokenType.d.ts +22 -0
  49. package/dist/lib/classes/llsd/LLSDTokenType.js +27 -0
  50. package/dist/lib/classes/llsd/LLSDTokenType.js.map +1 -0
  51. package/dist/lib/classes/llsd/LLSDType.d.ts +4 -0
  52. package/dist/lib/classes/llsd/LLSDType.js +3 -0
  53. package/dist/lib/classes/llsd/LLSDType.js.map +1 -0
  54. package/dist/lib/classes/public/GameObject.js +161 -2
  55. package/dist/lib/classes/public/GameObject.js.map +1 -1
  56. package/dist/lib/classes/public/GameObject.spec.d.ts +1 -0
  57. package/dist/lib/classes/public/GameObject.spec.js +148 -0
  58. package/dist/lib/classes/public/GameObject.spec.js.map +1 -0
  59. package/dist/lib/classes/python/PythonDict.js +6 -2
  60. package/dist/lib/classes/python/PythonDict.js.map +1 -1
  61. package/dist/lib/classes/python/PythonParser.js +5 -4
  62. package/dist/lib/classes/python/PythonParser.js.map +1 -1
  63. package/dist/lib/classes/python/PythonParser.spec.js +8 -0
  64. package/dist/lib/classes/python/PythonParser.spec.js.map +1 -1
  65. package/dist/lib/classes/python/PythonSet.js +2 -0
  66. package/dist/lib/classes/python/PythonSet.js.map +1 -1
  67. package/dist/lib/classes/python/PythonTokenType.js +2 -2
  68. package/dist/lib/classes/python/PythonTokenType.js.map +1 -1
  69. package/package.json +1 -1
@@ -33,21 +33,24 @@ const CompressedFlags_1 = require("../enums/CompressedFlags");
33
33
  const Vector3_1 = require("./Vector3");
34
34
  const ObjectResolvedEvent_1 = require("../events/ObjectResolvedEvent");
35
35
  const Avatar_1 = require("./public/Avatar");
36
- const PythonParser_1 = require("./python/PythonParser");
37
- const PythonDict_1 = require("./python/PythonDict");
38
- const PythonList_1 = require("./python/PythonList");
36
+ const LLSDNotationParser_1 = require("./llsd/LLSDNotationParser");
37
+ const LLSDMap_1 = require("./llsd/LLSDMap");
38
+ const LLGLTFMaterialOverride_1 = require("./LLGLTFMaterialOverride");
39
39
  class ObjectStoreLite {
40
40
  constructor(circuit, agent, clientEvents, options) {
41
- this.objects = {};
42
- this.objectsByUUID = {};
43
- this.objectsByParent = {};
44
- this.requestedObjects = {};
41
+ this.objects = new Map();
42
+ this.objectsByUUID = new Map();
43
+ this.objectsByParent = new Map();
44
+ this.fullStore = false;
45
+ this.requestedObjects = new Set();
45
46
  this.deadObjects = [];
46
47
  this.persist = false;
47
- this.pendingObjectProperties = {};
48
- this.selectedPrimsWithoutUpdate = {};
48
+ this.cachedMaterialOverrides = new Map();
49
+ this.pendingObjectProperties = new Map;
50
+ this.selectedPrimsWithoutUpdate = new Map();
49
51
  agent.localID = 0;
50
52
  this.options = options;
53
+ this.fullStore = false;
51
54
  this.clientEvents = clientEvents;
52
55
  this.circuit = circuit;
53
56
  this.agent = agent;
@@ -63,14 +66,102 @@ class ObjectStoreLite {
63
66
  switch (packet.message.id) {
64
67
  case Message_1.Message.GenericStreamingMessage:
65
68
  {
69
+ if (!this.fullStore) {
70
+ return;
71
+ }
66
72
  const genMsg = packet.message;
67
73
  if (genMsg.MethodData.Method === 0x4175) {
68
- const result = PythonParser_1.PythonParser.parse(genMsg.DataBlock.Data.toString('utf-8'));
69
- if (result instanceof PythonDict_1.PythonDict) {
70
- const arr = result.get('te');
71
- if (arr instanceof PythonList_1.PythonList) {
72
- if (arr.length === 0) {
73
- return;
74
+ const result = LLSDNotationParser_1.LLSDNotationParser.parse(genMsg.DataBlock.Data.toString('utf-8'));
75
+ if (result instanceof LLSDMap_1.LLSDMap) {
76
+ const localID = result.get('id');
77
+ if (typeof localID !== 'number') {
78
+ return;
79
+ }
80
+ const tes = result.get('te');
81
+ const ods = result.get('od');
82
+ const overrides = new Map();
83
+ if (Array.isArray(tes) && Array.isArray(ods) && tes.length === ods.length) {
84
+ for (let x = 0; x < tes.length; x++) {
85
+ const te = tes[x];
86
+ if (typeof te !== 'number') {
87
+ continue;
88
+ }
89
+ const params = ods[x];
90
+ if (!(params instanceof LLSDMap_1.LLSDMap)) {
91
+ continue;
92
+ }
93
+ const textureIDs = params.get('tex');
94
+ const baseColor = params.get('bc');
95
+ const emissiveColor = params.get('ec');
96
+ const metallicFactor = params.get('mf');
97
+ const roughnessFactor = params.get('rf');
98
+ const alphaMode = params.get('am');
99
+ const alphaCutoff = params.get('ac');
100
+ const doubleSided = params.get('ds');
101
+ const textureTransforms = params.get('ti');
102
+ const override = new LLGLTFMaterialOverride_1.LLGLTFMaterialOverride();
103
+ overrides.set(te, override);
104
+ if (textureIDs !== undefined && Array.isArray(textureIDs) && textureIDs.length === 4) {
105
+ override.textures = [];
106
+ for (const tex of textureIDs) {
107
+ if (typeof tex === 'string') {
108
+ override.textures.push(tex);
109
+ }
110
+ else if (tex instanceof UUID_1.UUID) {
111
+ override.textures.push(tex.toString());
112
+ }
113
+ }
114
+ }
115
+ function isNumberArray(array) {
116
+ return array.every(element => typeof element === 'number');
117
+ }
118
+ if (baseColor !== undefined && Array.isArray(baseColor) && baseColor.length === 4 && isNumberArray(baseColor)) {
119
+ override.baseColor = baseColor;
120
+ }
121
+ if (emissiveColor !== undefined && Array.isArray(emissiveColor) && emissiveColor.length === 3 && isNumberArray(emissiveColor)) {
122
+ override.emissiveColor = emissiveColor;
123
+ }
124
+ if (metallicFactor !== undefined && typeof metallicFactor === 'number') {
125
+ override.metallicFactor = metallicFactor;
126
+ }
127
+ if (roughnessFactor !== undefined && typeof roughnessFactor === 'number') {
128
+ override.roughnessFactor = roughnessFactor;
129
+ }
130
+ if (alphaMode !== undefined && typeof alphaMode === 'number') {
131
+ override.alphaMode = alphaMode;
132
+ }
133
+ if (alphaCutoff !== undefined && typeof alphaCutoff === 'number') {
134
+ override.alphaCutoff = alphaCutoff;
135
+ }
136
+ if (doubleSided !== undefined && typeof doubleSided === 'boolean') {
137
+ override.doubleSided = doubleSided;
138
+ }
139
+ function isLLGLTFTextureTransformOverride(objToCheck) {
140
+ const isArrayOfNumbers = (value) => {
141
+ return Array.isArray(value) && value.every(item => typeof item === 'number');
142
+ };
143
+ return (typeof objToCheck === 'object' &&
144
+ objToCheck !== null &&
145
+ 'offset' in objToCheck && isArrayOfNumbers(objToCheck.offset) &&
146
+ 'scale' in objToCheck && isArrayOfNumbers(objToCheck.scale) &&
147
+ 'rotation' in objToCheck && typeof objToCheck.rotation === 'number');
148
+ }
149
+ if (textureTransforms !== undefined && Array.isArray(textureTransforms) && textureTransforms.length === 4) {
150
+ override.textureTransforms = [];
151
+ for (const transform of textureTransforms) {
152
+ if (isLLGLTFTextureTransformOverride(transform)) {
153
+ override.textureTransforms.push(transform);
154
+ }
155
+ }
156
+ }
157
+ }
158
+ const obj = this.objects.get(localID);
159
+ const textureEntry = obj === null || obj === void 0 ? void 0 : obj.TextureEntry;
160
+ if (textureEntry) {
161
+ textureEntry.gltfMaterialOverrides = overrides;
162
+ }
163
+ else {
164
+ this.cachedMaterialOverrides.set(localID, overrides);
74
165
  }
75
166
  }
76
167
  }
@@ -81,13 +172,13 @@ class ObjectStoreLite {
81
172
  {
82
173
  const objProp = packet.message;
83
174
  for (const obj of objProp.ObjectData) {
84
- const obje = this.objectsByUUID[obj.ObjectID.toString()];
85
- if (obje !== undefined && this.objects[obje] !== undefined) {
86
- const o = this.objects[obje];
175
+ const obje = this.objectsByUUID.get(obj.ObjectID.toString());
176
+ const o = this.objects.get(obje !== null && obje !== void 0 ? obje : 0);
177
+ if (obje !== undefined && o !== undefined) {
87
178
  this.applyObjectProperties(o, obj);
88
179
  }
89
180
  else {
90
- this.pendingObjectProperties[obj.ObjectID.toString()] = obj;
181
+ this.pendingObjectProperties.set(obj.ObjectID.toString(), obj);
91
182
  }
92
183
  }
93
184
  break;
@@ -125,12 +216,13 @@ class ObjectStoreLite {
125
216
  }
126
217
  }));
127
218
  this.physicsSubscription = this.clientEvents.onPhysicsDataEvent.subscribe((evt) => {
128
- if (this.objects[evt.localID]) {
129
- this.objects[evt.localID].physicsShapeType = evt.physicsShapeType;
130
- this.objects[evt.localID].density = evt.density;
131
- this.objects[evt.localID].restitution = evt.restitution;
132
- this.objects[evt.localID].gravityMultiplier = evt.gravityMultiplier;
133
- this.objects[evt.localID].friction = evt.friction;
219
+ const obj = this.objects.get(evt.localID);
220
+ if (obj) {
221
+ obj.physicsShapeType = evt.physicsShapeType;
222
+ obj.density = evt.density;
223
+ obj.restitution = evt.restitution;
224
+ obj.gravityMultiplier = evt.gravityMultiplier;
225
+ obj.friction = evt.friction;
134
226
  }
135
227
  });
136
228
  this.selectedChecker = setInterval(() => {
@@ -177,9 +269,7 @@ class ObjectStoreLite {
177
269
  }, 1000);
178
270
  }
179
271
  applyObjectProperties(o, obj) {
180
- if (this.selectedPrimsWithoutUpdate[o.ID]) {
181
- delete this.selectedPrimsWithoutUpdate[o.ID];
182
- }
272
+ this.selectedPrimsWithoutUpdate.delete(o.ID);
183
273
  o.creatorID = obj.CreatorID;
184
274
  o.creationDate = obj.CreationDate;
185
275
  o.baseMask = obj.BaseMask;
@@ -223,13 +313,13 @@ class ObjectStoreLite {
223
313
  }
224
314
  requestMissingObject(localID, attempt = 0) {
225
315
  return __awaiter(this, void 0, void 0, function* () {
226
- if (this.requestedObjects[localID]) {
316
+ if (this.requestedObjects.has(localID)) {
227
317
  return;
228
318
  }
229
319
  if (this.circuit === undefined) {
230
320
  return;
231
321
  }
232
- this.requestedObjects[localID] = true;
322
+ this.requestedObjects.add(localID);
233
323
  const rmo = new RequestMultipleObjects_1.RequestMultipleObjectsMessage();
234
324
  rmo.AgentData = {
235
325
  AgentID: this.agent.agentID,
@@ -261,10 +351,10 @@ class ObjectStoreLite {
261
351
  }
262
352
  return FilterResponse_1.FilterResponse.NoMatch;
263
353
  });
264
- delete this.requestedObjects[localID];
354
+ this.requestedObjects.delete(localID);
265
355
  }
266
356
  catch (error) {
267
- delete this.requestedObjects[localID];
357
+ this.requestedObjects.delete(localID);
268
358
  if (attempt < 5) {
269
359
  yield this.requestMissingObject(localID, ++attempt);
270
360
  }
@@ -299,52 +389,58 @@ class ObjectStoreLite {
299
389
  const parentID = objData.ParentID;
300
390
  let addToParentList = true;
301
391
  let newObject = false;
302
- if (this.objects[localID]) {
303
- if (this.objects[localID].ParentID !== parentID && this.objectsByParent[parentID]) {
304
- const ind = this.objectsByParent[parentID].indexOf(localID);
392
+ let obj = this.objects.get(localID);
393
+ if (obj) {
394
+ const p = this.objectsByParent.get(parentID);
395
+ if (obj.ParentID !== parentID && p !== undefined) {
396
+ const ind = p.indexOf(localID);
305
397
  if (ind !== -1) {
306
- this.objectsByParent[parentID].splice(ind, 1);
398
+ p.splice(ind, 1);
307
399
  }
308
400
  }
309
- else if (this.objectsByParent[parentID]) {
401
+ else if (p) {
310
402
  addToParentList = false;
311
403
  }
312
404
  }
313
405
  else {
314
406
  newObject = true;
315
- this.objects[localID] = new GameObject_1.GameObject();
316
- this.objects[localID].region = this.agent.currentRegion;
407
+ const newObj = new GameObject_1.GameObject();
408
+ newObj.region = this.agent.currentRegion;
409
+ this.objects.set(localID, newObj);
317
410
  }
318
- const obj = this.objects[localID];
411
+ obj = this.objects.get(localID);
319
412
  obj.deleted = false;
320
413
  obj.ID = objData.ID;
321
414
  obj.FullID = objData.FullID;
322
415
  obj.ParentID = objData.ParentID;
323
416
  obj.OwnerID = objData.OwnerID;
324
417
  obj.PCode = objData.PCode;
325
- this.objects[localID].NameValue = this.parseNameValues(Utils_1.Utils.BufferToStringSimple(objData.NameValue));
326
- this.objects[localID].IsAttachment = this.objects[localID].NameValue['AttachItemID'] !== undefined;
418
+ obj.NameValue = this.parseNameValues(Utils_1.Utils.BufferToStringSimple(objData.NameValue));
419
+ obj.IsAttachment = obj.NameValue.AttachItemID !== undefined;
327
420
  if (obj.IsAttachment && obj.State !== undefined) {
328
- this.objects[localID].attachmentPoint = this.decodeAttachPoint(obj.State);
421
+ obj.attachmentPoint = this.decodeAttachPoint(obj.State);
329
422
  }
330
- if (objData.PCode === PCode_1.PCode.Avatar && this.objects[localID].FullID.toString() === this.agent.agentID.toString()) {
423
+ if (objData.PCode === PCode_1.PCode.Avatar && obj.FullID.toString() === this.agent.agentID.toString()) {
331
424
  this.agent.localID = localID;
332
425
  if (this.options & BotOptionFlags_1.BotOptionFlags.StoreMyAttachmentsOnly) {
333
426
  for (const objParentID of Object.keys(this.objectsByParent)) {
334
427
  const parent = parseInt(objParentID, 10);
335
428
  if (parent !== this.agent.localID) {
336
429
  let foundAvatars = false;
337
- for (const objID of this.objectsByParent[parent]) {
338
- if (this.objects[objID]) {
339
- const o = this.objects[objID];
340
- if (o.PCode === PCode_1.PCode.Avatar) {
341
- foundAvatars = true;
430
+ const p = this.objectsByParent.get(parent);
431
+ if (p !== undefined) {
432
+ for (const objID of p) {
433
+ const childObj = this.objects.get(objID);
434
+ if (childObj) {
435
+ if (childObj.PCode === PCode_1.PCode.Avatar) {
436
+ foundAvatars = true;
437
+ }
342
438
  }
343
439
  }
344
440
  }
345
- if (this.objects[parent]) {
346
- const o = this.objects[parent];
347
- if (o.PCode === PCode_1.PCode.Avatar) {
441
+ const parentObj = this.objects.get(parent);
442
+ if (parentObj) {
443
+ if (parentObj.PCode === PCode_1.PCode.Avatar) {
348
444
  foundAvatars = true;
349
445
  }
350
446
  }
@@ -355,12 +451,14 @@ class ObjectStoreLite {
355
451
  }
356
452
  }
357
453
  }
358
- this.objectsByUUID[objData.FullID.toString()] = localID;
359
- if (!this.objectsByParent[parentID]) {
360
- this.objectsByParent[parentID] = [];
454
+ this.objectsByUUID.set(objData.FullID.toString(), localID);
455
+ let objByParent = this.objectsByParent.get(parentID);
456
+ if (!objByParent) {
457
+ objByParent = [];
458
+ this.objectsByParent.set(parentID, objByParent);
361
459
  }
362
460
  if (addToParentList) {
363
- this.objectsByParent[parentID].push(localID);
461
+ objByParent.push(localID);
364
462
  }
365
463
  if (objData.PCode !== PCode_1.PCode.Avatar && this.options & BotOptionFlags_1.BotOptionFlags.StoreMyAttachmentsOnly) {
366
464
  if (this.agent.localID !== 0 && obj.ParentID !== this.agent.localID) {
@@ -369,13 +467,13 @@ class ObjectStoreLite {
369
467
  }
370
468
  }
371
469
  this.notifyObjectUpdate(newObject, obj);
372
- if (objData.ParentID !== undefined && objData.ParentID !== 0 && !this.objects[objData.ParentID]) {
470
+ if (objData.ParentID !== undefined && objData.ParentID !== 0 && !this.objects.get(objData.ParentID)) {
373
471
  this.requestMissingObject(objData.ParentID);
374
472
  }
375
473
  }
376
474
  }
377
475
  notifyTerseUpdate(obj) {
378
- if (this.objects[obj.ID]) {
476
+ if (this.objects.get(obj.ID)) {
379
477
  if (obj.PCode === PCode_1.PCode.Avatar) {
380
478
  if (this.agent.currentRegion.agents[obj.FullID.toString()] !== undefined) {
381
479
  this.agent.currentRegion.agents[obj.FullID.toString()].processObjectUpdate(obj);
@@ -392,6 +490,7 @@ class ObjectStoreLite {
392
490
  }
393
491
  }
394
492
  notifyObjectUpdate(newObject, obj) {
493
+ var _a;
395
494
  if (obj.PCode === PCode_1.PCode.Avatar) {
396
495
  const avatarID = obj.FullID.toString();
397
496
  if (newObject) {
@@ -413,11 +512,12 @@ class ObjectStoreLite {
413
512
  }
414
513
  }
415
514
  }
416
- if (obj.ParentID === 0 || (obj.ParentID !== undefined && this.objects[obj.ParentID] !== undefined && this.objects[obj.ParentID].PCode === PCode_1.PCode.Avatar)) {
515
+ const parentObj = this.objects.get((_a = obj.ParentID) !== null && _a !== void 0 ? _a : 0);
516
+ if (obj.ParentID === 0 || (obj.ParentID !== undefined && parentObj !== undefined && parentObj.PCode === PCode_1.PCode.Avatar)) {
417
517
  if (newObject) {
418
518
  if (obj.IsAttachment && obj.ParentID !== undefined) {
419
- if (this.objects[obj.ParentID] !== undefined && this.objects[obj.ParentID].PCode === PCode_1.PCode.Avatar) {
420
- const avatar = this.agent.currentRegion.agents[this.objects[obj.ParentID].FullID.toString()];
519
+ if (parentObj !== undefined && parentObj.PCode === PCode_1.PCode.Avatar) {
520
+ const avatar = this.agent.currentRegion.agents[parentObj.FullID.toString()];
421
521
  let invItemID = UUID_1.UUID.zero();
422
522
  if (obj.NameValue['AttachItemID']) {
423
523
  invItemID = new UUID_1.UUID(obj.NameValue['AttachItemID'].value);
@@ -446,8 +546,8 @@ class ObjectStoreLite {
446
546
  newObj.object = obj;
447
547
  newObj.createSelected = obj.Flags !== undefined && (obj.Flags & PrimFlags_1.PrimFlags.CreateSelected) !== 0;
448
548
  obj.createdSelected = newObj.createSelected;
449
- if (obj.Flags !== undefined && obj.Flags & PrimFlags_1.PrimFlags.CreateSelected && !this.pendingObjectProperties[obj.FullID.toString()]) {
450
- this.selectedPrimsWithoutUpdate[obj.ID] = true;
549
+ if (obj.Flags !== undefined && obj.Flags & PrimFlags_1.PrimFlags.CreateSelected && !this.pendingObjectProperties.get(obj.FullID.toString())) {
550
+ this.selectedPrimsWithoutUpdate.set(obj.ID, true);
451
551
  }
452
552
  this.clientEvents.onNewObjectEvent.next(newObj);
453
553
  }
@@ -458,9 +558,10 @@ class ObjectStoreLite {
458
558
  updObj.object = obj;
459
559
  this.clientEvents.onObjectUpdatedEvent.next(updObj);
460
560
  }
461
- if (this.pendingObjectProperties[obj.FullID.toString()]) {
462
- this.applyObjectProperties(obj, this.pendingObjectProperties[obj.FullID.toString()]);
463
- delete this.pendingObjectProperties[obj.FullID.toString()];
561
+ const pendingProp = this.pendingObjectProperties.get(obj.FullID.toString());
562
+ if (pendingProp) {
563
+ this.applyObjectProperties(obj, pendingProp);
564
+ this.pendingObjectProperties.delete(obj.FullID.toString());
464
565
  }
465
566
  }
466
567
  }
@@ -491,17 +592,17 @@ class ObjectStoreLite {
491
592
  const localID = buf.readUInt32LE(pos);
492
593
  pos += 4;
493
594
  const pcode = buf.readUInt8(pos++);
494
- let newObj = false;
495
- if (!this.objects[localID]) {
496
- newObj = true;
497
- this.objects[localID] = new GameObject_1.GameObject();
498
- this.objects[localID].region = this.agent.currentRegion;
595
+ const newObj = false;
596
+ let o = this.objects.get(localID);
597
+ if (!o) {
598
+ o = new GameObject_1.GameObject();
599
+ o.region = this.agent.currentRegion;
600
+ this.objects.set(localID, o);
499
601
  }
500
- const o = this.objects[localID];
501
602
  o.deleted = false;
502
603
  o.ID = localID;
503
604
  o.PCode = pcode;
504
- this.objectsByUUID[fullID.toString()] = localID;
605
+ this.objectsByUUID.set(fullID.toString(), localID);
505
606
  o.FullID = fullID;
506
607
  pos++;
507
608
  pos = pos + 42;
@@ -520,21 +621,24 @@ class ObjectStoreLite {
520
621
  o.ParentID = newParentID;
521
622
  let add = true;
522
623
  if (!newObj && o.ParentID !== undefined) {
523
- if (newParentID !== o.ParentID) {
524
- const index = this.objectsByParent[o.ParentID].indexOf(localID);
525
- if (index !== -1) {
526
- this.objectsByParent[o.ParentID].splice(index, 1);
624
+ const p = this.objectsByParent.get(o.ParentID);
625
+ if (newParentID !== o.ParentID && p) {
626
+ const ind = p.indexOf(localID);
627
+ if (ind !== -1) {
628
+ p.splice(ind, 1);
527
629
  }
528
630
  }
529
- else if (this.objectsByParent[o.ParentID]) {
631
+ else if (p) {
530
632
  add = false;
531
633
  }
532
634
  }
533
635
  if (add) {
534
- if (!this.objectsByParent[newParentID]) {
535
- this.objectsByParent[newParentID] = [];
636
+ let objByParent = this.objectsByParent.get(newParentID);
637
+ if (!objByParent) {
638
+ objByParent = [];
639
+ this.objectsByParent.set(newParentID, objByParent);
536
640
  }
537
- this.objectsByParent[newParentID].push(localID);
641
+ objByParent.push(localID);
538
642
  }
539
643
  if (pcode !== PCode_1.PCode.Avatar && newObj && this.options & BotOptionFlags_1.BotOptionFlags.StoreMyAttachmentsOnly) {
540
644
  if (this.agent.localID !== 0 && o.ParentID !== this.agent.localID) {
@@ -542,8 +646,10 @@ class ObjectStoreLite {
542
646
  return;
543
647
  }
544
648
  }
545
- if (o.ParentID !== undefined && o.ParentID !== 0 && !this.objects[o.ParentID]) {
546
- this.requestMissingObject(o.ParentID);
649
+ if (o.ParentID !== undefined && o.ParentID !== 0 && !this.objects.has(o.ParentID)) {
650
+ this.requestMissingObject(o.ParentID).catch((e) => {
651
+ console.error(e);
652
+ });
547
653
  }
548
654
  if (compressedflags & CompressedFlags_1.CompressedFlags.Tree) {
549
655
  pos++;
@@ -599,7 +705,7 @@ class ObjectStoreLite {
599
705
  killObject(killObj) {
600
706
  for (const obj of killObj.ObjectData) {
601
707
  const objectID = obj.ID;
602
- if (this.objects[objectID]) {
708
+ if (this.objects.has(objectID)) {
603
709
  this.deleteObject(objectID);
604
710
  }
605
711
  }
@@ -615,56 +721,59 @@ class ObjectStoreLite {
615
721
  }
616
722
  deleteObject(objectID) {
617
723
  var _a;
618
- if (this.objects[objectID]) {
619
- const objectUUID = this.objects[objectID].FullID;
620
- const obj = this.objects[objectID];
724
+ const obj = this.objects.get(objectID);
725
+ if (obj) {
726
+ const objectUUID = obj.FullID;
621
727
  obj.deleted = true;
622
728
  if (this.persist) {
623
729
  this.deadObjects.push(objectID);
624
730
  return;
625
731
  }
626
732
  if (obj.IsAttachment && obj.ParentID !== undefined) {
627
- if (this.objects[obj.ParentID] !== undefined && this.objects[obj.ParentID].PCode === PCode_1.PCode.Avatar) {
628
- (_a = this.agent.currentRegion.agents[this.objects[obj.ParentID].FullID.toString()]) === null || _a === void 0 ? void 0 : _a.removeAttachment(obj);
733
+ const parent = this.objects.get(obj.ParentID);
734
+ if (parent !== undefined && parent.PCode === PCode_1.PCode.Avatar) {
735
+ (_a = this.agent.currentRegion.agents[parent.FullID.toString()]) === null || _a === void 0 ? void 0 : _a.removeAttachment(obj);
629
736
  }
630
737
  }
631
738
  if (this.agent.currentRegion.agents[objectUUID.toString()] !== undefined) {
632
739
  this.agent.currentRegion.agents[objectUUID.toString()].isVisible = false;
633
740
  }
634
- if (this.objectsByParent[objectID]) {
635
- for (const childObjID of this.objectsByParent[objectID]) {
741
+ const objsByParent = this.objectsByParent.get(objectID);
742
+ if (objsByParent) {
743
+ for (const childObjID of objsByParent) {
636
744
  this.deleteObject(childObjID);
637
745
  }
638
746
  }
639
- delete this.objectsByParent[objectID];
747
+ this.objectsByParent.delete(objectID);
640
748
  const uuid = obj.FullID.toString();
641
- if (this.objectsByUUID[uuid]) {
642
- delete this.objectsByUUID[uuid];
643
- }
749
+ this.objectsByUUID.delete(uuid);
644
750
  if (obj.ParentID !== undefined) {
645
751
  const parentID = obj.ParentID;
646
- if (this.objectsByParent[parentID]) {
647
- const ind = this.objectsByParent[parentID].indexOf(objectID);
752
+ const objsByParentParent = this.objectsByParent.get(parentID);
753
+ if (objsByParentParent) {
754
+ const ind = objsByParentParent.indexOf(objectID);
648
755
  if (ind !== -1) {
649
- this.objectsByParent[parentID].splice(ind, 1);
756
+ objsByParentParent.splice(ind, 1);
650
757
  }
651
758
  }
652
759
  }
653
760
  if (this.rtree && obj.rtreeEntry !== undefined) {
654
761
  this.rtree.remove(obj.rtreeEntry);
655
762
  }
656
- delete this.objects[objectID];
763
+ this.objects.delete(objectID);
764
+ this.cachedMaterialOverrides.delete(objectID);
657
765
  }
658
766
  }
659
767
  getObjectsByParent(parentID) {
660
- const list = this.objectsByParent[parentID];
768
+ const list = this.objectsByParent.get(parentID);
661
769
  if (list === undefined) {
662
770
  return [];
663
771
  }
664
772
  const result = [];
665
773
  for (const localID of list) {
666
- if (this.objects[localID]) {
667
- result.push(this.objects[localID]);
774
+ const obj = this.objects.get(localID);
775
+ if (obj) {
776
+ result.push(obj);
668
777
  }
669
778
  }
670
779
  result.sort((a, b) => {
@@ -702,20 +811,22 @@ class ObjectStoreLite {
702
811
  delete this.selectedChecker;
703
812
  }
704
813
  this.physicsSubscription.unsubscribe();
705
- this.objects = {};
814
+ this.objects.clear();
706
815
  if (this.rtree) {
707
816
  this.rtree.clear();
708
817
  }
709
- this.objectsByUUID = {};
710
- this.objectsByParent = {};
818
+ this.objectsByUUID.clear();
819
+ this.objectsByParent.clear();
711
820
  delete this.circuit;
712
821
  }
713
822
  findParent(go) {
714
- if (go.ParentID !== undefined && go.ParentID !== 0 && this.objects[go.ParentID]) {
715
- return this.findParent(this.objects[go.ParentID]);
823
+ var _a;
824
+ const parentObj = this.objects.get((_a = go.ParentID) !== null && _a !== void 0 ? _a : 0);
825
+ if (go.ParentID !== undefined && go.ParentID !== 0 && parentObj) {
826
+ return this.findParent(parentObj);
716
827
  }
717
828
  else {
718
- if (go.ParentID !== undefined && go.ParentID !== 0 && !this.objects[go.ParentID]) {
829
+ if (go.ParentID !== undefined && go.ParentID !== 0 && !parentObj) {
719
830
  this.requestMissingObject(go.ParentID).catch((e) => {
720
831
  Logger_1.Logger.Error(e);
721
832
  });
@@ -743,9 +854,9 @@ class ObjectStoreLite {
743
854
  return __awaiter(this, void 0, void 0, function* () {
744
855
  const results = [];
745
856
  const found = {};
746
- for (const k of Object.keys(this.objects)) {
747
- const go = this.objects[parseInt(k, 10)];
748
- if (go.PCode !== PCode_1.PCode.Avatar && (go.IsAttachment === undefined || !go.IsAttachment)) {
857
+ for (const localID of this.objects.keys()) {
858
+ const go = this.objects.get(localID);
859
+ if (go && go.PCode !== PCode_1.PCode.Avatar && (go.IsAttachment === undefined || !go.IsAttachment)) {
749
860
  try {
750
861
  const parent = this.findParent(go);
751
862
  if (parent.ParentID === 0) {
@@ -816,17 +927,19 @@ class ObjectStoreLite {
816
927
  if (fullID instanceof UUID_1.UUID) {
817
928
  fullID = fullID.toString();
818
929
  }
819
- if (!this.objectsByUUID[fullID]) {
930
+ const localID = this.objectsByUUID.get(fullID);
931
+ const go = this.objects.get(localID !== null && localID !== void 0 ? localID : 0);
932
+ if (localID === undefined || go === undefined) {
820
933
  throw new Error('No object found with that UUID');
821
934
  }
822
- const localID = this.objectsByUUID[fullID];
823
- return this.objects[localID];
935
+ return go;
824
936
  }
825
937
  getObjectByLocalID(localID) {
826
- if (!this.objects[localID]) {
938
+ const go = this.objects.get(localID);
939
+ if (!go) {
827
940
  throw new Error('No object found with that UUID');
828
941
  }
829
- return this.objects[localID];
942
+ return go;
830
943
  }
831
944
  insertIntoRtree(obj) {
832
945
  if (!this.rtree) {