1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
import { Object3D } from 'three'
import TextSprite from 'three.textsprite'
import datasetList from './datasetList'
import { choice } from '../../util'
import {
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(1)
cloud.add(sprite)
return sprite
})
scene.add(cloud)
return cloud
}
export function update() {
cloud.rotation.y += CLOUD_ROTATION_SPEED
}
|