|
@@ -5,8 +5,9 @@
|
|
|
*/
|
|
|
|
|
|
import { Vec3, Mat4, Mat3 } from 'mol-math/linear-algebra'
|
|
|
+import { NumberArray } from 'mol-util/type-helpers';
|
|
|
|
|
|
-export function normalizeVec3Array<T extends Helpers.NumberArray> (a: T) {
|
|
|
+export function normalizeVec3Array<T extends NumberArray> (a: T) {
|
|
|
const n = a.length
|
|
|
for (let i = 0; i < n; i += 3) {
|
|
|
const x = a[ i ]
|
|
@@ -28,7 +29,7 @@ export function getNormalMatrix(out: Mat3, t: Mat4) {
|
|
|
|
|
|
const tmpV3 = Vec3.zero()
|
|
|
|
|
|
-export function transformPositionArray (t: Mat4, array: Helpers.NumberArray, offset: number, count: number) {
|
|
|
+export function transformPositionArray (t: Mat4, array: NumberArray, offset: number, count: number) {
|
|
|
for (let i = 0, il = count * 3; i < il; i += 3) {
|
|
|
Vec3.fromArray(tmpV3, array, offset + i)
|
|
|
Vec3.transformMat4(tmpV3, tmpV3, t)
|
|
@@ -36,7 +37,7 @@ export function transformPositionArray (t: Mat4, array: Helpers.NumberArray, off
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-export function transformDirectionArray (n: Mat3, array: Helpers.NumberArray, offset: number, count: number) {
|
|
|
+export function transformDirectionArray (n: Mat3, array: NumberArray, offset: number, count: number) {
|
|
|
for (let i = 0, il = count * 3; i < il; i += 3) {
|
|
|
Vec3.fromArray(tmpV3, array, offset + i)
|
|
|
Vec3.transformMat3(tmpV3, tmpV3, n)
|
|
@@ -44,13 +45,13 @@ export function transformDirectionArray (n: Mat3, array: Helpers.NumberArray, of
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-export function setArrayZero(array: Helpers.NumberArray) {
|
|
|
+export function setArrayZero(array: NumberArray) {
|
|
|
const n = array.length
|
|
|
for (let i = 0; i < n; ++i) array[i] = 0
|
|
|
}
|
|
|
|
|
|
/** iterate over the entire buffer and apply the radius to each vertex */
|
|
|
-export function appplyRadius(vertices: Helpers.NumberArray, radius: number) {
|
|
|
+export function appplyRadius(vertices: NumberArray, radius: number) {
|
|
|
const v = Vec3.zero()
|
|
|
const n = vertices.length
|
|
|
for (let i = 0; i < n; i += 3) {
|
|
@@ -65,7 +66,7 @@ export function appplyRadius(vertices: Helpers.NumberArray, radius: number) {
|
|
|
* indexed vertex normals weighted by triangle areas http://www.iquilezles.org/www/articles/normals/normals.htm
|
|
|
* normal array must contain only zeros
|
|
|
*/
|
|
|
-export function computeIndexedVertexNormals<T extends Helpers.NumberArray> (vertices: Helpers.NumberArray, indices: Helpers.NumberArray, normals: T) {
|
|
|
+export function computeIndexedVertexNormals<T extends NumberArray> (vertices: NumberArray, indices: NumberArray, normals: T) {
|
|
|
const a = Vec3.zero()
|
|
|
const b = Vec3.zero()
|
|
|
const c = Vec3.zero()
|
|
@@ -103,7 +104,7 @@ export function computeIndexedVertexNormals<T extends Helpers.NumberArray> (vert
|
|
|
}
|
|
|
|
|
|
/** vertex normals for unindexed triangle soup, normal array must contain only zeros */
|
|
|
-export function computeVertexNormals<T extends Helpers.NumberArray> (vertices: Helpers.NumberArray, normals: T) {
|
|
|
+export function computeVertexNormals<T extends NumberArray> (vertices: NumberArray, normals: T) {
|
|
|
setArrayZero(normals)
|
|
|
|
|
|
const a = Vec3.zero()
|