1

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.)

  • I guess it's best if the Chevrotain version of the `three.js` repository is upgraded in order to solve your issue. – Mugen87 Apr 21 '21 at 11:08
  • I agree, it should also be solvable with preventing minification of the Chevrotain source files in the build process if upgrading is too difficult. I'll report back once I get it working. It should be noted that the [changelog of Chevrotain](https://chevrotain.io/docs/changes/CHANGELOG.html) lists breaking changes for several of it's latest releases. – Michael Reed Apr 21 '21 at 11:24
  • Is there a better recommended way of including these tools in three.js projects than from the examples folders? Will unused tools in the examples folders still be bundled up for deployment? – Michael Reed Apr 21 '21 at 11:25
  • The components rely on certain version of thiry-party code so upgrading it by yourself is problematic. It's best to use the version from the repository. BTW: I'm working on a PR to upgrade chevrotain to the latest version. – Mugen87 Apr 21 '21 at 11:31
  • Cool, thanks for that! I just tested the deployment with minification disabled for the whole project and it did remove the error. So this issue should be resolved with integrating any version of Chevrotain >= v6. – Michael Reed Apr 21 '21 at 11:33

1 Answers1

0

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.

Mugen87
  • 28,829
  • 4
  • 27
  • 50