Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
a-super-sky
Advanced tools
Fancy, lightweight, drop-in day-night sky component for A-Frame.
Utilizes a-sun-sky and aframe-star-system for A-Frame 1.1.0 compatible stars; Also borrowed heavily from aframe-environment-component's "starry" preset, a static scene, that I used for the 1.2.0 stars and as a starting point to extrapolate fog color to light color. Beyond those, this library adds controls to enable and control animation, fog to create a more appealing (imo) star fade in/out effect, stronger sunset effect, and also adds a directional light entity that roughly tracks the sun/moon to allow shining a directional shadow-casting light source from the shader's "sun". Significant effort has been spent creating smooth transitions between all of these moving parts to create a coherent environment.
fog
creates feeling of creeping shadowy darkness after sunset, that then retreats as stars slowly fade into view and light the scene, without the cost of the equivalent shadowscycleduration
as high as you are willing to, and then throttle
as high as you can tolerate` before stuttering occurs.add sources to project:
add to sources:
<script src="https://cdn.jsdelivr.net/npm/a-super-sky@1.1.0/super-sky.js"></script>
add to the above:
<script src="https://cdn.jsdelivr.net/gh/matthewbryancurtis/aframe-star-system-component@db4f1030/index.js"></script>
then add a super-sky entity to your scene:
(it's recommended that you set sunbeamTarget
to the selector that matches your user's camera)
<a-super-sky
cycleduration="1"
groundcolor="#7BC8A4"
></a-super-sky>
if using the very popular aframe environment component, make sure you tell it to not set a sky:
<a-entity environment="skyType:none; lighting:none; "></a-entity>
cycleduration
is how long 1 sun loop takes (in minutes). By default, a full day is twice this length. (if mooncycle="false"
, it's 1x this length.)throttle
as high as you can before it starts looking choppy. By default, it'll target 40 updates per second (throttle=25), but will proportionately auto-tune down from that if cycleduration
starts to be longer than 10
(because that's when you stop needing 40 calcs per second to still get enough frames per arc angle in the sky for it to look smooth). You can set super-sky-debug="true"
to see logging info about the auto-tune throttle state, or run document.querySelector('[super-sky]').components['super-sky'].throttle
in your console. Net result: the longer your day, the lighter the computational load, and it'll always look smooth.groundcolor
should be set manually, and is used to calculate more realistic light color.targetfpd="0"
will mean the scene will freeze and not run any update calculationsstartpercent=".25"
means you want the scene to be at the 25% of a full day/night cycle, while .99
would be just before sunrise. 0
(default) is sunrise itself. 49
would be 1% before moon rises, .75
would be 'moonset'. (If mooncycle=false
, it's percent of just the sun rotation, instead of sun+moon rotations.)if you want shadows, add the shadow
component to entities that you want to cast shadows and receive shadows (allow shadows to be casted upon):
<a-sphere shadow="cast:true; receive:true;"></a-sphere>
<a-plane shadow="cast:false; receive:true;"></a-plane>
orbitduration
to whatever you want. The higher the number, the slower the sky. The slower the sky, the less often calculations need to be done to update it while still looking smooth.orbitduration
starts to be above 11
(unit is in minutes), which would be 20 minutes for a day/night cycle if mooncycle="true"
. You can see logged output regarding the tuning, throttle, fps, fpd (frames per degree), etc. when super-sky-debug="true"
/.targetfpd
(target frames per degree) if desired.I want to assume it's somehow my fault, but for some reason in my tests oldData
is almost always coming in as an empty object, and in general I'm observing very strange behavior when trying to use the 'correct' update()
functionality for A-Frame components? I'll file an issue here, but in the meantime I've just worked around the issue...
document.querySelector('[super-sky]').components['super-sky'].updateOrbitDuration(.1)
document.querySelector('[super-sky]').components['super-sky'].updateOrbitDuration(10000)
document.querySelector('[super-sky]').components['super-sky'].updateOrbitDuration(.1)
Easiest way? Pick hardcoded 'starttime', 'orbitduration' and 'mooncycle' values for your app. Voila, if their browser has correct time, then it'll always be in sync for all users. Use the correct/same values at instantiation.
snap/sync after the fact can be done for now this way:
// comp1
let user1Sky = JSON.stringify(document.querySelector('[super-sky]').components['super-sky'].shareSky())
// "{\"mooncycle\":true,\"orbitduration\":1.1,\"starttime\":1628045331326}"
// comp2
let user1Sky = JSON.parse(
"{\"mooncycle\":true,\"orbitduration\":1.1,\"starttime\":1628045331326}"
);
document.querySelector('[super-sky]').components['super-sky'].data.mooncycle = user1Sky.mooncycle
document.querySelector('[super-sky]').components['super-sky'].updateOrbitDuration(user1Sky.orbitduration)
document.querySelector('[super-sky]').components['super-sky'].data.starttime = user1Sky.starttime
document.querySelector('[super-sky]').components['super-sky'].updateSkyEpoch()
Add 'roughness' to the material to reduce shininess. In my demos, for example, I use material="roughness:.633"
on the <a-plane>
that acts as the ground
shadowsize
attribute, which underneath affects the light.shadowCamera
left/right/top/bottom values. This is how many meters from the sunbeamtarget
you calculate shadows from. Keep in mind that too large and the shadows get lower res... you'll need to start crafting some custom light/shadowCamera values here.sunbeamtarget
attribute, depending on your scene. This is the center of the invisible box around which shadows are calculated. By default, in this app, it's the user's view (so, [camera]
), and the default is the shadowsize
attribute of 15m (so, shadows are calculated within a 30m box around the user). If you only have things shadows should be cast from in the middle of the map, but want to see them even from far away, setting the target to the center of your map would work. This will make surface reflections during sunrise/sunset be a bit off, though, so probably compensate for that (e.g., add roughness to the appropriate material) to cover that up.Add a light source if your scene can handle it, or adjust starlightintensity
to a higher than default (.1) value (like .2) if you want to use fewer lights for higher performance/simplicity.
Look into shadow bias, and if you changed the default values for the sunbeamdistance
, that's probably the cause.
showshadowlight='false'
shadowsize
smaller (default is 15)cycleduration
as high as you are willing to, and then make throttle
(default 10ms) as high as you can before the updates look choppy.shadowMapHeight
and shadowMapWidth
of the sunbeam
to a lower value (default is 1024; try 512, or even further down to 256).cast
and receive
shadow
.You can file an issue, I'd be interested to hear. But honestly, you should probably see the docs to dig deeper into this. I'm not an expert.
As per the docs, add material="fog:false;"
to X.
document.querySelector('[super-sky]').components['super-sky'].timeOfDay()
update()
functionality seems completely borked? Have worked around it for now, but mostly updating values in a-frame inspector, for example, won't work.FAQs
drop-in full-featured sky
The npm package a-super-sky receives a total of 7 weekly downloads. As such, a-super-sky popularity was classified as not popular.
We found that a-super-sky demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.