threedog 2.2.0 → 2.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/core/engine/copies.js +1 -1
- package/core/engine/loop.js +1 -0
- package/core/inspect/metadata.generated.js +9 -0
- package/core/scene/canvasBox.js +9 -0
- package/core/scene/sceneMethods.js +2 -1
- package/docs/recipes/16-dev-bridge.md +3 -3
- package/package.json +1 -1
- package/render/fx/detail.tsl.js +3 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,22 @@
|
|
|
2
2
|
|
|
3
3
|
What changed in each version and how a game upgrades.
|
|
4
4
|
|
|
5
|
+
## 2.2.2 (2026-11-19)
|
|
6
|
+
|
|
7
|
+
Upgrading from 2.2.1: nothing to change.
|
|
8
|
+
|
|
9
|
+
- Fixed: `engine.step()` follows a changed viewport (canvas, camera and the UI root) even when no frame was drawn since, so a frozen or stepped page reads the new size on its next step; `engine.renderOnce()` resets `renderer.info`, so draw-call and triangle counts no longer add up across calls
|
|
10
|
+
- Changed (tools): an unknown option on a dev-bridge command says the working form (`errors latest 3`, `state key=value`, `step 2`, `hold <action> <seconds>`, `describe <path>`); `step` on a title screen says how to leave it (`state play=1`, or `--page "/?play"`); `snap` waits for loading to finish, as `shot` does, before it captures
|
|
11
|
+
- Changed (tools): `check` reminds when a game calls three's `bumpMap(` (rule R40): for a height computed in the shader use `detailBump` from `threedog/tsl`; `bumpMap` needs a texture
|
|
12
|
+
- Docs: recipe 16 §2a shows how to hold an action across `threedog snap`, and to step once after changing the viewport on a headless page
|
|
13
|
+
|
|
14
|
+
## 2.2.1 (2026-11-19)
|
|
15
|
+
|
|
16
|
+
Upgrading from 2.2.0: install `@threedog/tools@2.2.1` (the other packages only move with it). Nothing else changes.
|
|
17
|
+
|
|
18
|
+
- Fixed (tools): the published 2.2.0 tools package left out its `expect/` folder, so `threedog check`, `shot`, `test` and `expect` crashed on start after `npm install`. A test now packs every package and fails when shipped code imports a file the package leaves out
|
|
19
|
+
- Fixed (tools): two kinds of plain JS that TypeScript cannot follow were `✗` errors and failed `check`; they are now `!` reminders: a member read on a value whose type inference lost (`never`, as three's TSL declarations give for some `vec2(…).add(uniform(…))`), and an array literal passed where a fixed pair is declared (`repeat = [1, 1]` into a `[number, number]` option)
|
|
20
|
+
|
|
5
21
|
## 2.2.0 (2026-11-19)
|
|
6
22
|
|
|
7
23
|
Upgrading from 2.1: a game changes code only if it uses one of these. `engine.settings.open()` / `close()` / `toggle()` / `isOpen()` become `engine.ui.open('settings')` / `ui.close('settings')` / `ui.isOpen('settings')`, and an input binding on context `win-settings` moves to `ui-settings`. `engine.ui.open` / `close` with a name that is not a full-screen part now throws (fix the name). `engine.mod(point, { id })` on a point that is not per record throws (drop the id, or define the point `{ per: 'optional' }`). `engine.post.add` throws `post-effect` on an unknown key or a wrong type in the definition. Your own CSS that layered over the title screen by z-index: the title is now at 22 (was 80), and the layers are the `--threedog-z-*` variables. Tools: `--no-build` needs one earlier build of the same kind on this machine, and a `threedog test` spec's timeout starts when the engine is up (nothing to change: specs only get more time).
|
package/core/engine/copies.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
// A hot reload re-runs the same file (same path, a ?t= query): that is one copy, not two, so the path without the query decides.
|
|
7
7
|
import { coded } from '../base/errorHints.js';
|
|
8
8
|
|
|
9
|
-
export const VERSION = '2.
|
|
9
|
+
export const VERSION = '2.2.2'; // kept equal to package.json by the "[guard] engine copies" spec
|
|
10
10
|
|
|
11
11
|
const KEY = Symbol.for('threedog.engine.copies');
|
|
12
12
|
|
package/core/engine/loop.js
CHANGED
|
@@ -329,6 +329,7 @@ export const loopMethods = {
|
|
|
329
329
|
`engine.step(${String(seconds)}): seconds must be a finite number >= 0, e.g. engine.step(0.5) (real seconds; 1 / 60 is one fixed step)`);
|
|
330
330
|
if (seconds === 0) return describe ? this.describe() : null; // 0 advances nothing (a tiny positive value still runs one fixed step)
|
|
331
331
|
if (DEV && (this._inStart || this.session._busy)) warnOnce(coded('step-during-load', this._inStart ? STRINGS.stepStart : STRINGS.stepSession), 'step-during-load');
|
|
332
|
+
this._followBox(); // a viewport change while frozen / stepped: canvas, camera and UI root follow before this step reads them
|
|
332
333
|
const n = Math.max(1, Math.round(seconds / STEP));
|
|
333
334
|
this.stepBlend = 1; // step() takes the state to the end of each step, so the latest state is what cameras read and what gets drawn
|
|
334
335
|
let since = 0;
|
|
@@ -4019,6 +4019,15 @@ export const metadata = {
|
|
|
4019
4019
|
"code": "/\\bmaster\\??\\.disconnect\\s*\\(/",
|
|
4020
4020
|
"file": "packages/engine/core/audio/Audio.js"
|
|
4021
4021
|
},
|
|
4022
|
+
"bump": {
|
|
4023
|
+
"kind": "bump",
|
|
4024
|
+
"docRef": "recipes/56-webgpu-tsl.md §\"The engine\"",
|
|
4025
|
+
"seen": "a bumpMap() call (it does nothing for a height computed in the shader)",
|
|
4026
|
+
"use": "detailBump(positionView, normal, height, strength, faceDirection) from 'threedog/tsl' turns a procedural height node into a bumped normal; bumpMap stays right for a real texture",
|
|
4027
|
+
"quiet": "/\\bdetailBump\\b/",
|
|
4028
|
+
"code": "/\\bbumpMap\\s*\\(/",
|
|
4029
|
+
"file": "packages/engine/render/fx/detail.tsl.js"
|
|
4030
|
+
},
|
|
4022
4031
|
"collision": {
|
|
4023
4032
|
"kind": "collision",
|
|
4024
4033
|
"seen": "a hand-written box overlap",
|
package/core/scene/canvasBox.js
CHANGED
|
@@ -53,6 +53,7 @@ export function placeUI(e) {
|
|
|
53
53
|
export const resizeMethods = {
|
|
54
54
|
_resize() {
|
|
55
55
|
const { w, h } = canvasBox(this);
|
|
56
|
+
this._followed = { w, h }; // the box this resize answered: step() compares with it (_followBox)
|
|
56
57
|
placeUI(this);
|
|
57
58
|
if (fitPixelSize(this, w, h)) return;
|
|
58
59
|
const now = this.renderer.getSize(_size);
|
|
@@ -60,4 +61,12 @@ export const resizeMethods = {
|
|
|
60
61
|
this.renderer.setSize(w, h, !!this._autoSize); // the post chain follows the renderer on its next draw (postWebGL.js follow)
|
|
61
62
|
this._oAspect.drive(w / h);
|
|
62
63
|
},
|
|
64
|
+
/** step() calls this first: a frozen or stepped page has no rAF frame or ResizeObserver callback to follow a viewport change, so the box is compared here (the same path as the events).
|
|
65
|
+
* Compared with the box the last resize answered, not the renderer size: with pixelSize the renderer is smaller than the box by design, and a
|
|
66
|
+
* renderer the game or a test sized itself (renderer.setSize) must not be put back to the box while nothing on the page changed */
|
|
67
|
+
_followBox() {
|
|
68
|
+
const { w, h } = canvasBox(this), last = this._followed;
|
|
69
|
+
if (last && last.w === w && last.h === h) return;
|
|
70
|
+
this._resize();
|
|
71
|
+
},
|
|
63
72
|
};
|
|
@@ -6,7 +6,7 @@ import { askRatio, askPixelSize } from './pixelRatio.js';
|
|
|
6
6
|
import { codedError } from '../base/errorHints.js';
|
|
7
7
|
import { thing } from './thingOps.js';
|
|
8
8
|
import { isUnder } from '../base/util.js';
|
|
9
|
-
import { freshFrame, renderOnce as drawOnce } from '../../render/backend.js';
|
|
9
|
+
import { freshFrame, resetStats, renderOnce as drawOnce } from '../../render/backend.js';
|
|
10
10
|
import { freeParts, partsOf as parts, copyOwns, kept } from '../base/freeParts.js';
|
|
11
11
|
/**
|
|
12
12
|
* How many objects in the scene use each geometry and material. Why remove asks: disposing a kit that other streamed blocks still draw makes the renderer
|
|
@@ -106,6 +106,7 @@ export const sceneMethods = {
|
|
|
106
106
|
const own = this._ownFrame; // an engine draw, not the game taking the canvas over (render/ownFrame.js)
|
|
107
107
|
this._gameLights?.sync(); // the light watch catches up first: a RectAreaLight added since the last frame gets its tables before this draw (gameLights.js)
|
|
108
108
|
if (own) own.inside++;
|
|
109
|
+
resetStats(this.renderer); // autoReset is off: without this the counts of every renderOnce add up (same reset as _render)
|
|
109
110
|
try {
|
|
110
111
|
if (camera === this.camera) { freshFrame(this.renderer); this.post.render(0, target); return; }
|
|
111
112
|
drawOnce(this.renderer, this.scene, camera, target);
|
|
@@ -50,9 +50,9 @@ Every command and its options are in `../COMMANDS.md`. What each does to the gam
|
|
|
50
50
|
- `describe` by default gives only the 3 nearest things and the first quest; for detail use a path (`quests.active`, `nearby`, `world`) or `--full`.
|
|
51
51
|
|
|
52
52
|
## 2a. Hold a button down in a headless shot or test (`engine.input.simulate`)
|
|
53
|
-
- **In
|
|
54
|
-
- **
|
|
55
|
-
|
|
53
|
+
- **In page scripts and tests use `engine.input.simulate(action, down = true)`** (like `press`): `engine.input.simulate('jump'); engine.step(1 / 60); engine.input.simulate('jump', false)`.
|
|
54
|
+
- **Hold across a picture**: `threedog js "engine.input.simulate('moveForward', true)"`, `threedog step 1`, `threedog snap`; release with `false`.
|
|
55
|
+
- After changing the viewport on a headless page, `step` once before reading sizes (`step()` picks the new size up).
|
|
56
56
|
|
|
57
57
|
## 2c. Start the game from the command line: leave the title screen (`state play=1`, `--play`), open the page with URL parameters (`--page`)
|
|
58
58
|
- **Start clean.** Enter on a title picks Continue when a save exists, so a rerun by keys plays the last autosave. `state fresh=1` deletes the saves and
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "threedog",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.2",
|
|
4
4
|
"description": "Web 3D game engine on three.js, built to be driven by an AI. Start: npm install threedog three && npm install -D @threedog/tools && npx threedog init (writes the game and its CLAUDE.md). No built-in art",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
package/render/fx/detail.tsl.js
CHANGED
|
@@ -66,3 +66,6 @@ export const detailBump = Fn(/** @param {[N<'vec3'>, N<'vec3'>, N<'float'>, N<'f
|
|
|
66
66
|
const det = dot(sx, r1).mul(faceDir);
|
|
67
67
|
return normalize(abs(det).mul(surfNorm).sub(float(k).mul(sign(det)).mul(dFdx(h).mul(r1).add(dFdy(h).mul(r2)))));
|
|
68
68
|
});
|
|
69
|
+
|
|
70
|
+
// bumpMap() reads a texture's slope; given a height computed in a shader it bumps nothing and throws nothing. Quiet when the file already calls detailBump.
|
|
71
|
+
export const handRolled = [{ kind: 'bump', docRef: 'recipes/56-webgpu-tsl.md §"The engine"', seen: 'a bumpMap() call (it does nothing for a height computed in the shader)', use: "detailBump(positionView, normal, height, strength, faceDirection) from 'threedog/tsl' turns a procedural height node into a bumped normal; bumpMap stays right for a real texture", quiet: /\bdetailBump\b/, code: /\bbumpMap\s*\(/ }];
|