@woosh/meep-engine 2.117.21 → 2.117.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 +73 -10
- package/build/meep.min.js +1 -1
- package/build/meep.module.js +73 -10
- package/package.json +1 -1
- package/src/core/bvh2/bvh3/BVH.d.ts +2 -0
- package/src/core/bvh2/bvh3/BVH.d.ts.map +1 -1
- package/src/core/bvh2/bvh3/BVH.js +16 -2
package/build/meep.module.js
CHANGED
|
@@ -52064,19 +52064,52 @@ class TerrainPreview {
|
|
|
52064
52064
|
const UINT32_MAX = 4294967295;
|
|
52065
52065
|
|
|
52066
52066
|
/**
|
|
52067
|
-
*
|
|
52068
|
-
* @
|
|
52069
|
-
* @param {
|
|
52067
|
+
* This is essentially a {@link memcopy} implementation for ArrayBuffers
|
|
52068
|
+
* NOTE: allocates light-weight typed arrays under the hood, so beware of potential GC implications. Generally not an issue, unless you're copying very large number of very small arrays, consider alternatives such as {@link array_copy} instead
|
|
52069
|
+
* @param {ArrayBuffer} source
|
|
52070
|
+
* @param {number} source_offset
|
|
52071
|
+
* @param {ArrayBuffer} target
|
|
52072
|
+
* @param {number} target_offset
|
|
52073
|
+
* @param {number} byte_length
|
|
52070
52074
|
*/
|
|
52071
|
-
function
|
|
52072
|
-
|
|
52075
|
+
function array_buffer_copy(
|
|
52076
|
+
source, source_offset,
|
|
52077
|
+
target, target_offset,
|
|
52078
|
+
byte_length
|
|
52079
|
+
) {
|
|
52080
|
+
|
|
52081
|
+
/**
|
|
52082
|
+
* @type {Uint8Array|Uint16Array|Uint32Array}
|
|
52083
|
+
*/
|
|
52084
|
+
let source_array;
|
|
52085
|
+
/**
|
|
52086
|
+
* @type {Uint8Array|Uint16Array|Uint32Array}
|
|
52087
|
+
*/
|
|
52088
|
+
let target_array;
|
|
52089
|
+
|
|
52090
|
+
const alignment = largest_common_alignment_uint32(source_offset,target_offset,byte_length);
|
|
52091
|
+
|
|
52092
|
+
if (
|
|
52093
|
+
alignment === 4
|
|
52094
|
+
) {
|
|
52095
|
+
// aligned on 4-byte boundary
|
|
52096
|
+
source_array = new Uint32Array(source, source_offset, byte_length >>> 2);
|
|
52097
|
+
target_array = new Uint32Array(target, target_offset, byte_length >>> 2);
|
|
52098
|
+
|
|
52099
|
+
} else if (
|
|
52100
|
+
alignment === 2
|
|
52101
|
+
) {
|
|
52102
|
+
// aligned on 2-byte boundary
|
|
52103
|
+
source_array = new Uint16Array(source, source_offset, byte_length >>> 1);
|
|
52104
|
+
target_array = new Uint16Array(target, target_offset, byte_length >>> 1);
|
|
52073
52105
|
|
|
52074
|
-
if (destination_size >= source.length) {
|
|
52075
|
-
destination.set(source, 0);
|
|
52076
52106
|
} else {
|
|
52077
|
-
//
|
|
52078
|
-
|
|
52107
|
+
// worst-case, assume 1-byte boundary
|
|
52108
|
+
source_array = new Uint8Array(source, source_offset, byte_length);
|
|
52109
|
+
target_array = new Uint8Array(target, target_offset, byte_length);
|
|
52079
52110
|
}
|
|
52111
|
+
|
|
52112
|
+
target_array.set(source_array);
|
|
52080
52113
|
}
|
|
52081
52114
|
|
|
52082
52115
|
/**
|
|
@@ -52165,6 +52198,16 @@ class BVH {
|
|
|
52165
52198
|
*/
|
|
52166
52199
|
__data_buffer = new ArrayBuffer(INITIAL_CAPACITY * ELEMENT_WORD_COUNT * 4);
|
|
52167
52200
|
|
|
52201
|
+
/**
|
|
52202
|
+
* Access raw data
|
|
52203
|
+
* Useful for serialization
|
|
52204
|
+
* If you intend to modify the data directly - make sure you fully understand the implications of doing so
|
|
52205
|
+
* @returns {ArrayBuffer}
|
|
52206
|
+
*/
|
|
52207
|
+
get data_buffer(){
|
|
52208
|
+
return this.__data_buffer;
|
|
52209
|
+
}
|
|
52210
|
+
|
|
52168
52211
|
/**
|
|
52169
52212
|
*
|
|
52170
52213
|
* @type {Float32Array}
|
|
@@ -52290,7 +52333,11 @@ class BVH {
|
|
|
52290
52333
|
this.__data_uint32 = new Uint32Array(new_data_buffer);
|
|
52291
52334
|
|
|
52292
52335
|
// copy old data into new buffer
|
|
52293
|
-
|
|
52336
|
+
array_buffer_copy(
|
|
52337
|
+
old_data_uint32.buffer, old_data_uint32.byteOffset,
|
|
52338
|
+
new_data_buffer, 0,
|
|
52339
|
+
Math.min(old_data_uint32.byteLength, new_data_buffer.byteLength)
|
|
52340
|
+
);
|
|
52294
52341
|
|
|
52295
52342
|
this.__capacity = new_capacity;
|
|
52296
52343
|
}
|
|
@@ -61428,6 +61475,22 @@ Cache.prototype.delete = Cache.prototype.remove;
|
|
|
61428
61475
|
*/
|
|
61429
61476
|
Cache.prototype.has = Cache.prototype.contains;
|
|
61430
61477
|
|
|
61478
|
+
/**
|
|
61479
|
+
* Assumes arrays have the same type
|
|
61480
|
+
* @param {TypedArray|Float32Array|Uint8Array|Uint32Array} source
|
|
61481
|
+
* @param {TypedArray|Float32Array|Uint8Array|Uint32Array} destination
|
|
61482
|
+
*/
|
|
61483
|
+
function typed_array_copy(source, destination) {
|
|
61484
|
+
const destination_size = destination.length;
|
|
61485
|
+
|
|
61486
|
+
if (destination_size >= source.length) {
|
|
61487
|
+
destination.set(source, 0);
|
|
61488
|
+
} else {
|
|
61489
|
+
// destination is smaller than source, crop source data
|
|
61490
|
+
array_copy(source, 0, destination, 0, destination_size);
|
|
61491
|
+
}
|
|
61492
|
+
}
|
|
61493
|
+
|
|
61431
61494
|
/**
|
|
61432
61495
|
*
|
|
61433
61496
|
* @param {Object} a
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BVH.d.ts","sourceRoot":"","sources":["../../../../../src/core/bvh2/bvh3/BVH.js"],"names":[],"mappings":"AAQA,8BAA+B;AAC/B,+BAAgC;AAChC,+BAAgC;AAChC,8BAA+B;AAE/B;;;;;GAKG;AACH,+BAFU,MAAM,CAE+B;AAE/C;;;GAGG;AACH,wBAFU,MAAM,CAEoB;AAcpC;;;;;GAKG;AACH,iCAFU,MAAM,CAEqB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AMG;IACH,gBAoMC;IAED;;;OAGG;IACH,oBAIC;IAED;;;;OAIG;IACH,yCA8BC;IAED;;;;;OAKG;IACH,+BAJW,MAAM,EAAE,sBACR,MAAM,GACJ,MAAM,CAWlB;IAED;;;;;OAKG;IACH,0BA6BC;IAED;;;;;OAKG;IACH,cAJW,MAAM,KACN,MAAM,GACJ,OAAO,CAsCnB;CACJ"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { assert } from "../../assert.js";
|
|
2
2
|
import { UINT32_MAX } from "../../binary/UINT32_MAX.js";
|
|
3
3
|
import { array_copy } from "../../collection/array/array_copy.js";
|
|
4
|
-
import {
|
|
4
|
+
import { array_buffer_copy } from "../../collection/array/typed/array_buffer_copy.js";
|
|
5
5
|
import { aabb3_compute_surface_area } from "../../geom/3d/aabb/aabb3_compute_surface_area.js";
|
|
6
6
|
import { max2 } from "../../math/max2.js";
|
|
7
7
|
import { min2 } from "../../math/min2.js";
|
|
@@ -75,6 +75,16 @@ export class BVH {
|
|
|
75
75
|
*/
|
|
76
76
|
__data_buffer = new ArrayBuffer(INITIAL_CAPACITY * ELEMENT_WORD_COUNT * 4);
|
|
77
77
|
|
|
78
|
+
/**
|
|
79
|
+
* Access raw data
|
|
80
|
+
* Useful for serialization
|
|
81
|
+
* If you intend to modify the data directly - make sure you fully understand the implications of doing so
|
|
82
|
+
* @returns {ArrayBuffer}
|
|
83
|
+
*/
|
|
84
|
+
get data_buffer(){
|
|
85
|
+
return this.__data_buffer;
|
|
86
|
+
}
|
|
87
|
+
|
|
78
88
|
/**
|
|
79
89
|
*
|
|
80
90
|
* @type {Float32Array}
|
|
@@ -201,7 +211,11 @@ export class BVH {
|
|
|
201
211
|
this.__data_uint32 = new Uint32Array(new_data_buffer);
|
|
202
212
|
|
|
203
213
|
// copy old data into new buffer
|
|
204
|
-
|
|
214
|
+
array_buffer_copy(
|
|
215
|
+
old_data_uint32.buffer, old_data_uint32.byteOffset,
|
|
216
|
+
new_data_buffer, 0,
|
|
217
|
+
Math.min(old_data_uint32.byteLength, new_data_buffer.byteLength)
|
|
218
|
+
);
|
|
205
219
|
|
|
206
220
|
this.__capacity = new_capacity;
|
|
207
221
|
}
|