Jump to content

The texture is not in a right position


Kayla
 Share

Recommended Posts

Hi guys,

I am pretty new to babylonjs and javascript. I am currently working on the shirt configurator and I am facing a little issue about the UV. I exported this shirt from Marvelous Designer with unified UV and put it back in blender to export as gltf with textures. 

When I replaced the texture with javascript, I find out that the diffuse map is not in a right position while others are at the right place. Is there anything I can change or do to fix the problem? I try the u.Offset or v.Offset, it's isn't working. 

image.thumb.png.e12fb318c759cb1ce2ed4e9b28b57927.png

My Code: (I use  Babylonjs with jQuery and Fabricjs)

canvas code:

 
        var canvasSecond = document.getElementById("canvas2");
        canvasSecond.width = 1024;
        canvasSecond.height = 1024;
 
        //canvas
        var canvasSec = new fabric.Canvas('canvas2');
        fabric.Image.fromURL("textures/shirt_diffuse.png"function(img2) {
            var img3 = img2.set({ selectable: false });
            canvasSec.add(img2).renderAll();
 
        });
.
    //after so many command and lines...
        var texture = new BABYLON.DynamicTexture("texture"canvasSecondscenetruefalse);
        var nrmtexture = new BABYLON.Texture("textures/shirt_normal.png"scenetruefalse);
        var spectexture = new BABYLON.Texture("textures/shirt_spec.png"scenetruefalse);
 
        BABYLON.SceneLoader.ImportMesh("shirt""gltf/""shirt.gltf"scenefunction(MeshOne) {
            scene.createDefaultCameraOrLight(truetruetrue);
            var mesh = MeshOne[1];
 
            var material = new BABYLON.PBRMaterial("material"scene);
 
            material.albedoTexture = texture;
 
            material.reflectionTexture = new BABYLON.HDRCubeTexture("textures/abandoned_factory_canteen_02_2k.hdr"scene218falsefalsefalsefalse);
            material.bumpTexture = nrmtexture;
            material.specularTexture = spectexture;
 
            material.metallic = 0;
            material.roughness = 1;
            // standardUV = options.standardUV;
            mesh.material = material;
 
        });
        scene.onBeforeRenderObservable.add(() => {
            texture.update();
        });
 

 

 

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