From bd80801bbffd340859edc16c01dd296df3e4c522 Mon Sep 17 00:00:00 2001 From: Cansy Date: Thu, 14 Sep 2023 19:56:27 +0200 Subject: [PATCH] update-parcels --- Party-Time/src/index.ts | 23 +++++++++++------------ Party-Time/src/sceneFactory.ts | 1 - Party-Time/src/startParty.ts | 4 ++-- 3 files changed, 13 insertions(+), 15 deletions(-) diff --git a/Party-Time/src/index.ts b/Party-Time/src/index.ts index bdb0df25a..709bbd907 100644 --- a/Party-Time/src/index.ts +++ b/Party-Time/src/index.ts @@ -12,12 +12,11 @@ export function main() { // Function to call the API async function checkTime() { - const response = await fetch('https://worldtimeapi.org/api/timezone/etc/gmt+3') // GMT+3 const worldtime = await response.json() const timeNow = new Date(worldtime.datetime) - + // Debug console.log('\nParty Start: ', partyStart, '\nTime now: ', timeNow, '\nParty End: ', partyEnd) @@ -29,7 +28,9 @@ export function main() { const days = Math.floor(timeDiff / (1000 * 60 * 60 * 24)) // Calculate the number of hours left after subtracting the days const hours = Math.floor((timeDiff % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60)) - updateSignpost(`Party starts \n in ${days} days \n and ${hours} hours. \n At ${formatAMPM(partyStart.getHours())}`) + updateSignpost( + `Party starts \n in ${days} days \n and ${hours} hours. \n At ${formatAMPM(partyStart.getHours())}` + ) } // While Party else if (timeNow >= partyStart && timeNow <= partyEnd) { @@ -50,15 +51,13 @@ export function main() { const hours = Math.floor((timeDiff % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60)) updateSignpost(`Party ended\n${days} days\nand ${hours} hours ago`) - } - } checkTime() // Fetches time API evey 10 seconds let timer: number = 10 - function LoopSystem( dt: number ) { + function LoopSystem(dt: number) { timer -= dt if (timer <= 0) { timer = 10 @@ -70,18 +69,18 @@ export function main() { function updateSignpost(text: string) { // We get signpost by name set in sceneFactory.ts const signpostEntity = engine.getEntityOrNullByName('signpost') - if(signpostEntity) { + if (signpostEntity) { const signpost = TextShape.getMutable(signpostEntity) signpost.text = text } } function formatAMPM(hours: number) { - const ampm = hours >= 12 ? 'PM' : 'AM'; - hours = hours % 12; - hours = hours ? hours : 12; // the hour '0' should be '12' + const ampm = hours >= 12 ? 'PM' : 'AM' + hours = hours % 12 + hours = hours ? hours : 12 // the hour '0' should be '12' - const strTime = hours + ' ' + ampm; - return strTime; + const strTime = hours + ' ' + ampm + return strTime } } diff --git a/Party-Time/src/sceneFactory.ts b/Party-Time/src/sceneFactory.ts index 5e1385e66..8859e7148 100644 --- a/Party-Time/src/sceneFactory.ts +++ b/Party-Time/src/sceneFactory.ts @@ -159,5 +159,4 @@ export function buildScene() { fontSize: 2 }) Name.create(signpostText, { value: 'signpost' }) - } diff --git a/Party-Time/src/startParty.ts b/Party-Time/src/startParty.ts index 512c676bf..a767fd6fc 100644 --- a/Party-Time/src/startParty.ts +++ b/Party-Time/src/startParty.ts @@ -43,9 +43,9 @@ function createVideoShapes() { const floor = engine.addEntity() MeshRenderer.setPlane(floor) Transform.create(floor, { - position: { x: 8, y:0.05 , z: 8}, + position: { x: 8, y: 0.05, z: 8 }, rotation: Quaternion.fromEulerDegrees(90, 0, 0), - scale: { x: 16, y: 16, z: 16} + scale: { x: 16, y: 16, z: 16 } }) Material.setPbrMaterial(floor, videoMaterial)