scenejs_on_rails 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +5 -5
- data/app/controllers/scenejs_controller.rb +53 -0
- data/app/views/scenejs/get_scenejs_data.html.erb +3 -0
- data/lib/scenejs_on_rails.rb +1 -1
- data/lib/scenejs_on_rails/rails.rb +5 -0
- data/lib/scenejs_on_rails/version.rb +1 -1
- data/vendor/assets/javascripts/scenejs.js +17307 -0
- data/vendor/assets/javascripts/scenejs_extras/gui.js +478 -0
- data/vendor/assets/javascripts/scenejs_extras/gui/README.md +4 -0
- data/vendor/assets/javascripts/scenejs_extras/gui/dat.gui.min.js +94 -0
- data/vendor/assets/javascripts/scenejs_extras/gui/gui.js +385 -0
- data/vendor/assets/javascripts/scenejs_lib/cityBuilder.js +457 -0
- data/vendor/assets/javascripts/scenejs_lib/dat.gui.min.js +94 -0
- data/vendor/assets/javascripts/scenejs_lib/gl-matrix-min.js +28 -0
- data/vendor/assets/javascripts/scenejs_lib/gl-matrix.js +4078 -0
- data/vendor/assets/javascripts/scenejs_lib/require.js +36 -0
- data/vendor/assets/javascripts/scenejs_lib/requireConfig.js +18 -0
- data/vendor/assets/javascripts/scenejs_lib/requireWrapperEnd.js +1 -0
- data/vendor/assets/javascripts/scenejs_lib/requireWrapperStart.js +2 -0
- data/vendor/assets/javascripts/scenejs_lib/stats.min.js +6 -0
- data/vendor/assets/javascripts/scenejs_lib/sylvester.js +1 -0
- data/vendor/assets/javascripts/scenejs_lib/webgl-debug-utils.js +839 -0
- data/vendor/assets/javascripts/scenejs_plugins/geometry/boundary.js +59 -0
- data/vendor/assets/javascripts/scenejs_plugins/geometry/box.js +72 -0
- data/vendor/assets/javascripts/scenejs_plugins/geometry/plane.js +126 -0
- data/vendor/assets/javascripts/scenejs_plugins/geometry/quad.js +37 -0
- data/vendor/assets/javascripts/scenejs_plugins/geometry/skybox.js +86 -0
- data/vendor/assets/javascripts/scenejs_plugins/geometry/sphere.js +82 -0
- data/vendor/assets/javascripts/scenejs_plugins/geometry/teapot.js +5853 -0
- data/vendor/assets/javascripts/scenejs_plugins/geometry/torus.js +139 -0
- data/vendor/assets/javascripts/scenejs_plugins/geometry/vectorText.js +1499 -0
- data/vendor/assets/javascripts/scenejs_plugins/geometry/wobblyBox.js +44 -0
- data/vendor/assets/javascripts/scenejs_plugins/lib/canvas2image.js +198 -0
- data/vendor/assets/javascripts/scenejs_plugins/lib/frustum/frustumCullEngine.js +810 -0
- data/vendor/assets/javascripts/scenejs_plugins/lib/frustum/frustumCullSystem.js +185 -0
- data/vendor/assets/javascripts/scenejs_plugins/lib/frustum/frustumCullSystemPool.js +174 -0
- data/vendor/assets/javascripts/scenejs_plugins/lib/frustum/frustumCullWorker.js +142 -0
- data/vendor/assets/javascripts/scenejs_plugins/lib/gl-matrix-min.js +28 -0
- data/vendor/assets/javascripts/scenejs_plugins/lib/jquery-1.8.3.min.js +2 -0
- data/vendor/assets/javascripts/scenejs_plugins/lib/k3d.js +1029 -0
- data/vendor/assets/javascripts/scenejs_plugins/lib/physics/jiglib.all.min.js +3 -0
- data/vendor/assets/javascripts/scenejs_plugins/lib/physics/physics.js +223 -0
- data/vendor/assets/javascripts/scenejs_plugins/lib/physics/worker.js +330 -0
- data/vendor/assets/javascripts/scenejs_plugins/node/alpha/orbitTracking.js +295 -0
- data/vendor/assets/javascripts/scenejs_plugins/node/alpha/orbitTrackingTarget.js +43 -0
- data/vendor/assets/javascripts/scenejs_plugins/node/backgrounds/gradient.js +148 -0
- data/vendor/assets/javascripts/scenejs_plugins/node/cameras/orbit.js +172 -0
- data/vendor/assets/javascripts/scenejs_plugins/node/cameras/pickFlyOrbit.js +409 -0
- data/vendor/assets/javascripts/scenejs_plugins/node/canvas/capture.js +107 -0
- data/vendor/assets/javascripts/scenejs_plugins/node/demos/color.js +30 -0
- data/vendor/assets/javascripts/scenejs_plugins/node/demos/redTeapot.js +52 -0
- data/vendor/assets/javascripts/scenejs_plugins/node/demos/spinningTeapot.js +43 -0
- data/vendor/assets/javascripts/scenejs_plugins/node/effects/crt.js +36 -0
- data/vendor/assets/javascripts/scenejs_plugins/node/effects/fog.js +159 -0
- data/vendor/assets/javascripts/scenejs_plugins/node/effects/snowyPeaks.js +50 -0
- data/vendor/assets/javascripts/scenejs_plugins/node/effects/wobble.js +42 -0
- data/vendor/assets/javascripts/scenejs_plugins/node/effects/xray.js +126 -0
- data/vendor/assets/javascripts/scenejs_plugins/node/frustum/body.js +112 -0
- data/vendor/assets/javascripts/scenejs_plugins/node/frustum/cull.js +42 -0
- data/vendor/assets/javascripts/scenejs_plugins/node/frustum/lod.js +125 -0
- data/vendor/assets/javascripts/scenejs_plugins/node/heightmaps/custom.js +185 -0
- data/vendor/assets/javascripts/scenejs_plugins/node/import/3ds.js +91 -0
- data/vendor/assets/javascripts/scenejs_plugins/node/import/md2.js +139 -0
- data/vendor/assets/javascripts/scenejs_plugins/node/import/obj.js +100 -0
- data/vendor/assets/javascripts/scenejs_plugins/node/objects/buildings/building.js +352 -0
- data/vendor/assets/javascripts/scenejs_plugins/node/objects/buildings/building/HighRiseGlass.jpg +0 -0
- data/vendor/assets/javascripts/scenejs_plugins/node/objects/buildings/building/HighRiseGlassSpecular.jpg +0 -0
- data/vendor/assets/javascripts/scenejs_plugins/node/objects/buildings/building/highrise-windows.jpg +0 -0
- data/vendor/assets/javascripts/scenejs_plugins/node/objects/buildings/building/pixelcity_windows7.jpg +0 -0
- data/vendor/assets/javascripts/scenejs_plugins/node/objects/buildings/city.js +26 -0
- data/vendor/assets/javascripts/scenejs_plugins/node/objects/plants/ghostTree.js +387 -0
- data/vendor/assets/javascripts/scenejs_plugins/node/objects/space/planets/earth.js +168 -0
- data/vendor/assets/javascripts/scenejs_plugins/node/objects/space/planets/earth/earth-lights.gif +0 -0
- data/vendor/assets/javascripts/scenejs_plugins/node/objects/space/planets/earth/earth-specular.gif +0 -0
- data/vendor/assets/javascripts/scenejs_plugins/node/objects/space/planets/earth/earth-specular.jpg +0 -0
- data/vendor/assets/javascripts/scenejs_plugins/node/objects/space/planets/earth/earth.jpg +0 -0
- data/vendor/assets/javascripts/scenejs_plugins/node/objects/space/planets/earth/earthbump.jpg +0 -0
- data/vendor/assets/javascripts/scenejs_plugins/node/objects/space/planets/earth/earthclouds.jpg +0 -0
- data/vendor/assets/javascripts/scenejs_plugins/node/objects/toys/drinkingBird.js +632 -0
- data/vendor/assets/javascripts/scenejs_plugins/node/objects/vehicles/tank.js +77670 -0
- data/vendor/assets/javascripts/scenejs_plugins/node/objects/vehicles/tank.js~ +77636 -0
- data/vendor/assets/javascripts/scenejs_plugins/node/physics/body.js +85 -0
- data/vendor/assets/javascripts/scenejs_plugins/node/physics/box.js +30 -0
- data/vendor/assets/javascripts/scenejs_plugins/node/physics/material.js +35 -0
- data/vendor/assets/javascripts/scenejs_plugins/node/physics/plane.js +47 -0
- data/vendor/assets/javascripts/scenejs_plugins/node/physics/sphere.js +32 -0
- data/vendor/assets/javascripts/scenejs_plugins/node/physics/system.js +44 -0
- data/vendor/assets/javascripts/scenejs_plugins/node/physics/teapot.js +29 -0
- data/vendor/assets/javascripts/scenejs_plugins/node/prims/boundary.js +73 -0
- data/vendor/assets/javascripts/scenejs_plugins/node/prims/box.js +87 -0
- data/vendor/assets/javascripts/scenejs_plugins/node/prims/cylinder.js +186 -0
- data/vendor/assets/javascripts/scenejs_plugins/node/prims/grid.js +47 -0
- data/vendor/assets/javascripts/scenejs_plugins/node/prims/plane.js +137 -0
- data/vendor/assets/javascripts/scenejs_plugins/node/prims/quad.js +43 -0
- data/vendor/assets/javascripts/scenejs_plugins/node/prims/sphere.js +107 -0
- data/vendor/assets/javascripts/scenejs_plugins/node/prims/teapot.js +5846 -0
- data/vendor/assets/javascripts/scenejs_plugins/node/prims/torus.js +149 -0
- data/vendor/assets/javascripts/scenejs_plugins/node/prims/vectorText.js +1508 -0
- data/vendor/assets/javascripts/scenejs_plugins/node/skyboxes/clouds.js +19 -0
- data/vendor/assets/javascripts/scenejs_plugins/node/skyboxes/cloudySea.js +19 -0
- data/vendor/assets/javascripts/scenejs_plugins/node/skyboxes/custom.js +150 -0
- data/vendor/assets/javascripts/scenejs_plugins/node/skyboxes/grimmNight.js +19 -0
- data/vendor/assets/javascripts/scenejs_plugins/node/skyboxes/interstellarClouds.js +19 -0
- data/vendor/assets/javascripts/scenejs_plugins/node/skyboxes/miramarClouds.js +19 -0
- data/vendor/assets/javascripts/scenejs_plugins/node/skyboxes/stormyDays.js +19 -0
- data/vendor/assets/javascripts/scenejs_plugins/node/skyboxes/textures/clouds.jpg +0 -0
- data/vendor/assets/javascripts/scenejs_plugins/node/skyboxes/textures/cloudySea.jpg +0 -0
- data/vendor/assets/javascripts/scenejs_plugins/node/skyboxes/textures/grimmNight.jpg +0 -0
- data/vendor/assets/javascripts/scenejs_plugins/node/skyboxes/textures/interstellarClouds.jpg +0 -0
- data/vendor/assets/javascripts/scenejs_plugins/node/skyboxes/textures/miramarClouds.jpg +0 -0
- data/vendor/assets/javascripts/scenejs_plugins/node/skyboxes/textures/stormyDays.jpg +0 -0
- data/vendor/assets/javascripts/scenejs_plugins/node/skyboxes/textures/violentDays.jpg +0 -0
- data/vendor/assets/javascripts/scenejs_plugins/node/skyboxes/violentDays.js +19 -0
- data/vendor/assets/javascripts/scenejs_plugins/texture/image.js +67 -0
- data/vendor/assets/javascripts/scenejs_plugins/texture/video.js +105 -0
- metadata +113 -1
@@ -0,0 +1,36 @@
|
|
1
|
+
/*
|
2
|
+
RequireJS 2.1.6 Copyright (c) 2010-2012, The Dojo Foundation All Rights Reserved.
|
3
|
+
Available via the MIT or new BSD license.
|
4
|
+
see: http://github.com/jrburke/requirejs for details
|
5
|
+
*/
|
6
|
+
var requirejs,require,define;
|
7
|
+
(function(ba){function J(b){return"[object Function]"===N.call(b)}function K(b){return"[object Array]"===N.call(b)}function z(b,c){if(b){var d;for(d=0;d<b.length&&(!b[d]||!c(b[d],d,b));d+=1);}}function O(b,c){if(b){var d;for(d=b.length-1;-1<d&&(!b[d]||!c(b[d],d,b));d-=1);}}function t(b,c){return ha.call(b,c)}function m(b,c){return t(b,c)&&b[c]}function H(b,c){for(var d in b)if(t(b,d)&&c(b[d],d))break}function S(b,c,d,m){c&&H(c,function(c,l){if(d||!t(b,l))m&&"string"!==typeof c?(b[l]||(b[l]={}),S(b[l],
|
8
|
+
c,d,m)):b[l]=c});return b}function v(b,c){return function(){return c.apply(b,arguments)}}function ca(b){throw b;}function da(b){if(!b)return b;var c=ba;z(b.split("."),function(b){c=c[b]});return c}function B(b,c,d,m){c=Error(c+"\nhttp://requirejs.org/docs/errors.html#"+b);c.requireType=b;c.requireModules=m;d&&(c.originalError=d);return c}function ia(b){function c(a,f,C){var e,n,b,c,d,T,k,g=f&&f.split("/");e=g;var l=j.map,h=l&&l["*"];if(a&&"."===a.charAt(0))if(f){e=m(j.pkgs,f)?g=[f]:g.slice(0,g.length-
|
9
|
+
1);f=a=e.concat(a.split("/"));for(e=0;f[e];e+=1)if(n=f[e],"."===n)f.splice(e,1),e-=1;else if(".."===n)if(1===e&&(".."===f[2]||".."===f[0]))break;else 0<e&&(f.splice(e-1,2),e-=2);e=m(j.pkgs,f=a[0]);a=a.join("/");e&&a===f+"/"+e.main&&(a=f)}else 0===a.indexOf("./")&&(a=a.substring(2));if(C&&l&&(g||h)){f=a.split("/");for(e=f.length;0<e;e-=1){b=f.slice(0,e).join("/");if(g)for(n=g.length;0<n;n-=1)if(C=m(l,g.slice(0,n).join("/")))if(C=m(C,b)){c=C;d=e;break}if(c)break;!T&&(h&&m(h,b))&&(T=m(h,b),k=e)}!c&&
|
10
|
+
T&&(c=T,d=k);c&&(f.splice(0,d,c),a=f.join("/"))}return a}function d(a){A&&z(document.getElementsByTagName("script"),function(f){if(f.getAttribute("data-requiremodule")===a&&f.getAttribute("data-requirecontext")===k.contextName)return f.parentNode.removeChild(f),!0})}function p(a){var f=m(j.paths,a);if(f&&K(f)&&1<f.length)return d(a),f.shift(),k.require.undef(a),k.require([a]),!0}function g(a){var f,b=a?a.indexOf("!"):-1;-1<b&&(f=a.substring(0,b),a=a.substring(b+1,a.length));return[f,a]}function l(a,
|
11
|
+
f,b,e){var n,D,i=null,d=f?f.name:null,l=a,h=!0,j="";a||(h=!1,a="_@r"+(N+=1));a=g(a);i=a[0];a=a[1];i&&(i=c(i,d,e),D=m(r,i));a&&(i?j=D&&D.normalize?D.normalize(a,function(a){return c(a,d,e)}):c(a,d,e):(j=c(a,d,e),a=g(j),i=a[0],j=a[1],b=!0,n=k.nameToUrl(j)));b=i&&!D&&!b?"_unnormalized"+(O+=1):"";return{prefix:i,name:j,parentMap:f,unnormalized:!!b,url:n,originalName:l,isDefine:h,id:(i?i+"!"+j:j)+b}}function s(a){var f=a.id,b=m(q,f);b||(b=q[f]=new k.Module(a));return b}function u(a,f,b){var e=a.id,n=m(q,
|
12
|
+
e);if(t(r,e)&&(!n||n.defineEmitComplete))"defined"===f&&b(r[e]);else if(n=s(a),n.error&&"error"===f)b(n.error);else n.on(f,b)}function w(a,f){var b=a.requireModules,e=!1;if(f)f(a);else if(z(b,function(f){if(f=m(q,f))f.error=a,f.events.error&&(e=!0,f.emit("error",a))}),!e)h.onError(a)}function x(){U.length&&(ja.apply(I,[I.length-1,0].concat(U)),U=[])}function y(a){delete q[a];delete W[a]}function G(a,f,b){var e=a.map.id;a.error?a.emit("error",a.error):(f[e]=!0,z(a.depMaps,function(e,c){var d=e.id,
|
13
|
+
g=m(q,d);g&&(!a.depMatched[c]&&!b[d])&&(m(f,d)?(a.defineDep(c,r[d]),a.check()):G(g,f,b))}),b[e]=!0)}function E(){var a,f,b,e,n=(b=1E3*j.waitSeconds)&&k.startTime+b<(new Date).getTime(),c=[],i=[],g=!1,l=!0;if(!X){X=!0;H(W,function(b){a=b.map;f=a.id;if(b.enabled&&(a.isDefine||i.push(b),!b.error))if(!b.inited&&n)p(f)?g=e=!0:(c.push(f),d(f));else if(!b.inited&&(b.fetched&&a.isDefine)&&(g=!0,!a.prefix))return l=!1});if(n&&c.length)return b=B("timeout","Load timeout for modules: "+c,null,c),b.contextName=
|
14
|
+
k.contextName,w(b);l&&z(i,function(a){G(a,{},{})});if((!n||e)&&g)if((A||ea)&&!Y)Y=setTimeout(function(){Y=0;E()},50);X=!1}}function F(a){t(r,a[0])||s(l(a[0],null,!0)).init(a[1],a[2])}function L(a){var a=a.currentTarget||a.srcElement,b=k.onScriptLoad;a.detachEvent&&!Z?a.detachEvent("onreadystatechange",b):a.removeEventListener("load",b,!1);b=k.onScriptError;(!a.detachEvent||Z)&&a.removeEventListener("error",b,!1);return{node:a,id:a&&a.getAttribute("data-requiremodule")}}function M(){var a;for(x();I.length;){a=
|
15
|
+
I.shift();if(null===a[0])return w(B("mismatch","Mismatched anonymous define() module: "+a[a.length-1]));F(a)}}var X,$,k,P,Y,j={waitSeconds:7,baseUrl:"./",paths:{},pkgs:{},shim:{},config:{}},q={},W={},aa={},I=[],r={},V={},N=1,O=1;P={require:function(a){return a.require?a.require:a.require=k.makeRequire(a.map)},exports:function(a){a.usingExports=!0;if(a.map.isDefine)return a.exports?a.exports:a.exports=r[a.map.id]={}},module:function(a){return a.module?a.module:a.module={id:a.map.id,uri:a.map.url,config:function(){var b=
|
16
|
+
m(j.pkgs,a.map.id);return(b?m(j.config,a.map.id+"/"+b.main):m(j.config,a.map.id))||{}},exports:r[a.map.id]}}};$=function(a){this.events=m(aa,a.id)||{};this.map=a;this.shim=m(j.shim,a.id);this.depExports=[];this.depMaps=[];this.depMatched=[];this.pluginMaps={};this.depCount=0};$.prototype={init:function(a,b,c,e){e=e||{};if(!this.inited){this.factory=b;if(c)this.on("error",c);else this.events.error&&(c=v(this,function(a){this.emit("error",a)}));this.depMaps=a&&a.slice(0);this.errback=c;this.inited=
|
17
|
+
!0;this.ignore=e.ignore;e.enabled||this.enabled?this.enable():this.check()}},defineDep:function(a,b){this.depMatched[a]||(this.depMatched[a]=!0,this.depCount-=1,this.depExports[a]=b)},fetch:function(){if(!this.fetched){this.fetched=!0;k.startTime=(new Date).getTime();var a=this.map;if(this.shim)k.makeRequire(this.map,{enableBuildCallback:!0})(this.shim.deps||[],v(this,function(){return a.prefix?this.callPlugin():this.load()}));else return a.prefix?this.callPlugin():this.load()}},load:function(){var a=
|
18
|
+
this.map.url;V[a]||(V[a]=!0,k.load(this.map.id,a))},check:function(){if(this.enabled&&!this.enabling){var a,b,c=this.map.id;b=this.depExports;var e=this.exports,n=this.factory;if(this.inited)if(this.error)this.emit("error",this.error);else{if(!this.defining){this.defining=!0;if(1>this.depCount&&!this.defined){if(J(n)){if(this.events.error&&this.map.isDefine||h.onError!==ca)try{e=k.execCb(c,n,b,e)}catch(d){a=d}else e=k.execCb(c,n,b,e);this.map.isDefine&&((b=this.module)&&void 0!==b.exports&&b.exports!==
|
19
|
+
this.exports?e=b.exports:void 0===e&&this.usingExports&&(e=this.exports));if(a)return a.requireMap=this.map,a.requireModules=this.map.isDefine?[this.map.id]:null,a.requireType=this.map.isDefine?"define":"require",w(this.error=a)}else e=n;this.exports=e;if(this.map.isDefine&&!this.ignore&&(r[c]=e,h.onResourceLoad))h.onResourceLoad(k,this.map,this.depMaps);y(c);this.defined=!0}this.defining=!1;this.defined&&!this.defineEmitted&&(this.defineEmitted=!0,this.emit("defined",this.exports),this.defineEmitComplete=
|
20
|
+
!0)}}else this.fetch()}},callPlugin:function(){var a=this.map,b=a.id,d=l(a.prefix);this.depMaps.push(d);u(d,"defined",v(this,function(e){var n,d;d=this.map.name;var g=this.map.parentMap?this.map.parentMap.name:null,C=k.makeRequire(a.parentMap,{enableBuildCallback:!0});if(this.map.unnormalized){if(e.normalize&&(d=e.normalize(d,function(a){return c(a,g,!0)})||""),e=l(a.prefix+"!"+d,this.map.parentMap),u(e,"defined",v(this,function(a){this.init([],function(){return a},null,{enabled:!0,ignore:!0})})),
|
21
|
+
d=m(q,e.id)){this.depMaps.push(e);if(this.events.error)d.on("error",v(this,function(a){this.emit("error",a)}));d.enable()}}else n=v(this,function(a){this.init([],function(){return a},null,{enabled:!0})}),n.error=v(this,function(a){this.inited=!0;this.error=a;a.requireModules=[b];H(q,function(a){0===a.map.id.indexOf(b+"_unnormalized")&&y(a.map.id)});w(a)}),n.fromText=v(this,function(e,c){var d=a.name,g=l(d),i=Q;c&&(e=c);i&&(Q=!1);s(g);t(j.config,b)&&(j.config[d]=j.config[b]);try{h.exec(e)}catch(D){return w(B("fromtexteval",
|
22
|
+
"fromText eval for "+b+" failed: "+D,D,[b]))}i&&(Q=!0);this.depMaps.push(g);k.completeLoad(d);C([d],n)}),e.load(a.name,C,n,j)}));k.enable(d,this);this.pluginMaps[d.id]=d},enable:function(){W[this.map.id]=this;this.enabling=this.enabled=!0;z(this.depMaps,v(this,function(a,b){var c,e;if("string"===typeof a){a=l(a,this.map.isDefine?this.map:this.map.parentMap,!1,!this.skipMap);this.depMaps[b]=a;if(c=m(P,a.id)){this.depExports[b]=c(this);return}this.depCount+=1;u(a,"defined",v(this,function(a){this.defineDep(b,
|
23
|
+
a);this.check()}));this.errback&&u(a,"error",v(this,this.errback))}c=a.id;e=q[c];!t(P,c)&&(e&&!e.enabled)&&k.enable(a,this)}));H(this.pluginMaps,v(this,function(a){var b=m(q,a.id);b&&!b.enabled&&k.enable(a,this)}));this.enabling=!1;this.check()},on:function(a,b){var c=this.events[a];c||(c=this.events[a]=[]);c.push(b)},emit:function(a,b){z(this.events[a],function(a){a(b)});"error"===a&&delete this.events[a]}};k={config:j,contextName:b,registry:q,defined:r,urlFetched:V,defQueue:I,Module:$,makeModuleMap:l,
|
24
|
+
nextTick:h.nextTick,onError:w,configure:function(a){a.baseUrl&&"/"!==a.baseUrl.charAt(a.baseUrl.length-1)&&(a.baseUrl+="/");var b=j.pkgs,c=j.shim,e={paths:!0,config:!0,map:!0};H(a,function(a,b){e[b]?"map"===b?(j.map||(j.map={}),S(j[b],a,!0,!0)):S(j[b],a,!0):j[b]=a});a.shim&&(H(a.shim,function(a,b){K(a)&&(a={deps:a});if((a.exports||a.init)&&!a.exportsFn)a.exportsFn=k.makeShimExports(a);c[b]=a}),j.shim=c);a.packages&&(z(a.packages,function(a){a="string"===typeof a?{name:a}:a;b[a.name]={name:a.name,
|
25
|
+
location:a.location||a.name,main:(a.main||"main").replace(ka,"").replace(fa,"")}}),j.pkgs=b);H(q,function(a,b){!a.inited&&!a.map.unnormalized&&(a.map=l(b))});if(a.deps||a.callback)k.require(a.deps||[],a.callback)},makeShimExports:function(a){return function(){var b;a.init&&(b=a.init.apply(ba,arguments));return b||a.exports&&da(a.exports)}},makeRequire:function(a,f){function d(e,c,g){var i,j;f.enableBuildCallback&&(c&&J(c))&&(c.__requireJsBuild=!0);if("string"===typeof e){if(J(c))return w(B("requireargs",
|
26
|
+
"Invalid require call"),g);if(a&&t(P,e))return P[e](q[a.id]);if(h.get)return h.get(k,e,a,d);i=l(e,a,!1,!0);i=i.id;return!t(r,i)?w(B("notloaded",'Module name "'+i+'" has not been loaded yet for context: '+b+(a?"":". Use require([])"))):r[i]}M();k.nextTick(function(){M();j=s(l(null,a));j.skipMap=f.skipMap;j.init(e,c,g,{enabled:!0});E()});return d}f=f||{};S(d,{isBrowser:A,toUrl:function(b){var d,f=b.lastIndexOf("."),g=b.split("/")[0];if(-1!==f&&(!("."===g||".."===g)||1<f))d=b.substring(f,b.length),b=
|
27
|
+
b.substring(0,f);return k.nameToUrl(c(b,a&&a.id,!0),d,!0)},defined:function(b){return t(r,l(b,a,!1,!0).id)},specified:function(b){b=l(b,a,!1,!0).id;return t(r,b)||t(q,b)}});a||(d.undef=function(b){x();var c=l(b,a,!0),d=m(q,b);delete r[b];delete V[c.url];delete aa[b];d&&(d.events.defined&&(aa[b]=d.events),y(b))});return d},enable:function(a){m(q,a.id)&&s(a).enable()},completeLoad:function(a){var b,c,e=m(j.shim,a)||{},d=e.exports;for(x();I.length;){c=I.shift();if(null===c[0]){c[0]=a;if(b)break;b=!0}else c[0]===
|
28
|
+
a&&(b=!0);F(c)}c=m(q,a);if(!b&&!t(r,a)&&c&&!c.inited){if(j.enforceDefine&&(!d||!da(d)))return p(a)?void 0:w(B("nodefine","No define call for "+a,null,[a]));F([a,e.deps||[],e.exportsFn])}E()},nameToUrl:function(a,b,c){var d,g,l,i,k,p;if(h.jsExtRegExp.test(a))i=a+(b||"");else{d=j.paths;g=j.pkgs;i=a.split("/");for(k=i.length;0<k;k-=1)if(p=i.slice(0,k).join("/"),l=m(g,p),p=m(d,p)){K(p)&&(p=p[0]);i.splice(0,k,p);break}else if(l){a=a===l.name?l.location+"/"+l.main:l.location;i.splice(0,k,a);break}i=i.join("/");
|
29
|
+
i+=b||(/\?/.test(i)||c?"":".js");i=("/"===i.charAt(0)||i.match(/^[\w\+\.\-]+:/)?"":j.baseUrl)+i}return j.urlArgs?i+((-1===i.indexOf("?")?"?":"&")+j.urlArgs):i},load:function(a,b){h.load(k,a,b)},execCb:function(a,b,c,d){return b.apply(d,c)},onScriptLoad:function(a){if("load"===a.type||la.test((a.currentTarget||a.srcElement).readyState))R=null,a=L(a),k.completeLoad(a.id)},onScriptError:function(a){var b=L(a);if(!p(b.id))return w(B("scripterror","Script error for: "+b.id,a,[b.id]))}};k.require=k.makeRequire();
|
30
|
+
return k}var h,x,y,E,L,F,R,M,s,ga,ma=/(\/\*([\s\S]*?)\*\/|([^:]|^)\/\/(.*)$)/mg,na=/[^.]\s*require\s*\(\s*["']([^'"\s]+)["']\s*\)/g,fa=/\.js$/,ka=/^\.\//;x=Object.prototype;var N=x.toString,ha=x.hasOwnProperty,ja=Array.prototype.splice,A=!!("undefined"!==typeof window&&navigator&&window.document),ea=!A&&"undefined"!==typeof importScripts,la=A&&"PLAYSTATION 3"===navigator.platform?/^complete$/:/^(complete|loaded)$/,Z="undefined"!==typeof opera&&"[object Opera]"===opera.toString(),G={},u={},U=[],Q=
|
31
|
+
!1;if("undefined"===typeof define){if("undefined"!==typeof requirejs){if(J(requirejs))return;u=requirejs;requirejs=void 0}"undefined"!==typeof require&&!J(require)&&(u=require,require=void 0);h=requirejs=function(b,c,d,p){var g,l="_";!K(b)&&"string"!==typeof b&&(g=b,K(c)?(b=c,c=d,d=p):b=[]);g&&g.context&&(l=g.context);(p=m(G,l))||(p=G[l]=h.s.newContext(l));g&&p.configure(g);return p.require(b,c,d)};h.config=function(b){return h(b)};h.nextTick="undefined"!==typeof setTimeout?function(b){setTimeout(b,
|
32
|
+
4)}:function(b){b()};require||(require=h);h.version="2.1.6";h.jsExtRegExp=/^\/|:|\?|\.js$/;h.isBrowser=A;x=h.s={contexts:G,newContext:ia};h({});z(["toUrl","undef","defined","specified"],function(b){h[b]=function(){var c=G._;return c.require[b].apply(c,arguments)}});if(A&&(y=x.head=document.getElementsByTagName("head")[0],E=document.getElementsByTagName("base")[0]))y=x.head=E.parentNode;h.onError=ca;h.load=function(b,c,d){var h=b&&b.config||{},g;if(A)return g=h.xhtml?document.createElementNS("http://www.w3.org/1999/xhtml",
|
33
|
+
"html:script"):document.createElement("script"),g.type=h.scriptType||"text/javascript",g.charset="utf-8",g.async=!0,g.setAttribute("data-requirecontext",b.contextName),g.setAttribute("data-requiremodule",c),g.attachEvent&&!(g.attachEvent.toString&&0>g.attachEvent.toString().indexOf("[native code"))&&!Z?(Q=!0,g.attachEvent("onreadystatechange",b.onScriptLoad)):(g.addEventListener("load",b.onScriptLoad,!1),g.addEventListener("error",b.onScriptError,!1)),g.src=d,M=g,E?y.insertBefore(g,E):y.appendChild(g),
|
34
|
+
M=null,g;if(ea)try{importScripts(d),b.completeLoad(c)}catch(l){b.onError(B("importscripts","importScripts failed for "+c+" at "+d,l,[c]))}};A&&O(document.getElementsByTagName("script"),function(b){y||(y=b.parentNode);if(L=b.getAttribute("data-main"))return s=L,u.baseUrl||(F=s.split("/"),s=F.pop(),ga=F.length?F.join("/")+"/":"./",u.baseUrl=ga),s=s.replace(fa,""),h.jsExtRegExp.test(s)&&(s=L),u.deps=u.deps?u.deps.concat(s):[s],!0});define=function(b,c,d){var h,g;"string"!==typeof b&&(d=c,c=b,b=null);
|
35
|
+
K(c)||(d=c,c=null);!c&&J(d)&&(c=[],d.length&&(d.toString().replace(ma,"").replace(na,function(b,d){c.push(d)}),c=(1===d.length?["require"]:["require","exports","module"]).concat(c)));if(Q){if(!(h=M))R&&"interactive"===R.readyState||O(document.getElementsByTagName("script"),function(b){if("interactive"===b.readyState)return R=b}),h=R;h&&(b||(b=h.getAttribute("data-requiremodule")),g=G[h.getAttribute("data-requirecontext")])}(g?g.defQueue:U).push([b,c,d])};define.amd={jQuery:!0};h.exec=function(b){return eval(b)};
|
36
|
+
h(u)}})(this);
|
@@ -0,0 +1,18 @@
|
|
1
|
+
// Configure RequireJS to find plugins relative to plugins location
|
2
|
+
(function () {
|
3
|
+
|
4
|
+
var pluginPath;
|
5
|
+
|
6
|
+
SceneJS.on("configs",
|
7
|
+
function (configs) {
|
8
|
+
if (configs.pluginPath != pluginPath) {
|
9
|
+
pluginPath = configs.pluginPath;
|
10
|
+
var libPath = pluginPath + "/lib";
|
11
|
+
require.config({
|
12
|
+
paths:{
|
13
|
+
"scenejsPluginDeps":libPath
|
14
|
+
}
|
15
|
+
});
|
16
|
+
}
|
17
|
+
});
|
18
|
+
})();
|
@@ -0,0 +1 @@
|
|
1
|
+
}
|
@@ -0,0 +1,6 @@
|
|
1
|
+
// stats.js - http://github.com/mrdoob/stats.js
|
2
|
+
var Stats=function(){var l=Date.now(),m=l,g=0,n=Infinity,o=0,h=0,p=Infinity,q=0,r=0,s=0,f=document.createElement("div");f.id="stats";f.addEventListener("mousedown",function(b){b.preventDefault();t(++s%2)},!1);f.style.cssText="width:80px;opacity:0.9;cursor:pointer";var a=document.createElement("div");a.id="fps";a.style.cssText="padding:0 0 3px 3px;text-align:left;background-color:#002";f.appendChild(a);var i=document.createElement("div");i.id="fpsText";i.style.cssText="color:#0ff;font-family:Helvetica,Arial,sans-serif;font-size:9px;font-weight:bold;line-height:15px";
|
3
|
+
i.innerHTML="FPS";a.appendChild(i);var c=document.createElement("div");c.id="fpsGraph";c.style.cssText="position:relative;width:74px;height:30px;background-color:#0ff";for(a.appendChild(c);74>c.children.length;){var j=document.createElement("span");j.style.cssText="width:1px;height:30px;float:left;background-color:#113";c.appendChild(j)}var d=document.createElement("div");d.id="ms";d.style.cssText="padding:0 0 3px 3px;text-align:left;background-color:#020;display:none";f.appendChild(d);var k=document.createElement("div");
|
4
|
+
k.id="msText";k.style.cssText="color:#0f0;font-family:Helvetica,Arial,sans-serif;font-size:9px;font-weight:bold;line-height:15px";k.innerHTML="MS";d.appendChild(k);var e=document.createElement("div");e.id="msGraph";e.style.cssText="position:relative;width:74px;height:30px;background-color:#0f0";for(d.appendChild(e);74>e.children.length;)j=document.createElement("span"),j.style.cssText="width:1px;height:30px;float:left;background-color:#131",e.appendChild(j);var t=function(b){s=b;switch(s){case 0:a.style.display=
|
5
|
+
"block";d.style.display="none";break;case 1:a.style.display="none",d.style.display="block"}};return{REVISION:11,domElement:f,setMode:t,begin:function(){l=Date.now()},end:function(){var b=Date.now();g=b-l;n=Math.min(n,g);o=Math.max(o,g);k.textContent=g+" MS ("+n+"-"+o+")";var a=Math.min(30,30-30*(g/200));e.appendChild(e.firstChild).style.height=a+"px";r++;b>m+1E3&&(h=Math.round(1E3*r/(b-m)),p=Math.min(p,h),q=Math.max(q,h),i.textContent=h+" FPS ("+p+"-"+q+")",a=Math.min(30,30-30*(h/100)),c.appendChild(c.firstChild).style.height=
|
6
|
+
a+"px",m=b,r=0);return b},update:function(){l=this.end()}}};
|
@@ -0,0 +1 @@
|
|
1
|
+
eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('9 17={3i:\'0.1.3\',16:1e-6};l v(){}v.23={e:l(i){8(i<1||i>7.4.q)?w:7.4[i-1]},2R:l(){8 7.4.q},1u:l(){8 F.1x(7.2u(7))},24:l(a){9 n=7.4.q;9 V=a.4||a;o(n!=V.q){8 1L}J{o(F.13(7.4[n-1]-V[n-1])>17.16){8 1L}}H(--n);8 2x},1q:l(){8 v.u(7.4)},1b:l(a){9 b=[];7.28(l(x,i){b.19(a(x,i))});8 v.u(b)},28:l(a){9 n=7.4.q,k=n,i;J{i=k-n;a(7.4[i],i+1)}H(--n)},2q:l(){9 r=7.1u();o(r===0){8 7.1q()}8 7.1b(l(x){8 x/r})},1C:l(a){9 V=a.4||a;9 n=7.4.q,k=n,i;o(n!=V.q){8 w}9 b=0,1D=0,1F=0;7.28(l(x,i){b+=x*V[i-1];1D+=x*x;1F+=V[i-1]*V[i-1]});1D=F.1x(1D);1F=F.1x(1F);o(1D*1F===0){8 w}9 c=b/(1D*1F);o(c<-1){c=-1}o(c>1){c=1}8 F.37(c)},1m:l(a){9 b=7.1C(a);8(b===w)?w:(b<=17.16)},34:l(a){9 b=7.1C(a);8(b===w)?w:(F.13(b-F.1A)<=17.16)},2k:l(a){9 b=7.2u(a);8(b===w)?w:(F.13(b)<=17.16)},2j:l(a){9 V=a.4||a;o(7.4.q!=V.q){8 w}8 7.1b(l(x,i){8 x+V[i-1]})},2C:l(a){9 V=a.4||a;o(7.4.q!=V.q){8 w}8 7.1b(l(x,i){8 x-V[i-1]})},22:l(k){8 7.1b(l(x){8 x*k})},x:l(k){8 7.22(k)},2u:l(a){9 V=a.4||a;9 i,2g=0,n=7.4.q;o(n!=V.q){8 w}J{2g+=7.4[n-1]*V[n-1]}H(--n);8 2g},2f:l(a){9 B=a.4||a;o(7.4.q!=3||B.q!=3){8 w}9 A=7.4;8 v.u([(A[1]*B[2])-(A[2]*B[1]),(A[2]*B[0])-(A[0]*B[2]),(A[0]*B[1])-(A[1]*B[0])])},2A:l(){9 m=0,n=7.4.q,k=n,i;J{i=k-n;o(F.13(7.4[i])>F.13(m)){m=7.4[i]}}H(--n);8 m},2Z:l(x){9 a=w,n=7.4.q,k=n,i;J{i=k-n;o(a===w&&7.4[i]==x){a=i+1}}H(--n);8 a},3g:l(){8 S.2X(7.4)},2d:l(){8 7.1b(l(x){8 F.2d(x)})},2V:l(x){8 7.1b(l(y){8(F.13(y-x)<=17.16)?x:y})},1o:l(a){o(a.K){8 a.1o(7)}9 V=a.4||a;o(V.q!=7.4.q){8 w}9 b=0,2b;7.28(l(x,i){2b=x-V[i-1];b+=2b*2b});8 F.1x(b)},3a:l(a){8 a.1h(7)},2T:l(a){8 a.1h(7)},1V:l(t,a){9 V,R,x,y,z;2S(7.4.q){27 2:V=a.4||a;o(V.q!=2){8 w}R=S.1R(t).4;x=7.4[0]-V[0];y=7.4[1]-V[1];8 v.u([V[0]+R[0][0]*x+R[0][1]*y,V[1]+R[1][0]*x+R[1][1]*y]);1I;27 3:o(!a.U){8 w}9 C=a.1r(7).4;R=S.1R(t,a.U).4;x=7.4[0]-C[0];y=7.4[1]-C[1];z=7.4[2]-C[2];8 v.u([C[0]+R[0][0]*x+R[0][1]*y+R[0][2]*z,C[1]+R[1][0]*x+R[1][1]*y+R[1][2]*z,C[2]+R[2][0]*x+R[2][1]*y+R[2][2]*z]);1I;2P:8 w}},1t:l(a){o(a.K){9 P=7.4.2O();9 C=a.1r(P).4;8 v.u([C[0]+(C[0]-P[0]),C[1]+(C[1]-P[1]),C[2]+(C[2]-(P[2]||0))])}1d{9 Q=a.4||a;o(7.4.q!=Q.q){8 w}8 7.1b(l(x,i){8 Q[i-1]+(Q[i-1]-x)})}},1N:l(){9 V=7.1q();2S(V.4.q){27 3:1I;27 2:V.4.19(0);1I;2P:8 w}8 V},2n:l(){8\'[\'+7.4.2K(\', \')+\']\'},26:l(a){7.4=(a.4||a).2O();8 7}};v.u=l(a){9 V=25 v();8 V.26(a)};v.i=v.u([1,0,0]);v.j=v.u([0,1,0]);v.k=v.u([0,0,1]);v.2J=l(n){9 a=[];J{a.19(F.2F())}H(--n);8 v.u(a)};v.1j=l(n){9 a=[];J{a.19(0)}H(--n);8 v.u(a)};l S(){}S.23={e:l(i,j){o(i<1||i>7.4.q||j<1||j>7.4[0].q){8 w}8 7.4[i-1][j-1]},33:l(i){o(i>7.4.q){8 w}8 v.u(7.4[i-1])},2E:l(j){o(j>7.4[0].q){8 w}9 a=[],n=7.4.q,k=n,i;J{i=k-n;a.19(7.4[i][j-1])}H(--n);8 v.u(a)},2R:l(){8{2D:7.4.q,1p:7.4[0].q}},2D:l(){8 7.4.q},1p:l(){8 7.4[0].q},24:l(a){9 M=a.4||a;o(1g(M[0][0])==\'1f\'){M=S.u(M).4}o(7.4.q!=M.q||7.4[0].q!=M[0].q){8 1L}9 b=7.4.q,15=b,i,G,10=7.4[0].q,j;J{i=15-b;G=10;J{j=10-G;o(F.13(7.4[i][j]-M[i][j])>17.16){8 1L}}H(--G)}H(--b);8 2x},1q:l(){8 S.u(7.4)},1b:l(a){9 b=[],12=7.4.q,15=12,i,G,10=7.4[0].q,j;J{i=15-12;G=10;b[i]=[];J{j=10-G;b[i][j]=a(7.4[i][j],i+1,j+1)}H(--G)}H(--12);8 S.u(b)},2i:l(a){9 M=a.4||a;o(1g(M[0][0])==\'1f\'){M=S.u(M).4}8(7.4.q==M.q&&7.4[0].q==M[0].q)},2j:l(a){9 M=a.4||a;o(1g(M[0][0])==\'1f\'){M=S.u(M).4}o(!7.2i(M)){8 w}8 7.1b(l(x,i,j){8 x+M[i-1][j-1]})},2C:l(a){9 M=a.4||a;o(1g(M[0][0])==\'1f\'){M=S.u(M).4}o(!7.2i(M)){8 w}8 7.1b(l(x,i,j){8 x-M[i-1][j-1]})},2B:l(a){9 M=a.4||a;o(1g(M[0][0])==\'1f\'){M=S.u(M).4}8(7.4[0].q==M.q)},22:l(a){o(!a.4){8 7.1b(l(x){8 x*a})}9 b=a.1u?2x:1L;9 M=a.4||a;o(1g(M[0][0])==\'1f\'){M=S.u(M).4}o(!7.2B(M)){8 w}9 d=7.4.q,15=d,i,G,10=M[0].q,j;9 e=7.4[0].q,4=[],21,20,c;J{i=15-d;4[i]=[];G=10;J{j=10-G;21=0;20=e;J{c=e-20;21+=7.4[i][c]*M[c][j]}H(--20);4[i][j]=21}H(--G)}H(--d);9 M=S.u(4);8 b?M.2E(1):M},x:l(a){8 7.22(a)},32:l(a,b,c,d){9 e=[],12=c,i,G,j;9 f=7.4.q,1p=7.4[0].q;J{i=c-12;e[i]=[];G=d;J{j=d-G;e[i][j]=7.4[(a+i-1)%f][(b+j-1)%1p]}H(--G)}H(--12);8 S.u(e)},31:l(){9 a=7.4.q,1p=7.4[0].q;9 b=[],12=1p,i,G,j;J{i=1p-12;b[i]=[];G=a;J{j=a-G;b[i][j]=7.4[j][i]}H(--G)}H(--12);8 S.u(b)},1y:l(){8(7.4.q==7.4[0].q)},2A:l(){9 m=0,12=7.4.q,15=12,i,G,10=7.4[0].q,j;J{i=15-12;G=10;J{j=10-G;o(F.13(7.4[i][j])>F.13(m)){m=7.4[i][j]}}H(--G)}H(--12);8 m},2Z:l(x){9 a=w,12=7.4.q,15=12,i,G,10=7.4[0].q,j;J{i=15-12;G=10;J{j=10-G;o(7.4[i][j]==x){8{i:i+1,j:j+1}}}H(--G)}H(--12);8 w},30:l(){o(!7.1y){8 w}9 a=[],n=7.4.q,k=n,i;J{i=k-n;a.19(7.4[i][i])}H(--n);8 v.u(a)},1K:l(){9 M=7.1q(),1c;9 n=7.4.q,k=n,i,1s,1n=7.4[0].q,p;J{i=k-n;o(M.4[i][i]==0){2e(j=i+1;j<k;j++){o(M.4[j][i]!=0){1c=[];1s=1n;J{p=1n-1s;1c.19(M.4[i][p]+M.4[j][p])}H(--1s);M.4[i]=1c;1I}}}o(M.4[i][i]!=0){2e(j=i+1;j<k;j++){9 a=M.4[j][i]/M.4[i][i];1c=[];1s=1n;J{p=1n-1s;1c.19(p<=i?0:M.4[j][p]-M.4[i][p]*a)}H(--1s);M.4[j]=1c}}}H(--n);8 M},3h:l(){8 7.1K()},2z:l(){o(!7.1y()){8 w}9 M=7.1K();9 a=M.4[0][0],n=M.4.q-1,k=n,i;J{i=k-n+1;a=a*M.4[i][i]}H(--n);8 a},3f:l(){8 7.2z()},2y:l(){8(7.1y()&&7.2z()===0)},2Y:l(){o(!7.1y()){8 w}9 a=7.4[0][0],n=7.4.q-1,k=n,i;J{i=k-n+1;a+=7.4[i][i]}H(--n);8 a},3e:l(){8 7.2Y()},1Y:l(){9 M=7.1K(),1Y=0;9 a=7.4.q,15=a,i,G,10=7.4[0].q,j;J{i=15-a;G=10;J{j=10-G;o(F.13(M.4[i][j])>17.16){1Y++;1I}}H(--G)}H(--a);8 1Y},3d:l(){8 7.1Y()},2W:l(a){9 M=a.4||a;o(1g(M[0][0])==\'1f\'){M=S.u(M).4}9 T=7.1q(),1p=T.4[0].q;9 b=T.4.q,15=b,i,G,10=M[0].q,j;o(b!=M.q){8 w}J{i=15-b;G=10;J{j=10-G;T.4[i][1p+j]=M[i][j]}H(--G)}H(--b);8 T},2w:l(){o(!7.1y()||7.2y()){8 w}9 a=7.4.q,15=a,i,j;9 M=7.2W(S.I(a)).1K();9 b,1n=M.4[0].q,p,1c,2v;9 c=[],2c;J{i=a-1;1c=[];b=1n;c[i]=[];2v=M.4[i][i];J{p=1n-b;2c=M.4[i][p]/2v;1c.19(2c);o(p>=15){c[i].19(2c)}}H(--b);M.4[i]=1c;2e(j=0;j<i;j++){1c=[];b=1n;J{p=1n-b;1c.19(M.4[j][p]-M.4[i][p]*M.4[j][i])}H(--b);M.4[j]=1c}}H(--a);8 S.u(c)},3c:l(){8 7.2w()},2d:l(){8 7.1b(l(x){8 F.2d(x)})},2V:l(x){8 7.1b(l(p){8(F.13(p-x)<=17.16)?x:p})},2n:l(){9 a=[];9 n=7.4.q,k=n,i;J{i=k-n;a.19(v.u(7.4[i]).2n())}H(--n);8 a.2K(\'\\n\')},26:l(a){9 i,4=a.4||a;o(1g(4[0][0])!=\'1f\'){9 b=4.q,15=b,G,10,j;7.4=[];J{i=15-b;G=4[i].q;10=G;7.4[i]=[];J{j=10-G;7.4[i][j]=4[i][j]}H(--G)}H(--b);8 7}9 n=4.q,k=n;7.4=[];J{i=k-n;7.4.19([4[i]])}H(--n);8 7}};S.u=l(a){9 M=25 S();8 M.26(a)};S.I=l(n){9 a=[],k=n,i,G,j;J{i=k-n;a[i]=[];G=k;J{j=k-G;a[i][j]=(i==j)?1:0}H(--G)}H(--n);8 S.u(a)};S.2X=l(a){9 n=a.q,k=n,i;9 M=S.I(n);J{i=k-n;M.4[i][i]=a[i]}H(--n);8 M};S.1R=l(b,a){o(!a){8 S.u([[F.1H(b),-F.1G(b)],[F.1G(b),F.1H(b)]])}9 d=a.1q();o(d.4.q!=3){8 w}9 e=d.1u();9 x=d.4[0]/e,y=d.4[1]/e,z=d.4[2]/e;9 s=F.1G(b),c=F.1H(b),t=1-c;8 S.u([[t*x*x+c,t*x*y-s*z,t*x*z+s*y],[t*x*y+s*z,t*y*y+c,t*y*z-s*x],[t*x*z-s*y,t*y*z+s*x,t*z*z+c]])};S.3b=l(t){9 c=F.1H(t),s=F.1G(t);8 S.u([[1,0,0],[0,c,-s],[0,s,c]])};S.39=l(t){9 c=F.1H(t),s=F.1G(t);8 S.u([[c,0,s],[0,1,0],[-s,0,c]])};S.38=l(t){9 c=F.1H(t),s=F.1G(t);8 S.u([[c,-s,0],[s,c,0],[0,0,1]])};S.2J=l(n,m){8 S.1j(n,m).1b(l(){8 F.2F()})};S.1j=l(n,m){9 a=[],12=n,i,G,j;J{i=n-12;a[i]=[];G=m;J{j=m-G;a[i][j]=0}H(--G)}H(--12);8 S.u(a)};l 14(){}14.23={24:l(a){8(7.1m(a)&&7.1h(a.K))},1q:l(){8 14.u(7.K,7.U)},2U:l(a){9 V=a.4||a;8 14.u([7.K.4[0]+V[0],7.K.4[1]+V[1],7.K.4[2]+(V[2]||0)],7.U)},1m:l(a){o(a.W){8 a.1m(7)}9 b=7.U.1C(a.U);8(F.13(b)<=17.16||F.13(b-F.1A)<=17.16)},1o:l(a){o(a.W){8 a.1o(7)}o(a.U){o(7.1m(a)){8 7.1o(a.K)}9 N=7.U.2f(a.U).2q().4;9 A=7.K.4,B=a.K.4;8 F.13((A[0]-B[0])*N[0]+(A[1]-B[1])*N[1]+(A[2]-B[2])*N[2])}1d{9 P=a.4||a;9 A=7.K.4,D=7.U.4;9 b=P[0]-A[0],2a=P[1]-A[1],29=(P[2]||0)-A[2];9 c=F.1x(b*b+2a*2a+29*29);o(c===0)8 0;9 d=(b*D[0]+2a*D[1]+29*D[2])/c;9 e=1-d*d;8 F.13(c*F.1x(e<0?0:e))}},1h:l(a){9 b=7.1o(a);8(b!==w&&b<=17.16)},2T:l(a){8 a.1h(7)},1v:l(a){o(a.W){8 a.1v(7)}8(!7.1m(a)&&7.1o(a)<=17.16)},1U:l(a){o(a.W){8 a.1U(7)}o(!7.1v(a)){8 w}9 P=7.K.4,X=7.U.4,Q=a.K.4,Y=a.U.4;9 b=X[0],1z=X[1],1B=X[2],1T=Y[0],1S=Y[1],1M=Y[2];9 c=P[0]-Q[0],2s=P[1]-Q[1],2r=P[2]-Q[2];9 d=-b*c-1z*2s-1B*2r;9 e=1T*c+1S*2s+1M*2r;9 f=b*b+1z*1z+1B*1B;9 g=1T*1T+1S*1S+1M*1M;9 h=b*1T+1z*1S+1B*1M;9 k=(d*g/f+h*e)/(g-h*h);8 v.u([P[0]+k*b,P[1]+k*1z,P[2]+k*1B])},1r:l(a){o(a.U){o(7.1v(a)){8 7.1U(a)}o(7.1m(a)){8 w}9 D=7.U.4,E=a.U.4;9 b=D[0],1l=D[1],1k=D[2],1P=E[0],1O=E[1],1Q=E[2];9 x=(1k*1P-b*1Q),y=(b*1O-1l*1P),z=(1l*1Q-1k*1O);9 N=v.u([x*1Q-y*1O,y*1P-z*1Q,z*1O-x*1P]);9 P=11.u(a.K,N);8 P.1U(7)}1d{9 P=a.4||a;o(7.1h(P)){8 v.u(P)}9 A=7.K.4,D=7.U.4;9 b=D[0],1l=D[1],1k=D[2],1w=A[0],18=A[1],1a=A[2];9 x=b*(P[1]-18)-1l*(P[0]-1w),y=1l*((P[2]||0)-1a)-1k*(P[1]-18),z=1k*(P[0]-1w)-b*((P[2]||0)-1a);9 V=v.u([1l*x-1k*z,1k*y-b*x,b*z-1l*y]);9 k=7.1o(P)/V.1u();8 v.u([P[0]+V.4[0]*k,P[1]+V.4[1]*k,(P[2]||0)+V.4[2]*k])}},1V:l(t,a){o(1g(a.U)==\'1f\'){a=14.u(a.1N(),v.k)}9 R=S.1R(t,a.U).4;9 C=a.1r(7.K).4;9 A=7.K.4,D=7.U.4;9 b=C[0],1E=C[1],1J=C[2],1w=A[0],18=A[1],1a=A[2];9 x=1w-b,y=18-1E,z=1a-1J;8 14.u([b+R[0][0]*x+R[0][1]*y+R[0][2]*z,1E+R[1][0]*x+R[1][1]*y+R[1][2]*z,1J+R[2][0]*x+R[2][1]*y+R[2][2]*z],[R[0][0]*D[0]+R[0][1]*D[1]+R[0][2]*D[2],R[1][0]*D[0]+R[1][1]*D[1]+R[1][2]*D[2],R[2][0]*D[0]+R[2][1]*D[1]+R[2][2]*D[2]])},1t:l(a){o(a.W){9 A=7.K.4,D=7.U.4;9 b=A[0],18=A[1],1a=A[2],2N=D[0],1l=D[1],1k=D[2];9 c=7.K.1t(a).4;9 d=b+2N,2h=18+1l,2o=1a+1k;9 Q=a.1r([d,2h,2o]).4;9 e=[Q[0]+(Q[0]-d)-c[0],Q[1]+(Q[1]-2h)-c[1],Q[2]+(Q[2]-2o)-c[2]];8 14.u(c,e)}1d o(a.U){8 7.1V(F.1A,a)}1d{9 P=a.4||a;8 14.u(7.K.1t([P[0],P[1],(P[2]||0)]),7.U)}},1Z:l(a,b){a=v.u(a);b=v.u(b);o(a.4.q==2){a.4.19(0)}o(b.4.q==2){b.4.19(0)}o(a.4.q>3||b.4.q>3){8 w}9 c=b.1u();o(c===0){8 w}7.K=a;7.U=v.u([b.4[0]/c,b.4[1]/c,b.4[2]/c]);8 7}};14.u=l(a,b){9 L=25 14();8 L.1Z(a,b)};14.X=14.u(v.1j(3),v.i);14.Y=14.u(v.1j(3),v.j);14.Z=14.u(v.1j(3),v.k);l 11(){}11.23={24:l(a){8(7.1h(a.K)&&7.1m(a))},1q:l(){8 11.u(7.K,7.W)},2U:l(a){9 V=a.4||a;8 11.u([7.K.4[0]+V[0],7.K.4[1]+V[1],7.K.4[2]+(V[2]||0)],7.W)},1m:l(a){9 b;o(a.W){b=7.W.1C(a.W);8(F.13(b)<=17.16||F.13(F.1A-b)<=17.16)}1d o(a.U){8 7.W.2k(a.U)}8 w},2k:l(a){9 b=7.W.1C(a.W);8(F.13(F.1A/2-b)<=17.16)},1o:l(a){o(7.1v(a)||7.1h(a)){8 0}o(a.K){9 A=7.K.4,B=a.K.4,N=7.W.4;8 F.13((A[0]-B[0])*N[0]+(A[1]-B[1])*N[1]+(A[2]-B[2])*N[2])}1d{9 P=a.4||a;9 A=7.K.4,N=7.W.4;8 F.13((A[0]-P[0])*N[0]+(A[1]-P[1])*N[1]+(A[2]-(P[2]||0))*N[2])}},1h:l(a){o(a.W){8 w}o(a.U){8(7.1h(a.K)&&7.1h(a.K.2j(a.U)))}1d{9 P=a.4||a;9 A=7.K.4,N=7.W.4;9 b=F.13(N[0]*(A[0]-P[0])+N[1]*(A[1]-P[1])+N[2]*(A[2]-(P[2]||0)));8(b<=17.16)}},1v:l(a){o(1g(a.U)==\'1f\'&&1g(a.W)==\'1f\'){8 w}8!7.1m(a)},1U:l(a){o(!7.1v(a)){8 w}o(a.U){9 A=a.K.4,D=a.U.4,P=7.K.4,N=7.W.4;9 b=(N[0]*(P[0]-A[0])+N[1]*(P[1]-A[1])+N[2]*(P[2]-A[2]))/(N[0]*D[0]+N[1]*D[1]+N[2]*D[2]);8 v.u([A[0]+D[0]*b,A[1]+D[1]*b,A[2]+D[2]*b])}1d o(a.W){9 c=7.W.2f(a.W).2q();9 N=7.W.4,A=7.K.4,O=a.W.4,B=a.K.4;9 d=S.1j(2,2),i=0;H(d.2y()){i++;d=S.u([[N[i%3],N[(i+1)%3]],[O[i%3],O[(i+1)%3]]])}9 e=d.2w().4;9 x=N[0]*A[0]+N[1]*A[1]+N[2]*A[2];9 y=O[0]*B[0]+O[1]*B[1]+O[2]*B[2];9 f=[e[0][0]*x+e[0][1]*y,e[1][0]*x+e[1][1]*y];9 g=[];2e(9 j=1;j<=3;j++){g.19((i==j)?0:f[(j+(5-i)%3)%3])}8 14.u(g,c)}},1r:l(a){9 P=a.4||a;9 A=7.K.4,N=7.W.4;9 b=(A[0]-P[0])*N[0]+(A[1]-P[1])*N[1]+(A[2]-(P[2]||0))*N[2];8 v.u([P[0]+N[0]*b,P[1]+N[1]*b,(P[2]||0)+N[2]*b])},1V:l(t,a){9 R=S.1R(t,a.U).4;9 C=a.1r(7.K).4;9 A=7.K.4,N=7.W.4;9 b=C[0],1E=C[1],1J=C[2],1w=A[0],18=A[1],1a=A[2];9 x=1w-b,y=18-1E,z=1a-1J;8 11.u([b+R[0][0]*x+R[0][1]*y+R[0][2]*z,1E+R[1][0]*x+R[1][1]*y+R[1][2]*z,1J+R[2][0]*x+R[2][1]*y+R[2][2]*z],[R[0][0]*N[0]+R[0][1]*N[1]+R[0][2]*N[2],R[1][0]*N[0]+R[1][1]*N[1]+R[1][2]*N[2],R[2][0]*N[0]+R[2][1]*N[1]+R[2][2]*N[2]])},1t:l(a){o(a.W){9 A=7.K.4,N=7.W.4;9 b=A[0],18=A[1],1a=A[2],2M=N[0],2L=N[1],2Q=N[2];9 c=7.K.1t(a).4;9 d=b+2M,2p=18+2L,2m=1a+2Q;9 Q=a.1r([d,2p,2m]).4;9 e=[Q[0]+(Q[0]-d)-c[0],Q[1]+(Q[1]-2p)-c[1],Q[2]+(Q[2]-2m)-c[2]];8 11.u(c,e)}1d o(a.U){8 7.1V(F.1A,a)}1d{9 P=a.4||a;8 11.u(7.K.1t([P[0],P[1],(P[2]||0)]),7.W)}},1Z:l(a,b,c){a=v.u(a);a=a.1N();o(a===w){8 w}b=v.u(b);b=b.1N();o(b===w){8 w}o(1g(c)==\'1f\'){c=w}1d{c=v.u(c);c=c.1N();o(c===w){8 w}}9 d=a.4[0],18=a.4[1],1a=a.4[2];9 e=b.4[0],1W=b.4[1],1X=b.4[2];9 f,1i;o(c!==w){9 g=c.4[0],2l=c.4[1],2t=c.4[2];f=v.u([(1W-18)*(2t-1a)-(1X-1a)*(2l-18),(1X-1a)*(g-d)-(e-d)*(2t-1a),(e-d)*(2l-18)-(1W-18)*(g-d)]);1i=f.1u();o(1i===0){8 w}f=v.u([f.4[0]/1i,f.4[1]/1i,f.4[2]/1i])}1d{1i=F.1x(e*e+1W*1W+1X*1X);o(1i===0){8 w}f=v.u([b.4[0]/1i,b.4[1]/1i,b.4[2]/1i])}7.K=a;7.W=f;8 7}};11.u=l(a,b,c){9 P=25 11();8 P.1Z(a,b,c)};11.2I=11.u(v.1j(3),v.k);11.2H=11.u(v.1j(3),v.i);11.2G=11.u(v.1j(3),v.j);11.36=11.2I;11.35=11.2H;11.3j=11.2G;9 $V=v.u;9 $M=S.u;9 $L=14.u;9 $P=11.u;',62,206,'||||elements|||this|return|var||||||||||||function|||if||length||||create|Vector|null|||||||||Math|nj|while||do|anchor||||||||Matrix||direction||normal||||kj|Plane|ni|abs|Line|ki|precision|Sylvester|A2|push|A3|map|els|else||undefined|typeof|contains|mod|Zero|D3|D2|isParallelTo|kp|distanceFrom|cols|dup|pointClosestTo|np|reflectionIn|modulus|intersects|A1|sqrt|isSquare|X2|PI|X3|angleFrom|mod1|C2|mod2|sin|cos|break|C3|toRightTriangular|false|Y3|to3D|E2|E1|E3|Rotation|Y2|Y1|intersectionWith|rotate|v12|v13|rank|setVectors|nc|sum|multiply|prototype|eql|new|setElements|case|each|PA3|PA2|part|new_element|round|for|cross|product|AD2|isSameSizeAs|add|isPerpendicularTo|v22|AN3|inspect|AD3|AN2|toUnitVector|PsubQ3|PsubQ2|v23|dot|divisor|inverse|true|isSingular|determinant|max|canMultiplyFromLeft|subtract|rows|col|random|ZX|YZ|XY|Random|join|N2|N1|D1|slice|default|N3|dimensions|switch|liesIn|translate|snapTo|augment|Diagonal|trace|indexOf|diagonal|transpose|minor|row|isAntiparallelTo|ZY|YX|acos|RotationZ|RotationY|liesOn|RotationX|inv|rk|tr|det|toDiagonalMatrix|toUpperTriangular|version|XZ'.split('|'),0,{}))
|
@@ -0,0 +1,839 @@
|
|
1
|
+
|
2
|
+
WebGLDebugUtils = function() {
|
3
|
+
|
4
|
+
/**
|
5
|
+
* Wrapped logging function.
|
6
|
+
* @param {string} msg Message to log.
|
7
|
+
*/
|
8
|
+
var log = function(msg) {
|
9
|
+
if (window.console && window.console.log) {
|
10
|
+
window.console.log(msg);
|
11
|
+
}
|
12
|
+
};
|
13
|
+
|
14
|
+
/**
|
15
|
+
* Which arguements are enums.
|
16
|
+
* @type {!Object.<number, string>}
|
17
|
+
*/
|
18
|
+
var glValidEnumContexts = {
|
19
|
+
|
20
|
+
// Generic setters and getters
|
21
|
+
|
22
|
+
'enable': { 0:true },
|
23
|
+
'disable': { 0:true },
|
24
|
+
'getParameter': { 0:true },
|
25
|
+
|
26
|
+
// Rendering
|
27
|
+
|
28
|
+
'drawArrays': { 0:true },
|
29
|
+
'drawElements': { 0:true, 2:true },
|
30
|
+
|
31
|
+
// Shaders
|
32
|
+
|
33
|
+
'createShader': { 0:true },
|
34
|
+
'getShaderParameter': { 1:true },
|
35
|
+
'getProgramParameter': { 1:true },
|
36
|
+
|
37
|
+
// Vertex attributes
|
38
|
+
|
39
|
+
'getVertexAttrib': { 1:true },
|
40
|
+
'vertexAttribPointer': { 2:true },
|
41
|
+
|
42
|
+
// Textures
|
43
|
+
|
44
|
+
'bindTexture': { 0:true },
|
45
|
+
'activeTexture': { 0:true },
|
46
|
+
'getTexParameter': { 0:true, 1:true },
|
47
|
+
'texParameterf': { 0:true, 1:true },
|
48
|
+
'texParameteri': { 0:true, 1:true, 2:true },
|
49
|
+
'texImage2D': { 0:true, 2:true, 6:true, 7:true },
|
50
|
+
'texSubImage2D': { 0:true, 6:true, 7:true },
|
51
|
+
'copyTexImage2D': { 0:true, 2:true },
|
52
|
+
'copyTexSubImage2D': { 0:true },
|
53
|
+
'generateMipmap': { 0:true },
|
54
|
+
|
55
|
+
// Buffer objects
|
56
|
+
|
57
|
+
'bindBuffer': { 0:true },
|
58
|
+
'bufferData': { 0:true, 2:true },
|
59
|
+
'bufferSubData': { 0:true },
|
60
|
+
'getBufferParameter': { 0:true, 1:true },
|
61
|
+
|
62
|
+
// Renderbuffers and framebuffers
|
63
|
+
|
64
|
+
'pixelStorei': { 0:true, 1:true },
|
65
|
+
'readPixels': { 4:true, 5:true },
|
66
|
+
'bindRenderbuffer': { 0:true },
|
67
|
+
'bindFramebuffer': { 0:true },
|
68
|
+
'checkFramebufferStatus': { 0:true },
|
69
|
+
'framebufferRenderbuffer': { 0:true, 1:true, 2:true },
|
70
|
+
'framebufferTexture2D': { 0:true, 1:true, 2:true },
|
71
|
+
'getFramebufferAttachmentParameter': { 0:true, 1:true, 2:true },
|
72
|
+
'getRenderbufferParameter': { 0:true, 1:true },
|
73
|
+
'renderbufferStorage': { 0:true, 1:true },
|
74
|
+
|
75
|
+
// Frame buffer operations (clear, blend, depth test, stencil)
|
76
|
+
|
77
|
+
'clear': { 0:true },
|
78
|
+
'depthFunc': { 0:true },
|
79
|
+
'blendFunc': { 0:true, 1:true },
|
80
|
+
'blendFuncSeparate': { 0:true, 1:true, 2:true, 3:true },
|
81
|
+
'blendEquation': { 0:true },
|
82
|
+
'blendEquationSeparate': { 0:true, 1:true },
|
83
|
+
'stencilFunc': { 0:true },
|
84
|
+
'stencilFuncSeparate': { 0:true, 1:true },
|
85
|
+
'stencilMaskSeparate': { 0:true },
|
86
|
+
'stencilOp': { 0:true, 1:true, 2:true },
|
87
|
+
'stencilOpSeparate': { 0:true, 1:true, 2:true, 3:true },
|
88
|
+
|
89
|
+
// Culling
|
90
|
+
|
91
|
+
'cullFace': { 0:true },
|
92
|
+
'frontFace': { 0:true },
|
93
|
+
};
|
94
|
+
|
95
|
+
/**
|
96
|
+
* Map of numbers to names.
|
97
|
+
* @type {Object}
|
98
|
+
*/
|
99
|
+
var glEnums = null;
|
100
|
+
|
101
|
+
/**
|
102
|
+
* Initializes this module. Safe to call more than once.
|
103
|
+
* @param {!WebGLRenderingContext} ctx A WebGL context. If
|
104
|
+
* you have more than one context it doesn't matter which one
|
105
|
+
* you pass in, it is only used to pull out constants.
|
106
|
+
*/
|
107
|
+
function init(ctx) {
|
108
|
+
if (glEnums == null) {
|
109
|
+
glEnums = { };
|
110
|
+
for (var propertyName in ctx) {
|
111
|
+
if (typeof ctx[propertyName] == 'number') {
|
112
|
+
glEnums[ctx[propertyName]] = propertyName;
|
113
|
+
}
|
114
|
+
}
|
115
|
+
}
|
116
|
+
}
|
117
|
+
|
118
|
+
/**
|
119
|
+
* Checks the utils have been initialized.
|
120
|
+
*/
|
121
|
+
function checkInit() {
|
122
|
+
if (glEnums == null) {
|
123
|
+
throw 'WebGLDebugUtils.init(ctx) not called';
|
124
|
+
}
|
125
|
+
}
|
126
|
+
|
127
|
+
/**
|
128
|
+
* Returns true or false if value matches any WebGL enum
|
129
|
+
* @param {*} value Value to check if it might be an enum.
|
130
|
+
* @return {boolean} True if value matches one of the WebGL defined enums
|
131
|
+
*/
|
132
|
+
function mightBeEnum(value) {
|
133
|
+
checkInit();
|
134
|
+
return (glEnums[value] !== undefined);
|
135
|
+
}
|
136
|
+
|
137
|
+
/**
|
138
|
+
* Gets an string version of an WebGL enum.
|
139
|
+
*
|
140
|
+
* Example:
|
141
|
+
* var str = WebGLDebugUtil.glEnumToString(ctx.getError());
|
142
|
+
*
|
143
|
+
* @param {number} value Value to return an enum for
|
144
|
+
* @return {string} The string version of the enum.
|
145
|
+
*/
|
146
|
+
function glEnumToString(value) {
|
147
|
+
checkInit();
|
148
|
+
var name = glEnums[value];
|
149
|
+
return (name !== undefined) ? name :
|
150
|
+
("*UNKNOWN WebGL ENUM (0x" + value.toString(16) + ")");
|
151
|
+
}
|
152
|
+
|
153
|
+
/**
|
154
|
+
* Returns the string version of a WebGL argument.
|
155
|
+
* Attempts to convert enum arguments to strings.
|
156
|
+
* @param {string} functionName the name of the WebGL function.
|
157
|
+
* @param {number} argumentIndx the index of the argument.
|
158
|
+
* @param {*} value The value of the argument.
|
159
|
+
* @return {string} The value as a string.
|
160
|
+
*/
|
161
|
+
function glFunctionArgToString(functionName, argumentIndex, value) {
|
162
|
+
var funcInfo = glValidEnumContexts[functionName];
|
163
|
+
if (funcInfo !== undefined) {
|
164
|
+
if (funcInfo[argumentIndex]) {
|
165
|
+
return glEnumToString(value);
|
166
|
+
}
|
167
|
+
}
|
168
|
+
if (value === null) {
|
169
|
+
return "null";
|
170
|
+
} else if (value === undefined) {
|
171
|
+
return "undefined";
|
172
|
+
} else {
|
173
|
+
return value.toString();
|
174
|
+
}
|
175
|
+
}
|
176
|
+
|
177
|
+
/**
|
178
|
+
* Converts the arguments of a WebGL function to a string.
|
179
|
+
* Attempts to convert enum arguments to strings.
|
180
|
+
*
|
181
|
+
* @param {string} functionName the name of the WebGL function.
|
182
|
+
* @param {number} args The arguments.
|
183
|
+
* @return {string} The arguments as a string.
|
184
|
+
*/
|
185
|
+
function glFunctionArgsToString(functionName, args) {
|
186
|
+
// apparently we can't do args.join(",");
|
187
|
+
var argStr = "";
|
188
|
+
for (var ii = 0; ii < args.length; ++ii) {
|
189
|
+
argStr += ((ii == 0) ? '' : ', ') +
|
190
|
+
glFunctionArgToString(functionName, ii, args[ii]);
|
191
|
+
}
|
192
|
+
return argStr;
|
193
|
+
};
|
194
|
+
|
195
|
+
|
196
|
+
function makePropertyWrapper(wrapper, original, propertyName) {
|
197
|
+
//log("wrap prop: " + propertyName);
|
198
|
+
wrapper.__defineGetter__(propertyName, function() {
|
199
|
+
return original[propertyName];
|
200
|
+
});
|
201
|
+
// TODO(gmane): this needs to handle properties that take more than
|
202
|
+
// one value?
|
203
|
+
wrapper.__defineSetter__(propertyName, function(value) {
|
204
|
+
//log("set: " + propertyName);
|
205
|
+
original[propertyName] = value;
|
206
|
+
});
|
207
|
+
}
|
208
|
+
|
209
|
+
// Makes a function that calls a function on another object.
|
210
|
+
function makeFunctionWrapper(original, functionName) {
|
211
|
+
//log("wrap fn: " + functionName);
|
212
|
+
var f = original[functionName];
|
213
|
+
return function() {
|
214
|
+
//log("call: " + functionName);
|
215
|
+
var result = f.apply(original, arguments);
|
216
|
+
return result;
|
217
|
+
};
|
218
|
+
}
|
219
|
+
|
220
|
+
/**
|
221
|
+
* Given a WebGL context returns a wrapped context that calls
|
222
|
+
* gl.getError after every command and calls a function if the
|
223
|
+
* result is not gl.NO_ERROR.
|
224
|
+
*
|
225
|
+
* @param {!WebGLRenderingContext} ctx The webgl context to
|
226
|
+
* wrap.
|
227
|
+
* @param {!function(err, funcName, args): void} opt_onErrorFunc
|
228
|
+
* The function to call when gl.getError returns an
|
229
|
+
* error. If not specified the default function calls
|
230
|
+
* console.log with a message.
|
231
|
+
* @param {!function(funcName, args): void} opt_onFunc The
|
232
|
+
* function to call when each webgl function is called.
|
233
|
+
* You can use this to log all calls for example.
|
234
|
+
*/
|
235
|
+
function makeDebugContext(ctx, opt_onErrorFunc, opt_onFunc) {
|
236
|
+
init(ctx);
|
237
|
+
opt_onErrorFunc = opt_onErrorFunc || function(err, functionName, args) {
|
238
|
+
// apparently we can't do args.join(",");
|
239
|
+
var argStr = "";
|
240
|
+
for (var ii = 0; ii < args.length; ++ii) {
|
241
|
+
argStr += ((ii == 0) ? '' : ', ') +
|
242
|
+
glFunctionArgToString(functionName, ii, args[ii]);
|
243
|
+
}
|
244
|
+
log("WebGL error "+ glEnumToString(err) + " in "+ functionName +
|
245
|
+
"(" + argStr + ")");
|
246
|
+
};
|
247
|
+
|
248
|
+
// Holds booleans for each GL error so after we get the error ourselves
|
249
|
+
// we can still return it to the client app.
|
250
|
+
var glErrorShadow = { };
|
251
|
+
|
252
|
+
// Makes a function that calls a WebGL function and then calls getError.
|
253
|
+
function makeErrorWrapper(ctx, functionName) {
|
254
|
+
return function() {
|
255
|
+
if (opt_onFunc) {
|
256
|
+
opt_onFunc(functionName, arguments);
|
257
|
+
}
|
258
|
+
var result = ctx[functionName].apply(ctx, arguments);
|
259
|
+
var err = ctx.getError();
|
260
|
+
if (err != 0) {
|
261
|
+
glErrorShadow[err] = true;
|
262
|
+
opt_onErrorFunc(err, functionName, arguments);
|
263
|
+
}
|
264
|
+
return result;
|
265
|
+
};
|
266
|
+
}
|
267
|
+
|
268
|
+
// Make a an object that has a copy of every property of the WebGL context
|
269
|
+
// but wraps all functions.
|
270
|
+
var wrapper = {};
|
271
|
+
for (var propertyName in ctx) {
|
272
|
+
if (typeof ctx[propertyName] == 'function') {
|
273
|
+
wrapper[propertyName] = makeErrorWrapper(ctx, propertyName);
|
274
|
+
} else {
|
275
|
+
makePropertyWrapper(wrapper, ctx, propertyName);
|
276
|
+
}
|
277
|
+
}
|
278
|
+
|
279
|
+
// Override the getError function with one that returns our saved results.
|
280
|
+
wrapper.getError = function() {
|
281
|
+
for (var err in glErrorShadow) {
|
282
|
+
if (glErrorShadow.hasOwnProperty(err)) {
|
283
|
+
if (glErrorShadow[err]) {
|
284
|
+
glErrorShadow[err] = false;
|
285
|
+
return err;
|
286
|
+
}
|
287
|
+
}
|
288
|
+
}
|
289
|
+
return ctx.NO_ERROR;
|
290
|
+
};
|
291
|
+
|
292
|
+
return wrapper;
|
293
|
+
}
|
294
|
+
|
295
|
+
function resetToInitialState(ctx) {
|
296
|
+
var numAttribs = ctx.getParameter(ctx.MAX_VERTEX_ATTRIBS);
|
297
|
+
var tmp = ctx.createBuffer();
|
298
|
+
ctx.bindBuffer(ctx.ARRAY_BUFFER, tmp);
|
299
|
+
for (var ii = 0; ii < numAttribs; ++ii) {
|
300
|
+
ctx.disableVertexAttribArray(ii);
|
301
|
+
ctx.vertexAttribPointer(ii, 4, ctx.FLOAT, false, 0, 0);
|
302
|
+
ctx.vertexAttrib1f(ii, 0);
|
303
|
+
}
|
304
|
+
ctx.deleteBuffer(tmp);
|
305
|
+
|
306
|
+
var numTextureUnits = ctx.getParameter(ctx.MAX_TEXTURE_IMAGE_UNITS);
|
307
|
+
for (var ii = 0; ii < numTextureUnits; ++ii) {
|
308
|
+
ctx.activeTexture(ctx.TEXTURE0 + ii);
|
309
|
+
ctx.bindTexture(ctx.TEXTURE_CUBE_MAP, null);
|
310
|
+
ctx.bindTexture(ctx.TEXTURE_2D, null);
|
311
|
+
}
|
312
|
+
|
313
|
+
ctx.activeTexture(ctx.TEXTURE0);
|
314
|
+
ctx.useProgram(null);
|
315
|
+
ctx.bindBuffer(ctx.ARRAY_BUFFER, null);
|
316
|
+
ctx.bindBuffer(ctx.ELEMENT_ARRAY_BUFFER, null);
|
317
|
+
ctx.bindFramebuffer(ctx.FRAMEBUFFER, null);
|
318
|
+
ctx.bindRenderbuffer(ctx.RENDERBUFFER, null);
|
319
|
+
ctx.disable(ctx.BLEND);
|
320
|
+
ctx.disable(ctx.CULL_FACE);
|
321
|
+
ctx.disable(ctx.DEPTH_TEST);
|
322
|
+
ctx.disable(ctx.DITHER);
|
323
|
+
ctx.disable(ctx.SCISSOR_TEST);
|
324
|
+
ctx.blendColor(0, 0, 0, 0);
|
325
|
+
ctx.blendEquation(ctx.FUNC_ADD);
|
326
|
+
ctx.blendFunc(ctx.ONE, ctx.ZERO);
|
327
|
+
ctx.clearColor(0, 0, 0, 0);
|
328
|
+
ctx.clearDepth(1);
|
329
|
+
ctx.clearStencil(-1);
|
330
|
+
ctx.colorMask(true, true, true, true);
|
331
|
+
ctx.cullFace(ctx.BACK);
|
332
|
+
ctx.depthFunc(ctx.LESS);
|
333
|
+
ctx.depthMask(true);
|
334
|
+
ctx.depthRange(0, 1);
|
335
|
+
ctx.frontFace(ctx.CCW);
|
336
|
+
ctx.hint(ctx.GENERATE_MIPMAP_HINT, ctx.DONT_CARE);
|
337
|
+
ctx.lineWidth(1);
|
338
|
+
ctx.pixelStorei(ctx.PACK_ALIGNMENT, 4);
|
339
|
+
ctx.pixelStorei(ctx.UNPACK_ALIGNMENT, 4);
|
340
|
+
ctx.pixelStorei(ctx.UNPACK_FLIP_Y_WEBGL, false);
|
341
|
+
ctx.pixelStorei(ctx.UNPACK_PREMULTIPLY_ALPHA_WEBGL, false);
|
342
|
+
// TODO: Delete this IF.
|
343
|
+
if (ctx.UNPACK_COLORSPACE_CONVERSION_WEBGL) {
|
344
|
+
ctx.pixelStorei(ctx.UNPACK_COLORSPACE_CONVERSION_WEBGL, ctx.BROWSER_DEFAULT_WEBGL);
|
345
|
+
}
|
346
|
+
ctx.polygonOffset(0, 0);
|
347
|
+
ctx.sampleCoverage(1, false);
|
348
|
+
ctx.scissor(0, 0, ctx.canvas.width, ctx.canvas.height);
|
349
|
+
ctx.stencilFunc(ctx.ALWAYS, 0, 0xFFFFFFFF);
|
350
|
+
ctx.stencilMask(0xFFFFFFFF);
|
351
|
+
ctx.stencilOp(ctx.KEEP, ctx.KEEP, ctx.KEEP);
|
352
|
+
ctx.viewport(0, 0, ctx.canvas.width, ctx.canvas.height);
|
353
|
+
ctx.clear(ctx.COLOR_BUFFER_BIT | ctx.DEPTH_BUFFER_BIT | ctx.STENCIL_BUFFER_BIT);
|
354
|
+
|
355
|
+
// TODO: This should NOT be needed but Firefox fails with 'hint'
|
356
|
+
while(ctx.getError());
|
357
|
+
}
|
358
|
+
|
359
|
+
function makeLostContextSimulatingCanvas(canvas) {
|
360
|
+
var unwrappedContext_;
|
361
|
+
var wrappedContext_;
|
362
|
+
var onLost_ = [];
|
363
|
+
var onRestored_ = [];
|
364
|
+
var wrappedContext_ = {};
|
365
|
+
var contextId_ = 1;
|
366
|
+
var contextLost_ = false;
|
367
|
+
var resourceId_ = 0;
|
368
|
+
var resourceDb_ = [];
|
369
|
+
var numCallsToLoseContext_ = 0;
|
370
|
+
var numCalls_ = 0;
|
371
|
+
var canRestore_ = false;
|
372
|
+
var restoreTimeout_ = 0;
|
373
|
+
|
374
|
+
// Holds booleans for each GL error so can simulate errors.
|
375
|
+
var glErrorShadow_ = { };
|
376
|
+
|
377
|
+
canvas.getContext = function(f) {
|
378
|
+
return function() {
|
379
|
+
var ctx = f.apply(canvas, arguments);
|
380
|
+
// Did we get a context and is it a WebGL context?
|
381
|
+
if (ctx instanceof WebGLRenderingContext) {
|
382
|
+
if (ctx != unwrappedContext_) {
|
383
|
+
if (unwrappedContext_) {
|
384
|
+
throw "got different context"
|
385
|
+
}
|
386
|
+
unwrappedContext_ = ctx;
|
387
|
+
wrappedContext_ = makeLostContextSimulatingContext(unwrappedContext_);
|
388
|
+
}
|
389
|
+
return wrappedContext_;
|
390
|
+
}
|
391
|
+
return ctx;
|
392
|
+
}
|
393
|
+
}(canvas.getContext);
|
394
|
+
|
395
|
+
function wrapEvent(listener) {
|
396
|
+
if (typeof(listener) == "function") {
|
397
|
+
return listener;
|
398
|
+
} else {
|
399
|
+
return function(info) {
|
400
|
+
listener.handleEvent(info);
|
401
|
+
}
|
402
|
+
}
|
403
|
+
}
|
404
|
+
|
405
|
+
var addOnContextLostListener = function(listener) {
|
406
|
+
onLost_.push(wrapEvent(listener));
|
407
|
+
};
|
408
|
+
|
409
|
+
var addOnContextRestoredListener = function(listener) {
|
410
|
+
onRestored_.push(wrapEvent(listener));
|
411
|
+
};
|
412
|
+
|
413
|
+
|
414
|
+
function wrapAddEventListener(canvas) {
|
415
|
+
var f = canvas.addEventListener;
|
416
|
+
canvas.addEventListener = function(type, listener, bubble) {
|
417
|
+
switch (type) {
|
418
|
+
case 'webglcontextlost':
|
419
|
+
addOnContextLostListener(listener);
|
420
|
+
break;
|
421
|
+
case 'webglcontextrestored':
|
422
|
+
addOnContextRestoredListener(listener);
|
423
|
+
break;
|
424
|
+
default:
|
425
|
+
f.apply(canvas, arguments);
|
426
|
+
}
|
427
|
+
};
|
428
|
+
}
|
429
|
+
|
430
|
+
wrapAddEventListener(canvas);
|
431
|
+
|
432
|
+
canvas.loseContext = function() {
|
433
|
+
if (!contextLost_) {
|
434
|
+
contextLost_ = true;
|
435
|
+
numCallsToLoseContext_ = 0;
|
436
|
+
++contextId_;
|
437
|
+
while (unwrappedContext_.getError());
|
438
|
+
clearErrors();
|
439
|
+
glErrorShadow_[unwrappedContext_.CONTEXT_LOST_WEBGL] = true;
|
440
|
+
var event = makeWebGLContextEvent("context lost");
|
441
|
+
var callbacks = onLost_.slice();
|
442
|
+
setTimeout(function() {
|
443
|
+
//log("numCallbacks:" + callbacks.length);
|
444
|
+
for (var ii = 0; ii < callbacks.length; ++ii) {
|
445
|
+
//log("calling callback:" + ii);
|
446
|
+
callbacks[ii](event);
|
447
|
+
}
|
448
|
+
if (restoreTimeout_ >= 0) {
|
449
|
+
setTimeout(function() {
|
450
|
+
canvas.restoreContext();
|
451
|
+
}, restoreTimeout_);
|
452
|
+
}
|
453
|
+
}, 0);
|
454
|
+
}
|
455
|
+
};
|
456
|
+
|
457
|
+
canvas.restoreContext = function() {
|
458
|
+
if (contextLost_) {
|
459
|
+
if (onRestored_.length) {
|
460
|
+
setTimeout(function() {
|
461
|
+
if (!canRestore_) {
|
462
|
+
throw "can not restore. webglcontestlost listener did not call event.preventDefault";
|
463
|
+
}
|
464
|
+
freeResources();
|
465
|
+
resetToInitialState(unwrappedContext_);
|
466
|
+
contextLost_ = false;
|
467
|
+
numCalls_ = 0;
|
468
|
+
canRestore_ = false;
|
469
|
+
var callbacks = onRestored_.slice();
|
470
|
+
var event = makeWebGLContextEvent("context restored");
|
471
|
+
for (var ii = 0; ii < callbacks.length; ++ii) {
|
472
|
+
callbacks[ii](event);
|
473
|
+
}
|
474
|
+
}, 0);
|
475
|
+
}
|
476
|
+
}
|
477
|
+
};
|
478
|
+
|
479
|
+
canvas.loseContextInNCalls = function(numCalls) {
|
480
|
+
if (contextLost_) {
|
481
|
+
throw "You can not ask a lost contet to be lost";
|
482
|
+
}
|
483
|
+
numCallsToLoseContext_ = numCalls_ + numCalls;
|
484
|
+
};
|
485
|
+
|
486
|
+
canvas.getNumCalls = function() {
|
487
|
+
return numCalls_;
|
488
|
+
};
|
489
|
+
|
490
|
+
canvas.setRestoreTimeout = function(timeout) {
|
491
|
+
restoreTimeout_ = timeout;
|
492
|
+
};
|
493
|
+
|
494
|
+
function isWebGLObject(obj) {
|
495
|
+
//return false;
|
496
|
+
return (obj instanceof WebGLBuffer ||
|
497
|
+
obj instanceof WebGLFramebuffer ||
|
498
|
+
obj instanceof WebGLProgram ||
|
499
|
+
obj instanceof WebGLRenderbuffer ||
|
500
|
+
obj instanceof WebGLShader ||
|
501
|
+
obj instanceof WebGLTexture);
|
502
|
+
}
|
503
|
+
|
504
|
+
function checkResources(args) {
|
505
|
+
for (var ii = 0; ii < args.length; ++ii) {
|
506
|
+
var arg = args[ii];
|
507
|
+
if (isWebGLObject(arg)) {
|
508
|
+
return arg.__webglDebugContextLostId__ == contextId_;
|
509
|
+
}
|
510
|
+
}
|
511
|
+
return true;
|
512
|
+
}
|
513
|
+
|
514
|
+
function clearErrors() {
|
515
|
+
var k = Object.keys(glErrorShadow_);
|
516
|
+
for (var ii = 0; ii < k.length; ++ii) {
|
517
|
+
delete glErrorShadow_[k];
|
518
|
+
}
|
519
|
+
}
|
520
|
+
|
521
|
+
function loseContextIfTime() {
|
522
|
+
++numCalls_;
|
523
|
+
if (!contextLost_) {
|
524
|
+
if (numCallsToLoseContext_ == numCalls_) {
|
525
|
+
canvas.loseContext();
|
526
|
+
}
|
527
|
+
}
|
528
|
+
}
|
529
|
+
|
530
|
+
// Makes a function that simulates WebGL when out of context.
|
531
|
+
function makeLostContextFunctionWrapper(ctx, functionName) {
|
532
|
+
var f = ctx[functionName];
|
533
|
+
return function() {
|
534
|
+
// log("calling:" + functionName);
|
535
|
+
// Only call the functions if the context is not lost.
|
536
|
+
loseContextIfTime();
|
537
|
+
if (!contextLost_) {
|
538
|
+
//if (!checkResources(arguments)) {
|
539
|
+
// glErrorShadow_[wrappedContext_.INVALID_OPERATION] = true;
|
540
|
+
// return;
|
541
|
+
//}
|
542
|
+
|
543
|
+
var result = f.apply(ctx, arguments);
|
544
|
+
return result;
|
545
|
+
}
|
546
|
+
};
|
547
|
+
}
|
548
|
+
|
549
|
+
function freeResources() {
|
550
|
+
for (var ii = 0; ii < resourceDb_.length; ++ii) {
|
551
|
+
var resource = resourceDb_[ii];
|
552
|
+
if (resource instanceof WebGLBuffer) {
|
553
|
+
unwrappedContext_.deleteBuffer(resource);
|
554
|
+
} else if (resource instanceof WebGLFramebuffer) {
|
555
|
+
unwrappedContext_.deleteFramebuffer(resource);
|
556
|
+
} else if (resource instanceof WebGLProgram) {
|
557
|
+
unwrappedContext_.deleteProgram(resource);
|
558
|
+
} else if (resource instanceof WebGLRenderbuffer) {
|
559
|
+
unwrappedContext_.deleteRenderbuffer(resource);
|
560
|
+
} else if (resource instanceof WebGLShader) {
|
561
|
+
unwrappedContext_.deleteShader(resource);
|
562
|
+
} else if (resource instanceof WebGLTexture) {
|
563
|
+
unwrappedContext_.deleteTexture(resource);
|
564
|
+
}
|
565
|
+
}
|
566
|
+
}
|
567
|
+
|
568
|
+
function makeWebGLContextEvent(statusMessage) {
|
569
|
+
return {
|
570
|
+
statusMessage: statusMessage,
|
571
|
+
preventDefault: function() {
|
572
|
+
canRestore_ = true;
|
573
|
+
}
|
574
|
+
};
|
575
|
+
}
|
576
|
+
|
577
|
+
return canvas;
|
578
|
+
|
579
|
+
function makeLostContextSimulatingContext(ctx) {
|
580
|
+
// copy all functions and properties to wrapper
|
581
|
+
for (var propertyName in ctx) {
|
582
|
+
if (typeof ctx[propertyName] == 'function') {
|
583
|
+
wrappedContext_[propertyName] = makeLostContextFunctionWrapper(
|
584
|
+
ctx, propertyName);
|
585
|
+
} else {
|
586
|
+
makePropertyWrapper(wrappedContext_, ctx, propertyName);
|
587
|
+
}
|
588
|
+
}
|
589
|
+
|
590
|
+
// Wrap a few functions specially.
|
591
|
+
wrappedContext_.getError = function() {
|
592
|
+
loseContextIfTime();
|
593
|
+
if (!contextLost_) {
|
594
|
+
var err;
|
595
|
+
while (err = unwrappedContext_.getError()) {
|
596
|
+
glErrorShadow_[err] = true;
|
597
|
+
}
|
598
|
+
}
|
599
|
+
for (var err in glErrorShadow_) {
|
600
|
+
if (glErrorShadow_[err]) {
|
601
|
+
delete glErrorShadow_[err];
|
602
|
+
return err;
|
603
|
+
}
|
604
|
+
}
|
605
|
+
return wrappedContext_.NO_ERROR;
|
606
|
+
};
|
607
|
+
|
608
|
+
var creationFunctions = [
|
609
|
+
"createBuffer",
|
610
|
+
"createFramebuffer",
|
611
|
+
"createProgram",
|
612
|
+
"createRenderbuffer",
|
613
|
+
"createShader",
|
614
|
+
"createTexture"
|
615
|
+
];
|
616
|
+
for (var ii = 0; ii < creationFunctions.length; ++ii) {
|
617
|
+
var functionName = creationFunctions[ii];
|
618
|
+
wrappedContext_[functionName] = function(f) {
|
619
|
+
return function() {
|
620
|
+
loseContextIfTime();
|
621
|
+
if (contextLost_) {
|
622
|
+
return null;
|
623
|
+
}
|
624
|
+
var obj = f.apply(ctx, arguments);
|
625
|
+
obj.__webglDebugContextLostId__ = contextId_;
|
626
|
+
resourceDb_.push(obj);
|
627
|
+
return obj;
|
628
|
+
};
|
629
|
+
}(ctx[functionName]);
|
630
|
+
}
|
631
|
+
|
632
|
+
var functionsThatShouldReturnNull = [
|
633
|
+
"getActiveAttrib",
|
634
|
+
"getActiveUniform",
|
635
|
+
"getBufferParameter",
|
636
|
+
"getContextAttributes",
|
637
|
+
"getAttachedShaders",
|
638
|
+
"getFramebufferAttachmentParameter",
|
639
|
+
"getParameter",
|
640
|
+
"getProgramParameter",
|
641
|
+
"getProgramInfoLog",
|
642
|
+
"getRenderbufferParameter",
|
643
|
+
"getShaderParameter",
|
644
|
+
"getShaderInfoLog",
|
645
|
+
"getShaderSource",
|
646
|
+
"getTexParameter",
|
647
|
+
"getUniform",
|
648
|
+
"getUniformLocation",
|
649
|
+
"getVertexAttrib"
|
650
|
+
];
|
651
|
+
for (var ii = 0; ii < functionsThatShouldReturnNull.length; ++ii) {
|
652
|
+
var functionName = functionsThatShouldReturnNull[ii];
|
653
|
+
wrappedContext_[functionName] = function(f) {
|
654
|
+
return function() {
|
655
|
+
loseContextIfTime();
|
656
|
+
if (contextLost_) {
|
657
|
+
return null;
|
658
|
+
}
|
659
|
+
return f.apply(ctx, arguments);
|
660
|
+
}
|
661
|
+
}(wrappedContext_[functionName]);
|
662
|
+
}
|
663
|
+
|
664
|
+
var isFunctions = [
|
665
|
+
"isBuffer",
|
666
|
+
"isEnabled",
|
667
|
+
"isFramebuffer",
|
668
|
+
"isProgram",
|
669
|
+
"isRenderbuffer",
|
670
|
+
"isShader",
|
671
|
+
"isTexture"
|
672
|
+
];
|
673
|
+
for (var ii = 0; ii < isFunctions.length; ++ii) {
|
674
|
+
var functionName = isFunctions[ii];
|
675
|
+
wrappedContext_[functionName] = function(f) {
|
676
|
+
return function() {
|
677
|
+
loseContextIfTime();
|
678
|
+
if (contextLost_) {
|
679
|
+
return false;
|
680
|
+
}
|
681
|
+
return f.apply(ctx, arguments);
|
682
|
+
}
|
683
|
+
}(wrappedContext_[functionName]);
|
684
|
+
}
|
685
|
+
|
686
|
+
wrappedContext_.checkFramebufferStatus = function(f) {
|
687
|
+
return function() {
|
688
|
+
loseContextIfTime();
|
689
|
+
if (contextLost_) {
|
690
|
+
return wrappedContext_.FRAMEBUFFER_UNSUPPORTED;
|
691
|
+
}
|
692
|
+
return f.apply(ctx, arguments);
|
693
|
+
};
|
694
|
+
}(wrappedContext_.checkFramebufferStatus);
|
695
|
+
|
696
|
+
wrappedContext_.getAttribLocation = function(f) {
|
697
|
+
return function() {
|
698
|
+
loseContextIfTime();
|
699
|
+
if (contextLost_) {
|
700
|
+
return -1;
|
701
|
+
}
|
702
|
+
return f.apply(ctx, arguments);
|
703
|
+
};
|
704
|
+
}(wrappedContext_.getAttribLocation);
|
705
|
+
|
706
|
+
wrappedContext_.getVertexAttribOffset = function(f) {
|
707
|
+
return function() {
|
708
|
+
loseContextIfTime();
|
709
|
+
if (contextLost_) {
|
710
|
+
return 0;
|
711
|
+
}
|
712
|
+
return f.apply(ctx, arguments);
|
713
|
+
};
|
714
|
+
}(wrappedContext_.getVertexAttribOffset);
|
715
|
+
|
716
|
+
wrappedContext_.isContextLost = function() {
|
717
|
+
return contextLost_;
|
718
|
+
};
|
719
|
+
|
720
|
+
return wrappedContext_;
|
721
|
+
}
|
722
|
+
}
|
723
|
+
|
724
|
+
return {
|
725
|
+
/**
|
726
|
+
* Initializes this module. Safe to call more than once.
|
727
|
+
* @param {!WebGLRenderingContext} ctx A WebGL context. If
|
728
|
+
}
|
729
|
+
* you have more than one context it doesn't matter which one
|
730
|
+
* you pass in, it is only used to pull out constants.
|
731
|
+
*/
|
732
|
+
'init': init,
|
733
|
+
|
734
|
+
/**
|
735
|
+
* Returns true or false if value matches any WebGL enum
|
736
|
+
* @param {*} value Value to check if it might be an enum.
|
737
|
+
* @return {boolean} True if value matches one of the WebGL defined enums
|
738
|
+
*/
|
739
|
+
'mightBeEnum': mightBeEnum,
|
740
|
+
|
741
|
+
/**
|
742
|
+
* Gets an string version of an WebGL enum.
|
743
|
+
*
|
744
|
+
* Example:
|
745
|
+
* WebGLDebugUtil.init(ctx);
|
746
|
+
* var str = WebGLDebugUtil.glEnumToString(ctx.getError());
|
747
|
+
*
|
748
|
+
* @param {number} value Value to return an enum for
|
749
|
+
* @return {string} The string version of the enum.
|
750
|
+
*/
|
751
|
+
'glEnumToString': glEnumToString,
|
752
|
+
|
753
|
+
/**
|
754
|
+
* Converts the argument of a WebGL function to a string.
|
755
|
+
* Attempts to convert enum arguments to strings.
|
756
|
+
*
|
757
|
+
* Example:
|
758
|
+
* WebGLDebugUtil.init(ctx);
|
759
|
+
* var str = WebGLDebugUtil.glFunctionArgToString('bindTexture', 0, gl.TEXTURE_2D);
|
760
|
+
*
|
761
|
+
* would return 'TEXTURE_2D'
|
762
|
+
*
|
763
|
+
* @param {string} functionName the name of the WebGL function.
|
764
|
+
* @param {number} argumentIndx the index of the argument.
|
765
|
+
* @param {*} value The value of the argument.
|
766
|
+
* @return {string} The value as a string.
|
767
|
+
*/
|
768
|
+
'glFunctionArgToString': glFunctionArgToString,
|
769
|
+
|
770
|
+
/**
|
771
|
+
* Converts the arguments of a WebGL function to a string.
|
772
|
+
* Attempts to convert enum arguments to strings.
|
773
|
+
*
|
774
|
+
* @param {string} functionName the name of the WebGL function.
|
775
|
+
* @param {number} args The arguments.
|
776
|
+
* @return {string} The arguments as a string.
|
777
|
+
*/
|
778
|
+
'glFunctionArgsToString': glFunctionArgsToString,
|
779
|
+
|
780
|
+
/**
|
781
|
+
* Given a WebGL context returns a wrapped context that calls
|
782
|
+
* gl.getError after every command and calls a function if the
|
783
|
+
* result is not NO_ERROR.
|
784
|
+
*
|
785
|
+
* You can supply your own function if you want. For example, if you'd like
|
786
|
+
* an exception thrown on any GL error you could do this
|
787
|
+
*
|
788
|
+
* function throwOnGLError(err, funcName, args) {
|
789
|
+
* throw WebGLDebugUtils.glEnumToString(err) +
|
790
|
+
* " was caused by call to " + funcName;
|
791
|
+
* };
|
792
|
+
*
|
793
|
+
* ctx = WebGLDebugUtils.makeDebugContext(
|
794
|
+
* canvas.getContext("webgl"), throwOnGLError);
|
795
|
+
*
|
796
|
+
* @param {!WebGLRenderingContext} ctx The webgl context to wrap.
|
797
|
+
* @param {!function(err, funcName, args): void} opt_onErrorFunc The function
|
798
|
+
* to call when gl.getError returns an error. If not specified the default
|
799
|
+
* function calls console.log with a message.
|
800
|
+
* @param {!function(funcName, args): void} opt_onFunc The
|
801
|
+
* function to call when each webgl function is called. You
|
802
|
+
* can use this to log all calls for example.
|
803
|
+
*/
|
804
|
+
'makeDebugContext': makeDebugContext,
|
805
|
+
|
806
|
+
/**
|
807
|
+
* Given a canvas element returns a wrapped canvas element that will
|
808
|
+
* simulate lost context. The canvas returned adds the following functions.
|
809
|
+
*
|
810
|
+
* loseContext:
|
811
|
+
* simulates a lost context event.
|
812
|
+
*
|
813
|
+
* restoreContext:
|
814
|
+
* simulates the context being restored.
|
815
|
+
*
|
816
|
+
* lostContextInNCalls:
|
817
|
+
* loses the context after N gl calls.
|
818
|
+
*
|
819
|
+
* getNumCalls:
|
820
|
+
* tells you how many gl calls there have been so far.
|
821
|
+
*
|
822
|
+
* setRestoreTimeout:
|
823
|
+
* sets the number of milliseconds until the context is restored
|
824
|
+
* after it has been lost. Defaults to 0. Pass -1 to prevent
|
825
|
+
* automatic restoring.
|
826
|
+
*
|
827
|
+
* @param {!Canvas} canvas The canvas element to wrap.
|
828
|
+
*/
|
829
|
+
'makeLostContextSimulatingCanvas': makeLostContextSimulatingCanvas,
|
830
|
+
|
831
|
+
/**
|
832
|
+
* Resets a context to the initial state.
|
833
|
+
* @param {!WebGLRenderingContext} ctx The webgl context to
|
834
|
+
* reset.
|
835
|
+
*/
|
836
|
+
'resetToInitialState': resetToInitialState
|
837
|
+
};
|
838
|
+
|
839
|
+
}();
|