Uncaught TypeError: AXES is not a constructor

1

I have my Ejes.js code:

const mesh = require('./mesh')    
const geometry = require('./geometry')

function Ejes (dimension) {
  this.dimension = dimension 
  this.meshesDeEjes = []
}

Ejes.prototype.armarEjes = function () {
  var verticesx = [[0, 0, 0], [this.dimension, 0, 0]]
  var verticesy = [[0, 0, 0], [0, this.dimension, 0]]
  var verticesz = [[0, 0, 0], [0, 0, this.dimension]]  
  var faces = [[0, 0, 0]]
  var colorejex = [1.0, 0.0, 0.0, 1.0]
  var colorejey = [0.0, 1.0, 0.0, 1.0]
  var colorejez = [0.0, 0.0, 1.0, 1.0]
  var ejex = Object.create(geometry)
  var ejexmesh = Object.create(mesh)
  ejex.Geometry(verticesx, faces)
  ejexmesh.Mesh(ejex, colorejex)
  this.meshesDeEjes.push(ejexmesh)

  var ejey = Object.create(geometry)
  var ejeymesh = Object.create(mesh)    
  ejey.Geometry(verticesy, faces)    
  ejeymesh.Mesh(ejey, colorejey)    
  this.meshesDeEjes.push(ejeymesh)


  var ejez = Object.create(geometry)    
  var ejezmesh = Object.create(mesh)    
  ejez.Geometry(verticesz, faces)    
  ejezmesh.Mesh(ejez, colorejez)    
  this.meshesDeEjes.push(ejezmesh)

  return this.meshesDeEjes    
}

module.export = Ejes

And I have another file called index.js in which I invoke Axes:

const SCENE = require('./scene')
var EJES = require('./ejes')    
var scene = new SCENE()    
scene.clearColor = [0.2, 0.2, 0.2, 1.0]

var ejesobject = new EJES(10)    
var arregloejes = ejesobject.armarEjes()

for (var i = 0; i < arregloejes.length; i++) {
  scene.addMesh(arregloejes[i])   
}

And I have this error and I do not know how to solve it:

  

Uncaught TypeError: AXES is not a constructor       at Object.167 (index.js: 10)       at webpack_require (bootstrap 694943face10988c98c2: 54)       at Object.166 (tp03.js: 7)       at webpack_require (bootstrap 694943face10988c98c2: 54)       at webpackJsonpCallback (bootstrap 694943face10988c98c2: 25)       at tp03.js: 1

    
asked by Fabio Cataldo 28.03.2018 в 15:39
source

1 answer

1

As I remember the correct term is exports and not export . Therefore, the last part of your module should be:

// ...

module.exports = Ejes;

This is the link to the documentation:

answered by 28.03.2018 / 16:37
source