Skip to content

Instantly share code, notes, and snippets.

View lukevanin's full-sized avatar

Luke Van In lukevanin

View GitHub Profile
@lukevanin
lukevanin / beam_triposg.py
Created April 16, 2025 21:05
Run TripoSG 2D-to-3D on beam.cloud
#
# Run TripoSG 2D-to-3D on beam.cloud
#
# Luke Van In (x.com/lukevanin)
#
# This script is used to deploy the TripoSG 2D-to-3D model on beam.cloud.
#
# The model is deployed as a cloud endpoint, which can be called directly
# using the beam.cloud API.
#
@lukevanin
lukevanin / Particles.ts
Created March 22, 2025 08:44
Vibe coded particle system
import * as THREE from 'three';
import { World } from './world';
/**
* Particle configuration class
*/
export class ParticleConfig {
name: string;
textures: string[];
lifetime: number;
@lukevanin
lukevanin / actor.ts
Created March 22, 2025 08:36
Vibe coded actor
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';
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) {
@lukevanin
lukevanin / engine.ts
Created March 16, 2025 16:23
Vibe coded 3D engine utilities
// 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
@lukevanin
lukevanin / animationStateMachine.ts
Created March 16, 2025 16:22
Vibe coded animation state machine
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;
@lukevanin
lukevanin / actor.ts
Created March 16, 2025 16:21
Vibe coded actor
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';
@lukevanin
lukevanin / OpticalFlow.swift
Created December 4, 2022 14:05
Returns an image with vector field lines indicating the optical flow between two images.
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!
//
// 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
//
//
// 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