MCPcopy Index your code
hub / github.com/g3n/engine / parseObjLine

Method parseObjLine

loader/obj/obj.go:427–472  ·  view source on GitHub ↗

Parses obj file line, dispatching to specific parsers

(line string)

Source from the content-addressed store, hash-verified

425
426// Parses obj file line, dispatching to specific parsers
427func (dec *Decoder) parseObjLine(line string) error {
428
429 // Ignore empty lines
430 fields := strings.Fields(line)
431 if len(fields) == 0 {
432 return nil
433 }
434 // Ignore comment lines
435 ltype := fields[0]
436 if strings.HasPrefix(ltype, "#") {
437 return nil
438 }
439 switch ltype {
440 // Material library
441 case "mtllib":
442 return dec.parseMatlib(fields[1:])
443 // Object name
444 case "o":
445 return dec.parseObject(fields[1:])
446 // Group names. We are considering "group" the same as "object"
447 // This may not be right
448 case "g":
449 return dec.parseObject(fields[1:])
450 // Vertex coordinate
451 case "v":
452 return dec.parseVertex(fields[1:])
453 // Vertex normal coordinate
454 case "vn":
455 return dec.parseNormal(fields[1:])
456 // Vertex texture coordinate
457 case "vt":
458 return dec.parseTex(fields[1:])
459 // Face vertex
460 case "f":
461 return dec.parseFace(fields[1:])
462 // Use material
463 case "usemtl":
464 return dec.parseUsemtl(fields[1:])
465 // Smooth
466 case "s":
467 return dec.parseSmooth(fields[1:])
468 default:
469 dec.appendWarn(objType, "field not supported: "+ltype)
470 }
471 return nil
472}
473
474// Parses a mtllib line:
475// mtllib <name>

Callers

nothing calls this directly

Calls 9

parseMatlibMethod · 0.95
parseObjectMethod · 0.95
parseVertexMethod · 0.95
parseNormalMethod · 0.95
parseTexMethod · 0.95
parseFaceMethod · 0.95
parseUsemtlMethod · 0.95
parseSmoothMethod · 0.95
appendWarnMethod · 0.95

Tested by

no test coverage detected