nnrj/threejson
소개
ThreeJSON is a JSON-driven declarative scene runtime for Three.js, designed for persistent, mutable and extensible 3D worlds — from human-authored scenes to AI and Agent-driven generation and control.
창작 및 미디어측정된 스타 증가
- in 24h
- 0
- in 7 days
- 0
- in 15 days
- 기록 수집 중
- in 1 month
- 기록 수집 중
서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.
README.md
OriginalThreeJSON
JSON-driven Three.js scene runtime: build 3D scenes from configuration instead of hand-writing large chunks of Three.js boilerplate.
Official website:https://threejson.org/
Repository: github.com/nnrj/threejson · Issues: GitHub Issues
npm:threejson - npm 、@threejson/assets - npm
Demos: ThreeJSON Examples SceneEditor: ThreeJSON SceneEditor
Exact description:
ThreeJSON is a JSON-driven declarative scene runtime for Three.js, designed for persistent, mutable and extensible 3D worlds — from human-authored scenes to AI and Agent-driven generation and control.
Use in your project
npm install threejson
In addition, certain built-in models rely on the assets package (which contains textures, sample scene JSONs, etc.). By default, no manual setup is required as ThreeJSON will automatically fetch them via CDN.
If you prefer to host or use them locally, you can install the assets package separately:
npm install @threejson/assets
Development environment
To run tests, examples, and external tools (agent bridges, MCP) in this repo, use Node.js 24+.
git clone https://github.com/nnrj/threejson.git
cd threejson
nvm use # reads .nvmrc
npm ci && npm test
See docs/zh/development.md (Chinese; English: docs/en/development.md).
Use in your project
npm install threejson
In addition, certain built-in models rely on the assets package (which contains textures, sample scene JSONs, etc.). By default, no manual setup is required as ThreeJSON will automatically fetch them via CDN.
If you prefer to host or use them locally, you can install the assets package separately:
npm install @threejson/assets
The philosophy of ThreeJSON, distilled into four lines:
Scene as Data — The scene is data. Runtime as Engine — The runtime is the engine. Domain as Extension — Domains are extensions. Agent as Operator — Agents are operators.
In plain English:
You define the world. AI creates and reshapes it. ThreeJSON brings it to life.
Contributing and AI-generated code
This project allows AI-assisted contributions, subject to the AI-generated code guidelines in docs/zh/development.md (keep docs in sync, human-reviewed plans, attach docs/dev/plans/ with each submission). See also docs/dev/plans/README.md.
Documentation
See docs/en/README.md for the full caller guide, JSON format, and API reference.
If you want to understand the design of domains/, how domainModelList works, or how to create a custom business domain, see docs/en/domains.md.
Install from npm (package name: threejson)
Peer dependencies must be installed in your app (versions should satisfy the peerDependencies field in package.json):
- Three.js:
>= 0.179.0(recommended 0.184.x). Seedocs/zh/three-compat.md(Chinese; version matrix and workarounds).
npm install threejson three @tweenjs/tween.js
The minimal scene runtime has no mandatory archive, GIF, HTML rasterization, CSG, or SDF-text package. Install an optional peer only when the scene uses its capability:
.tjzarchives:fflate- GIF textures:
gifuct-js - HTML
infoPaneltextures:html2canvas-pro - CSG (
joins,inters, orholes):three-bvh-csg three-mesh-bvh - SDF scene text:
troika-three-text
For a normal JSON scene, prefer the narrow runtime entry:
import { createJsonScene } from "threejson/runtime";
Use the aggregate entry only when you also need built-in business domains or its compatibility API surface:
import { createSceneRuntime, deployMesh, door } from "threejson";
import { applyJsonPatchToObjectDescriptor } from "threejson/patch";
import { applyJsonPatchToJsonDocument } from "threejson/patch-core";
For pure core without built-in domains: import { createSceneRuntime } from "threejson/core". To control registration order yourself, add import "threejson/builtins/register".
Static assets (textures / models / scene JSON)
After npm install, built-in domains and /assets/... paths in scene JSON default to the active base first, then fall back to jsDelivr @threejson/assets (version pinned in runtime ASSETS_PACKAGE_VERSION). You do not need to install the assets package for CDN fallback.
Use a local static mount (clone, self-hosted):
import { createJsonScene } from "threejson/runtime";
import { LOCAL_ASSETS_BASE, setAssetsBaseUrl } from "threejson/assets";
setAssetsBaseUrl(LOCAL_ASSETS_BASE); // "/assets"
await createJsonScene(payload, {
canvas,
assetsBase: "/assets" // or sceneConfig.assetsBase in JSON
});
Priority (high → low): createJsonScene({ assetsBase }) → sceneConfig.assetsBase → setAssetsBaseUrl() → active-base-first CDN fallback. Keep /assets/textures/... in JSON; the loader rewrites against the active base first and falls back to CDN. Full https:// URLs are unchanged.
Bundlers (Vite, Webpack, etc.) resolve three and addons from node_modules.
npm + bundler vs import map + CDN: npm builds give locked versions, reproducible installs, and tree-shaking, at the cost of a build step. Import maps pointing at esm.sh / jsdelivr work in no-build HTML demos but depend on CDN availability; pin major versions in URLs to reduce drift.
Use without npm (clone + static server)
Clone the repo and serve it over HTTP (e.g. Live Server). For ordinary JSON scenes, map threejson/runtime → core/runtime.js, plus three, three/examples/jsm/, and @tweenjs/tween.js. Map the aggregate threejson → builtins/full.js only when built-in business domains are needed. Optional capability packages are mapped only when used; in particular, SDF text needs troika-three-text, not fflate. See examples/html-demo/README.md and docs/en/quick-start.md.
Quick Local Preview
After starting a static server, open index.html at the repo root. It redirects to website/index.html. The tutorial index is examples/html-demo/demo.html, which aggregates the examples/html-demo/*.html samples together with the root-level integrated pages such as room-show.html, tools/scene-host/editor/index.html, tools/scene-host/player/index.html, and port-show.html.
License
Trademark
"ThreeJSON" and the ThreeJSON logo are trademarks of the ThreeJSON project. The MIT license covers the source code only and does not grant rights to the ThreeJSON name/logo. See TRADEMARK.md (中文版:TRADEMARK.zh-CN.md) for usage guidelines and how to report impersonation.
관련 프로젝트 살펴보기
불러오는 중…