@xort/cga 0.0.83 → 0.0.84

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 (65) hide show
  1. package/build/@xort_cga.js +639 -314
  2. package/deploy.sh +13 -1
  3. package/dist/IKanimation/Bone.d.ts +1 -3
  4. package/dist/IKanimation/Bone.js +4 -22
  5. package/dist/alg/extrude.js +4 -4
  6. package/dist/extends/geometryaid.js +7 -15
  7. package/dist/index.d.ts +1 -2
  8. package/dist/index.js +1 -2
  9. package/dist/math/Color.d.ts +1 -2
  10. package/dist/math/Color.js +14 -31
  11. package/dist/math/Euler.d.ts +4 -5
  12. package/dist/math/Euler.js +16 -34
  13. package/dist/math/HVec3.d.ts +1 -2
  14. package/dist/math/HVec3.js +13 -30
  15. package/dist/math/Quat.d.ts +1 -2
  16. package/dist/math/Quat.js +23 -43
  17. package/dist/math/Vec2.d.ts +4 -4
  18. package/dist/math/Vec2.js +7 -24
  19. package/dist/math/Vec3.d.ts +5 -9
  20. package/dist/math/Vec3.js +35 -52
  21. package/dist/math/Vec4.d.ts +4 -4
  22. package/dist/math/Vec4.js +11 -28
  23. package/dist/math/vecs.d.ts +19 -6
  24. package/dist/math/vecs.js +31 -1
  25. package/dist/render/{buffer-attribute.d.ts → bufferAttribute.d.ts} +8 -4
  26. package/dist/render/{buffer-attribute.js → bufferAttribute.js} +4 -0
  27. package/dist/render/geometry.d.ts +7 -9
  28. package/dist/render/geometry.js +22 -25
  29. package/dist/render/mesh.d.ts +23 -18
  30. package/dist/render/mesh.js +62 -57
  31. package/dist/render/types.d.ts +1 -0
  32. package/dist/struct/3d/Box.d.ts +1 -1
  33. package/dist/struct/3d/Plane.js +1 -1
  34. package/package.json +73 -73
  35. package/rollup.config.js +1 -1
  36. package/src/IKanimation/Bone.ts +1 -5
  37. package/src/alg/extrude.ts +6 -6
  38. package/src/app.ts +2 -10
  39. package/src/extends/geometryaid.ts +10 -13
  40. package/src/index.ts +2 -4
  41. package/src/math/Color.ts +6 -8
  42. package/src/math/Euler.ts +11 -12
  43. package/src/math/HVec3.ts +3 -5
  44. package/src/math/Quat.ts +18 -23
  45. package/src/math/Vec2.ts +7 -7
  46. package/src/math/Vec3.ts +37 -36
  47. package/src/math/Vec4.ts +9 -9
  48. package/src/math/vecs.ts +50 -8
  49. package/src/render/{buffer-attribute.ts → bufferAttribute.ts} +11 -4
  50. package/src/render/geometry.ts +18 -15
  51. package/src/render/mesh.ts +56 -54
  52. package/src/render/types.ts +2 -0
  53. package/src/struct/3d/Box.ts +1 -1
  54. package/src/struct/3d/Plane.ts +2 -4
  55. package/dist/math/Vec.d.ts +0 -7
  56. package/dist/math/Vec.js +0 -41
  57. package/dist/math/vector.d.ts +0 -114
  58. package/dist/math/vector.js +0 -371
  59. package/dist/render/eventhandler.d.ts +0 -78
  60. package/dist/render/eventhandler.js +0 -191
  61. package/dist/render/thing.d.ts +0 -34
  62. package/dist/render/thing.js +0 -194
  63. package/src/math/Vec.ts +0 -26
  64. package/src/render/eventhandler.ts +0 -196
  65. package/src/render/thing.ts +0 -204
package/src/math/Vec2.ts CHANGED
@@ -1,10 +1,10 @@
1
1
  import { Mat3 } from './Mat3';
