three-base 1.129.15 → 2.0.1

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 (91) hide show
  1. package/README.md +1 -0
  2. package/index.js +1 -37
  3. package/index.ts +1 -61
  4. package/package.json +3 -4
  5. package/lib/ApngTexture.d.ts +0 -13
  6. package/lib/ApngTexture.js +0 -61
  7. package/lib/ApngTexture.ts +0 -91
  8. package/lib/ApngTextureManage.d.ts +0 -18
  9. package/lib/ApngTextureManage.js +0 -87
  10. package/lib/ApngTextureManage.ts +0 -130
  11. package/lib/EventMesh.d.ts +0 -18
  12. package/lib/EventMesh.js +0 -59
  13. package/lib/EventMesh.ts +0 -79
  14. package/lib/ExtrudeMesh.d.ts +0 -111
  15. package/lib/ExtrudeMesh.js +0 -363
  16. package/lib/ExtrudeMesh.ts +0 -571
  17. package/lib/FPScontrol.d.ts +0 -44
  18. package/lib/FPScontrol.js +0 -170
  19. package/lib/FPScontrol.ts +0 -209
  20. package/lib/InstancedGroupMesh.d.ts +0 -10
  21. package/lib/InstancedGroupMesh.js +0 -63
  22. package/lib/InstancedGroupMesh.ts +0 -80
  23. package/lib/KeyFrameAnimation.d.ts +0 -25
  24. package/lib/KeyFrameAnimation.js +0 -78
  25. package/lib/KeyFrameAnimation.ts +0 -122
  26. package/lib/PlaneText.d.ts +0 -37
  27. package/lib/PlaneText.js +0 -30
  28. package/lib/PlaneText.ts +0 -58
  29. package/lib/PlaneWithHtml.d.ts +0 -11
  30. package/lib/PlaneWithHtml.js +0 -67
  31. package/lib/PlaneWithHtml.ts +0 -84
  32. package/lib/PointLight/PointLight.d.ts +0 -13
  33. package/lib/PointLight/PointLight.js +0 -63
  34. package/lib/PointLight/PointLight.ts +0 -74
  35. package/lib/PointLight/pointLight_map.png +0 -0
  36. package/lib/Sky/Sky.d.ts +0 -13
  37. package/lib/Sky/Sky.js +0 -28
  38. package/lib/Sky/Sky.ts +0 -36
  39. package/lib/Sky/bluesky.jpg +0 -0
  40. package/lib/SpriteText.d.ts +0 -45
  41. package/lib/SpriteText.js +0 -162
  42. package/lib/SpriteText.ts +0 -189
  43. package/lib/SpriteText2.d.ts +0 -47
  44. package/lib/SpriteText2.js +0 -197
  45. package/lib/SpriteText2.ts +0 -236
  46. package/lib/Text3D/Text3D.d.ts +0 -20
  47. package/lib/Text3D/Text3D.js +0 -61
  48. package/lib/Text3D/Text3D.ts +0 -92
  49. package/lib/Text3D/fontController.d.ts +0 -59
  50. package/lib/Text3D/fontController.js +0 -200
  51. package/lib/Text3D/fontController.ts +0 -285
  52. package/lib/Text3D/gentilis.json +0 -811
  53. package/lib/ThreeBase.d.ts +0 -59
  54. package/lib/ThreeBase.js +0 -395
  55. package/lib/ThreeBase.ts +0 -475
  56. package/lib/ThreeMouse.d.ts +0 -39
  57. package/lib/ThreeMouse.js +0 -357
  58. package/lib/ThreeMouse.ts +0 -464
  59. package/lib/Transition.d.ts +0 -43
  60. package/lib/Transition.js +0 -196
  61. package/lib/Transition.ts +0 -268
  62. package/lib/index.d.ts +0 -22
  63. package/lib/keyContorls.d.ts +0 -25
  64. package/lib/keyContorls.js +0 -98
  65. package/lib/keyContorls.ts +0 -127
  66. package/lib/planeModal1/PlaneModal1.d.ts +0 -31
  67. package/lib/planeModal1/PlaneModal1.js +0 -104
  68. package/lib/planeModal1/PlaneModal1.ts +0 -150
  69. package/lib/planeModal1/planeModal.png +0 -0
  70. package/lib/shaders.d.ts +0 -17
  71. package/lib/shaders.js +0 -245
  72. package/lib/shaders.ts +0 -264
  73. package/lib/spriteModal1/SpriteModal1.d.ts +0 -30
  74. package/lib/spriteModal1/SpriteModal1.js +0 -109
  75. package/lib/spriteModal1/SpriteModal1.ts +0 -159
  76. package/lib/spriteModal1/spriteModal1.png +0 -0
  77. package/lib/stroke_pass/FullScreenQuad.d.ts +0 -7
  78. package/lib/stroke_pass/FullScreenQuad.js +0 -25
  79. package/lib/stroke_pass/FullScreenQuad.ts +0 -33
  80. package/lib/stroke_pass/stroke_pass.d.ts +0 -2
  81. package/lib/stroke_pass/stroke_pass.js +0 -190
  82. package/lib/stroke_pass/stroke_pass.ts +0 -211
  83. package/lib/threeLoader.d.ts +0 -20
  84. package/lib/threeLoader.js +0 -110
  85. package/lib/threeLoader.ts +0 -136
  86. package/lib/threeUtils.d.ts +0 -41
  87. package/lib/threeUtils.js +0 -179
  88. package/lib/threeUtils.ts +0 -212
  89. package/lib/type.d.ts +0 -0
  90. package/lib/type.js +0 -10
  91. package/lib/type.ts +0 -13
