gl-draw 0.15.23 → 0.15.25
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/dist/WebGPULineSegments2.js +1 -1
- package/dist/WebGPULineSegments2.module.js +72 -72
- package/dist/core/Loader/Loader.d.ts +4 -4
- package/dist/core/ResourceTracker.d.ts +1 -1
- package/dist/index.js +2 -2
- package/dist/index.module.js +88 -88
- package/dist/objects/index.js +1 -1
- package/dist/objects/index.module.js +41 -42
- package/dist/objects/line/index.d.ts +0 -1
- package/package.json +1 -1
|
@@ -41,14 +41,14 @@ import { LineSegmentsGeometry as Ke } from "three/examples/jsm/lines/LineSegment
|
|
|
41
41
|
import { LineSegmentsGeometry as un } from "three/examples/jsm/lines/LineSegmentsGeometry";
|
|
42
42
|
import { P as et, a as Z, M as tt, L as nt } from "../WebGPULineSegments2.module.js";
|
|
43
43
|
import { g as fn } from "../WebGPULineSegments2.module.js";
|
|
44
|
-
import { BufferGeometry as fe, Float32BufferAttribute as be, Vector3 as _, ShapeUtils as de, Shape as xe, Vector2 as G, ArcCurve as st, CatmullRomCurve3 as ot, CubicBezierCurve as it, CubicBezierCurve3 as rt, EllipseCurve as at, LineCurve as ct, LineCurve3 as lt, QuadraticBezierCurve as ht, QuadraticBezierCurve3 as ut, SplineCurve as dt, Box3 as ft, PlaneGeometry as pt, CanvasTexture as mt, AmbientLight as gt, DirectionalLight as yt, PointLight as bt, SpotLight as xt, HemisphereLight as wt, RectAreaLight as vt, Matrix4 as
|
|
44
|
+
import { BufferGeometry as fe, Float32BufferAttribute as be, Vector3 as _, ShapeUtils as de, Shape as xe, Vector2 as G, ArcCurve as st, CatmullRomCurve3 as ot, CubicBezierCurve as it, CubicBezierCurve3 as rt, EllipseCurve as at, LineCurve as ct, LineCurve3 as lt, QuadraticBezierCurve as ht, QuadraticBezierCurve3 as ut, SplineCurve as dt, Box3 as ft, PlaneGeometry as pt, CanvasTexture as mt, AmbientLight as gt, DirectionalLight as yt, PointLight as bt, SpotLight as xt, HemisphereLight as wt, RectAreaLight as vt, Matrix4 as De, BufferAttribute as Y, Ray as St, Sphere as At, LineSegments as Xe, Color as Ne, MeshBasicMaterial as Mt, Mesh as Lt } from "three";
|
|
45
45
|
import { mergeAttributes as Re, mergeGroups as Tt } from "three/examples/jsm/utils/BufferGeometryUtils";
|
|
46
46
|
import { g as Et, c as Ct } from "../uvGenerator.module.js";
|
|
47
47
|
import { Brush as Oe, Evaluator as Gt, INTERSECTION as Pt } from "three-bvh-csg";
|
|
48
48
|
import { RectAreaLightUniformsLib as _t } from "three/examples/jsm/lights/RectAreaLightUniformsLib";
|
|
49
49
|
import * as ne from "@tweenjs/tween.js";
|
|
50
50
|
import { LineSegments2 as jt } from "three/examples/jsm/lines/LineSegments2";
|
|
51
|
-
function
|
|
51
|
+
function V(m, e = 0) {
|
|
52
52
|
const t = m[0].index !== null, n = new Set(Object.keys(m[0].attributes)), s = new Set(
|
|
53
53
|
Object.keys(m[0].morphAttributes)
|
|
54
54
|
), i = {}, a = {}, f = m[0].morphTargetsRelative, r = new fe();
|
|
@@ -180,7 +180,7 @@ class Zt extends Z {
|
|
|
180
180
|
coordinate: o
|
|
181
181
|
}, a))
|
|
182
182
|
);
|
|
183
|
-
f =
|
|
183
|
+
f = V(h, i != null ? i : 0);
|
|
184
184
|
}
|
|
185
185
|
this.createMesh(f, s);
|
|
186
186
|
}
|
|
@@ -225,8 +225,8 @@ class K extends fe {
|
|
|
225
225
|
const r = [], h = t.curveSegments !== void 0 ? t.curveSegments : 12, o = t.steps !== void 0 ? t.steps : 1, c = t.depth !== void 0 ? t.depth : 1;
|
|
226
226
|
let y = t.bevelEnabled !== void 0 ? t.bevelEnabled : !0, u = t.bevelThickness !== void 0 ? t.bevelThickness : 0.2, g = t.bevelSize !== void 0 ? t.bevelSize : u - 0.1, L = t.bevelOffset !== void 0 ? t.bevelOffset : 0, S = t.bevelSegments !== void 0 ? t.bevelSegments : 3;
|
|
227
227
|
const A = t.extrudePath, P = t.UVGenerator !== void 0 ? t.UVGenerator : It, v = (Le = t.hasTop) != null ? Le : !0, z = (Te = t.hasBottom) != null ? Te : !0, ee = (Ee = t.hasSide) != null ? Ee : !0;
|
|
228
|
-
let
|
|
229
|
-
A && (
|
|
228
|
+
let D, $ = !1, U, se, oe, X;
|
|
229
|
+
A && (D = A.getSpacedPoints(o), $ = !0, y = !1, U = A.computeFrenetFrames(o, !1), se = new _(), oe = new _(), X = new _()), y || (S = 0, u = 0, g = 0, L = 0);
|
|
230
230
|
const we = f.extractPoints(h);
|
|
231
231
|
let O = we.shape;
|
|
232
232
|
const I = we.holes;
|
|
@@ -255,7 +255,7 @@ class K extends fe {
|
|
|
255
255
|
}
|
|
256
256
|
}
|
|
257
257
|
ve(O), I.forEach(ve);
|
|
258
|
-
const pe = I.length,
|
|
258
|
+
const pe = I.length, H = O;
|
|
259
259
|
for (let l = 0; l < pe; l++) {
|
|
260
260
|
const d = I[l];
|
|
261
261
|
O = O.concat(d);
|
|
@@ -283,8 +283,8 @@ class K extends fe {
|
|
|
283
283
|
return new G(x / M, b / M);
|
|
284
284
|
}
|
|
285
285
|
const re = [];
|
|
286
|
-
for (let l = 0, d =
|
|
287
|
-
p === d && (p = 0), x === d && (x = 0), re[l] = Se(
|
|
286
|
+
for (let l = 0, d = H.length, p = d - 1, x = l + 1; l < d; l++, p++, x++)
|
|
287
|
+
p === d && (p = 0), x === d && (x = 0), re[l] = Se(H[l], H[p], H[x]);
|
|
288
288
|
const me = [];
|
|
289
289
|
let q, ae = re.concat();
|
|
290
290
|
for (let l = 0, d = pe; l < d; l++) {
|
|
@@ -296,13 +296,13 @@ class K extends fe {
|
|
|
296
296
|
}
|
|
297
297
|
let J;
|
|
298
298
|
if (S === 0)
|
|
299
|
-
J = de.triangulateShape(
|
|
299
|
+
J = de.triangulateShape(H, I);
|
|
300
300
|
else {
|
|
301
301
|
const l = [], d = [];
|
|
302
302
|
for (let p = 0; p < S; p++) {
|
|
303
303
|
const x = p / S, b = u * Math.cos(x * Math.PI / 2), M = g * Math.sin(x * Math.PI / 2) + L;
|
|
304
|
-
for (let w = 0, T =
|
|
305
|
-
const E = te(
|
|
304
|
+
for (let w = 0, T = H.length; w < T; w++) {
|
|
305
|
+
const E = te(H[w], re[w], M);
|
|
306
306
|
W(E.x, E.y, -b), x === 0 && l.push(E);
|
|
307
307
|
}
|
|
308
308
|
for (let w = 0, T = pe; w < T; w++) {
|
|
@@ -324,17 +324,17 @@ class K extends fe {
|
|
|
324
324
|
const ce = J.length, Ae = g + L;
|
|
325
325
|
for (let l = 0; l < N; l++) {
|
|
326
326
|
const d = y ? te(O[l], ae[l], Ae) : O[l];
|
|
327
|
-
$ ? (oe.copy(U.normals[0]).multiplyScalar(d.x), se.copy(U.binormals[0]).multiplyScalar(d.y), X.copy(
|
|
327
|
+
$ ? (oe.copy(U.normals[0]).multiplyScalar(d.x), se.copy(U.binormals[0]).multiplyScalar(d.y), X.copy(D[0]).add(oe).add(se), W(X.x, X.y, X.z)) : W(d.x, d.y, 0);
|
|
328
328
|
}
|
|
329
329
|
for (let l = 1; l <= o; l++)
|
|
330
330
|
for (let d = 0; d < N; d++) {
|
|
331
331
|
const p = y ? te(O[d], ae[d], Ae) : O[d];
|
|
332
|
-
$ ? (oe.copy(U.normals[l]).multiplyScalar(p.x), se.copy(U.binormals[l]).multiplyScalar(p.y), X.copy(
|
|
332
|
+
$ ? (oe.copy(U.normals[l]).multiplyScalar(p.x), se.copy(U.binormals[l]).multiplyScalar(p.y), X.copy(D[l]).add(oe).add(se), W(X.x, X.y, X.z)) : W(p.x, p.y, c / o * l);
|
|
333
333
|
}
|
|
334
334
|
for (let l = S - 1; l >= 0; l--) {
|
|
335
335
|
const d = l / S, p = u * Math.cos(d * Math.PI / 2), x = g * Math.sin(d * Math.PI / 2) + L;
|
|
336
|
-
for (let b = 0, M =
|
|
337
|
-
const w = te(
|
|
336
|
+
for (let b = 0, M = H.length; b < M; b++) {
|
|
337
|
+
const w = te(H[b], re[b], x);
|
|
338
338
|
W(w.x, w.y, c + p);
|
|
339
339
|
}
|
|
340
340
|
for (let b = 0, M = I.length; b < M; b++) {
|
|
@@ -344,8 +344,8 @@ class K extends fe {
|
|
|
344
344
|
const C = te(w[T], q[T], x);
|
|
345
345
|
$ ? W(
|
|
346
346
|
C.x,
|
|
347
|
-
C.y +
|
|
348
|
-
|
|
347
|
+
C.y + D[o - 1].y,
|
|
348
|
+
D[o - 1].x + p
|
|
349
349
|
) : W(C.x, C.y, c + p);
|
|
350
350
|
}
|
|
351
351
|
}
|
|
@@ -386,7 +386,7 @@ class K extends fe {
|
|
|
386
386
|
function ke() {
|
|
387
387
|
const l = s.length / 3;
|
|
388
388
|
let d = 0;
|
|
389
|
-
Me(
|
|
389
|
+
Me(H, d), d += H.length;
|
|
390
390
|
for (let p = 0, x = I.length; p < x; p++) {
|
|
391
391
|
const b = I[p];
|
|
392
392
|
Me(b, d), d += b.length;
|
|
@@ -549,7 +549,7 @@ class Rt extends K {
|
|
|
549
549
|
if (r) {
|
|
550
550
|
const A = r.min, P = r.max, v = new _().subVectors(P, A);
|
|
551
551
|
for (let z = 0; z < u.count; z++) {
|
|
552
|
-
const ee = u.getX(z),
|
|
552
|
+
const ee = u.getX(z), D = u.getY(z), $ = (ee - A.x) / v.x, U = (D - A.y) / v.y;
|
|
553
553
|
g.setXY(z, $, U);
|
|
554
554
|
}
|
|
555
555
|
y.geometry.setAttribute("uv", g);
|
|
@@ -557,11 +557,11 @@ class Rt extends K {
|
|
|
557
557
|
u.needsUpdate = !0;
|
|
558
558
|
const L = new K(e, ue(j({}, t), {
|
|
559
559
|
hasTop: !1
|
|
560
|
-
})), S =
|
|
560
|
+
})), S = V([y.geometry, L], 2);
|
|
561
561
|
this.copy(S.toNonIndexed());
|
|
562
562
|
}
|
|
563
563
|
}
|
|
564
|
-
const
|
|
564
|
+
const He = (m) => {
|
|
565
565
|
const {
|
|
566
566
|
split: e,
|
|
567
567
|
depth: t,
|
|
@@ -611,7 +611,7 @@ class $t extends Z {
|
|
|
611
611
|
hasSide: y
|
|
612
612
|
} = this.options, u = Array.isArray(s) ? s : [s], g = Array.isArray(r) ? r : [r], L = f;
|
|
613
613
|
let S = i;
|
|
614
|
-
L || console.log("material is null"), !S && e ? S =
|
|
614
|
+
L || console.log("material is null"), !S && e ? S = He({
|
|
615
615
|
points: e,
|
|
616
616
|
depth: u[0],
|
|
617
617
|
box3: g[0],
|
|
@@ -619,11 +619,11 @@ class $t extends Z {
|
|
|
619
619
|
hasTop: o,
|
|
620
620
|
hasBottom: c,
|
|
621
621
|
hasSide: y
|
|
622
|
-
}) : !S && t ? S =
|
|
622
|
+
}) : !S && t ? S = V(
|
|
623
623
|
t.map(
|
|
624
624
|
(A, P) => {
|
|
625
625
|
var v, z;
|
|
626
|
-
return
|
|
626
|
+
return He({
|
|
627
627
|
points: A,
|
|
628
628
|
depth: (v = u[P]) != null ? v : u[0],
|
|
629
629
|
box3: (z = g[P]) != null ? z : g[0],
|
|
@@ -635,11 +635,11 @@ class $t extends Z {
|
|
|
635
635
|
}
|
|
636
636
|
),
|
|
637
637
|
n != null ? n : 0
|
|
638
|
-
) : !S && a && a.length > 1 ? S =
|
|
638
|
+
) : !S && a && a.length > 1 ? S = V(a, n != null ? n : 0) : !S && a && a.length === 1 && ([S] = a), this.createMesh(S, L);
|
|
639
639
|
});
|
|
640
640
|
}
|
|
641
641
|
addGeometries(e) {
|
|
642
|
-
const t = this.object3d, n =
|
|
642
|
+
const t = this.object3d, n = V([t.geometry, ...e]);
|
|
643
643
|
t.geometry = n;
|
|
644
644
|
}
|
|
645
645
|
setTextureAnisotropic(e, t) {
|
|
@@ -743,7 +743,7 @@ class Kt extends Z {
|
|
|
743
743
|
}
|
|
744
744
|
class Ot extends fe {
|
|
745
745
|
constructor(e = [], t = "none", n) {
|
|
746
|
-
super(), this.type = "MeshLineGeometry", this.pointCount = 0, this._points = [], this.shape = "none", this.shapeFunction = (s) => 1, this.matrixWorld = new
|
|
746
|
+
super(), this.type = "MeshLineGeometry", this.pointCount = 0, this._points = [], this.shape = "none", this.shapeFunction = (s) => 1, this.matrixWorld = new De(), this.shape = t, n && (this.shapeFunction = n), e.length > 0 && this.setPoints(e);
|
|
747
747
|
}
|
|
748
748
|
convertToVector3Array(e) {
|
|
749
749
|
if (typeof e[0] == "number") {
|
|
@@ -830,7 +830,7 @@ class Ot extends fe {
|
|
|
830
830
|
}
|
|
831
831
|
}
|
|
832
832
|
function en(m, e) {
|
|
833
|
-
const t = new
|
|
833
|
+
const t = new De(), n = new St(), s = new At(), i = new _(), a = this.geometry;
|
|
834
834
|
if (s.copy(a.boundingSphere), s.applyMatrix4(this.matrixWorld), !m.ray.intersectSphere(s, i)) return;
|
|
835
835
|
t.copy(this.matrixWorld).invert(), n.copy(m.ray).applyMatrix4(t);
|
|
836
836
|
const f = new _(), r = new _(), h = new _(), o = this instanceof Xe ? 2 : 1, c = a.index, y = a.attributes;
|
|
@@ -839,13 +839,13 @@ function en(m, e) {
|
|
|
839
839
|
for (let S = 0, A = u.length - 1; S < A; S += o) {
|
|
840
840
|
const P = u[S], v = u[S + 1];
|
|
841
841
|
f.fromArray(g, P * 3), r.fromArray(g, v * 3);
|
|
842
|
-
const z = L[Math.floor(S / 3)] !== void 0 ? L[Math.floor(S / 3)] : 1, ee = m.params.Line.threshold + this.material.lineWidth * z / 2,
|
|
842
|
+
const z = L[Math.floor(S / 3)] !== void 0 ? L[Math.floor(S / 3)] : 1, ee = m.params.Line.threshold + this.material.lineWidth * z / 2, D = ee * ee;
|
|
843
843
|
if (n.distanceSqToSegment(
|
|
844
844
|
f,
|
|
845
845
|
r,
|
|
846
846
|
i,
|
|
847
847
|
h
|
|
848
|
-
) >
|
|
848
|
+
) > D) continue;
|
|
849
849
|
i.applyMatrix4(this.matrixWorld);
|
|
850
850
|
const U = m.ray.origin.distanceTo(i);
|
|
851
851
|
U < m.near || U > m.far || (e.push({
|
|
@@ -890,7 +890,7 @@ let tn = class extends Z {
|
|
|
890
890
|
!o && h && (o = this.getMaterial(h)), !c && e ? c = ye({
|
|
891
891
|
nodes: e,
|
|
892
892
|
setPointWidth: f
|
|
893
|
-
}) : !c && t ? c =
|
|
893
|
+
}) : !c && t ? c = V(
|
|
894
894
|
t.map((y, u) => {
|
|
895
895
|
let g = f;
|
|
896
896
|
return !g && r && (g = () => {
|
|
@@ -902,7 +902,7 @@ let tn = class extends Z {
|
|
|
902
902
|
});
|
|
903
903
|
}),
|
|
904
904
|
a != null ? a : 0
|
|
905
|
-
) : !c && s && s.length > 1 ? c =
|
|
905
|
+
) : !c && s && s.length > 1 ? c = V(s, a != null ? a : 0) : !c && s && s.length === 1 && ([c] = s), this.createMesh(c, o);
|
|
906
906
|
});
|
|
907
907
|
}
|
|
908
908
|
setGeometry(e, t) {
|
|
@@ -919,7 +919,7 @@ let tn = class extends Z {
|
|
|
919
919
|
return s.uniforms.resolution.value.set(t, n), s;
|
|
920
920
|
}
|
|
921
921
|
addGeometries(e) {
|
|
922
|
-
const t = this.object3d, n =
|
|
922
|
+
const t = this.object3d, n = V([t.geometry, ...e]);
|
|
923
923
|
t.geometry = n;
|
|
924
924
|
}
|
|
925
925
|
resize(e, t) {
|
|
@@ -955,17 +955,16 @@ let tn = class extends Z {
|
|
|
955
955
|
}).onComplete(() => {
|
|
956
956
|
f && f();
|
|
957
957
|
}).start();
|
|
958
|
-
this.material.userData.tween =
|
|
958
|
+
this.material.userData.tween = !0, this.material.addEventListener("dispose", () => {
|
|
959
|
+
u.stop(), ne.remove(u), this.material.userData.tween = null;
|
|
960
|
+
});
|
|
959
961
|
}
|
|
960
962
|
render() {
|
|
961
963
|
const { width: e, height: t } = this.pencil.getSize();
|
|
962
964
|
this.resize(e, t);
|
|
963
965
|
}
|
|
964
|
-
dispose() {
|
|
965
|
-
this.material.userData.tween && (this.material.userData.tween.stop(), ne.remove(this.material.userData.tween)), super.dispose();
|
|
966
|
-
}
|
|
967
966
|
};
|
|
968
|
-
const
|
|
967
|
+
const Ve = (m) => {
|
|
969
968
|
const { points: e } = m, t = e.reduce((s, i, a) => (a < e.length - 1 && s.push(i, e[a + 1]), s), []);
|
|
970
969
|
return new fe().setFromPoints(t);
|
|
971
970
|
};
|
|
@@ -992,14 +991,14 @@ class sn extends Z {
|
|
|
992
991
|
instanceCount: o
|
|
993
992
|
} = this.options;
|
|
994
993
|
let c = i, y = n;
|
|
995
|
-
!c && h && (c = this.getMaterial(h)), !y && e ? y =
|
|
994
|
+
!c && h && (c = this.getMaterial(h)), !y && e ? y = Ve({
|
|
996
995
|
points: e
|
|
997
|
-
}) : !y && t ? y =
|
|
998
|
-
t.map((g) =>
|
|
996
|
+
}) : !y && t ? y = V(
|
|
997
|
+
t.map((g) => Ve({
|
|
999
998
|
points: g
|
|
1000
999
|
})),
|
|
1001
1000
|
a != null ? a : 0
|
|
1002
|
-
) : !y && s && s.length > 1 ? y =
|
|
1001
|
+
) : !y && s && s.length > 1 ? y = V(s, a != null ? a : 0) : !y && s && s.length === 1 && ([y] = s);
|
|
1003
1002
|
const u = new Ke().fromLineSegments(
|
|
1004
1003
|
new Xe(y)
|
|
1005
1004
|
);
|