MCPcopy Create free account
hub / github.com/cogentcore/core / OpenToLibraryFS

Method OpenToLibraryFS

xyz/io.go:213–226  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

211//
212// must have same name as .obj, or a default material is used.
213func (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.

Callers 2

OpenToLibraryMethod · 0.95
mainFunction · 0.80

Calls 4

NewInLibraryMethod · 0.95
DecodeFileFSFunction · 0.85
SplitMethod · 0.80
SetGroupMethod · 0.65

Tested by

no test coverage detected