matrix4().applyToBufferAttribute() not working

Description of the problem

I dont seem to detect a change in array when i apply a matrix to the array.

var test = new THREE.BoxBufferGeometry(2, 2, 2).attributes.position.array.slice(0);
console.log(test)
var test1 = new THREE.Matrix4().makeTranslation(3, 3, 3).applyToBufferAttribute(test);
console.log(test1, test);

http://jsfiddle.net/xgf1v2L5/

Three.js version
  • Dev
  • [x ] r84
Browser
  • All of them
  • [x ] Chrome
  • Firefox
  • Internet Explorer
OS
  • All of them
  • Windows
  • macOS
  • Linux
  • Android
  • iOS
Hardware Requirements (graphics card, VR Device, …)

Author: Fantashit

2 thoughts on “matrix4().applyToBufferAttribute() not working

  1. Pass attribute, not array, to .applyToBufferAttribute.

    var test = new THREE.BoxBufferGeometry(2, 2, 2).attributes.position;
    console.log(test.array)
    var test1 = new THREE.Matrix4().makeTranslation(3, 3, 3).applyToBufferAttribute(test);
    console.log(test1.array);
    
    Float32Array(72) [1, 1, 1, 1, 1, -1, 1, -1, 1, 1, -1, -1, -1, 1, -1, -1, 1, 1, -1, -1, -1, -1, -1, 1, -1, 1, -1, 1, 1, -1, -1, 1, 1, 1, 1, 1, -1, -1, 1, 1, -1, 1, -1, -1, -1, 1, -1, -1, -1, 1, 1, 1, 1, 1, -1, -1, 1, 1, -1, 1, 1, 1, -1, -1, 1, -1, 1, -1, -1, -1, -1, -1]
    Float32Array(72) [4, 4, 4, 4, 4, 2, 4, 2, 4, 4, 2, 2, 2, 4, 2, 2, 4, 4, 2, 2, 2, 2, 2, 4, 2, 4, 2, 4, 4, 2, 2, 4, 4, 4, 4, 4, 2, 2, 4, 4, 2, 4, 2, 2, 2, 4, 2, 2, 2, 4, 4, 4, 4, 4, 2, 2, 4, 4, 2, 4, 4, 4, 2, 2, 4, 2, 4, 2, 2, 2, 2, 2]
    
  2. Data in a buffers are not always organized in a straightforward sequence. They can have different layouts like e.g. interleaved buffers. Working with buffer attributes provide a thin abstraction over these “low-level” implementation details.

Comments are closed.