Update public site with latest JavaScript demos.

It has been a while, we've made a fix to our KTX writer, added a helmet
demo, etc.
This commit is contained in:
Philip Rideout
2019-03-08 17:49:28 -08:00
parent f1f9fde3a4
commit 64f2a580da
47 changed files with 209 additions and 24 deletions
+1 -1
View File
@@ -26,7 +26,7 @@
<pubDate>Tue, 30 Oct 2018 13:13:14 -0700</pubDate>
<guid>https://google.github.io/filament/webgl/</guid>
<description> tutorials Triangle Tutorial Redball Tutorial Suzanne Tutorial demos parquet suzanne knotess other documentation JavaScript API reference WebGL Meetup Slides (2018) </description>
<description> tutorials Triangle Tutorial Redball Tutorial Suzanne Tutorial demos parquet suzanne helmet knotess other documentation JavaScript API reference WebGL Meetup Slides (2018) </description>
</item>
</channel>
Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 806 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 737 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 MiB

Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
View File
Binary file not shown.
Binary file not shown.
+9 -12
View File
File diff suppressed because one or more lines are too long
Binary file not shown.
Binary file not shown.
+154
View File
@@ -0,0 +1,154 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>FlightHelmet</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,user-scalable=no,initial-scale=1">
<link href="https://google.github.io/filament/favicon.png" rel="icon" type="image/x-icon" />
<style>
body { margin: 0; overflow: hidden; }
canvas { touch-action: none; width: 100%; height: 100%; }
</style>
</head>
<body>
<canvas></canvas>
<script src="filament.js"></script>
<script src="gl-matrix-min.js"></script>
<script src="https://unpkg.com/gltumble"></script>
<script>
const ibl_suffix = Filament.getSupportedFormatSuffix('etc s3tc');
const env = 'syferfontein_18d_clear_2k';
const ibl_url = `${env}/${env}_ibl${ibl_suffix}.ktx`;
const sky_url = `${env}/${env}_skybox.ktx`;
const helmet_filamat_url = 'helmet.filamat';
const filamesh_url = 'helmet.filamesh';
Filament.init([
'FlightHelmet_baseColor.png',
'FlightHelmet_occlusionRoughnessMetallic.png',
'FlightHelmet_normal.png',
'FlightHelmet_baseColor1.png',
'FlightHelmet_occlusionRoughnessMetallic1.png',
'FlightHelmet_normal1.png',
'FlightHelmet_baseColor2.png',
'FlightHelmet_occlusionRoughnessMetallic2.png',
'FlightHelmet_normal2.png',
'FlightHelmet_baseColor3.png',
'FlightHelmet_occlusionRoughnessMetallic3.png',
'FlightHelmet_normal3.png',
'FlightHelmet_baseColor4.png',
'FlightHelmet_occlusionRoughnessMetallic4.png',
'FlightHelmet_normal4.png',
helmet_filamat_url, filamesh_url, ibl_url, sky_url
], () => {
window.Fov = Filament.Camera$Fov;
window.LightType = Filament.LightManager$Type;
window.app = new App(document.getElementsByTagName('canvas')[0]);
});
class App {
constructor(canvas) {
this.canvas = canvas;
const engine = this.engine = Filament.Engine.create(this.canvas);
this.scene = engine.createScene();
this.trackball = new Trackball(canvas, {startSpin: 0.035});
const sunlight = Filament.EntityManager.get().create();
Filament.LightManager.Builder(LightType.SUN)
.color([0.98, 0.92, 0.89])
.intensity(100000.0)
.direction([0.6, -1.0, -0.8])
.castShadows(true)
.sunAngularRadius(1.9)
.sunHaloSize(10.0)
.sunHaloFalloff(80.0)
.build(engine, sunlight);
this.scene.addEntity(sunlight);
const indirectLight = this.ibl = engine.createIblFromKtx(ibl_url);
this.scene.setIndirectLight(indirectLight);
indirectLight.setIntensity(100000);
const skybox = engine.createSkyFromKtx(sky_url);
this.scene.setSkybox(skybox);
const sampler = new Filament.TextureSampler(
Filament.MinFilter.LINEAR_MIPMAP_LINEAR,
Filament.MagFilter.LINEAR,
Filament.WrapMode.CLAMP_TO_EDGE);
const helmetMaterial = engine.createMaterial(helmet_filamat_url);
const setTextures = function(minstance, suffix) {
const setParam = minstance.setTextureParameter.bind(minstance);
const createTex = engine.createTextureFromPng.bind(engine);
const baseColor = `FlightHelmet_baseColor${suffix}.png`;
const orm = `FlightHelmet_occlusionRoughnessMetallic${suffix}.png`;
const normal = `FlightHelmet_normal${suffix}.png`;
setParam('baseColor', createTex(baseColor, {srgb: true}), sampler);
setParam('occlusionRoughnessMetallic', createTex(orm), sampler);
setParam('normalMap', createTex(normal), sampler);
};
const GlassPlasticMat = helmetMaterial.createInstance();
const LeatherPartsMat = helmetMaterial.createInstance();
const LensesMat = helmetMaterial.createInstance();
const MetalPartsMat = helmetMaterial.createInstance();
const RubberWoodMat = helmetMaterial.createInstance();
setTextures(GlassPlasticMat, '');
setTextures(LeatherPartsMat, '1');
setTextures(LensesMat, '2');
setTextures(MetalPartsMat, '3');
setTextures(RubberWoodMat, '4');
const mats = { GlassPlasticMat, LeatherPartsMat, LensesMat, MetalPartsMat, RubberWoodMat };
const mesh = engine.loadFilamesh(filamesh_url, null, mats);
let rm = engine.getRenderableManager();
let renderable = rm.getInstance(mesh.renderable);
rm.setCastShadows(renderable, true);
rm.setReceiveShadows(renderable, true);
this.helmet = mesh.renderable;
this.scene.addEntity(mesh.renderable);
this.swapChain = engine.createSwapChain();
this.renderer = engine.createRenderer();
this.camera = engine.createCamera();
this.view = engine.createView();
this.view.setCamera(this.camera);
this.view.setScene(this.scene);
this.resize();
this.render = this.render.bind(this);
this.resize = this.resize.bind(this);
window.addEventListener('resize', this.resize);
window.requestAnimationFrame(this.render);
}
render() {
const tcm = this.engine.getTransformManager();
const inst = tcm.getInstance(this.helmet);
tcm.setTransform(inst, this.trackball.getMatrix());
inst.delete();
this.renderer.render(this.swapChain, this.view);
window.requestAnimationFrame(this.render);
}
resize() {
const dpr = window.devicePixelRatio;
const width = this.canvas.width = window.innerWidth * dpr;
const height = this.canvas.height = window.innerHeight * dpr;
this.view.setViewport([0, 0, width, height]);
const y = -0.125, eye = [0, y, 2], center = [0, y, 0], up = [0, 1, 0];
this.camera.lookAt(eye, center, up);
const aspect = width / height;
const fov = aspect < 1 ? Fov.HORIZONTAL : Fov.VERTICAL;
this.camera.setProjectionFov(30, aspect, 1.0, 10.0, fov);
}
}
</script>
</body>
</html>
+1
View File
@@ -79,6 +79,7 @@
<ul>
<li><a href="https://google.github.io/filament/webgl/parquet.html">parquet</a></li>
<li><a href="https://google.github.io/filament/webgl/suzanne.html">suzanne</a></li>
<li><a href="https://google.github.io/filament/webgl/helmet.html">helmet</a></li>
<li><a href="https://prideout.net/knotess/">knotess</a></li>
</ul>
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+34 -1
View File
@@ -48,6 +48,10 @@
<td align="left">Singleton used for constructing entities in Filament's ECS.</td>
</tr>
<tr>
<td align="left"><a href="#Frustum">Frustum</a></td>
<td align="left">Represents the six planes of a truncated viewing pyramid</td>
</tr>
<tr>
<td align="left"><a href="#IcoSphere">IcoSphere</a></td>
<td align="left">Utility class for constructing spheres (requires glMatrix).</td>
</tr>
@@ -178,6 +182,10 @@
<td align="left"></td>
</tr>
<tr>
<td align="left"><a href="#Frustum%24Plane">Frustum$Plane</a></td>
<td align="left"></td>
</tr>
<tr>
<td align="left"><a href="#IndexBuffer%24IndexType">IndexBuffer$IndexType</a></td>
<td align="left"></td>
</tr>
@@ -420,6 +428,16 @@
<li><em>view</em> an instance of <a href="#View">View</a></li>
</ul>
</li>
<li><strong>engine.getLightManager()</strong>
<ul>
<li><em>returns</em> an instance of <a href="#LightManager">LightManager</a></li>
</ul>
</li>
<li><strong>engine.getRenderableManager()</strong>
<ul>
<li><em>returns</em> an instance of <a href="#RenderableManager">RenderableManager</a></li>
</ul>
</li>
<li><strong>engine.getTransformManager()</strong>
<ul>
<li><em>returns</em> an instance of <a href="#TransformManager">TransformManager</a></li>
@@ -430,7 +448,7 @@
<li>Consumes the contents of a filamesh file and creates a renderable.</li>
<li><em>buffer</em> asset string, or Uint8Array, or <a href="#Buffer">Buffer</a> with filamesh contents</li>
<li><em>definstance</em> Optional default <a href="#MaterialInstance">MaterialInstance</a></li>
<li><em>matinstances</em> Optional object that gets filled with name =&gt; <a href="#MaterialInstance">MaterialInstance</a></li>
<li><em>matinstances</em> Optional in-out object that gets populated with a name-to-<a href="#MaterialInstance">MaterialInstance</a> mapping. Clients can also optionally provide individual material instances using this argument.</li>
<li><em>returns</em> JavaScript object with keys <code>renderable</code>, <code>vertexBuffer</code>, and <code>indexBuffer</code>. These are of type <a href="#Entity">Entity</a>, <a href="#VertexBuffer">VertexBuffer</a>, and <a href="#IndexBuffer">IndexBuffer</a>.</li>
</ul>
</li>
@@ -459,6 +477,10 @@
</ul>
</div>
<div class='classdoc'>
<h2>class <a id='Frustum' href='#Frustum'>Frustum</a></h2>
<p>Represents the six planes of a truncated viewing pyramid</p>
</div>
<div class='classdoc'>
<h2>class <a id='IcoSphere' href='#IcoSphere'>IcoSphere</a></h2>
<p>Utility class for constructing spheres (requires glMatrix).</p>
<p>The constructor takes an integer subdivision level, with 0 being an icosahedron.
@@ -897,6 +919,17 @@ This defines the following functions:</p>
</ul>
</div>
<div class='enumdoc'>
<h2>enum <a id='Frustum$Plane' href='#Frustum$Plane'>Frustum$Plane</a></h2>
<ul>
<li>LEFT</li>
<li>RIGHT</li>
<li>BOTTOM</li>
<li>TOP</li>
<li>FAR</li>
<li>NEAR</li>
</ul>
</div>
<div class='enumdoc'>
<h2>enum <a id='IndexBuffer$IndexType' href='#IndexBuffer$IndexType'>IndexBuffer$IndexType</a></h2>
<ul>
<li>USHORT</li>
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+1 -1
View File
@@ -170,7 +170,7 @@ vb.setBufferAt(engine, <span style="color: #666666">1</span>, icosphere.tangents
ib.setBuffer(engine, icosphere.triangles);
Filament.RenderableManager.Builder(<span style="color: #666666">1</span>)
.boundingBox([ [<span style="color: #666666">-1</span>, <span style="color: #666666">-1</span>, <span style="color: #666666">-1</span>], [<span style="color: #666666">1</span>, <span style="color: #666666">1</span>, <span style="color: #666666">1</span>] ])
.boundingBox({ center<span style="color: #666666">:</span> [<span style="color: #666666">-1</span>, <span style="color: #666666">-1</span>, <span style="color: #666666">-1</span>], halfExtent<span style="color: #666666">:</span> [<span style="color: #666666">1</span>, <span style="color: #666666">1</span>, <span style="color: #666666">1</span>] })
.material(<span style="color: #666666">0</span>, matinstance)
.geometry(<span style="color: #666666">0</span>, PrimitiveType.TRIANGLES, vb, ib)
.build(engine, renderable);
+4 -4
View File
@@ -45,10 +45,10 @@ class App {
vb.setBufferAt(engine, 1, icosphere.tangents);
ib.setBuffer(engine, icosphere.triangles);
Filament.RenderableManager.Builder(1)
.boundingBox([
[-1, -1, -1],
[1, 1, 1]
])
.boundingBox({
center: [-1, -1, -1],
halfExtent: [1, 1, 1]
})
.material(0, matinstance)
.geometry(0, PrimitiveType.TRIANGLES, vb, ib)
.build(engine, renderable);
+1 -1
View File
@@ -170,7 +170,7 @@ triangle by setting up a bounding box and passing in the vertex and index buffer
<div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%"><span></span><span style="color: #008000; font-weight: bold">const</span> mat <span style="color: #666666">=</span> engine.createMaterial(<span style="color: #BA2121">&#39;triangle.filamat&#39;</span>);
<span style="color: #008000; font-weight: bold">const</span> matinst <span style="color: #666666">=</span> mat.getDefaultInstance();
Filament.RenderableManager.Builder(<span style="color: #666666">1</span>)
.boundingBox([[ <span style="color: #666666">-1</span>, <span style="color: #666666">-1</span>, <span style="color: #666666">-1</span> ], [ <span style="color: #666666">1</span>, <span style="color: #666666">1</span>, <span style="color: #666666">1</span> ]])
.boundingBox({ center<span style="color: #666666">:</span> [<span style="color: #666666">-1</span>, <span style="color: #666666">-1</span>, <span style="color: #666666">-1</span>], halfExtent<span style="color: #666666">:</span> [<span style="color: #666666">1</span>, <span style="color: #666666">1</span>, <span style="color: #666666">1</span>] })
.material(<span style="color: #666666">0</span>, matinst)
.geometry(<span style="color: #666666">0</span>, Filament.RenderableManager$PrimitiveType.TRIANGLES, <span style="color: #008000; font-weight: bold">this</span>.vb, <span style="color: #008000; font-weight: bold">this</span>.ib)
.build(engine, <span style="color: #008000; font-weight: bold">this</span>.triangle);
+4 -4
View File
@@ -31,10 +31,10 @@ class App {
const mat = engine.createMaterial('triangle.filamat');
const matinst = mat.getDefaultInstance();
Filament.RenderableManager.Builder(1)
.boundingBox([
[-1, -1, -1],
[1, 1, 1]
])
.boundingBox({
center: [-1, -1, -1],
halfExtent: [1, 1, 1]
})
.material(0, matinst)
.geometry(0, Filament.RenderableManager$PrimitiveType.TRIANGLES, this.vb, this.ib)
.build(engine, this.triangle);