android 360全景视频,there.js移动端 IOS 安卓 360全景视频(vr)

function getQueryString(name) {

console.log(name)

var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");

// var res = reg.split(':0');

var r = window.location.search.substr(1).match(reg);

if (r != null) {

return decodeURIComponent(r[2]);

}

return '';

}

// function aaa(event) {

// alert(event)

// if(event==undefined){

// alert('陀螺仪off')

// window.onLoad();

// }else{

// alert('陀螺仪on')

// }

// }

var isdevice=0;

window.= function() {

setTimeout(function() {

console.log('计时器结束')

if (AVR.OS.isiOS()) {

window.addEventListener("deviceorientation", aaaa, false);

function aaaa(event) {

console.log(event)

isdevice=1;

windowHide();

}

setTimeout(function(){

if(isdevice==1){

windowHide()

init();

}else{

windowShow()

}

},500)

console.log("是ios")

// ios 提示授权, 返回的是一个 promise

// getDevice()

} else {

console.log("不是ios")

init();

}

}, 500);

}

window.=function () {

init();

}

var win=document.getElementById('pop_window');

function windowShow(){

win.style.display='flex'

}

function windowHide(){

win.style.display='none'

}

function getDevice() {

console.log("aaaaaaaaaaaaaaaaaaaaaaaaaa")

windowHide();

window.DeviceOrientationEvent.requestPermission()

.then(permissionState => {

console.log(permissionState )

console.log(granted)

if(permissionState === "granted"){//允许

init();

window.addEventListener("devicemotion", function (e) {}, false);

// alert("允许使用陀螺仪:",state)

}else if(permissionState === "denied"){//拒绝

alert("拒绝使用陀螺仪会影响体验哦")

}else if(permissionState === "prompt"){

// alert("用户进行其他操作:",state)

}

})

}

//var vr=new VR(scene,renderer,container);

function init() {

var scene, renderer;

var container;

//renderer = new THREE.WebGLRenderer();

AVR.debug = true;

if (!AVR.Broswer.isIE() && AVR.Broswer.webglAvailable()) {

renderer = new THREE.WebGLRenderer();

} else {

renderer = new THREE.CanvasRenderer();

}

renderer.setPixelRatio(window.devicePixelRatio);

container = document.getElementById('example');

container.appendChild(renderer.domElement);

scene = new THREE.Scene();

var vr = new VR(scene, renderer, container, {

"fov": 100

});

//vr.playText="play90.png";

vr.vrbox.radius = 600;

if (AVR.isCrossScreen()) {

vr.effect.separation = 1.2;

}

vr.loadProgressManager.onLoad = function() {

if (AVR.OS.isiOS()) {

vr.toolBar.btn.click();

}

vr.toolBar.btn.click();

setTimeout(vr.controls.gyroUnfreeze(), 500)

console.log("不是ios")

console.log(AVR.OS.isiOS())

}

//全景资源加载中回调

vr.loadProgressManager.onProgress = function(item, loaded, total) {

console.log("全景资源加载中回调")

console.log("item=", item, "loaded", loaded, "total=", total);

}

//全景资源加载错误回调

vr.loadProgressManager.onError = function(xhr, cl) {

console.log("全景资源加载错误回调")

console.log(xhr, cl);

}

//AVR.useGyroscope=false;

// if(AVR.isCrossScreen()) {

// // 调整vr视窗偏移量

// vr.effect.separation=1.2;

// }

vr.loadProgressManager.onLoad=function () {

// 视频静音

vr.video.muted=false;

}

vr.init(function() {

});

// console.log(name)

console.log(getQueryString("url"))

vr.playPanorama(getQueryString("url"),vr.resType.video)

console.log(vr.resType.video)

// console.log(url)

vr.video.setAttribute("loop", "loop");

vr.video.crossOrigin = "*";

vr.video.autoplay = true;

// 屏幕旋转

vr.controls.autoRotate=true

vr.video.onended = function() {}

window.addEventListener('resize', function() {

var isHuawei = navigator.userAgent.match(/;sHUAWEIs[a-zA-Z0-9-]+sBuild//);

if (AVR.OS.isWeixin() && !AVR.OS.isiOS() && isHuawei) {

if (vr.video.getAttribute('x5-video-orientation') == "landscape") {

vr.toolBar.toolbar.style.width = document.body.clientWidth + "px";

} else {

vr.toolBar.toolbar.style.width = "100%";

}

}

}, {

passive: false

})

// function animate() {

// requestAnimationFrame(animate);

// renderer.render(scene, camera);

// }

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值