LoadScene creates a parent Node which contains all nodes contained by the specified scene index from the GLTF Scenes array.
(sceneIdx int)
| 152 | // LoadScene creates a parent Node which contains all nodes contained by |
| 153 | // the specified scene index from the GLTF Scenes array. |
| 154 | func (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. |