Qt Quick 3D Xr

はじめに

エクステンデッド・リアリティ(XR)とは、バーチャル・リアリティ(VR)、オーグメンテッド・リアリティ(AR)、ミックスド・リアリティ(MR)を含む用語です。これらの技術は、周囲の世界に対するユーザーの知覚を変化させる没入体験を作り出します。Qt Quick 3D Xrモジュールは、さまざまなデバイスやプラットフォームでQt Quick 3Dを使用したXRアプリケーションを開発するためのAPIを提供します。

Qt Quick 3D とQt Quick 3D Xr アプリケーションの違い

エントリー・ポイント

Qt Quick 3DとQt Quick 3D Xrアプリケーションの主な違いは、開発者の視点から見ると、シーンのエントリーポイントであり、実世界の単位とトラッキングデータを意識することが不可欠です。

Qt Quick 3Dでは、最小限のアプリケーションはカメラ、ライト、3Dモデルで構成される。これらの要素の位置とサイズは、シーンの座標系で定義されます。座標系は任意であり、アプリケーションのニーズに合わせて開発者が定義できます。

View3D {
    width: 1280
    height: 720

    PerspectiveCamera {
        position: Qt.vector3d(0, 200, 300)
    }

    DirectionalLight {
    }

    Node {
        id: sceneRoot
        Model {
            id: model
            position: Qt.vector3d(0, -200, 0)
            source: "#Cylinder"
            materials: [ PrincipledMaterial {
                    baseColor: "red"
            }]
        }
    }
}

XRアプリケーションでは、シーンを定義する際に実世界の単位とトラッキングデータを考慮します。カメラの位置と向きは、デバイスの、またはヘッドマウントディスプレイ(HMD)の場合はユーザーの頭の位置と向きによって定義されます。シーンの単位は実世界の単位に合わせる。例えば、ドアや机は、現実世界でも仮想世界と同じ大きさにしたいものです。

注: Qt Quick 3D Xr アプリケーションのエントリーポイントは、View3D ではなく、XrView です。さらに、XrOrigin はシーンの原点を定義し、トラッキングされたアイテムが相対的に配置されます。

XrView {
    DirectionalLight {
    }

    xrOrigin: XrOrigin {
        XrController {
            id: rightController
            controller: XrController.ControllerRight
        }
        XrController {
            id: leftController
            controller: XrController.ControllerLeft
        }
    }

    Node {
        id: sceneRoot
        Model {
            id: floor
            source: ":meshes/floor.mesh"
            materials: [ PrincipledMaterial {
                    baseColor: "green"
                }]
        }

        Model {
            id: table
            property real height: 0.7
            position: Qt.vector3d(0, height - 2.5, 0)
            source: ":meshes/table.mesh"
            materials: PrincipledMaterial {
                baseColor: "white"
            }
        }

        Model {
            id: monitor
            source: ":meshes/monitor.mesh"
            y: table.height
            XrItem {
                id: theScreen
                y: monitor.yOffset + height
                x: -width / 2
                width: monitor.width
                height: monitor.height
                contentItem: ScreenContent {}
            }
        }
    }
}

追加のCMake関数

Qt Quick 3D Xr Examples の CmakeLists.txt ファイルにあるように、プロジェクトのトップレベル CMakeLists ファイルに関数を追加する必要があります。

カスタムAndroidManifest.xml を指定し、それが使用されるようにするには、プロジェクトのCMakeListsファイルにこの行を追加します:

if(ANDROID)
    set_property(TARGET xr_simple APPEND PROPERTY QT_ANDROID_PACKAGE_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/android)
endif()

AndroidManifest.xml の設定の詳細については、Getting Started With Meta Quest 3ページの関連セクションを参照してください。

CMakeLists.txtの変更はvisionOSにも適用され、MacOSXBundleInfo.plist.in

if (APPLE AND CMAKE_SYSTEM_NAME STREQUAL "visionOS")
    set_target_properties(xr_simple PROPERTIES
        MACOSX_BUNDLE_GUI_IDENTIFIER io.qt.xr_simple
        MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/visionos/MacOSXBundleInfo.plist.in
    )
endif()

ここから先は?

Meta Quest 3を始める、またはApple Vision Proを始めるをご覧ください。サポートされるプラットフォームとデバイスの詳細については、サポートされるプラットフォームのページを参照してください。

特定のQt Quick 3D Xr APIをお探しの場合は、API Reference をご覧ください。また、Qt Quick 3D Xr ExamplesではQt Quick 3D Xr APIの使用方法をご紹介しています。

© 2025 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.