.glb import ZIMjs javascript solution to see the texture , why so difficult?

I like threejs to import gltf into new GKTFloader(“url”)

more info into example  ZIM with three.js 

but when using an .glb I can’t see the color texture appeari g.

so from this video https://youtu.be/017kfUTcAPE?si=ah4ugh3BVhNzGfhb

and video

realPlayerMe character maker you can extract .glb

see video

but many people have problem with that Issues with Model textures not displaying in Three.js – Material Conversion Problem?

so solution seems to script and turn 180degree and flip the file to be able to see it in a html5 canvas

see the discussion at Issues with Model textures not displaying in Three.js – Material Conversion Problem?

thanks to make a .glb directly visible onto the html5 canvas

click/scan the qr-code to see fullscreen app ZAPP: person3D fix+head turns up/down+left/right sliders + you move cam(ml5) | ZIM JavaScript Canvas Framework

or this with small body ZAPP: threejs person with hat: now canlook to the moving the cursor (.glb) | ZIM JavaScript Canvas Framework

idea from https://youtube.com/shorts/9GGaOP8ooOA?si=b_feM-OePiNFsmAQ

and https://youtu.be/017kfUTcAPE?si=ah4ugh3BVhNzGfhb

check also discussion Loading GLB models with texture. Can't see the texture in the scene! - #5 by shanky

check also how bones can turn into the threejs editor https://youtu.be/P7Lley9BjGA?si=LSXNWDzbhlgwXOdN

from article Animating Models Programmatically in Three.js - Wael Yasmina

so the idea of turning the head following the cursor at How to Make a Model's Head Follow the Cursor in Three.js - Wael Yasmina

with video I remade it in ZIM Editor - JavaScript Canvas Online Code Editor and Viewer

many have problem with gltf without color texture Loading GLB models with texture. Can't see the texture in the scene! - #5 by shanky

and this topic In scene.gltf file "images" for textures won't load in the browser using GLFLoader

and Blender Exported .glb model not loading with texture

Different file formats and engines have different conventions for UV coordinates. In glTF files, the UV coordinates are defined such that:

…the texture coordinate value of (0.0, 0.0) points to the beginning of the first (upper-left) image pixel, while the texture coordinate value of (1.0, 1.0) points to the end of the last (lower-right) image pixel.

In three.js this would imply that your THREE.Texture should be configured with the texture.flipY = false setting, the default is true. Other 3D model formats may have other conventions, or none specified. GLTFLoader handles this automatically if the texture is referenced by the .gltf/.glb file, but when manually adding a texture to a mesh from a glTF file, you’ll need to set .flipY=false yourself. Whether ZIMjs has any additional requirements, I’m not sure.

An alternative to texture.flipY would be to flip the texture coordinates on the geometry after loading, instead. If you prefer that approach, see:

1 Like

thanks to answer, but can you try the fox from https://app.mesh2motion.org/

so when I import it whithout texture in  ZIM with three.js  I see no texture you can see a white fox here ZAPP: robotFOXGame:ML5 jump above boxes, catch 10 coins (wood+green) | ZIM JavaScript Canvas Framework

so I fixed it into this now zim app ZAPP: FOXgame: catch coins, jump over red boxes (key+touch+cam=ML5)nospeed | ZIM JavaScript Canvas Framework

click the qr-code to open fullscreen

Note: I made it also with the threejs robot https://threejs.org/examples/#webgl_animation_skinning_morph where there was no texture problem because it is colored?

ZAPP: robot yellow game: jump above red boxes, catch the 10 coins (wood+green) | ZIM JavaScript Canvas Framework

the second app with the robot has also a sky ZAPP: robotYellow fullGAME: MOVE=show 1<fingers>4 + 5 fingers=JUMP (ml5cam) | ZIM JavaScript Canvas Framework

what do you think why the textures are not imported of the fox.glb and others in ZIMjs?

(note: idea of the game came from https://youtu.be/gi5sFJbjR6o where you need to move before the cam)

Lots of links there – sorry, that’s more than I’m going to click through! If you want to create one minimal reproducible example with a model and a texture not working as expected, I could try looking at that. If the issue is only happening in ZIM apps, it might be worth asking on the ZIM forums as well. I don’t have experience with ZIM myself.

this is simple sample ZAPP: Robot yellow VR/XR +HUD:walk/sit/wave.. expressions=eyebrow MENU on/off - Copy | ZIM JavaScript Canvas Framework with the robot that works in ZIM to animate (in blue sky sphere ZAPP: Robot yellow VR/XR +HUD:walk/sit/wave.. expressions=eyebrow TITLE on/off | ZIM JavaScript Canvas Framework )

you can see how it is with the fox with no texture when doing it what I supposed threeJS could bring the textures inside ZAPP: Robot FOX white VR/XR +HUD:run/sit/jump.. expressions=eyebrow (bg=blue) | ZIM JavaScript Canvas Framework

so I changed the code so into this app the fox has texture ZAPP: Robot FOX brown VR/XR +HUD:run/sit/jump.. expressions=eyebrow (bg=blue) - Copy | ZIM JavaScript Canvas Framework

but it should be directly visible ofcourse

Setting a breakpoint in the GLTFLoader source of the ZIM app, we see this error in the console:

THREE.GLTFLoader: Couldn’t load texture
TypeError: Failed to execute ‘createObjectURL’ on ‘URL’: Overload resolution failed.

Adding a breakpoint near the source of that error, execution fails on the following lines:

// Load binary image data from bufferView, if provided.

sourceURI = parser.getDependency( 'bufferView', sourceDef.bufferView ).then( function ( bufferView ) {

	isObjectURL = true;
	const blob = new Blob( [ bufferView ], { type: sourceDef.mimeType } );
	sourceURI = URL.createObjectURL( blob ); // ‼️
	return sourceURI;

} );

It looks like the ZIM environment has replaced the global Blob class with something else. Typing Blob in the console and you’ll see that it prints a different constructor than the usual [ native code ] result you’d get on other websites. So, it looks like this is a bug with the ZIM environment and would need to be reported there.

One option to work around the issue might be to use .gltf files with external textures, rather than .glb files with embedded textures, but normally in three.js that would not be needed.

2 Likes

Could try pinging: @danzen :slight_smile:

it works perfectly with .gltf files, so that is why is wondering if it was a ThreeJS problem or ZIMjs problem, @danzen told it was a ThreeJS problem.. ok so thanks for your answers. I’ll check it out.

check example with external loaded textures ZAPP: threejs person with hat: now canlook to the moving the cursor (.glb) | ZIM JavaScript Canvas Framework
and threejs gltf import, not working to turn the head by the cursor at ZAPP: threejs person: now can follow the head when moving the cursor (.gltf)NOTWORKS | ZIM JavaScript Canvas Framework

but it seems because there are multiple textures it gives the error in ZIM

Oh… if it is a Blob issue… add:

Blob = document.Blob;

at the start of the ready event before bringing in the three.js model.

If you then need a ZIM Blob too use zim.Blob.

We had made and used a ZIM Blob for a few years before we realized that JS had a Blob too. So the solution above should work. You can also set zns=true in a JS script before importing ZIM to force the zim namespace and then if you want globals use zimplify(“Blob”); which will exclude Blob from globals.