@woosh/meep-engine 2.118.11 → 2.118.13

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 CHANGED
@@ -52064,6 +52064,8 @@ function array_buffer_copy(
52064
52064
  target, target_offset,
52065
52065
  byte_length
52066
52066
  ) {
52067
+ // assert.ok(source instanceof ArrayBuffer || source instanceof SharedArrayBuffer,'source is not an ArrayBuffer');
52068
+ // assert.ok(target instanceof ArrayBuffer || target instanceof SharedArrayBuffer,'source is not an ArrayBuffer');
52067
52069
 
52068
52070
  /**
52069
52071
  * @type {Uint8Array|Uint16Array|Uint32Array}
@@ -52154,6 +52156,7 @@ const CAPACITY_GROW_MIN_STEP = 64;
52154
52156
  * @type {number}
52155
52157
  */
52156
52158
  const ELEMENT_WORD_COUNT = 10;
52159
+ const ELEMENT_BYTE_COUNT = ELEMENT_WORD_COUNT * 4;
52157
52160
 
52158
52161
  /**
52159
52162
  * How many nodes can be stored in the newly constructed tree before allocation needs to take place
@@ -52191,7 +52194,7 @@ class BVH {
52191
52194
  * If you intend to modify the data directly - make sure you fully understand the implications of doing so
52192
52195
  * @returns {ArrayBuffer}
52193
52196
  */
52194
- get data_buffer(){
52197
+ get data_buffer() {
52195
52198
  return this.__data_buffer;
52196
52199
  }
52197
52200
 
@@ -52312,19 +52315,23 @@ class BVH {
52312
52315
 
52313
52316
  const old_data_uint32 = this.__data_uint32;
52314
52317
 
52315
- const new_data_buffer = new ArrayBuffer(new_capacity * ELEMENT_WORD_COUNT * 4);
52318
+ const new_data_buffer = new ArrayBuffer(new_capacity * ELEMENT_BYTE_COUNT);
52316
52319
 
52317
52320
  this.__data_buffer = new_data_buffer;
52318
52321
 
52319
52322
  this.__data_float32 = new Float32Array(new_data_buffer);
52320
52323
  this.__data_uint32 = new Uint32Array(new_data_buffer);
52321
52324
 
52322
- // copy old data into new buffer
52323
- array_buffer_copy(
52324
- old_data_uint32.buffer, old_data_uint32.byteOffset,
52325
- new_data_buffer, 0,
52326
- Math.min(old_data_uint32.byteLength, new_data_buffer.byteLength)
52327
- );
52325
+ if (this.__size > 0) {
52326
+
52327
+ // copy old data into new buffer
52328
+ array_buffer_copy(
52329
+ old_data_uint32.buffer, old_data_uint32.byteOffset,
52330
+ new_data_buffer, 0,
52331
+ Math.min(this.__size * ELEMENT_BYTE_COUNT, new_data_buffer.byteLength)
52332
+ );
52333
+
52334
+ }
52328
52335
 
52329
52336
  this.__capacity = new_capacity;
52330
52337
  }
@@ -61393,10 +61400,25 @@ function typed_array_copy(source, destination) {
61393
61400
  const destination_size = destination.length;
61394
61401
 
61395
61402
  if (destination_size >= source.length) {
61403
+
61396
61404
  destination.set(source, 0);
61405
+
61406
+ } else if (source.constructor === destination.constructor) {
61407
+
61408
+ // same type
61409
+ array_buffer_copy(
61410
+ source.buffer,
61411
+ source.byteOffset,
61412
+ destination.buffer,
61413
+ destination.byteOffset,
61414
+ Math.min(source.byteLength, destination.byteLength)
61415
+ );
61416
+
61397
61417
  } else {
61418
+
61398
61419
  // destination is smaller than source, crop source data
61399
61420
  array_copy(source, 0, destination, 0, destination_size);
61421
+
61400
61422
  }
61401
61423
  }
61402
61424