javascript - Can Mesh.setGeometry pass through an image using Famo.us Engine -
so new famo.us
stupid question (i hope not).
var mesh = require('famous/webgl-renderables/mesh'); ..... var mesh = new mesh(meshnode).setgeometry('circle');
i can pass through multiple types of shapes through setgeometry
there way pass through image. example, logo?
thanks!
you cannot pass image geometry of mesh, can pass image apply material
mesh
. use mesh.setbasecolor
, pass in material.image
.
var scene = famousengine.createscene('body'); famousengine.init(); // add child node add our mesh to. var node = scene.addchild(); // pass child node new mesh component. var mesh = new mesh(node); // give mesh geometry. mesh.setgeometry('circle', { detail: 100 }); mesh.setbasecolor(material.image([], { texture: 'https://i.imgur.com/xn7lvcw.jpg' }));
run example snippet below (spinning sphere)
var famousengine = famous.core.famousengine; var mesh = famous.webglrenderables.mesh; var material = famous.webglmaterials.material; var transitionable = famous.transitions.transitionable; var scene = famousengine.createscene('body'); famousengine.init(); var rootnode = scene.addchild(); rootnode.setalign(0.5,0.5, 0); rootnode.setorigin(0.5, 0.5, 0); rootnode.setmountpoint(0.5, 0.5, 0.5); // add child node add our mesh to. var node = rootnode.addchild(); node.setalign(0.5,0.5, 0); node.setorigin(0.5, 0.5, 0); node.setmountpoint(0.5, 0.5, 0.5); node.setsizemode('absolute','absolute','absolute'); node.setabsolutesize(200,200,200); // start transitionable rotation value var transitiony = new transitionable(); var milisecs = 10000; var startangle = math.pi * 2 / milisecs; function rotatey() { transitiony.from(startangle).set(math.pi * 2, { duration: milisecs }, rotatey); } // pass child node new mesh component. var mesh = new mesh(node); // give mesh geometry. mesh.setgeometry('sphere', { detail: 100 }); mesh.setbasecolor(material.image([], { texture: 'https://i.imgur.com/xn7lvcw.png' })); // add spinner component 'node' called, every frame var spinner = rootnode.addcomponent({ onupdate: function(time) { if (!transitiony.isactive()) rotatey(); rootnode.setrotation(0, transitiony.get(), 0); rootnode.requestupdateonnexttick(spinner); } }); // let magic begin... rootnode.requestupdate(spinner);
html, body { width: 100%; height: 100%; margin: 0px; padding: 0px; } body { position: absolute; -webkit-transform-style: preserve-3d; transform-style: preserve-3d; -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; -webkit-perspective: 0; background-color: black; perspective: none; overflow: hidden; }
<meta http-equiv="x-ua-compatible" content="ie=edge"> <link rel="icon" href="favicon.ico?v=1" type="image/x-icon"> <meta name="description" content="draggable famous@0.5.2"> <meta name="viewport" content="width=device-width, initial-scale=1"> <script src="http://code.famo.us/famous/0.5.2/famous.min.js"></script>
Comments
Post a Comment