How can I create Mesh from PointCloud? - javascript

How can I create Mesh from PointCloud, using draco or similar package for node.js
Expect to get Mesh so that I could encode or create compressed file

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.

Use an .obj file like a normal BoxGeometry with Three JS

I would like to use an object file the same way I would use a BoxGeometry in three.js (like adding material and stuff), is there a way to do this?

Colada texture export for Three.js

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.

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.

Categories