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

Method NewGeometry

loader/collada/geometry.go:41–69  ·  view source on GitHub ↗

NewGeometry creates and returns a pointer to a new instance of the geometry with the specified id in the Collada document, its primitive type and and error.

(id string)

Source from the content-addressed store, hash-verified

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.
41func (d *Decoder) NewGeometry(id string) (geometry.IGeometry, uint32, error) {
42
43 id = strings.TrimPrefix(id, "#")
44 // Look for geometry with specified id in the dom
45 var geo *Geometry
46 for _, g := range d.dom.LibraryGeometries.Geometry {
47 if g.Id == id {
48 geo = g
49 break
50 }
51 }
52 if geo == nil {
53 return nil, 0, fmt.Errorf("Geometry:%s not found", id)
54 }
55
56 // Geometry type
57 switch gt := geo.GeometricElement.(type) {
58 // Collada mesh category includes points, lines, linestrips, triangles,
59 // triangle fans, triangle strips and polygons.
60 case *Mesh:
61 return newMesh(gt)
62 // B-Spline
63 // Bezier
64 // NURBS
65 // Patch
66 default:
67 return nil, 0, fmt.Errorf("GeometryElement:%T not supported", gt)
68 }
69}
70
71func newMesh(m *Mesh) (*geometry.Geometry, uint32, error) {
72

Callers 1

GetGeometryMethod · 0.95

Calls 1

newMeshFunction · 0.85

Tested by

no test coverage detected