I’m a bit of a newbie in javascript and blender, but JUST started on Three.js.
I’m currently trying to import a blender (glb) file to a scene containing simple lightning and background color. Since my blender object already has some shading and I’ve read that the glTF loader can open more complex shading I just exported the glb and loaded in the javascript/Three.js. The simple shapes which contain Principled BSDF appear just fine.
` var loader = new THREE.GLTFLoader();
loader.load('instrumento1novo.glb', handle_load);
var mesh;
function handle_load(gltf) {
console.log(gltf);
mesh = gltf.scene;
console.log(mesh.children[0]);
mesh.children[0].material = new THREE.MeshLambertMaterial();
scene.add( mesh );
gltf.animations; // Array<THREE.AnimationClip>
gltf.cameras; // Array<THREE.Camera>
gltf.asset;
mesh.position.z = -10;
}`
I’ve used glTF Viewer and the same shit happens. Also lots of errors (116 total) not having to do with shading, but that’s for another topic. Is it primarily a code/3D issue or glTF won’t load this materials?
When exporting to glTF, use the Principled BSDF node in Blender and follow the guidelines here: https://docs.blender.org/manual/en/2.80/addons/io_scene_gltf2.html. This particular material type is well-supported in Blender, fits well into glTF, and fits into the PBR material systems in modern engines. For something like a color ramp, you’ll likely need to convert it to a texture or vertex colors, or re-create that particular part in your code after loading the model.
Baking a diffuse map in Blender might also be an easy escape hatch, on this particular example.
LOL
Oh, sorry for the disappointment: Couple of people also mistook this for a ‘fish’ or pet (and it’s ok, it’s supposed to be ambiguous). It’s actually part of a series of imaginary instruments (outer-space or outworldly, alien-like), this one being kind of a saxophone. I would later do each specific sounding for them (a musician will help me in this). Since it’s experimentation, I still don’t have a clear view on how to turn this into a game properly.