@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.
- package/dist/lib/classes/LLGLTFMaterial.spec.js +47 -17
- package/dist/lib/classes/LLGLTFMaterial.spec.js.map +1 -1
- package/dist/lib/classes/LLGLTFMaterialData.d.ts +180 -21
- package/dist/lib/classes/LLGLTFMaterialOverride.d.ts +16 -0
- package/dist/lib/classes/LLGLTFMaterialOverride.js +7 -0
- package/dist/lib/classes/LLGLTFMaterialOverride.js.map +1 -0
- package/dist/lib/classes/ObjectStoreFull.js +86 -58
- package/dist/lib/classes/ObjectStoreFull.js.map +1 -1
- package/dist/lib/classes/ObjectStoreLite.d.ts +38 -15
- package/dist/lib/classes/ObjectStoreLite.js +229 -116
- package/dist/lib/classes/ObjectStoreLite.js.map +1 -1
- package/dist/lib/classes/TextureEntry.d.ts +2 -0
- package/dist/lib/classes/TextureEntry.js +1 -0
- package/dist/lib/classes/TextureEntry.js.map +1 -1
- package/dist/lib/classes/commands/CommunicationsCommands.js +21 -0
- package/dist/lib/classes/commands/CommunicationsCommands.js.map +1 -1
- package/dist/lib/classes/commands/FriendCommands.js +3 -0
- package/dist/lib/classes/commands/FriendCommands.js.map +1 -1
- package/dist/lib/classes/commands/GroupCommands.js +9 -0
- package/dist/lib/classes/commands/GroupCommands.js.map +1 -1
- package/dist/lib/classes/llsd/LLSDArray.d.ts +5 -0
- package/dist/lib/classes/llsd/LLSDArray.js +45 -0
- package/dist/lib/classes/llsd/LLSDArray.js.map +1 -0
- package/dist/lib/classes/llsd/LLSDMap.d.ts +10 -0
- package/dist/lib/classes/llsd/LLSDMap.js +94 -0
- package/dist/lib/classes/llsd/LLSDMap.js.map +1 -0
- package/dist/lib/classes/llsd/LLSDNotationParser.d.ts +9 -0
- package/dist/lib/classes/llsd/LLSDNotationParser.js +174 -0
- package/dist/lib/classes/llsd/LLSDNotationParser.js.map +1 -0
- package/dist/lib/classes/llsd/LLSDNotationParser.spec.d.ts +1 -0
- package/dist/lib/classes/llsd/LLSDNotationParser.spec.js +167 -0
- package/dist/lib/classes/llsd/LLSDNotationParser.spec.js.map +1 -0
- package/dist/lib/classes/llsd/LLSDObject.d.ts +4 -0
- package/dist/lib/classes/llsd/LLSDObject.js +10 -0
- package/dist/lib/classes/llsd/LLSDObject.js.map +1 -0
- package/dist/lib/classes/llsd/LLSDToken.d.ts +10 -0
- package/dist/lib/classes/llsd/LLSDToken.js +3 -0
- package/dist/lib/classes/llsd/LLSDToken.js.map +1 -0
- package/dist/lib/classes/llsd/LLSDTokenContainer.d.ts +7 -0
- package/dist/lib/classes/llsd/LLSDTokenContainer.js +3 -0
- package/dist/lib/classes/llsd/LLSDTokenContainer.js.map +1 -0
- package/dist/lib/classes/llsd/LLSDTokenGenerator.d.ts +2 -0
- package/dist/lib/classes/llsd/LLSDTokenGenerator.js +3 -0
- package/dist/lib/classes/llsd/LLSDTokenGenerator.js.map +1 -0
- package/dist/lib/classes/llsd/LLSDTokenSpec.d.ts +5 -0
- package/dist/lib/classes/llsd/LLSDTokenSpec.js +3 -0
- package/dist/lib/classes/llsd/LLSDTokenSpec.js.map +1 -0
- package/dist/lib/classes/llsd/LLSDTokenType.d.ts +22 -0
- package/dist/lib/classes/llsd/LLSDTokenType.js +27 -0
- package/dist/lib/classes/llsd/LLSDTokenType.js.map +1 -0
- package/dist/lib/classes/llsd/LLSDType.d.ts +4 -0
- package/dist/lib/classes/llsd/LLSDType.js +3 -0
- package/dist/lib/classes/llsd/LLSDType.js.map +1 -0
- package/dist/lib/classes/public/GameObject.js +161 -2
- package/dist/lib/classes/public/GameObject.js.map +1 -1
- package/dist/lib/classes/public/GameObject.spec.d.ts +1 -0
- package/dist/lib/classes/public/GameObject.spec.js +148 -0
- package/dist/lib/classes/public/GameObject.spec.js.map +1 -0
- package/dist/lib/classes/python/PythonDict.js +6 -2
- package/dist/lib/classes/python/PythonDict.js.map +1 -1
- package/dist/lib/classes/python/PythonParser.js +5 -4
- package/dist/lib/classes/python/PythonParser.js.map +1 -1
- package/dist/lib/classes/python/PythonParser.spec.js +8 -0
- package/dist/lib/classes/python/PythonParser.spec.js.map +1 -1
- package/dist/lib/classes/python/PythonSet.js +2 -0
- package/dist/lib/classes/python/PythonSet.js.map +1 -1
- package/dist/lib/classes/python/PythonTokenType.js +2 -2
- package/dist/lib/classes/python/PythonTokenType.js.map +1 -1
- 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
|
|
37
|
-
const
|
|
38
|
-
const
|
|
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.
|
|
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.
|
|
48
|
-
this.
|
|
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 =
|
|
69
|
-
if (result instanceof
|
|
70
|
-
const
|
|
71
|
-
if (
|
|
72
|
-
|
|
73
|
-
|
|
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
|
|
85
|
-
|
|
86
|
-
|
|
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
|
|
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
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
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
|
-
|
|
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
|
|
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
|
|
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
|
-
|
|
354
|
+
this.requestedObjects.delete(localID);
|
|
265
355
|
}
|
|
266
356
|
catch (error) {
|
|
267
|
-
|
|
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
|
-
|
|
303
|
-
|
|
304
|
-
|
|
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
|
-
|
|
398
|
+
p.splice(ind, 1);
|
|
307
399
|
}
|
|
308
400
|
}
|
|
309
|
-
else if (
|
|
401
|
+
else if (p) {
|
|
310
402
|
addToParentList = false;
|
|
311
403
|
}
|
|
312
404
|
}
|
|
313
405
|
else {
|
|
314
406
|
newObject = true;
|
|
315
|
-
|
|
316
|
-
|
|
407
|
+
const newObj = new GameObject_1.GameObject();
|
|
408
|
+
newObj.region = this.agent.currentRegion;
|
|
409
|
+
this.objects.set(localID, newObj);
|
|
317
410
|
}
|
|
318
|
-
|
|
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
|
-
|
|
326
|
-
|
|
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
|
-
|
|
421
|
+
obj.attachmentPoint = this.decodeAttachPoint(obj.State);
|
|
329
422
|
}
|
|
330
|
-
if (objData.PCode === PCode_1.PCode.Avatar &&
|
|
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
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
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
|
-
|
|
346
|
-
|
|
347
|
-
if (
|
|
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
|
|
359
|
-
|
|
360
|
-
|
|
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
|
-
|
|
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
|
|
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
|
|
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
|
-
|
|
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 (
|
|
420
|
-
const avatar = this.agent.currentRegion.agents[
|
|
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
|
|
450
|
-
this.selectedPrimsWithoutUpdate
|
|
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
|
-
|
|
462
|
-
|
|
463
|
-
|
|
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
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
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
|
|
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
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
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 (
|
|
631
|
+
else if (p) {
|
|
530
632
|
add = false;
|
|
531
633
|
}
|
|
532
634
|
}
|
|
533
635
|
if (add) {
|
|
534
|
-
|
|
535
|
-
|
|
636
|
+
let objByParent = this.objectsByParent.get(newParentID);
|
|
637
|
+
if (!objByParent) {
|
|
638
|
+
objByParent = [];
|
|
639
|
+
this.objectsByParent.set(newParentID, objByParent);
|
|
536
640
|
}
|
|
537
|
-
|
|
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
|
|
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
|
|
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
|
-
|
|
619
|
-
|
|
620
|
-
const
|
|
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
|
-
|
|
628
|
-
|
|
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
|
-
|
|
635
|
-
|
|
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
|
-
|
|
747
|
+
this.objectsByParent.delete(objectID);
|
|
640
748
|
const uuid = obj.FullID.toString();
|
|
641
|
-
|
|
642
|
-
delete this.objectsByUUID[uuid];
|
|
643
|
-
}
|
|
749
|
+
this.objectsByUUID.delete(uuid);
|
|
644
750
|
if (obj.ParentID !== undefined) {
|
|
645
751
|
const parentID = obj.ParentID;
|
|
646
|
-
|
|
647
|
-
|
|
752
|
+
const objsByParentParent = this.objectsByParent.get(parentID);
|
|
753
|
+
if (objsByParentParent) {
|
|
754
|
+
const ind = objsByParentParent.indexOf(objectID);
|
|
648
755
|
if (ind !== -1) {
|
|
649
|
-
|
|
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
|
-
|
|
763
|
+
this.objects.delete(objectID);
|
|
764
|
+
this.cachedMaterialOverrides.delete(objectID);
|
|
657
765
|
}
|
|
658
766
|
}
|
|
659
767
|
getObjectsByParent(parentID) {
|
|
660
|
-
const list = this.objectsByParent
|
|
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
|
-
|
|
667
|
-
|
|
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
|
-
|
|
715
|
-
|
|
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 && !
|
|
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
|
|
747
|
-
const go = this.objects
|
|
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
|
-
|
|
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
|
-
|
|
823
|
-
return this.objects[localID];
|
|
935
|
+
return go;
|
|
824
936
|
}
|
|
825
937
|
getObjectByLocalID(localID) {
|
|
826
|
-
|
|
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
|
|
942
|
+
return go;
|
|
830
943
|
}
|
|
831
944
|
insertIntoRtree(obj) {
|
|
832
945
|
if (!this.rtree) {
|