SkinnedMeshRenderer.bounds freezes after PrefabResource.instantiate() — clone remap bypasses listener registration
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 52/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Tranquilla
- Stack tecnologico
- typescript
- Ambito
- computer-graphics
Direzione di ricerca
Start in CloneManager.cloneProperty (around lines 109-115), where the _remap branch assigns _transformEntity before the @ignoreClone check, then read Renderer._setTransformEntity (around lines 470-477) and its use in SkinnedMeshRenderer._cloneTo and _applySkin. Done means the rootBone's _updateFlagManager has the _onTransformChanged listener after prefab.instantiate(), and bounds follow the instance when it moves. The payload names no test, so reproduce with the steps given.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Problem
After PrefabResource.instantiate(), SkinnedMeshRenderer.bounds freezes at the initial placement position and never updates when the entity moves. This causes frustum culling to permanently hide moved skinned characters.
Root Cause
Two layers:
Layer 1 (fundamental): CloneManager remap writes _transformEntity bypassing _setTransformEntity()
CloneManager.cloneProperty checks _remap (Entity references) before @ignoreClone:
// CloneManager.ts:109-111 — highest priority
if (sourceProperty instanceof Object && (<ICustomClone>sourceProperty)._remap) {
target[k] = (<ICustomClone>sourceProperty)._remap(srcRoot, targetRoot);
return; // ← returns before cloneMode check at line 115
}
// line 115 — @ignoreClone never reached for Entity references
if (cloneMode === CloneMode.Ignore) return;
During clone, target._transformEntity is directly assigned the remapped rootBone entity without calling _setTransformEntity(), so no _onTransformChanged listener is registered on the new rootBone's _updateFlagManager.
Layer 2 (missing defense): _setTransformEntity equality guard
The subsequent _cloneTo → _applySkin → _setTransformEntity(rootBone) tries to fix this, but the equality guard skips it:
// Renderer.ts:470-477
protected _setTransformEntity(entity: Entity): void {
const preEntity = this._transformEntity;
if (entity !== preEntity) { // ← false after remap set it, entire block skipped
preEntity?._updateFlagManager.removeListener(this._onTransformChanged);
entity?._updateFlagManager.addListener(this._onTransformChanged);
this._transformEntity = entity;
}
}
It assumes "same reference = listener already registered", which is not true after direct field writes from CloneManager.
Concrete example (character queue in a Cocos-to-Galacean migrated game)
Prefab entity tree:
character_man
├── Body ← SkinnedMeshRenderer is on this entity
└── mixamorig:Hips ← rootBone
Step 1 — SMR constructor:
_setTransformEntity(Body') → listener on Body' ✓, _transformEntity = Body'
Step 2 — CloneManager property copy:
_transformEntity is Entity → has _remap → direct assign: _transformEntity = Hips'
⚠️ No _setTransformEntity() call → Body' listener is orphaned, Hips' has 0 listeners
Step 3 — _cloneTo → _applySkin → _setTransformEntity(Hips'):
Hips' === _transformEntity (set in step 2) → equality guard → SKIP
Result: Hips' (rootBone) has 0 listeners → bounds never update → frustum culling wrong
Evidence
Diagnostic data from 12 pooled skinned characters:
| Field | Value |
|---|---|
_transformEntity === skin.rootBone |
true (remap worked correctly) |
Listener count on rootBone _updateFlagManager |
0 |
rootBone.worldMatrix |
Up-to-date (correct position) |
bounds |
Frozen at initial spawn position |
After forcing _dirtyUpdateFlag |= WorldVolume |
Bounds correct (proves _updateBounds logic is fine) |
Suggested Fix
Two options (can be combined):
Option A: Fix _setTransformEntity (defensive, minimal change)
Remove the equality guard so it always ensures the listener is registered:
protected _setTransformEntity(entity: Entity): void {
const preEntity = this._transformEntity;
preEntity?._updateFlagManager.removeListener(this._onTransformChanged);
if (entity) {
entity._updateFlagManager.addListener(this._onTransformChanged);
}
this._transformEntity = entity;
}
Verified to fix the issue. Zero per-frame overhead — only called during clone/skin setup.
Option B: Fix CloneManager priority (fundamental)
Respect @ignoreClone before _remap so that entity references on ignored fields are not written at all:
// Move ignore check before remap check:
if (cloneMode === CloneMode.Ignore) return;
if (sourceProperty instanceof Object && (<ICustomClone>sourceProperty)._remap) {
target[k] = (<ICustomClone>sourceProperty)._remap(srcRoot, targetRoot);
return;
}
Combined with @ignoreClone on Renderer._transformEntity, this prevents the direct write entirely.
Note: Option B has broader impact — other components relying on the current remap-first behavior may need review.
Reproduction
- Create a prefab containing a SkinnedMeshRenderer with a rootBone (e.g. Mixamo character)
const instance = prefab.instantiate()- Add to scene, move the instance entity each frame
- Observe:
instance.getComponentInChildren(SkinnedMeshRenderer).boundsstays at initial position - With
Camera.enableFrustumCulling = true, the character becomes invisible once moved away from spawn
- 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
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di galacean/engine
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 64/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 85/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 52/100
I maintainer di solito rispondono entro 1 giorno
-
RFC: Adopt Unity-style Collider components and hierarchical Rigidbody ownershipForse già presa Una pull request collegata a questa issue è aperta o già unita. Aperta
Difficoltà 5/5 Più di una settimana Idoneità per principianti 20/100
I maintainer di solito rispondono entro 1 giorno
-
SkinnedMeshRenderer should derive default rootBone-space localBounds from mesh and skinForse già presa Una pull request collegata a questa issue è aperta o già unita. Apertaenhancement
Difficoltà 4/5 3-5 giorni Idoneità per principianti 42/100
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di galacean/engine
Issue simili
-
bug impact:low Team: SecuritySolution Team:Defend Workflows v9.6.0
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
elastic/kibana#306401 · 3 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
agentes-chat/agentes-chat#927 ·
I maintainer di solito rispondono entro 1 giorno
-
[Bug]: Webapp workspace fails to render in Safari — "Can't find variable: requestIdleCallback"Apertacomp/desktop P2 type/bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
NousResearch/hermes-agent#157702 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
I maintainer di solito rispondono entro 1 giorno
-
e2e-failure ready-to-code
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 72/100
redhat-developer/rhdh-plugin-export-overlays#4794 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno