## drawing a sphere in javascript using webgl

can someone help me in programming a sphere in javascript using opengl? I have tried many codes like the function sphere but no outputs is obtained

## Enumerating points on the integer lattice, within a sphere, sorted by angle, in O(1) space

Inspired by this StackOverflow question: https://stackoverflow.com/questions/63346135

(it was not clearly presented, and got closed)

Let’s say I wanted to enumerate all the 3D points on the integer lattice, within a sphere, in order of the angle between the vector to the point and the up vector (say z).

Could I do this in O(1) space efficiently?

All I can find is:

``Remembering last point (init at (0,0,0)). (O(1) memory) while true     init best dot product to 0     going through all 3D points (three nested for's with radius range)         if this point has better dot product but least than last point             keep this point as best     if best dot product is still 0, exit      pick best point as current point (this is where the listing occurs)     update last point to best point ``

Not only is this absolutely slow, it also needs the use of integer math for dot product and length so that numerical precision doesn’t mess with symmetrical points and it would also need a tweak to guarantee symmetrical points are listed in a known order.

Is there any good algorithms that would apply here?

## Would it be unbalanced to let a Tempest Cleric replace one of their domain spells for the 4th-level spell Storm Sphere?

I wanted to pick your DM brains about allowing a Cleric of the Tempest domain to swap one of their domain spells.

One of the players in our campaign would like to swap Control Water (PHB, p.227) for Storm Sphere (XGtE, p.166). It seems to be in line with the whole flavour of a Tempest Cleric and they are both 4th-level spells.

Note: Storm Sphere appears in Xanathar’s Guide to Everything, so it had not been published at the time when the Tempest domain was published.

Would it be unbalanced to allow this spell swap for the Tempest clericâ€™s domain spells?

I would really appreciate any answers that draw on own experience of allowing tweaks for a Cleric domain spells.

## Can a ghost enter a Resilient Sphere?

The spell Otiluke’s Resilient Sphere says that nothing can pass through it. The spell Wall of Force says that too, but it also says that the spell extends into the Ethereal Plane, preventing ethereal travel. From this, my understanding is that a ghost could move through the sphere but wouldn’t be able to damage the creature inside by using it’s Etherealness action to move to the Ethereal Plane, then moving to overlap the creature, then using Etherealness to return. Is this correct? Or does something stop the ghost from returning to the Material Plane?

## Prime sphere requirements to use Tass in Mage 20th Anniversary Edition

I’m confused about what level of Prime is required to use Tass in the Mage 20th Anniversary Edition rules.

In the main rulebook the following statements are made:

M20 Rulebook:

• p 332: “To absorb Quintessence energy from the materialized Quintessence of Tass requires Prime 3.”

• p 520: Prime 1 sphere description says: “A beginning study of Prime allows the mage to perceive and channel Quintessence from Nodes, Tass, …”

• p 520: Prime 3 sphere description says: “… the Prime-skilled mage can draw both free and raw Quintessence from Nodes, Junctures (special times) and Tass …”

How do you DO That Rulebook says:

• pp. 43-45: “Any mage with an Avatar Background cab absorb that Background’s worth of Quintessence from a Node or Tass …”

First off – are there ways to use Tass other than absorbing the Quintessence into your pattern? Can you spend Tass to gain Quintessence effects like lowering the difficulty of a roll without absorbing it into your pattern?

And with regard to what levels of Prime are required to do these things, I can see support for any of these positions:

1. You don’t need any Prime at all to absorb Quintessence from Tass into your pattern, as “Any mage with an Avatar Background” can do it (How do you DO That pp. 43-45)
2. You need Prime 1, as the description for that sphere says Prime 1 allows you to channel Quintessence from Tass. (M20 p. 520)
3. You need Prime 3, as that is stated on M20 p. 332 and p. 520 explicitly

I have reviewed other answers at: How does the Prime Sphere affect gaining and storing Quintessence in M20? but it left me more confused than enlightented.

From a gameplay perspective, requiring Prime 3 to use Tass seems to defeat much of the purpose of Tass – as it can’t be readily exchanged between mages as portable Quintessence unless they have Prime 3.

## How to measure on a grid the area of a sphere area spell or effect centered on a creature?

Per the Wild Magic sorcerer’s Wild Magic Surge table (PHB, p. 104)

07-08: You cast fireball as a 3rd-level spell centered on yourself.

There’s other questionable area spells in that list (grease is a 10 foot square, so your square and which three?), but I’ll focus on spheres like fireball (PHB p. 241):

(…) Each creature in a 20-foot-radius sphere centered on the point must (…)

My problem is, the sources I found so far – including the other answers to similar questions here – talk about measuring spheres from grid square intersections, whereas this clearly talks about it being centered on the unlucky Wild Magic sorcerer. Plus, since it’s a wild magic effect, it doesn’t exactly have a caster that can pick a point of origin. Is there an accepted way to measure an effect like this?

## How does the Flaming Sphere spell’s area of effect work?

The description of the flaming sphere in the PHB reads:

Any creature that ends its turn within 5 feet of the sphere must […]

Does this mean flaming sphere affects a sphere with a diameter of 15 feet (5 feet from itself, 10 feet towards either direction)?

Also, does ramming the sphere require placing the sphere at the location of the enemy directly, or will it still do damage as long as the creature is in the affected range of the spell?

## Can flaming sphere cast at 60ft then be moved 30ft next turn to be 90ft away from you?

I was wondering if the 60ft range on flaming sphere is the max range it can ever be from you or only the max range you can cast it at. Then on subsequent turns you can move it even farther away. Same for Moonbeam and other similar spells. I could not find a clear answer googling it, and asking my friends geoups returned a split decision.

While I’m mostly interested in answering this for D&D 5e, I’d also be curious for Pathfinder 2e if for some reason the rules were different.

https://roll20.net/compendium/dnd5e/Flaming%20Sphere#content

## How do i get the Mollweide projection of a sphere?

I have defined three angular functions

``F1[\[Theta]_,\[Phi]_] := (1/2) (1 + Cos[\[Theta]] Cos[\[Theta]]) Cos[2\[Phi]] F2[\[Theta]_,\[Phi]_] := -Cos[\[Theta]] Sin[2\[Phi]] F3[\[Theta]_,\[Phi]_] := F1[\[Theta],\[Phi]]^2 + F2[\[Theta],\[Phi]]^2 ``

So I can “project” `F3[\[Theta], \[Phi]]` on a sphere in the following way

``SphericalPlot3D[1,{\[Theta],0,\[Pi]}, {\[Phi],0,2\[Pi]}, ColorFunction -> Function[{x,y,z, \[Theta],\[Phi],r}, ColorData["Rainbow"][F3[\[Theta],\[Phi]]]], ColorFunctionScaling -> False, Mesh -> True, Boxed -> True,  Axes -> True, AxesLabel -> {x, y, z}, PlotPoints -> 100, PlotLegends -> BarLegend["Rainbow"]] ``

and use the function to properly color the sphere. Is there a way to do the same thing using a Mollweide projection instead of a sphere?

## What happens when Otiluke’s Resilient Sphere is cast on a creature that has momentum going for them?

If a creature casts Otiluke’s resilient sphere on himself while he is walking or running, does the momentum stop when the spell is cast?

I’m thinking about a scenario where a creature is surrounded by a prismatic barrier. It can’t be seen through so to get through it by teleportation misty step is out of the picture. People are split on whether dimension door (having to target the area you are making the door to) is blocked due to the barrier blocking line of effect. The spell ‘teleportation’ is a riskier form of teleportation that is also a higher level spell and is thus more difficult to access. So my thoughts turned to a spell my artificer does have: Otiluke’s Resilient Sphere.

Resilient sphere tells you how it can be moved:

An enclosed creature can use its action to push against the sphere’s walls and thus roll the sphere at up to half the creature’s speed. Similarly, the globe can be picked up and moved by other creatures.

The words of the sphere only include a way for the creature inside to move by expending an action, it would however be fallacious to say this must be an exhaustive list of what ways the sphere can be moved. As it doesn’t say it can’t be moved by other means. These words would indicate that for an creature inside to start moving the sphere it will require its action.

I want to know if there is any way to cast the sphere and move it in the same turn on only your one action (without metamagic). Particularly, what happens if the creature enclosed in the sphere has momentum when the sphere is cast. Can a creature run at the prismatic barrier and cast Otiluke’s Resilient Sphere to get through it? I presume a creature can cast while moving, and if not I know a creature can cast while concentrating on a spell; At the very least a creature should be able to use a ready action to cast the spell and concentrate on it, run at the wall, and activate the spell before he hits the wall.