three-base 2.0.137 → 2.0.142
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/DirectionalLight.d.ts +6 -6
- package/DirectionalLight.js +68 -68
- package/DirectionalLight.ts +70 -0
- package/EventMap.d.ts +103 -0
- package/EventMap.js +17 -0
- package/EventMap.ts +139 -0
- package/EventMesh.d.ts +18 -18
- package/EventMesh.js +59 -59
- package/EventMesh.ts +60 -0
- package/ExtrudeMesh.d.ts +112 -112
- package/ExtrudeMesh.js +342 -366
- package/ExtrudeMesh.ts +553 -0
- package/FPScontrol.d.ts +511 -78
- package/FPScontrol.js +1799 -617
- package/FPScontrol.ts +1855 -0
- package/Fire/Fire.d.ts +28 -28
- package/Fire/Fire.js +80 -79
- package/Fire/Fire.ts +89 -0
- package/Fire/{FireGromtry.d.ts → FireGeometry.d.ts} +9 -9
- package/Fire/{FireGromtry.js → FireGeometry.js} +40 -40
- package/Fire/FireGeometry.ts +40 -0
- package/Fire/FireMaterial.d.ts +28 -28
- package/Fire/FireMaterial.js +32 -32
- package/Fire/FireMaterial.ts +89 -0
- package/Fire/index.d.ts +2 -1
- package/Fire/index.js +2 -1
- package/Fire/index.ts +2 -0
- package/GLTFDracoLoader.d.ts +71 -0
- package/GLTFDracoLoader.js +266 -0
- package/GLTFDracoLoader.ts +430 -0
- package/Grass/Grass.d.ts +8 -8
- package/Grass/Grass.js +38 -38
- package/Grass/Grass.ts +38 -0
- package/Grass/index.d.ts +2 -1
- package/Grass/index.js +2 -1
- package/Grass/index.ts +2 -0
- package/Ground1/Ground1.d.ts +10 -11
- package/Ground1/Ground1.js +95 -91
- package/Ground1/Ground1.ts +114 -0
- package/Ground1/index.d.ts +1 -1
- package/Ground1/index.js +1 -1
- package/Ground1/index.ts +1 -0
- package/MeshBase.d.ts +36 -35
- package/MeshBase.js +247 -223
- package/MeshBase.ts +253 -0
- package/Mirror.d.ts +25 -25
- package/Mirror.js +143 -139
- package/Mirror.ts +203 -0
- package/MktMesh/MktMesh.d.ts +291 -0
- package/MktMesh/MktMesh.js +1045 -0
- package/MktMesh/MktMesh.ts +1075 -0
- package/MktMesh/assetUrl.d.ts +35 -0
- package/MktMesh/assetUrl.js +69 -0
- package/MktMesh/assetUrl.ts +69 -0
- package/MktMesh/mktMappingShader.d.ts +12 -0
- package/MktMesh/mktMappingShader.js +139 -0
- package/MktMesh/mktMappingShader.ts +139 -0
- package/MktMesh/mktShader.d.ts +263 -0
- package/MktMesh/mktShader.js +1248 -0
- package/MktMesh/mktShader.ts +1344 -0
- package/MktMesh/panoBitmapTexture.d.ts +25 -0
- package/MktMesh/panoBitmapTexture.js +52 -0
- package/MktMesh/panoBitmapTexture.ts +54 -0
- package/MktMesh/panoSlotBind.d.ts +29 -0
- package/MktMesh/panoSlotBind.js +106 -0
- package/MktMesh/panoSlotBind.ts +153 -0
- package/MktMesh/panoSlotRoster.d.ts +22 -0
- package/MktMesh/panoSlotRoster.js +169 -0
- package/MktMesh/panoSlotRoster.ts +168 -0
- package/MktMesh/panoTileStitcher.d.ts +119 -0
- package/MktMesh/panoTileStitcher.js +533 -0
- package/MktMesh/panoTileStitcher.ts +616 -0
- package/MktMesh/types.d.ts +75 -0
- package/MktMesh/types.js +1 -0
- package/MktMesh/types.ts +87 -0
- package/MktMesh/wallCapTessellate.d.ts +33 -0
- package/MktMesh/wallCapTessellate.js +97 -0
- package/MktMesh/wallCapTessellate.ts +68 -0
- package/PipeMesh/PathGeometry.d.ts +44 -44
- package/PipeMesh/PathGeometry.js +307 -300
- package/PipeMesh/PathGeometry.ts +343 -0
- package/PipeMesh/PathPoint.d.ts +17 -17
- package/PipeMesh/PathPoint.js +31 -31
- package/PipeMesh/PathPoint.ts +36 -0
- package/PipeMesh/PathPointList.d.ts +31 -31
- package/PipeMesh/PathPointList.js +209 -208
- package/PipeMesh/PathPointList.ts +227 -0
- package/PipeMesh/PathTubeGeometry.d.ts +25 -25
- package/PipeMesh/PathTubeGeometry.js +130 -130
- package/PipeMesh/PathTubeGeometry.ts +146 -0
- package/PipeMesh/PipeMesh.d.ts +25 -25
- package/PipeMesh/PipeMesh.js +63 -63
- package/PipeMesh/PipeMesh.ts +76 -0
- package/PipeMesh/index.d.ts +1 -1
- package/PipeMesh/index.js +1 -1
- package/PipeMesh/index.ts +1 -0
- package/PlaneModal1/PlaneModal1.d.ts +34 -31
- package/PlaneModal1/PlaneModal1.js +109 -105
- package/PlaneModal1/PlaneModal1.ts +138 -0
- package/PlaneModal1/index.d.ts +1 -1
- package/PlaneModal1/index.js +1 -1
- package/PlaneModal1/index.ts +1 -0
- package/PlaneText.d.ts +27 -39
- package/PlaneText.js +35 -30
- package/PlaneText.ts +55 -0
- package/PlaneWithHtml.d.ts +13 -11
- package/PlaneWithHtml.js +64 -63
- package/PlaneWithHtml.ts +70 -0
- package/PointLight/PointLight.d.ts +13 -14
- package/PointLight/PointLight.js +64 -70
- package/PointLight/PointLight.ts +67 -0
- package/PointLight/index.d.ts +1 -1
- package/PointLight/index.js +1 -1
- package/PointLight/index.ts +1 -0
- package/README.md +110 -79
- package/Sky/Sky.d.ts +9 -9
- package/Sky/Sky.js +22 -22
- package/Sky/Sky.ts +22 -0
- package/Sky/index.d.ts +1 -1
- package/Sky/index.js +1 -1
- package/Sky/index.ts +1 -0
- package/SpotLight.d.ts +6 -6
- package/SpotLight.js +72 -72
- package/SpotLight.ts +74 -0
- package/SpriteModal1/SpriteModal1.d.ts +33 -30
- package/SpriteModal1/SpriteModal1.js +116 -110
- package/SpriteModal1/SpriteModal1.ts +146 -0
- package/SpriteModal1/index.d.ts +1 -1
- package/SpriteModal1/index.js +1 -1
- package/SpriteModal1/index.ts +1 -0
- package/SpriteText.d.ts +46 -45
- package/SpriteText.js +176 -163
- package/SpriteText.ts +205 -0
- package/SpriteText2.d.ts +48 -47
- package/SpriteText2.js +223 -198
- package/SpriteText2.ts +258 -0
- package/SpriteText3.d.ts +86 -0
- package/SpriteText3.js +519 -0
- package/SpriteText3.ts +599 -0
- package/SpriteWithHtml.d.ts +9 -7
- package/SpriteWithHtml.js +44 -44
- package/SpriteWithHtml.ts +50 -0
- package/Text3D/Text3D.d.ts +20 -20
- package/Text3D/Text3D.js +58 -62
- package/Text3D/Text3D.ts +77 -0
- package/Text3D/fontController.d.ts +60 -59
- package/Text3D/fontController.js +166 -199
- package/Text3D/fontController.ts +209 -0
- package/Text3D/index.d.ts +1 -1
- package/Text3D/index.js +1 -1
- package/Text3D/index.ts +1 -0
- package/ThreeBase.d.ts +248 -111
- package/ThreeBase.js +1202 -656
- package/ThreeBase.ts +1314 -0
- package/ThreeMouse.d.ts +54 -40
- package/ThreeMouse.js +453 -407
- package/ThreeMouse.ts +472 -0
- package/Transition.d.ts +45 -40
- package/Transition.js +209 -210
- package/Transition.ts +242 -0
- package/Water/Water.d.ts +5 -5
- package/Water/Water.js +44 -26
- package/Water/Water.ts +45 -0
- package/Water/index.d.ts +2 -0
- package/Water/index.js +2 -0
- package/Water/index.ts +2 -0
- package/WaterFlow/FloatingDuck.d.ts +88 -0
- package/WaterFlow/FloatingDuck.js +307 -0
- package/WaterFlow/FloatingDuck.ts +445 -0
- package/WaterFlow/GPUFluidSimulation.d.ts +56 -0
- package/WaterFlow/GPUFluidSimulation.js +785 -0
- package/WaterFlow/GPUFluidSimulation.ts +827 -0
- package/WaterFlow/ReservoirSystem.d.ts +106 -0
- package/WaterFlow/ReservoirSystem.js +621 -0
- package/WaterFlow/ReservoirSystem.ts +754 -0
- package/WaterFlow/SPHField.d.ts +35 -0
- package/WaterFlow/SPHField.js +204 -0
- package/WaterFlow/SPHField.ts +228 -0
- package/WaterFlow/ScreenSpaceFluidPass.d.ts +69 -0
- package/WaterFlow/ScreenSpaceFluidPass.js +736 -0
- package/WaterFlow/ScreenSpaceFluidPass.ts +789 -0
- package/WaterFlow/ShallowWaterSurface.d.ts +45 -0
- package/WaterFlow/ShallowWaterSurface.js +441 -0
- package/WaterFlow/ShallowWaterSurface.ts +510 -0
- package/WaterFlow/WaterFlow.d.ts +87 -0
- package/WaterFlow/WaterFlow.js +171 -0
- package/WaterFlow/WaterFlow.ts +219 -0
- package/WaterFlow/types.d.ts +161 -0
- package/WaterFlow/types.js +1 -0
- package/WaterFlow/types.ts +189 -0
- package/WaterFlow/waterFlowPass.d.ts +3 -0
- package/WaterFlow/waterFlowPass.js +20 -0
- package/WaterFlow/waterFlowPass.ts +40 -0
- package/collisionOBB.d.ts +42 -0
- package/collisionOBB.js +112 -0
- package/collisionOBB.ts +108 -0
- package/declare.d.ts +23 -165
- package/index.d.ts +1 -1
- package/index.js +1 -2
- package/index.ts +1 -0
- package/instanced/InstancedBatch.d.ts +57 -0
- package/instanced/InstancedBatch.js +348 -0
- package/instanced/InstancedBatch.ts +406 -0
- package/instanced/InstancedChild.d.ts +174 -0
- package/instanced/InstancedChild.js +264 -0
- package/instanced/InstancedChild.ts +327 -0
- package/instanced/InstancedGroup.d.ts +43 -0
- package/instanced/InstancedGroup.js +126 -0
- package/instanced/InstancedGroup.ts +137 -0
- package/{InstancedMeshBase.d.ts → instanced/InstancedMeshBase.d.ts} +38 -39
- package/{InstancedMeshBase.js → instanced/InstancedMeshBase.js} +282 -293
- package/instanced/InstancedMeshBase.ts +292 -0
- package/instanced/InstancedTemplate.d.ts +46 -0
- package/instanced/InstancedTemplate.js +125 -0
- package/instanced/InstancedTemplate.ts +188 -0
- package/keyControls.d.ts +30 -0
- package/{keyContorls.js → keyControls.js} +101 -98
- package/keyControls.ts +107 -0
- package/lensflare/LensFlare.d.ts +39 -0
- package/lensflare/LensFlare.js +373 -0
- package/lensflare/LensFlare.ts +448 -0
- package/lensflare/lensflare0.png +0 -0
- package/lensflare/lensflare3.png +0 -0
- package/lensflare/lensflare_custom.png +0 -0
- package/lensflare/lensflare_hex_ghost.png +0 -0
- package/lensflare/lensflare_hex_main.png +0 -0
- package/package.json +99 -25
- package/pass/bloom_pass.d.ts +2 -2
- package/pass/bloom_pass.js +188 -101
- package/pass/bloom_pass.ts +243 -0
- package/pass/cover_pass.d.ts +2 -2
- package/pass/cover_pass.js +122 -99
- package/pass/cover_pass.ts +182 -0
- package/pass/debugDepthState.d.ts +20 -0
- package/pass/debugDepthState.js +9 -0
- package/pass/debugDepthState.ts +22 -0
- package/pass/depthTestBias.d.ts +12 -0
- package/pass/depthTestBias.js +12 -0
- package/pass/depthTestBias.ts +12 -0
- package/pass/effectUserData.d.ts +27 -0
- package/pass/effectUserData.js +1 -0
- package/pass/effectUserData.ts +46 -0
- package/pass/frosted_glass_pass.d.ts +2 -2
- package/pass/frosted_glass_pass.js +167 -186
- package/pass/frosted_glass_pass.ts +288 -0
- package/pass/fsQuad.d.ts +9 -9
- package/pass/fsQuad.js +28 -28
- package/pass/fsQuad.ts +34 -0
- package/pass/glow_pass.d.ts +2 -2
- package/pass/glow_pass.js +449 -233
- package/pass/glow_pass.ts +654 -0
- package/pass/screen_bloom_pass.d.ts +11 -0
- package/pass/screen_bloom_pass.js +235 -0
- package/pass/screen_bloom_pass.ts +263 -0
- package/pass/ssao_pass.d.ts +88 -13
- package/pass/ssao_pass.js +802 -366
- package/pass/ssao_pass.ts +918 -0
- package/pass/stroke_pass.d.ts +2 -2
- package/pass/stroke_pass.js +329 -258
- package/pass/stroke_pass.ts +638 -0
- package/shaders/FXAAShaderMaterial.d.ts +3 -3
- package/shaders/FXAAShaderMaterial.js +23 -66
- package/shaders/FXAAShaderMaterial.ts +201 -0
- package/shaders/baseDepthVisShader.d.ts +11 -0
- package/shaders/baseDepthVisShader.js +36 -0
- package/shaders/baseDepthVisShader.ts +36 -0
- package/shaders/baseTextureToRenderShader.d.ts +2 -2
- package/shaders/baseTextureToRenderShader.js +55 -60
- package/shaders/baseTextureToRenderShader.ts +232 -0
- package/shaders/copyShader.d.ts +3 -3
- package/shaders/copyShader.js +13 -14
- package/shaders/copyShader.ts +32 -0
- package/shaders/debugDepthCompareShader.d.ts +14 -0
- package/shaders/debugDepthCompareShader.js +49 -0
- package/shaders/debugDepthCompareShader.ts +50 -0
- package/shaders/debugDepthJudgeShader.d.ts +18 -0
- package/shaders/debugDepthJudgeShader.js +52 -0
- package/shaders/debugDepthJudgeShader.ts +54 -0
- package/shaders/debugExcludedShader.d.ts +13 -0
- package/shaders/debugExcludedShader.js +46 -0
- package/shaders/debugExcludedShader.ts +48 -0
- package/spriteTextBg.d.ts +1 -0
- package/spriteTextBg.js +20 -0
- package/spriteTextBg.ts +20 -0
- package/threeLoader.d.ts +35 -34
- package/threeLoader.js +518 -527
- package/threeLoader.ts +525 -0
- package/threeUtils.d.ts +53 -52
- package/threeUtils.js +329 -330
- package/threeUtils.ts +373 -0
- package/types.d.ts +2 -0
- package/types.js +6 -0
- package/types.ts +8 -0
- package/ApngTexture.d.ts +0 -13
- package/ApngTexture.js +0 -61
- package/ApngTextureManage.d.ts +0 -18
- package/ApngTextureManage.js +0 -87
- package/KeyFrameAnimation.d.ts +0 -25
- package/KeyFrameAnimation.js +0 -78
- package/keyContorls.d.ts +0 -25
- package/lib/draco/draco_decoder.js +0 -34
- package/lib/draco/draco_decoder.wasm +0 -0
- package/lib/draco/draco_wasm_wrapper.js +0 -117
- package/pass/emissive_ao_pass.d.ts +0 -13
- package/pass/emissive_ao_pass.js +0 -370
- package/shaders.d.ts +0 -5
- package/shaders.js +0 -93
|
@@ -1,208 +1,209 @@
|
|
|
1
|
-
import { Vector3 } from 'three/src/math/Vector3.js';
|
|
2
|
-
import { PathPoint } from './PathPoint.js';
|
|
3
|
-
import { Matrix4 } from 'three/src/math/Matrix4.js';
|
|
4
|
-
import { QuadraticBezierCurve3 } from 'three/src/extras/curves/QuadraticBezierCurve3.js';
|
|
5
|
-
const helpVec3_1 = new Vector3();
|
|
6
|
-
const helpVec3_2 = new Vector3();
|
|
7
|
-
const helpVec3_3 = new Vector3();
|
|
8
|
-
const helpMat4 = new Matrix4();
|
|
9
|
-
const helpCurve = new QuadraticBezierCurve3(new Vector3(), new Vector3(), new Vector3());
|
|
10
|
-
function _getCornerBezierCurve(last, current, next, cornerRadius, firstCorner, out) {
|
|
11
|
-
const lastDir = helpVec3_1.subVectors(current, last);
|
|
12
|
-
const nextDir = helpVec3_2.subVectors(next, current);
|
|
13
|
-
const lastDirLength = lastDir.length();
|
|
14
|
-
const nextDirLength = nextDir.length();
|
|
15
|
-
lastDir.normalize();
|
|
16
|
-
nextDir.normalize();
|
|
17
|
-
// cornerRadius can not bigger then lineDistance / 2, auto fix this
|
|
18
|
-
const v0Dist = Math.min((firstCorner ? lastDirLength / 2 : lastDirLength) * 0.999999, cornerRadius);
|
|
19
|
-
out.v0.copy(current).sub(lastDir.multiplyScalar(v0Dist));
|
|
20
|
-
out.v1.copy(current);
|
|
21
|
-
const v2Dist = Math.min((nextDirLength / 2) * 0.999999, cornerRadius);
|
|
22
|
-
out.v2.copy(current).add(nextDir.multiplyScalar(v2Dist));
|
|
23
|
-
return out;
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* PathPointList
|
|
27
|
-
* input points to generate a PathPoint list
|
|
28
|
-
*/
|
|
29
|
-
class PathPointList {
|
|
30
|
-
array = []; // path point array
|
|
31
|
-
count = 0;
|
|
32
|
-
constructor() { }
|
|
33
|
-
/**
|
|
34
|
-
* Set points
|
|
35
|
-
* @param {Vector3[]} points key points array
|
|
36
|
-
* @param {number} cornerRadius? the corner radius. set 0 to disable round corner. default is 0.1
|
|
37
|
-
* @param {number} cornerSplit? the corner split. default is 10.
|
|
38
|
-
* @param {number} up? force up. default is auto up (calculate by tangent).
|
|
39
|
-
* @param {boolean} close? close path. default is false.
|
|
40
|
-
*/
|
|
41
|
-
set(points, cornerRadius = 0.1, cornerSplit = 10, up, close = false) {
|
|
42
|
-
points = points.slice(0);
|
|
43
|
-
if (points.length < 2) {
|
|
44
|
-
console.warn('PathPointList: points length less than 2.');
|
|
45
|
-
this.count = 0;
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
// Auto close
|
|
49
|
-
if (close && !points[0].equals(points[points.length - 1])) {
|
|
50
|
-
points.push(new Vector3().copy(points[0]));
|
|
51
|
-
}
|
|
52
|
-
// Generate path point list
|
|
53
|
-
for (let i = 0, l = points.length; i < l; i++) {
|
|
54
|
-
if (i === 0) {
|
|
55
|
-
this._start(points[i], points[i + 1], up);
|
|
56
|
-
}
|
|
57
|
-
else if (i === l - 1) {
|
|
58
|
-
if (close) {
|
|
59
|
-
// Connect end point and start point
|
|
60
|
-
this._corner(points[i], points[1], cornerRadius, cornerSplit, up);
|
|
61
|
-
// Fix start point
|
|
62
|
-
const dist = this.array[0].dist; // should not copy dist
|
|
63
|
-
this.array[0].copy(this.array[this.count - 1]);
|
|
64
|
-
this.array[0].dist = dist;
|
|
65
|
-
}
|
|
66
|
-
else {
|
|
67
|
-
this._end(points[i]);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
else {
|
|
71
|
-
this._corner(points[i], points[i + 1], cornerRadius, cornerSplit, up);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* Get distance of this path
|
|
77
|
-
* @return {number}
|
|
78
|
-
*/
|
|
79
|
-
distance() {
|
|
80
|
-
if (this.count > 0) {
|
|
81
|
-
return this.array[this.count - 1].dist;
|
|
82
|
-
}
|
|
83
|
-
return 0;
|
|
84
|
-
}
|
|
85
|
-
_getByIndex(index) {
|
|
86
|
-
if (!this.array[index]) {
|
|
87
|
-
this.array[index] = new PathPoint();
|
|
88
|
-
}
|
|
89
|
-
return this.array[index];
|
|
90
|
-
}
|
|
91
|
-
_start(current, next, up) {
|
|
92
|
-
this.count = 0;
|
|
93
|
-
const point = this._getByIndex(this.count);
|
|
94
|
-
point.pos.copy(current);
|
|
95
|
-
point.dir.subVectors(next, current);
|
|
96
|
-
// init start up dir
|
|
97
|
-
if (up) {
|
|
98
|
-
point.up.copy(up);
|
|
99
|
-
}
|
|
100
|
-
else {
|
|
101
|
-
// select an initial normal vector perpendicular to the first tangent vector
|
|
102
|
-
let min = Number.MAX_VALUE;
|
|
103
|
-
const tx = Math.abs(point.dir.x);
|
|
104
|
-
const ty = Math.abs(point.dir.y);
|
|
105
|
-
const tz = Math.abs(point.dir.z);
|
|
106
|
-
if (tx < min) {
|
|
107
|
-
min = tx;
|
|
108
|
-
point.up.set(1, 0, 0);
|
|
109
|
-
}
|
|
110
|
-
if (ty < min) {
|
|
111
|
-
min = ty;
|
|
112
|
-
point.up.set(0, 1, 0);
|
|
113
|
-
}
|
|
114
|
-
if (tz < min) {
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
point.
|
|
120
|
-
point.
|
|
121
|
-
point.
|
|
122
|
-
point.
|
|
123
|
-
point.
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
const
|
|
129
|
-
point.
|
|
130
|
-
point.
|
|
131
|
-
|
|
132
|
-
point.dir.
|
|
133
|
-
point.
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
point.
|
|
142
|
-
point.
|
|
143
|
-
point.
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
const
|
|
150
|
-
const
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
const
|
|
166
|
-
const
|
|
167
|
-
const
|
|
168
|
-
const
|
|
169
|
-
lastDir.
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
point.dir.
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
point.
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
}
|
|
208
|
-
|
|
1
|
+
import { Vector3 } from 'three/src/math/Vector3.js';
|
|
2
|
+
import { PathPoint } from './PathPoint.js';
|
|
3
|
+
import { Matrix4 } from 'three/src/math/Matrix4.js';
|
|
4
|
+
import { QuadraticBezierCurve3 } from 'three/src/extras/curves/QuadraticBezierCurve3.js';
|
|
5
|
+
const helpVec3_1 = new Vector3();
|
|
6
|
+
const helpVec3_2 = new Vector3();
|
|
7
|
+
const helpVec3_3 = new Vector3();
|
|
8
|
+
const helpMat4 = new Matrix4();
|
|
9
|
+
const helpCurve = new QuadraticBezierCurve3(new Vector3(), new Vector3(), new Vector3());
|
|
10
|
+
function _getCornerBezierCurve(last, current, next, cornerRadius, firstCorner, out) {
|
|
11
|
+
const lastDir = helpVec3_1.subVectors(current, last);
|
|
12
|
+
const nextDir = helpVec3_2.subVectors(next, current);
|
|
13
|
+
const lastDirLength = lastDir.length();
|
|
14
|
+
const nextDirLength = nextDir.length();
|
|
15
|
+
lastDir.normalize();
|
|
16
|
+
nextDir.normalize();
|
|
17
|
+
// cornerRadius can not bigger then lineDistance / 2, auto fix this
|
|
18
|
+
const v0Dist = Math.min((firstCorner ? lastDirLength / 2 : lastDirLength) * 0.999999, cornerRadius);
|
|
19
|
+
out.v0.copy(current).sub(lastDir.multiplyScalar(v0Dist));
|
|
20
|
+
out.v1.copy(current);
|
|
21
|
+
const v2Dist = Math.min((nextDirLength / 2) * 0.999999, cornerRadius);
|
|
22
|
+
out.v2.copy(current).add(nextDir.multiplyScalar(v2Dist));
|
|
23
|
+
return out;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* PathPointList
|
|
27
|
+
* input points to generate a PathPoint list
|
|
28
|
+
*/
|
|
29
|
+
class PathPointList {
|
|
30
|
+
array = []; // path point array
|
|
31
|
+
count = 0;
|
|
32
|
+
constructor() { }
|
|
33
|
+
/**
|
|
34
|
+
* Set points
|
|
35
|
+
* @param {Vector3[]} points key points array
|
|
36
|
+
* @param {number} cornerRadius? the corner radius. set 0 to disable round corner. default is 0.1
|
|
37
|
+
* @param {number} cornerSplit? the corner split. default is 10.
|
|
38
|
+
* @param {number} up? force up. default is auto up (calculate by tangent).
|
|
39
|
+
* @param {boolean} close? close path. default is false.
|
|
40
|
+
*/
|
|
41
|
+
set(points, cornerRadius = 0.1, cornerSplit = 10, up, close = false) {
|
|
42
|
+
points = points.slice(0);
|
|
43
|
+
if (points.length < 2) {
|
|
44
|
+
console.warn('PathPointList: points length less than 2.');
|
|
45
|
+
this.count = 0;
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
// Auto close
|
|
49
|
+
if (close && !points[0].equals(points[points.length - 1])) {
|
|
50
|
+
points.push(new Vector3().copy(points[0]));
|
|
51
|
+
}
|
|
52
|
+
// Generate path point list
|
|
53
|
+
for (let i = 0, l = points.length; i < l; i++) {
|
|
54
|
+
if (i === 0) {
|
|
55
|
+
this._start(points[i], points[i + 1], up);
|
|
56
|
+
}
|
|
57
|
+
else if (i === l - 1) {
|
|
58
|
+
if (close) {
|
|
59
|
+
// Connect end point and start point
|
|
60
|
+
this._corner(points[i], points[1], cornerRadius, cornerSplit, up);
|
|
61
|
+
// Fix start point
|
|
62
|
+
const dist = this.array[0].dist; // should not copy dist
|
|
63
|
+
this.array[0].copy(this.array[this.count - 1]);
|
|
64
|
+
this.array[0].dist = dist;
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
this._end(points[i]);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
this._corner(points[i], points[i + 1], cornerRadius, cornerSplit, up);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Get distance of this path
|
|
77
|
+
* @return {number}
|
|
78
|
+
*/
|
|
79
|
+
distance() {
|
|
80
|
+
if (this.count > 0) {
|
|
81
|
+
return this.array[this.count - 1].dist;
|
|
82
|
+
}
|
|
83
|
+
return 0;
|
|
84
|
+
}
|
|
85
|
+
_getByIndex(index) {
|
|
86
|
+
if (!this.array[index]) {
|
|
87
|
+
this.array[index] = new PathPoint();
|
|
88
|
+
}
|
|
89
|
+
return this.array[index];
|
|
90
|
+
}
|
|
91
|
+
_start(current, next, up) {
|
|
92
|
+
this.count = 0;
|
|
93
|
+
const point = this._getByIndex(this.count);
|
|
94
|
+
point.pos.copy(current);
|
|
95
|
+
point.dir.subVectors(next, current);
|
|
96
|
+
// init start up dir
|
|
97
|
+
if (up) {
|
|
98
|
+
point.up.copy(up);
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
// select an initial normal vector perpendicular to the first tangent vector
|
|
102
|
+
let min = Number.MAX_VALUE;
|
|
103
|
+
const tx = Math.abs(point.dir.x);
|
|
104
|
+
const ty = Math.abs(point.dir.y);
|
|
105
|
+
const tz = Math.abs(point.dir.z);
|
|
106
|
+
if (tx < min) {
|
|
107
|
+
min = tx;
|
|
108
|
+
point.up.set(1, 0, 0);
|
|
109
|
+
}
|
|
110
|
+
if (ty < min) {
|
|
111
|
+
min = ty;
|
|
112
|
+
point.up.set(0, 1, 0);
|
|
113
|
+
}
|
|
114
|
+
if (tz < min) {
|
|
115
|
+
min = tz;
|
|
116
|
+
point.up.set(0, 0, 1);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
point.right.crossVectors(point.dir, point.up).normalize();
|
|
120
|
+
point.up.crossVectors(point.right, point.dir).normalize();
|
|
121
|
+
point.dist = 0;
|
|
122
|
+
point.widthScale = 1;
|
|
123
|
+
point.sharp = false;
|
|
124
|
+
point.dir.normalize();
|
|
125
|
+
this.count++;
|
|
126
|
+
}
|
|
127
|
+
_end(current) {
|
|
128
|
+
const lastPoint = this.array[this.count - 1];
|
|
129
|
+
const point = this._getByIndex(this.count);
|
|
130
|
+
point.pos.copy(current);
|
|
131
|
+
point.dir.subVectors(current, lastPoint.pos);
|
|
132
|
+
const dist = point.dir.length();
|
|
133
|
+
point.dir.normalize();
|
|
134
|
+
point.up.copy(lastPoint.up); // copy last up
|
|
135
|
+
const vec = helpVec3_1.crossVectors(lastPoint.dir, point.dir);
|
|
136
|
+
if (vec.length() > Number.EPSILON) {
|
|
137
|
+
vec.normalize();
|
|
138
|
+
const theta = Math.acos(Math.min(Math.max(lastPoint.dir.dot(point.dir), -1), 1)); // clamp for floating pt errors
|
|
139
|
+
point.up.applyMatrix4(helpMat4.makeRotationAxis(vec, theta));
|
|
140
|
+
}
|
|
141
|
+
point.right.crossVectors(point.dir, point.up).normalize();
|
|
142
|
+
point.dist = lastPoint.dist + dist;
|
|
143
|
+
point.widthScale = 1;
|
|
144
|
+
point.sharp = false;
|
|
145
|
+
this.count++;
|
|
146
|
+
}
|
|
147
|
+
_corner(current, next, cornerRadius, cornerSplit, up) {
|
|
148
|
+
if (cornerRadius > 0 && cornerSplit > 0) {
|
|
149
|
+
const lastPoint = this.array[this.count - 1];
|
|
150
|
+
const curve = _getCornerBezierCurve(lastPoint.pos, current, next, cornerRadius, this.count - 1 === 0, helpCurve);
|
|
151
|
+
const samplerPoints = curve.getPoints(cornerSplit);
|
|
152
|
+
for (let f = 0; f < cornerSplit; f++) {
|
|
153
|
+
this._sharpCorner(samplerPoints[f], samplerPoints[f + 1], up, f === 0 ? 1 : 0);
|
|
154
|
+
}
|
|
155
|
+
if (!samplerPoints[cornerSplit].equals(next)) {
|
|
156
|
+
this._sharpCorner(samplerPoints[cornerSplit], next, up, 2);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
else {
|
|
160
|
+
this._sharpCorner(current, next, up, 0, true);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
// dirType: 0 - use middle dir / 1 - use last dir / 2- use next dir
|
|
164
|
+
_sharpCorner(current, next, up, dirType = 0, sharp = false) {
|
|
165
|
+
const lastPoint = this.array[this.count - 1];
|
|
166
|
+
const point = this._getByIndex(this.count);
|
|
167
|
+
const lastDir = helpVec3_1.subVectors(current, lastPoint.pos);
|
|
168
|
+
const nextDir = helpVec3_2.subVectors(next, current);
|
|
169
|
+
const lastDirLength = lastDir.length();
|
|
170
|
+
lastDir.normalize();
|
|
171
|
+
nextDir.normalize();
|
|
172
|
+
point.pos.copy(current);
|
|
173
|
+
if (dirType === 1) {
|
|
174
|
+
point.dir.copy(lastDir);
|
|
175
|
+
}
|
|
176
|
+
else if (dirType === 2) {
|
|
177
|
+
point.dir.copy(nextDir);
|
|
178
|
+
}
|
|
179
|
+
else {
|
|
180
|
+
point.dir.addVectors(lastDir, nextDir);
|
|
181
|
+
point.dir.normalize();
|
|
182
|
+
}
|
|
183
|
+
if (up) {
|
|
184
|
+
if (point.dir.dot(up) === 1) {
|
|
185
|
+
point.right.crossVectors(nextDir, up).normalize();
|
|
186
|
+
}
|
|
187
|
+
else {
|
|
188
|
+
point.right.crossVectors(point.dir, up).normalize();
|
|
189
|
+
}
|
|
190
|
+
point.up.crossVectors(point.right, point.dir).normalize();
|
|
191
|
+
}
|
|
192
|
+
else {
|
|
193
|
+
point.up.copy(lastPoint.up);
|
|
194
|
+
const vec = helpVec3_3.crossVectors(lastPoint.dir, point.dir);
|
|
195
|
+
if (vec.length() > Number.EPSILON) {
|
|
196
|
+
vec.normalize();
|
|
197
|
+
const theta = Math.acos(Math.min(Math.max(lastPoint.dir.dot(point.dir), -1), 1)); // clamp for floating pt errors
|
|
198
|
+
point.up.applyMatrix4(helpMat4.makeRotationAxis(vec, theta));
|
|
199
|
+
}
|
|
200
|
+
point.right.crossVectors(point.dir, point.up).normalize();
|
|
201
|
+
}
|
|
202
|
+
point.dist = lastPoint.dist + lastDirLength;
|
|
203
|
+
const _cos = lastDir.dot(nextDir);
|
|
204
|
+
point.widthScale = Math.min(1 / Math.sqrt((1 + _cos) / 2), 1.415) || 1;
|
|
205
|
+
point.sharp = Math.abs(_cos - 1) > 0.05 && sharp;
|
|
206
|
+
this.count++;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
export { PathPointList };
|
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
import { Vector3 } from 'three/src/math/Vector3.js';
|
|
2
|
+
import { PathPoint } from './PathPoint.js';
|
|
3
|
+
import { Matrix4 } from 'three/src/math/Matrix4.js';
|
|
4
|
+
import { QuadraticBezierCurve3 } from 'three/src/extras/curves/QuadraticBezierCurve3.js';
|
|
5
|
+
|
|
6
|
+
const helpVec3_1: Vector3 = new Vector3();
|
|
7
|
+
const helpVec3_2: Vector3 = new Vector3();
|
|
8
|
+
const helpVec3_3: Vector3 = new Vector3();
|
|
9
|
+
const helpMat4: Matrix4 = new Matrix4();
|
|
10
|
+
const helpCurve: QuadraticBezierCurve3 = new QuadraticBezierCurve3(new Vector3(), new Vector3(), new Vector3());
|
|
11
|
+
|
|
12
|
+
interface CornerBezierCurve {
|
|
13
|
+
v0: Vector3;
|
|
14
|
+
v1: Vector3;
|
|
15
|
+
v2: Vector3;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function _getCornerBezierCurve(last: Vector3, current: Vector3, next: Vector3, cornerRadius: number, firstCorner: boolean, out: QuadraticBezierCurve3): QuadraticBezierCurve3 {
|
|
19
|
+
const lastDir = helpVec3_1.subVectors(current, last);
|
|
20
|
+
const nextDir = helpVec3_2.subVectors(next, current);
|
|
21
|
+
const lastDirLength = lastDir.length();
|
|
22
|
+
const nextDirLength = nextDir.length();
|
|
23
|
+
lastDir.normalize();
|
|
24
|
+
nextDir.normalize();
|
|
25
|
+
// cornerRadius can not bigger then lineDistance / 2, auto fix this
|
|
26
|
+
const v0Dist = Math.min((firstCorner ? lastDirLength / 2 : lastDirLength) * 0.999999, cornerRadius);
|
|
27
|
+
out.v0.copy(current).sub(lastDir.multiplyScalar(v0Dist));
|
|
28
|
+
out.v1.copy(current);
|
|
29
|
+
const v2Dist = Math.min((nextDirLength / 2) * 0.999999, cornerRadius);
|
|
30
|
+
out.v2.copy(current).add(nextDir.multiplyScalar(v2Dist));
|
|
31
|
+
return out;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* PathPointList
|
|
36
|
+
* input points to generate a PathPoint list
|
|
37
|
+
*/
|
|
38
|
+
class PathPointList {
|
|
39
|
+
array: Array<PathPoint> = []; // path point array
|
|
40
|
+
count: number = 0;
|
|
41
|
+
|
|
42
|
+
constructor() { }
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Set points
|
|
46
|
+
* @param {Vector3[]} points key points array
|
|
47
|
+
* @param {number} cornerRadius? the corner radius. set 0 to disable round corner. default is 0.1
|
|
48
|
+
* @param {number} cornerSplit? the corner split. default is 10.
|
|
49
|
+
* @param {number} up? force up. default is auto up (calculate by tangent).
|
|
50
|
+
* @param {boolean} close? close path. default is false.
|
|
51
|
+
*/
|
|
52
|
+
set(points: Array<Vector3>, cornerRadius: number = 0.1, cornerSplit: number = 10, up?: Vector3, close: boolean = false): void {
|
|
53
|
+
points = points.slice(0);
|
|
54
|
+
if (points.length < 2) {
|
|
55
|
+
console.warn('PathPointList: points length less than 2.');
|
|
56
|
+
this.count = 0;
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
// Auto close
|
|
60
|
+
if (close && !points[0].equals(points[points.length - 1])) {
|
|
61
|
+
points.push(new Vector3().copy(points[0]));
|
|
62
|
+
}
|
|
63
|
+
// Generate path point list
|
|
64
|
+
for (let i = 0, l = points.length; i < l; i++) {
|
|
65
|
+
if (i === 0) {
|
|
66
|
+
this._start(points[i], points[i + 1], up);
|
|
67
|
+
}
|
|
68
|
+
else if (i === l - 1) {
|
|
69
|
+
if (close) {
|
|
70
|
+
// Connect end point and start point
|
|
71
|
+
this._corner(points[i], points[1], cornerRadius, cornerSplit, up);
|
|
72
|
+
// Fix start point
|
|
73
|
+
const dist = this.array[0].dist; // should not copy dist
|
|
74
|
+
this.array[0].copy(this.array[this.count - 1]);
|
|
75
|
+
this.array[0].dist = dist;
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
this._end(points[i]);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
this._corner(points[i], points[i + 1], cornerRadius, cornerSplit, up);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Get distance of this path
|
|
89
|
+
* @return {number}
|
|
90
|
+
*/
|
|
91
|
+
distance(): number {
|
|
92
|
+
if (this.count > 0) {
|
|
93
|
+
return this.array[this.count - 1].dist;
|
|
94
|
+
}
|
|
95
|
+
return 0;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
_getByIndex(index: number): PathPoint {
|
|
99
|
+
if (!this.array[index]) {
|
|
100
|
+
this.array[index] = new PathPoint();
|
|
101
|
+
}
|
|
102
|
+
return this.array[index];
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
_start(current: Vector3, next: Vector3, up?: Vector3): void {
|
|
106
|
+
this.count = 0;
|
|
107
|
+
const point = this._getByIndex(this.count);
|
|
108
|
+
point.pos.copy(current);
|
|
109
|
+
point.dir.subVectors(next, current);
|
|
110
|
+
// init start up dir
|
|
111
|
+
if (up) {
|
|
112
|
+
point.up.copy(up);
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
// select an initial normal vector perpendicular to the first tangent vector
|
|
116
|
+
let min = Number.MAX_VALUE;
|
|
117
|
+
const tx = Math.abs(point.dir.x);
|
|
118
|
+
const ty = Math.abs(point.dir.y);
|
|
119
|
+
const tz = Math.abs(point.dir.z);
|
|
120
|
+
if (tx < min) {
|
|
121
|
+
min = tx;
|
|
122
|
+
point.up.set(1, 0, 0);
|
|
123
|
+
}
|
|
124
|
+
if (ty < min) {
|
|
125
|
+
min = ty;
|
|
126
|
+
point.up.set(0, 1, 0);
|
|
127
|
+
}
|
|
128
|
+
if (tz < min) {
|
|
129
|
+
min = tz;
|
|
130
|
+
point.up.set(0, 0, 1);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
point.right.crossVectors(point.dir, point.up).normalize();
|
|
134
|
+
point.up.crossVectors(point.right, point.dir).normalize();
|
|
135
|
+
point.dist = 0;
|
|
136
|
+
point.widthScale = 1;
|
|
137
|
+
point.sharp = false;
|
|
138
|
+
point.dir.normalize();
|
|
139
|
+
this.count++;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
_end(current: Vector3): void {
|
|
143
|
+
const lastPoint = this.array[this.count - 1];
|
|
144
|
+
const point = this._getByIndex(this.count);
|
|
145
|
+
point.pos.copy(current);
|
|
146
|
+
point.dir.subVectors(current, lastPoint.pos);
|
|
147
|
+
const dist = point.dir.length();
|
|
148
|
+
point.dir.normalize();
|
|
149
|
+
point.up.copy(lastPoint.up); // copy last up
|
|
150
|
+
const vec = helpVec3_1.crossVectors(lastPoint.dir, point.dir);
|
|
151
|
+
if (vec.length() > Number.EPSILON) {
|
|
152
|
+
vec.normalize();
|
|
153
|
+
const theta = Math.acos(Math.min(Math.max(lastPoint.dir.dot(point.dir), -1), 1)); // clamp for floating pt errors
|
|
154
|
+
point.up.applyMatrix4(helpMat4.makeRotationAxis(vec, theta));
|
|
155
|
+
}
|
|
156
|
+
point.right.crossVectors(point.dir, point.up).normalize();
|
|
157
|
+
point.dist = lastPoint.dist + dist;
|
|
158
|
+
point.widthScale = 1;
|
|
159
|
+
point.sharp = false;
|
|
160
|
+
this.count++;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
_corner(current: Vector3, next: Vector3, cornerRadius: number, cornerSplit: number, up?: Vector3): void {
|
|
164
|
+
if (cornerRadius > 0 && cornerSplit > 0) {
|
|
165
|
+
const lastPoint = this.array[this.count - 1];
|
|
166
|
+
const curve = _getCornerBezierCurve(lastPoint.pos, current, next, cornerRadius, this.count - 1 === 0, helpCurve);
|
|
167
|
+
const samplerPoints = curve.getPoints(cornerSplit);
|
|
168
|
+
for (let f = 0; f < cornerSplit; f++) {
|
|
169
|
+
this._sharpCorner(samplerPoints[f], samplerPoints[f + 1], up, f === 0 ? 1 : 0);
|
|
170
|
+
}
|
|
171
|
+
if (!samplerPoints[cornerSplit].equals(next)) {
|
|
172
|
+
this._sharpCorner(samplerPoints[cornerSplit], next, up, 2);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
else {
|
|
176
|
+
this._sharpCorner(current, next, up, 0, true);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
// dirType: 0 - use middle dir / 1 - use last dir / 2- use next dir
|
|
181
|
+
_sharpCorner(current: Vector3, next: Vector3, up?: Vector3, dirType: 0 | 1 | 2 = 0, sharp: boolean = false): void {
|
|
182
|
+
const lastPoint = this.array[this.count - 1];
|
|
183
|
+
const point = this._getByIndex(this.count);
|
|
184
|
+
const lastDir = helpVec3_1.subVectors(current, lastPoint.pos);
|
|
185
|
+
const nextDir = helpVec3_2.subVectors(next, current);
|
|
186
|
+
const lastDirLength = lastDir.length();
|
|
187
|
+
lastDir.normalize();
|
|
188
|
+
nextDir.normalize();
|
|
189
|
+
point.pos.copy(current);
|
|
190
|
+
if (dirType === 1) {
|
|
191
|
+
point.dir.copy(lastDir);
|
|
192
|
+
}
|
|
193
|
+
else if (dirType === 2) {
|
|
194
|
+
point.dir.copy(nextDir);
|
|
195
|
+
}
|
|
196
|
+
else {
|
|
197
|
+
point.dir.addVectors(lastDir, nextDir);
|
|
198
|
+
point.dir.normalize();
|
|
199
|
+
}
|
|
200
|
+
if (up) {
|
|
201
|
+
if (point.dir.dot(up) === 1) {
|
|
202
|
+
point.right.crossVectors(nextDir, up).normalize();
|
|
203
|
+
}
|
|
204
|
+
else {
|
|
205
|
+
point.right.crossVectors(point.dir, up).normalize();
|
|
206
|
+
}
|
|
207
|
+
point.up.crossVectors(point.right, point.dir).normalize();
|
|
208
|
+
}
|
|
209
|
+
else {
|
|
210
|
+
point.up.copy(lastPoint.up);
|
|
211
|
+
const vec = helpVec3_3.crossVectors(lastPoint.dir, point.dir);
|
|
212
|
+
if (vec.length() > Number.EPSILON) {
|
|
213
|
+
vec.normalize();
|
|
214
|
+
const theta = Math.acos(Math.min(Math.max(lastPoint.dir.dot(point.dir), -1), 1)); // clamp for floating pt errors
|
|
215
|
+
point.up.applyMatrix4(helpMat4.makeRotationAxis(vec, theta));
|
|
216
|
+
}
|
|
217
|
+
point.right.crossVectors(point.dir, point.up).normalize();
|
|
218
|
+
}
|
|
219
|
+
point.dist = lastPoint.dist + lastDirLength;
|
|
220
|
+
const _cos = lastDir.dot(nextDir);
|
|
221
|
+
point.widthScale = Math.min(1 / Math.sqrt((1 + _cos) / 2), 1.415) || 1;
|
|
222
|
+
point.sharp = Math.abs(_cos - 1) > 0.05 && sharp;
|
|
223
|
+
this.count++;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
export { PathPointList };
|