Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
NotificationsYou must be signed in to change notification settings

CodingCoffee-01/Glowscript-vPython

Repository files navigation

it is based on Glowscript3.1 (vPython) , modified for using one vPython file ,

Major change is on function readSingleFile(evt) , and button declare

if want to change for your own vpython file , just need to change

$.get('./Demos/AtomicSolid-VPython.py',{},function(content)

change for your own code file name and put it into ./Demos

Then can use Github pages feature to demo your vPython program

這是根據 Glowscript 3.1 修改,

主要是改成單一vPython file , 而且可以用 Github Page 功能 demo 自己的vPython 程式

demo links :https://codingcoffee-01.github.io/Glowscript-vPython/

OBTAINING THE LATEST VERSION OF GLOWSCRIPT OFFLINE

Based on the work ofVesa Lappalainen of Finland, this package makes it possible to write and runGlowScript programs even when disconnected from the internet. To obtain the latest version of this package,go to the following location and click Download, then unzip the package to any convenient place on your computer:

CHOICE OF BROWSER

It is recommended to use the Chrome browser, as it is the only browser that provides detailed information on run-time errors and also makes it possible to use textures and JavaScript libraries. You can use a different browser if these issues are not important to you.

RUNNING PROGRAMS

Inside this folder, double clickGlowScript.html. This will start up your preferred browser.

As a test, enterbox() into the left (edit) pane.

ClickRun to run the program. To rotate, zoom, or pan the scene:

  • Right-button drag orCtrl-drag to rotate the "camera" to view scene
  • To zoom, drag with middle button orAlt/Option depressed, or use scroll wheel
    • On a two-button mouse, middle is left + right
  • Shift-drag to pan left/right and up/down
  • Touch screen: pinch/extend to zoom, swipe or two-finger rotate.

You can drag the vertical gray bar (and/or make the window wider or narrower) to arrange the edit and execution regions the way you want them. Make changes to the program and clickRun again. If you add a print statement a print area will appear at the right.

You can run or restart your program by pressingCtrl-1 orCtrl-2, just as you can at glowscript.org.

SAVING YOUR CHANGES

Click Save to save your program. It will be written to yourDownload folder (browser security rules forbid writing it anywhere else). You will be asked for a name. Suppose you specifytest. If your program is VPython or RapydScript, theDownload folder will have a file namedtest.py, otherwise it will betest.js (JavaScript). If in one session you do multiple saves, yourDownload folder will have multiple copies:test.py,test(1).py, etc.

If you create or modify a program without saving it and clickChoose File (Browse... on Firefox or Edge), you'll see a warning that you might wish to save your work. Similarly, when you attempt to close the browser or the browser tab, if you have modified the current program you'll be warned about saving the file.

DEMO PROGRAMS INCLUDED

ClickChoose File and navigate to theGlowScriptOffline folder to choose from programs in theDemos folder. Those demo programs that use textures will not display correctly when offline unless you start the package in a special waydescribed below in the section "Using Textures or JavaScript Libraries."

DOCUMENTATION INCLUDED

The GlowScript documentation is included in the package and is accessible by clickingHelp.

USING THE TEXT EDITOR

In the text editor, as in the editor at glowscript.org, select one or more lines and pressTAB to indent orShift-TAB to unindent; pressCtrl-/ to toggle commenting of the lines. PressingTAB with the cursor at the end of the line adds spaces to the end of that line. At the moment, find and replace options are not yet available; you can of course copy the program to a local text editor to use find and replace, then copy it back.

USING PROGRAMS FROM glowscript.org OR FROM VPYTHON 7

When you download programs fromglowscript.org, they are in the form of.py files whose first line is a statement about importing Vpython, like programs created with VPython 7. This first line is understood by the offline package, as isGlowScript X.Y VPython orGlowScript X.Y JavaScript.

EXPORTING A PROGRAM

When you clickExport, your program is processed to create code that can be embedded in your own web site, just like using the optionShare or export this program at glowscript.org. This processed code temporarily replaces your own program code. If you clickSave and give the name "test", a file namedtest.html will be written to yourDownload folder. Alternatively, pressCtrl-C to copy the code (all of which is preselected for you), then use a text editor to save this code to a local file that should have the extension.html.

When you are connected to the internet, double clicking this HTML file will start up your default browser and run the program. You can return to editing your original program by clickingRestore. (Notice that there is no need to be able to run the exported html file when disconnected from the internet, because you can run the original program in the offline package.)

POSSIBLE SLOWDOWN

If you make a large number of runs, performance may degrade due to an accumulation of "WebGL contexts". However, there is a simple remedy: reload the web page

IMPORT ISSUES, AND USING JAVASCRIPT

By default, if you don't start a program with a statement of the formGlowScript 2.7 JavaScript orGlowScript 2.7 RapydScript, it is assumed that this is a VPython program. You can also start a program with one of these kinds of Python import statements (or include such an import statement afterGlowScript 2.7 VPython):

  • from vpython import * The default; all VPython elements are available
  • from vpython import canvas, box, sphere, vec This MUST includecanvas
  • import vpython A red box:vpython.box(color=vpython.color.red)
  • import vpython as vp A red box:vp.box(color=vp.color.red)

If you don't include a GlowScript or import statement, this is the same as specifyingfrom vpython import *

USING TEXTURES OR JAVASCRIPT LIBRARIES

If you don't use textures or JavaScript libraries (using theget_library function), the instructions given above are adequate. If you do however use textures or JavaScript libraries, you need to follow these instructions:

For highly technical security reasons (CORS, Cross-Origin Resource Sharing), it is not possible to use textures or JavaScript libraries when offline unless you use the Chrome browser and configure Chrome in a special way.

  • First, exit Chrome. Then,

    • Windows: Double clickWindows_launch_chrome.bat in theGlowScriptOffline folder.
    • Mac: Double clickMac_launch_chrome.command in theGlowScriptOffline folder.
      • You may have to go to System Preferences/Security & Privacy and under the General tab specify that you want to allow it to execute now and in the future. (You may have to open the folder in a terminal and executechmod +x Mac_launch.command). You only need to execute the chmod instruction once, before usingMac_launch_chrome.command for the first time.
    • Linux: Open a terminal in theGlowScriptOffline folder.
      • Executechmod +x Linux_launch_chrome
      • Execute./Linux_launch_chrome
      • You only need to execute thechmod instruction once, before usingLinux_launch_chrome for the first time
  • You will see the warning,You are using an unsupported command-line flag: --disable-web-security. Stability and security will suffer.

  • On Mac or Linux, without exiting Chrome, double clickGlowScript.html.

  • If you quit and restart Chrome, its normal security rules will be restored.

  • It is important to exit this unsafe version of Chrome before using it for regular browsing.

  • Suppose you have an image namedcar.jpg that you want to use as a texture. Create a folder adjacent to theGlowScriptOffLine folder and placecar.jpg in it. Suppose you name the new folderMystuff. To use the texture:texture="../Mystuff/car.jpg".

  • To use a library written in JavaScript, place it in yourMystuff folder. Suppose the library is nameduseful.js. To use it, in your program execute the statementget_library("../Mystuff/useful.js").

    • The reason for putting theMystuff folder outside but next to theGlowScriptOnline folder is that whenever you update to a later version of the online package you don't want to lose yourMystuff files.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors2

  •  
  •  

[8]ページ先頭

©2009-2025 Movatter.jp