python Ursina Engine-3D (02-设置位置、旋转、缩放、颜色和文本)
1.创建cube2.设置旋转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()
效果:
更多推荐
已为社区贡献11条内容
所有评论(0)