├── .gitignore
├── CONTRIBUTING.md
├── LICENSE
├── NOTICE
├── README.md
├── docs
├── SAMPLES.md
└── TODO.md
├── poly-client
├── .eslintrc.js
├── .gitignore
├── .vscode
│ └── launch.json
├── app.mabu
├── app.package
├── manifest.xml
├── package.json
├── rollup.config.js
└── src
│ ├── GooglePolyApi.js
│ ├── GooglePolyApiKey.js
│ ├── app.js
│ ├── main.js
│ └── math.js
├── sample-async-await
├── .eslintrc.js
├── .gitignore
├── .vscode
│ └── launch.json
├── app.mabu
├── app.package
├── bin
│ └── index.js
├── manifest.xml
├── package.json
├── rollup.config.js
└── src
│ ├── App.js
│ └── main.js
├── sample-audio
├── .eslintrc.js
├── .gitignore
├── .vscode
│ └── launch.json
├── README.md
├── app.mabu
├── app.package
├── bin
│ └── index.js
├── manifest.xml
├── package.json
├── rollup.config.js
└── src
│ ├── App.js
│ ├── button.js
│ └── main.js
├── sample-book-of-shaders
├── .eslintrc.js
├── .gitignore
├── .npmrc
├── .vscode
│ └── launch.json
├── Makefile
├── app.mabu
├── app.package
├── manifest.xml
├── package.json
├── res
│ ├── README.md
│ ├── color.glsl
│ └── red.glsl
├── rollup.config.js
└── src
│ ├── app.js
│ ├── main.js
│ └── thebookofshaders.js
├── sample-components-prefab
├── .babelrc
├── .eslintrc.js
├── .gitignore
├── .vscode
│ └── launch.json
├── README.md
├── app.mabu
├── app.package
├── manifest.xml
├── package.json
├── rollup.config.js
└── src
│ ├── app.js
│ ├── components
│ ├── index.js
│ └── text-slider.js
│ ├── global-scope.js
│ └── main.js
├── sample-components-prop-visualizer
├── .babelrc
├── .eslintrc.js
├── .gitignore
├── README.md
├── app.mabu
├── app.package
├── jsconfig.json
├── manifest.xml
├── package.json
├── rollup.config.js
└── src
│ ├── app.js
│ ├── controllers
│ ├── Boolean.js
│ ├── Quat.js
│ ├── String.js
│ ├── Vec3.js
│ └── index.js
│ ├── global-scope.js
│ ├── main.js
│ └── propList.js
├── sample-components-router
├── .babelrc
├── .npmignore
├── .prettierrc
├── .vscode
│ └── settings.json
├── README.md
├── app.mabu
├── app.package
├── jsconfig.json
├── lr_resource_locator
├── manifest.xml
├── package.json
├── rollup.config.js
└── src
│ ├── app.js
│ ├── constants
│ ├── parameter.js
│ ├── paths.js
│ └── routes.js
│ ├── containers
│ ├── Home
│ │ └── index.js
│ ├── Nested
│ │ ├── deepNest.js
│ │ └── index.js
│ ├── Parameterized
│ │ └── index.js
│ ├── Primary
│ │ └── index.js
│ ├── Query
│ │ └── index.js
│ └── index.js
│ ├── global-scope.js
│ ├── main.js
│ └── utils
│ └── history.js
├── sample-components-tictactoe
├── .babelrc
├── .eslintrc.js
├── .gitignore
├── .npmignore
├── README.md
├── app.mabu
├── app.package
├── lr_resource_locator
├── manifest.xml
├── package.json
├── rollup.config.js
├── src
│ ├── app.js
│ ├── components
│ │ ├── board.js
│ │ ├── calculate-winner.js
│ │ ├── game-info.js
│ │ ├── game.js
│ │ ├── index.js
│ │ ├── player-chooser.js
│ │ └── square.js
│ ├── global-scope.js
│ └── main.js
└── tsconfig.json
├── sample-components
├── .babelrc
├── .eslintrc.js
├── .gitignore
├── .vscode
│ └── launch.json
├── README.md
├── app.mabu
├── app.package
├── manifest.xml
├── package.json
├── rollup.config.js
└── src
│ ├── app.js
│ ├── global-scope.js
│ └── main.js
├── sample-exclusive
├── .eslintrc.js
├── .gitignore
├── .vscode
│ └── launch.json
├── app.mabu
├── app.package
├── manifest.xml
├── package.json
├── rollup.config.js
└── src
│ ├── app.js
│ └── main.js
├── sample-external-package
├── .eslintrc.js
├── .gitignore
├── .vscode
│ └── launch.json
├── README.md
├── app.mabu
├── app.package
├── bin
│ └── index.js
├── manifest.xml
├── package.json
├── rollup.config.js
└── src
│ ├── App.js
│ ├── main.js
│ ├── text_lodash.js
│ └── text_underscore.js
├── sample-eyetracking
├── .eslintrc.js
├── .gitignore
├── app.mabu
├── app.package
├── manifest.xml
├── package.json
├── res
│ ├── Cube.fbx
│ ├── blink.mp3
│ ├── capsule.fbx
│ ├── capsule.mtl
│ ├── capsule.obj
│ ├── checker.png
│ ├── cube.mtl
│ ├── cube.obj
│ ├── fixation_violation.mp3
│ ├── icon
│ │ ├── InsidePortal
│ │ │ ├── gradient.png
│ │ │ ├── portal.mtl
│ │ │ └── portal.obj
│ │ └── OutsidePortal
│ │ │ ├── Leaper.fbx
│ │ │ ├── Leaper.kmat
│ │ │ └── Leaper.png
│ ├── left_blink.mp3
│ ├── plane.fbx
│ ├── plane.mtl
│ ├── plane.obj
│ ├── readme.txt
│ ├── right_blink.mp3
│ ├── sphere.fbx
│ ├── sphere.mtl
│ └── sphere.obj
├── rollup.config.js
└── src
│ ├── EyeFixation.js
│ ├── EyeOrientation.js
│ ├── SceneManager.js
│ ├── app.js
│ ├── helpers.js
│ └── main.js
├── sample-fetch-image
├── .eslintrc.js
├── .npmignore
├── .vscode
│ └── launch.json
├── README.md
├── app.mabu
├── app.package
├── bin
│ └── index.js
├── manifest.xml
├── package.json
├── rollup.config.js
└── src
│ ├── App.js
│ ├── button.js
│ ├── main.js
│ └── text.js
├── sample-fetch-local-file
├── .eslintrc.js
├── .gitignore
├── .vscode
│ └── launch.json
├── README.md
├── app.mabu
├── app.package
├── bin
│ └── index.js
├── manifest.xml
├── package.json
├── res
│ └── products.json
├── rollup.config.js
└── src
│ ├── App.js
│ ├── button.js
│ ├── main.js
│ └── text.js
├── sample-fetch-remote-file
├── .eslintrc.js
├── .gitignore
├── .vscode
│ └── launch.json
├── README.md
├── app.mabu
├── app.package
├── bin
│ └── index.js
├── manifest.xml
├── package.json
├── rollup.config.js
└── src
│ ├── App.js
│ ├── button.js
│ ├── main.js
│ └── text.js
├── sample-gestures
├── .eslintrc.js
├── .gitignore
├── app.mabu
├── app.package
├── manifest.xml
├── package.json
├── res
│ ├── Gesture_C.png
│ ├── Gesture_Finger.png
│ ├── Gesture_Fist.png
│ ├── Gesture_L.png
│ ├── Gesture_Ok.png
│ ├── Gesture_OpenHand.png
│ ├── Gesture_Pinch.png
│ ├── Gesture_Thumb.png
│ ├── Objects.xml
│ ├── Resources.xml
│ └── Sphere_P.FBX
├── rollup.config.js
└── src
│ ├── app.js
│ └── main.js
├── sample-immersive-app
├── .eslintrc.js
├── .gitignore
├── .vscode
│ └── launch.json
├── README.md
├── app.mabu
├── app.package
├── bin
│ └── index.js
├── manifest.xml
├── package.json
├── rollup.config.js
└── src
│ ├── App.js
│ └── main.js
├── sample-interval-no-await
├── .eslintrc.js
├── .gitignore
├── .vscode
│ └── launch.json
├── README.md
├── app.mabu
├── app.package
├── bin
│ └── index.js
├── manifest.xml
├── package.json
├── rollup.config.js
└── src
│ ├── App.js
│ └── main.js
├── sample-interval
├── .eslintrc.js
├── .gitignore
├── .vscode
│ └── launch.json
├── README.md
├── app.mabu
├── app.package
├── bin
│ └── index.js
├── manifest.xml
├── package.json
├── rollup.config.js
└── src
│ ├── App.js
│ └── main.js
├── sample-landscape-app
├── .eslintrc.js
├── .gitignore
├── .vscode
│ └── launch.json
├── README.md
├── app.mabu
├── app.package
├── bin
│ └── index.js
├── manifest.xml
├── package.json
├── rollup.config.js
└── src
│ ├── App.js
│ └── main.js
├── sample-model-animated
├── .eslintrc.js
├── .gitignore
├── .vscode
│ └── launch.json
├── app.mabu
├── app.package
├── bin
│ └── index.js
├── manifest.xml
├── package.json
├── resources
│ └── turkey
│ │ ├── turkey.kmat
│ │ ├── turkey4.fbx
│ │ ├── turkey_Normal.png
│ │ ├── turkey_Roughness.png
│ │ └── turkey_baseColor.png
├── rollup.config.js
└── src
│ ├── dynamic-fbx-scene.js
│ ├── main.js
│ └── scene.js
├── sample-model
├── .eslintrc.js
├── .gitignore
├── .vscode
│ └── launch.json
├── README.md
├── app.mabu
├── app.package
├── bin
│ └── index.js
├── manifest.xml
├── package.json
├── res
│ └── BoxTextured.glb
├── rollup.config.js
└── src
│ ├── App.js
│ └── main.js
├── sample-prism
├── .eslintrc.js
├── .gitignore
├── .vscode
│ └── launch.json
├── README.md
├── app.mabu
├── app.package
├── bin
│ └── index.js
├── manifest.xml
├── package.json
├── res
│ └── WaterBottle.glb
├── rollup.config.js
└── src
│ ├── App.js
│ └── main.js
├── sample-privilege
├── .eslintrc.js
├── .gitignore
├── .vscode
│ └── launch.json
├── app.mabu
├── app.package
├── bin
│ └── index.js
├── manifest.xml
├── package.json
├── rollup.config.js
└── src
│ ├── App.js
│ ├── button.js
│ └── main.js
├── sample-promise
├── .eslintrc.js
├── .gitignore
├── .vscode
│ └── launch.json
├── app.mabu
├── app.package
├── bin
│ └── index.js
├── manifest.xml
├── package.json
├── rollup.config.js
└── src
│ ├── App.js
│ └── main.js
├── sample-resource
├── .eslintrc.js
├── .gitignore
├── .vscode
│ └── launch.json
├── README.md
├── app.mabu
├── app.package
├── bin
│ └── index.js
├── manifest.xml
├── package.json
├── res
│ ├── pic_1.png
│ ├── pic_2.png
│ ├── pic_3.png
│ ├── pic_4.png
│ └── pic_5.png
├── rollup.config.js
└── src
│ ├── App.js
│ ├── button.js
│ ├── main.js
│ └── page.js
├── sample-threejs
├── .eslintrc.js
├── .gitignore
├── .vscode
│ └── launch.json
├── app.mabu
├── app.package
├── manifest.xml
├── package.json
├── rollup.config.js
└── src
│ ├── app.js
│ ├── main.js
│ └── perspective.js
├── sample-timeout
├── .eslintrc.js
├── .gitignore
├── .vscode
│ └── launch.json
├── app.mabu
├── app.package
├── bin
│ └── index.js
├── manifest.xml
├── package.json
├── rollup.config.js
└── src
│ ├── App.js
│ └── main.js
├── sample-ui-button
├── .eslintrc.js
├── .gitignore
├── .vscode
│ └── launch.json
├── app.mabu
├── app.package
├── bin
│ └── index.js
├── manifest.xml
├── package.json
├── rollup.config.js
└── src
│ ├── App.js
│ ├── button.js
│ ├── main.js
│ └── text.js
├── sample-ui-image
├── .eslintrc.js
├── .gitignore
├── .vscode
│ └── launch.json
├── README.md
├── app.mabu
├── app.package
├── bin
│ └── index.js
├── manifest.xml
├── package.json
├── res
│ └── cat.png
├── rollup.config.js
└── src
│ ├── App.js
│ └── main.js
├── sample-ui-pageview
├── .eslintrc.js
├── .gitignore
├── .vscode
│ └── launch.json
├── README.md
├── app.mabu
├── app.package
├── bin
│ └── index.js
├── manifest.xml
├── package.json
├── res
│ ├── pic_1.png
│ ├── pic_2.png
│ └── pic_3.png
├── rollup.config.js
└── src
│ ├── App.js
│ ├── button.js
│ ├── main.js
│ └── page.js
├── sample-video
├── .eslintrc.js
├── .gitignore
├── .vscode
│ └── launch.json
├── README.md
├── app.mabu
├── app.package
├── bin
│ └── index.js
├── manifest.xml
├── package.json
├── res
│ ├── PUT_SOME_VIDEO_FILE_HERE
│ └── PumpkinCandleH264.mp4
├── rollup.config.js
└── src
│ ├── App.js
│ └── main.js
├── sample-webgl-texture
├── .eslintrc.js
├── .gitignore
├── .vscode
│ └── launch.json
├── app.mabu
├── app.package
├── manifest.xml
├── package.json
├── res
│ └── cubetexture.png
├── rollup.config.js
└── src
│ ├── app.js
│ ├── common.js
│ ├── main.js
│ ├── mat4.js
│ ├── webgl-demo.js
│ └── webgl-polyfill.js
├── sample-webview
├── .eslintrc.js
├── .gitignore
├── app.mabu
├── app.package
├── manifest.xml
├── package.json
├── res
│ └── .placeholder
├── rollup.config.js
├── src
│ ├── WebViewClient.js
│ ├── app.js
│ └── main.js
└── tsconfig.json
├── sample-xeogl-gltf
├── .eslintrc.js
├── .gitignore
├── .vscode
│ └── launch.json
├── app.mabu
├── app.package
├── manifest.xml
├── package.json
├── photos
│ ├── ML_20190507_20.30.25.jpg
│ └── ML_20190507_20.31.00.jpg
├── res
│ ├── BoomBox
│ │ ├── BoomBox.bin
│ │ ├── BoomBox.gltf
│ │ ├── BoomBox_baseColor.png
│ │ ├── BoomBox_emissive.png
│ │ ├── BoomBox_normal.png
│ │ ├── BoomBox_occlusionRoughnessMetallic.png
│ │ └── README.md
│ └── Uffizi_Gallery
│ │ ├── Uffizi_Gallery_Radiance_NX.png
│ │ ├── Uffizi_Gallery_Radiance_NY.png
│ │ ├── Uffizi_Gallery_Radiance_NZ.png
│ │ ├── Uffizi_Gallery_Radiance_PX.png
│ │ ├── Uffizi_Gallery_Radiance_PY.png
│ │ └── Uffizi_Gallery_Radiance_PZ.png
├── rollup.config.js
└── src
│ ├── app.js
│ └── main.js
└── sample-xeogl
├── .eslintrc.js
├── .gitignore
├── .vscode
└── launch.json
├── app.mabu
├── app.package
├── manifest.xml
├── package.json
├── res
├── goldRoughness.jpg
└── uvGrid2.jpg
├── rollup.config.js
└── src
├── app.js
└── main.js
/.gitignore:
--------------------------------------------------------------------------------
1 | # MagicScript binary
2 | digest.sha512.signed
3 |
4 | # MagicScript bundle output
5 | bin
6 |
7 | # ML SDK build files
8 | .out
9 |
10 | # OS X
11 | .DS_Store
12 |
13 | # Node
14 | node_modules
15 |
16 | # NPM
17 | package-lock.json
18 |
19 | # yarn
20 | yarn-error.log
21 | yarn.lock
22 |
--------------------------------------------------------------------------------
/docs/SAMPLES.md:
--------------------------------------------------------------------------------
1 | # Samples included
2 |
3 | 1. [Audio](../sample-audio/README.md)
4 | 2. [External Package](../sample-external-package/README.md)
5 | 3. [Fetch Local File](../sample-fetch-local-file/README.md)
6 | 4. [Fetch Remote File](../sample-fetch-remote-file/README.md)
7 | 5. [Immersive App](../sample-immersive-app/README.md)
8 | 6. [Interval without Await](../sample-interval-no-await/README.md)
9 | 7. [Interval with Await](../sample-interval/README.md)
10 | 8. [Landscape App](../sample-landscape-app/README.md)
11 | 9. [Animated Model](../sample-model-animated/README.md)
12 | 10. [Model](../sample-model/README.md)
13 | 11. [Prism](../sample-prism/README.md)
14 | 12. [Promise](../sample-promise/README.md)
15 | 13. [Timeout](../sample-timeout/README.md)
16 | 14. [UiButton](../sample-ui-button/README.md)
17 | 15. [UiImage](../sample-ui-image/README.md)
18 | 16. [Resource](../sample-resource/README.md)
19 | 17. [UiPageView](../sample-ui-pageview/README.md)
20 | 18. [Video](../sample-video/README.md)
21 |
--------------------------------------------------------------------------------
/docs/TODO.md:
--------------------------------------------------------------------------------
1 | # TODO
2 |
3 | ## Samples Needed
4 |
5 | 1. UI Kit built-in icons use (for labels and buttoins).
6 | 2. [Font Awesome](https://fontawesome.com/) usage with UI Kit.
7 | 3. Video Node.
8 | 4. [glMatrix](http://glmatrix.net/) and Transform Node.
9 | 5. Animated Models.
10 | 6. [axios](https://github.com/axios/axios) networking sample.
11 | 7. Audio sample with wav file playback from "/res".
12 |
13 | ## Testing
14 |
15 | Automate "npm install" and "magic-script build -i" with [Travis CI](https://travis-ci.org/)
16 |
--------------------------------------------------------------------------------
/poly-client/.gitignore:
--------------------------------------------------------------------------------
1 | /.out/
2 | /node_modules/
3 | /bin/
4 | !/bin/index.js
5 | /digest.sha512.signed
6 |
--------------------------------------------------------------------------------
/poly-client/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | {
2 | // Use IntelliSense to learn about possible attributes.
3 | // Hover to view descriptions of existing attributes.
4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5 | "version": "0.2.0",
6 | "configurations": [
7 | {
8 | "type": "node",
9 | "request": "attach",
10 | "name": "Attach Program",
11 | "address": "127.0.0.1",
12 | "port": 9229,
13 | "localRoot": "${workspaceFolder}/bin",
14 | "remoteRoot": ".",
15 | "protocol": "inspector"
16 | }
17 | ]
18 | }
19 |
--------------------------------------------------------------------------------
/poly-client/app.mabu:
--------------------------------------------------------------------------------
1 | KIND = program
2 |
--------------------------------------------------------------------------------
/poly-client/app.package:
--------------------------------------------------------------------------------
1 | DATAS = "digest.sha512.signed" : "." \
2 | "bin/" : "bin/"
3 | OPTIONS = package/minApiLevel/2
4 |
--------------------------------------------------------------------------------
/poly-client/manifest.xml:
--------------------------------------------------------------------------------
1 |
5 |
8 |
12 |
13 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/poly-client/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "scripts": {
3 | "build": "rollup -c",
4 | "start": "magic-script run"
5 | },
6 | "private": true,
7 | "devDependencies": {
8 | "rollup": "^1.1.2",
9 | "rollup-plugin-commonjs": "^9.3.4",
10 | "rollup-plugin-node-resolve": "^4.0.0"
11 | },
12 | "dependencies": {
13 | "magic-script-polyfills": "^1.0.0"
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/poly-client/rollup.config.js:
--------------------------------------------------------------------------------
1 | // Rollup config for consuming some npm modules in MagicScript
2 | import resolve from 'rollup-plugin-node-resolve';
3 | import commonjs from 'rollup-plugin-commonjs';
4 |
5 | export default {
6 | external: ['uv', 'lumin'],
7 | input: 'src/main.js',
8 | preserveModules: true,
9 | output: {
10 | dir: 'bin',
11 | format: 'es'
12 | },
13 | plugins: [resolve(), commonjs()]
14 | };
15 |
--------------------------------------------------------------------------------
/poly-client/src/GooglePolyApiKey.js:
--------------------------------------------------------------------------------
1 | export default '[Enter Key]';
2 |
--------------------------------------------------------------------------------
/poly-client/src/math.js:
--------------------------------------------------------------------------------
1 | export function eulerToQuaternion (pitch, roll, yaw) {
2 | let cy = Math.cos(yaw * 0.5);
3 | let sy = Math.sin(yaw * 0.5);
4 | let cr = Math.cos(roll * 0.5);
5 | let sr = Math.sin(roll * 0.5);
6 | let cp = Math.cos(pitch * 0.5);
7 | let sp = Math.sin(pitch * 0.5);
8 |
9 | let w = cy * cr * cp + sy * sr * sp;
10 | let x = cy * sr * cp - sy * cr * sp;
11 | let y = cy * cr * sp + sy * sr * cp;
12 | let z = sy * cr * cp - cy * sr * sp;
13 | return [ x, y, z, w];
14 | }
15 |
--------------------------------------------------------------------------------
/sample-async-await/.gitignore:
--------------------------------------------------------------------------------
1 | /.out/
2 | /node_modules/
3 | /bin/
4 | !/bin/index.js
5 | /digest.sha512.signed
6 |
--------------------------------------------------------------------------------
/sample-async-await/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | {
2 | // Use IntelliSense to learn about possible attributes.
3 | // Hover to view descriptions of existing attributes.
4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5 | "version": "0.2.0",
6 | "configurations": [
7 | {
8 | "type": "node",
9 | "request": "attach",
10 | "name": "Attach Program",
11 | "address": "127.0.0.1",
12 | "port": 9229,
13 | "localRoot": "${workspaceFolder}/bin",
14 | "remoteRoot": ".",
15 | "protocol": "inspector"
16 | }
17 | ]
18 | }
19 |
--------------------------------------------------------------------------------
/sample-async-await/app.mabu:
--------------------------------------------------------------------------------
1 | KIND = program
2 |
--------------------------------------------------------------------------------
/sample-async-await/app.package:
--------------------------------------------------------------------------------
1 | DATAS = "digest.sha512.signed" : "." \
2 | "bin/" : "bin/"
3 | OPTIONS = package/minApiLevel/2
4 |
--------------------------------------------------------------------------------
/sample-async-await/bin/index.js:
--------------------------------------------------------------------------------
1 | #!/system/bin/script/mxs
2 | import './src/main.js';
3 |
--------------------------------------------------------------------------------
/sample-async-await/manifest.xml:
--------------------------------------------------------------------------------
1 |
5 |
8 |
12 |
13 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/sample-async-await/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "scripts": {
3 | "build": "rollup -c",
4 | "start": "magic-script run"
5 | },
6 | "private": true,
7 | "devDependencies": {
8 | "rollup": "^1.1.2",
9 | "rollup-plugin-commonjs": "^9.3.4",
10 | "rollup-plugin-node-resolve": "^4.0.0"
11 | },
12 | "dependencies": {
13 | "magic-script-polyfills": "^1.0.0"
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/sample-async-await/rollup.config.js:
--------------------------------------------------------------------------------
1 | // Rollup config for consuming some npm modules in MagicScript
2 |
3 | import resolve from 'rollup-plugin-node-resolve';
4 | import commonjs from 'rollup-plugin-commonjs';
5 |
6 | export default {
7 | external: ['uv', 'lumin'],
8 | input: 'src/main.js',
9 | preserveModules: true,
10 | output: {
11 | dir: 'bin',
12 | format: 'es'
13 | },
14 | plugins: [resolve(), commonjs()]
15 | };
16 |
--------------------------------------------------------------------------------
/sample-audio/.gitignore:
--------------------------------------------------------------------------------
1 | /.out/
2 | /node_modules/
3 | /bin/
4 | /digest.sha512.signed
5 |
--------------------------------------------------------------------------------
/sample-audio/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | {
2 | // Use IntelliSense to learn about possible attributes.
3 | // Hover to view descriptions of existing attributes.
4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5 | "version": "0.2.0",
6 | "configurations": [
7 | {
8 | "type": "node",
9 | "request": "attach",
10 | "name": "Attach Program",
11 | "address": "127.0.0.1",
12 | "port": 9229,
13 | "localRoot": "${workspaceFolder}/bin",
14 | "remoteRoot": ".",
15 | "protocol": "inspector"
16 | }
17 | ]
18 | }
19 |
--------------------------------------------------------------------------------
/sample-audio/README.md:
--------------------------------------------------------------------------------
1 | # Audio Sample
2 |
3 | Audio Node Sample App that uses built in UI Kit sound resources
4 |
5 | ## Usage
6 |
7 | See the [README](../README.md) file for details
8 |
9 | ## License
10 |
11 | This project is licensed under the Apache 2.0 License - see the [LICENSE](../LICENSE) file for details
12 |
--------------------------------------------------------------------------------
/sample-audio/app.mabu:
--------------------------------------------------------------------------------
1 | KIND = program
2 |
--------------------------------------------------------------------------------
/sample-audio/app.package:
--------------------------------------------------------------------------------
1 | DATAS = "digest.sha512.signed" : "." \
2 | "bin/" : "bin/"
3 | OPTIONS = package/minApiLevel/2
4 |
--------------------------------------------------------------------------------
/sample-audio/bin/index.js:
--------------------------------------------------------------------------------
1 | #!/system/bin/script/mxs
2 | import './src/main.js';
3 |
--------------------------------------------------------------------------------
/sample-audio/manifest.xml:
--------------------------------------------------------------------------------
1 |
5 |
8 |
12 |
13 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/sample-audio/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "scripts": {
3 | "build": "rollup -c",
4 | "start": "magic-script run"
5 | },
6 | "private": true,
7 | "devDependencies": {
8 | "rollup": "^1.1.2",
9 | "rollup-plugin-commonjs": "^9.2.0",
10 | "rollup-plugin-node-resolve": "^4.0.0"
11 | },
12 | "dependencies": {
13 | "magic-script-polyfills": "^1.0.0"
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/sample-audio/rollup.config.js:
--------------------------------------------------------------------------------
1 | // Rollup config for consuming some npm modules in MagicScript
2 |
3 | import resolve from 'rollup-plugin-node-resolve';
4 | import commonjs from 'rollup-plugin-commonjs';
5 |
6 | export default {
7 | external: ['uv', 'lumin'],
8 | input: 'src/main.js',
9 | preserveModules: true,
10 | output: {
11 | dir: 'bin',
12 | format: 'es'
13 | },
14 | plugins: [resolve(), commonjs()]
15 | };
16 |
--------------------------------------------------------------------------------
/sample-audio/src/App.js:
--------------------------------------------------------------------------------
1 | import { makeButton } from './button.js';
2 |
3 | export default async function start (app) {
4 | let prism = app.requestNewPrism([0.7, 0.5, 0.5]);
5 | let button = null;
6 | // Add button # 1
7 | button = makeButton(prism, 'UIButtonStream');
8 | button.setLocalPosition([0, 0.15, 0]);
9 | prism.getRootNode().addChild(button);
10 | // Add button # 2
11 | button = makeButton(prism, 'UIButtonHeartPlus');
12 | button.setLocalPosition([0, 0, 0]);
13 | prism.getRootNode().addChild(button);
14 | // Add button # 3
15 | button = makeButton(prism, 'UIButtonBlock');
16 | button.setLocalPosition([0, -0.15, 0]);
17 | prism.getRootNode().addChild(button);
18 | return prism;
19 | }
20 |
--------------------------------------------------------------------------------
/sample-audio/src/button.js:
--------------------------------------------------------------------------------
1 | //
2 |
3 | import { ui } from "lumin";
4 |
5 | function onPress(prism, id) {
6 | // FIXME: Convert to a more appropriate system API
7 | let sound = prism.getSound(id);
8 | if (sound) {
9 | let audio_node = prism.createAudioNode();
10 | if (audio_node) {
11 | audio_node.createWithSound(sound);
12 | // 0 to 8, with 0 for silence, 1 for unity gain, and 8 for 8x gain
13 | audio_node.setSoundVolumeLinear(5);
14 | audio_node.startSound();
15 | }
16 | }
17 | }
18 |
19 | export function makeButton(prism, id) {
20 | const { UiButton } = ui;
21 | let node = UiButton.Create(prism, id, 0, 0.1);
22 | console.log("makeButton");
23 | node.onActivateSub(function(uiEventData) {
24 | onPress(prism, id);
25 | });
26 | return node;
27 | }
28 |
--------------------------------------------------------------------------------
/sample-book-of-shaders/.eslintrc.js:
--------------------------------------------------------------------------------
1 | // ESLint config for MagicScript Apps
2 | module.exports = {
3 | env: {
4 | "es6": true
5 | },
6 | globals: {
7 | // These globals are provided by the vm itself.
8 | "print": true,
9 | "globalThis": true,
10 | // The following globals are provided by `magic-script-polyfills`
11 | "setTimeout": true,
12 | "clearTimeout": true,
13 | "setInterval": true,
14 | "clearInterval": true,
15 | "setImmediate": true,
16 | "clearImmediate": true,
17 | "fetch": true,
18 | "Headers": true,
19 | "Request": true,
20 | "Response": true,
21 |
22 | },
23 | parserOptions: {
24 | "ecmaVersion": 2018,
25 | "sourceType": "module"
26 | },
27 | extends: "semistandard",
28 | };
--------------------------------------------------------------------------------
/sample-book-of-shaders/.gitignore:
--------------------------------------------------------------------------------
1 | /.out/
2 | /node_modules/
3 | /bin/
4 | !/bin/index.js
5 | /digest.sha512.signed
6 |
--------------------------------------------------------------------------------
/sample-book-of-shaders/.npmrc:
--------------------------------------------------------------------------------
1 | registry=https://nexus.magicleap.blue/repository/npm-group/
2 |
--------------------------------------------------------------------------------
/sample-book-of-shaders/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | {
2 | // Use IntelliSense to learn about possible attributes.
3 | // Hover to view descriptions of existing attributes.
4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5 | "version": "0.2.0",
6 | "configurations": [
7 | {
8 | "type": "node",
9 | "request": "attach",
10 | "name": "Attach Program",
11 | "address": "127.0.0.1",
12 | "port": 9229,
13 | "localRoot": "${workspaceFolder}/bin",
14 | "remoteRoot": ".",
15 | "protocol": "inspector"
16 | }
17 | ]
18 | }
19 |
--------------------------------------------------------------------------------
/sample-book-of-shaders/app.mabu:
--------------------------------------------------------------------------------
1 | KIND = program
2 |
--------------------------------------------------------------------------------
/sample-book-of-shaders/app.package:
--------------------------------------------------------------------------------
1 | DATAS = "digest.sha512.signed" : "." \
2 | "res/" : "res/" \
3 | "bin/" : "bin/"
4 | OPTIONS = package/minApiLevel/2
5 |
--------------------------------------------------------------------------------
/sample-book-of-shaders/manifest.xml:
--------------------------------------------------------------------------------
1 |
5 |
8 |
12 |
13 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/sample-book-of-shaders/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "scripts": {
3 | "build": "rollup -c",
4 | "start": "magic-script run"
5 | },
6 | "private": true,
7 | "devDependencies": {
8 | "eslint-config-semistandard": "^13.0.0",
9 | "eslint-config-standard": "^12.0.0",
10 | "eslint-plugin-import": "^2.16.0",
11 | "eslint-plugin-node": "^8.0.1",
12 | "eslint-plugin-promise": "^4.0.1",
13 | "eslint-plugin-standard": "^4.0.0",
14 | "rollup": "^1.1.2",
15 | "rollup-plugin-commonjs": "https://github.com/creationix/rollup-plugin-commonjs.git",
16 | "rollup-plugin-node-resolve": "^4.0.0",
17 | "semistandard": "^13.0.1"
18 | },
19 | "dependencies": {
20 | "magic-script-polyfills": "^1.0.0"
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/sample-book-of-shaders/res/README.md:
--------------------------------------------------------------------------------
1 | There are more interesting samples at https://thebookofshaders.com/
2 |
3 | The following are good ones to test:
4 |
5 | - circle-wave
6 | - dots5
7 | - iching-01
8 | - marching-dots
9 | - smoke
10 | - spinwheel
11 | - voroni
--------------------------------------------------------------------------------
/sample-book-of-shaders/res/color.glsl:
--------------------------------------------------------------------------------
1 | #ifdef GL_ES
2 | precision mediump float;
3 | #endif
4 |
5 | uniform vec2 u_resolution;
6 | uniform vec2 u_mouse;
7 | uniform float u_time;
8 |
9 | void main(){
10 | vec2 st=gl_FragCoord.xy/u_resolution.xy;
11 | st.x*=u_resolution.x/u_resolution.y;
12 |
13 | vec3 color=vec3(0.);
14 | color=vec3(st.x,st.y,abs(sin(u_time)));
15 |
16 | gl_FragColor=vec4(color,1.);
17 | }
--------------------------------------------------------------------------------
/sample-book-of-shaders/res/red.glsl:
--------------------------------------------------------------------------------
1 | #ifdef GL_ES
2 | precision mediump float;
3 | #endif
4 |
5 | uniform float u_time;
6 |
7 | void main() {
8 | gl_FragColor = vec4(abs(sin(u_time)),0.0,0.0,1.0);
9 | }
10 |
--------------------------------------------------------------------------------
/sample-book-of-shaders/rollup.config.js:
--------------------------------------------------------------------------------
1 | // Rollup config for consuming some npm modules in MagicScript
2 |
3 | import resolve from 'rollup-plugin-node-resolve';
4 | import commonjs from 'rollup-plugin-commonjs';
5 |
6 | export default {
7 | external: ['uv', 'lumin'],
8 | input: 'src/main.js',
9 | preserveModules: true,
10 | output: {
11 | dir: 'bin',
12 | format: 'es'
13 | },
14 | plugins: [resolve(), commonjs()]
15 | };
16 |
--------------------------------------------------------------------------------
/sample-book-of-shaders/src/main.js:
--------------------------------------------------------------------------------
1 | import 'magic-script-polyfills';
2 | import { App } from './app.js';
3 |
4 | print('Starting app process...');
5 | new App(0.16);
6 |
--------------------------------------------------------------------------------
/sample-components-prefab/.babelrc:
--------------------------------------------------------------------------------
1 | {
2 | "plugins": [
3 | "@babel/plugin-syntax-jsx",
4 | "@babel/plugin-transform-react-jsx"
5 | ]
6 | }
7 |
--------------------------------------------------------------------------------
/sample-components-prefab/.eslintrc.js:
--------------------------------------------------------------------------------
1 | // ESLint config for MagicScript Apps
2 | module.exports = {
3 | env: {
4 | "es6": true
5 | },
6 | globals: {
7 | // These globals are provided by the vm itself.
8 | "print": true,
9 | "globalThis": true,
10 | // The following globals are provided by `magic-script-polyfills`
11 | "setTimeout": true,
12 | "clearTimeout": true,
13 | "setInterval": true,
14 | "clearInterval": true,
15 | "setImmediate": true,
16 | "clearImmediate": true,
17 | "fetch": true,
18 | "Headers": true,
19 | "Request": true,
20 | "Response": true,
21 |
22 | },
23 | parserOptions: {
24 | "ecmaVersion": 2018,
25 | "sourceType": "module"
26 | },
27 | extends: "semistandard",
28 | };
--------------------------------------------------------------------------------
/sample-components-prefab/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules/
2 | .out/
3 | bin/
4 | digest.sha512.signed
--------------------------------------------------------------------------------
/sample-components-prefab/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | {
2 | // Use IntelliSense to learn about possible attributes.
3 | // Hover to view descriptions of existing attributes.
4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5 | "version": "0.2.0",
6 | "configurations": [
7 | {
8 | "type": "node",
9 | "request": "attach",
10 | "name": "Attach Program",
11 | "address": "127.0.0.1",
12 | "port": 9229,
13 | "localRoot": "${workspaceFolder}/bin",
14 | "remoteRoot": ".",
15 | "protocol": "inspector"
16 | }
17 | ]
18 | }
19 |
--------------------------------------------------------------------------------
/sample-components-prefab/README.md:
--------------------------------------------------------------------------------
1 | # Purpose
2 | Demonstrate how to create a custom React component (prefab) which can be reused.
3 |
--------------------------------------------------------------------------------
/sample-components-prefab/app.mabu:
--------------------------------------------------------------------------------
1 | KIND = program
2 |
--------------------------------------------------------------------------------
/sample-components-prefab/app.package:
--------------------------------------------------------------------------------
1 | DATAS = "digest.sha512.signed" : "." \
2 | "bin/" : "bin/"
3 | OPTIONS = package/minApiLevel/2
4 |
--------------------------------------------------------------------------------
/sample-components-prefab/manifest.xml:
--------------------------------------------------------------------------------
1 |
5 |
8 |
12 |
13 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/sample-components-prefab/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "scripts": {
3 | "build": "rollup -c",
4 | "start": "magic-script run"
5 | },
6 | "private": true,
7 | "devDependencies": {
8 | "@babel/core": "^7.4.3",
9 | "@babel/plugin-transform-react-jsx": "^7.3.0",
10 | "eslint-config-semistandard": "^13.0.0",
11 | "eslint-config-standard": "^12.0.0",
12 | "eslint-plugin-import": "^2.16.0",
13 | "eslint-plugin-node": "^8.0.1",
14 | "eslint-plugin-promise": "^4.0.1",
15 | "eslint-plugin-standard": "^4.0.0",
16 | "rollup": "^1.1.2",
17 | "rollup-plugin-babel": "^4.3.2",
18 | "rollup-plugin-commonjs": "^9.3.4",
19 | "rollup-plugin-node-resolve": "^4.0.0",
20 | "semistandard": "^13.0.1"
21 | },
22 | "dependencies": {
23 | "magic-script-components": "0.0.8",
24 | "magic-script-polyfills": "^2.0.0"
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/sample-components-prefab/rollup.config.js:
--------------------------------------------------------------------------------
1 | // Rollup config for consuming some npm modules in MagicScript
2 |
3 | import babel from 'rollup-plugin-babel';
4 | import resolve from 'rollup-plugin-node-resolve';
5 | import commonjs from 'rollup-plugin-commonjs';
6 |
7 | const common = {
8 | plugins: [
9 | babel({ exclude: 'node_modules/**' }),
10 | resolve(),
11 | commonjs()
12 | ]
13 | };
14 |
15 | export default [
16 | {
17 | ...common,
18 | external: ['uv', 'lumin', 'ssl', 'jpeg', 'png', 'gl'],
19 | input: 'src/main.js',
20 | preserveModules: true,
21 | output: {
22 | dir: 'bin',
23 | format: 'es'
24 | }
25 | },
26 | {
27 | ...common,
28 | external: ['react'],
29 | input: 'src/app.js',
30 | output: {
31 | globals: { react: 'React' },
32 | file: 'bin/bundle.js',
33 | format: 'iife',
34 | name: '_'
35 | }
36 | }
37 | ];
38 |
--------------------------------------------------------------------------------
/sample-components-prefab/src/app.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import { TextSlider } from './components/index.js';
3 |
4 | export default class MyApp extends React.Component {
5 | constructor(props) {
6 | super(props);
7 |
8 | this.instructions = [
9 | 'Step 1:\nThis is prefab demo app created for fun :D',
10 | 'Step 2:\nCreating prefabs requires you to enjoy fun !',
11 | 'Step 3:\nEnjoying fun is a crucial element of creating prefabs.',
12 | 'Step 4:\nAnother crucial requirement is completion of\nmagic-script-components',
13 | ];
14 | }
15 |
16 | render() {
17 | return (
18 |
19 |
20 |
21 | );
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/sample-components-prefab/src/components/index.js:
--------------------------------------------------------------------------------
1 | export { default as TextSlider } from './text-slider.js';
--------------------------------------------------------------------------------
/sample-components-prefab/src/global-scope.js:
--------------------------------------------------------------------------------
1 | // This is a required workaround which expects NODE_ENV
2 | globalThis.process = { env: { NODE_ENV:"development" } };
3 | export default process;
--------------------------------------------------------------------------------
/sample-components-prefab/src/main.js:
--------------------------------------------------------------------------------
1 | // Add support for things like setTimeout, setInterval and fetch.
2 | // Simply importing this sets all these as global definitions.
3 | // They are declared in the .eslintrc so your editor won't complain.
4 | import 'magic-script-polyfills';
5 | import './global-scope.js';
6 |
7 | import React from 'react';
8 | import mxs from 'magic-script-components';
9 |
10 | // Load main app logic from the app class.
11 | import MyApp from './app.js';
12 |
13 | mxs.bootstrap();
14 |
--------------------------------------------------------------------------------
/sample-components-prop-visualizer/.babelrc:
--------------------------------------------------------------------------------
1 | {
2 | "plugins": [
3 | "@babel/plugin-syntax-jsx",
4 | "@babel/plugin-transform-react-jsx",
5 | [
6 | "module-resolver",
7 | {
8 | "root": ["."],
9 | "alias": {
10 | "~": ".",
11 | "@": "./src"
12 | }
13 | }
14 | ]
15 | ]
16 | }
17 |
--------------------------------------------------------------------------------
/sample-components-prop-visualizer/.gitignore:
--------------------------------------------------------------------------------
1 | # Node
2 | node_modules/
3 |
4 | # Lumin
5 | .out/
6 | bin/
7 | digest.sha512.signed
8 |
9 | # Vs Code
10 | .history
11 | .DS_Store
--------------------------------------------------------------------------------
/sample-components-prop-visualizer/README.md:
--------------------------------------------------------------------------------
1 | # README
2 |
3 | Initial version of the MXS-Props_Visualizer
4 |
5 | ### What is this repository for?
6 |
7 | This repo allows a user to interact with various MXS props and see real time feedback of how they affect a component.
8 |
--------------------------------------------------------------------------------
/sample-components-prop-visualizer/app.mabu:
--------------------------------------------------------------------------------
1 | KIND = program
2 |
--------------------------------------------------------------------------------
/sample-components-prop-visualizer/app.package:
--------------------------------------------------------------------------------
1 | DATAS = "digest.sha512.signed" : "." \
2 | "bin/" : "bin/"
3 | OPTIONS = package/minApiLevel/2
4 |
--------------------------------------------------------------------------------
/sample-components-prop-visualizer/jsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "baseUrl": ".",
4 | "paths": {
5 | "@/*": ["./src/*"],
6 | "~/*": ["./*"]
7 | }
8 | },
9 | "exclude": ["node_modules", ".out", "bin"]
10 | }
11 |
--------------------------------------------------------------------------------
/sample-components-prop-visualizer/manifest.xml:
--------------------------------------------------------------------------------
1 |
5 |
8 |
12 |
13 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/sample-components-prop-visualizer/src/controllers/Boolean.js:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import { Toggle } from "magic-script-components";
3 |
4 | export default function BooleanController({ applyValue }) {
5 | const handleToggle = e => {
6 | const val = e.On ? true : false;
7 |
8 | applyValue("value", val);
9 | };
10 |
11 | return (
12 |
17 | );
18 | }
19 |
--------------------------------------------------------------------------------
/sample-components-prop-visualizer/src/controllers/String.js:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import { TextEdit } from "magic-script-components";
3 |
4 | export default function StringController({ applyValue }) {
5 | return (
6 | applyValue("value", event.Text)}
9 | textAlignment="left"
10 | textSize={0.04}
11 | height={0.04}
12 | width={0.25}
13 | />
14 | );
15 | }
16 |
--------------------------------------------------------------------------------
/sample-components-prop-visualizer/src/controllers/index.js:
--------------------------------------------------------------------------------
1 | import Vec3 from "./Vec3";
2 | import Quat from "./Quat";
3 | import String from "./String";
4 | import Boolean from "./Boolean";
5 |
6 | export default {
7 | Vec3,
8 | Quat,
9 | String,
10 | Boolean
11 | };
12 |
--------------------------------------------------------------------------------
/sample-components-prop-visualizer/src/global-scope.js:
--------------------------------------------------------------------------------
1 | // This is a required workaround which expects NODE_ENV
2 | globalThis.process = { env: { NODE_ENV:"development" } };
3 | export default process;
4 |
--------------------------------------------------------------------------------
/sample-components-prop-visualizer/src/main.js:
--------------------------------------------------------------------------------
1 | // Add support for things like setTimeout, setInterval and fetch.
2 | // Simply importing this sets all these as global definitions.
3 | // They are declared in the .eslintrc so your editor won't complain.
4 | import "magic-script-polyfills";
5 | import "./global-scope.js";
6 |
7 | import React from "react";
8 | import mxs from "magic-script-components-lumin";
9 |
10 | // Load main app logic from the app class.
11 | import MyApp from "./app.js";
12 |
13 | mxs.bootstrap();
14 |
--------------------------------------------------------------------------------
/sample-components-router/.babelrc:
--------------------------------------------------------------------------------
1 | {
2 | "plugins": [
3 | "@babel/plugin-syntax-jsx",
4 | "@babel/plugin-transform-react-jsx",
5 | [
6 | "module-resolver",
7 | {
8 | "root": ["."],
9 | "alias": {
10 | "~": ".",
11 | "@": "./src"
12 | }
13 | }
14 | ]
15 | ]
16 | }
17 |
--------------------------------------------------------------------------------
/sample-components-router/.npmignore:
--------------------------------------------------------------------------------
1 | /bin/
2 |
--------------------------------------------------------------------------------
/sample-components-router/.prettierrc:
--------------------------------------------------------------------------------
1 | {
2 | "trailingComma": "es5",
3 | "semi": false,
4 | "singleQuote": true,
5 | "quoteProps": "as-needed",
6 | "endOfLine": "lf"
7 | }
--------------------------------------------------------------------------------
/sample-components-router/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "editor.formatOnSave": true
3 | }
--------------------------------------------------------------------------------
/sample-components-router/app.mabu:
--------------------------------------------------------------------------------
1 | KIND = program
2 |
--------------------------------------------------------------------------------
/sample-components-router/app.package:
--------------------------------------------------------------------------------
1 | DATAS = "digest.sha512.signed" : "." \
2 | "bin/" : "bin/"
3 | OPTIONS = package/minApiLevel/2
4 |
--------------------------------------------------------------------------------
/sample-components-router/jsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "baseUrl": ".",
4 | "paths": {
5 | "@/*": ["./src/*"],
6 | "~/*": ["./*"]
7 | }
8 | },
9 | "exclude": ["node_modules", ".out", "bin"]
10 | }
11 |
--------------------------------------------------------------------------------
/sample-components-router/lr_resource_locator:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/magic-script/magic-script-samples/12be913cc2f84f4d1bf706c15057ea0d4fc1d55c/sample-components-router/lr_resource_locator
--------------------------------------------------------------------------------
/sample-components-router/manifest.xml:
--------------------------------------------------------------------------------
1 |
5 |
7 |
11 |
12 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/sample-components-router/src/app.js:
--------------------------------------------------------------------------------
1 | //
2 | import React, { Component } from 'react'
3 | import { Router, Route, Switch } from 'react-router'
4 | import { View } from 'magic-script-components'
5 |
6 | import history from '@/utils/history'
7 | import routes from '@/constants/routes'
8 |
9 | export default class MyApp extends Component {
10 | render() {
11 | return (
12 |
13 |
14 |
15 | {routes.map((props, idx) => (
16 |
17 | ))}
18 |
19 |
20 |
21 | )
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/sample-components-router/src/constants/parameter.js:
--------------------------------------------------------------------------------
1 | // This is the value being passed as the parameter to the 'paramed' path
2 | // Simply change this value to see the value displayed on that route change
3 |
4 | // Route params are useful for things like a product detail page where you use
5 | // the same component to render different products. You could place that container
6 | // in a route like '/product-details/:id'. Then in componentDidMount, you could
7 | // pull the ID out of the route and make a fetch request for that product ID's details
8 |
9 | const param = 5
10 |
11 | export default param
12 |
--------------------------------------------------------------------------------
/sample-components-router/src/constants/paths.js:
--------------------------------------------------------------------------------
1 | export default {
2 | home: '/',
3 | primary: '/1',
4 | query: '/query',
5 | paramed: '/param/:id',
6 | nested: '/nest',
7 | }
8 |
--------------------------------------------------------------------------------
/sample-components-router/src/constants/routes.js:
--------------------------------------------------------------------------------
1 | // Route Definitions
2 | import paths from '@/constants/paths'
3 |
4 | // Containers
5 | import { Primary, Query, Home, Paramed, Nested } from '@/containers'
6 |
7 | export default [
8 | {
9 | exact: true,
10 | path: paths.home,
11 | component: Home,
12 | },
13 | {
14 | exact: false,
15 | path: paths.primary,
16 | component: Primary,
17 | },
18 | {
19 | exact: true,
20 | path: paths.query,
21 | component: Query,
22 | },
23 | {
24 | exact: false,
25 | path: paths.paramed,
26 | component: Paramed,
27 | },
28 | {
29 | exact: false,
30 | path: paths.nested,
31 | component: Nested,
32 | },
33 | ]
34 |
--------------------------------------------------------------------------------
/sample-components-router/src/containers/Nested/deepNest.js:
--------------------------------------------------------------------------------
1 | import React from 'react'
2 | import { Text } from 'magic-script-components'
3 |
4 | export default ({ match }) => (
5 |
6 | {`This is the Nested Route displaying! The param passed in is ${match.params.nestedID}`}
7 |
8 | )
9 |
--------------------------------------------------------------------------------
/sample-components-router/src/containers/index.js:
--------------------------------------------------------------------------------
1 | export { default as Home } from './Home'
2 | export { default as Primary } from './Primary'
3 | export { default as Query } from './Query'
4 | export { default as Paramed } from './Parameterized'
5 | export { default as Nested } from './Nested'
6 |
--------------------------------------------------------------------------------
/sample-components-router/src/global-scope.js:
--------------------------------------------------------------------------------
1 | // This is a required workaround which expects NODE_ENV
2 | globalThis.process = { env: { NODE_ENV: "development" } };
3 | export default process;
4 |
--------------------------------------------------------------------------------
/sample-components-router/src/main.js:
--------------------------------------------------------------------------------
1 | // Add support for things like setTimeout, setInterval and fetch.
2 | // Simply importing this sets all these as global definitions.
3 | // They are declared in the .eslintrc so your editor won't complain.
4 | import 'magic-script-polyfills'
5 | import process from './global-scope.js'
6 | import React from 'react'
7 | import mxs from 'magic-script-components-lumin'
8 |
9 | // Load main app logic from the app class.
10 | import MyApp from '@/app.js'
11 |
12 | mxs.bootstrap()
13 |
--------------------------------------------------------------------------------
/sample-components-router/src/utils/history.js:
--------------------------------------------------------------------------------
1 | import { createMemoryHistory } from "history";
2 |
3 | const history = createMemoryHistory();
4 |
5 | export default history;
6 |
--------------------------------------------------------------------------------
/sample-components-tictactoe/.babelrc:
--------------------------------------------------------------------------------
1 | {
2 | "plugins": [
3 | "@babel/plugin-syntax-jsx",
4 | "@babel/plugin-transform-react-jsx",
5 | "@babel/plugin-proposal-class-properties"
6 | ]
7 | }
8 |
9 |
--------------------------------------------------------------------------------
/sample-components-tictactoe/.eslintrc.js:
--------------------------------------------------------------------------------
1 | // ESLint config for MagicScript Apps
2 | module.exports = {
3 | env: {
4 | "es6": true
5 | },
6 | globals: {
7 | // These globals are provided by the vm itself.
8 | "print": true,
9 | "globalThis": true,
10 | // The following globals are provided by `magic-script-polyfills`
11 | "setTimeout": true,
12 | "clearTimeout": true,
13 | "setInterval": true,
14 | "clearInterval": true,
15 | "setImmediate": true,
16 | "clearImmediate": true,
17 | "fetch": true,
18 | "Headers": true,
19 | "Request": true,
20 | "Response": true,
21 |
22 | },
23 | parserOptions: {
24 | "ecmaVersion": 2018,
25 | "sourceType": "module"
26 | },
27 | extends: [
28 | "semistandard",
29 | "plugin:react/recommended"
30 | ],
31 | };
--------------------------------------------------------------------------------
/sample-components-tictactoe/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules/
2 | .out/
3 | bin/
4 | digest.sha512.signed
5 |
6 |
--------------------------------------------------------------------------------
/sample-components-tictactoe/.npmignore:
--------------------------------------------------------------------------------
1 | /.out/
2 | /node_modules/
3 | /bin/
4 | !/bin/index.js
5 | /digest.sha512.signed
6 |
--------------------------------------------------------------------------------
/sample-components-tictactoe/README.md:
--------------------------------------------------------------------------------
1 | # Tic Tac Toe sample
2 |
3 | This is a port of the React JS tic tac toe tutorial sample to Lumin Runtime.
4 | The original tutorial is available here:
5 |
6 | https://reactjs.org/tutorial/tutorial.html
--------------------------------------------------------------------------------
/sample-components-tictactoe/app.mabu:
--------------------------------------------------------------------------------
1 | KIND = program
2 |
--------------------------------------------------------------------------------
/sample-components-tictactoe/app.package:
--------------------------------------------------------------------------------
1 | DATAS = "digest.sha512.signed" : "." \
2 | "bin/" : "bin/"
3 | OPTIONS = package/minApiLevel/2
4 |
--------------------------------------------------------------------------------
/sample-components-tictactoe/lr_resource_locator:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/magic-script/magic-script-samples/12be913cc2f84f4d1bf706c15057ea0d4fc1d55c/sample-components-tictactoe/lr_resource_locator
--------------------------------------------------------------------------------
/sample-components-tictactoe/manifest.xml:
--------------------------------------------------------------------------------
1 |
5 |
7 |
11 |
12 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/sample-components-tictactoe/rollup.config.js:
--------------------------------------------------------------------------------
1 | // Rollup config for consuming some npm modules in MagicScript
2 |
3 | import babel from 'rollup-plugin-babel';
4 | import resolve from 'rollup-plugin-node-resolve';
5 | import commonjs from 'rollup-plugin-commonjs';
6 |
7 | export default {
8 | external: ['uv', 'lumin', 'ssl'],
9 | input: 'src/main.js',
10 | preserveModules: true,
11 | output: {
12 | dir: 'bin',
13 | format: 'es'
14 | },
15 | plugins: [
16 | babel({ exclude: "node_modules/**" }),
17 | resolve(),
18 | commonjs()
19 | ]
20 | };
21 |
--------------------------------------------------------------------------------
/sample-components-tictactoe/src/components/board.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import PropTypes from 'prop-types';
3 |
4 | import { GridLayout } from 'magic-script-components';
5 | import { Square } from './index.js';
6 |
7 | // Component that renders the full Tic Tac Toe board
8 | export default function Board (props) {
9 | const renderSquare = (props, i) => {
10 | return (
11 | props.onClick(i)}
16 | />
17 | );
18 | };
19 |
20 | const items = [];
21 | for (let i = 0; i < 9; i++) {
22 | items.push(renderSquare(props, i));
23 | }
24 | return {items};
25 | }
26 |
27 | Board.propTypes = {
28 | squares: PropTypes.arrayOf(PropTypes.string),
29 | onClick: PropTypes.func
30 | };
31 |
--------------------------------------------------------------------------------
/sample-components-tictactoe/src/components/calculate-winner.js:
--------------------------------------------------------------------------------
1 | export function calculateWinner (squares) {
2 | const lines = [
3 | [0, 1, 2],
4 | [3, 4, 5],
5 | [6, 7, 8],
6 | [0, 3, 6],
7 | [1, 4, 7],
8 | [2, 5, 8],
9 | [0, 4, 8],
10 | [2, 4, 6]
11 | ];
12 | for (let i = 0; i < lines.length; i++) {
13 | const [a, b, c] = lines[i];
14 | if (squares[a] && squares[a] === squares[b] && squares[a] === squares[c]) {
15 | return squares[a];
16 | }
17 | }
18 | return null;
19 | }
20 |
--------------------------------------------------------------------------------
/sample-components-tictactoe/src/components/index.js:
--------------------------------------------------------------------------------
1 | export { default as Board } from './board.js';
2 | export { default as Game } from './game.js';
3 | export { default as GameInfo } from './game-info.js';
4 | export { default as PlayerChooser } from './player-chooser.js';
5 | export { default as Square } from './square.js';
6 |
--------------------------------------------------------------------------------
/sample-components-tictactoe/src/components/square.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import PropTypes from 'prop-types';
3 |
4 | import { Button } from 'magic-script-components';
5 |
6 | // Component that renders a single square in the Tic Tac Toe board
7 | export default function Square (props) {
8 | const color = props.value === 'X' ? [1, 0.1, 0.1, 1] : [0.1, 0.1, 1, 1];
9 | return (
10 |
13 | );
14 | }
15 |
16 | Square.propTypes = {
17 | name: PropTypes.string,
18 | onClick: PropTypes.func,
19 | value: PropTypes.string
20 | };
21 |
--------------------------------------------------------------------------------
/sample-components-tictactoe/src/global-scope.js:
--------------------------------------------------------------------------------
1 | globalThis.process = { env: { NODE_ENV: 'development' } };
2 | export default process;
3 |
--------------------------------------------------------------------------------
/sample-components-tictactoe/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "allowJs": true,
4 | "noEmit": true,
5 | "typeRoots" : ["./node_modules/magic-script-typings", "./node_modules/@types"]
6 | }
7 | }
8 |
9 |
--------------------------------------------------------------------------------
/sample-components/.babelrc:
--------------------------------------------------------------------------------
1 | {
2 | "plugins": [
3 | "@babel/plugin-syntax-jsx",
4 | "@babel/plugin-transform-react-jsx"
5 | ]
6 | }
--------------------------------------------------------------------------------
/sample-components/.eslintrc.js:
--------------------------------------------------------------------------------
1 | // ESLint config for MagicScript Apps
2 | module.exports = {
3 | env: {
4 | "es6": true
5 | },
6 | globals: {
7 | // These globals are provided by the vm itself.
8 | "print": true,
9 | "globalThis": true,
10 | // The following globals are provided by `magic-script-polyfills`
11 | "setTimeout": true,
12 | "clearTimeout": true,
13 | "setInterval": true,
14 | "clearInterval": true,
15 | "setImmediate": true,
16 | "clearImmediate": true,
17 | "fetch": true,
18 | "Headers": true,
19 | "Request": true,
20 | "Response": true,
21 |
22 | },
23 | parserOptions: {
24 | "ecmaVersion": 2018,
25 | "sourceType": "module"
26 | },
27 | extends: "semistandard",
28 | };
--------------------------------------------------------------------------------
/sample-components/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules/
2 | .out/
3 | bin/
4 | digest.sha512.signed
5 |
--------------------------------------------------------------------------------
/sample-components/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | {
2 | // Use IntelliSense to learn about possible attributes.
3 | // Hover to view descriptions of existing attributes.
4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5 | "version": "0.2.0",
6 | "configurations": [
7 | {
8 | "type": "node",
9 | "request": "attach",
10 | "name": "Attach Program",
11 | "address": "127.0.0.1",
12 | "port": 9229,
13 | "localRoot": "${workspaceFolder}/bin",
14 | "remoteRoot": ".",
15 | "protocol": "inspector"
16 | }
17 | ]
18 | }
19 |
--------------------------------------------------------------------------------
/sample-components/README.md:
--------------------------------------------------------------------------------
1 | # sample-components
2 | sample app using magic-script-components
--------------------------------------------------------------------------------
/sample-components/app.mabu:
--------------------------------------------------------------------------------
1 | KIND = program
2 |
--------------------------------------------------------------------------------
/sample-components/app.package:
--------------------------------------------------------------------------------
1 | DATAS = "digest.sha512.signed" : "." \
2 | "bin/" : "bin/"
3 | OPTIONS = package/minApiLevel/2
4 |
--------------------------------------------------------------------------------
/sample-components/manifest.xml:
--------------------------------------------------------------------------------
1 |
5 |
8 |
12 |
13 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/sample-components/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "scripts": {
3 | "build": "rollup -c",
4 | "start": "magic-script run"
5 | },
6 | "private": true,
7 | "devDependencies": {
8 | "@babel/core": "^7.3.4",
9 | "@babel/plugin-transform-react-jsx": "^7.3.0",
10 | "eslint-config-semistandard": "^13.0.0",
11 | "eslint-config-standard": "^12.0.0",
12 | "eslint-plugin-import": "^2.16.0",
13 | "eslint-plugin-node": "^8.0.1",
14 | "eslint-plugin-promise": "^4.0.1",
15 | "eslint-plugin-standard": "^4.0.0",
16 | "rollup": "^1.1.2",
17 | "rollup-plugin-babel": "^4.3.2",
18 | "rollup-plugin-commonjs": "^9.3.4",
19 | "rollup-plugin-node-resolve": "^4.0.0",
20 | "semistandard": "^13.0.1"
21 | },
22 | "dependencies": {
23 | "magic-script-components": "0.0.8",
24 | "magic-script-polyfills": "^2.0.0"
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/sample-components/rollup.config.js:
--------------------------------------------------------------------------------
1 | // Rollup config for consuming some npm modules in MagicScript
2 |
3 | import babel from 'rollup-plugin-babel';
4 | import resolve from 'rollup-plugin-node-resolve';
5 | import commonjs from 'rollup-plugin-commonjs';
6 |
7 | const common = {
8 | plugins: [
9 | babel({ exclude: 'node_modules/**' }),
10 | resolve(),
11 | commonjs()
12 | ]
13 | };
14 |
15 | export default [
16 | {
17 | ...common,
18 | external: ['uv', 'lumin', 'ssl', 'jpeg', 'png', 'gl'],
19 | input: 'src/main.js',
20 | preserveModules: true,
21 | output: {
22 | dir: 'bin',
23 | format: 'es'
24 | }
25 | },
26 | {
27 | ...common,
28 | external: ['react'],
29 | input: 'src/app.js',
30 | output: {
31 | globals: { react: 'React' },
32 | file: 'bin/bundle.js',
33 | format: 'iife',
34 | name: '_'
35 | }
36 | }
37 | ];
38 |
--------------------------------------------------------------------------------
/sample-components/src/app.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 |
3 | export default class MyApp extends React.Component {
4 | constructor(props) {
5 | super(props);
6 |
7 | this.state = { counter: props.counter, message: 'placeholder' };
8 |
9 | this.onButtonClick = this.onButtonClick.bind(this);
10 | this.onTextChanged = this.onTextChanged.bind(this);
11 | }
12 |
13 | onButtonClick(event) {
14 | this.setState( state => ({ counter: state.counter + 1 }) );
15 | }
16 |
17 | onTextChanged(event) {
18 | console.log(event);
19 | }
20 |
21 | render() {
22 | return (
23 |
24 | {this.state.counter}
25 |
26 |
27 | );
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/sample-components/src/global-scope.js:
--------------------------------------------------------------------------------
1 | // This is a required workaround which expects NODE_ENV
2 | globalThis.process = { env: { NODE_ENV:"development" } };
3 | export default process;
4 |
--------------------------------------------------------------------------------
/sample-components/src/main.js:
--------------------------------------------------------------------------------
1 | // Add support for things like setTimeout, setInterval and fetch.
2 | // Simply importing this sets all these as global definitions.
3 | // They are declared in the .eslintrc so your editor won't complain.
4 | import 'magic-script-polyfills';
5 | import './global-scope.js';
6 |
7 | import React from 'react';
8 | import mxs from 'magic-script-components';
9 |
10 | // Load main app logic from the app class.
11 | import MyApp from './app.js';
12 |
13 | mxs.bootstrap();
14 |
--------------------------------------------------------------------------------
/sample-exclusive/.eslintrc.js:
--------------------------------------------------------------------------------
1 | // ESLint config for MagicScript Apps
2 | module.exports = {
3 | env: {
4 | "es6": true
5 | },
6 | globals: {
7 | // These globals are provided by the vm itself.
8 | "print": true,
9 | "globalThis": true,
10 | // The following globals are provided by `magic-script-polyfills`
11 | "setTimeout": true,
12 | "clearTimeout": true,
13 | "setInterval": true,
14 | "clearInterval": true,
15 | "setImmediate": true,
16 | "clearImmediate": true,
17 | "fetch": true,
18 | "Headers": true,
19 | "Request": true,
20 | "Response": true,
21 |
22 | },
23 | parserOptions: {
24 | "ecmaVersion": 2018,
25 | "sourceType": "module"
26 | },
27 | extends: "semistandard",
28 | };
--------------------------------------------------------------------------------
/sample-exclusive/.gitignore:
--------------------------------------------------------------------------------
1 | /.out/
2 | /node_modules/
3 | /bin/
4 | !/bin/index.js
5 | /digest.sha512.signed
6 |
--------------------------------------------------------------------------------
/sample-exclusive/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | {
2 | // Use IntelliSense to learn about possible attributes.
3 | // Hover to view descriptions of existing attributes.
4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5 | "version": "0.2.0",
6 | "configurations": [
7 | {
8 | "type": "node",
9 | "request": "attach",
10 | "name": "Attach Program",
11 | "address": "127.0.0.1",
12 | "port": 9229,
13 | "localRoot": "${workspaceFolder}/bin",
14 | "remoteRoot": ".",
15 | "protocol": "inspector"
16 | }
17 | ]
18 | }
19 |
--------------------------------------------------------------------------------
/sample-exclusive/app.mabu:
--------------------------------------------------------------------------------
1 | KIND = program
2 |
--------------------------------------------------------------------------------
/sample-exclusive/app.package:
--------------------------------------------------------------------------------
1 | DATAS = "digest.sha512.signed" : "." \
2 | "bin/" : "bin/"
3 | OPTIONS = package/minApiLevel/2
4 |
--------------------------------------------------------------------------------
/sample-exclusive/manifest.xml:
--------------------------------------------------------------------------------
1 |
5 |
8 |
12 |
13 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/sample-exclusive/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "scripts": {
3 | "build": "rollup -c",
4 | "start": "magic-script run"
5 | },
6 | "private": true,
7 | "devDependencies": {
8 | "eslint-config-semistandard": "^13.0.0",
9 | "eslint-config-standard": "^12.0.0",
10 | "eslint-plugin-import": "^2.16.0",
11 | "eslint-plugin-node": "^8.0.1",
12 | "eslint-plugin-promise": "^4.0.1",
13 | "eslint-plugin-standard": "^4.0.0",
14 | "rollup": "^1.1.2",
15 | "rollup-plugin-commonjs": "^9.3.4",
16 | "rollup-plugin-node-resolve": "^4.0.0",
17 | "semistandard": "^13.0.1"
18 | },
19 | "dependencies": {
20 | "gl-matrix": "^3.0.0",
21 | "magic-script-polyfills": "^1.0.0"
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/sample-exclusive/rollup.config.js:
--------------------------------------------------------------------------------
1 | // Rollup config for consuming some npm modules in MagicScript
2 |
3 | import resolve from 'rollup-plugin-node-resolve';
4 | import commonjs from 'rollup-plugin-commonjs';
5 |
6 | export default {
7 | external: ['uv', 'lumin', 'gl', 'egl', 'ssl'],
8 | input: 'src/main.js',
9 | preserveModules: true,
10 | output: {
11 | dir: 'bin',
12 | format: 'es'
13 | },
14 | plugins: [resolve(), commonjs()]
15 | };
16 |
--------------------------------------------------------------------------------
/sample-exclusive/src/main.js:
--------------------------------------------------------------------------------
1 | import 'magic-script-polyfills';
2 | import { App } from './app.js';
3 |
4 | print('Starting app process...');
5 | export default new App(0.16);
6 |
--------------------------------------------------------------------------------
/sample-external-package/.gitignore:
--------------------------------------------------------------------------------
1 | /.out/
2 | /node_modules/
3 | /bin/
4 | /digest.sha512.signed
5 |
--------------------------------------------------------------------------------
/sample-external-package/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | {
2 | // Use IntelliSense to learn about possible attributes.
3 | // Hover to view descriptions of existing attributes.
4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5 | "version": "0.2.0",
6 | "configurations": [
7 | {
8 | "type": "node",
9 | "request": "attach",
10 | "name": "Attach Program",
11 | "address": "127.0.0.1",
12 | "port": 9229,
13 | "localRoot": "${workspaceFolder}/bin",
14 | "remoteRoot": ".",
15 | "protocol": "inspector"
16 | }
17 | ]
18 | }
19 |
--------------------------------------------------------------------------------
/sample-external-package/README.md:
--------------------------------------------------------------------------------
1 | # External Package Sample
2 |
3 | Sample demoing external package inclusion.
4 | It shows how [Lodash](https://lodash.com/) and [Underscore](https://underscorejs.org/) could be used together with UiText.
5 |
6 | ## Usage
7 |
8 | See the [README](../README.md) file for details
9 |
10 | ## License
11 |
12 | This project is licensed under the Apache 2.0 License - see the [LICENSE](../LICENSE) file for details
13 |
--------------------------------------------------------------------------------
/sample-external-package/app.mabu:
--------------------------------------------------------------------------------
1 | KIND = program
2 |
--------------------------------------------------------------------------------
/sample-external-package/app.package:
--------------------------------------------------------------------------------
1 | DATAS = "digest.sha512.signed" : "." \
2 | "bin/" : "bin/"
3 | OPTIONS = package/minApiLevel/2
4 |
--------------------------------------------------------------------------------
/sample-external-package/bin/index.js:
--------------------------------------------------------------------------------
1 | #!/system/bin/script/mxs
2 | import './src/main.js';
3 |
--------------------------------------------------------------------------------
/sample-external-package/manifest.xml:
--------------------------------------------------------------------------------
1 |
5 |
8 |
12 |
13 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/sample-external-package/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "scripts": {
3 | "build": "rollup -c",
4 | "start": "magic-script run"
5 | },
6 | "private": true,
7 | "devDependencies": {
8 | "rollup": "^1.1.2",
9 | "rollup-plugin-commonjs": "^9.3.4",
10 | "rollup-plugin-node-resolve": "^4.0.0"
11 | },
12 | "dependencies": {
13 | "lodash": "^4.17.11",
14 | "underscore": "^1.9.1",
15 | "magic-script-polyfills": "^1.0.0"
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/sample-external-package/rollup.config.js:
--------------------------------------------------------------------------------
1 | // Rollup config for consuming some npm modules in MagicScript
2 |
3 | import resolve from 'rollup-plugin-node-resolve';
4 | import commonjs from 'rollup-plugin-commonjs';
5 |
6 | export default {
7 | external: ['uv', 'lumin'],
8 | input: 'src/main.js',
9 | preserveModules: true,
10 | output: {
11 | dir: 'bin',
12 | format: 'es'
13 | },
14 | plugins: [resolve(), commonjs()]
15 | };
16 |
--------------------------------------------------------------------------------
/sample-external-package/src/App.js:
--------------------------------------------------------------------------------
1 | import { makeTextUnderscore } from './text_underscore.js';
2 | import { makeTextLodash } from './text_lodash.js';
3 |
4 | export default async function start (app) {
5 | let prism = app.requestNewPrism([0.5, 0.5, 0.5]);
6 |
7 | let text_u = makeTextUnderscore(prism);
8 | text_u.setLocalPosition([0, 0.1, 0]);
9 | prism.getRootNode().addChild(text_u);
10 |
11 | let text_l = makeTextLodash(prism);
12 | text_l.setLocalPosition([0, -0.1, 0]);
13 | prism.getRootNode().addChild(text_l);
14 | return prism;
15 | }
16 |
--------------------------------------------------------------------------------
/sample-external-package/src/text_lodash.js:
--------------------------------------------------------------------------------
1 | //
2 | import { ui } from 'lumin';
3 | import __ from 'lodash';
4 |
5 | export function makeTextLodash(prism) {
6 | const { UiText, EclipseLabelType, Alignment, HorizontalTextAlignment } = ui;
7 | let array = [1, 2, 3, 4, 5, 6, 7];
8 | __.fill(array, '*', 2, 5);
9 | let result = __.map(array, function(num) {
10 | return num;
11 | });
12 | let node = UiText.CreateEclipseLabel(
13 | prism,
14 | 'Lodash.js result:\n' + result,
15 | EclipseLabelType.kT7
16 | );
17 | node.setAlignment(Alignment.CENTER_CENTER);
18 | node.setTextAlignment(HorizontalTextAlignment.kCenter);
19 | return node;
20 | }
21 |
--------------------------------------------------------------------------------
/sample-external-package/src/text_underscore.js:
--------------------------------------------------------------------------------
1 | //
2 | import { ui } from 'lumin';
3 | import _ from 'underscore';
4 |
5 | export function makeTextUnderscore(prism) {
6 | const { UiText, EclipseLabelType, Alignment, HorizontalTextAlignment } = ui;
7 | let result = _.map([1, 2, 3], function(num) {
8 | return num * 3;
9 | });
10 | let node = UiText.CreateEclipseLabel(
11 | prism,
12 | 'Underscore.js result:\n' + result,
13 | EclipseLabelType.kT7
14 | );
15 | node.setAlignment(Alignment.CENTER_CENTER);
16 | node.setTextAlignment(HorizontalTextAlignment.kCenter);
17 | return node;
18 | }
19 |
--------------------------------------------------------------------------------
/sample-eyetracking/.eslintrc.js:
--------------------------------------------------------------------------------
1 | // ESLint config for MagicScript Apps
2 | module.exports = {
3 | env: {
4 | "es6": true
5 | },
6 | globals: {
7 | // These globals are provided by the vm itself.
8 | "print": true,
9 | "globalThis": true,
10 | // The following globals are provided by `magic-script-polyfills`
11 | "setTimeout": true,
12 | "clearTimeout": true,
13 | "setInterval": true,
14 | "clearInterval": true,
15 | "setImmediate": true,
16 | "clearImmediate": true,
17 | "fetch": true,
18 | "Headers": true,
19 | "Request": true,
20 | "Response": true,
21 |
22 | },
23 | parserOptions: {
24 | "ecmaVersion": 2018,
25 | "sourceType": "module"
26 | },
27 | extends: "semistandard",
28 | };
--------------------------------------------------------------------------------
/sample-eyetracking/.gitignore:
--------------------------------------------------------------------------------
1 | /.out/
2 | /node_modules/
3 | /bin/
4 | !/bin/index.js
5 | /digest.sha512.signed
6 |
--------------------------------------------------------------------------------
/sample-eyetracking/app.mabu:
--------------------------------------------------------------------------------
1 | KIND = program
2 |
--------------------------------------------------------------------------------
/sample-eyetracking/app.package:
--------------------------------------------------------------------------------
1 | DATAS = "digest.sha512.signed" : "." \
2 | "bin/" : "bin/" \
3 | "res/" : "res/"
4 | OPTIONS = package/minApiLevel/2
5 | OUTNAME = app
6 |
--------------------------------------------------------------------------------
/sample-eyetracking/manifest.xml:
--------------------------------------------------------------------------------
1 |
5 |
8 |
12 |
13 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/sample-eyetracking/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "scripts": {
3 | "build": "rollup -c",
4 | "start": "magic-script run"
5 | },
6 | "private": true,
7 | "devDependencies": {
8 | "eslint-config-semistandard": "^13.0.0",
9 | "eslint-config-standard": "^12.0.0",
10 | "eslint-plugin-import": "^2.16.0",
11 | "eslint-plugin-node": "^8.0.1",
12 | "eslint-plugin-promise": "^4.0.1",
13 | "eslint-plugin-standard": "^4.0.0",
14 | "rollup": "^1.1.2",
15 | "rollup-plugin-commonjs": "^9.3.4",
16 | "rollup-plugin-node-resolve": "^4.0.0",
17 | "semistandard": "^13.0.1"
18 | },
19 | "dependencies": {
20 | "gl-matrix": "^3.0.0",
21 | "magic-script-polyfills": "^1.0.0"
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/sample-eyetracking/res/Cube.fbx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/magic-script/magic-script-samples/12be913cc2f84f4d1bf706c15057ea0d4fc1d55c/sample-eyetracking/res/Cube.fbx
--------------------------------------------------------------------------------
/sample-eyetracking/res/blink.mp3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/magic-script/magic-script-samples/12be913cc2f84f4d1bf706c15057ea0d4fc1d55c/sample-eyetracking/res/blink.mp3
--------------------------------------------------------------------------------
/sample-eyetracking/res/capsule.fbx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/magic-script/magic-script-samples/12be913cc2f84f4d1bf706c15057ea0d4fc1d55c/sample-eyetracking/res/capsule.fbx
--------------------------------------------------------------------------------
/sample-eyetracking/res/capsule.mtl:
--------------------------------------------------------------------------------
1 | # Blender MTL File: 'Capsule.blend'
2 | # Material Count: 1
3 |
4 | newmtl Material.001
5 | Ns 96.078431
6 | Ka 1.000000 1.000000 1.000000
7 | Kd 0.640000 0.640000 0.640000
8 | Ks 0.500000 0.500000 0.500000
9 | Ke 0.000000 0.000000 0.000000
10 | Ni 1.000000
11 | d 1.000000
12 | illum 2
13 | map_Kd checker.png
14 |
--------------------------------------------------------------------------------
/sample-eyetracking/res/checker.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/magic-script/magic-script-samples/12be913cc2f84f4d1bf706c15057ea0d4fc1d55c/sample-eyetracking/res/checker.png
--------------------------------------------------------------------------------
/sample-eyetracking/res/cube.mtl:
--------------------------------------------------------------------------------
1 | # Blender MTL File: 'Cube.blend'
2 | # Material Count: 1
3 |
4 | newmtl Material
5 | Ns 96.078431
6 | Ka 1.000000 1.000000 1.000000
7 | Kd 0.640000 0.640000 0.640000
8 | Ks 0.500000 0.500000 0.500000
9 | Ke 0.000000 0.000000 0.000000
10 | Ni 1.000000
11 | d 1.000000
12 | illum 2
13 | map_Kd checker.png
14 |
--------------------------------------------------------------------------------
/sample-eyetracking/res/fixation_violation.mp3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/magic-script/magic-script-samples/12be913cc2f84f4d1bf706c15057ea0d4fc1d55c/sample-eyetracking/res/fixation_violation.mp3
--------------------------------------------------------------------------------
/sample-eyetracking/res/icon/InsidePortal/gradient.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/magic-script/magic-script-samples/12be913cc2f84f4d1bf706c15057ea0d4fc1d55c/sample-eyetracking/res/icon/InsidePortal/gradient.png
--------------------------------------------------------------------------------
/sample-eyetracking/res/icon/InsidePortal/portal.mtl:
--------------------------------------------------------------------------------
1 |
2 | newmtl spherical_back_01
3 | Ns 254.901961
4 | Ka 0.000000 0.000000 0.000000
5 | Kd 0.480000 0.480000 0.480000
6 | Ks 0.040000 0.040000 0.040000
7 | Ke 0.000000 0.000000 0.000000
8 | Ni 1.000000
9 | d 1.000000
10 | illum 2
11 | map_Kd gradient.png
12 |
--------------------------------------------------------------------------------
/sample-eyetracking/res/icon/OutsidePortal/Leaper.fbx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/magic-script/magic-script-samples/12be913cc2f84f4d1bf706c15057ea0d4fc1d55c/sample-eyetracking/res/icon/OutsidePortal/Leaper.fbx
--------------------------------------------------------------------------------
/sample-eyetracking/res/icon/OutsidePortal/Leaper.kmat:
--------------------------------------------------------------------------------
1 | {"global":{"shaderName":"UnlitTextured","albedo":"res/icon/OutsidePortal/Leaper.png","opaque":true,"color":[1,1,1,1]},"materials":[{"name": "Leaper", "opaque": "true"}]}
2 |
--------------------------------------------------------------------------------
/sample-eyetracking/res/icon/OutsidePortal/Leaper.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/magic-script/magic-script-samples/12be913cc2f84f4d1bf706c15057ea0d4fc1d55c/sample-eyetracking/res/icon/OutsidePortal/Leaper.png
--------------------------------------------------------------------------------
/sample-eyetracking/res/left_blink.mp3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/magic-script/magic-script-samples/12be913cc2f84f4d1bf706c15057ea0d4fc1d55c/sample-eyetracking/res/left_blink.mp3
--------------------------------------------------------------------------------
/sample-eyetracking/res/plane.fbx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/magic-script/magic-script-samples/12be913cc2f84f4d1bf706c15057ea0d4fc1d55c/sample-eyetracking/res/plane.fbx
--------------------------------------------------------------------------------
/sample-eyetracking/res/plane.mtl:
--------------------------------------------------------------------------------
1 | # Blender MTL File: 'None'
2 | # Material Count: 1
3 |
4 | newmtl Material.001
5 | Ns 96.078431
6 | Ka 1.000000 1.000000 1.000000
7 | Kd 0.640000 0.640000 0.640000
8 | Ks 0.500000 0.500000 0.500000
9 | Ke 0.000000 0.000000 0.000000
10 | Ni 1.000000
11 | d 1.000000
12 | illum 2
13 | map_Kd checker.png
14 |
--------------------------------------------------------------------------------
/sample-eyetracking/res/plane.obj:
--------------------------------------------------------------------------------
1 | # Blender v2.79 (sub 0) OBJ File: ''
2 | # www.blender.org
3 | mtllib plane.mtl
4 | o Plane
5 | v -0.000000 0.500000 0.500000
6 | v 0.000000 -0.500000 0.500000
7 | v -0.000000 0.500000 -0.500000
8 | v 0.000000 -0.500000 -0.500000
9 | vt 0.000000 1.000000
10 | vt 0.000000 0.000000
11 | vt 1.000000 0.000000
12 | vt 1.000000 1.000000
13 | vn 1.0000 0.0000 -0.0000
14 | usemtl Material.001
15 | s off
16 | f 1/1/1 2/2/1 4/3/1 3/4/1
17 |
--------------------------------------------------------------------------------
/sample-eyetracking/res/readme.txt:
--------------------------------------------------------------------------------
1 | Add your resources here
2 |
--------------------------------------------------------------------------------
/sample-eyetracking/res/right_blink.mp3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/magic-script/magic-script-samples/12be913cc2f84f4d1bf706c15057ea0d4fc1d55c/sample-eyetracking/res/right_blink.mp3
--------------------------------------------------------------------------------
/sample-eyetracking/res/sphere.fbx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/magic-script/magic-script-samples/12be913cc2f84f4d1bf706c15057ea0d4fc1d55c/sample-eyetracking/res/sphere.fbx
--------------------------------------------------------------------------------
/sample-eyetracking/res/sphere.mtl:
--------------------------------------------------------------------------------
1 | # Blender MTL File: 'None'
2 | # Material Count: 1
3 |
4 | newmtl Material.001
5 | Ns 96.078431
6 | Ka 1.000000 1.000000 1.000000
7 | Kd 0.640000 0.640000 0.640000
8 | Ks 0.500000 0.500000 0.500000
9 | Ke 0.000000 0.000000 0.000000
10 | Ni 1.000000
11 | d 1.000000
12 | illum 2
13 | map_Kd checker.png
14 |
--------------------------------------------------------------------------------
/sample-eyetracking/rollup.config.js:
--------------------------------------------------------------------------------
1 | // Rollup config for consuming some npm modules in MagicScript
2 |
3 | import resolve from 'rollup-plugin-node-resolve';
4 | import commonjs from 'rollup-plugin-commonjs';
5 |
6 | export default {
7 | external: ['uv', 'lumin'],
8 | input: 'src/main.js',
9 | preserveModules: true,
10 | output: {
11 | dir: 'bin',
12 | format: 'es'
13 | },
14 | plugins: [resolve(), commonjs()]
15 | };
16 |
--------------------------------------------------------------------------------
/sample-eyetracking/src/app.js:
--------------------------------------------------------------------------------
1 | import { LandscapeApp } from "lumin"
2 | import { SceneManager } from "./SceneManager.js"
3 |
4 | import { EyeFixation } from "./EyeFixation.js"
5 | import { EyeOrientation } from "./EyeOrientation.js"
6 |
7 | export class App extends LandscapeApp {
8 | init() {
9 | let prism = this.requestNewPrism([2, 2, 2]);
10 | this.setCollisionsEnabled(prism, false);
11 | prism.app = this;
12 | let sceneManager = new SceneManager(prism);
13 | sceneManager.addScene(new EyeFixation("EyeFixation"));
14 | sceneManager.addScene(new EyeOrientation("EyeOrientation"));
15 | return 0;
16 | }
17 | updateLoop(delta) {
18 | return true;
19 | }
20 | eventListener(event) {
21 | return false;
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/sample-eyetracking/src/main.js:
--------------------------------------------------------------------------------
1 | // Add support for things like setTimeout, setInterval and fetch.
2 | // Simply importing this sets all these as global definitions.
3 | // They are declared in the .eslintrc so your editor won't complain.
4 | import 'magic-script-polyfills';
5 |
6 | // Load main app logic from the app class.
7 | import { App } from './app.js';
8 |
9 | // Launch our app!
10 | // The 0.5 value is the number of seconds to call `updateLoop` in an interval if
11 | // there are no other events waking the event loop.
12 | export default new App(0.5);
13 |
--------------------------------------------------------------------------------
/sample-fetch-image/.npmignore:
--------------------------------------------------------------------------------
1 | /.out/
2 | /node_modules/
3 | /bin/
4 | /digest.sha512.signed
5 |
--------------------------------------------------------------------------------
/sample-fetch-image/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | {
2 | // Use IntelliSense to learn about possible attributes.
3 | // Hover to view descriptions of existing attributes.
4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5 | "version": "0.2.0",
6 | "configurations": [
7 | {
8 | "type": "node",
9 | "request": "attach",
10 | "name": "Attach Program",
11 | "address": "127.0.0.1",
12 | "port": 9229,
13 | "localRoot": "${workspaceFolder}/bin",
14 | "remoteRoot": ".",
15 | "protocol": "inspector"
16 | }
17 | ]
18 | }
19 |
--------------------------------------------------------------------------------
/sample-fetch-image/README.md:
--------------------------------------------------------------------------------
1 | # Fetch Image Sample
2 |
3 | This app explaining how to use [Fetch API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API) built into MagicScript to load remote image file over HTTP and use it with UiImage.
4 |
5 | ## Usage
6 |
7 | See the [README](../README.md) file for details
8 |
9 | ## License
10 |
11 | This project is licensed under the Apache 2.0 License - see the [LICENSE](../LICENSE) file for details
12 |
--------------------------------------------------------------------------------
/sample-fetch-image/app.mabu:
--------------------------------------------------------------------------------
1 | KIND = program
2 |
--------------------------------------------------------------------------------
/sample-fetch-image/app.package:
--------------------------------------------------------------------------------
1 | DATAS = "digest.sha512.signed" : "." \
2 | "bin/" : "bin/"
3 | OPTIONS = package/minApiLevel/2
4 |
--------------------------------------------------------------------------------
/sample-fetch-image/bin/index.js:
--------------------------------------------------------------------------------
1 | #!/system/bin/script/mxs
2 | import './src/main.js';
3 |
--------------------------------------------------------------------------------
/sample-fetch-image/manifest.xml:
--------------------------------------------------------------------------------
1 |
5 |
8 |
12 |
13 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/sample-fetch-image/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "scripts": {
3 | "build": "rollup -c",
4 | "start": "magic-script run"
5 | },
6 | "private": true,
7 | "devDependencies": {
8 | "rollup": "^1.1.2",
9 | "rollup-plugin-commonjs": "^9.3.4",
10 | "rollup-plugin-node-resolve": "^4.0.0"
11 | },
12 | "dependencies": {
13 | "magic-script-polyfills": "^1.0.0"
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/sample-fetch-image/rollup.config.js:
--------------------------------------------------------------------------------
1 | // Rollup config for consuming some npm modules in MagicScript
2 |
3 | import resolve from 'rollup-plugin-node-resolve';
4 | import commonjs from 'rollup-plugin-commonjs';
5 |
6 | export default {
7 | external: ['uv', 'lumin'],
8 | input: 'src/main.js',
9 | preserveModules: true,
10 | output: {
11 | dir: 'bin',
12 | format: 'es'
13 | },
14 | plugins: [resolve(), commonjs()]
15 | };
16 |
--------------------------------------------------------------------------------
/sample-fetch-image/src/App.js:
--------------------------------------------------------------------------------
1 | import { makeText } from "./text.js";
2 | import { makeButton } from "./button.js";
3 |
4 | export default async function start (app) {
5 | let prism = app.requestNewPrism([0.7, 0.5, 0.2]);
6 | // Add text label
7 | let text = makeText(prism);
8 | prism.getRootNode().addChild(text);
9 | text.setLocalPosition([0, 0.2, 0]);
10 | // Add button
11 | let button = makeButton(app, prism, text);
12 | button.setLocalPosition([0, -0.2, 0]);
13 | prism.getRootNode().addChild(button);
14 | return prism;
15 | }
16 |
--------------------------------------------------------------------------------
/sample-fetch-image/src/text.js:
--------------------------------------------------------------------------------
1 | import { ui } from "lumin";
2 |
3 | export function makeText(prism) {
4 | const { UiText, EclipseLabelType, Alignment, HorizontalTextAlignment } = ui;
5 | let node = UiText.CreateEclipseLabel(
6 | prism,
7 | "Press the button\nto fetch network image",
8 | EclipseLabelType.kT5
9 | );
10 | node.setAlignment(Alignment.CENTER_CENTER);
11 | node.setTextAlignment(HorizontalTextAlignment.kCenter);
12 | return node;
13 | }
14 |
--------------------------------------------------------------------------------
/sample-fetch-local-file/.gitignore:
--------------------------------------------------------------------------------
1 | /.out/
2 | /node_modules/
3 | /bin/
4 | /digest.sha512.signed
5 |
--------------------------------------------------------------------------------
/sample-fetch-local-file/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | {
2 | // Use IntelliSense to learn about possible attributes.
3 | // Hover to view descriptions of existing attributes.
4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5 | "version": "0.2.0",
6 | "configurations": [
7 | {
8 | "type": "node",
9 | "request": "attach",
10 | "name": "Attach Program",
11 | "address": "127.0.0.1",
12 | "port": 9229,
13 | "localRoot": "${workspaceFolder}/bin",
14 | "remoteRoot": ".",
15 | "protocol": "inspector"
16 | }
17 | ]
18 | }
19 |
--------------------------------------------------------------------------------
/sample-fetch-local-file/README.md:
--------------------------------------------------------------------------------
1 | # Fetch Local File Sample
2 |
3 | This app explaining how to use [Fetch API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API) built into MagicScript to load local JSON file.
4 |
5 | ## Usage
6 |
7 | See the [README](../README.md) file for details
8 |
9 | ## License
10 |
11 | This project is licensed under the Apache 2.0 License - see the [LICENSE](../LICENSE) file for details
12 |
--------------------------------------------------------------------------------
/sample-fetch-local-file/app.mabu:
--------------------------------------------------------------------------------
1 | KIND = program
2 |
--------------------------------------------------------------------------------
/sample-fetch-local-file/app.package:
--------------------------------------------------------------------------------
1 | DATAS = "digest.sha512.signed" : "." \
2 | "bin/" : "bin/" \
3 | "res/" : "res/"
4 | OPTIONS = package/minApiLevel/2
5 |
--------------------------------------------------------------------------------
/sample-fetch-local-file/bin/index.js:
--------------------------------------------------------------------------------
1 | #!/system/bin/script/mxs
2 | import './src/main.js';
3 |
--------------------------------------------------------------------------------
/sample-fetch-local-file/manifest.xml:
--------------------------------------------------------------------------------
1 |
5 |
8 |
12 |
13 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/sample-fetch-local-file/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "scripts": {
3 | "build": "rollup -c",
4 | "start": "magic-script run"
5 | },
6 | "private": true,
7 | "devDependencies": {
8 | "rollup": "^1.1.2",
9 | "rollup-plugin-commonjs": "^9.2.0",
10 | "rollup-plugin-node-resolve": "^4.0.0"
11 | },
12 | "dependencies": {
13 | "magic-script-polyfills": "^1.0.0"
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/sample-fetch-local-file/res/products.json:
--------------------------------------------------------------------------------
1 | {
2 | "products": [
3 | { "Name": "Cheese", "Price": 2.5, "Location": "Refrigerated foods" },
4 | { "Name": "Crisps", "Price": 3, "Location": "the Snack isle" },
5 | { "Name": "Pizza", "Price": 4, "Location": "Refrigerated foods" },
6 | { "Name": "Chocolate", "Price": 1.5, "Location": "the Snack isle" },
7 | { "Name": "Self-raising flour", "Price": 1.5, "Location": "Home baking" },
8 | { "Name": "Ground almonds", "Price": 3, "Location": "Home baking" }
9 | ]
10 | }
11 |
--------------------------------------------------------------------------------
/sample-fetch-local-file/rollup.config.js:
--------------------------------------------------------------------------------
1 | // Rollup config for consuming some npm modules in MagicScript
2 |
3 | import resolve from 'rollup-plugin-node-resolve';
4 | import commonjs from 'rollup-plugin-commonjs';
5 |
6 | export default {
7 | external: ['uv', 'lumin'],
8 | input: 'src/main.js',
9 | preserveModules: true,
10 | output: {
11 | dir: 'bin',
12 | format: 'es'
13 | },
14 | plugins: [resolve(), commonjs()]
15 | };
16 |
--------------------------------------------------------------------------------
/sample-fetch-local-file/src/App.js:
--------------------------------------------------------------------------------
1 | import { makeText } from './text.js';
2 | import { makeButton } from './button.js';
3 |
4 | export default async function start (app) {
5 | let prism = app.requestNewPrism([0.7, 0.5, 0.2]);
6 | // Add text label
7 | let text = makeText(prism);
8 | prism.getRootNode().addChild(text);
9 | text.setLocalPosition([0, 0.1, 0]);
10 | // Add button
11 | let button = makeButton(prism, text);
12 | button.setLocalPosition([0, -0.1, 0]);
13 | prism.getRootNode().addChild(button);
14 | return prism;
15 | }
16 |
--------------------------------------------------------------------------------
/sample-fetch-local-file/src/text.js:
--------------------------------------------------------------------------------
1 | import { ui } from 'lumin';
2 |
3 | export function makeText(prism) {
4 | const { UiText, EclipseLabelType, Alignment, HorizontalTextAlignment } = ui;
5 | let node = UiText.CreateEclipseLabel(
6 | prism,
7 | 'Hello\nMagicScript!',
8 | EclipseLabelType.kT5
9 | );
10 | node.setAlignment(Alignment.CENTER_CENTER);
11 | node.setTextAlignment(HorizontalTextAlignment.kCenter);
12 | return node;
13 | }
14 |
--------------------------------------------------------------------------------
/sample-fetch-remote-file/.gitignore:
--------------------------------------------------------------------------------
1 | /.out/
2 | /node_modules/
3 | /bin/
4 | /digest.sha512.signed
5 |
--------------------------------------------------------------------------------
/sample-fetch-remote-file/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | {
2 | // Use IntelliSense to learn about possible attributes.
3 | // Hover to view descriptions of existing attributes.
4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5 | "version": "0.2.0",
6 | "configurations": [
7 | {
8 | "type": "node",
9 | "request": "attach",
10 | "name": "Attach Program",
11 | "address": "127.0.0.1",
12 | "port": 9229,
13 | "localRoot": "${workspaceFolder}/bin",
14 | "remoteRoot": ".",
15 | "protocol": "inspector"
16 | }
17 | ]
18 | }
19 |
--------------------------------------------------------------------------------
/sample-fetch-remote-file/README.md:
--------------------------------------------------------------------------------
1 | # Fetch Remote File Sample
2 |
3 | This app explaining how to use [Fetch API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API) built into MagicScript to load remote file over HTTP.
4 |
5 | ## Usage
6 |
7 | See the [README](../README.md) file for details
8 |
9 | ## License
10 |
11 | This project is licensed under the Apache 2.0 License - see the [LICENSE](../LICENSE) file for details
12 |
--------------------------------------------------------------------------------
/sample-fetch-remote-file/app.mabu:
--------------------------------------------------------------------------------
1 | KIND = program
2 |
--------------------------------------------------------------------------------
/sample-fetch-remote-file/app.package:
--------------------------------------------------------------------------------
1 | DATAS = "digest.sha512.signed" : "." \
2 | "bin/" : "bin/"
3 | OPTIONS = package/minApiLevel/2
4 |
--------------------------------------------------------------------------------
/sample-fetch-remote-file/bin/index.js:
--------------------------------------------------------------------------------
1 | #!/system/bin/script/mxs
2 | import './src/main.js';
3 |
--------------------------------------------------------------------------------
/sample-fetch-remote-file/manifest.xml:
--------------------------------------------------------------------------------
1 |
5 |
8 |
12 |
13 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/sample-fetch-remote-file/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "scripts": {
3 | "build": "rollup -c",
4 | "start": "magic-script run"
5 | },
6 | "private": true,
7 | "devDependencies": {
8 | "rollup": "^1.1.2",
9 | "rollup-plugin-commonjs": "^9.2.0",
10 | "rollup-plugin-node-resolve": "^4.0.0"
11 | },
12 | "dependencies": {
13 | "magic-script-polyfills": "^1.0.0"
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/sample-fetch-remote-file/rollup.config.js:
--------------------------------------------------------------------------------
1 | // Rollup config for consuming some npm modules in MagicScript
2 |
3 | import resolve from 'rollup-plugin-node-resolve';
4 | import commonjs from 'rollup-plugin-commonjs';
5 |
6 | export default {
7 | external: ['uv', 'lumin'],
8 | input: 'src/main.js',
9 | preserveModules: true,
10 | output: {
11 | dir: 'bin',
12 | format: 'es'
13 | },
14 | plugins: [resolve(), commonjs()]
15 | };
16 |
--------------------------------------------------------------------------------
/sample-fetch-remote-file/src/App.js:
--------------------------------------------------------------------------------
1 | import { makeText } from './text.js';
2 | import { makeButton } from './button.js';
3 |
4 | export default async function start (app) {
5 | let prism = app.requestNewPrism([0.7, 0.5, 0.2]);
6 | // Add text label
7 | let text = makeText(prism);
8 | prism.getRootNode().addChild(text);
9 | text.setLocalPosition([0, 0.1, 0]);
10 | // Add button
11 | let button = makeButton(prism, text);
12 | button.setLocalPosition([0, -0.1, 0]);
13 | prism.getRootNode().addChild(button);
14 | return prism;
15 | }
16 |
--------------------------------------------------------------------------------
/sample-fetch-remote-file/src/button.js:
--------------------------------------------------------------------------------
1 | //
2 | import { ui } from "lumin";
3 |
4 | async function basicFetch(text) {
5 | text.setText("basicFetch - start");
6 | let response = await fetch("http://jsonplaceholder.typicode.com/todos/1");
7 | if (!response.ok) {
8 | throw new Error("HTTP error, status = " + response.status);
9 | }
10 | let json = await response.json();
11 | console.log(json);
12 |
13 | let string = "basicFetch - Success:\n";
14 | string += JSON.stringify(json);
15 | text.setText(string);
16 | }
17 |
18 | export function makeButton(prism, text) {
19 | const { UiButton, EclipseButtonParams, EclipseButtonType } = ui;
20 | let prms = new EclipseButtonParams(EclipseButtonType.kText, "Press me");
21 | let node = UiButton.CreateEclipseButton(prism, prms);
22 | node.onActivateSub(uiEventData => {
23 | basicFetch(text).catch(error => {
24 | text.setText("basicFetch - Error: " + error.message);
25 | });
26 | });
27 | return node;
28 | }
29 |
--------------------------------------------------------------------------------
/sample-fetch-remote-file/src/text.js:
--------------------------------------------------------------------------------
1 | import { ui } from 'lumin';
2 |
3 | export function makeText(prism) {
4 | const { UiText, EclipseLabelType, Alignment, HorizontalTextAlignment } = ui;
5 | let node = UiText.CreateEclipseLabel(
6 | prism,
7 | 'Hello\nMagicScript!',
8 | EclipseLabelType.kT5
9 | );
10 | node.setAlignment(Alignment.CENTER_CENTER);
11 | node.setTextAlignment(HorizontalTextAlignment.kCenter);
12 | return node;
13 | }
14 |
--------------------------------------------------------------------------------
/sample-gestures/.eslintrc.js:
--------------------------------------------------------------------------------
1 | // ESLint config for MagicScript Apps
2 | module.exports = {
3 | env: {
4 | "es6": true
5 | },
6 | globals: {
7 | // These globals are provided by the vm itself.
8 | "print": true,
9 | "globalThis": true,
10 | // The following globals are provided by `magic-script-polyfills`
11 | "setTimeout": true,
12 | "clearTimeout": true,
13 | "setInterval": true,
14 | "clearInterval": true,
15 | "setImmediate": true,
16 | "clearImmediate": true,
17 | "fetch": true,
18 | "Headers": true,
19 | "Request": true,
20 | "Response": true,
21 |
22 | },
23 | parserOptions: {
24 | "ecmaVersion": 2018,
25 | "sourceType": "module"
26 | },
27 | extends: "semistandard",
28 | };
--------------------------------------------------------------------------------
/sample-gestures/.gitignore:
--------------------------------------------------------------------------------
1 | /.out/
2 | /node_modules/
3 | /bin/
4 | !/bin/index.js
5 | /digest.sha512.signed
6 |
--------------------------------------------------------------------------------
/sample-gestures/app.mabu:
--------------------------------------------------------------------------------
1 | KIND = program
2 |
--------------------------------------------------------------------------------
/sample-gestures/app.package:
--------------------------------------------------------------------------------
1 | DATAS = res/ : res/ \
2 | "digest.sha512.signed" : "." \
3 | "bin/" : "bin/"
4 | OPTIONS = package/minApiLevel/2
5 | OUTNAME=app
6 |
--------------------------------------------------------------------------------
/sample-gestures/manifest.xml:
--------------------------------------------------------------------------------
1 |
5 |
8 |
12 |
13 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/sample-gestures/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "scripts": {
3 | "build": "rollup -c",
4 | "start": "magic-script run"
5 | },
6 | "private": true,
7 | "devDependencies": {
8 | "eslint-config-semistandard": "^13.0.0",
9 | "eslint-config-standard": "^12.0.0",
10 | "eslint-plugin-import": "^2.16.0",
11 | "eslint-plugin-node": "^8.0.1",
12 | "eslint-plugin-promise": "^4.0.1",
13 | "eslint-plugin-standard": "^4.0.0",
14 | "rollup": "^1.1.2",
15 | "rollup-plugin-commonjs": "^9.3.4",
16 | "rollup-plugin-node-resolve": "^4.0.0",
17 | "semistandard": "^13.0.1"
18 | },
19 | "dependencies": {
20 | "gl-matrix": "^3.0.0",
21 | "magic-script-polyfills": "^1.0.0"
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/sample-gestures/res/Gesture_C.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/magic-script/magic-script-samples/12be913cc2f84f4d1bf706c15057ea0d4fc1d55c/sample-gestures/res/Gesture_C.png
--------------------------------------------------------------------------------
/sample-gestures/res/Gesture_Finger.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/magic-script/magic-script-samples/12be913cc2f84f4d1bf706c15057ea0d4fc1d55c/sample-gestures/res/Gesture_Finger.png
--------------------------------------------------------------------------------
/sample-gestures/res/Gesture_Fist.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/magic-script/magic-script-samples/12be913cc2f84f4d1bf706c15057ea0d4fc1d55c/sample-gestures/res/Gesture_Fist.png
--------------------------------------------------------------------------------
/sample-gestures/res/Gesture_L.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/magic-script/magic-script-samples/12be913cc2f84f4d1bf706c15057ea0d4fc1d55c/sample-gestures/res/Gesture_L.png
--------------------------------------------------------------------------------
/sample-gestures/res/Gesture_Ok.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/magic-script/magic-script-samples/12be913cc2f84f4d1bf706c15057ea0d4fc1d55c/sample-gestures/res/Gesture_Ok.png
--------------------------------------------------------------------------------
/sample-gestures/res/Gesture_OpenHand.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/magic-script/magic-script-samples/12be913cc2f84f4d1bf706c15057ea0d4fc1d55c/sample-gestures/res/Gesture_OpenHand.png
--------------------------------------------------------------------------------
/sample-gestures/res/Gesture_Pinch.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/magic-script/magic-script-samples/12be913cc2f84f4d1bf706c15057ea0d4fc1d55c/sample-gestures/res/Gesture_Pinch.png
--------------------------------------------------------------------------------
/sample-gestures/res/Gesture_Thumb.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/magic-script/magic-script-samples/12be913cc2f84f4d1bf706c15057ea0d4fc1d55c/sample-gestures/res/Gesture_Thumb.png
--------------------------------------------------------------------------------
/sample-gestures/res/Objects.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/sample-gestures/res/Resources.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/sample-gestures/res/Sphere_P.FBX:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/magic-script/magic-script-samples/12be913cc2f84f4d1bf706c15057ea0d4fc1d55c/sample-gestures/res/Sphere_P.FBX
--------------------------------------------------------------------------------
/sample-gestures/rollup.config.js:
--------------------------------------------------------------------------------
1 | // Rollup config for consuming some npm modules in MagicScript
2 |
3 | import resolve from 'rollup-plugin-node-resolve';
4 | import commonjs from 'rollup-plugin-commonjs';
5 |
6 | export default {
7 | external: ['uv', 'lumin'],
8 | input: 'src/main.js',
9 | preserveModules: true,
10 | output: {
11 | dir: 'bin',
12 | format: 'es'
13 | },
14 | plugins: [resolve(), commonjs()]
15 | };
16 |
--------------------------------------------------------------------------------
/sample-gestures/src/main.js:
--------------------------------------------------------------------------------
1 | // Add support for things like setTimeout, setInterval and fetch.
2 | // Simply importing this sets all these as global definitions.
3 | // They are declared in the .eslintrc so your editor won't complain.
4 | import 'magic-script-polyfills';
5 |
6 | // Load main app logic from the app class.
7 | import { App } from './app.js';
8 |
9 | // Launch our app!
10 | // The 0.5 value is the number of seconds to call `updateLoop` in an interval if
11 | // there are no other events waking the event loop.
12 | export default new App(0.5);
13 |
--------------------------------------------------------------------------------
/sample-immersive-app/.gitignore:
--------------------------------------------------------------------------------
1 | /.out/
2 | /node_modules/
3 | /bin/
4 | /digest.sha512.signed
5 |
--------------------------------------------------------------------------------
/sample-immersive-app/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | {
2 | // Use IntelliSense to learn about possible attributes.
3 | // Hover to view descriptions of existing attributes.
4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5 | "version": "0.2.0",
6 | "configurations": [
7 | {
8 | "type": "node",
9 | "request": "attach",
10 | "name": "Attach Program",
11 | "address": "127.0.0.1",
12 | "port": 9229,
13 | "localRoot": "${workspaceFolder}/bin",
14 | "remoteRoot": ".",
15 | "protocol": "inspector"
16 | }
17 | ]
18 | }
19 |
--------------------------------------------------------------------------------
/sample-immersive-app/README.md:
--------------------------------------------------------------------------------
1 | # Immersive App Sample
2 |
3 | Immersive App Sample demoing how to create immersive app with MagicScript
4 |
5 | ## Usage
6 |
7 | See the [README](../README.md) file for details
8 |
9 | ## License
10 |
11 | This project is licensed under the Apache 2.0 License - see the [LICENSE](../LICENSE) file for details
12 |
--------------------------------------------------------------------------------
/sample-immersive-app/app.mabu:
--------------------------------------------------------------------------------
1 | KIND = program
2 |
--------------------------------------------------------------------------------
/sample-immersive-app/app.package:
--------------------------------------------------------------------------------
1 | DATAS = "digest.sha512.signed" : "." \
2 | "bin/" : "bin/"
3 | OPTIONS = package/minApiLevel/2
4 |
--------------------------------------------------------------------------------
/sample-immersive-app/bin/index.js:
--------------------------------------------------------------------------------
1 | #!/system/bin/script/mxs
2 | import './src/main.js';
3 |
--------------------------------------------------------------------------------
/sample-immersive-app/manifest.xml:
--------------------------------------------------------------------------------
1 |
5 |
8 |
12 |
13 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/sample-immersive-app/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "scripts": {
3 | "build": "rollup -c",
4 | "start": "magic-script run"
5 | },
6 | "private": true,
7 | "devDependencies": {
8 | "rollup": "^1.1.2",
9 | "rollup-plugin-commonjs": "^9.2.0",
10 | "rollup-plugin-node-resolve": "^4.0.0"
11 | },
12 | "dependencies": {
13 | "magic-script-polyfills": "^1.0.0"
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/sample-immersive-app/rollup.config.js:
--------------------------------------------------------------------------------
1 | // Rollup config for consuming some npm modules in MagicScript
2 |
3 | import resolve from 'rollup-plugin-node-resolve';
4 | import commonjs from 'rollup-plugin-commonjs';
5 |
6 | export default {
7 | external: ['uv', 'lumin'],
8 | input: 'src/main.js',
9 | preserveModules: true,
10 | output: {
11 | dir: 'bin',
12 | format: 'es'
13 | },
14 | plugins: [resolve(), commonjs()]
15 | };
16 |
--------------------------------------------------------------------------------
/sample-immersive-app/src/App.js:
--------------------------------------------------------------------------------
1 |
2 | export default async function start (app) {
3 | let prism = app.requestNewPrism([1, 1, 1]);
4 | let node = prism.createLineNode();
5 | node.addPoints([0, 0, 0]);
6 | node.addPoints([1, 1, 1]);
7 |
8 | app.positionPrism(prism, [0, 0, -1]);
9 |
10 | prism.getRootNode().addChild(node);
11 | return prism;
12 | }
13 |
--------------------------------------------------------------------------------
/sample-interval-no-await/.gitignore:
--------------------------------------------------------------------------------
1 | /.out/
2 | /node_modules/
3 | /bin/
4 | /digest.sha512.signed
5 |
--------------------------------------------------------------------------------
/sample-interval-no-await/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | {
2 | // Use IntelliSense to learn about possible attributes.
3 | // Hover to view descriptions of existing attributes.
4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5 | "version": "0.2.0",
6 | "configurations": [
7 | {
8 | "type": "node",
9 | "request": "attach",
10 | "name": "Attach Program",
11 | "address": "127.0.0.1",
12 | "port": 9229,
13 | "localRoot": "${workspaceFolder}/bin",
14 | "remoteRoot": ".",
15 | "protocol": "inspector"
16 | }
17 | ]
18 | }
19 |
--------------------------------------------------------------------------------
/sample-interval-no-await/README.md:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/magic-script/magic-script-samples/12be913cc2f84f4d1bf706c15057ea0d4fc1d55c/sample-interval-no-await/README.md
--------------------------------------------------------------------------------
/sample-interval-no-await/app.mabu:
--------------------------------------------------------------------------------
1 | KIND = program
2 |
--------------------------------------------------------------------------------
/sample-interval-no-await/app.package:
--------------------------------------------------------------------------------
1 | DATAS = "digest.sha512.signed" : "." \
2 | "bin/" : "bin/"
3 | OPTIONS = package/minApiLevel/2
4 |
--------------------------------------------------------------------------------
/sample-interval-no-await/bin/index.js:
--------------------------------------------------------------------------------
1 | #!/system/bin/script/mxs
2 | import './src/main.js';
3 |
--------------------------------------------------------------------------------
/sample-interval-no-await/manifest.xml:
--------------------------------------------------------------------------------
1 |
5 |
8 |
12 |
13 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/sample-interval-no-await/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "scripts": {
3 | "build": "rollup -c",
4 | "start": "magic-script run"
5 | },
6 | "private": true,
7 | "devDependencies": {
8 | "rollup": "^1.1.2",
9 | "rollup-plugin-commonjs": "^9.2.0",
10 | "rollup-plugin-node-resolve": "^4.0.0"
11 | },
12 | "dependencies": {
13 | "magic-script-polyfills": "^1.0.0"
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/sample-interval-no-await/rollup.config.js:
--------------------------------------------------------------------------------
1 | // Rollup config for consuming some npm modules in MagicScript
2 |
3 | import resolve from 'rollup-plugin-node-resolve';
4 | import commonjs from 'rollup-plugin-commonjs';
5 |
6 | export default {
7 | external: ['uv', 'lumin'],
8 | input: 'src/main.js',
9 | preserveModules: true,
10 | output: {
11 | dir: 'bin',
12 | format: 'es'
13 | },
14 | plugins: [resolve(), commonjs()]
15 | };
16 |
--------------------------------------------------------------------------------
/sample-interval-no-await/src/App.js:
--------------------------------------------------------------------------------
1 | import { ui } from 'lumin';
2 |
3 | const INTERVAL_DURATION = 1000; // ms
4 | const MAX_VALUE = 1000;
5 | const INITIAL_VALUE = 1;
6 |
7 | export default async function start (app) {
8 | const prism = app.requestNewPrism([0.5, 0.5, 0.5]);
9 | const text = ui.UiText.CreateEclipseLabel(prism, 'Initial Label', ui.EclipseLabelType.kT3);
10 | text.setAlignment(ui.Alignment.CENTER_CENTER);
11 |
12 | prism.getRootNode().addChild(text);
13 |
14 | let counter = INITIAL_VALUE;
15 | let previousTime = Date.now();
16 |
17 | setInterval(() => {
18 | const currentTime = Date.now();
19 | text.setText(`Update ${counter} in ${currentTime - previousTime} ms`);
20 | previousTime = currentTime;
21 |
22 | if (counter <= MAX_VALUE) {
23 | counter++;
24 | } else {
25 | counter = INITIAL_VALUE;
26 | }
27 | }, INTERVAL_DURATION);
28 |
29 | return prism;
30 | }
31 |
--------------------------------------------------------------------------------
/sample-interval/.gitignore:
--------------------------------------------------------------------------------
1 | /.out/
2 | /node_modules/
3 | /bin/
4 | /digest.sha512.signed
5 |
--------------------------------------------------------------------------------
/sample-interval/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | {
2 | // Use IntelliSense to learn about possible attributes.
3 | // Hover to view descriptions of existing attributes.
4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5 | "version": "0.2.0",
6 | "configurations": [
7 | {
8 | "type": "node",
9 | "request": "attach",
10 | "name": "Attach Program",
11 | "address": "127.0.0.1",
12 | "port": 9229,
13 | "localRoot": "${workspaceFolder}/bin",
14 | "remoteRoot": ".",
15 | "protocol": "inspector"
16 | }
17 | ]
18 | }
19 |
--------------------------------------------------------------------------------
/sample-interval/README.md:
--------------------------------------------------------------------------------
1 | # Interval Sample
2 |
3 | Interval Sample shows how to use [setInterval](https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/setInterval) with MagicScript
4 |
5 | ## Usage
6 |
7 | See the [README](../README.md) file for details
8 |
9 | ## License
10 |
11 | This project is licensed under the Apache 2.0 License - see the [LICENSE](../LICENSE) file for details
12 |
--------------------------------------------------------------------------------
/sample-interval/app.mabu:
--------------------------------------------------------------------------------
1 | KIND = program
2 |
--------------------------------------------------------------------------------
/sample-interval/app.package:
--------------------------------------------------------------------------------
1 | DATAS = "digest.sha512.signed" : "." \
2 | "bin/" : "bin/"
3 | OPTIONS = package/minApiLevel/2
4 |
--------------------------------------------------------------------------------
/sample-interval/bin/index.js:
--------------------------------------------------------------------------------
1 | #!/system/bin/script/mxs
2 | import './src/main.js';
3 |
--------------------------------------------------------------------------------
/sample-interval/manifest.xml:
--------------------------------------------------------------------------------
1 |
5 |
8 |
12 |
13 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/sample-interval/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "scripts": {
3 | "build": "rollup -c",
4 | "start": "magic-script run"
5 | },
6 | "private": true,
7 | "devDependencies": {
8 | "rollup": "^1.1.2",
9 | "rollup-plugin-commonjs": "^9.3.4",
10 | "rollup-plugin-node-resolve": "^4.0.0"
11 | },
12 | "dependencies": {
13 | "magic-script-polyfills": "^1.0.0"
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/sample-interval/rollup.config.js:
--------------------------------------------------------------------------------
1 | // Rollup config for consuming some npm modules in MagicScript
2 |
3 | import resolve from 'rollup-plugin-node-resolve';
4 | import commonjs from 'rollup-plugin-commonjs';
5 |
6 | export default {
7 | external: ['uv', 'lumin'],
8 | input: 'src/main.js',
9 | preserveModules: true,
10 | output: {
11 | dir: 'bin',
12 | format: 'es'
13 | },
14 | plugins: [resolve(), commonjs()]
15 | };
16 |
--------------------------------------------------------------------------------
/sample-interval/src/App.js:
--------------------------------------------------------------------------------
1 | import { ui, LandscapeApp } from 'lumin';
2 | const { UiText, EclipseLabelType, Alignment, HorizontalTextAlignment } = ui;
3 |
4 | let sleep = ms => new Promise(resolve => setTimeout(resolve, ms));
5 |
6 | export default async function start (app) {
7 | let prism = app.requestNewPrism([0.4, 0.1, 0.1]);
8 | let text = UiText.CreateEclipseLabel(
9 | prism,
10 | 'There are no mistakes.',
11 | EclipseLabelType.kT3
12 | );
13 | text.setAlignment(Alignment.CENTER_CENTER);
14 | text.setTextAlignment(HorizontalTextAlignment.kCenter);
15 |
16 | prism.getRootNode().addChild(text);
17 | setInterval(async () => {
18 | text.setText('Only');
19 | await sleep(500);
20 | text.setText('Only happy');
21 | await sleep(500);
22 | text.setText('Only happy little');
23 | await sleep(500);
24 | text.setText('Only happy little accidents!');
25 | }, 5000);
26 | return prism;
27 | }
28 |
--------------------------------------------------------------------------------
/sample-landscape-app/.gitignore:
--------------------------------------------------------------------------------
1 | /.out/
2 | /node_modules/
3 | /bin/
4 | /digest.sha512.signed
5 |
--------------------------------------------------------------------------------
/sample-landscape-app/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | {
2 | // Use IntelliSense to learn about possible attributes.
3 | // Hover to view descriptions of existing attributes.
4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5 | "version": "0.2.0",
6 | "configurations": [
7 | {
8 | "type": "node",
9 | "request": "attach",
10 | "name": "Attach Program",
11 | "address": "127.0.0.1",
12 | "port": 9229,
13 | "localRoot": "${workspaceFolder}/bin",
14 | "remoteRoot": ".",
15 | "protocol": "inspector"
16 | }
17 | ]
18 | }
19 |
--------------------------------------------------------------------------------
/sample-landscape-app/README.md:
--------------------------------------------------------------------------------
1 | # Landscape App Sample
2 |
3 | Landscape App Sample demoing how to create landscape app with MagicScript
4 |
5 | ## Usage
6 |
7 | See the [README](../README.md) file for details
8 |
9 | ## License
10 |
11 | This project is licensed under the Apache 2.0 License - see the [LICENSE](../LICENSE) file for details
12 |
--------------------------------------------------------------------------------
/sample-landscape-app/app.mabu:
--------------------------------------------------------------------------------
1 | KIND = program
2 |
--------------------------------------------------------------------------------
/sample-landscape-app/app.package:
--------------------------------------------------------------------------------
1 | DATAS = "digest.sha512.signed" : "." \
2 | "bin/" : "bin/"
3 | OPTIONS = package/minApiLevel/2
4 |
--------------------------------------------------------------------------------
/sample-landscape-app/bin/index.js:
--------------------------------------------------------------------------------
1 | #!/system/bin/script/mxs
2 | import './src/main.js';
3 |
--------------------------------------------------------------------------------
/sample-landscape-app/manifest.xml:
--------------------------------------------------------------------------------
1 |
5 |
8 |
12 |
13 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/sample-landscape-app/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "scripts": {
3 | "build": "rollup -c",
4 | "start": "magic-script run"
5 | },
6 | "private": true,
7 | "devDependencies": {
8 | "rollup": "^1.1.2",
9 | "rollup-plugin-commonjs": "^9.3.4",
10 | "rollup-plugin-node-resolve": "^4.0.0"
11 | },
12 | "dependencies": {
13 | "magic-script-polyfills": "^1.0.0"
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/sample-landscape-app/rollup.config.js:
--------------------------------------------------------------------------------
1 | // Rollup config for consuming some npm modules in MagicScript
2 |
3 | import resolve from 'rollup-plugin-node-resolve';
4 | import commonjs from 'rollup-plugin-commonjs';
5 |
6 | export default {
7 | external: ['uv', 'lumin'],
8 | input: 'src/main.js',
9 | preserveModules: true,
10 | output: {
11 | dir: 'bin',
12 | format: 'es'
13 | },
14 | plugins: [resolve(), commonjs()]
15 | };
16 |
--------------------------------------------------------------------------------
/sample-landscape-app/src/App.js:
--------------------------------------------------------------------------------
1 |
2 | export default async function start (app) {
3 | let prism = app.requestNewPrism([0.5, 0.5, 0.5]);
4 | let node = prism.createLineNode();
5 | node.addPoints([0, 0, 0]);
6 | node.addPoints([0.5, 0.5, 0.5]);
7 | prism.getRootNode().addChild(node);
8 | return prism;
9 | }
10 |
--------------------------------------------------------------------------------
/sample-model-animated/.gitignore:
--------------------------------------------------------------------------------
1 | /.out/
2 | /node_modules/
3 | /bin/
4 | /digest.sha512.signed
5 |
--------------------------------------------------------------------------------
/sample-model-animated/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | {
2 | // Use IntelliSense to learn about possible attributes.
3 | // Hover to view descriptions of existing attributes.
4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5 | "version": "0.2.0",
6 | "configurations": [
7 | {
8 | "type": "node",
9 | "request": "attach",
10 | "name": "Attach Program",
11 | "address": "127.0.0.1",
12 | "port": 9229,
13 | "localRoot": "${workspaceFolder}/bin",
14 | "remoteRoot": ".",
15 | "protocol": "inspector"
16 | }
17 | ]
18 | }
19 |
--------------------------------------------------------------------------------
/sample-model-animated/app.mabu:
--------------------------------------------------------------------------------
1 | KIND = program
2 |
--------------------------------------------------------------------------------
/sample-model-animated/app.package:
--------------------------------------------------------------------------------
1 | DATAS = "digest.sha512.signed" : "." \
2 | "bin/" : "bin/" \
3 | "resources/" : "resources/"
4 |
5 | OPTIONS = package/minApiLevel/2
6 |
--------------------------------------------------------------------------------
/sample-model-animated/bin/index.js:
--------------------------------------------------------------------------------
1 | #!/system/bin/script/mxs
2 | import './src/main.js';
3 |
--------------------------------------------------------------------------------
/sample-model-animated/manifest.xml:
--------------------------------------------------------------------------------
1 |
5 |
8 |
12 |
13 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/sample-model-animated/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "scripts": {
3 | "build": "rollup -c",
4 | "start": "magic-script run"
5 | },
6 | "private": true,
7 | "devDependencies": {
8 | "rollup": "^1.1.2",
9 | "rollup-plugin-commonjs": "^9.3.4",
10 | "rollup-plugin-node-resolve": "^4.0.0"
11 | },
12 | "dependencies": {
13 | "magic-script-polyfills": "^1.0.0"
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/sample-model-animated/resources/turkey/turkey.kmat:
--------------------------------------------------------------------------------
1 | {
2 | "global": {
3 | "shaderName": "DiffuseNormalSpec",
4 | "albedo": "turkey/turkey_baseColor.png",
5 | "normal": "turkey/turkey_Normal.png",
6 | "roughness": "turkey/turkey_Roughness.png",
7 | "color": [
8 | 1,
9 | 1,
10 | 1,
11 | 1
12 | ]
13 | },
14 | "materials": [
15 | {
16 | "name": "turkey_material",
17 | "opaque": true
18 | }
19 | ]
20 | }
21 |
--------------------------------------------------------------------------------
/sample-model-animated/resources/turkey/turkey4.fbx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/magic-script/magic-script-samples/12be913cc2f84f4d1bf706c15057ea0d4fc1d55c/sample-model-animated/resources/turkey/turkey4.fbx
--------------------------------------------------------------------------------
/sample-model-animated/resources/turkey/turkey_Normal.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/magic-script/magic-script-samples/12be913cc2f84f4d1bf706c15057ea0d4fc1d55c/sample-model-animated/resources/turkey/turkey_Normal.png
--------------------------------------------------------------------------------
/sample-model-animated/resources/turkey/turkey_Roughness.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/magic-script/magic-script-samples/12be913cc2f84f4d1bf706c15057ea0d4fc1d55c/sample-model-animated/resources/turkey/turkey_Roughness.png
--------------------------------------------------------------------------------
/sample-model-animated/resources/turkey/turkey_baseColor.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/magic-script/magic-script-samples/12be913cc2f84f4d1bf706c15057ea0d4fc1d55c/sample-model-animated/resources/turkey/turkey_baseColor.png
--------------------------------------------------------------------------------
/sample-model-animated/rollup.config.js:
--------------------------------------------------------------------------------
1 | // Rollup config for consuming some npm modules in MagicScript
2 |
3 | import resolve from 'rollup-plugin-node-resolve';
4 | import commonjs from 'rollup-plugin-commonjs';
5 |
6 | export default {
7 | external: ['uv', 'lumin'],
8 | input: 'src/main.js',
9 | preserveModules: true,
10 | output: {
11 | dir: 'bin',
12 | format: 'es'
13 | },
14 | plugins: [resolve(), commonjs()]
15 | };
16 |
--------------------------------------------------------------------------------
/sample-model-animated/src/main.js:
--------------------------------------------------------------------------------
1 | // Add support for things like setTimeout, setInterval and fetch.
2 | import 'magic-script-polyfills';
3 |
4 | // Import our main app
5 | import { DynamicFbxScene } from './dynamic-fbx-scene.js';
6 |
7 | // Launch our app!
8 | new DynamicFbxScene(0.5);
9 |
--------------------------------------------------------------------------------
/sample-model-animated/src/scene.js:
--------------------------------------------------------------------------------
1 | import { LandscapeApp } from 'lumin';
2 |
3 | export class Scene extends LandscapeApp {
4 |
5 | constructor (timeDelta, name) {
6 | super(timeDelta);
7 |
8 | this._name = name;
9 | }
10 |
11 | // size is [width, height, depth]
12 | init(size) {
13 | this._prism = this.requestNewPrism(size);
14 | }
15 |
16 | get Prism() {
17 | return this._prism;
18 | }
19 |
20 | addToRootNode(node) {
21 | this._prism.getRootNode().addChild(node);
22 | }
23 | }
--------------------------------------------------------------------------------
/sample-model/.gitignore:
--------------------------------------------------------------------------------
1 | /.out/
2 | /node_modules/
3 | /bin/
4 | !/bin/index.js
5 | /digest.sha512.signed
6 |
--------------------------------------------------------------------------------
/sample-model/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | {
2 | // Use IntelliSense to learn about possible attributes.
3 | // Hover to view descriptions of existing attributes.
4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5 | "version": "0.2.0",
6 | "configurations": [
7 | {
8 | "type": "node",
9 | "request": "attach",
10 | "name": "Attach by Process ID",
11 | "processId": "${command:PickProcess}"
12 | },
13 | {
14 | "type": "node",
15 | "request": "attach",
16 | "name": "Attach Program",
17 | "address": "127.0.0.1",
18 | "port": 9229,
19 | "localRoot": "${workspaceFolder}/bin",
20 | "remoteRoot": ".",
21 | "protocol": "inspector"
22 | }
23 | ]
24 | }
25 |
--------------------------------------------------------------------------------
/sample-model/README.md:
--------------------------------------------------------------------------------
1 | # Model Sample
2 |
3 | MagicScript Model Node Sample
4 |
5 | ## Usage
6 |
7 | See the [README](../README.md) file for details
8 |
9 | ## License
10 |
11 | This project is licensed under the Apache 2.0 License - see the [LICENSE](../LICENSE) file for details
12 |
13 | [Box Textured Model](https://github.com/KhronosGroup/glTF-Sample-Models/tree/master/2.0/BoxTextured) file is licensed under a [Creative Commons Attribution 4.0 International License](http://creativecommons.org/licenses/by/4.0/).
14 |
--------------------------------------------------------------------------------
/sample-model/app.mabu:
--------------------------------------------------------------------------------
1 | KIND = program
2 |
--------------------------------------------------------------------------------
/sample-model/app.package:
--------------------------------------------------------------------------------
1 | DATAS = "digest.sha512.signed" : "." \
2 | "bin/" : "bin/" \
3 | "res/" : "res/"
4 | OPTIONS = package/minApiLevel/2
5 |
--------------------------------------------------------------------------------
/sample-model/bin/index.js:
--------------------------------------------------------------------------------
1 | #!/system/bin/script/mxs
2 | import './src/main.js';
3 |
--------------------------------------------------------------------------------
/sample-model/manifest.xml:
--------------------------------------------------------------------------------
1 |
5 |
8 |
12 |
13 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/sample-model/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "scripts": {
3 | "build": "rollup -c",
4 | "start": "magic-script run"
5 | },
6 | "private": true,
7 | "devDependencies": {
8 | "rollup": "^1.1.2",
9 | "rollup-plugin-commonjs": "^9.3.4",
10 | "rollup-plugin-node-resolve": "^4.0.0"
11 | },
12 | "dependencies": {
13 | "magic-script-polyfills": "^1.0.0"
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/sample-model/res/BoxTextured.glb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/magic-script/magic-script-samples/12be913cc2f84f4d1bf706c15057ea0d4fc1d55c/sample-model/res/BoxTextured.glb
--------------------------------------------------------------------------------
/sample-model/rollup.config.js:
--------------------------------------------------------------------------------
1 | // Rollup config for consuming some npm modules in MagicScript
2 |
3 | import resolve from 'rollup-plugin-node-resolve';
4 | import commonjs from 'rollup-plugin-commonjs';
5 |
6 | export default {
7 | external: ['uv', 'lumin'],
8 | input: 'src/main.js',
9 | preserveModules: true,
10 | output: {
11 | dir: 'bin',
12 | format: 'es'
13 | },
14 | plugins: [resolve(), commonjs()]
15 | };
16 |
--------------------------------------------------------------------------------
/sample-model/src/App.js:
--------------------------------------------------------------------------------
1 | export default async function start (app) {
2 | let prism = app.requestNewPrism([0.5, 0.5, 0.5]);
3 |
4 | let resource = prism.createModelResourceId("res/BoxTextured.glb", 0.3);
5 | let model = prism.createModelNode(resource);
6 |
7 | prism.getRootNode().addChild(model);
8 | return prism;
9 | }
10 |
--------------------------------------------------------------------------------
/sample-prism/.gitignore:
--------------------------------------------------------------------------------
1 | /.out/
2 | /node_modules/
3 | /bin/
4 | !/bin/index.js
5 | /digest.sha512.signed
6 |
--------------------------------------------------------------------------------
/sample-prism/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | {
2 | // Use IntelliSense to learn about possible attributes.
3 | // Hover to view descriptions of existing attributes.
4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5 | "version": "0.2.0",
6 | "configurations": [
7 | {
8 | "type": "node",
9 | "request": "attach",
10 | "name": "Attach Program",
11 | "address": "127.0.0.1",
12 | "port": 9229,
13 | "localRoot": "${workspaceFolder}/bin",
14 | "remoteRoot": ".",
15 | "protocol": "inspector"
16 | }
17 | ]
18 | }
19 |
--------------------------------------------------------------------------------
/sample-prism/README.md:
--------------------------------------------------------------------------------
1 | # Prism Sample
2 |
3 | MagicScript Prism Sample
4 |
5 | ## Usage
6 |
7 | See the [README](../README.md) file for details
8 |
9 | ## License
10 |
11 | This project is licensed under the Apache 2.0 License - see the [LICENSE](../LICENSE) file for details
12 |
13 | [Water Bottle Model](https://github.com/KhronosGroup/glTF-Sample-Models/tree/master/2.0/WaterBottle) file is Creative Commons licensed, as found here [CC0](http://creativecommons.org/publicdomain/zero/1.0/).
14 |
--------------------------------------------------------------------------------
/sample-prism/app.mabu:
--------------------------------------------------------------------------------
1 | KIND = program
2 |
--------------------------------------------------------------------------------
/sample-prism/app.package:
--------------------------------------------------------------------------------
1 | DATAS = "digest.sha512.signed" : "." \
2 | "res/" : "res/" \
3 | "bin/" : "bin/"
4 | OPTIONS = package/minApiLevel/2
5 |
--------------------------------------------------------------------------------
/sample-prism/bin/index.js:
--------------------------------------------------------------------------------
1 | #!/system/bin/script/mxs
2 | import './src/main.js';
3 |
--------------------------------------------------------------------------------
/sample-prism/manifest.xml:
--------------------------------------------------------------------------------
1 |
5 |
8 |
12 |
13 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/sample-prism/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "scripts": {
3 | "build": "rollup -c",
4 | "start": "magic-script run"
5 | },
6 | "private": true,
7 | "devDependencies": {
8 | "rollup": "^1.1.2",
9 | "rollup-plugin-commonjs": "^9.3.4",
10 | "rollup-plugin-node-resolve": "^4.0.0"
11 | },
12 | "dependencies": {
13 | "magic-script-polyfills": "^1.0.0"
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/sample-prism/res/WaterBottle.glb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/magic-script/magic-script-samples/12be913cc2f84f4d1bf706c15057ea0d4fc1d55c/sample-prism/res/WaterBottle.glb
--------------------------------------------------------------------------------
/sample-prism/rollup.config.js:
--------------------------------------------------------------------------------
1 | // Rollup config for consuming some npm modules in MagicScript
2 |
3 | import resolve from 'rollup-plugin-node-resolve';
4 | import commonjs from 'rollup-plugin-commonjs';
5 |
6 | export default {
7 | external: ['uv', 'lumin'],
8 | input: 'src/main.js',
9 | preserveModules: true,
10 | output: {
11 | dir: 'bin',
12 | format: 'es'
13 | },
14 | plugins: [resolve(), commonjs()]
15 | };
16 |
--------------------------------------------------------------------------------
/sample-prism/src/App.js:
--------------------------------------------------------------------------------
1 | export default async function start (app) {
2 |
3 | let prism = app.requestNewPrism([0.2, 0.4, 0.2]);
4 |
5 | let name = 'res/WaterBottle.glb';
6 | let resource = prism.createModelResourceId(name, 1.0);
7 | let model = prism.createModelNode(resource);
8 |
9 | prism.getRootNode().addChild(model);
10 | return prism;
11 | }
12 |
--------------------------------------------------------------------------------
/sample-privilege/.gitignore:
--------------------------------------------------------------------------------
1 | /.out/
2 | /node_modules/
3 | /bin/
4 | !/bin/index.js
5 | /digest.sha512.signed
6 |
--------------------------------------------------------------------------------
/sample-privilege/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | {
2 | // Use IntelliSense to learn about possible attributes.
3 | // Hover to view descriptions of existing attributes.
4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5 | "version": "0.2.0",
6 | "configurations": [
7 | {
8 | "type": "node",
9 | "request": "attach",
10 | "name": "Attach Program",
11 | "address": "127.0.0.1",
12 | "port": 9229,
13 | "localRoot": "${workspaceFolder}/bin",
14 | "remoteRoot": ".",
15 | "protocol": "inspector"
16 | }
17 | ]
18 | }
19 |
--------------------------------------------------------------------------------
/sample-privilege/app.mabu:
--------------------------------------------------------------------------------
1 | KIND = program
2 |
--------------------------------------------------------------------------------
/sample-privilege/app.package:
--------------------------------------------------------------------------------
1 | DATAS = "digest.sha512.signed" : "." \
2 | "bin/" : "bin/"
3 | OPTIONS = package/minApiLevel/2
4 |
--------------------------------------------------------------------------------
/sample-privilege/bin/index.js:
--------------------------------------------------------------------------------
1 | #!/system/bin/script/mxs
2 | import './src/main.js';
3 |
--------------------------------------------------------------------------------
/sample-privilege/manifest.xml:
--------------------------------------------------------------------------------
1 |
5 |
8 |
12 |
13 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/sample-privilege/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "scripts": {
3 | "build": "rollup -c",
4 | "start": "magic-script run"
5 | },
6 | "private": true,
7 | "devDependencies": {
8 | "rollup": "^1.1.2",
9 | "rollup-plugin-commonjs": "^9.3.4",
10 | "rollup-plugin-node-resolve": "^4.0.0"
11 | },
12 | "dependencies": {
13 | "magic-script-polyfills": "^1.0.0"
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/sample-privilege/rollup.config.js:
--------------------------------------------------------------------------------
1 | // Rollup config for consuming some npm modules in MagicScript
2 |
3 | import resolve from 'rollup-plugin-node-resolve';
4 | import commonjs from 'rollup-plugin-commonjs';
5 |
6 | export default {
7 | external: ['uv', 'lumin'],
8 | input: 'src/main.js',
9 | preserveModules: true,
10 | output: {
11 | dir: 'bin',
12 | format: 'es'
13 | },
14 | plugins: [resolve(), commonjs()]
15 | };
16 |
--------------------------------------------------------------------------------
/sample-privilege/src/App.js:
--------------------------------------------------------------------------------
1 | import { ui } from 'lumin';
2 | import { makeButton } from './button.js';
3 |
4 | export default async function start (app) {
5 | let prism = app.requestNewPrism([0.75, 0.75, 0.75]);
6 | let text = ui.UiText.CreateEclipseLabel(
7 | prism,
8 | 'Hello\nMagicScript!',
9 | ui.EclipseLabelType.kT7
10 | );
11 | text.setAlignment(ui.Alignment.CENTER_CENTER);
12 | text.setTextAlignment(ui.HorizontalTextAlignment.kCenter);
13 | prism.getRootNode().addChild(text);
14 |
15 | let button = makeButton(prism, app, text);
16 | button.setLocalPosition([0, -0.15, 0]);
17 | prism.getRootNode().addChild(button);
18 | return prism;
19 | }
20 |
--------------------------------------------------------------------------------
/sample-privilege/src/button.js:
--------------------------------------------------------------------------------
1 | import { ui, PrivilegeId, PrivilegeResult} from 'lumin';
2 |
3 | var counter = 0;
4 |
5 | function onPress(node, app, text) {
6 | console.log('onPress triggered!');
7 | counter++;
8 | var result = app.requestPrivilegeBlocking(PrivilegeId.kLocalAreaNetwork);
9 | print('privilege response', result);
10 | node.setText('Request Again');
11 | text.setText('Privilge ' + ((result == PrivilegeResult.kGranted) ? 'Granted' : 'Not Granted'));
12 | }
13 |
14 | export function makeButton(prism, app, text) {
15 | const { UiButton } = ui;
16 | let node = UiButton.Create(prism, 'Request Privilege', 0, 0.1);
17 | console.log('makeButton');
18 | node.onActivateSub(function (uiEventData) {
19 | onPress(node, app, text);
20 | });
21 | return node;
22 | }
23 |
--------------------------------------------------------------------------------
/sample-promise/.gitignore:
--------------------------------------------------------------------------------
1 | /.out/
2 | /node_modules/
3 | /bin/
4 | !/bin/index.js
5 | /digest.sha512.signed
6 |
--------------------------------------------------------------------------------
/sample-promise/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | {
2 | // Use IntelliSense to learn about possible attributes.
3 | // Hover to view descriptions of existing attributes.
4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5 | "version": "0.2.0",
6 | "configurations": [
7 | {
8 | "type": "node",
9 | "request": "attach",
10 | "name": "Attach Program",
11 | "address": "127.0.0.1",
12 | "port": 9229,
13 | "localRoot": "${workspaceFolder}/bin",
14 | "remoteRoot": ".",
15 | "protocol": "inspector"
16 | }
17 | ]
18 | }
19 |
--------------------------------------------------------------------------------
/sample-promise/app.mabu:
--------------------------------------------------------------------------------
1 | KIND = program
2 |
--------------------------------------------------------------------------------
/sample-promise/app.package:
--------------------------------------------------------------------------------
1 | DATAS = "digest.sha512.signed" : "." \
2 | "bin/" : "bin/"
3 | OPTIONS = package/minApiLevel/2
4 |
--------------------------------------------------------------------------------
/sample-promise/bin/index.js:
--------------------------------------------------------------------------------
1 | #!/system/bin/script/mxs
2 | import './src/main.js';
3 |
--------------------------------------------------------------------------------
/sample-promise/manifest.xml:
--------------------------------------------------------------------------------
1 |
5 |
8 |
12 |
13 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/sample-promise/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "scripts": {
3 | "build": "rollup -c",
4 | "start": "magic-script run"
5 | },
6 | "private": true,
7 | "devDependencies": {
8 | "rollup": "^1.1.2",
9 | "rollup-plugin-commonjs": "^9.3.4",
10 | "rollup-plugin-node-resolve": "^4.0.0"
11 | },
12 | "dependencies": {
13 | "magic-script-polyfills": "^1.0.0"
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/sample-promise/rollup.config.js:
--------------------------------------------------------------------------------
1 | // Rollup config for consuming some npm modules in MagicScript
2 |
3 | import resolve from 'rollup-plugin-node-resolve';
4 | import commonjs from 'rollup-plugin-commonjs';
5 |
6 | export default {
7 | external: ['uv', 'lumin'],
8 | input: 'src/main.js',
9 | preserveModules: true,
10 | output: {
11 | dir: 'bin',
12 | format: 'es'
13 | },
14 | plugins: [resolve(), commonjs()]
15 | };
16 |
--------------------------------------------------------------------------------
/sample-resource/.gitignore:
--------------------------------------------------------------------------------
1 | /.out/
2 | /node_modules/
3 | /bin/
4 | !/bin/index.js
5 | /digest.sha512.signed
6 |
--------------------------------------------------------------------------------
/sample-resource/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | {
2 | // Use IntelliSense to learn about possible attributes.
3 | // Hover to view descriptions of existing attributes.
4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5 | "version": "0.2.0",
6 | "configurations": [
7 | {
8 | "type": "node",
9 | "request": "attach",
10 | "name": "Attach Program",
11 | "address": "127.0.0.1",
12 | "port": 9229,
13 | "localRoot": "${workspaceFolder}/bin",
14 | "remoteRoot": ".",
15 | "protocol": "inspector"
16 | }
17 | ]
18 | }
19 |
--------------------------------------------------------------------------------
/sample-resource/app.mabu:
--------------------------------------------------------------------------------
1 | KIND = program
2 |
--------------------------------------------------------------------------------
/sample-resource/app.package:
--------------------------------------------------------------------------------
1 | DATAS = "digest.sha512.signed" : "." \
2 | "res/" : "res/" \
3 | "bin/" : "bin/"
4 | OPTIONS = package/minApiLevel/2
5 |
--------------------------------------------------------------------------------
/sample-resource/bin/index.js:
--------------------------------------------------------------------------------
1 | #!/system/bin/script/mxs
2 | import './src/main.js';
3 |
--------------------------------------------------------------------------------
/sample-resource/manifest.xml:
--------------------------------------------------------------------------------
1 |
5 |
8 |
12 |
13 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/sample-resource/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "scripts": {
3 | "build": "rollup -c",
4 | "start": "magic-script run"
5 | },
6 | "private": true,
7 | "devDependencies": {
8 | "rollup": "^1.1.2",
9 | "rollup-plugin-commonjs": "^9.3.4",
10 | "rollup-plugin-node-resolve": "^4.0.0"
11 | },
12 | "dependencies": {
13 | "magic-script-polyfills": "^1.0.0"
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/sample-resource/res/pic_1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/magic-script/magic-script-samples/12be913cc2f84f4d1bf706c15057ea0d4fc1d55c/sample-resource/res/pic_1.png
--------------------------------------------------------------------------------
/sample-resource/res/pic_2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/magic-script/magic-script-samples/12be913cc2f84f4d1bf706c15057ea0d4fc1d55c/sample-resource/res/pic_2.png
--------------------------------------------------------------------------------
/sample-resource/res/pic_3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/magic-script/magic-script-samples/12be913cc2f84f4d1bf706c15057ea0d4fc1d55c/sample-resource/res/pic_3.png
--------------------------------------------------------------------------------
/sample-resource/res/pic_4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/magic-script/magic-script-samples/12be913cc2f84f4d1bf706c15057ea0d4fc1d55c/sample-resource/res/pic_4.png
--------------------------------------------------------------------------------
/sample-resource/res/pic_5.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/magic-script/magic-script-samples/12be913cc2f84f4d1bf706c15057ea0d4fc1d55c/sample-resource/res/pic_5.png
--------------------------------------------------------------------------------
/sample-resource/rollup.config.js:
--------------------------------------------------------------------------------
1 | // Rollup config for consuming some npm modules in MagicScript
2 |
3 | import resolve from 'rollup-plugin-node-resolve';
4 | import commonjs from 'rollup-plugin-commonjs';
5 |
6 | export default {
7 | external: ['uv', 'lumin'],
8 | input: 'src/main.js',
9 | preserveModules: true,
10 | output: {
11 | dir: 'bin',
12 | format: 'es'
13 | },
14 | plugins: [resolve(), commonjs()]
15 | };
16 |
--------------------------------------------------------------------------------
/sample-resource/src/button.js:
--------------------------------------------------------------------------------
1 | import { ui } from 'lumin';
2 |
3 | var current = 0;
4 |
5 | function onPress(pageview, count) {
6 | console.log('onPress triggered!');
7 | current = ++current % count;
8 | pageview.showPage(current);
9 | }
10 |
11 | export function makeButton(prism, pageview, count) {
12 | const { UiButton, EclipseButtonParams, EclipseButtonType } = ui;
13 | let prms = new EclipseButtonParams(EclipseButtonType.kText, 'Next Page');
14 | let node = UiButton.CreateEclipseButton(prism, prms);
15 | console.log('makeButton');
16 | node.onActivateSub(function (uiEventData) {
17 | onPress(pageview, count);
18 | });
19 | return node;
20 | }
21 |
--------------------------------------------------------------------------------
/sample-threejs/.eslintrc.js:
--------------------------------------------------------------------------------
1 | // ESLint config for MagicScript Apps
2 | module.exports = {
3 | env: {
4 | "es6": true
5 | },
6 | globals: {
7 | // These globals are provided by the vm itself.
8 | "print": true,
9 | "globalThis": true,
10 | // The following globals are provided by `magic-script-polyfills`
11 | "setTimeout": true,
12 | "clearTimeout": true,
13 | "setInterval": true,
14 | "clearInterval": true,
15 | "setImmediate": true,
16 | "clearImmediate": true,
17 | "fetch": true,
18 | "Headers": true,
19 | "Request": true,
20 | "Response": true,
21 |
22 | },
23 | parserOptions: {
24 | "ecmaVersion": 2018,
25 | "sourceType": "module"
26 | },
27 | extends: "semistandard",
28 | };
--------------------------------------------------------------------------------
/sample-threejs/.gitignore:
--------------------------------------------------------------------------------
1 | /.out/
2 | /node_modules/
3 | /bin/
4 | !/bin/index.js
5 | /digest.sha512.signed
6 | /.vscode/
7 |
--------------------------------------------------------------------------------
/sample-threejs/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | {
2 | // Use IntelliSense to learn about possible attributes.
3 | // Hover to view descriptions of existing attributes.
4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5 | "version": "0.2.0",
6 | "configurations": [
7 | {
8 | "type": "node",
9 | "request": "attach",
10 | "name": "Attach Program",
11 | "address": "127.0.0.1",
12 | "port": 9229,
13 | "localRoot": "${workspaceFolder}/bin",
14 | "remoteRoot": ".",
15 | "protocol": "inspector"
16 | }
17 | ]
18 | }
19 |
--------------------------------------------------------------------------------
/sample-threejs/app.mabu:
--------------------------------------------------------------------------------
1 | KIND = program
2 |
--------------------------------------------------------------------------------
/sample-threejs/app.package:
--------------------------------------------------------------------------------
1 | DATAS = "digest.sha512.signed" : "." \
2 | "bin/" : "bin/"
3 | OPTIONS = package/minApiLevel/2
4 |
--------------------------------------------------------------------------------
/sample-threejs/manifest.xml:
--------------------------------------------------------------------------------
1 |
5 |
8 |
12 |
13 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/sample-threejs/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "scripts": {
3 | "build": "rollup -c",
4 | "start": "magic-script run"
5 | },
6 | "private": true,
7 | "devDependencies": {
8 | "eslint-config-semistandard": "^13.0.0",
9 | "eslint-config-standard": "^12.0.0",
10 | "eslint-plugin-import": "^2.16.0",
11 | "eslint-plugin-node": "^8.0.1",
12 | "eslint-plugin-promise": "^4.0.1",
13 | "eslint-plugin-standard": "^4.0.0",
14 | "rollup": "^1.1.2",
15 | "rollup-plugin-commonjs": "^10.0.0",
16 | "rollup-plugin-node-resolve": "^4.0.0",
17 | "semistandard": "^13.0.1"
18 | },
19 | "dependencies": {
20 | "gl-matrix": "^3.0.0",
21 | "magic-script-polyfills": "^2.1.0",
22 | "magic-script-webgl-prism-controller": "^2.0.0",
23 | "three": "^0.104.0"
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/sample-threejs/rollup.config.js:
--------------------------------------------------------------------------------
1 | // Rollup config for consuming some npm modules in MagicScript
2 |
3 | import resolve from 'rollup-plugin-node-resolve';
4 | import commonjs from 'rollup-plugin-commonjs';
5 |
6 | export default {
7 | external: ['uv', 'lumin', 'egl', 'png', 'gl', 'jpeg', 'ssl'],
8 | input: 'src/main.js',
9 | preserveModules: true,
10 | output: {
11 | dir: 'bin',
12 | format: 'es'
13 | },
14 | plugins: [resolve(), commonjs()]
15 | };
16 |
--------------------------------------------------------------------------------
/sample-threejs/src/main.js:
--------------------------------------------------------------------------------
1 | import 'magic-script-polyfills';
2 | import { App } from './app.js';
3 |
4 | export default new App(0.5);
5 |
--------------------------------------------------------------------------------
/sample-timeout/.gitignore:
--------------------------------------------------------------------------------
1 | /.out/
2 | /node_modules/
3 | /bin/
4 | !/bin/index.js
5 | /digest.sha512.signed
6 |
--------------------------------------------------------------------------------
/sample-timeout/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | {
2 | // Use IntelliSense to learn about possible attributes.
3 | // Hover to view descriptions of existing attributes.
4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5 | "version": "0.2.0",
6 | "configurations": [
7 | {
8 | "type": "node",
9 | "request": "attach",
10 | "name": "Attach Program",
11 | "address": "127.0.0.1",
12 | "port": 9229,
13 | "localRoot": "${workspaceFolder}/bin",
14 | "remoteRoot": ".",
15 | "protocol": "inspector"
16 | }
17 | ]
18 | }
19 |
--------------------------------------------------------------------------------
/sample-timeout/app.mabu:
--------------------------------------------------------------------------------
1 | KIND = program
2 |
--------------------------------------------------------------------------------
/sample-timeout/app.package:
--------------------------------------------------------------------------------
1 | DATAS = "digest.sha512.signed" : "." \
2 | "bin/" : "bin/"
3 | OPTIONS = package/minApiLevel/2
4 |
--------------------------------------------------------------------------------
/sample-timeout/bin/index.js:
--------------------------------------------------------------------------------
1 | #!/system/bin/script/mxs
2 | import './src/main.js';
3 |
--------------------------------------------------------------------------------
/sample-timeout/manifest.xml:
--------------------------------------------------------------------------------
1 |
5 |
8 |
12 |
13 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/sample-timeout/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "scripts": {
3 | "build": "rollup -c",
4 | "start": "magic-script run"
5 | },
6 | "private": true,
7 | "devDependencies": {
8 | "rollup": "^1.1.2",
9 | "rollup-plugin-commonjs": "^9.3.4",
10 | "rollup-plugin-node-resolve": "^4.0.0"
11 | },
12 | "dependencies": {
13 | "magic-script-polyfills": "^1.0.0"
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/sample-timeout/rollup.config.js:
--------------------------------------------------------------------------------
1 | // Rollup config for consuming some npm modules in MagicScript
2 |
3 | import resolve from 'rollup-plugin-node-resolve';
4 | import commonjs from 'rollup-plugin-commonjs';
5 |
6 | export default {
7 | external: ['uv', 'lumin'],
8 | input: 'src/main.js',
9 | preserveModules: true,
10 | output: {
11 | dir: 'bin',
12 | format: 'es'
13 | },
14 | plugins: [resolve(), commonjs()]
15 | };
16 |
--------------------------------------------------------------------------------
/sample-timeout/src/App.js:
--------------------------------------------------------------------------------
1 | import { ui } from 'lumin';
2 | const { UiButton } = ui;
3 |
4 | function sleep(ms) {
5 | return new Promise(resolve => setTimeout(resolve, ms));
6 | }
7 |
8 | export default async function start (app) {
9 | let prism = app.requestNewPrism([0.4, 0.2, 0.1]);
10 |
11 | let button = UiButton.Create(prism, 'Click Me', 0, 0.1);
12 | button.onActivateSub(async () => {
13 | button.setText('Thanks!');
14 | await sleep(1000);
15 | button.setText('Again?');
16 | });
17 | prism.getRootNode().addChild(button);
18 | return prism;
19 | }
20 |
--------------------------------------------------------------------------------
/sample-ui-button/.gitignore:
--------------------------------------------------------------------------------
1 | /.out/
2 | /node_modules/
3 | /bin/
4 | !/bin/index.js
5 | /digest.sha512.signed
6 |
--------------------------------------------------------------------------------
/sample-ui-button/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | {
2 | // Use IntelliSense to learn about possible attributes.
3 | // Hover to view descriptions of existing attributes.
4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5 | "version": "0.2.0",
6 | "configurations": [
7 | {
8 | "type": "node",
9 | "request": "attach",
10 | "name": "Attach Program",
11 | "address": "127.0.0.1",
12 | "port": 9229,
13 | "localRoot": "${workspaceFolder}/bin",
14 | "remoteRoot": ".",
15 | "protocol": "inspector"
16 | }
17 | ]
18 | }
19 |
--------------------------------------------------------------------------------
/sample-ui-button/app.mabu:
--------------------------------------------------------------------------------
1 | KIND = program
2 |
--------------------------------------------------------------------------------
/sample-ui-button/app.package:
--------------------------------------------------------------------------------
1 | DATAS = "digest.sha512.signed" : "." \
2 | "bin/" : "bin/"
3 | OPTIONS = package/minApiLevel/2
4 |
--------------------------------------------------------------------------------
/sample-ui-button/bin/index.js:
--------------------------------------------------------------------------------
1 | #!/system/bin/script/mxs
2 | import './src/main.js';
3 |
--------------------------------------------------------------------------------
/sample-ui-button/manifest.xml:
--------------------------------------------------------------------------------
1 |
5 |
8 |
12 |
13 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/sample-ui-button/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "scripts": {
3 | "build": "rollup -c",
4 | "start": "magic-script run"
5 | },
6 | "private": true,
7 | "devDependencies": {
8 | "rollup": "^1.1.2",
9 | "rollup-plugin-commonjs": "^9.3.4",
10 | "rollup-plugin-node-resolve": "^4.0.0"
11 | },
12 | "dependencies": {
13 | "magic-script-polyfills": "^1.0.0"
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/sample-ui-button/rollup.config.js:
--------------------------------------------------------------------------------
1 | // Rollup config for consuming some npm modules in MagicScript
2 |
3 | import resolve from 'rollup-plugin-node-resolve';
4 | import commonjs from 'rollup-plugin-commonjs';
5 |
6 | export default {
7 | external: ['uv', 'lumin'],
8 | input: 'src/main.js',
9 | preserveModules: true,
10 | output: {
11 | dir: 'bin',
12 | format: 'es'
13 | },
14 | plugins: [resolve(), commonjs()]
15 | };
16 |
--------------------------------------------------------------------------------
/sample-ui-button/src/App.js:
--------------------------------------------------------------------------------
1 | import { makeText } from './text.js';
2 | import { makeButton } from './button.js';
3 |
4 | export default async function start (app) {
5 | let prism = app.requestNewPrism([0.5, 0.5, 0.5]);
6 | // Add text label
7 | let text = makeText(prism);
8 | prism.getRootNode().addChild(text);
9 | text.setLocalPosition([0, 0.2, 0]);
10 | // Add button
11 | let button = makeButton(prism, text);
12 | button.setLocalPosition([0, -0.1, 0]);
13 | prism.getRootNode().addChild(button);
14 | return prism;
15 | }
16 |
--------------------------------------------------------------------------------
/sample-ui-button/src/button.js:
--------------------------------------------------------------------------------
1 | import { ui } from 'lumin';
2 |
3 | var counter = 0;
4 |
5 | function onPress(node, text) {
6 | console.log('onPress triggered!');
7 | counter++;
8 | node.setText('Press again');
9 | text.setText('Pressed ' + counter + ' time(s)');
10 | }
11 |
12 | export function makeButton(prism, text) {
13 | const { UiButton } = ui;
14 | let node = UiButton.Create(prism, 'Press me', 0, 0.1);
15 | console.log('makeButton');
16 | node.onActivateSub(function (uiEventData) {
17 | onPress(node, text);
18 | });
19 | return node;
20 | }
21 |
--------------------------------------------------------------------------------
/sample-ui-button/src/text.js:
--------------------------------------------------------------------------------
1 | import { ui } from 'lumin';
2 |
3 | export function makeText(prism) {
4 | const { UiText, EclipseLabelType, Alignment, HorizontalTextAlignment } = ui;
5 | let node = UiText.CreateEclipseLabel(
6 | prism,
7 | 'Hello\nMagicScript!',
8 | EclipseLabelType.kT7
9 | );
10 | node.setAlignment(Alignment.CENTER_CENTER);
11 | node.setTextAlignment(HorizontalTextAlignment.kCenter);
12 | return node;
13 | }
14 |
--------------------------------------------------------------------------------
/sample-ui-image/.gitignore:
--------------------------------------------------------------------------------
1 | /.out/
2 | /node_modules/
3 | /bin/
4 | !/bin/index.js
5 | /digest.sha512.signed
6 |
--------------------------------------------------------------------------------
/sample-ui-image/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | {
2 | // Use IntelliSense to learn about possible attributes.
3 | // Hover to view descriptions of existing attributes.
4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5 | "version": "0.2.0",
6 | "configurations": [
7 | {
8 | "type": "node",
9 | "request": "attach",
10 | "name": "Attach Program",
11 | "address": "127.0.0.1",
12 | "port": 9229,
13 | "localRoot": "${workspaceFolder}/bin",
14 | "remoteRoot": ".",
15 | "protocol": "inspector"
16 | }
17 | ]
18 | }
19 |
--------------------------------------------------------------------------------
/sample-ui-image/README.md:
--------------------------------------------------------------------------------
1 | # UiImage Sample
2 |
3 | MagicScript UiImage Sample
4 |
5 | ## Usage
6 |
7 | See the [README](../README.md) file for details
8 |
9 | ## License
10 |
11 | This project is licensed under the Apache 2.0 License - see the [LICENSE](../LICENSE) file for details
12 |
13 | [cat.png](res/cat.png) is released into the public domain by its author, Bakerq at English Wikipedia. This applies worldwide. More details can be found here: [Abyssinian_cat.png](https://commons.wikimedia.org/wiki/File:Abyssinian_cat.png)
14 |
--------------------------------------------------------------------------------
/sample-ui-image/app.mabu:
--------------------------------------------------------------------------------
1 | KIND = program
2 |
--------------------------------------------------------------------------------
/sample-ui-image/app.package:
--------------------------------------------------------------------------------
1 | DATAS = "digest.sha512.signed" : "." \
2 | "bin/" : "bin/" \
3 | "res/" : "res/"
4 | OPTIONS = package/minApiLevel/2
5 |
--------------------------------------------------------------------------------
/sample-ui-image/bin/index.js:
--------------------------------------------------------------------------------
1 | #!/system/bin/script/mxs
2 | import './src/main.js';
3 |
--------------------------------------------------------------------------------
/sample-ui-image/manifest.xml:
--------------------------------------------------------------------------------
1 |
5 |
8 |
12 |
13 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/sample-ui-image/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "scripts": {
3 | "build": "rollup -c",
4 | "start": "magic-script run"
5 | },
6 | "private": true,
7 | "devDependencies": {
8 | "rollup": "^1.1.2",
9 | "rollup-plugin-commonjs": "^9.3.4",
10 | "rollup-plugin-node-resolve": "^4.0.0"
11 | },
12 | "dependencies": {
13 | "magic-script-polyfills": "^1.0.0"
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/sample-ui-image/res/cat.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/magic-script/magic-script-samples/12be913cc2f84f4d1bf706c15057ea0d4fc1d55c/sample-ui-image/res/cat.png
--------------------------------------------------------------------------------
/sample-ui-image/rollup.config.js:
--------------------------------------------------------------------------------
1 | // Rollup config for consuming some npm modules in MagicScript
2 |
3 | import resolve from 'rollup-plugin-node-resolve';
4 | import commonjs from 'rollup-plugin-commonjs';
5 |
6 | export default {
7 | external: ['uv', 'lumin'],
8 | input: 'src/main.js',
9 | preserveModules: true,
10 | output: {
11 | dir: 'bin',
12 | format: 'es'
13 | },
14 | plugins: [resolve(), commonjs()]
15 | };
16 |
--------------------------------------------------------------------------------
/sample-ui-image/src/App.js:
--------------------------------------------------------------------------------
1 | import { ui } from 'lumin';
2 |
3 | export default async function start (app) {
4 | const { UiImage } = ui;
5 | let prism = app.requestNewPrism([0.5, 0.5, 0.5]);
6 | let image = UiImage.Create(prism, 'res/cat.png', 0.4, 0.3);
7 | prism.getRootNode().addChild(image);
8 | return prism;
9 | }
10 |
--------------------------------------------------------------------------------
/sample-ui-pageview/.gitignore:
--------------------------------------------------------------------------------
1 | /.out/
2 | /node_modules/
3 | /bin/
4 | !/bin/index.js
5 | /digest.sha512.signed
6 |
--------------------------------------------------------------------------------
/sample-ui-pageview/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | {
2 | // Use IntelliSense to learn about possible attributes.
3 | // Hover to view descriptions of existing attributes.
4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5 | "version": "0.2.0",
6 | "configurations": [
7 | {
8 | "type": "node",
9 | "request": "attach",
10 | "name": "Attach Program",
11 | "address": "127.0.0.1",
12 | "port": 9229,
13 | "localRoot": "${workspaceFolder}/bin",
14 | "remoteRoot": ".",
15 | "protocol": "inspector"
16 | }
17 | ]
18 | }
19 |
--------------------------------------------------------------------------------
/sample-ui-pageview/README.md:
--------------------------------------------------------------------------------
1 | # UiPageView Sample
2 |
3 | MagicScript UiPageView Sample
4 |
5 | ## Usage
6 |
7 | See the [README](../README.md) file for details
8 |
9 | ## License
10 |
11 | This project is licensed under the Apache 2.0 License - see the [LICENSE](../LICENSE) file for details
12 |
13 | All images included are distributed under permissive licenses:
14 |
15 | 1. [72nd Street in Bay Ridge, Brooklyn.png](https://commons.wikimedia.org/wiki/File:72nd_Street_in_Bay_Ridge,_Brooklyn.png)
16 |
17 | - License - [Creative Commons Attribution-Share Alike 3.0 Unported](https://creativecommons.org/licenses/by-sa/3.0/deed.en)
18 |
19 | 2. [Maracayu 1.png](https://commons.wikimedia.org/wiki/File:Maracayu_1.png)
20 |
21 | - License - [Public Domain](https://en.wikipedia.org/wiki/en:public_domain)
22 |
23 | 3. [Brunswick City Hall.PNG](https://commons.wikimedia.org/wiki/File:Brunswick_City_Hall.PNG)
24 |
25 | - License - [Public Domain](https://en.wikipedia.org/wiki/en:public_domain)
26 |
--------------------------------------------------------------------------------
/sample-ui-pageview/app.mabu:
--------------------------------------------------------------------------------
1 | KIND = program
2 |
--------------------------------------------------------------------------------
/sample-ui-pageview/app.package:
--------------------------------------------------------------------------------
1 | DATAS = "digest.sha512.signed" : "." \
2 | "bin/" : "bin/" \
3 | "res/" : "res/"
4 | OPTIONS = package/minApiLevel/2
5 |
--------------------------------------------------------------------------------
/sample-ui-pageview/bin/index.js:
--------------------------------------------------------------------------------
1 | #!/system/bin/script/mxs
2 | import './src/main.js';
3 |
--------------------------------------------------------------------------------
/sample-ui-pageview/manifest.xml:
--------------------------------------------------------------------------------
1 |
5 |
8 |
12 |
13 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/sample-ui-pageview/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "scripts": {
3 | "build": "rollup -c",
4 | "start": "magic-script run"
5 | },
6 | "private": true,
7 | "devDependencies": {
8 | "rollup": "^1.1.2",
9 | "rollup-plugin-commonjs": "^9.3.4",
10 | "rollup-plugin-node-resolve": "^4.0.0"
11 | },
12 | "dependencies": {
13 | "magic-script-polyfills": "^1.0.0"
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/sample-ui-pageview/res/pic_1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/magic-script/magic-script-samples/12be913cc2f84f4d1bf706c15057ea0d4fc1d55c/sample-ui-pageview/res/pic_1.png
--------------------------------------------------------------------------------
/sample-ui-pageview/res/pic_2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/magic-script/magic-script-samples/12be913cc2f84f4d1bf706c15057ea0d4fc1d55c/sample-ui-pageview/res/pic_2.png
--------------------------------------------------------------------------------
/sample-ui-pageview/res/pic_3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/magic-script/magic-script-samples/12be913cc2f84f4d1bf706c15057ea0d4fc1d55c/sample-ui-pageview/res/pic_3.png
--------------------------------------------------------------------------------
/sample-ui-pageview/rollup.config.js:
--------------------------------------------------------------------------------
1 | // Rollup config for consuming some npm modules in MagicScript
2 |
3 | import resolve from 'rollup-plugin-node-resolve';
4 | import commonjs from 'rollup-plugin-commonjs';
5 |
6 | export default {
7 | external: ['uv', 'lumin'],
8 | input: 'src/main.js',
9 | preserveModules: true,
10 | output: {
11 | dir: 'bin',
12 | format: 'es'
13 | },
14 | plugins: [resolve(), commonjs()]
15 | };
16 |
--------------------------------------------------------------------------------
/sample-ui-pageview/src/App.js:
--------------------------------------------------------------------------------
1 | import { ui } from 'lumin';
2 | import { makePage } from './page.js';
3 | import { makeButton } from './button.js';
4 |
5 | export default async function start (app) {
6 | const { UiPageView, Alignment } = ui;
7 | let prism = app.requestNewPrism([0.5, 0.5, 0.5]);
8 |
9 | // Create page view
10 | let pageview = UiPageView.Create(prism);
11 | pageview.setLocalPosition([0, 0.2, 0]);
12 | pageview.setAlignment(Alignment.CENTER_CENTER);
13 | prism.getRootNode().addChild(pageview);
14 |
15 | // Add pages
16 | pageview.addPage(makePage(prism, 'Picture # 1', 'res/pic_1.png'));
17 | pageview.addPage(makePage(prism, 'Picture # 2', 'res/pic_2.png'));
18 | pageview.addPage(makePage(prism, 'Picture # 3', 'res/pic_3.png'));
19 |
20 | // Add button
21 | let button = makeButton(prism, pageview);
22 | button.setLocalPosition([0, -0.2, 0]);
23 | prism.getRootNode().addChild(button);
24 |
25 | return prism;
26 | }
--------------------------------------------------------------------------------
/sample-ui-pageview/src/button.js:
--------------------------------------------------------------------------------
1 | import { ui } from 'lumin';
2 |
3 | var current = 0;
4 |
5 | function onPress(pageview) {
6 | console.log('onPress triggered!');
7 | current = ++current % 3;
8 | pageview.showPage(current);
9 | }
10 |
11 | export function makeButton(prism, pageview) {
12 | const { UiButton, EclipseButtonParams, EclipseButtonType } = ui;
13 | let prms = new EclipseButtonParams(EclipseButtonType.kText, 'Next Page');
14 | let node = UiButton.CreateEclipseButton(prism, prms);
15 | console.log('makeButton');
16 | node.onActivateSub(function(uiEventData) {
17 | onPress(pageview);
18 | });
19 | return node;
20 | }
21 |
--------------------------------------------------------------------------------
/sample-ui-pageview/src/page.js:
--------------------------------------------------------------------------------
1 | import { ui } from 'lumin';
2 |
3 | export function makePage(prism, text, name) {
4 | const {
5 | UiPanel,
6 | UiText,
7 | EclipseLabelType,
8 | Alignment,
9 | HorizontalTextAlignment,
10 | UiImage
11 | } = ui;
12 | // Create panel
13 | let panel = UiPanel.Create(prism);
14 | // Add text label
15 | let label = UiText.CreateEclipseLabel(prism, text, EclipseLabelType.kB1);
16 | label.setAlignment(Alignment.CENTER_CENTER);
17 | label.setTextAlignment(HorizontalTextAlignment.kCenter);
18 | panel.addChild(label);
19 | // Add image
20 | let image = UiImage.Create(prism, name, 0.4096, 0.3072);
21 | image.setLocalPosition([0, -0.2, 0]);
22 | panel.addChild(image);
23 | return panel;
24 | }
25 |
--------------------------------------------------------------------------------
/sample-video/.gitignore:
--------------------------------------------------------------------------------
1 | /.out/
2 | /node_modules/
3 | /bin/
4 | !/bin/index.js
5 | /digest.sha512.signed
6 |
--------------------------------------------------------------------------------
/sample-video/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | {
2 | // Use IntelliSense to learn about possible attributes.
3 | // Hover to view descriptions of existing attributes.
4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5 | "version": "0.2.0",
6 | "configurations": [
7 | {
8 | "type": "node",
9 | "request": "attach",
10 | "name": "Attach Program",
11 | "address": "127.0.0.1",
12 | "port": 9229,
13 | "localRoot": "${workspaceFolder}/bin",
14 | "remoteRoot": ".",
15 | "protocol": "inspector"
16 | }
17 | ]
18 | }
19 |
--------------------------------------------------------------------------------
/sample-video/README.md:
--------------------------------------------------------------------------------
1 | # Video Sample
2 |
3 | MagicScript Video Node Sample
4 |
5 | ## Usage
6 |
7 | 1. Download a video file in mp4 fromat from e.g. here: [Big Buck Bunny, Sunflower version](http://distribution.bbb3d.renderfarming.net/video/mp4/bbb_sunflower_1080p_30fps_normal.mp4)
8 | 2. Rename the file to **video.mp4**
9 | 3. Copy to **"res"** directory
10 | 4. See the [README](../README.md) file for further details
11 |
12 | ## License
13 |
14 | This project is licensed under the Apache 2.0 License - see the [LICENSE](../LICENSE) file for details
15 |
--------------------------------------------------------------------------------
/sample-video/app.mabu:
--------------------------------------------------------------------------------
1 | KIND = program
2 |
--------------------------------------------------------------------------------
/sample-video/app.package:
--------------------------------------------------------------------------------
1 | DATAS = "digest.sha512.signed" : "." \
2 | "bin/" : "bin/" \
3 | "res/" : "res/"
4 | OPTIONS = package/minApiLevel/2
5 |
--------------------------------------------------------------------------------
/sample-video/bin/index.js:
--------------------------------------------------------------------------------
1 | #!/system/bin/script/mxs
2 | import './src/main.js';
3 |
--------------------------------------------------------------------------------
/sample-video/manifest.xml:
--------------------------------------------------------------------------------
1 |
5 |
8 |
12 |
13 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/sample-video/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "scripts": {
3 | "build": "rollup -c",
4 | "start": "magic-script run"
5 | },
6 | "private": true,
7 | "devDependencies": {
8 | "rollup": "^1.1.2",
9 | "rollup-plugin-commonjs": "^9.3.4",
10 | "rollup-plugin-node-resolve": "^4.0.0"
11 | },
12 | "dependencies": {
13 | "magic-script-polyfills": "^1.0.0"
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/sample-video/res/PUT_SOME_VIDEO_FILE_HERE:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/magic-script/magic-script-samples/12be913cc2f84f4d1bf706c15057ea0d4fc1d55c/sample-video/res/PUT_SOME_VIDEO_FILE_HERE
--------------------------------------------------------------------------------
/sample-video/res/PumpkinCandleH264.mp4:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/magic-script/magic-script-samples/12be913cc2f84f4d1bf706c15057ea0d4fc1d55c/sample-video/res/PumpkinCandleH264.mp4
--------------------------------------------------------------------------------
/sample-video/rollup.config.js:
--------------------------------------------------------------------------------
1 | // Rollup config for consuming some npm modules in MagicScript
2 |
3 | import resolve from 'rollup-plugin-node-resolve';
4 | import commonjs from 'rollup-plugin-commonjs';
5 |
6 | export default {
7 | external: ['uv', 'lumin'],
8 | input: 'src/main.js',
9 | preserveModules: true,
10 | output: {
11 | dir: 'bin',
12 | format: 'es'
13 | },
14 | plugins: [resolve(), commonjs()]
15 | };
16 |
--------------------------------------------------------------------------------
/sample-webgl-texture/.eslintrc.js:
--------------------------------------------------------------------------------
1 | // ESLint config for MagicScript Apps
2 | module.exports = {
3 | env: {
4 | "es6": true
5 | },
6 | globals: {
7 | // These globals are provided by the vm itself.
8 | "print": true,
9 | "globalThis": true,
10 | // The following globals are provided by `magic-script-polyfills`
11 | "setTimeout": true,
12 | "clearTimeout": true,
13 | "setInterval": true,
14 | "clearInterval": true,
15 | "setImmediate": true,
16 | "clearImmediate": true,
17 | "fetch": true,
18 | "Headers": true,
19 | "Request": true,
20 | "Response": true,
21 | // More added from app.js polyfills
22 | "requestAnimationFrame": true,
23 | "Image": true,
24 | "document": true,
25 |
26 | },
27 | parserOptions: {
28 | "ecmaVersion": 2018,
29 | "sourceType": "module"
30 | },
31 | extends: "semistandard",
32 | };
--------------------------------------------------------------------------------
/sample-webgl-texture/.gitignore:
--------------------------------------------------------------------------------
1 | /.out/
2 | /node_modules/
3 | /bin/
4 | !/bin/index.js
5 | /digest.sha512.signed
6 |
--------------------------------------------------------------------------------
/sample-webgl-texture/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | {
2 | // Use IntelliSense to learn about possible attributes.
3 | // Hover to view descriptions of existing attributes.
4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5 | "version": "0.2.0",
6 | "configurations": [
7 | {
8 | "type": "node",
9 | "request": "attach",
10 | "name": "Attach Program",
11 | "address": "127.0.0.1",
12 | "port": 9229,
13 | "localRoot": "${workspaceFolder}/bin",
14 | "remoteRoot": ".",
15 | "protocol": "inspector"
16 | }
17 | ]
18 | }
19 |
--------------------------------------------------------------------------------
/sample-webgl-texture/app.mabu:
--------------------------------------------------------------------------------
1 | KIND = program
2 |
--------------------------------------------------------------------------------
/sample-webgl-texture/app.package:
--------------------------------------------------------------------------------
1 | DATAS = "digest.sha512.signed" : "." \
2 | "res/" : "res/" \
3 | "bin/" : "bin/"
4 | OPTIONS = package/minApiLevel/2
5 |
--------------------------------------------------------------------------------
/sample-webgl-texture/manifest.xml:
--------------------------------------------------------------------------------
1 |
5 |
8 |
12 |
13 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/sample-webgl-texture/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "scripts": {
3 | "build": "rollup -c",
4 | "start": "magic-script run"
5 | },
6 | "private": true,
7 | "devDependencies": {
8 | "eslint-config-semistandard": "^13.0.0",
9 | "eslint-config-standard": "^12.0.0",
10 | "eslint-plugin-import": "^2.16.0",
11 | "eslint-plugin-node": "^8.0.1",
12 | "eslint-plugin-promise": "^4.0.1",
13 | "eslint-plugin-standard": "^4.0.0",
14 | "rollup": "^1.1.2",
15 | "rollup-plugin-commonjs": "https://github.com/creationix/rollup-plugin-commonjs.git",
16 | "rollup-plugin-node-resolve": "^4.0.0",
17 | "semistandard": "^13.0.1"
18 | },
19 | "dependencies": {
20 | "magic-script-polyfills": "^1.0.0"
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/sample-webgl-texture/res/cubetexture.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/magic-script/magic-script-samples/12be913cc2f84f4d1bf706c15057ea0d4fc1d55c/sample-webgl-texture/res/cubetexture.png
--------------------------------------------------------------------------------
/sample-webgl-texture/rollup.config.js:
--------------------------------------------------------------------------------
1 | // Rollup config for consuming some npm modules in MagicScript
2 |
3 | import resolve from 'rollup-plugin-node-resolve';
4 | import commonjs from 'rollup-plugin-commonjs';
5 |
6 | export default {
7 | external: ['uv', 'lumin'],
8 | input: 'src/main.js',
9 | preserveModules: true,
10 | output: {
11 | dir: 'bin',
12 | format: 'es'
13 | },
14 | plugins: [resolve(), commonjs()]
15 | };
16 |
--------------------------------------------------------------------------------
/sample-webgl-texture/src/main.js:
--------------------------------------------------------------------------------
1 | // Add support for things like setTimeout, setInterval and fetch.
2 | // Simply importing this sets all these as global definitions.
3 | // They are declared in the .eslintrc so your editor won't complain.
4 | import 'magic-script-polyfills';
5 |
6 | // Load main app logic from the app class.
7 | import { App } from './app.js';
8 |
9 | // Launch our app!
10 | // The 0.5 value is the number of seconds to call `updateLoop` in an interval if
11 | // there are no other events waking the event loop.
12 | export default new App(0.5);
13 |
--------------------------------------------------------------------------------
/sample-webview/.eslintrc.js:
--------------------------------------------------------------------------------
1 | // ESLint config for MagicScript Apps
2 | module.exports = {
3 | env: {
4 | "es6": true
5 | },
6 | globals: {
7 | // These globals are provided by the vm itself.
8 | "print": true,
9 | "globalThis": true,
10 | // The following globals are provided by `magic-script-polyfills`
11 | "setTimeout": true,
12 | "clearTimeout": true,
13 | "setInterval": true,
14 | "clearInterval": true,
15 | "setImmediate": true,
16 | "clearImmediate": true,
17 | "fetch": true,
18 | "Headers": true,
19 | "Request": true,
20 | "Response": true,
21 |
22 | },
23 | parserOptions: {
24 | "ecmaVersion": 2018,
25 | "sourceType": "module"
26 | },
27 | extends: "semistandard",
28 | };
--------------------------------------------------------------------------------
/sample-webview/.gitignore:
--------------------------------------------------------------------------------
1 | /.out/
2 | /node_modules/
3 | /bin/
4 | !/bin/index.js
5 | /digest.sha512.signed
6 |
--------------------------------------------------------------------------------
/sample-webview/app.mabu:
--------------------------------------------------------------------------------
1 | KIND = program
2 |
--------------------------------------------------------------------------------
/sample-webview/app.package:
--------------------------------------------------------------------------------
1 | DATAS = "digest.sha512.signed" : "." \
2 | "res/" : "res/" \
3 | "bin/" : "bin/"
4 | OPTIONS = package/minApiLevel/2
5 |
--------------------------------------------------------------------------------
/sample-webview/manifest.xml:
--------------------------------------------------------------------------------
1 |
5 |
7 |
11 |
12 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/sample-webview/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "scripts": {
3 | "build": "rollup -c",
4 | "start": "magic-script run"
5 | },
6 | "private": true,
7 | "devDependencies": {
8 | "eslint-config-semistandard": "^13.0.0",
9 | "eslint-config-standard": "^12.0.0",
10 | "eslint-plugin-import": "^2.16.0",
11 | "eslint-plugin-node": "^8.0.1",
12 | "eslint-plugin-promise": "^4.0.1",
13 | "eslint-plugin-standard": "^4.0.0",
14 | "magic-script-typings": "1.4.0",
15 | "rollup": "^1.1.2",
16 | "rollup-plugin-commonjs": "^9.3.4",
17 | "rollup-plugin-node-resolve": "^4.0.0",
18 | "semistandard": "^13.0.1"
19 | },
20 | "dependencies": {
21 | "magic-script-polyfills": "^2.0.0"
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/sample-webview/res/.placeholder:
--------------------------------------------------------------------------------
1 | This folder is a placeholder for app assets.
--------------------------------------------------------------------------------
/sample-webview/rollup.config.js:
--------------------------------------------------------------------------------
1 | // Rollup config for consuming some npm modules in MagicScript
2 |
3 | import resolve from 'rollup-plugin-node-resolve';
4 | import commonjs from 'rollup-plugin-commonjs';
5 |
6 | export default {
7 | external: ['uv', 'lumin', 'ssl'],
8 | input: 'src/main.js',
9 | preserveModules: true,
10 | output: {
11 | dir: 'bin',
12 | format: 'es'
13 | },
14 | plugins: [resolve(), commonjs()]
15 | };
16 |
--------------------------------------------------------------------------------
/sample-webview/src/WebViewClient.js:
--------------------------------------------------------------------------------
1 | import { ui } from 'lumin';
2 |
3 | export class WebViewClient extends ui.UiWebViewClient {
4 | constructor(app){
5 | super();
6 | this.app = app;
7 | }
8 |
9 | onBeforeResourceLoad(webview, resource_url) {
10 | print("MxS onBeforeResourceLoad: ",resource_url);
11 | }
12 |
13 | onExternalProtocol(webview, url) {
14 | print("MxS onExternalProtocol", url);
15 | }
16 |
17 | onLoadEnd(webview, is_main_frame, http_error_code) {
18 | print("MxS onLoadEnd", is_main_frame, http_error_code);
19 | this.app.address_bar.setText(webview.getUrl());
20 | }
21 |
22 | onLoadError(webview, is_main_frame, error_code, error_str, failed_url) {
23 | print("MxS onLoadError", is_main_frame, error_code, error_str, failed_url);
24 | }
25 | }
26 |
27 |
--------------------------------------------------------------------------------
/sample-webview/src/main.js:
--------------------------------------------------------------------------------
1 | // Add support for things like setTimeout, setInterval and fetch.
2 | // Simply importing this sets all these as global definitions.
3 | // They are declared in the .eslintrc so your editor won't complain.
4 | import 'magic-script-polyfills';
5 |
6 | // Load main app logic from the app class.
7 | import { App } from './app.js';
8 |
9 | // Launch our app!
10 | // The 0.5 value is the number of seconds to call `updateLoop` in an interval if
11 | // there are no other events waking the event loop.
12 | export default new App(0.5);
13 |
--------------------------------------------------------------------------------
/sample-webview/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "allowJs": true,
4 | "noEmit": true,
5 | "typeRoots" : ["./node_modules/magic-script-typings", "./node_modules/@types"]
6 | }
7 | }
8 |
9 |
--------------------------------------------------------------------------------
/sample-xeogl-gltf/.eslintrc.js:
--------------------------------------------------------------------------------
1 | // ESLint config for MagicScript Apps
2 | module.exports = {
3 | env: {
4 | "es6": true
5 | },
6 | globals: {
7 | // These globals are provided by the vm itself.
8 | "print": true,
9 | "globalThis": true,
10 | // The following globals are provided by `magic-script-polyfills`
11 | "setTimeout": true,
12 | "clearTimeout": true,
13 | "setInterval": true,
14 | "clearInterval": true,
15 | "setImmediate": true,
16 | "clearImmediate": true,
17 | "fetch": true,
18 | "Headers": true,
19 | "Request": true,
20 | "Response": true,
21 |
22 | },
23 | parserOptions: {
24 | "ecmaVersion": 2018,
25 | "sourceType": "module"
26 | },
27 | extends: "semistandard",
28 | };
--------------------------------------------------------------------------------
/sample-xeogl-gltf/.gitignore:
--------------------------------------------------------------------------------
1 | /.out/
2 | /node_modules/
3 | /bin/
4 | !/bin/index.js
5 | /digest.sha512.signed
6 |
--------------------------------------------------------------------------------
/sample-xeogl-gltf/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | {
2 | // Use IntelliSense to learn about possible attributes.
3 | // Hover to view descriptions of existing attributes.
4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5 | "version": "0.2.0",
6 | "configurations": [
7 | {
8 | "type": "node",
9 | "request": "attach",
10 | "name": "Attach Program",
11 | "address": "127.0.0.1",
12 | "port": 9229,
13 | "localRoot": "${workspaceFolder}/bin",
14 | "remoteRoot": ".",
15 | "protocol": "inspector"
16 | }
17 | ]
18 | }
19 |
--------------------------------------------------------------------------------
/sample-xeogl-gltf/app.mabu:
--------------------------------------------------------------------------------
1 | KIND = program
2 |
--------------------------------------------------------------------------------
/sample-xeogl-gltf/app.package:
--------------------------------------------------------------------------------
1 | DATAS = "digest.sha512.signed" : "." \
2 | "res/" : "res/" \
3 | "bin/" : "bin/"
4 | OPTIONS = package/minApiLevel/2
5 |
--------------------------------------------------------------------------------
/sample-xeogl-gltf/manifest.xml:
--------------------------------------------------------------------------------
1 |
5 |
8 |
12 |
13 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/sample-xeogl-gltf/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "scripts": {
3 | "build": "rollup -c",
4 | "start": "magic-script run"
5 | },
6 | "private": true,
7 | "devDependencies": {
8 | "eslint-config-semistandard": "^13.0.0",
9 | "eslint-config-standard": "^12.0.0",
10 | "eslint-plugin-import": "^2.16.0",
11 | "eslint-plugin-node": "^8.0.1",
12 | "eslint-plugin-promise": "^4.0.1",
13 | "eslint-plugin-standard": "^4.0.0",
14 | "rollup": "^1.1.2",
15 | "rollup-plugin-commonjs": "https://github.com/creationix/rollup-plugin-commonjs.git",
16 | "rollup-plugin-node-resolve": "^4.0.0",
17 | "semistandard": "^13.0.1"
18 | },
19 | "dependencies": {
20 | "magic-script-polyfills": "^2.1.0",
21 | "magic-script-webgl-prism-controller": "^2.0.0",
22 | "xeogl": "^0.9.0",
23 | "xeogl-gltf-model": "^1.0.0"
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/sample-xeogl-gltf/photos/ML_20190507_20.30.25.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/magic-script/magic-script-samples/12be913cc2f84f4d1bf706c15057ea0d4fc1d55c/sample-xeogl-gltf/photos/ML_20190507_20.30.25.jpg
--------------------------------------------------------------------------------
/sample-xeogl-gltf/photos/ML_20190507_20.31.00.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/magic-script/magic-script-samples/12be913cc2f84f4d1bf706c15057ea0d4fc1d55c/sample-xeogl-gltf/photos/ML_20190507_20.31.00.jpg
--------------------------------------------------------------------------------
/sample-xeogl-gltf/res/BoomBox/BoomBox.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/magic-script/magic-script-samples/12be913cc2f84f4d1bf706c15057ea0d4fc1d55c/sample-xeogl-gltf/res/BoomBox/BoomBox.bin
--------------------------------------------------------------------------------
/sample-xeogl-gltf/res/BoomBox/BoomBox_baseColor.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/magic-script/magic-script-samples/12be913cc2f84f4d1bf706c15057ea0d4fc1d55c/sample-xeogl-gltf/res/BoomBox/BoomBox_baseColor.png
--------------------------------------------------------------------------------
/sample-xeogl-gltf/res/BoomBox/BoomBox_emissive.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/magic-script/magic-script-samples/12be913cc2f84f4d1bf706c15057ea0d4fc1d55c/sample-xeogl-gltf/res/BoomBox/BoomBox_emissive.png
--------------------------------------------------------------------------------
/sample-xeogl-gltf/res/BoomBox/BoomBox_normal.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/magic-script/magic-script-samples/12be913cc2f84f4d1bf706c15057ea0d4fc1d55c/sample-xeogl-gltf/res/BoomBox/BoomBox_normal.png
--------------------------------------------------------------------------------
/sample-xeogl-gltf/res/BoomBox/BoomBox_occlusionRoughnessMetallic.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/magic-script/magic-script-samples/12be913cc2f84f4d1bf706c15057ea0d4fc1d55c/sample-xeogl-gltf/res/BoomBox/BoomBox_occlusionRoughnessMetallic.png
--------------------------------------------------------------------------------
/sample-xeogl-gltf/res/BoomBox/README.md:
--------------------------------------------------------------------------------
1 | # Boom Box
2 | ## Screenshot
3 |
4 | 
5 |
6 | ## License Information
7 |
8 | [](http://creativecommons.org/publicdomain/zero/1.0/)
9 | To the extent possible under law, Microsoft has waived all copyright and related or neighboring rights to this asset.
--------------------------------------------------------------------------------
/sample-xeogl-gltf/res/Uffizi_Gallery/Uffizi_Gallery_Radiance_NX.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/magic-script/magic-script-samples/12be913cc2f84f4d1bf706c15057ea0d4fc1d55c/sample-xeogl-gltf/res/Uffizi_Gallery/Uffizi_Gallery_Radiance_NX.png
--------------------------------------------------------------------------------
/sample-xeogl-gltf/res/Uffizi_Gallery/Uffizi_Gallery_Radiance_NY.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/magic-script/magic-script-samples/12be913cc2f84f4d1bf706c15057ea0d4fc1d55c/sample-xeogl-gltf/res/Uffizi_Gallery/Uffizi_Gallery_Radiance_NY.png
--------------------------------------------------------------------------------
/sample-xeogl-gltf/res/Uffizi_Gallery/Uffizi_Gallery_Radiance_NZ.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/magic-script/magic-script-samples/12be913cc2f84f4d1bf706c15057ea0d4fc1d55c/sample-xeogl-gltf/res/Uffizi_Gallery/Uffizi_Gallery_Radiance_NZ.png
--------------------------------------------------------------------------------
/sample-xeogl-gltf/res/Uffizi_Gallery/Uffizi_Gallery_Radiance_PX.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/magic-script/magic-script-samples/12be913cc2f84f4d1bf706c15057ea0d4fc1d55c/sample-xeogl-gltf/res/Uffizi_Gallery/Uffizi_Gallery_Radiance_PX.png
--------------------------------------------------------------------------------
/sample-xeogl-gltf/res/Uffizi_Gallery/Uffizi_Gallery_Radiance_PY.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/magic-script/magic-script-samples/12be913cc2f84f4d1bf706c15057ea0d4fc1d55c/sample-xeogl-gltf/res/Uffizi_Gallery/Uffizi_Gallery_Radiance_PY.png
--------------------------------------------------------------------------------
/sample-xeogl-gltf/res/Uffizi_Gallery/Uffizi_Gallery_Radiance_PZ.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/magic-script/magic-script-samples/12be913cc2f84f4d1bf706c15057ea0d4fc1d55c/sample-xeogl-gltf/res/Uffizi_Gallery/Uffizi_Gallery_Radiance_PZ.png
--------------------------------------------------------------------------------
/sample-xeogl-gltf/rollup.config.js:
--------------------------------------------------------------------------------
1 | // Rollup config for consuming some npm modules in MagicScript
2 |
3 | import resolve from 'rollup-plugin-node-resolve';
4 | import commonjs from 'rollup-plugin-commonjs';
5 |
6 | export default {
7 | external: ['uv', 'lumin', 'ssl', 'png', 'jpeg', 'gl', 'egl'],
8 | input: 'src/main.js',
9 | preserveModules: true,
10 | output: {
11 | dir: 'bin',
12 | format: 'es'
13 | },
14 | plugins: [resolve(), commonjs()]
15 | };
16 |
--------------------------------------------------------------------------------
/sample-xeogl-gltf/src/main.js:
--------------------------------------------------------------------------------
1 | import 'magic-script-polyfills';
2 | import { App } from './app.js';
3 |
4 | export default new App(0.5);
5 |
--------------------------------------------------------------------------------
/sample-xeogl/.eslintrc.js:
--------------------------------------------------------------------------------
1 | // ESLint config for MagicScript Apps
2 | module.exports = {
3 | env: {
4 | "es6": true
5 | },
6 | globals: {
7 | // These globals are provided by the vm itself.
8 | "print": true,
9 | "globalThis": true,
10 | // The following globals are provided by `magic-script-polyfills`
11 | "setTimeout": true,
12 | "clearTimeout": true,
13 | "setInterval": true,
14 | "clearInterval": true,
15 | "setImmediate": true,
16 | "clearImmediate": true,
17 | "fetch": true,
18 | "Headers": true,
19 | "Request": true,
20 | "Response": true,
21 |
22 | },
23 | parserOptions: {
24 | "ecmaVersion": 2018,
25 | "sourceType": "module"
26 | },
27 | extends: "semistandard",
28 | };
--------------------------------------------------------------------------------
/sample-xeogl/.gitignore:
--------------------------------------------------------------------------------
1 | /.out/
2 | /node_modules/
3 | /bin/
4 | !/bin/index.js
5 | /digest.sha512.signed
6 |
--------------------------------------------------------------------------------
/sample-xeogl/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | {
2 | // Use IntelliSense to learn about possible attributes.
3 | // Hover to view descriptions of existing attributes.
4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5 | "version": "0.2.0",
6 | "configurations": [
7 | {
8 | "type": "node",
9 | "request": "attach",
10 | "name": "Attach Program",
11 | "address": "127.0.0.1",
12 | "port": 9229,
13 | "localRoot": "${workspaceFolder}/bin",
14 | "remoteRoot": ".",
15 | "protocol": "inspector"
16 | }
17 | ]
18 | }
19 |
--------------------------------------------------------------------------------
/sample-xeogl/app.mabu:
--------------------------------------------------------------------------------
1 | KIND = program
2 |
--------------------------------------------------------------------------------
/sample-xeogl/app.package:
--------------------------------------------------------------------------------
1 | DATAS = "digest.sha512.signed" : "." \
2 | "res/" : "res/" \
3 | "bin/" : "bin/"
4 | OPTIONS = package/minApiLevel/2
5 |
--------------------------------------------------------------------------------
/sample-xeogl/manifest.xml:
--------------------------------------------------------------------------------
1 |
5 |
8 |
12 |
13 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/sample-xeogl/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "scripts": {
3 | "build": "rollup -c",
4 | "start": "magic-script run"
5 | },
6 | "private": true,
7 | "devDependencies": {
8 | "eslint-config-semistandard": "^13.0.0",
9 | "eslint-config-standard": "^12.0.0",
10 | "eslint-plugin-import": "^2.16.0",
11 | "eslint-plugin-node": "^8.0.1",
12 | "eslint-plugin-promise": "^4.0.1",
13 | "eslint-plugin-standard": "^4.0.0",
14 | "rollup": "^1.1.2",
15 | "rollup-plugin-commonjs": "https://github.com/creationix/rollup-plugin-commonjs.git",
16 | "rollup-plugin-node-resolve": "^4.0.0",
17 | "semistandard": "^13.0.1"
18 | },
19 | "dependencies": {
20 | "magic-script-polyfills": "^2.1.0",
21 | "magic-script-webgl-prism-controller": "^2.0.0",
22 | "xeogl": "^0.9.0"
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/sample-xeogl/res/goldRoughness.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/magic-script/magic-script-samples/12be913cc2f84f4d1bf706c15057ea0d4fc1d55c/sample-xeogl/res/goldRoughness.jpg
--------------------------------------------------------------------------------
/sample-xeogl/res/uvGrid2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/magic-script/magic-script-samples/12be913cc2f84f4d1bf706c15057ea0d4fc1d55c/sample-xeogl/res/uvGrid2.jpg
--------------------------------------------------------------------------------
/sample-xeogl/rollup.config.js:
--------------------------------------------------------------------------------
1 | // Rollup config for consuming some npm modules in MagicScript
2 |
3 | import resolve from 'rollup-plugin-node-resolve';
4 | import commonjs from 'rollup-plugin-commonjs';
5 |
6 | export default {
7 | external: ['uv', 'lumin', 'egl', 'png', 'gl', 'jpeg', 'ssl'],
8 | input: 'src/main.js',
9 | preserveModules: true,
10 | output: {
11 | dir: 'bin',
12 | format: 'es'
13 | },
14 | plugins: [resolve(), commonjs()]
15 | };
16 |
--------------------------------------------------------------------------------
/sample-xeogl/src/main.js:
--------------------------------------------------------------------------------
1 | import 'magic-script-polyfills';
2 | import { App } from './app.js';
3 |
4 | export default new App(0.5);
5 |
--------------------------------------------------------------------------------