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

pano-controls

v4.0.0

Published

three.js `panorama / fov` controls as a typescript compatible npm module.

Downloads

7

Readme

PanoControls

three.js panorama / fov controls as a typescript compatible npm module.

程序概览

Entrys:

  • development: src/example.ts
  • production: src/index.ts

体验

git clone [email protected]:xiaomingTang/pano-controls.git
yarn
yarn start

Installation

# cmd
yarn add pano-controls
# or
npm i pano-controls

Usage

js/ts

import * as THREE from "three"
import PanoControls from "pano-controls"

const container = document.querySelector("#container")

// PerspectiveCamera is supported only
const camera = new THREE.PerspectiveCamera(/* ... */)

const panoControl = new PanoControls(camera, container)

panoControl.h   = whatEverYouWant
panoControl.v   = whatEverYouWant
panoControl.fov = whatEverYouWant
// updateCamera after reset h / v / fov
panoControl.updateCamera()

function animate() {
  renderer.render(scene, camera)
  // don't forget to run update()
  panoControl.update()
  window.requestAnimationFrame(animate)
}

animate()

react

import * as React from "react"
import * as THREE from "three"
import PanoControls from "pano-controls"

const { useState, useRef, useEffect } = React

// ...

function WhatEverComponent() {
  const containerRef = useRef()
  
  // PerspectiveCamera is supported only
  const camera = new THREE.PerspectiveCamera(/* ... */)

  useEffect(() => {
    if(containerRef) {
      const control = new PanoControls(camera, containerRef.current)

      control.h   = whatEverYouWant
      control.v   = whatEverYouWant
      control.fov = whatEverYouWant
      // updateCamera after reset h / v / fov
      control.updateCamera()

      return () => {
        // important!
        control.removeEvents()
      }
    }
  }, [containerRef])

  return <div ref={containerRef} style={{
    width: "100%",
    height: "100%",
  }} />
}

// don't forget to run update()

script

<canvas id="canvas" style="width: 100%; height: 100%;" />

<script src="path/to/three.min.js" />
<!-- 本包有一个依赖包, 名为 "tang-pano", 需要手动下载 -->
<script src="path/to/tang-pano/dist/index.min.js" />
<script src="path/to/pano-controls/dist/index.min.js" />

<script>
  // ...
  
  var PanoControls = window.PanoControls

  // same as js/ts
  var panoControl = new PanoControls(camera, container)
</script>

default values

panoControl.minH   = -180
panoControl.maxH   = 180
panoControl.minV   = EPS // EPS = 0.000001, as bugs occur while v === 0 or 180
panoControl.maxV   = 180 - EPS
panoControl.minFov = 40
panoControl.maxFov = 140

panoControl.enabled = true
panoControl.enableLooped = true
panoControl.enableScale  = true
panoControl.enableRotate = true
panoControl.enableScaleDamping  = true
panoControl.enableRotateDamping = true
panoControl.enableAutoRotate = false

panoControl.scaleSpeed  = -100
panoControl.rotateSpeed = 120
panoControl.scaleSmoothFactor  = 0.9  // 0 ~ 1
panoControl.rotateSmoothFactor = 0.9  // 0 ~ 1
panoControl.autoRotateSpeed = -0.05
panoControl.autoRotateInterval = 15000 // ms

Events

PanoControls extends https://github.com/Wolfy87/EventEmitter

change: while h / v / fov has changed

rotate: while h / v has changed

scale: while fov has changed

interact: while h / v / fov has changed caused by user action

License

MIT