serializeViews function
Serializes scene's view list into document's views array,
replacing any existing entries.
Call after serializeScene (camera nodes are referenced by the ids
that pass assigned). Views whose camera is not a node-backed
NodeCamera within the serialized graph are skipped with a debug
warning; render-texture targets are serialized from their live state.
Implementation
void serializeViews(Scene scene, SceneDocument document) {
final context = SerializeContext(document);
document.views.clear();
for (final view in scene.views) {
final camera = view.camera;
if (camera is! NodeCamera) {
debugPrint(
'fscene: skipping render view; its camera is not node-backed '
'(use a CameraComponent for serializable views).',
);
continue;
}
final cameraId = nodeFsceneId(camera.node);
if (cameraId == null || document.node(cameraId) == null) {
debugPrint(
'fscene: skipping render view; its camera node is not part of '
'the serialized graph.',
);
continue;
}
final target = view.target;
document.views.add(
RenderViewSpec(
cameraNode: cameraId,
target: target == null ? null : serializeRenderTexture(target, context),
layerMask: view.layerMask,
order: view.order,
antiAliasingMode: view.antiAliasingMode?.name,
renderScale: view.renderScale,
filterQuality: view.filterQuality?.name,
),
);
}
if (document.views.isNotEmpty) {
document.featuresUsed.add('renderTextures');
}
}