Three .js SceneExporter gets "Syntax not activated" error

So I am trying to export a three.js scene using SceneExporter, I just do this

var output = new THREE.SceneExporter().parse(scope.renderingEngine.scene);

When doing this I get the error

Uncaught SyntaxError: Unexpected token u

What happens on line 750 of SceneExporter.js (which is the line where the JSON gets parsed; new THREE.SceneExporter().parse(scope.renderingEngine.scene);

)

I don't have anything interesting on stage, just a bunch of geometries. I even tried a scene with no textures in it and still got this error.

Now if I change this line to just return output

, then JSON.stringify(output)

save that file, the JSON file doesn't validate. I am getting the following error:

Parse error on line 1:
"{    \n\t\"metadat
^
Expecting '{', '['

      

And here is line 1-10 of the JSON file

"{
    \n\t\"metadata\": {
        \n\t\t\"formatVersion\": 3.2,
        \n\t\t\"type\"\t\t: \"scene\",
        \n\t\t\"generatedBy\"\t: \"SceneExporter\",
        \n\t\t\"objects\": 153,
        \n\t\t\"geometries\": 144,
        \n\t\t\"materials\": 5,
        \n\t\t\"textures\": 1\n\t
    },
    \n\n\t\"urlBaseType\": \"relativeToScene\",

      

Does anyone else have this problem?

0


source to share


1 answer


The syntax error is the character "Unexpected token: ILLEGAL", probably through the use of "\ n \ t \ t" and other (escape sequences) external strings. I don't know what you are trying to achieve with off-string escape sequences, and I don't even know if you should use special characters in JSON.



Also, I see "\" in some of your lines. You cannot use "\". You can, however, use "\", which is the escape sequence for "\". Using a single "\" inside a line will give you the "Unexpected token: ILLEGAL" error. "\" must always be followed by a character that makes a valid escape sequence.

+1


source







All Articles