0
0
mirror of https://github.com/Doodle3D/Doodle3D-API synced 2024-11-14 16:27:56 +01:00

added boxes changed event

This commit is contained in:
casperlamboo 2016-04-21 15:17:38 +02:00
parent 65088708bd
commit 50167a686a

View File

@ -58,14 +58,22 @@ export default class Doodle3DManager extends EventDispatcher {
const newBoxes = boxes.filter(box => knownIPsClient.indexOf(box.localip) === -1); const newBoxes = boxes.filter(box => knownIPsClient.indexOf(box.localip) === -1);
const removedBoxes = this.boxes.filter(box => knownIPsServer.indexOf(box.boxData.localip) === -1); const removedBoxes = this.boxes.filter(box => knownIPsServer.indexOf(box.boxData.localip) === -1);
let changed = false;
for (const boxData of newBoxes) { for (const boxData of newBoxes) {
const box = new Doodle3DAPI(boxData); const box = new Doodle3DAPI(boxData);
this._addBox(box); this._addBox(box);
changed = true;
} }
for (const box of removedBoxes) { for (const box of removedBoxes) {
this._removeBox(box); this._removeBox(box);
changed = true;
}
if (changed) {
this.dispatchEvent({ type: 'boxeschanged', boxes: this.boxes });
} }
} }