Three.js plane inherit topography from set of meshes - three.js

What's working:
I have a solution for loading in topography using terrain tiles. Each tile occupies a plane as mesh. The image on the plane can then be any map tile source. Each plane mesh is a child of an object3d and offset accordingly to create the overall terrain.
The Question:
I am not sure the best way to go about having an irregular shape inherit 3d surfaces. This shape could be drawn or imported as KML. Is there a way to use a vertex shader to inherit the topography? I would like the topography as a mesh so that I can interrogate the topography of the shape. In this way it is different from using a shader to paint the surface as a mesh result is needed.
I do not yet have code for this to share as I do not know where to start. Vertex shader? Constructive solid Geometry?

Related

OpenGL ES: mixing perspective and orthographic projections

I have a scene rendered using a perspective projection. I'm attempting to render an additional piece of geometry (a polyline) into the scene using an orthographic projection.
This is working fine, but the geometry rendered using the orthographic projection is always rendered above everything else in the scene. Ideally, I would like the polyline geometry to correctly maintain it's depth in terms of the depth buffer (with objects at a closer Z to the camera drawn over the top of it).
Is this possible, or would I be better off using a perspective projection for the polyline and negating things like perspective divide in the vertex shader?

Unity3d Transform View Frustum

How do I transform a Unity3d camera's view frustum so that I can pass in a Plane and have the camera's near clipping plane become that plane? The plane might not be perpendicular to the looking direction. I am not familiar with the Matrix4x4.
image
I am not interested in a solution involving applying a material with a custom shader to every object in my scene.
Thanks for any help!

Three.js Merge objects and textures

My question is related to this article:
http://blog.wolfire.com/2009/06/how-to-project-decals/
If my understanding is correct, a mesh made from the intersection of the original mesh and a cube is added to the scene to make a decal appear.
I need to save the final texture. So I was wondering if there is a way to 'merge' the texture of the original mesh and the added decal mesh?
You'd need to do some tricky stuff to convert from the model geometry space into UV coordinate space so you could draw the new pixels into the texture map. If you want to be able to use more than one material that way, you'd also probably need to implement some kind of "material map" similar to how some deferred rendering systems work. Otherwise you're limited to at most, one material per face, which wouldn't work for detailed decals with alpha.
I guess you could copy the UV coordinates from the original mesh into the decal mesh, and the use that information to reproject the decal texture into the original texture

How to apply texture to mesh without specifying UV's in geometry using three.js?

Is it possible to apply texture to mesh without specifying UV's in geometry in three.js ?
There are classes such as THREE.CubeGeometry, THREE.SphereGeometry, etc. that automatically generate the UV coordinates for you. However, if you are creating your own geometry from scratch (i.e., specifying vertex locations, creating faces, etc.) then the answer is no. Either you need to set the UV coordinates manually when creating the geometry, or you need to write a custom shader which determines the UV coordinates for any given point. Think about it this way: if you don't specify UV coordinates, the points on your geometry have no idea which point on your texture they should display.

Intersect Sprites with Raycaster

I want to realize a 3D interactive globe with three.js and I wonder if there is a way to intersect over Sprites primitive with the Raycaster?
If you check the source code for RayCaster at
https://github.com/mrdoob/three.js/blob/master/src/core/Raycaster.js
it would appear that the intersectObject function only checks objects that are instances of THREE.Particle or THREE.Mesh, not THREE.Sprite. Possibly this is because sprites could be set to use screen coordinates, and so a ray that projects into your 3d scene wouldn't make sense in this situation, or if placed in the scene as the sprite image always faces the camera, it doesn't act like your standard 3d mesh.
Perhaps you could attach a PlaneGeometry or a very thin CubeGeometry to the position of your sprite, set its rotation to the rotation of the camera so that it is always parallel to the view plane of the camera like the sprite is, and then check for intersections with the mesh instead?

Resources