@adatechnology/game-crowd-three

中文文档
0.5.14发布于 2026/11/07MITTypeScriptES Module构建来源已验证近 30 天下载 2088

three.js drawing for @adatechnology/game-crowd: every agent, body on the ground and civilian as instances (a literal port of the team game's hordeRender and npcRender: view culling, LOD with hysteresis, attack pose, the pose by state), the renderer on the

原始使用文档
文档目录4 节
  1. Install
  2. Usage
  3. Test area
  4. Em português

@adatechnology/game-crowd-three

The three.js drawing of a @adatechnology/game-crowd crowd. Thousands of agents in a few draw calls: every crowd type is baked by the rich builder into its variants at three levels of detail (the instanced bodies of @adatechnology/game-characters-three), and each frame every agent, every body on the ground and every civilian becomes one instance of the right batch. three.js is passed in by the host; the package never imports it.

It is a literal port of the team game's drawing (jogo.js G 67079-67136 ZVAR, hordeRender; G 68469 PB; G 70177-70184 npcRender):

  • View culling: past √30 m, an agent more than 0.35·d + 3 m behind the view is left out; nothing past 200 m.
  • Level of detail at 18 and 55 m with 1.5 m of hysteresis, kept per agent (store.lod).
  • The attack pose in at 1.6 m from the target, out at 2.2 m, kept per agent (store.attackPose); the crowd reads it back (a striking agent does not turn to its velocity), as in the game.
  • The pose by state (dormant fallen, airborne leap, eating, pile step and grab as attack, swing and calling as scream, crawl), the bloater's swelling, the eyes out without the skull or on a dormant body.
  • Bodies on the ground on their own variant (near within 18 m), darkening 70% over their life and shrinking in the last 60 s; a body that was not an agent goes on the plain body batch.
  • Civilians one baked body each, a child 0.66 high and 0.75 wide, the bite showing.

Every number is in src/data/render.json with its source line, and the poses by state are options. The golden game-crowd-render.json (the game's hordeRender and npcRender on the 11 scenes of the horde and the survivors, recorded in node:vm by tools/characters-catalog) is replayed instance by instance by the tests.

Install

pnpm add @adatechnology/game-crowd-three three

Browser without a bundler (the global is GameCrowdThree; the kit's engines are bundled in, three.js is yours):

<script src="https://unpkg.com/@adatechnology/game-crowd-three/dist/index.global.js"></script>

Usage

import * as THREE from 'three'
import { createCrowd } from '@adatechnology/game-crowd'
import { createCrowdRenderer, CROWD_SOUND_BANK, HERD_SOUND_IDS } from '@adatechnology/game-crowd-three'
import { createBestBuilder } from '@adatechnology/game-characters-three'
import { undeadCrowdPack, UNDEAD_TYPES } from '@adatechnology/game-characters-undead'

const crowd = createCrowd({ pack: undeadCrowdPack(), seed: 7, target: player })
const best = createBestBuilder(THREE, { types: UNDEAD_TYPES.map((t) => ({ name: t.name['pt-BR'], eye: parseInt(t.eye.color, 16) })), random })
const renderer = createCrowdRenderer(THREE, {
  crowd,
  builders: { buildBest: (spec, lod) => (best.setLOD(lod), best.build(spec)), topMaterial: () => best.topM() },
  typeName: (type) => UNDEAD_TYPES.find((t) => t.id === type.id)!.name['pt-BR'],
  civilians: { list: () => civilians.list, body: (n) => bodyOf(n) },
})
scene.add(renderer.group)
audio.register(CROWD_SOUND_BANK) // groan, runner_groan, scream_hoarse and the herd's calls

// every frame, after crowd.update
renderer.update(dt, { camera: { x: camera.position.x, z: camera.position.z }, viewYaw, target: { x: player.state.x, z: player.state.z, alive: player.state.alive } })
renderer.lodCounts // [near, middle, far]

A type is baked the first time one of its bodies is drawn (bake() does them all at once). Without three.js, createCrowdInstances gives the same instances to any drawing.

createHerdView(THREE, { herd, flock, drawer, species }) draws game-crowd's herd with the animals' own rigs (game-animals-three's createAnimalsThree(THREE) is a drawer as it is) and the vultures gliding over the bodies.

Test area

createCrowdTestModule({ pack, builders, ... }) (crowd_area, only the generic contracts) puts a horde in the room, drawn on the instanced path, hunting the room's camera as a game-player body, with civilians, the herd, a region model (game-infection) and nine scenarios. Sounds go to host.audio (the bank is registered there), effects to host.effects (CROWD_EFFECTS maps them to the Oficina de VFX recipes). The content comes in by option. examples/crowd-test-area loads it with the kit's own packs (CrowdArea.loadInto(room), sala-multidao.html), and examples/interactables-test-area carries it too.

Em português

Desenho three.js da multidão do game-crowd: cada tipo assado nas variantes e em três níveis de detalhe, cada agente, corpo no chão e civil como uma instância. Porte literal do hordeRender e do npcRender do jogo (corte pela vista, nível de detalhe com histerese de 1,5 m, pose de ataque de 1,6 a 2,2 m, pose por estado, corpo que escurece e encolhe). A área de teste (crowd_area) põe uma horda caçando o corpo do jogador na sala.

版本与发布记录

@adatechnology/game-crowd-three 共发布 28 个版本,首次发布于 2026/10/25;过去 12 个月发布了 28 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.5.14latest2026/11/07今天
0.5.132026/11/07今天
0.5.122026/11/07今天
0.5.112026/11/07今天
0.5.102026/11/07今天
0.5.92026/11/07今天

关于 @adatechnology/game-crowd-three 的常见问题

@adatechnology/game-crowd-three 是什么?

three.js drawing for @adatechnology/game-crowd: every agent, body on the ground and civilian as instances (a literal port of the team game's hordeRender and npcRender: view culling, LOD with hysteresis, attack pose, the pose by state), the renderer on the

如何安装 @adatechnology/game-crowd-three?

在项目目录运行 npm install @adatechnology/game-crowd-three,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:three(^0.160.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@adatechnology/game-crowd-three 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@adatechnology/game-crowd-three 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@adatechnology/game-crowd-three 可以商用吗?

@adatechnology/game-crowd-three 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@adatechnology/game-crowd-three 的下载量有多少?

根据 npm 官方下载统计,@adatechnology/game-crowd-three 在 2026/10/05 – 2026/11/03 这 30 天内被下载 2,088 次,日均约 70 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@adatechnology/game-crowd-three 还在维护吗?

最新版本 0.5.14 发布于 2026/11/07(今天);至今共发布 28 个版本,其中过去 12 个月发布了 28 个;首次发布于 2026/10/25。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。