mrdoob / three.js

JavaScript 3D Library.
https://threejs.org/
MIT License
102.06k stars 35.34k forks source link

VRMLLoader: fails to load wrl files of crystal models #15281

Closed colorzircon closed 5 years ago

colorzircon commented 5 years ago

I'm a university teacher teaching Crystallography. I have built a lot of crystal models in .wrl format exported from WinXmorph and Krystalshaper, two software of crystal morphology drawing. These files can be opened correctly by many PC software.

Recently, I tried to share these models on web, so that my students could view them through the browser whatever using PC, Phone or Pad. These .wrl files are much simpler than house.wrl, however, cannot be loaded by VRMLLoader.

I will be very appreciated if you can help me to solve the problem. It's very significant for me and my students.

Attachment is several entire files for testing.

Look forward to your reply.

models for testing.zip

donmccurdy commented 5 years ago

As a possible workaround, these files seem to open correctly in Blender and export with the same appearance using https://github.com/KhronosGroup/glTF-Blender-IO. I realize if you have a lot of files that may be too much work. Example:

models for testing.zip screen shot 2018-11-19 at 7 59 27 pm

colorzircon commented 5 years ago

As a possible workaround, these files seem to open correctly in Blender and export with the same appearance using https://github.com/KhronosGroup/glTF-Blender-IO. I realize if you have a lot of files that may be too much work. Example:

models for testing.zip screen shot 2018-11-19 at 7 59 27 pm

Thank you very much for your prompt response. It's really an efficient method. But I don't know if there a way to display .glb files on web, because I try to enable them to be viewed through the browser using PC, Phone or Pad.

donmccurdy commented 5 years ago

You can definitely display the .glb files on web, yes — http://gltf-viewer.donmccurdy.com/ is an example, using THREE.GLTFLoader.

colorzircon commented 5 years ago

You can definitely display the .glb files on web, yes — http://gltf-viewer.donmccurdy.com/ is an example, using THREE.GLTFLoader.

Thank you very much. The problem that has been bothering me for a long time has been solved. image

Is there a way to batch convert .wrl to .glb in Blender?

donmccurdy commented 5 years ago

Yes, but it would require a bit of scripting ... see https://blender.stackexchange.com/questions/34537/how-to-batch-convert-between-file-formats. I haven't done this for VRML before but in theory you can just change a couple lines depending on the format.

colorzircon commented 5 years ago

Thank you very much for your patience. I also look forward to using VRMLloader to display my .wrl file in future.

Mugen87 commented 5 years ago

I've tested one of your VRML files (Cube.wrl) today and found a couple of issue in VRMLLoader:

Solving all these issues is actually quite a lot of work^^

cecilemuller commented 5 years ago

Also, Transform{rotation 1 0 0 0.0 children[ isn't malformed, it's valid VRML because commas between numbers are optional.

Mugen87 commented 5 years ago

The commas are not the problem but the children[ after the four quaternion values (the loader thinks its a quaternion format with five values^^). But as you said, this is still valid VRML. The loader is just not able to parse it...

Mugen87 commented 5 years ago

That said, even if the loader would be fixed, it's still a much better solution to load the assets as glTF like @donmccurdy suggested.

andreasplesch commented 5 years ago

@colorzircon : You could also try https://github.com/create3000/x_ite (understands VRML fully) or https://github.com/x3dom/x3dom (understands X3D) . But this should be discussed elsewhere.

colorzircon commented 5 years ago

Thank you all very much, my warm friends.

Up to now, there are three ways to display .wrl files.

  1. using THREE.GLTFLoader as @donmccurdy suggested.

  2. using X3DOM.js. .wrl file needs to be convert to html. Instantreality supplies an online encoding converter and also local PC software converter.

  3. X_ITE can directly load .wrl files without prior plugin installation.

Mugen87 commented 5 years ago

Please use option one :innocent: . glTF is faster to parse and produces smaller files compared to VRML or X3D. It is also the recommended 3D format of three.js:

https://threejs.org/docs/#manual/en/introduction/Loading-3D-models

No one should directly load formats like VRML, OBJ or Collada in 3D apps anymore.

andreasplesch commented 5 years ago

Oh, it looks like you have been already aware of alternatives. Apologies for the noise.

colorzircon commented 5 years ago

Oh, it looks like you have been already aware of alternatives. Apologies for the noise.

Never mind! Thank you very much for your suggestion.