我使用aframe.io库播放360视频。我无法设置视频播放器的宽高比,高度和宽度。
<a-scene id="scene" class="fullscreen" vr-mode-ui="enabled: false">
<a-entity id="vr-camera" camera look-controls="reverseMouseDrag: true" wasd-controls-enabled="true"></a-entity>
<a-assets>
<video id="aframeVideo" crossorigin="anonymous" ></video>
</a-assets>
<a-videosphere src="#aframeVideo" rotation="0 180 0" segments-height=9 segments-width=16></a-videosphere>
</a-scene>
我尝试通过a-scene标记和视频标记设置高度和宽度,但这不起作用,就好像设置无效一样。
然后我开始破解代码并设置a-canvas的高度和宽度
onResize() {
console.log('window resize');
const vrCanvas = document.getElementsByClassName('a-canvas')[0];
if (typeof vrCanvas !== 'undefined') {
const vrContainerHeight = document.getElementById('vr-container').offsetHeight;
const vrContainerWidth = document.getElementById('vr-container').offsetWidth;
if (typeof vrContainerWidth !== 'undefined' && typeof vrContainerHeight !== 'undefined') {
vrCanvas.style.height = vrContainerHeight + "px";
vrCanvas.style.width = vrContainerWidth + "px";
}
}
但它将我的视频和播放盘的初始位置扭曲到我视频的右侧。所以我试图将纵横比设置为19:6但是改变了segment-height和segments-width,这没有效果。
任何建议都将不胜感激。我不知道是否应该调整相机,视频层或场景,使用画布改变高度和宽度感觉就像一个黑客。提前致谢
POST EDIT: