20 KiB
20 KiB
Cocos Creator 3.8 Conversion Rules - Stage 1 World Camera And Visible Lands
Scope
- Stage 1A reconstructs the Cocos design/window size,
root/scene,farm_scene_v3world-map root, background map nodes, and main camera source values. - Stage 1B reconstructs the 24 visible land nodes under
farm_scene_v3/Scaled/Rotate/GridOrigin. - The 36-cell
farm_scene_v3_spritegrid is not used as visible-land authority for Stage 1B. - Target runtime is Cocos Creator 3.8.
Source Evidence
- Startup scene:
/Users/hy/Documents/dev/qq_farm_godot_rebuild_20260616/source_raw/6A3BB7D3D4349E2050E7B701AAD51600_726750140f8084ebcbe5190fe9c198c9/assets/main/import/ee/ee605885-16e1-4a63-bf4b-d9663c5764b2.2fd9c.json - World prefab:
/Users/hy/Documents/dev/qq_farm_godot_rebuild_20260616/downloads/raw/remote/extraRes/import/0e/0ec3b3100.19268.json - Runtime environment config:
/Users/hy/Documents/dev/qq_farm_godot_rebuild_20260616/downloads/raw/remote/delayRes/import/12/12fc59f2-1411-4cf8-bd1c-c92f6a8f0251.7ff67.json - Extracted source inventory:
/Users/hy/Documents/dev/qq_farm_godot_rebuild_20260616/source_first/out/main_scene_elements.json
Window And Canvas
- Source Cocos design resolution:
720 x 1280. - Source Cocos
rootsize:720 x 1280. - Source Cocos
root/scenesize:3320 x 2560. - Cocos Creator 3.8 project settings must preserve the same design resolution for this pass.
- Source
startup.sceneCanvas component is the compact row[15,-6,-5]. In Cocos compiled-json refs,_cameraComponent=-5resolves by~(-5)=4; refs record4is[0,3,7], so the Canvas camera target is instance7, theroot/ui/uiCameracc.Cameracomponent. - The generated Creator 3.8 Canvas must bind
root/ui/uiCamera, notroot/scene/Camera. The world camera is therefore not a Canvas-bound camera. Its serialized Camera height is640, and startup applies the source camera-controllerminZoom=0.8, producing runtimeorthoHeight=640 / 0.8 = 800.
World Map Position
farm_scene_v3local position is(0, -43.566, 0).farm_scene_v3/Scene/BgLayer/defaultbglocal position is(0, 1248.749, 0), size3320 x 1404.farm_scene_v3/Scene/FgLayer/defaultlocal position is(0, -316.229, 0), size3320 x 2472.- Cocos Creator 3.8 receives these local positions and sizes directly from source-backed generated data.
Visible Land Grid
- Visible land source prefab:
farm_scene_v3. - Visible land root chain:
farm_scene_v3/Scaledlocal position(-490.399, -225.906, 0), scale(1, 1, 1).farm_scene_v3/Scaled/Rotatelocal position(0, 0, 0), euler(0, 0, 0).farm_scene_v3/Scaled/Rotate/GridOriginlocal position(0, 0, 0), scale(1, 1, 1).
- Each source
grid_*node is generated as a Cocos Creator node underGridOrigin. - Each source
grid_*node keeps source local position, scale, euler, UITransform size196.021 x 110, and anchor(0, 0). - Each
grid_*/iconchild keeps source local position(98.011, 0, 0), UITransform size161.32 x 96.02, and anchor approximately(0.494, 0.503). - Render order follows the source
visual_land_cellsource indexes fromfarm_scene_v3, not theLand.idbusiness order. Land.grid_x/grid_ymaps directly tofarm_scene_v3/Scaled/Rotate/GridOrigin/grid_{grid_x}_{grid_y}.farm_scene_v3_sprite/Scaled/Rotate/GridOrigincontains 36 static cells and uses a different transform chain:Scaled.y=0.5,Rotate.z=-45,GridOrigin.x=1.07. This chain is recorded as excluded evidence and must not be used to place the 24 visible lands.
Land Asset And Level Rules
LandJsonAsset defines exactly 24 business lands. Land ids1..6have nopreceding_land_id; land id7is the first expandable land withpreceding_land_id=6,unlocked_res=model/v3/land_extend/spriteFrame,level_need=5, andgold_need=5000.farm_scene_v3serializes every visiblegrid_*/iconassp.Skeleton, not ascc.Sprite.- The source
scene_landsp.SkeletonDatais embedded in the compact prefab with atlasText, textureNames, skeletonJson, and source texture refs. - Cocos Creator 3.8 conversion must generate an external Spine asset:
assets/spine/stage1/scene_land.jsonfrom source skeletonJson.assets/spine/stage1/scene_land.atlasfrom source atlasText.assets/spine/stage1/scene_land.pngfrom the source atlas PNG.scene_land.json.metaimporterspine-data, withuserData.atlasUuidpointing toscene_land.atlas.meta.
- Each generated
grid_*/iconmust keepsp.Skeleton, source_preCacheMode,_cacheMode,_enableBatch, sourcedefaultSkin, and_skeletonDatareferencing the externalscene_landspine-data UUID. LevelJsonAsset is the authority for land-level animations and source resource mapping:- level 1
普通土地:land_spine_res=spine/v2/scene/scene_land/scene_land,merge_anim=land_valid1, dryland_dry1. - level 2
红土地:merge_anim=land_valid2, dryland_dry2. - level 3
黑土地:merge_anim=land_valid3, dryland_dry3. - level 4
金土地:merge_anim=land_valid4, dryland_dry4. - level 5
紫晶土地:merge_anim=land_valid4, dryland_dry4.
- level 1
WeatherJsonAsset id1is the sunny default and maps locked land tomodel/v3/land_locked/spriteFrame.- Local mock state may select a skeleton default animation, but it must not redefine land-level resource mapping. Without runtime player land-level state, unlocked lands default to
land_valid1only. - The first expandable land uses
land_extendfromLand.id=7.unlocked_resas a separate overlay child; its sourceiconremainssp.Skeletonand usesland_lockedin the current mock state. - The world-map text rendered on top of that board is not generated until its runtime node/font/offset evidence is recovered.
Empty Land Interaction
- Interaction prefab source:
extraRes/import/03/032791d54.4866b.json. plant_interactive_v2is generated inactive underroot/uibecause the source prefab layer is33554432(UI_2D) and the startup scene hasroot/ui/uiCamerawith priority1,_orthoHeight=640,clearFlags=0, and visibility34603008.- Interaction nodes keep source local positions, active states, UITransform sizes, label strings, and sprite references from the prefab evidence.
- Component field evidence defines
detailInteractionNode=plant_interactive_v2/followNode/detailNode, so the land detail bubble is mounted tofollowNode/detailNodeat runtime instead of being shown directly fromland_detail/land. - Component field evidence defines
landTargetNode=plant_interactive_v2/landTarget. ThelandTargetnode is the source mount target for the selected-land visual; the compact prefab does not serializeland_valid_selectedas a static child. - Do not generate
landTarget/gold;gui/texture/plantinteractive/goldis a coin image and is not a selected-land border. - The selected-land frame uses the original source SpriteFrame
model/v3/land_valid_selected/spriteFrame, rect/original size150 x 89, pivot(0.5, 0.5), and is generated as the runtime visualplant_interactive_v2/landTarget/land_valid_selectedat local(0, 0, 0). - The source click path does not move the
plant_interactive_v2root to the clicked land. The land icon touch event emits the source land position, then theplant_interactive_v2handler converts it throughworldToScreen,screenToWorld, andconvertToNodeSpaceARand sets the target nodes (landTargetNode,followInteractionNode, and related guide target). The generated root therefore stays at(0,0,0)underroot/ui, whilelandTargetfollows the land andfollowNodefollows the land only when the visible seed/tool slot count is three or fewer. farm_scene_v3/PrePlantandfarm_scene_v3/PostPlantremain recovered source nodes with local positions(0, 52, 0)and(0, 0, 0).- Do not trust parent
grid_*hitboxes as visual land hitboxes. Sourcegrid_*nodes have UITransform196.021 x 110with anchor(0, 0), while the visual land is the childgrid_*/iconwith size161.32 x 96.02, anchor(0.494, 0.503), and local(98.011, 0). - Click response resolves the intended land from the touch location against visible
grid_*/iconworld centers, then applies mock state gating. This matches the visible land center and avoids overlapping parent-hitbox dispatch. - Interaction popup and seed-list nodes keep source scale
(1, 1, 1). SpriteFrame/UITransform sizes are not multiplied by a hidden layout factor; their final screen projection must come only from the active camera and current Cocos view scale. - Source active-state evidence for the seed-list background is
bg_node3.active=trueandbg_node5.active=false. Runtime keepsbg_node3for three or fewer visible slots and switches tobg_node5only when more than three slots are visible. - Click response is mock-state gated only:
unlocked_normalactivatesplant_interactive_v2;first_expandableandlocked_unplowedreturn without activation. - Seed mock data must live under
assets/scripts/mock/and must not change recovered layout nodes.
Background Asset Selection
FarmEnvid6bindsfarm_scene_v3/Scene/BgLayer/defaultbgtodelayRes/scene/bg/spriteFrame, position(0, 1248.749), size3320 x 1404.FarmEnvid7bindsfarm_scene_v3/Scene/FgLayer/defaulttodelayRes/scene/fg/spriteFrame, position(0, -316.229), size3320 x 2472.- The lower-resolution
extraRes/model/v3/scene/bgandextraRes/model/v3/scene/fgtextures are not selected for this stage becauseFarmEnvdoes not bind them to the active default environment.
Camera
- Source Cocos main camera path:
root/scene/Camera. - Source Cocos main camera local position:
(0, 0, 1000). - Source Cocos projection:
0. - Source Cocos
_orthoHeight:640. - Source Cocos
_near:0. - Source Cocos
_far:2000. - Source Cocos camera-controller component
95c7akihY5GNYe9/Wanw0Abis on the sameroot/scene/Cameranode and serializesminZoom=0.8,maxZoom=2.4,minX=-360,maxX=360,minY=-320,maxY=320, andmaxVisibleWidth=2300. - Generated startup world-camera rule: keep the source Camera component as the base value, then apply the source controller minimum zoom, so runtime
mainCamera.orthoHeight = 640 / 0.8 = 800. - Cocos Creator 3.8 camera conversion must be implemented as a public script or generation rule before producing final scene data. Do not apply camera compensation inside the editor by hand.
UI Camera Viewport Sync
- Source Cocos UI camera path:
root/ui/uiCamera. - Source Cocos UI camera local position:
(360, 640, 1000). - Source Cocos UI camera projection:
0. - Source Cocos UI camera serialized
_orthoHeight:640. - Source Cocos UI camera visibility:
34603008; this includes the sourceUI_2Dlayer used bymain_ui_v2,plant_interactive_v2, and later UI prefabs. - Source UI roots also use
cc.Widget:main_ui_v2has_alignFlags=45,HeadInfohas_alignFlags=9, andSourcehas_alignFlags=33. These Widget flags must remain layout authority for top-left and top-right HUD placement. - Cocos Creator 3.8 can resize a Canvas-bound camera from the current screen visible size, but this project overrides the fixed UI layer back to the source Canvas coordinate system after resize events.
- The recovered
root/ui/uiCamerais the source Canvas-bound camera. The runtime component onroot/uimust keepuiCamera.orthoHeight = SOURCE_DESIGN_HEIGHT / 2androot/uisizeSOURCE_DESIGN_WIDTH x SOURCE_DESIGN_HEIGHT. - This fixed UI rule changes only the UI camera's runtime visible height and the root UI rectangle. It must not change the main world camera, source HUD node local positions, anchors, sizes, Widget flags, SpriteFrame metadata, or mock data.
- This rule also applies to
plant_interactive_v2, because the empty-land bubble, seed list, and selected-land visual live under source layerUI_2Dand are rendered byroot/ui/uiCamera. - Tall-viewport root-cause check:
- The generated project previously bound Canvas to
root/scene/Camera, so Creator 3.8 resized the world camera to784.8387096774193at744 x 1622, making the map, house, lands, and world-space objects smaller. - Source refs prove Canvas must bind
root/ui/uiCamera; after this correction the world camera no longer receives Canvas resize and starts at640 / 0.8 = 800, while the fixed UI layer restores the source720 x 1280coordinate system.
- The generated project previously bound Canvas to
Compact UITransform Defaults
- Compact prefab nodes that serialize a
cc.UITransformcomponent but omit_contentSizeand_anchorPointstill have a real Cocos UITransform at runtime. - Cocos Creator 3.8 engine source
cocos/2d/framework/ui-transform.tsinitializes the default UITransform values ascontentSize = 100 x 100andanchorPoint = (0.5, 0.5). - The generated Creator scene must therefore emit a
cc.UITransformwith100 x 100and anchor(0.5, 0.5)when source compact evidence has acc.UITransformcomponent and omits those two fields. - This rule is required for Widget nodes. Runtime evidence showed
main_ui_v2/Sourcehas sourcecc.Widgetalignment and a compactcc.UITransformcomponent with omitted size/anchor fields. Without emitting the default UITransform, Cocos Creator 3.8 Widget alignment reads a null UITransform and the first frame fails before world rendering completes. - This default rule must not be applied to nodes with no source
cc.UITransformcomponent. It only fills omitted fields on an existing source component.
Layer And Visibility
- Source Cocos camera visibility is
1083179010(0x40900002). - The visibility mask includes source world layer bit
1073741824and does not include Cocos Creator UI_2D layer bit33554432. - Stage 1A generated world nodes must therefore use layer
1073741824so the recovered source camera can see them without inventing a UI-layer conversion. - Later UI modules must decode their own source cameras and visibility masks instead of inheriting the Stage 1A world layer rule.
Camera Runtime Limits
minZoom:0.8maxZoom:2.4minX/maxX:-360 / 360minY/maxY:-320 / 320maxVisibleWidth:2300
Current Two-Layer Viewport Rule
- Current phase is a user-directed viewport architecture pass. Do not run
tools/generate_creator_project.pyto overwriteCocosFarm/assets/scenes/stage1_world_camera.sceneduring this pass. - The project design resolution is the source Canvas resolution
720 x 1280, policy2, recorded inCocosFarm/settings/v2/packages/project.json. - The default project view must stay source-backed at
720 x 1280; official preview device size must not replace recovered scene or UI coordinates. - Cocos Creator 3.8 still requires
cc.Camerarender components. The valid conversion is not a zero-camera scene; the valid conversion is to keep render cameras and remove business-level viewport logic from the camera nodes. root/sceneis the main map layer. Land, house, doghouse, crops, and later shop/world objects are rendered byroot/scene/Cameraand follow the map viewport.root/uiis the fixed UI layer. HUD, land info bubble, seed list, operation buttons, and future popups are rendered byroot/ui/uiCameraand keep fixed Cocos design-coordinate size. Browser CSS pixels still followcc.viewscale.Stage1MainWorldLayeris attached toroot/sceneand controls only the main map view:- Assign
mainCamera.orthoHeight = sourceCameraInitialOrthoHeight(). sourceCameraInitialOrthoHeight()is640 / 0.8 = 800, from source Camera_orthoHeight=640and source camera-controllerminZoom=0.8.- Keep
mainCamera.visibility = SOURCE_CAMERA_VISIBILITY.
- Assign
Stage1FixedUiLayeris attached toroot/uiand controls only the fixed UI view:- Assign
uiCamera.orthoHeight = SOURCE_DESIGN_HEIGHT / 2. - Assign the
root/uiUITransform size toSOURCE_DESIGN_WIDTH x SOURCE_DESIGN_HEIGHT. - Disable the root
Widgetonroot/uibecause this layer component owns the root visible rectangle. - Keep
root/uiat(0, 0, 0).
- Assign
- Do not call
view.setDesignResolutionSize()from these runtime layer components. Runtime verification showed resize-callback design changes trigger repeated design-resolution events and can render a black frame. The design resolution belongs in project settings for this pass. - At a browser or phone logical viewport, Creator may still scale the outer canvas to fit the selected preview device. Fixed UI means fixed source design-coordinate layout, not replacing the source
720 x 1280coordinate system with preview CSS pixels. - Land click conversion under the two-layer rule:
- Hit testing uses
mainCamera.worldToScreen(gridIcon.worldPosition). - Icon hitbox size is the original source icon size multiplied by the rendered main-camera projection scale.
- Popup placement converts the selected world icon position from main-camera screen space into fixed-UI world space through
uiCamera.screenToWorld, then into the interaction parent withconvertToNodeSpaceAR.
- Hit testing uses
- Runtime verification should report
mainCamera.orthoHeight=800,uiCamera.orthoHeight=640, and design resolution720 x 1280; source UI node sizes remain source sizes in design coordinates.
Render Order
- Preserve source hierarchy and sibling order unless source runtime code proves a mutation.
- Background layer and foreground layer must remain separate Cocos nodes because
FarmEnvbinds them independently. - Do not derive sibling order by sorting exported source indexes. For compact prefabs, resolve
_childrenorder from the compact reference table first.
Scene Decor - House And Doghouse
- Decor source prefab:
/Users/hy/Documents/dev/qq_farm_godot_rebuild_20260616/downloads/raw/remote/extraRes/import/0e/0ec3b3100.19268.json. - Decor skin config:
/Users/hy/Documents/dev/qq_farm_godot_rebuild_20260616/downloads/raw/remote/delayRes/import/2d/2d201122-b5a7-4181-8f60-d67a399ec757.edfbe.json. - Compact sibling-order rule: read
data[5][1][2]; for parent source indexN, the sequence after[0,N,0]maps negative child keys to concrete node row indexes in exact sibling order. Scene/FgLayersource order isdefault, fg, FarmSkin, Trees, DogLayer, DynamicDogLayer, Board, Tower, Storage.Scene/FgLayer/FarmSkinsource order isLayer1, Layer2, Layer3, Layer4, Layer5, Layer6, Layer7.- Generate every recovered
FgLayersibling in this order. Empty siblings are source placeholders until their own module is recovered. - House source:
SkinCfg.id=201001,skin_type=1,skin_name=默认小屋.- Parent node:
Scene/FgLayer/FarmSkin/Layer2. - Local position:
(347.6, 179.8, 0). - Spine asset:
spine/v2/costume/house/201001. - Cocos Creator asset output:
assets/spine/stage1/house_201001/201001.skel,201001.atlas,201001.png. - Generated node:
Scene/FgLayer/FarmSkin/Layer2/house_201001withsp.Skeleton,defaultSkin=default,defaultAnimation=idle_01.
- Doghouse source:
SkinCfg.id=205001,skin_type=5,skin_name=默认狗屋.- Spine asset:
spine/v2/costume/doghouse/205001. - Visible prefab node:
Scene/FgLayer/DogLayer/dogHouse. - Local position:
(24.266, 223.974, 0). - Anchor evidence:
(0.5, 0.2030596946602437). - Cocos Creator asset output:
assets/spine/stage1/doghouse_205001/205001.skel,205001.atlas,205001.png. - Generated node:
Scene/FgLayer/DogLayer/dogHousewithsp.Skeleton,defaultSkin=default,defaultAnimation=idle_01.
- Do not replace the house or doghouse with hand-drawn shapes or screenshot crops. Use the original Spine binary, atlas text, and atlas PNG.
- Canvas diagnostic preview is not a layout authority for binary Spine attachments until
tools/render_canvas_preview.pycan decode the full Spine attachment stack. Creator runtime Spine capture is the verification authority for Stage 1D decor visibility.