Import points from. txt

I’ve a complex shape in a .txt defined by points. I want to make an extrusion with it. Is there any way to import the points so i can use later the ExtrudeShapeCustom function?

Hey @Darth_Luis , how are you doing?

Babylon.js allows you to create you own asset importers for specific file types:

Create Your Own File Importer | Babylon.js Documentation (

I’ve made a simple demo using BABYLON.SceneLoader.RegisterPlugin to load a .txt file into you scene. You can than parse the file as you want.

Babylon.js Playground (

1 Like

Hey @srzerbetto thanks you for answer.
I’m having some problems with the loadAssets fuction
I’ve put the following lines in my code ( i’m writing it on visual core studio)
loadAssets(scene: any){
const container = new AssetContainer(scene);
return container;
However it doesn’t like the way i write it and suggest me the following change
loadAssets(scene: any): AssetContainer{
const container = new AssetContainer(scene);
return container;
Despite of being able to compile it stills complain about the loadAssets
Do you know what is the problem with it?

It seems like your editor is just suggesting that you specify the returning type of your loadAssets function. They suggested way show that the returning type is a AssetContainer.

This is not mandatory but it is a good practice when using Typescript.

Thank you, you’re right.
Now that I’ve import my “.txt” file, I need to tell Babylon that the data it reads is a Vector3 so I can use it as the shape of an ExtrusionShapeCustom.
How can I do it?

why do you need it to be .txt? this is not a common interchange format and that is why you now have to write your own parser.

Just make it JSON and then you wont need to write a parser. I’m pretty sure chatGPT could convert your .txt data into JSON with no troubles. work smart and embrace the future.

or is there some very specific need for using a .txt file?

I said .txt because I’ve got the data in that kind of file. I will try as you said. I have been searching but i can’t find how to import JSON files neither.
I also want my imported data to be a sucession of point so I can use it as the shape of a ExtrudeShapeCustom. Have I had to do something after importing it?

but i can’t find how to import JSON files neither

It seems you don’t have much coding experience, I’m not sure to what extent people will be willing to continue to respond to every question, when they start all just becoming trivial basic coding things,

I mean, I’m baffled that you can’t even find something when looking how to import json?

Again let me suggest, just ask chatgpt to write you some JavaScript to import a static json file. It will do that with ease

yes, I almost have no experience coding. Sorry for bothering you.

No need to apologize to me :slightly_smiling_face: also I’m not being bothered, I choose to be a part of this community and contribute, I consider it a blessing and a privilege.

Anyway, I just pointed out an observation and mentioned with this sort of predicament normally you have to expect help offered to eventually run out and reach an end, probably before you reach your goal.