|
@ -94,10 +94,12 @@ export class ItemManager { |
|
|
itemDef.model, |
|
|
itemDef.model, |
|
|
itemDef.texture, |
|
|
itemDef.texture, |
|
|
[], // spawnedObjects placeholder
|
|
|
[], // spawnedObjects placeholder
|
|
|
contentObject // The created content object
|
|
|
contentObject |
|
|
); |
|
|
); |
|
|
|
|
|
|
|
|
newItem.id = itemDef.id; |
|
|
newItem.id = itemDef.id; |
|
|
|
|
|
|
|
|
|
|
|
// Set links
|
|
|
if (itemDef.links) { |
|
|
if (itemDef.links) { |
|
|
newItem.links = itemDef.links; |
|
|
newItem.links = itemDef.links; |
|
|
} |
|
|
} |
|
@ -106,6 +108,7 @@ export class ItemManager { |
|
|
this.interactableItems.push(newItem); |
|
|
this.interactableItems.push(newItem); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Setting a key and value pair in the Map (id, item)
|
|
|
this.itemData.set(itemDef.id, newItem); |
|
|
this.itemData.set(itemDef.id, newItem); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
@ -113,15 +116,16 @@ export class ItemManager { |
|
|
_createLinkLines() { |
|
|
_createLinkLines() { |
|
|
|
|
|
|
|
|
this.itemData.forEach(item => { |
|
|
this.itemData.forEach(item => { |
|
|
console.log(item.id) |
|
|
|
|
|
|
|
|
|
|
|
if (!item.links) return; |
|
|
if (!item.links) return; |
|
|
|
|
|
|
|
|
item.links.forEach(linkedItemId => { |
|
|
item.links.forEach(linkedItemId => { |
|
|
|
|
|
// Goes through each connection; links = [0, 1, 2..]
|
|
|
const linkedItem = this.itemData.get(linkedItemId); |
|
|
const linkedItem = this.itemData.get(linkedItemId); |
|
|
if (!linkedItem) return; |
|
|
if (!linkedItem) return; |
|
|
|
|
|
|
|
|
|
|
|
// Creates a key for the Set; a Set can only have unique values, so used for no overlap
|
|
|
const key = [item.id, linkedItemId].sort().join('-'); |
|
|
const key = [item.id, linkedItemId].sort().join('-'); |
|
|
|
|
|
|
|
|
if (this.drawnLinks.has(key)) return; |
|
|
if (this.drawnLinks.has(key)) return; |
|
|
|
|
|
|
|
|
const material = new THREE.LineDashedMaterial({ |
|
|
const material = new THREE.LineDashedMaterial({ |
|
@ -141,7 +145,10 @@ export class ItemManager { |
|
|
line.computeLineDistances(); |
|
|
line.computeLineDistances(); |
|
|
|
|
|
|
|
|
this.scene.add(line); |
|
|
this.scene.add(line); |
|
|
|
|
|
|
|
|
|
|
|
// The Set is used as the key "0-1", then the item and the linkedItem are set as values in the Map?
|
|
|
this.linkLines.set(key, { line, item1: item, item2: linkedItem }); |
|
|
this.linkLines.set(key, { line, item1: item, item2: linkedItem }); |
|
|
|
|
|
// Make sure it is not drawn again, adding the unique pair here
|
|
|
this.drawnLinks.add(key); |
|
|
this.drawnLinks.add(key); |
|
|
}); |
|
|
}); |
|
|
}); |
|
|
}); |
|
|