react-native-model-viewer-webview 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/AGENTS.md ADDED
@@ -0,0 +1,53 @@
1
+ # React Native Model Viewer WebView Agent Notes
2
+
3
+ This package provides `ModelViewerWebView`, a WebView-backed wrapper around
4
+ Google's `<model-viewer>` web component for simple GLB/glTF previews in React
5
+ Native and Expo apps.
6
+
7
+ ## Scope
8
+
9
+ - Use this package for simple product, marketplace, demo, and vehicle model
10
+ previews where WebView rendering is acceptable.
11
+ - Do not position it as a native 3D engine.
12
+ - Recommend Filament, React Three Fiber Native, Three.js, or Expo GLView when
13
+ the user needs native GPU rendering, custom shaders, physics, AR, or complex
14
+ multi-object scenes.
15
+
16
+ ## Read First
17
+
18
+ - `README.md` for consumer installation and usage.
19
+ - `docs/HOW_IT_WORKS.md` for architecture and bridge behavior.
20
+ - `docs/COMPATIBILITY.md` for supported and unverified React Native ranges.
21
+ - `docs/AGENT_USAGE.md` for agent-facing skill/discovery files.
22
+ - `docs-site/index.html` for the public GitHub Pages docs.
23
+ - `agent-skills/react-native-model-viewer-webview/SKILL.md` when working as a
24
+ skills-compatible AI agent.
25
+
26
+ ## Development
27
+
28
+ - Keep `src` and `dist` in sync. Package tests run against `dist` because npm
29
+ consumers load `dist`.
30
+ - Add or update tests for behavior changes.
31
+ - Keep docs honest about WebView tradeoffs and unsupported native 3D use cases.
32
+ - Keep `docs-site` aligned with README examples and package limitations.
33
+ - Do not widen peer dependency or React Native support claims without updating
34
+ `docs/COMPATIBILITY.md` and verifying the relevant app matrix.
35
+
36
+ ## Checks
37
+
38
+ From this package directory:
39
+
40
+ ```bash
41
+ npm test
42
+ npm run typecheck
43
+ npm run pack:dry-run
44
+ ```
45
+
46
+ ## Publishing
47
+
48
+ - The npm package must include `AGENTS.md`, `llms.txt`, `docs`, and
49
+ `agent-skills`.
50
+ - GitHub Pages deploys from `docs-site` through
51
+ `.github/workflows/pages.yml`.
52
+ - Run `npm run pack:dry-run` and inspect the file list before release.
53
+ - Release tags use `v<version>`.
package/CHANGELOG.md ADDED
@@ -0,0 +1,67 @@
1
+ # Changelog
2
+
3
+ All notable changes to this package should be documented here.
4
+
5
+ This project uses semantic versioning. Versions below `1.0.0` may still change
6
+ minor APIs when the release notes call it out clearly.
7
+
8
+ ## 0.1.0 - 2026-05-31
9
+
10
+ Initial public release of `react-native-model-viewer-webview`.
11
+
12
+ ### Added
13
+
14
+ - Add `ModelViewerWebView`, a `react-native-webview` backed component for
15
+ rendering simple GLB and glTF previews through Google's `<model-viewer>` web
16
+ component.
17
+ - Add `modelSource` support for remote URLs, `data:` URIs, `file:` URIs, React
18
+ Native static asset module numbers from `require(...)`, and Expo-style
19
+ `{ localUri, uri }` asset objects.
20
+ - Keep `modelUri` as a string-only compatibility input for callers that already
21
+ have a resolved model URL.
22
+ - Add `htmlOptions` for common `<model-viewer>` controls, including
23
+ `cameraControls`, `autoRotate`, camera orbit bounds, exposure, shadow
24
+ intensity, background color, poster color, and additional attributes.
25
+ - Add status callbacks for model lifecycle handling:
26
+ `onStatus`, `onModelLoaded`, and `onModelError`.
27
+ - Add offline script loading hooks through `modelViewerScriptUrl` and
28
+ `modelViewerScript`.
29
+ - Export utility APIs for advanced consumers and tests:
30
+ `buildModelViewerHtml`, `parseModelViewerMessage`, and
31
+ `resolveModelSourceUri`.
32
+
33
+ ### Documentation
34
+
35
+ - Add README guidance for Expo and bare React Native installation, local GLB
36
+ Metro setup, offline script loading, and when to choose native 3D stacks
37
+ instead.
38
+ - Add `docs/HOW_IT_WORKS.md`, `docs/COMPATIBILITY.md`,
39
+ `docs/AGENT_USAGE.md`, and `docs/RELEASE.md`.
40
+ - Add `CONTRIBUTING.md`, `SECURITY.md`, `AGENTS.md`, `llms.txt`, and a portable
41
+ Agent Skill for AI-assisted package integration.
42
+ - Add a static GitHub Pages docs site with install instructions, examples,
43
+ direct answers for search/answer engines, use-case ideas, limitations, and
44
+ package-fit guidance.
45
+
46
+ ### Maintenance
47
+
48
+ - Add Node test coverage for model source resolution, generated model-viewer
49
+ HTML, WebView status parsing, package exports, agent assets, docs site
50
+ metadata, and GitHub Pages workflow configuration.
51
+ - Add TypeScript source checking and `npm pack --dry-run` verification through
52
+ `npm run check`.
53
+ - Add GitHub Actions workflows for package CI, npm publishing, and GitHub Pages
54
+ deployment.
55
+
56
+ ### Known Limitations
57
+
58
+ - `react-native-webview` is a peer dependency and must be installed by the
59
+ consuming app.
60
+ - This package renders through WebView; it is not a native 3D renderer and is
61
+ not intended for shaders, physics, AR, complex scenes, or game-like
62
+ interaction.
63
+ - React Native versions below `0.72` are unsupported.
64
+ - Local `.glb` and `.gltf` imports still depend on the consuming app's Metro
65
+ asset configuration.
66
+ - I am yet to test this on iOS. I will mark iOS as verified after I run a
67
+ WKWebView smoke test on an iOS device or simulator.
@@ -0,0 +1,79 @@
1
+ # Contributing
2
+
3
+ Thanks for helping improve `react-native-model-viewer-webview`.
4
+
5
+ This package has a deliberately small scope: show GLB/glTF assets in React
6
+ Native through WebView-backed `<model-viewer>` ergonomics. It should stay small,
7
+ honest, and easy to reason about.
8
+
9
+ ## Ground Rules
10
+
11
+ - Do not position this package as a replacement for Filament, React Three Fiber,
12
+ Three.js, or Expo GLView.
13
+ - Keep the public API boring and explicit.
14
+ - Prefer compatibility and clear failure modes over clever abstractions.
15
+ - Add tests for utility behavior before changing implementation.
16
+ - Keep `src` and `dist` in sync.
17
+ - Document platform limitations instead of hiding them.
18
+
19
+ ## Local Checks
20
+
21
+ From the package directory:
22
+
23
+ ```bash
24
+ npm install
25
+ npm run check
26
+ ```
27
+
28
+ The package tests run against `dist`, because `dist` is what npm consumers load.
29
+ If you change `src`, update `dist` before running tests.
30
+
31
+ From the app directory:
32
+
33
+ ```bash
34
+ cd ../../mobile
35
+ npm install
36
+ npx tsc --noEmit
37
+ npm run lint
38
+ ```
39
+
40
+ The mobile checks verify the local `file:` dependency and Metro/TypeScript
41
+ integration used by this repository's Expo app.
42
+
43
+ ## Test Coverage Expectations
44
+
45
+ Required for changes to:
46
+
47
+ - HTML generation: escaping, attributes, script loading, and safe defaults.
48
+ - Model source resolution: string URLs, data/file URLs, `localUri`, `uri`, and
49
+ React Native asset module numbers.
50
+ - Status parsing: load events, error events, malformed payloads, and raw WebView
51
+ messages.
52
+ - Public exports: avoid requiring React Native peers when a consumer imports only
53
+ utility functions.
54
+
55
+ Component rendering tests are intentionally not faked with shallow mocks right
56
+ now. WebView rendering confidence should come from real device smoke tests.
57
+
58
+ ## Pull Request Checklist
59
+
60
+ - [ ] README updated when public behavior changes.
61
+ - [ ] `docs/COMPATIBILITY.md` updated when peer ranges or platform claims change.
62
+ - [ ] `CHANGELOG.md` updated under `Unreleased`.
63
+ - [ ] `npm test` passes in the package.
64
+ - [ ] `npm run typecheck` passes in the package after installing package deps.
65
+ - [ ] `npm run pack:dry-run` shows only intended files.
66
+ - [ ] Mobile integration checks pass from `mobile`.
67
+ - [ ] Android device smoke test completed for rendering changes.
68
+ - [ ] iOS device smoke test completed before claiming iOS support.
69
+
70
+ ## Release Contributions
71
+
72
+ Release PRs should include:
73
+
74
+ - version bump in `package.json`
75
+ - `CHANGELOG.md` entry moved from `Unreleased` to the release version
76
+ - fresh package dry-run output reviewed
77
+ - Git tag created only after CI is green
78
+
79
+ See [`docs/RELEASE.md`](./docs/RELEASE.md) for the full release procedure.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 react-native-model-viewer-webview contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,288 @@
1
+ # react-native-model-viewer-webview
2
+
3
+ A tiny React Native and Expo wrapper around Google's `<model-viewer>` web
4
+ component, rendered inside `react-native-webview`.
5
+
6
+ It is for simple GLB/glTF previews, not for building a native 3D engine.
7
+
8
+ ## Why This Exists
9
+
10
+ Use this package when your product requirement sounds like:
11
+
12
+ > "Show this `.glb` in a React Native screen with orbit controls, auto-rotate,
13
+ > lighting, and load/error callbacks."
14
+
15
+ For that job, setting up Filament, Three.js, React Three Fiber, render loops,
16
+ lights, cameras, loaders, and Metro asset details can be more machinery than the
17
+ screen deserves. This package gives you the WebView version of the web
18
+ `<model-viewer>` ergonomics.
19
+
20
+ ## When To Use It
21
+
22
+ - Product cards or vehicle previews.
23
+ - Marketplace listings with one inspectable 3D asset.
24
+ - Expo demos and prototypes where WebView rendering is acceptable.
25
+ - Apps that already use `<model-viewer>` on the web and want similar mobile
26
+ behavior.
27
+ - Teams that want a small dependency and do not need full scene control.
28
+
29
+ ## When Not To Use It
30
+
31
+ Use a native 3D stack instead when you need:
32
+
33
+ - native GPU rendering as the core experience
34
+ - custom materials, shaders, lights, or post-processing
35
+ - physics, collision, skeletal animation control, or multi-object scenes
36
+ - precise frame timing or heavy interaction
37
+ - AR or game-like rendering
38
+
39
+ Good alternatives:
40
+
41
+ - [`react-native-filament`](https://margelo.github.io/react-native-filament/)
42
+ for a native mobile rendering engine.
43
+ - [`@react-three/fiber/native`](https://r3f.docs.pmnd.rs/getting-started/installation#react-native)
44
+ for the Three.js ecosystem on React Native.
45
+ - Expo [`GLView`](https://docs.expo.dev/versions/latest/sdk/gl-view/) when you
46
+ want lower-level WebGL control.
47
+
48
+ ## Install
49
+
50
+ Expo:
51
+
52
+ ```bash
53
+ npx expo install react-native-model-viewer-webview react-native-webview
54
+ ```
55
+
56
+ Bare React Native:
57
+
58
+ ```bash
59
+ npm install react-native-model-viewer-webview react-native-webview
60
+ ```
61
+
62
+ If your app already has a compatible `react-native-webview`, install only
63
+ `react-native-model-viewer-webview`. Bare React Native apps should follow
64
+ `react-native-webview`'s native setup instructions.
65
+
66
+ ## Quick Start
67
+
68
+ ```tsx
69
+ import { ModelViewerWebView } from "react-native-model-viewer-webview";
70
+
71
+ export function CarPreview() {
72
+ return (
73
+ <ModelViewerWebView
74
+ modelSource="https://example.com/car.glb"
75
+ style={{ height: 320 }}
76
+ htmlOptions={{
77
+ autoRotate: true,
78
+ cameraControls: true,
79
+ cameraOrbit: "35deg 66deg 6.2m",
80
+ disablePan: true,
81
+ exposure: 1.05,
82
+ shadowIntensity: 0.35,
83
+ }}
84
+ onModelLoaded={(status) => {
85
+ console.log(status.message);
86
+ }}
87
+ onModelError={(status) => {
88
+ console.warn(status.message);
89
+ }}
90
+ />
91
+ );
92
+ }
93
+ ```
94
+
95
+ ## Model Sources
96
+
97
+ `modelSource` accepts:
98
+
99
+ - a remote URL
100
+ - a `data:` URI
101
+ - a `file:` URI
102
+ - a React Native static asset module number from `require(...)`
103
+ - an object with `localUri` and/or `uri`, such as an Expo asset
104
+
105
+ ```tsx
106
+ <ModelViewerWebView
107
+ modelSource={require("./assets/car.glb")}
108
+ style={{ height: 320 }}
109
+ />
110
+ ```
111
+
112
+ ```tsx
113
+ import { Asset } from "expo-asset";
114
+ import { ModelViewerWebView } from "react-native-model-viewer-webview";
115
+
116
+ const carModel = Asset.fromModule(require("./assets/car.glb"));
117
+ await carModel.downloadAsync();
118
+
119
+ <ModelViewerWebView modelSource={carModel} style={{ height: 320 }} />;
120
+ ```
121
+
122
+ `localUri` is preferred over `uri` when both exist. `modelUri` is still accepted
123
+ as a string-only compatibility prop.
124
+
125
+ ## Metro Setup For Local GLB Files
126
+
127
+ If your app imports `.glb` files, add `glb` to Metro's asset extensions.
128
+
129
+ Expo example:
130
+
131
+ ```js
132
+ const { getDefaultConfig } = require("expo/metro-config");
133
+
134
+ const config = getDefaultConfig(__dirname);
135
+
136
+ config.resolver.assetExts = [
137
+ ...config.resolver.assetExts,
138
+ "glb",
139
+ "gltf",
140
+ ];
141
+
142
+ module.exports = config;
143
+ ```
144
+
145
+ ## Troubleshooting Local Package Development
146
+
147
+ If you test this package through `file:../path`, `npm link`, or a monorepo
148
+ symlink, make sure Metro resolves peer dependencies from the app, not from this
149
+ package's local `node_modules`.
150
+
151
+ Duplicate React copies can cause this error:
152
+
153
+ ```text
154
+ Invalid hook call. Hooks can only be called inside of the body of a function component.
155
+ ```
156
+
157
+ In that setup, alias `react`, `react-native`, and `react-native-webview` to the
158
+ app's `node_modules`, and exclude any package-local dev copies of those peers
159
+ from Metro's file map.
160
+
161
+ ## Offline Script Loading
162
+
163
+ By default, the generated WebView HTML loads `<model-viewer>` from Google's CDN.
164
+ That keeps the package tiny, but it means the viewer needs network access the
165
+ first time the WebView loads.
166
+
167
+ For offline apps, pass your own script URL:
168
+
169
+ ```tsx
170
+ <ModelViewerWebView
171
+ modelSource={require("./assets/car.glb")}
172
+ htmlOptions={{
173
+ modelViewerScriptUrl: "file:///path/to/model-viewer.min.js",
174
+ }}
175
+ />
176
+ ```
177
+
178
+ Or pass an inline module script if your build already bundles the source:
179
+
180
+ ```tsx
181
+ <ModelViewerWebView
182
+ modelSource="https://example.com/car.glb"
183
+ htmlOptions={{
184
+ modelViewerScript: bundledModelViewerSource,
185
+ }}
186
+ />
187
+ ```
188
+
189
+ ## Props
190
+
191
+ `ModelViewerWebView` accepts all `react-native-webview` props except `source` and
192
+ `onMessage`, which are managed by the package.
193
+
194
+ Important props:
195
+
196
+ | Prop | Type | Description |
197
+ | --- | --- | --- |
198
+ | `modelSource` | `string \| number \| { localUri?: string; uri?: string }` | Preferred model input. |
199
+ | `modelUri` | `string` | String-only compatibility input. |
200
+ | `htmlOptions` | `ModelViewerHtmlOptions` | Controls `<model-viewer>` attributes and script loading. |
201
+ | `onStatus` | `(status, event) => void` | Receives every status message from the WebView. |
202
+ | `onModelLoaded` | `(status, event) => void` | Fires when `<model-viewer>` emits `load`. |
203
+ | `onModelError` | `(status, event) => void` | Fires when page or model loading fails. |
204
+ | `webViewBaseUrl` | `string` | Base URL used for the generated HTML. Defaults to `https://localhost/`. |
205
+
206
+ Useful `htmlOptions`:
207
+
208
+ | Option | Description |
209
+ | --- | --- |
210
+ | `autoRotate` | Adds `auto-rotate`. |
211
+ | `cameraControls` | Adds `camera-controls`; defaults to `true`. |
212
+ | `cameraOrbit` | Sets the initial orbit. |
213
+ | `minCameraOrbit` / `maxCameraOrbit` | Bounds zoom/orbit. |
214
+ | `disablePan` | Adds `disable-pan`. |
215
+ | `exposure` / `shadowIntensity` | Basic visual tuning. |
216
+ | `backgroundColor` / `posterColor` | Controls the WebView and poster background. |
217
+ | `additionalAttributes` | Adds extra `<model-viewer>` attributes. |
218
+ | `modelViewerScriptUrl` | Loads a custom `<model-viewer>` script URL. |
219
+ | `modelViewerScript` | Inlines a custom module script. |
220
+
221
+ ## Example
222
+
223
+ See [`example/App.tsx`](./example/App.tsx) for a minimal Expo screen.
224
+
225
+ ## More Documentation
226
+
227
+ - [Public docs site](https://adityabhattad2021.github.io/react-native-model-viewer-webview/)
228
+ - [How it works](./docs/HOW_IT_WORKS.md)
229
+ - [Compatibility and support policy](./docs/COMPATIBILITY.md)
230
+ - [AI agent usage](./docs/AGENT_USAGE.md)
231
+ - [Release and maintenance guide](./docs/RELEASE.md)
232
+ - [Contributing](./CONTRIBUTING.md)
233
+ - [Security policy](./SECURITY.md)
234
+ - [Changelog](./CHANGELOG.md)
235
+
236
+ ## AI Agent Support
237
+
238
+ The package includes agent-facing docs so coding agents can integrate it without
239
+ guessing:
240
+
241
+ - [`AGENTS.md`](./AGENTS.md) for package-level agent instructions
242
+ - [`llms.txt`](./llms.txt) as a compact docs index
243
+ - [`agent-skills/react-native-model-viewer-webview/SKILL.md`](./agent-skills/react-native-model-viewer-webview/SKILL.md)
244
+ for skills-compatible agents
245
+
246
+ Claude Code can use the skill after copying it to
247
+ `~/.claude/skills/react-native-model-viewer-webview/SKILL.md` or a project-local
248
+ `.claude/skills/react-native-model-viewer-webview/SKILL.md`.
249
+ Installing from npm does not automatically install a skill into an agent client.
250
+ See [AI agent usage](./docs/AGENT_USAGE.md) for copy/symlink instructions.
251
+
252
+ ## Development
253
+
254
+ ```bash
255
+ npm test
256
+ npm run typecheck
257
+ npm run pack:dry-run
258
+ ```
259
+
260
+ The test suite runs against `dist` because that is the code npm consumers load.
261
+ When changing `src`, keep `dist` in sync before running the package tests.
262
+
263
+ ## Tradeoffs
264
+
265
+ This package renders through WebView, so it inherits WebView tradeoffs:
266
+
267
+ - startup cost is higher than a plain native view
268
+ - WebView memory use can matter in long lists
269
+ - native gestures and WebView gestures may need tuning in complex screens
270
+ - rendering behavior follows the platform WebView
271
+
272
+ The upside is simplicity. For many product preview surfaces, that is the whole
273
+ point.
274
+
275
+ ## Pre-Publish Checklist
276
+
277
+ Before publishing a release:
278
+
279
+ - test a remote `.glb` on Android
280
+ - test a bundled `.glb` on Android
281
+ - test at least one iOS physical device if iOS support is claimed
282
+ - test a no-network/offline script setup if documenting offline support
283
+ - run `npm pack --dry-run`
284
+ - keep the README positioning honest: this is not a Filament/R3F replacement
285
+
286
+ ## License
287
+
288
+ MIT
package/SECURITY.md ADDED
@@ -0,0 +1,31 @@
1
+ # Security Policy
2
+
3
+ ## Supported Versions
4
+
5
+ Security fixes are applied to the latest published minor version. Before `1.0.0`,
6
+ only the latest published version is supported.
7
+
8
+ ## Reporting A Vulnerability
9
+
10
+ Do not open public issues for vulnerabilities.
11
+
12
+ Report privately through the repository owner's preferred security channel. If
13
+ GitHub private vulnerability reporting is enabled, use that. Otherwise, contact
14
+ the maintainer directly and include:
15
+
16
+ - package version
17
+ - affected platform and React Native version
18
+ - reproduction steps
19
+ - impact
20
+ - whether the issue requires a malicious model file, malicious model URL, or
21
+ malicious app input
22
+
23
+ ## Security Considerations
24
+
25
+ This package generates HTML and runs it inside `react-native-webview`.
26
+
27
+ - Treat untrusted model URLs as remote content.
28
+ - Prefer trusted domains or bundled assets for production apps.
29
+ - Avoid passing untrusted strings through `additionalAttributes`.
30
+ - Use offline script loading for apps that cannot rely on CDN availability.
31
+ - Keep `react-native-webview` updated in consuming apps.
@@ -0,0 +1,134 @@
1
+ ---
2
+ name: react-native-model-viewer-webview
3
+ description: Use when adding, configuring, debugging, or reviewing react-native-model-viewer-webview in a React Native or Expo app, especially for simple GLB/glTF model previews rendered with WebView instead of Filament, React Three Fiber, Three.js, or Expo GLView.
4
+ ---
5
+
6
+ # React Native Model Viewer WebView
7
+
8
+ Use this skill to help users integrate `react-native-model-viewer-webview`.
9
+
10
+ ## First Decision
11
+
12
+ Confirm the package is the right tool:
13
+
14
+ - Use it for simple GLB/glTF product previews, vehicle previews, marketplace cards, and demos where WebView rendering is acceptable.
15
+ - Recommend `react-native-filament`, `@react-three/fiber/native`, Three.js, or Expo GLView when the user needs native GPU rendering, custom shaders/materials, physics, AR, many scene objects, or game-like interaction.
16
+
17
+ Do not describe this package as a native 3D engine.
18
+
19
+ ## Install
20
+
21
+ Expo:
22
+
23
+ ```bash
24
+ npx expo install react-native-model-viewer-webview react-native-webview
25
+ ```
26
+
27
+ Bare React Native:
28
+
29
+ ```bash
30
+ npm install react-native-model-viewer-webview react-native-webview
31
+ ```
32
+
33
+ If the app already has a compatible `react-native-webview`, install only
34
+ `react-native-model-viewer-webview`. For bare React Native apps, follow
35
+ `react-native-webview` native setup.
36
+
37
+ ## Basic Usage
38
+
39
+ ```tsx
40
+ import { ModelViewerWebView } from "react-native-model-viewer-webview";
41
+
42
+ export function ProductModel() {
43
+ return (
44
+ <ModelViewerWebView
45
+ modelSource="https://example.com/model.glb"
46
+ style={{ height: 320 }}
47
+ htmlOptions={{
48
+ autoRotate: true,
49
+ cameraControls: true,
50
+ exposure: 1.05,
51
+ shadowIntensity: 0.35,
52
+ }}
53
+ />
54
+ );
55
+ }
56
+ ```
57
+
58
+ ## Local GLB Files
59
+
60
+ If the user imports local `.glb` or `.gltf` files, tell them to add those
61
+ extensions to Metro asset extensions.
62
+
63
+ Expo `metro.config.js`:
64
+
65
+ ```js
66
+ const { getDefaultConfig } = require("expo/metro-config");
67
+
68
+ const config = getDefaultConfig(__dirname);
69
+
70
+ config.resolver.assetExts = [
71
+ ...config.resolver.assetExts,
72
+ "glb",
73
+ "gltf",
74
+ ];
75
+
76
+ module.exports = config;
77
+ ```
78
+
79
+ Then:
80
+
81
+ ```tsx
82
+ <ModelViewerWebView modelSource={require("./assets/model.glb")} />
83
+ ```
84
+
85
+ ## Expo Asset Objects
86
+
87
+ ```tsx
88
+ import { Asset } from "expo-asset";
89
+ import { ModelViewerWebView } from "react-native-model-viewer-webview";
90
+
91
+ const model = Asset.fromModule(require("./assets/model.glb"));
92
+ await model.downloadAsync();
93
+
94
+ <ModelViewerWebView modelSource={model} />;
95
+ ```
96
+
97
+ ## Offline Apps
98
+
99
+ By default, `<model-viewer>` loads from Google's CDN. For offline apps, use:
100
+
101
+ ```tsx
102
+ <ModelViewerWebView
103
+ modelSource={require("./assets/model.glb")}
104
+ htmlOptions={{
105
+ modelViewerScriptUrl: "file:///path/to/model-viewer.min.js",
106
+ }}
107
+ />
108
+ ```
109
+
110
+ or:
111
+
112
+ ```tsx
113
+ <ModelViewerWebView
114
+ modelSource="https://example.com/model.glb"
115
+ htmlOptions={{
116
+ modelViewerScript: bundledModelViewerSource,
117
+ }}
118
+ />
119
+ ```
120
+
121
+ ## Debugging Checklist
122
+
123
+ When the model does not render:
124
+
125
+ 1. Verify the app has `react-native-webview` installed.
126
+ 2. For local files, verify Metro includes `glb` and `gltf`.
127
+ 3. Check whether `onModelError` receives a page or model error.
128
+ 4. Try a known remote GLB to separate asset-loading problems from WebView problems.
129
+ 5. Test on a real Android or iOS device before claiming platform support.
130
+ 6. If native rendering quality or performance is the issue, recommend Filament or React Three Fiber Native instead.
131
+
132
+ ## References
133
+
134
+ Read `references/api.md` when you need the package API surface.
@@ -0,0 +1,4 @@
1
+ interface:
2
+ display_name: "React Native Model Viewer WebView"
3
+ short_description: "Add simple GLB previews to React Native"
4
+ default_prompt: "Use $react-native-model-viewer-webview to add a simple GLB preview to my Expo screen."