forked from Lngramos/three
-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathobjects_text_sprite.go
More file actions
67 lines (54 loc) · 1.7 KB
/
objects_text_sprite.go
File metadata and controls
67 lines (54 loc) · 1.7 KB
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
package three
//go:generate go run object3d_method_generator/main.go -typeName TextSprite -typeSlug text_sprite
import (
"github.com/gopherjs/gopherjs/js"
)
type TextSprite struct {
*js.Object
Text string
ID int `js:"id"`
Position *Vector3 `js:"position"`
Rotation *Euler `js:"rotation"`
Geometry *BufferGeometry `js:"geometry"`
MatrixAutoUpdate bool `js:"matrixAutoUpdate"`
RenderOrder int `js:"renderOrder"`
Visible bool `js:"visible"`
}
var _ Object3D = &TextSprite{}
type TextSpriteParameters struct {
*js.Object
TextSize int `js:"textSize"`
RedrawInterval int `js:"redrawInterval"`
Material *TextSpriteMaterial `js:"material"`
Texture *TextTextureParams `js:"texture"`
}
type TextSpriteMaterial struct {
*js.Object
Color *Color `js:"color"`
}
type TextTextureParams struct {
*js.Object
Text string `js:"text"`
FontFamily string `js:"fontFamily"`
Align string `js:"align"`
}
func NewTextSprite(text, align string, textSize int, color *Color) *TextSprite {
material := &TextSpriteMaterial{
Object: js.Global.Get("THREE").Get("SpriteMaterial").New(),
}
material.Color = color
textureParams := &TextTextureParams{
Object: js.Global.Get("THREE").Get("TextTexture").New(),
}
textureParams.Text = text
textureParams.Align = align
params := &TextSpriteParameters{
Object: js.Global.Get("Object").New(),
}
params.Object.Set("texture", textureParams)
params.Object.Set("material", material)
params.Object.Set("textSize", textSize)
return &TextSprite{
Object: js.Global.Get("THREE").Get("TextSprite").New(params),
}
}