MagicScript WebGL PrismController
Helper library for running webgl code in a Lumun Runtime Quadnode.
This expands on magic-script-polyfills to add an environment where popular webgl framework such as three.js and xeogl can run out of the box.
Usage
Create a normal MagicScript LandScape app and use this PrismController on your prism to enable browser style webgl APIs.
;; { let prism = this; let controller = windowcontroller = ; prism; }
Now, you can consume existing webgl libraries such as three.js, it will render to a quad that's created inside your prism. Note that this part of the code can also be used in a web browser.
; window { // Create an empty scene const scene = ; // Create a basic perspective camera const camera = 75 windowinnerWidth / windowinnerHeight 01 1000; camerapositionz = 4; // Create and configure a renderer const renderer = antialias: true ; renderer; renderer; // Append Renderer to DOM // Note: WebGLController ignores these calls, only here for browser compat. documentbody; // Create a Cube Mesh with basic material const geometry = 1 1 1; const material = color: '#433F81' ; const cube = geometry material; // Add cube to Scene scene; // Start rendering/animation. return window; { window; cuberotationx = time / 1000; cuberotationy = time / 1200; renderer; }};
Installation
Open a Terminal in your project's folder and run,
npm install magic-script-webgl-prism-controller
or
yarn add magic-script-webgl-prism-controller
License
This project is licensed under the Apache 2.0 License - see the LICENSE file for details