Skip to content

Commit ca2b1fb

Browse files
committed
Only apply the GLTF root transform when the entity still has the default transform
1 parent 3ce7e50 commit ca2b1fb

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

engine/core/subsystem/MeshSystem.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1764,10 +1764,15 @@ bool MeshSystem::loadGLTF(Entity entity, const std::string filename, bool asyncL
17641764
}
17651765
}
17661766

1767-
// getting mesh transform based on GLTF scene root node
1767+
// Only apply the GLTF root transform when the entity still has the default transform.
17681768
Matrix4 matrix = getGLTFMeshGlobalMatrix(meshNode, model, nodesParent);
1769-
matrix.decompose(transform.position, transform.scale, transform.rotation);
1770-
transform.needUpdate = true;
1769+
bool hasDefaultTransform = (transform.position == Vector3::ZERO)
1770+
&& (transform.rotation == Quaternion::IDENTITY)
1771+
&& (transform.scale == Vector3::UNIT_SCALE);
1772+
if (hasDefaultTransform) {
1773+
matrix.decompose(transform.position, transform.scale, transform.rotation);
1774+
transform.needUpdate = true;
1775+
}
17711776

17721777
mesh.cullingMode = CullingMode::BACK;
17731778
if (matrix.determinant() < 0.0){

0 commit comments

Comments
 (0)