Jump to content

add texture to grouped meshes


ramymabrouk
 Share

Recommended Posts

hi,

i am exporting a mesh array from blender and applying texture on the meshes, it works fine if i dont group the mesh array into a single mesh, which is required to implement drag and drop, it generates this error "(index):1 [.CommandBufferContext]GL ERROR :GL_INVALID_OPERATION : glDrawElements: attempt to access out of range vertices in attribute 2" when i merge textured meshes or add texture to merged meshes, any ideas ? (the imported .babylon file is attached) 

sofa.babylon

Link to comment
Share on other sites

Hi Ramy, welcome to the forum. I'm no scripter so I will leave them to explain the error and how to get around it in code.

However, there are some workarounds:

1. Merge the meshes in Blender - probably have to rework the UVs though.

2. A solution that I suggested on this thread

A variation on 2 would be to make a simple LOD mesh for the whole sofa, make it transparent,  pickable and the parent to all the other messages.

cheers, gryff :)

Link to comment
Share on other sites

Hi,

unfortantly I do not know how to upload files to the playground, please find my code and the attached files

 

function addsofa(filename) {
        // The first parameter can be used to specify which mesh to import. Here we import all meshes
        BABYLON.SceneLoader.ImportMesh("", "assets/scenes/", filename + ".babylon", scene, function (newMeshes) {
                // Set the target of the camera to the first imported mesh
                // camera.target = newMeshes;
                tagname = randString(10);
                for (i=0;i<newMeshes.length;i++){
                        newMeshes[i].material = new BABYLON.StandardMaterial(tagname + i, scene);
                        newMeshes[i].material.emissiveTexture = new BABYLON.Texture("assets/textures/tex5.jpg",scene,true,false,2)
                        newMeshes[i].material.diffuseColor = new BABYLON.Color3(0,0,0);
                        newMeshes[i].material.specularColor = new BABYLON.Color3(0,0,0);
                        
                        BABYLON.Tags.EnableFor(newMeshes[i]);
                        newMeshes[i].addTags(tagname);                       
                }
                var newMesh = new BABYLON.Mesh.MergeMeshes(newMeshes);
        });        
}

the last files is the one generating the error

tex5.jpg

sofa.babylon

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