I’m working on creating a 3D golf simulation game and am looking for some advice related to Babylon. I have read a lot of the posts related to large scene creation and dynamic tiles, but didn’t really find the details I was looking for.
A bit of background first;
- I’m very familiar with online map platforms like Cesium, Bing/Google Maps…
- I’m already able to create a great 3D golf course in Cesium JS with good performance, but cesium doesn’t have any physics engine. I have 3D terrain tiles, and GLB models.
- An average course in my game covers 10 sq KM and has 1m resolution for terrain. I have about 50 models, many which are trees that are instanced with less than 10K instances needed for a full course usually. If I get a good solution working and am ambitious, that largest course I’d likely attempt would be about 40 sq km since that’s the largest one in real life: Mission Hills Golf Club - Wikipedia
- I’ve been ramping up on blender and could probably
The lack of physics engine in Cesium is a blocker so I have been looking at alternatives, including building the whole thing in Babylon. I’m fairly certain the code I used to generate the course in Cesium is a small fraction of what it would take in Babylon, and there are a lot of other out of the box features there that make it a good starting point, but maybe not a long-term solution.
Before starting over from scratch with Babylon I was wondering about potentially integrating Babylon with cesium, purely for the physics aspect. My thinking is that at any given point in the game the player will have a limited area in which the ball could make it to, for simplicity lets say a rectangle that’s 100 meters wide and 400 meters long (in reality I could potentially use a cone shape to reduce the area further). I was thinking I could possibly use an offscreen canvas with Bablylon and generate that limited area. I could extract a grid of height points from Cesium’s terrain and load the same models. Then I could use a physics engine in babylon to fire the ball and play out the physics of collisions, and just translate the positions from the offscreen canvas to the relative location in Cesium. Does this sound like a reasonable approach?
Side note, I do know that a golf ball flight path is heavily influenced by its spin and likely not something that would be very accurately reproduced in most physics engine. I have however, wrote an algorithm that calculates an accurate flight path with speed and direction information at any point along it. I currently use this for a flat driving range part of my app and it is pretty accurate to reality. I was thinking I could reuse this “ideal” information and step through it with moveWithCollisions until the first collision, then hand it off to a physics engine to simulate.