This file contains hidden or 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
class RunTillTrue{ | |
constructor( s, func = null ){ | |
this.sec = s; | |
this.thread = null; | |
this.task = func; | |
this.active = false; | |
this.run = ()=>{ | |
if( !this.active || this.task() == true ) this.stop(); | |
}; |
This file contains hidden or 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 Mutation Observer, it checks to see if a Widget has been resized. */ | |
class ResizeObserver{ | |
constructor( elm, cb, timeOut=300 ){ | |
this.callBack = cb; | |
this.timeOut = timeOut; | |
this.obs = new MutationObserver( this.onCallback.bind(this) ); | |
this.obs.observe( elm, { attributes:true, childList:false, characterData:false, attributeOldValue:true } ); | |
} | |
onCallback( mList, ob ){ |
This file contains hidden or 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
let ecs = new Ecs() | |
.addSystem( new TestSys(), 50, true ); | |
let e = ecs.newEntity( "hero", ["Test"] ); | |
ecs.updateSystems(); | |
// COMPONENT | |
class Test{ | |
constructor(){ | |
this.string = "test"; |
This file contains hidden or 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
//################################################################################################# | |
class Water{ | |
constructor( gridSize=500, gridCell=51, style=0, defaultColor=0x676789 ){ | |
this.mat = new GerstnerWaveShader( gridCell ); | |
this.grid = new LineDotGrid( gridSize, gridSize, gridCell, gridCell, 0x676789, 0, 0, 2, this.mat, false ); | |
this._waveCount = 0; | |
//Center the Grid in World Space | |
this.grid.obj3D.position.x = gridSize * -0.5; | |
this.grid.obj3D.position.z = gridSize * -0.5; |
This file contains hidden or 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
//http://codeflow.org/entries/2010/aug/28/integration-by-example-euler-vs-verlet-vs-runge-kutta/ | |
//https://jsfiddle.net/bkanber/pDngH/ | |
//https://github.com/pqml/spring | |
//http://lolengine.net/blog/2015/05/03/damping-with-delta-time | |
//https://github.com/keijiro/SmoothingTest | |
//https://gafferongames.com/post/spring_physics/ | |
//https://stackoverflow.com/questions/5100811/algorithm-to-control-acceleration-until-a-position-is-reached | |
// | |
//http://lolengine.net/blog/2015/05/03/damping-with-delta-time |
This file contains hidden or 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 SCROLL_TOP_OFFSET = -19; | |
class Scroll{ | |
static next(){ | |
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
if( ! this.ary ){ | |
let elm, root = document.getElementById("ContentArea"); | |
this.ary = new Array(); | |
for( let i=0; i < root.childNodes.length; i++ ){ | |
if( root.childNodes[ i ].nodeType != 1 ) continue; |
This file contains hidden or 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
use std::any::Any; | |
use std::marker::PhantomData; | |
//#################################################### | |
struct Test{ data: Box<dyn Any> } | |
#[derive(Default, Debug)] | |
struct Pos{ x: f32 } | |
#[derive(Default, Debug)] |
This file contains hidden or 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 BITBLOCK_SIZE : usize = 16; | |
const BITBLOCK_SIZEF : f32 = 16.0; | |
type BitBlock = u16; | |
fn calc_block_size( n: f32 ) -> usize { ( n / BITBLOCK_SIZEF ).ceil() as usize } | |
fn calc_block( n: f32 ) -> usize { ( n / BITBLOCK_SIZEF ).floor() as usize } | |
#[derive(Debug)] | |
struct BitSet{ |
This file contains hidden or 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
#[derive(Debug)] | |
pub struct DenseVec<T>{ | |
data : Vec<T>, | |
e2d : Vec<usize>, | |
d2e : Vec<usize>, | |
} | |
impl<T> IStorage<T> for DenseVec<T>{ | |
fn new() -> Self{ DenseVec{ data: Vec::new(), e2d: Vec::new(), d2e: Vec::new() } } |
This file contains hidden or 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
#![allow(non_snake_case)] | |
#![allow(dead_code)] | |
#![allow(unused_variables)] | |
#![allow(unused_imports)] | |
#![allow(unused_mut)] | |
use std::fmt::Debug; | |
use std::cell::{ RefCell, RefMut, Ref }; | |
use std::collections::HashMap; | |
use std::any::{ TypeId, Any }; |