GithubHelp home page GithubHelp logo

farminf / pannellum-react Goto Github PK

View Code? Open in Web Editor NEW
110.0 7.0 79.0 60.68 MB

React Component for Pannellum (open source panorama viewer for the web)

License: MIT License

JavaScript 76.90% CSS 22.94% HTML 0.16%
react pannellum component library npm-package panorama 360-view react-360 react-vrviewer react-vr

pannellum-react's Introduction

pannellum-react

npm package

React Component library for the Pannellum project.

Special thanks to Matthew Petroff

Currently there are some problem with React V18

Install and Import

Install pannellum-react component

npm install pannellum-react --save

or

yarn add pannellum-react

Import pannellum-react in your react component file by

import { Pannellum, PannellumVideo } from "pannellum-react";

Note: By using import Pannellum from "pannellum-react/es/elements/Pannellum" the video.js component will be skipped, which decreases the production build by more than 500kb.

Note: Currently only equirectangular type is supported! planning to do also multires

Note: Tours component currently is not supported but is WIP. Note: For having video tours, there is the custum hotspot which can implement the video scene changing using handleClick. In fact in can be the tour for videos and photos. Note: You can also create your tour with custom hotspot, by changing the image dynamically. Note: If you manage the props by state, you can update the component smoothly (example: updating yaw, pitch or hfov won't re-render the image and it will dynamically update)

Demo

https://farminf.github.io/pannellum-react/

you can also use codesandbox playground

Edit q27rq5p6

Simple Example

import React, { Component } from 'react';
import { render } from 'react-dom';

import { Pannellum, PannellumVideo } from "pannellum-react";
import myImage from "./images/alma.jpg";
import myVideo from "./images/video.mp4";


const PannellumReact = () => (
  <div>
    <h1>Pannellum React Component</h>
    <Pannellum
        width="100%"
        height="500px"
        image={myImage}
        pitch={10}
        yaw={180}
        hfov={110}
        autoLoad
        onLoad={() => {
            console.log("panorama loaded");
        }}
    >
      <Pannellum.Hotspot
        type="info"
        pitch={11}
        yaw={-167}
        text="Info Hotspot Text 3"
        URL="https://github.com/farminf/pannellum-react"
      />

      <Pannellum.Hotspot
        type="info"
        pitch={31}
        yaw={-107}
        text="Info Hotspot Text 4"
        URL="https://github.com/farminf/pannellum-react"
      />
    </Pannellum>

    {/******  for video 360 component *******/}

    <PannellumVideo
      video={myVideo}
      loop
      width="100%"
      height="600px"
      pitch={10}
      yaw={180}
      hfov={140}
      minHfov={50}
      maxHfov={180}
    >
      <Pannellum.Hotspot
        type="custom"
        pitch={31}
        yaw={150}
        handleClick={(evt , name) => this.hanldeClick(name)}
        name="hs1"
      />

      <Pannellum.Hotspot
        type="info"
        pitch={31}
        yaw={-57}
        text="Info"
        URL="https://github.com/farminf"
      />
    </PannellumVideo>

    </div>
);

export default PannellumReact;

API

pannellum-react has most of the official pannellum properties (not all of them). It just needed to be passed as props of the pannellum component like example above.on

Props API

Name Type Default Description
id String Unique Generated String If you pass it, it will use it for div id, if not it would be unique string for each component
width String "100%" The width of the panorama div
height String "400px" The height of the panorama div
image String "" The 360 image path
haov Number 360 Initial horizontal angle of view
vaov Number 180 Initial vertical angle of view
vOffsect Number 0 Initial vertical offset angle
yaw Number 0 Starting yaw position in degrees
pitch Number 0 Starting pitch position in degrees
hfov Number 100 Starting horizontal field of view in degrees
maxHfov Number 150 Maximum field of view which user can zoom (in degrees)
minHfov Number 50 Minimum field of view which user can zoom (in degrees)
maxPitch Number 90 Maximum field of view pitch (in degrees)
minPitch Number -90 Minimum field of view pitch (in degrees)
maxYaw Number 180 Maximum field of view yaw (in degrees)
minYaw Number -180 Minimum field of view yaw (in degrees)
autoRotate Number 0 rotation speed in degrees per second. Positive is counter-clockwise, and negative is clockwise.
compass Boolean false Showing compass if true
title String "" Displays as the panorama’s title
author String "" Displays as the panorama’s author
preview String "" Preview image path to display
previewTitle String "" Preview title to display
previewAuthor String "" Preview Author to display
autoLoad Boolean false Load and dsplay the image automatically if true
orientationOnByDefault Boolean false If true Device orientation will work if device supported
showZoomCtrl Boolean true The zoom control display on the image
keyboardZoom Boolean true Enables zoom control from keyboard if true
disableKeyboardCtrl Boolean false Disables control from keyboard if true
mouseZoom Boolean true Enables zoom control with mouse if true
draggable Boolean true If false, mouse and touch dragging is disabled
showFullscreenCtrl Boolean true FullScreen control display
showControls Boolean true if False, no control displays
onLoad Function Callback function which fires after loading
onRender Function Callback function which fires after each render, helpful if you need to react to yaw/pitch/roll/zoom changes
onError Function Callback function which fires after error
onErrorcleared Function Callback function which calls after clearing the error
onMousedown Function Callback function which calls after mouse button press
onMouseup Function Callback function which calls after mouse button release
onTouchstart Function Callback function which calls after touch starts
onTouchend Function Callback function which calls after touch ends
hotspotDebug Boolean false For debug pupose (finding correct point for hotspot)
doubleClickZoom Boolean true Zoom if you double click

Additionally, by Getting refrence of the component, you can get the pannellum Viewer calling getViewer() which gives all the available functions of the viewer such as getPitch, setPitch , getYaw and etc. find here

Moreover, you can force render the component using forceRender() in case if you change a prop and didn't change constantly.(example would be hotspot: if you want to update hotspot dynamically, better to call forceRender after updating the hotspots)

example this.PanImage.current.getViewer().getPitch(), PanImage is ref of the component.

This is working also for the video component


HotSpot API

Info

Name Type Default Description
type String info you should pass it
pitch Number 0 the pitch for hotspot
yaw Number 0 the yaw for hotspot
text String "" on mouse over hotspot shows the text box
URL String "" onClick of hotspot opens on new page

Custom

Name Type Default Description
type String custom you should pass it
pitch Number 0 the pitch for hotspot
yaw Number 0 the yaw for hotspot
tooltip Function see demo (createTooltipFunc) the function pass div element and you can append any shape or html or ...
tooltipArg Object {} (createTooltipArgs) will be passed to handleClick
handleClick Function logging the handleClickArg (clickHandlerFunc) fires onclick of hotspot
handleClickArg Object {} (clickHandlerArgs) will be passed to handleClick
cssClass String tooltipcss String is used as the CSS class for the hotspot

Video API

these are videojs configuration properties which can be used

Name Type Default Description
video String " " Path to your 360 video
loop Boolean false Looping over video
autoplay Boolean true Play the video as page loaded
controls Boolean false showing controls under
muted Boolean true making video mute

in addition there are also pannellum properties(panorama) which works on video

Name Type Default Description
width String "100%" The width of the panorama div
height String "400px" The height of the panorama div
video String "" The 360 video path
yaw Number 0 Starting yaw position in degrees
pitch Number 0 Starting pitch position in degrees
hfov Number 100 Starting horizontal field of view in degrees
maxHfov Number 150 Maximum field of view which user can zoom (in degrees)
minHfov Number 50 Minimum field of view which user can zoom (in degrees)
maxPitch Number 90 Maximum field of view pitch (in degrees)
minPitch Number -90 Minimum field of view pitch (in degrees)
maxYaw Number 180 Maximum field of view yaw (in degrees)
minYaw Number -180 Minimum field of view yaw (in degrees)
autoRotate Number 0 rotation speed in degrees per second. Positive is counter-clockwise, and negative is clockwise.
mouseZoom Boolean true Enables zoom control with mouse if true
hotspotDebug Boolean false For debug pupose (finding correct point for hotspot)

if you are using chrome, try to keep muted true for autoplay.


Example with all the available props

<Pannellum
  width="100%"
  height="500px"
  image={myImage}
  haov={180}
  vaov={90}
  vOffset={1}
  pitch={10}
  yaw={180}
  hfov={110}
  maxHfov={170}
  minHfov={30}
  autoLoad
  author=""
  title=""
  orientationOnByDefault={false}
  compass
  draggable
  keyboardZoom
  mouseZoom
  preview=""
  previewAuthor=""
  previewTitle=""
  showControls
  showFullscreenCtrl
  showZoomCtrl
  hotspotDebug={false}
  onLoad={() => {
    console.log("panorama loaded");
  }}
  onError={err => {
    console.log("Error", err);
  }}
  onErrorcleared={() => {
    console.log("Error Cleared");
  }}
  onMousedown={evt => {
    console.log("Mouse Down", evt);
  }}
  onMouseup={evt => {
    console.log("Mouse Up", evt);
  }}
  onTouchstart={evt => {
    console.log("Touch Start", evt);
  }}
  onTouchend={evt => {
    console.log("Touch End", evt);
  }}
>
  <Pannellum.Hotspot
    type="info"
    pitch={11}
    yaw={-167}
    text="Info Hotspot Text"
    URL="https://github.com/farminf"
  />

  <Pannellum.Hotspot
    type="custom"
    pitch={31}
    yaw={150}
    handleClick={(evt , args) => console.log(args.name)}
    handleClickArg={{ "name":"test" }}
    {/* there are 3 other props. see the custom hotspot doc above*/}
  />

</Pannellum>

License

pannellum-react is released under the MIT license.

pannellum-react's People

Contributors

datsteves avatar dhruvsakariya avatar farminf avatar farminho avatar karianpour avatar litomore avatar redbaron76 avatar vlkpa avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

pannellum-react's Issues

Safari | Can't interact with controls

Using Safari, I'm not able to interact with video controls (Play, Pause, Timeline)
The pointer is stuck in the hand icon, for dragging the video orientation.

How to AutoRotate?

autoRotate prop is undocumented but it seems to be supported by the code in the Pannellum component. Setting autoRotate={+/-<num>} doesn't seem to work though.

How to implement an auto rotation onStart? Thanks

createTooltipFunc && createTooltipArgs

Do you think it's possible to fix / correctly implement those two props?
At the moment there's an undocumented Tooltip prop that would play the role of createTooltipFunc but, not having createTooltipArgs implemented, it's partly useless.

Furthermore, would be great to maintain the text prop in custom HotSpot too, so you still can give basic tooltip functionality for those who don't need to change the tooltips behaviour.

Great job till now, anyway! That's what I was looking for...

Potential fix to access denied error

Hello and thank you for this nice library!
I had a similar issue as the one discussed in the issue: #77
The very first time we use the <Pannellum image={some_URL_1} /> with the image source some_URL_1 it works fine. But whenever the I change the image property I pass to that same Pannellum instance exp: <Pannellum image={some_URL_2} />. I get the cannot access problem (all images are hosted on the same site & the problem only appear if I change the url I pass to the image property as I said).
The problem disapears if I make a new instance Pannellum instance for every new image URL (But that's wasteful and causes flashing/re-loading ofthe whole panaroma)

I was able to "make it work" without always creating a new Pannellum instance for every new image URL. I had to comment out the line 211 in master/src/elements/Pannellum.js as seen below:
if (state === "update") { // this.panorama.destroy(); }

I diagnoally read through the code (quickly, I might have missed something) and it seems the code simply removes canvas from container and the event listeners! I also checked memory consumption and it seems to be just fine

So my question is whether it's really safe to remove that this.panorama.destroy(); call ?

Thank you again!

Unable to use with React 17

While installing the package error shows up. The error:

npm ERR! Found: [email protected]
npm ERR! node_modules/react
npm ERR!   react@"^17.0.2" from the root project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer react@"16.x" from [email protected]
npm ERR! node_modules/pannellum-react
npm ERR!   pannellum-react@"1.2.4" from the root project

I am using React 17.0.2.

Full screen can only be toggled once

From both my own code and the demo linked from the repository's readme, it appears that full screen can only be toggled once. The first click will enable full screen, pressing escape or clicking the full screen control will minimize but the full screen indicator still shows on the control and clicking it doesn't do anything. This bug doesn't appear to be present in the base pannellum library.

EDIT: I sent a PR to resolve this bug. I am not sure why this library doesn't include Pannellum as a dependency rather than directly including its code into this library.

webpack error occurs on css files

I have configured my webpack config. And after adding pannellium-react I get the error:
ERROR in ./node_modules/pannellum-react/es/pannellum/css/pannellum.css (./node_modules/css-loader??ref--5-1!./node_modules/pannellum-react/es/pannellum/css/pannellum.css) Module not found: Error: Can't resolve 'img/sprites.svg' in '/node_modules/pannellum-react/es/pannellum/css' @ ./node_modules/pannellum-react/es/pannellum/css/pannellum.css (./node_modules/css-loader??ref--5-1!./node_modules/pannellum-react/es/pannellum/css/pannellum.css) 7:1130-1156 @ ./node_modules/pannellum-react/es/pannellum/css/pannellum.css @ ./node_modules/pannellum-react/es/elements/Pannellum.js @ ./node_modules/pannellum-react/es/index.js
Is something wrong with my config file here is a part of code:
rules: [ { test: /\.(js)$/, exclude: /node_modules/, use: ['babel-loader'] }, { test: /\.css$/, use: [ { loader: 'style-loader' }, { loader: 'css-loader', options: { modules: true, camelCase: true, sourceMap: true } } ] }, { test: /\.scss$/, use: [ "style-loader", // creates style nodes from JS strings "css-loader", // translates CSS into CommonJS "sass-loader" // compiles Sass to CSS, using Node Sass by default ] },

I cannot build my app. Missing files

Hi. I did install. All good.
but I just added the code to run the plugin and I have this error:

ERROR in ./node_modules/pannellum-react/lib/elements/Pannellum.js
Module not found: Error: Can't resolve '../pannellum/css/pannellum.css'

ERROR in ./node_modules/pannellum-react/lib/elements/PannellumVideo.js
Module not found: Error: Can't resolve '../pannellum/css/pannellum.css'

Im running your this code:

<Pannellum
	width="100%"
	height="500px"
	image={`./assets/img/placeholder/360image.jpg`}
	pitch={10}
	yaw={180}
	hfov={110}
	autoLoad
	onLoad={loaded360}
/>

some missing peace that I doing wrong?

API addScene() error

Excuse me for interrupting you.
When i use 'this.myPannellum.current.getViewer().addScene('secondScene', config);' errors.

Follow is code:

  selectOneScene = () => {
    const config = {
      autoLoad: true,
      autoRotate: 6,
      showZoomCtrl: false,
      showControls: false,
      showFullscreenCtrl: false,
      hotSpots: [
        {
          pitch: 10,
          yaw: 130,
          type: 'info',
          text: "struct",
        }
      ],
      basePath: "https://pannellum.org/images/alma.jpg",
    }
    this.myPannellum.current.getViewer().addScene('secondScene', config);
    this.myPannellum.current.getViewer().loadScene('secondScene', 10, 120, 10, true);
  }

Follow is api:
image

Follow is Errors:
image

image

How to custom the 'Hotspot' icon

      <Pannellum.Hotspot
        type="custom"
        pitch={0}
        yaw={150}
        handleClick={(evt, args) => this.changeImg()}
      />

image

In full view nagivation, the arrow icon seems to be better.
Is there any way to custom the icon?

image

Got a VideoJS warning in console

Seems we are using a deprecated API of the VideoJS.

I got this warning in the console.

VIDEOJS: WARN: videojs.plugin() is deprecated; use videojs.registerPlugin() instead

Package Size Improvements

When using the pannellum-react component via import {Pannellum} from "pannellum-react" as suggested, the whole video.js library will be imported/bundled with the project build.

By using import Pannellum from "pannellum-react/es/elements/Pannellum" the video.js component will be skipped, which decreases the production build by more than 500kb.

This is not really a bug, but it should be documented.

No controls

For some reason I can't get video controls to show even with showControls={true}

not able to drag image from imiddle

i am using the following code but not able to drag image from middle and only small top left is draggable :

<Pannellum
width="100%"
height="400px"
image={ArmImg}
pitch={10}
yaw={180}
hfov={500}
autoLoad
author=""
title=""
orientationOnByDefault={false}
draggable
keyboardZoom
mouseZoom
preview=""
previewAuthor=""
previewTitle=""
showControls
showFullscreenCtrl
showZoomCtrl
onLoad={() => {
console.log("panorama loaded");
}}
>
<Pannellum.Hotspot
type="info"
pitch={11}
yaw={-167}
text="Info Hotspot Text 3"
URL="https://github.com/farminf/pannellum-react"
/>

                            <Pannellum.Hotspot
                                type="info"
                                pitch={31}
                                yaw={-107}
                                text="Info Hotspot Text 4"
                                URL="https://github.com/farminf/pannellum-react"
                            />
                        </Pannellum>

kindly guide if i am doing something wrong.

thanks & Reagrds
gmchaturvedi

Can't create hotspots dynamically

If I want to create several hotspots dynamically, I get a javascript error.

Code to generate the error:
This will work:

<Pannellum ...>
    <Pannellum.Hotspot type='custom'/>
</Panellum>

But this will not:

<Pannellum ...>
    {[1, 2, 3].map(i => <Pannellum.Hotspot key={i} type='custom'/>)}
</Panellum>

The error that is generated is very weird:

image

Debugging inside this function shows that hotspots is indeed an array of objects containing a property props. But once inside the map function, hotspot is an array identical to hotspots

I'll try to create a codepen and come back with that.
Maybe you'll know the error already?

thx

Tooltip question

Hello again farminf~
Thank you for your reply before.
Now I'm working on a project which requires me to use a tooltip for a custom hotspot.
But in your Pannellum document, it says the default value of it is "see demo".
I've reviewed all the files in your folders but still, I didn't locate where it's being used.

Could you please tell me how to use tooltip and tooltiparg? Thanks.

Controls are blank but working

The buttons show up, but the action indicator icons are missing. They are just white squares.
Is there something I'm missing with the controls? Is there a straight forward way of customizing them, i.e making my own button components?

 <Pannellum
      width={elementWidth}
      height={elementHeight}
      image={image}
      pitch={pitch}
      yaw={yaw}
      hfov={hfov}
      autoLoad
      onLoad={onLoadFc}
   />

EDIT
I seem to have found the issue, but i'm still lost like a boy in a foreign country.
There seems to be a problem loading the icon.

pnlm-sprite {
    background-image: url([object Object]);
}

Another question that I have is if there is a way of customizing the loading indicator?

Viewer Jumping with custom minYaw maxYaw

Hi,

I'm facing a issue when setting up minYaw and maxYaw.
The problem happens when the viewer reaches the maxYaw value. My intention is to lock the viewer to not pass further than the maxYaw, but sometimes the view jumps from the max to the min value.

It is not too bad if the first yaw is set to 0 because the limits can stay far away from the 180 and -180, as you can see in the GIF below it takes some effort to make it happen.

The Code:

   yaw: 0,
    minYaw: -140,
    maxYaw: 140,

The Result:
5c1a9137111f6051506024

However if I set one of the values close to 180 or -180, it becomes really sensitive and jumps right away.

The Code:

          yaw: 0,
          minYaw: -140,
          maxYaw: 180,

The Result:
webp net-resizeimage

I'm setting those values via state of the component. Because the user can select different images, so each yaw, and min/max yaw values are taken from these states. I have a bunch of states like this one below.

   bolhaPetPlace: {
          img: bolhaPetPlace,
          foto: fotoPetPlace,
          pitch: 0,
          minPitch: -70,
          maxPitch: 80,

          yaw: 0,
          minYaw: -140,
          maxYaw: 140,

          hfov: 100,
          maxHfov: 110,
          minHfov: 100,
          hotSpotNumbers: 0,
          hotSpots: [
            {
              pitch: 0,
              yaw: 0,
              tooltipText: "Pet Place",
              handleClickArg: "PetPlace"
            }
          ]
        },

And I'm selecting witch one accordingly to another state set on another component

let witchBolha = this.props.currentBolha;

switch (witchBolha) {

    case "pet-place":
    selectedBolhaData = this.state.bolhasData.bolhaPetPlace;
    break;
    
    /* other cases*/

}

And then picking each value from it

    selectedBolha = selectedBolhaData.img;
    selectedFoto = selectedBolhaData.foto;
    pitch = selectedBolhaData.pitch;
    minPitch = selectedBolhaData.minPitch;
    maxPitch = selectedBolhaData.maxPitch;
    yaw = selectedBolhaData.yaw;
    minYaw = selectedBolhaData.minYaw;
    maxYaw = selectedBolhaData.maxYaw;
    hfov = selectedBolhaData.hfov;
    minHfov = selectedBolhaData.minHfov;
    maxHfov = selectedBolhaData.maxHfov;

Finally inserting everything into

<Pannellum
          width="100%"
          height="100%"
          image={selectedBolha}
          pitch={pitch}
          minPitch={minPitch}
          maxPitch={maxPitch}
          yaw={yaw}
          minYaw={minYaw}
          maxYaw={maxYaw}
          hfov={hfov}
          minHfov={minHfov}
          maxHfov={maxHfov}
          showControls={true}
          autoLoad
          autoRotate={0}
          onLoad={() => {
            document
              .querySelector(".pnlm-render-container")
              .classList.add("fadeIn");
          }}
        >
          {this.createHotspots(selectedBolhaData)}
        </Pannellum>

I'm sorry if I was confusing or my code is messy.
I'm a beginner in programming and even new to React.

Is there any way to work around this?

Thanks!

How to get camera pitch & yaw?

just like in pannellum.js you can get the camera pitch & yaw by viewer.getPitch() & viewer.getYaw(). Thanks in advance..

Error importing into gatsby

When embedding this component into gatsby, we have an error on window definition.

https://github.com/farminf/pannellum-react/blob/master/src/pannellum/js/libpannellum.js#L24

This triggers the below

WebpackError: ReferenceError: window is not defined

As we only render the component on client side, it's not necessary that we actually render on the serverside, only that the module itself doesn't crash compilation.

We can probably work around by using a conditional import on the panellum-react module, but ideally the window.libpannellum assignment would be wrapped in an if (typeof window !== 'undefined')

Moving hotspot

How would get the pitch and yaw of a hotspot to update without the video restarting?

Thanks

The package-lock.json file should keep sync with package.json

Node.js version: 11.3.0
npm version: 6.4.1

How to reproduce

# Install dependencies
$ npm i

# Review diff
$ git diff

Then I got the diff like this:

diff --git a/package-lock.json b/package-lock.json
index ff44429..fd2bcc3 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,6 +1,6 @@
 {
   "name": "pannellum-react",
-  "version": "0.2.8",
+  "version": "1.1.2",
   "lockfileVersion": 1,
   "requires": true,
   "dependencies": {
@@ -5605,14 +5605,12 @@
         "balanced-match": {
           "version": "1.0.0",
           "bundled": true,
-          "dev": true,
-          "optional": true
+          "dev": true
         },
         "brace-expansion": {
           "version": "1.1.11",
           "bundled": true,
           "dev": true,
-          "optional": true,
           "requires": {
             "balanced-match": "^1.0.0",
             "concat-map": "0.0.1"
@@ -5627,20 +5625,17 @@

...

How clickHandlerFunc works?

I'm facing some issues implementing my own click event on HotSpots.
Looking at documentation (and your code), in a React context, the click event should work like this (but it is not at the moment):

import React, { Component } from 'react';
import { Pannellum } from "pannellum-react";
import myImage from "./images/BAIN9148.jpg";

class App extends Component {

    clickHotSpot(e, args) {
        console.log(e, args);
    }

    render() {
        return (
            <div>
                <h1>Pannellum</h1>
                <Pannellum
                    width="100%"
                    height="800px"
                    image={myImage}
                    pitch={10}
                    yaw={180}
                    hfov={110}
                    maxHfov={130}
                    minHfov={90}
                    autoLoad
                    hotspotDebug={false}
                >

                    <Pannellum.Hotspot
                        type="info"
                        pitch={5}
                        yaw={20}
                        text="Click me"
                        clickHandlerFunc={this.clickHotSpot}
                        clickHandlerArgs={{
                            name: "Test"
                        }}
                    />

                </Pannellum>
            </div>
        );
    }
}

export default App;

Am I doing something wrong?
Thanks

Feature request: Custom Hotspot Children as React Component

Hi,

Thanks for the great work porting the library. However I've been trying to figure out how to implement custom hotspot without forking the library but is unclear to me. Your documentation, nor your example unfortunately shows how to implement a custom hotspot.

I am using a bit of my own code to display what I would like to achieve, take the product thumbnail image pass it as children to the pannellum hotspot. Or as a parameter. ProductImage is a styled-component:

`

      {products?.value && products?.value?.map((product, index) => (
        <Pannellum.Hotspot
          type="custom"
          pitch={0}
          yaw={index * 2}
          text={product.name}
          handleClick={() => setProduct(product.productHash)}
        >

          <ProductImage src={product.productThumbnail.src} />

        </Pannellum.Hotspot>

      ))}

    </Pannellum>

`

React 17.x

Hey, will there be support for 17.x react?
It works on this version, but installation via npm requires --legacy-peer-deps

orientationOnByDefault doesn't work

Hello,
How do you add the gyrosensor to it? I have added the orientationOnByDefault prop, but it's not working.

Below is the code:

<Pannellum width="100%" image={myImage} pitch={10} hfov={110} vaov={90} vOffset={1} yaw={180} maxHfov={170} minHfov={30} autoLoad showZoomCtrl={false} showFullscreenCtrl={false} orientationOnByDefault > </Pannellum>

Package versions:

"pannellum-react": "1.1.3",
 "react": "^16.8.6",

Next.js and Pannellum-react: "Global CSS cannot be imported from within node_modules." error

Hi!

I'm receiving the following error after installing and attempting to import the component in a Next.js 11 environment.

import { Pannellum } from "pannellum-react";

error - ./node_modules/pannellum-react/es/pannellum/css/pannellum.css Global CSS cannot be imported from within node_modules. Read more: https://nextjs.org/docs/messages/css-npm Location: node_modules/pannellum-react/es/elements/Pannellum.js

Next.js official documentation on this issue (https://nextjs.org/docs/messages/css-npm) doesn't have a good solution to this other than to refactor things so there's no CSS imported from node_modules or to "make a compiled version of the dependency."

That being said, I'm wondering if anyone has any insight on a workaround?

I found someone else with the same issue too: https://stackoverflow.com/questions/66664698/i-got-this-error-in-next-js-while-implement-pannellum-react-to-make-3d-images-g

Tracking URL here in case that thread ends up with valuable information.

Any insight much appreciated, and thanks for making the React version in the first place!

. . .

Some more info:


{ // package.json
  "name": "whatabyte",
  "version": "1.0.0",
  "main": "index.js",
  "license": "MIT",
  "node-version": "14",
  "dependencies": {
    "css-loader": "^6.2.0",
    "html-webpack-plugin": "^5.3.1",
    "next": "^11.1.2",
    "node-sass": "^5.0.0",
    "pannellum-react": "^1.2.4",
    "prismjs": "^1.23.0",
    "react": "^17.0.2",
    "react-dom": "^17.0.2",
    "react-icons": "^4.2.0",
    "webpack": "^5.52.1",
    "webpack-cli": "^4.6.0"
  },
  "scripts": {
    "dev": "next",
    "build": "next build",
     "build-export": "rm -rf .next && next build && next export",
    "start": "next start"

  }
}

And screenshot of errors in terminal:
Screen Shot 2021-09-10 at 5 41 24 PM

Custom Controls.

Hello farminf,
Thank you for putting pannellum into react, really helped me a lot.
Recently I've been working on a project which required to have a map over the 360 photo.
It's similar to a custom controls. (https://pannellum.org/documentation/examples/custom-controls/), the difference is just to put a image on the button, rather than a simple icon.

Is it possible in the pannellum-react? Thank you very much.

Honour style property

Hi,

<Pannellum width="100%" height="100%" style={...} ... />

Should honour other styling not just width/height.

Zolee

componentDidUpate version 1.2.2

Package installed by npm is different than repo. (version 1.2.2)

I noticed that in es/elements/Pannellum.js method componentDidUpdate had only this.renderImage("update") without any conditions, which are existing in 1.1.3.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.