chorama 0.0.0 → 0.1.1

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 (380) hide show
  1. package/.github/workflows/publish.yml +24 -0
  2. package/.github/workflows/static.yml +22 -53
  3. package/README.md +3 -1
  4. package/assets/models/glb/AlphaBlendModeTest.glb +0 -0
  5. package/assets/models/glb/IridescenceLamp.glb +0 -0
  6. package/assets/models/glb/teapot.glb +0 -0
  7. package/astro.config.mjs +9 -21
  8. package/content/guide/render-targets-and-views.md +3 -4
  9. package/content/guide/textures-and-assets.md +5 -2
  10. package/dist/index.module.js +23336 -0
  11. package/dist/index.module.js.map +1 -0
  12. package/dist/index.umd.js +23610 -0
  13. package/dist/index.umd.js.map +1 -0
  14. package/dist/website/_astro/DocLayout.BsV7p0dY.css +1 -0
  15. package/dist/website/examples/camera/orthographic/example.html +172 -0
  16. package/dist/website/examples/camera/orthographic/index.html +124 -0
  17. package/dist/website/examples/camera/perspective/example.html +190 -0
  18. package/dist/website/examples/camera/perspective/index.html +142 -0
  19. package/dist/website/examples/camera/tone_mapping/example.html +238 -0
  20. package/dist/website/examples/camera/tone_mapping/index.html +190 -0
  21. package/dist/website/examples/index.html +2 -0
  22. package/dist/website/examples/lights/directional/example.html +447 -0
  23. package/dist/website/examples/lights/directional/index.html +399 -0
  24. package/dist/website/examples/lights/multiple_spot_lights/example.html +356 -0
  25. package/dist/website/examples/lights/multiple_spot_lights/index.html +308 -0
  26. package/dist/website/examples/lights/point/example.html +387 -0
  27. package/dist/website/examples/lights/point/index.html +339 -0
  28. package/dist/website/examples/lights/spot/example.html +416 -0
  29. package/dist/website/examples/lights/spot/index.html +368 -0
  30. package/dist/website/examples/loader/gltf/basic/example.html +129 -0
  31. package/dist/website/examples/loader/gltf/basic/index.html +81 -0
  32. package/dist/website/examples/loader/gltf/material/alpha-blend-mode/example.html +131 -0
  33. package/dist/website/examples/loader/gltf/material/alpha-blend-mode/index.html +83 -0
  34. package/dist/website/examples/loader/gltf/material/flight_helmet/example.html +162 -0
  35. package/dist/website/examples/loader/gltf/material/flight_helmet/index.html +114 -0
  36. package/dist/website/examples/loader/gltf/material/iridescence_lamp/example.html +169 -0
  37. package/dist/website/examples/loader/gltf/material/iridescence_lamp/index.html +121 -0
  38. package/dist/website/examples/loader/objloader/example.html +144 -0
  39. package/dist/website/examples/loader/objloader/index.html +96 -0
  40. package/dist/website/examples/material/cullface/example.html +163 -0
  41. package/dist/website/examples/material/cullface/index.html +115 -0
  42. package/dist/website/examples/material/materials/example.html +175 -0
  43. package/dist/website/examples/material/materials/index.html +127 -0
  44. package/dist/website/examples/material/standard/basic/example.html +212 -0
  45. package/dist/website/examples/material/standard/basic/index.html +164 -0
  46. package/dist/website/examples/material/standard/reflection_refraction/example.html +241 -0
  47. package/dist/website/examples/material/standard/reflection_refraction/index.html +193 -0
  48. package/dist/website/examples/mesh/capsule/example.html +173 -0
  49. package/dist/website/examples/mesh/capsule/index.html +125 -0
  50. package/dist/website/examples/mesh/circle/example.html +173 -0
  51. package/dist/website/examples/mesh/circle/index.html +125 -0
  52. package/dist/website/examples/mesh/cone/example.html +180 -0
  53. package/dist/website/examples/mesh/cone/index.html +132 -0
  54. package/dist/website/examples/mesh/cuboid/example.html +207 -0
  55. package/dist/website/examples/mesh/cuboid/index.html +159 -0
  56. package/dist/website/examples/mesh/cylinder/example.html +195 -0
  57. package/dist/website/examples/mesh/cylinder/index.html +147 -0
  58. package/dist/website/examples/mesh/dodecahedron/example.html +158 -0
  59. package/dist/website/examples/mesh/dodecahedron/index.html +110 -0
  60. package/dist/website/examples/mesh/ellipsoid/example.html +179 -0
  61. package/dist/website/examples/mesh/ellipsoid/index.html +131 -0
  62. package/dist/website/examples/mesh/extrude/example.html +169 -0
  63. package/dist/website/examples/mesh/extrude/index.html +121 -0
  64. package/dist/website/examples/mesh/frustum/example.html +185 -0
  65. package/dist/website/examples/mesh/frustum/index.html +137 -0
  66. package/dist/website/examples/mesh/helix/example.html +184 -0
  67. package/dist/website/examples/mesh/helix/index.html +136 -0
  68. package/dist/website/examples/mesh/icosahedron/example.html +158 -0
  69. package/dist/website/examples/mesh/icosahedron/index.html +110 -0
  70. package/dist/website/examples/mesh/icosphere/example.html +163 -0
  71. package/dist/website/examples/mesh/icosphere/index.html +115 -0
  72. package/dist/website/examples/mesh/lathe/example.html +175 -0
  73. package/dist/website/examples/mesh/lathe/index.html +127 -0
  74. package/dist/website/examples/mesh/meshTopology/example.html +210 -0
  75. package/dist/website/examples/mesh/meshTopology/index.html +162 -0
  76. package/dist/website/examples/mesh/octahedron/example.html +158 -0
  77. package/dist/website/examples/mesh/octahedron/index.html +110 -0
  78. package/dist/website/examples/mesh/plane/example.html +173 -0
  79. package/dist/website/examples/mesh/plane/index.html +125 -0
  80. package/dist/website/examples/mesh/prism/example.html +173 -0
  81. package/dist/website/examples/mesh/prism/index.html +125 -0
  82. package/dist/website/examples/mesh/pyramid/example.html +172 -0
  83. package/dist/website/examples/mesh/pyramid/index.html +124 -0
  84. package/dist/website/examples/mesh/ring/example.html +173 -0
  85. package/dist/website/examples/mesh/ring/index.html +125 -0
  86. package/dist/website/examples/mesh/skinning/example.html +187 -0
  87. package/dist/website/examples/mesh/skinning/index.html +139 -0
  88. package/dist/website/examples/mesh/terrain/example.html +214 -0
  89. package/dist/website/examples/mesh/terrain/index.html +166 -0
  90. package/dist/website/examples/mesh/tetrahedron/example.html +158 -0
  91. package/dist/website/examples/mesh/tetrahedron/index.html +110 -0
  92. package/dist/website/examples/mesh/torus/example.html +173 -0
  93. package/dist/website/examples/mesh/torus/index.html +125 -0
  94. package/dist/website/examples/mesh/torus-knot/example.html +188 -0
  95. package/dist/website/examples/mesh/torus-knot/index.html +140 -0
  96. package/dist/website/examples/mesh/tube/example.html +180 -0
  97. package/dist/website/examples/mesh/tube/index.html +132 -0
  98. package/dist/website/examples/mesh/uvsphere/example.html +169 -0
  99. package/dist/website/examples/mesh/uvsphere/index.html +121 -0
  100. package/dist/website/examples/mesh/wedge/example.html +168 -0
  101. package/dist/website/examples/mesh/wedge/index.html +120 -0
  102. package/dist/website/examples/other/rotatingCube/example.html +142 -0
  103. package/dist/website/examples/other/rotatingCube/index.html +94 -0
  104. package/dist/website/examples/other/rotatingSphere/example.html +144 -0
  105. package/dist/website/examples/other/rotatingSphere/index.html +96 -0
  106. package/dist/website/examples/rendertarget/basic_canvas/example.html +178 -0
  107. package/dist/website/examples/rendertarget/basic_canvas/index.html +130 -0
  108. package/dist/website/examples/rendertarget/depth_texture/example.html +188 -0
  109. package/dist/website/examples/rendertarget/depth_texture/index.html +140 -0
  110. package/dist/website/examples/rendertarget/image_target/example.html +196 -0
  111. package/dist/website/examples/rendertarget/image_target/index.html +148 -0
  112. package/dist/website/examples/rendertarget/multiple_views/example.html +204 -0
  113. package/dist/website/examples/rendertarget/multiple_views/index.html +156 -0
  114. package/dist/website/examples/rendertarget/render_masks/example.html +222 -0
  115. package/dist/website/examples/rendertarget/render_masks/index.html +174 -0
  116. package/dist/website/examples/rendertarget/split_screen/example.html +178 -0
  117. package/dist/website/examples/rendertarget/split_screen/index.html +130 -0
  118. package/dist/website/examples/rendertarget/split_view/example.html +191 -0
  119. package/dist/website/examples/rendertarget/split_view/index.html +143 -0
  120. package/dist/website/examples/skybox/skybox/example.html +162 -0
  121. package/dist/website/examples/skybox/skybox/index.html +114 -0
  122. package/dist/website/examples/texture/arrays/example.html +204 -0
  123. package/dist/website/examples/texture/arrays/index.html +156 -0
  124. package/dist/website/examples/texture/textureWrap/example.html +169 -0
  125. package/dist/website/examples/texture/textureWrap/index.html +121 -0
  126. package/dist/website/examples/transform/propagation/example.html +141 -0
  127. package/dist/website/examples/transform/propagation/index.html +93 -0
  128. package/dist/website/guide/api-map/index.html +82 -0
  129. package/dist/website/guide/camera-and-controls/index.html +62 -0
  130. package/dist/website/guide/first-scene/index.html +119 -0
  131. package/dist/website/guide/index.html +58 -0
  132. package/dist/website/guide/installation/index.html +133 -0
  133. package/dist/website/guide/materials-and-lighting/index.html +90 -0
  134. package/dist/website/guide/plugins-and-render-pipeline/index.html +89 -0
  135. package/dist/website/guide/render-targets-and-views/index.html +95 -0
  136. package/dist/website/guide/scene-graph-and-transforms/index.html +69 -0
  137. package/dist/website/guide/textures-and-assets/index.html +85 -0
  138. package/dist/website/guide/troubleshooting/index.html +39 -0
  139. package/dist/website/images/disappointed.jpg +0 -0
  140. package/dist/website/images/skybox/grimmnight_back.png +0 -0
  141. package/dist/website/images/skybox/grimmnight_bottom.png +0 -0
  142. package/dist/website/images/skybox/grimmnight_front.png +0 -0
  143. package/dist/website/images/skybox/grimmnight_left.png +0 -0
  144. package/dist/website/images/skybox/grimmnight_right.png +0 -0
  145. package/dist/website/images/skybox/grimmnight_top.png +0 -0
  146. package/dist/website/images/skybox/miramar_back.png +0 -0
  147. package/dist/website/images/skybox/miramar_bottom.png +0 -0
  148. package/dist/website/images/skybox/miramar_front.png +0 -0
  149. package/dist/website/images/skybox/miramar_left.png +0 -0
  150. package/dist/website/images/skybox/miramar_right.png +0 -0
  151. package/dist/website/images/skybox/miramar_top.png +0 -0
  152. package/dist/website/images/uv.jpg +0 -0
  153. package/dist/website/index.html +157 -0
  154. package/dist/website/models/glb/AlphaBlendModeTest.glb +0 -0
  155. package/dist/website/models/glb/IridescenceLamp.glb +0 -0
  156. package/dist/website/models/glb/teapot.glb +0 -0
  157. package/dist/website/models/gltf/flight_helmet/FlightHelmet_Materials_GlassPlasticMat_BaseColor.png +0 -0
  158. package/dist/website/models/gltf/flight_helmet/FlightHelmet_Materials_GlassPlasticMat_Normal.png +0 -0
  159. package/dist/website/models/gltf/flight_helmet/FlightHelmet_Materials_GlassPlasticMat_OcclusionRoughMetal.png +0 -0
  160. package/dist/website/models/gltf/flight_helmet/FlightHelmet_Materials_LeatherPartsMat_BaseColor.png +0 -0
  161. package/dist/website/models/gltf/flight_helmet/FlightHelmet_Materials_LeatherPartsMat_Normal.png +0 -0
  162. package/dist/website/models/gltf/flight_helmet/FlightHelmet_Materials_LeatherPartsMat_OcclusionRoughMetal.png +0 -0
  163. package/dist/website/models/gltf/flight_helmet/FlightHelmet_Materials_LensesMat_BaseColor.png +0 -0
  164. package/dist/website/models/gltf/flight_helmet/FlightHelmet_Materials_LensesMat_Normal.png +0 -0
  165. package/dist/website/models/gltf/flight_helmet/FlightHelmet_Materials_LensesMat_OcclusionRoughMetal.png +0 -0
  166. package/dist/website/models/gltf/flight_helmet/FlightHelmet_Materials_MetalPartsMat_BaseColor.png +0 -0
  167. package/dist/website/models/gltf/flight_helmet/FlightHelmet_Materials_MetalPartsMat_Normal.png +0 -0
  168. package/dist/website/models/gltf/flight_helmet/FlightHelmet_Materials_MetalPartsMat_OcclusionRoughMetal.png +0 -0
  169. package/dist/website/models/gltf/flight_helmet/FlightHelmet_Materials_RubberWoodMat_BaseColor.png +0 -0
  170. package/dist/website/models/gltf/flight_helmet/FlightHelmet_Materials_RubberWoodMat_Normal.png +0 -0
  171. package/dist/website/models/gltf/flight_helmet/FlightHelmet_Materials_RubberWoodMat_OcclusionRoughMetal.png +0 -0
  172. package/dist/website/models/gltf/flight_helmet/index.bin +0 -0
  173. package/dist/website/models/gltf/flight_helmet/index.gltf +705 -0
  174. package/dist/website/models/gltf/object.gltf +23 -0
  175. package/dist/website/models/gltf/pirate_girl/index.bin +0 -0
  176. package/dist/website/models/gltf/pirate_girl/index.gltf +2082 -0
  177. package/dist/website/models/obj/pirate_girl/pirate_girl.obj +18459 -0
  178. package/dist/website/models/obj/pirate_girl/pirate_girl.png +0 -0
  179. package/env.d.ts +0 -14
  180. package/examples/camera/orthographic.js +2 -1
  181. package/examples/camera/perspective.js +2 -1
  182. package/examples/camera/tone_mapping.js +187 -0
  183. package/examples/lights/directional.js +2 -3
  184. package/examples/lights/multiple_spot_lights.js +2 -1
  185. package/examples/lights/point.js +2 -3
  186. package/examples/lights/spot.js +2 -3
  187. package/examples/loader/{gltfloader.js → gltf/basic.js} +8 -8
  188. package/examples/loader/gltf/material/alpha-blend-mode.js +80 -0
  189. package/examples/loader/{gltf_material.js → gltf/material/flight_helmet.js} +8 -8
  190. package/examples/loader/gltf/material/iridescence_lamp.js +118 -0
  191. package/examples/loader/objloader.js +9 -11
  192. package/examples/material/cullface.js +8 -7
  193. package/examples/material/materials.js +9 -11
  194. package/examples/material/standard/basic.js +3 -6
  195. package/examples/material/standard/reflection_refraction.js +190 -0
  196. package/examples/mesh/capsule.js +122 -0
  197. package/examples/mesh/circle.js +11 -6
  198. package/examples/mesh/cone.js +129 -0
  199. package/examples/mesh/cuboid.js +11 -6
  200. package/examples/mesh/cylinder.js +11 -6
  201. package/examples/mesh/dodecahedron.js +107 -0
  202. package/examples/mesh/ellipsoid.js +128 -0
  203. package/examples/mesh/extrude.js +118 -0
  204. package/examples/mesh/frustum.js +134 -0
  205. package/examples/mesh/helix.js +133 -0
  206. package/examples/mesh/icosahedron.js +107 -0
  207. package/examples/mesh/icosphere.js +112 -0
  208. package/examples/mesh/lathe.js +124 -0
  209. package/examples/mesh/meshTopology.js +64 -8
  210. package/examples/mesh/octahedron.js +107 -0
  211. package/examples/mesh/plane.js +11 -6
  212. package/examples/mesh/prism.js +122 -0
  213. package/examples/mesh/pyramid.js +121 -0
  214. package/examples/mesh/ring.js +122 -0
  215. package/examples/mesh/skinning.js +8 -8
  216. package/examples/mesh/terrain.js +163 -0
  217. package/examples/mesh/tetrahedron.js +107 -0
  218. package/examples/mesh/torus-knot.js +137 -0
  219. package/examples/mesh/torus.js +122 -0
  220. package/examples/mesh/tube.js +129 -0
  221. package/examples/mesh/uvsphere.js +11 -6
  222. package/examples/mesh/wedge.js +117 -0
  223. package/examples/other/rotatingCube.js +9 -11
  224. package/examples/other/rotatingSphere.js +9 -12
  225. package/examples/rendertarget/basic_canvas.js +5 -8
  226. package/examples/rendertarget/depth_texture.js +18 -11
  227. package/examples/rendertarget/image_target.js +19 -14
  228. package/examples/rendertarget/multiple_views.js +11 -16
  229. package/examples/rendertarget/render_masks.js +3 -5
  230. package/examples/rendertarget/split_screen.js +18 -14
  231. package/examples/rendertarget/split_view.js +12 -9
  232. package/examples/skybox/skybox.js +8 -8
  233. package/examples/texture/arrays.js +9 -12
  234. package/examples/texture/textureWrap.js +8 -8
  235. package/examples/transform/propagation.js +9 -11
  236. package/package.json +18 -12
  237. package/src/caches/cache.js +121 -182
  238. package/src/caches/uniformbuffers.js +42 -53
  239. package/src/constants/texture.js +1 -1
  240. package/src/content.config.js +1 -0
  241. package/src/core/layouts/bindgroup.js +167 -0
  242. package/src/core/layouts/index.js +3 -1
  243. package/src/core/layouts/pipeline.js +165 -0
  244. package/src/core/layouts/uniformbuffer.js +11 -3
  245. package/src/core/resources/gpubuffer.js +23 -2
  246. package/src/core/resources/gpumesh.js +37 -4
  247. package/src/core/resources/gpusampler.js +43 -0
  248. package/src/core/resources/gputexture.js +31 -2
  249. package/src/core/resources/index.js +4 -2
  250. package/src/core/resources/newuniformbuffer.js +58 -0
  251. package/src/core/resources/webglshadermodule.js +58 -0
  252. package/src/core/shader.js +24 -11
  253. package/src/core/webgl/bindgroup.js +200 -42
  254. package/src/core/webgl/descriptors.js +87 -25
  255. package/src/core/webgl/gpuqueue.js +63 -0
  256. package/src/core/webgl/index.js +3 -0
  257. package/src/core/webgl/renderpassencoder.js +703 -16
  258. package/src/core/webgl/renderpipeline.js +38 -1
  259. package/src/core/webgl/utils.js +207 -57
  260. package/src/core/webgl/webglrenderdevice.js +77 -53
  261. package/src/loader/gltf.js +716 -166
  262. package/src/loader/texture.js +69 -16
  263. package/src/loader/utils.js +44 -0
  264. package/src/material/alphablend.js +21 -0
  265. package/src/material/basic.js +15 -1
  266. package/src/material/depth.js +15 -1
  267. package/src/material/index.js +1 -0
  268. package/src/material/lambert.js +15 -1
  269. package/src/material/material.js +49 -7
  270. package/src/material/normal.js +14 -0
  271. package/src/material/phong.js +16 -2
  272. package/src/material/raw.js +21 -2
  273. package/src/material/standard.js +90 -2
  274. package/src/mesh/attribute/attribute.js +2 -2
  275. package/src/mesh/attributedata/separate.js +2 -2
  276. package/src/mesh/builders/capsule.js +47 -0
  277. package/src/mesh/builders/cone.js +29 -0
  278. package/src/mesh/builders/dodecahedron.js +130 -0
  279. package/src/mesh/builders/ellipsoid.js +65 -0
  280. package/src/mesh/builders/extrude.js +136 -0
  281. package/src/mesh/builders/frustum.js +26 -0
  282. package/src/mesh/builders/geometry.js +121 -0
  283. package/src/mesh/builders/helix.js +35 -0
  284. package/src/mesh/builders/icosahedron.js +61 -0
  285. package/src/mesh/builders/icosphere.js +141 -0
  286. package/src/mesh/builders/index.js +22 -1
  287. package/src/mesh/builders/lathe.js +85 -0
  288. package/src/mesh/builders/octahedron.js +43 -0
  289. package/src/mesh/builders/polyhedron.js +121 -0
  290. package/src/mesh/builders/prism.js +19 -0
  291. package/src/mesh/builders/pyramid.js +90 -0
  292. package/src/mesh/builders/ring.js +109 -0
  293. package/src/mesh/builders/surfaces.js +69 -0
  294. package/src/mesh/builders/terrain.js +80 -0
  295. package/src/mesh/builders/tetrahedron.js +37 -0
  296. package/src/mesh/builders/torusknot.js +36 -0
  297. package/src/mesh/builders/tube.js +209 -0
  298. package/src/mesh/builders/utils.js +130 -2
  299. package/src/mesh/builders/wedge.js +22 -0
  300. package/src/mesh/mesh.js +12 -4
  301. package/src/objects/camera/camera.js +104 -1
  302. package/src/objects/light/ambient.js +22 -1
  303. package/src/objects/light/directional.js +23 -1
  304. package/src/objects/light/point.js +25 -1
  305. package/src/objects/light/spot.js +27 -1
  306. package/src/objects/mesh.js +1 -53
  307. package/src/plugins/camera/RenderTarget2DPool.js +94 -0
  308. package/src/plugins/camera/camera.js +14 -6
  309. package/src/plugins/camera/index.js +2 -0
  310. package/src/plugins/camera/nodes/canvasblit.js +153 -0
  311. package/src/plugins/camera/nodes/index.js +4 -1
  312. package/src/plugins/camera/nodes/opaquepass.js +48 -33
  313. package/src/plugins/camera/nodes/tonemapping.js +217 -0
  314. package/src/plugins/camera/nodes/transparentpass.js +87 -0
  315. package/src/plugins/camera/nodes/{cameraview.js → view.js} +27 -1
  316. package/src/plugins/camera/resources/cameracolortargets.js +66 -0
  317. package/src/plugins/camera/resources/canvasblitpipeline.js +6 -0
  318. package/src/plugins/camera/resources/index.js +3 -0
  319. package/src/plugins/camera/resources/tonemappingpipeline.js +6 -0
  320. package/src/plugins/light/light.js +0 -4
  321. package/src/plugins/meshmaterial/meshmaterial.js +433 -170
  322. package/src/plugins/meshmaterial/nodes/meshmaterial.js +39 -6
  323. package/src/plugins/meshmaterial/resources/bonetexture.js +176 -0
  324. package/src/plugins/meshmaterial/resources/environmentmap.js +44 -0
  325. package/src/plugins/meshmaterial/resources/index.js +4 -0
  326. package/src/plugins/meshmaterial/resources/materialuniformbuffers.js +94 -0
  327. package/src/plugins/meshmaterial/resources/meshmaterialbindgroups.js +40 -0
  328. package/src/plugins/shadow/nodes/index.js +3 -3
  329. package/src/plugins/shadow/nodes/{shadowOccluder.js → occluder.js} +13 -19
  330. package/src/plugins/shadow/nodes/opaquePass.js +110 -0
  331. package/src/plugins/shadow/shadow.js +0 -5
  332. package/src/plugins/skeletonhelper/skeletonhelper.js +111 -69
  333. package/src/plugins/skybox/nodes/skybox.js +230 -38
  334. package/src/plugins/skybox/resources/skyboxpipeline.js +10 -0
  335. package/src/plugins/skybox/skybox.js +0 -119
  336. package/src/renderer/core/index.js +135 -21
  337. package/src/renderer/plugin.js +0 -20
  338. package/src/renderer/renderer.js +28 -12
  339. package/src/rendertarget/canvastarget.js +8 -5
  340. package/src/rendertarget/image.js +3 -3
  341. package/src/shader/basicFragment.glsl +12 -4
  342. package/src/shader/basicVertex.glsl +26 -15
  343. package/src/shader/blitFragment.glsl +9 -0
  344. package/src/shader/common/common.glsl +35 -6
  345. package/src/shader/common/index.js +1 -0
  346. package/src/shader/common/tonemap.glsl +118 -0
  347. package/src/shader/debug/skeletonFragment.glsl +0 -2
  348. package/src/shader/debug/skeletonVertex.glsl +1 -3
  349. package/src/shader/depthFragment.glsl +0 -3
  350. package/src/shader/fullscreenVertex.glsl +26 -0
  351. package/src/shader/index.js +3 -0
  352. package/src/shader/lambertFragment.glsl +12 -4
  353. package/src/shader/normalFragment.glsl +0 -3
  354. package/src/shader/phongFragment.glsl +12 -4
  355. package/src/shader/skyboxFragment.glsl +5 -5
  356. package/src/shader/skyboxVertex.glsl +5 -4
  357. package/src/shader/standardFragment.glsl +74 -17
  358. package/src/shader/tonemappingFragment.glsl +37 -0
  359. package/src/texture/sampler.js +101 -21
  360. package/src/texture/texture.js +252 -48
  361. package/src/utils/index.js +15 -1
  362. package/{examples/addons → src/utils}/rendergraph_gui.js +5 -2
  363. package/examples/mesh/geometries.js +0 -108
  364. package/scripts/stage-chorama.mjs +0 -29
  365. package/src/core/resources/framebuffer.js +0 -127
  366. package/src/plugins/shadow/nodes/shadowOpaquePass.js +0 -73
  367. package/website/config/index.ts +0 -1
  368. package/website/config/navigation.ts +0 -53
  369. package/website/content.config.ts +0 -92
  370. package/website/layouts/DocLayout.astro +0 -501
  371. package/website/layouts/Example.astro +0 -91
  372. package/website/pages/examples/[...slug].astro +0 -77
  373. package/website/pages/examples/index.astro +0 -98
  374. package/website/pages/examples/samples/[...slug].astro +0 -17
  375. package/website/pages/guide/[slug].astro +0 -30
  376. package/website/pages/guide/index.astro +0 -21
  377. package/website/pages/index.astro +0 -9
  378. package/website/plugins/remark-link-base.js +0 -23
  379. package/website/utils/url.ts +0 -30
  380. /package/src/plugins/shadow/nodes/{shadow.js → view.js} +0 -0
