How to use the aframe/src.THREE.Float32BufferAttribute 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
_attachSkin(section) {
    const { bones, vertexCount, boneIndices, boneWeights } = section.data;
    if (!this._frames) {
      throw new Error('We need frame hierarchy to make a skeleton');
    }

    const { count: newVertexCount } = this._geometry.getAttribute('position');
    const indicesBuffer = new THREE.Float32BufferAttribute(newVertexCount * 4, 4);
    const weightsBuffer = new THREE.Float32BufferAttribute(newVertexCount * 4, 4);
    for (let index = 0; index < vertexCount; index++) {
      for (const newIndex of this._vertexIndexTranslation[index]) {
        indicesBuffer.setXYZW(newIndex, ...boneIndices[index]);
        weightsBuffer.setXYZW(newIndex, ...boneWeights[index]);
      }
    }
    this._geometry.addAttribute('skinIndex', indicesBuffer);
    this._geometry.addAttribute('skinWeight', weightsBuffer);

    const frameByBoneId = keyBy(this._frames, 'extensions.RwAnimPlugin.data.boneId');
    const threeBoneById = {};
    const threeBones = [];

    for (const bone of bones) {
      const frame = frameByBoneId[bone.id];
      if (!frame) {
github kabbi / zanzarah-tools / src / three / TransformControls.js View on Github external
const vertices = [];
    arc = arc ? arc : 1;

    for (let i = 0; i <= 64 * arc; ++i) {
      if (facing === 'x') {
        vertices.push(0, Math.cos(i / 32 * Math.PI) * radius, Math.sin(i / 32 * Math.PI) * radius);
      }
      if (facing === 'y') {
        vertices.push(Math.cos(i / 32 * Math.PI) * radius, 0, Math.sin(i / 32 * Math.PI) * radius);
      }
      if (facing === 'z') {
        vertices.push(Math.sin(i / 32 * Math.PI) * radius, Math.cos(i / 32 * Math.PI) * radius, 0);
      }
    }

    geometry.addAttribute('position', new THREE.Float32BufferAttribute(vertices, 3));
    return geometry;
  };
github kabbi / zanzarah-tools / src / three / TransformControls.js View on Github external
const arrowGeometry = new THREE.Geometry();
  const mesh = new THREE.Mesh(new THREE.BoxGeometry(0.125, 0.125, 0.125));
  mesh.position.y = 0.5;
  mesh.updateMatrix();

  arrowGeometry.merge(mesh.geometry, mesh.matrix);

  const lineXGeometry = new THREE.BufferGeometry();
  lineXGeometry.addAttribute('position', new THREE.Float32BufferAttribute([ 0, 0, 0, 1, 0, 0 ], 3));

  const lineYGeometry = new THREE.BufferGeometry();
  lineYGeometry.addAttribute('position', new THREE.Float32BufferAttribute([ 0, 0, 0, 0, 1, 0 ], 3));

  const lineZGeometry = new THREE.BufferGeometry();
  lineZGeometry.addAttribute('position', new THREE.Float32BufferAttribute([ 0, 0, 0, 0, 0, 1 ], 3));

  this.handleGizmos = {

    X: [
      [ new THREE.Mesh(arrowGeometry, new GizmoMaterial({ color: 0xff0000 })), [ 0.5, 0, 0 ], [ 0, 0, -Math.PI / 2 ] ],
      [ new THREE.Line(lineXGeometry, new GizmoLineMaterial({ color: 0xff0000 })) ],
    ],

    Y: [
      [ new THREE.Mesh(arrowGeometry, new GizmoMaterial({ color: 0x00ff00 })), [ 0, 0.5, 0 ] ],
      [ new THREE.Line(lineYGeometry, new GizmoLineMaterial({ color: 0x00ff00 })) ],
    ],

    Z: [
      [ new THREE.Mesh(arrowGeometry, new GizmoMaterial({ color: 0x0000ff })), [ 0, 0, 0.5 ], [ Math.PI / 2, 0, 0 ] ],
      [ new THREE.Line(lineZGeometry, new GizmoLineMaterial({ color: 0x0000ff })) ],
github kabbi / zanzarah-tools / src / three / DFFLoader.js View on Github external
_attachSkin(section) {
    const { bones, vertexCount, boneIndices, boneWeights } = section.data;
    if (!this._frames) {
      throw new Error('We need frame hierarchy to make a skeleton');
    }

    const { count: newVertexCount } = this._geometry.getAttribute('position');
    const indicesBuffer = new THREE.Float32BufferAttribute(newVertexCount * 4, 4);
    const weightsBuffer = new THREE.Float32BufferAttribute(newVertexCount * 4, 4);
    for (let index = 0; index < vertexCount; index++) {
      for (const newIndex of this._vertexIndexTranslation[index]) {
        indicesBuffer.setXYZW(newIndex, ...boneIndices[index]);
        weightsBuffer.setXYZW(newIndex, ...boneWeights[index]);
      }
    }
    this._geometry.addAttribute('skinIndex', indicesBuffer);
    this._geometry.addAttribute('skinWeight', weightsBuffer);

    const frameByBoneId = keyBy(this._frames, 'extensions.RwAnimPlugin.data.boneId');
    const threeBoneById = {};
    const threeBones = [];

    for (const bone of bones) {
      const frame = frameByBoneId[bone.id];