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
|
@@ -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 .
|
|
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
|
-
|
|
129
|
-
|
|
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
|
|
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
|
-
|
|
189
|
-
|
|
190
|
-
this .
|
|
191
|
-
this .
|
|
192
|
-
this .texCoordBuffers
|
|
193
|
-
this .fogDepthBuffer
|
|
194
|
-
this .colorBuffer
|
|
195
|
-
this .normalBuffer
|
|
196
|
-
this .vertexBuffer
|
|
197
|
-
this .
|
|
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
|
-
|
|
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 .
|
|
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
|
-
|
|
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
|
-
|
|
491
|
+
intersectsLine: function (hitRay, renderObject, invModelViewMatrix, appearanceNode, intersections)
|
|
467
492
|
{
|
|
468
|
-
|
|
493
|
+
return this .intersectsLineWithGeometry (hitRay, renderObject .getModelViewMatrix () .get (), renderObject .getLocalObjects (), intersections);
|
|
469
494
|
},
|
|
470
|
-
|
|
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,
|
|
505
|
+
return function (hitRay, matrix, clipPlanes, intersections)
|
|
485
506
|
{
|
|
486
|
-
|
|
507
|
+
if (this .intersectsBBox (hitRay))
|
|
487
508
|
{
|
|
488
|
-
|
|
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
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
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
|
-
|
|
499
|
-
|
|
500
|
-
|
|
518
|
+
for (let i = 0; i < vertexCount; i += 3)
|
|
519
|
+
{
|
|
520
|
+
const i4 = i * 4;
|
|
501
521
|
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
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
|
-
|
|
507
|
-
|
|
508
|
-
|
|
526
|
+
if (hitRay .intersectsTriangle (v0, v1, v2, uvt))
|
|
527
|
+
{
|
|
528
|
+
// Get barycentric coordinates.
|
|
509
529
|
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
530
|
+
const
|
|
531
|
+
u = uvt .u,
|
|
532
|
+
v = uvt .v,
|
|
533
|
+
t = uvt .t;
|
|
514
534
|
|
|
515
|
-
|
|
535
|
+
// Determine vectors for X3DPointingDeviceSensors.
|
|
516
536
|
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
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
|
-
|
|
525
|
-
|
|
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
|
-
|
|
550
|
+
const i3 = i * 3;
|
|
528
551
|
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
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
|
-
|
|
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,
|
|
589
|
+
return function (hitRay, offsets)
|
|
552
590
|
{
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
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
|
-
|
|
672
|
+
if (box .intersectsBox (this .bbox))
|
|
619
673
|
{
|
|
620
|
-
|
|
621
|
-
{
|
|
622
|
-
box .multRight (invMatrix .assign (this .getMatrix ()) .inverse ());
|
|
674
|
+
box .multRight (invMatrix .assign (this .getMatrix ()) .inverse ());
|
|
623
675
|
|
|
624
|
-
|
|
676
|
+
this .transformMatrix (modelViewMatrix); // Apply screen transformations from screen nodes.
|
|
625
677
|
|
|
626
|
-
|
|
678
|
+
const vertices = this .vertices .getValue ();
|
|
627
679
|
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
680
|
+
for (let i = 0, length = this .vertexCount; i < length; i += 3)
|
|
681
|
+
{
|
|
682
|
+
const i4 = i * 4;
|
|
631
683
|
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
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
|
-
|
|
688
|
+
if (box .intersectsTriangle (v0, v1, v2))
|
|
689
|
+
{
|
|
690
|
+
if (clipPlanes .length)
|
|
637
691
|
{
|
|
638
|
-
if (
|
|
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
|
-
|
|
647
|
-
|
|
648
|
-
}
|
|
695
|
+
if (this .isClipped (modelViewMatrix .multVecMatrix (clipPoint .assign (v1)), clipPlanes))
|
|
696
|
+
continue;
|
|
649
697
|
|
|
650
|
-
|
|
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
|
|
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 =
|
|
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 .
|
|
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
|
|
745
|
-
|
|
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 .
|
|
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
|
-
|
|
795
|
-
|
|
796
|
-
|
|
840
|
+
if (this .multiTexCoords .length)
|
|
841
|
+
{
|
|
842
|
+
const maxTextures = this .getBrowser () .getMaxTextures ();
|
|
797
843
|
|
|
798
|
-
for (let i = this .multiTexCoords .length; i <
|
|
799
|
-
this .multiTexCoords [i] = this .multiTexCoords
|
|
844
|
+
for (let i = this .multiTexCoords .length; i < maxTextures; ++ i)
|
|
845
|
+
this .multiTexCoords [i] = this .multiTexCoords .at (-1);
|
|
800
846
|
|
|
801
|
-
this .multiTexCoords .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
|
|
870
|
+
// Create attribArray arrays.
|
|
821
871
|
{
|
|
822
|
-
const
|
|
872
|
+
const attribArrays = this .attribArrays;
|
|
823
873
|
|
|
824
|
-
for (const
|
|
825
|
-
|
|
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 =
|
|
830
|
-
|
|
879
|
+
for (let a = attribArrays .length; a < length; ++ a)
|
|
880
|
+
attribArrays [a] = X3DGeometryNode .createArray ();
|
|
831
881
|
|
|
832
|
-
|
|
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
|
|
901
|
+
// Transfer attribArrays.
|
|
854
902
|
|
|
855
|
-
for (let i = this .attribBuffers .length, length = this .
|
|
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 .
|
|
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 .
|
|
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 .
|
|
868
|
-
|
|
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 .
|
|
873
|
-
this .colorMaterial = !! (this .colors .length);
|
|
929
|
+
gl .bufferData (gl .ARRAY_BUFFER, this .colors .getValue (), gl .DYNAMIC_DRAW);
|
|
874
930
|
|
|
875
|
-
|
|
931
|
+
this .colorMaterial = !! this .colors .length;
|
|
932
|
+
|
|
933
|
+
if (this .colorMaterial !== lastColorMaterial)
|
|
934
|
+
this .updateVertexArrays ();
|
|
876
935
|
|
|
877
|
-
|
|
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 .
|
|
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 .
|
|
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
|
-
|
|
905
|
-
this .
|
|
906
|
-
this .
|
|
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
|
-
|
|
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
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
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
|
-
|
|
945
|
-
|
|
946
|
-
|
|
989
|
+
if (this .solid || ! backMaterialNode || frontShaderNode .getWireframe ())
|
|
990
|
+
{
|
|
991
|
+
this .displayGeometry (gl, context, appearanceNode, frontShaderNode, true, true);
|
|
947
992
|
}
|
|
948
|
-
|
|
993
|
+
else
|
|
949
994
|
{
|
|
950
|
-
|
|
951
|
-
|
|
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 .
|
|
1003
|
+
if (shaderNode .isValid ())
|
|
957
1004
|
{
|
|
958
1005
|
const
|
|
959
|
-
blendModeNode = appearanceNode .
|
|
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
|
-
|
|
972
|
-
|
|
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
|
-
|
|
975
|
-
|
|
1024
|
+
if (this .fogCoords)
|
|
1025
|
+
shaderNode .enableFogDepthAttribute (gl, this .fogDepthBuffer, 0, 0);
|
|
976
1026
|
|
|
977
|
-
|
|
978
|
-
|
|
1027
|
+
if (this .colorMaterial)
|
|
1028
|
+
shaderNode .enableColorAttribute (gl, this .colorBuffer, 0, 0);
|
|
979
1029
|
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
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 .
|
|
1037
|
+
if (shaderNode .getWireframe ())
|
|
987
1038
|
{
|
|
988
|
-
|
|
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 :
|
|
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 (
|
|
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 (
|
|
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 (
|
|
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,
|
|
1087
|
+
displayParticlesDepth: function (gl, context, shaderNode, particleSystem)
|
|
1058
1088
|
{
|
|
1059
|
-
|
|
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
|
-
|
|
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
|
|
1076
|
-
|
|
1077
|
-
modelViewMatrix [12] = x;
|
|
1078
|
-
modelViewMatrix [13] = y;
|
|
1079
|
-
modelViewMatrix [14] = z;
|
|
1093
|
+
const particleStride = particleSystem .particleStride;
|
|
1080
1094
|
|
|
1081
|
-
|
|
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
|
-
|
|
1084
|
-
|
|
1085
|
-
gl .drawArrays (shaderNode .primitiveMode, 0, this .vertexCount);
|
|
1099
|
+
this .updateParticlesShadow = false;
|
|
1086
1100
|
}
|
|
1087
1101
|
|
|
1088
|
-
|
|
1089
|
-
// attribNodes [i] .disable (gl, shaderNode);
|
|
1102
|
+
gl .drawArraysInstanced (this .primitiveMode, 0, this .vertexCount, particleSystem .numParticles);
|
|
1090
1103
|
},
|
|
1091
|
-
displayParticles: function (gl, context,
|
|
1104
|
+
displayParticles: function (gl, context, particleSystem)
|
|
1092
1105
|
{
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
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
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
+
if (this .solid || ! backMaterialNode || frontShaderNode .getWireframe ())
|
|
1113
|
+
{
|
|
1114
|
+
this .displayParticlesGeometry (gl, context, appearanceNode, frontShaderNode, true, true, particleSystem);
|
|
1112
1115
|
}
|
|
1113
|
-
|
|
1116
|
+
else
|
|
1114
1117
|
{
|
|
1115
|
-
|
|
1116
|
-
|
|
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,
|
|
1124
|
+
displayParticlesGeometry: function (gl, context, appearanceNode, shaderNode, back, front, particleSystem)
|
|
1120
1125
|
{
|
|
1121
|
-
if (shaderNode .
|
|
1126
|
+
if (shaderNode .isValid ())
|
|
1122
1127
|
{
|
|
1123
1128
|
const
|
|
1124
|
-
blendModeNode = appearanceNode .
|
|
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
|
-
|
|
1139
|
-
attribNodes [i] .enable (gl, shaderNode, attribBuffers [i]);
|
|
1144
|
+
const outputParticles = particleSystem .outputParticles;
|
|
1140
1145
|
|
|
1141
|
-
if (this .
|
|
1142
|
-
|
|
1146
|
+
if (outputParticles .vertexArrayObject .update (this .updateParticles) .enable (gl, shaderNode))
|
|
1147
|
+
{
|
|
1148
|
+
const particleStride = particleSystem .particleStride;
|
|
1143
1149
|
|
|
1144
|
-
|
|
1145
|
-
shaderNode .
|
|
1150
|
+
shaderNode .enableParticleAttribute (gl, outputParticles, particleStride, particleSystem .particleOffset, 1);
|
|
1151
|
+
shaderNode .enableParticleMatrixAttribute (gl, outputParticles, particleStride, particleSystem .matrixOffset, 1);
|
|
1146
1152
|
|
|
1147
|
-
|
|
1148
|
-
|
|
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
|
-
|
|
1156
|
+
if (this .fogCoords)
|
|
1157
|
+
shaderNode .enableFogDepthAttribute (gl, this .fogDepthBuffer, 0, 0);
|
|
1152
1158
|
|
|
1153
|
-
|
|
1154
|
-
|
|
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
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
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
|
-
|
|
1164
|
-
|
|
1165
|
-
const particle = particles [p];
|
|
1166
|
+
this .updateParticles = false;
|
|
1167
|
+
}
|
|
1166
1168
|
|
|
1167
|
-
|
|
1168
|
-
modelViewMatrix [13] = y;
|
|
1169
|
-
modelViewMatrix [14] = z;
|
|
1169
|
+
// Draw depending on wireframe, solid and transparent.
|
|
1170
1170
|
|
|
1171
|
-
|
|
1171
|
+
const positiveScale = Matrix4 .prototype .determinant3 .call (context .modelViewMatrix) > 0;
|
|
1172
1172
|
|
|
1173
|
-
|
|
1173
|
+
gl .frontFace (positiveScale ? this .frontFace : this .backFace .get (this .frontFace));
|
|
1174
1174
|
|
|
1175
|
-
|
|
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
|
-
|
|
1177
|
+
// Render transparent or back or front.
|
|
1189
1178
|
|
|
1190
|
-
gl .
|
|
1179
|
+
gl .enable (gl .CULL_FACE);
|
|
1191
1180
|
|
|
1192
|
-
if (
|
|
1181
|
+
if (back && ! this .solid)
|
|
1193
1182
|
{
|
|
1194
|
-
|
|
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
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
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
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
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
|
-
|
|
1259
|
-
|
|
1202
|
+
gl .drawArraysInstanced (primitiveMode, 0, this .vertexCount, particleSystem .numParticles);
|
|
1203
|
+
}
|
|
1260
1204
|
|
|
1261
1205
|
if (blendModeNode)
|
|
1262
1206
|
blendModeNode .disable (gl);
|