All files / engine/Source/Core TranslationRotationScale.js

100% Statements 8/8
100% Branches 11/11
100% Functions 2/2
100% Lines 8/8

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 58        1x 1x 1x                                 394x             394x             394x                   1x 5x                  
import Cartesian3 from "./Cartesian3.js";
import defined from "./defined.js";
import Quaternion from "./Quaternion.js";
 
const defaultScale = new Cartesian3(1.0, 1.0, 1.0);
const defaultTranslation = Cartesian3.ZERO;
const defaultRotation = Quaternion.IDENTITY;
 
/**
 * An affine transformation defined by a translation, rotation, and scale.
 * @alias TranslationRotationScale
 * @constructor
 *
 * @param {Cartesian3} [translation=Cartesian3.ZERO] A {@link Cartesian3} specifying the (x, y, z) translation to apply to the node.
 * @param {Quaternion} [rotation=Quaternion.IDENTITY] A {@link Quaternion} specifying the (x, y, z, w) rotation to apply to the node.
 * @param {Cartesian3} [scale=new Cartesian3(1.0, 1.0, 1.0)] A {@link Cartesian3} specifying the (x, y, z) scaling to apply to the node.
 */
function TranslationRotationScale(translation, rotation, scale) {
  /**
   * Gets or sets the (x, y, z) translation to apply to the node.
   * @type {Cartesian3}
   * @default Cartesian3.ZERO
   */
  this.translation = Cartesian3.clone(translation ?? defaultTranslation);
 
  /**
   * Gets or sets the (x, y, z, w) rotation to apply to the node.
   * @type {Quaternion}
   * @default Quaternion.IDENTITY
   */
  this.rotation = Quaternion.clone(rotation ?? defaultRotation);
 
  /**
   * Gets or sets the (x, y, z) scaling to apply to the node.
   * @type {Cartesian3}
   * @default new Cartesian3(1.0, 1.0, 1.0)
   */
  this.scale = Cartesian3.clone(scale ?? defaultScale);
}
 
/**
 * Compares this instance against the provided instance and returns
 * <code>true</code> if they are equal, <code>false</code> otherwise.
 *
 * @param {TranslationRotationScale} [right] The right hand side TranslationRotationScale.
 * @returns {boolean} <code>true</code> if they are equal, <code>false</code> otherwise.
 */
TranslationRotationScale.prototype.equals = function (right) {
  return (
    this === right ||
    (defined(right) &&
      Cartesian3.equals(this.translation, right.translation) &&
      Quaternion.equals(this.rotation, right.rotation) &&
      Cartesian3.equals(this.scale, right.scale))
  );
};
export default TranslationRotationScale;