gl-draw 0.15.19 → 0.15.21
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 +139 -0
- package/dist/WebGPULineSegments2.module.js +1014 -0
- package/dist/core/BaseObject/index.d.ts +2 -1
- package/dist/core/Composer.d.ts +5 -5
- package/dist/core/ResourceTracker.d.ts +1 -1
- package/dist/index.js +23 -23
- package/dist/index.module.js +79 -75
- package/dist/objects/conicPolygon/geometry/index.d.ts +4 -4
- package/dist/objects/index.d.ts +8 -8
- package/dist/objects/index.js +1 -1
- package/dist/objects/index.module.js +954 -927
- package/dist/objects/line/createGeometry.d.ts +2 -2
- package/dist/objects/line/index.d.ts +5 -5
- package/dist/objects/line/meshLine/MeshLineGeometry.d.ts +16 -35
- package/dist/objects/line/meshLine/MeshLineMaterial.d.ts +67 -41
- package/dist/objects/line/meshLine/fragment.d.ts +1 -0
- package/dist/objects/line/meshLine/index.d.ts +1 -0
- package/dist/objects/line/meshLine/raycast.d.ts +3 -0
- package/dist/objects/line/meshLine/vertex.d.ts +1 -0
- package/dist/plugins/index.js +1 -1
- package/dist/plugins/index.module.js +24 -24
- package/package.json +1 -1
- package/dist/index.module2.js +0 -1173
- package/dist/index2.js +0 -149
|
@@ -1,365 +1,450 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
for (var
|
|
7
|
-
|
|
8
|
-
if (
|
|
9
|
-
for (var
|
|
10
|
-
|
|
11
|
-
return
|
|
12
|
-
},
|
|
13
|
-
var
|
|
14
|
-
var
|
|
15
|
-
for (var
|
|
16
|
-
|
|
17
|
-
if (
|
|
18
|
-
for (var
|
|
19
|
-
|
|
20
|
-
return
|
|
1
|
+
var Ze = Object.defineProperty, $e = Object.defineProperties;
|
|
2
|
+
var Je = Object.getOwnPropertyDescriptors;
|
|
3
|
+
var he = Object.getOwnPropertySymbols;
|
|
4
|
+
var Ie = Object.prototype.hasOwnProperty, Be = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var ze = (m, e, t) => e in m ? Ze(m, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : m[e] = t, j = (m, e) => {
|
|
6
|
+
for (var t in e || (e = {}))
|
|
7
|
+
Ie.call(e, t) && ze(m, t, e[t]);
|
|
8
|
+
if (he)
|
|
9
|
+
for (var t of he(e))
|
|
10
|
+
Be.call(e, t) && ze(m, t, e[t]);
|
|
11
|
+
return m;
|
|
12
|
+
}, ue = (m, e) => $e(m, Je(e));
|
|
13
|
+
var ge = (m, e) => {
|
|
14
|
+
var t = {};
|
|
15
|
+
for (var n in m)
|
|
16
|
+
Ie.call(m, n) && e.indexOf(n) < 0 && (t[n] = m[n]);
|
|
17
|
+
if (m != null && he)
|
|
18
|
+
for (var n of he(m))
|
|
19
|
+
e.indexOf(n) < 0 && Be.call(m, n) && (t[n] = m[n]);
|
|
20
|
+
return t;
|
|
21
21
|
};
|
|
22
|
-
var
|
|
23
|
-
var
|
|
22
|
+
var ie = (m, e, t) => new Promise((n, s) => {
|
|
23
|
+
var i = (r) => {
|
|
24
24
|
try {
|
|
25
|
-
|
|
26
|
-
} catch (
|
|
27
|
-
|
|
25
|
+
f(t.next(r));
|
|
26
|
+
} catch (h) {
|
|
27
|
+
s(h);
|
|
28
28
|
}
|
|
29
|
-
},
|
|
29
|
+
}, a = (r) => {
|
|
30
30
|
try {
|
|
31
|
-
|
|
32
|
-
} catch (
|
|
33
|
-
|
|
31
|
+
f(t.throw(r));
|
|
32
|
+
} catch (h) {
|
|
33
|
+
s(h);
|
|
34
34
|
}
|
|
35
|
-
},
|
|
36
|
-
|
|
35
|
+
}, f = (r) => r.done ? n(r.value) : Promise.resolve(r.value).then(i, a);
|
|
36
|
+
f((t = t.apply(m, e)).next());
|
|
37
37
|
});
|
|
38
|
-
import {
|
|
39
|
-
import {
|
|
40
|
-
import {
|
|
41
|
-
import
|
|
42
|
-
import {
|
|
43
|
-
import {
|
|
44
|
-
import {
|
|
45
|
-
import {
|
|
46
|
-
import {
|
|
47
|
-
import {
|
|
48
|
-
import {
|
|
49
|
-
import
|
|
50
|
-
import {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
38
|
+
import { LineMaterial as Qe } from "three/examples/jsm/lines/LineMaterial";
|
|
39
|
+
import { LineMaterial as ln } from "three/examples/jsm/lines/LineMaterial";
|
|
40
|
+
import { LineSegmentsGeometry as Ke } from "three/examples/jsm/lines/LineSegmentsGeometry";
|
|
41
|
+
import { LineSegmentsGeometry as un } from "three/examples/jsm/lines/LineSegmentsGeometry";
|
|
42
|
+
import { P as et, a as Z, M as tt, L as nt } from "../WebGPULineSegments2.module.js";
|
|
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 Ve, BufferAttribute as Y, Ray as St, Sphere as At, LineSegments as Xe, Color as Ne, MeshBasicMaterial as Mt, Mesh as Lt } from "three";
|
|
45
|
+
import { mergeAttributes as Re, mergeGroups as Tt } from "three/examples/jsm/utils/BufferGeometryUtils";
|
|
46
|
+
import { g as Et, c as Ct } from "../uvGenerator.module.js";
|
|
47
|
+
import { Brush as Oe, Evaluator as Gt, INTERSECTION as Pt } from "three-bvh-csg";
|
|
48
|
+
import { RectAreaLightUniformsLib as _t } from "three/examples/jsm/lights/RectAreaLightUniformsLib";
|
|
49
|
+
import * as ne from "@tweenjs/tween.js";
|
|
50
|
+
import { LineSegments2 as jt } from "three/examples/jsm/lines/LineSegments2";
|
|
51
|
+
function H(m, e = 0) {
|
|
52
|
+
const t = m[0].index !== null, n = new Set(Object.keys(m[0].attributes)), s = new Set(
|
|
53
|
+
Object.keys(m[0].morphAttributes)
|
|
54
|
+
), i = {}, a = {}, f = m[0].morphTargetsRelative, r = new fe();
|
|
55
|
+
let h = 0;
|
|
56
|
+
for (let o = 0; o < m.length; ++o) {
|
|
57
|
+
const c = m[o];
|
|
58
|
+
let y = 0;
|
|
59
|
+
if (t !== (c.index !== null))
|
|
60
|
+
return console.error(
|
|
61
|
+
"THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index " + o + ". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them."
|
|
62
|
+
), null;
|
|
63
|
+
for (const u in c.attributes) {
|
|
64
|
+
if (!n.has(u))
|
|
65
|
+
return console.error(
|
|
66
|
+
"THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index " + o + '. All geometries must have compatible attributes; make sure "' + u + '" attribute exists among all geometries, or in none of them.'
|
|
67
|
+
), null;
|
|
68
|
+
i[u] === void 0 && (i[u] = []), i[u].push(c.attributes[u]), y++;
|
|
69
|
+
}
|
|
70
|
+
if (y !== n.size)
|
|
71
|
+
return console.error(
|
|
72
|
+
"THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index " + o + ". Make sure all geometries have the same number of attributes."
|
|
73
|
+
), null;
|
|
74
|
+
if (f !== c.morphTargetsRelative)
|
|
75
|
+
return console.error(
|
|
76
|
+
"THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index " + o + ". .morphTargetsRelative must be consistent throughout all geometries."
|
|
77
|
+
), null;
|
|
78
|
+
for (const u in c.morphAttributes) {
|
|
79
|
+
if (!s.has(u))
|
|
80
|
+
return console.error(
|
|
81
|
+
"THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index " + o + ". .morphAttributes must be consistent throughout all geometries."
|
|
82
|
+
), null;
|
|
83
|
+
a[u] === void 0 && (a[u] = []), a[u].push(c.morphAttributes[u]);
|
|
84
|
+
}
|
|
85
|
+
if (e) {
|
|
86
|
+
let u;
|
|
87
|
+
if (t)
|
|
88
|
+
u = c.index.count;
|
|
89
|
+
else if (c.attributes.position !== void 0)
|
|
90
|
+
u = c.attributes.position.count;
|
|
91
|
+
else
|
|
92
|
+
return console.error(
|
|
93
|
+
"THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index " + o + ". The geometry must have either an index or a position attribute"
|
|
94
|
+
), null;
|
|
95
|
+
if (e === 1)
|
|
96
|
+
r.addGroup(h, u, o);
|
|
97
|
+
else if (e === 2 && c.groups.length > 0)
|
|
98
|
+
for (let g of c.groups) {
|
|
99
|
+
let L = g.materialIndex;
|
|
100
|
+
r.addGroup(
|
|
101
|
+
h + g.start,
|
|
102
|
+
Math.min(g.count, u),
|
|
103
|
+
L
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
h += u;
|
|
107
|
+
}
|
|
76
108
|
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
}
|
|
86
|
-
|
|
109
|
+
if (t) {
|
|
110
|
+
let o = 0;
|
|
111
|
+
const c = [];
|
|
112
|
+
for (let y = 0; y < m.length; ++y) {
|
|
113
|
+
const u = m[y].index;
|
|
114
|
+
for (let g = 0; g < u.count; ++g)
|
|
115
|
+
c.push(u.getX(g) + o);
|
|
116
|
+
o += m[y].attributes.position.count;
|
|
117
|
+
}
|
|
118
|
+
r.setIndex(c);
|
|
87
119
|
}
|
|
88
|
-
|
|
89
|
-
const
|
|
90
|
-
|
|
120
|
+
for (const o in i) {
|
|
121
|
+
const c = Re(i[o]);
|
|
122
|
+
if (!c)
|
|
123
|
+
return console.error(
|
|
124
|
+
"THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the " + o + " attribute."
|
|
125
|
+
), null;
|
|
126
|
+
r.setAttribute(o, c);
|
|
91
127
|
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
}
|
|
128
|
+
for (const o in a) {
|
|
129
|
+
const c = a[o][0].length;
|
|
130
|
+
if (c === 0) break;
|
|
131
|
+
r.morphAttributes = r.morphAttributes || {}, r.morphAttributes[o] = [];
|
|
132
|
+
for (let y = 0; y < c; ++y) {
|
|
133
|
+
const u = [];
|
|
134
|
+
for (let L = 0; L < a[o].length; ++L)
|
|
135
|
+
u.push(a[o][L][y]);
|
|
136
|
+
const g = Re(u);
|
|
137
|
+
if (!g)
|
|
138
|
+
return console.error(
|
|
139
|
+
"THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the " + o + " morphAttribute."
|
|
140
|
+
), null;
|
|
141
|
+
r.morphAttributes[o].push(g);
|
|
142
|
+
}
|
|
96
143
|
}
|
|
144
|
+
return e === 2 ? Tt(r) : r;
|
|
97
145
|
}
|
|
98
|
-
|
|
146
|
+
const Ue = (m) => {
|
|
147
|
+
const f = m, { coordinate: e, startHeight: t, height: n } = f, s = ge(f, ["coordinate", "startHeight", "height"]);
|
|
148
|
+
let i = t || 0;
|
|
149
|
+
return typeof t != "undefined" && typeof n != "undefined" && (i = t + n), new et([e], ue(j({}, s), {
|
|
150
|
+
startHeight: t,
|
|
151
|
+
endHeight: i
|
|
152
|
+
}));
|
|
153
|
+
};
|
|
154
|
+
class Zt extends Z {
|
|
155
|
+
constructor(e) {
|
|
156
|
+
super(), this.options = j({}, e);
|
|
157
|
+
}
|
|
99
158
|
create() {
|
|
100
|
-
this.
|
|
159
|
+
const r = this.options, {
|
|
160
|
+
geometry: e,
|
|
161
|
+
coordinateArr: t,
|
|
162
|
+
coordinate: n,
|
|
163
|
+
material: s,
|
|
164
|
+
useGroups: i
|
|
165
|
+
} = r, a = ge(r, [
|
|
166
|
+
"geometry",
|
|
167
|
+
"coordinateArr",
|
|
168
|
+
"coordinate",
|
|
169
|
+
"material",
|
|
170
|
+
"useGroups"
|
|
171
|
+
]);
|
|
172
|
+
let f = e;
|
|
173
|
+
if (!f && n)
|
|
174
|
+
f = Ue(j({
|
|
175
|
+
coordinate: n
|
|
176
|
+
}, a));
|
|
177
|
+
else if (!f && t) {
|
|
178
|
+
const h = t.map(
|
|
179
|
+
(o) => Ue(j({
|
|
180
|
+
coordinate: o
|
|
181
|
+
}, a))
|
|
182
|
+
);
|
|
183
|
+
f = H(h, i != null ? i : 0);
|
|
184
|
+
}
|
|
185
|
+
this.createMesh(f, s);
|
|
101
186
|
}
|
|
102
187
|
}
|
|
103
|
-
const
|
|
104
|
-
ArcCurve:
|
|
105
|
-
CatmullRomCurve3:
|
|
106
|
-
CubicBezierCurve:
|
|
107
|
-
CubicBezierCurve3:
|
|
108
|
-
EllipseCurve:
|
|
109
|
-
LineCurve:
|
|
110
|
-
LineCurve3:
|
|
111
|
-
QuadraticBezierCurve:
|
|
112
|
-
QuadraticBezierCurve3:
|
|
113
|
-
SplineCurve:
|
|
188
|
+
const zt = {
|
|
189
|
+
ArcCurve: st,
|
|
190
|
+
CatmullRomCurve3: ot,
|
|
191
|
+
CubicBezierCurve: it,
|
|
192
|
+
CubicBezierCurve3: rt,
|
|
193
|
+
EllipseCurve: at,
|
|
194
|
+
LineCurve: ct,
|
|
195
|
+
LineCurve3: lt,
|
|
196
|
+
QuadraticBezierCurve: ht,
|
|
197
|
+
QuadraticBezierCurve3: ut,
|
|
198
|
+
SplineCurve: dt
|
|
114
199
|
};
|
|
115
|
-
class
|
|
200
|
+
class K extends fe {
|
|
116
201
|
/**
|
|
117
202
|
* Constructs a new extrude geometry.
|
|
118
203
|
*
|
|
119
204
|
* @param {Shape|Array<Shape>} [shapes] - A shape or an array of shapes.
|
|
120
205
|
* @param {ExtrudeGeometry~Options} [options] - The extrude settings.
|
|
121
206
|
*/
|
|
122
|
-
constructor(
|
|
123
|
-
new
|
|
124
|
-
new
|
|
125
|
-
new
|
|
126
|
-
new
|
|
127
|
-
]),
|
|
207
|
+
constructor(e = new xe([
|
|
208
|
+
new G(0.5, 0.5),
|
|
209
|
+
new G(-0.5, 0.5),
|
|
210
|
+
new G(-0.5, -0.5),
|
|
211
|
+
new G(0.5, -0.5)
|
|
212
|
+
]), t = {}) {
|
|
128
213
|
super(), this.type = "ExtrudeGeometry", this.parameters = {
|
|
129
|
-
shapes:
|
|
130
|
-
options:
|
|
131
|
-
},
|
|
132
|
-
const
|
|
133
|
-
for (let
|
|
134
|
-
const
|
|
135
|
-
|
|
214
|
+
shapes: e,
|
|
215
|
+
options: t
|
|
216
|
+
}, e = Array.isArray(e) ? e : [e];
|
|
217
|
+
const n = this, s = [], i = [];
|
|
218
|
+
for (let f = 0, r = e.length; f < r; f++) {
|
|
219
|
+
const h = e[f];
|
|
220
|
+
a(h);
|
|
136
221
|
}
|
|
137
|
-
this.setAttribute("position", new
|
|
138
|
-
function
|
|
139
|
-
var
|
|
140
|
-
const
|
|
141
|
-
let y =
|
|
142
|
-
const
|
|
143
|
-
let
|
|
144
|
-
|
|
145
|
-
const
|
|
146
|
-
let
|
|
147
|
-
const
|
|
148
|
-
if (!
|
|
149
|
-
|
|
150
|
-
for (let
|
|
151
|
-
const p =
|
|
152
|
-
|
|
222
|
+
this.setAttribute("position", new be(s, 3)), this.setAttribute("uv", new be(i, 2)), this.computeVertexNormals();
|
|
223
|
+
function a(f) {
|
|
224
|
+
var Le, Te, Ee;
|
|
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
|
+
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
|
+
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 V, $ = !1, U, se, oe, X;
|
|
229
|
+
A && (V = 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
|
+
const we = f.extractPoints(h);
|
|
231
|
+
let O = we.shape;
|
|
232
|
+
const I = we.holes;
|
|
233
|
+
if (!de.isClockWise(O)) {
|
|
234
|
+
O = O.reverse();
|
|
235
|
+
for (let l = 0, d = I.length; l < d; l++) {
|
|
236
|
+
const p = I[l];
|
|
237
|
+
de.isClockWise(p) && (I[l] = p.reverse());
|
|
153
238
|
}
|
|
154
239
|
}
|
|
155
|
-
function
|
|
240
|
+
function ve(l) {
|
|
156
241
|
const p = 10000000000000001e-36;
|
|
157
|
-
let
|
|
158
|
-
for (let
|
|
159
|
-
const
|
|
242
|
+
let x = l[0];
|
|
243
|
+
for (let b = 1; b <= l.length; b++) {
|
|
244
|
+
const M = b % l.length, w = l[M], T = w.x - x.x, E = w.y - x.y, C = T * T + E * E, B = Math.max(
|
|
245
|
+
Math.abs(w.x),
|
|
246
|
+
Math.abs(w.y),
|
|
160
247
|
Math.abs(x.x),
|
|
161
|
-
Math.abs(x.y)
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
if (E <= Y) {
|
|
166
|
-
c.splice(A, 1), m--;
|
|
248
|
+
Math.abs(x.y)
|
|
249
|
+
), Q = p * B * B;
|
|
250
|
+
if (C <= Q) {
|
|
251
|
+
l.splice(M, 1), b--;
|
|
167
252
|
continue;
|
|
168
253
|
}
|
|
169
|
-
|
|
254
|
+
x = w;
|
|
170
255
|
}
|
|
171
256
|
}
|
|
172
|
-
|
|
173
|
-
const
|
|
174
|
-
for (let
|
|
175
|
-
const d =
|
|
176
|
-
|
|
257
|
+
ve(O), I.forEach(ve);
|
|
258
|
+
const pe = I.length, D = O;
|
|
259
|
+
for (let l = 0; l < pe; l++) {
|
|
260
|
+
const d = I[l];
|
|
261
|
+
O = O.concat(d);
|
|
177
262
|
}
|
|
178
|
-
function
|
|
179
|
-
return d || console.error("THREE.ExtrudeGeometry: vec does not exist"),
|
|
263
|
+
function te(l, d, p) {
|
|
264
|
+
return d || console.error("THREE.ExtrudeGeometry: vec does not exist"), l.clone().addScaledVector(d, p);
|
|
180
265
|
}
|
|
181
|
-
const
|
|
182
|
-
function
|
|
183
|
-
let
|
|
184
|
-
const
|
|
185
|
-
if (Math.abs(
|
|
186
|
-
const
|
|
187
|
-
|
|
188
|
-
),
|
|
189
|
-
|
|
190
|
-
const
|
|
191
|
-
if (
|
|
192
|
-
return new
|
|
193
|
-
|
|
266
|
+
const N = O.length;
|
|
267
|
+
function Se(l, d, p) {
|
|
268
|
+
let x, b, M;
|
|
269
|
+
const w = l.x - d.x, T = l.y - d.y, E = p.x - l.x, C = p.y - l.y, B = w * w + T * T, Q = w * C - T * E;
|
|
270
|
+
if (Math.abs(Q) > Number.EPSILON) {
|
|
271
|
+
const R = Math.sqrt(B), Ce = Math.sqrt(
|
|
272
|
+
E * E + C * C
|
|
273
|
+
), Ge = d.x - T / R, Pe = d.y + w / R, qe = p.x - C / Ce, Ye = p.y + E / Ce, _e = ((qe - Ge) * C - (Ye - Pe) * E) / (w * C - T * E);
|
|
274
|
+
x = Ge + w * _e - l.x, b = Pe + T * _e - l.y;
|
|
275
|
+
const je = x * x + b * b;
|
|
276
|
+
if (je <= 2)
|
|
277
|
+
return new G(x, b);
|
|
278
|
+
M = Math.sqrt(je / 2);
|
|
194
279
|
} else {
|
|
195
|
-
let
|
|
196
|
-
|
|
280
|
+
let R = !1;
|
|
281
|
+
w > Number.EPSILON ? E > Number.EPSILON && (R = !0) : w < -Number.EPSILON ? E < -Number.EPSILON && (R = !0) : Math.sign(T) === Math.sign(C) && (R = !0), R ? (x = -T, b = w, M = Math.sqrt(B)) : (x = w, b = T, M = Math.sqrt(B / 2));
|
|
197
282
|
}
|
|
198
|
-
return new
|
|
283
|
+
return new G(x / M, b / M);
|
|
199
284
|
}
|
|
200
|
-
const
|
|
201
|
-
for (let
|
|
202
|
-
p === d && (p = 0),
|
|
203
|
-
const
|
|
204
|
-
let
|
|
205
|
-
for (let
|
|
206
|
-
const p =
|
|
207
|
-
|
|
208
|
-
for (let
|
|
209
|
-
|
|
210
|
-
|
|
285
|
+
const re = [];
|
|
286
|
+
for (let l = 0, d = D.length, p = d - 1, x = l + 1; l < d; l++, p++, x++)
|
|
287
|
+
p === d && (p = 0), x === d && (x = 0), re[l] = Se(D[l], D[p], D[x]);
|
|
288
|
+
const me = [];
|
|
289
|
+
let q, ae = re.concat();
|
|
290
|
+
for (let l = 0, d = pe; l < d; l++) {
|
|
291
|
+
const p = I[l];
|
|
292
|
+
q = [];
|
|
293
|
+
for (let x = 0, b = p.length, M = b - 1, w = x + 1; x < b; x++, M++, w++)
|
|
294
|
+
M === b && (M = 0), w === b && (w = 0), q[x] = Se(p[x], p[M], p[w]);
|
|
295
|
+
me.push(q), ae = ae.concat(q);
|
|
211
296
|
}
|
|
212
|
-
let
|
|
213
|
-
if (
|
|
214
|
-
|
|
297
|
+
let J;
|
|
298
|
+
if (S === 0)
|
|
299
|
+
J = de.triangulateShape(D, I);
|
|
215
300
|
else {
|
|
216
|
-
const
|
|
217
|
-
for (let p = 0; p <
|
|
218
|
-
const
|
|
219
|
-
for (let
|
|
220
|
-
const
|
|
221
|
-
|
|
301
|
+
const l = [], d = [];
|
|
302
|
+
for (let p = 0; p < S; p++) {
|
|
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 = D.length; w < T; w++) {
|
|
305
|
+
const E = te(D[w], re[w], M);
|
|
306
|
+
W(E.x, E.y, -b), x === 0 && l.push(E);
|
|
222
307
|
}
|
|
223
|
-
for (let
|
|
224
|
-
const
|
|
225
|
-
|
|
226
|
-
const
|
|
227
|
-
for (let
|
|
228
|
-
const
|
|
229
|
-
|
|
308
|
+
for (let w = 0, T = pe; w < T; w++) {
|
|
309
|
+
const E = I[w];
|
|
310
|
+
q = me[w];
|
|
311
|
+
const C = [];
|
|
312
|
+
for (let B = 0, Q = E.length; B < Q; B++) {
|
|
313
|
+
const R = te(E[B], q[B], M);
|
|
314
|
+
W(R.x, R.y, -b), x === 0 && C.push(R);
|
|
230
315
|
}
|
|
231
|
-
|
|
316
|
+
x === 0 && d.push(C);
|
|
232
317
|
}
|
|
233
318
|
}
|
|
234
|
-
|
|
235
|
-
|
|
319
|
+
J = de.triangulateShape(
|
|
320
|
+
l,
|
|
236
321
|
d
|
|
237
322
|
);
|
|
238
323
|
}
|
|
239
|
-
const
|
|
240
|
-
for (let
|
|
241
|
-
const d = y ?
|
|
242
|
-
|
|
324
|
+
const ce = J.length, Ae = g + L;
|
|
325
|
+
for (let l = 0; l < N; l++) {
|
|
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(V[0]).add(oe).add(se), W(X.x, X.y, X.z)) : W(d.x, d.y, 0);
|
|
243
328
|
}
|
|
244
|
-
for (let
|
|
245
|
-
for (let d = 0; d <
|
|
246
|
-
const p = y ?
|
|
247
|
-
|
|
329
|
+
for (let l = 1; l <= o; l++)
|
|
330
|
+
for (let d = 0; d < N; d++) {
|
|
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(V[l]).add(oe).add(se), W(X.x, X.y, X.z)) : W(p.x, p.y, c / o * l);
|
|
248
333
|
}
|
|
249
|
-
for (let
|
|
250
|
-
const d =
|
|
251
|
-
for (let
|
|
252
|
-
const
|
|
253
|
-
|
|
334
|
+
for (let l = S - 1; l >= 0; l--) {
|
|
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 = D.length; b < M; b++) {
|
|
337
|
+
const w = te(D[b], re[b], x);
|
|
338
|
+
W(w.x, w.y, c + p);
|
|
254
339
|
}
|
|
255
|
-
for (let
|
|
256
|
-
const
|
|
257
|
-
|
|
258
|
-
for (let
|
|
259
|
-
const
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
) :
|
|
340
|
+
for (let b = 0, M = I.length; b < M; b++) {
|
|
341
|
+
const w = I[b];
|
|
342
|
+
q = me[b];
|
|
343
|
+
for (let T = 0, E = w.length; T < E; T++) {
|
|
344
|
+
const C = te(w[T], q[T], x);
|
|
345
|
+
$ ? W(
|
|
346
|
+
C.x,
|
|
347
|
+
C.y + V[o - 1].y,
|
|
348
|
+
V[o - 1].x + p
|
|
349
|
+
) : W(C.x, C.y, c + p);
|
|
265
350
|
}
|
|
266
351
|
}
|
|
267
352
|
}
|
|
268
|
-
|
|
269
|
-
function
|
|
270
|
-
const
|
|
353
|
+
We(), ee && ke();
|
|
354
|
+
function We() {
|
|
355
|
+
const l = s.length / 3;
|
|
271
356
|
if (y) {
|
|
272
|
-
let d = 0, p =
|
|
273
|
-
if (
|
|
274
|
-
for (let
|
|
275
|
-
const
|
|
276
|
-
|
|
357
|
+
let d = 0, p = N * d;
|
|
358
|
+
if (z)
|
|
359
|
+
for (let x = 0; x < ce; x++) {
|
|
360
|
+
const b = J[x];
|
|
361
|
+
le(b[2] + p, b[1] + p, b[0] + p);
|
|
277
362
|
}
|
|
278
|
-
if (d = o +
|
|
279
|
-
for (let
|
|
280
|
-
const
|
|
281
|
-
|
|
363
|
+
if (d = o + S * 2, p = N * d, v)
|
|
364
|
+
for (let x = 0; x < ce; x++) {
|
|
365
|
+
const b = J[x];
|
|
366
|
+
le(b[0] + p, b[1] + p, b[2] + p);
|
|
282
367
|
}
|
|
283
368
|
} else {
|
|
284
|
-
if (
|
|
285
|
-
for (let d = 0; d <
|
|
286
|
-
const p =
|
|
287
|
-
|
|
369
|
+
if (z)
|
|
370
|
+
for (let d = 0; d < ce; d++) {
|
|
371
|
+
const p = J[d];
|
|
372
|
+
le(p[2], p[1], p[0]);
|
|
288
373
|
}
|
|
289
374
|
if (v)
|
|
290
|
-
for (let d = 0; d <
|
|
291
|
-
const p =
|
|
292
|
-
|
|
293
|
-
p[0] +
|
|
294
|
-
p[1] +
|
|
295
|
-
p[2] +
|
|
375
|
+
for (let d = 0; d < ce; d++) {
|
|
376
|
+
const p = J[d];
|
|
377
|
+
le(
|
|
378
|
+
p[0] + N * o,
|
|
379
|
+
p[1] + N * o,
|
|
380
|
+
p[2] + N * o
|
|
296
381
|
);
|
|
297
382
|
}
|
|
298
383
|
}
|
|
299
|
-
|
|
384
|
+
n.addGroup(l, s.length / 3 - l, 0);
|
|
300
385
|
}
|
|
301
|
-
function
|
|
302
|
-
const
|
|
386
|
+
function ke() {
|
|
387
|
+
const l = s.length / 3;
|
|
303
388
|
let d = 0;
|
|
304
|
-
|
|
305
|
-
for (let p = 0,
|
|
306
|
-
const
|
|
307
|
-
|
|
389
|
+
Me(D, d), d += D.length;
|
|
390
|
+
for (let p = 0, x = I.length; p < x; p++) {
|
|
391
|
+
const b = I[p];
|
|
392
|
+
Me(b, d), d += b.length;
|
|
308
393
|
}
|
|
309
|
-
|
|
394
|
+
n.addGroup(l, s.length / 3 - l, 1);
|
|
310
395
|
}
|
|
311
|
-
function
|
|
312
|
-
let p =
|
|
396
|
+
function Me(l, d) {
|
|
397
|
+
let p = l.length;
|
|
313
398
|
for (; --p >= 0; ) {
|
|
314
|
-
const
|
|
315
|
-
let
|
|
316
|
-
|
|
317
|
-
for (let
|
|
318
|
-
const
|
|
319
|
-
|
|
399
|
+
const x = p;
|
|
400
|
+
let b = p - 1;
|
|
401
|
+
b < 0 && (b = l.length - 1);
|
|
402
|
+
for (let M = 0, w = o + S * 2; M < w; M++) {
|
|
403
|
+
const T = N * M, E = N * (M + 1), C = d + x + T, B = d + b + T, Q = d + b + E, R = d + x + E;
|
|
404
|
+
Fe(C, B, Q, R);
|
|
320
405
|
}
|
|
321
406
|
}
|
|
322
407
|
}
|
|
323
|
-
function
|
|
324
|
-
|
|
408
|
+
function W(l, d, p) {
|
|
409
|
+
r.push(l), r.push(d), r.push(p);
|
|
325
410
|
}
|
|
326
|
-
function
|
|
327
|
-
|
|
328
|
-
const
|
|
411
|
+
function le(l, d, p) {
|
|
412
|
+
k(l), k(d), k(p);
|
|
413
|
+
const x = s.length / 3, b = P.generateTopUV(
|
|
414
|
+
n,
|
|
329
415
|
s,
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
g - 1
|
|
416
|
+
x - 3,
|
|
417
|
+
x - 2,
|
|
418
|
+
x - 1
|
|
334
419
|
);
|
|
335
|
-
|
|
420
|
+
F(b[0]), F(b[1]), F(b[2]);
|
|
336
421
|
}
|
|
337
|
-
function
|
|
338
|
-
|
|
339
|
-
const
|
|
422
|
+
function Fe(l, d, p, x) {
|
|
423
|
+
k(l), k(d), k(x), k(d), k(p), k(x);
|
|
424
|
+
const b = s.length / 3, M = P.generateSideWallUV(
|
|
425
|
+
n,
|
|
340
426
|
s,
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
m - 1
|
|
427
|
+
b - 6,
|
|
428
|
+
b - 3,
|
|
429
|
+
b - 2,
|
|
430
|
+
b - 1
|
|
346
431
|
);
|
|
347
|
-
|
|
432
|
+
F(M[0]), F(M[1]), F(M[3]), F(M[1]), F(M[2]), F(M[3]);
|
|
348
433
|
}
|
|
349
|
-
function
|
|
350
|
-
|
|
434
|
+
function k(l) {
|
|
435
|
+
s.push(r[l * 3 + 0]), s.push(r[l * 3 + 1]), s.push(r[l * 3 + 2]);
|
|
351
436
|
}
|
|
352
|
-
function
|
|
353
|
-
|
|
437
|
+
function F(l) {
|
|
438
|
+
i.push(l.x), i.push(l.y);
|
|
354
439
|
}
|
|
355
440
|
}
|
|
356
441
|
}
|
|
357
|
-
copy(
|
|
358
|
-
return super.copy(
|
|
442
|
+
copy(e) {
|
|
443
|
+
return super.copy(e), this.parameters = Object.assign({}, e.parameters), this;
|
|
359
444
|
}
|
|
360
445
|
toJSON() {
|
|
361
|
-
const
|
|
362
|
-
return
|
|
446
|
+
const e = super.toJSON(), t = this.parameters.shapes, n = this.parameters.options;
|
|
447
|
+
return Bt(t, n, e);
|
|
363
448
|
}
|
|
364
449
|
/**
|
|
365
450
|
* Factory method for creating an instance of this class from the given
|
|
@@ -369,751 +454,693 @@ class Z extends ot {
|
|
|
369
454
|
* @param {Array<Shape>} shapes - An array of shapes.
|
|
370
455
|
* @return {ExtrudeGeometry} A new instance.
|
|
371
456
|
*/
|
|
372
|
-
static fromJSON(
|
|
373
|
-
const
|
|
374
|
-
for (let
|
|
375
|
-
const
|
|
376
|
-
|
|
457
|
+
static fromJSON(e, t) {
|
|
458
|
+
const n = [];
|
|
459
|
+
for (let i = 0, a = e.shapes.length; i < a; i++) {
|
|
460
|
+
const f = t[e.shapes[i]];
|
|
461
|
+
n.push(f);
|
|
377
462
|
}
|
|
378
|
-
const
|
|
379
|
-
return
|
|
380
|
-
|
|
381
|
-
)), new
|
|
463
|
+
const s = e.options.extrudePath;
|
|
464
|
+
return s !== void 0 && (e.options.extrudePath = new zt[`${s.type}`]().fromJSON(
|
|
465
|
+
s
|
|
466
|
+
)), new K(n, e.options);
|
|
382
467
|
}
|
|
383
468
|
}
|
|
384
|
-
const
|
|
385
|
-
generateTopUV: function(
|
|
386
|
-
const
|
|
469
|
+
const It = {
|
|
470
|
+
generateTopUV: function(m, e, t, n, s) {
|
|
471
|
+
const i = e[t * 3], a = e[t * 3 + 1], f = e[n * 3], r = e[n * 3 + 1], h = e[s * 3], o = e[s * 3 + 1];
|
|
387
472
|
return [
|
|
388
|
-
new
|
|
389
|
-
new
|
|
390
|
-
new
|
|
473
|
+
new G(i, a),
|
|
474
|
+
new G(f, r),
|
|
475
|
+
new G(h, o)
|
|
391
476
|
];
|
|
392
477
|
},
|
|
393
|
-
generateSideWallUV: function(
|
|
394
|
-
const
|
|
395
|
-
return Math.abs(
|
|
396
|
-
new
|
|
397
|
-
new
|
|
398
|
-
new
|
|
399
|
-
new
|
|
478
|
+
generateSideWallUV: function(m, e, t, n, s, i) {
|
|
479
|
+
const a = e[t * 3], f = e[t * 3 + 1], r = e[t * 3 + 2], h = e[n * 3], o = e[n * 3 + 1], c = e[n * 3 + 2], y = e[s * 3], u = e[s * 3 + 1], g = e[s * 3 + 2], L = e[i * 3], S = e[i * 3 + 1], A = e[i * 3 + 2];
|
|
480
|
+
return Math.abs(f - o) < Math.abs(a - h) ? [
|
|
481
|
+
new G(a, 1 - r),
|
|
482
|
+
new G(h, 1 - c),
|
|
483
|
+
new G(y, 1 - g),
|
|
484
|
+
new G(L, 1 - A)
|
|
400
485
|
] : [
|
|
401
|
-
new
|
|
402
|
-
new
|
|
403
|
-
new
|
|
404
|
-
new
|
|
486
|
+
new G(f, 1 - r),
|
|
487
|
+
new G(o, 1 - c),
|
|
488
|
+
new G(u, 1 - g),
|
|
489
|
+
new G(S, 1 - A)
|
|
405
490
|
];
|
|
406
491
|
}
|
|
407
492
|
};
|
|
408
|
-
function
|
|
409
|
-
if (
|
|
410
|
-
for (let
|
|
411
|
-
const
|
|
412
|
-
|
|
493
|
+
function Bt(m, e, t) {
|
|
494
|
+
if (t.shapes = [], Array.isArray(m))
|
|
495
|
+
for (let n = 0, s = m.length; n < s; n++) {
|
|
496
|
+
const i = m[n];
|
|
497
|
+
t.shapes.push(i.uuid);
|
|
413
498
|
}
|
|
414
499
|
else
|
|
415
|
-
|
|
416
|
-
return
|
|
500
|
+
t.shapes.push(m.uuid);
|
|
501
|
+
return t.options = Object.assign({}, e), e.extrudePath !== void 0 && (t.options.extrudePath = e.extrudePath.toJSON()), t;
|
|
417
502
|
}
|
|
418
|
-
class
|
|
419
|
-
constructor(t) {
|
|
420
|
-
super(
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
503
|
+
class Rt extends K {
|
|
504
|
+
constructor(e, t) {
|
|
505
|
+
super(e, t);
|
|
506
|
+
const n = new Oe(
|
|
507
|
+
new K(e, ue(j({}, t), {
|
|
508
|
+
hasTop: !0,
|
|
509
|
+
hasSide: !0,
|
|
510
|
+
hasBottom: !1
|
|
511
|
+
}))
|
|
512
|
+
);
|
|
513
|
+
n.updateMatrixWorld();
|
|
514
|
+
const s = new ft().setFromObject(n), i = new _();
|
|
515
|
+
s.getSize(i);
|
|
516
|
+
const a = new _(
|
|
517
|
+
s.min.x + i.x / 2,
|
|
518
|
+
s.min.y + i.y / 2,
|
|
519
|
+
0
|
|
520
|
+
);
|
|
521
|
+
let f = t.topSegments, r = t.box3;
|
|
522
|
+
if (r) {
|
|
523
|
+
r = r.union(s);
|
|
524
|
+
const A = new _();
|
|
525
|
+
r.getSize(A);
|
|
526
|
+
const P = Math.max(
|
|
527
|
+
i.x / A.x,
|
|
528
|
+
i.y / A.y
|
|
529
|
+
);
|
|
530
|
+
f = Math.ceil(t.topSegments * P);
|
|
531
|
+
}
|
|
532
|
+
if (f < 4)
|
|
533
|
+
return this;
|
|
534
|
+
const h = new pt(
|
|
535
|
+
i.x,
|
|
536
|
+
i.y,
|
|
537
|
+
f,
|
|
538
|
+
f
|
|
539
|
+
), o = new Oe(h);
|
|
540
|
+
o.position.set(a.x, a.y, a.z), o.updateMatrixWorld();
|
|
541
|
+
const y = new Gt().evaluate(o, n, Pt), u = y.geometry.getAttribute("position"), g = new be(
|
|
542
|
+
u.count * 2,
|
|
543
|
+
2
|
|
544
|
+
);
|
|
545
|
+
for (let A = 0; A < u.count; A++) {
|
|
546
|
+
const P = u.getZ(A);
|
|
547
|
+
u.setZ(A, t.depth + P);
|
|
548
|
+
}
|
|
549
|
+
if (r) {
|
|
550
|
+
const A = r.min, P = r.max, v = new _().subVectors(P, A);
|
|
551
|
+
for (let z = 0; z < u.count; z++) {
|
|
552
|
+
const ee = u.getX(z), V = u.getY(z), $ = (ee - A.x) / v.x, U = (V - A.y) / v.y;
|
|
553
|
+
g.setXY(z, $, U);
|
|
554
|
+
}
|
|
555
|
+
y.geometry.setAttribute("uv", g);
|
|
556
|
+
}
|
|
557
|
+
u.needsUpdate = !0;
|
|
558
|
+
const L = new K(e, ue(j({}, t), {
|
|
559
|
+
hasTop: !1
|
|
560
|
+
})), S = H([y.geometry, L], 2);
|
|
561
|
+
this.copy(S.toNonIndexed());
|
|
427
562
|
}
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
563
|
+
}
|
|
564
|
+
const De = (m) => {
|
|
565
|
+
const {
|
|
566
|
+
split: e,
|
|
567
|
+
depth: t,
|
|
568
|
+
points: n,
|
|
569
|
+
box3: s,
|
|
570
|
+
hasTop: i,
|
|
571
|
+
hasBottom: a,
|
|
572
|
+
hasSide: f,
|
|
573
|
+
sideRepeat: r,
|
|
574
|
+
topSegments: h
|
|
575
|
+
} = m, o = h ? Rt : K, c = new o(new xe(n), {
|
|
576
|
+
depth: t,
|
|
577
|
+
bevelEnabled: !1,
|
|
578
|
+
box3: s,
|
|
579
|
+
UVGenerator: Et({
|
|
580
|
+
split: e,
|
|
581
|
+
box3: s,
|
|
582
|
+
sideRepeat: r
|
|
583
|
+
}),
|
|
584
|
+
hasTop: i,
|
|
585
|
+
hasBottom: a,
|
|
586
|
+
hasSide: f,
|
|
587
|
+
topSegments: h
|
|
588
|
+
});
|
|
589
|
+
return Ct(), c;
|
|
590
|
+
};
|
|
591
|
+
class $t extends Z {
|
|
592
|
+
constructor(e) {
|
|
593
|
+
super(), this.options = j({
|
|
594
|
+
depth: 1
|
|
595
|
+
}, e);
|
|
443
596
|
}
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
597
|
+
create() {
|
|
598
|
+
return ie(this, null, function* () {
|
|
599
|
+
const {
|
|
600
|
+
points: e,
|
|
601
|
+
pointsArr: t,
|
|
602
|
+
useGroups: n,
|
|
603
|
+
depth: s,
|
|
604
|
+
geometry: i,
|
|
605
|
+
geometryArr: a,
|
|
606
|
+
material: f,
|
|
607
|
+
box3: r,
|
|
608
|
+
split: h,
|
|
609
|
+
hasTop: o,
|
|
610
|
+
hasBottom: c,
|
|
611
|
+
hasSide: y
|
|
612
|
+
} = this.options, u = Array.isArray(s) ? s : [s], g = Array.isArray(r) ? r : [r], L = f;
|
|
613
|
+
let S = i;
|
|
614
|
+
L || console.log("material is null"), !S && e ? S = De({
|
|
615
|
+
points: e,
|
|
616
|
+
depth: u[0],
|
|
617
|
+
box3: g[0],
|
|
618
|
+
split: h,
|
|
619
|
+
hasTop: o,
|
|
620
|
+
hasBottom: c,
|
|
621
|
+
hasSide: y
|
|
622
|
+
}) : !S && t ? S = H(
|
|
623
|
+
t.map(
|
|
624
|
+
(A, P) => {
|
|
625
|
+
var v, z;
|
|
626
|
+
return De({
|
|
627
|
+
points: A,
|
|
628
|
+
depth: (v = u[P]) != null ? v : u[0],
|
|
629
|
+
box3: (z = g[P]) != null ? z : g[0],
|
|
630
|
+
split: h,
|
|
631
|
+
hasTop: o,
|
|
632
|
+
hasBottom: c,
|
|
633
|
+
hasSide: y
|
|
634
|
+
});
|
|
635
|
+
}
|
|
636
|
+
),
|
|
637
|
+
n != null ? n : 0
|
|
638
|
+
) : !S && a && a.length > 1 ? S = H(a, n != null ? n : 0) : !S && a && a.length === 1 && ([S] = a), this.createMesh(S, L);
|
|
450
639
|
});
|
|
451
640
|
}
|
|
452
|
-
|
|
453
|
-
const
|
|
454
|
-
|
|
641
|
+
addGeometries(e) {
|
|
642
|
+
const t = this.object3d, n = H([t.geometry, ...e]);
|
|
643
|
+
t.geometry = n;
|
|
455
644
|
}
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
if (this.object3d.children.forEach((i) => {
|
|
459
|
-
if (!(s && s === i) && i.scale.z !== 1) {
|
|
460
|
-
if (i.userData.levTween) return;
|
|
461
|
-
i.userData.enTween && (i.userData.enTween.stop(), i.userData.enTween = null);
|
|
462
|
-
const n = new et.Tween(i.scale).to({ z: 1 }, 100);
|
|
463
|
-
i.userData.levTween = n, n.start();
|
|
464
|
-
}
|
|
465
|
-
}), s) {
|
|
466
|
-
if (s.userData.enTween)
|
|
467
|
-
return;
|
|
468
|
-
s.userData.levTween && (s.userData.levTween.stop(), s.userData.levTween = null);
|
|
469
|
-
const i = new et.Tween(s.scale).to({ z: e }, 100);
|
|
470
|
-
return s.userData.enTween = i, i.start(), s.userData.index;
|
|
471
|
-
}
|
|
472
|
-
return -1;
|
|
645
|
+
setTextureAnisotropic(e, t) {
|
|
646
|
+
e.anisotropy = t || this.pencil.renderer.capabilities.getMaxAnisotropy();
|
|
473
647
|
}
|
|
474
|
-
|
|
475
|
-
|
|
648
|
+
}
|
|
649
|
+
const Jt = (m) => {
|
|
650
|
+
const {
|
|
651
|
+
topColor: e,
|
|
652
|
+
sideColor: t,
|
|
653
|
+
sideMap: n,
|
|
654
|
+
createCanvasObjectURL: s,
|
|
655
|
+
split: i,
|
|
656
|
+
maxAnisotropy: a
|
|
657
|
+
} = m;
|
|
658
|
+
return new Promise((f) => {
|
|
659
|
+
const r = n ? document.createElement("img") : {
|
|
660
|
+
src: "",
|
|
661
|
+
onload: () => {
|
|
662
|
+
},
|
|
663
|
+
width: 128,
|
|
664
|
+
height: 128
|
|
665
|
+
};
|
|
666
|
+
r.onload = () => {
|
|
667
|
+
const h = i, o = document.createElement("canvas"), c = o.getContext("2d");
|
|
668
|
+
o.height = r.height / (1 - h), o.width = r.width, h && e && (c.fillStyle = e, c.fillRect(0, 0, r.width, o.height * h)), n && r instanceof HTMLImageElement ? c.drawImage(r, 0, o.height * h, r.width, r.height) : t && (c.fillStyle = t, c.fillRect(0, o.height * h, r.width, r.height)), s && o.toBlob((u) => {
|
|
669
|
+
console.log(URL.createObjectURL(u));
|
|
670
|
+
});
|
|
671
|
+
const y = new mt(o);
|
|
672
|
+
f(y);
|
|
673
|
+
}, n ? r.src = n : r instanceof HTMLImageElement || r.onload();
|
|
674
|
+
});
|
|
675
|
+
};
|
|
676
|
+
class Qt extends Z {
|
|
677
|
+
create() {
|
|
678
|
+
this.createGroup();
|
|
476
679
|
}
|
|
477
680
|
}
|
|
478
|
-
class
|
|
479
|
-
constructor(
|
|
480
|
-
super(), this.rectAreaLightUniformsLibInit = !1, this.options =
|
|
681
|
+
class Kt extends Z {
|
|
682
|
+
constructor(e) {
|
|
683
|
+
super(), this.rectAreaLightUniformsLibInit = !1, this.options = e;
|
|
481
684
|
}
|
|
482
685
|
create() {
|
|
483
|
-
var
|
|
484
|
-
const
|
|
485
|
-
if (
|
|
486
|
-
const v = new
|
|
686
|
+
var t, n, s, i, a, f, r, h, o, c, y, u, g, L, S, A, P;
|
|
687
|
+
const e = this.options;
|
|
688
|
+
if (e.type === "AmbientLight") {
|
|
689
|
+
const v = new gt(e.color);
|
|
487
690
|
v.name = "环境光", this.object3d = v;
|
|
488
|
-
} else if (
|
|
489
|
-
const v = new
|
|
691
|
+
} else if (e.type === "DirectionalLight") {
|
|
692
|
+
const v = new yt(e.color, e.intensity);
|
|
490
693
|
v.name = "平行光", v.target.position.set(0, 0, 0), this.object3d = v, v.target.name = "平行光目标", v.shadow.camera.name = "平行光阴影相机", v.shadow.camera.userData.directionalLightShadow = !0, this.directionalLight = v;
|
|
491
|
-
} else if (
|
|
492
|
-
const v = new
|
|
493
|
-
(
|
|
494
|
-
(
|
|
495
|
-
(
|
|
496
|
-
(
|
|
694
|
+
} else if (e.type === "PointLight") {
|
|
695
|
+
const v = new bt(
|
|
696
|
+
(t = e.color) != null ? t : 16777215,
|
|
697
|
+
(n = e.intensity) != null ? n : 1,
|
|
698
|
+
(s = e.distance) != null ? s : 0,
|
|
699
|
+
(i = e.decay) != null ? i : 2
|
|
497
700
|
);
|
|
498
701
|
v.name = "点光源", this.object3d = v, this.pointLight = v;
|
|
499
|
-
} else if (
|
|
500
|
-
const v = new
|
|
501
|
-
(
|
|
502
|
-
(
|
|
503
|
-
(
|
|
504
|
-
(
|
|
505
|
-
(o =
|
|
506
|
-
(
|
|
702
|
+
} else if (e.type === "SpotLight") {
|
|
703
|
+
const v = new xt(
|
|
704
|
+
(a = e.color) != null ? a : 16777215,
|
|
705
|
+
(f = e.intensity) != null ? f : 1,
|
|
706
|
+
(r = e.distance) != null ? r : 0,
|
|
707
|
+
(h = e.angle) != null ? h : Math.PI / 3,
|
|
708
|
+
(o = e.penumbra) != null ? o : 1,
|
|
709
|
+
(c = e.decay) != null ? c : 2
|
|
507
710
|
);
|
|
508
711
|
v.name = "聚光灯", this.object3d = v, this.spotLight = v, v.target.name = "聚光灯目标";
|
|
509
|
-
} else if (
|
|
510
|
-
const v = new
|
|
511
|
-
(y =
|
|
512
|
-
(
|
|
513
|
-
(
|
|
712
|
+
} else if (e.type === "HemisphereLight") {
|
|
713
|
+
const v = new wt(
|
|
714
|
+
(y = e.color) != null ? y : 16777215,
|
|
715
|
+
(u = e.groundColor) != null ? u : 16777215,
|
|
716
|
+
(g = e.intensity) != null ? g : 1
|
|
514
717
|
);
|
|
515
718
|
v.name = "半球光", this.object3d = v, this.hemisphereLight = v;
|
|
516
|
-
} else if (
|
|
517
|
-
this.rectAreaLightUniformsLibInit || (
|
|
518
|
-
const v = new
|
|
519
|
-
(
|
|
520
|
-
(
|
|
521
|
-
(
|
|
522
|
-
(
|
|
719
|
+
} else if (e.type === "RectAreaLight") {
|
|
720
|
+
this.rectAreaLightUniformsLibInit || (_t.init(), this.rectAreaLightUniformsLibInit = !0);
|
|
721
|
+
const v = new vt(
|
|
722
|
+
(L = e.color) != null ? L : 16777215,
|
|
723
|
+
(S = e.intensity) != null ? S : 1,
|
|
724
|
+
(A = e.width) != null ? A : 10,
|
|
725
|
+
(P = e.height) != null ? P : 10
|
|
523
726
|
);
|
|
524
727
|
v.name = "矩形区域光", this.object3d = v, this.rectAreaLight = v;
|
|
525
728
|
}
|
|
526
729
|
}
|
|
527
730
|
render() {
|
|
528
|
-
const
|
|
529
|
-
|
|
530
|
-
const
|
|
731
|
+
const e = this.object3d;
|
|
732
|
+
e.target && this.pencil.scene.add(e.target);
|
|
733
|
+
const t = this.pencil.cameraTarget;
|
|
531
734
|
if (this.spotLight || this.directionalLight) {
|
|
532
|
-
const
|
|
533
|
-
|
|
534
|
-
} else this.pointLight && this.pointLight.position.copy(
|
|
735
|
+
const n = this.spotLight || this.directionalLight;
|
|
736
|
+
n.position.copy(t), n.target.position.copy(t);
|
|
737
|
+
} else this.pointLight && this.pointLight.position.copy(t);
|
|
535
738
|
}
|
|
536
739
|
dispose() {
|
|
537
|
-
const
|
|
538
|
-
|
|
740
|
+
const e = this.object3d;
|
|
741
|
+
e.target && this.pencil.scene.remove(e.target), super.dispose();
|
|
539
742
|
}
|
|
540
743
|
}
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
), n = {}, r = {}, l = a[0].morphTargetsRelative, h = new ot();
|
|
545
|
-
let b = 0;
|
|
546
|
-
for (let o = 0; o < a.length; ++o) {
|
|
547
|
-
const u = a[o];
|
|
548
|
-
let y = 0;
|
|
549
|
-
if (e !== (u.index !== null))
|
|
550
|
-
return console.error(
|
|
551
|
-
"THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index " + o + ". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them."
|
|
552
|
-
), null;
|
|
553
|
-
for (const f in u.attributes) {
|
|
554
|
-
if (!s.has(f))
|
|
555
|
-
return console.error(
|
|
556
|
-
"THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index " + o + '. All geometries must have compatible attributes; make sure "' + f + '" attribute exists among all geometries, or in none of them.'
|
|
557
|
-
), null;
|
|
558
|
-
n[f] === void 0 && (n[f] = []), n[f].push(u.attributes[f]), y++;
|
|
559
|
-
}
|
|
560
|
-
if (y !== s.size)
|
|
561
|
-
return console.error(
|
|
562
|
-
"THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index " + o + ". Make sure all geometries have the same number of attributes."
|
|
563
|
-
), null;
|
|
564
|
-
if (l !== u.morphTargetsRelative)
|
|
565
|
-
return console.error(
|
|
566
|
-
"THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index " + o + ". .morphTargetsRelative must be consistent throughout all geometries."
|
|
567
|
-
), null;
|
|
568
|
-
for (const f in u.morphAttributes) {
|
|
569
|
-
if (!i.has(f))
|
|
570
|
-
return console.error(
|
|
571
|
-
"THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index " + o + ". .morphAttributes must be consistent throughout all geometries."
|
|
572
|
-
), null;
|
|
573
|
-
r[f] === void 0 && (r[f] = []), r[f].push(u.morphAttributes[f]);
|
|
574
|
-
}
|
|
575
|
-
if (t) {
|
|
576
|
-
let f;
|
|
577
|
-
if (e)
|
|
578
|
-
f = u.index.count;
|
|
579
|
-
else if (u.attributes.position !== void 0)
|
|
580
|
-
f = u.attributes.position.count;
|
|
581
|
-
else
|
|
582
|
-
return console.error(
|
|
583
|
-
"THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index " + o + ". The geometry must have either an index or a position attribute"
|
|
584
|
-
), null;
|
|
585
|
-
if (t === 1)
|
|
586
|
-
h.addGroup(b, f, o);
|
|
587
|
-
else if (t === 2 && u.groups.length > 0)
|
|
588
|
-
for (let w of u.groups) {
|
|
589
|
-
let M = w.materialIndex;
|
|
590
|
-
h.addGroup(
|
|
591
|
-
b + w.start,
|
|
592
|
-
Math.min(w.count, f),
|
|
593
|
-
M
|
|
594
|
-
);
|
|
595
|
-
}
|
|
596
|
-
b += f;
|
|
597
|
-
}
|
|
744
|
+
class Ot extends fe {
|
|
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 Ve(), this.shape = t, n && (this.shapeFunction = n), e.length > 0 && this.setPoints(e);
|
|
598
747
|
}
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
748
|
+
convertToVector3Array(e) {
|
|
749
|
+
if (typeof e[0] == "number") {
|
|
750
|
+
const t = [], n = e;
|
|
751
|
+
for (let s = 0; s < n.length; s += 3)
|
|
752
|
+
t.push(new _(n[s], n[s + 1], n[s + 2]));
|
|
753
|
+
return t;
|
|
754
|
+
} else
|
|
755
|
+
return e.map((t) => {
|
|
756
|
+
if (t instanceof G)
|
|
757
|
+
return new _(t.x, t.y, 0);
|
|
758
|
+
if (t instanceof _)
|
|
759
|
+
return t;
|
|
760
|
+
if (Array.isArray(t) && t.length === 2)
|
|
761
|
+
return new _(t[0], t[1], 0);
|
|
762
|
+
if (Array.isArray(t) && t.length === 3)
|
|
763
|
+
return new _(t[0], t[1], t[2]);
|
|
764
|
+
}).filter(Boolean);
|
|
609
765
|
}
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
if (!u)
|
|
613
|
-
return console.error(
|
|
614
|
-
"THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the " + o + " attribute."
|
|
615
|
-
), null;
|
|
616
|
-
h.setAttribute(o, u);
|
|
766
|
+
setMatrixWorld(e) {
|
|
767
|
+
this.matrixWorld = e;
|
|
617
768
|
}
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
if (u === 0) break;
|
|
621
|
-
h.morphAttributes = h.morphAttributes || {}, h.morphAttributes[o] = [];
|
|
622
|
-
for (let y = 0; y < u; ++y) {
|
|
623
|
-
const f = [];
|
|
624
|
-
for (let M = 0; M < r[o].length; ++M)
|
|
625
|
-
f.push(r[o][M][y]);
|
|
626
|
-
const w = zt(f);
|
|
627
|
-
if (!w)
|
|
628
|
-
return console.error(
|
|
629
|
-
"THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the " + o + " morphAttribute."
|
|
630
|
-
), null;
|
|
631
|
-
h.morphAttributes[o].push(w);
|
|
632
|
-
}
|
|
769
|
+
setPoints(e, t) {
|
|
770
|
+
!e || e.length === 0 || (this._points = this.convertToVector3Array(e), this.pointCount = this._points.length, t && (this.shapeFunction = t, this.shape = "custom"), this.initializeGeometry(), this.updateGeometry());
|
|
633
771
|
}
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
setPointWidth: l,
|
|
658
|
-
lineWidthArr: h,
|
|
659
|
-
materialParameters: b,
|
|
660
|
-
instanceCount: o
|
|
661
|
-
} = this.options;
|
|
662
|
-
let u = n, y = s;
|
|
663
|
-
!u && b && (u = this.getMaterial(b)), !y && t ? y = Dt({
|
|
664
|
-
points: t
|
|
665
|
-
}) : !y && e ? y = R(
|
|
666
|
-
e.map((w) => Dt({
|
|
667
|
-
points: w
|
|
668
|
-
})),
|
|
669
|
-
r != null ? r : 0
|
|
670
|
-
) : !y && i && i.length > 1 ? y = R(i, r != null ? r : 0) : !y && i && i.length === 1 && ([y] = i);
|
|
671
|
-
const f = new Le().fromLineSegments(
|
|
672
|
-
new be(y)
|
|
673
|
-
);
|
|
674
|
-
if (this.pencil.options.WebGPUTHREE) {
|
|
675
|
-
o && (f.instanceCount = o);
|
|
676
|
-
const w = new Yt(f, u);
|
|
677
|
-
w.computeLineDistances(), this.object3d = w;
|
|
678
|
-
} else {
|
|
679
|
-
const w = new Me(f, u);
|
|
680
|
-
w.computeLineDistances(), this.object3d = w;
|
|
772
|
+
initializeGeometry() {
|
|
773
|
+
const e = new Y(
|
|
774
|
+
new Float32Array(this.pointCount * 6),
|
|
775
|
+
3
|
|
776
|
+
), t = new Y(
|
|
777
|
+
new Float32Array(this.pointCount * 6),
|
|
778
|
+
3
|
|
779
|
+
), n = new Y(new Float32Array(this.pointCount * 6), 3), s = new Y(
|
|
780
|
+
new Float32Array(this.pointCount * 2),
|
|
781
|
+
1
|
|
782
|
+
), i = new Y(new Float32Array(this.pointCount * 2), 1), a = new Y(new Float32Array(this.pointCount * 2), 1), f = new Y(new Float32Array(this.pointCount * 4), 2), r = new Y(
|
|
783
|
+
new Uint16Array((this.pointCount - 1) * 6),
|
|
784
|
+
1
|
|
785
|
+
);
|
|
786
|
+
this.shape === "taper" && (this.shapeFunction = (h) => 1 * Math.pow(4 * h * (1 - h), 1));
|
|
787
|
+
for (let h = 0, o = 0, c = 0; h < this.pointCount; h += 1, o += 2, c += 6) {
|
|
788
|
+
s.setX(o, h / this.pointCount), s.setX(o + 1, h / this.pointCount), i.setX(o, 1), i.setX(o + 1, -1);
|
|
789
|
+
const y = this.shape === "none" ? 1 : this.shapeFunction(h / (this.pointCount - 1));
|
|
790
|
+
a.setX(o, y), a.setX(o + 1, y);
|
|
791
|
+
const u = h / (this.pointCount - 1);
|
|
792
|
+
if (f.setXY(o, u, 0), f.setXY(o + 1, u, 1), h < this.pointCount - 1) {
|
|
793
|
+
const g = h * 2;
|
|
794
|
+
r.setX(c + 0, g + 0), r.setX(c + 1, g + 1), r.setX(c + 2, g + 2), r.setX(c + 3, g + 2), r.setX(c + 4, g + 1), r.setX(c + 5, g + 3);
|
|
681
795
|
}
|
|
682
|
-
}
|
|
683
|
-
|
|
684
|
-
getMaterial(t) {
|
|
685
|
-
return new Te(G({
|
|
686
|
-
color: new Nt("#ffffff")
|
|
687
|
-
}, t));
|
|
796
|
+
}
|
|
797
|
+
this.setAttribute("position", e), this.setAttribute("previous", t), this.setAttribute("next", n), this.setAttribute("counters", s), this.setAttribute("side", i), this.setAttribute("width", a), this.setAttribute("uv", f), this.setIndex(r);
|
|
688
798
|
}
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
)
|
|
701
|
-
) : a, e.set)
|
|
702
|
-
e.set(a, s);
|
|
703
|
-
else
|
|
704
|
-
for (n = 0; n < a.length; n++) e[n + s] = a[n];
|
|
705
|
-
return e;
|
|
706
|
-
}
|
|
707
|
-
function Ve(a) {
|
|
708
|
-
return a instanceof Float32Array ? a : a instanceof ot ? a.getAttribute("position").array : a.map((t) => {
|
|
709
|
-
const e = Array.isArray(t);
|
|
710
|
-
return t instanceof F ? [t.x, t.y, t.z] : t instanceof P ? [t.x, t.y, 0] : e && t.length === 3 ? [t[0], t[1], t[2]] : e && t.length === 2 ? [t[0], t[1], 0] : t;
|
|
711
|
-
}).flat();
|
|
712
|
-
}
|
|
713
|
-
class Be extends ot {
|
|
714
|
-
constructor() {
|
|
715
|
-
super(), this.type = "MeshLine", this.isMeshLine = !0, this.positions = [], this.previous = [], this.next = [], this.side = [], this.width = [], this.indices_array = [], this.uvs = [], this.counters = [], this.widthCallback = null, this._points = [], this.matrixWorld = new we(), Object.defineProperties(this, {
|
|
716
|
-
points: {
|
|
717
|
-
enumerable: !0,
|
|
718
|
-
get() {
|
|
719
|
-
return this._points;
|
|
720
|
-
},
|
|
721
|
-
set(t) {
|
|
722
|
-
this.setPoints(t, this.widthCallback);
|
|
723
|
-
}
|
|
724
|
-
}
|
|
725
|
-
});
|
|
799
|
+
updateGeometry() {
|
|
800
|
+
if (!this._points[0]) return;
|
|
801
|
+
const e = this.getAttribute("position"), t = this.getAttribute("previous"), n = this.getAttribute("next");
|
|
802
|
+
let s = 0, i = 0, a = 0;
|
|
803
|
+
const f = this._points[0];
|
|
804
|
+
t.setXYZ(i, f.x, f.y, f.z), i += 1, t.setXYZ(i, f.x, f.y, f.z), i += 1;
|
|
805
|
+
for (let h = 0; h < this.pointCount; h++) {
|
|
806
|
+
const o = this._points[h];
|
|
807
|
+
e.setXYZ(s, o.x, o.y, o.z), s += 1, e.setXYZ(s, o.x, o.y, o.z), s += 1, h < this.pointCount - 1 && (t.setXYZ(i, o.x, o.y, o.z), i += 1, t.setXYZ(i, o.x, o.y, o.z), i += 1), h > 0 && h + 1 <= this.pointCount && (n.setXYZ(a, o.x, o.y, o.z), a += 1, n.setXYZ(a, o.x, o.y, o.z), a += 1);
|
|
808
|
+
}
|
|
809
|
+
const r = this._points[this.pointCount - 1];
|
|
810
|
+
n.setXYZ(a, r.x, r.y, r.z), a += 1, n.setXYZ(a, r.x, r.y, r.z), a += 1, e.needsUpdate = !0, t.needsUpdate = !0, n.needsUpdate = !0, this.computeBoundingSphere(), this.computeBoundingBox();
|
|
726
811
|
}
|
|
727
|
-
|
|
728
|
-
this.
|
|
812
|
+
get points() {
|
|
813
|
+
return this._points;
|
|
729
814
|
}
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
for (let s = 0; s < t.length; s++) {
|
|
733
|
-
const i = t[s], n = s / (t.length - 1);
|
|
734
|
-
this.positions.push(i.x, i.y, i.z), this.positions.push(i.x, i.y, i.z), this.counters.push(n), this.counters.push(n);
|
|
735
|
-
}
|
|
736
|
-
else
|
|
737
|
-
for (let s = 0; s < t.length; s += 3) {
|
|
738
|
-
const i = s / (t.length - 1);
|
|
739
|
-
this.positions.push(t[s], t[s + 1], t[s + 2]), this.positions.push(t[s], t[s + 1], t[s + 2]), this.counters.push(i), this.counters.push(i);
|
|
740
|
-
}
|
|
741
|
-
this.process();
|
|
815
|
+
set points(e) {
|
|
816
|
+
this.setPoints(e);
|
|
742
817
|
}
|
|
743
|
-
|
|
744
|
-
const
|
|
745
|
-
|
|
818
|
+
updatePoints(e, t) {
|
|
819
|
+
const n = this.convertToVector3Array(e);
|
|
820
|
+
if (n.length !== this.pointCount) {
|
|
821
|
+
console.warn(
|
|
822
|
+
"MeshLineGeometry: Cannot update points with different length. Use setPoints() instead."
|
|
823
|
+
);
|
|
824
|
+
return;
|
|
825
|
+
}
|
|
826
|
+
this._points = n, t && (this.shapeFunction = t, this.shape = "custom", this.initializeGeometry()), this.updateGeometry();
|
|
746
827
|
}
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
return [this.positions[e], this.positions[e + 1], this.positions[e + 2]];
|
|
828
|
+
setShape(e, t) {
|
|
829
|
+
this.shape = e, t && (this.shapeFunction = t), this._points.length > 0 && (this.initializeGeometry(), this.updateGeometry());
|
|
750
830
|
}
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
831
|
+
}
|
|
832
|
+
function en(m, e) {
|
|
833
|
+
const t = new Ve(), n = new St(), s = new At(), i = new _(), a = this.geometry;
|
|
834
|
+
if (s.copy(a.boundingSphere), s.applyMatrix4(this.matrixWorld), !m.ray.intersectSphere(s, i)) return;
|
|
835
|
+
t.copy(this.matrixWorld).invert(), n.copy(m.ray).applyMatrix4(t);
|
|
836
|
+
const f = new _(), r = new _(), h = new _(), o = this instanceof Xe ? 2 : 1, c = a.index, y = a.attributes;
|
|
837
|
+
if (c !== null) {
|
|
838
|
+
const u = c.array, g = y.position.array, L = y.width.array;
|
|
839
|
+
for (let S = 0, A = u.length - 1; S < A; S += o) {
|
|
840
|
+
const P = u[S], v = u[S + 1];
|
|
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, V = ee * ee;
|
|
843
|
+
if (n.distanceSqToSegment(
|
|
844
|
+
f,
|
|
845
|
+
r,
|
|
846
|
+
i,
|
|
847
|
+
h
|
|
848
|
+
) > V) continue;
|
|
849
|
+
i.applyMatrix4(this.matrixWorld);
|
|
850
|
+
const U = m.ray.origin.distanceTo(i);
|
|
851
|
+
U < m.near || U > m.far || (e.push({
|
|
852
|
+
distance: U,
|
|
853
|
+
// What do we want? intersection point on the ray or on the segment??
|
|
854
|
+
// point: raycaster.ray.at( distance ),
|
|
855
|
+
point: h.clone().applyMatrix4(this.matrixWorld),
|
|
856
|
+
index: S,
|
|
857
|
+
face: null,
|
|
858
|
+
faceIndex: void 0,
|
|
859
|
+
object: this
|
|
860
|
+
}), S = A);
|
|
763
861
|
}
|
|
764
|
-
this.compareV3(t - 1, 0) ? s = this.copyV3(1) : s = this.copyV3(t - 1), this.next.push(s[0], s[1], s[2]), this.next.push(s[0], s[1], s[2]), !this._attributes || this._attributes.position.count !== this.counters.length ? this._attributes = {
|
|
765
|
-
position: new $(new Float32Array(this.positions), 3),
|
|
766
|
-
previous: new $(new Float32Array(this.previous), 3),
|
|
767
|
-
next: new $(new Float32Array(this.next), 3),
|
|
768
|
-
side: new $(new Float32Array(this.side), 1),
|
|
769
|
-
width: new $(new Float32Array(this.width), 1),
|
|
770
|
-
uv: new $(new Float32Array(this.uvs), 2),
|
|
771
|
-
index: new $(new Uint16Array(this.indices_array), 1),
|
|
772
|
-
counters: new $(new Float32Array(this.counters), 1)
|
|
773
|
-
} : (this._attributes.position.copyArray(new Float32Array(this.positions)), this._attributes.position.needsUpdate = !0, this._attributes.previous.copyArray(new Float32Array(this.previous)), this._attributes.previous.needsUpdate = !0, this._attributes.next.copyArray(new Float32Array(this.next)), this._attributes.next.needsUpdate = !0, this._attributes.side.copyArray(new Float32Array(this.side)), this._attributes.side.needsUpdate = !0, this._attributes.width.copyArray(new Float32Array(this.width)), this._attributes.width.needsUpdate = !0, this._attributes.uv.copyArray(new Float32Array(this.uvs)), this._attributes.uv.needsUpdate = !0, this._attributes.index.copyArray(new Uint16Array(this.indices_array)), this._attributes.index.needsUpdate = !0), this.setAttribute("position", this._attributes.position), this.setAttribute("previous", this._attributes.previous), this.setAttribute("next", this._attributes.next), this.setAttribute("side", this._attributes.side), this.setAttribute("width", this._attributes.width), this.setAttribute("uv", this._attributes.uv), this.setAttribute("counters", this._attributes.counters), this.setAttribute("position", this._attributes.position), this.setAttribute("previous", this._attributes.previous), this.setAttribute("next", this._attributes.next), this.setAttribute("side", this._attributes.side), this.setAttribute("width", this._attributes.width), this.setAttribute("uv", this._attributes.uv), this.setAttribute("counters", this._attributes.counters), this.setIndex(this._attributes.index), this.computeBoundingSphere(), this.computeBoundingBox();
|
|
774
|
-
}
|
|
775
|
-
/**
|
|
776
|
-
* Fast method to advance the line by one position. The oldest position is removed.
|
|
777
|
-
* @param position
|
|
778
|
-
*/
|
|
779
|
-
advance({ x: t, y: e, z: s }) {
|
|
780
|
-
const i = this._attributes.position.array, n = this._attributes.previous.array, r = this._attributes.next.array, l = i.length;
|
|
781
|
-
yt(i, 0, n, 0, l), yt(i, 6, i, 0, l - 6), i[l - 6] = t, i[l - 5] = e, i[l - 4] = s, i[l - 3] = t, i[l - 2] = e, i[l - 1] = s, yt(i, 6, r, 0, l - 6), r[l - 6] = t, r[l - 5] = e, r[l - 4] = s, r[l - 3] = t, r[l - 2] = e, r[l - 1] = s, this._attributes.position.needsUpdate = !0, this._attributes.previous.needsUpdate = !0, this._attributes.next.needsUpdate = !0;
|
|
782
862
|
}
|
|
783
863
|
}
|
|
784
|
-
const
|
|
785
|
-
const { setPointWidth:
|
|
786
|
-
return
|
|
864
|
+
const ye = (m) => {
|
|
865
|
+
const { setPointWidth: e, nodes: t } = m, n = new Ot();
|
|
866
|
+
return n.setPoints(t, e), n;
|
|
787
867
|
};
|
|
788
|
-
class
|
|
789
|
-
constructor(
|
|
790
|
-
super(), this.options =
|
|
868
|
+
let tn = class extends Z {
|
|
869
|
+
constructor(e = {}) {
|
|
870
|
+
super(), this.options = j({}, e);
|
|
791
871
|
}
|
|
792
872
|
get material() {
|
|
793
|
-
var
|
|
794
|
-
return (
|
|
873
|
+
var e;
|
|
874
|
+
return (e = this.object3d) == null ? void 0 : e.material;
|
|
795
875
|
}
|
|
796
876
|
create() {
|
|
797
|
-
return
|
|
877
|
+
return ie(this, null, function* () {
|
|
798
878
|
const {
|
|
799
|
-
nodes:
|
|
800
|
-
nodesArr:
|
|
801
|
-
geometry:
|
|
802
|
-
geometryArr:
|
|
803
|
-
material:
|
|
804
|
-
useGroups:
|
|
805
|
-
setPointWidth:
|
|
806
|
-
lineWidthArr:
|
|
807
|
-
materialParameters:
|
|
879
|
+
nodes: e,
|
|
880
|
+
nodesArr: t,
|
|
881
|
+
geometry: n,
|
|
882
|
+
geometryArr: s,
|
|
883
|
+
material: i,
|
|
884
|
+
useGroups: a,
|
|
885
|
+
setPointWidth: f,
|
|
886
|
+
lineWidthArr: r,
|
|
887
|
+
materialParameters: h
|
|
808
888
|
} = this.options;
|
|
809
|
-
let o =
|
|
810
|
-
!o &&
|
|
811
|
-
nodes:
|
|
812
|
-
setPointWidth:
|
|
813
|
-
}) : !
|
|
814
|
-
|
|
815
|
-
let
|
|
816
|
-
return !
|
|
817
|
-
var
|
|
818
|
-
return (
|
|
819
|
-
}),
|
|
889
|
+
let o = i, c = n;
|
|
890
|
+
!o && h && (o = this.getMaterial(h)), !c && e ? c = ye({
|
|
891
|
+
nodes: e,
|
|
892
|
+
setPointWidth: f
|
|
893
|
+
}) : !c && t ? c = H(
|
|
894
|
+
t.map((y, u) => {
|
|
895
|
+
let g = f;
|
|
896
|
+
return !g && r && (g = () => {
|
|
897
|
+
var L;
|
|
898
|
+
return (L = r[u]) != null ? L : r[0];
|
|
899
|
+
}), ye({
|
|
820
900
|
nodes: y,
|
|
821
|
-
setPointWidth:
|
|
901
|
+
setPointWidth: g
|
|
822
902
|
});
|
|
823
903
|
}),
|
|
824
|
-
|
|
825
|
-
) : !
|
|
904
|
+
a != null ? a : 0
|
|
905
|
+
) : !c && s && s.length > 1 ? c = H(s, a != null ? a : 0) : !c && s && s.length === 1 && ([c] = s), this.createMesh(c, o);
|
|
826
906
|
});
|
|
827
907
|
}
|
|
828
|
-
setGeometry(
|
|
829
|
-
const
|
|
830
|
-
nodes:
|
|
831
|
-
setPointWidth:
|
|
832
|
-
}),
|
|
833
|
-
|
|
908
|
+
setGeometry(e, t) {
|
|
909
|
+
const n = ye({
|
|
910
|
+
nodes: e,
|
|
911
|
+
setPointWidth: t
|
|
912
|
+
}), s = this.object3d, i = s.geometry;
|
|
913
|
+
s.geometry = n, i.dispose();
|
|
834
914
|
}
|
|
835
|
-
getMaterial(
|
|
836
|
-
const { width:
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
}, t));
|
|
915
|
+
getMaterial(e) {
|
|
916
|
+
const { width: t, height: n } = this.pencil.getSize(), s = new tt(j({
|
|
917
|
+
color: new Ne("#ffffff")
|
|
918
|
+
}, e));
|
|
919
|
+
return s.uniforms.resolution.value.set(t, n), s;
|
|
841
920
|
}
|
|
842
|
-
addGeometries(
|
|
843
|
-
const
|
|
844
|
-
|
|
921
|
+
addGeometries(e) {
|
|
922
|
+
const t = this.object3d, n = H([t.geometry, ...e]);
|
|
923
|
+
t.geometry = n;
|
|
845
924
|
}
|
|
846
|
-
resize(
|
|
847
|
-
var
|
|
848
|
-
(
|
|
925
|
+
resize(e, t) {
|
|
926
|
+
var n, s;
|
|
927
|
+
(s = (n = this.material) == null ? void 0 : n.uniforms) == null || s.resolution.value.set(e, t);
|
|
849
928
|
}
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
929
|
+
handleMaterialChange(e) {
|
|
930
|
+
if (e) {
|
|
931
|
+
const { width: t, height: n } = this.pencil.getSize();
|
|
932
|
+
this.resize(t, n);
|
|
933
|
+
}
|
|
854
934
|
}
|
|
855
935
|
animate({
|
|
856
|
-
duration:
|
|
857
|
-
delay:
|
|
858
|
-
repeat:
|
|
859
|
-
lineLoop:
|
|
860
|
-
onRepeat:
|
|
861
|
-
onUpdate:
|
|
862
|
-
onComplete:
|
|
863
|
-
startShow:
|
|
936
|
+
duration: e = 1e3,
|
|
937
|
+
delay: t = 0,
|
|
938
|
+
repeat: n = 0,
|
|
939
|
+
lineLoop: s,
|
|
940
|
+
onRepeat: i,
|
|
941
|
+
onUpdate: a,
|
|
942
|
+
onComplete: f,
|
|
943
|
+
startShow: r
|
|
864
944
|
} = {}) {
|
|
865
|
-
const { offset:
|
|
945
|
+
const { offset: h, offsetLoop: o } = this.material.uniforms;
|
|
866
946
|
if (this.material.userData.tween)
|
|
867
947
|
return;
|
|
868
|
-
const
|
|
869
|
-
|
|
948
|
+
const c = s != null ? s : !0;
|
|
949
|
+
h.value.x = 1, o.value = c && r ? 1 : 0;
|
|
870
950
|
let y = 0;
|
|
871
|
-
const
|
|
872
|
-
|
|
951
|
+
const u = new ne.Tween(h.value).to({ x: -1 }, e).delay(t).repeat(n).onUpdate(({ x: g }) => {
|
|
952
|
+
c && g <= 0 && o.value === 0 && (o.value = 1), a && a(g);
|
|
873
953
|
}).onRepeat(() => {
|
|
874
|
-
y += 1,
|
|
954
|
+
y += 1, i && i(y);
|
|
875
955
|
}).onComplete(() => {
|
|
876
|
-
|
|
956
|
+
f && f();
|
|
877
957
|
}).start();
|
|
878
|
-
this.material.userData.tween =
|
|
958
|
+
this.material.userData.tween = u;
|
|
879
959
|
}
|
|
880
960
|
render() {
|
|
881
|
-
const { width:
|
|
882
|
-
this.resize(
|
|
961
|
+
const { width: e, height: t } = this.pencil.getSize();
|
|
962
|
+
this.resize(e, t);
|
|
883
963
|
}
|
|
884
964
|
dispose() {
|
|
885
|
-
this.material.userData.tween && (this.material.userData.tween.stop(),
|
|
965
|
+
this.material.userData.tween && (this.material.userData.tween.stop(), ne.remove(this.material.userData.tween)), super.dispose();
|
|
886
966
|
}
|
|
887
|
-
}
|
|
888
|
-
const Ot = (a) => {
|
|
889
|
-
const l = a, { coordinate: t, startHeight: e, height: s } = l, i = gt(l, ["coordinate", "startHeight", "height"]);
|
|
890
|
-
let n = e || 0;
|
|
891
|
-
return typeof e != "undefined" && typeof s != "undefined" && (n = e + s), new Kt([t], ut(G({}, i), {
|
|
892
|
-
startHeight: e,
|
|
893
|
-
endHeight: n
|
|
894
|
-
}));
|
|
895
967
|
};
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
968
|
+
const He = (m) => {
|
|
969
|
+
const { points: e } = m, t = e.reduce((s, i, a) => (a < e.length - 1 && s.push(i, e[a + 1]), s), []);
|
|
970
|
+
return new fe().setFromPoints(t);
|
|
971
|
+
};
|
|
972
|
+
class sn extends Z {
|
|
973
|
+
constructor(e = {}) {
|
|
974
|
+
super(), this.options = j({}, e);
|
|
975
|
+
}
|
|
976
|
+
get material() {
|
|
977
|
+
var e;
|
|
978
|
+
return (e = this.object3d) == null ? void 0 : e.material;
|
|
899
979
|
}
|
|
900
980
|
create() {
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
981
|
+
return ie(this, null, function* () {
|
|
982
|
+
const {
|
|
983
|
+
points: e,
|
|
984
|
+
pointsArr: t,
|
|
985
|
+
geometry: n,
|
|
986
|
+
geometryArr: s,
|
|
987
|
+
material: i,
|
|
988
|
+
useGroups: a,
|
|
989
|
+
setPointWidth: f,
|
|
990
|
+
lineWidthArr: r,
|
|
991
|
+
materialParameters: h,
|
|
992
|
+
instanceCount: o
|
|
993
|
+
} = this.options;
|
|
994
|
+
let c = i, y = n;
|
|
995
|
+
!c && h && (c = this.getMaterial(h)), !y && e ? y = He({
|
|
996
|
+
points: e
|
|
997
|
+
}) : !y && t ? y = H(
|
|
998
|
+
t.map((g) => He({
|
|
999
|
+
points: g
|
|
1000
|
+
})),
|
|
1001
|
+
a != null ? a : 0
|
|
1002
|
+
) : !y && s && s.length > 1 ? y = H(s, a != null ? a : 0) : !y && s && s.length === 1 && ([y] = s);
|
|
1003
|
+
const u = new Ke().fromLineSegments(
|
|
1004
|
+
new Xe(y)
|
|
924
1005
|
);
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
1006
|
+
if (this.pencil.options.WebGPUTHREE) {
|
|
1007
|
+
o && (u.instanceCount = o);
|
|
1008
|
+
const g = new nt(u, c);
|
|
1009
|
+
g.computeLineDistances(), this.object3d = g;
|
|
1010
|
+
} else {
|
|
1011
|
+
const g = new jt(u, c);
|
|
1012
|
+
g.computeLineDistances(), this.object3d = g;
|
|
1013
|
+
}
|
|
1014
|
+
});
|
|
1015
|
+
}
|
|
1016
|
+
getMaterial(e) {
|
|
1017
|
+
return new Qe(j({
|
|
1018
|
+
color: new Ne("#ffffff")
|
|
1019
|
+
}, e));
|
|
928
1020
|
}
|
|
929
1021
|
}
|
|
930
|
-
class
|
|
931
|
-
constructor(
|
|
932
|
-
super(
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
);
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
const
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
}
|
|
976
|
-
if (h) {
|
|
977
|
-
const S = h.min, j = h.max, v = new F().subVectors(j, S);
|
|
978
|
-
for (let B = 0; B < f.count; B++) {
|
|
979
|
-
const pt = f.getX(B), J = f.getY(B), K = (pt - S.x) / v.x, X = (J - S.y) / v.y;
|
|
980
|
-
w.setXY(B, K, X);
|
|
981
|
-
}
|
|
982
|
-
y.geometry.setAttribute("uv", w);
|
|
983
|
-
}
|
|
984
|
-
f.needsUpdate = !0;
|
|
985
|
-
const M = new Z(t, ut(G({}, e), {
|
|
986
|
-
hasTop: !1
|
|
987
|
-
})), _ = R([y.geometry, M], 2);
|
|
988
|
-
this.copy(_.toNonIndexed());
|
|
1022
|
+
class on extends Z {
|
|
1023
|
+
constructor(e) {
|
|
1024
|
+
super(), this.objectType = "BaseObject#Node", this.onNodePointerIndex = [], this.options = j({
|
|
1025
|
+
type: "2d"
|
|
1026
|
+
}, e);
|
|
1027
|
+
}
|
|
1028
|
+
create() {
|
|
1029
|
+
const { position: e, children: t } = this.options, n = document.createElement("div");
|
|
1030
|
+
this.element = n, t && n.appendChild(t), this.options.type === "3d" ? this.createCSS3DObject(n) : this.options.type === "3dSprite" ? this.createCSS3DSprite(n) : this.createCSS2DObject(n), e && this.object3d.position.copy(e);
|
|
1031
|
+
}
|
|
1032
|
+
setChildren(e) {
|
|
1033
|
+
this.options.children = e, this.element.innerHTML = "", this.element.appendChild(e);
|
|
1034
|
+
}
|
|
1035
|
+
showAndEnsureVisible() {
|
|
1036
|
+
const e = this.options.children;
|
|
1037
|
+
e && (e.style.visibility = "hidden", this.show(), setTimeout(() => {
|
|
1038
|
+
e.style.visibility = "", this.ensureVisible();
|
|
1039
|
+
}));
|
|
1040
|
+
}
|
|
1041
|
+
moveElementToViewport() {
|
|
1042
|
+
const e = this.options.children;
|
|
1043
|
+
if (!e) return;
|
|
1044
|
+
const t = e.getBoundingClientRect(), n = window.innerWidth, s = window.innerHeight;
|
|
1045
|
+
let i = 0, a = 0;
|
|
1046
|
+
t.left < 0 ? i = -t.left : t.right > n && (i = n - t.right), t.top < 0 ? a = -t.top : t.bottom > s && (a = s - t.bottom), t.left + i < 0 && (i = -t.left), t.top + a < 0 && (a = -t.top), (i !== 0 || a !== 0) && (e.style.transform = `translate(${i}px, ${a}px)`);
|
|
1047
|
+
}
|
|
1048
|
+
ensureVisible() {
|
|
1049
|
+
const e = this.options.children;
|
|
1050
|
+
if (!e) return;
|
|
1051
|
+
e.style.transform && (e.style.transform = "");
|
|
1052
|
+
const t = new IntersectionObserver((n) => {
|
|
1053
|
+
n.forEach((s) => {
|
|
1054
|
+
s.isIntersecting && (this.moveElementToViewport(), t.disconnect());
|
|
1055
|
+
});
|
|
1056
|
+
});
|
|
1057
|
+
t.observe(e);
|
|
1058
|
+
}
|
|
1059
|
+
onPointerEvent(e, t) {
|
|
1060
|
+
const n = this.lead.handlePickNode([this], e, t);
|
|
1061
|
+
this.onNodePointerIndex.push(n);
|
|
1062
|
+
}
|
|
1063
|
+
dispose() {
|
|
1064
|
+
this.onNodePointerIndex.forEach((e) => {
|
|
1065
|
+
this.lead.removePickNode(e);
|
|
1066
|
+
}), super.dispose();
|
|
989
1067
|
}
|
|
990
1068
|
}
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
sideRepeat: h,
|
|
1001
|
-
topSegments: b
|
|
1002
|
-
} = a, o = b ? ze : Z, u = new o(new xt(s), {
|
|
1003
|
-
depth: e,
|
|
1004
|
-
bevelEnabled: !1,
|
|
1005
|
-
box3: i,
|
|
1006
|
-
UVGenerator: Ee({
|
|
1007
|
-
split: t,
|
|
1008
|
-
box3: i,
|
|
1009
|
-
sideRepeat: h
|
|
1010
|
-
}),
|
|
1011
|
-
hasTop: n,
|
|
1012
|
-
hasBottom: r,
|
|
1013
|
-
hasSide: l,
|
|
1014
|
-
topSegments: b
|
|
1015
|
-
});
|
|
1016
|
-
return Pe(), u;
|
|
1017
|
-
};
|
|
1018
|
-
class is extends q {
|
|
1019
|
-
constructor(t) {
|
|
1020
|
-
super(), this.options = G({
|
|
1021
|
-
depth: 1
|
|
1022
|
-
}, t);
|
|
1069
|
+
class rn extends Z {
|
|
1070
|
+
constructor(e) {
|
|
1071
|
+
super(), this.options = j({
|
|
1072
|
+
maxDepth: 10,
|
|
1073
|
+
percentDepth: !1,
|
|
1074
|
+
innerRadius: 25,
|
|
1075
|
+
outRadius: 42,
|
|
1076
|
+
activeIndex: -1
|
|
1077
|
+
}, e);
|
|
1023
1078
|
}
|
|
1024
1079
|
create() {
|
|
1025
|
-
return
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
hasTop: o,
|
|
1047
|
-
hasBottom: u,
|
|
1048
|
-
hasSide: y
|
|
1049
|
-
}) : !_ && e ? _ = R(
|
|
1050
|
-
e.map(
|
|
1051
|
-
(S, j) => {
|
|
1052
|
-
var v, B;
|
|
1053
|
-
return Ht({
|
|
1054
|
-
points: S,
|
|
1055
|
-
depth: (v = f[j]) != null ? v : f[0],
|
|
1056
|
-
box3: (B = w[j]) != null ? B : w[0],
|
|
1057
|
-
split: b,
|
|
1058
|
-
hasTop: o,
|
|
1059
|
-
hasBottom: u,
|
|
1060
|
-
hasSide: y
|
|
1061
|
-
});
|
|
1062
|
-
}
|
|
1063
|
-
),
|
|
1064
|
-
s != null ? s : 0
|
|
1065
|
-
) : !_ && r && r.length > 1 ? _ = R(r, s != null ? s : 0) : !_ && r && r.length === 1 && ([_] = r), this.createMesh(_, M);
|
|
1080
|
+
return ie(this, null, function* () {
|
|
1081
|
+
this.createGroup();
|
|
1082
|
+
const { data: e, maxDepth: t, colors: n, material: s, percentDepth: i, activeIndex: a } = this.options, f = Math.max(...e), r = e.reduce((o, c) => o + c, 0);
|
|
1083
|
+
let h = Math.PI / 2;
|
|
1084
|
+
e.forEach((o, c) => {
|
|
1085
|
+
if (o === 0) return;
|
|
1086
|
+
const y = Math.PI * 2 * (o / r), u = n[c], g = i ? t * (o / f) : t, L = this.createGeometry(g, y), S = s ? s.clone() : new Mt({
|
|
1087
|
+
color: u
|
|
1088
|
+
});
|
|
1089
|
+
s && S.color.set(u);
|
|
1090
|
+
const A = new Lt(L, S);
|
|
1091
|
+
A.userData.depth = g, A.userData.index = c, A.rotateZ(h), h += y, this.add(A);
|
|
1092
|
+
}), a !== -1 && this.setActive(a);
|
|
1093
|
+
});
|
|
1094
|
+
}
|
|
1095
|
+
createGeometry(e, t) {
|
|
1096
|
+
const { outRadius: n, innerRadius: s } = this.options, i = new xe();
|
|
1097
|
+
return i.moveTo(n, 0), i.lineTo(s, 0), i.absarc(0, 0, s, 0, t, !1), i.absarc(0, 0, n, t, 0, !0), new K(i, {
|
|
1098
|
+
curveSegments: 48,
|
|
1099
|
+
depth: e,
|
|
1100
|
+
bevelEnabled: !1
|
|
1066
1101
|
});
|
|
1067
1102
|
}
|
|
1068
|
-
|
|
1069
|
-
const
|
|
1070
|
-
|
|
1103
|
+
handlePick(e, t = 1.3) {
|
|
1104
|
+
const { object: n } = this.pencil.pick(e, this.object3d.children) || {}, s = n ? this.object3d.children.findIndex((i) => i === n) : this.options.activeIndex;
|
|
1105
|
+
return this.setActive(s, t);
|
|
1071
1106
|
}
|
|
1072
|
-
|
|
1073
|
-
|
|
1107
|
+
setActive(e, t = 1.3) {
|
|
1108
|
+
const n = this.object3d.children[e];
|
|
1109
|
+
if (this.object3d.children.forEach((s) => {
|
|
1110
|
+
if (!(n && n === s) && s.scale.z !== 1) {
|
|
1111
|
+
if (s.userData.levTween) return;
|
|
1112
|
+
s.userData.enTween && (s.userData.enTween.stop(), s.userData.enTween = null);
|
|
1113
|
+
const i = new ne.Tween(s.scale).to({ z: 1 }, 100);
|
|
1114
|
+
s.userData.levTween = i, i.start();
|
|
1115
|
+
}
|
|
1116
|
+
}), n) {
|
|
1117
|
+
if (n.userData.enTween)
|
|
1118
|
+
return;
|
|
1119
|
+
n.userData.levTween && (n.userData.levTween.stop(), n.userData.levTween = null);
|
|
1120
|
+
const s = new ne.Tween(n.scale).to({ z: t }, 100);
|
|
1121
|
+
return n.userData.enTween = s, s.start(), n.userData.index;
|
|
1122
|
+
}
|
|
1123
|
+
return -1;
|
|
1124
|
+
}
|
|
1125
|
+
render() {
|
|
1126
|
+
this.object3d.scale.z = 0, new ne.Tween(this.object3d.scale).to({ z: 1 }, 1e3).easing(ne.Easing.Sinusoidal.InOut).start();
|
|
1074
1127
|
}
|
|
1075
1128
|
}
|
|
1076
|
-
const ns = (a) => {
|
|
1077
|
-
const {
|
|
1078
|
-
topColor: t,
|
|
1079
|
-
sideColor: e,
|
|
1080
|
-
sideMap: s,
|
|
1081
|
-
createCanvasObjectURL: i,
|
|
1082
|
-
split: n,
|
|
1083
|
-
maxAnisotropy: r
|
|
1084
|
-
} = a;
|
|
1085
|
-
return new Promise((l) => {
|
|
1086
|
-
const h = s ? document.createElement("img") : {
|
|
1087
|
-
src: "",
|
|
1088
|
-
onload: () => {
|
|
1089
|
-
},
|
|
1090
|
-
width: 128,
|
|
1091
|
-
height: 128
|
|
1092
|
-
};
|
|
1093
|
-
h.onload = () => {
|
|
1094
|
-
const b = n, o = document.createElement("canvas"), u = o.getContext("2d");
|
|
1095
|
-
o.height = h.height / (1 - b), o.width = h.width, b && t && (u.fillStyle = t, u.fillRect(0, 0, h.width, o.height * b)), s && h instanceof HTMLImageElement ? u.drawImage(h, 0, o.height * b, h.width, h.height) : e && (u.fillStyle = e, u.fillRect(0, o.height * b, h.width, h.height)), i && o.toBlob((f) => {
|
|
1096
|
-
console.log(URL.createObjectURL(f));
|
|
1097
|
-
});
|
|
1098
|
-
const y = new Ae(o);
|
|
1099
|
-
l(y);
|
|
1100
|
-
}, s ? h.src = s : h instanceof HTMLImageElement || h.onload();
|
|
1101
|
-
});
|
|
1102
|
-
};
|
|
1103
1129
|
export {
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1130
|
+
Zt as ConicPolygon,
|
|
1131
|
+
$t as ExtrudePolygon,
|
|
1132
|
+
Qt as Group,
|
|
1133
|
+
Kt as Light,
|
|
1134
|
+
tn as Line,
|
|
1135
|
+
sn as Line2,
|
|
1136
|
+
ln as Line2Material,
|
|
1137
|
+
un as LineSegmentsGeometry,
|
|
1138
|
+
Ot as MeshLineGeometry,
|
|
1139
|
+
tt as MeshLineMaterial,
|
|
1140
|
+
en as MeshLineRaycast,
|
|
1141
|
+
on as Node,
|
|
1142
|
+
rn as Pie,
|
|
1143
|
+
et as getConicPolygonGeometry,
|
|
1144
|
+
fn as getConicPolygonGeometryMetas,
|
|
1145
|
+
Jt as getSplitTexture
|
|
1119
1146
|
};
|