Jump to content

Revolution Animation


Bash
 Share

Recommended Posts

I'm a newbie to the 3d dev world... WOW, the learning curve is HUGE! At any rate, I thought I would give Babylon.js a shot... I watched the learning series on Microsoft Virtual Academy with the two David's... In the materials example they show an example of creating 10 spheres in a circle surrounding a single sphere... That was the start of a simple idea I wanted to implement on a home page...

I would like to create a wheel of objects that a user could spin... and a random object would stop center screen showing the result of the spin... I want a vertical spinning series of objects... Not like a money wheel or vertical roulette wheel, but more like a slot machine wheel, or think "the price is right wheel", where players spin the wheel to get closest to $1...

My layout is very basic, and I simply need some assistance with how to go about animating something with physics... i.e. make the wheel look random and look realistic. Most of the examples I find show creation of scenes and objects, and perhaps some basic animation, but to create a game seems like it would be a huge undertaking. Assets (meshes) not withstanding, game logic seems like... well... formidable! 

I would also like some assistance with game code organization... Is there documentation on a logical order to store scripts and assets? 

* things I've determined from trial an error... The number of points should be evenly divisible by 360 in order for an object to be centered center screen... In this example the number of objects is 24, and the radius is 3... This centers an object center screen... If I use 16, and a radius of two this will also work for my needs...

Now I would like to animate the spinning of this "wheel of objects", and have some sort of physics working to make the experience realistic...

var createScene = function () {

    var scene = new BABYLON.Scene(engine);
    scene.clearColor = new BABYLON.Color3(0, 0, 0);
    var camera = new BABYLON.FreeCamera("camera1", new BABYLON.Vector3(0, 0, -6), scene);
    camera.setTarget(BABYLON.Vector3.Zero());
    camera.attachControl(canvas, false);
    var light = new BABYLON.HemisphericLight("light1", new BABYLON.Vector3(0, 0, 0), scene);
 
    var points = 24;
    var radius = 3;
 
    var slice = (2 * Math.PI) / points;
    for (var i = 0; i < points; i++) {
        angle = slice * i;
        var obj = BABYLON.Mesh.CreateBox("box" + i, .65, scene);
        obj.position.y = (0 + radius * Math.cos(angle));
        obj.position.x = -1;
        obj.position.z = (0 + radius * Math.sin(angle));
    }

return scene

}

 

   

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...