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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@carbonenginejs/format-gltf

v0.1.2

Published

glTF/GLB format reader with helpers for converting modern mesh scenes into CarbonEngineJS geometry data.

Readme

@carbonenginejs/format-gltf

Pure-JavaScript CarbonEngineJS-facing package for the glTF 2.0 / GLB format. No native tooling, no build step; it runs in Node and modern browsers.

The package currently exposes a read path. glTF is only the import source; it emits the shared CarbonEngineJS JSON geometry schema: deinterleaved vertex channels, triangle-index groups, optional skin skeletons, and explicit uncompressed transform animation curves.

CarbonEngine and Fenris Creations (CCP Games) are named in this package for interoperability and target-ecosystem context only. glTF itself is not a CCP format, and this package contains no CarbonEngine or Fenris Creations (CCP Games) source code.

Package

Install

npm install @carbonenginejs/format-gltf

Public API

The package root exports one public class: CjsFormatGltf. The Cjs prefix marks this as a CarbonEngineJS format/construction boundary, not an engine runtime class.

import CjsFormatGltf from "@carbonenginejs/format-gltf";

const gltf = new CjsFormatGltf({
    emit: "json",                  // "json" only for now
    source: "mesh.glb",            // name written to grannyFileSource
    buffers: null,                  // optional external .bin buffers for .gltf object input
    packTangents: false,            // opt-in: pack basis for GR2-style shader inputs
    uvHandedness: "right",          // "right" (default) | "left"
    rebuildMissingNormals: false,
    rebuildMissingTangents: false,
    rebuildMissingBiNormals: false,
    classes: {
        Root: CjsGeometryRoot,
        Mesh: CjsGeometryMesh,
        Model: CjsGeometryModel,
        Animation: CjsGeometryAnimation
    }
});

const json = gltf.Read(glbBytes);
const summary = gltf.Inspect(glbBytes);
const text = JSON.stringify(gltf.ToJSON(json));

The named export is the same class for callers that prefer named imports:

import { CjsFormatGltf } from "@carbonenginejs/format-gltf";

Format Rules

  • The package root currently exports one public format class: CjsFormatGltf.
  • Instance methods are PascalCase because format instances can hydrate or sit beside CarbonClasses without colliding with camelCase data fields.
  • Static one-shot methods are camelCase because they live on CjsFormatGltf itself, not on hydrated CarbonClass instances.
  • src/CjsFormatGltf.js is the public format boundary. Parser and geometry helpers live under src/core.
  • Read / static read return the shared JSON schema. emit: "raw" is not exposed yet because parser state is intentionally internal.
  • ToJSON / static toJSON converts format output to JSON-compatible data. It is not a glTF, GLB, OBJ, or GR2 writer.
  • Shared schema, registries, hydration utilities, decorators, math helpers, and animation-curve helpers are expected to move into future shared core packages once those packages exist.

JSON Graph

emit: "json" is the only public output mode. Square-bracketed fields are conditional in the broader shared schema:

Root
|-- grannyFileFormatRevision, grannyFileSource
|-- meshes: Mesh[]
|   |-- name, minBounds, maxBounds
|   |-- boneBindings: BoneBinding[]
|   |-- morphTargets: MorphTarget[]
|   |-- vertex: VertexChannels
|   |   |-- position, normal, tangent, binormal
|   |   |-- texcoord0, texcoord1
|   |   |-- blendIndice, blendWeight
|   |   `-- all channels are flat numeric arrays
|   `-- indices: IndexGroup[]
|       `-- name, bytesPerIndex, faces
|-- models: Model[]
|   `-- name, skeleton, meshBindings
`-- animations: Animation[]
    `-- trackGroups: TrackGroup[]
        `-- transformTracks: TransformTrack[]
            |-- orientation: Curve
            |-- position: Curve
            `-- scaleShear: Curve

glTF animation samplers are emitted as explicit uncompressed curves:

{
    source: {
        format: 1,
        degree: 1,
        interpolation: "LINEAR",
        path: "orientation"
    },
    uncompressed: {
        dimension: 4,
        knots: [ 0, 1 ],
        controls: [ 0, 0, 0, 1, 0, 0, 0.707, 0.707 ]
    }
}

This is deliberate. glTF animation data is already explicit sampler data, so it should not pretend to be a compressed Granny curve. STEP samplers use degree 0; LINEAR and CUBICSPLINE currently emit key values with degree 1 while preserving the original interpolation name in source.interpolation.

glTF Coverage

This first version handles the practical geometry path:

  • glTF 2.0 JSON objects
  • UTF-8 .gltf JSON text/bytes
  • .glb version 2 binary containers
  • embedded data: buffers
  • caller-provided external buffers via buffers
  • Node-only readFile(path) for .gltf/.glb
  • accessors, bufferViews, byte strides, normalized integer attributes
  • sparse accessors
  • triangle, triangle-strip, and triangle-fan primitives
  • POSITION, NORMAL, TANGENT, TEXCOORD_0, TEXCOORD_1
  • JOINTS_0 -> blendIndice
  • WEIGHTS_0 -> blendWeight
  • skins as shared-schema models/skeletons
  • transform animation channels for translation, rotation, and scale
  • morph target delta channels for position, normal, and tangent

Unsupported glTF primitive modes throw. Materials, textures, cameras, lights, scene transforms, mesh instancing, and extensions are not yet converted into CarbonEngineJS runtime objects.

Options

  • emit: "json" default. Other values currently throw.
  • source: default "memory". Written to grannyFileSource and used in error messages.
  • buffers: optional external buffer source for object/JSON .gltf input. Accepts an array, map, or object keyed by buffer index or URI.
  • packTangents: default false. true converts explicit normal/tangent/ binormal data into a packed four-component tangent channel for GR2-style shader inputs. glTF TANGENT.w is used when generating binormals.
  • uvHandedness: "right" default. Used when tangents/binormals are generated rather than authored.
  • rebuildMissingNormals: default false.
  • rebuildMissingTangents: default false.
  • rebuildMissingBiNormals: default false.
  • Missing-channel rebuild options and packTangents also accept rule functions. They receive { format, options, raw, json, mesh, meshIndex, feature, channel } and must return true or false.
  • classes: optional for new CjsFormatGltf(options), Read, and static read. Accepted keys are exposed as CjsFormatGltf.CLASS_KEYS.

Tests

npm test

Tests are fully self-contained and build glTF/GLB fixtures in memory. They do not require local asset folders, network access, or game files.

License

MIT (see LICENSE and NOTICE).

This package contains no CarbonEngine or Fenris Creations (CCP Games) code. Its output shape targets the shared CarbonEngineJS JSON geometry schema used for CarbonEngine interoperability.