Three.js: THREE.ColladaLoader: Undefined sampler

Created on 30 Oct 2017  路  20Comments  路  Source: mrdoob/three.js

Description of the problem

Hi,
Sorry for ticketing so many issues lately :sweat_smile:

Some meshes started showing this error after upgrading to the new Collada, e.g. this mesh.

So after some debugging, in the loader at this line it is trying to find texture0 in the samplers, while the correct sampler is texture0-sampler .

This workaround solves it for me.

var sampler = effect.profile.samplers[ textureObject.id ] || effect.profile.samplers[ textureObject.id + '-sampler' ];
Three.js version
  • [x] Dev
  • [ ] r87
  • [ ] ...
Browser
  • [x] All of them
  • [ ] Chrome
  • [ ] Firefox
  • [ ] Internet Explorer
OS
  • [x] All of them
  • [ ] Windows
  • [ ] macOS
  • [ ] Linux
  • [ ] Android
  • [ ] iOS
Hardware Requirements (graphics card, VR Device, ...)

Most helpful comment

I figured out a clean way that should solve the issue.

All 20 comments

I'm confused why the usage of the sampler just fails in your case 馃 . We tested with so many examples where this was no problem.

Your proposed fix might work in your case but it does not look like a generic solution to me. I need to debug this one...

After having a look at the rest of our models, it seems like there are only a very few meshes that have this problem ... but was working fine with the old collada :confused: .

Is it possible to provide the entire model as a zip file again? 馃槉 Makes it easier to see if the texture is actually applied.

Having the same issue with Maya 2017 here. Is the loader expecting a specific shading network to be set before exportation with the DAE_FBX exporter from Maya ? I am asking because it seems, among a couple of secondary disparities, that the surface and sampler2D newparams are not created in the dae file, nor the sampler passed as the texture in the texture tag of the desired channel. The texture is fed with the image id directly instead.
Correcting the issue manually in the file solves the problem, but are we supposed to export a specific material network or is the collada exporter supposed to properly convert various Maya materials directly suitable to threejs's collada loader ?
Thx for the support !

Edit : Mmmmh, the problem does not show up at all with the latest OpenCollada plugin for Maya 2017 (v1.6.60).
https://github.com/KhronosGroup/OpenCOLLADA/releases
Problem solved at least for me..

Sure, here is the model zipped .

In your files, it looks like the blender exporter is properly giving the sampler's id to the channel's texture, whereas meshlab's present kind of the same problem as Maya 2017's here, giving the image id instead of the sampler id to the channel's texture. Feels like a collada exportation plugin problem..

Sketchfab is actually able to load the file correctly. I'm still not sure about the correct handling of this case. Unfortunately, i did not find something useful in the spec. It only refers to the workflow via samplers.

https://www.khronos.org/files/collada_spec_1_5.pdf

Run into the same problem with every object I downloaded from clara.io which uses textures.

BUT! Found following ;)
https://github.com/KhronosGroup/OpenCOLLADA/issues/92#issuecomment-13135708

Also in the collada spec 1.5 ( @Mugen87 )
texture="myParam" => The value is specified by a reference to a previously defined object.
image

So the implementation of the Collada Loader seems fine according to the specification...
=> the issue itself is invalid since it rather seems like a bug in the exporter

Models from clara.io, with textures, works fine when uploaded again on clara.io so I don't know what clara.io does in perticular but probably they check for the sampler and if it is not available they create one... hacky but seems to work on their site.

Here is a thread on clara.io regarding .dae files downloaded there don't work with three.js
exporting-models-with-materials-not-working-in-three-js

@bhouston Can you recommend an approach for handle this issue inside ColladaLoader?

tl;dr: The problem is that some Collada files have texture tags that refer directly to an image and not to a sampler. ColladaLoader is currently unable to load such files because it expects a reference to a sampler.

I figured out a clean way that should solve the issue.

I can help trying it out when ready 馃憤

BTW just to be clear, because I missed this originally, we use the Autodesk FBX SDK export to create the Collada files exported from Clara.io. It has proven to be buggy.

@russdanner Can you please shader the model in this thread?

@russdanner your model is loading fine for me. @Mugen87 here's the file
heart-dae.zip

@looeee Thanks! Yeah, the editor loads the file without errors.

I'm having trouble with this model as well: https://clara.io/view/1a03ac6b-d6b5-4c2d-9f1a-c80068311396#

@LuckXP What do you mean with "trouble"? Can you please specify what's going wrong?

@Mugen87 Oh. Yeah sorry. Just that the model I posted results in the same "Undefined sampler." console warning.

@LuckXP Can you please share the model in this thread? I'll have a look.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

clawconduce picture clawconduce  路  3Comments

jack-jun picture jack-jun  路  3Comments

scrubs picture scrubs  路  3Comments

zsitro picture zsitro  路  3Comments

donmccurdy picture donmccurdy  路  3Comments