three-stdlib 2.14.1 → 2.14.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,45 +1,45 @@
1
- import { Mesh, Vector3, InstancedInterleavedBuffer, InterleavedBufferAttribute } from 'three';
1
+ import { Vector3, Mesh, InstancedInterleavedBuffer, InterleavedBufferAttribute } from 'three';
2
2
  import { LineSegmentsGeometry } from './LineSegmentsGeometry.js';
3
3
  import { LineMaterial } from './LineMaterial.js';
4
4
 
5
- var Wireframe = function (geometry, material) {
6
- Mesh.call(this);
7
- this.type = 'Wireframe';
8
- this.geometry = geometry !== undefined ? geometry : new LineSegmentsGeometry();
9
- this.material = material !== undefined ? material : new LineMaterial({
5
+ const _start = new Vector3();
6
+
7
+ const _end = new Vector3();
8
+
9
+ class Wireframe extends Mesh {
10
+ constructor(geometry = new LineSegmentsGeometry(), material = new LineMaterial({
10
11
  color: Math.random() * 0xffffff
11
- });
12
- };
13
-
14
- Wireframe.prototype = Object.assign(Object.create(Mesh.prototype), {
15
- constructor: Wireframe,
16
- isWireframe: true,
17
- computeLineDistances: function () {
18
- // for backwards-compatability, but could be a method of LineSegmentsGeometry...
19
- var start = new Vector3();
20
- var end = new Vector3();
21
- return function computeLineDistances() {
22
- var geometry = this.geometry;
23
- var instanceStart = geometry.attributes.instanceStart;
24
- var instanceEnd = geometry.attributes.instanceEnd;
25
- var lineDistances = new Float32Array(2 * instanceStart.data.count);
26
-
27
- for (let i = 0, j = 0, l = instanceStart.data.count; i < l; i++, j += 2) {
28
- start.fromBufferAttribute(instanceStart, i);
29
- end.fromBufferAttribute(instanceEnd, i);
30
- lineDistances[j] = j === 0 ? 0 : lineDistances[j - 1];
31
- lineDistances[j + 1] = lineDistances[j] + start.distanceTo(end);
32
- }
33
-
34
- var instanceDistanceBuffer = new InstancedInterleavedBuffer(lineDistances, 2, 1); // d0, d1
35
-
36
- geometry.setAttribute('instanceDistanceStart', new InterleavedBufferAttribute(instanceDistanceBuffer, 1, 0)); // d0
37
-
38
- geometry.setAttribute('instanceDistanceEnd', new InterleavedBufferAttribute(instanceDistanceBuffer, 1, 1)); // d1
39
-
40
- return this;
41
- };
42
- }()
43
- });
12
+ })) {
13
+ super(geometry, material);
14
+ this.isWireframe = true;
15
+ this.type = 'Wireframe';
16
+ } // for backwards-compatibility, but could be a method of LineSegmentsGeometry...
17
+
18
+
19
+ computeLineDistances() {
20
+ const geometry = this.geometry;
21
+ const instanceStart = geometry.attributes.instanceStart;
22
+ const instanceEnd = geometry.attributes.instanceEnd;
23
+ const lineDistances = new Float32Array(2 * instanceStart.count);
24
+
25
+ for (let i = 0, j = 0, l = instanceStart.count; i < l; i++, j += 2) {
26
+ _start.fromBufferAttribute(instanceStart, i);
27
+
28
+ _end.fromBufferAttribute(instanceEnd, i);
29
+
30
+ lineDistances[j] = j === 0 ? 0 : lineDistances[j - 1];
31
+ lineDistances[j + 1] = lineDistances[j] + _start.distanceTo(_end);
32
+ }
33
+
34
+ const instanceDistanceBuffer = new InstancedInterleavedBuffer(lineDistances, 2, 1); // d0, d1
35
+
36
+ geometry.setAttribute('instanceDistanceStart', new InterleavedBufferAttribute(instanceDistanceBuffer, 1, 0)); // d0
37
+
38
+ geometry.setAttribute('instanceDistanceEnd', new InterleavedBufferAttribute(instanceDistanceBuffer, 1, 1)); // d1
39
+
40
+ return this;
41
+ }
42
+
43
+ }
44
44
 
45
45
  export { Wireframe };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("three"),r=require("./LineSegmentsGeometry.cjs.js");require("@babel/runtime/helpers/defineProperty");var t=function(t){r.LineSegmentsGeometry.call(this),this.type="WireframeGeometry2",this.fromWireframeGeometry(new e.WireframeGeometry(t))};t.prototype=Object.assign(Object.create(r.LineSegmentsGeometry.prototype),{constructor:t,isWireframeGeometry2:!0}),exports.WireframeGeometry2=t;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("three"),r=require("./LineSegmentsGeometry.cjs.js");class t extends r.LineSegmentsGeometry{constructor(r){super(),this.isWireframeGeometry2=!0,this.type="WireframeGeometry2",this.fromWireframeGeometry(new e.WireframeGeometry(r))}}exports.WireframeGeometry2=t;
@@ -1,15 +1,14 @@
1
1
  import { WireframeGeometry } from 'three';
2
2
  import { LineSegmentsGeometry } from './LineSegmentsGeometry.js';
3
3
 
4
- var WireframeGeometry2 = function (geometry) {
5
- LineSegmentsGeometry.call(this);
6
- this.type = 'WireframeGeometry2';
7
- this.fromWireframeGeometry(new WireframeGeometry(geometry)); // set colors, maybe
8
- };
4
+ class WireframeGeometry2 extends LineSegmentsGeometry {
5
+ constructor(geometry) {
6
+ super();
7
+ this.isWireframeGeometry2 = true;
8
+ this.type = 'WireframeGeometry2';
9
+ this.fromWireframeGeometry(new WireframeGeometry(geometry)); // set colors, maybe
10
+ }
9
11
 
10
- WireframeGeometry2.prototype = Object.assign(Object.create(LineSegmentsGeometry.prototype), {
11
- constructor: WireframeGeometry2,
12
- isWireframeGeometry2: true
13
- });
12
+ }
14
13
 
15
14
  export { WireframeGeometry2 };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "three-stdlib",
3
- "version": "2.14.1",
3
+ "version": "2.14.2",
4
4
  "private": false,
5
5
  "description": "stand-alone library of threejs examples",
6
6
  "main": "index.cjs.js",