mirror of
https://github.com/wahyd4/three.js.git
synced 2026-08-18 01:16:20 +10:00
* `CanvasRenderer` and `SVGRenderer` basic lighting support (`*ColorStroke`/`*ColorFill` only) * `Renderer` > `Projector`. `CanvasRenderer`, `SVGRenderer` and `DOMRenderer` do not extend anymore * Interactivity base code (hdi folder). To be refactored... ([mindlapse](http://github.com/mindlapse)) * Added `computeCentroids` method to `Geometry` * Included `Stats.js` directly in the `/examples` folder to avoid the need of internet for playing around
48 lines
1.1 KiB
JavaScript
48 lines
1.1 KiB
JavaScript
/**
|
|
* @author mr.doob / http://mrdoob.com/
|
|
*/
|
|
|
|
var ClickCube = function (width, height, depth, onSelect) {
|
|
|
|
THREE.Geometry.call(this);
|
|
|
|
var scope = this,
|
|
width_half = width / 2,
|
|
height_half = height / 2,
|
|
depth_half = depth / 2;
|
|
|
|
v( width_half, height_half, -depth_half );
|
|
v( width_half, -height_half, -depth_half );
|
|
v( -width_half, -height_half, -depth_half );
|
|
v( -width_half, height_half, -depth_half );
|
|
v( width_half, height_half, depth_half );
|
|
v( width_half, -height_half, depth_half );
|
|
v( -width_half, -height_half, depth_half );
|
|
v( -width_half, height_half, depth_half );
|
|
|
|
f4( 0, 1, 2, 3 );
|
|
|
|
f4( 4, 7, 6, 5 );
|
|
f4( 0, 4, 5, 1 );
|
|
f4( 2, 6, 7, 3 );
|
|
f4( 1, 5, 6, 2 );
|
|
f4( 4, 0, 3, 7 );
|
|
|
|
function v(x, y, z) {
|
|
|
|
scope.vertices.push( new THREE.Vertex( new THREE.Vector3( x, y, z ) ) );
|
|
}
|
|
|
|
function f4(a, b, c, d) {
|
|
var f = new THREE.SelectableFace4( a, b, c, d, onSelect );
|
|
scope.faces.push(f);
|
|
}
|
|
|
|
this.computeCentroids();
|
|
this.computeNormals();
|
|
|
|
};
|
|
|
|
ClickCube.prototype = new THREE.Geometry();
|
|
ClickCube.prototype.constructor = ClickCube;
|