@drawcall/glts

中文文档
6.1.0发布于 2026/11/13MITTypeScriptES Module构建来源已验证近 30 天下载 5364

Like glTF, but for procedural Three.js assets.

原始使用文档
文档目录3 节
  1. Usage
  2. CLI
  3. Agent skill

GLTS

Like glTF, but for procedural Three.js assets.

A .glts file is a small TypeScript script that builds a scene with ordinary Three.js code. GLTSLoader fetches and runs it and gives you a native THREE.Scene that you can add anywhere, update every frame, hot reload, and dispose.

Use GLTS when an asset is easier to write as code than to model: procedural geometry, parametric or animated props, or assets written by AI coding agents. Assets can load other assets, share code through helper modules, be instanced like a Three.js InstancedMesh, import npm packages, and bring their own preview staging and render settings.

GLTS runs scripts as code, not in a sandbox. Only load scripts you trust.

pnpm add @drawcall/glts three

Usage

A script builds its asset in the scene it imports:

// public/crystal.glts
import * as THREE from "three/webgpu"
import { disposeRecursive, onDispose, onFrame, scene } from "@drawcall/glts"

const crystal = new THREE.Mesh(new THREE.IcosahedronGeometry(), new THREE.MeshNormalMaterial())
scene.add(crystal)

onFrame((delta) => {
  crystal.rotation.y += delta
})

onDispose(() => disposeRecursive(scene))

The app loads it like any other Three.js asset and renders with WebGPU:

import { GLTSLoader } from "@drawcall/glts"
import * as THREE from "three/webgpu"

const renderer = new THREE.WebGPURenderer({ canvas })
await renderer.init()

const loader = new GLTSLoader(new THREE.LoadingManager())
const crystal = await loader.loadAsync("/crystal.glts")
scene.add(crystal)

const timer = new THREE.Timer()
renderer.setAnimationLoop((time) => {
  timer.update(time)
  crystal.update(timer.getDelta())
  renderer.render(scene, camera)
})

In a Vite app, add glts() from @drawcall/glts/vite to the plugins: public scripts then load precompiled and share the app's packages.

CLI

Render a .glts asset to PNG or export it to GLB (Node.js 22.18+ or 24.11+):

npx drawcall glts render asset.glts -o preview.png
npx drawcall glts render asset.glts -o views.png --views '[[{"camera":"+x"},{"camera":"persp"}]]'
npx drawcall glts export asset.glts -o asset.glb

Rendering uses @drawcall/webgpu, with or without a GPU, and includes preview staging; in Node.js, render(file, options) from @drawcall/glts/node returns the same PNG as bytes. Export excludes it and writes supported geometry, materials, textures, skins, and explicit animation clips; procedural frame callbacks remain in the .glts file.

Agent skill

Everything else (helpers, composition, instancing, rendering, reload, packages, and the Vite plugin) is documented in the GLTS skill. Install it for your coding agent:

npx skills add drawcall-ai/glts --skill glts

The skill also ships inside the @drawcall/glts npm package at skills/glts/SKILL.md, so skills-npm links it automatically from node_modules, at the version you have installed.

版本与发布记录

@drawcall/glts 共发布 37 个版本,首次发布于 2026/08/12;过去 12 个月发布了 37 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
6.1.0latest2026/11/13今天
6.0.02026/11/121 天前
5.2.02026/11/112 天前
5.1.02026/11/102 天前
5.0.02026/11/103 天前
4.1.02026/11/058 天前

关于 @drawcall/glts 的常见问题

@drawcall/glts 是什么?

Like glTF, but for procedural Three.js assets.

如何安装 @drawcall/glts?

在项目目录运行 npm install @drawcall/glts,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:three(>=0.186.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。它还提供命令行工具 glts,可以用 npx glts 直接运行。

@drawcall/glts 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@drawcall/glts 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@drawcall/glts 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js ^22.18.0 || >=24.11.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@drawcall/glts 可以商用吗?

@drawcall/glts 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@drawcall/glts 的下载量有多少?

根据 npm 官方下载统计,@drawcall/glts 在 2026/10/13 – 2026/11/11 这 30 天内被下载 5,364 次,日均约 179 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@drawcall/glts 还在维护吗?

最新版本 6.1.0 发布于 2026/11/13(今天);至今共发布 37 个版本,其中过去 12 个月发布了 37 个;首次发布于 2026/08/12。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。