2
- import { EventHandler } from '../render/eventhandler';
3
- export class Vec2 extends EventHandler {
2
+ import { TypedArrayLike } from '../render/types';
3
+ export class Vec2 {
4
4
  isVec2: boolean = true;
5
5
 
6
6
  constructor(private _x: number = 0, private _y: number = 0) {
7
- super();
7
+
8
8
  }
9
9
 
10
10
  get x() {
@@ -14,7 +14,7 @@ export class Vec2 extends EventHandler {
14
14
  set x(value) {
15
15
  if (this._x !== value) {
16
16
  this._x = value;
17
- this.fire('change', 'x', this._x, value)
17
+ // this.fire('change', 'x', this._x, value)
18
18
  }
19
19
  }
20
20
 
@@ -25,7 +25,7 @@ export class Vec2 extends EventHandler {
25
25
  set y(value) {
26
26
  if (this._y !== value) {
27
27
  this._y = value;
28
- this.fire('change', 'y', this._y, value)
28
+ // this.fire('change', 'y', this._y, value)
29
29
  }
30
30
  }
31
31
 
@@ -361,14 +361,14 @@ export class Vec2 extends EventHandler {
361
361
  return v.x === this._x && v.y === this._y;
362
362
  }
363
363
 
364
- fromArray(array: number[], offset: number = 0) {
364
+ fromArray(array: TypedArrayLike, offset: number = 0) {
365
365
  this._x = array[offset];
366
366
  this._y = array[offset + 1];
367
367
 
368
368
  return this;
369
369
  }
370
370
 
371
- toArray(array: number[] = [], offset: number = 0) {
371
+ toArray(array: TypedArrayLike = [], offset: number = 0) {
372
372
  array[offset] = this._x;
373
373
  array[offset + 1] = this._y;
374
374
 
package/src/math/Vec3.ts CHANGED
@@ -7,14 +7,14 @@ import { DistanceResult } from '../alg/result';
7
7
  import { Line, line } from '../struct/3d/Line';
8
8
  import { Ray } from '../struct/3d/Ray';
9
9
  import { Segment } from '../struct/3d/Segment';
10
- import { Plane } from '../struct/3d/Plane';
11
- import { EventHandler } from '../render/eventhandler';
10
+ import { Plane } from '../struct/3d/Plane';
12
11
  import { Triangle } from '../struct/3d/Triangle';
13
12
  import { Capsule } from '../struct/3d/Capsule';
14
13
  import { Rectangle } from '../struct/3d/Rectangle';
15
14
  import { Circle } from '../struct/3d/Circle';
16
15
  import { Disk } from '../struct/3d/Disk';
17
16
  import { Polyline } from '..';
17
+ import { TypedArrayLike } from '../render/types';
18
18
  // import { wgs84RadiiSquared } from '../gis/gis';
19
19
  export interface IVec2 {
20
20
  x: number;
@@ -27,11 +27,12 @@ export interface IVec4 extends IVec3 {
27
27
  w: number;
28
28
  }
29
29
 
30
- export class Vec3 extends EventHandler implements IVec3 {
30
+ export class Vec3 implements IVec3 {
31
31
 
32
32
  constructor(private _x: number = 0, private _y: number = 0, private _z: number = 0) {
33
- super();
33
+
34
34
  }
35
+
35
36
  get x() {
36
37
  return this._x;
37
38
  }
@@ -39,7 +40,7 @@ export class Vec3 extends EventHandler implements IVec3 {
39
40
  set x(value) {
40
41
  if (this._x !== value) {
41
42
  this._x = value;
42
- this.fire('change', 'x', this._x, value)
43
+ // this.fire('change', 'x', this._x, value)
43
44
  }
44
45
  }
45
46
 
@@ -50,7 +51,7 @@ export class Vec3 extends EventHandler implements IVec3 {
50
51
  set y(value) {
51
52
  if (this._y !== value) {
52
53
  this._y = value;
53
- this.fire('change', 'y', this._y, value)
54
+ // this.fire('change', 'y', this._y, value)
54
55
  }
55
56
  }
56
57
 
@@ -61,7 +62,7 @@ export class Vec3 extends EventHandler implements IVec3 {
61
62
  set z(value) {
62
63
  if (this._z !== value) {
63
64
  this._z = value;
64
- this.fire('change', 'z', this._z, value)
65
+ // this.fire('change', 'z', this._z, value)
65
66
  }
66
67
  }
67
68
 
@@ -97,7 +98,7 @@ export class Vec3 extends EventHandler implements IVec3 {
97
98
  this._x = x;
98
99
  this._y = y;
99
100
  this._z = z;
100
- this.fire('change');
101
+ //// this.fire('change');
101
102
  return this;
102
103
  }
103
104
 
@@ -106,7 +107,7 @@ export class Vec3 extends EventHandler implements IVec3 {
106
107
  this._y = scalar;
107
108
  this._z = scalar;
108
109
 
109
- this.fire('change');
110
+ // this.fire('change');
110
111
  return this;
111
112
  }
112
113
 
@@ -150,7 +151,7 @@ export class Vec3 extends EventHandler implements IVec3 {
150
151
  this._y = v.y;
151
152
  this._z = v.z;
152
153
 
153
- this.fire('change');
154
+ // this.fire('change');
154
155
  return this;
155
156
  }
156
157
 
@@ -166,7 +167,7 @@ export class Vec3 extends EventHandler implements IVec3 {
166
167
  this._y += v.y;
167
168
  this._z += v.z;
168
169
 
169
- this.fire('change');
170
+ // this.fire('change');
170
171
  return this;
171
172
  }
172
173
 
@@ -175,7 +176,7 @@ export class Vec3 extends EventHandler implements IVec3 {
175
176
  this._y += s;
176
177
  this._z += s;
177
178
 
178
- this.fire('change');
179
+ // this.fire('change');
179
180
  return this;
180
181
  }
181
182
 
@@ -184,7 +185,7 @@ export class Vec3 extends EventHandler implements IVec3 {
184
185
  this._y = a.y + b.y;
185
186
  this._z = a.z + b.z;
186
187
 
187
- this.fire('change');
188
+ // this.fire('change');
188
189
  return this;
189
190
  }
190
191
 
@@ -193,7 +194,7 @@ export class Vec3 extends EventHandler implements IVec3 {
193
194
  this._y += v.y * s;
194
195
  this._z += v.z * s;
195
196
 
196
- this.fire('change');
197
+ // this.fire('change');
197
198
  return this;
198
199
  }
199
200
 
@@ -209,7 +210,7 @@ export class Vec3 extends EventHandler implements IVec3 {
209
210
  this._y -= v.y;
210
211
  this._z -= v.z;
211
212
 
212
- this.fire('change');
213
+ // this.fire('change');
213
214
  return this;
214
215
  }
215
216
 
@@ -218,7 +219,7 @@ export class Vec3 extends EventHandler implements IVec3 {
218
219
  this._y -= s;
219
220
  this._z -= s;
220
221
 
221
- this.fire('change');
222
+ // this.fire('change');
222
223
  return this;
223
224
  }
224
225
 
@@ -227,7 +228,7 @@ export class Vec3 extends EventHandler implements IVec3 {
227
228
  this._y = a.y - b.y;
228
229
  this._z = a.z - b.z;
229
230
 
230
- this.fire('change');
231
+ // this.fire('change');
231
232
  return this;
232
233
  }
233
234
 
@@ -240,7 +241,7 @@ export class Vec3 extends EventHandler implements IVec3 {
240
241
  this._y *= v.y;
241
242
  this._z *= v.z;
242
243
 
243
- this.fire('change');
244
+ // this.fire('change');
244
245
  return this;
245
246
  }
246
247
 
@@ -249,7 +250,7 @@ export class Vec3 extends EventHandler implements IVec3 {
249
250
  this._y *= scalar;
250
251
  this._z *= scalar;
251
252
 
252
- this.fire('change');
253
+ // this.fire('change');
253
254
  return this;
254
255
  }
255
256
 
@@ -258,7 +259,7 @@ export class Vec3 extends EventHandler implements IVec3 {
258
259
  this._y = a.y * b.y;
259
260
  this._z = a.z * b.z;
260
261
 
261
- this.fire('change');
262
+ // this.fire('change');
262
263
  return this;
263
264
  }
264
265
 
@@ -290,7 +291,7 @@ export class Vec3 extends EventHandler implements IVec3 {
290
291
  this._y = e[1] * x + e[4] * y + e[7] * z;
291
292
  this._z = e[2] * x + e[5] * y + e[8] * z;
292
293
 
293
- this.fire('change');
294
+ // this.fire('change');
294
295
  return this;
295
296
  }
296
297
 
@@ -306,11 +307,11 @@ export class Vec3 extends EventHandler implements IVec3 {
306
307
  this._y = (e[1] * x + e[5] * y + e[9] * z + e[13]) * w;
307
308
  this._z = (e[2] * x + e[6] * y + e[10] * z + e[14]) * w;
308
309
 
309
- this.fire('change');
310
+ // this.fire('change');
310
311
  return this;
311
312
  }
312
313
 
313
- applyQuat(q: { x: any; y: any; z: any; w: any; }) {
314
+ applyQuat(q: Quat) {
314
315
  var x = this._x,
315
316
  y = this._y,
316
317
  z = this._z;
@@ -332,7 +333,7 @@ export class Vec3 extends EventHandler implements IVec3 {
332
333
  this._y = iy * qw + iw * -qy + iz * -qx - ix * -qz;
333
334
  this._z = iz * qw + iw * -qz + ix * -qy - iy * -qx;
334
335
 
335
- this.fire('change');
336
+ // this.fire('change');
336
337
  return this;
337
338
  }
338
339
 
@@ -361,7 +362,7 @@ export class Vec3 extends EventHandler implements IVec3 {
361
362
  this._y = e[1] * x + e[5] * y + e[9] * z;
362
363
  this._z = e[2] * x + e[6] * y + e[10] * z;
363
364
 
364
- this.fire('change');
365
+ // this.fire('change');
365
366
  return this.normalize();
366
367
  }
367
368
 
@@ -370,7 +371,7 @@ export class Vec3 extends EventHandler implements IVec3 {
370
371
  this._y /= v.y;
371
372
  this._z /= v.z;
372
373
 
373
- this.fire('change');
374
+ // this.fire('change');
374
375
  return this;
375
376
  }
376
377
 
@@ -383,7 +384,7 @@ export class Vec3 extends EventHandler implements IVec3 {
383
384
  this._y = Math.min(this._y, v.y);
384
385
  this._z = Math.min(this._z, v.z);
385
386
 
386
- this.fire('change');
387
+ // this.fire('change');
387
388
  return this;
388
389
  }
389
390
 
@@ -392,7 +393,7 @@ export class Vec3 extends EventHandler implements IVec3 {
392
393
  this._y = Math.max(this._y, v.y);
393
394
  this._z = Math.max(this._z, v.z);
394
395
 
395
- this.fire('change');
396
+ // this.fire('change');
396
397
  return this;
397
398
  }
398
399
 
@@ -403,7 +404,7 @@ export class Vec3 extends EventHandler implements IVec3 {
403
404
  this._y = Math.max(min.y, Math.min(max.y, this._y));
404
405
  this._z = Math.max(min.z, Math.min(max.z, this._z));
405
406
 
406
- this.fire('change');
407
+ // this.fire('change');
407
408
  return this;
408
409
  }
409
410
 
@@ -412,7 +413,7 @@ export class Vec3 extends EventHandler implements IVec3 {
412
413
  this._y = Math.max(minVal, Math.min(maxVal, this._y));
413
414
  this._z = Math.max(minVal, Math.min(maxVal, this._z));
414
415
 
415
- this.fire('change');
416
+ // this.fire('change');
416
417
  return this;
417
418
  }
418
419
 
@@ -429,7 +430,7 @@ export class Vec3 extends EventHandler implements IVec3 {
429
430
  this._y = Math.floor(this._y);
430
431
  this._z = Math.floor(this._z);
431
432
 
432
- this.fire('change');
433
+ // this.fire('change');
433
434
  return this;
434
435
  }
435
436
 
@@ -438,7 +439,7 @@ export class Vec3 extends EventHandler implements IVec3 {
438
439
  this._y = Math.ceil(this._y);
439
440
  this._z = Math.ceil(this._z);
440
441
 
441
- this.fire('change');
442
+ // this.fire('change');
442
443
  return this;
443
444
  }
444
445
 
@@ -447,7 +448,7 @@ export class Vec3 extends EventHandler implements IVec3 {
447
448
  this._y = Math.round(this._y);
448
449
  this._z = Math.round(this._z);
449
450
 
450
- this.fire('change');
451
+ // this.fire('change');
451
452
  return this;
452
453
  }
453
454
 
@@ -456,7 +457,7 @@ export class Vec3 extends EventHandler implements IVec3 {
456
457
  this._y = this._y < 0 ? Math.ceil(this._y) : Math.floor(this._y);
457
458
  this._z = this._z < 0 ? Math.ceil(this._z) : Math.floor(this._z);
458
459
 
459
- this.fire('change');
460
+ // this.fire('change');
460
461
  return this;
461
462
  }
462
463
 
@@ -465,7 +466,7 @@ export class Vec3 extends EventHandler implements IVec3 {
465
466
  this._y = -this._y;
466
467
  this._z = -this._z;
467
468
 
468
- this.fire('change');
469
+ // this.fire('change');
469
470
  return this;
470
471
  }
471
472
 
@@ -771,7 +772,7 @@ export class Vec3 extends EventHandler implements IVec3 {
771
772
  return this;
772
773
  }
773
774
 
774
- toArray(array: number[] = [], offset: number = 0) {
775
+ toArray(array: TypedArrayLike = [], offset: number = 0) {
775
776
 
776
777
  array[offset] = this._x;
777
778
  array[offset + 1] = this._y;
package/src/math/Vec4.ts CHANGED
@@ -1,10 +1,10 @@
1
- import { EventHandler } from '../render/eventhandler';
1
+ import { TypedArrayLike } from '../render/types';
2
2
 
3
- export class Vec4 extends EventHandler {
3
+ export class Vec4 {
4
4
  isVec4: boolean = true;
5
5
 
6
6
  constructor(private _x: number = 0, private _y: number = 0, private _z: number = 0, private _w: number = 1) {
7
- super();
7
+
8
8
  }
9
9
 
10
10
 
@@ -15,7 +15,7 @@ export class Vec4 extends EventHandler {
15
15
  set x(value) {
16
16
  if (this._x !== value) {
17
17
  this._x = value;
18
- this.fire('change', 'x', this._x, value)
18
+ // this.fire('change', 'x', this._x, value)
19
19
  }
20
20
  }
21
21
 
@@ -26,7 +26,7 @@ export class Vec4 extends EventHandler {
26
26
  set y(value) {
27
27
  if (this._y !== value) {
28
28
  this._y = value;
29
- this.fire('change', 'y', this._y, value)
29
+ // this.fire('change', 'y', this._y, value)
30
30
  }
31
31
  }
32
32
 
@@ -37,7 +37,7 @@ export class Vec4 extends EventHandler {
37
37
  set z(value) {
38
38
  if (this._z !== value) {
39
39
  this._z = value;
40
- this.fire('change', 'z', this._z, value)
40
+ // this.fire('change', 'z', this._z, value)
41
41
  }
42
42
  }
43
43
 
@@ -48,7 +48,7 @@ export class Vec4 extends EventHandler {
48
48
  set w(value) {
49
49
  if (this._w !== value) {
50
50
  this._w = value;
51
- this.fire('change', 'w', this._w, value)
51
+ // this.fire('change', 'w', this._w, value)
52
52
  }
53
53
  }
54
54
 
@@ -546,7 +546,7 @@ export class Vec4 extends EventHandler {
546
546
  return v.x === this._x && v.y === this._y && v.z === this._z && v.w === this._w;
547
547
  }
548
548
 
549
- fromArray(array: number[], offset: number = 0) {
549
+ fromArray(array: TypedArrayLike, offset: number = 0) {
550
550
  this._x = array[offset];
551
551
  this._y = array[offset + 1];
552
552
  this._z = array[offset + 2];
@@ -555,7 +555,7 @@ export class Vec4 extends EventHandler {
555
555
  return this;
556
556
  }
557
557
 
558
- toArray(array: number[] = [], offset: number = 0) {
558
+ toArray(array: TypedArrayLike = [], offset: number = 0) {
559
559
 
560
560
  array[offset] = this._x;
561
561
  array[offset + 1] = this._y;
package/src/math/vecs.ts CHANGED
@@ -15,8 +15,9 @@ import { Vec3 } from './Vec3';
15
15
  import { ArrayList } from '../struct/data/ArrayList';
16
16
  import { Vec4 } from './Vec4';
17
17
  import { delta4 } from './Math';
18
- import { Mat4 } from "./Mat4";
18
+ import { Mat4 } from "./Mat4";
19
19
  import { Quat } from "./Quat";
20
+ import { TypedArrayLike } from "../render/types";
20
21
 
21
22
 
22
23
 
@@ -48,6 +49,47 @@ export class vecs {
48
49
 
49
50
  return vs;
50
51
  }
52
+
53
+ /**
54
+ * 找到最大值
55
+ * @param array
56
+ * @returns
57
+ */
58
+ static max(array: ArrayLike<number>) {
59
+
60
+ if (array.length === 0) return - Infinity;
61
+
62
+ var max = array[0];
63
+
64
+ for (var i = 1, l = array.length; i < l; ++i) {
65
+
66
+ if (array[i] > max) max = array[i];
67
+
68
+ }
69
+
70
+ return max;
71
+ }
72
+
73
+ /**
74
+ * 找到最小值
75
+ * @param array
76
+ * @returns
77
+ */
78
+ static min(array: ArrayLike<number>) {
79
+
80
+ if (array.length === 0) return - Infinity;
81
+
82
+ var min = array[0];
83
+
84
+ for (var i = 1, l = array.length; i < l; ++i) {
85
+
86
+ if (array[i] < min) min = array[i];
87
+
88
+ }
89
+
90
+ return min;
91
+ }
92
+
51
93
  /**
52
94
  * 去除相邻没有重复点
53
95
  */
@@ -369,19 +411,19 @@ export class vecs {
369
411
  * @param component 矢量维度,默认为3
370
412
  * @returns
371
413
  */
372
- static numbersToVecs(vss: number[], component: number = 3): Vec2[] | Vec3[] | Vec4[] {
414
+ static numbersToVecs(vss: TypedArrayLike, component: number = 3): Vec2[] | Vec3[] | Vec4[] {
373
415
  const result: any = []
374
416
 
375
417
  for (let i = 0, length = vss.length; i < length; i += component) {
376
418
  const vec = vecs.vec(component);
377
- vec.fromArray(vss.slice(i, i + component));
419
+ vec.fromArray(vss, i);
378
420
  result.push(vec);
379
421
  }
380
422
 
381
423
  return result;
382
424
  }
383
425
 
384
- static applyQuat(vss: number[], quat: Quat, component: number = 3) {
426
+ static applyQuat(vss: TypedArrayLike, quat: Quat, component: number = 3) {
385
427
  let vec;
386
428
  if (component === 3)
387
429
  vec = _vec31;
@@ -397,7 +439,7 @@ export class vecs {
397
439
  }
398
440
  }
399
441
 
400
- static applyMat4(vss: number[], mat: Mat4, component: number = 3) {
442
+ static applyMat4(vss: TypedArrayLike, mat: Mat4, component: number = 3) {
401
443
  let vec;
402
444
  if (component === 3)
403
445
  vec = _vec31;
@@ -413,7 +455,7 @@ export class vecs {
413
455
  }
414
456
  }
415
457
 
416
- static translate(vss: number[], distance: number[], component = 3) {
458
+ static translate(vss: TypedArrayLike, distance: number[], component = 3) {
417
459
  for (let i = 0; i < vss.length; i += component) {
418
460
  for (let j = 0; j < component; j++) {
419
461
  vss[i + j] += distance[j];
@@ -421,12 +463,12 @@ export class vecs {
421
463
  }
422
464
  }
423
465
 
424
- static rotate(vss: number[], axis: Vec3, angle: number) {
466
+ static rotate(vss: TypedArrayLike, axis: Vec3, angle: number) {
425
467
  vecs.applyQuat(vss, new Quat().setFromAxisAngle(axis, angle))
426
468
  }
427
469
 
428
470
 
429
- static scale(vss: number[], _scale: number[], component = 3) {
471
+ static scale(vss: TypedArrayLike, _scale: number[], component = 3) {
430
472
  for (let i = 0; i < vss.length; i += component) {
431
473
  for (let j = 0; j < component; j++) {
432
474
  vss[i + j] *= _scale[j];
@@ -1,4 +1,3 @@
1
-
2
1
  import { Mat3 } from "../math/Mat3";
3
2
  import { Mat4 } from "../math/Mat4";
4
3
  import { Vec2 } from "../math/Vec2";
@@ -9,16 +8,23 @@ import { TypedArray } from "./types";
9
8
 
10
9
  var _vector = new Vec3();
11
10
 
11
+ /**
12
+ * 几何体buffer属性
13
+ * 记录每个几何数据属性的细节
14
+ */
12
15
  export class BufferAttribute {
13
16
  name: string;
14
- array: TypedArray;
17
+
15
18
  itemSize: number;
16
- // usage: Usage;
17
- updateRange: { offset: number; count: number };
19
+ array: TypedArray;
20
+
18
21
  version: number;
19
22
  normalized: boolean;
23
+
20
24
  count: number;
21
25
 
26
+ updateRange: { offset: number; count: number };
27
+
22
28
  readonly isBufferAttribute: true = true;
23
29
  /**
24
30
  *
@@ -52,6 +58,7 @@ export class BufferAttribute {
52
58
 
53
59
  return this;
54
60
  }
61
+
55
62
  setUsage(usage: any): this {
56
63
  return this
57
64
  }
@@ -1,10 +1,9 @@
1
- import { Vec } from "../math/Vec";
2
- import { Mat3 } from "../math/Mat3";
1
+ import { Mat3 } from "../math/Mat3";
3
2
  import { Mat4 } from "../math/Mat4";
4
3
  import { v3, Vec3 } from "../math/Vec3";
5
4
  import { Box } from "../struct/3d/Box";
6
5
  import { Sphere } from "../struct/3d/Sphere";
7
- import { BufferAttribute, Float32BufferAttribute, Uint16BufferAttribute, Uint32BufferAttribute } from "./buffer-attribute";
6
+ import { BufferAttribute, Float32BufferAttribute, Uint16BufferAttribute, Uint32BufferAttribute } from "./bufferAttribute";
8
7
  import { isBufferArray, TypedArray } from "./types";
9
8
  import { Vec2 } from "../math/Vec2";
10
9
  import { Vec4 } from "../math/Vec4";
@@ -43,21 +42,25 @@ var _vector = new Vec3();
43
42
  */
44
43
  export class BufferGeometry {
45
44
  name: string;
46
- index: BufferAttribute | undefined;
45
+
46
+ boundingBox: Box | undefined;
47
+ boundingSphere: Sphere | undefined;
48
+
47
49
  morphAttributes: any;
48
50
  morphTargetsRelative: boolean;
51
+
52
+ index: BufferAttribute | undefined;
53
+ attributes: { [key: string]: BufferAttribute };
49
54
  groups: { start: number; count: number; materialIndex?: number }[];
50
- boundingBox: Box | undefined;
51
- boundingSphere: Sphere | undefined;
52
55
  drawRange: { start: number; count: number; };
53
- attributes: { [key: string]: BufferAttribute };
54
- parameters: any;
56
+
57
+ parameters: any;
58
+
55
59
  readonly isBufferGeometry: true = true;
56
- uuid: string = "";
57
- type: string = "BufferGeometry";
60
+
58
61
  constructor() {
59
62
 
60
- Object.defineProperty(this, 'id', { value: _bufferGeometryId += 2 });
63
+ Object.defineProperty(this, 'id', { value: _bufferGeometryId += 1 });
61
64
 
62
65
  this.name = '';
63
66
 
@@ -94,11 +97,11 @@ export class BufferGeometry {
94
97
 
95
98
  setIndex(index: BufferAttribute | TypedArray | number[]) {
96
99
  if (Array.isArray(index)) {
97
- this.index = new (Vec.max(index as any) > 65535 ? Uint32BufferAttribute : Uint16BufferAttribute)(index, 1);
100
+ this.index = new (vecs.max(index as any) > 65535 ? Uint32BufferAttribute : Uint16BufferAttribute)(index, 1);
98
101
  } else if (index instanceof BufferAttribute) {
99
102
  this.index = index;
100
103
  } else {
101
- this.index = new (Vec.max(index as any) > 65535 ? Uint32BufferAttribute : Uint16BufferAttribute)(index, 1)
104
+ this.index = new (vecs.max(index as any) > 65535 ? Uint32BufferAttribute : Uint16BufferAttribute)(index, 1)
102
105
  }
103
106
 
104
107
  }
@@ -1083,8 +1086,8 @@ export class BufferGeometry {
1083
1086
 
1084
1087
  // standard BufferGeometry serialization
1085
1088
 
1086
- data.uuid = this.uuid;
1087
- data.type = this.type;
1089
+ // data.uuid = this.uuid;
1090
+ // data.type = this.type;
1088
1091
  if (this.name !== '') data.name = this.name;
1089
1092
  if (Object.keys(this.userData).length > 0) data.userData = this.userData;
1090
1093