summaryrefslogtreecommitdiff
path: root/client/splash/cloud/index.js
diff options
context:
space:
mode:
Diffstat (limited to 'client/splash/cloud/index.js')
-rw-r--r--client/splash/cloud/index.js52
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
+}