Colada texture export for Three.js - javascript

I have a files in .FBX and I need to convert them in collada so I can use them in Three.js.
I managed to convert them with FBX Converter but then I lost textures.
How can I convert them so I can use textures.
Here is the FBX converted with FBX Converter:
pearl.dae
And here is the link of model which I exported as FBX_DAE in Maya 2013
model2.dae
I have just import the FBX and export as FBX_DAE
Model exported in Maya has texture if I do the quick preview on Mac but when I load it in Three.js it has no textures.
And the pearl.dae converted with FXB converter has no texture neather in quick previw nor in Three.js
Here is my loader code:
var Loader = new THREE.ColladaLoader();
Loader.options.convertUpAxis = true;
Loader.load('./models/pearl.dae', function(collada){
Bracelet = collada.scene;
Skin = collada.skins[0];
Bracelet.scale.x = Bracelet.scale.y = Bracelet.scale.z = 1;
Bracelet.updateMatrix();
init();
render();
});
Please help.

I have looked over your model files, pearl.dae contains no references to any textures. You might want to double-check your FBX converter settings and any errors or warning you may get. model2.dae on the other hand does reference a texture with the relative path of "../../Model/Nialaya_perla.fbm/Perla_diffuse.jpg" (the texture is not contained within the model file itself). I don't recall if Three.JS will automatically load textures from Collada model files, but unless that path is correct it will definitely fail. In my experience with Three.JS, it's usually better to load textures, create shaders, and apply them to plain models with just code. This will also give you the greatest control over the final look.

Related

Download threejs model to .stl

I came to find this library that downloads stl from threejs.
https://github.com/mrdoob/three.js/blob/master/examples/js/exporters/STLExporter.js
I am new to js / threejs, so I was wondering how could I incorporate this within my script, or how to link it as a library or other file.
Please note that the model I want to download is either one built from scratch in threejs or one that I imported as glb/gltb and changed some of its features in threejs.
Thank you.
There is an official example that demonstrates the usage of STLExporter. I suggest you study the respective source code and use it as a foundation for your own app. You can find the mentioned example right here:
https://threejs.org/examples/misc_exporter_stl
Please note that the model I want to download is either one built from scratch in threejs or one that I imported as glb/gltb and changed some of its features in threejs.
Please keep in mind that STL has no concept of materials. It only saves the raw geometry data. STL is also unable to export hierarchical information of a scene (e.g. child-parent relationships). So depending on what you are going to change in your scene, it's likely that the respective data can't be exported as expected.
There is two implementation for export,ASCII & Binary,
function exportASCII() {
const result = exporter.parse( mesh );
saveString( result, 'box.stl' );
}
function exportBinary() {
const result = exporter.parse( mesh, { binary: true } );
saveArrayBuffer( result, 'box.stl' );
}

How to convert OBJ/FBX to GLTF before loading to scene (using Threejs)

I am trying to create to create a webapp in which users can upload obj/fbx files and view them in the browser. I have used the OBJLoader and FBXLoader which Threejs provides and it is all working fine. I however want to convert both these models to GTLF before loading them into the scene (for the sake of consistency).
How can I achieve this in threejs? I know that threejs has a GTLF exporter but I am unaware of how to leverage it for my purposes.
There are two ways you could do this:
Method 1:
Convert using from OBJ or FBX to glTF using native libraries on your server, like obj2gltf and fbx2gltf.
Load the glTF file on the web app.
Method 2:
Load the OBJ or FBX using OBJLoader or FBXLoader, giving you a THREE.Mesh or other object.
Convert that THREE.Mesh to a glTF file using GLTFExporter.
Load the glTF file using GLTFLoader, giving you a THREE.Mesh or other object again.
Method 1 is harder, but may give you better conversion results because the native libraries have access to the FBX SDK. Method 2 is fairly easy, but I can’t think of any benefit to doing that… the Mesh you have after the loading the OBJ or FBX will be (at best) the same as the Mesh you get at the end. At worst, the roundtrip through GLTFExporter->GLTFLoader may introduce performance or correctness problems.

Trying to convert .dae file to .gtlf file so I can use with cesium 3d model

I am trying to convert a 3d dae file to a glTF file.
I originally built something in SketchUp and exported to .dae.
I tried the following site which is supposed to convert to .gtlf but it converts to a .glb. What is the difference between a .gtlf file and a .glb?
Can I use a .glb to load into Cesium?
Can I just use like an ordinary icon?
https://cesiumjs.org/convertmodel.html
The .glb file extension indicates the file uses the Binary glTF extension, which is an official Khronos extension (hence the KHR prefix) and is fully supported by Ceisum. Cesium actually ships with some example .glb files.
The main difference between binary glTF and stock glTF is the binary one is compressed and takes less network bandwidth.

I get "TypeError: a is undefined" when I try to load specific VTK file

I try to load VTK file using three.js, I have changed only one line in example file:
loader.load( "models/vtk/srtm.vtk" );
Here is my VTK file. There is TIN vector map, prepared in GRASS GIS, and converted using v.out.vtk command.
I am very new in Three.js and 3D Graphics, I just want to check some possibilities of Three.js for further work.

I need a source for three.js

Can somebody give me some information or a tutorial, to import an 3d model in format .obj with three.js?
You can get examples from here:
https://github.com/mrdoob/three.js/tree/master/examples
For importing models in .obj format,you may get the example from:
https://github.com/mrdoob/three.js/blob/master/examples/webgl_loader_obj.html

Categories