refactor cast into mod with typed arrays and trig tables. Also 3d css transforms for perf