Skip to content

Instantly share code, notes, and snippets.

View fluidpixel's full-sized avatar

Stuart Varrall fluidpixel

View GitHub Profile
@fluidpixel
fluidpixel / BetterTapGesture.swift
Last active June 11, 2024 00:28
Using SwiftUI DragGesture as a tap, as TapGesture doesn't give location (as of beta6)
struct ContentView: View {
@State var moved: CGFloat = 0
@State var startTime: Date?
var body: some View {
//0 means that it acts like a press
//coordinateSpace local means local to the view its added to
let tap = DragGesture(minimumDistance: 0, coordinateSpace: .local)
.onChanged { value in
//store distance the touch has moved as a sum of all movements
@fluidpixel
fluidpixel / enumerateChildNodesUsingBlock.swift
Created November 30, 2015 22:17
Add light map to materials imported from Collada
sceneView.scene!.rootNode.enumerateChildNodesUsingBlock (){
node, stop in
if let materials = node.geometry?.materials {
for material in materials {
//Blender export doesn't support multiple textures per object, so we add our lightmap to the 2nd UV channel here
let image = SCNImage(named:"WorldLightmap")
material.multiply.contents = image
material.multiply.intensity = 0.7
material.multiply.mappingChannel = 1
}