threedog 0.1.0 → 0.2.1

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.
Files changed (244) hide show
  1. package/README.md +4 -4
  2. package/core/Animator.js +1 -0
  3. package/core/Assets.js +28 -0
  4. package/core/DebugOverrides.js +143 -0
  5. package/core/Describe.js +14 -3
  6. package/core/Engine.js +44 -72
  7. package/core/Events.js +59 -1
  8. package/core/I18n.js +2 -2
  9. package/core/Inspect.js +12 -32
  10. package/core/InspectScene.js +7 -3
  11. package/core/MaterialInfo.js +32 -0
  12. package/core/Ops.js +43 -59
  13. package/core/Saves.js +5 -4
  14. package/core/UrlState.js +3 -2
  15. package/core/Vars.js +1 -0
  16. package/core/Views.js +49 -0
  17. package/core/actor.js +2 -2
  18. package/core/assetReport.js +83 -0
  19. package/core/catalog.js +169 -0
  20. package/core/checks.js +67 -0
  21. package/core/claims.js +51 -0
  22. package/core/debugView.js +76 -0
  23. package/core/describeRender.js +51 -0
  24. package/core/describeText.js +11 -4
  25. package/core/errorCodes.js +33 -0
  26. package/core/errorHints.js +6 -1
  27. package/core/grid.js +127 -0
  28. package/core/gridLoad.js +19 -0
  29. package/core/holds.js +106 -0
  30. package/core/lifecycle.js +1 -0
  31. package/core/lightWatch.js +23 -3
  32. package/core/look/coreParts.js +112 -0
  33. package/core/look/layers.js +136 -0
  34. package/core/look/part.js +173 -0
  35. package/core/look/report.js +79 -0
  36. package/core/look/write.js +86 -0
  37. package/core/loop.js +22 -16
  38. package/core/modules.js +19 -5
  39. package/core/opsAtomic.js +31 -0
  40. package/core/opsCheck.js +25 -14
  41. package/core/opsFail.js +20 -0
  42. package/core/opsHistory.js +6 -6
  43. package/core/opsRun.js +77 -0
  44. package/core/params.js +132 -0
  45. package/core/renamed.js +22 -0
  46. package/core/saveApply.js +2 -2
  47. package/core/sceneMethods.js +9 -34
  48. package/core/services.js +73 -0
  49. package/core/startup.js +3 -1
  50. package/core/styleParts.js +11 -9
  51. package/core/thingExplain.js +68 -0
  52. package/core/thingOps.js +35 -24
  53. package/core/things.js +15 -1
  54. package/core/util.js +11 -0
  55. package/core/validate.js +23 -7
  56. package/docs/AI.md +93 -114
  57. package/docs/API.md +8 -9
  58. package/docs/CODEMAP.md +67 -53
  59. package/docs/COMMANDS.md +21 -7
  60. package/docs/CONVENTIONS.md +22 -11
  61. package/docs/THREE.md +3 -3
  62. package/docs/api/assets.md +3 -0
  63. package/docs/api/characters.md +5 -2
  64. package/docs/api/collision.md +4 -0
  65. package/docs/api/content.md +1 -0
  66. package/docs/api/engine.md +23 -14
  67. package/docs/api/events.md +5 -1
  68. package/docs/api/post.md +5 -4
  69. package/docs/api/saves.md +2 -1
  70. package/docs/api/sky.md +3 -3
  71. package/docs/api/style.md +8 -8
  72. package/docs/api/tools.md +5 -2
  73. package/docs/api/vegetation.md +1 -0
  74. package/docs/api/weather.md +1 -1
  75. package/docs/recipes/01-new-game.md +41 -43
  76. package/docs/recipes/02-npc.md +38 -22
  77. package/docs/recipes/03-items-pickups.md +4 -4
  78. package/docs/recipes/04-quests.md +23 -23
  79. package/docs/recipes/05-props-bake.md +5 -5
  80. package/docs/recipes/06-clock-events.md +13 -0
  81. package/docs/recipes/07-flow-scenes-pause.md +6 -2
  82. package/docs/recipes/08-weather-sky.md +6 -6
  83. package/docs/recipes/09-style-pack.md +35 -100
  84. package/docs/recipes/12-navmesh.md +22 -0
  85. package/docs/recipes/13-animation.md +25 -6
  86. package/docs/recipes/14-custom-module.md +6 -7
  87. package/docs/recipes/15-perf.md +9 -1
  88. package/docs/recipes/16-dev-bridge.md +52 -18
  89. package/docs/recipes/18-world.md +5 -2
  90. package/docs/recipes/19-shooting-picking.md +9 -8
  91. package/docs/recipes/20-content-actions-save.md +10 -10
  92. package/docs/recipes/21-camera.md +51 -2
  93. package/docs/recipes/22-shop-gold.md +16 -16
  94. package/docs/recipes/23-ops.md +46 -10
  95. package/docs/recipes/27-net.md +3 -3
  96. package/docs/recipes/28-terrain.md +2 -2
  97. package/docs/recipes/29-grid.md +47 -27
  98. package/docs/recipes/34-environment-lighting.md +11 -10
  99. package/docs/recipes/35-style-from-reference.md +41 -46
  100. package/docs/recipes/36-sky-ground-plant-looks.md +22 -20
  101. package/docs/recipes/37-terrain-look-hooks.md +34 -13
  102. package/docs/recipes/38-environment-look-hooks.md +49 -42
  103. package/docs/recipes/40-scene.md +29 -0
  104. package/docs/recipes/41-thing-registry.md +29 -0
  105. package/docs/recipes/42-terrain-shape.md +1 -1
  106. package/docs/recipes/43-shader-patches-surface-looks.md +37 -20
  107. package/docs/recipes/44-water-weather-look-hooks.md +11 -9
  108. package/docs/recipes/45-cascaded-shadows.md +2 -2
  109. package/docs/recipes/46-blender-art-route.md +26 -4
  110. package/docs/recipes/47-island-snow-backdrop.md +4 -3
  111. package/docs/recipes/48-make-material.md +70 -0
  112. package/docs/recipes/49-game-module-contract.md +71 -0
  113. package/docs/recipes/50-own-renderer.md +12 -0
  114. package/docs/recipes/51-capability-catalog.md +63 -0
  115. package/docs/recipes/52-look.md +146 -0
  116. package/docs/recipes/53-ground-up-close.md +58 -0
  117. package/examples/action/GAMEMAP.md +7 -7
  118. package/examples/action/content/index.js +2 -1
  119. package/examples/action/content/views.js +6 -0
  120. package/examples/action/main.js +3 -2
  121. package/examples/sheepisland/GAMEMAP.md +3 -4
  122. package/examples/styletest/GAMEMAP.md +3 -3
  123. package/examples/styletest/content/npcs.js +1 -1
  124. package/examples/styletest/main.js +2 -2
  125. package/examples/styletest/panel.js +3 -3
  126. package/examples/world/GAMEMAP.md +3 -3
  127. package/examples/world/content/npcs.js +1 -1
  128. package/examples/world/main.js +1 -1
  129. package/index.d.ts +35 -2
  130. package/index.js +6 -3
  131. package/llms.txt +13 -7
  132. package/modules/ambience/Ambience.js +5 -2
  133. package/modules/camera/FirstPersonCamera.js +3 -5
  134. package/modules/camera/FixedCamera.js +19 -12
  135. package/modules/camera/FollowCamera.js +14 -8
  136. package/modules/camera/RtsCamera.js +3 -5
  137. package/modules/camera/common.js +40 -10
  138. package/modules/camera/index.js +1 -1
  139. package/modules/camera/projection.js +34 -0
  140. package/modules/characters/Character.js +45 -31
  141. package/modules/characters/assetModel.js +35 -7
  142. package/modules/characters/astar.js +14 -7
  143. package/modules/characters/index.js +6 -3
  144. package/modules/characters/movers/simple.js +6 -1
  145. package/modules/characters/npcSim.js +8 -2
  146. package/modules/characters/pathAsync.js +12 -6
  147. package/modules/characters/pathJob.js +2 -1
  148. package/modules/characters/proceduralRig.js +50 -11
  149. package/modules/characters/useModel.js +22 -0
  150. package/modules/characters/walkTo.js +58 -0
  151. package/modules/collision/Collision.js +102 -4
  152. package/modules/content/explain.js +13 -0
  153. package/modules/content/index.js +3 -1
  154. package/modules/content/loader.js +3 -0
  155. package/modules/content/rules.js +1 -0
  156. package/modules/debug/DebugPanel.js +11 -5
  157. package/modules/entities/Entities.js +6 -2
  158. package/modules/flow/index.js +5 -2
  159. package/modules/gameplay/Dialogue.js +5 -2
  160. package/modules/gameplay/Interactions.js +12 -2
  161. package/modules/gameplay/Inventory.js +21 -11
  162. package/modules/gameplay/Quests.js +13 -3
  163. package/modules/gameplay/pickups.js +6 -4
  164. package/modules/grid/Layer.js +1 -1
  165. package/modules/grid/index.js +1 -1
  166. package/modules/grid/tiles.js +9 -5
  167. package/modules/hlod/index.js +5 -2
  168. package/modules/hud/index.js +5 -2
  169. package/modules/level/index.js +5 -3
  170. package/modules/lights/index.js +5 -2
  171. package/modules/music/Music.js +6 -2
  172. package/modules/nav/index.js +5 -3
  173. package/modules/net/Client.js +4 -3
  174. package/modules/net/Host.js +2 -2
  175. package/modules/net/index.js +5 -3
  176. package/modules/particles/Particles.js +1 -1
  177. package/modules/photo/Photo.js +10 -7
  178. package/modules/rigid/RigidBodies.js +5 -2
  179. package/modules/settings/Settings.js +6 -3
  180. package/modules/settings/apply.js +2 -1
  181. package/modules/sky/Sky.js +21 -19
  182. package/modules/sky/cascades.js +6 -6
  183. package/modules/sky/domeLayers.js +1 -1
  184. package/modules/sky/environment.js +39 -13
  185. package/modules/sky/fog.js +9 -6
  186. package/modules/sky/frame.js +4 -3
  187. package/modules/sky/look.js +3 -2
  188. package/modules/sky/lookFog.js +80 -0
  189. package/modules/sky/lookShadow.js +50 -0
  190. package/modules/sky/lookSky.js +108 -0
  191. package/modules/sky/shader.js +2 -2
  192. package/modules/sky/shadow.js +4 -10
  193. package/modules/sky/skyModule.js +4 -3
  194. package/modules/terrain/ChunkManager.js +2 -33
  195. package/modules/terrain/chunkLevels.js +40 -0
  196. package/modules/terrain/index.js +10 -2
  197. package/modules/terrain/lookGround.js +61 -0
  198. package/modules/timeline/Timeline.js +7 -3
  199. package/modules/timeline/Tween.js +3 -7
  200. package/modules/timeline/shots.js +6 -4
  201. package/modules/triggers/index.js +9 -2
  202. package/modules/vegetation/Vegetation.js +17 -4
  203. package/modules/vegetation/index.js +7 -4
  204. package/modules/vegetation/lookWind.js +37 -0
  205. package/modules/vegetation/nearFade.js +39 -0
  206. package/modules/water/Water.js +19 -3
  207. package/modules/water/look.js +80 -0
  208. package/modules/weather/Weather.js +22 -31
  209. package/modules/weather/look.js +75 -0
  210. package/modules/weather/particles.js +1 -1
  211. package/modules/weather/strings.js +15 -0
  212. package/modules/world/explain.js +11 -0
  213. package/modules/world/index.js +11 -4
  214. package/modules/world/thingSource.js +44 -0
  215. package/package.json +2 -1
  216. package/render/PostFX.js +48 -51
  217. package/render/detail.js +39 -15
  218. package/render/effects.js +4 -2
  219. package/render/fuse.js +12 -0
  220. package/render/lights.js +4 -2
  221. package/render/lookSurface.js +161 -0
  222. package/render/materials.js +27 -10
  223. package/render/postLook.js +86 -0
  224. package/render/surface.js +3 -1
  225. package/types/core.d.ts +223 -29
  226. package/types/gameplay.d.ts +22 -6
  227. package/types/generated/core/DebugOverrides.d.ts +52 -0
  228. package/types/generated/core/Events.d.ts +43 -0
  229. package/types/generated/core/Ops.d.ts +62 -21
  230. package/types/generated/core/Saves.d.ts +1 -0
  231. package/types/generated/core/Views.d.ts +33 -0
  232. package/types/generated/modules/debug/DebugPanel.d.ts +2 -2
  233. package/types/generated/modules/grid/Layer.d.ts +1 -0
  234. package/types/generated/modules/sky/Sky.d.ts +10 -17
  235. package/types/generated/modules/weather/Weather.d.ts +5 -15
  236. package/types/generated/render/PostFX.d.ts +20 -23
  237. package/types/generated/render/materials.d.ts +10 -0
  238. package/types/physics.d.ts +8 -0
  239. package/types/style.d.ts +35 -20
  240. package/types/world.d.ts +7 -1
  241. package/ui/Parts.js +6 -2
  242. package/ui/UI.js +1 -1
  243. package/ui/defaults.js +1 -1
  244. package/docs/api/debug.md +0 -10
