【aframe】エモい空つくろう!空の色を変更・グラデーションにする方法
さて、今回学ぶことはこちら
- 空の色の変更方法(単色)
- 空をグラデーションにする方法
空の色の変更方法(単色)
まずは空の色を変更する方法です。
<a-sky color="black"></a-sky>
これをa-sceneの中に入れましょう。
終わった!一瞬!!
"black"の部分に色名かカラーコードを入れてください。
ちなみに上の画像は"lightblue"を入れました。
お好みの色名やカラーコードを入れてくださいね。
空をグラデーションにする方法
空をグラデーションにするにはこちら。
<head> <title>Page Title</title> <!-- aframeのライブラリ呼び出し --> <script src="https://rawgit.com/aframevr/aframe/master/dist/aframe-master.min.js"></script> <!-- 空のグラデーションのためのコンポーネント呼び出し --> <script src="https://unpkg.com/aframe-environment-component@1.0.0/dist/aframe-environment-component.min.js"></script> </head> <body> <a-scene> <a-sky radius="200" theta-length="110" material="shader:gradientshader;topColor:black;bottomColor:white" geometry="" visible="" id="sky" position=""></a-sky> </a-scene> </body>
skyをグラデーションにできるコンポーネントを追加しています。
https://github.com/supermedium/aframe-environment-component
a-skyの中の"shader:gradientshader;topColor:black;bottomColor:white"
ここでtopColor(天井側の色)とbottomColor(地面側の色)を指定してあげるといい感じのグラデーションな空が完成します。
あと、radius="200" theta-length="110"で
ふたつの色の割合とか変更できると思います!(まだ試してない)
上のサンプルで指定したtopColor:black;bottomColor:whiteで実行した空はこんな感じ。
おまけ
引用:uiGradients - Beautiful colored gradients
グラデーションの空をいい感じに作り上げるためにこんなサイトを利用してみてはいかがでしょうか!
カラーの組み合わせがとても参考になります。
エモい空を作りましょう!