npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@timefold/obj

v0.0.2

Published

obj loader and parser for timefold

Downloads

12

Readme

@timefold/obj

Fast and efficient, zero dependency .obj and .mtl loader and parser.

Overview

See it in action in this stackblitz example (⚠️ Renderer requires WebGPU).

  • 🔥 Fast and efficient.
  • 🔺 Use it in WebGL and WebGPU.
  • 🪶 Only 2.3 kB (minified and gzipped).
  • 🚀 Awesome DX and type safety.
  • 🔨 Supports interleaved, non-interleaved and indexed results.

Installation

  • npm i @timefold/obj

Quick start

import { ObjLoader, ObjParser, MtlLoader, MtlParser } from '@timefold/obj';

// fetch and parse a .obj file
const objResult1 = await ObjLoader.load('/assets/file.obj');
// or parse from a string
const objResult2 = ObjParser.parse('...');

// ---

// fetch and parse a .mtl file
const mtlResult1 = await MtlLoader.load('/assets/file.mtl');
// or parse from a string
const mtlResult2 = MtlParser.parse('...');

Options

You can also create a instance of the loader or parser yourself and pass some options:

import { ObjLoader, ObjParser } from '@timefold/obj';

const Loader = ObjLoader.createLoader({
    mode: 'interleaved-typed-array-indexed',
    splitObjectMode: 'object',
    flipUvX: false,
    flipUvY: false,
});

const objResult1 = await Loader.load('/assets/file.obj');

// ---

const parse = ObjParser.createParser({
    mode: 'interleaved-typed-array-indexed',
    splitObjectMode: 'object',
    flipUvX: false,
    flipUvY: false,
});

const objResult2 = parse('...');

Here is the full type of available options:

type Mode = 
    | "interleaved-number-array"
    | "interleaved-typed-array"
    | "interleaved-number-array-indexed"
    | "interleaved-typed-array-indexed" // default
    | "non-interleaved-number-array"
    | "non-interleaved-typed-array"
    | "non-interleaved-number-array-indexed"
    | "non-interleaved-typed-array-indexed"

type ParserOptions = {
    mode: Mode;
    splitObjectMode: 'object' | 'group';
    flipUvX: boolean;
    flipUvY: boolean;
};

The result will depend on the mode and looks like that

// This will be automatically inferred for you from the `mode` option
type Primitive =
    | InterleavedObjPrimitive
    | InterleavedObjPrimitiveIndexed
    | NonInterleavedObjPrimitive
    | NonInterleavedObjPrimitiveIndexed;

type ObjResult = {
    objects: Record<string, {
        name: string;
        primitives: Record<string, Primitive>;
    }>;
};

API

Types are abbreviated for a short and concise overview.

// obj
ObjLoader.load(path: string) => ObjResult
ObjParser.parse(source: string) => ObjResult
ObjLoader.createLoader(options?: Options) => Loader
ObjParser.createParser(options?: Options) => ParseFn
ObjParser.convertInterleavedToIndexed(primitive: Primitive) => ConvertedPrimitive
ObjParser.convertNonInterleavedToIndexed(primitive: Primitive) => ConvertedPrimitive
ObjParser.convertInterleavedToTypedArray(primitive: Primitive) => ConvertedPrimitive
ObjParser.convertNonInterleavedToTypedArray(primitive: Primitive) => ConvertedPrimitive

// mtl
MtlLoader.load(path: string) => MtlResult
MtlParser.parse(source: string) => MtlResult