Jump to content

Texture on merged mesh


Recommended Posts

Hi there.


Is there a way to use a texture on the whole merged mesh?


My problem is, if i merge some mesh into one, i can not use a texture on it, the framework apply the texture on every base shape.



Here is a sample of code:


var meshes = [];
for (var i = 0; i < 3; i++) {
    var mesh = BABYLON.Mesh.CreateTorus('mesh', (i * 2) + 1, 1, 10, scene, false);
    mesh.position.y = i;
var mesh = BABYLON.Mesh.MergeMeshes(meshes, true, true);
mesh.material = new BABYLON.StandardMaterial('beeHiveMaterial', scene);
mesh.diffuseTexture = new BABYLON.Texture('someimage.jpg', scene);
Link to comment
Share on other sites



To achieve the effect you're looking for I think you need to either:

- manipulate UV values (i.e. texture coordinates) of each vertex in your merged meshes, or

- build your mesh in a 3D software, such as Blender, and choose which type of texture projection you want on your object.


I made an example of my first suggestion in this PG: http://www.babylonjs-playground.com/#KGUJW#1

For each torus, I scaled the texture coordinates to just show a "slice" of the whole texture. The result is not incredibly looking... But you get the idea.

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.

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.


  • Recently Browsing   0 members

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