diff --git a/cocos/scene-graph/node.ts b/cocos/scene-graph/node.ts index 294c8d242fa..ccac05857fd 100644 --- a/cocos/scene-graph/node.ts +++ b/cocos/scene-graph/node.ts @@ -1525,7 +1525,7 @@ export class Node extends CCObject implements ISchedulable, CustomSerializable { @serializable protected _euler = new Vec3(); - protected _transformFlags = TransformBit.NONE; // does the world transform need to update? + protected _transformFlags = TransformBit.TRS; // does the world transform need to update? protected _eulerDirty = false; protected _flagChangeVersion = 0; diff --git a/native/cocos/core/scene-graph/Node.h b/native/cocos/core/scene-graph/Node.h index d08e12fde20..38baeed0324 100644 --- a/native/cocos/core/scene-graph/Node.h +++ b/native/cocos/core/scene-graph/Node.h @@ -657,7 +657,7 @@ class Node : public CCObject { // NOTE: TypeArray created in node.jsb.ts _ctor should have the same memory layout uint32_t _eventMask{0}; // Uint32: 0 uint32_t _layer{static_cast(Layers::LayerList::DEFAULT)}; // Uint32: 1 - uint32_t _transformFlags{0}; // Uint32: 2 + uint32_t _transformFlags{static_cast(TransformBit::TRS)}; // Uint32: 2 index_t _siblingIndex{0}; // Int32: 0 uint8_t _activeInHierarchy{0}; // Uint8: 0 uint8_t _active{1}; // Uint8: 1 diff --git a/tests/scene-graph/scene.test.ts b/tests/scene-graph/scene.test.ts new file mode 100644 index 00000000000..76e1cae9e20 --- /dev/null +++ b/tests/scene-graph/scene.test.ts @@ -0,0 +1,26 @@ +import { deserialize } from "../../cocos/serialization"; +import '../utils/matchers/value-type-asymmetric-matchers'; +import { v3 } from "../../cocos/core"; +import { Scene } from "../../cocos/scene-graph"; + +test(`Bugfix cocos/cocos-engine#16352: deserialized scene should have node transforms invalidated`, () => { + const archive = [{ + __type__: 'cc.Scene', + _children: [{ + __type__: 'cc.Node', + _name: 'Node', + _lscale: { + __type__: 'cc.Vec3', + x: 2, + y: 1, + z: 1, + }, + }], + }]; + + const scene = deserialize(archive) as Scene; + + const node = scene.getChildByPath('Node')!; + expect(node).not.toBeNull(); + expect(node.worldScale).toBeCloseToVec3(v3(2, 1, 1)); +}); \ No newline at end of file