@zephyr3d/scene 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (236) hide show
  1. package/dist/animation/animation.js +173 -0
  2. package/dist/animation/animation.js.map +1 -0
  3. package/dist/animation/animationset.js +95 -0
  4. package/dist/animation/animationset.js.map +1 -0
  5. package/dist/animation/animationtrack.js +38 -0
  6. package/dist/animation/animationtrack.js.map +1 -0
  7. package/dist/animation/eulerrotationtrack.js +33 -0
  8. package/dist/animation/eulerrotationtrack.js.map +1 -0
  9. package/dist/animation/rotationtrack.js +37 -0
  10. package/dist/animation/rotationtrack.js.map +1 -0
  11. package/dist/animation/scaletrack.js +36 -0
  12. package/dist/animation/scaletrack.js.map +1 -0
  13. package/dist/animation/skeleton.js +97 -0
  14. package/dist/animation/skeleton.js.map +1 -0
  15. package/dist/animation/translationtrack.js +36 -0
  16. package/dist/animation/translationtrack.js.map +1 -0
  17. package/dist/animation/usertrack.js +47 -0
  18. package/dist/animation/usertrack.js.map +1 -0
  19. package/dist/app.js +173 -0
  20. package/dist/app.js.map +1 -0
  21. package/dist/asset/assetmanager.js +476 -0
  22. package/dist/asset/assetmanager.js.map +1 -0
  23. package/dist/asset/builtin.js +373 -0
  24. package/dist/asset/builtin.js.map +1 -0
  25. package/dist/asset/loaders/dds/dds.js +472 -0
  26. package/dist/asset/loaders/dds/dds.js.map +1 -0
  27. package/dist/asset/loaders/dds/dds_loader.js +38 -0
  28. package/dist/asset/loaders/dds/dds_loader.js.map +1 -0
  29. package/dist/asset/loaders/gltf/gltf_loader.js +981 -0
  30. package/dist/asset/loaders/gltf/gltf_loader.js.map +1 -0
  31. package/dist/asset/loaders/gltf/helpers.js +314 -0
  32. package/dist/asset/loaders/gltf/helpers.js.map +1 -0
  33. package/dist/asset/loaders/hdr/hdr.js +175 -0
  34. package/dist/asset/loaders/hdr/hdr.js.map +1 -0
  35. package/dist/asset/loaders/image/tga_Loader.js +117 -0
  36. package/dist/asset/loaders/image/tga_Loader.js.map +1 -0
  37. package/dist/asset/loaders/image/webimage_loader.js +50 -0
  38. package/dist/asset/loaders/image/webimage_loader.js.map +1 -0
  39. package/dist/asset/loaders/loader.js +45 -0
  40. package/dist/asset/loaders/loader.js.map +1 -0
  41. package/dist/asset/model.js +264 -0
  42. package/dist/asset/model.js.map +1 -0
  43. package/dist/blitter/blitter.js +389 -0
  44. package/dist/blitter/blitter.js.map +1 -0
  45. package/dist/blitter/box.js +118 -0
  46. package/dist/blitter/box.js.map +1 -0
  47. package/dist/blitter/copy.js +22 -0
  48. package/dist/blitter/copy.js.map +1 -0
  49. package/dist/blitter/depthlimitedgaussion.js +166 -0
  50. package/dist/blitter/depthlimitedgaussion.js.map +1 -0
  51. package/dist/blitter/gaussianblur.js +229 -0
  52. package/dist/blitter/gaussianblur.js.map +1 -0
  53. package/dist/camera/base.js +90 -0
  54. package/dist/camera/base.js.map +1 -0
  55. package/dist/camera/camera.js +358 -0
  56. package/dist/camera/camera.js.map +1 -0
  57. package/dist/camera/fps.js +246 -0
  58. package/dist/camera/fps.js.map +1 -0
  59. package/dist/camera/orbit.js +157 -0
  60. package/dist/camera/orbit.js.map +1 -0
  61. package/dist/camera/orthocamera.js +126 -0
  62. package/dist/camera/orthocamera.js.map +1 -0
  63. package/dist/camera/perspectivecamera.js +133 -0
  64. package/dist/camera/perspectivecamera.js.map +1 -0
  65. package/dist/index.d.ts +8402 -0
  66. package/dist/index.js +87 -0
  67. package/dist/index.js.map +1 -0
  68. package/dist/input/inputmgr.js +242 -0
  69. package/dist/input/inputmgr.js.map +1 -0
  70. package/dist/material/blinn.js +75 -0
  71. package/dist/material/blinn.js.map +1 -0
  72. package/dist/material/grassmaterial.js +221 -0
  73. package/dist/material/grassmaterial.js.map +1 -0
  74. package/dist/material/lambert.js +52 -0
  75. package/dist/material/lambert.js.map +1 -0
  76. package/dist/material/lightmodel.js +2074 -0
  77. package/dist/material/lightmodel.js.map +1 -0
  78. package/dist/material/lit.js +578 -0
  79. package/dist/material/lit.js.map +1 -0
  80. package/dist/material/material.js +458 -0
  81. package/dist/material/material.js.map +1 -0
  82. package/dist/material/meshmaterial.js +311 -0
  83. package/dist/material/meshmaterial.js.map +1 -0
  84. package/dist/material/mixins/albedocolor.js +130 -0
  85. package/dist/material/mixins/albedocolor.js.map +1 -0
  86. package/dist/material/mixins/texture.js +110 -0
  87. package/dist/material/mixins/texture.js.map +1 -0
  88. package/dist/material/mixins/vertexcolor.js +45 -0
  89. package/dist/material/mixins/vertexcolor.js.map +1 -0
  90. package/dist/material/pbr.js +27 -0
  91. package/dist/material/pbr.js.map +1 -0
  92. package/dist/material/standard.js +282 -0
  93. package/dist/material/standard.js.map +1 -0
  94. package/dist/material/terrainlightmodel.js +259 -0
  95. package/dist/material/terrainlightmodel.js.map +1 -0
  96. package/dist/material/terrainmaterial.js +139 -0
  97. package/dist/material/terrainmaterial.js.map +1 -0
  98. package/dist/material/unlit.js +29 -0
  99. package/dist/material/unlit.js.map +1 -0
  100. package/dist/posteffect/bloom.js +398 -0
  101. package/dist/posteffect/bloom.js.map +1 -0
  102. package/dist/posteffect/compositor.js +264 -0
  103. package/dist/posteffect/compositor.js.map +1 -0
  104. package/dist/posteffect/fxaa.js +291 -0
  105. package/dist/posteffect/fxaa.js.map +1 -0
  106. package/dist/posteffect/grayscale.js +87 -0
  107. package/dist/posteffect/grayscale.js.map +1 -0
  108. package/dist/posteffect/posteffect.js +165 -0
  109. package/dist/posteffect/posteffect.js.map +1 -0
  110. package/dist/posteffect/sao.js +327 -0
  111. package/dist/posteffect/sao.js.map +1 -0
  112. package/dist/posteffect/tonemap.js +112 -0
  113. package/dist/posteffect/tonemap.js.map +1 -0
  114. package/dist/posteffect/water.js +535 -0
  115. package/dist/posteffect/water.js.map +1 -0
  116. package/dist/render/clipmap.js +462 -0
  117. package/dist/render/clipmap.js.map +1 -0
  118. package/dist/render/cluster_light.js +329 -0
  119. package/dist/render/cluster_light.js.map +1 -0
  120. package/dist/render/cull_visitor.js +124 -0
  121. package/dist/render/cull_visitor.js.map +1 -0
  122. package/dist/render/depth_pass.js +47 -0
  123. package/dist/render/depth_pass.js.map +1 -0
  124. package/dist/render/envlight.js +282 -0
  125. package/dist/render/envlight.js.map +1 -0
  126. package/dist/render/forward.js +186 -0
  127. package/dist/render/forward.js.map +1 -0
  128. package/dist/render/forward_pass.js +137 -0
  129. package/dist/render/forward_pass.js.map +1 -0
  130. package/dist/render/helper.js +38 -0
  131. package/dist/render/helper.js.map +1 -0
  132. package/dist/render/primitive.js +246 -0
  133. package/dist/render/primitive.js.map +1 -0
  134. package/dist/render/render_queue.js +163 -0
  135. package/dist/render/render_queue.js.map +1 -0
  136. package/dist/render/renderpass.js +151 -0
  137. package/dist/render/renderpass.js.map +1 -0
  138. package/dist/render/renderscheme.js +61 -0
  139. package/dist/render/renderscheme.js.map +1 -0
  140. package/dist/render/scatteringlut.js +634 -0
  141. package/dist/render/scatteringlut.js.map +1 -0
  142. package/dist/render/shadowmap_pass.js +70 -0
  143. package/dist/render/shadowmap_pass.js.map +1 -0
  144. package/dist/render/sky.js +881 -0
  145. package/dist/render/sky.js.map +1 -0
  146. package/dist/render/temporalcache.js +222 -0
  147. package/dist/render/temporalcache.js.map +1 -0
  148. package/dist/render/watermesh.js +835 -0
  149. package/dist/render/watermesh.js.map +1 -0
  150. package/dist/scene/environment.js +146 -0
  151. package/dist/scene/environment.js.map +1 -0
  152. package/dist/scene/graph_node.js +69 -0
  153. package/dist/scene/graph_node.js.map +1 -0
  154. package/dist/scene/light.js +436 -0
  155. package/dist/scene/light.js.map +1 -0
  156. package/dist/scene/mesh.js +215 -0
  157. package/dist/scene/mesh.js.map +1 -0
  158. package/dist/scene/model.js +111 -0
  159. package/dist/scene/model.js.map +1 -0
  160. package/dist/scene/octree.js +651 -0
  161. package/dist/scene/octree.js.map +1 -0
  162. package/dist/scene/octree_update_visitor.js +16 -0
  163. package/dist/scene/octree_update_visitor.js.map +1 -0
  164. package/dist/scene/raycast_visitor.js +72 -0
  165. package/dist/scene/raycast_visitor.js.map +1 -0
  166. package/dist/scene/scene.js +225 -0
  167. package/dist/scene/scene.js.map +1 -0
  168. package/dist/scene/scene_node.js +299 -0
  169. package/dist/scene/scene_node.js.map +1 -0
  170. package/dist/scene/terrain/grass.js +277 -0
  171. package/dist/scene/terrain/grass.js.map +1 -0
  172. package/dist/scene/terrain/heightfield.js +391 -0
  173. package/dist/scene/terrain/heightfield.js.map +1 -0
  174. package/dist/scene/terrain/patch.js +530 -0
  175. package/dist/scene/terrain/patch.js.map +1 -0
  176. package/dist/scene/terrain/quadtree.js +430 -0
  177. package/dist/scene/terrain/quadtree.js.map +1 -0
  178. package/dist/scene/terrain/terrain.js +258 -0
  179. package/dist/scene/terrain/terrain.js.map +1 -0
  180. package/dist/scene/xform.js +224 -0
  181. package/dist/scene/xform.js.map +1 -0
  182. package/dist/shaders/builtins.js +110 -0
  183. package/dist/shaders/builtins.js.map +1 -0
  184. package/dist/shaders/framework.js +709 -0
  185. package/dist/shaders/framework.js.map +1 -0
  186. package/dist/shaders/lighting.js +335 -0
  187. package/dist/shaders/lighting.js.map +1 -0
  188. package/dist/shaders/misc.js +405 -0
  189. package/dist/shaders/misc.js.map +1 -0
  190. package/dist/shaders/noise.js +157 -0
  191. package/dist/shaders/noise.js.map +1 -0
  192. package/dist/shaders/pbr.js +132 -0
  193. package/dist/shaders/pbr.js.map +1 -0
  194. package/dist/shaders/shadow.js +642 -0
  195. package/dist/shaders/shadow.js.map +1 -0
  196. package/dist/shaders/water.js +630 -0
  197. package/dist/shaders/water.js.map +1 -0
  198. package/dist/shadow/esm.js +235 -0
  199. package/dist/shadow/esm.js.map +1 -0
  200. package/dist/shadow/pcf_opt.js +182 -0
  201. package/dist/shadow/pcf_opt.js.map +1 -0
  202. package/dist/shadow/pcf_pd.js +190 -0
  203. package/dist/shadow/pcf_pd.js.map +1 -0
  204. package/dist/shadow/shadow_impl.js +15 -0
  205. package/dist/shadow/shadow_impl.js.map +1 -0
  206. package/dist/shadow/shadowmapper.js +709 -0
  207. package/dist/shadow/shadowmapper.js.map +1 -0
  208. package/dist/shadow/ssm.js +194 -0
  209. package/dist/shadow/ssm.js.map +1 -0
  210. package/dist/shadow/vsm.js +298 -0
  211. package/dist/shadow/vsm.js.map +1 -0
  212. package/dist/shapes/box.js +313 -0
  213. package/dist/shapes/box.js.map +1 -0
  214. package/dist/shapes/cylinder.js +74 -0
  215. package/dist/shapes/cylinder.js.map +1 -0
  216. package/dist/shapes/plane.js +48 -0
  217. package/dist/shapes/plane.js.map +1 -0
  218. package/dist/shapes/shape.js +33 -0
  219. package/dist/shapes/shape.js.map +1 -0
  220. package/dist/shapes/sphere.js +91 -0
  221. package/dist/shapes/sphere.js.map +1 -0
  222. package/dist/shapes/torus.js +100 -0
  223. package/dist/shapes/torus.js.map +1 -0
  224. package/dist/utility/aabbtree.js +390 -0
  225. package/dist/utility/aabbtree.js.map +1 -0
  226. package/dist/utility/bounding_volume.js +78 -0
  227. package/dist/utility/bounding_volume.js.map +1 -0
  228. package/dist/utility/panorama.js +163 -0
  229. package/dist/utility/panorama.js.map +1 -0
  230. package/dist/utility/pmrem.js +345 -0
  231. package/dist/utility/pmrem.js.map +1 -0
  232. package/dist/utility/shprojection.js +448 -0
  233. package/dist/utility/shprojection.js.map +1 -0
  234. package/dist/values.js +48 -0
  235. package/dist/values.js.map +1 -0
  236. package/package.json +70 -0
