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

Method LoadScene

loader/gltf/loader.go:154–175  ·  view source on GitHub ↗

LoadScene creates a parent Node which contains all nodes contained by the specified scene index from the GLTF Scenes array.

(sceneIdx int)

Source from the content-addressed store, hash-verified

152// LoadScene creates a parent Node which contains all nodes contained by
153// the specified scene index from the GLTF Scenes array.
154func (g *GLTF) LoadScene(sceneIdx int) (core.INode, error) {
155
156 // Check if provided scene index is valid
157 if sceneIdx < 0 || sceneIdx >= len(g.Scenes) {
158 return nil, fmt.Errorf("invalid scene index")
159 }
160 log.Debug("Loading Scene %d", sceneIdx)
161 sceneData := g.Scenes[sceneIdx]
162
163 scene := core.NewNode()
164 scene.SetName(sceneData.Name)
165
166 // Load all nodes
167 for _, ni := range sceneData.Nodes {
168 child, err := g.LoadNode(ni)
169 if err != nil {
170 return nil, err
171 }
172 scene.Add(child)
173 }
174 return scene, nil
175}
176
177// LoadNode creates and returns a new Node described by the specified index
178// in the decoded GLTF Nodes array.

Callers

nothing calls this directly

Calls 5

SetNameMethod · 0.95
LoadNodeMethod · 0.95
AddMethod · 0.95
NewNodeFunction · 0.92
DebugMethod · 0.80

Tested by

no test coverage detected