@woosh/meep-engine 2.47.1 → 2.47.2
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/meep.cjs +194 -283
- package/build/meep.min.js +1 -1
- package/build/meep.module.js +194 -283
- package/package.json +1 -1
- package/src/core/collection/list/List.js +8 -0
- package/src/core/geom/Rectangle.js +178 -168
- package/src/core/model/node-graph/NodeGraph.js +10 -1
- package/src/core/model/node-graph/node/NodeInstance.js +83 -15
- package/src/engine/ecs/fow/serialization/FogOfWarSerializationAdapter.js +7 -2
- package/src/engine/graphics/texture/sampler/Sampler2D.js +8 -116
- package/src/engine/graphics/texture/sampler/Sampler2D2Canvas.js +1 -1
- package/src/engine/graphics/texture/sampler/sampler2d_make_array_filler_function.js +65 -0
- package/src/engine/ui/tiles2d/computeTileGridMove.js +2 -2
|
@@ -78,11 +78,6 @@ export class Sampler2D {
|
|
|
78
78
|
* @type {number}
|
|
79
79
|
*/
|
|
80
80
|
this.version = 0;
|
|
81
|
-
/**
|
|
82
|
-
* @readonly
|
|
83
|
-
* @type {boolean}
|
|
84
|
-
*/
|
|
85
|
-
this.isSampler2D = true;
|
|
86
81
|
}
|
|
87
82
|
|
|
88
83
|
/**
|
|
@@ -113,7 +108,7 @@ export class Sampler2D {
|
|
|
113
108
|
|
|
114
109
|
if (l === 0) {
|
|
115
110
|
//no data
|
|
116
|
-
return
|
|
111
|
+
return;
|
|
117
112
|
}
|
|
118
113
|
|
|
119
114
|
let bestValue = data[channel];
|
|
@@ -139,8 +134,6 @@ export class Sampler2D {
|
|
|
139
134
|
if (resultCount < result.length) {
|
|
140
135
|
result.splice(resultCount, result.length - resultCount);
|
|
141
136
|
}
|
|
142
|
-
|
|
143
|
-
return;
|
|
144
137
|
}
|
|
145
138
|
|
|
146
139
|
/**
|
|
@@ -639,74 +632,6 @@ export class Sampler2D {
|
|
|
639
632
|
result.set(x, y);
|
|
640
633
|
}
|
|
641
634
|
|
|
642
|
-
/**
|
|
643
|
-
*
|
|
644
|
-
* @param {number} scale
|
|
645
|
-
* @param {number} offset
|
|
646
|
-
* @return {function(index:int, array:ArrayLike, x:int, y:int)}
|
|
647
|
-
*/
|
|
648
|
-
makeArrayFiller(scale, offset) {
|
|
649
|
-
scale = scale || 255;
|
|
650
|
-
offset = offset || 0;
|
|
651
|
-
|
|
652
|
-
const sampler = this;
|
|
653
|
-
const v4 = [1 / scale, 1 / scale, 1 / scale, 1 / scale];
|
|
654
|
-
|
|
655
|
-
//
|
|
656
|
-
function fillDD1(index, array, x, y) {
|
|
657
|
-
const val = (sampler.sampleChannelBilinear(x, y, 0) + offset) * scale | 0;
|
|
658
|
-
array[index] = val;
|
|
659
|
-
array[index + 1] = val;
|
|
660
|
-
array[index + 2] = val;
|
|
661
|
-
array[index + 3] = 255;
|
|
662
|
-
}
|
|
663
|
-
|
|
664
|
-
function fillDD2(index, array, x, y) {
|
|
665
|
-
sampler.sampleBilinear(x, y, v4, 0);
|
|
666
|
-
const val = (v4[0] + offset) * scale | 0;
|
|
667
|
-
array.fill(val, index, index + 3);
|
|
668
|
-
array[index + 3] = (v4[1] + offset) * scale | 0;
|
|
669
|
-
}
|
|
670
|
-
|
|
671
|
-
function fillDD3(index, array, x, y) {
|
|
672
|
-
|
|
673
|
-
sampler.sampleBilinear(x, y, v4, 0);
|
|
674
|
-
|
|
675
|
-
array[index] = (v4[0] + offset) * scale | 0;
|
|
676
|
-
array[index + 1] = (v4[1] + offset) * scale | 0;
|
|
677
|
-
array[index + 2] = (v4[2] + offset) * scale | 0;
|
|
678
|
-
array[index + 3] = 255;
|
|
679
|
-
}
|
|
680
|
-
|
|
681
|
-
function fillDD4(index, array, x, y) {
|
|
682
|
-
sampler.sampleBilinear(x, y, v4, 0);
|
|
683
|
-
array[index] = (v4[0] + offset) * scale | 0;
|
|
684
|
-
array[index + 1] = (v4[1] + offset) * scale | 0;
|
|
685
|
-
array[index + 2] = (v4[2] + offset) * scale | 0;
|
|
686
|
-
array[index + 3] = (v4[3] + offset) * scale | 0;
|
|
687
|
-
}
|
|
688
|
-
|
|
689
|
-
let fillDD;
|
|
690
|
-
switch (sampler.itemSize) {
|
|
691
|
-
case 1:
|
|
692
|
-
fillDD = fillDD1;
|
|
693
|
-
break;
|
|
694
|
-
case 2:
|
|
695
|
-
fillDD = fillDD2;
|
|
696
|
-
break;
|
|
697
|
-
case 3:
|
|
698
|
-
fillDD = fillDD3;
|
|
699
|
-
break;
|
|
700
|
-
case 4:
|
|
701
|
-
fillDD = fillDD4;
|
|
702
|
-
break;
|
|
703
|
-
default :
|
|
704
|
-
throw new Error("unsupported item size");
|
|
705
|
-
break;
|
|
706
|
-
}
|
|
707
|
-
return fillDD;
|
|
708
|
-
}
|
|
709
|
-
|
|
710
635
|
/**
|
|
711
636
|
* Copy a patch from another sampler with a margin.
|
|
712
637
|
* This is useful for texture rendering where filtering can cause bleeding along the edges of the patch.
|
|
@@ -1283,28 +1208,7 @@ export class Sampler2D {
|
|
|
1283
1208
|
* @param {BinaryBuffer} buffer
|
|
1284
1209
|
*/
|
|
1285
1210
|
toBinaryBuffer(buffer) {
|
|
1286
|
-
|
|
1287
|
-
const height = this.height;
|
|
1288
|
-
|
|
1289
|
-
const itemSize = this.itemSize;
|
|
1290
|
-
|
|
1291
|
-
buffer.writeUint16(width);
|
|
1292
|
-
buffer.writeUint16(height);
|
|
1293
|
-
|
|
1294
|
-
buffer.writeUint8(itemSize);
|
|
1295
|
-
|
|
1296
|
-
if (this.data instanceof Uint8Array) {
|
|
1297
|
-
//data type
|
|
1298
|
-
buffer.writeUint8(0);
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
const byteSize = width * height * itemSize;
|
|
1302
|
-
|
|
1303
|
-
buffer.writeBytes(this.data, 0, byteSize);
|
|
1304
|
-
|
|
1305
|
-
} else {
|
|
1306
|
-
throw new TypeError(`Unsupported data type`);
|
|
1307
|
-
}
|
|
1211
|
+
throw new Error('Deprecated, use Sampler2DSerializationAdapter instead');
|
|
1308
1212
|
}
|
|
1309
1213
|
|
|
1310
1214
|
/**
|
|
@@ -1312,24 +1216,7 @@ export class Sampler2D {
|
|
|
1312
1216
|
* @param {BinaryBuffer} buffer
|
|
1313
1217
|
*/
|
|
1314
1218
|
fromBinaryBuffer(buffer) {
|
|
1315
|
-
|
|
1316
|
-
this.height = buffer.readUint16();
|
|
1317
|
-
|
|
1318
|
-
this.itemSize = buffer.readUint8();
|
|
1319
|
-
|
|
1320
|
-
const dataType = buffer.readUint8();
|
|
1321
|
-
|
|
1322
|
-
if (dataType === 0) {
|
|
1323
|
-
|
|
1324
|
-
const numBytes = this.height * this.width * this.itemSize;
|
|
1325
|
-
this.data = new Uint8Array(numBytes);
|
|
1326
|
-
|
|
1327
|
-
buffer.readBytes(this.data, 0, numBytes);
|
|
1328
|
-
|
|
1329
|
-
this.version++;
|
|
1330
|
-
} else {
|
|
1331
|
-
throw new TypeError(`Unsupported data type (${dataType})`);
|
|
1332
|
-
}
|
|
1219
|
+
throw new Error('Deprecated, use Sampler2DSerializationAdapter instead');
|
|
1333
1220
|
}
|
|
1334
1221
|
|
|
1335
1222
|
/**
|
|
@@ -1574,6 +1461,11 @@ export class Sampler2D {
|
|
|
1574
1461
|
|
|
1575
1462
|
}
|
|
1576
1463
|
|
|
1464
|
+
/**
|
|
1465
|
+
* @readonly
|
|
1466
|
+
* @type {boolean}
|
|
1467
|
+
*/
|
|
1468
|
+
Sampler2D.prototype.isSampler2D = true;
|
|
1577
1469
|
|
|
1578
1470
|
/**
|
|
1579
1471
|
* Based on code from reddit https://www.reddit.com/r/javascript/comments/jxa8x/bicubic_interpolation/
|
|
@@ -12,7 +12,7 @@ import { sampler2d_write_to_canvas_raw } from "./sampler2d_write_to_canvas_raw.j
|
|
|
12
12
|
* @param {Number} [scale]
|
|
13
13
|
* @param {Number} [offset]
|
|
14
14
|
* @param {HTMLCanvasElement} [canvas] if no canvas is supplied, a new one will be created
|
|
15
|
-
* @param {function(index:int, array:ArrayLike<number>, x:int, y:int)} [fillDD] allows you to supply mapping function, if none is given - one will be created from sampler
|
|
15
|
+
* @param {function(index:int, array:ArrayLike<number>, x:int, y:int)} [fillDD] allows you to supply mapping function, if none is given - one will be created from sampler
|
|
16
16
|
* @returns {HTMLCanvasElement} canvas
|
|
17
17
|
*/
|
|
18
18
|
function convertSampler2D2Canvas(sampler, scale = 255, offset = 0, canvas, fillDD) {
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* @param {Sampler2D} sampler
|
|
4
|
+
* @param {number} scale
|
|
5
|
+
* @param {number} offset
|
|
6
|
+
* @return {function(index:int, array:ArrayLike, x:int, y:int)}
|
|
7
|
+
*/
|
|
8
|
+
export function sampler2d_make_array_filler_function(sampler, scale=255, offset=0){
|
|
9
|
+
|
|
10
|
+
const v4 = [1 / scale, 1 / scale, 1 / scale, 1 / scale];
|
|
11
|
+
|
|
12
|
+
//
|
|
13
|
+
function fillDD1(index, array, x, y) {
|
|
14
|
+
const val = (sampler.sampleChannelBilinear(x, y, 0) + offset) * scale | 0;
|
|
15
|
+
array[index] = val;
|
|
16
|
+
array[index + 1] = val;
|
|
17
|
+
array[index + 2] = val;
|
|
18
|
+
array[index + 3] = 255;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function fillDD2(index, array, x, y) {
|
|
22
|
+
sampler.sampleBilinear(x, y, v4, 0);
|
|
23
|
+
const val = (v4[0] + offset) * scale | 0;
|
|
24
|
+
array.fill(val, index, index + 3);
|
|
25
|
+
array[index + 3] = (v4[1] + offset) * scale | 0;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function fillDD3(index, array, x, y) {
|
|
29
|
+
|
|
30
|
+
sampler.sampleBilinear(x, y, v4, 0);
|
|
31
|
+
|
|
32
|
+
array[index] = (v4[0] + offset) * scale | 0;
|
|
33
|
+
array[index + 1] = (v4[1] + offset) * scale | 0;
|
|
34
|
+
array[index + 2] = (v4[2] + offset) * scale | 0;
|
|
35
|
+
array[index + 3] = 255;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function fillDD4(index, array, x, y) {
|
|
39
|
+
sampler.sampleBilinear(x, y, v4, 0);
|
|
40
|
+
array[index] = (v4[0] + offset) * scale | 0;
|
|
41
|
+
array[index + 1] = (v4[1] + offset) * scale | 0;
|
|
42
|
+
array[index + 2] = (v4[2] + offset) * scale | 0;
|
|
43
|
+
array[index + 3] = (v4[3] + offset) * scale | 0;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
let fillDD;
|
|
47
|
+
switch (sampler.itemSize) {
|
|
48
|
+
case 1:
|
|
49
|
+
fillDD = fillDD1;
|
|
50
|
+
break;
|
|
51
|
+
case 2:
|
|
52
|
+
fillDD = fillDD2;
|
|
53
|
+
break;
|
|
54
|
+
case 3:
|
|
55
|
+
fillDD = fillDD3;
|
|
56
|
+
break;
|
|
57
|
+
case 4:
|
|
58
|
+
fillDD = fillDD4;
|
|
59
|
+
break;
|
|
60
|
+
default :
|
|
61
|
+
throw new Error("unsupported item size");
|
|
62
|
+
break;
|
|
63
|
+
}
|
|
64
|
+
return fillDD;
|
|
65
|
+
}
|
|
@@ -16,8 +16,8 @@ import { aabb2_contains, aabb2_overlapExists } from "../../../core/geom/AABB2.js
|
|
|
16
16
|
* @returns {TileMoveProgram}
|
|
17
17
|
*/
|
|
18
18
|
export function computeTileGridMove(tile, targetX, targetY, source, target) {
|
|
19
|
-
assert.
|
|
20
|
-
assert.
|
|
19
|
+
assert.isNumber(targetX, 'targetX');
|
|
20
|
+
assert.isNumber(targetY, 'targetY');
|
|
21
21
|
|
|
22
22
|
assert.defined(tile, 'tile');
|
|
23
23
|
assert.defined(source, 'source');
|