Skip to content

Commit

Permalink
Merge pull request #7 from trinketapp/v3.2.1
Browse files Browse the repository at this point in the history
V3.2.1
  • Loading branch information
brianpmarks authored Jan 30, 2023
2 parents a0cfd87 + b58e748 commit d803dbd
Show file tree
Hide file tree
Showing 28 changed files with 171 additions and 121 deletions.
2 changes: 1 addition & 1 deletion ForInstalledPython/glow.min.js

Large diffs are not rendered by default.

4 changes: 0 additions & 4 deletions GlowScriptOffline/VPythonDocs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -154,13 +154,9 @@
<div>
<p class="Normal">VPython documentation was produced by Ruth Chabay,
David Scherer, and Bruce Sherwood.</p>
<p class="Normal"><a href="http://students.studybay.com/?p=336" target="_blank"> Armenian translation</a> by Gajk Melikyan</p>
<p class="Normal"><a href="http://www.teileshop.de/blog/2016/08/28/vpython" target="_blank">Estonian translation</a> by Sonja Kulmala</p>
<p class="Normal"><a href="http://www.auto-doc.fr/edu/2017/01/09/kayttamalla-vpython-luoda-3d-animaatioita/" target="_blank">Finnish translation</a> by Fijavan Brenk </p>
<p class="Normal"><a href="https://pngflare.com/ru-vpython" target="_blank">Russian translation</a> by Leonid Popov</p>
<p class="Normal"><a href="https://paintingvalley.com/uz-vpython" target="_blank">Uzbek translation</a> by Ruslan Tarasov</p>
<p class="Normal"><a href="https://www.clothingric.com/community/vpython-help" target="_blank">Urdu translation</a> by Sarah David</p>
<p class="Normal"><a href="http://www.opensourceinitiative.net/edu/VPythonDocs/" target="_blank">Ukrainian translation</a> by Sandi Wolfe</p>
<p class="Normal"><a href="vpython_hun.pdf" target="_blank">Hungarian translation</a> by Dimitar Todorov</p>
<p class="Normal">&nbsp;</p>
</div>
Expand Down
4 changes: 2 additions & 2 deletions GlowScriptOffline/VPythonDocs/technical.html
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,11 @@ <h1 class="Heading-1"><font color="#0000A0">Technical Issues</font></h1>
gl_FragColor = vec4 (color, 1.0);</p>
<p class="Normal">It may be that C2, C3, and C4 are all empty, but there is no obvious inexpensive way to get the information needed to tell the CPU to avoid scheduling those extra renders, because readPixels is very expensive. If there are more than four transparent layers, this algorithm will not treat them properly. However, note that the fifth and later peels will contribute little to the final pixel color, being partially occluded by four transparent layers in front.</p>
<p class="Normal">Before starting the many renders the objects are sorted into opaque and transparent lists, and if there are no transparent objects a simple C0 render is all that is needed. Moreover, this simple render can exploit antialiasing, whereas the storage into textures for depth peeling unfortunately turns off antialiasing.</p>
<p class="Normal">It is remarkable that doing 10 separate renders runs adequately fast for real-time rendering of moderately complicated scenes. For example, displaying a 10x10x10 grid of rotating transparent boxes can run at around 20 frames per second on ordinary computers, depending on the graphics card.</p>
<p class="Normal">It is remarkable that doing 10 separate renders runs adequately fast for real-time rendering of moderately complicated scenes. For example, displaying 1000 rotating transparent boxes may take only twice the render time needed to display 1000 rotating opaque boxes, depending on the graphics card.&nbsp; &nbsp;&nbsp;</p>
<p class="Normal">In OpenGL it is possible to create several textures in one render, but WegGL permits attaching just one texture to a framebuffer object, hence a large number of separate renders are needed.</p>
<p class="Normal">To see this algorithm in action, run this <a href="https://www.glowscript.org/#/user/GlowScriptDemos/folder/Examples/program/Transparency" target="_blank">Transparency</a> example program. </p>
<p class="Normal">Note that the code for this transparency demo is remarkably short. Web VPython is aimed at making it feasible for nonexpert programmers to exploit WebGL to generate navigable real-time 3D animations.</p>
<p class="Normal">At <a href="https://www.glowscript.org/docs/GlowScriptDocs/technical.html">https://www.glowscript.org/docs/GlowScriptDocs/technical.html</a><a href="https://github.com/BruceSherwood/glowscript" target="_blank"></a>, the key files dealing with depth peeling are lib/glow/WebGLRender.js and the shader programs in the shaders folder.</p>
<p class="Normal">At <a href="https://github.com/vpython/glowscript" target="_blank">github.com/vpython/glowscript</a> the key files dealing with depth peeling are lib/glow/WebGLRender.js and the shader programs in the shaders folder.</p>
<p class="Normal">It is possible to implement &quot;Fast Approximate Anti-Aliasing&quot; (FXAA) to get around the problem that the use of framebuffer objects turns off anti-aliasing:<br />
<a href="http://www.codinghorror.com/blog/2011/12/fast-approximate-anti-aliasing-fxaa.html" target="_blank">http://www.codinghorror.com/blog/2011/12/fast-approximate-anti-aliasing-fxaa.html</a></p>
<p class="Normal">This has not been tried in VPython.</p>
Expand Down

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion GlowScriptOffline/glowscript_libraries/compiler.3.2.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion GlowScriptOffline/glowscript_libraries/glow.3.2.min.js