@@ -2,7 +2,7 @@
2
2
  // Seven temperate ones are an opt-in preset: weather(presets.weather.temperate), extend with types: { ...presets.weather.temperate.types, dust: {...} }.
3
3
  // All fields blend smoothly on change.
4
4
  // Affects: cloud shadows, sky color, sun intensity, fog distance, wind (plants sway), rain/snow particles, lightning, ambience.
5
- // Particle and lightning looks: style.weather.rain / snow / lightning, engine.weather.define (particles.js, recipes/44).
5
+ // Particle and lightning looks: style.weather.rain / snow / lightning, engine.look.weather.replace (particles.js, recipes/44).
6
6
  //
7
7
  // engine.weather.set('rain', 20) // turn to rain over 20 seconds
8
8
  // engine.weather.setAuto(true) // change weather at random (uses engine.random, so step/tests are reproducible and saved)
@@ -10,29 +10,21 @@
10
10
  // i18n.add.
11
11
  import * as THREE from 'three';
12
12
  import { checkOptions, warnMissing, warnOnce } from '../../core/validate.js';
13
+ import { readParams, keysSchema } from '../../core/params.js';
13
14
  import { makeSystem, updateSystem, dropSystem, RAIN, SNOW } from './particles.js';
15
+ import { STRINGS, ERR } from './strings.js';
16
+ import { defineWeatherLook } from './look.js';
17
+ import { renamed } from '../../core/errorHints.js';
14
18
  /** @import { ModuleDef } from '../../types/core' */
