Renderer stops working when inserting specific code into function! three.js - variables

I would like to start off by mentioning that I am very new to coding, so some things that might seem very simple to someone with intermediate experience will probably not click quite as fast with me.
Okay so with the code I am writing, I am trying to get a three.js cube object to move to the places I click, using tweening. I managed to get this to work, but when I try to create a frame using three.js lines, the code stops working. In detail: when I add
line = new THREE.Line( lineGeometry, new THREE.LineBasicMaterial() );
scene.addObject( line );
to the Init() function. What is cause of this? My guess is it has something to do with global/local variables but even if that were correct I have no idea how to fix it !
This is the jsfiddle for reference

Related

wxGrid - RefreshBlock Undocumented Member Function

In order to refresh a part of the grid, i.e., when font or alignment changes, I was using the following approach:
wxRect rect1=CellToRect(TopLeft);
wxRect rect2=CellToRect(BottomRight);
wxRect r(rect1.GetTopLeft(), rect2.GetBottomRight());
RefreshRect(r);
This was refreshing only a part of the intended block and was not working correctly.
From the suggestions of intellisense I came across RefreshBlock function and it works correctly. I searched the docs and have not found any information on it. I wonder if it is not recommended to use RefreshBlock for some reason? What does RefreshBlock do, does it refresh a block (as the name suggests) or is it equivalent to Refresh?
I am using wxWidgets 3.2 on Win10.
Thanks in advance.
The function RefreshBlock() is indeed the best way to do what you want and it was only undocumented by mistake, i.e. we simply forgot to do it. I've added documentation for it only now, so it will only get included in 3.2.1, but you can still use it in your code, the function itself is available since 3.1.3.
It seems from the source code that, depending on the location of its parameters, RefreshBlock refreshes any of the following:
corner grid
frozen cols grid
frozen rows grid
main grid
Since the area I wanted to refresh was on the main grid the following approach works (the idea is similar to RefreshBlock's approach):
auto GridWnd = CellToGridWindow(TL);
wxRect rect = BlockToDeviceRect(TL, BR, GridWnd);
GetGridWindow()->RefreshRect(rect);
Now everything is refreshed correctly.
Notes:
If only RefreshRect(rect) is called, things will NOT work as expected.
Little experiment showed that BlockToDeviceRect(TL, BR) also works, therefore eliminating the need for auto GridWnd = CellToGridWindow(TL);

GSAP after clear timeline reverse animation not working

I am facing an issue when I clear the timeline using timeline.clear() to move back all the elements to it's original position because of immediateRenderer = true, now issue I am facing is after clear timeline revert is not working.
Please suggest a proper solution that includes immediateRenderer to true with on complete of animation elements should reset to it's original position and revert should work after clear the timeline
I have also search into GSAP forum but not get any proper solution for this issue.
When you clear() a timeline, that literally deletes all of its child animations, so it'd make sense that if you try to revert by doing something like seek(0), it would have no effect (there are no child tweens to re-render at their staring values). It sounds like maybe you just shouldn't call clear() before reverting.
If your goal is to revert the changes that a tween or timeline made, you should be able to simply seek(0) to jump back to the starting time, and if you want to pause it there so that it doesn't continue playing just pause(0) like:
var tl = new TimelineLite();
tl.to(...);
//then later...
tl.pause(0);
Is that what you're looking for?
If not, it'd be super helpful if you could provide a reduced test case in codepen or jsfiddle so that we can see what's going on.
Also, were you saying that you posted in the GreenSock forums but you didn't receive an answer? We're usually very good about answering every question, typically in less than 24 hours. Let me know if there's something we missed.

"No appropriate method" error generated when calling new function using class-defined object

I defined a class called "FilterCriteria" which has a bunch of function .m files (getAMask, getBMask, etc.) associated with it. When I create the FilterCriteria object and call the functions using it, I don't have any problems. However, recently I added another function (which, on a side note, is almost identical to another function that still works), and Matlab returns the error, "No appropriate method, property, or field getHMask for class FilterCriteria."
I've searched online for this problem, but I can't find anything. The file getHMask.m is definitely in the correct folder, so I don't understand why Matlab seems to have such a problem finding it.
Here's getHMask.m's header:
function mask = getHMask(object, quadrant, channel)
Any help would be greatly appreciated. Thanks in advance.
1) A mistake I make sometimes is not saving the file with the correct name. Make sure capital letters are in the right places etc!
2) Another layer of error checking here... You can call methods('object here') (see here) and make sure it lists the method (function) that you are trying to add to it. If it doesn't show up here you should check into the implementation of the method and make sure it's correctly being added to the class you're using for your object.
I had the same problem that's kind of suggested by Ben's bullet #2 and it was driving me crazy. Turns out MatLab wasn't loading the latest version of my class's m-file. I vaguely remembered it gave me a warning earlier about that, because there were old instances of the class in the workspace and to keep from invalidating them it said it wouldn't update the class until I cleared the workspace...
So if that's the problem, restarting MatLab will work, or you can just enter >> clear

