draco

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 27, 2026 License: Apache-2.0 Imports: 6 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package draco decodes Draco-compressed triangle meshes (bitstream version 2.2, the version KHR_draco_mesh_compression normatively references) in pure Go.

It is a port, modified for Go, of the decoding half of Google's Draco library 1.5.7 (https://github.com/google/draco, Copyright 2016 The Draco Authors, licensed under the Apache License, Version 2.0; see the NOTICE file in this directory): sequential and edgebreaker (standard and valence) connectivity, the generic, integer, quantization and normal attribute decoders, and the difference, parallelogram, multi-parallelogram, constrained multi-parallelogram, portable texture coordinate and geometric normal prediction schemes with their wrap and octahedron transforms. Every read is bounds checked so malformed input returns an error instead of panicking.

Index

Constants

This section is empty.

Variables

View Source
var DefaultLimits = Limits{MaxFaces: 1 << 22, MaxPoints: 1 << 22, MaxBytes: 256 << 20}

DefaultLimits are used when a Limits field is zero.

Functions

This section is empty.

Types

type Attribute

type Attribute struct {
	// contains filtered or unexported fields
}

Attribute is one decoded per-point attribute of a Mesh.

func (Attribute) IsFloat

func (a Attribute) IsFloat() bool

IsFloat reports whether the attribute stores floating-point values.

func (Attribute) Normalized

func (a Attribute) Normalized() bool

Normalized reports whether integer values are meant to be normalized.

func (Attribute) NumComponents

func (a Attribute) NumComponents() int

NumComponents returns the number of components per value.

func (Attribute) Value

func (a Attribute) Value(point, comp int) (float64, error)

Value returns component comp of the value of point. Integer values are returned exactly; float32 values are widened exactly.

type Limits

type Limits struct {
	// MaxFaces is the largest triangle count accepted.
	MaxFaces int
	// MaxPoints is the largest point (vertex) count accepted.
	MaxPoints int
	// MaxBytes caps the working memory, in bytes, that scales with the number of attributes and attribute connectivities a stream declares: per-attribute corner tables, point mappings, and decoded and portable values. A stream that would need more fails before allocating it. Mesh.Bytes reports what a successful decode charged.
	MaxBytes uint64
}

Limits caps the sizes a stream may declare, so a small malicious input cannot force large allocations.

type Mesh

type Mesh struct {
	// Faces holds three point indices per triangle.
	Faces []uint32
	// NumPoints is the number of points the faces index.
	NumPoints int
	// Bytes is the working memory charged against Limits.MaxBytes while decoding.
	Bytes uint64
	// contains filtered or unexported fields
}

Mesh is a decoded Draco triangle mesh. Faces index points; every attribute has one value per point.

func Decode

func Decode(data []byte, limits Limits) (*Mesh, error)

Decode decodes a Draco triangle mesh. Zero limit fields take DefaultLimits.

func (*Mesh) Attribute

func (m *Mesh) Attribute(uniqueID uint32) (Attribute, bool)

Attribute returns the attribute with the given unique id, which is what KHR_draco_mesh_compression's attributes map refers to.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL