Permalink
Browse files

more work

  • Loading branch information...
1 parent 536f6ab commit da48c2f21302f08237cf47911514fe90ce6ddc3d @jeromeetienne committed Mar 3, 2013
@@ -37614,6 +37614,27 @@ tQuery.MicroeventMixin = function(destObj){
}
};
+/**
+ * https://github.com/jeromeetienne/MicroCache.js
+*/
+tQuery.MicroCache = function(){
+ var _values = {};
+ return {
+ get : function(key){ return _values[key]; },
+ contains: function(key){ return key in _values; },
+ remove : function(key){ delete _values[key]; },
+ set : function(key, value){ _values[key] = value;},
+ values : function(){ return _values; },
+ getSet : function(key, value){
+ if( !this.contains(key) ){
+ this.set(key, typeof value == 'function' ? value() : value )
+ }
+ return this.get(key);
+ }
+ }
+}
+
+
tQuery.convert = {};
/**
@@ -38978,6 +38999,11 @@ tQuery.registerStatic('createTorusKnot', function(){
return this._createMesh(ctor, dflGeometry, arguments)
});
+tQuery.registerStatic('createCircle', function(){
+ var ctor = THREE.CircleGeometry;
+ var dflGeometry = [0.5, 32];
+ return this._createMesh(ctor, dflGeometry, arguments)
+});
tQuery.registerStatic('createVector3', function(x, y, z){
return new THREE.Vector3(x, y, z);
@@ -39982,7 +40008,7 @@ tQuery.World.registerInstance('boilerplate', function(opts){
tQuery.World.registerInstance('pageTitle', function(element){
// handle parameters polymorphism
if( typeof(element) === 'string' ){
- var element = document.querySelector(element);
+ element = document.querySelector(element);
}
// sanity check
console.assert( element instanceof HTMLElement, ".pageTitle(element) needs a HTMLElement");
@@ -39998,6 +40024,19 @@ tQuery.World.registerInstance('pageTitle', function(element){
return this;
});
+tQuery.World.registerInstance('devicePixelRatio', function(ratio){
+ // change devicePixelRatio
+ var tRenderer = this.tRenderer();
+ tRenderer.devicePixelRatio = ratio;
+
+ // get context
+ var ctx = tQuery.data(this, '_boilerplateCtx');
+ var windowResize= ctx.windowResize;
+ windowResize.trigger();
+ // for chained API
+ return this;
+});
+
tQuery.World.registerInstance('addBoilerplate', function(opts){
var _this = this;
// sanity check - no boilerplate is already installed
@@ -40061,6 +40100,13 @@ tQuery.World.registerInstance('addBoilerplate', function(opts){
this.removeBoilerplate();
});
+
+ // if on mobile, set devicePixelRatio to 1/2
+ // NOTE: assume that having touch event implies a mobile, it may not be true
+ var onMobile = 'ontouchstart' in window ? true : false;
+ onMobile && this.devicePixelRatio(1/2)
+
+
// for chained API
return this;
});
@@ -40094,7 +40140,8 @@ tQuery.World.registerInstance('removeBoilerplate', function(){
ctx.screenshot && ctx.screenshot.unbind();
// unbind fullscreen
ctx.fullscreen && ctx.fullscreen.unbind();
-});// This THREEx helper makes it easy to handle window resize.
+});
+// This THREEx helper makes it easy to handle window resize.
// It will update renderer and camera when window is resized.
//
// # Usage
@@ -40121,10 +40168,12 @@ var THREEx = THREEx || {};
*/
THREEx.WindowResize = function(renderer, camera){
var callback = function(){
+ var renderW = window.innerWidth;
+ var renderH = window.innerHeight;
// notify the renderer of the size change
- renderer.setSize( window.innerWidth, window.innerHeight );
+ renderer.setSize( renderW, renderH );
// update the camera
- camera.aspect = window.innerWidth / window.innerHeight;
+ camera.aspect = renderW / renderH;
camera.updateProjectionMatrix();
}
// bind the resize event
@@ -40137,7 +40186,13 @@ THREEx.WindowResize = function(renderer, camera){
stop : function(){
window.removeEventListener('resize', callback);
},
- resize : callback,
+ /**
+ * to manually trigger a resize
+ * @type {[type]}
+ */
+ trigger : function(){
+ callback();
+ },
};
}
@@ -40549,6 +40604,7 @@ requirejs.config({
"tquery.text.allfonts": "plugins/text/fonts/droid/droid_serif_regular.typeface",
"tquery.tweenjs": "plugins/tweenjs/tquery.tween",
"tquery.videos": "plugins/videos/tquery.createvideotexture",
+ "tquery.virtualjoystick": "plugins/virtualjoystick/vendor/virtualjoystick",
"tquery.webaudio": "plugins/requirejs/confrequire/webaudio.initrequire",
"webgl-inspector": "plugins/requirejs/confrequire/webglinspector.initrequire",
"domReady": "plugins/requirejs/vendor/domReady",
@@ -37614,6 +37614,27 @@ tQuery.MicroeventMixin = function(destObj){
}
};
+/**
+ * https://github.com/jeromeetienne/MicroCache.js
+*/
+tQuery.MicroCache = function(){
+ var _values = {};
+ return {
+ get : function(key){ return _values[key]; },
+ contains: function(key){ return key in _values; },
+ remove : function(key){ delete _values[key]; },
+ set : function(key, value){ _values[key] = value;},
+ values : function(){ return _values; },
+ getSet : function(key, value){
+ if( !this.contains(key) ){
+ this.set(key, typeof value == 'function' ? value() : value )
+ }
+ return this.get(key);
+ }
+ }
+}
+
+
tQuery.convert = {};
/**
@@ -38978,6 +38999,11 @@ tQuery.registerStatic('createTorusKnot', function(){
return this._createMesh(ctor, dflGeometry, arguments)
});
+tQuery.registerStatic('createCircle', function(){
+ var ctor = THREE.CircleGeometry;
+ var dflGeometry = [0.5, 32];
+ return this._createMesh(ctor, dflGeometry, arguments)
+});
tQuery.registerStatic('createVector3', function(x, y, z){
return new THREE.Vector3(x, y, z);
@@ -39982,7 +40008,7 @@ tQuery.World.registerInstance('boilerplate', function(opts){
tQuery.World.registerInstance('pageTitle', function(element){
// handle parameters polymorphism
if( typeof(element) === 'string' ){
- var element = document.querySelector(element);
+ element = document.querySelector(element);
}
// sanity check
console.assert( element instanceof HTMLElement, ".pageTitle(element) needs a HTMLElement");
@@ -39998,6 +40024,19 @@ tQuery.World.registerInstance('pageTitle', function(element){
return this;
});
+tQuery.World.registerInstance('devicePixelRatio', function(ratio){
+ // change devicePixelRatio
+ var tRenderer = this.tRenderer();
+ tRenderer.devicePixelRatio = ratio;
+
+ // get context
+ var ctx = tQuery.data(this, '_boilerplateCtx');
+ var windowResize= ctx.windowResize;
+ windowResize.trigger();
+ // for chained API
+ return this;
+});
+
tQuery.World.registerInstance('addBoilerplate', function(opts){
var _this = this;
// sanity check - no boilerplate is already installed
@@ -40061,6 +40100,13 @@ tQuery.World.registerInstance('addBoilerplate', function(opts){
this.removeBoilerplate();
});
+
+ // if on mobile, set devicePixelRatio to 1/2
+ // NOTE: assume that having touch event implies a mobile, it may not be true
+ var onMobile = 'ontouchstart' in window ? true : false;
+ onMobile && this.devicePixelRatio(1/2)
+
+
// for chained API
return this;
});
@@ -40094,7 +40140,8 @@ tQuery.World.registerInstance('removeBoilerplate', function(){
ctx.screenshot && ctx.screenshot.unbind();
// unbind fullscreen
ctx.fullscreen && ctx.fullscreen.unbind();
-});// This THREEx helper makes it easy to handle window resize.
+});
+// This THREEx helper makes it easy to handle window resize.
// It will update renderer and camera when window is resized.
//
// # Usage
@@ -40121,10 +40168,12 @@ var THREEx = THREEx || {};
*/
THREEx.WindowResize = function(renderer, camera){
var callback = function(){
+ var renderW = window.innerWidth;
+ var renderH = window.innerHeight;
// notify the renderer of the size change
- renderer.setSize( window.innerWidth, window.innerHeight );
+ renderer.setSize( renderW, renderH );
// update the camera
- camera.aspect = window.innerWidth / window.innerHeight;
+ camera.aspect = renderW / renderH;
camera.updateProjectionMatrix();
}
// bind the resize event
@@ -40137,7 +40186,13 @@ THREEx.WindowResize = function(renderer, camera){
stop : function(){
window.removeEventListener('resize', callback);
},
- resize : callback,
+ /**
+ * to manually trigger a resize
+ * @type {[type]}
+ */
+ trigger : function(){
+ callback();
+ },
};
}
View
@@ -388,6 +388,27 @@ tQuery.MicroeventMixin = function(destObj){
}
};
+/**
+ * https://github.com/jeromeetienne/MicroCache.js
+*/
+tQuery.MicroCache = function(){
+ var _values = {};
+ return {
+ get : function(key){ return _values[key]; },
+ contains: function(key){ return key in _values; },
+ remove : function(key){ delete _values[key]; },
+ set : function(key, value){ _values[key] = value;},
+ values : function(){ return _values; },
+ getSet : function(key, value){
+ if( !this.contains(key) ){
+ this.set(key, typeof value == 'function' ? value() : value )
+ }
+ return this.get(key);
+ }
+ }
+}
+
+
tQuery.convert = {};
/**
@@ -1752,6 +1773,11 @@ tQuery.registerStatic('createTorusKnot', function(){
return this._createMesh(ctor, dflGeometry, arguments)
});
+tQuery.registerStatic('createCircle', function(){
+ var ctor = THREE.CircleGeometry;
+ var dflGeometry = [0.5, 32];
+ return this._createMesh(ctor, dflGeometry, arguments)
+});
tQuery.registerStatic('createVector3', function(x, y, z){
return new THREE.Vector3(x, y, z);
@@ -6,7 +6,7 @@ tQuery.Mesh.registerInstance('linkify', function(url){
// build the underline
var underlineH = size.y / 10;
var deltaY = size.y / 20;
- var underline = tQuery.createCube(size.x, underlineH, size.z, mesh.get(0).material)
+ var underline = tQuery.createCube(size.x, underlineH, size.z)
.translateY(-size.y/2 - deltaY - underlineH/2)
.addClass('underline')
// make it invisible by default
@@ -44,6 +44,7 @@ requirejs.config({
"tquery.text.allfonts": "plugins/text/fonts/droid/droid_serif_regular.typeface",
"tquery.tweenjs": "plugins/tweenjs/tquery.tween",
"tquery.videos": "plugins/videos/tquery.createvideotexture",
+ "tquery.virtualjoystick": "plugins/virtualjoystick/vendor/virtualjoystick",
"tquery.webaudio": "plugins/requirejs/confrequire/webaudio.initrequire",
"webgl-inspector": "plugins/requirejs/confrequire/webglinspector.initrequire",
"domReady": "plugins/requirejs/vendor/domReady",
@@ -1,4 +1,4 @@
-<!doctype html><title>Minimal tQuery Page</title>
+s<!doctype html><title>Minimal tQuery Page</title>
<script src="../../../build/tquery-bundle-require.js"></script>
<body><script>
require(['tquery.skymap', 'tquery.grassground', 'tquery.minecraft'], function(){
@@ -28,6 +28,7 @@
+
tQuery(cubeCamera).addTo(sphere)
world.loop().hook(function(){
@@ -5,16 +5,9 @@
var world = tQuery.createWorld().boilerplate().start();
var object = tQuery.createTorusKnot().addTo(world);
- world.devicePixelRatio(1/2)
-
- world.removeCameraControls();
-
var joystick = new VirtualJoystick({
container : document.body,
- mouseSupport : true,
- fireCallback : function(){
- object.scaleBy(1.2)
- }
+ mouseSupport : true
});
world.loop().hook(function(delta, now){
@@ -4,9 +4,8 @@ var VirtualJoystick = function(opts)
this._container = opts.container || document.body;
this._stickEl = opts.stickElement || this._buildJoystickStick();
this._baseEl = opts.baseElement || this._buildJoystickBase();
- this._mouseSupport = 'mouseSupport' in opts? opts.mouseSupport : false;
this._range = opts.range || 60;
- this._fireCallback = opts.fireCallback || function(){};
+ this._mouseSupport = opra.mouseSupport !== undefined ? opts.mouseSupport : false;
this._container.style.position = "relative";
@@ -124,15 +123,10 @@ VirtualJoystick.prototype._onUp = function()
this._baseX = this._baseY = 0;
this._stickX = this._stickY = 0;
-
- if( (Date.now() - this._timestamp)/1000 < 0.5 ){
- this._fireCallback()
- }
}
VirtualJoystick.prototype._onDown = function(x, y)
{
- this._timestamp = Date.now();
this._pressed = true;
this._baseX = x;
this._baseY = y;

0 comments on commit da48c2f

Please sign in to comment.