diff options
| author | adamhrv <adam@ahprojects.com> | 2019-01-28 18:11:52 +0100 |
|---|---|---|
| committer | adamhrv <adam@ahprojects.com> | 2019-01-28 18:11:52 +0100 |
| commit | f8b279b2f0be793c5f877cac6373332954c6a5de (patch) | |
| tree | 60be7caeb0e8c96c59718300c68d5b1cdecde6f4 /client/splash/cloud/index.js | |
| parent | dd2c36288aa1e8af14588f9258f6785879b8638c (diff) | |
| parent | b0eb2d9672044a1b64a2a1f21540f9ef1bd7b571 (diff) | |
Merge branch 'master' of github.com:adamhrv/megapixels_dev
Diffstat (limited to 'client/splash/cloud/index.js')
| -rw-r--r-- | client/splash/cloud/index.js | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/client/splash/cloud/index.js b/client/splash/cloud/index.js new file mode 100644 index 00000000..d0a39d8c --- /dev/null +++ b/client/splash/cloud/index.js @@ -0,0 +1,52 @@ +import { Object3D } from 'three' + +import TextSprite from 'three.textsprite' + +import datasetList from './datasetList' +import { choice } from '../../util' + +import { + CLOUD_SCALE, + CLOUD_COLORS, + CLOUD_ROTATION_SPEED, + CLOUD_MAX_COUNT, + CLOUD_TEXT_MIN_SIZE, + CLOUD_TEXT_MAX_SIZE, +} from '../constants' + +import { scene } from '../renderer' + +export const fontFamily = 'Helvetica, Arial, sans-serif' + +let cloud = new Object3D() + +export function init() { + let sprites = Array.from({ length: Math.min(datasetList.length, CLOUD_MAX_COUNT) }, (t, i) => { + const sprite = new TextSprite({ + textSize: CLOUD_TEXT_MIN_SIZE + Math.random() * (CLOUD_TEXT_MAX_SIZE - CLOUD_TEXT_MIN_SIZE), + redrawInterval: 1, + material: { + color: choice(CLOUD_COLORS), + }, + texture: { + text: datasetList[i], + fontFamily, + }, + }) + sprite.position + .setX(Math.random()) + .setY(Math.random()) + .setZ(Math.random()) + .subScalar(1 / 2) + .setLength(1 + Math.random()) + .multiplyScalar(CLOUD_SCALE) + cloud.add(sprite) + return sprite + }) + scene.add(cloud) + return cloud +} + +export function update() { + cloud.rotation.y += CLOUD_ROTATION_SPEED +} |
