目录

1.创建cube

2.设置旋转

3.设置缩放

4.设置位置

5.设置颜色

6.设置文字


1.创建cube

from ursina import *

app = Ursina()

cube = Entity(model="cube")

app.run()

效果:

 2.设置旋转

from ursina import *

app = Ursina()

cube = Entity(model="cube", rotation = (45, 45, 0))  # 让这个cube绕x轴旋转45°,y轴转45°,z轴不转

app.run()

效果: 

3.设置缩放

from ursina import *

app = Ursina()

cube = Entity(model="cube", scale_x=2)  # 沿x轴扩大2倍
# cube = Entity(model="cube", scale=(1,2,3))  # 让cube沿y轴扩大2倍,z轴扩大3倍

app.run()

效果:

4.设置位置

from ursina import *

app = Ursina()

cube = Entity(model="cube", position=(3,2,1))

app.run()

效果:

5.设置颜色

from ursina import *

app = Ursina()

cube = Entity(model="cube", color=color.red)
# cube = Entity(model="cube", color=color.rgb(0,0,0,0.5))  # R,G,B,A

app.run()

效果: 

6.设置文字

from ursina import *

app = Ursina()

cube = Entity(model="cube", color=color.red)  # R,G,B,A

txt = Text(text="This is a red cube")
# txt = Text(text="This is a red cube", color=color.green)  # 设置文字颜色为绿色
# txt = Text(text="This is a red cube", scale=2)  # 设置文字大小
# txt = Text(text="This is a red cube", x=-0.3,y=-0.3)  # 设置文字位置

app.run()

 效果:

Logo

腾讯云面向开发者汇聚海量精品云计算使用和开发经验,营造开放的云计算技术生态圈。

更多推荐