を使用した拡張現実
コレクションでコンテンツを整理
必要に応じて、コンテンツの保存と分類を行います。
<model-viewer>
ウェブ コンポーネントを使用すると、ウェブ上で 3D モデルを表示して操作できます。また、ウェブ上の拡張現実で 3D モデルを配置して操作することもできます。
ARCore 対応の Android デバイスで表示すると、ar
属性を持つ <model-viewer>
コンポーネントは、次の例に示すようにボタンを表示します。
![モデル ビューアのスクリーンショット]()
ARCore 対応デバイスでこのボタンをタップすると、ar-modes
属性の値に応じて、Chrome の WebXR 機能または Scene Viewer アプリを使用してモデルが表示されます。
AR ボタンの外観は、ウェブ コンポーネント スロットを使用してカスタマイズできます。例については、<model-viewer> documentation
をご覧ください。Android アプリまたはブラウザから AR でインタラクティブな 3D モデルを表示する方法については、Scene Viewer もご覧ください。
<model-viewer>
を使ってみる
次の手順では、任意のウェブページで <model-viewer>
を使用する方法について説明します。
<model-viewer>
の依存関係を追加する
unpkg CDN から
<script type="module" src="https://unpkg.com/@google/model-viewer/dist/model-viewer.min.js"></script>
npm から
npm install @google/model-viewer
次に、任意のバンドルツールを使用して、node_modules/model-viewer/dist/model-viewer.min.js
に <model-viewer>
を追加します。
<model-viewer>
タグを含める
<model-viewer>
ウェブ コンポーネントを HTML ドキュメントに追加します。
<model-viewer src="https://modelviewer.dev/shared-assets/models/Astronaut.glb"
ios-src="https://modelviewer.dev/shared-assets/models/Astronaut.usdz"
alt="A 3D model of an astronaut"
ar
auto-rotate
camera-controls></model-viewer>
モデルの表示は、<model-viewer>
タグの属性を変更することで構成できます。これらのプロパティには、カメラの移動、モデルのアニメーション、環境情報などのオプションが公開されます。設定可能なすべての属性については、<model-viewer>
のドキュメントをご覧ください。モデル エディタ ユーティリティを使用すると、<model-viewer>
HTML タグを生成し、カメラの位置や照明などのプロパティを構成できます。
![モデルエディタのスクリーンショット]()
モデルの互換性
gltf
ファイル形式と glb
ファイル形式のモデルは <model-viewer>
でサポートされています。サポートされている glTF 拡張機能の一覧については、three.js GLTFLoader documentation
をご覧ください。
モデルが正しく表示されるように、モデル エディタでモデルを確認します。
サポート対象のブラウザとデバイス
<model-viewer>
を使用してウェブページに 3D モデルを表示することは、すべてのエバーグリーン ブラウザでサポートされています。要素にフォーカスが当たっているときにフォーカス リングを非表示にするには、:focus-visible
ポリフィルを使用することをおすすめします。
AR 機能を使用するには、ARCore 対応デバイスと Google Play 開発者サービス(AR)のインストールが必要です。webxr
AR モードについては、WebXR ブラウザのサポートを参照してください。デフォルトでは、WebXR がサポートされていない場合は、代わりにシーン ビューアが使用されます。
次のステップ
特に記載のない限り、このページのコンテンツはクリエイティブ・コモンズの表示 4.0 ライセンスにより使用許諾されます。コードサンプルは Apache 2.0 ライセンスにより使用許諾されます。詳しくは、Google Developers サイトのポリシーをご覧ください。Java は Oracle および関連会社の登録商標です。
最終更新日 2024-11-23 UTC。
[null,null,["最終更新日 2024-11-23 UTC。"],[],[],null,["# Augmented reality with <model-viewer>\n\nThe `\u003cmodel-viewer\u003e` web component can be used to view and interact with 3D models on the web, and it seamlessly transitions to placing and interacting with those 3D models in Augmented Reality on the web.\n\nWhen viewed on an ARCore-supported Android device, a `\u003cmodel-viewer\u003e` component\nwith the `ar` attribute displays a button as shown in the following example:\n\nTapping this button on ARCore-supported devices will display the model using Chrome's WebXR functionality or\n[the Scene Viewer app](/ar/develop/java/scene-viewer), depending on the value of\nthe [`ar-modes`](https://modelviewer.dev/docs/index.html#entrydocs-augmentedreality-attributes-arModes)\nattribute.\n\nThe appearance of the AR button can be customized by using web component slots.\nRefer to the [`\u003cmodel-viewer\u003e documentation`](https://modelviewer.dev/examples/augmentedreality/#customButton) for an example. See also, [Scene Viewer](/ar/develop/scene-viewer) for more\nabout displaying interactive 3D models in AR from an Android app or browser.\n\nGetting started with `\u003cmodel-viewer\u003e`\n-------------------------------------\n\nThe following steps show how to get started with `\u003cmodel-viewer\u003e` on any webpage.\n\n### Add the `\u003cmodel-viewer\u003e` dependency\n\n### From unpkg CDN\n\n \u003cscript type=\"module\" src=\"https://unpkg.com/@google/model-viewer/dist/model-viewer.min.js\"\u003e\u003c/script\u003e\n\n### From npm\n\n npm install @google/model-viewer\n\nThen, add `\u003cmodel-viewer\u003e` at `node_modules/model-viewer/dist/model-viewer.min.js` using your preferred bundler,\n\n### Include the `\u003cmodel-viewer\u003e` tag\n\nAdd the `\u003cmodel-viewer\u003e` web component to your HTML document: \n\n \u003cmodel-viewer src=\"https://modelviewer.dev/shared-assets/models/Astronaut.glb\"\n ios-src=\"https://modelviewer.dev/shared-assets/models/Astronaut.usdz\"\n alt=\"A 3D model of an astronaut\"\n ar\n auto-rotate\n camera-controls\u003e\u003c/model-viewer\u003e\n\n### Configure the `\u003cmodel-viewer\u003e` tag\n\nThe model display can be configured by changing the attributes on the `\u003cmodel-viewer\u003e` tag.\nThese properties expose options such as camera movement, model animations, and environment information.\nThe [`\u003cmodel-viewer\u003e` documentation](https://modelviewer.dev/docs/) lists all attributes that can be set.\nThe [Model Editor](https://modelviewer.dev/editor/) utility can generate a `\u003cmodel-viewer\u003e` HTML tag and configure properties such as camera position and lighting.\n\nModel compatibility\n-------------------\n\nModels in the [`gltf` and `glb` file format](https://www.khronos.org/gltf/) are supported by `\u003cmodel-viewer\u003e`.\nRefer to the [`three.js GLTFLoader documentation`](https://threejs.org/docs/#examples/en/loaders/GLTFLoader) for a list of\nsupported glTF extensions.\n\nTo ensure that your model will display properly, check your model in [Model Editor](https://modelviewer.dev/editor/).\n\nBrowser and device support\n--------------------------\n\nUsing `\u003cmodel-viewer\u003e` to display 3D models in a web page is supported in all evergreen browsers.\nWe recommend using [a `:focus-visible` polyfill](https://modelviewer.dev/#section-browser-support) to hide focus rings when the element is focused.\n\nAR features require an [ARCore-supported device](https://developers.google.com/ar/devices) and an installation of [Google Play Services for AR](https://play.google.com/store/apps/details?id=com.google.ar.core). For the `webxr` [AR mode](https://modelviewer.dev/docs/#entrydocs-augmentedreality-attributes-arModes), refer to [WebXR browser support](https://caniuse.com/webxr).\nBy default, if WebXR is not supported, [Scene Viewer](https://developers.google.com/ar/develop/java/scene-viewer#scene_viewer_runtime_requirements) will be used instead.\n\nNext steps\n----------\n\n- Review the [`\u003cmodel-viewer\u003e` reference documentation](https://modelviewer.dev/docs/index.html)\n- Check out [`\u003cmodel-viewer\u003e` samples on modelviewer.dev](https://modelviewer.dev/examples/)\n- See also, [Scene Viewer](/ar/develop/scene-viewer) for more about displaying interactive 3D models in AR from an Android app or browser."]]