正在加载视频...

视频加载失败

Ported Google's Draco decoder to pure JavaScript. 4.3× smaller than the WASM build, byte-for-byte identical output, often faster once you factor in load, init and parse.

95,436 次观看 • 3 个月前 •via X (Twitter)

49 条评论

mrdoob 的头像
mrdoob3 个月前

This library shines on spotty mobile connections, where transferring 100KB takes much longer than 20KB. Even if JS parsing is slower than WASM, the model displays faster because of the reduction in network overhead.

mrdoob 的头像
mrdoob3 个月前

Managed to reduce the bundle size. It's 5.2× smaller now.

Volodymyr Agafonkin 🇺🇦 的头像
Volodymyr Agafonkin 🇺🇦3 个月前

Very cool! A well-optimized JS version of a code like this can match native performance in my experience too. You should try meshopt decoder next! At Mapbox, we have switched from Draco to Meshopt because it's both simpler, faster and generated smaller models for our use case.

mrdoob 的头像
mrdoob3 个月前

Oh! I'll put that on the list 🤓

Arseny Kapoulkine 的头像
Arseny Kapoulkine3 个月前

@mourner Pure JS version is maintained here ;) (it's not particularly optimized, I'm sure it can be faster - getting close to Wasm speed should be impossible however, and the Wasm decoder bundled into JS is pretty tiny, but just in case you need JS-only option)

Volodymyr Agafonkin 🇺🇦 的头像
Volodymyr Agafonkin 🇺🇦3 个月前

@mrdoob Happy to see you chime in, amazing project! I guess you mean it’s impossible because of the SIMD build? But for certain cases (e.g a ton of smallish models), JS to WASM comms overhead could be bigger than the SIMD win. Worth an optimization pass attempt at least 😊

Arseny Kapoulkine 的头像
Arseny Kapoulkine3 个月前

I would be quite skeptical; the communication overhead is really just a copy of data in & out of the Wasm heap - it's not free but it's comparatively cheap and it's easy to lose much more on inefficient codegen. It's also not just SIMD; even scalar Wasm often runs faster than optimized JS for these workloads. But of course people should experiment :)

Volodymyr Agafonkin 🇺🇦 的头像
Volodymyr Agafonkin 🇺🇦3 个月前

@mrdoob Challenge accepted, I'm really curious! Will do some benchmarking on our typical workloads and report back

Volodymyr Agafonkin 🇺🇦 的头像
Volodymyr Agafonkin 🇺🇦3 个月前

@mrdoob You were right! On a typical Mapbox workload (90 buffers, 16.5MB compressed total), baseline JS reference is 14x slower than WASM; after heavy optimization, it's still 3.5x slower. The WASM version is exceptionaly fast and small, and cold start is 4-5ms (negligible)

herbst 的头像
herbst3 个月前

@fernandojsg Now do KTX2! 😄

mrdoob 的头像
mrdoob3 个月前

@fernandojsg Tempting 😅

robot 2.0 的头像
robot 2.03 个月前

you are really ramping up the speed lately

mrdoob 的头像
mrdoob3 个月前

I actually did this back in January with poor Opus 4.5. Decided to do another pass with 4.8 and finish it off today.

Alex Spînu 的头像
Alex Spînu3 个月前

This is cool - would be cool to see Cesium's gltf-pipeline for draco for batch compressing built in ( if the scope isnt to have a 1:1 draco port ) :D

mrdoob 的头像
mrdoob3 个月前

Feel free to send a PR or do whatever it's needed 🤗

gsimone 的头像
gsimone3 个月前

This feels like a good idea for a lot of cases, make sure to ship a benchmark - cli so agents can do it - so people can use to find the best tool for their job - eg. there's got to be a breaking point where paying the extra is worth it

David Ronai 的头像
David Ronai3 个月前

omg thats big ! 🥳

Anderson Mancini 的头像
Anderson Mancini3 个月前

Thats huge 🤯🤯🤯👏🏻👏🏻👏🏻

