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,58 @@
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>Guide | 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" open><summary class="tab-toggle is-active"><span>Guide</span><span class="chevron">›</span></summary><ul class="tabs"><li class="tab-item"><a href="/guide" class="is-active">Overview</a><ul class="subtabs"><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> <h1 id="guide">Guide</h1>
3
+ <p>This guide helps you build scenes with Chorama using practical, task-first steps.</p>
4
+ <h2 id="overview">Overview</h2>
5
+ <p>Chorama is a modular WebGL2 rendering library focused on explicit control: you compose render behavior with plugins, build scenes from reusable object/material/light primitives, and keep direct visibility into the render flow.</p>
6
+ <blockquote>
7
+ <p>[!WARNING]
8
+ Chorama is currently experimental and is not recommended for production use.
9
+ Expect API changes, behavior changes and breaking changes as the library evolves.</p>
10
+ </blockquote>
11
+ <p>This guide is structured to take you from first render to production-style scene setup. Instead of covering every class in isolation first, each chapter is anchored to a concrete task and points you to full runnable examples.</p>
12
+ <p>By the end of this guide, you should be able to:</p>
13
+ <ul>
14
+ <li>Set up a render loop with <code>WebGLRenderDevice</code>, <code>CanvasTarget</code>, and <code>WebGLRenderer</code></li>
15
+ <li>Build and animate scene objects with camera, materials, and lights</li>
16
+ <li>Load texture/model assets and handle async content safely</li>
17
+ <li>Use render targets and view configuration for offscreen and multi-view scenarios</li>
18
+ <li>Understand the plugin-driven pipeline enough to debug and extend behavior</li>
19
+ </ul>
20
+ <h2 id="who-this-guide-is-for">Who This Guide Is For</h2>
21
+ <p>Use this if you want direct WebGL2 control but still want reusable building blocks.</p>
22
+ <h2 id="how-to-use-this-guide">How To Use This Guide</h2>
23
+ <ul>
24
+ <li>New to Chorama: follow the reading order from top to bottom.</li>
25
+ <li>Migrating from another renderer: start at <a href="/guide/first-scene">First Scene</a>, then jump to <a href="/guide/plugins-and-render-pipeline">Plugins and Render Pipeline</a>.</li>
26
+ <li>Looking for a specific API: use <a href="/guide/api-map">API Map</a> as an index, then return to task pages for applied usage.</li>
27
+ <li>Blocked on behavior: check <a href="/guide/troubleshooting">Troubleshooting</a>, then compare your setup against a matching example route.</li>
28
+ </ul>
29
+ <h2 id="reading-order">Reading Order</h2>
30
+ <ol>
31
+ <li><a href="/guide/installation">Installation</a></li>
32
+ <li><a href="/guide/first-scene">First Scene</a></li>
33
+ <li><a href="/guide/camera-and-controls">Camera and Controls</a></li>
34
+ <li><a href="/guide/materials-and-lighting">Materials and Lighting</a></li>
35
+ <li><a href="/guide/textures-and-assets">Textures and Assets</a></li>
36
+ <li><a href="/guide/render-targets-and-views">Render Targets and Views</a></li>
37
+ <li><a href="/guide/scene-graph-and-transforms">Scene Graph and Transforms</a></li>
38
+ <li><a href="/guide/plugins-and-render-pipeline">Plugins and Render Pipeline</a></li>
39
+ <li><a href="/guide/api-map">API Map</a></li>
40
+ <li><a href="/guide/troubleshooting">Troubleshooting</a></li>
41
+ </ol>
42
+ <h2 id="core-flow">Core Flow</h2>
43
+ <p>The snippet below creates the minimum pieces needed to render a scene:</p>
44
+ <pre class="astro-code github-dark" style="background-color:#24292e;color:#e1e4e8; overflow-x: auto;" tabindex="0" data-language="js"><code><span class="line"><span style="color:#F97583">import</span><span style="color:#E1E4E8"> { WebGLRenderDevice, CanvasTarget, WebGLRenderer, Camera } </span><span style="color:#F97583">from</span><span style="color:#9ECBFF"> "chorama"</span><span style="color:#E1E4E8">;</span></span>
45
+ <span class="line"></span>
46
+ <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>
47
+ <span class="line"><span style="color:#F97583">const</span><span style="color:#79B8FF"> device</span><span style="color:#F97583"> =</span><span style="color:#F97583"> new</span><span style="color:#B392F0"> WebGLRenderDevice</span><span style="color:#E1E4E8">(canvas, { depth: </span><span style="color:#79B8FF">true</span><span style="color:#E1E4E8"> });</span></span>
48
+ <span class="line"><span style="color:#F97583">const</span><span style="color:#79B8FF"> target</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>
49
+ <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>
50
+ <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">(target);</span></span></code></pre>
51
+ <p>The <code>canvas</code> is the HTML surface where we draw on (or in a more technical terms, render to).
52
+ The <code>WebGLRenderDevice</code> executes our draw commands.
53
+ The <code>CanvasTarget</code> tells the camera where to render to. There is another type of target but thats for later.
54
+ The <code>WebGLRenderer</code> runs the render pipeline each frame.
55
+ The <code>Camera</code> provides view/projection data the renderer needs.</p>
56
+ <p>This snippet exists to show the baseline setup used in almost every example, so later chapters can add one concept at a time without repeating setup details.</p>
57
+ <p>For a complete runnable example, start with <a href="/examples/other/rotatingCube">Rotating Cube</a>.</p>
58
+ </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,133 @@
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>Installation | 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" open><summary class="tab-toggle is-active"><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" class="is-active">Installation</a><ul class="subtabs"><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> <h1 id="installation">Installation</h1>
3
+ <p>Choose how you want to use the library:</p>
4
+ <ul>
5
+ <li>If you want to use it now: use <strong>Manual Installation</strong>.</li>
6
+ <li>If you are waiting for package distribution: see <strong>NPM</strong> or <strong>CDN</strong>.</li>
7
+ </ul>
8
+ <h2 id="npm">NPM</h2>
9
+ <blockquote>
10
+ <p>[!Note]
11
+ This method is not yet available.</p>
12
+ </blockquote>
13
+ <h2 id="cdn">CDN</h2>
14
+ <blockquote>
15
+ <p>[!Note]
16
+ This method is not yet available.</p>
17
+ </blockquote>
18
+ <h2 id="manual-installation">Manual Installation</h2>
19
+ <h3 id="1-requirements">1) Requirements</h3>
20
+ <p>Install these first:</p>
21
+ <ul>
22
+ <li><a href="/downloads">Git</a> to clone the source code</li>
23
+ <li><a href="/">Node.js 18+</a> (includes npm) to install dependencies and build</li>
24
+ <li>A browser with WebGL2 support to run your app/examples</li>
25
+ </ul>
26
+ <h3 id="2-clone-the-repository-and-install-dependencies">2) Clone the repository and install dependencies</h3>
27
+ <pre class="astro-code github-dark" style="background-color:#24292e;color:#e1e4e8; overflow-x: auto;" tabindex="0" data-language="bash"><code><span class="line"><span style="color:#B392F0">git</span><span style="color:#9ECBFF"> clone</span><span style="color:#9ECBFF"> https://github.com/waynemwashuma/chorama.git</span></span>
28
+ <span class="line"><span style="color:#79B8FF">cd</span><span style="color:#9ECBFF"> chorama</span></span>
29
+ <span class="line"><span style="color:#B392F0">npm</span><span style="color:#9ECBFF"> install</span></span></code></pre>
30
+ <h3 id="3-build-the-library-files">3) Build the library files</h3>
31
+ <pre class="astro-code github-dark" style="background-color:#24292e;color:#e1e4e8; overflow-x: auto;" tabindex="0" data-language="bash"><code><span class="line"><span style="color:#B392F0">npm</span><span style="color:#9ECBFF"> run</span><span style="color:#9ECBFF"> build-src</span></span></code></pre>
32
+ <p>This creates build output in <code>dist/</code>, including:</p>
33
+ <ul>
34
+ <li><code>dist/index.umd.js</code></li>
35
+ <li><code>dist/index.module.js</code></li>
36
+ </ul>
37
+ <p>Optional: if you also want local docs/examples output, run:</p>
38
+ <pre class="astro-code github-dark" style="background-color:#24292e;color:#e1e4e8; overflow-x: auto;" tabindex="0" data-language="bash"><code><span class="line"><span style="color:#B392F0">npm</span><span style="color:#9ECBFF"> run</span><span style="color:#9ECBFF"> build</span></span></code></pre>
39
+ <h3 id="4-copy-files-to-your-project">4) Copy files to your project</h3>
40
+ <p>Copy one or both build files into your own project.</p>
41
+ <ul>
42
+ <li>Use <code>dist/index.module.js</code> for ESM usage (recommended).</li>
43
+ <li>Use <code>dist/index.umd.js</code> for plain script-tag usage.</li>
44
+ </ul>
45
+ <p>Example layout used below:</p>
46
+ <pre class="astro-code github-dark" style="background-color:#24292e;color:#e1e4e8; overflow-x: auto;" tabindex="0" data-language="text"><code><span class="line"><span>your-project/</span></span>
47
+ <span class="line"><span> libs/</span></span>
48
+ <span class="line"><span> chorama/</span></span>
49
+ <span class="line"><span> index.module.js</span></span>
50
+ <span class="line"><span> index.umd.js</span></span></code></pre>
51
+ <h3 id="5-use-in-your-project">5) Use in your project</h3>
52
+ <h4 id="esm-recommended">ESM (recommended)</h4>
53
+ <p>If you use a bundler, set an alias so your app can import from <code>"chorama"</code> directly.</p>
54
+ <h5 id="vite-viteconfigjs">Vite (<code>vite.config.js</code>)</h5>
55
+ <pre class="astro-code github-dark" style="background-color:#24292e;color:#e1e4e8; overflow-x: auto;" tabindex="0" data-language="js"><code><span class="line"><span style="color:#F97583">import</span><span style="color:#E1E4E8"> { defineConfig } </span><span style="color:#F97583">from</span><span style="color:#9ECBFF"> "vite"</span><span style="color:#E1E4E8">;</span></span>
56
+ <span class="line"><span style="color:#F97583">import</span><span style="color:#E1E4E8"> path </span><span style="color:#F97583">from</span><span style="color:#9ECBFF"> "node:path"</span><span style="color:#E1E4E8">;</span></span>
57
+ <span class="line"><span style="color:#F97583">import</span><span style="color:#E1E4E8"> { fileURLToPath } </span><span style="color:#F97583">from</span><span style="color:#9ECBFF"> "node:url"</span><span style="color:#E1E4E8">;</span></span>
58
+ <span class="line"></span>
59
+ <span class="line"><span style="color:#F97583">const</span><span style="color:#79B8FF"> __filename</span><span style="color:#F97583"> =</span><span style="color:#B392F0"> fileURLToPath</span><span style="color:#E1E4E8">(</span><span style="color:#F97583">import</span><span style="color:#E1E4E8">.</span><span style="color:#79B8FF">meta</span><span style="color:#E1E4E8">.url);</span></span>
60
+ <span class="line"><span style="color:#F97583">const</span><span style="color:#79B8FF"> __dirname</span><span style="color:#F97583"> =</span><span style="color:#E1E4E8"> path.</span><span style="color:#B392F0">dirname</span><span style="color:#E1E4E8">(__filename);</span></span>
61
+ <span class="line"></span>
62
+ <span class="line"><span style="color:#F97583">export</span><span style="color:#F97583"> default</span><span style="color:#B392F0"> defineConfig</span><span style="color:#E1E4E8">({</span></span>
63
+ <span class="line"><span style="color:#E1E4E8"> resolve: {</span></span>
64
+ <span class="line"><span style="color:#E1E4E8"> alias: {</span></span>
65
+ <span class="line"><span style="color:#E1E4E8"> chorama: path.</span><span style="color:#B392F0">resolve</span><span style="color:#E1E4E8">(__dirname, </span><span style="color:#9ECBFF">"libs/chorama/index.module.js"</span><span style="color:#E1E4E8">)</span></span>
66
+ <span class="line"><span style="color:#E1E4E8"> }</span></span>
67
+ <span class="line"><span style="color:#E1E4E8"> }</span></span>
68
+ <span class="line"><span style="color:#E1E4E8">});</span></span></code></pre>
69
+ <h5 id="webpack-webpackconfigjs">Webpack (<code>webpack.config.js</code>)</h5>
70
+ <pre class="astro-code github-dark" style="background-color:#24292e;color:#e1e4e8; overflow-x: auto;" tabindex="0" data-language="js"><code><span class="line"><span style="color:#F97583">const</span><span style="color:#79B8FF"> path</span><span style="color:#F97583"> =</span><span style="color:#B392F0"> require</span><span style="color:#E1E4E8">(</span><span style="color:#9ECBFF">"node:path"</span><span style="color:#E1E4E8">);</span></span>
71
+ <span class="line"></span>
72
+ <span class="line"><span style="color:#79B8FF">module</span><span style="color:#E1E4E8">.</span><span style="color:#79B8FF">exports</span><span style="color:#F97583"> =</span><span style="color:#E1E4E8"> {</span></span>
73
+ <span class="line"><span style="color:#E1E4E8"> resolve: {</span></span>
74
+ <span class="line"><span style="color:#E1E4E8"> alias: {</span></span>
75
+ <span class="line"><span style="color:#E1E4E8"> chorama: path.</span><span style="color:#B392F0">resolve</span><span style="color:#E1E4E8">(__dirname, </span><span style="color:#9ECBFF">"libs/chorama/index.module.js"</span><span style="color:#E1E4E8">)</span></span>
76
+ <span class="line"><span style="color:#E1E4E8"> }</span></span>
77
+ <span class="line"><span style="color:#E1E4E8"> }</span></span>
78
+ <span class="line"><span style="color:#E1E4E8">};</span></span></code></pre>
79
+ <p>Then import in app code:</p>
80
+ <pre class="astro-code github-dark" style="background-color:#24292e;color:#e1e4e8; overflow-x: auto;" tabindex="0" data-language="js"><code><span class="line"><span style="color:#F97583">import</span><span style="color:#E1E4E8"> { WebGLRenderer, MeshMaterialPlugin, CameraPlugin } </span><span style="color:#F97583">from</span><span style="color:#9ECBFF"> "chorama"</span><span style="color:#E1E4E8">;</span></span></code></pre>
81
+ <h4 id="plain-html-with-browser-import-maps-no-bundler">Plain HTML with browser import maps (no bundler)</h4>
82
+ <p>Use the ESM file with an import map:</p>
83
+ <pre class="astro-code github-dark" style="background-color:#24292e;color:#e1e4e8; overflow-x: auto;" tabindex="0" data-language="html"><code><span class="line"><span style="color:#E1E4E8">&lt;!</span><span style="color:#85E89D">doctype</span><span style="color:#B392F0"> html</span><span style="color:#E1E4E8">&gt;</span></span>
84
+ <span class="line"><span style="color:#E1E4E8">&lt;</span><span style="color:#85E89D">html</span><span style="color:#E1E4E8">&gt;</span></span>
85
+ <span class="line"><span style="color:#E1E4E8"> &lt;</span><span style="color:#85E89D">head</span><span style="color:#E1E4E8">&gt;</span></span>
86
+ <span class="line"><span style="color:#E1E4E8"> &lt;</span><span style="color:#85E89D">meta</span><span style="color:#B392F0"> charset</span><span style="color:#E1E4E8">=</span><span style="color:#9ECBFF">"utf-8"</span><span style="color:#E1E4E8"> /&gt;</span></span>
87
+ <span class="line"><span style="color:#E1E4E8"> &lt;</span><span style="color:#85E89D">meta</span><span style="color:#B392F0"> name</span><span style="color:#E1E4E8">=</span><span style="color:#9ECBFF">"viewport"</span><span style="color:#B392F0"> content</span><span style="color:#E1E4E8">=</span><span style="color:#9ECBFF">"width=device-width, initial-scale=1"</span><span style="color:#E1E4E8"> /&gt;</span></span>
88
+ <span class="line"><span style="color:#E1E4E8"> &lt;</span><span style="color:#85E89D">title</span><span style="color:#E1E4E8">&gt;Chorama - Import Map&lt;/</span><span style="color:#85E89D">title</span><span style="color:#E1E4E8">&gt;</span></span>
89
+ <span class="line"><span style="color:#E1E4E8"> &lt;</span><span style="color:#85E89D">script</span><span style="color:#B392F0"> type</span><span style="color:#E1E4E8">=</span><span style="color:#9ECBFF">"importmap"</span><span style="color:#E1E4E8">&gt;</span></span>
90
+ <span class="line"><span style="color:#E1E4E8"> {</span></span>
91
+ <span class="line"><span style="color:#E1E4E8"> "imports": {</span></span>
92
+ <span class="line"><span style="color:#E1E4E8"> "chorama": "./libs/chorama/index.module.js"</span></span>
93
+ <span class="line"><span style="color:#E1E4E8"> }</span></span>
94
+ <span class="line"><span style="color:#E1E4E8"> }</span></span>
95
+ <span class="line"><span style="color:#E1E4E8"> &lt;/</span><span style="color:#85E89D">script</span><span style="color:#E1E4E8">&gt;</span></span>
96
+ <span class="line"><span style="color:#E1E4E8"> &lt;/</span><span style="color:#85E89D">head</span><span style="color:#E1E4E8">&gt;</span></span>
97
+ <span class="line"><span style="color:#E1E4E8"> &lt;</span><span style="color:#85E89D">body</span><span style="color:#E1E4E8">&gt;</span></span>
98
+ <span class="line"><span style="color:#E1E4E8"> &lt;</span><span style="color:#85E89D">canvas</span><span style="color:#B392F0"> id</span><span style="color:#E1E4E8">=</span><span style="color:#9ECBFF">"app"</span><span style="color:#E1E4E8">&gt;&lt;/</span><span style="color:#85E89D">canvas</span><span style="color:#E1E4E8">&gt;</span></span>
99
+ <span class="line"><span style="color:#E1E4E8"> &lt;</span><span style="color:#85E89D">script</span><span style="color:#B392F0"> type</span><span style="color:#E1E4E8">=</span><span style="color:#9ECBFF">"module"</span><span style="color:#E1E4E8">&gt;</span></span>
100
+ <span class="line"><span style="color:#F97583"> import</span><span style="color:#E1E4E8"> { WebGLRenderer, MeshMaterialPlugin, CameraPlugin } </span><span style="color:#F97583">from</span><span style="color:#9ECBFF"> "chorama"</span><span style="color:#E1E4E8">;</span></span>
101
+ <span class="line"></span>
102
+ <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">getElementById</span><span style="color:#E1E4E8">(</span><span style="color:#9ECBFF">"app"</span><span style="color:#E1E4E8">);</span></span>
103
+ <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>
104
+ <span class="line"><span style="color:#E1E4E8"> canvas,</span></span>
105
+ <span class="line"><span style="color:#E1E4E8"> plugins: [</span><span style="color:#F97583">new</span><span style="color:#B392F0"> MeshMaterialPlugin</span><span style="color:#E1E4E8">(), </span><span style="color:#F97583">new</span><span style="color:#B392F0"> CameraPlugin</span><span style="color:#E1E4E8">()]</span></span>
106
+ <span class="line"><span style="color:#E1E4E8"> });</span></span>
107
+ <span class="line"><span style="color:#E1E4E8"> &lt;/</span><span style="color:#85E89D">script</span><span style="color:#E1E4E8">&gt;</span></span>
108
+ <span class="line"><span style="color:#E1E4E8"> &lt;/</span><span style="color:#85E89D">body</span><span style="color:#E1E4E8">&gt;</span></span>
109
+ <span class="line"><span style="color:#E1E4E8">&lt;/</span><span style="color:#85E89D">html</span><span style="color:#E1E4E8">&gt;</span></span></code></pre>
110
+ <h4 id="plain-html-with-script-tag-umd">Plain HTML with script tag (UMD)</h4>
111
+ <p>Use the UMD build if you do not want modules:</p>
112
+ <pre class="astro-code github-dark" style="background-color:#24292e;color:#e1e4e8; overflow-x: auto;" tabindex="0" data-language="html"><code><span class="line"><span style="color:#E1E4E8">&lt;!</span><span style="color:#85E89D">doctype</span><span style="color:#B392F0"> html</span><span style="color:#E1E4E8">&gt;</span></span>
113
+ <span class="line"><span style="color:#E1E4E8">&lt;</span><span style="color:#85E89D">html</span><span style="color:#E1E4E8">&gt;</span></span>
114
+ <span class="line"><span style="color:#E1E4E8"> &lt;</span><span style="color:#85E89D">head</span><span style="color:#E1E4E8">&gt;</span></span>
115
+ <span class="line"><span style="color:#E1E4E8"> &lt;</span><span style="color:#85E89D">meta</span><span style="color:#B392F0"> charset</span><span style="color:#E1E4E8">=</span><span style="color:#9ECBFF">"utf-8"</span><span style="color:#E1E4E8"> /&gt;</span></span>
116
+ <span class="line"><span style="color:#E1E4E8"> &lt;</span><span style="color:#85E89D">meta</span><span style="color:#B392F0"> name</span><span style="color:#E1E4E8">=</span><span style="color:#9ECBFF">"viewport"</span><span style="color:#B392F0"> content</span><span style="color:#E1E4E8">=</span><span style="color:#9ECBFF">"width=device-width, initial-scale=1"</span><span style="color:#E1E4E8"> /&gt;</span></span>
117
+ <span class="line"><span style="color:#E1E4E8"> &lt;</span><span style="color:#85E89D">title</span><span style="color:#E1E4E8">&gt;Chorama - Plain HTML&lt;/</span><span style="color:#85E89D">title</span><span style="color:#E1E4E8">&gt;</span></span>
118
+ <span class="line"><span style="color:#E1E4E8"> &lt;</span><span style="color:#85E89D">script</span><span style="color:#B392F0"> src</span><span style="color:#E1E4E8">=</span><span style="color:#9ECBFF">"./libs/chorama/index.umd.js"</span><span style="color:#E1E4E8">&gt;&lt;/</span><span style="color:#85E89D">script</span><span style="color:#E1E4E8">&gt;</span></span>
119
+ <span class="line"><span style="color:#E1E4E8"> &lt;/</span><span style="color:#85E89D">head</span><span style="color:#E1E4E8">&gt;</span></span>
120
+ <span class="line"><span style="color:#E1E4E8"> &lt;</span><span style="color:#85E89D">body</span><span style="color:#E1E4E8">&gt;</span></span>
121
+ <span class="line"><span style="color:#E1E4E8"> &lt;</span><span style="color:#85E89D">canvas</span><span style="color:#B392F0"> id</span><span style="color:#E1E4E8">=</span><span style="color:#9ECBFF">"app"</span><span style="color:#E1E4E8">&gt;&lt;/</span><span style="color:#85E89D">canvas</span><span style="color:#E1E4E8">&gt;</span></span>
122
+ <span class="line"><span style="color:#E1E4E8"> &lt;</span><span style="color:#85E89D">script</span><span style="color:#E1E4E8">&gt;</span></span>
123
+ <span class="line"><span style="color:#F97583"> const</span><span style="color:#E1E4E8"> { </span><span style="color:#79B8FF">WebGLRenderer</span><span style="color:#E1E4E8">, </span><span style="color:#79B8FF">MeshMaterialPlugin</span><span style="color:#E1E4E8">, </span><span style="color:#79B8FF">CameraPlugin</span><span style="color:#E1E4E8"> } </span><span style="color:#F97583">=</span><span style="color:#E1E4E8"> window.</span><span style="color:#79B8FF">CHORAMA</span><span style="color:#E1E4E8">;</span></span>
124
+ <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">getElementById</span><span style="color:#E1E4E8">(</span><span style="color:#9ECBFF">"app"</span><span style="color:#E1E4E8">);</span></span>
125
+ <span class="line"></span>
126
+ <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>
127
+ <span class="line"><span style="color:#E1E4E8"> canvas,</span></span>
128
+ <span class="line"><span style="color:#E1E4E8"> plugins: [</span><span style="color:#F97583">new</span><span style="color:#B392F0"> MeshMaterialPlugin</span><span style="color:#E1E4E8">(), </span><span style="color:#F97583">new</span><span style="color:#B392F0"> CameraPlugin</span><span style="color:#E1E4E8">()]</span></span>
129
+ <span class="line"><span style="color:#E1E4E8"> });</span></span>
130
+ <span class="line"><span style="color:#E1E4E8"> &lt;/</span><span style="color:#85E89D">script</span><span style="color:#E1E4E8">&gt;</span></span>
131
+ <span class="line"><span style="color:#E1E4E8"> &lt;/</span><span style="color:#85E89D">body</span><span style="color:#E1E4E8">&gt;</span></span>
132
+ <span class="line"><span style="color:#E1E4E8">&lt;/</span><span style="color:#85E89D">html</span><span style="color:#E1E4E8">&gt;</span></span></code></pre>
133
+ </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,90 @@
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>Materials and Lighting | 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" open><summary class="tab-toggle is-active"><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" class="is-active">Materials and Lighting</a><ul class="subtabs"><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> <h1 id="materials-and-lighting">Materials and Lighting</h1>
3
+ <p>This guide assumes you already have a working scene from <a href="/guide/first-scene">First Scene</a>.
4
+ Here, you will add lit materials and light objects in small steps.</p>
5
+ <h2 id="what-you-will-add">What You Will Add</h2>
6
+ <ul>
7
+ <li>a material choice based on visual style</li>
8
+ <li>renderer plugins required for lighting</li>
9
+ <li>ambient light for base visibility</li>
10
+ <li>one direct light source</li>
11
+ <li>a render list that includes lights</li>
12
+ </ul>
13
+ <h2 id="step-1-import-material-and-light-apis">Step 1: Import Material and Light APIs</h2>
14
+ <pre class="astro-code github-dark" style="background-color:#24292e;color:#e1e4e8; overflow-x: auto;" tabindex="0" data-language="js"><code><span class="line"><span style="color:#F97583">import</span><span style="color:#E1E4E8"> {</span></span>
15
+ <span class="line"><span style="color:#E1E4E8"> BasicMaterial,</span></span>
16
+ <span class="line"><span style="color:#E1E4E8"> LambertMaterial,</span></span>
17
+ <span class="line"><span style="color:#E1E4E8"> PhongMaterial,</span></span>
18
+ <span class="line"><span style="color:#E1E4E8"> StandardMaterial,</span></span>
19
+ <span class="line"><span style="color:#E1E4E8"> AmbientLight,</span></span>
20
+ <span class="line"><span style="color:#E1E4E8"> DirectionalLight,</span></span>
21
+ <span class="line"><span style="color:#E1E4E8"> LightPlugin</span></span>
22
+ <span class="line"><span style="color:#E1E4E8">} </span><span style="color:#F97583">from</span><span style="color:#9ECBFF"> "chorama"</span><span style="color:#E1E4E8">;</span></span></code></pre>
23
+ <p>Use <code>BasicMaterial</code> when you do not need scene lighting.
24
+ Use <code>LambertMaterial</code>, <code>PhongMaterial</code>, or <code>StandardMaterial</code> when you want lights to affect the surface.</p>
25
+ <h2 id="step-2-pick-a-material-model">Step 2: Pick a Material Model</h2>
26
+ <pre class="astro-code github-dark" style="background-color:#24292e;color:#e1e4e8; overflow-x: auto;" tabindex="0" data-language="js"><code><span class="line"><span style="color:#F97583">const</span><span style="color:#79B8FF"> basic</span><span style="color:#F97583"> =</span><span style="color:#F97583"> new</span><span style="color:#B392F0"> BasicMaterial</span><span style="color:#E1E4E8">();</span></span>
27
+ <span class="line"><span style="color:#F97583">const</span><span style="color:#79B8FF"> lambert</span><span style="color:#F97583"> =</span><span style="color:#F97583"> new</span><span style="color:#B392F0"> LambertMaterial</span><span style="color:#E1E4E8">();</span></span>
28
+ <span class="line"><span style="color:#F97583">const</span><span style="color:#79B8FF"> phong</span><span style="color:#F97583"> =</span><span style="color:#F97583"> new</span><span style="color:#B392F0"> PhongMaterial</span><span style="color:#E1E4E8">();</span></span>
29
+ <span class="line"><span style="color:#F97583">const</span><span style="color:#79B8FF"> standard</span><span style="color:#F97583"> =</span><span style="color:#F97583"> new</span><span style="color:#B392F0"> StandardMaterial</span><span style="color:#E1E4E8">({ roughness: </span><span style="color:#79B8FF">0.5</span><span style="color:#E1E4E8">, metallic: </span><span style="color:#79B8FF">0.1</span><span style="color:#E1E4E8"> });</span></span></code></pre>
30
+ <p>Quick guidance:</p>
31
+ <ul>
32
+ <li><code>BasicMaterial</code>: unlit shading</li>
33
+ <li><code>LambertMaterial</code>: diffuse lit shading</li>
34
+ <li><code>PhongMaterial</code>: diffuse + specular highlight shading</li>
35
+ <li><code>StandardMaterial</code>: physically-based roughness/metallic shasing</li>
36
+ </ul>
37
+ <p>For a first lit scene, start with <code>LambertMaterial</code>.</p>
38
+ <h2 id="step-3-apply-the-material-to-your-mesh-object">Step 3: Apply the Material to Your Mesh Object</h2>
39
+ <pre class="astro-code github-dark" style="background-color:#24292e;color:#e1e4e8; overflow-x: auto;" tabindex="0" data-language="js"><code><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">(mesh, lambert);</span></span></code></pre>
40
+ <p>The second parameter can be any of the materials shown in the previous step.
41
+ If you keep <code>BasicMaterial</code> as the material of the object, lights will not change the object’s appearance.</p>
42
+ <h2 id="step-4-enable-the-lighting-pipeline-in-the-renderer">Step 4: Enable the Lighting Pipeline in the Renderer</h2>
43
+ <pre class="astro-code github-dark" style="background-color:#24292e;color:#e1e4e8; overflow-x: auto;" tabindex="0" data-language="js"><code><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>
44
+ <span class="line"><span style="color:#E1E4E8"> plugins: [</span></span>
45
+ <span class="line"><span style="color:#F97583"> new</span><span style="color:#B392F0"> LightPlugin</span><span style="color:#E1E4E8">(),</span></span>
46
+ <span class="line"><span style="color:#F97583"> new</span><span style="color:#B392F0"> MeshMaterialPlugin</span><span style="color:#E1E4E8">(),</span></span>
47
+ <span class="line"><span style="color:#F97583"> new</span><span style="color:#B392F0"> CameraPlugin</span><span style="color:#E1E4E8">()</span></span>
48
+ <span class="line"><span style="color:#E1E4E8"> ]</span></span>
49
+ <span class="line"><span style="color:#E1E4E8">});</span></span></code></pre>
50
+ <p><code>LightPlugin</code> must be present on the renderer for lit materials to respond to lights.</p>
51
+ <h2 id="step-5-add-ambient-light">Step 5: Add Ambient Light</h2>
52
+ <pre class="astro-code github-dark" style="background-color:#24292e;color:#e1e4e8; overflow-x: auto;" tabindex="0" data-language="js"><code><span class="line"><span style="color:#F97583">const</span><span style="color:#79B8FF"> ambient</span><span style="color:#F97583"> =</span><span style="color:#F97583"> new</span><span style="color:#B392F0"> AmbientLight</span><span style="color:#E1E4E8">();</span></span>
53
+ <span class="line"><span style="color:#E1E4E8">ambient.intensity </span><span style="color:#F97583">=</span><span style="color:#79B8FF"> 0.15</span><span style="color:#E1E4E8">;</span></span></code></pre>
54
+ <p>Ambient light gives a soft base so unlit sides are still visible.
55
+ It is used to approximate indirect lighting for the entire scene.
56
+ Keep this low so directional/point/spot lights can affect the object’s appearance.</p>
57
+ <h2 id="step-6-add-a-directional-light">Step 6: Add a Directional Light</h2>
58
+ <pre class="astro-code github-dark" style="background-color:#24292e;color:#e1e4e8; overflow-x: auto;" tabindex="0" data-language="js"><code><span class="line"><span style="color:#F97583">const</span><span style="color:#79B8FF"> sun</span><span style="color:#F97583"> =</span><span style="color:#F97583"> new</span><span style="color:#B392F0"> DirectionalLight</span><span style="color:#E1E4E8">();</span></span>
59
+ <span class="line"><span style="color:#E1E4E8">sun.intensity </span><span style="color:#F97583">=</span><span style="color:#79B8FF"> 1.0</span><span style="color:#E1E4E8">;</span></span>
60
+ <span class="line"><span style="color:#E1E4E8">sun.transform.orientation.</span><span style="color:#B392F0">rotateX</span><span style="color:#E1E4E8">(</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"> 4</span><span style="color:#E1E4E8">);</span></span>
61
+ <span class="line"><span style="color:#E1E4E8">sun.transform.orientation.</span><span style="color:#B392F0">rotateZ</span><span style="color:#E1E4E8">(</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"> 4</span><span style="color:#E1E4E8">);</span></span></code></pre>
62
+ <p>Directional light is a good first light because it is simple and predictable.
63
+ It behaves like a distant light source with parallel rays. In this case, the light
64
+ will point downwards onto the scene.</p>
65
+ <h2 id="step-7-render-with-object-lights-and-camera">Step 7: Render with Object, Lights, and Camera</h2>
66
+ <pre class="astro-code github-dark" style="background-color:#24292e;color:#e1e4e8; overflow-x: auto;" tabindex="0" data-language="js"><code><span class="line"><span style="color:#E1E4E8">renderer.</span><span style="color:#B392F0">render</span><span style="color:#E1E4E8">([object, ambient, sun, camera], device);</span></span></code></pre>
67
+ <p>Your render list must include light objects each frame.
68
+ If lights are missing from the list, lit materials may look black or flat.</p>
69
+ <h2 id="step-8-animate-and-keep-scene-responsive">Step 8: Animate and Keep Scene Responsive</h2>
70
+ <pre class="astro-code github-dark" style="background-color:#24292e;color:#e1e4e8; overflow-x: auto;" tabindex="0" data-language="js"><code><span class="line"><span style="color:#F97583">function</span><span style="color:#B392F0"> frame</span><span style="color:#E1E4E8">() {</span></span>
71
+ <span class="line"><span style="color:#E1E4E8"> renderer.</span><span style="color:#B392F0">render</span><span style="color:#E1E4E8">([object, ambient, sun, camera], device);</span></span>
72
+ <span class="line"><span style="color:#B392F0"> requestAnimationFrame</span><span style="color:#E1E4E8">(frame);</span></span>
73
+ <span class="line"><span style="color:#E1E4E8">}</span></span>
74
+ <span class="line"></span>
75
+ <span class="line"><span style="color:#B392F0">requestAnimationFrame</span><span style="color:#E1E4E8">(frame);</span></span></code></pre>
76
+ <p>Keep your existing resize handler from <a href="/guide/first-scene">First Scene</a>.
77
+ Perspective scenes still require <code>camera.projection.aspect</code> updates on resize.</p>
78
+ <h2 id="switching-between-material-types">Switching Between Material Types</h2>
79
+ <p>You can swap material at runtime to compare look and performance:</p>
80
+ <pre class="astro-code github-dark" style="background-color:#24292e;color:#e1e4e8; overflow-x: auto;" tabindex="0" data-language="js"><code><span class="line"><span style="color:#E1E4E8">object.material </span><span style="color:#F97583">=</span><span style="color:#E1E4E8"> phong;</span></span>
81
+ <span class="line"><span style="color:#6A737D">// object.material = standard;</span></span>
82
+ <span class="line"><span style="color:#6A737D">// object.material = lambert;</span></span></code></pre>
83
+ <h2 id="reference-examples">Reference Examples</h2>
84
+ <ul>
85
+ <li><a href="/examples/lights/directional">Directional Light</a></li>
86
+ <li><a href="/examples/lights/point">Point Light</a></li>
87
+ <li><a href="/examples/lights/spot">Spot Light</a></li>
88
+ </ul>
89
+ <p>After this works, continue with <a href="/guide/textures-and-assets">Textures and Assets</a></p>
90
+ </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>