resource property

  1. @override
ByteBuffer? get resource
override

The resource data.

Implementation

@override
ByteBuffer? get resource {
  if (super.resource == null) {
    var previousIndex = -1;

    final entries = _storage.entries.toList()
      ..sort(Comparing.on((c) => c.key));
    final data = entries.fold<List<double>>([], (p, e) {
      if (previousIndex + 1 != e.key) {
        final field =
            slot.fields.indexed.firstWhere((e) => e.$1 == previousIndex + 1);
        throw StateError('Uniform ${slot.name}.${field.$2} was not set');
      }
      previousIndex = e.key;
      return p..addAll(e.value.data);
    });

    super.resource = Float32List.fromList(data).buffer;
  }

  return super.resource;
}
  1. @protected
set resource (ByteBuffer? resource)
inherited

Implementation

@protected
set resource(R resource) => _resource = resource;