Last active
April 26, 2022 14:15
-
-
Save tomaspietravallo/209489932a993fe8a954035e1eca4fce to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// [email protected] | |
import { Pool, } from './volts'; | |
// Pool aka 'a pool of dynamically instanced objects' | |
// A Pool of 'block0' objects, to be spawned under the Focal Distance | |
const pool = new Pool('block0', 'Focal Distance', {}); | |
// spawn 400 objects, 5 at a time | |
// (more at a time -> slower) | |
pool.populate(400, 5); |
// [email protected]
import Diagnostics from 'Diagnostics';
import { Pool, } from './volts';
import Time from "Time";
// Pool aka 'a pool of dynamically instanced objects'
// A Pool of 'block0' objects, to be spawned under the Focal Distance
const pool = new Pool('block0', 'Focal Distance', {});
let D1 = undefined
const tryInstancing = async () => {
if (D1 === undefined) {
D1 = new Date();
Diagnostics.log(`Starting ${D1}`)
};
await pool.populate(400,100);
// await new Promise(resolve=>Time.setTimeout(resolve, 500));
const s = (new Date() - D1) / 1000;
if (s > 10) {
Diagnostics.warn(`Stopped, took: ${s.toFixed(4)} seconds\nSpawned: ${pool.preInstancedObjectsCount} blocks`);
} else {
Diagnostics.log(s);
tryInstancing();
}
};
tryInstancing();
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
note that "slower" is somewhat dependent on the device & block. generally it'll take the same overall time to instance objects in the studio, which can make 1-5 @ a time feel smoother, but on device (iPhoneX, iOS15) I'm able to instance 400 directly without any hiccups