@woosh/meep-engine 2.118.12 → 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
@@ -52156,6 +52156,7 @@ const CAPACITY_GROW_MIN_STEP = 64;
52156
52156
  * @type {number}
52157
52157
  */
52158
52158
  const ELEMENT_WORD_COUNT = 10;
52159
+ const ELEMENT_BYTE_COUNT = ELEMENT_WORD_COUNT * 4;
52159
52160
 
52160
52161
  /**
52161
52162
  * How many nodes can be stored in the newly constructed tree before allocation needs to take place
@@ -52193,7 +52194,7 @@ class BVH {
52193
52194
  * If you intend to modify the data directly - make sure you fully understand the implications of doing so
52194
52195
  * @returns {ArrayBuffer}
52195
52196
  */
52196
- get data_buffer(){
52197
+ get data_buffer() {
52197
52198
  return this.__data_buffer;
52198
52199
  }
52199
52200
 
@@ -52314,19 +52315,23 @@ class BVH {
52314
52315
 
52315
52316
  const old_data_uint32 = this.__data_uint32;
52316
52317
 
52317
- const new_data_buffer = new ArrayBuffer(new_capacity * ELEMENT_WORD_COUNT * 4);
52318
+ const new_data_buffer = new ArrayBuffer(new_capacity * ELEMENT_BYTE_COUNT);
52318
52319
 
52319
52320
  this.__data_buffer = new_data_buffer;
52320
52321
 
52321
52322
  this.__data_float32 = new Float32Array(new_data_buffer);
52322
52323
  this.__data_uint32 = new Uint32Array(new_data_buffer);
52323
52324
 
52324
- // copy old data into new buffer
52325
- array_buffer_copy(
52326
- old_data_uint32.buffer, old_data_uint32.byteOffset,
52327
- new_data_buffer, 0,
52328
- Math.min(old_data_uint32.byteLength, new_data_buffer.byteLength)
52329
- );
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
+ }
52330
52335
 
52331
52336
  this.__capacity = new_capacity;
52332
52337
  }