在混合實境首頁中啟用 3D 模型的放置Enable placement of 3D models in the mixed reality home

注意

這項功能已新增為 Windows 10 2018 年4月更新的一部分。This feature was added as part of the Windows 10 April 2018 Update. 較舊版本的 Windows 與這項功能不相容。Older versions of Windows are not compatible with this feature.

Windows Mixed Reality home是使用者在啟動應用程式之前所居住的起點。The Windows Mixed Reality home is the starting point where users land before launching applications. 在某些案例中,2D 應用程式 (像是全像全像影像應用程式) 將3D 模型以裝飾的形式直接放入混合實境首頁,或以完整3D 進行進一步檢查。In some scenarios, 2D apps (like the Holograms app) enable placement of 3D models directly into the mixed reality home as decorations or for further inspection in full 3D. 新增模型」通訊協定 可讓您將來自您網站或應用程式的3d 模型直接傳送到 Windows Mixed Reality 首頁,它會保存為 3d 應用程式啟動器、2d 應用程式和全像影像。The add model protocol allows you to send a 3D model from your website or application directly into the Windows Mixed Reality home, where it will persist like 3D app launchers, 2D apps, and holograms.

例如,如果您要開發的應用程式會呈現3D 傢俱的目錄來設計空間,請使用「 新增模型」通訊協定 ,讓使用者能夠從類別目錄放置這些3d 傢俱模型。For example, if you're developing an application that surfaces a catalog of 3D furniture for designing a space, use the add model protocol to allow users to place those 3D furniture models from the catalog. 一旦放在世界中,使用者就可以移動、調整大小和移除這些3D 模型,就像家裡的其他全息圖一樣。Once placed in the world, users can move, resize, and remove these 3D models just like other holograms in the home. 本文概述如何實行「 新增模型」通訊協定 ,讓使用者能夠從您的應用程式或 Web 使用3d 物件裝飾其世界。This article provides an overview of implementing the add model protocol for enabling users to decorate their world with 3D objects from your app or the web.

裝置支援Device support

功能Feature HoloLensHoloLens 沉浸式頭戴裝置Immersive headsets
新增模型通訊協定Add model protocol ✔️✔️ ✔️✔️

基本概念The basics

有兩個步驟可讓您在 Windows Mixed Reality 首頁中放置3D 模型:There are two steps to enabling the placement of 3D models in the Windows Mixed Reality home:

  1. 確定您的3d 模型與 Windows Mixed Reality 首頁相容Ensure your 3D model is compatible with the Windows Mixed Reality home.
  2. (本文) ,在您的應用程式或網頁中執行「 新增模型」通訊協定Implement the add model protocol in your application or webpage (this article).

執行 新增模型通訊協定Implementing the add model protocol

當您有 相容的3d 模型之後,您可以從任何網頁或應用程式啟用下列 URI,以執行「 新增模型」通訊協定Once you have a compatible 3D model, you can implement the add model protocol by activating the following URI from any webpage or application:

ms-mixedreality:addmodel?uri=<Path to a .glb 3D model either local or remote>

如果 URI 指向遠端資源,則會自動下載並放在首頁中。If the URI points to a remote resource, then it will automatically be downloaded and placed in the home. 本機資源將會先複製到混合實境首頁的應用程式資料夾,然後再放在首頁中。Local resources will be copied to the mixed reality home's app data folder before being placed in the home. 我們建議您設計體驗,以考慮使用者可能會藉由隱藏按鈕或在可能情況下停用的較舊版本 Windows,來執行不支援這項功能的舊版 Windows。We recommend designing your experience to account for scenarios where the user might be running an older version of Windows that doesn't support this feature by hiding the button or disabling it if possible.

從通用 Windows 平臺應用程式叫用 新增模型通訊協定Invoking the add model protocol from a Universal Windows Platform app:

private async void launchURI_Click(object sender, RoutedEventArgs e)
{
   // Define the add model URI
   var uriAddModel = new Uri(@"ms-mixedreality:addModel?uri=sample.glb");

   // Launch the URI to invoke the placement
   var success = await Windows.System.Launcher.LaunchUriAsync(uriAddModel);

   if (success)
   {
      // URI launched
   }
   else
   {
      // URI launch failed
   }
}

從網頁叫用 新增模型通訊協定Invoking the add model protocol from a webpage:

<a class="btn btn-default" href="ms-mixedreality:addModel?uri=sample.glb"> Place 3D Model </a>

沉浸式 (VR) 耳機的考慮Considerations for immersive (VR) headsets

  • 針對沉浸式 (VR) 耳機,混合實境入口不需要在叫用 新增模型通訊協定 之前執行。For immersive (VR) headsets, the Mixed Reality Portal doesn't have to be running before invoking the add model protocol. 在此情況下,「 新增模型」通訊協定 將會啟動混合實境入口,並在您抵達混合實境首頁之後,直接將物件放在耳機所要查看的位置。In this case, the add model protocol will launch the Mixed Reality Portal and place the object directly where the headset is looking once you arrive in the mixed reality home.
  • 從已執行混合實境入口的桌面叫用 新增模型通訊協定 時,請確定耳機為「喚醒」。When invoking the add model protocol from the desktop with the Mixed Reality Portal already running, ensure that the headset is "awake". 如果沒有,則放置將不會成功。If not, the placement won't succeed.

另請參閱See also