PageSourceSearch

https://davidyao.me/projects/envymygun/js/geometry/nvmc/building.js

js davidyao.me collected 2026-10-04 00:20:32 UTC 1,410 bytes, 49 lines download raw bytes

1function Building(b) {
2	this.name = "Building";
3
4	var nv = b.pointsCount;
5	this.vertices = new Float32Array(nv * 2 * 3);
6
7	var vertexOffset = 0;
8	for (var i=0; i<nv; ++i) {
9		var v = b.positionAt(i);
10		this.vertices[vertexOffset + 0] = v[0];
11		this.vertices[vertexOffset + 1] = v[1];
12		this.vertices[vertexOffset + 2] = v[2];
13		vertexOffset += 3;
14	}
15
16	for (var i=0; i<nv; ++i) {
17		var v = b.positionAt(i);
18		this.vertices[vertexOffset + 0] = v[0];
19		this.vertices[vertexOffset + 1] = b.heightAt(i);
20		this.vertices[vertexOffset + 2] = v[2];
21		vertexOffset += 3;
22	}
23
24	this.triangleIndices = new Uint16Array(3 * (2 * nv + nv - 2));
25
26	var triangleOffset = 0;
27	for (var i=0; i<nv; ++i) {
28		this.triangleIndices[triangleOffset + 0] = i;
29		this.triangleIndices[triangleOffset + 1] = (i + 1) % nv;
30		this.triangleIndices[triangleOffset + 2] = nv+ (i+1)%nv;
31		triangleOffset += 3;
32
33		this.triangleIndices[triangleOffset + 0]  = i ;
34		this.triangleIndices[triangleOffset + 1]  =nv+ (i+1)%nv;
35		this.triangleIndices[triangleOffset + 2]  =nv+ i ;
36		triangleOffset += 3;
37	}
38	
39	/* triangles for the roof */
40	for (var i=0; i<(nv-2); ++i) {
41		this.triangleIndices[triangleOffset + 0] = nv;
42		this.triangleIndices[triangleOffset + 1] = nv + (i + 1) ;
43		this.triangleIndices[triangleOffset + 2] = nv + (i + 2) % nv;
44		triangleOffset += 3;
45	}
46
47	this.numVertices  = nv*2;
48	this.numTriangles = this.triangleIndices.length / 3;
49};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.