How to use the gl-matrix.vec2.fromValues function in gl-matrix

To help you get started, we’ve selected a few gl-matrix 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 magcius / noclip.website / src / BanjoKazooie / particles.ts View on Github external
}

// values are from a mixture of config structs and code
export const quicksandConfig = new EmitterConfig({
    spriteIndex: 0xd,
    frameChance: 0.2,

    primColor: vec4.fromValues(1, 1, 155 / 255, 100 / 255),
    pulseRange: vec2.fromValues(.1, .4),

    offsetMin: vec3.fromValues(-700, 0, -700),
    offsetMax: vec3.fromValues(700, 0, 700),
    velMin: vec3.fromValues(0, 90, 0),
    velMax: vec3.fromValues(0, 90, 0),

    lifetimeRange: vec2.fromValues(2, 2.5),
    startScaleRange: vec2.fromValues(2.5, 2.8),
    endScaleRange: vec2.fromValues(4, 5),

    phaseRange: vec2.fromValues(1, 6),
});

export const torchSmokeConfig = new EmitterConfig({
    spriteIndex: 0xd,
    frameChance: 1 / 40,

    primColor: vec4.fromValues(1, 1, 1, 35 / 255),
    pulseRange: vec2.fromValues(.3, .7),

    offsetMin: vec3.fromValues(0, 110, 0),
    offsetMax: vec3.fromValues(0, 110, 0),
    velMin: vec3.fromValues(0, 40, 0),
github magcius / noclip.website / src / BanjoKazooie / particles.ts View on Github external
phaseRange: vec2.fromValues(0, 4),
    fpsRange: vec2.fromValues(15, 30),
});

export const brentildaWandConfig = new EmitterConfig({
    spriteIndex: 0x13,
    delayRange: vec2.fromValues(1 / 15, 1 / 15), // every other frame

    pulseRange: vec2.fromValues(.4, .8),

    offsetMin: vec3.fromValues(-15, -15, -15),
    offsetMax: vec3.fromValues(15, 15, 15),
    accelMin: vec3.fromValues(0, -250, 0),
    accelMax: vec3.fromValues(0, -250, 0),

    lifetimeRange: vec2.fromValues(.7, .7),
    startScaleRange: vec2.fromValues(.25, .3),
    endScaleRange: vec2.fromValues(.03, .03),
    rotationRange: vec2.fromValues(200, 240),
});

function fromRange(range: vec2): number {
    return range[0] + Math.random() * (range[1] - range[0]);
}

function fromBB(dst: vec3, min: vec3, max: vec3): void {
    for (let i = 0; i < 3; i++) {
        dst[i] = min[i] + Math.random() * (max[i] - min[i]);
    }
}

const configScratch = vec3.create();
github DeviateFish / ingress-model-viewer / src / mesh / spherical-portal-link.js View on Github external
function toRadians(point) {
  return vec2.fromValues(point[0] * Math.PI / 180, point[1] * Math.PI / 180);
}
github magcius / noclip.website / src / kh / bin.ts View on Github external
function processUVs(view: DataView, offs: number, submeshOut: Submesh): number {
    if (!submeshOut) {
        return 0;
    }
    const qwc = view.getUint8(offs);
    const cmd = view.getUint8(offs + 0x1);
    const anim = (cmd & 0x8) > 0;
    const width = anim ? 8 : 4;
    offs += 2;
    for (let i = 0; i < qwc; i++) {
        submeshOut.uv.push(vec2.fromValues(
            view.getInt16(offs + i * width, true) / 4096,
            view.getInt16(offs + i * width + 0x2, true) / 4096
        ));
        submeshOut.uvScrollIndex.push(vec2.fromValues(
            anim ? view.getUint16(offs + i * width + 0x4, true) : 0,
            anim ? view.getUint16(offs + i * width + 0x6, true) : 0
        ));
    }
    return offs + qwc * width;
}
github DeviateFish / ingress-model-viewer / src / mesh / spherical-portal-link.js View on Github external
function dest(p, bearing, angle) {
  var lat = Math.asin(Math.sin(p[0]) * Math.cos(angle) + Math.cos(p[0]) * Math.sin(angle) * Math.cos(bearing)),
      lon = p[1] + Math.atan2(Math.sin(bearing) * Math.sin(angle) * Math.cos(p[0]), Math.cos(angle) - Math.sin(p[0]) * Math.sin(lat));

  lon = (lon + 3 * Math.PI) % (2 * Math.PI) - Math.PI;
  return vec2.fromValues(lat, lon);
}
github cginternals / webgl-operate / source / navigation.ts View on Github external
protected rotate(event: MouseEvent | TouchEvent, start: boolean): void {
        const point = this._eventHandler.offsets(event)[0];

        switch (this._metaphor) {
            case Navigation.Metaphor.FirstPerson:
                const firstPerson = this._firstPerson as FirstPersonModifier;
                let movement: vec2 | undefined;
                if (PointerLock.active() && event instanceof MouseEvent) {
                    movement = vec2.fromValues((event as MouseEvent).movementX, (event as MouseEvent).movementY);
                }
                start ? firstPerson.initiate(point) : firstPerson.process(point, movement);
                event.preventDefault();
                break;

            case Navigation.Metaphor.Trackball:
                const trackball = this._trackball as TrackballModifier;
                start ? trackball.initiate(point) : trackball.process(point);
                event.preventDefault();
                break;

            case Navigation.Metaphor.Turntable:
                const turntable = this._turntable as TurntableModifier;
                start ? turntable.initiate(point) : turntable.process(point);
                event.preventDefault();
                break;
github 2d-inc / Flare-JS / source / TextShaper.js View on Github external
x1 = 0;
				break;

			case TextAlign.Center:
				x0 = -_Size[0] / 2;
				x1 = _Size[0] / 2;
				break;
			default:
				x1 = _Size[0];
				break;
		}
		addPoint([x0, -renderLineHeight]);
		addPoint([x1, -renderLineHeight]);
		addPoint([x1, -renderLineHeight + _Size[1]]);
		addPoint([x0, -renderLineHeight + _Size[1]]);
		return [vec2.fromValues(min_x, min_y), vec2.fromValues(max_x, max_y)];
	}
}
github DeviateFish / ingress-model-viewer / src / drawable / ornament.js View on Github external
constructor(meshName, textureName) {
    super(PROGRAM, meshName, textureName);
    this.uniforms.u_texCoordBase = vec2.fromValues(0, 0);
    this.uniforms.u_texCoordExtent = vec2.fromValues(1, 1);
    this.uniforms.u_color = vec4.clone(Constants.teamColors.LOKI);
  }
}
github picturama / picturama / src / common / util / GeometryUtil.ts View on Github external
export function directionOfPoints(start: Vec2Like, end: Vec2Like): vec2 {
    return vec2.fromValues(end[0] - start[0], end[1] - start[1])
}