Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(343)

Unified Diff: examples/js/cube.js

Issue 839553004: Mojo JS Bindings: Update User's Guide, examples (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « examples/js/README.md ('k') | examples/js/hello.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: examples/js/cube.js
diff --git a/examples/js/cube.js b/examples/js/cube.js
index 3316885c26356c4813bce99c0e58309249926901..9ae7e902e64151fbb365f4a755bc4481c344d59d 100644
--- a/examples/js/cube.js
+++ b/examples/js/cube.js
@@ -7,7 +7,6 @@
define("main", [
"console",
"mojo/services/public/js/application",
- "mojo/services/gpu/public/interfaces/command_buffer.mojom",
"mojo/services/geometry/public/interfaces/geometry.mojom",
"mojo/services/gpu/public/interfaces/gpu.mojom",
"mojo/services/gpu/public/interfaces/viewport_parameter_listener.mojom",
@@ -17,16 +16,22 @@ define("main", [
"services/js/modules/clock",
"timer",
], function(console,
- appModule,
- cbModule,
- geoModule,
- gpuModule,
- vplModule,
- nvModule,
- coreModule,
- glModule,
- clockModule,
- timerModule) {
+ application,
+ geometry,
+ gpu,
+ vpl,
+ nv,
+ core,
+ gl,
+ clock,
+ timer) {
+
+ var Application = application.Application;
eseidel 2015/01/06 21:02:01 Can we use const?
+ var Context = gl.Context;
+ var Gpu = gpu.Gpu;
+ var Size = geometry.Size;
+ var ViewportParameterListener = vpl.ViewportParameterListener;
+ var NativeViewport = nv.NativeViewport;
const VERTEX_SHADER_SOURCE = [
'uniform mat4 u_mvpMatrix;',
@@ -285,8 +290,8 @@ define("main", [
class GLES2ClientImpl {
constructor (remotePipe, size) {
- this.gl_ = new glModule.Context(remotePipe, this.contextLost.bind(this));
- this.lastTime_ = clockModule.seconds();
+ this.gl_ = new Context(remotePipe, this.contextLost.bind(this));
+ this.lastTime_ = clock.seconds();
this.angle_ = 45;
this.program_ = loadProgram(this.gl_);
@@ -301,7 +306,7 @@ define("main", [
this.gl_.clearColor(0, 0, 0, 0);
this.setDimensions(size);
this.timer_ =
- timerModule.createRepeating(16, this.handleTimer.bind(this));
+ timer.createRepeating(16, this.handleTimer.bind(this));
}
setDimensions(size) {
@@ -326,7 +331,7 @@ define("main", [
};
handleTimer() {
- var now = clockModule.seconds();
+ var now = clock.seconds();
var secondsDelta = now - this.lastTime_;
this.lastTime_ = now;
@@ -365,16 +370,16 @@ define("main", [
}
}
- class CubeDemo extends appModule.Application {
+ class CubeDemo extends Application {
initialize(args) {
this.viewport = this.shell.connectToService(
- "mojo:native_viewport_service", nvModule.NativeViewport, this);
+ "mojo:native_viewport_service", NativeViewport, this);
this.gpu = this.shell.connectToService(
- "mojo:native_viewport_service", gpuModule.Gpu);
+ "mojo:native_viewport_service", Gpu);
var app = this;
- var viewportSize = new geoModule.Size({width: 800, height: 600});
+ var viewportSize = new Size({width: 800, height: 600});
this.viewport.create(viewportSize).then(
function(result) {
app.onViewportCreated(result.native_viewport_id, viewportSize);
@@ -385,12 +390,12 @@ define("main", [
}
onViewportCreated(id, size) {
- this.vpl = new vplModule.ViewportParameterListener.stubClass({
+ this.vpl = new ViewportParameterListener.stubClass({
onVSyncParametersUpdated: function(timebase, interval) {
console.log("onVSyncParametersUpdated");
}
});
- var pipe = coreModule.createMessagePipe();
+ var pipe = core.createMessagePipe();
this.gpu.createOnscreenGLES2Context(id, size, pipe.handle1, this.vpl);
this.gles2_ = new GLES2ClientImpl(pipe.handle0, size);
}
« no previous file with comments | « examples/js/README.md ('k') | examples/js/hello.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698