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
<script type="text/x-handlebars" id="components/chat-input"> | |
{{input id="tiChatInput" action="chatInputEnter"}} | |
</script> | |
MyApp.ChatInputComponent = Ember.Component.extend({ | |
didInsertElement: function () { | |
var self = this, | |
ctx = this.$('input').keydown(function (event) { | |
if (event.which === 9) { | |
// [TAB] |
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
request.onload = function () { | |
context.decodeAudioData(request.response, function (buf) { | |
// store as forward buffer | |
buffer = buf; | |
// create a reversed copy | |
bufferReversed = context.createBuffer(buf.numberOfChannels, buf.length, buf.sampleRate); | |
for (var i = 0; i < buf.numberOfChannels; i++) | |
bufferReversed.getChannelData(i).set( | |
Array.prototype.reverse.call(new Float32Array(buf.getChannelData(i))) | |
); |
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
/* | |
assuming a rather standard requirejs script tag referring to main(.js) | |
<script type="text/javascript" data-main="main" src="js/require.min.js"></script> | |
*/ | |
var w = newRequireWorker({ | |
shim: { three: { exports: 'THREE' } }, | |
baseUrl: 'js', | |
paths: { three: 'three.min' } | |
}, |
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
/** | |
* split a (loaded) model into mesh parts by material index | |
* @param {THREE.Geometry} geometry | |
* @param {Array<THREE.Material>} materials | |
* @returns {Array<THREE.Mesh>} | |
*/ | |
var splitByMaterial = function(geometry,materials) { | |
var parts = [], | |
geo, vMap, iMat, | |
addPart = function() { |
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
/** | |
* hexagon geometry - evenly subdivided | |
* @param radius | |
* @param {int=} segments - subdivisions | |
* @param {Number=} theta - default "pointy top" (Math.PI/2 for "flat top") | |
* @constructor | |
* @author lmg / https://github.com/kishalmi | |
*/ | |
THREE.HexGeometry = function (radius, segments, theta) { |
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
uniforms.time = { type: 'f', get value() { return performance.now()/1000 } }; |
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
/** | |
* create a geometry suitable for a THREE.Line of type THREE.LineStrip from a sphere | |
* thereby not displaying triangle-edges of a sphere wireframe. | |
* @param {THREE.SphereGeometry} geoSphere | |
* @returns {THREE.Geometry} | |
*/ | |
function lineStripGeometryFromSphereGeometry(geoSphere) { | |
var geoLine = new THREE.Geometry(), | |
w = geoSphere.widthSegments, h = geoSphere.heightSegments, | |
x, y; |
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
var img = document.createElement('img'); | |
img.src = renderer.domElement.toDataURL('image/png'); | |
img.onload = function() { | |
var canvas = document.createElement('canvas'); | |
canvas.width = renderer.domElement.width; | |
canvas.height = renderer.domElement.height; | |
var ctx = canvas.getContext('2d'); | |
ctx.drawImage(img, 0, 0, img.naturalWidth, img.naturalHeight, 0, 0, canvas.width, canvas.height); | |
var imageData = ctx.getImageData(0, 0, canvas.width, canvas.height); | |
} |
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
function render() { | |
var t = new Date().getTime() / 1000; // unixtime | |
var dt = clock.getDelta(); | |
dispatchSceneGraphEvent(scene, {type: 'preRender', t: t, dt: dt}); | |
renderer.clear(true, true, true); | |
renderer.render(scene, camera); | |
} |
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
/** | |
* cheap require (using jquery) | |
* loads a script (or scripts, if given an array) and executes it | |
* callbacks for progress and success | |
* won't load a script twice if already loaded (or failed) | |
* @param files | |
* @param callbackProgress | |
* @param callbackSuccess | |
*/ | |
function require(files, callbackProgress, callbackSuccess) { |
NewerOlder