Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: Cannot read property 'target' of undefined #3

Open
Manidavid opened this issue Jul 25, 2017 · 2 comments
Open

TypeError: Cannot read property 'target' of undefined #3

Manidavid opened this issue Jul 25, 2017 · 2 comments

Comments

@Manidavid
Copy link
Contributor

Manidavid commented Jul 25, 2017

I have installed three-stl-loader node module in my project, trying to process the STL file from amazon s3 url with the below code.

var url = 'https://s3.amazonaws.com/minifactory-stl/WALLY_1plate.stl';
var THREE = require('three')
var STLLoader = require('three-stl-loader')(THREE)
   
var loader = new THREE.STLLoader()
   
loader.load(url, function (geometry) {
   console.log(geometry);
   var material = new THREE.MeshNormalMaterial()
   var mesh = new THREE.Mesh(geometry, material)
   scene.add(mesh)
})

Getting the below error.

Error: Cannot find module 'three'
at Function.Module._resolveFilename (module.js:469:15)
at Function.Module._load (module.js:417:25)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at exports.stlmodel_create (/Users/workspace/web-api/controllers/stlmodelController.js:17:15)

Please provide some example code to solve this.

@data-doge
Copy link
Contributor

you're likely getting Error: Cannot find module 'three' because you haven't installed three. if you haven't already, please run npm i --save three

@Manidavid
Copy link
Contributor Author

Manidavid commented Jul 25, 2017

Thanks @data-doge . I haven't installed the three node module, after i run npm i --save three it got installed but when i run the above code it raised the below error,

ReferenceError: XMLHttpRequest is not defined
at FileLoader.load (\web-api\node_modules\three\build\three.js:29860:23)
at load (\web-api\node_modules\three-stl-loader\index.js:50:13)
at exports.stlmodel_create (\web-api\controllers\stlmodelController.js:10:10)

i found that XMLHttpRequest node moude also missed so i run npm install xmlhttprequest --save to install and required this module with the below code.

global.XMLHttpRequest = require("xmlhttprequest").XMLHttpRequest;
var url = 'https://s3.amazonaws.com/minifactory-stl/WALLY_1plate.stl';
var THREE = require('three')
var STLLoader = require('three-stl-loader')(THREE)

var loader = new STLLoader()

loader.load(url, function (geometry) {
  console.log(geometry);
  var material = new THREE.MeshNormalMaterial()
  var mesh = new THREE.Mesh(geometry, material)
  scene.add(mesh)
})

It couldn't make the geometry object but got error saying TypeError: Cannot read property 'target' of undefined , which i could not able to find any solution.

C:\Users\Documents\GitHub\3d-web-api\node_modules\three\build\three.js:2986
5
var response = event.target.response;
^

TypeError: Cannot read property 'target' of undefined
at . (\web-api\node_modules\thre
e\build\three.js:29865:26)
at dispatchEvent ((\web-api\node_modules\xml
httprequest\lib\XMLHttpRequest.js:595:29)
at setState (\web-api\node_modules\xmlhttpr
equest\lib\XMLHttpRequest.js:614:14)
at IncomingMessage. (\web-api\no
de_modules\xmlhttprequest\lib\XMLHttpRequest.js:447:13)
at emitNone (events.js:91:20)
at IncomingMessage.emit (events.js:185:7)
at endReadableNT (_stream_readable.js:974:12)
at _combinedTickCallback (internal/process/next_tick.js:80:11)
at process._tickCallback (internal/process/next_tick.js:104:9)

please note that am trying to access the STL file from the Amazon s3 bucket URL('https://s3.amazonaws.com/minifactory-stl/WALLY_1plate.stl').

Please help me with this issue.

@Manidavid Manidavid changed the title Cannot find module 'three' TypeError: Cannot read property 'target' of undefined Sep 6, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants