Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
102 commits
Select commit Hold shift + click to select a range
cb278a4
added initial files from project 1
xnieamo Apr 10, 2017
add709c
plays some notes woohoo
xnieamo Apr 11, 2017
f5a3afb
headaches
xnieamo Apr 11, 2017
a01bf1a
euclidian rhythms and beats
xnieamo Apr 17, 2017
37a6578
MorseThue and got tonal to work
xnieamo Apr 17, 2017
f1acd4f
playing around with chords
xnieamo Apr 18, 2017
e658ba9
readjust how chords work
xnieamo Apr 18, 2017
2cf26c5
add second instrument and drum beats
xnieamo Apr 19, 2017
cd89d3b
integrate save point
xnieamo Apr 19, 2017
a389190
milestone 1 visuals WIP
iambrian Apr 19, 2017
cb5446e
single note play removes lag
xnieamo Apr 19, 2017
4b51b8d
merge
xnieamo Apr 19, 2017
710af64
update package.json
iambrian Apr 19, 2017
3f80f65
Merge branch 'master' of https://github.com/xnieamo/Final-Project
iambrian Apr 19, 2017
18a6066
Update README.md
xnieamo Apr 19, 2017
cdbe33f
Update README.md
xnieamo Apr 19, 2017
a79dc9f
milestone 1 visual readme
iambrian Apr 19, 2017
62c1360
Update README.md
xnieamo Apr 19, 2017
0a4afdc
revert to proper tempo music
xnieamo Apr 19, 2017
e5cec06
Merge branch 'master' of https://github.com/xnieamo/Final-Project
xnieamo Apr 19, 2017
c4948bd
change page title
xnieamo Apr 19, 2017
f39e7bc
update readme
iambrian Apr 19, 2017
ad5f9ae
Merge branch 'master' of https://github.com/xnieamo/Final-Project
iambrian Apr 19, 2017
6fd465c
Update README.md
xnieamo Apr 19, 2017
19592f6
integrate scene 2
iambrian Apr 19, 2017
d72202b
Merge branch 'master' of https://github.com/xnieamo/Final-Project
iambrian Apr 19, 2017
33a3238
new stuff
xnieamo Apr 26, 2017
43a3e7b
WIP
iambrian Apr 26, 2017
90a1fbb
merged
iambrian Apr 26, 2017
941bf78
added melody and attempt at harmony
xnieamo Apr 26, 2017
4e044a4
Update README.md
iambrian Apr 26, 2017
2b08d4c
Update
xnieamo Apr 26, 2017
f46a34f
Update README.md
xnieamo Apr 26, 2017
6b04156
added new scene
iambrian Apr 27, 2017
86aaaeb
merge
iambrian Apr 27, 2017
a110dfb
Update README.md
iambrian Apr 27, 2017
fc96c9d
playing base properly from musicBox class
xnieamo Apr 30, 2017
5778103
playing melody from musicBox
xnieamo Apr 30, 2017
d94be92
made harmony work
xnieamo Apr 30, 2017
39b6d3b
started with melody generation via contour
xnieamo Apr 30, 2017
f5b773e
reflective surface
iambrian May 1, 2017
f14b228
playing around melody stuff
xnieamo May 1, 2017
dd27ad3
Merge branch 'master' of https://github.com/xnieamo/Final-Project
xnieamo May 1, 2017
cb1f69e
added base lines, made melody a bit better
xnieamo May 1, 2017
f7d7881
instrument change
iambrian May 1, 2017
eef6ae2
lightning
iambrian May 1, 2017
f05743f
Merge branch 'master' of https://github.com/xnieamo/Final-Project
iambrian May 1, 2017
dee82dc
good instruments
iambrian May 1, 2017
7022548
I don't know what changed, debugged euclid i think
xnieamo May 1, 2017
e5e7944
Merge branch 'master' of https://github.com/xnieamo/Final-Project
xnieamo May 1, 2017
42ea958
note type enum
iambrian May 2, 2017
1ba4ec4
Merge branch 'master' of https://github.com/xnieamo/Final-Project
iambrian May 2, 2017
c5ad9d3
create anchor sequence
xnieamo May 2, 2017
ac12461
ok
xnieamo May 2, 2017
a31188b
flairs and anchors
xnieamo May 2, 2017
e849266
hook generate base
iambrian May 2, 2017
b703254
merge
iambrian May 2, 2017
13829aa
playing with bass settings
xnieamo May 2, 2017
016d4ac
rando hook
iambrian May 2, 2017
f11f3e4
Merge branch 'master' of https://github.com/xnieamo/Final-Project
xnieamo May 2, 2017
cd1a1c3
weird add octave bug
iambrian May 2, 2017
bb81528
fixed upoctave
iambrian May 2, 2017
c52efdb
idk
xnieamo May 2, 2017
b0ab16f
Merge branch 'master' of https://github.com/xnieamo/Final-Project
xnieamo May 2, 2017
3c8a6a2
delete offscreen objects
iambrian May 2, 2017
7238506
workign on harmonies
xnieamo May 2, 2017
30a07e3
Merge branch 'master' of https://github.com/xnieamo/Final-Project
xnieamo May 2, 2017
1bd8119
testing stuff
xnieamo May 2, 2017
a0fb10f
whatever progress happened
xnieamo May 2, 2017
8619b02
idk
xnieamo May 3, 2017
371dbf6
rain and stuff
iambrian May 3, 2017
f8bfc2e
merge
iambrian May 3, 2017
da8c22a
playing around with stuff
xnieamo May 3, 2017
b5b16ac
Merge branch 'master' of https://github.com/xnieamo/Final-Project
xnieamo May 3, 2017
32e24c9
floaty things
iambrian May 3, 2017
2242a5f
rain contact and skybox gradient
iambrian May 3, 2017
e5f2d24
minor polish stuff
iambrian May 3, 2017
df8b744
add time uniform
iambrian May 3, 2017
a335709
fussing in a new file
xnieamo May 3, 2017
ff16f28
Merge branch 'master' of https://github.com/xnieamo/Final-Project
xnieamo May 3, 2017
a7323a2
interesting harmony
xnieamo May 3, 2017
1e821b8
maybe
xnieamo May 3, 2017
258c6bb
music experiments 2
iambrian May 3, 2017
8948ff3
merge
iambrian May 3, 2017
15165a8
float in icebergs
iambrian May 3, 2017
8546e9a
lots of small changes
xnieamo May 3, 2017
62ceb88
merge
xnieamo May 3, 2017
a5150ca
b melody
iambrian May 3, 2017
60fb94c
merge
iambrian May 3, 2017
6cf8373
music settings
iambrian May 3, 2017
de4bdd3
save music settings
xnieamo May 3, 2017
c65e8b7
merge
xnieamo May 3, 2017
a84c874
update
iambrian May 3, 2017
3527759
Merge branch 'master' of https://github.com/xnieamo/Final-Project
iambrian May 3, 2017
3d2f02f
final b
iambrian May 3, 2017
35a0a5f
finishing touches
xnieamo May 3, 2017
3d8fc85
Merge branch 'master' of https://github.com/xnieamo/Final-Project
xnieamo May 3, 2017
1d2e1ba
better evn
iambrian May 3, 2017
5bc61e3
ripples
iambrian May 5, 2017
e50ed6f
Update README.md
iambrian May 5, 2017
878449f
Update README.md
iambrian May 5, 2017
2c84242
Update README.md
iambrian May 6, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
*.map
192 changes: 115 additions & 77 deletions README.md