Large diffs are not rendered by default.

Binary file removed GlowScriptOffline3.2.zip
Binary file not shown.
145 changes: 61 additions & 84 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,77 +1,71 @@
GlowScript
==========
# GlowScript

GlowScript makes it easy to write programs in JavaScript or [VPython](http://vpython.org) (which uses the RapydScript compiler) that generate navigable real-time 3D animations, using the WebGL 3D graphics library available in modern browsers (with modern GPU-based graphics cards). For example, the following complete program creates a 3D canvas in the browser, displays a white 3D cube, creates default lighting, places the camera so that the cube fills the scene, and enables mouse controls to rotate and zoom the camera:

```javascript
box()
box()
```

That's it. That's the whole program (except for the GlowScript version header line that is supplied automatically). The key point is that lots of well-designed defaults are built into the GlowScript library. You can of course specify the canvas size, the color and other attributes of the objects, the direction of the camera view, etc.

For a history of the development of VPython, see [A time line for VPython development](https://brucesherwood.net/?p=136). Here is a technical overview of GlowScript VPython and VPython 7: [VPython Architecture](https://vpython.org/contents/VPythonArchitecture.pdf).

Documentation
-------------
## Documentation

At [glowscript.org](http://glowscript.org) click Help for full documentation. There is an extensive set of example programs available from the first page of glowscript.org. Programs can be created and stored at glowscript.org, but it is also possible to export a program to place on your own web page, or to use the GlowScript library without storing the program at glowscript.org. For programs stored at glowscript.org, you can share a link with someone and they can run your program simply by clicking on the link. Here is an example:

https://www.glowscript.org/#/user/GlowScriptDemos/folder/Examples/program/Bounce-VPython
https://www.glowscript.org/#/user/GlowScriptDemos/folder/Examples/program/Bounce-VPython

GlowScript was inspired by [VPython](http://vpython.org). The project was begun in 2011 by David Scherer and Bruce Sherwood. Originally programs had to be written in JavaScript, but in November 2014 it became possible to use Python, thanks to the [RapydScript](https://github.com/atsepkov/RapydScript) Python-to-JavaScript compiler created by Alex Tsepkov. GlowScript is now using a later version, [RapydScript-ng](https://github.com/kovidgoyal/rapydscript-ng) developed by Kovid Goyal.

For information related to building the GlowScript application, see MakingNewVersion.txt in the [docs](docs) folder. Also in the [docs](docs) folder is an overview of the GlowScript architecture, [GlowScriptOverview.md](docs/GlowScriptOverview.md).

Sister Project
--------------
## Sister Project

VPython 7 lets you run VPython programs in a Jupyter notebook or from program launchers such as IDLE or Spyder: see [vpython.org](https://vpython.org). Its development was initiated by John Coady and further developed by him, Ruth Chabay, Matt Craig, and Bruce Sherwood. The syntax is the same as GlowScript VPython, and it uses the GlowScript 3D graphics library, but VPython 7 runs with an installed standard Python, which provides access to the large number of Python modules. GlowScript VPython does not require installing any software but provides access only to libraries written in JavaScript, not to standard Python modules (it does however provide portions of Python's "random" module).
Run Locally
------------------

## Run Locally

At glowscript.org, your programs are stored in the cloud and are accessible from anywhere. However, there are times when you might need to write and run programs even when disconnected from the internet.

In this repository, click GlowScriptOffline3.2.zip and download the zip file.

Unzip the GlowScriptOffline package to any convenient place on your computer.

Inside the [GlowScriptOffline](GlowScriptOffline) folder, read the README file to learn how to use the package.
Run a Local Server (Py3 version)
------------------
Inside the [GlowScriptOffline](GlowScriptOffline) folder, read the README file to learn how to use the package.

## Run a Local Server

There are two sets of instructions given here for two possible
approaches.
approaches.

1. The first, "All Docker", is quite simple, and involves only
minimal new software (just [Docker](https://www.docker.com/products/docker-desktop)).
If you're using macOS or Linux you can run the
local webserver and datastore all in Docker. You don't need to install
anything else. However there is a rather annoying
bug in Windows that prevents the webserver from automatically restarting when
source files change. For this reason, if they wish to have this feature,
windows users must run a python process concurrently that tracks file
changes during development. Having said that, if you just want to try a
local webserver, and you don't care about having to restart the server
manually every time you change the source code, you can skip running
the extra python process. This is all described below.

2. The second, "Only Datastore in Docker", requires that users also install a
recent (e.g., 3.7+) version of python (and pip) such as that provided by
[anaconda](https://docs.anaconda.com/anaconda/install/)
(or [miniconda](https://docs.conda.io/en/latest/miniconda.html)), as well as
[Docker](https://www.docker.com/products/docker-desktop). This is all also described below.
minimal new software (just [Docker](https://www.docker.com/products/docker-desktop)).
If you're using macOS or Linux you can run the
local webserver and datastore all in Docker. You don't need to install
anything else. However there is a rather annoying
bug in Windows that prevents the webserver from automatically restarting when
source files change. If you just want to try a local webserver, and you don't
care about having to restart the server manually every time you change the
source code, you can skip running the extra python process.

2. The second, "Only Datastore in Docker", requires that users install
Python-3.8 such as that provided by
[anaconda](https://docs.anaconda.com/anaconda/install/)
(or [miniconda](https://docs.conda.io/en/latest/miniconda.html)), as well as
[Docker](https://www.docker.com/products/docker-desktop).

### Local Server Approach (1) All Docker

First install [Docker](https://www.docker.com/products/docker-desktop. Once
installed, start the Docker process.
First install [Docker](https://www.docker.com/products/docker-desktop). Once
installed, start the Docker desktop application.

Next check out or download the py38-app-engine branch of the glowscript repository (currently the `py38-app-engine` branch).
(How you do this depends on your familiarity with git. The simplest is to download a .zip file of the
`py38-app-engine` branch of the repository [here](https://github.com/vpython/glowscript/archive/py38-app-engine.zip))Then
open a console in the `glowscript` directory of the repository and run the webserver and datastore in docker:
Next check out or download the glowscript repository. Then, in a terminal window, change directory to the glowscript repository and type:

docker-compose up

this will take a substantial amount of time the first time, since it has to download all
the docker images. Once it's running, browse to: [http://localhost:8080](http://localhost:8080)
this will take a substantial amount of time the first time, since it has to download all
the docker images. Once it's running, browse to: [http://localhost:8080](http://localhost:8080)
to view the website. That's it! This will run in a window and show you how the
webserver is handling requests. If you'd rather run this in the background
you can use:
Expand All @@ -82,65 +76,49 @@ When you're finished, shut down the system with:

docker-compose down

* P.S. If you're using windows an you want to use the "auto-restart" feature when code files change
you'll need to run the filesystem monitoring tool
[docker-windows-volume-watcher](https://pypi.org/project/docker-windows-volume-watcher/)

pip install docker-windows-volume-watcher

* And when you're running the glowscript server locally, in a *separate* window, execute:

docker-volume-watcher glowscript_flask_1

* and it will take care of the rest.

### Local Server Approach (2) Only Datastore In Docker

To run a local webserver with only the datastore in Docker, but the
webserver itself running natively you need a recent version of Python3 and pip installed. The easiest method
is probably to install [anaconda](https://docs.anaconda.com/anaconda/install/) (or [miniconda](https://docs.conda.io/en/latest/miniconda.html), if you don't want the GUI package manager and extra applications). Once you have that you need to check out
or download the py38-app-engine branch of the glowscript repository (currently the `py38-app-engine` branch).
(How you do this depends on your familiarity with git. The simplest is to download a .zip file of the
`py38-app-engine` branch of the repository [here](https://github.com/vpython/glowscript/archive/py38-app-engine.zip))
First "cd" to the `glowscript` directory (the root directory of the repository)
and create a virtual environment for glowscript like so:
To run a local webserver with only the datastore in Docker, but the
webserver itself running natively you need Python-3.8.3. The easiest method
is probably to install [anaconda](https://docs.anaconda.com/anaconda/install/) (or [miniconda](https://docs.conda.io/en/latest/miniconda.html), if you don't want the GUI package manager and extra applications). With Anaconda or miniconda you can use the `conda` command to do this, for example:

cd /path/to/glowscript
python -m venv venv
conda create -n py383 python=3.8.3
conda activate py383

This will build a virtual environment for running locally. To activiate the virtual environment:
Your terminal prompt should now have a `(py383)` indicating that you have
activated the python-3.8.3 virtual environment. Once you have that you need to check out the glowscript repository. (How you do this depends on your familiarity with git. The simplest is to download a .zip file of the repository [here](https://github.com/vpython/glowscript/archive/refs/heads/master.zip))
Next change directory to the glowscript repository:

mac: source venv/bin/activate
windows (power shell): venv\Scripts\Activate.ps1
windows (cmd.exe shell): venv\Scripts\activate.bat
cd /path/to/glowscript

Your terminal prompt should now have a `(venv)` indicating that you have
activated the glowscript virtual environment. Before you can run glowscript the
Before you can run glowscript the
first time, you'll need to install dependencies into the virtual environment.
This can be done with pip:

pip install -r requirements.txt

In order to run the local datastore emulator it's easiest to use
[Docker](https://www.docker.com/products/docker-desktop). Download
a version of Docker that works with your OS. To test that you've
If you encounter any problems, follow the suggestions provided by the error messages.

In order to run the local datastore emulator it's easiest to use
[Docker](https://www.docker.com/products/docker-desktop). Download
a version of Docker that works with your OS. To test that you've
got docker installed OK, in the glowscript directory type:

docker-compose -f docker-datastore.yml up

this will take a substantial amount of time the first time, since it has to download all
this will take a substantial amount of time the first time, since it has to download all
the docker images. You'll see a lot of log messages, but among them you should see:

datastore_1 | [datastore] Dev App Server is now running.

In this case you're good! If not, check the error messages and
see if there are any useful clues. Good luck.
see if there are any useful clues. Good luck.

If the datastore is running, hit ctrl-c, and then type:

docker-compose -f docker-datastore.yml up -d

This will run the datastore in the background.
This will run the datastore in the background.

With the datastore running, you can run the webserver by typing:

Expand All @@ -154,25 +132,24 @@ When you're finished hit ctrl-c and then type:

To stop the background datastore emulator.

Then next time you're ready to develop, you can simply activate the environment again (make sure you see the "(venv)" in the shell prompt) and type:
Then next time you're ready to develop, you can simply activate the environment again (make sure you see the "(py383)" in the shell prompt) and type:

docker-compose -f docker-datastore.yml up -d

flask run

And you'll be up and running!

For Developers
--------------
## For Developers

In this repository's [docs](docs/) folder is a file [GlowScriptOverview.md](docs/GlowScriptOverview.md) that describes the architecture of GlowScript in detail. For many of the current issues, the relevant part of the document is the section on Execution (run-time). To test changes it is necessary to run a local server, as is describe in the previous heading. When you want to run using recent changes, you need to choose a version 0.1 greater than the current version number, and append "dev". For example, if the current version is 2.9, the first line of a test program would be GlowScript 3.0dev VPython.

License
-------
## License

The license is found at [LICENSE.txt](https://github.com/BruceSherwood/glowscript/blob/master/LICENSE.txt).

Early version
------------------------------------------------------------------------------
In December 2014 the original GlowScript repository was corrupted in such a way that it could not be reconstituted, but a backup that contains the history of commits is here:
## Early version

https://bitbucket.org/davidscherer/glowscript_backup/overview
In December 2014 the original GlowScript repository was corrupted in such a way that it could not be reconstituted, but a backup that contains the history of commits is here:

https://bitbucket.org/davidscherer/glowscript_backup/overview
3 changes: 3 additions & 0 deletions build_original.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
from __future__ import print_function, division

# Note: After installing nodejs, on Windows you
# must copy node.exe into the build-tools folder.

# This is the original Python 2.7 build file, used in building GlowScript
# according to the scheme described in docs/MakingNewVersion.txt.
# A more sophisticated build program is build_cli.py contributed by Iblis Lin.
Expand Down
Loading

0 comments on commit d803dbd

Please sign in to comment.