gl-draw 0.9.0-beta.33 → 0.9.0-beta.331

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.
Files changed (84) hide show
  1. package/README.md +0 -18
  2. package/dist/BaseObject.js +1 -1
  3. package/dist/BaseObject.module.js +121 -52
  4. package/dist/MeshLineMaterial.js +139 -0
  5. package/dist/MeshLineMaterial.module.js +422 -0
  6. package/dist/colorCorrection.js +1 -0
  7. package/dist/colorCorrection.module.js +25 -0
  8. package/dist/core/BaseObject.d.ts +22 -8
  9. package/dist/core/CSSRenderer/index.d.ts +1 -0
  10. package/dist/core/Camera.d.ts +1 -0
  11. package/dist/core/Composer.d.ts +34 -3
  12. package/dist/core/Controls.d.ts +56 -0
  13. package/dist/core/Pencil.d.ts +42 -13
  14. package/dist/core/Renderer.d.ts +2 -20
  15. package/dist/core/Scene.d.ts +3 -0
  16. package/dist/core/TransformControls.d.ts +18 -0
  17. package/dist/core/pass/CrossFadePass.d.ts +11 -0
  18. package/dist/disposeMesh.js +1 -1
  19. package/dist/disposeMesh.module.js +5 -5
  20. package/dist/events.js +1 -0
  21. package/dist/events.module.js +234 -0
  22. package/dist/getProjection.js +1 -0
  23. package/dist/getProjection.module.js +12 -0
  24. package/dist/index.js +18 -1
  25. package/dist/index.module.js +546 -545
  26. package/dist/index.module2.js +9 -0
  27. package/dist/index2.js +1 -0
  28. package/dist/objects/conicPolygon/createGeometry.d.ts +8 -0
  29. package/dist/objects/conicPolygon/geometry/index.d.ts +20 -18
  30. package/dist/objects/conicPolygon/geometry/triangulate.d.ts +2 -1
  31. package/dist/objects/conicPolygon/index.d.ts +9 -12
  32. package/dist/objects/extrudePolygon/createGeometry.d.ts +1 -0
  33. package/dist/objects/extrudePolygon/index.d.ts +2 -3
  34. package/dist/objects/image/index.d.ts +8 -6
  35. package/dist/objects/index.d.ts +2 -2
  36. package/dist/objects/index.js +1 -127
  37. package/dist/objects/index.module.js +952 -1370
  38. package/dist/objects/line/createGeometry.d.ts +3 -3
  39. package/dist/objects/line/index.d.ts +12 -11
  40. package/dist/objects/line/meshLine/MeshLineMaterial.d.ts +6 -1
  41. package/dist/objects/node/index.d.ts +9 -10
  42. package/dist/objects/video/index.d.ts +2 -2
  43. package/dist/plugins/Cache.d.ts +1 -0
  44. package/dist/plugins/Data.d.ts +1 -0
  45. package/dist/plugins/Draw.d.ts +27 -5
  46. package/dist/plugins/Loader/CacheLoader.d.ts +13 -0
  47. package/dist/plugins/Loader/TextureLoader.d.ts +6 -0
  48. package/dist/plugins/Loader/VideoTextureLoader.d.ts +6 -0
  49. package/dist/plugins/Loader/index.d.ts +105 -0
  50. package/dist/plugins/Worker/chunk.d.ts +1 -0
  51. package/dist/plugins/Worker/createGeometry.d.ts +3 -0
  52. package/dist/plugins/Worker/getAttributes/conicLine.d.ts +20 -0
  53. package/dist/plugins/Worker/getAttributes/conicPolygon.d.ts +28 -0
  54. package/dist/plugins/Worker/getAttributes/coords2Vector.d.ts +3 -0
  55. package/dist/plugins/Worker/getAttributes/extrudePolygon.d.ts +27 -0
  56. package/dist/plugins/Worker/getAttributes/getMessage.d.ts +13 -0
  57. package/dist/plugins/Worker/getAttributes/line.d.ts +20 -0
  58. package/dist/plugins/Worker/index.d.ts +42 -0
  59. package/dist/plugins/index.d.ts +1 -1
  60. package/dist/plugins/index.js +1 -1
  61. package/dist/plugins/index.module.js +656 -227
  62. package/dist/utils/colorCorrection.d.ts +13 -1
  63. package/dist/utils/disposeMesh.d.ts +1 -1
  64. package/dist/utils/getProjection.d.ts +10 -0
  65. package/dist/utils/index.d.ts +2 -0
  66. package/dist/utils/index.js +1 -1
  67. package/dist/utils/index.module.js +91 -91
  68. package/dist/utils/parseVector.d.ts +3 -0
  69. package/dist/utils/uvGenerator.d.ts +1 -0
  70. package/dist/uvGenerator.js +1 -1
  71. package/dist/uvGenerator.module.js +48 -47
  72. package/package.json +12 -12
  73. package/dist/core/Control.d.ts +0 -33
  74. package/dist/geojson/china.json +0 -103310
  75. package/dist/geojson/countries.json +0 -27483
  76. package/dist/objects/extrudePolygon/coords2Vector.d.ts +0 -7
  77. package/dist/objects/extrudePolygon/getWorkerGeometry.d.ts +0 -20
  78. package/dist/objects/line/coords2Vector.d.ts +0 -7
  79. package/dist/objects/line/getWorkerGeometry.d.ts +0 -16
  80. package/dist/objects/line/line.w.d.ts +0 -1
  81. package/dist/plugins/Worker.d.ts +0 -31
  82. package/dist/worker/extrudePolygon.w.js +0 -3403
  83. package/dist/worker/line.w.js +0 -5
  84. /package/dist/{objects/extrudePolygon/extrudePolygon.w.d.ts → plugins/Worker/getAttributes/geo.d.ts} +0 -0
