javascript - 如何在 Gatsby/React 中创建 360 度全景图像?
问题描述
我试图了解如何在 react/gatsbyjs 中创建基本的 360 度全景图像,用户可以在其中无限地水平滚动图像。这是我想要达到的结果:
借助普通 html/css/js 中的 jquery 插件,我可以轻松实现此结果,但是,我无法弄清楚如何以“反应方式”正确地做到这一点。我尝试过使用 react-vr,但是,当我尝试从 react-vr 导入所有需要的模块时,浏览器会抛出以下错误:
我还在学习 React,所以任何指针或建议将不胜感激!
这是我的组件代码:
import React, { Component } from 'react'
import { View, Pano } from 'react-vr'
import { Link } from 'gatsby'
import FooterMenu from '../../components/footer-menu/footer-menu'
import Content from '../../components/content-container/content'
import './upper.sass'
const UpperPage = () => {
return (
<Content>
<div id="view-1" class="view-content">
<Link to="/views" className="back-btn">
← back
</Link>
<View>
<Pano source={{ uri: '../../images/views/high.jpg' }} />
</View>
</div>
<FooterMenu />
</Content>
)
}
export default UpperPage
解决方案
I'm not familiar with the legacy React VR project, but this documentation suggests that it's not intended to be included within an existing React component but instead built as its own project.
This documentation offers two ways you can integrate a 360 project into an existing application, one of which is to use an iframe. To do this inside of Gatsby, you would set your React 360 project to build to a folder in the static
folder of your Gatsby project (e.g: your-gatsby-site/static/vr-experience/index.html
), and build/deploy it before you run gatsby build
. This will copy your React 360 project over to your public
folder on-build, making it available for HTTP requests.
推荐阅读
- java - DropWizard 非平凡配置验证
- ruby-on-rails - 在 Ruby 中,减量 (-=) 函数在 0 处停止
- c - 程序从管理员升级到系统
- typescript - 谷歌日历 API - 打字稿类型
- java - 从同一个 html 页面引用两个 jnlp 文件 - Java Webstart
- spring - Hibernate EntityInterceptor (EmptyInterceptor):过滤掉所有@Transaction(readOnly=TRUE) 事务
- c++ - 重载后重载赋值 [][]
- r - ggplot2:线图“疯狂”
- jquery - 将事件处理程序附加到除一个及其后代之外的所有元素
- javascript - video.js:适用于缓冲区预加载和响应式全屏渲染?