x_ite 4.7.12 → 5.0.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 (759) hide show
  1. package/.vscode/settings.json +9 -2
  2. package/Makefile +27 -24
  3. package/build/bin/version-number.pl +1 -1
  4. package/build/bin/version.pl +3 -3
  5. package/build/parts/default.start.frag.js +2 -2
  6. package/build/parts/x_ite.end.frag.js +1 -2
  7. package/build/parts/x_ite.start.frag.js +4 -7
  8. package/dist/assets/components/annotation.js +312 -312
  9. package/dist/assets/components/annotation.min.js +1 -1
  10. package/dist/assets/components/cad-geometry.js +536 -538
  11. package/dist/assets/components/cad-geometry.min.js +1 -1
  12. package/dist/assets/components/cube-map-texturing.js +797 -796
  13. package/dist/assets/components/cube-map-texturing.min.js +1 -1
  14. package/dist/assets/components/dis.js +487 -472
  15. package/dist/assets/components/dis.min.js +1 -1
  16. package/dist/assets/components/event-utilities.js +486 -505
  17. package/dist/assets/components/event-utilities.min.js +1 -1
  18. package/dist/assets/components/geometry2d.js +1221 -1271
  19. package/dist/assets/components/geometry2d.min.js +1 -1
  20. package/dist/assets/components/geospatial.js +2657 -2653
  21. package/dist/assets/components/geospatial.min.js +1 -2
  22. package/dist/assets/components/h-anim.js +640 -640
  23. package/dist/assets/components/h-anim.min.js +1 -1
  24. package/dist/assets/components/key-device-sensor.js +547 -549
  25. package/dist/assets/components/key-device-sensor.min.js +1 -1
  26. package/dist/assets/components/layout.js +1435 -1433
  27. package/dist/assets/components/layout.min.js +1 -1
  28. package/dist/assets/components/nurbs.js +3942 -3964
  29. package/dist/assets/components/nurbs.min.js +1 -2
  30. package/dist/assets/components/particle-systems.js +3227 -3238
  31. package/dist/assets/components/particle-systems.min.js +1 -2
  32. package/dist/assets/components/picking.js +1704 -1712
  33. package/dist/assets/components/picking.min.js +1 -1
  34. package/dist/assets/components/projective-texture-mapping.js +553 -553
  35. package/dist/assets/components/projective-texture-mapping.min.js +1 -1
  36. package/dist/assets/components/rigid-body-physics.js +3255 -3265
  37. package/dist/assets/components/rigid-body-physics.min.js +1 -59
  38. package/dist/assets/components/scripting.js +544 -549
  39. package/dist/assets/components/scripting.min.js +1 -1
  40. package/dist/assets/components/texturing-3d.js +2716 -2651
  41. package/dist/assets/components/texturing-3d.min.js +131 -48
  42. package/dist/assets/components/volume-rendering.js +2815 -2804
  43. package/dist/assets/components/volume-rendering.min.js +1 -3
  44. package/dist/assets/components/x_ite.js +142 -144
  45. package/dist/assets/components/x_ite.min.js +1 -1
  46. package/dist/assets/shaders/webgl1/Gouraud.fs +52 -15
  47. package/dist/assets/shaders/webgl1/Gouraud.vs +8 -9
  48. package/dist/assets/shaders/webgl1/{Wireframe.fs → Line.fs} +0 -0
  49. package/dist/assets/shaders/webgl1/{Wireframe.vs → Line.vs} +1 -1
  50. package/dist/assets/shaders/webgl1/PBR.fs +785 -0
  51. package/dist/assets/shaders/webgl1/PBR.vs +37 -0
  52. package/dist/assets/shaders/webgl1/Phong.fs +204 -32
  53. package/dist/assets/shaders/webgl1/Phong.vs +2 -3
  54. package/dist/assets/shaders/webgl1/{PointSet.fs → Point.fs} +59 -33
  55. package/dist/assets/shaders/webgl1/{PointSet.vs → Point.vs} +2 -2
  56. package/dist/assets/shaders/webgl1/Unlit.fs +73 -18
  57. package/dist/assets/shaders/webgl1/Unlit.vs +2 -3
  58. package/dist/assets/shaders/webgl2/Gouraud.fs +31 -19
  59. package/dist/assets/shaders/webgl2/Gouraud.vs +8 -9
  60. package/dist/assets/shaders/webgl2/{Wireframe.fs → Line.fs} +0 -0
  61. package/dist/assets/shaders/webgl2/{Wireframe.vs → Line.vs} +1 -1
  62. package/dist/assets/shaders/webgl2/PBR.fs +913 -0
  63. package/dist/assets/shaders/webgl2/PBR.vs +37 -0
  64. package/dist/assets/shaders/webgl2/Phong.fs +196 -35
  65. package/dist/assets/shaders/webgl2/Phong.vs +2 -3
  66. package/dist/assets/shaders/webgl2/{PointSet.fs → Point.fs} +87 -86
  67. package/dist/assets/shaders/webgl2/{PointSet.vs → Point.vs} +2 -2
  68. package/dist/assets/shaders/webgl2/Unlit.fs +55 -22
  69. package/dist/assets/shaders/webgl2/Unlit.vs +2 -3
  70. package/dist/example.html +2 -2
  71. package/dist/x_ite.css +316 -328
  72. package/dist/x_ite.js +55663 -52034
  73. package/dist/x_ite.min.js +79 -41
  74. package/dist/x_ite.zip +0 -0
  75. package/docs/Custom-Shaders.md +4 -3
  76. package/docs/_config.yml +1 -1
  77. package/docs/index.md +60 -7
  78. package/package.json +20 -20
  79. package/src/assets/components/annotation.js +24 -24
  80. package/src/assets/components/cad-geometry.js +24 -25
  81. package/src/assets/components/cube-map-texturing.js +18 -19
  82. package/src/assets/components/dis.js +22 -23
  83. package/src/assets/components/event-utilities.js +28 -29
  84. package/src/assets/components/geometry2d.js +28 -29
  85. package/src/assets/components/geospatial.js +34 -35
  86. package/src/assets/components/h-anim.js +22 -22
  87. package/src/assets/components/key-device-sensor.js +18 -19
  88. package/src/assets/components/layout.js +24 -25
  89. package/src/assets/components/nurbs.js +44 -45
  90. package/src/assets/components/particle-systems.js +36 -37
  91. package/src/assets/components/picking.js +25 -25
  92. package/src/assets/components/projective-texture-mapping.js +16 -16
  93. package/src/assets/components/rigid-body-physics.js +48 -48
  94. package/src/assets/components/scripting.js +14 -15
  95. package/src/assets/components/texturing-3d.js +26 -27
  96. package/src/assets/components/volume-rendering.js +46 -46
  97. package/src/assets/components/x_ite.js +12 -12
  98. package/src/assets/shaders/Types.glsl +230 -51
  99. package/src/assets/shaders/webgl1/Background.fs +2 -2
  100. package/src/assets/shaders/webgl1/Background.vs +4 -4
  101. package/src/assets/shaders/webgl1/Depth.fs +2 -2
  102. package/src/assets/shaders/webgl1/Depth.vs +3 -3
  103. package/src/assets/shaders/webgl1/Fallback.fs +15 -15
  104. package/src/assets/shaders/webgl1/Fallback.vs +5 -5
  105. package/src/assets/shaders/webgl1/FallbackUnlit.fs +4 -4
  106. package/src/assets/shaders/webgl1/FallbackUnlit.vs +3 -3
  107. package/src/assets/shaders/webgl1/Gouraud.fs +14 -14
  108. package/src/assets/shaders/webgl1/Gouraud.vs +54 -69
  109. package/src/assets/shaders/webgl1/Line.fs +74 -0
  110. package/src/assets/shaders/webgl1/Line.vs +63 -0
  111. package/src/assets/shaders/webgl1/PBR.fs +364 -0
  112. package/src/assets/shaders/webgl1/PBR.vs +46 -0
  113. package/src/assets/shaders/webgl1/Phong.fs +207 -84
  114. package/src/assets/shaders/webgl1/Phong.vs +17 -18
  115. package/src/assets/shaders/webgl1/Point.fs +88 -0
  116. package/src/assets/shaders/webgl1/Point.vs +70 -0
  117. package/src/assets/shaders/webgl1/Unlit.fs +53 -28
  118. package/src/assets/shaders/webgl1/Unlit.vs +17 -18
  119. package/src/assets/shaders/webgl1/include/ClipPlanes.glsl +7 -7
  120. package/src/assets/shaders/webgl1/include/Colors.glsl +27 -0
  121. package/src/assets/shaders/webgl1/include/Fog.glsl +17 -17
  122. package/src/assets/shaders/webgl1/include/Hatch.glsl +8 -8
  123. package/src/assets/shaders/webgl1/include/Normal.glsl +44 -0
  124. package/src/assets/shaders/webgl1/include/Pack.glsl +11 -11
  125. package/src/assets/shaders/webgl1/include/Perlin.glsl +19 -19
  126. package/src/assets/shaders/webgl1/include/Shadow.glsl +212 -212
  127. package/src/assets/shaders/webgl1/include/SpotFactor.glsl +12 -0
  128. package/src/assets/shaders/webgl1/include/Texture.glsl +444 -393
  129. package/src/assets/shaders/webgl2/Background.fs +2 -2
  130. package/src/assets/shaders/webgl2/Background.vs +4 -4
  131. package/src/assets/shaders/webgl2/Depth.fs +2 -2
  132. package/src/assets/shaders/webgl2/Depth.vs +3 -3
  133. package/src/assets/shaders/webgl2/Gouraud.fs +14 -14
  134. package/src/assets/shaders/webgl2/Gouraud.vs +54 -69
  135. package/src/assets/shaders/webgl2/Line.fs +73 -0
  136. package/src/assets/shaders/webgl2/Line.vs +64 -0
  137. package/src/assets/shaders/webgl2/PBR.fs +370 -0
  138. package/src/assets/shaders/webgl2/PBR.vs +48 -0
  139. package/src/assets/shaders/webgl2/Phong.fs +219 -84
  140. package/src/assets/shaders/webgl2/Phong.vs +17 -18
  141. package/src/assets/shaders/webgl2/Point.fs +87 -0
  142. package/src/assets/shaders/webgl2/Point.vs +71 -0
  143. package/src/assets/shaders/webgl2/Unlit.fs +56 -28
  144. package/src/assets/shaders/webgl2/Unlit.vs +17 -18
  145. package/src/assets/shaders/webgl2/include/ClipPlanes.glsl +7 -7
  146. package/src/assets/shaders/webgl2/include/Colors.glsl +27 -0
  147. package/src/assets/shaders/webgl2/include/Fog.glsl +34 -34
  148. package/src/assets/shaders/webgl2/include/Hatch.glsl +8 -8
  149. package/src/assets/shaders/webgl2/include/Normal.glsl +46 -0
  150. package/src/assets/shaders/webgl2/include/Pack.glsl +11 -11
  151. package/src/assets/shaders/webgl2/include/Perlin.glsl +19 -20
  152. package/src/assets/shaders/webgl2/include/Shadow.glsl +226 -226
  153. package/src/assets/shaders/webgl2/include/SpotFactor.glsl +12 -0
  154. package/src/assets/shaders/webgl2/include/Texture.glsl +557 -537
  155. package/src/bookmarks.js +92 -92
  156. package/src/examples.js +147 -147
  157. package/src/lib/ammojs/AmmoJS.js +2 -2
  158. package/src/lib/ammojs/Makefile +14 -15
  159. package/src/lib/jquery.fullscreen-min.js +2 -2
  160. package/src/lib/nurbs/extras/sample.js +215 -215
  161. package/src/lib/nurbs/nurbs.js +326 -326
  162. package/src/lib/nurbs/src/evaluate.js +405 -405
  163. package/src/lib/nurbs/src/numerical-derivative.js +48 -48
  164. package/src/lib/nurbs/src/support.js +143 -143
  165. package/src/lib/nurbs/src/transform.js +70 -70
  166. package/src/lib/nurbs/src/utils/accessor-preamble.js +23 -23
  167. package/src/lib/nurbs/src/utils/bisection-search.js +18 -18
  168. package/src/lib/nurbs/src/utils/cache-key.js +49 -50
  169. package/src/lib/nurbs/src/utils/create-accessors.js +101 -101
  170. package/src/lib/nurbs/src/utils/infer-type.js +43 -43
  171. package/src/lib/nurbs/src/utils/is-array-like.js +5 -5
  172. package/src/lib/nurbs/src/utils/is-ndarray-like.js +11 -11
  173. package/src/lib/nurbs/src/utils/is-ndarray.js +13 -13
  174. package/src/lib/nurbs/src/utils/ndloop.js +18 -18
  175. package/src/lib/nurbs/src/utils/size-getter.js +15 -15
  176. package/src/lib/nurbs/src/utils/variable.js +25 -25
  177. package/src/lib/opentype.js/bin/ot +27 -27
  178. package/src/lib/opentype.js/dist/opentype.js +5 -5
  179. package/src/lib/opentype.js/font-inspector.html +1 -1
  180. package/src/lib/opentype.js/site.css +1 -3
  181. package/src/locale/gettext.js +73 -73
  182. package/src/spinner.css +40 -43
  183. package/src/standard/Geospatial/Geodetic.js +195 -195
  184. package/src/standard/Geospatial/ReferenceEllipsoids.js +43 -43
  185. package/src/standard/Geospatial/UniversalTransverseMercator.js +159 -159
  186. package/src/standard/Math/Algorithm.js +199 -187
  187. package/src/standard/Math/Algorithms/Bezier.js +80 -80
  188. package/src/standard/Math/Algorithms/MergeSort.js +49 -49
  189. package/src/standard/Math/Algorithms/PartialSort.js +36 -36
  190. package/src/standard/Math/Algorithms/QuickSort.js +51 -51
  191. package/src/standard/Math/Algorithms/SAT.js +62 -62
  192. package/src/standard/Math/Algorithms/eigendecomposition.js +141 -141
  193. package/src/standard/Math/Geometry/Box2.js +205 -205
  194. package/src/standard/Math/Geometry/Box3.js +624 -624
  195. package/src/standard/Math/Geometry/Camera.js +68 -68
  196. package/src/standard/Math/Geometry/Cylinder3.js +112 -112
  197. package/src/standard/Math/Geometry/Line3.js +188 -153
  198. package/src/standard/Math/Geometry/Plane3.js +120 -120
  199. package/src/standard/Math/Geometry/Sphere3.js +148 -148
  200. package/src/standard/Math/Geometry/Spheroid3.js +38 -38
  201. package/src/standard/Math/Geometry/Triangle2.js +19 -19
  202. package/src/standard/Math/Geometry/Triangle3.js +148 -148
  203. package/src/standard/Math/Geometry/ViewVolume.js +359 -359
  204. package/src/standard/Math/Numbers/Color3.js +219 -214
  205. package/src/standard/Math/Numbers/Color4.js +148 -142
  206. package/src/standard/Math/Numbers/Complex.js +139 -139
  207. package/src/standard/Math/Numbers/Matrix2.js +193 -193
  208. package/src/standard/Math/Numbers/Matrix3.js +679 -679
  209. package/src/standard/Math/Numbers/Matrix4.js +883 -883
  210. package/src/standard/Math/Numbers/Quaternion.js +496 -496
  211. package/src/standard/Math/Numbers/Rotation4.js +421 -415
  212. package/src/standard/Math/Numbers/Vector2.js +220 -220
  213. package/src/standard/Math/Numbers/Vector3.js +280 -280
  214. package/src/standard/Math/Numbers/Vector4.js +296 -296
  215. package/src/standard/Math/Utility/BVH.js +303 -303
  216. package/src/standard/Math/Utility/MatrixStack.js +64 -64
  217. package/src/standard/Networking/BinaryTransport.js +67 -67
  218. package/src/standard/Time/MicroTime.js +22 -22
  219. package/src/standard/Utility/DataStorage.js +85 -81
  220. package/src/standard/Utility/MapUtilities.js +14 -1
  221. package/src/standard/Utility/ObjectCache.js +24 -24
  222. package/src/standard/Utility/Shuffle.js +13 -13
  223. package/src/tests.js +355 -384
  224. package/src/x_ite/Base/Events.js +64 -55
  225. package/src/x_ite/{Basic/X3DArrayField.js → Base/FieldArray.js} +19 -12
  226. package/src/x_ite/Base/FieldDefinitionArray.js +75 -0
  227. package/src/x_ite/{Basic/FieldDefinitionArray.js → Base/X3DArrayField.js} +35 -59
  228. package/src/x_ite/Base/X3DBaseNode.js +588 -0
  229. package/src/x_ite/{Bits → Base}/X3DCast.js +23 -22
  230. package/src/x_ite/Base/X3DChildObject.js +68 -62
  231. package/src/x_ite/{Bits → Base}/X3DConstants.js +85 -85
  232. package/src/x_ite/Base/X3DEventObject.js +73 -68
  233. package/src/x_ite/Base/X3DField.js +450 -0
  234. package/src/x_ite/Base/X3DFieldDefinition.js +78 -0
  235. package/src/x_ite/Base/X3DInfoArray.js +291 -0
  236. package/src/x_ite/Base/X3DObject.js +152 -109
  237. package/src/x_ite/Base/X3DObjectArrayField.js +573 -0
  238. package/src/x_ite/Base/X3DTypedArrayField.js +866 -0
  239. package/src/x_ite/Browser/Core/BrowserOptions.js +376 -394
  240. package/src/x_ite/Browser/Core/BrowserProperties.js +38 -38
  241. package/src/x_ite/Browser/Core/BrowserTimings.js +173 -172
  242. package/src/x_ite/Browser/Core/ContextMenu.js +547 -551
  243. package/src/x_ite/Browser/Core/Notification.js +57 -56
  244. package/src/x_ite/Browser/Core/PrimitiveQuality.js +8 -8
  245. package/src/x_ite/Browser/Core/RenderingProperties.js +55 -55
  246. package/src/x_ite/Browser/Core/Shading.js +10 -10
  247. package/src/x_ite/Browser/Core/TextureQuality.js +8 -8
  248. package/src/x_ite/Browser/Core/X3DCoreContext.js +746 -724
  249. package/src/x_ite/Browser/EnvironmentalEffects/X3DEnvironmentalEffectsContext.js +33 -25
  250. package/src/x_ite/Browser/Followers/X3DArrayChaserTemplate.js +23 -23
  251. package/src/x_ite/Browser/Followers/X3DArrayFollowerTemplate.js +127 -127
  252. package/src/x_ite/Browser/Geometry2D/Arc2DOptions.js +25 -25
  253. package/src/x_ite/Browser/Geometry2D/ArcClose2DOptions.js +25 -25
  254. package/src/x_ite/Browser/Geometry2D/Circle2DOptions.js +56 -55
  255. package/src/x_ite/Browser/Geometry2D/Disk2DOptions.js +116 -116
  256. package/src/x_ite/Browser/Geometry2D/Rectangle2DOptions.js +59 -59
  257. package/src/x_ite/Browser/Geometry2D/X3DGeometry2DContext.js +80 -77
  258. package/src/x_ite/Browser/Geometry3D/BoxOptions.js +70 -70
  259. package/src/x_ite/Browser/Geometry3D/ConeOptions.js +26 -26
  260. package/src/x_ite/Browser/Geometry3D/CylinderOptions.js +27 -27
  261. package/src/x_ite/Browser/Geometry3D/IcoSphere.js +357 -357
  262. package/src/x_ite/Browser/Geometry3D/IcoSphereOptions.js +61 -61
  263. package/src/x_ite/Browser/Geometry3D/QuadSphereOptions.js +243 -241
  264. package/src/x_ite/Browser/Geometry3D/X3DGeometry3DContext.js +37 -34
  265. package/src/x_ite/Browser/Geospatial/Geocentric.js +27 -27
  266. package/src/x_ite/Browser/Geospatial/Geospatial.js +157 -156
  267. package/src/x_ite/Browser/Grouping/X3DGroupingContext.js +38 -33
  268. package/src/x_ite/Browser/Interpolation/CatmullRomSplineInterpolator.js +128 -130
  269. package/src/x_ite/Browser/Interpolation/CatmullRomSplineInterpolator1.js +39 -41
  270. package/src/x_ite/Browser/Interpolation/CatmullRomSplineInterpolator2.js +3 -3
  271. package/src/x_ite/Browser/Interpolation/CatmullRomSplineInterpolator3.js +3 -3
  272. package/src/x_ite/Browser/Interpolation/CatmullRomSplineInterpolatorTemplate.js +54 -56
  273. package/src/x_ite/Browser/Interpolation/SquatInterpolator.js +54 -56
  274. package/src/x_ite/Browser/KeyDeviceSensor/X3DKeyDeviceSensorContext.js +44 -41
  275. package/src/x_ite/Browser/Layering/X3DLayeringContext.js +20 -18
  276. package/src/x_ite/Browser/Layout/ScreenText.js +406 -405
  277. package/src/x_ite/Browser/Layout/X3DLayoutContext.js +36 -30
  278. package/src/x_ite/Browser/Lighting/X3DLightingContext.js +54 -50
  279. package/src/x_ite/Browser/NURBS/NURBS.js +417 -417
  280. package/src/x_ite/Browser/Navigation/ExamineViewer.js +753 -753
  281. package/src/x_ite/Browser/Navigation/FlyViewer.js +39 -39
  282. package/src/x_ite/Browser/Navigation/LookAtViewer.js +461 -461
  283. package/src/x_ite/Browser/Navigation/NoneViewer.js +18 -18
  284. package/src/x_ite/Browser/Navigation/PlaneViewer.js +193 -193
  285. package/src/x_ite/Browser/Navigation/WalkViewer.js +61 -61
  286. package/src/x_ite/Browser/Navigation/X3DFlyViewer.js +709 -710
  287. package/src/x_ite/Browser/Navigation/X3DNavigationContext.js +188 -182
  288. package/src/x_ite/Browser/Navigation/X3DViewer.js +160 -160
  289. package/src/x_ite/Browser/Networking/X3DNetworkingContext.js +152 -143
  290. package/src/x_ite/Browser/Networking/urls.js +31 -31
  291. package/src/x_ite/Browser/ParticleSystems/X3DParticleSystemsContext.js +17 -13
  292. package/src/x_ite/Browser/Picking/IntersectionType.js +7 -7
  293. package/src/x_ite/Browser/Picking/MatchCriterion.js +8 -8
  294. package/src/x_ite/Browser/Picking/SortOrder.js +9 -9
  295. package/src/x_ite/Browser/Picking/VolumePicker.js +138 -138
  296. package/src/x_ite/Browser/Picking/X3DPickingContext.js +80 -69
  297. package/src/x_ite/Browser/PointingDeviceSensor/PointingDevice.js +208 -209
  298. package/src/x_ite/Browser/PointingDeviceSensor/PointingDeviceSensorContainer.js +34 -34
  299. package/src/x_ite/Browser/PointingDeviceSensor/X3DPointingDeviceSensorContext.js +269 -263
  300. package/src/x_ite/Browser/Rendering/X3DRenderingContext.js +132 -119
  301. package/src/x_ite/Browser/RigidBodyPhysics/AppliedParametersType.js +14 -14
  302. package/src/x_ite/Browser/Scripting/X3DScriptingContext.js +20 -19
  303. package/src/x_ite/Browser/Scripting/evaluate.js +7 -7
  304. package/src/x_ite/Browser/Shaders/Shader.js +152 -159
  305. package/src/x_ite/Browser/Shaders/ShaderSource.js +81 -63
  306. package/src/x_ite/Browser/Shaders/ShaderTest.js +97 -98
  307. package/src/x_ite/Browser/Shaders/X3DShadersContext.js +256 -249
  308. package/src/x_ite/Browser/Shape/AlphaMode.js +9 -9
  309. package/src/x_ite/Browser/Shape/X3DShapeContext.js +111 -89
  310. package/src/x_ite/Browser/Sound/X3DSoundContext.js +11 -11
  311. package/src/x_ite/Browser/Text/PolygonText.js +319 -319
  312. package/src/x_ite/Browser/Text/TextAlignment.js +9 -9
  313. package/src/x_ite/Browser/Text/X3DTextContext.js +72 -65
  314. package/src/x_ite/Browser/Text/X3DTextGeometry.js +506 -506
  315. package/src/x_ite/Browser/Texturing/MultiTextureFunctionType.js +8 -8
  316. package/src/x_ite/Browser/Texturing/MultiTextureModeType.js +25 -25
  317. package/src/x_ite/Browser/Texturing/MultiTextureSourceType.js +9 -9
  318. package/src/x_ite/Browser/Texturing/TextureCoordinateGeneratorModeType.js +17 -17
  319. package/src/x_ite/Browser/Texturing/X3DTexturingContext.js +259 -224
  320. package/src/x_ite/Browser/Texturing3D/DICOMParser.js +1066 -1066
  321. package/src/x_ite/Browser/Texturing3D/NRRDParser.js +641 -630
  322. package/src/x_ite/Browser/Time/X3DTimeContext.js +54 -37
  323. package/src/x_ite/Browser/VERSION.js +1 -1
  324. package/src/x_ite/Browser/VolumeRendering/VolumeStyle.fs +55 -55
  325. package/src/x_ite/Browser/VolumeRendering/VolumeStyle.vs +5 -5
  326. package/src/x_ite/Browser/VolumeRendering/X3DVolumeRenderingContext.js +52 -41
  327. package/src/x_ite/Browser/X3DBrowser.js +819 -755
  328. package/src/x_ite/Browser/X3DBrowserContext.js +253 -220
  329. package/src/x_ite/Components/Annotation/AnnotationLayer.js +43 -43
  330. package/src/x_ite/Components/Annotation/AnnotationTarget.js +38 -38
  331. package/src/x_ite/Components/Annotation/GroupAnnotation.js +48 -48
  332. package/src/x_ite/Components/Annotation/IconAnnotation.js +46 -46
  333. package/src/x_ite/Components/Annotation/TextAnnotation.js +39 -39
  334. package/src/x_ite/Components/Annotation/URLAnnotation.js +38 -38
  335. package/src/x_ite/Components/Annotation/X3DAnnotationNode.js +16 -16
  336. package/src/x_ite/Components/CADGeometry/CADAssembly.js +41 -41
  337. package/src/x_ite/Components/CADGeometry/CADFace.js +189 -189
  338. package/src/x_ite/Components/CADGeometry/CADLayer.js +38 -38
  339. package/src/x_ite/Components/CADGeometry/CADPart.js +46 -46
  340. package/src/x_ite/Components/CADGeometry/IndexedQuadSet.js +67 -67
  341. package/src/x_ite/Components/CADGeometry/QuadSet.js +64 -63
  342. package/src/x_ite/Components/CADGeometry/X3DProductStructureChildNode.js +13 -15
  343. package/src/x_ite/Components/Core/MetadataBoolean.js +38 -40
  344. package/src/x_ite/Components/Core/MetadataDouble.js +38 -40
  345. package/src/x_ite/Components/Core/MetadataFloat.js +38 -40
  346. package/src/x_ite/Components/Core/MetadataInteger.js +38 -40
  347. package/src/x_ite/Components/Core/MetadataSet.js +38 -40
  348. package/src/x_ite/Components/Core/MetadataString.js +38 -40
  349. package/src/x_ite/Components/Core/WorldInfo.js +42 -42
  350. package/src/x_ite/Components/Core/X3DBindableNode.js +20 -20
  351. package/src/x_ite/Components/Core/X3DChildNode.js +38 -40
  352. package/src/x_ite/Components/Core/X3DInfoNode.js +13 -15
  353. package/src/x_ite/Components/Core/X3DMetadataObject.js +11 -13
  354. package/src/x_ite/Components/Core/X3DNode.js +795 -14
  355. package/src/x_ite/Components/Core/X3DPrototypeInstance.js +585 -479
  356. package/src/x_ite/Components/Core/X3DSensorNode.js +13 -15
  357. package/src/x_ite/Components/Core.js +39 -39
  358. package/src/x_ite/Components/CubeMapTexturing/ComposedCubeMapTexture.js +193 -200
  359. package/src/x_ite/Components/CubeMapTexturing/GeneratedCubeMapTexture.js +209 -206
  360. package/src/x_ite/Components/CubeMapTexturing/ImageCubeMapTexture.js +213 -219
  361. package/src/x_ite/Components/CubeMapTexturing/X3DEnvironmentTextureNode.js +69 -60
  362. package/src/x_ite/Components/DIS/DISEntityManager.js +38 -40
  363. package/src/x_ite/Components/DIS/DISEntityTypeMapping.js +59 -41
  364. package/src/x_ite/Components/DIS/EspduTransform.js +128 -128
  365. package/src/x_ite/Components/DIS/ReceiverPdu.js +68 -68
  366. package/src/x_ite/Components/DIS/SignalPdu.js +68 -68
  367. package/src/x_ite/Components/DIS/TransmitterPdu.js +84 -84
  368. package/src/x_ite/Components/EnvironmentalEffects/Background.js +87 -89
  369. package/src/x_ite/Components/EnvironmentalEffects/Fog.js +59 -59
  370. package/src/x_ite/Components/EnvironmentalEffects/FogCoordinate.js +78 -78
  371. package/src/x_ite/Components/EnvironmentalEffects/LocalFog.js +56 -56
  372. package/src/x_ite/Components/EnvironmentalEffects/TextureBackground.js +86 -88
  373. package/src/x_ite/Components/EnvironmentalEffects/X3DBackgroundNode.js +582 -589
  374. package/src/x_ite/Components/EnvironmentalEffects/X3DFogObject.js +105 -105
  375. package/src/x_ite/Components/EnvironmentalEffects.js +25 -25
  376. package/src/x_ite/Components/EnvironmentalSensor/ProximitySensor.js +229 -229
  377. package/src/x_ite/Components/EnvironmentalSensor/TransformSensor.js +256 -256
  378. package/src/x_ite/Components/EnvironmentalSensor/VisibilitySensor.js +114 -114
  379. package/src/x_ite/Components/EnvironmentalSensor/X3DEnvironmentalSensorNode.js +71 -71
  380. package/src/x_ite/Components/EnvironmentalSensor.js +19 -19
  381. package/src/x_ite/Components/EventUtilities/BooleanFilter.js +50 -52
  382. package/src/x_ite/Components/EventUtilities/BooleanSequencer.js +50 -52
  383. package/src/x_ite/Components/EventUtilities/BooleanToggle.js +43 -45
  384. package/src/x_ite/Components/EventUtilities/BooleanTrigger.js +42 -44
  385. package/src/x_ite/Components/EventUtilities/IntegerSequencer.js +50 -52
  386. package/src/x_ite/Components/EventUtilities/IntegerTrigger.js +43 -45
  387. package/src/x_ite/Components/EventUtilities/TimeTrigger.js +43 -45
  388. package/src/x_ite/Components/EventUtilities/X3DSequencerNode.js +92 -94
  389. package/src/x_ite/Components/EventUtilities/X3DTriggerNode.js +13 -15
  390. package/src/x_ite/Components/Followers/ColorChaser.js +78 -78
  391. package/src/x_ite/Components/Followers/ColorDamper.js +78 -78
  392. package/src/x_ite/Components/Followers/CoordinateChaser.js +46 -46
  393. package/src/x_ite/Components/Followers/CoordinateDamper.js +48 -48
  394. package/src/x_ite/Components/Followers/OrientationChaser.js +64 -64
  395. package/src/x_ite/Components/Followers/OrientationDamper.js +61 -61
  396. package/src/x_ite/Components/Followers/PositionChaser.js +42 -42
  397. package/src/x_ite/Components/Followers/PositionChaser2D.js +42 -42
  398. package/src/x_ite/Components/Followers/PositionDamper.js +44 -44
  399. package/src/x_ite/Components/Followers/PositionDamper2D.js +44 -44
  400. package/src/x_ite/Components/Followers/ScalarChaser.js +70 -70
  401. package/src/x_ite/Components/Followers/ScalarDamper.js +60 -60
  402. package/src/x_ite/Components/Followers/TexCoordChaser2D.js +46 -46
  403. package/src/x_ite/Components/Followers/TexCoordDamper2D.js +48 -48
  404. package/src/x_ite/Components/Followers/X3DChaserNode.js +194 -194
  405. package/src/x_ite/Components/Followers/X3DDamperNode.js +120 -120
  406. package/src/x_ite/Components/Followers/X3DFollowerNode.js +83 -83
  407. package/src/x_ite/Components/Followers.js +45 -45
  408. package/src/x_ite/Components/Geometry2D/Arc2D.js +99 -113
  409. package/src/x_ite/Components/Geometry2D/ArcClose2D.js +164 -166
  410. package/src/x_ite/Components/Geometry2D/Circle2D.js +59 -67
  411. package/src/x_ite/Components/Geometry2D/Disk2D.js +207 -211
  412. package/src/x_ite/Components/Geometry2D/Polyline2D.js +43 -52
  413. package/src/x_ite/Components/Geometry2D/Polypoint2D.js +43 -60
  414. package/src/x_ite/Components/Geometry2D/Rectangle2D.js +76 -73
  415. package/src/x_ite/Components/Geometry2D/TriangleSet2D.js +69 -71
  416. package/src/x_ite/Components/Geometry3D/Box.js +90 -86
  417. package/src/x_ite/Components/Geometry3D/Cone.js +185 -187
  418. package/src/x_ite/Components/Geometry3D/Cylinder.js +246 -246
  419. package/src/x_ite/Components/Geometry3D/ElevationGrid.js +383 -384
  420. package/src/x_ite/Components/Geometry3D/Extrusion.js +653 -647
  421. package/src/x_ite/Components/Geometry3D/IndexedFaceSet.js +437 -445
  422. package/src/x_ite/Components/Geometry3D/Sphere.js +72 -74
  423. package/src/x_ite/Components/Geometry3D.js +25 -25
  424. package/src/x_ite/Components/Geospatial/GeoCoordinate.js +189 -191
  425. package/src/x_ite/Components/Geospatial/GeoElevationGrid.js +381 -383
  426. package/src/x_ite/Components/Geospatial/GeoLOD.js +397 -397
  427. package/src/x_ite/Components/Geospatial/GeoLocation.js +56 -56
  428. package/src/x_ite/Components/Geospatial/GeoMetadata.js +54 -36
  429. package/src/x_ite/Components/Geospatial/GeoOrigin.js +50 -52
  430. package/src/x_ite/Components/Geospatial/GeoPositionInterpolator.js +81 -83
  431. package/src/x_ite/Components/Geospatial/GeoProximitySensor.js +95 -97
  432. package/src/x_ite/Components/Geospatial/GeoTouchSensor.js +77 -79
  433. package/src/x_ite/Components/Geospatial/GeoTransform.js +79 -79
  434. package/src/x_ite/Components/Geospatial/GeoViewpoint.js +278 -278
  435. package/src/x_ite/Components/Geospatial/X3DGeospatialObject.js +216 -218
  436. package/src/x_ite/Components/Grouping/Group.js +37 -37
  437. package/src/x_ite/Components/Grouping/StaticGroup.js +245 -245
  438. package/src/x_ite/Components/Grouping/Switch.js +234 -234
  439. package/src/x_ite/Components/Grouping/Transform.js +42 -42
  440. package/src/x_ite/Components/Grouping/X3DBoundedObject.js +93 -93
  441. package/src/x_ite/Components/Grouping/X3DGroupingNode.js +654 -649
  442. package/src/x_ite/Components/Grouping/X3DTransformMatrix3DNode.js +99 -99
  443. package/src/x_ite/Components/Grouping/X3DTransformNode.js +31 -31
  444. package/src/x_ite/Components/Grouping.js +27 -27
  445. package/src/x_ite/Components/HAnim/HAnimDisplacer.js +35 -35
  446. package/src/x_ite/Components/HAnim/HAnimHumanoid.js +293 -293
  447. package/src/x_ite/Components/HAnim/HAnimJoint.js +137 -137
  448. package/src/x_ite/Components/HAnim/HAnimMotion.js +50 -50
  449. package/src/x_ite/Components/HAnim/HAnimSegment.js +44 -44
  450. package/src/x_ite/Components/HAnim/HAnimSite.js +43 -43
  451. package/src/x_ite/Components/Interpolation/ColorInterpolator.js +61 -63
  452. package/src/x_ite/Components/Interpolation/CoordinateInterpolator.js +60 -62
  453. package/src/x_ite/Components/Interpolation/CoordinateInterpolator2D.js +57 -59
  454. package/src/x_ite/Components/Interpolation/EaseInEaseOut.js +79 -80
  455. package/src/x_ite/Components/Interpolation/NormalInterpolator.js +96 -93
  456. package/src/x_ite/Components/Interpolation/OrientationInterpolator.js +70 -70
  457. package/src/x_ite/Components/Interpolation/PositionInterpolator.js +57 -59
  458. package/src/x_ite/Components/Interpolation/PositionInterpolator2D.js +57 -59
  459. package/src/x_ite/Components/Interpolation/ScalarInterpolator.js +53 -55
  460. package/src/x_ite/Components/Interpolation/SplinePositionInterpolator.js +78 -80
  461. package/src/x_ite/Components/Interpolation/SplinePositionInterpolator2D.js +77 -79
  462. package/src/x_ite/Components/Interpolation/SplineScalarInterpolator.js +78 -80
  463. package/src/x_ite/Components/Interpolation/SquadOrientationInterpolator.js +66 -66
  464. package/src/x_ite/Components/Interpolation/X3DInterpolatorNode.js +67 -69
  465. package/src/x_ite/Components/Interpolation.js +39 -39
  466. package/src/x_ite/Components/KeyDeviceSensor/KeySensor.js +304 -306
  467. package/src/x_ite/Components/KeyDeviceSensor/StringSensor.js +102 -104
  468. package/src/x_ite/Components/KeyDeviceSensor/X3DKeyDeviceSensorNode.js +51 -51
  469. package/src/x_ite/Components/Layering/Layer.js +50 -50
  470. package/src/x_ite/Components/Layering/LayerSet.js +160 -161
  471. package/src/x_ite/Components/Layering/Viewport.js +118 -118
  472. package/src/x_ite/Components/Layering/X3DLayerNode.js +322 -322
  473. package/src/x_ite/Components/Layering/X3DViewportNode.js +13 -13
  474. package/src/x_ite/Components/Layering.js +21 -21
  475. package/src/x_ite/Components/Layout/Layout.js +576 -578
  476. package/src/x_ite/Components/Layout/LayoutGroup.js +126 -126
  477. package/src/x_ite/Components/Layout/LayoutLayer.js +53 -53
  478. package/src/x_ite/Components/Layout/ScreenFontStyle.js +48 -48
  479. package/src/x_ite/Components/Layout/ScreenGroup.js +136 -136
  480. package/src/x_ite/Components/Layout/X3DLayoutNode.js +12 -14
  481. package/src/x_ite/Components/Lighting/DirectionalLight.js +239 -246
  482. package/src/x_ite/Components/Lighting/PointLight.js +296 -303
  483. package/src/x_ite/Components/Lighting/SpotLight.js +321 -316
  484. package/src/x_ite/Components/Lighting/X3DLightNode.js +153 -153
  485. package/src/x_ite/Components/Lighting.js +19 -19
  486. package/src/x_ite/Components/NURBS/Contour2D.js +81 -83
  487. package/src/x_ite/Components/NURBS/ContourPolyline2D.js +100 -102
  488. package/src/x_ite/Components/NURBS/CoordinateDouble.js +32 -34
  489. package/src/x_ite/Components/NURBS/NurbsCurve.js +167 -169
  490. package/src/x_ite/Components/NURBS/NurbsCurve2D.js +149 -149
  491. package/src/x_ite/Components/NURBS/NurbsOrientationInterpolator.js +166 -166
  492. package/src/x_ite/Components/NURBS/NurbsPatchSurface.js +45 -47
  493. package/src/x_ite/Components/NURBS/NurbsPositionInterpolator.js +154 -154
  494. package/src/x_ite/Components/NURBS/NurbsSet.js +125 -125
  495. package/src/x_ite/Components/NURBS/NurbsSurfaceInterpolator.js +128 -130
  496. package/src/x_ite/Components/NURBS/NurbsSweptSurface.js +120 -122
  497. package/src/x_ite/Components/NURBS/NurbsSwungSurface.js +120 -122
  498. package/src/x_ite/Components/NURBS/NurbsTextureCoordinate.js +93 -93
  499. package/src/x_ite/Components/NURBS/NurbsTrimmedSurface.js +88 -90
  500. package/src/x_ite/Components/NURBS/X3DNurbsControlCurveNode.js +13 -15
  501. package/src/x_ite/Components/NURBS/X3DNurbsSurfaceGeometryNode.js +339 -339
  502. package/src/x_ite/Components/NURBS/X3DParametricGeometryNode.js +18 -20
  503. package/src/x_ite/Components/Navigation/Billboard.js +132 -132
  504. package/src/x_ite/Components/Navigation/Collision.js +116 -116
  505. package/src/x_ite/Components/Navigation/LOD.js +308 -308
  506. package/src/x_ite/Components/Navigation/NavigationInfo.js +279 -285
  507. package/src/x_ite/Components/Navigation/OrthoViewpoint.js +258 -258
  508. package/src/x_ite/Components/Navigation/Viewpoint.js +137 -137
  509. package/src/x_ite/Components/Navigation/ViewpointGroup.js +169 -171
  510. package/src/x_ite/Components/Navigation/X3DViewpointNode.js +450 -453
  511. package/src/x_ite/Components/Navigation.js +27 -27
  512. package/src/x_ite/Components/Networking/Anchor.js +140 -128
  513. package/src/x_ite/Components/Networking/Inline.js +156 -197
  514. package/src/x_ite/Components/Networking/LoadSensor.js +193 -195
  515. package/src/x_ite/Components/Networking/X3DNetworkSensorNode.js +13 -15
  516. package/src/x_ite/Components/Networking/X3DUrlObject.js +170 -116
  517. package/src/x_ite/Components/Networking.js +21 -21
  518. package/src/x_ite/Components/ParticleSystems/BoundedPhysicsModel.js +62 -64
  519. package/src/x_ite/Components/ParticleSystems/ConeEmitter.js +81 -83
  520. package/src/x_ite/Components/ParticleSystems/ExplosionEmitter.js +59 -61
  521. package/src/x_ite/Components/ParticleSystems/ForcePhysicsModel.js +42 -44
  522. package/src/x_ite/Components/ParticleSystems/ParticleSystem.js +1433 -1433
  523. package/src/x_ite/Components/ParticleSystems/PointEmitter.js +77 -79
  524. package/src/x_ite/Components/ParticleSystems/PolylineEmitter.js +196 -196
  525. package/src/x_ite/Components/ParticleSystems/SurfaceEmitter.js +195 -195
  526. package/src/x_ite/Components/ParticleSystems/VolumeEmitter.js +250 -250
  527. package/src/x_ite/Components/ParticleSystems/WindPhysicsModel.js +69 -71
  528. package/src/x_ite/Components/ParticleSystems/X3DParticleEmitterNode.js +346 -346
  529. package/src/x_ite/Components/ParticleSystems/X3DParticlePhysicsModelNode.js +15 -17
  530. package/src/x_ite/Components/Picking/LinePickSensor.js +284 -286
  531. package/src/x_ite/Components/Picking/PickableGroup.js +155 -155
  532. package/src/x_ite/Components/Picking/PointPickSensor.js +272 -272
  533. package/src/x_ite/Components/Picking/PrimitivePickSensor.js +207 -209
  534. package/src/x_ite/Components/Picking/VolumePickSensor.js +182 -184
  535. package/src/x_ite/Components/Picking/X3DPickSensorNode.js +382 -382
  536. package/src/x_ite/Components/Picking/X3DPickableObject.js +28 -30
  537. package/src/x_ite/Components/PointingDeviceSensor/CylinderSensor.js +257 -259
  538. package/src/x_ite/Components/PointingDeviceSensor/PlaneSensor.js +245 -247
  539. package/src/x_ite/Components/PointingDeviceSensor/SphereSensor.js +173 -175
  540. package/src/x_ite/Components/PointingDeviceSensor/TouchSensor.js +61 -63
  541. package/src/x_ite/Components/PointingDeviceSensor/X3DDragSensorNode.js +14 -16
  542. package/src/x_ite/Components/PointingDeviceSensor/X3DPointingDeviceSensorNode.js +57 -59
  543. package/src/x_ite/Components/PointingDeviceSensor/X3DTouchSensorNode.js +19 -21
  544. package/src/x_ite/Components/PointingDeviceSensor.js +25 -25
  545. package/src/x_ite/Components/ProjectiveTextureMapping/TextureProjectorParallel.js +191 -191
  546. package/src/x_ite/Components/ProjectiveTextureMapping/TextureProjectorPerspective.js +162 -162
  547. package/src/x_ite/Components/ProjectiveTextureMapping/X3DTextureProjectorNode.js +156 -156
  548. package/src/x_ite/Components/Rendering/ClipPlane.js +120 -120
  549. package/src/x_ite/Components/Rendering/Color.js +112 -112
  550. package/src/x_ite/Components/Rendering/ColorRGBA.js +114 -114
  551. package/src/x_ite/Components/Rendering/Coordinate.js +33 -35
  552. package/src/x_ite/Components/Rendering/IndexedLineSet.js +236 -243
  553. package/src/x_ite/Components/Rendering/IndexedTriangleFanSet.js +102 -102
  554. package/src/x_ite/Components/Rendering/IndexedTriangleSet.js +55 -55
  555. package/src/x_ite/Components/Rendering/IndexedTriangleStripSet.js +110 -110
  556. package/src/x_ite/Components/Rendering/LineSet.js +172 -179
  557. package/src/x_ite/Components/Rendering/Normal.js +100 -100
  558. package/src/x_ite/Components/Rendering/PointSet.js +142 -154
  559. package/src/x_ite/Components/Rendering/TriangleFanSet.js +73 -73
  560. package/src/x_ite/Components/Rendering/TriangleSet.js +51 -53
  561. package/src/x_ite/Components/Rendering/TriangleStripSet.js +76 -76
  562. package/src/x_ite/Components/Rendering/X3DColorNode.js +25 -27
  563. package/src/x_ite/Components/Rendering/X3DComposedGeometryNode.js +318 -321
  564. package/src/x_ite/Components/Rendering/X3DCoordinateNode.js +132 -132
  565. package/src/x_ite/Components/Rendering/X3DGeometricPropertyNode.js +13 -15
  566. package/src/x_ite/Components/Rendering/X3DGeometryNode.js +1190 -1171
  567. package/src/x_ite/Components/Rendering/X3DLineGeometryNode.js +231 -189
  568. package/src/x_ite/Components/Rendering/X3DNormalNode.js +13 -15
  569. package/src/x_ite/Components/Rendering/X3DPointGeometryNode.js +267 -0
  570. package/src/x_ite/Components/Rendering.js +53 -53
  571. package/src/x_ite/Components/RigidBodyPhysics/BallJoint.js +149 -149
  572. package/src/x_ite/Components/RigidBodyPhysics/CollidableOffset.js +229 -229
  573. package/src/x_ite/Components/RigidBodyPhysics/CollidableShape.js +465 -465
  574. package/src/x_ite/Components/RigidBodyPhysics/CollisionCollection.js +152 -154
  575. package/src/x_ite/Components/RigidBodyPhysics/CollisionSensor.js +223 -223
  576. package/src/x_ite/Components/RigidBodyPhysics/CollisionSpace.js +117 -117
  577. package/src/x_ite/Components/RigidBodyPhysics/Contact.js +54 -56
  578. package/src/x_ite/Components/RigidBodyPhysics/DoubleAxisHingeJoint.js +245 -245
  579. package/src/x_ite/Components/RigidBodyPhysics/MotorJoint.js +68 -70
  580. package/src/x_ite/Components/RigidBodyPhysics/RigidBody.js +453 -453
  581. package/src/x_ite/Components/RigidBodyPhysics/RigidBodyCollection.js +326 -326
  582. package/src/x_ite/Components/RigidBodyPhysics/SingleAxisHingeJoint.js +171 -171
  583. package/src/x_ite/Components/RigidBodyPhysics/SliderJoint.js +169 -169
  584. package/src/x_ite/Components/RigidBodyPhysics/UniversalJoint.js +50 -52
  585. package/src/x_ite/Components/RigidBodyPhysics/X3DNBodyCollidableNode.js +101 -101
  586. package/src/x_ite/Components/RigidBodyPhysics/X3DNBodyCollisionSpaceNode.js +15 -15
  587. package/src/x_ite/Components/RigidBodyPhysics/X3DRigidJointNode.js +161 -163
  588. package/src/x_ite/Components/Scripting/Script.js +506 -510
  589. package/src/x_ite/Components/Scripting/X3DScriptNode.js +15 -15
  590. package/src/x_ite/Components/Shaders/ComposedShader.js +215 -178
  591. package/src/x_ite/Components/Shaders/FloatVertexAttribute.js +84 -83
  592. package/src/x_ite/Components/Shaders/Matrix3VertexAttribute.js +74 -74
  593. package/src/x_ite/Components/Shaders/Matrix4VertexAttribute.js +73 -73
  594. package/src/x_ite/Components/Shaders/PackagedShader.js +52 -49
  595. package/src/x_ite/Components/Shaders/ProgramShader.js +36 -38
  596. package/src/x_ite/Components/Shaders/ShaderPart.js +135 -147
  597. package/src/x_ite/Components/Shaders/ShaderProgram.js +49 -46
  598. package/src/x_ite/Components/Shaders/X3DProgrammableShaderObject.js +1259 -1255
  599. package/src/x_ite/Components/Shaders/X3DShaderNode.js +83 -93
  600. package/src/x_ite/Components/Shaders/X3DVertexAttributeNode.js +13 -15
  601. package/src/x_ite/Components/Shaders.js +33 -33
  602. package/src/x_ite/{Execution/ExportedNode.js → Components/Shape/AcousticProperties.js} +41 -71
  603. package/src/x_ite/Components/Shape/Appearance.js +331 -318
  604. package/src/x_ite/Components/Shape/FillProperties.js +101 -98
  605. package/src/x_ite/Components/Shape/LineProperties.js +71 -69
  606. package/src/x_ite/Components/Shape/Material.js +344 -116
  607. package/src/x_ite/Components/Shape/PhysicalMaterial.js +310 -0
  608. package/src/x_ite/Components/Shape/PointProperties.js +79 -95
  609. package/src/x_ite/Components/Shape/Shape.js +178 -181
  610. package/src/x_ite/Components/Shape/TwoSidedMaterial.js +200 -200
  611. package/src/x_ite/Components/Shape/UnlitMaterial.js +93 -46
  612. package/src/x_ite/Components/Shape/X3DAppearanceChildNode.js +13 -15
  613. package/src/x_ite/Components/Shape/X3DAppearanceNode.js +24 -24
  614. package/src/x_ite/Components/Shape/X3DMaterialNode.js +24 -24
  615. package/src/x_ite/Components/Shape/X3DOneSidedMaterialNode.js +158 -54
  616. package/src/x_ite/Components/Shape/X3DShapeNode.js +147 -147
  617. package/src/x_ite/Components/Shape.js +43 -37
  618. package/src/x_ite/Components/Sound/AudioClip.js +135 -140
  619. package/src/x_ite/Components/Sound/Sound.js +246 -246
  620. package/src/x_ite/Components/Sound/X3DSoundNode.js +13 -15
  621. package/src/x_ite/Components/Sound/X3DSoundSourceNode.js +165 -179
  622. package/src/x_ite/Components/Sound.js +19 -19
  623. package/src/x_ite/Components/Text/FontStyle.js +49 -49
  624. package/src/x_ite/Components/Text/Text.js +135 -135
  625. package/src/x_ite/Components/Text/X3DFontStyleNode.js +207 -205
  626. package/src/x_ite/Components/Text.js +17 -17
  627. package/src/x_ite/Components/Texturing/ImageTexture.js +181 -194
  628. package/src/x_ite/Components/Texturing/MovieTexture.js +180 -190
  629. package/src/x_ite/Components/Texturing/MultiTexture.js +255 -262
  630. package/src/x_ite/Components/Texturing/MultiTextureCoordinate.js +124 -118
  631. package/src/x_ite/Components/Texturing/MultiTextureTransform.js +82 -76
  632. package/src/x_ite/Components/Texturing/PixelTexture.js +222 -221
  633. package/src/x_ite/Components/Texturing/TextureCoordinate.js +116 -116
  634. package/src/x_ite/Components/Texturing/TextureCoordinateGenerator.js +90 -90
  635. package/src/x_ite/Components/Texturing/TextureProperties.js +158 -160
  636. package/src/x_ite/Components/Texturing/TextureTransform.js +99 -99
  637. package/src/x_ite/Components/Texturing/X3DSingleTextureCoordinateNode.js +33 -28
  638. package/src/x_ite/Components/Texturing/X3DSingleTextureNode.js +54 -54
  639. package/src/x_ite/Components/Texturing/X3DSingleTextureTransformNode.js +22 -17
  640. package/src/x_ite/Components/Texturing/X3DTexture2DNode.js +135 -124
  641. package/src/x_ite/Components/Texturing/X3DTextureCoordinateNode.js +16 -16
  642. package/src/x_ite/Components/Texturing/X3DTextureNode.js +24 -24
  643. package/src/x_ite/Components/Texturing/X3DTextureTransformNode.js +22 -22
  644. package/src/x_ite/Components/Texturing.js +45 -45
  645. package/src/x_ite/Components/Texturing3D/ComposedTexture3D.js +125 -123
  646. package/src/x_ite/Components/Texturing3D/ImageTexture3D.js +115 -131
  647. package/src/x_ite/Components/Texturing3D/PixelTexture3D.js +158 -160
  648. package/src/x_ite/Components/Texturing3D/TextureCoordinate3D.js +116 -116
  649. package/src/x_ite/Components/Texturing3D/TextureCoordinate4D.js +116 -116
  650. package/src/x_ite/Components/Texturing3D/TextureTransform3D.js +88 -88
  651. package/src/x_ite/Components/Texturing3D/TextureTransformMatrix3D.js +46 -46
  652. package/src/x_ite/Components/Texturing3D/X3DTexture3DNode.js +135 -121
  653. package/src/x_ite/Components/Time/TimeSensor.js +155 -152
  654. package/src/x_ite/Components/Time/X3DTimeDependentNode.js +299 -302
  655. package/src/x_ite/Components/Time.js +15 -15
  656. package/src/x_ite/Components/VolumeRendering/BlendedVolumeStyle.js +338 -338
  657. package/src/x_ite/Components/VolumeRendering/BoundaryEnhancementVolumeStyle.js +80 -80
  658. package/src/x_ite/Components/VolumeRendering/CartoonVolumeStyle.js +228 -228
  659. package/src/x_ite/Components/VolumeRendering/ComposedVolumeStyle.js +163 -163
  660. package/src/x_ite/Components/VolumeRendering/EdgeEnhancementVolumeStyle.js +117 -117
  661. package/src/x_ite/Components/VolumeRendering/IsoSurfaceVolumeData.js +334 -334
  662. package/src/x_ite/Components/VolumeRendering/OpacityMapVolumeStyle.js +116 -116
  663. package/src/x_ite/Components/VolumeRendering/ProjectionVolumeStyle.js +167 -167
  664. package/src/x_ite/Components/VolumeRendering/SegmentedVolumeData.js +247 -247
  665. package/src/x_ite/Components/VolumeRendering/ShadedVolumeStyle.js +198 -198
  666. package/src/x_ite/Components/VolumeRendering/SilhouetteEnhancementVolumeStyle.js +116 -116
  667. package/src/x_ite/Components/VolumeRendering/ToneMappedVolumeStyle.js +126 -126
  668. package/src/x_ite/Components/VolumeRendering/VolumeData.js +173 -173
  669. package/src/x_ite/Components/VolumeRendering/X3DComposableVolumeRenderStyleNode.js +12 -12
  670. package/src/x_ite/Components/VolumeRendering/X3DVolumeDataNode.js +167 -167
  671. package/src/x_ite/Components/VolumeRendering/X3DVolumeRenderStyleNode.js +70 -70
  672. package/src/x_ite/Components/X_ITE/BlendMode.js +143 -145
  673. package/src/x_ite/Components.js +47 -47
  674. package/src/x_ite/Configuration/ComponentInfo.js +47 -42
  675. package/src/x_ite/Configuration/ComponentInfoArray.js +21 -19
  676. package/src/x_ite/Configuration/ProfileInfo.js +33 -23
  677. package/src/x_ite/Configuration/ProfileInfoArray.js +26 -16
  678. package/src/x_ite/Configuration/SupportedComponents.js +311 -311
  679. package/src/x_ite/Configuration/SupportedNodes.js +53 -38
  680. package/src/x_ite/Configuration/SupportedProfiles.js +190 -190
  681. package/src/x_ite/Configuration/UnitInfo.js +60 -51
  682. package/src/x_ite/Configuration/UnitInfoArray.js +17 -10
  683. package/src/x_ite/DEBUG.js +2 -2
  684. package/src/x_ite/Execution/BindableList.js +146 -149
  685. package/src/x_ite/Execution/BindableStack.js +130 -123
  686. package/src/x_ite/Execution/ExportedNodesArray.js +75 -0
  687. package/src/x_ite/Execution/ImportedNodesArray.js +75 -0
  688. package/src/x_ite/{Basic/X3DFieldDefinition.js → Execution/NamedNodesArray.js} +20 -10
  689. package/src/x_ite/Execution/Scene.js +93 -90
  690. package/src/x_ite/Execution/X3DExecutionContext.js +957 -781
  691. package/src/x_ite/Execution/X3DExportedNode.js +152 -0
  692. package/src/x_ite/Execution/X3DImportedNode.js +393 -0
  693. package/src/x_ite/Execution/X3DScene.js +546 -493
  694. package/src/x_ite/Execution/X3DWorld.js +171 -0
  695. package/src/x_ite/Fallback.js +31 -31
  696. package/src/x_ite/Fields/ArrayFields.js +463 -443
  697. package/src/x_ite/Fields/SFBool.js +50 -47
  698. package/src/x_ite/Fields/SFColor.js +163 -160
  699. package/src/x_ite/Fields/SFColorRGBA.js +155 -152
  700. package/src/x_ite/Fields/SFDouble.js +51 -48
  701. package/src/x_ite/Fields/SFFloat.js +51 -48
  702. package/src/x_ite/Fields/SFImage.js +216 -213
  703. package/src/x_ite/Fields/SFInt32.js +47 -44
  704. package/src/x_ite/Fields/SFMatrix3.js +74 -71
  705. package/src/x_ite/Fields/SFMatrix4.js +68 -65
  706. package/src/x_ite/Fields/SFMatrixPrototypeTemplate.js +98 -98
  707. package/src/x_ite/Fields/SFNode.js +392 -299
  708. package/src/x_ite/Fields/SFNodeCache.js +22 -33
  709. package/src/x_ite/Fields/SFRotation.js +178 -175
  710. package/src/x_ite/Fields/SFString.js +71 -68
  711. package/src/x_ite/Fields/SFTime.js +47 -44
  712. package/src/x_ite/Fields/SFVec2.js +73 -70
  713. package/src/x_ite/Fields/SFVec3.js +105 -102
  714. package/src/x_ite/Fields/SFVec4.js +118 -115
  715. package/src/x_ite/Fields/SFVecPrototypeTemplate.js +94 -94
  716. package/src/x_ite/Fields.js +44 -44
  717. package/src/x_ite/InputOutput/FileLoader.js +426 -531
  718. package/src/x_ite/InputOutput/Generator.js +379 -376
  719. package/src/x_ite/{Configuration/X3DInfoArray.js → Parser/GoldenGate.js} +54 -86
  720. package/src/x_ite/Parser/HTMLSupport.js +28 -6
  721. package/src/x_ite/Parser/JSONParser.js +414 -388
  722. package/src/x_ite/Parser/VRMLParser.js +2964 -0
  723. package/src/x_ite/Parser/X3DParser.js +128 -128
  724. package/src/x_ite/Parser/XMLParser.js +1231 -1178
  725. package/src/x_ite/Prototype/ExternProtoDeclarationArray.js +17 -27
  726. package/src/x_ite/Prototype/ProtoDeclarationArray.js +17 -27
  727. package/src/x_ite/Prototype/X3DExternProtoDeclaration.js +279 -297
  728. package/src/x_ite/Prototype/X3DProtoDeclaration.js +264 -263
  729. package/src/x_ite/Prototype/X3DProtoDeclarationNode.js +58 -35
  730. package/src/x_ite/Rendering/DependentRenderer.js +83 -80
  731. package/src/x_ite/Rendering/TextureBuffer.js +171 -168
  732. package/src/x_ite/{Bits → Rendering}/TraverseType.js +11 -11
  733. package/src/x_ite/Rendering/X3DRenderObject.js +895 -906
  734. package/src/x_ite/Routing/RouteArray.js +19 -71
  735. package/src/x_ite/Routing/X3DRoute.js +185 -179
  736. package/src/x_ite/Routing/X3DRoutingContext.js +60 -54
  737. package/src/x_ite/X3D.js +191 -175
  738. package/src/x_ite.config.js +83 -83
  739. package/src/x_ite.css +279 -288
  740. package/src/x_ite.html +226 -193
  741. package/src/x_ite.js +100 -127
  742. package/x_ite.min.html +220 -187
  743. package/src/assets/shaders/webgl1/PointSet.fs +0 -100
  744. package/src/assets/shaders/webgl1/PointSet.vs +0 -70
  745. package/src/assets/shaders/webgl1/Wireframe.fs +0 -74
  746. package/src/assets/shaders/webgl1/Wireframe.vs +0 -63
  747. package/src/assets/shaders/webgl2/PointSet.fs +0 -99
  748. package/src/assets/shaders/webgl2/PointSet.vs +0 -71
  749. package/src/assets/shaders/webgl2/Wireframe.fs +0 -73
  750. package/src/assets/shaders/webgl2/Wireframe.vs +0 -64
  751. package/src/x_ite/Basic/X3DBaseNode.js +0 -1253
  752. package/src/x_ite/Basic/X3DField.js +0 -370
  753. package/src/x_ite/Basic/X3DObjectArrayField.js +0 -545
  754. package/src/x_ite/Basic/X3DTypedArrayField.js +0 -839
  755. package/src/x_ite/Browser/Core/X3DCoreContext.js.~1~ +0 -714
  756. package/src/x_ite/Components/Texturing/X3DTexture2DNode.js.~1~ +0 -209
  757. package/src/x_ite/Execution/ImportedNode.js +0 -375
  758. package/src/x_ite/Execution/World.js +0 -162
  759. package/src/x_ite/Parser/Parser.js +0 -2944
