Beispiel #1
0
 public Geometry(string uuid, string name, string type, GeometryAttributes attributes, GeometryIndexAttribute index)
 {
     Uuid = uuid;
     Name = name;
     Type = type;
     Data = new GeometryData(attributes, index);
 }
        public static Geometry ToBufferGeometry(UnityEngine.Mesh mesh)
        {
            var uuid           = Guid.NewGuid().ToString();
            var positionFloats = ToFloatArray(mesh.vertices);
            var normalFloats   = ToFloatArray(mesh.normals);
            var uvFloats       = ToFloatArray(mesh.uv);
            var indices        = ToUInt16Array(mesh.triangles);

            var geometry = new GeometryAttributes(
                new GeometryAttribute("Float32Array", 3, positionFloats),
                new GeometryAttribute("Float32Array", 3, normalFloats),
                new GeometryAttribute("Float32Array", 2, uvFloats));

            var res = new Geometry(uuid, mesh.name, "BufferGeometry", geometry, new GeometryIndexAttribute("Uint16Array", indices));

            return(res);
        }
Beispiel #3
0
 public GeometryData(GeometryAttributes attributes, GeometryIndexAttribute index)
 {
     Attributes = attributes;
     Index      = index;
 }