@woosh/meep-engine 2.138.12 → 2.138.15

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.
Files changed (58) hide show
  1. package/build/bundle-worker-image-decoder.js +1 -1
  2. package/editor/actions/concrete/PatchTerrainTextureAction.js +0 -2
  3. package/package.json +1 -1
  4. package/samples/terrain/from_image_2.js +2 -10
  5. package/src/engine/asset/loaders/image/ImageDecoderWorker.js +1 -1
  6. package/src/engine/asset/loaders/image/ImageRGBADataLoader.d.ts.map +1 -1
  7. package/src/engine/asset/loaders/image/ImageRGBADataLoader.js +6 -1
  8. package/src/engine/asset/loaders/image/png/PNGReader.d.ts +1 -99
  9. package/src/engine/asset/loaders/image/png/PNGReader.d.ts.map +1 -1
  10. package/src/engine/asset/loaders/image/png/PNGReader.js +31 -420
  11. package/src/engine/asset/loaders/image/png/chunk/png_chunk_decode_iTXt.d.ts +12 -0
  12. package/src/engine/asset/loaders/image/png/chunk/png_chunk_decode_iTXt.d.ts.map +1 -0
  13. package/src/engine/asset/loaders/image/png/chunk/png_chunk_decode_iTXt.js +53 -0
  14. package/src/engine/asset/loaders/image/png/chunk/png_chunk_decode_zTXt.d.ts +10 -0
  15. package/src/engine/asset/loaders/image/png/chunk/png_chunk_decode_zTXt.d.ts.map +1 -0
  16. package/src/engine/asset/loaders/image/png/chunk/png_chunk_decode_zTXt.js +42 -0
  17. package/src/engine/asset/loaders/image/png/filter/png_filter_unFilterAverage.d.ts +18 -0
  18. package/src/engine/asset/loaders/image/png/filter/png_filter_unFilterAverage.d.ts.map +1 -0
  19. package/src/engine/asset/loaders/image/png/filter/png_filter_unFilterAverage.js +59 -0
  20. package/src/engine/asset/loaders/image/png/filter/png_filter_unFilterNone.d.ts +17 -0
  21. package/src/engine/asset/loaders/image/png/filter/png_filter_unFilterNone.d.ts.map +1 -0
  22. package/src/engine/asset/loaders/image/png/filter/png_filter_unFilterNone.js +55 -0
  23. package/src/engine/asset/loaders/image/png/filter/png_filter_unFilterPaeth.d.ts +17 -0
  24. package/src/engine/asset/loaders/image/png/filter/png_filter_unFilterPaeth.d.ts.map +1 -0
  25. package/src/engine/asset/loaders/image/png/filter/png_filter_unFilterPaeth.js +74 -0
  26. package/src/engine/asset/loaders/image/png/filter/png_filter_unFilterSub.d.ts +15 -0
  27. package/src/engine/asset/loaders/image/png/filter/png_filter_unFilterSub.d.ts.map +1 -0
  28. package/src/engine/asset/loaders/image/png/filter/png_filter_unFilterSub.js +34 -0
  29. package/src/engine/asset/loaders/image/png/filter/png_filter_unFilterUp.d.ts +16 -0
  30. package/src/engine/asset/loaders/image/png/filter/png_filter_unFilterUp.d.ts.map +1 -0
  31. package/src/engine/asset/loaders/image/png/filter/png_filter_unFilterUp.js +46 -0
  32. package/src/engine/asset/loaders/image/png/inflate.d.ts +7 -0
  33. package/src/engine/asset/loaders/image/png/inflate.d.ts.map +1 -0
  34. package/src/engine/asset/loaders/image/png/inflate.js +20 -0
  35. package/src/engine/ecs/terrain/ecs/Terrain.js +1 -1
  36. package/src/engine/ecs/terrain/ecs/splat/SplatMapping.d.ts +0 -7
  37. package/src/engine/ecs/terrain/ecs/splat/SplatMapping.d.ts.map +1 -1
  38. package/src/engine/ecs/terrain/ecs/splat/SplatMapping.js +36 -19
  39. package/src/engine/graphics/impostors/octahedral/prototypeBaker.js +202 -8
  40. package/src/engine/graphics/impostors/octahedral/shader/ImpostorShaderDepthV0.d.ts +10 -0
  41. package/src/engine/graphics/impostors/octahedral/shader/ImpostorShaderDepthV0.d.ts.map +1 -0
  42. package/src/engine/graphics/impostors/octahedral/shader/ImpostorShaderDepthV0.js +395 -0
  43. package/src/engine/graphics/impostors/octahedral/shader/ImpostorShaderLitV0.d.ts +14 -0
  44. package/src/engine/graphics/impostors/octahedral/shader/ImpostorShaderLitV0.d.ts.map +1 -0
  45. package/src/engine/graphics/impostors/octahedral/shader/ImpostorShaderLitV0.js +757 -0
  46. package/src/engine/graphics/impostors/octahedral/shader/ImpostorShaderNormalsV0.d.ts +13 -0
  47. package/src/engine/graphics/impostors/octahedral/shader/ImpostorShaderNormalsV0.d.ts.map +1 -0
  48. package/src/engine/graphics/impostors/octahedral/shader/ImpostorShaderNormalsV0.js +380 -0
  49. package/src/engine/graphics/impostors/octahedral/shader/ImpostorShaderPerPixelV0.d.ts +6 -0
  50. package/src/engine/graphics/impostors/octahedral/shader/ImpostorShaderPerPixelV0.d.ts.map +1 -0
  51. package/src/engine/graphics/impostors/octahedral/shader/ImpostorShaderPerPixelV0.js +406 -0
  52. package/src/engine/graphics/impostors/octahedral/shader/ImpostorShaderV0.d.ts.map +1 -1
  53. package/src/engine/graphics/impostors/octahedral/shader/ImpostorShaderV0.js +8 -1
  54. package/src/engine/graphics/impostors/octahedral/shader/ImpostorShaderViewportDepthV0.d.ts +14 -0
  55. package/src/engine/graphics/impostors/octahedral/shader/ImpostorShaderViewportDepthV0.d.ts.map +1 -0
  56. package/src/engine/graphics/impostors/octahedral/shader/ImpostorShaderViewportDepthV0.js +356 -0
  57. package/src/engine/graphics/impostors/octahedral/shader/ImpostorShaderWireframeV0.d.ts.map +1 -1
  58. package/src/engine/graphics/impostors/octahedral/shader/ImpostorShaderWireframeV0.js +4 -1