Large diffs are not rendered by default.

19 changes: 19 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!DOCTYPE html>
<html>
<head>
<title>Final Project</title>
<style>
html, body {
margin: 0;
overflow: hidden;
}
canvas {
width: 100%;
height: 100%;
}
</style>
</head>
<body>
<script src="bundle.js"></script>
</body>
</html>
35 changes: 35 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"scripts": {
"start": "webpack-dev-server --hot --inline",
"build": "webpack",
"deploy": "gh-pages-deploy"
},
"gh-pages-deploy": {
"prep": [
"build"
],
"noprompt": true
},
"dependencies": {
"dat-gui": "^0.5.0",
"gl-matrix": "^2.3.2",
"midi.js": "",
"soundfont-player": "^0.10.5",
"stats-js": "^1.0.0-alpha1",
"three": "^0.82.1",
"three-orbit-controls": "^82.1.0",
"three.meshline": "^1.0.3",
"tonal": "0.69.0",
"three-effectcomposer": "0.0.1"
},
"devDependencies": {
"babel-core": "^6.18.2",
"babel-loader": "^6.2.8",
"babel-preset-es2015": "^6.18.0",
"gh-pages-deploy": "^0.4.2",
"webpack": "^1.13.3",
"webpack-dev-server": "^1.16.2",
"webpack-glsl-loader": "^1.0.1",
"json-loader": "^0.5.4"
}
}
285 changes: 285 additions & 0 deletions src/Mirror.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,285 @@
/**
* @author Slayvin / http://slayvin.net
*/

