Three.js updating cube scale with slider variable - webgl

I've created an html page with a jQueryUI slider in one div and a THREE.CubeGeometry in another (see http://codesigntools.com/sample7). The idea is to scale the cube using a global variable (slider1val) which is controlled by the slider. I've looked here and here but no avail. You can see from the linked code that I'm trying to make changes to the cube within the 'animate' function. Is that right?
I'm pretty new to js and to Three.js but I've used processing quite a bit so maybe I'm going about this the wrong way. Is there an example of someting similar I could look at, or could somebody walk me through the process of accessing and manipulating the cube's size with a global variable?
Thanks!

Answering my own question in the hopes that it will help somebody else:
Both comments were correct:
I had to define the cube globally and then act on its scale from
inside my updateGeom() function
Cory Gross had a good
example (now a dead link).
For in-depth example, please see on github here

Related

How would I go about creating a highlighted grid radius in roblox studio?

I'm sure you're asking what "highlighted grid radius means" so first let me explain what I am doing. I am creating a Roblox Studio project that involves a grid of grass block tiles as a map. When you click a tile with a selecting building then it makes that building. However, I would like a build radius as you build. For example you cant go, say, 30 grass blocks away from the closest building. I'm setting the default limit as 2 blocks for each building.
In case you are still confused here is a visual aid:
Example of what I am trying to accomplish
The highlighted blocks represent tiles that you can build on while the unhighlighted, obviously, represent blocks that you cannot build on. And yes, I know, in this example the build radius is one block unlike my previous statement. I am just eager to figure this out so I didn't make it any larger.
Now normally I wouldn't even use stack overflow because I would just try to figure it out myself, but I really am stumped. Normally I would have sort of an idea of where to start or how I should approach this and execute the idea. But I just don't know what to do, please help.
EDIT: (specifying issue further) I am unsure of how to actually find which grass blocks are within the radius. I should be able to give them all a SelectionBox I just need a way of finding the ones within the radius.

Model is not on top of marker ARjs

I'm just starting out in ARjs myself. I found an issue that I'm confused on how to solve. My gltf model won't show unless it's on scale 5x and it only showed partially as in the left top corner on the actual model. My assumption is from the position, but I'm not sure how to approach this?
I already saw the https://github.com/jeromeetienne/AR.js/issues/299 thread solution, but it didn't work.
You didn't share your code so it's really hard to know what is the problem there. From what you are describing I would try scaling your object down and not up. If you only see small parts of it on a 5x scale, I guess you were inside the object this entire time. Try scaling it down to ~0.1 and see if it works. Also, make sure your model is positioned to 0,0,0 (or just don't specify the position at all ass this is the default). Another thing I think you should try is our platform echoAR. You can upload your models and easily have an ARjs experience. Just follow the docs.

Creating text / number objects in ARKit

I want to create some objects (boxes, cylinders, pyramids, doesnt really matter) which display text / a number on the side / on all of it's sides. Short of making individual materials with the numbers displayed on them by hand, is there a simple way to achieve this?
I am using Swift 4 in XCode.
First thing, please try not to be discouraged. Thank you for reaching out to the ARKit community on stack :-)
We are here to help each other.
(I do feel your pain…and why I am trying to help)
Here is an interesting stack page that has helped me with placing items on the sides of objects(like boxes cylinders, pyramids).
I hope it can help you or others.
SCNBox different colour or texture on each face
Rickster pointed out some other possibilities.
We all learn by sharing what we know.
Smartdog
Depends on what you mean by "by hand". If you want the text displayed on the surface of the geometry, like a texture map, then texture-mapping it is the way to go. If you draw your text into a UIImage, you can set that as the material contents, which is a bit more dynamic than, say, creating a bunch of PNGs that each have a different number on them. Just make sure to choose an image size/resolution that looks good at the size your objects are displayed at.
For anyone lost in the internet trying to find an answer to this it's stupidly simple. Use SCNText and set it as a node. I just wasted 7 hours of my life trying to make number .dae models position themselves next to each other because there is no mention of this feature anywhere.
I hope I saved you as much pain as I just endured discovering this.

Is it possible to change texture hue programatically in Spritekit project?

I am interested in to how change hue of the texture in efficient way ? I am experimenting to create space dust which will change it's color every few seconds with nice, smooth transition from one color to another.
I find this possible in few ways:
Using core image like in this example. But I don't know how will this work in combination with Spritekit...
Using particle emitters to create space dust and change color of particles over time using particleColorSequnece property.
And easy one that came up on my mind , while playing with Photoshop, which is using two same, but differently colored images, one over another, and changing the opacity of the topmost one.
This gives me the effect I want, and actually looks fabulous, but is there any better way ? Maybe using SKTexture? In this particular case, I just need to change from one color to another , but what would be an efficient way to do this when multiple changes are required one after another ? This way, my third example requires additional images...
Here is the link which most closely describe what I am trying to accomplish. Just look how space dust changes its color overtime(from dark blue to purple and later to green or orange). I suppose this is done programatically... I would like to ask moderators to remove a link if it is not suitable to post it here. Thanks!
It is kind of a hard questions to answer and is rather subjective, however...
I personally would do the Emitter Node approach, because it seems like it is built for the type of use you are looking for and could have some cool effects trailing behind.
With that being said you specifically asked about changing the hue and colorBlendFactor might be what you are really looking for. I don't have a great link for it, but this might get you pointed in the right direction. You can see how they are blending colors to get the desired result.
Your solution with changing the alpha of two separate colors doesn't sound like a bad approach either.
Hopefully that helps and good luck =)

Is there a way to curve text/labels in Cocos2d?

Here is an example of what I would like to achieve.
Is there a way to "transform" a label in Cocos2d and obtain a curved text? I do not find any property in the CCLabelBMFont class that seem to allow this.
Any suggestion wellcome.
Rason for asking: I would prefer not to use pre-generated (with Photoshop or GIMP) text images. Hence I am looking for an answer to this problem and not to an alternative method.
One of the moderators of the Cocos2D forum has replied to me in their forum and it doesn't seem possible. Here is the link to the discussion on the forum, but as far as I can tell there is no solution (In my opinion it would require having implemented a draw call in the labels that blends the pixtures according to the new image matrix resulting from bending the original label image and as far as I can understand CCLabelBMFont does not seem to support this - and I am not sure that is easily possible to do so as the class does not derive from CCSprite but it may be in some other way that I do not know at the moment).

Resources