@threepipe/plugin-svg-renderer 0.2.4 → 0.2.6
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 +10 -1
- package/dist/BasicSVGRendererPlugin.d.ts +1 -1
- package/dist/ThreeSVGRendererPlugin.d.ts +1 -1
- package/dist/dependencies.txt +15 -15
- package/dist/index.d.ts +5 -5
- package/dist/index.js +618 -665
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +741 -788
- package/dist/index.mjs.map +1 -1
- package/dist/three-mesh-halfedge/core/Face.d.ts +3 -3
- package/dist/three-mesh-halfedge/core/Halfedge.d.ts +3 -3
- package/dist/three-mesh-halfedge/core/HalfedgeDS.d.ts +4 -4
- package/dist/three-mesh-halfedge/core/Vertex.d.ts +3 -3
- package/dist/three-mesh-halfedge/index.d.ts +4 -4
- package/dist/three-mesh-halfedge/operations/addEdge.d.ts +3 -3
- package/dist/three-mesh-halfedge/operations/addFace.d.ts +3 -3
- package/dist/three-mesh-halfedge/operations/addVertex.d.ts +3 -3
- package/dist/three-mesh-halfedge/operations/cutFace.d.ts +4 -4
- package/dist/three-mesh-halfedge/operations/removeEdge.d.ts +2 -2
- package/dist/three-mesh-halfedge/operations/removeFace.d.ts +2 -2
- package/dist/three-mesh-halfedge/operations/removeVertex.d.ts +2 -2
- package/dist/three-mesh-halfedge/operations/setFromGeometry.d.ts +2 -2
- package/dist/three-mesh-halfedge/operations/splitEdge.d.ts +4 -4
- package/dist/three-mesh-halfedge/utils/geometry.d.ts +1 -1
- package/dist/three-svg-renderer/SVGRenderer.d.ts +3 -3
- package/dist/three-svg-renderer/core/SVGMesh.d.ts +5 -5
- package/dist/three-svg-renderer/core/index.d.ts +3 -3
- package/dist/three-svg-renderer/core/svg/SVGDrawHandler.d.ts +3 -3
- package/dist/three-svg-renderer/core/svg/index.d.ts +2 -2
- package/dist/three-svg-renderer/core/svg/passes/ChainPass.d.ts +3 -3
- package/dist/three-svg-renderer/core/svg/passes/DrawPass.d.ts +1 -1
- package/dist/three-svg-renderer/core/svg/passes/FillPass.d.ts +2 -2
- package/dist/three-svg-renderer/core/svg/passes/SingularityPointPass.d.ts +2 -2
- package/dist/three-svg-renderer/core/svg/passes/index.d.ts +4 -4
- package/dist/three-svg-renderer/core/svg/svgutils.d.ts +1 -1
- package/dist/three-svg-renderer/core/viewmap/Chain.d.ts +5 -5
- package/dist/three-svg-renderer/core/viewmap/Polygon.d.ts +2 -2
- package/dist/three-svg-renderer/core/viewmap/ViewEdge.d.ts +4 -4
- package/dist/three-svg-renderer/core/viewmap/ViewVertex.d.ts +3 -3
- package/dist/three-svg-renderer/core/viewmap/Viewmap.d.ts +10 -10
- package/dist/three-svg-renderer/core/viewmap/index.d.ts +5 -5
- package/dist/three-svg-renderer/core/viewmap/operations/assignPolygons.d.ts +2 -2
- package/dist/three-svg-renderer/core/viewmap/operations/computeChainsVisibility.d.ts +3 -3
- package/dist/three-svg-renderer/core/viewmap/operations/computeMeshIntersections.d.ts +2 -2
- package/dist/three-svg-renderer/core/viewmap/operations/computePolygons.d.ts +1 -5
- package/dist/three-svg-renderer/core/viewmap/operations/computePolygons.d.ts.map +1 -1
- package/dist/three-svg-renderer/core/viewmap/operations/createChains.d.ts +4 -4
- package/dist/three-svg-renderer/core/viewmap/operations/createViewVertex.d.ts +3 -3
- package/dist/three-svg-renderer/core/viewmap/operations/find2dSingularities.d.ts +1 -1
- package/dist/three-svg-renderer/core/viewmap/operations/find3dSingularities.d.ts +5 -5
- package/dist/three-svg-renderer/core/viewmap/operations/meshIntersectionCb.d.ts +3 -3
- package/dist/three-svg-renderer/core/viewmap/operations/setupEdges.d.ts +4 -4
- package/dist/three-svg-renderer/core/viewmap/operations/splitEdge.d.ts +4 -4
- package/dist/three-svg-renderer/index.d.ts +3 -3
- package/dist/three-svg-renderer/utils/buffergeometry.d.ts +2 -2
- package/dist/three-svg-renderer/utils/geometry.d.ts +1 -1
- package/dist/three-svg-renderer/utils/index.d.ts +3 -3
- package/dist/three-svg-renderer/utils/orientationtests.d.ts +1 -1
- package/docs/assets/hierarchy.js +1 -1
- package/docs/assets/icons.js +1 -1
- package/docs/assets/icons.svg +1 -1
- package/docs/assets/main.js +2 -2
- package/docs/assets/search.js +1 -1
- package/docs/assets/style.css +3 -3
- package/docs/classes/BasicSVGRenderer.html +2 -2
- package/docs/classes/BasicSVGRendererPlugin.html +5 -4
- package/docs/classes/DrawPass.html +6 -6
- package/docs/classes/FillPass.html +6 -6
- package/docs/classes/SVGDrawHandler.html +2 -2
- package/docs/classes/SVGDrawInfo.html +2 -2
- package/docs/classes/SVGMesh.html +3 -3
- package/docs/classes/SVGRenderInfo.html +2 -2
- package/docs/classes/SVGRenderer.html +10 -10
- package/docs/classes/ThreeSVGRendererPlugin.html +15 -14
- package/docs/classes/Viewmap.html +2 -2
- package/docs/classes/ViewmapBuildInfo.html +3 -3
- package/docs/hierarchy.html +1 -1
- package/docs/interfaces/FillPassOptions.html +5 -5
- package/docs/interfaces/SVGDrawOptions.html +2 -2
- package/docs/interfaces/SVGMeshOptions.html +2 -2
- package/docs/interfaces/SVGTexture.html +3 -3
- package/docs/interfaces/ViewmapOptions.html +2 -2
- package/package.json +14 -3
- package/src/three-svg-renderer/core/viewmap/operations/computePolygons.ts +2 -2
- package/tsconfig.json +46 -0
- package/docs/.nojekyll +0 -1
package/dist/index.mjs
CHANGED
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* @threepipe/plugin-svg-renderer v0.2.4
|
|
4
|
-
* Copyright 2022-2025 repalash <palash@shaders.app>
|
|
5
|
-
* GPLV3 License
|
|
6
|
-
* See ./dependencies.txt for any bundled third-party dependencies and licenses.
|
|
7
|
-
*/
|
|
8
1
|
import { Vector3, Vector4, Box3, Matrix4, Frustum, Vector2, Color as Color$1, Matrix3, DoubleSide, Box2, SRGBColorSpace, Camera, uiToggle, uiConfig, uiButton, uiFolderContainer, AViewerPluginSync, computeMorphedAttributes, Triangle, BufferAttribute, Plane, Line3 as Line3$1, Sphere, BackSide, FrontSide, Ray, Mesh, onChange, uiVector, timeout } from "threepipe";
|
|
9
2
|
import { Vector3 as Vector3$1, Matrix4 as Matrix4$1, Vector2 as Vector2$1, Color as Color$2, Raycaster, DoubleSide as DoubleSide$1, Line3, PerspectiveCamera, Box2 as Box2$1, Triangle as Triangle$1, Mesh as Mesh$1 } from "threepipe";
|
|
10
3
|
class RenderableObject {
|
|
@@ -96,13 +89,13 @@ class Projector {
|
|
|
96
89
|
positionScreen.z *= invW;
|
|
97
90
|
vertex.visible = positionScreen.x >= -1 && positionScreen.x <= 1 && positionScreen.y >= -1 && positionScreen.y <= 1 && positionScreen.z >= -1 && positionScreen.z <= 1;
|
|
98
91
|
}
|
|
99
|
-
function pushVertex(x2, y2,
|
|
92
|
+
function pushVertex(x2, y2, z2) {
|
|
100
93
|
_vertex = getNextVertexInPool();
|
|
101
|
-
_vertex.position.set(x2, y2,
|
|
94
|
+
_vertex.position.set(x2, y2, z2);
|
|
102
95
|
projectVertex(_vertex);
|
|
103
96
|
}
|
|
104
|
-
function pushNormal(x2, y2,
|
|
105
|
-
normals.push(x2, y2,
|
|
97
|
+
function pushNormal(x2, y2, z2) {
|
|
98
|
+
normals.push(x2, y2, z2);
|
|
106
99
|
}
|
|
107
100
|
function pushColor(r, g, b2) {
|
|
108
101
|
colors.push(r, g, b2);
|
|
@@ -110,29 +103,29 @@ class Projector {
|
|
|
110
103
|
function pushUv(x2, y2) {
|
|
111
104
|
uvs.push(x2, y2);
|
|
112
105
|
}
|
|
113
|
-
function checkTriangleVisibility(v1,
|
|
114
|
-
if (v1.visible === true ||
|
|
106
|
+
function checkTriangleVisibility(v1, v22, v3) {
|
|
107
|
+
if (v1.visible === true || v22.visible === true || v3.visible === true) return true;
|
|
115
108
|
_points3[0] = v1.positionScreen;
|
|
116
|
-
_points3[1] =
|
|
109
|
+
_points3[1] = v22.positionScreen;
|
|
117
110
|
_points3[2] = v3.positionScreen;
|
|
118
111
|
return _clipBox.intersectsBox(_boundingBox.setFromPoints(_points3));
|
|
119
112
|
}
|
|
120
|
-
function checkBackfaceCulling(v1,
|
|
121
|
-
return (v3.positionScreen.x - v1.positionScreen.x) * (
|
|
113
|
+
function checkBackfaceCulling(v1, v22, v3) {
|
|
114
|
+
return (v3.positionScreen.x - v1.positionScreen.x) * (v22.positionScreen.y - v1.positionScreen.y) - (v3.positionScreen.y - v1.positionScreen.y) * (v22.positionScreen.x - v1.positionScreen.x) < 0;
|
|
122
115
|
}
|
|
123
116
|
function pushLine(a, b2) {
|
|
124
117
|
const v1 = _vertexPool[a];
|
|
125
|
-
const
|
|
118
|
+
const v22 = _vertexPool[b2];
|
|
126
119
|
v1.positionScreen.copy(v1.position).applyMatrix4(_modelViewProjectionMatrix);
|
|
127
|
-
|
|
128
|
-
if (clipLine(v1.positionScreen,
|
|
120
|
+
v22.positionScreen.copy(v22.position).applyMatrix4(_modelViewProjectionMatrix);
|
|
121
|
+
if (clipLine(v1.positionScreen, v22.positionScreen) === true) {
|
|
129
122
|
v1.positionScreen.multiplyScalar(1 / v1.positionScreen.w);
|
|
130
|
-
|
|
123
|
+
v22.positionScreen.multiplyScalar(1 / v22.positionScreen.w);
|
|
131
124
|
_line2 = getNextLineInPool();
|
|
132
125
|
_line2.id = object.id;
|
|
133
126
|
_line2.v1.copy(v1);
|
|
134
|
-
_line2.v2.copy(
|
|
135
|
-
_line2.z = Math.max(v1.positionScreen.z,
|
|
127
|
+
_line2.v2.copy(v22);
|
|
128
|
+
_line2.z = Math.max(v1.positionScreen.z, v22.positionScreen.z);
|
|
136
129
|
_line2.renderOrder = object.renderOrder;
|
|
137
130
|
_line2.material = object.material;
|
|
138
131
|
if (object.material.vertexColors) {
|
|
@@ -142,21 +135,21 @@ class Projector {
|
|
|
142
135
|
_renderData.elements.push(_line2);
|
|
143
136
|
}
|
|
144
137
|
}
|
|
145
|
-
function pushTriangle(a, b2,
|
|
138
|
+
function pushTriangle(a, b2, c, material) {
|
|
146
139
|
const v1 = _vertexPool[a];
|
|
147
|
-
const
|
|
148
|
-
const v3 = _vertexPool[
|
|
149
|
-
if (checkTriangleVisibility(v1,
|
|
150
|
-
if (material.side === DoubleSide || checkBackfaceCulling(v1,
|
|
140
|
+
const v22 = _vertexPool[b2];
|
|
141
|
+
const v3 = _vertexPool[c];
|
|
142
|
+
if (checkTriangleVisibility(v1, v22, v3) === false) return;
|
|
143
|
+
if (material.side === DoubleSide || checkBackfaceCulling(v1, v22, v3) === true) {
|
|
151
144
|
_face = getNextFaceInPool();
|
|
152
145
|
_face.id = object.id;
|
|
153
146
|
_face.v1.copy(v1);
|
|
154
|
-
_face.v2.copy(
|
|
147
|
+
_face.v2.copy(v22);
|
|
155
148
|
_face.v3.copy(v3);
|
|
156
|
-
_face.z = (v1.positionScreen.z +
|
|
149
|
+
_face.z = (v1.positionScreen.z + v22.positionScreen.z + v3.positionScreen.z) / 3;
|
|
157
150
|
_face.renderOrder = object.renderOrder;
|
|
158
|
-
_vector3.subVectors(v3.position,
|
|
159
|
-
_vector4.subVectors(v1.position,
|
|
151
|
+
_vector3.subVectors(v3.position, v22.position);
|
|
152
|
+
_vector4.subVectors(v1.position, v22.position);
|
|
160
153
|
_vector3.cross(_vector4);
|
|
161
154
|
_face.normalModel.copy(_vector3);
|
|
162
155
|
_face.normalModel.applyMatrix3(normalMatrix).normalize();
|
|
@@ -203,7 +196,7 @@ class Projector {
|
|
|
203
196
|
addObject(object);
|
|
204
197
|
}
|
|
205
198
|
const children = object.children;
|
|
206
|
-
for (let i = 0,
|
|
199
|
+
for (let i = 0, l2 = children.length; i < l2; i++) {
|
|
207
200
|
projectObject(children[i]);
|
|
208
201
|
}
|
|
209
202
|
}
|
|
@@ -248,10 +241,10 @@ class Projector {
|
|
|
248
241
|
const groups = geometry.groups;
|
|
249
242
|
if (attributes.position === void 0) continue;
|
|
250
243
|
const positions = attributes.position.array;
|
|
251
|
-
for (let i = 0,
|
|
244
|
+
for (let i = 0, l2 = positions.length; i < l2; i += 3) {
|
|
252
245
|
let x2 = positions[i];
|
|
253
246
|
let y2 = positions[i + 1];
|
|
254
|
-
let
|
|
247
|
+
let z2 = positions[i + 2];
|
|
255
248
|
const morphTargets = geometry.morphAttributes.position;
|
|
256
249
|
if (morphTargets !== void 0) {
|
|
257
250
|
const morphTargetsRelative = geometry.morphTargetsRelative;
|
|
@@ -263,31 +256,31 @@ class Projector {
|
|
|
263
256
|
if (morphTargetsRelative) {
|
|
264
257
|
x2 += target.getX(i / 3) * influence;
|
|
265
258
|
y2 += target.getY(i / 3) * influence;
|
|
266
|
-
|
|
259
|
+
z2 += target.getZ(i / 3) * influence;
|
|
267
260
|
} else {
|
|
268
261
|
x2 += (target.getX(i / 3) - positions[i]) * influence;
|
|
269
262
|
y2 += (target.getY(i / 3) - positions[i + 1]) * influence;
|
|
270
|
-
|
|
263
|
+
z2 += (target.getZ(i / 3) - positions[i + 2]) * influence;
|
|
271
264
|
}
|
|
272
265
|
}
|
|
273
266
|
}
|
|
274
|
-
renderList.pushVertex(x2, y2,
|
|
267
|
+
renderList.pushVertex(x2, y2, z2);
|
|
275
268
|
}
|
|
276
269
|
if (attributes.normal !== void 0) {
|
|
277
270
|
const normals = attributes.normal.array;
|
|
278
|
-
for (let i = 0,
|
|
271
|
+
for (let i = 0, l2 = normals.length; i < l2; i += 3) {
|
|
279
272
|
renderList.pushNormal(normals[i], normals[i + 1], normals[i + 2]);
|
|
280
273
|
}
|
|
281
274
|
}
|
|
282
275
|
if (attributes.color !== void 0) {
|
|
283
276
|
const colors = attributes.color.array;
|
|
284
|
-
for (let i = 0,
|
|
277
|
+
for (let i = 0, l2 = colors.length; i < l2; i += 3) {
|
|
285
278
|
renderList.pushColor(colors[i], colors[i + 1], colors[i + 2]);
|
|
286
279
|
}
|
|
287
280
|
}
|
|
288
281
|
if (attributes.uv !== void 0) {
|
|
289
282
|
const uvs = attributes.uv.array;
|
|
290
|
-
for (let i = 0,
|
|
283
|
+
for (let i = 0, l2 = uvs.length; i < l2; i += 2) {
|
|
291
284
|
renderList.pushUv(uvs[i], uvs[i + 1]);
|
|
292
285
|
}
|
|
293
286
|
}
|
|
@@ -298,12 +291,12 @@ class Projector {
|
|
|
298
291
|
const group = groups[g];
|
|
299
292
|
material = isMultiMaterial === true ? object.material[group.materialIndex] : object.material;
|
|
300
293
|
if (material === void 0) continue;
|
|
301
|
-
for (let i = group.start,
|
|
294
|
+
for (let i = group.start, l2 = group.start + group.count; i < l2; i += 3) {
|
|
302
295
|
renderList.pushTriangle(indices[i], indices[i + 1], indices[i + 2], material);
|
|
303
296
|
}
|
|
304
297
|
}
|
|
305
298
|
} else {
|
|
306
|
-
for (let i = 0,
|
|
299
|
+
for (let i = 0, l2 = indices.length; i < l2; i += 3) {
|
|
307
300
|
renderList.pushTriangle(indices[i], indices[i + 1], indices[i + 2], material);
|
|
308
301
|
}
|
|
309
302
|
}
|
|
@@ -313,12 +306,12 @@ class Projector {
|
|
|
313
306
|
const group = groups[g];
|
|
314
307
|
material = isMultiMaterial === true ? object.material[group.materialIndex] : object.material;
|
|
315
308
|
if (material === void 0) continue;
|
|
316
|
-
for (let i = group.start,
|
|
309
|
+
for (let i = group.start, l2 = group.start + group.count; i < l2; i += 3) {
|
|
317
310
|
renderList.pushTriangle(i, i + 1, i + 2, material);
|
|
318
311
|
}
|
|
319
312
|
}
|
|
320
313
|
} else {
|
|
321
|
-
for (let i = 0,
|
|
314
|
+
for (let i = 0, l2 = positions.length / 3; i < l2; i += 3) {
|
|
322
315
|
renderList.pushTriangle(i, i + 1, i + 2, material);
|
|
323
316
|
}
|
|
324
317
|
}
|
|
@@ -328,23 +321,23 @@ class Projector {
|
|
|
328
321
|
const attributes = geometry.attributes;
|
|
329
322
|
if (attributes.position !== void 0) {
|
|
330
323
|
const positions = attributes.position.array;
|
|
331
|
-
for (let i = 0,
|
|
324
|
+
for (let i = 0, l2 = positions.length; i < l2; i += 3) {
|
|
332
325
|
renderList.pushVertex(positions[i], positions[i + 1], positions[i + 2]);
|
|
333
326
|
}
|
|
334
327
|
if (attributes.color !== void 0) {
|
|
335
328
|
const colors = attributes.color.array;
|
|
336
|
-
for (let i = 0,
|
|
329
|
+
for (let i = 0, l2 = colors.length; i < l2; i += 3) {
|
|
337
330
|
renderList.pushColor(colors[i], colors[i + 1], colors[i + 2]);
|
|
338
331
|
}
|
|
339
332
|
}
|
|
340
333
|
if (geometry.index !== null) {
|
|
341
334
|
const indices = geometry.index.array;
|
|
342
|
-
for (let i = 0,
|
|
335
|
+
for (let i = 0, l2 = indices.length; i < l2; i += 2) {
|
|
343
336
|
renderList.pushLine(indices[i], indices[i + 1]);
|
|
344
337
|
}
|
|
345
338
|
} else {
|
|
346
339
|
const step = object.isLineSegments ? 2 : 1;
|
|
347
|
-
for (let i = 0,
|
|
340
|
+
for (let i = 0, l2 = positions.length / 3 - 1; i < l2; i += step) {
|
|
348
341
|
renderList.pushLine(i, i + 1);
|
|
349
342
|
}
|
|
350
343
|
}
|
|
@@ -354,7 +347,7 @@ class Projector {
|
|
|
354
347
|
const attributes = geometry.attributes;
|
|
355
348
|
if (attributes.position !== void 0) {
|
|
356
349
|
const positions = attributes.position.array;
|
|
357
|
-
for (let i = 0,
|
|
350
|
+
for (let i = 0, l2 = positions.length; i < l2; i += 3) {
|
|
358
351
|
_vector4.set(positions[i], positions[i + 1], positions[i + 2], 1);
|
|
359
352
|
_vector4.applyMatrix4(_modelViewProjectionMatrix);
|
|
360
353
|
pushPoint(_vector4, object, camera);
|
|
@@ -537,8 +530,8 @@ let SVGRenderer$1 = class SVGRenderer {
|
|
|
537
530
|
_svg.removeChild(_svg.childNodes[0]);
|
|
538
531
|
}
|
|
539
532
|
}
|
|
540
|
-
function convert(
|
|
541
|
-
return _precision !== null ?
|
|
533
|
+
function convert(c) {
|
|
534
|
+
return _precision !== null ? c.toFixed(_precision) : c;
|
|
542
535
|
}
|
|
543
536
|
this.clear = function() {
|
|
544
537
|
removeChildNodes();
|
|
@@ -634,8 +627,8 @@ let SVGRenderer$1 = class SVGRenderer {
|
|
|
634
627
|
_ambientLight.setRGB(0, 0, 0);
|
|
635
628
|
_directionalLights.setRGB(0, 0, 0);
|
|
636
629
|
_pointLights.setRGB(0, 0, 0);
|
|
637
|
-
for (let
|
|
638
|
-
const light = lights[
|
|
630
|
+
for (let l2 = 0, ll = lights.length; l2 < ll; l2++) {
|
|
631
|
+
const light = lights[l2];
|
|
639
632
|
const lightColor = light.color;
|
|
640
633
|
if (light.isAmbientLight) {
|
|
641
634
|
_ambientLight.r += lightColor.r;
|
|
@@ -653,8 +646,8 @@ let SVGRenderer$1 = class SVGRenderer {
|
|
|
653
646
|
}
|
|
654
647
|
}
|
|
655
648
|
function calculateLight(lights, position2, normal, color) {
|
|
656
|
-
for (let
|
|
657
|
-
const light = lights[
|
|
649
|
+
for (let l2 = 0, ll = lights.length; l2 < ll; l2++) {
|
|
650
|
+
const light = lights[l2];
|
|
658
651
|
const lightColor = light.color;
|
|
659
652
|
if (light.isDirectionalLight) {
|
|
660
653
|
const lightPosition = _vector3.setFromMatrixPosition(light.matrixWorld).sub(_normal2.setFromMatrixPosition(light.target.matrixWorld)).normalize();
|
|
@@ -691,8 +684,8 @@ let SVGRenderer$1 = class SVGRenderer {
|
|
|
691
684
|
}
|
|
692
685
|
addPath(style, path);
|
|
693
686
|
}
|
|
694
|
-
function renderLine(v1,
|
|
695
|
-
const path = "M" + convert(v1.positionScreen.x) + "," + convert(v1.positionScreen.y) + "L" + convert(
|
|
687
|
+
function renderLine(v1, v22, material) {
|
|
688
|
+
const path = "M" + convert(v1.positionScreen.x) + "," + convert(v1.positionScreen.y) + "L" + convert(v22.positionScreen.x) + "," + convert(v22.positionScreen.y);
|
|
696
689
|
if (material.isLineBasicMaterial) {
|
|
697
690
|
let style = "fill:none;stroke:" + material.color.getStyle(_this.outputColorSpace) + ";stroke-opacity:" + material.opacity + ";stroke-width:" + material.linewidth + ";stroke-linecap:" + material.linecap;
|
|
698
691
|
if (material.isLineDashedMaterial) {
|
|
@@ -701,10 +694,10 @@ let SVGRenderer$1 = class SVGRenderer {
|
|
|
701
694
|
addPath(style, path);
|
|
702
695
|
}
|
|
703
696
|
}
|
|
704
|
-
function renderFace3(v1,
|
|
697
|
+
function renderFace3(v1, v22, v3, element, material) {
|
|
705
698
|
_this.info.render.vertices += 3;
|
|
706
699
|
_this.info.render.faces++;
|
|
707
|
-
const path = "M" + convert(v1.positionScreen.x) + "," + convert(v1.positionScreen.y) + "L" + convert(
|
|
700
|
+
const path = "M" + convert(v1.positionScreen.x) + "," + convert(v1.positionScreen.y) + "L" + convert(v22.positionScreen.x) + "," + convert(v22.positionScreen.y) + "L" + convert(v3.positionScreen.x) + "," + convert(v3.positionScreen.y) + "z";
|
|
708
701
|
let style = "";
|
|
709
702
|
if (material.isMeshBasicMaterial) {
|
|
710
703
|
_color2.copy(material.color);
|
|
@@ -717,7 +710,7 @@ let SVGRenderer$1 = class SVGRenderer {
|
|
|
717
710
|
_diffuseColor.multiply(element.color);
|
|
718
711
|
}
|
|
719
712
|
_color2.copy(_ambientLight);
|
|
720
|
-
_centroid.copy(v1.positionWorld).add(
|
|
713
|
+
_centroid.copy(v1.positionWorld).add(v22.positionWorld).add(v3.positionWorld).divideScalar(3);
|
|
721
714
|
calculateLight(_lights, _centroid, element.normalModel, _color2);
|
|
722
715
|
_color2.multiply(_diffuseColor).add(material.emissive);
|
|
723
716
|
} else if (material.isMeshNormalMaterial) {
|
|
@@ -731,15 +724,15 @@ let SVGRenderer$1 = class SVGRenderer {
|
|
|
731
724
|
}
|
|
732
725
|
addPath(style, path);
|
|
733
726
|
}
|
|
734
|
-
function expand(v1,
|
|
735
|
-
let x2 =
|
|
727
|
+
function expand(v1, v22, pixels) {
|
|
728
|
+
let x2 = v22.x - v1.x, y2 = v22.y - v1.y;
|
|
736
729
|
const det = x2 * x2 + y2 * y2;
|
|
737
730
|
if (det === 0) return;
|
|
738
731
|
const idet = pixels / Math.sqrt(det);
|
|
739
732
|
x2 *= idet;
|
|
740
733
|
y2 *= idet;
|
|
741
|
-
|
|
742
|
-
|
|
734
|
+
v22.x += x2;
|
|
735
|
+
v22.y += y2;
|
|
743
736
|
v1.x -= x2;
|
|
744
737
|
v1.y -= y2;
|
|
745
738
|
}
|
|
@@ -774,16 +767,6 @@ let SVGRenderer$1 = class SVGRenderer {
|
|
|
774
767
|
}
|
|
775
768
|
}
|
|
776
769
|
};
|
|
777
|
-
/**
|
|
778
|
-
* @license
|
|
779
|
-
* ts-browser-helpers v0.19.4
|
|
780
|
-
* Copyright 2022-2025 repalash <palash@shaders.app>
|
|
781
|
-
* MIT License
|
|
782
|
-
* See ./dependencies.txt for bundled third-party dependencies and licenses.
|
|
783
|
-
*/
|
|
784
|
-
function Fe(t, ...e) {
|
|
785
|
-
return t;
|
|
786
|
-
}
|
|
787
770
|
function L(t, e) {
|
|
788
771
|
return Object.hasOwn ? Object.hasOwn(t, e) : t.hasOwnProperty(e);
|
|
789
772
|
}
|
|
@@ -797,8 +780,8 @@ const k = class k2 {
|
|
|
797
780
|
let o = i;
|
|
798
781
|
for (; o; ) {
|
|
799
782
|
const s = Object.values(Object.getOwnPropertyDescriptors(o));
|
|
800
|
-
for (let
|
|
801
|
-
if (
|
|
783
|
+
for (let c of s)
|
|
784
|
+
if (c.value === e)
|
|
802
785
|
return r.set(e, true), e.call(i, ...n);
|
|
803
786
|
o = Object.getPrototypeOf(o);
|
|
804
787
|
}
|
|
@@ -817,12 +800,12 @@ function I(t, e = "param") {
|
|
|
817
800
|
return this[`_oc_${n}`];
|
|
818
801
|
},
|
|
819
802
|
set(s) {
|
|
820
|
-
var
|
|
821
|
-
const
|
|
822
|
-
if (
|
|
803
|
+
var l2;
|
|
804
|
+
const c = this[`_oc_${n}`];
|
|
805
|
+
if (c === s) return;
|
|
823
806
|
this[`_oc_${n}`] = s;
|
|
824
|
-
const
|
|
825
|
-
typeof t == "string" ? (
|
|
807
|
+
const a = e === "param" ? [n, s, c, this] : e === "object" ? [{ key: n, value: s, oldValue: c, target: this }] : [];
|
|
808
|
+
typeof t == "string" ? (l2 = this[t]) == null || l2.call(this, ...a) : typeof t == "function" && U$1.callFunction(t, this, a);
|
|
826
809
|
}
|
|
827
810
|
};
|
|
828
811
|
if (r)
|
|
@@ -834,40 +817,34 @@ function Ke(t, e = "void") {
|
|
|
834
817
|
if (!t) throw new Error("onChange: fnKey is undefined, make sure the function exists or provide a string");
|
|
835
818
|
return I(t, e);
|
|
836
819
|
}
|
|
837
|
-
function
|
|
820
|
+
function bt() {
|
|
838
821
|
const t = (n, r) => n.toString(16).padStart(r, "0"), e = crypto.getRandomValues(new Uint8Array(16));
|
|
839
822
|
e[6] = e[6] & 15 | 64, e[8] = e[8] & 63 | 128;
|
|
840
823
|
const i = new DataView(e.buffer);
|
|
841
824
|
return `${t(i.getUint32(0), 8)}-${t(i.getUint16(4), 4)}-${t(i.getUint16(6), 4)}-${t(i.getUint16(8), 4)}-${t(i.getUint32(10), 8)}${t(i.getUint16(14), 4)}`;
|
|
842
825
|
}
|
|
843
|
-
|
|
844
|
-
* @license
|
|
845
|
-
* uiconfig.js v0.3.1
|
|
846
|
-
* Copyright 2022-2025 repalash <palash@shaders.app>
|
|
847
|
-
* MIT License
|
|
848
|
-
* See ./dependencies.txt for bundled third-party dependencies and licenses.
|
|
849
|
-
*/
|
|
850
|
-
const C = class C2 {
|
|
826
|
+
const v = class v2 {
|
|
851
827
|
};
|
|
852
|
-
|
|
853
|
-
let
|
|
854
|
-
function
|
|
855
|
-
r = r
|
|
856
|
-
const o = r
|
|
857
|
-
let
|
|
828
|
+
v.Map = /* @__PURE__ */ new WeakMap();
|
|
829
|
+
let p = v;
|
|
830
|
+
function b(n, e, t, r, s = true) {
|
|
831
|
+
r = r !== void 0 ? r : n[e], t = t ?? e + "";
|
|
832
|
+
const o = r?.uiConfig;
|
|
833
|
+
let i;
|
|
858
834
|
if (o)
|
|
859
|
-
|
|
835
|
+
i = o;
|
|
860
836
|
else {
|
|
861
|
-
const
|
|
862
|
-
|
|
863
|
-
type:
|
|
837
|
+
const u = T(r);
|
|
838
|
+
u === "folder" ? i = E(t, r, {}, "folder", s, e + "") : u && (i = {
|
|
839
|
+
type: u,
|
|
864
840
|
label: t,
|
|
865
|
-
property: [n, e]
|
|
841
|
+
property: [n, e],
|
|
842
|
+
propertyKey: e + ""
|
|
866
843
|
});
|
|
867
844
|
}
|
|
868
|
-
return
|
|
845
|
+
return i && !i.label && (i.label = t), i;
|
|
869
846
|
}
|
|
870
|
-
function
|
|
847
|
+
function V(n) {
|
|
871
848
|
if (!n) return [];
|
|
872
849
|
let e = n.constructor || Object;
|
|
873
850
|
e === Array && (e = Object);
|
|
@@ -875,62 +852,62 @@ function _(n) {
|
|
|
875
852
|
for (; e && e !== Object; )
|
|
876
853
|
r.push(e), e = Object.getPrototypeOf(e);
|
|
877
854
|
if (!r.length || Array.isArray(n)) {
|
|
878
|
-
const
|
|
879
|
-
for (const o of
|
|
880
|
-
const
|
|
881
|
-
if (
|
|
882
|
-
const
|
|
883
|
-
|
|
884
|
-
}
|
|
885
|
-
}
|
|
886
|
-
return r.reverse().forEach((
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
property: [n, a],
|
|
855
|
+
const s = typeof n == "object" ? Object.keys(n) : Array.isArray(n) ? n.map((o, i) => i) : [];
|
|
856
|
+
for (const o of s) {
|
|
857
|
+
const i = n[o];
|
|
858
|
+
if (i == null) continue;
|
|
859
|
+
const u = b(n, o, o + "", i, true);
|
|
860
|
+
u && t.push(u);
|
|
861
|
+
}
|
|
862
|
+
}
|
|
863
|
+
return r.reverse().forEach((s) => {
|
|
864
|
+
p.Map.get(s)?.forEach(({ params: o, propKey: i, uiType: u }) => {
|
|
865
|
+
let a;
|
|
866
|
+
if (u || (a = () => b(n, i)), a || (a = {
|
|
867
|
+
property: [n, i],
|
|
892
868
|
type: u || "input"
|
|
893
869
|
// ...params,
|
|
894
870
|
// ...extraParams,
|
|
895
|
-
}),
|
|
896
|
-
const
|
|
897
|
-
if (delete
|
|
898
|
-
const
|
|
899
|
-
|
|
900
|
-
const
|
|
901
|
-
return
|
|
871
|
+
}), o) {
|
|
872
|
+
const d = typeof o.params == "function" ? o.params(n) : o.params || {}, c = { ...o };
|
|
873
|
+
if (delete c.params, typeof a == "function") {
|
|
874
|
+
const y2 = a;
|
|
875
|
+
a = () => {
|
|
876
|
+
const m = y2();
|
|
877
|
+
return m && Object.assign(m, { ...c, ...d });
|
|
902
878
|
};
|
|
903
879
|
} else
|
|
904
|
-
Object.assign(
|
|
880
|
+
Object.assign(a, { ...c, ...d });
|
|
905
881
|
}
|
|
906
|
-
t.push(
|
|
882
|
+
t.push(a);
|
|
907
883
|
});
|
|
908
884
|
}), t;
|
|
909
885
|
}
|
|
910
|
-
function
|
|
886
|
+
function E(n, e, t = {}, r = "folder", s = false, o) {
|
|
911
887
|
return {
|
|
912
888
|
type: r,
|
|
913
889
|
label: n,
|
|
914
|
-
children:
|
|
915
|
-
uuid:
|
|
890
|
+
children: s ? [() => V(e)] : V(e),
|
|
891
|
+
uuid: bt(),
|
|
892
|
+
propertyKey: o,
|
|
916
893
|
...t
|
|
917
894
|
};
|
|
918
895
|
}
|
|
919
896
|
function T(n) {
|
|
920
897
|
return n == null ? null : Array.isArray(n) ? "folder" : typeof n == "boolean" ? "checkbox" : typeof n == "number" ? "number" : typeof n == "string" ? "input" : typeof n == "function" ? "button" : typeof n.x == "number" ? "vec" : typeof n.r == "number" ? "color" : n.isTexture ? "image" : typeof n == "object" ? "folder" : null;
|
|
921
898
|
}
|
|
922
|
-
function
|
|
899
|
+
function Q(n) {
|
|
923
900
|
return (e, t) => {
|
|
924
901
|
const r = e.constructor;
|
|
925
902
|
if (r === Object) throw new Error("Not possible to use uiConfig decorator on an object, use class instead");
|
|
926
|
-
|
|
903
|
+
p.Map.has(r) || p.Map.set(r, []), n(e, t, p.Map.get(r));
|
|
927
904
|
};
|
|
928
905
|
}
|
|
929
|
-
function
|
|
930
|
-
return
|
|
931
|
-
const o =
|
|
906
|
+
function l(n, e) {
|
|
907
|
+
return Q((t, r, s) => {
|
|
908
|
+
const o = s.findIndex((i) => i.propKey === r);
|
|
932
909
|
if (o && o < 0)
|
|
933
|
-
|
|
910
|
+
s.push({
|
|
934
911
|
params: e || {},
|
|
935
912
|
propKey: r,
|
|
936
913
|
uiType: n
|
|
@@ -939,24 +916,24 @@ function h(n, e) {
|
|
|
939
916
|
throw new Error(`Property ${r} already has a uiConfig decorator`);
|
|
940
917
|
});
|
|
941
918
|
}
|
|
942
|
-
function
|
|
919
|
+
function U(n, e, t = "panel") {
|
|
943
920
|
return (r) => class extends r {
|
|
944
921
|
constructor() {
|
|
945
|
-
super(...arguments), this.uiConfig =
|
|
922
|
+
super(...arguments), this.uiConfig = E(n, this, {}, t);
|
|
946
923
|
}
|
|
947
924
|
};
|
|
948
925
|
}
|
|
949
|
-
function
|
|
950
|
-
return Array.isArray(e) && typeof e[0] == "string" && (e = e.map((r) => ({ label: r, value: r }))),
|
|
926
|
+
function W(n, e, t) {
|
|
927
|
+
return Array.isArray(e) && typeof e[0] == "string" && (e = e.map((r) => ({ label: r, value: r }))), l("dropdown", { label: n, children: e, params: t });
|
|
951
928
|
}
|
|
952
|
-
function
|
|
953
|
-
return
|
|
929
|
+
function z(n, e) {
|
|
930
|
+
return l("number", { label: n, params: e });
|
|
954
931
|
}
|
|
955
|
-
function
|
|
956
|
-
return
|
|
932
|
+
function K(n, e) {
|
|
933
|
+
return l("checkbox", { label: n, params: e });
|
|
957
934
|
}
|
|
958
935
|
function X(n, e) {
|
|
959
|
-
return
|
|
936
|
+
return U(n, e, "folder");
|
|
960
937
|
}
|
|
961
938
|
var __defProp$2 = Object.defineProperty;
|
|
962
939
|
var __getOwnPropDesc$2 = Object.getOwnPropertyDescriptor;
|
|
@@ -978,19 +955,19 @@ let BasicSVGRenderer = class extends SVGRenderer$1 {
|
|
|
978
955
|
}
|
|
979
956
|
};
|
|
980
957
|
__decorateClass$2([
|
|
981
|
-
|
|
958
|
+
K()
|
|
982
959
|
], BasicSVGRenderer.prototype, "autoClear", 2);
|
|
983
960
|
__decorateClass$2([
|
|
984
|
-
|
|
961
|
+
K()
|
|
985
962
|
], BasicSVGRenderer.prototype, "sortObjects", 2);
|
|
986
963
|
__decorateClass$2([
|
|
987
|
-
|
|
964
|
+
K()
|
|
988
965
|
], BasicSVGRenderer.prototype, "sortElements", 2);
|
|
989
966
|
__decorateClass$2([
|
|
990
|
-
|
|
967
|
+
z()
|
|
991
968
|
], BasicSVGRenderer.prototype, "overdraw", 2);
|
|
992
969
|
__decorateClass$2([
|
|
993
|
-
|
|
970
|
+
W(void 0, ["low", "high"]),
|
|
994
971
|
Ke(BasicSVGRenderer.prototype._refresh)
|
|
995
972
|
], BasicSVGRenderer.prototype, "quality", 2);
|
|
996
973
|
BasicSVGRenderer = __decorateClass$2([
|
|
@@ -1019,7 +996,7 @@ let BasicSVGRendererPlugin = class extends AViewerPluginSync {
|
|
|
1019
996
|
this._lastStyles = void 0;
|
|
1020
997
|
this.autoRender = true;
|
|
1021
998
|
this._viewerListeners = {
|
|
1022
|
-
postRender: (
|
|
999
|
+
postRender: (_) => {
|
|
1023
1000
|
if (this.autoRender) this.render();
|
|
1024
1001
|
}
|
|
1025
1002
|
};
|
|
@@ -1029,7 +1006,6 @@ let BasicSVGRendererPlugin = class extends AViewerPluginSync {
|
|
|
1029
1006
|
this.renderer.domElement.style.display = "none";
|
|
1030
1007
|
}
|
|
1031
1008
|
onAdded(viewer) {
|
|
1032
|
-
var _a;
|
|
1033
1009
|
super.onAdded(viewer);
|
|
1034
1010
|
this.renderer.setSize(viewer.canvas.clientWidth, viewer.canvas.clientHeight);
|
|
1035
1011
|
this._refreshParams();
|
|
@@ -1045,7 +1021,7 @@ let BasicSVGRendererPlugin = class extends AViewerPluginSync {
|
|
|
1045
1021
|
element.style.width = canvasStyles.width;
|
|
1046
1022
|
element.style.height = canvasStyles.height;
|
|
1047
1023
|
} else {
|
|
1048
|
-
|
|
1024
|
+
this._viewer?.console.warn("BasicSVGRendererPlugin: canvas position should be absolute for proper rendering");
|
|
1049
1025
|
}
|
|
1050
1026
|
viewer.renderManager.addEventListener("resize", this._onResize);
|
|
1051
1027
|
}
|
|
@@ -1069,10 +1045,9 @@ let BasicSVGRendererPlugin = class extends AViewerPluginSync {
|
|
|
1069
1045
|
this.renderer.render(this._viewer.scene, this._viewer.scene.mainCamera);
|
|
1070
1046
|
}
|
|
1071
1047
|
download() {
|
|
1072
|
-
var _a;
|
|
1073
1048
|
const svg2 = this.renderer.domElement.outerHTML;
|
|
1074
1049
|
const blob = new Blob([svg2], { type: "image/svg+xml" });
|
|
1075
|
-
|
|
1050
|
+
this._viewer?.exportBlob(blob, "scene.svg");
|
|
1076
1051
|
}
|
|
1077
1052
|
get svgNode() {
|
|
1078
1053
|
return this.renderer.domElement;
|
|
@@ -1142,7 +1117,7 @@ class ViewEdge {
|
|
|
1142
1117
|
}
|
|
1143
1118
|
toJSON() {
|
|
1144
1119
|
return {
|
|
1145
|
-
id: [...this.a.vertices].map((
|
|
1120
|
+
id: [...this.a.vertices].map((v3) => v3.id).join(",") + "-" + [...this.b.vertices].map((v3) => v3.id).join(",")
|
|
1146
1121
|
};
|
|
1147
1122
|
}
|
|
1148
1123
|
clone() {
|
|
@@ -1268,7 +1243,7 @@ function vectors2Equal(a, b2, tolerance = 1e-10) {
|
|
|
1268
1243
|
return Math.abs(a.x - b2.x) < tolerance && Math.abs(a.y - b2.y) < tolerance;
|
|
1269
1244
|
}
|
|
1270
1245
|
const _matrix$3 = new Matrix4$1();
|
|
1271
|
-
function orient3D$2(a, b2,
|
|
1246
|
+
function orient3D$2(a, b2, c, d, epsilon = 1e-10) {
|
|
1272
1247
|
_matrix$3.set(
|
|
1273
1248
|
a.x,
|
|
1274
1249
|
a.y,
|
|
@@ -1278,9 +1253,9 @@ function orient3D$2(a, b2, c2, d, epsilon = 1e-10) {
|
|
|
1278
1253
|
b2.y,
|
|
1279
1254
|
b2.z,
|
|
1280
1255
|
1,
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1256
|
+
c.x,
|
|
1257
|
+
c.y,
|
|
1258
|
+
c.z,
|
|
1284
1259
|
1,
|
|
1285
1260
|
d.x,
|
|
1286
1261
|
d.y,
|
|
@@ -1295,11 +1270,11 @@ function orient3D$2(a, b2, c2, d, epsilon = 1e-10) {
|
|
|
1295
1270
|
}
|
|
1296
1271
|
return 0;
|
|
1297
1272
|
}
|
|
1298
|
-
function frontSide$1(a, b2,
|
|
1299
|
-
return orient3D$2(d, b2,
|
|
1273
|
+
function frontSide$1(a, b2, c, d, epsilon = 1e-10) {
|
|
1274
|
+
return orient3D$2(d, b2, c, a, epsilon) > 0;
|
|
1300
1275
|
}
|
|
1301
|
-
function sameSide(a, b2,
|
|
1302
|
-
return orient3D$2(a, b2,
|
|
1276
|
+
function sameSide(a, b2, c, d, e, epsilon = 1e-10) {
|
|
1277
|
+
return orient3D$2(a, b2, c, d, epsilon) > 0 === orient3D$2(a, b2, c, e, epsilon) > 0;
|
|
1303
1278
|
}
|
|
1304
1279
|
function round(num, divider = 100) {
|
|
1305
1280
|
return Math.round(num * divider) / divider;
|
|
@@ -1411,7 +1386,7 @@ let Polygon$1 = class Polygon {
|
|
|
1411
1386
|
};
|
|
1412
1387
|
var Arrangement2D = (() => {
|
|
1413
1388
|
var _scriptDir = import.meta.url;
|
|
1414
|
-
return function(Arrangement2D2) {
|
|
1389
|
+
return (function(Arrangement2D2) {
|
|
1415
1390
|
Arrangement2D2 = Arrangement2D2 || {};
|
|
1416
1391
|
var Module = typeof Arrangement2D2 != "undefined" ? Arrangement2D2 : {};
|
|
1417
1392
|
var readyPromiseResolve, readyPromiseReject;
|
|
@@ -2419,8 +2394,8 @@ var Arrangement2D = (() => {
|
|
|
2419
2394
|
function createWasm() {
|
|
2420
2395
|
var info = { "env": asmLibraryArg, "wasi_snapshot_preview1": asmLibraryArg };
|
|
2421
2396
|
function receiveInstance(instance, module) {
|
|
2422
|
-
var
|
|
2423
|
-
Module["asm"] =
|
|
2397
|
+
var exports$12 = instance.exports;
|
|
2398
|
+
Module["asm"] = exports$12;
|
|
2424
2399
|
wasmMemory = Module["asm"]["memory"];
|
|
2425
2400
|
assert(wasmMemory, "memory not found in wasm exports");
|
|
2426
2401
|
updateGlobalBufferAndViews(wasmMemory.buffer);
|
|
@@ -2465,8 +2440,8 @@ var Arrangement2D = (() => {
|
|
|
2465
2440
|
}
|
|
2466
2441
|
if (Module["instantiateWasm"]) {
|
|
2467
2442
|
try {
|
|
2468
|
-
var exports = Module["instantiateWasm"](info, receiveInstance);
|
|
2469
|
-
return exports;
|
|
2443
|
+
var exports$1 = Module["instantiateWasm"](info, receiveInstance);
|
|
2444
|
+
return exports$1;
|
|
2470
2445
|
} catch (e) {
|
|
2471
2446
|
err("Module.instantiateWasm callback failed with error: " + e);
|
|
2472
2447
|
return false;
|
|
@@ -2963,7 +2938,7 @@ var Arrangement2D = (() => {
|
|
|
2963
2938
|
bytes[i] = decoded.charCodeAt(i);
|
|
2964
2939
|
}
|
|
2965
2940
|
return bytes;
|
|
2966
|
-
} catch (
|
|
2941
|
+
} catch (_) {
|
|
2967
2942
|
throw new Error("Converting base64 string to bytes failed.");
|
|
2968
2943
|
}
|
|
2969
2944
|
}
|
|
@@ -3644,7 +3619,7 @@ var Arrangement2D = (() => {
|
|
|
3644
3619
|
_emscripten_bind_ContourList___destroy___0(self2);
|
|
3645
3620
|
};
|
|
3646
3621
|
return Arrangement2D2.ready;
|
|
3647
|
-
};
|
|
3622
|
+
});
|
|
3648
3623
|
})();
|
|
3649
3624
|
const Arr2DPromise = Arrangement2D();
|
|
3650
3625
|
class PolygonsInfo {
|
|
@@ -3656,7 +3631,7 @@ class PolygonsInfo {
|
|
|
3656
3631
|
async function computePolygons(viewmap, info = new PolygonsInfo()) {
|
|
3657
3632
|
const { chains, polygons } = viewmap;
|
|
3658
3633
|
const Arr2D = await Arr2DPromise;
|
|
3659
|
-
const visibleChains = chains.filter((
|
|
3634
|
+
const visibleChains = chains.filter((c) => c.visibility === ChainVisibility.Visible);
|
|
3660
3635
|
const points = new Arr2D.PointList();
|
|
3661
3636
|
let a, b2;
|
|
3662
3637
|
for (const chain of visibleChains) {
|
|
@@ -3670,7 +3645,7 @@ async function computePolygons(viewmap, info = new PolygonsInfo()) {
|
|
|
3670
3645
|
}
|
|
3671
3646
|
const builder = new Arr2D.ArrangementBuilder();
|
|
3672
3647
|
const arr2DPolygonlist = builder.getPolygons(points);
|
|
3673
|
-
const
|
|
3648
|
+
const p2 = new Arr2D.Point();
|
|
3674
3649
|
info.smallAreaIgnored = 0;
|
|
3675
3650
|
info.insidePointErrors = 0;
|
|
3676
3651
|
for (let i = 0; i < arr2DPolygonlist.size(); i++) {
|
|
@@ -3680,8 +3655,8 @@ async function computePolygons(viewmap, info = new PolygonsInfo()) {
|
|
|
3680
3655
|
const contour = convertContour(arr2DPolygon.contour);
|
|
3681
3656
|
const holes = convertContourList(arr2DPolygon.holes);
|
|
3682
3657
|
const polygon = new Polygon$1(i, contour, holes);
|
|
3683
|
-
if (arr2DPolygon.getInsidePoint(
|
|
3684
|
-
polygon.insidePoint.set(
|
|
3658
|
+
if (arr2DPolygon.getInsidePoint(p2)) {
|
|
3659
|
+
polygon.insidePoint.set(p2.x, p2.y);
|
|
3685
3660
|
polygons.push(polygon);
|
|
3686
3661
|
} else {
|
|
3687
3662
|
info.insidePointErrors += 1;
|
|
@@ -3692,7 +3667,7 @@ async function computePolygons(viewmap, info = new PolygonsInfo()) {
|
|
|
3692
3667
|
Arr2D.destroy(arr2DPolygon);
|
|
3693
3668
|
}
|
|
3694
3669
|
Arr2D.destroy(arr2DPolygonlist);
|
|
3695
|
-
Arr2D.destroy(
|
|
3670
|
+
Arr2D.destroy(p2);
|
|
3696
3671
|
}
|
|
3697
3672
|
function convertContourList(vector) {
|
|
3698
3673
|
const array2 = new Array();
|
|
@@ -3704,8 +3679,8 @@ function convertContourList(vector) {
|
|
|
3704
3679
|
function convertContour(contour) {
|
|
3705
3680
|
const array2 = new Array();
|
|
3706
3681
|
for (let i = 0; i < contour.size(); i++) {
|
|
3707
|
-
const
|
|
3708
|
-
array2.push(new Vector2$1(
|
|
3682
|
+
const p2 = contour.at(i);
|
|
3683
|
+
array2.push(new Vector2$1(p2.x, p2.y));
|
|
3709
3684
|
}
|
|
3710
3685
|
return array2;
|
|
3711
3686
|
}
|
|
@@ -3740,18 +3715,18 @@ function setupEdges(viewmap, options) {
|
|
|
3740
3715
|
const meshv1 = halfedge.vertex;
|
|
3741
3716
|
const meshv2 = halfedge.twin.vertex;
|
|
3742
3717
|
const v1 = createViewVertex(viewmap, meshv1.position);
|
|
3743
|
-
const
|
|
3718
|
+
const v22 = createViewVertex(viewmap, meshv2.position);
|
|
3744
3719
|
meshv1.viewVertex = v1;
|
|
3745
|
-
meshv2.viewVertex =
|
|
3720
|
+
meshv2.viewVertex = v22;
|
|
3746
3721
|
v1.vertices.add(meshv1);
|
|
3747
|
-
|
|
3748
|
-
const viewEdge = new ViewEdge(v1,
|
|
3722
|
+
v22.vertices.add(meshv2);
|
|
3723
|
+
const viewEdge = new ViewEdge(v1, v22, props.nature, halfedge);
|
|
3749
3724
|
viewEdge.faceAngle = props.faceAngle;
|
|
3750
3725
|
viewEdge.isConcave = props.isConcave;
|
|
3751
3726
|
viewEdge.isBack = props.isBack;
|
|
3752
3727
|
viewEdge.meshes.push(mesh);
|
|
3753
3728
|
v1.viewEdges.push(viewEdge);
|
|
3754
|
-
|
|
3729
|
+
v22.viewEdges.push(viewEdge);
|
|
3755
3730
|
if (halfedge.face) {
|
|
3756
3731
|
halfedge.face.viewEdges.push(viewEdge);
|
|
3757
3732
|
viewEdge.faces.push(halfedge.face);
|
|
@@ -3924,8 +3899,8 @@ function isTriDegenerated(tri) {
|
|
|
3924
3899
|
_tmp1.cross(_tmp2);
|
|
3925
3900
|
return _tmp1.x > -EPSILON$1 && _tmp1.x < EPSILON$1 && _tmp1.y > -EPSILON$1 && _tmp1.y < EPSILON$1 && _tmp1.z > -EPSILON$1 && _tmp1.z < EPSILON$1;
|
|
3926
3901
|
}
|
|
3927
|
-
function orient3D$1(a, b2,
|
|
3928
|
-
_matrix4.set(a.x, a.y, a.z, 1, b2.x, b2.y, b2.z, 1,
|
|
3902
|
+
function orient3D$1(a, b2, c, d) {
|
|
3903
|
+
_matrix4.set(a.x, a.y, a.z, 1, b2.x, b2.y, b2.z, 1, c.x, c.y, c.z, 1, d.x, d.y, d.z, 1);
|
|
3929
3904
|
const det = _matrix4.determinant();
|
|
3930
3905
|
if (det < -EPSILON$1)
|
|
3931
3906
|
return -1;
|
|
@@ -3934,8 +3909,8 @@ function orient3D$1(a, b2, c2, d) {
|
|
|
3934
3909
|
else
|
|
3935
3910
|
return 0;
|
|
3936
3911
|
}
|
|
3937
|
-
function orient2D(a, b2,
|
|
3938
|
-
_matrix3.set(a.x, a.y, 1, b2.x, b2.y, 1,
|
|
3912
|
+
function orient2D(a, b2, c) {
|
|
3913
|
+
_matrix3.set(a.x, a.y, 1, b2.x, b2.y, 1, c.x, c.y, 1);
|
|
3939
3914
|
const det = _matrix3.determinant();
|
|
3940
3915
|
if (det < -EPSILON$1)
|
|
3941
3916
|
return -1;
|
|
@@ -4022,9 +3997,9 @@ function makeTriAVertexPositive(tri, other) {
|
|
|
4022
3997
|
other.b = tmp;
|
|
4023
3998
|
}
|
|
4024
3999
|
}
|
|
4025
|
-
function intersectPlane(a, b2,
|
|
4000
|
+
function intersectPlane(a, b2, p2, n, target) {
|
|
4026
4001
|
_u$1$1.subVectors(b2, a);
|
|
4027
|
-
_v$1$1.subVectors(a,
|
|
4002
|
+
_v$1$1.subVectors(a, p2);
|
|
4028
4003
|
const dot1 = n.dot(_u$1$1);
|
|
4029
4004
|
const dot2 = n.dot(_v$1$1);
|
|
4030
4005
|
_u$1$1.multiplyScalar(-dot2 / dot1);
|
|
@@ -4125,8 +4100,8 @@ function coplanarIntersect(t1, t2, target) {
|
|
|
4125
4100
|
if (intersecting && target) {
|
|
4126
4101
|
clipTriangle(t1, t2, target);
|
|
4127
4102
|
_matrix$2.invert();
|
|
4128
|
-
for (const
|
|
4129
|
-
|
|
4103
|
+
for (const p3 of target) {
|
|
4104
|
+
p3.applyMatrix4(_matrix$2);
|
|
4130
4105
|
}
|
|
4131
4106
|
}
|
|
4132
4107
|
return intersecting;
|
|
@@ -4347,8 +4322,8 @@ function splitViewEdge3d(viewmap, edge, position2) {
|
|
|
4347
4322
|
_u$2.subVectors(position2, edge.a.pos3d);
|
|
4348
4323
|
_v$1.subVectors(edge.b.pos3d, edge.a.pos3d);
|
|
4349
4324
|
const cross = _u$2.cross(_v$1);
|
|
4350
|
-
const
|
|
4351
|
-
if (
|
|
4325
|
+
const v3 = cross.x + cross.y + cross.z;
|
|
4326
|
+
if (v3 > 1e-10 || v3 < -1e-10) {
|
|
4352
4327
|
return null;
|
|
4353
4328
|
}
|
|
4354
4329
|
if (_u$2.dot(_v$1) < -1e-10) {
|
|
@@ -4441,8 +4416,8 @@ function computeMeshIntersections(viewmap, info = new MeshIntersectionInfo()) {
|
|
|
4441
4416
|
return;
|
|
4442
4417
|
}
|
|
4443
4418
|
const v1 = createViewVertex(viewmap, line.start);
|
|
4444
|
-
const
|
|
4445
|
-
const intersectionViewVertices = [v1,
|
|
4419
|
+
const v22 = createViewVertex(viewmap, line.end);
|
|
4420
|
+
const intersectionViewVertices = [v1, v22];
|
|
4446
4421
|
const faceViewEdges = /* @__PURE__ */ new Set([...faceA.viewEdges, ...faceB.viewEdges]);
|
|
4447
4422
|
for (const e of faceViewEdges) {
|
|
4448
4423
|
_line$1.set(e.a.pos3d, e.b.pos3d);
|
|
@@ -4464,12 +4439,12 @@ function computeMeshIntersections(viewmap, info = new MeshIntersectionInfo()) {
|
|
|
4464
4439
|
});
|
|
4465
4440
|
for (let i = 0; i < intersectionViewVertices.length - 1; i++) {
|
|
4466
4441
|
const v12 = intersectionViewVertices[i];
|
|
4467
|
-
const
|
|
4468
|
-
const viewEdge = new ViewEdge(v12,
|
|
4442
|
+
const v222 = intersectionViewVertices[i + 1];
|
|
4443
|
+
const viewEdge = new ViewEdge(v12, v222, ViewEdgeNature.MeshIntersection);
|
|
4469
4444
|
viewEdge.meshes.push(meshA, meshB);
|
|
4470
4445
|
viewEdge.faces.push(faceA, faceB);
|
|
4471
4446
|
v12.viewEdges.push(viewEdge);
|
|
4472
|
-
|
|
4447
|
+
v222.viewEdges.push(viewEdge);
|
|
4473
4448
|
faceA.viewEdges.push(viewEdge);
|
|
4474
4449
|
faceB.viewEdges.push(viewEdge);
|
|
4475
4450
|
viewmap.viewEdges.push(viewEdge);
|
|
@@ -4542,9 +4517,9 @@ function splay(i, t, comparator) {
|
|
|
4542
4517
|
if (t === null) {
|
|
4543
4518
|
return t;
|
|
4544
4519
|
}
|
|
4545
|
-
var
|
|
4546
|
-
var
|
|
4547
|
-
|
|
4520
|
+
var l2, r, y2;
|
|
4521
|
+
var N = new Node();
|
|
4522
|
+
l2 = r = N;
|
|
4548
4523
|
while (true) {
|
|
4549
4524
|
var cmp = comparator(i, t.key);
|
|
4550
4525
|
if (cmp < 0) {
|
|
@@ -4576,17 +4551,17 @@ function splay(i, t, comparator) {
|
|
|
4576
4551
|
break;
|
|
4577
4552
|
}
|
|
4578
4553
|
}
|
|
4579
|
-
|
|
4580
|
-
|
|
4554
|
+
l2.right = t;
|
|
4555
|
+
l2 = t;
|
|
4581
4556
|
t = t.right;
|
|
4582
4557
|
} else {
|
|
4583
4558
|
break;
|
|
4584
4559
|
}
|
|
4585
4560
|
}
|
|
4586
|
-
|
|
4561
|
+
l2.right = t.left;
|
|
4587
4562
|
r.left = t.right;
|
|
4588
|
-
t.left =
|
|
4589
|
-
t.right =
|
|
4563
|
+
t.left = N.right;
|
|
4564
|
+
t.right = N.left;
|
|
4590
4565
|
return t;
|
|
4591
4566
|
}
|
|
4592
4567
|
function insert(i, data2, t, comparator, tree) {
|
|
@@ -4653,24 +4628,24 @@ function remove(i, t, comparator, tree) {
|
|
|
4653
4628
|
}
|
|
4654
4629
|
return t;
|
|
4655
4630
|
}
|
|
4656
|
-
function split(key,
|
|
4631
|
+
function split(key, v3, comparator) {
|
|
4657
4632
|
var left, right;
|
|
4658
|
-
if (
|
|
4633
|
+
if (v3 === null) {
|
|
4659
4634
|
left = right = null;
|
|
4660
4635
|
} else {
|
|
4661
|
-
|
|
4662
|
-
var cmp = comparator(
|
|
4636
|
+
v3 = splay(key, v3, comparator);
|
|
4637
|
+
var cmp = comparator(v3.key, key);
|
|
4663
4638
|
if (cmp === 0) {
|
|
4664
|
-
left =
|
|
4665
|
-
right =
|
|
4639
|
+
left = v3.left;
|
|
4640
|
+
right = v3.right;
|
|
4666
4641
|
} else if (cmp < 0) {
|
|
4667
|
-
right =
|
|
4668
|
-
|
|
4669
|
-
left =
|
|
4642
|
+
right = v3.right;
|
|
4643
|
+
v3.right = null;
|
|
4644
|
+
left = v3;
|
|
4670
4645
|
} else {
|
|
4671
|
-
left =
|
|
4672
|
-
|
|
4673
|
-
right =
|
|
4646
|
+
left = v3.left;
|
|
4647
|
+
v3.left = null;
|
|
4648
|
+
right = v3;
|
|
4674
4649
|
}
|
|
4675
4650
|
}
|
|
4676
4651
|
return { left, right };
|
|
@@ -4767,15 +4742,15 @@ Tree.prototype.contains = function contains(key) {
|
|
|
4767
4742
|
};
|
|
4768
4743
|
Tree.prototype.forEach = function forEach(visitor, ctx) {
|
|
4769
4744
|
var current = this._root;
|
|
4770
|
-
var
|
|
4745
|
+
var Q2 = [];
|
|
4771
4746
|
var done = false;
|
|
4772
4747
|
while (!done) {
|
|
4773
4748
|
if (current !== null) {
|
|
4774
|
-
|
|
4749
|
+
Q2.push(current);
|
|
4775
4750
|
current = current.left;
|
|
4776
4751
|
} else {
|
|
4777
|
-
if (
|
|
4778
|
-
current =
|
|
4752
|
+
if (Q2.length !== 0) {
|
|
4753
|
+
current = Q2.pop();
|
|
4779
4754
|
visitor.call(ctx, current);
|
|
4780
4755
|
current = current.right;
|
|
4781
4756
|
} else {
|
|
@@ -4787,15 +4762,15 @@ Tree.prototype.forEach = function forEach(visitor, ctx) {
|
|
|
4787
4762
|
};
|
|
4788
4763
|
Tree.prototype.range = function range(low, high, fn, ctx) {
|
|
4789
4764
|
var this$1$1 = this;
|
|
4790
|
-
var
|
|
4765
|
+
var Q2 = [];
|
|
4791
4766
|
var compare = this._comparator;
|
|
4792
4767
|
var node = this._root, cmp;
|
|
4793
|
-
while (
|
|
4768
|
+
while (Q2.length !== 0 || node) {
|
|
4794
4769
|
if (node) {
|
|
4795
|
-
|
|
4770
|
+
Q2.push(node);
|
|
4796
4771
|
node = node.left;
|
|
4797
4772
|
} else {
|
|
4798
|
-
node =
|
|
4773
|
+
node = Q2.pop();
|
|
4799
4774
|
cmp = compare(node.key, high);
|
|
4800
4775
|
if (cmp > 0) {
|
|
4801
4776
|
break;
|
|
@@ -4857,14 +4832,14 @@ Tree.prototype.maxNode = function maxNode(t) {
|
|
|
4857
4832
|
};
|
|
4858
4833
|
Tree.prototype.at = function at(index) {
|
|
4859
4834
|
var current = this._root, done = false, i = 0;
|
|
4860
|
-
var
|
|
4835
|
+
var Q2 = [];
|
|
4861
4836
|
while (!done) {
|
|
4862
4837
|
if (current) {
|
|
4863
|
-
|
|
4838
|
+
Q2.push(current);
|
|
4864
4839
|
current = current.left;
|
|
4865
4840
|
} else {
|
|
4866
|
-
if (
|
|
4867
|
-
current =
|
|
4841
|
+
if (Q2.length > 0) {
|
|
4842
|
+
current = Q2.pop();
|
|
4868
4843
|
if (i === index) {
|
|
4869
4844
|
return current;
|
|
4870
4845
|
}
|
|
@@ -4963,8 +4938,8 @@ Tree.prototype.toString = function toString(printNode) {
|
|
|
4963
4938
|
return n.key;
|
|
4964
4939
|
};
|
|
4965
4940
|
var out = [];
|
|
4966
|
-
printRow(this._root, "", true, function(
|
|
4967
|
-
return out.push(
|
|
4941
|
+
printRow(this._root, "", true, function(v3) {
|
|
4942
|
+
return out.push(v3);
|
|
4968
4943
|
}, printNode);
|
|
4969
4944
|
return out.join("");
|
|
4970
4945
|
};
|
|
@@ -5000,32 +4975,32 @@ function loadRecursive(parent, keys2, values2, start, end) {
|
|
|
5000
4975
|
}
|
|
5001
4976
|
function createList(keys2, values2) {
|
|
5002
4977
|
var head = { next: null };
|
|
5003
|
-
var
|
|
4978
|
+
var p2 = head;
|
|
5004
4979
|
for (var i = 0; i < keys2.length; i++) {
|
|
5005
|
-
|
|
4980
|
+
p2 = p2.next = { key: keys2[i], data: values2[i] };
|
|
5006
4981
|
}
|
|
5007
|
-
|
|
4982
|
+
p2.next = null;
|
|
5008
4983
|
return head.next;
|
|
5009
4984
|
}
|
|
5010
4985
|
function toList(root2) {
|
|
5011
4986
|
var current = root2;
|
|
5012
|
-
var
|
|
4987
|
+
var Q2 = [], done = false;
|
|
5013
4988
|
var head = { next: null };
|
|
5014
|
-
var
|
|
4989
|
+
var p2 = head;
|
|
5015
4990
|
while (!done) {
|
|
5016
4991
|
if (current) {
|
|
5017
|
-
|
|
4992
|
+
Q2.push(current);
|
|
5018
4993
|
current = current.left;
|
|
5019
4994
|
} else {
|
|
5020
|
-
if (
|
|
5021
|
-
current =
|
|
4995
|
+
if (Q2.length > 0) {
|
|
4996
|
+
current = p2 = p2.next = Q2.pop();
|
|
5022
4997
|
current = current.right;
|
|
5023
4998
|
} else {
|
|
5024
4999
|
done = true;
|
|
5025
5000
|
}
|
|
5026
5001
|
}
|
|
5027
5002
|
}
|
|
5028
|
-
|
|
5003
|
+
p2.next = null;
|
|
5029
5004
|
return head.next;
|
|
5030
5005
|
}
|
|
5031
5006
|
function sortedListToBST(list, start, end) {
|
|
@@ -5046,23 +5021,23 @@ function mergeLists(l1, l2, compare) {
|
|
|
5046
5021
|
return a - b2;
|
|
5047
5022
|
};
|
|
5048
5023
|
var head = {};
|
|
5049
|
-
var
|
|
5024
|
+
var p2 = head;
|
|
5050
5025
|
var p1 = l1;
|
|
5051
|
-
var
|
|
5052
|
-
while (p1 !== null &&
|
|
5053
|
-
if (compare(p1.key,
|
|
5054
|
-
|
|
5026
|
+
var p22 = l2;
|
|
5027
|
+
while (p1 !== null && p22 !== null) {
|
|
5028
|
+
if (compare(p1.key, p22.key) < 0) {
|
|
5029
|
+
p2.next = p1;
|
|
5055
5030
|
p1 = p1.next;
|
|
5056
5031
|
} else {
|
|
5057
|
-
|
|
5058
|
-
|
|
5032
|
+
p2.next = p22;
|
|
5033
|
+
p22 = p22.next;
|
|
5059
5034
|
}
|
|
5060
|
-
|
|
5035
|
+
p2 = p2.next;
|
|
5061
5036
|
}
|
|
5062
5037
|
if (p1 !== null) {
|
|
5063
|
-
|
|
5064
|
-
} else if (
|
|
5065
|
-
|
|
5038
|
+
p2.next = p1;
|
|
5039
|
+
} else if (p22 !== null) {
|
|
5040
|
+
p2.next = p22;
|
|
5066
5041
|
}
|
|
5067
5042
|
return head.next;
|
|
5068
5043
|
}
|
|
@@ -5332,7 +5307,7 @@ function swap(values2, boxes, indices, i, j) {
|
|
|
5332
5307
|
var m = 4 * j;
|
|
5333
5308
|
var a = boxes[k3];
|
|
5334
5309
|
var b2 = boxes[k3 + 1];
|
|
5335
|
-
var
|
|
5310
|
+
var c = boxes[k3 + 2];
|
|
5336
5311
|
var d = boxes[k3 + 3];
|
|
5337
5312
|
boxes[k3] = boxes[m];
|
|
5338
5313
|
boxes[k3 + 1] = boxes[m + 1];
|
|
@@ -5340,7 +5315,7 @@ function swap(values2, boxes, indices, i, j) {
|
|
|
5340
5315
|
boxes[k3 + 3] = boxes[m + 3];
|
|
5341
5316
|
boxes[m] = a;
|
|
5342
5317
|
boxes[m + 1] = b2;
|
|
5343
|
-
boxes[m + 2] =
|
|
5318
|
+
boxes[m + 2] = c;
|
|
5344
5319
|
boxes[m + 3] = d;
|
|
5345
5320
|
var e = indices[i];
|
|
5346
5321
|
indices[i] = indices[j];
|
|
@@ -5349,35 +5324,35 @@ function swap(values2, boxes, indices, i, j) {
|
|
|
5349
5324
|
function hilbert(x2, y2) {
|
|
5350
5325
|
var a = x2 ^ y2;
|
|
5351
5326
|
var b2 = 65535 ^ a;
|
|
5352
|
-
var
|
|
5327
|
+
var c = 65535 ^ (x2 | y2);
|
|
5353
5328
|
var d = x2 & (y2 ^ 65535);
|
|
5354
5329
|
var A2 = a | b2 >> 1;
|
|
5355
|
-
var
|
|
5356
|
-
var
|
|
5357
|
-
var D = a &
|
|
5330
|
+
var B = a >> 1 ^ a;
|
|
5331
|
+
var C = c >> 1 ^ b2 & d >> 1 ^ c;
|
|
5332
|
+
var D = a & c >> 1 ^ d >> 1 ^ d;
|
|
5358
5333
|
a = A2;
|
|
5359
|
-
b2 =
|
|
5360
|
-
|
|
5334
|
+
b2 = B;
|
|
5335
|
+
c = C;
|
|
5361
5336
|
d = D;
|
|
5362
5337
|
A2 = a & a >> 2 ^ b2 & b2 >> 2;
|
|
5363
|
-
|
|
5364
|
-
|
|
5365
|
-
D ^= b2 &
|
|
5338
|
+
B = a & b2 >> 2 ^ b2 & (a ^ b2) >> 2;
|
|
5339
|
+
C ^= a & c >> 2 ^ b2 & d >> 2;
|
|
5340
|
+
D ^= b2 & c >> 2 ^ (a ^ b2) & d >> 2;
|
|
5366
5341
|
a = A2;
|
|
5367
|
-
b2 =
|
|
5368
|
-
|
|
5342
|
+
b2 = B;
|
|
5343
|
+
c = C;
|
|
5369
5344
|
d = D;
|
|
5370
5345
|
A2 = a & a >> 4 ^ b2 & b2 >> 4;
|
|
5371
|
-
|
|
5372
|
-
|
|
5373
|
-
D ^= b2 &
|
|
5346
|
+
B = a & b2 >> 4 ^ b2 & (a ^ b2) >> 4;
|
|
5347
|
+
C ^= a & c >> 4 ^ b2 & d >> 4;
|
|
5348
|
+
D ^= b2 & c >> 4 ^ (a ^ b2) & d >> 4;
|
|
5374
5349
|
a = A2;
|
|
5375
|
-
b2 =
|
|
5376
|
-
|
|
5350
|
+
b2 = B;
|
|
5351
|
+
c = C;
|
|
5377
5352
|
d = D;
|
|
5378
|
-
|
|
5379
|
-
D ^= b2 &
|
|
5380
|
-
a =
|
|
5353
|
+
C ^= a & c >> 8 ^ b2 & d >> 8;
|
|
5354
|
+
D ^= b2 & c >> 8 ^ (a ^ b2) & d >> 8;
|
|
5355
|
+
a = C ^ C >> 1;
|
|
5381
5356
|
b2 = D ^ D >> 1;
|
|
5382
5357
|
var i0 = x2 ^ y2;
|
|
5383
5358
|
var i1 = b2 | 65535 ^ (i0 | a);
|
|
@@ -5471,9 +5446,9 @@ function bush(lines, options) {
|
|
|
5471
5446
|
}
|
|
5472
5447
|
index.add(minX, minY, maxX, maxY);
|
|
5473
5448
|
}
|
|
5474
|
-
function defaultIntersectionReporter(
|
|
5449
|
+
function defaultIntersectionReporter(p2, interior) {
|
|
5475
5450
|
results.push({
|
|
5476
|
-
point:
|
|
5451
|
+
point: p2,
|
|
5477
5452
|
segments: interior
|
|
5478
5453
|
});
|
|
5479
5454
|
}
|
|
@@ -5514,20 +5489,20 @@ function find2dSingularities(viewmap) {
|
|
|
5514
5489
|
}
|
|
5515
5490
|
if (splitViewVertices.length === 0) ;
|
|
5516
5491
|
else if (splitViewVertices.length === 1) {
|
|
5517
|
-
const
|
|
5518
|
-
|
|
5492
|
+
const v3 = splitViewVertices[0];
|
|
5493
|
+
v3.singularity = ViewVertexSingularity.ImageIntersection;
|
|
5519
5494
|
} else {
|
|
5520
5495
|
const v1 = splitViewVertices[0];
|
|
5521
|
-
const
|
|
5496
|
+
const v22 = splitViewVertices[1];
|
|
5522
5497
|
const d1 = v1.pos3d.distanceTo(viewmap.camera.position);
|
|
5523
|
-
const d2 =
|
|
5498
|
+
const d2 = v22.pos3d.distanceTo(viewmap.camera.position);
|
|
5524
5499
|
if (d1 > d2 + 1e-10) {
|
|
5525
5500
|
v1.singularity = ViewVertexSingularity.ImageIntersection;
|
|
5526
5501
|
} else if (d2 > d1 + 1e-10) {
|
|
5527
|
-
|
|
5502
|
+
v22.singularity = ViewVertexSingularity.ImageIntersection;
|
|
5528
5503
|
} else {
|
|
5529
5504
|
v1.singularity = ViewVertexSingularity.ImageIntersection;
|
|
5530
|
-
|
|
5505
|
+
v22.singularity = ViewVertexSingularity.ImageIntersection;
|
|
5531
5506
|
}
|
|
5532
5507
|
}
|
|
5533
5508
|
}
|
|
@@ -5545,8 +5520,8 @@ function singularityForPoint(viewVertex, camera) {
|
|
|
5545
5520
|
for (const edge of viewVertex.viewEdges) {
|
|
5546
5521
|
natures.add(edge.nature);
|
|
5547
5522
|
if (edge.faces.length > 1 && edge.nature === ViewEdgeNature.Silhouette) {
|
|
5548
|
-
concaveSilhouetteEdgeFound
|
|
5549
|
-
convexSilhouetteEdgeFound
|
|
5523
|
+
concaveSilhouetteEdgeFound ||= edge.isConcave;
|
|
5524
|
+
convexSilhouetteEdgeFound ||= !edge.isConcave;
|
|
5550
5525
|
}
|
|
5551
5526
|
}
|
|
5552
5527
|
if (natures.size === 0) {
|
|
@@ -5597,8 +5572,8 @@ function isAnyFaceOverlappingBoundary(viewVertex, camera) {
|
|
|
5597
5572
|
}
|
|
5598
5573
|
}
|
|
5599
5574
|
if (farthestHalfedge && otherVertex) {
|
|
5600
|
-
const
|
|
5601
|
-
const
|
|
5575
|
+
const c = camera.position;
|
|
5576
|
+
const p2 = vertex.position;
|
|
5602
5577
|
const e = otherVertex.position;
|
|
5603
5578
|
const boundaryFace = farthestHalfedge.twin.face;
|
|
5604
5579
|
if (boundaryFace) {
|
|
@@ -5606,7 +5581,7 @@ function isAnyFaceOverlappingBoundary(viewVertex, camera) {
|
|
|
5606
5581
|
if (halfedge.face !== boundaryFace) {
|
|
5607
5582
|
const q = halfedge.next.vertex.position;
|
|
5608
5583
|
const r = halfedge.next.vertex.position;
|
|
5609
|
-
if (!sameSide(
|
|
5584
|
+
if (!sameSide(p2, q, r, c, e) && sameSide(c, p2, q, e, r) && sameSide(c, p2, r, e, q)) {
|
|
5610
5585
|
return true;
|
|
5611
5586
|
}
|
|
5612
5587
|
}
|
|
@@ -5706,7 +5681,7 @@ class Viewmap {
|
|
|
5706
5681
|
};
|
|
5707
5682
|
if (this.skipActions) res();
|
|
5708
5683
|
else {
|
|
5709
|
-
actions[idx].process().catch((
|
|
5684
|
+
actions[idx].process().catch((_) => {
|
|
5710
5685
|
}).then(res);
|
|
5711
5686
|
}
|
|
5712
5687
|
} else {
|
|
@@ -5841,10 +5816,10 @@ class Viewmap {
|
|
|
5841
5816
|
return actions;
|
|
5842
5817
|
}
|
|
5843
5818
|
visibleChains() {
|
|
5844
|
-
return this.chains.filter((
|
|
5819
|
+
return this.chains.filter((c) => c.visibility === ChainVisibility.Visible);
|
|
5845
5820
|
}
|
|
5846
5821
|
hiddenChains() {
|
|
5847
|
-
return this.chains.filter((
|
|
5822
|
+
return this.chains.filter((c) => c.visibility === ChainVisibility.Hidden);
|
|
5848
5823
|
}
|
|
5849
5824
|
}
|
|
5850
5825
|
const methods$1 = {};
|
|
@@ -6064,24 +6039,24 @@ function prev2() {
|
|
|
6064
6039
|
}
|
|
6065
6040
|
function forward() {
|
|
6066
6041
|
const i = this.position();
|
|
6067
|
-
const
|
|
6068
|
-
|
|
6042
|
+
const p2 = this.parent();
|
|
6043
|
+
p2.add(this.remove(), i + 1);
|
|
6069
6044
|
return this;
|
|
6070
6045
|
}
|
|
6071
6046
|
function backward() {
|
|
6072
6047
|
const i = this.position();
|
|
6073
|
-
const
|
|
6074
|
-
|
|
6048
|
+
const p2 = this.parent();
|
|
6049
|
+
p2.add(this.remove(), i ? i - 1 : 0);
|
|
6075
6050
|
return this;
|
|
6076
6051
|
}
|
|
6077
6052
|
function front() {
|
|
6078
|
-
const
|
|
6079
|
-
|
|
6053
|
+
const p2 = this.parent();
|
|
6054
|
+
p2.add(this.remove());
|
|
6080
6055
|
return this;
|
|
6081
6056
|
}
|
|
6082
6057
|
function back() {
|
|
6083
|
-
const
|
|
6084
|
-
|
|
6058
|
+
const p2 = this.parent();
|
|
6059
|
+
p2.add(this.remove(), 0);
|
|
6085
6060
|
return this;
|
|
6086
6061
|
}
|
|
6087
6062
|
function before(element) {
|
|
@@ -6152,8 +6127,8 @@ function addClass(name) {
|
|
|
6152
6127
|
}
|
|
6153
6128
|
function removeClass(name) {
|
|
6154
6129
|
if (this.hasClass(name)) {
|
|
6155
|
-
this.attr("class", this.classes().filter(function(
|
|
6156
|
-
return
|
|
6130
|
+
this.attr("class", this.classes().filter(function(c) {
|
|
6131
|
+
return c !== name;
|
|
6157
6132
|
}).join(" "));
|
|
6158
6133
|
}
|
|
6159
6134
|
return this;
|
|
@@ -6216,7 +6191,7 @@ registerMethods("Dom", {
|
|
|
6216
6191
|
hide,
|
|
6217
6192
|
visible
|
|
6218
6193
|
});
|
|
6219
|
-
function data(a,
|
|
6194
|
+
function data(a, v3, r) {
|
|
6220
6195
|
if (a == null) {
|
|
6221
6196
|
return this.data(map(filter(this.node.attributes, (el) => el.nodeName.indexOf("data-") === 0), (el) => el.nodeName.slice(5)));
|
|
6222
6197
|
} else if (a instanceof Array) {
|
|
@@ -6226,8 +6201,8 @@ function data(a, v2, r) {
|
|
|
6226
6201
|
}
|
|
6227
6202
|
return data2;
|
|
6228
6203
|
} else if (typeof a === "object") {
|
|
6229
|
-
for (
|
|
6230
|
-
this.data(
|
|
6204
|
+
for (v3 in a) {
|
|
6205
|
+
this.data(v3, a[v3]);
|
|
6231
6206
|
}
|
|
6232
6207
|
} else if (arguments.length < 2) {
|
|
6233
6208
|
try {
|
|
@@ -6236,14 +6211,14 @@ function data(a, v2, r) {
|
|
|
6236
6211
|
return this.attr("data-" + a);
|
|
6237
6212
|
}
|
|
6238
6213
|
} else {
|
|
6239
|
-
this.attr("data-" + a,
|
|
6214
|
+
this.attr("data-" + a, v3 === null ? null : r === true || typeof v3 === "string" || typeof v3 === "number" ? v3 : JSON.stringify(v3));
|
|
6240
6215
|
}
|
|
6241
6216
|
return this;
|
|
6242
6217
|
}
|
|
6243
6218
|
registerMethods("Dom", {
|
|
6244
6219
|
data
|
|
6245
6220
|
});
|
|
6246
|
-
function remember(k3,
|
|
6221
|
+
function remember(k3, v3) {
|
|
6247
6222
|
if (typeof arguments[0] === "object") {
|
|
6248
6223
|
for (const key in k3) {
|
|
6249
6224
|
this.remember(key, k3[key]);
|
|
@@ -6251,7 +6226,7 @@ function remember(k3, v2) {
|
|
|
6251
6226
|
} else if (arguments.length === 1) {
|
|
6252
6227
|
return this.memory()[k3];
|
|
6253
6228
|
} else {
|
|
6254
|
-
this.memory()[k3] =
|
|
6229
|
+
this.memory()[k3] = v3;
|
|
6255
6230
|
}
|
|
6256
6231
|
return this;
|
|
6257
6232
|
}
|
|
@@ -6343,13 +6318,13 @@ function cieSpace(space) {
|
|
|
6343
6318
|
return false;
|
|
6344
6319
|
}
|
|
6345
6320
|
}
|
|
6346
|
-
function hueToRgb(
|
|
6321
|
+
function hueToRgb(p2, q, t) {
|
|
6347
6322
|
if (t < 0) t += 1;
|
|
6348
6323
|
if (t > 1) t -= 1;
|
|
6349
|
-
if (t < 1 / 6) return
|
|
6324
|
+
if (t < 1 / 6) return p2 + (q - p2) * 6 * t;
|
|
6350
6325
|
if (t < 1 / 2) return q;
|
|
6351
|
-
if (t < 2 / 3) return
|
|
6352
|
-
return
|
|
6326
|
+
if (t < 2 / 3) return p2 + (q - p2) * (2 / 3 - t) * 6;
|
|
6327
|
+
return p2;
|
|
6353
6328
|
}
|
|
6354
6329
|
class Color {
|
|
6355
6330
|
constructor(...inputs) {
|
|
@@ -6374,10 +6349,10 @@ class Color {
|
|
|
6374
6349
|
PI: pi
|
|
6375
6350
|
} = Math;
|
|
6376
6351
|
if (mode === "vibrant") {
|
|
6377
|
-
const
|
|
6378
|
-
const
|
|
6379
|
-
const
|
|
6380
|
-
const color = new Color(
|
|
6352
|
+
const l2 = (81 - 57) * random() + 57;
|
|
6353
|
+
const c = (83 - 45) * random() + 45;
|
|
6354
|
+
const h = 360 * random();
|
|
6355
|
+
const color = new Color(l2, c, h, "lch");
|
|
6381
6356
|
return color;
|
|
6382
6357
|
} else if (mode === "sine") {
|
|
6383
6358
|
t = t == null ? random() : t;
|
|
@@ -6387,16 +6362,16 @@ class Color {
|
|
|
6387
6362
|
const color = new Color(r, g, b2);
|
|
6388
6363
|
return color;
|
|
6389
6364
|
} else if (mode === "pastel") {
|
|
6390
|
-
const
|
|
6391
|
-
const
|
|
6392
|
-
const
|
|
6393
|
-
const color = new Color(
|
|
6365
|
+
const l2 = (94 - 86) * random() + 86;
|
|
6366
|
+
const c = (26 - 9) * random() + 9;
|
|
6367
|
+
const h = 360 * random();
|
|
6368
|
+
const color = new Color(l2, c, h, "lch");
|
|
6394
6369
|
return color;
|
|
6395
6370
|
} else if (mode === "dark") {
|
|
6396
|
-
const
|
|
6397
|
-
const
|
|
6398
|
-
const
|
|
6399
|
-
const color = new Color(
|
|
6371
|
+
const l2 = 10 + 10 * random();
|
|
6372
|
+
const c = (125 - 75) * random() + 86;
|
|
6373
|
+
const h = 360 * random();
|
|
6374
|
+
const color = new Color(l2, c, h, "lch");
|
|
6400
6375
|
return color;
|
|
6401
6376
|
} else if (mode === "rgb") {
|
|
6402
6377
|
const r = 255 * random();
|
|
@@ -6405,10 +6380,10 @@ class Color {
|
|
|
6405
6380
|
const color = new Color(r, g, b2);
|
|
6406
6381
|
return color;
|
|
6407
6382
|
} else if (mode === "lab") {
|
|
6408
|
-
const
|
|
6383
|
+
const l2 = 100 * random();
|
|
6409
6384
|
const a = 256 * random() - 128;
|
|
6410
6385
|
const b2 = 256 * random() - 128;
|
|
6411
|
-
const color = new Color(
|
|
6386
|
+
const color = new Color(l2, a, b2, "lab");
|
|
6412
6387
|
return color;
|
|
6413
6388
|
} else if (mode === "grey") {
|
|
6414
6389
|
const grey = 255 * random();
|
|
@@ -6428,15 +6403,15 @@ class Color {
|
|
|
6428
6403
|
_b,
|
|
6429
6404
|
_c
|
|
6430
6405
|
} = this.rgb();
|
|
6431
|
-
const [r, g, b2] = [_a, _b, _c].map((
|
|
6406
|
+
const [r, g, b2] = [_a, _b, _c].map((v3) => v3 / 255);
|
|
6432
6407
|
const k3 = Math.min(1 - r, 1 - g, 1 - b2);
|
|
6433
6408
|
if (k3 === 1) {
|
|
6434
6409
|
return new Color(0, 0, 0, 1, "cmyk");
|
|
6435
6410
|
}
|
|
6436
|
-
const
|
|
6411
|
+
const c = (1 - r - k3) / (1 - k3);
|
|
6437
6412
|
const m = (1 - g - k3) / (1 - k3);
|
|
6438
6413
|
const y2 = (1 - b2 - k3) / (1 - k3);
|
|
6439
|
-
const color = new Color(
|
|
6414
|
+
const color = new Color(c, m, y2, k3, "cmyk");
|
|
6440
6415
|
return color;
|
|
6441
6416
|
}
|
|
6442
6417
|
hsl() {
|
|
@@ -6445,18 +6420,18 @@ class Color {
|
|
|
6445
6420
|
_b,
|
|
6446
6421
|
_c
|
|
6447
6422
|
} = this.rgb();
|
|
6448
|
-
const [r, g, b2] = [_a, _b, _c].map((
|
|
6423
|
+
const [r, g, b2] = [_a, _b, _c].map((v3) => v3 / 255);
|
|
6449
6424
|
const max2 = Math.max(r, g, b2);
|
|
6450
6425
|
const min2 = Math.min(r, g, b2);
|
|
6451
|
-
const
|
|
6426
|
+
const l2 = (max2 + min2) / 2;
|
|
6452
6427
|
const isGrey = max2 === min2;
|
|
6453
6428
|
const delta = max2 - min2;
|
|
6454
|
-
const s = isGrey ? 0 :
|
|
6455
|
-
const
|
|
6456
|
-
const color = new Color(360 *
|
|
6429
|
+
const s = isGrey ? 0 : l2 > 0.5 ? delta / (2 - max2 - min2) : delta / (max2 + min2);
|
|
6430
|
+
const h = isGrey ? 0 : max2 === r ? ((g - b2) / delta + (g < b2 ? 6 : 0)) / 6 : max2 === g ? ((b2 - r) / delta + 2) / 6 : max2 === b2 ? ((r - g) / delta + 4) / 6 : 0;
|
|
6431
|
+
const color = new Color(360 * h, 100 * s, 100 * l2, "hsl");
|
|
6457
6432
|
return color;
|
|
6458
6433
|
}
|
|
6459
|
-
init(a = 0, b2 = 0,
|
|
6434
|
+
init(a = 0, b2 = 0, c = 0, d = 0, space = "rgb") {
|
|
6460
6435
|
a = !a ? 0 : a;
|
|
6461
6436
|
if (this.space) {
|
|
6462
6437
|
for (const component in this.space) {
|
|
@@ -6469,7 +6444,7 @@ class Color {
|
|
|
6469
6444
|
Object.assign(this, {
|
|
6470
6445
|
_a: a,
|
|
6471
6446
|
_b: b2,
|
|
6472
|
-
_c:
|
|
6447
|
+
_c: c,
|
|
6473
6448
|
_d: d,
|
|
6474
6449
|
space
|
|
6475
6450
|
});
|
|
@@ -6487,7 +6462,7 @@ class Color {
|
|
|
6487
6462
|
} else if (typeof a === "string") {
|
|
6488
6463
|
if (isRgb.test(a)) {
|
|
6489
6464
|
const noWhitespace = a.replace(whitespace, "");
|
|
6490
|
-
const [_a2, _b2, _c2] = rgb.exec(noWhitespace).slice(1, 4).map((
|
|
6465
|
+
const [_a2, _b2, _c2] = rgb.exec(noWhitespace).slice(1, 4).map((v3) => parseInt(v3));
|
|
6491
6466
|
Object.assign(this, {
|
|
6492
6467
|
_a: _a2,
|
|
6493
6468
|
_b: _b2,
|
|
@@ -6496,7 +6471,7 @@ class Color {
|
|
|
6496
6471
|
space: "rgb"
|
|
6497
6472
|
});
|
|
6498
6473
|
} else if (isHex.test(a)) {
|
|
6499
|
-
const hexParse = (
|
|
6474
|
+
const hexParse = (v3) => parseInt(v3, 16);
|
|
6500
6475
|
const [, _a2, _b2, _c2] = hex.exec(sixDigitHex(a)).map(hexParse);
|
|
6501
6476
|
Object.assign(this, {
|
|
6502
6477
|
_a: _a2,
|
|
@@ -6545,27 +6520,27 @@ class Color {
|
|
|
6545
6520
|
const {
|
|
6546
6521
|
x: x2,
|
|
6547
6522
|
y: y2,
|
|
6548
|
-
z
|
|
6523
|
+
z: z2
|
|
6549
6524
|
} = this.xyz();
|
|
6550
|
-
const
|
|
6525
|
+
const l2 = 116 * y2 - 16;
|
|
6551
6526
|
const a = 500 * (x2 - y2);
|
|
6552
|
-
const b2 = 200 * (y2 -
|
|
6553
|
-
const color = new Color(
|
|
6527
|
+
const b2 = 200 * (y2 - z2);
|
|
6528
|
+
const color = new Color(l2, a, b2, "lab");
|
|
6554
6529
|
return color;
|
|
6555
6530
|
}
|
|
6556
6531
|
lch() {
|
|
6557
6532
|
const {
|
|
6558
|
-
l,
|
|
6533
|
+
l: l2,
|
|
6559
6534
|
a,
|
|
6560
6535
|
b: b2
|
|
6561
6536
|
} = this.lab();
|
|
6562
|
-
const
|
|
6563
|
-
let
|
|
6564
|
-
if (
|
|
6565
|
-
|
|
6566
|
-
|
|
6537
|
+
const c = Math.sqrt(a ** 2 + b2 ** 2);
|
|
6538
|
+
let h = 180 * Math.atan2(b2, a) / Math.PI;
|
|
6539
|
+
if (h < 0) {
|
|
6540
|
+
h *= -1;
|
|
6541
|
+
h = 360 - h;
|
|
6567
6542
|
}
|
|
6568
|
-
const color = new Color(
|
|
6543
|
+
const color = new Color(l2, c, h, "lch");
|
|
6569
6544
|
return color;
|
|
6570
6545
|
}
|
|
6571
6546
|
/*
|
|
@@ -6578,24 +6553,24 @@ class Color {
|
|
|
6578
6553
|
let {
|
|
6579
6554
|
x: x2,
|
|
6580
6555
|
y: y2,
|
|
6581
|
-
z
|
|
6556
|
+
z: z2
|
|
6582
6557
|
} = this;
|
|
6583
6558
|
if (this.space === "lab" || this.space === "lch") {
|
|
6584
6559
|
let {
|
|
6585
|
-
l,
|
|
6560
|
+
l: l2,
|
|
6586
6561
|
a,
|
|
6587
6562
|
b: b3
|
|
6588
6563
|
} = this;
|
|
6589
6564
|
if (this.space === "lch") {
|
|
6590
6565
|
const {
|
|
6591
|
-
c
|
|
6592
|
-
h
|
|
6566
|
+
c,
|
|
6567
|
+
h
|
|
6593
6568
|
} = this;
|
|
6594
6569
|
const dToR = Math.PI / 180;
|
|
6595
|
-
a =
|
|
6596
|
-
b3 =
|
|
6570
|
+
a = c * Math.cos(dToR * h);
|
|
6571
|
+
b3 = c * Math.sin(dToR * h);
|
|
6597
6572
|
}
|
|
6598
|
-
const yL = (
|
|
6573
|
+
const yL = (l2 + 16) / 116;
|
|
6599
6574
|
const xL = a / 500 + yL;
|
|
6600
6575
|
const zL = yL - b3 / 200;
|
|
6601
6576
|
const ct = 16 / 116;
|
|
@@ -6603,11 +6578,11 @@ class Color {
|
|
|
6603
6578
|
const nm = 7.787;
|
|
6604
6579
|
x2 = 0.95047 * (xL ** 3 > mx ? xL ** 3 : (xL - ct) / nm);
|
|
6605
6580
|
y2 = 1 * (yL ** 3 > mx ? yL ** 3 : (yL - ct) / nm);
|
|
6606
|
-
|
|
6581
|
+
z2 = 1.08883 * (zL ** 3 > mx ? zL ** 3 : (zL - ct) / nm);
|
|
6607
6582
|
}
|
|
6608
|
-
const rU = x2 * 3.2406 + y2 * -1.5372 +
|
|
6609
|
-
const gU = x2 * -0.9689 + y2 * 1.8758 +
|
|
6610
|
-
const bU = x2 * 0.0557 + y2 * -0.204 +
|
|
6583
|
+
const rU = x2 * 3.2406 + y2 * -1.5372 + z2 * -0.4986;
|
|
6584
|
+
const gU = x2 * -0.9689 + y2 * 1.8758 + z2 * 0.0415;
|
|
6585
|
+
const bU = x2 * 0.0557 + y2 * -0.204 + z2 * 1.057;
|
|
6611
6586
|
const pow = Math.pow;
|
|
6612
6587
|
const bd = 31308e-7;
|
|
6613
6588
|
const r = rU > bd ? 1.055 * pow(rU, 1 / 2.4) - 0.055 : 12.92 * rU;
|
|
@@ -6617,33 +6592,33 @@ class Color {
|
|
|
6617
6592
|
return color;
|
|
6618
6593
|
} else if (this.space === "hsl") {
|
|
6619
6594
|
let {
|
|
6620
|
-
h
|
|
6595
|
+
h,
|
|
6621
6596
|
s,
|
|
6622
|
-
l
|
|
6597
|
+
l: l2
|
|
6623
6598
|
} = this;
|
|
6624
|
-
|
|
6599
|
+
h /= 360;
|
|
6625
6600
|
s /= 100;
|
|
6626
|
-
|
|
6601
|
+
l2 /= 100;
|
|
6627
6602
|
if (s === 0) {
|
|
6628
|
-
|
|
6629
|
-
const color2 = new Color(
|
|
6603
|
+
l2 *= 255;
|
|
6604
|
+
const color2 = new Color(l2, l2, l2);
|
|
6630
6605
|
return color2;
|
|
6631
6606
|
}
|
|
6632
|
-
const q =
|
|
6633
|
-
const
|
|
6634
|
-
const r = 255 * hueToRgb(
|
|
6635
|
-
const g = 255 * hueToRgb(
|
|
6636
|
-
const b2 = 255 * hueToRgb(
|
|
6607
|
+
const q = l2 < 0.5 ? l2 * (1 + s) : l2 + s - l2 * s;
|
|
6608
|
+
const p2 = 2 * l2 - q;
|
|
6609
|
+
const r = 255 * hueToRgb(p2, q, h + 1 / 3);
|
|
6610
|
+
const g = 255 * hueToRgb(p2, q, h);
|
|
6611
|
+
const b2 = 255 * hueToRgb(p2, q, h - 1 / 3);
|
|
6637
6612
|
const color = new Color(r, g, b2);
|
|
6638
6613
|
return color;
|
|
6639
6614
|
} else if (this.space === "cmyk") {
|
|
6640
6615
|
const {
|
|
6641
|
-
c
|
|
6616
|
+
c,
|
|
6642
6617
|
m,
|
|
6643
6618
|
y: y2,
|
|
6644
6619
|
k: k3
|
|
6645
6620
|
} = this;
|
|
6646
|
-
const r = 255 * (1 - Math.min(1,
|
|
6621
|
+
const r = 255 * (1 - Math.min(1, c * (1 - k3) + k3));
|
|
6647
6622
|
const g = 255 * (1 - Math.min(1, m * (1 - k3) + k3));
|
|
6648
6623
|
const b2 = 255 * (1 - Math.min(1, y2 * (1 - k3) + k3));
|
|
6649
6624
|
const color = new Color(r, g, b2);
|
|
@@ -6680,7 +6655,7 @@ class Color {
|
|
|
6680
6655
|
_b: g255,
|
|
6681
6656
|
_c: b255
|
|
6682
6657
|
} = this.rgb();
|
|
6683
|
-
const [r, g, b2] = [r255, g255, b255].map((
|
|
6658
|
+
const [r, g, b2] = [r255, g255, b255].map((v3) => v3 / 255);
|
|
6684
6659
|
const rL = r > 0.04045 ? Math.pow((r + 0.055) / 1.055, 2.4) : r / 12.92;
|
|
6685
6660
|
const gL = g > 0.04045 ? Math.pow((g + 0.055) / 1.055, 2.4) : g / 12.92;
|
|
6686
6661
|
const bL = b2 > 0.04045 ? Math.pow((b2 + 0.055) / 1.055, 2.4) : b2 / 12.92;
|
|
@@ -6689,8 +6664,8 @@ class Color {
|
|
|
6689
6664
|
const zU = (rL * 0.0193 + gL * 0.1192 + bL * 0.9505) / 1.08883;
|
|
6690
6665
|
const x2 = xU > 8856e-6 ? Math.pow(xU, 1 / 3) : 7.787 * xU + 16 / 116;
|
|
6691
6666
|
const y2 = yU > 8856e-6 ? Math.pow(yU, 1 / 3) : 7.787 * yU + 16 / 116;
|
|
6692
|
-
const
|
|
6693
|
-
const color = new Color(x2, y2,
|
|
6667
|
+
const z2 = zU > 8856e-6 ? Math.pow(zU, 1 / 3) : 7.787 * zU + 16 / 116;
|
|
6668
|
+
const color = new Color(x2, y2, z2, "xyz");
|
|
6694
6669
|
return color;
|
|
6695
6670
|
}
|
|
6696
6671
|
/*
|
|
@@ -6707,7 +6682,7 @@ class Color {
|
|
|
6707
6682
|
min: min2,
|
|
6708
6683
|
round: round2
|
|
6709
6684
|
} = Math;
|
|
6710
|
-
const format = (
|
|
6685
|
+
const format = (v3) => max2(0, min2(round2(v3), 255));
|
|
6711
6686
|
return [_a, _b, _c].map(format);
|
|
6712
6687
|
}
|
|
6713
6688
|
/*
|
|
@@ -6825,16 +6800,16 @@ class Matrix {
|
|
|
6825
6800
|
return o.a != null || o.b != null || o.c != null || o.d != null || o.e != null || o.f != null;
|
|
6826
6801
|
}
|
|
6827
6802
|
// left matrix, right matrix, target matrix which is overwritten
|
|
6828
|
-
static matrixMultiply(
|
|
6829
|
-
const a =
|
|
6830
|
-
const b2 =
|
|
6831
|
-
const
|
|
6832
|
-
const d =
|
|
6833
|
-
const e =
|
|
6834
|
-
const f =
|
|
6803
|
+
static matrixMultiply(l2, r, o) {
|
|
6804
|
+
const a = l2.a * r.a + l2.c * r.b;
|
|
6805
|
+
const b2 = l2.b * r.a + l2.d * r.b;
|
|
6806
|
+
const c = l2.a * r.c + l2.c * r.d;
|
|
6807
|
+
const d = l2.b * r.c + l2.d * r.d;
|
|
6808
|
+
const e = l2.e + l2.a * r.e + l2.c * r.f;
|
|
6809
|
+
const f = l2.f + l2.b * r.e + l2.d * r.f;
|
|
6835
6810
|
o.a = a;
|
|
6836
6811
|
o.b = b2;
|
|
6837
|
-
o.c =
|
|
6812
|
+
o.c = c;
|
|
6838
6813
|
o.d = d;
|
|
6839
6814
|
o.e = e;
|
|
6840
6815
|
o.f = f;
|
|
@@ -6857,19 +6832,19 @@ class Matrix {
|
|
|
6857
6832
|
decompose(cx2 = 0, cy2 = 0) {
|
|
6858
6833
|
const a = this.a;
|
|
6859
6834
|
const b2 = this.b;
|
|
6860
|
-
const
|
|
6835
|
+
const c = this.c;
|
|
6861
6836
|
const d = this.d;
|
|
6862
6837
|
const e = this.e;
|
|
6863
6838
|
const f = this.f;
|
|
6864
|
-
const determinant = a * d - b2 *
|
|
6839
|
+
const determinant = a * d - b2 * c;
|
|
6865
6840
|
const ccw = determinant > 0 ? 1 : -1;
|
|
6866
6841
|
const sx = ccw * Math.sqrt(a * a + b2 * b2);
|
|
6867
6842
|
const thetaRad = Math.atan2(ccw * b2, ccw * a);
|
|
6868
6843
|
const theta = 180 / Math.PI * thetaRad;
|
|
6869
6844
|
const ct = Math.cos(thetaRad);
|
|
6870
6845
|
const st = Math.sin(thetaRad);
|
|
6871
|
-
const lam = (a *
|
|
6872
|
-
const sy =
|
|
6846
|
+
const lam = (a * c + b2 * d) / determinant;
|
|
6847
|
+
const sy = c * sx / (lam * a - b2) || d * sx / (lam * b2 + a);
|
|
6873
6848
|
const tx = e - cx2 + cx2 * ct * sx + cy2 * (lam * ct * sx - st * sy);
|
|
6874
6849
|
const ty = f - cy2 + cx2 * st * sx + cy2 * (lam * st * sx + ct * sy);
|
|
6875
6850
|
return {
|
|
@@ -6923,15 +6898,15 @@ class Matrix {
|
|
|
6923
6898
|
inverseO() {
|
|
6924
6899
|
const a = this.a;
|
|
6925
6900
|
const b2 = this.b;
|
|
6926
|
-
const
|
|
6901
|
+
const c = this.c;
|
|
6927
6902
|
const d = this.d;
|
|
6928
6903
|
const e = this.e;
|
|
6929
6904
|
const f = this.f;
|
|
6930
|
-
const det = a * d - b2 *
|
|
6905
|
+
const det = a * d - b2 * c;
|
|
6931
6906
|
if (!det) throw new Error("Cannot invert " + this);
|
|
6932
6907
|
const na = d / det;
|
|
6933
6908
|
const nb = -b2 / det;
|
|
6934
|
-
const nc = -
|
|
6909
|
+
const nc = -c / det;
|
|
6935
6910
|
const nd = a / det;
|
|
6936
6911
|
const ne = -(na * e + nc * f);
|
|
6937
6912
|
const nf = -(nb * e + nd * f);
|
|
@@ -6948,17 +6923,17 @@ class Matrix {
|
|
|
6948
6923
|
}
|
|
6949
6924
|
lmultiplyO(matrix) {
|
|
6950
6925
|
const r = this;
|
|
6951
|
-
const
|
|
6952
|
-
return Matrix.matrixMultiply(
|
|
6926
|
+
const l2 = matrix instanceof Matrix ? matrix : new Matrix(matrix);
|
|
6927
|
+
return Matrix.matrixMultiply(l2, r, this);
|
|
6953
6928
|
}
|
|
6954
6929
|
// Left multiplies by the given matrix
|
|
6955
6930
|
multiply(matrix) {
|
|
6956
6931
|
return this.clone().multiplyO(matrix);
|
|
6957
6932
|
}
|
|
6958
6933
|
multiplyO(matrix) {
|
|
6959
|
-
const
|
|
6934
|
+
const l2 = this;
|
|
6960
6935
|
const r = matrix instanceof Matrix ? matrix : new Matrix(matrix);
|
|
6961
|
-
return Matrix.matrixMultiply(
|
|
6936
|
+
return Matrix.matrixMultiply(l2, r, this);
|
|
6962
6937
|
}
|
|
6963
6938
|
// Rotate matrix
|
|
6964
6939
|
rotate(r, cx2, cy2) {
|
|
@@ -6971,15 +6946,15 @@ class Matrix {
|
|
|
6971
6946
|
const {
|
|
6972
6947
|
a,
|
|
6973
6948
|
b: b2,
|
|
6974
|
-
c
|
|
6949
|
+
c,
|
|
6975
6950
|
d,
|
|
6976
6951
|
e,
|
|
6977
6952
|
f
|
|
6978
6953
|
} = this;
|
|
6979
6954
|
this.a = a * cos - b2 * sin;
|
|
6980
6955
|
this.b = b2 * cos + a * sin;
|
|
6981
|
-
this.c =
|
|
6982
|
-
this.d = d * cos +
|
|
6956
|
+
this.c = c * cos - d * sin;
|
|
6957
|
+
this.d = d * cos + c * sin;
|
|
6983
6958
|
this.e = e * cos - f * sin + cy2 * sin - cx2 * cos + cx2;
|
|
6984
6959
|
this.f = f * cos + e * sin - cx2 * sin - cy2 * cos + cy2;
|
|
6985
6960
|
return this;
|
|
@@ -6997,14 +6972,14 @@ class Matrix {
|
|
|
6997
6972
|
const {
|
|
6998
6973
|
a,
|
|
6999
6974
|
b: b2,
|
|
7000
|
-
c
|
|
6975
|
+
c,
|
|
7001
6976
|
d,
|
|
7002
6977
|
e,
|
|
7003
6978
|
f
|
|
7004
6979
|
} = this;
|
|
7005
6980
|
this.a = a * x2;
|
|
7006
6981
|
this.b = b2 * y2;
|
|
7007
|
-
this.c =
|
|
6982
|
+
this.c = c * x2;
|
|
7008
6983
|
this.d = d * y2;
|
|
7009
6984
|
this.e = e * x2 - cx2 * x2 + cx2;
|
|
7010
6985
|
this.f = f * y2 - cy2 * y2 + cy2;
|
|
@@ -7018,13 +6993,13 @@ class Matrix {
|
|
|
7018
6993
|
const {
|
|
7019
6994
|
a,
|
|
7020
6995
|
b: b2,
|
|
7021
|
-
c
|
|
6996
|
+
c,
|
|
7022
6997
|
d,
|
|
7023
6998
|
e,
|
|
7024
6999
|
f
|
|
7025
7000
|
} = this;
|
|
7026
7001
|
this.a = a + b2 * lx;
|
|
7027
|
-
this.c =
|
|
7002
|
+
this.c = c + d * lx;
|
|
7028
7003
|
this.e = e + f * lx - cy2 * lx;
|
|
7029
7004
|
return this;
|
|
7030
7005
|
}
|
|
@@ -7045,15 +7020,15 @@ class Matrix {
|
|
|
7045
7020
|
const {
|
|
7046
7021
|
a,
|
|
7047
7022
|
b: b2,
|
|
7048
|
-
c
|
|
7023
|
+
c,
|
|
7049
7024
|
d,
|
|
7050
7025
|
e,
|
|
7051
7026
|
f
|
|
7052
7027
|
} = this;
|
|
7053
7028
|
this.a = a + b2 * lx;
|
|
7054
7029
|
this.b = b2 + a * ly;
|
|
7055
|
-
this.c =
|
|
7056
|
-
this.d = d +
|
|
7030
|
+
this.c = c + d * lx;
|
|
7031
|
+
this.d = d + c * ly;
|
|
7057
7032
|
this.e = e + f * lx - cy2 * lx;
|
|
7058
7033
|
this.f = f + e * ly - cx2 * ly;
|
|
7059
7034
|
return this;
|
|
@@ -7205,12 +7180,12 @@ class Box {
|
|
|
7205
7180
|
let yMin = Infinity;
|
|
7206
7181
|
let yMax = -Infinity;
|
|
7207
7182
|
const pts = [new Point(this.x, this.y), new Point(this.x2, this.y), new Point(this.x, this.y2), new Point(this.x2, this.y2)];
|
|
7208
|
-
pts.forEach(function(
|
|
7209
|
-
|
|
7210
|
-
xMin = Math.min(xMin,
|
|
7211
|
-
xMax = Math.max(xMax,
|
|
7212
|
-
yMin = Math.min(yMin,
|
|
7213
|
-
yMax = Math.max(yMax,
|
|
7183
|
+
pts.forEach(function(p2) {
|
|
7184
|
+
p2 = p2.transform(m);
|
|
7185
|
+
xMin = Math.min(xMin, p2.x);
|
|
7186
|
+
xMax = Math.max(xMax, p2.x);
|
|
7187
|
+
yMin = Math.min(yMin, p2.y);
|
|
7188
|
+
yMax = Math.max(yMax, p2.y);
|
|
7214
7189
|
});
|
|
7215
7190
|
return new Box(xMin, yMin, xMax - xMin, yMax - yMin);
|
|
7216
7191
|
}
|
|
@@ -7277,17 +7252,17 @@ registerMethods({
|
|
|
7277
7252
|
if (!width2 || !height2) {
|
|
7278
7253
|
throw new Error("Impossible to get absolute width and height. Please provide an absolute width and height attribute on the zooming element");
|
|
7279
7254
|
}
|
|
7280
|
-
const
|
|
7281
|
-
const zoomX = width2 /
|
|
7282
|
-
const zoomY = height2 /
|
|
7255
|
+
const v3 = this.viewbox();
|
|
7256
|
+
const zoomX = width2 / v3.width;
|
|
7257
|
+
const zoomY = height2 / v3.height;
|
|
7283
7258
|
const zoom = Math.min(zoomX, zoomY);
|
|
7284
7259
|
if (level == null) {
|
|
7285
7260
|
return zoom;
|
|
7286
7261
|
}
|
|
7287
7262
|
let zoomAmount = zoom / level;
|
|
7288
7263
|
if (zoomAmount === Infinity) zoomAmount = Number.MAX_SAFE_INTEGER / 100;
|
|
7289
|
-
point2 = point2 || new Point(width2 / 2 / zoomX +
|
|
7290
|
-
const box = new Box(
|
|
7264
|
+
point2 = point2 || new Point(width2 / 2 / zoomX + v3.x, height2 / 2 / zoomY + v3.y);
|
|
7265
|
+
const box = new Box(v3).transform(new Matrix({
|
|
7291
7266
|
scale: zoomAmount,
|
|
7292
7267
|
origin: point2
|
|
7293
7268
|
}));
|
|
@@ -7360,7 +7335,7 @@ function clearEvents(instance) {
|
|
|
7360
7335
|
if (n.events) n.events = {};
|
|
7361
7336
|
}
|
|
7362
7337
|
function on(node, events, listener, binding, options) {
|
|
7363
|
-
const
|
|
7338
|
+
const l2 = listener.bind(binding || node);
|
|
7364
7339
|
const instance = makeInstance(node);
|
|
7365
7340
|
const bag = getEvents(instance);
|
|
7366
7341
|
const n = getEventTarget(instance);
|
|
@@ -7373,8 +7348,8 @@ function on(node, events, listener, binding, options) {
|
|
|
7373
7348
|
const ns = event.split(".")[1] || "*";
|
|
7374
7349
|
bag[ev] = bag[ev] || {};
|
|
7375
7350
|
bag[ev][ns] = bag[ev][ns] || {};
|
|
7376
|
-
bag[ev][ns][listener._svgjsListenerId] =
|
|
7377
|
-
n.addEventListener(ev,
|
|
7351
|
+
bag[ev][ns][listener._svgjsListenerId] = l2;
|
|
7352
|
+
n.addEventListener(ev, l2, options || false);
|
|
7378
7353
|
});
|
|
7379
7354
|
}
|
|
7380
7355
|
function off(node, events, listener, options) {
|
|
@@ -7389,7 +7364,7 @@ function off(node, events, listener, options) {
|
|
|
7389
7364
|
events.forEach(function(event) {
|
|
7390
7365
|
const ev = event && event.split(".")[0];
|
|
7391
7366
|
const ns = event && event.split(".")[1];
|
|
7392
|
-
let namespace,
|
|
7367
|
+
let namespace, l2;
|
|
7393
7368
|
if (listener) {
|
|
7394
7369
|
if (bag[ev] && bag[ev][ns || "*"]) {
|
|
7395
7370
|
n.removeEventListener(ev, bag[ev][ns || "*"][listener], options || false);
|
|
@@ -7397,8 +7372,8 @@ function off(node, events, listener, options) {
|
|
|
7397
7372
|
}
|
|
7398
7373
|
} else if (ev && ns) {
|
|
7399
7374
|
if (bag[ev] && bag[ev][ns]) {
|
|
7400
|
-
for (
|
|
7401
|
-
off(n, [ev, ns].join("."),
|
|
7375
|
+
for (l2 in bag[ev][ns]) {
|
|
7376
|
+
off(n, [ev, ns].join("."), l2);
|
|
7402
7377
|
}
|
|
7403
7378
|
delete bag[ev][ns];
|
|
7404
7379
|
}
|
|
@@ -7978,8 +7953,8 @@ class Element extends Dom {
|
|
|
7978
7953
|
}
|
|
7979
7954
|
// Get parent document
|
|
7980
7955
|
root() {
|
|
7981
|
-
const
|
|
7982
|
-
return
|
|
7956
|
+
const p2 = this.parent(getClass(root));
|
|
7957
|
+
return p2 && p2.root();
|
|
7983
7958
|
}
|
|
7984
7959
|
// set given data to the elements data property
|
|
7985
7960
|
setData(o) {
|
|
@@ -7988,8 +7963,8 @@ class Element extends Dom {
|
|
|
7988
7963
|
}
|
|
7989
7964
|
// Set element size to given width and height
|
|
7990
7965
|
size(width2, height2) {
|
|
7991
|
-
const
|
|
7992
|
-
return this.width(new SVGNumber(
|
|
7966
|
+
const p2 = proportionalSize(this, width2, height2);
|
|
7967
|
+
return this.width(new SVGNumber(p2.width)).height(new SVGNumber(p2.height));
|
|
7993
7968
|
}
|
|
7994
7969
|
// Set width of element
|
|
7995
7970
|
width(width2) {
|
|
@@ -8050,11 +8025,11 @@ const sugar = {
|
|
|
8050
8025
|
});
|
|
8051
8026
|
registerMethods(["Element", "Runner"], {
|
|
8052
8027
|
// Let the user set the matrix directly
|
|
8053
|
-
matrix: function(mat, b2,
|
|
8028
|
+
matrix: function(mat, b2, c, d, e, f) {
|
|
8054
8029
|
if (mat == null) {
|
|
8055
8030
|
return new Matrix(this);
|
|
8056
8031
|
}
|
|
8057
|
-
return this.attr("transform", new Matrix(mat, b2,
|
|
8032
|
+
return this.attr("transform", new Matrix(mat, b2, c, d, e, f));
|
|
8058
8033
|
},
|
|
8059
8034
|
// Map rotation to transform
|
|
8060
8035
|
rotate: function(angle, cx2, cy2) {
|
|
@@ -8142,12 +8117,12 @@ registerMethods("Path", {
|
|
|
8142
8117
|
});
|
|
8143
8118
|
registerMethods(["Element", "Runner"], {
|
|
8144
8119
|
// Set font
|
|
8145
|
-
font: function(a,
|
|
8120
|
+
font: function(a, v3) {
|
|
8146
8121
|
if (typeof a === "object") {
|
|
8147
|
-
for (
|
|
8122
|
+
for (v3 in a) this.font(v3, a[v3]);
|
|
8148
8123
|
return this;
|
|
8149
8124
|
}
|
|
8150
|
-
return a === "leading" ? this.leading(
|
|
8125
|
+
return a === "leading" ? this.leading(v3) : a === "anchor" ? this.attr("text-anchor", v3) : a === "size" || a === "family" || a === "weight" || a === "stretch" || a === "variant" || a === "style" ? this.attr("font-" + a, v3) : this.attr(a, v3);
|
|
8151
8126
|
}
|
|
8152
8127
|
});
|
|
8153
8128
|
const methods = ["click", "dblclick", "mousedown", "mouseup", "mouseover", "mouseout", "mousemove", "mouseenter", "mouseleave", "touchstart", "touchmove", "touchleave", "touchend", "touchcancel"].reduce(function(last, event) {
|
|
@@ -8285,8 +8260,8 @@ class Ellipse extends Shape {
|
|
|
8285
8260
|
super(nodeOrNew("ellipse", node), attrs2);
|
|
8286
8261
|
}
|
|
8287
8262
|
size(width2, height2) {
|
|
8288
|
-
const
|
|
8289
|
-
return this.rx(new SVGNumber(
|
|
8263
|
+
const p2 = proportionalSize(this, width2, height2);
|
|
8264
|
+
return this.rx(new SVGNumber(p2.width).divide(2)).ry(new SVGNumber(p2.height).divide(2));
|
|
8290
8265
|
}
|
|
8291
8266
|
}
|
|
8292
8267
|
extend(Ellipse, circled);
|
|
@@ -8345,9 +8320,9 @@ class Gradient extends Container {
|
|
|
8345
8320
|
super(nodeOrNew(type + "Gradient", typeof type === "string" ? null : type), attrs2);
|
|
8346
8321
|
}
|
|
8347
8322
|
// custom attr to handle transform
|
|
8348
|
-
attr(a, b2,
|
|
8323
|
+
attr(a, b2, c) {
|
|
8349
8324
|
if (a === "transform") a = "gradientTransform";
|
|
8350
|
-
return super.attr(a, b2,
|
|
8325
|
+
return super.attr(a, b2, c);
|
|
8351
8326
|
}
|
|
8352
8327
|
bbox() {
|
|
8353
8328
|
return new Box();
|
|
@@ -8394,9 +8369,9 @@ class Pattern extends Container {
|
|
|
8394
8369
|
super(nodeOrNew("pattern", node), attrs2);
|
|
8395
8370
|
}
|
|
8396
8371
|
// custom attr to handle transform
|
|
8397
|
-
attr(a, b2,
|
|
8372
|
+
attr(a, b2, c) {
|
|
8398
8373
|
if (a === "transform") a = "patternTransform";
|
|
8399
|
-
return super.attr(a, b2,
|
|
8374
|
+
return super.attr(a, b2, c);
|
|
8400
8375
|
}
|
|
8401
8376
|
bbox() {
|
|
8402
8377
|
return new Box();
|
|
@@ -8450,13 +8425,13 @@ class Image extends Shape {
|
|
|
8450
8425
|
if (!url) return this;
|
|
8451
8426
|
const img = new globals.window.Image();
|
|
8452
8427
|
on(img, "load", function(e) {
|
|
8453
|
-
const
|
|
8428
|
+
const p2 = this.parent(Pattern);
|
|
8454
8429
|
if (this.width() === 0 && this.height() === 0) {
|
|
8455
8430
|
this.size(img.width, img.height);
|
|
8456
8431
|
}
|
|
8457
|
-
if (
|
|
8458
|
-
if (
|
|
8459
|
-
|
|
8432
|
+
if (p2 instanceof Pattern) {
|
|
8433
|
+
if (p2.width() === 0 && p2.height() === 0) {
|
|
8434
|
+
p2.size(this.width(), this.height());
|
|
8460
8435
|
}
|
|
8461
8436
|
}
|
|
8462
8437
|
if (typeof callback === "function") {
|
|
@@ -8629,8 +8604,8 @@ class Line extends Shape {
|
|
|
8629
8604
|
}
|
|
8630
8605
|
// Set element size to given width and height
|
|
8631
8606
|
size(width2, height2) {
|
|
8632
|
-
const
|
|
8633
|
-
return this.attr(this.array().size(
|
|
8607
|
+
const p2 = proportionalSize(this, width2, height2);
|
|
8608
|
+
return this.attr(this.array().size(p2.width, p2.height).toLine());
|
|
8634
8609
|
}
|
|
8635
8610
|
}
|
|
8636
8611
|
extend(Line, pointed);
|
|
@@ -8701,9 +8676,9 @@ registerMethods({
|
|
|
8701
8676
|
});
|
|
8702
8677
|
register(Marker, "Marker");
|
|
8703
8678
|
function makeSetterGetter(k3, f) {
|
|
8704
|
-
return function(
|
|
8705
|
-
if (
|
|
8706
|
-
this[k3] =
|
|
8679
|
+
return function(v3) {
|
|
8680
|
+
if (v3 == null) return this[k3];
|
|
8681
|
+
this[k3] = v3;
|
|
8707
8682
|
if (f) f.call(this);
|
|
8708
8683
|
return this;
|
|
8709
8684
|
};
|
|
@@ -8794,11 +8769,11 @@ class Controller extends Stepper {
|
|
|
8794
8769
|
super();
|
|
8795
8770
|
this.stepper = fn;
|
|
8796
8771
|
}
|
|
8797
|
-
done(
|
|
8798
|
-
return
|
|
8772
|
+
done(c) {
|
|
8773
|
+
return c.done;
|
|
8799
8774
|
}
|
|
8800
|
-
step(current, target, dt,
|
|
8801
|
-
return this.stepper(current, target, dt,
|
|
8775
|
+
step(current, target, dt, c) {
|
|
8776
|
+
return this.stepper(current, target, dt, c);
|
|
8802
8777
|
}
|
|
8803
8778
|
}
|
|
8804
8779
|
function recalculate() {
|
|
@@ -8817,19 +8792,19 @@ class Spring extends Controller {
|
|
|
8817
8792
|
super();
|
|
8818
8793
|
this.duration(duration).overshoot(overshoot);
|
|
8819
8794
|
}
|
|
8820
|
-
step(current, target, dt,
|
|
8795
|
+
step(current, target, dt, c) {
|
|
8821
8796
|
if (typeof current === "string") return current;
|
|
8822
|
-
|
|
8797
|
+
c.done = dt === Infinity;
|
|
8823
8798
|
if (dt === Infinity) return target;
|
|
8824
8799
|
if (dt === 0) return current;
|
|
8825
8800
|
if (dt > 100) dt = 16;
|
|
8826
8801
|
dt /= 1e3;
|
|
8827
|
-
const velocity =
|
|
8802
|
+
const velocity = c.velocity || 0;
|
|
8828
8803
|
const acceleration = -this.d * velocity - this.k * (current - target);
|
|
8829
8804
|
const newPosition = current + velocity * dt + acceleration * dt * dt / 2;
|
|
8830
|
-
|
|
8831
|
-
|
|
8832
|
-
return
|
|
8805
|
+
c.velocity = velocity + acceleration * dt;
|
|
8806
|
+
c.done = Math.abs(target - newPosition) + Math.abs(velocity) < 2e-3;
|
|
8807
|
+
return c.done ? target : newPosition;
|
|
8833
8808
|
}
|
|
8834
8809
|
}
|
|
8835
8810
|
extend(Spring, {
|
|
@@ -8837,26 +8812,26 @@ extend(Spring, {
|
|
|
8837
8812
|
overshoot: makeSetterGetter("_overshoot", recalculate)
|
|
8838
8813
|
});
|
|
8839
8814
|
class PID extends Controller {
|
|
8840
|
-
constructor(
|
|
8815
|
+
constructor(p2 = 0.1, i = 0.01, d = 0, windup = 1e3) {
|
|
8841
8816
|
super();
|
|
8842
|
-
this.p(
|
|
8817
|
+
this.p(p2).i(i).d(d).windup(windup);
|
|
8843
8818
|
}
|
|
8844
|
-
step(current, target, dt,
|
|
8819
|
+
step(current, target, dt, c) {
|
|
8845
8820
|
if (typeof current === "string") return current;
|
|
8846
|
-
|
|
8821
|
+
c.done = dt === Infinity;
|
|
8847
8822
|
if (dt === Infinity) return target;
|
|
8848
8823
|
if (dt === 0) return current;
|
|
8849
|
-
const
|
|
8850
|
-
let i = (
|
|
8851
|
-
const d = (
|
|
8824
|
+
const p2 = target - current;
|
|
8825
|
+
let i = (c.integral || 0) + p2 * dt;
|
|
8826
|
+
const d = (p2 - (c.error || 0)) / dt;
|
|
8852
8827
|
const windup = this._windup;
|
|
8853
8828
|
if (windup !== false) {
|
|
8854
8829
|
i = Math.max(-windup, Math.min(i, windup));
|
|
8855
8830
|
}
|
|
8856
|
-
|
|
8857
|
-
|
|
8858
|
-
|
|
8859
|
-
return
|
|
8831
|
+
c.error = p2;
|
|
8832
|
+
c.integral = i;
|
|
8833
|
+
c.done = Math.abs(p2) < 1e-3;
|
|
8834
|
+
return c.done ? target : current + (this.P * p2 + this.I * i + this.D * d);
|
|
8860
8835
|
}
|
|
8861
8836
|
}
|
|
8862
8837
|
extend(PID, {
|
|
@@ -8878,72 +8853,72 @@ const segmentParameters = {
|
|
|
8878
8853
|
Z: 0
|
|
8879
8854
|
};
|
|
8880
8855
|
const pathHandlers = {
|
|
8881
|
-
M: function(
|
|
8882
|
-
|
|
8883
|
-
|
|
8884
|
-
return ["M",
|
|
8856
|
+
M: function(c, p2, p0) {
|
|
8857
|
+
p2.x = p0.x = c[0];
|
|
8858
|
+
p2.y = p0.y = c[1];
|
|
8859
|
+
return ["M", p2.x, p2.y];
|
|
8885
8860
|
},
|
|
8886
|
-
L: function(
|
|
8887
|
-
|
|
8888
|
-
|
|
8889
|
-
return ["L",
|
|
8861
|
+
L: function(c, p2) {
|
|
8862
|
+
p2.x = c[0];
|
|
8863
|
+
p2.y = c[1];
|
|
8864
|
+
return ["L", c[0], c[1]];
|
|
8890
8865
|
},
|
|
8891
|
-
H: function(
|
|
8892
|
-
|
|
8893
|
-
return ["H",
|
|
8866
|
+
H: function(c, p2) {
|
|
8867
|
+
p2.x = c[0];
|
|
8868
|
+
return ["H", c[0]];
|
|
8894
8869
|
},
|
|
8895
|
-
V: function(
|
|
8896
|
-
|
|
8897
|
-
return ["V",
|
|
8870
|
+
V: function(c, p2) {
|
|
8871
|
+
p2.y = c[0];
|
|
8872
|
+
return ["V", c[0]];
|
|
8898
8873
|
},
|
|
8899
|
-
C: function(
|
|
8900
|
-
|
|
8901
|
-
|
|
8902
|
-
return ["C",
|
|
8874
|
+
C: function(c, p2) {
|
|
8875
|
+
p2.x = c[4];
|
|
8876
|
+
p2.y = c[5];
|
|
8877
|
+
return ["C", c[0], c[1], c[2], c[3], c[4], c[5]];
|
|
8903
8878
|
},
|
|
8904
|
-
S: function(
|
|
8905
|
-
|
|
8906
|
-
|
|
8907
|
-
return ["S",
|
|
8879
|
+
S: function(c, p2) {
|
|
8880
|
+
p2.x = c[2];
|
|
8881
|
+
p2.y = c[3];
|
|
8882
|
+
return ["S", c[0], c[1], c[2], c[3]];
|
|
8908
8883
|
},
|
|
8909
|
-
Q: function(
|
|
8910
|
-
|
|
8911
|
-
|
|
8912
|
-
return ["Q",
|
|
8884
|
+
Q: function(c, p2) {
|
|
8885
|
+
p2.x = c[2];
|
|
8886
|
+
p2.y = c[3];
|
|
8887
|
+
return ["Q", c[0], c[1], c[2], c[3]];
|
|
8913
8888
|
},
|
|
8914
|
-
T: function(
|
|
8915
|
-
|
|
8916
|
-
|
|
8917
|
-
return ["T",
|
|
8889
|
+
T: function(c, p2) {
|
|
8890
|
+
p2.x = c[0];
|
|
8891
|
+
p2.y = c[1];
|
|
8892
|
+
return ["T", c[0], c[1]];
|
|
8918
8893
|
},
|
|
8919
|
-
Z: function(
|
|
8920
|
-
|
|
8921
|
-
|
|
8894
|
+
Z: function(c, p2, p0) {
|
|
8895
|
+
p2.x = p0.x;
|
|
8896
|
+
p2.y = p0.y;
|
|
8922
8897
|
return ["Z"];
|
|
8923
8898
|
},
|
|
8924
|
-
A: function(
|
|
8925
|
-
|
|
8926
|
-
|
|
8927
|
-
return ["A",
|
|
8899
|
+
A: function(c, p2) {
|
|
8900
|
+
p2.x = c[5];
|
|
8901
|
+
p2.y = c[6];
|
|
8902
|
+
return ["A", c[0], c[1], c[2], c[3], c[4], c[5], c[6]];
|
|
8928
8903
|
}
|
|
8929
8904
|
};
|
|
8930
8905
|
const mlhvqtcsaz = "mlhvqtcsaz".split("");
|
|
8931
8906
|
for (let i = 0, il = mlhvqtcsaz.length; i < il; ++i) {
|
|
8932
|
-
pathHandlers[mlhvqtcsaz[i]] = /* @__PURE__ */ function(i2) {
|
|
8933
|
-
return function(
|
|
8934
|
-
if (i2 === "H")
|
|
8935
|
-
else if (i2 === "V")
|
|
8907
|
+
pathHandlers[mlhvqtcsaz[i]] = /* @__PURE__ */ (function(i2) {
|
|
8908
|
+
return function(c, p2, p0) {
|
|
8909
|
+
if (i2 === "H") c[0] = c[0] + p2.x;
|
|
8910
|
+
else if (i2 === "V") c[0] = c[0] + p2.y;
|
|
8936
8911
|
else if (i2 === "A") {
|
|
8937
|
-
|
|
8938
|
-
|
|
8912
|
+
c[5] = c[5] + p2.x;
|
|
8913
|
+
c[6] = c[6] + p2.y;
|
|
8939
8914
|
} else {
|
|
8940
|
-
for (let j = 0, jl =
|
|
8941
|
-
|
|
8915
|
+
for (let j = 0, jl = c.length; j < jl; ++j) {
|
|
8916
|
+
c[j] = c[j] + (j % 2 ? p2.y : p2.x);
|
|
8942
8917
|
}
|
|
8943
8918
|
}
|
|
8944
|
-
return pathHandlers[i2](
|
|
8919
|
+
return pathHandlers[i2](c, p2, p0);
|
|
8945
8920
|
};
|
|
8946
|
-
}(mlhvqtcsaz[i].toUpperCase());
|
|
8921
|
+
})(mlhvqtcsaz[i].toUpperCase());
|
|
8947
8922
|
}
|
|
8948
8923
|
function makeAbsolut(parser2) {
|
|
8949
8924
|
const command = parser2.segment[0];
|
|
@@ -9120,25 +9095,25 @@ class PathArray extends SVGArray {
|
|
|
9120
9095
|
x2 -= box.x;
|
|
9121
9096
|
y2 -= box.y;
|
|
9122
9097
|
if (!isNaN(x2) && !isNaN(y2)) {
|
|
9123
|
-
for (let
|
|
9124
|
-
|
|
9125
|
-
if (
|
|
9098
|
+
for (let l2, i = this.length - 1; i >= 0; i--) {
|
|
9099
|
+
l2 = this[i][0];
|
|
9100
|
+
if (l2 === "M" || l2 === "L" || l2 === "T") {
|
|
9126
9101
|
this[i][1] += x2;
|
|
9127
9102
|
this[i][2] += y2;
|
|
9128
|
-
} else if (
|
|
9103
|
+
} else if (l2 === "H") {
|
|
9129
9104
|
this[i][1] += x2;
|
|
9130
|
-
} else if (
|
|
9105
|
+
} else if (l2 === "V") {
|
|
9131
9106
|
this[i][1] += y2;
|
|
9132
|
-
} else if (
|
|
9107
|
+
} else if (l2 === "C" || l2 === "S" || l2 === "Q") {
|
|
9133
9108
|
this[i][1] += x2;
|
|
9134
9109
|
this[i][2] += y2;
|
|
9135
9110
|
this[i][3] += x2;
|
|
9136
9111
|
this[i][4] += y2;
|
|
9137
|
-
if (
|
|
9112
|
+
if (l2 === "C") {
|
|
9138
9113
|
this[i][5] += x2;
|
|
9139
9114
|
this[i][6] += y2;
|
|
9140
9115
|
}
|
|
9141
|
-
} else if (
|
|
9116
|
+
} else if (l2 === "A") {
|
|
9142
9117
|
this[i][6] += x2;
|
|
9143
9118
|
this[i][7] += y2;
|
|
9144
9119
|
}
|
|
@@ -9156,28 +9131,28 @@ class PathArray extends SVGArray {
|
|
|
9156
9131
|
// Resize path string
|
|
9157
9132
|
size(width2, height2) {
|
|
9158
9133
|
const box = this.bbox();
|
|
9159
|
-
let i,
|
|
9134
|
+
let i, l2;
|
|
9160
9135
|
box.width = box.width === 0 ? 1 : box.width;
|
|
9161
9136
|
box.height = box.height === 0 ? 1 : box.height;
|
|
9162
9137
|
for (i = this.length - 1; i >= 0; i--) {
|
|
9163
|
-
|
|
9164
|
-
if (
|
|
9138
|
+
l2 = this[i][0];
|
|
9139
|
+
if (l2 === "M" || l2 === "L" || l2 === "T") {
|
|
9165
9140
|
this[i][1] = (this[i][1] - box.x) * width2 / box.width + box.x;
|
|
9166
9141
|
this[i][2] = (this[i][2] - box.y) * height2 / box.height + box.y;
|
|
9167
|
-
} else if (
|
|
9142
|
+
} else if (l2 === "H") {
|
|
9168
9143
|
this[i][1] = (this[i][1] - box.x) * width2 / box.width + box.x;
|
|
9169
|
-
} else if (
|
|
9144
|
+
} else if (l2 === "V") {
|
|
9170
9145
|
this[i][1] = (this[i][1] - box.y) * height2 / box.height + box.y;
|
|
9171
|
-
} else if (
|
|
9146
|
+
} else if (l2 === "C" || l2 === "S" || l2 === "Q") {
|
|
9172
9147
|
this[i][1] = (this[i][1] - box.x) * width2 / box.width + box.x;
|
|
9173
9148
|
this[i][2] = (this[i][2] - box.y) * height2 / box.height + box.y;
|
|
9174
9149
|
this[i][3] = (this[i][3] - box.x) * width2 / box.width + box.x;
|
|
9175
9150
|
this[i][4] = (this[i][4] - box.y) * height2 / box.height + box.y;
|
|
9176
|
-
if (
|
|
9151
|
+
if (l2 === "C") {
|
|
9177
9152
|
this[i][5] = (this[i][5] - box.x) * width2 / box.width + box.x;
|
|
9178
9153
|
this[i][6] = (this[i][6] - box.y) * height2 / box.height + box.y;
|
|
9179
9154
|
}
|
|
9180
|
-
} else if (
|
|
9155
|
+
} else if (l2 === "A") {
|
|
9181
9156
|
this[i][1] = this[i][1] * width2 / box.width;
|
|
9182
9157
|
this[i][2] = this[i][2] * height2 / box.height;
|
|
9183
9158
|
this[i][6] = (this[i][6] - box.x) * width2 / box.width + box.x;
|
|
@@ -9316,8 +9291,8 @@ class TransformBag {
|
|
|
9316
9291
|
return this;
|
|
9317
9292
|
}
|
|
9318
9293
|
toArray() {
|
|
9319
|
-
const
|
|
9320
|
-
return [
|
|
9294
|
+
const v3 = this;
|
|
9295
|
+
return [v3.scaleX, v3.scaleY, v3.shear, v3.rotate, v3.translateX, v3.translateY, v3.originX, v3.originY];
|
|
9321
9296
|
}
|
|
9322
9297
|
}
|
|
9323
9298
|
TransformBag.defaults = {
|
|
@@ -9444,8 +9419,8 @@ class Path extends Shape {
|
|
|
9444
9419
|
}
|
|
9445
9420
|
// Set element size to given width and height
|
|
9446
9421
|
size(width2, height2) {
|
|
9447
|
-
const
|
|
9448
|
-
return this.attr("d", this.array().size(
|
|
9422
|
+
const p2 = proportionalSize(this, width2, height2);
|
|
9423
|
+
return this.attr("d", this.array().size(p2.width, p2.height));
|
|
9449
9424
|
}
|
|
9450
9425
|
// Set width of element
|
|
9451
9426
|
width(width2) {
|
|
@@ -9480,12 +9455,12 @@ function clear2() {
|
|
|
9480
9455
|
function move$2(x2, y2) {
|
|
9481
9456
|
return this.attr("points", this.array().move(x2, y2));
|
|
9482
9457
|
}
|
|
9483
|
-
function plot(
|
|
9484
|
-
return
|
|
9458
|
+
function plot(p2) {
|
|
9459
|
+
return p2 == null ? this.array() : this.clear().attr("points", typeof p2 === "string" ? p2 : this._array = new PointArray(p2));
|
|
9485
9460
|
}
|
|
9486
9461
|
function size$1(width2, height2) {
|
|
9487
|
-
const
|
|
9488
|
-
return this.attr("points", this.array().size(
|
|
9462
|
+
const p2 = proportionalSize(this, width2, height2);
|
|
9463
|
+
return this.attr("points", this.array().size(p2.width, p2.height));
|
|
9489
9464
|
}
|
|
9490
9465
|
var poly = {
|
|
9491
9466
|
__proto__: null,
|
|
@@ -9504,8 +9479,8 @@ class Polygon2 extends Shape {
|
|
|
9504
9479
|
registerMethods({
|
|
9505
9480
|
Container: {
|
|
9506
9481
|
// Create a wrapped polygon element
|
|
9507
|
-
polygon: wrapWithAttrCheck(function(
|
|
9508
|
-
return this.put(new Polygon2()).plot(
|
|
9482
|
+
polygon: wrapWithAttrCheck(function(p2) {
|
|
9483
|
+
return this.put(new Polygon2()).plot(p2 || new PointArray());
|
|
9509
9484
|
})
|
|
9510
9485
|
}
|
|
9511
9486
|
});
|
|
@@ -9521,8 +9496,8 @@ class Polyline extends Shape {
|
|
|
9521
9496
|
registerMethods({
|
|
9522
9497
|
Container: {
|
|
9523
9498
|
// Create a wrapped polygon element
|
|
9524
|
-
polyline: wrapWithAttrCheck(function(
|
|
9525
|
-
return this.put(new Polyline()).plot(
|
|
9499
|
+
polyline: wrapWithAttrCheck(function(p2) {
|
|
9500
|
+
return this.put(new Polyline()).plot(p2 || new PointArray());
|
|
9526
9501
|
})
|
|
9527
9502
|
}
|
|
9528
9503
|
});
|
|
@@ -10027,16 +10002,16 @@ class Runner extends EventTarget {
|
|
|
10027
10002
|
}
|
|
10028
10003
|
return this;
|
|
10029
10004
|
}
|
|
10030
|
-
loops(
|
|
10005
|
+
loops(p2) {
|
|
10031
10006
|
const loopDuration = this._duration + this._wait;
|
|
10032
|
-
if (
|
|
10007
|
+
if (p2 == null) {
|
|
10033
10008
|
const loopsDone = Math.floor(this._time / loopDuration);
|
|
10034
10009
|
const relativeTime = this._time - loopsDone * loopDuration;
|
|
10035
10010
|
const position2 = relativeTime / this._duration;
|
|
10036
10011
|
return Math.min(loopsDone + position2, this._times);
|
|
10037
10012
|
}
|
|
10038
|
-
const whole = Math.floor(
|
|
10039
|
-
const partial =
|
|
10013
|
+
const whole = Math.floor(p2);
|
|
10014
|
+
const partial = p2 % 1;
|
|
10040
10015
|
const time = loopDuration * whole + this._duration * partial;
|
|
10041
10016
|
return this.time(time);
|
|
10042
10017
|
}
|
|
@@ -10045,7 +10020,7 @@ class Runner extends EventTarget {
|
|
|
10045
10020
|
this._persist = dtOrForever;
|
|
10046
10021
|
return this;
|
|
10047
10022
|
}
|
|
10048
|
-
position(
|
|
10023
|
+
position(p2) {
|
|
10049
10024
|
const x2 = this._time;
|
|
10050
10025
|
const d = this._duration;
|
|
10051
10026
|
const w = this._wait;
|
|
@@ -10053,7 +10028,7 @@ class Runner extends EventTarget {
|
|
|
10053
10028
|
const s = this._swing;
|
|
10054
10029
|
const r = this._reverse;
|
|
10055
10030
|
let position2;
|
|
10056
|
-
if (
|
|
10031
|
+
if (p2 == null) {
|
|
10057
10032
|
const f = function(x3) {
|
|
10058
10033
|
const swinging = s * Math.floor(x3 % (2 * (w + d)) / (w + d));
|
|
10059
10034
|
const backwards = swinging && !r || !swinging && r;
|
|
@@ -10068,14 +10043,14 @@ class Runner extends EventTarget {
|
|
|
10068
10043
|
const loopsDone = Math.floor(this.loops());
|
|
10069
10044
|
const swingForward = s && loopsDone % 2 === 0;
|
|
10070
10045
|
const forwards = swingForward && !r || r && swingForward;
|
|
10071
|
-
position2 = loopsDone + (forwards ?
|
|
10046
|
+
position2 = loopsDone + (forwards ? p2 : 1 - p2);
|
|
10072
10047
|
return this.loops(position2);
|
|
10073
10048
|
}
|
|
10074
|
-
progress(
|
|
10075
|
-
if (
|
|
10049
|
+
progress(p2) {
|
|
10050
|
+
if (p2 == null) {
|
|
10076
10051
|
return Math.min(1, this._time / this.duration());
|
|
10077
10052
|
}
|
|
10078
|
-
return this.time(
|
|
10053
|
+
return this.time(p2 * this.duration());
|
|
10079
10054
|
}
|
|
10080
10055
|
/*
|
|
10081
10056
|
Basic Functionality
|
|
@@ -10341,12 +10316,12 @@ registerMethods({
|
|
|
10341
10316
|
});
|
|
10342
10317
|
const difference = (a, b2) => a.filter((x2) => !b2.includes(x2));
|
|
10343
10318
|
extend(Runner, {
|
|
10344
|
-
attr(a,
|
|
10345
|
-
return this.styleAttr("attr", a,
|
|
10319
|
+
attr(a, v3) {
|
|
10320
|
+
return this.styleAttr("attr", a, v3);
|
|
10346
10321
|
},
|
|
10347
10322
|
// Add animatable styles
|
|
10348
|
-
css(s,
|
|
10349
|
-
return this.styleAttr("css", s,
|
|
10323
|
+
css(s, v3) {
|
|
10324
|
+
return this.styleAttr("css", s, v3);
|
|
10350
10325
|
},
|
|
10351
10326
|
styleAttr(type, nameOrAttrs, val) {
|
|
10352
10327
|
if (typeof nameOrAttrs === "string") {
|
|
@@ -10574,9 +10549,9 @@ extend(Runner, {
|
|
|
10574
10549
|
return this._queueNumber("height", height2);
|
|
10575
10550
|
},
|
|
10576
10551
|
// Add animatable plot
|
|
10577
|
-
plot(a, b2,
|
|
10552
|
+
plot(a, b2, c, d) {
|
|
10578
10553
|
if (arguments.length === 4) {
|
|
10579
|
-
return this.plot([a, b2,
|
|
10554
|
+
return this.plot([a, b2, c, d]);
|
|
10580
10555
|
}
|
|
10581
10556
|
if (this._tryRetarget("plot", a)) return this;
|
|
10582
10557
|
const morpher = new Morphable(this._stepper).type(this._element.MorphArray).to(a);
|
|
@@ -10989,8 +10964,8 @@ function dmove(dx2, dy2) {
|
|
|
10989
10964
|
}
|
|
10990
10965
|
const m = new Matrix(child);
|
|
10991
10966
|
const matrix = m.translate(dx2, dy2).transform(m.inverse());
|
|
10992
|
-
const
|
|
10993
|
-
child.move(
|
|
10967
|
+
const p2 = new Point(bbox2.x, bbox2.y).transform(matrix);
|
|
10968
|
+
child.move(p2.x, p2.y);
|
|
10994
10969
|
});
|
|
10995
10970
|
return this;
|
|
10996
10971
|
}
|
|
@@ -11010,9 +10985,9 @@ function move(x2 = 0, y2 = 0, box = this.bbox()) {
|
|
|
11010
10985
|
return this.dmove(dx2, dy2);
|
|
11011
10986
|
}
|
|
11012
10987
|
function size(width2, height2, box = this.bbox()) {
|
|
11013
|
-
const
|
|
11014
|
-
const scaleX =
|
|
11015
|
-
const scaleY =
|
|
10988
|
+
const p2 = proportionalSize(this, width2, height2, box);
|
|
10989
|
+
const scaleX = p2.width / box.width;
|
|
10990
|
+
const scaleY = p2.height / box.height;
|
|
11016
10991
|
this.children().forEach((child, i) => {
|
|
11017
10992
|
const o = new Point(box).transform(new Matrix(child).inverse());
|
|
11018
10993
|
child.scale(scaleX, scaleY, o.x, o.y);
|
|
@@ -11341,7 +11316,7 @@ extend(Shape, {
|
|
|
11341
11316
|
case "rect": {
|
|
11342
11317
|
let {
|
|
11343
11318
|
width: w,
|
|
11344
|
-
height:
|
|
11319
|
+
height: h,
|
|
11345
11320
|
rx: rx2,
|
|
11346
11321
|
ry: ry2,
|
|
11347
11322
|
x: x2,
|
|
@@ -11352,17 +11327,17 @@ extend(Shape, {
|
|
|
11352
11327
|
rx2 = rx2 || ry2;
|
|
11353
11328
|
ry2 = ry2 || rx2;
|
|
11354
11329
|
if (rx2 > w / 2) rx2 = w / 2;
|
|
11355
|
-
if (ry2 >
|
|
11330
|
+
if (ry2 > h / 2) ry2 = h / 2;
|
|
11356
11331
|
if (rx2 && ry2) {
|
|
11357
11332
|
d = [
|
|
11358
11333
|
["M", rx2 + x2, y2],
|
|
11359
11334
|
["h", w - 2 * rx2],
|
|
11360
11335
|
["a", rx2, ry2, 0, 0, 1, rx2, ry2],
|
|
11361
|
-
["v",
|
|
11336
|
+
["v", h - 2 * ry2],
|
|
11362
11337
|
["a", rx2, ry2, 0, 0, 1, -rx2, ry2],
|
|
11363
11338
|
["h", -w + 2 * rx2],
|
|
11364
11339
|
["a", rx2, ry2, 0, 0, 1, -rx2, -ry2],
|
|
11365
|
-
["v", -
|
|
11340
|
+
["v", -h + 2 * ry2],
|
|
11366
11341
|
["a", rx2, ry2, 0, 0, 1, rx2, -ry2],
|
|
11367
11342
|
["z"]
|
|
11368
11343
|
];
|
|
@@ -11370,9 +11345,9 @@ extend(Shape, {
|
|
|
11370
11345
|
d = [
|
|
11371
11346
|
["M", x2, y2],
|
|
11372
11347
|
["h", w],
|
|
11373
|
-
["v",
|
|
11348
|
+
["v", h],
|
|
11374
11349
|
["h", -w],
|
|
11375
|
-
["v", -
|
|
11350
|
+
["v", -h],
|
|
11376
11351
|
["z"]
|
|
11377
11352
|
];
|
|
11378
11353
|
}
|
|
@@ -11492,13 +11467,13 @@ function getSVGPath(contour, holes, closed, strokeStyle, fillStyle, fillImage, p
|
|
|
11492
11467
|
}
|
|
11493
11468
|
function getSVGPathCommands(points, closed = true) {
|
|
11494
11469
|
const cmds = new Array();
|
|
11495
|
-
let
|
|
11470
|
+
let p2;
|
|
11496
11471
|
if (points.length > 0) {
|
|
11497
|
-
|
|
11498
|
-
cmds.push(["M", round(
|
|
11472
|
+
p2 = points[0];
|
|
11473
|
+
cmds.push(["M", round(p2.x), round(p2.y)]);
|
|
11499
11474
|
for (let i = 1; i < points.length; i++) {
|
|
11500
|
-
|
|
11501
|
-
cmds.push(["L", round(
|
|
11475
|
+
p2 = points[i];
|
|
11476
|
+
cmds.push(["L", round(p2.x), round(p2.y)]);
|
|
11502
11477
|
}
|
|
11503
11478
|
if (closed) {
|
|
11504
11479
|
cmds.push(["Z"]);
|
|
@@ -11564,7 +11539,7 @@ class FillPass extends DrawPass {
|
|
|
11564
11539
|
svg2.add(group);
|
|
11565
11540
|
for (const mesh of viewmap.meshes) {
|
|
11566
11541
|
if (mesh.drawFills) {
|
|
11567
|
-
const polygons = viewmap.polygons.filter((
|
|
11542
|
+
const polygons = viewmap.polygons.filter((p2) => p2.mesh === mesh);
|
|
11568
11543
|
const objectGroup = new G({ id: mesh.name });
|
|
11569
11544
|
group.add(objectGroup);
|
|
11570
11545
|
for (const polygon of polygons) {
|
|
@@ -11615,7 +11590,7 @@ class FillPass extends DrawPass {
|
|
|
11615
11590
|
}
|
|
11616
11591
|
}
|
|
11617
11592
|
if (img) {
|
|
11618
|
-
const patternAndImages = svg2.defs().children().filter((
|
|
11593
|
+
const patternAndImages = svg2.defs().children().filter((c) => c instanceof Pattern && c.children().length === 1).map((c) => [c, c.children()[0]]);
|
|
11619
11594
|
patternAndImages.forEach(([pattern, image]) => {
|
|
11620
11595
|
pattern.x(0);
|
|
11621
11596
|
pattern.y(0);
|
|
@@ -11700,7 +11675,7 @@ class VisibleChainPass extends ChainPass {
|
|
|
11700
11675
|
super(options);
|
|
11701
11676
|
}
|
|
11702
11677
|
async draw(svg2, viewmap) {
|
|
11703
|
-
const chains = viewmap.chains.filter((
|
|
11678
|
+
const chains = viewmap.chains.filter((c) => c.visibility === ChainVisibility.Visible);
|
|
11704
11679
|
const meshes = Array.from(viewmap.meshes).filter((m) => m.drawVisibleContours);
|
|
11705
11680
|
const group = new G({ id: "visible-contours" });
|
|
11706
11681
|
drawChains(group, meshes, chains, this.options);
|
|
@@ -11722,7 +11697,7 @@ class HiddenChainPass extends ChainPass {
|
|
|
11722
11697
|
}
|
|
11723
11698
|
async draw(svg2, viewmap) {
|
|
11724
11699
|
const chains = viewmap.chains.filter(
|
|
11725
|
-
(
|
|
11700
|
+
(c) => c.visibility === ChainVisibility.Hidden
|
|
11726
11701
|
);
|
|
11727
11702
|
const meshes = Array.from(viewmap.meshes).filter((m) => m.drawHiddenContours);
|
|
11728
11703
|
const group = new G({ id: "hidden-contours" });
|
|
@@ -11731,19 +11706,18 @@ class HiddenChainPass extends ChainPass {
|
|
|
11731
11706
|
}
|
|
11732
11707
|
}
|
|
11733
11708
|
function drawChains(parent, meshes, chains, options) {
|
|
11734
|
-
var _a;
|
|
11735
11709
|
const { defaultStyle, styles } = options;
|
|
11736
11710
|
ViewEdgesNatures.sort(
|
|
11737
11711
|
(n1, n2) => (styles[n1].drawOrder ?? 0) - (styles[n2].drawOrder ?? 0)
|
|
11738
11712
|
);
|
|
11739
11713
|
for (const mesh of meshes) {
|
|
11740
|
-
const objectChains = chains.filter((
|
|
11714
|
+
const objectChains = chains.filter((c) => c.object === mesh);
|
|
11741
11715
|
const objectGroup = new G({ id: mesh.name });
|
|
11742
11716
|
parent.add(objectGroup);
|
|
11743
11717
|
for (const nature of ViewEdgesNatures) {
|
|
11744
|
-
if (
|
|
11718
|
+
if (styles[nature]?.enabled) {
|
|
11745
11719
|
const strokeStyle = { ...defaultStyle, ...styles[nature] };
|
|
11746
|
-
const natureChains = objectChains.filter((
|
|
11720
|
+
const natureChains = objectChains.filter((c) => c.nature === nature);
|
|
11747
11721
|
const natureGroup = new G({ id: nature });
|
|
11748
11722
|
objectGroup.add(natureGroup);
|
|
11749
11723
|
for (const chain of natureChains) {
|
|
@@ -11790,7 +11764,7 @@ function getLegend(options) {
|
|
|
11790
11764
|
}
|
|
11791
11765
|
const EPSILON = 1e-10;
|
|
11792
11766
|
const _matrix = new Matrix4$1();
|
|
11793
|
-
function orient3D(a, b2,
|
|
11767
|
+
function orient3D(a, b2, c, d) {
|
|
11794
11768
|
_matrix.set(
|
|
11795
11769
|
a.x,
|
|
11796
11770
|
a.y,
|
|
@@ -11800,9 +11774,9 @@ function orient3D(a, b2, c2, d) {
|
|
|
11800
11774
|
b2.y,
|
|
11801
11775
|
b2.z,
|
|
11802
11776
|
1,
|
|
11803
|
-
|
|
11804
|
-
|
|
11805
|
-
|
|
11777
|
+
c.x,
|
|
11778
|
+
c.y,
|
|
11779
|
+
c.z,
|
|
11806
11780
|
1,
|
|
11807
11781
|
d.x,
|
|
11808
11782
|
d.y,
|
|
@@ -11817,8 +11791,8 @@ function orient3D(a, b2, c2, d) {
|
|
|
11817
11791
|
}
|
|
11818
11792
|
return 0;
|
|
11819
11793
|
}
|
|
11820
|
-
function frontSide(a, b2,
|
|
11821
|
-
return orient3D(d, b2,
|
|
11794
|
+
function frontSide(a, b2, c, d) {
|
|
11795
|
+
return orient3D(d, b2, c, a);
|
|
11822
11796
|
}
|
|
11823
11797
|
const _u$1 = new Vector3$1();
|
|
11824
11798
|
const _v = new Vector3$1();
|
|
@@ -11895,21 +11869,21 @@ class Halfedge {
|
|
|
11895
11869
|
return null;
|
|
11896
11870
|
}
|
|
11897
11871
|
}
|
|
11898
|
-
function addEdge(struct, v1,
|
|
11899
|
-
if (v1 ===
|
|
11872
|
+
function addEdge(struct, v1, v22, allowParallels = false) {
|
|
11873
|
+
if (v1 === v22) {
|
|
11900
11874
|
throw new Error("Vertices v1 and v2 should be different");
|
|
11901
11875
|
}
|
|
11902
11876
|
if (!allowParallels) {
|
|
11903
|
-
const currentHalfEdge = v1.getHalfedgeToVertex(
|
|
11877
|
+
const currentHalfEdge = v1.getHalfedgeToVertex(v22);
|
|
11904
11878
|
if (currentHalfEdge) {
|
|
11905
11879
|
return currentHalfEdge;
|
|
11906
11880
|
}
|
|
11907
11881
|
}
|
|
11908
|
-
if (!v1.isFree() || !
|
|
11882
|
+
if (!v1.isFree() || !v22.isFree()) {
|
|
11909
11883
|
throw new Error("Vertices v1 and v2 are not free");
|
|
11910
11884
|
}
|
|
11911
11885
|
const h1 = new Halfedge(v1);
|
|
11912
|
-
const h2 = new Halfedge(
|
|
11886
|
+
const h2 = new Halfedge(v22);
|
|
11913
11887
|
h1.twin = h2;
|
|
11914
11888
|
h1.next = h2;
|
|
11915
11889
|
h1.prev = h2;
|
|
@@ -11926,7 +11900,7 @@ function addEdge(struct, v1, v2, allowParallels = false) {
|
|
|
11926
11900
|
} else {
|
|
11927
11901
|
v1.halfedge = h1;
|
|
11928
11902
|
}
|
|
11929
|
-
const in2 =
|
|
11903
|
+
const in2 = v22.freeHalfedgesInLoop().next().value;
|
|
11930
11904
|
if (in2) {
|
|
11931
11905
|
const out2 = in2.next;
|
|
11932
11906
|
h2.prev = in2;
|
|
@@ -11934,7 +11908,7 @@ function addEdge(struct, v1, v2, allowParallels = false) {
|
|
|
11934
11908
|
h1.next = out2;
|
|
11935
11909
|
out2.prev = h1;
|
|
11936
11910
|
} else {
|
|
11937
|
-
|
|
11911
|
+
v22.halfedge = h2;
|
|
11938
11912
|
}
|
|
11939
11913
|
struct.halfedges.push(h1);
|
|
11940
11914
|
struct.halfedges.push(h2);
|
|
@@ -12073,13 +12047,13 @@ function makeHalfedgesAdjacent(halfIn, halfOut) {
|
|
|
12073
12047
|
}
|
|
12074
12048
|
const b2 = halfIn.next;
|
|
12075
12049
|
const d = halfOut.prev;
|
|
12076
|
-
const
|
|
12050
|
+
const h = g.next;
|
|
12077
12051
|
halfIn.next = halfOut;
|
|
12078
12052
|
halfOut.prev = halfIn;
|
|
12079
12053
|
g.next = b2;
|
|
12080
12054
|
b2.prev = g;
|
|
12081
|
-
d.next =
|
|
12082
|
-
|
|
12055
|
+
d.next = h;
|
|
12056
|
+
h.prev = d;
|
|
12083
12057
|
return true;
|
|
12084
12058
|
}
|
|
12085
12059
|
const _u = new Vector3$1();
|
|
@@ -12246,10 +12220,10 @@ function addVertex(struct, position2, checkDuplicates = false, tolerance = 1e-10
|
|
|
12246
12220
|
}
|
|
12247
12221
|
}
|
|
12248
12222
|
}
|
|
12249
|
-
const
|
|
12250
|
-
|
|
12251
|
-
struct.vertices.push(
|
|
12252
|
-
return
|
|
12223
|
+
const v3 = new Vertex();
|
|
12224
|
+
v3.position.copy(position2);
|
|
12225
|
+
struct.vertices.push(v3);
|
|
12226
|
+
return v3;
|
|
12253
12227
|
}
|
|
12254
12228
|
function removeFace(struct, face) {
|
|
12255
12229
|
if (!struct.faces.remove(face)) {
|
|
@@ -12280,11 +12254,11 @@ function removeEdge(struct, halfedge, mergeFaces = true) {
|
|
|
12280
12254
|
halfedge.prev.next = twin.next;
|
|
12281
12255
|
twin.next.prev = halfedge.prev;
|
|
12282
12256
|
}
|
|
12283
|
-
const
|
|
12257
|
+
const v22 = twin.vertex;
|
|
12284
12258
|
if (halfedge.next === twin) {
|
|
12285
|
-
|
|
12259
|
+
v22.halfedge = null;
|
|
12286
12260
|
} else {
|
|
12287
|
-
|
|
12261
|
+
v22.halfedge = halfedge.next;
|
|
12288
12262
|
halfedge.next.prev = twin.prev;
|
|
12289
12263
|
twin.prev.next = halfedge.next;
|
|
12290
12264
|
}
|
|
@@ -12297,23 +12271,23 @@ function removeVertex(struct, vertex, mergeFaces = true) {
|
|
|
12297
12271
|
}
|
|
12298
12272
|
struct.vertices.remove(vertex);
|
|
12299
12273
|
}
|
|
12300
|
-
function cutFace(struct, face, v1,
|
|
12301
|
-
if (v1 ===
|
|
12274
|
+
function cutFace(struct, face, v1, v22, createNewFace = true) {
|
|
12275
|
+
if (v1 === v22) {
|
|
12302
12276
|
throw new Error("Vertices v1 and v2 should be different");
|
|
12303
12277
|
}
|
|
12304
12278
|
let out1 = face.halfedgeFromVertex(v1);
|
|
12305
12279
|
if (!out1 && !v1.isFree()) {
|
|
12306
12280
|
throw new Error("Vertices v1 does not belong to face nor is free");
|
|
12307
12281
|
}
|
|
12308
|
-
let out2 = face.halfedgeFromVertex(
|
|
12309
|
-
if (!out2 && !
|
|
12282
|
+
let out2 = face.halfedgeFromVertex(v22);
|
|
12283
|
+
if (!out2 && !v22.isFree()) {
|
|
12310
12284
|
throw new Error("Vertices v2 does not belong to face nor is free");
|
|
12311
12285
|
}
|
|
12312
|
-
if (out1 && out1.next.vertex ===
|
|
12286
|
+
if (out1 && out1.next.vertex === v22 || out2 && out2.next.vertex === v1) {
|
|
12313
12287
|
throw new Error("Vertices v1 and v2 are already connected");
|
|
12314
12288
|
}
|
|
12315
12289
|
const h1 = new Halfedge(v1);
|
|
12316
|
-
const h2 = new Halfedge(
|
|
12290
|
+
const h2 = new Halfedge(v22);
|
|
12317
12291
|
h1.face = face;
|
|
12318
12292
|
h2.face = face;
|
|
12319
12293
|
h1.twin = h2;
|
|
@@ -12332,7 +12306,7 @@ function cutFace(struct, face, v1, v2, createNewFace = true) {
|
|
|
12332
12306
|
} else {
|
|
12333
12307
|
v1.halfedge = h1;
|
|
12334
12308
|
}
|
|
12335
|
-
out2 = out2 ??
|
|
12309
|
+
out2 = out2 ?? v22.freeHalfedgesOutLoop().next().value;
|
|
12336
12310
|
if (out2) {
|
|
12337
12311
|
const in2 = out2.prev;
|
|
12338
12312
|
h2.prev = in2;
|
|
@@ -12340,7 +12314,7 @@ function cutFace(struct, face, v1, v2, createNewFace = true) {
|
|
|
12340
12314
|
h1.next = out2;
|
|
12341
12315
|
out2.prev = h1;
|
|
12342
12316
|
} else {
|
|
12343
|
-
|
|
12317
|
+
v22.halfedge = h2;
|
|
12344
12318
|
}
|
|
12345
12319
|
struct.halfedges.push(h1);
|
|
12346
12320
|
struct.halfedges.push(h2);
|
|
@@ -12349,10 +12323,10 @@ function cutFace(struct, face, v1, v2, createNewFace = true) {
|
|
|
12349
12323
|
}
|
|
12350
12324
|
let found = false;
|
|
12351
12325
|
const loop = h1.nextLoop();
|
|
12352
|
-
let
|
|
12353
|
-
while (!found && !
|
|
12354
|
-
found =
|
|
12355
|
-
|
|
12326
|
+
let h = loop.next();
|
|
12327
|
+
while (!found && !h.done) {
|
|
12328
|
+
found = h.value === h2;
|
|
12329
|
+
h = loop.next();
|
|
12356
12330
|
}
|
|
12357
12331
|
if (!found) {
|
|
12358
12332
|
face.halfedge = h1;
|
|
@@ -12361,8 +12335,8 @@ function cutFace(struct, face, v1, v2, createNewFace = true) {
|
|
|
12361
12335
|
newFace = new Face(h2);
|
|
12362
12336
|
struct.faces.push(newFace);
|
|
12363
12337
|
}
|
|
12364
|
-
for (const
|
|
12365
|
-
|
|
12338
|
+
for (const h3 of h2.nextLoop()) {
|
|
12339
|
+
h3.face = newFace;
|
|
12366
12340
|
}
|
|
12367
12341
|
}
|
|
12368
12342
|
return h1;
|
|
@@ -12370,22 +12344,22 @@ function cutFace(struct, face, v1, v2, createNewFace = true) {
|
|
|
12370
12344
|
function splitEdge(struct, halfedge, position2, tolerance = 1e-10) {
|
|
12371
12345
|
const twin = halfedge.twin;
|
|
12372
12346
|
const A2 = halfedge.vertex;
|
|
12373
|
-
const
|
|
12347
|
+
const B = twin.vertex;
|
|
12374
12348
|
if (A2.matchesPosition(position2, tolerance)) {
|
|
12375
12349
|
return A2;
|
|
12376
12350
|
}
|
|
12377
|
-
if (
|
|
12378
|
-
return
|
|
12351
|
+
if (B.matchesPosition(position2, tolerance)) {
|
|
12352
|
+
return B;
|
|
12379
12353
|
}
|
|
12380
12354
|
const newVertex = new Vertex();
|
|
12381
12355
|
newVertex.position.copy(position2);
|
|
12382
12356
|
const newHalfedge = new Halfedge(newVertex);
|
|
12383
|
-
const newTwin = new Halfedge(
|
|
12357
|
+
const newTwin = new Halfedge(B);
|
|
12384
12358
|
newHalfedge.twin = newTwin;
|
|
12385
12359
|
newTwin.twin = newHalfedge;
|
|
12386
12360
|
A2.halfedge = halfedge;
|
|
12387
12361
|
newVertex.halfedge = newHalfedge;
|
|
12388
|
-
|
|
12362
|
+
B.halfedge = newTwin;
|
|
12389
12363
|
newHalfedge.face = halfedge.face;
|
|
12390
12364
|
newTwin.face = twin.face;
|
|
12391
12365
|
newHalfedge.next = halfedge.next;
|
|
@@ -12432,18 +12406,18 @@ function setFromGeometry(struct, geometry, tolerance = 1e-10) {
|
|
|
12432
12406
|
vertexMap.set(i1, v1);
|
|
12433
12407
|
}
|
|
12434
12408
|
const i2 = getVertexIndex(faceIndex * 3 + (i + 1) % 3);
|
|
12435
|
-
let
|
|
12436
|
-
if (!
|
|
12409
|
+
let v22 = vertexMap.get(i2);
|
|
12410
|
+
if (!v22) {
|
|
12437
12411
|
pos_.fromBufferAttribute(positions, i2);
|
|
12438
|
-
|
|
12439
|
-
vertexMap.set(i2,
|
|
12412
|
+
v22 = struct.addVertex(pos_);
|
|
12413
|
+
vertexMap.set(i2, v22);
|
|
12440
12414
|
}
|
|
12441
12415
|
const hash1 = i1 + "-" + i2;
|
|
12442
12416
|
let h1 = halfedgeMap.get(hash1);
|
|
12443
|
-
if (h1
|
|
12417
|
+
if (h1?.face) h1 = void 0;
|
|
12444
12418
|
if (!h1) {
|
|
12445
12419
|
try {
|
|
12446
|
-
h1 = struct.addEdge(v1,
|
|
12420
|
+
h1 = struct.addEdge(v1, v22);
|
|
12447
12421
|
addedEdges.push(h1);
|
|
12448
12422
|
const h2 = h1.twin;
|
|
12449
12423
|
const hash2 = i2 + "-" + i1;
|
|
@@ -12547,8 +12521,8 @@ class HalfedgeDS {
|
|
|
12547
12521
|
* @param allowParallels Allows multiple pair of halfedges between vertices, default false
|
|
12548
12522
|
* @returns Existing or new halfedge
|
|
12549
12523
|
*/
|
|
12550
|
-
addEdge(v1,
|
|
12551
|
-
return addEdge(this, v1,
|
|
12524
|
+
addEdge(v1, v22, allowParallels = false) {
|
|
12525
|
+
return addEdge(this, v1, v22, allowParallels);
|
|
12552
12526
|
}
|
|
12553
12527
|
/**
|
|
12554
12528
|
* Adds a face to an existing halfedge loop
|
|
@@ -12602,8 +12576,8 @@ class HalfedgeDS {
|
|
|
12602
12576
|
* @param createNewFace wether to create a new face or not when cutting
|
|
12603
12577
|
* @returns the cutting halfedge
|
|
12604
12578
|
*/
|
|
12605
|
-
cutFace(face, v1,
|
|
12606
|
-
return cutFace(this, face, v1,
|
|
12579
|
+
cutFace(face, v1, v22, createNewFace = true) {
|
|
12580
|
+
return cutFace(this, face, v1, v22, createNewFace);
|
|
12607
12581
|
}
|
|
12608
12582
|
/**
|
|
12609
12583
|
* Splits the halfedge at position and returns the new vertex
|
|
@@ -12636,7 +12610,7 @@ const TRAVERSAL_COST = 1;
|
|
|
12636
12610
|
const BYTES_PER_NODE = 6 * 4 + 4 + 4;
|
|
12637
12611
|
const IS_LEAFNODE_FLAG = 65535;
|
|
12638
12612
|
const FLOAT32_EPSILON = Math.pow(2, -24);
|
|
12639
|
-
const SKIP_GENERATION = Symbol("SKIP_GENERATION");
|
|
12613
|
+
const SKIP_GENERATION = /* @__PURE__ */ Symbol("SKIP_GENERATION");
|
|
12640
12614
|
function getVertexCount(geo) {
|
|
12641
12615
|
return geo.index ? geo.index.count : geo.attributes.position.count;
|
|
12642
12616
|
}
|
|
@@ -12802,22 +12776,22 @@ function computeTriangleBounds(geo, target = null, offset = null, count = null)
|
|
|
12802
12776
|
ci = ci * stride + bufferOffset;
|
|
12803
12777
|
}
|
|
12804
12778
|
for (let el = 0; el < 3; el++) {
|
|
12805
|
-
let a, b2,
|
|
12779
|
+
let a, b2, c;
|
|
12806
12780
|
if (normalized) {
|
|
12807
12781
|
a = posAttr[getters[el]](ai);
|
|
12808
12782
|
b2 = posAttr[getters[el]](bi);
|
|
12809
|
-
|
|
12783
|
+
c = posAttr[getters[el]](ci);
|
|
12810
12784
|
} else {
|
|
12811
12785
|
a = posArr[ai + el];
|
|
12812
12786
|
b2 = posArr[bi + el];
|
|
12813
|
-
|
|
12787
|
+
c = posArr[ci + el];
|
|
12814
12788
|
}
|
|
12815
12789
|
let min2 = a;
|
|
12816
12790
|
if (b2 < min2) min2 = b2;
|
|
12817
|
-
if (
|
|
12791
|
+
if (c < min2) min2 = c;
|
|
12818
12792
|
let max2 = a;
|
|
12819
12793
|
if (b2 > max2) max2 = b2;
|
|
12820
|
-
if (
|
|
12794
|
+
if (c > max2) max2 = c;
|
|
12821
12795
|
const halfExtents = (max2 - min2) / 2;
|
|
12822
12796
|
const el2 = el * 2;
|
|
12823
12797
|
triangleBounds[tri6 + el2 + 0] = min2 + halfExtents;
|
|
@@ -12921,9 +12895,9 @@ function getOptimalSplit(nodeBoundingData, centroidBoundingData, triangleBounds,
|
|
|
12921
12895
|
const truncatedBins = [...sahBins];
|
|
12922
12896
|
truncatedBins.length = count;
|
|
12923
12897
|
let b2 = 0;
|
|
12924
|
-
for (let
|
|
12898
|
+
for (let c = cStart; c < cEnd; c += 6, b2++) {
|
|
12925
12899
|
const bin = truncatedBins[b2];
|
|
12926
|
-
bin.candidate = triangleBounds[
|
|
12900
|
+
bin.candidate = triangleBounds[c + 2 * a];
|
|
12927
12901
|
bin.count = 0;
|
|
12928
12902
|
const {
|
|
12929
12903
|
bounds,
|
|
@@ -12938,7 +12912,7 @@ function getOptimalSplit(nodeBoundingData, centroidBoundingData, triangleBounds,
|
|
|
12938
12912
|
bounds[d] = Infinity;
|
|
12939
12913
|
bounds[d + 3] = -Infinity;
|
|
12940
12914
|
}
|
|
12941
|
-
expandByTriangleBounds(
|
|
12915
|
+
expandByTriangleBounds(c, triangleBounds, bounds);
|
|
12942
12916
|
}
|
|
12943
12917
|
truncatedBins.sort(binsSort);
|
|
12944
12918
|
let splitCount = count;
|
|
@@ -12949,14 +12923,14 @@ function getOptimalSplit(nodeBoundingData, centroidBoundingData, triangleBounds,
|
|
|
12949
12923
|
splitCount--;
|
|
12950
12924
|
}
|
|
12951
12925
|
}
|
|
12952
|
-
for (let
|
|
12953
|
-
const center2 = triangleBounds[
|
|
12926
|
+
for (let c = cStart; c < cEnd; c += 6) {
|
|
12927
|
+
const center2 = triangleBounds[c + 2 * a];
|
|
12954
12928
|
for (let bi = 0; bi < splitCount; bi++) {
|
|
12955
12929
|
const bin = truncatedBins[bi];
|
|
12956
12930
|
if (center2 >= bin.candidate) {
|
|
12957
|
-
expandByTriangleBounds(
|
|
12931
|
+
expandByTriangleBounds(c, triangleBounds, bin.rightCacheBounds);
|
|
12958
12932
|
} else {
|
|
12959
|
-
expandByTriangleBounds(
|
|
12933
|
+
expandByTriangleBounds(c, triangleBounds, bin.leftCacheBounds);
|
|
12960
12934
|
bin.count++;
|
|
12961
12935
|
}
|
|
12962
12936
|
}
|
|
@@ -12993,14 +12967,14 @@ function getOptimalSplit(nodeBoundingData, centroidBoundingData, triangleBounds,
|
|
|
12993
12967
|
bounds[d + 3] = -Infinity;
|
|
12994
12968
|
}
|
|
12995
12969
|
}
|
|
12996
|
-
for (let
|
|
12997
|
-
const triCenter = triangleBounds[
|
|
12970
|
+
for (let c = cStart; c < cEnd; c += 6) {
|
|
12971
|
+
const triCenter = triangleBounds[c + 2 * a];
|
|
12998
12972
|
const relativeCenter = triCenter - axisLeft;
|
|
12999
12973
|
let binIndex = ~~(relativeCenter / binWidth);
|
|
13000
12974
|
if (binIndex >= BIN_COUNT) binIndex = BIN_COUNT - 1;
|
|
13001
12975
|
const bin = sahBins[binIndex];
|
|
13002
12976
|
bin.count++;
|
|
13003
|
-
expandByTriangleBounds(
|
|
12977
|
+
expandByTriangleBounds(c, triangleBounds, bin.bounds);
|
|
13004
12978
|
}
|
|
13005
12979
|
const lastBin = sahBins[BIN_COUNT - 1];
|
|
13006
12980
|
copyBounds(lastBin.bounds, lastBin.rightCacheBounds);
|
|
@@ -13166,7 +13140,7 @@ function _populateBuffer(byteOffset, node) {
|
|
|
13166
13140
|
if (node.buffer) {
|
|
13167
13141
|
const buffer = node.buffer;
|
|
13168
13142
|
uint8Array.set(new Uint8Array(buffer), byteOffset);
|
|
13169
|
-
for (let offset = byteOffset,
|
|
13143
|
+
for (let offset = byteOffset, l2 = byteOffset + buffer.byteLength; offset < l2; offset += BYTES_PER_NODE) {
|
|
13170
13144
|
const offset2 = offset / 2;
|
|
13171
13145
|
if (!IS_LEAF(offset2, uint16Array)) {
|
|
13172
13146
|
uint32Array[offset / 4 + 6] += stride4Offset;
|
|
@@ -13202,7 +13176,7 @@ function generateIndirectBuffer(geometry, useSharedArrayBuffer) {
|
|
|
13202
13176
|
const byteCount = useUint32 ? 4 : 2;
|
|
13203
13177
|
const buffer = useSharedArrayBuffer ? new SharedArrayBuffer(triCount * byteCount) : new ArrayBuffer(triCount * byteCount);
|
|
13204
13178
|
const indirectBuffer = useUint32 ? new Uint32Array(buffer) : new Uint16Array(buffer);
|
|
13205
|
-
for (let i = 0,
|
|
13179
|
+
for (let i = 0, l2 = indirectBuffer.length; i < l2; i++) {
|
|
13206
13180
|
indirectBuffer[i] = i;
|
|
13207
13181
|
}
|
|
13208
13182
|
return indirectBuffer;
|
|
@@ -13308,9 +13282,9 @@ class SeparatingAxisBounds {
|
|
|
13308
13282
|
setFromPointsField(points, field) {
|
|
13309
13283
|
let min2 = Infinity;
|
|
13310
13284
|
let max2 = -Infinity;
|
|
13311
|
-
for (let i = 0,
|
|
13312
|
-
const
|
|
13313
|
-
const val =
|
|
13285
|
+
for (let i = 0, l2 = points.length; i < l2; i++) {
|
|
13286
|
+
const p2 = points[i];
|
|
13287
|
+
const val = p2[field];
|
|
13314
13288
|
min2 = val < min2 ? val : min2;
|
|
13315
13289
|
max2 = val > max2 ? val : max2;
|
|
13316
13290
|
}
|
|
@@ -13320,9 +13294,9 @@ class SeparatingAxisBounds {
|
|
|
13320
13294
|
setFromPoints(axis, points) {
|
|
13321
13295
|
let min2 = Infinity;
|
|
13322
13296
|
let max2 = -Infinity;
|
|
13323
|
-
for (let i = 0,
|
|
13324
|
-
const
|
|
13325
|
-
const val = axis.dot(
|
|
13297
|
+
for (let i = 0, l2 = points.length; i < l2; i++) {
|
|
13298
|
+
const p2 = points[i];
|
|
13299
|
+
const val = axis.dot(p2);
|
|
13326
13300
|
min2 = val < min2 ? val : min2;
|
|
13327
13301
|
max2 = val > max2 ? val : max2;
|
|
13328
13302
|
}
|
|
@@ -13333,8 +13307,8 @@ class SeparatingAxisBounds {
|
|
|
13333
13307
|
return this.min > other.max || other.min > this.max;
|
|
13334
13308
|
}
|
|
13335
13309
|
}
|
|
13336
|
-
SeparatingAxisBounds.prototype.setFromBox = function() {
|
|
13337
|
-
const
|
|
13310
|
+
SeparatingAxisBounds.prototype.setFromBox = (function() {
|
|
13311
|
+
const p2 = new Vector3();
|
|
13338
13312
|
return function setFromBox(axis, box) {
|
|
13339
13313
|
const boxMin = box.min;
|
|
13340
13314
|
const boxMax = box.max;
|
|
@@ -13342,11 +13316,11 @@ SeparatingAxisBounds.prototype.setFromBox = function() {
|
|
|
13342
13316
|
let max2 = -Infinity;
|
|
13343
13317
|
for (let x2 = 0; x2 <= 1; x2++) {
|
|
13344
13318
|
for (let y2 = 0; y2 <= 1; y2++) {
|
|
13345
|
-
for (let
|
|
13346
|
-
|
|
13347
|
-
|
|
13348
|
-
|
|
13349
|
-
const val = axis.dot(
|
|
13319
|
+
for (let z2 = 0; z2 <= 1; z2++) {
|
|
13320
|
+
p2.x = boxMin.x * x2 + boxMax.x * (1 - x2);
|
|
13321
|
+
p2.y = boxMin.y * y2 + boxMax.y * (1 - y2);
|
|
13322
|
+
p2.z = boxMin.z * z2 + boxMax.z * (1 - z2);
|
|
13323
|
+
const val = axis.dot(p2);
|
|
13350
13324
|
min2 = Math.min(val, min2);
|
|
13351
13325
|
max2 = Math.max(val, max2);
|
|
13352
13326
|
}
|
|
@@ -13355,17 +13329,17 @@ SeparatingAxisBounds.prototype.setFromBox = function() {
|
|
|
13355
13329
|
this.min = min2;
|
|
13356
13330
|
this.max = max2;
|
|
13357
13331
|
};
|
|
13358
|
-
}();
|
|
13359
|
-
const closestPointLineToLine = function() {
|
|
13332
|
+
})();
|
|
13333
|
+
const closestPointLineToLine = (function() {
|
|
13360
13334
|
const dir1 = new Vector3();
|
|
13361
13335
|
const dir2 = new Vector3();
|
|
13362
13336
|
const v02 = new Vector3();
|
|
13363
13337
|
return function closestPointLineToLine2(l1, l2, result) {
|
|
13364
13338
|
const v0 = l1.start;
|
|
13365
13339
|
const v10 = dir1;
|
|
13366
|
-
const
|
|
13340
|
+
const v22 = l2.start;
|
|
13367
13341
|
const v32 = dir2;
|
|
13368
|
-
v02.subVectors(v0,
|
|
13342
|
+
v02.subVectors(v0, v22);
|
|
13369
13343
|
dir1.subVectors(l1.end, l1.start);
|
|
13370
13344
|
dir2.subVectors(l2.end, l2.start);
|
|
13371
13345
|
const d0232 = v02.dot(v32);
|
|
@@ -13384,8 +13358,8 @@ const closestPointLineToLine = function() {
|
|
|
13384
13358
|
result.x = d;
|
|
13385
13359
|
result.y = d2;
|
|
13386
13360
|
};
|
|
13387
|
-
}();
|
|
13388
|
-
const closestPointsSegmentToSegment = function() {
|
|
13361
|
+
})();
|
|
13362
|
+
const closestPointsSegmentToSegment = (function() {
|
|
13389
13363
|
const paramResult = new Vector2();
|
|
13390
13364
|
const temp12 = new Vector3();
|
|
13391
13365
|
const temp22 = new Vector3();
|
|
@@ -13414,52 +13388,52 @@ const closestPointsSegmentToSegment = function() {
|
|
|
13414
13388
|
l2.closestPointToPoint(target1, true, target2);
|
|
13415
13389
|
return;
|
|
13416
13390
|
} else {
|
|
13417
|
-
let
|
|
13391
|
+
let p2;
|
|
13418
13392
|
if (d < 0) {
|
|
13419
|
-
|
|
13393
|
+
p2 = l1.start;
|
|
13420
13394
|
} else {
|
|
13421
|
-
|
|
13395
|
+
p2 = l1.end;
|
|
13422
13396
|
}
|
|
13423
|
-
let
|
|
13397
|
+
let p22;
|
|
13424
13398
|
if (d2 < 0) {
|
|
13425
|
-
|
|
13399
|
+
p22 = l2.start;
|
|
13426
13400
|
} else {
|
|
13427
|
-
|
|
13401
|
+
p22 = l2.end;
|
|
13428
13402
|
}
|
|
13429
13403
|
const closestPoint = temp12;
|
|
13430
13404
|
const closestPoint2 = temp22;
|
|
13431
|
-
l1.closestPointToPoint(
|
|
13432
|
-
l2.closestPointToPoint(
|
|
13433
|
-
if (closestPoint.distanceToSquared(
|
|
13405
|
+
l1.closestPointToPoint(p22, true, temp12);
|
|
13406
|
+
l2.closestPointToPoint(p2, true, temp22);
|
|
13407
|
+
if (closestPoint.distanceToSquared(p22) <= closestPoint2.distanceToSquared(p2)) {
|
|
13434
13408
|
target1.copy(closestPoint);
|
|
13435
|
-
target2.copy(
|
|
13409
|
+
target2.copy(p22);
|
|
13436
13410
|
return;
|
|
13437
13411
|
} else {
|
|
13438
|
-
target1.copy(
|
|
13412
|
+
target1.copy(p2);
|
|
13439
13413
|
target2.copy(closestPoint2);
|
|
13440
13414
|
return;
|
|
13441
13415
|
}
|
|
13442
13416
|
}
|
|
13443
13417
|
};
|
|
13444
|
-
}();
|
|
13445
|
-
const sphereIntersectTriangle = function() {
|
|
13418
|
+
})();
|
|
13419
|
+
const sphereIntersectTriangle = (function() {
|
|
13446
13420
|
const closestPointTemp = new Vector3();
|
|
13447
13421
|
const projectedPointTemp = new Vector3();
|
|
13448
13422
|
const planeTemp = new Plane();
|
|
13449
13423
|
const lineTemp = new Line3$1();
|
|
13450
13424
|
return function sphereIntersectTriangle2(sphere, triangle3) {
|
|
13451
13425
|
const { radius, center: center2 } = sphere;
|
|
13452
|
-
const { a, b: b2, c
|
|
13426
|
+
const { a, b: b2, c } = triangle3;
|
|
13453
13427
|
lineTemp.start = a;
|
|
13454
13428
|
lineTemp.end = b2;
|
|
13455
13429
|
const closestPoint1 = lineTemp.closestPointToPoint(center2, true, closestPointTemp);
|
|
13456
13430
|
if (closestPoint1.distanceTo(center2) <= radius) return true;
|
|
13457
13431
|
lineTemp.start = a;
|
|
13458
|
-
lineTemp.end =
|
|
13432
|
+
lineTemp.end = c;
|
|
13459
13433
|
const closestPoint2 = lineTemp.closestPointToPoint(center2, true, closestPointTemp);
|
|
13460
13434
|
if (closestPoint2.distanceTo(center2) <= radius) return true;
|
|
13461
13435
|
lineTemp.start = b2;
|
|
13462
|
-
lineTemp.end =
|
|
13436
|
+
lineTemp.end = c;
|
|
13463
13437
|
const closestPoint3 = lineTemp.closestPointToPoint(center2, true, closestPointTemp);
|
|
13464
13438
|
if (closestPoint3.distanceTo(center2) <= radius) return true;
|
|
13465
13439
|
const plane = triangle3.getPlane(planeTemp);
|
|
@@ -13471,7 +13445,7 @@ const sphereIntersectTriangle = function() {
|
|
|
13471
13445
|
}
|
|
13472
13446
|
return false;
|
|
13473
13447
|
};
|
|
13474
|
-
}();
|
|
13448
|
+
})();
|
|
13475
13449
|
const ZERO_EPSILON = 1e-15;
|
|
13476
13450
|
function isNearZero(value) {
|
|
13477
13451
|
return Math.abs(value) < ZERO_EPSILON;
|
|
@@ -13493,7 +13467,7 @@ class ExtendedTriangle extends Triangle {
|
|
|
13493
13467
|
update() {
|
|
13494
13468
|
const a = this.a;
|
|
13495
13469
|
const b2 = this.b;
|
|
13496
|
-
const
|
|
13470
|
+
const c = this.c;
|
|
13497
13471
|
const points = this.points;
|
|
13498
13472
|
const satAxes = this.satAxes;
|
|
13499
13473
|
const satBounds = this.satBounds;
|
|
@@ -13507,18 +13481,18 @@ class ExtendedTriangle extends Triangle {
|
|
|
13507
13481
|
sab1.setFromPoints(axis1, points);
|
|
13508
13482
|
const axis2 = satAxes[2];
|
|
13509
13483
|
const sab2 = satBounds[2];
|
|
13510
|
-
axis2.subVectors(b2,
|
|
13484
|
+
axis2.subVectors(b2, c);
|
|
13511
13485
|
sab2.setFromPoints(axis2, points);
|
|
13512
13486
|
const axis3 = satAxes[3];
|
|
13513
13487
|
const sab3 = satBounds[3];
|
|
13514
|
-
axis3.subVectors(
|
|
13488
|
+
axis3.subVectors(c, a);
|
|
13515
13489
|
sab3.setFromPoints(axis3, points);
|
|
13516
13490
|
this.sphere.setFromPoints(this.points);
|
|
13517
13491
|
this.plane.setFromNormalAndCoplanarPoint(axis0, a);
|
|
13518
13492
|
this.needsUpdate = false;
|
|
13519
13493
|
}
|
|
13520
13494
|
}
|
|
13521
|
-
ExtendedTriangle.prototype.closestPointToSegment = function() {
|
|
13495
|
+
ExtendedTriangle.prototype.closestPointToSegment = (function() {
|
|
13522
13496
|
const point1 = new Vector3();
|
|
13523
13497
|
const point2 = new Vector3();
|
|
13524
13498
|
const edge = new Line3$1();
|
|
@@ -13555,8 +13529,8 @@ ExtendedTriangle.prototype.closestPointToSegment = function() {
|
|
|
13555
13529
|
}
|
|
13556
13530
|
return Math.sqrt(closestDistanceSq);
|
|
13557
13531
|
};
|
|
13558
|
-
}();
|
|
13559
|
-
ExtendedTriangle.prototype.intersectsTriangle = function() {
|
|
13532
|
+
})();
|
|
13533
|
+
ExtendedTriangle.prototype.intersectsTriangle = (function() {
|
|
13560
13534
|
const saTri2 = new ExtendedTriangle();
|
|
13561
13535
|
const arr1 = new Array(3);
|
|
13562
13536
|
const arr2 = new Array(3);
|
|
@@ -13719,15 +13693,15 @@ ExtendedTriangle.prototype.intersectsTriangle = function() {
|
|
|
13719
13693
|
return true;
|
|
13720
13694
|
}
|
|
13721
13695
|
};
|
|
13722
|
-
}();
|
|
13723
|
-
ExtendedTriangle.prototype.distanceToPoint = function() {
|
|
13696
|
+
})();
|
|
13697
|
+
ExtendedTriangle.prototype.distanceToPoint = (function() {
|
|
13724
13698
|
const target = new Vector3();
|
|
13725
13699
|
return function distanceToPoint(point2) {
|
|
13726
13700
|
this.closestPointToPoint(point2, target);
|
|
13727
13701
|
return point2.distanceTo(target);
|
|
13728
13702
|
};
|
|
13729
|
-
}();
|
|
13730
|
-
ExtendedTriangle.prototype.distanceToTriangle = function() {
|
|
13703
|
+
})();
|
|
13704
|
+
ExtendedTriangle.prototype.distanceToTriangle = (function() {
|
|
13731
13705
|
const point2 = new Vector3();
|
|
13732
13706
|
const point22 = new Vector3();
|
|
13733
13707
|
const cornerFields = ["a", "b", "c"];
|
|
@@ -13782,7 +13756,7 @@ ExtendedTriangle.prototype.distanceToTriangle = function() {
|
|
|
13782
13756
|
}
|
|
13783
13757
|
return Math.sqrt(closestDistanceSq);
|
|
13784
13758
|
};
|
|
13785
|
-
}();
|
|
13759
|
+
})();
|
|
13786
13760
|
class OrientedBox {
|
|
13787
13761
|
constructor(min2, max2, matrix) {
|
|
13788
13762
|
this.isOrientedBox = true;
|
|
@@ -13812,7 +13786,7 @@ class OrientedBox {
|
|
|
13812
13786
|
this.needsUpdate = true;
|
|
13813
13787
|
}
|
|
13814
13788
|
}
|
|
13815
|
-
OrientedBox.prototype.update = /* @__PURE__ */ function() {
|
|
13789
|
+
OrientedBox.prototype.update = /* @__PURE__ */ (function() {
|
|
13816
13790
|
return function update2() {
|
|
13817
13791
|
const matrix = this.matrix;
|
|
13818
13792
|
const min2 = this.min;
|
|
@@ -13820,13 +13794,13 @@ OrientedBox.prototype.update = /* @__PURE__ */ function() {
|
|
|
13820
13794
|
const points = this.points;
|
|
13821
13795
|
for (let x2 = 0; x2 <= 1; x2++) {
|
|
13822
13796
|
for (let y2 = 0; y2 <= 1; y2++) {
|
|
13823
|
-
for (let
|
|
13824
|
-
const i = (1 << 0) * x2 | (1 << 1) * y2 | (1 << 2) *
|
|
13825
|
-
const
|
|
13826
|
-
|
|
13827
|
-
|
|
13828
|
-
|
|
13829
|
-
|
|
13797
|
+
for (let z2 = 0; z2 <= 1; z2++) {
|
|
13798
|
+
const i = (1 << 0) * x2 | (1 << 1) * y2 | (1 << 2) * z2;
|
|
13799
|
+
const v3 = points[i];
|
|
13800
|
+
v3.x = x2 ? max2.x : min2.x;
|
|
13801
|
+
v3.y = y2 ? max2.y : min2.y;
|
|
13802
|
+
v3.z = z2 ? max2.z : min2.z;
|
|
13803
|
+
v3.applyMatrix4(matrix);
|
|
13830
13804
|
}
|
|
13831
13805
|
}
|
|
13832
13806
|
}
|
|
@@ -13848,8 +13822,8 @@ OrientedBox.prototype.update = /* @__PURE__ */ function() {
|
|
|
13848
13822
|
this.invMatrix.copy(this.matrix).invert();
|
|
13849
13823
|
this.needsUpdate = false;
|
|
13850
13824
|
};
|
|
13851
|
-
}();
|
|
13852
|
-
OrientedBox.prototype.intersectsBox = function() {
|
|
13825
|
+
})();
|
|
13826
|
+
OrientedBox.prototype.intersectsBox = (function() {
|
|
13853
13827
|
const aabbBounds = new SeparatingAxisBounds();
|
|
13854
13828
|
return function intersectsBox(box) {
|
|
13855
13829
|
if (this.needsUpdate) {
|
|
@@ -13877,8 +13851,8 @@ OrientedBox.prototype.intersectsBox = function() {
|
|
|
13877
13851
|
}
|
|
13878
13852
|
return true;
|
|
13879
13853
|
};
|
|
13880
|
-
}();
|
|
13881
|
-
OrientedBox.prototype.intersectsTriangle = function() {
|
|
13854
|
+
})();
|
|
13855
|
+
OrientedBox.prototype.intersectsTriangle = (function() {
|
|
13882
13856
|
const saTri = new ExtendedTriangle();
|
|
13883
13857
|
const pointsArr = new Array(3);
|
|
13884
13858
|
const cachedSatBounds = new SeparatingAxisBounds();
|
|
@@ -13927,8 +13901,8 @@ OrientedBox.prototype.intersectsTriangle = function() {
|
|
|
13927
13901
|
}
|
|
13928
13902
|
return true;
|
|
13929
13903
|
};
|
|
13930
|
-
}();
|
|
13931
|
-
OrientedBox.prototype.closestPointToPoint = /* @__PURE__ */ function() {
|
|
13904
|
+
})();
|
|
13905
|
+
OrientedBox.prototype.closestPointToPoint = /* @__PURE__ */ (function() {
|
|
13932
13906
|
return function closestPointToPoint2(point2, target1) {
|
|
13933
13907
|
if (this.needsUpdate) {
|
|
13934
13908
|
this.update();
|
|
@@ -13936,15 +13910,15 @@ OrientedBox.prototype.closestPointToPoint = /* @__PURE__ */ function() {
|
|
|
13936
13910
|
target1.copy(point2).applyMatrix4(this.invMatrix).clamp(this.min, this.max).applyMatrix4(this.matrix);
|
|
13937
13911
|
return target1;
|
|
13938
13912
|
};
|
|
13939
|
-
}();
|
|
13940
|
-
OrientedBox.prototype.distanceToPoint = function() {
|
|
13913
|
+
})();
|
|
13914
|
+
OrientedBox.prototype.distanceToPoint = (function() {
|
|
13941
13915
|
const target = new Vector3();
|
|
13942
13916
|
return function distanceToPoint(point2) {
|
|
13943
13917
|
this.closestPointToPoint(point2, target);
|
|
13944
13918
|
return point2.distanceTo(target);
|
|
13945
13919
|
};
|
|
13946
|
-
}();
|
|
13947
|
-
OrientedBox.prototype.distanceToBox = function() {
|
|
13920
|
+
})();
|
|
13921
|
+
OrientedBox.prototype.distanceToBox = (function() {
|
|
13948
13922
|
const xyzFields = ["x", "y", "z"];
|
|
13949
13923
|
const segments1 = new Array(12).fill().map(() => new Line3$1());
|
|
13950
13924
|
const segments2 = new Array(12).fill().map(() => new Line3$1());
|
|
@@ -13970,12 +13944,12 @@ OrientedBox.prototype.distanceToBox = function() {
|
|
|
13970
13944
|
const points = this.points;
|
|
13971
13945
|
let closestDistanceSq = Infinity;
|
|
13972
13946
|
for (let i = 0; i < 8; i++) {
|
|
13973
|
-
const
|
|
13974
|
-
point2.copy(
|
|
13975
|
-
const dist =
|
|
13947
|
+
const p2 = points[i];
|
|
13948
|
+
point2.copy(p2).clamp(min2, max2);
|
|
13949
|
+
const dist = p2.distanceToSquared(point2);
|
|
13976
13950
|
if (dist < closestDistanceSq) {
|
|
13977
13951
|
closestDistanceSq = dist;
|
|
13978
|
-
if (target1) target1.copy(
|
|
13952
|
+
if (target1) target1.copy(p2);
|
|
13979
13953
|
if (target2) target2.copy(point2);
|
|
13980
13954
|
if (dist < threshold2) return Math.sqrt(dist);
|
|
13981
13955
|
}
|
|
@@ -14010,10 +13984,10 @@ OrientedBox.prototype.distanceToBox = function() {
|
|
|
14010
13984
|
}
|
|
14011
13985
|
for (let x2 = 0; x2 <= 1; x2++) {
|
|
14012
13986
|
for (let y2 = 0; y2 <= 1; y2++) {
|
|
14013
|
-
for (let
|
|
13987
|
+
for (let z2 = 0; z2 <= 1; z2++) {
|
|
14014
13988
|
point2.x = x2 ? max2.x : min2.x;
|
|
14015
13989
|
point2.y = y2 ? max2.y : min2.y;
|
|
14016
|
-
point2.z =
|
|
13990
|
+
point2.z = z2 ? max2.z : min2.z;
|
|
14017
13991
|
this.closestPointToPoint(point2, point1);
|
|
14018
13992
|
const dist = point2.distanceToSquared(point1);
|
|
14019
13993
|
if (dist < closestDistanceSq) {
|
|
@@ -14041,7 +14015,7 @@ OrientedBox.prototype.distanceToBox = function() {
|
|
|
14041
14015
|
}
|
|
14042
14016
|
return Math.sqrt(closestDistanceSq);
|
|
14043
14017
|
};
|
|
14044
|
-
}();
|
|
14018
|
+
})();
|
|
14045
14019
|
class PrimitivePool {
|
|
14046
14020
|
constructor(getNewPrimitive) {
|
|
14047
14021
|
this._getNewPrimitive = getNewPrimitive;
|
|
@@ -14275,28 +14249,28 @@ function checkIntersection(ray2, pA, pB, pC, point2, side) {
|
|
|
14275
14249
|
point: point2.clone()
|
|
14276
14250
|
};
|
|
14277
14251
|
}
|
|
14278
|
-
function checkBufferGeometryIntersection(ray2, position2, normal, uv, uv1, a, b2,
|
|
14252
|
+
function checkBufferGeometryIntersection(ray2, position2, normal, uv, uv1, a, b2, c, side) {
|
|
14279
14253
|
_vA.fromBufferAttribute(position2, a);
|
|
14280
14254
|
_vB.fromBufferAttribute(position2, b2);
|
|
14281
|
-
_vC.fromBufferAttribute(position2,
|
|
14255
|
+
_vC.fromBufferAttribute(position2, c);
|
|
14282
14256
|
const intersection = checkIntersection(ray2, _vA, _vB, _vC, _intersectionPoint, side);
|
|
14283
14257
|
if (intersection) {
|
|
14284
14258
|
if (uv) {
|
|
14285
14259
|
_uvA.fromBufferAttribute(uv, a);
|
|
14286
14260
|
_uvB.fromBufferAttribute(uv, b2);
|
|
14287
|
-
_uvC.fromBufferAttribute(uv,
|
|
14261
|
+
_uvC.fromBufferAttribute(uv, c);
|
|
14288
14262
|
intersection.uv = Triangle.getInterpolation(_intersectionPoint, _vA, _vB, _vC, _uvA, _uvB, _uvC, new Vector2());
|
|
14289
14263
|
}
|
|
14290
14264
|
if (uv1) {
|
|
14291
14265
|
_uvA.fromBufferAttribute(uv1, a);
|
|
14292
14266
|
_uvB.fromBufferAttribute(uv1, b2);
|
|
14293
|
-
_uvC.fromBufferAttribute(uv1,
|
|
14267
|
+
_uvC.fromBufferAttribute(uv1, c);
|
|
14294
14268
|
intersection.uv1 = Triangle.getInterpolation(_intersectionPoint, _vA, _vB, _vC, _uvA, _uvB, _uvC, new Vector2());
|
|
14295
14269
|
}
|
|
14296
14270
|
if (normal) {
|
|
14297
14271
|
_normalA.fromBufferAttribute(normal, a);
|
|
14298
14272
|
_normalB.fromBufferAttribute(normal, b2);
|
|
14299
|
-
_normalC.fromBufferAttribute(normal,
|
|
14273
|
+
_normalC.fromBufferAttribute(normal, c);
|
|
14300
14274
|
intersection.normal = Triangle.getInterpolation(_intersectionPoint, _vA, _vB, _vC, _normalA, _normalB, _normalC, new Vector3());
|
|
14301
14275
|
if (intersection.normal.dot(ray2.direction) > 0) {
|
|
14302
14276
|
intersection.normal.multiplyScalar(-1);
|
|
@@ -14305,7 +14279,7 @@ function checkBufferGeometryIntersection(ray2, position2, normal, uv, uv1, a, b2
|
|
|
14305
14279
|
const face = {
|
|
14306
14280
|
a,
|
|
14307
14281
|
b: b2,
|
|
14308
|
-
c
|
|
14282
|
+
c,
|
|
14309
14283
|
normal: new Vector3(),
|
|
14310
14284
|
materialIndex: 0
|
|
14311
14285
|
};
|
|
@@ -14319,15 +14293,15 @@ function intersectTri(geo, side, ray2, tri, intersections) {
|
|
|
14319
14293
|
const triOffset = tri * 3;
|
|
14320
14294
|
let a = triOffset + 0;
|
|
14321
14295
|
let b2 = triOffset + 1;
|
|
14322
|
-
let
|
|
14296
|
+
let c = triOffset + 2;
|
|
14323
14297
|
const index = geo.index;
|
|
14324
14298
|
if (geo.index) {
|
|
14325
14299
|
a = index.getX(a);
|
|
14326
14300
|
b2 = index.getX(b2);
|
|
14327
|
-
|
|
14301
|
+
c = index.getX(c);
|
|
14328
14302
|
}
|
|
14329
14303
|
const { position: position2, normal, uv, uv1 } = geo.attributes;
|
|
14330
|
-
const intersection = checkBufferGeometryIntersection(ray2, position2, normal, uv, uv1, a, b2,
|
|
14304
|
+
const intersection = checkBufferGeometryIntersection(ray2, position2, normal, uv, uv1, a, b2, c, side);
|
|
14331
14305
|
if (intersection) {
|
|
14332
14306
|
intersection.faceIndex = tri;
|
|
14333
14307
|
if (intersections) intersections.push(intersection);
|
|
@@ -14381,7 +14355,7 @@ function iterateOverTriangles(offset, count, bvh, intersectsTriangleFunc, contai
|
|
|
14381
14355
|
const { geometry } = bvh;
|
|
14382
14356
|
const { index } = geometry;
|
|
14383
14357
|
const pos = geometry.attributes.position;
|
|
14384
|
-
for (let i = offset,
|
|
14358
|
+
for (let i = offset, l2 = count + offset; i < l2; i++) {
|
|
14385
14359
|
let tri;
|
|
14386
14360
|
tri = i;
|
|
14387
14361
|
setTriangle(triangle3, tri * 3, index, pos);
|
|
@@ -14402,7 +14376,7 @@ function refit(bvh, nodeIndices = null) {
|
|
|
14402
14376
|
let buffer, uint32Array2, uint16Array2, float32Array2;
|
|
14403
14377
|
let byteOffset = 0;
|
|
14404
14378
|
const roots = bvh._roots;
|
|
14405
|
-
for (let i = 0,
|
|
14379
|
+
for (let i = 0, l2 = roots.length; i < l2; i++) {
|
|
14406
14380
|
buffer = roots[i];
|
|
14407
14381
|
uint32Array2 = new Uint32Array(buffer);
|
|
14408
14382
|
uint16Array2 = new Uint16Array(buffer);
|
|
@@ -14422,17 +14396,17 @@ function refit(bvh, nodeIndices = null) {
|
|
|
14422
14396
|
let maxx = -Infinity;
|
|
14423
14397
|
let maxy = -Infinity;
|
|
14424
14398
|
let maxz = -Infinity;
|
|
14425
|
-
for (let i = 3 * offset,
|
|
14399
|
+
for (let i = 3 * offset, l2 = 3 * (offset + count); i < l2; i++) {
|
|
14426
14400
|
let index = indexArr[i];
|
|
14427
14401
|
const x2 = posAttr.getX(index);
|
|
14428
14402
|
const y2 = posAttr.getY(index);
|
|
14429
|
-
const
|
|
14403
|
+
const z2 = posAttr.getZ(index);
|
|
14430
14404
|
if (x2 < minx) minx = x2;
|
|
14431
14405
|
if (x2 > maxx) maxx = x2;
|
|
14432
14406
|
if (y2 < miny) miny = y2;
|
|
14433
14407
|
if (y2 > maxy) maxy = y2;
|
|
14434
|
-
if (
|
|
14435
|
-
if (
|
|
14408
|
+
if (z2 < minz) minz = z2;
|
|
14409
|
+
if (z2 > maxz) maxz = z2;
|
|
14436
14410
|
}
|
|
14437
14411
|
if (float32Array2[node32Index + 0] !== minx || float32Array2[node32Index + 1] !== miny || float32Array2[node32Index + 2] !== minz || float32Array2[node32Index + 3] !== maxx || float32Array2[node32Index + 4] !== maxy || float32Array2[node32Index + 5] !== maxz) {
|
|
14438
14412
|
float32Array2[node32Index + 0] = minx;
|
|
@@ -14556,7 +14530,7 @@ function iterateOverTriangles_indirect(offset, count, bvh, intersectsTriangleFun
|
|
|
14556
14530
|
const { geometry } = bvh;
|
|
14557
14531
|
const { index } = geometry;
|
|
14558
14532
|
const pos = geometry.attributes.position;
|
|
14559
|
-
for (let i = offset,
|
|
14533
|
+
for (let i = offset, l2 = count + offset; i < l2; i++) {
|
|
14560
14534
|
let tri;
|
|
14561
14535
|
tri = bvh.resolveTriangleIndex(i);
|
|
14562
14536
|
setTriangle(triangle3, tri * 3, index, pos);
|
|
@@ -14683,7 +14657,7 @@ function _intersectsGeometry$1(nodeIndex32, bvh, otherGeometry, geometryToBvh, c
|
|
|
14683
14657
|
tri.b.applyMatrix4(geometryToBvh);
|
|
14684
14658
|
tri.c.applyMatrix4(geometryToBvh);
|
|
14685
14659
|
tri.needsUpdate = true;
|
|
14686
|
-
for (let i = offset * 3,
|
|
14660
|
+
for (let i = offset * 3, l2 = (count + offset) * 3; i < l2; i += 3) {
|
|
14687
14661
|
setTriangle(triangle2$1, i, thisIndex, thisPos);
|
|
14688
14662
|
triangle2$1.needsUpdate = true;
|
|
14689
14663
|
if (tri.intersectsTriangle(triangle2$1)) {
|
|
@@ -14695,13 +14669,13 @@ function _intersectsGeometry$1(nodeIndex32, bvh, otherGeometry, geometryToBvh, c
|
|
|
14695
14669
|
});
|
|
14696
14670
|
return res;
|
|
14697
14671
|
} else {
|
|
14698
|
-
for (let i = offset * 3,
|
|
14672
|
+
for (let i = offset * 3, l2 = (count + offset) * 3; i < l2; i += 3) {
|
|
14699
14673
|
setTriangle(triangle$1, i, thisIndex, thisPos);
|
|
14700
14674
|
triangle$1.a.applyMatrix4(invertedMat$1);
|
|
14701
14675
|
triangle$1.b.applyMatrix4(invertedMat$1);
|
|
14702
14676
|
triangle$1.c.applyMatrix4(invertedMat$1);
|
|
14703
14677
|
triangle$1.needsUpdate = true;
|
|
14704
|
-
for (let i2 = 0,
|
|
14678
|
+
for (let i2 = 0, l22 = index.count; i2 < l22; i2 += 3) {
|
|
14705
14679
|
setTriangle(triangle2$1, i2, index, pos);
|
|
14706
14680
|
triangle2$1.needsUpdate = true;
|
|
14707
14681
|
if (triangle$1.intersectsTriangle(triangle2$1)) {
|
|
@@ -14788,7 +14762,7 @@ function closestPointToGeometry(bvh, otherGeometry, geometryToBvh, target1 = {},
|
|
|
14788
14762
|
triangle22.b.applyMatrix4(geometryToBvh);
|
|
14789
14763
|
triangle22.c.applyMatrix4(geometryToBvh);
|
|
14790
14764
|
triangle22.needsUpdate = true;
|
|
14791
|
-
for (let i = offset,
|
|
14765
|
+
for (let i = offset, l3 = offset + count; i < l3; i++) {
|
|
14792
14766
|
setTriangle(triangle3, 3 * i, index, pos);
|
|
14793
14767
|
triangle3.needsUpdate = true;
|
|
14794
14768
|
const dist = triangle3.distanceToTriangle(triangle22, tempTarget1, tempTarget2);
|
|
@@ -14816,7 +14790,7 @@ function closestPointToGeometry(bvh, otherGeometry, geometryToBvh, target1 = {},
|
|
|
14816
14790
|
triangle22.b.applyMatrix4(geometryToBvh);
|
|
14817
14791
|
triangle22.c.applyMatrix4(geometryToBvh);
|
|
14818
14792
|
triangle22.needsUpdate = true;
|
|
14819
|
-
for (let i = offset,
|
|
14793
|
+
for (let i = offset, l3 = offset + count; i < l3; i++) {
|
|
14820
14794
|
setTriangle(triangle3, 3 * i, index, pos);
|
|
14821
14795
|
triangle3.needsUpdate = true;
|
|
14822
14796
|
const dist = triangle3.distanceToTriangle(triangle22, tempTarget1, tempTarget2);
|
|
@@ -14869,7 +14843,7 @@ function refit_indirect(bvh, nodeIndices = null) {
|
|
|
14869
14843
|
let buffer, uint32Array2, uint16Array2, float32Array2;
|
|
14870
14844
|
let byteOffset = 0;
|
|
14871
14845
|
const roots = bvh._roots;
|
|
14872
|
-
for (let i = 0,
|
|
14846
|
+
for (let i = 0, l2 = roots.length; i < l2; i++) {
|
|
14873
14847
|
buffer = roots[i];
|
|
14874
14848
|
uint32Array2 = new Uint32Array(buffer);
|
|
14875
14849
|
uint16Array2 = new Uint16Array(buffer);
|
|
@@ -14889,20 +14863,20 @@ function refit_indirect(bvh, nodeIndices = null) {
|
|
|
14889
14863
|
let maxx = -Infinity;
|
|
14890
14864
|
let maxy = -Infinity;
|
|
14891
14865
|
let maxz = -Infinity;
|
|
14892
|
-
for (let i = offset,
|
|
14866
|
+
for (let i = offset, l2 = offset + count; i < l2; i++) {
|
|
14893
14867
|
const t = 3 * bvh.resolveTriangleIndex(i);
|
|
14894
14868
|
for (let j = 0; j < 3; j++) {
|
|
14895
14869
|
let index = t + j;
|
|
14896
14870
|
index = indexArr ? indexArr[index] : index;
|
|
14897
14871
|
const x2 = posAttr.getX(index);
|
|
14898
14872
|
const y2 = posAttr.getY(index);
|
|
14899
|
-
const
|
|
14873
|
+
const z2 = posAttr.getZ(index);
|
|
14900
14874
|
if (x2 < minx) minx = x2;
|
|
14901
14875
|
if (x2 > maxx) maxx = x2;
|
|
14902
14876
|
if (y2 < miny) miny = y2;
|
|
14903
14877
|
if (y2 > maxy) maxy = y2;
|
|
14904
|
-
if (
|
|
14905
|
-
if (
|
|
14878
|
+
if (z2 < minz) minz = z2;
|
|
14879
|
+
if (z2 > maxz) maxz = z2;
|
|
14906
14880
|
}
|
|
14907
14881
|
}
|
|
14908
14882
|
if (float32Array2[node32Index + 0] !== minx || float32Array2[node32Index + 1] !== miny || float32Array2[node32Index + 2] !== minz || float32Array2[node32Index + 3] !== maxx || float32Array2[node32Index + 4] !== maxy || float32Array2[node32Index + 5] !== maxz) {
|
|
@@ -15077,7 +15051,7 @@ function _intersectsGeometry(nodeIndex32, bvh, otherGeometry, geometryToBvh, cac
|
|
|
15077
15051
|
tri.b.applyMatrix4(geometryToBvh);
|
|
15078
15052
|
tri.c.applyMatrix4(geometryToBvh);
|
|
15079
15053
|
tri.needsUpdate = true;
|
|
15080
|
-
for (let i = offset,
|
|
15054
|
+
for (let i = offset, l2 = count + offset; i < l2; i++) {
|
|
15081
15055
|
setTriangle(triangle2, 3 * bvh.resolveTriangleIndex(i), thisIndex, thisPos);
|
|
15082
15056
|
triangle2.needsUpdate = true;
|
|
15083
15057
|
if (tri.intersectsTriangle(triangle2)) {
|
|
@@ -15089,14 +15063,14 @@ function _intersectsGeometry(nodeIndex32, bvh, otherGeometry, geometryToBvh, cac
|
|
|
15089
15063
|
});
|
|
15090
15064
|
return res;
|
|
15091
15065
|
} else {
|
|
15092
|
-
for (let i = offset,
|
|
15066
|
+
for (let i = offset, l2 = count + offset; i < l2; i++) {
|
|
15093
15067
|
const ti = bvh.resolveTriangleIndex(i);
|
|
15094
15068
|
setTriangle(triangle, 3 * ti, thisIndex, thisPos);
|
|
15095
15069
|
triangle.a.applyMatrix4(invertedMat);
|
|
15096
15070
|
triangle.b.applyMatrix4(invertedMat);
|
|
15097
15071
|
triangle.c.applyMatrix4(invertedMat);
|
|
15098
15072
|
triangle.needsUpdate = true;
|
|
15099
|
-
for (let i2 = 0,
|
|
15073
|
+
for (let i2 = 0, l22 = index.count; i2 < l22; i2 += 3) {
|
|
15100
15074
|
setTriangle(triangle2, i2, index, pos);
|
|
15101
15075
|
triangle2.needsUpdate = true;
|
|
15102
15076
|
if (triangle.intersectsTriangle(triangle2)) {
|
|
@@ -15184,7 +15158,7 @@ function closestPointToGeometry_indirect(bvh, otherGeometry, geometryToBvh, targ
|
|
|
15184
15158
|
triangle22.b.applyMatrix4(geometryToBvh);
|
|
15185
15159
|
triangle22.c.applyMatrix4(geometryToBvh);
|
|
15186
15160
|
triangle22.needsUpdate = true;
|
|
15187
|
-
for (let i = offset,
|
|
15161
|
+
for (let i = offset, l3 = offset + count; i < l3; i++) {
|
|
15188
15162
|
const ti = bvh.resolveTriangleIndex(i);
|
|
15189
15163
|
setTriangle(triangle3, 3 * ti, index, pos);
|
|
15190
15164
|
triangle3.needsUpdate = true;
|
|
@@ -15213,7 +15187,7 @@ function closestPointToGeometry_indirect(bvh, otherGeometry, geometryToBvh, targ
|
|
|
15213
15187
|
triangle22.b.applyMatrix4(geometryToBvh);
|
|
15214
15188
|
triangle22.c.applyMatrix4(geometryToBvh);
|
|
15215
15189
|
triangle22.needsUpdate = true;
|
|
15216
|
-
for (let i = offset,
|
|
15190
|
+
for (let i = offset, l3 = offset + count; i < l3; i++) {
|
|
15217
15191
|
const ti = bvh.resolveTriangleIndex(i);
|
|
15218
15192
|
setTriangle(triangle3, 3 * ti, index, pos);
|
|
15219
15193
|
triangle3.needsUpdate = true;
|
|
@@ -15657,7 +15631,7 @@ class MeshBVH {
|
|
|
15657
15631
|
const groups = geometry.groups;
|
|
15658
15632
|
const side = isMaterial ? materialOrSide.side : materialOrSide;
|
|
15659
15633
|
const raycastFunc = this.indirect ? raycast_indirect : raycast;
|
|
15660
|
-
for (let i = 0,
|
|
15634
|
+
for (let i = 0, l2 = roots.length; i < l2; i++) {
|
|
15661
15635
|
const materialSide = isArrayMaterial ? materialOrSide[groups[i].materialIndex].side : side;
|
|
15662
15636
|
const startCount = intersects.length;
|
|
15663
15637
|
raycastFunc(this, i, materialSide, ray2, intersects);
|
|
@@ -15679,7 +15653,7 @@ class MeshBVH {
|
|
|
15679
15653
|
const groups = geometry.groups;
|
|
15680
15654
|
const side = isMaterial ? materialOrSide.side : materialOrSide;
|
|
15681
15655
|
const raycastFirstFunc = this.indirect ? raycastFirst_indirect : raycastFirst;
|
|
15682
|
-
for (let i = 0,
|
|
15656
|
+
for (let i = 0, l2 = roots.length; i < l2; i++) {
|
|
15683
15657
|
const materialSide = isArrayMaterial ? materialOrSide[groups[i].materialIndex].side : side;
|
|
15684
15658
|
const result = raycastFirstFunc(this, i, materialSide, ray2);
|
|
15685
15659
|
if (result != null && (closestResult == null || result.distance < closestResult.distance)) {
|
|
@@ -15695,7 +15669,7 @@ class MeshBVH {
|
|
|
15695
15669
|
let result = false;
|
|
15696
15670
|
const roots = this._roots;
|
|
15697
15671
|
const intersectsGeometryFunc = this.indirect ? intersectsGeometry_indirect : intersectsGeometry;
|
|
15698
|
-
for (let i = 0,
|
|
15672
|
+
for (let i = 0, l2 = roots.length; i < l2; i++) {
|
|
15699
15673
|
result = intersectsGeometryFunc(this, i, otherGeometry, geomToMesh);
|
|
15700
15674
|
if (result) {
|
|
15701
15675
|
break;
|
|
@@ -15734,7 +15708,7 @@ class MeshBVH {
|
|
|
15734
15708
|
let result = false;
|
|
15735
15709
|
let byteOffset = 0;
|
|
15736
15710
|
const roots = this._roots;
|
|
15737
|
-
for (let i = 0,
|
|
15711
|
+
for (let i = 0, l2 = roots.length; i < l2; i++) {
|
|
15738
15712
|
const root2 = roots[i];
|
|
15739
15713
|
result = shapecast(this, i, intersectsBounds, intersectsRange, boundsTraverseOrder, byteOffset);
|
|
15740
15714
|
if (result) {
|
|
@@ -15879,7 +15853,7 @@ function acceleratedRaycast(raycaster, intersects) {
|
|
|
15879
15853
|
}
|
|
15880
15854
|
} else {
|
|
15881
15855
|
const hits = bvh.raycast(ray, this.material);
|
|
15882
|
-
for (let i = 0,
|
|
15856
|
+
for (let i = 0, l2 = hits.length; i < l2; i++) {
|
|
15883
15857
|
const hit = convertRaycastIntersect(hits[i], this, raycaster);
|
|
15884
15858
|
if (hit) {
|
|
15885
15859
|
intersects.push(hit);
|
|
@@ -15904,7 +15878,7 @@ class SVGMesh {
|
|
|
15904
15878
|
const bvhOptions = {
|
|
15905
15879
|
maxLeafTris: 1,
|
|
15906
15880
|
strategy: CENTER,
|
|
15907
|
-
...options
|
|
15881
|
+
...options?.bvhOptions
|
|
15908
15882
|
};
|
|
15909
15883
|
this.bvhOptions = bvhOptions;
|
|
15910
15884
|
this.bvh = new MeshBVH(this.threeMesh.geometry, bvhOptions);
|
|
@@ -16095,7 +16069,7 @@ let ThreeSVGRendererPlugin = class extends AViewerPluginSync {
|
|
|
16095
16069
|
this._meshes = /* @__PURE__ */ new Map();
|
|
16096
16070
|
this._rendering = false;
|
|
16097
16071
|
this._viewerListeners = {
|
|
16098
|
-
postRender: (
|
|
16072
|
+
postRender: (_) => {
|
|
16099
16073
|
if (this.autoRender) this.render();
|
|
16100
16074
|
}
|
|
16101
16075
|
};
|
|
@@ -16122,21 +16096,19 @@ let ThreeSVGRendererPlugin = class extends AViewerPluginSync {
|
|
|
16122
16096
|
Vertex.MAX_LOOP = 1e4;
|
|
16123
16097
|
}
|
|
16124
16098
|
setDirty(...args) {
|
|
16125
|
-
var _a, _b;
|
|
16126
16099
|
if (args[0] === "enabled") {
|
|
16127
16100
|
const last = args[2];
|
|
16128
16101
|
const current = args[1];
|
|
16129
|
-
if (last !== current &&
|
|
16102
|
+
if (last !== current && this._meshes?.size) {
|
|
16130
16103
|
this._toggleMaterialRendering([...this._meshes.values()], !current);
|
|
16131
16104
|
}
|
|
16132
16105
|
if (this.svgNodeContainer) {
|
|
16133
16106
|
this.svgNodeContainer.style.display = current ? "" : "none";
|
|
16134
16107
|
}
|
|
16135
16108
|
}
|
|
16136
|
-
|
|
16109
|
+
this._viewer?.setDirty();
|
|
16137
16110
|
}
|
|
16138
16111
|
onAdded(viewer) {
|
|
16139
|
-
var _a;
|
|
16140
16112
|
super.onAdded(viewer);
|
|
16141
16113
|
if (this.autoAddToContainer) {
|
|
16142
16114
|
viewer.container.prepend(this.svgNodeContainer);
|
|
@@ -16149,7 +16121,7 @@ let ThreeSVGRendererPlugin = class extends AViewerPluginSync {
|
|
|
16149
16121
|
this.svgNodeContainer.style.width = canvasStyles.width;
|
|
16150
16122
|
this.svgNodeContainer.style.height = canvasStyles.height;
|
|
16151
16123
|
} else {
|
|
16152
|
-
|
|
16124
|
+
this._viewer?.console.warn("ThreeSVGRendererPlugin: canvas position should be absolute for proper rendering");
|
|
16153
16125
|
}
|
|
16154
16126
|
viewer.renderManager.addEventListener("resize", this._onResize);
|
|
16155
16127
|
}
|
|
@@ -16281,16 +16253,14 @@ let ThreeSVGRendererPlugin = class extends AViewerPluginSync {
|
|
|
16281
16253
|
return "";
|
|
16282
16254
|
}
|
|
16283
16255
|
download() {
|
|
16284
|
-
var _a;
|
|
16285
16256
|
const svg2 = this.svgNodeContainer.innerHTML;
|
|
16286
16257
|
const blob = new Blob([svg2], { type: "image/svg+xml" });
|
|
16287
|
-
|
|
16258
|
+
this._viewer?.exportBlob(blob, "scene.svg");
|
|
16288
16259
|
}
|
|
16289
16260
|
get svgNode() {
|
|
16290
|
-
var _a;
|
|
16291
16261
|
if (!this.svgNodeContainer.children.length) return void 0;
|
|
16292
16262
|
if (this.svgNodeContainer.children.length > 1) {
|
|
16293
|
-
|
|
16263
|
+
this._viewer?.console.warn("ThreeSVGRenderer: Multiple svg nodes in container, should not be possible");
|
|
16294
16264
|
}
|
|
16295
16265
|
return this.svgNodeContainer.children[0];
|
|
16296
16266
|
}
|
|
@@ -16303,9 +16273,9 @@ let ThreeSVGRendererPlugin = class extends AViewerPluginSync {
|
|
|
16303
16273
|
this.renderer.viewmap.options.creaseAngle.min = this.creaseAngle.x;
|
|
16304
16274
|
this.renderer.viewmap.options.creaseAngle.max = this.creaseAngle.y;
|
|
16305
16275
|
const passes = this.renderer.drawHandler.passes;
|
|
16306
|
-
const fillPass = passes.find((
|
|
16307
|
-
const visibleContourPass = passes.find((
|
|
16308
|
-
const hiddenContourPass = passes.find((
|
|
16276
|
+
const fillPass = passes.find((p2) => p2 instanceof FillPass);
|
|
16277
|
+
const visibleContourPass = passes.find((p2) => p2 instanceof VisibleChainPass);
|
|
16278
|
+
const hiddenContourPass = passes.find((p2) => p2 instanceof HiddenChainPass);
|
|
16309
16279
|
if (fillPass) {
|
|
16310
16280
|
fillPass.enabled = this.drawPolygons && (this.drawPolygonFills || this.drawPolygonStrokes || this.drawImageFills);
|
|
16311
16281
|
fillPass.drawFills = this.drawPolygonFills;
|
|
@@ -16378,23 +16348,6 @@ __decorateClass([
|
|
|
16378
16348
|
ThreeSVGRendererPlugin = __decorateClass([
|
|
16379
16349
|
uiFolderContainer("SVG Renderer")
|
|
16380
16350
|
], ThreeSVGRendererPlugin);
|
|
16381
|
-
/**
|
|
16382
|
-
* @license
|
|
16383
|
-
* three-svg-renderer
|
|
16384
|
-
*
|
|
16385
|
-
* GNU GENERAL PUBLIC LICENSE
|
|
16386
|
-
* Version 3, 29 June 2007
|
|
16387
|
-
*
|
|
16388
|
-
* Copyright (c) 2022 Axel Antoine
|
|
16389
|
-
*/
|
|
16390
|
-
/**
|
|
16391
|
-
* @license
|
|
16392
|
-
* three-mesh-halfedge
|
|
16393
|
-
*
|
|
16394
|
-
* MIT License
|
|
16395
|
-
*
|
|
16396
|
-
* Copyright (c) 2022 Axel Antoine
|
|
16397
|
-
*/
|
|
16398
16351
|
export {
|
|
16399
16352
|
BasicSVGRenderer,
|
|
16400
16353
|
BasicSVGRendererPlugin,
|