Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
'Asset Store' : Func(webbrowser.open, "https://itch.io/tools/tag-ursina"),
# 'Open Scene Editor' : Func(print, ' '),
'Reload Textures [F6]' : application.hot_reloader.reload_textures,
'Reload Models [F7]' : application.hot_reloader.reload_models,
'Reload Code [F5]' : application.hot_reloader.reload_code,
},
width=.3,
x=.64,
enabled=False,
eternal=True
)
self.cog_menu.on_click = Func(setattr, self.cog_menu, 'enabled', False)
self.cog_menu.y = -.5 + self.cog_menu.scale_y
self.cog_menu.scale *= .75
self.cog_menu.text_entity.x += .025
self.cog_menu.highlight.color = color.azure
self.cog_button = Button(parent=self.editor_ui, eternal=True, model='circle', scale=.015, origin=(1,-1), position=self.bottom_right)
def _toggle_cog_menu():
self.cog_menu.enabled = not self.cog_menu.enabled
self.cog_button.on_click = _toggle_cog_menu
elif name.endswith('.bam'):
success = self.writeBamFile(path / name)
print('saved .bam to:', path / name)
if __name__ == '__main__':
from ursina import *
app = Ursina()
verts = ((0,0,0), (1,0,0), (.5, 1, 0), (-.5,1,0))
tris = (1, 2, 0, 2, 3, 0)
uvs = ((1.0, 0.0), (0.0, 1.0), (0.0, 0.0), (1.0, 1.0))
norms = ((0,0,-1),) * len(verts)
colors = (color.red, color.blue, color.lime, color.black)
e = Entity(model=Mesh(vertices=verts, triangles=tris, uvs=uvs, normals=norms, colors=colors), scale=2)
# line mesh test
verts = (Vec3(0,0,0), Vec3(0,1,0), Vec3(1,1,0), Vec3(2,2,0), Vec3(0,3,0), Vec3(-2,3,0))
tris = ((0,1), (3,4,5))
lines = Entity(model=Mesh(vertices=verts, triangles=tris, mode='line', thickness=4), color=color.cyan, z=-1)
points = Entity(model=Mesh(vertices=verts, mode='point', thickness=.05), color=color.red, z=-1.01)
# points.model.mode = MeshModes.point # can also use the MeshMode enum
print(e.model.recipe)
# e.model.save('bam_test', application.compressed_models_folder, 'bam')
EditorCamera()
app.run()
cubes = []
# best to paste up text BEFORE you mess with the lights
Text(origin=(4,-18), text="default lighting")
Text(origin=(.8,-4), text="replace with dimmer ambient for these three cubes")
Text(origin=(.9,11), text="also add a bit of directional for these three cubes")
cubes.append(Entity(model='cube', color=color.red, position=(-4,3,0)))
cubes.append(Entity(model='cube', color=color.green, position=(0,3,0)))
cubes.append(Entity(model='cube', color=color.blue, position=(4,3,0)))
# add a light for all subsequent entities
Light(type='ambient', color=(0.3,0.3,0.3,1)) # full spectrum
cubes.append(Entity(model='cube', color=color.red, position=(-4,0,0)))
cubes.append(Entity(model='cube', color=color.green, position=(0,0,0)))
cubes.append(Entity(model='cube', color=color.blue, position=(4,0,0)))
# add a light for all subsequent entities
Light(type='directional', color=(0.3,0.3,0.3,1), direction=(1,1,1)) # dim full spectrum
cubes.append(Entity(model='cube', color=color.red, position=(-4,-3,0)))
cubes.append(Entity(model='cube', color=color.green, position=(0,-3,0)))
cubes.append(Entity(model='cube', color=color.blue, position=(4,-3,0)))
def update():
for i in cubes:
i.rotation_x += .3
i.rotation_y += .3
i.rotation_z += .2
if __name__ == '__main__':
from ursina import *
app = Ursina() # create the game
cubes = []
# best to paste up text BEFORE you mess with the lights
Text(origin=(4,-18), text="default lighting")
Text(origin=(.8,-4), text="replace with dimmer ambient for these three cubes")
Text(origin=(.9,11), text="also add a bit of directional for these three cubes")
cubes.append(Entity(model='cube', color=color.red, position=(-4,3,0)))
cubes.append(Entity(model='cube', color=color.green, position=(0,3,0)))
cubes.append(Entity(model='cube', color=color.blue, position=(4,3,0)))
# add a light for all subsequent entities
Light(type='ambient', color=(0.3,0.3,0.3,1)) # full spectrum
cubes.append(Entity(model='cube', color=color.red, position=(-4,0,0)))
cubes.append(Entity(model='cube', color=color.green, position=(0,0,0)))
cubes.append(Entity(model='cube', color=color.blue, position=(4,0,0)))
# add a light for all subsequent entities
Light(type='directional', color=(0.3,0.3,0.3,1), direction=(1,1,1)) # dim full spectrum
cubes.append(Entity(model='cube', color=color.red, position=(-4,-3,0)))
cubes.append(Entity(model='cube', color=color.green, position=(0,-3,0)))
cubes.append(Entity(model='cube', color=color.blue, position=(4,-3,0)))
def set_up(self):
from ursina.entity import Entity
self.reparent_to(render)
self.reflection_map = load_texture(self.reflection_map)
self.fog = Fog('fog')
self.setFog(self.fog)
self.fog_color = color.light_gray
self.fog_density = 0