@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
|
@@ -0,0 +1,791 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.m4 = exports.Mat4 = void 0;
|
|
4
|
+
var Vec3_1 = require("./Vec3");
|
|
5
|
+
var Mat4 = /** @class */ (function () {
|
|
6
|
+
function Mat4() {
|
|
7
|
+
this.elements = [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1];
|
|
8
|
+
this.isMat4 = true;
|
|
9
|
+
if (arguments.length > 0) {
|
|
10
|
+
console.error(" Mat4: the constructor no longer reads arguments. use .set() instead.");
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
Mat4.prototype.set = function (n11, n12, n13, n14, n21, n22, n23, n24, n31, n32, n33, n34, n41, n42, n43, n44) {
|
|
14
|
+
var te = this.elements;
|
|
15
|
+
te[0] = n11;
|
|
16
|
+
te[4] = n12;
|
|
17
|
+
te[8] = n13;
|
|
18
|
+
te[12] = n14;
|
|
19
|
+
te[1] = n21;
|
|
20
|
+
te[5] = n22;
|
|
21
|
+
te[9] = n23;
|
|
22
|
+
te[13] = n24;
|
|
23
|
+
te[2] = n31;
|
|
24
|
+
te[6] = n32;
|
|
25
|
+
te[10] = n33;
|
|
26
|
+
te[14] = n34;
|
|
27
|
+
te[3] = n41;
|
|
28
|
+
te[7] = n42;
|
|
29
|
+
te[11] = n43;
|
|
30
|
+
te[15] = n44;
|
|
31
|
+
return this;
|
|
32
|
+
};
|
|
33
|
+
Object.defineProperty(Mat4, "Identity", {
|
|
34
|
+
get: function () {
|
|
35
|
+
return new Mat4();
|
|
36
|
+
},
|
|
37
|
+
enumerable: false,
|
|
38
|
+
configurable: true
|
|
39
|
+
});
|
|
40
|
+
Mat4.prototype.identity = function () {
|
|
41
|
+
this.set(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
|
|
42
|
+
return this;
|
|
43
|
+
};
|
|
44
|
+
Mat4.prototype.clone = function () {
|
|
45
|
+
return new Mat4().fromArray(this.elements);
|
|
46
|
+
};
|
|
47
|
+
Mat4.prototype.copy = function (m) {
|
|
48
|
+
var te = this.elements;
|
|
49
|
+
var me = m.elements;
|
|
50
|
+
te[0] = me[0];
|
|
51
|
+
te[1] = me[1];
|
|
52
|
+
te[2] = me[2];
|
|
53
|
+
te[3] = me[3];
|
|
54
|
+
te[4] = me[4];
|
|
55
|
+
te[5] = me[5];
|
|
56
|
+
te[6] = me[6];
|
|
57
|
+
te[7] = me[7];
|
|
58
|
+
te[8] = me[8];
|
|
59
|
+
te[9] = me[9];
|
|
60
|
+
te[10] = me[10];
|
|
61
|
+
te[11] = me[11];
|
|
62
|
+
te[12] = me[12];
|
|
63
|
+
te[13] = me[13];
|
|
64
|
+
te[14] = me[14];
|
|
65
|
+
te[15] = me[15];
|
|
66
|
+
return this;
|
|
67
|
+
};
|
|
68
|
+
Mat4.prototype.copyPosition = function (m) {
|
|
69
|
+
var te = this.elements, me = m.elements;
|
|
70
|
+
te[12] = me[12];
|
|
71
|
+
te[13] = me[13];
|
|
72
|
+
te[14] = me[14];
|
|
73
|
+
return this;
|
|
74
|
+
};
|
|
75
|
+
Mat4.prototype.extractBasis = function (xAxis, yAxis, zAxis) {
|
|
76
|
+
xAxis.setFromMatColumn(this, 0);
|
|
77
|
+
yAxis.setFromMatColumn(this, 1);
|
|
78
|
+
zAxis.setFromMatColumn(this, 2);
|
|
79
|
+
return this;
|
|
80
|
+
};
|
|
81
|
+
Mat4.prototype.makeBasis = function (xAxis, yAxis, zAxis) {
|
|
82
|
+
this.set(xAxis.x, yAxis.x, zAxis.x, 0, xAxis.y, yAxis.y, zAxis.y, 0, xAxis.z, yAxis.z, zAxis.z, 0, 0, 0, 0, 1);
|
|
83
|
+
return this;
|
|
84
|
+
};
|
|
85
|
+
Mat4.prototype.extractRotation = function (m) {
|
|
86
|
+
// this method does not support reflection matrices
|
|
87
|
+
var te = this.elements;
|
|
88
|
+
var me = m.elements;
|
|
89
|
+
var scaleX = 1 / _v1.setFromMatColumn(m, 0).length();
|
|
90
|
+
var scaleY = 1 / _v1.setFromMatColumn(m, 1).length();
|
|
91
|
+
var scaleZ = 1 / _v1.setFromMatColumn(m, 2).length();
|
|
92
|
+
te[0] = me[0] * scaleX;
|
|
93
|
+
te[1] = me[1] * scaleX;
|
|
94
|
+
te[2] = me[2] * scaleX;
|
|
95
|
+
te[3] = 0;
|
|
96
|
+
te[4] = me[4] * scaleY;
|
|
97
|
+
te[5] = me[5] * scaleY;
|
|
98
|
+
te[6] = me[6] * scaleY;
|
|
99
|
+
te[7] = 0;
|
|
100
|
+
te[8] = me[8] * scaleZ;
|
|
101
|
+
te[9] = me[9] * scaleZ;
|
|
102
|
+
te[10] = me[10] * scaleZ;
|
|
103
|
+
te[11] = 0;
|
|
104
|
+
te[12] = 0;
|
|
105
|
+
te[13] = 0;
|
|
106
|
+
te[14] = 0;
|
|
107
|
+
te[15] = 1;
|
|
108
|
+
return this;
|
|
109
|
+
};
|
|
110
|
+
Mat4.prototype.makeRotationFromEuler = function (euler) {
|
|
111
|
+
if (!(euler && euler.isEuler)) {
|
|
112
|
+
console.error(" Mat4: .makeRotationFromEuler() now expects a Euler rotation rather than a Vec3 and order.");
|
|
113
|
+
}
|
|
114
|
+
var te = this.elements;
|
|
115
|
+
var x = euler.x, y = euler.y, z = euler.z;
|
|
116
|
+
var a = Math.cos(x), b = Math.sin(x);
|
|
117
|
+
var c = Math.cos(y), d = Math.sin(y);
|
|
118
|
+
var e = Math.cos(z), f = Math.sin(z);
|
|
119
|
+
if (euler.order === "XYZ") {
|
|
120
|
+
var ae = a * e, af = a * f, be = b * e, bf = b * f;
|
|
121
|
+
te[0] = c * e;
|
|
122
|
+
te[4] = -c * f;
|
|
123
|
+
te[8] = d;
|
|
124
|
+
te[1] = af + be * d;
|
|
125
|
+
te[5] = ae - bf * d;
|
|
126
|
+
te[9] = -b * c;
|
|
127
|
+
te[2] = bf - ae * d;
|
|
128
|
+
te[6] = be + af * d;
|
|
129
|
+
te[10] = a * c;
|
|
130
|
+
}
|
|
131
|
+
else if (euler.order === "YXZ") {
|
|
132
|
+
var ce = c * e, cf = c * f, de = d * e, df = d * f;
|
|
133
|
+
te[0] = ce + df * b;
|
|
134
|
+
te[4] = de * b - cf;
|
|
135
|
+
te[8] = a * d;
|
|
136
|
+
te[1] = a * f;
|
|
137
|
+
te[5] = a * e;
|
|
138
|
+
te[9] = -b;
|
|
139
|
+
te[2] = cf * b - de;
|
|
140
|
+
te[6] = df + ce * b;
|
|
141
|
+
te[10] = a * c;
|
|
142
|
+
}
|
|
143
|
+
else if (euler.order === "ZXY") {
|
|
144
|
+
var ce = c * e, cf = c * f, de = d * e, df = d * f;
|
|
145
|
+
te[0] = ce - df * b;
|
|
146
|
+
te[4] = -a * f;
|
|
147
|
+
te[8] = de + cf * b;
|
|
148
|
+
te[1] = cf + de * b;
|
|
149
|
+
te[5] = a * e;
|
|
150
|
+
te[9] = df - ce * b;
|
|
151
|
+
te[2] = -a * d;
|
|
152
|
+
te[6] = b;
|
|
153
|
+
te[10] = a * c;
|
|
154
|
+
}
|
|
155
|
+
else if (euler.order === "ZYX") {
|
|
156
|
+
var ae = a * e, af = a * f, be = b * e, bf = b * f;
|
|
157
|
+
te[0] = c * e;
|
|
158
|
+
te[4] = be * d - af;
|
|
159
|
+
te[8] = ae * d + bf;
|
|
160
|
+
te[1] = c * f;
|
|
161
|
+
te[5] = bf * d + ae;
|
|
162
|
+
te[9] = af * d - be;
|
|
163
|
+
te[2] = -d;
|
|
164
|
+
te[6] = b * c;
|
|
165
|
+
te[10] = a * c;
|
|
166
|
+
}
|
|
167
|
+
else if (euler.order === "YZX") {
|
|
168
|
+
var ac = a * c, ad = a * d, bc = b * c, bd = b * d;
|
|
169
|
+
te[0] = c * e;
|
|
170
|
+
te[4] = bd - ac * f;
|
|
171
|
+
te[8] = bc * f + ad;
|
|
172
|
+
te[1] = f;
|
|
173
|
+
te[5] = a * e;
|
|
174
|
+
te[9] = -b * e;
|
|
175
|
+
te[2] = -d * e;
|
|
176
|
+
te[6] = ad * f + bc;
|
|
177
|
+
te[10] = ac - bd * f;
|
|
178
|
+
}
|
|
179
|
+
else if (euler.order === "XZY") {
|
|
180
|
+
var ac = a * c, ad = a * d, bc = b * c, bd = b * d;
|
|
181
|
+
te[0] = c * e;
|
|
182
|
+
te[4] = -f;
|
|
183
|
+
te[8] = d * e;
|
|
184
|
+
te[1] = ac * f + bd;
|
|
185
|
+
te[5] = a * e;
|
|
186
|
+
te[9] = ad * f - bc;
|
|
187
|
+
te[2] = bc * f - ad;
|
|
188
|
+
te[6] = b * e;
|
|
189
|
+
te[10] = bd * f + ac;
|
|
190
|
+
}
|
|
191
|
+
// bottom row
|
|
192
|
+
te[3] = 0;
|
|
193
|
+
te[7] = 0;
|
|
194
|
+
te[11] = 0;
|
|
195
|
+
// last column
|
|
196
|
+
te[12] = 0;
|
|
197
|
+
te[13] = 0;
|
|
198
|
+
te[14] = 0;
|
|
199
|
+
te[15] = 1;
|
|
200
|
+
return this;
|
|
201
|
+
};
|
|
202
|
+
Mat4.prototype.makeRotationFromQuat = function (q) {
|
|
203
|
+
return this.compose(_zero, q, _one);
|
|
204
|
+
};
|
|
205
|
+
Mat4.prototype.lookAt = function (eye, target, up) {
|
|
206
|
+
var te = this.elements;
|
|
207
|
+
_z.subVecs(eye, target);
|
|
208
|
+
if (_z.lengthSq() === 0) {
|
|
209
|
+
// eye and target are in the same position
|
|
210
|
+
_z.z = 1;
|
|
211
|
+
}
|
|
212
|
+
_z.normalize();
|
|
213
|
+
_x.crossVecs(up, _z);
|
|
214
|
+
if (_x.lengthSq() === 0) {
|
|
215
|
+
// up and z are parallel
|
|
216
|
+
if (Math.abs(up.z) === 1) {
|
|
217
|
+
_z.x += 0.0001;
|
|
218
|
+
}
|
|
219
|
+
else {
|
|
220
|
+
_z.z += 0.0001;
|
|
221
|
+
}
|
|
222
|
+
_z.normalize();
|
|
223
|
+
_x.crossVecs(up, _z);
|
|
224
|
+
}
|
|
225
|
+
_x.normalize();
|
|
226
|
+
_y.crossVecs(_z, _x);
|
|
227
|
+
te[0] = _x.x;
|
|
228
|
+
te[4] = _y.x;
|
|
229
|
+
te[8] = _z.x;
|
|
230
|
+
te[1] = _x.y;
|
|
231
|
+
te[5] = _y.y;
|
|
232
|
+
te[9] = _z.y;
|
|
233
|
+
te[2] = _x.z;
|
|
234
|
+
te[6] = _y.z;
|
|
235
|
+
te[10] = _z.z;
|
|
236
|
+
return this;
|
|
237
|
+
};
|
|
238
|
+
Mat4.prototype.multiply = function (m, n) {
|
|
239
|
+
if (n !== undefined) {
|
|
240
|
+
return this.multiplyMats(m, n);
|
|
241
|
+
}
|
|
242
|
+
return this.multiplyMats(this, m);
|
|
243
|
+
};
|
|
244
|
+
Mat4.prototype.premultiply = function (m) {
|
|
245
|
+
return this.multiplyMats(m, this);
|
|
246
|
+
};
|
|
247
|
+
Mat4.prototype.multiplyMats = function (a, b) {
|
|
248
|
+
var ae = a.elements;
|
|
249
|
+
var be = b.elements;
|
|
250
|
+
var te = this.elements;
|
|
251
|
+
var a11 = ae[0], a12 = ae[4], a13 = ae[8], a14 = ae[12];
|
|
252
|
+
var a21 = ae[1], a22 = ae[5], a23 = ae[9], a24 = ae[13];
|
|
253
|
+
var a31 = ae[2], a32 = ae[6], a33 = ae[10], a34 = ae[14];
|
|
254
|
+
var a41 = ae[3], a42 = ae[7], a43 = ae[11], a44 = ae[15];
|
|
255
|
+
var b11 = be[0], b12 = be[4], b13 = be[8], b14 = be[12];
|
|
256
|
+
var b21 = be[1], b22 = be[5], b23 = be[9], b24 = be[13];
|
|
257
|
+
var b31 = be[2], b32 = be[6], b33 = be[10], b34 = be[14];
|
|
258
|
+
var b41 = be[3], b42 = be[7], b43 = be[11], b44 = be[15];
|
|
259
|
+
te[0] = a11 * b11 + a12 * b21 + a13 * b31 + a14 * b41;
|
|
260
|
+
te[4] = a11 * b12 + a12 * b22 + a13 * b32 + a14 * b42;
|
|
261
|
+
te[8] = a11 * b13 + a12 * b23 + a13 * b33 + a14 * b43;
|
|
262
|
+
te[12] = a11 * b14 + a12 * b24 + a13 * b34 + a14 * b44;
|
|
263
|
+
te[1] = a21 * b11 + a22 * b21 + a23 * b31 + a24 * b41;
|
|
264
|
+
te[5] = a21 * b12 + a22 * b22 + a23 * b32 + a24 * b42;
|
|
265
|
+
te[9] = a21 * b13 + a22 * b23 + a23 * b33 + a24 * b43;
|
|
266
|
+
te[13] = a21 * b14 + a22 * b24 + a23 * b34 + a24 * b44;
|
|
267
|
+
te[2] = a31 * b11 + a32 * b21 + a33 * b31 + a34 * b41;
|
|
268
|
+
te[6] = a31 * b12 + a32 * b22 + a33 * b32 + a34 * b42;
|
|
269
|
+
te[10] = a31 * b13 + a32 * b23 + a33 * b33 + a34 * b43;
|
|
270
|
+
te[14] = a31 * b14 + a32 * b24 + a33 * b34 + a34 * b44;
|
|
271
|
+
te[3] = a41 * b11 + a42 * b21 + a43 * b31 + a44 * b41;
|
|
272
|
+
te[7] = a41 * b12 + a42 * b22 + a43 * b32 + a44 * b42;
|
|
273
|
+
te[11] = a41 * b13 + a42 * b23 + a43 * b33 + a44 * b43;
|
|
274
|
+
te[15] = a41 * b14 + a42 * b24 + a43 * b34 + a44 * b44;
|
|
275
|
+
return this;
|
|
276
|
+
};
|
|
277
|
+
Mat4.prototype.multiplyScalar = function (s) {
|
|
278
|
+
var te = this.elements;
|
|
279
|
+
te[0] *= s;
|
|
280
|
+
te[4] *= s;
|
|
281
|
+
te[8] *= s;
|
|
282
|
+
te[12] *= s;
|
|
283
|
+
te[1] *= s;
|
|
284
|
+
te[5] *= s;
|
|
285
|
+
te[9] *= s;
|
|
286
|
+
te[13] *= s;
|
|
287
|
+
te[2] *= s;
|
|
288
|
+
te[6] *= s;
|
|
289
|
+
te[10] *= s;
|
|
290
|
+
te[14] *= s;
|
|
291
|
+
te[3] *= s;
|
|
292
|
+
te[7] *= s;
|
|
293
|
+
te[11] *= s;
|
|
294
|
+
te[15] *= s;
|
|
295
|
+
return this;
|
|
296
|
+
};
|
|
297
|
+
Mat4.prototype.applyToBufferAttribute = function (attribute) {
|
|
298
|
+
for (var i = 0, l = attribute.count; i < l; i++) {
|
|
299
|
+
_v1.x = attribute.getX(i);
|
|
300
|
+
_v1.y = attribute.getY(i);
|
|
301
|
+
_v1.z = attribute.getZ(i);
|
|
302
|
+
_v1.applyMat4(this);
|
|
303
|
+
attribute.setXYZ(i, _v1.x, _v1.y, _v1.z);
|
|
304
|
+
}
|
|
305
|
+
return attribute;
|
|
306
|
+
};
|
|
307
|
+
Mat4.prototype.determinant = function () {
|
|
308
|
+
var te = this.elements;
|
|
309
|
+
var n11 = te[0], n12 = te[4], n13 = te[8], n14 = te[12];
|
|
310
|
+
var n21 = te[1], n22 = te[5], n23 = te[9], n24 = te[13];
|
|
311
|
+
var n31 = te[2], n32 = te[6], n33 = te[10], n34 = te[14];
|
|
312
|
+
var n41 = te[3], n42 = te[7], n43 = te[11], n44 = te[15];
|
|
313
|
+
//TODO: make this more efficient
|
|
314
|
+
//( based on http://www.euclideanspace.com/maths/algebra/matrix/functions/inverse/fourD/index.htm )
|
|
315
|
+
return (n41 *
|
|
316
|
+
(+n14 * n23 * n32 -
|
|
317
|
+
n13 * n24 * n32 -
|
|
318
|
+
n14 * n22 * n33 +
|
|
319
|
+
n12 * n24 * n33 +
|
|
320
|
+
n13 * n22 * n34 -
|
|
321
|
+
n12 * n23 * n34) +
|
|
322
|
+
n42 *
|
|
323
|
+
(+n11 * n23 * n34 -
|
|
324
|
+
n11 * n24 * n33 +
|
|
325
|
+
n14 * n21 * n33 -
|
|
326
|
+
n13 * n21 * n34 +
|
|
327
|
+
n13 * n24 * n31 -
|
|
328
|
+
n14 * n23 * n31) +
|
|
329
|
+
n43 *
|
|
330
|
+
(+n11 * n24 * n32 -
|
|
331
|
+
n11 * n22 * n34 -
|
|
332
|
+
n14 * n21 * n32 +
|
|
333
|
+
n12 * n21 * n34 +
|
|
334
|
+
n14 * n22 * n31 -
|
|
335
|
+
n12 * n24 * n31) +
|
|
336
|
+
n44 *
|
|
337
|
+
(-n13 * n22 * n31 -
|
|
338
|
+
n11 * n23 * n32 +
|
|
339
|
+
n11 * n22 * n33 +
|
|
340
|
+
n13 * n21 * n32 -
|
|
341
|
+
n12 * n21 * n33 +
|
|
342
|
+
n12 * n23 * n31));
|
|
343
|
+
};
|
|
344
|
+
Mat4.prototype.transpose = function () {
|
|
345
|
+
var te = this.elements;
|
|
346
|
+
var tmp;
|
|
347
|
+
tmp = te[1];
|
|
348
|
+
te[1] = te[4];
|
|
349
|
+
te[4] = tmp;
|
|
350
|
+
tmp = te[2];
|
|
351
|
+
te[2] = te[8];
|
|
352
|
+
te[8] = tmp;
|
|
353
|
+
tmp = te[6];
|
|
354
|
+
te[6] = te[9];
|
|
355
|
+
te[9] = tmp;
|
|
356
|
+
tmp = te[3];
|
|
357
|
+
te[3] = te[12];
|
|
358
|
+
te[12] = tmp;
|
|
359
|
+
tmp = te[7];
|
|
360
|
+
te[7] = te[13];
|
|
361
|
+
te[13] = tmp;
|
|
362
|
+
tmp = te[11];
|
|
363
|
+
te[11] = te[14];
|
|
364
|
+
te[14] = tmp;
|
|
365
|
+
return this;
|
|
366
|
+
};
|
|
367
|
+
Mat4.prototype.setPosition = function (x, y, z) {
|
|
368
|
+
var te = this.elements;
|
|
369
|
+
if (x.isVec3) {
|
|
370
|
+
te[12] = x.x;
|
|
371
|
+
te[13] = x.y;
|
|
372
|
+
te[14] = x.z;
|
|
373
|
+
}
|
|
374
|
+
else if (y !== undefined && z !== undefined) {
|
|
375
|
+
te[12] = x;
|
|
376
|
+
te[13] = y;
|
|
377
|
+
te[14] = z;
|
|
378
|
+
}
|
|
379
|
+
else {
|
|
380
|
+
if (x.x !== undefined && x.y !== undefined && x.z !== undefined) {
|
|
381
|
+
te[12] = x.x;
|
|
382
|
+
te[13] = x.y;
|
|
383
|
+
te[14] = x.z;
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
return this;
|
|
387
|
+
};
|
|
388
|
+
/**
|
|
389
|
+
* 矩阵求逆
|
|
390
|
+
* @returns 自己
|
|
391
|
+
*/
|
|
392
|
+
Mat4.prototype.invert = function () {
|
|
393
|
+
// based on http://www.euclideanspace.com/maths/algebra/matrix/functions/inverse/fourD/index.htm
|
|
394
|
+
var te = this.elements, n11 = te[0], n21 = te[1], n31 = te[2], n41 = te[3], n12 = te[4], n22 = te[5], n32 = te[6], n42 = te[7], n13 = te[8], n23 = te[9], n33 = te[10], n43 = te[11], n14 = te[12], n24 = te[13], n34 = te[14], n44 = te[15], t11 = n23 * n34 * n42 - n24 * n33 * n42 + n24 * n32 * n43 - n22 * n34 * n43 - n23 * n32 * n44 + n22 * n33 * n44, t12 = n14 * n33 * n42 - n13 * n34 * n42 - n14 * n32 * n43 + n12 * n34 * n43 + n13 * n32 * n44 - n12 * n33 * n44, t13 = n13 * n24 * n42 - n14 * n23 * n42 + n14 * n22 * n43 - n12 * n24 * n43 - n13 * n22 * n44 + n12 * n23 * n44, t14 = n14 * n23 * n32 - n13 * n24 * n32 - n14 * n22 * n33 + n12 * n24 * n33 + n13 * n22 * n34 - n12 * n23 * n34;
|
|
395
|
+
var det = n11 * t11 + n21 * t12 + n31 * t13 + n41 * t14;
|
|
396
|
+
if (det === 0)
|
|
397
|
+
return this.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
|
|
398
|
+
var detInv = 1 / det;
|
|
399
|
+
te[0] = t11 * detInv;
|
|
400
|
+
te[1] = (n24 * n33 * n41 - n23 * n34 * n41 - n24 * n31 * n43 + n21 * n34 * n43 + n23 * n31 * n44 - n21 * n33 * n44) * detInv;
|
|
401
|
+
te[2] = (n22 * n34 * n41 - n24 * n32 * n41 + n24 * n31 * n42 - n21 * n34 * n42 - n22 * n31 * n44 + n21 * n32 * n44) * detInv;
|
|
402
|
+
te[3] = (n23 * n32 * n41 - n22 * n33 * n41 - n23 * n31 * n42 + n21 * n33 * n42 + n22 * n31 * n43 - n21 * n32 * n43) * detInv;
|
|
403
|
+
te[4] = t12 * detInv;
|
|
404
|
+
te[5] = (n13 * n34 * n41 - n14 * n33 * n41 + n14 * n31 * n43 - n11 * n34 * n43 - n13 * n31 * n44 + n11 * n33 * n44) * detInv;
|
|
405
|
+
te[6] = (n14 * n32 * n41 - n12 * n34 * n41 - n14 * n31 * n42 + n11 * n34 * n42 + n12 * n31 * n44 - n11 * n32 * n44) * detInv;
|
|
406
|
+
te[7] = (n12 * n33 * n41 - n13 * n32 * n41 + n13 * n31 * n42 - n11 * n33 * n42 - n12 * n31 * n43 + n11 * n32 * n43) * detInv;
|
|
407
|
+
te[8] = t13 * detInv;
|
|
408
|
+
te[9] = (n14 * n23 * n41 - n13 * n24 * n41 - n14 * n21 * n43 + n11 * n24 * n43 + n13 * n21 * n44 - n11 * n23 * n44) * detInv;
|
|
409
|
+
te[10] = (n12 * n24 * n41 - n14 * n22 * n41 + n14 * n21 * n42 - n11 * n24 * n42 - n12 * n21 * n44 + n11 * n22 * n44) * detInv;
|
|
410
|
+
te[11] = (n13 * n22 * n41 - n12 * n23 * n41 - n13 * n21 * n42 + n11 * n23 * n42 + n12 * n21 * n43 - n11 * n22 * n43) * detInv;
|
|
411
|
+
te[12] = t14 * detInv;
|
|
412
|
+
te[13] = (n13 * n24 * n31 - n14 * n23 * n31 + n14 * n21 * n33 - n11 * n24 * n33 - n13 * n21 * n34 + n11 * n23 * n34) * detInv;
|
|
413
|
+
te[14] = (n14 * n22 * n31 - n12 * n24 * n31 - n14 * n21 * n32 + n11 * n24 * n32 + n12 * n21 * n34 - n11 * n22 * n34) * detInv;
|
|
414
|
+
te[15] = (n12 * n23 * n31 - n13 * n22 * n31 + n13 * n21 * n32 - n11 * n23 * n32 - n12 * n21 * n33 + n11 * n22 * n33) * detInv;
|
|
415
|
+
return this;
|
|
416
|
+
};
|
|
417
|
+
Mat4.prototype.getInverse = function (m, throwOnDegenerate) {
|
|
418
|
+
if (throwOnDegenerate === void 0) { throwOnDegenerate = true; }
|
|
419
|
+
// based on http://www.euclideanspace.com/maths/algebra/matrix/functions/inverse/fourD/index.htm
|
|
420
|
+
var te = this.elements, me = m.elements, n11 = me[0], n21 = me[1], n31 = me[2], n41 = me[3], n12 = me[4], n22 = me[5], n32 = me[6], n42 = me[7], n13 = me[8], n23 = me[9], n33 = me[10], n43 = me[11], n14 = me[12], n24 = me[13], n34 = me[14], n44 = me[15], t11 = n23 * n34 * n42 -
|
|
421
|
+
n24 * n33 * n42 +
|
|
422
|
+
n24 * n32 * n43 -
|
|
423
|
+
n22 * n34 * n43 -
|
|
424
|
+
n23 * n32 * n44 +
|
|
425
|
+
n22 * n33 * n44, t12 = n14 * n33 * n42 -
|
|
426
|
+
n13 * n34 * n42 -
|
|
427
|
+
n14 * n32 * n43 +
|
|
428
|
+
n12 * n34 * n43 +
|
|
429
|
+
n13 * n32 * n44 -
|
|
430
|
+
n12 * n33 * n44, t13 = n13 * n24 * n42 -
|
|
431
|
+
n14 * n23 * n42 +
|
|
432
|
+
n14 * n22 * n43 -
|
|
433
|
+
n12 * n24 * n43 -
|
|
434
|
+
n13 * n22 * n44 +
|
|
435
|
+
n12 * n23 * n44, t14 = n14 * n23 * n32 -
|
|
436
|
+
n13 * n24 * n32 -
|
|
437
|
+
n14 * n22 * n33 +
|
|
438
|
+
n12 * n24 * n33 +
|
|
439
|
+
n13 * n22 * n34 -
|
|
440
|
+
n12 * n23 * n34;
|
|
441
|
+
var det = n11 * t11 + n21 * t12 + n31 * t13 + n41 * t14;
|
|
442
|
+
if (det === 0) {
|
|
443
|
+
var msg = " Mat4: .getInverse() can't invert matrix, determinant is 0";
|
|
444
|
+
if (throwOnDegenerate === true) {
|
|
445
|
+
throw new Error(msg);
|
|
446
|
+
}
|
|
447
|
+
else {
|
|
448
|
+
console.warn(msg);
|
|
449
|
+
}
|
|
450
|
+
return this.identity();
|
|
451
|
+
}
|
|
452
|
+
var detInv = 1 / det;
|
|
453
|
+
te[0] = t11 * detInv;
|
|
454
|
+
te[1] =
|
|
455
|
+
(n24 * n33 * n41 -
|
|
456
|
+
n23 * n34 * n41 -
|
|
457
|
+
n24 * n31 * n43 +
|
|
458
|
+
n21 * n34 * n43 +
|
|
459
|
+
n23 * n31 * n44 -
|
|
460
|
+
n21 * n33 * n44) *
|
|
461
|
+
detInv;
|
|
462
|
+
te[2] =
|
|
463
|
+
(n22 * n34 * n41 -
|
|
464
|
+
n24 * n32 * n41 +
|
|
465
|
+
n24 * n31 * n42 -
|
|
466
|
+
n21 * n34 * n42 -
|
|
467
|
+
n22 * n31 * n44 +
|
|
468
|
+
n21 * n32 * n44) *
|
|
469
|
+
detInv;
|
|
470
|
+
te[3] =
|
|
471
|
+
(n23 * n32 * n41 -
|
|
472
|
+
n22 * n33 * n41 -
|
|
473
|
+
n23 * n31 * n42 +
|
|
474
|
+
n21 * n33 * n42 +
|
|
475
|
+
n22 * n31 * n43 -
|
|
476
|
+
n21 * n32 * n43) *
|
|
477
|
+
detInv;
|
|
478
|
+
te[4] = t12 * detInv;
|
|
479
|
+
te[5] =
|
|
480
|
+
(n13 * n34 * n41 -
|
|
481
|
+
n14 * n33 * n41 +
|
|
482
|
+
n14 * n31 * n43 -
|
|
483
|
+
n11 * n34 * n43 -
|
|
484
|
+
n13 * n31 * n44 +
|
|
485
|
+
n11 * n33 * n44) *
|
|
486
|
+
detInv;
|
|
487
|
+
te[6] =
|
|
488
|
+
(n14 * n32 * n41 -
|
|
489
|
+
n12 * n34 * n41 -
|
|
490
|
+
n14 * n31 * n42 +
|
|
491
|
+
n11 * n34 * n42 +
|
|
492
|
+
n12 * n31 * n44 -
|
|
493
|
+
n11 * n32 * n44) *
|
|
494
|
+
detInv;
|
|
495
|
+
te[7] =
|
|
496
|
+
(n12 * n33 * n41 -
|
|
497
|
+
n13 * n32 * n41 +
|
|
498
|
+
n13 * n31 * n42 -
|
|
499
|
+
n11 * n33 * n42 -
|
|
500
|
+
n12 * n31 * n43 +
|
|
501
|
+
n11 * n32 * n43) *
|
|
502
|
+
detInv;
|
|
503
|
+
te[8] = t13 * detInv;
|
|
504
|
+
te[9] =
|
|
505
|
+
(n14 * n23 * n41 -
|
|
506
|
+
n13 * n24 * n41 -
|
|
507
|
+
n14 * n21 * n43 +
|
|
508
|
+
n11 * n24 * n43 +
|
|
509
|
+
n13 * n21 * n44 -
|
|
510
|
+
n11 * n23 * n44) *
|
|
511
|
+
detInv;
|
|
512
|
+
te[10] =
|
|
513
|
+
(n12 * n24 * n41 -
|
|
514
|
+
n14 * n22 * n41 +
|
|
515
|
+
n14 * n21 * n42 -
|
|
516
|
+
n11 * n24 * n42 -
|
|
517
|
+
n12 * n21 * n44 +
|
|
518
|
+
n11 * n22 * n44) *
|
|
519
|
+
detInv;
|
|
520
|
+
te[11] =
|
|
521
|
+
(n13 * n22 * n41 -
|
|
522
|
+
n12 * n23 * n41 -
|
|
523
|
+
n13 * n21 * n42 +
|
|
524
|
+
n11 * n23 * n42 +
|
|
525
|
+
n12 * n21 * n43 -
|
|
526
|
+
n11 * n22 * n43) *
|
|
527
|
+
detInv;
|
|
528
|
+
te[12] = t14 * detInv;
|
|
529
|
+
te[13] =
|
|
530
|
+
(n13 * n24 * n31 -
|
|
531
|
+
n14 * n23 * n31 +
|
|
532
|
+
n14 * n21 * n33 -
|
|
533
|
+
n11 * n24 * n33 -
|
|
534
|
+
n13 * n21 * n34 +
|
|
535
|
+
n11 * n23 * n34) *
|
|
536
|
+
detInv;
|
|
537
|
+
te[14] =
|
|
538
|
+
(n14 * n22 * n31 -
|
|
539
|
+
n12 * n24 * n31 -
|
|
540
|
+
n14 * n21 * n32 +
|
|
541
|
+
n11 * n24 * n32 +
|
|
542
|
+
n12 * n21 * n34 -
|
|
543
|
+
n11 * n22 * n34) *
|
|
544
|
+
detInv;
|
|
545
|
+
te[15] =
|
|
546
|
+
(n12 * n23 * n31 -
|
|
547
|
+
n13 * n22 * n31 +
|
|
548
|
+
n13 * n21 * n32 -
|
|
549
|
+
n11 * n23 * n32 -
|
|
550
|
+
n12 * n21 * n33 +
|
|
551
|
+
n11 * n22 * n33) *
|
|
552
|
+
detInv;
|
|
553
|
+
return this;
|
|
554
|
+
};
|
|
555
|
+
Mat4.prototype.scale = function (v) {
|
|
556
|
+
var te = this.elements;
|
|
557
|
+
var x = v.x, y = v.y, z = v.z;
|
|
558
|
+
te[0] *= x;
|
|
559
|
+
te[4] *= y;
|
|
560
|
+
te[8] *= z;
|
|
561
|
+
te[1] *= x;
|
|
562
|
+
te[5] *= y;
|
|
563
|
+
te[9] *= z;
|
|
564
|
+
te[2] *= x;
|
|
565
|
+
te[6] *= y;
|
|
566
|
+
te[10] *= z;
|
|
567
|
+
te[3] *= x;
|
|
568
|
+
te[7] *= y;
|
|
569
|
+
te[11] *= z;
|
|
570
|
+
return this;
|
|
571
|
+
};
|
|
572
|
+
Mat4.prototype.getMaxScaleOnAxis = function () {
|
|
573
|
+
var te = this.elements;
|
|
574
|
+
var scaleXSq = te[0] * te[0] + te[1] * te[1] + te[2] * te[2];
|
|
575
|
+
var scaleYSq = te[4] * te[4] + te[5] * te[5] + te[6] * te[6];
|
|
576
|
+
var scaleZSq = te[8] * te[8] + te[9] * te[9] + te[10] * te[10];
|
|
577
|
+
return Math.sqrt(Math.max(scaleXSq, scaleYSq, scaleZSq));
|
|
578
|
+
};
|
|
579
|
+
Mat4.prototype.makeTranslation = function (x, y, z) {
|
|
580
|
+
this.set(1, 0, 0, x, 0, 1, 0, y, 0, 0, 1, z, 0, 0, 0, 1);
|
|
581
|
+
return this;
|
|
582
|
+
};
|
|
583
|
+
Mat4.prototype.makeRotationX = function (theta) {
|
|
584
|
+
var c = Math.cos(theta), s = Math.sin(theta);
|
|
585
|
+
this.set(1, 0, 0, 0, 0, c, -s, 0, 0, s, c, 0, 0, 0, 0, 1);
|
|
586
|
+
return this;
|
|
587
|
+
};
|
|
588
|
+
Mat4.prototype.makeRotationY = function (theta) {
|
|
589
|
+
var c = Math.cos(theta), s = Math.sin(theta);
|
|
590
|
+
this.set(c, 0, s, 0, 0, 1, 0, 0, -s, 0, c, 0, 0, 0, 0, 1);
|
|
591
|
+
return this;
|
|
592
|
+
};
|
|
593
|
+
Mat4.prototype.makeRotationZ = function (theta) {
|
|
594
|
+
var c = Math.cos(theta), s = Math.sin(theta);
|
|
595
|
+
this.set(c, -s, 0, 0, s, c, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
|
|
596
|
+
return this;
|
|
597
|
+
};
|
|
598
|
+
Mat4.prototype.makeRotationAxis = function (axis, angle) {
|
|
599
|
+
// Based on http://www.gamedev.net/reference/articles/article1199.asp
|
|
600
|
+
var c = Math.cos(angle);
|
|
601
|
+
var s = Math.sin(angle);
|
|
602
|
+
var t = 1 - c;
|
|
603
|
+
var x = axis.x, y = axis.y, z = axis.z;
|
|
604
|
+
var tx = t * x, ty = t * y;
|
|
605
|
+
this.set(tx * x + c, tx * y - s * z, tx * z + s * y, 0, tx * y + s * z, ty * y + c, ty * z - s * x, 0, tx * z - s * y, ty * z + s * x, t * z * z + c, 0, 0, 0, 0, 1);
|
|
606
|
+
return this;
|
|
607
|
+
};
|
|
608
|
+
Mat4.prototype.makeScale = function (x, y, z) {
|
|
609
|
+
this.set(x, 0, 0, 0, 0, y, 0, 0, 0, 0, z, 0, 0, 0, 0, 1);
|
|
610
|
+
return this;
|
|
611
|
+
};
|
|
612
|
+
/**
|
|
613
|
+
* 6个参数 都是由两个值来影响 [v1][v2] v1表示v2轴在v1轴产生效果
|
|
614
|
+
* @param xy
|
|
615
|
+
* @param xz
|
|
616
|
+
* @param yx
|
|
617
|
+
* @param yz
|
|
618
|
+
* @param zx
|
|
619
|
+
* @param zy
|
|
620
|
+
* @returns
|
|
621
|
+
*/
|
|
622
|
+
Mat4.prototype.makeShear = function (xy, xz, yx, yz, zx, zy) {
|
|
623
|
+
this.set(1, yx, zx, 0, xy, 1, zy, 0, xz, yz, 1, 0, 0, 0, 0, 1);
|
|
624
|
+
return this;
|
|
625
|
+
};
|
|
626
|
+
Mat4.prototype.compose = function (position, quat, scale) {
|
|
627
|
+
var te = this.elements;
|
|
628
|
+
var x = quat._x, y = quat._y, z = quat._z, w = quat._w;
|
|
629
|
+
var x2 = x + x, y2 = y + y, z2 = z + z;
|
|
630
|
+
var xx = x * x2, xy = x * y2, xz = x * z2;
|
|
631
|
+
var yy = y * y2, yz = y * z2, zz = z * z2;
|
|
632
|
+
var wx = w * x2, wy = w * y2, wz = w * z2;
|
|
633
|
+
var sx = scale.x, sy = scale.y, sz = scale.z;
|
|
634
|
+
te[0] = (1 - (yy + zz)) * sx;
|
|
635
|
+
te[1] = (xy + wz) * sx;
|
|
636
|
+
te[2] = (xz - wy) * sx;
|
|
637
|
+
te[3] = 0;
|
|
638
|
+
te[4] = (xy - wz) * sy;
|
|
639
|
+
te[5] = (1 - (xx + zz)) * sy;
|
|
640
|
+
te[6] = (yz + wx) * sy;
|
|
641
|
+
te[7] = 0;
|
|
642
|
+
te[8] = (xz + wy) * sz;
|
|
643
|
+
te[9] = (yz - wx) * sz;
|
|
644
|
+
te[10] = (1 - (xx + yy)) * sz;
|
|
645
|
+
te[11] = 0;
|
|
646
|
+
te[12] = position.x;
|
|
647
|
+
te[13] = position.y;
|
|
648
|
+
te[14] = position.z;
|
|
649
|
+
te[15] = 1;
|
|
650
|
+
return this;
|
|
651
|
+
};
|
|
652
|
+
Mat4.prototype.decompose = function (position, quat, scale) {
|
|
653
|
+
var te = this.elements;
|
|
654
|
+
var sx = _v1.set(te[0], te[1], te[2]).length();
|
|
655
|
+
var sy = _v1.set(te[4], te[5], te[6]).length();
|
|
656
|
+
var sz = _v1.set(te[8], te[9], te[10]).length();
|
|
657
|
+
// if determine is negative, we need to invert one scale
|
|
658
|
+
var det = this.determinant();
|
|
659
|
+
if (det < 0)
|
|
660
|
+
sx = -sx;
|
|
661
|
+
position.x = te[12];
|
|
662
|
+
position.y = te[13];
|
|
663
|
+
position.z = te[14];
|
|
664
|
+
// scale the rotation part
|
|
665
|
+
_m1.copy(this);
|
|
666
|
+
var invSX = 1 / sx;
|
|
667
|
+
var invSY = 1 / sy;
|
|
668
|
+
var invSZ = 1 / sz;
|
|
669
|
+
_m1.elements[0] *= invSX;
|
|
670
|
+
_m1.elements[1] *= invSX;
|
|
671
|
+
_m1.elements[2] *= invSX;
|
|
672
|
+
_m1.elements[4] *= invSY;
|
|
673
|
+
_m1.elements[5] *= invSY;
|
|
674
|
+
_m1.elements[6] *= invSY;
|
|
675
|
+
_m1.elements[8] *= invSZ;
|
|
676
|
+
_m1.elements[9] *= invSZ;
|
|
677
|
+
_m1.elements[10] *= invSZ;
|
|
678
|
+
quat.setFromRotationMat(_m1);
|
|
679
|
+
scale.x = sx;
|
|
680
|
+
scale.y = sy;
|
|
681
|
+
scale.z = sz;
|
|
682
|
+
return this;
|
|
683
|
+
};
|
|
684
|
+
Mat4.prototype.makePerspective = function (left, right, top, bottom, near, far) {
|
|
685
|
+
if (far === undefined) {
|
|
686
|
+
console.warn(" Mat4: .makePerspective() has been redefined and has a new signature. Please check the docs.");
|
|
687
|
+
}
|
|
688
|
+
var te = this.elements;
|
|
689
|
+
var x = (2 * near) / (right - left);
|
|
690
|
+
var y = (2 * near) / (top - bottom);
|
|
691
|
+
var a = (right + left) / (right - left);
|
|
692
|
+
var b = (top + bottom) / (top - bottom);
|
|
693
|
+
var c = -(far + near) / (far - near);
|
|
694
|
+
var d = (-2 * far * near) / (far - near);
|
|
695
|
+
te[0] = x;
|
|
696
|
+
te[4] = 0;
|
|
697
|
+
te[8] = a;
|
|
698
|
+
te[12] = 0;
|
|
699
|
+
te[1] = 0;
|
|
700
|
+
te[5] = y;
|
|
701
|
+
te[9] = b;
|
|
702
|
+
te[13] = 0;
|
|
703
|
+
te[2] = 0;
|
|
704
|
+
te[6] = 0;
|
|
705
|
+
te[10] = c;
|
|
706
|
+
te[14] = d;
|
|
707
|
+
te[3] = 0;
|
|
708
|
+
te[7] = 0;
|
|
709
|
+
te[11] = -1;
|
|
710
|
+
te[15] = 0;
|
|
711
|
+
return this;
|
|
712
|
+
};
|
|
713
|
+
Mat4.prototype.makeOrthographic = function (left, right, top, bottom, near, far) {
|
|
714
|
+
var te = this.elements;
|
|
715
|
+
var w = 1.0 / (right - left);
|
|
716
|
+
var h = 1.0 / (top - bottom);
|
|
717
|
+
var p = 1.0 / (far - near);
|
|
718
|
+
var x = (right + left) * w;
|
|
719
|
+
var y = (top + bottom) * h;
|
|
720
|
+
var z = (far + near) * p;
|
|
721
|
+
te[0] = 2 * w;
|
|
722
|
+
te[4] = 0;
|
|
723
|
+
te[8] = 0;
|
|
724
|
+
te[12] = -x;
|
|
725
|
+
te[1] = 0;
|
|
726
|
+
te[5] = 2 * h;
|
|
727
|
+
te[9] = 0;
|
|
728
|
+
te[13] = -y;
|
|
729
|
+
te[2] = 0;
|
|
730
|
+
te[6] = 0;
|
|
731
|
+
te[10] = -2 * p;
|
|
732
|
+
te[14] = -z;
|
|
733
|
+
te[3] = 0;
|
|
734
|
+
te[7] = 0;
|
|
735
|
+
te[11] = 0;
|
|
736
|
+
te[15] = 1;
|
|
737
|
+
return this;
|
|
738
|
+
};
|
|
739
|
+
Mat4.prototype.equals = function (matrix) {
|
|
740
|
+
var te = this.elements;
|
|
741
|
+
var me = matrix.elements;
|
|
742
|
+
for (var i = 0; i < 16; i++) {
|
|
743
|
+
if (te[i] !== me[i])
|
|
744
|
+
return false;
|
|
745
|
+
}
|
|
746
|
+
return true;
|
|
747
|
+
};
|
|
748
|
+
Mat4.prototype.fromArray = function (array, offset) {
|
|
749
|
+
if (offset === void 0) { offset = 0; }
|
|
750
|
+
for (var i = 0; i < 16; i++) {
|
|
751
|
+
this.elements[i] = array[i + offset];
|
|
752
|
+
}
|
|
753
|
+
return this;
|
|
754
|
+
};
|
|
755
|
+
Mat4.prototype.toArray = function (array, offset) {
|
|
756
|
+
if (array === void 0) { array = []; }
|
|
757
|
+
if (offset === void 0) { offset = 0; }
|
|
758
|
+
var te = this.elements;
|
|
759
|
+
array[offset] = te[0];
|
|
760
|
+
array[offset + 1] = te[1];
|
|
761
|
+
array[offset + 2] = te[2];
|
|
762
|
+
array[offset + 3] = te[3];
|
|
763
|
+
array[offset + 4] = te[4];
|
|
764
|
+
array[offset + 5] = te[5];
|
|
765
|
+
array[offset + 6] = te[6];
|
|
766
|
+
array[offset + 7] = te[7];
|
|
767
|
+
array[offset + 8] = te[8];
|
|
768
|
+
array[offset + 9] = te[9];
|
|
769
|
+
array[offset + 10] = te[10];
|
|
770
|
+
array[offset + 11] = te[11];
|
|
771
|
+
array[offset + 12] = te[12];
|
|
772
|
+
array[offset + 13] = te[13];
|
|
773
|
+
array[offset + 14] = te[14];
|
|
774
|
+
array[offset + 15] = te[15];
|
|
775
|
+
return array;
|
|
776
|
+
};
|
|
777
|
+
return Mat4;
|
|
778
|
+
}());
|
|
779
|
+
exports.Mat4 = Mat4;
|
|
780
|
+
var _v1 = (0, Vec3_1.v3)();
|
|
781
|
+
var _m1 = m4();
|
|
782
|
+
var _m2 = m4();
|
|
783
|
+
var _zero = (0, Vec3_1.v3)(0, 0, 0);
|
|
784
|
+
var _one = (0, Vec3_1.v3)(1, 1, 1);
|
|
785
|
+
var _x = (0, Vec3_1.v3)();
|
|
786
|
+
var _y = (0, Vec3_1.v3)();
|
|
787
|
+
var _z = (0, Vec3_1.v3)();
|
|
788
|
+
function m4() {
|
|
789
|
+
return new Mat4();
|
|
790
|
+
}
|
|
791
|
+
exports.m4 = m4;
|