Nicola 的头像
Nicola3 个月前

Would you recommend to use it already? I use Draco for boats models.

mrdoob 的头像
mrdoob3 个月前

Feel free to give it a go ✌️

Aymeric Rabot 的头像
Aymeric Rabot3 个月前

@wawasensei Yay! Thx

Gregor 的头像
Gregor3 个月前

wasm init was costing me 380ms before a single byte parsed

Luke Wood 的头像
Luke Wood3 个月前

This further supports my opinion that WASM is just generally not very useful.

tim 的头像
tim3 个月前

@threejs wow

David Bang 💥 的头像
David Bang 💥3 个月前

u r awesome

AiDevCraft 的头像
AiDevCraft3 个月前

The "once you factor in load and init" line is the unsung headline — for one-shot mesh decodes the WASM startup tax often eats its steady-state win. Bonus is sidestepping the SharedArrayBuffer/COOP header dance the WASM build usually drags into a CDN.

Dishant 的头像
Dishant3 个月前

the init time difference is wild. that alone makes it worth it for web use

Andrea Giammarchi 🍥 的头像
Andrea Giammarchi 🍥3 个月前

Some crash on Safari Mobile + littlest Tokyo has no light but overall wonderful project/port

keaukraine 的头像
keaukraine3 个月前

On my Pixel10 at battery saving power mode total improvement is ~1.1x on average. Load+init times are way longer for WASM, up to 400 ms which is user-perceivable. JS parse times are also not that bad. Overall, I agree that JS version is good enough.

Jules ⭐ 的头像
Jules ⭐3 个月前

JS is fast 💪

just-a-programmer 的头像
just-a-programmer3 个月前

Why is the wasm larger?

OGD 的头像
OGD3 个月前

@threejs Sick!

Alvaro アルバロ 的头像
Alvaro アルバロ3 个月前

@threejs 🙌

Skal 的头像
Skal3 个月前

Oh wow, nice! You know who to ping :)

mrdoob 的头像
mrdoob3 个月前

Haha yes. The man is very busy these days though 😅

Daniel Cluff 的头像
Daniel Cluff3 个月前

@iced_coffee_dev This is pretty cool but it looks like parsing is often slower. This is fine for one off imports but if you are loading a large amount of assets wasm probably wins. I would like to see a benchmark that tests performance at scale.

mrdoob 的头像
mrdoob3 个月前

@iced_coffee_dev Yeah. Do it 👌

Benny Schuetz 的头像
Benny Schuetz3 个月前

That's pretty slick!

Carmelo schepis 的头像
Carmelo schepis3 个月前

Impressive savings and speed boost!

hyeseong.kim 的头像
hyeseong.kim3 个月前

Pure JS port for the real win!

🌵 Marcel Wiessler 的头像
🌵 Marcel Wiessler3 个月前

But... in the video WASM rendering shows up before JS - what am I missing?

Erik Sombroek 的头像
Erik Sombroek3 个月前

Thats really nice!

Palash Bansal 的头像
Palash Bansal3 个月前

This is awesome, will put it in the 3d model quicklook app

Guilherme O'Tina 的头像
Guilherme O'Tina3 个月前

this is a great counterexample to the assumption that wasm is always the right call for web delivery. for long-running compute wasm wins easily. but for draco decoding where each call is short and the init overhead dominates, pure JS can win on total time plus bundle. 4.3x smaller changes the economics for shipping 3d on the web

Jens Fursund 的头像
Jens Fursund3 个月前

This is awesome!

Afshawn Lotfi 的头像
Afshawn Lotfi3 个月前

used to use Draco, like meshoptimizer better

tandavas 的头像
tandavas3 个月前

@iced_coffee_dev Extremely cool!

Saad Haider 的头像
Saad Haider3 个月前

Parse time is always bigger so for a game with alot of models, .js wont matter as the total parse time would make it par with the .wasm

mrdoob 的头像
mrdoob3 个月前

Yes

相关视频