SkinnedMeshRenderer should derive default rootBone-space localBounds from mesh and skin

Aperta
#3,185 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@luzhuang ci sta già lavorando.

Dal 15/11/2026.

  • #3186 di @luzhuang — aperta

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
42/100
Tipo di issue
Funzionalità
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
typescript

Direzione di ricerca

Read packages/core/src/mesh/SkinnedMeshRenderer.ts first, especially how localBounds is initialized and consumed in _updateBounds, then study the inverse-bind-matrix math in GLTFSceneParser._computeLocalBounds (packages/loader/src/gltf/parser/GLTFSceneParser.ts) as the reference implementation to move into the renderer. Check BoundingBox.transform and how skin.bones, rootBone and inverseBindMatrices are exposed, and how clone and property setters are wired today. Done means a code-created renderer with mesh plus skin reports valid local and world bounds that follow rootBone, custom bounds survive mesh/skin changes until reset to null, and tests cover the unskinned, in-joints and out-of-joints cases.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

enhancement

Summary

SkinnedMeshRenderer.localBounds currently initializes to (0, 0, 0)..(0, 0, 0) (packages/core/src/mesh/SkinnedMeshRenderer.ts) and is only populated inside GLTFSceneParser._computeLocalBounds (packages/loader/src/gltf/parser/GLTFSceneParser.ts). Any SkinnedMeshRenderer constructed by code, deserialized from .scene / .prefab without an explicitly serialized localBounds, or whose mesh, mesh.bounds, skin, skin.rootBone, skin.bones, or skin.inverseBindMatrices changes after setup ends up with zero or stale localBounds. When skin.rootBone is present, SkinnedMeshRenderer._updateBounds transforms that zero localBounds into a single-point bounds at rootBone.worldPosition, causing erroneous camera frustum culling.

Motivation

  1. Single source of truth for code-created and asset-loaded renderers: Calling entity.addComponent(SkinnedMeshRenderer) with mesh and skin should produce valid localBounds and world bounds without callers having to duplicate GLTFSceneParser's inverse-bind-matrix calculation.
  2. Dynamic invalidation: Updating renderer.mesh, mesh.bounds, renderer.skin, skin.rootBone, skin.bones, or skin.inverseBindMatrices at runtime should automatically refresh localBounds and world bounds unless the user explicitly overrode localBounds.
  3. Unlock upstream / Editor serialization simplification: Scene and prefab deserializers (HierarchyParser / ReflectionParser) and tools like Galacean Editor (galacean/editor#4588) can rely on SkinnedMeshRenderer deriving default localBounds from mesh + skin instead of decoding binary GLB inverseBindMatrices just to populate default localBounds for quantized / meshopt / Draco assets.

Proposed Contract (Symmetric with SpriteRenderer width / height)

  • No new public properties.
  • Automatic derivation by default:
    • When localBounds has not been customized, SkinnedMeshRenderer lazily derives localBounds in skin.rootBone ?? entity space from mesh and skin:
      • Null mesh: (0, 0, 0)..(0, 0, 0).
      • Unskinned (!skin || !skin.rootBone): mesh.bounds.
      • Skinned with rootBone in skin.bones and matching inverseBindMatrices[rootBoneIndex]: BoundingBox.transform(mesh.bounds, inverseBindMatrices[rootBoneIndex], localBounds).
      • Skinned with rootBone outside skin.bones (valid glTF case where skeleton is an ancestor/external node not in joints): capture bind-pose invert(rootBone.transform.worldMatrix) when bound and transform mesh.bounds by it so subsequent runtime rootBone transforms move world bounds without freezing.
  • Explicit customization & reset:
    • Assigning renderer.localBounds = box or mutating renderer.localBounds.min / renderer.localBounds.max locks custom bounds (not overwritten by subsequent mesh / skin changes).
    • Assigning renderer.localBounds = null (or undefined) clears the custom override and restores automatic derivation.
  • Clone semantics & single owner:
    • entity.clone() preserves whether localBounds is automatic vs custom as well as any captured out-of-joints bind-pose inverse matrix.
    • Remove GLTFSceneParser._computeLocalBounds so SkinnedMeshRenderer is the single owner.
Lingua principale
TypeScript
Stelle
5.9k
Fork
413
Merge medio
16h 17m
PR unite (30g)
41

Preparare l'ambiente

  • Nessun Dockerfile né file Docker Compose
  • Ha un modello di pull request
  • Nessuna guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di galacean/engine

Tutte le issue di galacean/engine

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.