Socket
Socket
Sign inDemoInstall

three-x3

Package Overview
Dependencies
2
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    three-x3

An interactive plug-and-play debugger and inspector for the Three.js JavaScript 3D library.


Version published
Weekly downloads
5
decreased by-44.44%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

Three.js x3

An interactive plug-and-play debugger and inspector for the Three.js JavaScript 3D library.

  • UMD Setup
  • window Setup
  • Documentation

Three.js x3 demonstration

UDM Setup

yarn add three three-x3

npm install three three-x3
import * as THREE from 'three';
import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls'
import THREEx3 from 'three-x3';

const x3 = new THREEx3(
  { THREE, OrbitControls, camera, renderer, scene }
);

x3.add(focusLight);
x3.add(light);
x3.add(cube, { label: 'Cube' });
x3.add(camera);

renderer.setAnimationLoop(() => {
  cube.rotation.x += 0.01; cube.rotation.y += 0.01;

  x3.tick();

  x3.fps(() => {
    renderer.render(scene, camera);
  });
});

window Setup

<script src="https://cdn.jsdelivr.net/npm/three@0.126.1/build/three.min.js" integrity="sha256-RhW9lLg3YYVh/c3z+9Q8cUD5GFShsH1f7mR0lvCROpk=" crossorigin="anonymous"></script>

<script src="https://cdn.jsdelivr.net/npm/three@0.126.1/examples/js/controls/OrbitControls.js" integrity="sha256-+ncCNttOcMopCUa47Sn26Tg06ZC2SnWoi/XikKAhnSY=" crossorigin="anonymous"></script>

<script src="https://cdn.jsdelivr.net/npm/three-x3@0.0.2/dist/x3-standalone.js" integrity="sha256-0ExWK4qAjoTCSQ2V15Z2tcdiRHexpO8qrOUNCGAWMC0=" crossorigin="anonymous"></script>
const x3 = new THREEx3(
  {
    THREE, OrbitControls: THREE.OrbitControls,
    camera, renderer, scene,
  }
);

x3.add(focusLight);
x3.add(light);
x3.add(cube, { label: 'Cube' });
x3.add(camera);

renderer.setAnimationLoop(() => {
  cube.rotation.x += 0.01; cube.rotation.y += 0.01;

  x3.tick();

  x3.fps(() => {
    renderer.render(scene, camera);
  });
});

Documentation

new

const x3 = new THREEx3(
  {
    THREE: THREE, OrbitControls: THREE.OrbitControls,
    camera: camera, renderer: renderer, scene: scene,
  },
  options
);

options parameter for new THREEx3:

PropertyPossible ValuesInfo
orbittrue falseOrbitControls
gridtrue false { visible: true, size: 10, divisions: 10 } { visible: false }GridHelper
axestrue false { visible: true, size: 5 } { visible: false }AxesHelper

add

Add a controller for the object:

x3.add(light, options);
x3.add(cube, options);
x3.add(camera, options);

options parameter for add:

PropertyPossible ValuesInfo
label'Some Label'Label for the folder.
helpertrue false { visible: true } { visible: false }Helper for lights. e.g. PointLightHelper
opentrue falseTells whether the folder should be closed or open.
xyz['position', 'rotation', 'scale']An array with the properties to show .x .y .z controls.

tick

Must run inside setAnimationLoop:

renderer.setAnimationLoop(() => {
  x3.tick();
  
  renderer.render(scene, camera);
});

fps

Displays a Performance Monitor with FPS (frames per second):

renderer.setAnimationLoop(() => {
  x3.tick();
  
  x3.fps(() => {
    renderer.render(scene, camera);
  });
});

Keywords

FAQs

Last updated on 14 Mar 2021

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc