Brunex92 Posted June 20, 2016 Share Posted June 20, 2016 Hey everyone, First of all, sorry for my bad english, not my first language. So, I'm doing this project, where I load a file, with some coordinates and colors, then I draw those on the canvas, just like this image:http://i.imgur.com/sAmhiip.png And as you can see, I'm using the DAT.GUI to control the axis and the planes. But here is my problem, when I load it, it goes really well, but when I unmark all 3 axis boxes, this happens:http://i.imgur.com/ck9kJRW.png All the objects have no light or color, sometimes it happens that it has color, but won't have light. This only happens after I load the file, if I unmark all 3 axis boxes on the beggining, nothing happens:http://i.imgur.com/dl4E7a1.png Also, if I unmark ALL boxes, including the plane ones, this happens:http://i.imgur.com/tdZzFYO.png Only one kind of cylinder with a sphere in the middle of it will show, and when i change camera position or rotation, those cylinder and sphere will change color, varying between the 3 axis colors and white. When the file isn't loaded, everything works the way I want, also if I unmark all 3 plane boxes, it works perfectly I really don't know what could be causing this problem, this is my text file I'm loadinghttp://pastebin.com/7h52G5Qn NOTE: I start reading the file after the [ARESTAS] keyword (line 133 in this example), and basically is like this: X1 Y1 Z1 X2 Y2 Z2 R G B This is how I'm reading the file: var matrix = []; var keyWord = '[ARESTAS]'; //Função para ler o arquivo function readSingleFile(evt) { var f = evt.target.files[0]; if (f) { matrix = []; var r = new FileReader(); var contents = 'empty'; r.onload = function(e) { contents = e.target.result; var pastKey = false; contents.split('\n').forEach(function(line, i) { if (pastKey) { var vals = line.trim().split(' '); if (vals.length > 2) { matrix.push(vals); } } if (line.trim() === keyWord) { pastKey = true; } }) update(); } r.readAsText(f); } else { alert("Failed"); } } document.getElementById('fileinput').addEventListener('change', readSingleFile, false); window.addEventListener('DOMContentLoaded', function() { update(); }); function update() { //BABYLON usual settings } If all these informations are not sufficient, let me know, I have no problem sharing the other parts of the script, but I really think the problem happens when I read the file. Thanks :] Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted June 20, 2016 Share Posted June 20, 2016 Hello! can you reproduce the issue in the Playground? It is far easier for us to help you then Quote Link to comment Share on other sites More sharing options...
Brunex92 Posted June 20, 2016 Author Share Posted June 20, 2016 @Deltakosh Is there any way to import other APIs in it or read and load files? Because I need the dat.gui API so I can control it. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted June 20, 2016 Share Posted June 20, 2016 dat is already referenced for you by the PG NasimiAsl 1 Quote Link to comment Share on other sites More sharing options...
Brunex92 Posted June 20, 2016 Author Share Posted June 20, 2016 Oh, didn't know about that In any case, here it ishttp://www.babylonjs-playground.com/#1WJUVD#1 But i don't know if it is possible to read and load a file on playground, so i did without it. And works exactly how it should, which means that the problem is when I load the file, I just don't know why/where. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted June 20, 2016 Share Posted June 20, 2016 You can save your file to a dropbox for isntance and load it from the PG Quote Link to comment Share on other sites More sharing options...
Brunex92 Posted June 20, 2016 Author Share Posted June 20, 2016 But how do I link the file in dropbox with the PG? I know almost nothing about loading files in javascript sorry Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted June 21, 2016 Share Posted June 21, 2016 http://www.babylonjs-playground.com/#23UCS8#5 Quote Link to comment Share on other sites More sharing options...
Brunex92 Posted June 21, 2016 Author Share Posted June 21, 2016 This applies to text files? I mean, in my case, it's a .txt file, not an .obj I read all the coordinates and put them into a matrix, then I draw them Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted June 21, 2016 Share Posted June 21, 2016 use xhr to load it then:) NasimiAsl 1 Quote Link to comment Share on other sites More sharing options...
Brunex92 Posted June 21, 2016 Author Share Posted June 21, 2016 In order to save all this work, since I still have to manage how do I use xhr properly, is it possible that this test can occur in my repository on github?brunex92.github.io The file that I've been using is attached. It's really simple to use it, just click on the Menu button, and choose the file. If it's not possible, then I need some time to manage how xhr works File: TestCluster.s3d Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted June 21, 2016 Share Posted June 21, 2016 Unfortunately everything is minified on your repo. I have no simple way to debug Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.