Generate Text Mesh using WASM

v4.0.0

6 Likes

Excellent !!! :heart::heart::heart:

1 Like

app/gen/

:grin:

1 Like

Hi there. This is amazing work!

I really want to use it and I have these possible errors on console :frowning: Could you please help? @ycw

When only Compile is trying to be executed
When .ts or .js is used

main.ts:88 Uncaught (in promise) TypeError: Cannot read property ‘Build’ of undefined
at Object.eval (main.ts:88)
at step (main.ts:33)
at Object.eval [as next] (main.ts:14)
at eval (main.ts:8)
at new Promise ()
at __awaiter (main.ts:4)
at Object.main [as default] (main.ts:42)
at eval (viewer.ts:75)
at e.aux.assetsManager.onProgress (auxiliaries.ts:60)
at e._decreaseWaitingTasksCount (babylon.js:16)

When .mjs is used

Uncaught (in promise) TypeError: Failed to execute ‘compile’ on ‘WebAssembly’: Incorrect response MIME type. Expected ‘application/wasm’

Bare example using babylon.font.js
https://jsfiddle.net/mych2w8s/

Bare example loading babylon.font.mjs as esmodule
https://jsfiddle.net/6fm1zrhk/

Extra: simple multiline layout solution
using babylonjs’ instancing and utils fn Font.Measure(..)

:beers:

2 Likes

Thank you very much @ycw ! I am now able to use it and it’s perfect.

Only three questions remain for further perfection in my project :slight_smile:

  • Is there a proper way to update the text, rather than disposing the mesh and rebuilding?
  • Compile throws mime-type error when local URL is given. How to tackle that?
  • Is there a way to avoid using <script> tags to include earcut and opentype?

I am using npm and installing these modules did not help for the ReferenceError: opentype is not defined.
Adding one line to import opentype in babylon.font.mjs throws ReferenceError: earcut is not defined.
Only defining window.earcut and window.opentype with their exports works, but it is not a good solution.

I have been looking around to find a proper way, I am not very well experienced in these terms so please excuse.

Much appreciation for your tool again!

1 Like

use a mesh pool

config server content-type: ...

no. ( need to make them deps of project babylon.font, i’ll try this https://github.com/ycw/Babylon.Font/tree/dev :clap: )

1 Like

solved. at GitHub - ycw/Babylon.Font: Generate text mesh for BabylonJS using WASM, written in AssemblyScript. ( v2.0.0 )

Now we need to import opentype, earcut and babylon as module
and inject to here ( see Release v2.0.0 · ycw/Babylon.Font · GitHub )


added a bare example to repo ( src ) ( live demo )

:beers:

1 Like

v3.0.0

  • fixed package.json
  • added gui to Bare Example
  • rm app/gen
  • use latest assemblyscript
2 Likes

v4.0.0

  • wasm out-of-mem is now recoverable
  • fixed .d.ts
4 Likes