@woosh/meep-engine 2.34.3 → 2.34.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.
@@ -88,9 +88,15 @@ test('replaceAnotherVertex', () => {
88
88
  v_b.addEdge(e_b);
89
89
 
90
90
  f_a.setVertexAt(0, v_a);
91
+ f_a.setVertexAt(1, new TopoVertex());
92
+ f_a.setVertexAt(2, new TopoVertex());
93
+
91
94
  e_a.v0 = v_a;
92
95
 
93
96
  f_b.setVertexAt(0, v_b);
97
+ f_b.setVertexAt(1, new TopoVertex());
98
+ f_b.setVertexAt(2, new TopoVertex());
99
+
94
100
  e_b.v0 = v_b;
95
101
 
96
102
  // verify assumptions about topology
@@ -1,4 +1,4 @@
1
- import { objectDeepEquals } from "./objectDeepEquals.d.ts";
1
+ import { objectDeepEquals } from "./objectDeepEquals.js";
2
2
 
3
3
  test('objectDeepEquals', () => {
4
4
  expect(objectDeepEquals({}, {})).toBe(true);
@@ -23,7 +23,7 @@ async function decode_png(png_bytes) {
23
23
  width,
24
24
  height,
25
25
  itemSize: uint_channels.itemSize,
26
- bitDepth: uint_channels.bitDepth
26
+ bitDepth: png.bitDepth
27
27
  });
28
28
  });
29
29
  }
@@ -41,6 +41,12 @@ export class ImageRGBADataLoader extends AssetLoader {
41
41
  return await this.decoder.decode(new Uint8Array(array_buffer));
42
42
  }
43
43
 
