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

visgl / loaders.gl / 20352515932

18 Dec 2025 09:56PM UTC coverage: 35.115% (-28.4%) from 63.485%
20352515932

push

github

web-flow
feat(loader-utils): Export is-type helpers (#3258)

1188 of 1998 branches covered (59.46%)

Branch coverage included in aggregate %.

147 of 211 new or added lines in 13 files covered. (69.67%)

30011 existing lines in 424 files now uncovered.

37457 of 108056 relevant lines covered (34.66%)

0.79 hits per line

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

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

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

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

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

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

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

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

×
UNCOV
37
    attributes
×
UNCOV
38
  };
×
UNCOV
39
}
×
40

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

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

×
UNCOV
52
    positions.set(POSITION.value, i * 3);
×
UNCOV
53

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

×
UNCOV
67
    i += POSITION.value.length / 3;
×
UNCOV
68
  }
×
UNCOV
69

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

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

×
UNCOV
83
  return attributes;
×
UNCOV
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