-
-
Save RasVandoros/f14b5e98b2fff8f960a69f880ab2a1ef 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
// Time-based skybox - G-van | |
let urlNW = "https://media-crvox.sfo2.digitaloceanspaces.com/0x5b962f3782702530eaab7e52e110a77d470f28e7/1653559546276-15aa9a6b-4903-457d-9a2d-5dbde2108b60.png" | |
let urlDW = "https://media-crvox.sfo2.digitaloceanspaces.com/0x008f38a71dd5e39f3eb4959411ebd724a4707818/1653612118184-3be3746d-2ee8-41bb-a955-2688b58e3ac4.png" | |
let urlNN = "https://media-crvox.sfo2.digitaloceanspaces.com/0x5b962f3782702530eaab7e52e110a77d470f28e7/1653559610342-7d74da9d-7a55-4d77-9196-1a0875d62f56.png" | |
let urlDN = "https://media-crvox.sfo2.digitaloceanspaces.com/0x008f38a71dd5e39f3eb4959411ebd724a4707818/1653612288581-23f836a7-f6b8-4ce8-9e27-d5f4f97560d2.png" | |
let urlNE = "https://media-crvox.sfo2.digitaloceanspaces.com/0x5b962f3782702530eaab7e52e110a77d470f28e7/1653559639173-a9ee4e93-f0fc-4ea7-907b-51d94f1eecae.png" | |
let urlDE = "https://media-crvox.sfo2.digitaloceanspaces.com/0x008f38a71dd5e39f3eb4959411ebd724a4707818/1653612361495-9b3164cd-251a-44b4-bbec-a22e0da9d57d.png" | |
let urlNS = "https://media-crvox.sfo2.digitaloceanspaces.com/0x5b962f3782702530eaab7e52e110a77d470f28e7/1653559660795-d4f1b1e5-b0a2-45d8-83af-022d6462ccb0.png" | |
let urlDS = "https://media-crvox.sfo2.digitaloceanspaces.com/0x008f38a71dd5e39f3eb4959411ebd724a4707818/1653612396502-bf47dbe4-3a56-4185-a7a3-8dc8818ff93a.png" | |
let urlNUp = "https://media-crvox.sfo2.digitaloceanspaces.com/0x5b962f3782702530eaab7e52e110a77d470f28e7/1653559691645-0316963c-2ad7-42fa-ac8e-b44e33ede0aa.png" | |
let urlDUp = "https://media-crvox.sfo2.digitaloceanspaces.com/0x008f38a71dd5e39f3eb4959411ebd724a4707818/1653612243071-26c17920-5b38-4338-971a-97f0cf62bf67.png" | |
let day = true | |
myInterval = setInterval(updateTime, 1000) | |
function updateTime() { | |
var myDate = new Date().getHours(); | |
if (myDate >= 17 || myDate < 7) { | |
if(day == true) { | |
setNightBg() | |
} | |
} | |
else { | |
if (day == false) { | |
setDayBg() | |
} | |
} | |
} | |
function setDayBg() { | |
let bgW = parcel.getFeatureById('bgW') | |
let bgE = parcel.getFeatureById('bgE') | |
let bgN = parcel.getFeatureById('bgN') | |
let bgS = parcel.getFeatureById('bgS') | |
let bgUp = parcel.getFeatureById('bgUp') | |
bgW.set({url:urlDW}) | |
bgE.set({url:urlDE}) | |
bgS.set({url:urlDS}) | |
bgN.set({url:urlDN}) | |
bgN.set({url:urlDN}) | |
bgUp.set({url:urlDUp}) | |
day = true | |
} | |
function setNightBg() { | |
let bgW = parcel.getFeatureById('bgW') | |
let bgE = parcel.getFeatureById('bgE') | |
let bgN = parcel.getFeatureById('bgN') | |
let bgS = parcel.getFeatureById('bgS') | |
let bgUp = parcel.getFeatureById('bgUp') | |
bgW.set({url:urlNW}) | |
bgE.set({url:urlNE}) | |
bgS.set({url:urlNS}) | |
bgN.set({url:urlNN}) | |
bgN.set({url:urlNN}) | |
bgUp.set({url:urlNUp}) | |
day = false | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Instructions:
Place this script anywhere within the free space / parcel
Set up your skybox around the free space.
By placing big images on every side including the top.
A total of 5 images.
Give each of them an id matching the script.
North side -> bgN
South side -> bgS
East side -> bgE
West side -> bgW
Ceiling -> bgUp
Customize the background images you are using.
At the moment, the script will update the skybox with the day and night images that @liliia_eth designed.
If you would like to customize the script further, you will need to change the URLs within the script.
It's lines 4-22. Simply replace any of the image URLs with one of yours and it should work.
For your understanding here is an example.
The name of the first variable is urlNW.
That means: urlN(ight)W(est)
Use the same pattern to understand what each variable refers to and change its corresponding url.
Customize the exact time that each night falls.
Do that in line 34 of the script.
At the moment, the script says:
if (myDate >= 17 || myDate < 7)
That means that nighttime falls after 17.00 and lasts until 7.00. ( The symbol || means OR)
Change the numbers to your liking!
Change how often time is checked.
You prob should not change this part but let me explain just in case.
This is done on line 26:
myInterval = setInterval(updateTime, 1000)
The number 1000 means that the script checks what time it is every 1000 milliseconds (1 second).