-3

So, am trying to make a third person game using cannon.js and three.js but I have encountered this error: Uncaught SyntaxError: missing ) after argument list It is coming from this script:

//create the model
_three.createModel(window.game.models.house, 12, new THREE.MeshLambertMaterial({ color: window.game.static.colors.cyan, shading: THREE.FlatShading });
//loads the model and calls it whatever
var house = _three.createModel(window.game.models.house, 12, new THREE.MeshLambertMaterial({ color: window.game.static.colors.cyan, shading: THREE.FlatShading });
console.log(house.mesh);
//collects the data from the model
_three.createModel(jsonData, scale, materials, isGeometry);
//loads the model
loader.load("js/game/game.models.js", function(geometry, materials) {
    window.game.models = { house: geometry };

    window.gameInstance = window.game.core();

    window.gameInstance.init({
        domContainer: document.querySelector("#game"),
        rendererClearColor: window.game.static.colors.black
    });
});

What this is supposed to do is grab a JSON script exported from blender and import it into my world but it is not loading but it is showing this unspecific error. The line of code which is giving the error is _three.createModel(window.game.models.house, 12, new THREE.MeshLambertMaterial({ color: window.game.static.colors.cyan, shading: THREE.FlatShading }); If there is any possible way to fix this or if I can reply with more helpful support please tell me!

WestLangley
  • 102,557
  • 10
  • 276
  • 276
  • 2
    The error already tells you what the problem is: a `)` is missing. You can fix the error by adding it. – Felix Kling May 14 '16 at 00:38
  • Note that this is a basic JS syntax error that has nothing to do with three.js, cannon.js or webgl. Parentheses need to be "balanced", i.e., for every opening `(` you need a closing `)`. – nnnnnn May 14 '16 at 00:44
  • Possible Duplicate : http://stackoverflow.com/questions/15558482/javascript-syntaxerror-missing-after-argument-list – Umair Shah May 14 '16 at 01:00

1 Answers1

0

PROBLEM : You are missing ) in your statements?

SOLUTION : Always properly write your statements with starting ( and ending )

REPLACE THESE LINES IN YOUR CODE :

//create the model
_three.createModel(window.game.models.house, 12, new THREE.MeshLambertMaterial({ color: window.game.static.colors.cyan, shading: THREE.FlatShading }));
//loads the model and calls it whatever
var house = _three.createModel(window.game.models.house, 12, new THREE.MeshLambertMaterial({ color: window.game.static.colors.cyan, shading: THREE.FlatShading }));

Suggestion : Use JSLint for fixing these errors before posting it here at Stack Over Flow.These are pretty basic errors.

HOW TO USE JSLint : Copy your code and paste it into the text box when you open JsLint and click on JSLint button down below and you will see all errors present in your code.But JSLint gives you alot more than just normal syntax errors so you can workout only with basic errors and if you want your code to be more better you can fix other errors too then..!

Umair Shah
  • 2,305
  • 2
  • 25
  • 50