結構化 3D 模型協作:讓 hierarchy 變成互動能力
這場 session 用 AirPods Pro 與引擎模型示範 visionOS 設計審查體驗:保留 USDZ hierarchy、在 entity tree 上放對 ManipulationComponent、用 ClippingComponent 做剖面檢視,並用 volume-weighted variance 自動展開組件。
visionOS 的 3D 協作不是把模型放進空間就結束;真正的關鍵是讓資產 hierarchy、component placement、座標轉換與數學規則共同決定互動。
這支影片在拆空間模型協作的四個前提
模型看起來對,不代表能互動
flatten 到 root 的 USDZ 仍可正常 render,但程式很難找出 piston、case、logic board 這些有意義的 part。hierarchy 是後續選取、隱藏、展開與協作的前提。
ManipulationComponent 放在哪裡,行為就在哪裡
放在 root 時整個 assembly 一起移動;移到 children 時每個 sub-entity 可被個別抓取。幾何沒有變,互動模型卻完全不同。
ClippingComponent 讓內部結構變成可探索表面
visionOS 27 的 clipping 可用 local-space bounds 丟掉 bounds 外的 geometry。再加上六個可拖曳 plane,就能做互動式剖面檢視。
展開方向可以由模型資料自己決定
影片用 volume-weighted position variance 比較 x、y、z 三軸,沿 variance 最大的方向展開組件,讓模型像設計審查中的 exploded view。
從靜態 USDZ 到可協作 inspection tool
先整理 hierarchy,再談互動
把 assemblies、sub-assemblies、parts 用清楚名稱與巢狀結構保留下來。flattened geometry 雖然能 render,但無法支援可靠的選取與程式控制。
用 component placement 切換 open / close 狀態
closed state 把 ManipulationComponent 與 InputTargetComponent 放在 assembly;open state 移除 root component,再加到 sub-entities,並設定 releaseBehavior 為 .stay。
用 ClippingComponent 建立剖面檢視
設定 local-space bounds,必要時打開 shouldClipChildren。若要讓使用者編輯 bounds,額外建立六個 plane entities 作為 visual affordance。
把 drag delta 轉進正確座標系
gesture 來自 clipping plane frame,bounds 要在 model frame 更新。流程是 plane frame 到 world,到 model,投影到 plane normal,再轉回 plane frame 更新 plane 位置。
用資料決定 exploded view 的自然方向
計算每個軸的 volume-weighted position variance,沿最大 variance 的軸建立 FromToBy animations,讓展開方向跟模型結構一致。
重點 1:hierarchy 是空間互動的資料模型
影片很明確地把 asset preparation 放在第一個技術段落:如果模型 export 時把所有 geometry flatten 到 root,viewport 看起來可能完全正確,但程式無法知道哪個 entity 是 piston、哪個是 enclosure、哪個是 logic board。互動不是從手勢開始,而是從資產結構開始。
對內容 pipeline 來說,這代表 USDZ export 應該保留 assembly / sub-assembly / part 的語意,並建立可預測命名。否則 RealityKit 端只能處理一堆無意義的 InteriorPart_47。
重點 2:clipping 的難點不是 component,而是座標系
ClippingComponent 的概念很直接:在 entity local space 給一個 axis-aligned bounding box,renderer 每 frame 丟掉 bounds 外的 geometry。真正容易出錯的是互動式 clipping plane。使用者拖的是 plane entity,bounds 更新的是 model coordinate frame,視覺 plane 又要回到自己的 coordinate frame。
重點 3:autoexpansion 把數學變成互動設計
展開模型時,硬編 x 軸或 y 軸通常會在不同 asset 上失效。影片示範用 volume-weighted position variance 讓程式自己選軸:先看每個 child 的位置分布,再用 volume 作權重,沿 variance 最大的軸展開。大型零件距離平均位置越遠,越能影響展開方向。
這個方法很適合 mechanical assembly、建築、城市基礎設施或任何「理解 part 與 whole 的關係」比單純看外觀更重要的模型。它讓 exploded view 不是固定動畫,而是從模型資料推導出來的協作工具。
風險與遷移注意事項
.stay,使用者放手後的位置可能不符合設計審查預期。shouldClipChildren 預設 false。把 component 加到 parent 卻看不到 children 被裁切,常見原因就在這裡。對 visionOS 團隊的實作啟發
來源
主要來源為 Apple Developer 官方影片頁、官方 transcript、章節與 resources;YouTube 影片頁用於 iframe 與發布 metadata。官方頁:Collaborate on structured 3D models in visionOS - WWDC26。YouTube:WWDC26: Collaborate on structured 3D models in visionOS | Apple。
- →可協作 3D 模型的第一步是保留 asset hierarchy,否則模型只能看,不能可靠操作。
- →ManipulationComponent 放在 root 或 children,決定使用者操作整個 assembly 還是個別零件。
- →visionOS 27 的 ClippingComponent 可做剖面檢視,但互動式 clipping planes 需要嚴格處理 coordinate frames。
- →autoexpansion 可用 volume-weighted position variance 選自然展開軸,讓 exploded view 來自模型資料。