@xort/cga 0.0.92 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (369) hide show
  1. package/THIRD_PARTY_NOTICES.md +47 -0
  2. package/build/@xort_cga.js +14209 -14318
  3. package/build/cga.d.ts +2284 -1958
  4. package/build/cga.esm.js +14179 -0
  5. package/dist/THIRD_PARTY_NOTICES.md +47 -0
  6. package/dist/index.cjs +14320 -0
  7. package/dist/index.cjs.map +1 -0
  8. package/dist/index.d.cts +2358 -0
  9. package/dist/index.d.ts +2358 -38
  10. package/dist/index.js +14181 -56
  11. package/dist/index.js.map +1 -0
  12. package/package.json +59 -47
  13. package/readme.md +162 -247
  14. package/.github/FUNDING.yml +0 -12
  15. package/cga/1./347/202/271/344/270/216/347/272/277/346/200/247/345/205/203/347/264/240/347/232/204/350/267/235/347/246/273.html +0 -601
  16. package/cga/1./347/202/271/344/270/216/347/272/277/346/200/247/345/205/203/347/264/240/347/232/204/350/267/235/347/246/273.md +0 -111
  17. package/cga/2./347/202/271/344/270/216/351/235/242/346/200/247/345/205/203/347/264/240.md +0 -4
  18. package/cga/img//347/202/271/344/270/216/345/260/204/347/272/277.png +0 -0
  19. package/cga/img//347/202/271/344/270/216/347/233/264/347/272/277.png +0 -0
  20. package/cga/img//347/202/271/344/270/216/347/272/277/346/256/265.png +0 -0
  21. package/cga/img//347/233/264/347/272/277/347/232/204/350/241/250/350/276/276/345/274/217.png +0 -0
  22. package/deploy.sh +0 -39
  23. package/dist/IKanimation/Bone.d.ts +0 -7
  24. package/dist/IKanimation/Bone.js +0 -20
  25. package/dist/IKanimation/CCDSolver.d.ts +0 -37
  26. package/dist/IKanimation/CCDSolver.js +0 -93
  27. package/dist/IKanimation/Joint.d.ts +0 -3
  28. package/dist/IKanimation/Joint.js +0 -17
  29. package/dist/IKanimation/constaint/constraint.d.ts +0 -10
  30. package/dist/IKanimation/constaint/constraint.js +0 -25
  31. package/dist/IKanimation/constaint/hinge.d.ts +0 -12
  32. package/dist/IKanimation/constaint/hinge.js +0 -46
  33. package/dist/IKanimation/constaint/slider.d.ts +0 -12
  34. package/dist/IKanimation/constaint/slider.js +0 -44
  35. package/dist/IKanimation/index.d.ts +0 -0
  36. package/dist/IKanimation/index.js +0 -9
  37. package/dist/IKanimation/isolver.d.ts +0 -4
  38. package/dist/IKanimation/isolver.js +0 -10
  39. package/dist/IKanimation/skeleton.d.ts +0 -13
  40. package/dist/IKanimation/skeleton.js +0 -31
  41. package/dist/alg/common.d.ts +0 -114
  42. package/dist/alg/common.js +0 -302
  43. package/dist/alg/curve.d.ts +0 -4
  44. package/dist/alg/curve.js +0 -11
  45. package/dist/alg/delaunator.d.ts +0 -29
  46. package/dist/alg/delaunator.js +0 -442
  47. package/dist/alg/delaunay.d.ts +0 -20
  48. package/dist/alg/delaunay.js +0 -199
  49. package/dist/alg/delaunayslow.d.ts +0 -18
  50. package/dist/alg/delaunayslow.js +0 -140
  51. package/dist/alg/extrude/extrude.d.ts +0 -3
  52. package/dist/alg/extrude/extrude.js +0 -17
  53. package/dist/alg/extrude.d.ts +0 -199
  54. package/dist/alg/extrude.js +0 -728
  55. package/dist/alg/offset/index.d.ts +0 -0
  56. package/dist/alg/offset/index.js +0 -9
  57. package/dist/alg/offset.d.ts +0 -0
  58. package/dist/alg/offset.js +0 -472
  59. package/dist/alg/pointset.d.ts +0 -94
  60. package/dist/alg/pointset.js +0 -223
  61. package/dist/alg/recognition.d.ts +0 -14
  62. package/dist/alg/recognition.js +0 -37
  63. package/dist/alg/result.d.ts +0 -22
  64. package/dist/alg/result.js +0 -2
  65. package/dist/alg/segmentset.d.ts +0 -11
  66. package/dist/alg/segmentset.js +0 -45
  67. package/dist/alg/sort.d.ts +0 -2
  68. package/dist/alg/sort.js +0 -14
  69. package/dist/alg/split.d.ts +0 -8
  70. package/dist/alg/split.js +0 -10
  71. package/dist/alg/trianglution.d.ts +0 -15
  72. package/dist/alg/trianglution.js +0 -70
  73. package/dist/alg/vol.d.ts +0 -6
  74. package/dist/alg/vol.js +0 -18
  75. package/dist/alg/voronoi.d.ts +0 -31
  76. package/dist/alg/voronoi.js +0 -418
  77. package/dist/app.d.ts +0 -1
  78. package/dist/app.js +0 -248
  79. package/dist/basic/distance.d.ts +0 -12
  80. package/dist/basic/distance.js +0 -39
  81. package/dist/csg/bsp.d.ts +0 -9
  82. package/dist/csg/bsp.js +0 -22
  83. package/dist/csg/node.d.ts +0 -12
  84. package/dist/csg/node.js +0 -75
  85. package/dist/csg/polygon.d.ts +0 -43
  86. package/dist/csg/polygon.js +0 -161
  87. package/dist/diamondMaterialShader.d.ts +0 -92
  88. package/dist/diamondMaterialShader.js +0 -118
  89. package/dist/effect/breath-light.d.ts +0 -4
  90. package/dist/effect/breath-light.js +0 -39
  91. package/dist/extends/geometryaid.d.ts +0 -28
  92. package/dist/extends/geometryaid.js +0 -71
  93. package/dist/extends/split.d.ts +0 -3
  94. package/dist/extends/split.js +0 -13
  95. package/dist/glview.d.ts +0 -112
  96. package/dist/glview.js +0 -564
  97. package/dist/math/Color.d.ts +0 -33
  98. package/dist/math/Color.js +0 -235
  99. package/dist/math/Euler.d.ts +0 -46
  100. package/dist/math/Euler.js +0 -225
  101. package/dist/math/HVec3.d.ts +0 -43
  102. package/dist/math/HVec3.js +0 -176
  103. package/dist/math/Mat3.d.ts +0 -29
  104. package/dist/math/Mat3.js +0 -244
  105. package/dist/math/Mat4.d.ts +0 -85
  106. package/dist/math/Mat4.js +0 -791
  107. package/dist/math/Math.d.ts +0 -130
  108. package/dist/math/Math.js +0 -198
  109. package/dist/math/Quat.d.ts +0 -82
  110. package/dist/math/Quat.js +0 -418
  111. package/dist/math/Vec2.d.ts +0 -68
  112. package/dist/math/Vec2.js +0 -328
  113. package/dist/math/Vec3.d.ts +0 -240
  114. package/dist/math/Vec3.js +0 -1082
  115. package/dist/math/Vec4.d.ts +0 -81
  116. package/dist/math/Vec4.js +0 -475
  117. package/dist/math/vecs.d.ts +0 -134
  118. package/dist/math/vecs.js +0 -464
  119. package/dist/render/bufferAttribute.d.ts +0 -104
  120. package/dist/render/bufferAttribute.js +0 -344
  121. package/dist/render/geometry.d.ts +0 -87
  122. package/dist/render/geometry.js +0 -769
  123. package/dist/render/mesh.d.ts +0 -30
  124. package/dist/render/mesh.js +0 -87
  125. package/dist/render/types.d.ts +0 -3
  126. package/dist/render/types.js +0 -8
  127. package/dist/robust/plane.d.ts +0 -7
  128. package/dist/robust/plane.js +0 -17
  129. package/dist/robust/vec.d.ts +0 -15
  130. package/dist/robust/vec.js +0 -71
  131. package/dist/struct/3d/Box.d.ts +0 -23
  132. package/dist/struct/3d/Box.js +0 -109
  133. package/dist/struct/3d/Capsule.d.ts +0 -12
  134. package/dist/struct/3d/Capsule.js +0 -36
  135. package/dist/struct/3d/Circle.d.ts +0 -52
  136. package/dist/struct/3d/Circle.js +0 -138
  137. package/dist/struct/3d/Disk.d.ts +0 -10
  138. package/dist/struct/3d/Disk.js +0 -22
  139. package/dist/struct/3d/Frustum.d.ts +0 -35
  140. package/dist/struct/3d/Frustum.js +0 -159
  141. package/dist/struct/3d/Line.d.ts +0 -40
  142. package/dist/struct/3d/Line.js +0 -340
  143. package/dist/struct/3d/Path.d.ts +0 -75
  144. package/dist/struct/3d/Path.js +0 -308
  145. package/dist/struct/3d/Plane.d.ts +0 -74
  146. package/dist/struct/3d/Plane.js +0 -298
  147. package/dist/struct/3d/Point.d.ts +0 -4
  148. package/dist/struct/3d/Point.js +0 -30
  149. package/dist/struct/3d/Polygon.d.ts +0 -8
  150. package/dist/struct/3d/Polygon.js +0 -55
  151. package/dist/struct/3d/Polyline.d.ts +0 -34
  152. package/dist/struct/3d/Polyline.js +0 -130
  153. package/dist/struct/3d/Ray.d.ts +0 -21
  154. package/dist/struct/3d/Ray.js +0 -262
  155. package/dist/struct/3d/Rectangle.d.ts +0 -7
  156. package/dist/struct/3d/Rectangle.js +0 -35
  157. package/dist/struct/3d/Segment.d.ts +0 -32
  158. package/dist/struct/3d/Segment.js +0 -334
  159. package/dist/struct/3d/Shape.d.ts +0 -4
  160. package/dist/struct/3d/Shape.js +0 -27
  161. package/dist/struct/3d/Sphere.d.ts +0 -11
  162. package/dist/struct/3d/Sphere.js +0 -30
  163. package/dist/struct/3d/Triangle.d.ts +0 -8
  164. package/dist/struct/3d/Triangle.js +0 -53
  165. package/dist/struct/bsp.d.ts +0 -9
  166. package/dist/struct/bsp.js +0 -44
  167. package/dist/struct/btree.d.ts +0 -0
  168. package/dist/struct/btree.js +0 -1
  169. package/dist/struct/data/ArrayList.d.ts +0 -42
  170. package/dist/struct/data/ArrayList.js +0 -172
  171. package/dist/struct/data/ArrayObject.d.ts +0 -30
  172. package/dist/struct/data/ArrayObject.js +0 -131
  173. package/dist/struct/data/type.d.ts +0 -13
  174. package/dist/struct/data/type.js +0 -18
  175. package/dist/struct/kdtree.d.ts +0 -0
  176. package/dist/struct/kdtree.js +0 -1
  177. package/dist/struct/polyTree.d.ts +0 -4
  178. package/dist/struct/polyTree.js +0 -27
  179. package/dist/struct/quatTree.d.ts +0 -0
  180. package/dist/struct/quatTree.js +0 -1
  181. package/dist/struct/tree.d.ts +0 -11
  182. package/dist/struct/tree.js +0 -26
  183. package/dist/utils/array.d.ts +0 -24
  184. package/dist/utils/array.js +0 -89
  185. package/dist/utils/types.d.ts +0 -24
  186. package/dist/utils/types.js +0 -20
  187. package/docs/.vuepress/components/distance.vue +0 -125
  188. package/docs/.vuepress/components/intersect.vue +0 -0
  189. package/docs/.vuepress/components/trianglution.vue +0 -121
  190. package/docs/.vuepress/components/utils.js +0 -314
  191. package/docs/.vuepress/config.js +0 -99
  192. package/docs/.vuepress/enhanceApp.js +0 -13
  193. package/docs/.vuepress/public/delaunay.png +0 -0
  194. package/docs/.vuepress/public/logo.png +0 -0
  195. package/docs/.vuepress/public/plane-set-convex.png +0 -0
  196. package/docs/.vuepress/public/sponsor/alipay.jpg +0 -0
  197. package/docs/.vuepress/public/sponsor/wechat.png +0 -0
  198. package/docs/README.md +0 -14
  199. package/docs/demo/README.md +0 -9
  200. package/docs/guide/README.md +0 -94
  201. package/docs/guide/array.md +0 -10
  202. package/docs/guide/cy/trianglution.html +0 -2
  203. package/docs/guide/distLineAll.md +0 -85
  204. package/docs/guide/distPointAll.md +0 -137
  205. package/docs/guide/distRayAll.md +0 -69
  206. package/docs/guide/distSegmentAll.md +0 -19
  207. package/docs/guide/point.vue +0 -12
  208. package/docs/guide/vector.md +0 -10
  209. package/docs/guide//345/270/270/347/224/250.md +0 -156
  210. package/docs/sponsor/README.md +0 -15
  211. package/docs//345/274/200/345/217/221/346/227/245/345/277/227/2020/345/271/2643/346/234/21013/346/227/245.md +0 -6
  212. package/effect/common.glsl +0 -34
  213. package/effect/drawing.glsl +0 -36
  214. package/effect/shape.arc.glsl +0 -13
  215. package/effect/shape.circle.glsl +0 -13
  216. package/effect/shape.grid.glsl +0 -42
  217. package/effect/shape.line.glsl +0 -18
  218. package/effect/shape.pie.glsl +0 -18
  219. package/effect/shape.plot.glsl +0 -10
  220. package/effect/shape.poly.glsl +0 -15
  221. package/effect/shape.rect.glsl +0 -14
  222. package/effect/shape.rectround.glsl +0 -15
  223. package/effect/shape.segment.glsl +0 -10
  224. package/effect/shape.spiral.glsl +0 -12
  225. package/effect/shape.star.glsl +0 -16
  226. package/examples/index.html +0 -31
  227. package/git.sh +0 -12
  228. package/gitproxy.sh +0 -6
  229. package/image/readme/1640758500266.png +0 -0
  230. package/image/readme/1640758513361.png +0 -0
  231. package/index.html +0 -14
  232. package/linear algorithm//346/225/260/345/255/246/350/241/250/350/276/276/345/274/217.md" +0 -122
  233. package/linear algorithm//347/237/251/351/230/265.md" +0 -91
  234. package/rollup.config.js +0 -79
  235. package/scripttest.html +0 -23
  236. package/src/IKanimation/Bone.ts +0 -20
  237. package/src/IKanimation/CCDSolver.ts +0 -114
  238. package/src/IKanimation/Joint.ts +0 -13
  239. package/src/IKanimation/constaint/constraint.ts +0 -23
  240. package/src/IKanimation/constaint/hinge.ts +0 -29
  241. package/src/IKanimation/constaint/slider.ts +0 -25
  242. package/src/IKanimation/index.ts +0 -8
  243. package/src/IKanimation/isolver.ts +0 -13
  244. package/src/IKanimation/skeleton.ts +0 -30
  245. package/src/alg/common.ts +0 -304
  246. package/src/alg/curve.ts +0 -9
  247. package/src/alg/delaunator.ts +0 -519
  248. package/src/alg/delaunay.ts +0 -163
  249. package/src/alg/delaunayslow.ts +0 -183
  250. package/src/alg/extrude/extrude.ts +0 -19
  251. package/src/alg/extrude.ts +0 -941
  252. package/src/alg/offset/index.ts +0 -8
  253. package/src/alg/offset.ts +0 -501
  254. package/src/alg/pointset.ts +0 -219
  255. package/src/alg/recognition.ts +0 -43
  256. package/src/alg/result.ts +0 -24
  257. package/src/alg/segmentset.ts +0 -44
  258. package/src/alg/sort.ts +0 -11
  259. package/src/alg/split.ts +0 -15
  260. package/src/alg/trianglution.ts +0 -53
  261. package/src/alg/vol.ts +0 -18
  262. package/src/alg/voronoi.ts +0 -303
  263. package/src/app.css +0 -12
  264. package/src/app.ts +0 -285
  265. package/src/assets/color.jpg +0 -0
  266. package/src/basic/distance.ts +0 -40
  267. package/src/clipper/clipper.d.ts +0 -323
  268. package/src/clipper/clipper.js +0 -7626
  269. package/src/clipper/clipper_float.js +0 -185
  270. package/src/clipper/clipper_float_unminified.js +0 -5639
  271. package/src/clipper/clipperint.js +0 -7626
  272. package/src/csg/bsp.ts +0 -24
  273. package/src/csg/csg.js +0 -583
  274. package/src/csg/node.ts +0 -91
  275. package/src/csg/polygon.ts +0 -177
  276. package/src/diamondMaterialShader.ts +0 -93
  277. package/src/effect/breath-light.ts +0 -24
  278. package/src/extends/geometryaid.ts +0 -86
  279. package/src/extends/split.ts +0 -15
  280. package/src/glview.ts +0 -570
  281. package/src/index.ts +0 -47
  282. package/src/math/Color.ts +0 -225
  283. package/src/math/Euler.ts +0 -238
  284. package/src/math/HVec3.ts +0 -1144
  285. package/src/math/Mat3.ts +0 -365
  286. package/src/math/Mat4.ts +0 -1134
  287. package/src/math/Math.ts +0 -213
  288. package/src/math/Quat.ts +0 -536
  289. package/src/math/Vec2.ts +0 -408
  290. package/src/math/Vec3.ts +0 -1307
  291. package/src/math/Vec4.ts +0 -587
  292. package/src/math/vecs.ts +0 -486
  293. package/src/render/bufferAttribute.ts +0 -491
  294. package/src/render/geometry.ts +0 -1329
  295. package/src/render/mesh.ts +0 -82
  296. package/src/render/types.ts +0 -17
  297. package/src/robust/plane.ts +0 -12
  298. package/src/robust/readme.md +0 -1
  299. package/src/robust/vec.ts +0 -61
  300. package/src/shader/cga.glsl +0 -202
  301. package/src/shader/common.glsl +0 -87
  302. package/src/shader/noise/GLSL-Noise.md +0 -1108
  303. package/src/shader/noise/cellular2D.glsl +0 -69
  304. package/src/shader/noise/cellular2x2.glsl +0 -64
  305. package/src/shader/noise/cellular2x2x2.glsl +0 -88
  306. package/src/shader/noise/cellular3D.glsl +0 -187
  307. package/src/shader/noise/classicnoise2D.glsl +0 -113
  308. package/src/shader/noise/classicnoise3D.glsl +0 -177
  309. package/src/shader/noise/classicnoise4D.glsl +0 -302
  310. package/src/shader/noise/noise2D.glsl +0 -71
  311. package/src/shader/noise/noise3D.glsl +0 -103
  312. package/src/shader/noise/noise3Dgrad.glsl +0 -111
  313. package/src/shader/noise/noise4D.glsl +0 -129
  314. package/src/shader/noise/psrdnoise2D.glsl +0 -462
  315. package/src/struct/3d/Box.ts +0 -124
  316. package/src/struct/3d/Capsule.ts +0 -18
  317. package/src/struct/3d/Circle.ts +0 -149
  318. package/src/struct/3d/Disk.ts +0 -22
  319. package/src/struct/3d/Frustum.ts +0 -189
  320. package/src/struct/3d/Line.ts +0 -378
  321. package/src/struct/3d/Path.ts +0 -314
  322. package/src/struct/3d/Plane.ts +0 -341
  323. package/src/struct/3d/Point.ts +0 -7
  324. package/src/struct/3d/PolyLine.ts +0 -115
  325. package/src/struct/3d/Polygon.ts +0 -46
  326. package/src/struct/3d/Ray.ts +0 -285
  327. package/src/struct/3d/Rectangle.ts +0 -18
  328. package/src/struct/3d/Segment.ts +0 -330
  329. package/src/struct/3d/Shape.ts +0 -7
  330. package/src/struct/3d/Sphere.ts +0 -31
  331. package/src/struct/3d/Triangle.ts +0 -28
  332. package/src/struct/bsp.ts +0 -18
  333. package/src/struct/btree.ts +0 -0
  334. package/src/struct/data/ArrayList.ts +0 -144
  335. package/src/struct/data/ArrayObject.ts +0 -105
  336. package/src/struct/data/type.ts +0 -14
  337. package/src/struct/kdtree.ts +0 -0
  338. package/src/struct/polyTree.ts +0 -8
  339. package/src/struct/quatTree.ts +0 -0
  340. package/src/struct/tree.ts +0 -30
  341. package/src/utils/array.ts +0 -106
  342. package/src/utils/types.ts +0 -42
  343. package/src-gis/app.ts +0 -7
  344. package/src-gis/core/Cartographic.ts +0 -48
  345. package/src-gis/core/EllipsoidGeodesic.ts +0 -56
  346. package/src-gis/core/EllipsoidTerrainProvider.ts +0 -35
  347. package/src-gis/core/HeightmapTerrainData.ts +0 -5
  348. package/src-gis/core/Rectangle.ts +0 -112
  349. package/src-gis/core/TaskProcessor.ts +0 -222
  350. package/src-gis/gis.ts +0 -25
  351. package/src-gis/globe.ts +0 -54
  352. package/src-gis/math/Cartographic.ts +0 -24
  353. package/src-gis/math/GVec3.ts +0 -55
  354. package/src-gis/math/ellipsoid.ts +0 -13
  355. package/src-gis/provider/DcTerrainProvider.ts +0 -36
  356. package/src-gis/provider/TerrainProvider.ts +0 -12
  357. package/src-gis/scene/DcImageryProvider.ts +0 -36
  358. package/src-gis/scene/GeographicTilingScheme.ts +0 -65
  359. package/src-gis/scene/Globe.ts +0 -76
  360. package/src-gis/scene/GlobeSurfaceShaderSet.ts +0 -9
  361. package/src-gis/scene/GlobeSurfaceTileProvider.ts +0 -25
  362. package/src-gis/scene/ImageryLayerCollection.ts +0 -75
  363. package/src-gis/scene/ImageryProvider.ts +0 -28
  364. package/src-gis/scene/QuadtreeTile.ts +0 -162
  365. package/src-gis/scene/UrlTemplateImageryProvider.ts +0 -32
  366. package/src-gis/scene/quadtree_primitive.ts +0 -58
  367. package/tsconfig.json +0 -77
  368. package/webpack.config.js +0 -112
  369. package//350/256/241/347/256/227/345/207/240/344/275/225/351/227/256/351/242/230.md +0 -26
