GetGeometry returns a pointer to an instance of the geometry with the specified id in the Collada document, its primitive type and an error. If no previous instance of the geometry was found the geometry is created
(id string)
| 19 | // and an error. If no previous instance of the geometry was found |
| 20 | // the geometry is created |
| 21 | func (d *Decoder) GetGeometry(id string) (geometry.IGeometry, uint32, error) { |
| 22 | |
| 23 | // If geometry already created, returns it |
| 24 | ginst, ok := d.geometries[id] |
| 25 | if ok { |
| 26 | return ginst.geom, ginst.ptype, nil |
| 27 | } |
| 28 | |
| 29 | // Creates geometry and saves it associated with its id |
| 30 | geom, ptype, err := d.NewGeometry(id) |
| 31 | if err != nil { |
| 32 | return nil, 0, err |
| 33 | } |
| 34 | d.geometries[id] = geomInstance{geom, ptype} |
| 35 | |
| 36 | return geom, ptype, nil |
| 37 | } |
| 38 | |
| 39 | // NewGeometry creates and returns a pointer to a new instance of the geometry |
| 40 | // with the specified id in the Collada document, its primitive type and and error. |