Hi, Can someone help me with this?
My imported gltf/glb model doesn’t look exactly the same like I have in the blender. I’m not able to understand why it is happening. Did I not export it correctly from blender? Did I need any specific configuration to add on three js?
Here is the Babylon playground link -
https://playground.babylonjs.com/#Y2A92N
This is the code sample that I tried locally -
import { Engine, Scene, SceneLoader, ArcRotateCamera, Tools, Vector3, HemisphericLight,
ShaderMaterial, Texture, Color3 } from "@babylonjs/core";
import '@babylonjs/inspector'
import "@babylonjs/core/Debug/debugLayer";
import '../../style.css';
let scene
const loadGLTF = () => {
// new GLTFLoader().loadAsync()
SceneLoader.Append('../../../src/assets/verge3d/', 'test continents6.glb', scene, (scene) => {
// scene.createDefaultCameraOrLight(true, true, true);
// scene.createDefaultXRExperienceAsync()
// // scene.createDefaultEnvironment();
// scene.createDefaultLight();
// // scene.activeCamera.alpha += Math.PI;
// // scene.lightsEnabled = false
// scene.createDefaultEnvironment({
// createGround: false,
// createSkybox: false,
// groundYBias: 0.01,
// enableGroundMirror: true,
// });
console.log('scene loaded', scene)
}, () => {
console.log('loading...')
}, (error) => {
console.log(error)
},
'.glb')
// SceneLoader.ImportMesh("", "../../../src/assets/verge3d/", 'final continents4.glb', scene, (meshes) => {
// console.log(meshes)
// }, () => {
// console.log('loading...')
// }, (scene, message) => {
// console.log(message)
// }, '.glb')
}
const init = () => {
try {
const canvas = document.getElementById("babylonjs-container");
canvas.style.width = "100%";
canvas.style.height = "100%";
const engine = new Engine(canvas, true);
scene = new Scene(engine);
scene.useRightHandedSystem = true;
const camera = new ArcRotateCamera("camera", Tools.ToRadians(90), Tools.ToRadians(65), 10, Vector3.Zero(), scene);
// This targets the camera to scene origin
camera.setTarget(Vector3.Zero());
// This attaches the camera to the canvas
camera.attachControl(canvas, true);
// scene.ambientColor = new Color3(1, 1, 1);
// const light = new HemisphericLight("light1", new Vector3(0, 1, 0), scene);
// light.intensity = 0.7;
// const shaderMaterial = new ShaderMaterial(
// "shader",
// scene,
// {
// vertex: "custom",
// fragment: "custom",
// },
// {
// attributes: ["position", "normal", "uv"],
// uniforms: ["world", "worldView", "worldViewProjection", "view", "projection"],
// },
// );
// const mainTexture = new Texture("../../assets/verge3d/v3d_exported_image_image_0.jpeg", scene);
// shaderMaterial.setTexture("textureSampler", mainTexture);
loadGLTF()
engine.runRenderLoop(() => {
scene.render();
});
} catch (error) {
console.log('init error', error);
}
}
init()
That’s how it looks in babylon js -
And that’s how it looks in a blender -
island layer -
water layer -
Am I missing any shading configuration in Babylon js? Or, the exported model missing any shading configurations. I’ve searched a lot but didn’t find any solutions. I’ve just started with Babylon js, didn’t know much. Please help me!!!