Skip to content

armgit / 67.js

Public Imported from GitHub
0

3D engine that AI agents drive

Stabilize trusted releases and introduce graphics-engine positioning

Nguyen Xuan Anef67edddefeb
diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml
index 3d2bd26e..e19209e3 100644
--- a/.github/workflows/publish.yml
+++ b/.github/workflows/publish.yml
@@ -30,13 +30,4 @@ jobs:
- run: npm run prepare:release
- run: npm run smoke:package
- name: Publish a new version through OIDC
- shell: bash
- run: |
- package_name=$(node -p "require('./package.json').name")
- package_version=$(node -p "require('./package.json').version")
- published_version=$(npm view "$package_name@$package_version" version --json 2>/dev/null || true)
- if [ "$published_version" = "\"$package_version\"" ]; then
- echo "$package_name@$package_version is already published."
- else
- npm publish --access public
- fi
+ run: npm run publish:ci
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 5c7eb257..a7f908ad 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,10 @@
# Changelog
+## 0.2.4
+
+- Publish changed versions through GitHub Actions and npm trusted publishing.
+- Skip versions that already exist on the registry.
+
## 0.2.3
- Publish the package under the CodePawl organization as `@codepawlhq/67js`.
diff --git a/README.md b/README.md
index b0b220ed..e7c8382b 100644
--- a/README.md
+++ b/README.md
@@ -1,7 +1,26 @@
# 67.js
-67.js is an experimental WebGL2 renderer with an explodable WALL·E study, an interactive nature world and a deterministic 3D short film.
-The viewers run without Three.js. The optional benchmark loads Three.js separately.
+67.js is a JavaScript graphics engine for the browser, built around meshes, materials and cameras familiar to Three.js users.
+It combines a focused WebGL2 renderer with interactive scene studios and a workflow for exporting images and cinematic video.
+Its optimization work targets shared geometry, predictable frame allocation and explicit CPU/GPU render budgets.
+
+The current release includes an explodable WALL·E study, an interactive nature world and a deterministic 3D short film.
+The viewers use the 67.js renderer. The optional benchmark loads Three.js for comparison.
+
+## What it includes
+
+- Instanced geometry, PBR lighting, shadows, MSAA, FXAA and specular filtering.
+- On-demand rendering for object inspection and deterministic time sampling for the short film.
+- Interactive studios with orbit controls, material settings, assembly views and GLB export.
+- CPU and GPU image/video export with memory planning and encoder backpressure.
+- A versioned npm package, standalone browser module and release metadata shared by the website and guide.
+
+## Direction
+
+67.js aims to make rendering, interaction and media production available through one browser graphics workflow.
+The next implementation adds HDR targets, bloom, color grading, reusable keyframe animation and orthographic 2D views.
+It also adds glTF asset input and landscape, portrait and square export presets for films and shorts.
+These features are tracked as implementation work. They are not part of the current published API until their release passes verification.
![WALL·E rendered by 67.js](docs/wall-e.png)
@@ -20,7 +39,9 @@ The studio renders on demand. Continuous animation pauses in hidden tabs.
npm install 67js@npm:@codepawlhq/67js
```
-The registry package is `@codepawlhq/67js`. Its local alias is `67js`, so imports stay short. The project brand is 67.js. The library is ESM and bundles its runtime dependencies. Core exports include `Renderer67`, `box`, `cylinder`, `sphere`, `torus`, `assemblyOffset`, `exportGlb`, render budget helpers and `VERSION`. Scene constructors are separate addons. Browser module downloads and the guide are available at https://67js.codepawl.com.
+The registry package is `@codepawlhq/67js`. Its local alias is `67js`, so imports stay short. The project brand is 67.js.
+
+The library is ESM and bundles its runtime dependencies. Core exports include `Renderer67`, `box`, `cylinder`, `sphere`, `torus`, `assemblyOffset`, `exportGlb`, render budget helpers and `VERSION`. Scene constructors are separate addons. Browser module downloads and the guide are available at https://67js.codepawl.com.
## Run
diff --git a/getting-started.html b/getting-started.html
index d43c5119..301d7c64 100644
--- a/getting-started.html
+++ b/getting-started.html
@@ -11,7 +11,7 @@
<a class="skip-link" href="#content">Skip to content</a>
<aside class="navigation">
<a class="brand" href="./index.html" aria-label="67.js home">67<span>.js</span></a>
- <p class="library-description">JavaScript 3D library</p>
+ <p class="library-description">JavaScript graphics engine</p>
<span class="version" data-release-version>Loading release</span>
<nav aria-label="Library">
<a href="./index.html#examples">Examples</a>
diff --git a/index.html b/index.html
index cd84b1cf..df5446d1 100644
--- a/index.html
+++ b/index.html
@@ -4,14 +4,14 @@
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="theme-color" content="#191d22" />
- <meta name="description" content="67.js is a WebGL2 library for procedural 3D scenes. Explore examples, install a release and build your first scene." />
- <title>67.js · JavaScript 3D library</title>
+ <meta name="description" content="67.js is a browser graphics engine for interactive scenes and cinematic media. Explore demos, install a release and start building." />
+ <title>67.js · JavaScript graphics engine</title>
</head>
<body>
<a class="skip-link" href="#content">Skip to content</a>
<aside class="navigation">
<a class="brand" href="./index.html" aria-label="67.js home">67<span>.js</span></a>
- <p class="library-description">JavaScript 3D library</p>
+ <p class="library-description">JavaScript graphics engine</p>
<span class="version" data-release-version>Loading release</span>
<nav aria-label="Library">
<a href="#examples" aria-current="page">Examples</a>
@@ -23,7 +23,7 @@
</aside>
<main id="content">
<header class="introduction">
- <div><h1>3D scenes, in JavaScript</h1><p>A WebGL2 renderer with procedural geometry, shared meshes and scene controls</p></div>
+ <div><h1>Browser graphics, in JavaScript</h1><p>A graphics engine with interactive scene studios and an integrated workflow for rendering images and cinematic video</p></div>
<a class="start-link" href="./getting-started.html">Build your first scene <span aria-hidden="true">↗</span></a>
</header>
<section class="install" aria-label="Install the current release">
diff --git a/package-lock.json b/package-lock.json
index f1a97948..b0846eb9 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "@codepawlhq/67js",
- "version": "0.2.3",
+ "version": "0.2.4",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "@codepawlhq/67js",
- "version": "0.2.3",
+ "version": "0.2.4",
"license": "MIT",
"devDependencies": {
"gl-matrix": "3.4.4",
diff --git a/package.json b/package.json
index 4cc44410..3f713ef2 100644
--- a/package.json
+++ b/package.json
@@ -1,9 +1,9 @@
{
"name": "@codepawlhq/67js",
- "version": "0.2.3",
+ "version": "0.2.4",
"private": false,
"type": "module",
- "description": "A focused WebGL2 renderer and procedural 3D studio",
+ "description": "A browser graphics engine for interactive 3D scenes and cinematic media, with bounded CPU/GPU export",
"license": "MIT",
"homepage": "https://67js.codepawl.com",
"repository": {
@@ -39,7 +39,8 @@
"render": "node scripts/render-media.mjs",
"score": "node scripts/score.mjs",
"export:model": "node scripts/export-model.mjs",
- "smoke:package": "node scripts/smoke-package.mjs"
+ "smoke:package": "node scripts/smoke-package.mjs",
+ "publish:ci": "node scripts/publish-ci.mjs"
},
"devDependencies": {
"gl-matrix": "3.4.4",
diff --git a/scripts/prepare-release.mjs b/scripts/prepare-release.mjs
index 22f214e0..42e85745 100644
--- a/scripts/prepare-release.mjs
+++ b/scripts/prepare-release.mjs
@@ -27,7 +27,8 @@ const packResult = JSON.parse(run(process.execPath, [npmCli, 'pack', '--ignore-s
const packed = Array.isArray(packResult) ? packResult[0] : packResult[metadata.name];
if (!packed?.filename) throw new Error('npm pack did not return a package archive.');
const tarball = `/releases/${packed.filename}`;
-const integrity = `sha512-${createHash('sha512').update(await readFile(resolve(releases, packed.filename))).digest('base64')}`;
+let archive = await readFile(resolve(releases, packed.filename));
+let integrity = `sha512-${createHash('sha512').update(archive).digest('base64')}`;
await cp(resolve(root, 'build'), resolve(releases, metadata.version), { recursive: true });
run(process.execPath, ['node_modules/vite/bin/vite.js', 'build', '--config', 'vite.browser.config.js']);
await copyFile(resolve(root, 'build-browser/67.module.js'), resolve(releases, metadata.version, '67.module.js'));
@@ -35,17 +36,30 @@ await copyFile(resolve(root, 'CHANGELOG.md'), resolve(root, 'public/changelog.md
let registryVersion = null;
let registryPublished = false;
+let publishedPackage;
try {
const response = await fetch(`https://registry.npmjs.org/${encodeURIComponent(metadata.name)}`, { signal: AbortSignal.timeout(5000) });
if (response.ok) {
const registry = await response.json();
registryVersion = registry['dist-tags']?.latest ?? null;
- registryPublished = Boolean(registry.versions?.[metadata.version]);
+ publishedPackage = registry.versions?.[metadata.version];
+ registryPublished = Boolean(publishedPackage);
}
} catch {
// The downloadable package remains usable when the external registry is unavailable.
}
+if (publishedPackage) {
+ const canonicalURL = new URL(publishedPackage.dist.tarball);
+ if (canonicalURL.origin !== 'https://registry.npmjs.org') throw new Error('Unexpected registry archive origin.');
+ const response = await fetch(canonicalURL, { signal: AbortSignal.timeout(30000) });
+ if (!response.ok) throw new Error(`Canonical package download failed: HTTP ${response.status}.`);
+ archive = Buffer.from(await response.arrayBuffer());
+ integrity = `sha512-${createHash('sha512').update(archive).digest('base64')}`;
+ if (integrity !== publishedPackage.dist.integrity) throw new Error('Canonical package integrity verification failed.');
+ await writeFile(resolve(releases, packed.filename), archive);
+}
+
const release = {
version: metadata.version,
packageName: metadata.name,
@@ -57,7 +71,7 @@ const release = {
registryPublished,
registryVersion,
integrity,
- packageBytes: packed.size,
+ packageBytes: archive.length,
api: './getting-started.html#api',
changelog: '/changelog.md',
};
diff --git a/scripts/publish-ci.mjs b/scripts/publish-ci.mjs
new file mode 100644
index 00000000..6c11a4fe
--- /dev/null
+++ b/scripts/publish-ci.mjs
@@ -0,0 +1,16 @@
+import { readFile } from 'node:fs/promises';
+import { spawnSync } from 'node:child_process';
+
+const metadata = JSON.parse(await readFile('package.json', 'utf8'));
+const response = await fetch(`https://registry.npmjs.org/${encodeURIComponent(metadata.name)}/${metadata.version}`, { signal: AbortSignal.timeout(30000) });
+if (response.ok) {
+ const published = await response.json();
+ if (published.version !== metadata.version) throw new Error('Registry returned an unexpected version.');
+ console.log(`${metadata.name}@${metadata.version} is already published.`);
+} else {
+ if (response.status !== 404) throw new Error(`Registry version check failed: HTTP ${response.status}.`);
+ if (!process.env.GITHUB_ACTIONS || !process.env.ACTIONS_ID_TOKEN_REQUEST_URL) throw new Error('Run this release through the GitHub Actions trusted publisher.');
+ if (!process.env.npm_execpath) throw new Error('Run this script through npm run publish:ci.');
+ const result = spawnSync(process.execPath, [process.env.npm_execpath, 'publish', '--access', 'public'], { windowsHide: true, stdio: 'inherit' });
+ if (result.status !== 0) throw new Error(`npm publish failed with exit code ${result.status}.`);
+}
diff --git a/src/effects.js b/src/effects.js
new file mode 100644
index 00000000..7d26a653
--- /dev/null
+++ b/src/effects.js
@@ -0,0 +1,29 @@
+export const EFFECT_PRESETS = Object.freeze({
+ neutral: Object.freeze({ saturation: 1, contrast: 1, temperature: 0, vignette: 0, grain: 0, bloom: Object.freeze({ strength: 0, threshold: 1, radius: 1 }) }),
+ cinematic: Object.freeze({ saturation: 0.88, contrast: 1.08, temperature: 0.08, vignette: 0.16, grain: 0.012, bloom: Object.freeze({ strength: 0.25, threshold: 1, radius: 1.5 }) }),
+ vivid: Object.freeze({ saturation: 1.15, contrast: 1.03, temperature: 0, vignette: 0.06, grain: 0, bloom: Object.freeze({ strength: 0.3, threshold: 0.9, radius: 1.2 }) }),
+});
+
+function numberInRange(value, fallback, minimum, maximum, name) {
+ const result = value ?? fallback;
+ if (!Number.isFinite(result) || result < minimum || result > maximum) throw new Error(`${name} must be between ${minimum} and ${maximum}.`);
+ return result;
+}
+
+export function resolveEffects(effects = {}) {
+ if (!effects || typeof effects !== 'object' || Array.isArray(effects)) throw new Error('Effects must be an object.');
+ const bloom = effects.bloom ?? {};
+ if (!bloom || typeof bloom !== 'object' || Array.isArray(bloom)) throw new Error('Bloom must be an object.');
+ return {
+ saturation: numberInRange(effects.saturation, 1, 0, 2, 'Saturation'),
+ contrast: numberInRange(effects.contrast, 1, 0.1, 2, 'Contrast'),
+ temperature: numberInRange(effects.temperature, 0, -1, 1, 'Temperature'),
+ vignette: numberInRange(effects.vignette, 0, 0, 1, 'Vignette'),
+ grain: numberInRange(effects.grain, 0, 0, 0.1, 'Grain'),
+ bloom: {
+ strength: numberInRange(bloom.strength, 0, 0, 2, 'Bloom strength'),
+ threshold: numberInRange(bloom.threshold, 1, 0, 10, 'Bloom threshold'),
+ radius: numberInRange(bloom.radius, 1, 0.1, 4, 'Bloom radius'),
+ },
+ };
+}
diff --git a/tests/effects.test.js b/tests/effects.test.js
new file mode 100644
index 00000000..f46120e4
--- /dev/null
+++ b/tests/effects.test.js
@@ -0,0 +1,22 @@
+import test from 'node:test';
+import assert from 'node:assert/strict';
+import { EFFECT_PRESETS, resolveEffects } from '../src/effects.js';
+
+test('neutral effects preserve the existing image by default', () => {
+ assert.deepEqual(resolveEffects(), EFFECT_PRESETS.neutral);
+});
+
+test('partial bloom settings retain defaults without changing caller data', () => {
+ const settings = { bloom: { strength: 0.4 } };
+ const resolved = resolveEffects(settings);
+ assert.equal(resolved.bloom.threshold, 1);
+ assert.equal(resolved.bloom.strength, 0.4);
+ assert.deepEqual(settings, { bloom: { strength: 0.4 } });
+ for (const preset of Object.values(EFFECT_PRESETS)) assert.deepEqual(resolveEffects(preset), preset);
+});
+
+test('nonfinite or out-of-range effects fail before GPU uniforms are changed', () => {
+ for (const settings of [{ saturation: Infinity }, { contrast: 0 }, { temperature: 2 }, { grain: -1 }, { bloom: { radius: NaN } }, { bloom: false }, null]) {
+ assert.throws(() => resolveEffects(settings));
+ }
+});