aframe-babia-components
Version:
A data visualization set of components for A-Frame.
255 lines (226 loc) • 11 kB
HTML
<html>
<head>
<meta charset="utf-8">
<title>BabiaXR - Multiuser Babia-boats Demo</title>
<meta name="description" content="Babiaxr multiuser demo using babia-boats.">
</meta>
<!-- Aframe -->
<script src="https://aframe.io/releases/1.2.0/aframe.min.js"></script>
<script src="https://cdn.jsdelivr.net/gh/donmccurdy/aframe-extras@v6.1.0/dist/aframe-extras.min.js"></script>
<script
src="https://unpkg.com/aframe-environment-component@1.2.0/dist/aframe-environment-component.min.js"></script>
<script src="../../dist/aframe-babia-components.js"></script>
<!-- Mulituser -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/2.3.0/socket.io.slim.js"></script>
<script src="./easyrtc.js"></script>
<script src="https://unpkg.com/networked-aframe@^0.8.0/dist/networked-aframe.js"></script>
<!-- Gitlab Corner -->
<link rel="stylesheet" href="../assets/gitlab-corner.css">
</head>
<body>
<a-scene id="AframeScene" networked-scene="
room: multi_boats_selector;
adapter: easyrtc;
debug: true;
audio: true;
serverURL: https://f-l2108-pc02.aulas.etsit.urjc.es:49153/;
">
<a-assets>
<!-- Dummy asset to make the scene sync (WIP)-->
<img src="https://wallpapercave.com/wp/wp2345390.jpg?dummy=8484744">
<!-- Templates -->
<!-- Selector and navigator -->
<template id="selector-template">
<a-entity class="selector"></a-entity>
</template>
<!-- Camera -->
<template id="rig-template">
<a-entity class="rig"></a-entity>
</template>
<template id="camera-template">
<a-entity class="camera"></a-entity>
</template>
<template id="avatar-template">
<a-sphere class="avatar" networked-audio-source></a-sphere>
</template>
<template id="username-tag-template">
<a-text class="username-tag"></a-text>
</template>
</a-assets>
<!-- Environment -->
<a-entity environment="preset: yavapai" renderer="antialias: true"></a-entity>
<!-- Slider -->
<a-entity id="nav" babia-navigator position="6 1 1" rotation="0 0 0" scale="0.5 0.5 0.5"
></a-entity>
<!-- Querier -->
<a-entity id="querier" babia-queryjson="url: ../selector_boats/commits2.json;"></a-entity>
<!-- 3 Selector -->
<a-entity id="selector" networked="template:#selector-template; networkId:selector; persistent: true; owner: scene"
babia-selector="from: querier; controller: nav"></a-entity>
<!-- Treebuilder -->
<a-entity id="treebuilder" babia-treebuilder="field: path; split_by: /; from: selector"></a-entity>
<!-- Boats Visualizer -->
<a-entity id="boats" babia-boats="from: treebuilder; area: area"
position="1 0.1 0" scale="0.3 0.3 0.3"></a-entity>
<!-- Camera -->
<a-entity id="rig" position="4 1.6 3" rotation="0 0 0"
networked="template:#rig-template; attachTemplateToLocal:false">
<a-entity id="camera" camera look-controls wasd-controls="fly: false"
networked="template:#camera-template;attachTemplateToLocal:false;">
<a-sphere id="avatar" color="#D3FFE4" scale="0.25 0.25 0.25"
networked="template:#avatar-template;attachTemplateToLocal:false;">
<a-text id="username-tag"
networked="template:#username-tag-template; attachTemplateToLocal:false"
position="-0.5 1.5 0" width="5" color="black" value="username"></a-text>
</a-sphere>
</a-entity>
<!-- Hand Controls -->
<a-entity id="leftHand" interaction-hands aabb-collider="objects: .grabbable"
hand-controls="hand: left; handModelStyle: highPoly" mixin="touch"
teleport-controls="cameraRig: #cameraRig; teleportOrigin: #head; collisionEntities: .environmentGround;
hitCylinderColor: #ff3468; curveHitColor: #ff3468; curveMissColor: #333333; curveLineWidth: 0.01; button: grip">
<a-entity id="tooltip_trigger_L" class="tips" tooltip="text: Grab; width: 0.07; height: 0.03; targetPosition: 0.002 -0.02 -0.014; lineHorizontalAlign: right; rotation: -90 0 0; src:assets/tooltip.png"
position="-0.09 -0.04 -0.08"></a-entity>
<a-entity id="tooltip_grip_L" class="tips" tooltip="text: Teleport; width: 0.08; height: 0.04; targetPosition: 0.006 -0.008 0.033; rotation: -90 0 0; src:assets/tooltip.png"
position="0.085 -0.01 0.07"></a-entity>
</a-entity>
<a-entity id="rightHand" interaction-hands aabb-collider="objects: .grabbable"
hand-controls="hand: right; handModelStyle: highPoly" mixin="touch"
laser-controls="hand: right" raycaster="objects: .babiaxraycasterclass, #audio_button">
<a-entity id="tooltip_trigger_R" class="tips" tooltip="text: Click/Grab ; width: 0.07; height: 0.03; targetPosition: 0.005 -0.02 -0.014; lineHorizontalAlign: left; rotation: -90 0 0; src:assets/tooltip.png"
position="0.09 -0.04 -0.08"></a-entity>
<a-entity id="tooltip_grip_R" class="tips" tooltip="text: Open/Close \nTips; width: 0.08; height: 0.04; targetPosition: -0.006 -0.008 0.033; rotation: -90 0 0; lineHorizontalAlign: right; src:assets/tooltip.png"
position="-0.085 -0.01 0.07"></a-entity>
</a-entity>
<a-entity id="cursor" cursor="rayOrigin:mouse" raycaster="objects: .babiaxraycasterclass, #audio_button">
</a-entity>
</a-entity>
<!-- Audio Button -->
<a-plane id="audio_button" position="7 2.5 0" rotation="0 0 0" height="0.5" width="1.5" color="#000" scale="0.5 0.5 0.5">
<a-text id="audio_label" value="Stop Audio" color="#fff" width="4" position="-0.5 0 0" rotation="0 0 0">
</a-text>
</a-plane>
</a-scene>
<script>
/* Camera */
let rig = document.getElementById('rig')
let avatar = document.getElementById('avatar')
let usernameTag = document.getElementById('username-tag')
let color = getRandomColor();
usernameTag.setAttribute('value', color)
avatar.setAttribute('color', color)
function getRandomColor() {
var digits = '0123456789ABCDEF';
var color = '#';
for (var i = 0; i < 6; i++) {
color += digits[Math.floor(Math.random() * 16)];
}
return color;
}
/* Audio */
let audioButton = document.getElementById('audio_button');
let audioLabel = document.getElementById('audio_label');
audioButton.addEventListener('click', function (event) {
if (audioLabel.getAttribute('value') === 'Stop Audio') {
stopAudio();
} else {
turnOnAudio();
}
});
function turnOnAudio() {
NAF.connection.adapter.enableMicrophone(true);
audioButton.setAttribute('color', '#000');
audioLabel.setAttribute('color', '#fff');
audioLabel.setAttribute('value', 'Stop Audio');
}
function stopAudio() {
NAF.connection.adapter.enableMicrophone(false);
audioButton.setAttribute('color', '#fff');
audioLabel.setAttribute('color', '#000');
audioLabel.setAttribute('value', 'Turn on Audio');
}
/* Update avatar height in VR */
document.addEventListener('controllerconnected', (event) => {
rig.setAttribute('position', { x: 4, y: 1.6, z: 3 })
})
</script>
<script>
NAF.schemas.add({
template: '#selector-template',
components: [
'babia-selector'
]
})
// Avatar
NAF.schemas.add({
template: '#rig-template',
components: [
'position',
'rotation'
]
});
NAF.schemas.add({
template: '#camera-template',
components: [
'position',
'rotation'
]
});
NAF.schemas.add({
template: '#avatar-template',
components: [
'position',
'rotation',
'color',
'scale'
]
});
NAF.schemas.add({
template: '#username-tag-template',
components: [
'value',
'color',
'width',
'position',
'rotation'
]
});
</script>
<!-- GITLAB CORNER-->
<div class="gitlab-corner-wrapper"><a
href="https://gitlab.com/babiaxr/aframe-babia-components/-/blob/master/examples/multi_boats/with_selector"
class="gitlab-corner" aria-label="View source on GitLab"><svg id="logo_art" data-name="logo art"
xmlns="http://www.w3.org/2000/svg" viewBox="0 0 586 559">
<g id="g44">
<path id="path46" class="cls-1"
d="M461.17,301.83l-18.91-58.12L404.84,128.43a6.47,6.47,0,0,0-12.27,0L355.15,243.64H230.82L193.4,128.43a6.46,6.46,0,0,0-12.26,0L143.78,243.64l-18.91,58.19a12.88,12.88,0,0,0,4.66,14.39L293,435,456.44,316.22a12.9,12.9,0,0,0,4.73-14.39" />
</g>
<g id="g48">
<path id="path50" class="cls-2" d="M293,434.91h0l62.16-191.28H230.87L293,434.91Z" />
</g>
<g id="g56">
<path id="path58" class="cls-1" d="M293,434.91,230.82,243.63h-87L293,434.91Z" />
</g>
<g id="g64">
<path id="path66" class="cls-3"
d="M143.75,243.69h0l-18.91,58.12a12.88,12.88,0,0,0,4.66,14.39L293,435,143.75,243.69Z" />
</g>
<g id="g72">
<path id="path74" class="cls-2"
d="M143.78,243.69h87.11L193.4,128.49a6.47,6.47,0,0,0-12.27,0l-37.35,115.2Z" />
</g>
<g id="g76">
<path id="path78" class="cls-1" d="M293,434.91l62.16-191.28H442.3L293,434.91Z" />
</g>
<g id="g80">
<path id="path82" class="cls-3"
d="M442.24,243.69h0l18.91,58.12a12.85,12.85,0,0,1-4.66,14.39L293,434.91l149.2-191.22Z" />
</g>
<g id="g84">
<path id="path86" class="cls-2"
d="M442.28,243.69h-87.1l37.42-115.2a6.46,6.46,0,0,1,12.26,0l37.42,115.2Z" />
</g>
</svg></a></div>
</body>
</html>