Giter Site home page Giter Site logo

mchlggr / three-mesh-ui Goto Github PK

View Code? Open in Web Editor NEW

This project forked from felixmariotto/three-mesh-ui

0.0 0.0 0.0 14.48 MB

⏹ Make VR user interfaces for Three.js

Home Page: https://felixmariotto.github.io/three-mesh-ui/#basic_setup

License: MIT License

JavaScript 97.86% HTML 2.14%

three-mesh-ui's Introduction

three-mesh-ui

buttons example tuto example big text example big text example

📢 7.x.x is in evaluation, check it out here felixmariotto#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 ⚠️ It requires three as peer dependency

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>

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

💪 You can use the minified version named three-mesh-ui.min.js (codesandbox demo)
⚠️ 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();

three-mesh-ui's People

Contributors

felixmariotto avatar swingingtom avatar trusktr avatar dependabot[bot] avatar enijar avatar hybridherbst avatar corecode1 avatar saitonakamura avatar kalegd avatar joecoppola-hia avatar sylwesterdigital avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.