Values of this instance change with every call to scan(...)
so it's not meant for you to keep.
CollisionContact objects are part of an internal object pooling. This is a measure to reduce
the pressure on the garbage collector.
constcontactsA = collision.scan(myScanShape); // 1st scan constcontactsA_copy = contacts.map(c=>c.copy()); // copy for later use constcontactsB = collision.scan(myScanShape); // 2nd scan
console.log(contactsA); // <- BAD! Random data because of 2nd scan console.log(contactsA_copy); // <- OK! console.log(contactsB); // <- OK, because it's data from the last scan
Object that contains the details about a contact.
🔥 Careful
Values of this instance change with every call to
scan(...)
so it's not meant for you to keep.CollisionContact objects are part of an internal object pooling. This is a measure to reduce the pressure on the garbage collector.