@xort/cga 0.0.93 → 0.1.0
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/THIRD_PARTY_NOTICES.md +47 -0
- package/build/@xort_cga.js +14187 -12097
- package/build/cga.d.ts +2284 -1983
- package/build/cga.esm.js +14179 -0
- package/dist/THIRD_PARTY_NOTICES.md +47 -0
- package/dist/index.cjs +14320 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +2358 -0
- package/dist/index.d.ts +2358 -38
- package/dist/index.js +14181 -56
- package/dist/index.js.map +1 -0
- package/package.json +59 -47
- package/readme.md +162 -247
- package/.github/FUNDING.yml +0 -12
- package/cga/1./347/202/271/344/270/216/347/272/277/346/200/247/345/205/203/347/264/240/347/232/204/350/267/235/347/246/273.html +0 -601
- package/cga/1./347/202/271/344/270/216/347/272/277/346/200/247/345/205/203/347/264/240/347/232/204/350/267/235/347/246/273.md +0 -111
- package/cga/2./347/202/271/344/270/216/351/235/242/346/200/247/345/205/203/347/264/240.md +0 -4
- package/cga/img//347/202/271/344/270/216/345/260/204/347/272/277.png +0 -0
- package/cga/img//347/202/271/344/270/216/347/233/264/347/272/277.png +0 -0
- package/cga/img//347/202/271/344/270/216/347/272/277/346/256/265.png +0 -0
- package/cga/img//347/233/264/347/272/277/347/232/204/350/241/250/350/276/276/345/274/217.png +0 -0
- package/deploy.sh +0 -39
- package/dist/IKanimation/Bone.d.ts +0 -7
- package/dist/IKanimation/Bone.js +0 -20
- package/dist/IKanimation/CCDSolver.d.ts +0 -37
- package/dist/IKanimation/CCDSolver.js +0 -93
- package/dist/IKanimation/Joint.d.ts +0 -3
- package/dist/IKanimation/Joint.js +0 -17
- package/dist/IKanimation/constaint/constraint.d.ts +0 -10
- package/dist/IKanimation/constaint/constraint.js +0 -25
- package/dist/IKanimation/constaint/hinge.d.ts +0 -12
- package/dist/IKanimation/constaint/hinge.js +0 -46
- package/dist/IKanimation/constaint/slider.d.ts +0 -12
- package/dist/IKanimation/constaint/slider.js +0 -44
- package/dist/IKanimation/index.d.ts +0 -0
- package/dist/IKanimation/index.js +0 -9
- package/dist/IKanimation/isolver.d.ts +0 -4
- package/dist/IKanimation/isolver.js +0 -10
- package/dist/IKanimation/skeleton.d.ts +0 -13
- package/dist/IKanimation/skeleton.js +0 -31
- package/dist/alg/common.d.ts +0 -114
- package/dist/alg/common.js +0 -302
- package/dist/alg/curve.d.ts +0 -4
- package/dist/alg/curve.js +0 -11
- package/dist/alg/delaunator.d.ts +0 -29
- package/dist/alg/delaunator.js +0 -442
- package/dist/alg/delaunay.d.ts +0 -20
- package/dist/alg/delaunay.js +0 -199
- package/dist/alg/delaunayslow.d.ts +0 -18
- package/dist/alg/delaunayslow.js +0 -140
- package/dist/alg/extrude/extrude.d.ts +0 -3
- package/dist/alg/extrude/extrude.js +0 -17
- package/dist/alg/extrude.d.ts +0 -199
- package/dist/alg/extrude.js +0 -728
- package/dist/alg/offset/index.d.ts +0 -0
- package/dist/alg/offset/index.js +0 -9
- package/dist/alg/offset.d.ts +0 -0
- package/dist/alg/offset.js +0 -472
- package/dist/alg/pointset.d.ts +0 -94
- package/dist/alg/pointset.js +0 -223
- package/dist/alg/recognition.d.ts +0 -14
- package/dist/alg/recognition.js +0 -37
- package/dist/alg/result.d.ts +0 -22
- package/dist/alg/result.js +0 -2
- package/dist/alg/segmentset.d.ts +0 -11
- package/dist/alg/segmentset.js +0 -45
- package/dist/alg/sort.d.ts +0 -2
- package/dist/alg/sort.js +0 -14
- package/dist/alg/split.d.ts +0 -8
- package/dist/alg/split.js +0 -10
- package/dist/alg/trianglution.d.ts +0 -15
- package/dist/alg/trianglution.js +0 -70
- package/dist/alg/vol.d.ts +0 -6
- package/dist/alg/vol.js +0 -18
- package/dist/alg/voronoi.d.ts +0 -31
- package/dist/alg/voronoi.js +0 -418
- package/dist/app.d.ts +0 -1
- package/dist/app.js +0 -248
- package/dist/basic/distance.d.ts +0 -12
- package/dist/basic/distance.js +0 -39
- package/dist/csg/bsp.d.ts +0 -9
- package/dist/csg/bsp.js +0 -22
- package/dist/csg/node.d.ts +0 -12
- package/dist/csg/node.js +0 -75
- package/dist/csg/polygon.d.ts +0 -43
- package/dist/csg/polygon.js +0 -161
- package/dist/diamondMaterialShader.d.ts +0 -92
- package/dist/diamondMaterialShader.js +0 -118
- package/dist/effect/breath-light.d.ts +0 -4
- package/dist/effect/breath-light.js +0 -39
- package/dist/extends/geometryaid.d.ts +0 -28
- package/dist/extends/geometryaid.js +0 -71
- package/dist/extends/split.d.ts +0 -3
- package/dist/extends/split.js +0 -13
- package/dist/glview.d.ts +0 -112
- package/dist/glview.js +0 -564
- package/dist/math/Color.d.ts +0 -33
- package/dist/math/Color.js +0 -235
- package/dist/math/Euler.d.ts +0 -46
- package/dist/math/Euler.js +0 -225
- package/dist/math/HVec3.d.ts +0 -43
- package/dist/math/HVec3.js +0 -176
- package/dist/math/Mat3.d.ts +0 -29
- package/dist/math/Mat3.js +0 -244
- package/dist/math/Mat4.d.ts +0 -85
- package/dist/math/Mat4.js +0 -791
- package/dist/math/Math.d.ts +0 -130
- package/dist/math/Math.js +0 -198
- package/dist/math/Quat.d.ts +0 -82
- package/dist/math/Quat.js +0 -418
- package/dist/math/Vec2.d.ts +0 -68
- package/dist/math/Vec2.js +0 -328
- package/dist/math/Vec3.d.ts +0 -240
- package/dist/math/Vec3.js +0 -1082
- package/dist/math/Vec4.d.ts +0 -81
- package/dist/math/Vec4.js +0 -475
- package/dist/math/vecs.d.ts +0 -134
- package/dist/math/vecs.js +0 -464
- package/dist/render/bufferAttribute.d.ts +0 -104
- package/dist/render/bufferAttribute.js +0 -344
- package/dist/render/geometry.d.ts +0 -87
- package/dist/render/geometry.js +0 -769
- package/dist/render/mesh.d.ts +0 -30
- package/dist/render/mesh.js +0 -87
- package/dist/render/types.d.ts +0 -3
- package/dist/render/types.js +0 -8
- package/dist/robust/plane.d.ts +0 -7
- package/dist/robust/plane.js +0 -17
- package/dist/robust/vec.d.ts +0 -15
- package/dist/robust/vec.js +0 -71
- package/dist/struct/3d/Box.d.ts +0 -23
- package/dist/struct/3d/Box.js +0 -109
- package/dist/struct/3d/Capsule.d.ts +0 -12
- package/dist/struct/3d/Capsule.js +0 -36
- package/dist/struct/3d/Circle.d.ts +0 -52
- package/dist/struct/3d/Circle.js +0 -138
- package/dist/struct/3d/Disk.d.ts +0 -10
- package/dist/struct/3d/Disk.js +0 -22
- package/dist/struct/3d/Frustum.d.ts +0 -35
- package/dist/struct/3d/Frustum.js +0 -159
- package/dist/struct/3d/Line.d.ts +0 -40
- package/dist/struct/3d/Line.js +0 -340
- package/dist/struct/3d/Path.d.ts +0 -75
- package/dist/struct/3d/Path.js +0 -308
- package/dist/struct/3d/Plane.d.ts +0 -74
- package/dist/struct/3d/Plane.js +0 -298
- package/dist/struct/3d/Point.d.ts +0 -4
- package/dist/struct/3d/Point.js +0 -30
- package/dist/struct/3d/Polygon.d.ts +0 -8
- package/dist/struct/3d/Polygon.js +0 -55
- package/dist/struct/3d/Polyline.d.ts +0 -34
- package/dist/struct/3d/Polyline.js +0 -130
- package/dist/struct/3d/Ray.d.ts +0 -21
- package/dist/struct/3d/Ray.js +0 -262
- package/dist/struct/3d/Rectangle.d.ts +0 -7
- package/dist/struct/3d/Rectangle.js +0 -35
- package/dist/struct/3d/Segment.d.ts +0 -32
- package/dist/struct/3d/Segment.js +0 -334
- package/dist/struct/3d/Shape.d.ts +0 -4
- package/dist/struct/3d/Shape.js +0 -27
- package/dist/struct/3d/Sphere.d.ts +0 -11
- package/dist/struct/3d/Sphere.js +0 -30
- package/dist/struct/3d/Triangle.d.ts +0 -8
- package/dist/struct/3d/Triangle.js +0 -53
- package/dist/struct/bsp.d.ts +0 -9
- package/dist/struct/bsp.js +0 -44
- package/dist/struct/btree.d.ts +0 -0
- package/dist/struct/btree.js +0 -1
- package/dist/struct/data/ArrayList.d.ts +0 -42
- package/dist/struct/data/ArrayList.js +0 -172
- package/dist/struct/data/ArrayObject.d.ts +0 -30
- package/dist/struct/data/ArrayObject.js +0 -131
- package/dist/struct/data/type.d.ts +0 -13
- package/dist/struct/data/type.js +0 -18
- package/dist/struct/kdtree.d.ts +0 -0
- package/dist/struct/kdtree.js +0 -1
- package/dist/struct/polyTree.d.ts +0 -4
- package/dist/struct/polyTree.js +0 -27
- package/dist/struct/quatTree.d.ts +0 -0
- package/dist/struct/quatTree.js +0 -1
- package/dist/struct/tree.d.ts +0 -11
- package/dist/struct/tree.js +0 -26
- package/dist/utils/array.d.ts +0 -24
- package/dist/utils/array.js +0 -89
- package/dist/utils/types.d.ts +0 -24
- package/dist/utils/types.js +0 -20
- package/docs/.vuepress/components/distance.vue +0 -125
- package/docs/.vuepress/components/intersect.vue +0 -0
- package/docs/.vuepress/components/trianglution.vue +0 -121
- package/docs/.vuepress/components/utils.js +0 -314
- package/docs/.vuepress/config.js +0 -99
- package/docs/.vuepress/enhanceApp.js +0 -13
- package/docs/.vuepress/public/delaunay.png +0 -0
- package/docs/.vuepress/public/logo.png +0 -0
- package/docs/.vuepress/public/plane-set-convex.png +0 -0
- package/docs/.vuepress/public/sponsor/alipay.jpg +0 -0
- package/docs/.vuepress/public/sponsor/wechat.png +0 -0
- package/docs/README.md +0 -14
- package/docs/demo/README.md +0 -9
- package/docs/guide/README.md +0 -94
- package/docs/guide/array.md +0 -10
- package/docs/guide/cy/trianglution.html +0 -2
- package/docs/guide/distLineAll.md +0 -85
- package/docs/guide/distPointAll.md +0 -137
- package/docs/guide/distRayAll.md +0 -69
- package/docs/guide/distSegmentAll.md +0 -19
- package/docs/guide/point.vue +0 -12
- package/docs/guide/vector.md +0 -10
- package/docs/guide//345/270/270/347/224/250.md +0 -156
- package/docs/sponsor/README.md +0 -15
- package/docs//345/274/200/345/217/221/346/227/245/345/277/227/2020/345/271/2643/346/234/21013/346/227/245.md +0 -6
- package/effect/common.glsl +0 -34
- package/effect/drawing.glsl +0 -36
- package/effect/shape.arc.glsl +0 -13
- package/effect/shape.circle.glsl +0 -13
- package/effect/shape.grid.glsl +0 -42
- package/effect/shape.line.glsl +0 -18
- package/effect/shape.pie.glsl +0 -18
- package/effect/shape.plot.glsl +0 -10
- package/effect/shape.poly.glsl +0 -15
- package/effect/shape.rect.glsl +0 -14
- package/effect/shape.rectround.glsl +0 -15
- package/effect/shape.segment.glsl +0 -10
- package/effect/shape.spiral.glsl +0 -12
- package/effect/shape.star.glsl +0 -16
- package/examples/index.html +0 -31
- package/git.sh +0 -12
- package/gitproxy.sh +0 -6
- package/image/readme/1640758500266.png +0 -0
- package/image/readme/1640758513361.png +0 -0
- package/index.html +0 -14
- package/linear algorithm//346/225/260/345/255/246/350/241/250/350/276/276/345/274/217.md" +0 -122
- package/linear algorithm//347/237/251/351/230/265.md" +0 -91
- package/rollup.config.js +0 -82
- package/scripttest.html +0 -23
- package/src/IKanimation/Bone.ts +0 -20
- package/src/IKanimation/CCDSolver.ts +0 -114
- package/src/IKanimation/Joint.ts +0 -13
- package/src/IKanimation/constaint/constraint.ts +0 -23
- package/src/IKanimation/constaint/hinge.ts +0 -29
- package/src/IKanimation/constaint/slider.ts +0 -25
- package/src/IKanimation/index.ts +0 -8
- package/src/IKanimation/isolver.ts +0 -13
- package/src/IKanimation/skeleton.ts +0 -30
- package/src/alg/common.ts +0 -304
- package/src/alg/curve.ts +0 -9
- package/src/alg/delaunator.ts +0 -519
- package/src/alg/delaunay.ts +0 -163
- package/src/alg/delaunayslow.ts +0 -183
- package/src/alg/extrude/extrude.ts +0 -19
- package/src/alg/extrude.ts +0 -941
- package/src/alg/offset/index.ts +0 -8
- package/src/alg/offset.ts +0 -501
- package/src/alg/pointset.ts +0 -219
- package/src/alg/recognition.ts +0 -43
- package/src/alg/result.ts +0 -24
- package/src/alg/segmentset.ts +0 -44
- package/src/alg/sort.ts +0 -11
- package/src/alg/split.ts +0 -15
- package/src/alg/trianglution.ts +0 -53
- package/src/alg/vol.ts +0 -18
- package/src/alg/voronoi.ts +0 -303
- package/src/app.css +0 -12
- package/src/app.ts +0 -285
- package/src/assets/color.jpg +0 -0
- package/src/basic/distance.ts +0 -40
- package/src/clipper/clipper.d.ts +0 -323
- package/src/clipper/clipper.js +0 -7626
- package/src/clipper/clipper_float.js +0 -185
- package/src/clipper/clipper_float_unminified.js +0 -5639
- package/src/clipper/clipperint.js +0 -7626
- package/src/csg/bsp.ts +0 -24
- package/src/csg/csg.js +0 -583
- package/src/csg/node.ts +0 -91
- package/src/csg/polygon.ts +0 -177
- package/src/diamondMaterialShader.ts +0 -93
- package/src/effect/breath-light.ts +0 -24
- package/src/extends/geometryaid.ts +0 -86
- package/src/extends/split.ts +0 -15
- package/src/glview.ts +0 -570
- package/src/index.ts +0 -47
- package/src/math/Color.ts +0 -225
- package/src/math/Euler.ts +0 -238
- package/src/math/HVec3.ts +0 -1144
- package/src/math/Mat3.ts +0 -365
- package/src/math/Mat4.ts +0 -1134
- package/src/math/Math.ts +0 -213
- package/src/math/Quat.ts +0 -536
- package/src/math/Vec2.ts +0 -408
- package/src/math/Vec3.ts +0 -1307
- package/src/math/Vec4.ts +0 -587
- package/src/math/vecs.ts +0 -486
- package/src/render/bufferAttribute.ts +0 -491
- package/src/render/geometry.ts +0 -1329
- package/src/render/mesh.ts +0 -82
- package/src/render/types.ts +0 -17
- package/src/robust/plane.ts +0 -12
- package/src/robust/readme.md +0 -1
- package/src/robust/vec.ts +0 -61
- package/src/shader/cga.glsl +0 -202
- package/src/shader/common.glsl +0 -87
- package/src/shader/noise/GLSL-Noise.md +0 -1108
- package/src/shader/noise/cellular2D.glsl +0 -69
- package/src/shader/noise/cellular2x2.glsl +0 -64
- package/src/shader/noise/cellular2x2x2.glsl +0 -88
- package/src/shader/noise/cellular3D.glsl +0 -187
- package/src/shader/noise/classicnoise2D.glsl +0 -113
- package/src/shader/noise/classicnoise3D.glsl +0 -177
- package/src/shader/noise/classicnoise4D.glsl +0 -302
- package/src/shader/noise/noise2D.glsl +0 -71
- package/src/shader/noise/noise3D.glsl +0 -103
- package/src/shader/noise/noise3Dgrad.glsl +0 -111
- package/src/shader/noise/noise4D.glsl +0 -129
- package/src/shader/noise/psrdnoise2D.glsl +0 -462
- package/src/struct/3d/Box.ts +0 -124
- package/src/struct/3d/Capsule.ts +0 -18
- package/src/struct/3d/Circle.ts +0 -149
- package/src/struct/3d/Disk.ts +0 -22
- package/src/struct/3d/Frustum.ts +0 -189
- package/src/struct/3d/Line.ts +0 -378
- package/src/struct/3d/Path.ts +0 -314
- package/src/struct/3d/Plane.ts +0 -341
- package/src/struct/3d/Point.ts +0 -7
- package/src/struct/3d/PolyLine.ts +0 -115
- package/src/struct/3d/Polygon.ts +0 -46
- package/src/struct/3d/Ray.ts +0 -285
- package/src/struct/3d/Rectangle.ts +0 -18
- package/src/struct/3d/Segment.ts +0 -330
- package/src/struct/3d/Shape.ts +0 -7
- package/src/struct/3d/Sphere.ts +0 -31
- package/src/struct/3d/Triangle.ts +0 -28
- package/src/struct/bsp.ts +0 -18
- package/src/struct/btree.ts +0 -0
- package/src/struct/data/ArrayList.ts +0 -144
- package/src/struct/data/ArrayObject.ts +0 -105
- package/src/struct/data/type.ts +0 -14
- package/src/struct/kdtree.ts +0 -0
- package/src/struct/polyTree.ts +0 -8
- package/src/struct/quatTree.ts +0 -0
- package/src/struct/tree.ts +0 -30
- package/src/utils/array.ts +0 -106
- package/src/utils/types.ts +0 -42
- package/src-gis/app.ts +0 -7
- package/src-gis/core/Cartographic.ts +0 -48
- package/src-gis/core/EllipsoidGeodesic.ts +0 -56
- package/src-gis/core/EllipsoidTerrainProvider.ts +0 -35
- package/src-gis/core/HeightmapTerrainData.ts +0 -5
- package/src-gis/core/Rectangle.ts +0 -112
- package/src-gis/core/TaskProcessor.ts +0 -222
- package/src-gis/gis.ts +0 -25
- package/src-gis/globe.ts +0 -54
- package/src-gis/math/Cartographic.ts +0 -24
- package/src-gis/math/GVec3.ts +0 -55
- package/src-gis/math/ellipsoid.ts +0 -13
- package/src-gis/provider/DcTerrainProvider.ts +0 -36
- package/src-gis/provider/TerrainProvider.ts +0 -12
- package/src-gis/scene/DcImageryProvider.ts +0 -36
- package/src-gis/scene/GeographicTilingScheme.ts +0 -65
- package/src-gis/scene/Globe.ts +0 -76
- package/src-gis/scene/GlobeSurfaceShaderSet.ts +0 -9
- package/src-gis/scene/GlobeSurfaceTileProvider.ts +0 -25
- package/src-gis/scene/ImageryLayerCollection.ts +0 -75
- package/src-gis/scene/ImageryProvider.ts +0 -28
- package/src-gis/scene/QuadtreeTile.ts +0 -162
- package/src-gis/scene/UrlTemplateImageryProvider.ts +0 -32
- package/src-gis/scene/quadtree_primitive.ts +0 -58
- package/tsconfig.json +0 -77
- package/webpack.config.js +0 -112
- package//350/256/241/347/256/227/345/207/240/344/275/225/351/227/256/351/242/230.md +0 -26
package/dist/math/Vec4.d.ts
DELETED
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import { TypedArrayLike } from '../render/types';
|
|
2
|
-
export declare class Vec4 {
|
|
3
|
-
private _x;
|
|
4
|
-
private _y;
|
|
5
|
-
private _z;
|
|
6
|
-
private _w;
|
|
7
|
-
isVec4: boolean;
|
|
8
|
-
constructor(_x?: number, _y?: number, _z?: number, _w?: number);
|
|
9
|
-
get x(): number;
|
|
10
|
-
set x(value: number);
|
|
11
|
-
get y(): number;
|
|
12
|
-
set y(value: number);
|
|
13
|
-
get z(): number;
|
|
14
|
-
set z(value: number);
|
|
15
|
-
get w(): number;
|
|
16
|
-
set w(value: number);
|
|
17
|
-
static isVec4(v: Vec4): boolean;
|
|
18
|
-
get width(): number;
|
|
19
|
-
set width(value: number);
|
|
20
|
-
get height(): number;
|
|
21
|
-
set height(value: number);
|
|
22
|
-
set(x: number, y: number, z: number, w: number): this;
|
|
23
|
-
setScalar(scalar: number): this;
|
|
24
|
-
setX(x: number): this;
|
|
25
|
-
setY(y: number): this;
|
|
26
|
-
setZ(z: number): this;
|
|
27
|
-
setW(w: number): this;
|
|
28
|
-
setComponent(index: number, value: number): this;
|
|
29
|
-
getComponent(index: number): number;
|
|
30
|
-
clone(): Vec4;
|
|
31
|
-
copy(v: {
|
|
32
|
-
x: number;
|
|
33
|
-
y: number;
|
|
34
|
-
z: number;
|
|
35
|
-
w: number | undefined;
|
|
36
|
-
}): this;
|
|
37
|
-
add(v: Vec4, w?: Vec4): Vec4;
|
|
38
|
-
addScalar(s: number): this;
|
|
39
|
-
addVecs(a: Vec4, b: Vec4): this;
|
|
40
|
-
addScaledVec(v: Vec4, s: number): this;
|
|
41
|
-
sub(v: Vec4, w?: Vec4): this;
|
|
42
|
-
subScalar(s: number): this;
|
|
43
|
-
subVecs(a: Vec4, b: Vec4): this;
|
|
44
|
-
multiplyScalar(scalar: number): this;
|
|
45
|
-
applyMat4(m: {
|
|
46
|
-
elements: any;
|
|
47
|
-
}): this;
|
|
48
|
-
divideScalar(scalar: number): this;
|
|
49
|
-
setAxisAngleFromQuat(q: {
|
|
50
|
-
w: number;
|
|
51
|
-
x: number;
|
|
52
|
-
y: number;
|
|
53
|
-
z: number;
|
|
54
|
-
}): this;
|
|
55
|
-
setAxisAngleFromRotationMat(m: {
|
|
56
|
-
elements: any;
|
|
57
|
-
}): this;
|
|
58
|
-
min(v: Vec4): this;
|
|
59
|
-
max(v: Vec4): this;
|
|
60
|
-
clamp(min: Vec4, max: Vec4): this;
|
|
61
|
-
clampScalar(minVal: number, maxVal: number): this;
|
|
62
|
-
clampLength(min: number, max: number): this;
|
|
63
|
-
floor(): this;
|
|
64
|
-
ceil(): this;
|
|
65
|
-
round(): this;
|
|
66
|
-
roundToZero(): this;
|
|
67
|
-
negate(): this;
|
|
68
|
-
dot(v: Vec4): number;
|
|
69
|
-
lengthSq(): number;
|
|
70
|
-
length(): number;
|
|
71
|
-
manhattanLength(): number;
|
|
72
|
-
normalize(): this;
|
|
73
|
-
setLength(length: any): this;
|
|
74
|
-
lerp(v: Vec4, alpha: number): this;
|
|
75
|
-
lerpVecs(v1: Vec4, v2: any, alpha: any): Vec4;
|
|
76
|
-
equals(v: Vec4): boolean;
|
|
77
|
-
fromArray(array: TypedArrayLike, offset?: number): this;
|
|
78
|
-
toArray(array?: TypedArrayLike, offset?: number): TypedArrayLike;
|
|
79
|
-
fromBufferAttribute(attribute: any, index: any, offset: undefined): this;
|
|
80
|
-
}
|
|
81
|
-
export declare function v4(x?: number, y?: number, z?: number, w?: number): Vec4;
|
package/dist/math/Vec4.js
DELETED
|
@@ -1,475 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.v4 = exports.Vec4 = void 0;
|
|
4
|
-
var Vec4 = /** @class */ (function () {
|
|
5
|
-
function Vec4(_x, _y, _z, _w) {
|
|
6
|
-
if (_x === void 0) { _x = 0; }
|
|
7
|
-
if (_y === void 0) { _y = 0; }
|
|
8
|
-
if (_z === void 0) { _z = 0; }
|
|
9
|
-
if (_w === void 0) { _w = 1; }
|
|
10
|
-
this._x = _x;
|
|
11
|
-
this._y = _y;
|
|
12
|
-
this._z = _z;
|
|
13
|
-
this._w = _w;
|
|
14
|
-
this.isVec4 = true;
|
|
15
|
-
}
|
|
16
|
-
Object.defineProperty(Vec4.prototype, "x", {
|
|
17
|
-
get: function () {
|
|
18
|
-
return this._x;
|
|
19
|
-
},
|
|
20
|
-
set: function (value) {
|
|
21
|
-
if (this._x !== value) {
|
|
22
|
-
this._x = value;
|
|
23
|
-
// this.fire('change', 'x', this._x, value)
|
|
24
|
-
}
|
|
25
|
-
},
|
|
26
|
-
enumerable: false,
|
|
27
|
-
configurable: true
|
|
28
|
-
});
|
|
29
|
-
Object.defineProperty(Vec4.prototype, "y", {
|
|
30
|
-
get: function () {
|
|
31
|
-
return this._y;
|
|
32
|
-
},
|
|
33
|
-
set: function (value) {
|
|
34
|
-
if (this._y !== value) {
|
|
35
|
-
this._y = value;
|
|
36
|
-
// this.fire('change', 'y', this._y, value)
|
|
37
|
-
}
|
|
38
|
-
},
|
|
39
|
-
enumerable: false,
|
|
40
|
-
configurable: true
|
|
41
|
-
});
|
|
42
|
-
Object.defineProperty(Vec4.prototype, "z", {
|
|
43
|
-
get: function () {
|
|
44
|
-
return this._z;
|
|
45
|
-
},
|
|
46
|
-
set: function (value) {
|
|
47
|
-
if (this._z !== value) {
|
|
48
|
-
this._z = value;
|
|
49
|
-
// this.fire('change', 'z', this._z, value)
|
|
50
|
-
}
|
|
51
|
-
},
|
|
52
|
-
enumerable: false,
|
|
53
|
-
configurable: true
|
|
54
|
-
});
|
|
55
|
-
Object.defineProperty(Vec4.prototype, "w", {
|
|
56
|
-
get: function () {
|
|
57
|
-
return this._w;
|
|
58
|
-
},
|
|
59
|
-
set: function (value) {
|
|
60
|
-
if (this._w !== value) {
|
|
61
|
-
this._w = value;
|
|
62
|
-
// this.fire('change', 'w', this._w, value)
|
|
63
|
-
}
|
|
64
|
-
},
|
|
65
|
-
enumerable: false,
|
|
66
|
-
configurable: true
|
|
67
|
-
});
|
|
68
|
-
Vec4.isVec4 = function (v) {
|
|
69
|
-
return !isNaN(v.x) && !isNaN(v.y) && !isNaN(v.z) && !isNaN(v.w);
|
|
70
|
-
};
|
|
71
|
-
Object.defineProperty(Vec4.prototype, "width", {
|
|
72
|
-
get: function () {
|
|
73
|
-
return this._z;
|
|
74
|
-
},
|
|
75
|
-
set: function (value) {
|
|
76
|
-
this._z = value;
|
|
77
|
-
},
|
|
78
|
-
enumerable: false,
|
|
79
|
-
configurable: true
|
|
80
|
-
});
|
|
81
|
-
Object.defineProperty(Vec4.prototype, "height", {
|
|
82
|
-
get: function () {
|
|
83
|
-
return this._w;
|
|
84
|
-
},
|
|
85
|
-
set: function (value) {
|
|
86
|
-
this._w = value;
|
|
87
|
-
},
|
|
88
|
-
enumerable: false,
|
|
89
|
-
configurable: true
|
|
90
|
-
});
|
|
91
|
-
Vec4.prototype.set = function (x, y, z, w) {
|
|
92
|
-
this._x = x;
|
|
93
|
-
this._y = y;
|
|
94
|
-
this._z = z;
|
|
95
|
-
this._w = w;
|
|
96
|
-
return this;
|
|
97
|
-
};
|
|
98
|
-
Vec4.prototype.setScalar = function (scalar) {
|
|
99
|
-
this._x = scalar;
|
|
100
|
-
this._y = scalar;
|
|
101
|
-
this._z = scalar;
|
|
102
|
-
this._w = scalar;
|
|
103
|
-
return this;
|
|
104
|
-
};
|
|
105
|
-
Vec4.prototype.setX = function (x) {
|
|
106
|
-
this._x = x;
|
|
107
|
-
return this;
|
|
108
|
-
};
|
|
109
|
-
Vec4.prototype.setY = function (y) {
|
|
110
|
-
this._y = y;
|
|
111
|
-
return this;
|
|
112
|
-
};
|
|
113
|
-
Vec4.prototype.setZ = function (z) {
|
|
114
|
-
this._z = z;
|
|
115
|
-
return this;
|
|
116
|
-
};
|
|
117
|
-
Vec4.prototype.setW = function (w) {
|
|
118
|
-
this._w = w;
|
|
119
|
-
return this;
|
|
120
|
-
};
|
|
121
|
-
Vec4.prototype.setComponent = function (index, value) {
|
|
122
|
-
switch (index) {
|
|
123
|
-
case 0:
|
|
124
|
-
this._x = value;
|
|
125
|
-
break;
|
|
126
|
-
case 1:
|
|
127
|
-
this._y = value;
|
|
128
|
-
break;
|
|
129
|
-
case 2:
|
|
130
|
-
this._z = value;
|
|
131
|
-
break;
|
|
132
|
-
case 3:
|
|
133
|
-
this._w = value;
|
|
134
|
-
break;
|
|
135
|
-
default:
|
|
136
|
-
throw new Error("index is out of range: " + index);
|
|
137
|
-
}
|
|
138
|
-
return this;
|
|
139
|
-
};
|
|
140
|
-
Vec4.prototype.getComponent = function (index) {
|
|
141
|
-
switch (index) {
|
|
142
|
-
case 0:
|
|
143
|
-
return this._x;
|
|
144
|
-
case 1:
|
|
145
|
-
return this._y;
|
|
146
|
-
case 2:
|
|
147
|
-
return this._z;
|
|
148
|
-
case 3:
|
|
149
|
-
return this._w;
|
|
150
|
-
default:
|
|
151
|
-
throw new Error("index is out of range: " + index);
|
|
152
|
-
}
|
|
153
|
-
};
|
|
154
|
-
Vec4.prototype.clone = function () {
|
|
155
|
-
return new Vec4(this._x, this._y, this._z, this._w);
|
|
156
|
-
};
|
|
157
|
-
Vec4.prototype.copy = function (v) {
|
|
158
|
-
this._x = v.x;
|
|
159
|
-
this._y = v.y;
|
|
160
|
-
this._z = v.z;
|
|
161
|
-
this._w = v.w !== undefined ? v.w : 1;
|
|
162
|
-
return this;
|
|
163
|
-
};
|
|
164
|
-
Vec4.prototype.add = function (v, w) {
|
|
165
|
-
if (w !== undefined) {
|
|
166
|
-
console.warn("Vec4: .add() now only accepts one argument. Use .addVecs( a, b ) instead.");
|
|
167
|
-
return this.addVecs(v, w);
|
|
168
|
-
}
|
|
169
|
-
this._x += v.x;
|
|
170
|
-
this._y += v.y;
|
|
171
|
-
this._z += v.z;
|
|
172
|
-
this._w += v.w;
|
|
173
|
-
return this;
|
|
174
|
-
};
|
|
175
|
-
Vec4.prototype.addScalar = function (s) {
|
|
176
|
-
this._x += s;
|
|
177
|
-
this._y += s;
|
|
178
|
-
this._z += s;
|
|
179
|
-
this._w += s;
|
|
180
|
-
return this;
|
|
181
|
-
};
|
|
182
|
-
Vec4.prototype.addVecs = function (a, b) {
|
|
183
|
-
this._x = a.x + b.x;
|
|
184
|
-
this._y = a.y + b.y;
|
|
185
|
-
this._z = a.z + b.z;
|
|
186
|
-
this._w = a.w + b.w;
|
|
187
|
-
return this;
|
|
188
|
-
};
|
|
189
|
-
Vec4.prototype.addScaledVec = function (v, s) {
|
|
190
|
-
this._x += v.x * s;
|
|
191
|
-
this._y += v.y * s;
|
|
192
|
-
this._z += v.z * s;
|
|
193
|
-
this._w += v.w * s;
|
|
194
|
-
return this;
|
|
195
|
-
};
|
|
196
|
-
Vec4.prototype.sub = function (v, w) {
|
|
197
|
-
if (w !== undefined) {
|
|
198
|
-
return this.subVecs(v, w);
|
|
199
|
-
}
|
|
200
|
-
this._x -= v.x;
|
|
201
|
-
this._y -= v.y;
|
|
202
|
-
this._z -= v.z;
|
|
203
|
-
this._w -= v.w;
|
|
204
|
-
return this;
|
|
205
|
-
};
|
|
206
|
-
Vec4.prototype.subScalar = function (s) {
|
|
207
|
-
this._x -= s;
|
|
208
|
-
this._y -= s;
|
|
209
|
-
this._z -= s;
|
|
210
|
-
this._w -= s;
|
|
211
|
-
return this;
|
|
212
|
-
};
|
|
213
|
-
Vec4.prototype.subVecs = function (a, b) {
|
|
214
|
-
this._x = a.x - b.x;
|
|
215
|
-
this._y = a.y - b.y;
|
|
216
|
-
this._z = a.z - b.z;
|
|
217
|
-
this._w = a.w - b.w;
|
|
218
|
-
return this;
|
|
219
|
-
};
|
|
220
|
-
Vec4.prototype.multiplyScalar = function (scalar) {
|
|
221
|
-
this._x *= scalar;
|
|
222
|
-
this._y *= scalar;
|
|
223
|
-
this._z *= scalar;
|
|
224
|
-
this._w *= scalar;
|
|
225
|
-
return this;
|
|
226
|
-
};
|
|
227
|
-
Vec4.prototype.applyMat4 = function (m) {
|
|
228
|
-
var x = this._x, y = this._y, z = this._z, w = this._w;
|
|
229
|
-
var e = m.elements;
|
|
230
|
-
this._x = e[0] * x + e[4] * y + e[8] * z + e[12] * w;
|
|
231
|
-
this._y = e[1] * x + e[5] * y + e[9] * z + e[13] * w;
|
|
232
|
-
this._z = e[2] * x + e[6] * y + e[10] * z + e[14] * w;
|
|
233
|
-
this._w = e[3] * x + e[7] * y + e[11] * z + e[15] * w;
|
|
234
|
-
return this;
|
|
235
|
-
};
|
|
236
|
-
Vec4.prototype.divideScalar = function (scalar) {
|
|
237
|
-
return this.multiplyScalar(1 / scalar);
|
|
238
|
-
};
|
|
239
|
-
Vec4.prototype.setAxisAngleFromQuat = function (q) {
|
|
240
|
-
// http://www.euclideanspace.com/maths/geometry/rotations/conversions/QuatToAngle/index.htm
|
|
241
|
-
// q is assumed to be normalized
|
|
242
|
-
this._w = 2 * Math.acos(q.w);
|
|
243
|
-
var s = Math.sqrt(1 - q.w * q.w);
|
|
244
|
-
if (s < 0.0001) {
|
|
245
|
-
this._x = 1;
|
|
246
|
-
this._y = 0;
|
|
247
|
-
this._z = 0;
|
|
248
|
-
}
|
|
249
|
-
else {
|
|
250
|
-
this._x = q.x / s;
|
|
251
|
-
this._y = q.y / s;
|
|
252
|
-
this._z = q.z / s;
|
|
253
|
-
}
|
|
254
|
-
return this;
|
|
255
|
-
};
|
|
256
|
-
Vec4.prototype.setAxisAngleFromRotationMat = function (m) {
|
|
257
|
-
// http://www.euclideanspace.com/maths/geometry/rotations/conversions/matrixToAngle/index.htm
|
|
258
|
-
// assumes the upper 3x3 of m is a pure rotation matrix (i.e, unscaled)
|
|
259
|
-
var angle, x, y, z, // variables for result
|
|
260
|
-
epsilon = 0.01, // margin to allow for rounding errors
|
|
261
|
-
epsilon2 = 0.1, // margin to distinguish between 0 and 180 degrees
|
|
262
|
-
te = m.elements, m11 = te[0], m12 = te[4], m13 = te[8], m21 = te[1], m22 = te[5], m23 = te[9], m31 = te[2], m32 = te[6], m33 = te[10];
|
|
263
|
-
if (Math.abs(m12 - m21) < epsilon &&
|
|
264
|
-
Math.abs(m13 - m31) < epsilon &&
|
|
265
|
-
Math.abs(m23 - m32) < epsilon) {
|
|
266
|
-
// singularity found
|
|
267
|
-
// first check for identity matrix which must have +1 for all terms
|
|
268
|
-
// in leading diagonal and zero in other terms
|
|
269
|
-
if (Math.abs(m12 + m21) < epsilon2 &&
|
|
270
|
-
Math.abs(m13 + m31) < epsilon2 &&
|
|
271
|
-
Math.abs(m23 + m32) < epsilon2 &&
|
|
272
|
-
Math.abs(m11 + m22 + m33 - 3) < epsilon2) {
|
|
273
|
-
// this singularity is identity matrix so angle = 0
|
|
274
|
-
this.set(1, 0, 0, 0);
|
|
275
|
-
return this; // zero angle, arbitrary axis
|
|
276
|
-
}
|
|
277
|
-
// otherwise this singularity is angle = 180
|
|
278
|
-
angle = Math.PI;
|
|
279
|
-
var xx = (m11 + 1) / 2;
|
|
280
|
-
var yy = (m22 + 1) / 2;
|
|
281
|
-
var zz = (m33 + 1) / 2;
|
|
282
|
-
var xy = (m12 + m21) / 4;
|
|
283
|
-
var xz = (m13 + m31) / 4;
|
|
284
|
-
var yz = (m23 + m32) / 4;
|
|
285
|
-
if (xx > yy && xx > zz) {
|
|
286
|
-
// m11 is the largest diagonal term
|
|
287
|
-
if (xx < epsilon) {
|
|
288
|
-
x = 0;
|
|
289
|
-
y = 0.707106781;
|
|
290
|
-
z = 0.707106781;
|
|
291
|
-
}
|
|
292
|
-
else {
|
|
293
|
-
x = Math.sqrt(xx);
|
|
294
|
-
y = xy / x;
|
|
295
|
-
z = xz / x;
|
|
296
|
-
}
|
|
297
|
-
}
|
|
298
|
-
else if (yy > zz) {
|
|
299
|
-
// m22 is the largest diagonal term
|
|
300
|
-
if (yy < epsilon) {
|
|
301
|
-
x = 0.707106781;
|
|
302
|
-
y = 0;
|
|
303
|
-
z = 0.707106781;
|
|
304
|
-
}
|
|
305
|
-
else {
|
|
306
|
-
y = Math.sqrt(yy);
|
|
307
|
-
x = xy / y;
|
|
308
|
-
z = yz / y;
|
|
309
|
-
}
|
|
310
|
-
}
|
|
311
|
-
else {
|
|
312
|
-
// m33 is the largest diagonal term so base result on this
|
|
313
|
-
if (zz < epsilon) {
|
|
314
|
-
x = 0.707106781;
|
|
315
|
-
y = 0.707106781;
|
|
316
|
-
z = 0;
|
|
317
|
-
}
|
|
318
|
-
else {
|
|
319
|
-
z = Math.sqrt(zz);
|
|
320
|
-
x = xz / z;
|
|
321
|
-
y = yz / z;
|
|
322
|
-
}
|
|
323
|
-
}
|
|
324
|
-
this.set(x, y, z, angle);
|
|
325
|
-
return this; // return 180 deg rotation
|
|
326
|
-
}
|
|
327
|
-
// as we have reached here there are no singularities so we can handle normally
|
|
328
|
-
var s = Math.sqrt((m32 - m23) * (m32 - m23) +
|
|
329
|
-
(m13 - m31) * (m13 - m31) +
|
|
330
|
-
(m21 - m12) * (m21 - m12)); // used to normalize
|
|
331
|
-
if (Math.abs(s) < 0.001)
|
|
332
|
-
s = 1;
|
|
333
|
-
// prevent divide by zero, should not happen if matrix is orthogonal and should be
|
|
334
|
-
// caught by singularity test above, but I've left it in just in case
|
|
335
|
-
this._x = (m32 - m23) / s;
|
|
336
|
-
this._y = (m13 - m31) / s;
|
|
337
|
-
this._z = (m21 - m12) / s;
|
|
338
|
-
this._w = Math.acos((m11 + m22 + m33 - 1) / 2);
|
|
339
|
-
return this;
|
|
340
|
-
};
|
|
341
|
-
Vec4.prototype.min = function (v) {
|
|
342
|
-
this._x = Math.min(this._x, v.x);
|
|
343
|
-
this._y = Math.min(this._y, v.y);
|
|
344
|
-
this._z = Math.min(this._z, v.z);
|
|
345
|
-
this._w = Math.min(this._w, v.w);
|
|
346
|
-
return this;
|
|
347
|
-
};
|
|
348
|
-
Vec4.prototype.max = function (v) {
|
|
349
|
-
this._x = Math.max(this._x, v.x);
|
|
350
|
-
this._y = Math.max(this._y, v.y);
|
|
351
|
-
this._z = Math.max(this._z, v.z);
|
|
352
|
-
this._w = Math.max(this._w, v.w);
|
|
353
|
-
return this;
|
|
354
|
-
};
|
|
355
|
-
Vec4.prototype.clamp = function (min, max) {
|
|
356
|
-
// assumes min < max, componentwise
|
|
357
|
-
this._x = Math.max(min.x, Math.min(max.x, this._x));
|
|
358
|
-
this._y = Math.max(min.y, Math.min(max.y, this._y));
|
|
359
|
-
this._z = Math.max(min.z, Math.min(max.z, this._z));
|
|
360
|
-
this._w = Math.max(min.w, Math.min(max.w, this._w));
|
|
361
|
-
return this;
|
|
362
|
-
};
|
|
363
|
-
Vec4.prototype.clampScalar = function (minVal, maxVal) {
|
|
364
|
-
this._x = Math.max(minVal, Math.min(maxVal, this._x));
|
|
365
|
-
this._y = Math.max(minVal, Math.min(maxVal, this._y));
|
|
366
|
-
this._z = Math.max(minVal, Math.min(maxVal, this._z));
|
|
367
|
-
this._w = Math.max(minVal, Math.min(maxVal, this._w));
|
|
368
|
-
return this;
|
|
369
|
-
};
|
|
370
|
-
Vec4.prototype.clampLength = function (min, max) {
|
|
371
|
-
var length = this.length();
|
|
372
|
-
return this.divideScalar(length || 1).multiplyScalar(Math.max(min, Math.min(max, length)));
|
|
373
|
-
};
|
|
374
|
-
Vec4.prototype.floor = function () {
|
|
375
|
-
this._x = Math.floor(this._x);
|
|
376
|
-
this._y = Math.floor(this._y);
|
|
377
|
-
this._z = Math.floor(this._z);
|
|
378
|
-
this._w = Math.floor(this._w);
|
|
379
|
-
return this;
|
|
380
|
-
};
|
|
381
|
-
Vec4.prototype.ceil = function () {
|
|
382
|
-
this._x = Math.ceil(this._x);
|
|
383
|
-
this._y = Math.ceil(this._y);
|
|
384
|
-
this._z = Math.ceil(this._z);
|
|
385
|
-
this._w = Math.ceil(this._w);
|
|
386
|
-
return this;
|
|
387
|
-
};
|
|
388
|
-
Vec4.prototype.round = function () {
|
|
389
|
-
this._x = Math.round(this._x);
|
|
390
|
-
this._y = Math.round(this._y);
|
|
391
|
-
this._z = Math.round(this._z);
|
|
392
|
-
this._w = Math.round(this._w);
|
|
393
|
-
return this;
|
|
394
|
-
};
|
|
395
|
-
Vec4.prototype.roundToZero = function () {
|
|
396
|
-
this._x = this._x < 0 ? Math.ceil(this._x) : Math.floor(this._x);
|
|
397
|
-
this._y = this._y < 0 ? Math.ceil(this._y) : Math.floor(this._y);
|
|
398
|
-
this._z = this._z < 0 ? Math.ceil(this._z) : Math.floor(this._z);
|
|
399
|
-
this._w = this._w < 0 ? Math.ceil(this._w) : Math.floor(this._w);
|
|
400
|
-
return this;
|
|
401
|
-
};
|
|
402
|
-
Vec4.prototype.negate = function () {
|
|
403
|
-
this._x = -this._x;
|
|
404
|
-
this._y = -this._y;
|
|
405
|
-
this._z = -this._z;
|
|
406
|
-
this._w = -this._w;
|
|
407
|
-
return this;
|
|
408
|
-
};
|
|
409
|
-
Vec4.prototype.dot = function (v) {
|
|
410
|
-
return this._x * v.x + this._y * v.y + this._z * v.z + this._w * v.w;
|
|
411
|
-
};
|
|
412
|
-
Vec4.prototype.lengthSq = function () {
|
|
413
|
-
return (this._x * this._x + this._y * this._y + this._z * this._z + this._w * this._w);
|
|
414
|
-
};
|
|
415
|
-
Vec4.prototype.length = function () {
|
|
416
|
-
return Math.sqrt(this._x * this._x + this._y * this._y + this._z * this._z + this._w * this._w);
|
|
417
|
-
};
|
|
418
|
-
Vec4.prototype.manhattanLength = function () {
|
|
419
|
-
return (Math.abs(this._x) + Math.abs(this._y) + Math.abs(this._z) + Math.abs(this._w));
|
|
420
|
-
};
|
|
421
|
-
Vec4.prototype.normalize = function () {
|
|
422
|
-
return this.divideScalar(this.length() || 1);
|
|
423
|
-
};
|
|
424
|
-
Vec4.prototype.setLength = function (length) {
|
|
425
|
-
return this.normalize().multiplyScalar(length);
|
|
426
|
-
};
|
|
427
|
-
Vec4.prototype.lerp = function (v, alpha) {
|
|
428
|
-
this._x += (v.x - this._x) * alpha;
|
|
429
|
-
this._y += (v.y - this._y) * alpha;
|
|
430
|
-
this._z += (v.z - this._z) * alpha;
|
|
431
|
-
this._w += (v.w - this._w) * alpha;
|
|
432
|
-
return this;
|
|
433
|
-
};
|
|
434
|
-
Vec4.prototype.lerpVecs = function (v1, v2, alpha) {
|
|
435
|
-
return this.subVecs(v2, v1)
|
|
436
|
-
.multiplyScalar(alpha)
|
|
437
|
-
.add(v1);
|
|
438
|
-
};
|
|
439
|
-
Vec4.prototype.equals = function (v) {
|
|
440
|
-
return v.x === this._x && v.y === this._y && v.z === this._z && v.w === this._w;
|
|
441
|
-
};
|
|
442
|
-
Vec4.prototype.fromArray = function (array, offset) {
|
|
443
|
-
if (offset === void 0) { offset = 0; }
|
|
444
|
-
this._x = array[offset];
|
|
445
|
-
this._y = array[offset + 1];
|
|
446
|
-
this._z = array[offset + 2];
|
|
447
|
-
this._w = array[offset + 3];
|
|
448
|
-
return this;
|
|
449
|
-
};
|
|
450
|
-
Vec4.prototype.toArray = function (array, offset) {
|
|
451
|
-
if (array === void 0) { array = []; }
|
|
452
|
-
if (offset === void 0) { offset = 0; }
|
|
453
|
-
array[offset] = this._x;
|
|
454
|
-
array[offset + 1] = this._y;
|
|
455
|
-
array[offset + 2] = this._z;
|
|
456
|
-
array[offset + 3] = this._w;
|
|
457
|
-
return array;
|
|
458
|
-
};
|
|
459
|
-
Vec4.prototype.fromBufferAttribute = function (attribute, index, offset) {
|
|
460
|
-
if (offset !== undefined) {
|
|
461
|
-
console.warn("Vec4: offset has been removed from .fromBufferAttribute().");
|
|
462
|
-
}
|
|
463
|
-
this._x = attribute.getX(index);
|
|
464
|
-
this._y = attribute.getY(index);
|
|
465
|
-
this._z = attribute.getZ(index);
|
|
466
|
-
this._w = attribute.getW(index);
|
|
467
|
-
return this;
|
|
468
|
-
};
|
|
469
|
-
return Vec4;
|
|
470
|
-
}());
|
|
471
|
-
exports.Vec4 = Vec4;
|
|
472
|
-
function v4(x, y, z, w) {
|
|
473
|
-
return new Vec4(x, y, z, w);
|
|
474
|
-
}
|
|
475
|
-
exports.v4 = v4;
|
package/dist/math/vecs.d.ts
DELETED
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 当向量以数组的方式出现,一个计算单元库
|
|
3
|
-
* @Description : 向量数组
|
|
4
|
-
* @Author : 赵耀圣
|
|
5
|
-
* @QQ : 549184003
|
|
6
|
-
* @Date : 2021-08-02 15:09:33
|
|
7
|
-
* @LastEditTime : 2021-08-02 15:50:16
|
|
8
|
-
* @FilePath : \cga.js\src\math\VecArray.ts
|
|
9
|
-
*/
|
|
10
|
-
import { Vec2 } from './Vec2';
|
|
11
|
-
import { Vec3 } from './Vec3';
|
|
12
|
-
import { ArrayList } from '../struct/data/ArrayList';
|
|
13
|
-
import { Vec4 } from './Vec4';
|
|
14
|
-
import { Mat4 } from "./Mat4";
|
|
15
|
-
import { Quat } from "./Quat";
|
|
16
|
-
import { TypedArrayLike } from "../render/types";
|
|
17
|
-
/**
|
|
18
|
-
* 矢量几何操作,数字数组/矢量数组,常用工具集合
|
|
19
|
-
*/
|
|
20
|
-
export declare class vecs {
|
|
21
|
-
/**
|
|
22
|
-
* 去除相邻的重复向量
|
|
23
|
-
* @param vs 矢量集合
|
|
24
|
-
* @param delta 误差
|
|
25
|
-
* @returns
|
|
26
|
-
*/
|
|
27
|
-
static uniqueNeighborVecs(vs: Array<Vec3>, delta?: number): Vec3[];
|
|
28
|
-
/**
|
|
29
|
-
* 找到最大值
|
|
30
|
-
* @param array
|
|
31
|
-
* @returns
|
|
32
|
-
*/
|
|
33
|
-
static max(array: ArrayLike<number>): number;
|
|
34
|
-
/**
|
|
35
|
-
* 找到最小值
|
|
36
|
-
* @param array
|
|
37
|
-
* @returns
|
|
38
|
-
*/
|
|
39
|
-
static min(array: ArrayLike<number>): number;
|
|
40
|
-
/**
|
|
41
|
-
* 去除相邻没有重复点
|
|
42
|
-
*/
|
|
43
|
-
static uniqueNeighbor(vs: number[], component?: number, delta?: number): number[];
|
|
44
|
-
/**
|
|
45
|
-
* 去除任意重复点
|
|
46
|
-
* @param vs 向量数组
|
|
47
|
-
* @param component 向量组件数量
|
|
48
|
-
* @returns 无重复向量数组
|
|
49
|
-
*/
|
|
50
|
-
static unique(vs: number[], component?: number): number[];
|
|
51
|
-
/**
|
|
52
|
-
* 翻转向量数组
|
|
53
|
-
* @param vecs 向量数组
|
|
54
|
-
* @param component 组件数量
|
|
55
|
-
* @returns
|
|
56
|
-
*/
|
|
57
|
-
static reverse(vecs: number[], component?: number): number[];
|
|
58
|
-
/**
|
|
59
|
-
* 点积
|
|
60
|
-
* @param vecs
|
|
61
|
-
* @returns
|
|
62
|
-
*/
|
|
63
|
-
static dot(...vecs: number[]): number;
|
|
64
|
-
/**
|
|
65
|
-
* 长度平方
|
|
66
|
-
* @param vecs
|
|
67
|
-
* @returns
|
|
68
|
-
*/
|
|
69
|
-
static distanceSq(...vecs: number[]): number;
|
|
70
|
-
/**
|
|
71
|
-
* 长度
|
|
72
|
-
* @param vecs
|
|
73
|
-
* @returns
|
|
74
|
-
*/
|
|
75
|
-
static distance(...vecs: number[]): number;
|
|
76
|
-
/**
|
|
77
|
-
* 相加
|
|
78
|
-
* @param vecs
|
|
79
|
-
* @returns
|
|
80
|
-
*/
|
|
81
|
-
static add(...vecs: number[]): number[] | (number & any[]);
|
|
82
|
-
/**
|
|
83
|
-
* 相减
|
|
84
|
-
* @param vecs
|
|
85
|
-
* @returns
|
|
86
|
-
*/
|
|
87
|
-
static sub(...vecs: number[]): number[];
|
|
88
|
-
/**
|
|
89
|
-
* 相乘
|
|
90
|
-
* @param vecs
|
|
91
|
-
* @returns
|
|
92
|
-
*/
|
|
93
|
-
static mul(...vecs: number[]): number[] | (number & any[]);
|
|
94
|
-
/**
|
|
95
|
-
* 获取矢量数组的i个矢量
|
|
96
|
-
* @param vecs
|
|
97
|
-
* @param i
|
|
98
|
-
* @param component
|
|
99
|
-
* @returns
|
|
100
|
-
*/
|
|
101
|
-
static getVecAt(vecs: number[], i: number, component?: number): number[];
|
|
102
|
-
/**
|
|
103
|
-
* 在第 i 个位置插入一个向量
|
|
104
|
-
* @param vecs
|
|
105
|
-
* @param i
|
|
106
|
-
* @param vec
|
|
107
|
-
*/
|
|
108
|
-
static insertAt(vecs: number[], i: number, ...vec: number[]): void;
|
|
109
|
-
/**
|
|
110
|
-
* 是否逆时针
|
|
111
|
-
* counterclockwise
|
|
112
|
-
*/
|
|
113
|
-
static isCCW<T>(shape: Array<T> | ArrayList<T>, component?: number): boolean;
|
|
114
|
-
/**
|
|
115
|
-
* 将向量深度拆解为数字
|
|
116
|
-
* @param {Array} Array<Vec4 | Vec3 | Vec2 | any> | any
|
|
117
|
-
* @param {String} comSort 'x','y','z','w' 按顺序选取后自由组合
|
|
118
|
-
* @returns {Array<Number>} 数字数组
|
|
119
|
-
*/
|
|
120
|
-
static verctorToNumbers(vectors: Array<Vec4 | Vec3 | Vec2 | any> | any, comSort?: string): number[];
|
|
121
|
-
static vec(component?: number): Vec3 | Vec4 | Vec2;
|
|
122
|
-
/**
|
|
123
|
-
* 数字数组 转 适量数组
|
|
124
|
-
* @param vss 数字数组
|
|
125
|
-
* @param component 矢量维度,默认为3
|
|
126
|
-
* @returns
|
|
127
|
-
*/
|
|
128
|
-
static numbersToVecs(vss: TypedArrayLike, component?: number): Vec2[] | Vec3[] | Vec4[];
|
|
129
|
-
static applyQuat(vss: TypedArrayLike, quat: Quat, component?: number): void;
|
|
130
|
-
static applyMat4(vss: TypedArrayLike, mat: Mat4, component?: number): void;
|
|
131
|
-
static translate(vss: TypedArrayLike, distance: number[], component?: number): void;
|
|
132
|
-
static rotate(vss: TypedArrayLike, axis: Vec3, angle: number): void;
|
|
133
|
-
static scale(vss: TypedArrayLike, _scale: number[], component?: number): void;
|
|
134
|
-
}
|