Skip to content

Instantly share code, notes, and snippets.

@zadvorsky
zadvorsky / CameraStore.js
Created February 9, 2021 20:40
Store a THREE.js camera position and (Orbit) controls target between page refreshes. Handy if you're working on a scene and refreshing often.
/**
* Use the Web Storage API to save camera position and target between page refreshes.
*
* @param {Object} options
* @param {*} options.camera - The camera you want to store the position of.
* @param {*} [options.controls] - A controls object with a `.target` property.
* @param {String} [options.name="main"] - An optional label. Useful if you want to store multiple cameras.
* @param {Boolean} [options.session=true] - Indicates if you want to use local or session storage.
* See https://developer.mozilla.org/en-US/docs/Web/API/Storage
*/
window.console = {
original: console,
...console,
speak: (strings, func, start) => strings.forEach(string => {
speechSynthesis.speak(new SpeechSynthesisUtterance((start ? start : '') + string))
return console.original[func](string)
}),
log: (...strings) => console.speak(strings, 'log', `Dear diary. `),
info: (...strings) => console.speak(strings, 'info', `For your information. `),
warn: (...strings) => console.speak(strings, 'warn', `I'm warning you. `),
@mbader
mbader / SassMeister-input.scss
Last active January 14, 2021 11:52
Sass Staggered Transition Delay
// ----
// Sass (v3.4.14)
// Compass (v1.0.3)
// ----
@mixin staggered_transitions($nth:1,$items:2,$initial:0,$step:.1){
@for $i from $nth through $items{
&:nth-of-type(#{$i}){
transition-delay:#{$initial}s;
}
@gre
gre / easing.js
Last active April 30, 2024 04:58
Simple Easing Functions in Javascript - see https://github.com/gre/bezier-easing
/*
* This work is free. You can redistribute it and/or modify it under the
* terms of the Do What The Fuck You Want To Public License, Version 2,
* as published by Sam Hocevar. See the COPYING file for more details.
*/
/*
* Easing Functions - inspired from http://gizma.com/easing/
* only considering the t value for the range [0, 1] => [0, 1]
*/
EasingFunctions = {