x_ite 5.0.3 → 6.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (385) hide show
  1. package/.vscode/settings.json +12 -5
  2. package/.vscode/tasks.json +25 -1
  3. package/Makefile +36 -28
  4. package/README.md +6 -11
  5. package/build/bin/dist.pl +0 -6
  6. package/build/bin/examples-and-tests.pl +75 -0
  7. package/build/bin/tests-menu.pl +57 -0
  8. package/build/bin/version.pl +7 -4
  9. package/build/parts/default.start.frag.js +3 -2
  10. package/dist/assets/components/annotation.js +3 -2
  11. package/dist/assets/components/annotation.min.js +1 -1
  12. package/dist/assets/components/cad-geometry.js +3 -2
  13. package/dist/assets/components/cad-geometry.min.js +1 -1
  14. package/dist/assets/components/cube-map-texturing.js +8 -20
  15. package/dist/assets/components/cube-map-texturing.min.js +1 -1
  16. package/dist/assets/components/dis.js +3 -2
  17. package/dist/assets/components/dis.min.js +1 -1
  18. package/dist/assets/components/event-utilities.js +4 -3
  19. package/dist/assets/components/event-utilities.min.js +1 -1
  20. package/dist/assets/components/geometry2d.js +38 -52
  21. package/dist/assets/components/geometry2d.min.js +1 -1
  22. package/dist/assets/components/geospatial.js +34 -1686
  23. package/dist/assets/components/geospatial.min.js +1 -1
  24. package/dist/assets/components/h-anim.js +71 -77
  25. package/dist/assets/components/h-anim.min.js +1 -1
  26. package/dist/assets/components/key-device-sensor.js +4 -3
  27. package/dist/assets/components/key-device-sensor.min.js +1 -1
  28. package/dist/assets/components/layout.js +101 -173
  29. package/dist/assets/components/layout.min.js +1 -1
  30. package/dist/assets/components/nurbs.js +3 -2
  31. package/dist/assets/components/nurbs.min.js +1 -1
  32. package/dist/assets/components/particle-systems.js +1926 -1669
  33. package/dist/assets/components/particle-systems.min.js +1 -1
  34. package/dist/assets/components/picking.js +34 -41
  35. package/dist/assets/components/picking.min.js +1 -1
  36. package/dist/assets/components/projective-texture-mapping.js +73 -86
  37. package/dist/assets/components/projective-texture-mapping.min.js +1 -1
  38. package/dist/assets/components/rigid-body-physics.js +37 -57
  39. package/dist/assets/components/rigid-body-physics.min.js +1 -1
  40. package/dist/assets/components/scripting.js +3 -2
  41. package/dist/assets/components/scripting.min.js +1 -1
  42. package/dist/assets/components/texturing-3d.js +27 -33
  43. package/dist/assets/components/texturing-3d.min.js +3 -3
  44. package/dist/assets/components/volume-rendering.js +12 -11
  45. package/dist/assets/components/volume-rendering.min.js +1 -1
  46. package/dist/assets/components/x_ite.js +3 -2
  47. package/dist/assets/components/x_ite.min.js +1 -1
  48. package/dist/assets/images/Shading.png +0 -0
  49. package/dist/assets/linetype/1.png +0 -0
  50. package/dist/assets/linetype/10.png +0 -0
  51. package/dist/assets/linetype/11.png +0 -0
  52. package/dist/assets/linetype/12.png +0 -0
  53. package/dist/assets/linetype/13.png +0 -0
  54. package/dist/assets/linetype/14.png +0 -0
  55. package/dist/assets/linetype/15.png +0 -0
  56. package/dist/assets/linetype/16.png +0 -0
  57. package/dist/assets/linetype/2.png +0 -0
  58. package/dist/assets/linetype/3.png +0 -0
  59. package/dist/assets/linetype/4.png +0 -0
  60. package/dist/assets/linetype/5.png +0 -0
  61. package/dist/assets/linetype/6.png +0 -0
  62. package/dist/assets/linetype/7.png +0 -0
  63. package/dist/assets/linetype/8.png +0 -0
  64. package/dist/assets/linetype/9.png +0 -0
  65. package/dist/assets/shaders/webgl1/Gouraud.vs +1 -1
  66. package/dist/assets/shaders/webgl1/Line.fs +0 -21
  67. package/dist/assets/shaders/webgl1/Line.vs +0 -10
  68. package/dist/assets/shaders/webgl1/PBR.fs +1 -1
  69. package/dist/assets/shaders/webgl1/PBR.vs +1 -1
  70. package/dist/assets/shaders/webgl1/Phong.fs +1 -1
  71. package/dist/assets/shaders/webgl1/Point.vs +1 -1
  72. package/dist/assets/shaders/webgl2/Depth.vs +29 -1
  73. package/dist/assets/shaders/webgl2/Gouraud.vs +32 -4
  74. package/dist/assets/shaders/webgl2/Line.fs +24 -12
  75. package/dist/assets/shaders/webgl2/Line.vs +36 -11
  76. package/dist/assets/shaders/webgl2/LineTransform.fs +4 -0
  77. package/dist/assets/shaders/webgl2/LineTransform.vs +57 -0
  78. package/dist/assets/shaders/webgl2/PBR.fs +1 -1
  79. package/dist/assets/shaders/webgl2/PBR.vs +35 -7
  80. package/dist/assets/shaders/webgl2/Phong.fs +1 -1
  81. package/dist/assets/shaders/webgl2/Phong.vs +31 -3
  82. package/dist/assets/shaders/webgl2/Point.vs +30 -2
  83. package/dist/assets/shaders/webgl2/Unlit.vs +31 -3
  84. package/dist/example.html +6 -6
  85. package/dist/x_ite.css +199 -224
  86. package/dist/x_ite.js +16335 -15917
  87. package/dist/x_ite.min.js +17 -17
  88. package/dist/x_ite.zip +0 -0
  89. package/docs/404.md +6 -0
  90. package/docs/Accessing-the-External-Browser.md +21 -15
  91. package/docs/Browser-Support.md +6 -0
  92. package/docs/Custom-Shaders.md +18 -25
  93. package/docs/Features.md +11 -5
  94. package/docs/Gemfile +44 -0
  95. package/docs/Gemfile.lock +122 -0
  96. package/docs/Glossary.md +6 -0
  97. package/docs/How-To-Configure-Your-Web-Server.md +6 -0
  98. package/docs/Supported-Nodes.md +9 -1
  99. package/docs/What's-New.md +93 -39
  100. package/docs/XHTML-DOM-Integration.md +6 -0
  101. package/docs/_config.yml +2 -2
  102. package/docs/assets/css/main.scss +26 -0
  103. package/docs/index.md +42 -50
  104. package/docs/reference/Browser-Services.md +9 -3
  105. package/docs/reference/Constants-Services.md +6 -0
  106. package/docs/reference/ECMAScript-Object-and-Function-Definitions.md +12 -6
  107. package/docs/reference/Field-Services-and-Objects.md +105 -1
  108. package/docs/reference/Prototype-Services.md +11 -0
  109. package/docs/reference/Route-Services.md +9 -0
  110. package/docs/reference/Scene-Services.md +17 -2
  111. package/docs/reference/Script-Node-Authoring-Interface.md +7 -1
  112. package/docs/tutorials/Adding-backgrounds.md +6 -0
  113. package/docs/tutorials/Adding-fog.md +6 -0
  114. package/docs/tutorials/Adding-sound.md +6 -0
  115. package/docs/tutorials/Animating-transforms.md +6 -0
  116. package/docs/tutorials/Basic-Nodes.md +6 -0
  117. package/docs/tutorials/Building-a-X3D-world.md +6 -0
  118. package/docs/tutorials/Building-elevation-grids.md +6 -0
  119. package/docs/tutorials/Building-extruded-shapes.md +6 -0
  120. package/docs/tutorials/Building-primitive-shapes.md +6 -0
  121. package/docs/tutorials/Building-shapes-out-of-points,-lines,-and-faces.md +6 -0
  122. package/docs/tutorials/Controlling-appearance-with-materials.md +6 -0
  123. package/docs/tutorials/Controlling-color-on-coordinate-based-geometry.md +6 -0
  124. package/docs/tutorials/Controlling-detail.md +6 -0
  125. package/docs/tutorials/Controlling-how-textures-are-mapped.md +6 -0
  126. package/docs/tutorials/Controlling-navigation.md +6 -0
  127. package/docs/tutorials/Controlling-shading-on-coordinate-based-geometry.md +6 -0
  128. package/docs/tutorials/Controlling-the-viewpoint.md +6 -0
  129. package/docs/tutorials/Creating-new-node-types.md +6 -0
  130. package/docs/tutorials/Grouping-nodes.md +6 -0
  131. package/docs/tutorials/Hello,-World!.md +6 -0
  132. package/docs/tutorials/Improving-Performance.md +6 -0
  133. package/docs/tutorials/Increasing-Rendering-Speed.md +6 -0
  134. package/docs/tutorials/Introducing-X3D.md +6 -0
  135. package/docs/tutorials/Introducing-animation.md +6 -0
  136. package/docs/tutorials/Introducing-script-use.md +6 -0
  137. package/docs/tutorials/Lighting-your-world.md +6 -0
  138. package/docs/tutorials/Mapping-textures.md +6 -0
  139. package/docs/tutorials/Naming-nodes.md +6 -0
  140. package/docs/tutorials/Providing-information-about-your-world.md +6 -0
  141. package/docs/tutorials/Sensing-the-viewer.md +6 -0
  142. package/docs/tutorials/Sensing-viewer-actions.md +6 -0
  143. package/docs/tutorials/Transforming-Shapes.md +6 -0
  144. package/docs/tutorials/Writing-program-scripts-with-ECMAScript.md +6 -0
  145. package/docs/tutorials/index.md +42 -36
  146. package/package.json +6 -7
  147. package/src/assets/components/geometry2d.js +1 -1
  148. package/src/assets/components/key-device-sensor.js +1 -1
  149. package/src/assets/components/layout.js +1 -1
  150. package/src/assets/components/particle-systems.js +1 -1
  151. package/src/assets/components/volume-rendering.js +1 -1
  152. package/src/assets/images/Shading.png +0 -0
  153. package/src/assets/linetype/1.png +0 -0
  154. package/src/assets/linetype/10.png +0 -0
  155. package/src/assets/linetype/11.png +0 -0
  156. package/src/assets/linetype/12.png +0 -0
  157. package/src/assets/linetype/13.png +0 -0
  158. package/src/assets/linetype/14.png +0 -0
  159. package/src/assets/linetype/15.png +0 -0
  160. package/src/assets/linetype/16.png +0 -0
  161. package/src/assets/linetype/2.png +0 -0
  162. package/src/assets/linetype/3.png +0 -0
  163. package/src/assets/linetype/4.png +0 -0
  164. package/src/assets/linetype/5.png +0 -0
  165. package/src/assets/linetype/6.png +0 -0
  166. package/src/assets/linetype/7.png +0 -0
  167. package/src/assets/linetype/8.png +0 -0
  168. package/src/assets/linetype/9.png +0 -0
  169. package/src/assets/shaders/Types.glsl +1 -9
  170. package/src/assets/shaders/webgl1/Gouraud.fs +1 -1
  171. package/src/assets/shaders/webgl1/Gouraud.vs +2 -3
  172. package/src/assets/shaders/webgl1/Line.fs +3 -28
  173. package/src/assets/shaders/webgl1/Line.vs +6 -20
  174. package/src/assets/shaders/webgl1/PBR.fs +6 -6
  175. package/src/assets/shaders/webgl1/PBR.vs +1 -1
  176. package/src/assets/shaders/webgl1/Phong.fs +10 -10
  177. package/src/assets/shaders/webgl1/Point.vs +2 -2
  178. package/src/assets/shaders/webgl1/Unlit.fs +4 -4
  179. package/src/assets/shaders/webgl1/include/Normal.glsl +1 -1
  180. package/src/assets/shaders/webgl1/include/Texture.glsl +3 -8
  181. package/src/assets/shaders/webgl2/Depth.vs +4 -1
  182. package/src/assets/shaders/webgl2/Gouraud.fs +1 -1
  183. package/src/assets/shaders/webgl2/Gouraud.vs +8 -6
  184. package/src/assets/shaders/webgl2/Line.fs +11 -17
  185. package/src/assets/shaders/webgl2/Line.vs +17 -21
  186. package/src/assets/shaders/webgl2/LineTransform.fs +6 -0
  187. package/src/assets/shaders/webgl2/LineTransform.vs +77 -0
  188. package/src/assets/shaders/webgl2/PBR.fs +6 -6
  189. package/src/assets/shaders/webgl2/PBR.vs +10 -7
  190. package/src/assets/shaders/webgl2/Phong.fs +11 -11
  191. package/src/assets/shaders/webgl2/Phong.vs +6 -3
  192. package/src/assets/shaders/webgl2/Point.vs +5 -4
  193. package/src/assets/shaders/webgl2/Unlit.fs +5 -5
  194. package/src/assets/shaders/webgl2/Unlit.vs +6 -3
  195. package/src/assets/shaders/webgl2/include/Line2.glsl +20 -0
  196. package/src/assets/shaders/webgl2/include/Normal.glsl +1 -1
  197. package/src/assets/shaders/webgl2/include/Particle.glsl +36 -0
  198. package/src/assets/shaders/webgl2/include/Texture.glsl +3 -3
  199. package/src/example.html +6 -6
  200. package/src/examples.js +5 -4
  201. package/src/standard/Math/Algorithm.js +12 -28
  202. package/src/standard/Math/Geometry/Line2.js +163 -0
  203. package/src/standard/Math/Geometry/Line3.js +3 -5
  204. package/src/standard/Math/Geometry/Plane3.js +0 -2
  205. package/src/standard/Math/Geometry/Triangle3.js +1 -1
  206. package/src/standard/Math/Geometry/ViewVolume.js +121 -103
  207. package/src/standard/Math/Numbers/Color3.js +6 -0
  208. package/src/standard/Math/Numbers/Color4.js +7 -0
  209. package/src/standard/Math/Numbers/Complex.js +48 -34
  210. package/src/standard/Math/Numbers/Matrix2.js +62 -2
  211. package/src/standard/Math/Numbers/Matrix3.js +129 -110
  212. package/src/standard/Math/Numbers/Matrix4.js +138 -119
  213. package/src/standard/Math/Numbers/Quaternion.js +12 -5
  214. package/src/standard/Math/Numbers/Rotation4.js +8 -1
  215. package/src/standard/Math/Numbers/Vector2.js +42 -9
  216. package/src/standard/Math/Numbers/Vector3.js +50 -14
  217. package/src/standard/Math/Numbers/Vector4.js +48 -11
  218. package/src/standard/Math/Utility/BVH.js +45 -17
  219. package/src/tests.js +68 -66
  220. package/src/x_ite/Base/X3DBaseNode.js +22 -11
  221. package/src/x_ite/Base/X3DField.js +1 -1
  222. package/src/x_ite/Browser/Core/BrowserOptions.js +24 -143
  223. package/src/x_ite/Browser/Core/BrowserTimings.js +6 -4
  224. package/src/x_ite/Browser/Core/Context.js +185 -0
  225. package/src/x_ite/Browser/Core/ContextMenu.js +398 -211
  226. package/src/x_ite/Browser/Core/Notification.js +1 -0
  227. package/src/x_ite/Browser/Core/X3DCoreContext.js +35 -146
  228. package/src/x_ite/Browser/Followers/X3DArrayFollowerTemplate.js +1 -1
  229. package/src/x_ite/Browser/Geometry2D/Disk2DOptions.js +1 -0
  230. package/src/x_ite/Browser/Geometry2D/X3DGeometry2DContext.js +2 -2
  231. package/src/x_ite/Browser/Geometry3D/X3DGeometry3DContext.js +41 -2
  232. package/src/x_ite/Browser/Geospatial/Geocentric.js +2 -2
  233. package/src/x_ite/Browser/Interpolation/CatmullRomSplineInterpolatorTemplate.js +1 -1
  234. package/src/x_ite/Browser/Layout/ScreenText.js +18 -65
  235. package/src/x_ite/Browser/Layout/X3DLayoutContext.js +59 -16
  236. package/src/x_ite/Browser/Navigation/ExamineViewer.js +13 -20
  237. package/src/x_ite/Browser/Navigation/LookAtViewer.js +1 -4
  238. package/src/x_ite/Browser/Navigation/PlaneViewer.js +0 -3
  239. package/src/x_ite/Browser/Navigation/X3DFlyViewer.js +15 -8
  240. package/src/x_ite/Browser/Navigation/X3DViewer.js +12 -20
  241. package/src/x_ite/Browser/Networking/X3DNetworkingContext.js +11 -7
  242. package/src/x_ite/Browser/ParticleSystems/BVH.glsl +183 -0
  243. package/src/x_ite/Browser/ParticleSystems/Box3.glsl +47 -0
  244. package/src/x_ite/Browser/ParticleSystems/GeometryTypes.js +66 -0
  245. package/src/x_ite/Browser/ParticleSystems/Line3.glsl +55 -0
  246. package/src/x_ite/Browser/ParticleSystems/Plane3.glsl +160 -0
  247. package/src/x_ite/Browser/PointingDeviceSensor/PointingDevice.js +27 -3
  248. package/src/x_ite/Browser/PointingDeviceSensor/X3DPointingDeviceSensorContext.js +41 -37
  249. package/src/x_ite/Browser/Rendering/X3DRenderingContext.js +21 -13
  250. package/src/x_ite/Browser/Shaders/Shader.js +33 -12
  251. package/src/x_ite/Browser/Shaders/ShaderSource.js +6 -0
  252. package/src/x_ite/Browser/Shaders/ShaderTest.js +16 -10
  253. package/src/x_ite/Browser/Shape/X3DShapeContext.js +50 -9
  254. package/src/x_ite/Browser/Text/X3DTextContext.js +4 -13
  255. package/src/x_ite/Browser/Text/X3DTextGeometry.js +2 -1
  256. package/src/x_ite/Browser/Texturing/X3DTexturingContext.js +71 -34
  257. package/src/x_ite/Browser/Texturing3D/DICOMParser.js +2 -2
  258. package/src/x_ite/Browser/Time/X3DTimeContext.js +4 -2
  259. package/src/x_ite/Browser/VERSION.js +1 -1
  260. package/src/x_ite/Browser/X3DBrowser.js +7 -6
  261. package/src/x_ite/Browser/X3DBrowserContext.js +43 -10
  262. package/src/x_ite/Components/Core/X3DNode.js +4 -0
  263. package/src/x_ite/Components/Core/X3DPrototypeInstance.js +0 -2
  264. package/src/x_ite/Components/CubeMapTexturing/ComposedCubeMapTexture.js +3 -4
  265. package/src/x_ite/Components/CubeMapTexturing/GeneratedCubeMapTexture.js +1 -12
  266. package/src/x_ite/Components/CubeMapTexturing/ImageCubeMapTexture.js +1 -2
  267. package/src/x_ite/Components/EnvironmentalEffects/TextureBackground.js +1 -1
  268. package/src/x_ite/Components/EnvironmentalEffects/X3DBackgroundNode.js +76 -77
  269. package/src/x_ite/Components/EnvironmentalEffects/X3DFogObject.js +2 -9
  270. package/src/x_ite/Components/EnvironmentalSensor/ProximitySensor.js +51 -65
  271. package/src/x_ite/Components/EventUtilities/X3DSequencerNode.js +1 -1
  272. package/src/x_ite/Components/Followers/ColorDamper.js +1 -1
  273. package/src/x_ite/Components/Followers/X3DChaserNode.js +18 -32
  274. package/src/x_ite/Components/Followers/X3DDamperNode.js +1 -6
  275. package/src/x_ite/Components/Followers/X3DFollowerNode.js +1 -1
  276. package/src/x_ite/Components/Geometry2D/Disk2D.js +30 -46
  277. package/src/x_ite/Components/Geometry2D/TriangleSet2D.js +1 -1
  278. package/src/x_ite/Components/Geometry3D/ElevationGrid.js +12 -4
  279. package/src/x_ite/Components/Geometry3D/IndexedFaceSet.js +4 -4
  280. package/src/x_ite/Components/Geospatial/GeoCoordinate.js +10 -27
  281. package/src/x_ite/Components/Geospatial/GeoLOD.js +1 -1
  282. package/src/x_ite/Components/Geospatial/GeoPositionInterpolator.js +5 -10
  283. package/src/x_ite/Components/Geospatial/GeoTouchSensor.js +9 -16
  284. package/src/x_ite/Components/Geospatial/GeoTransform.js +6 -18
  285. package/src/x_ite/Components/Geospatial/GeoViewpoint.js +26 -30
  286. package/src/x_ite/Components/Geospatial/X3DGeospatialObject.js +20 -27
  287. package/src/x_ite/Components/Grouping/X3DGroupingNode.js +8 -8
  288. package/src/x_ite/Components/Grouping/X3DTransformNode.js +0 -4
  289. package/src/x_ite/Components/HAnim/HAnimHumanoid.js +68 -75
  290. package/src/x_ite/Components/Interpolation/OrientationInterpolator.js +4 -11
  291. package/src/x_ite/Components/Interpolation/X3DInterpolatorNode.js +1 -1
  292. package/src/x_ite/Components/Layout/LayoutGroup.js +4 -9
  293. package/src/x_ite/Components/Layout/ScreenFontStyle.js +1 -1
  294. package/src/x_ite/Components/Layout/ScreenGroup.js +16 -80
  295. package/src/x_ite/Components/Lighting/DirectionalLight.js +28 -36
  296. package/src/x_ite/Components/Lighting/PointLight.js +32 -47
  297. package/src/x_ite/Components/Lighting/SpotLight.js +33 -48
  298. package/src/x_ite/Components/Navigation/Billboard.js +49 -56
  299. package/src/x_ite/Components/Navigation/LOD.js +2 -2
  300. package/src/x_ite/Components/Navigation/OrthoViewpoint.js +29 -30
  301. package/src/x_ite/Components/Navigation/Viewpoint.js +16 -20
  302. package/src/x_ite/Components/Navigation/X3DViewpointNode.js +82 -111
  303. package/src/x_ite/Components/Networking/Anchor.js +18 -7
  304. package/src/x_ite/Components/ParticleSystems/BoundedPhysicsModel.js +6 -6
  305. package/src/x_ite/Components/ParticleSystems/ConeEmitter.js +44 -36
  306. package/src/x_ite/Components/ParticleSystems/ExplosionEmitter.js +26 -17
  307. package/src/x_ite/Components/ParticleSystems/ForcePhysicsModel.js +20 -7
  308. package/src/x_ite/Components/ParticleSystems/ParticleSystem.js +463 -882
  309. package/src/x_ite/Components/ParticleSystems/PointEmitter.js +39 -35
  310. package/src/x_ite/Components/ParticleSystems/PolylineEmitter.js +112 -128
  311. package/src/x_ite/Components/ParticleSystems/SurfaceEmitter.js +105 -112
  312. package/src/x_ite/Components/ParticleSystems/VolumeEmitter.js +138 -176
  313. package/src/x_ite/Components/ParticleSystems/WindPhysicsModel.js +16 -11
  314. package/src/x_ite/Components/ParticleSystems/X3DParticleEmitterNode.js +807 -217
  315. package/src/x_ite/Components/Picking/LinePickSensor.js +31 -39
  316. package/src/x_ite/Components/PointingDeviceSensor/CylinderSensor.js +91 -108
  317. package/src/x_ite/Components/PointingDeviceSensor/PlaneSensor.js +56 -59
  318. package/src/x_ite/Components/PointingDeviceSensor/SphereSensor.js +54 -71
  319. package/src/x_ite/Components/PointingDeviceSensor/TouchSensor.js +8 -15
  320. package/src/x_ite/Components/ProjectiveTextureMapping/TextureProjectorParallel.js +43 -50
  321. package/src/x_ite/Components/ProjectiveTextureMapping/TextureProjectorPerspective.js +32 -39
  322. package/src/x_ite/Components/Rendering/ClipPlane.js +3 -11
  323. package/src/x_ite/Components/Rendering/Color.js +12 -24
  324. package/src/x_ite/Components/Rendering/ColorRGBA.js +13 -25
  325. package/src/x_ite/Components/Rendering/IndexedLineSet.js +26 -4
  326. package/src/x_ite/Components/Rendering/LineSet.js +35 -13
  327. package/src/x_ite/Components/Rendering/PointSet.js +35 -13
  328. package/src/x_ite/Components/Rendering/X3DComposedGeometryNode.js +13 -5
  329. package/src/x_ite/Components/Rendering/X3DGeometryNode.js +331 -387
  330. package/src/x_ite/Components/Rendering/X3DLineGeometryNode.js +350 -140
  331. package/src/x_ite/Components/Rendering/X3DPointGeometryNode.js +116 -126
  332. package/src/x_ite/Components/RigidBodyPhysics/DoubleAxisHingeJoint.js +24 -38
  333. package/src/x_ite/Components/RigidBodyPhysics/SingleAxisHingeJoint.js +10 -17
  334. package/src/x_ite/Components/Shaders/ComposedShader.js +35 -75
  335. package/src/x_ite/Components/Shaders/FloatVertexAttribute.js +8 -11
  336. package/src/x_ite/Components/Shaders/Matrix3VertexAttribute.js +10 -14
  337. package/src/x_ite/Components/Shaders/Matrix4VertexAttribute.js +10 -14
  338. package/src/x_ite/Components/Shaders/ShaderPart.js +1 -10
  339. package/src/x_ite/Components/Shaders/X3DProgrammableShaderObject.js +220 -210
  340. package/src/x_ite/Components/Shaders/X3DShaderNode.js +28 -10
  341. package/src/x_ite/Components/Shaders/X3DVertexAttributeNode.js +15 -1
  342. package/src/x_ite/Components/Shape/Appearance.js +37 -4
  343. package/src/x_ite/Components/Shape/FillProperties.js +12 -1
  344. package/src/x_ite/Components/Shape/LineProperties.js +33 -1
  345. package/src/x_ite/Components/Shape/PointProperties.js +24 -3
  346. package/src/x_ite/Components/Shape/Shape.js +30 -39
  347. package/src/x_ite/Components/Shape/TwoSidedMaterial.js +3 -1
  348. package/src/x_ite/Components/Sound/Sound.js +31 -41
  349. package/src/x_ite/Components/Text/Text.js +6 -20
  350. package/src/x_ite/Components/Texturing/ImageTexture.js +1 -1
  351. package/src/x_ite/Components/Texturing/MovieTexture.js +1 -1
  352. package/src/x_ite/Components/Texturing/PixelTexture.js +2 -2
  353. package/src/x_ite/Components/Texturing/TextureCoordinate.js +5 -5
  354. package/src/x_ite/Components/Texturing/TextureProperties.js +4 -4
  355. package/src/x_ite/Components/Texturing/X3DSingleTextureNode.js +5 -4
  356. package/src/x_ite/Components/Texturing/X3DTexture2DNode.js +24 -33
  357. package/src/x_ite/Components/Texturing3D/TextureCoordinate3D.js +5 -5
  358. package/src/x_ite/Components/Texturing3D/TextureCoordinate4D.js +5 -5
  359. package/src/x_ite/Components/Texturing3D/X3DTexture3DNode.js +12 -19
  360. package/src/x_ite/Components/VolumeRendering/X3DVolumeDataNode.js +8 -8
  361. package/src/x_ite/Components.js +2 -2
  362. package/src/x_ite/Fallback.js +9 -3
  363. package/src/x_ite/Fields/SFColor.js +4 -0
  364. package/src/x_ite/Fields/SFColorRGBA.js +4 -0
  365. package/src/x_ite/Fields/SFImage.js +2 -11
  366. package/src/x_ite/Fields/SFMatrixPrototypeTemplate.js +4 -0
  367. package/src/x_ite/Fields/SFRotation.js +4 -0
  368. package/src/x_ite/Fields/SFString.js +4 -0
  369. package/src/x_ite/Fields/SFVecPrototypeTemplate.js +22 -2
  370. package/src/x_ite/Parser/XMLParser.js +1 -1
  371. package/src/x_ite/Rendering/TextureBuffer.js +43 -36
  372. package/src/x_ite/Rendering/VertexArray.js +103 -0
  373. package/src/x_ite/Rendering/X3DRenderObject.js +127 -148
  374. package/src/x_ite/X3D.js +32 -26
  375. package/src/x_ite.config.js +0 -5
  376. package/src/x_ite.css +216 -175
  377. package/src/x_ite.html +15 -10
  378. package/src/x_ite.js +49 -1
  379. package/x_ite.min.html +15 -10
  380. package/dist/assets/hatching/0.png +0 -0
  381. package/dist/assets/linetype/0.png +0 -0
  382. package/src/assets/hatching/0.png +0 -0
  383. package/src/assets/linetype/0.png +0 -0
  384. package/src/spinner.css +0 -67
  385. package/src/x_ite/Browser/Shape/LineStipples.xcf +0 -0
