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-mesh-ui

v6.5.4

Published

a library on top of three.js to help in creating 3D user interfaces

Downloads

13,541

Readme

three-mesh-ui

Examples (live)  |  NPM  |  Documentation  |  Contributing

📢 7.x.x is in evaluation, check it out here https://github.com/felixmariotto/three-mesh-ui/pull/223

What is it ?

three-mesh-ui is a small library for building VR user interfaces. The objects it creates are three.object3Ds, usable directly in a three.js scene like any other Object3D.

It is not a framework, but a minimalist library to be used with the last version of three.js. It has no dependency but three.js.

Why ?

In a normal three.js workflow, the common practice is to build user interfaces with HTML/CSS.

In immersive VR, it is impossible, therefore this library was created.

Quick Start

Try it now

Give it a try in this jsFiddle

Using react-three-fiber ? Here is a codesandbox to get started.

Import

JSM

With NPM

npm install three-mesh-ui :warning: It requires three as peer dependency

ES6 (codesandbox demo)
import ThreeMeshUI from 'three-mesh-ui'
CommonJS
const ThreeMeshUI = require('three-mesh-ui');
HTML <script> tag (codesandbox demo)
 <!-- Defines the import map -->
<script async src="https://unpkg.com/[email protected]/dist/es-module-shims.js"></script>
<script type="importmap">
{
    "imports": {
        "three": "https://unpkg.com/[email protected]/build/three.module.js",
        "three-mesh-ui": "https://unpkg.com/[email protected]/build/three-mesh-ui.module.js"
    }
}
</script>

<!-- Then we can code our app -->
<script type="module">
    import * as THREE from "three";
    import * as ThreeMeshUI from "three-mesh-ui";

    // code goes here ...
</script>

:muscle: You can use the minified version named three-mesh-ui.module.min.js (codesandbox demo)

JS

HTML <script> tag (codesandbox demo)

<!-- As three-mesh-ui has a peer dependency on three.js -->
<!-- Be sure to load three before three-mesh-ui -->
<script src="https://unpkg.com/[email protected]/build/three.js"></script>

<script src="https://unpkg.com/[email protected]/build/three-mesh-ui.js"></script>

<!-- Then we can code our app -->
<script>
    /* global THREE, ThreeMeshUI */

    // code goes here ...
</script>

:muscle: You can use the minified version named three-mesh-ui.min.js (codesandbox demo)
:warning: Although this would theorically allows you to build 'something', loading js libraries instead of using jsm, might restrict the global features you would have. This is true for both three and three-mesh-ui libraries.

Font files

In order to display some text with three-mesh-ui, you will need to provide font files.
You can use the two files named Roboto-msdf in this directory, or create your own font files

API

Here is an example of basic three-mesh-ui usage :

const container = new ThreeMeshUI.Block({
 width: 1.2,
 height: 0.7,
 padding: 0.2,
 fontFamily: './assets/Roboto-msdf.json',
 fontTexture: './assets/Roboto-msdf.png',
});

//

const text = new ThreeMeshUI.Text({
 content: "Some text to be displayed"
});

container.add( text );

// scene is a THREE.Scene (see three.js)
scene.add( container );

// This is typically done in the render loop :
ThreeMeshUI.update();