@@ -0,0 +1,472 @@
1
+ /* eslint-disable @typescript-eslint/no-unused-vars */ const DDSHeaderSize = 31; // in DWORD
2
+ const DDSHeaderSizeExtended = 31 + 5; // in DWORD
3
+ const DDS_MAGIC = 0x20534444; // magic
4
+ const DDPF_ALPHAPIXELS = 0x1;
5
+ const DDPF_ALPHA = 0x2;
6
+ const DDPF_FOURCC = 0x4;
7
+ const DDPF_RGB = 0x40;
8
+ const DDPF_LUMINANCE = 0x20000;
9
+ const DDSCAPS2_CUBEMAP = 0x200;
10
+ const DDSCAPS2_CUBEMAP_POSITIVEX = 0x400;
11
+ const DDSCAPS2_CUBEMAP_NEGATIVEX = 0x800;
12
+ const DDSCAPS2_CUBEMAP_POSITIVEY = 0x1000;
13
+ const DDSCAPS2_CUBEMAP_NEGATIVEY = 0x2000;
14
+ const DDSCAPS2_CUBEMAP_POSITIVEZ = 0x4000;
15
+ const DDSCAPS2_CUBEMAP_NEGATIVEZ = 0x8000;
16
+ const DDS_CUBEMAP_ALLFACES = DDSCAPS2_CUBEMAP | DDSCAPS2_CUBEMAP_POSITIVEX | DDSCAPS2_CUBEMAP_NEGATIVEX | DDSCAPS2_CUBEMAP_POSITIVEY | DDSCAPS2_CUBEMAP_NEGATIVEY | DDSCAPS2_CUBEMAP_POSITIVEZ | DDSCAPS2_CUBEMAP_NEGATIVEZ;
17
+ const DDSCAPS2_VOLUME = 0x200000;
18
+ var DX10ResourceDimension;
19
+ (function(DX10ResourceDimension) {
20
+ DX10ResourceDimension[DX10ResourceDimension["DDS_DIMENSION_TEXTURE1D"] = 2] = "DDS_DIMENSION_TEXTURE1D";
21
+ DX10ResourceDimension[DX10ResourceDimension["DDS_DIMENSION_TEXTURE2D"] = 3] = "DDS_DIMENSION_TEXTURE2D";
22
+ DX10ResourceDimension[DX10ResourceDimension["DDS_DIMENSION_TEXTURE3D"] = 4] = "DDS_DIMENSION_TEXTURE3D";
23
+ })(DX10ResourceDimension || (DX10ResourceDimension = {}));
24
+ var DXGIFormat;
25
+ (function(DXGIFormat) {
26
+ DXGIFormat[DXGIFormat["DXGI_FORMAT_RGBA32F"] = 2] = "DXGI_FORMAT_RGBA32F";
27
+ DXGIFormat[DXGIFormat["DXGI_FORMAT_RGBA32UI"] = 3] = "DXGI_FORMAT_RGBA32UI";
28
+ DXGIFormat[DXGIFormat["DXGI_FORMAT_RGBA32I"] = 4] = "DXGI_FORMAT_RGBA32I";
29
+ DXGIFormat[DXGIFormat["DXGI_FORMAT_RGB32F"] = 6] = "DXGI_FORMAT_RGB32F";
30
+ DXGIFormat[DXGIFormat["DXGI_FORMAT_RGB32UI"] = 7] = "DXGI_FORMAT_RGB32UI";
31
+ DXGIFormat[DXGIFormat["DXGI_FORMAT_RGB32I"] = 8] = "DXGI_FORMAT_RGB32I";
32
+ DXGIFormat[DXGIFormat["DXGI_FORMAT_RGBA16F"] = 10] = "DXGI_FORMAT_RGBA16F";
33
+ DXGIFormat[DXGIFormat["DXGI_FORMAT_RGBA16UI"] = 12] = "DXGI_FORMAT_RGBA16UI";
34
+ DXGIFormat[DXGIFormat["DXGI_FORMAT_RGBA16I"] = 14] = "DXGI_FORMAT_RGBA16I";
35
+ DXGIFormat[DXGIFormat["DXGI_FORMAT_RG32F"] = 16] = "DXGI_FORMAT_RG32F";
36
+ DXGIFormat[DXGIFormat["DXGI_FORMAT_RG32UI"] = 17] = "DXGI_FORMAT_RG32UI";
37
+ DXGIFormat[DXGIFormat["DXGI_FORMAT_RG32I"] = 18] = "DXGI_FORMAT_RG32I";
38
+ DXGIFormat[DXGIFormat["DXGI_FORMAT_RGBA8"] = 28] = "DXGI_FORMAT_RGBA8";
39
+ DXGIFormat[DXGIFormat["DXGI_FORMAT_RGBA8_SRGB"] = 29] = "DXGI_FORMAT_RGBA8_SRGB";
40
+ DXGIFormat[DXGIFormat["DXGI_FORMAT_RGBA8UI"] = 30] = "DXGI_FORMAT_RGBA8UI";
41
+ DXGIFormat[DXGIFormat["DXGI_FORMAT_RGBA8I"] = 32] = "DXGI_FORMAT_RGBA8I";
42
+ DXGIFormat[DXGIFormat["DXGI_FORMAT_RG16F"] = 34] = "DXGI_FORMAT_RG16F";
43
+ DXGIFormat[DXGIFormat["DXGI_FORMAT_RG16UI"] = 36] = "DXGI_FORMAT_RG16UI";
44
+ DXGIFormat[DXGIFormat["DXGI_FORMAT_RG16I"] = 38] = "DXGI_FORMAT_RG16I";
45
+ DXGIFormat[DXGIFormat["DXGI_FORMAT_R32F"] = 41] = "DXGI_FORMAT_R32F";
46
+ DXGIFormat[DXGIFormat["DXGI_FORMAT_R32UI"] = 42] = "DXGI_FORMAT_R32UI";
47
+ DXGIFormat[DXGIFormat["DXGI_FORMAT_R32I"] = 43] = "DXGI_FORMAT_R32I";
48
+ DXGIFormat[DXGIFormat["DXGI_FORMAT_R16F"] = 54] = "DXGI_FORMAT_R16F";
49
+ DXGIFormat[DXGIFormat["DXGI_FORMAT_R16UI"] = 57] = "DXGI_FORMAT_R16UI";
50
+ DXGIFormat[DXGIFormat["DXGI_FORMAT_R16I"] = 59] = "DXGI_FORMAT_R16I";
51
+ DXGIFormat[DXGIFormat["DXGI_FORMAT_BGR565"] = 85] = "DXGI_FORMAT_BGR565";
52
+ DXGIFormat[DXGIFormat["DXGI_FORMAT_BGRA5551"] = 86] = "DXGI_FORMAT_BGRA5551";
53
+ DXGIFormat[DXGIFormat["DXGI_FORMAT_BGRA8"] = 87] = "DXGI_FORMAT_BGRA8";
54
+ DXGIFormat[DXGIFormat["DXGI_FORMAT_BGRX8"] = 88] = "DXGI_FORMAT_BGRX8";
55
+ DXGIFormat[DXGIFormat["DXGI_FORMAT_BGRA8_SRGB"] = 91] = "DXGI_FORMAT_BGRA8_SRGB";
56
+ DXGIFormat[DXGIFormat["DXGI_FORMAT_BGRX8_SRGB"] = 93] = "DXGI_FORMAT_BGRX8_SRGB";
57
+ })(DXGIFormat || (DXGIFormat = {}));
58
+ var D3DFormat;
59
+ (function(D3DFormat) {
60
+ D3DFormat[D3DFormat["D3DFMT_RGB8"] = 20] = "D3DFMT_RGB8";
61
+ D3DFormat[D3DFormat["D3DFMT_ARGB8"] = 21] = "D3DFMT_ARGB8";
62
+ D3DFormat[D3DFormat["D3DFMT_XRGB8"] = 22] = "D3DFMT_XRGB8";
63
+ D3DFormat[D3DFormat["D3DFMT_RGB565"] = 23] = "D3DFMT_RGB565";
64
+ D3DFormat[D3DFormat["D3DFMT_XRGB1555"] = 24] = "D3DFMT_XRGB1555";
65
+ D3DFormat[D3DFormat["D3DFMT_ARGB1555"] = 25] = "D3DFMT_ARGB1555";
66
+ D3DFormat[D3DFormat["D3DFMT_ARGB4"] = 26] = "D3DFMT_ARGB4";
67
+ D3DFormat[D3DFormat["D3DFMT_A8"] = 28] = "D3DFMT_A8";
68
+ D3DFormat[D3DFormat["D3DFMT_XRGB4"] = 30] = "D3DFMT_XRGB4";
69
+ D3DFormat[D3DFormat["D3DFMT_ABGR8"] = 32] = "D3DFMT_ABGR8";
70
+ D3DFormat[D3DFormat["D3DFMT_XBGR8"] = 33] = "D3DFMT_XBGR8";
71
+ D3DFormat[D3DFormat["D3DFMT_A8P8"] = 40] = "D3DFMT_A8P8";
72
+ D3DFormat[D3DFormat["D3DFMT_P8"] = 41] = "D3DFMT_P8";
73
+ D3DFormat[D3DFormat["D3DFMT_L8"] = 50] = "D3DFMT_L8";
74
+ D3DFormat[D3DFormat["D3DFMT_A8L8"] = 51] = "D3DFMT_A8L8";
75
+ D3DFormat[D3DFormat["D3DFMT_DXT1"] = FourCCToInt32('DXT1')] = "D3DFMT_DXT1";
76
+ D3DFormat[D3DFormat["D3DFMT_DXT2"] = FourCCToInt32('DXT2')] = "D3DFMT_DXT2";
77
+ D3DFormat[D3DFormat["D3DFMT_DXT3"] = FourCCToInt32('DXT3')] = "D3DFMT_DXT3";
78
+ D3DFormat[D3DFormat["D3DFMT_DXT4"] = FourCCToInt32('DXT4')] = "D3DFMT_DXT4";
79
+ D3DFormat[D3DFormat["D3DFMT_DXT5"] = FourCCToInt32('DXT5')] = "D3DFMT_DXT5";
80
+ D3DFormat[D3DFormat["D3DFMT_R16F"] = 111] = "D3DFMT_R16F";
81
+ D3DFormat[D3DFormat["D3DFMT_RG16F"] = 112] = "D3DFMT_RG16F";
82
+ D3DFormat[D3DFormat["D3DFMT_RGBA16F"] = 113] = "D3DFMT_RGBA16F";
83
+ D3DFormat[D3DFormat["D3DFMT_R32F"] = 114] = "D3DFMT_R32F";
84
+ D3DFormat[D3DFormat["D3DFMT_RG32F"] = 115] = "D3DFMT_RG32F";
85
+ D3DFormat[D3DFormat["D3DFMT_RGBA32F"] = 116] = "D3DFMT_RGBA32F";
86
+ })(D3DFormat || (D3DFormat = {}));
87
+ function FourCCToInt32(value) {
88
+ return value.charCodeAt(0) + (value.charCodeAt(1) << 8) + (value.charCodeAt(2) << 16) + (value.charCodeAt(3) << 24);
89
+ }
90
+ function Int32ToFourCC(value) {
91
+ return String.fromCharCode(value & 0xff, value >> 8 & 0xff, value >> 16 & 0xff, value >> 24 & 0xff);
92
+ }
93
+ function loadDDSHeader(dds) {
94
+ const ddsHeader = {};
95
+ const header = new Uint32Array(dds, 0, DDSHeaderSize + 1);
96
+ const magic = header[0];
97
+ if (magic !== DDS_MAGIC) {
98
+ console.log('Invalid DDS magic');
99
+ return null;
100
+ }
101
+ ddsHeader.dwSize = header[1];
102
+ if (ddsHeader.dwSize !== 124) {
103
+ console.log('Invalid DDS header size');
104
+ return null;
105
+ }
106
+ ddsHeader.dataOffset = ddsHeader.dwSize + 4;
107
+ ddsHeader.dwFlags = header[2];
108
+ ddsHeader.dwHeight = header[3];
109
+ ddsHeader.dwWidth = header[4];
110
+ ddsHeader.dwPitchOrLinearSize = header[5];
111
+ ddsHeader.dwDepth = header[6];
112
+ ddsHeader.dwMipmapCount = header[7];
113
+ ddsHeader.ddsPixelFormat = {};
114
+ ddsHeader.ddsPixelFormat.dwFlags = header[20];
115
+ ddsHeader.ddsPixelFormat.dwFourCC = header[21];
116
+ ddsHeader.ddsPixelFormat.dwRGBBitCount = header[22];
117
+ ddsHeader.ddsPixelFormat.dwRBitMask = header[23];
118
+ ddsHeader.ddsPixelFormat.dwGBitMask = header[24];
119
+ ddsHeader.ddsPixelFormat.dwBBitMask = header[25];
120
+ ddsHeader.ddsPixelFormat.dwABitMask = header[26];
121
+ ddsHeader.dwCaps = header[27];
122
+ ddsHeader.dwCaps2 = header[28];
123
+ ddsHeader.dwCaps3 = header[29];
124
+ ddsHeader.dwCaps4 = header[30];
125
+ if (Int32ToFourCC(ddsHeader.ddsPixelFormat.dwFourCC) === 'DX10') {
126
+ const headerEx = new Uint32Array(dds, 0, DDSHeaderSizeExtended + 1);
127
+ ddsHeader.ddsHeaderDX10 = {};
128
+ ddsHeader.ddsHeaderDX10.dxgiFormat = headerEx[32];
129
+ ddsHeader.ddsPixelFormat.dwFourCC = ddsHeader.ddsHeaderDX10.dxgiFormat;
130
+ ddsHeader.ddsHeaderDX10.dimension = headerEx[33];
131
+ ddsHeader.ddsHeaderDX10.miscFlag = headerEx[34];
132
+ ddsHeader.ddsHeaderDX10.arraySize = headerEx[35];
133
+ ddsHeader.dataOffset += 5 * 4;
134
+ }
135
+ return ddsHeader;
136
+ }
137
+ var DDSConvert;
138
+ (function(DDSConvert) {
139
+ DDSConvert[DDSConvert["RGB_SWIZZLE"] = 1] = "RGB_SWIZZLE";
140
+ DDSConvert[DDSConvert["ALPHA_ONE"] = 22] = "ALPHA_ONE";
141
+ })(DDSConvert || (DDSConvert = {}));
142
+ const dxgiFormatMap = {
143
+ [2]: 'rgba32f',
144
+ [3]: 'rgba32ui',
145
+ [4]: 'rgba32i',
146
+ [10]: 'rgba16f',
147
+ [12]: 'rgba16ui',
148
+ [14]: 'rgba16i',
149
+ [16]: 'rg32f',
150
+ [17]: 'rg32ui',
151
+ [18]: 'rg32i',
152
+ [28]: 'rgba8unorm',
153
+ [29]: 'rgba8unorm-srgb',
154
+ [30]: 'rgba8ui',
155
+ [31]: 'rgba8snorm',
156
+ [32]: 'rgba8i',
157
+ [34]: 'rg16f',
158
+ [36]: 'rg16ui',
159
+ [38]: 'rg16i',
160
+ [41]: 'r32f',
161
+ [42]: 'r32ui',
162
+ [43]: 'r32i',
163
+ [49]: 'rg8unorm',
164
+ [50]: 'rg8ui',
165
+ [51]: 'rg8snorm',
166
+ [52]: 'rg8i',
167
+ [54]: 'r16f',
168
+ [57]: 'r16ui',
169
+ [59]: 'r16i',
170
+ [61]: 'r8unorm',
171
+ [62]: 'r8ui',
172
+ [63]: 'r8snorm',
173
+ [64]: 'r8i',
174
+ [71]: 'dxt1',
175
+ [72]: 'dxt1-srgb',
176
+ [74]: 'dxt3',
177
+ [75]: 'dxt3-srgb',
178
+ [77]: 'dxt5',
179
+ [78]: 'dxt5-srgb'
180
+ };
181
+ const legacyDDSMap = [
182
+ {
183
+ format: 'dxt1',
184
+ convertFlags: 0,
185
+ pf: {
186
+ dwFlags: DDPF_FOURCC,
187
+ dwFourCC: FourCCToInt32('DXT1')
188
+ }
189
+ },
190
+ {
191
+ format: 'dxt3',
192
+ convertFlags: 0,
193
+ pf: {
194
+ dwFlags: DDPF_FOURCC,
195
+ dwFourCC: FourCCToInt32('DXT3')
196
+ }
197
+ },
198
+ {
199
+ format: 'dxt5',
200
+ convertFlags: 0,
201
+ pf: {
202
+ dwFlags: DDPF_FOURCC,
203
+ dwFourCC: FourCCToInt32('DXT5')
204
+ }
205
+ },
206
+ {
207
+ format: 'bgra8unorm',
208
+ convertFlags: 1,
209
+ pf: {
210
+ dwFlags: DDPF_RGB | DDPF_ALPHAPIXELS,
211
+ dwRGBBitCount: 32,
212
+ dwRBitMask: 0x00ff0000,
213
+ dwGBitMask: 0x0000ff00,
214
+ dwBBitMask: 0x000000ff,
215
+ dwABitMask: 0xff000000
216
+ }
217
+ },
218
+ {
219
+ format: 'bgra8unorm',
220
+ convertFlags: 1 | 22,
221
+ pf: {
222
+ dwFlags: DDPF_RGB,
223
+ dwRGBBitCount: 32,
224
+ dwRBitMask: 0x00ff0000,
225
+ dwGBitMask: 0x0000ff00,
226
+ dwBBitMask: 0x000000ff
227
+ }
228
+ },
229
+ {
230
+ format: 'rgba8unorm',
231
+ convertFlags: 0,
232
+ pf: {
233
+ dwFlags: DDPF_RGB | DDPF_ALPHAPIXELS,
234
+ dwRGBBitCount: 32,
235
+ dwRBitMask: 0x000000ff,
236
+ dwGBitMask: 0x0000ff00,
237
+ dwBBitMask: 0x00ff0000,
238
+ dwABitMask: 0xff000000
239
+ }
240
+ },
241
+ {
242
+ format: 'rgba8unorm',
243
+ convertFlags: 22,
244
+ pf: {
245
+ dwFlags: DDPF_RGB,
246
+ dwRGBBitCount: 32,
247
+ dwRBitMask: 0x000000ff,
248
+ dwGBitMask: 0x0000ff00,
249
+ dwBBitMask: 0x00ff0000
250
+ }
251
+ },
252
+ {
253
+ format: 'r16f',
254
+ convertFlags: 0,
255
+ pf: {
256
+ dwFlags: DDPF_FOURCC,
257
+ dwFourCC: 111
258
+ }
259
+ },
260
+ {
261
+ format: 'r16f',
262
+ convertFlags: 0,
263
+ pf: {
264
+ dwFlags: DDPF_FOURCC,
265
+ dwFourCC: DXGIFormat.DXGI_FORMAT_R16F
266
+ }
267
+ },
268
+ {
269
+ format: 'rg16f',
270
+ convertFlags: 0,
271
+ pf: {
272
+ dwFlags: DDPF_FOURCC,
273
+ dwFourCC: 112
274
+ }
275
+ },
276
+ {
277
+ format: 'rg16f',
278
+ convertFlags: 0,
279
+ pf: {
280
+ dwFlags: DDPF_FOURCC,
281
+ dwFourCC: DXGIFormat.DXGI_FORMAT_RG16F
282
+ }
283
+ },
284
+ {
285
+ format: 'rgba16f',
286
+ convertFlags: 0,
287
+ pf: {
288
+ dwFlags: DDPF_FOURCC,
289
+ dwFourCC: 113
290
+ }
291
+ },
292
+ {
293
+ format: 'rgba16f',
294
+ convertFlags: 0,
295
+ pf: {
296
+ dwFlags: DDPF_FOURCC,
297
+ dwFourCC: DXGIFormat.DXGI_FORMAT_RGBA16F
298
+ }
299
+ },
300
+ {
301
+ format: 'r32f',
302
+ convertFlags: 0,
303
+ pf: {
304
+ dwFlags: DDPF_FOURCC,
305
+ dwFourCC: 114
306
+ }
307
+ },
308
+ {
309
+ format: 'r32f',
310
+ convertFlags: 0,
311
+ pf: {
312
+ dwFlags: DDPF_FOURCC,
313
+ dwFourCC: DXGIFormat.DXGI_FORMAT_R32F
314
+ }
315
+ },
316
+ {
317
+ format: 'rg32f',
318
+ convertFlags: 0,
319
+ pf: {
320
+ dwFlags: DDPF_FOURCC,
321
+ dwFourCC: 115
322
+ }
323
+ },
324
+ {
325
+ format: 'rg32f',
326
+ convertFlags: 0,
327
+ pf: {
328
+ dwFlags: DDPF_FOURCC,
329
+ dwFourCC: DXGIFormat.DXGI_FORMAT_RG32F
330
+ }
331
+ },
332
+ {
333
+ format: 'rgba32f',
334
+ convertFlags: 0,
335
+ pf: {
336
+ dwFlags: DDPF_FOURCC,
337
+ dwFourCC: 116
338
+ }
339
+ },
340
+ {
341
+ format: 'rgba32f',
342
+ convertFlags: 0,
343
+ pf: {
344
+ dwFlags: DDPF_FOURCC,
345
+ dwFourCC: DXGIFormat.DXGI_FORMAT_RGBA32F
346
+ }
347
+ }
348
+ ];
349
+ function getTextureFormat(header) {
350
+ if (header.ddsHeaderDX10) {
351
+ const format = header.ddsHeaderDX10 ? dxgiFormatMap[header.ddsHeaderDX10.dxgiFormat] : null;
352
+ if (format) {
353
+ return format;
354
+ }
355
+ }
356
+ const pf = header.ddsPixelFormat;
357
+ const flags = pf.dwFlags;
358
+ let index;
359
+ for(index = 0; index < legacyDDSMap.length; index++){
360
+ const entry = legacyDDSMap[index];
361
+ if (flags & DDPF_FOURCC && entry.pf.dwFlags & DDPF_FOURCC) {
362
+ if (pf.dwFourCC === entry.pf.dwFourCC) {
363
+ break;
364
+ }
365
+ } else if (flags === entry.pf.dwFlags) {
366
+ if (flags & DDPF_ALPHA) {
367
+ if (pf.dwRGBBitCount === entry.pf.dwRGBBitCount && pf.dwABitMask === entry.pf.dwABitMask) {
368
+ break;
369
+ }
370
+ } else if (flags & DDPF_LUMINANCE) {
371
+ if (pf.dwRGBBitCount === entry.pf.dwRGBBitCount && pf.dwRBitMask === entry.pf.dwRBitMask) {
372
+ if (pf.dwABitMask === entry.pf.dwABitMask || !(flags & DDPF_ALPHAPIXELS)) {
373
+ break;
374
+ }
375
+ }
376
+ } else if (pf.dwRGBBitCount === entry.pf.dwRGBBitCount) {
377
+ if (pf.dwRBitMask === entry.pf.dwRBitMask && pf.dwGBitMask === entry.pf.dwGBitMask && pf.dwBBitMask === entry.pf.dwBBitMask) {
378
+ if (pf.dwABitMask === entry.pf.dwABitMask || !(flags & DDPF_ALPHAPIXELS)) {
379
+ break;
380
+ }
381
+ }
382
+ }
383
+ }
384
+ }
385
+ if (index === legacyDDSMap.length) {
386
+ return null;
387
+ }
388
+ return legacyDDSMap[index].format;
389
+ }
390
+ function getMetaDataFromHeader(header, metaData) {
391
+ metaData = metaData || {};
392
+ metaData.format = getTextureFormat(header);
393
+ if (metaData.format === null) {
394
+ return null;
395
+ }
396
+ metaData.isCompressed = metaData.format === 'dxt1' || metaData.format === 'dxt3' || metaData.format === 'dxt5';
397
+ metaData.dataOffset = header.ddsHeaderDX10 ? 37 * 4 : 32 * 4;
398
+ metaData.width = header.dwWidth;
399
+ metaData.height = header.dwHeight;
400
+ metaData.depth = 1;
401
+ metaData.mipLevels = header.dwMipmapCount || 1;
402
+ metaData.arraySize = header.ddsHeaderDX10 ? header.ddsHeaderDX10.arraySize : 1;
403
+ metaData.isCubemap = metaData.isVolume = false;
404
+ if (header.dwCaps2 & DDS_CUBEMAP_ALLFACES) {
405
+ metaData.isCubemap = true;
406
+ metaData.arraySize *= 6;
407
+ } else if (header.dwCaps2 & DDSCAPS2_VOLUME) {
408
+ metaData.isVolume = true;
409
+ metaData.depth = header.dwDepth;
410
+ } else if (header.ddsHeaderDX10) {
411
+ metaData.isArray = true;
412
+ metaData.depth = header.ddsHeaderDX10.arraySize;
413
+ }
414
+ return metaData;
415
+ }
416
+ function getMipmapData(dds, width, height, format, dataOffset) {
417
+ switch(format){
418
+ case 'r16f':
419
+ return new Uint16Array(dds, dataOffset, width * height);
420
+ case 'rg16f':
421
+ return new Uint16Array(dds, dataOffset, width * height * 2);
422
+ case 'r32f':
423
+ return new Float32Array(dds, dataOffset, width * height);
424
+ case 'rgba8unorm':
425
+ case 'bgra8unorm':
426
+ return new Uint8Array(dds, dataOffset, width * height * 4);
427
+ case 'rgba16f':
428
+ return new Uint16Array(dds, dataOffset, width * height * 4);
429
+ case 'rg32f':
430
+ return new Float32Array(dds, dataOffset, width * height * 2);
431
+ case 'rgba32f':
432
+ return new Float32Array(dds, dataOffset, width * height * 4);
433
+ case 'dxt1':
434
+ return new Uint8Array(dds, dataOffset, Math.max(4, width) / 4 * Math.max(4, height) / 4 * 8);
435
+ case 'dxt3':
436
+ case 'dxt5':
437
+ return new Uint8Array(dds, dataOffset, Math.max(4, width) / 4 * Math.max(4, height) / 4 * 16);
438
+ default:
439
+ return null;
440
+ }
441
+ }
442
+ /** @internal */ function getDDSMipLevelsInfo(dds) {
443
+ const ddsHeader = loadDDSHeader(dds);
444
+ if (!ddsHeader) {
445
+ return null;
446
+ }
447
+ const ddsLevelsInfo = {};
448
+ getMetaDataFromHeader(ddsHeader, ddsLevelsInfo);
449
+ ddsLevelsInfo.mipDatas = [];
450
+ let dataOffset = ddsLevelsInfo.dataOffset;
451
+ for(let i = 0; i < ddsLevelsInfo.arraySize; i++){
452
+ const mipDatas = [];
453
+ let width = ddsLevelsInfo.width;
454
+ let height = ddsLevelsInfo.height;
455
+ for(let mip = 0; mip < ddsLevelsInfo.mipLevels; mip++){
456
+ const mipData = getMipmapData(dds, width, height, ddsLevelsInfo.format, dataOffset);
457
+ mipDatas.push({
458
+ data: mipData,
459
+ width: width,
460
+ height: height
461
+ });
462
+ dataOffset += mipData.byteLength;
463
+ width = Math.max(1, width >> 1);
464
+ height = Math.max(1, height >> 1);
465
+ }
466
+ ddsLevelsInfo.mipDatas.push(mipDatas);
467
+ }
468
+ return ddsLevelsInfo;
469
+ }
470
+
471
+ export { getDDSMipLevelsInfo };
472
+ //# sourceMappingURL=dds.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dds.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -0,0 +1,38 @@
1
+ import { getDDSMipLevelsInfo } from './dds.js';
2
+ import { AbstractTextureLoader } from '../loader.js';
3
+ import { Application } from '../../../app.js';
4
+
5
+ /**
6
+ * The DDS texture loader
7
+ * @internal
8
+ */ class DDSLoader extends AbstractTextureLoader {
9
+ supportExtension(ext) {
10
+ return ext === '.dds';
11
+ }
12
+ supportMIMEType(mimeType) {
13
+ return mimeType === 'image/dds';
14
+ }
15
+ async load(assetManager, url, mimeType, data, srgb, samplerOptions, texture) {
16
+ const arrayBuffer = data;
17
+ const mipmapLevelData = getDDSMipLevelsInfo(arrayBuffer);
18
+ if (!mipmapLevelData) {
19
+ throw new Error(`read DDS file failed: ${url}`);
20
+ }
21
+ const options = {
22
+ texture: texture,
23
+ samplerOptions
24
+ };
25
+ return Application.instance.device.createTextureFromMipmapData(mipmapLevelData, srgb, options);
26
+ /*
27
+ if (mipmapLevelData.isCubemap) {
28
+ return Application.instance.device.createCubeTextureFromMipmapData(mipmapLevelData, options);
29
+ } else if (mipmapLevelData.isVolume) {
30
+ throw new Error(`load DDS volume texture is not supported`);
31
+ } else {
32
+ return Application.instance.device.createTexture2DFromMipmapData(mipmapLevelData, options);
33
+ }
34
+ */ }
35
+ }
36
+
37
+ export { DDSLoader };
38
+ //# sourceMappingURL=dds_loader.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dds_loader.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}