How to upgrade Chevrotain in VRMLLoader

172 views Asked by At

Trying to load vrml files into a three.js scene using the VRMLLoader bundled with three.

When running the project locally, everything runs fine without issues, loading the project from a built deployment leads to the onLoad function failing due to minification of the source code. This is the error that I'm getting:

Error: Terminal Token name: not found in rule:

Here is the full stack trace:

Error: Terminal Token name: <n> not found in rule: <version>  
See: https://sap.github.io/chevrotain/docs/guide/resolving_grammar_errors.html#TERMINAL_NAME_NOT_FOUND
For Further details.
at chevrotain.module.min.js:2
at P (chevrotain.module.min.js:2)
at chevrotain.module.min.js:2
at Object.h [as forEach] (chevrotain.module.min.js:2)
at N (chevrotain.module.min.js:2)
at chevrotain.module.min.js:2
at Object.e.buildTopProduction (chevrotain.module.min.js:2)
at n.t.RULE (chevrotain.module.min.js:2)
at new n (VRMLLoader.js:3289)
at u (VRMLLoader.js:108)

The Github link the stack trace provides is for the old Github repo of the Chevrotain project (this is the new repo). Some searching around yields the latest version of this page (here) which indicates that the embedded version of Chevrotain in the VRMLLoader is outdated and leads to this troubleshooting page for older versions (here).

This link highlights that there is an issue with versions of Chevrotain <5.0 where minification of the source can lead to errors - none of the docs point to very useful answers because this issue has been circumvented in later versions of Chevrotain.

I'm currently using the VRMLLoader that is packaged with three.js under this file location as shown in this code snippet:

import * as THREE from "three";
import { VRMLLoader } from 'three/examples/jsm/loaders/VRMLLoader.js'

Question 1: How do I upgrade the Chevrotain files included in the examples of the latest version of three.js?

Question 2: Is there a better way to include the VRMLLoader in projects (other than importing them from examples as I've shown above)? (This also applies to other tools such as OrbitControls etc.)

1

There are 1 answers

0
Mugen87 On

I've filed a PR at GitHub in order to upgrade chevrotain to the latest version 9.0.1, see https://github.com/mrdoob/three.js/pull/21694.

With the next release r128 at the end of April this issue should be solved.