How to use the aframe/src.THREE.BufferAttribute function in aframe

To help you get started, we’ve selected a few aframe examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github kabbi / zanzarah-tools / src / three / DFFLoader.js View on Github external
const triangleGroups = this._getTriangleGroups(section);
    const triangleCount = Object.keys(triangleGroups).reduce((sum, key) => (
      sum + triangleGroups[key].length
    ), 0);

    const positionBuffer = new THREE.BufferAttribute(
      new Float32Array(triangleCount * 3 * 3), 3
    );
    const normalBuffer = normals && new THREE.BufferAttribute(
      new Float32Array(triangleCount * 3 * 3), 3, true
    );
    const colorBuffer = vertexColors && new THREE.BufferAttribute(
      new Uint8Array(triangleCount * 3 * 3), 3, true
    );
    const uvBuffer = textureCoords && new THREE.BufferAttribute(
      new Float32Array(triangleCount * 3 * 2), 2, true
    );

    let vertexPos = 0;
    const newVertexIndices = {};
    for (const materialIndex of Object.keys(triangleGroups)) {
      const faces = triangleGroups[materialIndex];
      geometry.addGroup(vertexPos, faces.length * 3, Number(materialIndex));
      for (const indices of faces) {
        for (const index of indices) {
          const [ vx, vy, vz ] = vertices[index];
          positionBuffer.setXYZ(vertexPos, vx, vy, vz);
          newVertexIndices[index] = newVertexIndices[index] || [];
          newVertexIndices[index].push(vertexPos);
          if (normalBuffer) {
            const [ nx, ny, nz ] = normals[index];
github kabbi / zanzarah-tools / src / three / DFFLoader.js View on Github external
_parseGeometry(section) {
    const { vertices, normals, vertexColors, textureCoords} = this._getData(section);
    const geometry = new THREE.BufferGeometry();

    const triangleGroups = this._getTriangleGroups(section);
    const triangleCount = Object.keys(triangleGroups).reduce((sum, key) => (
      sum + triangleGroups[key].length
    ), 0);

    const positionBuffer = new THREE.BufferAttribute(
      new Float32Array(triangleCount * 3 * 3), 3
    );
    const normalBuffer = normals && new THREE.BufferAttribute(
      new Float32Array(triangleCount * 3 * 3), 3, true
    );
    const colorBuffer = vertexColors && new THREE.BufferAttribute(
      new Uint8Array(triangleCount * 3 * 3), 3, true
    );
    const uvBuffer = textureCoords && new THREE.BufferAttribute(
      new Float32Array(triangleCount * 3 * 2), 2, true
    );

    let vertexPos = 0;
    const newVertexIndices = {};
    for (const materialIndex of Object.keys(triangleGroups)) {
      const faces = triangleGroups[materialIndex];
      geometry.addGroup(vertexPos, faces.length * 3, Number(materialIndex));
      for (const indices of faces) {
        for (const index of indices) {
github kabbi / zanzarah-tools / src / three / DFFLoader.js View on Github external
_parseGeometry(section) {
    const { vertices, normals, vertexColors, textureCoords} = this._getData(section);
    const geometry = new THREE.BufferGeometry();

    const triangleGroups = this._getTriangleGroups(section);
    const triangleCount = Object.keys(triangleGroups).reduce((sum, key) => (
      sum + triangleGroups[key].length
    ), 0);

    const positionBuffer = new THREE.BufferAttribute(
      new Float32Array(triangleCount * 3 * 3), 3
    );
    const normalBuffer = normals && new THREE.BufferAttribute(
      new Float32Array(triangleCount * 3 * 3), 3, true
    );
    const colorBuffer = vertexColors && new THREE.BufferAttribute(
      new Uint8Array(triangleCount * 3 * 3), 3, true
    );
    const uvBuffer = textureCoords && new THREE.BufferAttribute(
      new Float32Array(triangleCount * 3 * 2), 2, true
    );

    let vertexPos = 0;
    const newVertexIndices = {};
    for (const materialIndex of Object.keys(triangleGroups)) {
      const faces = triangleGroups[materialIndex];
github kabbi / zanzarah-tools / src / three / DFFLoader.js View on Github external
_parseGeometry(section) {
    const { vertices, normals, vertexColors, textureCoords} = this._getData(section);
    const geometry = new THREE.BufferGeometry();

    const triangleGroups = this._getTriangleGroups(section);
    const triangleCount = Object.keys(triangleGroups).reduce((sum, key) => (
      sum + triangleGroups[key].length
    ), 0);

    const positionBuffer = new THREE.BufferAttribute(
      new Float32Array(triangleCount * 3 * 3), 3
    );
    const normalBuffer = normals && new THREE.BufferAttribute(
      new Float32Array(triangleCount * 3 * 3), 3, true
    );
    const colorBuffer = vertexColors && new THREE.BufferAttribute(
      new Uint8Array(triangleCount * 3 * 3), 3, true
    );
    const uvBuffer = textureCoords && new THREE.BufferAttribute(
      new Float32Array(triangleCount * 3 * 2), 2, true
    );

    let vertexPos = 0;
    const newVertexIndices = {};
    for (const materialIndex of Object.keys(triangleGroups)) {
      const faces = triangleGroups[materialIndex];
      geometry.addGroup(vertexPos, faces.length * 3, Number(materialIndex));
      for (const indices of faces) {
        for (const index of indices) {
          const [ vx, vy, vz ] = vertices[index];
          positionBuffer.setXYZ(vertexPos, vx, vy, vz);
          newVertexIndices[index] = newVertexIndices[index] || [];