npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

photo-sphere-viewer-lensflare-plugin

v2.1.2

Published

Plugin to add lens flares on a 360° pano built with photo-sphere-viewer

Downloads

8,274

Readme

photo-sphere-viewer-lensflare-plugin

Plugin to add lens flares to a Photo Sphere Viewer (Library: PhotoSphereViewer) by mistic100

lensflare

NPM JavaScript Style Guide

Installation

NPM

npm install photo-sphere-viewer-lensflare-plugin

Yarn

yarn add photo-sphere-viewer-lensflare-plugin

Usage

HTML

<script src="https://cdn.jsdelivr.net/npm/photo-sphere-viewer-lensflare-plugin/dist/index.min.js"></script>

JavaScript

import { LensflarePlugin } from 'photo-sphere-viewer-lensflare-plugin';
const viewer = new PhotoSphereViewer.Viewer({
    container: document.querySelector('#viewer'),
    panorama: 'pano.jpg',
    plugins: [
        [LensflarePlugin, {
            lensflares: [
                {
                    id: 'sun',
                    position: { yaw: '145deg', pitch: '2deg' },
                    type: 0,
                }
            ]
        }]
    ]
});

Options

| Option | Type | Default | Description | | --- | --- | --- | --- | | lensflares | Array | [] | Array of lens flares |

Lens Flare Options

| Option | Type | Default | Description | | --- | --- | --- | --- | | id | String | '' | ID of the lens flare | | position | Object | { yaw: '0deg', pitch: '0deg' } | Position of the lens flare | | type | Number | 0 | Type of the lens flare (available: 0) | | color | HSL | { h: 0.08, s: 0.2, l: 0.5 } | Color of the lens flare |

Methods

To call methods you need to get the plugin instance.

const lensflaresPlugin = viewer.getPlugin(LensflarePlugin);

and then you can call the methods.

toggleAllLensflares

Toggle all lens flares.

lensflaresPlugin.toggleAllLensflares();

showAllLensflares

Show all lens flares.

lensflaresPlugin.showAllLensflares();

hideAllLensflares

Hide all lens flares.

lensflaresPlugin.hideAllLensflares();

getNbLensflares

Get the number of lens flares.

const nb = lensflaresPlugin.getNbLensflares();

getLensflares

Get all the lens flares.

const lensflares: LensflareObject[] = lensflaresPlugin.getLensflares();

getLensflare

Get a lens flare.

const lensflare: LensflareObject = lensflaresPlugin.getLensflare('sun');

addLensflare

Add a lens flare.

lensflaresPlugin.addLensflare({
    id: 'sun',
    position: { yaw: '145deg', pitch: '2deg' },
    type: 0,
});

updateLensflare

Update a lens flare.

lensflaresPlugin.updateLensflare({
    id: 'sun',
    position: { yaw: '145deg', pitch: '2deg' },
    type: 0,
});

removeLensflare

Remove a lens flare.

lensflaresPlugin.removeLensflare('sun');

removeLensflares

Remove multiple lens flares.

lensflaresPlugin.removeLensflares(['sun', 'moon']);

setLensflares

Clear all lens flares and add new ones.

lensflaresPlugin.setLensflares([
    {
        id: 'sun',
        position: { yaw: '145deg', pitch: '2deg' },
        type: 0,
    },
    {
        id: 'moon',
        position: { yaw: '30.6deg', pitch: '41.2deg' },
        type: 0,
    }
]);

clearLensflares

Clear all lens flares.

lensflaresPlugin.clearLensflares();

Examples

Run the provided example

npm run test

Add multiple lens flares

const viewer = new PhotoSphereViewer.Viewer({
    container: document.querySelector('#viewer'),
    panorama: 'pano.jpg',
    defaultYaw: 20.75,
    defaultPitch: 0.17,
    plugins: [
        [PhotoSphereViewerLensflarePlugin, {
            lensflares: [
                {
                    id: 'sun',
                    position: { yaw: '145deg', pitch: '2deg' },
                },
                {
                    id: 'moon',
                    position: { yaw: '30.6deg', pitch: '41.2deg' },
                    color: { h: 0.6, s: 0.5, l: 0.2 },
                }
            ]
        }]
    ]
});

Result of the example

multilens

CodeSandbox

Edit photo-sphere-viewer-lensflare-plugin