chorama 0.0.0 → 0.1.2

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 +23334 -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,82 @@
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>API Map | 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">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" class="is-active">API Map</a><ul class="subtabs"><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="api-map">API Map</h1>
3
+ <p>This is a high-level map of the public surface exported from <code>src/index.js</code>.</p>
4
+ <h2 id="quick-import-example">Quick Import Example</h2>
5
+ <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>
6
+ <span class="line"><span style="color:#E1E4E8"> WebGLRenderDevice,</span></span>
7
+ <span class="line"><span style="color:#E1E4E8"> WebGLRenderer,</span></span>
8
+ <span class="line"><span style="color:#E1E4E8"> Camera,</span></span>
9
+ <span class="line"><span style="color:#E1E4E8"> MeshMaterial3D,</span></span>
10
+ <span class="line"><span style="color:#E1E4E8"> MeshMaterialPlugin,</span></span>
11
+ <span class="line"><span style="color:#E1E4E8"> CameraPlugin</span></span>
12
+ <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>
13
+ <h2 id="rendering-core">Rendering Core</h2>
14
+ <ul>
15
+ <li><code>WebGLRenderDevice</code></li>
16
+ <li><code>WebGLRenderer</code></li>
17
+ <li>Core descriptors/pipeline types from <code>core</code></li>
18
+ </ul>
19
+ <h2 id="scene-objects">Scene Objects</h2>
20
+ <ul>
21
+ <li><code>Object3D</code></li>
22
+ <li><code>MeshMaterial3D</code></li>
23
+ <li><code>Camera</code></li>
24
+ <li><code>SkyBox</code></li>
25
+ <li><code>Bone3D</code></li>
26
+ </ul>
27
+ <h2 id="materials">Materials</h2>
28
+ <ul>
29
+ <li><code>BasicMaterial</code></li>
30
+ <li><code>LambertMaterial</code></li>
31
+ <li><code>PhongMaterial</code></li>
32
+ <li><code>StandardMaterial</code></li>
33
+ <li><code>RawMaterial</code></li>
34
+ <li>Debug variants (<code>NormalMaterial</code>, <code>DepthMaterial</code>)</li>
35
+ </ul>
36
+ <h2 id="lighting">Lighting</h2>
37
+ <ul>
38
+ <li><code>AmbientLight</code></li>
39
+ <li><code>DirectionalLight</code></li>
40
+ <li><code>PointLight</code></li>
41
+ <li><code>SpotLight</code></li>
42
+ <li>Shadow helpers</li>
43
+ </ul>
44
+ <h2 id="geometry-and-mesh">Geometry and Mesh</h2>
45
+ <ul>
46
+ <li><code>Mesh</code></li>
47
+ <li>Mesh builders: <code>PlaneMeshBuilder</code>, <code>CuboidMeshBuilder</code>, <code>UVSphereMeshBuilder</code>, etc.</li>
48
+ <li><code>Attribute</code> and attribute-data utilities</li>
49
+ </ul>
50
+ <h2 id="camera-and-control">Camera and Control</h2>
51
+ <ul>
52
+ <li><code>PerspectiveProjection</code></li>
53
+ <li><code>OrthographicProjection</code></li>
54
+ <li><code>OrbitCameraControls</code></li>
55
+ </ul>
56
+ <h2 id="assets-and-textures">Assets and Textures</h2>
57
+ <ul>
58
+ <li><code>TextureLoader</code></li>
59
+ <li><code>OBJLoader</code></li>
60
+ <li><code>GLTFLoader</code></li>
61
+ <li><code>Texture</code>, <code>Sampler</code></li>
62
+ </ul>
63
+ <h2 id="render-targets">Render Targets</h2>
64
+ <ul>
65
+ <li><code>CanvasTarget</code></li>
66
+ <li><code>ImageTarget</code></li>
67
+ <li><code>RenderTarget</code></li>
68
+ </ul>
69
+ <h2 id="plugins">Plugins</h2>
70
+ <ul>
71
+ <li><code>CameraPlugin</code></li>
72
+ <li><code>MeshMaterialPlugin</code></li>
73
+ <li><code>LightPlugin</code></li>
74
+ <li><code>ShadowPlugin</code></li>
75
+ <li><code>SkyboxPlugin</code></li>
76
+ </ul>
77
+ <p>For real usage patterns:</p>
78
+ <ul>
79
+ <li><a href="/examples/other/rotatingCube">Rotating Cube</a></li>
80
+ <li><a href="/examples">Examples Overview</a></li>
81
+ </ul>
82
+ </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,62 @@
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>Camera and Controls | 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" class="is-active">Camera and Controls</a><ul class="subtabs"><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="camera-and-controls">Camera and Controls</h1>
3
+ <p>This guide assumes you already have a working render loop from <a href="/guide/first-scene">First Scene</a>.
4
+ Here, we only focus on camera setup and controls.</p>
5
+ <h2 id="what-you-will-add">What You Will Add</h2>
6
+ <ul>
7
+ <li>one camera bound to a render target</li>
8
+ <li>a perspective projection setup</li>
9
+ <li>orbit controls for mouse/touch navigation</li>
10
+ </ul>
11
+ <h2 id="step-1-import-camera-apis">Step 1: Import Camera APIs</h2>
12
+ <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>
13
+ <span class="line"><span style="color:#E1E4E8"> Camera,</span></span>
14
+ <span class="line"><span style="color:#E1E4E8"> PerspectiveProjection,</span></span>
15
+ <span class="line"><span style="color:#E1E4E8"> OrthographicProjection,</span></span>
16
+ <span class="line"><span style="color:#E1E4E8"> OrbitCameraControls</span></span>
17
+ <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>
18
+ <p>You only need <code>OrthographicProjection</code> if you plan to switch projection type.</p>
19
+ <h2 id="step-2-create-a-camera">Step 2: Create a Camera</h2>
20
+ <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"> 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>
21
+ <span class="line"><span style="color:#E1E4E8">camera.transform.position.z </span><span style="color:#F97583">=</span><span style="color:#79B8FF"> 3</span><span style="color:#E1E4E8">;</span></span></code></pre>
22
+ <p><code>target</code> should be your existing <code>CanvasTarget</code>.
23
+ The <code>z</code> offset keeps objects visible in front of the camera.</p>
24
+ <h2 id="step-3-configure-perspective-projection">Step 3: Configure Perspective Projection</h2>
25
+ <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">if</span><span style="color:#E1E4E8"> (camera.projection </span><span style="color:#F97583">instanceof</span><span style="color:#B392F0"> PerspectiveProjection</span><span style="color:#E1E4E8">) {</span></span>
26
+ <span class="line"><span style="color:#E1E4E8"> camera.projection.fov </span><span style="color:#F97583">=</span><span style="color:#E1E4E8"> Math.</span><span style="color:#79B8FF">PI</span><span style="color:#F97583"> /</span><span style="color:#79B8FF"> 3</span><span style="color:#E1E4E8">;</span></span>
27
+ <span class="line"><span style="color:#E1E4E8"> camera.projection.aspect </span><span style="color:#F97583">=</span><span style="color:#E1E4E8"> innerWidth </span><span style="color:#F97583">/</span><span style="color:#E1E4E8"> innerHeight;</span></span>
28
+ <span class="line"><span style="color:#E1E4E8">}</span></span></code></pre>
29
+ <p>Use this as the default for most real-time 3D scenes.</p>
30
+ <h2 id="step-4-add-orbit-controls">Step 4: Add Orbit Controls</h2>
31
+ <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"> controls</span><span style="color:#F97583"> =</span><span style="color:#F97583"> new</span><span style="color:#B392F0"> OrbitCameraControls</span><span style="color:#E1E4E8">(camera, canvas);</span></span>
32
+ <span class="line"><span style="color:#E1E4E8">controls.distance </span><span style="color:#F97583">=</span><span style="color:#79B8FF"> 4</span><span style="color:#E1E4E8">;</span></span></code></pre>
33
+ <p><code>canvas</code> should be the element receiving pointer input.
34
+ <code>distance</code> controls how far the orbit camera stays from its target.</p>
35
+ <h2 id="step-5-update-controls-in-the-frame-loop">Step 5: Update Controls in the Frame Loop</h2>
36
+ <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>
37
+ <span class="line"><span style="color:#E1E4E8"> controls.</span><span style="color:#B392F0">update</span><span style="color:#E1E4E8">();</span></span>
38
+ <span class="line"><span style="color:#E1E4E8"> renderer.</span><span style="color:#B392F0">render</span><span style="color:#E1E4E8">([object, camera], device);</span></span>
39
+ <span class="line"><span style="color:#B392F0"> requestAnimationFrame</span><span style="color:#E1E4E8">(frame);</span></span>
40
+ <span class="line"><span style="color:#E1E4E8">}</span></span>
41
+ <span class="line"></span>
42
+ <span class="line"><span style="color:#B392F0">requestAnimationFrame</span><span style="color:#E1E4E8">(frame);</span></span></code></pre>
43
+ <p>Call <code>controls.update()</code> every frame before rendering.
44
+ If you skip it, input changes will not be applied.</p>
45
+ <h2 id="switch-to-orthographic-projection">Switch to Orthographic Projection</h2>
46
+ <p>Use orthographic projection when you need no perspective foreshortening.</p>
47
+ <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"> ortho</span><span style="color:#F97583"> =</span><span style="color:#F97583"> new</span><span style="color:#B392F0"> OrthographicProjection</span><span style="color:#E1E4E8">();</span></span>
48
+ <span class="line"><span style="color:#E1E4E8">ortho.left </span><span style="color:#F97583">=</span><span style="color:#F97583"> -</span><span style="color:#79B8FF">5</span><span style="color:#E1E4E8">;</span></span>
49
+ <span class="line"><span style="color:#E1E4E8">ortho.right </span><span style="color:#F97583">=</span><span style="color:#79B8FF"> 5</span><span style="color:#E1E4E8">;</span></span>
50
+ <span class="line"><span style="color:#E1E4E8">ortho.top </span><span style="color:#F97583">=</span><span style="color:#79B8FF"> 5</span><span style="color:#E1E4E8">;</span></span>
51
+ <span class="line"><span style="color:#E1E4E8">ortho.bottom </span><span style="color:#F97583">=</span><span style="color:#F97583"> -</span><span style="color:#79B8FF">5</span><span style="color:#E1E4E8">;</span></span>
52
+ <span class="line"></span>
53
+ <span class="line"><span style="color:#E1E4E8">camera.projection </span><span style="color:#F97583">=</span><span style="color:#E1E4E8"> ortho;</span></span></code></pre>
54
+ <p>For orthographic cameras, update bounds yourself when viewport shape changes.</p>
55
+ <h2 id="reference-examples">Reference Examples</h2>
56
+ <p>If you want to compare against an example, see:</p>
57
+ <ul>
58
+ <li><a href="/examples/camera/perspective">Perspective Camera</a></li>
59
+ <li><a href="/examples/camera/orthographic">Orthographic Camera</a></li>
60
+ </ul>
61
+ <p>After this works, continue with <a href="/guide/materials-and-lighting">Materials and Lighting</a>.</p>
62
+ </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,119 @@
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>First Scene | 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" class="is-active">First Scene</a><ul class="subtabs"><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="first-scene">First Scene</h1>
3
+ <p>This guide helps you render your first object on screen with the smallest useful setup.
4
+ You will build one scene with:</p>
5
+ <ul>
6
+ <li>one canvas</li>
7
+ <li>one render device</li>
8
+ <li>one renderer</li>
9
+ <li>one camera</li>
10
+ <li>one cube mesh</li>
11
+ <li>one animation loop</li>
12
+ </ul>
13
+ <p>The goal is to get a stable baseline you can reuse in every new project.</p>
14
+ <h2 id="what-you-will-build">What You Will Build</h2>
15
+ <p>At the end, you will have a rotating cube rendered each frame.
16
+ No lighting setup, model loading, or advanced scene graph features are required here.
17
+ Those topics are covered in other dedicated guides.</p>
18
+ <h2 id="before-you-start">Before You Start</h2>
19
+ <p>Make sure you already have a working local install from <a href="/guide/installation">Installation</a>.
20
+ You should be able to import from <code>chorama</code> or your local alias path.</p>
21
+ <h2 id="build-your-first-scene">Build Your first scene</h2>
22
+ <p>In your source file, do the following:</p>
23
+ <h3 id="step-1-import-what-you-need">Step 1: Import what you need</h3>
24
+ <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>
25
+ <span class="line"><span style="color:#E1E4E8"> WebGLRenderDevice,</span></span>
26
+ <span class="line"><span style="color:#E1E4E8"> CanvasTarget,</span></span>
27
+ <span class="line"><span style="color:#E1E4E8"> WebGLRenderer,</span></span>
28
+ <span class="line"><span style="color:#E1E4E8"> Camera,</span></span>
29
+ <span class="line"><span style="color:#E1E4E8"> PerspectiveProjection,</span></span>
30
+ <span class="line"><span style="color:#E1E4E8"> MeshMaterial3D,</span></span>
31
+ <span class="line"><span style="color:#E1E4E8"> BasicMaterial,</span></span>
32
+ <span class="line"><span style="color:#E1E4E8"> CuboidMeshBuilder,</span></span>
33
+ <span class="line"><span style="color:#E1E4E8"> Quaternion,</span></span>
34
+ <span class="line"><span style="color:#E1E4E8"> MeshMaterialPlugin,</span></span>
35
+ <span class="line"><span style="color:#E1E4E8"> CameraPlugin</span></span>
36
+ <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>
37
+ <p>This imports all the items we require for this setup.</p>
38
+ <h3 id="step-2-create-and-mount-a-canvas">Step 2: Create and mount a canvas</h3>
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"> 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>
40
+ <span class="line"><span style="color:#E1E4E8">document.body.</span><span style="color:#B392F0">append</span><span style="color:#E1E4E8">(canvas);</span></span></code></pre>
41
+ <p>Create the canvas and appends it to the body of the html document</p>
42
+ <h3 id="step-3-create-device-and-render-target">Step 3: Create device and render target</h3>
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"> 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>
44
+ <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></code></pre>
45
+ <p>The <code>device</code> manages GPU-side rendering operations.
46
+ The <code>target</code> is the camera output surface.</p>
47
+ <h3 id="step-4-create-renderer-and-required-plugins">Step 4: Create renderer and required plugins</h3>
48
+ <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>
49
+ <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>
50
+ <span class="line"><span style="color:#E1E4E8">});</span></span></code></pre>
51
+ <p>These two plugins are required for this scene:</p>
52
+ <ul>
53
+ <li><code>MeshMaterialPlugin</code> draws mesh plus material objects.</li>
54
+ <li><code>CameraPlugin</code> enables camera processing in the render pass.</li>
55
+ </ul>
56
+ <h3 id="step-5-create-and-position-a-camera">Step 5: Create and position a camera</h3>
57
+ <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"> 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>
58
+ <span class="line"><span style="color:#E1E4E8">camera.transform.position.z </span><span style="color:#F97583">=</span><span style="color:#79B8FF"> 2.5</span><span style="color:#E1E4E8">;</span></span>
59
+ <span class="line"></span>
60
+ <span class="line"><span style="color:#F97583">if</span><span style="color:#E1E4E8"> (camera.projection </span><span style="color:#F97583">instanceof</span><span style="color:#B392F0"> PerspectiveProjection</span><span style="color:#E1E4E8">) {</span></span>
61
+ <span class="line"><span style="color:#E1E4E8"> camera.projection.fov </span><span style="color:#F97583">=</span><span style="color:#E1E4E8"> Math.</span><span style="color:#79B8FF">PI</span><span style="color:#F97583"> /</span><span style="color:#79B8FF"> 3</span><span style="color:#E1E4E8">;</span></span>
62
+ <span class="line"><span style="color:#E1E4E8"> camera.projection.aspect </span><span style="color:#F97583">=</span><span style="color:#79B8FF"> 1</span><span style="color:#E1E4E8">;</span></span>
63
+ <span class="line"><span style="color:#E1E4E8">}</span></span></code></pre>
64
+ <p>Moving camera on <code>z</code> ensures the cube is in front of the view.
65
+ The initial <code>aspect</code> is a temporary placeholder; resize will set the real value.</p>
66
+ <h3 id="step-6-create-a-cube-object">Step 6: Create a cube object</h3>
67
+ <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"> cubeMesh</span><span style="color:#F97583"> =</span><span style="color:#F97583"> new</span><span style="color:#B392F0"> CuboidMeshBuilder</span><span style="color:#E1E4E8">().</span><span style="color:#B392F0">build</span><span style="color:#E1E4E8">();</span></span>
68
+ <span class="line"><span style="color:#F97583">const</span><span style="color:#79B8FF"> cubeMaterial</span><span style="color:#F97583"> =</span><span style="color:#F97583"> new</span><span style="color:#B392F0"> BasicMaterial</span><span style="color:#E1E4E8">();</span></span>
69
+ <span class="line"><span style="color:#F97583">const</span><span style="color:#79B8FF"> cube</span><span style="color:#F97583"> =</span><span style="color:#F97583"> new</span><span style="color:#B392F0"> MeshMaterial3D</span><span style="color:#E1E4E8">(cubeMesh, cubeMaterial);</span></span></code></pre>
70
+ <p>This creates one drawable object with default shading.
71
+ Using <code>BasicMaterial</code> for an object that has no lighting applied to it.</p>
72
+ <h3 id="step-7-define-per-frame-rotation">Step 7: Define per-frame rotation</h3>
73
+ <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"> stepRotation</span><span style="color:#F97583"> =</span><span style="color:#E1E4E8"> Quaternion.</span><span style="color:#B392F0">fromEuler</span><span style="color:#E1E4E8">(</span><span style="color:#79B8FF">0.01</span><span style="color:#E1E4E8">, </span><span style="color:#79B8FF">0.01</span><span style="color:#E1E4E8">, </span><span style="color:#79B8FF">0.0</span><span style="color:#E1E4E8">);</span></span></code></pre>
74
+ <p>This rotation is multiplied into cube orientation each frame to animate motion.</p>
75
+ <h3 id="step-8-add-resize-handling">Step 8: Add resize handling</h3>
76
+ <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"> resize</span><span style="color:#E1E4E8">() {</span></span>
77
+ <span class="line"><span style="color:#F97583"> const</span><span style="color:#79B8FF"> cssWidth</span><span style="color:#F97583"> =</span><span style="color:#E1E4E8"> window.innerWidth;</span></span>
78
+ <span class="line"><span style="color:#F97583"> const</span><span style="color:#79B8FF"> cssHeight</span><span style="color:#F97583"> =</span><span style="color:#E1E4E8"> window.innerHeight;</span></span>
79
+ <span class="line"><span style="color:#F97583"> const</span><span style="color:#79B8FF"> dpr</span><span style="color:#F97583"> =</span><span style="color:#E1E4E8"> window.devicePixelRatio </span><span style="color:#F97583">||</span><span style="color:#79B8FF"> 1</span><span style="color:#E1E4E8">;</span></span>
80
+ <span class="line"></span>
81
+ <span class="line"><span style="color:#E1E4E8"> canvas.style.width </span><span style="color:#F97583">=</span><span style="color:#E1E4E8"> cssWidth </span><span style="color:#F97583">+</span><span style="color:#9ECBFF"> "px"</span><span style="color:#E1E4E8">;</span></span>
82
+ <span class="line"><span style="color:#E1E4E8"> canvas.style.height </span><span style="color:#F97583">=</span><span style="color:#E1E4E8"> cssHeight </span><span style="color:#F97583">+</span><span style="color:#9ECBFF"> "px"</span><span style="color:#E1E4E8">;</span></span>
83
+ <span class="line"><span style="color:#E1E4E8"> canvas.width </span><span style="color:#F97583">=</span><span style="color:#E1E4E8"> Math.</span><span style="color:#B392F0">floor</span><span style="color:#E1E4E8">(cssWidth </span><span style="color:#F97583">*</span><span style="color:#E1E4E8"> dpr);</span></span>
84
+ <span class="line"><span style="color:#E1E4E8"> canvas.height </span><span style="color:#F97583">=</span><span style="color:#E1E4E8"> Math.</span><span style="color:#B392F0">floor</span><span style="color:#E1E4E8">(cssHeight </span><span style="color:#F97583">*</span><span style="color:#E1E4E8"> dpr);</span></span>
85
+ <span class="line"></span>
86
+ <span class="line"><span style="color:#F97583"> if</span><span style="color:#E1E4E8"> (camera.projection </span><span style="color:#F97583">instanceof</span><span style="color:#B392F0"> PerspectiveProjection</span><span style="color:#E1E4E8">) {</span></span>
87
+ <span class="line"><span style="color:#E1E4E8"> camera.projection.aspect </span><span style="color:#F97583">=</span><span style="color:#E1E4E8"> cssWidth </span><span style="color:#F97583">/</span><span style="color:#E1E4E8"> cssHeight;</span></span>
88
+ <span class="line"><span style="color:#E1E4E8"> }</span></span>
89
+ <span class="line"><span style="color:#E1E4E8">}</span></span>
90
+ <span class="line"></span>
91
+ <span class="line"><span style="color:#E1E4E8">window.</span><span style="color:#B392F0">addEventListener</span><span style="color:#E1E4E8">(</span><span style="color:#9ECBFF">"resize"</span><span style="color:#E1E4E8">, resize);</span></span>
92
+ <span class="line"><span style="color:#B392F0">resize</span><span style="color:#E1E4E8">();</span></span></code></pre>
93
+ <p>This keeps render resolution sharp and camera projection correct.
94
+ If you skip this, stretching and blur are likely on resize or high-DPI screens.</p>
95
+ <h3 id="step-9-start-the-render-loop">Step 9: Start the render loop</h3>
96
+ <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>
97
+ <span class="line"><span style="color:#E1E4E8"> cube.transform.orientation.</span><span style="color:#B392F0">multiply</span><span style="color:#E1E4E8">(stepRotation);</span></span>
98
+ <span class="line"><span style="color:#E1E4E8"> renderer.</span><span style="color:#B392F0">render</span><span style="color:#E1E4E8">([cube, camera], device);</span></span>
99
+ <span class="line"><span style="color:#B392F0"> requestAnimationFrame</span><span style="color:#E1E4E8">(frame);</span></span>
100
+ <span class="line"><span style="color:#E1E4E8">}</span></span>
101
+ <span class="line"></span>
102
+ <span class="line"><span style="color:#B392F0">requestAnimationFrame</span><span style="color:#E1E4E8">(frame);</span></span></code></pre>
103
+ <p>Each frame does three things: update state, render, schedule next frame.</p>
104
+ <h2 id="what-you-can-try-next">What You Can Try Next</h2>
105
+ <p>Change only one variable at a time:</p>
106
+ <ul>
107
+ <li>move camera: <code>camera.transform.position.z = 4</code></li>
108
+ <li>stop rotation: remove <code>cube.transform.orientation.multiply(stepRotation)</code></li>
109
+ <li>rotate one axis only: <code>Quaternion.fromEuler(0.0, 0.01, 0.0)</code></li>
110
+ <li>change shape: replace <code>CuboidMeshBuilder</code> with another mesh builder</li>
111
+ </ul>
112
+ <p>These changes help verify your scene wiring before adding complexity.</p>
113
+ <h2 id="reference-example">Reference Example</h2>
114
+ <p>If you want to compare against an example, see:</p>
115
+ <ul>
116
+ <li><a href="/examples/other/rotatingCube">Rotating Cube</a></li>
117
+ </ul>
118
+ <p>After this works, continue with <a href="/guide/camera-and-controls">Camera and Controls</a>.</p>
119
+ </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>