# fairygui-three

> A GUI Editor & framework for three.js

Latest version **1.0.1** (published 2024-07-08) · MIT license · 0 weekly downloads

## Install

```sh
npm install fairygui-three
pnpm add fairygui-three
yarn add fairygui-three
bun add fairygui-three
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2024-07-08 |
| First published | 2020-06-09 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 5.2 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 294 |
| Author | guzhu |
| Maintainers | guzhu |
| Keywords | three, three.js, fairygui, fgui, gui |

## Links

- npm: https://www.npmjs.com/package/fairygui-three
- Repository: https://github.com/fairygui/FairyGUI-threejs
- Homepage: https://fairygui.com/
- Issues: https://github.com/fairygui/FairyGUI-threejs/issues
- npm.io page: https://npm.io/package/fairygui-three

## Dependencies (1)

- [@types/node](https://npm.io/package/@types/node.md) ^14.0.1

## Recent versions

- 1.0.1 (latest) — 2024-07-08
- 0.9.2 — 2022-05-18
- 0.9.1 — 2021-06-29
- 0.9.0 — 2021-06-29
- 0.8.0 — 2021-06-11
- 0.7.0 — 2021-04-30
- 0.6.0 — 2021-03-28
- 0.5.1 — 2020-08-27
- 0.5.0 — 2020-08-27
- 0.4.0 — 2020-06-29
- 0.3.1 — 2020-06-15
- 0.3.0 — 2020-06-11
- 0.2.0 — 2020-06-11
- 0.1.1 — 2020-06-09
- 0.1.0 — 2020-06-09

## README

# FairyGUI-three

#### A GUI Editor&amp;framework for Three.js ####

Official website: [www.fairygui.com](https://www.fairygui.com)

### Usage ###

Step 1, we use the editor to create the UI.

![](images/20200610-084916.png)

Step 2, we only need a little code to display it.

```javascript
import * as fgui from "fairygui-three";

var renderer;
var scene;
var view;

init();
animate();

function init() {
    //THREE initialization code here

    fgui.Stage.init(renderer, { screenMode:'horizontal' });  //screenMode is optional if you dont want to rotate the screen 
    fgui.Stage.scene = scene;

    fgui.UIPackage.loadPackage('path/to/UI').then(()=> {
        view = fgui.UIPackage.CreateObject('Basics', 'Main');
        view.makeFullScreen();
        fgui.GRoot.inst.addChild(view);
    });
}

function animate() {

    requestAnimationFrame( animate );

    fgui.Stage.update();
    renderer.render(scene, fgui.Stage.camera);
}
```

You should see [this](https://fairygui.com/threejs-demo/main/)

In the example above, an UI is created and displayed by an orthographic camera (fgui.Stage.camera) . It's easy to display UI by an specific perspective camera.

```javascript
import * as fgui from "fairygui-three";

var renderer;
var scene;
var camera;
var view;

init();
animate();

function init() {
    //THREE initialization code here

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

    fgui.Stage.init(renderer);
    fgui.Stage.scene = scene;

    fgui.UIPackage.loadPackage('path/to/UI').then(()=> {
        view = fgui.UIPackage.CreateObject('3DInventory', 'Main');
        view.displayObject.camera = camera;
        view.displayObject.setLayer(0);

        let container = new Group();
        container.scale.set(0.5, 0.5, 0.5);
        container.add(view.obj3D);
        scene.add(container);
    });
}

function animate() {

    requestAnimationFrame( animate );

    fgui.Stage.update();
    renderer.render(scene, camera);
}
```

You should see [this](https://fairygui.com/threejs-demo/3d/)

If a perspective camera is using for all UI,

```javascript
    Stage.init(renderer, { defaultLayer:0 });
    Stage.camera = yourCamera;
```

# License
MIT

---
_Source: https://npm.io/package/fairygui-three · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
