1 回答
TA贡献1811条经验 获得超6个赞
视频由多个图像帧组成。如果您拍摄您在汽车周围行走的视频并播放它,看起来就像您显示了一个物体的 360 度视图。
以下是您的示例的示例: https: //cdn.spincar.com/swipetospin-viewers/spincarcomdemo/wp0ab2a70jl135405/20190222192724.K4BAQSBW/ec/0-0.jpg
他们有 60 个帧,从 0-0 到 0-60。我想到的算法是:将视频切成帧。他们有一个滑块来播放它们。或者实现一个拖动功能,向左拖动减少框,向右拖动增加框,记得环绕
currentFrame = (currentFrame + dragDirection) % totalFrame
const $slider = document.getElementById('frame');
const $img = document.getElementById('img');
$slider.addEventListener('change', (e) => {
$img.src = `https://cdn.spincar.com/swipetospin-viewers/spincarcomdemo/wp0ab2a70jl135405/20190222192724.K4BAQSBW/ec/0-${e.target.value}.jpg`;
});
// Preload your imgs
for (let i = 0; i <= 63; i ++) {
const img = new Image();
img.src = `https://cdn.spincar.com/swipetospin-viewers/spincarcomdemo/wp0ab2a70jl135405/20190222192724.K4BAQSBW/ec/0-${i}.jpg`
}
<img src="https://cdn.spincar.com/swipetospin-viewers/spincarcomdemo/wp0ab2a70jl135405/20190222192724.K4BAQSBW/ec/0-0.jpg" alt="Car" id="img" />
<input type="range" id="frame" name="frame" min="0" max="63" value="0">
- 1 回答
- 0 关注
- 120 浏览
添加回答
举报