-
Notifications
You must be signed in to change notification settings - Fork 2
/
client-bot-examine
51 lines (44 loc) · 1.84 KB
/
client-bot-examine
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/nodejs
// https://github.com/zach-capalbo/hubs-client-bot
const {HubsBot} = require('hubs-client-bot')
let bot = new HubsBot();
async function runBot() {
let URL_TO_YOUR_HUBS_ROOM='https://hubs.mozilla.com/baRZEkr/clinical-simulation';
await bot.enterRoom(URL_TO_YOUR_HUBS_ROOM, {name: "Automation Bot"});
await bot.page.waitFor(5000);
// Wait for network sync. TODO: Add an actual event handler
let STETHOSCOPE='https://sketchfab.com/3d-models/stethoscope-ce1ba77195dd4746841e58346864c059';
await bot.spawnObject({url: STETHOSCOPE, position: {x:2,y:1,z:10}, pinned: true})
await bot.spawnObject({url: STETHOSCOPE, position: {x:9,y:1,z:-5}, pinned: true, dynamic: true, gravity: {x:0, y: -9.8, z:0}, autoDropTimeout: 1000});
await bot.say("Placed stethoscope");
await bot.page.waitFor(5000);
await bot.evaluate(() => {
function adjustWindow(el, idx) {
NAF.utils.getNetworkedEntity(el).then(networkedEl => {
const mine = NAF.utils.isMine(networkedEl);
var owned = NAF.utils.takeOwnership(networkedEl);
//var center = el.getAttribute('position');
//console.log("pos "+JSON.stringify(center));
networkedEl.setAttribute("scale","2 2 2");
//networkedEl.setAttribute("pinned", "true");
networkedEl.setAttribute("position", "2 1 " + (idx * 1 + 0));
networkedEl.setAttribute("rotation", "0 0 32");
networkedEl.setAttribute("dynamic", "true");
networkedEl.setAttribute("gravity", "0 -9.8 0");
networkedEl.setAttribute("autoDropTimeout", "1000");
console.log("attributes set");
});
}
let objs = document.querySelectorAll("[gltf-model-plus][networked]")
console.log("objs "+objs.length);
for (var i=0; i<objs.length;i++) {
let obj = objs[i];
adjustWindow(obj,i);
}
});
console.log("Done");
await bot.say("...tidy");
//await bot.quit();
//process.exit(0);
}
runBot()