GetMaterial returns a pointer to an instance of the material with the specified id in the Collada document and an error. If no previous instance of the material was found it is created.
(id string)
| 18 | // with the specified id in the Collada document and an error. |
| 19 | // If no previous instance of the material was found it is created. |
| 20 | func (d *Decoder) GetMaterial(id string) (material.IMaterial, error) { |
| 21 | |
| 22 | // If material already created, returns it |
| 23 | mat := d.materials[id] |
| 24 | if mat != nil { |
| 25 | return mat, nil |
| 26 | } |
| 27 | |
| 28 | // Creates material and saves it associated with its id |
| 29 | mat, err := d.NewMaterial(id) |
| 30 | if err != nil { |
| 31 | return nil, err |
| 32 | } |
| 33 | d.materials[id] = mat |
| 34 | return mat, nil |
| 35 | } |
| 36 | |
| 37 | // NewMaterial creates and returns a pointer to a new material |
| 38 | // from the specified material id/url in the dom |