three加载360度全景视频实现webvr视频播放效果代码
代码语言:html
所属分类:多媒体
代码描述:three加载360度全景视频实现webvr视频播放效果代码,在chrome等支持webvr的浏览器中运行,带上vr头盔即可体验360度视频播放。
代码标签: three 360度 全景 视频 webvr 视频 播放
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no"> </head> <body> <div id="container"></div> <video id="video" loop muted crossOrigin="anonymous" playsinline style="display:none"> <source src="//repo.bfw.wiki/bfwtool/examples/textures/MaryOculus.webm"> <source src="//repo.bfw.wiki/bfwtool/examples/textures/MaryOculus.mp4"> </video> <!-- Import maps polyfill --> <!-- Remove this when import maps will be widely supported --> <script async type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/es-module-shims.1.3.6.js"></script> <script type="importmap"> { "imports": { "three": "//repo.bfw.wiki/bfwtool/build/three.module.js" } } </script> <script type="module"> import * as THREE from 'three'; import Stats from '//repo.bfw.wiki/bfwtool/examples/jsm/libs/stats.module.js'; import { VRButton } from '//repo.bfw.wiki/bfwtool/examples/jsm/webxr/VRButton.js'; let camera, scene, renderer; init(); animate(); function init() { const container = document.getElementById( 'container' ); container.addEventListener( 'click', function () { video.play(); } ); camera = new THREE.PerspectiveCamera( 70, window.innerWidth / window.innerHeight, 1, 2000 ); camera.layers.enable( 1 ); // render left view when no stereo available // video const video = document.getElementById( 'video' ); video.play(); const texture = new THREE.VideoTexture( video ); scene = new THREE.Scene(); scene.backg.........完整代码请登录后点击上方下载按钮下载查看
网友评论0