@@ -0,0 +1,140 @@
1
+ <!DOCTYPE html> <html lang="en"> <head><meta charset="UTF-8"><meta name="viewport" content="width=device-width"><meta name="generator" content="Astro v7.2.2"><title>Torus Knot | chorama</title><style>.category-section[data-astro-cid-mzi2nk5r]+.category-section[data-astro-cid-mzi2nk5r]{margin-top:2rem}.category-section[data-astro-cid-mzi2nk5r] h2[data-astro-cid-mzi2nk5r]{margin-bottom:.75rem}.examples-grid[data-astro-cid-mzi2nk5r]{grid-template-columns:repeat(auto-fill,minmax(220px,1fr));gap:1rem;margin-top:1.5rem;display:grid}.example-card[data-astro-cid-mzi2nk5r]{aspect-ratio:4/3;border:1px solid var(--border);background:var(--surface-2);border-radius:0;text-decoration:none;display:block;position:relative;overflow:hidden}.example-card[data-astro-cid-mzi2nk5r] img[data-astro-cid-mzi2nk5r]{object-fit:cover;width:100%;height:100%;display:block}.example-card[data-astro-cid-mzi2nk5r] span[data-astro-cid-mzi2nk5r]{text-align:center;color:#fff;background:linear-gradient(#00000026,#000c);padding:.55rem .75rem;font-weight:700;position:absolute;bottom:0;left:0;right:0}.example-frame[data-astro-cid-mxkslj3q]{width:100%;margin-bottom:1.25rem;position:relative}.example-link[data-astro-cid-mxkslj3q]{z-index:1;color:var(--accent);background:#00000059;border-radius:0;padding:.2rem .5rem;font-weight:600;text-decoration:underline;position:absolute;top:7rem;left:50%;transform:translate(-50%)}.example-link[data-astro-cid-mxkslj3q]:hover{color:var(--accent-secondary)}.source-code[data-astro-cid-mxkslj3q]{outline:1px solid var(--border);outline-offset:0;border-radius:0;overflow:hidden}.example-preview[data-astro-cid-mxkslj3q]{border:1px solid var(--border);background:#fff;border-radius:0;width:100%;height:560px;margin:0 0 1.25rem;display:block}.source-code[data-astro-cid-mxkslj3q] .astro-code{border:0!important;border-radius:0!important}.source-code[data-astro-cid-mxkslj3q] pre{padding:10px;margin:0!important}
2
+ </style><link rel="stylesheet" href="/_astro/DocLayout.BsV7p0dY.css"></head> <body> <div class="shell"> <button class="menu-toggle" id="menu-toggle" type="button" aria-label="Toggle menu" aria-expanded="false" aria-controls="site-sidebar"> <span></span> <span></span> <span></span> </button> <aside id="site-sidebar" aria-label="Sidebar navigation"> <p class="tabs-title">Navigation</p> <div><ul class="tabs"><li class="tab-item"><details class="tab-group"><summary class="tab-toggle"><span>Introduction</span><span class="chevron">›</span></summary><ul class="tabs"><li class="tab-item"><a href="/#features">Features</a></li><li class="tab-item"><a href="/#who-this-is-for">Who This Is For</a></li><li class="tab-item"><a href="/#getting-started">Getting Started</a><ul class="subtabs" hidden><li class="tab-item"><a href="/#requirements">Requirements</a></li><li class="tab-item"><a href="/#install-dependencies">Install dependencies</a></li><li class="tab-item"><a href="/#build-library-bundles">Build library bundles</a></li><li class="tab-item"><a href="/#run-demos">Run demos</a></li></ul></li><li class="tab-item"><a href="/#core-usage-flow">Core Usage Flow</a></li></ul></details></li><li class="tab-item"><details class="tab-group"><summary class="tab-toggle"><span>Guide</span><span class="chevron">›</span></summary><ul class="tabs"><li class="tab-item"><a href="/guide">Overview</a><ul class="subtabs" hidden><li class="tab-item"><a href="/guide#who-this-guide-is-for">Who This Guide Is For</a></li><li class="tab-item"><a href="/guide#how-to-use-this-guide">How To Use This Guide</a></li><li class="tab-item"><a href="/guide#reading-order">Reading Order</a></li><li class="tab-item"><a href="/guide#core-flow">Core Flow</a></li></ul></li><li class="tab-item"><a href="/guide/installation">Installation</a><ul class="subtabs" hidden><li class="tab-item"><a href="/guide/installation#npm">NPM</a></li><li class="tab-item"><a href="/guide/installation#cdn">CDN</a></li><li class="tab-item"><a href="/guide/installation#manual-installation">Manual Installation</a><ul class="subtabs" hidden><li class="tab-item"><a href="/guide/installation#1-requirements">Requirements</a></li><li class="tab-item"><a href="/guide/installation#2-clone-the-repository-and-install-dependencies">Clone the repository and install dependencies</a></li><li class="tab-item"><a href="/guide/installation#3-build-the-library-files">Build the library files</a></li><li class="tab-item"><a href="/guide/installation#4-copy-files-to-your-project">Copy files to your project</a></li><li class="tab-item"><a href="/guide/installation#5-use-in-your-project">Use in your project</a><ul class="subtabs" hidden><li class="tab-item"><a href="/guide/installation#esm-recommended">ESM (recommended)</a><ul class="subtabs" hidden><li class="tab-item"><a href="/guide/installation#vite-viteconfigjs">Vite (vite.config.js)</a></li><li class="tab-item"><a href="/guide/installation#webpack-webpackconfigjs">Webpack (webpack.config.js)</a></li></ul></li><li class="tab-item"><a href="/guide/installation#plain-html-with-browser-import-maps-no-bundler">Plain HTML with browser import maps (no bundler)</a></li><li class="tab-item"><a href="/guide/installation#plain-html-with-script-tag-umd">Plain HTML with script tag (UMD)</a></li></ul></li></ul></li></ul></li><li class="tab-item"><a href="/guide/first-scene">First Scene</a><ul class="subtabs" hidden><li class="tab-item"><a href="/guide/first-scene#what-you-will-build">What You Will Build</a></li><li class="tab-item"><a href="/guide/first-scene#before-you-start">Before You Start</a></li><li class="tab-item"><a href="/guide/first-scene#build-your-first-scene">Build Your first scene</a><ul class="subtabs" hidden><li class="tab-item"><a href="/guide/first-scene#step-1-import-what-you-need">Step 1: Import what you need</a></li><li class="tab-item"><a href="/guide/first-scene#step-2-create-and-mount-a-canvas">Step 2: Create and mount a canvas</a></li><li class="tab-item"><a href="/guide/first-scene#step-3-create-device-and-render-target">Step 3: Create device and render target</a></li><li class="tab-item"><a href="/guide/first-scene#step-4-create-renderer-and-required-plugins">Step 4: Create renderer and required plugins</a></li><li class="tab-item"><a href="/guide/first-scene#step-5-create-and-position-a-camera">Step 5: Create and position a camera</a></li><li class="tab-item"><a href="/guide/first-scene#step-6-create-a-cube-object">Step 6: Create a cube object</a></li><li class="tab-item"><a href="/guide/first-scene#step-7-define-per-frame-rotation">Step 7: Define per-frame rotation</a></li><li class="tab-item"><a href="/guide/first-scene#step-8-add-resize-handling">Step 8: Add resize handling</a></li><li class="tab-item"><a href="/guide/first-scene#step-9-start-the-render-loop">Step 9: Start the render loop</a></li></ul></li><li class="tab-item"><a href="/guide/first-scene#what-you-can-try-next">What You Can Try Next</a></li><li class="tab-item"><a href="/guide/first-scene#reference-example">Reference Example</a></li></ul></li><li class="tab-item"><a href="/guide/camera-and-controls">Camera and Controls</a><ul class="subtabs" hidden><li class="tab-item"><a href="/guide/camera-and-controls#what-you-will-add">What You Will Add</a></li><li class="tab-item"><a href="/guide/camera-and-controls#step-1-import-camera-apis">Step 1: Import Camera APIs</a></li><li class="tab-item"><a href="/guide/camera-and-controls#step-2-create-a-camera">Step 2: Create a Camera</a></li><li class="tab-item"><a href="/guide/camera-and-controls#step-3-configure-perspective-projection">Step 3: Configure Perspective Projection</a></li><li class="tab-item"><a href="/guide/camera-and-controls#step-4-add-orbit-controls">Step 4: Add Orbit Controls</a></li><li class="tab-item"><a href="/guide/camera-and-controls#step-5-update-controls-in-the-frame-loop">Step 5: Update Controls in the Frame Loop</a></li><li class="tab-item"><a href="/guide/camera-and-controls#switch-to-orthographic-projection">Switch to Orthographic Projection</a></li><li class="tab-item"><a href="/guide/camera-and-controls#reference-examples">Reference Examples</a></li></ul></li><li class="tab-item"><a href="/guide/materials-and-lighting">Materials and Lighting</a><ul class="subtabs" hidden><li class="tab-item"><a href="/guide/materials-and-lighting#what-you-will-add">What You Will Add</a></li><li class="tab-item"><a href="/guide/materials-and-lighting#step-1-import-material-and-light-apis">Step 1: Import Material and Light APIs</a></li><li class="tab-item"><a href="/guide/materials-and-lighting#step-2-pick-a-material-model">Step 2: Pick a Material Model</a></li><li class="tab-item"><a href="/guide/materials-and-lighting#step-3-apply-the-material-to-your-mesh-object">Step 3: Apply the Material to Your Mesh Object</a></li><li class="tab-item"><a href="/guide/materials-and-lighting#step-4-enable-the-lighting-pipeline-in-the-renderer">Step 4: Enable the Lighting Pipeline in the Renderer</a></li><li class="tab-item"><a href="/guide/materials-and-lighting#step-5-add-ambient-light">Step 5: Add Ambient Light</a></li><li class="tab-item"><a href="/guide/materials-and-lighting#step-6-add-a-directional-light">Step 6: Add a Directional Light</a></li><li class="tab-item"><a href="/guide/materials-and-lighting#step-7-render-with-object-lights-and-camera">Step 7: Render with Object, Lights, and Camera</a></li><li class="tab-item"><a href="/guide/materials-and-lighting#step-8-animate-and-keep-scene-responsive">Step 8: Animate and Keep Scene Responsive</a></li><li class="tab-item"><a href="/guide/materials-and-lighting#switching-between-material-types">Switching Between Material Types</a></li><li class="tab-item"><a href="/guide/materials-and-lighting#reference-examples">Reference Examples</a></li></ul></li><li class="tab-item"><a href="/guide/textures-and-assets">What You Will Add</a><ul class="subtabs" hidden><li class="tab-item"><a href="/guide/textures-and-assets#what-you-will-add">What You Will Add</a></li><li class="tab-item"><a href="/guide/textures-and-assets#step-1-import-loaders">Step 1: Import Loaders</a></li><li class="tab-item"><a href="/guide/textures-and-assets#step-2-load-a-texture">Step 2: Load a Texture</a></li><li class="tab-item"><a href="/guide/textures-and-assets#step-3-apply-the-texture-to-a-material">Step 3: Apply the Texture to a Material</a></li><li class="tab-item"><a href="/guide/textures-and-assets#step-4-load-an-obj-model">Step 4: Load an OBJ Model</a></li><li class="tab-item"><a href="/guide/textures-and-assets#step-5-optionally-patch-imported-obj-materials">Step 5: Optionally Patch Imported OBJ Materials</a></li><li class="tab-item"><a href="/guide/textures-and-assets#step-6-load-a-gltf-scene">Step 6: Load a glTF Scene</a></li><li class="tab-item"><a href="/guide/textures-and-assets#step-7-render-streaming-assets-safely">Step 7: Render Streaming Assets Safely</a></li><li class="tab-item"><a href="/guide/textures-and-assets#path-rules-that-prevent-most-loading-errors">Path Rules That Prevent Most Loading Errors</a></li><li class="tab-item"><a href="/guide/textures-and-assets#reference-examples">Reference Examples</a></li></ul></li><li class="tab-item"><a href="/guide/render-targets-and-views">Render Targets and Views</a><ul class="subtabs" hidden><li class="tab-item"><a href="/guide/render-targets-and-views#what-you-will-add">What You Will Add</a></li><li class="tab-item"><a href="/guide/render-targets-and-views#step-1-import-render-target-apis">Step 1: Import Render Target APIs</a></li><li class="tab-item"><a href="/guide/render-targets-and-views#step-2-create-a-canvas-target-most-common">Step 2: Create a Canvas Target (Most Common)</a></li><li class="tab-item"><a href="/guide/render-targets-and-views#step-3-render-a-scene-to-the-canvas-target">Step 3: Render a Scene to the Canvas Target</a></li><li class="tab-item"><a href="/guide/render-targets-and-views#step-4-create-an-offscreen-image-target">Step 4: Create an Offscreen Image Target</a></li><li class="tab-item"><a href="/guide/render-targets-and-views#step-5-render-offscreen-with-a-dedicated-camera">Step 5: Render Offscreen with a Dedicated Camera</a></li><li class="tab-item"><a href="/guide/render-targets-and-views#step-6-use-offscreen-output-as-a-texture">Step 6: Use Offscreen Output as a Texture</a></li><li class="tab-item"><a href="/guide/render-targets-and-views#step-7-split-canvas-with-viewports">Step 7: Split Canvas with Viewports</a></li><li class="tab-item"><a href="/guide/render-targets-and-views#step-8-bind-cameras-to-each-view-and-render-once">Step 8: Bind Cameras to Each View and Render Once</a></li><li class="tab-item"><a href="/guide/render-targets-and-views#step-9-use-scissor-for-hard-splitmasking">Step 9: Use Scissor for Hard Split/Masking</a></li><li class="tab-item"><a href="/guide/render-targets-and-views#resize-rule-for-multi-view-scenes">Resize Rule for Multi-View Scenes</a></li><li class="tab-item"><a href="/guide/render-targets-and-views#reference-examples">Reference Examples</a></li></ul></li><li class="tab-item"><a href="/guide/scene-graph-and-transforms">Scene Graph and Transforms</a><ul class="subtabs" hidden><li class="tab-item"><a href="/guide/scene-graph-and-transforms#what-you-will-add">What You Will Add</a></li><li class="tab-item"><a href="/guide/scene-graph-and-transforms#step-1-import-what-you-need">Step 1: Import What You Need</a></li><li class="tab-item"><a href="/guide/scene-graph-and-transforms#step-2-create-parent-and-child-nodes">Step 2: Create Parent and Child Nodes</a></li><li class="tab-item"><a href="/guide/scene-graph-and-transforms#step-3-build-the-hierarchy">Step 3: Build the Hierarchy</a></li><li class="tab-item"><a href="/guide/scene-graph-and-transforms#step-4-set-local-transforms">Step 4: Set Local Transforms</a></li><li class="tab-item"><a href="/guide/scene-graph-and-transforms#step-5-animate-the-parent">Step 5: Animate the Parent</a></li><li class="tab-item"><a href="/guide/scene-graph-and-transforms#step-6-render-the-hierarchy">Step 6: Render the Hierarchy</a></li><li class="tab-item"><a href="/guide/scene-graph-and-transforms#traverse-the-graph-for-bulk-operations">Traverse the Graph for Bulk Operations</a></li><li class="tab-item"><a href="/guide/scene-graph-and-transforms#reparent-safely">Reparent Safely</a></li><li class="tab-item"><a href="/guide/scene-graph-and-transforms#reference-examples">Reference Examples</a></li></ul></li><li class="tab-item"><a href="/guide/plugins-and-render-pipeline">Plugins and Render Pipeline</a><ul class="subtabs" hidden><li class="tab-item"><a href="/guide/plugins-and-render-pipeline#what-you-will-add">What You Will Add</a></li><li class="tab-item"><a href="/guide/plugins-and-render-pipeline#step-1-import-core-renderer-and-plugins">Step 1: Import Core Renderer and Plugins</a></li><li class="tab-item"><a href="/guide/plugins-and-render-pipeline#step-2-build-a-minimal-plugin-stack">Step 2: Build a Minimal Plugin Stack</a></li><li class="tab-item"><a href="/guide/plugins-and-render-pipeline#step-3-add-lighting-support">Step 3: Add Lighting Support</a></li><li class="tab-item"><a href="/guide/plugins-and-render-pipeline#step-4-add-shadows-and-skybox-when-needed">Step 4: Add Shadows and Skybox When Needed</a></li><li class="tab-item"><a href="/guide/plugins-and-render-pipeline#step-5-render-as-usual">Step 5: Render as Usual</a></li><li class="tab-item"><a href="/guide/plugins-and-render-pipeline#what-happens-during-render">What Happens During render()</a></li><li class="tab-item"><a href="/guide/plugins-and-render-pipeline#plugin-roles">Plugin Roles</a></li><li class="tab-item"><a href="/guide/plugins-and-render-pipeline#create-a-custom-plugin">Create a Custom Plugin</a></li></ul></li><li class="tab-item"><a href="/guide/api-map">API Map</a><ul class="subtabs" hidden><li class="tab-item"><a href="/guide/api-map#quick-import-example">Quick Import Example</a></li><li class="tab-item"><a href="/guide/api-map#rendering-core">Rendering Core</a></li><li class="tab-item"><a href="/guide/api-map#scene-objects">Scene Objects</a></li><li class="tab-item"><a href="/guide/api-map#materials">Materials</a></li><li class="tab-item"><a href="/guide/api-map#lighting">Lighting</a></li><li class="tab-item"><a href="/guide/api-map#geometry-and-mesh">Geometry and Mesh</a></li><li class="tab-item"><a href="/guide/api-map#camera-and-control">Camera and Control</a></li><li class="tab-item"><a href="/guide/api-map#assets-and-textures">Assets and Textures</a></li><li class="tab-item"><a href="/guide/api-map#render-targets">Render Targets</a></li><li class="tab-item"><a href="/guide/api-map#plugins">Plugins</a></li></ul></li><li class="tab-item"><a href="/guide/troubleshooting">Troubleshooting</a><ul class="subtabs" hidden><li class="tab-item"><a href="/guide/troubleshooting#blank-canvas">Blank Canvas</a></li><li class="tab-item"><a href="/guide/troubleshooting#object-is-black-or-unlit">Object Is Black or Unlit</a></li><li class="tab-item"><a href="/guide/troubleshooting#distorted-aspect-ratio">Distorted Aspect Ratio</a></li><li class="tab-item"><a href="/guide/troubleshooting#missing-textures-or-models">Missing Textures or Models</a></li><li class="tab-item"><a href="/guide/troubleshooting#shadows-not-visible">Shadows Not Visible</a></li></ul></li></ul></details></li><li class="tab-item"><a href="/examples">Examples</a></li></ul></div> </aside> <main> <div class="example-frame" data-astro-cid-mxkslj3q> <a href="/examples" data-astro-cid-mxkslj3q>← Back to examples</a> <h1 style="text-align:center" data-astro-cid-mxkslj3q>Torus Knot</h1> <a class="example-link" href="/examples/mesh/torus-knot/example.html" target="_blank" rel="noreferrer" data-astro-cid-mxkslj3q>
3
+ Open as a stand-alone example
4
+ </a> <iframe class="example-preview" title="Torus Knot preview" src="/examples/mesh/torus-knot/example.html" loading="lazy" data-astro-cid-mxkslj3q></iframe> </div> <p data-astro-cid-mxkslj3q>Source file: /examples/mesh/torus-knot.js</p> <div class="source-code" data-astro-cid-mxkslj3q> <pre class="astro-code github-dark" style="background-color:#24292e;color:#e1e4e8; overflow-x: auto;" tabindex="0" data-astro-cid-mxkslj3q data-language="js"><code><span class="line"><span style="color:#F97583">import</span><span style="color:#E1E4E8"> Stats </span><span style="color:#F97583">from</span><span style="color:#9ECBFF"> "stats.js"</span></span>
5
+ <span class="line"><span style="color:#F97583">import</span><span style="color:#E1E4E8"> { GUI } </span><span style="color:#F97583">from</span><span style="color:#9ECBFF"> "dat.gui"</span></span>
6
+ <span class="line"><span style="color:#F97583">import</span><span style="color:#E1E4E8"> {</span></span>
7
+ <span class="line"><span style="color:#E1E4E8"> BasicMaterial,</span></span>
8
+ <span class="line"><span style="color:#E1E4E8"> Camera,</span></span>
9
+ <span class="line"><span style="color:#E1E4E8"> CameraPlugin,</span></span>
10
+ <span class="line"><span style="color:#E1E4E8"> MeshMaterial3D,</span></span>
11
+ <span class="line"><span style="color:#E1E4E8"> MeshMaterialPlugin,</span></span>
12
+ <span class="line"><span style="color:#E1E4E8"> PerspectiveProjection,</span></span>
13
+ <span class="line"><span style="color:#E1E4E8"> OrbitCameraControls,</span></span>
14
+ <span class="line"><span style="color:#E1E4E8"> TextureLoader,</span></span>
15
+ <span class="line"><span style="color:#E1E4E8"> TorusKnotMeshBuilder,</span></span>
16
+ <span class="line"><span style="color:#E1E4E8"> WireframeBuilder,</span></span>
17
+ <span class="line"><span style="color:#E1E4E8"> WebGLRenderDevice,</span></span>
18
+ <span class="line"><span style="color:#E1E4E8"> WebGLRenderer,</span></span>
19
+ <span class="line"><span style="color:#E1E4E8"> CanvasTarget</span></span>
20
+ <span class="line"><span style="color:#E1E4E8">} </span><span style="color:#F97583">from</span><span style="color:#9ECBFF"> "chorama"</span></span>
21
+ <span class="line"></span>
22
+ <span class="line"><span style="color:#F97583">const</span><span style="color:#79B8FF"> canvas</span><span style="color:#F97583"> =</span><span style="color:#E1E4E8"> document.</span><span style="color:#B392F0">createElement</span><span style="color:#E1E4E8">(</span><span style="color:#9ECBFF">"canvas"</span><span style="color:#E1E4E8">)</span></span>
23
+ <span class="line"><span style="color:#F97583">const</span><span style="color:#79B8FF"> renderTarget</span><span style="color:#F97583"> =</span><span style="color:#F97583"> new</span><span style="color:#B392F0"> CanvasTarget</span><span style="color:#E1E4E8">(canvas)</span></span>
24
+ <span class="line"><span style="color:#F97583">const</span><span style="color:#79B8FF"> renderDevice</span><span style="color:#F97583"> =</span><span style="color:#F97583"> new</span><span style="color:#B392F0"> WebGLRenderDevice</span><span style="color:#E1E4E8">(canvas, {</span></span>
25
+ <span class="line"><span style="color:#E1E4E8"> depth: </span><span style="color:#79B8FF">true</span></span>
26
+ <span class="line"><span style="color:#E1E4E8">})</span></span>
27
+ <span class="line"><span style="color:#F97583">const</span><span style="color:#79B8FF"> renderer</span><span style="color:#F97583"> =</span><span style="color:#F97583"> new</span><span style="color:#B392F0"> WebGLRenderer</span><span style="color:#E1E4E8">({</span></span>
28
+ <span class="line"><span style="color:#E1E4E8"> plugins: [</span></span>
29
+ <span class="line"><span style="color:#F97583"> new</span><span style="color:#B392F0"> CameraPlugin</span><span style="color:#E1E4E8">(),</span></span>
30
+ <span class="line"><span style="color:#F97583"> new</span><span style="color:#B392F0"> MeshMaterialPlugin</span><span style="color:#E1E4E8">(),</span></span>
31
+ <span class="line"><span style="color:#E1E4E8"> ]</span></span>
32
+ <span class="line"><span style="color:#E1E4E8">})</span></span>
33
+ <span class="line"><span style="color:#F97583">const</span><span style="color:#79B8FF"> camera</span><span style="color:#F97583"> =</span><span style="color:#F97583"> new</span><span style="color:#B392F0"> Camera</span><span style="color:#E1E4E8">(renderTarget)</span></span>
34
+ <span class="line"><span style="color:#F97583">const</span><span style="color:#79B8FF"> cameraControls</span><span style="color:#F97583"> =</span><span style="color:#F97583"> new</span><span style="color:#B392F0"> OrbitCameraControls</span><span style="color:#E1E4E8">(camera, canvas)</span></span>
35
+ <span class="line"></span>
36
+ <span class="line"><span style="color:#F97583">const</span><span style="color:#79B8FF"> textureLoader</span><span style="color:#F97583"> =</span><span style="color:#F97583"> new</span><span style="color:#B392F0"> TextureLoader</span><span style="color:#E1E4E8">()</span></span>
37
+ <span class="line"><span style="color:#F97583">const</span><span style="color:#79B8FF"> texture</span><span style="color:#F97583"> =</span><span style="color:#E1E4E8"> textureLoader.</span><span style="color:#B392F0">load</span><span style="color:#E1E4E8">({</span></span>
38
+ <span class="line"><span style="color:#E1E4E8"> paths: [</span><span style="color:#9ECBFF">"/images/uv.jpg"</span><span style="color:#E1E4E8">],</span></span>
39
+ <span class="line"><span style="color:#E1E4E8"> flipY: </span><span style="color:#79B8FF">true</span></span>
40
+ <span class="line"><span style="color:#E1E4E8">})</span></span>
41
+ <span class="line"><span style="color:#F97583">const</span><span style="color:#79B8FF"> material</span><span style="color:#F97583"> =</span><span style="color:#F97583"> new</span><span style="color:#B392F0"> BasicMaterial</span><span style="color:#E1E4E8">({</span></span>
42
+ <span class="line"><span style="color:#E1E4E8"> mainTexture: texture</span></span>
43
+ <span class="line"><span style="color:#E1E4E8">})</span></span>
44
+ <span class="line"></span>
45
+ <span class="line"><span style="color:#F97583">const</span><span style="color:#79B8FF"> meshBuilder</span><span style="color:#F97583"> =</span><span style="color:#F97583"> new</span><span style="color:#B392F0"> TorusKnotMeshBuilder</span><span style="color:#E1E4E8">()</span></span>
46
+ <span class="line"><span style="color:#E1E4E8">meshBuilder.radius </span><span style="color:#F97583">=</span><span style="color:#79B8FF"> 0.52</span></span>
47
+ <span class="line"><span style="color:#E1E4E8">meshBuilder.knotRadius </span><span style="color:#F97583">=</span><span style="color:#79B8FF"> 0.18</span></span>
48
+ <span class="line"><span style="color:#E1E4E8">meshBuilder.tubeRadius </span><span style="color:#F97583">=</span><span style="color:#79B8FF"> 0.055</span></span>
49
+ <span class="line"><span style="color:#E1E4E8">meshBuilder.p </span><span style="color:#F97583">=</span><span style="color:#79B8FF"> 2</span></span>
50
+ <span class="line"><span style="color:#E1E4E8">meshBuilder.q </span><span style="color:#F97583">=</span><span style="color:#79B8FF"> 3</span></span>
51
+ <span class="line"><span style="color:#E1E4E8">meshBuilder.radialSegments </span><span style="color:#F97583">=</span><span style="color:#79B8FF"> 10</span></span>
52
+ <span class="line"><span style="color:#E1E4E8">meshBuilder.pathSegments </span><span style="color:#F97583">=</span><span style="color:#79B8FF"> 240</span></span>
53
+ <span class="line"><span style="color:#F97583">const</span><span style="color:#79B8FF"> object</span><span style="color:#F97583"> =</span><span style="color:#F97583"> new</span><span style="color:#B392F0"> MeshMaterial3D</span><span style="color:#E1E4E8">(meshBuilder.</span><span style="color:#B392F0">build</span><span style="color:#E1E4E8">(), material)</span></span>
54
+ <span class="line"></span>
55
+ <span class="line"><span style="color:#E1E4E8">camera.transform.position.</span><span style="color:#B392F0">set</span><span style="color:#E1E4E8">(</span><span style="color:#79B8FF">0</span><span style="color:#E1E4E8">, </span><span style="color:#79B8FF">0.35</span><span style="color:#E1E4E8">, </span><span style="color:#79B8FF">8</span><span style="color:#E1E4E8">)</span></span>
56
+ <span class="line"><span style="color:#F97583">if</span><span style="color:#E1E4E8"> (camera.projection </span><span style="color:#F97583">instanceof</span><span style="color:#B392F0"> PerspectiveProjection</span><span style="color:#E1E4E8">) {</span></span>
57
+ <span class="line"><span style="color:#E1E4E8"> camera.projection.fov </span><span style="color:#F97583">=</span><span style="color:#E1E4E8"> Math.</span><span style="color:#79B8FF">PI</span><span style="color:#F97583"> /</span><span style="color:#79B8FF"> 180</span><span style="color:#F97583"> *</span><span style="color:#79B8FF"> 100</span></span>
58
+ <span class="line"><span style="color:#E1E4E8"> camera.projection.aspect </span><span style="color:#F97583">=</span><span style="color:#E1E4E8"> innerWidth </span><span style="color:#F97583">/</span><span style="color:#E1E4E8"> innerHeight</span></span>
59
+ <span class="line"><span style="color:#E1E4E8">}</span></span>
60
+ <span class="line"></span>
61
+ <span class="line"><span style="color:#E1E4E8">document.body.</span><span style="color:#B392F0">append</span><span style="color:#E1E4E8">(canvas)</span></span>
62
+ <span class="line"><span style="color:#B392F0">addEventListener</span><span style="color:#E1E4E8">(</span><span style="color:#9ECBFF">"resize"</span><span style="color:#E1E4E8">, updateView)</span></span>
63
+ <span class="line"><span style="color:#B392F0">updateView</span><span style="color:#E1E4E8">()</span></span>
64
+ <span class="line"><span style="color:#B392F0">requestAnimationFrame</span><span style="color:#E1E4E8">(update)</span></span>
65
+ <span class="line"></span>
66
+ <span class="line"><span style="color:#6A737D">// demo-only GUI controls</span></span>
67
+ <span class="line"><span style="color:#F97583">const</span><span style="color:#79B8FF"> controls</span><span style="color:#F97583"> =</span><span style="color:#F97583"> new</span><span style="color:#B392F0"> GUI</span><span style="color:#E1E4E8">()</span></span>
68
+ <span class="line"><span style="color:#F97583">const</span><span style="color:#79B8FF"> settings</span><span style="color:#F97583"> =</span><span style="color:#E1E4E8"> {</span></span>
69
+ <span class="line"><span style="color:#E1E4E8"> wireframe: </span><span style="color:#79B8FF">false</span></span>
70
+ <span class="line"><span style="color:#E1E4E8">}</span></span>
71
+ <span class="line"><span style="color:#F97583">const</span><span style="color:#79B8FF"> buildOptionsFolder</span><span style="color:#F97583"> =</span><span style="color:#E1E4E8"> controls.</span><span style="color:#B392F0">addFolder</span><span style="color:#E1E4E8">(</span><span style="color:#9ECBFF">"Settings"</span><span style="color:#E1E4E8">)</span></span>
72
+ <span class="line"><span style="color:#E1E4E8">buildOptionsFolder</span></span>
73
+ <span class="line"><span style="color:#E1E4E8"> .</span><span style="color:#B392F0">add</span><span style="color:#E1E4E8">(meshBuilder, </span><span style="color:#9ECBFF">"radius"</span><span style="color:#E1E4E8">, </span><span style="color:#79B8FF">0</span><span style="color:#E1E4E8">, </span><span style="color:#79B8FF">2</span><span style="color:#E1E4E8">, </span><span style="color:#79B8FF">0.01</span><span style="color:#E1E4E8">)</span></span>
74
+ <span class="line"><span style="color:#E1E4E8"> .</span><span style="color:#B392F0">name</span><span style="color:#E1E4E8">(</span><span style="color:#9ECBFF">"Radius"</span><span style="color:#E1E4E8">)</span></span>
75
+ <span class="line"><span style="color:#E1E4E8"> .</span><span style="color:#B392F0">onFinishChange</span><span style="color:#E1E4E8">(buildMesh)</span></span>
76
+ <span class="line"><span style="color:#E1E4E8">buildOptionsFolder</span></span>
77
+ <span class="line"><span style="color:#E1E4E8"> .</span><span style="color:#B392F0">add</span><span style="color:#E1E4E8">(meshBuilder, </span><span style="color:#9ECBFF">"knotRadius"</span><span style="color:#E1E4E8">, </span><span style="color:#79B8FF">0</span><span style="color:#E1E4E8">, </span><span style="color:#79B8FF">1</span><span style="color:#E1E4E8">, </span><span style="color:#79B8FF">0.001</span><span style="color:#E1E4E8">)</span></span>
78
+ <span class="line"><span style="color:#E1E4E8"> .</span><span style="color:#B392F0">name</span><span style="color:#E1E4E8">(</span><span style="color:#9ECBFF">"Knot Radius"</span><span style="color:#E1E4E8">)</span></span>
79
+ <span class="line"><span style="color:#E1E4E8"> .</span><span style="color:#B392F0">onFinishChange</span><span style="color:#E1E4E8">(buildMesh)</span></span>
80
+ <span class="line"><span style="color:#E1E4E8">buildOptionsFolder</span></span>
81
+ <span class="line"><span style="color:#E1E4E8"> .</span><span style="color:#B392F0">add</span><span style="color:#E1E4E8">(meshBuilder, </span><span style="color:#9ECBFF">"tubeRadius"</span><span style="color:#E1E4E8">, </span><span style="color:#79B8FF">0</span><span style="color:#E1E4E8">, </span><span style="color:#79B8FF">0.5</span><span style="color:#E1E4E8">, </span><span style="color:#79B8FF">0.001</span><span style="color:#E1E4E8">)</span></span>
82
+ <span class="line"><span style="color:#E1E4E8"> .</span><span style="color:#B392F0">name</span><span style="color:#E1E4E8">(</span><span style="color:#9ECBFF">"Tube Radius"</span><span style="color:#E1E4E8">)</span></span>
83
+ <span class="line"><span style="color:#E1E4E8"> .</span><span style="color:#B392F0">onFinishChange</span><span style="color:#E1E4E8">(buildMesh)</span></span>
84
+ <span class="line"><span style="color:#E1E4E8">buildOptionsFolder</span></span>
85
+ <span class="line"><span style="color:#E1E4E8"> .</span><span style="color:#B392F0">add</span><span style="color:#E1E4E8">(meshBuilder, </span><span style="color:#9ECBFF">"p"</span><span style="color:#E1E4E8">, </span><span style="color:#79B8FF">1</span><span style="color:#E1E4E8">, </span><span style="color:#79B8FF">10</span><span style="color:#E1E4E8">, </span><span style="color:#79B8FF">1</span><span style="color:#E1E4E8">)</span></span>
86
+ <span class="line"><span style="color:#E1E4E8"> .</span><span style="color:#B392F0">name</span><span style="color:#E1E4E8">(</span><span style="color:#9ECBFF">"P"</span><span style="color:#E1E4E8">)</span></span>
87
+ <span class="line"><span style="color:#E1E4E8"> .</span><span style="color:#B392F0">onFinishChange</span><span style="color:#E1E4E8">(buildMesh)</span></span>
88
+ <span class="line"><span style="color:#E1E4E8">buildOptionsFolder</span></span>
89
+ <span class="line"><span style="color:#E1E4E8"> .</span><span style="color:#B392F0">add</span><span style="color:#E1E4E8">(meshBuilder, </span><span style="color:#9ECBFF">"q"</span><span style="color:#E1E4E8">, </span><span style="color:#79B8FF">1</span><span style="color:#E1E4E8">, </span><span style="color:#79B8FF">10</span><span style="color:#E1E4E8">, </span><span style="color:#79B8FF">1</span><span style="color:#E1E4E8">)</span></span>
90
+ <span class="line"><span style="color:#E1E4E8"> .</span><span style="color:#B392F0">name</span><span style="color:#E1E4E8">(</span><span style="color:#9ECBFF">"Q"</span><span style="color:#E1E4E8">)</span></span>
91
+ <span class="line"><span style="color:#E1E4E8"> .</span><span style="color:#B392F0">onFinishChange</span><span style="color:#E1E4E8">(buildMesh)</span></span>
92
+ <span class="line"><span style="color:#E1E4E8">buildOptionsFolder</span></span>
93
+ <span class="line"><span style="color:#E1E4E8"> .</span><span style="color:#B392F0">add</span><span style="color:#E1E4E8">(meshBuilder, </span><span style="color:#9ECBFF">"radialSegments"</span><span style="color:#E1E4E8">, </span><span style="color:#79B8FF">3</span><span style="color:#E1E4E8">, </span><span style="color:#79B8FF">64</span><span style="color:#E1E4E8">, </span><span style="color:#79B8FF">1</span><span style="color:#E1E4E8">)</span></span>
94
+ <span class="line"><span style="color:#E1E4E8"> .</span><span style="color:#B392F0">name</span><span style="color:#E1E4E8">(</span><span style="color:#9ECBFF">"Radial Segments"</span><span style="color:#E1E4E8">)</span></span>
95
+ <span class="line"><span style="color:#E1E4E8"> .</span><span style="color:#B392F0">onFinishChange</span><span style="color:#E1E4E8">(buildMesh)</span></span>
96
+ <span class="line"><span style="color:#E1E4E8">buildOptionsFolder</span></span>
97
+ <span class="line"><span style="color:#E1E4E8"> .</span><span style="color:#B392F0">add</span><span style="color:#E1E4E8">(meshBuilder, </span><span style="color:#9ECBFF">"pathSegments"</span><span style="color:#E1E4E8">, </span><span style="color:#79B8FF">8</span><span style="color:#E1E4E8">, </span><span style="color:#79B8FF">512</span><span style="color:#E1E4E8">, </span><span style="color:#79B8FF">1</span><span style="color:#E1E4E8">)</span></span>
98
+ <span class="line"><span style="color:#E1E4E8"> .</span><span style="color:#B392F0">name</span><span style="color:#E1E4E8">(</span><span style="color:#9ECBFF">"Path Segments"</span><span style="color:#E1E4E8">)</span></span>
99
+ <span class="line"><span style="color:#E1E4E8"> .</span><span style="color:#B392F0">onFinishChange</span><span style="color:#E1E4E8">(buildMesh)</span></span>
100
+ <span class="line"><span style="color:#E1E4E8">buildOptionsFolder</span></span>
101
+ <span class="line"><span style="color:#E1E4E8"> .</span><span style="color:#B392F0">add</span><span style="color:#E1E4E8">(settings, </span><span style="color:#9ECBFF">"wireframe"</span><span style="color:#E1E4E8">)</span></span>
102
+ <span class="line"><span style="color:#E1E4E8"> .</span><span style="color:#B392F0">name</span><span style="color:#E1E4E8">(</span><span style="color:#9ECBFF">"Wireframe"</span><span style="color:#E1E4E8">)</span></span>
103
+ <span class="line"><span style="color:#E1E4E8"> .</span><span style="color:#B392F0">onChange</span><span style="color:#E1E4E8">(buildMesh)</span></span>
104
+ <span class="line"><span style="color:#E1E4E8">buildOptionsFolder.</span><span style="color:#B392F0">open</span><span style="color:#E1E4E8">()</span></span>
105
+ <span class="line"></span>
106
+ <span class="line"><span style="color:#F97583">function</span><span style="color:#B392F0"> update</span><span style="color:#E1E4E8">() {</span></span>
107
+ <span class="line"><span style="color:#E1E4E8"> stats.</span><span style="color:#B392F0">begin</span><span style="color:#E1E4E8">()</span></span>
108
+ <span class="line"><span style="color:#E1E4E8"> cameraControls.</span><span style="color:#B392F0">update</span><span style="color:#E1E4E8">()</span></span>
109
+ <span class="line"><span style="color:#E1E4E8"> renderer.</span><span style="color:#B392F0">render</span><span style="color:#E1E4E8">([object, camera], renderDevice)</span></span>
110
+ <span class="line"><span style="color:#E1E4E8"> stats.</span><span style="color:#B392F0">end</span><span style="color:#E1E4E8">()</span></span>
111
+ <span class="line"></span>
112
+ <span class="line"><span style="color:#B392F0"> requestAnimationFrame</span><span style="color:#E1E4E8">(update)</span></span>
113
+ <span class="line"><span style="color:#E1E4E8">}</span></span>
114
+ <span class="line"></span>
115
+ <span class="line"><span style="color:#F97583">function</span><span style="color:#B392F0"> updateView</span><span style="color:#E1E4E8">() {</span></span>
116
+ <span class="line"><span style="color:#E1E4E8"> canvas.style.width </span><span style="color:#F97583">=</span><span style="color:#E1E4E8"> innerWidth </span><span style="color:#F97583">+</span><span style="color:#9ECBFF"> "px"</span></span>
117
+ <span class="line"><span style="color:#E1E4E8"> canvas.style.height </span><span style="color:#F97583">=</span><span style="color:#E1E4E8"> innerHeight </span><span style="color:#F97583">+</span><span style="color:#9ECBFF"> "px"</span></span>
118
+ <span class="line"><span style="color:#E1E4E8"> canvas.width </span><span style="color:#F97583">=</span><span style="color:#E1E4E8"> innerWidth </span><span style="color:#F97583">*</span><span style="color:#E1E4E8"> devicePixelRatio</span></span>
119
+ <span class="line"><span style="color:#E1E4E8"> canvas.height </span><span style="color:#F97583">=</span><span style="color:#E1E4E8"> innerHeight </span><span style="color:#F97583">*</span><span style="color:#E1E4E8"> devicePixelRatio</span></span>
120
+ <span class="line"></span>
121
+ <span class="line"><span style="color:#F97583"> if</span><span style="color:#E1E4E8"> (camera.projection </span><span style="color:#F97583">instanceof</span><span style="color:#B392F0"> PerspectiveProjection</span><span style="color:#E1E4E8">) {</span></span>
122
+ <span class="line"><span style="color:#E1E4E8"> camera.projection.aspect </span><span style="color:#F97583">=</span><span style="color:#E1E4E8"> innerWidth </span><span style="color:#F97583">/</span><span style="color:#E1E4E8"> innerHeight</span></span>
123
+ <span class="line"><span style="color:#E1E4E8"> }</span></span>
124
+ <span class="line"><span style="color:#E1E4E8">}</span></span>
125
+ <span class="line"></span>
126
+ <span class="line"><span style="color:#F97583">function</span><span style="color:#B392F0"> buildMesh</span><span style="color:#E1E4E8">() {</span></span>
127
+ <span class="line"><span style="color:#F97583"> const</span><span style="color:#79B8FF"> mesh</span><span style="color:#F97583"> =</span><span style="color:#E1E4E8"> meshBuilder.</span><span style="color:#B392F0">build</span><span style="color:#E1E4E8">()</span></span>
128
+ <span class="line"><span style="color:#F97583"> if</span><span style="color:#E1E4E8"> (settings.wireframe) {</span></span>
129
+ <span class="line"><span style="color:#E1E4E8"> object.mesh </span><span style="color:#F97583">=</span><span style="color:#F97583"> new</span><span style="color:#B392F0"> WireframeBuilder</span><span style="color:#E1E4E8">(mesh).</span><span style="color:#B392F0">build</span><span style="color:#E1E4E8">()</span></span>
130
+ <span class="line"><span style="color:#E1E4E8"> } </span><span style="color:#F97583">else</span><span style="color:#E1E4E8"> {</span></span>
131
+ <span class="line"><span style="color:#E1E4E8"> object.mesh </span><span style="color:#F97583">=</span><span style="color:#E1E4E8"> mesh</span></span>
132
+ <span class="line"><span style="color:#E1E4E8"> }</span></span>
133
+ <span class="line"><span style="color:#E1E4E8">}</span></span>
134
+ <span class="line"></span>
135
+ <span class="line"><span style="color:#6A737D">// demo-only performance monitor</span></span>
136
+ <span class="line"><span style="color:#F97583">const</span><span style="color:#79B8FF"> stats</span><span style="color:#F97583"> =</span><span style="color:#F97583"> new</span><span style="color:#B392F0"> Stats</span><span style="color:#E1E4E8">()</span></span>
137
+ <span class="line"><span style="color:#E1E4E8">stats.</span><span style="color:#B392F0">showPanel</span><span style="color:#E1E4E8">(</span><span style="color:#79B8FF">1</span><span style="color:#E1E4E8">)</span></span>
138
+ <span class="line"><span style="color:#E1E4E8">document.body.</span><span style="color:#B392F0">append</span><span style="color:#E1E4E8">(stats.dom)</span></span>
139
+ <span class="line"><span style="color:#E1E4E8">stats.dom.</span><span style="color:#B392F0">removeAttribute</span><span style="color:#E1E4E8">(</span><span style="color:#9ECBFF">"style"</span><span style="color:#E1E4E8">)</span></span>
140
+ <span class="line"><span style="color:#E1E4E8">stats.dom.classList.</span><span style="color:#B392F0">add</span><span style="color:#E1E4E8">(</span><span style="color:#9ECBFF">"performance-monitor"</span><span style="color:#E1E4E8">)</span></span></code></pre> </div> </main> </div> <script type="module">var e=document.getElementById(`menu-toggle`);e?.addEventListener(`click`,()=>{let t=document.body.classList.toggle(`menu-open`);e.setAttribute(`aria-expanded`,t?`true`:`false`)});var t=document.getElementById(`site-sidebar`);if(t instanceof HTMLElement){let e=window.location.pathname.replace(/\/+$/,``)||`/`,n=`sidebar-scroll:${e===`/`?`/`:e.split(`/`)[1]||e}`,r=0,i=()=>{try{let e=sessionStorage.getItem(n);return e===null?null:Number.parseInt(e,10)}catch{return null}},a=()=>{try{sessionStorage.setItem(n,String(t.scrollTop))}catch{}r=0},o=()=>{r===0&&(r=window.requestAnimationFrame(a))},s=i();s!==null&&Number.isFinite(s)&&(t.scrollTop=s),t.addEventListener(`scroll`,o,{passive:!0}),window.addEventListener(`pagehide`,a),window.addEventListener(`beforeunload`,a)}</script></body> </html>
@@ -0,0 +1,180 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
+ <title>Tube</title>
7
+ <style>
8
+ :root {
9
+ color-scheme: dark;
10
+ --bg: #05070a;
11
+ }
12
+
13
+ html,
14
+ body {
15
+ margin: 0;
16
+ width: 100%;
17
+ height: 100%;
18
+ background: var(--bg);
19
+ color: #eef2f7;
20
+ overflow: hidden;
21
+ }
22
+
23
+ canvas {
24
+ background-color: black;
25
+ touch-action: none;
26
+ }
27
+
28
+ .dg.ac {
29
+ position: fixed;
30
+ top: 0;
31
+ left: auto;
32
+ right: 0;
33
+ z-index: 10000;
34
+ }
35
+
36
+ .performance-monitor {
37
+ position: fixed;
38
+ top: 0%;
39
+ left: 0%;
40
+ right: auto;
41
+ cursor: pointer;
42
+ opacity: 0.9;
43
+ z-index: 10000;
44
+ }
45
+ </style>
46
+ <script type="importmap">{"imports":{"chorama":"https://cdn.jsdelivr.net/npm/chorama@0.1.1/dist/index.module.js","@rollup/plugin-node-resolve":"https://cdn.jsdelivr.net/npm/@rollup/plugin-node-resolve@16.0.3/dist/es/index.js","@rollup/plugin-typescript":"https://cdn.jsdelivr.net/npm/@rollup/plugin-typescript@12.3.0/dist/es/index.js","astro":"https://cdn.jsdelivr.net/npm/astro@7.2.2/dist/index.js","dat.gui":"https://cdn.jsdelivr.net/npm/dat.gui@0.7.9/build/dat.gui.module.js","hash-it":"https://cdn.jsdelivr.net/npm/hash-it@7.0.2/dist/es/index.mjs","hisabati":"https://cdn.jsdelivr.net/npm/hisabati@0.1.0/dist/index.module.js","marangi":"https://cdn.jsdelivr.net/npm/marangi@0.1.0/dist/index.module.js","rollup":"https://cdn.jsdelivr.net/npm/rollup@4.62.5/dist/es/rollup.js","stats.js":"https://cdn.jsdelivr.net/npm/stats.js@0.17.0/src/Stats.js","vifaa":"https://cdn.jsdelivr.net/npm/vifaa@0.3.0/dist/index.module.js","vite":"https://cdn.jsdelivr.net/npm/vite@8.2.1/dist/node/index.js","wima-docs-website-template":"https://cdn.jsdelivr.net/npm/wima-docs-website-template@0.1.0/src/index.js"}}</script>
47
+ </head>
48
+ <body>
49
+ <script type="module">import Stats from "stats.js"
50
+ import { GUI } from "dat.gui"
51
+ import {
52
+ BasicMaterial,
53
+ Camera,
54
+ CameraPlugin,
55
+ MeshMaterial3D,
56
+ MeshMaterialPlugin,
57
+ PerspectiveProjection,
58
+ OrbitCameraControls,
59
+ TextureLoader,
60
+ TubeMeshBuilder,
61
+ Vector3,
62
+ WireframeBuilder,
63
+ WebGLRenderDevice,
64
+ WebGLRenderer,
65
+ CanvasTarget
66
+ } from "chorama"
67
+
68
+ const canvas = document.createElement("canvas")
69
+ const renderTarget = new CanvasTarget(canvas)
70
+ const renderDevice = new WebGLRenderDevice(canvas, {
71
+ depth: true
72
+ })
73
+ const renderer = new WebGLRenderer({
74
+ plugins: [
75
+ new CameraPlugin(),
76
+ new MeshMaterialPlugin(),
77
+ ]
78
+ })
79
+ const camera = new Camera(renderTarget)
80
+ const cameraControls = new OrbitCameraControls(camera, canvas)
81
+
82
+ const textureLoader = new TextureLoader()
83
+ const texture = textureLoader.load({
84
+ paths: ["/images/uv.jpg"],
85
+ flipY: true
86
+ })
87
+ const material = new BasicMaterial({
88
+ mainTexture: texture
89
+ })
90
+
91
+ const meshBuilder = new TubeMeshBuilder()
92
+ meshBuilder.points = [
93
+ new Vector3(0.0, -0.5, 0.0),
94
+ new Vector3(0.3, -0.2, 0.2),
95
+ new Vector3(0.5, 0.1, 0.55),
96
+ new Vector3(0.25, 0.35, 0.9),
97
+ new Vector3(-0.15, 0.0, 1.2),
98
+ new Vector3(0.12, -0.3, 1.45)
99
+ ]
100
+ meshBuilder.radius = 0.07
101
+ meshBuilder.radialSegments = 12
102
+ const object = new MeshMaterial3D(meshBuilder.build(), material)
103
+
104
+ camera.transform.position.set(0, 0.35, 8)
105
+ if (camera.projection instanceof PerspectiveProjection) {
106
+ camera.projection.fov = Math.PI / 180 * 100
107
+ camera.projection.aspect = innerWidth / innerHeight
108
+ }
109
+
110
+ document.body.append(canvas)
111
+ addEventListener("resize", updateView)
112
+ updateView()
113
+ requestAnimationFrame(update)
114
+
115
+ const settings = {
116
+ closed: meshBuilder.closed,
117
+ wireframe: false
118
+ }
119
+ // demo-only GUI controls
120
+ const controls = new GUI()
121
+ const buildOptionsFolder = controls.addFolder("Settings")
122
+ buildOptionsFolder
123
+ .add(meshBuilder, "radius", 0.01, 0.5, 0.001)
124
+ .name("Radius")
125
+ .onFinishChange(buildMesh)
126
+ buildOptionsFolder
127
+ .add(meshBuilder, "radialSegments", 3, 32, 1)
128
+ .name("Radial Segments")
129
+ .onFinishChange(buildMesh)
130
+ buildOptionsFolder
131
+ .add(settings, "closed")
132
+ .name("Closed")
133
+ .onChange((value) => {
134
+ meshBuilder.closed = value
135
+ buildMesh()
136
+ })
137
+ buildOptionsFolder
138
+ .add(settings, "wireframe")
139
+ .name("Wireframe")
140
+ .onChange(buildMesh)
141
+ buildOptionsFolder.open()
142
+
143
+ function update() {
144
+ stats.begin()
145
+ cameraControls.update()
146
+ renderer.render([object, camera], renderDevice)
147
+ stats.end()
148
+
149
+ requestAnimationFrame(update)
150
+ }
151
+
152
+ function updateView() {
153
+ canvas.style.width = innerWidth + "px"
154
+ canvas.style.height = innerHeight + "px"
155
+ canvas.width = innerWidth * devicePixelRatio
156
+ canvas.height = innerHeight * devicePixelRatio
157
+
158
+ if (camera.projection instanceof PerspectiveProjection) {
159
+ camera.projection.aspect = innerWidth / innerHeight
160
+ }
161
+ }
162
+
163
+ function buildMesh() {
164
+ const mesh = meshBuilder.build()
165
+ if (settings.wireframe) {
166
+ object.mesh = new WireframeBuilder(mesh).build()
167
+ } else {
168
+ object.mesh = mesh
169
+ }
170
+ }
171
+
172
+ // demo-only performance monitor
173
+ const stats = new Stats()
174
+ stats.showPanel(1)
175
+ document.body.append(stats.dom)
176
+ stats.dom.removeAttribute("style")
177
+ stats.dom.classList.add("performance-monitor")
178
+ </script>
179
+ </body>
180
+ </html>