@@ -56,7 +56,6 @@ define ([
56
56
  "x_ite/Base/X3DCast",
57
57
  "standard/Math/Geometry/Triangle3",
58
58
  "standard/Math/Numbers/Vector3",
59
- "standard/Math/Algorithm",
60
59
  ],
61
60
  function (Fields,
62
61
  X3DFieldDefinition,
@@ -65,8 +64,7 @@ function (Fields,
65
64
  X3DConstants,
66
65
  X3DCast,
67
66
  Triangle3,
68
- Vector3,
69
- Algorithm)
67
+ Vector3)
70
68
  {
71
69
  "use strict";
72
70
 
@@ -76,25 +74,52 @@ function (Fields,
76
74
 
77
75
  this .addType (X3DConstants .SurfaceEmitter);
78
76
 
79
- this ._speed .setUnit ("speed");
80
- this ._mass .setUnit ("mass");
81
- this ._surfaceArea .setUnit ("area");
77
+ this .surfaceNode = null;
78
+ this .surfaceArray = new Float32Array ();
82
79
 
83
- this .surfaceNode = null;
84
- this .areaSoFarArray = [ 0 ];
85
- this .direction = new Vector3 (0, 0, 0);
80
+ this .addSampler ("surface");
81
+
82
+ this .addUniform ("solid", "uniform bool solid;");
83
+ this .addUniform ("verticesIndex", "uniform int verticesIndex;");
84
+ this .addUniform ("normalsIndex", "uniform int normalsIndex;");
85
+ this .addUniform ("surface", "uniform sampler2D surface;");
86
+
87
+ this .addFunction (/* glsl */ `vec4 position; vec3 getRandomVelocity ()
88
+ {
89
+ if (verticesIndex < 0)
90
+ {
91
+ return vec3 (0.0);
92
+ }
93
+ else
94
+ {
95
+ vec3 normal;
96
+
97
+ getRandomPointOnSurface (surface, verticesIndex, normalsIndex, position, normal);
98
+
99
+ if (solid == false && random () > 0.5)
100
+ normal = -normal;
101
+
102
+ return normal * getRandomSpeed ();
103
+ }
104
+ }`);
105
+
106
+ this .addFunction (/* glsl */ `vec4 getRandomPosition ()
107
+ {
108
+ return verticesIndex < 0 ? vec4 (NaN) : position;
109
+ }`);
86
110
  }
87
111
 
88
112
  SurfaceEmitter .prototype = Object .assign (Object .create (X3DParticleEmitterNode .prototype),
89
113
  {
90
114
  constructor: SurfaceEmitter,
91
115
  [Symbol .for ("X_ITE.X3DBaseNode.fieldDefinitions")]: new FieldDefinitionArray ([
92
- new X3DFieldDefinition (X3DConstants .inputOutput, "metadata", new Fields .SFNode ()),
93
- new X3DFieldDefinition (X3DConstants .inputOutput, "speed", new Fields .SFFloat ()),
94
- new X3DFieldDefinition (X3DConstants .inputOutput, "variation", new Fields .SFFloat (0.25)),
95
- new X3DFieldDefinition (X3DConstants .initializeOnly, "mass", new Fields .SFFloat ()),
96
- new X3DFieldDefinition (X3DConstants .initializeOnly, "surfaceArea", new Fields .SFFloat ()),
97
- new X3DFieldDefinition (X3DConstants .initializeOnly, "surface", new Fields .SFNode ()),
116
+ new X3DFieldDefinition (X3DConstants .inputOutput, "metadata", new Fields .SFNode ()),
117
+ new X3DFieldDefinition (X3DConstants .inputOutput, "on", new Fields .SFBool (true)),
118
+ new X3DFieldDefinition (X3DConstants .inputOutput, "speed", new Fields .SFFloat ()),
119
+ new X3DFieldDefinition (X3DConstants .inputOutput, "variation", new Fields .SFFloat (0.25)),
120
+ new X3DFieldDefinition (X3DConstants .inputOutput, "mass", new Fields .SFFloat ()),
121
+ new X3DFieldDefinition (X3DConstants .inputOutput, "surfaceArea", new Fields .SFFloat ()),
122
+ new X3DFieldDefinition (X3DConstants .inputOutput, "surface", new Fields .SFNode ()),
98
123
  ]),
99
124
  getTypeName: function ()
100
125
  {
@@ -112,6 +137,17 @@ function (Fields,
112
137
  {
113
138
  X3DParticleEmitterNode .prototype .initialize .call (this);
114
139
 
140
+ const browser = this .getBrowser ();
141
+
142
+ if (browser .getContext () .getVersion () < 2)
143
+ return;
144
+
145
+ // Create GL stuff.
146
+
147
+ this .surfaceTexture = this .createTexture ();
148
+
149
+ // Initialize fields.
150
+
115
151
  this ._surface .addInterest ("set_surface__", this);
116
152
 
117
153
  this .set_surface__ ();
@@ -119,141 +155,98 @@ function (Fields,
119
155
  set_surface__: function ()
120
156
  {
121
157
  if (this .surfaceNode)
158
+ {
159
+ this .surfaceNode ._solid .removeInterest ("set_solid__", this);
122
160
  this .surfaceNode ._rebuild .removeInterest ("set_geometry__", this);
161
+ }
123
162
 
124
163
  this .surfaceNode = X3DCast (X3DConstants .X3DGeometryNode, this ._surface);
125
164
 
126
165
  if (this .surfaceNode)
166
+ {
167
+ this .surfaceNode ._solid .addInterest ("set_solid__", this);
127
168
  this .surfaceNode ._rebuild .addInterest ("set_geometry__", this);
169
+ }
128
170
 
171
+ this .set_solid__ ();
129
172
  this .set_geometry__ ();
130
173
  },
174
+ set_solid__: function ()
175
+ {
176
+ if (this .surfaceNode)
177
+ this .setUniform ("uniform1i", "solid", this .surfaceNode ._solid .getValue ());
178
+ },
131
179
  set_geometry__: (function ()
132
180
  {
133
- var
181
+ const
134
182
  vertex1 = new Vector3 (0, 0, 0),
135
183
  vertex2 = new Vector3 (0, 0, 0),
136
184
  vertex3 = new Vector3 (0, 0, 0);
137
185
 
138
186
  return function ()
139
187
  {
188
+ const gl = this .getBrowser () .getContext ();
189
+
140
190
  if (this .surfaceNode)
141
191
  {
142
- delete this .getRandomPosition;
143
- delete this .getRandomVelocity;
192
+ const
193
+ vertices = this .surfaceNode .getVertices () .getValue (),
194
+ normals = this .surfaceNode .getNormals () .getValue (),
195
+ numVertices = vertices .length / 4,
196
+ numAreaSoFar = numVertices / 3 + 1,
197
+ surfaceArraySize = Math .ceil (Math .sqrt (numAreaSoFar + numVertices + numVertices));
144
198
 
145
- var
146
- areaSoFar = 0,
147
- areaSoFarArray = this .areaSoFarArray,
148
- vertices = this .surfaceNode .getVertices () .getValue ();
199
+ const
200
+ verticesIndex = numAreaSoFar,
201
+ normalsIndex = verticesIndex + numVertices;
149
202
 
150
- this .normals = this .surfaceNode .getNormals () .getValue ();
151
- this .vertices = vertices;
203
+ let surfaceArray = this .surfaceArray;
152
204
 
153
- areaSoFarArray .length = 1;
205
+ if (surfaceArray .length < surfaceArraySize * surfaceArraySize * 4)
206
+ surfaceArray = this .surfaceArray = new Float32Array (surfaceArraySize * surfaceArraySize * 4);
154
207
 
155
- for (var i = 0, length = vertices .length; i < length; i += 12)
208
+ let areaSoFar = 0;
209
+
210
+ for (let i = 0, length = vertices .length; i < length; i += 12)
156
211
  {
157
212
  vertex1 .set (vertices [i], vertices [i + 1], vertices [i + 2]);
158
213
  vertex2 .set (vertices [i + 4], vertices [i + 5], vertices [i + 6]);
159
214
  vertex3 .set (vertices [i + 8], vertices [i + 9], vertices [i + 10]);
160
215
 
161
- areaSoFar += Triangle3 .area (vertex1, vertex2, vertex3);
162
- areaSoFarArray .push (areaSoFar);
216
+ surfaceArray [i / 3 + 4] = areaSoFar += Triangle3 .area (vertex1, vertex2, vertex3);
163
217
  }
164
- }
165
- else
166
- {
167
- this .getRandomPosition = getPosition;
168
- this .getRandomVelocity = this .getSphericalRandomVelocity;
169
- }
170
- };
171
- })(),
172
- getRandomPosition: function (position)
173
- {
174
- // Determine index0.
175
218
 
176
- var
177
- areaSoFarArray = this .areaSoFarArray,
178
- length = areaSoFarArray .length,
179
- fraction = Math .random () * areaSoFarArray .at (-1),
180
- index0 = 0;
219
+ surfaceArray .set (vertices, verticesIndex * 4);
181
220
 
182
- if (length == 1 || fraction <= areaSoFarArray [0])
183
- {
184
- index0 = 0;
185
- }
186
- else if (fraction >= areaSoFarArray .at (-1))
187
- {
188
- index0 = length - 2;
189
- }
190
- else
191
- {
192
- var index = Algorithm .upperBound (areaSoFarArray, 0, length, fraction, Algorithm .less);
221
+ for (let s = normalsIndex * 4, n = 0, l = normals .length; n < l; s += 4, n += 3)
222
+ {
223
+ surfaceArray [s + 0] = normals [n + 0];
224
+ surfaceArray [s + 1] = normals [n + 1];
225
+ surfaceArray [s + 2] = normals [n + 2];
226
+ }
193
227
 
194
- if (index < length)
195
- {
196
- index0 = index - 1;
228
+ this .setUniform ("uniform1i", "verticesIndex", numVertices ? verticesIndex : -1);
229
+ this .setUniform ("uniform1i", "normalsIndex", numVertices ? normalsIndex : -1);
230
+
231
+ if (surfaceArraySize)
232
+ {
233
+ gl .bindTexture (gl .TEXTURE_2D, this .surfaceTexture);
234
+ gl .texImage2D (gl .TEXTURE_2D, 0, gl .RGBA32F, surfaceArraySize, surfaceArraySize, 0, gl .RGBA, gl .FLOAT, surfaceArray);
235
+ }
197
236
  }
198
237
  else
199
238
  {
200
- index0 = 0;
239
+ this .setUniform ("uniform1i", "verticesIndex", -1);
240
+ this .setUniform ("uniform1i", "normalsIndex", -1);
201
241
  }
202
- }
203
-
204
- // Random barycentric coordinates.
205
-
206
- var
207
- u = Math .random (),
208
- v = Math .random ();
209
-
210
- if (u + v > 1)
211
- {
212
- u = 1 - u;
213
- v = 1 - v;
214
- }
215
-
216
- var t = 1 - u - v;
217
-
218
- // Interpolate and set position.
219
-
220
- var
221
- i = index0 * 12,
222
- vertices = this .vertices;
223
-
224
- position .x = u * vertices [i] + v * vertices [i + 4] + t * vertices [i + 8];
225
- position .y = u * vertices [i + 1] + v * vertices [i + 5] + t * vertices [i + 9];
226
- position .z = u * vertices [i + 2] + v * vertices [i + 6] + t * vertices [i + 10];
227
-
228
- var
229
- i = index0 * 9,
230
- normals = this .normals,
231
- direction = this .direction;
232
-
233
- direction .x = u * normals [i] + v * normals [i + 3] + t * normals [i + 6];
234
- direction .y = u * normals [i + 1] + v * normals [i + 4] + t * normals [i + 7];
235
- direction .z = u * normals [i + 2] + v * normals [i + 5] + t * normals [i + 8];
236
-
237
- return position;
238
- },
239
- getRandomVelocity: function (velocity)
242
+ };
243
+ })(),
244
+ activateTextures: function (gl, program)
240
245
  {
241
- var
242
- speed = this .getRandomSpeed (),
243
- direction = this .direction;
244
-
245
- velocity .x = direction .x * speed;
246
- velocity .y = direction .y * speed;
247
- velocity .z = direction .z * speed;
248
-
249
- return velocity;
250
- },
246
+ gl .activeTexture (gl .TEXTURE0 + program .surfaceTextureUnit);
247
+ gl .bindTexture (gl .TEXTURE_2D, this .surfaceTexture);
248
+ },
251
249
  });
252
250
 
253
- function getPosition (position)
254
- {
255
- return position .set (0, 0, 0);
256
- }
257
-
258
251
  return SurfaceEmitter;
259
252
  });