const THREE = require('three'); // older modules are imported like this. You shouldn't have to worry about this much

THREE.ShaderLib[ 'mirror' ] = {

uniforms: {
"time": { value: 0 },
"splashes": { type: "v2v", value: [ new THREE.Vector2(-9999,-9999), new THREE.Vector2(-9999,-9999), new THREE.Vector2(-9999,-9999), new THREE.Vector2(-9999,-9999), new THREE.Vector2(-9999,-9999) ] },
"mirrorColor": { value: new THREE.Color( 0xff0000 ) },
"mirrorSampler": { value: null },
"textureMatrix" : { value: new THREE.Matrix4() }
},

vertexShader: require('./shaders/mirror-vert.glsl'),

fragmentShader: require('./shaders/mirror-frag.glsl'),

};

THREE.Mirror = function ( renderer, camera, options ) {

THREE.Object3D.call( this );

this.name = 'mirror_' + this.id;

options = options || {};

this.matrixNeedsUpdate = true;

var width = options.textureWidth !== undefined ? options.textureWidth : 512;
var height = options.textureHeight !== undefined ? options.textureHeight : 512;

this.clipBias = options.clipBias !== undefined ? options.clipBias : 0.0;

var mirrorColor = options.color !== undefined ? new THREE.Color( options.color ) : new THREE.Color( 0x7F7F7F );

this.renderer = renderer;
this.mirrorPlane = new THREE.Plane();
this.normal = new THREE.Vector3( 0, 0, 1 );
this.mirrorWorldPosition = new THREE.Vector3();
this.cameraWorldPosition = new THREE.Vector3();
this.rotationMatrix = new THREE.Matrix4();
this.lookAtPosition = new THREE.Vector3( 0, 0, - 1 );
this.clipPlane = new THREE.Vector4();

// For debug only, show the normal and plane of the mirror
var debugMode = options.debugMode !== undefined ? options.debugMode : false;

if ( debugMode ) {

var arrow = new THREE.ArrowHelper( new THREE.Vector3( 0, 0, 1 ), new THREE.Vector3( 0, 0, 0 ), 10, 0xffff80 );
var planeGeometry = new THREE.Geometry();
planeGeometry.vertices.push( new THREE.Vector3( - 10, - 10, 0 ) );
planeGeometry.vertices.push( new THREE.Vector3( 10, - 10, 0 ) );
planeGeometry.vertices.push( new THREE.Vector3( 10, 10, 0 ) );
planeGeometry.vertices.push( new THREE.Vector3( - 10, 10, 0 ) );
planeGeometry.vertices.push( planeGeometry.vertices[ 0 ] );
var plane = new THREE.Line( planeGeometry, new THREE.LineBasicMaterial( { color: 0xffff80 } ) );

this.add( arrow );
this.add( plane );

}

if ( camera instanceof THREE.PerspectiveCamera ) {

this.camera = camera;

} else {

this.camera = new THREE.PerspectiveCamera();
console.log( this.name + ': camera is not a Perspective Camera!' );

}

this.textureMatrix = new THREE.Matrix4();

this.mirrorCamera = this.camera.clone();
this.mirrorCamera.matrixAutoUpdate = true;

var parameters = { minFilter: THREE.LinearFilter, magFilter: THREE.LinearFilter, format: THREE.RGBFormat, stencilBuffer: false };

this.renderTarget = new THREE.WebGLRenderTarget( width, height, parameters );
this.renderTarget2 = new THREE.WebGLRenderTarget( width, height, parameters );

var mirrorShader = THREE.ShaderLib[ "mirror" ];
var mirrorUniforms = THREE.UniformsUtils.clone( mirrorShader.uniforms );

this.material = new THREE.ShaderMaterial( {

fragmentShader: mirrorShader.fragmentShader,
vertexShader: mirrorShader.vertexShader,
uniforms: mirrorUniforms

} );

this.material.uniforms.mirrorSampler.value = this.renderTarget.texture;
this.material.uniforms.mirrorColor.value = mirrorColor;
this.material.uniforms.textureMatrix.value = this.textureMatrix;

if ( ! THREE.Math.isPowerOfTwo( width ) || ! THREE.Math.isPowerOfTwo( height ) ) {

this.renderTarget.texture.generateMipmaps = false;
this.renderTarget2.texture.generateMipmaps = false;

}

this.updateTextureMatrix();
this.render();

};

