meshoptimizer's glTF buffer decoder (EXT_meshopt_compression) in MoonBit, decoding as meshoptimizer 1.3.0 does
moon add t-ujiie-g/meshopt/// A buffer view of `count` elements of `size` bytes, or None if `source` is malformed.
fn view(
source : FixedArray[Byte],
count : Int,
size : Int,
mode : @meshopt.Mode,
filter : @meshopt.Filter,
) -> FixedArray[Byte]? {
// Check before allocating: the counts come from an untrusted glTF.
guard @meshopt.source_fits(count, size, source.length(), mode, filter) else {
return None
}
let target = FixedArray::make(count * size, b'\x00')
let ok = @meshopt.decode_gltf_buffer(
target,
count,
size,
source,
0,
source.length(),
mode,
filter,
)
if ok { Some(target) } else { None }
}pub(all) enum Filter {
NoFilter
Octahedral
Quaternion
Exponential
Color
}pub(all) enum Mode {
Attributes
Triangles
Indices
}Install
Download zipmeshoptimizer's glTF buffer decoder (EXT_meshopt_compression) in MoonBit, decoding as meshoptimizer 1.3.0 does