@@ -55,13 +55,8 @@ define ([
55
55
  "x_ite/Components/Geometry3D/IndexedFaceSet",
56
56
  "x_ite/Base/X3DConstants",
57
57
  "standard/Math/Numbers/Vector3",
58
- "standard/Math/Numbers/Rotation4",
59
- "standard/Math/Geometry/Line3",
60
- "standard/Math/Geometry/Plane3",
61
58
  "standard/Math/Geometry/Triangle3",
62
- "standard/Math/Algorithm",
63
59
  "standard/Math/Utility/BVH",
64
- "standard/Math/Algorithms/QuickSort",
65
60
  ],
66
61
  function (Fields,
67
62
  X3DFieldDefinition,
@@ -70,13 +65,8 @@ function (Fields,
70
65
  IndexedFaceSet,
71
66
  X3DConstants,
72
67
  Vector3,
73
- Rotation4,
74
- Line3,
75
- Plane3,
76
68
  Triangle3,
77
- Algorithm,
78
- BVH,
79
- QuickSort)
69
+ BVH)
80
70
  {
81
71
  "use strict";
82
72
 
@@ -86,28 +76,87 @@ function (Fields,
86
76
 
87
77
  this .addType (X3DConstants .VolumeEmitter);
88
78
 
89
- this ._speed .setUnit ("speed");
90
- this ._mass .setUnit ("mass");
91
- this ._surfaceArea .setUnit ("area");
79
+ this .volumeNode = new IndexedFaceSet (executionContext);
80
+ this .volumeArray = new Float32Array ();
92
81
 
93
- this .direction = new Vector3 (0, 0, 0);
94
- this .volumeNode = new IndexedFaceSet (executionContext);
95
- this .areaSoFarArray = [ 0 ];
82
+ this .addSampler ("volume");
83
+
84
+ this .addUniform ("direction", "uniform vec3 direction;");
85
+ this .addUniform ("verticesIndex", "uniform int verticesIndex;");
86
+ this .addUniform ("normalsIndex", "uniform int normalsIndex;");
87
+ this .addUniform ("hierarchyIndex", "uniform int hierarchyIndex;");
88
+ this .addUniform ("hierarchyRoot", "uniform int hierarchyRoot;");
89
+ this .addUniform ("volume", "uniform sampler2D volume;");
90
+
91
+ this .addFunction (/* glsl */ `vec3 getRandomVelocity ()
92
+ {
93
+ if (hierarchyRoot < 0)
94
+ {
95
+ return vec3 (0.0);
96
+ }
97
+ else
98
+ {
99
+ if (direction == vec3 (0.0))
100
+ return getRandomSphericalVelocity ();
101
+
102
+ else
103
+ return direction * getRandomSpeed ();
104
+ }
105
+ }`);
106
+
107
+ this .addFunction (/* glsl */ `vec4 getRandomPosition ()
108
+ {
109
+ if (hierarchyRoot < 0)
110
+ {
111
+ return vec4 (NaN);
112
+ }
113
+ else
114
+ {
115
+ vec4 point;
116
+ vec3 normal;
117
+
118
+ getRandomPointOnSurface (volume, verticesIndex, normalsIndex, point, normal);
119
+
120
+ Line3 line = Line3 (point .xyz, getRandomSurfaceNormal (normal));
121
+
122
+ vec4 points [ARRAY_SIZE];
123
+
124
+ int numIntersections = getIntersections (volume, verticesIndex, hierarchyIndex, hierarchyRoot, line, points);
125
+
126
+ numIntersections -= numIntersections % 2; // We need an even count of intersections.
127
+
128
+ switch (numIntersections)
129
+ {
130
+ case 0:
131
+ return vec4 (0.0);
132
+ case 2:
133
+ break;
134
+ default:
135
+ sort (points, numIntersections, plane3 (line .point, line .direction));
136
+ break;
137
+ }
138
+
139
+ int index = int (fract (random ()) * float (numIntersections / 2)) * 2; // Select random intersection.
140
+
141
+ return mix (points [index], points [index + 1], random ());
142
+ }
143
+ }`);
96
144
  }
97
145
 
98
146
  VolumeEmitter .prototype = Object .assign (Object .create (X3DParticleEmitterNode .prototype),
99
147
  {
100
148
  constructor: VolumeEmitter,
101
149
  [Symbol .for ("X_ITE.X3DBaseNode.fieldDefinitions")]: new FieldDefinitionArray ([
102
- new X3DFieldDefinition (X3DConstants .inputOutput, "metadata", new Fields .SFNode ()),
103
- new X3DFieldDefinition (X3DConstants .initializeOnly, "internal", new Fields .SFBool (true)),
104
- new X3DFieldDefinition (X3DConstants .inputOutput, "direction", new Fields .SFVec3f (0, 1, 0)),
105
- new X3DFieldDefinition (X3DConstants .inputOutput, "speed", new Fields .SFFloat ()),
106
- new X3DFieldDefinition (X3DConstants .inputOutput, "variation", new Fields .SFFloat (0.25)),
107
- new X3DFieldDefinition (X3DConstants .initializeOnly, "mass", new Fields .SFFloat ()),
108
- new X3DFieldDefinition (X3DConstants .initializeOnly, "surfaceArea", new Fields .SFFloat ()),
109
- new X3DFieldDefinition (X3DConstants .inputOutput, "coordIndex", new Fields .MFInt32 (-1)),
110
- new X3DFieldDefinition (X3DConstants .inputOutput, "coord", new Fields .SFNode ()),
150
+ new X3DFieldDefinition (X3DConstants .inputOutput, "metadata", new Fields .SFNode ()),
151
+ new X3DFieldDefinition (X3DConstants .inputOutput, "on", new Fields .SFBool (true)),
152
+ new X3DFieldDefinition (X3DConstants .inputOutput, "internal", new Fields .SFBool (true)),
153
+ new X3DFieldDefinition (X3DConstants .inputOutput, "direction", new Fields .SFVec3f (0, 1, 0)),
154
+ new X3DFieldDefinition (X3DConstants .inputOutput, "speed", new Fields .SFFloat ()),
155
+ new X3DFieldDefinition (X3DConstants .inputOutput, "variation", new Fields .SFFloat (0.25)),
156
+ new X3DFieldDefinition (X3DConstants .inputOutput, "mass", new Fields .SFFloat ()),
157
+ new X3DFieldDefinition (X3DConstants .inputOutput, "surfaceArea", new Fields .SFFloat ()),
158
+ new X3DFieldDefinition (X3DConstants .inputOutput, "coordIndex", new Fields .MFInt32 (-1)),
159
+ new X3DFieldDefinition (X3DConstants .inputOutput, "coord", new Fields .SFNode ()),
111
160
  ]),
112
161
  getTypeName: function ()
113
162
  {
@@ -125,6 +174,17 @@ function (Fields,
125
174
  {
126
175
  X3DParticleEmitterNode .prototype .initialize .call (this);
127
176
 
177
+ const browser = this .getBrowser ();
178
+
179
+ if (browser .getContext () .getVersion () < 2)
180
+ return;
181
+
182
+ // Create GL stuff.
183
+
184
+ this .volumeTexture = this .createTexture ();
185
+
186
+ // Initialize fields.
187
+
128
188
  this ._direction .addInterest ("set_direction__", this);
129
189
 
130
190
  this ._coordIndex .addFieldInterest (this .volumeNode ._coordIndex);
@@ -142,184 +202,86 @@ function (Fields,
142
202
  this .set_direction__ ();
143
203
  this .set_geometry__ ();
144
204
  },
145
- set_direction__: function ()
205
+ set_direction__: (function ()
146
206
  {
147
- this .direction .assign (this ._direction .getValue ()) .normalize ();
207
+ const direction = new Vector3 (0, 0, 0);
148
208
 
149
- if (this .direction .equals (Vector3 .Zero))
150
- this .getRandomVelocity = this .getSphericalRandomVelocity;
151
- else
152
- delete this .getRandomVelocity;
153
- },
209
+ return function ()
210
+ {
211
+ direction .assign (this ._direction .getValue ()) .normalize ();
212
+
213
+ this .setUniform ("uniform3f", "direction", direction .x, direction .y, direction .z);
214
+ };
215
+ })(),
154
216
  set_geometry__: (function ()
155
217
  {
156
- var
218
+ const
157
219
  vertex1 = new Vector3 (0, 0, 0),
158
220
  vertex2 = new Vector3 (0, 0, 0),
159
221
  vertex3 = new Vector3 (0, 0, 0);
160
222
 
161
223
  return function ()
162
224
  {
163
- var
164
- areaSoFar = 0,
165
- areaSoFarArray = this .areaSoFarArray,
166
- normals = this .volumeNode .getNormals () .getValue (),
167
- vertices = this .volumeNode .getVertices () .getValue ();
168
-
169
- this .normals = normals;
170
- this .vertices = vertices;
171
-
172
- areaSoFarArray .length = 1;
173
-
174
- for (var i = 0, length = vertices .length; i < length; i += 12)
225
+ const
226
+ gl = this .getBrowser () .getContext (),
227
+ vertices = this .volumeNode .getVertices () .getValue (),
228
+ normals = this .volumeNode .getNormals () .getValue (),
229
+ hierarchy = new BVH (vertices, normals) .toArray ([ ]),
230
+ numVertices = vertices .length / 4,
231
+ numNormals = normals .length / 3,
232
+ numAreaSoFar = numVertices / 3 + 1,
233
+ hierarchyLength = hierarchy .length / 4,
234
+ volumeArraySize = Math .ceil (Math .sqrt (numAreaSoFar + numVertices + numVertices + hierarchyLength));
235
+
236
+ const
237
+ verticesIndex = numAreaSoFar,
238
+ normalsIndex = verticesIndex + numVertices,
239
+ hierarchyIndex = normalsIndex + numNormals;
240
+
241
+ let volumeArray = this .volumeArray;
242
+
243
+ if (volumeArray .length < volumeArraySize * volumeArraySize * 4)
244
+ volumeArray = this .volumeArray = new Float32Array (volumeArraySize * volumeArraySize * 4);
245
+
246
+ let areaSoFar = 0;
247
+
248
+ for (let i = 0, length = vertices .length; i < length; i += 12)
175
249
  {
176
250
  vertex1 .set (vertices [i], vertices [i + 1], vertices [i + 2]);
177
251
  vertex2 .set (vertices [i + 4], vertices [i + 5], vertices [i + 6]);
178
252
  vertex3 .set (vertices [i + 8], vertices [i + 9], vertices [i + 10]);
179
253
 
180
- areaSoFar += Triangle3 .area (vertex1, vertex2, vertex3);
181
- areaSoFarArray .push (areaSoFar);
254
+ volumeArray [i / 3 + 4] = areaSoFar += Triangle3 .area (vertex1, vertex2, vertex3);
182
255
  }
183
256
 
184
- this .bvh = new BVH (vertices, normals);
185
- };
186
- })(),
187
- getRandomPosition: (function ()
188
- {
189
- var
190
- point = new Vector3 (0, 0, 0),
191
- normal = new Vector3 (0, 0, 0),
192
- rotation = new Rotation4 (0, 0, 1, 0),
193
- line = new Line3 (Vector3 .Zero, Vector3 .zAxis),
194
- plane = new Plane3 (Vector3 .Zero, Vector3 .zAxis),
195
- intersections = [ ],
196
- sorter = new QuickSort (intersections, PlaneCompare);
197
-
198
- function PlaneCompare (a, b)
199
- {
200
- return plane .getDistanceToPoint (a) < plane .getDistanceToPoint (b);
201
- }
257
+ volumeArray .set (vertices, verticesIndex * 4);
202
258
 
203
- return function (position)
204
- {
205
- // Get random point on surface
206
-
207
- // Determine index0.
208
-
209
- var
210
- areaSoFarArray = this .areaSoFarArray,
211
- length = areaSoFarArray .length,
212
- fraction = Math .random () * areaSoFarArray .at (-1),
213
- index0 = 0;
214
-
215
- if (length == 1 || fraction <= areaSoFarArray [0])
259
+ for (let s = normalsIndex * 4, n = 0, l = normals .length; n < l; s += 4, n += 3)
216
260
  {
217
- index0 = 0;
218
- }
219
- else if (fraction >= areaSoFarArray .at (-1))
220
- {
221
- index0 = length - 2;
222
- }
223
- else
224
- {
225
- var index = Algorithm .upperBound (areaSoFarArray, 0, length, fraction, Algorithm .less);
226
-
227
- if (index < length)
228
- {
229
- index0 = index - 1;
230
- }
231
- else
232
- {
233
- index0 = 0;
234
- }
261
+ volumeArray [s + 0] = normals [n + 0];
262
+ volumeArray [s + 1] = normals [n + 1];
263
+ volumeArray [s + 2] = normals [n + 2];
235
264
  }
236
265
 
237
- // Random barycentric coordinates.
266
+ volumeArray .set (hierarchy, hierarchyIndex * 4);
238
267
 
239
- var
240
- u = Math .random (),
241
- v = Math .random ();
268
+ this .setUniform ("uniform1i", "verticesIndex", verticesIndex);
269
+ this .setUniform ("uniform1i", "normalsIndex", normalsIndex);
270
+ this .setUniform ("uniform1i", "hierarchyIndex", hierarchyIndex);
271
+ this .setUniform ("uniform1i", "hierarchyRoot", hierarchyIndex + hierarchyLength - 1);
242
272
 
243
- if (u + v > 1)
273
+ if (volumeArraySize)
244
274
  {
245
- u = 1 - u;
246
- v = 1 - v;
275
+ gl .bindTexture (gl .TEXTURE_2D, this .volumeTexture);
276
+ gl .texImage2D (gl .TEXTURE_2D, 0, gl .RGBA32F, volumeArraySize, volumeArraySize, 0, gl .RGBA, gl .FLOAT, volumeArray);
247
277
  }
248
-
249
- var t = 1 - u - v;
250
-
251
- // Interpolate and determine random point on surface and normal.
252
-
253
- var
254
- i = index0 * 12,
255
- vertices = this .vertices;
256
-
257
- point .x = u * vertices [i] + v * vertices [i + 4] + t * vertices [i + 8];
258
- point .y = u * vertices [i + 1] + v * vertices [i + 5] + t * vertices [i + 9];
259
- point .z = u * vertices [i + 2] + v * vertices [i + 6] + t * vertices [i + 10];
260
-
261
- var
262
- i = index0 * 9,
263
- normals = this .normals;
264
-
265
- normal .x = u * normals [i] + v * normals [i + 3] + t * normals [i + 6];
266
- normal .y = u * normals [i + 1] + v * normals [i + 4] + t * normals [i + 7];
267
- normal .z = u * normals [i + 2] + v * normals [i + 5] + t * normals [i + 8];
268
-
269
- rotation .setFromToVec (Vector3 .zAxis, normal);
270
- rotation .multVecRot (this .getRandomSurfaceNormal (normal));
271
-
272
- // Setup random line throu volume for intersection text
273
- // and a plane corresponding to the line for intersection sorting.
274
-
275
- line .set (point, normal);
276
- plane .set (point, normal);
277
-
278
- // Find random point in volume.
279
-
280
- var numIntersections = this .bvh .intersectsLine (line, intersections);
281
-
282
- numIntersections -= numIntersections % 2; // We need an even count of intersections.
283
-
284
- if (numIntersections)
285
- {
286
- // Sort intersections along line with a little help from the plane.
287
-
288
- sorter .sort (0, numIntersections);
289
-
290
- // Select random intersection pair.
291
-
292
- var
293
- index = Math .round (this .getRandomValue (0, numIntersections / 2 - 1)) * 2,
294
- point0 = intersections [index],
295
- point1 = intersections [index + 1],
296
- t = Math .random ();
297
-
298
- // lerp
299
- position .x = point0 .x + (point1 .x - point0 .x) * t;
300
- position .y = point0 .y + (point1 .y - point0 .y) * t;
301
- position .z = point0 .z + (point1 .z - point0 .z) * t;
302
-
303
- return position;
304
- }
305
-
306
- // Discard point.
307
-
308
- return position .set (Number .POSITIVE_INFINITY, Number .POSITIVE_INFINITY, Number .POSITIVE_INFINITY);
309
278
  };
310
279
  })(),
311
- getRandomVelocity: function (velocity)
280
+ activateTextures: function (gl, program)
312
281
  {
313
- var
314
- direction = this .direction,
315
- speed = this .getRandomSpeed ();
316
-
317
- velocity .x = direction .x * speed;
318
- velocity .y = direction .y * speed;
319
- velocity .z = direction .z * speed;
320
-
321
- return velocity;
322
- },
282
+ gl .activeTexture (gl .TEXTURE0 + program .volumeTextureUnit);
283
+ gl .bindTexture (gl .TEXTURE_2D, this .volumeTexture);
284
+ },
323
285
  });
324
286
 
325
287
  return VolumeEmitter;