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
float ConvertLinear01DepthToRawDepth(float d) | |
{ | |
// Linear01Depth | |
// return 1.0 / (_ZBufferParams.x * z + _ZBufferParams.y); | |
// d = 1.0 / (_ZBufferParams.x * z + _ZBufferParams.y); | |
// d * (_ZBufferParams.x * z + _ZBufferParams.y) = 1.0; | |
// _ZBufferParams.x * z * d + _ZBufferParams.y * d = 1.0; | |
// _ZBufferParams.x * z * d = 1.0 - _ZBufferParams.y * d; | |
// z = (1.0 - _ZBufferParams.y * d) / (_ZBufferParams.x * d); |
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.Generic; | |
using UnityEngine; | |
namespace Utilities | |
{ | |
public class GameObjectPool<T> where T : Component | |
{ | |
private GameObject _rootObj; | |
private T _spawnObject; | |
private int _poolNum; |
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; | |
namespace Utilities | |
{ | |
// ---------------------------------------------------------------------------------------- | |
// refs: | |
// https://stackoverflow.com/questions/33437244/find-children-of-children-of-a-gameobject | |
// ---------------------------------------------------------------------------------------- | |
public static class TransformUtilities |
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.Generic; | |
namespace Utilities | |
{ | |
// singleton: https://gist.github.com/takumifukasawa/9519ed0f64abdf68608d098a3441b0d9 | |
public class ServiceLocator : SingletonComponent<ServiceLocator> | |
{ | |
private static Dictionary<Type, object> _dictionary = new Dictionary<Type, object>(); |
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 UnityEngine; | |
namespace Utilities | |
{ | |
public class SingletonComponent<T> : MonoBehaviour where T : MonoBehaviour | |
{ | |
private static T _instance; | |
public static T Instance |
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 UnityEngine; | |
using System.Collections.Generic; | |
using System.Linq; | |
namespace Utilities | |
{ | |
public class StateMachine<T> where T : IConvertible |
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
export class TimeAccumulator { | |
targetFPS; | |
#callback; | |
#lastTime; | |
maxChaseCount; | |
constructor(targetFPS, callback, maxChaseCount = 60) { | |
this.targetFPS = targetFPS; | |
this.#callback = callback; |
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
export class TimeSkipper { | |
targetFPS; | |
#callback; | |
#lastTime; | |
constructor(targetFPS, callback) { | |
this.targetFPS = targetFPS; | |
this.#callback = callback; | |
} |
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
<!doctype html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0" | |
name="viewport"> | |
<meta content="ie=edge" http-equiv="X-UA-Compatible"> | |
<title>Document</title> | |
<style> | |
.wrapper { |
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
// obj の情報はここに書いてある | |
// https://ja.wikipedia.org/wiki/Wavefront_.obj%E3%83%95%E3%82%A1%E3%82%A4%E3%83%AB | |
export default async function loadObj(path) { | |
const response = await fetch(path); | |
const text = await response.text(); | |
const lines = text.split('\n'); | |
// webgl用のデータ群 | |
const positions = []; |
NewerOlder