Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AssemblyScript] porting source from JS to AS #421

Draft
wants to merge 32 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
65f3513
configuring env for working with assemblyscript
StEvUgnIn Mar 26, 2021
600fc7d
porting js into as
StEvUgnIn Mar 26, 2021
68c0b01
set assemblyscript portability for AS/TS
StEvUgnIn Mar 27, 2021
758766d
update gitignore - yarn
StEvUgnIn Mar 27, 2021
2239143
configuration for compilation of AS into JS
StEvUgnIn Mar 27, 2021
b61761e
add source types declarations for build
StEvUgnIn Mar 27, 2021
4276d9c
fix required explicit toString conversion
StEvUgnIn Mar 28, 2021
fd1907b
fix module typings
StEvUgnIn Mar 28, 2021
f917c0c
implement workaround for AS100
StEvUgnIn Mar 28, 2021
2e2ac0b
tsc build dist/index.dts from portable AS directly
StEvUgnIn Mar 28, 2021
a53c4e3
build successfully javascript and webassembly
StEvUgnIn Mar 28, 2021
6f18cce
removed directive for TS typings
StEvUgnIn Mar 29, 2021
f1b573b
another fix to AS100 for expected closure
StEvUgnIn Mar 29, 2021
6ff09f6
fix AS warnings
StEvUgnIn Mar 29, 2021
6deca79
optimize MathUtil library
StEvUgnIn Mar 29, 2021
dc5e7da
optimize build for speed
StEvUgnIn Mar 29, 2021
cca26fa
fix modules in dist/index.d.ts
StEvUgnIn Mar 29, 2021
598eff0
compile from single file index.ts
StEvUgnIn Mar 30, 2021
28f978a
changetype is not implemented for TS compilation
StEvUgnIn Mar 30, 2021
0749891
change MathUtil into JSMath and Maths namespaces
StEvUgnIn Mar 30, 2021
36ecee9
merge JSMath and Maths and toolchain TS into AMD modules
StEvUgnIn Apr 1, 2021
79a3b97
simplify toolchain to compile TS/AS into JS
StEvUgnIn Apr 1, 2021
8a56b64
definitive toolchain compilation
StEvUgnIn Apr 1, 2021
78a6d91
hypot cannot be parsed in JS build
StEvUgnIn Apr 2, 2021
0dd49ae
javascript interface for webassembly
StEvUgnIn Apr 2, 2021
194ed13
update .travis.yml for using latest node-lts version
StEvUgnIn Apr 2, 2021
1922b8d
add upper case support
StEvUgnIn Apr 4, 2021
1124e84
right asynchronous call for WebAssembly loading
StEvUgnIn Apr 4, 2021
885e3b1
update assembly and asconfig.json
StEvUgnIn Apr 26, 2021
2b03776
loader
StEvUgnIn Apr 26, 2021
32801c0
build
StEvUgnIn Apr 28, 2021
ae420e4
as-pect
StEvUgnIn Apr 28, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ tmp
node_modules
npm-debug.log
package-lock.json
yarn.lock
dist
!dist/gl-matrix.js
!dist/gl-matrix.min.js
6 changes: 3 additions & 3 deletions .size-snapshot.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"gzipped": 13273
},
"dist\\gl-matrix-min.js": {
"bundled": 199625,
"minified": 50914,
"gzipped": 12913
"bundled": 2173,
"minified": 1927,
"gzipped": 1003
}
}
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2015-2020, Brandon Jones, Colin MacKenzie IV.
Copyright (c) 2015-2021, 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
Expand Down
20 changes: 20 additions & 0 deletions asconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"targets": {
"debug": {
"binaryFile": "build/untouched.wasm",
"textFile": "build/untouched.wat",
"sourceMap": true,
"debug": true
},
"release": {
"binaryFile": "build/optimized.wasm",
"textFile": "build/optimized.wat",
"sourceMap": true,
"optimizeLevel": 3,
"shrinkLevel": 1,
"converge": false,
"noAssert": false
StEvUgnIn marked this conversation as resolved.
Show resolved Hide resolved
}
},
"options": {}
}
45 changes: 45 additions & 0 deletions assembly/common.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import { MathUtil } from "./imports"

/**
* Common utilities
* @module glMatrix
*/

// Configuration Constants
export const EPSILON = 0.000001;
export type ARRAY_TYPE = Float64Array;
export let RANDOM = Math.random;
export let ANGLE_ORDER = "zyx";

/**
* Sets the type of array used when creating new vectors and matrices
*
* @param {Object} type Array type, such as Float32Array or Array
*/
export function setMatrixArrayType(type: Object): void {
throw new Error("Not implemented yet");
}

const degree: f64 = Math.PI / 180;

/**
* Convert Degree To Radian
*
* @param {Number} a Angle in Degrees
*/
export function toRadian(a: f64): f64 {
return a * degree;
}

/**
* Tests whether or not the arguments have approximately the same value, within an absolute
* or relative tolerance of glMatrix.EPSILON (an absolute tolerance is used for values less
* than or equal to 1.0, and a relative tolerance is used for larger values)
*
* @param {Number} a The first number to test.
* @param {Number} b The second number to test.
* @returns {Boolean} True if the numbers are approximately equal, false otherwise.
*/
export function equals(a: f64, b: f64): bool {
return Math.abs(a - b) <= EPSILON * MathUtil.max(1.0, Math.abs(a), Math.abs(b));
}
20 changes: 20 additions & 0 deletions assembly/imports.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// this file import things passed in from JS, and exports them for use by other
// AS modules.

// @ts-ignore
// prettier-ignore

export declare namespace MathUtil {
function min(a: i32, b: i32): i32;

function max(a: f64, b: f64, c: f64): f64;

// @ts-ignore decorator
@external("Math", "hypot")
function hypot(a: f64, b: f64, c?: f64, d?: f64, e?: f64, f?: f64, g?: f64, h?: f64, i?: f64, j?: f64, k?: f64, l?: f64, m?: f64, n?: f64, o?: f64, p?: f64): f64;
}

export interface IArguments {
}

export type IndexedCollection = Float64Array;
17 changes: 17 additions & 0 deletions assembly/index.as.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import * as glMatrix from "./common";
import * as mat2 from "./mat2";
import * as mat2d from "./mat2d";
import * as mat3 from "./mat3";
import * as mat4 from "./mat4";
import * as quat from "./quat";
import * as quat2 from "./quat2";
import * as vec2 from "./vec2";
import * as vec3 from "./vec3";
import * as vec4 from "./vec4";

export {
glMatrix,
mat2, mat2d, mat3, mat4,
quat, quat2,
vec2, vec3, vec4,
};
18 changes: 18 additions & 0 deletions assembly/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import "assemblyscript/std/portable";
import * as glMatrix from "./common";
import * as mat2 from "./mat2";
import * as mat2d from "./mat2d";
import * as mat3 from "./mat3";
import * as mat4 from "./mat4";
import * as quat from "./quat";
import * as quat2 from "./quat2";
import * as vec2 from "./vec2";
import * as vec3 from "./vec3";
import * as vec4 from "./vec4";

export {
glMatrix,
mat2, mat2d, mat3, mat4,
quat, quat2,
vec2, vec3, vec4,
};
Loading