gl-draw 0.9.0 → 0.9.2

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.
@@ -1,28 +1,28 @@
1
1
  var N = Object.defineProperty, W = Object.defineProperties;
2
2
  var _ = Object.getOwnPropertyDescriptors;
3
- var w = Object.getOwnPropertySymbols;
4
- var A = Object.prototype.hasOwnProperty, z = Object.prototype.propertyIsEnumerable;
5
- var B = (c, e, t) => e in c ? N(c, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : c[e] = t, C = (c, e) => {
3
+ var E = Object.getOwnPropertySymbols;
4
+ var A = Object.prototype.hasOwnProperty, B = Object.prototype.propertyIsEnumerable;
5
+ var z = (l, e, t) => e in l ? N(l, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : l[e] = t, C = (l, e) => {
6
6
  for (var t in e || (e = {}))
7
- A.call(e, t) && B(c, t, e[t]);
8
- if (w)
9
- for (var t of w(e))
10
- z.call(e, t) && B(c, t, e[t]);
11
- return c;
12
- }, S = (c, e) => W(c, _(e));
13
- var O = (c, e) => {
7
+ A.call(e, t) && z(l, t, e[t]);
8
+ if (E)
9
+ for (var t of E(e))
10
+ B.call(e, t) && z(l, t, e[t]);
11
+ return l;
12
+ }, S = (l, e) => W(l, _(e));
13
+ var O = (l, e) => {
14
14
  var t = {};
15
- for (var s in c)
16
- A.call(c, s) && e.indexOf(s) < 0 && (t[s] = c[s]);
17
- if (c != null && w)
18
- for (var s of w(c))
19
- e.indexOf(s) < 0 && z.call(c, s) && (t[s] = c[s]);
15
+ for (var s in l)
16
+ A.call(l, s) && e.indexOf(s) < 0 && (t[s] = l[s]);
17
+ if (l != null && E)
18
+ for (var s of E(l))
19
+ e.indexOf(s) < 0 && B.call(l, s) && (t[s] = l[s]);
20
20
  return t;
21
21
  };
22
- import M from "camera-controls";
23
- import * as d from "three";
24
- import { ShaderMaterial as X, Uniform as L, REVISION as q } from "three";
25
- import * as T from "@tweenjs/tween.js";
22
+ import x from "camera-controls";
23
+ import * as h from "three";
24
+ import { ShaderMaterial as X, Uniform as T, REVISION as q } from "three";
25
+ import * as L from "@tweenjs/tween.js";
26
26
  import { e as j } from "./events.module.js";
27
27
  import $ from "deepmerge";
28
28
  import Y from "three/examples/jsm/libs/stats.module";
@@ -37,8 +37,8 @@ import { RectAreaLightHelper as Q } from "three/examples/jsm/helpers/RectAreaLig
37
37
  import { TransformControls as ee } from "three/examples/jsm/controls/TransformControls";
38
38
  import { CSS3DRenderer as te } from "three/examples/jsm/renderers/CSS3DRenderer";
39
39
  import { CSS2DRenderer as se } from "three/examples/jsm/renderers/CSS2DRenderer";
40
- import { Pass as re, BlendFunction as y, ToneMappingMode as V, EffectComposer as oe, RenderPass as ne, CopyPass as ie, FXAAEffect as ae, EffectPass as R, ToneMappingEffect as le, SelectiveBloomEffect as ce } from "postprocessing";
41
- import { i as de } from "./isPlainObject.module.js";
40
+ import { Pass as re, BlendFunction as y, ToneMappingMode as I, EffectComposer as oe, RenderPass as ie, CopyPass as ne, FXAAEffect as ae, EffectPass as M, ToneMappingEffect as ce, SelectiveBloomEffect as le } from "postprocessing";
41
+ import { i as he } from "./isPlainObject.module.js";
42
42
  import { B as $e } from "./BaseObject.module.js";
43
43
  const me = {
44
44
  antialias: !1,
@@ -53,42 +53,42 @@ const me = {
53
53
  depth: !1,
54
54
  physicallyCorrectLights: !1
55
55
  };
56
- class he {
56
+ class de {
57
57
  constructor(e) {
58
58
  this.options = e;
59
59
  const { width: t, height: s, rendererParams: r } = e, {
60
60
  canvas: o,
61
- context: n,
62
- alpha: i,
61
+ context: i,
62
+ alpha: n,
63
63
  devicePixelRatio: a,
64
- antialias: l,
64
+ antialias: c,
65
65
  powerPreference: m,
66
- toneMappingExposure: h,
67
- outputColorSpace: p,
66
+ toneMappingExposure: d,
67
+ outputColorSpace: f,
68
68
  logarithmicDepthBuffer: u,
69
69
  preserveDrawingBuffer: v,
70
- stencil: f,
71
- depth: b,
70
+ stencil: p,
71
+ depth: w,
72
72
  physicallyCorrectLights: P
73
- } = r, g = new d.WebGLRenderer({
73
+ } = r, g = new h.WebGLRenderer({
74
74
  canvas: o,
75
- context: n,
76
- alpha: i,
77
- antialias: l,
75
+ context: i,
76
+ alpha: n,
77
+ antialias: c,
78
78
  powerPreference: m,
79
79
  logarithmicDepthBuffer: u,
80
80
  preserveDrawingBuffer: v,
81
- stencil: f,
82
- depth: b
81
+ stencil: p,
82
+ depth: w
83
83
  });
84
- g.setSize(t, s), g.setPixelRatio(a), g.toneMappingExposure = h, g.outputColorSpace = p, +d.REVISION < 155 && (g.useLegacyLights = P), this.renderer = g;
84
+ g.setSize(t, s), g.setPixelRatio(a), g.toneMappingExposure = d, g.outputColorSpace = f, +h.REVISION < 155 && (g.useLegacyLights = P), this.renderer = g;
85
85
  }
86
86
  setSize(e, t) {
87
87
  this.renderer.setSize(e, t);
88
88
  }
89
- render() {
90
- const { scene: e, camera: t } = this.options;
91
- this.renderer.render(e, t);
89
+ render(e) {
90
+ const { scene: t, camera: s } = this.options;
91
+ this.renderer.render(t, e || s);
92
92
  }
93
93
  dispose() {
94
94
  var e, t;
@@ -104,41 +104,41 @@ class D {
104
104
  const s = e.addFolder(t), r = this.guiParams[t];
105
105
  Object.keys(r).forEach((o) => {
106
106
  const {
107
- min: n,
108
- max: i,
107
+ min: i,
108
+ max: n,
109
109
  step: a,
110
- name: l,
110
+ name: c,
111
111
  paramMap: m,
112
- items: h,
113
- value: p,
112
+ items: d,
113
+ value: f,
114
114
  target: u
115
115
  } = r[o], v = o.toLowerCase().indexOf("color") > -1;
116
- let f;
117
- const b = typeof p == "undefined" && u, P = b ? u() : r[o], g = b ? o : "value";
118
- h ? f = s.add(P, g, h) : v ? f = s.addColor(P, g) : f = s.add(P, g), f = f.name(l || o), typeof n != "undefined" && (f = f.min(n)), typeof i != "undefined" && (f = f.max(i)), typeof a != "undefined" && (f = f.step(a)), f = f.onChange(() => {
116
+ let p;
117
+ const w = typeof f == "undefined" && u, P = w ? u() : r[o], g = w ? o : "value";
118
+ d ? p = s.add(P, g, d) : v ? p = s.addColor(P, g) : p = s.add(P, g), p = p.name(c || o), typeof i != "undefined" && (p = p.min(i)), typeof n != "undefined" && (p = p.max(n)), typeof a != "undefined" && (p = p.step(a)), p = p.onChange(() => {
119
119
  this.setTargetValue(t, o, P[g], m);
120
- }), b && f.listen();
120
+ }), w && p.listen();
121
121
  });
122
122
  });
123
123
  }
124
124
  setTargetValue(e, t, s, r) {
125
125
  const {
126
126
  onChange: o,
127
- target: n,
128
- value: i
127
+ target: i,
128
+ value: n
129
129
  } = this.guiParams[e][t], a = t.toLowerCase().indexOf("color") > -1;
130
- if (n && !(typeof i == "undefined" && n)) {
131
- let m = n();
132
- Array.isArray(m) || (m = [m]), m.forEach((h) => {
133
- if (h)
130
+ if (i && !(typeof n == "undefined" && i)) {
131
+ let m = i();
132
+ Array.isArray(m) || (m = [m]), m.forEach((d) => {
133
+ if (d)
134
134
  if (a)
135
135
  try {
136
- h[r || t].set(s);
137
- } catch (p) {
136
+ d[r || t].set(s);
137
+ } catch (f) {
138
138
  t !== "color" && !r && console.warn(`${t} is not a color,set paramMap`);
139
139
  }
140
140
  else
141
- h[r || t] = s;
141
+ d[r || t] = s;
142
142
  });
143
143
  }
144
144
  o && o(s);
@@ -152,30 +152,39 @@ class D {
152
152
  });
153
153
  }
154
154
  }
155
- const fe = {
155
+ const pe = {
156
156
  fov: 45,
157
157
  near: 1,
158
158
  far: 1e3,
159
- up: new d.Vector3(0, 1, 0)
159
+ up: new h.Vector3(0, 1, 0)
160
160
  };
161
- class pe {
161
+ class fe {
162
162
  constructor(e) {
163
163
  this.customCamera = !1, this.options = e;
164
164
  const { width: t, height: s, cameraParams: r } = e;
165
- if (r instanceof d.Camera)
165
+ if (r instanceof h.Camera)
166
166
  this.camera = r, this.customCamera = !0;
167
167
  else {
168
- const { fov: o, far: n, near: i, up: a } = r, l = new d.PerspectiveCamera(
168
+ const { fov: o, far: i, near: n, up: a } = r, c = new h.PerspectiveCamera(
169
169
  o,
170
170
  t / s,
171
- i,
172
- n
171
+ n,
172
+ i
173
173
  );
174
- l.position.set(0, 0, 400), l.lookAt(0, 0, 0), l.up = a, this.camera = l;
174
+ c.position.set(0, 0, 400), c.lookAt(0, 0, 0), c.up = a, this.camera = c;
175
175
  }
176
176
  }
177
177
  setSize(e, t) {
178
- this.camera instanceof d.PerspectiveCamera && (this.camera.aspect = e / t), this.camera.updateProjectionMatrix();
178
+ this.camera instanceof h.PerspectiveCamera && (this.camera.aspect = e / t), this.camera.updateProjectionMatrix(), this.camera2 && (this.camera2.aspect = e / t, this.camera2.updateProjectionMatrix());
179
+ }
180
+ addCamera2() {
181
+ const e = new h.PerspectiveCamera(
182
+ this.camera.fov,
183
+ this.camera.aspect,
184
+ this.camera.near,
185
+ this.camera.far
186
+ );
187
+ return e.position.copy(this.camera.position), this.camera2 = e, e;
179
188
  }
180
189
  setGui(e) {
181
190
  const t = new D({
@@ -219,7 +228,7 @@ class pe {
219
228
  }
220
229
  })
221
230
  });
222
- this.camera instanceof d.PerspectiveCamera && (t.guiParams.camera.fov = {
231
+ this.camera instanceof h.PerspectiveCamera && (t.guiParams.camera.fov = {
223
232
  min: 0,
224
233
  max: 90,
225
234
  step: 1,
@@ -237,19 +246,19 @@ const ue = {
237
246
  class ge {
238
247
  constructor(e) {
239
248
  this.overrideMaterial = !1, this.options = e;
240
- const { camera: t, sceneParams: s } = e, { background: r, om: o } = s, n = o ? new d.Scene() : new Proxy(new d.Scene(), {
241
- set: (i, a, l) => Reflect.set(i, a, l),
242
- get: (i, a) => {
249
+ const { camera: t, sceneParams: s } = e, { background: r, om: o } = s, i = o ? new h.Scene() : new Proxy(new h.Scene(), {
250
+ set: (n, a, c) => Reflect.set(n, a, c),
251
+ get: (n, a) => {
243
252
  if (a === "overrideMaterial") {
244
- const l = Reflect.get(i, a);
245
- return this.overrideMaterial = !!l, F.forEach((m) => {
253
+ const c = Reflect.get(n, a);
254
+ return this.overrideMaterial = !!c, F.forEach((m) => {
246
255
  this.overrideMaterial ? m.useDepth = 1 : m.useDepth = 0;
247
256
  }), null;
248
257
  }
249
- return Reflect.get(i, a);
258
+ return Reflect.get(n, a);
250
259
  }
251
260
  });
252
- r && (n.background = r), n.add(t), this.scene = n;
261
+ r && (i.background = r), i.add(t), this.scene = i;
253
262
  }
254
263
  dispose() {
255
264
  var e;
@@ -267,25 +276,25 @@ class Ce {
267
276
  let r = this.helpers[t];
268
277
  if (r === void 0) {
269
278
  if (e.isScene)
270
- r = new d.AxesHelper(100);
279
+ r = new h.AxesHelper(100);
271
280
  else if (e.isCamera)
272
- r = new d.CameraHelper(e);
281
+ r = new h.CameraHelper(e);
273
282
  else if (e.isPointLight)
274
- r = new d.PointLightHelper(e, 1);
283
+ r = new h.PointLightHelper(e, 1);
275
284
  else if (e.isDirectionalLight)
276
- r = new d.DirectionalLightHelper(e, 1);
285
+ r = new h.DirectionalLightHelper(e, 1);
277
286
  else if (e.isSpotLight)
278
- r = new d.SpotLightHelper(e);
287
+ r = new h.SpotLightHelper(e);
279
288
  else if (e.isHemisphereLight)
280
- r = new d.HemisphereLightHelper(e, 10);
289
+ r = new h.HemisphereLightHelper(e, 10);
281
290
  else if (e.isRectAreaLight)
282
291
  r = new Q(e);
283
292
  else {
284
- const o = new d.Box3();
293
+ const o = new h.Box3();
285
294
  if (o.setFromObject(e, !0), o.isEmpty() === !1) {
286
- r = new d.Box3Helper(o);
287
- const n = r.material;
288
- n.userData.object = e, n.depthTest = !1, n.transparent = !0;
295
+ r = new h.Box3Helper(o);
296
+ const i = r.material;
297
+ i.userData.object = e, i.depthTest = !1, i.transparent = !0;
289
298
  } else
290
299
  return;
291
300
  }
@@ -296,7 +305,7 @@ class Ce {
296
305
  const t = e.uuid, { scene: s } = this.options;
297
306
  if (this.helpers[t] !== void 0) {
298
307
  const r = this.helpers[t];
299
- s.remove(r), delete this.helpers[t], r instanceof d.Box3Helper && r.dispose();
308
+ s.remove(r), delete this.helpers[t], r instanceof h.Box3Helper && r.dispose();
300
309
  }
301
310
  }
302
311
  removeAll() {
@@ -308,14 +317,14 @@ class Ce {
308
317
  }
309
318
  removeAllExcludeScene() {
310
319
  Object.keys(this.helpers).forEach((e) => {
311
- this.helpers[e] instanceof d.AxesHelper || this.remove({
320
+ this.helpers[e] instanceof h.AxesHelper || this.remove({
312
321
  uuid: e
313
322
  });
314
323
  });
315
324
  }
316
325
  update() {
317
326
  Object.values(this.helpers).forEach((e) => {
318
- if (e.update && e.update(), e instanceof d.Box3Helper) {
327
+ if (e.update && e.update(), e instanceof h.Box3Helper) {
319
328
  const t = e.material, { object: s } = t.userData;
320
329
  s && e.box.setFromObject(s, !0);
321
330
  }
@@ -330,10 +339,14 @@ class ve {
330
339
  this.autoRotateSpeed = 0, this.options = e;
331
340
  const { camera: t, controlsParams: s, customControl: r } = e, { domElement: o } = s;
332
341
  if (r) {
333
- const n = new r(t, o);
334
- n.enableDamping = !0, n.dampingFactor = 0.063, n.autoRotate = !1, n.autoRotateSpeed = -60, n.enableZoom = !0, n.zoomSpeed = 0.2, this.controls = n;
342
+ const i = new r(t, o);
343
+ i.enableDamping = !0, i.dampingFactor = 0.063, i.autoRotate = !1, i.autoRotateSpeed = -60, i.enableZoom = !0, i.zoomSpeed = 0.2, this.controls = i;
335
344
  } else
336
- M.install({ THREE: d }), this.cameraControls = new M(t, o);
345
+ x.install({ THREE: h }), this.cameraControls = new x(t, o);
346
+ }
347
+ addCameraControls2(e) {
348
+ const { controlsParams: t } = this.options, { domElement: s } = t;
349
+ this.cameraControls2 = new x(e, s);
337
350
  }
338
351
  enable() {
339
352
  this.controls ? this.controls.enabled = !0 : this.cameraControls && (this.cameraControls.enabled = !0);
@@ -342,12 +355,12 @@ class ve {
342
355
  this.controls ? this.controls.enabled = !1 : this.cameraControls && (this.cameraControls.enabled = !1);
343
356
  }
344
357
  update(e) {
345
- var t, s;
346
- (t = this.controls) == null || t.update(), (s = this.cameraControls) == null || s.update(e), this.autoRotateSpeed && this.cameraControls && (this.cameraControls.azimuthAngle += this.autoRotateSpeed * e * d.MathUtils.DEG2RAD);
358
+ var t, s, r;
359
+ (t = this.controls) == null || t.update(), (s = this.cameraControls) == null || s.update(e), (r = this.cameraControls2) == null || r.update(e), this.autoRotateSpeed && this.cameraControls && (this.cameraControls.azimuthAngle += this.autoRotateSpeed * e * h.MathUtils.DEG2RAD);
347
360
  }
348
361
  dispose() {
349
- var e, t;
350
- (e = this.controls) == null || e.dispose(), (t = this.cameraControls) == null || t.dispose();
362
+ var e, t, s;
363
+ (e = this.controls) == null || e.dispose(), (t = this.cameraControls) == null || t.dispose(), (s = this.cameraControls2) == null || s.dispose();
351
364
  }
352
365
  }
353
366
  class Pe {
@@ -406,16 +419,16 @@ class Pe {
406
419
  this.event.removeAllListeners(), (e = this.controls) == null || e.dispose();
407
420
  }
408
421
  }
409
- const G = {
422
+ const V = {
410
423
  zIndex: "auto"
411
424
  };
412
- class be {
425
+ class we {
413
426
  constructor(e) {
414
427
  this.container = e;
415
428
  }
416
429
  addRenderer(e, t) {
417
- const s = t.container || this.container, r = s.offsetWidth, o = s.offsetHeight, n = e === "css2d" ? new se() : new te();
418
- n.domElement.style.position = "absolute", n.domElement.style.top = "0", n.domElement.style.pointerEvents = "none", n.domElement.style.zIndex = t.zIndex, n.setSize(r, o), s.appendChild(n.domElement), e === "css2d" ? this.css2Drenderer = n : e === "css3d" && (this.css3Drenderer = n);
430
+ const s = t.container || this.container, r = s.offsetWidth, o = s.offsetHeight, i = e === "css2d" ? new se() : new te();
431
+ i.domElement.style.position = "absolute", i.domElement.style.top = "0", i.domElement.style.pointerEvents = "none", i.domElement.style.zIndex = t.zIndex, i.setSize(r, o), s.appendChild(i.domElement), e === "css2d" ? this.css2Drenderer = i : e === "css3d" && (this.css3Drenderer = i);
419
432
  }
420
433
  setSize(e, t) {
421
434
  var s, r;
@@ -426,16 +439,17 @@ class be {
426
439
  (s = this.css2Drenderer) == null || s.render(e, t), (r = this.css3Drenderer) == null || r.render(e, t);
427
440
  }
428
441
  dispose() {
429
- this.css2Drenderer = void 0, this.css3Drenderer = void 0;
442
+ var e, t;
443
+ (e = this.css2Drenderer) == null || e.domElement.remove(), (t = this.css3Drenderer) == null || t.domElement.remove(), this.css2Drenderer = void 0, this.css3Drenderer = void 0;
430
444
  }
431
445
  }
432
- const H = ["encodings_fragment", "colorspace_fragment"];
433
- class Ee extends X {
446
+ const G = ["encodings_fragment", "colorspace_fragment"];
447
+ class be extends X {
434
448
  constructor() {
435
449
  super({
436
450
  uniforms: {
437
- inputBuffer: new L(null),
438
- ratio: new L(1)
451
+ inputBuffer: new T(null),
452
+ ratio: new T(1)
439
453
  },
440
454
  fragmentShader: `
441
455
  uniform sampler2D inputBuffer;
@@ -445,7 +459,7 @@ class Ee extends X {
445
459
  vec4 texel = texture2D(inputBuffer, vUv);
446
460
  gl_FragColor = texel * ratio;
447
461
  // Support automatic output encoding.
448
- #include <${+q < 154 ? H[0] : H[1]}>
462
+ #include <${+q < 154 ? G[0] : G[1]}>
449
463
 
450
464
  }
451
465
  `,
@@ -462,9 +476,9 @@ class Ee extends X {
462
476
  });
463
477
  }
464
478
  }
465
- class we extends re {
479
+ class Ee extends re {
466
480
  constructor() {
467
- super("CrossFadePass"), this.fullscreenMaterial = new Ee();
481
+ super("CrossFadePass"), this.fullscreenMaterial = new be();
468
482
  }
469
483
  render(e, t, s) {
470
484
  const r = this.fullscreenMaterial;
@@ -482,7 +496,7 @@ const U = {
482
496
  ignoreBackground: !0,
483
497
  epsilon: 1e-3
484
498
  }, Se = {
485
- mode: V.REINHARD2_ADAPTIVE,
499
+ mode: I.REINHARD2_ADAPTIVE,
486
500
  resolution: 256,
487
501
  whitePoint: 16,
488
502
  middleGrey: 0.6,
@@ -493,38 +507,45 @@ const U = {
493
507
  class xe {
494
508
  constructor(e) {
495
509
  this.active = !0, this.options = e;
496
- const { renderer: t, scene: s, camera: r, composerParams: o } = e, { multisampling: n, frameBufferType: i } = o, { maxSamples: a } = t.capabilities, l = new oe(t, {
497
- multisampling: Math.min(n, a),
510
+ const { renderer: t, scene: s, camera: r } = e;
511
+ this.finalComposer = this.addFinalComposer(r), this.renderer = t, this.scene = s, this.camera = r;
512
+ }
513
+ addFinalComposer(e) {
514
+ const { renderer: t, scene: s, composerParams: r } = this.options, { multisampling: o, frameBufferType: i } = r, { maxSamples: n } = t.capabilities, a = new oe(t, {
515
+ multisampling: Math.min(o, n),
498
516
  frameBufferType: i
499
517
  });
500
- l.addPass(new ne(s, r)), this.finalComposer = l, this.renderer = t, this.scene = s, this.camera = r;
518
+ return a.addPass(new ie(s, e)), a;
519
+ }
520
+ addFinalComposer2(e) {
521
+ const t = this.addFinalComposer(e);
522
+ this.finalComposer2 = t;
501
523
  }
502
524
  addCopyPass() {
503
- const e = new ie();
525
+ const e = new ne();
504
526
  this.finalComposer.addPass(e), this.copyPass = e;
505
527
  }
506
528
  addCrossFadePass() {
507
- const e = new we();
529
+ const e = new Ee();
508
530
  this.finalComposer.addPass(e), this.crossFadePass = e;
509
531
  }
510
532
  addFXAAPass() {
511
- const { camera: e } = this, t = new ae({ blendFunction: y.NORMAL }), s = new R(e, t);
533
+ const { camera: e } = this, t = new ae({ blendFunction: y.NORMAL }), s = new M(e, t);
512
534
  this.finalComposer.addPass(s), this.fxaaPass = s;
513
535
  }
514
536
  addToneMappingPass(e) {
515
- const { camera: t } = this, s = new le(C({}, e));
537
+ const { camera: t } = this, s = new ce(C({}, e));
516
538
  this.toneMappingEffect = s;
517
- const r = new R(t, s);
539
+ const r = new M(t, s);
518
540
  this.finalComposer.addPass(r), this.toneMappingPass = r;
519
541
  }
520
542
  addToneMappingGui(e) {
521
- if (!this.toneMappingEffect)
522
- return;
543
+ if (!this.toneMappingEffect) return;
523
544
  new D({
524
545
  toneMapping: {
525
546
  blendFunction: {
526
547
  value: this.toneMappingEffect.mode,
527
- items: V,
548
+ items: I,
528
549
  onChange: (s) => {
529
550
  this.toneMappingEffect.mode = Number(s);
530
551
  }
@@ -562,14 +583,13 @@ class xe {
562
583
  }).showGui(e);
563
584
  }
564
585
  addBloomPass(e) {
565
- const { camera: t, scene: s } = this, m = C(C({}, U), e), { epsilon: r, ignoreBackground: o, mipmapBlurPassRadius: n } = m, i = O(m, ["epsilon", "ignoreBackground", "mipmapBlurPassRadius"]), a = new ce(s, t, C({}, i));
566
- o && (a.ignoreBackground = o), n && (a.mipmapBlurPass.radius = n), a.depthMaskMaterial.epsilon = r, a.luminancePass.enabled = !1, a.luminancePass.enabled = e.luminancePass;
567
- const l = new R(t, a);
568
- this.finalComposer.addPass(l), this.bloomPass = l, this.bloomEffect = a;
586
+ const { camera: t, scene: s } = this, m = C(C({}, U), e), { epsilon: r, ignoreBackground: o, mipmapBlurPassRadius: i } = m, n = O(m, ["epsilon", "ignoreBackground", "mipmapBlurPassRadius"]), a = new le(s, t, C({}, n));
587
+ o && (a.ignoreBackground = o), i && (a.mipmapBlurPass.radius = i), a.depthMaskMaterial.epsilon = r, a.luminancePass.enabled = !1, a.luminancePass.enabled = e.luminancePass;
588
+ const c = new M(t, a);
589
+ this.finalComposer.addPass(c), this.bloomPass = c, this.bloomEffect = a;
569
590
  }
570
591
  addBloomGui(e) {
571
- if (!this.bloomEffect)
572
- return;
592
+ if (!this.bloomEffect) return;
573
593
  new D({
574
594
  bloom: {
575
595
  intensity: {
@@ -637,7 +657,7 @@ class xe {
637
657
  }
638
658
  getSize() {
639
659
  const { renderer: e } = this.options;
640
- return e.getSize(new d.Vector2());
660
+ return e.getSize(new h.Vector2());
641
661
  }
642
662
  enable() {
643
663
  this.active || (this.active = !0);
@@ -646,43 +666,49 @@ class xe {
646
666
  this.active && (this.active = !1);
647
667
  }
648
668
  setSize(e, t) {
649
- this.finalComposer.setSize(e, t);
669
+ var s;
670
+ this.finalComposer.setSize(e, t), (s = this.finalComposer2) == null || s.setSize(e, t);
650
671
  }
651
672
  render() {
652
673
  this.active && this.finalComposer.render();
653
674
  }
675
+ render2() {
676
+ var e;
677
+ this.active && ((e = this.finalComposer2) == null || e.render());
678
+ }
654
679
  dispose() {
655
- this.finalComposer.dispose();
680
+ var e;
681
+ this.finalComposer.dispose(), (e = this.finalComposer2) == null || e.dispose();
656
682
  }
657
683
  }
658
684
  const Re = () => {
659
685
  try {
660
- const c = document.createElement("canvas");
661
- return !!(window.WebGL2RenderingContext && c.getContext("webgl2"));
662
- } catch (c) {
686
+ const l = document.createElement("canvas");
687
+ return !!(window.WebGL2RenderingContext && l.getContext("webgl2"));
688
+ } catch (l) {
663
689
  return !1;
664
690
  }
665
- }, E = !1, k = Re() !== !1, x = class x {
691
+ }, b = !1, H = Re() !== !1, R = class R {
666
692
  constructor(e, t) {
667
- this.raycaster = new d.Raycaster(), this.installPlugins = /* @__PURE__ */ new Map(), this.event = new j.EventEmitter(), this.clock = new d.Clock(), this.userData = {}, this.options = $(x.options, e, {
668
- isMergeableObject: de
693
+ this.raycaster = new h.Raycaster(), this.installPlugins = /* @__PURE__ */ new Map(), this.event = new j.EventEmitter(), this.clock = new h.Clock(), this.userData = {}, this.mulitViewport = !1, this.options = $(R.options, e, {
694
+ isMergeableObject: he
669
695
  }), this.event.setMaxListeners(1 / 0);
670
696
  const {
671
697
  container: s,
672
698
  stats: r,
673
699
  gui: o,
674
- resizeObserver: n
700
+ resizeObserver: i
675
701
  } = this.options;
676
702
  if (o) {
677
- const i = new Z();
678
- i.open(!1), this.gui = i;
703
+ const n = new Z();
704
+ n.open(!1), this.gui = n;
679
705
  }
680
706
  if (r) {
681
- const i = new Y();
682
- i.showPanel(0), i.dom.style.position = "absolute", s.appendChild(i.dom), this.stats = i;
707
+ const n = new Y();
708
+ n.showPanel(0), n.dom.style.position = "absolute", s.appendChild(n.dom), this.stats = n;
683
709
  }
684
- this.init(), this.initComposer(), this.initCSSRenderer(), this.initControls(), n && this.initResizeObserver(), this.clock.getDelta(), this.clock.getElapsedTime(), t && (Array.isArray(t) || (t = [t]), t.forEach((i) => {
685
- Array.isArray(i) || (i = [i]), this.use(i[0], i[1]);
710
+ this.init(), this.initComposer(), this.initCSSRenderer(), this.initControls(), i && this.initResizeObserver(), this.clock.getDelta(), this.clock.getElapsedTime(), t && (Array.isArray(t) || (t = [t]), t.forEach((n) => {
711
+ Array.isArray(n) || (n = [n]), this.use(n[0], n[1]);
686
712
  }));
687
713
  }
688
714
  getPlugin(e) {
@@ -695,10 +721,10 @@ const Re = () => {
695
721
  return this.controlsController.cameraControls;
696
722
  }
697
723
  get cameraPositon() {
698
- return this.cameraControls.getPosition(new d.Vector3(), !1);
724
+ return this.cameraControls.getPosition(new h.Vector3(), !1);
699
725
  }
700
726
  get cameraTarget() {
701
- return this.cameraControls.getTarget(new d.Vector3(), !1);
727
+ return this.cameraControls.getTarget(new h.Vector3(), !1);
702
728
  }
703
729
  get camera() {
704
730
  return this.cameraController.camera;
@@ -716,36 +742,36 @@ const Re = () => {
716
742
  helper: s,
717
743
  renderer: r,
718
744
  scene: o,
719
- camera: n,
720
- control: i
721
- } = this.options, { width: a, height: l } = this.getSize(), m = new pe({
745
+ camera: i,
746
+ control: n
747
+ } = this.options, { width: a, height: c } = this.getSize(), m = new fe({
722
748
  isdev: t,
723
749
  width: a,
724
- height: l,
725
- cameraParams: n,
726
- cameraControls: i === !0
750
+ height: c,
751
+ cameraParams: i,
752
+ cameraControls: n === !0
727
753
  });
728
754
  this.gui && m.setGui(this.gui);
729
- const h = m.camera, p = new ge({
730
- camera: h,
755
+ const d = m.camera, f = new ge({
756
+ camera: d,
731
757
  sceneParams: o
732
- }), u = p.scene, v = new he({
758
+ }), u = f.scene, v = new de({
733
759
  width: a,
734
- height: l,
760
+ height: c,
735
761
  scene: u,
736
- camera: h,
762
+ camera: d,
737
763
  isdev: t,
738
764
  rendererParams: S(C({}, r), {
739
765
  antialias: !1
740
766
  })
741
767
  });
742
768
  if (s) {
743
- const f = new Ce({
769
+ const p = new Ce({
744
770
  scene: u
745
771
  });
746
- f.add(u), this.helperController = f;
772
+ p.add(u), this.helperController = p;
747
773
  }
748
- this.sceneController = p, this.rendererController = v, this.cameraController = m, e.appendChild(v.renderer.domElement);
774
+ this.sceneController = f, this.rendererController = v, this.cameraController = m, e.appendChild(v.renderer.domElement);
749
775
  }
750
776
  initComposer() {
751
777
  const {
@@ -754,25 +780,25 @@ const Re = () => {
754
780
  toneMapping: s,
755
781
  toneMappingParams: r,
756
782
  crossOpacity: o,
757
- renderer: n,
758
- multisampling: i,
783
+ renderer: i,
784
+ multisampling: n,
759
785
  frameBufferType: a,
760
- passes: l
786
+ passes: c
761
787
  } = this.options;
762
- let { antialias: m } = n;
763
- m === "msaa" && !k && (m = !1, console.warn("MSAA is not supported on this browser"));
764
- const h = new xe({
788
+ let { antialias: m } = i;
789
+ m === "msaa" && !H && (m = !1, console.warn("MSAA is not supported on this browser"));
790
+ const d = new xe({
765
791
  renderer: this.renderer,
766
792
  scene: this.scene,
767
793
  camera: this.camera,
768
794
  composerParams: {
769
- multisampling: m === "msaa" ? i : 0,
770
- frameBufferType: s ? d.HalfFloatType : a
795
+ multisampling: m === "msaa" ? n : 0,
796
+ frameBufferType: s ? h.HalfFloatType : a
771
797
  }
772
798
  });
773
- this.composerController = h, e && (h.addBloomPass(t), this.gui && h.addBloomGui(this.gui)), s && (h.addToneMappingPass(r), this.gui && h.addToneMappingGui(this.gui)), m === "fxaa" && h.addFXAAPass(), o && h.addCrossFadePass(), l && l.forEach((p) => {
774
- h.finalComposer.addPass(p);
775
- }), h.finalComposer.passes.length === 1 && h.addCopyPass();
799
+ this.composerController = d, e && (d.addBloomPass(t), this.gui && d.addBloomGui(this.gui)), s && (d.addToneMappingPass(r), this.gui && d.addToneMappingGui(this.gui)), m === "fxaa" && d.addFXAAPass(), o && d.addCrossFadePass(), c && c.forEach((f) => {
800
+ d.finalComposer.addPass(f);
801
+ }), d.finalComposer.passes.length === 1 && d.addCopyPass();
776
802
  }
777
803
  get opacity() {
778
804
  const { crossFadePass: e } = this.composerController;
@@ -795,8 +821,8 @@ const Re = () => {
795
821
  css3DRendererParams: o
796
822
  } = this.options;
797
823
  if (t || s) {
798
- const n = new be(e);
799
- t && n.addRenderer("css2d", r), s && n.addRenderer("css3d", o), this.cssRendererController = n;
824
+ const i = new we(e);
825
+ t && i.addRenderer("css2d", r), s && i.addRenderer("css3d", o), this.cssRendererController = i;
800
826
  }
801
827
  }
802
828
  initControls() {
@@ -839,8 +865,7 @@ const Re = () => {
839
865
  }
840
866
  initResizeObserver() {
841
867
  const { container: e } = this.options;
842
- if (this.resizeObserver)
843
- return;
868
+ if (this.resizeObserver) return;
844
869
  const t = new ResizeObserver((s) => {
845
870
  for (const r of s) {
846
871
  const o = r.contentRect;
@@ -853,36 +878,36 @@ const Re = () => {
853
878
  const {
854
879
  rendererController: r,
855
880
  cameraController: o,
856
- composerController: n,
857
- cssRendererController: i
881
+ composerController: i,
882
+ cssRendererController: n
858
883
  } = this;
859
- o == null || o.setSize(e, t), r == null || r.setSize(e, t), n == null || n.setSize(e, t), i == null || i.setSize(e, t), this.installPlugins.forEach((a) => {
860
- var l;
861
- (l = a.setSize) == null || l.call(a, e, t);
884
+ o == null || o.setSize(e, t), r == null || r.setSize(e, t), i == null || i.setSize(e, t), n == null || n.setSize(e, t), this.installPlugins.forEach((a) => {
885
+ var c;
886
+ (c = a.setSize) == null || c.call(a, e, t);
862
887
  }), s && this.event.emit("resize", { width: e, height: t });
863
888
  }
864
889
  pick(e, t, s = !1) {
865
- const { raycaster: r, options: o } = this, { container: n } = o, i = new d.Vector2(), a = n.getBoundingClientRect();
866
- if (i.x = (e.clientX - a.left) / (a.right - a.left) * 2 - 1, i.y = -((e.clientY - a.top) / (a.bottom - a.top)) * 2 + 1, this.camera && this.scene) {
867
- r.setFromCamera(i, this.camera);
868
- const l = r.intersectObjects(
890
+ const { raycaster: r, options: o } = this, { container: i } = o, n = new h.Vector2(), a = i.getBoundingClientRect();
891
+ if (n.x = (e.clientX - a.left) / (a.right - a.left) * 2 - 1, n.y = -((e.clientY - a.top) / (a.bottom - a.top)) * 2 + 1, this.camera && this.scene) {
892
+ r.setFromCamera(n, this.camera);
893
+ const c = r.intersectObjects(
869
894
  t || this.scene.children,
870
895
  s
871
896
  );
872
- if (l.length)
897
+ if (c.length)
873
898
  return {
874
- object: l[0].object,
875
- intersects: l
899
+ object: c[0].object,
900
+ intersects: c
876
901
  };
877
902
  }
878
903
  }
879
904
  render() {
880
- var n, i, a, l, m, h;
905
+ var i, n, a, c, m, d;
881
906
  const { scene: e, camera: t, clock: s } = this, r = s.getDelta(), o = s.getElapsedTime();
882
- T.update(), (n = this.controlsController) == null || n.update(r), this.installPlugins.forEach((p) => {
907
+ L.update(), (i = this.controlsController) == null || i.update(r), this.installPlugins.forEach((f) => {
883
908
  var u;
884
- (u = p.update) == null || u.call(p, r, o);
885
- }), (i = this.helperController) == null || i.update(), (a = this.composerController) != null && a.active ? this.composerController.render() : (l = this.rendererController) == null || l.render(), (m = this.cssRendererController) == null || m.render(e, t), (h = this.stats) == null || h.update(), this.event.emit("render", { delta: r, elapsed: o });
909
+ (u = f.update) == null || u.call(f, r, o);
910
+ }), (n = this.helperController) == null || n.update(), (a = this.composerController) != null && a.active ? this.mulitViewport ? (this.setViewportLeft(), this.composerController.render(), this.setViewportRight(), this.composerController.render2()) : this.composerController.render() : (c = this.rendererController) == null || c.render(), (m = this.cssRendererController) == null || m.render(e, t), (d = this.stats) == null || d.update(), this.event.emit("render", { delta: r, elapsed: o });
886
911
  }
887
912
  start() {
888
913
  this.renderer.setAnimationLoop(this.render.bind(this)), this.event.emit("start");
@@ -893,45 +918,81 @@ const Re = () => {
893
918
  autoRotate(e) {
894
919
  this.controlsController.autoRotateSpeed = e;
895
920
  }
921
+ setMulitViewport(e) {
922
+ if (this.mulitViewport = e, e) {
923
+ if (!this.controlsController.cameraControls2) {
924
+ const t = this.cameraController.addCamera2();
925
+ this.composerController.addFinalComposer2(t), this.controlsController.addCameraControls2(t);
926
+ }
927
+ this.controlsController.cameraControls.interactiveArea = new DOMRect(
928
+ 0,
929
+ 0,
930
+ 0.5,
931
+ 1
932
+ ), this.controlsController.cameraControls2.interactiveArea = new DOMRect(
933
+ 0.5,
934
+ 0,
935
+ 0.5,
936
+ 1
937
+ );
938
+ } else e || (this.controlsController.cameraControls2 && (this.controlsController.cameraControls2.interactiveArea = new DOMRect(
939
+ 0,
940
+ 0,
941
+ 1,
942
+ 1
943
+ )), this.setViewportFull());
944
+ }
945
+ setViewportFull() {
946
+ const e = this.getSize(), t = 0, s = 0, r = e.width, o = e.height, i = r / o;
947
+ this.camera.aspect !== i && (this.camera.aspect = i, this.camera.updateProjectionMatrix()), this.renderer.setViewport(t, s, r, o), this.renderer.setScissor(t, s, r, o), this.renderer.setScissorTest(!0);
948
+ }
949
+ setViewportLeft() {
950
+ const e = this.getSize(), t = 0, s = 0, r = e.width / 2, o = e.height, i = r / o;
951
+ this.camera.aspect !== i && (this.camera.aspect = i, this.camera.updateProjectionMatrix()), this.renderer.setViewport(t, s, r, o), this.renderer.setScissor(t, s, r, o), this.renderer.setScissorTest(!0);
952
+ }
953
+ setViewportRight() {
954
+ const e = this.getSize(), t = e.width / 2, s = 0, r = e.width / 2, o = e.height, i = r / o, n = this.cameraController.camera2;
955
+ n && n.aspect !== i && (n.aspect = i, n.updateProjectionMatrix()), this.renderer.setViewport(t, s, r, o), this.renderer.setScissor(t, s, r, o), this.renderer.setScissorTest(!0);
956
+ }
896
957
  dispose() {
897
- var e, t, s, r, o, n, i, a, l, m, h;
898
- this.stop(), T.removeAll(), this.event.removeAllListeners(), (e = this.resizeObserver) == null || e.unobserve(this.options.container), this.handeleResize(0, 0), this.installPlugins.forEach((p) => {
958
+ var e, t, s, r, o, i, n, a, c, m, d;
959
+ this.stop(), L.removeAll(), this.event.removeAllListeners(), (e = this.resizeObserver) == null || e.unobserve(this.options.container), this.handeleResize(0, 0), this.installPlugins.forEach((f) => {
899
960
  var u;
900
- (u = p.dispose) == null || u.call(p);
901
- }), (t = this.controlsController) == null || t.dispose(), (s = this.transformController) == null || s.dispose(), (r = this.cssRendererController) == null || r.dispose(), (o = this.sceneController) == null || o.dispose(), (n = this.helperController) == null || n.dispose(), (i = this.composerController) == null || i.dispose(), (a = this.rendererController) == null || a.dispose(), this.cssRendererController = void 0, (l = this.gui) == null || l.destroy(), this.installPlugins.clear(), (m = this.stats) == null || m.dom.remove(), (h = this.renderer) == null || h.domElement.remove();
961
+ (u = f.dispose) == null || u.call(f);
962
+ }), (t = this.controlsController) == null || t.dispose(), (s = this.transformController) == null || s.dispose(), (r = this.cssRendererController) == null || r.dispose(), (o = this.sceneController) == null || o.dispose(), (i = this.helperController) == null || i.dispose(), (n = this.composerController) == null || n.dispose(), (a = this.rendererController) == null || a.dispose(), this.cssRendererController = void 0, (c = this.gui) == null || c.destroy(), this.installPlugins.clear(), (m = this.stats) == null || m.dom.remove(), (d = this.renderer) == null || d.domElement.remove();
902
963
  }
903
964
  };
904
- x.options = {
905
- isdev: E,
906
- stats: E,
907
- gui: E,
908
- helper: E,
965
+ R.options = {
966
+ isdev: b,
967
+ stats: b,
968
+ gui: b,
969
+ helper: b,
909
970
  control: !0,
910
- transformControls: E,
971
+ transformControls: b,
911
972
  resizeObserver: !0,
912
973
  renderer: S(C({}, me), {
913
- antialias: k ? "msaa" : "fxaa"
974
+ antialias: H ? "msaa" : "fxaa"
914
975
  }),
915
976
  multisampling: 4,
916
- frameBufferType: d.UnsignedByteType,
977
+ frameBufferType: h.UnsignedByteType,
917
978
  scene: ue,
918
- camera: fe,
979
+ camera: pe,
919
980
  bloom: !1,
920
981
  bloomParams: U,
921
982
  toneMapping: !1,
922
983
  toneMappingParams: Se,
923
984
  crossOpacity: !1,
924
985
  css2DRenderer: !1,
925
- css2DRendererParams: C({}, G),
986
+ css2DRendererParams: C({}, V),
926
987
  css3DRenderer: !1,
927
- css3DRendererParams: C({}, G)
988
+ css3DRendererParams: C({}, V)
928
989
  };
929
- let I = x;
930
- const _e = M.ACTION;
990
+ let k = R;
991
+ const _e = x.ACTION;
931
992
  export {
932
993
  $e as BaseObject,
933
994
  D as GUIObject,
934
- I as Pencil,
995
+ k as Pencil,
935
996
  _e as cameraControlsAction,
936
- I as default
997
+ k as default
937
998
  };