Skip to content

Instantly share code, notes, and snippets.

@califat
Forked from anonymous/index.html
Created April 20, 2017 13:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save califat/b9b77197805efc33110261a3ee2e1914 to your computer and use it in GitHub Desktop.
Save califat/b9b77197805efc33110261a3ee2e1914 to your computer and use it in GitHub Desktop.
Virtual Reality video plus links
<head>
<meta charset="utf-8">
<title>360&deg; Image Gallery</title>
<meta name="description" content="360&deg; Image Gallery - A-Frame">
<script src="https://rawgit.com/aframevr/aframe/917c06889ee1f3f79b7b1bbd9eab9815f9512503/dist/aframe.min.js"></script>
<script src="https://npmcdn.com/aframe-animation-component@3.0.1"></script>
<script src="https://npmcdn.com/aframe-event-set-component@3.0.1"></script>
<script src="https://npmcdn.com/aframe-layout-component@3.0.1"></script>
<script src="https://npmcdn.com/aframe-template-component@3.0.1"></script>
<script src="https://rawgit.com/aframevr/aframe/master/dist/aframe.min.js"></script>
<script src="https://unpkg.com/aframe-video-controls@0.2.1"></script>
<script>
var myRotation = {};
myRotation.myx = 0;
myRotation.myy = 0;
myRotation.myz = 0;
jQuery.getScript("https://aframe.io/releases/0.3.0/aframe.min.js", function(data, status, jqxhr) {
/*
do something now that the script is loaded and code has been executed
*/
$('#myAframe').html( "\
<a-scene>\
<a-assets>\
<img id='my360img' src='https://dl.dropboxusercontent.com/u/45973806/_Project/_9NowVRLounge/VRLounge_Aframe/images/9now_bg.jpg'>\
<img id='rail1img' src='https://dl.dropboxusercontent.com/u/45973806/_Project/_9NowVRLounge/VRLounge_Aframe/images/rail1.png' crossorigin='anonymous'>\
<img id='logoVR' src='https://dl.dropboxusercontent.com/u/45973806/_Project/_9NowVRLounge/VRLounge_Aframe/images/9nowVRLogo.png' crossorigin='anonymous'>\
<img id='my360img' src='http://4.bp.blogspot.com/-yfcJ9QhZ6EE/VZpKaZDHgaI/AAAAAAAADqw/k4pC1NSgXrY/s1600/railway-track-1920x965.jpg' crossorigin='anonymous'>\
<img id='watchnowimg' src='https://dl.dropboxusercontent.com/u/45973806/_Project/_9NowVRLounge/VRLounge_Aframe/images/watchnow.png' crossorigin='anonymous''>\
</a-assets>\
<a-sky id='my360' src='#my360img' rotation='0 0 0'></a-sky>\
<a-curvedimage id='panel1' src='#rail1img' radius='2' theta-length='200' height='1' rotation='0 0 0' scale='1 1 1' position='0 1 0'></a-curvedimage>\
<a-image id='logo' src='#logoVR' width='1' height='0.4' opacity='0.75' position='-2 2 -2' scale='1 1 1'>\
<a-animation attribute='scale' from='1 0 1' to='1 1 1' delay='1500' dur='200' fill='both' easing='ease-out'></a-animation>\
<a-animation attribute='position' from='-1 0 -2' to='-1.2 2.3 -2' delay='1000' dur='1000' fill='both' easing='ease-out'></a-animation>\
</a-image>\
<a-image id='watchnow' src='#watchnowimg' width='2.6' height='1.4' opacity='0' position='1 2.3 -2' scale='1 1 1'>\
<a-animation attribute='opacity' from='0' to='1' delay='1000' dur='1000' fill='both' easing='ease-out'></a-animation>\
</a-image>\
<a-light type='directional' color='#fff' intensity='0.2' position='0 0 -10'></a-light>\
<a-light type='ambient' color='#ccc'></a-light>\
<a-camera id='player' position='0 0 0'></a-camera>\
</a-scene>");
TweenMax.to(myRotation,600,{myx:0, myy:1440, myz:0, onUpdate:updateHandie});
function updateHandie()
{
document.getElementById('panel1').setAttribute("rotation", ""+myRotation.myx+ " "+myRotation.myy+ " "+ myRotation.myz +"");
}
});
</script>
</head>
<body>
<a-scene>
<a-entity position="-0 -5 -4" mixin="f_point" id="finish1"></a-entity>
<a-assets>
<img id="video-pause-image" crossorigin src="https://cdn.aframe.io/360-video-boilerplate/img/pause.png">
<img id="video-play-image" crossorigin src="https://cdn.aframe.io/360-video-boilerplate/img/play.png" >
<video id="cityVideo" loop crossorigin
src="https://dl.dropboxusercontent.com/u/45973806/_Project/_9NowVRLounge/VRLounge_Aframe/video/rabbit360_1Mbps_1000x500.mp4"></video>
<a-mixin
id="f_point"
geometry="primitive: box;width:0.9;height:0.2;depth: 0.8"
material="color: #000000">
</a-mixin>
<img id="city" crossorigin="anonymous" src="https://cdn.aframe.io/360-image-gallery-boilerplate/img/city.jpg">
<img id="city-thumb" crossorigin="anonymous" src="https://cdn1.iconfinder.com/data/icons/MetroStation-PNG/128/MB__home.png">
<img id="cubes-thumb" crossorigin="anonymous" src="https://cdn.aframe.io/360-image-gallery-boilerplate/img/thumb-cubes.jpg">
<img id="sechelt-thumb" crossorigin="anonymous" src="https://cdn.aframe.io/360-image-gallery-boilerplate/img/thumb-sechelt.jpg">
<audio id="click-sound" crossorigin="anonymous" src="https://cdn.aframe.io/360-image-gallery-boilerplate/audio/click.ogg"></audio>
<img id="cubes" crossorigin="anonymous" src="https://cdn.aframe.io/360-image-gallery-boilerplate/img/cubes.jpg">
<img id="sechelt" crossorigin="anonymous" src="http://360.littlstar.com/production/027a3245-0340-41c0-b0e1-8b7259d3ab69/web_poster.jpg">
<!-- Image link template to be reused. -->
<script id="link" type="text/nunjucks">
<a-plane class="link" height="1" width="1"
material="shader: flat; src: {{ thumb }}"
event-set__1="_event: mousedown; scale: 1 1 1"
event-set__2="_event: mouseup; scale: 1.2 1.2 1"
event-set__3="_event: mouseenter; scale: 1.2 1.2 1"
event-set__4="_event: mouseleave; scale: 1 1 1"
set-image="on: click; target: #image-360; src: {{ src }}"
sound="on: click; src: #click-sound"
update-raycaster="#cursor"></a-plane>
</script>
</a-assets>
<!-- 360 video, rotated 180-degrees to select an initial view. -->
<a-videosphere src="#cityVideo" rotation="0 230 0"></a-videosphere>
<!-- Image links. -->
<a-entity id="links" layout="type: line; margin: 1.5" position="0 -1 -4">
<a-entity
video-controls="src: #cityVideo; backgroundColor: #333; barColor: #EF2D5E; textColor: #ffffff; infoTextTop: Gaze and click on the icon or progress bar.; infoTextBottom: Double-click outside of the player to toggle it."
position="0 1 2" scale="3 3 3 "></a-entity>
</a-entity>
<!-- Camera + cursor. -->
<a-entity camera look-controls>
<a-cursor id="cursor"
animation__click="property: scale; startEvents: click; from: 0.1 0.1 0.1; to: 3 3 3; dur: 150"
animation__fusing="property: fusing; startEvents: fusing; from: 3 3 3; to: 0.1 0.1 0.1; dur: 1000"
event-set__1="_event: mouseenter; color: springgreen"
event-set__2="_event: mouseleave; color: red"
raycaster="objects: .link"></a-cursor>
</a-entity>
<a-entity bmfont-text="text: Hello world"></a-entity>
</a-scene>
<!--githubcorner-->
<a href="https://github.com/ngokevin/kframe/tree/master/components/text/examples/vaporwave/" class="github-corner">
<svg width="80" height="80" viewBox="0 0 250 250" style="fill: #111; color: #EFEFEF; position: fixed; bottom: 0; border: 0; left: 0; transform: rotate(180deg); opacity: 0.8">
<path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path><path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2" fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"></path><path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z" fill="currentColor" class="octo-body"></path>
</svg>
</a>
<style>.github-corner:hover .octo-arm{animation:octocat-wave 560ms ease-in-out}@keyframes octocat-wave{0%,100%{transform:rotate(0)}20%,60%{transform:rotate(-25deg)}40%,80%{transform:rotate(10deg)}}@media (max-width:500px){.github-corner:hover .octo-arm{animation:none}.github-corner .octo-arm{animation:octocat-wave 560ms ease-in-out}}
</style>
<!--endgithubcorner-->
<script>
document.querySelector('#finish1').addEventListener('click', function () {
window.location.assign("https://www.youtube.com/embed/t99N223fqCo?autoplay=1");
mouseoversound.playclip()
});
</script>
</body>
</html>
/* global AFRAME */
/**
* Component that listens to an event, fades out an entity, swaps the texture, and fades it
* back in.
*/
AFRAME.registerComponent('set-image', {
schema: {
on: {type: 'string'},
target: {type: 'selector'},
src: {type: 'string'},
dur: {type: 'number', default: 300}
},
init: function () {
var data = this.data;
var el = this.el;
this.setupFadeAnimation();
el.addEventListener(data.on, function () {
// Fade out image.
data.target.emit('set-image-fade');
// Wait for fade to complete.
setTimeout(function () {
// Set image.
data.target.setAttribute('material', 'src', data.src);
}, data.dur);
});
},
/**
* Setup fade-in + fade-out.
*/
setupFadeAnimation: function () {
var data = this.data;
var targetEl = this.data.target;
// Only set up once.
if (targetEl.dataset.setImageFadeSetup) { return; }
targetEl.dataset.setImageFadeSetup = true;
// Create animation.
targetEl.setAttribute('animation__fade', {
property: 'material.color',
startEvents: 'set-image-fade',
dir: 'alternate',
dur: data.dur,
from: '#FFF',
to: '#777'
});
}
});
AFRAME.registerComponent('update-raycaster', {
schema: {type: 'selector'},
init: function () {
var raycasterEl = this.data;
raycasterEl.components.raycaster.refreshObjects();
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment