refactor: use equalsClose for position juggling
This commit is contained in:
parent
957b4c8a15
commit
92f4f4a2d1
|
@ -1,4 +1,5 @@
|
|||
import {compose, virtualize} from '@avocado/core';
|
||||
import {Vector} from '@avocado/math';
|
||||
|
||||
const decorate = compose(
|
||||
virtualize([
|
||||
|
@ -25,6 +26,9 @@ class AbstractWorldBase {
|
|||
tick(elapsed) {
|
||||
// Propagate position updates.
|
||||
for (const entity of this.entities.values()) {
|
||||
if (Vector.equalsClose(entity.position, entity.body.position)) {
|
||||
continue;
|
||||
}
|
||||
entity.position = entity.body.position;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -65,6 +65,9 @@ export class Body extends AbstractBody {
|
|||
}
|
||||
|
||||
set position(position) {
|
||||
if (Vector.equalsClose(this.position, position)) {
|
||||
return;
|
||||
}
|
||||
MatterBody.setPosition(this.matterBody, {
|
||||
x: position[0],
|
||||
y: position[1],
|
||||
|
|
Loading…
Reference in New Issue
Block a user