How to use the InstancedBufferAttribute function from three

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

66
67
68
69
70
71
72
73
74
75
        high: {value: colorRange[1]},
        colormap: {type: 't', value: colormap},
    };
    geometry.setAttribute(
        'attributes',
        new THREE.InstancedBufferAttribute(attribute, 1).setUsage(THREE.DynamicDrawUsage),
    );
} else {
    colors = (pointColors && pointColors.length === positions.length / 3
            ? colorsToFloat32Array(pointColors) : getColorsArray(color, positions.length / 3)
fork icon115
star icon803
watch icon0

+ 5 other calls in file

185
186
187
188
189
190
191
192
193
194
    }
  }
}

let offsets = new THREE.InstancedBufferAttribute(new Float32Array(blockData.n_tx * 2), 2)
let scales = new THREE.InstancedBufferAttribute(new Float32Array(blockData.n_tx), 1)

for (let i = 0; i < blockData.n_tx; i++) {
// if (typeof blockData.tx[i] === 'undefined') {
//   continue
fork icon17
star icon126
watch icon10

+ 23 other calls in file

26
27
28
29
30
31
32
33
34
35
// Setting BufferAttribute
const baseGeometry = new THREE.OctahedronBufferGeometry(30, 4);
geometry.copy(baseGeometry);

// Setting InstancedBufferAttribute
const radian = new THREE.InstancedBufferAttribute(new Float32Array(this.instances), 1);
const hsv = new THREE.InstancedBufferAttribute(new Float32Array(this.instances * 3), 3);
const noiseDiff = new THREE.InstancedBufferAttribute(new Float32Array(this.instances), 1);
const speed = new THREE.InstancedBufferAttribute(new Float32Array(this.instances), 1);
for (var i = 0; i < this.instances; i++) {
fork icon260
star icon0
watch icon0

+ 7 other calls in file

17
18
19
20
21
22
23
24
25
26
const geometry = new THREE.InstancedBufferGeometry();
const baseGeometry = new THREE.BoxGeometry(40, 1, 10);
geometry.copy(baseGeometry);

const height = new THREE.InstancedBufferAttribute(new Float32Array(this.instances), 1);
const offsetX = new THREE.InstancedBufferAttribute(new Float32Array(this.instances), 1);
for ( var i = 0, ul = this.instances; i < ul; i++ ) {
  height.setXYZ(i, (i + 1) * 150 + 200);
  offsetX.setXYZ(i, (i - (this.instances - 1) / 2) * 120);
}
fork icon260
star icon0
watch icon0

3428
3429
3430
3431
3432
3433
3434
3435
3436
3437

    //let aCurveFloat32 = new Float32Array(aCurve);
    //console.log(mesh, mesh.geometry);
    //this.scene.children[0].geometry.setAttribute(
    //  "aCurve",
    //  new THREE.InstancedBufferAttribute(aCurveFloat32, 3, false)
    //);
}
if(this.box.length==2){
    for (let i = 0; i < mesh.count; i++) {
fork icon3
star icon7
watch icon0

+ 35 other calls in file

3430
3431
3432
3433
3434
3435
3436
3437
3438
    }
    let aCurveFloat32 = new Float32Array(aCurve);
    //console.log(mesh, mesh.geometry);
    this.scene.children[0].geometry.setAttribute(
      "aCurve",
      new THREE.InstancedBufferAttribute(aCurveFloat32, 2, false)
    );
    
}
fork icon3
star icon7
watch icon0

+ 33 other calls in file

144
145
146
147
148
149
150
151
152
153
let aStateFloat32 = new Float32Array(aState);


instancedGeometry.setAttribute(
      "aState",
      new THREE.InstancedBufferAttribute(aStateFloat32, 2, false)
    );

for (let i = 0; i < instanceCount; i++) {
  aCurve.push(this.pos[i][0], this.pos[i][1], 0.0);
fork icon3
star icon7
watch icon0

+ 15 other calls in file

406
407
408
409
410
411
412
413
414
415
const array = new cons( count * itemSize );
let newAttribute;

if ( attribute.isInstancedInterleavedBufferAttribute ) {

    newAttribute = new THREE.InstancedBufferAttribute( array, itemSize, normalized, attribute.meshPerAttribute );

} else {

    newAttribute = new THREE.BufferAttribute( array, itemSize, normalized );
fork icon2
star icon10
watch icon0

382
383
384
385
386
387
388
389
390
391
392
const SHUTTER_STROBE_FREQUENCIES_DEFAULT = {
  SLOW: 1,
  FAST: 10
}


var position_buffer_attribute = new THREE.InstancedBufferAttribute(new Float32Array(MAX_INSTANCES * 3), 3).setDynamic(true)
var direction_buffer_attribute = new THREE.InstancedBufferAttribute(new Float32Array(MAX_INSTANCES * 3), 3).setDynamic(true)
var intensity_buffer_attribute = new THREE.InstancedBufferAttribute(new Float32Array(MAX_INSTANCES), 1).setDynamic(true)
var color_buffer_attribute = new THREE.InstancedBufferAttribute(new Float32Array(MAX_INSTANCES * 3), 3).setDynamic(true)
var emissive_buffer_attribute = new THREE.InstancedBufferAttribute(new Float32Array(MAX_INSTANCES), 1).setDynamic(true)
fork icon0
star icon7
watch icon0

+ 23 other calls in file

Other functions in three

Sorted by popularity

function icon

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