@recast-navigation/three 0.34.0 → 0.35.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.
package/README.md CHANGED
@@ -16,7 +16,7 @@ To import the three.js glue, you can either use the `three` entrypoint in `recas
16
16
 
17
17
  ```ts
18
18
  import { init } from 'recast-navigation'
19
- import { ... } from 'recast-navigation/three';
19
+ import { ... } from '@recast-navigation/three';
20
20
  ```
21
21
 
22
22
  Or you can use the packages directly:
@@ -44,7 +44,7 @@ This package provides convenience functions for generating nav meshes from THREE
44
44
 
45
45
  ```ts
46
46
  import { init } from 'recast-navigation';
47
- import { threeToSoloNavMesh, threeToTiledNavMesh, threeToTileCache } from 'recast-navigation/three';
47
+ import { threeToSoloNavMesh, threeToTiledNavMesh, threeToTileCache } from '@recast-navigation/three';
48
48
  import * as THREE from 'three';
49
49
 
50
50
  /* initialize the library */
@@ -93,7 +93,7 @@ This library provides helpers that are used in conjunction with the core library
93
93
  This package provides a `DebugDrawer` utility that can visualise a navmesh and other generation intermediates.
94
94
 
95
95
  ```ts
96
- import { DebugDrawer } from 'recast-navigation/three';
96
+ import { DebugDrawer } from '@recast-navigation/three';
97
97
 
98
98
  const debugDrawer = new DebugDrawer();
99
99
 
@@ -116,9 +116,9 @@ This package provides helpers for visualizing various recast-navigation objects
116
116
  #### `NavMeshHelper`
117
117
 
118
118
  ```ts
119
- import { NavMeshHelper } from 'recast-navigation/three';
119
+ import { NavMeshHelper } from '@recast-navigation/three';
120
120
 
121
- const navMeshHelper = new NavMeshHelper({ navMesh });
121
+ const navMeshHelper = new NavMeshHelper(navMesh);
122
122
 
123
123
  scene.add(navMeshHelper);
124
124
 
@@ -129,11 +129,11 @@ navMeshHelper.update();
129
129
  #### `OffMeshConnectionsHelper`
130
130
 
131
131
  ```ts
132
- import { OffMeshConnectionsHelper } from 'recast-navigation/three';
132
+ import { OffMeshConnectionsHelper } from '@recast-navigation/three';
133
133
 
134
- const offMeshConnectionsHelper = new OffMeshConnectionsHelper({
135
- offMeshConnections,
136
- });
134
+ const offMeshConnectionsHelper = new OffMeshConnectionsHelper(
135
+ offMeshConnections
136
+ );
137
137
 
138
138
  scene.add(offMeshConnectionsHelper);
139
139
  ```
@@ -143,9 +143,9 @@ scene.add(offMeshConnectionsHelper);
143
143
  Visualises obstacles in a `TileCache`.
144
144
 
145
145
  ```ts
146
- import { TileCacheHelper } from 'recast-navigation/three';
146
+ import { TileCacheHelper } from '@recast-navigation/three';
147
147
 
148
- const tileCacheHelper = new TileCacheHelper({ tileCache });
148
+ const tileCacheHelper = new TileCacheHelper(tileCache);
149
149
 
150
150
  scene.add(tileCacheHelper);
151
151
 
@@ -158,9 +158,9 @@ tileCacheHelper.update();
158
158
  Visualises agents in a `Crowd`.
159
159
 
160
160
  ```ts
161
- import { CrowdHelper } from 'recast-navigation/three';
161
+ import { CrowdHelper } from '@recast-navigation/three';
162
162
 
163
- const crowdHelper = new CrowdHelper({ crowd });
163
+ const crowdHelper = new CrowdHelper(crowd);
164
164
 
165
165
  scene.add(crowdHelper);
166
166
 
@@ -175,8 +175,7 @@ You can optionally provide custom materials to the helpers.
175
175
  ```ts
176
176
  // NavMeshHelper
177
177
  const navMeshMaterial = new THREE.MeshBasicMaterial({ color: 'red' });
178
- const navMeshHelper = new NavMeshHelper({
179
- navMesh,
178
+ const navMeshHelper = new NavMeshHelper(navMesh, {
180
179
  navMeshMaterial,
181
180
  });
182
181
 
@@ -190,8 +189,7 @@ const offMeshConnectionExitCircleMaterial = new THREE.MeshBasicMaterial({
190
189
  const offMeshConnectionLineMaterial = new THREE.LineBasicMaterial({
191
190
  color: 'white',
192
191
  });
193
- const offMeshConnectionsHelper = new OffMeshConnectionsHelper({
194
- offMeshConnections,
192
+ const offMeshConnectionsHelper = new OffMeshConnectionsHelper(offMeshConnections, {
195
193
  entryCircleMaterial: offMeshConnectionEntryCircleMaterial,
196
194
  exitCircleMaterial: offMeshConnectionExitCircleMaterial,
197
195
  lineMaterial: offMeshConnectionLineMaterial,
@@ -199,15 +197,13 @@ const offMeshConnectionsHelper = new OffMeshConnectionsHelper({
199
197
 
200
198
  // TileCacheHelper
201
199
  const obstacleMaterial = new THREE.MeshBasicMaterial({ color: 'blue' });
202
- const tileCacheHelper = new TileCacheHelper({
203
- tileCache,
200
+ const tileCacheHelper = new TileCacheHelper(tileCache, {
204
201
  obstacleMaterial,
205
202
  });
206
203
 
207
204
  // CrowdHelper
208
205
  const agentMaterial = new THREE.MeshBasicMaterial({ color: 'red' });
209
- const crowdHelper = new CrowdHelper({
210
- crowd,
206
+ const crowdHelper = new CrowdHelper(crowd, {
211
207
  agentMaterial,
212
208
  });
213
209
  ```
@@ -1,4 +1,4 @@
1
- import { NavMesh, NavMeshQuery, RecastCompactHeightfield, RecastContourSet, RecastHeightfield, RecastHeightfieldLayer, RecastHeightfieldLayerSet, RecastPolyMesh, RecastPolyMeshDetail } from '@recast-navigation/core';
1
+ import { DebugDrawerPrimitive, NavMesh, NavMeshQuery, RecastCompactHeightfield, RecastContourSet, RecastHeightfield, RecastHeightfieldLayer, RecastHeightfieldLayerSet, RecastPolyMesh, RecastPolyMeshDetail } from '@recast-navigation/core';
2
2
  import * as THREE from 'three';
3
3
  import { LineMaterial } from 'three/addons';
