• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

visgl / loaders.gl / 25798238260

13 May 2026 12:10PM UTC coverage: 60.607% (+0.3%) from 60.27%
25798238260

push

github

web-flow
feat(json) GeoJSON -> geoarrow, schema, logging  (#3399)

13466 of 24516 branches covered (54.93%)

Branch coverage included in aggregate %.

448 of 541 new or added lines in 12 files covered. (82.81%)

1264 existing lines in 117 files now uncovered.

27516 of 43103 relevant lines covered (63.84%)

15056.99 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

100.0
/modules/obj/src/lib/parse-obj.ts
1
import type {Mesh, MeshAttributes} from '@loaders.gl/schema';
2
import {getMeshBoundingBox} from '@loaders.gl/schema-utils';
3
import {parseOBJMeshes} from './parse-obj-meshes';
4
import {getOBJSchema} from './get-obj-schema';
5

6
export function parseOBJ(text: string, options?): Mesh {
7
  const {meshes} = parseOBJMeshes(text);
14✔
8

9
  // @ts-expect-error
10
  const vertexCount = meshes.reduce((s, mesh) => s + mesh.header.vertexCount, 0);
62✔
11
  // TODO - render objects separately
12
  const attributes = mergeAttributes(meshes, vertexCount);
14✔
13

14
  const header = {
14✔
15
    vertexCount,
16
    // @ts-ignore Need to export Attributes type
17
    boundingBox: getMeshBoundingBox(attributes)
18
  };
19

20
  const schema = getOBJSchema(attributes, {
14✔
21
    mode: 4,
22
    boundingBox: header.boundingBox
23
  });
24

25
  return {
14✔
26
    // Data return by this loader implementation
27
    loaderData: {
28
      header: {}
29
    },
30

31
    // Normalised data
32
    schema,
33
    header,
34
    mode: 4, // TRIANGLES
35
    topology: 'point-list',
36

37
    attributes
38
  };
39
}
40

41
// eslint-disable-next-line max-statements
42
function mergeAttributes(meshes, vertexCount): MeshAttributes {
43
  const positions = new Float32Array(vertexCount * 3);
14✔
44
  let normals;
45
  let colors;
46
  let uvs;
47
  let i = 0;
14✔
48

49
  for (const mesh of meshes) {
14✔
50
    const {POSITION, NORMAL, COLOR_0, TEXCOORD_0} = mesh.attributes;
62✔
51

52
    positions.set(POSITION.value, i * 3);
62✔
53

54
    if (NORMAL) {
62✔
55
      normals = normals || new Float32Array(vertexCount * 3);
7✔
56
      normals.set(NORMAL.value, i * 3);
7✔
57
    }
58
    if (COLOR_0) {
62✔
UNCOV
59
      colors = colors || new Float32Array(vertexCount * 3);
1✔
UNCOV
60
      colors.set(COLOR_0.value, i * 3);
1✔
61
    }
62
    if (TEXCOORD_0) {
62✔
63
      uvs = uvs || new Float32Array(vertexCount * 2);
6✔
64
      uvs.set(TEXCOORD_0.value, i * 2);
6✔
65
    }
66

67
    i += POSITION.value.length / 3;
62✔
68
  }
69

70
  const attributes: MeshAttributes = {};
14✔
71
  attributes.POSITION = {value: positions, size: 3};
14✔
72

73
  if (normals) {
14✔
74
    attributes.NORMAL = {value: normals, size: 3};
7✔
75
  }
76
  if (colors) {
14✔
UNCOV
77
    attributes.COLOR_0 = {value: colors, size: 3};
1✔
78
  }
79
  if (uvs) {
14✔
80
    attributes.TEXCOORD_0 = {value: uvs, size: 2};
6✔
81
  }
82

83
  return attributes;
14✔
84
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc