Replaced custom functions with three.js equivalents.