Online MTM2 truck viewer

Downloads: https://www.mtm2.com/~trucks/trucks.php
User avatar
Kmaster
Member
Posts: 1416
Joined: Fri Oct 10, 2003 6:19 pm
Location: Valparaíso, Chile.
Contact:

Online MTM2 truck viewer

Post by Kmaster »

JSTruckViewer
I created a very simple, online POD truck viewer for MTM2 trucks based on the Three.js library.

JSTruckViewer is a browser-based pure javascript 3D viewer for MTM2 and 2.1 patch trucks. Drop in a POD or ZIP file from your local storage, or point it at a CORS-enabled URL, and the viewer decodes the complete truck model, textures, axles, driveshaft, axlebars, shocks and wheel placement in a render that you can freely move with your mouse. Latest version includes scene lighting and texture smoothing.
Captura de pantalla 2026-06-03 a la(s) 3.42.44 p.m..jpg
Captura de pantalla 2026-06-03 a la(s) 3.42.44 p.m..jpg (141.2 KiB) Viewed 12148 times
I hosted it on github pages so i can be previewed right away.

https://juanputrerasm.github.io/JSTruckViewer/

it is also directly implemented in the Trucks page thanks to Fila. This version supports podzipped trucks.

You need all the files mentioned in the TRK & BIN files inside the actual POD file. Missing textures are replaced by solid gray.

Source code: https://github.com/juanputrerasm/JSTruckViewer

*edited to reflect latests changes*
Last edited by Kmaster on Wed Jun 03, 2026 3:48 pm, edited 2 times in total.
User avatar
Fila
Member
Posts: 1548
Joined: Mon Jul 02, 2001 2:01 pm
Location: Lost in Translation
Contact:

Re: Online MTM2 truck viewer

Post by Fila »

This is pretty neat. Probably have to cheat the tire position right?
User avatar
Kmaster
Member
Posts: 1416
Joined: Fri Oct 10, 2003 6:19 pm
Location: Valparaíso, Chile.
Contact:

Re: Online MTM2 truck viewer

Post by Kmaster »

The truck looks like is flying isn't it? but wheel position is based on the static.bpos values of each wheel, and the wheel itself is expected to be centered around its own origin.
the true cheat of sorts is on the axlebar. static.bpos values are used but then i had to re-center the model and scale it so it fits the inner faces of the wheels. Obviously this trick is not perfect, when rendering trucks likes BF Power wheels from RepFan the axlebar is separated from the wheels. So maybe the axlebar don't need any re-scaling at all
User avatar
Fila
Member
Posts: 1548
Joined: Mon Jul 02, 2001 2:01 pm
Location: Lost in Translation
Contact:

Re: Online MTM2 truck viewer

Post by Fila »

The axle bar looks correct. Maybe it is somehow tied into the tires to begin. It would make sense since they move together with the tires.

I haven't touched the MTM2 code in a long time, I don't even know what are the latest versions that I was able to get to compile (as that is a hassle in its own right due to the spaghetti code from 20 years ago). lol. I will have to try and remember how to set it up again with the latest visual studio and see if I can spot anything about it in there (and work on having the viewer default to the missing stock parts).
User avatar
Kmaster
Member
Posts: 1416
Joined: Fri Oct 10, 2003 6:19 pm
Location: Valparaíso, Chile.
Contact:

Re: Online MTM2 truck viewer

Post by Kmaster »

in the meantime I added light support, removed the axle scaling and added a ground grid

Image

Image
Jpez1432
Member
Posts: 104
Joined: Sun Apr 17, 2005 8:10 am
Location: U.S.A.
Contact:

Re: Online MTM2 truck viewer

Post by Jpez1432 »

Hey KMaster, not sure how you do the scaling in your rendering. I use OpenGL so everything is normalized. I multiple/scale the models by 1/65536.0f, swap x/z and negate z. the scrape points and wheel positions and axlebar/driveshaftpos I scale all by 1/32.0f and then the fourlinks are the absolute value of the the axlebars and the shock position is the wheel position * 0.256f x. kinda hard to explain if you want I can send some code or try and explain better.
User avatar
Fila
Member
Posts: 1548
Joined: Mon Jul 02, 2001 2:01 pm
Location: Lost in Translation
Contact:

Re: Online MTM2 truck viewer

Post by Fila »

Alright I realized why the trucks look like floating. There's two reasons and definitely in the MTM2 code.

1. The drive shaft is missing.
2. MTM adds some fake struts through code. The model itself doesn't have them but MTM2 code adds some 2D always-facing sprites to simulate the struts.

