All files / engine/Source/DataSources DynamicGeometryBatch.js

93.33% Statements 28/30
66.66% Branches 4/6
100% Functions 6/6
92.3% Lines 24/26

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57                406x 406x 406x     1x 3x                 1x 205x 205x 205x 3x 3x       1x 1778x 1778x 3x   1778x     1x 392x 392x     392x     1x 77x 77x     77x      
import AssociativeArray from "../Core/AssociativeArray.js";
import defined from "../Core/defined.js";
import BoundingSphereState from "./BoundingSphereState.js";
 
/**
 * @private
 */
function DynamicGeometryBatch(primitives, orderedGroundPrimitives) {
  this._primitives = primitives;
  this._orderedGroundPrimitives = orderedGroundPrimitives;
  this._dynamicUpdaters = new AssociativeArray();
}
 
DynamicGeometryBatch.prototype.add = function (time, updater) {
  this._dynamicUpdaters.set(
    updater.id,
    updater.createDynamicUpdater(
      this._primitives,
      this._orderedGroundPrimitives,
    ),
  );
};
 
DynamicGeometryBatch.prototype.remove = function (updater) {
  const id = updater.id;
  const dynamicUpdater = this._dynamicUpdaters.get(id);
  if (defined(dynamicUpdater)) {
    this._dynamicUpdaters.remove(id);
    dynamicUpdater.destroy();
  }
};
 
DynamicGeometryBatch.prototype.update = function (time) {
  const geometries = this._dynamicUpdaters.values;
  for (let i = 0, len = geometries.length; i < len; i++) {
    geometries[i].update(time);
  }
  return true;
};
 
DynamicGeometryBatch.prototype.removeAllPrimitives = function () {
  const geometries = this._dynamicUpdaters.values;
  for (let i = 0, len = geometries.length; i < len; i++) {
    geometries[i].destroy();
  }
  this._dynamicUpdaters.removeAll();
};
 
DynamicGeometryBatch.prototype.getBoundingSphere = function (updater, result) {
  updater = this._dynamicUpdaters.get(updater.id);
  Iif (defined(updater) && defined(updater.getBoundingSphere)) {
    return updater.getBoundingSphere(result);
  }
  return BoundingSphereState.FAILED;
};
export default DynamicGeometryBatch;