4
4
  export type DebugDrawerParams = {
@@ -11,10 +11,9 @@ export declare class DebugDrawer extends THREE.Group {
11
11
  pointMaterial: THREE.Material;
12
12
  pointGeometry: THREE.SphereGeometry;
13
13
  lineMaterial: LineMaterial;
14
- private debugDrawImpl;
15
- private currentVertices;
16
- private currentPrimitive;
14
+ private debugDrawerUtils;
17
15
  constructor({ triMaterial, pointMaterial, lineMaterial, }?: DebugDrawerParams);
16
+ drawPrimitives(primitives: DebugDrawerPrimitive[]): void;
18
17
  drawHeightfieldSolid(hf: RecastHeightfield): void;
19
18
  drawHeightfieldWalkable(hf: RecastHeightfield): void;
20
19
  drawCompactHeightfieldSolid(chf: RecastCompactHeightfield): void;
@@ -36,9 +35,8 @@ export declare class DebugDrawer extends THREE.Group {
36
35
  drawNavMeshPoly(mesh: NavMesh, ref: number, col: number): void;
37
36
  reset(): void;
38
37
  dispose(): void;
39
- private vertex;
40
- private endPoints;
41
- private endLines;
42
- private endTris;
43
- private endQuads;
38
+ private drawPoints;
39
+ private drawLines;
40
+ private drawTris;
41
+ private drawQuads;
44
42
  }
@@ -1,14 +1,13 @@
1
1
  import { Crowd } from '@recast-navigation/core';
2
2
  import { Material, Mesh, Object3D } from 'three';
3
3
  export type CrowdHelperParams = {
4
- crowd: Crowd;
5
4
  agentMaterial?: Material;
6
5
  };
7
6
  export declare class CrowdHelper extends Object3D {
8
7
  agentMeshes: Map<number, Mesh>;
9
8
  recastCrowd: Crowd;
10
9
  agentMaterial: Material;
11
- constructor({ crowd, agentMaterial }: CrowdHelperParams);
10
+ constructor(crowd: Crowd, params?: CrowdHelperParams);
12
11
  /**
13
12
  * Update the three debug view of the crowd agents.
14
13
  *
@@ -1,15 +1,14 @@
1
1
  import { NavMesh } from '@recast-navigation/core';
2
2
  import { BufferGeometry, Material, Mesh, Object3D } from 'three';
3
3
  export type NavMeshHelperParams = {
4
- navMesh: NavMesh;
5
4
  navMeshMaterial?: Material;
6
5
  };
7
6
  export declare class NavMeshHelper extends Object3D {
8
7
  navMesh: NavMesh;
9
- navMeshMaterial: Material;
10
8
  mesh: Mesh;
11
- geometry: BufferGeometry;
12
- constructor({ navMesh, navMeshMaterial }: NavMeshHelperParams);
9
+ navMeshMaterial: Material;
10
+ navMeshGeometry: BufferGeometry;
11
+ constructor(navMesh: NavMesh, params?: NavMeshHelperParams);
13
12
  /**
14
13
  * Update the three debug nav mesh.
15
14
  *
@@ -1,7 +1,6 @@
1
1
  import { OffMeshConnectionParams } from '@recast-navigation/core';
2
2
  import { LineBasicMaterial, Material, Object3D } from 'three';
3
3
  export type OffMeshConnectionsHelperParams = {
4
- offMeshConnections?: OffMeshConnectionParams[];
5
4
  entryCircleMaterial?: Material;
6
5
  exitCircleMaterial?: Material;
7
6
  lineMaterial?: LineBasicMaterial;
@@ -11,7 +10,7 @@ export declare class OffMeshConnectionsHelper extends Object3D {
11
10
  entryCircleMaterial: Material;
12
11
  exitCircleMaterial: Material;
13
12
  lineMaterial: LineBasicMaterial;
14
- constructor({ offMeshConnections, entryCircleMaterial, exitCircleMaterial, lineMaterial, }: OffMeshConnectionsHelperParams);
13
+ constructor(offMeshConnections: OffMeshConnectionParams[], params?: OffMeshConnectionsHelperParams);
15
14
  /**
16
15
  * Update the three debug view of the off mesh connections.
17
16
  */
@@ -1,14 +1,13 @@
1
1
  import { Obstacle, TileCache } from '@recast-navigation/core';
2
2
  import { Material, Mesh, Object3D } from 'three';
3
3
  export type TileCacheHelperParams = {
4
- tileCache: TileCache;
5
4
  obstacleMaterial?: Material;
6
5
  };
7
6
  export declare class TileCacheHelper extends Object3D {
8
7
  tileCache: TileCache;
9
8
  obstacleMeshes: Map<Obstacle, Mesh>;
10
9
  obstacleMaterial: Material;
11
- constructor({ tileCache, obstacleMaterial }: TileCacheHelperParams);
10
+ constructor(tileCache: TileCache, params?: TileCacheHelperParams);
12
11
  /**
13
12
  * Update the obstacle meshes.
14
13
  *
package/dist/index.mjs CHANGED
@@ -1,2 +1,457 @@
1
- import{Raw as t}from"@recast-navigation/core";import*as e from"three";import{Box3 as n,Vector3 as i,InstancedBufferGeometry as r,Float32BufferAttribute as s,InstancedInterleavedBuffer as a,InterleavedBufferAttribute as o,WireframeGeometry as l,Sphere as d,UniformsLib as c,Vector2 as h,ShaderLib as u,UniformsUtils as p,ShaderMaterial as f,Vector4 as m,Matrix4 as w,Line3 as g,Mesh as y,MathUtils as v,Object3D as b,MeshBasicMaterial as x,CylinderGeometry as D,BufferGeometry as M,BufferAttribute as S,LineBasicMaterial as A,CircleGeometry as _,CatmullRomCurve3 as E,Line as z,BoxGeometry as U}from"three";import{generateSoloNavMesh as C,generateTiledNavMesh as I,generateTileCache as P}from"@recast-navigation/generators";const B=new n,L=new i;class R extends r{constructor(){super(),this.isLineSegmentsGeometry=!0,this.type="LineSegmentsGeometry";this.setIndex([0,2,1,2,3,1,2,4,3,4,5,3,4,6,5,6,7,5]),this.setAttribute("position",new s([-1,2,0,1,2,0,-1,1,0,1,1,0,-1,0,0,1,0,0,-1,-1,0,1,-1,0],3)),this.setAttribute("uv",new s([-1,2,1,2,-1,1,1,1,-1,-1,1,-1,-1,-2,1,-2],2))}applyMatrix4(t){const e=this.attributes.instanceStart,n=this.attributes.instanceEnd;return void 0!==e&&(e.applyMatrix4(t),n.applyMatrix4(t),e.needsUpdate=!0),null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this}setPositions(t){let e;t instanceof Float32Array?e=t:Array.isArray(t)&&(e=new Float32Array(t));const n=new a(e,6,1);return this.setAttribute("instanceStart",new o(n,3,0)),this.setAttribute("instanceEnd",new o(n,3,3)),this.computeBoundingBox(),this.computeBoundingSphere(),this}setColors(t){let e;t instanceof Float32Array?e=t:Array.isArray(t)&&(e=new Float32Array(t));const n=new a(e,6,1);return this.setAttribute("instanceColorStart",new o(n,3,0)),this.setAttribute("instanceColorEnd",new o(n,3,3)),this}fromWireframeGeometry(t){return this.setPositions(t.attributes.position.array),this}fromEdgesGeometry(t){return this.setPositions(t.attributes.position.array),this}fromMesh(t){return this.fromWireframeGeometry(new l(t.geometry)),this}fromLineSegments(t){const e=t.geometry;return this.setPositions(e.attributes.position.array),this}computeBoundingBox(){null===this.boundingBox&&(this.boundingBox=new n);const t=this.attributes.instanceStart,e=this.attributes.instanceEnd;void 0!==t&&void 0!==e&&(this.boundingBox.setFromBufferAttribute(t),B.setFromBufferAttribute(e),this.boundingBox.union(B))}computeBoundingSphere(){null===this.boundingSphere&&(this.boundingSphere=new d),null===this.boundingBox&&this.computeBoundingBox();const t=this.attributes.instanceStart,e=this.attributes.instanceEnd;if(void 0!==t&&void 0!==e){const n=this.boundingSphere.center;this.boundingBox.getCenter(n);let i=0;for(let r=0,s=t.count;r<s;r++)L.fromBufferAttribute(t,r),i=Math.max(i,n.distanceToSquared(L)),L.fromBufferAttribute(e,r),i=Math.max(i,n.distanceToSquared(L));this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&console.error("THREE.LineSegmentsGeometry.computeBoundingSphere(): Computed radius is NaN. The instanced position data is likely to have NaN values.",this)}}toJSON(){}applyMatrix(t){return console.warn("THREE.LineSegmentsGeometry: applyMatrix() has been renamed to applyMatrix4()."),this.applyMatrix4(t)}}c.line={worldUnits:{value:1},linewidth:{value:1},resolution:{value:new h(1,1)},dashOffset:{value:0},dashScale:{value:1},dashSize:{value:1},gapSize:{value:1}},u.line={uniforms:p.merge([c.common,c.fog,c.line]),vertexShader:"\n\t\t#include <common>\n\t\t#include <color_pars_vertex>\n\t\t#include <fog_pars_vertex>\n\t\t#include <logdepthbuf_pars_vertex>\n\t\t#include <clipping_planes_pars_vertex>\n\n\t\tuniform float linewidth;\n\t\tuniform vec2 resolution;\n\n\t\tattribute vec3 instanceStart;\n\t\tattribute vec3 instanceEnd;\n\n\t\tattribute vec3 instanceColorStart;\n\t\tattribute vec3 instanceColorEnd;\n\n\t\t#ifdef WORLD_UNITS\n\n\t\t\tvarying vec4 worldPos;\n\t\t\tvarying vec3 worldStart;\n\t\t\tvarying vec3 worldEnd;\n\n\t\t\t#ifdef USE_DASH\n\n\t\t\t\tvarying vec2 vUv;\n\n\t\t\t#endif\n\n\t\t#else\n\n\t\t\tvarying vec2 vUv;\n\n\t\t#endif\n\n\t\t#ifdef USE_DASH\n\n\t\t\tuniform float dashScale;\n\t\t\tattribute float instanceDistanceStart;\n\t\t\tattribute float instanceDistanceEnd;\n\t\t\tvarying float vLineDistance;\n\n\t\t#endif\n\n\t\tvoid trimSegment( const in vec4 start, inout vec4 end ) {\n\n\t\t\t// trim end segment so it terminates between the camera plane and the near plane\n\n\t\t\t// conservative estimate of the near plane\n\t\t\tfloat a = projectionMatrix[ 2 ][ 2 ]; // 3nd entry in 3th column\n\t\t\tfloat b = projectionMatrix[ 3 ][ 2 ]; // 3nd entry in 4th column\n\t\t\tfloat nearEstimate = - 0.5 * b / a;\n\n\t\t\tfloat alpha = ( nearEstimate - start.z ) / ( end.z - start.z );\n\n\t\t\tend.xyz = mix( start.xyz, end.xyz, alpha );\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\t#ifdef USE_COLOR\n\n\t\t\t\tvColor.xyz = ( position.y < 0.5 ) ? instanceColorStart : instanceColorEnd;\n\n\t\t\t#endif\n\n\t\t\t#ifdef USE_DASH\n\n\t\t\t\tvLineDistance = ( position.y < 0.5 ) ? dashScale * instanceDistanceStart : dashScale * instanceDistanceEnd;\n\t\t\t\tvUv = uv;\n\n\t\t\t#endif\n\n\t\t\tfloat aspect = resolution.x / resolution.y;\n\n\t\t\t// camera space\n\t\t\tvec4 start = modelViewMatrix * vec4( instanceStart, 1.0 );\n\t\t\tvec4 end = modelViewMatrix * vec4( instanceEnd, 1.0 );\n\n\t\t\t#ifdef WORLD_UNITS\n\n\t\t\t\tworldStart = start.xyz;\n\t\t\t\tworldEnd = end.xyz;\n\n\t\t\t#else\n\n\t\t\t\tvUv = uv;\n\n\t\t\t#endif\n\n\t\t\t// special case for perspective projection, and segments that terminate either in, or behind, the camera plane\n\t\t\t// clearly the gpu firmware has a way of addressing this issue when projecting into ndc space\n\t\t\t// but we need to perform ndc-space calculations in the shader, so we must address this issue directly\n\t\t\t// perhaps there is a more elegant solution -- WestLangley\n\n\t\t\tbool perspective = ( projectionMatrix[ 2 ][ 3 ] == - 1.0 ); // 4th entry in the 3rd column\n\n\t\t\tif ( perspective ) {\n\n\t\t\t\tif ( start.z < 0.0 && end.z >= 0.0 ) {\n\n\t\t\t\t\ttrimSegment( start, end );\n\n\t\t\t\t} else if ( end.z < 0.0 && start.z >= 0.0 ) {\n\n\t\t\t\t\ttrimSegment( end, start );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\t// clip space\n\t\t\tvec4 clipStart = projectionMatrix * start;\n\t\t\tvec4 clipEnd = projectionMatrix * end;\n\n\t\t\t// ndc space\n\t\t\tvec3 ndcStart = clipStart.xyz / clipStart.w;\n\t\t\tvec3 ndcEnd = clipEnd.xyz / clipEnd.w;\n\n\t\t\t// direction\n\t\t\tvec2 dir = ndcEnd.xy - ndcStart.xy;\n\n\t\t\t// account for clip-space aspect ratio\n\t\t\tdir.x *= aspect;\n\t\t\tdir = normalize( dir );\n\n\t\t\t#ifdef WORLD_UNITS\n\n\t\t\t\tvec3 worldDir = normalize( end.xyz - start.xyz );\n\t\t\t\tvec3 tmpFwd = normalize( mix( start.xyz, end.xyz, 0.5 ) );\n\t\t\t\tvec3 worldUp = normalize( cross( worldDir, tmpFwd ) );\n\t\t\t\tvec3 worldFwd = cross( worldDir, worldUp );\n\t\t\t\tworldPos = position.y < 0.5 ? start: end;\n\n\t\t\t\t// height offset\n\t\t\t\tfloat hw = linewidth * 0.5;\n\t\t\t\tworldPos.xyz += position.x < 0.0 ? hw * worldUp : - hw * worldUp;\n\n\t\t\t\t// don't extend the line if we're rendering dashes because we\n\t\t\t\t// won't be rendering the endcaps\n\t\t\t\t#ifndef USE_DASH\n\n\t\t\t\t\t// cap extension\n\t\t\t\t\tworldPos.xyz += position.y < 0.5 ? - hw * worldDir : hw * worldDir;\n\n\t\t\t\t\t// add width to the box\n\t\t\t\t\tworldPos.xyz += worldFwd * hw;\n\n\t\t\t\t\t// endcaps\n\t\t\t\t\tif ( position.y > 1.0 || position.y < 0.0 ) {\n\n\t\t\t\t\t\tworldPos.xyz -= worldFwd * 2.0 * hw;\n\n\t\t\t\t\t}\n\n\t\t\t\t#endif\n\n\t\t\t\t// project the worldpos\n\t\t\t\tvec4 clip = projectionMatrix * worldPos;\n\n\t\t\t\t// shift the depth of the projected points so the line\n\t\t\t\t// segments overlap neatly\n\t\t\t\tvec3 clipPose = ( position.y < 0.5 ) ? ndcStart : ndcEnd;\n\t\t\t\tclip.z = clipPose.z * clip.w;\n\n\t\t\t#else\n\n\t\t\t\tvec2 offset = vec2( dir.y, - dir.x );\n\t\t\t\t// undo aspect ratio adjustment\n\t\t\t\tdir.x /= aspect;\n\t\t\t\toffset.x /= aspect;\n\n\t\t\t\t// sign flip\n\t\t\t\tif ( position.x < 0.0 ) offset *= - 1.0;\n\n\t\t\t\t// endcaps\n\t\t\t\tif ( position.y < 0.0 ) {\n\n\t\t\t\t\toffset += - dir;\n\n\t\t\t\t} else if ( position.y > 1.0 ) {\n\n\t\t\t\t\toffset += dir;\n\n\t\t\t\t}\n\n\t\t\t\t// adjust for linewidth\n\t\t\t\toffset *= linewidth;\n\n\t\t\t\t// adjust for clip-space to screen-space conversion // maybe resolution should be based on viewport ...\n\t\t\t\toffset /= resolution.y;\n\n\t\t\t\t// select end\n\t\t\t\tvec4 clip = ( position.y < 0.5 ) ? clipStart : clipEnd;\n\n\t\t\t\t// back to clip space\n\t\t\t\toffset *= clip.w;\n\n\t\t\t\tclip.xy += offset;\n\n\t\t\t#endif\n\n\t\t\tgl_Position = clip;\n\n\t\t\tvec4 mvPosition = ( position.y < 0.5 ) ? start : end; // this is an approximation\n\n\t\t\t#include <logdepthbuf_vertex>\n\t\t\t#include <clipping_planes_vertex>\n\t\t\t#include <fog_vertex>\n\n\t\t}\n\t\t",fragmentShader:"\n\t\tuniform vec3 diffuse;\n\t\tuniform float opacity;\n\t\tuniform float linewidth;\n\n\t\t#ifdef USE_DASH\n\n\t\t\tuniform float dashOffset;\n\t\t\tuniform float dashSize;\n\t\t\tuniform float gapSize;\n\n\t\t#endif\n\n\t\tvarying float vLineDistance;\n\n\t\t#ifdef WORLD_UNITS\n\n\t\t\tvarying vec4 worldPos;\n\t\t\tvarying vec3 worldStart;\n\t\t\tvarying vec3 worldEnd;\n\n\t\t\t#ifdef USE_DASH\n\n\t\t\t\tvarying vec2 vUv;\n\n\t\t\t#endif\n\n\t\t#else\n\n\t\t\tvarying vec2 vUv;\n\n\t\t#endif\n\n\t\t#include <common>\n\t\t#include <color_pars_fragment>\n\t\t#include <fog_pars_fragment>\n\t\t#include <logdepthbuf_pars_fragment>\n\t\t#include <clipping_planes_pars_fragment>\n\n\t\tvec2 closestLineToLine(vec3 p1, vec3 p2, vec3 p3, vec3 p4) {\n\n\t\t\tfloat mua;\n\t\t\tfloat mub;\n\n\t\t\tvec3 p13 = p1 - p3;\n\t\t\tvec3 p43 = p4 - p3;\n\n\t\t\tvec3 p21 = p2 - p1;\n\n\t\t\tfloat d1343 = dot( p13, p43 );\n\t\t\tfloat d4321 = dot( p43, p21 );\n\t\t\tfloat d1321 = dot( p13, p21 );\n\t\t\tfloat d4343 = dot( p43, p43 );\n\t\t\tfloat d2121 = dot( p21, p21 );\n\n\t\t\tfloat denom = d2121 * d4343 - d4321 * d4321;\n\n\t\t\tfloat numer = d1343 * d4321 - d1321 * d4343;\n\n\t\t\tmua = numer / denom;\n\t\t\tmua = clamp( mua, 0.0, 1.0 );\n\t\t\tmub = ( d1343 + d4321 * ( mua ) ) / d4343;\n\t\t\tmub = clamp( mub, 0.0, 1.0 );\n\n\t\t\treturn vec2( mua, mub );\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\t#include <clipping_planes_fragment>\n\n\t\t\t#ifdef USE_DASH\n\n\t\t\t\tif ( vUv.y < - 1.0 || vUv.y > 1.0 ) discard; // discard endcaps\n\n\t\t\t\tif ( mod( vLineDistance + dashOffset, dashSize + gapSize ) > dashSize ) discard; // todo - FIX\n\n\t\t\t#endif\n\n\t\t\tfloat alpha = opacity;\n\n\t\t\t#ifdef WORLD_UNITS\n\n\t\t\t\t// Find the closest points on the view ray and the line segment\n\t\t\t\tvec3 rayEnd = normalize( worldPos.xyz ) * 1e5;\n\t\t\t\tvec3 lineDir = worldEnd - worldStart;\n\t\t\t\tvec2 params = closestLineToLine( worldStart, worldEnd, vec3( 0.0, 0.0, 0.0 ), rayEnd );\n\n\t\t\t\tvec3 p1 = worldStart + lineDir * params.x;\n\t\t\t\tvec3 p2 = rayEnd * params.y;\n\t\t\t\tvec3 delta = p1 - p2;\n\t\t\t\tfloat len = length( delta );\n\t\t\t\tfloat norm = len / linewidth;\n\n\t\t\t\t#ifndef USE_DASH\n\n\t\t\t\t\t#ifdef USE_ALPHA_TO_COVERAGE\n\n\t\t\t\t\t\tfloat dnorm = fwidth( norm );\n\t\t\t\t\t\talpha = 1.0 - smoothstep( 0.5 - dnorm, 0.5 + dnorm, norm );\n\n\t\t\t\t\t#else\n\n\t\t\t\t\t\tif ( norm > 0.5 ) {\n\n\t\t\t\t\t\t\tdiscard;\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t#endif\n\n\t\t\t\t#endif\n\n\t\t\t#else\n\n\t\t\t\t#ifdef USE_ALPHA_TO_COVERAGE\n\n\t\t\t\t\t// artifacts appear on some hardware if a derivative is taken within a conditional\n\t\t\t\t\tfloat a = vUv.x;\n\t\t\t\t\tfloat b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;\n\t\t\t\t\tfloat len2 = a * a + b * b;\n\t\t\t\t\tfloat dlen = fwidth( len2 );\n\n\t\t\t\t\tif ( abs( vUv.y ) > 1.0 ) {\n\n\t\t\t\t\t\talpha = 1.0 - smoothstep( 1.0 - dlen, 1.0 + dlen, len2 );\n\n\t\t\t\t\t}\n\n\t\t\t\t#else\n\n\t\t\t\t\tif ( abs( vUv.y ) > 1.0 ) {\n\n\t\t\t\t\t\tfloat a = vUv.x;\n\t\t\t\t\t\tfloat b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;\n\t\t\t\t\t\tfloat len2 = a * a + b * b;\n\n\t\t\t\t\t\tif ( len2 > 1.0 ) discard;\n\n\t\t\t\t\t}\n\n\t\t\t\t#endif\n\n\t\t\t#endif\n\n\t\t\tvec4 diffuseColor = vec4( diffuse, alpha );\n\n\t\t\t#include <logdepthbuf_fragment>\n\t\t\t#include <color_fragment>\n\n\t\t\tgl_FragColor = vec4( diffuseColor.rgb, alpha );\n\n\t\t\t#include <tonemapping_fragment>\n\t\t\t#include <colorspace_fragment>\n\t\t\t#include <fog_fragment>\n\t\t\t#include <premultiplied_alpha_fragment>\n\n\t\t}\n\t\t"};class T extends f{constructor(t){super({type:"LineMaterial",uniforms:p.clone(u.line.uniforms),vertexShader:u.line.vertexShader,fragmentShader:u.line.fragmentShader,clipping:!0}),this.isLineMaterial=!0,this.setValues(t)}get color(){return this.uniforms.diffuse.value}set color(t){this.uniforms.diffuse.value=t}get worldUnits(){return"WORLD_UNITS"in this.defines}set worldUnits(t){!0===t?this.defines.WORLD_UNITS="":delete this.defines.WORLD_UNITS}get linewidth(){return this.uniforms.linewidth.value}set linewidth(t){this.uniforms.linewidth&&(this.uniforms.linewidth.value=t)}get dashed(){return"USE_DASH"in this.defines}set dashed(t){!0===t!==this.dashed&&(this.needsUpdate=!0),!0===t?this.defines.USE_DASH="":delete this.defines.USE_DASH}get dashScale(){return this.uniforms.dashScale.value}set dashScale(t){this.uniforms.dashScale.value=t}get dashSize(){return this.uniforms.dashSize.value}set dashSize(t){this.uniforms.dashSize.value=t}get dashOffset(){return this.uniforms.dashOffset.value}set dashOffset(t){this.uniforms.dashOffset.value=t}get gapSize(){return this.uniforms.gapSize.value}set gapSize(t){this.uniforms.gapSize.value=t}get opacity(){return this.uniforms.opacity.value}set opacity(t){this.uniforms&&(this.uniforms.opacity.value=t)}get resolution(){return this.uniforms.resolution.value}set resolution(t){this.uniforms.resolution.value.copy(t)}get alphaToCoverage(){return"USE_ALPHA_TO_COVERAGE"in this.defines}set alphaToCoverage(t){this.defines&&(!0===t!==this.alphaToCoverage&&(this.needsUpdate=!0),!0===t?this.defines.USE_ALPHA_TO_COVERAGE="":delete this.defines.USE_ALPHA_TO_COVERAGE)}}const N=new m,V=new i,O=new i,H=new m,W=new m,F=new m,G=new i,j=new w,k=new g,q=new i,Q=new n,$=new d,J=new m;let X,K;function Y(t,e,n){return J.set(0,0,-e,1).applyMatrix4(t.projectionMatrix),J.multiplyScalar(1/J.w),J.x=K/n.width,J.y=K/n.height,J.applyMatrix4(t.projectionMatrixInverse),J.multiplyScalar(1/J.w),Math.abs(Math.max(J.x,J.y))}class Z extends y{constructor(t=new R,e=new T({color:16777215*Math.random()})){super(t,e),this.isLineSegments2=!0,this.type="LineSegments2"}computeLineDistances(){const t=this.geometry,e=t.attributes.instanceStart,n=t.attributes.instanceEnd,i=new Float32Array(2*e.count);for(let t=0,r=0,s=e.count;t<s;t++,r+=2)V.fromBufferAttribute(e,t),O.fromBufferAttribute(n,t),i[r]=0===r?0:i[r-1],i[r+1]=i[r]+V.distanceTo(O);const r=new a(i,2,1);return t.setAttribute("instanceDistanceStart",new o(r,1,0)),t.setAttribute("instanceDistanceEnd",new o(r,1,1)),this}raycast(t,e){const n=this.material.worldUnits,r=t.camera;null!==r||n||console.error('LineSegments2: "Raycaster.camera" needs to be set in order to raycast against LineSegments2 while worldUnits is set to false.');const s=void 0!==t.params.Line2&&t.params.Line2.threshold||0;X=t.ray;const a=this.matrixWorld,o=this.geometry,l=this.material;let d,c;if(K=l.linewidth+s,null===o.boundingSphere&&o.computeBoundingSphere(),$.copy(o.boundingSphere).applyMatrix4(a),n)d=.5*K;else{d=Y(r,Math.max(r.near,$.distanceToPoint(X.origin)),l.resolution)}if($.radius+=d,!1!==X.intersectsSphere($)){if(null===o.boundingBox&&o.computeBoundingBox(),Q.copy(o.boundingBox).applyMatrix4(a),n)c=.5*K;else{c=Y(r,Math.max(r.near,Q.distanceToPoint(X.origin)),l.resolution)}Q.expandByScalar(c),!1!==X.intersectsBox(Q)&&(n?function(t,e){const n=t.matrixWorld,r=t.geometry,s=r.attributes.instanceStart,a=r.attributes.instanceEnd;for(let o=0,l=Math.min(r.instanceCount,s.count);o<l;o++){k.start.fromBufferAttribute(s,o),k.end.fromBufferAttribute(a,o),k.applyMatrix4(n);const r=new i,l=new i;X.distanceSqToSegment(k.start,k.end,l,r),l.distanceTo(r)<.5*K&&e.push({point:l,pointOnLine:r,distance:X.origin.distanceTo(l),object:t,face:null,faceIndex:o,uv:null,uv1:null})}}(this,e):function(t,e,n){const r=e.projectionMatrix,s=t.material.resolution,a=t.matrixWorld,o=t.geometry,l=o.attributes.instanceStart,d=o.attributes.instanceEnd,c=Math.min(o.instanceCount,l.count),h=-e.near;X.at(1,F),F.w=1,F.applyMatrix4(e.matrixWorldInverse),F.applyMatrix4(r),F.multiplyScalar(1/F.w),F.x*=s.x/2,F.y*=s.y/2,F.z=0,G.copy(F),j.multiplyMatrices(e.matrixWorldInverse,a);for(let e=0,o=c;e<o;e++){if(H.fromBufferAttribute(l,e),W.fromBufferAttribute(d,e),H.w=1,W.w=1,H.applyMatrix4(j),W.applyMatrix4(j),H.z>h&&W.z>h)continue;if(H.z>h){const t=H.z-W.z,e=(H.z-h)/t;H.lerp(W,e)}else if(W.z>h){const t=W.z-H.z,e=(W.z-h)/t;W.lerp(H,e)}H.applyMatrix4(r),W.applyMatrix4(r),H.multiplyScalar(1/H.w),W.multiplyScalar(1/W.w),H.x*=s.x/2,H.y*=s.y/2,W.x*=s.x/2,W.y*=s.y/2,k.start.copy(H),k.start.z=0,k.end.copy(W),k.end.z=0;const o=k.closestPointToPointParameter(G,!0);k.at(o,q);const c=v.lerp(H.z,W.z,o),u=c>=-1&&c<=1,p=G.distanceTo(q)<.5*K;if(u&&p){k.start.fromBufferAttribute(l,e),k.end.fromBufferAttribute(d,e),k.start.applyMatrix4(a),k.end.applyMatrix4(a);const r=new i,s=new i;X.distanceSqToSegment(k.start,k.end,s,r),n.push({point:s,pointOnLine:r,distance:X.origin.distanceTo(s),object:t,face:null,faceIndex:e,uv:null,uv1:null})}}}(this,r,e))}}onBeforeRender(t){const e=this.material.uniforms;e&&e.resolution&&(t.getViewport(N),this.material.uniforms.resolution.value.set(N.z,N.w))}}const tt=new e.Color;class et extends e.Group{pointGeometry=new e.SphereGeometry(.02,32,32);currentVertices=[];currentPrimitive=0;constructor({triMaterial:n,pointMaterial:i,lineMaterial:r}={}){super(),this.triMaterial=n??new e.MeshBasicMaterial({vertexColors:!0,transparent:!0,opacity:.4,depthWrite:!1}),this.pointMaterial=i??new e.MeshBasicMaterial,this.lineMaterial=r??new T({color:16777215,linewidth:2,vertexColors:!0,polygonOffset:!0,polygonOffsetFactor:-4,polygonOffsetUnits:-10}),this.debugDrawImpl=new t.Module.DebugDrawImpl,this.debugDrawImpl.handleBegin=(t,e)=>{this.currentPrimitive=t,this.currentVertices=[]},this.debugDrawImpl.handleDepthMask=t=>{},this.debugDrawImpl.handleTexture=t=>{},this.debugDrawImpl.handleVertexWithColor=(t,e,n,i)=>{this.vertex(t,e,n,i)},this.debugDrawImpl.handleVertexWithColorAndUV=(t,e,n,i,r,s)=>{this.vertex(t,e,n,i)},this.debugDrawImpl.handleEnd=()=>{this.currentPrimitive===t.Module.DU_DRAW_LINES?this.endLines():this.currentPrimitive===t.Module.DU_DRAW_TRIS?this.endTris():this.currentPrimitive===t.Module.DU_DRAW_QUADS?this.endQuads():this.currentPrimitive===t.Module.DU_DRAW_POINTS&&this.endPoints()}}drawHeightfieldSolid(e){t.RecastDebugDraw.debugDrawHeightfieldSolid(this.debugDrawImpl,e.raw)}drawHeightfieldWalkable(e){t.RecastDebugDraw.debugDrawHeightfieldWalkable(this.debugDrawImpl,e.raw)}drawCompactHeightfieldSolid(e){t.RecastDebugDraw.debugDrawCompactHeightfieldSolid(this.debugDrawImpl,e.raw)}drawCompactHeightfieldRegions(e){t.RecastDebugDraw.debugDrawCompactHeightfieldRegions(this.debugDrawImpl,e.raw)}drawCompactHeightfieldDistance(e){t.RecastDebugDraw.debugDrawCompactHeightfieldDistance(this.debugDrawImpl,e.raw)}drawHeightfieldLayer(e,n){t.RecastDebugDraw.debugDrawHeightfieldLayer(this.debugDrawImpl,e.raw,n)}drawHeightfieldLayers(e){t.RecastDebugDraw.debugDrawHeightfieldLayers(this.debugDrawImpl,e.raw)}drawRegionConnections(e,n=1){t.RecastDebugDraw.debugDrawRegionConnections(this.debugDrawImpl,e.raw,n)}drawRawContours(e,n=1){t.RecastDebugDraw.debugDrawRawContours(this.debugDrawImpl,e.raw,n)}drawContours(e,n=1){t.RecastDebugDraw.debugDrawContours(this.debugDrawImpl,e.raw,n)}drawPolyMesh(e){t.RecastDebugDraw.debugDrawPolyMesh(this.debugDrawImpl,e.raw)}drawPolyMeshDetail(e){t.RecastDebugDraw.debugDrawPolyMeshDetail(this.debugDrawImpl,e.raw)}drawNavMesh(e,n=0){t.DetourDebugDraw.debugDrawNavMesh(this.debugDrawImpl,e.raw.getNavMesh(),n)}drawNavMeshWithClosedList(e,n,i=0){t.DetourDebugDraw.debugDrawNavMeshWithClosedList(this.debugDrawImpl,e.raw.m_navMesh,n.raw.m_navQuery,i)}drawNavMeshNodes(e){t.DetourDebugDraw.debugDrawNavMeshNodes(this.debugDrawImpl,e.raw.m_navQuery)}drawNavMeshBVTree(e){t.DetourDebugDraw.debugDrawNavMeshBVTree(this.debugDrawImpl,e.raw.m_navMesh)}drawNavMeshPortals(e){t.DetourDebugDraw.debugDrawNavMeshPortals(this.debugDrawImpl,e.raw.m_navMesh)}drawNavMeshPolysWithFlags(e,n,i){t.DetourDebugDraw.debugDrawNavMeshPolysWithFlags(this.debugDrawImpl,e.raw.m_navMesh,n,i)}drawNavMeshPoly(e,n,i){t.DetourDebugDraw.debugDrawNavMeshPoly(this.debugDrawImpl,e.raw.m_navMesh,n,i)}reset(){for(const t of this.children)(t instanceof e.Mesh||t instanceof Z)&&t.geometry.dispose();this.clear()}dispose(){this.reset(),t.Module.destroy(this.debugDrawImpl),this.pointGeometry.dispose(),this.triMaterial.dispose(),this.pointMaterial.dispose(),this.lineMaterial.dispose()}vertex(t,e,n,i){const r=(i>>16&255)/255,s=(i>>8&255)/255,a=(255&i)/255,o=(i>>24&255)/255;this.currentVertices.push([t,e,n,r,s,a,o])}endPoints(){const t=this.pointGeometry,n=new e.InstancedMesh(t,this.pointMaterial,this.currentVertices.length);for(let t=0;t<this.currentVertices.length;t++){const[i,r,s,a,o,l]=this.currentVertices[t];n.setMatrixAt(t,(new e.Matrix4).setPosition(i,r,s)),n.setColorAt(t,tt.setRGB(a,o,l))}n.instanceMatrix.needsUpdate=!0,this.add(n)}endLines(){const t=new R,e=[],n=[];for(let t=0;t<this.currentVertices.length;t+=2){const[i,r,s,a,o,l]=this.currentVertices[t],[d,c,h,u,p,f]=this.currentVertices[t+1];e.push(i,r,s),e.push(d,c,h),n.push(a,o,l),n.push(u,p,f)}t.setPositions(e),t.setColors(n);const i=new Z(t,this.lineMaterial);this.add(i)}endTris(){const t=new e.BufferGeometry,n=new Float32Array(3*this.currentVertices.length),i=new Float32Array(3*this.currentVertices.length);for(let t=0;t<this.currentVertices.length;t++){const[e,r,s,a,o,l]=this.currentVertices[t];n[3*t+0]=e,n[3*t+1]=r,n[3*t+2]=s,i[3*t+0]=a,i[3*t+1]=o,i[3*t+2]=l}t.setAttribute("position",new e.BufferAttribute(n,3)),t.setAttribute("color",new e.BufferAttribute(i,3));const r=this.triMaterial,s=new e.Mesh(t,r);this.add(s)}endQuads(){const t=[],n=[];for(let e=0;e<this.currentVertices.length;e+=4){const i=[this.currentVertices[e],this.currentVertices[e+1],this.currentVertices[e+2],this.currentVertices[e],this.currentVertices[e+2],this.currentVertices[e+3]];for(const[e,r,s,a,o,l]of i)t.push(e,r,s),n.push(a,o,l)}const i=new e.BufferGeometry;i.setAttribute("position",new e.BufferAttribute(new Float32Array(t),3)),i.setAttribute("color",new e.BufferAttribute(new Float32Array(n),3));const r=this.triMaterial,s=new e.Mesh(i,r);this.add(s)}}class nt extends b{agentMeshes=new Map;constructor({crowd:t,agentMaterial:e}){super(),this.recastCrowd=t,this.agentMaterial=e??new x({color:"red"}),this.update()}update(){const t=this.recastCrowd.getAgents(),e=new Set(this.agentMeshes.keys());for(const n of t){e.delete(n.agentIndex);const t=n.position(),r=n.velocity();let s=this.agentMeshes.get(n.agentIndex);void 0===s?(s=this.createAgentMesh(n),this.add(s),this.agentMeshes.set(n.agentIndex,s)):this.updateAgentGeometry(s,n),s.position.set(t.x,t.y+n.height/2,t.z),s.lookAt((new i).copy(s.position).add(r))}for(const t of e){const e=this.agentMeshes.get(t);e&&(this.remove(e),this.agentMeshes.delete(t))}}createAgentMesh(t){const e=new y;return e.material=this.agentMaterial,this.updateAgentGeometry(e,t),e.userData={radius:t.radius,height:t.height},e}updateAgentGeometry(t,e){if(t.userData.radius!==e.radius||t.userData.height!==e.height){const n=new D(e.radius,e.radius,e.height);t.geometry.dispose(),t.geometry=n,t.userData.radius=e.radius,t.userData.height=e.height}}}class it extends b{constructor({navMesh:t,navMeshMaterial:e}){super(),this.navMesh=t,this.geometry=new M,this.navMeshMaterial=e||new x({color:"orange",transparent:!0,opacity:.7,depthWrite:!1}),this.update(),this.mesh=new y(this.geometry,this.navMeshMaterial),this.add(this.mesh)}update(){const[t,e]=this.navMesh.getDebugNavMesh();this.geometry.setAttribute("position",new S(Float32Array.from(t),3)),this.geometry.setIndex(new S(Uint32Array.from(e),1)),this.geometry.computeVertexNormals()}}class rt extends b{constructor({offMeshConnections:t,entryCircleMaterial:e,exitCircleMaterial:n,lineMaterial:i}){super(),this.offMeshConnections=t??[],this.entryCircleMaterial=e??new x({color:"green"}),this.exitCircleMaterial=n??new x({color:"blue"}),this.lineMaterial=i??new A({color:"red"}),this.update()}update(){this.clear();for(const t of this.offMeshConnections){const e=new _(t.radius,16),n=new y(e,this.entryCircleMaterial);n.position.copy(t.startPosition),n.position.y+=.001,n.rotation.x=-Math.PI/2,this.add(n);const r=new y(e,t.bidirectional?this.entryCircleMaterial:this.exitCircleMaterial);r.position.copy(t.endPosition),r.position.y+=.001,r.rotation.x=-Math.PI/2,this.add(r);const s=(new i).copy(t.startPosition),a=(new i).copy(t.endPosition),o=(new i).addVectors(s,a).multiplyScalar(.5);o.y*=1.2;const l=new E([s,o,a]).getPoints(50),d=(new M).setFromPoints(l),c=new z(d,this.lineMaterial);this.add(c)}}}class st extends b{obstacleMeshes=new Map;constructor({tileCache:t,obstacleMaterial:e}){super(),this.tileCache=t,this.obstacleMaterial=e||new x({color:"red",wireframe:!0,wireframeLinewidth:2}),this.update()}update(){const t=new Set(this.obstacleMeshes.keys());for(const[,e]of this.tileCache.obstacles){const n=this.obstacleMeshes.get(e);if(t.delete(e),!n){const{position:t}=e,n=new y(void 0,this.obstacleMaterial);if(n.position.copy(t),"box"===e.type){const{halfExtents:t,angle:i}=e;n.geometry=new U(2*t.x,2*t.y,2*t.z),n.rotation.y=i}else{if("cylinder"!==e.type)throw new Error(`Unknown obstacle type: ${e}`);{const{radius:t,height:i}=e;n.geometry=new D(t,t,i,16),n.position.y+=i/2}}this.add(n),this.obstacleMeshes.set(e,n)}}for(const e of t){const t=this.obstacleMeshes.get(e);t&&(this.remove(t),this.obstacleMeshes.delete(e))}}}const at=new i,ot=t=>{const e=[];for(const n of t){const t=n.geometry.attributes.position;if(!t||3!==t.itemSize)continue;let i=n;const r=n.geometry.getIndex()?.array;if(void 0===r){i=i.clone(),i.geometry=n.geometry.clone();const e=[];for(let n=0;n<t.count;n++)e.push(n);i.geometry.setIndex(e)}e.push(i)}const n=[],i=[],r={};let s=0;for(const t of e){t.updateMatrixWorld();const e=t.geometry.attributes.position.array,a=t.geometry.getIndex().array;for(let o=0;o<a.length;o++){const l=3*a[o],d=at.set(e[l],e[l+1],e[l+2]);t.localToWorld(d);const c=`${d.x}_${d.y}_${d.z}`;let h=r[c];h||(r[c]=h=s,n.push(d.x,d.y,d.z),s++),i.push(h)}}return[Float32Array.from(n),Uint32Array.from(i)]},lt=(t,e={},n=!1)=>{const[i,r]=ot(t);return C(i,r,e,n)},dt=(t,e={},n=!1)=>{const[i,r]=ot(t);return I(i,r,e,n)},ct=(t,e={},n=!1)=>{const[i,r]=ot(t);return P(i,r,e,n)};export{nt as CrowdHelper,et as DebugDrawer,it as NavMeshHelper,rt as OffMeshConnectionsHelper,st as TileCacheHelper,ot as getPositionsAndIndices,lt as threeToSoloNavMesh,ct as threeToTileCache,dt as threeToTiledNavMesh};
2
- //# sourceMappingURL=index.mjs.map
1
+ import { DebugDrawerUtils } from '@recast-navigation/core';
2
+ import * as THREE from 'three';
3
+ import { Object3D, MeshBasicMaterial, Vector3, Mesh, CylinderGeometry, BufferGeometry, BufferAttribute, LineBasicMaterial, CircleGeometry, CatmullRomCurve3, Line, BoxGeometry } from 'three';
4
+ import { LineMaterial, LineSegments2, LineSegmentsGeometry } from 'three/addons';
5
+ import { mergePositionsAndIndices, generateSoloNavMesh, generateTiledNavMesh, generateTileCache } from '@recast-navigation/generators';
6
+
7
+ const _color = new THREE.Color();
8
+ class DebugDrawer extends THREE.Group {
9
+ pointGeometry = new THREE.SphereGeometry(0.02, 32, 32);
10
+ constructor({
11
+ triMaterial,
12
+ pointMaterial,
13
+ lineMaterial
14
+ } = {}) {
15
+ super();
16
+ this.debugDrawerUtils = new DebugDrawerUtils();
17
+ this.triMaterial = triMaterial ?? new THREE.MeshBasicMaterial({
18
+ vertexColors: true,
19
+ transparent: true,
20
+ opacity: 0.4,
21
+ depthWrite: false
22
+ });
23
+ this.pointMaterial = pointMaterial ?? new THREE.MeshBasicMaterial();
24
+ this.lineMaterial = lineMaterial ?? new LineMaterial({
25
+ color: 0xffffff,
26
+ linewidth: 2,
27
+ vertexColors: true,
28
+ polygonOffset: true,
29
+ polygonOffsetFactor: -4,
30
+ polygonOffsetUnits: -10
31
+ });
32
+ }
33
+ drawPrimitives(primitives) {
34
+ for (const primitive of primitives) {
35
+ switch (primitive.type) {
36
+ case 'points':
37
+ this.drawPoints(primitive);
38
+ break;
39
+ case 'lines':
40
+ this.drawLines(primitive);
41
+ break;
42
+ case 'tris':
43
+ this.drawTris(primitive);
44
+ break;
45
+ case 'quads':
46
+ this.drawQuads(primitive);
47
+ break;
48
+ }
49
+ }
50
+ }
51
+ drawHeightfieldSolid(hf) {
52
+ const primitives = this.debugDrawerUtils.drawHeightfieldSolid(hf);
53
+ this.drawPrimitives(primitives);
54
+ }
55
+ drawHeightfieldWalkable(hf) {
56
+ const primitives = this.debugDrawerUtils.drawHeightfieldWalkable(hf);
57
+ this.drawPrimitives(primitives);
58
+ }
59
+ drawCompactHeightfieldSolid(chf) {
60
+ const primitives = this.debugDrawerUtils.drawCompactHeightfieldSolid(chf);
61
+ this.drawPrimitives(primitives);
62
+ }
63
+ drawCompactHeightfieldRegions(chf) {
64
+ const primitives = this.debugDrawerUtils.drawCompactHeightfieldRegions(chf);
65
+ this.drawPrimitives(primitives);
66
+ }
67
+ drawCompactHeightfieldDistance(chf) {
68
+ const primitives = this.debugDrawerUtils.drawCompactHeightfieldDistance(chf);
69
+ this.drawPrimitives(primitives);
70
+ }
71
+ drawHeightfieldLayer(layer, idx) {
72
+ const primitives = this.debugDrawerUtils.drawHeightfieldLayer(layer, idx);
73
+ this.drawPrimitives(primitives);
74
+ }
75
+ drawHeightfieldLayers(lset) {
76
+ const primitives = this.debugDrawerUtils.drawHeightfieldLayers(lset);
77
+ this.drawPrimitives(primitives);
78
+ }
79
+ drawRegionConnections(cset, alpha = 1) {
80
+ const primitives = this.debugDrawerUtils.drawRegionConnections(cset, alpha);
81
+ this.drawPrimitives(primitives);
82
+ }
83
+ drawRawContours(cset, alpha = 1) {
84
+ const primitives = this.debugDrawerUtils.drawRawContours(cset, alpha);
85
+ this.drawPrimitives(primitives);
86
+ }
87
+ drawContours(cset, alpha = 1) {
88
+ const primitives = this.debugDrawerUtils.drawContours(cset, alpha);
89
+ this.drawPrimitives(primitives);
90
+ }
91
+ drawPolyMesh(mesh) {
92
+ const primitives = this.debugDrawerUtils.drawPolyMesh(mesh);
93
+ this.drawPrimitives(primitives);
94
+ }
95
+ drawPolyMeshDetail(dmesh) {
96
+ const primitives = this.debugDrawerUtils.drawPolyMeshDetail(dmesh);
97
+ this.drawPrimitives(primitives);
98
+ }
99
+ drawNavMesh(mesh, flags = 0) {
100
+ const primitives = this.debugDrawerUtils.drawNavMesh(mesh, flags);
101
+ this.drawPrimitives(primitives);
102
+ }
103
+ drawNavMeshWithClosedList(mesh, query, flags = 0) {
104
+ const primitives = this.debugDrawerUtils.drawNavMeshWithClosedList(mesh, query, flags);
105
+ this.drawPrimitives(primitives);
106
+ }
107
+ drawNavMeshNodes(query) {
108
+ const primitives = this.debugDrawerUtils.drawNavMeshNodes(query);
109
+ this.drawPrimitives(primitives);
110
+ }
111
+ drawNavMeshBVTree(mesh) {
112
+ const primitives = this.debugDrawerUtils.drawNavMeshBVTree(mesh);
113
+ this.drawPrimitives(primitives);
114
+ }
115
+ drawNavMeshPortals(mesh) {
116
+ const primitives = this.debugDrawerUtils.drawNavMeshPortals(mesh);
117
+ this.drawPrimitives(primitives);
118
+ }
119
+ drawNavMeshPolysWithFlags(mesh, flags, col) {
120
+ const primitives = this.debugDrawerUtils.drawNavMeshPolysWithFlags(mesh, flags, col);
121
+ this.drawPrimitives(primitives);
122
+ }
123
+ drawNavMeshPoly(mesh, ref, col) {
124
+ const primitives = this.debugDrawerUtils.drawNavMeshPoly(mesh, ref, col);
125
+ this.drawPrimitives(primitives);
126
+ }
127
+ // todo:
128
+ // - drawTileCacheLayerAreas
129
+ // - drawTileCacheLayerRegions
130
+ // - drawTileCacheContours
131
+ // - drawTileCachePolyMesh
132
+ reset() {
133
+ for (const child of this.children) {
134
+ if (child instanceof THREE.Mesh || child instanceof LineSegments2) {
135
+ child.geometry.dispose();
136
+ }
137
+ }
138
+ this.clear();
139
+ }
140
+ dispose() {
141
+ this.debugDrawerUtils.dispose();
142
+ this.reset();
143
+ this.pointGeometry.dispose();
144
+ this.triMaterial.dispose();
145
+ this.pointMaterial.dispose();
146
+ this.lineMaterial.dispose();
147
+ }
148
+ drawPoints(primitive) {
149
+ const geometry = this.pointGeometry;
150
+ const instancedMesh = new THREE.InstancedMesh(geometry, this.pointMaterial, primitive.vertices.length / 3);
151
+ for (let point = 0; point < primitive.vertices.length / 7; point++) {
152
+ const [x, y, z, r, g, b] = primitive.vertices[point];
153
+ instancedMesh.setMatrixAt(point, new THREE.Matrix4().setPosition(x, y, z));
154
+ instancedMesh.setColorAt(point, _color.setRGB(r, g, b));
155
+ }
156
+ instancedMesh.instanceMatrix.needsUpdate = true;
157
+ this.add(instancedMesh);
158
+ }
159
+ drawLines(primitive) {
160
+ const lineSegmentsGeometry = new LineSegmentsGeometry();
161
+ const positions = [];
162
+ const colors = [];
163
+ for (let i = 0; i < primitive.vertices.length; i += 2) {
164
+ const [x1, y1, z1, r1, g1, b1] = primitive.vertices[i];
165
+ const [x2, y2, z2, r2, g2, b2] = primitive.vertices[i + 1];
166
+ positions.push(x1, y1, z1);
167
+ positions.push(x2, y2, z2);
168
+ colors.push(r1, g1, b1);
169
+ colors.push(r2, g2, b2);
170
+ }
171
+ lineSegmentsGeometry.setPositions(positions);
172
+ lineSegmentsGeometry.setColors(colors);
173
+ const lineSegments = new LineSegments2(lineSegmentsGeometry, this.lineMaterial);
174
+ this.add(lineSegments);
175
+ }
176
+ drawTris(primitive) {
177
+ const geometry = new THREE.BufferGeometry();
178
+ const positions = new Float32Array(primitive.vertices.length * 3);
179
+ const colors = new Float32Array(primitive.vertices.length * 3);
180
+ for (let i = 0; i < primitive.vertices.length; i++) {
181
+ const [x, y, z, r, g, b] = primitive.vertices[i];
182
+ positions[i * 3 + 0] = x;
183
+ positions[i * 3 + 1] = y;
184
+ positions[i * 3 + 2] = z;
185
+ colors[i * 3 + 0] = r;
186
+ colors[i * 3 + 1] = g;
187
+ colors[i * 3 + 2] = b;
188
+ }
189
+ geometry.setAttribute('position', new THREE.BufferAttribute(positions, 3));
190
+ geometry.setAttribute('color', new THREE.BufferAttribute(colors, 3));
191
+ const material = this.triMaterial;
192
+ const mesh = new THREE.Mesh(geometry, material);
193
+ this.add(mesh);
194
+ }
195
+ drawQuads(primitive) {
196
+ const positions = [];
197
+ const colors = [];
198
+ for (let i = 0; i < primitive.vertices.length; i += 4) {
199
+ const vertices = [primitive.vertices[i], primitive.vertices[i + 1], primitive.vertices[i + 2], primitive.vertices[i], primitive.vertices[i + 2], primitive.vertices[i + 3]];
200
+ for (const [x, y, z, r, g, b] of vertices) {
201
+ positions.push(x, y, z);
202
+ colors.push(r, g, b);
203
+ }
204
+ }
205
+ const geometry = new THREE.BufferGeometry();
206
+ geometry.setAttribute('position', new THREE.BufferAttribute(new Float32Array(positions), 3));
207
+ geometry.setAttribute('color', new THREE.BufferAttribute(new Float32Array(colors), 3));
208
+ const material = this.triMaterial;
209
+ const mesh = new THREE.Mesh(geometry, material);
210
+ this.add(mesh);
211
+ }
212
+ }
213
+
214
+ class CrowdHelper extends Object3D {
215
+ agentMeshes = new Map();
216
+ constructor(crowd, params) {
217
+ super();
218
+ this.recastCrowd = crowd;
219
+ this.agentMaterial = params?.agentMaterial ?? new MeshBasicMaterial({
220
+ color: 'red'
221
+ });
222
+ this.update();
223
+ }
224
+ /**
225
+ * Update the three debug view of the crowd agents.
226
+ *
227
+ * This should be called after updating the crowd.
228
+ */
229
+ update() {
230
+ const agents = this.recastCrowd.getAgents();
231
+ const unseen = new Set(this.agentMeshes.keys());
232
+ for (const agent of agents) {
233
+ unseen.delete(agent.agentIndex);
234
+ const position = agent.position();
235
+ const velocity = agent.velocity();
236
+ let agentMesh = this.agentMeshes.get(agent.agentIndex);
237
+ if (agentMesh === undefined) {
238
+ agentMesh = this.createAgentMesh(agent);
239
+ this.add(agentMesh);
240
+ this.agentMeshes.set(agent.agentIndex, agentMesh);
241
+ } else {
242
+ this.updateAgentGeometry(agentMesh, agent);
243
+ }
244
+ agentMesh.position.set(position.x, position.y + agent.height / 2, position.z);
245
+ agentMesh.lookAt(new Vector3().copy(agentMesh.position).add(velocity));
246
+ }
247
+ for (const agentId of unseen) {
248
+ const agentMesh = this.agentMeshes.get(agentId);
249
+ if (agentMesh) {
250
+ this.remove(agentMesh);
251
+ this.agentMeshes.delete(agentId);
252
+ }
253
+ }
254
+ }
255
+ createAgentMesh(agent) {
256
+ const mesh = new Mesh();
257
+ mesh.material = this.agentMaterial;
258
+ this.updateAgentGeometry(mesh, agent);
259
+ mesh.userData = {
260
+ radius: agent.radius,
261
+ height: agent.height
262
+ };
263
+ return mesh;
264
+ }
265
+ updateAgentGeometry(agentMesh, agentParams) {
266
+ if (agentMesh.userData.radius !== agentParams.radius || agentMesh.userData.height !== agentParams.height) {
267
+ const geometry = new CylinderGeometry(agentParams.radius, agentParams.radius, agentParams.height);
268
+ agentMesh.geometry.dispose();
269
+ agentMesh.geometry = geometry;
270
+ agentMesh.userData.radius = agentParams.radius;
271
+ agentMesh.userData.height = agentParams.height;
272
+ }
273
+ }
274
+ }
275
+
276
+ class NavMeshHelper extends Object3D {
277
+ constructor(navMesh, params) {
278
+ super();
279
+ this.navMesh = navMesh;
280
+ this.navMeshGeometry = new BufferGeometry();
281
+ this.navMeshMaterial = params?.navMeshMaterial ? params.navMeshMaterial : new MeshBasicMaterial({
282
+ color: 'orange',
283
+ transparent: true,
284
+ opacity: 0.7,
285
+ depthWrite: false
286
+ });
287
+ this.update();
288
+ this.mesh = new Mesh(this.navMeshGeometry, this.navMeshMaterial);
289
+ this.add(this.mesh);
290
+ }
291
+ /**
292
+ * Update the three debug nav mesh.
293
+ *
294
+ * This should be called after updating the nav mesh.
295
+ */
296
+ update() {
297
+ const [positions, indices] = this.navMesh.getDebugNavMesh();
298
+ this.navMeshGeometry.setAttribute('position', new BufferAttribute(Float32Array.from(positions), 3));
299
+ this.navMeshGeometry.setIndex(new BufferAttribute(Uint32Array.from(indices), 1));
300
+ this.navMeshGeometry.computeVertexNormals();
301
+ }
302
+ }
303
+
304
+ class OffMeshConnectionsHelper extends Object3D {
305
+ constructor(offMeshConnections, params) {
306
+ super();
307
+ this.offMeshConnections = offMeshConnections ?? [];
308
+ this.entryCircleMaterial = params?.entryCircleMaterial ?? new MeshBasicMaterial({
309
+ color: 'green'
310
+ });
311
+ this.exitCircleMaterial = params?.exitCircleMaterial ?? new MeshBasicMaterial({
312
+ color: 'blue'
313
+ });
314
+ this.lineMaterial = params?.lineMaterial ?? new LineBasicMaterial({
315
+ color: 'red'
316
+ });
317
+ this.update();
318
+ }
319
+ /**
320
+ * Update the three debug view of the off mesh connections.
321
+ */
322
+ update() {
323
+ this.clear();
324
+ for (const offMeshConnection of this.offMeshConnections) {
325
+ // start and end circles
326
+ const circleGeometry = new CircleGeometry(offMeshConnection.radius, 16);
327
+ const startMesh = new Mesh(circleGeometry, this.entryCircleMaterial);
328
+ startMesh.position.copy(offMeshConnection.startPosition);
329
+ startMesh.position.y += 0.001;
330
+ startMesh.rotation.x = -Math.PI / 2;
331
+ this.add(startMesh);
332
+ const endMesh = new Mesh(circleGeometry, offMeshConnection.bidirectional ? this.entryCircleMaterial : this.exitCircleMaterial);
333
+ endMesh.position.copy(offMeshConnection.endPosition);
334
+ endMesh.position.y += 0.001;
335
+ endMesh.rotation.x = -Math.PI / 2;
336
+ this.add(endMesh);
337
+ // line between points
338
+ const start = new Vector3().copy(offMeshConnection.startPosition);
339
+ const end = new Vector3().copy(offMeshConnection.endPosition);
340
+ const middle = new Vector3().addVectors(start, end).multiplyScalar(0.5);
341
+ middle.y *= 1.2;
342
+ const curve = new CatmullRomCurve3([start, middle, end]);
343
+ const curvePoints = curve.getPoints(50);
344
+ const lineGeometry = new BufferGeometry().setFromPoints(curvePoints);
345
+ const line = new Line(lineGeometry, this.lineMaterial);
346
+ this.add(line);
347
+ }
348
+ }
349
+ }
350
+
351
+ class TileCacheHelper extends Object3D {
352
+ obstacleMeshes = new Map();
353
+ constructor(tileCache, params) {
354
+ super();
355
+ this.tileCache = tileCache;
356
+ this.obstacleMaterial = params?.obstacleMaterial ? params.obstacleMaterial : new MeshBasicMaterial({
357
+ color: 'red',
358
+ wireframe: true,
359
+ wireframeLinewidth: 2
360
+ });
361
+ this.update();
362
+ }
363
+ /**
364
+ * Update the obstacle meshes.
365
+ *
366
+ * This should be called after adding or removing obstacles.
367
+ */
368
+ update() {
369
+ const unseen = new Set(this.obstacleMeshes.keys());
370
+ for (const [, obstacle] of this.tileCache.obstacles) {
371
+ const obstacleMesh = this.obstacleMeshes.get(obstacle);
372
+ unseen.delete(obstacle);
373
+ if (!obstacleMesh) {
374
+ const {
375
+ position
376
+ } = obstacle;
377
+ const mesh = new Mesh(undefined, this.obstacleMaterial);
378
+ mesh.position.copy(position);
379
+ if (obstacle.type === 'box') {
380
+ const {
381
+ halfExtents,
382
+ angle
383
+ } = obstacle;
384
+ mesh.geometry = new BoxGeometry(halfExtents.x * 2, halfExtents.y * 2, halfExtents.z * 2);
385
+ mesh.rotation.y = angle;
386
+ } else if (obstacle.type === 'cylinder') {
387
+ const {
388
+ radius,
389
+ height
390
+ } = obstacle;
391
+ mesh.geometry = new CylinderGeometry(radius, radius, height, 16);
392
+ mesh.position.y += height / 2;
393
+ } else {
394
+ throw new Error(`Unknown obstacle type: ${obstacle}`);
395
+ }
396
+ this.add(mesh);
397
+ this.obstacleMeshes.set(obstacle, mesh);
398
+ }
399
+ }
400
+ for (const obstacle of unseen) {
401
+ const obstacleMesh = this.obstacleMeshes.get(obstacle);
402
+ if (obstacleMesh) {
403
+ this.remove(obstacleMesh);
404
+ this.obstacleMeshes.delete(obstacle);
405
+ }
406
+ }
407
+ }
408
+ }
409
+
410
+ const _position = new Vector3();
411
+ const getPositionsAndIndices = meshes => {
412
+ const toMerge = [];
413
+ for (const mesh of meshes) {
414
+ const positionAttribute = mesh.geometry.attributes.position;
415
+ if (!positionAttribute || positionAttribute.itemSize !== 3) {
416
+ continue;
417
+ }
418
+ mesh.updateMatrixWorld();
419
+ const positions = new Float32Array(positionAttribute.array);
420
+ for (let i = 0; i < positions.length; i += 3) {
421
+ const pos = _position.set(positions[i], positions[i + 1], positions[i + 2]);
422
+ mesh.localToWorld(pos);
423
+ positions[i] = pos.x;
424
+ positions[i + 1] = pos.y;
425
+ positions[i + 2] = pos.z;
426
+ }
427
+ let indices = mesh.geometry.getIndex()?.array;
428
+ if (indices === undefined) {
429
+ // this will become indexed when merging with other meshes
430
+ const ascendingIndex = [];
431
+ for (let i = 0; i < positionAttribute.count; i++) {
432
+ ascendingIndex.push(i);
433
+ }
434
+ indices = ascendingIndex;
435
+ }
436
+ toMerge.push({
437
+ positions,
438
+ indices
439
+ });
440
+ }
441
+ return mergePositionsAndIndices(toMerge);
442
+ };
443
+
444
+ const threeToSoloNavMesh = (meshes, navMeshGeneratorConfig = {}, keepIntermediates = false) => {
445
+ const [positions, indices] = getPositionsAndIndices(meshes);
446
+ return generateSoloNavMesh(positions, indices, navMeshGeneratorConfig, keepIntermediates);
447
+ };
448
+ const threeToTiledNavMesh = (meshes, navMeshGeneratorConfig = {}, keepIntermediates = false) => {
449
+ const [positions, indices] = getPositionsAndIndices(meshes);
450
+ return generateTiledNavMesh(positions, indices, navMeshGeneratorConfig, keepIntermediates);
451
+ };
452
+ const threeToTileCache = (meshes, navMeshGeneratorConfig = {}, keepIntermediates = false) => {
453
+ const [positions, indices] = getPositionsAndIndices(meshes);
454
+ return generateTileCache(positions, indices, navMeshGeneratorConfig, keepIntermediates);
455
+ };
456
+
457
+ export { CrowdHelper, DebugDrawer, NavMeshHelper, OffMeshConnectionsHelper, TileCacheHelper, getPositionsAndIndices, threeToSoloNavMesh, threeToTileCache, threeToTiledNavMesh };
package/package.json CHANGED
@@ -6,7 +6,7 @@
6
6
  "email": "isaac@isaacmason.com",
7
7
  "url": "https://isaacmason.com/"
8
8
  },
9
- "version": "0.34.0",
9
+ "version": "0.35.1",
10
10
  "license": "MIT",
11
11
  "homepage": "https://github.com/isaac-mason/recast-navigation-js",
12
12
  "bugs": {
@@ -27,8 +27,8 @@
27
27
  "lint": "eslint src"
28
28
  },
29
29
  "dependencies": {
30
- "@recast-navigation/core": "0.34.0",
31
- "@recast-navigation/generators": "0.34.0"
30
+ "@recast-navigation/core": "0.35.1",
31
+ "@recast-navigation/generators": "0.35.1"
32
32
  },
33
33
  "peerDependencies": {
34
34
  "@types/three": "0.x.x",
@@ -42,15 +42,14 @@
42
42
  "@rollup/plugin-babel": "^6.0.4",
43
43
  "@rollup/plugin-commonjs": "^25.0.7",
44
44
  "@rollup/plugin-node-resolve": "^15.0.1",
45
- "@rollup/plugin-terser": "^0.4.3",
46
45
  "@rollup/plugin-typescript": "^11.1.6",
47
- "@types/three": "^0.167.1",
46
+ "@types/three": "^0.169.0",
48
47
  "eslint": "^9.6.0",
49
48
  "prettier": "^3.1.0",
50
49
  "rollup": "^4.14.0",
51
50
  "rollup-plugin-copy": "^3.4.0",
52
51
  "rollup-plugin-filesize": "^10.0.0",
53
- "three": "^0.167.1",
52
+ "three": "^0.169.0",
54
53
  "typescript": "^5.4.3"
55
54
  },
56
55
  "packageManager": "yarn@3.2.1"
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.mjs","sources":["../../../node_modules/three/examples/jsm/lines/LineSegmentsGeometry.js","../../../node_modules/three/examples/jsm/lines/LineMaterial.js","../../../node_modules/three/examples/jsm/lines/LineSegments2.js","../src/debug/debug-drawer.ts","../src/helpers/crowd-helper.ts","../src/helpers/nav-mesh-helper.ts","../src/helpers/off-mesh-connections-helper.ts","../src/helpers/tile-cache-helper.ts","../src/utils/get-positions-and-indices.ts","../src/utils/generators.ts"],"sourcesContent":["import {\n\tBox3,\n\tFloat32BufferAttribute,\n\tInstancedBufferGeometry,\n\tInstancedInterleavedBuffer,\n\tInterleavedBufferAttribute,\n\tSphere,\n\tVector3,\n\tWireframeGeometry\n} from 'three';\n\nconst _box = new Box3();\nconst _vector = new Vector3();\n\nclass LineSegmentsGeometry extends InstancedBufferGeometry {\n\n\tconstructor() {\n\n\t\tsuper();\n\n\t\tthis.isLineSegmentsGeometry = true;\n\n\t\tthis.type = 'LineSegmentsGeometry';\n\n\t\tconst positions = [ - 1, 2, 0, 1, 2, 0, - 1, 1, 0, 1, 1, 0, - 1, 0, 0, 1, 0, 0, - 1, - 1, 0, 1, - 1, 0 ];\n\t\tconst uvs = [ - 1, 2, 1, 2, - 1, 1, 1, 1, - 1, - 1, 1, - 1, - 1, - 2, 1, - 2 ];\n\t\tconst index = [ 0, 2, 1, 2, 3, 1, 2, 4, 3, 4, 5, 3, 4, 6, 5, 6, 7, 5 ];\n\n\t\tthis.setIndex( index );\n\t\tthis.setAttribute( 'position', new Float32BufferAttribute( positions, 3 ) );\n\t\tthis.setAttribute( 'uv', new Float32BufferAttribute( uvs, 2 ) );\n\n\t}\n\n\tapplyMatrix4( matrix ) {\n\n\t\tconst start = this.attributes.instanceStart;\n\t\tconst end = this.attributes.instanceEnd;\n\n\t\tif ( start !== undefined ) {\n\n\t\t\tstart.applyMatrix4( matrix );\n\n\t\t\tend.applyMatrix4( matrix );\n\n\t\t\tstart.needsUpdate = true;\n\n\t\t}\n\n\t\tif ( this.boundingBox !== null ) {\n\n\t\t\tthis.computeBoundingBox();\n\n\t\t}\n\n\t\tif ( this.boundingSphere !== null ) {\n\n\t\t\tthis.computeBoundingSphere();\n\n\t\t}\n\n\t\treturn this;\n\n\t}\n\n\tsetPositions( array ) {\n\n\t\tlet lineSegments;\n\n\t\tif ( array instanceof Float32Array ) {\n\n\t\t\tlineSegments = array;\n\n\t\t} else if ( Array.isArray( array ) ) {\n\n\t\t\tlineSegments = new Float32Array( array );\n\n\t\t}\n\n\t\tconst instanceBuffer = new InstancedInterleavedBuffer( lineSegments, 6, 1 ); // xyz, xyz\n\n\t\tthis.setAttribute( 'instanceStart', new InterleavedBufferAttribute( instanceBuffer, 3, 0 ) ); // xyz\n\t\tthis.setAttribute( 'instanceEnd', new InterleavedBufferAttribute( instanceBuffer, 3, 3 ) ); // xyz\n\n\t\t//\n\n\t\tthis.computeBoundingBox();\n\t\tthis.computeBoundingSphere();\n\n\t\treturn this;\n\n\t}\n\n\tsetColors( array ) {\n\n\t\tlet colors;\n\n\t\tif ( array instanceof Float32Array ) {\n\n\t\t\tcolors = array;\n\n\t\t} else if ( Array.isArray( array ) ) {\n\n\t\t\tcolors = new Float32Array( array );\n\n\t\t}\n\n\t\tconst instanceColorBuffer = new InstancedInterleavedBuffer( colors, 6, 1 ); // rgb, rgb\n\n\t\tthis.setAttribute( 'instanceColorStart', new InterleavedBufferAttribute( instanceColorBuffer, 3, 0 ) ); // rgb\n\t\tthis.setAttribute( 'instanceColorEnd', new InterleavedBufferAttribute( instanceColorBuffer, 3, 3 ) ); // rgb\n\n\t\treturn this;\n\n\t}\n\n\tfromWireframeGeometry( geometry ) {\n\n\t\tthis.setPositions( geometry.attributes.position.array );\n\n\t\treturn this;\n\n\t}\n\n\tfromEdgesGeometry( geometry ) {\n\n\t\tthis.setPositions( geometry.attributes.position.array );\n\n\t\treturn this;\n\n\t}\n\n\tfromMesh( mesh ) {\n\n\t\tthis.fromWireframeGeometry( new WireframeGeometry( mesh.geometry ) );\n\n\t\t// set colors, maybe\n\n\t\treturn this;\n\n\t}\n\n\tfromLineSegments( lineSegments ) {\n\n\t\tconst geometry = lineSegments.geometry;\n\n\t\tthis.setPositions( geometry.attributes.position.array ); // assumes non-indexed\n\n\t\t// set colors, maybe\n\n\t\treturn this;\n\n\t}\n\n\tcomputeBoundingBox() {\n\n\t\tif ( this.boundingBox === null ) {\n\n\t\t\tthis.boundingBox = new Box3();\n\n\t\t}\n\n\t\tconst start = this.attributes.instanceStart;\n\t\tconst end = this.attributes.instanceEnd;\n\n\t\tif ( start !== undefined && end !== undefined ) {\n\n\t\t\tthis.boundingBox.setFromBufferAttribute( start );\n\n\t\t\t_box.setFromBufferAttribute( end );\n\n\t\t\tthis.boundingBox.union( _box );\n\n\t\t}\n\n\t}\n\n\tcomputeBoundingSphere() {\n\n\t\tif ( this.boundingSphere === null ) {\n\n\t\t\tthis.boundingSphere = new Sphere();\n\n\t\t}\n\n\t\tif ( this.boundingBox === null ) {\n\n\t\t\tthis.computeBoundingBox();\n\n\t\t}\n\n\t\tconst start = this.attributes.instanceStart;\n\t\tconst end = this.attributes.instanceEnd;\n\n\t\tif ( start !== undefined && end !== undefined ) {\n\n\t\t\tconst center = this.boundingSphere.center;\n\n\t\t\tthis.boundingBox.getCenter( center );\n\n\t\t\tlet maxRadiusSq = 0;\n\n\t\t\tfor ( let i = 0, il = start.count; i < il; i ++ ) {\n\n\t\t\t\t_vector.fromBufferAttribute( start, i );\n\t\t\t\tmaxRadiusSq = Math.max( maxRadiusSq, center.distanceToSquared( _vector ) );\n\n\t\t\t\t_vector.fromBufferAttribute( end, i );\n\t\t\t\tmaxRadiusSq = Math.max( maxRadiusSq, center.distanceToSquared( _vector ) );\n\n\t\t\t}\n\n\t\t\tthis.boundingSphere.radius = Math.sqrt( maxRadiusSq );\n\n\t\t\tif ( isNaN( this.boundingSphere.radius ) ) {\n\n\t\t\t\tconsole.error( 'THREE.LineSegmentsGeometry.computeBoundingSphere(): Computed radius is NaN. The instanced position data is likely to have NaN values.', this );\n\n\t\t\t}\n\n\t\t}\n\n\t}\n\n\ttoJSON() {\n\n\t\t// todo\n\n\t}\n\n\tapplyMatrix( matrix ) {\n\n\t\tconsole.warn( 'THREE.LineSegmentsGeometry: applyMatrix() has been renamed to applyMatrix4().' );\n\n\t\treturn this.applyMatrix4( matrix );\n\n\t}\n\n}\n\nexport { LineSegmentsGeometry };\n","import {\n\tShaderLib,\n\tShaderMaterial,\n\tUniformsLib,\n\tUniformsUtils,\n\tVector2,\n} from 'three';\n\nUniformsLib.line = {\n\n\tworldUnits: { value: 1 },\n\tlinewidth: { value: 1 },\n\tresolution: { value: new Vector2( 1, 1 ) },\n\tdashOffset: { value: 0 },\n\tdashScale: { value: 1 },\n\tdashSize: { value: 1 },\n\tgapSize: { value: 1 } // todo FIX - maybe change to totalSize\n\n};\n\nShaderLib[ 'line' ] = {\n\n\tuniforms: UniformsUtils.merge( [\n\t\tUniformsLib.common,\n\t\tUniformsLib.fog,\n\t\tUniformsLib.line\n\t] ),\n\n\tvertexShader:\n\t/* glsl */`\n\t\t#include <common>\n\t\t#include <color_pars_vertex>\n\t\t#include <fog_pars_vertex>\n\t\t#include <logdepthbuf_pars_vertex>\n\t\t#include <clipping_planes_pars_vertex>\n\n\t\tuniform float linewidth;\n\t\tuniform vec2 resolution;\n\n\t\tattribute vec3 instanceStart;\n\t\tattribute vec3 instanceEnd;\n\n\t\tattribute vec3 instanceColorStart;\n\t\tattribute vec3 instanceColorEnd;\n\n\t\t#ifdef WORLD_UNITS\n\n\t\t\tvarying vec4 worldPos;\n\t\t\tvarying vec3 worldStart;\n\t\t\tvarying vec3 worldEnd;\n\n\t\t\t#ifdef USE_DASH\n\n\t\t\t\tvarying vec2 vUv;\n\n\t\t\t#endif\n\n\t\t#else\n\n\t\t\tvarying vec2 vUv;\n\n\t\t#endif\n\n\t\t#ifdef USE_DASH\n\n\t\t\tuniform float dashScale;\n\t\t\tattribute float instanceDistanceStart;\n\t\t\tattribute float instanceDistanceEnd;\n\t\t\tvarying float vLineDistance;\n\n\t\t#endif\n\n\t\tvoid trimSegment( const in vec4 start, inout vec4 end ) {\n\n\t\t\t// trim end segment so it terminates between the camera plane and the near plane\n\n\t\t\t// conservative estimate of the near plane\n\t\t\tfloat a = projectionMatrix[ 2 ][ 2 ]; // 3nd entry in 3th column\n\t\t\tfloat b = projectionMatrix[ 3 ][ 2 ]; // 3nd entry in 4th column\n\t\t\tfloat nearEstimate = - 0.5 * b / a;\n\n\t\t\tfloat alpha = ( nearEstimate - start.z ) / ( end.z - start.z );\n\n\t\t\tend.xyz = mix( start.xyz, end.xyz, alpha );\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\t#ifdef USE_COLOR\n\n\t\t\t\tvColor.xyz = ( position.y < 0.5 ) ? instanceColorStart : instanceColorEnd;\n\n\t\t\t#endif\n\n\t\t\t#ifdef USE_DASH\n\n\t\t\t\tvLineDistance = ( position.y < 0.5 ) ? dashScale * instanceDistanceStart : dashScale * instanceDistanceEnd;\n\t\t\t\tvUv = uv;\n\n\t\t\t#endif\n\n\t\t\tfloat aspect = resolution.x / resolution.y;\n\n\t\t\t// camera space\n\t\t\tvec4 start = modelViewMatrix * vec4( instanceStart, 1.0 );\n\t\t\tvec4 end = modelViewMatrix * vec4( instanceEnd, 1.0 );\n\n\t\t\t#ifdef WORLD_UNITS\n\n\t\t\t\tworldStart = start.xyz;\n\t\t\t\tworldEnd = end.xyz;\n\n\t\t\t#else\n\n\t\t\t\tvUv = uv;\n\n\t\t\t#endif\n\n\t\t\t// special case for perspective projection, and segments that terminate either in, or behind, the camera plane\n\t\t\t// clearly the gpu firmware has a way of addressing this issue when projecting into ndc space\n\t\t\t// but we need to perform ndc-space calculations in the shader, so we must address this issue directly\n\t\t\t// perhaps there is a more elegant solution -- WestLangley\n\n\t\t\tbool perspective = ( projectionMatrix[ 2 ][ 3 ] == - 1.0 ); // 4th entry in the 3rd column\n\n\t\t\tif ( perspective ) {\n\n\t\t\t\tif ( start.z < 0.0 && end.z >= 0.0 ) {\n\n\t\t\t\t\ttrimSegment( start, end );\n\n\t\t\t\t} else if ( end.z < 0.0 && start.z >= 0.0 ) {\n\n\t\t\t\t\ttrimSegment( end, start );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\t// clip space\n\t\t\tvec4 clipStart = projectionMatrix * start;\n\t\t\tvec4 clipEnd = projectionMatrix * end;\n\n\t\t\t// ndc space\n\t\t\tvec3 ndcStart = clipStart.xyz / clipStart.w;\n\t\t\tvec3 ndcEnd = clipEnd.xyz / clipEnd.w;\n\n\t\t\t// direction\n\t\t\tvec2 dir = ndcEnd.xy - ndcStart.xy;\n\n\t\t\t// account for clip-space aspect ratio\n\t\t\tdir.x *= aspect;\n\t\t\tdir = normalize( dir );\n\n\t\t\t#ifdef WORLD_UNITS\n\n\t\t\t\tvec3 worldDir = normalize( end.xyz - start.xyz );\n\t\t\t\tvec3 tmpFwd = normalize( mix( start.xyz, end.xyz, 0.5 ) );\n\t\t\t\tvec3 worldUp = normalize( cross( worldDir, tmpFwd ) );\n\t\t\t\tvec3 worldFwd = cross( worldDir, worldUp );\n\t\t\t\tworldPos = position.y < 0.5 ? start: end;\n\n\t\t\t\t// height offset\n\t\t\t\tfloat hw = linewidth * 0.5;\n\t\t\t\tworldPos.xyz += position.x < 0.0 ? hw * worldUp : - hw * worldUp;\n\n\t\t\t\t// don't extend the line if we're rendering dashes because we\n\t\t\t\t// won't be rendering the endcaps\n\t\t\t\t#ifndef USE_DASH\n\n\t\t\t\t\t// cap extension\n\t\t\t\t\tworldPos.xyz += position.y < 0.5 ? - hw * worldDir : hw * worldDir;\n\n\t\t\t\t\t// add width to the box\n\t\t\t\t\tworldPos.xyz += worldFwd * hw;\n\n\t\t\t\t\t// endcaps\n\t\t\t\t\tif ( position.y > 1.0 || position.y < 0.0 ) {\n\n\t\t\t\t\t\tworldPos.xyz -= worldFwd * 2.0 * hw;\n\n\t\t\t\t\t}\n\n\t\t\t\t#endif\n\n\t\t\t\t// project the worldpos\n\t\t\t\tvec4 clip = projectionMatrix * worldPos;\n\n\t\t\t\t// shift the depth of the projected points so the line\n\t\t\t\t// segments overlap neatly\n\t\t\t\tvec3 clipPose = ( position.y < 0.5 ) ? ndcStart : ndcEnd;\n\t\t\t\tclip.z = clipPose.z * clip.w;\n\n\t\t\t#else\n\n\t\t\t\tvec2 offset = vec2( dir.y, - dir.x );\n\t\t\t\t// undo aspect ratio adjustment\n\t\t\t\tdir.x /= aspect;\n\t\t\t\toffset.x /= aspect;\n\n\t\t\t\t// sign flip\n\t\t\t\tif ( position.x < 0.0 ) offset *= - 1.0;\n\n\t\t\t\t// endcaps\n\t\t\t\tif ( position.y < 0.0 ) {\n\n\t\t\t\t\toffset += - dir;\n\n\t\t\t\t} else if ( position.y > 1.0 ) {\n\n\t\t\t\t\toffset += dir;\n\n\t\t\t\t}\n\n\t\t\t\t// adjust for linewidth\n\t\t\t\toffset *= linewidth;\n\n\t\t\t\t// adjust for clip-space to screen-space conversion // maybe resolution should be based on viewport ...\n\t\t\t\toffset /= resolution.y;\n\n\t\t\t\t// select end\n\t\t\t\tvec4 clip = ( position.y < 0.5 ) ? clipStart : clipEnd;\n\n\t\t\t\t// back to clip space\n\t\t\t\toffset *= clip.w;\n\n\t\t\t\tclip.xy += offset;\n\n\t\t\t#endif\n\n\t\t\tgl_Position = clip;\n\n\t\t\tvec4 mvPosition = ( position.y < 0.5 ) ? start : end; // this is an approximation\n\n\t\t\t#include <logdepthbuf_vertex>\n\t\t\t#include <clipping_planes_vertex>\n\t\t\t#include <fog_vertex>\n\n\t\t}\n\t\t`,\n\n\tfragmentShader:\n\t/* glsl */`\n\t\tuniform vec3 diffuse;\n\t\tuniform float opacity;\n\t\tuniform float linewidth;\n\n\t\t#ifdef USE_DASH\n\n\t\t\tuniform float dashOffset;\n\t\t\tuniform float dashSize;\n\t\t\tuniform float gapSize;\n\n\t\t#endif\n\n\t\tvarying float vLineDistance;\n\n\t\t#ifdef WORLD_UNITS\n\n\t\t\tvarying vec4 worldPos;\n\t\t\tvarying vec3 worldStart;\n\t\t\tvarying vec3 worldEnd;\n\n\t\t\t#ifdef USE_DASH\n\n\t\t\t\tvarying vec2 vUv;\n\n\t\t\t#endif\n\n\t\t#else\n\n\t\t\tvarying vec2 vUv;\n\n\t\t#endif\n\n\t\t#include <common>\n\t\t#include <color_pars_fragment>\n\t\t#include <fog_pars_fragment>\n\t\t#include <logdepthbuf_pars_fragment>\n\t\t#include <clipping_planes_pars_fragment>\n\n\t\tvec2 closestLineToLine(vec3 p1, vec3 p2, vec3 p3, vec3 p4) {\n\n\t\t\tfloat mua;\n\t\t\tfloat mub;\n\n\t\t\tvec3 p13 = p1 - p3;\n\t\t\tvec3 p43 = p4 - p3;\n\n\t\t\tvec3 p21 = p2 - p1;\n\n\t\t\tfloat d1343 = dot( p13, p43 );\n\t\t\tfloat d4321 = dot( p43, p21 );\n\t\t\tfloat d1321 = dot( p13, p21 );\n\t\t\tfloat d4343 = dot( p43, p43 );\n\t\t\tfloat d2121 = dot( p21, p21 );\n\n\t\t\tfloat denom = d2121 * d4343 - d4321 * d4321;\n\n\t\t\tfloat numer = d1343 * d4321 - d1321 * d4343;\n\n\t\t\tmua = numer / denom;\n\t\t\tmua = clamp( mua, 0.0, 1.0 );\n\t\t\tmub = ( d1343 + d4321 * ( mua ) ) / d4343;\n\t\t\tmub = clamp( mub, 0.0, 1.0 );\n\n\t\t\treturn vec2( mua, mub );\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\t#include <clipping_planes_fragment>\n\n\t\t\t#ifdef USE_DASH\n\n\t\t\t\tif ( vUv.y < - 1.0 || vUv.y > 1.0 ) discard; // discard endcaps\n\n\t\t\t\tif ( mod( vLineDistance + dashOffset, dashSize + gapSize ) > dashSize ) discard; // todo - FIX\n\n\t\t\t#endif\n\n\t\t\tfloat alpha = opacity;\n\n\t\t\t#ifdef WORLD_UNITS\n\n\t\t\t\t// Find the closest points on the view ray and the line segment\n\t\t\t\tvec3 rayEnd = normalize( worldPos.xyz ) * 1e5;\n\t\t\t\tvec3 lineDir = worldEnd - worldStart;\n\t\t\t\tvec2 params = closestLineToLine( worldStart, worldEnd, vec3( 0.0, 0.0, 0.0 ), rayEnd );\n\n\t\t\t\tvec3 p1 = worldStart + lineDir * params.x;\n\t\t\t\tvec3 p2 = rayEnd * params.y;\n\t\t\t\tvec3 delta = p1 - p2;\n\t\t\t\tfloat len = length( delta );\n\t\t\t\tfloat norm = len / linewidth;\n\n\t\t\t\t#ifndef USE_DASH\n\n\t\t\t\t\t#ifdef USE_ALPHA_TO_COVERAGE\n\n\t\t\t\t\t\tfloat dnorm = fwidth( norm );\n\t\t\t\t\t\talpha = 1.0 - smoothstep( 0.5 - dnorm, 0.5 + dnorm, norm );\n\n\t\t\t\t\t#else\n\n\t\t\t\t\t\tif ( norm > 0.5 ) {\n\n\t\t\t\t\t\t\tdiscard;\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t#endif\n\n\t\t\t\t#endif\n\n\t\t\t#else\n\n\t\t\t\t#ifdef USE_ALPHA_TO_COVERAGE\n\n\t\t\t\t\t// artifacts appear on some hardware if a derivative is taken within a conditional\n\t\t\t\t\tfloat a = vUv.x;\n\t\t\t\t\tfloat b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;\n\t\t\t\t\tfloat len2 = a * a + b * b;\n\t\t\t\t\tfloat dlen = fwidth( len2 );\n\n\t\t\t\t\tif ( abs( vUv.y ) > 1.0 ) {\n\n\t\t\t\t\t\talpha = 1.0 - smoothstep( 1.0 - dlen, 1.0 + dlen, len2 );\n\n\t\t\t\t\t}\n\n\t\t\t\t#else\n\n\t\t\t\t\tif ( abs( vUv.y ) > 1.0 ) {\n\n\t\t\t\t\t\tfloat a = vUv.x;\n\t\t\t\t\t\tfloat b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;\n\t\t\t\t\t\tfloat len2 = a * a + b * b;\n\n\t\t\t\t\t\tif ( len2 > 1.0 ) discard;\n\n\t\t\t\t\t}\n\n\t\t\t\t#endif\n\n\t\t\t#endif\n\n\t\t\tvec4 diffuseColor = vec4( diffuse, alpha );\n\n\t\t\t#include <logdepthbuf_fragment>\n\t\t\t#include <color_fragment>\n\n\t\t\tgl_FragColor = vec4( diffuseColor.rgb, alpha );\n\n\t\t\t#include <tonemapping_fragment>\n\t\t\t#include <colorspace_fragment>\n\t\t\t#include <fog_fragment>\n\t\t\t#include <premultiplied_alpha_fragment>\n\n\t\t}\n\t\t`\n};\n\nclass LineMaterial extends ShaderMaterial {\n\n\tconstructor( parameters ) {\n\n\t\tsuper( {\n\n\t\t\ttype: 'LineMaterial',\n\n\t\t\tuniforms: UniformsUtils.clone( ShaderLib[ 'line' ].uniforms ),\n\n\t\t\tvertexShader: ShaderLib[ 'line' ].vertexShader,\n\t\t\tfragmentShader: ShaderLib[ 'line' ].fragmentShader,\n\n\t\t\tclipping: true // required for clipping support\n\n\t\t} );\n\n\t\tthis.isLineMaterial = true;\n\n\t\tthis.setValues( parameters );\n\n\t}\n\n\tget color() {\n\n\t\treturn this.uniforms.diffuse.value;\n\n\t}\n\n\tset color( value ) {\n\n\t\tthis.uniforms.diffuse.value = value;\n\n\t}\n\n\tget worldUnits() {\n\n\t\treturn 'WORLD_UNITS' in this.defines;\n\n\t}\n\n\tset worldUnits( value ) {\n\n\t\tif ( value === true ) {\n\n\t\t\tthis.defines.WORLD_UNITS = '';\n\n\t\t} else {\n\n\t\t\tdelete this.defines.WORLD_UNITS;\n\n\t\t}\n\n\t}\n\n\tget linewidth() {\n\n\t\treturn this.uniforms.linewidth.value;\n\n\t}\n\n\tset linewidth( value ) {\n\n\t\tif ( ! this.uniforms.linewidth ) return;\n\t\tthis.uniforms.linewidth.value = value;\n\n\t}\n\n\tget dashed() {\n\n\t\treturn 'USE_DASH' in this.defines;\n\n\t}\n\n\tset dashed( value ) {\n\n\t\tif ( ( value === true ) !== this.dashed ) {\n\n\t\t\tthis.needsUpdate = true;\n\n\t\t}\n\n\t\tif ( value === true ) {\n\n\t\t\tthis.defines.USE_DASH = '';\n\n\t\t} else {\n\n\t\t\tdelete this.defines.USE_DASH;\n\n\t\t}\n\n\t}\n\n\tget dashScale() {\n\n\t\treturn this.uniforms.dashScale.value;\n\n\t}\n\n\tset dashScale( value ) {\n\n\t\tthis.uniforms.dashScale.value = value;\n\n\t}\n\n\tget dashSize() {\n\n\t\treturn this.uniforms.dashSize.value;\n\n\t}\n\n\tset dashSize( value ) {\n\n\t\tthis.uniforms.dashSize.value = value;\n\n\t}\n\n\tget dashOffset() {\n\n\t\treturn this.uniforms.dashOffset.value;\n\n\t}\n\n\tset dashOffset( value ) {\n\n\t\tthis.uniforms.dashOffset.value = value;\n\n\t}\n\n\tget gapSize() {\n\n\t\treturn this.uniforms.gapSize.value;\n\n\t}\n\n\tset gapSize( value ) {\n\n\t\tthis.uniforms.gapSize.value = value;\n\n\t}\n\n\tget opacity() {\n\n\t\treturn this.uniforms.opacity.value;\n\n\t}\n\n\tset opacity( value ) {\n\n\t\tif ( ! this.uniforms ) return;\n\t\tthis.uniforms.opacity.value = value;\n\n\t}\n\n\tget resolution() {\n\n\t\treturn this.uniforms.resolution.value;\n\n\t}\n\n\tset resolution( value ) {\n\n\t\tthis.uniforms.resolution.value.copy( value );\n\n\t}\n\n\tget alphaToCoverage() {\n\n\t\treturn 'USE_ALPHA_TO_COVERAGE' in this.defines;\n\n\t}\n\n\tset alphaToCoverage( value ) {\n\n\t\tif ( ! this.defines ) return;\n\n\t\tif ( ( value === true ) !== this.alphaToCoverage ) {\n\n\t\t\tthis.needsUpdate = true;\n\n\t\t}\n\n\t\tif ( value === true ) {\n\n\t\t\tthis.defines.USE_ALPHA_TO_COVERAGE = '';\n\n\t\t} else {\n\n\t\t\tdelete this.defines.USE_ALPHA_TO_COVERAGE;\n\n\t\t}\n\n\t}\n\n}\n\nexport { LineMaterial };\n","import {\n\tBox3,\n\tInstancedInterleavedBuffer,\n\tInterleavedBufferAttribute,\n\tLine3,\n\tMathUtils,\n\tMatrix4,\n\tMesh,\n\tSphere,\n\tVector3,\n\tVector4\n} from 'three';\nimport { LineSegmentsGeometry } from '../lines/LineSegmentsGeometry.js';\nimport { LineMaterial } from '../lines/LineMaterial.js';\n\nconst _viewport = new Vector4();\n\nconst _start = new Vector3();\nconst _end = new Vector3();\n\nconst _start4 = new Vector4();\nconst _end4 = new Vector4();\n\nconst _ssOrigin = new Vector4();\nconst _ssOrigin3 = new Vector3();\nconst _mvMatrix = new Matrix4();\nconst _line = new Line3();\nconst _closestPoint = new Vector3();\n\nconst _box = new Box3();\nconst _sphere = new Sphere();\nconst _clipToWorldVector = new Vector4();\n\nlet _ray, _lineWidth;\n\n// Returns the margin required to expand by in world space given the distance from the camera,\n// line width, resolution, and camera projection\nfunction getWorldSpaceHalfWidth( camera, distance, resolution ) {\n\n\t// transform into clip space, adjust the x and y values by the pixel width offset, then\n\t// transform back into world space to get world offset. Note clip space is [-1, 1] so full\n\t// width does not need to be halved.\n\t_clipToWorldVector.set( 0, 0, - distance, 1.0 ).applyMatrix4( camera.projectionMatrix );\n\t_clipToWorldVector.multiplyScalar( 1.0 / _clipToWorldVector.w );\n\t_clipToWorldVector.x = _lineWidth / resolution.width;\n\t_clipToWorldVector.y = _lineWidth / resolution.height;\n\t_clipToWorldVector.applyMatrix4( camera.projectionMatrixInverse );\n\t_clipToWorldVector.multiplyScalar( 1.0 / _clipToWorldVector.w );\n\n\treturn Math.abs( Math.max( _clipToWorldVector.x, _clipToWorldVector.y ) );\n\n}\n\nfunction raycastWorldUnits( lineSegments, intersects ) {\n\n\tconst matrixWorld = lineSegments.matrixWorld;\n\tconst geometry = lineSegments.geometry;\n\tconst instanceStart = geometry.attributes.instanceStart;\n\tconst instanceEnd = geometry.attributes.instanceEnd;\n\tconst segmentCount = Math.min( geometry.instanceCount, instanceStart.count );\n\n\tfor ( let i = 0, l = segmentCount; i < l; i ++ ) {\n\n\t\t_line.start.fromBufferAttribute( instanceStart, i );\n\t\t_line.end.fromBufferAttribute( instanceEnd, i );\n\n\t\t_line.applyMatrix4( matrixWorld );\n\n\t\tconst pointOnLine = new Vector3();\n\t\tconst point = new Vector3();\n\n\t\t_ray.distanceSqToSegment( _line.start, _line.end, point, pointOnLine );\n\t\tconst isInside = point.distanceTo( pointOnLine ) < _lineWidth * 0.5;\n\n\t\tif ( isInside ) {\n\n\t\t\tintersects.push( {\n\t\t\t\tpoint,\n\t\t\t\tpointOnLine,\n\t\t\t\tdistance: _ray.origin.distanceTo( point ),\n\t\t\t\tobject: lineSegments,\n\t\t\t\tface: null,\n\t\t\t\tfaceIndex: i,\n\t\t\t\tuv: null,\n\t\t\t\tuv1: null,\n\t\t\t} );\n\n\t\t}\n\n\t}\n\n}\n\nfunction raycastScreenSpace( lineSegments, camera, intersects ) {\n\n\tconst projectionMatrix = camera.projectionMatrix;\n\tconst material = lineSegments.material;\n\tconst resolution = material.resolution;\n\tconst matrixWorld = lineSegments.matrixWorld;\n\n\tconst geometry = lineSegments.geometry;\n\tconst instanceStart = geometry.attributes.instanceStart;\n\tconst instanceEnd = geometry.attributes.instanceEnd;\n\tconst segmentCount = Math.min( geometry.instanceCount, instanceStart.count );\n\n\tconst near = - camera.near;\n\n\t//\n\n\t// pick a point 1 unit out along the ray to avoid the ray origin\n\t// sitting at the camera origin which will cause \"w\" to be 0 when\n\t// applying the projection matrix.\n\t_ray.at( 1, _ssOrigin );\n\n\t// ndc space [ - 1.0, 1.0 ]\n\t_ssOrigin.w = 1;\n\t_ssOrigin.applyMatrix4( camera.matrixWorldInverse );\n\t_ssOrigin.applyMatrix4( projectionMatrix );\n\t_ssOrigin.multiplyScalar( 1 / _ssOrigin.w );\n\n\t// screen space\n\t_ssOrigin.x *= resolution.x / 2;\n\t_ssOrigin.y *= resolution.y / 2;\n\t_ssOrigin.z = 0;\n\n\t_ssOrigin3.copy( _ssOrigin );\n\n\t_mvMatrix.multiplyMatrices( camera.matrixWorldInverse, matrixWorld );\n\n\tfor ( let i = 0, l = segmentCount; i < l; i ++ ) {\n\n\t\t_start4.fromBufferAttribute( instanceStart, i );\n\t\t_end4.fromBufferAttribute( instanceEnd, i );\n\n\t\t_start4.w = 1;\n\t\t_end4.w = 1;\n\n\t\t// camera space\n\t\t_start4.applyMatrix4( _mvMatrix );\n\t\t_end4.applyMatrix4( _mvMatrix );\n\n\t\t// skip the segment if it's entirely behind the camera\n\t\tconst isBehindCameraNear = _start4.z > near && _end4.z > near;\n\t\tif ( isBehindCameraNear ) {\n\n\t\t\tcontinue;\n\n\t\t}\n\n\t\t// trim the segment if it extends behind camera near\n\t\tif ( _start4.z > near ) {\n\n\t\t\tconst deltaDist = _start4.z - _end4.z;\n\t\t\tconst t = ( _start4.z - near ) / deltaDist;\n\t\t\t_start4.lerp( _end4, t );\n\n\t\t} else if ( _end4.z > near ) {\n\n\t\t\tconst deltaDist = _end4.z - _start4.z;\n\t\t\tconst t = ( _end4.z - near ) / deltaDist;\n\t\t\t_end4.lerp( _start4, t );\n\n\t\t}\n\n\t\t// clip space\n\t\t_start4.applyMatrix4( projectionMatrix );\n\t\t_end4.applyMatrix4( projectionMatrix );\n\n\t\t// ndc space [ - 1.0, 1.0 ]\n\t\t_start4.multiplyScalar( 1 / _start4.w );\n\t\t_end4.multiplyScalar( 1 / _end4.w );\n\n\t\t// screen space\n\t\t_start4.x *= resolution.x / 2;\n\t\t_start4.y *= resolution.y / 2;\n\n\t\t_end4.x *= resolution.x / 2;\n\t\t_end4.y *= resolution.y / 2;\n\n\t\t// create 2d segment\n\t\t_line.start.copy( _start4 );\n\t\t_line.start.z = 0;\n\n\t\t_line.end.copy( _end4 );\n\t\t_line.end.z = 0;\n\n\t\t// get closest point on ray to segment\n\t\tconst param = _line.closestPointToPointParameter( _ssOrigin3, true );\n\t\t_line.at( param, _closestPoint );\n\n\t\t// check if the intersection point is within clip space\n\t\tconst zPos = MathUtils.lerp( _start4.z, _end4.z, param );\n\t\tconst isInClipSpace = zPos >= - 1 && zPos <= 1;\n\n\t\tconst isInside = _ssOrigin3.distanceTo( _closestPoint ) < _lineWidth * 0.5;\n\n\t\tif ( isInClipSpace && isInside ) {\n\n\t\t\t_line.start.fromBufferAttribute( instanceStart, i );\n\t\t\t_line.end.fromBufferAttribute( instanceEnd, i );\n\n\t\t\t_line.start.applyMatrix4( matrixWorld );\n\t\t\t_line.end.applyMatrix4( matrixWorld );\n\n\t\t\tconst pointOnLine = new Vector3();\n\t\t\tconst point = new Vector3();\n\n\t\t\t_ray.distanceSqToSegment( _line.start, _line.end, point, pointOnLine );\n\n\t\t\tintersects.push( {\n\t\t\t\tpoint: point,\n\t\t\t\tpointOnLine: pointOnLine,\n\t\t\t\tdistance: _ray.origin.distanceTo( point ),\n\t\t\t\tobject: lineSegments,\n\t\t\t\tface: null,\n\t\t\t\tfaceIndex: i,\n\t\t\t\tuv: null,\n\t\t\t\tuv1: null,\n\t\t\t} );\n\n\t\t}\n\n\t}\n\n}\n\nclass LineSegments2 extends Mesh {\n\n\tconstructor( geometry = new LineSegmentsGeometry(), material = new LineMaterial( { color: Math.random() * 0xffffff } ) ) {\n\n\t\tsuper( geometry, material );\n\n\t\tthis.isLineSegments2 = true;\n\n\t\tthis.type = 'LineSegments2';\n\n\t}\n\n\t// for backwards-compatibility, but could be a method of LineSegmentsGeometry...\n\n\tcomputeLineDistances() {\n\n\t\tconst geometry = this.geometry;\n\n\t\tconst instanceStart = geometry.attributes.instanceStart;\n\t\tconst instanceEnd = geometry.attributes.instanceEnd;\n\t\tconst lineDistances = new Float32Array( 2 * instanceStart.count );\n\n\t\tfor ( let i = 0, j = 0, l = instanceStart.count; i < l; i ++, j += 2 ) {\n\n\t\t\t_start.fromBufferAttribute( instanceStart, i );\n\t\t\t_end.fromBufferAttribute( instanceEnd, i );\n\n\t\t\tlineDistances[ j ] = ( j === 0 ) ? 0 : lineDistances[ j - 1 ];\n\t\t\tlineDistances[ j + 1 ] = lineDistances[ j ] + _start.distanceTo( _end );\n\n\t\t}\n\n\t\tconst instanceDistanceBuffer = new InstancedInterleavedBuffer( lineDistances, 2, 1 ); // d0, d1\n\n\t\tgeometry.setAttribute( 'instanceDistanceStart', new InterleavedBufferAttribute( instanceDistanceBuffer, 1, 0 ) ); // d0\n\t\tgeometry.setAttribute( 'instanceDistanceEnd', new InterleavedBufferAttribute( instanceDistanceBuffer, 1, 1 ) ); // d1\n\n\t\treturn this;\n\n\t}\n\n\traycast( raycaster, intersects ) {\n\n\t\tconst worldUnits = this.material.worldUnits;\n\t\tconst camera = raycaster.camera;\n\n\t\tif ( camera === null && ! worldUnits ) {\n\n\t\t\tconsole.error( 'LineSegments2: \"Raycaster.camera\" needs to be set in order to raycast against LineSegments2 while worldUnits is set to false.' );\n\n\t\t}\n\n\t\tconst threshold = ( raycaster.params.Line2 !== undefined ) ? raycaster.params.Line2.threshold || 0 : 0;\n\n\t\t_ray = raycaster.ray;\n\n\t\tconst matrixWorld = this.matrixWorld;\n\t\tconst geometry = this.geometry;\n\t\tconst material = this.material;\n\n\t\t_lineWidth = material.linewidth + threshold;\n\n\t\t// check if we intersect the sphere bounds\n\t\tif ( geometry.boundingSphere === null ) {\n\n\t\t\tgeometry.computeBoundingSphere();\n\n\t\t}\n\n\t\t_sphere.copy( geometry.boundingSphere ).applyMatrix4( matrixWorld );\n\n\t\t// increase the sphere bounds by the worst case line screen space width\n\t\tlet sphereMargin;\n\t\tif ( worldUnits ) {\n\n\t\t\tsphereMargin = _lineWidth * 0.5;\n\n\t\t} else {\n\n\t\t\tconst distanceToSphere = Math.max( camera.near, _sphere.distanceToPoint( _ray.origin ) );\n\t\t\tsphereMargin = getWorldSpaceHalfWidth( camera, distanceToSphere, material.resolution );\n\n\t\t}\n\n\t\t_sphere.radius += sphereMargin;\n\n\t\tif ( _ray.intersectsSphere( _sphere ) === false ) {\n\n\t\t\treturn;\n\n\t\t}\n\n\t\t// check if we intersect the box bounds\n\t\tif ( geometry.boundingBox === null ) {\n\n\t\t\tgeometry.computeBoundingBox();\n\n\t\t}\n\n\t\t_box.copy( geometry.boundingBox ).applyMatrix4( matrixWorld );\n\n\t\t// increase the box bounds by the worst case line width\n\t\tlet boxMargin;\n\t\tif ( worldUnits ) {\n\n\t\t\tboxMargin = _lineWidth * 0.5;\n\n\t\t} else {\n\n\t\t\tconst distanceToBox = Math.max( camera.near, _box.distanceToPoint( _ray.origin ) );\n\t\t\tboxMargin = getWorldSpaceHalfWidth( camera, distanceToBox, material.resolution );\n\n\t\t}\n\n\t\t_box.expandByScalar( boxMargin );\n\n\t\tif ( _ray.intersectsBox( _box ) === false ) {\n\n\t\t\treturn;\n\n\t\t}\n\n\t\tif ( worldUnits ) {\n\n\t\t\traycastWorldUnits( this, intersects );\n\n\t\t} else {\n\n\t\t\traycastScreenSpace( this, camera, intersects );\n\n\t\t}\n\n\t}\n\n\tonBeforeRender( renderer ) {\n\n\t\tconst uniforms = this.material.uniforms;\n\n\t\tif ( uniforms && uniforms.resolution ) {\n\n\t\t\trenderer.getViewport( _viewport );\n\t\t\tthis.material.uniforms.resolution.value.set( _viewport.z, _viewport.w );\n\n\t\t}\n\n\t}\n\n}\n\nexport { LineSegments2 };\n",null,null,null,null,null,null,null],"names":["_box","Box3","_vector","Vector3","LineSegmentsGeometry","InstancedBufferGeometry","constructor","super","this","isLineSegmentsGeometry","type","setIndex","setAttribute","Float32BufferAttribute","applyMatrix4","matrix","start","attributes","instanceStart","end","instanceEnd","undefined","needsUpdate","boundingBox","computeBoundingBox","boundingSphere","computeBoundingSphere","setPositions","array","lineSegments","Float32Array","Array","isArray","instanceBuffer","InstancedInterleavedBuffer","InterleavedBufferAttribute","setColors","colors","instanceColorBuffer","fromWireframeGeometry","geometry","position","fromEdgesGeometry","fromMesh","mesh","WireframeGeometry","fromLineSegments","setFromBufferAttribute","union","Sphere","center","getCenter","maxRadiusSq","i","il","count","fromBufferAttribute","Math","max","distanceToSquared","radius","sqrt","isNaN","console","error","toJSON","applyMatrix","warn","UniformsLib","line","worldUnits","value","linewidth","resolution","Vector2","dashOffset","dashScale","dashSize","gapSize","ShaderLib","uniforms","UniformsUtils","merge","common","fog","vertexShader","fragmentShader","LineMaterial","ShaderMaterial","parameters","clone","clipping","isLineMaterial","setValues","color","diffuse","defines","WORLD_UNITS","dashed","USE_DASH","opacity","copy","alphaToCoverage","USE_ALPHA_TO_COVERAGE","_viewport","Vector4","_start","_end","_start4","_end4","_ssOrigin","_ssOrigin3","_mvMatrix","Matrix4","_line","Line3","_closestPoint","_sphere","_clipToWorldVector","_ray","_lineWidth","getWorldSpaceHalfWidth","camera","distance","set","projectionMatrix","multiplyScalar","w","x","width","y","height","projectionMatrixInverse","abs","LineSegments2","Mesh","material","random","isLineSegments2","computeLineDistances","lineDistances","j","l","distanceTo","instanceDistanceBuffer","raycast","raycaster","intersects","threshold","params","Line2","ray","matrixWorld","sphereMargin","boxMargin","near","distanceToPoint","origin","intersectsSphere","expandByScalar","intersectsBox","min","instanceCount","pointOnLine","point","distanceSqToSegment","push","object","face","faceIndex","uv","uv1","raycastWorldUnits","segmentCount","at","matrixWorldInverse","z","multiplyMatrices","deltaDist","t","lerp","param","closestPointToPointParameter","zPos","MathUtils","isInClipSpace","isInside","raycastScreenSpace","onBeforeRender","renderer","getViewport","_color","THREE","Color","DebugDrawer","Group","pointGeometry","SphereGeometry","currentVertices","currentPrimitive","triMaterial","pointMaterial","lineMaterial","MeshBasicMaterial","vertexColors","transparent","depthWrite","polygonOffset","polygonOffsetFactor","polygonOffsetUnits","debugDrawImpl","Raw","Module","DebugDrawImpl","handleBegin","primitive","_size","handleDepthMask","_state","handleTexture","handleVertexWithColor","vertex","handleVertexWithColorAndUV","_u","_v","handleEnd","DU_DRAW_LINES","endLines","DU_DRAW_TRIS","endTris","DU_DRAW_QUADS","endQuads","DU_DRAW_POINTS","endPoints","drawHeightfieldSolid","hf","RecastDebugDraw","debugDrawHeightfieldSolid","raw","drawHeightfieldWalkable","debugDrawHeightfieldWalkable","drawCompactHeightfieldSolid","chf","debugDrawCompactHeightfieldSolid","drawCompactHeightfieldRegions","debugDrawCompactHeightfieldRegions","drawCompactHeightfieldDistance","debugDrawCompactHeightfieldDistance","drawHeightfieldLayer","layer","idx","debugDrawHeightfieldLayer","drawHeightfieldLayers","lset","debugDrawHeightfieldLayers","drawRegionConnections","cset","alpha","debugDrawRegionConnections","drawRawContours","debugDrawRawContours","drawContours","debugDrawContours","drawPolyMesh","debugDrawPolyMesh","drawPolyMeshDetail","dmesh","debugDrawPolyMeshDetail","drawNavMesh","flags","DetourDebugDraw","debugDrawNavMesh","getNavMesh","drawNavMeshWithClosedList","query","debugDrawNavMeshWithClosedList","m_navMesh","m_navQuery","drawNavMeshNodes","debugDrawNavMeshNodes","drawNavMeshBVTree","debugDrawNavMeshBVTree","drawNavMeshPortals","debugDrawNavMeshPortals","drawNavMeshPolysWithFlags","col","debugDrawNavMeshPolysWithFlags","drawNavMeshPoly","ref","debugDrawNavMeshPoly","reset","child","children","dispose","clear","destroy","r","g","b","a","instancedMesh","InstancedMesh","length","setMatrixAt","setPosition","setColorAt","setRGB","instanceMatrix","add","lineSegmentsGeometry","positions","x1","y1","z1","r1","g1","b1","x2","y2","z2","r2","g2","b2","BufferGeometry","BufferAttribute","vertices","CrowdHelper","Object3D","agentMeshes","Map","crowd","agentMaterial","recastCrowd","update","agents","getAgents","unseen","Set","keys","agent","delete","agentIndex","velocity","agentMesh","get","createAgentMesh","updateAgentGeometry","lookAt","agentId","remove","userData","agentParams","CylinderGeometry","NavMeshHelper","navMesh","navMeshMaterial","indices","getDebugNavMesh","from","Uint32Array","computeVertexNormals","OffMeshConnectionsHelper","offMeshConnections","entryCircleMaterial","exitCircleMaterial","LineBasicMaterial","offMeshConnection","circleGeometry","CircleGeometry","startMesh","startPosition","rotation","PI","endMesh","bidirectional","endPosition","middle","addVectors","curvePoints","CatmullRomCurve3","getPoints","lineGeometry","setFromPoints","Line","TileCacheHelper","obstacleMeshes","tileCache","obstacleMaterial","wireframe","wireframeLinewidth","obstacle","obstacles","obstacleMesh","halfExtents","angle","BoxGeometry","Error","tmpVec3","getPositionsAndIndices","meshes","meshesToMerge","positionAttribute","itemSize","meshToMerge","index","getIndex","ascendingIndex","mergedPositions","mergedIndices","positionToIndex","indexCounter","updateMatrixWorld","pt","pos","localToWorld","key","threeToSoloNavMesh","navMeshGeneratorConfig","keepIntermediates","generateSoloNavMesh","threeToTiledNavMesh","generateTiledNavMesh","threeToTileCache","generateTileCache"],"mappings":"mtBAWA,MAAMA,EAAO,IAAIC,EACXC,EAAU,IAAIC,EAEpB,MAAMC,UAA6BC,EAElC,WAAAC,GAECC,QAEAC,KAAKC,wBAAyB,EAE9BD,KAAKE,KAAO,uBAMZF,KAAKG,SAFS,CAAE,EAAG,EAAG,EAAG,EAAG,EAAG,EAAG,EAAG,EAAG,EAAG,EAAG,EAAG,EAAG,EAAG,EAAG,EAAG,EAAG,EAAG,IAGnEH,KAAKI,aAAc,WAAY,IAAIC,EALjB,EAAI,EAAG,EAAG,EAAG,EAAG,EAAG,GAAK,EAAG,EAAG,EAAG,EAAG,EAAG,GAAK,EAAG,EAAG,EAAG,EAAG,EAAG,GAAK,GAAK,EAAG,EAAG,GAAK,EAAG,GAK/B,IACtEL,KAAKI,aAAc,KAAM,IAAIC,EALjB,EAAI,EAAG,EAAG,EAAG,GAAK,EAAG,EAAG,EAAG,GAAK,GAAK,EAAG,GAAK,GAAK,GAAK,EAAG,GAAK,GAKjB,GAE1D,CAED,YAAAC,CAAcC,GAEb,MAAMC,EAAQR,KAA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