Comparing version 3.0.4 to 3.1.0
@@ -6,6 +6,9 @@ import * as THREE from 'three' | ||
geometry: THREE.BufferGeometry | ||
points: Float32Array | Array<number> | ||
points: Float32Array | Array<THREE.Vector3 | THREE.Vector2 | [number, number, number] | [number, number] | number> | ||
isMeshLine: boolean | ||
setPoints(points: Float32Array | Array<number>, wcb?: (p: number) => any): void | ||
setPoints( | ||
points: Float32Array | Array<THREE.Vector3 | THREE.Vector2 | [number, number, number] | [number, number] | number>, | ||
wcb?: (p: number) => any, | ||
): void | ||
setMatrixWorld(matrixWorld: THREE.Matrix4): void | ||
@@ -12,0 +15,0 @@ setGeometry(g: THREE.BufferGeometry, c: (p: number) => any): void |
@@ -11,3 +11,9 @@ import * as r from "three"; | ||
} | ||
class S extends r.BufferGeometry { | ||
function C(a) { | ||
return a instanceof Float32Array ? a : a.map((t) => { | ||
const e = Array.isArray(t); | ||
return t instanceof r.Vector3 ? [t.x, t.y, t.z] : t instanceof r.Vector2 ? [t.x, t.y, 0] : e && t.length === 3 ? [t[0], t[1], t[2]] : e && t.length === 2 ? [t[0], t[1], 0] : t; | ||
}).flat(); | ||
} | ||
class V extends r.BufferGeometry { | ||
constructor() { | ||
@@ -42,3 +48,3 @@ super(), this.type = "MeshLine", this.isMeshLine = !0, this.positions = [], this.previous = [], this.next = [], this.side = [], this.width = [], this.indices_array = [], this.uvs = [], this.counters = [], this._points = [], this._geom = null, this.widthCallback = null, this.matrixWorld = new r.Matrix4(), Object.defineProperties(this, { | ||
setPoints(t, e) { | ||
if (!(t instanceof Float32Array) && !(t instanceof Array)) { | ||
if (t = C(t), !(t instanceof Float32Array) && !(t instanceof Array)) { | ||
console.error("ERROR: The BufferArray of points is not instancied correctly."); | ||
@@ -205,3 +211,3 @@ return; | ||
}`; | ||
class V extends r.ShaderMaterial { | ||
class k extends r.ShaderMaterial { | ||
constructor(t) { | ||
@@ -380,3 +386,3 @@ super({ | ||
} | ||
function k(a, t) { | ||
function U(a, t) { | ||
const e = new r.Matrix4(), i = new r.Ray(), s = new r.Sphere(), n = new r.Vector3(), u = this.geometry; | ||
@@ -392,4 +398,4 @@ if (s.copy(u.boundingSphere), s.applyMatrix4(this.matrixWorld), a.ray.intersectSphere(s, n) === !1) | ||
o.fromArray(y, w * 3), f.fromArray(y, _ * 3); | ||
const M = b[Math.floor(h / 3)] != null ? b[Math.floor(h / 3)] : 1, g = a.params.Line.threshold + this.material.lineWidth * M / 2, C = g * g; | ||
if (i.distanceSqToSegment(o, f, n, d) > C) | ||
const M = b[Math.floor(h / 3)] != null ? b[Math.floor(h / 3)] : 1, g = a.params.Line.threshold + this.material.lineWidth * M / 2, P = g * g; | ||
if (i.distanceSqToSegment(o, f, n, d) > P) | ||
continue; | ||
@@ -410,5 +416,5 @@ n.applyMatrix4(this.matrixWorld); | ||
export { | ||
S as MeshLineGeometry, | ||
V as MeshLineMaterial, | ||
k as raycast | ||
V as MeshLineGeometry, | ||
k as MeshLineMaterial, | ||
U as raycast | ||
}; |
{ | ||
"name": "meshline", | ||
"version": "3.0.4", | ||
"version": "3.1.0", | ||
"author": "Jaume Sanchez <the.spite@gmail.com> (https://www.clicktorelease.com)", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -25,19 +25,22 @@ # MeshLine | ||
##### Create an array of 3D coordinates | ||
##### Create a MeshLine | ||
First, create the list of numbers that will define the 3D points for the line. | ||
Create a `MeshLineGeometry` instance. | ||
```jsx | ||
const points = [] | ||
for (let j = 0; j < Math.PI; j += (2 * Math.PI) / 100) { | ||
points.push(Math.cos(j), Math.sin(j), 0) | ||
} | ||
const geometry = new MeshLineGeometry() | ||
``` | ||
##### Create a MeshLine and assign the points | ||
##### Create and assign points | ||
Once you have that, you can create a new `MeshLineGeometry`, and call `.setPoints()` passing the list of points. | ||
Pass a list of points into `.setPoints()`. Expected inputs are: | ||
- `Float32Array` | ||
- `Array<THREE.Vector3 | THREE.Vector2 | [number, number, number] | [number, number] | number>` | ||
```jsx | ||
const geometry = new MeshLineGeometry() | ||
const points = [] | ||
for (let j = 0; j < Math.PI; j += (2 * Math.PI) / 100) { | ||
points.push(Math.cos(j), Math.sin(j), 0) | ||
} | ||
geometry.setPoints(points) | ||
@@ -44,0 +47,0 @@ ``` |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
37238
585
170
0