THREE.Mirror.prototype = Object.create( THREE.Object3D.prototype );
THREE.Mirror.prototype.constructor = THREE.Mirror;

THREE.Mirror.prototype.updateSplash = function ( splashes ) {

while (splashes.length < 5) {
splashes.push(new THREE.Vector2(-9999,-9999));
}
this.material.uniforms.splashes.value = splashes;

};

THREE.Mirror.prototype.updateTime = function ( time ) {

this.material.uniforms.time.value = time;

};

THREE.Mirror.prototype.renderWithMirror = function ( otherMirror ) {

// update the mirror matrix to mirror the current view
this.updateTextureMatrix();
this.matrixNeedsUpdate = false;

// set the camera of the other mirror so the mirrored view is the reference view
var tempCamera = otherMirror.camera;
otherMirror.camera = this.mirrorCamera;

// render the other mirror in temp texture
otherMirror.renderTemp();
otherMirror.material.uniforms.mirrorSampler.value = otherMirror.renderTarget2.texture;

// render the current mirror
this.render();
this.matrixNeedsUpdate = true;

// restore material and camera of other mirror
otherMirror.material.uniforms.mirrorSampler.value = otherMirror.renderTarget.texture;
otherMirror.camera = tempCamera;

// restore texture matrix of other mirror
otherMirror.updateTextureMatrix();

};

