@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.
- package/core/geom/3d/topology/TopoVertex.spec.js +6 -0
- package/core/model/object/objectDeepEquals.spec.js +1 -1
- package/engine/asset/loaders/image/ImageDecoderWorker.js +1 -1
- package/engine/asset/loaders/image/ImageRGBADataLoader.js +10 -4
- package/engine/asset/loaders/image/codec/NativeImageDecoder.js +3 -1
- package/engine/asset/loaders/image/codec/ThreadedImageDecoder.js +2 -1
- package/engine/asset/loaders/image/png/PNG.js +10 -4
- package/engine/asset/loaders/material/bitmap2sampler_gl.js +8 -2
- package/engine/asset/loaders/material/computeTextureEquality.js +3 -0
- package/engine/asset/loaders/material/computeTextureHash.js +8 -0
- package/engine/graphics/micron/plugin/MicronRenderPlugin.js +3 -3
- package/package.json +1 -1
- package/samples/terrain/editor.js +1 -0
|
@@ -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
|
|
@@ -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
|
-
|
|
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 '${
|
|
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);
|
|
@@ -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
|
|
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
|
-
|
|
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
|
-
|
|
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
|
}
|
|
@@ -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
|
-
//
|
|
136
|
-
|
|
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.
|
|
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
|
|