SpaceSim | body simulation of the solar system
kandi X-RAY | SpaceSim Summary
kandi X-RAY | SpaceSim Summary
SpaceSim is an n-body simulation of the solar system complete with stars, planets, moons, and spacecraft. It is currently setup to simulate various SpaceX launch profiles with vehicles including the Dragon, Falcon 9, and Falcon Heavy.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of SpaceSim
SpaceSim Key Features
SpaceSim Examples and Code Snippets
Community Discussions
Trending Discussions on SpaceSim
QUESTION
I have the following scene https://rawgit.com/bicarbon8/SpaceSim/MomentumProblem/babylon.html that I've setup with the ability to rotate using the following keys:
- i = pitch down
- k = pitch up
- j = roll left
- l = roll right
- u = yaw left
- o = yaw right
- / = cancel all rotation
and to move with the following keys:
- q = move forwards
- a = move backwards
- s = strafe left
- f = strafe right
- e = move up
- d = move down
- \ = cancel all movement
which is working fine to move the mesh in a direction that it is pointing, but I would like to initiate motion based on the rotation of the mesh, but then continue the movement in the original direction irrespective of the change in rotation to the mesh that happens after motion is initiated (maintain momentum).
I'm tracking the motion in each direction via a separate object with x, y, and z values so that each press of the keyboard for motion only modifies this object which is then applied to the mesh for each loop of the animation cycle, but because I'm using:
mesh.locallyTranslate(new BABYLON.Vector3(x, y, z))
when the mesh is rotated the motion rotates with the mesh. How can I convert the directionality of the mesh's rotation into a Vector3 that I can use with World-based translation such that the subsequent rotation of the mesh does not affect the motion it already has?
NOTE: this should simulate motion in a microgravity / no gravity environment
Thanks in advance for any help.
...ANSWER
Answered 2017-Nov-02 at 16:08managed to find a solution on my own through a combination of Unity engine and Three.js solutions to a similar type of problem followed by scouring the Babylon.js github pages. To fix it I had to change my globally tracked velocity object from a direct input based on key presses to a calculated BABYLON.Vector3 based on the mesh's World Matrix and a Normalised Vector3 for the local-space direction I wanted to move the mesh which is then added to the existing global Vector3 used to track the momentum (and is then subsequently applied to the mesh using World-space translation.
Original:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install SpaceSim
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page