arcanine Posted November 27, 2014 Share Posted November 27, 2014 Hello, I've got a basic incomplete game in threejs but would like to port it to babylon for some of the more game specific functionalityone of the first features is that every item in the game has randomised textures, I'd dynamically draw a canvas then apply it to the mesh Is this possible in Babylon? If so what classes/methods/documentation do I need to be looking at to achieve this? Quote Link to comment Share on other sites More sharing options...
RaananW Posted November 27, 2014 Share Posted November 27, 2014 Hi, Welcome to the forum! The dynamic texture is exactly what you need - http://doc.babylonjs.com/page.php?p=24709http://blogs.msdn.com/b/eternalcoding/archive/2013/08/12/creating-a-3d-chart-for-your-windows-8-1-app-using-babylon-js.aspx The function getContext gives you the canvas to draw on. Just don't forget to update (that's also the name of the function) after making changes to the canvas :-) That was my mistake.You can also give a canvas element as the "options" variable, it will be set automatically as the texture's canvas.. Quote Link to comment Share on other sites More sharing options...
arcanine Posted November 27, 2014 Author Share Posted November 27, 2014 What is the options parameter exactly? the documentation says it's an object, the tutorial shows it as an integer, my testing shows is accepts a blank canvas element thank you for the kind reception Quote Link to comment Share on other sites More sharing options...
RaananW Posted November 27, 2014 Share Posted November 27, 2014 Yeah, the documentation can be sometimes misleading. But the community is working on it :-)That's the benefit of open source projects - you can actually see what the variables do. Take a look here - https://github.com/BabylonJS/Babylon.js/blob/master/Babylon/Materials/textures/babylon.dynamicTexture.ts"options" can be either the canvas size (width and height), a canvas object (an object with a getContext function) or a json object with width and height as parameter:var options = 512; //ORvar options = { width : 512, height: 1024 }; //ORvar options = document.getElementById("canvasId");So, anything goes, it is all up to you how you use it. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.