How to use gl-vec3 - 10 common examples

To help you get started, we’ve selected a few gl-vec3 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 rolyatmax / sketches / sketches / 2019.10.27-21.36.51.js View on Github external
function subdivideMeshes (mesh) {
    const planeNormal = rand.onSphere(1)
    const planePt = rand.insideSphere(5)
    const [mesh1, mesh2] = clipMeshWithPlane(mesh, planeNormal, planePt)
    const offset1 = vec3.scale([], planeNormal, settings.offset)
    const offset2 = vec3.scale([], planeNormal, -settings.offset)
    // const rotation = mat4.fromRotation([], rand.range(0, Math.PI * 0.5), planeNormal)
    return [
      mesh1.map(points => points.map(pt => vec3.add([], pt, offset1))),
      mesh2.map(points => points.map(pt => vec3.add([], pt, offset2)))
      // mesh1.map(points => points.map(pt => vec3.transformMat4([], pt, rotation))),
      // mesh2
    ]
  }
github rolyatmax / sketches / sketches / 2019.10.28-18.39.01.js View on Github external
function subdivideMeshes (mesh) {
    const planeNormal = rand.onSphere(1)
    const planePt = rand.insideSphere(5)
    const [mesh1, mesh2] = clipMeshWithPlane(mesh, planeNormal, planePt)
    const offset1 = vec3.scale([], planeNormal, settings.offset)
    const offset2 = vec3.scale([], planeNormal, -settings.offset)
    // const rotation = mat4.fromRotation([], rand.range(0, Math.PI * 0.5), planeNormal)
    return [
      mesh1.map(points => points.map(pt => vec3.add([], pt, offset1))),
      mesh2.map(points => points.map(pt => vec3.add([], pt, offset2)))
      // mesh1.map(points => points.map(pt => vec3.transformMat4([], pt, rotation))),
      // mesh2
    ]
  }
github rolyatmax / sketches / sketches / 2019.10.27-21.36.51.js View on Github external
function getLinePlaneIntersection (line, planeNormal, pointOnPlane) {
  const [p0, p1] = line
  const dir = vec3.subtract([], p1, p0)
  const t = vec3.dot(vec3.subtract([], pointOnPlane, p0), planeNormal) / vec3.dot(dir, planeNormal)
  return t >= 0 && t <= 1 ? vec3.add([], vec3.scale([], dir, t), p0) : null
}
github rolyatmax / sketches / sketches / 2019.10.27-17.42.23.js View on Github external
function getLinePlaneIntersection (line, planeNormal, pointOnPlane) {
  const [p0, p1] = line
  const dir = vec3.subtract([], p1, p0)
  const t = vec3.dot(vec3.subtract([], pointOnPlane, p0), planeNormal) / vec3.dot(dir, planeNormal)
  return t >= 0 && t <= 1 ? vec3.add([], vec3.scale([], dir, t), p0) : null
}
github rolyatmax / sketches / sketches / 2019.10.28-18.39.01.js View on Github external
function getLinePlaneIntersection (line, planeNormal, pointOnPlane) {
  const [p0, p1] = line
  const dir = vec3.subtract([], p1, p0)
  const t = vec3.dot(vec3.subtract([], pointOnPlane, p0), planeNormal) / vec3.dot(dir, planeNormal)
  return t >= 0 && t <= 1 ? vec3.add([], vec3.scale([], dir, t), p0) : null
}
github rolyatmax / sketches / sketches / 2019.10.28-19.57.21.js View on Github external
function getLinePlaneIntersection (line, planeNormal, pointOnPlane) {
  const [p0, p1] = line
  const dir = vec3.subtract([], p1, p0)
  const t = vec3.dot(vec3.subtract([], pointOnPlane, p0), planeNormal) / vec3.dot(dir, planeNormal)
  return t >= 0 && t <= 1 ? vec3.add([], vec3.scale([], dir, t), p0) : null
}
github rolyatmax / sketches / lib / clip-mesh-with-plane / clip-mesh-with-plane-0.0.1.js View on Github external
function getLinePlaneIntersection (line, planeNormal, pointOnPlane) {
  const [p0, p1] = line
  const dir = vec3.subtract([], p1, p0)
  const t = vec3.dot(vec3.subtract([], pointOnPlane, p0), planeNormal) / vec3.dot(dir, planeNormal)
  return t >= 0 && t <= 1 ? vec3.add([], vec3.scale([], dir, t), p0) : null
}
github rolyatmax / sketches / src / ruminative-steven.js View on Github external
function tick () {
    let velocity = vec3.subtract([], curPosition, lastPosition)
    const delta = vec3.subtract([], destination, curPosition)
    const acceleration = vec3.scale([], delta, 0.001)
    velocity = vec3.add(velocity, acceleration, velocity)
    if (vec3.length(velocity) > 0.005) {
      velocity = vec3.normalize(velocity, velocity)
      velocity = vec3.scale(velocity, velocity, 0.005)
    }
    const nextPosition = vec3.add([], velocity, curPosition)
    lastPosition = curPosition
    curPosition = nextPosition
    return curPosition
  }
}
github djalbat / xgl / es6 / maths / vec3.js View on Github external
function normalise(vec) {
  const out = [];

  vec3.normalize(out, vec);

  return out;
}
github djalbat / xgl / lib / maths / vec3.js View on Github external
function normalise(vec) {
  var out = [];

  vec3.normalize(out, vec);

  return out;
}

gl-vec3

gl-matrix's vec3, split into smaller pieces

Zlib
Latest version published 6 years ago

Package Health Score

56 / 100
Full package analysis