@@ -48,10 +48,10 @@
48
48
 
49
49
 
50
50
  define ([
51
- "x_ite/Bits/X3DCast",
52
- "x_ite/Bits/X3DConstants",
53
- "x_ite/Components/Navigation/OrthoViewpoint",
54
- "standard/Math/Numbers/Matrix3",
51
+ "x_ite/Base/X3DCast",
52
+ "x_ite/Base/X3DConstants",
53
+ "x_ite/Components/Navigation/OrthoViewpoint",
54
+ "standard/Math/Numbers/Matrix3",
55
55
  ],
56
56
  function (X3DCast,
57
57
  X3DConstants,
@@ -60,1291 +60,1295 @@ function (X3DCast,
60
60
  {
61
61
  "use strict";
62
62
 
63
- function X3DProgrammableShaderObject (executionContext)
64
- {
65
- this .addType (X3DConstants .X3DProgrammableShaderObject);
66
-
67
- this .x3d_ClipPlane = [ ];
68
- this .x3d_LightType = [ ];
69
- this .x3d_LightOn = [ ];
70
- this .x3d_LightColor = [ ];
71
- this .x3d_LightIntensity = [ ];
72
- this .x3d_LightAmbientIntensity = [ ];
73
- this .x3d_LightAttenuation = [ ];
74
- this .x3d_LightLocation = [ ];
75
- this .x3d_LightDirection = [ ];
76
- this .x3d_LightBeamWidth = [ ];
77
- this .x3d_LightCutOffAngle = [ ];
78
- this .x3d_LightRadius = [ ];
79
- this .x3d_LightMatrix = [ ];
80
- this .x3d_ShadowIntensity = [ ];
81
- this .x3d_ShadowColor = [ ];
82
- this .x3d_ShadowBias = [ ];
83
- this .x3d_ShadowMatrix = [ ];
84
- this .x3d_ShadowMapSize = [ ];
85
- this .x3d_ShadowMap = [ ];
86
- this .x3d_TextureType = [ ];
87
- this .x3d_Texture2D = [ ];
88
- this .x3d_Texture3D = [ ];
89
- this .x3d_CubeMapTexture = [ ];
90
- this .x3d_MultiTextureMode = [ ];
91
- this .x3d_MultiTextureAlphaMode = [ ];
92
- this .x3d_MultiTextureSource = [ ];
93
- this .x3d_MultiTextureFunction = [ ];
94
- this .x3d_TextureCoordinateGeneratorMode = [ ];
95
- this .x3d_TextureCoordinateGeneratorParameter = [ ];
96
- this .x3d_ProjectiveTexture = [ ];
97
- this .x3d_ProjectiveTextureMatrix = [ ];
98
- this .x3d_ProjectiveTextureLocation = [ ];
99
- this .x3d_TexCoord = [ ];
100
- this .x3d_TextureMatrix = [ ];
101
-
102
- this .numClipPlanes = 0;
103
- this .fogNode = null;
104
- this .numLights = 0;
105
- this .numGlobalLights = 0;
106
- this .lightNodes = [ ];
107
- this .numProjectiveTextures = 0;
108
- this .numGlobalProjectiveTextures = 0;
109
- this .projectiveTextureNodes = [ ];
110
- this .textures = new Map ();
111
- }
112
-
113
- X3DProgrammableShaderObject .prototype =
114
- {
115
- constructor: X3DProgrammableShaderObject,
116
- initialize: function ()
117
- {
118
- const browser = this .getBrowser ();
119
-
120
- this .x3d_MaxClipPlanes = browser .getMaxClipPlanes ();
121
- this .x3d_MaxLights = browser .getMaxLights ();
122
- this .x3d_MaxTextures = browser .getMaxTextures ();
123
- },
124
- hasUserDefinedFields: function ()
125
- {
126
- return true;
127
- },
128
- bindAttributeLocations: function (gl, program)
129
- {
130
- gl .bindAttribLocation (program, 0, "x3d_Vertex");
131
- },
132
- getDefaultUniforms: function ()
133
- {
134
- // Get uniforms and attributes.
135
-
136
- const
137
- browser = this .getBrowser (),
138
- gl = browser .getContext (),
139
- program = this .getProgram ();
140
-
141
- this .x3d_LogarithmicFarFactor1_2 = gl .getUniformLocation (program, "x3d_LogarithmicFarFactor1_2");
142
-
143
- this .x3d_GeometryType = gl .getUniformLocation (program, "x3d_GeometryType");
144
- this .x3d_NumClipPlanes = gl .getUniformLocation (program, "x3d_NumClipPlanes");
145
-
146
- this .x3d_ClipPlanes = gl .getUniformLocation (program, "x3d_ClipPlane");
147
-
148
- for (let i = 0; i < this .x3d_MaxClipPlanes; ++ i)
149
- this .x3d_ClipPlane [i] = gl .getUniformLocation (program, "x3d_ClipPlane[" + i + "]");
150
-
151
- this .x3d_FogType = this .getUniformLocation (gl, program, "x3d_Fog.type", "x3d_FogType");
152
- this .x3d_FogColor = this .getUniformLocation (gl, program, "x3d_Fog.color", "x3d_FogColor");
153
- this .x3d_FogVisibilityRange = this .getUniformLocation (gl, program, "x3d_Fog.visibilityRange", "x3d_FogVisibilityRange");
154
- this .x3d_FogMatrix = this .getUniformLocation (gl, program, "x3d_Fog.matrix", "x3d_FogMatrix");
155
- this .x3d_FogCoord = this .getUniformLocation (gl, program, "x3d_Fog.fogCoord", "x3d_FogCoord");
156
-
157
- this .x3d_AlphaCutoff = gl .getUniformLocation (program, "x3d_AlphaCutoff");
158
-
159
- this .x3d_PointPropertiesPointSizeScaleFactor = gl .getUniformLocation (program, "x3d_PointProperties.pointSizeScaleFactor");
160
- this .x3d_PointPropertiesPointSizeMinValue = gl .getUniformLocation (program, "x3d_PointProperties.pointSizeMinValue");
161
- this .x3d_PointPropertiesPointSizeMaxValue = gl .getUniformLocation (program, "x3d_PointProperties.pointSizeMaxValue");
162
- this .x3d_PointPropertiesPointSizeAttenuation = gl .getUniformLocation (program, "x3d_PointProperties.pointSizeAttenuation");
163
- this .x3d_PointPropertiesColorMode = gl .getUniformLocation (program, "x3d_PointProperties.colorMode");
164
-
165
- this .x3d_LinePropertiesApplied = gl .getUniformLocation (program, "x3d_LineProperties.applied");
166
- this .x3d_LinePropertiesLinewidthScaleFactor = this .getUniformLocation (gl, program, "x3d_LineProperties.linewidthScaleFactor", "x3d_LinewidthScaleFactor");
167
- this .x3d_LinePropertiesLinetype = gl .getUniformLocation (program, "x3d_LineProperties.linetype");
168
-
169
- this .x3d_FillPropertiesFilled = gl .getUniformLocation (program, "x3d_FillProperties.filled");
170
- this .x3d_FillPropertiesHatched = gl .getUniformLocation (program, "x3d_FillProperties.hatched");
171
- this .x3d_FillPropertiesHatchColor = gl .getUniformLocation (program, "x3d_FillProperties.hatchColor");
172
- this .x3d_FillPropertiesHatchStyle = gl .getUniformLocation (program, "x3d_FillProperties.hatchStyle");
173
-
174
- this .x3d_ColorMaterial = gl .getUniformLocation (program, "x3d_ColorMaterial");
175
- this .x3d_NumLights = gl .getUniformLocation (program, "x3d_NumLights");
176
-
177
- for (let i = 0; i < this .x3d_MaxLights; ++ i)
178
- {
179
- this .x3d_LightType [i] = this .getUniformLocation (gl, program, "x3d_LightSource[" + i + "].type", "x3d_LightType[" + i + "]");
180
- this .x3d_LightColor [i] = this .getUniformLocation (gl, program, "x3d_LightSource[" + i + "].color", "x3d_LightColor[" + i + "]");
181
- this .x3d_LightAmbientIntensity [i] = this .getUniformLocation (gl, program, "x3d_LightSource[" + i + "].ambientIntensity", "x3d_LightAmbientIntensity[" + i + "]");
182
- this .x3d_LightIntensity [i] = this .getUniformLocation (gl, program, "x3d_LightSource[" + i + "].intensity", "x3d_LightIntensity[" + i + "]");
183
- this .x3d_LightAttenuation [i] = this .getUniformLocation (gl, program, "x3d_LightSource[" + i + "].attenuation", "x3d_LightAttenuation[" + i + "]");
184
- this .x3d_LightLocation [i] = this .getUniformLocation (gl, program, "x3d_LightSource[" + i + "].location", "x3d_LightLocation[" + i + "]");
185
- this .x3d_LightDirection [i] = this .getUniformLocation (gl, program, "x3d_LightSource[" + i + "].direction", "x3d_LightDirection[" + i + "]");
186
- this .x3d_LightBeamWidth [i] = this .getUniformLocation (gl, program, "x3d_LightSource[" + i + "].beamWidth", "x3d_LightBeamWidth[" + i + "]");
187
- this .x3d_LightCutOffAngle [i] = this .getUniformLocation (gl, program, "x3d_LightSource[" + i + "].cutOffAngle", "x3d_LightCutOffAngle[" + i + "]");
188
- this .x3d_LightRadius [i] = this .getUniformLocation (gl, program, "x3d_LightSource[" + i + "].radius", "x3d_LightRadius[" + i + "]");
189
- this .x3d_LightMatrix [i] = this .getUniformLocation (gl, program, "x3d_LightSource[" + i + "].matrix", "x3d_LightMatrix[" + i + "]");
190
-
191
- this .x3d_ShadowIntensity [i] = gl .getUniformLocation (program, "x3d_LightSource[" + i + "].shadowIntensity");
192
- this .x3d_ShadowColor [i] = gl .getUniformLocation (program, "x3d_LightSource[" + i + "].shadowColor");
193
- this .x3d_ShadowBias [i] = gl .getUniformLocation (program, "x3d_LightSource[" + i + "].shadowBias");
194
- this .x3d_ShadowMatrix [i] = gl .getUniformLocation (program, "x3d_LightSource[" + i + "].shadowMatrix");
195
- this .x3d_ShadowMapSize [i] = gl .getUniformLocation (program, "x3d_LightSource[" + i + "].shadowMapSize");
196
- this .x3d_ShadowMap [i] = gl .getUniformLocation (program, "x3d_ShadowMap[" + i + "]");
197
- }
198
-
199
- this .x3d_AmbientIntensity = this .getUniformLocation (gl, program, "x3d_Material.ambientIntensity", "x3d_FrontMaterial.ambientIntensity");
200
- this .x3d_DiffuseColor = this .getUniformLocation (gl, program, "x3d_Material.diffuseColor", "x3d_FrontMaterial.diffuseColor");
201
- this .x3d_SpecularColor = this .getUniformLocation (gl, program, "x3d_Material.specularColor", "x3d_FrontMaterial.specularColor");
202
- this .x3d_EmissiveColor = this .getUniformLocation (gl, program, "x3d_Material.emissiveColor", "x3d_FrontMaterial.emissiveColor");
203
- this .x3d_Shininess = this .getUniformLocation (gl, program, "x3d_Material.shininess", "x3d_FrontMaterial.shininess");
204
- this .x3d_Transparency = this .getUniformLocation (gl, program, "x3d_Material.transparency", "x3d_FrontMaterial.transparency");
205
-
206
- this .x3d_NumTextures = gl .getUniformLocation (program, "x3d_NumTextures");
207
- this .x3d_NumProjectiveTextures = gl .getUniformLocation (program, "x3d_NumProjectiveTextures");
208
- this .x3d_MultiTextureColor = gl .getUniformLocation (program, "x3d_MultiTextureColor");
209
-
210
- for (let i = 0; i < this .x3d_MaxTextures; ++ i)
211
- {
212
- this .x3d_TextureType [i] = gl .getUniformLocation (program, "x3d_TextureType[" + i + "]");
213
- this .x3d_Texture2D [i] = gl .getUniformLocation (program, "x3d_Texture2D[" + i + "]");
214
- this .x3d_Texture3D [i] = gl .getUniformLocation (program, "x3d_Texture3D[" + i + "]");
215
- this .x3d_CubeMapTexture [i] = gl .getUniformLocation (program, "x3d_CubeMapTexture[" + i + "]");
216
-
217
- this .x3d_MultiTextureMode [i] = gl .getUniformLocation (program, "x3d_MultiTexture[" + i + "].mode");
218
- this .x3d_MultiTextureAlphaMode [i] = gl .getUniformLocation (program, "x3d_MultiTexture[" + i + "].alphaMode");
219
- this .x3d_MultiTextureSource [i] = gl .getUniformLocation (program, "x3d_MultiTexture[" + i + "].source");
220
- this .x3d_MultiTextureFunction [i] = gl .getUniformLocation (program, "x3d_MultiTexture[" + i + "].function");
221
-
222
- this .x3d_TextureCoordinateGeneratorMode [i] = gl .getUniformLocation (program, "x3d_TextureCoordinateGenerator[" + i + "].mode");
223
- this .x3d_TextureCoordinateGeneratorParameter [i] = gl .getUniformLocation (program, "x3d_TextureCoordinateGenerator[" + i + "].parameter");
224
-
225
- this .x3d_ProjectiveTexture [i] = gl .getUniformLocation (program, "x3d_ProjectiveTexture[" + i + "]");
226
- this .x3d_ProjectiveTextureMatrix [i] = gl .getUniformLocation (program, "x3d_ProjectiveTextureMatrix[" + i + "]");
227
- this .x3d_ProjectiveTextureLocation [i] = gl .getUniformLocation (program, "x3d_ProjectiveTextureLocation[" + i + "]");
228
-
229
- this .x3d_TextureMatrix [i] = gl .getUniformLocation (program, "x3d_TextureMatrix[" + i + "]");
230
- this .x3d_TexCoord [i] = this .getAttribLocation (gl, program, "x3d_TexCoord" + i, i ? "" : "x3d_TexCoord");
231
- }
232
-
233
- this .x3d_Viewport = gl .getUniformLocation (program, "x3d_Viewport");
234
- this .x3d_ProjectionMatrix = gl .getUniformLocation (program, "x3d_ProjectionMatrix");
235
- this .x3d_ModelViewMatrix = gl .getUniformLocation (program, "x3d_ModelViewMatrix");
236
- this .x3d_NormalMatrix = gl .getUniformLocation (program, "x3d_NormalMatrix");
237
- this .x3d_CameraSpaceMatrix = gl .getUniformLocation (program, "x3d_CameraSpaceMatrix");
238
-
239
- this .x3d_FogDepth = gl .getAttribLocation (program, "x3d_FogDepth");
240
- this .x3d_Color = gl .getAttribLocation (program, "x3d_Color");
241
- this .x3d_Normal = gl .getAttribLocation (program, "x3d_Normal");
242
- this .x3d_Vertex = gl .getAttribLocation (program, "x3d_Vertex");
243
-
244
- this .x3d_ParticleId = gl .getUniformLocation (program, "x3d_Particle.id");
245
- this .x3d_ParticleLife = gl .getUniformLocation (program, "x3d_Particle.life");
246
- this .x3d_ParticleElapsedTime = gl .getUniformLocation (program, "x3d_Particle.elapsedTime");
247
-
248
- // Fill special uniforms with default values, textures for units are created in X3DTexturingContext.
249
-
250
- gl .uniform1i (this .x3d_LinePropertiesLinetype, browser .getLinetypeUnit ());
251
- gl .uniform1i (this .x3d_FillPropertiesHatchStyle, browser .getHatchStyleUnit ());
252
- gl .uniform1i (this .x3d_NumTextures, 0);
253
- gl .uniform1iv (this .x3d_Texture2D [0], browser .getTexture2DUnits ());
254
- gl .uniform1iv (this .x3d_CubeMapTexture [0], browser .getCubeMapTextureUnits ());
255
- gl .uniform1iv (this .x3d_ShadowMap [0], new Int32Array (this .x3d_MaxLights) .fill (browser .getShadowTextureUnit ()));
256
-
257
- if (browser .getProjectiveTextureMapping ())
258
- gl .uniform1iv (this .x3d_ProjectiveTexture [0], browser .getProjectiveTextureUnits ());
259
-
260
- if (gl .getVersion () >= 2)
261
- gl .uniform1iv (this .x3d_Texture3D [0], browser .getTexture3DUnits ());
262
-
263
- // Return true if valid, otherwise false.
264
-
265
- if (this .x3d_FogDepth < 0)
266
- {
267
- this .enableFogDepthAttribute = Function .prototype;
268
- this .disableFogDepthAttribute = Function .prototype;
269
- }
270
- else
271
- {
272
- delete this .enableFogDepthAttribute;
273
- delete this .disableFogDepthAttribute;
274
- }
275
-
276
- if (this .x3d_Color < 0)
277
- {
278
- this .enableColorAttribute = Function .prototype;
279
- this .disableColorAttribute = Function .prototype;
280
- }
281
- else
282
- {
283
- delete this .enableColorAttribute;
284
- delete this .disableColorAttribute;
285
- }
286
-
287
- if (this .x3d_TexCoord .some (function (location) { return location >= 0; }))
288
- {
289
- delete this .enableTexCoordAttribute;
290
- delete this .disableTexCoordAttribute;
291
- }
292
- else
293
- {
294
- this .enableTexCoordAttribute = Function .prototype;
295
- this .disableTexCoordAttribute = Function .prototype;
296
- }
297
-
298
- if (this .x3d_Normal < 0)
299
- {
300
- this .enableNormalAttribute = Function .prototype;
301
- this .disableNormalAttribute = Function .prototype;
302
- }
303
- else
304
- {
305
- delete this .enableNormalAttribute;
306
- delete this .disableNormalAttribute;
307
- }
308
-
309
- if (this .x3d_Vertex < 0)
310
- {
311
- if (gl .getVersion () >= 2)
312
- console .warn ("Missing »in vec4 x3d_Vertex;«.");
313
- else
314
- console .warn ("Missing »attribute vec4 x3d_Vertex;«.");
315
-
316
- return false;
317
- }
318
-
319
- return true;
320
- },
321
- getUniformLocation: function (gl, program, name, depreciated)
322
- {
323
- // Legacy function to get uniform location.
324
-
325
- let location = gl .getUniformLocation (program, name);
326
-
327
- if (location)
328
- return location;
329
-
330
- // Look for depreciated location.
331
-
332
- if (depreciated)
333
- {
334
- location = gl .getUniformLocation (program, depreciated);
335
-
336
- if (location)
337
- {
338
- console .warn (this .getTypeName (), this .getName (), "Using uniform location name »" + depreciated + "« is depreciated, use »" + name + "«. See https://create3000.github.io/x_ite/Custom-Shaders.html.");
339
- }
340
-
341
- return location;
342
- }
343
-
344
- return 0;
345
- },
346
- getAttribLocation: function (gl, program, name, depreciated)
347
- {
348
- // Legacy function to get uniform location.
349
-
350
- let location = gl .getAttribLocation (program, name);
351
-
352
- if (location >= 0)
353
- return location;
354
-
355
- // Look for depreciated location.
356
-
357
- if (depreciated)
358
- {
359
- location = gl .getAttribLocation (program, depreciated);
360
-
361
- if (location >= 0)
362
- {
363
- console .warn (this .getTypeName (), this .getName (), "Using attribute location name »" + depreciated + "« is depreciated, use »" + name + "«. See https://create3000.github.io/x_ite/Custom-Shaders.html.");
364
- }
365
-
366
- return location;
367
- }
368
-
369
- return -1;
370
- },
371
- addShaderFields: function ()
372
- {
373
- const
374
- gl = this .getBrowser () .getContext (),
375
- program = this .getProgram (),
376
- userDefinedFields = this .getUserDefinedFields ();
377
-
378
- this .textures .clear ();
379
-
380
- userDefinedFields .forEach (function (field)
381
- {
382
- const location = gl .getUniformLocation (program, field .getName ());
383
-
384
- if (location)
385
- {
386
- switch (field .getType ())
387
- {
388
- case X3DConstants .SFImage:
389
- {
390
- location .array = new Int32Array (3 + field .array .length);
391
- break;
392
- }
393
- case X3DConstants .SFMatrix3d:
394
- case X3DConstants .SFMatrix3f:
395
- case X3DConstants .SFRotation:
396
- {
397
- location .array = new Float32Array (9);
398
- break;
399
- }
400
- case X3DConstants .SFMatrix4d:
401
- case X3DConstants .SFMatrix4f:
402
- {
403
- location .array = new Float32Array (16);
404
- break;
405
- }
406
- case X3DConstants .SFNode:
407
- {
408
- break;
409
- }
410
- case X3DConstants .MFBool:
411
- case X3DConstants .MFInt32:
412
- {
413
- location .array = new Int32Array (this .getLocationLength (gl, program, field));
414
- break;
415
- }
416
- case X3DConstants .MFFloat:
417
- case X3DConstants .MFDouble:
418
- case X3DConstants .MFTime:
419
- {
420
- location .array = new Float32Array (this .getLocationLength (gl, program, field));
421
- break;
422
- }
423
- case X3DConstants .MFImage:
424
- {
425
- location .array = new Int32Array (this .getImagesLength (field));
426
- break;
427
- }
428
- case X3DConstants .MFMatrix3d:
429
- case X3DConstants .MFMatrix3f:
430
- case X3DConstants .MFRotation:
431
- {
432
- location .array = new Float32Array (9 * this .getLocationLength (gl, program, field));
433
- break;
434
- }
435
- case X3DConstants .MFMatrix4d:
436
- case X3DConstants .MFMatrix4f:
437
- {
438
- location .array = new Float32Array (16 * this .getLocationLength (gl, program, field));
439
- break;
440
- }
441
- case X3DConstants .MFNode:
442
- {
443
- const locations = location .locations = [ ];
444
-
445
- for (let i = 0;; ++ i)
446
- {
447
- const l = gl .getUniformLocation (program, field .getName () + "[" + i + "]");
448
-
449
- if (! l)
450
- break;
451
-
452
- locations .push (l);
453
- }
454
-
455
- break;
456
- }
457
- case X3DConstants .MFVec2d:
458
- case X3DConstants .MFVec2f:
459
- {
460
- location .array = new Float32Array (2 * this .getLocationLength (gl, program, field));
461
- break;
462
- }
463
- case X3DConstants .MFVec3d:
464
- case X3DConstants .MFVec3f:
465
- case X3DConstants .MFColor:
466
- {
467
- location .array = new Float32Array (3 * this .getLocationLength (gl, program, field));
468
- break;
469
- }
470
- case X3DConstants .MFVec4d:
471
- case X3DConstants .MFVec4f:
472
- case X3DConstants .MFColorRGBA:
473
- {
474
- location .array = new Float32Array (4 * this .getLocationLength (gl, program, field));
475
- break;
476
- }
477
- }
478
-
479
- if (location .array)
480
- field ._uniformLocation = location .array .length ? location : null;
481
- else
482
- field ._uniformLocation = location;
483
-
484
- field .addInterest ("set_field__", this);
485
-
486
- this .set_field__ (field);
487
- }
488
- },
489
- this);
490
- },
491
- removeShaderFields: function ()
492
- {
493
- const userDefinedFields = this .getUserDefinedFields ();
494
-
495
- userDefinedFields .forEach (function (field)
496
- {
497
- field .removeInterest ("set_field__", this);
498
- },
499
- this);
500
- },
501
- set_field__: (function ()
502
- {
503
- const matrix3 = new Matrix3 ();
504
-
505
- return function (field)
506
- {
507
- const
508
- gl = this .getBrowser () .getContext (),
509
- location = field ._uniformLocation;
510
-
511
- if (location)
512
- {
513
- switch (field .getType ())
514
- {
515
- case X3DConstants .SFBool:
516
- case X3DConstants .SFInt32:
517
- {
518
- gl .uniform1i (location, field .getValue ());
519
- return;
520
- }
521
- case X3DConstants .SFColor:
522
- {
523
- const value = field .getValue ();
524
- gl .uniform3f (location, value .r, value .g, value .b);
525
- return;
526
- }
527
- case X3DConstants .SFColorRGBA:
528
- {
529
- const value = field .getValue ();
530
- gl .uniform4f (location, value .r, value .g, value .b, value .a);
531
- return;
532
- }
533
- case X3DConstants .SFDouble:
534
- case X3DConstants .SFFloat:
535
- case X3DConstants .SFTime:
536
- {
537
- gl .uniform1f (location, field .getValue ());
538
- return;
539
- }
540
- case X3DConstants .SFImage:
541
- {
542
- let array = location .array;
543
-
544
- const
545
- pixels = field .array,
546
- length = 3 + pixels .length;
547
-
548
- if (length !== array .length)
549
- array = location .array = new Int32Array (length);
550
-
551
- array [0] = field .width;
552
- array [1] = field .height;
553
- array [2] = field .comp;
554
-
555
- for (let a = 3, p = 0, pl = pixels .length; p < pl; ++ p, ++ a)
556
- array [a] = pixels [p];
557
-
558
- gl .uniform1iv (location, array);
559
- return;
560
- }
561
- case X3DConstants .SFMatrix3d:
562
- case X3DConstants .SFMatrix3f:
563
- {
564
- location .array .set (field .getValue ());
565
-
566
- gl .uniformMatrix3fv (location, false, location .array);
567
- return;
568
- }
569
- case X3DConstants .SFMatrix4d:
570
- case X3DConstants .SFMatrix4f:
571
- {
572
- location .array .set (field .getValue ());
573
-
574
- gl .uniformMatrix4fv (location, false, location .array);
575
- return;
576
- }
577
- case X3DConstants .SFNode:
578
- {
579
- const texture = X3DCast (X3DConstants .X3DTextureNode, field);
580
-
581
- if (texture)
582
- {
583
- this .textures .set (location, { name: field .getName (), texture: texture, textureUnit: undefined } );
584
- return;
585
- }
586
-
587
- this .textures .delete (location);
588
- return;
589
- }
590
- case X3DConstants .SFRotation:
591
- {
592
- field .getValue () .getMatrix (location .array);
593
-
594
- gl .uniformMatrix3fv (location, false, location .array);
595
- return;
596
- }
597
- case X3DConstants .SFString:
598
- {
599
- return;
600
- }
601
- case X3DConstants .SFVec2d:
602
- case X3DConstants .SFVec2f:
603
- {
604
- const value = field .getValue ();
605
- gl .uniform2f (location, value .x, value .y);
606
- return;
607
- }
608
- case X3DConstants .SFVec3d:
609
- case X3DConstants .SFVec3f:
610
- {
611
- const value = field .getValue ();
612
- gl .uniform3f (location, value .x, value .y, value .z);
613
- return;
614
- }
615
- case X3DConstants .SFVec4d:
616
- case X3DConstants .SFVec4f:
617
- {
618
- const value = field .getValue ();
619
- gl .uniform4f (location, value .x, value .y, value .z, value .w);
620
- return;
621
- }
622
- case X3DConstants .MFBool:
623
- case X3DConstants .MFInt32:
624
- {
625
- const array = location .array;
626
-
627
- for (var i = 0, length = field .length; i < length; ++ i)
628
- array [i] = field [i];
629
-
630
- for (let length = array .length; i < length; ++ i)
631
- array [i] = 0;
632
-
633
- gl .uniform1iv (location, array);
634
- return;
635
- }
636
- case X3DConstants .MFColor:
637
- {
638
- const array = location .array;
639
-
640
- for (var i = 0, k = 0, length = field .length; i < length; ++ i)
641
- {
642
- const color = field [i];
643
-
644
- array [k++] = color .r;
645
- array [k++] = color .g;
646
- array [k++] = color .b;
647
- }
648
-
649
- for (let length = array .length; k < length; ++ k)
650
- array [k] = 0;
651
-
652
- gl .uniform3fv (location, array);
653
- return;
654
- }
655
- case X3DConstants .MFColorRGBA:
656
- {
657
- const array = location .array;
658
-
659
- for (var i = 0, k = 0, length = field .length; i < length; ++ i)
660
- {
661
- const color = field [i];
662
-
663
- array [k++] = color .r;
664
- array [k++] = color .g;
665
- array [k++] = color .b;
666
- array [k++] = color .a;
667
- }
668
-
669
- for (let length = array .length; k < length; ++ k)
670
- array [k] = 0;
671
-
672
- gl .uniform4fv (location, array);
673
- return;
674
- }
675
- case X3DConstants .MFDouble:
676
- case X3DConstants .MFFloat:
677
- case X3DConstants .MFTime:
678
- {
679
- const array = location .array;
680
-
681
- for (var i = 0, length = field .length; i < length; ++ i)
682
- array [i] = field [i];
683
-
684
- for (let length = array .length; i < length; ++ i)
685
- array [i] = 0;
686
-
687
- gl .uniform1fv (location, array);
688
- return;
689
- }
690
- case X3DConstants .MFImage:
691
- {
692
- const array = location .array;
693
-
694
- for (let i = 0, a = 0, length = field .length; i < length; ++ i)
695
- {
696
- const
697
- value = field [i],
698
- pixels = value .array;
699
-
700
- array [a ++] = value .width;
701
- array [a ++] = value .height;
702
- array [a ++] = value .comp;
703
-
704
- for (let p = 0, pl = pixels .length; p < pl; ++ p)
705
- array [a ++] = pixels [p];
706
- }
707
-
708
- gl .uniform1iv (location, array);
709
- return;
710
- }
711
- case X3DConstants .MFMatrix3d:
712
- case X3DConstants .MFMatrix3f:
713
- {
714
- const array = location .array;
715
-
716
- for (var i = 0, k = 0, length = field .length; i < length; ++ i)
717
- {
718
- const matrix = field [i];
719
-
720
- for (let m = 0; m < 9; ++ m)
721
- array [k++] = matrix [m];
722
- }
723
-
724
- for (let length = array .length; k < length; ++ k)
725
- array [k] = 0;
726
-
727
- gl .uniformMatrix3fv (location, false, array);
728
- return;
729
- }
730
- case X3DConstants .MFMatrix4d:
731
- case X3DConstants .MFMatrix4f:
732
- {
733
- const array = location .array;
734
-
735
- for (var i = 0, k = 0, length = field .length; i < length; ++ i)
736
- {
737
- const matrix = field [i];
738
-
739
- for (let m = 0; m < 16; ++ m)
740
- array [k++] = matrix [m];
741
- }
742
-
743
- for (let length = array .length; k < length; ++ k)
744
- array [k] = 0;
745
-
746
- gl .uniformMatrix4fv (location, false, array);
747
- return;
748
- }
749
- case X3DConstants .MFNode:
750
- {
751
- const locations = location .locations;
752
-
753
- for (let i = 0, length = field .length; i < length; ++ i)
754
- {
755
- const texture = X3DCast (X3DConstants .X3DTextureNode, field [i]);
756
-
757
- if (texture)
758
- {
759
- this .textures .set (locations [i], { name: field [i] .getName (), texture: texture, textureUnit: undefined } );
760
- continue;
761
- }
762
- }
763
-
764
- return;
765
- }
766
- case X3DConstants .MFRotation:
767
- {
768
- const array = location .array;
769
-
770
- for (var i = 0, k = 0, length = field .length; i < length; ++ i)
771
- {
772
- const matrix = field [i] .getValue () .getMatrix (matrix3);
773
-
774
- array [k++] = matrix [0];
775
- array [k++] = matrix [1];
776
- array [k++] = matrix [2];
777
- array [k++] = matrix [3];
778
- array [k++] = matrix [4];
779
- array [k++] = matrix [5];
780
- array [k++] = matrix [6];
781
- array [k++] = matrix [7];
782
- array [k++] = matrix [8];
783
- }
784
-
785
- for (let length = array .length; k < length; ++ k)
786
- array [k] = 0;
787
-
788
- gl .uniformMatrix3fv (location, false, array);
789
- return;
790
- }
791
- case X3DConstants .MFString:
792
- {
793
- return;
794
- }
795
- case X3DConstants .MFVec2d:
796
- case X3DConstants .MFVec2f:
797
- {
798
- const array = location .array;
799
-
800
- for (var i = 0, k = 0, length = field .length; i < length; ++ i)
801
- {
802
- const vector = field [i];
803
-
804
- array [k++] = vector .x;
805
- array [k++] = vector .y;
806
- }
807
-
808
- for (let length = array .length; k < length; ++ k)
809
- array [k] = 0;
810
-
811
- gl .uniform2fv (location, array);
812
- return;
813
- }
814
- case X3DConstants .MFVec3d:
815
- case X3DConstants .MFVec3f:
816
- {
817
- const array = location .array;
818
-
819
- for (var i = 0, k = 0, length = field .length; i < length; ++ i)
820
- {
821
- const vector = field [i];
822
-
823
- array [k++] = vector .x;
824
- array [k++] = vector .y;
825
- array [k++] = vector .z;
826
- }
827
-
828
- for (let length = array .length; k < length; ++ k)
829
- array [k] = 0;
830
-
831
- gl .uniform3fv (location, array);
832
- return;
833
- }
834
- case X3DConstants .MFVec4d:
835
- case X3DConstants .MFVec4f:
836
- {
837
- const array = location .array;
838
-
839
- for (var i = 0, k = 0, length = field .length; i < length; ++ i)
840
- {
841
- const vector = field [i];
842
-
843
- array [k++] = vector .x;
844
- array [k++] = vector .y;
845
- array [k++] = vector .z;
846
- array [k++] = vector .w;
847
- }
848
-
849
- for (let length = array .length; k < length; ++ k)
850
- array [k] = 0;
851
-
852
- gl .uniform4fv (location, array);
853
- return;
854
- }
855
- }
856
- }
857
- };
858
- })(),
859
- getImagesLength: function (field)
860
- {
861
- const images = field .getValue ();
862
-
863
- let length = 3 * images .length;
864
-
865
- for (const image of images)
866
- length += image .array .length;
867
-
868
- return length;
869
- },
870
- getLocationLength: function (gl, program, field)
871
- {
872
- const name = field .getName ();
873
-
874
- for (let i = 0; ; ++ i)
875
- {
876
- const location = gl .getUniformLocation (program, name + "[" + i + "]");
877
-
878
- if (! location)
879
- return i;
880
- }
881
- },
882
- hasFog: function (fogNode)
883
- {
884
- if (this .fogNode === fogNode)
885
- return true;
886
-
887
- this .fogNode = fogNode;
888
-
889
- return false;
890
- },
891
- hasLight: function (i, lightNode)
892
- {
893
- if (this .lightNodes [i] === lightNode)
894
- return true;
895
-
896
- this .lightNodes [i] = lightNode;
897
-
898
- return false;
899
- },
900
- hasTextureProjector: function (i, textureProjectorNode)
901
- {
902
- if (this .projectiveTextureNodes [i] === textureProjectorNode)
903
- return true;
904
-
905
- this .projectiveTextureNodes [i] = textureProjectorNode;
906
-
907
- return false;
908
- },
909
- setLocalObjects: function (gl, localObjects)
910
- {
911
- // Clip planes and local lights
912
-
913
- this .numClipPlanes = 0;
914
- this .numLights = 0;
915
- this .numProjectiveTextures = 0;
916
- this .lightNodes .length = 0;
917
- this .projectiveTextureNodes .length = 0;
63
+ const _uniformLocation = Symbol .for ("X3DField.uniformLocation");
64
+
65
+ function X3DProgrammableShaderObject (executionContext)
66
+ {
67
+ this .addType (X3DConstants .X3DProgrammableShaderObject);
68
+
69
+ this .x3d_ClipPlane = [ ];
70
+ this .x3d_LightType = [ ];
71
+ this .x3d_LightOn = [ ];
72
+ this .x3d_LightColor = [ ];
73
+ this .x3d_LightIntensity = [ ];
74
+ this .x3d_LightAmbientIntensity = [ ];
75
+ this .x3d_LightAttenuation = [ ];
76
+ this .x3d_LightLocation = [ ];
77
+ this .x3d_LightDirection = [ ];
78
+ this .x3d_LightBeamWidth = [ ];
79
+ this .x3d_LightCutOffAngle = [ ];
80
+ this .x3d_LightRadius = [ ];
81
+ this .x3d_LightMatrix = [ ];
82
+ this .x3d_ShadowIntensity = [ ];
83
+ this .x3d_ShadowColor = [ ];
84
+ this .x3d_ShadowBias = [ ];
85
+ this .x3d_ShadowMatrix = [ ];
86
+ this .x3d_ShadowMapSize = [ ];
87
+ this .x3d_ShadowMap = [ ];
88
+ this .x3d_Textures = [ ];
89
+ this .x3d_MultiTextureMode = [ ];
90
+ this .x3d_MultiTextureAlphaMode = [ ];
91
+ this .x3d_MultiTextureSource = [ ];
92
+ this .x3d_MultiTextureFunction = [ ];
93
+ this .x3d_TextureCoordinateGeneratorMode = [ ];
94
+ this .x3d_TextureCoordinateGeneratorParameter = [ ];
95
+ this .x3d_ProjectiveTexture = [ ];
96
+ this .x3d_ProjectiveTextureMatrix = [ ];
97
+ this .x3d_ProjectiveTextureLocation = [ ];
98
+ this .x3d_TexCoord = [ ];
99
+ this .x3d_TextureMatrix = [ ];
100
+
101
+ this .numClipPlanes = 0;
102
+ this .fogNode = null;
103
+ this .numLights = 0;
104
+ this .numGlobalLights = 0;
105
+ this .lightNodes = [ ];
106
+ this .numProjectiveTextures = 0;
107
+ this .numGlobalProjectiveTextures = 0;
108
+ this .projectiveTextureNodes = [ ];
109
+ this .textures = new Map ();
110
+ }
111
+
112
+ X3DProgrammableShaderObject .prototype =
113
+ {
114
+ constructor: X3DProgrammableShaderObject,
115
+ initialize: function ()
116
+ {
117
+ const browser = this .getBrowser ();
118
+
119
+ this .x3d_MaxClipPlanes = browser .getMaxClipPlanes ();
120
+ this .x3d_MaxLights = browser .getMaxLights ();
121
+ this .x3d_MaxTextures = browser .getMaxTextures ();
122
+ },
123
+ canUserDefinedFields: function ()
124
+ {
125
+ return true;
126
+ },
127
+ bindAttributeLocations: function (gl, program)
128
+ {
129
+ gl .bindAttribLocation (program, 0, "x3d_Vertex");
130
+ },
131
+ getDefaultUniforms: function ()
132
+ {
133
+ // Get uniforms and attributes.
134
+
135
+ const
136
+ browser = this .getBrowser (),
137
+ gl = browser .getContext (),
138
+ program = this .getProgram ();
139
+
140
+ this .x3d_LogarithmicFarFactor1_2 = gl .getUniformLocation (program, "x3d_LogarithmicFarFactor1_2");
141
+
142
+ this .x3d_GeometryType = gl .getUniformLocation (program, "x3d_GeometryType");
143
+ this .x3d_NumClipPlanes = gl .getUniformLocation (program, "x3d_NumClipPlanes");
144
+
145
+ this .x3d_ClipPlanes = gl .getUniformLocation (program, "x3d_ClipPlane");
146
+
147
+ for (let i = 0; i < this .x3d_MaxClipPlanes; ++ i)
148
+ this .x3d_ClipPlane [i] = gl .getUniformLocation (program, "x3d_ClipPlane[" + i + "]");
149
+
150
+ this .x3d_FogType = this .getUniformLocation (gl, program, "x3d_Fog.type", "x3d_FogType");
151
+ this .x3d_FogColor = this .getUniformLocation (gl, program, "x3d_Fog.color", "x3d_FogColor");
152
+ this .x3d_FogVisibilityRange = this .getUniformLocation (gl, program, "x3d_Fog.visibilityRange", "x3d_FogVisibilityRange");
153
+ this .x3d_FogMatrix = this .getUniformLocation (gl, program, "x3d_Fog.matrix", "x3d_FogMatrix");
154
+ this .x3d_FogCoord = this .getUniformLocation (gl, program, "x3d_Fog.fogCoord", "x3d_FogCoord");
155
+
156
+ this .x3d_AlphaCutoff = gl .getUniformLocation (program, "x3d_AlphaCutoff");
157
+
158
+ this .x3d_PointPropertiesPointSizeScaleFactor = gl .getUniformLocation (program, "x3d_PointProperties.pointSizeScaleFactor");
159
+ this .x3d_PointPropertiesPointSizeMinValue = gl .getUniformLocation (program, "x3d_PointProperties.pointSizeMinValue");
160
+ this .x3d_PointPropertiesPointSizeMaxValue = gl .getUniformLocation (program, "x3d_PointProperties.pointSizeMaxValue");
161
+ this .x3d_PointPropertiesPointSizeAttenuation = gl .getUniformLocation (program, "x3d_PointProperties.pointSizeAttenuation");
162
+
163
+ this .x3d_LinePropertiesApplied = gl .getUniformLocation (program, "x3d_LineProperties.applied");
164
+ this .x3d_LinePropertiesLinewidthScaleFactor = this .getUniformLocation (gl, program, "x3d_LineProperties.linewidthScaleFactor", "x3d_LinewidthScaleFactor");
165
+ this .x3d_LinePropertiesLinetype = gl .getUniformLocation (program, "x3d_LineProperties.linetype");
166
+
167
+ this .x3d_FillPropertiesFilled = gl .getUniformLocation (program, "x3d_FillProperties.filled");
168
+ this .x3d_FillPropertiesHatched = gl .getUniformLocation (program, "x3d_FillProperties.hatched");
169
+ this .x3d_FillPropertiesHatchColor = gl .getUniformLocation (program, "x3d_FillProperties.hatchColor");
170
+ this .x3d_FillPropertiesHatchStyle = gl .getUniformLocation (program, "x3d_FillProperties.hatchStyle");
171
+
172
+ this .x3d_ColorMaterial = gl .getUniformLocation (program, "x3d_ColorMaterial");
173
+ this .x3d_NumLights = gl .getUniformLocation (program, "x3d_NumLights");
174
+
175
+ for (let i = 0; i < this .x3d_MaxLights; ++ i)
176
+ {
177
+ this .x3d_LightType [i] = this .getUniformLocation (gl, program, "x3d_LightSource[" + i + "].type", "x3d_LightType[" + i + "]");
178
+ this .x3d_LightColor [i] = this .getUniformLocation (gl, program, "x3d_LightSource[" + i + "].color", "x3d_LightColor[" + i + "]");
179
+ this .x3d_LightAmbientIntensity [i] = this .getUniformLocation (gl, program, "x3d_LightSource[" + i + "].ambientIntensity", "x3d_LightAmbientIntensity[" + i + "]");
180
+ this .x3d_LightIntensity [i] = this .getUniformLocation (gl, program, "x3d_LightSource[" + i + "].intensity", "x3d_LightIntensity[" + i + "]");
181
+ this .x3d_LightAttenuation [i] = this .getUniformLocation (gl, program, "x3d_LightSource[" + i + "].attenuation", "x3d_LightAttenuation[" + i + "]");
182
+ this .x3d_LightLocation [i] = this .getUniformLocation (gl, program, "x3d_LightSource[" + i + "].location", "x3d_LightLocation[" + i + "]");
183
+ this .x3d_LightDirection [i] = this .getUniformLocation (gl, program, "x3d_LightSource[" + i + "].direction", "x3d_LightDirection[" + i + "]");
184
+ this .x3d_LightBeamWidth [i] = this .getUniformLocation (gl, program, "x3d_LightSource[" + i + "].beamWidth", "x3d_LightBeamWidth[" + i + "]");
185
+ this .x3d_LightCutOffAngle [i] = this .getUniformLocation (gl, program, "x3d_LightSource[" + i + "].cutOffAngle", "x3d_LightCutOffAngle[" + i + "]");
186
+ this .x3d_LightRadius [i] = this .getUniformLocation (gl, program, "x3d_LightSource[" + i + "].radius", "x3d_LightRadius[" + i + "]");
187
+ this .x3d_LightMatrix [i] = this .getUniformLocation (gl, program, "x3d_LightSource[" + i + "].matrix", "x3d_LightMatrix[" + i + "]");
188
+
189
+ this .x3d_ShadowIntensity [i] = gl .getUniformLocation (program, "x3d_LightSource[" + i + "].shadowIntensity");
190
+ this .x3d_ShadowColor [i] = gl .getUniformLocation (program, "x3d_LightSource[" + i + "].shadowColor");
191
+ this .x3d_ShadowBias [i] = gl .getUniformLocation (program, "x3d_LightSource[" + i + "].shadowBias");
192
+ this .x3d_ShadowMatrix [i] = gl .getUniformLocation (program, "x3d_LightSource[" + i + "].shadowMatrix");
193
+ this .x3d_ShadowMapSize [i] = gl .getUniformLocation (program, "x3d_LightSource[" + i + "].shadowMapSize");
194
+ this .x3d_ShadowMap [i] = gl .getUniformLocation (program, "x3d_ShadowMap[" + i + "]");
195
+ }
196
+
197
+ this .x3d_AmbientIntensity = this .getUniformLocation (gl, program, "x3d_Material.ambientIntensity", "x3d_FrontMaterial.ambientIntensity");
198
+ this .x3d_DiffuseColor = this .getUniformLocation (gl, program, "x3d_Material.diffuseColor", "x3d_FrontMaterial.diffuseColor");
199
+ this .x3d_SpecularColor = this .getUniformLocation (gl, program, "x3d_Material.specularColor", "x3d_FrontMaterial.specularColor");
200
+ this .x3d_EmissiveColor = this .getUniformLocation (gl, program, "x3d_Material.emissiveColor", "x3d_FrontMaterial.emissiveColor");
201
+ this .x3d_Shininess = this .getUniformLocation (gl, program, "x3d_Material.shininess", "x3d_FrontMaterial.shininess");
202
+ this .x3d_BaseColor = gl .getUniformLocation (program, "x3d_Material.baseColor");
203
+ this .x3d_Metallic = gl .getUniformLocation (program, "x3d_Material.metallic");
204
+ this .x3d_Roughness = gl .getUniformLocation (program, "x3d_Material.roughness");
205
+ this .x3d_OcclusionStrength = gl .getUniformLocation (program, "x3d_Material.occlusionStrength");
206
+ this .x3d_NormalScale = gl .getUniformLocation (program, "x3d_Material.normalScale");
207
+ this .x3d_Transparency = this .getUniformLocation (gl, program, "x3d_Material.transparency", "x3d_FrontMaterial.transparency");
208
+
209
+ const materialTextures = [
210
+ "x3d_AmbientTexture",
211
+ "x3d_DiffuseTexture",
212
+ "x3d_SpecularTexture",
213
+ "x3d_EmissiveTexture",
214
+ "x3d_ShininessTexture",
215
+ "x3d_BaseTexture",
216
+ "x3d_MetallicRoughnessTexture",
217
+ "x3d_OcclusionTexture",
218
+ "x3d_NormalTexture",
219
+ ];
220
+
221
+ for (const materialTexture of materialTextures)
222
+ {
223
+ this [materialTexture] = {
224
+ textureTransformMapping: gl .getUniformLocation (program, materialTexture + ".textureTransformMapping"),
225
+ textureCoordinateMapping: gl .getUniformLocation (program, materialTexture + ".textureCoordinateMapping"),
226
+ texture2D: gl .getUniformLocation (program, materialTexture + ".texture2D"),
227
+ texture3D: gl .getUniformLocation (program, materialTexture + ".texture3D"),
228
+ textureCube: gl .getUniformLocation (program, materialTexture + ".textureCube"),
229
+ };
230
+ }
231
+
232
+ this .x3d_NumTextures = gl .getUniformLocation (program, "x3d_NumTextures");
233
+ this .x3d_NumProjectiveTextures = gl .getUniformLocation (program, "x3d_NumProjectiveTextures");
234
+ this .x3d_MultiTextureColor = gl .getUniformLocation (program, "x3d_MultiTextureColor");
235
+
236
+ for (let i = 0; i < this .x3d_MaxTextures; ++ i)
237
+ {
238
+ this .x3d_Textures [i] = {
239
+ textureType: gl .getUniformLocation (program, "x3d_TextureType[" + i + "]"),
240
+ texture2D: gl .getUniformLocation (program, "x3d_Texture2D[" + i + "]"),
241
+ texture3D: gl .getUniformLocation (program, "x3d_Texture3D[" + i + "]"),
242
+ textureCube: this .getUniformLocation (gl, program, "x3d_TextureCube[" + i + "]", "x3d_CubeMapTexture[" + i + "]"),
243
+ }
244
+
245
+ this .x3d_MultiTextureMode [i] = gl .getUniformLocation (program, "x3d_MultiTexture[" + i + "].mode");
246
+ this .x3d_MultiTextureAlphaMode [i] = gl .getUniformLocation (program, "x3d_MultiTexture[" + i + "].alphaMode");
247
+ this .x3d_MultiTextureSource [i] = gl .getUniformLocation (program, "x3d_MultiTexture[" + i + "].source");
248
+ this .x3d_MultiTextureFunction [i] = gl .getUniformLocation (program, "x3d_MultiTexture[" + i + "].function");
249
+
250
+ this .x3d_TextureCoordinateGeneratorMode [i] = gl .getUniformLocation (program, "x3d_TextureCoordinateGenerator[" + i + "].mode");
251
+ this .x3d_TextureCoordinateGeneratorParameter [i] = gl .getUniformLocation (program, "x3d_TextureCoordinateGenerator[" + i + "].parameter");
252
+
253
+ this .x3d_ProjectiveTexture [i] = gl .getUniformLocation (program, "x3d_ProjectiveTexture[" + i + "]");
254
+ this .x3d_ProjectiveTextureMatrix [i] = gl .getUniformLocation (program, "x3d_ProjectiveTextureMatrix[" + i + "]");
255
+ this .x3d_ProjectiveTextureLocation [i] = gl .getUniformLocation (program, "x3d_ProjectiveTextureLocation[" + i + "]");
256
+
257
+ this .x3d_TextureMatrix [i] = gl .getUniformLocation (program, "x3d_TextureMatrix[" + i + "]");
258
+ this .x3d_TexCoord [i] = this .getAttribLocation (gl, program, "x3d_TexCoord" + i, i ? "" : "x3d_TexCoord");
259
+ }
260
+
261
+ this .x3d_Viewport = gl .getUniformLocation (program, "x3d_Viewport");
262
+ this .x3d_ProjectionMatrix = gl .getUniformLocation (program, "x3d_ProjectionMatrix");
263
+ this .x3d_ModelViewMatrix = gl .getUniformLocation (program, "x3d_ModelViewMatrix");
264
+ this .x3d_NormalMatrix = gl .getUniformLocation (program, "x3d_NormalMatrix");
265
+ this .x3d_CameraSpaceMatrix = gl .getUniformLocation (program, "x3d_CameraSpaceMatrix");
266
+
267
+ this .x3d_FogDepth = gl .getAttribLocation (program, "x3d_FogDepth");
268
+ this .x3d_Color = gl .getAttribLocation (program, "x3d_Color");
269
+ this .x3d_Normal = gl .getAttribLocation (program, "x3d_Normal");
270
+ this .x3d_Vertex = gl .getAttribLocation (program, "x3d_Vertex");
271
+
272
+ this .x3d_ParticleId = gl .getUniformLocation (program, "x3d_Particle.id");
273
+ this .x3d_ParticleLife = gl .getUniformLocation (program, "x3d_Particle.life");
274
+ this .x3d_ParticleElapsedTime = gl .getUniformLocation (program, "x3d_Particle.elapsedTime");
275
+
276
+ // Fill special uniforms with default values, textures for units are created in X3DTexturingContext.
277
+
278
+ gl .uniform1i (this .x3d_LinePropertiesLinetype, browser .getDefaultTexture2DUnit ());
279
+ gl .uniform1i (this .x3d_FillPropertiesHatchStyle, browser .getDefaultTexture2DUnit ());
280
+
281
+ for (const materialTexture of materialTextures)
282
+ {
283
+ gl .uniform1i (this [materialTexture] .texture2D, browser .getDefaultTexture2DUnit ());
284
+ gl .uniform1i (this [materialTexture] .texture3D, browser .getDefaultTexture3DUnit ());
285
+ gl .uniform1i (this [materialTexture] .textureCube, browser .getDefaultTextureCubeUnit ());
286
+ }
287
+
288
+ gl .uniform1i (this .x3d_NumTextures, 0);
289
+
290
+ for (const uniforms of this .x3d_Textures)
291
+ {
292
+ gl .uniform1i (uniforms .texture2D, browser .getDefaultTexture2DUnit ());
293
+
294
+ if (gl .getVersion () >= 2)
295
+ gl .uniform1i (uniforms .texture3D, browser .getDefaultTexture3DUnit ());
296
+
297
+ gl .uniform1i (uniforms .textureCube, browser .getDefaultTextureCubeUnit ());
298
+ }
299
+
300
+ for (const uniform of this .x3d_ShadowMap)
301
+ gl .uniform1i (uniform, browser .getDefaultTexture2DUnit ());
302
+
303
+ if (browser .getProjectiveTextureMapping ())
304
+ {
305
+ for (const uniform of this .x3d_ProjectiveTexture)
306
+ gl .uniform1i (uniform, browser .getDefaultTexture2DUnit ());
307
+ }
308
+
309
+ // Return true if valid, otherwise false.
310
+
311
+ if (this .x3d_FogDepth < 0)
312
+ {
313
+ this .enableFogDepthAttribute = Function .prototype;
314
+ this .disableFogDepthAttribute = Function .prototype;
315
+ }
316
+ else
317
+ {
318
+ delete this .enableFogDepthAttribute;
319
+ delete this .disableFogDepthAttribute;
320
+ }
321
+
322
+ if (this .x3d_Color < 0)
323
+ {
324
+ this .enableColorAttribute = Function .prototype;
325
+ this .disableColorAttribute = Function .prototype;
326
+ }
327
+ else
328
+ {
329
+ delete this .enableColorAttribute;
330
+ delete this .disableColorAttribute;
331
+ }
332
+
333
+ if (this .x3d_TexCoord .some (function (location) { return location >= 0; }))
334
+ {
335
+ delete this .enableTexCoordAttribute;
336
+ delete this .disableTexCoordAttribute;
337
+ }
338
+ else
339
+ {
340
+ this .enableTexCoordAttribute = Function .prototype;
341
+ this .disableTexCoordAttribute = Function .prototype;
342
+ }
343
+
344
+ if (this .x3d_Normal < 0)
345
+ {
346
+ this .enableNormalAttribute = Function .prototype;
347
+ this .disableNormalAttribute = Function .prototype;
348
+ }
349
+ else
350
+ {
351
+ delete this .enableNormalAttribute;
352
+ delete this .disableNormalAttribute;
353
+ }
354
+
355
+ if (this .x3d_Vertex < 0)
356
+ {
357
+ if (gl .getVersion () >= 2)
358
+ console .warn ("Missing »in vec4 x3d_Vertex;«.");
359
+ else
360
+ console .warn ("Missing »attribute vec4 x3d_Vertex;«.");
361
+
362
+ return false;
363
+ }
364
+
365
+ return true;
366
+ },
367
+ getUniformLocation: function (gl, program, name, depreciated)
368
+ {
369
+ // Legacy function to get uniform location.
370
+
371
+ let location = gl .getUniformLocation (program, name);
372
+
373
+ if (location)
374
+ return location;
375
+
376
+ // Look for depreciated location.
377
+
378
+ if (depreciated)
379
+ {
380
+ location = gl .getUniformLocation (program, depreciated);
381
+
382
+ if (location)
383
+ {
384
+ console .warn (this .getTypeName (), this .getName (), "Using uniform location name »" + depreciated + "« is depreciated, use »" + name + "«. See https://create3000.github.io/x_ite/Custom-Shaders.html.");
385
+ }
386
+
387
+ return location;
388
+ }
389
+
390
+ return 0;
391
+ },
392
+ getAttribLocation: function (gl, program, name, depreciated)
393
+ {
394
+ // Legacy function to get uniform location.
395
+
396
+ let location = gl .getAttribLocation (program, name);
397
+
398
+ if (location >= 0)
399
+ return location;
400
+
401
+ // Look for depreciated location.
402
+
403
+ if (depreciated)
404
+ {
405
+ location = gl .getAttribLocation (program, depreciated);
406
+
407
+ if (location >= 0)
408
+ {
409
+ console .warn (this .getTypeName (), this .getName (), "Using attribute location name »" + depreciated + "« is depreciated, use »" + name + "«. See https://create3000.github.io/x_ite/Custom-Shaders.html.");
410
+ }
411
+
412
+ return location;
413
+ }
414
+
415
+ return -1;
416
+ },
417
+ addShaderFields: function ()
418
+ {
419
+ const
420
+ gl = this .getBrowser () .getContext (),
421
+ program = this .getProgram ();
422
+
423
+ this .textures .clear ();
424
+
425
+ for (const field of this .getUserDefinedFields ())
426
+ {
427
+ const location = gl .getUniformLocation (program, field .getName ());
428
+
429
+ if (location)
430
+ {
431
+ switch (field .getType ())
432
+ {
433
+ case X3DConstants .SFImage:
434
+ {
435
+ location .array = new Int32Array (3 + field .array .length);
436
+ break;
437
+ }
438
+ case X3DConstants .SFMatrix3d:
439
+ case X3DConstants .SFMatrix3f:
440
+ case X3DConstants .SFRotation:
441
+ {
442
+ location .array = new Float32Array (9);
443
+ break;
444
+ }
445
+ case X3DConstants .SFMatrix4d:
446
+ case X3DConstants .SFMatrix4f:
447
+ {
448
+ location .array = new Float32Array (16);
449
+ break;
450
+ }
451
+ case X3DConstants .SFNode:
452
+ {
453
+ break;
454
+ }
455
+ case X3DConstants .MFBool:
456
+ case X3DConstants .MFInt32:
457
+ {
458
+ location .array = new Int32Array (this .getLocationLength (gl, program, field));
459
+ break;
460
+ }
461
+ case X3DConstants .MFFloat:
462
+ case X3DConstants .MFDouble:
463
+ case X3DConstants .MFTime:
464
+ {
465
+ location .array = new Float32Array (this .getLocationLength (gl, program, field));
466
+ break;
467
+ }
468
+ case X3DConstants .MFImage:
469
+ {
470
+ location .array = new Int32Array (this .getImagesLength (field));
471
+ break;
472
+ }
473
+ case X3DConstants .MFMatrix3d:
474
+ case X3DConstants .MFMatrix3f:
475
+ case X3DConstants .MFRotation:
476
+ {
477
+ location .array = new Float32Array (9 * this .getLocationLength (gl, program, field));
478
+ break;
479
+ }
480
+ case X3DConstants .MFMatrix4d:
481
+ case X3DConstants .MFMatrix4f:
482
+ {
483
+ location .array = new Float32Array (16 * this .getLocationLength (gl, program, field));
484
+ break;
485
+ }
486
+ case X3DConstants .MFNode:
487
+ {
488
+ const locations = location .locations = [ ];
489
+
490
+ for (let i = 0;; ++ i)
491
+ {
492
+ const l = gl .getUniformLocation (program, field .getName () + "[" + i + "]");
493
+
494
+ if (! l)
495
+ break;
496
+
497
+ locations .push (l);
498
+ }
499
+
500
+ break;
501
+ }
502
+ case X3DConstants .MFVec2d:
503
+ case X3DConstants .MFVec2f:
504
+ {
505
+ location .array = new Float32Array (2 * this .getLocationLength (gl, program, field));
506
+ break;
507
+ }
508
+ case X3DConstants .MFVec3d:
509
+ case X3DConstants .MFVec3f:
510
+ case X3DConstants .MFColor:
511
+ {
512
+ location .array = new Float32Array (3 * this .getLocationLength (gl, program, field));
513
+ break;
514
+ }
515
+ case X3DConstants .MFVec4d:
516
+ case X3DConstants .MFVec4f:
517
+ case X3DConstants .MFColorRGBA:
518
+ {
519
+ location .array = new Float32Array (4 * this .getLocationLength (gl, program, field));
520
+ break;
521
+ }
522
+ }
523
+
524
+ if (location .array)
525
+ field [_uniformLocation] = location .array .length ? location : null;
526
+ else
527
+ field [_uniformLocation] = location;
528
+
529
+ field .addInterest ("set_field__", this);
530
+
531
+ this .set_field__ (field);
532
+ }
533
+ }
534
+ },
535
+ removeShaderFields: function ()
536
+ {
537
+ for (const field of this .getUserDefinedFields ())
538
+ field .removeInterest ("set_field__", this);
539
+ },
540
+ set_field__: (function ()
541
+ {
542
+ const matrix3 = new Matrix3 ();
543
+
544
+ return function (field)
545
+ {
546
+ const
547
+ gl = this .getBrowser () .getContext (),
548
+ location = field [_uniformLocation];
549
+
550
+ if (location)
551
+ {
552
+ switch (field .getType ())
553
+ {
554
+ case X3DConstants .SFBool:
555
+ case X3DConstants .SFInt32:
556
+ {
557
+ gl .uniform1i (location, field .getValue ());
558
+ return;
559
+ }
560
+ case X3DConstants .SFColor:
561
+ {
562
+ const value = field .getValue ();
563
+ gl .uniform3f (location, value .r, value .g, value .b);
564
+ return;
565
+ }
566
+ case X3DConstants .SFColorRGBA:
567
+ {
568
+ const value = field .getValue ();
569
+ gl .uniform4f (location, value .r, value .g, value .b, value .a);
570
+ return;
571
+ }
572
+ case X3DConstants .SFDouble:
573
+ case X3DConstants .SFFloat:
574
+ case X3DConstants .SFTime:
575
+ {
576
+ gl .uniform1f (location, field .getValue ());
577
+ return;
578
+ }
579
+ case X3DConstants .SFImage:
580
+ {
581
+ let array = location .array;
582
+
583
+ const
584
+ pixels = field .array,
585
+ length = 3 + pixels .length;
586
+
587
+ if (length !== array .length)
588
+ array = location .array = new Int32Array (length);
589
+
590
+ array [0] = field .width;
591
+ array [1] = field .height;
592
+ array [2] = field .comp;
593
+
594
+ for (let a = 3, p = 0, pl = pixels .length; p < pl; ++ p, ++ a)
595
+ array [a] = pixels [p];
596
+
597
+ gl .uniform1iv (location, array);
598
+ return;
599
+ }
600
+ case X3DConstants .SFMatrix3d:
601
+ case X3DConstants .SFMatrix3f:
602
+ {
603
+ location .array .set (field .getValue ());
604
+
605
+ gl .uniformMatrix3fv (location, false, location .array);
606
+ return;
607
+ }
608
+ case X3DConstants .SFMatrix4d:
609
+ case X3DConstants .SFMatrix4f:
610
+ {
611
+ location .array .set (field .getValue ());
612
+
613
+ gl .uniformMatrix4fv (location, false, location .array);
614
+ return;
615
+ }
616
+ case X3DConstants .SFNode:
617
+ {
618
+ const texture = X3DCast (X3DConstants .X3DTextureNode, field);
619
+
620
+ if (texture)
621
+ {
622
+ this .textures .set (location, { name: field .getName (), texture: texture } );
623
+ return;
624
+ }
625
+
626
+ this .textures .delete (location);
627
+ return;
628
+ }
629
+ case X3DConstants .SFRotation:
630
+ {
631
+ field .getValue () .getMatrix (location .array);
632
+
633
+ gl .uniformMatrix3fv (location, false, location .array);
634
+ return;
635
+ }
636
+ case X3DConstants .SFString:
637
+ {
638
+ return;
639
+ }
640
+ case X3DConstants .SFVec2d:
641
+ case X3DConstants .SFVec2f:
642
+ {
643
+ const value = field .getValue ();
644
+ gl .uniform2f (location, value .x, value .y);
645
+ return;
646
+ }
647
+ case X3DConstants .SFVec3d:
648
+ case X3DConstants .SFVec3f:
649
+ {
650
+ const value = field .getValue ();
651
+ gl .uniform3f (location, value .x, value .y, value .z);
652
+ return;
653
+ }
654
+ case X3DConstants .SFVec4d:
655
+ case X3DConstants .SFVec4f:
656
+ {
657
+ const value = field .getValue ();
658
+ gl .uniform4f (location, value .x, value .y, value .z, value .w);
659
+ return;
660
+ }
661
+ case X3DConstants .MFBool:
662
+ case X3DConstants .MFInt32:
663
+ {
664
+ const array = location .array;
665
+
666
+ for (var i = 0, length = field .length; i < length; ++ i)
667
+ array [i] = field [i];
668
+
669
+ for (let length = array .length; i < length; ++ i)
670
+ array [i] = 0;
671
+
672
+ gl .uniform1iv (location, array);
673
+ return;
674
+ }
675
+ case X3DConstants .MFColor:
676
+ {
677
+ const array = location .array;
678
+
679
+ for (var i = 0, k = 0, length = field .length; i < length; ++ i)
680
+ {
681
+ const color = field [i];
682
+
683
+ array [k++] = color .r;
684
+ array [k++] = color .g;
685
+ array [k++] = color .b;
686
+ }
687
+
688
+ for (let length = array .length; k < length; ++ k)
689
+ array [k] = 0;
690
+
691
+ gl .uniform3fv (location, array);
692
+ return;
693
+ }
694
+ case X3DConstants .MFColorRGBA:
695
+ {
696
+ const array = location .array;
697
+
698
+ for (var i = 0, k = 0, length = field .length; i < length; ++ i)
699
+ {
700
+ const color = field [i];
701
+
702
+ array [k++] = color .r;
703
+ array [k++] = color .g;
704
+ array [k++] = color .b;
705
+ array [k++] = color .a;
706
+ }
707
+
708
+ for (let length = array .length; k < length; ++ k)
709
+ array [k] = 0;
710
+
711
+ gl .uniform4fv (location, array);
712
+ return;
713
+ }
714
+ case X3DConstants .MFDouble:
715
+ case X3DConstants .MFFloat:
716
+ case X3DConstants .MFTime:
717
+ {
718
+ const array = location .array;
719
+
720
+ for (var i = 0, length = field .length; i < length; ++ i)
721
+ array [i] = field [i];
722
+
723
+ for (let length = array .length; i < length; ++ i)
724
+ array [i] = 0;
725
+
726
+ gl .uniform1fv (location, array);
727
+ return;
728
+ }
729
+ case X3DConstants .MFImage:
730
+ {
731
+ const array = location .array;
732
+
733
+ for (let i = 0, a = 0, length = field .length; i < length; ++ i)
734
+ {
735
+ const
736
+ value = field [i],
737
+ pixels = value .array;
738
+
739
+ array [a ++] = value .width;
740
+ array [a ++] = value .height;
741
+ array [a ++] = value .comp;
742
+
743
+ for (let p = 0, pl = pixels .length; p < pl; ++ p)
744
+ array [a ++] = pixels [p];
745
+ }
746
+
747
+ gl .uniform1iv (location, array);
748
+ return;
749
+ }
750
+ case X3DConstants .MFMatrix3d:
751
+ case X3DConstants .MFMatrix3f:
752
+ {
753
+ const array = location .array;
754
+
755
+ for (var i = 0, k = 0, length = field .length; i < length; ++ i)
756
+ {
757
+ const matrix = field [i];
758
+
759
+ for (let m = 0; m < 9; ++ m)
760
+ array [k++] = matrix [m];
761
+ }
762
+
763
+ for (let length = array .length; k < length; ++ k)
764
+ array [k] = 0;
765
+
766
+ gl .uniformMatrix3fv (location, false, array);
767
+ return;
768
+ }
769
+ case X3DConstants .MFMatrix4d:
770
+ case X3DConstants .MFMatrix4f:
771
+ {
772
+ const array = location .array;
773
+
774
+ for (var i = 0, k = 0, length = field .length; i < length; ++ i)
775
+ {
776
+ const matrix = field [i];
777
+
778
+ for (let m = 0; m < 16; ++ m)
779
+ array [k++] = matrix [m];
780
+ }
781
+
782
+ for (let length = array .length; k < length; ++ k)
783
+ array [k] = 0;
784
+
785
+ gl .uniformMatrix4fv (location, false, array);
786
+ return;
787
+ }
788
+ case X3DConstants .MFNode:
789
+ {
790
+ const locations = location .locations;
791
+
792
+ for (const node of field)
793
+ {
794
+ const texture = X3DCast (X3DConstants .X3DTextureNode, node);
795
+
796
+ if (texture)
797
+ {
798
+ this .textures .set (locations [i], { name: field .getName (), texture: texture } );
799
+ continue;
800
+ }
801
+ }
802
+
803
+ return;
804
+ }
805
+ case X3DConstants .MFRotation:
806
+ {
807
+ const array = location .array;
808
+
809
+ for (var i = 0, k = 0, length = field .length; i < length; ++ i)
810
+ {
811
+ const matrix = field [i] .getValue () .getMatrix (matrix3);
812
+
813
+ array [k++] = matrix [0];
814
+ array [k++] = matrix [1];
815
+ array [k++] = matrix [2];
816
+ array [k++] = matrix [3];
817
+ array [k++] = matrix [4];
818
+ array [k++] = matrix [5];
819
+ array [k++] = matrix [6];
820
+ array [k++] = matrix [7];
821
+ array [k++] = matrix [8];
822
+ }
823
+
824
+ for (let length = array .length; k < length; ++ k)
825
+ array [k] = 0;
826
+
827
+ gl .uniformMatrix3fv (location, false, array);
828
+ return;
829
+ }
830
+ case X3DConstants .MFString:
831
+ {
832
+ return;
833
+ }
834
+ case X3DConstants .MFVec2d:
835
+ case X3DConstants .MFVec2f:
836
+ {
837
+ const array = location .array;
838
+
839
+ for (var i = 0, k = 0, length = field .length; i < length; ++ i)
840
+ {
841
+ const vector = field [i];
842
+
843
+ array [k++] = vector .x;
844
+ array [k++] = vector .y;
845
+ }
846
+
847
+ for (let length = array .length; k < length; ++ k)
848
+ array [k] = 0;
849
+
850
+ gl .uniform2fv (location, array);
851
+ return;
852
+ }
853
+ case X3DConstants .MFVec3d:
854
+ case X3DConstants .MFVec3f:
855
+ {
856
+ const array = location .array;
857
+
858
+ for (var i = 0, k = 0, length = field .length; i < length; ++ i)
859
+ {
860
+ const vector = field [i];
861
+
862
+ array [k++] = vector .x;
863
+ array [k++] = vector .y;
864
+ array [k++] = vector .z;
865
+ }
866
+
867
+ for (let length = array .length; k < length; ++ k)
868
+ array [k] = 0;
869
+
870
+ gl .uniform3fv (location, array);
871
+ return;
872
+ }
873
+ case X3DConstants .MFVec4d:
874
+ case X3DConstants .MFVec4f:
875
+ {
876
+ const array = location .array;
877
+
878
+ for (var i = 0, k = 0, length = field .length; i < length; ++ i)
879
+ {
880
+ const vector = field [i];
881
+
882
+ array [k++] = vector .x;
883
+ array [k++] = vector .y;
884
+ array [k++] = vector .z;
885
+ array [k++] = vector .w;
886
+ }
887
+
888
+ for (let length = array .length; k < length; ++ k)
889
+ array [k] = 0;
890
+
891
+ gl .uniform4fv (location, array);
892
+ return;
893
+ }
894
+ }
895
+ }
896
+ };
897
+ })(),
898
+ getImagesLength: function (field)
899
+ {
900
+ const images = field .getValue ();
901
+
902
+ let length = 3 * images .length;
903
+
904
+ for (const image of images)
905
+ length += image .array .length;
906
+
907
+ return length;
908
+ },
909
+ getLocationLength: function (gl, program, field)
910
+ {
911
+ const name = field .getName ();
912
+
913
+ for (let i = 0; ; ++ i)
914
+ {
915
+ const location = gl .getUniformLocation (program, name + "[" + i + "]");
916
+
917
+ if (! location)
918
+ return i;
919
+ }
920
+ },
921
+ hasFog: function (fogNode)
922
+ {
923
+ if (this .fogNode === fogNode)
924
+ return true;
925
+
926
+ this .fogNode = fogNode;
927
+
928
+ return false;
929
+ },
930
+ hasLight: function (i, lightNode)
931
+ {
932
+ if (this .lightNodes [i] === lightNode)
933
+ return true;
934
+
935
+ this .lightNodes [i] = lightNode;
936
+
937
+ return false;
938
+ },
939
+ hasTextureProjector: function (i, textureProjectorNode)
940
+ {
941
+ if (this .projectiveTextureNodes [i] === textureProjectorNode)
942
+ return true;
943
+
944
+ this .projectiveTextureNodes [i] = textureProjectorNode;
945
+
946
+ return false;
947
+ },
948
+ setLocalObjects: function (gl, localObjects)
949
+ {
950
+ // Clip planes and local lights
918
951
 
919
- for (const localObject of localObjects)
920
- localObject .setShaderUniforms (gl, this);
952
+ this .numClipPlanes = 0;
953
+ this .numLights = 0;
954
+ this .numProjectiveTextures = 0;
955
+ this .lightNodes .length = 0;
956
+ this .projectiveTextureNodes .length = 0;
921
957
 
922
- gl .uniform1i (this .x3d_NumClipPlanes, Math .min (this .numClipPlanes, this .x3d_MaxClipPlanes));
923
- gl .uniform1i (this .x3d_NumLights, Math .min (this .numLights, this .x3d_MaxLights));
924
- gl .uniform1i (this .x3d_NumProjectiveTextures, Math .min (this .numProjectiveTextures, this .x3d_MaxTextures));
925
- },
926
- setGlobalUniforms: function (gl, renderObject, cameraSpaceMatrixArray, projectionMatrixArray, viewportArray)
927
- {
928
- const globalObjects = renderObject .getGlobalObjects ();
958
+ for (const localObject of localObjects)
959
+ localObject .setShaderUniforms (gl, this);
929
960
 
930
- // Set viewport
961
+ gl .uniform1i (this .x3d_NumClipPlanes, Math .min (this .numClipPlanes, this .x3d_MaxClipPlanes));
962
+ gl .uniform1i (this .x3d_NumLights, Math .min (this .numLights, this .x3d_MaxLights));
963
+ gl .uniform1i (this .x3d_NumProjectiveTextures, Math .min (this .numProjectiveTextures, this .x3d_MaxTextures));
964
+ },
965
+ setGlobalUniforms: function (gl, renderObject, cameraSpaceMatrixArray, projectionMatrixArray, viewportArray)
966
+ {
967
+ const globalObjects = renderObject .getGlobalObjects ();
931
968
 
932
- gl .uniform4iv (this .x3d_Viewport, viewportArray);
969
+ // Set viewport
933
970
 
934
- // Set projection matrix
971
+ gl .uniform4iv (this .x3d_Viewport, viewportArray);
935
972
 
936
- gl .uniformMatrix4fv (this .x3d_ProjectionMatrix, false, projectionMatrixArray);
937
- gl .uniformMatrix4fv (this .x3d_CameraSpaceMatrix, false, cameraSpaceMatrixArray);
973
+ // Set projection matrix
938
974
 
939
- // Fog
975
+ gl .uniformMatrix4fv (this .x3d_ProjectionMatrix, false, projectionMatrixArray);
976
+ gl .uniformMatrix4fv (this .x3d_CameraSpaceMatrix, false, cameraSpaceMatrixArray);
940
977
 
941
- this .fogNode = null;
978
+ // Fog
942
979
 
943
- // Set global lights and global texture projectors
980
+ this .fogNode = null;
944
981
 
945
- this .numLights = 0;
946
- this .numProjectiveTextures = 0;
947
- this .lightNodes .length = 0;
948
- this .projectiveTextureNodes .length = 0;
982
+ // Set global lights and global texture projectors
949
983
 
950
- for (const globalObject of globalObjects)
951
- globalObject .setShaderUniforms (gl, this);
952
-
953
- this .numGlobalLights = this .numLights;
954
- this .numGlobalProjectiveTextures = this .numProjectiveTextures;
984
+ this .numLights = 0;
985
+ this .numProjectiveTextures = 0;
986
+ this .lightNodes .length = 0;
987
+ this .projectiveTextureNodes .length = 0;
955
988
 
956
- // Logarithmic depth buffer support.
989
+ for (const globalObject of globalObjects)
990
+ globalObject .setShaderUniforms (gl, this, renderObject);
957
991
 
958
- const
959
- viewpoint = renderObject .getViewpoint (),
960
- navigationInfo = renderObject .getNavigationInfo ();
992
+ this .numGlobalLights = this .numLights;
993
+ this .numGlobalProjectiveTextures = this .numProjectiveTextures;
961
994
 
962
- if (viewpoint instanceof OrthoViewpoint)
963
- gl .uniform1f (this .x3d_LogarithmicFarFactor1_2, -1);
964
- else
965
- gl .uniform1f (this .x3d_LogarithmicFarFactor1_2, 1 / Math .log2 (navigationInfo .getFarValue (viewpoint) + 1));
966
- },
967
- setLocalUniforms: function (gl, context, front = true)
968
- {
969
- const
970
- shapeNode = context .shapeNode,
971
- geometryNode = context .geometryContext || shapeNode .getGeometry (),
972
- geometryType = geometryNode .geometryType,
973
- textureCoordinateNode = geometryNode .textureCoordinateNode,
974
- appearanceNode = shapeNode .getAppearance (),
975
- stylePropertiesNode = appearanceNode .stylePropertiesNode [geometryType],
976
- materialNode = front ? appearanceNode .materialNode : appearanceNode .backMaterialNode,
977
- textureNode = context .textureNode || appearanceNode .textureNode,
978
- textureTransformNode = appearanceNode .textureTransformNode,
979
- modelViewMatrix = context .modelViewMatrix,
980
- localObjects = context .localObjects;
995
+ // Logarithmic depth buffer support.
981
996
 
982
- // Model view matrix
997
+ const
998
+ viewpoint = renderObject .getViewpoint (),
999
+ navigationInfo = renderObject .getNavigationInfo ();
983
1000
 
984
- gl .uniformMatrix4fv (this .x3d_ModelViewMatrix, false, modelViewMatrix);
1001
+ if (viewpoint instanceof OrthoViewpoint)
1002
+ gl .uniform1f (this .x3d_LogarithmicFarFactor1_2, -1);
1003
+ else
1004
+ gl .uniform1f (this .x3d_LogarithmicFarFactor1_2, 1 / Math .log2 (navigationInfo .getFarValue (viewpoint) + 1));
1005
+ },
1006
+ setLocalUniforms: function (gl, context, front = true)
1007
+ {
1008
+ const
1009
+ renderObject = context .renderer,
1010
+ shapeNode = context .shapeNode,
1011
+ geometryNode = context .geometryContext || shapeNode .getGeometry (),
1012
+ geometryType = geometryNode .geometryType,
1013
+ appearanceNode = shapeNode .getAppearance (),
1014
+ materialNode = front ? appearanceNode .materialNode : appearanceNode .backMaterialNode,
1015
+ textureNode = context .textureNode || appearanceNode .textureNode,
1016
+ modelViewMatrix = context .modelViewMatrix;
985
1017
 
986
- // Geometry type
1018
+ // Model view matrix
987
1019
 
988
- gl .uniform1i (this .x3d_GeometryType, geometryType);
1020
+ gl .uniformMatrix4fv (this .x3d_ModelViewMatrix, false, modelViewMatrix);
989
1021
 
990
- // Clip planes and local lights
1022
+ // Geometry type
991
1023
 
992
- this .numClipPlanes = 0;
993
- this .numLights = this .numGlobalLights;
994
- this .numProjectiveTextures = this .numGlobalProjectiveTextures;
1024
+ gl .uniform1i (this .x3d_GeometryType, geometryType);
995
1025
 
996
- for (const localObject of localObjects)
997
- localObject .setShaderUniforms (gl, this);
998
-
999
- gl .uniform1i (this .x3d_NumClipPlanes, Math .min (this .numClipPlanes, this .x3d_MaxClipPlanes));
1000
- gl .uniform1i (this .x3d_NumLights, Math .min (this .numLights, this .x3d_MaxLights));
1001
- gl .uniform1i (this .x3d_NumProjectiveTextures, Math .min (this .numProjectiveTextures, this .x3d_MaxTextures));
1026
+ // Clip planes and local lights
1002
1027
 
1003
- // Fog, there is always one
1028
+ this .numClipPlanes = 0;
1029
+ this .numLights = this .numGlobalLights;
1030
+ this .numProjectiveTextures = this .numGlobalProjectiveTextures;
1004
1031
 
1005
- context .fogNode .setShaderUniforms (gl, this);
1006
- gl .uniform1i (this .x3d_FogCoord, geometryNode .fogCoords);
1032
+ for (const localObject of context .localObjects)
1033
+ localObject .setShaderUniforms (gl, this, renderObject);
1007
1034
 
1008
- // Alpha
1035
+ gl .uniform1i (this .x3d_NumClipPlanes, Math .min (this .numClipPlanes, this .x3d_MaxClipPlanes));
1036
+ gl .uniform1i (this .x3d_NumLights, Math .min (this .numLights, this .x3d_MaxLights));
1037
+ gl .uniform1i (this .x3d_NumProjectiveTextures, Math .min (this .numProjectiveTextures, this .x3d_MaxTextures));
1009
1038
 
1010
- gl .uniform1f (this .x3d_AlphaCutoff, appearanceNode .alphaCutoff);
1039
+ // Fog, there is always one
1011
1040
 
1012
- // Style
1041
+ context .fogNode .setShaderUniforms (gl, this);
1042
+ gl .uniform1i (this .x3d_FogCoord, geometryNode .fogCoords);
1013
1043
 
1014
- stylePropertiesNode .setShaderUniforms (gl, this);
1044
+ // Alpha
1015
1045
 
1016
- // Material
1046
+ gl .uniform1f (this .x3d_AlphaCutoff, appearanceNode .alphaCutoff);
1017
1047
 
1018
- gl .uniform1i (this .x3d_ColorMaterial, geometryNode .colorMaterial);
1019
- materialNode .setShaderUniforms (gl, this, front);
1048
+ // Style
1020
1049
 
1021
- // Normal matrix
1050
+ appearanceNode .stylePropertiesNode [geometryType] .setShaderUniforms (gl, this);
1022
1051
 
1023
- gl .uniformMatrix3fv (this .x3d_NormalMatrix, false, this .getNormalMatrix (modelViewMatrix));
1052
+ // Material
1024
1053
 
1025
- // Texture
1054
+ gl .uniform1i (this .x3d_ColorMaterial, geometryNode .colorMaterial);
1055
+ materialNode .setShaderUniforms (gl, this, renderObject, appearanceNode .textureTransformMapping, geometryNode .textureCoordinateMapping, front);
1026
1056
 
1027
- if (textureNode)
1028
- {
1029
- textureNode .setShaderUniforms (gl, this, context .renderer);
1030
- textureTransformNode .setShaderUniforms (gl, this);
1031
- textureCoordinateNode .setShaderUniforms (gl, this);
1032
- }
1033
- else
1034
- {
1035
- gl .uniform1i (this .x3d_NumTextures, 0);
1057
+ // Normal matrix
1036
1058
 
1037
- if (this .getCustom ())
1038
- {
1039
- textureTransformNode .setShaderUniforms (gl, this);
1040
- textureCoordinateNode .setShaderUniforms (gl, this);
1041
- }
1042
- }
1043
- },
1044
- getNormalMatrix: (function ()
1045
- {
1046
- const normalMatrix = new Float32Array (9);
1047
-
1048
- return function (modelViewMatrix)
1049
- {
1050
- try
1051
- {
1052
- normalMatrix [0] = modelViewMatrix [0], normalMatrix [3] = modelViewMatrix [1], normalMatrix [6] = modelViewMatrix [ 2],
1053
- normalMatrix [1] = modelViewMatrix [4], normalMatrix [4] = modelViewMatrix [5], normalMatrix [7] = modelViewMatrix [ 6],
1054
- normalMatrix [2] = modelViewMatrix [8], normalMatrix [5] = modelViewMatrix [9], normalMatrix [8] = modelViewMatrix [10];
1055
-
1056
- Matrix3 .prototype .inverse .call (normalMatrix);
1057
-
1058
- return normalMatrix;
1059
- }
1060
- catch (error)
1061
- {
1062
- normalMatrix .set (Matrix3 .Identity);
1063
-
1064
- return normalMatrix;
1065
- }
1066
- };
1067
- })(),
1068
- enable: function (gl)
1069
- {
1070
- const browser = this .getBrowser ();
1071
-
1072
- //console .log (this .getName ());
1073
- //console .log (browser .getCombinedTextureUnits () .length);
1059
+ gl .uniformMatrix3fv (this .x3d_NormalMatrix, false, this .getNormalMatrix (modelViewMatrix));
1074
1060
 
1075
- this .textures .forEach (function (object, location)
1076
- {
1077
- const
1078
- name = object .name,
1079
- texture = object .texture;
1061
+ // Texture
1080
1062
 
1081
- if (! browser .getCombinedTextureUnits () .length)
1082
- {
1083
- console .warn ("Not enough combined texture units for uniform variable '" + name + "' available.");
1084
- return;
1085
- }
1086
-
1087
- const textureUnit = object .textureUnit = browser .getCombinedTextureUnits () .pop ();
1088
-
1089
- gl .uniform1i (location, textureUnit);
1090
- gl .activeTexture (gl .TEXTURE0 + textureUnit);
1091
- gl .bindTexture (texture .getTarget (), texture .getTexture ());
1092
- });
1093
-
1094
- gl .activeTexture (gl .TEXTURE0);
1095
- },
1096
- disable: function (gl)
1097
- {
1098
- const browser = this .getBrowser ();
1099
-
1100
- this .textures .forEach (function (object)
1101
- {
1102
- const textureUnit = object .textureUnit;
1103
-
1104
- if (textureUnit !== undefined)
1105
- browser .getCombinedTextureUnits () .push (textureUnit);
1106
-
1107
- object .textureUnit = undefined;
1108
- });
1109
-
1110
- //console .log (browser .getCombinedTextureUnits () .length);
1111
- },
1112
- enableFloatAttrib: function (gl, name, buffer, components)
1113
- {
1114
- const location = gl. getAttribLocation (this .getProgram (), name);
1115
-
1116
- if (location === -1)
1117
- return;
1118
-
1119
- gl .enableVertexAttribArray (location);
1120
-
1121
- gl .bindBuffer (gl .ARRAY_BUFFER, buffer);
1122
- gl .vertexAttribPointer (location, components, gl .FLOAT, false, 0, 0);
1123
- },
1124
- disableFloatAttrib: function (gl, name)
1125
- {
1126
- const location = gl .getAttribLocation (this .getProgram (), name);
1127
-
1128
- if (location === -1)
1129
- return;
1130
-
1131
- gl .disableVertexAttribArray (location);
1132
- },
1133
- enableMatrix3Attrib: function (gl, name, buffer)
1134
- {
1135
- const location = gl .getAttribLocation (this .getProgram (), name);
1136
-
1137
- if (location === -1)
1138
- return;
1139
-
1140
- gl .enableVertexAttribArray (location);
1141
- gl .enableVertexAttribArray (location + 1);
1142
- gl .enableVertexAttribArray (location + 2);
1143
-
1144
- gl .bindBuffer (gl .ARRAY_BUFFER, buffer);
1145
-
1146
- gl .vertexAttribPointer (location, 3, gl .FLOAT, false, 9 * 4, 3 * 4 * 0);
1147
- gl .vertexAttribPointer (location + 1, 3, gl .FLOAT, false, 9 * 4, 3 * 4 * 1);
1148
- gl .vertexAttribPointer (location + 2, 3, gl .FLOAT, false, 9 * 4, 3 * 4 * 2);
1149
- },
1150
- disableMatrix3Attrib: function (gl, name)
1151
- {
1152
- const location = gl .getAttribLocation (this .getProgram (), name);
1153
-
1154
- if (location === -1)
1155
- return;
1156
-
1157
- gl .disableVertexAttribArray (location);
1158
- gl .disableVertexAttribArray (location + 1);
1159
- gl .disableVertexAttribArray (location + 2);
1160
- },
1161
- enableMatrix4Attrib: function (gl, name, buffer)
1162
- {
1163
- const location = gl .getAttribLocation (this .getProgram (), name);
1164
-
1165
- if (location === -1)
1166
- return;
1167
-
1168
- gl .enableVertexAttribArray (location);
1169
- gl .enableVertexAttribArray (location + 1);
1170
- gl .enableVertexAttribArray (location + 2);
1171
- gl .enableVertexAttribArray (location + 3);
1172
-
1173
- gl .bindBuffer (gl .ARRAY_BUFFER, buffer);
1174
-
1175
- gl .vertexAttribPointer (location, 4, gl .FLOAT, false, 16 * 4, 4 * 4 * 0);
1176
- gl .vertexAttribPointer (location + 1, 4, gl .FLOAT, false, 16 * 4, 4 * 4 * 1);
1177
- gl .vertexAttribPointer (location + 2, 4, gl .FLOAT, false, 16 * 4, 4 * 4 * 2);
1178
- gl .vertexAttribPointer (location + 3, 4, gl .FLOAT, false, 16 * 4, 4 * 4 * 3);
1179
- },
1180
- disableMatrix4Attrib: function (gl, name)
1181
- {
1182
- const location = gl .getAttribLocation (this .getProgram (), name);
1183
-
1184
- if (location === -1)
1185
- return;
1186
-
1187
- gl .disableVertexAttribArray (location);
1188
- gl .disableVertexAttribArray (location + 1);
1189
- gl .disableVertexAttribArray (location + 2);
1190
- gl .disableVertexAttribArray (location + 3);
1191
- },
1192
- enableFogDepthAttribute: function (gl, fogDepthBuffer)
1193
- {
1194
- gl .enableVertexAttribArray (this .x3d_FogDepth);
1195
- gl .bindBuffer (gl .ARRAY_BUFFER, fogDepthBuffer);
1196
- gl .vertexAttribPointer (this .x3d_FogDepth, 1, gl .FLOAT, false, 0, 0);
1197
- },
1198
- disableFogDepthAttribute: function (gl)
1199
- {
1200
- gl .disableVertexAttribArray (this .x3d_FogDepth);
1201
- },
1202
- enableColorAttribute: function (gl, colorBuffer)
1203
- {
1204
- gl .enableVertexAttribArray (this .x3d_Color);
1205
- gl .bindBuffer (gl .ARRAY_BUFFER, colorBuffer);
1206
- gl .vertexAttribPointer (this .x3d_Color, 4, gl .FLOAT, false, 0, 0);
1207
- },
1208
- disableColorAttribute: function (gl)
1209
- {
1210
- gl .disableVertexAttribArray (this .x3d_Color);
1211
- },
1212
- enableTexCoordAttribute: function (gl, texCoordBuffers, d)
1213
- {
1214
- const length = Math .min (this .x3d_MaxTextures, texCoordBuffers .length);
1215
-
1216
- for (let i = 0; i < length; ++ i)
1217
- {
1218
- const x3d_TexCoord = this .x3d_TexCoord [i];
1219
-
1220
- if (x3d_TexCoord === -1)
1221
- continue;
1222
-
1223
- gl .enableVertexAttribArray (x3d_TexCoord);
1224
- gl .bindBuffer (gl .ARRAY_BUFFER, texCoordBuffers [i]);
1225
- gl .vertexAttribPointer (x3d_TexCoord, 4, gl .FLOAT, false, 0, 0);
1226
- }
1227
- },
1228
- disableTexCoordAttribute: function (gl)
1229
- {
1230
- for (let i = 0, length = this .x3d_MaxTextures; i < length; ++ i)
1231
- {
1232
- const x3d_TexCoord = this .x3d_TexCoord [i];
1233
-
1234
- if (x3d_TexCoord === -1)
1235
- continue;
1236
-
1237
- gl .disableVertexAttribArray (x3d_TexCoord);
1238
- }
1239
- },
1240
- enableNormalAttribute: function (gl, normalBuffer)
1241
- {
1242
- gl .enableVertexAttribArray (this .x3d_Normal);
1243
- gl .bindBuffer (gl .ARRAY_BUFFER, normalBuffer);
1244
- gl .vertexAttribPointer (this .x3d_Normal, 3, gl .FLOAT, false, 0, 0);
1245
- },
1246
- disableNormalAttribute: function (gl)
1247
- {
1248
- gl .disableVertexAttribArray (this .x3d_Normal);
1249
- },
1250
- enableVertexAttribute: function (gl, vertexBuffer)
1251
- {
1252
- gl .enableVertexAttribArray (this .x3d_Vertex);
1253
- gl .bindBuffer (gl .ARRAY_BUFFER, vertexBuffer);
1254
- gl .vertexAttribPointer (this .x3d_Vertex, 4, gl .FLOAT, false, 0, 0);
1255
- },
1256
- disableVertexAttribute: function (gl)
1257
- {
1258
- gl .disableVertexAttribArray (this .x3d_Vertex);
1259
- },
1260
- setParticle: function (gl, particle, modelViewMatrix)
1261
- {
1262
- gl .uniformMatrix4fv (this .x3d_ModelViewMatrix, false, modelViewMatrix);
1263
-
1264
- gl .uniform1i (this .x3d_ParticleId, particle .id);
1265
- gl .uniform1i (this .x3d_ParticleLife, particle .life);
1266
- gl .uniform1f (this .x3d_ParticleElapsedTime, particle .elapsedTime / particle .lifetime);
1267
- },
1268
- getProgramInfo: function ()
1269
- {
1270
- function cmp (lhs, rhs) { return lhs < rhs ? -1 : lhs > rhs ? 1 : 0; }
1271
-
1272
- const
1273
- gl = this .getBrowser () .getContext (),
1274
- program = this .getProgram ();
1275
-
1276
- const
1277
- result = {
1278
- attributes: [ ],
1279
- uniforms: [ ],
1280
- attributeCount: 0,
1281
- uniformCount: 0,
1282
- },
1283
- activeUniforms = gl .getProgramParameter (program, gl.ACTIVE_UNIFORMS),
1284
- activeAttributes = gl .getProgramParameter (program, gl.ACTIVE_ATTRIBUTES);
1285
-
1286
- // Taken from the WebGl spec:
1287
- // http://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14
1288
- const enums = {
1289
- 0x8B50: 'vec2',
1290
- 0x8B51: 'vec3',
1291
- 0x8B52: 'vec4',
1292
- 0x8B53: 'ivec2',
1293
- 0x8B54: 'ivec3',
1294
- 0x8B55: 'ivec4',
1295
- 0x8B56: 'bool',
1296
- 0x8B57: 'bvec2',
1297
- 0x8B58: 'bvec3',
1298
- 0x8B59: 'bvec4',
1299
- 0x8B5A: 'mat2',
1300
- 0x8B5B: 'mat3',
1301
- 0x8B5C: 'mat4',
1302
- 0x8B5E: 'sampler2D',
1303
- 0x8B60: 'samplerCube',
1304
- 0x1400: 'byte',
1305
- 0x1401: 'ubyte',
1306
- 0x1402: 'short',
1307
- 0x1403: 'ushort',
1308
- 0x1404: 'int',
1309
- 0x1405: 'uint',
1310
- 0x1406: 'float',
1311
- };
1312
-
1313
- // Loop through active uniforms
1314
- for (let i = 0; i < activeUniforms; ++ i)
1315
- {
1316
- const uniform = gl .getActiveUniform (program, i);
1317
- uniform .typeName = enums [uniform.type];
1318
- result .uniforms .push (Object .assign ({ }, uniform));
1319
- result .uniformCount += uniform .size;
1320
- }
1321
-
1322
- // Loop through active attributes
1323
- for (let i = 0; i < activeAttributes; ++ i)
1324
- {
1325
- const attribute = gl .getActiveAttrib (program, i);
1326
- attribute .typeName = enums [attribute .type];
1327
- result .attributes .push (Object .assign ({ }, attribute));
1328
- result .attributeCount += attribute .size;
1329
- }
1330
-
1331
- result .uniforms .sort (function (a, b) { return cmp (a .name, b .name); });
1332
- result .attributes .sort (function (a, b) { return cmp (a .name, b .name); });
1333
-
1334
- return result;
1335
- },
1336
- printProgramInfo: function ()
1337
- {
1338
- const programInfo = this .getProgramInfo ();
1339
-
1340
- console .log (this .getName ());
1341
- console .table (programInfo .attributes);
1342
- console .log (this .getName (), "attributeCount", programInfo .attributeCount);
1343
- console .log (this .getName ());
1344
- console .table (programInfo .uniforms);
1345
- console .log (this .getName (), "uniformCount", programInfo .uniformCount);
1346
- },
1347
- };
1348
-
1349
- return X3DProgrammableShaderObject;
1063
+ if (textureNode)
1064
+ textureNode .setShaderUniforms (gl, this, renderObject);
1065
+ else
1066
+ gl .uniform1i (this .x3d_NumTextures, 0);
1067
+
1068
+ appearanceNode .textureTransformNode .setShaderUniforms (gl, this);
1069
+ geometryNode .textureCoordinateNode .setShaderUniforms (gl, this);
1070
+ },
1071
+ getNormalMatrix: (function ()
1072
+ {
1073
+ const normalMatrix = new Float32Array (9);
1074
+
1075
+ return function (modelViewMatrix)
1076
+ {
1077
+ try
1078
+ {
1079
+ normalMatrix [0] = modelViewMatrix [0], normalMatrix [3] = modelViewMatrix [1], normalMatrix [6] = modelViewMatrix [ 2],
1080
+ normalMatrix [1] = modelViewMatrix [4], normalMatrix [4] = modelViewMatrix [5], normalMatrix [7] = modelViewMatrix [ 6],
1081
+ normalMatrix [2] = modelViewMatrix [8], normalMatrix [5] = modelViewMatrix [9], normalMatrix [8] = modelViewMatrix [10];
1082
+
1083
+ Matrix3 .prototype .inverse .call (normalMatrix);
1084
+
1085
+ return normalMatrix;
1086
+ }
1087
+ catch (error)
1088
+ {
1089
+ normalMatrix .set (Matrix3 .Identity);
1090
+
1091
+ return normalMatrix;
1092
+ }
1093
+ };
1094
+ })(),
1095
+ enable: function (gl)
1096
+ {
1097
+ const browser = this .getBrowser ();
1098
+
1099
+ for (const [location, object] of this .textures)
1100
+ {
1101
+ const
1102
+ texture = object .texture,
1103
+ textureUnit = browser .getTextureUnit (texture .getTextureType ());
1104
+
1105
+ if (textureUnit === undefined)
1106
+ {
1107
+ console .warn ("Not enough combined texture units for uniform variable '" + object .name + "' available.");
1108
+ return;
1109
+ }
1110
+
1111
+ gl .activeTexture (gl .TEXTURE0 + textureUnit);
1112
+ gl .bindTexture (texture .getTarget (), texture .getTexture ());
1113
+ gl .uniform1i (location, textureUnit);
1114
+ }
1115
+ },
1116
+ enableFloatAttrib: function (gl, name, buffer, components)
1117
+ {
1118
+ const location = gl. getAttribLocation (this .getProgram (), name);
1119
+
1120
+ if (location === -1)
1121
+ return;
1122
+
1123
+ gl .enableVertexAttribArray (location);
1124
+
1125
+ gl .bindBuffer (gl .ARRAY_BUFFER, buffer);
1126
+ gl .vertexAttribPointer (location, components, gl .FLOAT, false, 0, 0);
1127
+ },
1128
+ disableFloatAttrib: function (gl, name)
1129
+ {
1130
+ const location = gl .getAttribLocation (this .getProgram (), name);
1131
+
1132
+ if (location === -1)
1133
+ return;
1134
+
1135
+ gl .disableVertexAttribArray (location);
1136
+ },
1137
+ enableMatrix3Attrib: function (gl, name, buffer)
1138
+ {
1139
+ const location = gl .getAttribLocation (this .getProgram (), name);
1140
+
1141
+ if (location === -1)
1142
+ return;
1143
+
1144
+ gl .enableVertexAttribArray (location);
1145
+ gl .enableVertexAttribArray (location + 1);
1146
+ gl .enableVertexAttribArray (location + 2);
1147
+
1148
+ gl .bindBuffer (gl .ARRAY_BUFFER, buffer);
1149
+
1150
+ gl .vertexAttribPointer (location, 3, gl .FLOAT, false, 9 * 4, 3 * 4 * 0);
1151
+ gl .vertexAttribPointer (location + 1, 3, gl .FLOAT, false, 9 * 4, 3 * 4 * 1);
1152
+ gl .vertexAttribPointer (location + 2, 3, gl .FLOAT, false, 9 * 4, 3 * 4 * 2);
1153
+ },
1154
+ disableMatrix3Attrib: function (gl, name)
1155
+ {
1156
+ const location = gl .getAttribLocation (this .getProgram (), name);
1157
+
1158
+ if (location === -1)
1159
+ return;
1160
+
1161
+ gl .disableVertexAttribArray (location);
1162
+ gl .disableVertexAttribArray (location + 1);
1163
+ gl .disableVertexAttribArray (location + 2);
1164
+ },
1165
+ enableMatrix4Attrib: function (gl, name, buffer)
1166
+ {
1167
+ const location = gl .getAttribLocation (this .getProgram (), name);
1168
+
1169
+ if (location === -1)
1170
+ return;
1171
+
1172
+ gl .enableVertexAttribArray (location);
1173
+ gl .enableVertexAttribArray (location + 1);
1174
+ gl .enableVertexAttribArray (location + 2);
1175
+ gl .enableVertexAttribArray (location + 3);
1176
+
1177
+ gl .bindBuffer (gl .ARRAY_BUFFER, buffer);
1178
+
1179
+ gl .vertexAttribPointer (location, 4, gl .FLOAT, false, 16 * 4, 4 * 4 * 0);
1180
+ gl .vertexAttribPointer (location + 1, 4, gl .FLOAT, false, 16 * 4, 4 * 4 * 1);
1181
+ gl .vertexAttribPointer (location + 2, 4, gl .FLOAT, false, 16 * 4, 4 * 4 * 2);
1182
+ gl .vertexAttribPointer (location + 3, 4, gl .FLOAT, false, 16 * 4, 4 * 4 * 3);
1183
+ },
1184
+ disableMatrix4Attrib: function (gl, name)
1185
+ {
1186
+ const location = gl .getAttribLocation (this .getProgram (), name);
1187
+
1188
+ if (location === -1)
1189
+ return;
1190
+
1191
+ gl .disableVertexAttribArray (location);
1192
+ gl .disableVertexAttribArray (location + 1);
1193
+ gl .disableVertexAttribArray (location + 2);
1194
+ gl .disableVertexAttribArray (location + 3);
1195
+ },
1196
+ enableFogDepthAttribute: function (gl, fogDepthBuffer)
1197
+ {
1198
+ gl .enableVertexAttribArray (this .x3d_FogDepth);
1199
+ gl .bindBuffer (gl .ARRAY_BUFFER, fogDepthBuffer);
1200
+ gl .vertexAttribPointer (this .x3d_FogDepth, 1, gl .FLOAT, false, 0, 0);
1201
+ },
1202
+ disableFogDepthAttribute: function (gl)
1203
+ {
1204
+ gl .disableVertexAttribArray (this .x3d_FogDepth);
1205
+ },
1206
+ enableColorAttribute: function (gl, colorBuffer)
1207
+ {
1208
+ gl .enableVertexAttribArray (this .x3d_Color);
1209
+ gl .bindBuffer (gl .ARRAY_BUFFER, colorBuffer);
1210
+ gl .vertexAttribPointer (this .x3d_Color, 4, gl .FLOAT, false, 0, 0);
1211
+ },
1212
+ disableColorAttribute: function (gl)
1213
+ {
1214
+ gl .disableVertexAttribArray (this .x3d_Color);
1215
+ },
1216
+ enableTexCoordAttribute: function (gl, texCoordBuffers, d)
1217
+ {
1218
+ const length = Math .min (this .x3d_MaxTextures, texCoordBuffers .length);
1219
+
1220
+ for (let i = 0; i < length; ++ i)
1221
+ {
1222
+ const x3d_TexCoord = this .x3d_TexCoord [i];
1223
+
1224
+ if (x3d_TexCoord === -1)
1225
+ continue;
1226
+
1227
+ gl .enableVertexAttribArray (x3d_TexCoord);
1228
+ gl .bindBuffer (gl .ARRAY_BUFFER, texCoordBuffers [i]);
1229
+ gl .vertexAttribPointer (x3d_TexCoord, 4, gl .FLOAT, false, 0, 0);
1230
+ }
1231
+ },
1232
+ disableTexCoordAttribute: function (gl)
1233
+ {
1234
+ for (let i = 0, length = this .x3d_MaxTextures; i < length; ++ i)
1235
+ {
1236
+ const x3d_TexCoord = this .x3d_TexCoord [i];
1237
+
1238
+ if (x3d_TexCoord === -1)
1239
+ continue;
1240
+
1241
+ gl .disableVertexAttribArray (x3d_TexCoord);
1242
+ }
1243
+ },
1244
+ enableNormalAttribute: function (gl, normalBuffer)
1245
+ {
1246
+ gl .enableVertexAttribArray (this .x3d_Normal);
1247
+ gl .bindBuffer (gl .ARRAY_BUFFER, normalBuffer);
1248
+ gl .vertexAttribPointer (this .x3d_Normal, 3, gl .FLOAT, false, 0, 0);
1249
+ },
1250
+ disableNormalAttribute: function (gl)
1251
+ {
1252
+ gl .disableVertexAttribArray (this .x3d_Normal);
1253
+ },
1254
+ enableVertexAttribute: function (gl, vertexBuffer)
1255
+ {
1256
+ gl .enableVertexAttribArray (this .x3d_Vertex);
1257
+ gl .bindBuffer (gl .ARRAY_BUFFER, vertexBuffer);
1258
+ gl .vertexAttribPointer (this .x3d_Vertex, 4, gl .FLOAT, false, 0, 0);
1259
+ },
1260
+ disableVertexAttribute: function (gl)
1261
+ {
1262
+ gl .disableVertexAttribArray (this .x3d_Vertex);
1263
+ },
1264
+ setParticle: function (gl, particle, modelViewMatrix)
1265
+ {
1266
+ gl .uniformMatrix4fv (this .x3d_ModelViewMatrix, false, modelViewMatrix);
1267
+
1268
+ gl .uniform1i (this .x3d_ParticleId, particle .id);
1269
+ gl .uniform1i (this .x3d_ParticleLife, particle .life);
1270
+ gl .uniform1f (this .x3d_ParticleElapsedTime, particle .elapsedTime / particle .lifetime);
1271
+ },
1272
+ getProgramInfo: function ()
1273
+ {
1274
+ function cmp (lhs, rhs) { return lhs < rhs ? -1 : lhs > rhs ? 1 : 0; }
1275
+
1276
+ const
1277
+ gl = this .getBrowser () .getContext (),
1278
+ program = this .getProgram ();
1279
+
1280
+ const
1281
+ result = {
1282
+ attributes: [ ],
1283
+ uniforms: [ ],
1284
+ attributeCount: 0,
1285
+ uniformCount: 0,
1286
+ },
1287
+ activeUniforms = gl .getProgramParameter (program, gl.ACTIVE_UNIFORMS),
1288
+ activeAttributes = gl .getProgramParameter (program, gl.ACTIVE_ATTRIBUTES);
1289
+
1290
+ // Taken from the WebGl spec:
1291
+ // http://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14
1292
+ const enums = {
1293
+ 0x8B50: 'vec2',
1294
+ 0x8B51: 'vec3',
1295
+ 0x8B52: 'vec4',
1296
+ 0x8B53: 'ivec2',
1297
+ 0x8B54: 'ivec3',
1298
+ 0x8B55: 'ivec4',
1299
+ 0x8B56: 'bool',
1300
+ 0x8B57: 'bvec2',
1301
+ 0x8B58: 'bvec3',
1302
+ 0x8B59: 'bvec4',
1303
+ 0x8B5A: 'mat2',
1304
+ 0x8B5B: 'mat3',
1305
+ 0x8B5C: 'mat4',
1306
+ 0x8B5E: 'sampler2D',
1307
+ 0x8B60: 'samplerCube',
1308
+ 0x1400: 'byte',
1309
+ 0x1401: 'ubyte',
1310
+ 0x1402: 'short',
1311
+ 0x1403: 'ushort',
1312
+ 0x1404: 'int',
1313
+ 0x1405: 'uint',
1314
+ 0x1406: 'float',
1315
+ };
1316
+
1317
+ // Loop through active uniforms
1318
+ for (let i = 0; i < activeUniforms; ++ i)
1319
+ {
1320
+ const uniform = gl .getActiveUniform (program, i);
1321
+ uniform .typeName = enums [uniform.type];
1322
+ result .uniforms .push (Object .assign ({ }, uniform));
1323
+ result .uniformCount += uniform .size;
1324
+ }
1325
+
1326
+ // Loop through active attributes
1327
+ for (let i = 0; i < activeAttributes; ++ i)
1328
+ {
1329
+ const attribute = gl .getActiveAttrib (program, i);
1330
+ attribute .typeName = enums [attribute .type];
1331
+ result .attributes .push (Object .assign ({ }, attribute));
1332
+ result .attributeCount += attribute .size;
1333
+ }
1334
+
1335
+ result .uniforms .sort (function (a, b) { return cmp (a .name, b .name); });
1336
+ result .attributes .sort (function (a, b) { return cmp (a .name, b .name); });
1337
+
1338
+ return result;
1339
+ },
1340
+ printProgramInfo: function ()
1341
+ {
1342
+ const programInfo = this .getProgramInfo ();
1343
+
1344
+ console .log (this .getName ());
1345
+ console .table (programInfo .attributes);
1346
+ console .log (this .getName (), "attributeCount", programInfo .attributeCount);
1347
+ console .log (this .getName ());
1348
+ console .table (programInfo .uniforms);
1349
+ console .log (this .getName (), "uniformCount", programInfo .uniformCount);
1350
+ },
1351
+ };
1352
+
1353
+ return X3DProgrammableShaderObject;
1350
1354
  });