View useAnimationFrame.ts
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 { useRef, useEffect, useCallback } from 'react' | |
const useAnimationFrame = ( | |
tick: (dt: number, elapsed: number, frame: number) => void | |
) => { | |
const tickRef = useRef(tick) | |
const requestRef = useRef(0) | |
const prevTimeRef = useRef(0) | |
const elapsedRef = useRef(0) | |
const frameRef = useRef(0) |
View ToggleManager.tsx
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 React, { useState, useMemo, useContext } from 'react'; | |
interface ToggleState { | |
items: any[]; | |
toggleItem: (item: any, toggled?: boolean) => boolean; | |
} | |
const ToggleContext = React.createContext<ToggleState>({ | |
items: [], | |
toggleItem: () => false, |
View QueryHelper.cs
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
using System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
[CreateAssetMenu(menuName = "Problematic/Query Helper")] | |
public class QueryHelper : ScriptableObject | |
{ | |
[SerializeField] | |
protected float maxDistance = Mathf.Infinity; | |
[SerializeField] |
View LSystemGenerator.cs
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
using System; | |
using System.Collections; | |
using System.Collections.Generic; | |
using System.Linq; | |
public interface ILSystemGenerator { | |
string Generate (string axiom, int depth); | |
void Clear(); | |
} |
View PoissonDiscSampler.cs
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
using System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
namespace Problematic.Toolkit { | |
// https://www.cs.ubc.ca/~rbridson/docs/bridson-siggraph07-poissondisk.pdf | |
public static class PoissonDiscSampler { | |
const int SAMPLE_LIMIT = 30; | |
public static IEnumerable<Vector2> Sample<T> (QuadTree<T> quadTree, float minSeparation, System.Func<Vector2, T> CreateSample, System.Func<Vector2, QuadTree<T>, float, bool> IsCandidateValid) where T : IQuadTreeObject{ |
View StateHistory.cs
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
using System; | |
using System.Collections.Concurrent; | |
using UnityEngine; | |
public class StateHistory<T> where T : IState<T> { | |
protected T[] buffer; | |
public int Head { get; protected set; } | |
public int Tail { | |
get { | |
if (Count < buffer.Length) { |
View PatrolBehaviour.cs
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
using UnityEngine; | |
using System.Collections.Generic; | |
public class PatrolBehaviour : MonoBehaviour { | |
Queue<Transform> patrolTargets; | |
void Start () { | |
patrolTargets = new Queue<Transform>(); | |
patrolTargets.Enqueue(target1); | |
patrolTargets.Enqueue(target2); |
View flatten.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
function flatten (arr) { | |
if (!(arr instanceof Array)) { | |
return arr; | |
} | |
return arr.reduce((acc, val) => acc.concat(flatten(val)), []); | |
} | |
module.exports = flatten; |
View RateLimiter.cs
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
using UnityEngine; | |
[CreateAssetMenu (menuName = "Problematic/Rate Limiter")] | |
public class RateLimiter : ScriptableObject | |
{ | |
[SerializeField] | |
float capacity; | |
[SerializeField] | |
float fillRate; |
View LitParticle.shader
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
Shader "Custom/Lit Particle" { | |
Properties { | |
_TintColor ("Tint Color", Color) = (1,1,1,1) | |
_MainTex ("Particle Texture", 2D) = "white" {} | |
} | |
SubShader { | |
Tags { "RenderType"="Transparent" "Queue"="Transparent" } | |
LOD 200 | |
CGPROGRAM |
NewerOlder