host
A module script.
Interface
What this asset declares: the schema it conforms to, what it exposes, and the rendered structured payload.
conforms to
zero/source-extract/v2module threezero.host Host bridge for the ThreeZero runtime. A session owns an entity pool under a temporary root, maps THREE geometry/material specs onto Zero Model primitives, and syncs per-frame transforms through the batched ECS path (reflect.bindEntities + substrate buffers + entity.batchWrite). `envFor` builds the flat `__ZERO` function table a ZeroJS VM calls across the marshaling bridge.
quatX(deg: number) → void
Quaternion for a rotation of `deg` degrees about X, as the {x,y,z,w} array the Transform rotation field takes.
| arg | type | description |
|---|---|---|
| deg | number |
mapGeometry(g: any) → void
Map a THREE geometry spec { type, p = {...} } to a Zero primitive model plus the constant local pose of the visual child that makes the primitive match THREE's geometry-space conventions (dimensions, axis, and origin).
| arg | type | description |
|---|---|---|
| g | any |
quatMul(a: { number }, b: { number }) → void
Pick the backing material asset for a THREE material spec.
| arg | type | description |
|---|---|---|
| a | { number } | |
| b | { number } |
quatRotate(q: { number }, v: { number }) → void
| arg | type | description |
|---|---|---|
| q | { number } | |
| v | { number } |
composeBakePose(bake: { number }, g: any) → void
The pose for a mesh visual combining a geometry bake (flat TRS from the JS side's translate/rotate calls on a parametric geometry) with the primitive's constant mapping pose: vertex v -> Bake * Map * v.
| arg | type | description |
|---|---|---|
| bake | { number } | |
| g | any |
mapMaterial(mat: any) → string
| arg | type | description |
|---|---|---|
| mat | any |
applyTint(vis: any, mat: any) → void
| arg | type | description |
|---|---|---|
| vis | any | |
| mat | any |
new(opts: any?) → void
| arg | type | description |
|---|---|---|
| opts | any? |
_register(id: number, rec: any) → void
| arg | type | description |
|---|---|---|
| id | number | |
| rec | any |
_parentEnt(parentId: any) → any
The hierarchy parent for a new object: another tracked object's entity, or the session root when the object sits directly under the THREE scene.
| arg | type | description |
|---|---|---|
| parentId | any |
createNode(spec: any) → number
A bare transform node mirroring a THREE Group/Object3D. Carries no visual; exists so children compose world transforms through the native hierarchy.
| arg | type | description |
|---|---|---|
| spec | any |
geomArray(v: any) → any
A plain number array for a geometry field that may arrive as a zero-copy typed-array record from the zerojs bridge.
| arg | type | description |
|---|---|---|
| v | any |
createMesh(spec: any) → number
| arg | type | description |
|---|---|---|
| spec | any |
createInstancedMesh(spec: any) → number
An instanced mesh: one parent entity, one shared visual source (a single runtime mesh handle for custom vertex data, or a mapped primitive model), and one child entity per instance carrying its decomposed TRS. Same-model children batch into GPU instancing in the renderer.
| arg | type | description |
|---|---|---|
| spec | any |
updateInstances(id: number, upd: any) → void
Re-sync per-instance data for an instanced mesh: `upd.trs` carries the full flat TRS array (10 per instance), `upd.colors` a flat RGB array. Transforms land in one batchWrite per field.
| arg | type | description |
|---|---|---|
| id | number | |
| upd | any |
createModel(spec: any) → number
A GLTF model node: stamps the imported bundle's node rows as temporary entities carrying native Mesh/Material components resolved from the bundle's own sub-assets. The node carries the THREE-side transform; the stamped hierarchy hangs beneath it. No script components, no persistence — the JS app owns behavior and the engine renders.
| arg | type | description |
|---|---|---|
| spec | any |
playAnimation(id: number, clipName: any) → void
Play an animation clip on a model node's stamped bundle: resolves the clip among the bundle's own animation assets by name, falling back to the first.
| arg | type | description |
|---|---|---|
| id | number | |
| clipName | any |
createPointLight(spec: any) → number
| arg | type | description |
|---|---|---|
| spec | any |
updateLight(id: number, spec: any) → void
| arg | type | description |
|---|---|---|
| id | number | |
| spec | any |
updateMeshMaterial(id: number, mat: any) → void
| arg | type | description |
|---|---|---|
| id | number | |
| mat | any |
setVisible(id: number, v: boolean) → void
| arg | type | description |
|---|---|---|
| id | number | |
| v | boolean |
remove(id: number) → void
| arg | type | description |
|---|---|---|
| id | number |
syncTransforms(flat: { number }) → void
Apply a frame of transforms. `flat` is [id, px,py,pz, qx,qy,qz,qw, sx,sy,sz] repeating, carrying ONLY the objects whose local transform changed this frame (the JS side tracks dirtiness). Each field lands in one batchWrite crossing sized to the change set, so static objects generate no writes at all.
| arg | type | description |
|---|---|---|
| flat | { number } |
setKinematic(id: number, spec: any) → void
Register (or with spec == nil, release) constant-velocity host integration for an object. `spec` = { px,py,pz, vx,vy,vz, wrap = { axis = "x"|"y"|"z", min, max } }. Registered objects advance in `tick` each frame and land in one translation batchWrite — per-frame motion costs no interpreted JS. `wrap` teleports the axis back across the [min,max] band when it exits.
| arg | type | description |
|---|---|---|
| id | number | |
| spec | any |
tick(dt: number) → void
Advance every kinematic object by `dt` seconds and write the frame's translations in one batch crossing.
| arg | type | description |
|---|---|---|
| dt | number |
getPosition(id: number) → void
Current local position of a kinematic object as {x, y, z} — the readback for JS-side game logic (collision) against host-integrated motion.
| arg | type | description |
|---|---|---|
| id | number |
setCamera(c: any) → void
| arg | type | description |
|---|---|---|
| c | any |
setAmbient(spec: any) → void
| arg | type | description |
|---|---|---|
| spec | any |
setDirectional(spec: any) → void
| arg | type | description |
|---|---|---|
| spec | any |
setBackground(c: any) → void
| arg | type | description |
|---|---|---|
| c | any |
readResolved(full: string) → string
Serve a browser-style fetch from the session's asset root. Returns { ok, status, body } with the file's raw bytes as a string. Resolve one candidate VFS file path: direct read, importer-relocated (`<stem>.<category>/<base>`), then content-hash sibling (`<stem>.<hash>.<ext>` as written by hashing build pipelines when the request uses the logical name).
| arg | type | description |
|---|---|---|
| full | string |
jsonDecode(s: string) → any
JSON + matrix helpers shared by bundle metadata and the geometry kernels Minimal JSON decoder (objects, arrays, strings, numbers, booleans, null; UTF-8 passthrough with \uXXXX escapes) for bundle entity_template files.
| arg | type | description |
|---|---|---|
| s | string |
skipWs( ) → void
parseString( ) → string
parseNumber( ) → number
parseValue( ) → void
normalMatrix(m: { number }) → void
Inverse-transpose of the upper-left 3x3, for transforming normals.
| arg | type | description |
|---|---|---|
| m | { number } |
loadBundleMeta(bundlePath: string) → any
Parse a bundle's entity_template into node rows plus its animation clip names. Cached per bundle path; the template is authored once at import.
| arg | type | description |
|---|---|---|
| bundlePath | string |
bundleIdentityFor(bundlePath: string) → string
The bundle asset identity for a bundle VFS path (`/zero/source/a/b/x.bundle` → `a.b.x.bundle`).
| arg | type | description |
|---|---|---|
| bundlePath | string |
bundleFor(url: string) → string
Resolve a model URL to the bundle the importer derived from the source file. Model sources are imported at authoring time; a URL without its bundle resolves to nil and the caller reports it.
| arg | type | description |
|---|---|---|
| url | string |
sourceGlbFor(url: string) → string
Resolve a model URL to its source file on the VFS (the same candidate walk bundleFor uses, but for the .glb/.gltf itself).
| arg | type | description |
|---|---|---|
| url | string |
loadModel(url: string) → any
JS-facing model metadata: named nodes with hierarchy (parent as index), local TRS, mesh/skinned flags, and the bundle's animation clip names.
| arg | type | description |
|---|---|---|
| url | string |
refByIdentity(category: string, identity: string) → any
| arg | type | description |
|---|---|---|
| category | string | |
| identity | string |
subAssetHandle(identity: string, category: string) → any
| arg | type | description |
|---|---|---|
| identity | string | |
| category | string |
readBundleMesh(source: string, nodeName: string) → any
Vertex data for one mesh node of a model's bundle — the read side of the bundle-mapped proxy contract: a proxy's BufferGeometry materializes real attributes from this when the app introspects it. Returns flat positions/normals/uvs plus triangle indices (0-based).
| arg | type | description |
|---|---|---|
| source | string | |
| nodeName | string |
stampBundle(source: string, node: any, rec: any) → void
Stamp a model URL's bundle rows as temporary entities under `node`: Transform hierarchy plus native Mesh/Material components. Rows flagged hidden stay hidden; the first skinned row becomes the animation mount.
| arg | type | description |
|---|---|---|
| source | string | |
| node | any | |
| rec | any |
isTaRec(v: any) → boolean
Geometry kernels — bulk operations on typed-array records The zerojs bridge crosses typed arrays as zero-copy layout records over their backing buffer, so these run native loops over the SAME bytes the JS BufferAttributes hold. In-place ops mutate what JS sees; producing ops return fresh records the bridge lifts back into typed arrays.
| arg | type | description |
|---|---|---|
| v | any |
f32Rec(buf: buffer, len: number) → any
| arg | type | description |
|---|---|---|
| buf | buffer | |
| len | number |
u32Rec(buf: buffer, len: number) → any
| arg | type | description |
|---|---|---|
| buf | buffer | |
| len | number |
copyIntoF32(dst: buffer, at: number, rec: any) → void
Copy a record's elements into `dst` as f32 starting at element `at`, converting element kinds through the record's own reader.
| arg | type | description |
|---|---|---|
| dst | buffer | |
| at | number | |
| rec | any |
applyMat4(spec: any) → boolean
In-place position (mat4) and normal (inverse-transpose) transform, matching BufferGeometry.applyMatrix4. `m` is a 16-element column-major matrix.
| arg | type | description |
|---|---|---|
| spec | any |
merge(spec: any) → any
Merge geometries: concatenates each named float attribute and offsets indices by the running vertex count. Geometries without an index contribute a sequential range. Returns records plus per-geometry groups.
| arg | type | description |
|---|---|---|
| spec | any |
toNonIndexed(spec: any) → any
Expand indexed attributes into per-corner arrays, matching toNonIndexed.
| arg | type | description |
|---|---|---|
| spec | any |
bounds(spec: any) → any
Axis-aligned bounds and bounding sphere of a position record.
| arg | type | description |
|---|---|---|
| spec | any |
computeNormals(spec: any) → any
Area-weighted vertex normals from positions (+ optional index), matching computeVertexNormals. Returns a fresh normal record.
| arg | type | description |
|---|---|---|
| spec | any |
corner(i: number) → void
| arg | type | description |
|---|---|---|
| i | number |
addFace(ia: number, ib: number, ic: number) → void
| arg | type | description |
|---|---|---|
| ia | number | |
| ib | number | |
| ic | number |
fetchFile(url: string) → any
| arg | type | description |
|---|---|---|
| url | string |
destroy( ) → void
envFor(session: any) → void
The flat function table installed as `__ZERO` on a ZeroJS VM. Every function is a plain closure over the session so the marshaling bridge lifts each into a JS function.
| arg | type | description |
|---|---|---|
| session | any |
createMesh(spec: ?) → void
| arg | type | description |
|---|---|---|
| spec | ? |
createInstancedMesh(spec: ?) → void
| arg | type | description |
|---|---|---|
| spec | ? |
updateInstances(id: ?, upd: ?) → void
| arg | type | description |
|---|---|---|
| id | ? | |
| upd | ? |
createNode(spec: ?) → void
| arg | type | description |
|---|---|---|
| spec | ? |
createModel(spec: ?) → void
| arg | type | description |
|---|---|---|
| spec | ? |
playAnimation(id: ?, clipName: ?) → void
| arg | type | description |
|---|---|---|
| id | ? | |
| clipName | ? |
createPointLight(spec: ?) → void
| arg | type | description |
|---|---|---|
| spec | ? |
updateLight(id: ?, spec: ?) → void
| arg | type | description |
|---|---|---|
| id | ? | |
| spec | ? |
updateMeshMaterial(id: ?, mat: ?) → void
| arg | type | description |
|---|---|---|
| id | ? | |
| mat | ? |
setVisible(id: ?, v: ?) → void
| arg | type | description |
|---|---|---|
| id | ? | |
| v | ? |
remove(id: ?) → void
| arg | type | description |
|---|---|---|
| id | ? |
syncTransforms(flat: ?) → void
| arg | type | description |
|---|---|---|
| flat | ? |
setKinematic(id: ?, spec: ?) → void
| arg | type | description |
|---|---|---|
| id | ? | |
| spec | ? |
getPosition(id: ?) → void
| arg | type | description |
|---|---|---|
| id | ? |
setCamera(c: ?) → void
| arg | type | description |
|---|---|---|
| c | ? |
setAmbient(s: ?) → void
| arg | type | description |
|---|---|---|
| s | ? |
setDirectional(s: ?) → void
| arg | type | description |
|---|---|---|
| s | ? |
setBackground(c: ?) → void
| arg | type | description |
|---|---|---|
| c | ? |
screen( ) → void
now( ) → void
input( ) → void
pollEvents( ) → void
fetchFile(url: ?) → void
| arg | type | description |
|---|---|---|
| url | ? |
loadModel(url: ?) → void
| arg | type | description |
|---|---|---|
| url | ? |
readBundleMesh(source: ?, nodeName: ?) → void
| arg | type | description |
|---|---|---|
| source | ? | |
| nodeName | ? |
geomApplyMat4(spec: ?) → void
| arg | type | description |
|---|---|---|
| spec | ? |
geomMerge(spec: ?) → void
| arg | type | description |
|---|---|---|
| spec | ? |
geomToNonIndexed(spec: ?) → void
| arg | type | description |
|---|---|---|
| spec | ? |
geomBounds(spec: ?) → void
| arg | type | description |
|---|---|---|
| spec | ? |
geomComputeNormals(spec: ?) → void
| arg | type | description |
|---|---|---|
| spec | ? |
Sub-parts
Everything contained inside this part. Assets are composite children (clickable cards). Files are leaf payloads. Expand any row to view its source.
Showing up to 3 levels deep. Open a part to see what it holds further down.
Problems
Everything affecting this asset right now: its own problems, anything wrong inside it, and problems on its direct dependencies.
agent_score is exposed.+ quality × 0.35
+ performance × 0.25
± compat factor
Usability ratings
Did the part work as advertised when consumers tried to drop it in. Separate from upvotes: those are taste; this is "did it function".
Scoped to this part · feeds back into the world's score.