Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Python_超人
宇宙模拟器
提交
9f5b0f13
宇宙模拟器
项目概览
Python_超人
/
宇宙模拟器
通知
19
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
宇宙模拟器
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
9f5b0f13
编写于
7月 18, 2023
作者:
三月三net
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Python超人-宇宙模拟器
上级
0dbe0462
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
54 addition
and
19 deletion
+54
-19
sim_scenes/earth/earth_3d.py
sim_scenes/earth/earth_3d.py
+25
-19
simulators/ursina/entities/camera3d.py
simulators/ursina/entities/camera3d.py
+29
-0
未找到文件。
sim_scenes/earth/earth_3d.py
浏览文件 @
9f5b0f13
...
@@ -33,6 +33,7 @@ if __name__ == '__main__':
...
@@ -33,6 +33,7 @@ if __name__ == '__main__':
size_scale
=
1.001
,
parent
=
earth
)
size_scale
=
1.001
,
parent
=
earth
)
bodies
=
[
earth
,
clouds
]
bodies
=
[
earth
,
clouds
]
# camera.camera_pos = "right"
# camera.camera_pos = "right"
# camera_l2r = 0.002 * AU * UrsinaConfig.SCALE_FACTOR
# camera_l2r = 0.002 * AU * UrsinaConfig.SCALE_FACTOR
#
#
...
@@ -47,28 +48,33 @@ if __name__ == '__main__':
...
@@ -47,28 +48,33 @@ if __name__ == '__main__':
#
#
#
#
# camera.switch_position = switch_position
# camera.switch_position = switch_position
init_pos
=
(
1.45
*
earth
.
radius
*
UrsinaConfig
.
SCALE_FACTOR
,
def
on_ready
():
earth
.
camera3d
=
Camera3d
()
earth
.
camera3d
.
position
=
(
1.45
*
earth
.
radius
*
UrsinaConfig
.
SCALE_FACTOR
,
0
,
0
,
-
30000
*
UrsinaConfig
.
SCALE_FACTOR
)
-
30000
*
UrsinaConfig
.
SCALE_FACTOR
)
Camera3d
.
support3d
(
init_pos
)
# def on_ready():
#
# Camera3d.init_on_ready(init_pos)
# earth.camera3d = Camera3d()
# earth.camera3d.position = (1.45 * earth.radius * UrsinaConfig.SCALE_FACTOR,
# 0,
# -30000 * UrsinaConfig.SCALE_FACTOR)
#
# # camera_look_at(earth, rotation_z=0)
# # camera.fov = 40
# earth._3d_card = create_3d_card()
# camera_look_at(earth, rotation_z=0)
# def on_before_evolving(evolve_args):
# camera.fov = 40
# Camera3d.exec_on_before_evolving(evolve_args)
earth
.
_3d_card
=
create_3d_card
()
# earth._3d_card.switch_color()
# earth.camera3d.switch_position()
def
on_before_evolving
(
evolve_args
):
# if earth._3d_card.switch_flag == 1:
earth
.
_3d_card
.
switch_color
()
# evolve_args["evolve_dt"] = 0.0
earth
.
camera3d
.
switch_position
()
if
earth
.
_3d_card
.
switch_flag
==
1
:
evolve_args
[
"evolve_dt"
]
=
0.0
# 订阅事件后,上面的函数功能才会起作用
# 订阅事件后,上面的函数功能才会起作用
# 运行前会触发 on_ready
#
#
运行前会触发 on_ready
UrsinaEvent
.
on_ready_subscription
(
on_ready
)
#
UrsinaEvent.on_ready_subscription(on_ready)
UrsinaEvent
.
on_before_evolving_subscription
(
on_before_evolving
)
# UrsinaEvent.on_before_evolving_subscription(Camera3d.exec_
on_before_evolving)
# 使用 ursina 查看的运行效果
# 使用 ursina 查看的运行效果
# 常用快捷键: P:运行和暂停 O:重新开始 I:显示天体轨迹
# 常用快捷键: P:运行和暂停 O:重新开始 I:显示天体轨迹
...
...
simulators/ursina/entities/camera3d.py
浏览文件 @
9f5b0f13
...
@@ -9,10 +9,18 @@
...
@@ -9,10 +9,18 @@
from
ursina
import
Entity
,
camera
from
ursina
import
Entity
,
camera
from
common.consts
import
AU
from
common.consts
import
AU
from
sim_scenes.func
import
create_3d_card
from
simulators.ursina.ursina_config
import
UrsinaConfig
from
simulators.ursina.ursina_config
import
UrsinaConfig
from
simulators.ursina.ursina_event
import
UrsinaEvent
class
OCamera
:
pass
class
Camera3d
(
Entity
):
class
Camera3d
(
Entity
):
o
=
OCamera
()
def
__init__
(
self
,
**
kwargs
):
def
__init__
(
self
,
**
kwargs
):
super
().
__init__
()
super
().
__init__
()
for
key
,
value
in
kwargs
.
items
():
for
key
,
value
in
kwargs
.
items
():
...
@@ -33,3 +41,24 @@ class Camera3d(Entity):
...
@@ -33,3 +41,24 @@ class Camera3d(Entity):
def
update
(
self
):
def
update
(
self
):
pass
pass
@
staticmethod
def
support3d
(
init_pos
):
def
on_ready
():
Camera3d
.
init_on_ready
(
init_pos
)
UrsinaEvent
.
on_ready_subscription
(
on_ready
)
UrsinaEvent
.
on_before_evolving_subscription
(
Camera3d
.
exec_on_before_evolving
)
@
staticmethod
def
init_on_ready
(
position
):
Camera3d
.
o
.
camera3d
=
Camera3d
()
Camera3d
.
o
.
camera3d
.
position
=
position
Camera3d
.
o
.
_3d_card
=
create_3d_card
()
@
staticmethod
def
exec_on_before_evolving
(
evolve_args
):
Camera3d
.
o
.
_3d_card
.
switch_color
()
Camera3d
.
o
.
camera3d
.
switch_position
()
if
Camera3d
.
o
.
_3d_card
.
switch_flag
==
1
:
evolve_args
[
"evolve_dt"
]
=
0.0
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录