UNPKG

4.5 kBMarkdownView Raw
1<p align="center">
2 <img alt="A 3D model of an astronaut" src="screenshot.png" width="480">
3</p>
4
5# `<model-viewer>`
6
7 [![Build Status](https://github.com/google/model-viewer/workflows/Unit%20tests/badge.svg?branch=master)](https://github.com/google/model-viewer/actions?query=branch%3Amaster)
8 [![NPM](https://img.shields.io/npm/v/@google/model-viewer.svg)](https://www.npmjs.com/package/@google/model-viewer)
9 [![Bundlephobia](https://badgen.net/bundlephobia/minzip/@google/model-viewer)](https://bundlephobia.com/result?p=@google/model-viewer)
10 [![Join the community on Spectrum](https://withspectrum.github.io/badge/badge.svg)](https://spectrum.chat/model-viewer)
11
12`<model-viewer>` is a web component that makes rendering interactive 3D
13models - optionally in AR - easy to do, on as many browsers and devices as possible.
14`<model-viewer>` strives to give you great defaults for rendering quality and
15performance.
16
17As new standards and APIs become available `<model-viewer>` will be improved
18to take advantage of them. If possible, fallbacks and polyfills will be
19supported to provide a seamless development experience.
20
21[Demo](https://model-viewer.glitch.me) • [Documentation](https://modelviewer.dev/) • [Kanban](https://github.com/google/model-viewer/projects/1) • [Quality Tests](https://modelviewer.dev/fidelity/)
22
23
24## Installing
25
26The `<model-viewer>` web component can be installed from [NPM](https://npmjs.org):
27
28```sh
29npm install @google/model-viewer
30```
31
32It can also be used directly from various free CDNs such as [unpkg.com](https://unpkg.com):
33
34```html
35<script type="module" src="https://unpkg.com/@google/model-viewer/dist/model-viewer.min.js"></script>
36```
37
38For more detailed usage documentation and live examples, please visit our docs
39at [modelviewer.dev](https://modelviewer.dev)!
40
41### Important note about versions
42Our goal for `<model-viewer>` is to be a consistent, stable part of your web
43platform while continuing to deliver cutting-edge features. We’ll always try
44to minimize breaking changes, and to keep the component backwards compatible.
45See our [guide to contributing](../../CONTRIBUTING.md#Stability) for more
46information on backwards compatibility.
47
48For your production site you may want the extra stability that comes by
49pinning to a specific version, and upgrading on your own schedule (after
50testing).
51
52If you’ve installed via [NPM](https://npmjs.org), you’re all set - you’ll only
53upgrade when you run [`npm update`](https://docs.npmjs.com/cli/update.html).
54
55If you’re using [unpkg.com](https://unpkg.com), you can pin to a specific
56version by specifying it in the URL. Replace the `<version>` tag in the sample
57below with the full version number (like `0.10.0`) to be pinned to.
58
59```html
60<!-- Loads <model-viewer> for modern browsers: -->
61<script type="module"
62 src="https://unpkg.com/@google/model-viewer@<version>/dist/model-viewer.min.js">
63</script>
64```
65
66
67## Browser Support
68
69`<model-viewer>` is supported on the last 2 major versions of all evergreen
70desktop and mobile browsers.
71
72| | <img src="https://github.com/alrra/browser-logos/raw/master/src/chrome/chrome_32x32.png" width="16"> Chrome | <img src="https://github.com/alrra/browser-logos/raw/master/src/firefox/firefox_32x32.png" width="16"> Firefox | <img src="https://github.com/alrra/browser-logos/raw/master/src/safari/safari_32x32.png" width="16"> Safari | <img src="https://github.com/alrra/browser-logos/raw/master/src/edge/edge_32x32.png" width="16"> Edge |
73| -------- | --- | --- | --- | --- |
74| Desktop | ✅ | ✅ | ✅ | ✅ |
75| Mobile | ✅ | ✅ | ✅ | ✅ |
76
77`<model-viewer>` builds upon standard web platform APIs so that the performance,
78capabilities and compatibility of the library get better as the web evolves.
79
80## Development
81
82To get started, follow the instructions in [the main README.md file](../../README.md).
83
84The following commands are available when developing `<model-viewer>`:
85
86Command | Description
87------------------------------- | -----------
88`npm run build` | Builds all `<model-viewer>` distributable files
89`npm run build:dev` | Builds a subset of distributable files (faster than `npm run build`)
90`npm run test` | Run `<model-viewer>` unit tests
91`npm run clean` | Deletes all build artifacts
92`npm run dev` | Starts `tsc` and `rollup` in "watch" mode, causing artifacts to automatically rebuild upon incremental changes
93