Skip to content

Instantly share code, notes, and snippets.

View Anthelmed's full-sized avatar

Anthelme Dumont Anthelmed

View GitHub Profile
@Anthelmed
Anthelmed / Custom cannon js body
Last active November 9, 2022 00:05
Using v-hacd https://github.com/kmammou/v-hacd to create custom collider for cannon js
import THREE from 'three';
import CANNON from 'cannon';
export const generateThreeVertices = (rawVerts) => {
let verts = [];
for(let v = 0; v < rawVerts.length; v+=3){
verts.push(new THREE.Vector3(rawVerts[v],
rawVerts[v+1],
rawVerts[v+2]));
@Anthelmed
Anthelmed / WRL loader and parser
Last active April 2, 2018 21:03
WRL loader/parser es6
/**
* WRLLoader class
*/
class WRLLoader {
/**
* load method
* @returns {Promise}
*/
load(path) {
const xhr = new XMLHttpRequest();
@Anthelmed
Anthelmed / BlendingSurfaceShader.shader
Created September 6, 2017 13:20
Unity blending shader prototype
Shader "Custom/BlendingSurfaceShader" {
Properties {
[NoScaleOffset] _NoiseTex ("Noise", 2D) = "white" {}
[NoScaleOffset] _BottomDiffuseTex ("Bottom diffuse", 2D) = "white" {}
[NoScaleOffset] [Normal] _BottomNormalTex ("Bottom normal", 2D) = "bump" {}
[NoScaleOffset] _MiddleDiffuseTex ("Middle diffuse", 2D) = "white" {}
[NoScaleOffset] [Normal] _MiddleNormalTex ("Middle normal", 2D) = "bump" {}
Shader "Custom/SilhouetteShader"
{
Properties
{
_SilhouetteColor("Silhouette Color", Color) = (0,1,0,1)
}
SubShader
{
Tags{"Queue"="Geometry+1" "RenderType" = "Geometry"}
@Anthelmed
Anthelmed / ReplaceDuplicateMeshesEditorWindow
Last active October 3, 2020 17:29
Unity - Find and replace meshes that are identical but use different assets
using System.Collections.Generic;
using System.Linq;
using UnityEditor;
using UnityEngine;
namespace AnthelmeDumontTools
{
public class ReplaceDuplicateMeshesEditorWindow : EditorWindow
{
private GameObject[] _selectedObjects;
@Anthelmed
Anthelmed / RaymarchSDF.hlsl
Last active October 18, 2023 21:26
A Texture3D SDF function to be used inside Unity shader graph
#ifndef RAYMARCHSDFINCLUDE_INCLUDED
#define RAYMARCHSDFINCLUDE_INCLUDED
#define STEPS 256
#define MAX_DISTANCE 500
#define MIN_DISTANCE 0.001
#if !SHADERGRAPH_PREVIEW
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Texture.hlsl"
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
@Anthelmed
Anthelmed / Animation
Created December 10, 2021 18:44
Using Unity UIToolkit transition animation system to animate a GameObject
using UnityEngine;
using UnityEngine.UIElements;
using UnityEngine.UIElements.Experimental;
public class Animation : MonoBehaviour
{
[SerializeField] private Transform transform;
[SerializeField] private UIDocument uiDocument;
[SerializeField] private int durationMs = 3000;
@Anthelmed
Anthelmed / Menu Button Custom Render Texture.shader
Last active January 28, 2022 09:52
Menu Button Custom Render Texture
Shader "CustomRenderTexture/Menu Button Custom Render Texture"
{
Properties
{
_NoiseScale("Noise Scale", float) = 1
_NoiseStrength("Noise Strength", float) = 0.1
_NoiseSpeed("Noise Speed", float) = 0.1
_NoiseOffset("Noise Offset", float) = 0
}
@Anthelmed
Anthelmed / MainMenu.cs
Created January 28, 2022 09:52
MainMenu
using System;
using System.Collections.Generic;
using Unity.Mathematics;
using UnityEngine;
using UnityEngine.UIElements;
public class MainMenu : MonoBehaviour
{
[SerializeField] private UIDocument mainMenuUIDocument;
[SerializeField] private Material buttonHoverMaterial;
@Anthelmed
Anthelmed / FileUtils.cs
Last active February 8, 2022 21:35
Unity Read/Write SaveAsync/LoadAsync streamingAssets file utils
using System.IO;
using System.Threading;
using System.Threading.Tasks;
using Newtonsoft.Json; // https://docs.unity3d.com/Packages/com.unity.nuget.newtonsoft-json@2.0/manual/index.html
using UnityEngine;
public static class FileUtils
{
public static string RootDirectory
{