GLKBaseEffect prepareToDraw GL ERROR: 0x0501

So ive been doing some iphone development with some OpenglES in it, but i am getting a rather weird error when i call prepareToDraw on my effect. My program in short simulates dice rolling (trying to learn objective-c and opengl). The program works fine for the most part, i can use everything ive programmed my app to do (with its bugs in the physics but ill fix that later). The problem comes in after ive used the part that contains the OpenGL.
The program contains 2 menu's you have to go through in order to reach the screen that is using OpenGL, once you have used the apps OpenGL part and go back to the previous menu, then try go back to the OpenGL part again, i get a print out saying GL ERROR: 0x0501. ive narrowed it down to be caused by the prepareToDraw method from my effect. The other weird part about it, is if i go back, then forward again, the OpenGL works again, and can be repeated again and again for it to be working and breaking every second time you go into the OpenGL part.
I've been searching around for similar problems to mine, but each time its got something to do with loading textures that are not a power-of-two texture, which doesnt help me because im not even using textures yet, just colored vertices.
ive pastebin'd my two code files where the problem should lie
Dice.m: http://pastebin.com/ze1DEEzs
in the draw method you'll see my printouts have narrowed down where the problem lies, which is the prepareToDraw method. (line 308)
RollViewController.m: http://pastebin.com/VycwAh3R
this file is where i setup the effect and the context etc, so i must be doing something wrong in here to cause the prepareToDraw method to mess up every 2nd time i run the OpenGL part of the program. i have a feeling it has something to do with not letting go some kind of resource to do with the context and the effect, but i cant find anything about deleting context and effect (probably because you dont need to but im not sure).
I hope there is someone out there that has run into the same problem and can answer my question and i hope its not just a silly mistake because ive been trying to solve this for a while now :)
thanks
After much pain and suffering i finally found a fix to the problem. Im not exactly sure why this is a problem, but creating the context within the OpenGL part (aka RollViewController.m) is not the way to do it. Instead you should create it once throughout the lifetime of your program and just set your current context for your glkview to be the context you have made. Maybe someone can enlighten me why recreating the context is a bad idea.
In my code i have a profile object that gets passed around between views and menu's so that they can all communicate with the same data, so i just defined a public context within my profile object so that everything can get access to the context instead of creating their own (and breaking).
The error seems general and might be because of different issues. I avoided it(for now) by not using mipmaps. I commented the following code I had and don't have the error anymore.
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_NEAREST);
glGenerateMipmap(GL_TEXTURE_2D)

create a new object

I want to create a new object so as to instantiate and use it several times;
For example, if I want to create an object that has a label and a button inside, how do I? I created a new NSObject but inside it has nothing, then how do I make everything from scratch since there was a viewDidLoad for example (obviously, since it has a view)?
thanks!
Your questions lead me to think that you're really just starting out. There's nothing wrong with that, but rather than trying to summarize several megabytes of documentation in a few paragraphs, I'm just going to point you to the iOS Starting Point. I think that you're just trying to create a container that can hold other UI components? If so, use a UIView for that. However, don't jump in and try to get something specific done without first reading through some of the Getting Started documents -- you'll just end up back here, and we'll just point you back to the docs. You might like the Your First iOS Application guide, as that lets you get your feet wet but explains things along the way.