photo sphere viewer使用图像数据替代路径来生成全景图

photo sphere viewer是一个js库,用来将全景图片生成360度的全景图像,但是其要求传入的是个路径。如何使用数据代替路径生成图像。

我采用的方法是用img标签生成图像,然后调用img.src来替换path

<!DOCTYPE html>
<html>

    <head>
        <meta charset="utf-8" />
        <title>Photo Sphere Viewer</title>
        <meta name="viewport" content="initial-scale=1.0" />
        <script src="{{ url_for('static', filename='three.min.js')}}"></script>
        <script src="{{ url_for('static', filename='photo-sphere-viewer.min.js')}}"></script>
        <style>
            html, body {
                margin: 0;
                width: 100%;
                height: 100%;
                overflow: hidden;
            }

            #container {
                width: 100%;
                height: 100%;
            }
        </style>
    </head>

    <body>
        <div id="container"></div>
        <img id="image" src="data:image/jpeg;base64,{{ image }}" alt="test">
        <script>
            var div = document.getElementById('container');
            var img = document.getElementById('image');
            var PSV = new PhotoSphereViewer({
                    panorama: img.src,
                    container: div,
                    time_anim: 3000,
                    navbar: true,
                    navbar_style: {
                        backgroundColor: 'rgba(58, 67, 77, 0.7)'
                    },
                });
        </script>
    </body>

</html>

传入的image是经过base64压缩过的图像的数据

转载于:https://www.cnblogs.com/lgh344902118/p/7459098.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值