Outer Glow around 2D object using three.js - 2d

I have a screen full of tiled/stacked triangular pieces of 2D "paper" using three.js. The objects are added at random positions/intervals and are positioned very close to each other on the z-axis so they don't stack too high.
I have the lighting exactly how I want it for the bump-map and shape shadows... but the shapes themselves have no cast shadow. This is because the objects are too close together to get the desired effect, and I don't want to mess up the current light source. Cast shadows would also be only in one direction (opposite the light source)... whereas I am attempting to get a shadow (actually an outer-glow) around the entire piece of paper.
I am therefore trying to create an outer-glow or at least find a reasonable solution to fake soft drop shadows around the entire shape. I have attached an image illustrating what I'm trying to accomplish... in essence it's like a CSS box-shadow effect.
box-shadow: 0px 0px 18px rgba(50, 50, 50, 0.75);
Any guidance would be greatly appreciated, thanks!
tl;dr: Trying to create a outer-glow around 2D shapes in three.js

Related

How understand interpolation about box-shadow described on MDN?

Happy new year!
When I was reading the description of CSS property box-shadow, I can not figure out what Interpolation section on this page means.
I googled for this but still confused.
Is it about CSS animation?
Could you please help? Thanks.
Please provide some code examples if possible.
Let me have a stab at digesting this block of nonesense
Each shadow in the list (treating none as a 0-length list) is
interpolated via the color (as color) component, and x, y, blur, and
(when appropriate) spread (as length) components.
Each shadow in the list is interpolated (various meanings but generally: mixed, blended) using the color, x, y, blur and spread values.
For each shadow, if both input shadows are or are not inset, then the
interpolated shadow must match the input shadows in that regard. If
any pair of input shadows has one inset and the other not inset, the
entire shadow list is uninterpolable.
We can only interpolate (blend, mix whatever) the same type of shadow, be it inset or not, we cannot blend an inset shadow with a non inset shadow
If the lists of shadows have different lengths, then the shorter list
is padded at the end with shadows whose color is transparent, all
lengths are 0, and whose inset (or not) matches the longer list.
I'm not sure how you would end up with a list of various lengths but from what I can garner this is saying that if we somehow end up with a list of different lengths, the browser will compensate for this by adding in transparent shadows so that it has something to interpolate (blend, mix etc) with
TL;DR
It's just explaining the steps that the browser goes through to interpolate multiple shadows and isn't related to animations from what I can see.
Don't worry about it, let the browser do it's thing!

SVG uneven stroke-width

The fiddle below shows an SVG map with CSS hover animations.
https://jsfiddle.net/persianturtle/akkjcmo1/
svg .state:hover , .state.active {
cursor: pointer;
stroke-width: 4;
stroke-alignment: inner;
stroke: #000;
z-index: 100;
}
It doesn't seem that the stroke-alignment: inner; property is being applied. It seems that different states on the map have different strokes depending on which state the border is 'owned' by. Is there a way to have a unified stroke width for all hovered states?
To see the problem clearly, hover over California and then Utah. California has a nice unified stroke-width. Utah does not.
Take a look at this:
I made the stroke width 15 just to show that it's a matter of what element gets printed first. in SVG, you kind of can't set a z-index to the elements because their priority is set by the order in which they appear in the code. You'd need some JavaScript (I think) to re-order the elements. A good starting point is this question: SVG re-ordering z-index (Raphael optional).
Also, as pointed out in the comments, stroke-alignment is still a working draft and might simply not be working.
So, I ran into this with a polygon, exactly the stroke behavior you described and stroke-alignment: inner; not being acknowledged.
So, because the stroke-alignment is being ignored, the part of the stroke on the very edge of the artboard get clipped.
I have a greatly simplified version of what you're doing and I'm calculating my points dynamically, but the work around was to set my polygon/path a couple of pixels inside, so for example point 0,0 becomes 2,2.
Then all the points and their outside/center aligned strokes fit inside the artboard and don't get clipped.

How to invert a css clip-path or animate hard-stops in SVG radial gradients

It seems that generally a css clip-path is used to hide beginning at the edges of an element. I can use something like this:
clip-path:circle(70% at center);
and get something like this:
Is there a way I can invert that? I want my result to be something like this:
I want to clip the center of the image, not the edges. It's an SVG, so I tried something like this pen, animating a radial gradient: http://codepen.io/ethanclevenger91/pen/myMYwQ
But that didn't work like expected. There's the animated one and then one with what I assume the final step of the animation cycle should look like, but it doesn't. Any light on either of these would be appreciated.
You can use a still use a clipPath if you use it in its url form i.e. as svg markup. Draw the path outer rectangle clockwise and the inner ellipse (using two or more elliptical arcs) anticlockwise, drawing everything as a single path together with clip-rule="evenodd"
Alternatively you could use a <mask>. This is a simpler, but slower solution. Draw a white ellipse within the mask area and that part of the mask will be opaque.
So here's what ended up happening:
Since the background I was trying to match was a solid color, I gave the circles a stroke double their radius (since stroke is applied centered on the edge of the object) and then applied a clip-path the size of the object. Then I animated the stroke to 0. Will update with a link to the application when it's live.

Creating alert icon with shadow in CSS

i am trying to create the following image using css.... so far i've got this after googling a bit http://jsfiddle.net/w9Zgc/ and i want to make the following shape..
is there any way this can be done... any help would be appreciated.. oh and i would like the shadow to be like the one here... http://jsfiddle.net/w9Zgc/
So I managed to create an icon that renders more or less the same in all current browsers. I had to use an extra useless span, unfortunately.
http://codepen.io/myajouri/full/nJDzl
The triangle is made of two parts:
the upper (triangular) part is a transformed (skewed and rotated) square with rounded corners.
the bottom of the triangle is the bottom part of a rectangle with rounded corners.
Both parts are cut and joint at certain places to form the triangular shape with rounded corners and shadows.

Cocos2d grid design for drawing lines

Hello guys
I have a small problem while designing a iphone game with a grid using cocos2d.
The game needs a 10x10 grid in the middle of the screen (it is not covering the entire screen).
A line is drawn at runtime where the user touches two points in the grid.
Question: would tilemap be ideal for this problem? As i need to verify the co-ordinates do belong to the grid or not when the user touches a point would tilemap be useful?
Question: Is there any better way of solving this in cocos2d. Please help me out.
Thanks
I wouldn't recommend using tilemap for this. Personally I'd do it all with math.
Lets for arguments sake say your grid squares are 10px by 10px.
You now instantly know the positions of the rects for each square.
top right square would be (90, 0, 10, 10), this obviously doesn't include the positioning of your grid, but you can easily add that onto this by adding.. (90+gridPos.x, 0+gridPos.y, 10, 10).
Then you just check your touches intersect the rects of the grids.
Drawing a line is fairly simple, i imagine you'd draw it from the center of the 2 grid points.
So if the line started in the top right grid square it's initial point would start at (90+gridPos.x, 0+gridPos.y, 5, 5), or (90+gridPos.x, 0+gridPos.y, gridSquareHeight/2, gridSquareWidth/2)
Using cocos2d it's pretty easy to also make every square a touchable sprite, that can react when touched however you like, sending a message back to a delegate or even just doing a visual effect.
There are tonnes of possibilities for solving this problem.

Resources