@woosh/meep-engine 2.122.5 → 2.122.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/bundle-worker-image-decoder.js +1 -1
- package/package.json +1 -1
- package/src/core/geom/3d/SurfacePoint3.js +2 -2
- package/src/core/geom/3d/frustum/frustum3_computeNearestPointToPoint.js +1 -1
- package/src/core/geom/3d/topology/bounds/computeTriangleClusterNormalBoundingCone.js +4 -4
- package/src/core/geom/Vector3.d.ts +56 -40
- package/src/core/geom/Vector3.d.ts.map +1 -1
- package/src/core/geom/Vector3.js +100 -96
- package/src/core/geom/packing/computeBoundingSphereOfSpheres.d.ts +12 -1
- package/src/core/geom/packing/max-rect/MaxRectanglesPacker.d.ts +14 -11
- package/src/core/geom/packing/max-rect/MaxRectanglesPacker.d.ts.map +1 -1
- package/src/core/geom/packing/max-rect/MaxRectanglesPacker.js +25 -36
- package/src/core/geom/packing/max-rect/aabb2_validate_packing.d.ts +2 -0
- package/src/core/geom/packing/max-rect/aabb2_validate_packing.d.ts.map +1 -0
- package/src/core/geom/packing/max-rect/aabb2_validate_packing.js +29 -0
- package/src/core/geom/packing/max-rect/packMaxRectangles.d.ts +0 -3
- package/src/core/geom/packing/max-rect/packMaxRectangles.d.ts.map +1 -1
- package/src/core/geom/packing/max-rect/packMaxRectangles.js +0 -3
- package/src/core/geom/packing/miniball/Miniball.d.ts +2 -1
- package/src/core/geom/packing/miniball/Miniball.d.ts.map +1 -1
- package/src/core/geom/packing/miniball/Miniball.js +2 -1
- package/src/core/math/spline/v3_computeCatmullRomSplineUniformDistance.js +1 -1
- package/src/engine/asset/loaders/image/png/crc32.d.ts +11 -6
- package/src/engine/asset/loaders/image/png/crc32.d.ts.map +1 -1
- package/src/engine/asset/loaders/image/png/crc32.js +43 -18
- package/src/engine/graphics/particles/particular/engine/emitter/ParticleEmitter.js +2 -2
- package/src/engine/graphics/render/forward_plus/prototype/prototypeLightManager.js +2 -2
- package/src/engine/navigation/ecs/components/Path.js +1 -1
package/src/core/geom/Vector3.js
CHANGED
|
@@ -64,13 +64,74 @@ export class Vector3 {
|
|
|
64
64
|
this.onChanged = new Signal();
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
+
/**
|
|
68
|
+
*
|
|
69
|
+
* @return {number}
|
|
70
|
+
*/
|
|
71
|
+
get 0() {
|
|
72
|
+
return this.x;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
*
|
|
77
|
+
* @return {number}
|
|
78
|
+
*/
|
|
79
|
+
get 1() {
|
|
80
|
+
return this.y;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
*
|
|
85
|
+
* @return {number}
|
|
86
|
+
*/
|
|
87
|
+
get 2() {
|
|
88
|
+
return this.z;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
*
|
|
93
|
+
* @param {number} v
|
|
94
|
+
*/
|
|
95
|
+
set 0(v) {
|
|
96
|
+
this.x = v;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
*
|
|
101
|
+
* @param {number} v
|
|
102
|
+
*/
|
|
103
|
+
set 1(v) {
|
|
104
|
+
this.y = v;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
*
|
|
109
|
+
* @param {number} v
|
|
110
|
+
*/
|
|
111
|
+
set 2(v) {
|
|
112
|
+
this.z = v;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
*
|
|
117
|
+
* @return {Generator<number>}
|
|
118
|
+
*/
|
|
119
|
+
* [Symbol.iterator]() {
|
|
120
|
+
|
|
121
|
+
yield this.x;
|
|
122
|
+
yield this.y;
|
|
123
|
+
yield this.z;
|
|
124
|
+
|
|
125
|
+
}
|
|
126
|
+
|
|
67
127
|
/**
|
|
68
128
|
*
|
|
69
129
|
* @param {number[]|Float32Array} array
|
|
70
|
-
* @param {number} offset
|
|
130
|
+
* @param {number} [offset]
|
|
131
|
+
* @returns {this}
|
|
71
132
|
*/
|
|
72
|
-
|
|
73
|
-
this.set(
|
|
133
|
+
fromArray(array, offset = 0) {
|
|
134
|
+
return this.set(
|
|
74
135
|
array[offset],
|
|
75
136
|
array[offset + 1],
|
|
76
137
|
array[offset + 2]
|
|
@@ -78,11 +139,11 @@ export class Vector3 {
|
|
|
78
139
|
}
|
|
79
140
|
|
|
80
141
|
/**
|
|
81
|
-
*
|
|
82
|
-
* @param {number[]
|
|
83
|
-
* @
|
|
142
|
+
* @param {number[]|Float32Array|ArrayLike} [array]
|
|
143
|
+
* @param {number} [offset]
|
|
144
|
+
* @returns {number[]}
|
|
84
145
|
*/
|
|
85
|
-
|
|
146
|
+
toArray(array = [], offset = 0) {
|
|
86
147
|
array[offset] = this.x;
|
|
87
148
|
array[offset + 1] = this.y;
|
|
88
149
|
array[offset + 2] = this.z;
|
|
@@ -118,7 +179,10 @@ export class Vector3 {
|
|
|
118
179
|
this.z = z;
|
|
119
180
|
|
|
120
181
|
if (this.onChanged.hasHandlers()) {
|
|
121
|
-
this.onChanged.send6(
|
|
182
|
+
this.onChanged.send6(
|
|
183
|
+
x, y, z,
|
|
184
|
+
oldX, oldY, oldZ
|
|
185
|
+
);
|
|
122
186
|
}
|
|
123
187
|
|
|
124
188
|
}
|
|
@@ -324,21 +388,21 @@ export class Vector3 {
|
|
|
324
388
|
}
|
|
325
389
|
|
|
326
390
|
/**
|
|
327
|
-
*
|
|
391
|
+
* Add a scalar value to each component of the vector
|
|
328
392
|
* @param {number} val
|
|
329
393
|
* @returns {this}
|
|
330
394
|
*/
|
|
331
|
-
|
|
332
|
-
return this.set(this.x
|
|
395
|
+
addScalar(val) {
|
|
396
|
+
return this.set(this.x + val, this.y + val, this.z + val);
|
|
333
397
|
}
|
|
334
398
|
|
|
335
399
|
/**
|
|
336
|
-
*
|
|
400
|
+
* Subtract scalar value from each component of the vector
|
|
337
401
|
* @param {number} val
|
|
338
402
|
* @returns {this}
|
|
339
403
|
*/
|
|
340
|
-
|
|
341
|
-
return this.
|
|
404
|
+
subScalar(val) {
|
|
405
|
+
return this.addScalar(-val);
|
|
342
406
|
}
|
|
343
407
|
|
|
344
408
|
/**
|
|
@@ -534,11 +598,7 @@ export class Vector3 {
|
|
|
534
598
|
distanceSqrTo(other) {
|
|
535
599
|
assert.defined(other, "other");
|
|
536
600
|
|
|
537
|
-
|
|
538
|
-
const dy = this.y - other.y;
|
|
539
|
-
const dz = this.z - other.z;
|
|
540
|
-
|
|
541
|
-
return v3_length_sqr(dx, dy, dz);
|
|
601
|
+
return this._distanceSqrTo(other.x, other.y, other.z);
|
|
542
602
|
}
|
|
543
603
|
|
|
544
604
|
/**
|
|
@@ -549,7 +609,11 @@ export class Vector3 {
|
|
|
549
609
|
* @return {number}
|
|
550
610
|
*/
|
|
551
611
|
_distanceSqrTo(x, y, z) {
|
|
552
|
-
return v3_length_sqr(
|
|
612
|
+
return v3_length_sqr(
|
|
613
|
+
this.x - x,
|
|
614
|
+
this.y - y,
|
|
615
|
+
this.z - z
|
|
616
|
+
);
|
|
553
617
|
}
|
|
554
618
|
|
|
555
619
|
/**
|
|
@@ -672,7 +736,7 @@ export class Vector3 {
|
|
|
672
736
|
const _y = (m4[1] * x + m4[5] * y + m4[9] * z + m4[13]) * w;
|
|
673
737
|
const _z = (m4[2] * x + m4[6] * y + m4[10] * z + m4[14]) * w;
|
|
674
738
|
|
|
675
|
-
|
|
739
|
+
return this.set(_x, _y, _z);
|
|
676
740
|
}
|
|
677
741
|
|
|
678
742
|
/**
|
|
@@ -729,7 +793,7 @@ export class Vector3 {
|
|
|
729
793
|
const _y = matrix4[13];
|
|
730
794
|
const _z = matrix4[14];
|
|
731
795
|
|
|
732
|
-
|
|
796
|
+
return this.set(_x, _y, _z);
|
|
733
797
|
}
|
|
734
798
|
|
|
735
799
|
/**
|
|
@@ -859,7 +923,7 @@ export class Vector3 {
|
|
|
859
923
|
const _y = radius * cos_phi;
|
|
860
924
|
const _z = radius * sin_phi * cos_theta;
|
|
861
925
|
|
|
862
|
-
|
|
926
|
+
return this.set(_x, _y, _z);
|
|
863
927
|
}
|
|
864
928
|
|
|
865
929
|
/**
|
|
@@ -958,39 +1022,6 @@ export class Vector3 {
|
|
|
958
1022
|
return x ^ (y << 1) ^ (z << 2);
|
|
959
1023
|
}
|
|
960
1024
|
|
|
961
|
-
|
|
962
|
-
get 0() {
|
|
963
|
-
return this.x;
|
|
964
|
-
}
|
|
965
|
-
|
|
966
|
-
get 1() {
|
|
967
|
-
return this.y;
|
|
968
|
-
}
|
|
969
|
-
|
|
970
|
-
get 2() {
|
|
971
|
-
return this.z;
|
|
972
|
-
}
|
|
973
|
-
|
|
974
|
-
set 0(v) {
|
|
975
|
-
this.x = v;
|
|
976
|
-
}
|
|
977
|
-
|
|
978
|
-
set 1(v) {
|
|
979
|
-
this.y = v;
|
|
980
|
-
}
|
|
981
|
-
|
|
982
|
-
set 2(v) {
|
|
983
|
-
this.z = v;
|
|
984
|
-
}
|
|
985
|
-
|
|
986
|
-
* [Symbol.iterator]() {
|
|
987
|
-
|
|
988
|
-
yield this.x;
|
|
989
|
-
yield this.y;
|
|
990
|
-
yield this.z;
|
|
991
|
-
|
|
992
|
-
}
|
|
993
|
-
|
|
994
1025
|
/**
|
|
995
1026
|
* Dot product
|
|
996
1027
|
* @param {Vector3|Vector4} a
|
|
@@ -1033,42 +1064,6 @@ export class Vector3 {
|
|
|
1033
1064
|
static fromScalar(value) {
|
|
1034
1065
|
return new Vector3(value, value, value);
|
|
1035
1066
|
}
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
/**
|
|
1039
|
-
*
|
|
1040
|
-
* @param {THREE.Matrix4} matrix4
|
|
1041
|
-
* @deprecated use {@link @applyMatrix4} directly instead, pass `mat.elements`
|
|
1042
|
-
*/
|
|
1043
|
-
applyMatrix4_three(matrix4) {
|
|
1044
|
-
throw new Error("use applyMatrix4 instead")
|
|
1045
|
-
}
|
|
1046
|
-
|
|
1047
|
-
/**
|
|
1048
|
-
* @deprecated use non-three.js version instead
|
|
1049
|
-
* @param {THREE.Matrix4} m
|
|
1050
|
-
*/
|
|
1051
|
-
transformDirection_three(m) {
|
|
1052
|
-
throw new Error("use applyDirectionMatrix4 instead")
|
|
1053
|
-
}
|
|
1054
|
-
|
|
1055
|
-
/**
|
|
1056
|
-
* @deprecated use non-three.js version instead
|
|
1057
|
-
* @param {THREE.Matrix3} m
|
|
1058
|
-
* @returns {Vector3}
|
|
1059
|
-
*/
|
|
1060
|
-
applyMatrix3_three(m) {
|
|
1061
|
-
throw new Error("use applyMatrix3 instead")
|
|
1062
|
-
}
|
|
1063
|
-
|
|
1064
|
-
/**
|
|
1065
|
-
* @deprecated use non-three.js version instead
|
|
1066
|
-
* @param {THREE.Matrix4} matrix4
|
|
1067
|
-
*/
|
|
1068
|
-
threejs_setFromMatrixPosition(matrix4) {
|
|
1069
|
-
throw new Error("use setFromMatrixPosition instead")
|
|
1070
|
-
}
|
|
1071
|
-
|
|
1072
1067
|
}
|
|
1073
1068
|
|
|
1074
1069
|
// Aliases
|
|
@@ -1076,12 +1071,21 @@ export class Vector3 {
|
|
|
1076
1071
|
Vector3.prototype.distanceToSquared = Vector3.prototype.distanceSqrTo;
|
|
1077
1072
|
|
|
1078
1073
|
Vector3.prototype.lengthSq = Vector3.prototype.lengthSqr;
|
|
1079
|
-
Vector3.prototype.fromArray = Vector3.prototype.readFromArray;
|
|
1080
|
-
Vector3.prototype.toArray = Vector3.prototype.writeToArray;
|
|
1081
1074
|
/**
|
|
1082
|
-
* @
|
|
1075
|
+
* @readonly
|
|
1076
|
+
* @deprecated Use {@link fromArray} instead
|
|
1077
|
+
*/
|
|
1078
|
+
Vector3.prototype.readFromArray = Vector3.prototype.fromArray;
|
|
1079
|
+
/**
|
|
1080
|
+
* @readonly
|
|
1081
|
+
* @deprecated Use {@link toArray} instead
|
|
1082
|
+
*/
|
|
1083
|
+
Vector3.prototype.writeToArray = Vector3.prototype.toArray;
|
|
1084
|
+
/**
|
|
1085
|
+
* @readonly
|
|
1086
|
+
* @deprecated use {@link toArray} instead
|
|
1083
1087
|
*/
|
|
1084
|
-
Vector3.prototype.asArray = Vector3.prototype.
|
|
1088
|
+
Vector3.prototype.asArray = Vector3.prototype.toArray;
|
|
1085
1089
|
|
|
1086
1090
|
|
|
1087
1091
|
/**
|
|
@@ -1 +1,12 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Computes bounding sphere of a number of spheres
|
|
3
|
+
* NOTE: implementation does not produce a very tight sphere, here is a good resource for a better implementation:
|
|
4
|
+
* https://github.com/CGAL/cgal/blob/master/Bounding_volumes/include/CGAL/Min_sphere_of_spheres_d/Min_sphere_of_spheres_d_support_set.h
|
|
5
|
+
* @param {number[]|Float32Array|Float64Array} result
|
|
6
|
+
* @param {number[]|Float32Array|Float64Array} data
|
|
7
|
+
* @param {number} offset
|
|
8
|
+
* @param {number} count
|
|
9
|
+
* @param {number} dimensions
|
|
10
|
+
*/
|
|
11
|
+
export function computeBoundingSphereOfSpheres(result: number[] | Float32Array | Float64Array, data: number[] | Float32Array | Float64Array, offset: number, count: number, dimensions: number): void;
|
|
12
|
+
//# sourceMappingURL=computeBoundingSphereOfSpheres.d.ts.map
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Packs rectangles into a finite area, packer is incremental and supports both insertions and removals of rectangles
|
|
2
|
+
* Packs rectangles into a finite area, packer is incremental and supports both insertions and removals of rectangles.
|
|
3
3
|
* Implementation of "max rectangles" packing algorithm.
|
|
4
|
-
* Useful for packing texture atlases
|
|
4
|
+
* Useful for packing texture atlases.
|
|
5
|
+
*
|
|
6
|
+
* @see "A Thousand Ways to Pack the Bin - A Practical Approach to Two-Dimensional Rectangle Bin Packing" 2010 Jukka Jylänki
|
|
5
7
|
*/
|
|
6
8
|
export class MaxRectanglesPacker {
|
|
7
9
|
/**
|
|
@@ -17,26 +19,29 @@ export class MaxRectanglesPacker {
|
|
|
17
19
|
*/
|
|
18
20
|
free: QuadTreeNode<any>;
|
|
19
21
|
/**
|
|
20
|
-
*
|
|
22
|
+
* Currently held boxes.
|
|
23
|
+
* Managed internally, do not modify.
|
|
24
|
+
* @readonly
|
|
21
25
|
* @type {AABB2[]}
|
|
22
26
|
*/
|
|
23
|
-
boxes: AABB2[];
|
|
27
|
+
readonly boxes: AABB2[];
|
|
24
28
|
/**
|
|
25
29
|
*
|
|
26
|
-
* @param {AABB2} box
|
|
27
|
-
* @returns {boolean}
|
|
30
|
+
* @param {AABB2} box exact box to remove
|
|
31
|
+
* @returns {boolean} true when box is removed, false if not found
|
|
28
32
|
*/
|
|
29
33
|
remove(box: AABB2): boolean;
|
|
30
34
|
/**
|
|
31
35
|
*
|
|
32
36
|
* @param {AABB2[]} boxes
|
|
33
|
-
* @returns {number}
|
|
37
|
+
* @returns {number} How many failed to be removed. Failure represents box that was not packed in the first place.
|
|
34
38
|
*/
|
|
35
39
|
removeMany(boxes: AABB2[]): number;
|
|
36
40
|
/**
|
|
37
|
-
*
|
|
41
|
+
* Pack a given box.
|
|
42
|
+
* Atomic, if box fails packing - the existing data structure is unchanged.
|
|
38
43
|
* @param {AABB2} box
|
|
39
|
-
* @returns {boolean}
|
|
44
|
+
* @returns {boolean} true if box was successfully added into the packing, false otherwise
|
|
40
45
|
*/
|
|
41
46
|
add(box: AABB2): boolean;
|
|
42
47
|
/**
|
|
@@ -69,9 +74,7 @@ export class MaxRectanglesPacker {
|
|
|
69
74
|
* @returns {boolean} false if packing fails after resize, true otherwise
|
|
70
75
|
*/
|
|
71
76
|
resize(width: number, height: number): boolean;
|
|
72
|
-
validate(): boolean;
|
|
73
77
|
}
|
|
74
78
|
import Vector2 from "../../Vector2.js";
|
|
75
79
|
import { QuadTreeNode } from "../../2d/quad-tree/QuadTreeNode.js";
|
|
76
|
-
import AABB2 from "../../2d/aabb/AABB2.js";
|
|
77
80
|
//# sourceMappingURL=MaxRectanglesPacker.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MaxRectanglesPacker.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/packing/max-rect/MaxRectanglesPacker.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"MaxRectanglesPacker.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/packing/max-rect/MaxRectanglesPacker.js"],"names":[],"mappings":"AAUA;;;;;;GAMG;AACH;IACI;;;;OAIG;IACH,mBAHW,MAAM,UACN,MAAM,EAqBhB;IAlBG,cAAsC;IAEtC;;;OAGG;IACH,wBAAiD;IAKjD;;;;;OAKG;IACH,gBAFU,KAAK,EAAE,CAEF;IAGnB;;;;OAIG;IACH,YAHW,KAAK,GACH,OAAO,CAoBnB;IAED;;;;OAIG;IACH,kBAHW,KAAK,EAAE,GACL,MAAM,CAgBlB;IAED;;;;;OAKG;IACH,SAHW,KAAK,GACH,OAAO,CAanB;IAED;;;;;;OAMG;IACH,UAJW,MAAM,KACN,MAAM,GACL,OAAO,CAIlB;IAED;;;;OAIG;IACH,eAHW,KAAK,EAAE,GACL,OAAO,CAiDnB;IAED;;;OAGG;IACH,UAFa,OAAO,CAWnB;IAED;;OAEG;IACH,cAKC;IAED;;;;;OAKG;IACH,cAJW,MAAM,UACN,MAAM,GACJ,OAAO,CAmCnB;CAEJ;oBA5OmB,kBAAkB;6BADT,oCAAoC"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { assert } from "../../../assert.js";
|
|
2
2
|
import BinaryHeap from "../../../collection/heap/BinaryHeap.js";
|
|
3
|
-
import AABB2 from "../../2d/aabb/AABB2.js";
|
|
4
3
|
import { QuadTreeDatum } from "../../2d/quad-tree/QuadTreeDatum.js";
|
|
5
4
|
import { QuadTreeNode } from "../../2d/quad-tree/QuadTreeNode.js";
|
|
6
5
|
import Vector2 from "../../Vector2.js";
|
|
@@ -10,9 +9,11 @@ import { packOneBox } from "./packOneBox.js";
|
|
|
10
9
|
import { removeRedundantBoxes } from "./removeRedundantBoxes.js";
|
|
11
10
|
|
|
12
11
|
/**
|
|
13
|
-
* Packs rectangles into a finite area, packer is incremental and supports both insertions and removals of rectangles
|
|
12
|
+
* Packs rectangles into a finite area, packer is incremental and supports both insertions and removals of rectangles.
|
|
14
13
|
* Implementation of "max rectangles" packing algorithm.
|
|
15
|
-
* Useful for packing texture atlases
|
|
14
|
+
* Useful for packing texture atlases.
|
|
15
|
+
*
|
|
16
|
+
* @see "A Thousand Ways to Pack the Bin - A Practical Approach to Two-Dimensional Rectangle Bin Packing" 2010 Jukka Jylänki
|
|
16
17
|
*/
|
|
17
18
|
export class MaxRectanglesPacker {
|
|
18
19
|
/**
|
|
@@ -33,7 +34,9 @@ export class MaxRectanglesPacker {
|
|
|
33
34
|
this.free.add(null, 0, 0, width, height);
|
|
34
35
|
|
|
35
36
|
/**
|
|
36
|
-
*
|
|
37
|
+
* Currently held boxes.
|
|
38
|
+
* Managed internally, do not modify.
|
|
39
|
+
* @readonly
|
|
37
40
|
* @type {AABB2[]}
|
|
38
41
|
*/
|
|
39
42
|
this.boxes = [];
|
|
@@ -41,8 +44,8 @@ export class MaxRectanglesPacker {
|
|
|
41
44
|
|
|
42
45
|
/**
|
|
43
46
|
*
|
|
44
|
-
* @param {AABB2} box
|
|
45
|
-
* @returns {boolean}
|
|
47
|
+
* @param {AABB2} box exact box to remove
|
|
48
|
+
* @returns {boolean} true when box is removed, false if not found
|
|
46
49
|
*/
|
|
47
50
|
remove(box) {
|
|
48
51
|
const i = this.boxes.indexOf(box);
|
|
@@ -54,7 +57,7 @@ export class MaxRectanglesPacker {
|
|
|
54
57
|
|
|
55
58
|
this.boxes.splice(i, 1);
|
|
56
59
|
|
|
57
|
-
//introduce a free node in the unoccupied space
|
|
60
|
+
// introduce a free node in the unoccupied space
|
|
58
61
|
this.free.insertDatum(new QuadTreeDatum(box.x0, box.y0, box.x1, box.y1));
|
|
59
62
|
|
|
60
63
|
|
|
@@ -67,7 +70,7 @@ export class MaxRectanglesPacker {
|
|
|
67
70
|
/**
|
|
68
71
|
*
|
|
69
72
|
* @param {AABB2[]} boxes
|
|
70
|
-
* @returns {number}
|
|
73
|
+
* @returns {number} How many failed to be removed. Failure represents box that was not packed in the first place.
|
|
71
74
|
*/
|
|
72
75
|
removeMany(boxes) {
|
|
73
76
|
let failures = 0;
|
|
@@ -86,9 +89,10 @@ export class MaxRectanglesPacker {
|
|
|
86
89
|
}
|
|
87
90
|
|
|
88
91
|
/**
|
|
89
|
-
*
|
|
92
|
+
* Pack a given box.
|
|
93
|
+
* Atomic, if box fails packing - the existing data structure is unchanged.
|
|
90
94
|
* @param {AABB2} box
|
|
91
|
-
* @returns {boolean}
|
|
95
|
+
* @returns {boolean} true if box was successfully added into the packing, false otherwise
|
|
92
96
|
*/
|
|
93
97
|
add(box) {
|
|
94
98
|
const success = packOneBox(box, this.free);
|
|
@@ -120,8 +124,8 @@ export class MaxRectanglesPacker {
|
|
|
120
124
|
* @returns {boolean}
|
|
121
125
|
*/
|
|
122
126
|
addMany(boxes) {
|
|
123
|
-
assert.defined(boxes,'boxes');
|
|
124
|
-
assert.isArray(boxes,'boxes');
|
|
127
|
+
assert.defined(boxes, 'boxes');
|
|
128
|
+
assert.isArray(boxes, 'boxes');
|
|
125
129
|
|
|
126
130
|
// assert.ok(this.validate());
|
|
127
131
|
|
|
@@ -200,6 +204,14 @@ export class MaxRectanglesPacker {
|
|
|
200
204
|
* @returns {boolean} false if packing fails after resize, true otherwise
|
|
201
205
|
*/
|
|
202
206
|
resize(width, height) {
|
|
207
|
+
assert.isNumber(width, 'width');
|
|
208
|
+
assert.isNumber(height, 'height');
|
|
209
|
+
|
|
210
|
+
assert.isFiniteNumber(width, 'width');
|
|
211
|
+
assert.isFiniteNumber(height, 'height');
|
|
212
|
+
|
|
213
|
+
assert.greaterThan(width, 0, 'width');
|
|
214
|
+
assert.greaterThan(height, 0, 'height');
|
|
203
215
|
|
|
204
216
|
// assert.ok(this.validate());
|
|
205
217
|
|
|
@@ -209,7 +221,7 @@ export class MaxRectanglesPacker {
|
|
|
209
221
|
this.size.set(width, height);
|
|
210
222
|
|
|
211
223
|
if (oldWidth > width || oldHeight > height) {
|
|
212
|
-
//canvas was made smaller in at least one dimension, re-pack is required
|
|
224
|
+
// canvas was made smaller in at least one dimension, re-pack is required
|
|
213
225
|
return this.repack();
|
|
214
226
|
}
|
|
215
227
|
|
|
@@ -226,29 +238,6 @@ export class MaxRectanglesPacker {
|
|
|
226
238
|
return true;
|
|
227
239
|
}
|
|
228
240
|
|
|
229
|
-
validate() {
|
|
230
|
-
|
|
231
|
-
const boxes = this.boxes;
|
|
232
|
-
const numPatches = boxes.length;
|
|
233
|
-
let i, j;
|
|
234
|
-
|
|
235
|
-
for (i = 0; i < numPatches; i++) {
|
|
236
|
-
const p0 = boxes[i];
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
for (j = i + 1; j < numPatches; j++) {
|
|
240
|
-
const p1 = boxes[j];
|
|
241
|
-
|
|
242
|
-
if (p0.computeOverlap(p1, new AABB2())) {
|
|
243
|
-
console.warn("Overlap", p0, p1);
|
|
244
|
-
return false;
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
return true;
|
|
251
|
-
}
|
|
252
241
|
}
|
|
253
242
|
|
|
254
243
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"aabb2_validate_packing.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/packing/max-rect/aabb2_validate_packing.js"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import AABB2 from "../../2d/aabb/AABB2.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
*
|
|
5
|
+
* @param {AABB2[]} boxes
|
|
6
|
+
* @return {boolean}
|
|
7
|
+
*/
|
|
8
|
+
function validate(boxes) {
|
|
9
|
+
|
|
10
|
+
const numPatches = boxes.length;
|
|
11
|
+
let i, j;
|
|
12
|
+
|
|
13
|
+
for (i = 0; i < numPatches; i++) {
|
|
14
|
+
const p0 = boxes[i];
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
for (j = i + 1; j < numPatches; j++) {
|
|
18
|
+
const p1 = boxes[j];
|
|
19
|
+
|
|
20
|
+
if (p0.computeOverlap(p1, new AABB2())) {
|
|
21
|
+
console.warn("Overlap", p0, p1);
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return true;
|
|
29
|
+
}
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Packs {@link AABB2} boxes into defined bounds
|
|
3
3
|
*
|
|
4
|
-
* Based on paper "A Thousand Ways to Pack the Bin - A Practical Approach to Two-Dimensional Rectangle Bin Packing" 2010 Jukka Jylänki
|
|
5
|
-
* Method presented called Maximal Rectangles
|
|
6
|
-
*
|
|
7
4
|
* @param {number} width
|
|
8
5
|
* @param {number} height
|
|
9
6
|
* @param {AABB2[]} boxes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"packMaxRectangles.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/packing/max-rect/packMaxRectangles.js"],"names":[],"mappings":"AAEA
|
|
1
|
+
{"version":3,"file":"packMaxRectangles.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/packing/max-rect/packMaxRectangles.js"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,yCALW,MAAM,UACN,MAAM,SACN,KAAK,EAAE,GACL,OAAO,CAOnB"}
|
|
@@ -3,9 +3,6 @@ import { MaxRectanglesPacker } from "./MaxRectanglesPacker.js";
|
|
|
3
3
|
/**
|
|
4
4
|
* Packs {@link AABB2} boxes into defined bounds
|
|
5
5
|
*
|
|
6
|
-
* Based on paper "A Thousand Ways to Pack the Bin - A Practical Approach to Two-Dimensional Rectangle Bin Packing" 2010 Jukka Jylänki
|
|
7
|
-
* Method presented called Maximal Rectangles
|
|
8
|
-
*
|
|
9
6
|
* @param {number} width
|
|
10
7
|
* @param {number} height
|
|
11
8
|
* @param {AABB2[]} boxes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Miniball.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/packing/miniball/Miniball.js"],"names":[],"mappings":"AAwBA
|
|
1
|
+
{"version":3,"file":"Miniball.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/packing/miniball/Miniball.js"],"names":[],"mappings":"AAwBA;;;;GAIG;AACH;IACI;;;;;OAKG;IACH,oBAFW,QAAQ,EAoGlB;IA/FG;;;OAGG;IACH,WAFU,MAAM,CAEE;IAClB;;;OAGG;IACH,WAFU,MAAM,CAEE;IAClB;;;OAGG;IACH,iBAFU,MAAM,CAEQ;IACxB;;;;;;;;;;OAUG;IACH,wBAAwB;IACxB;;;;OAIG;IACH,iBAAiB;IACjB;;;OAGG;IACH,SAFU,MAAM,CAEA;IAEhB;;OAEG;IACH,GAFU,QAAQ,CAEH;IAEf;;;;OAIG;IACH,eAA2B;IAI3B;;;OAGG;IACH,KAFU,MAAM,CAEU;IAM1B;;;;OAIG;IACH,iBAA4D;IAE5D;;;OAGG;IACH,aAFU,MAAM,EAAE,GAAC,YAAY,CAEkD;IAEjF;;;OAGG;IACH,eAFU,MAAM,EAAE,GAAC,YAAY,CAEwD;IAEvF;;;OAGG;IACH,SAFU,MAAM,EAAE,GAAC,YAAY,CAEsD;IAErF;;;;OAIG;IACH,kBAAgC;IAIpC;;;;;;;OAOG;IACH,WAFY,OAAO,CAIlB;IAED;;;;;;OAMG;IACH,UAFY,MAAM,CAIjB;IAED;;;;;;OAMG;IACH,UAFY,MAAM,EAAE,CAInB;IAED;;;OAGG;IACH,eAFa,OAAO,CAInB;IAED;;;;;;OAMG;IACH,QAJY,MAAM,CAMjB;IAED;;;;;;;;OAQG;IACH,iBAkCC;IAED;;OAEG;IACH,yBAGC;IAED;;OAEG;IACH,qBAcC;IAED;;;;;;;;;;OAUG;IACH,gBA4CC;IAED;;;;;;;;OAQG;IACH,kBAFY,OAAO,CA4BlB;IAED;;;;;;;;OAQG;IACH,yBAyDC;IAGD;;;OAGG;IACH,YAFY,MAAM,CAkBjB;CACJ;wBAnbuB,cAAc"}
|
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* 32-bit
|
|
3
|
-
* Returns CRC of the bytes buf[0..len-1]
|
|
2
|
+
* 32-bit Cyclic Redundancy Checksum.
|
|
4
3
|
* @see https://en.wikipedia.org/wiki/Cyclic_redundancy_check
|
|
5
4
|
* @param {Uint8Array} buffer byte buffer
|
|
6
|
-
* @param {number} offset
|
|
7
|
-
* @param {number} length how many bytes to include in checksum calculation
|
|
8
|
-
* @return {number}
|
|
5
|
+
* @param {number} [offset=0] where to start in the input buffer
|
|
6
|
+
* @param {number} [length=buffer.length] how many bytes to include in checksum calculation
|
|
7
|
+
* @return {number} Unsigned 32-bit integer value
|
|
8
|
+
* @copyright Company Named Limited (c) 2025
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* const buffer = new BinaryBuffer();
|
|
12
|
+
* buffer.writeASCIIString("Hello World");
|
|
13
|
+
* const checksum = crc32(buffer.raw_bytes, 0, buffer.position);
|
|
9
14
|
*/
|
|
10
|
-
export function crc32(buffer: Uint8Array, offset
|
|
15
|
+
export function crc32(buffer: Uint8Array, offset?: number, length?: number): number;
|
|
11
16
|
//# sourceMappingURL=crc32.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"crc32.d.ts","sourceRoot":"","sources":["../../../../../../../src/engine/asset/loaders/image/png/crc32.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"crc32.d.ts","sourceRoot":"","sources":["../../../../../../../src/engine/asset/loaders/image/png/crc32.js"],"names":[],"mappings":"AAuEA;;;;;;;;;;;;;GAaG;AACH,8BAXW,UAAU,WACV,MAAM,WACN,MAAM,GACL,MAAM,CAcjB"}
|