4.js is an enhanced, backward-compatible fork of Three.js r185 for modern
WebGL, WebGPU, and WebXR applications. The native package is @tnb1j/4js,
and the recommended namespace is FOUR.
This repository is an independent derivative project. It is not an official Three.js release. See UPSTREAM.md, NOTICE, and LICENSE for provenance and licensing details.
This repository is an experimental public preview, not a stable release. Build, lint, unit, migration, and entry-point compatibility checks are release gates. The inherited screenshot comparison suite is available as a manually triggered CI check while its cross-environment reference differences are reviewed. Screenshot baselines are not regenerated automatically.
- Node.js 24 or newer
- npm 11 (authoritative package manager)
Node.js 26 is also used for verification.
The initial npm release is distributed under the preview tag. Install it
with:
npm install @tnb1j/4js@previewimport * as FOUR from '@tnb1j/4js';
const scene = new FOUR.Scene();
const camera = new FOUR.PerspectiveCamera( 70, innerWidth / innerHeight, 0.01, 100 );
const renderer = new FOUR.WebGLRenderer( { antialias: true } );
renderer.setSize( innerWidth, innerHeight );
document.body.appendChild( renderer.domElement );WebGPU and TSL use dedicated entry points:
import * as FOUR from '@tnb1j/4js/webgpu';
import { color, pass } from '@tnb1j/4js/tsl';Addons remain available under the familiar addon layout:
import { OrbitControls } from '@tnb1j/4js/addons/controls/OrbitControls.js';For reproducible browser builds, pin the exact package version in an import
map. The same URLs can be used with jsDelivr by replacing
https://unpkg.com/ with https://cdn.jsdelivr.net/npm/.
<script type="importmap">
{
"imports": {
"@tnb1j/4js": "https://unpkg.com/@tnb1j/4js@0.185.1-four.2/build/4.module.js",
"@tnb1j/4js/addons/": "https://unpkg.com/@tnb1j/4js@0.185.1-four.2/examples/jsm/"
}
}
</script>
<script type="module">
import * as FOUR from '@tnb1j/4js';
import { OrbitControls } from '@tnb1j/4js/addons/controls/OrbitControls.js';
const scene = new FOUR.Scene();
</script>The direct core-module URL is:
https://unpkg.com/@tnb1j/4js@0.185.1-four.2/build/4.module.js
The repository ships a migration utility:
npx four-migrate --check src
npx four-migrate --write srcLegacy bundles and entry points remain available during the compatibility window. See MIGRATION.md for package aliases, import maps, namespace changes, and staged migration guidance.
FOUR.CapabilitiesReport: portable renderer and platform capability reportsFOUR.Diagnostics: structured, bounded diagnostic event collectionFOUR.AssetScheduler: prioritized, cancellable asset task schedulingFOUR.RenderGraph: experimental dependency-aware render task graphFOUR.TemporalPipeline: WebGPU temporal antialiasing and upscaling pipeline
npm ci
npm run build
npm test
npm run test-rebranding
npm run test-migrateRun the development server with:
npm run devThe source tree is intentionally large because it includes examples, manual content, and test assets. See GITHUB_DEPLOYMENT.md before publishing a new repository.
4.js is distributed under the MIT License inherited from Three.js. The original copyright and permission notice must remain with copies or substantial portions of the software. Modified distributions should also retain NOTICE.