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

threex.domevents

v1.0.1

Published

threex.domevents ================

Downloads

24,444

Readme

threex.domevents

threex.domevents is a three.js extension which provide dom events inside your 3d scene. Always in a effort to stay close to usual pratices, the events name are the same as in DOM. The semantic is the same too, which makes it all very easy to learn. Currently, the available events are click, dblclick, mouseup, mousedown, mouseover and mouse out.

Show Don't Tell

How To Install It

You can install it via script tag

<script src='threex.domevents.js'></script>

Or you can install with bower, as you wish.

bower install threex.domevents

How To Use It

Let's start by bindinf dom events like on 3d objects.

THREEx.DomEvent.js

First you need to instanciate the layer, like this.

var domEvents	= new THREEx.DomEvents(camera, renderer.domElement)

Always in a effort to stay close to usual pratices, the events name are the same as in DOM. The semantic is the same too. Currently, the available events are click, dblclick, mouseup, mousedown, mouseover and mouse out. Then you bind an event on a mesh like this

domEvents.addEventListener(mesh, 'click', function(event){
	console.log('you clicked on the mesh')
}, false)

You can remove an event listener too, here is the whole cycle

// define the callback
function callback(event){
	console.log('you clicked on the mesh')	
}

// add an event listener for this callback
domEvents.addEventListener(mesh, 'click', callback, false)

// remove an event listener for this callback
domEvents.removeEventListener(mesh, 'click', callback, false)

If the camera changes, you can use domEvents.camera(camera) to set the new one. Now that you got the

THREEx.Linkify.js

This helper will linkify any object3d you got. Here linkify is the fact to act as a <a> tag would behave. If you hover the mouse over it, the pointer is changed to become an hand, and you got text decoration. If you click on the object, it will open a new tab with the url your specified. It is that simple.

var url		= 'http://jeromeetienne.github.io/threex/'
var linkify	= THREEx.Linkify(domEvents, mesh, url, true)

The parameters are

  • domEvents: an instance of THREEx.DomEvents
  • mesh: an instance of THREE.Mesh
  • url: a string of the url
  • withBoundingBox: true if you bind the bounding box and not the mesh itself. It may be useful when your mesh is complex. useful because it is faster to test for simple mesh, usefull as it make the detections less flacky for the users for complex meshes.

Additionnaly you can use linkify.destroy() to stop listening on those events. The exposed properties are

  • linkify.underline is the mesh for the underline
  • linkify.eventTarget is the model on which the domEvents are bound

TODO

  • find a good demo
    • test all events in the demo
    • why not the usual teapots ones ?