15
19
  /** @import { WeatherName, WeatherPreset, WeatherOptions } from '../../types/world' */
16
20
 
17
21
  // The table when the game gives none: one calm type, so engine.weather works without assuming rain, snow or storms exist
18
22
  const ONLY_CLEAR = { clear: {} };
19
- const STRINGS = {
20
- 'zh-CN': { 'weather.clear': '晴', 'weather.cloudy': '多云', 'weather.overcast': '阴', 'weather.rain': '雨', 'weather.storm': '暴雨',
21
- 'weather.snow': '雪', 'weather.fog': '雾', 'weather.auto': '自动变化' },
22
- en: { 'weather.clear': 'Clear', 'weather.cloudy': 'Cloudy', 'weather.overcast': 'Overcast', 'weather.rain': 'Rain', 'weather.storm': 'Storm',
23
- 'weather.snow': 'Snow', 'weather.fog': 'Fog', 'weather.auto': 'Auto' },
24
- };
25
23
  const STYLE_KEYS = ['area', 'overcastColor', 'lightningBrightness', 'lightning', 'rain', 'snow', 'types'];
26
24
  const OPTIONS = ['start', 'auto', 'particles', 'types', 'autoPool', 'autoInterval', 'transition', 'area'];
25
+ const WEATHER_PARAMS = keysSchema(OPTIONS);
27
26
  // Fields a type leaves out: calm (no cloud, rain, snow, grey or lightning; normal sun, fog and wind)
28
27
  const CALM = { cloud: 0, sun: 1, fog: 1, wind: 1, rain: 0, snow: 0, grey: 0, lightning: 0 };
29
- const ERR = {
30
- types: "weather({ types }): the game's weather table, name -> { cloud, sun, fog, wind, rain, snow, grey, lightning } (left-out fields are calm), at least one; got {got}. Seven temperate ones: weather(presets.weather.temperate) with presets from 'threedog'",
31
- field: "weather type '{k}': field {f} must be a number (every field blends smoothly on change); got {got}",
32
- start: "weather({ start }): '{got}' is not one of this game's weather types ({list})",
33
- pool: "weather({ autoPool }): '{got}' is not one of this game's weather types ({list})",
34
- };
35
-
36
28
  /** engine.weather */
37
29
  export class Weather {
38
30
  /**
@@ -105,23 +97,16 @@ export class Weather {
105
97
  /** @internal */ this._cover = { strength: cover.strength ?? 0.8 };
106
98
  Object.assign(this._layer, { foliageCover: cover.foliage ?? null, groundCover: cover.ground ?? null, coverAmount: 0 });
107
99
  }
100
+ defineWeatherLook(this); // look.weather: the style's rain / snow / lightning values are its style layer
108
101
  }
109
102
 
110
103
  /**
111
- * Draw particles for a field of this game's weather table (its amount is weather.current[field], so they fade with the weather). spec takes the
112
- * keys of style.weather.rain (shape, color, size, speed, sway, density, glsl...) or create(engine, { area, count }) => { object, update } for a
113
- * system of your own. The same field again replaces it, rain and snow included. See recipes/44-water-weather-look-hooks.md
114
- * @example
115
- * engine.weather.define('ash', { shape: 'soft', color: 0x555555, size: 14, speed: 0.8, sway: 3 }); // types: { ashfall: { ash: 1, grey: 0.5 } }
116
- * @param {string} field
117
- * @param {import('../../types/style').StyleWeatherParticles} [spec]
118
- * @returns {{ field: string, object: THREE.Object3D, uniforms: Record<string, { value: any }> | null }}
104
+ * Renamed in 0.2: throws and names the new call, engine.look.weather.replace({ [field]: spec }) (recipes/44-water-weather-look-hooks.md)
105
+ * @param {string} _field
106
+ * @param {import('../../types/style').StyleWeatherParticles} [_spec]
107
+ * @returns {never}
119
108
  */
120
- define(field, spec = {}) {
121
- const fields = [...new Set(Object.values(this.types).flatMap(v => Object.keys(v)))];
122
- if (!fields.includes(field)) throw new Error(`weather.define('${field}'): no weather type has a field '${field}'; add it to a type in weather({ types }) (e.g. ashfall: { ${field}: 1 }), or use one of ${fields.join(', ')}`);
123
- return this._build(field, spec, field === 'rain' ? RAIN : field === 'snow' ? SNOW : undefined);
124
- }
109
+ define(_field, _spec) { return renamed('weatherDefine'); }
125
110
 
126
111
  /** @internal */
