x_ite 4.0.5 → 4.7.5
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/.github/ISSUE_TEMPLATE/bug_report.md +38 -0
- package/.vscode/settings.json +15 -0
- package/.vscode/tasks.json +25 -0
- package/Makefile +55 -15
- package/README.md +13 -130
- package/build/bin/dist.pl +156 -0
- package/build/bin/version-number.pl +25 -0
- package/build/{version.pl → bin/version.pl} +64 -21
- package/build/components/annotation.build.js +15 -0
- package/build/components/cad-geometry.build.js +15 -0
- package/build/components/cube-map-texturing.build.js +15 -0
- package/build/components/dis.build.js +15 -0
- package/build/components/event-utilities.build.js +15 -0
- package/build/components/geometry2d.build.js +15 -0
- package/build/components/geospatial.build.js +15 -0
- package/build/components/h-anim.build.js +15 -0
- package/build/components/key-device-sensor.build.js +15 -0
- package/build/components/layout.build.js +15 -0
- package/build/components/nurbs.build.js +15 -0
- package/build/components/particle-systems.build.js +15 -0
- package/build/components/picking.build.js +15 -0
- package/build/components/projective-texture-mapping.build.js +15 -0
- package/build/components/rigid-body-physics.build.js +15 -0
- package/build/components/scripting.build.js +15 -0
- package/build/components/texturing-3d.build.js +15 -0
- package/build/components/volume-rendering.build.js +15 -0
- package/build/components/x_ite.build.js +15 -0
- package/build/parts/default.end.frag +2 -0
- package/build/parts/default.start.frag +6 -0
- package/build/parts/x_ite.end.frag +23 -0
- package/build/parts/x_ite.start.frag +8 -0
- package/build/x_ite.build.js +18 -0
- package/dist/LICENSE.txt +49 -0
- package/dist/assets/components/annotation.js +813 -0
- package/dist/assets/components/annotation.min.js +1 -0
- package/dist/assets/components/cad-geometry.js +1037 -0
- package/dist/assets/components/cad-geometry.min.js +1 -0
- package/dist/assets/components/cube-map-texturing.js +1212 -0
- package/dist/assets/components/cube-map-texturing.min.js +1 -0
- package/dist/assets/components/dis.js +908 -0
- package/dist/assets/components/dis.min.js +1 -0
- package/dist/assets/components/event-utilities.js +1114 -0
- package/dist/assets/components/event-utilities.min.js +1 -0
- package/dist/assets/components/geometry2d.js +2190 -0
- package/dist/assets/components/geometry2d.min.js +1 -0
- package/dist/assets/components/geospatial.js +3850 -0
- package/dist/assets/components/geospatial.min.js +2 -0
- package/dist/assets/components/h-anim.js +1084 -0
- package/dist/assets/components/h-anim.min.js +1 -0
- package/dist/assets/components/key-device-sensor.js +850 -0
- package/dist/assets/components/key-device-sensor.min.js +1 -0
- package/dist/assets/components/layout.js +2008 -0
- package/dist/assets/components/layout.min.js +1 -0
- package/dist/assets/components/nurbs.js +5388 -0
- package/dist/assets/components/nurbs.min.js +2 -0
- package/dist/assets/components/particle-systems.js +4216 -0
- package/dist/assets/components/particle-systems.min.js +2 -0
- package/dist/assets/components/picking.js +2481 -0
- package/dist/assets/components/picking.min.js +1 -0
- package/dist/assets/components/projective-texture-mapping.js +813 -0
- package/dist/assets/components/projective-texture-mapping.min.js +1 -0
- package/dist/assets/components/rigid-body-physics.js +4569 -0
- package/dist/assets/components/rigid-body-physics.min.js +59 -0
- package/dist/assets/components/scripting.js +801 -0
- package/dist/assets/components/scripting.min.js +1 -0
- package/dist/assets/components/texturing-3d.js +10054 -0
- package/dist/assets/components/texturing-3d.min.js +48 -0
- package/dist/assets/components/volume-rendering.js +3966 -0
- package/dist/assets/components/volume-rendering.min.js +3 -0
- package/dist/assets/components/x_ite.js +285 -0
- package/dist/assets/components/x_ite.min.js +1 -0
- package/{fonts → dist/assets/fonts}/DroidSerif-Bold.ttf +0 -0
- package/{fonts → dist/assets/fonts}/DroidSerif-BoldItalic.ttf +0 -0
- package/{fonts → dist/assets/fonts}/DroidSerif-Italic.ttf +0 -0
- package/{fonts → dist/assets/fonts}/DroidSerif-Regular.ttf +0 -0
- package/{fonts → dist/assets/fonts}/Ubuntu-B.ttf +0 -0
- package/{fonts → dist/assets/fonts}/Ubuntu-BI.ttf +0 -0
- package/{fonts → dist/assets/fonts}/Ubuntu-R.ttf +0 -0
- package/{fonts → dist/assets/fonts}/Ubuntu-RI.ttf +0 -0
- package/{fonts → dist/assets/fonts}/UbuntuMono-B.ttf +0 -0
- package/{fonts → dist/assets/fonts}/UbuntuMono-BI.ttf +0 -0
- package/{fonts → dist/assets/fonts}/UbuntuMono-R.ttf +0 -0
- package/{fonts → dist/assets/fonts}/UbuntuMono-RI.ttf +0 -0
- package/dist/assets/hatching/0.png +0 -0
- package/dist/assets/hatching/1.png +0 -0
- package/dist/assets/hatching/10.png +0 -0
- package/dist/assets/hatching/11.png +0 -0
- package/dist/assets/hatching/12.png +0 -0
- package/dist/assets/hatching/13.png +0 -0
- package/dist/assets/hatching/14.png +0 -0
- package/dist/assets/hatching/15.png +0 -0
- package/dist/assets/hatching/16.png +0 -0
- package/dist/assets/hatching/17.png +0 -0
- package/dist/assets/hatching/18.png +0 -0
- package/dist/assets/hatching/19.png +0 -0
- package/dist/assets/hatching/2.png +0 -0
- package/dist/assets/hatching/3.png +0 -0
- package/dist/assets/hatching/4.png +0 -0
- package/dist/assets/hatching/5.png +0 -0
- package/dist/assets/hatching/6.png +0 -0
- package/dist/assets/hatching/7.png +0 -0
- package/dist/assets/hatching/8.png +0 -0
- package/dist/assets/hatching/9.png +0 -0
- package/dist/{images → assets/images}/ExamineViewer.png +0 -0
- package/dist/{images → assets/images}/FlyViewer.png +0 -0
- package/dist/{images → assets/images}/NoneViewer.png +0 -0
- package/dist/{images → assets/images}/PlaneViewer.png +0 -0
- package/dist/{images → assets/images}/PrimitiveQuality.png +0 -0
- package/dist/{images → assets/images}/TextureQuality.png +0 -0
- package/dist/{images → assets/images}/Time.png +0 -0
- package/dist/{images → assets/images}/Viewpoint.png +0 -0
- package/dist/{images → assets/images}/WalkViewer.png +0 -0
- package/dist/assets/images/go-next.png +0 -0
- package/dist/{images → assets/images}/gtk-fullscreen.png +0 -0
- package/dist/{images → assets/images}/gtk-leave-fullscreen.png +0 -0
- package/dist/{images → assets/images}/gtk-zoom-fit.png +0 -0
- package/dist/{images → assets/images}/gtk-zoom-in.png +0 -0
- package/dist/{images → assets/images}/help-about.png +0 -0
- package/dist/{images → assets/images}/icon.bw.png +0 -0
- package/dist/{images → assets/images}/icon.png +0 -0
- package/dist/assets/images/logo.128.png +0 -0
- package/dist/{images → assets/images}/logo.bw.png +0 -0
- package/dist/{images → assets/images}/logo.png +0 -0
- package/dist/assets/linetype/0.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/Background.fs +23 -0
- package/dist/assets/shaders/webgl1/Background.vs +16 -0
- package/dist/assets/shaders/webgl1/Depth.fs +60 -0
- package/dist/assets/shaders/webgl1/Depth.vs +13 -0
- package/dist/assets/shaders/webgl1/Fallback.fs +28 -0
- package/dist/assets/shaders/webgl1/Fallback.vs +24 -0
- package/dist/assets/shaders/webgl1/FallbackUnlit.fs +16 -0
- package/dist/assets/shaders/webgl1/FallbackUnlit.vs +18 -0
- package/dist/assets/shaders/webgl1/Gouraud.fs +529 -0
- package/dist/assets/shaders/webgl1/Gouraud.vs +108 -0
- package/dist/assets/shaders/webgl1/Phong.fs +838 -0
- package/dist/assets/shaders/webgl1/Phong.vs +52 -0
- package/dist/assets/shaders/webgl1/PointSet.fs +541 -0
- package/dist/assets/shaders/webgl1/PointSet.vs +48 -0
- package/dist/assets/shaders/webgl1/Unlit.fs +541 -0
- package/dist/assets/shaders/webgl1/Unlit.vs +52 -0
- package/dist/assets/shaders/webgl1/Wireframe.fs +93 -0
- package/dist/assets/shaders/webgl1/Wireframe.vs +47 -0
- package/dist/assets/shaders/webgl2/Background.fs +25 -0
- package/dist/assets/shaders/webgl2/Background.vs +17 -0
- package/dist/assets/shaders/webgl2/Depth.fs +62 -0
- package/dist/assets/shaders/webgl2/Depth.vs +14 -0
- package/dist/assets/shaders/webgl2/Gouraud.fs +684 -0
- package/dist/assets/shaders/webgl2/Gouraud.vs +109 -0
- package/dist/assets/shaders/webgl2/Phong.fs +1014 -0
- package/dist/assets/shaders/webgl2/Phong.vs +53 -0
- package/dist/assets/shaders/webgl2/PointSet.fs +696 -0
- package/dist/assets/shaders/webgl2/PointSet.vs +49 -0
- package/dist/assets/shaders/webgl2/Unlit.fs +696 -0
- package/dist/assets/shaders/webgl2/Unlit.vs +53 -0
- package/dist/assets/shaders/webgl2/Wireframe.fs +102 -0
- package/dist/assets/shaders/webgl2/Wireframe.vs +48 -0
- package/dist/example.html +8 -7
- package/dist/x_ite.css +180 -59
- package/dist/x_ite.js +74696 -68048
- package/dist/x_ite.min.js +42 -41
- package/dist/x_ite.zip +0 -0
- package/docs/404.md +5 -0
- package/docs/Accessing-the-External-Browser.md +290 -0
- package/docs/Browser-Support.md +47 -0
- package/docs/Custom-Shaders.md +905 -0
- package/docs/Features.md +49 -0
- package/docs/Glossary.md +339 -0
- package/docs/How-To-Configure-Your-Web-Server.md +56 -0
- package/docs/Supported-Nodes.md +370 -0
- package/docs/What's-New.md +1240 -0
- package/docs/XHTML-DOM-Integration.md +82 -0
- package/docs/_config.yml +140 -0
- package/docs/_data/navigation.yml +137 -0
- package/docs/assets/css/main.scss +100 -0
- package/docs/assets/images/logo.png +0 -0
- package/docs/google3696ee938394d7b6.html +1 -0
- package/docs/index.md +1026 -0
- package/docs/reference/Browser-Services.md +333 -0
- package/docs/reference/Constants-Services.md +376 -0
- package/docs/reference/ECMAScript-Object-and-Function-Definitions.md +128 -0
- package/docs/reference/Field-Services-and-Objects.md +1006 -0
- package/docs/reference/Prototype-Services.md +121 -0
- package/docs/reference/Route-Services.md +49 -0
- package/docs/reference/Scene-Services.md +360 -0
- package/docs/reference/Script-Node-Authoring-Interface.md +334 -0
- package/docs/tutorials/Adding-backgrounds.md +268 -0
- package/docs/tutorials/Adding-fog.md +67 -0
- package/docs/tutorials/Adding-sound.md +326 -0
- package/docs/tutorials/Animating-transforms.md +385 -0
- package/docs/tutorials/Basic-Nodes.md +317 -0
- package/docs/tutorials/Building-a-X3D-world.md +152 -0
- package/docs/tutorials/Building-elevation-grids.md +170 -0
- package/docs/tutorials/Building-extruded-shapes.md +145 -0
- package/docs/tutorials/Building-primitive-shapes.md +204 -0
- package/docs/tutorials/Building-shapes-out-of-points,-lines,-and-faces.md +311 -0
- package/docs/tutorials/Controlling-appearance-with-materials.md +186 -0
- package/docs/tutorials/Controlling-color-on-coordinate-based-geometry.md +208 -0
- package/docs/tutorials/Controlling-detail.md +130 -0
- package/docs/tutorials/Controlling-how-textures-are-mapped.md +277 -0
- package/docs/tutorials/Controlling-navigation.md +70 -0
- package/docs/tutorials/Controlling-shading-on-coordinate-based-geometry.md +180 -0
- package/docs/tutorials/Controlling-the-viewpoint.md +49 -0
- package/docs/tutorials/Creating-new-node-types.md +313 -0
- package/docs/tutorials/Grouping-nodes.md +237 -0
- package/docs/tutorials/Hello,-World!.md +204 -0
- package/docs/tutorials/Improving-Performance.md +227 -0
- package/docs/tutorials/Increasing-Rendering-Speed.md +110 -0
- package/docs/tutorials/Introducing-X3D.md +94 -0
- package/docs/tutorials/Introducing-animation.md +211 -0
- package/docs/tutorials/Introducing-script-use.md +127 -0
- package/docs/tutorials/Lighting-your-world.md +139 -0
- package/docs/tutorials/Mapping-textures.md +212 -0
- package/docs/tutorials/Naming-nodes.md +161 -0
- package/docs/tutorials/Providing-information-about-your-world.md +30 -0
- package/docs/tutorials/Sensing-the-viewer.md +205 -0
- package/docs/tutorials/Sensing-viewer-actions.md +214 -0
- package/docs/tutorials/Transforming-Shapes.md +270 -0
- package/docs/tutorials/Writing-program-scripts-with-ECMAScript.md +631 -0
- package/docs/tutorials/index.md +78 -0
- package/meta/logo/logo.png +0 -0
- package/meta/logo/logo.svg +216 -217
- package/meta/web3d.html +76 -54
- package/package.json +41 -24
- package/src/assets/components/annotation.js +87 -0
- package/src/assets/components/cad-geometry.js +88 -0
- package/src/assets/components/cube-map-texturing.js +78 -0
- package/src/assets/components/dis.js +84 -0
- package/src/assets/components/event-utilities.js +93 -0
- package/src/assets/components/geometry2d.js +93 -0
- package/src/assets/components/geospatial.js +102 -0
- package/src/assets/components/h-anim.js +83 -0
- package/src/assets/components/key-device-sensor.js +78 -0
- package/src/assets/components/layout.js +87 -0
- package/src/assets/components/nurbs.js +118 -0
- package/src/assets/components/particle-systems.js +105 -0
- package/src/assets/components/picking.js +87 -0
- package/src/assets/components/projective-texture-mapping.js +75 -0
- package/src/assets/components/rigid-body-physics.js +123 -0
- package/src/assets/components/scripting.js +72 -0
- package/src/assets/components/texturing-3d.js +91 -0
- package/src/assets/components/volume-rendering.js +118 -0
- package/src/assets/components/x_ite.js +69 -0
- package/src/assets/fonts/DroidSerif-Bold.ttf +0 -0
- package/src/assets/fonts/DroidSerif-BoldItalic.ttf +0 -0
- package/src/assets/fonts/DroidSerif-Italic.ttf +0 -0
- package/src/assets/fonts/DroidSerif-Regular.ttf +0 -0
- package/src/assets/fonts/Ubuntu-B.ttf +0 -0
- package/src/assets/fonts/Ubuntu-BI.ttf +0 -0
- package/src/assets/fonts/Ubuntu-R.ttf +0 -0
- package/src/assets/fonts/Ubuntu-RI.ttf +0 -0
- package/src/assets/fonts/UbuntuMono-B.ttf +0 -0
- package/src/assets/fonts/UbuntuMono-BI.ttf +0 -0
- package/src/assets/fonts/UbuntuMono-R.ttf +0 -0
- package/src/assets/fonts/UbuntuMono-RI.ttf +0 -0
- package/src/assets/hatching/0.png +0 -0
- package/src/assets/hatching/1.png +0 -0
- package/src/assets/hatching/10.png +0 -0
- package/src/assets/hatching/11.png +0 -0
- package/src/assets/hatching/12.png +0 -0
- package/src/assets/hatching/13.png +0 -0
- package/src/assets/hatching/14.png +0 -0
- package/src/assets/hatching/15.png +0 -0
- package/src/assets/hatching/16.png +0 -0
- package/src/assets/hatching/17.png +0 -0
- package/src/assets/hatching/18.png +0 -0
- package/src/assets/hatching/19.png +0 -0
- package/src/assets/hatching/2.png +0 -0
- package/src/assets/hatching/3.png +0 -0
- package/src/assets/hatching/4.png +0 -0
- package/src/assets/hatching/5.png +0 -0
- package/src/assets/hatching/6.png +0 -0
- package/src/assets/hatching/7.png +0 -0
- package/src/assets/hatching/8.png +0 -0
- package/src/assets/hatching/9.png +0 -0
- package/src/{images → assets/images}/ExamineViewer.png +0 -0
- package/src/{images → assets/images}/FlyViewer.png +0 -0
- package/src/{images → assets/images}/NoneViewer.png +0 -0
- package/src/{images → assets/images}/PlaneViewer.png +0 -0
- package/src/{images → assets/images}/PrimitiveQuality.png +0 -0
- package/src/{images → assets/images}/TextureQuality.png +0 -0
- package/src/{images → assets/images}/Time.png +0 -0
- package/src/{images → assets/images}/Viewpoint.png +0 -0
- package/src/{images → assets/images}/WalkViewer.png +0 -0
- package/src/assets/images/go-next.png +0 -0
- package/src/{images → assets/images}/gtk-fullscreen.png +0 -0
- package/src/{images → assets/images}/gtk-leave-fullscreen.png +0 -0
- package/src/{images → assets/images}/gtk-zoom-fit.png +0 -0
- package/src/{images → assets/images}/gtk-zoom-in.png +0 -0
- package/src/{images → assets/images}/help-about.png +0 -0
- package/src/{images → assets/images}/icon.bw.png +0 -0
- package/src/{images → assets/images}/icon.png +0 -0
- package/src/assets/images/logo.128.png +0 -0
- package/src/{images → assets/images}/logo.bw.png +0 -0
- package/src/{images → assets/images}/logo.png +0 -0
- package/src/assets/linetype/0.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 +102 -0
- package/src/assets/shaders/webgl1/Background.fs +16 -0
- package/src/assets/shaders/webgl1/Background.vs +22 -0
- package/src/assets/shaders/webgl1/Depth.fs +16 -0
- package/src/assets/shaders/webgl1/Depth.vs +20 -0
- package/src/assets/shaders/webgl1/Fallback.fs +38 -0
- package/src/assets/shaders/webgl1/Fallback.vs +30 -0
- package/src/assets/shaders/webgl1/FallbackUnlit.fs +22 -0
- package/src/assets/shaders/webgl1/FallbackUnlit.vs +24 -0
- package/src/assets/shaders/webgl1/Gouraud.fs +66 -0
- package/src/assets/shaders/webgl1/Gouraud.vs +148 -0
- package/src/assets/shaders/webgl1/Phong.fs +173 -0
- package/src/assets/shaders/webgl1/Phong.vs +67 -0
- package/src/assets/shaders/webgl1/PointSet.fs +100 -0
- package/src/assets/shaders/webgl1/PointSet.vs +70 -0
- package/src/assets/shaders/webgl1/Unlit.fs +89 -0
- package/src/assets/shaders/webgl1/Unlit.vs +67 -0
- package/src/assets/shaders/webgl1/Wireframe.fs +74 -0
- package/src/assets/shaders/webgl1/Wireframe.vs +63 -0
- package/src/assets/shaders/webgl1/include/ClipPlanes.glsl +16 -0
- package/src/assets/shaders/webgl1/include/Fog.glsl +38 -0
- package/src/assets/shaders/webgl1/include/Hatch.glsl +18 -0
- package/src/assets/shaders/webgl1/include/Pack.glsl +51 -0
- package/src/assets/shaders/webgl1/include/Perlin.glsl +40 -0
- package/src/assets/shaders/webgl1/include/Shadow.glsl +310 -0
- package/src/assets/shaders/webgl1/include/Texture.glsl +488 -0
- package/src/assets/shaders/webgl2/Background.fs +19 -0
- package/src/assets/shaders/webgl2/Background.vs +23 -0
- package/src/assets/shaders/webgl2/Depth.fs +19 -0
- package/src/assets/shaders/webgl2/Depth.vs +21 -0
- package/src/assets/shaders/webgl2/Gouraud.fs +64 -0
- package/src/assets/shaders/webgl2/Gouraud.vs +149 -0
- package/src/assets/shaders/webgl2/Phong.fs +171 -0
- package/src/assets/shaders/webgl2/Phong.vs +68 -0
- package/src/assets/shaders/webgl2/PointSet.fs +99 -0
- package/src/assets/shaders/webgl2/PointSet.vs +71 -0
- package/src/assets/shaders/webgl2/Unlit.fs +88 -0
- package/src/assets/shaders/webgl2/Unlit.vs +68 -0
- package/src/assets/shaders/webgl2/Wireframe.fs +73 -0
- package/src/assets/shaders/webgl2/Wireframe.vs +64 -0
- package/src/assets/shaders/webgl2/include/ClipPlanes.glsl +16 -0
- package/src/assets/shaders/webgl2/include/Fog.glsl +46 -0
- package/src/assets/shaders/webgl2/include/Hatch.glsl +18 -0
- package/src/assets/shaders/webgl2/include/Pack.glsl +51 -0
- package/src/assets/shaders/webgl2/include/Perlin.glsl +40 -0
- package/src/assets/shaders/webgl2/include/Shadow.glsl +324 -0
- package/src/assets/shaders/webgl2/include/Texture.glsl +623 -0
- package/src/bookmarks.js +83 -164
- package/src/dummy.js +1 -0
- package/src/example.html +8 -7
- package/src/examples.js +150 -0
- package/src/lib/ammojs/AmmoJS.js +58 -0
- package/src/lib/ammojs/Makefile +26 -0
- package/src/lib/ammojs/ammo.idl +1031 -0
- package/src/lib/ammojs/ammo.js +40 -0
- package/src/lib/jpeg/jpeg.js +1019 -0
- package/src/lib/nurbs/extras/sample.js +242 -0
- package/src/lib/nurbs/nurbs.js +342 -0
- package/src/lib/nurbs/src/evaluate.js +413 -0
- package/src/lib/nurbs/src/numerical-derivative.js +54 -0
- package/src/lib/nurbs/src/support.js +151 -0
- package/src/lib/nurbs/src/transform.js +78 -0
- package/src/lib/nurbs/src/utils/accessor-preamble.js +33 -0
- package/src/lib/nurbs/src/utils/bisection-search.js +28 -0
- package/src/lib/nurbs/src/utils/cache-key.js +57 -0
- package/src/lib/nurbs/src/utils/create-accessors.js +110 -0
- package/src/lib/nurbs/src/utils/infer-type.js +52 -0
- package/src/lib/nurbs/src/utils/is-array-like.js +10 -0
- package/src/lib/nurbs/src/utils/is-ndarray-like.js +18 -0
- package/src/lib/nurbs/src/utils/is-ndarray.js +21 -0
- package/src/lib/nurbs/src/utils/ndloop.js +23 -0
- package/src/lib/nurbs/src/utils/size-getter.js +22 -0
- package/src/lib/nurbs/src/utils/variable.js +31 -0
- package/src/locale/de.po +8 -3
- package/src/locale/fr.po +9 -4
- package/src/locale/gettext.js +3 -3
- package/src/spinner.css +21 -8
- package/src/standard/Geospatial/Geodetic.js +48 -48
- package/src/standard/Geospatial/ReferenceEllipsoids.js +1 -1
- package/src/standard/Geospatial/UniversalTransverseMercator.js +43 -43
- package/src/standard/Math/Algorithm.js +25 -41
- package/src/standard/Math/Algorithms/Bezier.js +147 -0
- package/src/standard/Math/Algorithms/MergeSort.js +2 -2
- package/src/standard/Math/Algorithms/PartialSort.js +97 -0
- package/src/standard/Math/Algorithms/QuickSort.js +8 -6
- package/src/standard/Math/Algorithms/SAT.js +4 -8
- package/src/standard/Math/Algorithms/eigendecomposition.js +37 -33
- package/src/standard/Math/Geometry/Box2.js +84 -56
- package/src/standard/Math/Geometry/Box3.js +457 -284
- package/src/standard/Math/Geometry/Camera.js +24 -15
- package/src/standard/Math/Geometry/Cylinder3.js +13 -13
- package/src/standard/Math/Geometry/Line3.js +61 -53
- package/src/standard/Math/Geometry/Plane3.js +16 -16
- package/src/standard/Math/Geometry/Sphere3.js +122 -105
- package/src/standard/Math/Geometry/Spheroid3.js +1 -1
- package/src/standard/Math/Geometry/Triangle2.js +6 -6
- package/src/standard/Math/Geometry/Triangle3.js +80 -88
- package/src/standard/Math/Geometry/ViewVolume.js +315 -116
- package/src/standard/Math/Numbers/Color3.js +45 -29
- package/src/standard/Math/Numbers/Color4.js +25 -14
- package/src/standard/Math/Numbers/Complex.js +15 -22
- package/src/standard/Math/Numbers/Matrix2.js +37 -17
- package/src/standard/Math/Numbers/Matrix3.js +181 -212
- package/src/standard/Math/Numbers/Matrix4.js +204 -262
- package/src/standard/Math/Numbers/Quaternion.js +60 -147
- package/src/standard/Math/Numbers/Rotation4.js +197 -129
- package/src/standard/Math/Numbers/Vector2.js +53 -109
- package/src/standard/Math/Numbers/Vector3.js +75 -144
- package/src/standard/Math/Numbers/Vector4.js +85 -155
- package/src/standard/Math/Utility/BVH.js +35 -30
- package/src/standard/Math/Utility/MatrixStack.js +6 -9
- package/src/standard/Networking/BinaryTransport.js +8 -8
- package/src/standard/Time/MicroTime.js +79 -0
- package/src/standard/Utility/DataStorage.js +40 -17
- package/src/standard/Utility/MapUtilities.js +69 -0
- package/src/standard/Utility/ObjectCache.js +2 -3
- package/src/standard/Utility/Shuffle.js +5 -6
- package/src/tests.js +386 -0
- package/src/x_ite/Base/Events.js +22 -30
- package/src/x_ite/Base/X3DChildObject.js +35 -19
- package/src/x_ite/Base/X3DEventObject.js +10 -12
- package/src/x_ite/Base/X3DObject.js +63 -43
- package/src/x_ite/Basic/FieldDefinitionArray.js +16 -10
- package/src/x_ite/Basic/X3DArrayField.js +3 -430
- package/src/x_ite/Basic/X3DBaseNode.js +551 -288
- package/src/x_ite/Basic/X3DField.js +133 -96
- package/src/x_ite/Basic/X3DFieldDefinition.js +0 -4
- package/src/x_ite/Basic/X3DObjectArrayField.js +545 -0
- package/src/x_ite/Basic/X3DTypedArrayField.js +839 -0
- package/src/x_ite/Bits/TraverseType.js +2 -5
- package/src/x_ite/Bits/X3DConstants.js +12 -322
- package/src/x_ite/Browser/Core/BrowserOptions.js +205 -77
- package/src/x_ite/Browser/Core/BrowserProperties.js +2 -4
- package/src/x_ite/Browser/Core/BrowserTimings.js +16 -15
- package/src/x_ite/Browser/Core/ContextMenu.js +202 -80
- package/src/x_ite/Browser/Core/Notification.js +14 -6
- package/src/x_ite/Browser/Core/PrimitiveQuality.js +3 -7
- package/src/x_ite/Browser/Core/RenderingProperties.js +10 -11
- package/src/x_ite/Browser/Core/Shading.js +66 -0
- package/src/x_ite/Browser/Core/TextureQuality.js +3 -7
- package/src/x_ite/Browser/Core/X3DCoreContext.js +495 -48
- package/src/x_ite/Browser/Core/X3DCoreContext.js.~1~ +714 -0
- package/src/x_ite/Browser/EnvironmentalEffects/X3DEnvironmentalEffectsContext.js +17 -23
- package/src/x_ite/Browser/Followers/X3DArrayChaserTemplate.js +12 -20
- package/src/x_ite/Browser/Followers/X3DArrayFollowerTemplate.js +82 -34
- package/src/x_ite/Browser/Geometry2D/Arc2DOptions.js +3 -5
- package/src/x_ite/Browser/Geometry2D/ArcClose2DOptions.js +3 -5
- package/src/x_ite/Browser/Geometry2D/Circle2DOptions.js +12 -9
- package/src/x_ite/Browser/Geometry2D/Disk2DOptions.js +60 -42
- package/src/x_ite/Browser/Geometry2D/Rectangle2DOptions.js +16 -20
- package/src/x_ite/Browser/Geometry2D/X3DGeometry2DContext.js +51 -12
- package/src/x_ite/Browser/Geometry3D/BoxOptions.js +17 -21
- package/src/x_ite/Browser/Geometry3D/ConeOptions.js +2 -4
- package/src/x_ite/Browser/Geometry3D/CylinderOptions.js +2 -4
- package/src/x_ite/Browser/Geometry3D/IcoSphereOptions.js +2 -4
- package/src/x_ite/Browser/Geometry3D/QuadSphereOptions.js +3 -5
- package/src/x_ite/Browser/Geometry3D/X3DGeometry3DContext.js +8 -9
- package/src/x_ite/Browser/Grouping/X3DGroupingContext.js +98 -0
- package/src/x_ite/Browser/Interpolation/CatmullRomSplineInterpolator.js +12 -12
- package/src/x_ite/Browser/Interpolation/CatmullRomSplineInterpolator1.js +2 -4
- package/src/x_ite/Browser/Interpolation/CatmullRomSplineInterpolatorTemplate.js +2 -4
- package/src/x_ite/Browser/KeyDeviceSensor/X3DKeyDeviceSensorContext.js +22 -200
- package/src/x_ite/Browser/Layout/ScreenText.js +287 -295
- package/src/x_ite/Browser/Layout/X3DLayoutContext.js +15 -12
- package/src/x_ite/Browser/Lighting/X3DLightingContext.js +18 -12
- package/src/x_ite/Browser/NURBS/NURBS.js +481 -0
- package/src/x_ite/Browser/Navigation/ExamineViewer.js +587 -127
- package/src/x_ite/Browser/Navigation/FlyViewer.js +23 -5
- package/src/x_ite/Browser/Navigation/LookAtViewer.js +402 -18
- package/src/x_ite/Browser/Navigation/NoneViewer.js +13 -3
- package/src/x_ite/Browser/Navigation/PlaneViewer.js +46 -28
- package/src/x_ite/Browser/Navigation/WalkViewer.js +45 -17
- package/src/x_ite/Browser/Navigation/X3DFlyViewer.js +414 -207
- package/src/x_ite/Browser/Navigation/X3DNavigationContext.js +65 -48
- package/src/x_ite/Browser/Navigation/X3DViewer.js +99 -45
- package/src/x_ite/Browser/Networking/X3DNetworkingContext.js +39 -38
- package/src/x_ite/Browser/Networking/urls.js +34 -5
- package/src/x_ite/Browser/ParticleSystems/X3DParticleSystemsContext.js +7 -9
- package/src/x_ite/Browser/Picking/IntersectionType.js +63 -0
- package/src/x_ite/Browser/Picking/MatchCriterion.js +64 -0
- package/src/x_ite/Browser/Picking/SortOrder.js +65 -0
- package/src/x_ite/Browser/Picking/VolumePicker.js +197 -0
- package/src/x_ite/Browser/Picking/X3DPickingContext.js +130 -0
- package/src/x_ite/Browser/PointingDeviceSensor/PointingDevice.js +89 -30
- package/src/x_ite/Browser/PointingDeviceSensor/PointingDeviceSensorContainer.js +1 -3
- package/src/x_ite/Browser/PointingDeviceSensor/X3DPointingDeviceSensorContext.js +33 -15
- package/src/x_ite/Browser/Rendering/X3DRenderingContext.js +39 -151
- package/src/x_ite/Browser/RigidBodyPhysics/AppliedParametersType.js +70 -0
- package/src/x_ite/Browser/Shaders/Shader.js +150 -50
- package/src/x_ite/Browser/Shaders/ShaderSource.js +140 -0
- package/src/x_ite/Browser/Shaders/ShaderTest.js +94 -77
- package/src/x_ite/Browser/Shaders/X3DShadersContext.js +220 -5
- package/src/x_ite/Browser/Shape/AlphaMode.js +65 -0
- package/src/x_ite/Browser/Shape/LineStipples.xcf +0 -0
- package/src/x_ite/Browser/Shape/X3DShapeContext.js +108 -4
- package/src/x_ite/Browser/Sound/X3DSoundContext.js +1 -20
- package/src/x_ite/Browser/Text/PolygonText.js +165 -359
- package/src/x_ite/Browser/Text/TextAlignment.js +3 -7
- package/src/x_ite/Browser/Text/X3DTextContext.js +38 -30
- package/src/x_ite/Browser/Text/X3DTextGeometry.js +58 -84
- package/src/x_ite/Browser/Texturing/MultiTextureFunctionType.js +64 -0
- package/src/x_ite/Browser/Texturing/MultiTextureModeType.js +81 -0
- package/src/x_ite/Browser/Texturing/MultiTextureSourceType.js +65 -0
- package/src/x_ite/Browser/Texturing/TextureCoordinateGeneratorModeType.js +73 -0
- package/src/x_ite/Browser/Texturing/X3DTexturingContext.js +148 -41
- package/src/x_ite/Browser/Texturing3D/DICOMParser.js +1126 -0
- package/src/x_ite/Browser/Texturing3D/NRRDParser.js +686 -0
- package/src/x_ite/Browser/Time/X3DTimeContext.js +20 -17
- package/src/x_ite/Browser/VERSION.js +2 -2
- package/src/x_ite/Browser/VolumeRendering/VolumeStyle.fs +120 -0
- package/src/x_ite/Browser/VolumeRendering/VolumeStyle.vs +28 -0
- package/src/x_ite/Browser/VolumeRendering/X3DVolumeRenderingContext.js +114 -0
- package/src/x_ite/Browser/X3DBrowser.js +282 -182
- package/src/x_ite/Browser/X3DBrowserContext.js +77 -43
- package/src/x_ite/Components/Annotation/AnnotationLayer.js +108 -0
- package/src/x_ite/Components/Annotation/AnnotationTarget.js +101 -0
- package/src/x_ite/Components/{PointingDeviceSensor/TouchGroup.js → Annotation/GroupAnnotation.js} +30 -24
- package/src/x_ite/Components/Annotation/IconAnnotation.js +110 -0
- package/src/x_ite/Components/Annotation/TextAnnotation.js +102 -0
- package/src/x_ite/Components/Annotation/URLAnnotation.js +101 -0
- package/src/x_ite/Components/Annotation/X3DAnnotationNode.js +76 -0
- package/src/x_ite/Components/CADGeometry/CADAssembly.js +6 -8
- package/src/x_ite/Components/CADGeometry/CADFace.js +137 -33
- package/src/x_ite/Components/CADGeometry/CADLayer.js +5 -18
- package/src/x_ite/Components/CADGeometry/CADPart.js +6 -12
- package/src/x_ite/Components/CADGeometry/IndexedQuadSet.js +20 -36
- package/src/x_ite/Components/CADGeometry/QuadSet.js +11 -24
- package/src/x_ite/Components/CADGeometry/X3DProductStructureChildNode.js +2 -4
- package/src/x_ite/Components/Core/MetadataBoolean.js +2 -4
- package/src/x_ite/Components/Core/MetadataDouble.js +2 -4
- package/src/x_ite/Components/Core/MetadataFloat.js +2 -4
- package/src/x_ite/Components/Core/MetadataInteger.js +2 -4
- package/src/x_ite/Components/Core/MetadataSet.js +2 -4
- package/src/x_ite/Components/Core/MetadataString.js +2 -4
- package/src/x_ite/Components/Core/WorldInfo.js +18 -10
- package/src/x_ite/Components/Core/X3DBindableNode.js +5 -36
- package/src/x_ite/Components/Core/X3DChildNode.js +16 -5
- package/src/x_ite/Components/Core/X3DInfoNode.js +2 -4
- package/src/x_ite/Components/Core/X3DMetadataObject.js +1 -3
- package/src/x_ite/Components/Core/X3DNode.js +2 -64
- package/src/x_ite/Components/Core/X3DPrototypeInstance.js +190 -210
- package/src/x_ite/Components/Core/X3DSensorNode.js +2 -4
- package/src/x_ite/Components/Core.js +111 -0
- package/src/x_ite/Components/CubeMapTexturing/ComposedCubeMapTexture.js +42 -50
- package/src/x_ite/Components/CubeMapTexturing/GeneratedCubeMapTexture.js +41 -42
- package/src/x_ite/Components/CubeMapTexturing/ImageCubeMapTexture.js +44 -59
- package/src/x_ite/Components/CubeMapTexturing/X3DEnvironmentTextureNode.js +48 -46
- package/src/x_ite/Components/DIS/DISEntityManager.js +2 -4
- package/src/x_ite/Components/DIS/DISEntityTypeMapping.js +2 -4
- package/src/x_ite/Components/DIS/EspduTransform.js +13 -9
- package/src/x_ite/Components/DIS/ReceiverPdu.js +13 -9
- package/src/x_ite/Components/DIS/SignalPdu.js +13 -9
- package/src/x_ite/Components/DIS/TransmitterPdu.js +13 -9
- package/src/x_ite/Components/EnvironmentalEffects/Background.js +2 -4
- package/src/x_ite/Components/EnvironmentalEffects/Fog.js +15 -18
- package/src/x_ite/Components/EnvironmentalEffects/FogCoordinate.js +59 -7
- package/src/x_ite/Components/EnvironmentalEffects/LocalFog.js +12 -10
- package/src/x_ite/Components/EnvironmentalEffects/TextureBackground.js +2 -4
- package/src/x_ite/Components/EnvironmentalEffects/X3DBackgroundNode.js +149 -143
- package/src/x_ite/Components/EnvironmentalEffects/X3DFogObject.js +61 -22
- package/src/x_ite/Components/EnvironmentalEffects.js +90 -0
- package/src/x_ite/Components/EnvironmentalSensor/ProximitySensor.js +121 -121
- package/src/x_ite/Components/EnvironmentalSensor/TransformSensor.js +173 -53
- package/src/x_ite/Components/EnvironmentalSensor/VisibilitySensor.js +33 -31
- package/src/x_ite/Components/EnvironmentalSensor/X3DEnvironmentalSensorNode.js +19 -11
- package/src/x_ite/Components/EnvironmentalSensor.js +81 -0
- package/src/x_ite/Components/EventUtilities/BooleanFilter.js +2 -4
- package/src/x_ite/Components/EventUtilities/BooleanSequencer.js +2 -4
- package/src/x_ite/Components/EventUtilities/BooleanToggle.js +2 -4
- package/src/x_ite/Components/EventUtilities/BooleanTrigger.js +2 -4
- package/src/x_ite/Components/EventUtilities/IntegerSequencer.js +2 -4
- package/src/x_ite/Components/EventUtilities/IntegerTrigger.js +2 -4
- package/src/x_ite/Components/EventUtilities/TimeTrigger.js +2 -4
- package/src/x_ite/Components/EventUtilities/X3DSequencerNode.js +2 -4
- package/src/x_ite/Components/EventUtilities/X3DTriggerNode.js +2 -4
- package/src/x_ite/Components/Followers/ColorChaser.js +3 -7
- package/src/x_ite/Components/Followers/ColorDamper.js +3 -7
- package/src/x_ite/Components/Followers/CoordinateChaser.js +3 -11
- package/src/x_ite/Components/Followers/CoordinateDamper.js +2 -10
- package/src/x_ite/Components/Followers/OrientationChaser.js +9 -7
- package/src/x_ite/Components/Followers/OrientationDamper.js +9 -7
- package/src/x_ite/Components/Followers/PositionChaser.js +3 -7
- package/src/x_ite/Components/Followers/PositionChaser2D.js +3 -7
- package/src/x_ite/Components/Followers/PositionDamper.js +3 -7
- package/src/x_ite/Components/Followers/PositionDamper2D.js +3 -7
- package/src/x_ite/Components/Followers/ScalarChaser.js +7 -7
- package/src/x_ite/Components/Followers/ScalarDamper.js +3 -7
- package/src/x_ite/Components/Followers/TexCoordChaser2D.js +3 -11
- package/src/x_ite/Components/Followers/TexCoordDamper2D.js +3 -11
- package/src/x_ite/Components/Followers/X3DChaserNode.js +26 -26
- package/src/x_ite/Components/Followers/X3DDamperNode.js +6 -10
- package/src/x_ite/Components/Followers/X3DFollowerNode.js +11 -11
- package/src/x_ite/Components/Followers.js +120 -0
- package/src/x_ite/Components/Geometry2D/Arc2D.js +28 -30
- package/src/x_ite/Components/Geometry2D/ArcClose2D.js +95 -93
- package/src/x_ite/Components/Geometry2D/Circle2D.js +16 -15
- package/src/x_ite/Components/Geometry2D/Disk2D.js +80 -88
- package/src/x_ite/Components/Geometry2D/Polyline2D.js +13 -19
- package/src/x_ite/Components/Geometry2D/Polypoint2D.js +12 -18
- package/src/x_ite/Components/Geometry2D/Rectangle2D.js +13 -13
- package/src/x_ite/Components/Geometry2D/TriangleSet2D.js +31 -30
- package/src/x_ite/Components/Geometry3D/Box.js +12 -12
- package/src/x_ite/Components/Geometry3D/Cone.js +34 -36
- package/src/x_ite/Components/Geometry3D/Cylinder.js +52 -54
- package/src/x_ite/Components/Geometry3D/ElevationGrid.js +90 -52
- package/src/x_ite/Components/Geometry3D/Extrusion.js +472 -388
- package/src/x_ite/Components/Geometry3D/IndexedFaceSet.js +193 -163
- package/src/x_ite/Components/Geometry3D/Sphere.js +17 -19
- package/src/x_ite/Components/Geometry3D.js +90 -0
- package/src/x_ite/Components/Geospatial/GeoCoordinate.js +124 -61
- package/src/x_ite/Components/Geospatial/GeoElevationGrid.js +54 -36
- package/src/x_ite/Components/Geospatial/GeoLOD.js +190 -98
- package/src/x_ite/Components/Geospatial/GeoLocation.js +8 -10
- package/src/x_ite/Components/Geospatial/GeoMetadata.js +2 -4
- package/src/x_ite/Components/Geospatial/GeoOrigin.js +2 -4
- package/src/x_ite/Components/Geospatial/GeoPositionInterpolator.js +4 -4
- package/src/x_ite/Components/Geospatial/GeoProximitySensor.js +10 -7
- package/src/x_ite/Components/Geospatial/GeoTouchSensor.js +4 -4
- package/src/x_ite/Components/Geospatial/GeoTransform.js +13 -13
- package/src/x_ite/Components/Geospatial/GeoViewpoint.js +131 -78
- package/src/x_ite/Components/Geospatial/X3DGeospatialObject.js +7 -9
- package/src/x_ite/Components/Grouping/Group.js +5 -7
- package/src/x_ite/Components/Grouping/StaticGroup.js +194 -22
- package/src/x_ite/Components/Grouping/Switch.js +174 -25
- package/src/x_ite/Components/Grouping/Transform.js +5 -7
- package/src/x_ite/Components/Grouping/X3DBoundedObject.js +70 -16
- package/src/x_ite/Components/Grouping/X3DGroupingNode.js +442 -151
- package/src/x_ite/Components/Grouping/X3DTransformMatrix3DNode.js +53 -29
- package/src/x_ite/Components/Grouping/X3DTransformNode.js +6 -9
- package/src/x_ite/Components/Grouping.js +93 -0
- package/src/x_ite/Components/{H-Anim → HAnim}/HAnimDisplacer.js +8 -10
- package/src/x_ite/Components/HAnim/HAnimHumanoid.js +360 -0
- package/src/x_ite/Components/{H-Anim → HAnim}/HAnimJoint.js +108 -23
- package/src/x_ite/Components/HAnim/HAnimMotion.js +113 -0
- package/src/x_ite/Components/{H-Anim → HAnim}/HAnimSegment.js +14 -14
- package/src/x_ite/Components/{H-Anim → HAnim}/HAnimSite.js +14 -16
- package/src/x_ite/Components/Interpolation/ColorInterpolator.js +13 -11
- package/src/x_ite/Components/Interpolation/CoordinateInterpolator.js +21 -13
- package/src/x_ite/Components/Interpolation/CoordinateInterpolator2D.js +19 -11
- package/src/x_ite/Components/Interpolation/EaseInEaseOut.js +8 -8
- package/src/x_ite/Components/Interpolation/NormalInterpolator.js +28 -14
- package/src/x_ite/Components/Interpolation/OrientationInterpolator.js +27 -16
- package/src/x_ite/Components/Interpolation/PositionInterpolator.js +10 -8
- package/src/x_ite/Components/Interpolation/PositionInterpolator2D.js +10 -8
- package/src/x_ite/Components/Interpolation/ScalarInterpolator.js +2 -4
- package/src/x_ite/Components/Interpolation/SplinePositionInterpolator.js +7 -9
- package/src/x_ite/Components/Interpolation/SplinePositionInterpolator2D.js +7 -9
- package/src/x_ite/Components/Interpolation/SplineScalarInterpolator.js +7 -9
- package/src/x_ite/Components/Interpolation/SquadOrientationInterpolator.js +10 -11
- package/src/x_ite/Components/Interpolation/X3DInterpolatorNode.js +2 -4
- package/src/x_ite/Components/Interpolation.js +111 -0
- package/src/x_ite/Components/KeyDeviceSensor/KeySensor.js +72 -8
- package/src/x_ite/Components/KeyDeviceSensor/StringSensor.js +65 -4
- package/src/x_ite/Components/KeyDeviceSensor/X3DKeyDeviceSensorNode.js +5 -29
- package/src/x_ite/Components/Layering/Layer.js +14 -6
- package/src/x_ite/Components/Layering/LayerSet.js +6 -10
- package/src/x_ite/Components/Layering/Viewport.js +10 -12
- package/src/x_ite/Components/Layering/X3DLayerNode.js +76 -69
- package/src/x_ite/Components/Layering/X3DViewportNode.js +2 -6
- package/src/x_ite/Components/Layering.js +84 -0
- package/src/x_ite/Components/Layout/Layout.js +163 -173
- package/src/x_ite/Components/Layout/LayoutGroup.js +20 -19
- package/src/x_ite/Components/Layout/LayoutLayer.js +12 -9
- package/src/x_ite/Components/Layout/ScreenFontStyle.js +4 -8
- package/src/x_ite/Components/Layout/ScreenGroup.js +63 -56
- package/src/x_ite/Components/Layout/X3DLayoutNode.js +2 -4
- package/src/x_ite/Components/Lighting/DirectionalLight.js +41 -31
- package/src/x_ite/Components/Lighting/PointLight.js +117 -104
- package/src/x_ite/Components/Lighting/SpotLight.js +77 -53
- package/src/x_ite/Components/Lighting/X3DLightNode.js +90 -68
- package/src/x_ite/Components/Lighting.js +81 -0
- package/src/x_ite/Components/NURBS/Contour2D.js +47 -5
- package/src/x_ite/Components/NURBS/ContourPolyline2D.js +69 -5
- package/src/x_ite/Components/NURBS/CoordinateDouble.js +2 -4
- package/src/x_ite/Components/NURBS/NurbsCurve.js +140 -10
- package/src/x_ite/Components/NURBS/NurbsCurve2D.js +117 -8
- package/src/x_ite/Components/NURBS/NurbsOrientationInterpolator.js +139 -10
- package/src/x_ite/Components/NURBS/NurbsPatchSurface.js +3 -5
- package/src/x_ite/Components/NURBS/NurbsPositionInterpolator.js +125 -10
- package/src/x_ite/Components/NURBS/NurbsSet.js +92 -11
- package/src/x_ite/Components/NURBS/NurbsSurfaceInterpolator.js +96 -12
- package/src/x_ite/Components/NURBS/NurbsSweptSurface.js +88 -7
- package/src/x_ite/Components/NURBS/NurbsSwungSurface.js +88 -7
- package/src/x_ite/Components/NURBS/NurbsTextureCoordinate.js +62 -13
- package/src/x_ite/Components/NURBS/NurbsTrimmedSurface.js +41 -6
- package/src/x_ite/Components/NURBS/X3DNurbsControlCurveNode.js +2 -4
- package/src/x_ite/Components/NURBS/X3DNurbsSurfaceGeometryNode.js +333 -7
- package/src/x_ite/Components/NURBS/X3DParametricGeometryNode.js +9 -5
- package/src/x_ite/Components/Navigation/Billboard.js +14 -15
- package/src/x_ite/Components/Navigation/Collision.js +13 -12
- package/src/x_ite/Components/Navigation/LOD.js +221 -66
- package/src/x_ite/Components/Navigation/NavigationInfo.js +110 -99
- package/src/x_ite/Components/Navigation/OrthoViewpoint.js +138 -45
- package/src/x_ite/Components/Navigation/Viewpoint.js +55 -33
- package/src/x_ite/Components/Navigation/ViewpointGroup.js +18 -10
- package/src/x_ite/Components/Navigation/X3DViewpointNode.js +241 -181
- package/src/x_ite/Components/Navigation.js +93 -0
- package/src/x_ite/Components/Networking/Anchor.js +24 -28
- package/src/x_ite/Components/Networking/Inline.js +68 -50
- package/src/x_ite/Components/Networking/LoadSensor.js +2 -4
- package/src/x_ite/Components/Networking/X3DNetworkSensorNode.js +2 -4
- package/src/x_ite/Components/Networking/X3DUrlObject.js +93 -11
- package/src/x_ite/Components/Networking.js +84 -0
- package/src/x_ite/Components/ParticleSystems/BoundedPhysicsModel.js +6 -8
- package/src/x_ite/Components/ParticleSystems/ConeEmitter.js +8 -4
- package/src/x_ite/Components/ParticleSystems/ExplosionEmitter.js +7 -4
- package/src/x_ite/Components/ParticleSystems/ForcePhysicsModel.js +4 -4
- package/src/x_ite/Components/ParticleSystems/ParticleSystem.js +451 -287
- package/src/x_ite/Components/ParticleSystems/PointEmitter.js +7 -4
- package/src/x_ite/Components/ParticleSystems/PolylineEmitter.js +53 -40
- package/src/x_ite/Components/ParticleSystems/SurfaceEmitter.js +62 -55
- package/src/x_ite/Components/ParticleSystems/VolumeEmitter.js +133 -123
- package/src/x_ite/Components/ParticleSystems/WindPhysicsModel.js +25 -22
- package/src/x_ite/Components/ParticleSystems/X3DParticleEmitterNode.js +28 -27
- package/src/x_ite/Components/ParticleSystems/X3DParticlePhysicsModelNode.js +2 -4
- package/src/x_ite/Components/Picking/LinePickSensor.js +253 -10
- package/src/x_ite/Components/Picking/PickableGroup.js +121 -10
- package/src/x_ite/Components/Picking/PointPickSensor.js +262 -12
- package/src/x_ite/Components/Picking/PrimitivePickSensor.js +176 -8
- package/src/x_ite/Components/Picking/VolumePickSensor.js +152 -8
- package/src/x_ite/Components/Picking/X3DPickSensorNode.js +378 -7
- package/src/x_ite/Components/Picking/X3DPickableObject.js +22 -4
- package/src/x_ite/Components/PointingDeviceSensor/CylinderSensor.js +33 -15
- package/src/x_ite/Components/PointingDeviceSensor/PlaneSensor.js +7 -4
- package/src/x_ite/Components/PointingDeviceSensor/SphereSensor.js +2 -4
- package/src/x_ite/Components/PointingDeviceSensor/TouchSensor.js +4 -4
- package/src/x_ite/Components/PointingDeviceSensor/X3DDragSensorNode.js +4 -4
- package/src/x_ite/Components/PointingDeviceSensor/X3DPointingDeviceSensorNode.js +3 -5
- package/src/x_ite/Components/PointingDeviceSensor/X3DTouchSensorNode.js +2 -4
- package/src/x_ite/Components/PointingDeviceSensor.js +90 -0
- package/src/x_ite/Components/ProjectiveTextureMapping/TextureProjectorParallel.js +282 -0
- package/src/x_ite/Components/ProjectiveTextureMapping/TextureProjectorPerspective.js +227 -0
- package/src/x_ite/Components/ProjectiveTextureMapping/X3DTextureProjectorNode.js +217 -0
- package/src/x_ite/Components/Rendering/ClipPlane.js +12 -16
- package/src/x_ite/Components/Rendering/Color.js +62 -17
- package/src/x_ite/Components/Rendering/ColorRGBA.js +65 -17
- package/src/x_ite/Components/Rendering/Coordinate.js +4 -4
- package/src/x_ite/Components/Rendering/IndexedLineSet.js +68 -81
- package/src/x_ite/Components/Rendering/IndexedTriangleFanSet.js +20 -19
- package/src/x_ite/Components/Rendering/IndexedTriangleSet.js +10 -7
- package/src/x_ite/Components/Rendering/IndexedTriangleStripSet.js +21 -23
- package/src/x_ite/Components/Rendering/LineSet.js +54 -37
- package/src/x_ite/Components/Rendering/Normal.js +65 -13
- package/src/x_ite/Components/Rendering/PointSet.js +52 -33
- package/src/x_ite/Components/Rendering/TriangleFanSet.js +10 -14
- package/src/x_ite/Components/Rendering/TriangleSet.js +2 -4
- package/src/x_ite/Components/Rendering/TriangleStripSet.js +9 -13
- package/src/x_ite/Components/Rendering/X3DColorNode.js +13 -12
- package/src/x_ite/Components/Rendering/X3DComposedGeometryNode.js +118 -79
- package/src/x_ite/Components/Rendering/X3DCoordinateNode.js +103 -44
- package/src/x_ite/Components/Rendering/X3DGeometricPropertyNode.js +2 -4
- package/src/x_ite/Components/Rendering/X3DGeometryNode.js +722 -591
- package/src/x_ite/Components/Rendering/X3DLineGeometryNode.js +129 -92
- package/src/x_ite/Components/Rendering/X3DNormalNode.js +2 -4
- package/src/x_ite/Components/Rendering.js +132 -0
- package/src/x_ite/Components/RigidBodyPhysics/BallJoint.js +116 -7
- package/src/x_ite/Components/RigidBodyPhysics/CollidableOffset.js +199 -11
- package/src/x_ite/Components/RigidBodyPhysics/CollidableShape.js +436 -11
- package/src/x_ite/Components/RigidBodyPhysics/CollisionCollection.js +118 -10
- package/src/x_ite/Components/RigidBodyPhysics/CollisionSensor.js +192 -9
- package/src/x_ite/Components/RigidBodyPhysics/CollisionSpace.js +84 -8
- package/src/x_ite/Components/RigidBodyPhysics/Contact.js +20 -14
- package/src/x_ite/Components/RigidBodyPhysics/DoubleAxisHingeJoint.js +200 -12
- package/src/x_ite/Components/RigidBodyPhysics/MotorJoint.js +14 -4
- package/src/x_ite/Components/RigidBodyPhysics/RigidBody.js +424 -17
- package/src/x_ite/Components/RigidBodyPhysics/RigidBodyCollection.js +295 -19
- package/src/x_ite/Components/RigidBodyPhysics/SingleAxisHingeJoint.js +162 -10
- package/src/x_ite/Components/RigidBodyPhysics/SliderJoint.js +135 -8
- package/src/x_ite/Components/RigidBodyPhysics/UniversalJoint.js +10 -6
- package/src/x_ite/Components/RigidBodyPhysics/X3DNBodyCollidableNode.js +93 -9
- package/src/x_ite/Components/RigidBodyPhysics/X3DNBodyCollisionSpaceNode.js +5 -8
- package/src/x_ite/Components/RigidBodyPhysics/X3DRigidJointNode.js +150 -4
- package/src/x_ite/Components/Scripting/Script.js +156 -105
- package/src/x_ite/Components/Scripting/X3DScriptNode.js +3 -7
- package/src/x_ite/Components/Shaders/ComposedShader.js +38 -53
- package/src/x_ite/Components/Shaders/FloatVertexAttribute.js +38 -15
- package/src/x_ite/Components/Shaders/Matrix3VertexAttribute.js +32 -14
- package/src/x_ite/Components/Shaders/Matrix4VertexAttribute.js +32 -14
- package/src/x_ite/Components/Shaders/PackagedShader.js +19 -17
- package/src/x_ite/Components/Shaders/ProgramShader.js +2 -4
- package/src/x_ite/Components/Shaders/ShaderPart.js +38 -26
- package/src/x_ite/Components/Shaders/ShaderProgram.js +16 -14
- package/src/x_ite/Components/Shaders/X3DProgrammableShaderObject.js +836 -699
- package/src/x_ite/Components/Shaders/X3DShaderNode.js +61 -101
- package/src/x_ite/Components/Shaders/X3DVertexAttributeNode.js +2 -4
- package/src/x_ite/Components/Shaders.js +102 -0
- package/src/x_ite/Components/Shape/Appearance.js +179 -69
- package/src/x_ite/Components/Shape/FillProperties.js +65 -8
- package/src/x_ite/Components/Shape/LineProperties.js +29 -9
- package/src/x_ite/Components/Shape/Material.js +50 -64
- package/src/x_ite/Components/Shape/PointProperties.js +162 -0
- package/src/x_ite/Components/Shape/Shape.js +116 -68
- package/src/x_ite/Components/Shape/TwoSidedMaterial.js +56 -62
- package/src/x_ite/Components/Shape/UnlitMaterial.js +109 -0
- package/src/x_ite/Components/Shape/X3DAppearanceChildNode.js +2 -4
- package/src/x_ite/Components/Shape/X3DAppearanceNode.js +14 -11
- package/src/x_ite/Components/Shape/X3DMaterialNode.js +17 -6
- package/src/x_ite/Components/Shape/X3DOneSidedMaterialNode.js +111 -0
- package/src/x_ite/Components/Shape/X3DShapeNode.js +54 -29
- package/src/x_ite/Components/Shape.js +108 -0
- package/src/x_ite/Components/Sound/AudioClip.js +47 -57
- package/src/x_ite/Components/Sound/Sound.js +177 -83
- package/src/x_ite/Components/Sound/X3DSoundNode.js +2 -4
- package/src/x_ite/Components/Sound/X3DSoundSourceNode.js +38 -24
- package/src/x_ite/Components/Sound.js +81 -0
- package/src/x_ite/Components/Text/FontStyle.js +4 -6
- package/src/x_ite/Components/Text/Text.js +21 -18
- package/src/x_ite/Components/Text/X3DFontStyleNode.js +58 -93
- package/src/x_ite/Components/Text.js +78 -0
- package/src/x_ite/Components/Texturing/ImageTexture.js +57 -67
- package/src/x_ite/Components/Texturing/MovieTexture.js +59 -70
- package/src/x_ite/Components/Texturing/MultiTexture.js +238 -15
- package/src/x_ite/Components/Texturing/MultiTextureCoordinate.js +85 -8
- package/src/x_ite/Components/Texturing/MultiTextureTransform.js +47 -8
- package/src/x_ite/Components/Texturing/PixelTexture.js +61 -27
- package/src/x_ite/Components/Texturing/TextureCoordinate.js +72 -22
- package/src/x_ite/Components/Texturing/TextureCoordinateGenerator.js +69 -11
- package/src/x_ite/Components/Texturing/TextureProperties.js +98 -69
- package/src/x_ite/Components/Texturing/TextureTransform.js +58 -52
- package/src/x_ite/Components/Texturing/X3DSingleTextureCoordinateNode.js +91 -0
- package/src/x_ite/Components/Texturing/X3DSingleTextureNode.js +183 -0
- package/src/x_ite/Components/Texturing/X3DSingleTextureTransformNode.js +77 -0
- package/src/x_ite/Components/Texturing/X3DTexture2DNode.js +42 -97
- package/src/x_ite/Components/Texturing/X3DTexture2DNode.js.~1~ +209 -0
- package/src/x_ite/Components/Texturing/X3DTextureCoordinateNode.js +4 -12
- package/src/x_ite/Components/Texturing/X3DTextureNode.js +10 -71
- package/src/x_ite/Components/Texturing/X3DTextureTransformNode.js +5 -14
- package/src/x_ite/Components/Texturing.js +120 -0
- package/src/x_ite/Components/Texturing3D/ComposedTexture3D.js +90 -8
- package/src/x_ite/Components/Texturing3D/ImageTexture3D.js +106 -16
- package/src/x_ite/Components/Texturing3D/PixelTexture3D.js +126 -8
- package/src/x_ite/Components/Texturing3D/TextureCoordinate3D.js +75 -25
- package/src/x_ite/Components/Texturing3D/TextureCoordinate4D.js +74 -24
- package/src/x_ite/Components/Texturing3D/TextureTransform3D.js +42 -36
- package/src/x_ite/Components/Texturing3D/TextureTransformMatrix3D.js +19 -16
- package/src/x_ite/Components/Texturing3D/X3DTexture3DNode.js +110 -8
- package/src/x_ite/Components/Time/TimeSensor.js +68 -38
- package/src/x_ite/Components/Time/X3DTimeDependentNode.js +29 -29
- package/src/x_ite/Components/Time.js +75 -0
- package/src/x_ite/Components/VolumeRendering/BlendedVolumeStyle.js +311 -12
- package/src/x_ite/Components/VolumeRendering/BoundaryEnhancementVolumeStyle.js +60 -8
- package/src/x_ite/Components/VolumeRendering/CartoonVolumeStyle.js +219 -10
- package/src/x_ite/Components/VolumeRendering/ComposedVolumeStyle.js +134 -7
- package/src/x_ite/Components/VolumeRendering/EdgeEnhancementVolumeStyle.js +88 -9
- package/src/x_ite/Components/VolumeRendering/IsoSurfaceVolumeData.js +311 -15
- package/src/x_ite/Components/VolumeRendering/OpacityMapVolumeStyle.js +87 -7
- package/src/x_ite/Components/VolumeRendering/ProjectionVolumeStyle.js +136 -6
- package/src/x_ite/Components/VolumeRendering/SegmentedVolumeData.js +224 -13
- package/src/x_ite/Components/VolumeRendering/ShadedVolumeStyle.js +193 -12
- package/src/x_ite/Components/VolumeRendering/SilhouetteEnhancementVolumeStyle.js +87 -10
- package/src/x_ite/Components/VolumeRendering/ToneMappedVolumeStyle.js +97 -9
- package/src/x_ite/Components/VolumeRendering/VolumeData.js +155 -12
- package/src/x_ite/Components/VolumeRendering/X3DComposableVolumeRenderStyleNode.js +2 -4
- package/src/x_ite/Components/VolumeRendering/X3DVolumeDataNode.js +155 -5
- package/src/x_ite/Components/VolumeRendering/X3DVolumeRenderStyleNode.js +64 -4
- package/src/x_ite/Components/X_ITE/BlendMode.js +206 -0
- package/src/x_ite/Components.js +110 -0
- package/src/x_ite/Configuration/ComponentInfo.js +21 -15
- package/src/x_ite/Configuration/ComponentInfoArray.js +11 -16
- package/src/x_ite/Configuration/ProfileInfo.js +10 -10
- package/src/x_ite/Configuration/ProfileInfoArray.js +10 -3
- package/src/x_ite/Configuration/SupportedComponents.js +312 -303
- package/src/x_ite/Configuration/SupportedNodes.js +44 -716
- package/src/x_ite/Configuration/SupportedProfiles.js +196 -168
- package/src/x_ite/Configuration/UnitInfo.js +22 -8
- package/src/x_ite/Configuration/UnitInfoArray.js +2 -3
- package/src/x_ite/Configuration/X3DInfoArray.js +46 -26
- package/src/x_ite/DEBUG.js +4 -5
- package/src/x_ite/Execution/BindableList.js +99 -34
- package/src/x_ite/Execution/BindableStack.js +65 -74
- package/src/x_ite/Execution/ExportedNode.js +32 -9
- package/src/x_ite/Execution/ImportedNode.js +144 -63
- package/src/x_ite/Execution/Scene.js +33 -35
- package/src/x_ite/Execution/World.js +31 -29
- package/src/x_ite/Execution/X3DExecutionContext.js +452 -194
- package/src/x_ite/Execution/X3DScene.js +303 -74
- package/src/x_ite/{Error.js → Fallback.js} +25 -24
- package/src/x_ite/Fields/ArrayFields.js +315 -112
- package/src/x_ite/Fields/SFBool.js +11 -10
- package/src/x_ite/Fields/SFColor.js +43 -19
- package/src/x_ite/Fields/SFColorRGBA.js +40 -18
- package/src/x_ite/Fields/SFDouble.js +17 -10
- package/src/x_ite/Fields/SFFloat.js +18 -11
- package/src/x_ite/Fields/SFImage.js +47 -38
- package/src/x_ite/Fields/SFInt32.js +10 -9
- package/src/x_ite/Fields/SFMatrix3.js +24 -17
- package/src/x_ite/Fields/SFMatrix4.js +24 -17
- package/src/x_ite/Fields/SFMatrixPrototypeTemplate.js +15 -8
- package/src/x_ite/Fields/SFNode.js +119 -39
- package/src/x_ite/Fields/SFNodeCache.js +89 -0
- package/src/x_ite/Fields/SFRotation.js +42 -27
- package/src/x_ite/Fields/SFString.js +14 -15
- package/src/x_ite/Fields/SFTime.js +12 -11
- package/src/x_ite/Fields/SFVec2.js +17 -14
- package/src/x_ite/Fields/SFVec3.js +23 -17
- package/src/x_ite/Fields/SFVec4.js +25 -19
- package/src/x_ite/Fields/SFVecPrototypeTemplate.js +51 -19
- package/src/x_ite/Fields.js +3 -9
- package/src/x_ite/InputOutput/FileLoader.js +264 -181
- package/src/x_ite/InputOutput/Generator.js +136 -60
- package/src/x_ite/Parser/HTMLSupport.js +3 -596
- package/src/x_ite/Parser/JSONParser.js +446 -0
- package/src/x_ite/Parser/Parser.js +617 -652
- package/src/x_ite/Parser/X3DParser.js +176 -0
- package/src/x_ite/Parser/XMLParser.js +359 -94
- package/src/x_ite/Prototype/ExternProtoDeclarationArray.js +19 -3
- package/src/x_ite/Prototype/ProtoDeclarationArray.js +19 -3
- package/src/x_ite/Prototype/X3DExternProtoDeclaration.js +120 -61
- package/src/x_ite/Prototype/X3DProtoDeclaration.js +144 -59
- package/src/x_ite/Prototype/X3DProtoDeclarationNode.js +16 -18
- package/src/x_ite/Rendering/DependentRenderer.js +9 -13
- package/src/x_ite/Rendering/{DepthBuffer.js → TextureBuffer.js} +84 -53
- package/src/x_ite/Rendering/X3DRenderObject.js +640 -531
- package/src/x_ite/Routing/RouteArray.js +38 -16
- package/src/x_ite/Routing/X3DRoute.js +67 -68
- package/src/x_ite/Routing/X3DRoutingContext.js +6 -6
- package/src/x_ite/X3D.js +74 -70
- package/src/x_ite.config.js +91 -0
- package/src/x_ite.css +175 -53
- package/src/x_ite.html +128 -439
- package/src/x_ite.js +87 -25
- package/tests/{SEE.txt → README.md} +1 -0
- package/tests/tests.mdproj +1 -1
- package/x_ite.min.html +128 -439
- package/.bzrignore +0 -3
- package/.npmignore +0 -3
- package/AUTHORS.md +0 -6
- package/STYLE_GUIDE.md +0 -51
- package/X_ITE.sln +0 -56
- package/X_ITE.userprefs +0 -13
- package/build/build.mdproj +0 -24
- package/build/dist.pl +0 -97
- package/build/parts/end.frag +0 -10
- package/build/parts/start.frag +0 -7
- package/dist/LICENCES.txt +0 -344
- package/dist/dist.mdproj +0 -45
- package/dist/images/logo.128.png +0 -0
- package/fonts/fonts.mdproj +0 -29
- package/meta/meta.mdproj +0 -35
- package/require.build.js +0 -15
- package/require.build.min.js +0 -15
- package/src/images/logo.128.png +0 -0
- package/src/lib/jquery-contextMenu/README.md +0 -355
- package/src/lib/jquery-contextMenu/dist/images/cut.png +0 -0
- package/src/lib/jquery-contextMenu/dist/images/door.png +0 -0
- package/src/lib/jquery-contextMenu/dist/images/page_white_add.png +0 -0
- package/src/lib/jquery-contextMenu/dist/images/page_white_copy.png +0 -0
- package/src/lib/jquery-contextMenu/dist/images/page_white_delete.png +0 -0
- package/src/lib/jquery-contextMenu/dist/images/page_white_edit.png +0 -0
- package/src/lib/jquery-contextMenu/dist/images/page_white_paste.png +0 -0
- package/src/lib/jquery-contextMenu/dist/jquery.contextMenu.css +0 -155
- package/src/lib/jquery-contextMenu/dist/jquery.contextMenu.js +0 -1811
- package/src/lib/jquery-contextMenu/dist/jquery.contextMenu.min.css +0 -16
- package/src/lib/jquery-contextMenu/dist/jquery.contextMenu.min.css.map +0 -1
- package/src/lib/jquery-contextMenu/dist/jquery.contextMenu.min.js +0 -18
- package/src/lib/jquery-contextMenu/dist/jquery.contextMenu.min.js.map +0 -1
- package/src/lib/jquery-contextMenu/dist/jquery.ui.position.js +0 -517
- package/src/lib/jquery-contextMenu/dist/jquery.ui.position.min.js +0 -4
- package/src/lib/jquery-contextMenu/package.json +0 -99
- package/src/lib/opentype.js/.npmignore +0 -5
- package/src/locale/de.mo +0 -0
- package/src/locale/fr.mo +0 -0
- package/src/require.config.js +0 -51
- package/src/src.mdproj +0 -729
- package/src/standard/Networking/URI.js +0 -687
- package/src/x_ite/Browser/Shaders/BackgroundSphereFragmentShader.fs +0 -29
- package/src/x_ite/Browser/Shaders/BackgroundSphereVertexShader.vs +0 -22
- package/src/x_ite/Browser/Shaders/Bits/Line3.h +0 -14
- package/src/x_ite/Browser/Shaders/Bits/Plane3.h +0 -47
- package/src/x_ite/Browser/Shaders/Bits/Random.h +0 -31
- package/src/x_ite/Browser/Shaders/Depth.fs +0 -51
- package/src/x_ite/Browser/Shaders/Depth.vs +0 -20
- package/src/x_ite/Browser/Shaders/Gouraud.fs +0 -110
- package/src/x_ite/Browser/Shaders/Gouraud.vs +0 -188
- package/src/x_ite/Browser/Shaders/Phong.fs +0 -255
- package/src/x_ite/Browser/Shaders/Phong.vs +0 -38
- package/src/x_ite/Browser/Shaders/PointSet.fs +0 -64
- package/src/x_ite/Browser/Shaders/Wireframe.fs +0 -61
- package/src/x_ite/Browser/Shaders/Wireframe.vs +0 -55
- package/src/x_ite/Components/H-Anim/HAnimHumanoid.js +0 -118
|
@@ -0,0 +1,4216 @@
|
|
|
1
|
+
(function () {
|
|
2
|
+
|
|
3
|
+
var
|
|
4
|
+
define = X3D .define,
|
|
5
|
+
require = X3D .require,
|
|
6
|
+
module = { };
|
|
7
|
+
/* -*- Mode: JavaScript; coding: utf-8; tab-width: 3; indent-tabs-mode: tab; c-basic-offset: 3 -*-
|
|
8
|
+
*******************************************************************************
|
|
9
|
+
*
|
|
10
|
+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
11
|
+
*
|
|
12
|
+
* Copyright create3000, Scheffelstraße 31a, Leipzig, Germany 2011.
|
|
13
|
+
*
|
|
14
|
+
* All rights reserved. Holger Seelig <holger.seelig@yahoo.de>.
|
|
15
|
+
*
|
|
16
|
+
* The copyright notice above does not evidence any actual of intended
|
|
17
|
+
* publication of such source code, and is an unpublished work by create3000.
|
|
18
|
+
* This material contains CONFIDENTIAL INFORMATION that is the property of
|
|
19
|
+
* create3000.
|
|
20
|
+
*
|
|
21
|
+
* No permission is granted to copy, distribute, or create derivative works from
|
|
22
|
+
* the contents of this software, in whole or in part, without the prior written
|
|
23
|
+
* permission of create3000.
|
|
24
|
+
*
|
|
25
|
+
* NON-MILITARY USE ONLY
|
|
26
|
+
*
|
|
27
|
+
* All create3000 software are effectively free software with a non-military use
|
|
28
|
+
* restriction. It is free. Well commented source is provided. You may reuse the
|
|
29
|
+
* source in any way you please with the exception anything that uses it must be
|
|
30
|
+
* marked to indicate is contains 'non-military use only' components.
|
|
31
|
+
*
|
|
32
|
+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
33
|
+
*
|
|
34
|
+
* Copyright 2015, 2016 Holger Seelig <holger.seelig@yahoo.de>.
|
|
35
|
+
*
|
|
36
|
+
* This file is part of the X_ITE Project.
|
|
37
|
+
*
|
|
38
|
+
* X_ITE is free software: you can redistribute it and/or modify it under the
|
|
39
|
+
* terms of the GNU General Public License version 3 only, as published by the
|
|
40
|
+
* Free Software Foundation.
|
|
41
|
+
*
|
|
42
|
+
* X_ITE is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
43
|
+
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
|
44
|
+
* A PARTICULAR PURPOSE. See the GNU General Public License version 3 for more
|
|
45
|
+
* details (a copy is included in the LICENSE file that accompanied this code).
|
|
46
|
+
*
|
|
47
|
+
* You should have received a copy of the GNU General Public License version 3
|
|
48
|
+
* along with X_ITE. If not, see <http://www.gnu.org/licenses/gpl.html> for a
|
|
49
|
+
* copy of the GPLv3 License.
|
|
50
|
+
*
|
|
51
|
+
* For Silvio, Joy and Adi.
|
|
52
|
+
*
|
|
53
|
+
******************************************************************************/
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
define ('x_ite/Components/ParticleSystems/X3DParticleEmitterNode',[
|
|
57
|
+
"x_ite/Components/Core/X3DNode",
|
|
58
|
+
"x_ite/Bits/X3DConstants",
|
|
59
|
+
"standard/Math/Numbers/Vector3",
|
|
60
|
+
"standard/Math/Numbers/Rotation4",
|
|
61
|
+
"standard/Math/Geometry/Line3",
|
|
62
|
+
"standard/Math/Geometry/Plane3",
|
|
63
|
+
"standard/Math/Algorithm",
|
|
64
|
+
"standard/Math/Algorithms/QuickSort",
|
|
65
|
+
],
|
|
66
|
+
function (X3DNode,
|
|
67
|
+
X3DConstants,
|
|
68
|
+
Vector3,
|
|
69
|
+
Rotation4,
|
|
70
|
+
Line3,
|
|
71
|
+
Plane3,
|
|
72
|
+
Algorithm,
|
|
73
|
+
QuickSort)
|
|
74
|
+
{
|
|
75
|
+
"use strict";
|
|
76
|
+
|
|
77
|
+
var
|
|
78
|
+
normal = new Vector3 (0, 0, 0),
|
|
79
|
+
fromPosition = new Vector3 (0, 0, 0),
|
|
80
|
+
line = new Line3 (Vector3 .Zero, Vector3 .zAxis),
|
|
81
|
+
plane = new Plane3 (Vector3 .Zero, Vector3 .zAxis);
|
|
82
|
+
|
|
83
|
+
function PlaneCompare (a, b)
|
|
84
|
+
{
|
|
85
|
+
return plane .getDistanceToPoint (a) < plane .getDistanceToPoint (b);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function PlaneCompareValue (a, b)
|
|
89
|
+
{
|
|
90
|
+
return a < plane .getDistanceToPoint (b);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function X3DParticleEmitterNode (executionContext)
|
|
94
|
+
{
|
|
95
|
+
X3DNode .call (this, executionContext);
|
|
96
|
+
|
|
97
|
+
this .addType (X3DConstants .X3DParticleEmitterNode);
|
|
98
|
+
|
|
99
|
+
this .speed_ .setUnit ("speed");
|
|
100
|
+
this .mass_ .setUnit ("mass");
|
|
101
|
+
this .surfaceArea_ .setUnit ("area");
|
|
102
|
+
|
|
103
|
+
this .rotations = [ ];
|
|
104
|
+
this .intersections = [ ];
|
|
105
|
+
this .intersectionNormals = [ ];
|
|
106
|
+
this .sorter = new QuickSort (this .intersections, PlaneCompare);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
X3DParticleEmitterNode .prototype = Object .assign (Object .create (X3DNode .prototype),
|
|
110
|
+
{
|
|
111
|
+
constructor: X3DParticleEmitterNode,
|
|
112
|
+
initialize: function ()
|
|
113
|
+
{
|
|
114
|
+
X3DNode .prototype .initialize .call (this);
|
|
115
|
+
|
|
116
|
+
this .speed_ .addInterest ("set_speed__", this);
|
|
117
|
+
this .variation_ .addInterest ("set_variation__", this);
|
|
118
|
+
this .mass_ .addInterest ("set_mass__", this);
|
|
119
|
+
|
|
120
|
+
this .set_speed__ ();
|
|
121
|
+
this .set_variation__ ();
|
|
122
|
+
this .set_mass__ ();
|
|
123
|
+
},
|
|
124
|
+
set_speed__: function ()
|
|
125
|
+
{
|
|
126
|
+
this .speed = this .speed_ .getValue ();
|
|
127
|
+
},
|
|
128
|
+
set_variation__: function ()
|
|
129
|
+
{
|
|
130
|
+
this .variation = this .variation_ .getValue ();
|
|
131
|
+
},
|
|
132
|
+
set_mass__: function ()
|
|
133
|
+
{
|
|
134
|
+
this .mass = this .mass_ .getValue ();
|
|
135
|
+
},
|
|
136
|
+
isExplosive: function ()
|
|
137
|
+
{
|
|
138
|
+
return false;
|
|
139
|
+
},
|
|
140
|
+
getMass: function ()
|
|
141
|
+
{
|
|
142
|
+
return this .mass;
|
|
143
|
+
},
|
|
144
|
+
getRandomLifetime: function (particleLifetime, lifetimeVariation)
|
|
145
|
+
{
|
|
146
|
+
var
|
|
147
|
+
v = particleLifetime * lifetimeVariation,
|
|
148
|
+
min = Math .max (0, particleLifetime - v),
|
|
149
|
+
max = particleLifetime + v;
|
|
150
|
+
|
|
151
|
+
return Math .random () * (max - min) + min;
|
|
152
|
+
},
|
|
153
|
+
getRandomSpeed: function ()
|
|
154
|
+
{
|
|
155
|
+
var
|
|
156
|
+
speed = this .speed,
|
|
157
|
+
v = speed * this .variation,
|
|
158
|
+
min = Math .max (0, speed - v),
|
|
159
|
+
max = speed + v;
|
|
160
|
+
|
|
161
|
+
return Math .random () * (max - min) + min;
|
|
162
|
+
},
|
|
163
|
+
getSphericalRandomVelocity: function (velocity)
|
|
164
|
+
{
|
|
165
|
+
return this .getRandomNormal (velocity) .multiply (this .getRandomSpeed ());
|
|
166
|
+
},
|
|
167
|
+
getRandomValue: function (min, max)
|
|
168
|
+
{
|
|
169
|
+
return Math .random () * (max - min) + min;
|
|
170
|
+
},
|
|
171
|
+
getRandomNormal: function (normal)
|
|
172
|
+
{
|
|
173
|
+
var
|
|
174
|
+
theta = this .getRandomValue (-1, 1) * Math .PI,
|
|
175
|
+
cphi = this .getRandomValue (-1, 1),
|
|
176
|
+
phi = Math .acos (cphi),
|
|
177
|
+
r = Math .sin (phi);
|
|
178
|
+
|
|
179
|
+
return normal .set (Math .sin (theta) * r,
|
|
180
|
+
Math .cos (theta) * r,
|
|
181
|
+
cphi);
|
|
182
|
+
},
|
|
183
|
+
getRandomNormalWithAngle: function (angle, normal)
|
|
184
|
+
{
|
|
185
|
+
var
|
|
186
|
+
theta = (Math .random () * 2 - 1) * Math .PI,
|
|
187
|
+
cphi = this .getRandomValue (Math .cos (angle), 1),
|
|
188
|
+
phi = Math .acos (cphi),
|
|
189
|
+
r = Math .sin (phi);
|
|
190
|
+
|
|
191
|
+
return normal .set (Math .sin (theta) * r,
|
|
192
|
+
Math .cos (theta) * r,
|
|
193
|
+
cphi);
|
|
194
|
+
},
|
|
195
|
+
getRandomNormalWithDirectionAndAngle: function (direction, angle, normal)
|
|
196
|
+
{
|
|
197
|
+
rotation .setFromToVec (Vector3 .zAxis, direction);
|
|
198
|
+
|
|
199
|
+
return rotation .multVecRot (this .getRandomNormalWithAngle (angle, normal));
|
|
200
|
+
},
|
|
201
|
+
getRandomSurfaceNormal: function (normal)
|
|
202
|
+
{
|
|
203
|
+
var
|
|
204
|
+
theta = this .getRandomValue (-1, 1) * Math .PI,
|
|
205
|
+
cphi = Math .pow (Math .random (), 1/3),
|
|
206
|
+
phi = Math .acos (cphi),
|
|
207
|
+
r = Math .sin (phi);
|
|
208
|
+
|
|
209
|
+
return normal .set (Math .sin (theta) * r,
|
|
210
|
+
Math .cos (theta) * r,
|
|
211
|
+
cphi);
|
|
212
|
+
},
|
|
213
|
+
animate: function (particleSystem, deltaTime)
|
|
214
|
+
{
|
|
215
|
+
var
|
|
216
|
+
particles = particleSystem .particles,
|
|
217
|
+
numParticles = particleSystem .numParticles,
|
|
218
|
+
createParticles = particleSystem .createParticles,
|
|
219
|
+
particleLifetime = particleSystem .particleLifetime,
|
|
220
|
+
lifetimeVariation = particleSystem .lifetimeVariation,
|
|
221
|
+
speeds = particleSystem .speeds, // speed of velocities
|
|
222
|
+
velocities = particleSystem .velocities, // resulting velocities from forces
|
|
223
|
+
turbulences = particleSystem .turbulences, // turbulences
|
|
224
|
+
rotations = this .rotations, // rotation to direction of force
|
|
225
|
+
numForces = particleSystem .numForces, // number of forces
|
|
226
|
+
boundedPhysics = particleSystem .boundedVertices .length,
|
|
227
|
+
boundedVolume = particleSystem .boundedVolume;
|
|
228
|
+
|
|
229
|
+
for (var i = rotations .length; i < numForces; ++ i)
|
|
230
|
+
rotations [i] = new Rotation4 (0, 0, 1, 0);
|
|
231
|
+
|
|
232
|
+
for (var i = 0; i < numForces; ++ i)
|
|
233
|
+
rotations [i] .setFromToVec (Vector3 .zAxis, velocities [i]);
|
|
234
|
+
|
|
235
|
+
for (var i = 0; i < numParticles; ++ i)
|
|
236
|
+
{
|
|
237
|
+
var
|
|
238
|
+
particle = particles [i],
|
|
239
|
+
elapsedTime = particle .elapsedTime + deltaTime;
|
|
240
|
+
|
|
241
|
+
if (elapsedTime > particle .lifetime)
|
|
242
|
+
{
|
|
243
|
+
// Create new particle or hide particle.
|
|
244
|
+
|
|
245
|
+
particle .lifetime = this .getRandomLifetime (particleLifetime, lifetimeVariation);
|
|
246
|
+
particle .elapsedTime = 0;
|
|
247
|
+
|
|
248
|
+
if (createParticles)
|
|
249
|
+
{
|
|
250
|
+
++ particle .life;
|
|
251
|
+
this .getRandomPosition (particle .position);
|
|
252
|
+
this .getRandomVelocity (particle .velocity);
|
|
253
|
+
}
|
|
254
|
+
else
|
|
255
|
+
particle .position .set (Number .POSITIVE_INFINITY, Number .POSITIVE_INFINITY, Number .POSITIVE_INFINITY);
|
|
256
|
+
}
|
|
257
|
+
else
|
|
258
|
+
{
|
|
259
|
+
// Animate particle.
|
|
260
|
+
|
|
261
|
+
var
|
|
262
|
+
position = particle .position,
|
|
263
|
+
velocity = particle .velocity;
|
|
264
|
+
|
|
265
|
+
for (var f = 0; f < numForces; ++ f)
|
|
266
|
+
{
|
|
267
|
+
velocity .add (rotations [f] .multVecRot (this .getRandomNormalWithAngle (turbulences [f], normal)) .multiply (speeds [f]));
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
if (boundedPhysics)
|
|
271
|
+
{
|
|
272
|
+
fromPosition .x = position .x;
|
|
273
|
+
fromPosition .y = position .y;
|
|
274
|
+
fromPosition .z = position .z;
|
|
275
|
+
|
|
276
|
+
position .x += velocity .x * deltaTime;
|
|
277
|
+
position .y += velocity .y * deltaTime;
|
|
278
|
+
position .z += velocity .z * deltaTime;
|
|
279
|
+
|
|
280
|
+
this .bounce (boundedVolume, fromPosition, position, velocity);
|
|
281
|
+
}
|
|
282
|
+
else
|
|
283
|
+
{
|
|
284
|
+
position .x += velocity .x * deltaTime;
|
|
285
|
+
position .y += velocity .y * deltaTime;
|
|
286
|
+
position .z += velocity .z * deltaTime;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
particle .elapsedTime = elapsedTime;
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
// Animate color if needed.
|
|
294
|
+
|
|
295
|
+
if (particleSystem .geometryContext .colorMaterial)
|
|
296
|
+
this .getColors (particles, particleSystem .colorKeys, particleSystem .colorRamp, numParticles);
|
|
297
|
+
},
|
|
298
|
+
bounce: function (boundedVolume, fromPosition, toPosition, velocity)
|
|
299
|
+
{
|
|
300
|
+
normal .assign (velocity) .normalize ();
|
|
301
|
+
|
|
302
|
+
line .set (fromPosition, normal);
|
|
303
|
+
|
|
304
|
+
var
|
|
305
|
+
intersections = this .intersections,
|
|
306
|
+
intersectionNormals = this .intersectionNormals,
|
|
307
|
+
numIntersections = boundedVolume .intersectsLine (line, intersections, intersectionNormals);
|
|
308
|
+
|
|
309
|
+
if (numIntersections)
|
|
310
|
+
{
|
|
311
|
+
for (var i = 0; i < numIntersections; ++ i)
|
|
312
|
+
intersections [i] .index = i;
|
|
313
|
+
|
|
314
|
+
plane .set (fromPosition, normal);
|
|
315
|
+
|
|
316
|
+
this .sorter .sort (0, numIntersections);
|
|
317
|
+
|
|
318
|
+
var index = Algorithm .upperBound (intersections, 0, numIntersections, 0, PlaneCompareValue);
|
|
319
|
+
|
|
320
|
+
if (index < numIntersections)
|
|
321
|
+
{
|
|
322
|
+
var
|
|
323
|
+
intersection = intersections [index],
|
|
324
|
+
intersectionNormal = intersectionNormals [intersection .index];
|
|
325
|
+
|
|
326
|
+
plane .set (intersection, intersectionNormal);
|
|
327
|
+
|
|
328
|
+
if (plane .getDistanceToPoint (fromPosition) * plane .getDistanceToPoint (toPosition) < 0)
|
|
329
|
+
{
|
|
330
|
+
var dot2 = 2 * intersectionNormal .dot (velocity);
|
|
331
|
+
|
|
332
|
+
velocity .x -= intersectionNormal .x * dot2;
|
|
333
|
+
velocity .y -= intersectionNormal .y * dot2;
|
|
334
|
+
velocity .z -= intersectionNormal .z * dot2;
|
|
335
|
+
|
|
336
|
+
normal .assign (velocity) .normalize ();
|
|
337
|
+
|
|
338
|
+
var distance = intersection .distance (fromPosition);
|
|
339
|
+
|
|
340
|
+
toPosition .x = intersection .x + normal .x * distance;
|
|
341
|
+
toPosition .y = intersection .y + normal .y * distance;
|
|
342
|
+
toPosition .z = intersection .z + normal .z * distance;
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
},
|
|
347
|
+
getColors: function (particles, colorKeys, colorRamp, numParticles)
|
|
348
|
+
{
|
|
349
|
+
var
|
|
350
|
+
length = colorKeys .length,
|
|
351
|
+
index0 = 0,
|
|
352
|
+
index1 = 0,
|
|
353
|
+
weight = 0;
|
|
354
|
+
|
|
355
|
+
for (var i = 0; i < numParticles; ++ i)
|
|
356
|
+
{
|
|
357
|
+
// Determine index0, index1 and weight.
|
|
358
|
+
|
|
359
|
+
var
|
|
360
|
+
particle = particles [i],
|
|
361
|
+
fraction = particle .elapsedTime / particle .lifetime,
|
|
362
|
+
color = particle .color;
|
|
363
|
+
|
|
364
|
+
if (length == 1 || fraction <= colorKeys [0])
|
|
365
|
+
{
|
|
366
|
+
index0 = 0;
|
|
367
|
+
index1 = 0;
|
|
368
|
+
weight = 0;
|
|
369
|
+
}
|
|
370
|
+
else if (fraction >= colorKeys [length - 1])
|
|
371
|
+
{
|
|
372
|
+
index0 = length - 2;
|
|
373
|
+
index1 = length - 1;
|
|
374
|
+
weight = 1;
|
|
375
|
+
}
|
|
376
|
+
else
|
|
377
|
+
{
|
|
378
|
+
var index = Algorithm .upperBound (colorKeys, 0, length, fraction, Algorithm .less);
|
|
379
|
+
|
|
380
|
+
if (index < length)
|
|
381
|
+
{
|
|
382
|
+
index1 = index;
|
|
383
|
+
index0 = index - 1;
|
|
384
|
+
|
|
385
|
+
var
|
|
386
|
+
key0 = colorKeys [index0],
|
|
387
|
+
key1 = colorKeys [index1];
|
|
388
|
+
|
|
389
|
+
weight = Algorithm .clamp ((fraction - key0) / (key1 - key0), 0, 1);
|
|
390
|
+
}
|
|
391
|
+
else
|
|
392
|
+
{
|
|
393
|
+
index0 = 0;
|
|
394
|
+
index1 = 0;
|
|
395
|
+
weight = 0;
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
// Interpolate and set color.
|
|
400
|
+
|
|
401
|
+
var
|
|
402
|
+
color0 = colorRamp [index0],
|
|
403
|
+
color1 = colorRamp [index1];
|
|
404
|
+
|
|
405
|
+
// Algorithm .lerp (color0, color1, weight);
|
|
406
|
+
color .x = color0 .x + weight * (color1 .x - color0 .x);
|
|
407
|
+
color .y = color0 .y + weight * (color1 .y - color0 .y);
|
|
408
|
+
color .z = color0 .z + weight * (color1 .z - color0 .z);
|
|
409
|
+
color .w = color0 .w + weight * (color1 .w - color0 .w);
|
|
410
|
+
}
|
|
411
|
+
},
|
|
412
|
+
});
|
|
413
|
+
|
|
414
|
+
return X3DParticleEmitterNode;
|
|
415
|
+
});
|
|
416
|
+
|
|
417
|
+
/* -*- Mode: JavaScript; coding: utf-8; tab-width: 3; indent-tabs-mode: tab; c-basic-offset: 3 -*-
|
|
418
|
+
*******************************************************************************
|
|
419
|
+
*
|
|
420
|
+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
421
|
+
*
|
|
422
|
+
* Copyright create3000, Scheffelstraße 31a, Leipzig, Germany 2011.
|
|
423
|
+
*
|
|
424
|
+
* All rights reserved. Holger Seelig <holger.seelig@yahoo.de>.
|
|
425
|
+
*
|
|
426
|
+
* The copyright notice above does not evidence any actual of intended
|
|
427
|
+
* publication of such source code, and is an unpublished work by create3000.
|
|
428
|
+
* This material contains CONFIDENTIAL INFORMATION that is the property of
|
|
429
|
+
* create3000.
|
|
430
|
+
*
|
|
431
|
+
* No permission is granted to copy, distribute, or create derivative works from
|
|
432
|
+
* the contents of this software, in whole or in part, without the prior written
|
|
433
|
+
* permission of create3000.
|
|
434
|
+
*
|
|
435
|
+
* NON-MILITARY USE ONLY
|
|
436
|
+
*
|
|
437
|
+
* All create3000 software are effectively free software with a non-military use
|
|
438
|
+
* restriction. It is free. Well commented source is provided. You may reuse the
|
|
439
|
+
* source in any way you please with the exception anything that uses it must be
|
|
440
|
+
* marked to indicate is contains 'non-military use only' components.
|
|
441
|
+
*
|
|
442
|
+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
443
|
+
*
|
|
444
|
+
* Copyright 2015, 2016 Holger Seelig <holger.seelig@yahoo.de>.
|
|
445
|
+
*
|
|
446
|
+
* This file is part of the X_ITE Project.
|
|
447
|
+
*
|
|
448
|
+
* X_ITE is free software: you can redistribute it and/or modify it under the
|
|
449
|
+
* terms of the GNU General Public License version 3 only, as published by the
|
|
450
|
+
* Free Software Foundation.
|
|
451
|
+
*
|
|
452
|
+
* X_ITE is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
453
|
+
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
|
454
|
+
* A PARTICULAR PURPOSE. See the GNU General Public License version 3 for more
|
|
455
|
+
* details (a copy is included in the LICENSE file that accompanied this code).
|
|
456
|
+
*
|
|
457
|
+
* You should have received a copy of the GNU General Public License version 3
|
|
458
|
+
* along with X_ITE. If not, see <http://www.gnu.org/licenses/gpl.html> for a
|
|
459
|
+
* copy of the GPLv3 License.
|
|
460
|
+
*
|
|
461
|
+
* For Silvio, Joy and Adi.
|
|
462
|
+
*
|
|
463
|
+
******************************************************************************/
|
|
464
|
+
|
|
465
|
+
|
|
466
|
+
define ('x_ite/Components/ParticleSystems/PointEmitter',[
|
|
467
|
+
"x_ite/Fields",
|
|
468
|
+
"x_ite/Basic/X3DFieldDefinition",
|
|
469
|
+
"x_ite/Basic/FieldDefinitionArray",
|
|
470
|
+
"x_ite/Components/ParticleSystems/X3DParticleEmitterNode",
|
|
471
|
+
"x_ite/Bits/X3DConstants",
|
|
472
|
+
"standard/Math/Numbers/Vector3",
|
|
473
|
+
],
|
|
474
|
+
function (Fields,
|
|
475
|
+
X3DFieldDefinition,
|
|
476
|
+
FieldDefinitionArray,
|
|
477
|
+
X3DParticleEmitterNode,
|
|
478
|
+
X3DConstants,
|
|
479
|
+
Vector3)
|
|
480
|
+
{
|
|
481
|
+
"use strict";
|
|
482
|
+
|
|
483
|
+
function PointEmitter (executionContext)
|
|
484
|
+
{
|
|
485
|
+
X3DParticleEmitterNode .call (this, executionContext);
|
|
486
|
+
|
|
487
|
+
this .addType (X3DConstants .PointEmitter);
|
|
488
|
+
|
|
489
|
+
this .position_ .setUnit ("length");
|
|
490
|
+
this .speed_ .setUnit ("speed");
|
|
491
|
+
this .mass_ .setUnit ("mass");
|
|
492
|
+
this .surfaceArea_ .setUnit ("area");
|
|
493
|
+
|
|
494
|
+
this .direction = new Vector3 (0, 0, 0);
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
PointEmitter .prototype = Object .assign (Object .create (X3DParticleEmitterNode .prototype),
|
|
498
|
+
{
|
|
499
|
+
constructor: PointEmitter,
|
|
500
|
+
fieldDefinitions: new FieldDefinitionArray ([
|
|
501
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "metadata", new Fields .SFNode ()),
|
|
502
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "position", new Fields .SFVec3f ()),
|
|
503
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "direction", new Fields .SFVec3f (0, 1, 0)),
|
|
504
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "speed", new Fields .SFFloat ()),
|
|
505
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "variation", new Fields .SFFloat (0.25)),
|
|
506
|
+
new X3DFieldDefinition (X3DConstants .initializeOnly, "mass", new Fields .SFFloat ()),
|
|
507
|
+
new X3DFieldDefinition (X3DConstants .initializeOnly, "surfaceArea", new Fields .SFFloat ()),
|
|
508
|
+
]),
|
|
509
|
+
getTypeName: function ()
|
|
510
|
+
{
|
|
511
|
+
return "PointEmitter";
|
|
512
|
+
},
|
|
513
|
+
getComponentName: function ()
|
|
514
|
+
{
|
|
515
|
+
return "ParticleSystems";
|
|
516
|
+
},
|
|
517
|
+
getContainerField: function ()
|
|
518
|
+
{
|
|
519
|
+
return "emitter";
|
|
520
|
+
},
|
|
521
|
+
initialize: function ()
|
|
522
|
+
{
|
|
523
|
+
X3DParticleEmitterNode .prototype .initialize .call (this);
|
|
524
|
+
|
|
525
|
+
this .position_ .addInterest ("set_position__", this);
|
|
526
|
+
this .direction_ .addInterest ("set_direction__", this);
|
|
527
|
+
|
|
528
|
+
this .set_position__ ();
|
|
529
|
+
this .set_direction__ ();
|
|
530
|
+
},
|
|
531
|
+
set_position__: function ()
|
|
532
|
+
{
|
|
533
|
+
this .position = this .position_ .getValue ()
|
|
534
|
+
},
|
|
535
|
+
set_direction__: function ()
|
|
536
|
+
{
|
|
537
|
+
this .direction .assign (this .direction_ .getValue ()) .normalize ();
|
|
538
|
+
|
|
539
|
+
if (this .direction .equals (Vector3 .Zero))
|
|
540
|
+
this .getRandomVelocity = this .getSphericalRandomVelocity;
|
|
541
|
+
else
|
|
542
|
+
delete this .getRandomVelocity;
|
|
543
|
+
},
|
|
544
|
+
getRandomPosition: function (position)
|
|
545
|
+
{
|
|
546
|
+
return position .assign (this .position);
|
|
547
|
+
},
|
|
548
|
+
getRandomVelocity: function (velocity)
|
|
549
|
+
{
|
|
550
|
+
var
|
|
551
|
+
direction = this .direction,
|
|
552
|
+
speed = this .getRandomSpeed ();
|
|
553
|
+
|
|
554
|
+
velocity .x = direction .x * speed;
|
|
555
|
+
velocity .y = direction .y * speed;
|
|
556
|
+
velocity .z = direction .z * speed;
|
|
557
|
+
|
|
558
|
+
return velocity;
|
|
559
|
+
},
|
|
560
|
+
});
|
|
561
|
+
|
|
562
|
+
return PointEmitter;
|
|
563
|
+
});
|
|
564
|
+
|
|
565
|
+
|
|
566
|
+
|
|
567
|
+
/* -*- Mode: JavaScript; coding: utf-8; tab-width: 3; indent-tabs-mode: tab; c-basic-offset: 3 -*-
|
|
568
|
+
*******************************************************************************
|
|
569
|
+
*
|
|
570
|
+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
571
|
+
*
|
|
572
|
+
* Copyright create3000, Scheffelstraße 31a, Leipzig, Germany 2011.
|
|
573
|
+
*
|
|
574
|
+
* All rights reserved. Holger Seelig <holger.seelig@yahoo.de>.
|
|
575
|
+
*
|
|
576
|
+
* The copyright notice above does not evidence any actual of intended
|
|
577
|
+
* publication of such source code, and is an unpublished work by create3000.
|
|
578
|
+
* This material contains CONFIDENTIAL INFORMATION that is the property of
|
|
579
|
+
* create3000.
|
|
580
|
+
*
|
|
581
|
+
* No permission is granted to copy, distribute, or create derivative works from
|
|
582
|
+
* the contents of this software, in whole or in part, without the prior written
|
|
583
|
+
* permission of create3000.
|
|
584
|
+
*
|
|
585
|
+
* NON-MILITARY USE ONLY
|
|
586
|
+
*
|
|
587
|
+
* All create3000 software are effectively free software with a non-military use
|
|
588
|
+
* restriction. It is free. Well commented source is provided. You may reuse the
|
|
589
|
+
* source in any way you please with the exception anything that uses it must be
|
|
590
|
+
* marked to indicate is contains 'non-military use only' components.
|
|
591
|
+
*
|
|
592
|
+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
593
|
+
*
|
|
594
|
+
* Copyright 2015, 2016 Holger Seelig <holger.seelig@yahoo.de>.
|
|
595
|
+
*
|
|
596
|
+
* This file is part of the X_ITE Project.
|
|
597
|
+
*
|
|
598
|
+
* X_ITE is free software: you can redistribute it and/or modify it under the
|
|
599
|
+
* terms of the GNU General Public License version 3 only, as published by the
|
|
600
|
+
* Free Software Foundation.
|
|
601
|
+
*
|
|
602
|
+
* X_ITE is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
603
|
+
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
|
604
|
+
* A PARTICULAR PURPOSE. See the GNU General Public License version 3 for more
|
|
605
|
+
* details (a copy is included in the LICENSE file that accompanied this code).
|
|
606
|
+
*
|
|
607
|
+
* You should have received a copy of the GNU General Public License version 3
|
|
608
|
+
* along with X_ITE. If not, see <http://www.gnu.org/licenses/gpl.html> for a
|
|
609
|
+
* copy of the GPLv3 License.
|
|
610
|
+
*
|
|
611
|
+
* For Silvio, Joy and Adi.
|
|
612
|
+
*
|
|
613
|
+
******************************************************************************/
|
|
614
|
+
|
|
615
|
+
|
|
616
|
+
define ('x_ite/Browser/ParticleSystems/X3DParticleSystemsContext',[
|
|
617
|
+
"x_ite/Components/ParticleSystems/PointEmitter",
|
|
618
|
+
],
|
|
619
|
+
function (PointEmitter)
|
|
620
|
+
{
|
|
621
|
+
"use strict";
|
|
622
|
+
|
|
623
|
+
function X3DParticleSystemsContext () { }
|
|
624
|
+
|
|
625
|
+
X3DParticleSystemsContext .prototype =
|
|
626
|
+
{
|
|
627
|
+
getDefaultEmitter: function ()
|
|
628
|
+
{
|
|
629
|
+
this .defaultEmitter = new PointEmitter (this .getPrivateScene ());
|
|
630
|
+
this .defaultEmitter .setup ();
|
|
631
|
+
|
|
632
|
+
this .getDefaultEmitter = function () { return this .defaultEmitter; };
|
|
633
|
+
|
|
634
|
+
return this .defaultEmitter;
|
|
635
|
+
},
|
|
636
|
+
};
|
|
637
|
+
|
|
638
|
+
return X3DParticleSystemsContext;
|
|
639
|
+
});
|
|
640
|
+
|
|
641
|
+
/* -*- Mode: JavaScript; coding: utf-8; tab-width: 3; indent-tabs-mode: tab; c-basic-offset: 3 -*-
|
|
642
|
+
*******************************************************************************
|
|
643
|
+
*
|
|
644
|
+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
645
|
+
*
|
|
646
|
+
* Copyright create3000, Scheffelstraße 31a, Leipzig, Germany 2011.
|
|
647
|
+
*
|
|
648
|
+
* All rights reserved. Holger Seelig <holger.seelig@yahoo.de>.
|
|
649
|
+
*
|
|
650
|
+
* The copyright notice above does not evidence any actual of intended
|
|
651
|
+
* publication of such source code, and is an unpublished work by create3000.
|
|
652
|
+
* This material contains CONFIDENTIAL INFORMATION that is the property of
|
|
653
|
+
* create3000.
|
|
654
|
+
*
|
|
655
|
+
* No permission is granted to copy, distribute, or create derivative works from
|
|
656
|
+
* the contents of this software, in whole or in part, without the prior written
|
|
657
|
+
* permission of create3000.
|
|
658
|
+
*
|
|
659
|
+
* NON-MILITARY USE ONLY
|
|
660
|
+
*
|
|
661
|
+
* All create3000 software are effectively free software with a non-military use
|
|
662
|
+
* restriction. It is free. Well commented source is provided. You may reuse the
|
|
663
|
+
* source in any way you please with the exception anything that uses it must be
|
|
664
|
+
* marked to indicate is contains 'non-military use only' components.
|
|
665
|
+
*
|
|
666
|
+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
667
|
+
*
|
|
668
|
+
* Copyright 2015, 2016 Holger Seelig <holger.seelig@yahoo.de>.
|
|
669
|
+
*
|
|
670
|
+
* This file is part of the X_ITE Project.
|
|
671
|
+
*
|
|
672
|
+
* X_ITE is free software: you can redistribute it and/or modify it under the
|
|
673
|
+
* terms of the GNU General Public License version 3 only, as published by the
|
|
674
|
+
* Free Software Foundation.
|
|
675
|
+
*
|
|
676
|
+
* X_ITE is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
677
|
+
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
|
678
|
+
* A PARTICULAR PURPOSE. See the GNU General Public License version 3 for more
|
|
679
|
+
* details (a copy is included in the LICENSE file that accompanied this code).
|
|
680
|
+
*
|
|
681
|
+
* You should have received a copy of the GNU General Public License version 3
|
|
682
|
+
* along with X_ITE. If not, see <http://www.gnu.org/licenses/gpl.html> for a
|
|
683
|
+
* copy of the GPLv3 License.
|
|
684
|
+
*
|
|
685
|
+
* For Silvio, Joy and Adi.
|
|
686
|
+
*
|
|
687
|
+
******************************************************************************/
|
|
688
|
+
|
|
689
|
+
|
|
690
|
+
define ('x_ite/Components/ParticleSystems/X3DParticlePhysicsModelNode',[
|
|
691
|
+
"x_ite/Components/Core/X3DNode",
|
|
692
|
+
"x_ite/Bits/X3DConstants",
|
|
693
|
+
],
|
|
694
|
+
function (X3DNode,
|
|
695
|
+
X3DConstants)
|
|
696
|
+
{
|
|
697
|
+
"use strict";
|
|
698
|
+
|
|
699
|
+
function X3DParticlePhysicsModelNode (executionContext)
|
|
700
|
+
{
|
|
701
|
+
X3DNode .call (this, executionContext);
|
|
702
|
+
|
|
703
|
+
this .addType (X3DConstants .X3DParticlePhysicsModelNode);
|
|
704
|
+
}
|
|
705
|
+
|
|
706
|
+
X3DParticlePhysicsModelNode .prototype = Object .assign (Object .create (X3DNode .prototype),
|
|
707
|
+
{
|
|
708
|
+
constructor: X3DParticlePhysicsModelNode,
|
|
709
|
+
addForce: function ()
|
|
710
|
+
{ },
|
|
711
|
+
});
|
|
712
|
+
|
|
713
|
+
return X3DParticlePhysicsModelNode;
|
|
714
|
+
});
|
|
715
|
+
|
|
716
|
+
|
|
717
|
+
|
|
718
|
+
/* -*- Mode: JavaScript; coding: utf-8; tab-width: 3; indent-tabs-mode: tab; c-basic-offset: 3 -*-
|
|
719
|
+
*******************************************************************************
|
|
720
|
+
*
|
|
721
|
+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
722
|
+
*
|
|
723
|
+
* Copyright create3000, Scheffelstraße 31a, Leipzig, Germany 2011.
|
|
724
|
+
*
|
|
725
|
+
* All rights reserved. Holger Seelig <holger.seelig@yahoo.de>.
|
|
726
|
+
*
|
|
727
|
+
* The copyright notice above does not evidence any actual of intended
|
|
728
|
+
* publication of such source code, and is an unpublished work by create3000.
|
|
729
|
+
* This material contains CONFIDENTIAL INFORMATION that is the property of
|
|
730
|
+
* create3000.
|
|
731
|
+
*
|
|
732
|
+
* No permission is granted to copy, distribute, or create derivative works from
|
|
733
|
+
* the contents of this software, in whole or in part, without the prior written
|
|
734
|
+
* permission of create3000.
|
|
735
|
+
*
|
|
736
|
+
* NON-MILITARY USE ONLY
|
|
737
|
+
*
|
|
738
|
+
* All create3000 software are effectively free software with a non-military use
|
|
739
|
+
* restriction. It is free. Well commented source is provided. You may reuse the
|
|
740
|
+
* source in any way you please with the exception anything that uses it must be
|
|
741
|
+
* marked to indicate is contains 'non-military use only' components.
|
|
742
|
+
*
|
|
743
|
+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
744
|
+
*
|
|
745
|
+
* Copyright 2015, 2016 Holger Seelig <holger.seelig@yahoo.de>.
|
|
746
|
+
*
|
|
747
|
+
* This file is part of the X_ITE Project.
|
|
748
|
+
*
|
|
749
|
+
* X_ITE is free software: you can redistribute it and/or modify it under the
|
|
750
|
+
* terms of the GNU General Public License version 3 only, as published by the
|
|
751
|
+
* Free Software Foundation.
|
|
752
|
+
*
|
|
753
|
+
* X_ITE is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
754
|
+
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
|
755
|
+
* A PARTICULAR PURPOSE. See the GNU General Public License version 3 for more
|
|
756
|
+
* details (a copy is included in the LICENSE file that accompanied this code).
|
|
757
|
+
*
|
|
758
|
+
* You should have received a copy of the GNU General Public License version 3
|
|
759
|
+
* along with X_ITE. If not, see <http://www.gnu.org/licenses/gpl.html> for a
|
|
760
|
+
* copy of the GPLv3 License.
|
|
761
|
+
*
|
|
762
|
+
* For Silvio, Joy and Adi.
|
|
763
|
+
*
|
|
764
|
+
******************************************************************************/
|
|
765
|
+
|
|
766
|
+
|
|
767
|
+
define ('x_ite/Components/ParticleSystems/BoundedPhysicsModel',[
|
|
768
|
+
"x_ite/Fields",
|
|
769
|
+
"x_ite/Basic/X3DFieldDefinition",
|
|
770
|
+
"x_ite/Basic/FieldDefinitionArray",
|
|
771
|
+
"x_ite/Components/ParticleSystems/X3DParticlePhysicsModelNode",
|
|
772
|
+
"x_ite/Bits/X3DConstants",
|
|
773
|
+
"x_ite/Bits/X3DCast",
|
|
774
|
+
],
|
|
775
|
+
function (Fields,
|
|
776
|
+
X3DFieldDefinition,
|
|
777
|
+
FieldDefinitionArray,
|
|
778
|
+
X3DParticlePhysicsModelNode,
|
|
779
|
+
X3DConstants,
|
|
780
|
+
X3DCast)
|
|
781
|
+
{
|
|
782
|
+
"use strict";
|
|
783
|
+
|
|
784
|
+
function BoundedPhysicsModel (executionContext)
|
|
785
|
+
{
|
|
786
|
+
X3DParticlePhysicsModelNode .call (this, executionContext);
|
|
787
|
+
|
|
788
|
+
this .addType (X3DConstants .BoundedPhysicsModel);
|
|
789
|
+
}
|
|
790
|
+
|
|
791
|
+
BoundedPhysicsModel .prototype = Object .assign (Object .create (X3DParticlePhysicsModelNode .prototype),
|
|
792
|
+
{
|
|
793
|
+
constructor: BoundedPhysicsModel,
|
|
794
|
+
fieldDefinitions: new FieldDefinitionArray ([
|
|
795
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "metadata", new Fields .SFNode ()),
|
|
796
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "enabled", new Fields .SFBool (true)),
|
|
797
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "geometry", new Fields .SFNode ()),
|
|
798
|
+
]),
|
|
799
|
+
getTypeName: function ()
|
|
800
|
+
{
|
|
801
|
+
return "BoundedPhysicsModel";
|
|
802
|
+
},
|
|
803
|
+
getComponentName: function ()
|
|
804
|
+
{
|
|
805
|
+
return "ParticleSystems";
|
|
806
|
+
},
|
|
807
|
+
getContainerField: function ()
|
|
808
|
+
{
|
|
809
|
+
return "physics";
|
|
810
|
+
},
|
|
811
|
+
initialize: function ()
|
|
812
|
+
{
|
|
813
|
+
X3DParticlePhysicsModelNode .prototype .initialize .call (this);
|
|
814
|
+
|
|
815
|
+
this .geometry_ .addInterest ("set_geometry__", this);
|
|
816
|
+
|
|
817
|
+
this .set_geometry__ ();
|
|
818
|
+
},
|
|
819
|
+
set_geometry__: function ()
|
|
820
|
+
{
|
|
821
|
+
if (this .geometryNode)
|
|
822
|
+
this .geometryNode .rebuild_ .removeInterest ("addNodeEvent", this);
|
|
823
|
+
|
|
824
|
+
this .geometryNode = X3DCast (X3DConstants .X3DGeometryNode, this .geometry_);
|
|
825
|
+
|
|
826
|
+
if (this .geometryNode)
|
|
827
|
+
this .geometryNode .rebuild_ .addInterest ("addNodeEvent", this);
|
|
828
|
+
},
|
|
829
|
+
addGeometry: function (boundedNormals, boundedVertices)
|
|
830
|
+
{
|
|
831
|
+
if (this .geometryNode)
|
|
832
|
+
{
|
|
833
|
+
var
|
|
834
|
+
normals = this .geometryNode .getNormals () .getValue (),
|
|
835
|
+
vertices = this .geometryNode .getVertices () .getValue ();
|
|
836
|
+
|
|
837
|
+
for (var i = 0, length = normals .length; i < length; ++ i)
|
|
838
|
+
boundedNormals .push (normals [i]);
|
|
839
|
+
|
|
840
|
+
for (var i = 0, length = vertices .length; i < length; ++ i)
|
|
841
|
+
boundedVertices .push (vertices [i]);
|
|
842
|
+
}
|
|
843
|
+
},
|
|
844
|
+
});
|
|
845
|
+
|
|
846
|
+
return BoundedPhysicsModel;
|
|
847
|
+
});
|
|
848
|
+
|
|
849
|
+
|
|
850
|
+
|
|
851
|
+
/* -*- Mode: JavaScript; coding: utf-8; tab-width: 3; indent-tabs-mode: tab; c-basic-offset: 3 -*-
|
|
852
|
+
*******************************************************************************
|
|
853
|
+
*
|
|
854
|
+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
855
|
+
*
|
|
856
|
+
* Copyright create3000, Scheffelstraße 31a, Leipzig, Germany 2011.
|
|
857
|
+
*
|
|
858
|
+
* All rights reserved. Holger Seelig <holger.seelig@yahoo.de>.
|
|
859
|
+
*
|
|
860
|
+
* The copyright notice above does not evidence any actual of intended
|
|
861
|
+
* publication of such source code, and is an unpublished work by create3000.
|
|
862
|
+
* This material contains CONFIDENTIAL INFORMATION that is the property of
|
|
863
|
+
* create3000.
|
|
864
|
+
*
|
|
865
|
+
* No permission is granted to copy, distribute, or create derivative works from
|
|
866
|
+
* the contents of this software, in whole or in part, without the prior written
|
|
867
|
+
* permission of create3000.
|
|
868
|
+
*
|
|
869
|
+
* NON-MILITARY USE ONLY
|
|
870
|
+
*
|
|
871
|
+
* All create3000 software are effectively free software with a non-military use
|
|
872
|
+
* restriction. It is free. Well commented source is provided. You may reuse the
|
|
873
|
+
* source in any way you please with the exception anything that uses it must be
|
|
874
|
+
* marked to indicate is contains 'non-military use only' components.
|
|
875
|
+
*
|
|
876
|
+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
877
|
+
*
|
|
878
|
+
* Copyright 2015, 2016 Holger Seelig <holger.seelig@yahoo.de>.
|
|
879
|
+
*
|
|
880
|
+
* This file is part of the X_ITE Project.
|
|
881
|
+
*
|
|
882
|
+
* X_ITE is free software: you can redistribute it and/or modify it under the
|
|
883
|
+
* terms of the GNU General Public License version 3 only, as published by the
|
|
884
|
+
* Free Software Foundation.
|
|
885
|
+
*
|
|
886
|
+
* X_ITE is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
887
|
+
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
|
888
|
+
* A PARTICULAR PURPOSE. See the GNU General Public License version 3 for more
|
|
889
|
+
* details (a copy is included in the LICENSE file that accompanied this code).
|
|
890
|
+
*
|
|
891
|
+
* You should have received a copy of the GNU General Public License version 3
|
|
892
|
+
* along with X_ITE. If not, see <http://www.gnu.org/licenses/gpl.html> for a
|
|
893
|
+
* copy of the GPLv3 License.
|
|
894
|
+
*
|
|
895
|
+
* For Silvio, Joy and Adi.
|
|
896
|
+
*
|
|
897
|
+
******************************************************************************/
|
|
898
|
+
|
|
899
|
+
|
|
900
|
+
define ('x_ite/Components/ParticleSystems/ConeEmitter',[
|
|
901
|
+
"x_ite/Fields",
|
|
902
|
+
"x_ite/Basic/X3DFieldDefinition",
|
|
903
|
+
"x_ite/Basic/FieldDefinitionArray",
|
|
904
|
+
"x_ite/Components/ParticleSystems/X3DParticleEmitterNode",
|
|
905
|
+
"x_ite/Bits/X3DConstants",
|
|
906
|
+
"standard/Math/Numbers/Vector3",
|
|
907
|
+
"standard/Math/Numbers/Rotation4",
|
|
908
|
+
],
|
|
909
|
+
function (Fields,
|
|
910
|
+
X3DFieldDefinition,
|
|
911
|
+
FieldDefinitionArray,
|
|
912
|
+
X3DParticleEmitterNode,
|
|
913
|
+
X3DConstants,
|
|
914
|
+
Vector3,
|
|
915
|
+
Rotation4)
|
|
916
|
+
{
|
|
917
|
+
"use strict";
|
|
918
|
+
|
|
919
|
+
function ConeEmitter (executionContext)
|
|
920
|
+
{
|
|
921
|
+
X3DParticleEmitterNode .call (this, executionContext);
|
|
922
|
+
|
|
923
|
+
this .addType (X3DConstants .ConeEmitter);
|
|
924
|
+
|
|
925
|
+
this .position_ .setUnit ("length");
|
|
926
|
+
this .angle_ .setUnit ("angle");
|
|
927
|
+
this .speed_ .setUnit ("speed");
|
|
928
|
+
this .mass_ .setUnit ("mass");
|
|
929
|
+
this .surfaceArea_ .setUnit ("area");
|
|
930
|
+
|
|
931
|
+
this .rotation = new Rotation4 (0, 0, 1, 0);
|
|
932
|
+
}
|
|
933
|
+
|
|
934
|
+
ConeEmitter .prototype = Object .assign (Object .create (X3DParticleEmitterNode .prototype),
|
|
935
|
+
{
|
|
936
|
+
constructor: ConeEmitter,
|
|
937
|
+
fieldDefinitions: new FieldDefinitionArray ([
|
|
938
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "metadata", new Fields .SFNode ()),
|
|
939
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "position", new Fields .SFVec3f ()),
|
|
940
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "direction", new Fields .SFVec3f (0, 1, 0)),
|
|
941
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "angle", new Fields .SFFloat (0.7854)),
|
|
942
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "speed", new Fields .SFFloat ()),
|
|
943
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "variation", new Fields .SFFloat (0.25)),
|
|
944
|
+
new X3DFieldDefinition (X3DConstants .initializeOnly, "mass", new Fields .SFFloat ()),
|
|
945
|
+
new X3DFieldDefinition (X3DConstants .initializeOnly, "surfaceArea", new Fields .SFFloat ()),
|
|
946
|
+
]),
|
|
947
|
+
getTypeName: function ()
|
|
948
|
+
{
|
|
949
|
+
return "ConeEmitter";
|
|
950
|
+
},
|
|
951
|
+
getComponentName: function ()
|
|
952
|
+
{
|
|
953
|
+
return "ParticleSystems";
|
|
954
|
+
},
|
|
955
|
+
getContainerField: function ()
|
|
956
|
+
{
|
|
957
|
+
return "emitter";
|
|
958
|
+
},
|
|
959
|
+
initialize: function ()
|
|
960
|
+
{
|
|
961
|
+
X3DParticleEmitterNode .prototype .initialize .call (this);
|
|
962
|
+
|
|
963
|
+
this .position_ .addInterest ("set_position__", this);
|
|
964
|
+
this .direction_ .addInterest ("set_direction__", this);
|
|
965
|
+
this .angle_ .addInterest ("set_angle__", this);
|
|
966
|
+
|
|
967
|
+
this .set_position__ ();
|
|
968
|
+
this .set_direction__ ();
|
|
969
|
+
this .set_angle__ ();
|
|
970
|
+
},
|
|
971
|
+
set_position__: function ()
|
|
972
|
+
{
|
|
973
|
+
this .position = this .position_ .getValue ()
|
|
974
|
+
},
|
|
975
|
+
set_direction__: function ()
|
|
976
|
+
{
|
|
977
|
+
var direction = this .direction_ .getValue ();
|
|
978
|
+
|
|
979
|
+
this .rotation .setFromToVec (Vector3 .zAxis, direction);
|
|
980
|
+
|
|
981
|
+
if (direction .equals (Vector3 .Zero))
|
|
982
|
+
this .getRandomVelocity = this .getSphericalRandomVelocity;
|
|
983
|
+
else
|
|
984
|
+
delete this .getRandomVelocity;
|
|
985
|
+
},
|
|
986
|
+
set_angle__: function ()
|
|
987
|
+
{
|
|
988
|
+
this .angle = this .angle_ .getValue ()
|
|
989
|
+
},
|
|
990
|
+
getRandomPosition: function (position)
|
|
991
|
+
{
|
|
992
|
+
return position .assign (this .position);
|
|
993
|
+
},
|
|
994
|
+
getRandomVelocity: function (velocity)
|
|
995
|
+
{
|
|
996
|
+
return this .rotation .multVecRot (this .getRandomNormalWithAngle (this .angle, velocity) .multiply (this .getRandomSpeed ()));
|
|
997
|
+
},
|
|
998
|
+
});
|
|
999
|
+
|
|
1000
|
+
return ConeEmitter;
|
|
1001
|
+
});
|
|
1002
|
+
|
|
1003
|
+
|
|
1004
|
+
|
|
1005
|
+
/* -*- Mode: JavaScript; coding: utf-8; tab-width: 3; indent-tabs-mode: tab; c-basic-offset: 3 -*-
|
|
1006
|
+
*******************************************************************************
|
|
1007
|
+
*
|
|
1008
|
+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
1009
|
+
*
|
|
1010
|
+
* Copyright create3000, Scheffelstraße 31a, Leipzig, Germany 2011.
|
|
1011
|
+
*
|
|
1012
|
+
* All rights reserved. Holger Seelig <holger.seelig@yahoo.de>.
|
|
1013
|
+
*
|
|
1014
|
+
* The copyright notice above does not evidence any actual of intended
|
|
1015
|
+
* publication of such source code, and is an unpublished work by create3000.
|
|
1016
|
+
* This material contains CONFIDENTIAL INFORMATION that is the property of
|
|
1017
|
+
* create3000.
|
|
1018
|
+
*
|
|
1019
|
+
* No permission is granted to copy, distribute, or create derivative works from
|
|
1020
|
+
* the contents of this software, in whole or in part, without the prior written
|
|
1021
|
+
* permission of create3000.
|
|
1022
|
+
*
|
|
1023
|
+
* NON-MILITARY USE ONLY
|
|
1024
|
+
*
|
|
1025
|
+
* All create3000 software are effectively free software with a non-military use
|
|
1026
|
+
* restriction. It is free. Well commented source is provided. You may reuse the
|
|
1027
|
+
* source in any way you please with the exception anything that uses it must be
|
|
1028
|
+
* marked to indicate is contains 'non-military use only' components.
|
|
1029
|
+
*
|
|
1030
|
+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
1031
|
+
*
|
|
1032
|
+
* Copyright 2015, 2016 Holger Seelig <holger.seelig@yahoo.de>.
|
|
1033
|
+
*
|
|
1034
|
+
* This file is part of the X_ITE Project.
|
|
1035
|
+
*
|
|
1036
|
+
* X_ITE is free software: you can redistribute it and/or modify it under the
|
|
1037
|
+
* terms of the GNU General Public License version 3 only, as published by the
|
|
1038
|
+
* Free Software Foundation.
|
|
1039
|
+
*
|
|
1040
|
+
* X_ITE is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
1041
|
+
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
|
1042
|
+
* A PARTICULAR PURPOSE. See the GNU General Public License version 3 for more
|
|
1043
|
+
* details (a copy is included in the LICENSE file that accompanied this code).
|
|
1044
|
+
*
|
|
1045
|
+
* You should have received a copy of the GNU General Public License version 3
|
|
1046
|
+
* along with X_ITE. If not, see <http://www.gnu.org/licenses/gpl.html> for a
|
|
1047
|
+
* copy of the GPLv3 License.
|
|
1048
|
+
*
|
|
1049
|
+
* For Silvio, Joy and Adi.
|
|
1050
|
+
*
|
|
1051
|
+
******************************************************************************/
|
|
1052
|
+
|
|
1053
|
+
|
|
1054
|
+
define ('x_ite/Components/ParticleSystems/ExplosionEmitter',[
|
|
1055
|
+
"x_ite/Fields",
|
|
1056
|
+
"x_ite/Basic/X3DFieldDefinition",
|
|
1057
|
+
"x_ite/Basic/FieldDefinitionArray",
|
|
1058
|
+
"x_ite/Components/ParticleSystems/X3DParticleEmitterNode",
|
|
1059
|
+
"x_ite/Bits/X3DConstants",
|
|
1060
|
+
],
|
|
1061
|
+
function (Fields,
|
|
1062
|
+
X3DFieldDefinition,
|
|
1063
|
+
FieldDefinitionArray,
|
|
1064
|
+
X3DParticleEmitterNode,
|
|
1065
|
+
X3DConstants)
|
|
1066
|
+
{
|
|
1067
|
+
"use strict";
|
|
1068
|
+
|
|
1069
|
+
function ExplosionEmitter (executionContext)
|
|
1070
|
+
{
|
|
1071
|
+
X3DParticleEmitterNode .call (this, executionContext);
|
|
1072
|
+
|
|
1073
|
+
this .addType (X3DConstants .ExplosionEmitter);
|
|
1074
|
+
|
|
1075
|
+
this .position_ .setUnit ("length");
|
|
1076
|
+
this .speed_ .setUnit ("speed");
|
|
1077
|
+
this .mass_ .setUnit ("mass");
|
|
1078
|
+
this .surfaceArea_ .setUnit ("area");
|
|
1079
|
+
|
|
1080
|
+
this .getRandomVelocity = this .getSphericalRandomVelocity;
|
|
1081
|
+
}
|
|
1082
|
+
|
|
1083
|
+
ExplosionEmitter .prototype = Object .assign (Object .create (X3DParticleEmitterNode .prototype),
|
|
1084
|
+
{
|
|
1085
|
+
constructor: ExplosionEmitter,
|
|
1086
|
+
fieldDefinitions: new FieldDefinitionArray ([
|
|
1087
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "metadata", new Fields .SFNode ()),
|
|
1088
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "position", new Fields .SFVec3f ()),
|
|
1089
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "speed", new Fields .SFFloat ()),
|
|
1090
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "variation", new Fields .SFFloat (0.25)),
|
|
1091
|
+
new X3DFieldDefinition (X3DConstants .initializeOnly, "mass", new Fields .SFFloat ()),
|
|
1092
|
+
new X3DFieldDefinition (X3DConstants .initializeOnly, "surfaceArea", new Fields .SFFloat ()),
|
|
1093
|
+
]),
|
|
1094
|
+
getTypeName: function ()
|
|
1095
|
+
{
|
|
1096
|
+
return "ExplosionEmitter";
|
|
1097
|
+
},
|
|
1098
|
+
getComponentName: function ()
|
|
1099
|
+
{
|
|
1100
|
+
return "ParticleSystems";
|
|
1101
|
+
},
|
|
1102
|
+
getContainerField: function ()
|
|
1103
|
+
{
|
|
1104
|
+
return "emitter";
|
|
1105
|
+
},
|
|
1106
|
+
initialize: function ()
|
|
1107
|
+
{
|
|
1108
|
+
X3DParticleEmitterNode .prototype .initialize .call (this);
|
|
1109
|
+
|
|
1110
|
+
this .position_ .addInterest ("set_position__", this);
|
|
1111
|
+
|
|
1112
|
+
this .set_position__ ();
|
|
1113
|
+
},
|
|
1114
|
+
set_position__: function ()
|
|
1115
|
+
{
|
|
1116
|
+
this .position = this .position_ .getValue ()
|
|
1117
|
+
},
|
|
1118
|
+
isExplosive: function ()
|
|
1119
|
+
{
|
|
1120
|
+
return true;
|
|
1121
|
+
},
|
|
1122
|
+
getRandomPosition: function (position)
|
|
1123
|
+
{
|
|
1124
|
+
return position .assign (this .position);
|
|
1125
|
+
},
|
|
1126
|
+
});
|
|
1127
|
+
|
|
1128
|
+
return ExplosionEmitter;
|
|
1129
|
+
});
|
|
1130
|
+
|
|
1131
|
+
|
|
1132
|
+
|
|
1133
|
+
/* -*- Mode: JavaScript; coding: utf-8; tab-width: 3; indent-tabs-mode: tab; c-basic-offset: 3 -*-
|
|
1134
|
+
*******************************************************************************
|
|
1135
|
+
*
|
|
1136
|
+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
1137
|
+
*
|
|
1138
|
+
* Copyright create3000, Scheffelstraße 31a, Leipzig, Germany 2011.
|
|
1139
|
+
*
|
|
1140
|
+
* All rights reserved. Holger Seelig <holger.seelig@yahoo.de>.
|
|
1141
|
+
*
|
|
1142
|
+
* The copyright notice above does not evidence any actual of intended
|
|
1143
|
+
* publication of such source code, and is an unpublished work by create3000.
|
|
1144
|
+
* This material contains CONFIDENTIAL INFORMATION that is the property of
|
|
1145
|
+
* create3000.
|
|
1146
|
+
*
|
|
1147
|
+
* No permission is granted to copy, distribute, or create derivative works from
|
|
1148
|
+
* the contents of this software, in whole or in part, without the prior written
|
|
1149
|
+
* permission of create3000.
|
|
1150
|
+
*
|
|
1151
|
+
* NON-MILITARY USE ONLY
|
|
1152
|
+
*
|
|
1153
|
+
* All create3000 software are effectively free software with a non-military use
|
|
1154
|
+
* restriction. It is free. Well commented source is provided. You may reuse the
|
|
1155
|
+
* source in any way you please with the exception anything that uses it must be
|
|
1156
|
+
* marked to indicate is contains 'non-military use only' components.
|
|
1157
|
+
*
|
|
1158
|
+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
1159
|
+
*
|
|
1160
|
+
* Copyright 2015, 2016 Holger Seelig <holger.seelig@yahoo.de>.
|
|
1161
|
+
*
|
|
1162
|
+
* This file is part of the X_ITE Project.
|
|
1163
|
+
*
|
|
1164
|
+
* X_ITE is free software: you can redistribute it and/or modify it under the
|
|
1165
|
+
* terms of the GNU General Public License version 3 only, as published by the
|
|
1166
|
+
* Free Software Foundation.
|
|
1167
|
+
*
|
|
1168
|
+
* X_ITE is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
1169
|
+
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
|
1170
|
+
* A PARTICULAR PURPOSE. See the GNU General Public License version 3 for more
|
|
1171
|
+
* details (a copy is included in the LICENSE file that accompanied this code).
|
|
1172
|
+
*
|
|
1173
|
+
* You should have received a copy of the GNU General Public License version 3
|
|
1174
|
+
* along with X_ITE. If not, see <http://www.gnu.org/licenses/gpl.html> for a
|
|
1175
|
+
* copy of the GPLv3 License.
|
|
1176
|
+
*
|
|
1177
|
+
* For Silvio, Joy and Adi.
|
|
1178
|
+
*
|
|
1179
|
+
******************************************************************************/
|
|
1180
|
+
|
|
1181
|
+
|
|
1182
|
+
define ('x_ite/Components/ParticleSystems/ForcePhysicsModel',[
|
|
1183
|
+
"x_ite/Fields",
|
|
1184
|
+
"x_ite/Basic/X3DFieldDefinition",
|
|
1185
|
+
"x_ite/Basic/FieldDefinitionArray",
|
|
1186
|
+
"x_ite/Components/ParticleSystems/X3DParticlePhysicsModelNode",
|
|
1187
|
+
"x_ite/Bits/X3DConstants",
|
|
1188
|
+
],
|
|
1189
|
+
function (Fields,
|
|
1190
|
+
X3DFieldDefinition,
|
|
1191
|
+
FieldDefinitionArray,
|
|
1192
|
+
X3DParticlePhysicsModelNode,
|
|
1193
|
+
X3DConstants)
|
|
1194
|
+
{
|
|
1195
|
+
"use strict";
|
|
1196
|
+
|
|
1197
|
+
function ForcePhysicsModel (executionContext)
|
|
1198
|
+
{
|
|
1199
|
+
X3DParticlePhysicsModelNode .call (this, executionContext);
|
|
1200
|
+
|
|
1201
|
+
this .addType (X3DConstants .ForcePhysicsModel);
|
|
1202
|
+
|
|
1203
|
+
this .force_ .setUnit ("force");
|
|
1204
|
+
}
|
|
1205
|
+
|
|
1206
|
+
ForcePhysicsModel .prototype = Object .assign (Object .create (X3DParticlePhysicsModelNode .prototype),
|
|
1207
|
+
{
|
|
1208
|
+
constructor: ForcePhysicsModel,
|
|
1209
|
+
fieldDefinitions: new FieldDefinitionArray ([
|
|
1210
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "metadata", new Fields .SFNode ()),
|
|
1211
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "enabled", new Fields .SFBool (true)),
|
|
1212
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "force", new Fields .SFVec3f (0, -9.8, 0)),
|
|
1213
|
+
]),
|
|
1214
|
+
getTypeName: function ()
|
|
1215
|
+
{
|
|
1216
|
+
return "ForcePhysicsModel";
|
|
1217
|
+
},
|
|
1218
|
+
getComponentName: function ()
|
|
1219
|
+
{
|
|
1220
|
+
return "ParticleSystems";
|
|
1221
|
+
},
|
|
1222
|
+
getContainerField: function ()
|
|
1223
|
+
{
|
|
1224
|
+
return "physics";
|
|
1225
|
+
},
|
|
1226
|
+
addForce: function (i, emitterNode, forces, turbulences)
|
|
1227
|
+
{
|
|
1228
|
+
if (this .enabled_ .getValue ())
|
|
1229
|
+
{
|
|
1230
|
+
forces [i] .assign (this .force_ .getValue ());
|
|
1231
|
+
turbulences [i] = 0;
|
|
1232
|
+
}
|
|
1233
|
+
},
|
|
1234
|
+
});
|
|
1235
|
+
|
|
1236
|
+
return ForcePhysicsModel;
|
|
1237
|
+
});
|
|
1238
|
+
|
|
1239
|
+
|
|
1240
|
+
|
|
1241
|
+
/* -*- Mode: JavaScript; coding: utf-8; tab-width: 3; indent-tabs-mode: tab; c-basic-offset: 3 -*-
|
|
1242
|
+
*******************************************************************************
|
|
1243
|
+
*
|
|
1244
|
+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
1245
|
+
*
|
|
1246
|
+
* Copyright create3000, Scheffelstraße 31a, Leipzig, Germany 2011.
|
|
1247
|
+
*
|
|
1248
|
+
* All rights reserved. Holger Seelig <holger.seelig@yahoo.de>.
|
|
1249
|
+
*
|
|
1250
|
+
* The copyright notice above does not evidence any actual of intended
|
|
1251
|
+
* publication of such source code, and is an unpublished work by create3000.
|
|
1252
|
+
* This material contains CONFIDENTIAL INFORMATION that is the property of
|
|
1253
|
+
* create3000.
|
|
1254
|
+
*
|
|
1255
|
+
* No permission is granted to copy, distribute, or create derivative works from
|
|
1256
|
+
* the contents of this software, in whole or in part, without the prior written
|
|
1257
|
+
* permission of create3000.
|
|
1258
|
+
*
|
|
1259
|
+
* NON-MILITARY USE ONLY
|
|
1260
|
+
*
|
|
1261
|
+
* All create3000 software are effectively free software with a non-military use
|
|
1262
|
+
* restriction. It is free. Well commented source is provided. You may reuse the
|
|
1263
|
+
* source in any way you please with the exception anything that uses it must be
|
|
1264
|
+
* marked to indicate is contains 'non-military use only' components.
|
|
1265
|
+
*
|
|
1266
|
+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
1267
|
+
*
|
|
1268
|
+
* Copyright 2015, 2016 Holger Seelig <holger.seelig@yahoo.de>.
|
|
1269
|
+
*
|
|
1270
|
+
* This file is part of the X_ITE Project.
|
|
1271
|
+
*
|
|
1272
|
+
* X_ITE is free software: you can redistribute it and/or modify it under the
|
|
1273
|
+
* terms of the GNU General Public License version 3 only, as published by the
|
|
1274
|
+
* Free Software Foundation.
|
|
1275
|
+
*
|
|
1276
|
+
* X_ITE is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
1277
|
+
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
|
1278
|
+
* A PARTICULAR PURPOSE. See the GNU General Public License version 3 for more
|
|
1279
|
+
* details (a copy is included in the LICENSE file that accompanied this code).
|
|
1280
|
+
*
|
|
1281
|
+
* You should have received a copy of the GNU General Public License version 3
|
|
1282
|
+
* along with X_ITE. If not, see <http://www.gnu.org/licenses/gpl.html> for a
|
|
1283
|
+
* copy of the GPLv3 License.
|
|
1284
|
+
*
|
|
1285
|
+
* For Silvio, Joy and Adi.
|
|
1286
|
+
*
|
|
1287
|
+
******************************************************************************/
|
|
1288
|
+
|
|
1289
|
+
|
|
1290
|
+
define ('standard/Math/Utility/BVH',[
|
|
1291
|
+
"standard/Math/Numbers/Vector3",
|
|
1292
|
+
"standard/Math/Geometry/Plane3",
|
|
1293
|
+
"standard/Math/Algorithms/QuickSort",
|
|
1294
|
+
],
|
|
1295
|
+
function (Vector3,
|
|
1296
|
+
Plane3,
|
|
1297
|
+
QuickSort)
|
|
1298
|
+
{
|
|
1299
|
+
"use strict";
|
|
1300
|
+
|
|
1301
|
+
const
|
|
1302
|
+
v0 = new Vector3 (0, 0, 0),
|
|
1303
|
+
v1 = new Vector3 (0, 0, 0),
|
|
1304
|
+
v2 = new Vector3 (0, 0, 0),
|
|
1305
|
+
uvt = { u: 0, v: 0, t: 0 };
|
|
1306
|
+
|
|
1307
|
+
// Box normals for bbox / line intersection.
|
|
1308
|
+
const boxNormals = [
|
|
1309
|
+
new Vector3 (0, 0, 1), // front
|
|
1310
|
+
new Vector3 (0, 0, -1), // back
|
|
1311
|
+
new Vector3 (0, 1, 0), // top
|
|
1312
|
+
new Vector3 (0, -1, 0), // bottom
|
|
1313
|
+
new Vector3 (1, 0, 0) // right
|
|
1314
|
+
// left: We do not have to test for left.
|
|
1315
|
+
];
|
|
1316
|
+
|
|
1317
|
+
function SortComparator (vertices, axis)
|
|
1318
|
+
{
|
|
1319
|
+
function compare (a, b)
|
|
1320
|
+
{
|
|
1321
|
+
const
|
|
1322
|
+
vertices = compare .vertices;
|
|
1323
|
+
axis = compare .axis;
|
|
1324
|
+
|
|
1325
|
+
return Math .min (vertices [a + axis], vertices [a + 4 + axis], vertices [a + 8 + axis]) <
|
|
1326
|
+
Math .min (vertices [b + axis], vertices [b + 4 + axis], vertices [b + 8 + axis]);
|
|
1327
|
+
}
|
|
1328
|
+
|
|
1329
|
+
compare .vertices = vertices;
|
|
1330
|
+
compare .axis = axis;
|
|
1331
|
+
|
|
1332
|
+
return compare;
|
|
1333
|
+
}
|
|
1334
|
+
|
|
1335
|
+
function Triangle (tree, triangle)
|
|
1336
|
+
{
|
|
1337
|
+
this .vertices = tree .vertices;
|
|
1338
|
+
this .normals = tree .normals;
|
|
1339
|
+
this .i4 = triangle * 12;
|
|
1340
|
+
this .i3 = triangle * 9;
|
|
1341
|
+
}
|
|
1342
|
+
|
|
1343
|
+
Triangle .prototype =
|
|
1344
|
+
{
|
|
1345
|
+
intersectsLine: function (line, intersections, intersectionNormals)
|
|
1346
|
+
{
|
|
1347
|
+
const
|
|
1348
|
+
vertices = this .vertices,
|
|
1349
|
+
normals = this .normals,
|
|
1350
|
+
i4 = this .i4,
|
|
1351
|
+
i3 = this .i3;
|
|
1352
|
+
|
|
1353
|
+
v0 .x = vertices [i4]; v0 .y = vertices [i4 + 1]; v0 .z = vertices [i4 + 2];
|
|
1354
|
+
v1 .x = vertices [i4 + 4]; v1 .y = vertices [i4 + 5]; v1 .z = vertices [i4 + 6];
|
|
1355
|
+
v2 .x = vertices [i4 + 8]; v2 .y = vertices [i4 + 9]; v2 .z = vertices [i4 + 10];
|
|
1356
|
+
|
|
1357
|
+
if (line .intersectsTriangle (v0, v1, v2, uvt))
|
|
1358
|
+
{
|
|
1359
|
+
// Get barycentric coordinates.
|
|
1360
|
+
|
|
1361
|
+
const
|
|
1362
|
+
u = uvt .u,
|
|
1363
|
+
v = uvt .v,
|
|
1364
|
+
t = 1 - u - v;
|
|
1365
|
+
|
|
1366
|
+
// Determine vectors for X3DPointingDeviceSensors.
|
|
1367
|
+
|
|
1368
|
+
const i = intersections .size ++;
|
|
1369
|
+
|
|
1370
|
+
if (i >= intersections .length)
|
|
1371
|
+
intersections .push (new Vector3 (0, 0, 0));
|
|
1372
|
+
|
|
1373
|
+
intersections [i] .set (t * vertices [i4] + u * vertices [i4 + 4] + v * vertices [i4 + 8],
|
|
1374
|
+
t * vertices [i4 + 1] + u * vertices [i4 + 5] + v * vertices [i4 + 9],
|
|
1375
|
+
t * vertices [i4 + 2] + u * vertices [i4 + 6] + v * vertices [i4 + 10]);
|
|
1376
|
+
|
|
1377
|
+
if (intersectionNormals)
|
|
1378
|
+
{
|
|
1379
|
+
if (i >= intersectionNormals .length)
|
|
1380
|
+
intersectionNormals .push (new Vector3 (0, 0, 0));
|
|
1381
|
+
|
|
1382
|
+
intersectionNormals [i] .set (t * normals [i3] + u * normals [i3 + 3] + v * normals [i3 + 6],
|
|
1383
|
+
t * normals [i3 + 1] + u * normals [i3 + 4] + v * normals [i3 + 7],
|
|
1384
|
+
t * normals [i3 + 2] + u * normals [i3 + 5] + v * normals [i3 + 8]);
|
|
1385
|
+
}
|
|
1386
|
+
}
|
|
1387
|
+
},
|
|
1388
|
+
};
|
|
1389
|
+
|
|
1390
|
+
function Node (tree, triangles, first, size)
|
|
1391
|
+
{
|
|
1392
|
+
this .min = new Vector3 (0, 0, 0);
|
|
1393
|
+
this .max = new Vector3 (0, 0, 0);
|
|
1394
|
+
this .planes = [ ];
|
|
1395
|
+
this .intersection = new Vector3 (0, 0, 0);
|
|
1396
|
+
|
|
1397
|
+
const
|
|
1398
|
+
vertices = tree .vertices,
|
|
1399
|
+
min = this .min,
|
|
1400
|
+
max = this .max,
|
|
1401
|
+
last = first + size;
|
|
1402
|
+
|
|
1403
|
+
let t = triangles [first] * 12;
|
|
1404
|
+
|
|
1405
|
+
// Calculate bbox
|
|
1406
|
+
|
|
1407
|
+
min .set (vertices [t], vertices [t + 1], vertices [t + 2]);
|
|
1408
|
+
max .assign (min);
|
|
1409
|
+
|
|
1410
|
+
for (let i = first; i < last; ++ i)
|
|
1411
|
+
{
|
|
1412
|
+
t = triangles [i] * 12;
|
|
1413
|
+
|
|
1414
|
+
v0 .set (vertices [t], vertices [t + 1], vertices [t + 2]);
|
|
1415
|
+
v1 .set (vertices [t + 4], vertices [t + 5], vertices [t + 6]);
|
|
1416
|
+
v2 .set (vertices [t + 8], vertices [t + 9], vertices [t + 10]);
|
|
1417
|
+
|
|
1418
|
+
min .min (v0, v1, v2);
|
|
1419
|
+
max .max (v0, v1, v2);
|
|
1420
|
+
}
|
|
1421
|
+
|
|
1422
|
+
for (let i = 0; i < 5; ++ i)
|
|
1423
|
+
this .planes [i] = new Plane3 (i % 2 ? min : max, boxNormals [i]);
|
|
1424
|
+
|
|
1425
|
+
// Sort and split array
|
|
1426
|
+
|
|
1427
|
+
if (size > 2)
|
|
1428
|
+
{
|
|
1429
|
+
// Sort array
|
|
1430
|
+
|
|
1431
|
+
tree .sorter .compare .axis = this .getLongestAxis (min, max);
|
|
1432
|
+
tree .sorter .sort (first, last);
|
|
1433
|
+
|
|
1434
|
+
// Split array
|
|
1435
|
+
|
|
1436
|
+
var leftSize = size >>> 1;
|
|
1437
|
+
}
|
|
1438
|
+
else
|
|
1439
|
+
var leftSize = 1;
|
|
1440
|
+
|
|
1441
|
+
// Split array
|
|
1442
|
+
|
|
1443
|
+
const rightSize = size - leftSize;
|
|
1444
|
+
|
|
1445
|
+
// Construct left and right node
|
|
1446
|
+
|
|
1447
|
+
if (leftSize > 1)
|
|
1448
|
+
this .left = new Node (tree, triangles, first, leftSize);
|
|
1449
|
+
else
|
|
1450
|
+
this .left = new Triangle (tree, triangles [first]);
|
|
1451
|
+
|
|
1452
|
+
if (rightSize > 1)
|
|
1453
|
+
this .right = new Node (tree, triangles, first + leftSize, rightSize);
|
|
1454
|
+
else
|
|
1455
|
+
this .right = new Triangle (tree, triangles [first + leftSize]);
|
|
1456
|
+
}
|
|
1457
|
+
|
|
1458
|
+
Node .prototype =
|
|
1459
|
+
{
|
|
1460
|
+
intersectsLine: function (line, intersections, intersectionNormals)
|
|
1461
|
+
{
|
|
1462
|
+
if (this .intersectsBBox (line))
|
|
1463
|
+
{
|
|
1464
|
+
this .left .intersectsLine (line, intersections, intersectionNormals);
|
|
1465
|
+
this .right .intersectsLine (line, intersections, intersectionNormals);
|
|
1466
|
+
}
|
|
1467
|
+
},
|
|
1468
|
+
intersectsBBox: function (line)
|
|
1469
|
+
{
|
|
1470
|
+
const
|
|
1471
|
+
planes = this .planes,
|
|
1472
|
+
min = this .min,
|
|
1473
|
+
max = this .max,
|
|
1474
|
+
minX = min .x,
|
|
1475
|
+
maxX = max .x,
|
|
1476
|
+
minY = min .y,
|
|
1477
|
+
maxY = max .y,
|
|
1478
|
+
minZ = min .z,
|
|
1479
|
+
maxZ = max .z,
|
|
1480
|
+
intersection = this .intersection;
|
|
1481
|
+
|
|
1482
|
+
// front
|
|
1483
|
+
if (planes [0] .intersectsLine (line, intersection))
|
|
1484
|
+
{
|
|
1485
|
+
if (intersection .x >= minX && intersection .x <= maxX &&
|
|
1486
|
+
intersection .y >= minY && intersection .y <= maxY)
|
|
1487
|
+
return true;
|
|
1488
|
+
}
|
|
1489
|
+
|
|
1490
|
+
// back
|
|
1491
|
+
if (planes [1] .intersectsLine (line, intersection))
|
|
1492
|
+
{
|
|
1493
|
+
if (intersection .x >= minX && intersection .x <= maxX &&
|
|
1494
|
+
intersection .y >= minY && intersection .y <= maxY)
|
|
1495
|
+
return true;
|
|
1496
|
+
}
|
|
1497
|
+
|
|
1498
|
+
// top
|
|
1499
|
+
if (planes [2] .intersectsLine (line, intersection))
|
|
1500
|
+
{
|
|
1501
|
+
if (intersection .x >= minX && intersection .x <= maxX &&
|
|
1502
|
+
intersection .z >= minZ && intersection .z <= maxZ)
|
|
1503
|
+
return true;
|
|
1504
|
+
}
|
|
1505
|
+
|
|
1506
|
+
// bottom
|
|
1507
|
+
if (planes [3] .intersectsLine (line, intersection))
|
|
1508
|
+
{
|
|
1509
|
+
if (intersection .x >= minX && intersection .x <= maxX &&
|
|
1510
|
+
intersection .z >= minZ && intersection .z <= maxZ)
|
|
1511
|
+
return true;
|
|
1512
|
+
}
|
|
1513
|
+
|
|
1514
|
+
// right
|
|
1515
|
+
if (planes [4] .intersectsLine (line, intersection))
|
|
1516
|
+
{
|
|
1517
|
+
if (intersection .y >= minY && intersection .y <= maxY &&
|
|
1518
|
+
intersection .z >= minZ && intersection .z <= maxZ)
|
|
1519
|
+
return true;
|
|
1520
|
+
}
|
|
1521
|
+
|
|
1522
|
+
return false;
|
|
1523
|
+
},
|
|
1524
|
+
getLongestAxis: function (min, max)
|
|
1525
|
+
{
|
|
1526
|
+
const
|
|
1527
|
+
x = max .x - min .x,
|
|
1528
|
+
y = max .y - min .y,
|
|
1529
|
+
z = max .z - min .z;
|
|
1530
|
+
|
|
1531
|
+
if (x < y)
|
|
1532
|
+
{
|
|
1533
|
+
if (y < z)
|
|
1534
|
+
return 2;
|
|
1535
|
+
|
|
1536
|
+
return 1;
|
|
1537
|
+
}
|
|
1538
|
+
else
|
|
1539
|
+
{
|
|
1540
|
+
if (x < z)
|
|
1541
|
+
return 2;
|
|
1542
|
+
|
|
1543
|
+
return 0;
|
|
1544
|
+
}
|
|
1545
|
+
},
|
|
1546
|
+
};
|
|
1547
|
+
|
|
1548
|
+
function BVH (vertices, normals)
|
|
1549
|
+
{
|
|
1550
|
+
this .vertices = vertices;
|
|
1551
|
+
this .normals = normals;
|
|
1552
|
+
|
|
1553
|
+
const numTriangles = vertices .length / 12;
|
|
1554
|
+
|
|
1555
|
+
switch (numTriangles)
|
|
1556
|
+
{
|
|
1557
|
+
case 0:
|
|
1558
|
+
{
|
|
1559
|
+
this .root = null;
|
|
1560
|
+
break;
|
|
1561
|
+
}
|
|
1562
|
+
case 1:
|
|
1563
|
+
{
|
|
1564
|
+
this .root = new Triangle (this, 0);
|
|
1565
|
+
break;
|
|
1566
|
+
}
|
|
1567
|
+
default:
|
|
1568
|
+
{
|
|
1569
|
+
const triangles = [ ];
|
|
1570
|
+
|
|
1571
|
+
for (let i = 0; i < numTriangles; ++ i)
|
|
1572
|
+
triangles .push (i);
|
|
1573
|
+
|
|
1574
|
+
this .sorter = new QuickSort (triangles, SortComparator (vertices, 0));
|
|
1575
|
+
|
|
1576
|
+
this .root = new Node (this, triangles, 0, numTriangles);
|
|
1577
|
+
break;
|
|
1578
|
+
}
|
|
1579
|
+
}
|
|
1580
|
+
}
|
|
1581
|
+
|
|
1582
|
+
BVH .prototype =
|
|
1583
|
+
{
|
|
1584
|
+
constructor: BVH,
|
|
1585
|
+
|
|
1586
|
+
intersectsLine: function (line, intersections, intersectionNormals)
|
|
1587
|
+
{
|
|
1588
|
+
intersections .size = 0;
|
|
1589
|
+
|
|
1590
|
+
if (this .root)
|
|
1591
|
+
{
|
|
1592
|
+
this .root .intersectsLine (line, intersections, intersectionNormals);
|
|
1593
|
+
return intersections .size;
|
|
1594
|
+
}
|
|
1595
|
+
|
|
1596
|
+
return 0;
|
|
1597
|
+
},
|
|
1598
|
+
};
|
|
1599
|
+
|
|
1600
|
+
return BVH;
|
|
1601
|
+
});
|
|
1602
|
+
|
|
1603
|
+
/* -*- Mode: JavaScript; coding: utf-8; tab-width: 3; indent-tabs-mode: tab; c-basic-offset: 3 -*-
|
|
1604
|
+
*******************************************************************************
|
|
1605
|
+
*
|
|
1606
|
+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
1607
|
+
*
|
|
1608
|
+
* Copyright create3000, Scheffelstraße 31a, Leipzig, Germany 2011.
|
|
1609
|
+
*
|
|
1610
|
+
* All rights reserved. Holger Seelig <holger.seelig@yahoo.de>.
|
|
1611
|
+
*
|
|
1612
|
+
* The copyright notice above does not evidence any actual of intended
|
|
1613
|
+
* publication of such source code, and is an unpublished work by create3000.
|
|
1614
|
+
* This material contains CONFIDENTIAL INFORMATION that is the property of
|
|
1615
|
+
* create3000.
|
|
1616
|
+
*
|
|
1617
|
+
* No permission is granted to copy, distribute, or create derivative works from
|
|
1618
|
+
* the contents of this software, in whole or in part, without the prior written
|
|
1619
|
+
* permission of create3000.
|
|
1620
|
+
*
|
|
1621
|
+
* NON-MILITARY USE ONLY
|
|
1622
|
+
*
|
|
1623
|
+
* All create3000 software are effectively free software with a non-military use
|
|
1624
|
+
* restriction. It is free. Well commented source is provided. You may reuse the
|
|
1625
|
+
* source in any way you please with the exception anything that uses it must be
|
|
1626
|
+
* marked to indicate is contains 'non-military use only' components.
|
|
1627
|
+
*
|
|
1628
|
+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
1629
|
+
*
|
|
1630
|
+
* Copyright 2015, 2016 Holger Seelig <holger.seelig@yahoo.de>.
|
|
1631
|
+
*
|
|
1632
|
+
* This file is part of the X_ITE Project.
|
|
1633
|
+
*
|
|
1634
|
+
* X_ITE is free software: you can redistribute it and/or modify it under the
|
|
1635
|
+
* terms of the GNU General Public License version 3 only, as published by the
|
|
1636
|
+
* Free Software Foundation.
|
|
1637
|
+
*
|
|
1638
|
+
* X_ITE is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
1639
|
+
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
|
1640
|
+
* A PARTICULAR PURPOSE. See the GNU General Public License version 3 for more
|
|
1641
|
+
* details (a copy is included in the LICENSE file that accompanied this code).
|
|
1642
|
+
*
|
|
1643
|
+
* You should have received a copy of the GNU General Public License version 3
|
|
1644
|
+
* along with X_ITE. If not, see <http://www.gnu.org/licenses/gpl.html> for a
|
|
1645
|
+
* copy of the GPLv3 License.
|
|
1646
|
+
*
|
|
1647
|
+
* For Silvio, Joy and Adi.
|
|
1648
|
+
*
|
|
1649
|
+
******************************************************************************/
|
|
1650
|
+
|
|
1651
|
+
|
|
1652
|
+
define ('x_ite/Components/ParticleSystems/ParticleSystem',[
|
|
1653
|
+
"x_ite/Fields",
|
|
1654
|
+
"x_ite/Basic/X3DFieldDefinition",
|
|
1655
|
+
"x_ite/Basic/FieldDefinitionArray",
|
|
1656
|
+
"x_ite/Components/Shape/X3DShapeNode",
|
|
1657
|
+
"x_ite/Bits/TraverseType",
|
|
1658
|
+
"x_ite/Bits/X3DConstants",
|
|
1659
|
+
"x_ite/Bits/X3DCast",
|
|
1660
|
+
"x_ite/Browser/Shape/AlphaMode",
|
|
1661
|
+
"standard/Math/Numbers/Vector3",
|
|
1662
|
+
"standard/Math/Numbers/Vector4",
|
|
1663
|
+
"standard/Math/Numbers/Matrix4",
|
|
1664
|
+
"standard/Math/Numbers/Matrix3",
|
|
1665
|
+
"standard/Math/Algorithms/QuickSort",
|
|
1666
|
+
"standard/Math/Algorithm",
|
|
1667
|
+
"standard/Math/Utility/BVH",
|
|
1668
|
+
],
|
|
1669
|
+
function (Fields,
|
|
1670
|
+
X3DFieldDefinition,
|
|
1671
|
+
FieldDefinitionArray,
|
|
1672
|
+
X3DShapeNode,
|
|
1673
|
+
TraverseType,
|
|
1674
|
+
X3DConstants,
|
|
1675
|
+
X3DCast,
|
|
1676
|
+
AlphaMode,
|
|
1677
|
+
Vector3,
|
|
1678
|
+
Vector4,
|
|
1679
|
+
Matrix4,
|
|
1680
|
+
Matrix3,
|
|
1681
|
+
QuickSort,
|
|
1682
|
+
Algorithm,
|
|
1683
|
+
BVH)
|
|
1684
|
+
{
|
|
1685
|
+
"use strict";
|
|
1686
|
+
|
|
1687
|
+
var i = 0;
|
|
1688
|
+
|
|
1689
|
+
const
|
|
1690
|
+
POINT = i ++,
|
|
1691
|
+
LINE = i ++,
|
|
1692
|
+
TRIANGLE = i ++,
|
|
1693
|
+
QUAD = i ++,
|
|
1694
|
+
GEOMETRY = i ++,
|
|
1695
|
+
SPRITE = i ++;
|
|
1696
|
+
|
|
1697
|
+
const GeometryTypes = {
|
|
1698
|
+
POINT: POINT,
|
|
1699
|
+
LINE: LINE,
|
|
1700
|
+
TRIANGLE: TRIANGLE,
|
|
1701
|
+
QUAD: QUAD,
|
|
1702
|
+
GEOMETRY: GEOMETRY,
|
|
1703
|
+
SPRITE: SPRITE,
|
|
1704
|
+
};
|
|
1705
|
+
|
|
1706
|
+
const
|
|
1707
|
+
invModelViewMatrix = new Matrix4 (),
|
|
1708
|
+
billboardToScreen = new Vector3 (0, 0, 0),
|
|
1709
|
+
viewerYAxis = new Vector3 (0, 0, 0),
|
|
1710
|
+
vector = new Vector3 (0, 0, 0),
|
|
1711
|
+
normal = new Vector3 (0, 0, 0),
|
|
1712
|
+
s1 = new Vector3 (0, 0, 0),
|
|
1713
|
+
s2 = new Vector3 (0, 0, 0),
|
|
1714
|
+
s3 = new Vector3 (0, 0, 0),
|
|
1715
|
+
s4 = new Vector3 (0, 0, 0),
|
|
1716
|
+
x = new Vector3 (0, 0, 0),
|
|
1717
|
+
y = new Vector3 (0, 0, 0);
|
|
1718
|
+
|
|
1719
|
+
function compareDistance (lhs, rhs) { return lhs .distance < rhs .distance; }
|
|
1720
|
+
|
|
1721
|
+
function ParticleSystem (executionContext)
|
|
1722
|
+
{
|
|
1723
|
+
X3DShapeNode .call (this, executionContext);
|
|
1724
|
+
|
|
1725
|
+
this .addType (X3DConstants .ParticleSystem);
|
|
1726
|
+
|
|
1727
|
+
this .particleSize_ .setUnit ("length");
|
|
1728
|
+
|
|
1729
|
+
this .createParticles = true;
|
|
1730
|
+
this .particles = [ ];
|
|
1731
|
+
this .velocities = [ ];
|
|
1732
|
+
this .speeds = [ ];
|
|
1733
|
+
this .turbulences = [ ];
|
|
1734
|
+
this .geometryType = POINT;
|
|
1735
|
+
this .maxParticles = 0;
|
|
1736
|
+
this .numParticles = 0;
|
|
1737
|
+
this .particleLifetime = 0;
|
|
1738
|
+
this .lifetimeVariation = 0;
|
|
1739
|
+
this .emitterNode = null;
|
|
1740
|
+
this .forcePhysicsModelNodes = [ ];
|
|
1741
|
+
this .boundedPhysicsModelNodes = [ ];
|
|
1742
|
+
this .boundedNormals = [ ];
|
|
1743
|
+
this .boundedVertices = [ ];
|
|
1744
|
+
this .boundedVolume = null;
|
|
1745
|
+
this .creationTime = 0;
|
|
1746
|
+
this .pauseTime = 0;
|
|
1747
|
+
this .deltaTime = 0;
|
|
1748
|
+
this .numForces = 0;
|
|
1749
|
+
this .colorKeys = [ ];
|
|
1750
|
+
this .colorRamppNode = null;
|
|
1751
|
+
this .colorRamp = [ ];
|
|
1752
|
+
this .texCoordKeys = [ ];
|
|
1753
|
+
this .texCoordRampNode = null;
|
|
1754
|
+
this .texCoordRamp = [ ];
|
|
1755
|
+
this .texCoordAnim = false;
|
|
1756
|
+
this .vertexCount = 0;
|
|
1757
|
+
this .shaderNode = null;
|
|
1758
|
+
this .rotation = new Matrix3 ();
|
|
1759
|
+
this .particleSorter = new QuickSort (this .particles, compareDistance);
|
|
1760
|
+
this .sortParticles = false;
|
|
1761
|
+
this .geometryContext = { };
|
|
1762
|
+
}
|
|
1763
|
+
|
|
1764
|
+
ParticleSystem .prototype = Object .assign (Object .create (X3DShapeNode .prototype),
|
|
1765
|
+
{
|
|
1766
|
+
constructor: ParticleSystem,
|
|
1767
|
+
fieldDefinitions: new FieldDefinitionArray ([
|
|
1768
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "metadata", new Fields .SFNode ()),
|
|
1769
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "enabled", new Fields .SFBool (true)),
|
|
1770
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "createParticles", new Fields .SFBool (true)),
|
|
1771
|
+
new X3DFieldDefinition (X3DConstants .initializeOnly, "geometryType", new Fields .SFString ("QUAD")),
|
|
1772
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "maxParticles", new Fields .SFInt32 (200)),
|
|
1773
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "particleLifetime", new Fields .SFFloat (5)),
|
|
1774
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "lifetimeVariation", new Fields .SFFloat (0.25)),
|
|
1775
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "particleSize", new Fields .SFVec2f (0.02, 0.02)),
|
|
1776
|
+
new X3DFieldDefinition (X3DConstants .initializeOnly, "emitter", new Fields .SFNode ()),
|
|
1777
|
+
new X3DFieldDefinition (X3DConstants .initializeOnly, "physics", new Fields .MFNode ()),
|
|
1778
|
+
new X3DFieldDefinition (X3DConstants .initializeOnly, "colorKey", new Fields .MFFloat ()),
|
|
1779
|
+
new X3DFieldDefinition (X3DConstants .initializeOnly, "colorRamp", new Fields .SFNode ()),
|
|
1780
|
+
new X3DFieldDefinition (X3DConstants .initializeOnly, "texCoordKey", new Fields .MFFloat ()),
|
|
1781
|
+
new X3DFieldDefinition (X3DConstants .initializeOnly, "texCoordRamp", new Fields .SFNode ()),
|
|
1782
|
+
new X3DFieldDefinition (X3DConstants .outputOnly, "isActive", new Fields .SFBool ()),
|
|
1783
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "visible", new Fields .SFBool (true)),
|
|
1784
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "castShadow", new Fields .SFBool (true)),
|
|
1785
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "bboxDisplay", new Fields .SFBool ()),
|
|
1786
|
+
new X3DFieldDefinition (X3DConstants .initializeOnly, "bboxSize", new Fields .SFVec3f (-1, -1, -1)),
|
|
1787
|
+
new X3DFieldDefinition (X3DConstants .initializeOnly, "bboxCenter", new Fields .SFVec3f ()),
|
|
1788
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "appearance", new Fields .SFNode ()),
|
|
1789
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "geometry", new Fields .SFNode ()),
|
|
1790
|
+
]),
|
|
1791
|
+
getTypeName: function ()
|
|
1792
|
+
{
|
|
1793
|
+
return "ParticleSystem";
|
|
1794
|
+
},
|
|
1795
|
+
getComponentName: function ()
|
|
1796
|
+
{
|
|
1797
|
+
return "ParticleSystems";
|
|
1798
|
+
},
|
|
1799
|
+
getContainerField: function ()
|
|
1800
|
+
{
|
|
1801
|
+
return "children";
|
|
1802
|
+
},
|
|
1803
|
+
initialize: function ()
|
|
1804
|
+
{
|
|
1805
|
+
X3DShapeNode .prototype .initialize .call (this);
|
|
1806
|
+
|
|
1807
|
+
const
|
|
1808
|
+
browser = this .getBrowser (),
|
|
1809
|
+
gl = browser .getContext ();
|
|
1810
|
+
|
|
1811
|
+
this .isLive () .addInterest ("set_live__", this);
|
|
1812
|
+
|
|
1813
|
+
browser .getBrowserOptions () .Shading_ .addInterest ("set_shader__", this);
|
|
1814
|
+
|
|
1815
|
+
this .enabled_ .addInterest ("set_enabled__", this);
|
|
1816
|
+
this .createParticles_ .addInterest ("set_createParticles__", this);
|
|
1817
|
+
this .geometryType_ .addInterest ("set_geometryType__", this);
|
|
1818
|
+
this .maxParticles_ .addInterest ("set_enabled__", this);
|
|
1819
|
+
this .particleLifetime_ .addInterest ("set_particleLifetime__", this);
|
|
1820
|
+
this .lifetimeVariation_ .addInterest ("set_lifetimeVariation__", this);
|
|
1821
|
+
this .emitter_ .addInterest ("set_emitter__", this);
|
|
1822
|
+
this .physics_ .addInterest ("set_physics__", this);
|
|
1823
|
+
this .colorKey_ .addInterest ("set_color__", this);
|
|
1824
|
+
this .colorRamp_ .addInterest ("set_colorRamp__", this);
|
|
1825
|
+
this .texCoordKey_ .addInterest ("set_texCoord__", this);
|
|
1826
|
+
this .texCoordRamp_ .addInterest ("set_texCoordRamp__", this);
|
|
1827
|
+
|
|
1828
|
+
this .idBuffer = gl .createBuffer ();
|
|
1829
|
+
this .positionBuffer = gl .createBuffer ();
|
|
1830
|
+
this .elapsedTimeBuffer = gl .createBuffer ();
|
|
1831
|
+
this .lifeBuffer = gl .createBuffer ();
|
|
1832
|
+
this .colorBuffer = gl .createBuffer ();
|
|
1833
|
+
this .texCoordBuffers = [ gl .createBuffer () ];
|
|
1834
|
+
this .normalBuffer = gl .createBuffer ();
|
|
1835
|
+
this .vertexBuffer = gl .createBuffer ();
|
|
1836
|
+
|
|
1837
|
+
for (var i = 1, channels = this .getBrowser () .getMaxTextures (); i < channels; ++ i)
|
|
1838
|
+
this .texCoordBuffers .push (this .texCoordBuffers [0]);
|
|
1839
|
+
|
|
1840
|
+
this .idArray = new Float32Array ();
|
|
1841
|
+
this .positionArray = new Float32Array ();
|
|
1842
|
+
this .elapsedTimeArray = new Float32Array ();
|
|
1843
|
+
this .lifeArray = new Float32Array ();
|
|
1844
|
+
this .colorArray = new Float32Array ();
|
|
1845
|
+
this .texCoordArray = new Float32Array ();
|
|
1846
|
+
this .normalArray = new Float32Array ();
|
|
1847
|
+
this .vertexArray = new Float32Array ();
|
|
1848
|
+
|
|
1849
|
+
this .primitiveMode = gl .TRIANGLES;
|
|
1850
|
+
|
|
1851
|
+
// Geometry context
|
|
1852
|
+
|
|
1853
|
+
this .geometryContext .fogCoords = false;
|
|
1854
|
+
this .geometryContext .textureCoordinateNode = browser .getDefaultTextureCoordinate ();
|
|
1855
|
+
|
|
1856
|
+
// Call order is higly important at startup.
|
|
1857
|
+
this .set_emitter__ ();
|
|
1858
|
+
this .set_enabled__ ();
|
|
1859
|
+
this .set_createParticles__ ();
|
|
1860
|
+
this .set_particleLifetime__ ();
|
|
1861
|
+
this .set_lifetimeVariation__ ();
|
|
1862
|
+
this .set_physics__ ();
|
|
1863
|
+
this .set_colorRamp__ ();
|
|
1864
|
+
this .set_texCoordRamp__ ();
|
|
1865
|
+
},
|
|
1866
|
+
set_bbox__: function ()
|
|
1867
|
+
{
|
|
1868
|
+
if (this .bboxSize_ .getValue () .equals (this .getDefaultBBoxSize ()))
|
|
1869
|
+
this .bbox .set ();
|
|
1870
|
+
else
|
|
1871
|
+
this .bbox .set (this .bboxSize_ .getValue (), this .bboxCenter_ .getValue ());
|
|
1872
|
+
|
|
1873
|
+
this .bboxSize .assign (this .bbox .size);
|
|
1874
|
+
this .bboxCenter .assign (this .bbox .center);
|
|
1875
|
+
},
|
|
1876
|
+
set_transparent__: function ()
|
|
1877
|
+
{
|
|
1878
|
+
if (this .getAppearance () .getAlphaMode () === AlphaMode .AUTO)
|
|
1879
|
+
{
|
|
1880
|
+
switch (this .geometryType)
|
|
1881
|
+
{
|
|
1882
|
+
case POINT:
|
|
1883
|
+
{
|
|
1884
|
+
this .setTransparent (true);
|
|
1885
|
+
break;
|
|
1886
|
+
}
|
|
1887
|
+
default:
|
|
1888
|
+
{
|
|
1889
|
+
this .setTransparent (this .getAppearance () .getTransparent () ||
|
|
1890
|
+
(this .colorRampNode && this .colorRampNode .getTransparent ()) ||
|
|
1891
|
+
(this .geometryType === GEOMETRY && this .geometryNode && this .geometryNode .getTransparent ()));
|
|
1892
|
+
break;
|
|
1893
|
+
}
|
|
1894
|
+
}
|
|
1895
|
+
}
|
|
1896
|
+
else
|
|
1897
|
+
{
|
|
1898
|
+
this .setTransparent (this .getAppearance () .getTransparent ());
|
|
1899
|
+
}
|
|
1900
|
+
},
|
|
1901
|
+
set_live__: function ()
|
|
1902
|
+
{
|
|
1903
|
+
if (this .isLive () .getValue ())
|
|
1904
|
+
{
|
|
1905
|
+
if (this .isActive_ .getValue () && this .maxParticles_ .getValue ())
|
|
1906
|
+
{
|
|
1907
|
+
this .getBrowser () .sensorEvents () .addInterest ("animateParticles", this);
|
|
1908
|
+
|
|
1909
|
+
if (this .pauseTime)
|
|
1910
|
+
{
|
|
1911
|
+
this .creationTime += performance .now () / 1000 - this .pauseTime;
|
|
1912
|
+
this .pauseTime = 0;
|
|
1913
|
+
}
|
|
1914
|
+
}
|
|
1915
|
+
}
|
|
1916
|
+
else
|
|
1917
|
+
{
|
|
1918
|
+
if (this .isActive_ .getValue () && this .maxParticles_ .getValue ())
|
|
1919
|
+
{
|
|
1920
|
+
this .getBrowser () .sensorEvents () .removeInterest ("animateParticles", this);
|
|
1921
|
+
|
|
1922
|
+
if (this .pauseTime === 0)
|
|
1923
|
+
this .pauseTime = performance .now () / 1000;
|
|
1924
|
+
}
|
|
1925
|
+
}
|
|
1926
|
+
},
|
|
1927
|
+
set_enabled__: function ()
|
|
1928
|
+
{
|
|
1929
|
+
if (this .enabled_ .getValue () && this .maxParticles_ .getValue ())
|
|
1930
|
+
{
|
|
1931
|
+
if (! this .isActive_ .getValue ())
|
|
1932
|
+
{
|
|
1933
|
+
if (this .isLive () .getValue ())
|
|
1934
|
+
{
|
|
1935
|
+
this .getBrowser () .sensorEvents () .addInterest ("animateParticles", this);
|
|
1936
|
+
|
|
1937
|
+
this .pauseTime = 0;
|
|
1938
|
+
}
|
|
1939
|
+
else
|
|
1940
|
+
this .pauseTime = performance .now () / 1000;
|
|
1941
|
+
|
|
1942
|
+
this .isActive_ = true;
|
|
1943
|
+
}
|
|
1944
|
+
}
|
|
1945
|
+
else
|
|
1946
|
+
{
|
|
1947
|
+
if (this .isActive_ .getValue ())
|
|
1948
|
+
{
|
|
1949
|
+
if (this .isLive () .getValue ())
|
|
1950
|
+
{
|
|
1951
|
+
this .getBrowser () .sensorEvents () .removeInterest ("animateParticles", this);
|
|
1952
|
+
}
|
|
1953
|
+
|
|
1954
|
+
this .isActive_ = false;
|
|
1955
|
+
|
|
1956
|
+
this .numParticles = 0;
|
|
1957
|
+
}
|
|
1958
|
+
}
|
|
1959
|
+
|
|
1960
|
+
this .set_maxParticles__ ();
|
|
1961
|
+
},
|
|
1962
|
+
set_createParticles__: function ()
|
|
1963
|
+
{
|
|
1964
|
+
this .createParticles = this .createParticles_ .getValue ();
|
|
1965
|
+
},
|
|
1966
|
+
set_geometryType__: function ()
|
|
1967
|
+
{
|
|
1968
|
+
var
|
|
1969
|
+
gl = this .getBrowser () .getContext (),
|
|
1970
|
+
maxParticles = this .maxParticles;
|
|
1971
|
+
|
|
1972
|
+
// geometryType
|
|
1973
|
+
|
|
1974
|
+
this .geometryType = GeometryTypes [this .geometryType_ .getValue ()];
|
|
1975
|
+
|
|
1976
|
+
if (! this .geometryType)
|
|
1977
|
+
this .geometryType = POINT;
|
|
1978
|
+
|
|
1979
|
+
// Create buffers
|
|
1980
|
+
|
|
1981
|
+
switch (this .geometryType)
|
|
1982
|
+
{
|
|
1983
|
+
case POINT:
|
|
1984
|
+
{
|
|
1985
|
+
this .idArray = new Float32Array (maxParticles);
|
|
1986
|
+
this .positionArray = new Float32Array (3 * maxParticles);
|
|
1987
|
+
this .elapsedTimeArray = new Float32Array (maxParticles);
|
|
1988
|
+
this .lifeArray = new Float32Array (maxParticles);
|
|
1989
|
+
this .colorArray = new Float32Array (4 * maxParticles);
|
|
1990
|
+
this .texCoordArray = new Float32Array ();
|
|
1991
|
+
this .normalArray = new Float32Array ();
|
|
1992
|
+
this .vertexArray = new Float32Array (4 * maxParticles);
|
|
1993
|
+
|
|
1994
|
+
for (var i = 0, a = this .idArray, l = a .length; i < l; ++ i)
|
|
1995
|
+
a [i] = i;
|
|
1996
|
+
|
|
1997
|
+
this .colorArray .fill (1);
|
|
1998
|
+
this .vertexArray .fill (1);
|
|
1999
|
+
|
|
2000
|
+
this .testWireframe = false;
|
|
2001
|
+
this .primitiveMode = gl .POINTS;
|
|
2002
|
+
this .texCoordCount = 0;
|
|
2003
|
+
this .vertexCount = 1;
|
|
2004
|
+
|
|
2005
|
+
this .geometryContext .geometryType = 0;
|
|
2006
|
+
break;
|
|
2007
|
+
}
|
|
2008
|
+
case LINE:
|
|
2009
|
+
{
|
|
2010
|
+
this .idArray = new Float32Array (2 * maxParticles);
|
|
2011
|
+
this .positionArray = new Float32Array (2 * 3 * maxParticles);
|
|
2012
|
+
this .elapsedTimeArray = new Float32Array (2 * maxParticles);
|
|
2013
|
+
this .lifeArray = new Float32Array (2 * maxParticles);
|
|
2014
|
+
this .colorArray = new Float32Array (2 * 4 * maxParticles);
|
|
2015
|
+
this .texCoordArray = new Float32Array ();
|
|
2016
|
+
this .normalArray = new Float32Array ();
|
|
2017
|
+
this .vertexArray = new Float32Array (2 * 4 * maxParticles);
|
|
2018
|
+
|
|
2019
|
+
for (var i = 0, a = this .idArray, l = a .length; i < l; ++ i)
|
|
2020
|
+
a [i] = Math .floor (i / 2);
|
|
2021
|
+
|
|
2022
|
+
this .colorArray .fill (1);
|
|
2023
|
+
this .vertexArray .fill (1);
|
|
2024
|
+
|
|
2025
|
+
this .testWireframe = false;
|
|
2026
|
+
this .primitiveMode = gl .LINES;
|
|
2027
|
+
this .texCoordCount = 2;
|
|
2028
|
+
this .vertexCount = 2;
|
|
2029
|
+
|
|
2030
|
+
this .geometryContext .geometryType = 1;
|
|
2031
|
+
break;
|
|
2032
|
+
}
|
|
2033
|
+
case TRIANGLE:
|
|
2034
|
+
case QUAD:
|
|
2035
|
+
case SPRITE:
|
|
2036
|
+
{
|
|
2037
|
+
this .idArray = new Float32Array (6 * maxParticles);
|
|
2038
|
+
this .positionArray = new Float32Array (6 * 3 * maxParticles);
|
|
2039
|
+
this .elapsedTimeArray = new Float32Array (6 * maxParticles);
|
|
2040
|
+
this .lifeArray = new Float32Array (6 * maxParticles);
|
|
2041
|
+
this .colorArray = new Float32Array (6 * 4 * maxParticles);
|
|
2042
|
+
this .texCoordArray = new Float32Array (6 * 4 * maxParticles);
|
|
2043
|
+
this .normalArray = new Float32Array (6 * 3 * maxParticles);
|
|
2044
|
+
this .vertexArray = new Float32Array (6 * 4 * maxParticles);
|
|
2045
|
+
|
|
2046
|
+
for (var i = 0, a = this .idArray, l = a .length; i < l; ++ i)
|
|
2047
|
+
a [i] = Math .floor (i / 6);
|
|
2048
|
+
|
|
2049
|
+
this .colorArray .fill (1);
|
|
2050
|
+
this .vertexArray .fill (1);
|
|
2051
|
+
|
|
2052
|
+
var
|
|
2053
|
+
texCoordArray = this .texCoordArray,
|
|
2054
|
+
normalArray = this .normalArray;
|
|
2055
|
+
|
|
2056
|
+
for (var i = 0, length = 6 * 3 * maxParticles; i < length; i += 3)
|
|
2057
|
+
{
|
|
2058
|
+
normalArray [i] = 0;
|
|
2059
|
+
normalArray [i + 1] = 0;
|
|
2060
|
+
normalArray [i + 2] = 1;
|
|
2061
|
+
}
|
|
2062
|
+
|
|
2063
|
+
gl .bindBuffer (gl .ARRAY_BUFFER, this .normalBuffer);
|
|
2064
|
+
gl .bufferData (gl .ARRAY_BUFFER, this .normalArray, gl .STATIC_DRAW);
|
|
2065
|
+
|
|
2066
|
+
for (var i = 0; i < maxParticles; ++ i)
|
|
2067
|
+
{
|
|
2068
|
+
var i24 = i * 24;
|
|
2069
|
+
|
|
2070
|
+
// p4 ------ p3
|
|
2071
|
+
// | / |
|
|
2072
|
+
// | / |
|
|
2073
|
+
// | / |
|
|
2074
|
+
// | / |
|
|
2075
|
+
// p1 ------ p2
|
|
2076
|
+
|
|
2077
|
+
// p1
|
|
2078
|
+
texCoordArray [i24] = texCoordArray [i24 + 12] = 0;
|
|
2079
|
+
texCoordArray [i24 + 1] = texCoordArray [i24 + 13] = 0;
|
|
2080
|
+
texCoordArray [i24 + 2] = texCoordArray [i24 + 14] = 0;
|
|
2081
|
+
texCoordArray [i24 + 3] = texCoordArray [i24 + 15] = 1;
|
|
2082
|
+
|
|
2083
|
+
// p2
|
|
2084
|
+
texCoordArray [i24 + 4] = 1;
|
|
2085
|
+
texCoordArray [i24 + 5] = 0;
|
|
2086
|
+
texCoordArray [i24 + 6] = 0;
|
|
2087
|
+
texCoordArray [i24 + 7] = 1;
|
|
2088
|
+
|
|
2089
|
+
// p3
|
|
2090
|
+
texCoordArray [i24 + 8] = texCoordArray [i24 + 16] = 1;
|
|
2091
|
+
texCoordArray [i24 + 9] = texCoordArray [i24 + 17] = 1;
|
|
2092
|
+
texCoordArray [i24 + 10] = texCoordArray [i24 + 18] = 0;
|
|
2093
|
+
texCoordArray [i24 + 11] = texCoordArray [i24 + 19] = 1;
|
|
2094
|
+
|
|
2095
|
+
// p4
|
|
2096
|
+
texCoordArray [i24 + 20] = 0;
|
|
2097
|
+
texCoordArray [i24 + 21] = 1;
|
|
2098
|
+
texCoordArray [i24 + 22] = 0;
|
|
2099
|
+
texCoordArray [i24 + 23] = 1;
|
|
2100
|
+
}
|
|
2101
|
+
|
|
2102
|
+
gl .bindBuffer (gl .ARRAY_BUFFER, this .texCoordBuffers [0]);
|
|
2103
|
+
gl .bufferData (gl .ARRAY_BUFFER, this .texCoordArray, gl .STATIC_DRAW);
|
|
2104
|
+
|
|
2105
|
+
this .testWireframe = true;
|
|
2106
|
+
this .primitiveMode = gl .TRIANGLES;
|
|
2107
|
+
this .texCoordCount = 4;
|
|
2108
|
+
this .vertexCount = 6;
|
|
2109
|
+
|
|
2110
|
+
this .geometryContext .geometryType = 2;
|
|
2111
|
+
break;
|
|
2112
|
+
}
|
|
2113
|
+
case GEOMETRY:
|
|
2114
|
+
{
|
|
2115
|
+
this .texCoordCount = 0;
|
|
2116
|
+
this .vertexCount = 0;
|
|
2117
|
+
break;
|
|
2118
|
+
}
|
|
2119
|
+
}
|
|
2120
|
+
|
|
2121
|
+
gl .bindBuffer (gl .ARRAY_BUFFER, this .idBuffer);
|
|
2122
|
+
gl .bufferData (gl .ARRAY_BUFFER, this .idArray, gl .STATIC_DRAW);
|
|
2123
|
+
|
|
2124
|
+
this .set_shader__ ();
|
|
2125
|
+
this .set_transparent__ ();
|
|
2126
|
+
},
|
|
2127
|
+
set_shader__: function ()
|
|
2128
|
+
{
|
|
2129
|
+
switch (this .geometryType)
|
|
2130
|
+
{
|
|
2131
|
+
case POINT:
|
|
2132
|
+
{
|
|
2133
|
+
this .shaderNode = this .getBrowser () .getPointShader ();
|
|
2134
|
+
break;
|
|
2135
|
+
}
|
|
2136
|
+
case LINE:
|
|
2137
|
+
{
|
|
2138
|
+
this .shaderNode = this .getBrowser () .getLineShader ();
|
|
2139
|
+
break;
|
|
2140
|
+
}
|
|
2141
|
+
case TRIANGLE:
|
|
2142
|
+
case QUAD:
|
|
2143
|
+
case SPRITE:
|
|
2144
|
+
case GEOMETRY:
|
|
2145
|
+
{
|
|
2146
|
+
this .shaderNode = null;
|
|
2147
|
+
break;
|
|
2148
|
+
}
|
|
2149
|
+
}
|
|
2150
|
+
},
|
|
2151
|
+
set_maxParticles__: function ()
|
|
2152
|
+
{
|
|
2153
|
+
var
|
|
2154
|
+
particles = this .particles,
|
|
2155
|
+
maxParticles = Math .max (0, this .maxParticles_ .getValue ());
|
|
2156
|
+
|
|
2157
|
+
for (var i = this .numParticles, length = Math .min (particles .length, maxParticles); i < length; ++ i)
|
|
2158
|
+
{
|
|
2159
|
+
particles [i] .life = 1;
|
|
2160
|
+
particles [i] .lifetime = -1;
|
|
2161
|
+
}
|
|
2162
|
+
|
|
2163
|
+
for (var i = particles .length, length = maxParticles; i < length; ++ i)
|
|
2164
|
+
{
|
|
2165
|
+
particles [i] = {
|
|
2166
|
+
id: i,
|
|
2167
|
+
life: 1,
|
|
2168
|
+
lifetime: -1,
|
|
2169
|
+
elapsedTime: 0,
|
|
2170
|
+
position: new Vector3 (0, 0, 0),
|
|
2171
|
+
velocity: new Vector3 (0, 0, 0),
|
|
2172
|
+
color: new Vector4 (1, 1, 1, 1),
|
|
2173
|
+
distance: 0,
|
|
2174
|
+
};
|
|
2175
|
+
}
|
|
2176
|
+
|
|
2177
|
+
this .maxParticles = maxParticles;
|
|
2178
|
+
this .numParticles = Math .min (this .numParticles, maxParticles);
|
|
2179
|
+
|
|
2180
|
+
if (! this .emitterNode .isExplosive ())
|
|
2181
|
+
this .creationTime = performance .now () / 1000;
|
|
2182
|
+
|
|
2183
|
+
this .set_geometryType__ ();
|
|
2184
|
+
},
|
|
2185
|
+
set_particleLifetime__: function ()
|
|
2186
|
+
{
|
|
2187
|
+
this .particleLifetime = this .particleLifetime_ .getValue ();
|
|
2188
|
+
},
|
|
2189
|
+
set_lifetimeVariation__: function ()
|
|
2190
|
+
{
|
|
2191
|
+
this .lifetimeVariation = this .lifetimeVariation_ .getValue ();
|
|
2192
|
+
},
|
|
2193
|
+
set_emitter__: function ()
|
|
2194
|
+
{
|
|
2195
|
+
this .emitterNode = X3DCast (X3DConstants .X3DParticleEmitterNode, this .emitter_);
|
|
2196
|
+
|
|
2197
|
+
if (! this .emitterNode)
|
|
2198
|
+
this .emitterNode = this .getBrowser () .getDefaultEmitter ();
|
|
2199
|
+
|
|
2200
|
+
this .createParticles = this .createParticles_ .getValue ();
|
|
2201
|
+
},
|
|
2202
|
+
set_physics__: function ()
|
|
2203
|
+
{
|
|
2204
|
+
var
|
|
2205
|
+
physics = this .physics_ .getValue (),
|
|
2206
|
+
forcePhysicsModelNodes = this .forcePhysicsModelNodes,
|
|
2207
|
+
boundedPhysicsModelNodes = this .boundedPhysicsModelNodes;
|
|
2208
|
+
|
|
2209
|
+
for (var i = 0, length = boundedPhysicsModelNodes .length; i < length; ++ i)
|
|
2210
|
+
boundedPhysicsModelNodes [i] .removeInterest ("set_boundedPhysics__", this);
|
|
2211
|
+
|
|
2212
|
+
forcePhysicsModelNodes .length = 0;
|
|
2213
|
+
boundedPhysicsModelNodes .length = 0;
|
|
2214
|
+
|
|
2215
|
+
for (var i = 0, length = physics .length; i < length; ++ i)
|
|
2216
|
+
{
|
|
2217
|
+
try
|
|
2218
|
+
{
|
|
2219
|
+
var
|
|
2220
|
+
innerNode = physics [i] .getValue () .getInnerNode (),
|
|
2221
|
+
type = innerNode .getType ();
|
|
2222
|
+
|
|
2223
|
+
for (var t = type .length - 1; t >= 0; -- t)
|
|
2224
|
+
{
|
|
2225
|
+
switch (type [t])
|
|
2226
|
+
{
|
|
2227
|
+
case X3DConstants .ForcePhysicsModel:
|
|
2228
|
+
case X3DConstants .WindPhysicsModel:
|
|
2229
|
+
{
|
|
2230
|
+
forcePhysicsModelNodes .push (innerNode);
|
|
2231
|
+
break;
|
|
2232
|
+
}
|
|
2233
|
+
case X3DConstants .BoundedPhysicsModel:
|
|
2234
|
+
{
|
|
2235
|
+
innerNode .addInterest ("set_boundedPhysics__", this);
|
|
2236
|
+
boundedPhysicsModelNodes .push (innerNode);
|
|
2237
|
+
break;
|
|
2238
|
+
}
|
|
2239
|
+
default:
|
|
2240
|
+
continue;
|
|
2241
|
+
}
|
|
2242
|
+
|
|
2243
|
+
break;
|
|
2244
|
+
}
|
|
2245
|
+
}
|
|
2246
|
+
catch (error)
|
|
2247
|
+
{ }
|
|
2248
|
+
}
|
|
2249
|
+
|
|
2250
|
+
this .set_boundedPhysics__ ();
|
|
2251
|
+
},
|
|
2252
|
+
set_boundedPhysics__: function ()
|
|
2253
|
+
{
|
|
2254
|
+
var
|
|
2255
|
+
boundedPhysicsModelNodes = this .boundedPhysicsModelNodes,
|
|
2256
|
+
boundedNormals = this .boundedNormals,
|
|
2257
|
+
boundedVertices = this .boundedVertices;
|
|
2258
|
+
|
|
2259
|
+
boundedNormals .length = 0;
|
|
2260
|
+
boundedVertices .length = 0;
|
|
2261
|
+
|
|
2262
|
+
for (var i = 0, length = boundedPhysicsModelNodes .length; i < length; ++ i)
|
|
2263
|
+
{
|
|
2264
|
+
boundedPhysicsModelNodes [i] .addGeometry (boundedNormals, boundedVertices);
|
|
2265
|
+
}
|
|
2266
|
+
|
|
2267
|
+
this .boundedVolume = new BVH (boundedVertices, boundedNormals);
|
|
2268
|
+
},
|
|
2269
|
+
set_colorRamp__: function ()
|
|
2270
|
+
{
|
|
2271
|
+
if (this .colorRampNode)
|
|
2272
|
+
this .colorRampNode .removeInterest ("set_color__", this);
|
|
2273
|
+
|
|
2274
|
+
this .colorRampNode = X3DCast (X3DConstants .X3DColorNode, this .colorRamp_);
|
|
2275
|
+
|
|
2276
|
+
if (this .colorRampNode)
|
|
2277
|
+
this .colorRampNode .addInterest ("set_color__", this);
|
|
2278
|
+
|
|
2279
|
+
this .set_color__ ();
|
|
2280
|
+
this .set_transparent__ ();
|
|
2281
|
+
},
|
|
2282
|
+
set_color__: function ()
|
|
2283
|
+
{
|
|
2284
|
+
var
|
|
2285
|
+
colorKey = this .colorKey_,
|
|
2286
|
+
colorKeys = this .colorKeys,
|
|
2287
|
+
colorRamp = this .colorRamp;
|
|
2288
|
+
|
|
2289
|
+
for (var i = 0, length = colorKey .length; i < length; ++ i)
|
|
2290
|
+
colorKeys [i] = colorKey [i];
|
|
2291
|
+
|
|
2292
|
+
colorKeys .length = length;
|
|
2293
|
+
|
|
2294
|
+
if (this .colorRampNode)
|
|
2295
|
+
this .colorRampNode .getVectors (this .colorRamp);
|
|
2296
|
+
|
|
2297
|
+
for (var i = colorRamp .length, length = colorKey .length; i < length; ++ i)
|
|
2298
|
+
colorRamp [i] = new Vector4 (1, 1, 1, 1);
|
|
2299
|
+
|
|
2300
|
+
colorRamp .length = length;
|
|
2301
|
+
|
|
2302
|
+
this .geometryContext .colorMaterial = !! (colorKeys .length && this .colorRampNode);
|
|
2303
|
+
},
|
|
2304
|
+
set_texCoordRamp__: function ()
|
|
2305
|
+
{
|
|
2306
|
+
if (this .texCoordRampNode)
|
|
2307
|
+
this .texCoordRampNode .removeInterest ("set_texCoord__", this);
|
|
2308
|
+
|
|
2309
|
+
this .texCoordRampNode = X3DCast (X3DConstants .X3DTextureCoordinateNode, this .texCoordRamp_);
|
|
2310
|
+
|
|
2311
|
+
if (this .texCoordRampNode)
|
|
2312
|
+
this .texCoordRampNode .addInterest ("set_texCoord__", this);
|
|
2313
|
+
|
|
2314
|
+
this .set_texCoord__ ();
|
|
2315
|
+
},
|
|
2316
|
+
set_texCoord__: function ()
|
|
2317
|
+
{
|
|
2318
|
+
var
|
|
2319
|
+
texCoordKey = this .texCoordKey_,
|
|
2320
|
+
texCoordKeys = this .texCoordKeys,
|
|
2321
|
+
texCoordRamp = this .texCoordRamp;
|
|
2322
|
+
|
|
2323
|
+
for (var i = 0, length = texCoordKey .length; i < length; ++ i)
|
|
2324
|
+
texCoordKeys [i] = texCoordKey [i];
|
|
2325
|
+
|
|
2326
|
+
texCoordKeys .length = length;
|
|
2327
|
+
|
|
2328
|
+
if (this .texCoordRampNode)
|
|
2329
|
+
this .texCoordRampNode .getTexCoord (texCoordRamp);
|
|
2330
|
+
|
|
2331
|
+
for (var i = texCoordRamp .length, length = texCoordKey .length * this .texCoordCount; i < length; ++ i)
|
|
2332
|
+
texCoordRamp [i] = new Vector4 (0, 0, 0, 0);
|
|
2333
|
+
|
|
2334
|
+
texCoordRamp .length = length;
|
|
2335
|
+
|
|
2336
|
+
this .texCoordAnim = !! (texCoordKeys .length && this .texCoordRampNode);
|
|
2337
|
+
},
|
|
2338
|
+
intersectsBox: function (box, clipPlanes)
|
|
2339
|
+
{
|
|
2340
|
+
// TODO: implement me.
|
|
2341
|
+
},
|
|
2342
|
+
animateParticles: function ()
|
|
2343
|
+
{
|
|
2344
|
+
var emitterNode = this .emitterNode;
|
|
2345
|
+
|
|
2346
|
+
// Determine delta time
|
|
2347
|
+
|
|
2348
|
+
var
|
|
2349
|
+
DELAY = 15, // Delay in frames when dt full applys.
|
|
2350
|
+
dt = 1 / Math .max (10, this .getBrowser () .getCurrentFrameRate ());
|
|
2351
|
+
|
|
2352
|
+
// var deltaTime is only for the emitter, this.deltaTime is for the forces.
|
|
2353
|
+
var deltaTime = this .deltaTime = ((DELAY - 1) * this .deltaTime + dt) / DELAY; // Moving average about DELAY frames.
|
|
2354
|
+
|
|
2355
|
+
// Determine numParticles
|
|
2356
|
+
|
|
2357
|
+
if (emitterNode .isExplosive ())
|
|
2358
|
+
{
|
|
2359
|
+
var
|
|
2360
|
+
now = performance .now () / 1000,
|
|
2361
|
+
particleLifetime = this .particleLifetime + this .particleLifetime * this .lifetimeVariation;
|
|
2362
|
+
|
|
2363
|
+
if (this .numParticles === 0 || now - this .creationTime > particleLifetime)
|
|
2364
|
+
{
|
|
2365
|
+
this .creationTime = now;
|
|
2366
|
+
this .numParticles = this .maxParticles;
|
|
2367
|
+
this .createParticles = this .createParticles_ .getValue ();
|
|
2368
|
+
|
|
2369
|
+
deltaTime = Number .POSITIVE_INFINITY;
|
|
2370
|
+
}
|
|
2371
|
+
else
|
|
2372
|
+
this .createParticles = false;
|
|
2373
|
+
}
|
|
2374
|
+
else
|
|
2375
|
+
{
|
|
2376
|
+
if (this .numParticles < this .maxParticles)
|
|
2377
|
+
{
|
|
2378
|
+
var
|
|
2379
|
+
now = performance .now () / 1000,
|
|
2380
|
+
newParticles = Math .max (0, Math .floor ((now - this .creationTime) * this .maxParticles / this .particleLifetime));
|
|
2381
|
+
|
|
2382
|
+
if (newParticles)
|
|
2383
|
+
this .creationTime = now;
|
|
2384
|
+
|
|
2385
|
+
this .numParticles = Math .floor (Math .min (this .maxParticles, this .numParticles + newParticles));
|
|
2386
|
+
}
|
|
2387
|
+
}
|
|
2388
|
+
|
|
2389
|
+
// Apply forces.
|
|
2390
|
+
|
|
2391
|
+
if (emitterNode .getMass ())
|
|
2392
|
+
{
|
|
2393
|
+
var
|
|
2394
|
+
forcePhysicsModelNodes = this .forcePhysicsModelNodes,
|
|
2395
|
+
velocities = this .velocities,
|
|
2396
|
+
speeds = this .speeds,
|
|
2397
|
+
turbulences = this .turbulences,
|
|
2398
|
+
deltaMass = this .deltaTime / emitterNode .getMass ();
|
|
2399
|
+
|
|
2400
|
+
// Collect forces in velocities and collect turbulences.
|
|
2401
|
+
|
|
2402
|
+
for (var i = velocities .length, length = forcePhysicsModelNodes .length; i < length; ++ i)
|
|
2403
|
+
velocities [i] = new Vector3 (0, 0, 0);
|
|
2404
|
+
|
|
2405
|
+
for (var i = 0, length = forcePhysicsModelNodes .length; i < length; ++ i)
|
|
2406
|
+
forcePhysicsModelNodes [i] .addForce (i, emitterNode, velocities, turbulences);
|
|
2407
|
+
|
|
2408
|
+
// Determine velocities from forces and determine speed.
|
|
2409
|
+
|
|
2410
|
+
for (var i = 0, length = velocities .length; i < length; ++ i)
|
|
2411
|
+
{
|
|
2412
|
+
velocities [i] .multiply (deltaMass);
|
|
2413
|
+
speeds [i] = velocities [i] .abs ();
|
|
2414
|
+
}
|
|
2415
|
+
|
|
2416
|
+
this .numForces = length;
|
|
2417
|
+
}
|
|
2418
|
+
else
|
|
2419
|
+
{
|
|
2420
|
+
this .numForces = 0;
|
|
2421
|
+
}
|
|
2422
|
+
|
|
2423
|
+
// Determine particle position, velocity and colors
|
|
2424
|
+
|
|
2425
|
+
emitterNode .animate (this, deltaTime);
|
|
2426
|
+
|
|
2427
|
+
this .updateGeometry (null);
|
|
2428
|
+
|
|
2429
|
+
this .getBrowser () .addBrowserEvent ();
|
|
2430
|
+
},
|
|
2431
|
+
updateGeometry: function (modelViewMatrix)
|
|
2432
|
+
{
|
|
2433
|
+
switch (this .geometryType)
|
|
2434
|
+
{
|
|
2435
|
+
case POINT:
|
|
2436
|
+
if (! modelViewMatrix)
|
|
2437
|
+
this .updatePoint ();
|
|
2438
|
+
break;
|
|
2439
|
+
case LINE:
|
|
2440
|
+
if (! modelViewMatrix)
|
|
2441
|
+
this .updateLine ();
|
|
2442
|
+
break;
|
|
2443
|
+
case TRIANGLE:
|
|
2444
|
+
case QUAD:
|
|
2445
|
+
case SPRITE:
|
|
2446
|
+
this .updateQuad (modelViewMatrix);
|
|
2447
|
+
break;
|
|
2448
|
+
case GEOMETRY:
|
|
2449
|
+
break;
|
|
2450
|
+
}
|
|
2451
|
+
},
|
|
2452
|
+
updatePoint: function ()
|
|
2453
|
+
{
|
|
2454
|
+
var
|
|
2455
|
+
gl = this .getBrowser () .getContext (),
|
|
2456
|
+
particles = this .particles,
|
|
2457
|
+
numParticles = this .numParticles,
|
|
2458
|
+
positionArray = this .positionArray,
|
|
2459
|
+
elapsedTimeArray = this .elapsedTimeArray,
|
|
2460
|
+
lifeArray = this .lifeArray,
|
|
2461
|
+
colorArray = this .colorArray,
|
|
2462
|
+
vertexArray = this .vertexArray;
|
|
2463
|
+
|
|
2464
|
+
// Colors
|
|
2465
|
+
|
|
2466
|
+
if (this .geometryContext .colorMaterial)
|
|
2467
|
+
{
|
|
2468
|
+
for (var i = 0; i < numParticles; ++ i)
|
|
2469
|
+
{
|
|
2470
|
+
var
|
|
2471
|
+
color = particles [i] .color,
|
|
2472
|
+
i4 = i * 4;
|
|
2473
|
+
|
|
2474
|
+
colorArray [i4] = color .x;
|
|
2475
|
+
colorArray [i4 + 1] = color .y;
|
|
2476
|
+
colorArray [i4 + 2] = color .z;
|
|
2477
|
+
colorArray [i4 + 3] = color .w;
|
|
2478
|
+
}
|
|
2479
|
+
|
|
2480
|
+
gl .bindBuffer (gl .ARRAY_BUFFER, this .colorBuffer);
|
|
2481
|
+
gl .bufferData (gl .ARRAY_BUFFER, this .colorArray, gl .STATIC_DRAW);
|
|
2482
|
+
}
|
|
2483
|
+
|
|
2484
|
+
// Vertices
|
|
2485
|
+
|
|
2486
|
+
for (var i = 0; i < numParticles; ++ i)
|
|
2487
|
+
{
|
|
2488
|
+
var
|
|
2489
|
+
position = particles [i] .position,
|
|
2490
|
+
elapsedTime = particles [i] .elapsedTime / particles [i] .lifetime,
|
|
2491
|
+
i3 = i * 3,
|
|
2492
|
+
i4 = i * 4;
|
|
2493
|
+
|
|
2494
|
+
positionArray [i3] = position .x;
|
|
2495
|
+
positionArray [i3 + 1] = position .y;
|
|
2496
|
+
positionArray [i3 + 2] = position .z;
|
|
2497
|
+
|
|
2498
|
+
elapsedTimeArray [i] = elapsedTime;
|
|
2499
|
+
lifeArray [i] = particles [i] .life;
|
|
2500
|
+
|
|
2501
|
+
vertexArray [i4] = position .x;
|
|
2502
|
+
vertexArray [i4 + 1] = position .y;
|
|
2503
|
+
vertexArray [i4 + 2] = position .z;
|
|
2504
|
+
}
|
|
2505
|
+
|
|
2506
|
+
gl .bindBuffer (gl .ARRAY_BUFFER, this .positionBuffer);
|
|
2507
|
+
gl .bufferData (gl .ARRAY_BUFFER, this .positionArray, gl .STATIC_DRAW);
|
|
2508
|
+
gl .bindBuffer (gl .ARRAY_BUFFER, this .elapsedTimeBuffer);
|
|
2509
|
+
gl .bufferData (gl .ARRAY_BUFFER, this .elapsedTimeArray, gl .STATIC_DRAW);
|
|
2510
|
+
gl .bindBuffer (gl .ARRAY_BUFFER, this .lifeBuffer);
|
|
2511
|
+
gl .bufferData (gl .ARRAY_BUFFER, this .lifeArray, gl .STATIC_DRAW);
|
|
2512
|
+
gl .bindBuffer (gl .ARRAY_BUFFER, this .vertexBuffer);
|
|
2513
|
+
gl .bufferData (gl .ARRAY_BUFFER, this .vertexArray, gl .STATIC_DRAW);
|
|
2514
|
+
},
|
|
2515
|
+
updateLine: function ()
|
|
2516
|
+
{
|
|
2517
|
+
var
|
|
2518
|
+
gl = this .getBrowser () .getContext (),
|
|
2519
|
+
particles = this .particles,
|
|
2520
|
+
numParticles = this .numParticles,
|
|
2521
|
+
positionArray = this .positionArray,
|
|
2522
|
+
elapsedTimeArray = this .elapsedTimeArray,
|
|
2523
|
+
lifeArray = this .lifeArray,
|
|
2524
|
+
colorArray = this .colorArray,
|
|
2525
|
+
vertexArray = this .vertexArray,
|
|
2526
|
+
sy1_2 = this .particleSize_ .y / 2;
|
|
2527
|
+
|
|
2528
|
+
// Colors
|
|
2529
|
+
|
|
2530
|
+
if (this .geometryContext .colorMaterial)
|
|
2531
|
+
{
|
|
2532
|
+
for (var i = 0; i < numParticles; ++ i)
|
|
2533
|
+
{
|
|
2534
|
+
var
|
|
2535
|
+
color = particles [i] .color,
|
|
2536
|
+
i8 = i * 8;
|
|
2537
|
+
|
|
2538
|
+
colorArray [i8] = color .x;
|
|
2539
|
+
colorArray [i8 + 1] = color .y;
|
|
2540
|
+
colorArray [i8 + 2] = color .z;
|
|
2541
|
+
colorArray [i8 + 3] = color .w;
|
|
2542
|
+
|
|
2543
|
+
colorArray [i8 + 4] = color .x;
|
|
2544
|
+
colorArray [i8 + 5] = color .y;
|
|
2545
|
+
colorArray [i8 + 6] = color .z;
|
|
2546
|
+
colorArray [i8 + 7] = color .w;
|
|
2547
|
+
}
|
|
2548
|
+
|
|
2549
|
+
gl .bindBuffer (gl .ARRAY_BUFFER, this .colorBuffer);
|
|
2550
|
+
gl .bufferData (gl .ARRAY_BUFFER, this .colorArray, gl .STATIC_DRAW);
|
|
2551
|
+
}
|
|
2552
|
+
|
|
2553
|
+
// Vertices
|
|
2554
|
+
|
|
2555
|
+
for (var i = 0; i < numParticles; ++ i)
|
|
2556
|
+
{
|
|
2557
|
+
var
|
|
2558
|
+
particle = particles [i],
|
|
2559
|
+
position = particle .position,
|
|
2560
|
+
elapsedTime = particles [i] .elapsedTime / particles [i] .lifetime,
|
|
2561
|
+
life = particles [i] .life,
|
|
2562
|
+
x = position .x,
|
|
2563
|
+
y = position .y,
|
|
2564
|
+
z = position .z,
|
|
2565
|
+
i2 = i * 2,
|
|
2566
|
+
i6 = i * 6,
|
|
2567
|
+
i8 = i * 8;
|
|
2568
|
+
|
|
2569
|
+
positionArray [i6] = x;
|
|
2570
|
+
positionArray [i6 + 1] = y;
|
|
2571
|
+
positionArray [i6 + 2] = z;
|
|
2572
|
+
positionArray [i6 + 3] = x;
|
|
2573
|
+
positionArray [i6 + 4] = y;
|
|
2574
|
+
positionArray [i6 + 5] = z;
|
|
2575
|
+
|
|
2576
|
+
elapsedTimeArray [i2] = elapsedTime;
|
|
2577
|
+
elapsedTimeArray [i2 + 1] = elapsedTime;
|
|
2578
|
+
|
|
2579
|
+
lifeArray [i2] = life;
|
|
2580
|
+
lifeArray [i2 + 1] = life;
|
|
2581
|
+
|
|
2582
|
+
// Length of line / 2.
|
|
2583
|
+
normal .assign (particle .velocity) .normalize () .multiply (sy1_2);
|
|
2584
|
+
|
|
2585
|
+
vertexArray [i8] = x - normal .x;
|
|
2586
|
+
vertexArray [i8 + 1] = y - normal .y;
|
|
2587
|
+
vertexArray [i8 + 2] = z - normal .z;
|
|
2588
|
+
|
|
2589
|
+
vertexArray [i8 + 4] = x + normal .x;
|
|
2590
|
+
vertexArray [i8 + 5] = y + normal .y;
|
|
2591
|
+
vertexArray [i8 + 6] = z + normal .z;
|
|
2592
|
+
}
|
|
2593
|
+
|
|
2594
|
+
gl .bindBuffer (gl .ARRAY_BUFFER, this .positionBuffer);
|
|
2595
|
+
gl .bufferData (gl .ARRAY_BUFFER, this .positionArray, gl .STATIC_DRAW);
|
|
2596
|
+
gl .bindBuffer (gl .ARRAY_BUFFER, this .elapsedTimeBuffer);
|
|
2597
|
+
gl .bufferData (gl .ARRAY_BUFFER, this .elapsedTimeArray, gl .STATIC_DRAW);
|
|
2598
|
+
gl .bindBuffer (gl .ARRAY_BUFFER, this .lifeBuffer);
|
|
2599
|
+
gl .bufferData (gl .ARRAY_BUFFER, this .lifeArray, gl .STATIC_DRAW);
|
|
2600
|
+
gl .bindBuffer (gl .ARRAY_BUFFER, this .vertexBuffer);
|
|
2601
|
+
gl .bufferData (gl .ARRAY_BUFFER, this .vertexArray, gl .STATIC_DRAW);
|
|
2602
|
+
},
|
|
2603
|
+
updateQuad: function (modelViewMatrix)
|
|
2604
|
+
{
|
|
2605
|
+
try
|
|
2606
|
+
{
|
|
2607
|
+
var
|
|
2608
|
+
gl = this .getBrowser () .getContext (),
|
|
2609
|
+
particles = this .particles,
|
|
2610
|
+
maxParticles = this .maxParticles,
|
|
2611
|
+
numParticles = this .numParticles,
|
|
2612
|
+
positionArray = this .positionArray,
|
|
2613
|
+
elapsedTimeArray = this .elapsedTimeArray,
|
|
2614
|
+
lifeArray = this .lifeArray,
|
|
2615
|
+
colorArray = this .colorArray,
|
|
2616
|
+
texCoordArray = this .texCoordArray,
|
|
2617
|
+
normalArray = this .normalArray,
|
|
2618
|
+
vertexArray = this .vertexArray,
|
|
2619
|
+
sx1_2 = this .particleSize_ .x / 2,
|
|
2620
|
+
sy1_2 = this .particleSize_ .y / 2;
|
|
2621
|
+
|
|
2622
|
+
// Sort particles
|
|
2623
|
+
|
|
2624
|
+
// if (this .sortParticles) // always false
|
|
2625
|
+
// {
|
|
2626
|
+
// for (var i = 0; i < numParticles; ++ i)
|
|
2627
|
+
// {
|
|
2628
|
+
// var particle = particles [i];
|
|
2629
|
+
// particle .distance = modelViewMatrix .getDepth (particle .position);
|
|
2630
|
+
// }
|
|
2631
|
+
//
|
|
2632
|
+
// // Expensisive function!!!
|
|
2633
|
+
// this .particleSorter .sort (0, numParticles);
|
|
2634
|
+
// }
|
|
2635
|
+
|
|
2636
|
+
// Colors
|
|
2637
|
+
|
|
2638
|
+
if (! modelViewMatrix) // if called from animateParticles
|
|
2639
|
+
{
|
|
2640
|
+
if (this .geometryContext .colorMaterial)
|
|
2641
|
+
{
|
|
2642
|
+
for (var i = 0; i < maxParticles; ++ i)
|
|
2643
|
+
{
|
|
2644
|
+
var
|
|
2645
|
+
color = particles [i] .color,
|
|
2646
|
+
i24 = i * 24;
|
|
2647
|
+
|
|
2648
|
+
// p4 ------ p3
|
|
2649
|
+
// | / |
|
|
2650
|
+
// | / |
|
|
2651
|
+
// | / |
|
|
2652
|
+
// | / |
|
|
2653
|
+
// p1 ------ p2
|
|
2654
|
+
|
|
2655
|
+
// p1, p2, p3; p1, p3, p4
|
|
2656
|
+
colorArray [i24] = colorArray [i24 + 4] = colorArray [i24 + 8] = colorArray [i24 + 12] = colorArray [i24 + 16] = colorArray [i24 + 20] = color .x;
|
|
2657
|
+
colorArray [i24 + 1] = colorArray [i24 + 5] = colorArray [i24 + 9] = colorArray [i24 + 13] = colorArray [i24 + 17] = colorArray [i24 + 21] = color .y;
|
|
2658
|
+
colorArray [i24 + 2] = colorArray [i24 + 6] = colorArray [i24 + 10] = colorArray [i24 + 14] = colorArray [i24 + 18] = colorArray [i24 + 22] = color .z;
|
|
2659
|
+
colorArray [i24 + 3] = colorArray [i24 + 7] = colorArray [i24 + 11] = colorArray [i24 + 15] = colorArray [i24 + 19] = colorArray [i24 + 23] = color .w;
|
|
2660
|
+
}
|
|
2661
|
+
|
|
2662
|
+
gl .bindBuffer (gl .ARRAY_BUFFER, this .colorBuffer);
|
|
2663
|
+
gl .bufferData (gl .ARRAY_BUFFER, this .colorArray, gl .STATIC_DRAW);
|
|
2664
|
+
}
|
|
2665
|
+
|
|
2666
|
+
if (this .texCoordAnim && this .texCoordArray .length)
|
|
2667
|
+
{
|
|
2668
|
+
var
|
|
2669
|
+
texCoordKeys = this .texCoordKeys,
|
|
2670
|
+
texCoordRamp = this .texCoordRamp;
|
|
2671
|
+
|
|
2672
|
+
var
|
|
2673
|
+
length = texCoordKeys .length,
|
|
2674
|
+
index0 = 0;
|
|
2675
|
+
|
|
2676
|
+
for (var i = 0; i < maxParticles; ++ i)
|
|
2677
|
+
{
|
|
2678
|
+
// Determine index0.
|
|
2679
|
+
|
|
2680
|
+
var
|
|
2681
|
+
particle = particles [i],
|
|
2682
|
+
fraction = particle .elapsedTime / particle .lifetime;
|
|
2683
|
+
|
|
2684
|
+
if (length == 1 || fraction <= texCoordKeys [0])
|
|
2685
|
+
{
|
|
2686
|
+
index0 = 0;
|
|
2687
|
+
}
|
|
2688
|
+
else if (fraction >= texCoordKeys .at (-1))
|
|
2689
|
+
{
|
|
2690
|
+
index0 = length - 2;
|
|
2691
|
+
}
|
|
2692
|
+
else
|
|
2693
|
+
{
|
|
2694
|
+
var index = Algorithm .upperBound (texCoordKeys, 0, length, fraction, Algorithm .less);
|
|
2695
|
+
|
|
2696
|
+
if (index < length)
|
|
2697
|
+
index0 = index - 1;
|
|
2698
|
+
else
|
|
2699
|
+
index0 = 0;
|
|
2700
|
+
}
|
|
2701
|
+
|
|
2702
|
+
// Set texCoord.
|
|
2703
|
+
|
|
2704
|
+
index0 *= this .texCoordCount;
|
|
2705
|
+
|
|
2706
|
+
var
|
|
2707
|
+
texCoord1 = texCoordRamp [index0],
|
|
2708
|
+
texCoord2 = texCoordRamp [index0 + 1],
|
|
2709
|
+
texCoord3 = texCoordRamp [index0 + 2],
|
|
2710
|
+
texCoord4 = texCoordRamp [index0 + 3],
|
|
2711
|
+
i24 = i * 24;
|
|
2712
|
+
|
|
2713
|
+
// p4 ------ p3
|
|
2714
|
+
// | / |
|
|
2715
|
+
// | / |
|
|
2716
|
+
// | / |
|
|
2717
|
+
// | / |
|
|
2718
|
+
// p1 ------ p2
|
|
2719
|
+
|
|
2720
|
+
// p1
|
|
2721
|
+
texCoordArray [i24] = texCoordArray [i24 + 12] = texCoord1 .x;
|
|
2722
|
+
texCoordArray [i24 + 1] = texCoordArray [i24 + 13] = texCoord1 .y;
|
|
2723
|
+
texCoordArray [i24 + 2] = texCoordArray [i24 + 14] = texCoord1 .z;
|
|
2724
|
+
texCoordArray [i24 + 3] = texCoordArray [i24 + 15] = texCoord1 .w;
|
|
2725
|
+
|
|
2726
|
+
// p2
|
|
2727
|
+
texCoordArray [i24 + 4] = texCoord2 .x;
|
|
2728
|
+
texCoordArray [i24 + 5] = texCoord2 .y;
|
|
2729
|
+
texCoordArray [i24 + 6] = texCoord2 .z;
|
|
2730
|
+
texCoordArray [i24 + 7] = texCoord2 .w;
|
|
2731
|
+
|
|
2732
|
+
// p3
|
|
2733
|
+
texCoordArray [i24 + 8] = texCoordArray [i24 + 16] = texCoord3 .x;
|
|
2734
|
+
texCoordArray [i24 + 9] = texCoordArray [i24 + 17] = texCoord3 .y;
|
|
2735
|
+
texCoordArray [i24 + 10] = texCoordArray [i24 + 18] = texCoord3 .z;
|
|
2736
|
+
texCoordArray [i24 + 11] = texCoordArray [i24 + 19] = texCoord3 .w;
|
|
2737
|
+
|
|
2738
|
+
// p4
|
|
2739
|
+
texCoordArray [i24 + 20] = texCoord4 .x;
|
|
2740
|
+
texCoordArray [i24 + 21] = texCoord4 .y;
|
|
2741
|
+
texCoordArray [i24 + 22] = texCoord4 .z;
|
|
2742
|
+
texCoordArray [i24 + 23] = texCoord4 .w;
|
|
2743
|
+
}
|
|
2744
|
+
|
|
2745
|
+
gl .bindBuffer (gl .ARRAY_BUFFER, this .texCoordBuffers [0]);
|
|
2746
|
+
gl .bufferData (gl .ARRAY_BUFFER, this .texCoordArray, gl .STATIC_DRAW);
|
|
2747
|
+
}
|
|
2748
|
+
}
|
|
2749
|
+
|
|
2750
|
+
// Vertices
|
|
2751
|
+
|
|
2752
|
+
if (this .geometryType === SPRITE)
|
|
2753
|
+
{
|
|
2754
|
+
if (modelViewMatrix) // if called from depth or draw
|
|
2755
|
+
{
|
|
2756
|
+
// Normals
|
|
2757
|
+
|
|
2758
|
+
var rotation = this .getScreenAlignedRotation (modelViewMatrix);
|
|
2759
|
+
|
|
2760
|
+
normal
|
|
2761
|
+
.set (rotation [0], rotation [1], rotation [2])
|
|
2762
|
+
.cross (vector .set (rotation [3], rotation [4], rotation [5]))
|
|
2763
|
+
.normalize ();
|
|
2764
|
+
|
|
2765
|
+
var
|
|
2766
|
+
nx = normal .x,
|
|
2767
|
+
ny = normal .y,
|
|
2768
|
+
nz = normal .z;
|
|
2769
|
+
|
|
2770
|
+
for (var i = 0, length = 6 * 3 * maxParticles; i < length; i += 3)
|
|
2771
|
+
{
|
|
2772
|
+
normalArray [i] = nx;
|
|
2773
|
+
normalArray [i + 1] = ny;
|
|
2774
|
+
normalArray [i + 2] = nz;
|
|
2775
|
+
}
|
|
2776
|
+
|
|
2777
|
+
gl .bindBuffer (gl .ARRAY_BUFFER, this .normalBuffer);
|
|
2778
|
+
gl .bufferData (gl .ARRAY_BUFFER, this .normalArray, gl .STATIC_DRAW);
|
|
2779
|
+
|
|
2780
|
+
// Vertices
|
|
2781
|
+
|
|
2782
|
+
s1 .set (-sx1_2, -sy1_2, 0);
|
|
2783
|
+
s2 .set ( sx1_2, -sy1_2, 0);
|
|
2784
|
+
s3 .set ( sx1_2, sy1_2, 0);
|
|
2785
|
+
s4 .set (-sx1_2, sy1_2, 0);
|
|
2786
|
+
|
|
2787
|
+
rotation .multVecMatrix (s1);
|
|
2788
|
+
rotation .multVecMatrix (s2);
|
|
2789
|
+
rotation .multVecMatrix (s3);
|
|
2790
|
+
rotation .multVecMatrix (s4);
|
|
2791
|
+
|
|
2792
|
+
for (var i = 0; i < numParticles; ++ i)
|
|
2793
|
+
{
|
|
2794
|
+
var
|
|
2795
|
+
position = particles [i] .position,
|
|
2796
|
+
elapsedTime = particles [i] .elapsedTime / particles [i] .lifetime,
|
|
2797
|
+
x = position .x,
|
|
2798
|
+
y = position .y,
|
|
2799
|
+
z = position .z,
|
|
2800
|
+
i6 = i * 6,
|
|
2801
|
+
i18 = i * 18,
|
|
2802
|
+
i24 = i * 24;
|
|
2803
|
+
|
|
2804
|
+
// p4 ------ p3
|
|
2805
|
+
// | / |
|
|
2806
|
+
// | / |
|
|
2807
|
+
// | / |
|
|
2808
|
+
// | / |
|
|
2809
|
+
// p1 ------ p2
|
|
2810
|
+
|
|
2811
|
+
|
|
2812
|
+
positionArray [i18] = positionArray [i18 + 3] = positionArray [i18 + 6] = positionArray [i18 + 9] = positionArray [i18 + 12] = positionArray [i18 + 15] = x;
|
|
2813
|
+
positionArray [i18 + 1] = positionArray [i18 + 4] = positionArray [i18 + 7] = positionArray [i18 + 10] = positionArray [i18 + 13] = positionArray [i18 + 16] = y;
|
|
2814
|
+
positionArray [i18 + 2] = positionArray [i18 + 5] = positionArray [i18 + 8] = positionArray [i18 + 11] = positionArray [i18 + 14] = positionArray [i18 + 17] = z;
|
|
2815
|
+
|
|
2816
|
+
elapsedTimeArray [i6] = elapsedTimeArray [i6 + 1] = elapsedTimeArray [i6 + 2] = elapsedTimeArray [i6 + 3] = elapsedTimeArray [i6 + 4] = elapsedTimeArray [i6 + 5] = elapsedTime;
|
|
2817
|
+
lifeArray [i6] = lifeArray [i6 + 1] = lifeArray [i6 + 2] = lifeArray [i6 + 3] = lifeArray [i6 + 4] = lifeArray [i6 + 5] = particles [i] .life;
|
|
2818
|
+
|
|
2819
|
+
// p1
|
|
2820
|
+
vertexArray [i24] = vertexArray [i24 + 12] = x + s1 .x;
|
|
2821
|
+
vertexArray [i24 + 1] = vertexArray [i24 + 13] = y + s1 .y;
|
|
2822
|
+
vertexArray [i24 + 2] = vertexArray [i24 + 14] = z + s1 .z;
|
|
2823
|
+
|
|
2824
|
+
// p2
|
|
2825
|
+
vertexArray [i24 + 4] = x + s2 .x;
|
|
2826
|
+
vertexArray [i24 + 5] = y + s2 .y;
|
|
2827
|
+
vertexArray [i24 + 6] = z + s2 .z;
|
|
2828
|
+
|
|
2829
|
+
// p3
|
|
2830
|
+
vertexArray [i24 + 8] = vertexArray [i24 + 16] = x + s3 .x;
|
|
2831
|
+
vertexArray [i24 + 9] = vertexArray [i24 + 17] = y + s3 .y;
|
|
2832
|
+
vertexArray [i24 + 10] = vertexArray [i24 + 18] = z + s3 .z;
|
|
2833
|
+
|
|
2834
|
+
// p4
|
|
2835
|
+
vertexArray [i24 + 20] = x + s4 .x;
|
|
2836
|
+
vertexArray [i24 + 21] = y + s4 .y;
|
|
2837
|
+
vertexArray [i24 + 22] = z + s4 .z;
|
|
2838
|
+
}
|
|
2839
|
+
|
|
2840
|
+
gl .bindBuffer (gl .ARRAY_BUFFER, this .positionBuffer);
|
|
2841
|
+
gl .bufferData (gl .ARRAY_BUFFER, this .positionArray, gl .STATIC_DRAW);
|
|
2842
|
+
gl .bindBuffer (gl .ARRAY_BUFFER, this .elapsedTimeBuffer);
|
|
2843
|
+
gl .bufferData (gl .ARRAY_BUFFER, this .elapsedTimeArray, gl .STATIC_DRAW);
|
|
2844
|
+
gl .bindBuffer (gl .ARRAY_BUFFER, this .lifeBuffer);
|
|
2845
|
+
gl .bufferData (gl .ARRAY_BUFFER, this .lifeArray, gl .STATIC_DRAW);
|
|
2846
|
+
gl .bindBuffer (gl .ARRAY_BUFFER, this .vertexBuffer);
|
|
2847
|
+
gl .bufferData (gl .ARRAY_BUFFER, this .vertexArray, gl .STATIC_DRAW);
|
|
2848
|
+
}
|
|
2849
|
+
}
|
|
2850
|
+
else
|
|
2851
|
+
{
|
|
2852
|
+
if (! modelViewMatrix) // if called from animateParticles
|
|
2853
|
+
{
|
|
2854
|
+
for (var i = 0; i < numParticles; ++ i)
|
|
2855
|
+
{
|
|
2856
|
+
var
|
|
2857
|
+
position = particles [i] .position,
|
|
2858
|
+
elapsedTime = particles [i] .elapsedTime / particles [i] .lifetime,
|
|
2859
|
+
x = position .x,
|
|
2860
|
+
y = position .y,
|
|
2861
|
+
z = position .z,
|
|
2862
|
+
i6 = i * 6,
|
|
2863
|
+
i18 = i * 18,
|
|
2864
|
+
i24 = i * 24;
|
|
2865
|
+
|
|
2866
|
+
// p4 ------ p3
|
|
2867
|
+
// | / |
|
|
2868
|
+
// | / |
|
|
2869
|
+
// | / |
|
|
2870
|
+
// | / |
|
|
2871
|
+
// p1 ------ p2
|
|
2872
|
+
|
|
2873
|
+
positionArray [i18] = positionArray [i18 + 3] = positionArray [i18 + 6] = positionArray [i18 + 9] = positionArray [i18 + 12] = positionArray [i18 + 15] = x;
|
|
2874
|
+
positionArray [i18 + 1] = positionArray [i18 + 4] = positionArray [i18 + 7] = positionArray [i18 + 10] = positionArray [i18 + 13] = positionArray [i18 + 16] = y;
|
|
2875
|
+
positionArray [i18 + 2] = positionArray [i18 + 5] = positionArray [i18 + 8] = positionArray [i18 + 11] = positionArray [i18 + 14] = positionArray [i18 + 17] = z;
|
|
2876
|
+
|
|
2877
|
+
elapsedTimeArray [i6] = elapsedTimeArray [i6 + 1] = elapsedTimeArray [i6 + 2] = elapsedTimeArray [i6 + 3] = elapsedTimeArray [i6 + 4] = elapsedTimeArray [i6 + 5] = elapsedTime;
|
|
2878
|
+
lifeArray [i6] = lifeArray [i6 + 1] = lifeArray [i6 + 2] = lifeArray [i6 + 3] = lifeArray [i6 + 4] = lifeArray [i6 + 5] = particles [i] .life;
|
|
2879
|
+
|
|
2880
|
+
// p1
|
|
2881
|
+
vertexArray [i24] = vertexArray [i24 + 12] = x - sx1_2;
|
|
2882
|
+
vertexArray [i24 + 1] = vertexArray [i24 + 13] = y - sy1_2;
|
|
2883
|
+
vertexArray [i24 + 2] = vertexArray [i24 + 14] = z;
|
|
2884
|
+
|
|
2885
|
+
// p2
|
|
2886
|
+
vertexArray [i24 + 4] = x + sx1_2;
|
|
2887
|
+
vertexArray [i24 + 5] = y - sy1_2;
|
|
2888
|
+
vertexArray [i24 + 6] = z;
|
|
2889
|
+
|
|
2890
|
+
// p3
|
|
2891
|
+
vertexArray [i24 + 8] = vertexArray [i24 + 16] = x + sx1_2;
|
|
2892
|
+
vertexArray [i24 + 9] = vertexArray [i24 + 17] = y + sy1_2;
|
|
2893
|
+
vertexArray [i24 + 10] = vertexArray [i24 + 18] = z;
|
|
2894
|
+
|
|
2895
|
+
// p4
|
|
2896
|
+
vertexArray [i24 + 20] = x - sx1_2;
|
|
2897
|
+
vertexArray [i24 + 21] = y + sy1_2;
|
|
2898
|
+
vertexArray [i24 + 22] = z;
|
|
2899
|
+
}
|
|
2900
|
+
|
|
2901
|
+
gl .bindBuffer (gl .ARRAY_BUFFER, this .positionBuffer);
|
|
2902
|
+
gl .bufferData (gl .ARRAY_BUFFER, this .positionArray, gl .STATIC_DRAW);
|
|
2903
|
+
gl .bindBuffer (gl .ARRAY_BUFFER, this .elapsedTimeBuffer);
|
|
2904
|
+
gl .bufferData (gl .ARRAY_BUFFER, this .elapsedTimeArray, gl .STATIC_DRAW);
|
|
2905
|
+
gl .bindBuffer (gl .ARRAY_BUFFER, this .lifeBuffer);
|
|
2906
|
+
gl .bufferData (gl .ARRAY_BUFFER, this .lifeArray, gl .STATIC_DRAW);
|
|
2907
|
+
gl .bindBuffer (gl .ARRAY_BUFFER, this .vertexBuffer);
|
|
2908
|
+
gl .bufferData (gl .ARRAY_BUFFER, this .vertexArray, gl .STATIC_DRAW);
|
|
2909
|
+
}
|
|
2910
|
+
}
|
|
2911
|
+
}
|
|
2912
|
+
catch (error)
|
|
2913
|
+
{
|
|
2914
|
+
console .log (error);
|
|
2915
|
+
}
|
|
2916
|
+
},
|
|
2917
|
+
traverse: function (type, renderObject)
|
|
2918
|
+
{
|
|
2919
|
+
if (! this .isActive_ .getValue ())
|
|
2920
|
+
return;
|
|
2921
|
+
|
|
2922
|
+
switch (type)
|
|
2923
|
+
{
|
|
2924
|
+
case TraverseType .POINTER:
|
|
2925
|
+
{
|
|
2926
|
+
break;
|
|
2927
|
+
}
|
|
2928
|
+
case TraverseType .PICKING:
|
|
2929
|
+
{
|
|
2930
|
+
break;
|
|
2931
|
+
}
|
|
2932
|
+
case TraverseType .COLLISION:
|
|
2933
|
+
{
|
|
2934
|
+
// TODO: to be implemented.
|
|
2935
|
+
break;
|
|
2936
|
+
}
|
|
2937
|
+
case TraverseType .SHADOW:
|
|
2938
|
+
{
|
|
2939
|
+
if (this .castShadow_ .getValue ())
|
|
2940
|
+
renderObject .addDepthShape (this);
|
|
2941
|
+
|
|
2942
|
+
break;
|
|
2943
|
+
}
|
|
2944
|
+
case TraverseType .DISPLAY:
|
|
2945
|
+
{
|
|
2946
|
+
if (renderObject .addDisplayShape (this))
|
|
2947
|
+
this .getAppearance () .traverse (type, renderObject); // Currently used for GeneratedCubeMapTexture.
|
|
2948
|
+
|
|
2949
|
+
break;
|
|
2950
|
+
}
|
|
2951
|
+
}
|
|
2952
|
+
|
|
2953
|
+
if (this .geometryType === GEOMETRY)
|
|
2954
|
+
{
|
|
2955
|
+
if (this .getGeometry ())
|
|
2956
|
+
this .getGeometry () .traverse (type, renderObject); // Currently used for ScreenText.
|
|
2957
|
+
}
|
|
2958
|
+
},
|
|
2959
|
+
depth: function (gl, context, shaderNode)
|
|
2960
|
+
{
|
|
2961
|
+
// Update geometry if SPRITE.
|
|
2962
|
+
|
|
2963
|
+
this .updateGeometry (context .modelViewMatrix);
|
|
2964
|
+
|
|
2965
|
+
// Display geometry.
|
|
2966
|
+
|
|
2967
|
+
if (this .geometryType === GEOMETRY)
|
|
2968
|
+
{
|
|
2969
|
+
var geometryNode = this .getGeometry ();
|
|
2970
|
+
|
|
2971
|
+
if (geometryNode)
|
|
2972
|
+
geometryNode .displayParticlesDepth (gl, context, shaderNode, this .particles, this .numParticles);
|
|
2973
|
+
}
|
|
2974
|
+
else
|
|
2975
|
+
{
|
|
2976
|
+
if (this .numParticles <= 0)
|
|
2977
|
+
return;
|
|
2978
|
+
|
|
2979
|
+
if (shaderNode .getValid ())
|
|
2980
|
+
{
|
|
2981
|
+
// Setup vertex attributes.
|
|
2982
|
+
|
|
2983
|
+
shaderNode .enableFloatAttrib (gl, "x3d_ParticleId", this .idBuffer, 1);
|
|
2984
|
+
shaderNode .enableFloatAttrib (gl, "x3d_ParticlePosition", this .positionBuffer, 3);
|
|
2985
|
+
shaderNode .enableFloatAttrib (gl, "x3d_ParticleElapsedTime", this .elapsedTimeBuffer, 1);
|
|
2986
|
+
shaderNode .enableFloatAttrib (gl, "x3d_ParticleLife", this .lifeBuffer, 1);
|
|
2987
|
+
shaderNode .enableVertexAttribute (gl, this .vertexBuffer);
|
|
2988
|
+
|
|
2989
|
+
gl .drawArrays (this .primitiveMode, 0, this .numParticles * this .vertexCount);
|
|
2990
|
+
|
|
2991
|
+
shaderNode .disableFloatAttrib (gl, "x3d_ParticleId");
|
|
2992
|
+
shaderNode .disableFloatAttrib (gl, "x3d_ParticlePosition");
|
|
2993
|
+
shaderNode .disableFloatAttrib (gl, "x3d_ParticleElapsedTime");
|
|
2994
|
+
shaderNode .disableFloatAttrib (gl, "x3d_ParticleLife");
|
|
2995
|
+
}
|
|
2996
|
+
}
|
|
2997
|
+
},
|
|
2998
|
+
display: function (gl, context)
|
|
2999
|
+
{
|
|
3000
|
+
try
|
|
3001
|
+
{
|
|
3002
|
+
if (this .numParticles <= 0)
|
|
3003
|
+
return;
|
|
3004
|
+
|
|
3005
|
+
// Update geometry if SPRITE.
|
|
3006
|
+
|
|
3007
|
+
this .updateGeometry (context .modelViewMatrix);
|
|
3008
|
+
|
|
3009
|
+
// Display geometry.
|
|
3010
|
+
|
|
3011
|
+
if (this .geometryType === GEOMETRY)
|
|
3012
|
+
{
|
|
3013
|
+
const geometryNode = this .getGeometry ();
|
|
3014
|
+
|
|
3015
|
+
if (geometryNode)
|
|
3016
|
+
geometryNode .displayParticles (gl, context, this .particles, this .numParticles);
|
|
3017
|
+
}
|
|
3018
|
+
else
|
|
3019
|
+
{
|
|
3020
|
+
const
|
|
3021
|
+
appearanceNode = this .getAppearance (),
|
|
3022
|
+
shaderNode = appearanceNode .shaderNode || this .shaderNode || appearanceNode .materialNode .getShader (context .browser, context .shadow);
|
|
3023
|
+
|
|
3024
|
+
// Setup shader.
|
|
3025
|
+
|
|
3026
|
+
if (shaderNode .getValid ())
|
|
3027
|
+
{
|
|
3028
|
+
context .geometryContext = this .geometryContext;
|
|
3029
|
+
|
|
3030
|
+
const blendModeNode = appearanceNode .blendModeNode;
|
|
3031
|
+
|
|
3032
|
+
if (blendModeNode)
|
|
3033
|
+
blendModeNode .enable (gl);
|
|
3034
|
+
|
|
3035
|
+
shaderNode .enable (gl);
|
|
3036
|
+
shaderNode .setLocalUniforms (gl, context);
|
|
3037
|
+
|
|
3038
|
+
// Setup vertex attributes.
|
|
3039
|
+
|
|
3040
|
+
shaderNode .enableFloatAttrib (gl, "x3d_ParticleId", this .idBuffer, 1);
|
|
3041
|
+
shaderNode .enableFloatAttrib (gl, "x3d_ParticlePosition", this .positionBuffer, 3);
|
|
3042
|
+
shaderNode .enableFloatAttrib (gl, "x3d_ParticleElapsedTime", this .elapsedTimeBuffer, 1);
|
|
3043
|
+
shaderNode .enableFloatAttrib (gl, "x3d_ParticleLife", this .lifeBuffer, 1);
|
|
3044
|
+
|
|
3045
|
+
if (this .geometryContext .colorMaterial)
|
|
3046
|
+
shaderNode .enableColorAttribute (gl, this .colorBuffer);
|
|
3047
|
+
|
|
3048
|
+
if (this .texCoordArray .length)
|
|
3049
|
+
shaderNode .enableTexCoordAttribute (gl, this .texCoordBuffers);
|
|
3050
|
+
|
|
3051
|
+
if (this .normalArray .length)
|
|
3052
|
+
shaderNode .enableNormalAttribute (gl, this .normalBuffer);
|
|
3053
|
+
|
|
3054
|
+
shaderNode .enableVertexAttribute (gl, this .vertexBuffer);
|
|
3055
|
+
|
|
3056
|
+
if (shaderNode .wireframe && this .testWireframe)
|
|
3057
|
+
{
|
|
3058
|
+
// Wireframes are always solid so only one drawing call is needed.
|
|
3059
|
+
|
|
3060
|
+
for (var i = 0, length = this .numParticles * this .vertexCount; i < length; i += 3)
|
|
3061
|
+
gl .drawArrays (shaderNode .primitiveMode, i, 3);
|
|
3062
|
+
}
|
|
3063
|
+
else
|
|
3064
|
+
{
|
|
3065
|
+
const positiveScale = Matrix4 .prototype .determinant3 .call (context .modelViewMatrix) > 0;
|
|
3066
|
+
|
|
3067
|
+
gl .frontFace (positiveScale ? gl .CCW : gl .CW);
|
|
3068
|
+
gl .enable (gl .CULL_FACE);
|
|
3069
|
+
gl .cullFace (gl .BACK);
|
|
3070
|
+
|
|
3071
|
+
gl .drawArrays (this .primitiveMode, 0, this .numParticles * this .vertexCount);
|
|
3072
|
+
}
|
|
3073
|
+
|
|
3074
|
+
shaderNode .disableFloatAttrib (gl, "x3d_ParticleId");
|
|
3075
|
+
shaderNode .disableFloatAttrib (gl, "x3d_ParticlePosition");
|
|
3076
|
+
shaderNode .disableFloatAttrib (gl, "x3d_ParticleElapsedTime");
|
|
3077
|
+
shaderNode .disableFloatAttrib (gl, "x3d_ParticleLife");
|
|
3078
|
+
|
|
3079
|
+
shaderNode .disableColorAttribute (gl);
|
|
3080
|
+
shaderNode .disableTexCoordAttribute (gl);
|
|
3081
|
+
shaderNode .disableNormalAttribute (gl);
|
|
3082
|
+
shaderNode .disable (gl);
|
|
3083
|
+
|
|
3084
|
+
if (blendModeNode)
|
|
3085
|
+
blendModeNode .disable (gl);
|
|
3086
|
+
|
|
3087
|
+
context .geometryContext = null;
|
|
3088
|
+
}
|
|
3089
|
+
}
|
|
3090
|
+
}
|
|
3091
|
+
catch (error)
|
|
3092
|
+
{
|
|
3093
|
+
// Catch error from setLocalUniforms.
|
|
3094
|
+
console .log (error);
|
|
3095
|
+
}
|
|
3096
|
+
},
|
|
3097
|
+
getScreenAlignedRotation: function (modelViewMatrix)
|
|
3098
|
+
{
|
|
3099
|
+
invModelViewMatrix .assign (modelViewMatrix) .inverse ();
|
|
3100
|
+
|
|
3101
|
+
invModelViewMatrix .multDirMatrix (billboardToScreen .assign (Vector3 .zAxis));
|
|
3102
|
+
invModelViewMatrix .multDirMatrix (viewerYAxis .assign (Vector3 .yAxis));
|
|
3103
|
+
|
|
3104
|
+
x .assign (viewerYAxis) .cross (billboardToScreen);
|
|
3105
|
+
y .assign (billboardToScreen) .cross (x);
|
|
3106
|
+
var z = billboardToScreen;
|
|
3107
|
+
|
|
3108
|
+
// Compose rotation
|
|
3109
|
+
|
|
3110
|
+
x .normalize ();
|
|
3111
|
+
y .normalize ();
|
|
3112
|
+
z .normalize ();
|
|
3113
|
+
|
|
3114
|
+
return this .rotation .set (x .x, x .y, x .z,
|
|
3115
|
+
y .x, y .y, y .z,
|
|
3116
|
+
z .x, z .y, z .z);
|
|
3117
|
+
},
|
|
3118
|
+
});
|
|
3119
|
+
|
|
3120
|
+
return ParticleSystem;
|
|
3121
|
+
});
|
|
3122
|
+
|
|
3123
|
+
/* -*- Mode: JavaScript; coding: utf-8; tab-width: 3; indent-tabs-mode: tab; c-basic-offset: 3 -*-
|
|
3124
|
+
*******************************************************************************
|
|
3125
|
+
*
|
|
3126
|
+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
3127
|
+
*
|
|
3128
|
+
* Copyright create3000, Scheffelstraße 31a, Leipzig, Germany 2011.
|
|
3129
|
+
*
|
|
3130
|
+
* All rights reserved. Holger Seelig <holger.seelig@yahoo.de>.
|
|
3131
|
+
*
|
|
3132
|
+
* The copyright notice above does not evidence any actual of intended
|
|
3133
|
+
* publication of such source code, and is an unpublished work by create3000.
|
|
3134
|
+
* This material contains CONFIDENTIAL INFORMATION that is the property of
|
|
3135
|
+
* create3000.
|
|
3136
|
+
*
|
|
3137
|
+
* No permission is granted to copy, distribute, or create derivative works from
|
|
3138
|
+
* the contents of this software, in whole or in part, without the prior written
|
|
3139
|
+
* permission of create3000.
|
|
3140
|
+
*
|
|
3141
|
+
* NON-MILITARY USE ONLY
|
|
3142
|
+
*
|
|
3143
|
+
* All create3000 software are effectively free software with a non-military use
|
|
3144
|
+
* restriction. It is free. Well commented source is provided. You may reuse the
|
|
3145
|
+
* source in any way you please with the exception anything that uses it must be
|
|
3146
|
+
* marked to indicate is contains 'non-military use only' components.
|
|
3147
|
+
*
|
|
3148
|
+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
3149
|
+
*
|
|
3150
|
+
* Copyright 2015, 2016 Holger Seelig <holger.seelig@yahoo.de>.
|
|
3151
|
+
*
|
|
3152
|
+
* This file is part of the X_ITE Project.
|
|
3153
|
+
*
|
|
3154
|
+
* X_ITE is free software: you can redistribute it and/or modify it under the
|
|
3155
|
+
* terms of the GNU General Public License version 3 only, as published by the
|
|
3156
|
+
* Free Software Foundation.
|
|
3157
|
+
*
|
|
3158
|
+
* X_ITE is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
3159
|
+
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
|
3160
|
+
* A PARTICULAR PURPOSE. See the GNU General Public License version 3 for more
|
|
3161
|
+
* details (a copy is included in the LICENSE file that accompanied this code).
|
|
3162
|
+
*
|
|
3163
|
+
* You should have received a copy of the GNU General Public License version 3
|
|
3164
|
+
* along with X_ITE. If not, see <http://www.gnu.org/licenses/gpl.html> for a
|
|
3165
|
+
* copy of the GPLv3 License.
|
|
3166
|
+
*
|
|
3167
|
+
* For Silvio, Joy and Adi.
|
|
3168
|
+
*
|
|
3169
|
+
******************************************************************************/
|
|
3170
|
+
|
|
3171
|
+
|
|
3172
|
+
define ('x_ite/Components/ParticleSystems/PolylineEmitter',[
|
|
3173
|
+
"x_ite/Fields",
|
|
3174
|
+
"x_ite/Basic/X3DFieldDefinition",
|
|
3175
|
+
"x_ite/Basic/FieldDefinitionArray",
|
|
3176
|
+
"x_ite/Components/ParticleSystems/X3DParticleEmitterNode",
|
|
3177
|
+
"x_ite/Components/Rendering/IndexedLineSet",
|
|
3178
|
+
"x_ite/Bits/X3DConstants",
|
|
3179
|
+
"standard/Math/Numbers/Vector3",
|
|
3180
|
+
"standard/Math/Algorithm",
|
|
3181
|
+
],
|
|
3182
|
+
function (Fields,
|
|
3183
|
+
X3DFieldDefinition,
|
|
3184
|
+
FieldDefinitionArray,
|
|
3185
|
+
X3DParticleEmitterNode,
|
|
3186
|
+
IndexedLineSet,
|
|
3187
|
+
X3DConstants,
|
|
3188
|
+
Vector3,
|
|
3189
|
+
Algorithm)
|
|
3190
|
+
{
|
|
3191
|
+
"use strict";
|
|
3192
|
+
|
|
3193
|
+
function PolylineEmitter (executionContext)
|
|
3194
|
+
{
|
|
3195
|
+
X3DParticleEmitterNode .call (this, executionContext);
|
|
3196
|
+
|
|
3197
|
+
this .addType (X3DConstants .PolylineEmitter);
|
|
3198
|
+
|
|
3199
|
+
this .speed_ .setUnit ("speed");
|
|
3200
|
+
this .mass_ .setUnit ("mass");
|
|
3201
|
+
this .surfaceArea_ .setUnit ("area");
|
|
3202
|
+
|
|
3203
|
+
this .direction = new Vector3 (0, 0, 0);
|
|
3204
|
+
this .polylineNode = new IndexedLineSet (executionContext);
|
|
3205
|
+
this .polylines = [ ];
|
|
3206
|
+
this .lengthSoFarArray = [ 0 ];
|
|
3207
|
+
}
|
|
3208
|
+
|
|
3209
|
+
PolylineEmitter .prototype = Object .assign (Object .create (X3DParticleEmitterNode .prototype),
|
|
3210
|
+
{
|
|
3211
|
+
constructor: PolylineEmitter,
|
|
3212
|
+
fieldDefinitions: new FieldDefinitionArray ([
|
|
3213
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "metadata", new Fields .SFNode ()),
|
|
3214
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "direction", new Fields .SFVec3f (0, 1, 0)),
|
|
3215
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "speed", new Fields .SFFloat ()),
|
|
3216
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "variation", new Fields .SFFloat (0.25)),
|
|
3217
|
+
new X3DFieldDefinition (X3DConstants .initializeOnly, "mass", new Fields .SFFloat ()),
|
|
3218
|
+
new X3DFieldDefinition (X3DConstants .initializeOnly, "surfaceArea", new Fields .SFFloat ()),
|
|
3219
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "coordIndex", new Fields .MFInt32 (-1)),
|
|
3220
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "coord", new Fields .SFNode ()),
|
|
3221
|
+
]),
|
|
3222
|
+
getTypeName: function ()
|
|
3223
|
+
{
|
|
3224
|
+
return "PolylineEmitter";
|
|
3225
|
+
},
|
|
3226
|
+
getComponentName: function ()
|
|
3227
|
+
{
|
|
3228
|
+
return "ParticleSystems";
|
|
3229
|
+
},
|
|
3230
|
+
getContainerField: function ()
|
|
3231
|
+
{
|
|
3232
|
+
return "emitter";
|
|
3233
|
+
},
|
|
3234
|
+
initialize: function ()
|
|
3235
|
+
{
|
|
3236
|
+
X3DParticleEmitterNode .prototype .initialize .call (this);
|
|
3237
|
+
|
|
3238
|
+
this .direction_ .addInterest ("set_direction__", this);
|
|
3239
|
+
|
|
3240
|
+
this .coordIndex_ .addFieldInterest (this .polylineNode .coordIndex_);
|
|
3241
|
+
this .coord_ .addFieldInterest (this .polylineNode .coord_);
|
|
3242
|
+
|
|
3243
|
+
this .polylineNode .coordIndex_ = this .coordIndex_;
|
|
3244
|
+
this .polylineNode .coord_ = this .coord_;
|
|
3245
|
+
|
|
3246
|
+
this .polylineNode .rebuild_ .addInterest ("set_polyline", this);
|
|
3247
|
+
this .polylineNode .setPrivate (true);
|
|
3248
|
+
this .polylineNode .setup ();
|
|
3249
|
+
|
|
3250
|
+
this .set_direction__ ();
|
|
3251
|
+
this .set_polyline ();
|
|
3252
|
+
},
|
|
3253
|
+
set_direction__: function ()
|
|
3254
|
+
{
|
|
3255
|
+
this .direction .assign (this .direction_ .getValue ()) .normalize ();
|
|
3256
|
+
|
|
3257
|
+
if (this .direction .equals (Vector3 .Zero))
|
|
3258
|
+
this .getRandomVelocity = this .getSphericalRandomVelocity;
|
|
3259
|
+
else
|
|
3260
|
+
delete this .getRandomVelocity;
|
|
3261
|
+
},
|
|
3262
|
+
set_polyline: (function ()
|
|
3263
|
+
{
|
|
3264
|
+
var
|
|
3265
|
+
vertex1 = new Vector3 (0, 0, 0),
|
|
3266
|
+
vertex2 = new Vector3 (0, 0, 0);
|
|
3267
|
+
|
|
3268
|
+
return function ()
|
|
3269
|
+
{
|
|
3270
|
+
var vertices = this .vertices = this .polylineNode .getVertices () .getValue ();
|
|
3271
|
+
|
|
3272
|
+
if (vertices .length)
|
|
3273
|
+
{
|
|
3274
|
+
delete this .getRandomPosition;
|
|
3275
|
+
|
|
3276
|
+
var
|
|
3277
|
+
lengthSoFar = 0,
|
|
3278
|
+
lengthSoFarArray = this .lengthSoFarArray;
|
|
3279
|
+
|
|
3280
|
+
lengthSoFarArray .length = 1;
|
|
3281
|
+
|
|
3282
|
+
for (var i = 0, length = vertices .length; i < length; i += 8)
|
|
3283
|
+
{
|
|
3284
|
+
vertex1 .set (vertices [i], vertices [i + 1], vertices [i + 2]);
|
|
3285
|
+
vertex2 .set (vertices [i + 4], vertices [i + 5], vertices [i + 6]);
|
|
3286
|
+
|
|
3287
|
+
lengthSoFar += vertex2 .subtract (vertex1) .abs ();
|
|
3288
|
+
lengthSoFarArray .push (lengthSoFar);
|
|
3289
|
+
}
|
|
3290
|
+
}
|
|
3291
|
+
else
|
|
3292
|
+
{
|
|
3293
|
+
this .getRandomPosition = getPosition;
|
|
3294
|
+
}
|
|
3295
|
+
};
|
|
3296
|
+
})(),
|
|
3297
|
+
getRandomPosition: function (position)
|
|
3298
|
+
{
|
|
3299
|
+
// Determine index0 and weight.
|
|
3300
|
+
|
|
3301
|
+
var
|
|
3302
|
+
lengthSoFarArray = this .lengthSoFarArray,
|
|
3303
|
+
length = lengthSoFarArray .length,
|
|
3304
|
+
fraction = Math .random () * lengthSoFarArray .at (-1),
|
|
3305
|
+
index0 = 0,
|
|
3306
|
+
index1 = 0,
|
|
3307
|
+
weight = 0;
|
|
3308
|
+
|
|
3309
|
+
if (length == 1 || fraction <= lengthSoFarArray [0])
|
|
3310
|
+
{
|
|
3311
|
+
index0 = 0;
|
|
3312
|
+
weight = 0;
|
|
3313
|
+
}
|
|
3314
|
+
else if (fraction >= lengthSoFarArray .at (-1))
|
|
3315
|
+
{
|
|
3316
|
+
index0 = length - 2;
|
|
3317
|
+
weight = 1;
|
|
3318
|
+
}
|
|
3319
|
+
else
|
|
3320
|
+
{
|
|
3321
|
+
var index = Algorithm .upperBound (lengthSoFarArray, 0, length, fraction, Algorithm .less);
|
|
3322
|
+
|
|
3323
|
+
if (index < length)
|
|
3324
|
+
{
|
|
3325
|
+
index1 = index;
|
|
3326
|
+
index0 = index - 1;
|
|
3327
|
+
|
|
3328
|
+
var
|
|
3329
|
+
key0 = lengthSoFarArray [index0],
|
|
3330
|
+
key1 = lengthSoFarArray [index1];
|
|
3331
|
+
|
|
3332
|
+
weight = Algorithm .clamp ((fraction - key0) / (key1 - key0), 0, 1);
|
|
3333
|
+
}
|
|
3334
|
+
else
|
|
3335
|
+
{
|
|
3336
|
+
index0 = 0;
|
|
3337
|
+
weight = 0;
|
|
3338
|
+
}
|
|
3339
|
+
}
|
|
3340
|
+
|
|
3341
|
+
// Interpolate and set position.
|
|
3342
|
+
|
|
3343
|
+
index0 *= 8;
|
|
3344
|
+
index1 = index0 + 4;
|
|
3345
|
+
|
|
3346
|
+
var
|
|
3347
|
+
vertices = this .vertices,
|
|
3348
|
+
x1 = vertices [index0],
|
|
3349
|
+
y1 = vertices [index0 + 1],
|
|
3350
|
+
z1 = vertices [index0 + 2],
|
|
3351
|
+
x2 = vertices [index1],
|
|
3352
|
+
y2 = vertices [index1 + 1],
|
|
3353
|
+
z2 = vertices [index1 + 2];
|
|
3354
|
+
|
|
3355
|
+
position .x = x1 + weight * (x2 - x1);
|
|
3356
|
+
position .y = y1 + weight * (y2 - y1);
|
|
3357
|
+
position .z = z1 + weight * (z2 - z1);
|
|
3358
|
+
|
|
3359
|
+
return position;
|
|
3360
|
+
},
|
|
3361
|
+
getRandomVelocity: function (velocity)
|
|
3362
|
+
{
|
|
3363
|
+
var
|
|
3364
|
+
direction = this .direction,
|
|
3365
|
+
speed = this .getRandomSpeed ();
|
|
3366
|
+
|
|
3367
|
+
velocity .x = direction .x * speed;
|
|
3368
|
+
velocity .y = direction .y * speed;
|
|
3369
|
+
velocity .z = direction .z * speed;
|
|
3370
|
+
|
|
3371
|
+
return velocity;
|
|
3372
|
+
},
|
|
3373
|
+
});
|
|
3374
|
+
|
|
3375
|
+
function getPosition (position)
|
|
3376
|
+
{
|
|
3377
|
+
return position .set (0, 0, 0);
|
|
3378
|
+
}
|
|
3379
|
+
|
|
3380
|
+
return PolylineEmitter;
|
|
3381
|
+
});
|
|
3382
|
+
|
|
3383
|
+
/* -*- Mode: JavaScript; coding: utf-8; tab-width: 3; indent-tabs-mode: tab; c-basic-offset: 3 -*-
|
|
3384
|
+
*******************************************************************************
|
|
3385
|
+
*
|
|
3386
|
+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
3387
|
+
*
|
|
3388
|
+
* Copyright create3000, Scheffelstraße 31a, Leipzig, Germany 2011.
|
|
3389
|
+
*
|
|
3390
|
+
* All rights reserved. Holger Seelig <holger.seelig@yahoo.de>.
|
|
3391
|
+
*
|
|
3392
|
+
* The copyright notice above does not evidence any actual of intended
|
|
3393
|
+
* publication of such source code, and is an unpublished work by create3000.
|
|
3394
|
+
* This material contains CONFIDENTIAL INFORMATION that is the property of
|
|
3395
|
+
* create3000.
|
|
3396
|
+
*
|
|
3397
|
+
* No permission is granted to copy, distribute, or create derivative works from
|
|
3398
|
+
* the contents of this software, in whole or in part, without the prior written
|
|
3399
|
+
* permission of create3000.
|
|
3400
|
+
*
|
|
3401
|
+
* NON-MILITARY USE ONLY
|
|
3402
|
+
*
|
|
3403
|
+
* All create3000 software are effectively free software with a non-military use
|
|
3404
|
+
* restriction. It is free. Well commented source is provided. You may reuse the
|
|
3405
|
+
* source in any way you please with the exception anything that uses it must be
|
|
3406
|
+
* marked to indicate is contains 'non-military use only' components.
|
|
3407
|
+
*
|
|
3408
|
+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
3409
|
+
*
|
|
3410
|
+
* Copyright 2015, 2016 Holger Seelig <holger.seelig@yahoo.de>.
|
|
3411
|
+
*
|
|
3412
|
+
* This file is part of the X_ITE Project.
|
|
3413
|
+
*
|
|
3414
|
+
* X_ITE is free software: you can redistribute it and/or modify it under the
|
|
3415
|
+
* terms of the GNU General Public License version 3 only, as published by the
|
|
3416
|
+
* Free Software Foundation.
|
|
3417
|
+
*
|
|
3418
|
+
* X_ITE is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
3419
|
+
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
|
3420
|
+
* A PARTICULAR PURPOSE. See the GNU General Public License version 3 for more
|
|
3421
|
+
* details (a copy is included in the LICENSE file that accompanied this code).
|
|
3422
|
+
*
|
|
3423
|
+
* You should have received a copy of the GNU General Public License version 3
|
|
3424
|
+
* along with X_ITE. If not, see <http://www.gnu.org/licenses/gpl.html> for a
|
|
3425
|
+
* copy of the GPLv3 License.
|
|
3426
|
+
*
|
|
3427
|
+
* For Silvio, Joy and Adi.
|
|
3428
|
+
*
|
|
3429
|
+
******************************************************************************/
|
|
3430
|
+
|
|
3431
|
+
|
|
3432
|
+
define ('x_ite/Components/ParticleSystems/SurfaceEmitter',[
|
|
3433
|
+
"x_ite/Fields",
|
|
3434
|
+
"x_ite/Basic/X3DFieldDefinition",
|
|
3435
|
+
"x_ite/Basic/FieldDefinitionArray",
|
|
3436
|
+
"x_ite/Components/ParticleSystems/X3DParticleEmitterNode",
|
|
3437
|
+
"x_ite/Bits/X3DConstants",
|
|
3438
|
+
"x_ite/Bits/X3DCast",
|
|
3439
|
+
"standard/Math/Geometry/Triangle3",
|
|
3440
|
+
"standard/Math/Numbers/Vector3",
|
|
3441
|
+
"standard/Math/Algorithm",
|
|
3442
|
+
],
|
|
3443
|
+
function (Fields,
|
|
3444
|
+
X3DFieldDefinition,
|
|
3445
|
+
FieldDefinitionArray,
|
|
3446
|
+
X3DParticleEmitterNode,
|
|
3447
|
+
X3DConstants,
|
|
3448
|
+
X3DCast,
|
|
3449
|
+
Triangle3,
|
|
3450
|
+
Vector3,
|
|
3451
|
+
Algorithm)
|
|
3452
|
+
{
|
|
3453
|
+
"use strict";
|
|
3454
|
+
|
|
3455
|
+
function SurfaceEmitter (executionContext)
|
|
3456
|
+
{
|
|
3457
|
+
X3DParticleEmitterNode .call (this, executionContext);
|
|
3458
|
+
|
|
3459
|
+
this .addType (X3DConstants .SurfaceEmitter);
|
|
3460
|
+
|
|
3461
|
+
this .speed_ .setUnit ("speed");
|
|
3462
|
+
this .mass_ .setUnit ("mass");
|
|
3463
|
+
this .surfaceArea_ .setUnit ("area");
|
|
3464
|
+
|
|
3465
|
+
this .surfaceNode = null;
|
|
3466
|
+
this .areaSoFarArray = [ 0 ];
|
|
3467
|
+
this .direction = new Vector3 (0, 0, 0);
|
|
3468
|
+
}
|
|
3469
|
+
|
|
3470
|
+
SurfaceEmitter .prototype = Object .assign (Object .create (X3DParticleEmitterNode .prototype),
|
|
3471
|
+
{
|
|
3472
|
+
constructor: SurfaceEmitter,
|
|
3473
|
+
fieldDefinitions: new FieldDefinitionArray ([
|
|
3474
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "metadata", new Fields .SFNode ()),
|
|
3475
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "speed", new Fields .SFFloat ()),
|
|
3476
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "variation", new Fields .SFFloat (0.25)),
|
|
3477
|
+
new X3DFieldDefinition (X3DConstants .initializeOnly, "mass", new Fields .SFFloat ()),
|
|
3478
|
+
new X3DFieldDefinition (X3DConstants .initializeOnly, "surfaceArea", new Fields .SFFloat ()),
|
|
3479
|
+
new X3DFieldDefinition (X3DConstants .initializeOnly, "surface", new Fields .SFNode ()),
|
|
3480
|
+
]),
|
|
3481
|
+
getTypeName: function ()
|
|
3482
|
+
{
|
|
3483
|
+
return "SurfaceEmitter";
|
|
3484
|
+
},
|
|
3485
|
+
getComponentName: function ()
|
|
3486
|
+
{
|
|
3487
|
+
return "ParticleSystems";
|
|
3488
|
+
},
|
|
3489
|
+
getContainerField: function ()
|
|
3490
|
+
{
|
|
3491
|
+
return "emitter";
|
|
3492
|
+
},
|
|
3493
|
+
initialize: function ()
|
|
3494
|
+
{
|
|
3495
|
+
X3DParticleEmitterNode .prototype .initialize .call (this);
|
|
3496
|
+
|
|
3497
|
+
this .surface_ .addInterest ("set_surface__", this);
|
|
3498
|
+
|
|
3499
|
+
this .set_surface__ ();
|
|
3500
|
+
},
|
|
3501
|
+
set_surface__: function ()
|
|
3502
|
+
{
|
|
3503
|
+
if (this .surfaceNode)
|
|
3504
|
+
this .surfaceNode .rebuild_ .removeInterest ("set_geometry__", this);
|
|
3505
|
+
|
|
3506
|
+
this .surfaceNode = X3DCast (X3DConstants .X3DGeometryNode, this .surface_);
|
|
3507
|
+
|
|
3508
|
+
if (this .surfaceNode)
|
|
3509
|
+
this .surfaceNode .rebuild_ .addInterest ("set_geometry__", this);
|
|
3510
|
+
|
|
3511
|
+
this .set_geometry__ ();
|
|
3512
|
+
},
|
|
3513
|
+
set_geometry__: (function ()
|
|
3514
|
+
{
|
|
3515
|
+
var
|
|
3516
|
+
vertex1 = new Vector3 (0, 0, 0),
|
|
3517
|
+
vertex2 = new Vector3 (0, 0, 0),
|
|
3518
|
+
vertex3 = new Vector3 (0, 0, 0);
|
|
3519
|
+
|
|
3520
|
+
return function ()
|
|
3521
|
+
{
|
|
3522
|
+
if (this .surfaceNode)
|
|
3523
|
+
{
|
|
3524
|
+
delete this .getRandomPosition;
|
|
3525
|
+
delete this .getRandomVelocity;
|
|
3526
|
+
|
|
3527
|
+
var
|
|
3528
|
+
areaSoFar = 0,
|
|
3529
|
+
areaSoFarArray = this .areaSoFarArray,
|
|
3530
|
+
vertices = this .surfaceNode .getVertices () .getValue ();
|
|
3531
|
+
|
|
3532
|
+
this .normals = this .surfaceNode .getNormals () .getValue ();
|
|
3533
|
+
this .vertices = vertices;
|
|
3534
|
+
|
|
3535
|
+
areaSoFarArray .length = 1;
|
|
3536
|
+
|
|
3537
|
+
for (var i = 0, length = vertices .length; i < length; i += 12)
|
|
3538
|
+
{
|
|
3539
|
+
vertex1 .set (vertices [i], vertices [i + 1], vertices [i + 2]);
|
|
3540
|
+
vertex2 .set (vertices [i + 4], vertices [i + 5], vertices [i + 6]);
|
|
3541
|
+
vertex3 .set (vertices [i + 8], vertices [i + 9], vertices [i + 10]);
|
|
3542
|
+
|
|
3543
|
+
areaSoFar += Triangle3 .area (vertex1, vertex2, vertex3);
|
|
3544
|
+
areaSoFarArray .push (areaSoFar);
|
|
3545
|
+
}
|
|
3546
|
+
}
|
|
3547
|
+
else
|
|
3548
|
+
{
|
|
3549
|
+
this .getRandomPosition = getPosition;
|
|
3550
|
+
this .getRandomVelocity = this .getSphericalRandomVelocity;
|
|
3551
|
+
}
|
|
3552
|
+
};
|
|
3553
|
+
})(),
|
|
3554
|
+
getRandomPosition: function (position)
|
|
3555
|
+
{
|
|
3556
|
+
// Determine index0.
|
|
3557
|
+
|
|
3558
|
+
var
|
|
3559
|
+
areaSoFarArray = this .areaSoFarArray,
|
|
3560
|
+
length = areaSoFarArray .length,
|
|
3561
|
+
fraction = Math .random () * areaSoFarArray .at (-1),
|
|
3562
|
+
index0 = 0;
|
|
3563
|
+
|
|
3564
|
+
if (length == 1 || fraction <= areaSoFarArray [0])
|
|
3565
|
+
{
|
|
3566
|
+
index0 = 0;
|
|
3567
|
+
}
|
|
3568
|
+
else if (fraction >= areaSoFarArray .at (-1))
|
|
3569
|
+
{
|
|
3570
|
+
index0 = length - 2;
|
|
3571
|
+
}
|
|
3572
|
+
else
|
|
3573
|
+
{
|
|
3574
|
+
var index = Algorithm .upperBound (areaSoFarArray, 0, length, fraction, Algorithm .less);
|
|
3575
|
+
|
|
3576
|
+
if (index < length)
|
|
3577
|
+
{
|
|
3578
|
+
index0 = index - 1;
|
|
3579
|
+
}
|
|
3580
|
+
else
|
|
3581
|
+
{
|
|
3582
|
+
index0 = 0;
|
|
3583
|
+
}
|
|
3584
|
+
}
|
|
3585
|
+
|
|
3586
|
+
// Random barycentric coordinates.
|
|
3587
|
+
|
|
3588
|
+
var
|
|
3589
|
+
u = Math .random (),
|
|
3590
|
+
v = Math .random ();
|
|
3591
|
+
|
|
3592
|
+
if (u + v > 1)
|
|
3593
|
+
{
|
|
3594
|
+
u = 1 - u;
|
|
3595
|
+
v = 1 - v;
|
|
3596
|
+
}
|
|
3597
|
+
|
|
3598
|
+
var t = 1 - u - v;
|
|
3599
|
+
|
|
3600
|
+
// Interpolate and set position.
|
|
3601
|
+
|
|
3602
|
+
var
|
|
3603
|
+
i = index0 * 12,
|
|
3604
|
+
vertices = this .vertices;
|
|
3605
|
+
|
|
3606
|
+
position .x = u * vertices [i] + v * vertices [i + 4] + t * vertices [i + 8];
|
|
3607
|
+
position .y = u * vertices [i + 1] + v * vertices [i + 5] + t * vertices [i + 9];
|
|
3608
|
+
position .z = u * vertices [i + 2] + v * vertices [i + 6] + t * vertices [i + 10];
|
|
3609
|
+
|
|
3610
|
+
var
|
|
3611
|
+
i = index0 * 9,
|
|
3612
|
+
normals = this .normals,
|
|
3613
|
+
direction = this .direction;
|
|
3614
|
+
|
|
3615
|
+
direction .x = u * normals [i] + v * normals [i + 3] + t * normals [i + 6];
|
|
3616
|
+
direction .y = u * normals [i + 1] + v * normals [i + 4] + t * normals [i + 7];
|
|
3617
|
+
direction .z = u * normals [i + 2] + v * normals [i + 5] + t * normals [i + 8];
|
|
3618
|
+
|
|
3619
|
+
return position;
|
|
3620
|
+
},
|
|
3621
|
+
getRandomVelocity: function (velocity)
|
|
3622
|
+
{
|
|
3623
|
+
var
|
|
3624
|
+
speed = this .getRandomSpeed (),
|
|
3625
|
+
direction = this .direction;
|
|
3626
|
+
|
|
3627
|
+
velocity .x = direction .x * speed;
|
|
3628
|
+
velocity .y = direction .y * speed;
|
|
3629
|
+
velocity .z = direction .z * speed;
|
|
3630
|
+
|
|
3631
|
+
return velocity;
|
|
3632
|
+
},
|
|
3633
|
+
});
|
|
3634
|
+
|
|
3635
|
+
function getPosition (position)
|
|
3636
|
+
{
|
|
3637
|
+
return position .set (0, 0, 0);
|
|
3638
|
+
}
|
|
3639
|
+
|
|
3640
|
+
return SurfaceEmitter;
|
|
3641
|
+
});
|
|
3642
|
+
|
|
3643
|
+
/* -*- Mode: JavaScript; coding: utf-8; tab-width: 3; indent-tabs-mode: tab; c-basic-offset: 3 -*-
|
|
3644
|
+
*******************************************************************************
|
|
3645
|
+
*
|
|
3646
|
+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
3647
|
+
*
|
|
3648
|
+
* Copyright create3000, Scheffelstraße 31a, Leipzig, Germany 2011.
|
|
3649
|
+
*
|
|
3650
|
+
* All rights reserved. Holger Seelig <holger.seelig@yahoo.de>.
|
|
3651
|
+
*
|
|
3652
|
+
* The copyright notice above does not evidence any actual of intended
|
|
3653
|
+
* publication of such source code, and is an unpublished work by create3000.
|
|
3654
|
+
* This material contains CONFIDENTIAL INFORMATION that is the property of
|
|
3655
|
+
* create3000.
|
|
3656
|
+
*
|
|
3657
|
+
* No permission is granted to copy, distribute, or create derivative works from
|
|
3658
|
+
* the contents of this software, in whole or in part, without the prior written
|
|
3659
|
+
* permission of create3000.
|
|
3660
|
+
*
|
|
3661
|
+
* NON-MILITARY USE ONLY
|
|
3662
|
+
*
|
|
3663
|
+
* All create3000 software are effectively free software with a non-military use
|
|
3664
|
+
* restriction. It is free. Well commented source is provided. You may reuse the
|
|
3665
|
+
* source in any way you please with the exception anything that uses it must be
|
|
3666
|
+
* marked to indicate is contains 'non-military use only' components.
|
|
3667
|
+
*
|
|
3668
|
+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
3669
|
+
*
|
|
3670
|
+
* Copyright 2015, 2016 Holger Seelig <holger.seelig@yahoo.de>.
|
|
3671
|
+
*
|
|
3672
|
+
* This file is part of the X_ITE Project.
|
|
3673
|
+
*
|
|
3674
|
+
* X_ITE is free software: you can redistribute it and/or modify it under the
|
|
3675
|
+
* terms of the GNU General Public License version 3 only, as published by the
|
|
3676
|
+
* Free Software Foundation.
|
|
3677
|
+
*
|
|
3678
|
+
* X_ITE is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
3679
|
+
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
|
3680
|
+
* A PARTICULAR PURPOSE. See the GNU General Public License version 3 for more
|
|
3681
|
+
* details (a copy is included in the LICENSE file that accompanied this code).
|
|
3682
|
+
*
|
|
3683
|
+
* You should have received a copy of the GNU General Public License version 3
|
|
3684
|
+
* along with X_ITE. If not, see <http://www.gnu.org/licenses/gpl.html> for a
|
|
3685
|
+
* copy of the GPLv3 License.
|
|
3686
|
+
*
|
|
3687
|
+
* For Silvio, Joy and Adi.
|
|
3688
|
+
*
|
|
3689
|
+
******************************************************************************/
|
|
3690
|
+
|
|
3691
|
+
|
|
3692
|
+
define ('x_ite/Components/ParticleSystems/VolumeEmitter',[
|
|
3693
|
+
"x_ite/Fields",
|
|
3694
|
+
"x_ite/Basic/X3DFieldDefinition",
|
|
3695
|
+
"x_ite/Basic/FieldDefinitionArray",
|
|
3696
|
+
"x_ite/Components/ParticleSystems/X3DParticleEmitterNode",
|
|
3697
|
+
"x_ite/Components/Geometry3D/IndexedFaceSet",
|
|
3698
|
+
"x_ite/Bits/X3DConstants",
|
|
3699
|
+
"standard/Math/Numbers/Vector3",
|
|
3700
|
+
"standard/Math/Numbers/Rotation4",
|
|
3701
|
+
"standard/Math/Geometry/Line3",
|
|
3702
|
+
"standard/Math/Geometry/Plane3",
|
|
3703
|
+
"standard/Math/Geometry/Triangle3",
|
|
3704
|
+
"standard/Math/Algorithm",
|
|
3705
|
+
"standard/Math/Utility/BVH",
|
|
3706
|
+
"standard/Math/Algorithms/QuickSort",
|
|
3707
|
+
],
|
|
3708
|
+
function (Fields,
|
|
3709
|
+
X3DFieldDefinition,
|
|
3710
|
+
FieldDefinitionArray,
|
|
3711
|
+
X3DParticleEmitterNode,
|
|
3712
|
+
IndexedFaceSet,
|
|
3713
|
+
X3DConstants,
|
|
3714
|
+
Vector3,
|
|
3715
|
+
Rotation4,
|
|
3716
|
+
Line3,
|
|
3717
|
+
Plane3,
|
|
3718
|
+
Triangle3,
|
|
3719
|
+
Algorithm,
|
|
3720
|
+
BVH,
|
|
3721
|
+
QuickSort)
|
|
3722
|
+
{
|
|
3723
|
+
"use strict";
|
|
3724
|
+
|
|
3725
|
+
function VolumeEmitter (executionContext)
|
|
3726
|
+
{
|
|
3727
|
+
X3DParticleEmitterNode .call (this, executionContext);
|
|
3728
|
+
|
|
3729
|
+
this .addType (X3DConstants .VolumeEmitter);
|
|
3730
|
+
|
|
3731
|
+
this .speed_ .setUnit ("speed");
|
|
3732
|
+
this .mass_ .setUnit ("mass");
|
|
3733
|
+
this .surfaceArea_ .setUnit ("area");
|
|
3734
|
+
|
|
3735
|
+
this .direction = new Vector3 (0, 0, 0);
|
|
3736
|
+
this .volumeNode = new IndexedFaceSet (executionContext);
|
|
3737
|
+
this .areaSoFarArray = [ 0 ];
|
|
3738
|
+
}
|
|
3739
|
+
|
|
3740
|
+
VolumeEmitter .prototype = Object .assign (Object .create (X3DParticleEmitterNode .prototype),
|
|
3741
|
+
{
|
|
3742
|
+
constructor: VolumeEmitter,
|
|
3743
|
+
fieldDefinitions: new FieldDefinitionArray ([
|
|
3744
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "metadata", new Fields .SFNode ()),
|
|
3745
|
+
new X3DFieldDefinition (X3DConstants .initializeOnly, "internal", new Fields .SFBool (true)),
|
|
3746
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "direction", new Fields .SFVec3f (0, 1, 0)),
|
|
3747
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "speed", new Fields .SFFloat ()),
|
|
3748
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "variation", new Fields .SFFloat (0.25)),
|
|
3749
|
+
new X3DFieldDefinition (X3DConstants .initializeOnly, "mass", new Fields .SFFloat ()),
|
|
3750
|
+
new X3DFieldDefinition (X3DConstants .initializeOnly, "surfaceArea", new Fields .SFFloat ()),
|
|
3751
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "coordIndex", new Fields .MFInt32 (-1)),
|
|
3752
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "coord", new Fields .SFNode ()),
|
|
3753
|
+
]),
|
|
3754
|
+
getTypeName: function ()
|
|
3755
|
+
{
|
|
3756
|
+
return "VolumeEmitter";
|
|
3757
|
+
},
|
|
3758
|
+
getComponentName: function ()
|
|
3759
|
+
{
|
|
3760
|
+
return "ParticleSystems";
|
|
3761
|
+
},
|
|
3762
|
+
getContainerField: function ()
|
|
3763
|
+
{
|
|
3764
|
+
return "emitter";
|
|
3765
|
+
},
|
|
3766
|
+
initialize: function ()
|
|
3767
|
+
{
|
|
3768
|
+
X3DParticleEmitterNode .prototype .initialize .call (this);
|
|
3769
|
+
|
|
3770
|
+
this .direction_ .addInterest ("set_direction__", this);
|
|
3771
|
+
|
|
3772
|
+
this .coordIndex_ .addFieldInterest (this .volumeNode .coordIndex_);
|
|
3773
|
+
this .coord_ .addFieldInterest (this .volumeNode .coord_);
|
|
3774
|
+
|
|
3775
|
+
this .volumeNode .creaseAngle_ = Math .PI;
|
|
3776
|
+
this .volumeNode .convex_ = false;
|
|
3777
|
+
this .volumeNode .coordIndex_ = this .coordIndex_;
|
|
3778
|
+
this .volumeNode .coord_ = this .coord_;
|
|
3779
|
+
|
|
3780
|
+
this .volumeNode .rebuild_ .addInterest ("set_geometry__", this);
|
|
3781
|
+
this .volumeNode .setPrivate (true);
|
|
3782
|
+
this .volumeNode .setup ();
|
|
3783
|
+
|
|
3784
|
+
this .set_direction__ ();
|
|
3785
|
+
this .set_geometry__ ();
|
|
3786
|
+
},
|
|
3787
|
+
set_direction__: function ()
|
|
3788
|
+
{
|
|
3789
|
+
this .direction .assign (this .direction_ .getValue ()) .normalize ();
|
|
3790
|
+
|
|
3791
|
+
if (this .direction .equals (Vector3 .Zero))
|
|
3792
|
+
this .getRandomVelocity = this .getSphericalRandomVelocity;
|
|
3793
|
+
else
|
|
3794
|
+
delete this .getRandomVelocity;
|
|
3795
|
+
},
|
|
3796
|
+
set_geometry__: (function ()
|
|
3797
|
+
{
|
|
3798
|
+
var
|
|
3799
|
+
vertex1 = new Vector3 (0, 0, 0),
|
|
3800
|
+
vertex2 = new Vector3 (0, 0, 0),
|
|
3801
|
+
vertex3 = new Vector3 (0, 0, 0);
|
|
3802
|
+
|
|
3803
|
+
return function ()
|
|
3804
|
+
{
|
|
3805
|
+
var
|
|
3806
|
+
areaSoFar = 0,
|
|
3807
|
+
areaSoFarArray = this .areaSoFarArray,
|
|
3808
|
+
normals = this .volumeNode .getNormals () .getValue (),
|
|
3809
|
+
vertices = this .volumeNode .getVertices () .getValue ();
|
|
3810
|
+
|
|
3811
|
+
this .normals = normals;
|
|
3812
|
+
this .vertices = vertices;
|
|
3813
|
+
|
|
3814
|
+
areaSoFarArray .length = 1;
|
|
3815
|
+
|
|
3816
|
+
for (var i = 0, length = vertices .length; i < length; i += 12)
|
|
3817
|
+
{
|
|
3818
|
+
vertex1 .set (vertices [i], vertices [i + 1], vertices [i + 2]);
|
|
3819
|
+
vertex2 .set (vertices [i + 4], vertices [i + 5], vertices [i + 6]);
|
|
3820
|
+
vertex3 .set (vertices [i + 8], vertices [i + 9], vertices [i + 10]);
|
|
3821
|
+
|
|
3822
|
+
areaSoFar += Triangle3 .area (vertex1, vertex2, vertex3);
|
|
3823
|
+
areaSoFarArray .push (areaSoFar);
|
|
3824
|
+
}
|
|
3825
|
+
|
|
3826
|
+
this .bvh = new BVH (vertices, normals);
|
|
3827
|
+
};
|
|
3828
|
+
})(),
|
|
3829
|
+
getRandomPosition: (function ()
|
|
3830
|
+
{
|
|
3831
|
+
var
|
|
3832
|
+
point = new Vector3 (0, 0, 0),
|
|
3833
|
+
normal = new Vector3 (0, 0, 0),
|
|
3834
|
+
rotation = new Rotation4 (0, 0, 1, 0),
|
|
3835
|
+
line = new Line3 (Vector3 .Zero, Vector3 .zAxis),
|
|
3836
|
+
plane = new Plane3 (Vector3 .Zero, Vector3 .zAxis),
|
|
3837
|
+
intersections = [ ],
|
|
3838
|
+
sorter = new QuickSort (intersections, PlaneCompare);
|
|
3839
|
+
|
|
3840
|
+
function PlaneCompare (a, b)
|
|
3841
|
+
{
|
|
3842
|
+
return plane .getDistanceToPoint (a) < plane .getDistanceToPoint (b);
|
|
3843
|
+
}
|
|
3844
|
+
|
|
3845
|
+
return function (position)
|
|
3846
|
+
{
|
|
3847
|
+
// Get random point on surface
|
|
3848
|
+
|
|
3849
|
+
// Determine index0.
|
|
3850
|
+
|
|
3851
|
+
var
|
|
3852
|
+
areaSoFarArray = this .areaSoFarArray,
|
|
3853
|
+
length = areaSoFarArray .length,
|
|
3854
|
+
fraction = Math .random () * areaSoFarArray .at (-1),
|
|
3855
|
+
index0 = 0;
|
|
3856
|
+
|
|
3857
|
+
if (length == 1 || fraction <= areaSoFarArray [0])
|
|
3858
|
+
{
|
|
3859
|
+
index0 = 0;
|
|
3860
|
+
}
|
|
3861
|
+
else if (fraction >= areaSoFarArray .at (-1))
|
|
3862
|
+
{
|
|
3863
|
+
index0 = length - 2;
|
|
3864
|
+
}
|
|
3865
|
+
else
|
|
3866
|
+
{
|
|
3867
|
+
var index = Algorithm .upperBound (areaSoFarArray, 0, length, fraction, Algorithm .less);
|
|
3868
|
+
|
|
3869
|
+
if (index < length)
|
|
3870
|
+
{
|
|
3871
|
+
index0 = index - 1;
|
|
3872
|
+
}
|
|
3873
|
+
else
|
|
3874
|
+
{
|
|
3875
|
+
index0 = 0;
|
|
3876
|
+
}
|
|
3877
|
+
}
|
|
3878
|
+
|
|
3879
|
+
// Random barycentric coordinates.
|
|
3880
|
+
|
|
3881
|
+
var
|
|
3882
|
+
u = Math .random (),
|
|
3883
|
+
v = Math .random ();
|
|
3884
|
+
|
|
3885
|
+
if (u + v > 1)
|
|
3886
|
+
{
|
|
3887
|
+
u = 1 - u;
|
|
3888
|
+
v = 1 - v;
|
|
3889
|
+
}
|
|
3890
|
+
|
|
3891
|
+
var t = 1 - u - v;
|
|
3892
|
+
|
|
3893
|
+
// Interpolate and determine random point on surface and normal.
|
|
3894
|
+
|
|
3895
|
+
var
|
|
3896
|
+
i = index0 * 12,
|
|
3897
|
+
vertices = this .vertices;
|
|
3898
|
+
|
|
3899
|
+
point .x = u * vertices [i] + v * vertices [i + 4] + t * vertices [i + 8];
|
|
3900
|
+
point .y = u * vertices [i + 1] + v * vertices [i + 5] + t * vertices [i + 9];
|
|
3901
|
+
point .z = u * vertices [i + 2] + v * vertices [i + 6] + t * vertices [i + 10];
|
|
3902
|
+
|
|
3903
|
+
var
|
|
3904
|
+
i = index0 * 9,
|
|
3905
|
+
normals = this .normals;
|
|
3906
|
+
|
|
3907
|
+
normal .x = u * normals [i] + v * normals [i + 3] + t * normals [i + 6];
|
|
3908
|
+
normal .y = u * normals [i + 1] + v * normals [i + 4] + t * normals [i + 7];
|
|
3909
|
+
normal .z = u * normals [i + 2] + v * normals [i + 5] + t * normals [i + 8];
|
|
3910
|
+
|
|
3911
|
+
rotation .setFromToVec (Vector3 .zAxis, normal);
|
|
3912
|
+
rotation .multVecRot (this .getRandomSurfaceNormal (normal));
|
|
3913
|
+
|
|
3914
|
+
// Setup random line throu volume for intersection text
|
|
3915
|
+
// and a plane corresponding to the line for intersection sorting.
|
|
3916
|
+
|
|
3917
|
+
line .set (point, normal);
|
|
3918
|
+
plane .set (point, normal);
|
|
3919
|
+
|
|
3920
|
+
// Find random point in volume.
|
|
3921
|
+
|
|
3922
|
+
var numIntersections = this .bvh .intersectsLine (line, intersections);
|
|
3923
|
+
|
|
3924
|
+
numIntersections -= numIntersections % 2; // We need an even count of intersections.
|
|
3925
|
+
|
|
3926
|
+
if (numIntersections)
|
|
3927
|
+
{
|
|
3928
|
+
// Sort intersections along line with a little help from the plane.
|
|
3929
|
+
|
|
3930
|
+
sorter .sort (0, numIntersections);
|
|
3931
|
+
|
|
3932
|
+
// Select random intersection pair.
|
|
3933
|
+
|
|
3934
|
+
var
|
|
3935
|
+
index = Math .round (this .getRandomValue (0, numIntersections / 2 - 1)) * 2,
|
|
3936
|
+
point0 = intersections [index],
|
|
3937
|
+
point1 = intersections [index + 1],
|
|
3938
|
+
t = Math .random ();
|
|
3939
|
+
|
|
3940
|
+
// lerp
|
|
3941
|
+
position .x = point0 .x + (point1 .x - point0 .x) * t;
|
|
3942
|
+
position .y = point0 .y + (point1 .y - point0 .y) * t;
|
|
3943
|
+
position .z = point0 .z + (point1 .z - point0 .z) * t;
|
|
3944
|
+
|
|
3945
|
+
return position;
|
|
3946
|
+
}
|
|
3947
|
+
|
|
3948
|
+
// Discard point.
|
|
3949
|
+
|
|
3950
|
+
return position .set (Number .POSITIVE_INFINITY, Number .POSITIVE_INFINITY, Number .POSITIVE_INFINITY);
|
|
3951
|
+
};
|
|
3952
|
+
})(),
|
|
3953
|
+
getRandomVelocity: function (velocity)
|
|
3954
|
+
{
|
|
3955
|
+
var
|
|
3956
|
+
direction = this .direction,
|
|
3957
|
+
speed = this .getRandomSpeed ();
|
|
3958
|
+
|
|
3959
|
+
velocity .x = direction .x * speed;
|
|
3960
|
+
velocity .y = direction .y * speed;
|
|
3961
|
+
velocity .z = direction .z * speed;
|
|
3962
|
+
|
|
3963
|
+
return velocity;
|
|
3964
|
+
},
|
|
3965
|
+
});
|
|
3966
|
+
|
|
3967
|
+
return VolumeEmitter;
|
|
3968
|
+
});
|
|
3969
|
+
|
|
3970
|
+
/* -*- Mode: JavaScript; coding: utf-8; tab-width: 3; indent-tabs-mode: tab; c-basic-offset: 3 -*-
|
|
3971
|
+
*******************************************************************************
|
|
3972
|
+
*
|
|
3973
|
+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
3974
|
+
*
|
|
3975
|
+
* Copyright create3000, Scheffelstraße 31a, Leipzig, Germany 2011.
|
|
3976
|
+
*
|
|
3977
|
+
* All rights reserved. Holger Seelig <holger.seelig@yahoo.de>.
|
|
3978
|
+
*
|
|
3979
|
+
* The copyright notice above does not evidence any actual of intended
|
|
3980
|
+
* publication of such source code, and is an unpublished work by create3000.
|
|
3981
|
+
* This material contains CONFIDENTIAL INFORMATION that is the property of
|
|
3982
|
+
* create3000.
|
|
3983
|
+
*
|
|
3984
|
+
* No permission is granted to copy, distribute, or create derivative works from
|
|
3985
|
+
* the contents of this software, in whole or in part, without the prior written
|
|
3986
|
+
* permission of create3000.
|
|
3987
|
+
*
|
|
3988
|
+
* NON-MILITARY USE ONLY
|
|
3989
|
+
*
|
|
3990
|
+
* All create3000 software are effectively free software with a non-military use
|
|
3991
|
+
* restriction. It is free. Well commented source is provided. You may reuse the
|
|
3992
|
+
* source in any way you please with the exception anything that uses it must be
|
|
3993
|
+
* marked to indicate is contains 'non-military use only' components.
|
|
3994
|
+
*
|
|
3995
|
+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
3996
|
+
*
|
|
3997
|
+
* Copyright 2015, 2016 Holger Seelig <holger.seelig@yahoo.de>.
|
|
3998
|
+
*
|
|
3999
|
+
* This file is part of the X_ITE Project.
|
|
4000
|
+
*
|
|
4001
|
+
* X_ITE is free software: you can redistribute it and/or modify it under the
|
|
4002
|
+
* terms of the GNU General Public License version 3 only, as published by the
|
|
4003
|
+
* Free Software Foundation.
|
|
4004
|
+
*
|
|
4005
|
+
* X_ITE is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
4006
|
+
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
|
4007
|
+
* A PARTICULAR PURPOSE. See the GNU General Public License version 3 for more
|
|
4008
|
+
* details (a copy is included in the LICENSE file that accompanied this code).
|
|
4009
|
+
*
|
|
4010
|
+
* You should have received a copy of the GNU General Public License version 3
|
|
4011
|
+
* along with X_ITE. If not, see <http://www.gnu.org/licenses/gpl.html> for a
|
|
4012
|
+
* copy of the GPLv3 License.
|
|
4013
|
+
*
|
|
4014
|
+
* For Silvio, Joy and Adi.
|
|
4015
|
+
*
|
|
4016
|
+
******************************************************************************/
|
|
4017
|
+
|
|
4018
|
+
|
|
4019
|
+
define ('x_ite/Components/ParticleSystems/WindPhysicsModel',[
|
|
4020
|
+
"x_ite/Fields",
|
|
4021
|
+
"x_ite/Basic/X3DFieldDefinition",
|
|
4022
|
+
"x_ite/Basic/FieldDefinitionArray",
|
|
4023
|
+
"x_ite/Components/ParticleSystems/X3DParticlePhysicsModelNode",
|
|
4024
|
+
"x_ite/Bits/X3DConstants",
|
|
4025
|
+
"standard/Math/Numbers/Vector3",
|
|
4026
|
+
"standard/Math/Algorithm",
|
|
4027
|
+
],
|
|
4028
|
+
function (Fields,
|
|
4029
|
+
X3DFieldDefinition,
|
|
4030
|
+
FieldDefinitionArray,
|
|
4031
|
+
X3DParticlePhysicsModelNode,
|
|
4032
|
+
X3DConstants,
|
|
4033
|
+
Vector3,
|
|
4034
|
+
Algorithm)
|
|
4035
|
+
{
|
|
4036
|
+
"use strict";
|
|
4037
|
+
|
|
4038
|
+
function WindPhysicsModel (executionContext)
|
|
4039
|
+
{
|
|
4040
|
+
X3DParticlePhysicsModelNode .call (this, executionContext);
|
|
4041
|
+
|
|
4042
|
+
this .addType (X3DConstants .WindPhysicsModel);
|
|
4043
|
+
|
|
4044
|
+
this .speed_ .setUnit ("speed");
|
|
4045
|
+
}
|
|
4046
|
+
|
|
4047
|
+
WindPhysicsModel .prototype = Object .assign (Object .create (X3DParticlePhysicsModelNode .prototype),
|
|
4048
|
+
{
|
|
4049
|
+
constructor: WindPhysicsModel,
|
|
4050
|
+
fieldDefinitions: new FieldDefinitionArray ([
|
|
4051
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "metadata", new Fields .SFNode ()),
|
|
4052
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "enabled", new Fields .SFBool (true)),
|
|
4053
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "direction", new Fields .SFVec3f ()),
|
|
4054
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "speed", new Fields .SFFloat (0.1)),
|
|
4055
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "gustiness", new Fields .SFFloat (0.1)),
|
|
4056
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "turbulence", new Fields .SFFloat ()),
|
|
4057
|
+
]),
|
|
4058
|
+
getTypeName: function ()
|
|
4059
|
+
{
|
|
4060
|
+
return "WindPhysicsModel";
|
|
4061
|
+
},
|
|
4062
|
+
getComponentName: function ()
|
|
4063
|
+
{
|
|
4064
|
+
return "ParticleSystems";
|
|
4065
|
+
},
|
|
4066
|
+
getContainerField: function ()
|
|
4067
|
+
{
|
|
4068
|
+
return "physics";
|
|
4069
|
+
},
|
|
4070
|
+
getRandomSpeed: function (emitterNode)
|
|
4071
|
+
{
|
|
4072
|
+
var
|
|
4073
|
+
speed = Math .max (0, this .speed_ .getValue ()),
|
|
4074
|
+
variation = speed * Math .max (0, this .gustiness_ .getValue ());
|
|
4075
|
+
|
|
4076
|
+
return emitterNode .getRandomValue (Math .max (0, speed - variation), speed + variation);
|
|
4077
|
+
},
|
|
4078
|
+
addForce: (function ()
|
|
4079
|
+
{
|
|
4080
|
+
var force = new Vector3 (0, 0, 0);
|
|
4081
|
+
|
|
4082
|
+
return function (i, emitterNode, forces, turbulences)
|
|
4083
|
+
{
|
|
4084
|
+
var surfaceArea = emitterNode .surfaceArea_ .getValue ()
|
|
4085
|
+
|
|
4086
|
+
if (this .enabled_ .getValue ())
|
|
4087
|
+
{
|
|
4088
|
+
var
|
|
4089
|
+
randomSpeed = this .getRandomSpeed (emitterNode),
|
|
4090
|
+
pressure = Math .pow (10, 2 * Math .log (randomSpeed)) * 0.64615;
|
|
4091
|
+
|
|
4092
|
+
if (this .direction_ .getValue () .equals (Vector3 .Zero))
|
|
4093
|
+
emitterNode .getRandomNormal (force);
|
|
4094
|
+
else
|
|
4095
|
+
force .assign (this .direction_ .getValue ()) .normalize ();
|
|
4096
|
+
|
|
4097
|
+
forces [i] .assign (force .multiply (surfaceArea * pressure));
|
|
4098
|
+
turbulences [i] = Math .PI * Algorithm .clamp (this .turbulence_ .getValue (), 0, 1);
|
|
4099
|
+
}
|
|
4100
|
+
};
|
|
4101
|
+
})(),
|
|
4102
|
+
});
|
|
4103
|
+
|
|
4104
|
+
return WindPhysicsModel;
|
|
4105
|
+
});
|
|
4106
|
+
|
|
4107
|
+
|
|
4108
|
+
|
|
4109
|
+
/*******************************************************************************
|
|
4110
|
+
*
|
|
4111
|
+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
4112
|
+
*
|
|
4113
|
+
* Copyright create3000, Scheffelstraße 31a, Leipzig, Germany 2011.
|
|
4114
|
+
*
|
|
4115
|
+
* All rights reserved. Holger Seelig <holger.seelig@yahoo.de>.
|
|
4116
|
+
*
|
|
4117
|
+
* The copyright notice above does not evidence any actual of intended
|
|
4118
|
+
* publication of such source code, and is an unpublished work by create3000.
|
|
4119
|
+
* This material contains CONFIDENTIAL INFORMATION that is the property of
|
|
4120
|
+
* create3000.
|
|
4121
|
+
*
|
|
4122
|
+
* No permission is granted to copy, distribute, or create derivative works from
|
|
4123
|
+
* the contents of this software, in whole or in part, without the prior written
|
|
4124
|
+
* permission of create3000.
|
|
4125
|
+
*
|
|
4126
|
+
* NON-MILITARY USE ONLY
|
|
4127
|
+
*
|
|
4128
|
+
* All create3000 software are effectively free software with a non-military use
|
|
4129
|
+
* restriction. It is free. Well commented source is provided. You may reuse the
|
|
4130
|
+
* source in any way you please with the exception anything that uses it must be
|
|
4131
|
+
* marked to indicate is contains 'non-military use only' components.
|
|
4132
|
+
*
|
|
4133
|
+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
4134
|
+
*
|
|
4135
|
+
* Copyright 2015, 2016 Holger Seelig <holger.seelig@yahoo.de>.
|
|
4136
|
+
*
|
|
4137
|
+
* This file is part of the X_ITE Project.
|
|
4138
|
+
*
|
|
4139
|
+
* X_ITE is free software: you can redistribute it and/or modify it under the
|
|
4140
|
+
* terms of the GNU General Public License version 3 only, as published by the
|
|
4141
|
+
* Free Software Foundation.
|
|
4142
|
+
*
|
|
4143
|
+
* X_ITE is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
4144
|
+
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
|
4145
|
+
* A PARTICULAR PURPOSE. See the GNU General Public License version 3 for more
|
|
4146
|
+
* details (a copy is included in the LICENSE file that accompanied this code).
|
|
4147
|
+
*
|
|
4148
|
+
* You should have received a copy of the GNU General Public License version 3
|
|
4149
|
+
* along with X_ITE. If not, see <http://www.gnu.org/licenses/gpl.html> for a
|
|
4150
|
+
* copy of the GPLv3 License.
|
|
4151
|
+
*
|
|
4152
|
+
* For Silvio, Joy and Adi.
|
|
4153
|
+
*
|
|
4154
|
+
******************************************************************************/
|
|
4155
|
+
|
|
4156
|
+
|
|
4157
|
+
define ([
|
|
4158
|
+
"x_ite/Components",
|
|
4159
|
+
"x_ite/Browser/ParticleSystems/X3DParticleSystemsContext",
|
|
4160
|
+
"x_ite/Components/ParticleSystems/BoundedPhysicsModel",
|
|
4161
|
+
"x_ite/Components/ParticleSystems/ConeEmitter",
|
|
4162
|
+
"x_ite/Components/ParticleSystems/ExplosionEmitter",
|
|
4163
|
+
"x_ite/Components/ParticleSystems/ForcePhysicsModel",
|
|
4164
|
+
"x_ite/Components/ParticleSystems/ParticleSystem",
|
|
4165
|
+
"x_ite/Components/ParticleSystems/PointEmitter",
|
|
4166
|
+
"x_ite/Components/ParticleSystems/PolylineEmitter",
|
|
4167
|
+
"x_ite/Components/ParticleSystems/SurfaceEmitter",
|
|
4168
|
+
"x_ite/Components/ParticleSystems/VolumeEmitter",
|
|
4169
|
+
"x_ite/Components/ParticleSystems/WindPhysicsModel",
|
|
4170
|
+
"x_ite/Components/ParticleSystems/X3DParticleEmitterNode",
|
|
4171
|
+
"x_ite/Components/ParticleSystems/X3DParticlePhysicsModelNode",
|
|
4172
|
+
],
|
|
4173
|
+
function (Components,
|
|
4174
|
+
X3DParticleSystemsContext,
|
|
4175
|
+
BoundedPhysicsModel,
|
|
4176
|
+
ConeEmitter,
|
|
4177
|
+
ExplosionEmitter,
|
|
4178
|
+
ForcePhysicsModel,
|
|
4179
|
+
ParticleSystem,
|
|
4180
|
+
PointEmitter,
|
|
4181
|
+
PolylineEmitter,
|
|
4182
|
+
SurfaceEmitter,
|
|
4183
|
+
VolumeEmitter,
|
|
4184
|
+
WindPhysicsModel,
|
|
4185
|
+
X3DParticleEmitterNode,
|
|
4186
|
+
X3DParticlePhysicsModelNode)
|
|
4187
|
+
{
|
|
4188
|
+
"use strict";
|
|
4189
|
+
|
|
4190
|
+
Components .addComponent ({
|
|
4191
|
+
name: "ParticleSystems",
|
|
4192
|
+
types:
|
|
4193
|
+
{
|
|
4194
|
+
BoundedPhysicsModel: BoundedPhysicsModel,
|
|
4195
|
+
ConeEmitter: ConeEmitter,
|
|
4196
|
+
ExplosionEmitter: ExplosionEmitter,
|
|
4197
|
+
ForcePhysicsModel: ForcePhysicsModel,
|
|
4198
|
+
ParticleSystem: ParticleSystem,
|
|
4199
|
+
PointEmitter: PointEmitter,
|
|
4200
|
+
PolylineEmitter: PolylineEmitter,
|
|
4201
|
+
SurfaceEmitter: SurfaceEmitter,
|
|
4202
|
+
VolumeEmitter: VolumeEmitter,
|
|
4203
|
+
WindPhysicsModel: WindPhysicsModel,
|
|
4204
|
+
},
|
|
4205
|
+
abstractTypes:
|
|
4206
|
+
{
|
|
4207
|
+
X3DParticleEmitterNode: X3DParticleEmitterNode,
|
|
4208
|
+
X3DParticlePhysicsModelNode: X3DParticlePhysicsModelNode,
|
|
4209
|
+
},
|
|
4210
|
+
browser: X3DParticleSystemsContext,
|
|
4211
|
+
});
|
|
4212
|
+
});
|
|
4213
|
+
|
|
4214
|
+
|
|
4215
|
+
|
|
4216
|
+
}());
|