@@ -1,129 +0,0 @@
1
- //
2
- // Description : Array and textureless GLSL 2D/3D/4D simplex
3
- // noise functions.
4
- // Author : Ian McEwan, Ashima Arts.
5
- // Maintainer : stegu
6
- // Lastmod : 20110822 (ijm)
7
- // License : Copyright (C) 2011 Ashima Arts. All rights reserved.
8
- // Distributed under the MIT License. See LICENSE file.
9
- // https://github.com/ashima/webgl-noise
10
- // https://github.com/stegu/webgl-noise
11
- //
12
-
13
- vec4 mod289(vec4 x) {
14
- return x - floor(x * (1.0 / 289.0)) * 289.0; }
15
-
16
- float mod289(float x) {
17
- return x - floor(x * (1.0 / 289.0)) * 289.0; }
18
-
19
- vec4 permute(vec4 x) {
20
- return mod289(((x*34.0)+1.0)*x);
21
- }
22
-
23
- float permute(float x) {
24
- return mod289(((x*34.0)+1.0)*x);
25
- }
26
-
27
- vec4 taylorInvSqrt(vec4 r)
28
- {
29
- return 1.79284291400159 - 0.85373472095314 * r;
30
- }
31
-
32
- float taylorInvSqrt(float r)
33
- {
34
- return 1.79284291400159 - 0.85373472095314 * r;
35
- }
36
-
37
- vec4 grad4(float j, vec4 ip)
38
- {
39
- const vec4 ones = vec4(1.0, 1.0, 1.0, -1.0);
40
- vec4 p,s;
41
-
42
- p.xyz = floor( fract (vec3(j) * ip.xyz) * 7.0) * ip.z - 1.0;
43
- p.w = 1.5 - dot(abs(p.xyz), ones.xyz);
44
- s = vec4(lessThan(p, vec4(0.0)));
45
- p.xyz = p.xyz + (s.xyz*2.0 - 1.0) * s.www;
46
-
47
- return p;
48
- }
49
-
50
- // (sqrt(5) - 1)/4 = F4, used once below
51
- #define F4 0.309016994374947451
52
-
53
- float snoise(vec4 v)
54
- {
55
- const vec4 C = vec4( 0.138196601125011, // (5 - sqrt(5))/20 G4
56
- 0.276393202250021, // 2 * G4
57
- 0.414589803375032, // 3 * G4
58
- -0.447213595499958); // -1 + 4 * G4
59
-
60
- // First corner
61
- vec4 i = floor(v + dot(v, vec4(F4)) );
62
- vec4 x0 = v - i + dot(i, C.xxxx);
63
-
64
- // Other corners
65
-
66
- // Rank sorting originally contributed by Bill Licea-Kane, AMD (formerly ATI)
67
- vec4 i0;
68
- vec3 isX = step( x0.yzw, x0.xxx );
69
- vec3 isYZ = step( x0.zww, x0.yyz );
70
- // i0.x = dot( isX, vec3( 1.0 ) );
71
- i0.x = isX.x + isX.y + isX.z;
72
- i0.yzw = 1.0 - isX;
73
- // i0.y += dot( isYZ.xy, vec2( 1.0 ) );
74
- i0.y += isYZ.x + isYZ.y;
75
- i0.zw += 1.0 - isYZ.xy;
76
- i0.z += isYZ.z;
77
- i0.w += 1.0 - isYZ.z;
78
-
79
- // i0 now contains the unique values 0,1,2,3 in each channel
80
- vec4 i3 = clamp( i0, 0.0, 1.0 );
81
- vec4 i2 = clamp( i0-1.0, 0.0, 1.0 );
82
- vec4 i1 = clamp( i0-2.0, 0.0, 1.0 );
83
-
84
- // x0 = x0 - 0.0 + 0.0 * C.xxxx
85
- // x1 = x0 - i1 + 1.0 * C.xxxx
86
- // x2 = x0 - i2 + 2.0 * C.xxxx
87
- // x3 = x0 - i3 + 3.0 * C.xxxx
88
- // x4 = x0 - 1.0 + 4.0 * C.xxxx
89
- vec4 x1 = x0 - i1 + C.xxxx;
90
- vec4 x2 = x0 - i2 + C.yyyy;
91
- vec4 x3 = x0 - i3 + C.zzzz;
92
- vec4 x4 = x0 + C.wwww;
93
-
94
- // Permutations
95
- i = mod289(i);
96
- float j0 = permute( permute( permute( permute(i.w) + i.z) + i.y) + i.x);
97
- vec4 j1 = permute( permute( permute( permute (
98
- i.w + vec4(i1.w, i2.w, i3.w, 1.0 ))
99
- + i.z + vec4(i1.z, i2.z, i3.z, 1.0 ))
100
- + i.y + vec4(i1.y, i2.y, i3.y, 1.0 ))
101
- + i.x + vec4(i1.x, i2.x, i3.x, 1.0 ));
102
-
103
- // Gradients: 7x7x6 points over a cube, mapped onto a 4-cross polytope
104
- // 7*7*6 = 294, which is close to the ring size 17*17 = 289.
105
- vec4 ip = vec4(1.0/294.0, 1.0/49.0, 1.0/7.0, 0.0) ;
106
-
107
- vec4 p0 = grad4(j0, ip);
108
- vec4 p1 = grad4(j1.x, ip);
109
- vec4 p2 = grad4(j1.y, ip);
110
- vec4 p3 = grad4(j1.z, ip);
111
- vec4 p4 = grad4(j1.w, ip);
112
-
113
- // Normalise gradients
114
- vec4 norm = taylorInvSqrt(vec4(dot(p0,p0), dot(p1,p1), dot(p2, p2), dot(p3,p3)));
115
- p0 *= norm.x;
116
- p1 *= norm.y;
117
- p2 *= norm.z;
118
- p3 *= norm.w;
119
- p4 *= taylorInvSqrt(dot(p4,p4));
120
-
121
- // Mix contributions from the five corners
122
- vec3 m0 = max(0.6 - vec3(dot(x0,x0), dot(x1,x1), dot(x2,x2)), 0.0);
123
- vec2 m1 = max(0.6 - vec2(dot(x3,x3), dot(x4,x4) ), 0.0);
124
- m0 = m0 * m0;
125
- m1 = m1 * m1;
126
- return 49.0 * ( dot(m0*m0, vec3( dot( p0, x0 ), dot( p1, x1 ), dot( p2, x2 )))
127
- + dot(m1*m1, vec2( dot( p3, x3 ), dot( p4, x4 ) ) ) ) ;
128
-
129
- }
@@ -1,462 +0,0 @@
1
- //
2
- // vec3 psrdnoise(vec2 pos, vec2 per, float rot)
3
- // vec3 psdnoise(vec2 pos, vec2 per)
4
- // float psrnoise(vec2 pos, vec2 per, float rot)
5
- // float psnoise(vec2 pos, vec2 per)
6
- // vec3 srdnoise(vec2 pos, float rot)
7
- // vec3 sdnoise(vec2 pos)
8
- // float srnoise(vec2 pos, float rot)
9
- // float snoise(vec2 pos)
10
- //
11
- // Periodic (tiling) 2-D simplex noise (hexagonal lattice gradient noise)
12
- // with rotating gradients and analytic derivatives.
13
- // Variants also without the derivative (no "d" in the name), without
14
- // the tiling property (no "p" in the name) and without the rotating
15
- // gradients (no "r" in the name).
16
- //
17
- // This is (yet) another variation on simplex noise. It's similar to the
18
- // version presented by Ken Perlin, but the grid is axis-aligned and
19
- // slightly stretched in the y direction to permit rectangular tiling.
20
- //
21
- // The noise can be made to tile seamlessly to any integer period in x and
22
- // any even integer period in y. Odd periods may be specified for y, but
23
- // then the actual tiling period will be twice that number.
24
- //
25
- // The rotating gradients give the appearance of a swirling motion, and can
26
- // serve a similar purpose for animation as motion along z in 3-D noise.
27
- // The rotating gradients in conjunction with the analytic derivatives
28
- // can make "flow noise" effects as presented by Perlin and Neyret.
29
- //
30
- // vec3 {p}s{r}dnoise(vec2 pos {, vec2 per} {, float rot})
31
- // "pos" is the input (x,y) coordinate
32
- // "per" is the x and y period, where per.x is a positive integer
33
- // and per.y is a positive even integer
34
- // "rot" is the angle to rotate the gradients (any float value,
35
- // where 0.0 is no rotation and 1.0 is one full turn)
36
- // The first component of the 3-element return vector is the noise value.
37
- // The second and third components are the x and y partial derivatives.
38
- //
39
- // float {p}s{r}noise(vec2 pos {, vec2 per} {, float rot})
40
- // "pos" is the input (x,y) coordinate
41
- // "per" is the x and y period, where per.x is a positive integer
42
- // and per.y is a positive even integer
43
- // "rot" is the angle to rotate the gradients (any float value,
44
- // where 0.0 is no rotation and 1.0 is one full turn)
45
- // The return value is the noise value.
46
- // Partial derivatives are not computed, making these functions faster.
47
- //
48
- // Author: Stefan Gustavson (stefan.gustavson@gmail.com)
49
- // Version 2016-05-10.
50
- //
51
- // Many thanks to Ian McEwan of Ashima Arts for the
52
- // idea of using a permutation polynomial.
53
- //
54
- // Copyright (c) 2016 Stefan Gustavson. All rights reserved.
55
- // Distributed under the MIT license. See LICENSE file.
56
- // https://github.com/stegu/webgl-noise
57
- //
58
-
59
- //
60
- // TODO: One-pixel wide artefacts used to occur due to precision issues with
61
- // the gradient indexing. This is specific to this variant of noise, because
62
- // one axis of the simplex grid is perfectly aligned with the input x axis.
63
- // The errors were rare, and they are now very unlikely to ever be visible
64
- // after a quick fix was introduced: a small offset is added to the y coordinate.
65
- // A proper fix would involve using round() instead of floor() in selected
66
- // places, but the quick fix works fine.
67
- // (If you run into problems with this, please let me know.)
68
- //
69
-
70
- // Modulo 289, optimizes to code without divisions
71
- vec3 mod289(vec3 x) {
72
- return x - floor(x * (1.0 / 289.0)) * 289.0;
73
- }
74
-
75
- // Permutation polynomial (ring size 289 = 17*17)
76
- vec3 permute(vec3 x) {
77
- return mod289(((x*34.0)+1.0)*x);
78
- }
79
-
80
- // Hashed 2-D gradients with an extra rotation.
81
- // (The constant 0.0243902439 is 1/41)
82
- vec2 rgrad2(vec2 p, float rot) {
83
- #if 0
84
- // Map from a line to a diamond such that a shift maps to a rotation.
85
- float u = permute(permute(p.x) + p.y) * 0.0243902439 + rot; // Rotate by shift
86
- u = 4.0 * fract(u) - 2.0;
87
- // (This vector could be normalized, exactly or approximately.)
88
- return vec2(abs(u)-1.0, abs(abs(u+1.0)-2.0)-1.0);
89
- #else
90
- // For more isotropic gradients, sin/cos can be used instead.
91
- float u = permute(permute(p.x) + p.y) * 0.0243902439 + rot; // Rotate by shift
92
- u = fract(u) * 6.28318530718; // 2*pi
93
- return vec2(cos(u), sin(u));
94
- #endif
95
- }
96
-
97
- //
98
- // 2-D tiling simplex noise with rotating gradients and analytical derivative.
99
- // The first component of the 3-element return vector is the noise value,
100
- // and the second and third components are the x and y partial derivatives.
101
- //
102
- vec3 psrdnoise(vec2 pos, vec2 per, float rot) {
103
- // Hack: offset y slightly to hide some rare artifacts
104
- pos.y += 0.01;
105
- // Skew to hexagonal grid
106
- vec2 uv = vec2(pos.x + pos.y*0.5, pos.y);
107
-
108
- vec2 i0 = floor(uv);
109
- vec2 f0 = fract(uv);
110
- // Traversal order
111
- vec2 i1 = (f0.x > f0.y) ? vec2(1.0, 0.0) : vec2(0.0, 1.0);
112
-
113
- // Unskewed grid points in (x,y) space
114
- vec2 p0 = vec2(i0.x - i0.y * 0.5, i0.y);
115
- vec2 p1 = vec2(p0.x + i1.x - i1.y * 0.5, p0.y + i1.y);
116
- vec2 p2 = vec2(p0.x + 0.5, p0.y + 1.0);
117
-
118
- // Integer grid point indices in (u,v) space
119
- i1 = i0 + i1;
120
- vec2 i2 = i0 + vec2(1.0, 1.0);
121
-
122
- // Vectors in unskewed (x,y) coordinates from
123
- // each of the simplex corners to the evaluation point
124
- vec2 d0 = pos - p0;
125
- vec2 d1 = pos - p1;
126
- vec2 d2 = pos - p2;
127
-
128
- // Wrap i0, i1 and i2 to the desired period before gradient hashing:
129
- // wrap points in (x,y), map to (u,v)
130
- vec3 xw = mod(vec3(p0.x, p1.x, p2.x), per.x);
131
- vec3 yw = mod(vec3(p0.y, p1.y, p2.y), per.y);
132
- vec3 iuw = xw + 0.5 * yw;
133
- vec3 ivw = yw;
134
-
135
- // Create gradients from indices
136
- vec2 g0 = rgrad2(vec2(iuw.x, ivw.x), rot);
137
- vec2 g1 = rgrad2(vec2(iuw.y, ivw.y), rot);
138
- vec2 g2 = rgrad2(vec2(iuw.z, ivw.z), rot);
139
-
140
- // Gradients dot vectors to corresponding corners
141
- // (The derivatives of this are simply the gradients)
142
- vec3 w = vec3(dot(g0, d0), dot(g1, d1), dot(g2, d2));
143
-
144
- // Radial weights from corners
145
- // 0.8 is the square of 2/sqrt(5), the distance from
146
- // a grid point to the nearest simplex boundary
147
- vec3 t = 0.8 - vec3(dot(d0, d0), dot(d1, d1), dot(d2, d2));
148
-
149
- // Partial derivatives for analytical gradient computation
150
- vec3 dtdx = -2.0 * vec3(d0.x, d1.x, d2.x);
151
- vec3 dtdy = -2.0 * vec3(d0.y, d1.y, d2.y);
152
-
153
- // Set influence of each surflet to zero outside radius sqrt(0.8)
154
- if (t.x < 0.0) {
155
- dtdx.x = 0.0;
156
- dtdy.x = 0.0;
157
- t.x = 0.0;
158
- }
159
- if (t.y < 0.0) {
160
- dtdx.y = 0.0;
161
- dtdy.y = 0.0;
162
- t.y = 0.0;
163
- }
164
- if (t.z < 0.0) {
165
- dtdx.z = 0.0;
166
- dtdy.z = 0.0;
167
- t.z = 0.0;
168
- }
169
-
170
- // Fourth power of t (and third power for derivative)
171
- vec3 t2 = t * t;
172
- vec3 t4 = t2 * t2;
173
- vec3 t3 = t2 * t;
174
-
175
- // Final noise value is:
176
- // sum of ((radial weights) times (gradient dot vector from corner))
177
- float n = dot(t4, w);
178
-
179
- // Final analytical derivative (gradient of a sum of scalar products)
180
- vec2 dt0 = vec2(dtdx.x, dtdy.x) * 4.0 * t3.x;
181
- vec2 dn0 = t4.x * g0 + dt0 * w.x;
182
- vec2 dt1 = vec2(dtdx.y, dtdy.y) * 4.0 * t3.y;
183
- vec2 dn1 = t4.y * g1 + dt1 * w.y;
184
- vec2 dt2 = vec2(dtdx.z, dtdy.z) * 4.0 * t3.z;
185
- vec2 dn2 = t4.z * g2 + dt2 * w.z;
186
-
187
- return 11.0*vec3(n, dn0 + dn1 + dn2);
188
- }
189
-
190
- //
191
- // 2-D tiling simplex noise with fixed gradients
192
- // and analytical derivative.
193
- // This function is implemented as a wrapper to "psrdnoise",
194
- // at the minimal cost of three extra additions.
195
- //
196
- vec3 psdnoise(vec2 pos, vec2 per) {
197
- return psrdnoise(pos, per, 0.0);
198
- }
199
-
200
- //
201
- // 2-D tiling simplex noise with rotating gradients,
202
- // but without the analytical derivative.
203
- //
204
- float psrnoise(vec2 pos, vec2 per, float rot) {
205
- // Offset y slightly to hide some rare artifacts
206
- pos.y += 0.001;
207
- // Skew to hexagonal grid
208
- vec2 uv = vec2(pos.x + pos.y*0.5, pos.y);
209
-
210
- vec2 i0 = floor(uv);
211
- vec2 f0 = fract(uv);
212
- // Traversal order
213
- vec2 i1 = (f0.x > f0.y) ? vec2(1.0, 0.0) : vec2(0.0, 1.0);
214
-
215
- // Unskewed grid points in (x,y) space
216
- vec2 p0 = vec2(i0.x - i0.y * 0.5, i0.y);
217
- vec2 p1 = vec2(p0.x + i1.x - i1.y * 0.5, p0.y + i1.y);
218
- vec2 p2 = vec2(p0.x + 0.5, p0.y + 1.0);
219
-
220
- // Integer grid point indices in (u,v) space
221
- i1 = i0 + i1;
222
- vec2 i2 = i0 + vec2(1.0, 1.0);
223
-
224
- // Vectors in unskewed (x,y) coordinates from
225
- // each of the simplex corners to the evaluation point
226
- vec2 d0 = pos - p0;
227
- vec2 d1 = pos - p1;
228
- vec2 d2 = pos - p2;
229
-
230
- // Wrap i0, i1 and i2 to the desired period before gradient hashing:
231
- // wrap points in (x,y), map to (u,v)
232
- vec3 xw = mod(vec3(p0.x, p1.x, p2.x), per.x);
233
- vec3 yw = mod(vec3(p0.y, p1.y, p2.y), per.y);
234
- vec3 iuw = xw + 0.5 * yw;
235
- vec3 ivw = yw;
236
-
237
- // Create gradients from indices
238
- vec2 g0 = rgrad2(vec2(iuw.x, ivw.x), rot);
239
- vec2 g1 = rgrad2(vec2(iuw.y, ivw.y), rot);
240
- vec2 g2 = rgrad2(vec2(iuw.z, ivw.z), rot);
241
-
242
- // Gradients dot vectors to corresponding corners
243
- // (The derivatives of this are simply the gradients)
244
- vec3 w = vec3(dot(g0, d0), dot(g1, d1), dot(g2, d2));
245
-
246
- // Radial weights from corners
247
- // 0.8 is the square of 2/sqrt(5), the distance from
248
- // a grid point to the nearest simplex boundary
249
- vec3 t = 0.8 - vec3(dot(d0, d0), dot(d1, d1), dot(d2, d2));
250
-
251
- // Set influence of each surflet to zero outside radius sqrt(0.8)
252
- t = max(t, 0.0);
253
-
254
- // Fourth power of t
255
- vec3 t2 = t * t;
256
- vec3 t4 = t2 * t2;
257
-
258
- // Final noise value is:
259
- // sum of ((radial weights) times (gradient dot vector from corner))
260
- float n = dot(t4, w);
261
-
262
- // Rescale to cover the range [-1,1] reasonably well
263
- return 11.0*n;
264
- }
265
-
266
- //
267
- // 2-D tiling simplex noise with fixed gradients,
268
- // without the analytical derivative.
269
- // This function is implemented as a wrapper to "psrnoise",
270
- // at the minimal cost of three extra additions.
271
- //
272
- float psnoise(vec2 pos, vec2 per) {
273
- return psrnoise(pos, per, 0.0);
274
- }
275
-
276
- //
277
- // 2-D non-tiling simplex noise with rotating gradients and analytical derivative.
278
- // The first component of the 3-element return vector is the noise value,
279
- // and the second and third components are the x and y partial derivatives.
280
- //
281
- vec3 srdnoise(vec2 pos, float rot) {
282
- // Offset y slightly to hide some rare artifacts
283
- pos.y += 0.001;
284
- // Skew to hexagonal grid
285
- vec2 uv = vec2(pos.x + pos.y*0.5, pos.y);
286
-
287
- vec2 i0 = floor(uv);
288
- vec2 f0 = fract(uv);
289
- // Traversal order
290
- vec2 i1 = (f0.x > f0.y) ? vec2(1.0, 0.0) : vec2(0.0, 1.0);
291
-
292
- // Unskewed grid points in (x,y) space
293
- vec2 p0 = vec2(i0.x - i0.y * 0.5, i0.y);
294
- vec2 p1 = vec2(p0.x + i1.x - i1.y * 0.5, p0.y + i1.y);
295
- vec2 p2 = vec2(p0.x + 0.5, p0.y + 1.0);
296
-
297
- // Integer grid point indices in (u,v) space
298
- i1 = i0 + i1;
299
- vec2 i2 = i0 + vec2(1.0, 1.0);
300
-
301
- // Vectors in unskewed (x,y) coordinates from
302
- // each of the simplex corners to the evaluation point
303
- vec2 d0 = pos - p0;
304
- vec2 d1 = pos - p1;
305
- vec2 d2 = pos - p2;
306
-
307
- vec3 x = vec3(p0.x, p1.x, p2.x);
308
- vec3 y = vec3(p0.y, p1.y, p2.y);
309
- vec3 iuw = x + 0.5 * y;
310
- vec3 ivw = y;
311
-
312
- // Avoid precision issues in permutation
313
- iuw = mod289(iuw);
314
- ivw = mod289(ivw);
315
-
316
- // Create gradients from indices
317
- vec2 g0 = rgrad2(vec2(iuw.x, ivw.x), rot);
318
- vec2 g1 = rgrad2(vec2(iuw.y, ivw.y), rot);
319
- vec2 g2 = rgrad2(vec2(iuw.z, ivw.z), rot);
320
-
321
- // Gradients dot vectors to corresponding corners
322
- // (The derivatives of this are simply the gradients)
323
- vec3 w = vec3(dot(g0, d0), dot(g1, d1), dot(g2, d2));
324
-
325
- // Radial weights from corners
326
- // 0.8 is the square of 2/sqrt(5), the distance from
327
- // a grid point to the nearest simplex boundary
328
- vec3 t = 0.8 - vec3(dot(d0, d0), dot(d1, d1), dot(d2, d2));
329
-
330
- // Partial derivatives for analytical gradient computation
331
- vec3 dtdx = -2.0 * vec3(d0.x, d1.x, d2.x);
332
- vec3 dtdy = -2.0 * vec3(d0.y, d1.y, d2.y);
333
-
334
- // Set influence of each surflet to zero outside radius sqrt(0.8)
335
- if (t.x < 0.0) {
336
- dtdx.x = 0.0;
337
- dtdy.x = 0.0;
338
- t.x = 0.0;
339
- }
340
- if (t.y < 0.0) {
341
- dtdx.y = 0.0;
342
- dtdy.y = 0.0;
343
- t.y = 0.0;
344
- }
345
- if (t.z < 0.0) {
346
- dtdx.z = 0.0;
347
- dtdy.z = 0.0;
348
- t.z = 0.0;
349
- }
350
-
351
- // Fourth power of t (and third power for derivative)
352
- vec3 t2 = t * t;
353
- vec3 t4 = t2 * t2;
354
- vec3 t3 = t2 * t;
355
-
356
- // Final noise value is:
357
- // sum of ((radial weights) times (gradient dot vector from corner))
358
- float n = dot(t4, w);
359
-
360
- // Final analytical derivative (gradient of a sum of scalar products)
361
- vec2 dt0 = vec2(dtdx.x, dtdy.x) * 4.0 * t3.x;
362
- vec2 dn0 = t4.x * g0 + dt0 * w.x;
363
- vec2 dt1 = vec2(dtdx.y, dtdy.y) * 4.0 * t3.y;
364
- vec2 dn1 = t4.y * g1 + dt1 * w.y;
365
- vec2 dt2 = vec2(dtdx.z, dtdy.z) * 4.0 * t3.z;
366
- vec2 dn2 = t4.z * g2 + dt2 * w.z;
367
-
368
- return 11.0*vec3(n, dn0 + dn1 + dn2);
369
- }
370
-
371
- //
372
- // 2-D non-tiling simplex noise with fixed gradients and analytical derivative.
373
- // This function is implemented as a wrapper to "srdnoise",
374
- // at the minimal cost of three extra additions.
375
- //
376
- vec3 sdnoise(vec2 pos) {
377
- return srdnoise(pos, 0.0);
378
- }
379
-
380
- //
381
- // 2-D non-tiling simplex noise with rotating gradients,
382
- // without the analytical derivative.
383
- //
384
- float srnoise(vec2 pos, float rot) {
385
- // Offset y slightly to hide some rare artifacts
386
- pos.y += 0.001;
387
- // Skew to hexagonal grid
388
- vec2 uv = vec2(pos.x + pos.y*0.5, pos.y);
389
-
390
- vec2 i0 = floor(uv);
391
- vec2 f0 = fract(uv);
392
- // Traversal order
393
- vec2 i1 = (f0.x > f0.y) ? vec2(1.0, 0.0) : vec2(0.0, 1.0);
394
-
395
- // Unskewed grid points in (x,y) space
396
- vec2 p0 = vec2(i0.x - i0.y * 0.5, i0.y);
397
- vec2 p1 = vec2(p0.x + i1.x - i1.y * 0.5, p0.y + i1.y);
398
- vec2 p2 = vec2(p0.x + 0.5, p0.y + 1.0);
399
-
400
- // Integer grid point indices in (u,v) space
401
- i1 = i0 + i1;
402
- vec2 i2 = i0 + vec2(1.0, 1.0);
403
-
404
- // Vectors in unskewed (x,y) coordinates from
405
- // each of the simplex corners to the evaluation point
406
- vec2 d0 = pos - p0;
407
- vec2 d1 = pos - p1;
408
- vec2 d2 = pos - p2;
409
-
410
- // Wrap i0, i1 and i2 to the desired period before gradient hashing:
411
- // wrap points in (x,y), map to (u,v)
412
- vec3 x = vec3(p0.x, p1.x, p2.x);
413
- vec3 y = vec3(p0.y, p1.y, p2.y);
414
- vec3 iuw = x + 0.5 * y;
415
- vec3 ivw = y;
416
-
417
- // Avoid precision issues in permutation
418
- iuw = mod289(iuw);
419
- ivw = mod289(ivw);
420
-
421
- // Create gradients from indices
422
- vec2 g0 = rgrad2(vec2(iuw.x, ivw.x), rot);
423
- vec2 g1 = rgrad2(vec2(iuw.y, ivw.y), rot);
424
- vec2 g2 = rgrad2(vec2(iuw.z, ivw.z), rot);
425
-
426
- // Gradients dot vectors to corresponding corners
427
- // (The derivatives of this are simply the gradients)
428
- vec3 w = vec3(dot(g0, d0), dot(g1, d1), dot(g2, d2));
429
-
430
- // Radial weights from corners
431
- // 0.8 is the square of 2/sqrt(5), the distance from
432
- // a grid point to the nearest simplex boundary
433
- vec3 t = 0.8 - vec3(dot(d0, d0), dot(d1, d1), dot(d2, d2));
434
-
435
- // Set influence of each surflet to zero outside radius sqrt(0.8)
436
- t = max(t, 0.0);
437
-
438
- // Fourth power of t
439
- vec3 t2 = t * t;
440
- vec3 t4 = t2 * t2;
441
-
442
- // Final noise value is:
443
- // sum of ((radial weights) times (gradient dot vector from corner))
444
- float n = dot(t4, w);
445
-
446
- // Rescale to cover the range [-1,1] reasonably well
447
- return 11.0*n;
448
- }
449
-
450
- //
451
- // 2-D non-tiling simplex noise with fixed gradients,
452
- // without the analytical derivative.
453
- // This function is implemented as a wrapper to "srnoise",
454
- // at the minimal cost of three extra additions.
455
- // Note: if this kind of noise is all you want, there are faster
456
- // GLSL implementations of non-tiling simplex noise out there.
457
- // This one is included mainly for completeness and compatibility
458
- // with the other functions in the file.
459
- //
460
- float snoise(vec2 pos) {
461
- return srnoise(pos, 0.0);
462
- }
@@ -1,124 +0,0 @@
1
-
2
- import { BufferAttribute } from "../../render/bufferAttribute";
3
- import { v3, Vec3 } from "../../math/Vec3";
4
-
5
-
6
- const _vector = new Vec3();
7
-
8
- export class Box {
9
-
10
- min: Vec3;
11
- max: Vec3;
12
- _center: Vec3 = v3();
13
- constructor(min: Vec3 = v3(Infinity, Infinity, Infinity), max: Vec3 = v3(-Infinity, -Infinity, -Infinity)) {
14
- this.min = min;
15
- this.max = max;
16
- // if (points) {
17
- // this.setFromPoints(points);
18
- // }
19
- }
20
-
21
- get center() {
22
- return this._center.add(this.min, this.max).multiplyScalar(0.5)
23
- }
24
-
25
- /**
26
- *
27
- * @param {Array<Vec3>} points
28
- */
29
- setFromPoints(points: any) {
30
- this.min.set(Infinity, Infinity, Infinity);
31
- this.max.set(-Infinity, -Infinity, -Infinity);
32
- this.expand(...points)
33
- }
34
-
35
- expand(...points: any[]) {
36
- for (let i = 0; i < points.length; i++) {
37
- const point = points[i];
38
- this.min.min(point);
39
- this.max.max(point);
40
- }
41
- this.center.addVecs(this.min, this.max).multiplyScalar(0.5);
42
- }
43
-
44
- makeEmpty() {
45
- this.min.x = this.min.y = this.min.z = + Infinity;
46
- this.max.x = this.max.y = this.max.z = - Infinity;
47
-
48
- return this;
49
- }
50
- clone(): Box | undefined {
51
- return new Box().copy(this);
52
- }
53
- copy(box: Box): Box {
54
- this.min.copy(box.min);
55
- this.max.copy(box.max);
56
-
57
- return this;
58
- }
59
- setFromCenterAndSize(center: Vec3, size: Vec3) {
60
-
61
- const halfSize = _vector.copy(size).multiplyScalar(0.5);
62
-
63
- this.min.copy(center).sub(halfSize);
64
- this.max.copy(center).add(halfSize);
65
-
66
- return this;
67
-
68
- }
69
-
70
-
71
- setFromBufferAttribute(attribute: BufferAttribute) {
72
-
73
- let minX = + Infinity;
74
- let minY = + Infinity;
75
- let minZ = + Infinity;
76
-
77
- let maxX = - Infinity;
78
- let maxY = - Infinity;
79
- let maxZ = - Infinity;
80
-
81
- for (let i = 0, l = attribute.count; i < l; i++) {
82
-
83
- const x = attribute.getX(i);
84
- const y = attribute.getY(i);
85
- const z = attribute.getZ(i);
86
-
87
- if (x < minX) minX = x;
88
- if (y < minY) minY = y;
89
- if (z < minZ) minZ = z;
90
-
91
- if (x > maxX) maxX = x;
92
- if (y > maxY) maxY = y;
93
- if (z > maxZ) maxZ = z;
94
-
95
- }
96
-
97
- this.min.set(minX, minY, minZ);
98
- this.max.set(maxX, maxY, maxZ);
99
-
100
- return this;
101
- }
102
- expandByPoint(point: Vec3) {
103
- this.min.min(point);
104
- this.max.max(point);
105
-
106
- return this;
107
- }
108
-
109
- isEmpty() {
110
- return (this.max.x < this.min.x) || (this.max.y < this.min.y) || (this.max.z < this.min.z);
111
- }
112
-
113
- getCenter(target: Vec3): Vec3 {
114
- if (target === undefined) {
115
-
116
- console.warn('THREE.Box3: .getCenter() target is now required');
117
- target = new Vec3();
118
-
119
- }
120
-
121
- return this.isEmpty() ? target.set(0, 0, 0) : target.addVecs(this.min, this.max).multiplyScalar(0.5);
122
-
123
- }
124
- }