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
const q = this._hoverEffect.$viewManager.active._components.lights._directionalLight.shadow.camera.quaternion | |
const v = vector3.set(0, 0, -1).applyQuaternion(q) | |
this.helper.setDirection(v) | |
this._mesh.material.uniforms.uLightDirection.value.copy(v) | |
// Implementation from https://gist.github.com/TimSC/8c25ca941d614bf48ebba6b473747d72 | |
vec3 projectToGround(vec3 planeNormal, vec3 planePoint, vec3 rayDirection, vec3 rayPoint ) { | |
float epsilon=0.000001; |
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 * as THREE from 'three' | |
const vertexShader = ` | |
varying vec2 vUv; | |
void main() { | |
gl_Position = vec4(position.xy * 2., 1.0, 1.0); | |
vUv = uv; | |
} | |
` |
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
@mixin delay($delayOffset, $type, $baseDelay: 0ms, $childNumber: 5) { | |
@for $i from 1 through $childNumber { | |
&:nth-child(#{$i}) { | |
$finalDelay: $baseDelay + $delayOffset * (1 - $i); | |
@if $type == "both" { | |
animation-delay: $finalDelay; | |
transition-delay: $finalDelay; | |
} @else { | |
#{$type}-delay: $finalDelay; | |
} |
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
// ------------ | |
// --- MATH --- | |
// ------------ | |
float remap(float value, float start1, float stop1, float start2, float stop2) { | |
return start2 + (stop2 - start2) * ((value - start1) / (stop1 - start1)); | |
} | |
float cremap(float value, float start1, float stop1, float start2, float stop2) { | |
float r = remap(value, start1, stop1, start2, stop2); |
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
declare module 'virtual-scroll' { | |
export type VirtualScrollEvent = { | |
x: number // total distance scrolled on the x axis | |
y: number // total distance scrolled on the y axis | |
deltaX: number // distance scrolled since the last event on the x axis | |
deltaY: number // distance scrolled since the last event on the y axis | |
originalEvent: Event // the native event triggered by the pointer device or keyboard | |
} | |
export type VirtualScrollCallback = (e: VirtualScrollEvent) => void |
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 * as THREE from 'three' | |
/** | |
* Utility class for gpgpu | |
* | |
* | |
* Receives initTexture and shaderMaterial. | |
* | |
* | |
* Each tick renders the material with the previous state as input. |
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
const randomVectorInCone = (theta: number, target: THREE.Vector3) => { | |
const z = remap(Math.random(), [0, 1], [Math.cos(theta), 1]) | |
const phi = remap(Math.random(), [0, 1], [0, 2 * Math.PI]) | |
target.set( | |
Math.sqrt(1 - z * z) * Math.cos(phi), | |
Math.sqrt(1 - z * z) * Math.sin(phi), | |
z | |
) | |
target.normalize() |
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
type Callback<T, K extends keyof T> = (prop: T[K], prevProp: T[K] | null) => void | |
type OnChange<T> = <K extends keyof T>(propName: K, cb: Callback<T, K>, triggerOnBind?: boolean) => () => void | |
type Trigger<T> = <K extends keyof T>(propName: K) => void | |
export type ObservableState<T> = { | |
__onChange: OnChange<T> | |
__trigger: Trigger<T> | |
} & T |