// SPDX-FileCopyrightText: 2023 Unity Technologies and the glTFast authors // SPDX-License-Identifier: Apache-2.0 namespace GLTFast.Schema { /// [System.Serializable] public class AccessorSparse : AccessorSparseBase { } /// [System.Serializable] public abstract class AccessorSparseBase : AccessorSparseBase where TIndices : AccessorSparseIndices where TValues : AccessorSparseValues { /// public TIndices indices; /// public TValues values; /// public override AccessorSparseIndices Indices => indices; /// public override AccessorSparseValues Values => values; } /// /// Sparse property of a glTF /// /// [System.Serializable] public abstract class AccessorSparseBase { /// /// Number of entries stored in the sparse array. /// public int count; /// /// Index array of size `count` that points to those accessor attributes that /// deviate from their initialization value. Indices must strictly increase. /// public abstract AccessorSparseIndices Indices { get; } /// /// "Array of size `count` times number of components, storing the displaced /// accessor attributes pointed by `indices`. Substituted values must have /// the same `componentType` and number of components as the base accessor. /// public abstract AccessorSparseValues Values { get; } internal void GltfSerialize(JsonWriter writer) { writer.AddObject(); writer.AddProperty("count", count); if (Indices != null) { writer.AddProperty("indices"); Indices.GltfSerialize(writer); } if (Values != null) { writer.AddProperty("values"); Values.GltfSerialize(writer); } writer.Close(); } } }