Skip to content

Commit

Permalink
Updated builds.
Browse files Browse the repository at this point in the history
  • Loading branch information
mrdoob committed Sep 22, 2021
1 parent 8ea885c commit 64f9b32
Show file tree
Hide file tree
Showing 3 changed files with 264 additions and 271 deletions.
277 changes: 137 additions & 140 deletions build/three.js
Original file line number Diff line number Diff line change
Expand Up @@ -22339,111 +22339,108 @@
const _triangle = new Triangle();

class EdgesGeometry extends BufferGeometry {
constructor(geometry, thresholdAngle) {
constructor(geometry = null, thresholdAngle = 1) {
super();
this.type = 'EdgesGeometry';
this.parameters = {
geometry: geometry,
thresholdAngle: thresholdAngle
};
thresholdAngle = thresholdAngle !== undefined ? thresholdAngle : 1;

if (geometry.isGeometry === true) {
console.error('THREE.EdgesGeometry no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.');
return;
}
if (geometry !== null) {
const precisionPoints = 4;
const precision = Math.pow(10, precisionPoints);
const thresholdDot = Math.cos(DEG2RAD * thresholdAngle);
const indexAttr = geometry.getIndex();
const positionAttr = geometry.getAttribute('position');
const indexCount = indexAttr ? indexAttr.count : positionAttr.count;
const indexArr = [0, 0, 0];
const vertKeys = ['a', 'b', 'c'];
const hashes = new Array(3);
const edgeData = {};
const vertices = [];

for (let i = 0; i < indexCount; i += 3) {
if (indexAttr) {
indexArr[0] = indexAttr.getX(i);
indexArr[1] = indexAttr.getX(i + 1);
indexArr[2] = indexAttr.getX(i + 2);
} else {
indexArr[0] = i;
indexArr[1] = i + 1;
indexArr[2] = i + 2;
}

const precisionPoints = 4;
const precision = Math.pow(10, precisionPoints);
const thresholdDot = Math.cos(DEG2RAD * thresholdAngle);
const indexAttr = geometry.getIndex();
const positionAttr = geometry.getAttribute('position');
const indexCount = indexAttr ? indexAttr.count : positionAttr.count;
const indexArr = [0, 0, 0];
const vertKeys = ['a', 'b', 'c'];
const hashes = new Array(3);
const edgeData = {};
const vertices = [];
const {
a,
b,
c
} = _triangle;
a.fromBufferAttribute(positionAttr, indexArr[0]);
b.fromBufferAttribute(positionAttr, indexArr[1]);
c.fromBufferAttribute(positionAttr, indexArr[2]);

for (let i = 0; i < indexCount; i += 3) {
if (indexAttr) {
indexArr[0] = indexAttr.getX(i);
indexArr[1] = indexAttr.getX(i + 1);
indexArr[2] = indexAttr.getX(i + 2);
} else {
indexArr[0] = i;
indexArr[1] = i + 1;
indexArr[2] = i + 2;
}
_triangle.getNormal(_normal); // create hashes for the edge from the vertices

const {
a,
b,
c
} = _triangle;
a.fromBufferAttribute(positionAttr, indexArr[0]);
b.fromBufferAttribute(positionAttr, indexArr[1]);
c.fromBufferAttribute(positionAttr, indexArr[2]);

_triangle.getNormal(_normal); // create hashes for the edge from the vertices
hashes[0] = `${Math.round(a.x * precision)},${Math.round(a.y * precision)},${Math.round(a.z * precision)}`;
hashes[1] = `${Math.round(b.x * precision)},${Math.round(b.y * precision)},${Math.round(b.z * precision)}`;
hashes[2] = `${Math.round(c.x * precision)},${Math.round(c.y * precision)},${Math.round(c.z * precision)}`; // skip degenerate triangles

if (hashes[0] === hashes[1] || hashes[1] === hashes[2] || hashes[2] === hashes[0]) {
continue;
} // iterate over every edge

hashes[0] = `${Math.round(a.x * precision)},${Math.round(a.y * precision)},${Math.round(a.z * precision)}`;
hashes[1] = `${Math.round(b.x * precision)},${Math.round(b.y * precision)},${Math.round(b.z * precision)}`;
hashes[2] = `${Math.round(c.x * precision)},${Math.round(c.y * precision)},${Math.round(c.z * precision)}`; // skip degenerate triangles

if (hashes[0] === hashes[1] || hashes[1] === hashes[2] || hashes[2] === hashes[0]) {
continue;
} // iterate over every edge


for (let j = 0; j < 3; j++) {
// get the first and next vertex making up the edge
const jNext = (j + 1) % 3;
const vecHash0 = hashes[j];
const vecHash1 = hashes[jNext];
const v0 = _triangle[vertKeys[j]];
const v1 = _triangle[vertKeys[jNext]];
const hash = `${vecHash0}_${vecHash1}`;
const reverseHash = `${vecHash1}_${vecHash0}`;

if (reverseHash in edgeData && edgeData[reverseHash]) {
// if we found a sibling edge add it into the vertex array if
// it meets the angle threshold and delete the edge from the map.
if (_normal.dot(edgeData[reverseHash].normal) <= thresholdDot) {
vertices.push(v0.x, v0.y, v0.z);
vertices.push(v1.x, v1.y, v1.z);
}
for (let j = 0; j < 3; j++) {
// get the first and next vertex making up the edge
const jNext = (j + 1) % 3;
const vecHash0 = hashes[j];
const vecHash1 = hashes[jNext];
const v0 = _triangle[vertKeys[j]];
const v1 = _triangle[vertKeys[jNext]];
const hash = `${vecHash0}_${vecHash1}`;
const reverseHash = `${vecHash1}_${vecHash0}`;

if (reverseHash in edgeData && edgeData[reverseHash]) {
// if we found a sibling edge add it into the vertex array if
// it meets the angle threshold and delete the edge from the map.
if (_normal.dot(edgeData[reverseHash].normal) <= thresholdDot) {
vertices.push(v0.x, v0.y, v0.z);
vertices.push(v1.x, v1.y, v1.z);
}

edgeData[reverseHash] = null;
} else if (!(hash in edgeData)) {
// if we've already got an edge here then skip adding a new one
edgeData[hash] = {
index0: indexArr[j],
index1: indexArr[jNext],
normal: _normal.clone()
};
edgeData[reverseHash] = null;
} else if (!(hash in edgeData)) {
// if we've already got an edge here then skip adding a new one
edgeData[hash] = {
index0: indexArr[j],
index1: indexArr[jNext],
normal: _normal.clone()
};
}
}
}
} // iterate over all remaining, unmatched edges and add them to the vertex array
} // iterate over all remaining, unmatched edges and add them to the vertex array


for (const key in edgeData) {
if (edgeData[key]) {
const {
index0,
index1
} = edgeData[key];
for (const key in edgeData) {
if (edgeData[key]) {
const {
index0,
index1
} = edgeData[key];

_v0.fromBufferAttribute(positionAttr, index0);
_v0.fromBufferAttribute(positionAttr, index0);

_v1$1.fromBufferAttribute(positionAttr, index1);
_v1$1.fromBufferAttribute(positionAttr, index1);

vertices.push(_v0.x, _v0.y, _v0.z);
vertices.push(_v1$1.x, _v1$1.y, _v1$1.z);
vertices.push(_v0.x, _v0.y, _v0.z);
vertices.push(_v1$1.x, _v1$1.y, _v1$1.z);
}
}
}

this.setAttribute('position', new Float32BufferAttribute(vertices, 3));
this.setAttribute('position', new Float32BufferAttribute(vertices, 3));
}
}

}
Expand Down Expand Up @@ -25690,46 +25687,65 @@
}

class WireframeGeometry extends BufferGeometry {
constructor(geometry) {
constructor(geometry = null) {
super();
this.type = 'WireframeGeometry';
this.parameters = {
geometry: geometry
};

if (geometry.isGeometry === true) {
console.error('THREE.WireframeGeometry no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.');
return;
} // buffer


const vertices = [];
const edges = new Set(); // helper variables

const start = new Vector3();
const end = new Vector3();

if (geometry.index !== null) {
// indexed BufferGeometry
const position = geometry.attributes.position;
const indices = geometry.index;
let groups = geometry.groups;

if (groups.length === 0) {
groups = [{
start: 0,
count: indices.count,
materialIndex: 0
}];
} // create a data structure that contains all eges without duplicates


for (let o = 0, ol = groups.length; o < ol; ++o) {
const group = groups[o];
const groupStart = group.start;
const groupCount = group.count;
if (geometry !== null) {
// buffer
const vertices = [];
const edges = new Set(); // helper variables

const start = new Vector3();
const end = new Vector3();

if (geometry.index !== null) {
// indexed BufferGeometry
const position = geometry.attributes.position;
const indices = geometry.index;
let groups = geometry.groups;

if (groups.length === 0) {
groups = [{
start: 0,
count: indices.count,
materialIndex: 0
}];
} // create a data structure that contains all eges without duplicates


for (let o = 0, ol = groups.length; o < ol; ++o) {
const group = groups[o];
const groupStart = group.start;
const groupCount = group.count;

for (let i = groupStart, l = groupStart + groupCount; i < l; i += 3) {
for (let j = 0; j < 3; j++) {
const index1 = indices.getX(i + j);
const index2 = indices.getX(i + (j + 1) % 3);
start.fromBufferAttribute(position, index1);
end.fromBufferAttribute(position, index2);

if (isUniqueEdge(start, end, edges) === true) {
vertices.push(start.x, start.y, start.z);
vertices.push(end.x, end.y, end.z);
}
}
}
}
} else {
// non-indexed BufferGeometry
const position = geometry.attributes.position;

for (let i = groupStart, l = groupStart + groupCount; i < l; i += 3) {
for (let i = 0, l = position.count / 3; i < l; i++) {
for (let j = 0; j < 3; j++) {
const index1 = indices.getX(i + j);
const index2 = indices.getX(i + (j + 1) % 3);
// three edges per triangle, an edge is represented as (index1, index2)
// e.g. the first triangle has the following edges: (0,1),(1,2),(2,0)
const index1 = 3 * i + j;
const index2 = 3 * i + (j + 1) % 3;
start.fromBufferAttribute(position, index1);
end.fromBufferAttribute(position, index2);

Expand All @@ -25739,30 +25755,11 @@
}
}
}
}
} else {
// non-indexed BufferGeometry
const position = geometry.attributes.position;

for (let i = 0, l = position.count / 3; i < l; i++) {
for (let j = 0; j < 3; j++) {
// three edges per triangle, an edge is represented as (index1, index2)
// e.g. the first triangle has the following edges: (0,1),(1,2),(2,0)
const index1 = 3 * i + j;
const index2 = 3 * i + (j + 1) % 3;
start.fromBufferAttribute(position, index1);
end.fromBufferAttribute(position, index2);

if (isUniqueEdge(start, end, edges) === true) {
vertices.push(start.x, start.y, start.z);
vertices.push(end.x, end.y, end.z);
}
}
}
} // build geometry
} // build geometry


this.setAttribute('position', new Float32BufferAttribute(vertices, 3));
this.setAttribute('position', new Float32BufferAttribute(vertices, 3));
}
}

}
Expand Down
2 changes: 1 addition & 1 deletion build/three.min.js

Large diffs are not rendered by default.

Loading

0 comments on commit 64f9b32

Please sign in to comment.