Add more tests and fix JS mode.
This commit is contained in:
parent
4441978b31
commit
8ad38bafb0
3
.github/workflows/build.yml
vendored
3
.github/workflows/build.yml
vendored
|
@ -14,3 +14,6 @@ jobs:
|
||||||
- uses: jiro4989/setup-nim-action@v1
|
- uses: jiro4989/setup-nim-action@v1
|
||||||
- run: nimble test -y
|
- run: nimble test -y
|
||||||
- run: nimble test --gc:orc -y
|
- run: nimble test --gc:orc -y
|
||||||
|
- run: nimble test -y -d:vmathObjBased
|
||||||
|
- run: nimble test -y -d:vmathArrayBased
|
||||||
|
- run: nim js -r tests/test.nim
|
||||||
|
|
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -4,5 +4,6 @@
|
||||||
!*.*
|
!*.*
|
||||||
|
|
||||||
# normal ignores:
|
# normal ignores:
|
||||||
|
*.js
|
||||||
*.exe
|
*.exe
|
||||||
nimcache
|
nimcache
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
<img src="docs/banner.png">
|
<img src="docs/banner.png">
|
||||||
|
|
||||||
|
![Github Actions](https://github.com/treeform/vmath/workflows/Github%20Actions/badge.svg)
|
||||||
|
|
||||||
# VMath
|
# VMath
|
||||||
|
|
||||||
![Github Actions](https://github.com/treeform/vmath/workflows/Github%20Actions/badge.svg)
|
![Github Actions](https://github.com/treeform/vmath/workflows/Github%20Actions/badge.svg)
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
## Based on the work of https://github.com/edin/raytracer
|
## Based on the work of https://github.com/edin/raytracer
|
||||||
|
## MIT License
|
||||||
|
## Copyright (c) 2021 Edin Omeragic
|
||||||
|
|
||||||
import chroma, math, times, pixie, vmath, benchy
|
import chroma, math, times, pixie, vmath, benchy
|
||||||
|
|
||||||
|
|
|
@ -105,6 +105,7 @@ block:
|
||||||
assert isNan(float64(5.0e-324)) == false
|
assert isNan(float64(5.0e-324)) == false
|
||||||
|
|
||||||
block:
|
block:
|
||||||
|
when not defined(js):
|
||||||
# Test vec2 cast.
|
# Test vec2 cast.
|
||||||
var v = vec2(1.0, 2.0)
|
var v = vec2(1.0, 2.0)
|
||||||
var a = cast[array[2, float32]](v)
|
var a = cast[array[2, float32]](v)
|
||||||
|
@ -667,7 +668,7 @@ block:
|
||||||
doAssert q == quat(0, 0, 0, 0)
|
doAssert q == quat(0, 0, 0, 0)
|
||||||
|
|
||||||
block:
|
block:
|
||||||
# Test matrix to quat test.
|
# Test matrix and vector multiplication.
|
||||||
var a3 = mat3(
|
var a3 = mat3(
|
||||||
0.9659258723258972, -0.258819043636322, 0.0,
|
0.9659258723258972, -0.258819043636322, 0.0,
|
||||||
0.258819043636322, 0.9659258723258972, 0.0,
|
0.258819043636322, 0.9659258723258972, 0.0,
|
||||||
|
@ -679,12 +680,17 @@ block:
|
||||||
77.64571380615234, 0.0, 1.0
|
77.64571380615234, 0.0, 1.0
|
||||||
)
|
)
|
||||||
|
|
||||||
|
when not defined(js):
|
||||||
|
# TODO: Figure out why we loose soo much precision in js.
|
||||||
|
|
||||||
doAssert a3 * b3 ~= mat3(
|
doAssert a3 * b3 ~= mat3(
|
||||||
1.0000, 0.0000, 0.0000,
|
1.0000, 0.0000, 0.0000,
|
||||||
0.0000, 1.0000, 0.0000,
|
0.0000, 1.0000, 0.0000,
|
||||||
50.0000, 50.0000, 1.0000
|
50.0000, 50.0000, 1.0000
|
||||||
)
|
)
|
||||||
|
|
||||||
|
doAssert a3 * vec2(77.64571380615234, 0) ~= vec2(50.0, 50.0)
|
||||||
|
|
||||||
doAssert mat3(1, 2, 3, 4, 5, 6, 7, 8, 9) *
|
doAssert mat3(1, 2, 3, 4, 5, 6, 7, 8, 9) *
|
||||||
mat3(10, 20, 30, 40, 50, 60, 70, 80, 90) ~= mat3(
|
mat3(10, 20, 30, 40, 50, 60, 70, 80, 90) ~= mat3(
|
||||||
300.0000, 360.0000, 420.0000,
|
300.0000, 360.0000, 420.0000,
|
||||||
|
@ -692,8 +698,6 @@ block:
|
||||||
1020.0000, 1260.0000, 1500.0000
|
1020.0000, 1260.0000, 1500.0000
|
||||||
)
|
)
|
||||||
|
|
||||||
doAssert a3 * vec2(77.64571380615234, 0) ~= vec2(50.0, 50.0)
|
|
||||||
|
|
||||||
block:
|
block:
|
||||||
# test quat and matrix lookat
|
# test quat and matrix lookat
|
||||||
doAssert lookAt(vec3(1, 2, 3), vec3(0, 0, 0)).quat ~=
|
doAssert lookAt(vec3(1, 2, 3), vec3(0, 0, 0)).quat ~=
|
||||||
|
|
Loading…
Reference in a new issue