Skip to content

Instantly share code, notes, and snippets.

@oldschooljarvis
Created June 11, 2015 23:04
Show Gist options
  • Save oldschooljarvis/031463a0f8cb8fbf3d84 to your computer and use it in GitHub Desktop.
Save oldschooljarvis/031463a0f8cb8fbf3d84 to your computer and use it in GitHub Desktop.
GL Image Texture Checkerboard Behavior #2
'use strict';
var f = require('famous');
f.core.FamousEngine.init();
var scene = f.core.FamousEngine.createScene();
//Function that spawns a node with an image mapped to a GL texture, then bounces it.
function spawnImageGL(src) {
var glImage = scene.addChild();
glImage.setSizeMode('absolute','absolute','absolute').setAbsoluteSize(200, 200).setAlign(0.5, 0.5).setMountPoint(0.5, 0.5).setOrigin(0.5, 0.5);
glImage.setOpacity(0.99); //alpha channel fix; doesn't affect issue behavior.
new f.webglRenderables.Mesh(glImage)
.setGeometry('Plane')
.setBaseColor(f.webglMaterials.Material.image(
[],
{
texture: f.webglMaterials.TextureRegistry.register('logo', src)
}
)
);
new f.components.Position(glImage).set(600, 0, 0, {duration: 5000, curve: 'spring'});
}
f.core.FamousEngine.getClock().setTimeout(function() {
spawnImageGL('images/famous_logo.png')
}, 1000);
f.core.FamousEngine.getClock().setTimeout(function() {
spawnImageGL('images/famous_logo.png')
}, 2000);
f.core.FamousEngine.getClock().setTimeout(function() {
spawnImageGL('images/famous_logo_magenta.png')
}, 5000);
f.core.FamousEngine.getClock().setTimeout(function() {
spawnImageGL('images/famous_logo_magenta.png')
}, 6000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment