Hi, i’m trying to import glb/gltf models
But, the model looks totally black.
In sandbox or the other 3d viewers, it looks totally normal.
(I think model/exporter has no problem)
Weirdly, when using scene.createDefaultEnvironment(), the models looks normal.
Is it a bug?
If not, what should i append to my own scene?
(irrelavent parts are omitted)
window.addEventListener('DOMContentLoaded', function(){
let isKeyPressed = {}; //object for multiple key presses
let inclinationSpeed = 0.002;
let canvas = document.getElementById('renderCanvas');
let engine = new BABYLON.Engine(canvas, true);
let camera;
BABYLON.Database.IDBStorageEnabled = true;
let createScene = function () {Preformatted text
let scene = new BABYLON.Scene(engine);
// scene.createDefaultEnvironment({
// createSkybox: false,
// enableGroundMirror: false,
// });
let skyboxMaterial = new BABYLON.SkyMaterial("skyMaterial", scene);
skyboxMaterial.inclination = 0;
skyboxMaterial.backFaceCulling = false;
skyboxMaterial.disableLighting = true;
let skybox = BABYLON.Mesh.CreateBox("skyBox", 1000.0, scene);
skybox.material = skyboxMaterial;
skybox.renderingGroupId = 0;
let meshes = [];
let assetsManager = new BABYLON.AssetsManager(scene);
let meshTask = assetsManager.addMeshTask("takeName", "", "models/", "untitled.glb");
meshTask.onSuccess = function (task) {
var originalMesh = task.loadedMeshes[0];
for (var i= 0; i< 10; ++i) {
for (var j= 0; j< 10; ++j) {
console.log(originalMesh);
var newClone = originalMesh.clone("index: " + i);
newClone.position.y =+ i*3;
newClone.position.x =+ j*3;
meshes.push(newClone);
}
}
console.log(task);
}
meshTask.onError = function (task, message, exception) {
console.log(message, exception);
}
assetsManager.load();
let light = new BABYLON.PointLight("light01", new BABYLON.Vector3(0, 100, 100), scene);
light.shadowEnabled = true;
camera = new BABYLON.ArcRotateCamera("Camera", 0, 0.8, 100, new BABYLON.Vector3.Zero(), scene);
camera.attachControl(canvas, true);
let ground = BABYLON.Mesh.CreateGround("ground", 500, 500, 5, scene);
ground.position.y = -0.5;
ground.receiveShadows = true;
attachImposter(ground,scene,0);
return scene;
}
let scene = createScene();