The gray box is from Cube.obj file. And the small purple one in it is made with CreatBox constructor.
As we can see, the gray box has penetrated surfaces, and inside surfaces are only visible but external transparent.
I used ImportMesh to import the obj file. To solve this distorted mesh, I tried
sideOrientation,
needDepthPrePass,
alph,
setVerticesData(flip normal),
backFaceCulling and so on.
But nothing worked out…
Also when I tried to change material color of normal cube from glb (converted from max fbx file), it also has same effect.
What should I do? Please help me…
here is my code
BABYLON.SceneLoader.ImportMesh("", "res/", "Cube.obj", scene, function(meshes, particleSystems, skeletons) {
console.log()
for (var i in meshes) {
console.log(meshes[i].id);
}
// var m = scene.getMeshByName('__root__');
var m2 = scene.getMeshByName('Cube');
// m2.scaling.z = 20;
// m.position.y = 3;
// m.setPositionWithLocalVector(new BABYLON.Vector3(0, 0, 0));
//m.absolutePosition.y = -10;
// console.log(BABYLON.Mesh.DOUBLESIDE);
console.log(m2.material);
// m2.material = myMaterial;
// m2.sideOrientation = BABYLON.Mesh.DOUBLESIDE;
// m2.material.needDepthPrePass = true;
// m2.material.alph = 1;
// var normals = m2.getVerticesData(BABYLON.VertexBuffer.NormalKind);
// for (var i in normals) {
// normals[i] *= -;
// }
// m2.setVerticesData(BABYLON.VertexBuffer.NormalKind, normals);
// m2.material.wireframe = true;
// m2.backFaceCulling = false;
Also I loaded 3d text in babylonjs using threejs. but when I try to change its color material, its surfaces are broken… what should I do…
Is is wrong to try to put color material? Actually, even I couldn’t find any PG showing the exactly same cases.
I am sure it is very simple to reproduce this bug at your working environment.
If you want, I can share this test project as .zip file. Should I send an email with file?
BTW, I couldn’t find babylon 3d text plugin anywhere, so in the end I had no choice but to try threejs 3d text. If possible, I want to try babylon’s modules to create 3d text.
Well the only thing that is close to one of your export type is the first c# unity export.
But instead of using that Unity wiki code to export obj files… we have the Babylon Editor Toolkit to export directly to .babylon scene files. We have an upcoming version that will export unity content to gltf/glb
Ok… then… currently, it is unstable to try to change materials of meshes loaded from external resources like glb, obj and so on except .babylon extension file.
Also recently I found the newest unityexporter works fine with typescript. Unity also has 3d text asset… I will give it a try with babylon file. Thank you.
I dont think i can support Unity 3D Text as far as a component. You would have to use something that produced actual Unity Meshes. Whether you IMPORTED some 3D text from any other authoring package as FBX or something. But once it gets into Unity as a Mesh… 3D Text or not… I can export it.
I started playing around with TextMeshPro that is now a part of Unity 2019.
It does export the 3D text mesh… but you need to TWEAK the material properties in babylon to get it to like as CLOSE AS POSSIBLE to unity.
Btw… once you have a mesh in Babylon … however it got there, creating native geometry, gltf, obj… whatever… you should be able to change or update any material properties at runtime
Yes that’s the point i am trying to explain. I just used standard material to change colors. But I don’t know why it removes visible surfaces as well. Anyway I will try babylon ext again later and then feed back here. Thank you.
Not sure, I would have to see it… Can you setup a playground… ???
But i can tell you (as the Babylon Toolkit Guy)… A mesh is a mesh is a mesh…
Its the exporter… In your C# Unity ExportOBJ… You might have to go in and make sure your getting (serializing) all the mesh properties… I found that missing or messed up normal and or tangents will effect that material appearance.
Make sure your mesh has at least:
positions
normals
tangents
uvs
triangles (Indices)
vertex colors (if it has any)
These are the main things i pickup when exporting geometry (.babylon or .gltf scene files)
Anyways… try setup a playground so we can check it out… What might be missing from the geometry that is cause the funny material issues you are having
Wow thank you. But I am also talking about common glb files from 3dsmax. It also has same bug with cube after changing color with babylon standardmaterial. It is also same with threejs glb objects.
So all of them have same reason like the csharp exporter
Thats strange… Try make playground… We (the community) we check it out and try help if we can…
But that seems strange though… I export .babylon and .gltf/.glb scene files all the time… And i have EXTENSIVE custom material and shader support… So my GLTF extension modifies material properties (after the instance of the material has been created) all the time… Including color properties… As a matter a fact… i think i am doing a Linear Color Correction on one of my materials and it works perfect. ot too mention stuff like lightmaps… all after the fact using regular babylon material pipeline code.
You issue is not the geometry itself but the Material Side Orientation and the HAND-SYSTEMS.
Note… You are import meshes with different hand systems… babylon, gltf and obj.
BABYLON is left handed. I know GLTF is right handed… and apparently OBJ is as well.
Babylon by default is Left-Handed System… I think the default is COUNTER-CLOCKWISE on the materials.
Now what side orientation is setup for the material is normally handled by the system or loader. It also depends on if the the SYSTEM is in Left or Right handed mode: scene.useRightHandedSystem = false is default.
Check docs on left and right handed support and material side orientation. Hope that helps
I added support for the 3D Text component in Unity … it will serialize the metadata about the 3D text and use the MeshWriter extension to render the text as 3D