@xort/cga 0.0.71
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/.github/FUNDING.yml +12 -0
- package/LICENSE +21 -0
- package/build/cga.js +14564 -0
- 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 +601 -0
- 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 +111 -0
- package/cga/2./347/202/271/344/270/216/351/235/242/346/200/247/345/205/203/347/264/240.md +4 -0
- 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 +27 -0
- package/dist/IKanimation/Bone.d.ts +9 -0
- package/dist/IKanimation/Bone.js +38 -0
- package/dist/IKanimation/CCDSolver.d.ts +37 -0
- package/dist/IKanimation/CCDSolver.js +93 -0
- package/dist/IKanimation/Joint.d.ts +3 -0
- package/dist/IKanimation/Joint.js +17 -0
- package/dist/IKanimation/constaint/constraint.d.ts +10 -0
- package/dist/IKanimation/constaint/constraint.js +25 -0
- package/dist/IKanimation/constaint/hinge.d.ts +12 -0
- package/dist/IKanimation/constaint/hinge.js +44 -0
- package/dist/IKanimation/constaint/slider.d.ts +12 -0
- package/dist/IKanimation/constaint/slider.js +42 -0
- package/dist/IKanimation/index.d.ts +0 -0
- package/dist/IKanimation/index.js +9 -0
- package/dist/IKanimation/isolver.d.ts +4 -0
- package/dist/IKanimation/isolver.js +10 -0
- package/dist/IKanimation/skeleton.d.ts +13 -0
- package/dist/IKanimation/skeleton.js +31 -0
- package/dist/alg/common.d.ts +114 -0
- package/dist/alg/common.js +302 -0
- package/dist/alg/curve.d.ts +4 -0
- package/dist/alg/curve.js +11 -0
- package/dist/alg/delaunator.d.ts +29 -0
- package/dist/alg/delaunator.js +442 -0
- package/dist/alg/delaunay.d.ts +20 -0
- package/dist/alg/delaunay.js +199 -0
- package/dist/alg/delaunayslow.d.ts +18 -0
- package/dist/alg/delaunayslow.js +140 -0
- package/dist/alg/extrude/extrude.d.ts +3 -0
- package/dist/alg/extrude/extrude.js +17 -0
- package/dist/alg/extrude.d.ts +199 -0
- package/dist/alg/extrude.js +729 -0
- package/dist/alg/offset/index.d.ts +0 -0
- package/dist/alg/offset/index.js +9 -0
- package/dist/alg/offset.d.ts +0 -0
- package/dist/alg/offset.js +472 -0
- package/dist/alg/pointset.d.ts +94 -0
- package/dist/alg/pointset.js +223 -0
- package/dist/alg/recognition.d.ts +14 -0
- package/dist/alg/recognition.js +37 -0
- package/dist/alg/result.d.ts +22 -0
- package/dist/alg/result.js +2 -0
- package/dist/alg/segmentset.d.ts +11 -0
- package/dist/alg/segmentset.js +45 -0
- package/dist/alg/sort.d.ts +2 -0
- package/dist/alg/sort.js +14 -0
- package/dist/alg/split.d.ts +8 -0
- package/dist/alg/split.js +10 -0
- package/dist/alg/trianglution.d.ts +20 -0
- package/dist/alg/trianglution.js +75 -0
- package/dist/alg/vol.d.ts +6 -0
- package/dist/alg/vol.js +18 -0
- package/dist/alg/voronoi.d.ts +31 -0
- package/dist/alg/voronoi.js +418 -0
- package/dist/app.d.ts +1 -0
- package/dist/app.js +241 -0
- package/dist/basic/distance.d.ts +12 -0
- package/dist/basic/distance.js +42 -0
- package/dist/csg/bsp.d.ts +9 -0
- package/dist/csg/bsp.js +22 -0
- package/dist/csg/node.d.ts +12 -0
- package/dist/csg/node.js +75 -0
- package/dist/csg/polygon.d.ts +43 -0
- package/dist/csg/polygon.js +161 -0
- package/dist/diamondMaterialShader.d.ts +92 -0
- package/dist/diamondMaterialShader.js +114 -0
- package/dist/effect/breath-light.d.ts +4 -0
- package/dist/effect/breath-light.js +37 -0
- package/dist/extends/geometryaid.d.ts +28 -0
- package/dist/extends/geometryaid.js +80 -0
- package/dist/extends/split.d.ts +3 -0
- package/dist/extends/split.js +13 -0
- package/dist/glview.d.ts +112 -0
- package/dist/glview.js +564 -0
- package/dist/index.d.ts +36 -0
- package/dist/index.js +50 -0
- package/dist/math/Euler.d.ts +47 -0
- package/dist/math/Euler.js +243 -0
- package/dist/math/HVec3.d.ts +44 -0
- package/dist/math/HVec3.js +193 -0
- package/dist/math/Mat3.d.ts +29 -0
- package/dist/math/Mat3.js +244 -0
- package/dist/math/Mat4.d.ts +85 -0
- package/dist/math/Mat4.js +791 -0
- package/dist/math/Math.d.ts +130 -0
- package/dist/math/Math.js +198 -0
- package/dist/math/Quat.d.ts +83 -0
- package/dist/math/Quat.js +438 -0
- package/dist/math/Vec.d.ts +7 -0
- package/dist/math/Vec.js +41 -0
- package/dist/math/Vec2.d.ts +68 -0
- package/dist/math/Vec2.js +345 -0
- package/dist/math/Vec3.d.ts +232 -0
- package/dist/math/Vec3.js +1087 -0
- package/dist/math/Vec4.d.ts +81 -0
- package/dist/math/Vec4.js +492 -0
- package/dist/math/vector.d.ts +114 -0
- package/dist/math/vector.js +371 -0
- package/dist/render/buffer-attribute.d.ts +100 -0
- package/dist/render/buffer-attribute.js +356 -0
- package/dist/render/eventhandler.d.ts +78 -0
- package/dist/render/eventhandler.js +187 -0
- package/dist/render/geometry.d.ts +89 -0
- package/dist/render/geometry.js +775 -0
- package/dist/render/mesh.d.ts +25 -0
- package/dist/render/mesh.js +80 -0
- package/dist/render/thing.d.ts +34 -0
- package/dist/render/thing.js +194 -0
- package/dist/render/types.d.ts +2 -0
- package/dist/render/types.js +7 -0
- package/dist/robust/plane.d.ts +7 -0
- package/dist/robust/plane.js +17 -0
- package/dist/robust/vec.d.ts +15 -0
- package/dist/robust/vec.js +71 -0
- package/dist/shape/arc.d.ts +2 -0
- package/dist/shape/arc.js +14 -0
- package/dist/src/IKanimation/Bone.d.ts +9 -0
- package/dist/src/IKanimation/Bone.js +40 -0
- package/dist/src/IKanimation/CCDSolver.d.ts +37 -0
- package/dist/src/IKanimation/CCDSolver.js +93 -0
- package/dist/src/IKanimation/Joint.d.ts +3 -0
- package/dist/src/IKanimation/Joint.js +17 -0
- package/dist/src/IKanimation/constaint/constraint.d.ts +10 -0
- package/dist/src/IKanimation/constaint/constraint.js +25 -0
- package/dist/src/IKanimation/constaint/hinge.d.ts +12 -0
- package/dist/src/IKanimation/constaint/hinge.js +46 -0
- package/dist/src/IKanimation/constaint/slider.d.ts +12 -0
- package/dist/src/IKanimation/constaint/slider.js +44 -0
- package/dist/src/IKanimation/index.d.ts +0 -0
- package/dist/src/IKanimation/index.js +9 -0
- package/dist/src/IKanimation/isolver.d.ts +4 -0
- package/dist/src/IKanimation/isolver.js +10 -0
- package/dist/src/IKanimation/skeleton.d.ts +13 -0
- package/dist/src/IKanimation/skeleton.js +31 -0
- package/dist/src/alg/common.d.ts +114 -0
- package/dist/src/alg/common.js +302 -0
- package/dist/src/alg/curve.d.ts +4 -0
- package/dist/src/alg/curve.js +11 -0
- package/dist/src/alg/delaunator.d.ts +29 -0
- package/dist/src/alg/delaunator.js +442 -0
- package/dist/src/alg/delaunay.d.ts +20 -0
- package/dist/src/alg/delaunay.js +199 -0
- package/dist/src/alg/delaunayslow.d.ts +18 -0
- package/dist/src/alg/delaunayslow.js +140 -0
- package/dist/src/alg/extrude/extrude.d.ts +3 -0
- package/dist/src/alg/extrude/extrude.js +17 -0
- package/dist/src/alg/extrude.d.ts +199 -0
- package/dist/src/alg/extrude.js +731 -0
- package/dist/src/alg/offset/index.d.ts +0 -0
- package/dist/src/alg/offset/index.js +9 -0
- package/dist/src/alg/offset.d.ts +0 -0
- package/dist/src/alg/offset.js +472 -0
- package/dist/src/alg/pointset.d.ts +94 -0
- package/dist/src/alg/pointset.js +223 -0
- package/dist/src/alg/recognition.d.ts +14 -0
- package/dist/src/alg/recognition.js +37 -0
- package/dist/src/alg/result.d.ts +22 -0
- package/dist/src/alg/result.js +2 -0
- package/dist/src/alg/segmentset.d.ts +11 -0
- package/dist/src/alg/segmentset.js +45 -0
- package/dist/src/alg/sort.d.ts +2 -0
- package/dist/src/alg/sort.js +14 -0
- package/dist/src/alg/split.d.ts +8 -0
- package/dist/src/alg/split.js +10 -0
- package/dist/src/alg/trianglution.d.ts +20 -0
- package/dist/src/alg/trianglution.js +77 -0
- package/dist/src/alg/vol.d.ts +6 -0
- package/dist/src/alg/vol.js +18 -0
- package/dist/src/alg/voronoi.d.ts +31 -0
- package/dist/src/alg/voronoi.js +418 -0
- package/dist/src/app.d.ts +1 -0
- package/dist/src/app.js +245 -0
- package/dist/src/basic/distance.d.ts +12 -0
- package/dist/src/basic/distance.js +42 -0
- package/dist/src/csg/bsp.d.ts +9 -0
- package/dist/src/csg/bsp.js +22 -0
- package/dist/src/csg/node.d.ts +12 -0
- package/dist/src/csg/node.js +75 -0
- package/dist/src/csg/polygon.d.ts +43 -0
- package/dist/src/csg/polygon.js +161 -0
- package/dist/src/diamondMaterialShader.d.ts +92 -0
- package/dist/src/diamondMaterialShader.js +118 -0
- package/dist/src/effect/breath-light.d.ts +4 -0
- package/dist/src/effect/breath-light.js +39 -0
- package/dist/src/extends/geometryaid.d.ts +28 -0
- package/dist/src/extends/geometryaid.js +80 -0
- package/dist/src/extends/split.d.ts +3 -0
- package/dist/src/extends/split.js +13 -0
- package/dist/src/glview.d.ts +112 -0
- package/dist/src/glview.js +564 -0
- package/dist/src/index.d.ts +36 -0
- package/dist/src/index.js +54 -0
- package/dist/src/math/Euler.d.ts +47 -0
- package/dist/src/math/Euler.js +245 -0
- package/dist/src/math/HVec3.d.ts +44 -0
- package/dist/src/math/HVec3.js +195 -0
- package/dist/src/math/Mat3.d.ts +29 -0
- package/dist/src/math/Mat3.js +244 -0
- package/dist/src/math/Mat4.d.ts +85 -0
- package/dist/src/math/Mat4.js +791 -0
- package/dist/src/math/Math.d.ts +130 -0
- package/dist/src/math/Math.js +198 -0
- package/dist/src/math/Quat.d.ts +83 -0
- package/dist/src/math/Quat.js +440 -0
- package/dist/src/math/Vec.d.ts +7 -0
- package/dist/src/math/Vec.js +43 -0
- package/dist/src/math/Vec2.d.ts +68 -0
- package/dist/src/math/Vec2.js +347 -0
- package/dist/src/math/Vec3.d.ts +232 -0
- package/dist/src/math/Vec3.js +1089 -0
- package/dist/src/math/Vec4.d.ts +81 -0
- package/dist/src/math/Vec4.js +494 -0
- package/dist/src/math/vector.d.ts +114 -0
- package/dist/src/math/vector.js +373 -0
- package/dist/src/render/buffer-attribute.d.ts +100 -0
- package/dist/src/render/buffer-attribute.js +340 -0
- package/dist/src/render/eventhandler.d.ts +78 -0
- package/dist/src/render/eventhandler.js +189 -0
- package/dist/src/render/geometry.d.ts +89 -0
- package/dist/src/render/geometry.js +775 -0
- package/dist/src/render/mesh.d.ts +25 -0
- package/dist/src/render/mesh.js +82 -0
- package/dist/src/render/thing.d.ts +34 -0
- package/dist/src/render/thing.js +196 -0
- package/dist/src/render/types.d.ts +2 -0
- package/dist/src/render/types.js +8 -0
- package/dist/src/robust/plane.d.ts +7 -0
- package/dist/src/robust/plane.js +17 -0
- package/dist/src/robust/vec.d.ts +15 -0
- package/dist/src/robust/vec.js +71 -0
- package/dist/src/shape/arc.d.ts +2 -0
- package/dist/src/shape/arc.js +14 -0
- package/dist/src/struct/3d/Box.d.ts +23 -0
- package/dist/src/struct/3d/Box.js +109 -0
- package/dist/src/struct/3d/Capsule.d.ts +12 -0
- package/dist/src/struct/3d/Capsule.js +36 -0
- package/dist/src/struct/3d/Circle.d.ts +34 -0
- package/dist/src/struct/3d/Circle.js +80 -0
- package/dist/src/struct/3d/Disk.d.ts +10 -0
- package/dist/src/struct/3d/Disk.js +22 -0
- package/dist/src/struct/3d/Frustum.d.ts +35 -0
- package/dist/src/struct/3d/Frustum.js +159 -0
- package/dist/src/struct/3d/Line.d.ts +40 -0
- package/dist/src/struct/3d/Line.js +339 -0
- package/dist/src/struct/3d/Path.d.ts +75 -0
- package/dist/src/struct/3d/Path.js +308 -0
- package/dist/src/struct/3d/Plane.d.ts +74 -0
- package/dist/src/struct/3d/Plane.js +295 -0
- package/dist/src/struct/3d/Point.d.ts +4 -0
- package/dist/src/struct/3d/Point.js +30 -0
- package/dist/src/struct/3d/Polygon.d.ts +8 -0
- package/dist/src/struct/3d/Polygon.js +55 -0
- package/dist/src/struct/3d/Polyline.d.ts +25 -0
- package/dist/src/struct/3d/Polyline.js +109 -0
- package/dist/src/struct/3d/Ray.d.ts +21 -0
- package/dist/src/struct/3d/Ray.js +262 -0
- package/dist/src/struct/3d/Rectangle.d.ts +7 -0
- package/dist/src/struct/3d/Rectangle.js +35 -0
- package/dist/src/struct/3d/Segment.d.ts +32 -0
- package/dist/src/struct/3d/Segment.js +334 -0
- package/dist/src/struct/3d/Shape.d.ts +4 -0
- package/dist/src/struct/3d/Shape.js +27 -0
- package/dist/src/struct/3d/Sphere.d.ts +11 -0
- package/dist/src/struct/3d/Sphere.js +30 -0
- package/dist/src/struct/3d/Triangle.d.ts +8 -0
- package/dist/src/struct/3d/Triangle.js +53 -0
- package/dist/src/struct/data/ArrayList.d.ts +42 -0
- package/dist/src/struct/data/ArrayList.js +172 -0
- package/dist/src/struct/data/ArrayObject.d.ts +30 -0
- package/dist/src/struct/data/ArrayObject.js +131 -0
- package/dist/src/struct/data/type.d.ts +13 -0
- package/dist/src/struct/data/type.js +18 -0
- package/dist/src/utils/array.d.ts +24 -0
- package/dist/src/utils/array.js +89 -0
- package/dist/src/utils/types.d.ts +24 -0
- package/dist/src/utils/types.js +20 -0
- package/dist/src-gis/app.d.ts +1 -0
- package/dist/src-gis/app.js +4 -0
- package/dist/src-gis/core/Cartographic.d.ts +20 -0
- package/dist/src-gis/core/Cartographic.js +52 -0
- package/dist/src-gis/core/EllipsoidGeodesic.d.ts +14 -0
- package/dist/src-gis/core/EllipsoidGeodesic.js +51 -0
- package/dist/src-gis/core/EllipsoidTerrainProvider.d.ts +10 -0
- package/dist/src-gis/core/EllipsoidTerrainProvider.js +29 -0
- package/dist/src-gis/core/HeightmapTerrainData.d.ts +3 -0
- package/dist/src-gis/core/HeightmapTerrainData.js +9 -0
- package/dist/src-gis/core/Rectangle.d.ts +45 -0
- package/dist/src-gis/core/Rectangle.js +127 -0
- package/dist/src-gis/core/TaskProcessor.d.ts +35 -0
- package/dist/src-gis/core/TaskProcessor.js +183 -0
- package/dist/src-gis/gis.d.ts +5 -0
- package/dist/src-gis/gis.js +12 -0
- package/dist/src-gis/globe.d.ts +12 -0
- package/dist/src-gis/globe.js +61 -0
- package/dist/src-gis/math/Cartographic.d.ts +8 -0
- package/dist/src-gis/math/Cartographic.js +26 -0
- package/dist/src-gis/math/GVec3.d.ts +12 -0
- package/dist/src-gis/math/GVec3.js +69 -0
- package/dist/src-gis/math/ellipsoid.d.ts +8 -0
- package/dist/src-gis/math/ellipsoid.js +14 -0
- package/dist/src-gis/provider/DcTerrainProvider.d.ts +15 -0
- package/dist/src-gis/provider/DcTerrainProvider.js +19 -0
- package/dist/src-gis/provider/TerrainProvider.d.ts +3 -0
- package/dist/src-gis/provider/TerrainProvider.js +17 -0
- package/dist/src-gis/scene/DcImageryProvider.d.ts +6 -0
- package/dist/src-gis/scene/DcImageryProvider.js +35 -0
- package/dist/src-gis/scene/GeographicTilingScheme.d.ts +21 -0
- package/dist/src-gis/scene/GeographicTilingScheme.js +46 -0
- package/dist/src-gis/scene/Globe.d.ts +34 -0
- package/dist/src-gis/scene/Globe.js +62 -0
- package/dist/src-gis/scene/GlobeSurfaceShaderSet.d.ts +6 -0
- package/dist/src-gis/scene/GlobeSurfaceShaderSet.js +11 -0
- package/dist/src-gis/scene/GlobeSurfaceTileProvider.d.ts +21 -0
- package/dist/src-gis/scene/GlobeSurfaceTileProvider.js +15 -0
- package/dist/src-gis/scene/ImageryLayerCollection.d.ts +21 -0
- package/dist/src-gis/scene/ImageryLayerCollection.js +87 -0
- package/dist/src-gis/scene/ImageryProvider.d.ts +4 -0
- package/dist/src-gis/scene/ImageryProvider.js +28 -0
- package/dist/src-gis/scene/QuadtreeTile.d.ts +48 -0
- package/dist/src-gis/scene/QuadtreeTile.js +137 -0
- package/dist/src-gis/scene/UrlTemplateImageryProvider.d.ts +9 -0
- package/dist/src-gis/scene/UrlTemplateImageryProvider.js +29 -0
- package/dist/src-gis/scene/quadtree_primitive.d.ts +14 -0
- package/dist/src-gis/scene/quadtree_primitive.js +50 -0
- package/dist/struct/3d/Box.d.ts +23 -0
- package/dist/struct/3d/Box.js +109 -0
- package/dist/struct/3d/Capsule.d.ts +12 -0
- package/dist/struct/3d/Capsule.js +34 -0
- package/dist/struct/3d/Circle.d.ts +34 -0
- package/dist/struct/3d/Circle.js +80 -0
- package/dist/struct/3d/Disk.d.ts +10 -0
- package/dist/struct/3d/Disk.js +22 -0
- package/dist/struct/3d/Frustum.d.ts +35 -0
- package/dist/struct/3d/Frustum.js +159 -0
- package/dist/struct/3d/Line.d.ts +40 -0
- package/dist/struct/3d/Line.js +339 -0
- package/dist/struct/3d/Path.d.ts +75 -0
- package/dist/struct/3d/Path.js +306 -0
- package/dist/struct/3d/Plane.d.ts +74 -0
- package/dist/struct/3d/Plane.js +293 -0
- package/dist/struct/3d/Point.d.ts +4 -0
- package/dist/struct/3d/Point.js +28 -0
- package/dist/struct/3d/Polygon.d.ts +8 -0
- package/dist/struct/3d/Polygon.js +53 -0
- package/dist/struct/3d/Polyline.d.ts +25 -0
- package/dist/struct/3d/Polyline.js +107 -0
- package/dist/struct/3d/Ray.d.ts +21 -0
- package/dist/struct/3d/Ray.js +262 -0
- package/dist/struct/3d/Rectangle.d.ts +7 -0
- package/dist/struct/3d/Rectangle.js +33 -0
- package/dist/struct/3d/Segment.d.ts +32 -0
- package/dist/struct/3d/Segment.js +332 -0
- package/dist/struct/3d/Shape.d.ts +4 -0
- package/dist/struct/3d/Shape.js +25 -0
- package/dist/struct/3d/Sphere.d.ts +11 -0
- package/dist/struct/3d/Sphere.js +30 -0
- package/dist/struct/3d/Triangle.d.ts +8 -0
- package/dist/struct/3d/Triangle.js +51 -0
- package/dist/struct/data/ArrayList.d.ts +42 -0
- package/dist/struct/data/ArrayList.js +170 -0
- package/dist/struct/data/ArrayObject.d.ts +30 -0
- package/dist/struct/data/ArrayObject.js +129 -0
- package/dist/struct/data/type.d.ts +13 -0
- package/dist/struct/data/type.js +18 -0
- package/dist/utils/array.d.ts +24 -0
- package/dist/utils/array.js +89 -0
- package/dist/utils/types.d.ts +24 -0
- package/dist/utils/types.js +20 -0
- package/docs/.vuepress/components/distance.vue +125 -0
- package/docs/.vuepress/components/intersect.vue +0 -0
- package/docs/.vuepress/components/trianglution.vue +121 -0
- package/docs/.vuepress/components/utils.js +314 -0
- package/docs/.vuepress/config.js +99 -0
- package/docs/.vuepress/enhanceApp.js +13 -0
- 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 +14 -0
- package/docs/demo/README.md +9 -0
- package/docs/guide/README.md +94 -0
- package/docs/guide/array.md +10 -0
- package/docs/guide/cy/trianglution.html +2 -0
- package/docs/guide/distLineAll.md +85 -0
- package/docs/guide/distPointAll.md +137 -0
- package/docs/guide/distRayAll.md +69 -0
- package/docs/guide/distSegmentAll.md +19 -0
- package/docs/guide/point.vue +12 -0
- package/docs/guide/vector.md +10 -0
- package/docs/guide//345/270/270/347/224/250.md +156 -0
- package/docs/sponsor/README.md +15 -0
- 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 +6 -0
- package/effect/common.glsl +34 -0
- package/effect/drawing.glsl +36 -0
- package/effect/shape.arc.glsl +13 -0
- package/effect/shape.circle.glsl +13 -0
- package/effect/shape.grid.glsl +42 -0
- package/effect/shape.line.glsl +18 -0
- package/effect/shape.pie.glsl +18 -0
- package/effect/shape.plot.glsl +10 -0
- package/effect/shape.poly.glsl +15 -0
- package/effect/shape.rect.glsl +14 -0
- package/effect/shape.rectround.glsl +15 -0
- package/effect/shape.segment.glsl +10 -0
- package/effect/shape.spiral.glsl +12 -0
- package/effect/shape.star.glsl +16 -0
- package/examples/index.html +31 -0
- package/git.sh +12 -0
- package/image/readme/1640758500266.png +0 -0
- package/image/readme/1640758513361.png +0 -0
- package/index.html +14 -0
- package/linear algorithm//346/225/260/345/255/246/350/241/250/350/276/276/345/274/217.md" +122 -0
- package/linear algorithm//347/237/251/351/230/265.md" +91 -0
- package/package.json +72 -0
- package/readme.md +247 -0
- package/rollup.config.js +71 -0
- package/scripttest.html +23 -0
- package/src/IKanimation/Bone.ts +24 -0
- package/src/IKanimation/CCDSolver.ts +114 -0
- package/src/IKanimation/Joint.ts +13 -0
- package/src/IKanimation/constaint/constraint.ts +23 -0
- package/src/IKanimation/constaint/hinge.ts +29 -0
- package/src/IKanimation/constaint/slider.ts +25 -0
- package/src/IKanimation/index.ts +8 -0
- package/src/IKanimation/isolver.ts +13 -0
- package/src/IKanimation/skeleton.ts +30 -0
- package/src/alg/common.ts +304 -0
- package/src/alg/curve.ts +9 -0
- package/src/alg/delaunator.ts +519 -0
- package/src/alg/delaunay.ts +163 -0
- package/src/alg/delaunayslow.ts +183 -0
- package/src/alg/extrude/extrude.ts +19 -0
- package/src/alg/extrude.ts +941 -0
- package/src/alg/offset/index.ts +8 -0
- package/src/alg/offset.ts +501 -0
- package/src/alg/pointset.ts +219 -0
- package/src/alg/recognition.ts +43 -0
- package/src/alg/result.ts +24 -0
- package/src/alg/segmentset.ts +44 -0
- package/src/alg/sort.ts +11 -0
- package/src/alg/split.ts +15 -0
- package/src/alg/trianglution.ts +58 -0
- package/src/alg/vol.ts +18 -0
- package/src/alg/voronoi.ts +303 -0
- package/src/app.css +12 -0
- package/src/app.ts +290 -0
- package/src/assets/color.jpg +0 -0
- package/src/basic/distance.ts +40 -0
- package/src/clipper/clipper.d.ts +323 -0
- package/src/clipper/clipper.js +7626 -0
- package/src/clipper/clipper_float.js +185 -0
- package/src/clipper/clipper_float_unminified.js +5639 -0
- package/src/clipper/clipperint.js +7626 -0
- package/src/csg/bsp.ts +24 -0
- package/src/csg/csg.js +583 -0
- package/src/csg/node.ts +91 -0
- package/src/csg/polygon.ts +177 -0
- package/src/diamondMaterialShader.ts +93 -0
- package/src/effect/breath-light.ts +24 -0
- package/src/extends/geometryaid.ts +89 -0
- package/src/extends/split.ts +15 -0
- package/src/glview.ts +570 -0
- package/src/index.ts +44 -0
- package/src/math/Euler.ts +239 -0
- package/src/math/HVec3.ts +1146 -0
- package/src/math/Mat3.ts +365 -0
- package/src/math/Mat4.ts +1134 -0
- package/src/math/Math.ts +213 -0
- package/src/math/Quat.ts +541 -0
- package/src/math/Vec.ts +26 -0
- package/src/math/Vec2.ts +408 -0
- package/src/math/Vec3.ts +1294 -0
- package/src/math/Vec4.ts +587 -0
- package/src/math/vector.ts +378 -0
- package/src/render/buffer-attribute.ts +484 -0
- package/src/render/eventhandler.ts +193 -0
- package/src/render/geometry.ts +1326 -0
- package/src/render/mesh.ts +80 -0
- package/src/render/thing.ts +204 -0
- package/src/render/types.ts +15 -0
- package/src/robust/plane.ts +12 -0
- package/src/robust/readme.md +1 -0
- package/src/robust/vec.ts +61 -0
- package/src/shader/cga.glsl +202 -0
- package/src/shader/common.glsl +87 -0
- package/src/shader/noise/GLSL-Noise.md +1108 -0
- package/src/shader/noise/cellular2D.glsl +69 -0
- package/src/shader/noise/cellular2x2.glsl +64 -0
- package/src/shader/noise/cellular2x2x2.glsl +88 -0
- package/src/shader/noise/cellular3D.glsl +187 -0
- package/src/shader/noise/classicnoise2D.glsl +113 -0
- package/src/shader/noise/classicnoise3D.glsl +177 -0
- package/src/shader/noise/classicnoise4D.glsl +302 -0
- package/src/shader/noise/noise2D.glsl +71 -0
- package/src/shader/noise/noise3D.glsl +103 -0
- package/src/shader/noise/noise3Dgrad.glsl +111 -0
- package/src/shader/noise/noise4D.glsl +129 -0
- package/src/shader/noise/psrdnoise2D.glsl +462 -0
- package/src/shape/arc.ts +14 -0
- package/src/struct/3d/Box.ts +124 -0
- package/src/struct/3d/Capsule.ts +18 -0
- package/src/struct/3d/Circle.ts +78 -0
- package/src/struct/3d/Disk.ts +22 -0
- package/src/struct/3d/Frustum.ts +189 -0
- package/src/struct/3d/Line.ts +378 -0
- package/src/struct/3d/Path.ts +314 -0
- package/src/struct/3d/Plane.ts +339 -0
- package/src/struct/3d/Point.ts +7 -0
- package/src/struct/3d/PolyLine.ts +98 -0
- package/src/struct/3d/Polygon.ts +44 -0
- package/src/struct/3d/Ray.ts +285 -0
- package/src/struct/3d/Rectangle.ts +18 -0
- package/src/struct/3d/Segment.ts +330 -0
- package/src/struct/3d/Shape.ts +7 -0
- package/src/struct/3d/Sphere.ts +31 -0
- package/src/struct/3d/Triangle.ts +28 -0
- package/src/struct/data/ArrayList.ts +144 -0
- package/src/struct/data/ArrayObject.ts +105 -0
- package/src/struct/data/type.ts +14 -0
- package/src/utils/array.ts +106 -0
- package/src/utils/types.ts +42 -0
- package/src-gis/app.ts +7 -0
- package/src-gis/core/Cartographic.ts +48 -0
- package/src-gis/core/EllipsoidGeodesic.ts +56 -0
- package/src-gis/core/EllipsoidTerrainProvider.ts +35 -0
- package/src-gis/core/HeightmapTerrainData.ts +5 -0
- package/src-gis/core/Rectangle.ts +112 -0
- package/src-gis/core/TaskProcessor.ts +222 -0
- package/src-gis/gis.ts +25 -0
- package/src-gis/globe.ts +54 -0
- package/src-gis/math/Cartographic.ts +24 -0
- package/src-gis/math/GVec3.ts +55 -0
- package/src-gis/math/ellipsoid.ts +13 -0
- package/src-gis/provider/DcTerrainProvider.ts +36 -0
- package/src-gis/provider/TerrainProvider.ts +12 -0
- package/src-gis/scene/DcImageryProvider.ts +36 -0
- package/src-gis/scene/GeographicTilingScheme.ts +65 -0
- package/src-gis/scene/Globe.ts +76 -0
- package/src-gis/scene/GlobeSurfaceShaderSet.ts +9 -0
- package/src-gis/scene/GlobeSurfaceTileProvider.ts +25 -0
- package/src-gis/scene/ImageryLayerCollection.ts +75 -0
- package/src-gis/scene/ImageryProvider.ts +28 -0
- package/src-gis/scene/QuadtreeTile.ts +162 -0
- package/src-gis/scene/UrlTemplateImageryProvider.ts +32 -0
- package/src-gis/scene/quadtree_primitive.ts +58 -0
- package/tsconfig.json +75 -0
- package/webpack.config.js +112 -0
- package//350/256/241/347/256/227/345/207/240/344/275/225/351/227/256/351/242/230.md +26 -0
package/src/math/Quat.ts
ADDED
|
@@ -0,0 +1,541 @@
|
|
|
1
|
+
import { clamp } from "./Math";
|
|
2
|
+
import { Euler } from './Euler';
|
|
3
|
+
import { EventHandler } from '../render/eventhandler';
|
|
4
|
+
|
|
5
|
+
export class Quat extends EventHandler {
|
|
6
|
+
isQuat: boolean = true;
|
|
7
|
+
constructor(public _x: number = 0, public _y: number = 0, public _z: number = 0, public _w: number = 1) {
|
|
8
|
+
super();
|
|
9
|
+
}
|
|
10
|
+
get x() {
|
|
11
|
+
return this._x;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
set x(value) {
|
|
15
|
+
if (this._x !== value) {
|
|
16
|
+
this._x = value;
|
|
17
|
+
this.fire('change', 'x', this._x, value)
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
get y() {
|
|
22
|
+
return this._y;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
set y(value) {
|
|
26
|
+
if (this._y !== value) {
|
|
27
|
+
this._y = value;
|
|
28
|
+
this.fire('change', 'y', this._y, value)
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
get z() {
|
|
33
|
+
return this._z;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
set z(value) {
|
|
37
|
+
if (this._z !== value) {
|
|
38
|
+
this._z = value;
|
|
39
|
+
this.fire('change', 'z', this._z, value)
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
get w() {
|
|
44
|
+
return this._w;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
set w(value) {
|
|
48
|
+
if (this._w !== value) {
|
|
49
|
+
this._w = value;
|
|
50
|
+
this.fire('change', 'w', this._w, value)
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
static slerp(qa: any, qb: any, qm: { copy: (arg0: any) => { (): any; new(): any; slerp: { (arg0: any, arg1: any): any; new(): any; }; }; }, t: any) {
|
|
55
|
+
return qm.copy(qa).slerp(qb, t);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
static slerpFlat(dst: { [x: string]: any; }, dstOffset: number, src0: { [x: string]: any; }, srcOffset0: number, src1: { [x: string]: any; }, srcOffset1: number, t: number) {
|
|
59
|
+
// fuzz-free, array-based Quat SLERP operation
|
|
60
|
+
|
|
61
|
+
var x0 = src0[srcOffset0 + 0],
|
|
62
|
+
y0 = src0[srcOffset0 + 1],
|
|
63
|
+
z0 = src0[srcOffset0 + 2],
|
|
64
|
+
w0 = src0[srcOffset0 + 3],
|
|
65
|
+
x1 = src1[srcOffset1 + 0],
|
|
66
|
+
y1 = src1[srcOffset1 + 1],
|
|
67
|
+
z1 = src1[srcOffset1 + 2],
|
|
68
|
+
w1 = src1[srcOffset1 + 3];
|
|
69
|
+
|
|
70
|
+
if (w0 !== w1 || x0 !== x1 || y0 !== y1 || z0 !== z1) {
|
|
71
|
+
var s = 1 - t,
|
|
72
|
+
cos = x0 * x1 + y0 * y1 + z0 * z1 + w0 * w1,
|
|
73
|
+
dir = cos >= 0 ? 1 : -1,
|
|
74
|
+
sqrSin = 1 - cos * cos;
|
|
75
|
+
|
|
76
|
+
// Skip the Slerp for tiny steps to avoid numeric problems:
|
|
77
|
+
if (sqrSin > Number.EPSILON) {
|
|
78
|
+
var sin = Math.sqrt(sqrSin),
|
|
79
|
+
len = Math.atan2(sin, cos * dir);
|
|
80
|
+
|
|
81
|
+
s = Math.sin(s * len) / sin;
|
|
82
|
+
t = Math.sin(t * len) / sin;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
var tDir = t * dir;
|
|
86
|
+
|
|
87
|
+
x0 = x0 * s + x1 * tDir;
|
|
88
|
+
y0 = y0 * s + y1 * tDir;
|
|
89
|
+
z0 = z0 * s + z1 * tDir;
|
|
90
|
+
w0 = w0 * s + w1 * tDir;
|
|
91
|
+
|
|
92
|
+
// Normalize in case we just did a lerp:
|
|
93
|
+
if (s === 1 - t) {
|
|
94
|
+
var f = 1 / Math.sqrt(x0 * x0 + y0 * y0 + z0 * z0 + w0 * w0);
|
|
95
|
+
|
|
96
|
+
x0 *= f;
|
|
97
|
+
y0 *= f;
|
|
98
|
+
z0 *= f;
|
|
99
|
+
w0 *= f;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
dst[dstOffset] = x0;
|
|
104
|
+
dst[dstOffset + 1] = y0;
|
|
105
|
+
dst[dstOffset + 2] = z0;
|
|
106
|
+
dst[dstOffset + 3] = w0;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
static multiplyQuatsFlat(dst: { [x: string]: number; }, dstOffset: number, src0: { [x: string]: any; }, srcOffset0: number, src1: { [x: string]: any; }, srcOffset1: number) {
|
|
110
|
+
|
|
111
|
+
var x0 = src0[srcOffset0];
|
|
112
|
+
var y0 = src0[srcOffset0 + 1];
|
|
113
|
+
var z0 = src0[srcOffset0 + 2];
|
|
114
|
+
var w0 = src0[srcOffset0 + 3];
|
|
115
|
+
|
|
116
|
+
var x1 = src1[srcOffset1];
|
|
117
|
+
var y1 = src1[srcOffset1 + 1];
|
|
118
|
+
var z1 = src1[srcOffset1 + 2];
|
|
119
|
+
var w1 = src1[srcOffset1 + 3];
|
|
120
|
+
|
|
121
|
+
dst[dstOffset] = x0 * w1 + w0 * x1 + y0 * z1 - z0 * y1;
|
|
122
|
+
dst[dstOffset + 1] = y0 * w1 + w0 * y1 + z0 * x1 - x0 * z1;
|
|
123
|
+
dst[dstOffset + 2] = z0 * w1 + w0 * z1 + x0 * y1 - y0 * x1;
|
|
124
|
+
dst[dstOffset + 3] = w0 * w1 - x0 * x1 - y0 * y1 - z0 * z1;
|
|
125
|
+
|
|
126
|
+
return dst;
|
|
127
|
+
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
set(x: number, y: number, z: number, w: number) {
|
|
132
|
+
this._x = x;
|
|
133
|
+
this._y = y;
|
|
134
|
+
this._z = z;
|
|
135
|
+
this._w = w;
|
|
136
|
+
|
|
137
|
+
this.fire("change", this);
|
|
138
|
+
|
|
139
|
+
return this;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
clone() {
|
|
143
|
+
return new Quat(this._x, this._y, this._z, this._w);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
copy(quat: Quat) {
|
|
147
|
+
this._x = quat.x;
|
|
148
|
+
this._y = quat.y;
|
|
149
|
+
this._z = quat.z;
|
|
150
|
+
this._w = quat.w;
|
|
151
|
+
|
|
152
|
+
this.fire("change", this);
|
|
153
|
+
|
|
154
|
+
return this;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
setFromEuler(euler: Euler, update?: boolean) {
|
|
158
|
+
if (!(euler && euler.isEuler)) {
|
|
159
|
+
throw new Error(
|
|
160
|
+
"Quat: .setFromEuler() now expects an Euler rotation rather than a Vec3 and order."
|
|
161
|
+
);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
var x = euler._x,
|
|
165
|
+
y = euler._y,
|
|
166
|
+
z = euler._z,
|
|
167
|
+
order = euler.order;
|
|
168
|
+
|
|
169
|
+
// http://www.mathworks.com/matlabcentral/fileexchange/
|
|
170
|
+
// 20696-function-to-convert-between-dcm-Euler-angles-Quats-and-Euler-Vecs/
|
|
171
|
+
// content/SpinCalc.m
|
|
172
|
+
|
|
173
|
+
var cos = Math.cos;
|
|
174
|
+
var sin = Math.sin;
|
|
175
|
+
|
|
176
|
+
var c1 = cos(x / 2);
|
|
177
|
+
var c2 = cos(y / 2);
|
|
178
|
+
var c3 = cos(z / 2);
|
|
179
|
+
|
|
180
|
+
var s1 = sin(x / 2);
|
|
181
|
+
var s2 = sin(y / 2);
|
|
182
|
+
var s3 = sin(z / 2);
|
|
183
|
+
|
|
184
|
+
if (order === "XYZ") {
|
|
185
|
+
this._x = s1 * c2 * c3 + c1 * s2 * s3;
|
|
186
|
+
this._y = c1 * s2 * c3 - s1 * c2 * s3;
|
|
187
|
+
this._z = c1 * c2 * s3 + s1 * s2 * c3;
|
|
188
|
+
this._w = c1 * c2 * c3 - s1 * s2 * s3;
|
|
189
|
+
} else if (order === "YXZ") {
|
|
190
|
+
this._x = s1 * c2 * c3 + c1 * s2 * s3;
|
|
191
|
+
this._y = c1 * s2 * c3 - s1 * c2 * s3;
|
|
192
|
+
this._z = c1 * c2 * s3 - s1 * s2 * c3;
|
|
193
|
+
this._w = c1 * c2 * c3 + s1 * s2 * s3;
|
|
194
|
+
} else if (order === "ZXY") {
|
|
195
|
+
this._x = s1 * c2 * c3 - c1 * s2 * s3;
|
|
196
|
+
this._y = c1 * s2 * c3 + s1 * c2 * s3;
|
|
197
|
+
this._z = c1 * c2 * s3 + s1 * s2 * c3;
|
|
198
|
+
this._w = c1 * c2 * c3 - s1 * s2 * s3;
|
|
199
|
+
} else if (order === "ZYX") {
|
|
200
|
+
this._x = s1 * c2 * c3 - c1 * s2 * s3;
|
|
201
|
+
this._y = c1 * s2 * c3 + s1 * c2 * s3;
|
|
202
|
+
this._z = c1 * c2 * s3 - s1 * s2 * c3;
|
|
203
|
+
this._w = c1 * c2 * c3 + s1 * s2 * s3;
|
|
204
|
+
} else if (order === "YZX") {
|
|
205
|
+
this._x = s1 * c2 * c3 + c1 * s2 * s3;
|
|
206
|
+
this._y = c1 * s2 * c3 + s1 * c2 * s3;
|
|
207
|
+
this._z = c1 * c2 * s3 - s1 * s2 * c3;
|
|
208
|
+
this._w = c1 * c2 * c3 - s1 * s2 * s3;
|
|
209
|
+
} else if (order === "XZY") {
|
|
210
|
+
this._x = s1 * c2 * c3 - c1 * s2 * s3;
|
|
211
|
+
this._y = c1 * s2 * c3 - s1 * c2 * s3;
|
|
212
|
+
this._z = c1 * c2 * s3 + s1 * s2 * c3;
|
|
213
|
+
this._w = c1 * c2 * c3 + s1 * s2 * s3;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
if (update !== false) this.fire("change", this);
|
|
217
|
+
|
|
218
|
+
return this;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
setFromAxisAngle(axis: { x: number; y: number; z: number; }, angle: number) {
|
|
222
|
+
// http://www.euclideanspace.com/maths/geometry/rotations/conversions/angleToQuat/index.htm
|
|
223
|
+
|
|
224
|
+
// assumes axis is normalized
|
|
225
|
+
|
|
226
|
+
var halfAngle = angle / 2,
|
|
227
|
+
s = Math.sin(halfAngle);
|
|
228
|
+
|
|
229
|
+
this._x = axis.x * s;
|
|
230
|
+
this._y = axis.y * s;
|
|
231
|
+
this._z = axis.z * s;
|
|
232
|
+
this._w = Math.cos(halfAngle);
|
|
233
|
+
|
|
234
|
+
this.fire("change", this);
|
|
235
|
+
|
|
236
|
+
return this;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
setFromRotationMat(m: { elements: any; }) {
|
|
240
|
+
// http://www.euclideanspace.com/maths/geometry/rotations/conversions/matrixToQuat/index.htm
|
|
241
|
+
|
|
242
|
+
// assumes the upper 3x3 of m is a pure rotation matrix (i.e, unscaled)
|
|
243
|
+
|
|
244
|
+
var te = m.elements,
|
|
245
|
+
m11 = te[0],
|
|
246
|
+
m12 = te[4],
|
|
247
|
+
m13 = te[8],
|
|
248
|
+
m21 = te[1],
|
|
249
|
+
m22 = te[5],
|
|
250
|
+
m23 = te[9],
|
|
251
|
+
m31 = te[2],
|
|
252
|
+
m32 = te[6],
|
|
253
|
+
m33 = te[10],
|
|
254
|
+
trace = m11 + m22 + m33,
|
|
255
|
+
s;
|
|
256
|
+
|
|
257
|
+
if (trace > 0) {
|
|
258
|
+
s = 0.5 / Math.sqrt(trace + 1.0);
|
|
259
|
+
|
|
260
|
+
this._w = 0.25 / s;
|
|
261
|
+
this._x = (m32 - m23) * s;
|
|
262
|
+
this._y = (m13 - m31) * s;
|
|
263
|
+
this._z = (m21 - m12) * s;
|
|
264
|
+
} else if (m11 > m22 && m11 > m33) {
|
|
265
|
+
s = 2.0 * Math.sqrt(1.0 + m11 - m22 - m33);
|
|
266
|
+
|
|
267
|
+
this._w = (m32 - m23) / s;
|
|
268
|
+
this._x = 0.25 * s;
|
|
269
|
+
this._y = (m12 + m21) / s;
|
|
270
|
+
this._z = (m13 + m31) / s;
|
|
271
|
+
} else if (m22 > m33) {
|
|
272
|
+
s = 2.0 * Math.sqrt(1.0 + m22 - m11 - m33);
|
|
273
|
+
|
|
274
|
+
this._w = (m13 - m31) / s;
|
|
275
|
+
this._x = (m12 + m21) / s;
|
|
276
|
+
this._y = 0.25 * s;
|
|
277
|
+
this._z = (m23 + m32) / s;
|
|
278
|
+
} else {
|
|
279
|
+
s = 2.0 * Math.sqrt(1.0 + m33 - m11 - m22);
|
|
280
|
+
|
|
281
|
+
this._w = (m21 - m12) / s;
|
|
282
|
+
this._x = (m13 + m31) / s;
|
|
283
|
+
this._y = (m23 + m32) / s;
|
|
284
|
+
this._z = 0.25 * s;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
this.fire("change", this);
|
|
288
|
+
|
|
289
|
+
return this;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
setFromUnitVecs(vFrom: { dot: (arg0: any) => number; x: number; z: number; y: number; }, vTo: { z: number; y: number; x: number; }) {
|
|
293
|
+
// assumes direction Vecs vFrom and vTo are normalized
|
|
294
|
+
|
|
295
|
+
var EPS = 0.000001;
|
|
296
|
+
|
|
297
|
+
var r = vFrom.dot(vTo) + 1;
|
|
298
|
+
|
|
299
|
+
if (r < EPS) {
|
|
300
|
+
r = 0;
|
|
301
|
+
|
|
302
|
+
if (Math.abs(vFrom.x) > Math.abs(vFrom.z)) {
|
|
303
|
+
this._x = -vFrom.y;
|
|
304
|
+
this._y = vFrom.x;
|
|
305
|
+
this._z = 0;
|
|
306
|
+
this._w = r;
|
|
307
|
+
} else {
|
|
308
|
+
this._x = 0;
|
|
309
|
+
this._y = -vFrom.z;
|
|
310
|
+
this._z = vFrom.y;
|
|
311
|
+
this._w = r;
|
|
312
|
+
}
|
|
313
|
+
} else {
|
|
314
|
+
// crossVecs( vFrom, vTo ); // inlined to avoid cyclic dependency on Vec3
|
|
315
|
+
|
|
316
|
+
this._x = vFrom.y * vTo.z - vFrom.z * vTo.y;
|
|
317
|
+
this._y = vFrom.z * vTo.x - vFrom.x * vTo.z;
|
|
318
|
+
this._z = vFrom.x * vTo.y - vFrom.y * vTo.x;
|
|
319
|
+
this._w = r;
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
return this.normalize();
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
angleTo(q: any) {
|
|
326
|
+
return 2 * Math.acos(Math.abs(clamp(this.dot(q), -1, 1)));
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
rotateTowards(q: any, step: number) {
|
|
330
|
+
var angle = this.angleTo(q);
|
|
331
|
+
|
|
332
|
+
if (angle === 0) return this;
|
|
333
|
+
|
|
334
|
+
var t = Math.min(1, step / angle);
|
|
335
|
+
|
|
336
|
+
this.slerp(q, t);
|
|
337
|
+
|
|
338
|
+
return this;
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
inverse() {
|
|
342
|
+
// Quat is assumed to have unit length
|
|
343
|
+
|
|
344
|
+
return this.conjugate();
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
invert() {
|
|
348
|
+
|
|
349
|
+
// quaternion is assumed to have unit length
|
|
350
|
+
|
|
351
|
+
return this.conjugate();
|
|
352
|
+
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
conjugate() {
|
|
356
|
+
this._x *= -1;
|
|
357
|
+
this._y *= -1;
|
|
358
|
+
this._z *= -1;
|
|
359
|
+
|
|
360
|
+
this.fire("change", this);
|
|
361
|
+
|
|
362
|
+
return this;
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
dot(v: Quat) {
|
|
366
|
+
return this._x * v._x + this._y * v._y + this._z * v._z + this._w * v._w;
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
lengthSq() {
|
|
370
|
+
return (
|
|
371
|
+
this._x * this._x +
|
|
372
|
+
this._y * this._y +
|
|
373
|
+
this._z * this._z +
|
|
374
|
+
this._w * this._w
|
|
375
|
+
);
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
length() {
|
|
379
|
+
return Math.sqrt(
|
|
380
|
+
this._x * this._x +
|
|
381
|
+
this._y * this._y +
|
|
382
|
+
this._z * this._z +
|
|
383
|
+
this._w * this._w
|
|
384
|
+
);
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
normalize() {
|
|
388
|
+
var l = this.length();
|
|
389
|
+
|
|
390
|
+
if (l === 0) {
|
|
391
|
+
this._x = 0;
|
|
392
|
+
this._y = 0;
|
|
393
|
+
this._z = 0;
|
|
394
|
+
this._w = 1;
|
|
395
|
+
} else {
|
|
396
|
+
l = 1 / l;
|
|
397
|
+
|
|
398
|
+
this._x = this._x * l;
|
|
399
|
+
this._y = this._y * l;
|
|
400
|
+
this._z = this._z * l;
|
|
401
|
+
this._w = this._w * l;
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
this.fire("change", this);
|
|
405
|
+
|
|
406
|
+
return this;
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
multiply(q: Quat, p?: Quat) {
|
|
410
|
+
if (p !== undefined) {
|
|
411
|
+
return this.multiplyQuats(q, p);
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
return this.multiplyQuats(this, q);
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
premultiply(q: Quat) {
|
|
418
|
+
return this.multiplyQuats(q, this);
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
multiplyQuats(a: Quat, b: Quat) {
|
|
422
|
+
// from http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/Quats/code/index.htm
|
|
423
|
+
|
|
424
|
+
var qax = a._x,
|
|
425
|
+
qay = a._y,
|
|
426
|
+
qaz = a._z,
|
|
427
|
+
qaw = a._w;
|
|
428
|
+
var qbx = b._x,
|
|
429
|
+
qby = b._y,
|
|
430
|
+
qbz = b._z,
|
|
431
|
+
qbw = b._w;
|
|
432
|
+
|
|
433
|
+
this._x = qax * qbw + qaw * qbx + qay * qbz - qaz * qby;
|
|
434
|
+
this._y = qay * qbw + qaw * qby + qaz * qbx - qax * qbz;
|
|
435
|
+
this._z = qaz * qbw + qaw * qbz + qax * qby - qay * qbx;
|
|
436
|
+
this._w = qaw * qbw - qax * qbx - qay * qby - qaz * qbz;
|
|
437
|
+
|
|
438
|
+
this.fire("change", this);
|
|
439
|
+
|
|
440
|
+
return this;
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
slerp(qb: Quat, t: number) {
|
|
444
|
+
if (t === 0) return this;
|
|
445
|
+
if (t === 1) return this.copy(qb);
|
|
446
|
+
|
|
447
|
+
var x = this._x,
|
|
448
|
+
y = this._y,
|
|
449
|
+
z = this._z,
|
|
450
|
+
w = this._w;
|
|
451
|
+
|
|
452
|
+
// http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/Quats/slerp/
|
|
453
|
+
|
|
454
|
+
var cosHalfTheta = w * qb._w + x * qb._x + y * qb._y + z * qb._z;
|
|
455
|
+
|
|
456
|
+
if (cosHalfTheta < 0) {
|
|
457
|
+
this._w = -qb._w;
|
|
458
|
+
this._x = -qb._x;
|
|
459
|
+
this._y = -qb._y;
|
|
460
|
+
this._z = -qb._z;
|
|
461
|
+
|
|
462
|
+
cosHalfTheta = -cosHalfTheta;
|
|
463
|
+
} else {
|
|
464
|
+
this.copy(qb);
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
if (cosHalfTheta >= 1.0) {
|
|
468
|
+
this._w = w;
|
|
469
|
+
this._x = x;
|
|
470
|
+
this._y = y;
|
|
471
|
+
this._z = z;
|
|
472
|
+
|
|
473
|
+
return this;
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
var sqrSinHalfTheta = 1.0 - cosHalfTheta * cosHalfTheta;
|
|
477
|
+
|
|
478
|
+
if (sqrSinHalfTheta <= Number.EPSILON) {
|
|
479
|
+
var s = 1 - t;
|
|
480
|
+
this._w = s * w + t * this._w;
|
|
481
|
+
this._x = s * x + t * this._x;
|
|
482
|
+
this._y = s * y + t * this._y;
|
|
483
|
+
this._z = s * z + t * this._z;
|
|
484
|
+
|
|
485
|
+
this.normalize();
|
|
486
|
+
this.fire("change", this);
|
|
487
|
+
|
|
488
|
+
return this;
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
var sinHalfTheta = Math.sqrt(sqrSinHalfTheta);
|
|
492
|
+
var halfTheta = Math.atan2(sinHalfTheta, cosHalfTheta);
|
|
493
|
+
var ratioA = Math.sin((1 - t) * halfTheta) / sinHalfTheta,
|
|
494
|
+
ratioB = Math.sin(t * halfTheta) / sinHalfTheta;
|
|
495
|
+
|
|
496
|
+
this._w = w * ratioA + this._w * ratioB;
|
|
497
|
+
this._x = x * ratioA + this._x * ratioB;
|
|
498
|
+
this._y = y * ratioA + this._y * ratioB;
|
|
499
|
+
this._z = z * ratioA + this._z * ratioB;
|
|
500
|
+
|
|
501
|
+
this.fire("change", this);
|
|
502
|
+
|
|
503
|
+
return this;
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
equals(quat: Quat) {
|
|
507
|
+
return (
|
|
508
|
+
quat._x === this._x &&
|
|
509
|
+
quat._y === this._y &&
|
|
510
|
+
quat._z === this._z &&
|
|
511
|
+
quat._w === this._w
|
|
512
|
+
);
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
fromArray(array: Array<number>, offset: number = 0) {
|
|
516
|
+
|
|
517
|
+
this._x = array[offset];
|
|
518
|
+
this._y = array[offset + 1];
|
|
519
|
+
this._z = array[offset + 2];
|
|
520
|
+
this._w = array[offset + 3];
|
|
521
|
+
|
|
522
|
+
this.fire("change", this);
|
|
523
|
+
|
|
524
|
+
return this;
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
toArray(array: number[] = [], offset: number = 0) {
|
|
528
|
+
|
|
529
|
+
array[offset] = this._x;
|
|
530
|
+
array[offset + 1] = this._y;
|
|
531
|
+
array[offset + 2] = this._z;
|
|
532
|
+
array[offset + 3] = this._w;
|
|
533
|
+
|
|
534
|
+
return array;
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
export function quat(x?: number, y?: number, z?: number, w?: number) {
|
|
540
|
+
return new Quat(x, y, z, w);
|
|
541
|
+
}
|
package/src/math/Vec.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 暂不使用
|
|
3
|
+
*/
|
|
4
|
+
export class Vec extends Array {
|
|
5
|
+
constructor(n: number) {
|
|
6
|
+
super();
|
|
7
|
+
while (n-- > 0) {
|
|
8
|
+
this[this.length] = 0;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
static max(array: ArrayLike<number>) {
|
|
13
|
+
|
|
14
|
+
if (array.length === 0) return - Infinity;
|
|
15
|
+
|
|
16
|
+
var max = array[0];
|
|
17
|
+
|
|
18
|
+
for (var i = 1, l = array.length; i < l; ++i) {
|
|
19
|
+
|
|
20
|
+
if (array[i] > max) max = array[i];
|
|
21
|
+
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return max;
|
|
25
|
+
}
|
|
26
|
+
}
|