mrdoob / three.js

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

VRMLLexer: Improve support for `Script`, `PROTO` and sensor nodes. #28959

Open ANUBIS9000 opened 1 month ago

ANUBIS9000 commented 1 month ago

Description

I am sure my wrl file is correct and it can be open with other viewer, but when i use vrmlloader , it reports

VRMLLoader.js:71 Error: THREE.VRMLLexer: Lexing errors detected. at VRMLLexer.lex (VRMLLoader.js:3272:1) at generateVRMLTree (VRMLLoader.js:99:1) at VRMLLoader.parse (VRMLLoader.js:3244:1) at Object.eval [as onLoad] (VRMLLoader.js:61:1) at eval (three.module.js:44206:1)

if i load a compressed wrl file , it cant be resolved , will become some error encode string, threejs event cant read the version info correctly . if load a wrl file without compress , that will lead to that error above. what should i do to load wrl file correctly, i know wrl file is not very common in nowadays but i really need it , thank you

Reproduction steps

1.build a vue3 project and install newest three.js 2.make a demo to load a wrl file simply , i used different files to test, each of that files can be open in other software good such as vrmlpad and rapidauthor . 3.the file cant be resolved , it leads to an error of lexing

Code

const loadVRML = () => {
  const loader = new VRMLLoader()
  loader.load(`/life.wrl`, model => {
    model.scale.set(30, 30, 30)
    scene.value.add(model)
  })
}

Live example

Screenshots

No response

Version

latest

Device

Desktop

Browser

Chrome

OS

Windows

Mugen87 commented 1 month ago

Please share one of the problematic VRML files in this issue.

ANUBIS9000 commented 1 month ago

this zip contains two files one is original file the other is republish with vrmlpad , if you can solve this problem would you please give me a sample to load it , thank you very much wrl.zip

Mugen87 commented 1 month ago

Unfortunately, this file is quite complex and holds some less common syntax like embedded JavaScript code, PROTO definitions and sensors. Most of this syntax can't be parsed by VRMLLoader yet.

Even if the parsing is possible, you should be aware that the interactivity of the asset can't be retained. Meaning you will end up with a static asset which is maybe not what you want.

ANUBIS9000 commented 1 month ago

Unfortunately, this file is quite complex and holds some less common syntax like embedded JavaScript code, PROTO definitions and sensors. Most of this syntax can't be parsed by VRMLLoader yet.

Even if the parsing is possible, you should be aware that the interactivity of the asset can't be retained. Meaning you will end up with a static asset which is maybe not what you want.

Oh ...... I got the situation , vrml is not common today but in some unique field they use it in a complex way , is there still some chance to make it supported . or maybe some other ways such as convert vrml to some modern formats , what would you recommend about it ? i have a lot of that files with complex content , if i use some tools to convert ,maybe i will also face this kind of problem , i tried blender but also failed . i still very appreciate that you made a vrmlloader which other frame even dont have one. Thank you for answer me whatever , at least i dont need to keep confusing with this error .

ANUBIS9000 commented 1 month ago

Unfortunately, this file is quite complex and holds some less common syntax like embedded JavaScript code, PROTO definitions and sensors. Most of this syntax can't be parsed by VRMLLoader yet. Even if the parsing is possible, you should be aware that the interactivity of the asset can't be retained. Meaning you will end up with a static asset which is maybe not what you want.

Oh ...... I got the situation , vrml is not common today but in some unique field they use it in a complex way , is there still some chance to make it supported . or maybe some other ways such as convert vrml to some modern formats , what would you recommend about it ? i have a lot of that files with complex content , if i use some tools to convert ,maybe i will also face this kind of problem , i tried blender but also failed . i still very appreciate that you made a vrmlloader which other frame even dont have one. Thank you for answer me whatever , at least i dont need to keep confusing with this error .

Unfortunately, this file is quite complex and holds some less common syntax like embedded JavaScript code, PROTO definitions and sensors. Most of this syntax can't be parsed by VRMLLoader yet. Even if the parsing is possible, you should be aware that the interactivity of the asset can't be retained. Meaning you will end up with a static asset which is maybe not what you want.

Oh ...... I got the situation , vrml is not common today but in some unique field they use it in a complex way , is there still some chance to make it supported . or maybe some other ways such as convert vrml to some modern formats , what would you recommend about it ? i have a lot of that files with complex content , if i use some tools to convert ,maybe i will also face this kind of problem , i tried blender but also failed . i still very appreciate that you made a vrmlloader which other frame even dont have one. Thank you for answer me whatever , at least i dont need to keep confusing with this error .

i mean: thank you for answer me anyway , at least i dont need to keep confusing myself . excuse me , i need to improve my grammar.

ANUBIS9000 commented 1 month ago

i noticed the title change to "VRMLLexer: Improve support for Script, PROTO and sensor nodes. " so i reopen this issue, i'll be very grateful if you can improve this loader. and i think maybe it can help some people face the same issue like me. thank you