Sprite constructor

Sprite([
  1. Material? material
])

Implementation

Sprite([Material? material]) : super() {
  type = 'Sprite';

  if (_geometry == null) {
    _geometry = BufferGeometry();

    var float32List =
        Float32Array.from([-0.5, -0.5, 0, 0, 0, 0.5, -0.5, 0, 1, 0, 0.5, 0.5, 0, 1, 1, -0.5, 0.5, 0, 0, 1]);

    var interleavedBuffer = InterleavedBuffer(float32List, 5);

    _geometry!.setIndex([0, 1, 2, 0, 2, 3]);
    _geometry!.setAttribute('position', InterleavedBufferAttribute(interleavedBuffer, 3, 0, false));
    _geometry!.setAttribute('uv', InterleavedBufferAttribute(interleavedBuffer, 2, 3, false));
  }

  geometry = _geometry;
  this.material = (material != null) ? material : SpriteMaterial(null);
}