THREE.Mirror.prototype.updateTextureMatrix = function () {

this.updateMatrixWorld();
this.camera.updateMatrixWorld();

this.mirrorWorldPosition.setFromMatrixPosition( this.matrixWorld );
this.cameraWorldPosition.setFromMatrixPosition( this.camera.matrixWorld );

this.rotationMatrix.extractRotation( this.matrixWorld );

this.normal.set( 0, 0, 1 );
this.normal.applyMatrix4( this.rotationMatrix );

var view = this.mirrorWorldPosition.clone().sub( this.cameraWorldPosition );
view.reflect( this.normal ).negate();
view.add( this.mirrorWorldPosition );

this.rotationMatrix.extractRotation( this.camera.matrixWorld );

this.lookAtPosition.set( 0, 0, - 1 );
this.lookAtPosition.applyMatrix4( this.rotationMatrix );
this.lookAtPosition.add( this.cameraWorldPosition );

var target = this.mirrorWorldPosition.clone().sub( this.lookAtPosition );
target.reflect( this.normal ).negate();
target.add( this.mirrorWorldPosition );

this.up.set( 0, - 1, 0 );
this.up.applyMatrix4( this.rotationMatrix );
this.up.reflect( this.normal ).negate();

this.mirrorCamera.position.copy( view );
this.mirrorCamera.up = this.up;
this.mirrorCamera.lookAt( target );

this.mirrorCamera.updateProjectionMatrix();
this.mirrorCamera.updateMatrixWorld();
this.mirrorCamera.matrixWorldInverse.getInverse( this.mirrorCamera.matrixWorld );

// Update the texture matrix
this.textureMatrix.set( 0.5, 0.0, 0.0, 0.5,
0.0, 0.5, 0.0, 0.5,
0.0, 0.0, 0.5, 0.5,
0.0, 0.0, 0.0, 1.0 );
this.textureMatrix.multiply( this.mirrorCamera.projectionMatrix );
this.textureMatrix.multiply( this.mirrorCamera.matrixWorldInverse );

// Now update projection matrix with new clip plane, implementing code from: http://www.terathon.com/code/oblique.html
// Paper explaining this technique: http://www.terathon.com/lengyel/Lengyel-Oblique.pdf
this.mirrorPlane.setFromNormalAndCoplanarPoint( this.normal, this.mirrorWorldPosition );
this.mirrorPlane.applyMatrix4( this.mirrorCamera.matrixWorldInverse );

this.clipPlane.set( this.mirrorPlane.normal.x, this.mirrorPlane.normal.y, this.mirrorPlane.normal.z, this.mirrorPlane.constant );

var q = new THREE.Vector4();
var projectionMatrix = this.mirrorCamera.projectionMatrix;

q.x = ( Math.sign( this.clipPlane.x ) + projectionMatrix.elements[ 8 ] ) / projectionMatrix.elements[ 0 ];
q.y = ( Math.sign( this.clipPlane.y ) + projectionMatrix.elements[ 9 ] ) / projectionMatrix.elements[ 5 ];
q.z = - 1.0;
q.w = ( 1.0 + projectionMatrix.elements[ 10 ] ) / projectionMatrix.elements[ 14 ];

// Calculate the scaled plane vector
var c = new THREE.Vector4();
c = this.clipPlane.multiplyScalar( 2.0 / this.clipPlane.dot( q ) );

// Replacing the third row of the projection matrix
projectionMatrix.elements[ 2 ] = c.x;
projectionMatrix.elements[ 6 ] = c.y;
projectionMatrix.elements[ 10 ] = c.z + 1.0 - this.clipBias;
projectionMatrix.elements[ 14 ] = c.w;

};

THREE.Mirror.prototype.render = function () {

if ( this.matrixNeedsUpdate ) this.updateTextureMatrix();

this.matrixNeedsUpdate = true;

// Render the mirrored view of the current scene into the target texture
var scene = this;

while ( scene.parent !== null ) {

scene = scene.parent;

}

if ( scene !== undefined && scene instanceof THREE.Scene ) {

// We can't render ourself to ourself
var visible = this.material.visible;
this.material.visible = false;

this.renderer.render( scene, this.mirrorCamera, this.renderTarget, true );

this.material.visible = visible;

}

};

THREE.Mirror.prototype.renderTemp = function () {

if ( this.matrixNeedsUpdate ) this.updateTextureMatrix();

this.matrixNeedsUpdate = true;

// Render the mirrored view of the current scene into the target texture
var scene = this;

while ( scene.parent !== null ) {

scene = scene.parent;

}

if ( scene !== undefined && scene instanceof THREE.Scene ) {

this.renderer.render( scene, this.mirrorCamera, this.renderTarget2, true );

}

};
Loading