Browse Source

Improved WebTexture component

Josh Engebretson 10 years ago
parent
commit
0ab7785b9f
1 changed files with 14 additions and 6 deletions
  1. 14 6
      WebTexture/Resources/Components/WebTexture.js

+ 14 - 6
WebTexture/Resources/Components/WebTexture.js

@@ -1,18 +1,26 @@
 "atomic component";
 
-var webClient = new WebView.WebClient();
+// First create a web texture and set filtering mode
 var webTexture = new WebView.WebTexture2D();
 var texture2D = webTexture.texture2D;
 texture2D.filterMode = Atomic.FILTER_TRILINEAR;
+
+// Setup a simple material for the web texture
+var webMaterial = new Atomic.Material();
+webMaterial.setTechnique(0, Atomic.cache.getResource("Technique", "Techniques/Diff.xml"));
+webMaterial.setTexture(Atomic.TU_DIFFUSE, texture2D);
+
+// Create web client with pluggable handlers
+var webClient = new WebView.WebClient();
+// Set our render handler to be the WebTexture2D we created above
 webClient.webRenderHandler = webTexture;
-webClient.createBrowser("http://www.atomicgameengine.com", 1224, 1224);
-var renderMaterial = new Atomic.Material();
-renderMaterial.setTechnique(0, Atomic.cache.getResource("Technique", "Techniques/Diff.xml"));
-renderMaterial.setTexture(Atomic.TU_DIFFUSE, texture2D);
+// Create the browser!
+webClient.createBrowser("http://www.atomicgameengine.com", 1024, 1024);
 
 exports.component = function(self) {
 
+  // assign the web material to our model component
   var model = self.node.getComponent("StaticModel");
-  model.setMaterial(renderMaterial);
+  model.setMaterial(webMaterial);
 
 }