Documentation
¶
Overview ¶
Package occt converts STEP CAD files to GLB (binary glTF) in pure Go.
It embeds OpenCascade (OCCT) compiled to WebAssembly and runs it under wazero, so `go get` works on any platform Go supports — no cgo, no system dependencies. Names, colors, and assembly hierarchy from the STEP file are preserved in the produced GLB.
glb, err := occt.StepToGLB(ctx, stepBytes)
For servers, create one Converter and reuse it: the wasm module is compiled once, and each conversion runs in its own short-lived instance (goroutine-safe, memory returned to the OS per call).
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrInvalidInput reports empty or malformed arguments. ErrInvalidInput = errors.New("occt: invalid input") // ErrParse reports an input file that could not be parsed. ErrParse = errors.New("occt: file parse failed") // ErrEmptyModel reports an input file with no convertible shapes. ErrEmptyModel = errors.New("occt: no shapes in file") // ErrConversion reports a failure while meshing or writing glTF. ErrConversion = errors.New("occt: conversion failed") )
Sentinel errors, matchable with errors.Is. The returned error also carries the shim's detailed message.
Functions ¶
Types ¶
type Converter ¶
type Converter struct {
// contains filtered or unexported fields
}
Converter holds the compiled OCCT wasm module. It is safe for concurrent use: every conversion runs in a fresh, short-lived module instance.
func NewConverter ¶
func NewConverter(ctx context.Context, opts ...ConverterOption) (*Converter, error)
NewConverter compiles the embedded OCCT wasm module (the expensive step, done once) and returns a reusable, goroutine-safe Converter.
type ConverterOption ¶
type ConverterOption func(*converterConfig)
ConverterOption configures a Converter.
func WithDefaultOptions ¶
func WithDefaultOptions(opts ...Option) ConverterOption
WithDefaultOptions sets conversion options applied to every StepToGLB call on this Converter (still overridable per call).
func WithInterpreter ¶
func WithInterpreter() ConverterOption
WithInterpreter selects wazero's interpreter engine instead of its optimizing compiler. Much slower; intended for tests and debugging.
type Option ¶
type Option func(*options)
Option configures a single conversion.
func WithAngularDeflection ¶
WithAngularDeflection sets the angular deflection for meshing, in radians. Smaller values produce finer meshes on curved surfaces.
func WithLinearDeflection ¶
WithLinearDeflection sets the chordal deflection for meshing. With WithRelativeDeflection(true) (the default) it is a fraction of the shape's bounding box; otherwise it is an absolute distance in model units (millimeters for most STEP files). Smaller values produce finer meshes.
func WithRelativeDeflection ¶
WithRelativeDeflection chooses whether linear deflection is relative to each shape's bounding box (true, default) or absolute in model units.