package/README.md CHANGED
@@ -239,21 +239,3 @@ interface Options {
239
239
  (method) BaseObject.dispose(): void
240
240
  ```
241
241
 
242
- ## 提示
243
- ### @tweenjs/tween.js 使用需要注册
244
- ```js
245
- const pencil = new Pencil({
246
- ...
247
- })
248
- pencil.use({
249
- install: () => {},
250
- update: () => {
251
- TWEEN.update();
252
- },
253
- dispose: () => {
254
- TWEEN.removeAll();
255
- },
256
- })
257
- ```
258
-
259
-
@@ -1 +1 @@
1
- "use strict";const o=require("three"),h=require("esus-lite"),a=require("three/examples/jsm/renderers/CSS2DRenderer"),c=require("three/examples/jsm/renderers/CSS3DRenderer"),d=require("./disposeMesh.js");require("idb-keyval");function u(t){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const r in t)if(r!=="default"){const i=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(e,r,i.get?i:{enumerable:!0,get:()=>t[r]})}}return e.default=t,Object.freeze(e)}const s=u(o),n=t=>{t&&(d.disposeMesh(t),t.children.forEach(e=>{e.userData.BaseObject_||n(e)}))};class b{constructor(){this.objecttype__="BaseObject",this.userData={},this.pm=h.makePromiseCreator(),this.visible=!1}get parent(){const e=this.object3d.parent;return(e==null?void 0:e.userData.BaseObject_)||this.pencil.scene}get children(){return this.object3d.children.map(e=>e.userData.BaseObject_).filter(e=>!!e)}init(){}create(){}render(){}update(e,r){}resize(e,r){}show(){return this.object3d&&(this.object3d.visible=!0),this.visible=!0,this}hide(){return this.object3d&&(this.object3d.visible=!1),this.visible=!1,this}isVisible(){return this.visible}createMesh(...e){return this.object3d=new s.Mesh(...e),this}createGroup(){return this.object3d=new s.Group,this}createPoints(...e){return this.object3d=new s.Points(...e),this}createCSS2DObject(e){return this.object3d=new a.CSS2DObject(e),this}createCSS3DObject(e){return this.object3d=new c.CSS3DObject(e),this}createCSS3DSprite(e){return this.object3d=new c.CSS3DSprite(e),this}createSprite(e){return this.object3d=new s.Sprite(e),this}add(...e){return this.object3d.add(...e),this}remove(...e){return this.object3d.remove(...e),this}attach(...e){return[...e].forEach(r=>{this.object3d.attach(r.object3d)}),this}getSize(){const e=new s.Box3().setFromObject(this.object3d);return{min:e.min,max:e.max,size:e.getSize(new s.Vector3)}}traverse(e){e(this),this.children.forEach(r=>{r.traverse(e)})}dispose(){n(this.object3d)}}exports.BaseObject=b;
1
+ "use strict";const l=require("three"),d=require("esus-lite"),u=require("three/examples/jsm/renderers/CSS2DRenderer"),c=require("three/examples/jsm/renderers/CSS3DRenderer"),n=require("./disposeMesh.js");require("idb-keyval");require("d3-geo");function b(i){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(i){for(const e in i)if(e!=="default"){const r=Object.getOwnPropertyDescriptor(i,e);Object.defineProperty(t,e,r.get?r:{enumerable:!0,get:()=>i[e]})}}return t.default=i,Object.freeze(t)}const a=b(l),h=(i,t,e)=>{t&&(n.disposeMesh(t,e),t.children.forEach(r=>{i.has(r)||h(i,r,e)}))};class j{constructor(){this.objectType="BaseObject",this.userData={},this.prefab=!1,this.pm=d.makePromiseCreator(),this.materialList={},this.useMaterialType="origin"}get parent(){const t=this.object3d.parent;return t?this.drawController.objMap.get(t)||this.pencil.scene:null}get children(){return this.object3d.children.map(t=>this.drawController.objMap.get(t)).filter(t=>!!t)}get position(){var t;return(t=this.object3d)==null?void 0:t.position}get rotation(){var t;return(t=this.object3d)==null?void 0:t.rotation}get scale(){var t;return(t=this.object3d)==null?void 0:t.scale}get add(){var t;return(t=this.object3d)==null?void 0:t.add.bind(this.object3d)}get remove(){var t;return(t=this.object3d)==null?void 0:t.remove.bind(this.object3d)}get visible(){return this.object3d?this.object3d.visible:!1}create(){}render(){}update(t,e){}resize(t,e){}show(){return this.object3d&&(this.object3d.visible=!0),this}hide(){return this.object3d&&(this.object3d.visible=!1),this}createMesh(...t){return this.object3d=new a.Mesh(...t),this}createGroup(){return this.object3d=new a.Group,this}createPoints(...t){return this.object3d=new a.Points(...t),this}createCSS2DObject(t){return this.object3d=new u.CSS2DObject(t),this}createCSS3DObject(t){return this.object3d=new c.CSS3DObject(t),this}createCSS3DSprite(t){return this.object3d=new c.CSS3DSprite(t),this}createSprite(t){return this.object3d=new a.Sprite(t),this}attach(...t){return[...t].forEach(e=>{this.object3d.attach(e.object3d),this.drawController!==e.drawController&&(e.drawController.objects.delete(e.key),this.drawController.objects.set(e.key,e))}),this}getSize(){const t=new a.Box3().setFromObject(this.object3d);return{min:t.min,max:t.max,size:t.getSize(new a.Vector3)}}traverse(t){t(this),this.children.forEach(e=>{e.traverse(t)})}clone(){return this.instantiate()}instantiate(){return this.drawController.instantiate(this,{create:t=>{this.object3d&&(t.object3d=this.object3d.clone(!0))}})}erase(){this.drawController.erase(this)}cloneMaterial(){const t=this.object3d;if(!t||!t.material)return;const e=t.material;if(Array.isArray(e))return e.map(r=>{const s=r.userData;r.userData={};const o=r.clone();return r.userData=s,o});{const r=e.userData;e.userData={};const s=e.clone();return e.userData=r,s}}setMaterialList(t,e,r=!0){const s=this.object3d;if(!s||!s.material)return;if(this.materialList.origin||(this.materialList.origin=s.material),!r&&this.materialList[t])return this.materialList[t];const o=e==="clone"?this.cloneMaterial():e;return this.materialList[t]=o,o}useMaterial(t){const e=this.object3d;!e||!e.material||this.useMaterialType===t||!this.materialList[t]||(this.useMaterialType=t,e.material=this.materialList[t])}setTop(t){this.object3d&&(this.object3d.renderOrder=t)}dispose(t=!0){h(this.drawController.objMap,this.object3d,t),t&&Object.keys(this.materialList).forEach(e=>{e!=="origin"&&n.disposeMesh({material:this.materialList[e]})})}}exports.BaseObject=j;
@@ -1,93 +1,162 @@
1
- import * as t from "three";
1
+ import * as s from "three";
2
2
  import { makePromiseCreator as h } from "esus-lite";
3
- import { CSS2DObject as c } from "three/examples/jsm/renderers/CSS2DRenderer";
4
- import { CSS3DObject as o, CSS3DSprite as a } from "three/examples/jsm/renderers/CSS3DRenderer";
5
- import { d as n } from "./disposeMesh.module.js";
3
+ import { CSS2DObject as l } from "three/examples/jsm/renderers/CSS2DRenderer";
4
+ import { CSS3DObject as d, CSS3DSprite as b } from "three/examples/jsm/renderers/CSS3DRenderer";
5
+ import { d as c } from "./disposeMesh.module.js";
6
6
  import "idb-keyval";
7
- const s = (r) => {
8
- r && (n(r), r.children.forEach((e) => {
9
- e.userData.BaseObject_ || s(e);
7
+ import "d3-geo";
8
+ const n = (o, t, e) => {
9
+ t && (c(t, e), t.children.forEach((r) => {
10
+ o.has(r) || n(o, r, e);
10
11
  }));
11
12
  };
12
- class m {
13
+ class S {
13
14
  constructor() {
14
- this.objecttype__ = "BaseObject", this.userData = {}, this.pm = h(), this.visible = !1;
15
+ this.objectType = "BaseObject", this.userData = {}, this.prefab = !1, this.pm = h(), this.materialList = {}, this.useMaterialType = "origin";
15
16
  }
16
17
  get parent() {
17
- const e = this.object3d.parent;
18
- return (e == null ? void 0 : e.userData.BaseObject_) || this.pencil.scene;
18
+ const t = this.object3d.parent;
19
+ return t ? this.drawController.objMap.get(t) || this.pencil.scene : null;
19
20
  }
20
21
  get children() {
21
- return this.object3d.children.map((e) => e.userData.BaseObject_).filter((e) => !!e);
22
+ return this.object3d.children.map((t) => this.drawController.objMap.get(t)).filter((t) => !!t);
22
23
  }
23
- init() {
24
+ get position() {
25
+ var t;
26
+ return (t = this.object3d) == null ? void 0 : t.position;
27
+ }
28
+ get rotation() {
29
+ var t;
30
+ return (t = this.object3d) == null ? void 0 : t.rotation;
31
+ }
32
+ get scale() {
33
+ var t;
34
+ return (t = this.object3d) == null ? void 0 : t.scale;
35
+ }
36
+ get add() {
37
+ var t;
38
+ return (t = this.object3d) == null ? void 0 : t.add.bind(this.object3d);
39
+ }
40
+ get remove() {
41
+ var t;
42
+ return (t = this.object3d) == null ? void 0 : t.remove.bind(this.object3d);
43
+ }
44
+ get visible() {
45
+ return this.object3d ? this.object3d.visible : !1;
24
46
  }
25
47
  create() {
26
48
  }
27
49
  render() {
28
50
  }
29
- update(e, i) {
51
+ update(t, e) {
30
52
  }
31
- resize(e, i) {
53
+ resize(t, e) {
32
54
  }
33
55
  show() {
34
- return this.object3d && (this.object3d.visible = !0), this.visible = !0, this;
56
+ return this.object3d && (this.object3d.visible = !0), this;
35
57
  }
36
58
  hide() {
37
- return this.object3d && (this.object3d.visible = !1), this.visible = !1, this;
38
- }
39
- isVisible() {
40
- return this.visible;
59
+ return this.object3d && (this.object3d.visible = !1), this;
41
60
  }
42
- createMesh(...e) {
43
- return this.object3d = new t.Mesh(...e), this;
61
+ createMesh(...t) {
62
+ return this.object3d = new s.Mesh(...t), this;
44
63
  }
45
64
  createGroup() {
46
- return this.object3d = new t.Group(), this;
65
+ return this.object3d = new s.Group(), this;
47
66
  }
48
- createPoints(...e) {
49
- return this.object3d = new t.Points(...e), this;
67
+ createPoints(...t) {
68
+ return this.object3d = new s.Points(...t), this;
50
69
  }
51
- createCSS2DObject(e) {
52
- return this.object3d = new c(e), this;
70
+ createCSS2DObject(t) {
71
+ return this.object3d = new l(t), this;
53
72
  }
54
- createCSS3DObject(e) {
55
- return this.object3d = new o(e), this;
73
+ createCSS3DObject(t) {
74
+ return this.object3d = new d(t), this;
56
75
  }
57
- createCSS3DSprite(e) {
58
- return this.object3d = new a(e), this;
76
+ createCSS3DSprite(t) {
77
+ return this.object3d = new b(t), this;
59
78
  }
60
- createSprite(e) {
61
- return this.object3d = new t.Sprite(e), this;
79
+ createSprite(t) {
80
+ return this.object3d = new s.Sprite(t), this;
62
81
  }
63
- add(...e) {
64
- return this.object3d.add(...e), this;
65
- }
66
- remove(...e) {
67
- return this.object3d.remove(...e), this;
68
- }
69
- attach(...e) {
70
- return [...e].forEach((i) => {
71
- this.object3d.attach(i.object3d);
82
+ attach(...t) {
83
+ return [...t].forEach((e) => {
84
+ this.object3d.attach(e.object3d), this.drawController !== e.drawController && (e.drawController.objects.delete(e.key), this.drawController.objects.set(e.key, e));
72
85
  }), this;
73
86
  }
74
87
  getSize() {
75
- const e = new t.Box3().setFromObject(this.object3d);
88
+ const t = new s.Box3().setFromObject(this.object3d);
76
89
  return {
77
- min: e.min,
78
- max: e.max,
79
- size: e.getSize(new t.Vector3())
90
+ min: t.min,
91
+ max: t.max,
92
+ size: t.getSize(new s.Vector3())
80
93
  };
81
94
  }
82
- traverse(e) {
83
- e(this), this.children.forEach((i) => {
84
- i.traverse(e);
95
+ traverse(t) {
96
+ t(this), this.children.forEach((e) => {
97
+ e.traverse(t);
98
+ });
99
+ }
100
+ clone() {
101
+ return this.instantiate();
102
+ }
103
+ instantiate() {
104
+ return this.drawController.instantiate(this, {
105
+ create: (t) => {
106
+ this.object3d && (t.object3d = this.object3d.clone(!0));
107
+ }
85
108
  });
86
109
  }
87
- dispose() {
88
- s(this.object3d);
110
+ erase() {
111
+ this.drawController.erase(this);
112
+ }
113
+ cloneMaterial() {
114
+ const t = this.object3d;
115
+ if (!t || !t.material)
116
+ return;
117
+ const e = t.material;
118
+ if (Array.isArray(e))
119
+ return e.map((r) => {
120
+ const i = r.userData;
121
+ r.userData = {};
122
+ const a = r.clone();
123
+ return r.userData = i, a;
124
+ });
125
+ {
126
+ const r = e.userData;
127
+ e.userData = {};
128
+ const i = e.clone();
129
+ return e.userData = r, i;
130
+ }
131
+ }
132
+ setMaterialList(t, e, r = !0) {
133
+ const i = this.object3d;
134
+ if (!i || !i.material)
135
+ return;
136
+ if (this.materialList.origin || (this.materialList.origin = i.material), !r && this.materialList[t])
137
+ return this.materialList[t];
138
+ const a = e === "clone" ? this.cloneMaterial() : e;
139
+ return this.materialList[t] = a, a;
140
+ }
141
+ useMaterial(t) {
142
+ const e = this.object3d;
143
+ !e || !e.material || this.useMaterialType === t || !this.materialList[t] || (this.useMaterialType = t, e.material = this.materialList[t]);
144
+ }
145
+ setTop(t) {
146
+ this.object3d && (this.object3d.renderOrder = t);
147
+ }
148
+ dispose(t = !0) {
149
+ n(
150
+ this.drawController.objMap,
151
+ this.object3d,
152
+ t
153
+ ), t && Object.keys(this.materialList).forEach((e) => {
154
+ e !== "origin" && c({
155
+ material: this.materialList[e]
156
+ });
157
+ });
89
158
  }
90
159
  }
91
160
  export {
92
- m as B
161
+ S as B
93
162
  };
@@ -0,0 +1,139 @@
1
+ "use strict";var f=Object.defineProperty,m=Object.defineProperties;var v=Object.getOwnPropertyDescriptors;var s=Object.getOwnPropertySymbols;var p=Object.prototype.hasOwnProperty,c=Object.prototype.propertyIsEnumerable;var o=(i,t,e)=>t in i?f(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e,u=(i,t)=>{for(var e in t||(t={}))p.call(t,e)&&o(i,e,t[e]);if(s)for(var e of s(t))c.call(t,e)&&o(i,e,t[e]);return i},l=(i,t)=>m(i,v(t));const d=require("three");function g(i){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(i){for(const e in i)if(e!=="default"){const n=Object.getOwnPropertyDescriptor(i,e);Object.defineProperty(t,e,n.get?n:{enumerable:!0,get:()=>i[e]})}}return t.default=i,Object.freeze(t)}const r=g(d),h=["encodings_fragment","colorspace_fragment"],y=`
2
+ #include <common>
3
+ #include <logdepthbuf_pars_vertex>
4
+ #include <fog_pars_vertex>
5
+
6
+ attribute vec3 previous;
7
+ attribute vec3 next;
8
+ attribute float side;
9
+ attribute float width;
10
+ attribute float counters;
11
+
12
+ uniform vec2 resolution;
13
+ uniform float lineWidth;
14
+ uniform vec3 color;
15
+ uniform float opacity;
16
+ uniform float sizeAttenuation;
17
+ uniform vec2 offset;
18
+
19
+ uniform float time;
20
+ uniform vec3 lightColor;
21
+ uniform vec2 uCenter;
22
+ uniform float size;
23
+ uniform float speed;
24
+ uniform float lightWidth;
25
+ uniform float lineLightAnimation;
26
+
27
+ varying vec2 vUV;
28
+ varying vec4 vColor;
29
+ varying float vCounters;
30
+ varying vec2 vHighPrecisionZW;
31
+
32
+ vec2 fix(vec4 i, float aspect) {
33
+ vec2 res = i.xy / i.w;
34
+ res.x *= aspect;
35
+ vCounters = counters;
36
+ return res;
37
+ }
38
+
39
+ void main() {
40
+ float aspect = resolution.x / resolution.y;
41
+ if (lineLightAnimation == 1.0) {
42
+ vec2 vWorld=position.xy;
43
+ float r_time=mod(time/(speed*size),2.);
44
+ float l=distance(vWorld, uCenter)/size;
45
+ float r_opacity=smoothstep(r_time-lightWidth*2.,r_time-lightWidth,l)-smoothstep(r_time-lightWidth,r_time,l);
46
+ vColor=vec4(mix(color,lightColor,r_opacity),opacity);
47
+ } else {
48
+ vColor=vec4(color,opacity);
49
+ }
50
+
51
+ vUV=uv+offset;
52
+
53
+ mat4 m = projectionMatrix * modelViewMatrix;
54
+ vec4 finalPosition = m * vec4(position, 1.0);
55
+ vec4 prevPos = m * vec4(previous, 1.0);
56
+ vec4 nextPos = m * vec4(next, 1.0);
57
+
58
+ vec2 currentP = fix(finalPosition, aspect);
59
+ vec2 prevP = fix(prevPos, aspect);
60
+ vec2 nextP = fix(nextPos, aspect);
61
+
62
+ float w = lineWidth * width;
63
+
64
+ vec2 dir;
65
+ if (nextP == currentP) dir = normalize(currentP - prevP);
66
+ else if (prevP == currentP) dir = normalize(nextP - currentP);
67
+ else {
68
+ vec2 dir1 = normalize(currentP - prevP);
69
+ vec2 dir2 = normalize(nextP - currentP);
70
+ dir = normalize(dir1 + dir2);
71
+
72
+ vec2 perp = vec2(-dir1.y, dir1.x);
73
+ vec2 miter = vec2(-dir.y, dir.x);
74
+ //w = clamp(w / dot(miter, perp), 0., 4. * lineWidth * width);
75
+ }
76
+
77
+ //vec2 normal = (cross(vec3(dir, 0.), vec3(0., 0., 1.))).xy;
78
+ vec4 normal = vec4(-dir.y, dir.x, 0., 1.);
79
+ normal.xy *= .5 * w;
80
+ //normal *= projectionMatrix;
81
+ if (sizeAttenuation == 0.) {
82
+ normal.xy *= finalPosition.w;
83
+ normal.xy /= (vec4(resolution, 0., 1.) * projectionMatrix).xy;
84
+ }
85
+
86
+ finalPosition.xy += normal.xy * side;
87
+ gl_Position = finalPosition;
88
+ #include <logdepthbuf_vertex>
89
+ #include <fog_vertex>
90
+ vec4 mvPosition = modelViewMatrix * vec4(position, 1.0);
91
+ vHighPrecisionZW = finalPosition.zw;
92
+ #include <fog_vertex>
93
+ }
94
+ `,b=`
95
+ #include <packing>
96
+ #include <fog_pars_fragment>
97
+ #include <logdepthbuf_pars_fragment>
98
+
99
+ uniform sampler2D map;
100
+ uniform sampler2D alphaMap;
101
+ uniform float useMap;
102
+ uniform float useAlphaMap;
103
+ uniform float useDash;
104
+ uniform float dashArray;
105
+ uniform float dashOffset;
106
+ uniform float dashRatio;
107
+ uniform float visibility;
108
+ uniform float alphaTest;
109
+ uniform vec2 repeat;
110
+ uniform float useDepth;
111
+
112
+ varying vec2 vUV;
113
+ varying vec4 vColor;
114
+ varying float vCounters;
115
+ varying vec2 vHighPrecisionZW;
116
+
117
+ void main() {
118
+ #include <logdepthbuf_fragment>
119
+ vec4 c = vColor;
120
+ if (useMap == 1.) c *= texture2D(map, vUV * repeat);
121
+ if (useAlphaMap == 1.) c.a *= texture2D(alphaMap, vUV * repeat).a;
122
+ if (c.a < alphaTest) discard;
123
+ if (useDash == 1.) {
124
+ c.a *= ceil(mod(vCounters + dashOffset, dashArray) - (dashArray * dashRatio));
125
+ }
126
+ if (useDepth == 1.) {
127
+ float fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;
128
+ gl_FragColor = packDepthToRGBA( fragCoordZ );
129
+ }else{
130
+ gl_FragColor = c;
131
+ gl_FragColor.a *= step(vCounters, visibility);
132
+ }
133
+
134
+
135
+ #include <fog_fragment>
136
+ #include <tonemapping_fragment>
137
+ #include <${+r.REVISION<154?h[0]:h[1]}>
138
+ }
139
+ `,a=[];class x extends r.ShaderMaterial{constructor(t){super({uniforms:l(u({},r.UniformsLib.fog),{lineWidth:{value:1},map:{value:null},useMap:{value:0},alphaMap:{value:null},useAlphaMap:{value:0},color:{value:new r.Color(16777215)},opacity:{value:1},resolution:{value:new r.Vector2(1,1)},sizeAttenuation:{value:1},dashArray:{value:0},dashOffset:{value:0},dashRatio:{value:.5},useDash:{value:0},useDepth:{value:0},visibility:{value:1},alphaTest:{value:0},repeat:{value:new r.Vector2(1,1)},offset:{value:new r.Vector2(1,1)},lineLightAnimation:{value:0},time:{value:0},size:{value:300},speed:{value:.3},lightWidth:{value:.1},uCenter:{value:new r.Vector2(0,0)},lightColor:{value:new r.Color(16777215)}}),vertexShader:y,fragmentShader:b}),a.push(this),this.type="MeshLineMaterial",Object.defineProperties(this,{lineWidth:{enumerable:!0,get(){return this.uniforms.lineWidth.value},set(e){this.uniforms.lineWidth.value=e}},map:{enumerable:!0,get(){return this.uniforms.map.value},set(e){this.uniforms.map.value=e}},useMap:{enumerable:!0,get(){return this.uniforms.useMap.value},set(e){this.uniforms.useMap.value=e}},alphaMap:{enumerable:!0,get(){return this.uniforms.alphaMap.value},set(e){this.uniforms.alphaMap.value=e}},useAlphaMap:{enumerable:!0,get(){return this.uniforms.useAlphaMap.value},set(e){this.uniforms.useAlphaMap.value=e}},color:{enumerable:!0,get(){return this.uniforms.color.value},set(e){this.uniforms.color.value=e}},opacity:{enumerable:!0,get(){return this.uniforms.opacity.value},set(e){this.uniforms.opacity.value=e}},resolution:{enumerable:!0,get(){return this.uniforms.resolution.value},set(e){this.uniforms.resolution.value.copy(e)}},sizeAttenuation:{enumerable:!0,get(){return this.uniforms.sizeAttenuation.value},set(e){this.uniforms.sizeAttenuation.value=e}},dashArray:{enumerable:!0,get(){return this.uniforms.dashArray.value},set(e){this.uniforms.dashArray.value=e,this.useDash=e!==0?1:0}},dashOffset:{enumerable:!0,get(){return this.uniforms.dashOffset.value},set(e){this.uniforms.dashOffset.value=e}},dashRatio:{enumerable:!0,get(){return this.uniforms.dashRatio.value},set(e){this.uniforms.dashRatio.value=e}},useDash:{enumerable:!0,get(){return this.uniforms.useDash.value},set(e){this.uniforms.useDash.value=e}},useDepth:{enumerable:!0,get(){return this.uniforms.useDepth.value},set(e){this.uniforms.useDepth.value=e}},visibility:{enumerable:!0,get(){return this.uniforms.visibility.value},set(e){this.uniforms.visibility.value=e}},alphaTest:{enumerable:!0,get(){return this.uniforms.alphaTest.value},set(e){this.uniforms.alphaTest.value=e}},repeat:{enumerable:!0,get(){return this.uniforms.repeat.value},set(e){this.uniforms.repeat.value.copy(e)}},lineLightAnimation:{enumerable:!0,get:function(){return this.uniforms.lineLightAnimation.value},set:function(e){this.uniforms.lineLightAnimation.value=e}},time:{enumerable:!0,get:function(){return this.uniforms.time.value},set:function(e){this.uniforms.time.value=e}},size:{enumerable:!0,get:function(){return this.uniforms.size.value},set:function(e){this.uniforms.size.value=e}},speed:{enumerable:!0,get:function(){return this.uniforms.speed.value},set:function(e){this.uniforms.speed.value=e}},lightWidth:{enumerable:!0,get:function(){return this.uniforms.lightWidth.value},set:function(e){this.uniforms.lightWidth.value=e}},uCenter:{enumerable:!0,get:function(){return this.uniforms.uCenter.value},set:function(e){this.uniforms.uCenter.value=e}},lightColor:{enumerable:!0,get:function(){return this.uniforms.lightColor.value},set:function(e){e&&(this.uniforms.lightColor.value=e)}}}),this.setValues(t)}copy(t){return super.copy(t),this.lineWidth=t.lineWidth,this.map=t.map,this.useMap=t.useMap,this.alphaMap=t.alphaMap,this.useAlphaMap=t.useAlphaMap,this.color.copy(t.color),this.opacity=t.opacity,this.resolution.copy(t.resolution),this.sizeAttenuation=t.sizeAttenuation,this.dashArray=t.dashArray,this.dashOffset=t.dashOffset,this.dashRatio=t.dashRatio,this.useDash=t.useDash,this.visibility=t.visibility,this.alphaTest=t.alphaTest,this.repeat.copy(t.repeat),this}dispose(){super.dispose();const t=a.indexOf(this);t>-1&&a.splice(t,1)}}exports.MeshLineMaterial=x;exports.meshLineMaterialArr=a;