loadAccessorF32 loads data from the specified accessor and performs validation of the Type and ComponentType.
(ai int, usage string, validTypes []string, validComponentTypes []int)
| 946 | |
| 947 | // loadAccessorF32 loads data from the specified accessor and performs validation of the Type and ComponentType. |
| 948 | func (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. |
| 972 | func (g *GLTF) loadAccessorBytes(ac Accessor) ([]byte, error) { |
no test coverage detected