Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
722a9aa
Use global polyfillconfig if available
benallfree Feb 12, 2020
7f8ba6e
Create global aframeConfig
benallfree Feb 13, 2020
62d12d3
Revert "Create global aframeConfig"
benallfree Feb 15, 2020
aa23290
Revert "Use global polyfillconfig if available"
benallfree Feb 15, 2020
73549cc
Updated cordova compatibility
benallfree Feb 15, 2020
63054ab
Add Cordova check for CSS
benallfree Feb 19, 2020
1610a14
Cordova-specific CSS and disable mobile wake lock (nosleep)
benallfree Feb 20, 2020
90f4f5d
Remove cordova.css
benallfree Feb 21, 2020
a84c0f7
Readme update
benallfree Feb 22, 2020
c75f2c0
More readme updates
benallfree Feb 22, 2020
79ad4bc
Move package metadata definition
benallfree Feb 23, 2020
0a09879
Config file update
benallfree Mar 6, 2020
0b492a9
Use existing deepMerge
benallfree Mar 6, 2020
9302179
Merge branch 'upstream-master' into cordova-compat
benallfree Mar 6, 2020
f59f330
Revert doc version mods
benallfree Mar 6, 2020
e30ab71
Remove extra logging
benallfree Mar 6, 2020
8cb2c25
Remove debug switches
benallfree Mar 6, 2020
a3cca92
Cordova docs update
benallfree Mar 7, 2020
e7e75fb
deepAssign bugfix
benallfree Mar 8, 2020
feefbc2
Updates
benallfree Mar 8, 2020
be94258
Revert aggressive changes
benallfree Mar 8, 2020
ac3820f
Docs udate
benallfree Mar 8, 2020
f0d6e43
Remove warning
benallfree Mar 8, 2020
2b62b74
Remove style mods
benallfree Mar 8, 2020
f17ace5
readme
benallfree Mar 8, 2020
0e4bc7d
restore bypass
benallfree Mar 8, 2020
4869d62
XHR update
benallfree Mar 8, 2020
044bfaa
Readme update
benallfree Mar 8, 2020
20a483c
Readme update
benallfree Mar 9, 2020
e1dce63
Readme fix
benallfree Mar 9, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 85 additions & 0 deletions docs/introduction/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,3 +123,88 @@ A-Frame. `angle` can initialize a scene template with a single command:
```sh
npm install -g angle && angle initscene
```

## Cordova Development

A-Frame is compatible with Cordova apps. Currently, network access is required as A-Frame and its dependencies load assets from CDN sources.

[Cordova A-Frame Showcase App (demo)](https://github.com/benallfree/cordova-aframe-showcase)

### Installation

Install the [cordova-plugin-xhr-local-file](https://github.com/benallfree/cordova-plugin-xhr-local-file) plugin. This is needed because
Cordova runs from `file://`, and XHR requests to local `file://` assets (JSON fonts, 3D models, etc) will fail without this plugin.

```bash
cordova plugin add cordova-plugin-xhr-local-file
```

In your `index.html`, adjust as follows:

```html
<head>
<meta
http-equiv="Content-Security-Policy"
content="
default-src
'self'
data:
gap:
https://ssl.gstatic.com
'unsafe-eval'
https://cdn.aframe.io <-- required
https://dpdb.webvr.rocks <-- required
https://fonts.googleapis.com <-- required
https://cdn.jsdelivr.net <-- your choice, see below
;
style-src
'self'
'unsafe-inline'
;
media-src *;
img-src
'self'
data: <-- required
content: <-- required
blob: <-- required
;
"
/>
...
<script src="https://cdn.jsdelivr.net/npm/aframe@1.0.4/dist/aframe-master.min.js"></script>
<script id='my-scene' type="text/html">
...your scene goes here...
</script>
<script>
document.addEventListener('deviceready', function() {
// After the 'deviceready' event, Cordova is ready for you to render your A-Frame scene.
document.getElementById('scene-root').innerHTML = document.getElementById('my-scene').innerHTML
})
</script>
</head>
<body>
<div id='scene-root'></div>
...
</body>
```

### Discussion


#### deviceready
The most important difference between a browser environment and a Cordova environment is waiting for the `deviceready` event
before rendering your scene.

The sample above shows a pure DOM+JS approach, but you can also use a framework like React:

```javascript
document.addEventListener('deviceready', () => {
ReactDOM.render(<Root />, document.getElementById('root'))
})
```

#### Layout

Depending on your target device, you may find that A-Frame's default CSS causes certain buttons and controls to appear out of
position or too close to the edge of the phone screen. Supply your own CSS overrides to adjust positioning to fit
the target device.
5 changes: 3 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ if (!window.hasNativeWebXRImplementation && !window.hasNativeWebVRImplementation
var polyfillConfig = {
BUFFER_SCALE: bufferScale,
CARDBOARD_UI_DISABLED: true,
ROTATE_INSTRUCTIONS_DISABLED: true
ROTATE_INSTRUCTIONS_DISABLED: true,
MOBILE_WAKE_LOCK: !!window.cordova
};
window.webvrpolyfill = new WebVRPolyfill(polyfillConfig);
}
Expand All @@ -43,7 +44,7 @@ if (window.document.currentScript && window.document.currentScript.parentNode !=
}

// Error if not using a server.
if (window.location.protocol === 'file:') {
if (!window.cordova && window.location.protocol === 'file:') {
error(
'This HTML file is currently being served via the file:// protocol. ' +
'Assets, textures, and models WILL NOT WORK due to cross-origin policy! ' +
Expand Down