GameMonetize Posted May 23, 2015 Share Posted May 23, 2015 I agree with Alby, they should all be submitted here:https://github.com/BabylonJS/UserFunctions Quote Link to comment Share on other sites More sharing options...
jerome Posted May 24, 2015 Share Posted May 24, 2015 will be done Quote Link to comment Share on other sites More sharing options...
jerome Posted May 26, 2015 Share Posted May 26, 2015 How do we fork an empty github repo ? Quote Link to comment Share on other sites More sharing options...
jerome Posted May 27, 2015 Share Posted May 27, 2015 upI don't know how to push the user custom function into this empty github repo (can't fork an empty repo ) Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted May 27, 2015 Share Posted May 27, 2015 I've just uploaded a sample function Quote Link to comment Share on other sites More sharing options...
Wingnut Posted May 29, 2015 Share Posted May 29, 2015 Hey Alby... just between you and I... ahem... don't let DK's incessant insistence upon using github... harsh your mellow (bother you). Just collect all your favorite functions in a big fat text file, try to categorize them somehow, talk talk talk about each one, and publish it somewhere near and dear. (where you can easily add-to/edit it). You could store it in some secret folder at BabylonDocs. Wanna? The viewer wants .md (github markdown)... but it handles plain old ascii text JUST FINE. Want to make many text documents, start categorizing the funcs? Can do! (Wingy hands you a "Just say NO to github" t-shirt) Keep the url the same... forever... and we'll all go web-sniffin' the "library" whenever we need a useful function. It is SO easy to do control-f to find something in a big fat .txt file, eh? GitHub... pfft. DK has been drinkin' all day, you can tell. (j/k) Quote Link to comment Share on other sites More sharing options...
jerome Posted May 29, 2015 Share Posted May 29, 2015 Wingy on guitar Yeeeeaaaahhhh !!! Quote Link to comment Share on other sites More sharing options...
Wingnut Posted May 29, 2015 Share Posted May 29, 2015 Geezer jam! Quote Link to comment Share on other sites More sharing options...
Alby Posted May 29, 2015 Author Share Posted May 29, 2015 Playing "cannet heat" : -->"on the road again"... Quote Link to comment Share on other sites More sharing options...
Testouille Posted June 1, 2015 Share Posted June 1, 2015 This will be my first contribution to a community ever, so, tell me how can I can explain better :http://www.babylonjs-playground.com/#1HOSTQThis defines a new Mesh, the "Advanced Ground". All of its cells are squares.It takes the following argument :- name : the name of mesh- width : the width of the ground (in cells)- height : the height of the ground (in cells)- size : the size of a cell- scene : the scene- fsize : a function I will expain laterThe particularity of the advanced ground is that all of its cells are cube. Which means you can change each one of them without modifying the others.In order to midify the size of the cube of a cell, you have two ways :The first one is the fsize function. When you make the ground, you give a "fsize" function. This fsize function tells the ground what are the size of its faces.For instance, in the playground, we have the following fsize function :function (i, j, width, height, size) { if (i == 0 || i == width - 1) { return (size); } if (j == 0 || j == height - 1) { return (size); } return (0);}So, what it says is that, if a face is a border one, then its height will be the size of a cell. (That's what we see on the playground.) The second one is using the method "UpdateFaces", it takes an array of array which are made this way :[x, y, s], where x is the x of the face you want to change, y its y, and s the size you want.For instance, in the playground, we use it this way : ground.UpdateFaces([[3, 3, 2], [6, 6, 4]]);So, what it says is "We want the face at 3,3 to have a height of 2 times the size of a cell, and we want the face at 6, 6 to have a height of 4 times the size of a cell". You can see the result and try to modify it in the playground When we deal with user input, instead of knowing when the user click, or when the user push a keyboard button, we often want to know if a keyboard button is being pushed, or if a mouse button is being clicked, so the following code can be usefull :{ var keyPressed = []; for (var i = 0; i < 255; i++) { keyPressed[i] = false; } window.addEventListener("keydown", function (event) { keyPressed[event.keyCode] = true; }); window.addEventListener("keyup", function (event) { keyPressed[event.keyCode] = false; });} // Deal with keyboard and creates keyPressed (Use keyPressed[i] to check if key of keyCode i is pressed){ var mousePressed = []; for (var i = 0; i < 3; i++) { mousePressed[i] = false; } document.addEventListener("mousedown", function (event) { mousePressed[event.button] = true; }); document.addEventListener("mouseup", function (event) { mousePressed[event.button] = false; });} // Deal with mouse and creates mousePressed (Same as keyPressed[i])With this, having a timed renderloop can come handy : every 10ms, we want to check userinput, and do stuff.{ var time = +(new Date).getTime(); engine.runRenderLoop(function () { if (Date.now() - time > 10) { // Run every 10 ms time = Date.now(); dealWithCamera(); } scene.render() });} // RenderLoop timed Wingnut 1 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.