Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

aframe-environment-component

Package Overview
Dependencies
Maintainers
0
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

aframe-environment-component

Infinite environments for your A-Frame VR scene in just one file.

  • 1.4.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.8K
decreased by-1.9%
Maintainers
0
Weekly downloads
 
Created
Source

aframe-environment-component

A simple way of setting up a whole basic environment for your A-Frame VR scene.

gif

Make sure you are using A-Frame 1.3.0 or later. Then just include aframe-environment-component.js in your HTML:

<script src="https://unpkg.com/aframe-environment-component@1.3.3/dist/aframe-environment-component.min.js"></script>

and add the environment component to an entity:

<a-entity environment></a-entity>

That's it! :)

Presets

The previous code will setup a default scene, but you have a bunch of already predefined presets to choose from, using the preset parameter, like this:

<a-entity environment="preset: <name of the preset>"></a-entity>

You can view and try all the presets in the aframe-environment-component Test Page. The current list of presets are listed in the next section.

Parameters

Apart from using a preset, you can tweak the environment with many parameters, like this:

<a-entity environment="lightPosition: 1 5 -2; groundColor: #445"></a-entity>

You can also select a preset but change some of its parameters:

<a-entity environment="preset: forest; groundColor: #445; grid: cross"></a-entity>

This is the list of the available parameters.

ParameterDefaultDescription
activetrueShow/hides the component. Use this instead of using thevisible attribute
preset'default'Valid values:none, default, contact, egypt, checkerboard, forest, goaland, yavapai, goldmine, threetowers, poison, arches, tron, japan, dream, volcano, starry, osiris, moon
seed1Seed for randomization. If you don't like the layout of the elements, try another value for the seed.
skyType'atmosphere'Valid values:color, gradient, atmosphere
skyColorWhenskyType is color or gradient, it sets the main sky color
horizonColorWhenskyType is gradient, it sets the color of the sky near the horizon
lighting'distant'Valid values:none, distant, point. A hemisphere light and a key light (directional or point) are added to the scene automatically when using the component. Use none if you don't want this automatic lighting set being added. The color and intensity are estimated automatically.
shadowfalseShadows on/off. Sky light casts shadows on the ground of all those objects withshadow component applied
shadowSize10Shadows size
lightPosition0 1 -0.2Position of the main light. IfskyType is atmospheric, only the orientation matters (is a directional light) and it can turn the scene into night when lowered towards the horizon.
fog0Amount of fog (0 = none, 1 = full fog). The color is estimated automatically.
flatShadingfalseWhether to show everything smoothed (false) or polygonal (true).
playArea1Radius of the area in the center reserved for the player and the gameplay. The ground is flat in there and no objects are placed inside.
stageSize200Environment ground diameter and sky radius.
ground'hills'Valid values:none, flat, hills, canyon, spikes, noise. Orography style.
groundYScale3Maximum height (in meters) of ground's features (hills, mountains, peaks..)
groundTexture'none'Valid values:none, checkerboard, squares, walkernoise
groundColor'#553e35'Main color of the ground
groundColor2'#694439'Secondary color of the ground. Used for textures, ignored ifgroundTexture is none
groundDensity64Number of divisions of the ground mesh.
groundFrequency10Frequency used to generate noise / terrain unevenness on the ground mesh.
dressing'none'Valid values:none, cubes, pyramids, cylinders, towers, mushrooms, trees, apparatus, torii. Dressing is the term we use here for the set of additional objects that are put on the ground for decoration.
dressingAmount10Number of objects used for dressing
dressingColor'#795449'Base color of dressing objects
dressingScale5Height (in meters) of dressing objects
dressingVariance'1 1 1'Maximum x,y,z meters to randomize the size and rotation of each dressing object. Use0 0 0 for no variation in size nor rotation
dressingUniformScaletrueIffalse, a different value is used for each coordinate x, y, z in the random variance of size.
grid'none'Valid values:none, 1x1, 2x2, crosses, dots, xlines, ylines. 1x1 and 2x2 are rectangular grids of 1 and 2 meters side, respectively.
gridColor'#ccc'Color of the grid.

The best way to work with them is to press ctrl-alt-i to open the inspector, search for 'environment' in the filter box and select it, and tweak the parameters while checking the changes in realtime. When you are happy, you can use the Copy attributes button or even better, copy the attributes logged in the browser's dev tools console.

Performance

The main idea of this component is to have a complete and visually interesting environment by just including one .js file, with no extra includes or requests. This requires to store all the assets inside the js or (in most of cases) to procedurally generate them. Despite of the computing time and increased file size, both options are normally faster than requesting and waiting for additional textures or model files.

Apart from the parameter dressingAmount, there is not much difference among different values in parameters in terms of performance. Just keep dressingAmount value under watch and lower it if the performance is not optimal.

Help and contact

PRs are appreciated, issues are welcomed. For any question, ping @feiss at aframevr in Slack or Discord.

Keywords

FAQs

Package last updated on 12 Nov 2024

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc