OpenToLibraryFS opens object(s) from given file in the given filesystem into the scene's Library using a decoder based on the file extension. The library key name must be unique, and is given by libnm -- if empty, then the filename (only) without extension is used. Supported formats include: .obj =
(fsys fs.FS, fname string, libnm string)
| 211 | // |
| 212 | // must have same name as .obj, or a default material is used. |
| 213 | func (sc *Scene) OpenToLibraryFS(fsys fs.FS, fname string, libnm string) (*Group, error) { |
| 214 | dec, err := DecodeFileFS(fsys, fname) |
| 215 | if err != nil { |
| 216 | return nil, err |
| 217 | } |
| 218 | if libnm == "" { |
| 219 | _, fn := filepath.Split(fname) |
| 220 | ext := filepath.Ext(fn) |
| 221 | libnm = strings.TrimSuffix(fn, ext) |
| 222 | } |
| 223 | gp := sc.NewInLibrary(libnm) |
| 224 | dec.SetGroup(sc, gp) |
| 225 | return gp, nil |
| 226 | } |
| 227 | |
| 228 | // OpenScene opens a scene from the given file, using a decoder based on |
| 229 | // the file extension in first file name. |
no test coverage detected