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
@@ -49,6 +49,7 @@
49
49
 
50
50
  define ([
51
51
  "x_ite/Fields",
52
+ "x_ite/Rendering/VertexArray",
52
53
  "x_ite/Components/Core/X3DNode",
53
54
  "x_ite/Base/X3DConstants",
54
55
  "x_ite/Browser/Core/Shading",
@@ -61,6 +62,7 @@ define ([
61
62
  "standard/Math/Algorithm",
62
63
  ],
63
64
  function (Fields,
65
+ VertexArray,
64
66
  X3DNode,
65
67
  X3DConstants,
66
68
  Shading,
@@ -108,13 +110,12 @@ function (Fields,
108
110
  this .max = new Vector3 (0, 0, 0);
109
111
  this .bbox = new Box3 (this .min, this .max, true);
110
112
  this .solid = true;
111
- this .geometryType = 3;
112
113
  this .primitiveMode = browser .getContext () .TRIANGLES;
114
+ this .geometryType = 3;
113
115
  this .flatShading = undefined;
114
116
  this .colorMaterial = false;
115
117
  this .attribNodes = [ ];
116
- this .attribs = [ ];
117
- this .textureCoordinateNode = browser .getDefaultTextureCoordinate ();
118
+ this .attribArrays = [ ];
118
119
  this .textureCoordinateMapping = new Map ();
119
120
  this .multiTexCoords = [ ];
120
121
  this .texCoords = X3DGeometryNode .createArray ();
@@ -123,12 +124,12 @@ function (Fields,
123
124
  this .normals = X3DGeometryNode .createArray ();
124
125
  this .flatNormals = X3DGeometryNode .createArray ();
125
126
  this .vertices = X3DGeometryNode .createArray ();
127
+ this .fogCoords = false;
126
128
  this .vertexCount = 0;
129
+ this .planes = [ ];
127
130
 
128
- // This methods are configured in transfer.
129
- this .depth = Function .prototype;
130
- this .display = Function .prototype;
131
- this .displayParticles = Function .prototype;
131
+ for (let i = 0; i < 5; ++ i)
132
+ this .planes [i] = new Plane3 (Vector3 .Zero, Vector3 .zAxis);
132
133
  }
133
134
 
134
135
  // Function to select ether Array or MFFloat for color/normal/vertex arrays.
@@ -158,10 +159,10 @@ function (Fields,
158
159
 
159
160
  array .shrinkToFit = function ()
160
161
  {
161
- if (this .length !== this .typedArray .length)
162
- this .typedArray = new Float32Array (this);
163
- else
162
+ if (this .length === this .typedArray .length)
164
163
  this .typedArray .set (this);
164
+ else
165
+ this .typedArray = new Float32Array (this);
165
166
  };
166
167
 
167
168
  return array;
@@ -180,24 +181,26 @@ function (Fields,
180
181
  {
181
182
  X3DNode .prototype .initialize .call (this);
182
183
 
184
+ const
185
+ browser = this .getBrowser (),
186
+ gl = browser .getContext ();
187
+
183
188
  this .isLive () .addInterest ("set_live__", this);
184
189
 
185
190
  this .addInterest ("requestRebuild", this);
186
191
  this ._rebuild .addInterest ("rebuild", this);
187
192
 
188
- const gl = this .getBrowser () .getContext ();
189
-
190
- this .frontFace = gl .CCW;
191
- this .attribBuffers = [ ];
192
- this .texCoordBuffers = [ ];
193
- this .fogDepthBuffer = gl .createBuffer ();
194
- this .colorBuffer = gl .createBuffer ();
195
- this .normalBuffer = gl .createBuffer ();
196
- this .vertexBuffer = gl .createBuffer ();
197
- this .planes = [ ];
198
-
199
- for (let i = 0; i < 5; ++ i)
200
- this .planes [i] = new Plane3 (Vector3 .Zero, Vector3 .zAxis);
193
+ this .frontFace = gl .CCW;
194
+ this .backFace = new Map ([[gl .CCW, gl .CW], [gl .CW, gl .CCW]]);
195
+ this .attribBuffers = [ ];
196
+ this .textureCoordinateNode = browser .getDefaultTextureCoordinate ();
197
+ this .texCoordBuffers = Array .from ({length: browser .getMaxTextures ()}, () => gl .createBuffer ());
198
+ this .fogDepthBuffer = gl .createBuffer ();
199
+ this .colorBuffer = gl .createBuffer ();
200
+ this .normalBuffer = gl .createBuffer ();
201
+ this .vertexBuffer = gl .createBuffer ();
202
+ this .vertexArrayObject = new VertexArray ();
203
+ this .shadowArrayObject = new VertexArray ();
201
204
 
202
205
  this .set_live__ ();
203
206
  },
@@ -265,7 +268,9 @@ function (Fields,
265
268
  },
266
269
  setCCW: function (value)
267
270
  {
268
- this .frontFace = value ? this .getBrowser () .getContext () .CCW : this .getBrowser () .getContext () .CW;
271
+ const gl = this .getBrowser () .getContext ();
272
+
273
+ this .frontFace = value ? gl .CCW : gl .CW;
269
274
  },
270
275
  getAttrib: function ()
271
276
  {
@@ -273,7 +278,11 @@ function (Fields,
273
278
  },
274
279
  getAttribs: function ()
275
280
  {
276
- return this .attribs;
281
+ return this .attribArrays;
282
+ },
283
+ getAttribBuffers: function ()
284
+ {
285
+ return this .attribBuffers;
277
286
  },
278
287
  setFogDepths: function (value)
279
288
  {
@@ -345,6 +354,14 @@ function (Fields,
345
354
  {
346
355
  return this .vertices;
347
356
  },
357
+ updateVertexArrays: function ()
358
+ {
359
+ this .vertexArrayObject .update ();
360
+ this .shadowArrayObject .update ();
361
+
362
+ this .updateParticlesShadow = true;
363
+ this .updateParticles = true;
364
+ },
348
365
  buildTexCoords: function ()
349
366
  {
350
367
  const texCoords = this .texCoords;
@@ -372,7 +389,7 @@ function (Fields,
372
389
  texCoords .shrinkToFit ();
373
390
  }
374
391
 
375
- return texCoords;
392
+ this .getMultiTexCoords () .push (texCoords);
376
393
  },
377
394
  getTexCoordParams: (function ()
378
395
  {
@@ -456,6 +473,14 @@ function (Fields,
456
473
 
457
474
  return normals_;
458
475
  },
476
+ transformLine: function (hitRay)
477
+ {
478
+ // Apply sceen nodes transformation in place here.
479
+ },
480
+ transformMatrix: function (hitRay)
481
+ {
482
+ // Apply sceen nodes transformation in place here.
483
+ },
459
484
  isClipped: function (point, clipPlanes)
460
485
  {
461
486
  return clipPlanes .some (function (clipPlane)
@@ -463,15 +488,11 @@ function (Fields,
463
488
  return clipPlane .isClipped (point);
464
489
  });
465
490
  },
466
- transformLine: function (hitRay)
491
+ intersectsLine: function (hitRay, renderObject, invModelViewMatrix, appearanceNode, intersections)
467
492
  {
468
- // Apply sceen nodes transformation in place here.
493
+ return this .intersectsLineWithGeometry (hitRay, renderObject .getModelViewMatrix () .get (), renderObject .getLocalObjects (), intersections);
469
494
  },
470
- transformMatrix: function (hitRay)
471
- {
472
- // Apply sceen nodes transformation in place here.
473
- },
474
- intersectsLine: (function ()
495
+ intersectsLineWithGeometry: (function ()
475
496
  {
476
497
  const
477
498
  modelViewMatrix = new Matrix4 (),
@@ -481,85 +502,118 @@ function (Fields,
481
502
  v2 = new Vector3 (0, 0, 0),
482
503
  clipPoint = new Vector3 (0, 0, 0);
483
504
 
484
- return function (hitRay, clipPlanes, modelViewMatrix_, intersections)
505
+ return function (hitRay, matrix, clipPlanes, intersections)
485
506
  {
486
- try
507
+ if (this .intersectsBBox (hitRay))
487
508
  {
488
- if (this .intersectsBBox (hitRay))
489
- {
490
- this .transformLine (hitRay); // Apply screen transformations from screen nodes.
491
- this .transformMatrix (modelViewMatrix .assign (modelViewMatrix_)); // Apply screen transformations from screen nodes.
509
+ this .transformLine (hitRay); // Apply screen transformations from screen nodes.
510
+ this .transformMatrix (modelViewMatrix .assign (matrix)); // Apply screen transformations from screen nodes.
492
511
 
493
- const
494
- texCoords = this .multiTexCoords [0] .getValue (),
495
- normals = this .normals .getValue (),
496
- vertices = this .vertices .getValue ();
512
+ const
513
+ texCoords = this .multiTexCoords [0] .getValue (),
514
+ normals = this .normals .getValue (),
515
+ vertices = this .vertices .getValue (),
516
+ vertexCount = this .vertexCount;
497
517
 
498
- for (let i = 0, length = this .vertexCount; i < length; i += 3)
499
- {
500
- const i4 = i * 4;
518
+ for (let i = 0; i < vertexCount; i += 3)
519
+ {
520
+ const i4 = i * 4;
501
521
 
502
- v0 .x = vertices [i4]; v0 .y = vertices [i4 + 1]; v0 .z = vertices [i4 + 2];
503
- v1 .x = vertices [i4 + 4]; v1 .y = vertices [i4 + 5]; v1 .z = vertices [i4 + 6];
504
- v2 .x = vertices [i4 + 8]; v2 .y = vertices [i4 + 9]; v2 .z = vertices [i4 + 10];
522
+ v0 .x = vertices [i4]; v0 .y = vertices [i4 + 1]; v0 .z = vertices [i4 + 2];
523
+ v1 .x = vertices [i4 + 4]; v1 .y = vertices [i4 + 5]; v1 .z = vertices [i4 + 6];
524
+ v2 .x = vertices [i4 + 8]; v2 .y = vertices [i4 + 9]; v2 .z = vertices [i4 + 10];
505
525
 
506
- if (hitRay .intersectsTriangle (v0, v1, v2, uvt))
507
- {
508
- // Get barycentric coordinates.
526
+ if (hitRay .intersectsTriangle (v0, v1, v2, uvt))
527
+ {
528
+ // Get barycentric coordinates.
509
529
 
510
- const
511
- u = uvt .u,
512
- v = uvt .v,
513
- t = uvt .t;
530
+ const
531
+ u = uvt .u,
532
+ v = uvt .v,
533
+ t = uvt .t;
514
534
 
515
- // Determine vectors for X3DPointingDeviceSensors.
535
+ // Determine vectors for X3DPointingDeviceSensors.
516
536
 
517
- const point = new Vector3 (t * vertices [i4] + u * vertices [i4 + 4] + v * vertices [i4 + 8],
518
- t * vertices [i4 + 1] + u * vertices [i4 + 5] + v * vertices [i4 + 9],
519
- t * vertices [i4 + 2] + u * vertices [i4 + 6] + v * vertices [i4 + 10]);
537
+ const point = new Vector3 (t * vertices [i4] + u * vertices [i4 + 4] + v * vertices [i4 + 8],
538
+ t * vertices [i4 + 1] + u * vertices [i4 + 5] + v * vertices [i4 + 9],
539
+ t * vertices [i4 + 2] + u * vertices [i4 + 6] + v * vertices [i4 + 10]);
520
540
 
541
+ if (clipPlanes .length)
542
+ {
521
543
  if (this .isClipped (modelViewMatrix .multVecMatrix (clipPoint .assign (point)), clipPlanes))
522
544
  continue;
545
+ }
523
546
 
524
- const texCoord = new Vector2 (t * texCoords [i4] + u * texCoords [i4 + 4] + v * texCoords [i4 + 8],
525
- t * texCoords [i4 + 1] + u * texCoords [i4 + 5] + v * texCoords [i4 + 9]);
547
+ const texCoord = new Vector2 (t * texCoords [i4] + u * texCoords [i4 + 4] + v * texCoords [i4 + 8],
548
+ t * texCoords [i4 + 1] + u * texCoords [i4 + 5] + v * texCoords [i4 + 9]);
526
549
 
527
- const i3 = i * 3;
550
+ const i3 = i * 3;
528
551
 
529
- const normal = new Vector3 (t * normals [i3] + u * normals [i3 + 3] + v * normals [i3 + 6],
530
- t * normals [i3 + 1] + u * normals [i3 + 4] + v * normals [i3 + 7],
531
- t * normals [i3 + 2] + u * normals [i3 + 5] + v * normals [i3 + 8]);
552
+ const normal = new Vector3 (t * normals [i3] + u * normals [i3 + 3] + v * normals [i3 + 6],
553
+ t * normals [i3 + 1] + u * normals [i3 + 4] + v * normals [i3 + 7],
554
+ t * normals [i3 + 2] + u * normals [i3 + 5] + v * normals [i3 + 8]);
532
555
 
533
- intersections .push ({ texCoord: texCoord, normal: normal, point: this .getMatrix () .multVecMatrix (point) });
534
- }
556
+ intersections .push ({ texCoord: texCoord, normal: normal, point: this .getMatrix () .multVecMatrix (point) });
535
557
  }
536
558
  }
537
-
538
- return intersections .length;
539
- }
540
- catch (error)
541
- {
542
- console .log (error);
543
- return false;
544
559
  }
560
+
561
+ return intersections .length;
562
+ };
563
+ })(),
564
+ getPlanesWithOffset: (function ()
565
+ {
566
+ const
567
+ min = new Vector3 (0, 0, 0),
568
+ max = new Vector3 (0, 0, 0),
569
+ planes = [ ];
570
+
571
+ for (let i = 0; i < 5; ++ i)
572
+ planes [i] = new Plane3 (Vector3 .Zero, Vector3 .zAxis);
573
+
574
+ return function (minX, minY, minZ, maxX, maxY, maxZ)
575
+ {
576
+ min .set (minX, minY, minZ);
577
+ max .set (maxX, maxY, maxZ);
578
+
579
+ for (let i = 0; i < 5; ++ i)
580
+ planes [i] .set (i % 2 ? min : max, boxNormals [i]);
581
+
582
+ return planes;
545
583
  };
546
584
  })(),
547
585
  intersectsBBox: (function ()
548
586
  {
549
587
  const intersection = new Vector3 (0, 0, 0);
550
588
 
551
- return function (hitRay, offset = 0)
589
+ return function (hitRay, offsets)
552
590
  {
553
- const
554
- planes = this .planes,
555
- min = this .min,
556
- max = this .max,
557
- minX = min .x - offset,
558
- maxX = max .x + offset,
559
- minY = min .y - offset,
560
- maxY = max .y + offset,
561
- minZ = min .z - offset,
562
- maxZ = max .z + offset;
591
+ if (offsets)
592
+ {
593
+ var
594
+ min = this .min,
595
+ max = this .max,
596
+ minX = min .x - offsets .x,
597
+ maxX = max .x + offsets .x,
598
+ minY = min .y - offsets .y,
599
+ maxY = max .y + offsets .y,
600
+ minZ = min .z - offsets .z,
601
+ maxZ = max .z + offsets .z,
602
+ planes = this .getPlanesWithOffset (minX, minY, minZ, maxX, maxY, maxZ);
603
+ }
604
+ else
605
+ {
606
+ var
607
+ min = this .min,
608
+ max = this .max,
609
+ minX = min .x,
610
+ maxX = max .x,
611
+ minY = min .y,
612
+ maxY = max .y,
613
+ minZ = min .z,
614
+ maxZ = max .z,
615
+ planes = this .planes;
616
+ }
563
617
 
564
618
  // front
565
619
  if (planes [0] .intersectsLine (hitRay, intersection))
@@ -615,50 +669,42 @@ function (Fields,
615
669
 
616
670
  return function (box, clipPlanes, modelViewMatrix)
617
671
  {
618
- try
672
+ if (box .intersectsBox (this .bbox))
619
673
  {
620
- if (box .intersectsBox (this .bbox))
621
- {
622
- box .multRight (invMatrix .assign (this .getMatrix ()) .inverse ());
674
+ box .multRight (invMatrix .assign (this .getMatrix ()) .inverse ());
623
675
 
624
- this .transformMatrix (modelViewMatrix); // Apply screen transformations from screen nodes.
676
+ this .transformMatrix (modelViewMatrix); // Apply screen transformations from screen nodes.
625
677
 
626
- const vertices = this .vertices .getValue ();
678
+ const vertices = this .vertices .getValue ();
627
679
 
628
- for (let i = 0, length = this .vertexCount; i < length; i += 3)
629
- {
630
- const i4 = i * 4;
680
+ for (let i = 0, length = this .vertexCount; i < length; i += 3)
681
+ {
682
+ const i4 = i * 4;
631
683
 
632
- v0 .x = vertices [i4]; v0 .y = vertices [i4 + 1]; v0 .z = vertices [i4 + 2];
633
- v1 .x = vertices [i4 + 4]; v1 .y = vertices [i4 + 5]; v1 .z = vertices [i4 + 6];
634
- v2 .x = vertices [i4 + 8]; v2 .y = vertices [i4 + 9]; v2 .z = vertices [i4 + 10];
684
+ v0 .x = vertices [i4]; v0 .y = vertices [i4 + 1]; v0 .z = vertices [i4 + 2];
685
+ v1 .x = vertices [i4 + 4]; v1 .y = vertices [i4 + 5]; v1 .z = vertices [i4 + 6];
686
+ v2 .x = vertices [i4 + 8]; v2 .y = vertices [i4 + 9]; v2 .z = vertices [i4 + 10];
635
687
 
636
- if (box .intersectsTriangle (v0, v1, v2))
688
+ if (box .intersectsTriangle (v0, v1, v2))
689
+ {
690
+ if (clipPlanes .length)
637
691
  {
638
- if (clipPlanes .length)
639
- {
640
- if (this .isClipped (modelViewMatrix .multVecMatrix (clipPoint .assign (v0)), clipPlanes))
641
- continue;
642
-
643
- if (this .isClipped (modelViewMatrix .multVecMatrix (clipPoint .assign (v1)), clipPlanes))
644
- continue;
692
+ if (this .isClipped (modelViewMatrix .multVecMatrix (clipPoint .assign (v0)), clipPlanes))
693
+ continue;
645
694
 
646
- if (this .isClipped (modelViewMatrix .multVecMatrix (clipPoint .assign (v2)), clipPlanes))
647
- continue;
648
- }
695
+ if (this .isClipped (modelViewMatrix .multVecMatrix (clipPoint .assign (v1)), clipPlanes))
696
+ continue;
649
697
 
650
- return true;
698
+ if (this .isClipped (modelViewMatrix .multVecMatrix (clipPoint .assign (v2)), clipPlanes))
699
+ continue;
651
700
  }
701
+
702
+ return true;
652
703
  }
653
704
  }
654
-
655
- return false;
656
- }
657
- catch (error)
658
- {
659
- console .log (error);
660
- return false;
661
705
  }
706
+
707
+ return false;
662
708
  };
663
709
  })(),
664
710
  set_live__: function ()
@@ -681,7 +727,9 @@ function (Fields,
681
727
  if (this .geometryType < 2)
682
728
  return;
683
729
 
684
- const flatShading = this .getBrowser () .getBrowserOptions () .getShading () === Shading .FLAT;
730
+ const
731
+ browser = this .getBrowser (),
732
+ flatShading = browser .getBrowserOptions () .getShading () === Shading .FLAT;
685
733
 
686
734
  if (flatShading === this .flatShading)
687
735
  return;
@@ -690,7 +738,7 @@ function (Fields,
690
738
 
691
739
  // Generate flat normals if needed.
692
740
 
693
- const gl = this .getBrowser () .getContext ();
741
+ const gl = browser .getContext ();
694
742
 
695
743
  if (flatShading)
696
744
  {
@@ -723,7 +771,7 @@ function (Fields,
723
771
  // Transfer normals.
724
772
 
725
773
  gl .bindBuffer (gl .ARRAY_BUFFER, this .normalBuffer);
726
- gl .bufferData (gl .ARRAY_BUFFER, flatShading ? this .flatNormals .getValue () : this .normals .getValue (), gl .STATIC_DRAW);
774
+ gl .bufferData (gl .ARRAY_BUFFER, flatShading ? this .flatNormals .getValue () : this .normals .getValue (), gl .DYNAMIC_DRAW);
727
775
  };
728
776
  })(),
729
777
  requestRebuild: function ()
@@ -741,8 +789,8 @@ function (Fields,
741
789
 
742
790
  // Shrink arrays before transfer to graphics card.
743
791
 
744
- for (const attrib of this .attribs)
745
- attrib .shrinkToFit ();
792
+ for (const attribArray of this .attribArrays)
793
+ attribArray .shrinkToFit ();
746
794
 
747
795
  for (const multiTexCoord of this .multiTexCoords)
748
796
  multiTexCoord .shrinkToFit ();
@@ -786,19 +834,17 @@ function (Fields,
786
834
 
787
835
  // Generate texCoord if needed.
788
836
 
789
- if (this .geometryType > 1)
790
- {
791
- if (this .multiTexCoords .length === 0)
792
- this .multiTexCoords .push (this .buildTexCoords ());
837
+ if (this .multiTexCoords .length === 0)
838
+ this .buildTexCoords ();
793
839
 
794
- const
795
- last = this .multiTexCoords .length - 1,
796
- length = this .getBrowser () .getMaxTextures ();
840
+ if (this .multiTexCoords .length)
841
+ {
842
+ const maxTextures = this .getBrowser () .getMaxTextures ();
797
843
 
798
- for (let i = this .multiTexCoords .length; i < length; ++ i)
799
- this .multiTexCoords [i] = this .multiTexCoords [last];
844
+ for (let i = this .multiTexCoords .length; i < maxTextures; ++ i)
845
+ this .multiTexCoords [i] = this .multiTexCoords .at (-1);
800
846
 
801
- this .multiTexCoords .length = length;
847
+ this .multiTexCoords .length = maxTextures;
802
848
  }
803
849
 
804
850
  // Upload normals or flat normals.
@@ -808,6 +854,10 @@ function (Fields,
808
854
  // Upload arrays.
809
855
 
810
856
  this .transfer ();
857
+
858
+ // Setup render functions.
859
+
860
+ this .setRenderFunctions ();
811
861
  };
812
862
  })(),
813
863
  clear: function ()
@@ -817,19 +867,19 @@ function (Fields,
817
867
  this .min .set (Number .POSITIVE_INFINITY, Number .POSITIVE_INFINITY, Number .POSITIVE_INFINITY);
818
868
  this .max .set (Number .NEGATIVE_INFINITY, Number .NEGATIVE_INFINITY, Number .NEGATIVE_INFINITY);
819
869
 
820
- // Create attrib arrays.
870
+ // Create attribArray arrays.
821
871
  {
822
- const attribs = this .attribs;
872
+ const attribArrays = this .attribArrays;
823
873
 
824
- for (const attrib of attribs)
825
- attrib .length = 0;
874
+ for (const attribArray of attribArrays)
875
+ attribArray .length = 0;
826
876
 
827
877
  const length = this .attribNodes .length;
828
878
 
829
- for (let a = attribs .length; a < length; ++ a)
830
- attribs [a] = X3DGeometryNode .createArray ();
879
+ for (let a = attribArrays .length; a < length; ++ a)
880
+ attribArrays [a] = X3DGeometryNode .createArray ();
831
881
 
832
- attribs .length = length;
882
+ attribArrays .length = length;
833
883
  }
834
884
 
835
885
  // Buffer
@@ -846,119 +896,117 @@ function (Fields,
846
896
  },
847
897
  transfer: function ()
848
898
  {
849
- const
850
- gl = this .getBrowser () .getContext (),
851
- count = this .vertices .length / 4;
899
+ const gl = this .getBrowser () .getContext ();
852
900
 
853
- // Transfer attribs.
901
+ // Transfer attribArrays.
854
902
 
855
- for (let i = this .attribBuffers .length, length = this .attribs .length; i < length; ++ i)
903
+ for (let i = this .attribBuffers .length, length = this .attribArrays .length; i < length; ++ i)
856
904
  this .attribBuffers .push (gl .createBuffer ());
857
905
 
858
- for (let i = 0, length = this .attribs .length; i < length; ++ i)
906
+ for (let i = 0, length = this .attribArrays .length; i < length; ++ i)
859
907
  {
860
908
  gl .bindBuffer (gl .ARRAY_BUFFER, this .attribBuffers [i]);
861
- gl .bufferData (gl .ARRAY_BUFFER, this .attribs [i] .getValue (), gl .STATIC_DRAW);
909
+ gl .bufferData (gl .ARRAY_BUFFER, this .attribArrays [i] .getValue (), gl .DYNAMIC_DRAW);
862
910
  }
863
911
 
864
912
  // Transfer fog depths.
865
913
 
914
+ const lastFogCoords = this .fogCoords;
915
+
866
916
  gl .bindBuffer (gl .ARRAY_BUFFER, this .fogDepthBuffer);
867
- gl .bufferData (gl .ARRAY_BUFFER, this .fogDepths .getValue (), gl .STATIC_DRAW);
868
- this .fogCoords = !! (this .fogDepths .length);
917
+ gl .bufferData (gl .ARRAY_BUFFER, this .fogDepths .getValue (), gl .DYNAMIC_DRAW);
918
+
919
+ this .fogCoords = !! this .fogDepths .length;
920
+
921
+ if (this .fogCoords !== lastFogCoords)
922
+ this .updateVertexArrays ();
923
+
869
924
  // Transfer colors.
870
925
 
926
+ const lastColorMaterial = this .colorMaterial;
927
+
871
928
  gl .bindBuffer (gl .ARRAY_BUFFER, this .colorBuffer);
872
- gl .bufferData (gl .ARRAY_BUFFER, this .colors .getValue (), gl .STATIC_DRAW);
873
- this .colorMaterial = !! (this .colors .length);
929
+ gl .bufferData (gl .ARRAY_BUFFER, this .colors .getValue (), gl .DYNAMIC_DRAW);
874
930
 
875
- // Transfer multiTexCoords.
931
+ this .colorMaterial = !! this .colors .length;
932
+
933
+ if (this .colorMaterial !== lastColorMaterial)
934
+ this .updateVertexArrays ();
876
935
 
877
- for (let i = this .texCoordBuffers .length, length = this .multiTexCoords .length; i < length; ++ i)
878
- this .texCoordBuffers .push (gl .createBuffer ());
936
+ // Transfer multiTexCoords.
879
937
 
880
938
  for (let i = 0, length = this .multiTexCoords .length; i < length; ++ i)
881
939
  {
882
940
  gl .bindBuffer (gl .ARRAY_BUFFER, this .texCoordBuffers [i]);
883
- gl .bufferData (gl .ARRAY_BUFFER, this .multiTexCoords [i] .getValue (), gl .STATIC_DRAW);
941
+ gl .bufferData (gl .ARRAY_BUFFER, this .multiTexCoords [i] .getValue (), gl .DYNAMIC_DRAW);
884
942
  }
885
943
 
886
944
  // Transfer vertices.
887
945
 
888
946
  gl .bindBuffer (gl .ARRAY_BUFFER, this .vertexBuffer);
889
- gl .bufferData (gl .ARRAY_BUFFER, this .vertices .getValue (), gl .STATIC_DRAW);
890
- this .vertexCount = count;
891
-
892
- // Setup render functions.
947
+ gl .bufferData (gl .ARRAY_BUFFER, this .vertices .getValue (), gl .DYNAMIC_DRAW);
893
948
 
949
+ this .vertexCount = this .vertices .length / 4;
950
+ },
951
+ setRenderFunctions: function ()
952
+ {
894
953
  if (this .vertexCount)
895
954
  {
896
955
  // Use default render functions.
956
+
897
957
  delete this .depth;
898
958
  delete this .display;
959
+ delete this .displayParticlesDepth;
899
960
  delete this .displayParticles;
900
961
  }
901
962
  else
902
963
  {
903
964
  // Use no render function.
904
- this .depth = Function .prototype;
905
- this .display = Function .prototype;
906
- this .displayParticles = Function .prototype;
965
+
966
+ this .depth = Function .prototype;
967
+ this .display = Function .prototype;
968
+ this .displayParticlesDepth = Function .prototype;
969
+ this .displayParticles = Function .prototype;
907
970
  }
908
- },
971
+ },
909
972
  traverse: function (type, renderObject)
910
973
  { },
911
974
  depth: function (gl, context, shaderNode)
912
975
  {
913
- // Setup vertex attributes.
914
-
915
- // Attribs in depth rendering are not supported.
916
- //for (let i = 0, length = attribNodes .length; i < length; ++ i)
917
- // attribNodes [i] .enable (gl, shaderNode, attribBuffers [i]);
918
-
919
- shaderNode .enableVertexAttribute (gl, this .vertexBuffer);
920
-
921
- //for (let i = 0, length = attribNodes .length; i < length; ++ i)
922
- // attribNodes [i] .disable (gl, shaderNode);
976
+ if (this .shadowArrayObject .enable (gl, shaderNode))
977
+ shaderNode .enableVertexAttribute (gl, this .vertexBuffer, 0, 0);
923
978
 
924
979
  gl .drawArrays (this .primitiveMode, 0, this .vertexCount);
925
980
  },
926
981
  display: function (gl, context)
927
982
  {
928
- try
929
- {
930
- const
931
- appearanceNode = context .shapeNode .getAppearance (),
932
- materialNode = appearanceNode .materialNode,
933
- backMaterialNode = appearanceNode .backMaterialNode,
934
- frontShaderNode = appearanceNode .shaderNode || materialNode .getShader (context .browser, context .shadow);
935
-
936
- if (this .solid || !backMaterialNode || frontShaderNode .wireframe)
937
- {
938
- this .displayGeometry (gl, context, appearanceNode, frontShaderNode, true, true);
939
- }
940
- else
941
- {
942
- const backShaderNode = appearanceNode .shaderNode || backMaterialNode .getShader (context .browser, context .shadow)
983
+ const
984
+ appearanceNode = context .shapeNode .getAppearance (),
985
+ materialNode = appearanceNode .getMaterial (),
986
+ backMaterialNode = appearanceNode .getBackMaterial (),
987
+ frontShaderNode = appearanceNode .getShader () || materialNode .getShader (context .browser, context .shadow);
943
988
 
944
- this .displayGeometry (gl, context, appearanceNode, backShaderNode, true, false);
945
- this .displayGeometry (gl, context, appearanceNode, frontShaderNode, false, true);
946
- }
989
+ if (this .solid || ! backMaterialNode || frontShaderNode .getWireframe ())
990
+ {
991
+ this .displayGeometry (gl, context, appearanceNode, frontShaderNode, true, true);
947
992
  }
948
- catch (error)
993
+ else
949
994
  {
950
- // Catch error from setLocalUniforms.
951
- console .log (error);
995
+ const backShaderNode = appearanceNode .getShader () || backMaterialNode .getShader (context .browser, context .shadow)
996
+
997
+ this .displayGeometry (gl, context, appearanceNode, backShaderNode, true, false);
998
+ this .displayGeometry (gl, context, appearanceNode, frontShaderNode, false, true);
952
999
  }
953
1000
  },
954
1001
  displayGeometry: function (gl, context, appearanceNode, shaderNode, back, front)
955
1002
  {
956
- if (shaderNode .getValid ())
1003
+ if (shaderNode .isValid ())
957
1004
  {
958
1005
  const
959
- blendModeNode = appearanceNode .blendModeNode,
1006
+ blendModeNode = appearanceNode .getBlendMode (),
960
1007
  attribNodes = this .attribNodes,
961
- attribBuffers = this .attribBuffers;
1008
+ attribBuffers = this .attribBuffers,
1009
+ primitiveMode = shaderNode .getPrimitiveMode (this .primitiveMode);
962
1010
 
963
1011
  if (blendModeNode)
964
1012
  blendModeNode .enable (gl);
@@ -968,40 +1016,34 @@ function (Fields,
968
1016
 
969
1017
  // Setup vertex attributes.
970
1018
 
971
- for (let i = 0, length = attribNodes .length; i < length; ++ i)
972
- attribNodes [i] .enable (gl, shaderNode, attribBuffers [i]);
1019
+ if (this .vertexArrayObject .enable (gl, shaderNode))
1020
+ {
1021
+ for (let i = 0, length = attribNodes .length; i < length; ++ i)
1022
+ attribNodes [i] .enable (gl, shaderNode, attribBuffers [i]);
973
1023
 
974
- if (this .fogCoords)
975
- shaderNode .enableFogDepthAttribute (gl, this .fogDepthBuffer);
1024
+ if (this .fogCoords)
1025
+ shaderNode .enableFogDepthAttribute (gl, this .fogDepthBuffer, 0, 0);
976
1026
 
977
- if (this .colorMaterial)
978
- shaderNode .enableColorAttribute (gl, this .colorBuffer);
1027
+ if (this .colorMaterial)
1028
+ shaderNode .enableColorAttribute (gl, this .colorBuffer, 0, 0);
979
1029
 
980
- shaderNode .enableTexCoordAttribute (gl, this .texCoordBuffers);
981
- shaderNode .enableNormalAttribute (gl, this .normalBuffer);
982
- shaderNode .enableVertexAttribute (gl, this .vertexBuffer);
1030
+ shaderNode .enableTexCoordAttribute (gl, this .texCoordBuffers, 0, 0);
1031
+ shaderNode .enableNormalAttribute (gl, this .normalBuffer, 0, 0);
1032
+ shaderNode .enableVertexAttribute (gl, this .vertexBuffer, 0, 0);
1033
+ }
983
1034
 
984
1035
  // Draw depending on wireframe, solid and transparent.
985
1036
 
986
- if (shaderNode .wireframe)
1037
+ if (shaderNode .getWireframe ())
987
1038
  {
988
- // Points and Wireframes.
989
-
990
- if (shaderNode .primitiveMode === gl .POINTS)
991
- {
992
- gl .drawArrays (shaderNode .primitiveMode, 0, this .vertexCount);
993
- }
994
- else
995
- {
996
- for (let i = 0, length = this .vertexCount; i < length; i += 3)
997
- gl .drawArrays (shaderNode .primitiveMode, i, 3);
998
- }
1039
+ for (let i = 0, length = this .vertexCount; i < length; i += 3)
1040
+ gl .drawArrays (primitiveMode, i, 3);
999
1041
  }
1000
1042
  else
1001
1043
  {
1002
1044
  const positiveScale = Matrix4 .prototype .determinant3 .call (context .modelViewMatrix) > 0;
1003
1045
 
1004
- gl .frontFace (positiveScale ? this .frontFace : (this .frontFace === gl .CCW ? gl .CW : gl .CCW));
1046
+ gl .frontFace (positiveScale ? this .frontFace : this .backFace .get (this .frontFace));
1005
1047
 
1006
1048
  if (context .transparent || back !== front)
1007
1049
  {
@@ -1011,10 +1053,10 @@ function (Fields,
1011
1053
 
1012
1054
  // Render back.
1013
1055
 
1014
- if (back && !this .solid)
1056
+ if (back && ! this .solid)
1015
1057
  {
1016
1058
  gl .cullFace (gl .FRONT);
1017
- gl .drawArrays (shaderNode .primitiveMode, 0, this .vertexCount);
1059
+ gl .drawArrays (primitiveMode, 0, this .vertexCount);
1018
1060
  }
1019
1061
 
1020
1062
  // Render front.
@@ -1022,7 +1064,7 @@ function (Fields,
1022
1064
  if (front)
1023
1065
  {
1024
1066
  gl .cullFace (gl .BACK);
1025
- gl .drawArrays (shaderNode .primitiveMode, 0, this .vertexCount);
1067
+ gl .drawArrays (primitiveMode, 0, this .vertexCount);
1026
1068
  }
1027
1069
  }
1028
1070
  else
@@ -1034,96 +1076,60 @@ function (Fields,
1034
1076
  else
1035
1077
  gl .disable (gl .CULL_FACE);
1036
1078
 
1037
- gl .drawArrays (shaderNode .primitiveMode, 0, this .vertexCount);
1079
+ gl .drawArrays (primitiveMode, 0, this .vertexCount);
1038
1080
  }
1039
1081
  }
1040
1082
 
1041
- for (const attribNode of attribNodes)
1042
- attribNode .disable (gl, shaderNode);
1043
-
1044
- if (this .fogCoords)
1045
- shaderNode .disableFogDepthAttribute (gl);
1046
-
1047
- if (this .colorMaterial)
1048
- shaderNode .disableColorAttribute (gl);
1049
-
1050
- shaderNode .disableTexCoordAttribute (gl);
1051
- shaderNode .disableNormalAttribute (gl);
1052
-
1053
1083
  if (blendModeNode)
1054
1084
  blendModeNode .disable (gl);
1055
1085
  }
1056
1086
  },
1057
- displayParticlesDepth: function (gl, context, shaderNode, particles, numParticles)
1087
+ displayParticlesDepth: function (gl, context, shaderNode, particleSystem)
1058
1088
  {
1059
- // Attribs in depth rendering are not supported:
1060
- //for (let i = 0, length = attribNodes .length; i < length; ++ i)
1061
- // attribNodes [i] .enable (gl, shaderNode, attribBuffers [i]);
1062
-
1063
- shaderNode .enableVertexAttribute (gl, this .vertexBuffer);
1064
-
1065
- // Draw depending on wireframe, solid and transparent.
1089
+ const outputParticles = particleSystem .outputParticles;
1066
1090
 
1067
- const
1068
- modelViewMatrix = context .modelViewMatrix,
1069
- x = modelViewMatrix [12],
1070
- y = modelViewMatrix [13],
1071
- z = modelViewMatrix [14];
1072
-
1073
- for (let p = 0; p < numParticles; ++ p)
1091
+ if (outputParticles .shadowArrayObject .update (this .updateParticlesShadow) .enable (gl, shaderNode))
1074
1092
  {
1075
- const particle = particles [p];
1076
-
1077
- modelViewMatrix [12] = x;
1078
- modelViewMatrix [13] = y;
1079
- modelViewMatrix [14] = z;
1093
+ const particleStride = particleSystem .particleStride;
1080
1094
 
1081
- Matrix4 .prototype .translate .call (modelViewMatrix, particle .position);
1095
+ shaderNode .enableParticleAttribute (gl, outputParticles, particleStride, particleSystem .particleOffset, 1);
1096
+ shaderNode .enableParticleMatrixAttribute (gl, outputParticles, particleStride, particleSystem .matrixOffset, 1);
1097
+ shaderNode .enableVertexAttribute (gl, this .vertexBuffer, 0, 0);
1082
1098
 
1083
- shaderNode .setParticle (gl, particle, modelViewMatrix);
1084
-
1085
- gl .drawArrays (shaderNode .primitiveMode, 0, this .vertexCount);
1099
+ this .updateParticlesShadow = false;
1086
1100
  }
1087
1101
 
1088
- //for (let i = 0, length = attribNodes .length; i < length; ++ i)
1089
- // attribNodes [i] .disable (gl, shaderNode);
1102
+ gl .drawArraysInstanced (this .primitiveMode, 0, this .vertexCount, particleSystem .numParticles);
1090
1103
  },
1091
- displayParticles: function (gl, context, particles, numParticles)
1104
+ displayParticles: function (gl, context, particleSystem)
1092
1105
  {
1093
- try
1094
- {
1095
- const
1096
- appearanceNode = context .shapeNode .getAppearance (),
1097
- materialNode = appearanceNode .materialNode,
1098
- backMaterialNode = appearanceNode .backMaterialNode,
1099
- frontShaderNode = appearanceNode .shaderNode || materialNode .getShader (context .browser, context .shadow);
1100
-
1101
- if (this .solid || !backMaterialNode || frontShaderNode .wireframe)
1102
- {
1103
- this .displayParticlesGeometry (gl, context, appearanceNode, frontShaderNode, true, true, particles, numParticles);
1104
- }
1105
- else
1106
- {
1107
- const backShaderNode = appearanceNode .shaderNode || backMaterialNode .getShader (context .browser, context .shadow);
1106
+ const
1107
+ appearanceNode = context .shapeNode .getAppearance (),
1108
+ materialNode = appearanceNode .getMaterial (),
1109
+ backMaterialNode = appearanceNode .getBackMaterial (),
1110
+ frontShaderNode = appearanceNode .getShader () || materialNode .getShader (context .browser, context .shadow);
1108
1111
 
1109
- this .displayParticlesGeometry (gl, context, appearanceNode, backShaderNode, true, false, particles, numParticles);
1110
- this .displayParticlesGeometry (gl, context, appearanceNode, frontShaderNode, false, true, particles, numParticles);
1111
- }
1112
+ if (this .solid || ! backMaterialNode || frontShaderNode .getWireframe ())
1113
+ {
1114
+ this .displayParticlesGeometry (gl, context, appearanceNode, frontShaderNode, true, true, particleSystem);
1112
1115
  }
1113
- catch (error)
1116
+ else
1114
1117
  {
1115
- // Catch error from setLocalUniforms.
1116
- console .log (error);
1118
+ const backShaderNode = appearanceNode .getShader () || backMaterialNode .getShader (context .browser, context .shadow);
1119
+
1120
+ this .displayParticlesGeometry (gl, context, appearanceNode, backShaderNode, true, false, particleSystem);
1121
+ this .displayParticlesGeometry (gl, context, appearanceNode, frontShaderNode, false, true, particleSystem);
1117
1122
  }
1118
1123
  },
1119
- displayParticlesGeometry: function (gl, context, appearanceNode, shaderNode, back, front, particles, numParticles)
1124
+ displayParticlesGeometry: function (gl, context, appearanceNode, shaderNode, back, front, particleSystem)
1120
1125
  {
1121
- if (shaderNode .getValid ())
1126
+ if (shaderNode .isValid ())
1122
1127
  {
1123
1128
  const
1124
- blendModeNode = appearanceNode .blendModeNode,
1129
+ blendModeNode = appearanceNode .getBlendMode (),
1125
1130
  attribNodes = this .attribNodes,
1126
- attribBuffers = this .attribBuffers;
1131
+ attribBuffers = this .attribBuffers,
1132
+ primitiveMode = shaderNode .getPrimitiveMode (this .primitiveMode);
1127
1133
 
1128
1134
  if (blendModeNode)
1129
1135
  blendModeNode .enable (gl);
@@ -1135,128 +1141,66 @@ function (Fields,
1135
1141
 
1136
1142
  // Setup vertex attributes.
1137
1143
 
1138
- for (let i = 0, length = attribNodes .length; i < length; ++ i)
1139
- attribNodes [i] .enable (gl, shaderNode, attribBuffers [i]);
1144
+ const outputParticles = particleSystem .outputParticles;
1140
1145
 
1141
- if (this .fogCoords)
1142
- shaderNode .enableFogDepthAttribute (gl, this .fogDepthBuffer);
1146
+ if (outputParticles .vertexArrayObject .update (this .updateParticles) .enable (gl, shaderNode))
1147
+ {
1148
+ const particleStride = particleSystem .particleStride;
1143
1149
 
1144
- if (this .colorMaterial)
1145
- shaderNode .enableColorAttribute (gl, this .colorBuffer);
1150
+ shaderNode .enableParticleAttribute (gl, outputParticles, particleStride, particleSystem .particleOffset, 1);
1151
+ shaderNode .enableParticleMatrixAttribute (gl, outputParticles, particleStride, particleSystem .matrixOffset, 1);
1146
1152
 
1147
- shaderNode .enableTexCoordAttribute (gl, this .texCoordBuffers);
1148
- shaderNode .enableNormalAttribute (gl, this .normalBuffer);
1149
- shaderNode .enableVertexAttribute (gl, this .vertexBuffer);
1153
+ for (let i = 0, length = attribNodes .length; i < length; ++ i)
1154
+ attribNodes [i] .enable (gl, shaderNode, attribBuffers [i]);
1150
1155
 
1151
- // Draw depending on wireframe, solid and transparent.
1156
+ if (this .fogCoords)
1157
+ shaderNode .enableFogDepthAttribute (gl, this .fogDepthBuffer, 0, 0);
1152
1158
 
1153
- const
1154
- modelViewMatrix = context .modelViewMatrix,
1155
- x = modelViewMatrix [12],
1156
- y = modelViewMatrix [13],
1157
- z = modelViewMatrix [14];
1159
+ if (this .colorMaterial)
1160
+ shaderNode .enableColorAttribute (gl, this .colorBuffer, 0, 0);
1158
1161
 
1159
- if (shaderNode .wireframe)
1160
- {
1161
- // Points and Wireframes.
1162
+ shaderNode .enableTexCoordAttribute (gl, this .texCoordBuffers, 0, 0);
1163
+ shaderNode .enableNormalAttribute (gl, this .normalBuffer, 0, 0);
1164
+ shaderNode .enableVertexAttribute (gl, this .vertexBuffer, 0, 0);
1162
1165
 
1163
- for (let p = 0; p < numParticles; ++ p)
1164
- {
1165
- const particle = particles [p];
1166
+ this .updateParticles = false;
1167
+ }
1166
1168
 
1167
- modelViewMatrix [12] = x;
1168
- modelViewMatrix [13] = y;
1169
- modelViewMatrix [14] = z;
1169
+ // Draw depending on wireframe, solid and transparent.
1170
1170
 
1171
- Matrix4 .prototype .translate .call (modelViewMatrix, particle .position);
1171
+ const positiveScale = Matrix4 .prototype .determinant3 .call (context .modelViewMatrix) > 0;
1172
1172
 
1173
- shaderNode .setParticle (gl, particle, modelViewMatrix);
1173
+ gl .frontFace (positiveScale ? this .frontFace : this .backFace .get (this .frontFace));
1174
1174
 
1175
- if (shaderNode .primitiveMode === gl .POINTS)
1176
- {
1177
- gl .drawArrays (shaderNode .primitiveMode, 0, this .vertexCount);
1178
- }
1179
- else
1180
- {
1181
- for (let i = 0, length = this .vertexCount; i < length; i += 3)
1182
- gl .drawArrays (shaderNode .primitiveMode, i, 3);
1183
- }
1184
- }
1185
- }
1186
- else
1175
+ if (context .transparent || back !== front)
1187
1176
  {
1188
- const positiveScale = Matrix4 .prototype .determinant3 .call (context .modelViewMatrix) > 0;
1177
+ // Render transparent or back or front.
1189
1178
 
1190
- gl .frontFace (positiveScale ? this .frontFace : (this .frontFace === gl .CCW ? gl .CW : gl .CCW));
1179
+ gl .enable (gl .CULL_FACE);
1191
1180
 
1192
- if (context .transparent || back !== front)
1181
+ if (back && ! this .solid)
1193
1182
  {
1194
- // Render transparent or back or front.
1195
-
1196
- for (let p = 0; p < numParticles; ++ p)
1197
- {
1198
- const particle = particles [p];
1199
-
1200
- modelViewMatrix [12] = x;
1201
- modelViewMatrix [13] = y;
1202
- modelViewMatrix [14] = z;
1203
-
1204
- Matrix4 .prototype .translate .call (modelViewMatrix, particle .position);
1205
-
1206
- shaderNode .setParticle (gl, particle, modelViewMatrix);
1207
-
1208
- gl .enable (gl .CULL_FACE);
1209
-
1210
- if (back && !this .solid)
1211
- {
1212
- gl .cullFace (gl .FRONT);
1213
- gl .drawArrays (shaderNode .primitiveMode, 0, this .vertexCount);
1214
- }
1215
-
1216
- if (front)
1217
- {
1218
- gl .cullFace (gl .BACK);
1219
- gl .drawArrays (shaderNode .primitiveMode, 0, this .vertexCount);
1220
- }
1221
- }
1183
+ gl .cullFace (gl .FRONT);
1184
+ gl .drawArraysInstanced (primitiveMode, 0, this .vertexCount, particleSystem .numParticles);
1222
1185
  }
1223
- else
1224
- {
1225
- // Render solid or both sides.
1226
-
1227
- if (this .solid)
1228
- gl .enable (gl .CULL_FACE);
1229
- else
1230
- gl .disable (gl .CULL_FACE);
1231
-
1232
- for (let p = 0; p < numParticles; ++ p)
1233
- {
1234
- const particle = particles [p];
1235
1186
 
1236
- modelViewMatrix [12] = x;
1237
- modelViewMatrix [13] = y;
1238
- modelViewMatrix [14] = z;
1239
-
1240
- Matrix4 .prototype .translate .call (modelViewMatrix, particle .position);
1241
-
1242
- shaderNode .setParticle (gl, particle, modelViewMatrix);
1243
-
1244
- gl .drawArrays (shaderNode .primitiveMode, 0, this .vertexCount);
1245
- }
1187
+ if (front)
1188
+ {
1189
+ gl .cullFace (gl .BACK);
1190
+ gl .drawArraysInstanced (primitiveMode, 0, this .vertexCount, particleSystem .numParticles);
1246
1191
  }
1247
1192
  }
1193
+ else
1194
+ {
1195
+ // Render solid or both sides.
1248
1196
 
1249
- for (const attribNode of attribNodes)
1250
- attribNode .disable (gl, shaderNode);
1251
-
1252
- if (this .fogCoords)
1253
- shaderNode .disableFogDepthAttribute (gl);
1254
-
1255
- if (this .colorMaterial)
1256
- shaderNode .disableColorAttribute (gl);
1197
+ if (this .solid)
1198
+ gl .enable (gl .CULL_FACE);
1199
+ else
1200
+ gl .disable (gl .CULL_FACE);
1257
1201
 
1258
- shaderNode .disableTexCoordAttribute (gl);
1259
- shaderNode .disableNormalAttribute (gl);
1202
+ gl .drawArraysInstanced (primitiveMode, 0, this .vertexCount, particleSystem .numParticles);
1203
+ }
1260
1204
 
1261
1205
  if (blendModeNode)
1262
1206
  blendModeNode .disable (gl);