@immugio/three-math-extensions 0.2.36 → 0.2.37
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -1
- package/cjs/Line3D.js +7 -5
- package/esm/Line3D.js +7 -5
- package/package.json +1 -1
- package/src/Line3D.ts +9 -6
package/CHANGELOG.md
CHANGED
|
@@ -7,7 +7,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
9
9
|
|
|
10
|
-
## [0.2.
|
|
10
|
+
## [0.2.37](https://github.com/Immugio/three-math-extensions/compare/0.2.36...0.2.37)
|
|
11
|
+
|
|
12
|
+
### Commits
|
|
13
|
+
|
|
14
|
+
- Line3D.joinLines should preserve the order where possible [`af1c417`](https://github.com/Immugio/three-math-extensions/commit/af1c41757cbe0a4a7f804587dfca3c771023d587)
|
|
15
|
+
|
|
16
|
+
## [0.2.36](https://github.com/Immugio/three-math-extensions/compare/0.2.35...0.2.36) - 2024-10-24
|
|
11
17
|
|
|
12
18
|
### Commits
|
|
13
19
|
|
package/cjs/Line3D.js
CHANGED
|
@@ -135,25 +135,27 @@ class Line3D extends three_1.Line3 {
|
|
|
135
135
|
if (lines.length < 2) {
|
|
136
136
|
return lines.map(x => x.clone());
|
|
137
137
|
}
|
|
138
|
-
const toProcess = lines.
|
|
138
|
+
const toProcess = lines.map((line, index) => ({ line: line.clone(), index }));
|
|
139
139
|
const result = [];
|
|
140
140
|
while (toProcess.length > 0) {
|
|
141
141
|
const current = toProcess.pop();
|
|
142
142
|
let joinedLine;
|
|
143
143
|
for (let i = 0; i < result.length; i++) {
|
|
144
144
|
const other = result[i];
|
|
145
|
-
joinedLine = current.joinLine(other, distanceTolerance, parallelTolerance);
|
|
145
|
+
joinedLine = current.line.joinLine(other.line, distanceTolerance, parallelTolerance);
|
|
146
146
|
if (joinedLine) {
|
|
147
147
|
result.splice(i, 1);
|
|
148
|
-
toProcess.push(joinedLine);
|
|
148
|
+
toProcess.push({ line: joinedLine, index: current.index });
|
|
149
149
|
break;
|
|
150
150
|
}
|
|
151
151
|
}
|
|
152
152
|
if (!joinedLine) {
|
|
153
|
-
result.push(current
|
|
153
|
+
result.push(current);
|
|
154
154
|
}
|
|
155
155
|
}
|
|
156
|
-
|
|
156
|
+
// Sort the result based on the original indices
|
|
157
|
+
result.sort((a, b) => a.index - b.index);
|
|
158
|
+
return result.map(item => item.line);
|
|
157
159
|
}
|
|
158
160
|
/**
|
|
159
161
|
* Returns true if this line section completely overlaps the @other line section.
|
package/esm/Line3D.js
CHANGED
|
@@ -132,25 +132,27 @@ export class Line3D extends Line3 {
|
|
|
132
132
|
if (lines.length < 2) {
|
|
133
133
|
return lines.map(x => x.clone());
|
|
134
134
|
}
|
|
135
|
-
const toProcess = lines.
|
|
135
|
+
const toProcess = lines.map((line, index) => ({ line: line.clone(), index }));
|
|
136
136
|
const result = [];
|
|
137
137
|
while (toProcess.length > 0) {
|
|
138
138
|
const current = toProcess.pop();
|
|
139
139
|
let joinedLine;
|
|
140
140
|
for (let i = 0; i < result.length; i++) {
|
|
141
141
|
const other = result[i];
|
|
142
|
-
joinedLine = current.joinLine(other, distanceTolerance, parallelTolerance);
|
|
142
|
+
joinedLine = current.line.joinLine(other.line, distanceTolerance, parallelTolerance);
|
|
143
143
|
if (joinedLine) {
|
|
144
144
|
result.splice(i, 1);
|
|
145
|
-
toProcess.push(joinedLine);
|
|
145
|
+
toProcess.push({ line: joinedLine, index: current.index });
|
|
146
146
|
break;
|
|
147
147
|
}
|
|
148
148
|
}
|
|
149
149
|
if (!joinedLine) {
|
|
150
|
-
result.push(current
|
|
150
|
+
result.push(current);
|
|
151
151
|
}
|
|
152
152
|
}
|
|
153
|
-
|
|
153
|
+
// Sort the result based on the original indices
|
|
154
|
+
result.sort((a, b) => a.index - b.index);
|
|
155
|
+
return result.map(item => item.line);
|
|
154
156
|
}
|
|
155
157
|
/**
|
|
156
158
|
* Returns true if this line section completely overlaps the @other line section.
|
package/package.json
CHANGED
package/src/Line3D.ts
CHANGED
|
@@ -167,8 +167,8 @@ export class Line3D extends Line3 {
|
|
|
167
167
|
return lines.map(x => x.clone());
|
|
168
168
|
}
|
|
169
169
|
|
|
170
|
-
const toProcess = lines.
|
|
171
|
-
const result: Line3D[] = [];
|
|
170
|
+
const toProcess = lines.map((line, index) => ({ line: line.clone(), index }));
|
|
171
|
+
const result: { line: Line3D, index: number }[] = [];
|
|
172
172
|
|
|
173
173
|
while (toProcess.length > 0) {
|
|
174
174
|
const current = toProcess.pop();
|
|
@@ -176,20 +176,23 @@ export class Line3D extends Line3 {
|
|
|
176
176
|
|
|
177
177
|
for (let i = 0; i < result.length; i++) {
|
|
178
178
|
const other = result[i];
|
|
179
|
-
joinedLine = current.joinLine(other, distanceTolerance, parallelTolerance);
|
|
179
|
+
joinedLine = current.line.joinLine(other.line, distanceTolerance, parallelTolerance);
|
|
180
180
|
if (joinedLine) {
|
|
181
181
|
result.splice(i, 1);
|
|
182
|
-
toProcess.push(joinedLine);
|
|
182
|
+
toProcess.push({ line: joinedLine, index: current.index });
|
|
183
183
|
break;
|
|
184
184
|
}
|
|
185
185
|
}
|
|
186
186
|
|
|
187
187
|
if (!joinedLine) {
|
|
188
|
-
result.push(current
|
|
188
|
+
result.push(current);
|
|
189
189
|
}
|
|
190
190
|
}
|
|
191
191
|
|
|
192
|
-
|
|
192
|
+
// Sort the result based on the original indices
|
|
193
|
+
result.sort((a, b) => a.index - b.index);
|
|
194
|
+
|
|
195
|
+
return result.map(item => item.line);
|
|
193
196
|
}
|
|
194
197
|
|
|
195
198
|
/**
|