Ejemplo n.º 1
0
 public Vrm10Storage()
 {
     Gltf    = new VrmProtobuf.glTF();
     Buffers = new List <ArrayByteBuffer>()
     {
         new ArrayByteBuffer()
     };
 }
Ejemplo n.º 2
0
        public Vrm10Storage(ArraySegment <byte> json, Memory <byte> bin)
        {
            var parserSettings = Google.Protobuf.JsonParser.Settings.Default;
            var jsonString     = Encoding.UTF8.GetString(json.Array, json.Offset, json.Count);
            var deserialized   = new Google.Protobuf.JsonParser(parserSettings).Parse <VrmProtobuf.glTF>(jsonString);

            Gltf = deserialized;
            var array = bin.ToArray();

            Buffers = new List <ArrayByteBuffer>()
            {
                new ArrayByteBuffer(array, bin.Length)
            };
        }
Ejemplo n.º 3
0
        public void MaterialTest()
        {
            var settings = Google.Protobuf.JsonFormatter.Settings.Default.WithPreserveProtoFieldNames(true);
            var q        = "\"";

            {
                var data = new VrmProtobuf.Material
                {
                    Name = "Some",
                };

                var json = new Google.Protobuf.JsonFormatter(settings).Format(data);
                Assert.AreEqual($"{{ {q}name{q}: {q}Some{q} }}", json);
            }

            {
                var data = new VrmProtobuf.glTF();
                data.Textures.Add(new VrmProtobuf.Texture
                {
                });
                var json = new Google.Protobuf.JsonFormatter(settings).Format(data);
                // Assert.Equal($"{{ {q}name{q}: {q}Some{q} }}", json);
            }

            {
                var data = new VrmProtobuf.Material
                {
                    Name = "Alicia_body",
                    PbrMetallicRoughness = new VrmProtobuf.MaterialPbrMetallicRoughness
                    {
                        // BaseColorFactor = new[] { 1, 1, 1, 1 },
                        // BaseColorTexture= { },
                        MetallicFactor  = 0,
                        RoughnessFactor = 0.9f
                    },
                    AlphaMode   = "OPAQUE",
                    AlphaCutoff = 0.5f,
                    Extensions  = new VrmProtobuf.Material.Types.Extensions
                    {
                        KHRMaterialsUnlit = { }
                    }
                };

                var json = new Google.Protobuf.JsonFormatter(settings).Format(data);
                // Assert.Equal($"{{ {q}name{q}: {q}Some{q} }}", json);
            }
        }