Forum

Problem with pick_object

21 September 2016 19:21
Hi,
I'm trying to get an object by clicking on it, the function is:
function setup_click_on_object() {
	_canvas_elem.addEventListener("mousedown", function(e){click_on_object(e)}, false);
	
	function click_on_object(e) {
		console.log("Clicked");
		// if (_disable_interaction)
        // return;

		if (e.preventDefault)
			e.preventDefault();
		
		var canvas_xy = m_cont.client_to_canvas_coords(e.clientX, e.clientY, _vec2_tmp);
		
		var x = canvas_xy[0];
		var y = canvas_xy[1];		
		
		var obj = m_scs.pick_object(x, y);
		
		if (obj)
			console.log(m_scs.get_object_name(obj));
		}
}

And the console returns:
TypeError: Argument 2 is not valid for any of the 2-argument overloads of WebGLRenderingContext.uniform3fv.

Have you experimented something like that?
In the debug I found out the error is in the renderer module, renderer.js:1502:17, and it has something to do with UI_color_id, this is the renderer.js bit:
        case "u_color_id":
            fun = function(gl, loc, obj_render, batch) {
                gl.uniform3fv(loc, obj_render.color_id);
            }

Any help is welcome
26 September 2016 11:50
Hi, this can be a bug. Can you provide us with a demo to reproduce it?
26 September 2016 20:19
You have the file in this post
The blue cube is the object that is selectable, I think the ship cockpit should be selectable too.
Thank you
27 September 2016 18:51
This was a bug and the fix will be available in the upcoming release on this week. The bug was related to objects, which simultaneously have "Do Not Render" & "Enable Outlining" options enabled (ScoutCollision in your case). The error is displayed when you click on such object.

So, for now you can deselect the "Enable Outlining" option on the ScoutCollision object as a workaround. Thanks for the report!
28 September 2016 11:28
Ah, ok, I'll try it, thank you
28 September 2016 11:55
Just a warning: if you'll use a new 16.09 SDK don't forget about this important change: https://www.blend4web.com/en/forums/topic/2459/?page=1#post-12197
28 September 2016 13:21
Ok, I take a note
 
Please register or log in to leave a reply.