Hello,
First time posting here.
I’m wondering what the significance of the PlayCanvas math.random() function is. Is there some reason why i should be using this over the standard Javascript implementation?
The docs don’t mention anything specific.
http://developer.playcanvas.com/en/api/pc.math.html#random
At first I suspected it was performance related, but after doing some rudimentary tests (below) I’m not so sure…
defaultRandom: 436ms
playCanvasRandom: 528ms
Perhaps there is something significant about the pc namespace that I haven’t picked up yet?
var testSize = 10000000
// test random
console.time('defaultRandom');
defaultRandom(testSize);
console.timeEnd('defaultRandom');
console.time('playCanvasRandom');
playCanvasRandom(testSize);
console.timeEnd('playCanvasRandom');
function defaultRandom(testSize) {
var a1 = [];
while(a1.length < testSize) {
a1.push(Math.random(1,testSize));
}
}
function playCanvasRandom(testSize) {
var a1 = [];
while(a1.length < testSize) {
a1.push(pc.math.random(1,testSize));
}
}