Last active
February 14, 2021 07:18
-
-
Save cubesky/b1ffa99be008ed89886aa48497a78058 to your computer and use it in GitHub Desktop.
Use babylonJS to Render Bilibili 360 Video to VR HeadSet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var cav = document.createElement('canvas') | |
cav.style.width = "100%" | |
cav.style.height = "100%" | |
document.querySelector('#v_tag').append(cav) | |
var babylon = document.createElement('script') | |
babylon.src = "https://cdn.babylonjs.com/babylon.js" | |
babylon.onload = function() { | |
var engine = new BABYLON.Engine(cav,true) | |
var createScene = function () { | |
var scene = new BABYLON.Scene(engine); | |
var vrHelper = scene.createDefaultVRExperience(); | |
vrHelper.teleportationEnabled = false; | |
var videoDome = new BABYLON.VideoDome( | |
"videoDome", | |
[player.getPlayurl()], | |
{ | |
resolution: 32 | |
}, | |
scene | |
); | |
vrHelper.currentVRCamera.attachControl(cav, true); | |
return scene; | |
}; | |
var scene = createScene() | |
engine.runRenderLoop(function() { | |
scene.render(); | |
}); | |
window.addEventListener('resize', function() { | |
engine.resize(); | |
}); | |
} | |
document.body.appendChild(babylon) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
我写了一个支持声音播放,支持拖进度条的版本:
https://swimmingtiger.gitee.io/bilibili-360-vr/
于是我的插件就做好了