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-creative-controls

v1.0.1

Published

Three.js noclip camera controls that feel similar to minecraft creative mode

Downloads

11

Readme

Three Creative Controls

Three.js noclip camera controls that feel similar to minecraft creative mode. Based on PointerLockControls.

Install using npm:

npm i three-creative-controls

Usage

Import the module

import * as THREE from "three";
import { CreativeControls } from "three-creative-controls"

Reference a blocker and menu screen from your html in your code. Create a CreativeControls object and provide your scene camera, renderer and both the menu and blocker element. Define the movement speed for the controls as a Vector3 object. Default is 200, 200, 200

const blocker = document.getElementById('blocker');
const menu = document.getElementById('menu');

const creativeControls = CreativeControls.Controls(camera, renderer.domElement, menu, blocker);
const creativeControlsSpeed = new Vector3(200, 200, 200);

Run the CreativeControls update function to keep your controls object updated. Pass your controls object and the desired speed vector as parameters.

const animate = () => {
  requestAnimationFrame(animate);
  renderer.render(scene, camera);
  
  CreativeControls.update(creativeControls, creativeControlsSpeed);
};

Blocker and Menu element

The Blocker element is used as an overlay for your current scene to make the menu more visible. The Menu could feature whatever you want. The sample menu down below just displays the controls.

<div id="blocker">
  <div id="menu">
    <p style="font-size: 36px; color: white">
      Click to play
    </p>
    <p style="font-size: 24px; color: white">
      Move: WASD<br/>
      Fly up: SPACE<br/>
      Fly down: SHIFT
    </p>
  </div>
</div>

Styling for the sample blocker and menu:

#blocker {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0,0,0,0.8);
}

#menu {
  width: 100%;
  height: 100%;

  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;

  text-align: center;
  font-size: 14px;
  cursor: pointer;
}

Crosshair

Feel free to add a crosshair to your scene if necessary. The easiest approach is the following:

<body>
  <div id="crosshair">
    <img id="crosshairImage" src="./images/crosshair.svg"/>
  </div>
</body>

Styling of the crosshair vector graphic:

#crosshair {
  position: fixed;
  pointer-events: none;
  width: 100%;
  height: 100%;

  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;

  text-align: center;
}

#crosshairImage {
  width: 1.5%;
  opacity: 0.8;
  object-fit: cover;
}

Refer to the demo if you have any questions.

Run the Demo

Clone the repository and run

npm i
npm start

The example is available under localhost:3000

image