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-musketeers

v0.11.0

Published

[![Build Status](https://travis-ci.org/webgl/three-musketeers.svg?branch=master)](https://travis-ci.org/webgl/three-musketeers) [![npm](https://img.shields.io/npm/v/three-musketeers.svg)](https://www.npmjs.com/package/three-musketeers)

Downloads

193

Readme

three musketeers

Build Status npm

"All for one. One for all."

This module serves as an intuitive tool to introspect, debug and test any THREE.js application.

GitHubDocumentationExamplesDemo

Demo

IMAGE ALT TEXT HERE

Usage

Download the minified library and include it in your HTML, or install and import it as a npm module.

$ npm i three-musketeers

The code below creates a scene, a camera, and a geometric cube, and it adds the cube to the scene. It then creates a WebGL renderer for the scene and camera, and it adds that viewport to the document.body element. Finally, it animates the cube within the scene for the camera.

Lastly, we simply pass the necessary resources to the musketeers instance and attach it to our window via the alias $$$ for experimentation:

// sample application
import * as THREE from 'three';
import musketeers from 'three-musketeers';

init();

function init() {
  const { innerWidth, innerHeight } = window;
  const scene = new THREE.Scene();

  const renderer = new THREE.WebGLRenderer({ antialias: true });
  renderer.setSize(innerWidth, innerHeight);
  document.body.appendChild(renderer.domElement);

  const camera = new THREE.PerspectiveCamera(70, innerWidth / innerHeight, 0.01, 10);
  camera.position.z = 1;
  scene.add(camera);

  const mesh = new THREE.Mesh(
    new THREE.BoxGeometry(0.2, 0.2, 0.2),
    new THREE.MeshBasicMaterial({ color: 0xFF0000 })
  );
  // assign a unique name to our mesh to be able to query it later
  mesh.name = 'CUBE_1';
  scene.add(mesh);

  renderer.render(scene, camera);

  // attach $$$ to the window for browser debugging
  window.$$$ = musketeers({ renderer, scene, camera });
}

Now, you can inspect the scene through the window object:

// javascript console in the browser

$$$
.debug() // enable visual debug mode
.isValid(); // true
$$$
.find('Cube_1') // the unique identifier we assigned to our mesh
.exists(); // true
$$$
.findAll((node) => node.geometry.type === 'BoxGeometry') // returns an array of items of this type
$$$
.find('Cube_1')
.click(); // locates the item in the 3D scene and clicks the item
window.addEventListener('click', (event) => {
  // find all intersected items on 'click'
  const intersectedItems = $$$.pickFromEvent(event);
  console.log(intersectedItems); // useful for debugging
});

Check out the documentation for more details. You can also check out the example testing a 3D application with selenium.

# running and testing the example 3d application

$ npm run selenium
$ npm run start
$ npm run test:e2e

Contribute

I welcome contributors. Please contribute if you have ideas to improve this library. Please use GitHub's pull request and issues features. You can also help implement upcoming features from the TODO page. Feel free to reach out if you'd like more context or info for implementation details.

Here are a few scripts to help you get started:

| NPM Commands | Description | | ------------ | --------------------------------------------------------- | | start | Runs the examples for development | | test | Runs unit tests for the module | | build | Builds the module | | docs | Updates the documentation | | components | Updates the component entry points | | selenium | Runs selenium | | test:e2e | Runs e2e automated testing for the examples as an example |

Other Resources

Three.js QuestionsThree.js ForumThree.js GitterThree.js Slack