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

Method GetMaterial

loader/collada/material.go:20–35  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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.
20func (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

Callers 1

newNodeMethod · 0.95

Calls 1

NewMaterialMethod · 0.95

Tested by

no test coverage detected