Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: jeromeetienne/tquery
base: 1e41bb0bf4
...
head fork: jeromeetienne/tquery
compare: 367113c8c8
Checking mergeability… Don't worry, you can still create the pull request.
  • 7 commits
  • 11 files changed
  • 0 commit comments
  • 1 contributor
View
2  Makefile
@@ -81,7 +81,7 @@ buildBundle: buildCore
cat vendor/three.js/Three.js >> build/tquery-bundle.js
cat build/tquery.js >> build/tquery-bundle.js
# include boilerplate
- cat plugins/boilerplate/tquery.world.boilerplate.js >> build/tquery-bundle.js
+ cat plugins/boilerplate/*.js >> build/tquery-bundle.js
cat vendor/threex/THREEx.WindowResize.js >> build/tquery-bundle.js
cat vendor/threex/THREEx.screenshot.js >> build/tquery-bundle.js
cat vendor/threex/THREEx.FullScreen.js >> build/tquery-bundle.js
View
11 build/tquery-bundle.js
@@ -2199,6 +2199,17 @@ tQuery.convert.toBool = function(value){
}
return undefined; // never reached - just to workaround linter complaint
};
+
+tQuery.convert.toTexture = function(value){
+ if( arguments.length === 1 && value instanceof THREE.Texture ){
+ return value;
+ }else if( arguments.length === 1 && typeof(value) === 'string' ){
+ return THREE.ImageUtils.loadTexture(value);
+ }else{
+ console.assert(false, "invalid parameter");
+ }
+ return undefined; // never reached - just to workaround linter complaint
+};
/**
* implementation of the tQuery.Node
*
View
11 build/tquery.js
@@ -364,6 +364,17 @@ tQuery.convert.toBool = function(value){
}
return undefined; // never reached - just to workaround linter complaint
};
+
+tQuery.convert.toTexture = function(value){
+ if( arguments.length === 1 && value instanceof THREE.Texture ){
+ return value;
+ }else if( arguments.length === 1 && typeof(value) === 'string' ){
+ return THREE.ImageUtils.loadTexture(value);
+ }else{
+ console.assert(false, "invalid parameter");
+ }
+ return undefined; // never reached - just to workaround linter complaint
+};
/**
* implementation of the tQuery.Node
*
View
11 js/tquery.convert.js
@@ -58,3 +58,14 @@ tQuery.convert.toBool = function(value){
}
return undefined; // never reached - just to workaround linter complaint
};
+
+tQuery.convert.toTexture = function(value){
+ if( arguments.length === 1 && value instanceof THREE.Texture ){
+ return value;
+ }else if( arguments.length === 1 && typeof(value) === 'string' ){
+ return THREE.ImageUtils.loadTexture(value);
+ }else{
+ console.assert(false, "invalid parameter");
+ }
+ return undefined; // never reached - just to workaround linter complaint
+};
View
6 plugins/blueskybackground/examples/index.html
@@ -0,0 +1,6 @@
+<!doctype html><title>Minimal tQuery Page</title>
+<script src="../../../build/tquery-bundle.js"></script>
+<script src="../tquery.addblueskybackground.js"></script>
+<body><script>
+ tQuery.addBlueSkyBackground();
+</script></body>
View
12 plugins/bluesky/examples/index.html → .../blueskybackground/tquery.addblueskybackground.js
@@ -1,9 +1,4 @@
-<!doctype html><title>Minimal tQuery Page</title>
-<script src="../../../build/tquery-bundle.js"></script>
-<body><script>
- //var world = tQuery.createWorld().boilerplate().start();
- //var object = tQuery.createTorus().addTo(world);
-
+tQuery.register('addBlueSkyBackground', function(){
// directly from @mrdoob in http://mrdoob.com/lab/javascript/webgl/clouds/
var canvas = document.createElement( 'canvas' );
var context = canvas.getContext( '2d' );
@@ -11,7 +6,7 @@
canvas.height = window.innerHeight;
var gradient = context.createLinearGradient( 0, 0, 0, canvas.height );
- gradient.addColorStop(0, "#1e4877");
+ gradient.addColorStop(0 , "#1e4877");
gradient.addColorStop(0.5, "#4584b4");
context.fillStyle = gradient;
@@ -19,5 +14,4 @@
var url = canvas.toDataURL('image/png');
document.body.style.background = 'url(' + url + ')';
-
-</script></body>
+})
View
127 plugins/boilerplate/tquery.world.boilerplate.js
@@ -0,0 +1,127 @@
+// backward compatibility only
+tQuery.World.register('fullpage', function(){
+ console.log("world.fullpage() is obsolete. use world.boilerplate() instead.");
+ return this.boilerplate();
+});
+
+tQuery.World.register('boilerplate', function(opts){
+ // put renderer fullpage
+ var domElement = document.body;
+ domElement.style.margin = "0";
+ domElement.style.padding = "0";
+ domElement.style.overflow = 'hidden';
+ this.appendTo(domElement);
+ this._renderer.setSize( domElement.offsetWidth, domElement.offsetHeight );
+
+ // add the boilerplate
+ this.addBoilerplate(opts);
+
+ // for chained API
+ return this;
+});
+
+tQuery.World.register('addBoilerplate', function(opts){
+ var _this = this;
+ // sanity check - no boilerplate is already installed
+ console.assert( this.hasBoilerplate() !== true );
+ // handle parameters
+ opts = tQuery.extend(opts, {
+ honorInfo : true,
+ stats : true,
+ cameraControls : true,
+ windowResize : true,
+ screenshot : true,
+ fullscreen : true
+ });
+ // get the context
+ var ctx = {};
+
+ // create the context
+ tQuery.data(this, '_boilerplateCtx', ctx);
+
+ // add css for the info element if any
+ if( opts.honorInfo ){
+ var element = document.getElementById('info');
+ if( element ){
+ element.style.position = "absolute";
+ element.style.width = "100%";
+ element.style.textAlign = "center";
+ }
+ }
+
+
+ // get some variables
+ var tCamera = this.tCamera();
+ var tRenderer = this.tRenderer();
+
+ // add Stats.js - https://github.com/mrdoob/stats.js
+ if( opts.stats ){
+ ctx.stats = new Stats();
+ ctx.stats.domElement.style.position = 'absolute';
+ ctx.stats.domElement.style.bottom = '0px';
+ tRenderer.domElement.parentNode && tRenderer.domElement.parentNode.appendChild( ctx.stats.domElement );
+ ctx.loopStats = function(){
+ ctx.stats.update();
+ };
+ this.loop().hook(ctx.loopStats);
+ }
+
+ // create a camera contol
+ if( opts.cameraControls ){
+ ctx.cameraControls = new THREEx.DragPanControls(tCamera);
+ this.setCameraControls(ctx.cameraControls);
+ }
+
+ // transparently support window resize
+ if( opts.windowResize ){
+ ctx.windowResize = THREEx.WindowResize.bind(tRenderer, tCamera);
+ }
+ // allow 'p' to make screenshot
+ if( opts.screenshot ){
+ ctx.screenshot = THREEx.Screenshot.bindKey(tRenderer);
+ }
+ // allow 'f' to go fullscreen where this feature is supported
+ if( opts.fullscreen && THREEx.FullScreen.available() ){
+ ctx.fullscreen = THREEx.FullScreen.bindKey();
+ }
+
+ // bind 'destroy' event on tQuery.world
+ ctx._$onDestroy = this.bind('destroy', function(){
+ if( this.hasBoilerplate() === false ) return;
+ this.removeBoilerplate();
+ });
+
+ // for chained API
+ return this;
+});
+
+tQuery.World.register('hasBoilerplate', function(){
+ // get the context
+ var ctx = tQuery.data(this, "_boilerplateCtx")
+ // return true if ctx if defined, false otherwise
+ return ctx === undefined ? false : true;
+});
+
+tQuery.World.register('removeBoilerplate', function(){
+ // get context
+ var ctx = tQuery.data(this, '_boilerplateCtx');
+ // if not present, return now
+ if( ctx === undefined ) return this;
+ // remove the context from this
+ tQuery.removeData(this, '_boilerplateCtx');
+
+ // unbind 'destroy' for tQuery.World
+ this.unbind('destroy', this._$onDestroy);
+
+ // remove stats.js
+ ctx.stats && document.body.removeChild(ctx.stats.domElement );
+ ctx.stats && this.loop().unhook(ctx.loopStats);
+ // remove camera
+ ctx.cameraControls && this.removeCameraControls()
+ // stop windowResize
+ ctx.windowResize && ctx.windowResize.stop();
+ // unbind screenshot
+ ctx.screenshot && ctx.screenshot.unbind();
+ // unbind fullscreen
+ ctx.fullscreen && ctx.fullscreen.unbind();
+});
View
3  plugins/materials/examples/index.html
@@ -11,8 +11,9 @@
tQuery.createDirectionalLight().addTo(world).position(1,1,-1).color(0xFFFFFF);
tQuery.createDirectionalLight().addTo(world).position(-1,1,1).color(0xffffff).intensity(1);
+ var textureUrl = "../../assets/images/water.jpg";
var object = tQuery.createTorus()
- .setLambertMaterial().ambient(0x444444).color(0xFFffff).back()
+ .setLambertMaterial().ambient(0x444444).color(0xFFffff).map(textureUrl).back()
//.setPhongMaterial().ambient(0x444444).color(0xFF88FF).back()
//.setBasicMaterial().wireframe(true).color(0x000000).back()
.addTo(world);
View
1  plugins/materials/tquery.meshbasicmaterial.js
@@ -49,6 +49,7 @@ tQuery.inherit(tQuery.MeshBasicMaterial, tQuery.Material);
tQuery.mixinAttributes(tQuery.MeshBasicMaterial, {
color : tQuery.convert.toThreeColor,
ambient : tQuery.convert.toThreeColor,
+ map : tQuery.convert.toTexture,
wireframe : tQuery.convert.toBool
});
View
3  plugins/materials/tquery.meshlambertmaterial.js
@@ -48,7 +48,8 @@ tQuery.inherit(tQuery.MeshLambertMaterial, tQuery.Material);
*/
tQuery.mixinAttributes(tQuery.MeshLambertMaterial, {
color : tQuery.convert.toThreeColor,
- ambient : tQuery.convert.toThreeColor
+ ambient : tQuery.convert.toThreeColor,
+ map : tQuery.convert.toTexture
});
View
3  plugins/materials/tquery.meshphongmaterial.js
@@ -50,7 +50,8 @@ tQuery.mixinAttributes(tQuery.MeshPhongMaterial, {
color : tQuery.convert.toThreeColor,
ambient : tQuery.convert.toThreeColor,
specular : tQuery.convert.toThreeColor,
- shininess : tQuery.convert.toNumber
+ shininess : tQuery.convert.toNumber,
+ map : tQuery.convert.toTexture
});

No commit comments for this range

Something went wrong with that request. Please try again.