Skip to content

Commit

Permalink
Structure updates.
Browse files Browse the repository at this point in the history
  • Loading branch information
vaneenige committed May 17, 2019
1 parent 1e5a9f7 commit a403a41
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 46 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ dist
node_modules
.DS_Store
package-lock.json
coverage
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
registry=https://registry.npmjs.org/
43 changes: 9 additions & 34 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@
"start": "http-server demo --silent & $npm_execpath run watch",
"watch": "microbundle watch --format umd --entry demo/src/index.js --output demo/dist/bundle.js",
"build": "microbundle --name Phenomenon --format es,umd --sourcemap false",
"eslint": "eslint src/index.js",
"test": "karmatic",
"prepare": "$npm_execpath run eslint && $npm_execpath run test && $npm_execpath run build"
"prepare": "$npm_execpath run test && $npm_execpath run build"
},
"repository": {
"type": "git",
Expand All @@ -31,39 +30,15 @@
"particles",
"shaders"
],
"devDependencies": {
"eslint": "^5.9.0",
"eslint-config-airbnb-base": "^13.0.0",
"eslint-config-prettier": "^3.3.0",
"eslint-plugin-import": "^2.13.0",
"eslint-plugin-prettier": "^3.0.0",
"http-server": "^0.11.1",
"karmatic": "^1.2.0",
"microbundle": "^0.7.0",
"prettier": "^1.15.2",
"webpack": "^4.17.1"
},
"eslintConfig": {
"extends": [
"airbnb-base",
"prettier"
],
"plugins": [
"prettier"
],
"rules": {
"linebreak-style": "off",
"prettier/prettier": [
"error"
]
},
"env": {
"browser": true,
"mocha": true
}
},
"prettier": {
"printWidth": 100,
"singleQuote": true
"singleQuote": true,
"trailingComma": "es5"
},
"devDependencies": {
"http-server": "^0.11.1",
"karmatic": "^1.3.1",
"microbundle": "^0.11.0",
"webpack": "^4.31.0"
}
}
24 changes: 12 additions & 12 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class Instance {
modifiers: {},
attributes: [],
multiplier: 1,
buffers: []
buffers: [],
});

// Assign optional parameters
Expand Down Expand Up @@ -84,13 +84,13 @@ class Instance {
if (typeof this.geometry.vertices !== 'undefined') {
this.attributes.push({
name: 'aPosition',
size: 3
size: 3,
});
}
if (typeof this.geometry.normal !== 'undefined') {
this.attributes.push({
name: 'aNormal',
size: 3
size: 3,
});
}
this.attributeKeys = [];
Expand Down Expand Up @@ -224,15 +224,15 @@ class Renderer {
canvas = document.querySelector('canvas'),
context = {},
contextType = 'experimental-webgl',
settings = {}
settings = {},
} = {}) {
// Get context with optional parameters
const gl = canvas.getContext(
contextType,
Object.assign(
{
alpha: false,
antialias: false
antialias: false,
},
context
)
Expand All @@ -244,14 +244,14 @@ class Renderer {
canvas,
uniforms: {},
instances: new Map(),
shouldRender: true
shouldRender: true,
});

// Assign default parameters
Object.assign(this, {
devicePixelRatio: 1,
clearColor: [1, 1, 1, 1],
position: { x: 0, y: 0, z: 2 }
position: { x: 0, y: 0, z: 2 },
});

// Assign optional parameters
Expand All @@ -265,7 +265,7 @@ class Renderer {
vec4: (loc, val) => gl.uniform4fv(loc, val),
mat2: (loc, val) => gl.uniformMatrix2fv(loc, false, val),
mat3: (loc, val) => gl.uniformMatrix3fv(loc, false, val),
mat4: (loc, val) => gl.uniformMatrix4fv(loc, false, val)
mat4: (loc, val) => gl.uniformMatrix4fv(loc, false, val),
};

// Enable depth
Expand Down Expand Up @@ -332,17 +332,17 @@ class Renderer {

this.uniforms.uProjectionMatrix = {
type: 'mat4',
value: projectionMatrix
value: projectionMatrix,
};

this.uniforms.uViewMatrix = {
type: 'mat4',
value: viewMatrix
value: viewMatrix,
};

this.uniforms.uModelMatrix = {
type: 'mat4',
value: modelMatrix
value: modelMatrix,
};
}

Expand Down Expand Up @@ -386,7 +386,7 @@ class Renderer {

Object.assign(settings, {
gl: this.gl,
uniformMap: this.uniformMap
uniformMap: this.uniformMap,
});

const instance = new Instance(settings);
Expand Down

0 comments on commit a403a41

Please sign in to comment.