Application for Visualizing Rays Bouncing Through City

I’m looking for a 3D rendering tool to develop an application (browser or desktop) and babylon.js seems to be it. I’m a C++ software engineer of >10 years who knows how to play with python/bash, and enough javascript/HTML/CSS to be dangerous.

What I need to do is a few steps long:

  1. Import a file of “buildings” represented by 2D outlines (in the XY-plan), a minimum height, and a maximum height. Many of these will be simple cuboids, but some may have more than 4 sides. The data for these can be a list of triangles per building. Say up to 1,000.
  2. Import a list of triangles representing a terrain. Say up to 10,000.
  3. Import a list of line segments showing the path a bunch of balls or bullets would take bouncing around the city from point A to point B. This line has a thin width. Say up to 100,000 segments.
  4. The ability to attach data to the line segments (say color or length or width) and then easily turn them on/off with some drop-down filters.
  5. Other notes: Everything in the scene is static, not changing over time. I don’t really care about textures and shadows look so long as you can fly around the scene and see the different buildings/rays (for instance brown terrain, gray buildings, and green lines are OK).

Before I start down this road:

  1. Do you think babylon can handle this well?
  2. I’m thinking performance should be OK, but I’m a little worried of going down the wrong path with how I structure my code or using the wrong idiom to load/form meshes, and finding it’s way too slow in the end. I need it to be really fast to load/render/filter on a workstation.
  3. I’m hoping much of this can be refactoring example code to suit for rendering and maybe writing some file importers as needed… is that a realistic hope? Does anyone know if there are some relevant code blocks or even similar applications I can grab code from?

Thanks so much for any hours your response will save me!!!

Hiya tcdan. Wow, cool project! I’ll try MY version of answers.

  1. Yes, our extrudeShape, polygonMeshBuilder, and a cool system called GeometryBuilder… can all do extrudes from line-shapes… and set end-caps or not. I recently used an extrudeShape… here. I believe @nasimiasl’s GeometryBuilder… uses SVG lines as its “layout”. And let’s not forget about @jerome’s Solid Particle System (SPS) which is AMAZINGLY performant with collision-testing cuboids.

  2. Yes, but most people would not use a list of triangles, whatever that is. We would use a ground mesh or heightMap or displaceMap. I don’t know what a “list of triangles” is, but if it has vertex positions, we can convert it to the vertexData objects that are “the database” for a single BJS mesh. A vertexData object holds vertex positions, their indicies (triangle “face” connecting), their lighting normals, sometimes their UVs (texture mapping), and sometimes color-per-vertex data. BJS standard boxes are 24-vert… making them flat-shaded by default. There are other 8-vert smooth-shaded ways, as wanted. Our edgesRenderer can give-back some geo-definition to smooth-shaded 8-vert boxes. [demo]

  3. Import line segments? Their paths are pre-calculated? If so, yeah, these trajectories would be used to create a linesMesh object. They can have color and length, single or multi-segmented, but they are NOT thickness-adjustable. But, they could be converted to “tubeMesh” fairly easily.

Regarding pre-calculated trajectories that are imported: Its more fun to let a JS algorithm draw/calc the line segments afer extrudedBuildings.onReady… using BJS raycasting and a ricochet formula. :slight_smile:

  1. Already covered. No thickness without converting linesMesh into tubeMesh/cylinder “rods”. All your tubes would be perfectly straight trajectory… and thus… low-vert-count, hi-perf tubes (no sub-divs along the way).

  2. Can do, easy.

1b. Yep, BJS can handle this… if you’re running on a platform more-modern than an Apple2e. :slight_smile:

2b. No problems. BJS doesn’t render anything that is not within camera.fov (field-of-view) “frustum” (cone). Our core coders team… are all performance junkies. If they can somehow squeeze another 2 FPS from ANYWHERE, they will. They’re essentially obsessed with performance. But you must be sure to KNOW how to utilize those available performance features… and we can help (and so can docs-reading). But what you have described… I think you have nothing to worry about AT ALL. Want to “fire” the balls from a physics engine “gun”, and have them leave a smoke trail as they ricochet from building-wall to building-wall (with gravity and velocity fall-off matching real-Earth physics)? I think CAN DO. With our new Ammo plugin, even MATERIAL physics… you know… was the ricochet off-of brick? Wood? Steel? Plastic? Material density tests and penetration calcs, even! Projectile material tests and (bullet lead) soft-body deformations. SO COOL! (sorry, tmi)

3b. Create Your Own File Importer - Babylon.js Documentation A custom file importer… how cool is THAT? But we already allow import of a ton of standard and bleeding-edge filetypes. Umm… this is a guess… but… I think JSON “blobs” are used quite often… to transfer data around, for BJS scenes. I know nothing about them.

Now… don’t count on my answers to mean ANYTHING. I am wrong… pretty often. I mislead… pretty often. I’m a forever-noob… but I have been hanging-around watching BJS grow… from infancy (6+ years). I’m no pro-coder. I’m an artist, and demented experimenter… and I talk a lot in posts… which sometimes work ok for noobs to read… as if they were tutorials. I over-explain… because I like kids and foreigners who don’t speak much English. I’m a founding member of the World famous “Lamer Support Foundation”… and I need to maintain a certain level of stupidity and inexperience… to fulfill that role. :smiley: In deep-tech category… I haven’t advanced at all, in 30+ years. I still use vacuum-tube-powered mesh, and my BJS scenes are coal-steam driven. heh. I hope I’ve been helpful and somewhere near correct. Party on, good luck, we’re here to help-out. Stay tuned for more/better comments.

Geez, no more replies than mine? hmm.

Where have all the typists gone? sigh. Sorry tcdan… I might have put them all to-sleep with my prev post. :smiley: Maybe my rambling answer… covered all the bases. Nah… I doubt that. heh

Maybe tcdan got a brain tumor from trying to read it.

(Wingy launches some fireworks - it’s drone-hunting season… 1-day only… today) :slight_smile: