Skip to content

heestand-xyz/PNG3D

Repository files navigation

PNG3D

File format for 3D images (voxel volume)

This format is mainly built for use with AsyncGraphics and the Graphic3D type

Read & Write

import Spatial
import PNG3D
import AsyncGraphics
let resolution = Size3D(width: 100, height: 100, depth: 100)
let graphic3D: Graphic3D = try await .sphere(resolution: resolution)

/// Write
let fileData: Data = try await PNG3D.write(graphic3D: graphic3D)
let fileURL = URL(filePath: "/Users/.../Desktop/test.png3d")
try fileData.write(to: fileURL)

/// Read
let newFileData = try Data(contentsOf: fileURL)
let newGraphic3D: Graphic3D = try await PNG3D.read(data: newFileData)

View

Optimized for visionOS in 3D, tho still works on iOS and macOS in 2D.

import SwiftUI
import PNG3D

struct ContentView: View {
    
    let url = URL(filePath: "/Users/.../Desktop/test.png3d")
        
    var body: some View {
        PNG3DView(url: url, placement: .fit)
    }
}

About

File format for 3D images

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages