我是coffeescript的新手.有没有办法让这三行设置旋转并完成相同的事情,就像你在python中通过解压缩元组一样?
@cosines = [0,1,0]
@branch.rotation.x = Math.asin(@cosines.x)
@branch.rotation.y = Math.asin(@cosines.y)
@branch.rotation.z = Math.asin(@cosines.z)
Run Code Online (Sandbox Code Playgroud)
这是我能想到的最好的代码.
@cosines = [0,1,0]
rot = @branch.rotation
[rot.x, rot.y, rot.z] = [Math.asin(c) for c in @cosines]
Run Code Online (Sandbox Code Playgroud)
该拆包 解构是一样的Python,但用方括号.
| 归档时间: |
|
| 查看次数: |
1264 次 |
| 最近记录: |