Giter Club home page Giter Club logo

pex's Introduction

pex-gl

npm version stability-stable npm minzipped size dependencies types Conventional Commits styled with prettier linted with eslint license

Create a RenderingContext (2d, webgl, webgl2, bitmaprenderer, webgpu) for use in PEX.

Installation

npm install pex-gl

Usage

import createRenderingContext, { FALLBACKS } from "pex-gl";

// Creates a webgl context filling the window
const context = createRenderingContext();

// Creates a webgl context from an existing canvas and keeps its size
const context = createRenderingContext({ canvas });

// Creates a webgl context on a new canvas with given width and height
const context = createRenderingContext({ width, height });

// Creates a new canvas of type "webgpu"
const context = createRenderingContext({ type: "webgpu" });

// Creates a new canvas of type "webgl" or fallback to experimental-webgl in case it fails
const context = createRenderingContext({ type: "webgl" });

// Disable fallbacks for "webgl2"
FALLBACKS.webgl2 = [];
// Creates a new canvas of type "webgl2" and return null in case it fails
const context = createRenderingContext({ type: "webgl2" });

API

Modules

pex-gl

Typedefs

PexGLOptions : object

Options for context creation. All optional.

pex-gl

pex-gl.FALLBACKS

Context fallbacks map

Kind: static constant of pex-gl

pex-gl.default([opts]) ⇒ RenderingContext

Creates a rendering context.

Kind: static method of pex-gl

Param Type Default
[opts] PexGLOptions {}

PexGLOptions : object

Options for context creation. All optional.

Kind: global typedef Properties

Name Type Default Description
[width] number window.innerWidth Request an initial canvas width.
[height] number window.innerHeight Request an initial canvas height.
[pixelRatio] boolean 1 Multiply canvas dimensions with a given ratio.
[fullscreen] boolean !opts.width && !opts.height Make the canvas fullscreen.
[type] "2d" | "bitmaprenderer" | "webgl" | "webgl2" | "webgpu" "webgl" A "contextType" for getContext.
[element] HTMLElement document.body Element to append the canvas to.
[...contextAttributes] CanvasRenderingContext2DSettings | WebGLContextAttributes {} Attributes to be passed to getContext.

License

MIT. See license file.

pex's People

Contributors

brianhinch avatar dawidgorny avatar ottoh avatar szymonkaliski avatar vorg avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pex's Issues

example doesn't work in plask

hi,

I'm excited to check out pex, but I get error messages when I try to run the example in plask. I initialized a new project and opened main.js in plask, but something's going wrong:

/Volumes/Macintosh HD/Projects/bla/bla/pex/test-project/node_modules/pex-sys/lib/Window.js:26
  screens = plask.Window.screensInfo();
                         ^
TypeError: Object function (width, height, opts) {
  setInterval(function() { }, 999999999);  // Hack to prevent empty event loop.
  var nswindow_ = new PlaskRawMac.NSWindow(
      opts.type === '3d' ? 1 : 0,
      width, height,
      opts.multisample === true,
      opts.display === undefined ? -1 : opts.display,
      opts.borderless === true,
      opts.fullscreen === true);
  var this_ = this;

// [...]

  this.blit = function() {
    nswindow_.blit();
  };
} has no method 'screensInfo'
    at Object.<anonymous> (/Volumes/Macintosh HD/Projects/bla/bla/pex/test-project/node_modules/pex-sys/lib/Window.js:26:26)
    at Module._compile (module.js:454:26)
    at Object.Module._extensions..js (module.js:472:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:362:17)
    at require (module.js:378:17)
    at Object.<anonymous> (/Volumes/Macintosh HD/Projects/bla/bla/pex/test-project/node_modules/pex-sys/index.js:2:25)
    at Module._compile (module.js:454:26)
    at Object.Module._extensions..js (module.js:472:10)

latest plask (README_2013-05-22.txt)

Set current pex-* package version is generated package.json

