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.
- package/.vscode/settings.json +12 -5
- package/.vscode/tasks.json +25 -1
- package/Makefile +36 -28
- package/README.md +6 -11
- package/build/bin/dist.pl +0 -6
- package/build/bin/examples-and-tests.pl +75 -0
- package/build/bin/tests-menu.pl +57 -0
- package/build/bin/version.pl +7 -4
- package/build/parts/default.start.frag.js +3 -2
- package/dist/assets/components/annotation.js +3 -2
- package/dist/assets/components/annotation.min.js +1 -1
- package/dist/assets/components/cad-geometry.js +3 -2
- package/dist/assets/components/cad-geometry.min.js +1 -1
- package/dist/assets/components/cube-map-texturing.js +8 -20
- package/dist/assets/components/cube-map-texturing.min.js +1 -1
- package/dist/assets/components/dis.js +3 -2
- package/dist/assets/components/dis.min.js +1 -1
- package/dist/assets/components/event-utilities.js +4 -3
- package/dist/assets/components/event-utilities.min.js +1 -1
- package/dist/assets/components/geometry2d.js +38 -52
- package/dist/assets/components/geometry2d.min.js +1 -1
- package/dist/assets/components/geospatial.js +34 -1686
- package/dist/assets/components/geospatial.min.js +1 -1
- package/dist/assets/components/h-anim.js +71 -77
- package/dist/assets/components/h-anim.min.js +1 -1
- package/dist/assets/components/key-device-sensor.js +4 -3
- package/dist/assets/components/key-device-sensor.min.js +1 -1
- package/dist/assets/components/layout.js +101 -173
- package/dist/assets/components/layout.min.js +1 -1
- package/dist/assets/components/nurbs.js +3 -2
- package/dist/assets/components/nurbs.min.js +1 -1
- package/dist/assets/components/particle-systems.js +1926 -1669
- package/dist/assets/components/particle-systems.min.js +1 -1
- package/dist/assets/components/picking.js +34 -41
- package/dist/assets/components/picking.min.js +1 -1
- package/dist/assets/components/projective-texture-mapping.js +73 -86
- package/dist/assets/components/projective-texture-mapping.min.js +1 -1
- package/dist/assets/components/rigid-body-physics.js +37 -57
- package/dist/assets/components/rigid-body-physics.min.js +1 -1
- package/dist/assets/components/scripting.js +3 -2
- package/dist/assets/components/scripting.min.js +1 -1
- package/dist/assets/components/texturing-3d.js +27 -33
- package/dist/assets/components/texturing-3d.min.js +3 -3
- package/dist/assets/components/volume-rendering.js +12 -11
- package/dist/assets/components/volume-rendering.min.js +1 -1
- package/dist/assets/components/x_ite.js +3 -2
- package/dist/assets/components/x_ite.min.js +1 -1
- package/dist/assets/images/Shading.png +0 -0
- package/dist/assets/linetype/1.png +0 -0
- package/dist/assets/linetype/10.png +0 -0
- package/dist/assets/linetype/11.png +0 -0
- package/dist/assets/linetype/12.png +0 -0
- package/dist/assets/linetype/13.png +0 -0
- package/dist/assets/linetype/14.png +0 -0
- package/dist/assets/linetype/15.png +0 -0
- package/dist/assets/linetype/16.png +0 -0
- package/dist/assets/linetype/2.png +0 -0
- package/dist/assets/linetype/3.png +0 -0
- package/dist/assets/linetype/4.png +0 -0
- package/dist/assets/linetype/5.png +0 -0
- package/dist/assets/linetype/6.png +0 -0
- package/dist/assets/linetype/7.png +0 -0
- package/dist/assets/linetype/8.png +0 -0
- package/dist/assets/linetype/9.png +0 -0
- package/dist/assets/shaders/webgl1/Gouraud.vs +1 -1
- package/dist/assets/shaders/webgl1/Line.fs +0 -21
- package/dist/assets/shaders/webgl1/Line.vs +0 -10
- package/dist/assets/shaders/webgl1/PBR.fs +1 -1
- package/dist/assets/shaders/webgl1/PBR.vs +1 -1
- package/dist/assets/shaders/webgl1/Phong.fs +1 -1
- package/dist/assets/shaders/webgl1/Point.vs +1 -1
- package/dist/assets/shaders/webgl2/Depth.vs +29 -1
- package/dist/assets/shaders/webgl2/Gouraud.vs +32 -4
- package/dist/assets/shaders/webgl2/Line.fs +24 -12
- package/dist/assets/shaders/webgl2/Line.vs +36 -11
- package/dist/assets/shaders/webgl2/LineTransform.fs +4 -0
- package/dist/assets/shaders/webgl2/LineTransform.vs +57 -0
- package/dist/assets/shaders/webgl2/PBR.fs +1 -1
- package/dist/assets/shaders/webgl2/PBR.vs +35 -7
- package/dist/assets/shaders/webgl2/Phong.fs +1 -1
- package/dist/assets/shaders/webgl2/Phong.vs +31 -3
- package/dist/assets/shaders/webgl2/Point.vs +30 -2
- package/dist/assets/shaders/webgl2/Unlit.vs +31 -3
- package/dist/example.html +6 -6
- package/dist/x_ite.css +199 -224
- package/dist/x_ite.js +16335 -15917
- package/dist/x_ite.min.js +17 -17
- package/dist/x_ite.zip +0 -0
- package/docs/404.md +6 -0
- package/docs/Accessing-the-External-Browser.md +21 -15
- package/docs/Browser-Support.md +6 -0
- package/docs/Custom-Shaders.md +18 -25
- package/docs/Features.md +11 -5
- package/docs/Gemfile +44 -0
- package/docs/Gemfile.lock +122 -0
- package/docs/Glossary.md +6 -0
- package/docs/How-To-Configure-Your-Web-Server.md +6 -0
- package/docs/Supported-Nodes.md +9 -1
- package/docs/What's-New.md +93 -39
- package/docs/XHTML-DOM-Integration.md +6 -0
- package/docs/_config.yml +2 -2
- package/docs/assets/css/main.scss +26 -0
- package/docs/index.md +42 -50
- package/docs/reference/Browser-Services.md +9 -3
- package/docs/reference/Constants-Services.md +6 -0
- package/docs/reference/ECMAScript-Object-and-Function-Definitions.md +12 -6
- package/docs/reference/Field-Services-and-Objects.md +105 -1
- package/docs/reference/Prototype-Services.md +11 -0
- package/docs/reference/Route-Services.md +9 -0
- package/docs/reference/Scene-Services.md +17 -2
- package/docs/reference/Script-Node-Authoring-Interface.md +7 -1
- package/docs/tutorials/Adding-backgrounds.md +6 -0
- package/docs/tutorials/Adding-fog.md +6 -0
- package/docs/tutorials/Adding-sound.md +6 -0
- package/docs/tutorials/Animating-transforms.md +6 -0
- package/docs/tutorials/Basic-Nodes.md +6 -0
- package/docs/tutorials/Building-a-X3D-world.md +6 -0
- package/docs/tutorials/Building-elevation-grids.md +6 -0
- package/docs/tutorials/Building-extruded-shapes.md +6 -0
- package/docs/tutorials/Building-primitive-shapes.md +6 -0
- package/docs/tutorials/Building-shapes-out-of-points,-lines,-and-faces.md +6 -0
- package/docs/tutorials/Controlling-appearance-with-materials.md +6 -0
- package/docs/tutorials/Controlling-color-on-coordinate-based-geometry.md +6 -0
- package/docs/tutorials/Controlling-detail.md +6 -0
- package/docs/tutorials/Controlling-how-textures-are-mapped.md +6 -0
- package/docs/tutorials/Controlling-navigation.md +6 -0
- package/docs/tutorials/Controlling-shading-on-coordinate-based-geometry.md +6 -0
- package/docs/tutorials/Controlling-the-viewpoint.md +6 -0
- package/docs/tutorials/Creating-new-node-types.md +6 -0
- package/docs/tutorials/Grouping-nodes.md +6 -0
- package/docs/tutorials/Hello,-World!.md +6 -0
- package/docs/tutorials/Improving-Performance.md +6 -0
- package/docs/tutorials/Increasing-Rendering-Speed.md +6 -0
- package/docs/tutorials/Introducing-X3D.md +6 -0
- package/docs/tutorials/Introducing-animation.md +6 -0
- package/docs/tutorials/Introducing-script-use.md +6 -0
- package/docs/tutorials/Lighting-your-world.md +6 -0
- package/docs/tutorials/Mapping-textures.md +6 -0
- package/docs/tutorials/Naming-nodes.md +6 -0
- package/docs/tutorials/Providing-information-about-your-world.md +6 -0
- package/docs/tutorials/Sensing-the-viewer.md +6 -0
- package/docs/tutorials/Sensing-viewer-actions.md +6 -0
- package/docs/tutorials/Transforming-Shapes.md +6 -0
- package/docs/tutorials/Writing-program-scripts-with-ECMAScript.md +6 -0
- package/docs/tutorials/index.md +42 -36
- package/package.json +6 -7
- package/src/assets/components/geometry2d.js +1 -1
- package/src/assets/components/key-device-sensor.js +1 -1
- package/src/assets/components/layout.js +1 -1
- package/src/assets/components/particle-systems.js +1 -1
- package/src/assets/components/volume-rendering.js +1 -1
- package/src/assets/images/Shading.png +0 -0
- package/src/assets/linetype/1.png +0 -0
- package/src/assets/linetype/10.png +0 -0
- package/src/assets/linetype/11.png +0 -0
- package/src/assets/linetype/12.png +0 -0
- package/src/assets/linetype/13.png +0 -0
- package/src/assets/linetype/14.png +0 -0
- package/src/assets/linetype/15.png +0 -0
- package/src/assets/linetype/16.png +0 -0
- package/src/assets/linetype/2.png +0 -0
- package/src/assets/linetype/3.png +0 -0
- package/src/assets/linetype/4.png +0 -0
- package/src/assets/linetype/5.png +0 -0
- package/src/assets/linetype/6.png +0 -0
- package/src/assets/linetype/7.png +0 -0
- package/src/assets/linetype/8.png +0 -0
- package/src/assets/linetype/9.png +0 -0
- package/src/assets/shaders/Types.glsl +1 -9
- package/src/assets/shaders/webgl1/Gouraud.fs +1 -1
- package/src/assets/shaders/webgl1/Gouraud.vs +2 -3
- package/src/assets/shaders/webgl1/Line.fs +3 -28
- package/src/assets/shaders/webgl1/Line.vs +6 -20
- package/src/assets/shaders/webgl1/PBR.fs +6 -6
- package/src/assets/shaders/webgl1/PBR.vs +1 -1
- package/src/assets/shaders/webgl1/Phong.fs +10 -10
- package/src/assets/shaders/webgl1/Point.vs +2 -2
- package/src/assets/shaders/webgl1/Unlit.fs +4 -4
- package/src/assets/shaders/webgl1/include/Normal.glsl +1 -1
- package/src/assets/shaders/webgl1/include/Texture.glsl +3 -8
- package/src/assets/shaders/webgl2/Depth.vs +4 -1
- package/src/assets/shaders/webgl2/Gouraud.fs +1 -1
- package/src/assets/shaders/webgl2/Gouraud.vs +8 -6
- package/src/assets/shaders/webgl2/Line.fs +11 -17
- package/src/assets/shaders/webgl2/Line.vs +17 -21
- package/src/assets/shaders/webgl2/LineTransform.fs +6 -0
- package/src/assets/shaders/webgl2/LineTransform.vs +77 -0
- package/src/assets/shaders/webgl2/PBR.fs +6 -6
- package/src/assets/shaders/webgl2/PBR.vs +10 -7
- package/src/assets/shaders/webgl2/Phong.fs +11 -11
- package/src/assets/shaders/webgl2/Phong.vs +6 -3
- package/src/assets/shaders/webgl2/Point.vs +5 -4
- package/src/assets/shaders/webgl2/Unlit.fs +5 -5
- package/src/assets/shaders/webgl2/Unlit.vs +6 -3
- package/src/assets/shaders/webgl2/include/Line2.glsl +20 -0
- package/src/assets/shaders/webgl2/include/Normal.glsl +1 -1
- package/src/assets/shaders/webgl2/include/Particle.glsl +36 -0
- package/src/assets/shaders/webgl2/include/Texture.glsl +3 -3
- package/src/example.html +6 -6
- package/src/examples.js +5 -4
- package/src/standard/Math/Algorithm.js +12 -28
- package/src/standard/Math/Geometry/Line2.js +163 -0
- package/src/standard/Math/Geometry/Line3.js +3 -5
- package/src/standard/Math/Geometry/Plane3.js +0 -2
- package/src/standard/Math/Geometry/Triangle3.js +1 -1
- package/src/standard/Math/Geometry/ViewVolume.js +121 -103
- package/src/standard/Math/Numbers/Color3.js +6 -0
- package/src/standard/Math/Numbers/Color4.js +7 -0
- package/src/standard/Math/Numbers/Complex.js +48 -34
- package/src/standard/Math/Numbers/Matrix2.js +62 -2
- package/src/standard/Math/Numbers/Matrix3.js +129 -110
- package/src/standard/Math/Numbers/Matrix4.js +138 -119
- package/src/standard/Math/Numbers/Quaternion.js +12 -5
- package/src/standard/Math/Numbers/Rotation4.js +8 -1
- package/src/standard/Math/Numbers/Vector2.js +42 -9
- package/src/standard/Math/Numbers/Vector3.js +50 -14
- package/src/standard/Math/Numbers/Vector4.js +48 -11
- package/src/standard/Math/Utility/BVH.js +45 -17
- package/src/tests.js +68 -66
- package/src/x_ite/Base/X3DBaseNode.js +22 -11
- package/src/x_ite/Base/X3DField.js +1 -1
- package/src/x_ite/Browser/Core/BrowserOptions.js +24 -143
- package/src/x_ite/Browser/Core/BrowserTimings.js +6 -4
- package/src/x_ite/Browser/Core/Context.js +185 -0
- package/src/x_ite/Browser/Core/ContextMenu.js +398 -211
- package/src/x_ite/Browser/Core/Notification.js +1 -0
- package/src/x_ite/Browser/Core/X3DCoreContext.js +35 -146
- package/src/x_ite/Browser/Followers/X3DArrayFollowerTemplate.js +1 -1
- package/src/x_ite/Browser/Geometry2D/Disk2DOptions.js +1 -0
- package/src/x_ite/Browser/Geometry2D/X3DGeometry2DContext.js +2 -2
- package/src/x_ite/Browser/Geometry3D/X3DGeometry3DContext.js +41 -2
- package/src/x_ite/Browser/Geospatial/Geocentric.js +2 -2
- package/src/x_ite/Browser/Interpolation/CatmullRomSplineInterpolatorTemplate.js +1 -1
- package/src/x_ite/Browser/Layout/ScreenText.js +18 -65
- package/src/x_ite/Browser/Layout/X3DLayoutContext.js +59 -16
- package/src/x_ite/Browser/Navigation/ExamineViewer.js +13 -20
- package/src/x_ite/Browser/Navigation/LookAtViewer.js +1 -4
- package/src/x_ite/Browser/Navigation/PlaneViewer.js +0 -3
- package/src/x_ite/Browser/Navigation/X3DFlyViewer.js +15 -8
- package/src/x_ite/Browser/Navigation/X3DViewer.js +12 -20
- package/src/x_ite/Browser/Networking/X3DNetworkingContext.js +11 -7
- package/src/x_ite/Browser/ParticleSystems/BVH.glsl +183 -0
- package/src/x_ite/Browser/ParticleSystems/Box3.glsl +47 -0
- package/src/x_ite/Browser/ParticleSystems/GeometryTypes.js +66 -0
- package/src/x_ite/Browser/ParticleSystems/Line3.glsl +55 -0
- package/src/x_ite/Browser/ParticleSystems/Plane3.glsl +160 -0
- package/src/x_ite/Browser/PointingDeviceSensor/PointingDevice.js +27 -3
- package/src/x_ite/Browser/PointingDeviceSensor/X3DPointingDeviceSensorContext.js +41 -37
- package/src/x_ite/Browser/Rendering/X3DRenderingContext.js +21 -13
- package/src/x_ite/Browser/Shaders/Shader.js +33 -12
- package/src/x_ite/Browser/Shaders/ShaderSource.js +6 -0
- package/src/x_ite/Browser/Shaders/ShaderTest.js +16 -10
- package/src/x_ite/Browser/Shape/X3DShapeContext.js +50 -9
- package/src/x_ite/Browser/Text/X3DTextContext.js +4 -13
- package/src/x_ite/Browser/Text/X3DTextGeometry.js +2 -1
- package/src/x_ite/Browser/Texturing/X3DTexturingContext.js +71 -34
- package/src/x_ite/Browser/Texturing3D/DICOMParser.js +2 -2
- package/src/x_ite/Browser/Time/X3DTimeContext.js +4 -2
- package/src/x_ite/Browser/VERSION.js +1 -1
- package/src/x_ite/Browser/X3DBrowser.js +7 -6
- package/src/x_ite/Browser/X3DBrowserContext.js +43 -10
- package/src/x_ite/Components/Core/X3DNode.js +4 -0
- package/src/x_ite/Components/Core/X3DPrototypeInstance.js +0 -2
- package/src/x_ite/Components/CubeMapTexturing/ComposedCubeMapTexture.js +3 -4
- package/src/x_ite/Components/CubeMapTexturing/GeneratedCubeMapTexture.js +1 -12
- package/src/x_ite/Components/CubeMapTexturing/ImageCubeMapTexture.js +1 -2
- package/src/x_ite/Components/EnvironmentalEffects/TextureBackground.js +1 -1
- package/src/x_ite/Components/EnvironmentalEffects/X3DBackgroundNode.js +76 -77
- package/src/x_ite/Components/EnvironmentalEffects/X3DFogObject.js +2 -9
- package/src/x_ite/Components/EnvironmentalSensor/ProximitySensor.js +51 -65
- package/src/x_ite/Components/EventUtilities/X3DSequencerNode.js +1 -1
- package/src/x_ite/Components/Followers/ColorDamper.js +1 -1
- package/src/x_ite/Components/Followers/X3DChaserNode.js +18 -32
- package/src/x_ite/Components/Followers/X3DDamperNode.js +1 -6
- package/src/x_ite/Components/Followers/X3DFollowerNode.js +1 -1
- package/src/x_ite/Components/Geometry2D/Disk2D.js +30 -46
- package/src/x_ite/Components/Geometry2D/TriangleSet2D.js +1 -1
- package/src/x_ite/Components/Geometry3D/ElevationGrid.js +12 -4
- package/src/x_ite/Components/Geometry3D/IndexedFaceSet.js +4 -4
- package/src/x_ite/Components/Geospatial/GeoCoordinate.js +10 -27
- package/src/x_ite/Components/Geospatial/GeoLOD.js +1 -1
- package/src/x_ite/Components/Geospatial/GeoPositionInterpolator.js +5 -10
- package/src/x_ite/Components/Geospatial/GeoTouchSensor.js +9 -16
- package/src/x_ite/Components/Geospatial/GeoTransform.js +6 -18
- package/src/x_ite/Components/Geospatial/GeoViewpoint.js +26 -30
- package/src/x_ite/Components/Geospatial/X3DGeospatialObject.js +20 -27
- package/src/x_ite/Components/Grouping/X3DGroupingNode.js +8 -8
- package/src/x_ite/Components/Grouping/X3DTransformNode.js +0 -4
- package/src/x_ite/Components/HAnim/HAnimHumanoid.js +68 -75
- package/src/x_ite/Components/Interpolation/OrientationInterpolator.js +4 -11
- package/src/x_ite/Components/Interpolation/X3DInterpolatorNode.js +1 -1
- package/src/x_ite/Components/Layout/LayoutGroup.js +4 -9
- package/src/x_ite/Components/Layout/ScreenFontStyle.js +1 -1
- package/src/x_ite/Components/Layout/ScreenGroup.js +16 -80
- package/src/x_ite/Components/Lighting/DirectionalLight.js +28 -36
- package/src/x_ite/Components/Lighting/PointLight.js +32 -47
- package/src/x_ite/Components/Lighting/SpotLight.js +33 -48
- package/src/x_ite/Components/Navigation/Billboard.js +49 -56
- package/src/x_ite/Components/Navigation/LOD.js +2 -2
- package/src/x_ite/Components/Navigation/OrthoViewpoint.js +29 -30
- package/src/x_ite/Components/Navigation/Viewpoint.js +16 -20
- package/src/x_ite/Components/Navigation/X3DViewpointNode.js +82 -111
- package/src/x_ite/Components/Networking/Anchor.js +18 -7
- package/src/x_ite/Components/ParticleSystems/BoundedPhysicsModel.js +6 -6
- package/src/x_ite/Components/ParticleSystems/ConeEmitter.js +44 -36
- package/src/x_ite/Components/ParticleSystems/ExplosionEmitter.js +26 -17
- package/src/x_ite/Components/ParticleSystems/ForcePhysicsModel.js +20 -7
- package/src/x_ite/Components/ParticleSystems/ParticleSystem.js +463 -882
- package/src/x_ite/Components/ParticleSystems/PointEmitter.js +39 -35
- package/src/x_ite/Components/ParticleSystems/PolylineEmitter.js +112 -128
- package/src/x_ite/Components/ParticleSystems/SurfaceEmitter.js +105 -112
- package/src/x_ite/Components/ParticleSystems/VolumeEmitter.js +138 -176
- package/src/x_ite/Components/ParticleSystems/WindPhysicsModel.js +16 -11
- package/src/x_ite/Components/ParticleSystems/X3DParticleEmitterNode.js +807 -217
- package/src/x_ite/Components/Picking/LinePickSensor.js +31 -39
- package/src/x_ite/Components/PointingDeviceSensor/CylinderSensor.js +91 -108
- package/src/x_ite/Components/PointingDeviceSensor/PlaneSensor.js +56 -59
- package/src/x_ite/Components/PointingDeviceSensor/SphereSensor.js +54 -71
- package/src/x_ite/Components/PointingDeviceSensor/TouchSensor.js +8 -15
- package/src/x_ite/Components/ProjectiveTextureMapping/TextureProjectorParallel.js +43 -50
- package/src/x_ite/Components/ProjectiveTextureMapping/TextureProjectorPerspective.js +32 -39
- package/src/x_ite/Components/Rendering/ClipPlane.js +3 -11
- package/src/x_ite/Components/Rendering/Color.js +12 -24
- package/src/x_ite/Components/Rendering/ColorRGBA.js +13 -25
- package/src/x_ite/Components/Rendering/IndexedLineSet.js +26 -4
- package/src/x_ite/Components/Rendering/LineSet.js +35 -13
- package/src/x_ite/Components/Rendering/PointSet.js +35 -13
- package/src/x_ite/Components/Rendering/X3DComposedGeometryNode.js +13 -5
- package/src/x_ite/Components/Rendering/X3DGeometryNode.js +331 -387
- package/src/x_ite/Components/Rendering/X3DLineGeometryNode.js +350 -140
- package/src/x_ite/Components/Rendering/X3DPointGeometryNode.js +116 -126
- package/src/x_ite/Components/RigidBodyPhysics/DoubleAxisHingeJoint.js +24 -38
- package/src/x_ite/Components/RigidBodyPhysics/SingleAxisHingeJoint.js +10 -17
- package/src/x_ite/Components/Shaders/ComposedShader.js +35 -75
- package/src/x_ite/Components/Shaders/FloatVertexAttribute.js +8 -11
- package/src/x_ite/Components/Shaders/Matrix3VertexAttribute.js +10 -14
- package/src/x_ite/Components/Shaders/Matrix4VertexAttribute.js +10 -14
- package/src/x_ite/Components/Shaders/ShaderPart.js +1 -10
- package/src/x_ite/Components/Shaders/X3DProgrammableShaderObject.js +220 -210
- package/src/x_ite/Components/Shaders/X3DShaderNode.js +28 -10
- package/src/x_ite/Components/Shaders/X3DVertexAttributeNode.js +15 -1
- package/src/x_ite/Components/Shape/Appearance.js +37 -4
- package/src/x_ite/Components/Shape/FillProperties.js +12 -1
- package/src/x_ite/Components/Shape/LineProperties.js +33 -1
- package/src/x_ite/Components/Shape/PointProperties.js +24 -3
- package/src/x_ite/Components/Shape/Shape.js +30 -39
- package/src/x_ite/Components/Shape/TwoSidedMaterial.js +3 -1
- package/src/x_ite/Components/Sound/Sound.js +31 -41
- package/src/x_ite/Components/Text/Text.js +6 -20
- package/src/x_ite/Components/Texturing/ImageTexture.js +1 -1
- package/src/x_ite/Components/Texturing/MovieTexture.js +1 -1
- package/src/x_ite/Components/Texturing/PixelTexture.js +2 -2
- package/src/x_ite/Components/Texturing/TextureCoordinate.js +5 -5
- package/src/x_ite/Components/Texturing/TextureProperties.js +4 -4
- package/src/x_ite/Components/Texturing/X3DSingleTextureNode.js +5 -4
- package/src/x_ite/Components/Texturing/X3DTexture2DNode.js +24 -33
- package/src/x_ite/Components/Texturing3D/TextureCoordinate3D.js +5 -5
- package/src/x_ite/Components/Texturing3D/TextureCoordinate4D.js +5 -5
- package/src/x_ite/Components/Texturing3D/X3DTexture3DNode.js +12 -19
- package/src/x_ite/Components/VolumeRendering/X3DVolumeDataNode.js +8 -8
- package/src/x_ite/Components.js +2 -2
- package/src/x_ite/Fallback.js +9 -3
- package/src/x_ite/Fields/SFColor.js +4 -0
- package/src/x_ite/Fields/SFColorRGBA.js +4 -0
- package/src/x_ite/Fields/SFImage.js +2 -11
- package/src/x_ite/Fields/SFMatrixPrototypeTemplate.js +4 -0
- package/src/x_ite/Fields/SFRotation.js +4 -0
- package/src/x_ite/Fields/SFString.js +4 -0
- package/src/x_ite/Fields/SFVecPrototypeTemplate.js +22 -2
- package/src/x_ite/Parser/XMLParser.js +1 -1
- package/src/x_ite/Rendering/TextureBuffer.js +43 -36
- package/src/x_ite/Rendering/VertexArray.js +103 -0
- package/src/x_ite/Rendering/X3DRenderObject.js +127 -148
- package/src/x_ite/X3D.js +32 -26
- package/src/x_ite.config.js +0 -5
- package/src/x_ite.css +216 -175
- package/src/x_ite.html +15 -10
- package/src/x_ite.js +49 -1
- package/x_ite.min.html +15 -10
- package/dist/assets/hatching/0.png +0 -0
- package/dist/assets/linetype/0.png +0 -0
- package/src/assets/hatching/0.png +0 -0
- package/src/assets/linetype/0.png +0 -0
- package/src/spinner.css +0 -67
- package/src/x_ite/Browser/Shape/LineStipples.xcf +0 -0
|
@@ -52,69 +52,70 @@ define ([
|
|
|
52
52
|
"x_ite/Base/X3DFieldDefinition",
|
|
53
53
|
"x_ite/Base/FieldDefinitionArray",
|
|
54
54
|
"x_ite/Components/Shape/X3DShapeNode",
|
|
55
|
+
"x_ite/Browser/ParticleSystems/GeometryTypes",
|
|
56
|
+
"x_ite/Rendering/VertexArray",
|
|
55
57
|
"x_ite/Rendering/TraverseType",
|
|
56
58
|
"x_ite/Base/X3DConstants",
|
|
57
59
|
"x_ite/Base/X3DCast",
|
|
58
60
|
"x_ite/Browser/Shape/AlphaMode",
|
|
59
61
|
"standard/Math/Numbers/Vector3",
|
|
60
|
-
"standard/Math/Numbers/Vector4",
|
|
61
62
|
"standard/Math/Numbers/Matrix4",
|
|
62
63
|
"standard/Math/Numbers/Matrix3",
|
|
63
|
-
"standard/Math/Algorithms/QuickSort",
|
|
64
|
-
"standard/Math/Algorithm",
|
|
65
64
|
"standard/Math/Utility/BVH",
|
|
66
65
|
],
|
|
67
66
|
function (Fields,
|
|
68
67
|
X3DFieldDefinition,
|
|
69
68
|
FieldDefinitionArray,
|
|
70
69
|
X3DShapeNode,
|
|
70
|
+
GeometryTypes,
|
|
71
|
+
VertexArray,
|
|
71
72
|
TraverseType,
|
|
72
73
|
X3DConstants,
|
|
73
74
|
X3DCast,
|
|
74
75
|
AlphaMode,
|
|
75
76
|
Vector3,
|
|
76
|
-
Vector4,
|
|
77
77
|
Matrix4,
|
|
78
78
|
Matrix3,
|
|
79
|
-
QuickSort,
|
|
80
|
-
Algorithm,
|
|
81
79
|
BVH)
|
|
82
80
|
{
|
|
83
81
|
"use strict";
|
|
84
82
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
const
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
83
|
+
const PointGeometry = new Float32Array ([0, 0, 0, 1]);
|
|
84
|
+
|
|
85
|
+
const LineGeometry = new Float32Array ([
|
|
86
|
+
// TexCoords
|
|
87
|
+
0, 0, 0, 1,
|
|
88
|
+
1, 0, 0, 1,
|
|
89
|
+
// Vertices
|
|
90
|
+
0, 0, -0.5, 1,
|
|
91
|
+
0, 0, 0.5, 1,
|
|
92
|
+
]);
|
|
93
|
+
|
|
94
|
+
// p4 ------ p3
|
|
95
|
+
// | / |
|
|
96
|
+
// | / |
|
|
97
|
+
// | / |
|
|
98
|
+
// | / |
|
|
99
|
+
// p1 ------ p2
|
|
100
|
+
|
|
101
|
+
const QuadGeometry = new Float32Array ([
|
|
102
|
+
// TexCoords
|
|
103
|
+
0, 0, 0, 1,
|
|
104
|
+
1, 0, 0, 1,
|
|
105
|
+
1, 1, 0, 1,
|
|
106
|
+
0, 0, 0, 1,
|
|
107
|
+
1, 1, 0, 1,
|
|
108
|
+
0, 1, 0, 1,
|
|
109
|
+
// Normal
|
|
110
|
+
0, 0, 1,
|
|
111
|
+
// Vertices
|
|
112
|
+
-0.5, -0.5, 0, 1,
|
|
113
|
+
0.5, -0.5, 0, 1,
|
|
114
|
+
0.5, 0.5, 0, 1,
|
|
115
|
+
-0.5, -0.5, 0, 1,
|
|
116
|
+
0.5, 0.5, 0, 1,
|
|
117
|
+
-0.5, 0.5, 0, 1,
|
|
118
|
+
]);
|
|
118
119
|
|
|
119
120
|
function ParticleSystem (executionContext)
|
|
120
121
|
{
|
|
@@ -124,39 +125,25 @@ function (Fields,
|
|
|
124
125
|
|
|
125
126
|
this ._particleSize .setUnit ("length");
|
|
126
127
|
|
|
127
|
-
this .createParticles = true;
|
|
128
|
-
this .particles = [ ];
|
|
129
|
-
this .velocities = [ ];
|
|
130
|
-
this .speeds = [ ];
|
|
131
|
-
this .turbulences = [ ];
|
|
132
|
-
this .geometryType = POINT;
|
|
133
128
|
this .maxParticles = 0;
|
|
134
129
|
this .numParticles = 0;
|
|
135
|
-
this .particleLifetime = 0;
|
|
136
|
-
this .lifetimeVariation = 0;
|
|
137
|
-
this .emitterNode = null;
|
|
138
130
|
this .forcePhysicsModelNodes = [ ];
|
|
131
|
+
this .forces = new Float32Array (4);
|
|
139
132
|
this .boundedPhysicsModelNodes = [ ];
|
|
140
133
|
this .boundedNormals = [ ];
|
|
141
134
|
this .boundedVertices = [ ];
|
|
142
|
-
this .
|
|
135
|
+
this .colorRamp = new Float32Array ();
|
|
136
|
+
this .texCoordRamp = new Float32Array ();
|
|
137
|
+
this .geometryContext = { };
|
|
143
138
|
this .creationTime = 0;
|
|
144
139
|
this .pauseTime = 0;
|
|
145
140
|
this .deltaTime = 0;
|
|
146
|
-
this .
|
|
147
|
-
this .
|
|
148
|
-
this .
|
|
149
|
-
this .
|
|
150
|
-
this .
|
|
151
|
-
this .
|
|
152
|
-
this .texCoordRamp = [ ];
|
|
153
|
-
this .texCoordAnim = false;
|
|
154
|
-
this .vertexCount = 0;
|
|
155
|
-
this .shaderNode = null;
|
|
156
|
-
this .rotation = new Matrix3 ();
|
|
157
|
-
this .particleSorter = new QuickSort (this .particles, compareDistance);
|
|
158
|
-
this .sortParticles = false;
|
|
159
|
-
this .geometryContext = { };
|
|
141
|
+
this .particleStride = Float32Array .BYTES_PER_ELEMENT * 7 * 4; // 7 x vec4
|
|
142
|
+
this .particleOffsets = Array .from ({length: 7}, (_, i) => Float32Array .BYTES_PER_ELEMENT * 4 * i); // i x vec4
|
|
143
|
+
this .particleOffset = this .particleOffsets [0];
|
|
144
|
+
this .colorOffset = this .particleOffsets [1];
|
|
145
|
+
this .matrixOffset = this .particleOffsets [3];
|
|
146
|
+
this .texCoordOffset = 0;
|
|
160
147
|
}
|
|
161
148
|
|
|
162
149
|
ParticleSystem .prototype = Object .assign (Object .create (X3DShapeNode .prototype),
|
|
@@ -206,6 +193,9 @@ function (Fields,
|
|
|
206
193
|
browser = this .getBrowser (),
|
|
207
194
|
gl = browser .getContext ();
|
|
208
195
|
|
|
196
|
+
if (browser .getContext () .getVersion () < 2)
|
|
197
|
+
return;
|
|
198
|
+
|
|
209
199
|
this .isLive () .addInterest ("set_live__", this);
|
|
210
200
|
|
|
211
201
|
browser .getBrowserOptions () ._Shading .addInterest ("set_shader__", this);
|
|
@@ -213,6 +203,7 @@ function (Fields,
|
|
|
213
203
|
this ._enabled .addInterest ("set_enabled__", this);
|
|
214
204
|
this ._createParticles .addInterest ("set_createParticles__", this);
|
|
215
205
|
this ._geometryType .addInterest ("set_geometryType__", this);
|
|
206
|
+
this ._geometryType .addInterest ("set_texCoord__", this);
|
|
216
207
|
this ._maxParticles .addInterest ("set_enabled__", this);
|
|
217
208
|
this ._particleLifetime .addInterest ("set_particleLifetime__", this);
|
|
218
209
|
this ._lifetimeVariation .addInterest ("set_lifetimeVariation__", this);
|
|
@@ -223,38 +214,42 @@ function (Fields,
|
|
|
223
214
|
this ._texCoordKey .addInterest ("set_texCoord__", this);
|
|
224
215
|
this ._texCoordRamp .addInterest ("set_texCoordRamp__", this);
|
|
225
216
|
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
this .
|
|
229
|
-
this .
|
|
230
|
-
|
|
231
|
-
this .
|
|
232
|
-
this .
|
|
233
|
-
this .
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
this .
|
|
241
|
-
this .
|
|
242
|
-
this .
|
|
243
|
-
this .
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
this .
|
|
217
|
+
// Create particles stuff.
|
|
218
|
+
|
|
219
|
+
this .inputParticles = this .createBuffer ();
|
|
220
|
+
this .outputParticles = this .createBuffer ();
|
|
221
|
+
|
|
222
|
+
this .inputParticles . emitterArrayObject = new VertexArray ();
|
|
223
|
+
this .inputParticles . vertexArrayObject = new VertexArray ();
|
|
224
|
+
this .inputParticles .shadowArrayObject = new VertexArray ();
|
|
225
|
+
this .outputParticles .emitterArrayObject = new VertexArray ();
|
|
226
|
+
this .outputParticles .vertexArrayObject = new VertexArray ();
|
|
227
|
+
this .outputParticles .shadowArrayObject = new VertexArray ();
|
|
228
|
+
|
|
229
|
+
// Create forces stuff.
|
|
230
|
+
|
|
231
|
+
this .forcesTexture = this .createTexture ();
|
|
232
|
+
this .boundedTexture = this .createTexture ();
|
|
233
|
+
this .colorRampTexture = this .createTexture ();
|
|
234
|
+
this .texCoordRampTexture = this .createTexture ();
|
|
235
|
+
|
|
236
|
+
// Create GL stuff.
|
|
237
|
+
|
|
238
|
+
this .geometryBuffer = this .createBuffer ();
|
|
239
|
+
this .texCoordBuffers = new Array (browser .getMaxTextures ()) .fill (this .geometryBuffer);
|
|
248
240
|
|
|
249
241
|
// Geometry context
|
|
250
242
|
|
|
251
|
-
this .geometryContext .fogCoords
|
|
243
|
+
this .geometryContext .fogCoords = false;
|
|
252
244
|
this .geometryContext .textureCoordinateNode = browser .getDefaultTextureCoordinate ();
|
|
253
245
|
this .geometryContext .textureCoordinateMapping = new Map ();
|
|
254
246
|
|
|
255
|
-
//
|
|
247
|
+
// Init fields.
|
|
248
|
+
// Call order is very important at startup.
|
|
249
|
+
|
|
256
250
|
this .set_emitter__ ();
|
|
257
251
|
this .set_enabled__ ();
|
|
252
|
+
this .set_geometryType__ ();
|
|
258
253
|
this .set_createParticles__ ();
|
|
259
254
|
this .set_particleLifetime__ ();
|
|
260
255
|
this .set_lifetimeVariation__ ();
|
|
@@ -278,7 +273,7 @@ function (Fields,
|
|
|
278
273
|
{
|
|
279
274
|
switch (this .geometryType)
|
|
280
275
|
{
|
|
281
|
-
case POINT:
|
|
276
|
+
case GeometryTypes .POINT:
|
|
282
277
|
{
|
|
283
278
|
this .setTransparent (true);
|
|
284
279
|
break;
|
|
@@ -287,7 +282,7 @@ function (Fields,
|
|
|
287
282
|
{
|
|
288
283
|
this .setTransparent (this .getAppearance () .getTransparent () ||
|
|
289
284
|
(this .colorRampNode && this .colorRampNode .getTransparent ()) ||
|
|
290
|
-
(this .geometryType === GEOMETRY && this .geometryNode && this .geometryNode .getTransparent ()));
|
|
285
|
+
(this .geometryType === GeometryTypes .GEOMETRY && this .geometryNode && this .geometryNode .getTransparent ()));
|
|
291
286
|
break;
|
|
292
287
|
}
|
|
293
288
|
}
|
|
@@ -327,7 +322,7 @@ function (Fields,
|
|
|
327
322
|
{
|
|
328
323
|
if (this ._enabled .getValue () && this ._maxParticles .getValue ())
|
|
329
324
|
{
|
|
330
|
-
if (!
|
|
325
|
+
if (!this ._isActive .getValue ())
|
|
331
326
|
{
|
|
332
327
|
if (this .isLive () .getValue ())
|
|
333
328
|
{
|
|
@@ -339,6 +334,8 @@ function (Fields,
|
|
|
339
334
|
this .pauseTime = performance .now () / 1000;
|
|
340
335
|
|
|
341
336
|
this ._isActive = true;
|
|
337
|
+
|
|
338
|
+
delete this .traverse;
|
|
342
339
|
}
|
|
343
340
|
}
|
|
344
341
|
else
|
|
@@ -353,6 +350,7 @@ function (Fields,
|
|
|
353
350
|
this ._isActive = false;
|
|
354
351
|
|
|
355
352
|
this .numParticles = 0;
|
|
353
|
+
this .traverse = Function .prototype;
|
|
356
354
|
}
|
|
357
355
|
}
|
|
358
356
|
|
|
@@ -364,161 +362,83 @@ function (Fields,
|
|
|
364
362
|
},
|
|
365
363
|
set_geometryType__: function ()
|
|
366
364
|
{
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
// geometryType
|
|
365
|
+
const
|
|
366
|
+
browser = this .getBrowser (),
|
|
367
|
+
gl = browser .getContext ();
|
|
372
368
|
|
|
373
|
-
|
|
369
|
+
// Set geometryType.
|
|
374
370
|
|
|
375
|
-
|
|
376
|
-
this .
|
|
371
|
+
this .geometryType = GeometryTypes .hasOwnProperty (this ._geometryType .getValue ())
|
|
372
|
+
? GeometryTypes [this ._geometryType .getValue ()]
|
|
373
|
+
: GeometryTypes .QUAD;
|
|
377
374
|
|
|
378
|
-
// Create buffers
|
|
375
|
+
// Create buffers.
|
|
379
376
|
|
|
380
377
|
switch (this .geometryType)
|
|
381
378
|
{
|
|
382
|
-
case POINT:
|
|
379
|
+
case GeometryTypes .POINT:
|
|
383
380
|
{
|
|
384
|
-
this .
|
|
385
|
-
|
|
386
|
-
this .elapsedTimeArray = new Float32Array (maxParticles);
|
|
387
|
-
this .lifeArray = new Float32Array (maxParticles);
|
|
388
|
-
this .colorArray = new Float32Array (4 * maxParticles);
|
|
389
|
-
this .texCoordArray = new Float32Array ();
|
|
390
|
-
this .normalArray = new Float32Array ();
|
|
391
|
-
this .vertexArray = new Float32Array (4 * maxParticles);
|
|
392
|
-
|
|
393
|
-
for (var i = 0, a = this .idArray, l = a .length; i < l; ++ i)
|
|
394
|
-
a [i] = i;
|
|
395
|
-
|
|
396
|
-
this .colorArray .fill (1);
|
|
397
|
-
this .vertexArray .fill (1);
|
|
398
|
-
|
|
399
|
-
this .testWireframe = false;
|
|
400
|
-
this .primitiveMode = gl .POINTS;
|
|
381
|
+
this .geometryContext .geometryType = 0;
|
|
382
|
+
|
|
401
383
|
this .texCoordCount = 0;
|
|
402
384
|
this .vertexCount = 1;
|
|
385
|
+
this .hasNormals = false;
|
|
386
|
+
this .primitiveMode = gl .POINTS;
|
|
387
|
+
|
|
388
|
+
this .verticesOffset = 0;
|
|
389
|
+
|
|
390
|
+
gl .bindBuffer (gl .ARRAY_BUFFER, this .geometryBuffer);
|
|
391
|
+
gl .bufferData (gl .ARRAY_BUFFER, PointGeometry, gl .DYNAMIC_DRAW);
|
|
403
392
|
|
|
404
|
-
this .geometryContext .geometryType = 0;
|
|
405
393
|
break;
|
|
406
394
|
}
|
|
407
|
-
case LINE:
|
|
395
|
+
case GeometryTypes .LINE:
|
|
408
396
|
{
|
|
409
|
-
this .
|
|
410
|
-
|
|
411
|
-
this .elapsedTimeArray = new Float32Array (2 * maxParticles);
|
|
412
|
-
this .lifeArray = new Float32Array (2 * maxParticles);
|
|
413
|
-
this .colorArray = new Float32Array (2 * 4 * maxParticles);
|
|
414
|
-
this .texCoordArray = new Float32Array ();
|
|
415
|
-
this .normalArray = new Float32Array ();
|
|
416
|
-
this .vertexArray = new Float32Array (2 * 4 * maxParticles);
|
|
417
|
-
|
|
418
|
-
for (var i = 0, a = this .idArray, l = a .length; i < l; ++ i)
|
|
419
|
-
a [i] = Math .floor (i / 2);
|
|
420
|
-
|
|
421
|
-
this .colorArray .fill (1);
|
|
422
|
-
this .vertexArray .fill (1);
|
|
423
|
-
|
|
424
|
-
this .testWireframe = false;
|
|
425
|
-
this .primitiveMode = gl .LINES;
|
|
397
|
+
this .geometryContext .geometryType = 1;
|
|
398
|
+
|
|
426
399
|
this .texCoordCount = 2;
|
|
427
400
|
this .vertexCount = 2;
|
|
401
|
+
this .hasNormals = false;
|
|
402
|
+
this .primitiveMode = gl .LINES;
|
|
403
|
+
|
|
404
|
+
this .texCoordsOffset = 0;
|
|
405
|
+
this .verticesOffset = Float32Array .BYTES_PER_ELEMENT * 8;
|
|
406
|
+
|
|
407
|
+
gl .bindBuffer (gl .ARRAY_BUFFER, this .geometryBuffer);
|
|
408
|
+
gl .bufferData (gl .ARRAY_BUFFER, LineGeometry, gl .DYNAMIC_DRAW);
|
|
428
409
|
|
|
429
|
-
this .geometryContext .geometryType = 1;
|
|
430
410
|
break;
|
|
431
411
|
}
|
|
432
|
-
case TRIANGLE:
|
|
433
|
-
case QUAD:
|
|
434
|
-
case SPRITE:
|
|
412
|
+
case GeometryTypes .TRIANGLE:
|
|
413
|
+
case GeometryTypes .QUAD:
|
|
414
|
+
case GeometryTypes .SPRITE:
|
|
435
415
|
{
|
|
436
|
-
this .
|
|
437
|
-
this .positionArray = new Float32Array (6 * 3 * maxParticles);
|
|
438
|
-
this .elapsedTimeArray = new Float32Array (6 * maxParticles);
|
|
439
|
-
this .lifeArray = new Float32Array (6 * maxParticles);
|
|
440
|
-
this .colorArray = new Float32Array (6 * 4 * maxParticles);
|
|
441
|
-
this .texCoordArray = new Float32Array (6 * 4 * maxParticles);
|
|
442
|
-
this .normalArray = new Float32Array (6 * 3 * maxParticles);
|
|
443
|
-
this .vertexArray = new Float32Array (6 * 4 * maxParticles);
|
|
444
|
-
|
|
445
|
-
for (var i = 0, a = this .idArray, l = a .length; i < l; ++ i)
|
|
446
|
-
a [i] = Math .floor (i / 6);
|
|
447
|
-
|
|
448
|
-
this .colorArray .fill (1);
|
|
449
|
-
this .vertexArray .fill (1);
|
|
450
|
-
|
|
451
|
-
var
|
|
452
|
-
texCoordArray = this .texCoordArray,
|
|
453
|
-
normalArray = this .normalArray;
|
|
454
|
-
|
|
455
|
-
for (var i = 0, length = 6 * 3 * maxParticles; i < length; i += 3)
|
|
456
|
-
{
|
|
457
|
-
normalArray [i] = 0;
|
|
458
|
-
normalArray [i + 1] = 0;
|
|
459
|
-
normalArray [i + 2] = 1;
|
|
460
|
-
}
|
|
461
|
-
|
|
462
|
-
gl .bindBuffer (gl .ARRAY_BUFFER, this .normalBuffer);
|
|
463
|
-
gl .bufferData (gl .ARRAY_BUFFER, this .normalArray, gl .STATIC_DRAW);
|
|
464
|
-
|
|
465
|
-
for (var i = 0; i < maxParticles; ++ i)
|
|
466
|
-
{
|
|
467
|
-
var i24 = i * 24;
|
|
468
|
-
|
|
469
|
-
// p4 ------ p3
|
|
470
|
-
// | / |
|
|
471
|
-
// | / |
|
|
472
|
-
// | / |
|
|
473
|
-
// | / |
|
|
474
|
-
// p1 ------ p2
|
|
475
|
-
|
|
476
|
-
// p1
|
|
477
|
-
texCoordArray [i24] = texCoordArray [i24 + 12] = 0;
|
|
478
|
-
texCoordArray [i24 + 1] = texCoordArray [i24 + 13] = 0;
|
|
479
|
-
texCoordArray [i24 + 2] = texCoordArray [i24 + 14] = 0;
|
|
480
|
-
texCoordArray [i24 + 3] = texCoordArray [i24 + 15] = 1;
|
|
481
|
-
|
|
482
|
-
// p2
|
|
483
|
-
texCoordArray [i24 + 4] = 1;
|
|
484
|
-
texCoordArray [i24 + 5] = 0;
|
|
485
|
-
texCoordArray [i24 + 6] = 0;
|
|
486
|
-
texCoordArray [i24 + 7] = 1;
|
|
487
|
-
|
|
488
|
-
// p3
|
|
489
|
-
texCoordArray [i24 + 8] = texCoordArray [i24 + 16] = 1;
|
|
490
|
-
texCoordArray [i24 + 9] = texCoordArray [i24 + 17] = 1;
|
|
491
|
-
texCoordArray [i24 + 10] = texCoordArray [i24 + 18] = 0;
|
|
492
|
-
texCoordArray [i24 + 11] = texCoordArray [i24 + 19] = 1;
|
|
493
|
-
|
|
494
|
-
// p4
|
|
495
|
-
texCoordArray [i24 + 20] = 0;
|
|
496
|
-
texCoordArray [i24 + 21] = 1;
|
|
497
|
-
texCoordArray [i24 + 22] = 0;
|
|
498
|
-
texCoordArray [i24 + 23] = 1;
|
|
499
|
-
}
|
|
500
|
-
|
|
501
|
-
gl .bindBuffer (gl .ARRAY_BUFFER, this .texCoordBuffers [0]);
|
|
502
|
-
gl .bufferData (gl .ARRAY_BUFFER, this .texCoordArray, gl .STATIC_DRAW);
|
|
416
|
+
this .geometryContext .geometryType = 2;
|
|
503
417
|
|
|
504
|
-
this .testWireframe = true;
|
|
505
|
-
this .primitiveMode = gl .TRIANGLES;
|
|
506
418
|
this .texCoordCount = 4;
|
|
507
419
|
this .vertexCount = 6;
|
|
420
|
+
this .hasNormals = true;
|
|
421
|
+
this .primitiveMode = gl .TRIANGLES;
|
|
422
|
+
|
|
423
|
+
this .texCoordsOffset = 0;
|
|
424
|
+
this .normalOffset = Float32Array .BYTES_PER_ELEMENT * 24;
|
|
425
|
+
this .verticesOffset = Float32Array .BYTES_PER_ELEMENT * 27;
|
|
426
|
+
|
|
427
|
+
gl .bindBuffer (gl .ARRAY_BUFFER, this .geometryBuffer);
|
|
428
|
+
gl .bufferData (gl .ARRAY_BUFFER, QuadGeometry, gl .DYNAMIC_DRAW);
|
|
508
429
|
|
|
509
|
-
this .geometryContext .geometryType = 2;
|
|
510
430
|
break;
|
|
511
431
|
}
|
|
512
|
-
case GEOMETRY:
|
|
432
|
+
case GeometryTypes .GEOMETRY:
|
|
513
433
|
{
|
|
514
434
|
this .texCoordCount = 0;
|
|
515
435
|
this .vertexCount = 0;
|
|
436
|
+
|
|
516
437
|
break;
|
|
517
438
|
}
|
|
518
439
|
}
|
|
519
440
|
|
|
520
|
-
|
|
521
|
-
gl .bufferData (gl .ARRAY_BUFFER, this .idArray, gl .STATIC_DRAW);
|
|
441
|
+
this .updateVertexArrays ();
|
|
522
442
|
|
|
523
443
|
this .set_shader__ ();
|
|
524
444
|
this .set_transparent__ ();
|
|
@@ -527,20 +447,17 @@ function (Fields,
|
|
|
527
447
|
{
|
|
528
448
|
switch (this .geometryType)
|
|
529
449
|
{
|
|
530
|
-
case POINT:
|
|
450
|
+
case GeometryTypes .POINT:
|
|
531
451
|
{
|
|
532
452
|
this .shaderNode = this .getBrowser () .getPointShader ();
|
|
533
453
|
break;
|
|
534
454
|
}
|
|
535
|
-
case LINE:
|
|
455
|
+
case GeometryTypes .LINE:
|
|
536
456
|
{
|
|
537
457
|
this .shaderNode = this .getBrowser () .getLineShader ();
|
|
538
458
|
break;
|
|
539
459
|
}
|
|
540
|
-
|
|
541
|
-
case QUAD:
|
|
542
|
-
case SPRITE:
|
|
543
|
-
case GEOMETRY:
|
|
460
|
+
default:
|
|
544
461
|
{
|
|
545
462
|
this .shaderNode = null;
|
|
546
463
|
break;
|
|
@@ -549,37 +466,18 @@ function (Fields,
|
|
|
549
466
|
},
|
|
550
467
|
set_maxParticles__: function ()
|
|
551
468
|
{
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
maxParticles
|
|
555
|
-
|
|
556
|
-
for (var i = this .numParticles, length = Math .min (particles .length, maxParticles); i < length; ++ i)
|
|
557
|
-
{
|
|
558
|
-
particles [i] .life = 1;
|
|
559
|
-
particles [i] .lifetime = -1;
|
|
560
|
-
}
|
|
561
|
-
|
|
562
|
-
for (var i = particles .length, length = maxParticles; i < length; ++ i)
|
|
563
|
-
{
|
|
564
|
-
particles [i] = {
|
|
565
|
-
id: i,
|
|
566
|
-
life: 1,
|
|
567
|
-
lifetime: -1,
|
|
568
|
-
elapsedTime: 0,
|
|
569
|
-
position: new Vector3 (0, 0, 0),
|
|
570
|
-
velocity: new Vector3 (0, 0, 0),
|
|
571
|
-
color: new Vector4 (1, 1, 1, 1),
|
|
572
|
-
distance: 0,
|
|
573
|
-
};
|
|
574
|
-
}
|
|
469
|
+
const
|
|
470
|
+
lastNumParticles = this .numParticles,
|
|
471
|
+
maxParticles = Math .max (0, this ._maxParticles .getValue ());
|
|
575
472
|
|
|
576
473
|
this .maxParticles = maxParticles;
|
|
577
|
-
this .numParticles = Math .min (
|
|
474
|
+
this .numParticles = Math .min (lastNumParticles, maxParticles);
|
|
578
475
|
|
|
579
|
-
if (!
|
|
476
|
+
if (!this .emitterNode .isExplosive ())
|
|
580
477
|
this .creationTime = performance .now () / 1000;
|
|
581
478
|
|
|
582
|
-
this .
|
|
479
|
+
this .resizeBuffers (lastNumParticles);
|
|
480
|
+
this .updateVertexArrays ();
|
|
583
481
|
},
|
|
584
482
|
set_particleLifetime__: function ()
|
|
585
483
|
{
|
|
@@ -593,33 +491,33 @@ function (Fields,
|
|
|
593
491
|
{
|
|
594
492
|
this .emitterNode = X3DCast (X3DConstants .X3DParticleEmitterNode, this ._emitter);
|
|
595
493
|
|
|
596
|
-
if (!
|
|
494
|
+
if (!this .emitterNode)
|
|
597
495
|
this .emitterNode = this .getBrowser () .getDefaultEmitter ();
|
|
598
496
|
|
|
599
497
|
this .createParticles = this ._createParticles .getValue ();
|
|
600
498
|
},
|
|
601
499
|
set_physics__: function ()
|
|
602
500
|
{
|
|
603
|
-
|
|
501
|
+
const
|
|
604
502
|
physics = this ._physics .getValue (),
|
|
605
503
|
forcePhysicsModelNodes = this .forcePhysicsModelNodes,
|
|
606
504
|
boundedPhysicsModelNodes = this .boundedPhysicsModelNodes;
|
|
607
505
|
|
|
608
|
-
for (
|
|
506
|
+
for (let i = 0, length = boundedPhysicsModelNodes .length; i < length; ++ i)
|
|
609
507
|
boundedPhysicsModelNodes [i] .removeInterest ("set_boundedPhysics__", this);
|
|
610
508
|
|
|
611
509
|
forcePhysicsModelNodes .length = 0;
|
|
612
510
|
boundedPhysicsModelNodes .length = 0;
|
|
613
511
|
|
|
614
|
-
for (
|
|
512
|
+
for (let i = 0, length = physics .length; i < length; ++ i)
|
|
615
513
|
{
|
|
616
514
|
try
|
|
617
515
|
{
|
|
618
|
-
|
|
516
|
+
const
|
|
619
517
|
innerNode = physics [i] .getValue () .getInnerNode (),
|
|
620
518
|
type = innerNode .getType ();
|
|
621
519
|
|
|
622
|
-
for (
|
|
520
|
+
for (let t = type .length - 1; t >= 0; -- t)
|
|
623
521
|
{
|
|
624
522
|
switch (type [t])
|
|
625
523
|
{
|
|
@@ -650,7 +548,8 @@ function (Fields,
|
|
|
650
548
|
},
|
|
651
549
|
set_boundedPhysics__: function ()
|
|
652
550
|
{
|
|
653
|
-
|
|
551
|
+
const
|
|
552
|
+
gl = this .getBrowser () .getContext (),
|
|
654
553
|
boundedPhysicsModelNodes = this .boundedPhysicsModelNodes,
|
|
655
554
|
boundedNormals = this .boundedNormals,
|
|
656
555
|
boundedVertices = this .boundedVertices;
|
|
@@ -658,13 +557,43 @@ function (Fields,
|
|
|
658
557
|
boundedNormals .length = 0;
|
|
659
558
|
boundedVertices .length = 0;
|
|
660
559
|
|
|
661
|
-
for (
|
|
560
|
+
for (let i = 0, length = boundedPhysicsModelNodes .length; i < length; ++ i)
|
|
662
561
|
{
|
|
663
562
|
boundedPhysicsModelNodes [i] .addGeometry (boundedNormals, boundedVertices);
|
|
664
563
|
}
|
|
665
564
|
|
|
666
|
-
|
|
667
|
-
|
|
565
|
+
// Texture
|
|
566
|
+
|
|
567
|
+
const
|
|
568
|
+
boundedHierarchy = new BVH (boundedVertices, boundedNormals) .toArray ([ ]),
|
|
569
|
+
numBoundedVertices = boundedVertices .length / 4,
|
|
570
|
+
numBoundedNormals = boundedNormals .length / 3,
|
|
571
|
+
boundedHierarchyLength = boundedHierarchy .length / 4,
|
|
572
|
+
boundedArraySize = Math .ceil (Math .sqrt (numBoundedVertices + numBoundedNormals + boundedHierarchyLength)),
|
|
573
|
+
boundedArray = new Float32Array (boundedArraySize * boundedArraySize * 4);
|
|
574
|
+
|
|
575
|
+
this .boundedVerticesIndex = 0;
|
|
576
|
+
this .boundedNormalsIndex = numBoundedVertices;
|
|
577
|
+
this .boundedHierarchyIndex = this .boundedNormalsIndex + numBoundedNormals;
|
|
578
|
+
this .boundedHierarchyRoot = this .boundedHierarchyIndex + boundedHierarchyLength - 1;
|
|
579
|
+
|
|
580
|
+
boundedArray .set (boundedVertices);
|
|
581
|
+
|
|
582
|
+
for (let s = this .boundedNormalsIndex * 4, n = 0, l = boundedNormals .length; n < l; s += 4, n += 3)
|
|
583
|
+
{
|
|
584
|
+
boundedArray [s + 0] = boundedNormals [n + 0];
|
|
585
|
+
boundedArray [s + 1] = boundedNormals [n + 1];
|
|
586
|
+
boundedArray [s + 2] = boundedNormals [n + 2];
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
boundedArray .set (boundedHierarchy, this .boundedHierarchyIndex * 4);
|
|
590
|
+
|
|
591
|
+
if (boundedArraySize)
|
|
592
|
+
{
|
|
593
|
+
gl .bindTexture (gl .TEXTURE_2D, this .boundedTexture);
|
|
594
|
+
gl .texImage2D (gl .TEXTURE_2D, 0, gl .RGBA32F, boundedArraySize, boundedArraySize, 0, gl .RGBA, gl .FLOAT, boundedArray);
|
|
595
|
+
}
|
|
596
|
+
},
|
|
668
597
|
set_colorRamp__: function ()
|
|
669
598
|
{
|
|
670
599
|
if (this .colorRampNode)
|
|
@@ -680,25 +609,35 @@ function (Fields,
|
|
|
680
609
|
},
|
|
681
610
|
set_color__: function ()
|
|
682
611
|
{
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
612
|
+
const
|
|
613
|
+
gl = this .getBrowser () .getContext (),
|
|
614
|
+
colorKey = this ._colorKey,
|
|
615
|
+
numColors = colorKey .length,
|
|
616
|
+
textureSize = Math .ceil (Math .sqrt (numColors * 2));
|
|
687
617
|
|
|
688
|
-
|
|
689
|
-
colorKeys [i] = colorKey [i];
|
|
618
|
+
let colorRamp = this .colorRamp;
|
|
690
619
|
|
|
691
|
-
|
|
620
|
+
if (textureSize * textureSize * 4 > colorRamp .length)
|
|
621
|
+
colorRamp = this .colorRamp = new Float32Array (textureSize * textureSize * 4);
|
|
622
|
+
|
|
623
|
+
for (let i = 0; i < numColors; ++ i)
|
|
624
|
+
colorRamp [i * 4] = colorKey [i];
|
|
692
625
|
|
|
693
626
|
if (this .colorRampNode)
|
|
694
|
-
this .colorRampNode .
|
|
627
|
+
colorRamp .set (this .colorRampNode .addColors ([ ], numColors) .slice (0, numColors * 4), numColors * 4);
|
|
628
|
+
else
|
|
629
|
+
colorRamp .fill (1, numColors * 4);
|
|
695
630
|
|
|
696
|
-
|
|
697
|
-
|
|
631
|
+
if (textureSize)
|
|
632
|
+
{
|
|
633
|
+
gl .bindTexture (gl .TEXTURE_2D, this .colorRampTexture);
|
|
634
|
+
gl .texImage2D (gl .TEXTURE_2D, 0, gl .RGBA32F, textureSize, textureSize, 0, gl .RGBA, gl .FLOAT, colorRamp);
|
|
635
|
+
}
|
|
698
636
|
|
|
699
|
-
|
|
637
|
+
this .numColors = numColors;
|
|
638
|
+
this .geometryContext .colorMaterial = !! (numColors && this .colorRampNode);
|
|
700
639
|
|
|
701
|
-
this .
|
|
640
|
+
this .updateVertexArrays ();
|
|
702
641
|
},
|
|
703
642
|
set_texCoordRamp__: function ()
|
|
704
643
|
{
|
|
@@ -714,48 +653,117 @@ function (Fields,
|
|
|
714
653
|
},
|
|
715
654
|
set_texCoord__: function ()
|
|
716
655
|
{
|
|
717
|
-
|
|
656
|
+
const
|
|
657
|
+
gl = this .getBrowser () .getContext (),
|
|
718
658
|
texCoordKey = this ._texCoordKey,
|
|
719
|
-
|
|
720
|
-
|
|
659
|
+
numTexCoords = texCoordKey .length,
|
|
660
|
+
textureSize = Math .ceil (Math .sqrt (numTexCoords + numTexCoords * this .texCoordCount));
|
|
661
|
+
|
|
662
|
+
let texCoordRamp = this .texCoordRamp;
|
|
721
663
|
|
|
722
|
-
|
|
723
|
-
|
|
664
|
+
if (textureSize * textureSize * 4 > texCoordRamp .length)
|
|
665
|
+
texCoordRamp = this .texCoordRamp = new Float32Array (textureSize * textureSize * 4);
|
|
666
|
+
else
|
|
667
|
+
texCoordRamp .fill (0);
|
|
724
668
|
|
|
725
|
-
|
|
669
|
+
for (let i = 0; i < numTexCoords; ++ i)
|
|
670
|
+
texCoordRamp [i * 4] = texCoordKey [i];
|
|
726
671
|
|
|
727
672
|
if (this .texCoordRampNode)
|
|
728
|
-
this .texCoordRampNode .getTexCoord (
|
|
673
|
+
texCoordRamp .set (this .texCoordRampNode .getTexCoord ([ ]) .slice (0, numTexCoords * this .texCoordCount * 4), numTexCoords * 4);
|
|
674
|
+
|
|
675
|
+
if (textureSize)
|
|
676
|
+
{
|
|
677
|
+
gl .bindTexture (gl .TEXTURE_2D, this .texCoordRampTexture);
|
|
678
|
+
gl .texImage2D (gl .TEXTURE_2D, 0, gl .RGBA32F, textureSize, textureSize, 0, gl .RGBA, gl .FLOAT, texCoordRamp);
|
|
679
|
+
}
|
|
680
|
+
|
|
681
|
+
this .numTexCoords = this .texCoordRampNode ? numTexCoords : 0;
|
|
682
|
+
|
|
683
|
+
this .updateVertexArrays ();
|
|
684
|
+
},
|
|
685
|
+
updateVertexArrays: function ()
|
|
686
|
+
{
|
|
687
|
+
this .inputParticles .vertexArrayObject .update ();
|
|
688
|
+
this .inputParticles .shadowArrayObject .update ();
|
|
689
|
+
this .inputParticles .emitterArrayObject .update ();
|
|
690
|
+
this .outputParticles .vertexArrayObject .update ();
|
|
691
|
+
this .outputParticles .shadowArrayObject .update ();
|
|
692
|
+
this .outputParticles .emitterArrayObject .update ();
|
|
693
|
+
},
|
|
694
|
+
createTexture: function ()
|
|
695
|
+
{
|
|
696
|
+
const
|
|
697
|
+
gl = this .getBrowser () .getContext (),
|
|
698
|
+
texture = gl .createTexture ();
|
|
699
|
+
|
|
700
|
+
gl .bindTexture (gl .TEXTURE_2D, texture);
|
|
729
701
|
|
|
730
|
-
|
|
731
|
-
|
|
702
|
+
gl .texParameteri (gl .TEXTURE_2D, gl .TEXTURE_WRAP_S, gl .CLAMP_TO_EDGE);
|
|
703
|
+
gl .texParameteri (gl .TEXTURE_2D, gl .TEXTURE_WRAP_T, gl .CLAMP_TO_EDGE);
|
|
704
|
+
gl .texParameteri (gl .TEXTURE_2D, gl .TEXTURE_MAG_FILTER, gl .NEAREST);
|
|
705
|
+
gl .texParameteri (gl .TEXTURE_2D, gl .TEXTURE_MIN_FILTER, gl .NEAREST);
|
|
732
706
|
|
|
733
|
-
|
|
707
|
+
gl .texImage2D (gl .TEXTURE_2D, 0, gl .RGBA32F, 1, 1, 0, gl .RGBA, gl .FLOAT, new Float32Array (4));
|
|
734
708
|
|
|
735
|
-
|
|
709
|
+
return texture;
|
|
736
710
|
},
|
|
737
|
-
|
|
711
|
+
createBuffer: function ()
|
|
738
712
|
{
|
|
739
|
-
|
|
713
|
+
const
|
|
714
|
+
gl = this .getBrowser () .getContext (),
|
|
715
|
+
buffer = gl .createBuffer ();
|
|
716
|
+
|
|
717
|
+
gl .bindBuffer (gl .ARRAY_BUFFER, buffer);
|
|
718
|
+
gl .bufferData (gl .ARRAY_BUFFER, new Uint32Array (), gl .DYNAMIC_DRAW);
|
|
719
|
+
|
|
720
|
+
return buffer;
|
|
721
|
+
},
|
|
722
|
+
resizeBuffers: function (lastNumParticles)
|
|
723
|
+
{
|
|
724
|
+
const
|
|
725
|
+
gl = this .getBrowser () .getContext (),
|
|
726
|
+
maxParticles = this .maxParticles,
|
|
727
|
+
particleStride = this .particleStride,
|
|
728
|
+
outputParticles = Object .assign (gl .createBuffer (), this .outputParticles),
|
|
729
|
+
data = new Uint8Array (maxParticles * particleStride);
|
|
730
|
+
|
|
731
|
+
// Resize input buffer.
|
|
732
|
+
|
|
733
|
+
gl .bindBuffer (gl .ARRAY_BUFFER, this .inputParticles);
|
|
734
|
+
gl .bufferData (gl .ARRAY_BUFFER, data, gl .DYNAMIC_DRAW);
|
|
735
|
+
|
|
736
|
+
// Resize output buffer.
|
|
737
|
+
|
|
738
|
+
gl .bindBuffer (gl .COPY_READ_BUFFER, this .outputParticles);
|
|
739
|
+
gl .bindBuffer (gl .ARRAY_BUFFER, outputParticles);
|
|
740
|
+
gl .bufferData (gl .ARRAY_BUFFER, data, gl .DYNAMIC_DRAW);
|
|
741
|
+
gl .copyBufferSubData (gl .COPY_READ_BUFFER, gl .ARRAY_BUFFER, 0, 0, Math .min (maxParticles * particleStride, lastNumParticles * particleStride));
|
|
742
|
+
gl .deleteBuffer (this .outputParticles);
|
|
743
|
+
|
|
744
|
+
this .outputParticles = outputParticles;
|
|
740
745
|
},
|
|
741
746
|
animateParticles: function ()
|
|
742
747
|
{
|
|
743
|
-
|
|
748
|
+
const
|
|
749
|
+
browser = this .getBrowser (),
|
|
750
|
+
gl = browser .getContext (),
|
|
751
|
+
emitterNode = this .emitterNode;
|
|
744
752
|
|
|
745
753
|
// Determine delta time
|
|
746
754
|
|
|
747
|
-
|
|
748
|
-
DELAY = 15, // Delay in frames when dt
|
|
755
|
+
const
|
|
756
|
+
DELAY = 15, // Delay in frames when dt fully applies.
|
|
749
757
|
dt = 1 / Math .max (10, this .getBrowser () .getCurrentFrameRate ());
|
|
750
758
|
|
|
751
|
-
//
|
|
752
|
-
|
|
759
|
+
// let deltaTime is only for the emitter, this.deltaTime is for the forces.
|
|
760
|
+
let deltaTime = this .deltaTime = ((DELAY - 1) * this .deltaTime + dt) / DELAY; // Moving average about DELAY frames.
|
|
753
761
|
|
|
754
762
|
// Determine numParticles
|
|
755
763
|
|
|
756
764
|
if (emitterNode .isExplosive ())
|
|
757
765
|
{
|
|
758
|
-
|
|
766
|
+
const
|
|
759
767
|
now = performance .now () / 1000,
|
|
760
768
|
particleLifetime = this .particleLifetime + this .particleLifetime * this .lifetimeVariation;
|
|
761
769
|
|
|
@@ -774,7 +782,7 @@ function (Fields,
|
|
|
774
782
|
{
|
|
775
783
|
if (this .numParticles < this .maxParticles)
|
|
776
784
|
{
|
|
777
|
-
|
|
785
|
+
const
|
|
778
786
|
now = performance .now () / 1000,
|
|
779
787
|
newParticles = Math .max (0, Math .floor ((now - this .creationTime) * this .maxParticles / this .particleLifetime));
|
|
780
788
|
|
|
@@ -789,548 +797,106 @@ function (Fields,
|
|
|
789
797
|
|
|
790
798
|
if (emitterNode .getMass ())
|
|
791
799
|
{
|
|
792
|
-
|
|
793
|
-
forcePhysicsModelNodes = this .forcePhysicsModelNodes,
|
|
794
|
-
velocities = this .velocities,
|
|
795
|
-
speeds = this .speeds,
|
|
796
|
-
turbulences = this .turbulences,
|
|
797
|
-
deltaMass = this .deltaTime / emitterNode .getMass ();
|
|
800
|
+
const forcePhysicsModelNodes = this .forcePhysicsModelNodes;
|
|
798
801
|
|
|
799
|
-
|
|
802
|
+
let
|
|
803
|
+
numForces = forcePhysicsModelNodes .length,
|
|
804
|
+
forces = this .forces,
|
|
805
|
+
timeByMass = deltaTime / emitterNode .getMass ();
|
|
800
806
|
|
|
801
|
-
|
|
802
|
-
velocities [i] = new Vector3 (0, 0, 0);
|
|
807
|
+
// Collect forces in velocities and collect turbulences.
|
|
803
808
|
|
|
804
|
-
|
|
805
|
-
|
|
809
|
+
if (numForces * 4 > forces .length)
|
|
810
|
+
forces = this .forces = new Float32Array (numForces * 4);
|
|
806
811
|
|
|
807
|
-
|
|
812
|
+
let disabledForces = 0;
|
|
808
813
|
|
|
809
|
-
for (
|
|
814
|
+
for (let i = 0; i < numForces; ++ i)
|
|
810
815
|
{
|
|
811
|
-
|
|
812
|
-
speeds [i] = velocities [i] .abs ();
|
|
816
|
+
disabledForces += !forcePhysicsModelNodes [i] .addForce (i - disabledForces, emitterNode, timeByMass, forces);
|
|
813
817
|
}
|
|
814
818
|
|
|
815
|
-
this .numForces =
|
|
816
|
-
}
|
|
817
|
-
else
|
|
818
|
-
{
|
|
819
|
-
this .numForces = 0;
|
|
820
|
-
}
|
|
819
|
+
this .numForces = numForces -= disabledForces;
|
|
821
820
|
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
emitterNode .animate (this, deltaTime);
|
|
825
|
-
|
|
826
|
-
this .updateGeometry (null);
|
|
827
|
-
|
|
828
|
-
this .getBrowser () .addBrowserEvent ();
|
|
829
|
-
},
|
|
830
|
-
updateGeometry: function (modelViewMatrix)
|
|
831
|
-
{
|
|
832
|
-
switch (this .geometryType)
|
|
833
|
-
{
|
|
834
|
-
case POINT:
|
|
835
|
-
if (! modelViewMatrix)
|
|
836
|
-
this .updatePoint ();
|
|
837
|
-
break;
|
|
838
|
-
case LINE:
|
|
839
|
-
if (! modelViewMatrix)
|
|
840
|
-
this .updateLine ();
|
|
841
|
-
break;
|
|
842
|
-
case TRIANGLE:
|
|
843
|
-
case QUAD:
|
|
844
|
-
case SPRITE:
|
|
845
|
-
this .updateQuad (modelViewMatrix);
|
|
846
|
-
break;
|
|
847
|
-
case GEOMETRY:
|
|
848
|
-
break;
|
|
849
|
-
}
|
|
850
|
-
},
|
|
851
|
-
updatePoint: function ()
|
|
852
|
-
{
|
|
853
|
-
var
|
|
854
|
-
gl = this .getBrowser () .getContext (),
|
|
855
|
-
particles = this .particles,
|
|
856
|
-
numParticles = this .numParticles,
|
|
857
|
-
positionArray = this .positionArray,
|
|
858
|
-
elapsedTimeArray = this .elapsedTimeArray,
|
|
859
|
-
lifeArray = this .lifeArray,
|
|
860
|
-
colorArray = this .colorArray,
|
|
861
|
-
vertexArray = this .vertexArray;
|
|
862
|
-
|
|
863
|
-
// Colors
|
|
864
|
-
|
|
865
|
-
if (this .geometryContext .colorMaterial)
|
|
866
|
-
{
|
|
867
|
-
for (var i = 0; i < numParticles; ++ i)
|
|
821
|
+
if (numForces)
|
|
868
822
|
{
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
i4 = i * 4;
|
|
872
|
-
|
|
873
|
-
colorArray [i4] = color .x;
|
|
874
|
-
colorArray [i4 + 1] = color .y;
|
|
875
|
-
colorArray [i4 + 2] = color .z;
|
|
876
|
-
colorArray [i4 + 3] = color .w;
|
|
823
|
+
gl .bindTexture (gl .TEXTURE_2D, this .forcesTexture);
|
|
824
|
+
gl .texImage2D (gl .TEXTURE_2D, 0, gl .RGBA32F, numForces, 1, 0, gl .RGBA, gl .FLOAT, forces);
|
|
877
825
|
}
|
|
878
|
-
|
|
879
|
-
gl .bindBuffer (gl .ARRAY_BUFFER, this .colorBuffer);
|
|
880
|
-
gl .bufferData (gl .ARRAY_BUFFER, this .colorArray, gl .STATIC_DRAW);
|
|
881
826
|
}
|
|
882
|
-
|
|
883
|
-
// Vertices
|
|
884
|
-
|
|
885
|
-
for (var i = 0; i < numParticles; ++ i)
|
|
827
|
+
else
|
|
886
828
|
{
|
|
887
|
-
|
|
888
|
-
position = particles [i] .position,
|
|
889
|
-
elapsedTime = particles [i] .elapsedTime / particles [i] .lifetime,
|
|
890
|
-
i3 = i * 3,
|
|
891
|
-
i4 = i * 4;
|
|
892
|
-
|
|
893
|
-
positionArray [i3] = position .x;
|
|
894
|
-
positionArray [i3 + 1] = position .y;
|
|
895
|
-
positionArray [i3 + 2] = position .z;
|
|
896
|
-
|
|
897
|
-
elapsedTimeArray [i] = elapsedTime;
|
|
898
|
-
lifeArray [i] = particles [i] .life;
|
|
899
|
-
|
|
900
|
-
vertexArray [i4] = position .x;
|
|
901
|
-
vertexArray [i4 + 1] = position .y;
|
|
902
|
-
vertexArray [i4 + 2] = position .z;
|
|
829
|
+
this .numForces = 0;
|
|
903
830
|
}
|
|
904
831
|
|
|
905
|
-
|
|
906
|
-
gl .bufferData (gl .ARRAY_BUFFER, this .positionArray, gl .STATIC_DRAW);
|
|
907
|
-
gl .bindBuffer (gl .ARRAY_BUFFER, this .elapsedTimeBuffer);
|
|
908
|
-
gl .bufferData (gl .ARRAY_BUFFER, this .elapsedTimeArray, gl .STATIC_DRAW);
|
|
909
|
-
gl .bindBuffer (gl .ARRAY_BUFFER, this .lifeBuffer);
|
|
910
|
-
gl .bufferData (gl .ARRAY_BUFFER, this .lifeArray, gl .STATIC_DRAW);
|
|
911
|
-
gl .bindBuffer (gl .ARRAY_BUFFER, this .vertexBuffer);
|
|
912
|
-
gl .bufferData (gl .ARRAY_BUFFER, this .vertexArray, gl .STATIC_DRAW);
|
|
913
|
-
},
|
|
914
|
-
updateLine: function ()
|
|
915
|
-
{
|
|
916
|
-
var
|
|
917
|
-
gl = this .getBrowser () .getContext (),
|
|
918
|
-
particles = this .particles,
|
|
919
|
-
numParticles = this .numParticles,
|
|
920
|
-
positionArray = this .positionArray,
|
|
921
|
-
elapsedTimeArray = this .elapsedTimeArray,
|
|
922
|
-
lifeArray = this .lifeArray,
|
|
923
|
-
colorArray = this .colorArray,
|
|
924
|
-
vertexArray = this .vertexArray,
|
|
925
|
-
sy1_2 = this ._particleSize .y / 2;
|
|
926
|
-
|
|
927
|
-
// Colors
|
|
928
|
-
|
|
929
|
-
if (this .geometryContext .colorMaterial)
|
|
930
|
-
{
|
|
931
|
-
for (var i = 0; i < numParticles; ++ i)
|
|
932
|
-
{
|
|
933
|
-
var
|
|
934
|
-
color = particles [i] .color,
|
|
935
|
-
i8 = i * 8;
|
|
936
|
-
|
|
937
|
-
colorArray [i8] = color .x;
|
|
938
|
-
colorArray [i8 + 1] = color .y;
|
|
939
|
-
colorArray [i8 + 2] = color .z;
|
|
940
|
-
colorArray [i8 + 3] = color .w;
|
|
941
|
-
|
|
942
|
-
colorArray [i8 + 4] = color .x;
|
|
943
|
-
colorArray [i8 + 5] = color .y;
|
|
944
|
-
colorArray [i8 + 6] = color .z;
|
|
945
|
-
colorArray [i8 + 7] = color .w;
|
|
946
|
-
}
|
|
832
|
+
// Swap buffers.
|
|
947
833
|
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
834
|
+
const inputParticles = this .outputParticles;
|
|
835
|
+
this .outputParticles = this .inputParticles;
|
|
836
|
+
this .inputParticles = inputParticles;
|
|
951
837
|
|
|
952
|
-
//
|
|
838
|
+
// Determine particle position, velocity and colors.
|
|
953
839
|
|
|
954
|
-
|
|
955
|
-
{
|
|
956
|
-
var
|
|
957
|
-
particle = particles [i],
|
|
958
|
-
position = particle .position,
|
|
959
|
-
elapsedTime = particles [i] .elapsedTime / particles [i] .lifetime,
|
|
960
|
-
life = particles [i] .life,
|
|
961
|
-
x = position .x,
|
|
962
|
-
y = position .y,
|
|
963
|
-
z = position .z,
|
|
964
|
-
i2 = i * 2,
|
|
965
|
-
i6 = i * 6,
|
|
966
|
-
i8 = i * 8;
|
|
967
|
-
|
|
968
|
-
positionArray [i6] = x;
|
|
969
|
-
positionArray [i6 + 1] = y;
|
|
970
|
-
positionArray [i6 + 2] = z;
|
|
971
|
-
positionArray [i6 + 3] = x;
|
|
972
|
-
positionArray [i6 + 4] = y;
|
|
973
|
-
positionArray [i6 + 5] = z;
|
|
974
|
-
|
|
975
|
-
elapsedTimeArray [i2] = elapsedTime;
|
|
976
|
-
elapsedTimeArray [i2 + 1] = elapsedTime;
|
|
977
|
-
|
|
978
|
-
lifeArray [i2] = life;
|
|
979
|
-
lifeArray [i2 + 1] = life;
|
|
980
|
-
|
|
981
|
-
// Length of line / 2.
|
|
982
|
-
normal .assign (particle .velocity) .normalize () .multiply (sy1_2);
|
|
983
|
-
|
|
984
|
-
vertexArray [i8] = x - normal .x;
|
|
985
|
-
vertexArray [i8 + 1] = y - normal .y;
|
|
986
|
-
vertexArray [i8 + 2] = z - normal .z;
|
|
987
|
-
|
|
988
|
-
vertexArray [i8 + 4] = x + normal .x;
|
|
989
|
-
vertexArray [i8 + 5] = y + normal .y;
|
|
990
|
-
vertexArray [i8 + 6] = z + normal .z;
|
|
991
|
-
}
|
|
840
|
+
emitterNode .animate (this, deltaTime);
|
|
992
841
|
|
|
993
|
-
|
|
994
|
-
gl .bufferData (gl .ARRAY_BUFFER, this .positionArray, gl .STATIC_DRAW);
|
|
995
|
-
gl .bindBuffer (gl .ARRAY_BUFFER, this .elapsedTimeBuffer);
|
|
996
|
-
gl .bufferData (gl .ARRAY_BUFFER, this .elapsedTimeArray, gl .STATIC_DRAW);
|
|
997
|
-
gl .bindBuffer (gl .ARRAY_BUFFER, this .lifeBuffer);
|
|
998
|
-
gl .bufferData (gl .ARRAY_BUFFER, this .lifeArray, gl .STATIC_DRAW);
|
|
999
|
-
gl .bindBuffer (gl .ARRAY_BUFFER, this .vertexBuffer);
|
|
1000
|
-
gl .bufferData (gl .ARRAY_BUFFER, this .vertexArray, gl .STATIC_DRAW);
|
|
842
|
+
browser .addBrowserEvent ();
|
|
1001
843
|
},
|
|
1002
|
-
|
|
844
|
+
updateSprite: (function ()
|
|
1003
845
|
{
|
|
1004
|
-
|
|
1005
|
-
{
|
|
1006
|
-
var
|
|
1007
|
-
gl = this .getBrowser () .getContext (),
|
|
1008
|
-
particles = this .particles,
|
|
1009
|
-
maxParticles = this .maxParticles,
|
|
1010
|
-
numParticles = this .numParticles,
|
|
1011
|
-
positionArray = this .positionArray,
|
|
1012
|
-
elapsedTimeArray = this .elapsedTimeArray,
|
|
1013
|
-
lifeArray = this .lifeArray,
|
|
1014
|
-
colorArray = this .colorArray,
|
|
1015
|
-
texCoordArray = this .texCoordArray,
|
|
1016
|
-
normalArray = this .normalArray,
|
|
1017
|
-
vertexArray = this .vertexArray,
|
|
1018
|
-
sx1_2 = this ._particleSize .x / 2,
|
|
1019
|
-
sy1_2 = this ._particleSize .y / 2;
|
|
1020
|
-
|
|
1021
|
-
// Sort particles
|
|
1022
|
-
|
|
1023
|
-
// if (this .sortParticles) // always false
|
|
1024
|
-
// {
|
|
1025
|
-
// for (var i = 0; i < numParticles; ++ i)
|
|
1026
|
-
// {
|
|
1027
|
-
// var particle = particles [i];
|
|
1028
|
-
// particle .distance = modelViewMatrix .getDepth (particle .position);
|
|
1029
|
-
// }
|
|
1030
|
-
//
|
|
1031
|
-
// // Expensisive function!!!
|
|
1032
|
-
// this .particleSorter .sort (0, numParticles);
|
|
1033
|
-
// }
|
|
1034
|
-
|
|
1035
|
-
// Colors
|
|
1036
|
-
|
|
1037
|
-
if (! modelViewMatrix) // if called from animateParticles
|
|
1038
|
-
{
|
|
1039
|
-
if (this .geometryContext .colorMaterial)
|
|
1040
|
-
{
|
|
1041
|
-
for (var i = 0; i < maxParticles; ++ i)
|
|
1042
|
-
{
|
|
1043
|
-
var
|
|
1044
|
-
color = particles [i] .color,
|
|
1045
|
-
i24 = i * 24;
|
|
1046
|
-
|
|
1047
|
-
// p4 ------ p3
|
|
1048
|
-
// | / |
|
|
1049
|
-
// | / |
|
|
1050
|
-
// | / |
|
|
1051
|
-
// | / |
|
|
1052
|
-
// p1 ------ p2
|
|
1053
|
-
|
|
1054
|
-
// p1, p2, p3; p1, p3, p4
|
|
1055
|
-
colorArray [i24] = colorArray [i24 + 4] = colorArray [i24 + 8] = colorArray [i24 + 12] = colorArray [i24 + 16] = colorArray [i24 + 20] = color .x;
|
|
1056
|
-
colorArray [i24 + 1] = colorArray [i24 + 5] = colorArray [i24 + 9] = colorArray [i24 + 13] = colorArray [i24 + 17] = colorArray [i24 + 21] = color .y;
|
|
1057
|
-
colorArray [i24 + 2] = colorArray [i24 + 6] = colorArray [i24 + 10] = colorArray [i24 + 14] = colorArray [i24 + 18] = colorArray [i24 + 22] = color .z;
|
|
1058
|
-
colorArray [i24 + 3] = colorArray [i24 + 7] = colorArray [i24 + 11] = colorArray [i24 + 15] = colorArray [i24 + 19] = colorArray [i24 + 23] = color .w;
|
|
1059
|
-
}
|
|
1060
|
-
|
|
1061
|
-
gl .bindBuffer (gl .ARRAY_BUFFER, this .colorBuffer);
|
|
1062
|
-
gl .bufferData (gl .ARRAY_BUFFER, this .colorArray, gl .STATIC_DRAW);
|
|
1063
|
-
}
|
|
1064
|
-
|
|
1065
|
-
if (this .texCoordAnim && this .texCoordArray .length)
|
|
1066
|
-
{
|
|
1067
|
-
var
|
|
1068
|
-
texCoordKeys = this .texCoordKeys,
|
|
1069
|
-
texCoordRamp = this .texCoordRamp;
|
|
846
|
+
const data = new Float32Array (QuadGeometry);
|
|
1070
847
|
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
848
|
+
const quad = [
|
|
849
|
+
new Vector3 (-0.5, -0.5, 0),
|
|
850
|
+
new Vector3 ( 0.5, -0.5, 0),
|
|
851
|
+
new Vector3 ( 0.5, 0.5, 0),
|
|
852
|
+
new Vector3 (-0.5, -0.5, 0),
|
|
853
|
+
new Vector3 ( 0.5, 0.5, 0),
|
|
854
|
+
new Vector3 (-0.5, 0.5, 0),
|
|
855
|
+
];
|
|
1074
856
|
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
var
|
|
1080
|
-
particle = particles [i],
|
|
1081
|
-
fraction = particle .elapsedTime / particle .lifetime;
|
|
1082
|
-
|
|
1083
|
-
if (length == 1 || fraction <= texCoordKeys [0])
|
|
1084
|
-
{
|
|
1085
|
-
index0 = 0;
|
|
1086
|
-
}
|
|
1087
|
-
else if (fraction >= texCoordKeys .at (-1))
|
|
1088
|
-
{
|
|
1089
|
-
index0 = length - 2;
|
|
1090
|
-
}
|
|
1091
|
-
else
|
|
1092
|
-
{
|
|
1093
|
-
var index = Algorithm .upperBound (texCoordKeys, 0, length, fraction, Algorithm .less);
|
|
1094
|
-
|
|
1095
|
-
if (index < length)
|
|
1096
|
-
index0 = index - 1;
|
|
1097
|
-
else
|
|
1098
|
-
index0 = 0;
|
|
1099
|
-
}
|
|
857
|
+
const
|
|
858
|
+
vertex = new Vector3 (0, 0, 0),
|
|
859
|
+
size = new Vector3 (0, 0, 0);
|
|
1100
860
|
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
var
|
|
1106
|
-
texCoord1 = texCoordRamp [index0],
|
|
1107
|
-
texCoord2 = texCoordRamp [index0 + 1],
|
|
1108
|
-
texCoord3 = texCoordRamp [index0 + 2],
|
|
1109
|
-
texCoord4 = texCoordRamp [index0 + 3],
|
|
1110
|
-
i24 = i * 24;
|
|
1111
|
-
|
|
1112
|
-
// p4 ------ p3
|
|
1113
|
-
// | / |
|
|
1114
|
-
// | / |
|
|
1115
|
-
// | / |
|
|
1116
|
-
// | / |
|
|
1117
|
-
// p1 ------ p2
|
|
1118
|
-
|
|
1119
|
-
// p1
|
|
1120
|
-
texCoordArray [i24] = texCoordArray [i24 + 12] = texCoord1 .x;
|
|
1121
|
-
texCoordArray [i24 + 1] = texCoordArray [i24 + 13] = texCoord1 .y;
|
|
1122
|
-
texCoordArray [i24 + 2] = texCoordArray [i24 + 14] = texCoord1 .z;
|
|
1123
|
-
texCoordArray [i24 + 3] = texCoordArray [i24 + 15] = texCoord1 .w;
|
|
1124
|
-
|
|
1125
|
-
// p2
|
|
1126
|
-
texCoordArray [i24 + 4] = texCoord2 .x;
|
|
1127
|
-
texCoordArray [i24 + 5] = texCoord2 .y;
|
|
1128
|
-
texCoordArray [i24 + 6] = texCoord2 .z;
|
|
1129
|
-
texCoordArray [i24 + 7] = texCoord2 .w;
|
|
1130
|
-
|
|
1131
|
-
// p3
|
|
1132
|
-
texCoordArray [i24 + 8] = texCoordArray [i24 + 16] = texCoord3 .x;
|
|
1133
|
-
texCoordArray [i24 + 9] = texCoordArray [i24 + 17] = texCoord3 .y;
|
|
1134
|
-
texCoordArray [i24 + 10] = texCoordArray [i24 + 18] = texCoord3 .z;
|
|
1135
|
-
texCoordArray [i24 + 11] = texCoordArray [i24 + 19] = texCoord3 .w;
|
|
1136
|
-
|
|
1137
|
-
// p4
|
|
1138
|
-
texCoordArray [i24 + 20] = texCoord4 .x;
|
|
1139
|
-
texCoordArray [i24 + 21] = texCoord4 .y;
|
|
1140
|
-
texCoordArray [i24 + 22] = texCoord4 .z;
|
|
1141
|
-
texCoordArray [i24 + 23] = texCoord4 .w;
|
|
1142
|
-
}
|
|
861
|
+
return function (gl, rotation)
|
|
862
|
+
{
|
|
863
|
+
// Normal
|
|
1143
864
|
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
}
|
|
1147
|
-
}
|
|
865
|
+
for (let i = 0; i < 3; ++ i)
|
|
866
|
+
data [24 + i] = rotation [6 + i];
|
|
1148
867
|
|
|
1149
868
|
// Vertices
|
|
1150
869
|
|
|
1151
|
-
|
|
1152
|
-
{
|
|
1153
|
-
if (modelViewMatrix) // if called from depth or draw
|
|
1154
|
-
{
|
|
1155
|
-
// Normals
|
|
1156
|
-
|
|
1157
|
-
var rotation = this .getScreenAlignedRotation (modelViewMatrix);
|
|
1158
|
-
|
|
1159
|
-
normal
|
|
1160
|
-
.set (rotation [0], rotation [1], rotation [2])
|
|
1161
|
-
.cross (vector .set (rotation [3], rotation [4], rotation [5]))
|
|
1162
|
-
.normalize ();
|
|
1163
|
-
|
|
1164
|
-
var
|
|
1165
|
-
nx = normal .x,
|
|
1166
|
-
ny = normal .y,
|
|
1167
|
-
nz = normal .z;
|
|
1168
|
-
|
|
1169
|
-
for (var i = 0, length = 6 * 3 * maxParticles; i < length; i += 3)
|
|
1170
|
-
{
|
|
1171
|
-
normalArray [i] = nx;
|
|
1172
|
-
normalArray [i + 1] = ny;
|
|
1173
|
-
normalArray [i + 2] = nz;
|
|
1174
|
-
}
|
|
1175
|
-
|
|
1176
|
-
gl .bindBuffer (gl .ARRAY_BUFFER, this .normalBuffer);
|
|
1177
|
-
gl .bufferData (gl .ARRAY_BUFFER, this .normalArray, gl .STATIC_DRAW);
|
|
870
|
+
size .set (this ._particleSize .x, this ._particleSize .y, 1);
|
|
1178
871
|
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
s2 .set ( sx1_2, -sy1_2, 0);
|
|
1183
|
-
s3 .set ( sx1_2, sy1_2, 0);
|
|
1184
|
-
s4 .set (-sx1_2, sy1_2, 0);
|
|
1185
|
-
|
|
1186
|
-
rotation .multVecMatrix (s1);
|
|
1187
|
-
rotation .multVecMatrix (s2);
|
|
1188
|
-
rotation .multVecMatrix (s3);
|
|
1189
|
-
rotation .multVecMatrix (s4);
|
|
872
|
+
for (let i = 0; i < 6; ++ i)
|
|
873
|
+
{
|
|
874
|
+
const index = 27 + i * 4;
|
|
1190
875
|
|
|
1191
|
-
|
|
1192
|
-
{
|
|
1193
|
-
var
|
|
1194
|
-
position = particles [i] .position,
|
|
1195
|
-
elapsedTime = particles [i] .elapsedTime / particles [i] .lifetime,
|
|
1196
|
-
x = position .x,
|
|
1197
|
-
y = position .y,
|
|
1198
|
-
z = position .z,
|
|
1199
|
-
i6 = i * 6,
|
|
1200
|
-
i18 = i * 18,
|
|
1201
|
-
i24 = i * 24;
|
|
1202
|
-
|
|
1203
|
-
// p4 ------ p3
|
|
1204
|
-
// | / |
|
|
1205
|
-
// | / |
|
|
1206
|
-
// | / |
|
|
1207
|
-
// | / |
|
|
1208
|
-
// p1 ------ p2
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
positionArray [i18] = positionArray [i18 + 3] = positionArray [i18 + 6] = positionArray [i18 + 9] = positionArray [i18 + 12] = positionArray [i18 + 15] = x;
|
|
1212
|
-
positionArray [i18 + 1] = positionArray [i18 + 4] = positionArray [i18 + 7] = positionArray [i18 + 10] = positionArray [i18 + 13] = positionArray [i18 + 16] = y;
|
|
1213
|
-
positionArray [i18 + 2] = positionArray [i18 + 5] = positionArray [i18 + 8] = positionArray [i18 + 11] = positionArray [i18 + 14] = positionArray [i18 + 17] = z;
|
|
1214
|
-
|
|
1215
|
-
elapsedTimeArray [i6] = elapsedTimeArray [i6 + 1] = elapsedTimeArray [i6 + 2] = elapsedTimeArray [i6 + 3] = elapsedTimeArray [i6 + 4] = elapsedTimeArray [i6 + 5] = elapsedTime;
|
|
1216
|
-
lifeArray [i6] = lifeArray [i6 + 1] = lifeArray [i6 + 2] = lifeArray [i6 + 3] = lifeArray [i6 + 4] = lifeArray [i6 + 5] = particles [i] .life;
|
|
1217
|
-
|
|
1218
|
-
// p1
|
|
1219
|
-
vertexArray [i24] = vertexArray [i24 + 12] = x + s1 .x;
|
|
1220
|
-
vertexArray [i24 + 1] = vertexArray [i24 + 13] = y + s1 .y;
|
|
1221
|
-
vertexArray [i24 + 2] = vertexArray [i24 + 14] = z + s1 .z;
|
|
1222
|
-
|
|
1223
|
-
// p2
|
|
1224
|
-
vertexArray [i24 + 4] = x + s2 .x;
|
|
1225
|
-
vertexArray [i24 + 5] = y + s2 .y;
|
|
1226
|
-
vertexArray [i24 + 6] = z + s2 .z;
|
|
1227
|
-
|
|
1228
|
-
// p3
|
|
1229
|
-
vertexArray [i24 + 8] = vertexArray [i24 + 16] = x + s3 .x;
|
|
1230
|
-
vertexArray [i24 + 9] = vertexArray [i24 + 17] = y + s3 .y;
|
|
1231
|
-
vertexArray [i24 + 10] = vertexArray [i24 + 18] = z + s3 .z;
|
|
1232
|
-
|
|
1233
|
-
// p4
|
|
1234
|
-
vertexArray [i24 + 20] = x + s4 .x;
|
|
1235
|
-
vertexArray [i24 + 21] = y + s4 .y;
|
|
1236
|
-
vertexArray [i24 + 22] = z + s4 .z;
|
|
1237
|
-
}
|
|
876
|
+
rotation .multVecMatrix (vertex .assign (quad [i]) .multVec (size))
|
|
1238
877
|
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
gl .bufferData (gl .ARRAY_BUFFER, this .elapsedTimeArray, gl .STATIC_DRAW);
|
|
1243
|
-
gl .bindBuffer (gl .ARRAY_BUFFER, this .lifeBuffer);
|
|
1244
|
-
gl .bufferData (gl .ARRAY_BUFFER, this .lifeArray, gl .STATIC_DRAW);
|
|
1245
|
-
gl .bindBuffer (gl .ARRAY_BUFFER, this .vertexBuffer);
|
|
1246
|
-
gl .bufferData (gl .ARRAY_BUFFER, this .vertexArray, gl .STATIC_DRAW);
|
|
1247
|
-
}
|
|
878
|
+
data [index + 0] = vertex .x;
|
|
879
|
+
data [index + 1] = vertex .y;
|
|
880
|
+
data [index + 2] = vertex .z;
|
|
1248
881
|
}
|
|
1249
|
-
else
|
|
1250
|
-
{
|
|
1251
|
-
if (! modelViewMatrix) // if called from animateParticles
|
|
1252
|
-
{
|
|
1253
|
-
for (var i = 0; i < numParticles; ++ i)
|
|
1254
|
-
{
|
|
1255
|
-
var
|
|
1256
|
-
position = particles [i] .position,
|
|
1257
|
-
elapsedTime = particles [i] .elapsedTime / particles [i] .lifetime,
|
|
1258
|
-
x = position .x,
|
|
1259
|
-
y = position .y,
|
|
1260
|
-
z = position .z,
|
|
1261
|
-
i6 = i * 6,
|
|
1262
|
-
i18 = i * 18,
|
|
1263
|
-
i24 = i * 24;
|
|
1264
|
-
|
|
1265
|
-
// p4 ------ p3
|
|
1266
|
-
// | / |
|
|
1267
|
-
// | / |
|
|
1268
|
-
// | / |
|
|
1269
|
-
// | / |
|
|
1270
|
-
// p1 ------ p2
|
|
1271
|
-
|
|
1272
|
-
positionArray [i18] = positionArray [i18 + 3] = positionArray [i18 + 6] = positionArray [i18 + 9] = positionArray [i18 + 12] = positionArray [i18 + 15] = x;
|
|
1273
|
-
positionArray [i18 + 1] = positionArray [i18 + 4] = positionArray [i18 + 7] = positionArray [i18 + 10] = positionArray [i18 + 13] = positionArray [i18 + 16] = y;
|
|
1274
|
-
positionArray [i18 + 2] = positionArray [i18 + 5] = positionArray [i18 + 8] = positionArray [i18 + 11] = positionArray [i18 + 14] = positionArray [i18 + 17] = z;
|
|
1275
|
-
|
|
1276
|
-
elapsedTimeArray [i6] = elapsedTimeArray [i6 + 1] = elapsedTimeArray [i6 + 2] = elapsedTimeArray [i6 + 3] = elapsedTimeArray [i6 + 4] = elapsedTimeArray [i6 + 5] = elapsedTime;
|
|
1277
|
-
lifeArray [i6] = lifeArray [i6 + 1] = lifeArray [i6 + 2] = lifeArray [i6 + 3] = lifeArray [i6 + 4] = lifeArray [i6 + 5] = particles [i] .life;
|
|
1278
|
-
|
|
1279
|
-
// p1
|
|
1280
|
-
vertexArray [i24] = vertexArray [i24 + 12] = x - sx1_2;
|
|
1281
|
-
vertexArray [i24 + 1] = vertexArray [i24 + 13] = y - sy1_2;
|
|
1282
|
-
vertexArray [i24 + 2] = vertexArray [i24 + 14] = z;
|
|
1283
|
-
|
|
1284
|
-
// p2
|
|
1285
|
-
vertexArray [i24 + 4] = x + sx1_2;
|
|
1286
|
-
vertexArray [i24 + 5] = y - sy1_2;
|
|
1287
|
-
vertexArray [i24 + 6] = z;
|
|
1288
|
-
|
|
1289
|
-
// p3
|
|
1290
|
-
vertexArray [i24 + 8] = vertexArray [i24 + 16] = x + sx1_2;
|
|
1291
|
-
vertexArray [i24 + 9] = vertexArray [i24 + 17] = y + sy1_2;
|
|
1292
|
-
vertexArray [i24 + 10] = vertexArray [i24 + 18] = z;
|
|
1293
|
-
|
|
1294
|
-
// p4
|
|
1295
|
-
vertexArray [i24 + 20] = x - sx1_2;
|
|
1296
|
-
vertexArray [i24 + 21] = y + sy1_2;
|
|
1297
|
-
vertexArray [i24 + 22] = z;
|
|
1298
|
-
}
|
|
1299
882
|
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
gl .bindBuffer (gl .ARRAY_BUFFER, this .vertexBuffer);
|
|
1307
|
-
gl .bufferData (gl .ARRAY_BUFFER, this .vertexArray, gl .STATIC_DRAW);
|
|
1308
|
-
}
|
|
1309
|
-
}
|
|
1310
|
-
}
|
|
1311
|
-
catch (error)
|
|
1312
|
-
{
|
|
1313
|
-
console .error (error);
|
|
1314
|
-
}
|
|
1315
|
-
},
|
|
883
|
+
gl .bindBuffer (gl .ARRAY_BUFFER, this .geometryBuffer);
|
|
884
|
+
gl .bufferData (gl .ARRAY_BUFFER, data, gl .DYNAMIC_DRAW);
|
|
885
|
+
};
|
|
886
|
+
})(),
|
|
887
|
+
intersectsBox: function (box, clipPlanes)
|
|
888
|
+
{ },
|
|
1316
889
|
traverse: function (type, renderObject)
|
|
1317
890
|
{
|
|
1318
|
-
if (
|
|
891
|
+
if (this .numParticles === 0)
|
|
1319
892
|
return;
|
|
1320
893
|
|
|
1321
894
|
switch (type)
|
|
1322
895
|
{
|
|
1323
896
|
case TraverseType .POINTER:
|
|
1324
|
-
{
|
|
1325
|
-
break;
|
|
1326
|
-
}
|
|
1327
897
|
case TraverseType .PICKING:
|
|
1328
|
-
{
|
|
1329
|
-
break;
|
|
1330
|
-
}
|
|
1331
898
|
case TraverseType .COLLISION:
|
|
1332
899
|
{
|
|
1333
|
-
// TODO: to be implemented.
|
|
1334
900
|
break;
|
|
1335
901
|
}
|
|
1336
902
|
case TraverseType .SHADOW:
|
|
@@ -1349,7 +915,7 @@ function (Fields,
|
|
|
1349
915
|
}
|
|
1350
916
|
}
|
|
1351
917
|
|
|
1352
|
-
if (this .geometryType === GEOMETRY)
|
|
918
|
+
if (this .geometryType === GeometryTypes .GEOMETRY)
|
|
1353
919
|
{
|
|
1354
920
|
if (this .getGeometry ())
|
|
1355
921
|
this .getGeometry () .traverse (type, renderObject); // Currently used for ScreenText.
|
|
@@ -1357,76 +923,88 @@ function (Fields,
|
|
|
1357
923
|
},
|
|
1358
924
|
depth: function (gl, context, shaderNode)
|
|
1359
925
|
{
|
|
1360
|
-
// Update geometry if SPRITE.
|
|
1361
|
-
|
|
1362
|
-
this .updateGeometry (context .modelViewMatrix);
|
|
1363
|
-
|
|
1364
926
|
// Display geometry.
|
|
1365
927
|
|
|
1366
|
-
|
|
928
|
+
switch (this .geometryType)
|
|
1367
929
|
{
|
|
1368
|
-
|
|
930
|
+
case GeometryTypes .GEOMETRY:
|
|
931
|
+
{
|
|
932
|
+
const geometryNode = this .getGeometry ();
|
|
1369
933
|
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
}
|
|
1373
|
-
else
|
|
1374
|
-
{
|
|
1375
|
-
if (this .numParticles <= 0)
|
|
1376
|
-
return;
|
|
934
|
+
if (geometryNode)
|
|
935
|
+
geometryNode .displayParticlesDepth (gl, context, shaderNode, this);
|
|
1377
936
|
|
|
1378
|
-
|
|
937
|
+
break;
|
|
938
|
+
}
|
|
939
|
+
case GeometryTypes .SPRITE:
|
|
1379
940
|
{
|
|
1380
|
-
|
|
941
|
+
this .updateSprite (gl, this .getScreenAlignedRotation (context .modelViewMatrix));
|
|
942
|
+
// [fall trough]
|
|
943
|
+
}
|
|
944
|
+
default:
|
|
945
|
+
{
|
|
946
|
+
const outputParticles = this .outputParticles;
|
|
947
|
+
|
|
948
|
+
if (outputParticles .shadowArrayObject .enable (gl, shaderNode))
|
|
949
|
+
{
|
|
950
|
+
const particleStride = this .particleStride;
|
|
1381
951
|
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
shaderNode .enableVertexAttribute (gl, this .vertexBuffer);
|
|
952
|
+
shaderNode .enableParticleAttribute (gl, outputParticles, particleStride, this .particleOffset, 1);
|
|
953
|
+
shaderNode .enableParticleMatrixAttribute (gl, outputParticles, particleStride, this .matrixOffset, 1);
|
|
954
|
+
shaderNode .enableVertexAttribute (gl, this .geometryBuffer, 0, this .verticesOffset);
|
|
955
|
+
}
|
|
1387
956
|
|
|
1388
|
-
gl .
|
|
957
|
+
gl .drawArraysInstanced (this .primitiveMode, 0, this .vertexCount, this .numParticles);
|
|
1389
958
|
|
|
1390
|
-
|
|
1391
|
-
shaderNode .disableFloatAttrib (gl, "x3d_ParticlePosition");
|
|
1392
|
-
shaderNode .disableFloatAttrib (gl, "x3d_ParticleElapsedTime");
|
|
1393
|
-
shaderNode .disableFloatAttrib (gl, "x3d_ParticleLife");
|
|
959
|
+
break;
|
|
1394
960
|
}
|
|
1395
961
|
}
|
|
1396
962
|
},
|
|
1397
963
|
display: function (gl, context)
|
|
1398
964
|
{
|
|
1399
|
-
|
|
1400
|
-
{
|
|
1401
|
-
if (this .numParticles <= 0)
|
|
1402
|
-
return;
|
|
1403
|
-
|
|
1404
|
-
// Update geometry if SPRITE.
|
|
1405
|
-
|
|
1406
|
-
this .updateGeometry (context .modelViewMatrix);
|
|
1407
|
-
|
|
1408
|
-
// Display geometry.
|
|
965
|
+
// Display geometry.
|
|
1409
966
|
|
|
1410
|
-
|
|
967
|
+
switch (this .geometryType)
|
|
968
|
+
{
|
|
969
|
+
case GeometryTypes .GEOMETRY:
|
|
1411
970
|
{
|
|
1412
971
|
const geometryNode = this .getGeometry ();
|
|
1413
972
|
|
|
1414
973
|
if (geometryNode)
|
|
1415
|
-
geometryNode .displayParticles (gl, context, this
|
|
974
|
+
geometryNode .displayParticles (gl, context, this);
|
|
975
|
+
|
|
976
|
+
break;
|
|
1416
977
|
}
|
|
1417
|
-
|
|
978
|
+
case GeometryTypes .SPRITE:
|
|
979
|
+
{
|
|
980
|
+
this .updateSprite (gl, this .getScreenAlignedRotation (context .modelViewMatrix));
|
|
981
|
+
// [fall trough]
|
|
982
|
+
}
|
|
983
|
+
case GeometryTypes .QUAD:
|
|
984
|
+
case GeometryTypes .TRIANGLE:
|
|
985
|
+
{
|
|
986
|
+
const positiveScale = Matrix4 .prototype .determinant3 .call (context .modelViewMatrix) > 0;
|
|
987
|
+
|
|
988
|
+
gl .frontFace (positiveScale ? gl .CCW : gl .CW);
|
|
989
|
+
gl .enable (gl .CULL_FACE);
|
|
990
|
+
gl .cullFace (gl .BACK);
|
|
991
|
+
|
|
992
|
+
// [fall trough]
|
|
993
|
+
}
|
|
994
|
+
default:
|
|
1418
995
|
{
|
|
1419
996
|
const
|
|
1420
997
|
appearanceNode = this .getAppearance (),
|
|
1421
|
-
shaderNode = appearanceNode .
|
|
998
|
+
shaderNode = appearanceNode .getShader () || this .shaderNode || appearanceNode .getMaterial () .getShader (context .browser, context .shadow),
|
|
999
|
+
primitiveMode = shaderNode .getPrimitiveMode (this .primitiveMode);
|
|
1422
1000
|
|
|
1423
1001
|
// Setup shader.
|
|
1424
1002
|
|
|
1425
|
-
if (shaderNode .
|
|
1003
|
+
if (shaderNode .isValid ())
|
|
1426
1004
|
{
|
|
1427
1005
|
context .geometryContext = this .geometryContext;
|
|
1428
1006
|
|
|
1429
|
-
const blendModeNode = appearanceNode .
|
|
1007
|
+
const blendModeNode = appearanceNode .getBlendMode ();
|
|
1430
1008
|
|
|
1431
1009
|
if (blendModeNode)
|
|
1432
1010
|
blendModeNode .enable (gl);
|
|
@@ -1434,85 +1012,88 @@ function (Fields,
|
|
|
1434
1012
|
shaderNode .enable (gl);
|
|
1435
1013
|
shaderNode .setLocalUniforms (gl, context);
|
|
1436
1014
|
|
|
1437
|
-
|
|
1015
|
+
if (this .numTexCoords)
|
|
1016
|
+
{
|
|
1017
|
+
const textureUnit = context .browser .getTexture2DUnit ();
|
|
1438
1018
|
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1019
|
+
gl .activeTexture (gl .TEXTURE0 + textureUnit);
|
|
1020
|
+
gl .bindTexture (gl .TEXTURE_2D, this .texCoordRampTexture);
|
|
1021
|
+
gl .uniform1i (shaderNode .x3d_TexCoordRamp, textureUnit);
|
|
1022
|
+
}
|
|
1443
1023
|
|
|
1444
|
-
|
|
1445
|
-
shaderNode .enableColorAttribute (gl, this .colorBuffer);
|
|
1024
|
+
// Setup vertex attributes.
|
|
1446
1025
|
|
|
1447
|
-
|
|
1448
|
-
shaderNode .enableTexCoordAttribute (gl, this .texCoordBuffers);
|
|
1026
|
+
const outputParticles = this .outputParticles;
|
|
1449
1027
|
|
|
1450
|
-
if (
|
|
1451
|
-
|
|
1028
|
+
if (outputParticles .vertexArrayObject .enable (gl, shaderNode))
|
|
1029
|
+
{
|
|
1030
|
+
const particleStride = this .particleStride;
|
|
1452
1031
|
|
|
1453
|
-
|
|
1032
|
+
shaderNode .enableParticleAttribute (gl, outputParticles, particleStride, this .particleOffset, 1);
|
|
1033
|
+
shaderNode .enableParticleMatrixAttribute (gl, outputParticles, particleStride, this .matrixOffset, 1);
|
|
1454
1034
|
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1035
|
+
if (this .geometryContext .colorMaterial)
|
|
1036
|
+
{
|
|
1037
|
+
shaderNode .enableColorAttribute (gl, outputParticles, particleStride, this .colorOffset);
|
|
1038
|
+
shaderNode .colorAttributeDivisor (gl, 1);
|
|
1039
|
+
}
|
|
1458
1040
|
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
}
|
|
1462
|
-
else
|
|
1463
|
-
{
|
|
1464
|
-
const positiveScale = Matrix4 .prototype .determinant3 .call (context .modelViewMatrix) > 0;
|
|
1041
|
+
if (this .texCoordCount)
|
|
1042
|
+
shaderNode .enableTexCoordAttribute (gl, this .texCoordBuffers, 0, this .texCoordOffset);
|
|
1465
1043
|
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1044
|
+
if (this .hasNormals)
|
|
1045
|
+
{
|
|
1046
|
+
shaderNode .enableNormalAttribute (gl, this .geometryBuffer, 0, this .normalOffset);
|
|
1047
|
+
shaderNode .normalAttributeDivisor (gl, this .maxParticles);
|
|
1048
|
+
}
|
|
1469
1049
|
|
|
1470
|
-
|
|
1050
|
+
shaderNode .enableVertexAttribute (gl, this .geometryBuffer, 0, this .verticesOffset);
|
|
1471
1051
|
}
|
|
1472
1052
|
|
|
1473
|
-
|
|
1474
|
-
shaderNode .disableFloatAttrib (gl, "x3d_ParticlePosition");
|
|
1475
|
-
shaderNode .disableFloatAttrib (gl, "x3d_ParticleElapsedTime");
|
|
1476
|
-
shaderNode .disableFloatAttrib (gl, "x3d_ParticleLife");
|
|
1477
|
-
|
|
1478
|
-
shaderNode .disableColorAttribute (gl);
|
|
1479
|
-
shaderNode .disableTexCoordAttribute (gl);
|
|
1480
|
-
shaderNode .disableNormalAttribute (gl);
|
|
1053
|
+
gl .drawArraysInstanced (primitiveMode, 0, this .vertexCount, this .numParticles);
|
|
1481
1054
|
|
|
1482
1055
|
if (blendModeNode)
|
|
1483
1056
|
blendModeNode .disable (gl);
|
|
1484
1057
|
|
|
1485
|
-
context .geometryContext
|
|
1058
|
+
delete context .geometryContext;
|
|
1486
1059
|
}
|
|
1060
|
+
|
|
1061
|
+
break;
|
|
1487
1062
|
}
|
|
1488
1063
|
}
|
|
1489
|
-
catch (error)
|
|
1490
|
-
{
|
|
1491
|
-
// Catch error from setLocalUniforms.
|
|
1492
|
-
console .error (error);
|
|
1493
|
-
}
|
|
1494
1064
|
},
|
|
1495
|
-
getScreenAlignedRotation: function (
|
|
1065
|
+
getScreenAlignedRotation: (function ()
|
|
1496
1066
|
{
|
|
1497
|
-
|
|
1067
|
+
const
|
|
1068
|
+
invModelViewMatrix = new Matrix4 (),
|
|
1069
|
+
billboardToScreen = new Vector3 (0, 0, 0),
|
|
1070
|
+
viewerYAxis = new Vector3 (0, 0, 0),
|
|
1071
|
+
y = new Vector3 (0, 0, 0),
|
|
1072
|
+
rotation = new Matrix3 (9);
|
|
1498
1073
|
|
|
1499
|
-
|
|
1500
|
-
|
|
1074
|
+
return function (modelViewMatrix)
|
|
1075
|
+
{
|
|
1076
|
+
invModelViewMatrix .assign (modelViewMatrix) .inverse ();
|
|
1077
|
+
invModelViewMatrix .multDirMatrix (billboardToScreen .assign (Vector3 .zAxis));
|
|
1078
|
+
invModelViewMatrix .multDirMatrix (viewerYAxis .assign (Vector3 .yAxis));
|
|
1501
1079
|
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1080
|
+
const x = viewerYAxis .cross (billboardToScreen);
|
|
1081
|
+
y .assign (billboardToScreen) .cross (x);
|
|
1082
|
+
const z = billboardToScreen;
|
|
1505
1083
|
|
|
1506
|
-
|
|
1084
|
+
// Compose rotation matrix.
|
|
1507
1085
|
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1086
|
+
x .normalize ();
|
|
1087
|
+
y .normalize ();
|
|
1088
|
+
z .normalize ();
|
|
1511
1089
|
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1090
|
+
rotation .set (x .x, x .y, x .z,
|
|
1091
|
+
y .x, y .y, y .z,
|
|
1092
|
+
z .x, z .y, z .z);
|
|
1093
|
+
|
|
1094
|
+
return rotation;
|
|
1095
|
+
};
|
|
1096
|
+
})(),
|
|
1516
1097
|
});
|
|
1517
1098
|
|
|
1518
1099
|
return ParticleSystem;
|