MCPcopy
hub / github.com/g3n/engine / loadAccessorF32

Method loadAccessorF32

loader/gltf/loader.go:948–969  ·  view source on GitHub ↗

loadAccessorF32 loads data from the specified accessor and performs validation of the Type and ComponentType.

(ai int, usage string, validTypes []string, validComponentTypes []int)

Source from the content-addressed store, hash-verified

946
947// loadAccessorF32 loads data from the specified accessor and performs validation of the Type and ComponentType.
948func (g *GLTF) loadAccessorF32(ai int, usage string, validTypes []string, validComponentTypes []int) (math32.ArrayF32, error) {
949
950 // Get Accessor for the specified index
951 ac := g.Accessors[ai]
952 if ac.BufferView == nil {
953 return nil, fmt.Errorf("accessor.BufferView == nil NOT SUPPORTED YET") // TODO
954 }
955
956 // Validate type and component type
957 err := g.validateAccessor(ac, usage, validTypes, validComponentTypes)
958 if err != nil {
959 return nil, err
960 }
961
962 // Load bytes
963 data, err := g.loadAccessorBytes(ac)
964 if err != nil {
965 return nil, err
966 }
967
968 return g.bytesToArrayF32(data, ac.ComponentType, ac.Count*TypeSizes[ac.Type])
969}
970
971// loadAccessorBytes returns the base byte array used by an accessor.
972func (g *GLTF) loadAccessorBytes(ac Accessor) ([]byte, error) {

Callers 2

LoadSkinMethod · 0.95
LoadAnimationMethod · 0.95

Calls 3

validateAccessorMethod · 0.95
loadAccessorBytesMethod · 0.95
bytesToArrayF32Method · 0.95

Tested by

no test coverage detected