package/lib/ThreeMouse.js DELETED
@@ -1,357 +0,0 @@
1
- //
2
- //
3
- //
4
- //
5
- //
6
- // 启动鼠标事件
7
- import * as THREE from "three";
8
- import { Raycaster } from "three";
9
- import { debounce } from "lodash";
10
- /**
11
- * harp.gl 专用的鼠标拾取模型对象
12
- */
13
- export default class ThreeMouse {
14
- constructor(renderer, camera, scene) {
15
- this._renderer = renderer;
16
- this._camera = camera;
17
- this._scene = scene;
18
- this._frame = this._renderer.info.render.frame;
19
- this._renderer.domElement.addEventListener("mouseenter", () => { this._mouseInRenderer = true; }, true); //鼠标进入开启拾取
20
- this._renderer.domElement.addEventListener("mouseleave", this._mouseleave, true); //鼠标离开停止拾取
21
- this._renderer.domElement.addEventListener("mousemove", this._mousemove, true); //鼠标移动监听事件
22
- this._renderer.domElement.addEventListener("pointerdown", this._mousedown, true); //鼠标按下监听事件
23
- this._renderer.domElement.addEventListener("pointerup", this._mouseup, true); //鼠标弹起监听事件
24
- }
25
- // 渲染器
26
- _renderer;
27
- _camera;
28
- _scene;
29
- // 鼠标在渲染器上面的位置
30
- _mosePosition = new THREE.Vector2(0, 0);
31
- // 鼠标按下的位置 如果和鼠标弹起的位置相同 才算一次有效的点击事件
32
- _mouseDownPosition = new THREE.Vector2(0, 0);
33
- //当前鼠标指针上的对象
34
- _mesh_on;
35
- //鼠标按下的对象
36
- _mesh_Down;
37
- //射线拾取器
38
- _raycaster = new Raycaster();
39
- // 当前渲染的帧数 ( 鼠标滑动事件 一帧只需要执行费一次即可 )
40
- _frame = 0;
41
- //鼠标是否在渲染器上
42
- _mouseInRenderer = false;
43
- // 鼠标滑动的事件
44
- _mousemoveEvent;
45
- // 需要被拾取的对象数组
46
- _object3ds = [];
47
- // 点击次数
48
- _click_num = 0;
49
- // 获取拾取到的对象
50
- _getSelected(object3ds) {
51
- let intersection;
52
- if (object3ds.length) {
53
- intersection = this._raycaster.intersectObjects(object3ds, false)[0];
54
- }
55
- return intersection;
56
- }
57
- ;
58
- // 判断对象上面是否有事件
59
- hasEvent(object, types = []) {
60
- if (!object) {
61
- return false;
62
- }
63
- // 如果 启用事件为关闭的话就不执行事件
64
- if (object["userData"] && object["userData"]["enableEvent"] === false) {
65
- return false;
66
- }
67
- const hasevent = types.some(type => {
68
- //@ts-ignore
69
- if (object["_listeners"] && object["_listeners"][type] && object["_listeners"][type][0]) {
70
- return true;
71
- }
72
- // if (object["userData"] && object["userData"]["cursor"]) {
73
- // return true;
74
- // }
75
- return false;
76
- });
77
- return hasevent;
78
- }
79
- // 判断对象上是否有鼠标样式
80
- hasCursor(object) {
81
- if (!object) {
82
- return false;
83
- }
84
- // 如果 启用事件为关闭的话就不执行事件
85
- if (object["userData"] && object["userData"]["enableEvent"] === false) {
86
- return false;
87
- }
88
- if (object["userData"] && object["userData"]["cursor"]) {
89
- return true;
90
- }
91
- }
92
- // 分发鼠标拾取事件
93
- dispatchEvent() {
94
- // 提取有事件的对象
95
- const meshs = [];
96
- this._scene.traverseVisible(mesh => {
97
- // 判断对象是否有指定的事件
98
- if (this.hasCursor(mesh) || this.hasEvent(mesh, ["leftclick", "rightclick", "click", "dbclick", "mouseenter", "mouseleave", "mousemove", "mousedown", "mouseup"])) {
99
- meshs.push(mesh);
100
- }
101
- });
102
- this._object3ds = meshs;
103
- // 没有鼠标事件就不往下执行了
104
- if (!this._mousemoveEvent || !this._mouseInRenderer) {
105
- return;
106
- }
107
- // 拾取模型
108
- let intersection = this._getSelected(meshs);
109
- if (intersection) {
110
- const MouseEvent = Object.assign(intersection, {
111
- renderer: this._renderer,
112
- camera: this._camera,
113
- object: intersection.object,
114
- type: this._mousemoveEvent.type,
115
- offsetX: this._mousemoveEvent.offsetX,
116
- offsetY: this._mousemoveEvent.offsetY,
117
- x: this._mousemoveEvent.x,
118
- y: this._mousemoveEvent.y
119
- });
120
- // 触发滑动事件
121
- if (this._mesh_on === MouseEvent.object) {
122
- if (this.hasEvent(MouseEvent.object, ["mousemove"])) {
123
- MouseEvent.type = "mousemove";
124
- MouseEvent.object.dispatchEvent(MouseEvent);
125
- }
126
- // 鼠标划入滑出事件
127
- }
128
- else if (this._mesh_on !== MouseEvent.object) {
129
- if (this.hasEvent(this._mesh_on, ["mouseleave"])) {
130
- MouseEvent.type = "mouseleave";
131
- this._mesh_on.dispatchEvent(MouseEvent);
132
- }
133
- if (this.hasEvent(MouseEvent.object, ["mouseenter"])) {
134
- MouseEvent.type = "mouseenter";
135
- MouseEvent.object.dispatchEvent(MouseEvent);
136
- }
137
- }
138
- this._mesh_on = MouseEvent.object || undefined; // 设置为当前鼠标上的对象
139
- // 鼠标样式
140
- if (this._mesh_on && this._mesh_on.userData && this._mesh_on.userData.cursor) {
141
- this._renderer.domElement.style.cursor = this._mesh_on.userData.cursor;
142
- }
143
- else {
144
- this._renderer.domElement.style.cursor = "auto";
145
- }
146
- }
147
- else {
148
- if (this.hasEvent(this._mesh_on, ["mouseleave"])) {
149
- // 鼠标离开事件
150
- this._mesh_on.dispatchEvent({
151
- renderer: this._renderer,
152
- camera: this._camera,
153
- object: this._mesh_on,
154
- type: "mouseleave",
155
- offsetX: this._mousemoveEvent.offsetX,
156
- offsetY: this._mousemoveEvent.offsetY,
157
- x: this._mousemoveEvent.x,
158
- y: this._mousemoveEvent.y
159
- });
160
- }
161
- // 置空当前鼠标上面的对象
162
- this._mesh_on = undefined;
163
- this._renderer.domElement.style.cursor = "auto"; // 鼠标样式
164
- }
165
- }
166
- // 鼠标离开事件
167
- _mouseleave = (e) => {
168
- this._mouseInRenderer = false;
169
- // 鼠标离开事件
170
- if (this._mousemoveEvent && this.hasEvent(this._mesh_on, ["mouseleave"])) {
171
- this._mesh_on.dispatchEvent({
172
- renderer: this._renderer,
173
- camera: this._camera,
174
- object: this._mesh_on,
175
- type: "mouseleave",
176
- offsetX: this._mousemoveEvent.offsetX,
177
- offsetY: this._mousemoveEvent.offsetY,
178
- x: this._mousemoveEvent.x,
179
- y: this._mousemoveEvent.y
180
- });
181
- }
182
- // 置空当前鼠标上面的对象
183
- this._mesh_on = undefined;
184
- this._renderer.domElement.style.cursor = "auto"; // 鼠标样式
185
- };
186
- // 鼠标滑动 设置鼠标位置
187
- _mousemove = (e) => {
188
- this._mousemoveEvent = e;
189
- this._frame = this._renderer.info.render.frame;
190
- if (document.pointerLockElement) { // 如果当前有元素 锁住了鼠标
191
- this._mosePosition.set(0, 0); // 鼠标就指向canvas 的正中心
192
- }
193
- else {
194
- this._mosePosition.x = (e.offsetX / this._renderer.domElement.offsetWidth) * 2 - 1;
195
- this._mosePosition.y = -(e.offsetY / this._renderer.domElement.offsetHeight) * 2 + 1;
196
- }
197
- this._raycaster.setFromCamera(this._mosePosition, this._camera); // 设置射线拾取的参数
198
- };
199
- // 鼠标按下事件
200
- _mousedown = (e) => {
201
- // 记录按下的位置
202
- this._mouseDownPosition.set(e.offsetX, e.offsetY);
203
- this._mousemove(e);
204
- let intersection = this._getSelected(this._object3ds);
205
- if (!intersection || !this._mousemoveEvent) {
206
- return;
207
- }
208
- this._mesh_Down = this._mesh_on = intersection.object;
209
- // 触发鼠标按下事件
210
- if (this.hasEvent(this._mesh_Down, ["mousedown"])) {
211
- this._mesh_Down.dispatchEvent({
212
- ...intersection,
213
- renderer: this._renderer,
214
- camera: this._camera,
215
- object: intersection.object,
216
- type: "mousedown",
217
- offsetX: this._mousemoveEvent.offsetX,
218
- offsetY: this._mousemoveEvent.offsetY,
219
- x: this._mousemoveEvent.x,
220
- y: this._mousemoveEvent.y
221
- });
222
- }
223
- };
224
- // 鼠标弹起事件
225
- _mouseup = debounce(async (e) => {
226
- // 提取有事件的对象
227
- const meshs = [];
228
- let intersection = this._getSelected(this._object3ds);
229
- if (!intersection || !this._mousemoveEvent) {
230
- return;
231
- }
232
- this._mesh_on = intersection.object;
233
- if (this.hasEvent(this._mesh_Down, ["mouseup"])) {
234
- this._mesh_on.dispatchEvent({
235
- ...intersection,
236
- renderer: this._renderer,
237
- camera: this._camera,
238
- object: intersection.object,
239
- type: "mouseup",
240
- offsetX: this._mousemoveEvent.offsetX,
241
- offsetY: this._mousemoveEvent.offsetY,
242
- x: this._mousemoveEvent.x,
243
- y: this._mousemoveEvent.y
244
- });
245
- }
246
- // 触发鼠标弹起事件
247
- if (this._mesh_Down &&
248
- this._mesh_Down === this._mesh_on &&
249
- Math.abs(this._mouseDownPosition.x - e.offsetX) < 5 &&
250
- Math.abs(this._mouseDownPosition.y - e.offsetY) < 5) {
251
- // 是否有双击事件
252
- if (this.hasEvent(this._mesh_Down, ["dbclick"])) {
253
- this._click_num++;
254
- await new Promise(resolve => setTimeout(resolve, 200));
255
- // 只点击了一次
256
- if (this._click_num === 1) {
257
- if (this.hasEvent(this._mesh_Down, ["click"])) {
258
- this._mesh_Down.dispatchEvent({
259
- ...intersection,
260
- renderer: this._renderer,
261
- camera: this._camera,
262
- object: intersection.object,
263
- type: "click",
264
- offsetX: this._mousemoveEvent.offsetX,
265
- offsetY: this._mousemoveEvent.offsetY,
266
- x: this._mousemoveEvent.x,
267
- y: this._mousemoveEvent.y
268
- });
269
- }
270
- if (this.hasEvent(this._mesh_Down, ["leftclick"]) && (e.button === 0)) {
271
- this._mesh_Down.dispatchEvent({
272
- ...intersection,
273
- renderer: this._renderer,
274
- camera: this._camera,
275
- object: intersection.object,
276
- type: "leftclick",
277
- offsetX: this._mousemoveEvent.offsetX,
278
- offsetY: this._mousemoveEvent.offsetY,
279
- x: this._mousemoveEvent.x,
280
- y: this._mousemoveEvent.y
281
- });
282
- }
283
- if (this.hasEvent(this._mesh_Down, ["rightclick"]) && (e.button === 2)) {
284
- this._mesh_Down.dispatchEvent({
285
- ...intersection,
286
- renderer: this._renderer,
287
- camera: this._camera,
288
- object: intersection.object,
289
- type: "rightclick",
290
- offsetX: this._mousemoveEvent.offsetX,
291
- offsetY: this._mousemoveEvent.offsetY,
292
- x: this._mousemoveEvent.x,
293
- y: this._mousemoveEvent.y
294
- });
295
- }
296
- }
297
- else if (this._click_num > 1) {
298
- if (this.hasEvent(this._mesh_Down, ["dbclick"]) && (new Date().valueOf() - this._click_num > 1) && (e.button === 0)) {
299
- this._mesh_Down.dispatchEvent({
300
- ...intersection,
301
- renderer: this._renderer,
302
- camera: this._camera,
303
- object: intersection.object,
304
- type: "dbclick",
305
- offsetX: this._mousemoveEvent.offsetX,
306
- offsetY: this._mousemoveEvent.offsetY,
307
- x: this._mousemoveEvent.x,
308
- y: this._mousemoveEvent.y
309
- });
310
- }
311
- }
312
- }
313
- else {
314
- if (this.hasEvent(this._mesh_Down, ["click"])) {
315
- this._mesh_Down.dispatchEvent({
316
- ...intersection,
317
- renderer: this._renderer,
318
- camera: this._camera,
319
- object: intersection.object,
320
- type: "click",
321
- offsetX: this._mousemoveEvent.offsetX,
322
- offsetY: this._mousemoveEvent.offsetY,
323
- x: this._mousemoveEvent.x,
324
- y: this._mousemoveEvent.y
325
- });
326
- }
327
- if (this.hasEvent(this._mesh_Down, ["leftclick"]) && (e.button === 0)) {
328
- this._mesh_Down.dispatchEvent({
329
- ...intersection,
330
- renderer: this._renderer,
331
- camera: this._camera,
332
- object: intersection.object,
333
- type: "leftclick",
334
- offsetX: this._mousemoveEvent.offsetX,
335
- offsetY: this._mousemoveEvent.offsetY,
336
- x: this._mousemoveEvent.x,
337
- y: this._mousemoveEvent.y
338
- });
339
- }
340
- if (this.hasEvent(this._mesh_Down, ["rightclick"]) && (e.button === 2)) {
341
- this._mesh_Down.dispatchEvent({
342
- ...intersection,
343
- renderer: this._renderer,
344
- camera: this._camera,
345
- object: intersection.object,
346
- type: "rightclick",
347
- offsetX: this._mousemoveEvent.offsetX,
348
- offsetY: this._mousemoveEvent.offsetY,
349
- x: this._mousemoveEvent.x,
350
- y: this._mousemoveEvent.y
351
- });
352
- }
353
- }
354
- this._click_num = 0;
355
- }
356
- });
357
- }