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

three-wheel-menu

v0.0.6

Published

rotation menu with three.js

Downloads

2

Readme

DEMO

wheel_menu

Usage

import * as THREE from 'three'
import WheelMenu from 'three-wheel-menu'

const items = [
  {name: 'Skill'},
  {name: 'Profile'},
  {name: 'Work'},
];

const wheelMenu = new WheelMenu({
  THREE, // It's not necessary if you use CDN
  scene,
  canvas,
  camera,
  radius: 150,
  origin: {x: 0, y: 0, z: 0},
  rotation: {x: 0, y: 1.64, z: 0},
  items,
  onClick,
});

tick();
function tick() {
  wheelMenu.tick();
  requestAnimationFrame(tick);
}

Parameter

  new WheelMenu(
    THREE, // import * as THREE from 'three'
    scene, // THREE.Scene()
    camera, // THREE.PerspectiveCamera
    canvas, // canvas element
    options // optional values
  )

| name | type | description | -- | -- | -- | items | Array<HTMLCanvasElement | {name: string, width: number, height: number, color: string, fillStyle: string, font: string,fontSize: number, padding: number}> | menu items. default value is {width: 300,height: font height, color: '#000000',fillStyle: '#ffffff',font: 'Bold sans-serif',fontSize: 20,padding: 10,} | | radius | number | radius of menu | | origin | {x: number, y: number, z: number} | origin of menu. | | rotation | {x: number, y: number, z: number} | rotation of menu. number is rad. (±0~2π) | | onClick | function | function that is executed when item is clicked. argument: onClick({name: string, ...}, Three.Sprite) | | onMoved | function | function that is executed when item moved to selected position. argument: onClick({name: string, ...}, Three.Sprite) | | selected | HTMLCanvasElement | {name: string, ...} | default selected item. | | isBidirectional | bool | flag that decide rotation direction bidirect or unidirect. | | isReverse | bool | flag that rotation direction. | | selectedRotation | number | digree when item selected. (±0~360) |

Sample

Use image

const img = new Image()
const canvas1 = document.createElement('canvas')
const context = canvas.getContext('2d')

canvas1.setAttribute('id', 'item1') // add id if you use `selected`

await new Promise(resolve => {
  img.onload = function(res) {
    console.log(img.width)
    canvas.width = img.width/2
    canvas.height = img.height/2
    context.drawImage(img, 0, 0, img.width/2, img.height/2);
    resolve()
  }
  img.src = '/image/path';
})

const items = [canvas1, image2, ...]

Use html element

import html2canvas from 'html2canvas'

const target = document.getElementById('item1')
const element1 = await new Promise((res) => {
  html2canvas(target).then(function(c) {
    c.setAttribute('id', target.getAttribute('id')) // add id if you use `selected`
    res(c)
  });
})

const items = [element1, element2, ...]
<div style="height: 0px; overFlow: 'hidden';">
  <div id="item1">dom element1</div>
  <div id="item2">dom element2</div>
  <div id="item3">dom element3</div>
  <div id="item4">dom element4</div>
</div>
#menu1 {
  width: 180px;
  height: 50px;
  line-height: 50px;
  text-align: center;
  font-size: 20px;
  background: linear-gradient(90deg, rgba(3,255,231,1) 0%, rgba(255,255,255,0.580392156862745) 81%);
  border-radius: 10px;
}