This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// ============================================================================ | |
// | |
// Quick sketch / rough idea of a redux store/state/action/reducer pattern. | |
// | |
// This works differently to ReduxJS, in that the reducer does not implement a | |
// switch statement for the action, but instead uses a double-dispatch | |
// functional call from the action to a factory that produces the redicer. | |
//. The store also has methods for each action type. | |
// |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// Example using self.map to get a strong reference to a weak reference on self. | |
// | |
import Foundation | |
import PlaygroundSupport | |
final class Test { | |
private let queue: DispatchQueue |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// Example showing how to add Equatable protocol conformance to a complex enum using a switch statement. | |
// | |
// Useful if you need to compare two enums, e.g: | |
// let a = ApplicationViewState.content("foo") | |
// let b = ApplicationViewState.connectionError | |
// let c = ApplicationViewState.content("foo" | |
// a == b // false | |
// |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func opticalFlow(referenceImage: UIImage, floatingImage: UIImage) -> UIImage? { | |
let request = VNGenerateOpticalFlowRequest( | |
targetedCGImage: referenceImage.cgImage! | |
) | |
request.computationAccuracy = .high | |
request.outputPixelFormat = kCVPixelFormatType_TwoComponent32Float | |
imageRequestHandler = VNImageRequestHandler( | |
cgImage: floatingImage.cgImage! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as THREE from 'three'; | |
import { | |
AnimationContext, | |
AnimationState, | |
AnimationStates | |
} from './animationStateMachine'; | |
import { AnimationAction, AnimationClip, AnimationMixer, Clock, Object3D, Scene } from 'three'; | |
import { loadActorModel, removeRootMotion } from './engine'; | |
import { FBXLoader } from 'three/examples/jsm/loaders/FBXLoader.js'; | |
import { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader.js'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { getAnimationDebugInfo } from './engine'; | |
// Animation state class | |
export class AnimationState { | |
context: AnimationContext | null = null; | |
private retryCount: number = 0; | |
private static MAX_RETRIES: number = 5; | |
private audioEffect: string | null = null; | |
private animationName: string; | |
private transitionDuration: number; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Import Three.js and additional modules | |
import * as THREE from 'three'; | |
import { FBXLoader } from 'three/examples/jsm/loaders/FBXLoader.js'; | |
import { AnimationClip, AnimationMixer, Object3D, Scene, Vector3 } from 'three'; | |
import { AnimationDebugInfo } from './debug'; | |
// Global animation speed multiplier | |
const ANIMATION_SPEED_MULTIPLIER = 1.2; | |
// Animation variables |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as THREE from 'three'; | |
// TODO: Change the navigation mesh completely. Use a texturemap on the navmesh to indicate walkable regions. Render the textures using an orthographic camera set at the player's head height. | |
export function cutHolesInFloor(group: THREE.Group, floorMesh: THREE.Mesh): void { | |
// Helper function to collect all meshes in the group, including nested ones | |
function getAllMeshes(object: THREE.Object3D): THREE.Mesh[] { | |
const meshes: THREE.Mesh[] = []; | |
object.traverse((child) => { | |
if (child instanceof THREE.Mesh) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as THREE from 'three'; | |
import { | |
AnimationContext, | |
AnimationState, | |
AnimationStates | |
} from './animationStateMachine'; | |
import { AnimationAction, AnimationClip, AnimationMixer, Clock, Object3D, Scene } from 'three'; | |
import { loadActorModel, removeRootMotion } from './engine'; | |
import { FBXLoader } from 'three/examples/jsm/loaders/FBXLoader.js'; | |
import { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader.js'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as THREE from 'three'; | |
import { World } from './world'; | |
/** | |
* Particle configuration class | |
*/ | |
export class ParticleConfig { | |
name: string; | |
textures: string[]; | |
lifetime: number; |
OlderNewer