1
0
mirror of https://github.com/troisjs/trois.git synced 2024-11-24 04:12:02 +08:00

optimize notes

This commit is contained in:
Sander Moolin 2021-03-22 14:57:22 -04:00
parent 68d7bd19ea
commit 26e0ca6063

View File

@ -94,6 +94,7 @@ export default {
instanceId: intersect.instanceId instanceId: intersect.instanceId
} }
}); });
// TODO: optimize
const newIntersects = intersects.filter(intersect => !old.find(val => val.object === intersect.object && val.instanceId === intersect.instanceId)); const newIntersects = intersects.filter(intersect => !old.find(val => val.object === intersect.object && val.instanceId === intersect.instanceId));
if (newIntersects.length) { if (newIntersects.length) {
this.onPointerEnter(newIntersects) this.onPointerEnter(newIntersects)
@ -113,6 +114,7 @@ export default {
instanceId: intersect.instanceId instanceId: intersect.instanceId
} }
}); });
// TODO: optimize
const expiredIntersects = this._intersects.filter(intersect => !newObjects.find(val => val.object === intersect.object && val.instanceId === intersect.instanceId)); const expiredIntersects = this._intersects.filter(intersect => !newObjects.find(val => val.object === intersect.object && val.instanceId === intersect.instanceId));
if (expiredIntersects.length) { if (expiredIntersects.length) {
this.onPointerLeave(expiredIntersects) this.onPointerLeave(expiredIntersects)