当前位置: 首页 > 工具软件 > Pannellum > 使用案例 >

Pannellum:实例之一个简单的例子

鲁波光
2023-12-01

播放简单的圆柱投影

效果:

A simple example

代码:

<!DOCTYPE HTML>
<html lang="ch">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="author"content=“KaiSarH,huankai7@163.com”>
    <title>A simple example</title>
    <link rel="stylesheet" href="pannellum.css"/>
    <script type="text/javascript" src="pannellum.js"></script>
    <style>
        /*
        定义样式,全景图显示的位置
        */
        #panorama {
            width: 1200px;
            height: 800px;
        }
    </style>
</head>
<body>
<div id="panorama"></div>
<script>
    // 使用pannellum.viewer可以创建一个新的全景对象
    // 第一个参数type设置Pannellum处理全景图片的方式
    // 第二个参数panorama添加全景图片
    pannellum.viewer('panorama', {
        "type": "equirectangular",
        "panorama": "test/test.jpg"
    });
</script>
</body>
</html>

总结:

  1. 当我们在使用Pannellum的时候,需要把pannnellum.css和pannnellum.js引入到项目中
  2. 定义一个存储全景图的div(似曾相识的地方—openLayer)
  3. 使用pannellum.viewer创建一个全景对象
  4. 对viewer的参数进行设置
  5. 参数type设置Pannellum处理全景图片的方式
  6. 参数panorama添加全景图片
 类似资料: