x_ite 4.7.14 → 5.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (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 +55636 -52046
  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 +594 -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 +655 -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 -160
  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 +120 -83
  487. package/src/x_ite/Components/NURBS/ContourPolyline2D.js +103 -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 +129 -125
  495. package/src/x_ite/Components/NURBS/NurbsSurfaceInterpolator.js +128 -130
  496. package/src/x_ite/Components/NURBS/NurbsSweptSurface.js +121 -123
  497. package/src/x_ite/Components/NURBS/NurbsSwungSurface.js +120 -122
  498. package/src/x_ite/Components/NURBS/NurbsTextureCoordinate.js +94 -94
  499. package/src/x_ite/Components/NURBS/NurbsTrimmedSurface.js +127 -90
  500. package/src/x_ite/Components/NURBS/X3DNurbsControlCurveNode.js +13 -15
  501. package/src/x_ite/Components/NURBS/X3DNurbsSurfaceGeometryNode.js +337 -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 +324 -116
  607. package/src/x_ite/Components/Shape/PhysicalMaterial.js +298 -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 +150 -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 -301
  708. package/src/x_ite/Fields/SFNodeCache.js +22 -32
  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 -372
  753. package/src/x_ite/Basic/X3DObjectArrayField.js +0 -551
  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,21 +48,21 @@
48
48
 
49
49
 
50
50
  define ([
51
- "x_ite/Fields",
52
- "x_ite/Basic/X3DFieldDefinition",
53
- "x_ite/Basic/FieldDefinitionArray",
54
- "x_ite/Components/Shape/X3DShapeNode",
55
- "x_ite/Bits/TraverseType",
56
- "x_ite/Bits/X3DConstants",
57
- "x_ite/Bits/X3DCast",
58
- "x_ite/Browser/Shape/AlphaMode",
59
- "standard/Math/Numbers/Vector3",
60
- "standard/Math/Numbers/Vector4",
61
- "standard/Math/Numbers/Matrix4",
62
- "standard/Math/Numbers/Matrix3",
63
- "standard/Math/Algorithms/QuickSort",
64
- "standard/Math/Algorithm",
65
- "standard/Math/Utility/BVH",
51
+ "x_ite/Fields",
52
+ "x_ite/Base/X3DFieldDefinition",
53
+ "x_ite/Base/FieldDefinitionArray",
54
+ "x_ite/Components/Shape/X3DShapeNode",
55
+ "x_ite/Rendering/TraverseType",
56
+ "x_ite/Base/X3DConstants",
57
+ "x_ite/Base/X3DCast",
58
+ "x_ite/Browser/Shape/AlphaMode",
59
+ "standard/Math/Numbers/Vector3",
60
+ "standard/Math/Numbers/Vector4",
61
+ "standard/Math/Numbers/Matrix4",
62
+ "standard/Math/Numbers/Matrix3",
63
+ "standard/Math/Algorithms/QuickSort",
64
+ "standard/Math/Algorithm",
65
+ "standard/Math/Utility/BVH",
66
66
  ],
67
67
  function (Fields,
68
68
  X3DFieldDefinition,
@@ -71,7 +71,7 @@ function (Fields,
71
71
  TraverseType,
72
72
  X3DConstants,
73
73
  X3DCast,
74
- AlphaMode,
74
+ AlphaMode,
75
75
  Vector3,
76
76
  Vector4,
77
77
  Matrix4,
@@ -82,942 +82,943 @@ function (Fields,
82
82
  {
83
83
  "use strict";
84
84
 
85
- var i = 0;
86
-
87
- const
88
- POINT = i ++,
89
- LINE = i ++,
90
- TRIANGLE = i ++,
91
- QUAD = i ++,
92
- GEOMETRY = i ++,
93
- SPRITE = i ++;
94
-
95
- const GeometryTypes = {
96
- POINT: POINT,
97
- LINE: LINE,
98
- TRIANGLE: TRIANGLE,
99
- QUAD: QUAD,
100
- GEOMETRY: GEOMETRY,
101
- SPRITE: SPRITE,
102
- };
103
-
104
- const
105
- invModelViewMatrix = new Matrix4 (),
106
- billboardToScreen = new Vector3 (0, 0, 0),
107
- viewerYAxis = new Vector3 (0, 0, 0),
108
- vector = new Vector3 (0, 0, 0),
109
- normal = new Vector3 (0, 0, 0),
110
- s1 = new Vector3 (0, 0, 0),
111
- s2 = new Vector3 (0, 0, 0),
112
- s3 = new Vector3 (0, 0, 0),
113
- s4 = new Vector3 (0, 0, 0),
114
- x = new Vector3 (0, 0, 0),
115
- y = new Vector3 (0, 0, 0);
116
-
117
- function compareDistance (lhs, rhs) { return lhs .distance < rhs .distance; }
118
-
119
- function ParticleSystem (executionContext)
120
- {
121
- X3DShapeNode .call (this, executionContext);
122
-
123
- this .addType (X3DConstants .ParticleSystem);
124
-
125
- this .particleSize_ .setUnit ("length");
126
-
127
- this .createParticles = true;
128
- this .particles = [ ];
129
- this .velocities = [ ];
130
- this .speeds = [ ];
131
- this .turbulences = [ ];
132
- this .geometryType = POINT;
133
- this .maxParticles = 0;
134
- this .numParticles = 0;
135
- this .particleLifetime = 0;
136
- this .lifetimeVariation = 0;
137
- this .emitterNode = null;
138
- this .forcePhysicsModelNodes = [ ];
139
- this .boundedPhysicsModelNodes = [ ];
140
- this .boundedNormals = [ ];
141
- this .boundedVertices = [ ];
142
- this .boundedVolume = null;
143
- this .creationTime = 0;
144
- this .pauseTime = 0;
145
- this .deltaTime = 0;
146
- this .numForces = 0;
147
- this .colorKeys = [ ];
148
- this .colorRamppNode = null;
149
- this .colorRamp = [ ];
150
- this .texCoordKeys = [ ];
151
- this .texCoordRampNode = null;
152
- this .texCoordRamp = [ ];
153
- this .texCoordAnim = false;
154
- this .vertexCount = 0;
155
- this .shaderNode = null;
156
- this .rotation = new Matrix3 ();
157
- this .particleSorter = new QuickSort (this .particles, compareDistance);
158
- this .sortParticles = false;
159
- this .geometryContext = { };
160
- }
161
-
162
- ParticleSystem .prototype = Object .assign (Object .create (X3DShapeNode .prototype),
163
- {
164
- constructor: ParticleSystem,
165
- fieldDefinitions: new FieldDefinitionArray ([
166
- new X3DFieldDefinition (X3DConstants .inputOutput, "metadata", new Fields .SFNode ()),
167
- new X3DFieldDefinition (X3DConstants .inputOutput, "enabled", new Fields .SFBool (true)),
168
- new X3DFieldDefinition (X3DConstants .inputOutput, "createParticles", new Fields .SFBool (true)),
169
- new X3DFieldDefinition (X3DConstants .initializeOnly, "geometryType", new Fields .SFString ("QUAD")),
170
- new X3DFieldDefinition (X3DConstants .inputOutput, "maxParticles", new Fields .SFInt32 (200)),
171
- new X3DFieldDefinition (X3DConstants .inputOutput, "particleLifetime", new Fields .SFFloat (5)),
172
- new X3DFieldDefinition (X3DConstants .inputOutput, "lifetimeVariation", new Fields .SFFloat (0.25)),
173
- new X3DFieldDefinition (X3DConstants .inputOutput, "particleSize", new Fields .SFVec2f (0.02, 0.02)),
174
- new X3DFieldDefinition (X3DConstants .initializeOnly, "emitter", new Fields .SFNode ()),
175
- new X3DFieldDefinition (X3DConstants .initializeOnly, "physics", new Fields .MFNode ()),
176
- new X3DFieldDefinition (X3DConstants .initializeOnly, "colorKey", new Fields .MFFloat ()),
177
- new X3DFieldDefinition (X3DConstants .initializeOnly, "colorRamp", new Fields .SFNode ()),
178
- new X3DFieldDefinition (X3DConstants .initializeOnly, "texCoordKey", new Fields .MFFloat ()),
179
- new X3DFieldDefinition (X3DConstants .initializeOnly, "texCoordRamp", new Fields .SFNode ()),
180
- new X3DFieldDefinition (X3DConstants .outputOnly, "isActive", new Fields .SFBool ()),
181
- new X3DFieldDefinition (X3DConstants .inputOutput, "visible", new Fields .SFBool (true)),
182
- new X3DFieldDefinition (X3DConstants .inputOutput, "castShadow", new Fields .SFBool (true)),
183
- new X3DFieldDefinition (X3DConstants .inputOutput, "bboxDisplay", new Fields .SFBool ()),
184
- new X3DFieldDefinition (X3DConstants .initializeOnly, "bboxSize", new Fields .SFVec3f (-1, -1, -1)),
185
- new X3DFieldDefinition (X3DConstants .initializeOnly, "bboxCenter", new Fields .SFVec3f ()),
186
- new X3DFieldDefinition (X3DConstants .inputOutput, "appearance", new Fields .SFNode ()),
187
- new X3DFieldDefinition (X3DConstants .inputOutput, "geometry", new Fields .SFNode ()),
188
- ]),
189
- getTypeName: function ()
190
- {
191
- return "ParticleSystem";
192
- },
193
- getComponentName: function ()
194
- {
195
- return "ParticleSystems";
196
- },
197
- getContainerField: function ()
198
- {
199
- return "children";
200
- },
201
- initialize: function ()
202
- {
203
- X3DShapeNode .prototype .initialize .call (this);
204
-
205
- const
206
- browser = this .getBrowser (),
207
- gl = browser .getContext ();
208
-
209
- this .isLive () .addInterest ("set_live__", this);
210
-
211
- browser .getBrowserOptions () .Shading_ .addInterest ("set_shader__", this);
212
-
213
- this .enabled_ .addInterest ("set_enabled__", this);
214
- this .createParticles_ .addInterest ("set_createParticles__", this);
215
- this .geometryType_ .addInterest ("set_geometryType__", this);
216
- this .maxParticles_ .addInterest ("set_enabled__", this);
217
- this .particleLifetime_ .addInterest ("set_particleLifetime__", this);
218
- this .lifetimeVariation_ .addInterest ("set_lifetimeVariation__", this);
219
- this .emitter_ .addInterest ("set_emitter__", this);
220
- this .physics_ .addInterest ("set_physics__", this);
221
- this .colorKey_ .addInterest ("set_color__", this);
222
- this .colorRamp_ .addInterest ("set_colorRamp__", this);
223
- this .texCoordKey_ .addInterest ("set_texCoord__", this);
224
- this .texCoordRamp_ .addInterest ("set_texCoordRamp__", this);
225
-
226
- this .idBuffer = gl .createBuffer ();
227
- this .positionBuffer = gl .createBuffer ();
228
- this .elapsedTimeBuffer = gl .createBuffer ();
229
- this .lifeBuffer = gl .createBuffer ();
230
- this .colorBuffer = gl .createBuffer ();
231
- this .texCoordBuffers = [ gl .createBuffer () ];
232
- this .normalBuffer = gl .createBuffer ();
233
- this .vertexBuffer = gl .createBuffer ();
234
-
235
- for (var i = 1, channels = this .getBrowser () .getMaxTextures (); i < channels; ++ i)
236
- this .texCoordBuffers .push (this .texCoordBuffers [0]);
237
-
238
- this .idArray = new Float32Array ();
239
- this .positionArray = new Float32Array ();
240
- this .elapsedTimeArray = new Float32Array ();
241
- this .lifeArray = new Float32Array ();
242
- this .colorArray = new Float32Array ();
243
- this .texCoordArray = new Float32Array ();
244
- this .normalArray = new Float32Array ();
245
- this .vertexArray = new Float32Array ();
246
-
247
- this .primitiveMode = gl .TRIANGLES;
248
-
249
- // Geometry context
250
-
251
- this .geometryContext .fogCoords = false;
252
- this .geometryContext .textureCoordinateNode = browser .getDefaultTextureCoordinate ();
253
-
254
- // Call order is higly important at startup.
255
- this .set_emitter__ ();
256
- this .set_enabled__ ();
257
- this .set_createParticles__ ();
258
- this .set_particleLifetime__ ();
259
- this .set_lifetimeVariation__ ();
260
- this .set_physics__ ();
261
- this .set_colorRamp__ ();
262
- this .set_texCoordRamp__ ();
263
- },
264
- set_bbox__: function ()
265
- {
266
- if (this .bboxSize_ .getValue () .equals (this .getDefaultBBoxSize ()))
267
- this .bbox .set ();
268
- else
269
- this .bbox .set (this .bboxSize_ .getValue (), this .bboxCenter_ .getValue ());
270
-
271
- this .bboxSize .assign (this .bbox .size);
272
- this .bboxCenter .assign (this .bbox .center);
273
- },
274
- set_transparent__: function ()
275
- {
276
- if (this .getAppearance () .getAlphaMode () === AlphaMode .AUTO)
277
- {
278
- switch (this .geometryType)
279
- {
280
- case POINT:
281
- {
282
- this .setTransparent (true);
283
- break;
284
- }
285
- default:
286
- {
287
- this .setTransparent (this .getAppearance () .getTransparent () ||
288
- (this .colorRampNode && this .colorRampNode .getTransparent ()) ||
289
- (this .geometryType === GEOMETRY && this .geometryNode && this .geometryNode .getTransparent ()));
290
- break;
291
- }
292
- }
293
- }
294
- else
295
- {
296
- this .setTransparent (this .getAppearance () .getTransparent ());
297
- }
298
- },
299
- set_live__: function ()
300
- {
301
- if (this .isLive () .getValue ())
302
- {
303
- if (this .isActive_ .getValue () && this .maxParticles_ .getValue ())
304
- {
305
- this .getBrowser () .sensorEvents () .addInterest ("animateParticles", this);
306
-
307
- if (this .pauseTime)
308
- {
309
- this .creationTime += performance .now () / 1000 - this .pauseTime;
310
- this .pauseTime = 0;
311
- }
312
- }
313
- }
314
- else
315
- {
316
- if (this .isActive_ .getValue () && this .maxParticles_ .getValue ())
317
- {
318
- this .getBrowser () .sensorEvents () .removeInterest ("animateParticles", this);
319
-
320
- if (this .pauseTime === 0)
321
- this .pauseTime = performance .now () / 1000;
322
- }
323
- }
324
- },
325
- set_enabled__: function ()
326
- {
327
- if (this .enabled_ .getValue () && this .maxParticles_ .getValue ())
328
- {
329
- if (! this .isActive_ .getValue ())
330
- {
331
- if (this .isLive () .getValue ())
332
- {
333
- this .getBrowser () .sensorEvents () .addInterest ("animateParticles", this);
334
-
335
- this .pauseTime = 0;
336
- }
337
- else
338
- this .pauseTime = performance .now () / 1000;
339
-
340
- this .isActive_ = true;
341
- }
342
- }
343
- else
344
- {
345
- if (this .isActive_ .getValue ())
346
- {
347
- if (this .isLive () .getValue ())
348
- {
349
- this .getBrowser () .sensorEvents () .removeInterest ("animateParticles", this);
350
- }
351
-
352
- this .isActive_ = false;
353
-
354
- this .numParticles = 0;
355
- }
356
- }
357
-
358
- this .set_maxParticles__ ();
359
- },
360
- set_createParticles__: function ()
361
- {
362
- this .createParticles = this .createParticles_ .getValue ();
363
- },
364
- set_geometryType__: function ()
365
- {
366
- var
367
- gl = this .getBrowser () .getContext (),
368
- maxParticles = this .maxParticles;
369
-
370
- // geometryType
371
-
372
- this .geometryType = GeometryTypes [this .geometryType_ .getValue ()];
373
-
374
- if (! this .geometryType)
375
- this .geometryType = POINT;
376
-
377
- // Create buffers
378
-
379
- switch (this .geometryType)
380
- {
381
- case POINT:
382
- {
383
- this .idArray = new Float32Array (maxParticles);
384
- this .positionArray = new Float32Array (3 * maxParticles);
385
- this .elapsedTimeArray = new Float32Array (maxParticles);
386
- this .lifeArray = new Float32Array (maxParticles);
387
- this .colorArray = new Float32Array (4 * maxParticles);
388
- this .texCoordArray = new Float32Array ();
389
- this .normalArray = new Float32Array ();
390
- this .vertexArray = new Float32Array (4 * maxParticles);
391
-
392
- for (var i = 0, a = this .idArray, l = a .length; i < l; ++ i)
393
- a [i] = i;
394
-
395
- this .colorArray .fill (1);
396
- this .vertexArray .fill (1);
397
-
398
- this .testWireframe = false;
399
- this .primitiveMode = gl .POINTS;
400
- this .texCoordCount = 0;
401
- this .vertexCount = 1;
402
-
403
- this .geometryContext .geometryType = 0;
404
- break;
405
- }
406
- case LINE:
407
- {
408
- this .idArray = new Float32Array (2 * maxParticles);
409
- this .positionArray = new Float32Array (2 * 3 * maxParticles);
410
- this .elapsedTimeArray = new Float32Array (2 * maxParticles);
411
- this .lifeArray = new Float32Array (2 * maxParticles);
412
- this .colorArray = new Float32Array (2 * 4 * maxParticles);
413
- this .texCoordArray = new Float32Array ();
414
- this .normalArray = new Float32Array ();
415
- this .vertexArray = new Float32Array (2 * 4 * maxParticles);
416
-
417
- for (var i = 0, a = this .idArray, l = a .length; i < l; ++ i)
418
- a [i] = Math .floor (i / 2);
419
-
420
- this .colorArray .fill (1);
421
- this .vertexArray .fill (1);
422
-
423
- this .testWireframe = false;
424
- this .primitiveMode = gl .LINES;
425
- this .texCoordCount = 2;
426
- this .vertexCount = 2;
427
-
428
- this .geometryContext .geometryType = 1;
429
- break;
430
- }
431
- case TRIANGLE:
432
- case QUAD:
433
- case SPRITE:
434
- {
435
- this .idArray = new Float32Array (6 * maxParticles);
436
- this .positionArray = new Float32Array (6 * 3 * maxParticles);
437
- this .elapsedTimeArray = new Float32Array (6 * maxParticles);
438
- this .lifeArray = new Float32Array (6 * maxParticles);
439
- this .colorArray = new Float32Array (6 * 4 * maxParticles);
440
- this .texCoordArray = new Float32Array (6 * 4 * maxParticles);
441
- this .normalArray = new Float32Array (6 * 3 * maxParticles);
442
- this .vertexArray = new Float32Array (6 * 4 * maxParticles);
443
-
444
- for (var i = 0, a = this .idArray, l = a .length; i < l; ++ i)
445
- a [i] = Math .floor (i / 6);
446
-
447
- this .colorArray .fill (1);
448
- this .vertexArray .fill (1);
449
-
450
- var
451
- texCoordArray = this .texCoordArray,
452
- normalArray = this .normalArray;
453
-
454
- for (var i = 0, length = 6 * 3 * maxParticles; i < length; i += 3)
455
- {
456
- normalArray [i] = 0;
457
- normalArray [i + 1] = 0;
458
- normalArray [i + 2] = 1;
459
- }
460
-
461
- gl .bindBuffer (gl .ARRAY_BUFFER, this .normalBuffer);
462
- gl .bufferData (gl .ARRAY_BUFFER, this .normalArray, gl .STATIC_DRAW);
463
-
464
- for (var i = 0; i < maxParticles; ++ i)
465
- {
466
- var i24 = i * 24;
467
-
468
- // p4 ------ p3
469
- // | / |
470
- // | / |
471
- // | / |
472
- // | / |
473
- // p1 ------ p2
474
-
475
- // p1
476
- texCoordArray [i24] = texCoordArray [i24 + 12] = 0;
477
- texCoordArray [i24 + 1] = texCoordArray [i24 + 13] = 0;
478
- texCoordArray [i24 + 2] = texCoordArray [i24 + 14] = 0;
479
- texCoordArray [i24 + 3] = texCoordArray [i24 + 15] = 1;
480
-
481
- // p2
482
- texCoordArray [i24 + 4] = 1;
483
- texCoordArray [i24 + 5] = 0;
484
- texCoordArray [i24 + 6] = 0;
485
- texCoordArray [i24 + 7] = 1;
486
-
487
- // p3
488
- texCoordArray [i24 + 8] = texCoordArray [i24 + 16] = 1;
489
- texCoordArray [i24 + 9] = texCoordArray [i24 + 17] = 1;
490
- texCoordArray [i24 + 10] = texCoordArray [i24 + 18] = 0;
491
- texCoordArray [i24 + 11] = texCoordArray [i24 + 19] = 1;
492
-
493
- // p4
494
- texCoordArray [i24 + 20] = 0;
495
- texCoordArray [i24 + 21] = 1;
496
- texCoordArray [i24 + 22] = 0;
497
- texCoordArray [i24 + 23] = 1;
498
- }
499
-
500
- gl .bindBuffer (gl .ARRAY_BUFFER, this .texCoordBuffers [0]);
501
- gl .bufferData (gl .ARRAY_BUFFER, this .texCoordArray, gl .STATIC_DRAW);
502
-
503
- this .testWireframe = true;
504
- this .primitiveMode = gl .TRIANGLES;
505
- this .texCoordCount = 4;
506
- this .vertexCount = 6;
507
-
508
- this .geometryContext .geometryType = 2;
509
- break;
510
- }
511
- case GEOMETRY:
512
- {
513
- this .texCoordCount = 0;
514
- this .vertexCount = 0;
515
- break;
516
- }
517
- }
518
-
519
- gl .bindBuffer (gl .ARRAY_BUFFER, this .idBuffer);
520
- gl .bufferData (gl .ARRAY_BUFFER, this .idArray, gl .STATIC_DRAW);
521
-
522
- this .set_shader__ ();
523
- this .set_transparent__ ();
524
- },
525
- set_shader__: function ()
526
- {
527
- switch (this .geometryType)
528
- {
529
- case POINT:
530
- {
531
- this .shaderNode = this .getBrowser () .getPointShader ();
532
- break;
533
- }
534
- case LINE:
535
- {
536
- this .shaderNode = this .getBrowser () .getLineShader ();
537
- break;
538
- }
539
- case TRIANGLE:
540
- case QUAD:
541
- case SPRITE:
542
- case GEOMETRY:
543
- {
544
- this .shaderNode = null;
545
- break;
546
- }
547
- }
548
- },
549
- set_maxParticles__: function ()
550
- {
551
- var
552
- particles = this .particles,
553
- maxParticles = Math .max (0, this .maxParticles_ .getValue ());
554
-
555
- for (var i = this .numParticles, length = Math .min (particles .length, maxParticles); i < length; ++ i)
556
- {
557
- particles [i] .life = 1;
558
- particles [i] .lifetime = -1;
559
- }
560
-
561
- for (var i = particles .length, length = maxParticles; i < length; ++ i)
562
- {
563
- particles [i] = {
564
- id: i,
565
- life: 1,
566
- lifetime: -1,
567
- elapsedTime: 0,
568
- position: new Vector3 (0, 0, 0),
569
- velocity: new Vector3 (0, 0, 0),
570
- color: new Vector4 (1, 1, 1, 1),
571
- distance: 0,
572
- };
573
- }
574
-
575
- this .maxParticles = maxParticles;
576
- this .numParticles = Math .min (this .numParticles, maxParticles);
577
-
578
- if (! this .emitterNode .isExplosive ())
579
- this .creationTime = performance .now () / 1000;
580
-
581
- this .set_geometryType__ ();
582
- },
583
- set_particleLifetime__: function ()
584
- {
585
- this .particleLifetime = this .particleLifetime_ .getValue ();
586
- },
587
- set_lifetimeVariation__: function ()
588
- {
589
- this .lifetimeVariation = this .lifetimeVariation_ .getValue ();
590
- },
591
- set_emitter__: function ()
592
- {
593
- this .emitterNode = X3DCast (X3DConstants .X3DParticleEmitterNode, this .emitter_);
594
-
595
- if (! this .emitterNode)
596
- this .emitterNode = this .getBrowser () .getDefaultEmitter ();
597
-
598
- this .createParticles = this .createParticles_ .getValue ();
599
- },
600
- set_physics__: function ()
601
- {
602
- var
603
- physics = this .physics_ .getValue (),
604
- forcePhysicsModelNodes = this .forcePhysicsModelNodes,
605
- boundedPhysicsModelNodes = this .boundedPhysicsModelNodes;
606
-
607
- for (var i = 0, length = boundedPhysicsModelNodes .length; i < length; ++ i)
608
- boundedPhysicsModelNodes [i] .removeInterest ("set_boundedPhysics__", this);
609
-
610
- forcePhysicsModelNodes .length = 0;
611
- boundedPhysicsModelNodes .length = 0;
612
-
613
- for (var i = 0, length = physics .length; i < length; ++ i)
614
- {
615
- try
616
- {
617
- var
618
- innerNode = physics [i] .getValue () .getInnerNode (),
619
- type = innerNode .getType ();
620
-
621
- for (var t = type .length - 1; t >= 0; -- t)
622
- {
623
- switch (type [t])
624
- {
625
- case X3DConstants .ForcePhysicsModel:
626
- case X3DConstants .WindPhysicsModel:
627
- {
628
- forcePhysicsModelNodes .push (innerNode);
629
- break;
630
- }
631
- case X3DConstants .BoundedPhysicsModel:
632
- {
633
- innerNode .addInterest ("set_boundedPhysics__", this);
634
- boundedPhysicsModelNodes .push (innerNode);
635
- break;
636
- }
637
- default:
638
- continue;
639
- }
640
-
641
- break;
642
- }
643
- }
644
- catch (error)
645
- { }
646
- }
647
-
648
- this .set_boundedPhysics__ ();
649
- },
650
- set_boundedPhysics__: function ()
651
- {
652
- var
653
- boundedPhysicsModelNodes = this .boundedPhysicsModelNodes,
654
- boundedNormals = this .boundedNormals,
655
- boundedVertices = this .boundedVertices;
656
-
657
- boundedNormals .length = 0;
658
- boundedVertices .length = 0;
659
-
660
- for (var i = 0, length = boundedPhysicsModelNodes .length; i < length; ++ i)
661
- {
662
- boundedPhysicsModelNodes [i] .addGeometry (boundedNormals, boundedVertices);
663
- }
664
-
665
- this .boundedVolume = new BVH (boundedVertices, boundedNormals);
666
- },
667
- set_colorRamp__: function ()
668
- {
669
- if (this .colorRampNode)
670
- this .colorRampNode .removeInterest ("set_color__", this);
671
-
672
- this .colorRampNode = X3DCast (X3DConstants .X3DColorNode, this .colorRamp_);
673
-
674
- if (this .colorRampNode)
675
- this .colorRampNode .addInterest ("set_color__", this);
676
-
677
- this .set_color__ ();
678
- this .set_transparent__ ();
679
- },
680
- set_color__: function ()
681
- {
682
- var
683
- colorKey = this .colorKey_,
684
- colorKeys = this .colorKeys,
685
- colorRamp = this .colorRamp;
686
-
687
- for (var i = 0, length = colorKey .length; i < length; ++ i)
688
- colorKeys [i] = colorKey [i];
689
-
690
- colorKeys .length = length;
691
-
692
- if (this .colorRampNode)
693
- this .colorRampNode .getVectors (this .colorRamp);
694
-
695
- for (var i = colorRamp .length, length = colorKey .length; i < length; ++ i)
696
- colorRamp [i] = new Vector4 (1, 1, 1, 1);
697
-
698
- colorRamp .length = length;
699
-
700
- this .geometryContext .colorMaterial = !! (colorKeys .length && this .colorRampNode);
701
- },
702
- set_texCoordRamp__: function ()
703
- {
704
- if (this .texCoordRampNode)
705
- this .texCoordRampNode .removeInterest ("set_texCoord__", this);
706
-
707
- this .texCoordRampNode = X3DCast (X3DConstants .X3DTextureCoordinateNode, this .texCoordRamp_);
708
-
709
- if (this .texCoordRampNode)
710
- this .texCoordRampNode .addInterest ("set_texCoord__", this);
711
-
712
- this .set_texCoord__ ();
713
- },
714
- set_texCoord__: function ()
715
- {
716
- var
717
- texCoordKey = this .texCoordKey_,
718
- texCoordKeys = this .texCoordKeys,
719
- texCoordRamp = this .texCoordRamp;
720
-
721
- for (var i = 0, length = texCoordKey .length; i < length; ++ i)
722
- texCoordKeys [i] = texCoordKey [i];
723
-
724
- texCoordKeys .length = length;
725
-
726
- if (this .texCoordRampNode)
727
- this .texCoordRampNode .getTexCoord (texCoordRamp);
728
-
729
- for (var i = texCoordRamp .length, length = texCoordKey .length * this .texCoordCount; i < length; ++ i)
730
- texCoordRamp [i] = new Vector4 (0, 0, 0, 0);
731
-
732
- texCoordRamp .length = length;
733
-
734
- this .texCoordAnim = !! (texCoordKeys .length && this .texCoordRampNode);
735
- },
736
- intersectsBox: function (box, clipPlanes)
737
- {
738
- // TODO: implement me.
739
- },
740
- animateParticles: function ()
741
- {
742
- var emitterNode = this .emitterNode;
743
-
744
- // Determine delta time
745
-
746
- var
747
- DELAY = 15, // Delay in frames when dt full applys.
748
- dt = 1 / Math .max (10, this .getBrowser () .getCurrentFrameRate ());
749
-
750
- // var deltaTime is only for the emitter, this.deltaTime is for the forces.
751
- var deltaTime = this .deltaTime = ((DELAY - 1) * this .deltaTime + dt) / DELAY; // Moving average about DELAY frames.
752
-
753
- // Determine numParticles
754
-
755
- if (emitterNode .isExplosive ())
756
- {
757
- var
758
- now = performance .now () / 1000,
759
- particleLifetime = this .particleLifetime + this .particleLifetime * this .lifetimeVariation;
760
-
761
- if (this .numParticles === 0 || now - this .creationTime > particleLifetime)
762
- {
763
- this .creationTime = now;
764
- this .numParticles = this .maxParticles;
765
- this .createParticles = this .createParticles_ .getValue ();
766
-
767
- deltaTime = Number .POSITIVE_INFINITY;
768
- }
769
- else
770
- this .createParticles = false;
771
- }
772
- else
773
- {
774
- if (this .numParticles < this .maxParticles)
775
- {
776
- var
777
- now = performance .now () / 1000,
778
- newParticles = Math .max (0, Math .floor ((now - this .creationTime) * this .maxParticles / this .particleLifetime));
779
-
780
- if (newParticles)
781
- this .creationTime = now;
782
-
783
- this .numParticles = Math .floor (Math .min (this .maxParticles, this .numParticles + newParticles));
784
- }
785
- }
786
-
787
- // Apply forces.
788
-
789
- if (emitterNode .getMass ())
790
- {
791
- var
792
- forcePhysicsModelNodes = this .forcePhysicsModelNodes,
793
- velocities = this .velocities,
794
- speeds = this .speeds,
795
- turbulences = this .turbulences,
796
- deltaMass = this .deltaTime / emitterNode .getMass ();
797
-
798
- // Collect forces in velocities and collect turbulences.
799
-
800
- for (var i = velocities .length, length = forcePhysicsModelNodes .length; i < length; ++ i)
801
- velocities [i] = new Vector3 (0, 0, 0);
802
-
803
- for (var i = 0, length = forcePhysicsModelNodes .length; i < length; ++ i)
804
- forcePhysicsModelNodes [i] .addForce (i, emitterNode, velocities, turbulences);
805
-
806
- // Determine velocities from forces and determine speed.
807
-
808
- for (var i = 0, length = velocities .length; i < length; ++ i)
809
- {
810
- velocities [i] .multiply (deltaMass);
811
- speeds [i] = velocities [i] .abs ();
812
- }
813
-
814
- this .numForces = length;
815
- }
816
- else
817
- {
818
- this .numForces = 0;
819
- }
820
-
821
- // Determine particle position, velocity and colors
822
-
823
- emitterNode .animate (this, deltaTime);
824
-
825
- this .updateGeometry (null);
826
-
827
- this .getBrowser () .addBrowserEvent ();
828
- },
829
- updateGeometry: function (modelViewMatrix)
830
- {
831
- switch (this .geometryType)
832
- {
833
- case POINT:
834
- if (! modelViewMatrix)
835
- this .updatePoint ();
836
- break;
837
- case LINE:
838
- if (! modelViewMatrix)
839
- this .updateLine ();
840
- break;
841
- case TRIANGLE:
842
- case QUAD:
843
- case SPRITE:
844
- this .updateQuad (modelViewMatrix);
845
- break;
846
- case GEOMETRY:
847
- break;
848
- }
849
- },
850
- updatePoint: function ()
851
- {
852
- var
853
- gl = this .getBrowser () .getContext (),
854
- particles = this .particles,
855
- numParticles = this .numParticles,
856
- positionArray = this .positionArray,
857
- elapsedTimeArray = this .elapsedTimeArray,
858
- lifeArray = this .lifeArray,
859
- colorArray = this .colorArray,
860
- vertexArray = this .vertexArray;
861
-
862
- // Colors
863
-
864
- if (this .geometryContext .colorMaterial)
865
- {
866
- for (var i = 0; i < numParticles; ++ i)
867
- {
868
- var
869
- color = particles [i] .color,
870
- i4 = i * 4;
871
-
872
- colorArray [i4] = color .x;
873
- colorArray [i4 + 1] = color .y;
874
- colorArray [i4 + 2] = color .z;
875
- colorArray [i4 + 3] = color .w;
876
- }
877
-
878
- gl .bindBuffer (gl .ARRAY_BUFFER, this .colorBuffer);
879
- gl .bufferData (gl .ARRAY_BUFFER, this .colorArray, gl .STATIC_DRAW);
880
- }
881
-
882
- // Vertices
883
-
884
- for (var i = 0; i < numParticles; ++ i)
885
- {
886
- var
887
- position = particles [i] .position,
888
- elapsedTime = particles [i] .elapsedTime / particles [i] .lifetime,
889
- i3 = i * 3,
890
- i4 = i * 4;
891
-
892
- positionArray [i3] = position .x;
893
- positionArray [i3 + 1] = position .y;
894
- positionArray [i3 + 2] = position .z;
895
-
896
- elapsedTimeArray [i] = elapsedTime;
897
- lifeArray [i] = particles [i] .life;
898
-
899
- vertexArray [i4] = position .x;
900
- vertexArray [i4 + 1] = position .y;
901
- vertexArray [i4 + 2] = position .z;
902
- }
903
-
904
- gl .bindBuffer (gl .ARRAY_BUFFER, this .positionBuffer);
905
- gl .bufferData (gl .ARRAY_BUFFER, this .positionArray, gl .STATIC_DRAW);
906
- gl .bindBuffer (gl .ARRAY_BUFFER, this .elapsedTimeBuffer);
907
- gl .bufferData (gl .ARRAY_BUFFER, this .elapsedTimeArray, gl .STATIC_DRAW);
908
- gl .bindBuffer (gl .ARRAY_BUFFER, this .lifeBuffer);
909
- gl .bufferData (gl .ARRAY_BUFFER, this .lifeArray, gl .STATIC_DRAW);
910
- gl .bindBuffer (gl .ARRAY_BUFFER, this .vertexBuffer);
911
- gl .bufferData (gl .ARRAY_BUFFER, this .vertexArray, gl .STATIC_DRAW);
912
- },
913
- updateLine: function ()
914
- {
915
- var
916
- gl = this .getBrowser () .getContext (),
917
- particles = this .particles,
918
- numParticles = this .numParticles,
919
- positionArray = this .positionArray,
920
- elapsedTimeArray = this .elapsedTimeArray,
921
- lifeArray = this .lifeArray,
922
- colorArray = this .colorArray,
923
- vertexArray = this .vertexArray,
924
- sy1_2 = this .particleSize_ .y / 2;
925
-
926
- // Colors
927
-
928
- if (this .geometryContext .colorMaterial)
929
- {
930
- for (var i = 0; i < numParticles; ++ i)
931
- {
932
- var
933
- color = particles [i] .color,
934
- i8 = i * 8;
935
-
936
- colorArray [i8] = color .x;
937
- colorArray [i8 + 1] = color .y;
938
- colorArray [i8 + 2] = color .z;
939
- colorArray [i8 + 3] = color .w;
940
-
941
- colorArray [i8 + 4] = color .x;
942
- colorArray [i8 + 5] = color .y;
943
- colorArray [i8 + 6] = color .z;
944
- colorArray [i8 + 7] = color .w;
945
- }
946
-
947
- gl .bindBuffer (gl .ARRAY_BUFFER, this .colorBuffer);
948
- gl .bufferData (gl .ARRAY_BUFFER, this .colorArray, gl .STATIC_DRAW);
949
- }
950
-
951
- // Vertices
952
-
953
- for (var i = 0; i < numParticles; ++ i)
954
- {
955
- var
956
- particle = particles [i],
957
- position = particle .position,
958
- elapsedTime = particles [i] .elapsedTime / particles [i] .lifetime,
959
- life = particles [i] .life,
960
- x = position .x,
961
- y = position .y,
962
- z = position .z,
963
- i2 = i * 2,
964
- i6 = i * 6,
965
- i8 = i * 8;
966
-
967
- positionArray [i6] = x;
968
- positionArray [i6 + 1] = y;
969
- positionArray [i6 + 2] = z;
970
- positionArray [i6 + 3] = x;
971
- positionArray [i6 + 4] = y;
972
- positionArray [i6 + 5] = z;
973
-
974
- elapsedTimeArray [i2] = elapsedTime;
975
- elapsedTimeArray [i2 + 1] = elapsedTime;
976
-
977
- lifeArray [i2] = life;
978
- lifeArray [i2 + 1] = life;
979
-
980
- // Length of line / 2.
981
- normal .assign (particle .velocity) .normalize () .multiply (sy1_2);
982
-
983
- vertexArray [i8] = x - normal .x;
984
- vertexArray [i8 + 1] = y - normal .y;
985
- vertexArray [i8 + 2] = z - normal .z;
986
-
987
- vertexArray [i8 + 4] = x + normal .x;
988
- vertexArray [i8 + 5] = y + normal .y;
989
- vertexArray [i8 + 6] = z + normal .z;
990
- }
991
-
992
- gl .bindBuffer (gl .ARRAY_BUFFER, this .positionBuffer);
993
- gl .bufferData (gl .ARRAY_BUFFER, this .positionArray, gl .STATIC_DRAW);
994
- gl .bindBuffer (gl .ARRAY_BUFFER, this .elapsedTimeBuffer);
995
- gl .bufferData (gl .ARRAY_BUFFER, this .elapsedTimeArray, gl .STATIC_DRAW);
996
- gl .bindBuffer (gl .ARRAY_BUFFER, this .lifeBuffer);
997
- gl .bufferData (gl .ARRAY_BUFFER, this .lifeArray, gl .STATIC_DRAW);
998
- gl .bindBuffer (gl .ARRAY_BUFFER, this .vertexBuffer);
999
- gl .bufferData (gl .ARRAY_BUFFER, this .vertexArray, gl .STATIC_DRAW);
1000
- },
1001
- updateQuad: function (modelViewMatrix)
1002
- {
1003
- try
1004
- {
1005
- var
1006
- gl = this .getBrowser () .getContext (),
1007
- particles = this .particles,
1008
- maxParticles = this .maxParticles,
1009
- numParticles = this .numParticles,
1010
- positionArray = this .positionArray,
1011
- elapsedTimeArray = this .elapsedTimeArray,
1012
- lifeArray = this .lifeArray,
1013
- colorArray = this .colorArray,
1014
- texCoordArray = this .texCoordArray,
1015
- normalArray = this .normalArray,
1016
- vertexArray = this .vertexArray,
1017
- sx1_2 = this .particleSize_ .x / 2,
1018
- sy1_2 = this .particleSize_ .y / 2;
1019
-
1020
- // Sort particles
85
+ var i = 0;
86
+
87
+ const
88
+ POINT = i ++,
89
+ LINE = i ++,
90
+ TRIANGLE = i ++,
91
+ QUAD = i ++,
92
+ GEOMETRY = i ++,
93
+ SPRITE = i ++;
94
+
95
+ const GeometryTypes = {
96
+ POINT: POINT,
97
+ LINE: LINE,
98
+ TRIANGLE: TRIANGLE,
99
+ QUAD: QUAD,
100
+ GEOMETRY: GEOMETRY,
101
+ SPRITE: SPRITE,
102
+ };
103
+
104
+ const
105
+ invModelViewMatrix = new Matrix4 (),
106
+ billboardToScreen = new Vector3 (0, 0, 0),
107
+ viewerYAxis = new Vector3 (0, 0, 0),
108
+ vector = new Vector3 (0, 0, 0),
109
+ normal = new Vector3 (0, 0, 0),
110
+ s1 = new Vector3 (0, 0, 0),
111
+ s2 = new Vector3 (0, 0, 0),
112
+ s3 = new Vector3 (0, 0, 0),
113
+ s4 = new Vector3 (0, 0, 0),
114
+ x = new Vector3 (0, 0, 0),
115
+ y = new Vector3 (0, 0, 0);
116
+
117
+ function compareDistance (lhs, rhs) { return lhs .distance < rhs .distance; }
118
+
119
+ function ParticleSystem (executionContext)
120
+ {
121
+ X3DShapeNode .call (this, executionContext);
122
+
123
+ this .addType (X3DConstants .ParticleSystem);
124
+
125
+ this ._particleSize .setUnit ("length");
126
+
127
+ this .createParticles = true;
128
+ this .particles = [ ];
129
+ this .velocities = [ ];
130
+ this .speeds = [ ];
131
+ this .turbulences = [ ];
132
+ this .geometryType = POINT;
133
+ this .maxParticles = 0;
134
+ this .numParticles = 0;
135
+ this .particleLifetime = 0;
136
+ this .lifetimeVariation = 0;
137
+ this .emitterNode = null;
138
+ this .forcePhysicsModelNodes = [ ];
139
+ this .boundedPhysicsModelNodes = [ ];
140
+ this .boundedNormals = [ ];
141
+ this .boundedVertices = [ ];
142
+ this .boundedVolume = null;
143
+ this .creationTime = 0;
144
+ this .pauseTime = 0;
145
+ this .deltaTime = 0;
146
+ this .numForces = 0;
147
+ this .colorKeys = [ ];
148
+ this .colorRamppNode = null;
149
+ this .colorRamp = [ ];
150
+ this .texCoordKeys = [ ];
151
+ this .texCoordRampNode = null;
152
+ this .texCoordRamp = [ ];
153
+ this .texCoordAnim = false;
154
+ this .vertexCount = 0;
155
+ this .shaderNode = null;
156
+ this .rotation = new Matrix3 ();
157
+ this .particleSorter = new QuickSort (this .particles, compareDistance);
158
+ this .sortParticles = false;
159
+ this .geometryContext = { };
160
+ }
161
+
162
+ ParticleSystem .prototype = Object .assign (Object .create (X3DShapeNode .prototype),
163
+ {
164
+ constructor: ParticleSystem,
165
+ [Symbol .for ("X_ITE.X3DBaseNode.fieldDefinitions")]: new FieldDefinitionArray ([
166
+ new X3DFieldDefinition (X3DConstants .inputOutput, "metadata", new Fields .SFNode ()),
167
+ new X3DFieldDefinition (X3DConstants .inputOutput, "enabled", new Fields .SFBool (true)),
168
+ new X3DFieldDefinition (X3DConstants .inputOutput, "createParticles", new Fields .SFBool (true)),
169
+ new X3DFieldDefinition (X3DConstants .initializeOnly, "geometryType", new Fields .SFString ("QUAD")),
170
+ new X3DFieldDefinition (X3DConstants .inputOutput, "maxParticles", new Fields .SFInt32 (200)),
171
+ new X3DFieldDefinition (X3DConstants .inputOutput, "particleLifetime", new Fields .SFFloat (5)),
172
+ new X3DFieldDefinition (X3DConstants .inputOutput, "lifetimeVariation", new Fields .SFFloat (0.25)),
173
+ new X3DFieldDefinition (X3DConstants .inputOutput, "particleSize", new Fields .SFVec2f (0.02, 0.02)),
174
+ new X3DFieldDefinition (X3DConstants .initializeOnly, "emitter", new Fields .SFNode ()),
175
+ new X3DFieldDefinition (X3DConstants .initializeOnly, "physics", new Fields .MFNode ()),
176
+ new X3DFieldDefinition (X3DConstants .initializeOnly, "colorKey", new Fields .MFFloat ()),
177
+ new X3DFieldDefinition (X3DConstants .initializeOnly, "colorRamp", new Fields .SFNode ()),
178
+ new X3DFieldDefinition (X3DConstants .initializeOnly, "texCoordKey", new Fields .MFFloat ()),
179
+ new X3DFieldDefinition (X3DConstants .initializeOnly, "texCoordRamp", new Fields .SFNode ()),
180
+ new X3DFieldDefinition (X3DConstants .outputOnly, "isActive", new Fields .SFBool ()),
181
+ new X3DFieldDefinition (X3DConstants .inputOutput, "visible", new Fields .SFBool (true)),
182
+ new X3DFieldDefinition (X3DConstants .inputOutput, "castShadow", new Fields .SFBool (true)),
183
+ new X3DFieldDefinition (X3DConstants .inputOutput, "bboxDisplay", new Fields .SFBool ()),
184
+ new X3DFieldDefinition (X3DConstants .initializeOnly, "bboxSize", new Fields .SFVec3f (-1, -1, -1)),
185
+ new X3DFieldDefinition (X3DConstants .initializeOnly, "bboxCenter", new Fields .SFVec3f ()),
186
+ new X3DFieldDefinition (X3DConstants .inputOutput, "appearance", new Fields .SFNode ()),
187
+ new X3DFieldDefinition (X3DConstants .inputOutput, "geometry", new Fields .SFNode ()),
188
+ ]),
189
+ getTypeName: function ()
190
+ {
191
+ return "ParticleSystem";
192
+ },
193
+ getComponentName: function ()
194
+ {
195
+ return "ParticleSystems";
196
+ },
197
+ getContainerField: function ()
198
+ {
199
+ return "children";
200
+ },
201
+ initialize: function ()
202
+ {
203
+ X3DShapeNode .prototype .initialize .call (this);
204
+
205
+ const
206
+ browser = this .getBrowser (),
207
+ gl = browser .getContext ();
208
+
209
+ this .isLive () .addInterest ("set_live__", this);
210
+
211
+ browser .getBrowserOptions () ._Shading .addInterest ("set_shader__", this);
212
+
213
+ this ._enabled .addInterest ("set_enabled__", this);
214
+ this ._createParticles .addInterest ("set_createParticles__", this);
215
+ this ._geometryType .addInterest ("set_geometryType__", this);
216
+ this ._maxParticles .addInterest ("set_enabled__", this);
217
+ this ._particleLifetime .addInterest ("set_particleLifetime__", this);
218
+ this ._lifetimeVariation .addInterest ("set_lifetimeVariation__", this);
219
+ this ._emitter .addInterest ("set_emitter__", this);
220
+ this ._physics .addInterest ("set_physics__", this);
221
+ this ._colorKey .addInterest ("set_color__", this);
222
+ this ._colorRamp .addInterest ("set_colorRamp__", this);
223
+ this ._texCoordKey .addInterest ("set_texCoord__", this);
224
+ this ._texCoordRamp .addInterest ("set_texCoordRamp__", this);
225
+
226
+ this .idBuffer = gl .createBuffer ();
227
+ this .positionBuffer = gl .createBuffer ();
228
+ this .elapsedTimeBuffer = gl .createBuffer ();
229
+ this .lifeBuffer = gl .createBuffer ();
230
+ this .colorBuffer = gl .createBuffer ();
231
+ this .texCoordBuffers = [ gl .createBuffer () ];
232
+ this .normalBuffer = gl .createBuffer ();
233
+ this .vertexBuffer = gl .createBuffer ();
234
+
235
+ for (var i = 1, channels = this .getBrowser () .getMaxTextures (); i < channels; ++ i)
236
+ this .texCoordBuffers .push (this .texCoordBuffers [0]);
237
+
238
+ this .idArray = new Float32Array ();
239
+ this .positionArray = new Float32Array ();
240
+ this .elapsedTimeArray = new Float32Array ();
241
+ this .lifeArray = new Float32Array ();
242
+ this .colorArray = new Float32Array ();
243
+ this .texCoordArray = new Float32Array ();
244
+ this .normalArray = new Float32Array ();
245
+ this .vertexArray = new Float32Array ();
246
+
247
+ this .primitiveMode = gl .TRIANGLES;
248
+
249
+ // Geometry context
250
+
251
+ this .geometryContext .fogCoords = false;
252
+ this .geometryContext .textureCoordinateNode = browser .getDefaultTextureCoordinate ();
253
+ this .geometryContext .textureCoordinateMapping = new Map ();
254
+
255
+ // Call order is higly important at startup.
256
+ this .set_emitter__ ();
257
+ this .set_enabled__ ();
258
+ this .set_createParticles__ ();
259
+ this .set_particleLifetime__ ();
260
+ this .set_lifetimeVariation__ ();
261
+ this .set_physics__ ();
262
+ this .set_colorRamp__ ();
263
+ this .set_texCoordRamp__ ();
264
+ },
265
+ set_bbox__: function ()
266
+ {
267
+ if (this ._bboxSize .getValue () .equals (this .getDefaultBBoxSize ()))
268
+ this .bbox .set ();
269
+ else
270
+ this .bbox .set (this ._bboxSize .getValue (), this ._bboxCenter .getValue ());
271
+
272
+ this .bboxSize .assign (this .bbox .size);
273
+ this .bboxCenter .assign (this .bbox .center);
274
+ },
275
+ set_transparent__: function ()
276
+ {
277
+ if (this .getAppearance () .getAlphaMode () === AlphaMode .AUTO)
278
+ {
279
+ switch (this .geometryType)
280
+ {
281
+ case POINT:
282
+ {
283
+ this .setTransparent (true);
284
+ break;
285
+ }
286
+ default:
287
+ {
288
+ this .setTransparent (this .getAppearance () .getTransparent () ||
289
+ (this .colorRampNode && this .colorRampNode .getTransparent ()) ||
290
+ (this .geometryType === GEOMETRY && this .geometryNode && this .geometryNode .getTransparent ()));
291
+ break;
292
+ }
293
+ }
294
+ }
295
+ else
296
+ {
297
+ this .setTransparent (this .getAppearance () .getTransparent ());
298
+ }
299
+ },
300
+ set_live__: function ()
301
+ {
302
+ if (this .isLive () .getValue ())
303
+ {
304
+ if (this ._isActive .getValue () && this ._maxParticles .getValue ())
305
+ {
306
+ this .getBrowser () .sensorEvents () .addInterest ("animateParticles", this);
307
+
308
+ if (this .pauseTime)
309
+ {
310
+ this .creationTime += performance .now () / 1000 - this .pauseTime;
311
+ this .pauseTime = 0;
312
+ }
313
+ }
314
+ }
315
+ else
316
+ {
317
+ if (this ._isActive .getValue () && this ._maxParticles .getValue ())
318
+ {
319
+ this .getBrowser () .sensorEvents () .removeInterest ("animateParticles", this);
320
+
321
+ if (this .pauseTime === 0)
322
+ this .pauseTime = performance .now () / 1000;
323
+ }
324
+ }
325
+ },
326
+ set_enabled__: function ()
327
+ {
328
+ if (this ._enabled .getValue () && this ._maxParticles .getValue ())
329
+ {
330
+ if (! this ._isActive .getValue ())
331
+ {
332
+ if (this .isLive () .getValue ())
333
+ {
334
+ this .getBrowser () .sensorEvents () .addInterest ("animateParticles", this);
335
+
336
+ this .pauseTime = 0;
337
+ }
338
+ else
339
+ this .pauseTime = performance .now () / 1000;
340
+
341
+ this ._isActive = true;
342
+ }
343
+ }
344
+ else
345
+ {
346
+ if (this ._isActive .getValue ())
347
+ {
348
+ if (this .isLive () .getValue ())
349
+ {
350
+ this .getBrowser () .sensorEvents () .removeInterest ("animateParticles", this);
351
+ }
352
+
353
+ this ._isActive = false;
354
+
355
+ this .numParticles = 0;
356
+ }
357
+ }
358
+
359
+ this .set_maxParticles__ ();
360
+ },
361
+ set_createParticles__: function ()
362
+ {
363
+ this .createParticles = this ._createParticles .getValue ();
364
+ },
365
+ set_geometryType__: function ()
366
+ {
367
+ var
368
+ gl = this .getBrowser () .getContext (),
369
+ maxParticles = this .maxParticles;
370
+
371
+ // geometryType
372
+
373
+ this .geometryType = GeometryTypes [this ._geometryType .getValue ()];
374
+
375
+ if (! this .geometryType)
376
+ this .geometryType = POINT;
377
+
378
+ // Create buffers
379
+
380
+ switch (this .geometryType)
381
+ {
382
+ case POINT:
383
+ {
384
+ this .idArray = new Float32Array (maxParticles);
385
+ this .positionArray = new Float32Array (3 * maxParticles);
386
+ this .elapsedTimeArray = new Float32Array (maxParticles);
387
+ this .lifeArray = new Float32Array (maxParticles);
388
+ this .colorArray = new Float32Array (4 * maxParticles);
389
+ this .texCoordArray = new Float32Array ();
390
+ this .normalArray = new Float32Array ();
391
+ this .vertexArray = new Float32Array (4 * maxParticles);
392
+
393
+ for (var i = 0, a = this .idArray, l = a .length; i < l; ++ i)
394
+ a [i] = i;
395
+
396
+ this .colorArray .fill (1);
397
+ this .vertexArray .fill (1);
398
+
399
+ this .testWireframe = false;
400
+ this .primitiveMode = gl .POINTS;
401
+ this .texCoordCount = 0;
402
+ this .vertexCount = 1;
403
+
404
+ this .geometryContext .geometryType = 0;
405
+ break;
406
+ }
407
+ case LINE:
408
+ {
409
+ this .idArray = new Float32Array (2 * maxParticles);
410
+ this .positionArray = new Float32Array (2 * 3 * maxParticles);
411
+ this .elapsedTimeArray = new Float32Array (2 * maxParticles);
412
+ this .lifeArray = new Float32Array (2 * maxParticles);
413
+ this .colorArray = new Float32Array (2 * 4 * maxParticles);
414
+ this .texCoordArray = new Float32Array ();
415
+ this .normalArray = new Float32Array ();
416
+ this .vertexArray = new Float32Array (2 * 4 * maxParticles);
417
+
418
+ for (var i = 0, a = this .idArray, l = a .length; i < l; ++ i)
419
+ a [i] = Math .floor (i / 2);
420
+
421
+ this .colorArray .fill (1);
422
+ this .vertexArray .fill (1);
423
+
424
+ this .testWireframe = false;
425
+ this .primitiveMode = gl .LINES;
426
+ this .texCoordCount = 2;
427
+ this .vertexCount = 2;
428
+
429
+ this .geometryContext .geometryType = 1;
430
+ break;
431
+ }
432
+ case TRIANGLE:
433
+ case QUAD:
434
+ case SPRITE:
435
+ {
436
+ this .idArray = new Float32Array (6 * maxParticles);
437
+ this .positionArray = new Float32Array (6 * 3 * maxParticles);
438
+ this .elapsedTimeArray = new Float32Array (6 * maxParticles);
439
+ this .lifeArray = new Float32Array (6 * maxParticles);
440
+ this .colorArray = new Float32Array (6 * 4 * maxParticles);
441
+ this .texCoordArray = new Float32Array (6 * 4 * maxParticles);
442
+ this .normalArray = new Float32Array (6 * 3 * maxParticles);
443
+ this .vertexArray = new Float32Array (6 * 4 * maxParticles);
444
+
445
+ for (var i = 0, a = this .idArray, l = a .length; i < l; ++ i)
446
+ a [i] = Math .floor (i / 6);
447
+
448
+ this .colorArray .fill (1);
449
+ this .vertexArray .fill (1);
450
+
451
+ var
452
+ texCoordArray = this .texCoordArray,
453
+ normalArray = this .normalArray;
454
+
455
+ for (var i = 0, length = 6 * 3 * maxParticles; i < length; i += 3)
456
+ {
457
+ normalArray [i] = 0;
458
+ normalArray [i + 1] = 0;
459
+ normalArray [i + 2] = 1;
460
+ }
461
+
462
+ gl .bindBuffer (gl .ARRAY_BUFFER, this .normalBuffer);
463
+ gl .bufferData (gl .ARRAY_BUFFER, this .normalArray, gl .STATIC_DRAW);
464
+
465
+ for (var i = 0; i < maxParticles; ++ i)
466
+ {
467
+ var i24 = i * 24;
468
+
469
+ // p4 ------ p3
470
+ // | / |
471
+ // | / |
472
+ // | / |
473
+ // | / |
474
+ // p1 ------ p2
475
+
476
+ // p1
477
+ texCoordArray [i24] = texCoordArray [i24 + 12] = 0;
478
+ texCoordArray [i24 + 1] = texCoordArray [i24 + 13] = 0;
479
+ texCoordArray [i24 + 2] = texCoordArray [i24 + 14] = 0;
480
+ texCoordArray [i24 + 3] = texCoordArray [i24 + 15] = 1;
481
+
482
+ // p2
483
+ texCoordArray [i24 + 4] = 1;
484
+ texCoordArray [i24 + 5] = 0;
485
+ texCoordArray [i24 + 6] = 0;
486
+ texCoordArray [i24 + 7] = 1;
487
+
488
+ // p3
489
+ texCoordArray [i24 + 8] = texCoordArray [i24 + 16] = 1;
490
+ texCoordArray [i24 + 9] = texCoordArray [i24 + 17] = 1;
491
+ texCoordArray [i24 + 10] = texCoordArray [i24 + 18] = 0;
492
+ texCoordArray [i24 + 11] = texCoordArray [i24 + 19] = 1;
493
+
494
+ // p4
495
+ texCoordArray [i24 + 20] = 0;
496
+ texCoordArray [i24 + 21] = 1;
497
+ texCoordArray [i24 + 22] = 0;
498
+ texCoordArray [i24 + 23] = 1;
499
+ }
500
+
501
+ gl .bindBuffer (gl .ARRAY_BUFFER, this .texCoordBuffers [0]);
502
+ gl .bufferData (gl .ARRAY_BUFFER, this .texCoordArray, gl .STATIC_DRAW);
503
+
504
+ this .testWireframe = true;
505
+ this .primitiveMode = gl .TRIANGLES;
506
+ this .texCoordCount = 4;
507
+ this .vertexCount = 6;
508
+
509
+ this .geometryContext .geometryType = 2;
510
+ break;
511
+ }
512
+ case GEOMETRY:
513
+ {
514
+ this .texCoordCount = 0;
515
+ this .vertexCount = 0;
516
+ break;
517
+ }
518
+ }
519
+
520
+ gl .bindBuffer (gl .ARRAY_BUFFER, this .idBuffer);
521
+ gl .bufferData (gl .ARRAY_BUFFER, this .idArray, gl .STATIC_DRAW);
522
+
523
+ this .set_shader__ ();
524
+ this .set_transparent__ ();
525
+ },
526
+ set_shader__: function ()
527
+ {
528
+ switch (this .geometryType)
529
+ {
530
+ case POINT:
531
+ {
532
+ this .shaderNode = this .getBrowser () .getPointShader ();
533
+ break;
534
+ }
535
+ case LINE:
536
+ {
537
+ this .shaderNode = this .getBrowser () .getLineShader ();
538
+ break;
539
+ }
540
+ case TRIANGLE:
541
+ case QUAD:
542
+ case SPRITE:
543
+ case GEOMETRY:
544
+ {
545
+ this .shaderNode = null;
546
+ break;
547
+ }
548
+ }
549
+ },
550
+ set_maxParticles__: function ()
551
+ {
552
+ var
553
+ particles = this .particles,
554
+ maxParticles = Math .max (0, this ._maxParticles .getValue ());
555
+
556
+ for (var i = this .numParticles, length = Math .min (particles .length, maxParticles); i < length; ++ i)
557
+ {
558
+ particles [i] .life = 1;
559
+ particles [i] .lifetime = -1;
560
+ }
561
+
562
+ for (var i = particles .length, length = maxParticles; i < length; ++ i)
563
+ {
564
+ particles [i] = {
565
+ id: i,
566
+ life: 1,
567
+ lifetime: -1,
568
+ elapsedTime: 0,
569
+ position: new Vector3 (0, 0, 0),
570
+ velocity: new Vector3 (0, 0, 0),
571
+ color: new Vector4 (1, 1, 1, 1),
572
+ distance: 0,
573
+ };
574
+ }
575
+
576
+ this .maxParticles = maxParticles;
577
+ this .numParticles = Math .min (this .numParticles, maxParticles);
578
+
579
+ if (! this .emitterNode .isExplosive ())
580
+ this .creationTime = performance .now () / 1000;
581
+
582
+ this .set_geometryType__ ();
583
+ },
584
+ set_particleLifetime__: function ()
585
+ {
586
+ this .particleLifetime = this ._particleLifetime .getValue ();
587
+ },
588
+ set_lifetimeVariation__: function ()
589
+ {
590
+ this .lifetimeVariation = this ._lifetimeVariation .getValue ();
591
+ },
592
+ set_emitter__: function ()
593
+ {
594
+ this .emitterNode = X3DCast (X3DConstants .X3DParticleEmitterNode, this ._emitter);
595
+
596
+ if (! this .emitterNode)
597
+ this .emitterNode = this .getBrowser () .getDefaultEmitter ();
598
+
599
+ this .createParticles = this ._createParticles .getValue ();
600
+ },
601
+ set_physics__: function ()
602
+ {
603
+ var
604
+ physics = this ._physics .getValue (),
605
+ forcePhysicsModelNodes = this .forcePhysicsModelNodes,
606
+ boundedPhysicsModelNodes = this .boundedPhysicsModelNodes;
607
+
608
+ for (var i = 0, length = boundedPhysicsModelNodes .length; i < length; ++ i)
609
+ boundedPhysicsModelNodes [i] .removeInterest ("set_boundedPhysics__", this);
610
+
611
+ forcePhysicsModelNodes .length = 0;
612
+ boundedPhysicsModelNodes .length = 0;
613
+
614
+ for (var i = 0, length = physics .length; i < length; ++ i)
615
+ {
616
+ try
617
+ {
618
+ var
619
+ innerNode = physics [i] .getValue () .getInnerNode (),
620
+ type = innerNode .getType ();
621
+
622
+ for (var t = type .length - 1; t >= 0; -- t)
623
+ {
624
+ switch (type [t])
625
+ {
626
+ case X3DConstants .ForcePhysicsModel:
627
+ case X3DConstants .WindPhysicsModel:
628
+ {
629
+ forcePhysicsModelNodes .push (innerNode);
630
+ break;
631
+ }
632
+ case X3DConstants .BoundedPhysicsModel:
633
+ {
634
+ innerNode .addInterest ("set_boundedPhysics__", this);
635
+ boundedPhysicsModelNodes .push (innerNode);
636
+ break;
637
+ }
638
+ default:
639
+ continue;
640
+ }
641
+
642
+ break;
643
+ }
644
+ }
645
+ catch (error)
646
+ { }
647
+ }
648
+
649
+ this .set_boundedPhysics__ ();
650
+ },
651
+ set_boundedPhysics__: function ()
652
+ {
653
+ var
654
+ boundedPhysicsModelNodes = this .boundedPhysicsModelNodes,
655
+ boundedNormals = this .boundedNormals,
656
+ boundedVertices = this .boundedVertices;
657
+
658
+ boundedNormals .length = 0;
659
+ boundedVertices .length = 0;
660
+
661
+ for (var i = 0, length = boundedPhysicsModelNodes .length; i < length; ++ i)
662
+ {
663
+ boundedPhysicsModelNodes [i] .addGeometry (boundedNormals, boundedVertices);
664
+ }
665
+
666
+ this .boundedVolume = new BVH (boundedVertices, boundedNormals);
667
+ },
668
+ set_colorRamp__: function ()
669
+ {
670
+ if (this .colorRampNode)
671
+ this .colorRampNode .removeInterest ("set_color__", this);
672
+
673
+ this .colorRampNode = X3DCast (X3DConstants .X3DColorNode, this ._colorRamp);
674
+
675
+ if (this .colorRampNode)
676
+ this .colorRampNode .addInterest ("set_color__", this);
677
+
678
+ this .set_color__ ();
679
+ this .set_transparent__ ();
680
+ },
681
+ set_color__: function ()
682
+ {
683
+ var
684
+ colorKey = this ._colorKey,
685
+ colorKeys = this .colorKeys,
686
+ colorRamp = this .colorRamp;
687
+
688
+ for (var i = 0, length = colorKey .length; i < length; ++ i)
689
+ colorKeys [i] = colorKey [i];
690
+
691
+ colorKeys .length = length;
692
+
693
+ if (this .colorRampNode)
694
+ this .colorRampNode .getVectors (this .colorRamp);
695
+
696
+ for (var i = colorRamp .length, length = colorKey .length; i < length; ++ i)
697
+ colorRamp [i] = new Vector4 (1, 1, 1, 1);
698
+
699
+ colorRamp .length = length;
700
+
701
+ this .geometryContext .colorMaterial = !! (colorKeys .length && this .colorRampNode);
702
+ },
703
+ set_texCoordRamp__: function ()
704
+ {
705
+ if (this .texCoordRampNode)
706
+ this .texCoordRampNode .removeInterest ("set_texCoord__", this);
707
+
708
+ this .texCoordRampNode = X3DCast (X3DConstants .X3DTextureCoordinateNode, this ._texCoordRamp);
709
+
710
+ if (this .texCoordRampNode)
711
+ this .texCoordRampNode .addInterest ("set_texCoord__", this);
712
+
713
+ this .set_texCoord__ ();
714
+ },
715
+ set_texCoord__: function ()
716
+ {
717
+ var
718
+ texCoordKey = this ._texCoordKey,
719
+ texCoordKeys = this .texCoordKeys,
720
+ texCoordRamp = this .texCoordRamp;
721
+
722
+ for (var i = 0, length = texCoordKey .length; i < length; ++ i)
723
+ texCoordKeys [i] = texCoordKey [i];
724
+
725
+ texCoordKeys .length = length;
726
+
727
+ if (this .texCoordRampNode)
728
+ this .texCoordRampNode .getTexCoord (texCoordRamp);
729
+
730
+ for (var i = texCoordRamp .length, length = texCoordKey .length * this .texCoordCount; i < length; ++ i)
731
+ texCoordRamp [i] = new Vector4 (0, 0, 0, 0);
732
+
733
+ texCoordRamp .length = length;
734
+
735
+ this .texCoordAnim = !! (texCoordKeys .length && this .texCoordRampNode);
736
+ },
737
+ intersectsBox: function (box, clipPlanes)
738
+ {
739
+ // TODO: implement me.
740
+ },
741
+ animateParticles: function ()
742
+ {
743
+ var emitterNode = this .emitterNode;
744
+
745
+ // Determine delta time
746
+
747
+ var
748
+ DELAY = 15, // Delay in frames when dt full applys.
749
+ dt = 1 / Math .max (10, this .getBrowser () .getCurrentFrameRate ());
750
+
751
+ // var deltaTime is only for the emitter, this.deltaTime is for the forces.
752
+ var deltaTime = this .deltaTime = ((DELAY - 1) * this .deltaTime + dt) / DELAY; // Moving average about DELAY frames.
753
+
754
+ // Determine numParticles
755
+
756
+ if (emitterNode .isExplosive ())
757
+ {
758
+ var
759
+ now = performance .now () / 1000,
760
+ particleLifetime = this .particleLifetime + this .particleLifetime * this .lifetimeVariation;
761
+
762
+ if (this .numParticles === 0 || now - this .creationTime > particleLifetime)
763
+ {
764
+ this .creationTime = now;
765
+ this .numParticles = this .maxParticles;
766
+ this .createParticles = this ._createParticles .getValue ();
767
+
768
+ deltaTime = Number .POSITIVE_INFINITY;
769
+ }
770
+ else
771
+ this .createParticles = false;
772
+ }
773
+ else
774
+ {
775
+ if (this .numParticles < this .maxParticles)
776
+ {
777
+ var
778
+ now = performance .now () / 1000,
779
+ newParticles = Math .max (0, Math .floor ((now - this .creationTime) * this .maxParticles / this .particleLifetime));
780
+
781
+ if (newParticles)
782
+ this .creationTime = now;
783
+
784
+ this .numParticles = Math .floor (Math .min (this .maxParticles, this .numParticles + newParticles));
785
+ }
786
+ }
787
+
788
+ // Apply forces.
789
+
790
+ if (emitterNode .getMass ())
791
+ {
792
+ var
793
+ forcePhysicsModelNodes = this .forcePhysicsModelNodes,
794
+ velocities = this .velocities,
795
+ speeds = this .speeds,
796
+ turbulences = this .turbulences,
797
+ deltaMass = this .deltaTime / emitterNode .getMass ();
798
+
799
+ // Collect forces in velocities and collect turbulences.
800
+
801
+ for (var i = velocities .length, length = forcePhysicsModelNodes .length; i < length; ++ i)
802
+ velocities [i] = new Vector3 (0, 0, 0);
803
+
804
+ for (var i = 0, length = forcePhysicsModelNodes .length; i < length; ++ i)
805
+ forcePhysicsModelNodes [i] .addForce (i, emitterNode, velocities, turbulences);
806
+
807
+ // Determine velocities from forces and determine speed.
808
+
809
+ for (var i = 0, length = velocities .length; i < length; ++ i)
810
+ {
811
+ velocities [i] .multiply (deltaMass);
812
+ speeds [i] = velocities [i] .abs ();
813
+ }
814
+
815
+ this .numForces = length;
816
+ }
817
+ else
818
+ {
819
+ this .numForces = 0;
820
+ }
821
+
822
+ // Determine particle position, velocity and colors
823
+
824
+ emitterNode .animate (this, deltaTime);
825
+
826
+ this .updateGeometry (null);
827
+
828
+ this .getBrowser () .addBrowserEvent ();
829
+ },
830
+ updateGeometry: function (modelViewMatrix)
831
+ {
832
+ switch (this .geometryType)
833
+ {
834
+ case POINT:
835
+ if (! modelViewMatrix)
836
+ this .updatePoint ();
837
+ break;
838
+ case LINE:
839
+ if (! modelViewMatrix)
840
+ this .updateLine ();
841
+ break;
842
+ case TRIANGLE:
843
+ case QUAD:
844
+ case SPRITE:
845
+ this .updateQuad (modelViewMatrix);
846
+ break;
847
+ case GEOMETRY:
848
+ break;
849
+ }
850
+ },
851
+ updatePoint: function ()
852
+ {
853
+ var
854
+ gl = this .getBrowser () .getContext (),
855
+ particles = this .particles,
856
+ numParticles = this .numParticles,
857
+ positionArray = this .positionArray,
858
+ elapsedTimeArray = this .elapsedTimeArray,
859
+ lifeArray = this .lifeArray,
860
+ colorArray = this .colorArray,
861
+ vertexArray = this .vertexArray;
862
+
863
+ // Colors
864
+
865
+ if (this .geometryContext .colorMaterial)
866
+ {
867
+ for (var i = 0; i < numParticles; ++ i)
868
+ {
869
+ var
870
+ color = particles [i] .color,
871
+ i4 = i * 4;
872
+
873
+ colorArray [i4] = color .x;
874
+ colorArray [i4 + 1] = color .y;
875
+ colorArray [i4 + 2] = color .z;
876
+ colorArray [i4 + 3] = color .w;
877
+ }
878
+
879
+ gl .bindBuffer (gl .ARRAY_BUFFER, this .colorBuffer);
880
+ gl .bufferData (gl .ARRAY_BUFFER, this .colorArray, gl .STATIC_DRAW);
881
+ }
882
+
883
+ // Vertices
884
+
885
+ for (var i = 0; i < numParticles; ++ i)
886
+ {
887
+ var
888
+ position = particles [i] .position,
889
+ elapsedTime = particles [i] .elapsedTime / particles [i] .lifetime,
890
+ i3 = i * 3,
891
+ i4 = i * 4;
892
+
893
+ positionArray [i3] = position .x;
894
+ positionArray [i3 + 1] = position .y;
895
+ positionArray [i3 + 2] = position .z;
896
+
897
+ elapsedTimeArray [i] = elapsedTime;
898
+ lifeArray [i] = particles [i] .life;
899
+
900
+ vertexArray [i4] = position .x;
901
+ vertexArray [i4 + 1] = position .y;
902
+ vertexArray [i4 + 2] = position .z;
903
+ }
904
+
905
+ gl .bindBuffer (gl .ARRAY_BUFFER, this .positionBuffer);
906
+ gl .bufferData (gl .ARRAY_BUFFER, this .positionArray, gl .STATIC_DRAW);
907
+ gl .bindBuffer (gl .ARRAY_BUFFER, this .elapsedTimeBuffer);
908
+ gl .bufferData (gl .ARRAY_BUFFER, this .elapsedTimeArray, gl .STATIC_DRAW);
909
+ gl .bindBuffer (gl .ARRAY_BUFFER, this .lifeBuffer);
910
+ gl .bufferData (gl .ARRAY_BUFFER, this .lifeArray, gl .STATIC_DRAW);
911
+ gl .bindBuffer (gl .ARRAY_BUFFER, this .vertexBuffer);
912
+ gl .bufferData (gl .ARRAY_BUFFER, this .vertexArray, gl .STATIC_DRAW);
913
+ },
914
+ updateLine: function ()
915
+ {
916
+ var
917
+ gl = this .getBrowser () .getContext (),
918
+ particles = this .particles,
919
+ numParticles = this .numParticles,
920
+ positionArray = this .positionArray,
921
+ elapsedTimeArray = this .elapsedTimeArray,
922
+ lifeArray = this .lifeArray,
923
+ colorArray = this .colorArray,
924
+ vertexArray = this .vertexArray,
925
+ sy1_2 = this ._particleSize .y / 2;
926
+
927
+ // Colors
928
+
929
+ if (this .geometryContext .colorMaterial)
930
+ {
931
+ for (var i = 0; i < numParticles; ++ i)
932
+ {
933
+ var
934
+ color = particles [i] .color,
935
+ i8 = i * 8;
936
+
937
+ colorArray [i8] = color .x;
938
+ colorArray [i8 + 1] = color .y;
939
+ colorArray [i8 + 2] = color .z;
940
+ colorArray [i8 + 3] = color .w;
941
+
942
+ colorArray [i8 + 4] = color .x;
943
+ colorArray [i8 + 5] = color .y;
944
+ colorArray [i8 + 6] = color .z;
945
+ colorArray [i8 + 7] = color .w;
946
+ }
947
+
948
+ gl .bindBuffer (gl .ARRAY_BUFFER, this .colorBuffer);
949
+ gl .bufferData (gl .ARRAY_BUFFER, this .colorArray, gl .STATIC_DRAW);
950
+ }
951
+
952
+ // Vertices
953
+
954
+ for (var i = 0; i < numParticles; ++ i)
955
+ {
956
+ var
957
+ particle = particles [i],
958
+ position = particle .position,
959
+ elapsedTime = particles [i] .elapsedTime / particles [i] .lifetime,
960
+ life = particles [i] .life,
961
+ x = position .x,
962
+ y = position .y,
963
+ z = position .z,
964
+ i2 = i * 2,
965
+ i6 = i * 6,
966
+ i8 = i * 8;
967
+
968
+ positionArray [i6] = x;
969
+ positionArray [i6 + 1] = y;
970
+ positionArray [i6 + 2] = z;
971
+ positionArray [i6 + 3] = x;
972
+ positionArray [i6 + 4] = y;
973
+ positionArray [i6 + 5] = z;
974
+
975
+ elapsedTimeArray [i2] = elapsedTime;
976
+ elapsedTimeArray [i2 + 1] = elapsedTime;
977
+
978
+ lifeArray [i2] = life;
979
+ lifeArray [i2 + 1] = life;
980
+
981
+ // Length of line / 2.
982
+ normal .assign (particle .velocity) .normalize () .multiply (sy1_2);
983
+
984
+ vertexArray [i8] = x - normal .x;
985
+ vertexArray [i8 + 1] = y - normal .y;
986
+ vertexArray [i8 + 2] = z - normal .z;
987
+
988
+ vertexArray [i8 + 4] = x + normal .x;
989
+ vertexArray [i8 + 5] = y + normal .y;
990
+ vertexArray [i8 + 6] = z + normal .z;
991
+ }
992
+
993
+ gl .bindBuffer (gl .ARRAY_BUFFER, this .positionBuffer);
994
+ gl .bufferData (gl .ARRAY_BUFFER, this .positionArray, gl .STATIC_DRAW);
995
+ gl .bindBuffer (gl .ARRAY_BUFFER, this .elapsedTimeBuffer);
996
+ gl .bufferData (gl .ARRAY_BUFFER, this .elapsedTimeArray, gl .STATIC_DRAW);
997
+ gl .bindBuffer (gl .ARRAY_BUFFER, this .lifeBuffer);
998
+ gl .bufferData (gl .ARRAY_BUFFER, this .lifeArray, gl .STATIC_DRAW);
999
+ gl .bindBuffer (gl .ARRAY_BUFFER, this .vertexBuffer);
1000
+ gl .bufferData (gl .ARRAY_BUFFER, this .vertexArray, gl .STATIC_DRAW);
1001
+ },
1002
+ updateQuad: function (modelViewMatrix)
1003
+ {
1004
+ try
1005
+ {
1006
+ var
1007
+ gl = this .getBrowser () .getContext (),
1008
+ particles = this .particles,
1009
+ maxParticles = this .maxParticles,
1010
+ numParticles = this .numParticles,
1011
+ positionArray = this .positionArray,
1012
+ elapsedTimeArray = this .elapsedTimeArray,
1013
+ lifeArray = this .lifeArray,
1014
+ colorArray = this .colorArray,
1015
+ texCoordArray = this .texCoordArray,
1016
+ normalArray = this .normalArray,
1017
+ vertexArray = this .vertexArray,
1018
+ sx1_2 = this ._particleSize .x / 2,
1019
+ sy1_2 = this ._particleSize .y / 2;
1020
+
1021
+ // Sort particles
1021
1022
 
1022
1023
  // if (this .sortParticles) // always false
1023
1024
  // {
@@ -1031,489 +1032,488 @@ function (Fields,
1031
1032
  // this .particleSorter .sort (0, numParticles);
1032
1033
  // }
1033
1034
 
1034
- // Colors
1035
-
1036
- if (! modelViewMatrix) // if called from animateParticles
1037
- {
1038
- if (this .geometryContext .colorMaterial)
1039
- {
1040
- for (var i = 0; i < maxParticles; ++ i)
1041
- {
1042
- var
1043
- color = particles [i] .color,
1044
- i24 = i * 24;
1045
-
1046
- // p4 ------ p3
1047
- // | / |
1048
- // | / |
1049
- // | / |
1050
- // | / |
1051
- // p1 ------ p2
1052
-
1053
- // p1, p2, p3; p1, p3, p4
1054
- colorArray [i24] = colorArray [i24 + 4] = colorArray [i24 + 8] = colorArray [i24 + 12] = colorArray [i24 + 16] = colorArray [i24 + 20] = color .x;
1055
- colorArray [i24 + 1] = colorArray [i24 + 5] = colorArray [i24 + 9] = colorArray [i24 + 13] = colorArray [i24 + 17] = colorArray [i24 + 21] = color .y;
1056
- colorArray [i24 + 2] = colorArray [i24 + 6] = colorArray [i24 + 10] = colorArray [i24 + 14] = colorArray [i24 + 18] = colorArray [i24 + 22] = color .z;
1057
- colorArray [i24 + 3] = colorArray [i24 + 7] = colorArray [i24 + 11] = colorArray [i24 + 15] = colorArray [i24 + 19] = colorArray [i24 + 23] = color .w;
1058
- }
1059
-
1060
- gl .bindBuffer (gl .ARRAY_BUFFER, this .colorBuffer);
1061
- gl .bufferData (gl .ARRAY_BUFFER, this .colorArray, gl .STATIC_DRAW);
1062
- }
1063
-
1064
- if (this .texCoordAnim && this .texCoordArray .length)
1065
- {
1066
- var
1067
- texCoordKeys = this .texCoordKeys,
1068
- texCoordRamp = this .texCoordRamp;
1069
-
1070
- var
1071
- length = texCoordKeys .length,
1072
- index0 = 0;
1073
-
1074
- for (var i = 0; i < maxParticles; ++ i)
1075
- {
1076
- // Determine index0.
1077
-
1078
- var
1079
- particle = particles [i],
1080
- fraction = particle .elapsedTime / particle .lifetime;
1081
-
1082
- if (length == 1 || fraction <= texCoordKeys [0])
1083
- {
1084
- index0 = 0;
1085
- }
1086
- else if (fraction >= texCoordKeys .at (-1))
1087
- {
1088
- index0 = length - 2;
1089
- }
1090
- else
1091
- {
1092
- var index = Algorithm .upperBound (texCoordKeys, 0, length, fraction, Algorithm .less);
1093
-
1094
- if (index < length)
1095
- index0 = index - 1;
1096
- else
1097
- index0 = 0;
1098
- }
1099
-
1100
- // Set texCoord.
1101
-
1102
- index0 *= this .texCoordCount;
1103
-
1104
- var
1105
- texCoord1 = texCoordRamp [index0],
1106
- texCoord2 = texCoordRamp [index0 + 1],
1107
- texCoord3 = texCoordRamp [index0 + 2],
1108
- texCoord4 = texCoordRamp [index0 + 3],
1109
- i24 = i * 24;
1110
-
1111
- // p4 ------ p3
1112
- // | / |
1113
- // | / |
1114
- // | / |
1115
- // | / |
1116
- // p1 ------ p2
1117
-
1118
- // p1
1119
- texCoordArray [i24] = texCoordArray [i24 + 12] = texCoord1 .x;
1120
- texCoordArray [i24 + 1] = texCoordArray [i24 + 13] = texCoord1 .y;
1121
- texCoordArray [i24 + 2] = texCoordArray [i24 + 14] = texCoord1 .z;
1122
- texCoordArray [i24 + 3] = texCoordArray [i24 + 15] = texCoord1 .w;
1123
-
1124
- // p2
1125
- texCoordArray [i24 + 4] = texCoord2 .x;
1126
- texCoordArray [i24 + 5] = texCoord2 .y;
1127
- texCoordArray [i24 + 6] = texCoord2 .z;
1128
- texCoordArray [i24 + 7] = texCoord2 .w;
1129
-
1130
- // p3
1131
- texCoordArray [i24 + 8] = texCoordArray [i24 + 16] = texCoord3 .x;
1132
- texCoordArray [i24 + 9] = texCoordArray [i24 + 17] = texCoord3 .y;
1133
- texCoordArray [i24 + 10] = texCoordArray [i24 + 18] = texCoord3 .z;
1134
- texCoordArray [i24 + 11] = texCoordArray [i24 + 19] = texCoord3 .w;
1135
-
1136
- // p4
1137
- texCoordArray [i24 + 20] = texCoord4 .x;
1138
- texCoordArray [i24 + 21] = texCoord4 .y;
1139
- texCoordArray [i24 + 22] = texCoord4 .z;
1140
- texCoordArray [i24 + 23] = texCoord4 .w;
1141
- }
1142
-
1143
- gl .bindBuffer (gl .ARRAY_BUFFER, this .texCoordBuffers [0]);
1144
- gl .bufferData (gl .ARRAY_BUFFER, this .texCoordArray, gl .STATIC_DRAW);
1145
- }
1146
- }
1147
-
1148
- // Vertices
1149
-
1150
- if (this .geometryType === SPRITE)
1151
- {
1152
- if (modelViewMatrix) // if called from depth or draw
1153
- {
1154
- // Normals
1155
-
1156
- var rotation = this .getScreenAlignedRotation (modelViewMatrix);
1157
-
1158
- normal
1159
- .set (rotation [0], rotation [1], rotation [2])
1160
- .cross (vector .set (rotation [3], rotation [4], rotation [5]))
1161
- .normalize ();
1162
-
1163
- var
1164
- nx = normal .x,
1165
- ny = normal .y,
1166
- nz = normal .z;
1167
-
1168
- for (var i = 0, length = 6 * 3 * maxParticles; i < length; i += 3)
1169
- {
1170
- normalArray [i] = nx;
1171
- normalArray [i + 1] = ny;
1172
- normalArray [i + 2] = nz;
1173
- }
1174
-
1175
- gl .bindBuffer (gl .ARRAY_BUFFER, this .normalBuffer);
1176
- gl .bufferData (gl .ARRAY_BUFFER, this .normalArray, gl .STATIC_DRAW);
1177
-
1178
- // Vertices
1179
-
1180
- s1 .set (-sx1_2, -sy1_2, 0);
1181
- s2 .set ( sx1_2, -sy1_2, 0);
1182
- s3 .set ( sx1_2, sy1_2, 0);
1183
- s4 .set (-sx1_2, sy1_2, 0);
1184
-
1185
- rotation .multVecMatrix (s1);
1186
- rotation .multVecMatrix (s2);
1187
- rotation .multVecMatrix (s3);
1188
- rotation .multVecMatrix (s4);
1189
-
1190
- for (var i = 0; i < numParticles; ++ i)
1191
- {
1192
- var
1193
- position = particles [i] .position,
1194
- elapsedTime = particles [i] .elapsedTime / particles [i] .lifetime,
1195
- x = position .x,
1196
- y = position .y,
1197
- z = position .z,
1198
- i6 = i * 6,
1199
- i18 = i * 18,
1200
- i24 = i * 24;
1201
-
1202
- // p4 ------ p3
1203
- // | / |
1204
- // | / |
1205
- // | / |
1206
- // | / |
1207
- // p1 ------ p2
1208
-
1209
-
1210
- positionArray [i18] = positionArray [i18 + 3] = positionArray [i18 + 6] = positionArray [i18 + 9] = positionArray [i18 + 12] = positionArray [i18 + 15] = x;
1211
- positionArray [i18 + 1] = positionArray [i18 + 4] = positionArray [i18 + 7] = positionArray [i18 + 10] = positionArray [i18 + 13] = positionArray [i18 + 16] = y;
1212
- positionArray [i18 + 2] = positionArray [i18 + 5] = positionArray [i18 + 8] = positionArray [i18 + 11] = positionArray [i18 + 14] = positionArray [i18 + 17] = z;
1213
-
1214
- elapsedTimeArray [i6] = elapsedTimeArray [i6 + 1] = elapsedTimeArray [i6 + 2] = elapsedTimeArray [i6 + 3] = elapsedTimeArray [i6 + 4] = elapsedTimeArray [i6 + 5] = elapsedTime;
1215
- lifeArray [i6] = lifeArray [i6 + 1] = lifeArray [i6 + 2] = lifeArray [i6 + 3] = lifeArray [i6 + 4] = lifeArray [i6 + 5] = particles [i] .life;
1216
-
1217
- // p1
1218
- vertexArray [i24] = vertexArray [i24 + 12] = x + s1 .x;
1219
- vertexArray [i24 + 1] = vertexArray [i24 + 13] = y + s1 .y;
1220
- vertexArray [i24 + 2] = vertexArray [i24 + 14] = z + s1 .z;
1221
-
1222
- // p2
1223
- vertexArray [i24 + 4] = x + s2 .x;
1224
- vertexArray [i24 + 5] = y + s2 .y;
1225
- vertexArray [i24 + 6] = z + s2 .z;
1226
-
1227
- // p3
1228
- vertexArray [i24 + 8] = vertexArray [i24 + 16] = x + s3 .x;
1229
- vertexArray [i24 + 9] = vertexArray [i24 + 17] = y + s3 .y;
1230
- vertexArray [i24 + 10] = vertexArray [i24 + 18] = z + s3 .z;
1231
-
1232
- // p4
1233
- vertexArray [i24 + 20] = x + s4 .x;
1234
- vertexArray [i24 + 21] = y + s4 .y;
1235
- vertexArray [i24 + 22] = z + s4 .z;
1236
- }
1237
-
1238
- gl .bindBuffer (gl .ARRAY_BUFFER, this .positionBuffer);
1239
- gl .bufferData (gl .ARRAY_BUFFER, this .positionArray, gl .STATIC_DRAW);
1240
- gl .bindBuffer (gl .ARRAY_BUFFER, this .elapsedTimeBuffer);
1241
- gl .bufferData (gl .ARRAY_BUFFER, this .elapsedTimeArray, gl .STATIC_DRAW);
1242
- gl .bindBuffer (gl .ARRAY_BUFFER, this .lifeBuffer);
1243
- gl .bufferData (gl .ARRAY_BUFFER, this .lifeArray, gl .STATIC_DRAW);
1244
- gl .bindBuffer (gl .ARRAY_BUFFER, this .vertexBuffer);
1245
- gl .bufferData (gl .ARRAY_BUFFER, this .vertexArray, gl .STATIC_DRAW);
1246
- }
1247
- }
1248
- else
1249
- {
1250
- if (! modelViewMatrix) // if called from animateParticles
1251
- {
1252
- for (var i = 0; i < numParticles; ++ i)
1253
- {
1254
- var
1255
- position = particles [i] .position,
1256
- elapsedTime = particles [i] .elapsedTime / particles [i] .lifetime,
1257
- x = position .x,
1258
- y = position .y,
1259
- z = position .z,
1260
- i6 = i * 6,
1261
- i18 = i * 18,
1262
- i24 = i * 24;
1263
-
1264
- // p4 ------ p3
1265
- // | / |
1266
- // | / |
1267
- // | / |
1268
- // | / |
1269
- // p1 ------ p2
1270
-
1271
- positionArray [i18] = positionArray [i18 + 3] = positionArray [i18 + 6] = positionArray [i18 + 9] = positionArray [i18 + 12] = positionArray [i18 + 15] = x;
1272
- positionArray [i18 + 1] = positionArray [i18 + 4] = positionArray [i18 + 7] = positionArray [i18 + 10] = positionArray [i18 + 13] = positionArray [i18 + 16] = y;
1273
- positionArray [i18 + 2] = positionArray [i18 + 5] = positionArray [i18 + 8] = positionArray [i18 + 11] = positionArray [i18 + 14] = positionArray [i18 + 17] = z;
1274
-
1275
- elapsedTimeArray [i6] = elapsedTimeArray [i6 + 1] = elapsedTimeArray [i6 + 2] = elapsedTimeArray [i6 + 3] = elapsedTimeArray [i6 + 4] = elapsedTimeArray [i6 + 5] = elapsedTime;
1276
- lifeArray [i6] = lifeArray [i6 + 1] = lifeArray [i6 + 2] = lifeArray [i6 + 3] = lifeArray [i6 + 4] = lifeArray [i6 + 5] = particles [i] .life;
1277
-
1278
- // p1
1279
- vertexArray [i24] = vertexArray [i24 + 12] = x - sx1_2;
1280
- vertexArray [i24 + 1] = vertexArray [i24 + 13] = y - sy1_2;
1281
- vertexArray [i24 + 2] = vertexArray [i24 + 14] = z;
1282
-
1283
- // p2
1284
- vertexArray [i24 + 4] = x + sx1_2;
1285
- vertexArray [i24 + 5] = y - sy1_2;
1286
- vertexArray [i24 + 6] = z;
1287
-
1288
- // p3
1289
- vertexArray [i24 + 8] = vertexArray [i24 + 16] = x + sx1_2;
1290
- vertexArray [i24 + 9] = vertexArray [i24 + 17] = y + sy1_2;
1291
- vertexArray [i24 + 10] = vertexArray [i24 + 18] = z;
1292
-
1293
- // p4
1294
- vertexArray [i24 + 20] = x - sx1_2;
1295
- vertexArray [i24 + 21] = y + sy1_2;
1296
- vertexArray [i24 + 22] = z;
1297
- }
1298
-
1299
- gl .bindBuffer (gl .ARRAY_BUFFER, this .positionBuffer);
1300
- gl .bufferData (gl .ARRAY_BUFFER, this .positionArray, gl .STATIC_DRAW);
1301
- gl .bindBuffer (gl .ARRAY_BUFFER, this .elapsedTimeBuffer);
1302
- gl .bufferData (gl .ARRAY_BUFFER, this .elapsedTimeArray, gl .STATIC_DRAW);
1303
- gl .bindBuffer (gl .ARRAY_BUFFER, this .lifeBuffer);
1304
- gl .bufferData (gl .ARRAY_BUFFER, this .lifeArray, gl .STATIC_DRAW);
1305
- gl .bindBuffer (gl .ARRAY_BUFFER, this .vertexBuffer);
1306
- gl .bufferData (gl .ARRAY_BUFFER, this .vertexArray, gl .STATIC_DRAW);
1307
- }
1308
- }
1309
- }
1310
- catch (error)
1311
- {
1312
- console .log (error);
1313
- }
1314
- },
1315
- traverse: function (type, renderObject)
1316
- {
1317
- if (! this .isActive_ .getValue ())
1318
- return;
1319
-
1320
- switch (type)
1321
- {
1322
- case TraverseType .POINTER:
1323
- {
1324
- break;
1325
- }
1326
- case TraverseType .PICKING:
1327
- {
1328
- break;
1329
- }
1330
- case TraverseType .COLLISION:
1331
- {
1332
- // TODO: to be implemented.
1333
- break;
1334
- }
1335
- case TraverseType .SHADOW:
1336
- {
1337
- if (this .castShadow_ .getValue ())
1338
- renderObject .addDepthShape (this);
1339
-
1340
- break;
1341
- }
1342
- case TraverseType .DISPLAY:
1343
- {
1344
- if (renderObject .addDisplayShape (this))
1345
- this .getAppearance () .traverse (type, renderObject); // Currently used for GeneratedCubeMapTexture.
1346
-
1347
- break;
1348
- }
1349
- }
1350
-
1351
- if (this .geometryType === GEOMETRY)
1352
- {
1353
- if (this .getGeometry ())
1354
- this .getGeometry () .traverse (type, renderObject); // Currently used for ScreenText.
1355
- }
1356
- },
1357
- depth: function (gl, context, shaderNode)
1358
- {
1359
- // Update geometry if SPRITE.
1360
-
1361
- this .updateGeometry (context .modelViewMatrix);
1362
-
1363
- // Display geometry.
1364
-
1365
- if (this .geometryType === GEOMETRY)
1366
- {
1367
- var geometryNode = this .getGeometry ();
1368
-
1369
- if (geometryNode)
1370
- geometryNode .displayParticlesDepth (gl, context, shaderNode, this .particles, this .numParticles);
1371
- }
1372
- else
1373
- {
1374
- if (this .numParticles <= 0)
1375
- return;
1376
-
1377
- if (shaderNode .getValid ())
1378
- {
1379
- // Setup vertex attributes.
1380
-
1381
- shaderNode .enableFloatAttrib (gl, "x3d_ParticleId", this .idBuffer, 1);
1382
- shaderNode .enableFloatAttrib (gl, "x3d_ParticlePosition", this .positionBuffer, 3);
1383
- shaderNode .enableFloatAttrib (gl, "x3d_ParticleElapsedTime", this .elapsedTimeBuffer, 1);
1384
- shaderNode .enableFloatAttrib (gl, "x3d_ParticleLife", this .lifeBuffer, 1);
1385
- shaderNode .enableVertexAttribute (gl, this .vertexBuffer);
1386
-
1387
- gl .drawArrays (this .primitiveMode, 0, this .numParticles * this .vertexCount);
1388
-
1389
- shaderNode .disableFloatAttrib (gl, "x3d_ParticleId");
1390
- shaderNode .disableFloatAttrib (gl, "x3d_ParticlePosition");
1391
- shaderNode .disableFloatAttrib (gl, "x3d_ParticleElapsedTime");
1392
- shaderNode .disableFloatAttrib (gl, "x3d_ParticleLife");
1393
- }
1394
- }
1395
- },
1396
- display: function (gl, context)
1397
- {
1398
- try
1399
- {
1400
- if (this .numParticles <= 0)
1401
- return;
1402
-
1403
- // Update geometry if SPRITE.
1404
-
1405
- this .updateGeometry (context .modelViewMatrix);
1406
-
1407
- // Display geometry.
1408
-
1409
- if (this .geometryType === GEOMETRY)
1410
- {
1411
- const geometryNode = this .getGeometry ();
1412
-
1413
- if (geometryNode)
1414
- geometryNode .displayParticles (gl, context, this .particles, this .numParticles);
1415
- }
1416
- else
1417
- {
1418
- const
1419
- appearanceNode = this .getAppearance (),
1420
- shaderNode = appearanceNode .shaderNode || this .shaderNode || appearanceNode .materialNode .getShader (context .browser, context .shadow);
1421
-
1422
- // Setup shader.
1423
-
1424
- if (shaderNode .getValid ())
1425
- {
1426
- context .geometryContext = this .geometryContext;
1427
-
1428
- const blendModeNode = appearanceNode .blendModeNode;
1429
-
1430
- if (blendModeNode)
1431
- blendModeNode .enable (gl);
1432
-
1433
- shaderNode .enable (gl);
1434
- shaderNode .setLocalUniforms (gl, context);
1435
-
1436
- // Setup vertex attributes.
1437
-
1438
- shaderNode .enableFloatAttrib (gl, "x3d_ParticleId", this .idBuffer, 1);
1439
- shaderNode .enableFloatAttrib (gl, "x3d_ParticlePosition", this .positionBuffer, 3);
1440
- shaderNode .enableFloatAttrib (gl, "x3d_ParticleElapsedTime", this .elapsedTimeBuffer, 1);
1441
- shaderNode .enableFloatAttrib (gl, "x3d_ParticleLife", this .lifeBuffer, 1);
1442
-
1443
- if (this .geometryContext .colorMaterial)
1444
- shaderNode .enableColorAttribute (gl, this .colorBuffer);
1445
-
1446
- if (this .texCoordArray .length)
1447
- shaderNode .enableTexCoordAttribute (gl, this .texCoordBuffers);
1448
-
1449
- if (this .normalArray .length)
1450
- shaderNode .enableNormalAttribute (gl, this .normalBuffer);
1451
-
1452
- shaderNode .enableVertexAttribute (gl, this .vertexBuffer);
1453
-
1454
- if (shaderNode .wireframe && this .testWireframe)
1455
- {
1456
- // Wireframes are always solid so only one drawing call is needed.
1457
-
1458
- for (var i = 0, length = this .numParticles * this .vertexCount; i < length; i += 3)
1459
- gl .drawArrays (shaderNode .primitiveMode, i, 3);
1460
- }
1461
- else
1462
- {
1463
- const positiveScale = Matrix4 .prototype .determinant3 .call (context .modelViewMatrix) > 0;
1464
-
1465
- gl .frontFace (positiveScale ? gl .CCW : gl .CW);
1466
- gl .enable (gl .CULL_FACE);
1467
- gl .cullFace (gl .BACK);
1468
-
1469
- gl .drawArrays (this .primitiveMode, 0, this .numParticles * this .vertexCount);
1470
- }
1471
-
1472
- shaderNode .disableFloatAttrib (gl, "x3d_ParticleId");
1473
- shaderNode .disableFloatAttrib (gl, "x3d_ParticlePosition");
1474
- shaderNode .disableFloatAttrib (gl, "x3d_ParticleElapsedTime");
1475
- shaderNode .disableFloatAttrib (gl, "x3d_ParticleLife");
1476
-
1477
- shaderNode .disableColorAttribute (gl);
1478
- shaderNode .disableTexCoordAttribute (gl);
1479
- shaderNode .disableNormalAttribute (gl);
1480
- shaderNode .disable (gl);
1481
-
1482
- if (blendModeNode)
1483
- blendModeNode .disable (gl);
1484
-
1485
- context .geometryContext = null;
1486
- }
1487
- }
1488
- }
1489
- catch (error)
1490
- {
1491
- // Catch error from setLocalUniforms.
1492
- console .log (error);
1493
- }
1494
- },
1495
- getScreenAlignedRotation: function (modelViewMatrix)
1496
- {
1497
- invModelViewMatrix .assign (modelViewMatrix) .inverse ();
1035
+ // Colors
1036
+
1037
+ if (! modelViewMatrix) // if called from animateParticles
1038
+ {
1039
+ if (this .geometryContext .colorMaterial)
1040
+ {
1041
+ for (var i = 0; i < maxParticles; ++ i)
1042
+ {
1043
+ var
1044
+ color = particles [i] .color,
1045
+ i24 = i * 24;
1046
+
1047
+ // p4 ------ p3
1048
+ // | / |
1049
+ // | / |
1050
+ // | / |
1051
+ // | / |
1052
+ // p1 ------ p2
1053
+
1054
+ // p1, p2, p3; p1, p3, p4
1055
+ colorArray [i24] = colorArray [i24 + 4] = colorArray [i24 + 8] = colorArray [i24 + 12] = colorArray [i24 + 16] = colorArray [i24 + 20] = color .x;
1056
+ colorArray [i24 + 1] = colorArray [i24 + 5] = colorArray [i24 + 9] = colorArray [i24 + 13] = colorArray [i24 + 17] = colorArray [i24 + 21] = color .y;
1057
+ colorArray [i24 + 2] = colorArray [i24 + 6] = colorArray [i24 + 10] = colorArray [i24 + 14] = colorArray [i24 + 18] = colorArray [i24 + 22] = color .z;
1058
+ colorArray [i24 + 3] = colorArray [i24 + 7] = colorArray [i24 + 11] = colorArray [i24 + 15] = colorArray [i24 + 19] = colorArray [i24 + 23] = color .w;
1059
+ }
1060
+
1061
+ gl .bindBuffer (gl .ARRAY_BUFFER, this .colorBuffer);
1062
+ gl .bufferData (gl .ARRAY_BUFFER, this .colorArray, gl .STATIC_DRAW);
1063
+ }
1064
+
1065
+ if (this .texCoordAnim && this .texCoordArray .length)
1066
+ {
1067
+ var
1068
+ texCoordKeys = this .texCoordKeys,
1069
+ texCoordRamp = this .texCoordRamp;
1070
+
1071
+ var
1072
+ length = texCoordKeys .length,
1073
+ index0 = 0;
1074
+
1075
+ for (var i = 0; i < maxParticles; ++ i)
1076
+ {
1077
+ // Determine index0.
1078
+
1079
+ var
1080
+ particle = particles [i],
1081
+ fraction = particle .elapsedTime / particle .lifetime;
1082
+
1083
+ if (length == 1 || fraction <= texCoordKeys [0])
1084
+ {
1085
+ index0 = 0;
1086
+ }
1087
+ else if (fraction >= texCoordKeys .at (-1))
1088
+ {
1089
+ index0 = length - 2;
1090
+ }
1091
+ else
1092
+ {
1093
+ var index = Algorithm .upperBound (texCoordKeys, 0, length, fraction, Algorithm .less);
1094
+
1095
+ if (index < length)
1096
+ index0 = index - 1;
1097
+ else
1098
+ index0 = 0;
1099
+ }
1100
+
1101
+ // Set texCoord.
1102
+
1103
+ index0 *= this .texCoordCount;
1104
+
1105
+ var
1106
+ texCoord1 = texCoordRamp [index0],
1107
+ texCoord2 = texCoordRamp [index0 + 1],
1108
+ texCoord3 = texCoordRamp [index0 + 2],
1109
+ texCoord4 = texCoordRamp [index0 + 3],
1110
+ i24 = i * 24;
1111
+
1112
+ // p4 ------ p3
1113
+ // | / |
1114
+ // | / |
1115
+ // | / |
1116
+ // | / |
1117
+ // p1 ------ p2
1118
+
1119
+ // p1
1120
+ texCoordArray [i24] = texCoordArray [i24 + 12] = texCoord1 .x;
1121
+ texCoordArray [i24 + 1] = texCoordArray [i24 + 13] = texCoord1 .y;
1122
+ texCoordArray [i24 + 2] = texCoordArray [i24 + 14] = texCoord1 .z;
1123
+ texCoordArray [i24 + 3] = texCoordArray [i24 + 15] = texCoord1 .w;
1124
+
1125
+ // p2
1126
+ texCoordArray [i24 + 4] = texCoord2 .x;
1127
+ texCoordArray [i24 + 5] = texCoord2 .y;
1128
+ texCoordArray [i24 + 6] = texCoord2 .z;
1129
+ texCoordArray [i24 + 7] = texCoord2 .w;
1130
+
1131
+ // p3
1132
+ texCoordArray [i24 + 8] = texCoordArray [i24 + 16] = texCoord3 .x;
1133
+ texCoordArray [i24 + 9] = texCoordArray [i24 + 17] = texCoord3 .y;
1134
+ texCoordArray [i24 + 10] = texCoordArray [i24 + 18] = texCoord3 .z;
1135
+ texCoordArray [i24 + 11] = texCoordArray [i24 + 19] = texCoord3 .w;
1136
+
1137
+ // p4
1138
+ texCoordArray [i24 + 20] = texCoord4 .x;
1139
+ texCoordArray [i24 + 21] = texCoord4 .y;
1140
+ texCoordArray [i24 + 22] = texCoord4 .z;
1141
+ texCoordArray [i24 + 23] = texCoord4 .w;
1142
+ }
1143
+
1144
+ gl .bindBuffer (gl .ARRAY_BUFFER, this .texCoordBuffers [0]);
1145
+ gl .bufferData (gl .ARRAY_BUFFER, this .texCoordArray, gl .STATIC_DRAW);
1146
+ }
1147
+ }
1148
+
1149
+ // Vertices
1150
+
1151
+ if (this .geometryType === SPRITE)
1152
+ {
1153
+ if (modelViewMatrix) // if called from depth or draw
1154
+ {
1155
+ // Normals
1156
+
1157
+ var rotation = this .getScreenAlignedRotation (modelViewMatrix);
1158
+
1159
+ normal
1160
+ .set (rotation [0], rotation [1], rotation [2])
1161
+ .cross (vector .set (rotation [3], rotation [4], rotation [5]))
1162
+ .normalize ();
1163
+
1164
+ var
1165
+ nx = normal .x,
1166
+ ny = normal .y,
1167
+ nz = normal .z;
1168
+
1169
+ for (var i = 0, length = 6 * 3 * maxParticles; i < length; i += 3)
1170
+ {
1171
+ normalArray [i] = nx;
1172
+ normalArray [i + 1] = ny;
1173
+ normalArray [i + 2] = nz;
1174
+ }
1175
+
1176
+ gl .bindBuffer (gl .ARRAY_BUFFER, this .normalBuffer);
1177
+ gl .bufferData (gl .ARRAY_BUFFER, this .normalArray, gl .STATIC_DRAW);
1178
+
1179
+ // Vertices
1180
+
1181
+ s1 .set (-sx1_2, -sy1_2, 0);
1182
+ s2 .set ( sx1_2, -sy1_2, 0);
1183
+ s3 .set ( sx1_2, sy1_2, 0);
1184
+ s4 .set (-sx1_2, sy1_2, 0);
1185
+
1186
+ rotation .multVecMatrix (s1);
1187
+ rotation .multVecMatrix (s2);
1188
+ rotation .multVecMatrix (s3);
1189
+ rotation .multVecMatrix (s4);
1190
+
1191
+ for (var i = 0; i < numParticles; ++ i)
1192
+ {
1193
+ var
1194
+ position = particles [i] .position,
1195
+ elapsedTime = particles [i] .elapsedTime / particles [i] .lifetime,
1196
+ x = position .x,
1197
+ y = position .y,
1198
+ z = position .z,
1199
+ i6 = i * 6,
1200
+ i18 = i * 18,
1201
+ i24 = i * 24;
1202
+
1203
+ // p4 ------ p3
1204
+ // | / |
1205
+ // | / |
1206
+ // | / |
1207
+ // | / |
1208
+ // p1 ------ p2
1209
+
1210
+
1211
+ positionArray [i18] = positionArray [i18 + 3] = positionArray [i18 + 6] = positionArray [i18 + 9] = positionArray [i18 + 12] = positionArray [i18 + 15] = x;
1212
+ positionArray [i18 + 1] = positionArray [i18 + 4] = positionArray [i18 + 7] = positionArray [i18 + 10] = positionArray [i18 + 13] = positionArray [i18 + 16] = y;
1213
+ positionArray [i18 + 2] = positionArray [i18 + 5] = positionArray [i18 + 8] = positionArray [i18 + 11] = positionArray [i18 + 14] = positionArray [i18 + 17] = z;
1214
+
1215
+ elapsedTimeArray [i6] = elapsedTimeArray [i6 + 1] = elapsedTimeArray [i6 + 2] = elapsedTimeArray [i6 + 3] = elapsedTimeArray [i6 + 4] = elapsedTimeArray [i6 + 5] = elapsedTime;
1216
+ lifeArray [i6] = lifeArray [i6 + 1] = lifeArray [i6 + 2] = lifeArray [i6 + 3] = lifeArray [i6 + 4] = lifeArray [i6 + 5] = particles [i] .life;
1217
+
1218
+ // p1
1219
+ vertexArray [i24] = vertexArray [i24 + 12] = x + s1 .x;
1220
+ vertexArray [i24 + 1] = vertexArray [i24 + 13] = y + s1 .y;
1221
+ vertexArray [i24 + 2] = vertexArray [i24 + 14] = z + s1 .z;
1222
+
1223
+ // p2
1224
+ vertexArray [i24 + 4] = x + s2 .x;
1225
+ vertexArray [i24 + 5] = y + s2 .y;
1226
+ vertexArray [i24 + 6] = z + s2 .z;
1227
+
1228
+ // p3
1229
+ vertexArray [i24 + 8] = vertexArray [i24 + 16] = x + s3 .x;
1230
+ vertexArray [i24 + 9] = vertexArray [i24 + 17] = y + s3 .y;
1231
+ vertexArray [i24 + 10] = vertexArray [i24 + 18] = z + s3 .z;
1232
+
1233
+ // p4
1234
+ vertexArray [i24 + 20] = x + s4 .x;
1235
+ vertexArray [i24 + 21] = y + s4 .y;
1236
+ vertexArray [i24 + 22] = z + s4 .z;
1237
+ }
1238
+
1239
+ gl .bindBuffer (gl .ARRAY_BUFFER, this .positionBuffer);
1240
+ gl .bufferData (gl .ARRAY_BUFFER, this .positionArray, gl .STATIC_DRAW);
1241
+ gl .bindBuffer (gl .ARRAY_BUFFER, this .elapsedTimeBuffer);
1242
+ gl .bufferData (gl .ARRAY_BUFFER, this .elapsedTimeArray, gl .STATIC_DRAW);
1243
+ gl .bindBuffer (gl .ARRAY_BUFFER, this .lifeBuffer);
1244
+ gl .bufferData (gl .ARRAY_BUFFER, this .lifeArray, gl .STATIC_DRAW);
1245
+ gl .bindBuffer (gl .ARRAY_BUFFER, this .vertexBuffer);
1246
+ gl .bufferData (gl .ARRAY_BUFFER, this .vertexArray, gl .STATIC_DRAW);
1247
+ }
1248
+ }
1249
+ else
1250
+ {
1251
+ if (! modelViewMatrix) // if called from animateParticles
1252
+ {
1253
+ for (var i = 0; i < numParticles; ++ i)
1254
+ {
1255
+ var
1256
+ position = particles [i] .position,
1257
+ elapsedTime = particles [i] .elapsedTime / particles [i] .lifetime,
1258
+ x = position .x,
1259
+ y = position .y,
1260
+ z = position .z,
1261
+ i6 = i * 6,
1262
+ i18 = i * 18,
1263
+ i24 = i * 24;
1264
+
1265
+ // p4 ------ p3
1266
+ // | / |
1267
+ // | / |
1268
+ // | / |
1269
+ // | / |
1270
+ // p1 ------ p2
1271
+
1272
+ positionArray [i18] = positionArray [i18 + 3] = positionArray [i18 + 6] = positionArray [i18 + 9] = positionArray [i18 + 12] = positionArray [i18 + 15] = x;
1273
+ positionArray [i18 + 1] = positionArray [i18 + 4] = positionArray [i18 + 7] = positionArray [i18 + 10] = positionArray [i18 + 13] = positionArray [i18 + 16] = y;
1274
+ positionArray [i18 + 2] = positionArray [i18 + 5] = positionArray [i18 + 8] = positionArray [i18 + 11] = positionArray [i18 + 14] = positionArray [i18 + 17] = z;
1275
+
1276
+ elapsedTimeArray [i6] = elapsedTimeArray [i6 + 1] = elapsedTimeArray [i6 + 2] = elapsedTimeArray [i6 + 3] = elapsedTimeArray [i6 + 4] = elapsedTimeArray [i6 + 5] = elapsedTime;
1277
+ lifeArray [i6] = lifeArray [i6 + 1] = lifeArray [i6 + 2] = lifeArray [i6 + 3] = lifeArray [i6 + 4] = lifeArray [i6 + 5] = particles [i] .life;
1278
+
1279
+ // p1
1280
+ vertexArray [i24] = vertexArray [i24 + 12] = x - sx1_2;
1281
+ vertexArray [i24 + 1] = vertexArray [i24 + 13] = y - sy1_2;
1282
+ vertexArray [i24 + 2] = vertexArray [i24 + 14] = z;
1283
+
1284
+ // p2
1285
+ vertexArray [i24 + 4] = x + sx1_2;
1286
+ vertexArray [i24 + 5] = y - sy1_2;
1287
+ vertexArray [i24 + 6] = z;
1288
+
1289
+ // p3
1290
+ vertexArray [i24 + 8] = vertexArray [i24 + 16] = x + sx1_2;
1291
+ vertexArray [i24 + 9] = vertexArray [i24 + 17] = y + sy1_2;
1292
+ vertexArray [i24 + 10] = vertexArray [i24 + 18] = z;
1293
+
1294
+ // p4
1295
+ vertexArray [i24 + 20] = x - sx1_2;
1296
+ vertexArray [i24 + 21] = y + sy1_2;
1297
+ vertexArray [i24 + 22] = z;
1298
+ }
1299
+
1300
+ gl .bindBuffer (gl .ARRAY_BUFFER, this .positionBuffer);
1301
+ gl .bufferData (gl .ARRAY_BUFFER, this .positionArray, gl .STATIC_DRAW);
1302
+ gl .bindBuffer (gl .ARRAY_BUFFER, this .elapsedTimeBuffer);
1303
+ gl .bufferData (gl .ARRAY_BUFFER, this .elapsedTimeArray, gl .STATIC_DRAW);
1304
+ gl .bindBuffer (gl .ARRAY_BUFFER, this .lifeBuffer);
1305
+ gl .bufferData (gl .ARRAY_BUFFER, this .lifeArray, gl .STATIC_DRAW);
1306
+ gl .bindBuffer (gl .ARRAY_BUFFER, this .vertexBuffer);
1307
+ gl .bufferData (gl .ARRAY_BUFFER, this .vertexArray, gl .STATIC_DRAW);
1308
+ }
1309
+ }
1310
+ }
1311
+ catch (error)
1312
+ {
1313
+ console .error (error);
1314
+ }
1315
+ },
1316
+ traverse: function (type, renderObject)
1317
+ {
1318
+ if (! this ._isActive .getValue ())
1319
+ return;
1320
+
1321
+ switch (type)
1322
+ {
1323
+ case TraverseType .POINTER:
1324
+ {
1325
+ break;
1326
+ }
1327
+ case TraverseType .PICKING:
1328
+ {
1329
+ break;
1330
+ }
1331
+ case TraverseType .COLLISION:
1332
+ {
1333
+ // TODO: to be implemented.
1334
+ break;
1335
+ }
1336
+ case TraverseType .SHADOW:
1337
+ {
1338
+ if (this ._castShadow .getValue ())
1339
+ renderObject .addDepthShape (this);
1340
+
1341
+ break;
1342
+ }
1343
+ case TraverseType .DISPLAY:
1344
+ {
1345
+ if (renderObject .addDisplayShape (this))
1346
+ this .getAppearance () .traverse (type, renderObject); // Currently used for GeneratedCubeMapTexture.
1347
+
1348
+ break;
1349
+ }
1350
+ }
1351
+
1352
+ if (this .geometryType === GEOMETRY)
1353
+ {
1354
+ if (this .getGeometry ())
1355
+ this .getGeometry () .traverse (type, renderObject); // Currently used for ScreenText.
1356
+ }
1357
+ },
1358
+ depth: function (gl, context, shaderNode)
1359
+ {
1360
+ // Update geometry if SPRITE.
1361
+
1362
+ this .updateGeometry (context .modelViewMatrix);
1363
+
1364
+ // Display geometry.
1365
+
1366
+ if (this .geometryType === GEOMETRY)
1367
+ {
1368
+ var geometryNode = this .getGeometry ();
1369
+
1370
+ if (geometryNode)
1371
+ geometryNode .displayParticlesDepth (gl, context, shaderNode, this .particles, this .numParticles);
1372
+ }
1373
+ else
1374
+ {
1375
+ if (this .numParticles <= 0)
1376
+ return;
1377
+
1378
+ if (shaderNode .getValid ())
1379
+ {
1380
+ // Setup vertex attributes.
1381
+
1382
+ shaderNode .enableFloatAttrib (gl, "x3d_ParticleId", this .idBuffer, 1);
1383
+ shaderNode .enableFloatAttrib (gl, "x3d_ParticlePosition", this .positionBuffer, 3);
1384
+ shaderNode .enableFloatAttrib (gl, "x3d_ParticleElapsedTime", this .elapsedTimeBuffer, 1);
1385
+ shaderNode .enableFloatAttrib (gl, "x3d_ParticleLife", this .lifeBuffer, 1);
1386
+ shaderNode .enableVertexAttribute (gl, this .vertexBuffer);
1387
+
1388
+ gl .drawArrays (this .primitiveMode, 0, this .numParticles * this .vertexCount);
1389
+
1390
+ shaderNode .disableFloatAttrib (gl, "x3d_ParticleId");
1391
+ shaderNode .disableFloatAttrib (gl, "x3d_ParticlePosition");
1392
+ shaderNode .disableFloatAttrib (gl, "x3d_ParticleElapsedTime");
1393
+ shaderNode .disableFloatAttrib (gl, "x3d_ParticleLife");
1394
+ }
1395
+ }
1396
+ },
1397
+ display: function (gl, context)
1398
+ {
1399
+ try
1400
+ {
1401
+ if (this .numParticles <= 0)
1402
+ return;
1403
+
1404
+ // Update geometry if SPRITE.
1405
+
1406
+ this .updateGeometry (context .modelViewMatrix);
1407
+
1408
+ // Display geometry.
1409
+
1410
+ if (this .geometryType === GEOMETRY)
1411
+ {
1412
+ const geometryNode = this .getGeometry ();
1413
+
1414
+ if (geometryNode)
1415
+ geometryNode .displayParticles (gl, context, this .particles, this .numParticles);
1416
+ }
1417
+ else
1418
+ {
1419
+ const
1420
+ appearanceNode = this .getAppearance (),
1421
+ shaderNode = appearanceNode .shaderNode || this .shaderNode || appearanceNode .materialNode .getShader (context .browser, context .shadow);
1422
+
1423
+ // Setup shader.
1424
+
1425
+ if (shaderNode .getValid ())
1426
+ {
1427
+ context .geometryContext = this .geometryContext;
1428
+
1429
+ const blendModeNode = appearanceNode .blendModeNode;
1430
+
1431
+ if (blendModeNode)
1432
+ blendModeNode .enable (gl);
1433
+
1434
+ shaderNode .enable (gl);
1435
+ shaderNode .setLocalUniforms (gl, context);
1436
+
1437
+ // Setup vertex attributes.
1438
+
1439
+ shaderNode .enableFloatAttrib (gl, "x3d_ParticleId", this .idBuffer, 1);
1440
+ shaderNode .enableFloatAttrib (gl, "x3d_ParticlePosition", this .positionBuffer, 3);
1441
+ shaderNode .enableFloatAttrib (gl, "x3d_ParticleElapsedTime", this .elapsedTimeBuffer, 1);
1442
+ shaderNode .enableFloatAttrib (gl, "x3d_ParticleLife", this .lifeBuffer, 1);
1443
+
1444
+ if (this .geometryContext .colorMaterial)
1445
+ shaderNode .enableColorAttribute (gl, this .colorBuffer);
1446
+
1447
+ if (this .texCoordArray .length)
1448
+ shaderNode .enableTexCoordAttribute (gl, this .texCoordBuffers);
1449
+
1450
+ if (this .normalArray .length)
1451
+ shaderNode .enableNormalAttribute (gl, this .normalBuffer);
1452
+
1453
+ shaderNode .enableVertexAttribute (gl, this .vertexBuffer);
1454
+
1455
+ if (shaderNode .wireframe && this .testWireframe)
1456
+ {
1457
+ // Wireframes are always solid so only one drawing call is needed.
1458
+
1459
+ for (var i = 0, length = this .numParticles * this .vertexCount; i < length; i += 3)
1460
+ gl .drawArrays (shaderNode .primitiveMode, i, 3);
1461
+ }
1462
+ else
1463
+ {
1464
+ const positiveScale = Matrix4 .prototype .determinant3 .call (context .modelViewMatrix) > 0;
1465
+
1466
+ gl .frontFace (positiveScale ? gl .CCW : gl .CW);
1467
+ gl .enable (gl .CULL_FACE);
1468
+ gl .cullFace (gl .BACK);
1469
+
1470
+ gl .drawArrays (this .primitiveMode, 0, this .numParticles * this .vertexCount);
1471
+ }
1472
+
1473
+ shaderNode .disableFloatAttrib (gl, "x3d_ParticleId");
1474
+ shaderNode .disableFloatAttrib (gl, "x3d_ParticlePosition");
1475
+ shaderNode .disableFloatAttrib (gl, "x3d_ParticleElapsedTime");
1476
+ shaderNode .disableFloatAttrib (gl, "x3d_ParticleLife");
1477
+
1478
+ shaderNode .disableColorAttribute (gl);
1479
+ shaderNode .disableTexCoordAttribute (gl);
1480
+ shaderNode .disableNormalAttribute (gl);
1481
+
1482
+ if (blendModeNode)
1483
+ blendModeNode .disable (gl);
1484
+
1485
+ context .geometryContext = null;
1486
+ }
1487
+ }
1488
+ }
1489
+ catch (error)
1490
+ {
1491
+ // Catch error from setLocalUniforms.
1492
+ console .error (error);
1493
+ }
1494
+ },
1495
+ getScreenAlignedRotation: function (modelViewMatrix)
1496
+ {
1497
+ invModelViewMatrix .assign (modelViewMatrix) .inverse ();
1498
1498
 
1499
- invModelViewMatrix .multDirMatrix (billboardToScreen .assign (Vector3 .zAxis));
1500
- invModelViewMatrix .multDirMatrix (viewerYAxis .assign (Vector3 .yAxis));
1499
+ invModelViewMatrix .multDirMatrix (billboardToScreen .assign (Vector3 .zAxis));
1500
+ invModelViewMatrix .multDirMatrix (viewerYAxis .assign (Vector3 .yAxis));
1501
1501
 
1502
- x .assign (viewerYAxis) .cross (billboardToScreen);
1503
- y .assign (billboardToScreen) .cross (x);
1504
- var z = billboardToScreen;
1502
+ x .assign (viewerYAxis) .cross (billboardToScreen);
1503
+ y .assign (billboardToScreen) .cross (x);
1504
+ var z = billboardToScreen;
1505
1505
 
1506
- // Compose rotation
1507
-
1508
- x .normalize ();
1509
- y .normalize ();
1510
- z .normalize ();
1511
-
1512
- return this .rotation .set (x .x, x .y, x .z,
1513
- y .x, y .y, y .z,
1514
- z .x, z .y, z .z);
1515
- },
1516
- });
1506
+ // Compose rotation
1517
1507
 
1518
- return ParticleSystem;
1508
+ x .normalize ();
1509
+ y .normalize ();
1510
+ z .normalize ();
1511
+
1512
+ return this .rotation .set (x .x, x .y, x .z,
1513
+ y .x, y .y, y .z,
1514
+ z .x, z .y, z .z);
1515
+ },
1516
+ });
1517
+
1518
+ return ParticleSystem;
1519
1519
  });