44
+ /**
45
+ *
46
+ * @param {String} path
47
+ * @return {Promise<ImageRGBADataAsset>}
48
+ * @private
49
+ */
44
50
  async __standard(path) {
45
51
 
46
52
  const bitmap = await this.__decode_via_worker(path);
@@ -48,19 +54,19 @@ export class ImageRGBADataLoader extends AssetLoader {
48
54
 
49
55
  let data;
50
56
 
51
- switch (bitmap.bitDepth) {
52
- case 8:
57
+ const bitDepth = bitmap.bitDepth;
53
58
 
59
+ switch (bitDepth) {
60
+ case 8:
54
61
  data = new Uint8Array(bitmap.data);
55
62
  break
56
63
  case 16:
57
64
  data = new Uint16Array(bitmap.data);
58
65
  break;
59
66
  default:
60
- throw new Error(`Unsupported bit depth '${bitmap.bitDepth}'`);
67
+ throw new Error(`Unsupported bit depth '${bitDepth}'. path='${path}'`);
61
68
  }
62
69
 
63
-
64
70
  return new ImageRGBADataAsset(data, bitmap.width, bitmap.height, bitmap.itemSize);
65
71
  }
66
72
 
@@ -2,7 +2,7 @@ import { Codec } from "./Codec.js";
2
2
 
3
3
  /**
4
4
  *
5
- * @param {Image|ImageBitmap} img
5
+ * @param {Image|ImageBitmap|HTMLImageElement} img
6
6
  * @returns {Uint8Array}
7
7
  */
8
8
  function decode(img) {
@@ -28,10 +28,12 @@ export class NativeImageDecoder extends Codec {
28
28
  async decode(data) {
29
29
  const image = new Image();
30
30
 
31
+ // convert binary data to image URL that we can load
31
32
  const url = URL.createObjectURL(new Blob([data]));
32
33
 
33
34
  image.src = url;
34
35
 
36
+ // give browser a chance to decode image in async
35
37
  await image.decode();
36
38
 
37
39
  const rgba_data = decode(image);
@@ -24,6 +24,7 @@ export class ThreadedImageDecoder extends Codec {
24
24
  }
25
25
 
26
26
  async decode(data) {
27
- return await this.worker.request('decode', [data.buffer]);
27
+ const result = await this.worker.request('decode', [data.buffer]);
28
+ return result;
28
29
  }
29
30
  }
@@ -343,7 +343,9 @@ PNG.prototype.getUint8Data_case3 = function () {
343
343
  for (let i = 0; i < pixel_count; i++) {
344
344
  const destination_address = i * itemSize;
345
345
 
346
- const lookup_value = pixels[i * d];
346
+ const lookup_index = pixels[i * d];
347
+
348
+ const lookup_value = lookup_index * 3;
347
349
 
348
350
  result_data[destination_address] = palette[lookup_value];
349
351
  result_data[destination_address + 1] = palette[lookup_value + 1];
@@ -381,7 +383,12 @@ PNG.prototype.getUint8Data = function () {
381
383
  break;
382
384
  case 3:
383
385
  // palette
384
- return this.getUint8Data_case3();
386
+ const c3 = this.getUint8Data_case3();
387
+
388
+ data = c3.data;
389
+ itemSize = c3.itemSize;
390
+
391
+ break;
385
392
  case 4:
386
393
  // grayscale with alpha
387
394
  data = this.pixels;
@@ -397,7 +404,6 @@ PNG.prototype.getUint8Data = function () {
397
404
 
398
405
  return {
399
406
  data,
400
- itemSize,
401
- bitDepth: this.bitDepth
407
+ itemSize
402
408
  };
403
409
  };
@@ -2,7 +2,7 @@
2
2
  * Transfer bitmap contents to Sampler2D, effectively moving data to CPU, making it readable
3
3
  * @param {WebGL2RenderingContext} gl
4
4
  * @param {Sampler2D} sampler
5
- * @param {ImageBitmap} bitmap
5
+ * @param {ImageBitmap|ImageData|HTMLImageElement|HTMLCanvasElement|HTMLVideoElement} bitmap
6
6
  */
7
7
  export function bitmap2sampler_gl(gl, sampler, bitmap) {
8
8
  gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, bitmap);
@@ -15,5 +15,11 @@ export function bitmap2sampler_gl(gl, sampler, bitmap) {
15
15
  throw new Error(`Expected sampler.itemSize to be 4, instead was '${sampler.itemSize}'`);
16
16
  }
17
17
 
18
- gl.readPixels(0, 0, w, h, gl.RGBA, gl.UNSIGNED_BYTE, sampler.data);
18
+ /**
19
+ *
20
+ * @type {Uint8ClampedArray}
21
+ */
22
+ const target_data = sampler.data;
23
+
24
+ gl.readPixels(0, 0, w, h, gl.RGBA, gl.UNSIGNED_BYTE, target_data);
19
25
  }
@@ -78,6 +78,9 @@ export function textureImagesEqual(a, b) {
78
78
  if (a.src === b.src) {
79
79
  //same source
80
80
  return true;
81
+ } else {
82
+ // different source, assume images are different too
83
+ return false;
81
84
  }
82
85
  }
83
86
 
@@ -2,6 +2,7 @@ import { computeImageBitmapHash } from "./computeImageBitmapHash.js";
2
2
  import { computeHashIntegerArray } from "../../../../core/collection/array/computeHashIntegerArray.js";
3
3
  import { computeHashFloat } from "../../../../core/math/hash/computeHashFloat.js";
4
4
  import { murmur3_32 } from "../../../../core/math/hash/murmur3_32.js";
5
+ import { computeStringHash } from "../../../../core/primitives/strings/computeStringHash.js";
5
6
 
6
7
  /**
7
8
  *
@@ -20,6 +21,11 @@ function vector2Hash(v) {
20
21
  */
21
22
  const data_cache = new WeakMap();
22
23
 
24
+ /**
25
+ *
26
+ * @param {ImageBitmap|HTMLImageElement|{data,width:number,height:number}} image
27
+ * @return {number}
28
+ */
23
29
  export function computeImageDataHash(image) {
24
30
  const cached_value = data_cache.get(image);
25
31
 
@@ -31,6 +37,8 @@ export function computeImageDataHash(image) {
31
37
 
32
38
  if (image instanceof ImageBitmap) {
33
39
  result = computeImageBitmapHash(image);
40
+ } else if (image instanceof HTMLImageElement) {
41
+ result = computeStringHash(image.src);
34
42
  }
35
43
 
36
44
  let width = 0;
@@ -125,15 +125,15 @@ class GLTFAssetTransformer extends AssetTransformer {
125
125
  /**
126
126
  *
127
127
  * @param {Asset} source
128
- * @param asset_description
128
+ * @param {AssetDescription} asset_description
129
129
  * @return {Promise<Asset>}
130
130
  */
131
131
  async transform(source, asset_description) {
132
132
  const animationClips = source.animations;
133
133
 
134
134
  if (animationClips !== undefined && animationClips.length > 0) {
135
- // not suitable
136
- return source;
135
+ // animations might cause trouble
136
+ console.warn(`model '${asset_description.path}' contains animations, these animations might not works as intended with micron.`);
137
137
  }
138
138
 
139
139
  /**
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "productName": "Meep",
6
6
  "description": "production-ready JavaScript game engine based on Entity Component System Architecture",
7
7
  "author": "Alexander Goldring",
8
- "version": "2.34.3",
8
+ "version": "2.34.7",
9
9
  "dependencies": {
10
10
  "gl-matrix": "3.4.3",
11
11
  "fast-levenshtein": "2.0.6",
@@ -20,6 +20,7 @@ import { copy_Sampler2D_channel_data } from "../../engine/graphics/texture/sampl
20
20
  import { TextureAssetLoader } from "../../engine/asset/loaders/texture/TextureAssetLoader.js";
21
21
  import { CanvasView } from "../../view/elements/CanvasView.js";
22
22
  import convertSampler2D2Canvas from "../../engine/graphics/texture/sampler/Sampler2D2Canvas.js";
23
+ import { drawSamplerHTML } from "../../engine/graphics/texture/sampler/util/drawSamplerHTML.js";
23
24
 
24
25
  const engineHarness = new EngineHarness();
25
26