networked-aframe
Version:
A web framework for building multi-user virtual reality experiences.
94 lines (85 loc) • 3.35 kB
HTML
<html>
<head>
<meta charset="utf-8" />
<title>Basic AR Example — Networked-Aframe</title>
<meta name="description" content="Basic AR Example — Networked-Aframe" />
<script src="https://aframe.io/releases/1.6.0/aframe.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/4.8.1/socket.io.min.js"></script>
<script src="/easyrtc/easyrtc.js"></script>
<script src="/dist/networked-aframe.js"></script>
<script>
// see issue https://github.com/networked-aframe/networked-aframe/issues/267
NAF.schemas.getComponentsOriginal = NAF.schemas.getComponents;
NAF.schemas.getComponents = (template) => {
if (!NAF.schemas.hasTemplate('#avatar-template')) {
NAF.schemas.add({
template: '#avatar-template',
components: [
{
component: 'position',
requiresNetworkUpdate: NAF.utils.vectorRequiresUpdate(0.001)
},
{
component: 'rotation',
requiresNetworkUpdate: NAF.utils.vectorRequiresUpdate(0.5)
},
{
selector: '.head',
component: 'material',
property: 'color'
}
]
});
}
const components = NAF.schemas.getComponentsOriginal(template);
return components;
};
</script>
<!-- AR -->
<script src="https://rawgit.com/jeromeetienne/ar.js/master/aframe/build/aframe-ar.js"></script>
<script>
THREEx.ArToolkitContext.baseURL = 'https://rawgit.com/jeromeetienne/ar.js/master/three.js/';
</script>
<script src="https://cdn.jsdelivr.net/npm/aframe-randomizer-components@3.0.2/dist/aframe-randomizer-components.min.js"></script>
<script src="js/spawn-in-circle.component.js"></script>
<script>
function onARConnect() {
console.log('AR Client Connected');
}
</script>
</head>
<body>
<a-scene
artoolkit="sourceType: webcam"
network-scene="
room: basic;
debug: true;
onConnect: onARConnect;
"
renderer="physicallyCorrectLights: true;"
>
<a-assets>
<!-- Templates -->
<!-- Avatar -->
<template id="avatar-template">
<a-entity class="avatar">
<a-sphere class="head" color="#5985ff" scale="0.45 0.5 0.4" random-color></a-sphere>
<a-entity class="face" position="0 0.05 0">
<a-sphere class="eye" color="#efefef" position="0.16 0.1 -0.35" scale="0.12 0.12 0.12">
<a-sphere class="pupil" color="#000" position="0 0 -1" scale="0.2 0.2 0.2"></a-sphere>
</a-sphere>
<a-sphere class="eye" color="#efefef" position="-0.16 0.1 -0.35" scale="0.12 0.12 0.12">
<a-sphere class="pupil" color="#000" position="0 0 -1" scale="0.2 0.2 0.2"></a-sphere>
</a-sphere>
</a-entity>
</a-entity>
</template>
<!-- /Templates -->
</a-assets>
<a-entity light="color: #ccccff; intensity: 1; type: ambient;" visible=""></a-entity>
<a-entity light="color: #ffaaff; intensity: 1.5" position="5 5 5"></a-entity>
<a-marker-camera preset="hiro"></a-marker-camera>
</a-scene>
</body>
</html>