@woosh/meep-engine 2.109.22 → 2.109.23
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/meep.cjs +1 -1
- package/build/meep.module.js +1 -1
- package/package.json +1 -1
- package/src/core/primitives/array/computeStridedArrayHash.d.ts +13 -0
- package/src/core/primitives/array/computeStridedArrayHash.d.ts.map +1 -0
- package/src/core/primitives/array/computeStridedArrayHash.js +36 -0
- package/src/core/primitives/array/computeStridedIntegerArrayHash.js +2 -1
- package/src/engine/graphics/geometry/buffered/computeBufferAttributeHash.d.ts.map +1 -1
- package/src/engine/graphics/geometry/buffered/computeBufferAttributeHash.js +6 -2
package/build/meep.cjs
CHANGED
|
@@ -49144,7 +49144,7 @@ function computeStridedIntegerArrayHash(
|
|
|
49144
49144
|
let hash = length;
|
|
49145
49145
|
|
|
49146
49146
|
for (let i = offset; i < length; i += stride) {
|
|
49147
|
-
const value = array[i] >>> 0; //force
|
|
49147
|
+
const value = array[i] >>> 0; //force uint32
|
|
49148
49148
|
|
|
49149
49149
|
/**
|
|
49150
49150
|
* Simple hashing scheme, multiplying existing hash by a prime and adding next value
|
package/build/meep.module.js
CHANGED
|
@@ -49142,7 +49142,7 @@ function computeStridedIntegerArrayHash(
|
|
|
49142
49142
|
let hash = length;
|
|
49143
49143
|
|
|
49144
49144
|
for (let i = offset; i < length; i += stride) {
|
|
49145
|
-
const value = array[i] >>> 0; //force
|
|
49145
|
+
const value = array[i] >>> 0; //force uint32
|
|
49146
49146
|
|
|
49147
49147
|
/**
|
|
49148
49148
|
* Simple hashing scheme, multiplying existing hash by a prime and adding next value
|
package/package.json
CHANGED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Useful for computing hashes of large arrays, can pick a relevant stride and skip large chunks of memory while still capturing good amount of unique information from evenly-spaced areas of the array
|
|
3
|
+
* @template T
|
|
4
|
+
* @param {T[]|Uint32Array|Uint16Array|Uint8Array} array
|
|
5
|
+
* @param {number} offset
|
|
6
|
+
* @param {number} length
|
|
7
|
+
* @param {number} stride
|
|
8
|
+
* @param {function(T):number} elementHash
|
|
9
|
+
* @param {*} [elementHashContext]
|
|
10
|
+
* @return {number}
|
|
11
|
+
*/
|
|
12
|
+
export function computeStridedArrayHash<T>(array: Uint8Array | Uint16Array | Uint32Array | T[], offset: number, length: number, stride: number, elementHash: (arg0: T) => number, elementHashContext?: any): number;
|
|
13
|
+
//# sourceMappingURL=computeStridedArrayHash.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"computeStridedArrayHash.d.ts","sourceRoot":"","sources":["../../../../../src/core/primitives/array/computeStridedArrayHash.js"],"names":[],"mappings":"AAEA;;;;;;;;;;GAUG;AACH,wGAPW,MAAM,UACN,MAAM,UACN,MAAM,4BACM,MAAM,6BAEjB,MAAM,CAwBjB"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { assert } from "../../assert.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Useful for computing hashes of large arrays, can pick a relevant stride and skip large chunks of memory while still capturing good amount of unique information from evenly-spaced areas of the array
|
|
5
|
+
* @template T
|
|
6
|
+
* @param {T[]|Uint32Array|Uint16Array|Uint8Array} array
|
|
7
|
+
* @param {number} offset
|
|
8
|
+
* @param {number} length
|
|
9
|
+
* @param {number} stride
|
|
10
|
+
* @param {function(T):number} elementHash
|
|
11
|
+
* @param {*} [elementHashContext]
|
|
12
|
+
* @return {number}
|
|
13
|
+
*/
|
|
14
|
+
export function computeStridedArrayHash(
|
|
15
|
+
array, offset, length, stride,
|
|
16
|
+
elementHash, elementHashContext
|
|
17
|
+
) {
|
|
18
|
+
|
|
19
|
+
assert.isFunction(elementHash, 'elementHash');
|
|
20
|
+
|
|
21
|
+
let hash = length;
|
|
22
|
+
|
|
23
|
+
for (let i = offset; i < length; i += stride) {
|
|
24
|
+
const value = elementHash.call(elementHashContext, array[i]);
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Simple hashing scheme, multiplying existing hash by a prime and adding next value
|
|
28
|
+
* (h<<5) - h === h*31
|
|
29
|
+
* @type {number}
|
|
30
|
+
*/
|
|
31
|
+
hash = ((hash << 5) - hash) + value;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// force uint32
|
|
35
|
+
return hash >>> 0;
|
|
36
|
+
}
|
|
@@ -12,7 +12,7 @@ export function computeStridedIntegerArrayHash(
|
|
|
12
12
|
let hash = length;
|
|
13
13
|
|
|
14
14
|
for (let i = offset; i < length; i += stride) {
|
|
15
|
-
const value = array[i] >>> 0; //force
|
|
15
|
+
const value = array[i] >>> 0; //force uint32
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
18
|
* Simple hashing scheme, multiplying existing hash by a prime and adding next value
|
|
@@ -25,3 +25,4 @@ export function computeStridedIntegerArrayHash(
|
|
|
25
25
|
// force uint32
|
|
26
26
|
return hash >>> 0;
|
|
27
27
|
}
|
|
28
|
+
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"computeBufferAttributeHash.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/geometry/buffered/computeBufferAttributeHash.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"computeBufferAttributeHash.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/geometry/buffered/computeBufferAttributeHash.js"],"names":[],"mappings":"AAIA;;;;GAIG;AACH,sDAHW,MAAM,eAAe,GACnB,MAAM,CAyBlB"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { min2 } from "../../../../core/math/min2.js";
|
|
2
|
-
import {
|
|
2
|
+
import { computeStridedArrayHash } from "../../../../core/primitives/array/computeStridedArrayHash.js";
|
|
3
|
+
import { computeHashFloat } from "../../../../core/primitives/numbers/computeHashFloat.js";
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
*
|
|
@@ -21,7 +22,10 @@ export function computeBufferAttributeHash(attribute) {
|
|
|
21
22
|
// compute stride so that we don't have to iterate over the entire buffer, instead picking at most X(509) values to consider
|
|
22
23
|
const stride = Math.max(1, Math.ceil(hash_evaluation_length / 31));
|
|
23
24
|
|
|
24
|
-
result ^=
|
|
25
|
+
result ^= computeStridedArrayHash(
|
|
26
|
+
data, 0, hash_evaluation_length, stride,
|
|
27
|
+
computeHashFloat
|
|
28
|
+
);
|
|
25
29
|
|
|
26
30
|
}
|
|
27
31
|
|