topical media & game development
mobile-query-three-plugins-buffergeometry-examples-original.htm / htm
<!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);
var triangles = 50;
var vertexIdxArray = new Int16Array(triangles * 3);
for(var i = 0; i < vertexIdxArray.length; i++){
vertexIdxArray[i] = i;
}
var vertexPosArray = new Float32Array(triangles * 3 * 3);
for(var i = 0; i < vertexPosArray.length; i++ ){
vertexPosArray[i] = Math.random() * 2;
}
var uvArray = new Float32Array(triangles * 3 * 2);
for(var i = 0; i < uvArray.length; i++ ){
uvArray[i] = Math.random();
}
var attributes = {
index : {
itemSize: 1,
array : vertexIdxArray,
numItems: vertexIdxArray.length
},
position : {
itemSize: 3,
array : vertexPosArray,
numItems: vertexPosArray.length
},
uv : {
itemSize: 2,
array : uvArray,
numItems: uvArray.length
}
};
var geometry = new THREE.BufferGeometry();
geometry.attributes = attributes;
geometry.offsets = [{
start : 0,
count : triangles * 3,
index : 0
}];
geometry.computeBoundingBox();
geometry.computeBoundingSphere();
geometry.computeVertexNormals();
var material = new THREE.MeshBasicMaterial({
color : 0xffffff,
map : THREE.ImageUtils.loadTexture( "../../assets/images/water.jpg" )
});
//var material = new THREE.MeshNormalMaterial();
var mesh = new THREE.Mesh(geometry, material);
world.add(mesh);
</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.