@@ -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,7 @@
1
+ /**
2
+ *
3
+ * @param {Uint8Array} encoded_chunk
4
+ * @returns {ArrayBuffer}
5
+ */
6
+ export function inflate(encoded_chunk: Uint8Array): ArrayBuffer;
7
+ //# sourceMappingURL=inflate.d.ts.map
@@ -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
+ }
@@ -40,7 +40,7 @@ let idCounter = 0;
40
40
  * NOTE: edges of the terrain will typically result in patches smaller than this, so this is upper bound
41
41
  * @type {number}
42
42
  */
43
- const TILE_SIZE = 7;
43
+ const TILE_SIZE = 32;
44
44
 
45
45
  class Terrain {
46
46
  /**
@@ -17,12 +17,6 @@ export class SplatMapping {
17
17
  * @type {DataTexture2DArray}
18
18
  */
19
19
  weightTexture: DataTexture2DArray;
20
- /**
21
- * @deprecated No longer used due to poor blending results
22
- * stores indices of materials participating in the splat mix
23
- * @type {DataTexture}
24
- */
25
- materialTexture: DataTexture;
26
20
  toJSON(): {
27
21
  size: {
28
22
  x: number;
@@ -130,6 +124,5 @@ export class SplatMapping {
130
124
  }
131
125
  import Vector2 from "../../../../../core/geom/Vector2.js";
132
126
  import { DataTexture2DArray } from "three";
133
- import { DataTexture } from "three";
134
127
  import { Sampler2D } from "../../../../graphics/texture/sampler/Sampler2D.js";
135
128
  //# sourceMappingURL=SplatMapping.d.ts.map
@@ -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;IAO7F;;;;OAIG;IACH,iBAFU,WAAW,CAEoE;IAG7F;;;;;;;MAQC;IAED;;;;;;;aA6BC;IAED;;;;;OAKG;IACH,8BAJW,SAAS,SACT,MAAM,YACN,MAAM,QA0BhB;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,gBAGC;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;oBA5gBmB,qCAAqC;mCALiD,OAAO;4BAAP,OAAO;0BAUvF,mDAAmD"}
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"}
@@ -1,4 +1,4 @@
1
- import { DataTexture, DataTexture2DArray, LinearFilter, NearestFilter, RedFormat, UnsignedByteType } from "three";
1
+ import { DataTexture2DArray, LinearFilter, NearestFilter, RedFormat, UnsignedByteType } from "three";
2
2
  import { assert } from "../../../../../core/assert.js";
3
3
  import { Base64 } from "../../../../../core/binary/base64/Base64.js";
4
4
  import { array_copy } from "../../../../../core/collection/array/array_copy.js";
@@ -43,13 +43,8 @@ export class SplatMapping {
43
43
  this.weightTexture.type = UnsignedByteType;
44
44
  this.weightTexture.magFilter = LinearFilter;
45
45
  this.weightTexture.minFilter = NearestFilter;
46
+ this.weightTexture.needsUpdate = true;
46
47
 
47
- /**
48
- * @deprecated No longer used due to poor blending results
49
- * stores indices of materials participating in the splat mix
50
- * @type {DataTexture}
51
- */
52
- this.materialTexture = new DataTexture(new Uint8Array(width * height * 4), width, height);
53
48
  }
54
49
 
55
50
  toJSON() {
@@ -100,27 +95,50 @@ export class SplatMapping {
100
95
  * @param {number} channel
101
96
  */
102
97
  writeLayerFromSampler(source, index, channel = 0) {
103
- const weightData = this.weightData;
98
+ const weight_data = this.weightData;
104
99
 
105
100
  const width = this.size.x;
106
101
  const height = this.size.y;
107
102
 
108
103
  const dataOffset = index * width * height;
109
104
 
110
- for (let y = 0; y < height; y++) {
111
- const v = (y + 0.5) / height;
112
105
 
113
- for (let x = 0; x < width; x++) {
106
+ if (source.width === width && source.height === height) {
114
107
 
115
- const u = (x + 0.5) / width;
108
+ // special fast path
109
+ const pixel_count = width * height;
116
110
 
117
- const targetIndex = y * width + x;
118
- const targetAddress = dataOffset + targetIndex;
111
+ const source_channel_count = source.itemSize;
112
+ const source_data = source.data;
119
113
 
120
- const value = source.sampleChannelBilinearUV(u , v , channel);
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 {
121
119
 
122
- weightData[targetAddress] = value;
120
+ for (let y = 0; y < height; y++) {
121
+
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
+ }
123
140
  }
141
+
124
142
  }
125
143
 
126
144
  }
@@ -299,7 +317,7 @@ export class SplatMapping {
299
317
  * @returns {Uint8ClampedArray|Uint8Array}
300
318
  */
301
319
  get materialData() {
302
- return this.materialTexture.image.data;
320
+ throw new Error('deprecated, use getLayerWeightSampler');
303
321
  }
304
322
 
305
323
  /**
@@ -307,7 +325,7 @@ export class SplatMapping {
307
325
  * @return {Sampler2D}
308
326
  */
309
327
  get materialSampler() {
310
- return new Sampler2D(this.materialData, 4, this.size.x, this.size.y);
328
+ throw new Error('deprecated, use getLayerWeightSampler');
311
329
  }
312
330
 
313
331
  /**
@@ -368,7 +386,6 @@ export class SplatMapping {
368
386
 
369
387
  dispose() {
370
388
  this.weightTexture.dispose();
371
- this.materialTexture.dispose();
372
389
  }
373
390
 
374
391
  /**