127
112
  _build(field, spec, base) {
@@ -164,10 +149,11 @@ export class Weather {
164
149
  /**
165
150
  * Advance weather transition, automatic weather and lightning (the module calls this itself every fixed step)
166
151
  * @param {number} dt
152
+ * @param {boolean} [quiet] true during engine.skip: same state changes, no lightning event (nobody saw it)
167
153
  * @returns {void}
168
154
  * @internal
169
155
  */
170
- tick(dt) {
156
+ tick(dt, quiet = false) {
171
157
  const rnd = this.engine.random;
172
158
  if (this.t < 1) {
173
159
  this.t = Math.min(1, this.t + dt / this.dur);
@@ -183,7 +169,7 @@ export class Weather {
183
169
  }
184
170
  if (this.current.lightning > 0.5) {
185
171
  this.nextBolt -= dt;
186
- if (this.nextBolt <= 0) { this.flash = 1; this.nextBolt = rnd.range(6, 20); this.engine.events.emit('weather:lightning'); }
172
+ if (this.nextBolt <= 0) { this.flash = 1; this.nextBolt = rnd.range(6, 20); if (!quiet) this.engine.events.emit('weather:lightning'); }
187
173
  }
188
174
  this.flash = Math.max(0, this.flash - dt * 3);
189
175
  }
@@ -216,11 +202,11 @@ export class Weather {
216
202
  * @returns {ModuleDef<Weather>}
217
203
  */
218
204
  export function weather(opts = {}) {
205
+ readParams('weather', WEATHER_PARAMS, opts);
219
206
  let w = null;
220
207
  return {
221
- name: 'weather', label: 'Weather', requires: ['sky'], stage: 'environment', before: ['sky'],
208
+ name: 'weather', label: 'Weather', params: WEATHER_PARAMS, options: opts, requires: ['sky'], stage: 'environment', before: ['sky'],
222
209
  install(e) {
223
- checkOptions('weather()', opts, OPTIONS);
224
210
  e.i18n.add(STRINGS);
225
211
  w = new Weather(e, opts);
226
212
  e.audio.condition('weather', v => [].concat(v).includes(w.name)); // audio rule condition { weather: 'rain' | ['rain', 'storm'] }
@@ -235,6 +221,11 @@ export function weather(opts = {}) {
235
221
  return w;
236
222
  },
237
223
  fixed(dt) { w.tick(dt); },
224
+ // engine.skip: fixed hooks do not run, so the skipped fixed steps are replayed here without events (a bolt nobody saw)
225
+ skip(dt) { // replay the fixed steps (same random draws, same order as stepping, so checkSkip matches); nothing pending = nothing to replay
226
+ if (w.t >= 1 && !w.auto && !(w.current.lightning > 0.5)) return;
227
+ for (let n = Math.round(dt * 60); n > 0; n--) w.tick(1 / 60, true); // 60 = the engine's fixed steps per second
228
+ },
238
229
  frame(dt, e) { w.apply(e.camera); },
239
230
  // scenario param weather: switch to this weather at once (no transition) and turn off automatic weather, so the scene is reproducible
240
231
  applyState(e, { weather: name }) {
@@ -0,0 +1,75 @@
1
+ // look.weather: rain / snow particles, lightning flash and the overcast color as a look part (recipes/52-look.md).
2
+ // set({ 'rain.color', 'rain.speed', 'snow.size', 'lightning.brightness', overcastColor ... }) rebuilds that field's particle system once (a few ms)
3
+ // patch('rain.vertex' | 'rain.fragment' | 'snow.vertex' | 'snow.fragment', glsl) the WHOLE shader text, not a function (see shaders.js)
4
+ // replace({ rain: spec, ash: spec }) spec = the keys of style.weather.rain or { create(engine, { area, count }) => { object, update } }; null gives back
5
+ // The old engine.weather call with a field name was renamed in 0.2 (it throws): use replace({ [field]: spec }).
6
+ // Why the shader stays whole (decision #9): the rain / snow shaders move vertices and size points; a function hook would hide most of that.
7
+ import { defineLookPart, REPLACE } from '../../core/look/part.js';
8
+ import { warnOnce } from '../../core/validate.js';
9
+ import { RAIN, SNOW, dropSystem } from './particles.js';
10
+
11
+ const WHY = { rain: 'built-in rain: streaks drawn while a weather type has rain > 0', snow: 'built-in snow: flakes drawn while a weather type has snow > 0' };
12
+ const OFF = { rain: "leave 'rain' out of the weather table (no particles are built), or look.weather.set({ 'rain.opacity': 0 })", snow: "leave 'snow' out of the weather table, or look.weather.set({ 'snow.opacity': 0 })" };
13
+ const KEYS = { rain: ['color', 'opacity', 'length', 'speed', 'slant'], snow: ['color', 'opacity', 'size', 'speed', 'sway'] };
14
+ const BASE = { rain: RAIN, snow: SNOW };
15
+ const FIELDS = ['rain', 'snow'], STAGES = ['vertex', 'fragment'];
16
+
17
+ /** { 'rain.color': { type, default, why, off } ... } built from the particle defaults, so the numbers live in one place (particles.js) */
18
+ const rows = () => Object.fromEntries(FIELDS.flatMap(f => KEYS[f].map(k => [`${f}.${k}`,
19
+ { type: k === 'color' ? 'any' : 'number', default: BASE[f][k], ...(k === 'color' ? {} : { min: 0 }), cost: 'gpu', why: WHY[f], off: OFF[f] }])));
20
+
21
+ /** @param {any} w the Weather module */
22
+ export function defineWeatherLook(w) {
23
+ const e = w.engine, st = e.style.weather ?? {}, { cover, ...snowStyle } = st.snow ?? {};
24
+ const styleSpec = f => (f === 'snow' ? snowStyle : st[f] ?? {});
25
+ let applied = {}; // fields a replace() holds now: field -> spec
26
+ const rebuild = f => {
27
+ if (applied[f]) return; // replace() owns this field
28
+ if (!w.systems.has(f)) { warnOnce(`look.weather: this game's weather table has no ${f}, so there are no ${f} particles to change; add a type with ${f}: 1 to weather({ types })`); return; }
29
+ const v = p.values(), s = styleSpec(f), g = { ...s.glsl };
30
+ for (const h of STAGES) { const x = p.value(`hook:${f}.${h}`); if (x) g[h] = x; }
31
+ w._build(f, { ...s, ...Object.fromEntries(KEYS[f].map(k => [k, v[`${f}.${k}`]])), ...(Object.keys(g).length ? { glsl: g } : {}) }, BASE[f]);
32
+ };
33
+ const p = defineLookPart(e, {
34
+ id: 'weather', group: 'dynamic', module: 'weather', object: () => w.systems, docs: ['recipes/52-look.md'], applyAtStart: false,
35
+ params: {
36
+ ...rows(),
37
+ 'lightning.brightness': { type: 'number', default: 1, min: 0, neutral: true, cost: 'uniform', desc: 'how bright the sky flashes at a strike' },
38
+ overcastColor: { type: 'any', default: 0x8c8c8c, cost: 'uniform', why: 'sky and fog turn this gray as a weather type raises grey', off: 'weather types with grey: 0 never use it' },
39
+ },
40
+ style: () => ({
41
+ ...Object.fromEntries(FIELDS.flatMap(f => KEYS[f].filter(k => styleSpec(f)[k] !== undefined).map(k => [`${f}.${k}`, styleSpec(f)[k]]))),
42
+ ...Object.fromEntries(FIELDS.flatMap(f => STAGES.filter(h => styleSpec(f).glsl?.[h]).map(h => [`hook:${f}.${h}`, styleSpec(f).glsl[h]]))),
43
+ 'lightning.brightness': st.lightningBrightness, overcastColor: st.overcastColor,
44
+ }),
45
+ read: () => ({}),
46
+ apply(v, changed) {
47
+ if (changed.has('lightning.brightness')) w.flashStrength = v['lightning.brightness'];
48
+ if (changed.has('overcastColor')) w.grey.set(v.overcastColor);
49
+ for (const f of FIELDS) if ([...changed].some(k => k.startsWith(f + '.'))) rebuild(f);
50
+ },
51
+ hooks: Object.fromEntries(FIELDS.flatMap(f => STAGES.map(h => [`${f}.${h}`, { signature: 'whole GLSL shader text (copy it from modules/weather/shaders.js)', scope: ['uCam', 'uSize', 'uFallOff', 'uOpacity', 'uColor'] }]))),
52
+ applyHook(name) { rebuild(name.split('.')[0]); },
53
+ replace: { accepts: '{ <field>: spec } with spec = the keys of style.weather.rain, or { create(engine, { area, count }) => { object, update?(amount, ctx) } }; null gives the fields back',
54
+ loses: ['the style rain / snow look of every field named in the object (look.weather.set values for it are ignored while it holds)'] },
55
+ // a wrong replace value stops here, before any layer is written (the throw used to come from applyReplace, after the write)
56
+ validate: (k, v) => {
57
+ if (k !== REPLACE) return null;
58
+ if (v != null && (typeof v !== 'object' || Array.isArray(v))) return "is { <field>: spec }, e.g. replace({ ash: { shape: 'soft', color: 0x555555 } }); see recipes/44-water-weather-look-hooks.md";
59
+ const fields = [...new Set(Object.values(w.types).flatMap(t => Object.keys(t)))], bad = Object.keys(v ?? {}).find(f => !fields.includes(f));
60
+ return bad ? `no weather type has a field '${bad}'; add it to a type in weather({ types }) (e.g. ashfall: { ${bad}: 1 }), or use one of ${fields.join(', ')}` : null;
61
+ },
62
+ applyReplace(impl) {
63
+ const next = impl ?? {}, old = applied;
64
+ applied = next;
65
+ for (const f of new Set([...Object.keys(old), ...Object.keys(next)])) {
66
+ if (next[f] && next[f] === old[f]) continue; // unchanged: keep the system (and any handle the game holds)
67
+ if (next[f]) w._build(f, next[f], BASE[f]);
68
+ else if (BASE[f]) rebuild(f);
69
+ else { const s = w.systems.get(f); if (s) { dropSystem(e, s); w.systems.delete(f); } }
70
+ }
71
+ },
72
+ });
73
+ return p;
74
+ }
75
+
@@ -1,5 +1,5 @@
1
1
  // Weather particle systems (recipes/44). Built-in rain and snow are two specs of one falling-particle system; a game draws a field of its
2
- // own table (ash, petals, sparks) with engine.weather.define(field, spec), and the same call replaces rain or snow. The amount each frame is
2
+ // own table (ash, petals, sparks) with engine.look.weather.replace({ field: spec }), and the same call replaces rain or snow. The amount each frame is
3
3
  // weather.current[field], so the table's smooth blending drives particles too.
4
4
  //
5
5
  // spec (style.weather.rain / snow, or define): shape 'line' (streaks that slant with the wind) | 'round' | 'soft' | 'square' (point sprites
@@ -0,0 +1,15 @@
1
+ // Weather display names (string table weather.<name>); a game that adds a weather adds its name with i18n.add.
2
+ export const STRINGS = {
3
+ 'zh-CN': { 'weather.clear': '晴', 'weather.cloudy': '多云', 'weather.overcast': '阴', 'weather.rain': '雨', 'weather.storm': '暴雨',
4
+ 'weather.snow': '雪', 'weather.fog': '雾', 'weather.auto': '自动变化' },
5
+ en: { 'weather.clear': 'Clear', 'weather.cloudy': 'Cloudy', 'weather.overcast': 'Overcast', 'weather.rain': 'Rain', 'weather.storm': 'Storm',
6
+ 'weather.snow': 'Snow', 'weather.fog': 'Fog', 'weather.auto': 'Auto' },
7
+ };
8
+
9
+ // Errors of weather() / the weather table
10
+ export const ERR = {
11
+ types: "weather({ types }): the game's weather table, name -> { cloud, sun, fog, wind, rain, snow, grey, lightning } (left-out fields are calm), at least one; got {got}. Seven temperate ones: weather(presets.weather.temperate) with presets from 'threedog'",
12
+ field: "weather type '{k}': field {f} must be a number (every field blends smoothly on change); got {got}",
13
+ start: "weather({ start }): '{got}' is not one of this game's weather types ({list})",
14
+ pool: "weather({ autoPool }): '{got}' is not one of this game's weather types ({list})",
15
+ };
@@ -0,0 +1,11 @@
1
+ // World's contribution to thing.explain() (core/thingExplain.js): the record's fields as `state`, and the record's own collision / picking rules.
2
+ // Template rules come from the content module's explainer (content/explain.js), which runs after this and overrides these.
3
+
4
+ /** @internal Fill state and rules for a thing that has a world record */
5
+ export function worldExplain(e, t, out) {
6
+ const rec = e.world?.get(t.id);
7
+ if (!rec) return;
8
+ out.state = { ...t.fields, position: t.position };
9
+ Object.assign(out.rules, { blocksMovement: rec.collide ?? false, pickable: rec.static !== false, interact: null, note: RULES_NOTE });
10
+ }
11
+ export const RULES_NOTE = 'blocksMovement = the collision shape (box / circle) walkers stop at; blocking sight is not modelled by the engine';
@@ -2,14 +2,19 @@
2
2
  // engine.use(world()) // the openWorld() preset installs it by default
3
3
  // engine.use(world({ radius: 80 })) // distance (meters) for building models and counting as near, default 60
4
4
  // Save key world (runtime records whole, initial records only changes and removals, see the top of World.js); emits world:load after loading. The loading screen waits for world.ready (nearby models all built). describe() reports world.total / byKind / presented, and nearby records with a name go into nearby.
5
+ import { recordSource } from './thingSource.js';
5
6
  import { World } from './World.js';
6
7
  import { WORLD_MIGRATE } from './persist.js';
7
- import { checkOptions, closest, warnOnce, DEV } from '../../core/validate.js';
8
+ import { worldExplain } from './explain.js';
9
+ import { closest, warnOnce, DEV } from '../../core/validate.js';
10
+ import { readParams, keysSchema } from '../../core/params.js';
8
11
 
9
12
  const ORPHAN = '[world] the save has changes for {n} id(s) that the content no longer defines: {list}. They are kept in the save (restoring the entry brings them back); '
10
13
  + "if an entry was renamed, add the pair to content/renames.js (export default { 'oldId': 'newId' }) and the saved state follows it; 'oldId': null drops it";
11
14
  const RENAME_TARGET = '[world] content/renames.js moves saved state to {list}, which no content entry defines: fix the new id (did you mean {near}?)';
12
15
 
16
+ const WORLD_PARAMS = keysSchema(['cellSize', 'radius', 'farEvery', 'farMaxPerTick', 'buildPerFrame']);
17
+
13
18
  /**
14
19
  * World data module: installed as engine.world. Put things here that must be saved, survive level changes and keep changing while far away; models are only built while nearby
15
20
  * @example engine.use(world())
@@ -17,15 +22,17 @@ const RENAME_TARGET = '[world] content/renames.js moves saved state to {list}, w
17
22
  * @returns {import('../../types/core').ModuleDef<World>}
18
23
  */
19
24
  export function world(opts = {}) {
20
- checkOptions('world()', opts, ['cellSize', 'radius', 'farEvery', 'farMaxPerTick', 'buildPerFrame']);
25
+ readParams('world', WORLD_PARAMS, opts);
21
26
  let w = null;
22
27
  return {
23
- name: 'world', label: 'World data', stage: 'world',
28
+ name: 'world', label: 'World data', params: WORLD_PARAMS, options: opts, stage: 'world',
24
29
  install(e) {
25
30
  w = new World(e, opts);
26
31
  e.stream.player.at(() => w.center); // the default stream source sits where gameplay is simulated (world.anchor, else the player)
27
32
  e.stream.readyCheck('world', s => s.detail !== 'full' || w.ready);
28
- e.saves.register('world', { version: 3, migrate: WORLD_MIGRATE, save: () => w.toJSON(), load: d => w.fromJSON(d) });
33
+ e.saves.register('world', { atomic: true, version: 3, migrate: WORLD_MIGRATE, save: () => w.toJSON(), load: d => w.fromJSON(d) });
34
+ e._things.addSource(recordSource(w)); // engine.thing / thing.set / the shared id space reach the records through this
35
+ e.explainWith(worldExplain);
29
36
  e.budget.metric('worldRecords', () => w.records.size);
30
37
  if (DEV) { // orphans are known once content loaded (engine:ready), after a load, and per level for `<level>/<node>` ids
31
38
  const warn = () => {
@@ -0,0 +1,44 @@
1
+ // What the world module tells core about its records: engine._things.addSource(...) at install. Core knows only this shape (has / get / set / remove /
2
+ // explain, plus idOf / view / ids / restore for the model link and undo), never the World class, so engine.thing, thing.set and the shared id space
3
+ // work the same whether or not this module is installed.
4
+ const SAY = {
5
+ defined: 'defined in {at}: edit it there to change the level for good (ops change only this session), or: npx threedog content set {id} <field> <json>',
6
+ node: 'level {level} node {node}: change it in the level model',
7
+ spawned: 'made during play{op}: not in content, saved whole',
8
+ };
9
+ const NOT_FIELDS = new Set(['id', 'kind', 'position', 'zone', 'floor', 'offsetY']);
10
+
11
+ /** The record as a thing to change: id, kind, template, where it was authored (definedAt / level node / spawned by which op), model and its fields */
12
+ function describeRecord(w, id) {
13
+ const rec = w.get(id); if (!rec) return null;
14
+ const o = w.origin(id) ?? {}, fields = {};
15
+ for (const k in rec) if (!NOT_FIELDS.has(k)) fields[k] = rec[k];
16
+ const how = o.definedAt ? SAY.defined.replace('{at}', o.definedAt).replace('{id}', id) : o.node ? SAY.node.replace('{level}', o.level).replace('{node}', o.node)
17
+ : o.spawned ? SAY.spawned.replace('{op}', o.spawned.op ? ` by op ${o.spawned.op} at tick ${o.spawned.tick}` : '') : null;
18
+ return { id, kind: rec.kind, template: o.template ?? null, definedAt: o.definedAt ?? null, ...(o.templateAt && { templateAt: o.templateAt }),
19
+ ...(o.node && { level: o.level, node: o.node }), ...(o.spawned && { spawned: o.spawned }), model: o.model ?? rec.model ?? null,
20
+ position: { ...rec.position }, fields, edit: how };
21
+ }
22
+
23
+ /** @param {any} w the World @returns the record source for engine._things.addSource @internal */
24
+ export function recordSource(w) {
25
+ return {
26
+ name: 'world',
27
+ has: id => !!w.get(id),
28
+ get: id => w.get(id),
29
+ ids: () => w.query({}).map(r => r.id),
30
+ idOf: obj => w.idOf(obj),
31
+ view: id => w.view(id),
32
+ explain: id => describeRecord(w, id),
33
+ /** Change a record (position / rot / scale); returns the values it replaced (set(id, thatValue) is the undo) */
34
+ set(id, patch) {
35
+ // rot / scale are the template instance fields (templates.js); a record without them reads as rot 0, scale 1
36
+ const rec = w.get(id), before = { position: { ...rec.position }, ...(patch.rot != null && { rot: rec.rot ?? 0 }), ...(patch.scale != null && { scale: rec.scale ?? 1 }) };
37
+ w.set(id, patch);
38
+ return before;
39
+ },
40
+ /** Remove a record; returns what restore needs */
41
+ remove(id) { const rec = structuredClone(w.get(id)), authored = w.authored(id); w.remove(id); return { rec, authored }; },
42
+ restore: ({ rec, authored }) => w.restore(rec, authored),
43
+ };
44
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "threedog",
3
- "version": "0.1.0",
3
+ "version": "0.2.1",
4
4
  "description": "Web 3D game engine on three.js for large low-poly worlds: core + modules + style packs, built to be driven by an AI",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -24,6 +24,7 @@
24
24
  "default": "./index.js"
25
25
  },
26
26
  "./error-hints": "./core/errorHints.js",
27
+ "./grid": "./core/grid.js",
27
28
  "./worker": {
28
29
  "types": "./types/worker.d.ts",
29
30
  "default": "./core/threadServe.js"
package/render/PostFX.js CHANGED
@@ -1,5 +1,5 @@
1
1
  // Post-processing as an ordered list of named effects in four slots. The engine owns no look of its own here: bloom, AO and
2
- // outline are effects a style pack registers (they come from @threedog/post-effects); games add theirs with engine.post.add().
2
+ // outline are effects a style pack registers (they come from @threedog/post-effects); games add theirs with look.post.replace([...]).
3
3
  // An effect promises only a name, params and on/off; how it draws is its create() (a three.js Pass under WebGLRenderer),
4
4
  // so a WebGPU backend can later bring its own implementation without changing callers.
5
5
  //
@@ -13,8 +13,10 @@ import * as THREE from 'three';
13
13
  import { EffectComposer } from 'three/addons/postprocessing/EffectComposer.js';
14
14
  import { RenderPass } from 'three/addons/postprocessing/RenderPass.js';
15
15
  import { OutputPass } from 'three/addons/postprocessing/OutputPass.js';
16
- import { warnMissing } from '../core/validate.js';
17
- import { FusedPass, groupFuse } from './fuse.js';
16
+ import { warnMissing, warnOnce } from '../core/validate.js';
17
+ import { renamed } from '../core/errorHints.js';
18
+ import { FusedPass, groupFuse, checkDepthOrder } from './fuse.js';
19
+ import { definePostLook } from './postLook.js';
18
20
  /** @import { Engine } from '../types/core' */
19
21
 
20
22
  /**
@@ -40,23 +42,11 @@ import { FusedPass, groupFuse } from './fuse.js';
40
42
  * RenderPixelatedPass, or the tone-mapping output); the chain throws when it would not. A pass that writes the scene depth into its own output (gl_FragDepth, then set pass.keepsDepth = true; dof does) does not count as a swap. update: apply new params in place;
41
43
  * without it set() rebuilds the implementation.
42
44
  * @typedef {{ readonly name: string, readonly slot: PostSlot, readonly order: number, readonly enabled: boolean,
43
- * readonly params: Record<string, any>, enable(on: boolean): void, set(params: Record<string, any>): void, remove(): void }} PostHandle
45
+ * readonly params: Record<string, any> }} PostHandle
44
46
  */
45
47
 
46
48
  const SLOTS = ['scene', 'hdr', 'ldr', 'final'];
47
49
 
48
- // Only the buffer the scene render wrote holds scene depth: after a pass that swaps buffers, readBuffer.depthTexture is another
49
- // target's (a fullscreen quad's, or stale). A depth reader behind such a pass would silently find nothing, so the chain refuses it.
50
- function checkDepthOrder(chain) {
51
- let swapped = null;
52
- for (const e of chain) {
53
- if (e._def?.needsDepth && swapped)
54
- throw new Error(`post effect '${e.name}' reads scene depth (needsDepth) but runs after '${swapped}', which swaps buffers, so the depth it would read is not the scene's; ` +
55
- `give '${e.name}' a lower order or an earlier slot than '${swapped}', or turn one of them off`);
56
- if (e._impl.needsSwap && !e._impl.keepsDepth) swapped ??= e.name;
57
- }
58
- }
59
-
60
50
  export class PostFX {
61
51
  /**
62
52
  * @param {Engine} engine
@@ -75,13 +65,22 @@ export class PostFX {
75
65
  /** @internal */ this._scenePass = /** @type {any} */ (null);
76
66
  /** @internal */ this._output = /** @type {any} */ (null);
77
67
  /** @internal */ this._building = true; // add() skips chain rebuilds until every style effect is in
78
- for (const e of effects) this.add(e, { enabled: enabled[e.name] ?? (e.costly && engine.tier === 'low' ? false : undefined) });
68
+ /** Why a costly effect started off (name -> reason), shown by describe().render and logged once: a silent "bloom is missing" in headless / software rendering looked like a bug @internal */
69
+ this._offWhy = /** @type {Record<string, string>} */ ({});
70
+ for (const e of effects) {
71
+ const lowOff = enabled[e.name] == null && e.costly && engine.tier === 'low';
72
+ if (lowOff) this._offWhy[e.name] = `starts off: costly effect on a low-tier device (${engine.headless ? 'headless runs use software rendering, which is low tier' : 'weak GPU or software rendering'}); turn it on with createEngine({ post: { ${e.name}: true } }) or engine.look.post.set({ '${e.name}.enabled': true })`;
73
+ this._add(e, { enabled: enabled[e.name] ?? (lowOff ? false : undefined) });
74
+ }
75
+ const why = Object.entries(this._offWhy);
76
+ if (why.length) warnOnce(`post: ${why.map(([n]) => n).join(', ')} ${why.length > 1 ? 'are' : 'is'} off by default here. ${why[0][1]}`);
79
77
  this._building = false;
80
78
  this._sync();
79
+ /** look.post: the style's effects are its style layer; look.post.set writes its 'game' layer @internal */ this._look = definePostLook(this, effects);
81
80
  }
82
81
 
83
82
  /**
84
- * MSAA on (read-only; switch with post.enable('antialias', on))
83
+ * MSAA on (read-only; switch with post.setAntialias(on))
85
84
  * @returns {boolean}
86
85
  */
87
86
  get antialias() { return this._aa; }
@@ -92,22 +91,18 @@ export class PostFX {
92
91
  get active() { return this._aa || this._list.some(e => e.enabled); }
93
92
 
94
93
  /**
95
- * Add a named effect; returns its handle. Slot and order come from the effect unless given here.
96
- * @example
97
- * import { RenderPixelatedPass } from 'three/addons/postprocessing/RenderPixelatedPass.js';
98
- * const pixels = engine.post.add({ name: 'pixelate', slot: 'scene', params: { size: 4 },
99
- * create: ({ scene, camera, width, height, params }) => new RenderPixelatedPass(params.size, scene, camera),
100
- * update: (pass, p) => pass.setPixelSize(p.size) });
101
- * pixels.set({ size: 6 }); pixels.enable(false); pixels.remove();
102
- * @param {PostEffect} effect
103
- * @param {{ slot?: PostSlot, order?: number, enabled?: boolean }} [opts]
104
- * @returns {PostHandle}
94
+ * Renamed in 0.2: throws and names the new call (engine.look.post.patch / engine.look.post.replace, recipes/52-look.md)
95
+ * @param {PostEffect} _effect
96
+ * @param {{ slot?: PostSlot, order?: number, enabled?: boolean }} [_opts]
97
+ * @returns {never}
105
98
  * @experimental
106
99
  */
107
- add(effect, { slot, order, enabled } = {}) {
100
+ add(_effect, _opts) { return renamed('postAdd'); }
101
+ /** Effects are added by look.post (patch generates a fuse effect, replace swaps the chain) with this @internal */
102
+ _add(effect, { slot, order, enabled } = {}) {
108
103
  if (!effect || typeof effect.name !== 'string' || (typeof effect.create !== 'function' && !effect.fuse))
109
- throw new Error("post.add(effect): effect needs { name: 'myEffect', create: (ctx) => pass } (or a fuse snippet, see PostEffect)");
110
- if (this.get(effect.name)) throw new Error(`post effect '${effect.name}' is already added; change it with post.get('${effect.name}').set(params), or remove() it first`);
104
+ throw new Error("post effect: needs { name: 'myEffect', create: (ctx) => pass } (or a fuse snippet, see PostEffect)");
105
+ if (this.get(effect.name)) throw new Error(`post effect '${effect.name}' is already added; change it with look.post.set({ '${effect.name}.<param>': value }), or drop it with look.post.replace([...])`);
111
106
  const s = slot ?? effect.slot ?? 'hdr';
112
107
  if (!SLOTS.includes(s)) throw new Error(`post effect '${effect.name}': unknown slot '${s}', use ${SLOTS.join(' | ')}`);
113
108
  if (effect.fuse && s === 'scene') throw new Error(`post effect '${effect.name}': a fuse snippet colors an existing image, it cannot replace the scene render; use slot 'hdr' | 'ldr' | 'final'`);
@@ -117,14 +112,17 @@ export class PostFX {
117
112
  const h = {
118
113
  name: effect.name, slot: s, order: order ?? effect.order ?? 0, enabled: enabled ?? effect.enabled ?? true,
119
114
  params: { ...effect.params }, _def: effect, _impl: /** @type {any} */ (null), _removed: false,
120
- enable(on) { const was = h.enabled; post._change(() => { h.enabled = !!on; }, () => { h.enabled = was; }); },
121
- set(p) {
115
+ enable() { return renamed('postHandle'); }, // the old handle verbs throw renamed-api; look.post writes through _enable / _set / _remove
116
+ set() { return renamed('postHandle'); },
117
+ remove() { return renamed('postHandle'); },
118
+ _enable(on) { const was = h.enabled; post._change(() => { h.enabled = !!on; }, () => { h.enabled = was; }); },
119
+ _set(p) {
122
120
  Object.assign(h.params, p);
123
121
  if (effect.fuse) { for (const p of post._fused.values()) p.refresh(); return; }
124
122
  if (!h._impl) return;
125
123
  if (effect.update) effect.update(h._impl, h.params); else { h._impl.dispose?.(); h._impl = null; post._sync(); }
126
124
  },
127
- remove() {
125
+ _remove() {
128
126
  if (h._removed) return;
129
127
  h._removed = true; h._impl?.dispose?.(); h._impl = null;
130
128
  post._list = post._list.filter(e => e !== h); post._sync();
@@ -135,32 +133,31 @@ export class PostFX {
135
133
  return h;
136
134
  }
137
135
  /**
138
- * Handle of an added effect, or undefined: engine.post.get('bloom')?.set({ strength: 0.6 })
136
+ * Read-only record of an added effect (name, slot, order, enabled, params), or undefined. Change one with engine.look.post.set({ 'bloom.strength': 0.6 })
139
137
  * @param {string} name
140
138
  * @returns {PostHandle | undefined}
141
139
  * @experimental
142
140
  */
143
141
  get(name) { return this._list.find(e => e.name === name); }
144
142
  /**
145
- * Turn an effect, or 'antialias' (MSAA), on or off; false (and a dev warning naming the effects) when no such effect is added
146
- * @example
147
- * engine.post.enable('bloom', false); engine.post.enable('antialias', true);
148
- * @param {string} name
143
+ * Renamed in 0.2: throws and names the new call (engine.look.post.set({ 'bloom.enabled': on }); MSAA: engine.post.setAntialias(on))
144
+ * @param {string} _name
145
+ * @param {boolean} _on
146
+ * @returns {never}
147
+ * @experimental
148
+ */
149
+ enable(_name, _on) { return renamed('postEnable'); }
150
+ /**
151
+ * Turn MSAA (antialiasing of the post chain) on or off. It is a render target setting, not a look part.
152
+ * @example engine.post.setAntialias(false);
149
153
  * @param {boolean} on
150
- * @returns {boolean}
154
+ * @returns {void}
151
155
  * @experimental
152
156
  */
153
- enable(name, on) {
154
- if (name === 'antialias') {
155
- this._aa = !!on;
156
- if (this.composer) for (const rt of [this.composer.renderTarget1, this.composer.renderTarget2]) { rt.samples = on ? 4 : 0; rt.dispose(); }
157
- this._sync();
158
- return true;
159
- }
160
- const h = this.get(name);
161
- if (!h) { warnMissing('post effect', name, ['antialias', ...this._list.map(e => e.name)]); return false; }
162
- h.enable(on);
163
- return true;
157
+ setAntialias(on) {
158
+ this._aa = !!on;
159
+ if (this.composer) for (const rt of [this.composer.renderTarget1, this.composer.renderTarget2]) { rt.samples = on ? 4 : 0; rt.dispose(); }
160
+ this._sync();
164
161
  }
165
162
  /**
166
163
  * Effects in render order: [{ name, slot, order, enabled }]