From 0cdb4c023044ea4dc681b42c211a90e2e455d199 Mon Sep 17 00:00:00 2001 From: Doug Wright Date: Sun, 14 Mar 2021 20:01:53 +0000 Subject: [PATCH] Extend visualisation to support all of the boxes in a packing #213 --- src/PackedBoxList.php | 8 +- visualiser/babylonjs.html | 274 ++++++++++++++++++++------------------ 2 files changed, 150 insertions(+), 132 deletions(-) diff --git a/src/PackedBoxList.php b/src/PackedBoxList.php index 6016540f..29a6d9d5 100644 --- a/src/PackedBoxList.php +++ b/src/PackedBoxList.php @@ -12,6 +12,7 @@ use function count; use Countable; use IteratorAggregate; +use JsonSerializable; use function reset; use function round; use Traversable; @@ -22,7 +23,7 @@ * * @author Doug Wright */ -class PackedBoxList implements IteratorAggregate, Countable +class PackedBoxList implements IteratorAggregate, Countable, JsonSerializable { /** * List containing boxes. @@ -171,4 +172,9 @@ public function getVolumeUtilisation(): float return round($itemVolume / $boxVolume * 100, 1); } + + public function jsonSerialize(): array + { + return $this->list; + } } diff --git a/visualiser/babylonjs.html b/visualiser/babylonjs.html index 2142a14f..df09b2f0 100644 --- a/visualiser/babylonjs.html +++ b/visualiser/babylonjs.html @@ -22,7 +22,7 @@