Commit Graph

15 Commits

Author SHA1 Message Date
Philip Rideout
5da454f652 JavaScript: concise texture creation functions
This makes our createTexture* helpers more consistent with the
createMaterial helper, and extends the wrapped Engine class with new
methods.

Before, clients did something like this:

    const ao = Filament.createTextureFromPng(Filament.assets['foo.png'], engine);
    ...
    engine.destroyTexture(ao);

Now, they can do:

    const ao = engine.createTextureFromPng('foo.png');
    ...
    engine.destroyTexture(ao);

This is more symmetric and concise. In general the JS API now supports a
class of "buffer-like" objects which exploit dynamic typing in order to
accept any of the following: BufferDescriptor, asset string, or
Uint8Array.
2018-10-29 18:09:45 -07:00
Philip Rideout
3b793a7994 Fix bad memory access in JS wood demo. 2018-10-26 16:29:26 -07:00
Philip Rideout
83e4402e90 JS: fix use-before-free for PNG data. 2018-10-26 10:05:18 -07:00
Philip Rideout
c6a1900beb Add JS utility for PNG files. 2018-10-26 10:05:18 -07:00
Philip Rideout
b73f58e6ef Expose MeshIO to JavaScript clients. 2018-10-25 08:12:53 -07:00
Philip Rideout
68dfb5ae80 Introduce reference page for JS.
The docgen script now looks for /// comments in the binding definitions,
and generates markdown from those. The reference page has three
sections: classes, free functions, and enums.
2018-10-24 10:05:08 -07:00
Philip Rideout
ab24665396 Allow JS clients to configure FXAA and WebGL context. 2018-10-23 07:58:16 -07:00
Philip Rideout
605a836565 Add JavaScript utility functions to reduce boilerplate. (#406)
* JS utilities: simplified render method.

* redball tutorial now rotates camera.

* JS utilities: add createTextureFromKtx.

* JS utilities: add createIblFromKtx.

* Repair testwasm.

* Update libs/filamentjs/docs/tutorial_redball.md

Co-Authored-By: prideout <philiprideout@gmail.com>

* Update libs/filamentjs/docs/tutorial_redball.md

Co-Authored-By: prideout <philiprideout@gmail.com>

* Update libs/filamentjs/docs/tutorial_redball.md

Co-Authored-By: prideout <philiprideout@gmail.com>
2018-10-18 18:19:05 -07:00
Philip Rideout
b0853b5eb6 jsbindings: fix buffer lifetime bug.
This is a fix-up to f5319f2.
2018-10-18 12:29:22 -07:00
Philip Rideout
d3e7f40398 Add IBL to jsbinding and testwasm. 2018-10-17 16:13:53 -07:00
Philip Rideout
f5319f2492 jsbindings: fix buffer lifetime bug.
In order to match its JavaScript counterpart, the Buffer wrapper needs
to use reference counting, and the easiest way to achieve that is
with shared_ptr.
2018-10-17 16:13:53 -07:00
Philip Rideout
e00ba80561 jsbindings: add JS utilities, enhance testwasm. 2018-10-17 10:17:04 -07:00
Philip Rideout
9b8d5fdf12 Add JS bindings for Texture, PixelBufferDescriptor, et al. 2018-10-15 18:35:53 -07:00
Philip Rideout
0326d60d0a jsbindings: simplify BufferDescriptor wrapper.
The JS BufferDescriptor wrapper is used in two directions: JS => WASM
and WASM => JS. In both cases, it needs to be sure to delete the
underlying driver::BufferDescriptor. This is safe because the contents
of the underlying descriptor are always moved to its final destination
before the wrapper is destroyed.
2018-10-15 12:16:02 -07:00
Philip Rideout
473824b15e Introduce JavaScript API using embind.
This adds filamentjs to libs, which builds a Filament-only WASM file.
Unlike our existing web demos, this WASM file contains no application
code.

These bindings are by no means complete, but they are sufficient for a
"hello triangle" demo that I have working locally. Sneak peak of the
Triangle JS app code:

    https://gist.github.com/prideout/e9d6dd0e312146c8a287d2d109affa4d

This commit merely adds the bindings to the build. Demos and docs are
forthcoming.
2018-10-12 17:09:52 -07:00