How to use the aframe/src.THREE.Vector3 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 / OrbitControls.js View on Github external
THREE.OrbitControls = function (object, domElement) {
  this.object = object;

  this.domElement = (domElement === undefined) ? document : domElement;

  // Set to false to disable this control
  this.enabled = true;

  // "target" sets the location of focus, where the object orbits around
  this.target = new THREE.Vector3();

  // How far you can dolly in and out ( PerspectiveCamera only )
  this.minDistance = 0;
  this.maxDistance = Infinity;

  // How far you can zoom in and out ( OrthographicCamera only )
  this.minZoom = 0;
  this.maxZoom = Infinity;

  // How far you can orbit vertically, upper and lower limits.
  // Range is 0 to Math.PI radians.
  this.minPolarAngle = 0; // radians
  this.maxPolarAngle = Math.PI; // radians

  // How far you can orbit horizontally, upper and lower limits.
  // If set, must be a sub-interval of the interval [ - Math.PI, Math.PI ].
github kabbi / zanzarah-tools / src / three / OrbitControls.js View on Github external
this.update = (function () {
    const offset = new THREE.Vector3();

    // so camera.up is the orbit axis
    const quat = new THREE.Quaternion().setFromUnitVectors(object.up, new THREE.Vector3(0, 1, 0));
    const quatInverse = quat.clone().inverse();

    const lastPosition = new THREE.Vector3();
    const lastQuaternion = new THREE.Quaternion();

    return function update() {
      const position = scope.object.position;

      offset.copy(position).sub(scope.target);

      // rotate offset to "y-axis-is-up" space
      offset.applyQuaternion(quat);

      // angle from z-axis around y-axis
      spherical.setFromVector3(offset);

      if (scope.autoRotate && state === STATE.NONE) {
        rotateLeft(getAutoRotationAngle());
      }
github kabbi / zanzarah-tools / src / three / BSPLoader.js View on Github external
_parseGeometry(data) {
    const geometry = new THREE.Geometry();

    const { vertices } = data;
    for (const [ x, y, z ] of vertices) {
      geometry.vertices.push(new THREE.Vector3(x, y, z));
    }

    const { indices, colors } = data;
    for (const [ materialIndex, a, b, c ] of indices) {
      const indexes = [a, b, c];
      const faceColors = colors ? indexes.map(index => {
        const color = colors[index];
        return new THREE.Color(parseInt(color, 16) & 0xFFFFFF)
          .multiplyScalar(ColorMultiplier);
      }) : null;
      geometry.faces.push(new THREE.Face3(a, b, c, null, faceColors, materialIndex));
    }

    const { textureCoords } = data;
    const uvLayer = geometry.faceVertexUvs[0] = [];
    // eslint-disable-next-line no-unused-vars
github kabbi / zanzarah-tools / src / components / z-entity.js View on Github external
createArrow() {
    const { type } = this.data;
    this.arrow = new THREE.ArrowHelper(
      new THREE.Vector3(0, 0, 1),
      new THREE.Vector3(0, 0, 0),
      (MarkerSizes[type] || 1) * 2,
      this.getMarkerColor()
    );
    this.arrow.cone.material.wireframe = true;
    this.el.setObject3D('arrow', this.arrow);
  },
github kabbi / zanzarah-tools / src / three / TransformControls.js View on Github external
const mouseDownEvent = { type: 'mouseDown' };
  const mouseUpEvent = { type: 'mouseUp', mode: _mode };
  const objectChangeEvent = { type: 'objectChange' };

  const ray = new THREE.Raycaster();
  const pointerVector = new THREE.Vector2();

  const point = new THREE.Vector3();
  const offset = new THREE.Vector3();

  const rotation = new THREE.Vector3();
  const offsetRotation = new THREE.Vector3();
  let scale = 1;

  const lookAtMatrix = new THREE.Matrix4();
  const eye = new THREE.Vector3();

  const tempMatrix = new THREE.Matrix4();
  const tempVector = new THREE.Vector3();
  const tempQuaternion = new THREE.Quaternion();
  const unitX = new THREE.Vector3(1, 0, 0);
  const unitY = new THREE.Vector3(0, 1, 0);
  const unitZ = new THREE.Vector3(0, 0, 1);

  const quaternionXYZ = new THREE.Quaternion();
  const quaternionX = new THREE.Quaternion();
  const quaternionY = new THREE.Quaternion();
  const quaternionZ = new THREE.Quaternion();
  const quaternionE = new THREE.Quaternion();

  const oldPosition = new THREE.Vector3();
  const oldScale = new THREE.Vector3();
github kabbi / zanzarah-tools / src / three / TransformControls.js View on Github external
const eye = new THREE.Vector3();

  const tempMatrix = new THREE.Matrix4();
  const tempVector = new THREE.Vector3();
  const tempQuaternion = new THREE.Quaternion();
  const unitX = new THREE.Vector3(1, 0, 0);
  const unitY = new THREE.Vector3(0, 1, 0);
  const unitZ = new THREE.Vector3(0, 0, 1);

  const quaternionXYZ = new THREE.Quaternion();
  const quaternionX = new THREE.Quaternion();
  const quaternionY = new THREE.Quaternion();
  const quaternionZ = new THREE.Quaternion();
  const quaternionE = new THREE.Quaternion();

  const oldPosition = new THREE.Vector3();
  const oldScale = new THREE.Vector3();
  const oldRotationMatrix = new THREE.Matrix4();

  const parentRotationMatrix = new THREE.Matrix4();
  const parentScale = new THREE.Vector3();

  const worldPosition = new THREE.Vector3();
  const worldRotation = new THREE.Euler();
  const worldRotationMatrix = new THREE.Matrix4();
  const camPosition = new THREE.Vector3();
  const camRotation = new THREE.Euler();

  domElement.addEventListener('mousedown', onPointerDown, false);
  domElement.addEventListener('touchstart', onPointerDown, false);

  domElement.addEventListener('mousemove', onPointerHover, false);
github kabbi / zanzarah-tools / src / three / TransformControls.js View on Github external
const quaternionX = new THREE.Quaternion();
  const quaternionY = new THREE.Quaternion();
  const quaternionZ = new THREE.Quaternion();
  const quaternionE = new THREE.Quaternion();

  const oldPosition = new THREE.Vector3();
  const oldScale = new THREE.Vector3();
  const oldRotationMatrix = new THREE.Matrix4();

  const parentRotationMatrix = new THREE.Matrix4();
  const parentScale = new THREE.Vector3();

  const worldPosition = new THREE.Vector3();
  const worldRotation = new THREE.Euler();
  const worldRotationMatrix = new THREE.Matrix4();
  const camPosition = new THREE.Vector3();
  const camRotation = new THREE.Euler();

  domElement.addEventListener('mousedown', onPointerDown, false);
  domElement.addEventListener('touchstart', onPointerDown, false);

  domElement.addEventListener('mousemove', onPointerHover, false);
  domElement.addEventListener('touchmove', onPointerHover, false);

  domElement.addEventListener('mousemove', onPointerMove, false);
  domElement.addEventListener('touchmove', onPointerMove, false);

  domElement.addEventListener('mouseup', onPointerUp, false);
  domElement.addEventListener('mouseout', onPointerUp, false);
  domElement.addEventListener('touchend', onPointerUp, false);
  domElement.addEventListener('touchcancel', onPointerUp, false);
  domElement.addEventListener('touchleave', onPointerUp, false);
github kabbi / zanzarah-tools / src / three / TransformControls.js View on Github external
const ray = new THREE.Raycaster();
  const pointerVector = new THREE.Vector2();

  const point = new THREE.Vector3();
  const offset = new THREE.Vector3();

  const rotation = new THREE.Vector3();
  const offsetRotation = new THREE.Vector3();
  let scale = 1;

  const lookAtMatrix = new THREE.Matrix4();
  const eye = new THREE.Vector3();

  const tempMatrix = new THREE.Matrix4();
  const tempVector = new THREE.Vector3();
  const tempQuaternion = new THREE.Quaternion();
  const unitX = new THREE.Vector3(1, 0, 0);
  const unitY = new THREE.Vector3(0, 1, 0);
  const unitZ = new THREE.Vector3(0, 0, 1);

  const quaternionXYZ = new THREE.Quaternion();
  const quaternionX = new THREE.Quaternion();
  const quaternionY = new THREE.Quaternion();
  const quaternionZ = new THREE.Quaternion();
  const quaternionE = new THREE.Quaternion();

  const oldPosition = new THREE.Vector3();
  const oldScale = new THREE.Vector3();
  const oldRotationMatrix = new THREE.Matrix4();

  const parentRotationMatrix = new THREE.Matrix4();
github kabbi / zanzarah-tools / src / components / z-light.js View on Github external
update() {
    const { object3D } = this.el;
    const { type } = this.data;

    switch (type) {
      case 'UnknownLight1': {
        const { _unknownVectors: [ position, rotation ] } = this.data;
        object3D.position.fromArray(position);
        const [ ra, rb, rc ] = rotation;
        object3D.rotation.z = Math.atan2(ra, rb);
        object3D.rotation.y = Math.atan2(ra, rc);
        const arrow = new THREE.ArrowHelper(
          new THREE.Vector3(1, 0, 0),
          new THREE.Vector3(0, 0, 0),
          1,
          0xFFFFFF,
          0.4,
          0.3
        );
        arrow.cone.material.wireframe = true;
        this.el.setObject3D('mesh', arrow);
        break;
      }
      default:
        break;
    }
  },
});
github kabbi / zanzarah-tools / src / components / z-light.js View on Github external
update() {
    const { object3D } = this.el;
    const { type } = this.data;

    switch (type) {
      case 'UnknownLight1': {
        const { _unknownVectors: [ position, rotation ] } = this.data;
        object3D.position.fromArray(position);
        const [ ra, rb, rc ] = rotation;
        object3D.rotation.z = Math.atan2(ra, rb);
        object3D.rotation.y = Math.atan2(ra, rc);
        const arrow = new THREE.ArrowHelper(
          new THREE.Vector3(1, 0, 0),
          new THREE.Vector3(0, 0, 0),
          1,
          0xFFFFFF,
          0.4,
          0.3
        );
        arrow.cone.material.wireframe = true;
        this.el.setObject3D('mesh', arrow);
        break;
      }
      default:
        break;
    }
  },
});