Currenly we set * for each pex package. This is wrong as in the future as packages evolve we don't have track of which package we have used in that project. Solutions:

a) Synchronous npm show package version

var execSync = require('exec-sync');

function getPackageVersion(pkg) {
    var version = execSync('npm show ' + pkg + ' version');
    version = version.trim();
    return version;
}

'pex-color':            getPackageVersion('pex-color'),

Pros: easy
Cons: synchronous = slow, can't create projects when offline

b) Manually call npm install pex-color --save for each pex package

Additionally we need to call cd project name and npm install for all remaining packages

//'pex-color':           "*", //don't include pex-packages in generated package.json

Pros: faster
Cons: still can fail when offline, breaks 'generate project and forget' philosophy of a project generator

c) Hardcoded package versions in pex distro and update from time to time

'pex-color':           "0.1.0",

Pros: fast
Cons: easy to get out of sync with state of the packages

d) Run npm install 'ls node_modules' --save inside folder manually

Re-saves all package versions

Pros: optional
Cons: optional, requires effort

Pex errors on ExampleApp

Using the instructions for running Pex in the browser I get the error.

Error: Cannot find module 'pex-cam/PerspCamera' from '/Users/chadvavra/Documents/CODE/pex/myFirstProject/exampleApp'

Changing main.js to
var PerspCamera = require('pex-cam/perspective');

then tells me
Cannot find module 'pex-cam/Arcball'

I feel like I'm using the wrong version.

Help is much appreciated.

thanks.

Cannot find module 'pex-context'/Context

Hello,

I have been trying to get started with Pex and it appears that the example project created is incorrect. Which is the correct module to be linking to and how to do so correctly in a Pex project?

Initial error I recieve when running the pex turotial is:

Cannot find module 'pex-cam/PerspCamera' from 'path/to/exampleApp'

I fix this error (and an error searching for Arcball as well ) by changing in main.js

the variables to:
var PerspCamera = require('pex-cam/perspective'); var Arcball = require('pex-cam/orbiter');

But now have a new error

Error: Cannot find module 'pex-Context/Context'

There is no variable in example main.js - so how do we link to this and what is the correct module in the pex-context file?

On a side note - I notie this repo is quite old... is there any continued development on Pex? And if not, what is it that Variable are using as an alternative?

Best,

O.

Why aren't dependencies explicit?

Looking around I noticed that many packages in the pex-gl organization do not appear to explicitly reference each other via the dependencies field in their package.json files.

I noticed this:
https://github.com/pex-gl/pex/blob/master/lib/pkg/pex-packages-core.json

Which seems to make sure that if you use pex init your project gets all the right things installed, but I'm curious to understand why this approach is used over the more traditional dependencies field?

Installation issue

Got the following error after running 'sudo npm install -g pex' on the terminal, any idea why?
Thanks,

fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
make: *** [Release/obj.target/ffi_bindings/src/ffi.o] Error 1
gyp ERR! build error
gyp ERR! stack Error: make failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:267:23)
gyp ERR! stack at ChildProcess.emit (events.js:110:17)
gyp ERR! stack at Process.ChildProcess._handle.onexit (child_process.js:1067:12)
gyp ERR! System Darwin 14.0.0
gyp ERR! command "node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /usr/local/lib/node_modules/pex/node_modules/exec-sync/node_modules/ffi
gyp ERR! node -v v0.12.0
gyp ERR! node-gyp -v v1.0.2
gyp ERR! not ok
npm ERR! Darwin 14.0.0
npm ERR! argv "node" "/usr/local/bin/npm" "install" "-g" "pex"
npm ERR! node v0.12.0
npm ERR! npm v2.5.1
npm ERR! code ELIFECYCLE

npm ERR! [email protected] install: node-gyp rebuild
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script 'node-gyp rebuild'.
npm ERR! This is most likely a problem with the ffi package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-gyp rebuild
npm ERR! You can get their info via:
npm ERR! npm owner ls ffi
npm ERR! There is likely additional logging output above.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.