Pick what is drawn far away
Detail by distance: draw a model in full near the camera, and as a lighter level, another model or a picture farther off. Set it in GameView.world.detail.
ts
// in src/game.ts
import { type GameView } from '@v12-engine/client'
import { createGame } from '@v12-engine/engine'
import { rules } from './rules'
export const view: GameView = {
units: {
looks: {}
},
world: {
detail: {
// for every model that says nothing of its own: full, then 40% of its triangles from 40 cells, 15% from 80, a picture from 140
levels: [{}, { ratio: 0.4, from: 40 }, { ratio: 0.15, from: 80 }, { draw: 'impostor', from: 140 }],
// shadows cast from the next lighter level
shadowBias: 1,
// by model: a bush is a card from close by
models: { 'trees/bush.glb': [{}, { draw: 'impostor', from: 30 }] },
// a boss is always drawn at full, as what is selected and hovered are
important: (entity) => entity.def.id === 'lich',
// no files on disk: a level made in the page as it is first wanted
simplify: true
}
}
}
export const game = createGame(rules).view(view)Make the lighter levels as files beside the models:
sh
npm run lod -- public/games/mygame/models/castle.glb # castle.lod1.glb (40%) and castle.lod2.glb (15%) beside it
npm run lod -- public/models --ratios 0.5,0.2 # every model of a folder, at these parts of the triangles
npm run lod -- public/models --check # which have none, or older than their modelDone: far models draw with 40% and then 15% of their triangles, then as a picture; bushes become cards at 30 cells; the lich is always in full.
In the editor
- In the Look panel's Detail fold, set the map's levels and distances.
- Turn on View › Detail levels to tint each thing by its level.
- In the Inspector, pin a doodad to a level.
- In the Model view's Detail tab, see a model's levels with their triangles, and make them.
Reference
| Level field | What it does |
|---|---|
from | Distance in cells where it starts. |
under | Screen size in pixels below which it's used. |
when | Your own test. |
ratio | Part of the triangles kept. |
draw: 'impostor' | A card of pictures from eight sides. |
Later wins: the model's own, the game by model, the game for all, the map, the player's quality setting. See Detail by distance.