Jump to content

Light problem when I load a file


Brunex92
 Share

Recommended Posts

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 loading
http://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 :]

 

Link to comment
Share on other sites

Oh, didn't know about that
In any case, here it is
http://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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...