a library on top of three.js to help in creating 3D user interfaces
npm install three-mesh-uiš¢ 7.x.x is in evaluation, check it out here https://github.com/felixmariotto/three-mesh-ui/pull/223
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.
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.
Give it a try in this jsFiddle
Using react-three-fiber ? Here is a codesandbox to get started.
npm install three-mesh-ui##### ES6 (codesandbox demo)
``javascript`
import ThreeMeshUI from 'three-mesh-ui'
##### CommonJS
`javascript`
const ThreeMeshUI = require('three-mesh-ui');
##### HTML <script> tag (codesandbox demo)
`html
`
:muscle: You can use the minified version named __three-mesh-ui.module.min.js__ (codesandbox demo)
html
`
: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 filesAPI
Here is an example of basic three-mesh-ui usage :
`javascript
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();
``