How to use the math.gl.Vector3 function in math

To help you get started, we’ve selected a few math 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 uber / luma.gl / modules / experimental / src / scenegraph / nodes / scenegraph-node.js View on Github external
constructor(props = {}) {
    const {id} = props;

    this.id = id || uid(this.constructor.name);

    this.display = true; // whether to display the object at all
    this.position = new Vector3();
    this.rotation = new Vector3();
    this.scale = new Vector3(1, 1, 1);
    this.matrix = new Matrix4();
    this.userData = {};

    this.props = {};
    this._setScenegraphNodeProps(props);
  }
github uber / luma.gl / modules / experimental / src / scenegraph / nodes / scenegraph-node.js View on Github external
constructor(props = {}) {
    const {id} = props;

    this.id = id || uid(this.constructor.name);

    this.display = true; // whether to display the object at all
    this.position = new Vector3();
    this.rotation = new Vector3();
    this.scale = new Vector3(1, 1, 1);
    this.matrix = new Matrix4();
    this.userData = {};

    this.props = {};
    this._setScenegraphNodeProps(props);
  }
github uber / luma.gl / modules / experimental / src / scenegraph / nodes / scenegraph-node.js View on Github external
constructor(props = {}) {
    const {id} = props;

    this.id = id || uid(this.constructor.name);

    this.display = true; // whether to display the object at all
    this.position = new Vector3();
    this.rotation = new Vector3();
    this.scale = new Vector3(1, 1, 1);
    this.matrix = new Matrix4();
    this.userData = {};

    this.props = {};
    this._setScenegraphNodeProps(props);
  }
github uber / luma.gl / src / deprecated / scene.js View on Github external
getDirectionalUniforms(directional) {
    const {color, direction} = directional;

    // Normalize lighting direction vector
    const dir = new Vector3(direction.x, direction.y, direction.z)
      .normalize()
      .scale(-1, -1, -1);

    return {
      directionalColor: [color.r, color.g, color.b],
      lightingDirection: [dir.x, dir.y, dir.z]
    };
  }
github uber / deck.gl / test / modules / core / viewports / viewport.spec.js View on Github external
function getCulling(p, planes) {
  const outDirs = [];
  p = new Vector3(p);
  for (const dir in planes) {
    const plane = planes[dir];
    if (p.dot(plane.normal) > plane.distance) {
      outDirs.push(dir);
    }
  }
  return outDirs.length ? outDirs : null;
}
github uber / deck.gl / test / modules / core / viewports / web-mercator-viewport.spec.js View on Github external
function getCulling(p, planes) {
  let outDir = null;
  p = new Vector3(p);
  for (const dir in planes) {
    const plane = planes[dir];
    if (p.dot(plane.normal) > plane.distance) {
      outDir = dir;
      break;
    }
  }
  return outDir;
}
github uber-web / math.gl / modules / culling / src / lib / bounding-sphere.js View on Github external
constructor(center = [0, 0, 0], radius = 0.0) {
    this.radius = -0;
    this.center = new Vector3();
    this.fromCenterRadius(center, radius);
  }
github uber-web / math.gl / modules / culling / src / lib / plane.js View on Github external
constructor(normal = [0, 0, 1], distance = 0) {
    this.normal = new Vector3();
    this.distance = -0;
    this.fromNormalDistance(normal, distance);
  }
github uber / nebula.gl / modules / layers / src / layers / path-marker-layer / polyline.js View on Github external
export function getClosestPointOnLine({ p, p1, p2, clampToLine = true }) {
  const lineVector = new Vector3(p2).subtract(p1);
  const pointVector = new Vector3(p).subtract(p1);
  let dotProduct = lineVector.dot(pointVector);
  if (clampToLine) {
    dotProduct = clamp(dotProduct, 0, 1);
  }
  return lineVector.lerp(dotProduct);
}
github uber / nebula.gl / modules / layers / src / layers / path-marker-layer / polyline.js View on Github external
export function getClosestPointOnLine({ p, p1, p2, clampToLine = true }) {
  const lineVector = new Vector3(p2).subtract(p1);
  const pointVector = new Vector3(p).subtract(p1);
  let dotProduct = lineVector.dot(pointVector);
  if (clampToLine) {
    dotProduct = clamp(dotProduct, 0, 1);
  }
  return lineVector.lerp(dotProduct);
}

math

Mathematical Functions

Unknown
Latest version published 13 years ago

Package Health Score

39 / 100
Full package analysis