Skip to content

Instantly share code, notes, and snippets.

@NanoDano
NanoDano / bounce_random_cubes.py
Last active April 18, 2022 17:31
Blender3D script to generate and animate bouncing cubes
import bpy
import random
# Reference: https://www.youtube.com/watch?v=r8hqLh_HE08
# After running the script, go to the Animation tab and hit SPACE to run the animation
def delete_all_cubes():
# Select all cubes by name
for o in bpy.context.scene.objects:
@NanoDano
NanoDano / macropad_piano.py
Created June 26, 2022 22:27
AdaFruit MacroPad as MIDI piano (CircuitPy)
# This is the `code.py` for CircuitPy
"""
G9 = 127
"A4" = 69
C4 = 60
C0 = 12
"""
from adafruit_macropad import MacroPad
# C minor pentatonic
@NanoDano
NanoDano / rename_all.py
Created March 4, 2023 21:07
Rename all files recursively
# Remove a prefix from all files in recursive subdirs
import os
PREFIX_TO_REMOVE = "Something - "
ROOT_DIR = "."
for (dirpath, dirs, files) in os.walk(ROOT_DIR):
for filename in files:
# print(f'{filename} {dirpath} {dirs}')
@NanoDano
NanoDano / export_blend_to_gltf.py
Created May 15, 2023 00:09
Export a Blender file to glTF from the command-line headless
"""
This script automates the process of exporting the .glb file.
You can run this script from the command-line in a headless mode.
Example usages:
```sh
blender -b -P export_gltf.py mymodel.blend
/Applications/Blender.app/Contents/MacOS/Blender -b -P export_gltf.py "Monkey.blend"
```
@NanoDano
NanoDano / PlayerMovementController.cs
Created June 13, 2023 23:38
Unity MMORPG style player camera
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerMovementController : MonoBehaviour
{
public CharacterController characterController;
public Camera playerCamera;
private Vector3 playerVelocity;
@NanoDano
NanoDano / PlayAnimationOnKey.cs
Created June 19, 2023 00:09
Play animation on keypress in Unity
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayAnimationOnKey : MonoBehaviour
{
public Animation animationToPlay;
// Start is called before the first frame update
void Start()
{