All files / src/WebGL/objects Sprite.ts

0% Statements 0/12
0% Branches 0/5
0% Functions 0/3
0% Lines 0/11

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                                                                   
import { Material } from './../materials/Material';
import { SpriteMaterial } from '../materials';
import { Object3D } from "../core";
import { Vector3 } from '../math';
//Sprite object
/** @constructor */
export class Sprite extends Object3D {
  rotation3d: Vector3;
  _modelViewMatrix: any;
  z?: number;
  material?: Material;
 
  constructor(material = new SpriteMaterial() as Material) {
    super();
    this.material = material as Material;
    this.rotation3d = this.rotation as Vector3;
    this.rotation = 0;
  }
 
  updateMatrix() {
    this.matrix.setPosition(this.position);
    this.rotation3d.set(0, 0, this.rotation);
    this.matrix.setRotationFromEuler(this.rotation3d);
 
    Iif (this.scale.x !== 1 || this.scale.y !== 1) this.matrix.scale(this.scale);
    this.matrixWorldNeedsUpdate = true;
  }
 
  clone<T extends this>(object = new Sprite(this.material)): Sprite  {
    Object3D.prototype.clone.call(this, object);
    return object;
  }
}