liangyong
(liangyong)
January 31, 2024, 8:00am
1
Using the same PLY and PNG for texture mapping in C++is normal, but it is not normal when using vtk.js. How should I solve this problem。
It looks like this:
The texture appears to be split
daker
October 14, 2024, 3:13pm
2
You can contribute a fix to this, the PLYReader needs DuplicatePointsForFaceTexture feature from the c++
if (this->DuplicatePointsForFaceTexture)
{
for (int k = 0; k < face.nverts; k++)
{
// new texture stored at the current face
float newTex[] = { face.texcoord[k * 2], face.texcoord[k * 2 + 1] };
// texture stored at vtkVerts[k] point
float currentTex[2];
texCoordsPoints->GetTypedTuple(vtkVerts[k], currentTex);
double newTex3[] = { newTex[0], newTex[1], 0 };
if (currentTex[0] == -1.0)
{
// newly seen texture coordinates for vertex
texCoordsPoints->SetTuple2(vtkVerts[k], newTex[0], newTex[1]);
vtkIdType ti;
texLocator->InsertUniquePoint(newTex3, ti);
pointIds.resize(std::max(ti + 1, static_cast<vtkIdType>(pointIds.size())));
pointIds[ti].push_back(vtkVerts[k]);
}
else
This file has been truncated. show original
opened 02:49AM - 25 Jul 23 UTC
type: bug 🐞
module: I/O
### Bug description
Load the ply file with vtkPLYReader and add textures with v… tkTexture, but the added textures have gaps.
It is normal to load the same file using meshLab software.
### Steps to reproduce
![ply01](https://github.com/Kitware/vtk-js/assets/23071651/ed0291d2-61d4-422a-99e3-2c4a0cb0832a)
const reader = vtkPLYReader.newInstance();
const mapper = vtkMapper.newInstance({ scalarVisibility: false });
const actor = vtkActor.newInstance();
actor.setMapper(mapper);
mapper.setInputConnection(reader.getOutputPort());
reader
.setUrl(lowerFolder)
.then(async (res) => {
const fullScreenRenderer = vtkFullScreenRenderWindow.newInstance();
let renderer = fullScreenRenderer.getRenderer();
let renderWindow = fullScreenRenderer.getRenderWindow();
const text = await reader.getDataAccessHelper().fetchText(null,lowerFolder);
const headText = text.split("end_header")[0];
const TextureFile0 = headText.split("TextureFile")[1];
const textureUrl = TextureFile0.split("\n")[0].trim();
const image = new Image();
image.src = folder + textureUrl;
const texture = vtkTexture.newInstance();
texture.setInterpolate(true);
texture.setImage(image);
actor.addTexture(texture);
renderer.addActor(actor);
setTimeout(() => {
renderWindow.render();
fullScreenRenderer.getInteractor().render();
}, 200);
if (renderer && renderWindow) {
const resetCamera = renderer.resetCamera;
const render = renderWindow.render;
resetCamera();
render();
}
})
### Detailed Behavior
_No response_
### Expected Behavior
The PLYReader and class vtkTexture correctly loads.
If the PLYReader class can automatically read the jpg address in the ply file, it would be perfect
### Environment
- vtk.js version: 28.3.3 & 25.15.2
- Browsers: chrome 114.0.5735.248
- OS: Windows 11