How to use the ShaderLib function from three

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

24
25
26
27
28
29
30
31
32
33
const opacities = (config.opacities && config.opacities.data
    && config.opacities.data.length === positions.length / 3) ? config.opacities.data : null;
const sizes = (config.point_sizes && config.point_sizes.data
    && config.point_sizes.data.length === positions.length / 3) ? config.point_sizes.data : null;
const {colorsToFloat32Array} = buffer;
const phongShader = THREE.ShaderLib.phong;
let i;
const boundingBoxGeometry = new THREE.BufferGeometry();
const geometry = new THREE.IcosahedronBufferGeometry(config.point_size * 0.5, meshDetail);
const colorMap = (config.color_map && config.color_map.data) || null;
fork icon115
star icon803
watch icon0

56
57
58
59
60
61
62
63
64
65
    side: THREE.DoubleSide,
  });
}

function createSnowMaterial() {
  const shaderPoint = THREE.ShaderLib.points;
  const uniforms = {
    ...shaderPoint.uniforms,
    iTime: { value: 0 },
    pSize: { value: 10 },
fork icon9
star icon77
watch icon5

+ 5 other calls in file

14
15
16
17
18
19
20
21
22
23
constructor(parameters) {

    parameters = parameters || {};

    parameters.uniforms = three.UniformsUtils.merge([
        three.ShaderLib.normal.uniforms,
        { linearize_depth: { value: parameters.linearize_depth ?? true } }
    ]);
    parameters.vertexShader = 'varying mat4 vProjectionMatrix;' + '\n'
        + three.ShaderLib.normal.vertexShader.replace(
fork icon0
star icon0
watch icon0

+ 39 other calls in file

161
162
163
164
165
166
167
168
169
170


// ADD SKYBOX TO SCENE WITH MATERIAL
////////////////////

var shader = THREE.ShaderLib.cube;
shader.uniforms.tCube.value = skyMaterials[currentBackground]['textureCube'];
var material = new THREE.ShaderMaterial( {

    fragmentShader: shader.fragmentShader,
fork icon0
star icon0
watch icon2

15
16
17
18
19
20
21
22
23
}

module.exports = function (scene) {
    textureCube = THREE.ImageUtils.loadTextureCube( ['images/skyboxes/bigCube/smaller.jpg','images/skyboxes/bigCube/smaller.jpg','images/skyboxes/bigCube/smaller.jpg','images/skyboxes/bigCube/smaller.jpg','images/skyboxes/bigCube/smaller.jpg','images/skyboxes/bigCube/smaller.jpg'], new THREE.CubeRefractionMapping());

    shader = THREE.ShaderLib.cube;
    shader.uniforms.tCube.value = textureCube;

    material = new THREE.ShaderMaterial( {
fork icon0
star icon0
watch icon2

Other functions in three

Sorted by popularity

function icon

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