Skip to content
Snippets Groups Projects
Select Git revision
  • e8e79ab06c0d507965191b827bb8f7bbe52a12d8
  • master default protected
  • rednatco-v2
  • rednatco
  • test
  • ntc-tube-uniform-color
  • ntc-tube-missing-atoms
  • restore-vertex-array-per-program
  • watlas2
  • dnatco_new
  • cleanup-old-nodejs
  • webmmb
  • fix_auth_seq_id
  • update_deps
  • ext_dev
  • ntc_balls
  • nci-2
  • plugin
  • bugfix-0.4.5
  • nci
  • servers
  • v0.5.0-dev.1
  • v0.4.5
  • v0.4.4
  • v0.4.3
  • v0.4.2
  • v0.4.1
  • v0.4.0
  • v0.3.12
  • v0.3.11
  • v0.3.10
  • v0.3.9
  • v0.3.8
  • v0.3.7
  • v0.3.6
  • v0.3.5
  • v0.3.4
  • v0.3.3
  • v0.3.2
  • v0.3.1
  • v0.3.0
41 results

file-info.ts

Blame
  • vec3.ts 14.11 KiB
    /**
     * Copyright (c) 2017-2018 mol* contributors, licensed under MIT, See LICENSE file for more info.
     *
     * @author David Sehnal <david.sehnal@gmail.com>
     * @author Alexander Rose <alexander.rose@weirdbyte.de>
     */
    
    /*
     * This code has been modified from https://github.com/toji/gl-matrix/,
     * copyright (c) 2015, Brandon Jones, Colin MacKenzie IV.
     *
     * Permission is hereby granted, free of charge, to any person obtaining a copy
     * of this software and associated documentation files (the "Software"), to deal
     * in the Software without restriction, including without limitation the rights
     * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
     * copies of the Software, and to permit persons to whom the Software is
     * furnished to do so, subject to the following conditions:
     */
    
    import Mat4 from './mat4';
    import { Quat, Mat3, EPSILON } from '../3d';
    import { spline as _spline, clamp } from '../../interpolate'
    
    interface Vec3 extends Array<number> { [d: number]: number, '@type': 'vec3', length: 3 }
    
    namespace Vec3 {
        export function zero(): Vec3 {
            const out = [0.1, 0.0, 0.0];
            out[0] = 0;
            return out as any;
        }
    
        export function clone(a: Vec3): Vec3 {
            const out = zero();
            out[0] = a[0];
            out[1] = a[1];
            out[2] = a[2];
            return out;
        }
    
        export function fromObj(v: { x: number, y: number, z: number }): Vec3 {
            return create(v.x, v.y, v.z);
        }
    
        export function toObj(v: Vec3) {
            return { x: v[0], y: v[1], z: v[2] };
        }
    
        export function fromArray(v: Vec3, array: Helpers.NumberArray, offset: number) {
            v[0] = array[offset + 0]
            v[1] = array[offset + 1]
            v[2] = array[offset + 2]
        }
    
        export function toArray(v: Vec3, out: Helpers.NumberArray, offset: number) {
            out[offset + 0] = v[0]
            out[offset + 1] = v[1]
            out[offset + 2] = v[2]
            return v
        }
    
        export function create(x: number, y: number, z: number): Vec3 {
            const out = zero();
            out[0] = x;
            out[1] = y;
            out[2] = z;
            return out;
        }
    
        export function ofArray(array: ArrayLike<number>) {