Jump to content

Drag image so it fits the ground


granskog
 Share

Recommended Posts

Hi, how can I drag the images so they fits to size of ground, One image is one square.

 

My code for this is:

var ground = BABYLON.Mesh.CreateGround("ground", (number*BLOCK_SIZE), (number*BLOCK_SIZE), 1, scene);ground.position.y = BLOCK_SIZE / 2;if(number % 2 === 0){	ground.position.x += BLOCK_SIZE / 2;	ground.position.z += BLOCK_SIZE / 2;}var groundMaterial = new BABYLON.StandardMaterial("ground", scene);groundMaterial.emissiveTexture = new BABYLON.Texture("textures/ground.png", scene);groundMaterial.emissiveTexture.uScale = number;groundMaterial.emissiveTexture.vScale = number;ground.material = groundMaterial;

Please help me/

Granskog

Link to comment
Share on other sites

Hi granskog, welcome to the forum!

"Drag" is a mousebutton thing, but I think you mean stretch or fit or something.

Really, all you have to do is put 'number' in place of '1' in that first line.  You need to subdivide the ground.  You have it set for 1 subdivision.

I made a playground that shows the fix.  I also overlayed a second ground... a wireframe ground, so you can see the subdivisions better.  Maybe this will help.  Do experiments, edits, hit RUN again... zip a version and take it home, have fun.  I THINK this is what you are looking for.

http://playground.babylonjs.com/#R9NXF

Again, welcome!  Keep us posted on your progress and discoveries.

Later, you might want to check out http://makina-corpus.com/blog/metier/2014/how-to-use-multimaterials-with-a-tiled-ground-in-babylonjs 

Link to comment
Share on other sites

I think Wingnut already gave you the solution, what exactly is the problem or what don't you understand?

Here is a simpler version of Wingnuts example: http://playground.babylonjs.com/#R9NXF#1 Isn't that what you want?

I think one of the links wingnut posted seems broken, so I try add add it here again: http://makina-corpus.com/blog/metier/2014/how-to-use-multimaterials-with-a-tiled-ground-in-babylonjs

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...