@woosh/meep-engine 2.138.13 → 2.138.16
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/samples/terrain/from_image_2.js +2 -10
- package/src/engine/asset/loaders/image/ImageDecoderWorker.js +1 -1
- package/src/engine/asset/loaders/image/ImageRGBADataLoader.d.ts.map +1 -1
- package/src/engine/asset/loaders/image/ImageRGBADataLoader.js +6 -1
- package/src/engine/asset/loaders/image/png/PNGReader.d.ts +1 -99
- package/src/engine/asset/loaders/image/png/PNGReader.d.ts.map +1 -1
- package/src/engine/asset/loaders/image/png/PNGReader.js +31 -420
- package/src/engine/asset/loaders/image/png/chunk/png_chunk_decode_iTXt.d.ts +12 -0
- package/src/engine/asset/loaders/image/png/chunk/png_chunk_decode_iTXt.d.ts.map +1 -0
- package/src/engine/asset/loaders/image/png/chunk/png_chunk_decode_iTXt.js +53 -0
- package/src/engine/asset/loaders/image/png/chunk/png_chunk_decode_zTXt.d.ts +10 -0
- package/src/engine/asset/loaders/image/png/chunk/png_chunk_decode_zTXt.d.ts.map +1 -0
- package/src/engine/asset/loaders/image/png/chunk/png_chunk_decode_zTXt.js +42 -0
- package/src/engine/asset/loaders/image/png/filter/png_filter_unFilterAverage.d.ts +18 -0
- package/src/engine/asset/loaders/image/png/filter/png_filter_unFilterAverage.d.ts.map +1 -0
- package/src/engine/asset/loaders/image/png/filter/png_filter_unFilterAverage.js +59 -0
- package/src/engine/asset/loaders/image/png/filter/png_filter_unFilterNone.d.ts +17 -0
- package/src/engine/asset/loaders/image/png/filter/png_filter_unFilterNone.d.ts.map +1 -0
- package/src/engine/asset/loaders/image/png/filter/png_filter_unFilterNone.js +55 -0
- package/src/engine/asset/loaders/image/png/filter/png_filter_unFilterPaeth.d.ts +17 -0
- package/src/engine/asset/loaders/image/png/filter/png_filter_unFilterPaeth.d.ts.map +1 -0
- package/src/engine/asset/loaders/image/png/filter/png_filter_unFilterPaeth.js +74 -0
- package/src/engine/asset/loaders/image/png/filter/png_filter_unFilterSub.d.ts +15 -0
- package/src/engine/asset/loaders/image/png/filter/png_filter_unFilterSub.d.ts.map +1 -0
- package/src/engine/asset/loaders/image/png/filter/png_filter_unFilterSub.js +34 -0
- package/src/engine/asset/loaders/image/png/filter/png_filter_unFilterUp.d.ts +16 -0
- package/src/engine/asset/loaders/image/png/filter/png_filter_unFilterUp.d.ts.map +1 -0
- package/src/engine/asset/loaders/image/png/filter/png_filter_unFilterUp.js +46 -0
- package/src/engine/asset/loaders/image/png/inflate.d.ts +7 -0
- package/src/engine/asset/loaders/image/png/inflate.d.ts.map +1 -0
- package/src/engine/asset/loaders/image/png/inflate.js +20 -0
- package/src/engine/ecs/terrain/ecs/Terrain.js +1 -1
- package/src/engine/ecs/terrain/ecs/splat/SplatMapping.d.ts.map +1 -1
- package/src/engine/ecs/terrain/ecs/splat/SplatMapping.js +32 -9
- package/src/engine/graphics/impostors/octahedral/prototypeBaker.js +202 -8
- package/src/engine/graphics/impostors/octahedral/shader/ImpostorShaderDepthV0.d.ts +10 -0
- package/src/engine/graphics/impostors/octahedral/shader/ImpostorShaderDepthV0.d.ts.map +1 -0
- package/src/engine/graphics/impostors/octahedral/shader/ImpostorShaderDepthV0.js +418 -0
- package/src/engine/graphics/impostors/octahedral/shader/ImpostorShaderLitV0.d.ts +14 -0
- package/src/engine/graphics/impostors/octahedral/shader/ImpostorShaderLitV0.d.ts.map +1 -0
- package/src/engine/graphics/impostors/octahedral/shader/ImpostorShaderLitV0.js +757 -0
- package/src/engine/graphics/impostors/octahedral/shader/ImpostorShaderNormalsV0.d.ts +13 -0
- package/src/engine/graphics/impostors/octahedral/shader/ImpostorShaderNormalsV0.d.ts.map +1 -0
- package/src/engine/graphics/impostors/octahedral/shader/ImpostorShaderNormalsV0.js +380 -0
- package/src/engine/graphics/impostors/octahedral/shader/ImpostorShaderPerPixelV0.d.ts +6 -0
- package/src/engine/graphics/impostors/octahedral/shader/ImpostorShaderPerPixelV0.d.ts.map +1 -0
- package/src/engine/graphics/impostors/octahedral/shader/ImpostorShaderPerPixelV0.js +406 -0
- package/src/engine/graphics/impostors/octahedral/shader/ImpostorShaderV0.d.ts.map +1 -1
- package/src/engine/graphics/impostors/octahedral/shader/ImpostorShaderV0.js +8 -1
- package/src/engine/graphics/impostors/octahedral/shader/ImpostorShaderViewportDepthV0.d.ts +14 -0
- package/src/engine/graphics/impostors/octahedral/shader/ImpostorShaderViewportDepthV0.d.ts.map +1 -0
- package/src/engine/graphics/impostors/octahedral/shader/ImpostorShaderViewportDepthV0.js +356 -0
- package/src/engine/graphics/impostors/octahedral/shader/ImpostorShaderWireframeV0.d.ts.map +1 -1
- package/src/engine/graphics/impostors/octahedral/shader/ImpostorShaderWireframeV0.js +4 -1
- package/src/engine/graphics/shaders/TerrainShader.js +2 -2
- package/src/engine/intelligence/mcts/MonteCarlo.d.ts +35 -4
- package/src/engine/intelligence/mcts/MonteCarlo.d.ts.map +1 -1
- package/src/engine/intelligence/mcts/MonteCarlo.js +101 -31
- package/src/engine/intelligence/mcts/StateNode.d.ts +47 -24
- package/src/engine/intelligence/mcts/StateNode.d.ts.map +1 -1
- package/src/engine/intelligence/mcts/StateNode.js +364 -316
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `Average` filter uses the average of the two neighboring pixels (left
|
|
3
|
+
* and above) to predict the value of a pixel.
|
|
4
|
+
*
|
|
5
|
+
* `Average(x) = Raw(x) + floor((Raw(x-bpp)+Prior(x))/2)`
|
|
6
|
+
*
|
|
7
|
+
* @param {Uint8Array} scanline raw data
|
|
8
|
+
* @param {number} scanline_offset
|
|
9
|
+
* @param {Uint8Array} pixels processed output
|
|
10
|
+
* @param {number} bpp bytes-per-pixel
|
|
11
|
+
* @param {number} offset
|
|
12
|
+
* @param {number} output_offset_previous pass a negative value when there is no previous scanline
|
|
13
|
+
* @param {number} length
|
|
14
|
+
*
|
|
15
|
+
* @see https://www.w3.org/TR/PNG-Filters.html
|
|
16
|
+
*/
|
|
17
|
+
export function png_filter_unFilterAverage(
|
|
18
|
+
scanline,
|
|
19
|
+
scanline_offset,
|
|
20
|
+
pixels,
|
|
21
|
+
bpp,
|
|
22
|
+
offset,
|
|
23
|
+
output_offset_previous,
|
|
24
|
+
length
|
|
25
|
+
) {
|
|
26
|
+
let i = 0, byte, prev, prior;
|
|
27
|
+
|
|
28
|
+
if (output_offset_previous < 0) {
|
|
29
|
+
|
|
30
|
+
// Prior(x) == 0 && Raw(x - bpp) == 0
|
|
31
|
+
for (; i < bpp; i++) {
|
|
32
|
+
pixels[offset + i] = scanline[i + scanline_offset];
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// Prior(x) == 0 && Raw(x - bpp) != 0 (right shift, prevent doubles)
|
|
36
|
+
for (; i < length; i++) {
|
|
37
|
+
const of_i = offset + i;
|
|
38
|
+
pixels[of_i] = (scanline[i + scanline_offset] + (pixels[of_i - bpp] >> 1)) & 0xFF;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
} else {
|
|
42
|
+
|
|
43
|
+
// Prior(x) != 0 && Raw(x - bpp) == 0
|
|
44
|
+
for (; i < bpp; i++) {
|
|
45
|
+
pixels[offset + i] = (scanline[i + scanline_offset] + (pixels[output_offset_previous + i] >> 1)) & 0xFF;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// Prior(x) != 0 && Raw(x - bpp) != 0
|
|
49
|
+
for (; i < length; i++) {
|
|
50
|
+
byte = scanline[i + scanline_offset];
|
|
51
|
+
|
|
52
|
+
prev = pixels[offset + i - bpp];
|
|
53
|
+
prior = pixels[output_offset_previous + i];
|
|
54
|
+
|
|
55
|
+
pixels[offset + i] = (byte + (prev + prior >> 1)) & 0xFF;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
}
|
|
59
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* With the None filter, the scanline is transmitted unmodified; it is only necessary to insert a filter type byte before the data.
|
|
3
|
+
*
|
|
4
|
+
* For depths < 8 the scanline byte is unpacked into individual samples; for depths 8 and 16 the bytes are copied straight through
|
|
5
|
+
* (16-bit samples are stored as two big-endian bytes per channel — the filter layer still operates byte-wise).
|
|
6
|
+
*
|
|
7
|
+
* @param {Uint8Array} data
|
|
8
|
+
* @param {number} scanline_address
|
|
9
|
+
* @param {Uint8Array} output
|
|
10
|
+
* @param {number} output_offset
|
|
11
|
+
* @param {number} length number of bytes (depth >= 8) or samples (depth < 8) to produce
|
|
12
|
+
* @param {number} bit_depth one of 1, 2, 4, 8, 16
|
|
13
|
+
*
|
|
14
|
+
* @see https://www.w3.org/TR/PNG-Filters.html
|
|
15
|
+
*/
|
|
16
|
+
export function png_filter_unFilterNone(data: Uint8Array, scanline_address: number, output: Uint8Array, output_offset: number, length: number, bit_depth: number): void;
|
|
17
|
+
//# sourceMappingURL=png_filter_unFilterNone.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"png_filter_unFilterNone.d.ts","sourceRoot":"","sources":["../../../../../../../../src/engine/asset/loaders/image/png/filter/png_filter_unFilterNone.js"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,8CATW,UAAU,oBACV,MAAM,UACN,UAAU,iBACV,MAAM,UACN,MAAM,aACN,MAAM,QA2ChB"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* With the None filter, the scanline is transmitted unmodified; it is only necessary to insert a filter type byte before the data.
|
|
3
|
+
*
|
|
4
|
+
* For depths < 8 the scanline byte is unpacked into individual samples; for depths 8 and 16 the bytes are copied straight through
|
|
5
|
+
* (16-bit samples are stored as two big-endian bytes per channel — the filter layer still operates byte-wise).
|
|
6
|
+
*
|
|
7
|
+
* @param {Uint8Array} data
|
|
8
|
+
* @param {number} scanline_address
|
|
9
|
+
* @param {Uint8Array} output
|
|
10
|
+
* @param {number} output_offset
|
|
11
|
+
* @param {number} length number of bytes (depth >= 8) or samples (depth < 8) to produce
|
|
12
|
+
* @param {number} bit_depth one of 1, 2, 4, 8, 16
|
|
13
|
+
*
|
|
14
|
+
* @see https://www.w3.org/TR/PNG-Filters.html
|
|
15
|
+
*/
|
|
16
|
+
export function png_filter_unFilterNone(
|
|
17
|
+
data,
|
|
18
|
+
scanline_address,
|
|
19
|
+
output,
|
|
20
|
+
output_offset,
|
|
21
|
+
length,
|
|
22
|
+
bit_depth
|
|
23
|
+
) {
|
|
24
|
+
if (bit_depth === 1) {
|
|
25
|
+
for (let x = 0; x < length; x++) {
|
|
26
|
+
const q = x >>> 4;
|
|
27
|
+
const datum = data[q + scanline_address];
|
|
28
|
+
const shift = ((x) & 0x7);
|
|
29
|
+
const out_value = (datum >>> shift) & 0x1;
|
|
30
|
+
output[output_offset + x] = out_value;
|
|
31
|
+
}
|
|
32
|
+
} else if (bit_depth === 2) {
|
|
33
|
+
for (let x = 0; x < length; x++) {
|
|
34
|
+
const q = x >>> 2;
|
|
35
|
+
const datum = data[q + scanline_address];
|
|
36
|
+
const shift = ((~x) & 0x3) << 1;
|
|
37
|
+
const out_value = (datum >>> shift) & 0x3;
|
|
38
|
+
output[output_offset + x] = out_value;
|
|
39
|
+
}
|
|
40
|
+
} else if (bit_depth === 4) {
|
|
41
|
+
for (let x = 0; x < length; x++) {
|
|
42
|
+
const q = x >>> 1;
|
|
43
|
+
const datum = data[q + scanline_address];
|
|
44
|
+
const shift = ((~x) & 0x1) << 2;
|
|
45
|
+
const out_value = (datum >>> shift) & 0xF;
|
|
46
|
+
output[output_offset + x] = out_value;
|
|
47
|
+
}
|
|
48
|
+
} else if (bit_depth === 8 || bit_depth === 16) {
|
|
49
|
+
for (let x = 0; x < length; x++) {
|
|
50
|
+
output[output_offset + x] = data[x + scanline_address];
|
|
51
|
+
}
|
|
52
|
+
} else {
|
|
53
|
+
throw new Error(`unsupported bit depth ${bit_depth}`);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `Paeth` filter computes a simple linear function of the three neighboring pixels (left, above, upper left), then chooses as predictor the neighboring pixel closest to the computed value.
|
|
3
|
+
*
|
|
4
|
+
* This technique is due to Alan W. Paeth.
|
|
5
|
+
*
|
|
6
|
+
* @param {Uint8Array} scanline raw data
|
|
7
|
+
* @param {number} scanline_offset
|
|
8
|
+
* @param {Uint8Array} pixels processed output
|
|
9
|
+
* @param {number} bpp bytes-per-pixel
|
|
10
|
+
* @param {number} offset
|
|
11
|
+
* @param {number} output_offset_previous pass a negative value when there is no previous scanline
|
|
12
|
+
* @param {number} length
|
|
13
|
+
*
|
|
14
|
+
* @see https://www.w3.org/TR/PNG-Filters.html
|
|
15
|
+
*/
|
|
16
|
+
export function png_filter_unFilterPaeth(scanline: Uint8Array, scanline_offset: number, pixels: Uint8Array, bpp: number, offset: number, output_offset_previous: number, length: number): void;
|
|
17
|
+
//# sourceMappingURL=png_filter_unFilterPaeth.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"png_filter_unFilterPaeth.d.ts","sourceRoot":"","sources":["../../../../../../../../src/engine/asset/loaders/image/png/filter/png_filter_unFilterPaeth.js"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,mDAVW,UAAU,mBACV,MAAM,UACN,UAAU,OACV,MAAM,UACN,MAAM,0BACN,MAAM,UACN,MAAM,QA8DhB"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `Paeth` filter computes a simple linear function of the three neighboring pixels (left, above, upper left), then chooses as predictor the neighboring pixel closest to the computed value.
|
|
3
|
+
*
|
|
4
|
+
* This technique is due to Alan W. Paeth.
|
|
5
|
+
*
|
|
6
|
+
* @param {Uint8Array} scanline raw data
|
|
7
|
+
* @param {number} scanline_offset
|
|
8
|
+
* @param {Uint8Array} pixels processed output
|
|
9
|
+
* @param {number} bpp bytes-per-pixel
|
|
10
|
+
* @param {number} offset
|
|
11
|
+
* @param {number} output_offset_previous pass a negative value when there is no previous scanline
|
|
12
|
+
* @param {number} length
|
|
13
|
+
*
|
|
14
|
+
* @see https://www.w3.org/TR/PNG-Filters.html
|
|
15
|
+
*/
|
|
16
|
+
export function png_filter_unFilterPaeth(
|
|
17
|
+
scanline,
|
|
18
|
+
scanline_offset,
|
|
19
|
+
pixels,
|
|
20
|
+
bpp,
|
|
21
|
+
offset,
|
|
22
|
+
output_offset_previous,
|
|
23
|
+
length
|
|
24
|
+
) {
|
|
25
|
+
let i = 0, raw, a, b, c, p, pa, pb, pc, pr;
|
|
26
|
+
|
|
27
|
+
if (output_offset_previous < 0) {
|
|
28
|
+
|
|
29
|
+
// Prior(x) == 0 && Raw(x - bpp) == 0
|
|
30
|
+
for (; i < bpp; i++) {
|
|
31
|
+
pixels[offset + i] = scanline[i + scanline_offset];
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// Prior(x) == 0 && Raw(x - bpp) != 0
|
|
35
|
+
// paethPredictor(x, 0, 0) is always x
|
|
36
|
+
for (; i < length; i++) {
|
|
37
|
+
pixels[offset + i] = (scanline[i + scanline_offset] + pixels[offset + i - bpp]) & 0xFF;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
} else {
|
|
41
|
+
|
|
42
|
+
// Prior(x) != 0 && Raw(x - bpp) == 0
|
|
43
|
+
// paethPredictor(x, 0, 0) is always x
|
|
44
|
+
for (; i < bpp; i++) {
|
|
45
|
+
pixels[offset + i] = (scanline[i + scanline_offset] + pixels[output_offset_previous + i]) & 0xFF;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// Prior(x) != 0 && Raw(x - bpp) != 0
|
|
49
|
+
for (; i < length; i++) {
|
|
50
|
+
raw = scanline[i + scanline_offset];
|
|
51
|
+
|
|
52
|
+
c = pixels[output_offset_previous + i - bpp];
|
|
53
|
+
b = pixels[output_offset_previous + i];
|
|
54
|
+
a = pixels[offset + i - bpp];
|
|
55
|
+
|
|
56
|
+
p = a + b - c;
|
|
57
|
+
|
|
58
|
+
pa = Math.abs(p - a);
|
|
59
|
+
pb = Math.abs(p - b);
|
|
60
|
+
pc = Math.abs(p - c);
|
|
61
|
+
|
|
62
|
+
if (pa <= pb && pa <= pc) {
|
|
63
|
+
pr = a;
|
|
64
|
+
} else if (pb <= pc) {
|
|
65
|
+
pr = b;
|
|
66
|
+
} else {
|
|
67
|
+
pr = c;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
pixels[offset + i] = (raw + pr) & 0xFF;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
}
|
|
74
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `Sub` filter transmits the difference between each byte and the value
|
|
3
|
+
* of the corresponding byte of the prior pixel.
|
|
4
|
+
* `Sub(x) = Raw(x) + Raw(x - bpp)`
|
|
5
|
+
*
|
|
6
|
+
* @param {Uint8Array} scanline raw data
|
|
7
|
+
* @param {number} scanline_offset
|
|
8
|
+
* @param {Uint8Array} pixels processed output
|
|
9
|
+
* @param {number} bpp bytes-per-pixel
|
|
10
|
+
* @param {number} offset
|
|
11
|
+
* @param {number} length
|
|
12
|
+
* @see https://www.w3.org/TR/PNG-Filters.html
|
|
13
|
+
*/
|
|
14
|
+
export function png_filter_unFilterSub(scanline: Uint8Array, scanline_offset: number, pixels: Uint8Array, bpp: number, offset: number, length: number): void;
|
|
15
|
+
//# sourceMappingURL=png_filter_unFilterSub.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"png_filter_unFilterSub.d.ts","sourceRoot":"","sources":["../../../../../../../../src/engine/asset/loaders/image/png/filter/png_filter_unFilterSub.js"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,iDARW,UAAU,mBACV,MAAM,UACN,UAAU,OACV,MAAM,UACN,MAAM,UACN,MAAM,QAuBhB"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `Sub` filter transmits the difference between each byte and the value
|
|
3
|
+
* of the corresponding byte of the prior pixel.
|
|
4
|
+
* `Sub(x) = Raw(x) + Raw(x - bpp)`
|
|
5
|
+
*
|
|
6
|
+
* @param {Uint8Array} scanline raw data
|
|
7
|
+
* @param {number} scanline_offset
|
|
8
|
+
* @param {Uint8Array} pixels processed output
|
|
9
|
+
* @param {number} bpp bytes-per-pixel
|
|
10
|
+
* @param {number} offset
|
|
11
|
+
* @param {number} length
|
|
12
|
+
* @see https://www.w3.org/TR/PNG-Filters.html
|
|
13
|
+
*/
|
|
14
|
+
export function png_filter_unFilterSub(
|
|
15
|
+
scanline,
|
|
16
|
+
scanline_offset,
|
|
17
|
+
pixels,
|
|
18
|
+
bpp,
|
|
19
|
+
offset,
|
|
20
|
+
length
|
|
21
|
+
) {
|
|
22
|
+
|
|
23
|
+
let i = 0;
|
|
24
|
+
|
|
25
|
+
for (; i < bpp; i++) {
|
|
26
|
+
pixels[offset + i] = scanline[i + scanline_offset];
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
for (; i < length; i++) {
|
|
30
|
+
// Raw(x) + Raw(x - bpp)
|
|
31
|
+
const of_i = offset + i;
|
|
32
|
+
pixels[of_i] = (scanline[i + scanline_offset] + pixels[of_i - bpp]) & 0xFF;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `Up` filter is just like the Sub() filter except that the pixel
|
|
3
|
+
* immediately above the current pixel, rather than just to its left, is used
|
|
4
|
+
* as the predictor.
|
|
5
|
+
* `Up(x) = Raw(x) + Prior(x)`
|
|
6
|
+
*
|
|
7
|
+
* @param {Uint8Array} scanline raw data
|
|
8
|
+
* @param {number} scanline_offset
|
|
9
|
+
* @param {Uint8Array} pixels processed output
|
|
10
|
+
* @param {number} offset
|
|
11
|
+
* @param {number} output_offset_previous pass a negative value when there is no previous scanline
|
|
12
|
+
* @param {number} length
|
|
13
|
+
* @see https://www.w3.org/TR/PNG-Filters.html
|
|
14
|
+
*/
|
|
15
|
+
export function png_filter_unFilterUp(scanline: Uint8Array, scanline_offset: number, pixels: Uint8Array, offset: number, output_offset_previous: number, length: number): void;
|
|
16
|
+
//# sourceMappingURL=png_filter_unFilterUp.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"png_filter_unFilterUp.d.ts","sourceRoot":"","sources":["../../../../../../../../src/engine/asset/loaders/image/png/filter/png_filter_unFilterUp.js"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,gDARW,UAAU,mBACV,MAAM,UACN,UAAU,UACV,MAAM,0BACN,MAAM,UACN,MAAM,QAkChB"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `Up` filter is just like the Sub() filter except that the pixel
|
|
3
|
+
* immediately above the current pixel, rather than just to its left, is used
|
|
4
|
+
* as the predictor.
|
|
5
|
+
* `Up(x) = Raw(x) + Prior(x)`
|
|
6
|
+
*
|
|
7
|
+
* @param {Uint8Array} scanline raw data
|
|
8
|
+
* @param {number} scanline_offset
|
|
9
|
+
* @param {Uint8Array} pixels processed output
|
|
10
|
+
* @param {number} offset
|
|
11
|
+
* @param {number} output_offset_previous pass a negative value when there is no previous scanline
|
|
12
|
+
* @param {number} length
|
|
13
|
+
* @see https://www.w3.org/TR/PNG-Filters.html
|
|
14
|
+
*/
|
|
15
|
+
export function png_filter_unFilterUp(
|
|
16
|
+
scanline,
|
|
17
|
+
scanline_offset,
|
|
18
|
+
pixels,
|
|
19
|
+
offset,
|
|
20
|
+
output_offset_previous,
|
|
21
|
+
length
|
|
22
|
+
) {
|
|
23
|
+
let i = 0, byte, prev;
|
|
24
|
+
|
|
25
|
+
// Prior(x) is 0 for all x on the first scanline
|
|
26
|
+
if (output_offset_previous < 0) {
|
|
27
|
+
|
|
28
|
+
for (; i < length; i++) {
|
|
29
|
+
pixels[offset + i] = scanline[i + scanline_offset];
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
} else {
|
|
33
|
+
|
|
34
|
+
for (; i < length; i++) {
|
|
35
|
+
|
|
36
|
+
// Raw(x)
|
|
37
|
+
byte = scanline[i + scanline_offset];
|
|
38
|
+
|
|
39
|
+
// Prior(x)
|
|
40
|
+
prev = pixels[output_offset_previous + i];
|
|
41
|
+
|
|
42
|
+
pixels[offset + i] = (byte + prev) & 0xFF;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inflate.d.ts","sourceRoot":"","sources":["../../../../../../../src/engine/asset/loaders/image/png/inflate.js"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,uCAHW,UAAU,GACR,WAAW,CAcvB"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import zlib from "pako";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
*
|
|
5
|
+
* @param {Uint8Array} encoded_chunk
|
|
6
|
+
* @returns {ArrayBuffer}
|
|
7
|
+
*/
|
|
8
|
+
export function inflate(encoded_chunk) {
|
|
9
|
+
const inflator = new zlib.Inflate();
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
inflator.push(encoded_chunk);
|
|
13
|
+
|
|
14
|
+
if (inflator.err) {
|
|
15
|
+
throw new Error(inflator.err);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
return inflator.result.buffer;
|
|
20
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SplatMapping.d.ts","sourceRoot":"","sources":["../../../../../../../src/engine/ecs/terrain/ecs/splat/SplatMapping.js"],"names":[],"mappings":"AAaA;;GAEG;AACH;IAEQ;;;OAGG;IACH,MAFU,OAAO,CAEY;IAE7B;;;OAGG;IACH,OAFU,MAAM,CAEF;IAOd;;;OAGG;IACH,eAFU,kBAAkB,CAEiE;IAUjG;;;;;;;MAQC;IAED;;;;;;;aA6BC;IAED;;;;;OAKG;IACH,8BAJW,SAAS,SACT,MAAM,YACN,MAAM,
|
|
1
|
+
{"version":3,"file":"SplatMapping.d.ts","sourceRoot":"","sources":["../../../../../../../src/engine/ecs/terrain/ecs/splat/SplatMapping.js"],"names":[],"mappings":"AAaA;;GAEG;AACH;IAEQ;;;OAGG;IACH,MAFU,OAAO,CAEY;IAE7B;;;OAGG;IACH,OAFU,MAAM,CAEF;IAOd;;;OAGG;IACH,eAFU,kBAAkB,CAEiE;IAUjG;;;;;;;MAQC;IAED;;;;;;;aA6BC;IAED;;;;;OAKG;IACH,8BAJW,SAAS,SACT,MAAM,YACN,MAAM,QAiDhB;IAED;;;;;OAKG;IACH,gCAJW,SAAS,SACT,MAAM,YACN,MAAM,QA2BhB;IAED;;;;;;;OAOG;IACH,wBANW,UAAU,gBACV,MAAM,gBACN,MAAM,eACN,MAAM,gBACN,MAAM,QA2ChB;IAED;;;;;;;OAOG;IACH,4BANW,UAAU,WACV,MAAM,WACN,MAAM,SACN,MAAM,UACN,MAAM,QAuChB;IAED;;;;;;OAMG;IACH,gBALW,MAAM,KACN,MAAM,iBACN,MAAM,GACJ,MAAM,CAKlB;IAED;;;;OAIG;IACH,6BAHW,MAAM,GACJ,SAAS,CAcrB;IAED;;OAEG;IACH,iDAEC;IAED;;;OAGG;IACH,mDAEC;IAED;;;OAGG;IACH,iCAEC;IAED;;;;OAIG;IACH,gCAHW,UAAU,QAoDpB;IAED,gBAEC;IAED;;;;OAIG;IACH,yBAHW,MAAM,GACJ,OAAO,CAuCnB;IAED;;;;OAIG;IACH,8BAHW,MAAM,SACN,MAAM,QAqBhB;IAED,uBAiBC;IAED;;;;;;OAMG;IACH,cALW,MAAM,UACN,MAAM,SACN,MAAM,cACN,OAAO,QA6DjB;CACJ;oBA7hBmB,qCAAqC;mCALoC,OAAO;0BAU1E,mDAAmD"}
|
|
@@ -95,27 +95,50 @@ export class SplatMapping {
|
|
|
95
95
|
* @param {number} channel
|
|
96
96
|
*/
|
|
97
97
|
writeLayerFromSampler(source, index, channel = 0) {
|
|
98
|
-
const
|
|
98
|
+
const weight_data = this.weightData;
|
|
99
99
|
|
|
100
100
|
const width = this.size.x;
|
|
101
101
|
const height = this.size.y;
|
|
102
102
|
|
|
103
103
|
const dataOffset = index * width * height;
|
|
104
104
|
|
|
105
|
-
for (let y = 0; y < height; y++) {
|
|
106
|
-
const v = (y + 0.5) / height;
|
|
107
105
|
|
|
108
|
-
|
|
106
|
+
if (source.width === width && source.height === height) {
|
|
109
107
|
|
|
110
|
-
|
|
108
|
+
// special fast path
|
|
109
|
+
const pixel_count = width * height;
|
|
111
110
|
|
|
112
|
-
|
|
113
|
-
|
|
111
|
+
const source_channel_count = source.itemSize;
|
|
112
|
+
const source_data = source.data;
|
|
113
|
+
|
|
114
|
+
for (let i = 0; i < pixel_count; i++) {
|
|
115
|
+
weight_data[dataOffset + i] = source_data[i * source_channel_count + channel]
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
} else {
|
|
114
119
|
|
|
115
|
-
|
|
120
|
+
for (let y = 0; y < height; y++) {
|
|
116
121
|
|
|
117
|
-
|
|
122
|
+
const v = (y + 0.5) / height;
|
|
123
|
+
|
|
124
|
+
for (let x = 0; x < width; x++) {
|
|
125
|
+
|
|
126
|
+
const u = (x + 0.5) / width;
|
|
127
|
+
|
|
128
|
+
const targetIndex = y * width + x;
|
|
129
|
+
const targetAddress = dataOffset + targetIndex;
|
|
130
|
+
|
|
131
|
+
let value = source.sampleChannelBilinearUV(u, v, channel);
|
|
132
|
+
|
|
133
|
+
if (value > 0 && value < 1) {
|
|
134
|
+
// avoid collapse to 0
|
|
135
|
+
value = 1;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
weight_data[targetAddress] = value;
|
|
139
|
+
}
|
|
118
140
|
}
|
|
141
|
+
|
|
119
142
|
}
|
|
120
143
|
|
|
121
144
|
}
|