A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.
TypeScript 2d-game-engine3d3d-game-engineandroidcppecsgame-editorgame-enginegamedeviostypescriptwebassemblywebglwebgpuwechat-minigame
feat(verify): a package can be resized, and asked which LOD its own view chose
esengine85a358a120cb
diff --git a/pipeline/src/runtime/gameHost.ts b/pipeline/src/runtime/gameHost.tsindex 2a81779be..3ea607395 100644--- a/pipeline/src/runtime/gameHost.ts+++ b/pipeline/src/runtime/gameHost.ts@@ -19,7 +19,7 @@ import {acquireWebGPUDevice, ThirdPersonCamera, CharacterController3D, AnimatorController,Animator, TPC_SPEED, TPC_GROUNDED, Particle, MeleeAttack, Health,Hunter, NavAgent, Perception, AnimatorRootMotion, Playthrough, Name,- worldResidencyReport, PostProcess, Renderer, Audio,+ worldResidencyReport, PostProcess, Renderer, Audio, Camera,} from 'esengine';import type {SceneData, AddressableManifest, PackagedGameConfig, RenderSurfaceSource, WorldManifest,@@ -594,12 +594,16 @@ async function boot(): Promise<void> {* granted. Read through the same Renderer API the editor's panels use, so* a divergence here is the shipping path and not a second implementation.*/- decisions(name: string, view = 0): Record<string, unknown> | null {+ decisions(name: string, view?: number): Record<string, unknown> | null {const entity = app.world.findEntityByName(name);if (entity === null) return null;+ // A LOD level belongs to a VIEW, not to the entity: asked with view 0 the+ // renderer has no record and answers null, which reads as "no LOD here".+ const camera = view ?? [...app.world.getEntitiesWithComponents([Camera])][0] ?? 0;return {entity,- lod: Renderer.lodInspect(view, entity),+ view: camera,+ lod: Renderer.lodInspect(camera >>> 0, entity),light: Renderer.lightStatus(entity),shadow: Renderer.shadowStatus(entity),};@@ -622,6 +626,19 @@ async function boot(): Promise<void> {} : null,};},+ /**+ * Resize one named thing, so a LOD decision can be driven WITHOUT moving the+ * camera. Distance and projected size change together when a driver walks,+ * and a selector that used distance would pass a test that only ever walked.+ */+ setScale(name: string, s: number): boolean {+ const entity = app.world.findEntityByName(name);+ if (entity === null || !app.world.has(entity, Transform)) return false;+ app.world.update(entity, Transform, (t) => {+ t.scale.x = s; t.scale.y = s; t.scale.z = s;+ });+ return true;+ },/*** Take the GPU away, and read what the renderer says about itself after.*diff --git a/tools/launchers/residency-run.mjs b/tools/launchers/residency-run.mjsindex d34378a3d..0d73cc129 100644--- a/tools/launchers/residency-run.mjs+++ b/tools/launchers/residency-run.mjs@@ -21,7 +21,8 @@* A script is a list of steps: {do:"read",as}, {do:"walkTo",x,z},* {do:"tap",key}, {do:"step",frames}, {do:"stream",as,key,count},* {do:"loseDevice",as}, {do:"readiness",as,cell}, {do:"counters",as},- * {do:"renderFacts",as}, {do:"decisions",as,name}, {do:"configFacts",as,buses}.+ * {do:"renderFacts",as}, {do:"decisions",as,name}, {do:"configFacts",as,buses},+ * {do:"scale",name,to}.* Each read prints one JSON line.*/import { app, BrowserWindow } from 'electron';@@ -254,6 +255,13 @@ async function main() {console.log(`readiness ${step.as}: ${JSON.stringify({ claim, device })}`);continue;}+ if (step.do === 'scale') {+ const ok = await exec(+ `window.__estellaCooked.setScale(${JSON.stringify(step.name)}, ${Number(step.to)})`);+ if (!ok) { console.error(`✗ scale: no "${step.name}" to resize`); process.exit(1); }+ await exec(holdScript([], step.frames ?? 5));+ continue;+ }if (step.do === 'configFacts') {await settle();const f = await exec(@@ -270,7 +278,7 @@ async function main() {if (step.do === 'decisions') {await settle();const d = await exec(- `window.__estellaCooked.decisions(${JSON.stringify(step.name)}, ${step.view ?? 0})`);+ `window.__estellaCooked.decisions(${JSON.stringify(step.name)}, ${step.view ?? 'undefined'})`);console.log(`reading ${step.as}: ${JSON.stringify(d)}`);continue;}