@woosh/meep-engine 2.124.4 → 2.124.5
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/package.json +1 -1
- package/src/engine/asset/loaders/material/computeTextureEquality.d.ts +4 -4
- package/src/engine/asset/loaders/material/computeTextureEquality.d.ts.map +1 -1
- package/src/engine/asset/loaders/material/computeTextureEquality.js +23 -7
- package/src/engine/asset/loaders/material/computeTextureHash.d.ts.map +1 -1
- package/src/engine/asset/loaders/material/computeTextureHash.js +14 -2
package/package.json
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"description": "Pure JavaScript game engine. Fully featured and production ready.",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"author": "Alexander Goldring",
|
|
8
|
-
"version": "2.124.
|
|
8
|
+
"version": "2.124.5",
|
|
9
9
|
"main": "build/meep.module.js",
|
|
10
10
|
"module": "build/meep.module.js",
|
|
11
11
|
"exports": {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
* @param {Texture} a
|
|
4
|
-
* @param {Texture} b
|
|
2
|
+
* Compare two three.js textures for equality
|
|
3
|
+
* @param {THREE.Texture} a
|
|
4
|
+
* @param {THREE.Texture} b
|
|
5
5
|
* @returns {boolean}
|
|
6
6
|
*/
|
|
7
|
-
export function computeTextureEquality(a: Texture, b: Texture): boolean;
|
|
7
|
+
export function computeTextureEquality(a: THREE.Texture, b: THREE.Texture): boolean;
|
|
8
8
|
/**
|
|
9
9
|
*
|
|
10
10
|
* @param {Image|ImageBitmap|HTMLCanvasElement|[]|{width:number, height:number}} a
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"computeTextureEquality.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/asset/loaders/material/computeTextureEquality.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"computeTextureEquality.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/asset/loaders/material/computeTextureEquality.js"],"names":[],"mappings":"AAOA;;;;;GAKG;AACH,0CAJW,KAAK,CAAC,OAAO,KACb,KAAK,CAAC,OAAO,GACX,OAAO,CA8DnB;AAED;;;;;GAKG;AACH,sCAJW,8DAAM,WAAW,GAAC,iBAAiB,GAAC,EAAE,GAAC;IAAC,KAAK,EAAC,MAAM,CAAC;IAAC,MAAM,EAAC,MAAM,CAAA;CAAC,KACpE,8DAAM,WAAW,GAAC,iBAAiB,GAAC,EAAE,GAAC;IAAC,KAAK,EAAC,MAAM,CAAC;IAAC,MAAM,EAAC,MAAM,CAAA;CAAC,GAClE,OAAO,CA2EnB"}
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import { fastArrayEquals } from "../../../../core/collection/array/fastArrayEquals.js";
|
|
2
|
-
import {
|
|
2
|
+
import { isArrayLike } from "../../../../core/collection/array/isArrayLike.js";
|
|
3
3
|
import { computeImageCanvasEquality } from "../../../graphics/canvas/computeImageCanvasEquality.js";
|
|
4
4
|
import { isImageBitmap } from "../../../graphics/texture/isImageBitmap.js";
|
|
5
5
|
import { computeImageBitmapEquality } from "./computeImageBitmapEquality.js";
|
|
6
6
|
|
|
7
|
-
//
|
|
8
7
|
|
|
9
8
|
/**
|
|
10
|
-
*
|
|
11
|
-
* @param {Texture} a
|
|
12
|
-
* @param {Texture} b
|
|
9
|
+
* Compare two three.js textures for equality
|
|
10
|
+
* @param {THREE.Texture} a
|
|
11
|
+
* @param {THREE.Texture} b
|
|
13
12
|
* @returns {boolean}
|
|
14
13
|
*/
|
|
15
14
|
export function computeTextureEquality(a, b) {
|
|
@@ -26,6 +25,14 @@ export function computeTextureEquality(a, b) {
|
|
|
26
25
|
return false;
|
|
27
26
|
}
|
|
28
27
|
|
|
28
|
+
// special methods
|
|
29
|
+
if (typeof a.equals === "function" && typeof b.equals === "function") {
|
|
30
|
+
// can check for equality using custom methods
|
|
31
|
+
return a.equals(b);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// revert to generic check
|
|
35
|
+
|
|
29
36
|
if (
|
|
30
37
|
a.mapping !== b.mapping
|
|
31
38
|
|| a.wrapS !== b.wrapS
|
|
@@ -61,10 +68,11 @@ export function computeTextureEquality(a, b) {
|
|
|
61
68
|
}
|
|
62
69
|
|
|
63
70
|
//TODO implement support for other texture types
|
|
71
|
+
|
|
72
|
+
// checks up until now were for rejection, so if we got until this point - textures must be equal
|
|
64
73
|
return true;
|
|
65
74
|
}
|
|
66
75
|
|
|
67
|
-
|
|
68
76
|
/**
|
|
69
77
|
*
|
|
70
78
|
* @param {Image|ImageBitmap|HTMLCanvasElement|[]|{width:number, height:number}} a
|
|
@@ -130,7 +138,15 @@ export function textureImagesEqual(a, b) {
|
|
|
130
138
|
return true;
|
|
131
139
|
}
|
|
132
140
|
|
|
133
|
-
|
|
141
|
+
const a_data = a.data;
|
|
142
|
+
const b_data = b.data;
|
|
143
|
+
|
|
144
|
+
if (a_data === null && b_data === null) {
|
|
145
|
+
// special case, empty texture
|
|
146
|
+
return true;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
if (isArrayLike(a_data) && isArrayLike(b_data)) {
|
|
134
150
|
return textureMipmapEqual(a, b);
|
|
135
151
|
}
|
|
136
152
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"computeTextureHash.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/asset/loaders/material/computeTextureHash.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"computeTextureHash.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/asset/loaders/material/computeTextureHash.js"],"names":[],"mappings":"AA0BA;;;;GAIG;AACH,4CAHW,WAAW,GAAC,gBAAgB,GAAC;IAAC,IAAI,MAAC;IAAA,KAAK,EAAC,MAAM,CAAC;IAAA,MAAM,EAAC,MAAM,CAAA;CAAC,GAC7D,MAAM,CA0CjB;AA4CD;;;;GAIG;AACH,sCAHW,OAAO,GAAC,KAAK,CAAC,OAAO,GACnB,MAAM,CAgDlB"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { assert } from "../../../../core/assert.js";
|
|
1
2
|
import { combine_hash } from "../../../../core/collection/array/combine_hash.js";
|
|
2
3
|
import { murmur3_32 } from "../../../../core/math/hash/murmur3_32.js";
|
|
3
4
|
import { computeHashFloat } from "../../../../core/primitives/numbers/computeHashFloat.js";
|
|
@@ -45,7 +46,7 @@ export function computeImageDataHash(image) {
|
|
|
45
46
|
|
|
46
47
|
result = computeStringHash(image.src);
|
|
47
48
|
|
|
48
|
-
}else if(image instanceof HTMLCanvasElement) {
|
|
49
|
+
} else if (image instanceof HTMLCanvasElement) {
|
|
49
50
|
|
|
50
51
|
result = computeHtmlCanvasElementHash(image);
|
|
51
52
|
|
|
@@ -123,9 +124,20 @@ export function computeTextureHash(t) {
|
|
|
123
124
|
}
|
|
124
125
|
|
|
125
126
|
if (t === undefined) {
|
|
126
|
-
return
|
|
127
|
+
return 1;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// special methods
|
|
131
|
+
if (typeof t.hash === "function") {
|
|
132
|
+
const hash = t.hash(); // must produce an integer value
|
|
133
|
+
|
|
134
|
+
assert.isInteger(hash, 'hash');
|
|
135
|
+
|
|
136
|
+
return hash;
|
|
127
137
|
}
|
|
128
138
|
|
|
139
|
+
// revert to generic check
|
|
140
|
+
|
|
129
141
|
const specificHash = computeSpecificHash(t);
|
|
130
142
|
|
|
131
143
|
return combine_hash(
|