Skip to content

Instantly share code, notes, and snippets.

@shallaa
shallaa / SoftEngine.js
Created April 27, 2015 07:04
SoftEngine.js
/**
* Created by JunHo on 2015-03-29.
*/
var SoftEngine;
(function(W){
W['requestAnimationFrame'] = (function(){
return W['requestAnimationFrame'] ||
W['webkitRequestAnimationFrame'] ||
W['mozRequestAnimationFrame'] ||
function(callback){
@shallaa
shallaa / mg0.2.js
Created June 2, 2015 01:51
mogl.0.2
( function( global ){
var MoGL = (function(){
var isFactory, isSuperChain,
uuidProp, isAliveProp, idProp,
uuid, counter, totalCount,
MoGL, fn;
//내부용 상수
isFactory = {factory:1},//팩토리 함수용 식별상수
isSuperChain = {superChain:1},//생성자체인용 상수
( function( W ){
'use strict';
(function(){ //webGL은 되지만 지원되지 않는 기능의 polyfill
var test = function test(){};
if(!('name' in test) || test.name != 'test'){ //함수에 name속성이 없다면..
Object.defineProperty( Function.prototype, 'name', {
get:function(){
var f;
if(!('__name' in this)){//캐쉬에서 없다면
f = this.toString();//함수를 문자열로 바꿔서 function과 ()사이의 문자열을 이름으로 추출
@shallaa
shallaa / frustum.js
Created June 23, 2015 11:47
frustum
.method('matPerspective', {
description:'퍼스펙티브 매트릭스',
sample: [
'var mtx = new Matrix();',
'mtx.matPerspective(55, 4/3,0.1,1000);'
],
ret: ['this - 메서드체이닝을 위해 자신을 반환함.'],
param:[
'fov:number - 시야각, degree 단위로 입력',
'aspect:number - 가로/세로비율',
@shallaa
shallaa / exam1.js
Last active December 1, 2015 15:23
function abc() {
var a = 'bbb';
console.log(a); // ---- 1
function c() {
console.log(a); // --- 2
(function() {
console.log(a); // --- 3
a = 'ccc';
})();
var a;
@shallaa
shallaa / exam2.js
Last active December 1, 2015 15:03
var obj = {
a: console.log(this), // --- 1
fn: function() {
console.log(this); // --- 2
function fn() {
console.log(this); // --- 3
}
fn();
}
}
@shallaa
shallaa / exam3.js
Last active December 1, 2015 15:21
var a = 0;
for(var i = 5; i--; ) { a++; };
console.log(a);
var b = 0;
for(var i = 5; i--, i;){ b++; };
console.log(b);
@shallaa
shallaa / exam4.js
Last active December 1, 2015 17:27
function Child(aa, bb) {
this.aa = aa;
this.bb = bb;
}
function Parent() {
}
Parent.prototype.a = [1];
Parent.prototype.f = function() {
this.a.push(this.a.length + 1);
};
@shallaa
shallaa / exam5.js
Last active December 1, 2015 15:20
function closure(start) {
return function count() {
return {
inc: function() { start++; },
get: function() { return start; }
}
}
}
var f1 = closure(0);
var f2 = f1;
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>무제 문서</title>
</head>
<body>
<canvas id="c" width="500" height="500"></canvas>
<script id="2d-vertex-shader2" type="notjs">
attribute vec4 a_position;