How to use the js function from three

Find comprehensive JavaScript three.js code examples handpicked from public code repositorys.

8
9
10
11
12
13
14
15
16
17
18
 * @property {{r:number,g:number,b:number}} sky.color - rgb color (value are between [0,1])
 * @property {{offset:number,phi:number,theta:number}} sky.sun_position - position of the sun in sheprical coord (phi theta) + an offset {@link THREEUtil.bindLightTransform}
 */


/**
 * Set of function for a high level use of THREE.js
 */
module.exports = {
  /**
   *  Default scene 3D config
fork icon15
star icon10
watch icon0

+ 4 other calls in file

11
12
13
14
15
16
17
18
19
20

// other
window.d3Chromatic = require('d3-scale-chromatic');
window.MeshLine = require('three.meshline');

// scene manager handles all things THREE.js
const SceneManager = require('./src/scene-manager');

// init the scene manager
const canvas = document.getElementById("canvas");
fork icon1
star icon8
watch icon2

50
51
52
53
54
55
56
57
58
59
  const g = Math.min(255, 50 + ((i * 52973) % 256));
  const b = Math.min(255, 50 + ((i * 44111) % 256));
  return { r: r / 255, g: g / 255, b: b / 255 };
}
componentDidMount() {
  // Try to start up THREE.js
  if (ChaosRenderer.isWebGLAvailable()) {
    // Renderer and canvas
    const { element, props } = this;
    const renderer = new THREE.WebGLRenderer({
fork icon0
star icon8
watch icon0

166
167
168
169
170
171
172
173
174
175
  key: "getWindowSize",
  value: function getWindowSize() {
    return new THREE.Vector2(this.width, this.height);
  }
  /**
   * return renderer THREE.js
   * @returns {undefined|THREE.WebGLRenderer}
   */

}, {
fork icon0
star icon1
watch icon0

219
220
221
222
223
224
225
226
227
228
* @param {?MainLoop} options.mainLoop - {@link MainLoop} instance to use, otherwise a default one will be constructed
* @param {?(WebGLRenderer|object)} options.renderer - {@link WebGLRenderer} instance to use, otherwise
* a default one will be constructed. In this case, if options.renderer is an object, it will be used to
* configure the renderer (see {@link c3DEngine}.  If not present, a new <canvas> will be created and
* added to viewerDiv (mutually exclusive with mainLoop)
* @param {boolean} [options.renderer.isWebGL2=true] - enable webgl 2.0 for THREE.js.
* @param {?Scene} [options.scene3D] - [THREE.Scene](https://threejs.org/docs/#api/en/scenes/Scene) instance to use, otherwise a default one will be constructed
* @param {?Color} options.diffuse - [THREE.Color](https://threejs.org/docs/?q=color#api/en/math/Color) Diffuse color terrain material.
* This color is applied to terrain if there isn't color layer on terrain extent (by example on pole).
*
fork icon0
star icon1
watch icon0

0
1
2
3
4
5
6
7
8
9
/** @format */

const THREE = require('three');

/**
 * Set of class/function for a high level use of THREE.js
 */
module.exports = {
  /**
   * Texture encoding used to have the right color of the .glb model + have an alpha channel
fork icon0
star icon1
watch icon2

Other functions in three

Sorted by popularity

function icon

three.Vector3 is the most popular function in three (22341 examples)