So the way the truck looks in the JViewer is the default position when the truck is in the air. In the game it doesn't look as odd because of the additional drive shaft and fake struts giving you the illusion it is all connected. Once it lands on the ground, it has a different "resting" position that I will have to look and see if I can find it. It's probably a fixed value for all the trucks since the game doesn't take into consideration weight etc.
Attachments
TRI_susp_cheat.jpg
TRI_susp_cheat.jpg (167.13 KiB) Viewed 41164 times
User avatar
Fila
Member
Posts: 1548
Joined: Mon Jul 02, 2001 2:01 pm
Location: Lost in Translation
Contact:

Re: Online MTM2 truck viewer

Post by Fila »

Also... for some reason after downloading the latest version the axle bar won't show up anymore (and lights are not working).
User avatar
Fila
Member
Posts: 1548
Joined: Mon Jul 02, 2001 2:01 pm
Location: Lost in Translation
Contact:

Re: Online MTM2 truck viewer

Post by Fila »

I looked at BinEdit to see how it displays a truck (when you use import.trk) and it has the same missing driveshaft and fake struts, but it has the tires in the ground resting position.
User avatar
Kmaster
Member
Posts: 1416
Joined: Fri Oct 10, 2003 6:19 pm
Location: Valparaíso, Chile.
Contact:

Re: Online MTM2 truck viewer

Post by Kmaster »

Jpez1432 wrote: Sat May 23, 2026 9:00 am Hey KMaster, not sure how you do the scaling in your rendering. I use OpenGL so everything is normalized. I multiple/scale the models by 1/65536.0f, swap x/z and negate z. the scrape points and wheel positions and axlebar/driveshaftpos I scale all by 1/32.0f and then the fourlinks are the absolute value of the the axlebars and the shock position is the wheel position * 0.256f x. kinda hard to explain if you want I can send some code or try and explain better.
Question: Where did you get those values? because mine are read directly from the BIN file header, the file tells you its own scale factor.
magnify power block type was something I discovered while working in JTraxx since it wasn't specified anywhere, at least not openly. I got some help from Striker (the dev of Terminal Fury) since I was having some issues with hellbender model scaling and found out about it. it wasn't even specified in the jtrfp library or Traxx source.

here's a complete AI agent code analysis:

Code: Select all

Each vertex component is a raw int32. The least significant bit is a geometry flag, not part of the coordinate, shift 
it out first:
coordinate = rawInt32 >> 1
Then scale using magnifyPower, a value stored directly in the BIN file header (block type 0x14):
scaled = coordinate * (512.0 / magnifyPower)
The file is self-describing: magnifyPower is literally the second int32 in the file. It's almost always 65536, which 
simplifies to coordinate / 128, but reading it from the file is the correct approach. Hardcoding 65536 will silently 
produce wrong geometry for any BIN that uses a different value.
Skipping the >> 1 or using integer math instead of float will also break geometry.

Regarding TRK positions (wheel anchors, scrape points, axlebarOffset, driveshaftPos):
These are already in game units, no scaling needed. They are used as-is alongside the BIN-scaled vertices.

On the fourlinks and shock:
Fourlinks = abs(axlebarOffset) confirms the X component is a half-width magnitude, not a signed 
lateral offset. The shock_x = wheel_x * 0.256 is good to have for suspension visualization.
if you need more info on it let me know
Fila wrote: Sun May 24, 2026 5:11 pm Also... for some reason after downloading the latest version the axle bar won't show up anymore (and lights are not working).
I "hard reload" and erased all cache data after deploying the new version. In chrome: Dev tools enabled > right click reload button > empty cache & hard reload. Otherwise it will fail to load.
Fila wrote: Sun May 24, 2026 4:53 pm So the way the truck looks in the JViewer is the default position when the truck is in the air. In the game it doesn't look as odd because of the additional drive shaft and fake struts giving you the illusion it is all connected. Once it lands on the ground, it has a different "resting" position that I will have to look and see if I can find it. It's probably a fixed value for all the trucks since the game doesn't take into consideration weight etc.
Good info, then in the meantime I can just squash the truck a little bit to make it look more familiar.
User avatar
Kmaster
Member
Posts: 1416
Joined: Fri Oct 10, 2003 6:19 pm
Location: Valparaíso, Chile.
Contact:

Re: Online MTM2 truck viewer

Post by Kmaster »

y-1.0 seems to do the trick. Funny enough, at that offset the wheels are actually clipping through the body, i never noticed that before!
Image
User avatar
Fila
Member
Posts: 1548
Joined: Mon Jul 02, 2001 2:01 pm
Location: Lost in Translation
Contact:

Re: Online MTM2 truck viewer

Post by Fila »

Yeah. I only realized that now myself when I was looking for the fake struts.
User avatar
Kmaster
Member
Posts: 1416
Joined: Fri Oct 10, 2003 6:19 pm
Location: Valparaíso, Chile.
Contact:

