How to set up SceneKit collision detection

The main things to get about collision detection in SceneKit: it’s based on bit masks, which together form a table. a contact delegate is how you respond to collisions. Making objects collide For example, you might state a bit of game design in plain English like this: Asteroids hit each other (and make smaller asteroids). … Read more

Extracting vertices from scenekit

The geometry source When you call geometrySourcesForSemantic: you are given back an array of SCNGeometrySource objects with the given semantic in your case the sources for the vertex data). This data could have been encoded in many different ways and a multiple sources can use the same data with a different stride and offset. The … Read more

ARKit – What do the different columns in Transform Matrix represent?

ARKit, RealityKit and SceneKit frameworks use 4 x 4 Transformation Matrices to translate, rotate, scale and shear 3D objects (just like simd_float4x4 matrix type). Let’s see how these matrices look like. In 3D Graphics we often use a 4×4 Matrix with 16 useful elements. The Identity 4×4 Matrix is as following: Between those sixteen elements … Read more

How to use iOS (Swift) SceneKit SCNSceneRenderer unprojectPoint properly

Typical depth buffers in a 3D graphics pipeline are not linear. Perspective division causes depths in normalized device coordinates to be on a different scale. (See also here.) So the z-coordinate you’re feeding into unprojectPoint isn’t actually the one you want. How, then, to find the normalized-depth coordinate matching a plane in world space? Well, … Read more