Basic render 3D perspective projection onto 2D screen with camera (without opengl)

The ‘way it’s done’ is to use homogenous transformations and coordinates. You take a point in space and: Position it relative to the camera using the model matrix. Project it either orthographically or in perspective using the projection matrix. Apply the viewport trnasformation to place it on the screen. This gets pretty vague, but I’ll … Read more

How to render clipped surfaces as solid objects

You want to render a clipped surface as if it were a solid — i.e., not hollow. You can achieve that effect with MeshPhongMaterial — or any three.js material for that matter — with a simple hack to the material shader. material.onBeforeCompile = function( shader ) { shader.fragmentShader = shader.fragmentShader.replace( ‘#include <output_fragment>’, ` vec3 backfaceColor … Read more

Projecting the ARKit face tracking 3D mesh to 2D image coordinates

Maybe you can use the projectPoint function of the SCNSceneRenderer. extension ARFaceAnchor{ // struct to store the 3d vertex and the 2d projection point struct VerticesAndProjection { var vertex: SIMD3<Float> var projected: CGPoint } // return a struct with vertices and projection func verticeAndProjection(to view: ARSCNView) -> [VerticesAndProjection]{ let points = geometry.vertices.compactMap({ (vertex) -> VerticesAndProjection? … Read more

Flipping a quaternion from right to left handed coordinates

I don’t think any of these answers is correct. Andres is correct that quaternions don’t have handedness (*). Handedness (or what I’ll call “axis conventions”) is a property that humans apply; it’s how we map our concepts of “forward, right, up” to the X, Y, Z axes. These things are true: Pure-rotation matrices (orthogonal, determinant … Read more