Re: Online MTM2 truck viewer

Post by Kmaster »

i added ZIP file support and changed the theme. I saw this one in a three.js demo and liked it. it maches MTMG style also
screenshot_wildfirev2bymatt785.png
screenshot_wildfirev2bymatt785.png (58.83 KiB) Viewed 37996 times
now the viewer uses the fflate lib to extract zip files, then loads the first POD file found.

yeah, the BIN renderer needs some help :wink: https://juanputrerasm.github.io/JSTruckViewer/

source
User avatar
Fila
Member
Posts: 1548
Joined: Mon Jul 02, 2001 2:01 pm
Location: Lost in Translation
Contact:

Re: Online MTM2 truck viewer

Post by Fila »

Hey, looking better and better. Since I don't know three.js, I assume it only has one specific rendering option right?

I haven't had a chance but probably at the end of the week I will look into the mtm2 code to try and find how it handles the drive shaft/fake struts.
User avatar
Kmaster
Member
Posts: 1416
Joined: Fri Oct 10, 2003 6:19 pm
Location: Valparaíso, Chile.
Contact:

Re: Online MTM2 truck viewer

Post by Kmaster »

Thanks for the help fila. I went ahead and implemented all the missing parts based on BinEdit truck editor; axlebars, driveshaft and shocks. and after some observation, fix the z-fighting issues three.js had with double sided faces. i kept the gravity hack (the y:-1.0 hack) now switchable. Now the app looks more production quality.

Image
User avatar
Fila
Member
Posts: 1548
Joined: Mon Jul 02, 2001 2:01 pm
Location: Lost in Translation
Contact:

Re: Online MTM2 truck viewer

Post by Fila »

Oh wow this is looking great! I'll toy around with it in the weekend see if I can spot anything else. And I'm gonna think of how to incorporate it into the website.
User avatar
KF2416
Member
Posts: 47
Joined: Thu Sep 22, 2022 10:50 pm
Location: Somewhere in Canada
Contact:

Re: Online MTM2 truck viewer

Post by KF2416 »

Assets (like models and textures from base games like MTM 1 and 2) are missing when previewing a truck using online truck viewer. They always don't load properly, not even in "ART" and "MODELS" folders.
Attachments
missingassets.PNG
missingassets.PNG (84.2 KiB) Viewed 29433 times
The monster truck garage of KimikoFan2...

Image

Impact Monster Championship playlist:
https://www.youtube.com/playlist?list=P ... _NZQT6712_

The Monster Truck Community Server (feel free to join if you want):
https://discord.gg/SxwBuTRAJA

"I'm Army Armstrong. Are you ready for Microsoft's Monster Truck Madness?"
-Army Armstrong, 1996
User avatar
Kmaster
Member
Posts: 1416
Joined: Fri Oct 10, 2003 6:19 pm
Location: Valparaíso, Chile.
Contact:

Re: Online MTM2 truck viewer

Post by Kmaster »

yes, stock art and models are not included in the viewer.

i noticed that the pod file LegendOfWii_BoogeyVan2013.pod doesnt include them also, so the warnings in you screenshot are correct.
Captura de pantalla 2026-05-29 a la(s) 2.27.57 a.m..jpg
Captura de pantalla 2026-05-29 a la(s) 2.27.57 a.m..jpg (55.69 KiB) Viewed 29179 times
basically Boogey Van 2013 is a podzipped truck and like i mentioned on the OP, these wont work correctly due to missing assets.
User avatar
KF2416
Member
Posts: 47
Joined: Thu Sep 22, 2022 10:50 pm
Location: Somewhere in Canada
Contact:

Re: Online MTM2 truck viewer

Post by KF2416 »

So, can you at least fix it by including stock arts and models in the viewer?
The monster truck garage of KimikoFan2...

Image

Impact Monster Championship playlist:
https://www.youtube.com/playlist?list=P ... _NZQT6712_

The Monster Truck Community Server (feel free to join if you want):
https://discord.gg/SxwBuTRAJA

"I'm Army Armstrong. Are you ready for Microsoft's Monster Truck Madness?"
-Army Armstrong, 1996
User avatar
Kmaster
Member
Posts: 1416
Joined: Fri Oct 10, 2003 6:19 pm
Location: Valparaíso, Chile.
Contact:

Re: Online MTM2 truck viewer

Post by Kmaster »

KF2416 wrote: Fri May 29, 2026 1:56 am So, can you at least fix it by including stock arts and models in the viewer?
it's something i need to think about. Game assets are copyrighted content, and uploading them in github... not a good idea. Maybe we can add custom axles or wheels that look similar to stock models & art? or add the ability to replace these with your own supplied truck2.pod files? We'll figure it out.
Post Reply