setMorphWeights method

  1. @override
void setMorphWeights(
  1. Float32List? weights
)
inherited

Hook for morphed geometries to receive the owning node's morph weights.

The default implementation does nothing. The render passes call this right before each draw's bind (mirroring setJointsTexture), so a geometry shared between several nodes blends each node's own weights.

Implementation

@override
void setMorphWeights(Float32List? weights) {
  if (weights == null) return;
  if (usesGpuMorphing) {
    // Retained by reference: the render item hands the node's live list
    // right before each draw's bind, which reads it synchronously.
    _gpuWeights = weights;
    return;
  }
  final base = _baseVertexFloats;
  if (base == null) return; // Nothing uploaded yet.
  if (_weightsMatch(weights)) return;
  _appliedWeights = Float32List.fromList(weights);
  final blended = _blendScratch ??= Float32List(base.length);
  _blendInterleaved(base, blended, weights);
  _uploadingBlend = true;
  try {
    uploadVertexData(
      ByteData.sublistView(blended),
      _baseVertexCount,
      _baseIndices,
      indexType: _baseIndexType,
    );
  } finally {
    _uploadingBlend = false;
  }
}