topical media & game development
mobile-query-three-plugins-physics-examples-labyrinth.htm / htm
<!doctype html><title>Minimal tQuery Page</title>
<script src="../../../build/tquery-bundle.js"></script>
<script src="./vendor/physijs/physi.js"></script>
<script src="../tquery.physijs.js"></script>
<body><script>
var world = tQuery.createWorld().boilerplate().start();
world.tCamera().translateZ(-130);
// TODO this cause trouble. i dont want to setup that everytime
Physijs.scripts.worker = 'vendor/physijs/physijs_worker.js';
Physijs.scripts.ammo = 'ammo.js';
world.enablePhysics();
world.getCameraControls().rangeX *= 4;
world.getCameraControls().rangeY *= 4;
var groundW = 100;
var groundH = 1;
var groundD = 75;
var wallW = 3;
var texture = THREE.ImageUtils.loadTexture( "../../assets/images/plywood.jpg" );
texture.wrapS = texture.wrapT = THREE.RepeatWrapping;
texture.repeat.set( 2, 2 );
// Ground
tQuery.createCube(groundW, groundH, groundD).addTo(world)
.translateY(-10-groundH/2)
.setBasicMaterial().map(texture).back()
.enablePhysics({
mass : 0,
friction : 0.5,
restitution : 1
});
var texture = THREE.ImageUtils.loadTexture( "../../assets/images/wood.jpg" );
texture.wrapS = texture.wrapT = THREE.RepeatWrapping;
texture.repeat.set( 0.5, 0.5 );
// north
tQuery.createCube(groundW, wallW, wallW).addTo(world)
.setBasicMaterial().map(texture).back()
.translateY(-10+wallW/2)
.translateZ(+groundD/2-wallW/2)
// south
tQuery.createCube(groundW, wallW, wallW).addTo(world)
.setBasicMaterial().map(texture).back()
.translateY(-10+wallW/2)
.translateZ(-groundD/2+wallW/2)
// east
tQuery.createCube(wallW, wallW, groundD-wallW*2).addTo(world)
.setBasicMaterial().map(texture).back()
.translateX(-groundW/2 + wallW/2)
.translateY(-10+wallW/2)
// west
tQuery.createCube(wallW, wallW, groundD-wallW*2).addTo(world)
.setBasicMaterial().map(texture).back()
.translateX(+groundW/2 - wallW/2)
.translateY(-10+wallW/2)
//world.physics().setGravity(new THREE.Vector3(1,2,0))
var texture = THREE.ImageUtils.loadTexture( "../../assets/images/water.jpg" );
// create the ball
var object = tQuery.createSphere()
object.addTo(world)
.setBasicMaterial().color(0xffffff).map(texture).back()
.geometry().scaleBy(4, 4, 4).back()
.rotation(Math.random()*Math.PI*2, Math.random()*Math.PI*2, Math.random()*Math.PI*2)
.position(Math.random()*2-1, 15, Math.random()*2-1)
.enablePhysics({
//tGeometry : new THREE.SphereGeometry(),
friction : 0.5,
restitution : 1
});
</script></body>
(C) Æliens
04/09/2009
You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.