MCPcopy Index your code
hub / github.com/g3n/engine / parseKd

Method parseKd

loader/obj/obj.go:814–829  ·  view source on GitHub ↗

Parses diffuse reflectivity: Kd r g b

(fields []string)

Source from the content-addressed store, hash-verified

812// Parses diffuse reflectivity:
813// Kd r g b
814func (dec *Decoder) parseKd(fields []string) error {
815
816 if len(fields) < 3 {
817 return dec.formatError("'Kd' with less than 3 fields")
818 }
819 var colors [3]float32
820 for pos, f := range fields[:3] {
821 val, err := strconv.ParseFloat(f, 32)
822 if err != nil {
823 return err
824 }
825 colors[pos] = float32(val)
826 }
827 dec.matCurrent.Diffuse.Set(colors[0], colors[1], colors[2])
828 return nil
829}
830
831// Parses emissive color:
832// Ke r g b

Callers 1

parseMtlLineMethod · 0.95

Calls 2

formatErrorMethod · 0.95
SetMethod · 0.45

Tested by

no test coverage detected