x_ite 4.2.17 → 4.7.7
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/launch.json +15 -0
- package/.vscode/settings.json +12 -0
- package/.vscode/tasks.json +25 -0
- package/Makefile +27 -10
- package/README.md +13 -145
- package/build/bin/dist.pl +65 -8
- package/build/bin/version-number.pl +25 -0
- package/build/bin/version.pl +54 -14
- 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.js +3 -0
- package/build/parts/default.start.frag.js +15 -0
- package/build/parts/x_ite.end.frag.js +25 -0
- package/build/parts/x_ite.start.frag.js +16 -0
- package/build/x_ite.build.js +5 -2
- package/dist/{components/texturing-3d.js → assets/components/annotation.js} +341 -263
- package/dist/assets/components/annotation.min.js +1 -0
- package/dist/{components → assets/components}/cad-geometry.js +180 -76
- package/dist/assets/components/cad-geometry.min.js +1 -0
- package/dist/assets/components/cube-map-texturing.js +1222 -0
- package/dist/assets/components/cube-map-texturing.min.js +1 -0
- package/dist/assets/components/dis.js +918 -0
- package/dist/assets/components/dis.min.js +1 -0
- package/dist/assets/components/event-utilities.js +1124 -0
- package/dist/assets/components/event-utilities.min.js +1 -0
- package/dist/assets/components/geometry2d.js +2200 -0
- package/dist/assets/components/geometry2d.min.js +1 -0
- package/dist/{components → assets/components}/geospatial.js +364 -269
- package/dist/assets/components/geospatial.min.js +2 -0
- package/dist/{components → assets/components}/h-anim.js +224 -62
- package/dist/assets/components/h-anim.min.js +1 -0
- package/dist/assets/components/key-device-sensor.js +860 -0
- package/dist/assets/components/key-device-sensor.min.js +1 -0
- package/dist/assets/components/layout.js +2018 -0
- package/dist/assets/components/layout.min.js +1 -0
- package/dist/{components → assets/components}/nurbs.js +632 -348
- package/dist/assets/components/nurbs.min.js +2 -0
- package/dist/{components → assets/components}/particle-systems.js +514 -476
- package/dist/assets/components/particle-systems.min.js +2 -0
- package/dist/assets/components/picking.js +2491 -0
- package/dist/assets/components/picking.min.js +1 -0
- package/dist/assets/components/projective-texture-mapping.js +823 -0
- package/dist/assets/components/projective-texture-mapping.min.js +1 -0
- package/dist/assets/components/rigid-body-physics.js +4579 -0
- package/dist/assets/components/rigid-body-physics.min.js +59 -0
- package/dist/assets/components/scripting.js +816 -0
- package/dist/assets/components/scripting.min.js +1 -0
- package/dist/assets/components/texturing-3d.js +10064 -0
- package/dist/assets/components/texturing-3d.min.js +48 -0
- package/dist/assets/components/volume-rendering.js +3976 -0
- package/dist/assets/components/volume-rendering.min.js +3 -0
- package/dist/assets/components/x_ite.js +295 -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 +15 -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 +107 -0
- package/dist/assets/shaders/webgl1/Phong.fs +837 -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 +538 -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 +108 -0
- package/dist/assets/shaders/webgl2/Phong.fs +1013 -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 +693 -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 +167 -49
- package/dist/x_ite.js +66263 -60020
- package/dist/x_ite.min.js +41 -41
- package/dist/x_ite.zip +0 -0
- package/docs/404.md +5 -0
- package/docs/Accessing-the-External-Browser.md +319 -0
- package/docs/Browser-Support.md +47 -0
- package/docs/Custom-Shaders.md +896 -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 +1295 -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 +1033 -0
- package/docs/reference/Browser-Services.md +361 -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 +342 -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 +3 -3
- package/package.json +43 -28
- package/src/assets/components/annotation.js +87 -0
- package/src/{components → assets/components}/cad-geometry.js +0 -0
- package/src/{x_ite/Components/CubeMapTexturing.js → assets/components/cube-map-texturing.js} +15 -21
- package/src/assets/components/dis.js +84 -0
- package/src/{x_ite/Components/EventUtilities.js → assets/components/event-utilities.js} +20 -26
- package/src/{x_ite/Components/Geometry2D.js → assets/components/geometry2d.js} +22 -25
- package/src/{components → assets/components}/geospatial.js +0 -0
- package/src/{components → assets/components}/h-anim.js +9 -7
- package/src/{x_ite/Components/KeyDeviceSensor.js → assets/components/key-device-sensor.js} +17 -20
- package/src/{x_ite/Components/Layout.js → assets/components/layout.js} +20 -23
- package/src/{components → assets/components}/nurbs.js +0 -0
- package/src/{components → assets/components}/particle-systems.js +1 -1
- package/src/assets/components/picking.js +87 -0
- package/src/assets/components/projective-texture-mapping.js +75 -0
- package/src/{components → assets/components}/rigid-body-physics.js +7 -2
- package/src/{x_ite/Components/Scripting.js → assets/components/scripting.js} +13 -19
- package/src/{components → assets/components}/texturing-3d.js +12 -13
- package/src/assets/components/volume-rendering.js +118 -0
- package/src/{x_ite/Components/X_ITE.js → assets/components/x_ite.js} +12 -30
- 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 +21 -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 +147 -0
- package/src/assets/shaders/webgl1/Phong.fs +172 -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 +86 -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/{x_ite/Browser/Shaders/Include/Pack.h → assets/shaders/webgl1/include/Pack.glsl} +0 -1
- package/src/assets/shaders/webgl1/include/Perlin.glsl +40 -0
- package/src/{x_ite/Browser/Shaders/Include/Shadow.h → assets/shaders/webgl1/include/Shadow.glsl} +33 -33
- 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 +148 -0
- package/src/assets/shaders/webgl2/Phong.fs +170 -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 +85 -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 +33 -12
- package/src/dummy.js +1 -0
- package/src/example.html +8 -7
- package/src/examples.js +21 -3
- package/src/lib/ammojs/AmmoJS.js +58 -0
- package/src/lib/ammojs/Makefile +4 -0
- package/src/lib/ammojs/ammo.idl +72 -1
- package/src/lib/ammojs/ammo.js +25 -21
- package/src/lib/jpeg/jpeg.js +1019 -0
- package/src/lib/nurbs/extras/sample.js +137 -80
- package/src/locale/de.po +18 -73
- package/src/locale/fr.po +18 -74
- package/src/spinner.css +18 -6
- package/src/standard/Geospatial/Geodetic.js +43 -43
- package/src/standard/Geospatial/ReferenceEllipsoids.js +1 -1
- package/src/standard/Geospatial/UniversalTransverseMercator.js +42 -42
- package/src/standard/Math/Algorithm.js +22 -39
- 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 +6 -6
- 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 +400 -358
- package/src/standard/Math/Geometry/Camera.js +19 -16
- package/src/standard/Math/Geometry/Cylinder3.js +13 -13
- package/src/standard/Math/Geometry/Line3.js +34 -34
- package/src/standard/Math/Geometry/Plane3.js +15 -15
- 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 +5 -5
- package/src/standard/Math/Geometry/Triangle3.js +12 -14
- package/src/standard/Math/Geometry/ViewVolume.js +303 -106
- package/src/standard/Math/Numbers/Color3.js +26 -23
- package/src/standard/Math/Numbers/Color4.js +9 -9
- package/src/standard/Math/Numbers/Complex.js +13 -17
- package/src/standard/Math/Numbers/Matrix2.js +20 -13
- package/src/standard/Math/Numbers/Matrix3.js +129 -205
- package/src/standard/Math/Numbers/Matrix4.js +136 -257
- package/src/standard/Math/Numbers/Quaternion.js +49 -138
- package/src/standard/Math/Numbers/Rotation4.js +42 -55
- package/src/standard/Math/Numbers/Vector2.js +32 -115
- package/src/standard/Math/Numbers/Vector3.js +46 -151
- package/src/standard/Math/Numbers/Vector4.js +44 -163
- package/src/standard/Math/Utility/BVH.js +21 -20
- package/src/standard/Math/Utility/MatrixStack.js +4 -4
- package/src/standard/Networking/BinaryTransport.js +8 -8
- package/src/standard/Time/MicroTime.js +81 -0
- package/src/standard/Utility/DataStorage.js +11 -14
- 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 +84 -5
- package/src/x_ite/Base/Events.js +9 -10
- package/src/x_ite/Base/X3DChildObject.js +20 -16
- package/src/x_ite/Base/X3DEventObject.js +3 -7
- package/src/x_ite/Base/X3DObject.js +44 -27
- package/src/x_ite/Basic/FieldDefinitionArray.js +11 -4
- package/src/x_ite/Basic/X3DBaseNode.js +427 -246
- package/src/x_ite/Basic/X3DField.js +48 -69
- package/src/x_ite/Basic/X3DFieldDefinition.js +0 -4
- package/src/x_ite/Basic/X3DObjectArrayField.js +102 -108
- package/src/x_ite/Basic/X3DTypedArrayField.js +194 -163
- package/src/x_ite/Bits/TraverseType.js +2 -5
- package/src/x_ite/Bits/X3DConstants.js +11 -2
- package/src/x_ite/Browser/Core/BrowserOptions.js +89 -68
- package/src/x_ite/Browser/Core/BrowserTimings.js +21 -29
- package/src/x_ite/Browser/Core/ContextMenu.js +139 -60
- package/src/x_ite/Browser/Core/Notification.js +3 -3
- package/src/x_ite/Browser/Core/PrimitiveQuality.js +3 -7
- package/src/x_ite/Browser/Core/Shading.js +3 -7
- package/src/x_ite/Browser/Core/TextureQuality.js +3 -7
- package/src/x_ite/Browser/Core/X3DCoreContext.js +398 -58
- package/src/x_ite/Browser/Core/X3DCoreContext.js.~1~ +714 -0
- package/src/x_ite/Browser/EnvironmentalEffects/X3DEnvironmentalEffectsContext.js +17 -28
- package/src/x_ite/Browser/Followers/X3DArrayChaserTemplate.js +5 -14
- package/src/x_ite/Browser/Followers/X3DArrayFollowerTemplate.js +81 -28
- package/src/x_ite/Browser/Geometry2D/Disk2DOptions.js +53 -44
- package/src/x_ite/Browser/Geometry2D/X3DGeometry2DContext.js +51 -12
- 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/KeyDeviceSensor/X3DKeyDeviceSensorContext.js +14 -206
- package/src/x_ite/Browser/Layout/ScreenText.js +226 -254
- package/src/x_ite/Browser/Layout/X3DLayoutContext.js +13 -11
- package/src/x_ite/Browser/Lighting/X3DLightingContext.js +15 -9
- package/src/x_ite/Browser/NURBS/NURBS.js +84 -72
- package/src/x_ite/Browser/Navigation/ExamineViewer.js +125 -83
- package/src/x_ite/Browser/Navigation/FlyViewer.js +14 -9
- package/src/x_ite/Browser/Navigation/LookAtViewer.js +60 -40
- package/src/x_ite/Browser/Navigation/NoneViewer.js +12 -1
- package/src/x_ite/Browser/Navigation/PlaneViewer.js +39 -20
- package/src/x_ite/Browser/Navigation/WalkViewer.js +21 -6
- package/src/x_ite/Browser/Navigation/X3DFlyViewer.js +110 -85
- package/src/x_ite/Browser/Navigation/X3DNavigationContext.js +11 -6
- package/src/x_ite/Browser/Navigation/X3DViewer.js +73 -48
- package/src/x_ite/Browser/Networking/X3DNetworkingContext.js +18 -24
- package/src/x_ite/Browser/Networking/urls.js +31 -16
- package/src/x_ite/Browser/ParticleSystems/X3DParticleSystemsContext.js +5 -6
- 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 +26 -20
- package/src/x_ite/Browser/PointingDeviceSensor/X3DPointingDeviceSensorContext.js +17 -10
- package/src/x_ite/Browser/Rendering/X3DRenderingContext.js +38 -27
- package/src/x_ite/Browser/RigidBodyPhysics/AppliedParametersType.js +70 -0
- package/src/x_ite/Browser/Shaders/Shader.js +112 -92
- package/src/x_ite/Browser/Shaders/ShaderSource.js +140 -0
- package/src/x_ite/Browser/Shaders/ShaderTest.js +92 -77
- package/src/x_ite/Browser/Shaders/X3DShadersContext.js +134 -74
- 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/Text/PolygonText.js +153 -170
- 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 +49 -74
- 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 +147 -45
- 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 +1 -1
- 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 -224
- package/src/x_ite/Browser/X3DBrowserContext.js +60 -27
- 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/Annotation/GroupAnnotation.js +112 -0
- 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 +4 -4
- package/src/x_ite/Components/CADGeometry/CADFace.js +135 -30
- package/src/x_ite/Components/CADGeometry/CADLayer.js +3 -18
- package/src/x_ite/Components/CADGeometry/CADPart.js +4 -8
- package/src/x_ite/Components/CADGeometry/IndexedQuadSet.js +18 -10
- package/src/x_ite/Components/Core/WorldInfo.js +16 -6
- package/src/x_ite/Components/Core/X3DBindableNode.js +4 -33
- package/src/x_ite/Components/Core/X3DChildNode.js +14 -1
- package/src/x_ite/Components/Core/X3DNode.js +0 -63
- package/src/x_ite/Components/Core/X3DPrototypeInstance.js +128 -168
- package/src/x_ite/Components/Core.js +6 -9
- package/src/x_ite/Components/CubeMapTexturing/ComposedCubeMapTexture.js +38 -46
- package/src/x_ite/Components/CubeMapTexturing/GeneratedCubeMapTexture.js +31 -30
- package/src/x_ite/Components/CubeMapTexturing/ImageCubeMapTexture.js +42 -57
- package/src/x_ite/Components/CubeMapTexturing/X3DEnvironmentTextureNode.js +36 -48
- package/src/x_ite/Components/DIS/EspduTransform.js +12 -6
- package/src/x_ite/Components/DIS/ReceiverPdu.js +12 -6
- package/src/x_ite/Components/DIS/SignalPdu.js +12 -6
- package/src/x_ite/Components/DIS/TransmitterPdu.js +12 -6
- package/src/x_ite/Components/EnvironmentalEffects/Fog.js +5 -16
- package/src/x_ite/Components/EnvironmentalEffects/FogCoordinate.js +55 -3
- package/src/x_ite/Components/EnvironmentalEffects/LocalFog.js +3 -5
- package/src/x_ite/Components/EnvironmentalEffects/X3DBackgroundNode.js +116 -116
- package/src/x_ite/Components/EnvironmentalEffects/X3DFogObject.js +5 -6
- package/src/x_ite/Components/EnvironmentalEffects.js +6 -9
- package/src/x_ite/Components/EnvironmentalSensor/ProximitySensor.js +116 -117
- package/src/x_ite/Components/EnvironmentalSensor/TransformSensor.js +169 -49
- package/src/x_ite/Components/EnvironmentalSensor/VisibilitySensor.js +31 -27
- package/src/x_ite/Components/EnvironmentalSensor/X3DEnvironmentalSensorNode.js +12 -5
- package/src/x_ite/Components/EnvironmentalSensor.js +6 -9
- package/src/x_ite/Components/Followers/ColorChaser.js +1 -3
- package/src/x_ite/Components/Followers/ColorDamper.js +1 -3
- package/src/x_ite/Components/Followers/CoordinateChaser.js +1 -7
- package/src/x_ite/Components/Followers/CoordinateDamper.js +0 -6
- package/src/x_ite/Components/Followers/OrientationChaser.js +7 -3
- package/src/x_ite/Components/Followers/OrientationDamper.js +7 -3
- package/src/x_ite/Components/Followers/PositionChaser.js +1 -3
- package/src/x_ite/Components/Followers/PositionChaser2D.js +1 -3
- package/src/x_ite/Components/Followers/PositionDamper.js +1 -3
- package/src/x_ite/Components/Followers/PositionDamper2D.js +1 -3
- package/src/x_ite/Components/Followers/ScalarChaser.js +1 -3
- package/src/x_ite/Components/Followers/ScalarDamper.js +1 -3
- package/src/x_ite/Components/Followers/TexCoordChaser2D.js +1 -7
- package/src/x_ite/Components/Followers/TexCoordDamper2D.js +1 -7
- package/src/x_ite/Components/Followers/X3DChaserNode.js +20 -18
- package/src/x_ite/Components/Followers/X3DDamperNode.js +5 -7
- package/src/x_ite/Components/Followers/X3DFollowerNode.js +5 -7
- package/src/x_ite/Components/Followers.js +6 -9
- package/src/x_ite/Components/Geometry2D/Arc2D.js +10 -14
- package/src/x_ite/Components/Geometry2D/ArcClose2D.js +87 -86
- package/src/x_ite/Components/Geometry2D/Circle2D.js +1 -3
- package/src/x_ite/Components/Geometry2D/Disk2D.js +43 -58
- package/src/x_ite/Components/Geometry2D/Polyline2D.js +4 -8
- package/src/x_ite/Components/Geometry2D/Polypoint2D.js +3 -5
- package/src/x_ite/Components/Geometry2D/TriangleSet2D.js +20 -16
- package/src/x_ite/Components/Geometry3D/Cone.js +1 -3
- package/src/x_ite/Components/Geometry3D/Cylinder.js +3 -5
- package/src/x_ite/Components/Geometry3D/ElevationGrid.js +35 -17
- package/src/x_ite/Components/Geometry3D/Extrusion.js +125 -107
- package/src/x_ite/Components/Geometry3D/IndexedFaceSet.js +164 -142
- package/src/x_ite/Components/Geometry3D/Sphere.js +3 -5
- package/src/x_ite/Components/Geometry3D.js +6 -9
- package/src/x_ite/Components/Geospatial/GeoElevationGrid.js +7 -7
- package/src/x_ite/Components/Geospatial/GeoLOD.js +207 -124
- package/src/x_ite/Components/Geospatial/GeoLocation.js +6 -6
- package/src/x_ite/Components/Geospatial/GeoProximitySensor.js +5 -3
- package/src/x_ite/Components/Geospatial/GeoTransform.js +9 -9
- package/src/x_ite/Components/Geospatial/GeoViewpoint.js +27 -27
- package/src/x_ite/Components/Grouping/Group.js +3 -3
- package/src/x_ite/Components/Grouping/StaticGroup.js +49 -56
- package/src/x_ite/Components/Grouping/Switch.js +171 -21
- package/src/x_ite/Components/Grouping/Transform.js +3 -3
- package/src/x_ite/Components/Grouping/X3DBoundedObject.js +68 -15
- package/src/x_ite/Components/Grouping/X3DGroupingNode.js +339 -180
- package/src/x_ite/Components/Grouping/X3DTransformMatrix3DNode.js +51 -25
- package/src/x_ite/Components/Grouping/X3DTransformNode.js +2 -4
- package/src/x_ite/Components/Grouping.js +6 -9
- package/src/x_ite/Components/{H-Anim → HAnim}/HAnimDisplacer.js +4 -4
- package/src/x_ite/Components/{H-Anim → HAnim}/HAnimHumanoid.js +24 -14
- package/src/x_ite/Components/{H-Anim → HAnim}/HAnimJoint.js +44 -20
- package/src/x_ite/Components/HAnim/HAnimMotion.js +113 -0
- package/src/x_ite/Components/{H-Anim → HAnim}/HAnimSegment.js +6 -4
- package/src/x_ite/Components/{H-Anim → HAnim}/HAnimSite.js +4 -4
- package/src/x_ite/Components/Interpolation/OrientationInterpolator.js +8 -7
- package/src/x_ite/Components/Interpolation/SquadOrientationInterpolator.js +4 -3
- package/src/x_ite/Components/Interpolation.js +6 -9
- package/src/x_ite/Components/KeyDeviceSensor/X3DKeyDeviceSensorNode.js +1 -3
- package/src/x_ite/Components/Layering/Layer.js +12 -2
- package/src/x_ite/Components/Layering/LayerSet.js +4 -6
- package/src/x_ite/Components/Layering/Viewport.js +8 -8
- package/src/x_ite/Components/Layering/X3DLayerNode.js +67 -62
- package/src/x_ite/Components/Layering.js +6 -9
- package/src/x_ite/Components/Layout/LayoutGroup.js +18 -15
- package/src/x_ite/Components/Layout/LayoutLayer.js +10 -5
- package/src/x_ite/Components/Layout/ScreenFontStyle.js +12 -14
- package/src/x_ite/Components/Layout/ScreenGroup.js +25 -31
- package/src/x_ite/Components/Lighting/DirectionalLight.js +27 -22
- package/src/x_ite/Components/Lighting/PointLight.js +26 -29
- package/src/x_ite/Components/Lighting/SpotLight.js +29 -24
- package/src/x_ite/Components/Lighting/X3DLightNode.js +85 -66
- package/src/x_ite/Components/Lighting.js +6 -9
- package/src/x_ite/Components/NURBS/Contour2D.js +45 -1
- package/src/x_ite/Components/NURBS/ContourPolyline2D.js +53 -25
- package/src/x_ite/Components/NURBS/NurbsCurve.js +21 -24
- package/src/x_ite/Components/NURBS/NurbsCurve2D.js +44 -25
- package/src/x_ite/Components/NURBS/NurbsOrientationInterpolator.js +19 -21
- package/src/x_ite/Components/NURBS/NurbsPositionInterpolator.js +18 -20
- package/src/x_ite/Components/NURBS/NurbsSet.js +17 -6
- package/src/x_ite/Components/NURBS/NurbsSweptSurface.js +2 -2
- package/src/x_ite/Components/NURBS/NurbsSwungSurface.js +2 -2
- package/src/x_ite/Components/NURBS/NurbsTextureCoordinate.js +15 -16
- package/src/x_ite/Components/NURBS/NurbsTrimmedSurface.js +38 -1
- package/src/x_ite/Components/NURBS/X3DNurbsSurfaceGeometryNode.js +116 -43
- package/src/x_ite/Components/Navigation/Billboard.js +12 -11
- package/src/x_ite/Components/Navigation/Collision.js +10 -8
- package/src/x_ite/Components/Navigation/LOD.js +207 -59
- package/src/x_ite/Components/Navigation/NavigationInfo.js +29 -43
- package/src/x_ite/Components/Navigation/OrthoViewpoint.js +99 -18
- package/src/x_ite/Components/Navigation/Viewpoint.js +15 -15
- package/src/x_ite/Components/Navigation/ViewpointGroup.js +12 -5
- package/src/x_ite/Components/Navigation/X3DViewpointNode.js +137 -148
- package/src/x_ite/Components/Navigation.js +6 -9
- package/src/x_ite/Components/Networking/Anchor.js +22 -24
- package/src/x_ite/Components/Networking/Inline.js +63 -44
- package/src/x_ite/Components/Networking/X3DUrlObject.js +88 -8
- package/src/x_ite/Components/Networking.js +6 -9
- package/src/x_ite/Components/ParticleSystems/BoundedPhysicsModel.js +2 -2
- package/src/x_ite/Components/ParticleSystems/ParticleSystem.js +215 -199
- package/src/x_ite/Components/ParticleSystems/PolylineEmitter.js +44 -39
- package/src/x_ite/Components/ParticleSystems/SurfaceEmitter.js +48 -46
- package/src/x_ite/Components/ParticleSystems/VolumeEmitter.js +121 -117
- package/src/x_ite/Components/ParticleSystems/WindPhysicsModel.js +21 -18
- package/src/x_ite/Components/ParticleSystems/X3DParticleEmitterNode.js +20 -22
- package/src/x_ite/Components/Picking/LinePickSensor.js +251 -6
- package/src/x_ite/Components/Picking/PickableGroup.js +120 -7
- package/src/x_ite/Components/Picking/PointPickSensor.js +260 -8
- package/src/x_ite/Components/Picking/PrimitivePickSensor.js +174 -4
- package/src/x_ite/Components/Picking/VolumePickSensor.js +150 -4
- package/src/x_ite/Components/Picking/X3DPickSensorNode.js +377 -4
- package/src/x_ite/Components/Picking/X3DPickableObject.js +21 -1
- package/src/x_ite/Components/PointingDeviceSensor/CylinderSensor.js +26 -11
- package/src/x_ite/Components/PointingDeviceSensor.js +6 -9
- 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 +8 -10
- package/src/x_ite/Components/Rendering/Color.js +22 -13
- package/src/x_ite/Components/Rendering/ColorRGBA.js +28 -16
- package/src/x_ite/Components/Rendering/IndexedLineSet.js +52 -33
- package/src/x_ite/Components/Rendering/IndexedTriangleFanSet.js +17 -14
- package/src/x_ite/Components/Rendering/IndexedTriangleSet.js +9 -4
- package/src/x_ite/Components/Rendering/IndexedTriangleStripSet.js +17 -17
- package/src/x_ite/Components/Rendering/LineSet.js +44 -27
- package/src/x_ite/Components/Rendering/Normal.js +20 -4
- package/src/x_ite/Components/Rendering/PointSet.js +38 -16
- package/src/x_ite/Components/Rendering/TriangleFanSet.js +7 -9
- package/src/x_ite/Components/Rendering/TriangleStripSet.js +6 -8
- package/src/x_ite/Components/Rendering/X3DColorNode.js +16 -1
- package/src/x_ite/Components/Rendering/X3DComposedGeometryNode.js +80 -55
- package/src/x_ite/Components/Rendering/X3DCoordinateNode.js +11 -13
- package/src/x_ite/Components/Rendering/X3DGeometryNode.js +622 -477
- package/src/x_ite/Components/Rendering/X3DLineGeometryNode.js +159 -90
- package/src/x_ite/Components/Rendering.js +6 -9
- package/src/x_ite/Components/RigidBodyPhysics/BallJoint.js +8 -10
- package/src/x_ite/Components/RigidBodyPhysics/CollidableOffset.js +142 -26
- package/src/x_ite/Components/RigidBodyPhysics/CollidableShape.js +312 -128
- package/src/x_ite/Components/RigidBodyPhysics/CollisionCollection.js +91 -7
- package/src/x_ite/Components/RigidBodyPhysics/CollisionSensor.js +189 -4
- package/src/x_ite/Components/RigidBodyPhysics/CollisionSpace.js +82 -4
- package/src/x_ite/Components/RigidBodyPhysics/Contact.js +1 -1
- package/src/x_ite/Components/RigidBodyPhysics/DoubleAxisHingeJoint.js +49 -37
- package/src/x_ite/Components/RigidBodyPhysics/RigidBody.js +45 -39
- package/src/x_ite/Components/RigidBodyPhysics/RigidBodyCollection.js +41 -34
- package/src/x_ite/Components/RigidBodyPhysics/SingleAxisHingeJoint.js +25 -20
- package/src/x_ite/Components/RigidBodyPhysics/SliderJoint.js +8 -10
- package/src/x_ite/Components/RigidBodyPhysics/X3DNBodyCollidableNode.js +15 -16
- package/src/x_ite/Components/RigidBodyPhysics/X3DNBodyCollisionSpaceNode.js +2 -4
- package/src/x_ite/Components/Scripting/Script.js +147 -101
- package/src/x_ite/Components/Scripting/X3DScriptNode.js +2 -4
- package/src/x_ite/Components/Shaders/ComposedShader.js +17 -19
- package/src/x_ite/Components/Shaders/FloatVertexAttribute.js +9 -3
- package/src/x_ite/Components/Shaders/Matrix3VertexAttribute.js +10 -3
- package/src/x_ite/Components/Shaders/Matrix4VertexAttribute.js +10 -3
- package/src/x_ite/Components/Shaders/PackagedShader.js +18 -14
- package/src/x_ite/Components/Shaders/ShaderPart.js +30 -18
- package/src/x_ite/Components/Shaders/ShaderProgram.js +15 -11
- package/src/x_ite/Components/Shaders/X3DProgrammableShaderObject.js +681 -558
- package/src/x_ite/Components/Shaders/X3DShaderNode.js +48 -12
- package/src/x_ite/Components/Shaders.js +15 -18
- package/src/x_ite/Components/Shape/Appearance.js +153 -77
- package/src/x_ite/Components/Shape/FillProperties.js +63 -4
- package/src/x_ite/Components/Shape/LineProperties.js +27 -5
- package/src/x_ite/Components/Shape/Material.js +48 -62
- package/src/x_ite/Components/Shape/PointProperties.js +162 -0
- package/src/x_ite/Components/Shape/Shape.js +86 -39
- package/src/x_ite/Components/Shape/TwoSidedMaterial.js +53 -59
- package/src/x_ite/Components/Shape/UnlitMaterial.js +109 -0
- package/src/x_ite/Components/Shape/X3DAppearanceNode.js +9 -6
- package/src/x_ite/Components/Shape/X3DMaterialNode.js +16 -3
- package/src/x_ite/Components/Shape/X3DOneSidedMaterialNode.js +111 -0
- package/src/x_ite/Components/Shape/X3DShapeNode.js +41 -17
- package/src/x_ite/Components/Shape.js +22 -16
- package/src/x_ite/Components/Sound/AudioClip.js +36 -50
- package/src/x_ite/Components/Sound/Sound.js +36 -36
- package/src/x_ite/Components/Sound/X3DSoundSourceNode.js +18 -6
- package/src/x_ite/Components/Sound.js +6 -9
- package/src/x_ite/Components/Text/FontStyle.js +10 -12
- package/src/x_ite/Components/Text/Text.js +6 -6
- package/src/x_ite/Components/Text/X3DFontStyleNode.js +56 -87
- package/src/x_ite/Components/Text.js +6 -9
- package/src/x_ite/Components/Texturing/ImageTexture.js +48 -63
- package/src/x_ite/Components/Texturing/MovieTexture.js +42 -56
- package/src/x_ite/Components/Texturing/MultiTexture.js +236 -11
- package/src/x_ite/Components/Texturing/MultiTextureCoordinate.js +73 -6
- package/src/x_ite/Components/Texturing/MultiTextureTransform.js +45 -4
- package/src/x_ite/Components/Texturing/PixelTexture.js +45 -11
- package/src/x_ite/Components/Texturing/TextureCoordinate.js +32 -17
- package/src/x_ite/Components/Texturing/TextureCoordinateGenerator.js +68 -8
- package/src/x_ite/Components/Texturing/TextureProperties.js +96 -65
- package/src/x_ite/Components/Texturing/TextureTransform.js +55 -47
- 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 -95
- package/src/x_ite/Components/Texturing/X3DTexture2DNode.js.~1~ +209 -0
- package/src/x_ite/Components/Texturing/X3DTextureCoordinateNode.js +3 -17
- package/src/x_ite/Components/Texturing/X3DTextureNode.js +6 -67
- package/src/x_ite/Components/Texturing/X3DTextureTransformNode.js +4 -11
- package/src/x_ite/Components/Texturing.js +31 -25
- package/src/x_ite/Components/Texturing3D/ComposedTexture3D.js +88 -4
- package/src/x_ite/Components/Texturing3D/ImageTexture3D.js +105 -13
- package/src/x_ite/Components/Texturing3D/PixelTexture3D.js +124 -4
- package/src/x_ite/Components/Texturing3D/TextureCoordinate3D.js +35 -18
- package/src/x_ite/Components/Texturing3D/TextureCoordinate4D.js +35 -18
- package/src/x_ite/Components/Texturing3D/TextureTransform3D.js +41 -31
- package/src/x_ite/Components/Texturing3D/TextureTransformMatrix3D.js +18 -11
- package/src/x_ite/Components/Texturing3D/X3DTexture3DNode.js +110 -6
- package/src/x_ite/Components/Time/TimeSensor.js +23 -19
- package/src/x_ite/Components/Time/X3DTimeDependentNode.js +11 -7
- package/src/x_ite/Components/Time.js +6 -9
- package/src/x_ite/Components/VolumeRendering/BlendedVolumeStyle.js +309 -8
- package/src/x_ite/Components/VolumeRendering/BoundaryEnhancementVolumeStyle.js +58 -4
- package/src/x_ite/Components/VolumeRendering/CartoonVolumeStyle.js +217 -6
- package/src/x_ite/Components/VolumeRendering/ComposedVolumeStyle.js +132 -3
- package/src/x_ite/Components/VolumeRendering/EdgeEnhancementVolumeStyle.js +86 -5
- package/src/x_ite/Components/VolumeRendering/IsoSurfaceVolumeData.js +309 -11
- package/src/x_ite/Components/VolumeRendering/OpacityMapVolumeStyle.js +85 -3
- package/src/x_ite/Components/VolumeRendering/ProjectionVolumeStyle.js +134 -2
- package/src/x_ite/Components/VolumeRendering/SegmentedVolumeData.js +222 -9
- package/src/x_ite/Components/VolumeRendering/ShadedVolumeStyle.js +191 -8
- package/src/x_ite/Components/VolumeRendering/SilhouetteEnhancementVolumeStyle.js +85 -6
- package/src/x_ite/Components/VolumeRendering/ToneMappedVolumeStyle.js +95 -5
- package/src/x_ite/Components/VolumeRendering/VolumeData.js +153 -8
- package/src/x_ite/Components/VolumeRendering/X3DVolumeDataNode.js +155 -3
- package/src/x_ite/Components/VolumeRendering/X3DVolumeRenderStyleNode.js +62 -0
- package/src/x_ite/Components/X_ITE/BlendMode.js +51 -51
- package/src/x_ite/Components.js +11 -16
- package/src/x_ite/Configuration/ComponentInfo.js +12 -6
- package/src/x_ite/Configuration/ComponentInfoArray.js +4 -7
- package/src/x_ite/Configuration/ProfileInfo.js +10 -6
- package/src/x_ite/Configuration/SupportedComponents.js +66 -40
- package/src/x_ite/Configuration/SupportedNodes.js +22 -6
- package/src/x_ite/Configuration/SupportedProfiles.js +91 -89
- package/src/x_ite/Configuration/UnitInfo.js +12 -2
- package/src/x_ite/Configuration/X3DInfoArray.js +37 -18
- package/src/x_ite/Execution/BindableList.js +63 -38
- package/src/x_ite/Execution/BindableStack.js +63 -71
- package/src/x_ite/Execution/ExportedNode.js +25 -2
- package/src/x_ite/Execution/ImportedNode.js +122 -39
- package/src/x_ite/Execution/Scene.js +22 -14
- package/src/x_ite/Execution/World.js +22 -19
- package/src/x_ite/Execution/X3DExecutionContext.js +381 -221
- package/src/x_ite/Execution/X3DScene.js +213 -53
- package/src/x_ite/{Error.js → Fallback.js} +26 -29
- package/src/x_ite/Fields/ArrayFields.js +176 -57
- package/src/x_ite/Fields/SFBool.js +6 -5
- package/src/x_ite/Fields/SFColor.js +24 -21
- package/src/x_ite/Fields/SFColorRGBA.js +23 -23
- package/src/x_ite/Fields/SFDouble.js +6 -5
- package/src/x_ite/Fields/SFFloat.js +7 -6
- package/src/x_ite/Fields/SFImage.js +37 -36
- package/src/x_ite/Fields/SFInt32.js +5 -4
- package/src/x_ite/Fields/SFMatrix3.js +19 -15
- package/src/x_ite/Fields/SFMatrix4.js +19 -15
- package/src/x_ite/Fields/SFMatrixPrototypeTemplate.js +10 -2
- package/src/x_ite/Fields/SFNode.js +105 -53
- package/src/x_ite/Fields/SFNodeCache.js +93 -0
- package/src/x_ite/Fields/SFRotation.js +31 -27
- package/src/x_ite/Fields/SFString.js +9 -8
- package/src/x_ite/Fields/SFTime.js +6 -5
- package/src/x_ite/Fields/SFVec2.js +17 -13
- package/src/x_ite/Fields/SFVec3.js +21 -17
- package/src/x_ite/Fields/SFVec4.js +24 -20
- package/src/x_ite/Fields/SFVecPrototypeTemplate.js +8 -4
- package/src/x_ite/Fields.js +2 -6
- package/src/x_ite/InputOutput/FileLoader.js +174 -190
- package/src/x_ite/InputOutput/Generator.js +133 -104
- package/src/x_ite/Parser/HTMLSupport.js +3 -596
- package/src/x_ite/Parser/JSONParser.js +348 -245
- package/src/x_ite/Parser/Parser.js +314 -303
- package/src/x_ite/Parser/X3DParser.js +41 -20
- package/src/x_ite/Parser/XMLParser.js +178 -60
- package/src/x_ite/Prototype/ExternProtoDeclarationArray.js +17 -0
- package/src/x_ite/Prototype/ProtoDeclarationArray.js +17 -0
- package/src/x_ite/Prototype/X3DExternProtoDeclaration.js +104 -44
- package/src/x_ite/Prototype/X3DProtoDeclaration.js +111 -42
- package/src/x_ite/Prototype/X3DProtoDeclarationNode.js +16 -14
- package/src/x_ite/Rendering/DependentRenderer.js +7 -9
- package/src/x_ite/Rendering/TextureBuffer.js +24 -19
- package/src/x_ite/Rendering/X3DRenderObject.js +455 -428
- package/src/x_ite/Routing/RouteArray.js +34 -11
- package/src/x_ite/Routing/X3DRoute.js +60 -60
- package/src/x_ite/Routing/X3DRoutingContext.js +6 -6
- package/src/x_ite/X3D.js +30 -37
- package/src/x_ite.config.js +40 -5
- package/src/x_ite.css +165 -45
- package/src/x_ite.html +49 -29
- package/src/x_ite.js +86 -25
- package/x_ite.min.html +49 -22
- package/.bzrignore +0 -3
- package/AUTHORS.md +0 -6
- package/STYLE_GUIDE.md +0 -51
- package/X_ITE.sln +0 -54
- package/X_ITE.userprefs +0 -14
- package/build/build.mdproj +0 -47
- package/build/cad-geometry.build.js +0 -15
- package/build/geospatial.build.js +0 -15
- package/build/h-anim.build.js +0 -15
- package/build/nurbs.build.js +0 -15
- package/build/particle-systems.build.js +0 -15
- package/build/parts/cad-geometry.end.frag +0 -2
- package/build/parts/cad-geometry.start.frag +0 -6
- package/build/parts/geospatial.end.frag +0 -2
- package/build/parts/geospatial.start.frag +0 -6
- package/build/parts/h-anim.end.frag +0 -2
- package/build/parts/h-anim.start.frag +0 -6
- package/build/parts/nurbs.end.frag +0 -2
- package/build/parts/nurbs.start.frag +0 -6
- package/build/parts/particle-systems.end.frag +0 -2
- package/build/parts/particle-systems.start.frag +0 -6
- package/build/parts/rigid-body-physics.end.frag +0 -2
- package/build/parts/rigid-body-physics.start.frag +0 -6
- package/build/parts/texturing-3d.end.frag +0 -2
- package/build/parts/texturing-3d.start.frag +0 -6
- package/build/parts/x_ite.end.frag +0 -9
- package/build/parts/x_ite.start.frag +0 -6
- package/build/rigid-body-physics.build.js +0 -15
- package/build/texturing-3d.build.js +0 -15
- package/dist/components/README +0 -3
- package/dist/components/cad-geometry.min.js +0 -1
- package/dist/components/geospatial.min.js +0 -2
- package/dist/components/h-anim.min.js +0 -1
- package/dist/components/nurbs.min.js +0 -2
- package/dist/components/particle-systems.min.js +0 -2
- package/dist/components/rigid-body-physics.js +0 -3761
- package/dist/components/rigid-body-physics.min.js +0 -56
- package/dist/components/texturing-3d.min.js +0 -1
- package/dist/dist.mdproj +0 -61
- package/dist/images/logo.128.png +0 -0
- package/fonts/fonts.mdproj +0 -29
- package/meta/meta.mdproj +0 -35
- package/src/components/cad-geometry.config.js +0 -56
- package/src/components/geospatial.config.js +0 -56
- package/src/components/h-anim.config.js +0 -56
- package/src/components/nurbs.config.js +0 -61
- package/src/components/particle-systems.config.js +0 -56
- package/src/components/rigid-body-physics.config.js +0 -61
- package/src/components/texturing-3d.config.js +0 -56
- package/src/images/logo.128.png +0 -0
- package/src/locale/de.mo +0 -0
- package/src/locale/fr.mo +0 -0
- package/src/src.mdproj +0 -698
- package/src/standard/Networking/URI.js +0 -785
- package/src/test.x3d +0 -225
- package/src/x_ite/Browser/Shaders/Background.fs +0 -31
- package/src/x_ite/Browser/Shaders/Background.vs +0 -23
- package/src/x_ite/Browser/Shaders/Depth.fs +0 -32
- package/src/x_ite/Browser/Shaders/Depth.vs +0 -21
- package/src/x_ite/Browser/Shaders/Gouraud.fs +0 -135
- package/src/x_ite/Browser/Shaders/Gouraud.vs +0 -145
- package/src/x_ite/Browser/Shaders/Phong.fs +0 -269
- package/src/x_ite/Browser/Shaders/Phong.vs +0 -47
- package/src/x_ite/Browser/Shaders/PointSet.fs +0 -86
- package/src/x_ite/Browser/Shaders/Types.h +0 -55
- package/src/x_ite/Browser/Shaders/Wireframe.fs +0 -82
- package/src/x_ite/Browser/Shaders/Wireframe.vs +0 -61
- package/src/x_ite/Components/DIS.js +0 -91
- package/src/x_ite/Components/Picking.js +0 -94
- package/src/x_ite/Components/VolumeRendering.js +0 -121
|
@@ -0,0 +1,3976 @@
|
|
|
1
|
+
(function (globalModule, globalRequire)
|
|
2
|
+
{
|
|
3
|
+
|
|
4
|
+
if (typeof __filename === "undefined")
|
|
5
|
+
{
|
|
6
|
+
globalModule = undefined;
|
|
7
|
+
globalRequire = undefined;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
// Undefine global variables.
|
|
11
|
+
var module = { }, exports, process;
|
|
12
|
+
|
|
13
|
+
const
|
|
14
|
+
define = X3D .define,
|
|
15
|
+
require = X3D .require;
|
|
16
|
+
/* -*- Mode: JavaScript; coding: utf-8; tab-width: 3; indent-tabs-mode: tab; c-basic-offset: 3 -*-
|
|
17
|
+
*******************************************************************************
|
|
18
|
+
*
|
|
19
|
+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
20
|
+
*
|
|
21
|
+
* Copyright create3000, ScheffelstraÃe 31a, Leipzig, Germany 2011.
|
|
22
|
+
*
|
|
23
|
+
* All rights reserved. Holger Seelig <holger.seelig@yahoo.de>.
|
|
24
|
+
*
|
|
25
|
+
* The copyright notice above does not evidence any actual of intended
|
|
26
|
+
* publication of such source code, and is an unpublished work by create3000.
|
|
27
|
+
* This material contains CONFIDENTIAL INFORMATION that is the property of
|
|
28
|
+
* create3000.
|
|
29
|
+
*
|
|
30
|
+
* No permission is granted to copy, distribute, or create derivative works from
|
|
31
|
+
* the contents of this software, in whole or in part, without the prior written
|
|
32
|
+
* permission of create3000.
|
|
33
|
+
*
|
|
34
|
+
* NON-MILITARY USE ONLY
|
|
35
|
+
*
|
|
36
|
+
* All create3000 software are effectively free software with a non-military use
|
|
37
|
+
* restriction. It is free. Well commented source is provided. You may reuse the
|
|
38
|
+
* source in any way you please with the exception anything that uses it must be
|
|
39
|
+
* marked to indicate is contains 'non-military use only' components.
|
|
40
|
+
*
|
|
41
|
+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
42
|
+
*
|
|
43
|
+
* Copyright 2015, 2016 Holger Seelig <holger.seelig@yahoo.de>.
|
|
44
|
+
*
|
|
45
|
+
* This file is part of the X_ITE Project.
|
|
46
|
+
*
|
|
47
|
+
* X_ITE is free software: you can redistribute it and/or modify it under the
|
|
48
|
+
* terms of the GNU General Public License version 3 only, as published by the
|
|
49
|
+
* Free Software Foundation.
|
|
50
|
+
*
|
|
51
|
+
* X_ITE is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
52
|
+
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
|
53
|
+
* A PARTICULAR PURPOSE. See the GNU General Public License version 3 for more
|
|
54
|
+
* details (a copy is included in the LICENSE file that accompanied this code).
|
|
55
|
+
*
|
|
56
|
+
* You should have received a copy of the GNU General Public License version 3
|
|
57
|
+
* along with X_ITE. If not, see <http://www.gnu.org/licenses/gpl.html> for a
|
|
58
|
+
* copy of the GPLv3 License.
|
|
59
|
+
*
|
|
60
|
+
* For Silvio, Joy and Adi.
|
|
61
|
+
*
|
|
62
|
+
******************************************************************************/
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
define ('x_ite/Components/VolumeRendering/X3DVolumeRenderStyleNode',[
|
|
66
|
+
"x_ite/Components/Core/X3DNode",
|
|
67
|
+
"x_ite/Bits/X3DConstants",
|
|
68
|
+
],
|
|
69
|
+
function (X3DNode,
|
|
70
|
+
X3DConstants)
|
|
71
|
+
{
|
|
72
|
+
"use strict";
|
|
73
|
+
|
|
74
|
+
function X3DVolumeRenderStyleNode (executionContext)
|
|
75
|
+
{
|
|
76
|
+
X3DNode .call (this, executionContext);
|
|
77
|
+
|
|
78
|
+
this .addType (X3DConstants .X3DVolumeRenderStyleNode);
|
|
79
|
+
|
|
80
|
+
this .volumeDataNodes = new Set ();
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
X3DVolumeRenderStyleNode .prototype = Object .assign (Object .create (X3DNode .prototype),
|
|
84
|
+
{
|
|
85
|
+
constructor: X3DVolumeRenderStyleNode,
|
|
86
|
+
addShaderFields: function (shaderNode)
|
|
87
|
+
{ },
|
|
88
|
+
getUniformsText: function ()
|
|
89
|
+
{
|
|
90
|
+
return "";
|
|
91
|
+
},
|
|
92
|
+
getFunctionsText: function ()
|
|
93
|
+
{
|
|
94
|
+
return "";
|
|
95
|
+
},
|
|
96
|
+
getVolumeData: function ()
|
|
97
|
+
{
|
|
98
|
+
return this .volumeDataNodes;
|
|
99
|
+
},
|
|
100
|
+
addVolumeData: function (volumeDataNode)
|
|
101
|
+
{
|
|
102
|
+
this .volumeDataNodes .add (volumeDataNode);
|
|
103
|
+
},
|
|
104
|
+
removeVolumeData: function (volumeDataNode)
|
|
105
|
+
{
|
|
106
|
+
this .volumeDataNodes .delete (volumeDataNode);
|
|
107
|
+
},
|
|
108
|
+
getNormalText: function (surfaceNormalsNode)
|
|
109
|
+
{
|
|
110
|
+
var string = "";
|
|
111
|
+
|
|
112
|
+
if (surfaceNormalsNode)
|
|
113
|
+
{
|
|
114
|
+
string += "uniform sampler3D surfaceNormals_" + this .getId () + ";\n";
|
|
115
|
+
|
|
116
|
+
string += "\n";
|
|
117
|
+
string += "vec4\n";
|
|
118
|
+
string += "getNormal_" + this .getId () + " (in vec3 texCoord)\n";
|
|
119
|
+
string += "{\n";
|
|
120
|
+
string += " vec3 n = texture (surfaceNormals_" + this .getId () + ", texCoord) .xyz * 2.0 - 1.0;\n";
|
|
121
|
+
string += "\n";
|
|
122
|
+
string += " return vec4 (normalize (x3d_TextureNormalMatrix * n), length (n));\n";
|
|
123
|
+
string += "}\n";
|
|
124
|
+
}
|
|
125
|
+
else
|
|
126
|
+
{
|
|
127
|
+
string += "\n";
|
|
128
|
+
string += "vec4\n";
|
|
129
|
+
string += "getNormal_" + this .getId () + " (in vec3 texCoord)\n";
|
|
130
|
+
string += "{\n";
|
|
131
|
+
string += " vec4 offset = vec4 (1.0 / x3d_TextureSize, 0.0);\n";
|
|
132
|
+
string += " float i0 = texture (x3d_Texture3D [0], texCoord + offset .xww) .r;\n";
|
|
133
|
+
string += " float i1 = texture (x3d_Texture3D [0], texCoord - offset .xww) .r;\n";
|
|
134
|
+
string += " float i2 = texture (x3d_Texture3D [0], texCoord + offset .wyw) .r;\n";
|
|
135
|
+
string += " float i3 = texture (x3d_Texture3D [0], texCoord - offset .wyw) .r;\n";
|
|
136
|
+
string += " float i4 = texture (x3d_Texture3D [0], texCoord + offset .wwz) .r;\n";
|
|
137
|
+
string += " float i5 = texture (x3d_Texture3D [0], texCoord - offset .wwz) .r;\n";
|
|
138
|
+
string += " vec3 n = vec3 (i1 - i0, i3 - i2, i5 - i4);\n";
|
|
139
|
+
string += "\n";
|
|
140
|
+
string += " return vec4 (normalize (x3d_TextureNormalMatrix * n), length (n));\n";
|
|
141
|
+
string += "}\n";
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
return string;
|
|
145
|
+
},
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
return X3DVolumeRenderStyleNode;
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
/* -*- Mode: JavaScript; coding: utf-8; tab-width: 3; indent-tabs-mode: tab; c-basic-offset: 3 -*-
|
|
152
|
+
*******************************************************************************
|
|
153
|
+
*
|
|
154
|
+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
155
|
+
*
|
|
156
|
+
* Copyright create3000, ScheffelstraÃe 31a, Leipzig, Germany 2011.
|
|
157
|
+
*
|
|
158
|
+
* All rights reserved. Holger Seelig <holger.seelig@yahoo.de>.
|
|
159
|
+
*
|
|
160
|
+
* The copyright notice above does not evidence any actual of intended
|
|
161
|
+
* publication of such source code, and is an unpublished work by create3000.
|
|
162
|
+
* This material contains CONFIDENTIAL INFORMATION that is the property of
|
|
163
|
+
* create3000.
|
|
164
|
+
*
|
|
165
|
+
* No permission is granted to copy, distribute, or create derivative works from
|
|
166
|
+
* the contents of this software, in whole or in part, without the prior written
|
|
167
|
+
* permission of create3000.
|
|
168
|
+
*
|
|
169
|
+
* NON-MILITARY USE ONLY
|
|
170
|
+
*
|
|
171
|
+
* All create3000 software are effectively free software with a non-military use
|
|
172
|
+
* restriction. It is free. Well commented source is provided. You may reuse the
|
|
173
|
+
* source in any way you please with the exception anything that uses it must be
|
|
174
|
+
* marked to indicate is contains 'non-military use only' components.
|
|
175
|
+
*
|
|
176
|
+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
177
|
+
*
|
|
178
|
+
* Copyright 2015, 2016 Holger Seelig <holger.seelig@yahoo.de>.
|
|
179
|
+
*
|
|
180
|
+
* This file is part of the X_ITE Project.
|
|
181
|
+
*
|
|
182
|
+
* X_ITE is free software: you can redistribute it and/or modify it under the
|
|
183
|
+
* terms of the GNU General Public License version 3 only, as published by the
|
|
184
|
+
* Free Software Foundation.
|
|
185
|
+
*
|
|
186
|
+
* X_ITE is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
187
|
+
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
|
188
|
+
* A PARTICULAR PURPOSE. See the GNU General Public License version 3 for more
|
|
189
|
+
* details (a copy is included in the LICENSE file that accompanied this code).
|
|
190
|
+
*
|
|
191
|
+
* You should have received a copy of the GNU General Public License version 3
|
|
192
|
+
* along with X_ITE. If not, see <http://www.gnu.org/licenses/gpl.html> for a
|
|
193
|
+
* copy of the GPLv3 License.
|
|
194
|
+
*
|
|
195
|
+
* For Silvio, Joy and Adi.
|
|
196
|
+
*
|
|
197
|
+
******************************************************************************/
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
define ('x_ite/Components/VolumeRendering/X3DComposableVolumeRenderStyleNode',[
|
|
201
|
+
"x_ite/Components/VolumeRendering/X3DVolumeRenderStyleNode",
|
|
202
|
+
"x_ite/Bits/X3DConstants",
|
|
203
|
+
],
|
|
204
|
+
function (X3DVolumeRenderStyleNode,
|
|
205
|
+
X3DConstants)
|
|
206
|
+
{
|
|
207
|
+
"use strict";
|
|
208
|
+
|
|
209
|
+
function X3DComposableVolumeRenderStyleNode (executionContext)
|
|
210
|
+
{
|
|
211
|
+
X3DVolumeRenderStyleNode .call (this, executionContext);
|
|
212
|
+
|
|
213
|
+
this .addType (X3DConstants .X3DComposableVolumeRenderStyleNode);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
X3DComposableVolumeRenderStyleNode .prototype = Object .assign (Object .create (X3DVolumeRenderStyleNode .prototype),
|
|
217
|
+
{
|
|
218
|
+
constructor: X3DComposableVolumeRenderStyleNode,
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
return X3DComposableVolumeRenderStyleNode;
|
|
222
|
+
});
|
|
223
|
+
|
|
224
|
+
/* -*- Mode: JavaScript; coding: utf-8; tab-width: 3; indent-tabs-mode: tab; c-basic-offset: 3 -*-
|
|
225
|
+
*******************************************************************************
|
|
226
|
+
*
|
|
227
|
+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
228
|
+
*
|
|
229
|
+
* Copyright create3000, ScheffelstraÃe 31a, Leipzig, Germany 2011.
|
|
230
|
+
*
|
|
231
|
+
* All rights reserved. Holger Seelig <holger.seelig@yahoo.de>.
|
|
232
|
+
*
|
|
233
|
+
* The copyright notice above does not evidence any actual of intended
|
|
234
|
+
* publication of such source code, and is an unpublished work by create3000.
|
|
235
|
+
* This material contains CONFIDENTIAL INFORMATION that is the property of
|
|
236
|
+
* create3000.
|
|
237
|
+
*
|
|
238
|
+
* No permission is granted to copy, distribute, or create derivative works from
|
|
239
|
+
* the contents of this software, in whole or in part, without the prior written
|
|
240
|
+
* permission of create3000.
|
|
241
|
+
*
|
|
242
|
+
* NON-MILITARY USE ONLY
|
|
243
|
+
*
|
|
244
|
+
* All create3000 software are effectively free software with a non-military use
|
|
245
|
+
* restriction. It is free. Well commented source is provided. You may reuse the
|
|
246
|
+
* source in any way you please with the exception anything that uses it must be
|
|
247
|
+
* marked to indicate is contains 'non-military use only' components.
|
|
248
|
+
*
|
|
249
|
+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
250
|
+
*
|
|
251
|
+
* Copyright 2015, 2016 Holger Seelig <holger.seelig@yahoo.de>.
|
|
252
|
+
*
|
|
253
|
+
* This file is part of the X_ITE Project.
|
|
254
|
+
*
|
|
255
|
+
* X_ITE is free software: you can redistribute it and/or modify it under the
|
|
256
|
+
* terms of the GNU General Public License version 3 only, as published by the
|
|
257
|
+
* Free Software Foundation.
|
|
258
|
+
*
|
|
259
|
+
* X_ITE is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
260
|
+
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
|
261
|
+
* A PARTICULAR PURPOSE. See the GNU General Public License version 3 for more
|
|
262
|
+
* details (a copy is included in the LICENSE file that accompanied this code).
|
|
263
|
+
*
|
|
264
|
+
* You should have received a copy of the GNU General Public License version 3
|
|
265
|
+
* along with X_ITE. If not, see <http://www.gnu.org/licenses/gpl.html> for a
|
|
266
|
+
* copy of the GPLv3 License.
|
|
267
|
+
*
|
|
268
|
+
* For Silvio, Joy and Adi.
|
|
269
|
+
*
|
|
270
|
+
******************************************************************************/
|
|
271
|
+
|
|
272
|
+
|
|
273
|
+
define ('x_ite/Components/VolumeRendering/OpacityMapVolumeStyle',[
|
|
274
|
+
"x_ite/Fields",
|
|
275
|
+
"x_ite/Basic/X3DFieldDefinition",
|
|
276
|
+
"x_ite/Basic/FieldDefinitionArray",
|
|
277
|
+
"x_ite/Components/VolumeRendering/X3DComposableVolumeRenderStyleNode",
|
|
278
|
+
"x_ite/Bits/X3DConstants",
|
|
279
|
+
"x_ite/Bits/X3DCast",
|
|
280
|
+
],
|
|
281
|
+
function (Fields,
|
|
282
|
+
X3DFieldDefinition,
|
|
283
|
+
FieldDefinitionArray,
|
|
284
|
+
X3DComposableVolumeRenderStyleNode,
|
|
285
|
+
X3DConstants,
|
|
286
|
+
X3DCast)
|
|
287
|
+
{
|
|
288
|
+
"use strict";
|
|
289
|
+
|
|
290
|
+
function OpacityMapVolumeStyle (executionContext)
|
|
291
|
+
{
|
|
292
|
+
X3DComposableVolumeRenderStyleNode .call (this, executionContext);
|
|
293
|
+
|
|
294
|
+
this .addType (X3DConstants .OpacityMapVolumeStyle);
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
OpacityMapVolumeStyle .prototype = Object .assign (Object .create (X3DComposableVolumeRenderStyleNode .prototype),
|
|
298
|
+
{
|
|
299
|
+
constructor: OpacityMapVolumeStyle,
|
|
300
|
+
fieldDefinitions: new FieldDefinitionArray ([
|
|
301
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "enabled", new Fields .SFBool (true)),
|
|
302
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "metadata", new Fields .SFNode ()),
|
|
303
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "transferFunction", new Fields .SFNode ()),
|
|
304
|
+
]),
|
|
305
|
+
getTypeName: function ()
|
|
306
|
+
{
|
|
307
|
+
return "OpacityMapVolumeStyle";
|
|
308
|
+
},
|
|
309
|
+
getComponentName: function ()
|
|
310
|
+
{
|
|
311
|
+
return "VolumeRendering";
|
|
312
|
+
},
|
|
313
|
+
getContainerField: function ()
|
|
314
|
+
{
|
|
315
|
+
return "renderStyle";
|
|
316
|
+
},
|
|
317
|
+
initialize: function ()
|
|
318
|
+
{
|
|
319
|
+
X3DComposableVolumeRenderStyleNode .prototype .initialize .call (this);
|
|
320
|
+
|
|
321
|
+
var gl = this .getBrowser () .getContext ();
|
|
322
|
+
|
|
323
|
+
if (gl .getVersion () < 2)
|
|
324
|
+
return;
|
|
325
|
+
|
|
326
|
+
this .transferFunction_ .addInterest ("set_transferFunction__", this);
|
|
327
|
+
|
|
328
|
+
this .set_transferFunction__ ();
|
|
329
|
+
},
|
|
330
|
+
set_transferFunction__: function ()
|
|
331
|
+
{
|
|
332
|
+
this .transferFunctionNode = X3DCast (X3DConstants .X3DTexture2DNode, this .transferFunction_);
|
|
333
|
+
|
|
334
|
+
if (! this .transferFunctionNode)
|
|
335
|
+
this .transferFunctionNode = X3DCast (X3DConstants .X3DTexture3DNode, this .transferFunction_);
|
|
336
|
+
|
|
337
|
+
if (! this .transferFunctionNode)
|
|
338
|
+
this .transferFunctionNode = this .getBrowser () .getDefaultTransferFunction ();
|
|
339
|
+
},
|
|
340
|
+
addShaderFields: function (shaderNode)
|
|
341
|
+
{
|
|
342
|
+
if (! this .enabled_ .getValue ())
|
|
343
|
+
return;
|
|
344
|
+
|
|
345
|
+
shaderNode .addUserDefinedField (X3DConstants .inputOutput, "transferFunction_" + this .getId (), new Fields .SFNode (this .transferFunctionNode));
|
|
346
|
+
},
|
|
347
|
+
getUniformsText: function ()
|
|
348
|
+
{
|
|
349
|
+
if (! this .enabled_ .getValue ())
|
|
350
|
+
return "";
|
|
351
|
+
|
|
352
|
+
var string = "";
|
|
353
|
+
|
|
354
|
+
string += "\n";
|
|
355
|
+
string += "// OpacityMapVolumeStyle\n";
|
|
356
|
+
string += "\n";
|
|
357
|
+
|
|
358
|
+
if (this .transferFunctionNode .getType () .indexOf (X3DConstants .X3DTexture2DNode) !== -1)
|
|
359
|
+
{
|
|
360
|
+
string += "uniform sampler2D transferFunction_" + this .getId () + ";\n";
|
|
361
|
+
|
|
362
|
+
string += "\n";
|
|
363
|
+
string += "vec4\n";
|
|
364
|
+
string += "getOpacityMapStyle_" + this .getId () + " (in vec4 originalColor)\n";
|
|
365
|
+
string += "{\n";
|
|
366
|
+
string += " return texture (transferFunction_" + this .getId () + ", originalColor .rg);\n";
|
|
367
|
+
string += "}\n";
|
|
368
|
+
}
|
|
369
|
+
else
|
|
370
|
+
{
|
|
371
|
+
string += "uniform sampler3D transferFunction_" + this .getId () + ";\n";
|
|
372
|
+
|
|
373
|
+
string += "\n";
|
|
374
|
+
string += "vec4\n";
|
|
375
|
+
string += "getOpacityMapStyle_" + this .getId () + " (in vec4 originalColor)\n";
|
|
376
|
+
string += "{\n";
|
|
377
|
+
string += " return texture (transferFunction_" + this .getId () + ", originalColor .rgb);\n";
|
|
378
|
+
string += "}\n";
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
return string;
|
|
382
|
+
},
|
|
383
|
+
getFunctionsText: function ()
|
|
384
|
+
{
|
|
385
|
+
if (! this .enabled_ .getValue ())
|
|
386
|
+
return "";
|
|
387
|
+
|
|
388
|
+
var string = "";
|
|
389
|
+
|
|
390
|
+
string += "\n";
|
|
391
|
+
string += " // OpacityMapVolumeStyle\n";
|
|
392
|
+
string += "\n";
|
|
393
|
+
string += " textureColor = getOpacityMapStyle_" + this .getId () + " (textureColor);\n";
|
|
394
|
+
|
|
395
|
+
return string;
|
|
396
|
+
},
|
|
397
|
+
});
|
|
398
|
+
|
|
399
|
+
return OpacityMapVolumeStyle;
|
|
400
|
+
});
|
|
401
|
+
|
|
402
|
+
/* -*- Mode: JavaScript; coding: utf-8; tab-width: 3; indent-tabs-mode: tab; c-basic-offset: 3 -*-
|
|
403
|
+
*******************************************************************************
|
|
404
|
+
*
|
|
405
|
+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
406
|
+
*
|
|
407
|
+
* Copyright create3000, Scheffelstraße 31a, Leipzig, Germany 2011.
|
|
408
|
+
*
|
|
409
|
+
* All rights reserved. Holger Seelig <holger.seelig@yahoo.de>.
|
|
410
|
+
*
|
|
411
|
+
* The copyright notice above does not evidence any actual of intended
|
|
412
|
+
* publication of such source code, and is an unpublished work by create3000.
|
|
413
|
+
* This material contains CONFIDENTIAL INFORMATION that is the property of
|
|
414
|
+
* create3000.
|
|
415
|
+
*
|
|
416
|
+
* No permission is granted to copy, distribute, or create derivative works from
|
|
417
|
+
* the contents of this software, in whole or in part, without the prior written
|
|
418
|
+
* permission of create3000.
|
|
419
|
+
*
|
|
420
|
+
* NON-MILITARY USE ONLY
|
|
421
|
+
*
|
|
422
|
+
* All create3000 software are effectively free software with a non-military use
|
|
423
|
+
* restriction. It is free. Well commented source is provided. You may reuse the
|
|
424
|
+
* source in any way you please with the exception anything that uses it must be
|
|
425
|
+
* marked to indicate is contains 'non-military use only' components.
|
|
426
|
+
*
|
|
427
|
+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
428
|
+
*
|
|
429
|
+
* Copyright 2015, 2016 Holger Seelig <holger.seelig@yahoo.de>.
|
|
430
|
+
*
|
|
431
|
+
* This file is part of the X_ITE Project.
|
|
432
|
+
*
|
|
433
|
+
* X_ITE is free software: you can redistribute it and/or modify it under the
|
|
434
|
+
* terms of the GNU General Public License version 3 only, as published by the
|
|
435
|
+
* Free Software Foundation.
|
|
436
|
+
*
|
|
437
|
+
* X_ITE is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
438
|
+
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
|
439
|
+
* A PARTICULAR PURPOSE. See the GNU General Public License version 3 for more
|
|
440
|
+
* details (a copy is included in the LICENSE file that accompanied this code).
|
|
441
|
+
*
|
|
442
|
+
* You should have received a copy of the GNU General Public License version 3
|
|
443
|
+
* along with X_ITE. If not, see <http://www.gnu.org/licenses/gpl.html> for a
|
|
444
|
+
* copy of the GPLv3 License.
|
|
445
|
+
*
|
|
446
|
+
* For Silvio, Joy and Adi.
|
|
447
|
+
*
|
|
448
|
+
******************************************************************************/
|
|
449
|
+
|
|
450
|
+
|
|
451
|
+
define ('x_ite/Browser/VolumeRendering/X3DVolumeRenderingContext',[
|
|
452
|
+
"x_ite/Components/Texturing/PixelTexture",
|
|
453
|
+
"x_ite/Components/Texturing/TextureProperties",
|
|
454
|
+
"x_ite/Components/VolumeRendering/OpacityMapVolumeStyle",
|
|
455
|
+
],
|
|
456
|
+
function (PixelTexture,
|
|
457
|
+
TextureProperties,
|
|
458
|
+
OpacityMapVolumeStyle)
|
|
459
|
+
{
|
|
460
|
+
"use strict";
|
|
461
|
+
|
|
462
|
+
function X3DVolumeRenderingContext () { }
|
|
463
|
+
|
|
464
|
+
X3DVolumeRenderingContext .prototype =
|
|
465
|
+
{
|
|
466
|
+
getDefaultVolumeStyle: function ()
|
|
467
|
+
{
|
|
468
|
+
this .defaultVolumeStyle = new OpacityMapVolumeStyle (this .getPrivateScene ());
|
|
469
|
+
this .defaultVolumeStyle .setup ();
|
|
470
|
+
|
|
471
|
+
this .getDefaultVolumeStyle = function () { return this .defaultVolumeStyle; };
|
|
472
|
+
|
|
473
|
+
return this .defaultVolumeStyle;
|
|
474
|
+
},
|
|
475
|
+
getDefaultBlendedVolumeStyle: function ()
|
|
476
|
+
{
|
|
477
|
+
this .defaultBlendedVolumeStyle = new OpacityMapVolumeStyle (this .getPrivateScene ());
|
|
478
|
+
this .defaultBlendedVolumeStyle .setup ();
|
|
479
|
+
|
|
480
|
+
this .getDefaultBlendedVolumeStyle = function () { return this .defaultBlendedVolumeStyle; };
|
|
481
|
+
|
|
482
|
+
return this .defaultBlendedVolumeStyle;
|
|
483
|
+
},
|
|
484
|
+
getDefaultTransferFunction: function ()
|
|
485
|
+
{
|
|
486
|
+
this .defaultTransferFunction = new PixelTexture (this .getPrivateScene ());
|
|
487
|
+
|
|
488
|
+
var textureProperties = new TextureProperties (this .getPrivateScene ());
|
|
489
|
+
|
|
490
|
+
textureProperties .generateMipMaps_ = true;
|
|
491
|
+
textureProperties .boundaryModeS_ = "CLAMP_TO_EDGE";
|
|
492
|
+
textureProperties .boundaryModeT_ = "REPEAT";
|
|
493
|
+
|
|
494
|
+
this .defaultTransferFunction .textureProperties_ = textureProperties;
|
|
495
|
+
|
|
496
|
+
this .defaultTransferFunction .image_ .width = 256;
|
|
497
|
+
this .defaultTransferFunction .image_ .height = 1;
|
|
498
|
+
this .defaultTransferFunction .image_ .comp = 2;
|
|
499
|
+
|
|
500
|
+
var array = this .defaultTransferFunction .image_ .array;
|
|
501
|
+
|
|
502
|
+
for (var i = 0; i < 256; ++ i)
|
|
503
|
+
array [i] = (i << 8) | i;
|
|
504
|
+
|
|
505
|
+
textureProperties .setup ();
|
|
506
|
+
this .defaultTransferFunction .setup ();
|
|
507
|
+
|
|
508
|
+
this .getDefaultTransferFunction = function () { return this .defaultTransferFunction; };
|
|
509
|
+
|
|
510
|
+
return this .defaultTransferFunction;
|
|
511
|
+
},
|
|
512
|
+
};
|
|
513
|
+
|
|
514
|
+
return X3DVolumeRenderingContext;
|
|
515
|
+
});
|
|
516
|
+
|
|
517
|
+
/* -*- Mode: JavaScript; coding: utf-8; tab-width: 3; indent-tabs-mode: tab; c-basic-offset: 3 -*-
|
|
518
|
+
*******************************************************************************
|
|
519
|
+
*
|
|
520
|
+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
521
|
+
*
|
|
522
|
+
* Copyright create3000, ScheffelstraÃe 31a, Leipzig, Germany 2011.
|
|
523
|
+
*
|
|
524
|
+
* All rights reserved. Holger Seelig <holger.seelig@yahoo.de>.
|
|
525
|
+
*
|
|
526
|
+
* The copyright notice above does not evidence any actual of intended
|
|
527
|
+
* publication of such source code, and is an unpublished work by create3000.
|
|
528
|
+
* This material contains CONFIDENTIAL INFORMATION that is the property of
|
|
529
|
+
* create3000.
|
|
530
|
+
*
|
|
531
|
+
* No permission is granted to copy, distribute, or create derivative works from
|
|
532
|
+
* the contents of this software, in whole or in part, without the prior written
|
|
533
|
+
* permission of create3000.
|
|
534
|
+
*
|
|
535
|
+
* NON-MILITARY USE ONLY
|
|
536
|
+
*
|
|
537
|
+
* All create3000 software are effectively free software with a non-military use
|
|
538
|
+
* restriction. It is free. Well commented source is provided. You may reuse the
|
|
539
|
+
* source in any way you please with the exception anything that uses it must be
|
|
540
|
+
* marked to indicate is contains 'non-military use only' components.
|
|
541
|
+
*
|
|
542
|
+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
543
|
+
*
|
|
544
|
+
* Copyright 2015, 2016 Holger Seelig <holger.seelig@yahoo.de>.
|
|
545
|
+
*
|
|
546
|
+
* This file is part of the X_ITE Project.
|
|
547
|
+
*
|
|
548
|
+
* X_ITE is free software: you can redistribute it and/or modify it under the
|
|
549
|
+
* terms of the GNU General Public License version 3 only, as published by the
|
|
550
|
+
* Free Software Foundation.
|
|
551
|
+
*
|
|
552
|
+
* X_ITE is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
553
|
+
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
|
554
|
+
* A PARTICULAR PURPOSE. See the GNU General Public License version 3 for more
|
|
555
|
+
* details (a copy is included in the LICENSE file that accompanied this code).
|
|
556
|
+
*
|
|
557
|
+
* You should have received a copy of the GNU General Public License version 3
|
|
558
|
+
* along with X_ITE. If not, see <http://www.gnu.org/licenses/gpl.html> for a
|
|
559
|
+
* copy of the GPLv3 License.
|
|
560
|
+
*
|
|
561
|
+
* For Silvio, Joy and Adi.
|
|
562
|
+
*
|
|
563
|
+
******************************************************************************/
|
|
564
|
+
|
|
565
|
+
|
|
566
|
+
define ('x_ite/Components/VolumeRendering/BlendedVolumeStyle',[
|
|
567
|
+
"x_ite/Fields",
|
|
568
|
+
"x_ite/Basic/X3DFieldDefinition",
|
|
569
|
+
"x_ite/Basic/FieldDefinitionArray",
|
|
570
|
+
"x_ite/Components/VolumeRendering/X3DComposableVolumeRenderStyleNode",
|
|
571
|
+
"x_ite/Bits/X3DConstants",
|
|
572
|
+
"x_ite/Bits/X3DCast",
|
|
573
|
+
"x_ite/DEBUG",
|
|
574
|
+
],
|
|
575
|
+
function (Fields,
|
|
576
|
+
X3DFieldDefinition,
|
|
577
|
+
FieldDefinitionArray,
|
|
578
|
+
X3DComposableVolumeRenderStyleNode,
|
|
579
|
+
X3DConstants,
|
|
580
|
+
X3DCast,
|
|
581
|
+
DEBUG)
|
|
582
|
+
{
|
|
583
|
+
"use strict";
|
|
584
|
+
|
|
585
|
+
function BlendedVolumeStyle (executionContext)
|
|
586
|
+
{
|
|
587
|
+
X3DComposableVolumeRenderStyleNode .call (this, executionContext);
|
|
588
|
+
|
|
589
|
+
this .addType (X3DConstants .BlendedVolumeStyle);
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
BlendedVolumeStyle .prototype = Object .assign (Object .create (X3DComposableVolumeRenderStyleNode .prototype),
|
|
593
|
+
{
|
|
594
|
+
constructor: BlendedVolumeStyle,
|
|
595
|
+
fieldDefinitions: new FieldDefinitionArray ([
|
|
596
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "metadata", new Fields .SFNode ()),
|
|
597
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "enabled", new Fields .SFBool (true)),
|
|
598
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "weightConstant1", new Fields .SFFloat (0.5)),
|
|
599
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "weightConstant2", new Fields .SFFloat (0.5)),
|
|
600
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "weightFunction1", new Fields .SFString ("CONSTANT")),
|
|
601
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "weightFunction2", new Fields .SFString ("CONSTANT")),
|
|
602
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "weightTransferFunction1", new Fields .SFNode ()),
|
|
603
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "weightTransferFunction2", new Fields .SFNode ()),
|
|
604
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "renderStyle", new Fields .SFNode ()),
|
|
605
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "voxels", new Fields .SFNode ()),
|
|
606
|
+
]),
|
|
607
|
+
getTypeName: function ()
|
|
608
|
+
{
|
|
609
|
+
return "BlendedVolumeStyle";
|
|
610
|
+
},
|
|
611
|
+
getComponentName: function ()
|
|
612
|
+
{
|
|
613
|
+
return "VolumeRendering";
|
|
614
|
+
},
|
|
615
|
+
getContainerField: function ()
|
|
616
|
+
{
|
|
617
|
+
return "renderStyle";
|
|
618
|
+
},
|
|
619
|
+
initialize: function ()
|
|
620
|
+
{
|
|
621
|
+
X3DComposableVolumeRenderStyleNode .prototype .initialize .call (this);
|
|
622
|
+
|
|
623
|
+
var gl = this .getBrowser () .getContext ();
|
|
624
|
+
|
|
625
|
+
if (gl .getVersion () < 2)
|
|
626
|
+
return;
|
|
627
|
+
|
|
628
|
+
this .weightTransferFunction1_ .addInterest ("set_weightTransferFunction1__", this);
|
|
629
|
+
this .weightTransferFunction2_ .addInterest ("set_weightTransferFunction2__", this);
|
|
630
|
+
this .renderStyle_ .addInterest ("set_renderStyle__", this);
|
|
631
|
+
this .voxels_ .addInterest ("set_voxels__", this);
|
|
632
|
+
|
|
633
|
+
this .set_weightTransferFunction1__ ();
|
|
634
|
+
this .set_weightTransferFunction2__ ();
|
|
635
|
+
this .set_renderStyle__ ();
|
|
636
|
+
this .set_voxels__ ();
|
|
637
|
+
},
|
|
638
|
+
addVolumeData: function (volumeDataNode)
|
|
639
|
+
{
|
|
640
|
+
X3DComposableVolumeRenderStyleNode .prototype .addVolumeData .call (this, volumeDataNode);
|
|
641
|
+
|
|
642
|
+
if (this .renderStyleNode)
|
|
643
|
+
this .renderStyleNode .addVolumeData (volumeDataNode);
|
|
644
|
+
},
|
|
645
|
+
removeVolumeData: function (volumeDataNode)
|
|
646
|
+
{
|
|
647
|
+
X3DComposableVolumeRenderStyleNode .prototype .removeVolumeData .call (this, volumeDataNode);
|
|
648
|
+
|
|
649
|
+
if (this .renderStyleNode)
|
|
650
|
+
this .renderStyleNode .removeVolumeData (volumeDataNode);
|
|
651
|
+
},
|
|
652
|
+
set_weightTransferFunction1__: function ()
|
|
653
|
+
{
|
|
654
|
+
this .weightTransferFunction1Node = X3DCast (X3DConstants .X3DTexture2DNode, this .weightTransferFunction1_);
|
|
655
|
+
},
|
|
656
|
+
set_weightTransferFunction2__: function ()
|
|
657
|
+
{
|
|
658
|
+
this .weightTransferFunction2Node = X3DCast (X3DConstants .X3DTexture2DNode, this .weightTransferFunction2_);
|
|
659
|
+
},
|
|
660
|
+
set_renderStyle__: function ()
|
|
661
|
+
{
|
|
662
|
+
if (this .renderStyleNode)
|
|
663
|
+
{
|
|
664
|
+
this .renderStyleNode .removeInterest ("addNodeEvent", this);
|
|
665
|
+
|
|
666
|
+
this .getVolumeData () .forEach (function (volumeDataNode)
|
|
667
|
+
{
|
|
668
|
+
this .renderStyleNode .removeVolumeData (volumeDataNode);
|
|
669
|
+
}
|
|
670
|
+
.bind (this));
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
this .renderStyleNode = X3DCast (X3DConstants .X3DComposableVolumeRenderStyleNode, this .renderStyle_);
|
|
674
|
+
|
|
675
|
+
if (this .renderStyleNode)
|
|
676
|
+
{
|
|
677
|
+
this .renderStyleNode .addInterest ("addNodeEvent", this);
|
|
678
|
+
|
|
679
|
+
this .getVolumeData () .forEach (function (volumeDataNode)
|
|
680
|
+
{
|
|
681
|
+
this .renderStyleNode .addVolumeData (volumeDataNode);
|
|
682
|
+
}
|
|
683
|
+
.bind (this));
|
|
684
|
+
}
|
|
685
|
+
},
|
|
686
|
+
set_voxels__: function ()
|
|
687
|
+
{
|
|
688
|
+
if (this .voxelsNode)
|
|
689
|
+
this .voxelsNode .removeInterest ("set_textureSize__", this);
|
|
690
|
+
|
|
691
|
+
this .voxelsNode = X3DCast (X3DConstants .X3DTexture3DNode, this .voxels_);
|
|
692
|
+
|
|
693
|
+
if (this .voxelsNode)
|
|
694
|
+
{
|
|
695
|
+
this .voxelsNode .addInterest ("set_textureSize__", this);
|
|
696
|
+
|
|
697
|
+
this .set_textureSize__ ();
|
|
698
|
+
}
|
|
699
|
+
},
|
|
700
|
+
set_textureSize__: function ()
|
|
701
|
+
{
|
|
702
|
+
this .getVolumeData () .forEach (function (volumeDataNode)
|
|
703
|
+
{
|
|
704
|
+
try
|
|
705
|
+
{
|
|
706
|
+
var textureSize = volumeDataNode .getShader () .getField ("textureSize_" + this .getId ());
|
|
707
|
+
|
|
708
|
+
textureSize .x = this .voxelsNode .getWidth ();
|
|
709
|
+
textureSize .y = this .voxelsNode .getHeight ();
|
|
710
|
+
textureSize .z = this .voxelsNode .getDepth ();
|
|
711
|
+
}
|
|
712
|
+
catch (error)
|
|
713
|
+
{
|
|
714
|
+
if (DEBUG)
|
|
715
|
+
console .log (error);
|
|
716
|
+
}
|
|
717
|
+
}
|
|
718
|
+
.bind (this));
|
|
719
|
+
},
|
|
720
|
+
addShaderFields: function (shaderNode)
|
|
721
|
+
{
|
|
722
|
+
if (! this .enabled_ .getValue ())
|
|
723
|
+
return;
|
|
724
|
+
|
|
725
|
+
shaderNode .addUserDefinedField (X3DConstants .inputOutput, "weightConstant1_" + this .getId (), this .weightConstant1_ .copy ());
|
|
726
|
+
shaderNode .addUserDefinedField (X3DConstants .inputOutput, "weightConstant2_" + this .getId (), this .weightConstant2_ .copy ());
|
|
727
|
+
|
|
728
|
+
if (this .weightTransferFunction1Node)
|
|
729
|
+
shaderNode .addUserDefinedField (X3DConstants .inputOutput, "weightTransferFunction1_" + this .getId (), new Fields .SFNode (this .weightTransferFunction1Node));
|
|
730
|
+
|
|
731
|
+
if (this .weightTransferFunction2Node)
|
|
732
|
+
shaderNode .addUserDefinedField (X3DConstants .inputOutput, "weightTransferFunction2_" + this .getId (), new Fields .SFNode (this .weightTransferFunction2Node));
|
|
733
|
+
|
|
734
|
+
if (this .voxelsNode)
|
|
735
|
+
{
|
|
736
|
+
var textureSize = new Fields .SFVec3f (this .voxelsNode .getWidth (), this .voxelsNode .getHeight (), this .voxelsNode .getDepth ());
|
|
737
|
+
|
|
738
|
+
shaderNode .addUserDefinedField (X3DConstants .inputOutput, "voxels_" + this .getId (), new Fields .SFNode (this .voxelsNode));
|
|
739
|
+
shaderNode .addUserDefinedField (X3DConstants .inputOutput, "textureSize_" + this .getId (), textureSize);
|
|
740
|
+
}
|
|
741
|
+
else
|
|
742
|
+
{
|
|
743
|
+
shaderNode .addUserDefinedField (X3DConstants .inputOutput, "textureSize_" + this .getId (), new Fields .SFVec3f ());
|
|
744
|
+
}
|
|
745
|
+
|
|
746
|
+
this .getBrowser () .getDefaultBlendedVolumeStyle () .addShaderFields (shaderNode);
|
|
747
|
+
|
|
748
|
+
if (this .renderStyleNode)
|
|
749
|
+
this .renderStyleNode .addShaderFields (shaderNode);
|
|
750
|
+
},
|
|
751
|
+
getUniformsText: function ()
|
|
752
|
+
{
|
|
753
|
+
if (! this .enabled_ .getValue ())
|
|
754
|
+
return "";
|
|
755
|
+
|
|
756
|
+
if (! this .voxelsNode)
|
|
757
|
+
return "";
|
|
758
|
+
|
|
759
|
+
var string = "";
|
|
760
|
+
|
|
761
|
+
string += "\n";
|
|
762
|
+
string += "// BlendedVolumeStyle\n";
|
|
763
|
+
string += "\n";
|
|
764
|
+
string += "uniform float weightConstant1_" + this .getId () + ";\n";
|
|
765
|
+
string += "uniform float weightConstant2_" + this .getId () + ";\n";
|
|
766
|
+
|
|
767
|
+
if (this .weightTransferFunction1Node)
|
|
768
|
+
string += "uniform sampler2D weightTransferFunction1_" + this .getId () + ";\n";
|
|
769
|
+
|
|
770
|
+
if (this .weightTransferFunction2Node)
|
|
771
|
+
string += "uniform sampler2D weightTransferFunction2_" + this .getId () + ";\n";
|
|
772
|
+
|
|
773
|
+
string += "uniform sampler3D voxels_" + this .getId () + ";\n";
|
|
774
|
+
string += "uniform vec3 textureSize_" + this .getId () + ";\n";
|
|
775
|
+
|
|
776
|
+
var uniformsText = this .getBrowser () .getDefaultBlendedVolumeStyle () .getUniformsText ();
|
|
777
|
+
|
|
778
|
+
if (this .renderStyleNode)
|
|
779
|
+
uniformsText += this .renderStyleNode .getUniformsText ();
|
|
780
|
+
|
|
781
|
+
uniformsText = uniformsText .replace (/x3d_Texture3D \[0\]/g, "voxels_" + this .getId ());
|
|
782
|
+
uniformsText = uniformsText .replace (/x3d_TextureSize/g, "textureSize_" + this .getId ());
|
|
783
|
+
|
|
784
|
+
string += "\n";
|
|
785
|
+
string += uniformsText;
|
|
786
|
+
|
|
787
|
+
string += "\n";
|
|
788
|
+
string += "vec4\n";
|
|
789
|
+
string += "getBlendedStyle_" + this .getId () + " (in vec4 originalColor, in vec3 texCoord)\n";
|
|
790
|
+
string += "{\n";
|
|
791
|
+
|
|
792
|
+
string += " vec4 blendColor_" + this .getId () + " = texture (voxels_" + this .getId () + ", texCoord);";
|
|
793
|
+
|
|
794
|
+
var functionsText = this .getBrowser () .getDefaultBlendedVolumeStyle () .getFunctionsText ();
|
|
795
|
+
|
|
796
|
+
if (this .renderStyleNode)
|
|
797
|
+
functionsText += this .renderStyleNode .getFunctionsText ();
|
|
798
|
+
|
|
799
|
+
functionsText = functionsText .replace (/textureColor/g, "blendColor_" + this .getId ());
|
|
800
|
+
|
|
801
|
+
string += "\n";
|
|
802
|
+
string += functionsText;
|
|
803
|
+
|
|
804
|
+
switch (this .weightFunction1_ .getValue ())
|
|
805
|
+
{
|
|
806
|
+
default: // CONSTANT
|
|
807
|
+
{
|
|
808
|
+
string += " float w1_" + this .getId () + " = weightConstant1_" + this .getId () + ";\n";
|
|
809
|
+
break;
|
|
810
|
+
}
|
|
811
|
+
case "ALPHA0":
|
|
812
|
+
{
|
|
813
|
+
string += " float w1_" + this .getId () + " = originalColor .a;\n";
|
|
814
|
+
break;
|
|
815
|
+
}
|
|
816
|
+
case "ALPHA1":
|
|
817
|
+
{
|
|
818
|
+
string += " float w1_" + this .getId () + " = blendColor_ " + this .getId () + " .a;\n";
|
|
819
|
+
break;
|
|
820
|
+
}
|
|
821
|
+
case "ONE_MINUS_ALPHA0":
|
|
822
|
+
{
|
|
823
|
+
string += " float w1_" + this .getId () + " = 1.0 - originalColor .a;\n";
|
|
824
|
+
break;
|
|
825
|
+
}
|
|
826
|
+
case "ONE_MINUS_ALPHA1":
|
|
827
|
+
{
|
|
828
|
+
string += " float w1_" + this .getId () + " = 1.0 - blendColor_ " + this .getId () + " .a;\n";
|
|
829
|
+
break;
|
|
830
|
+
}
|
|
831
|
+
case "TABLE":
|
|
832
|
+
{
|
|
833
|
+
if (this .weightTransferFunction1Node)
|
|
834
|
+
{
|
|
835
|
+
string += " float w1_" + this .getId () + " = texture (weightTransferFunction1_" + this .getId () + ", vec2 (originalColor .a, blendColor_" + this .getId () + " .a)) .r;\n";
|
|
836
|
+
}
|
|
837
|
+
else
|
|
838
|
+
{
|
|
839
|
+
// Use default CONSTANT value.
|
|
840
|
+
string += " float w1_" + this .getId () + " = weightConstant1_" + this .getId () + ";\n";
|
|
841
|
+
}
|
|
842
|
+
|
|
843
|
+
break;
|
|
844
|
+
}
|
|
845
|
+
}
|
|
846
|
+
|
|
847
|
+
switch (this .weightFunction2_ .getValue ())
|
|
848
|
+
{
|
|
849
|
+
default: // CONSTANT
|
|
850
|
+
{
|
|
851
|
+
string += " float w2_" + this .getId () + " = weightConstant2_" + this .getId () + ";\n";
|
|
852
|
+
break;
|
|
853
|
+
}
|
|
854
|
+
case "ALPHA0":
|
|
855
|
+
{
|
|
856
|
+
string += " float w2_" + this .getId () + " = originalColor .a;\n";
|
|
857
|
+
break;
|
|
858
|
+
}
|
|
859
|
+
case "ALPHA1":
|
|
860
|
+
{
|
|
861
|
+
string += " float w2_" + this .getId () + " = blendColor_ " + this .getId () + " .a;\n";
|
|
862
|
+
break;
|
|
863
|
+
}
|
|
864
|
+
case "ONE_MINUS_ALPHA0":
|
|
865
|
+
{
|
|
866
|
+
string += " float w2_" + this .getId () + " = 1.0 - originalColor .a;\n";
|
|
867
|
+
break;
|
|
868
|
+
}
|
|
869
|
+
case "ONE_MINUS_ALPHA1":
|
|
870
|
+
{
|
|
871
|
+
string += " float w2_" + this .getId () + " = 1.0 - blendColor_ " + this .getId () + " .a;\n";
|
|
872
|
+
break;
|
|
873
|
+
}
|
|
874
|
+
case "TABLE":
|
|
875
|
+
{
|
|
876
|
+
if (this .weightTransferFunction2Node)
|
|
877
|
+
{
|
|
878
|
+
string += " float w2_" + this .getId () + " = texture (weightTransferFunction2_" + this .getId () + ", vec2 (originalColor .a, blendColor_" + this .getId () + " .a)) .r;\n";
|
|
879
|
+
}
|
|
880
|
+
else
|
|
881
|
+
{
|
|
882
|
+
// Use default CONSTANT value.
|
|
883
|
+
string += " float w2_" + this .getId () + " = weightConstant2_" + this .getId () + ";\n";
|
|
884
|
+
}
|
|
885
|
+
|
|
886
|
+
break;
|
|
887
|
+
}
|
|
888
|
+
}
|
|
889
|
+
|
|
890
|
+
string += "\n";
|
|
891
|
+
string += " return clamp (originalColor * w1_" + this .getId () + " + blendColor_" + this .getId () + " * w2_" + this .getId () + ", 0.0, 1.0);\n";
|
|
892
|
+
string += "}\n";
|
|
893
|
+
|
|
894
|
+
return string;
|
|
895
|
+
},
|
|
896
|
+
getFunctionsText: function ()
|
|
897
|
+
{
|
|
898
|
+
if (! this .enabled_ .getValue ())
|
|
899
|
+
return "";
|
|
900
|
+
|
|
901
|
+
if (! this .voxelsNode)
|
|
902
|
+
return "";
|
|
903
|
+
|
|
904
|
+
var string = "";
|
|
905
|
+
|
|
906
|
+
string += "\n";
|
|
907
|
+
string += " // BlendedVolumeStyle\n";
|
|
908
|
+
string += "\n";
|
|
909
|
+
string += " textureColor = getBlendedStyle_" + this .getId () + " (textureColor, texCoord);\n";
|
|
910
|
+
|
|
911
|
+
return string;
|
|
912
|
+
},
|
|
913
|
+
});
|
|
914
|
+
|
|
915
|
+
return BlendedVolumeStyle;
|
|
916
|
+
});
|
|
917
|
+
|
|
918
|
+
/* -*- Mode: JavaScript; coding: utf-8; tab-width: 3; indent-tabs-mode: tab; c-basic-offset: 3 -*-
|
|
919
|
+
*******************************************************************************
|
|
920
|
+
*
|
|
921
|
+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
922
|
+
*
|
|
923
|
+
* Copyright create3000, ScheffelstraÃe 31a, Leipzig, Germany 2011.
|
|
924
|
+
*
|
|
925
|
+
* All rights reserved. Holger Seelig <holger.seelig@yahoo.de>.
|
|
926
|
+
*
|
|
927
|
+
* The copyright notice above does not evidence any actual of intended
|
|
928
|
+
* publication of such source code, and is an unpublished work by create3000.
|
|
929
|
+
* This material contains CONFIDENTIAL INFORMATION that is the property of
|
|
930
|
+
* create3000.
|
|
931
|
+
*
|
|
932
|
+
* No permission is granted to copy, distribute, or create derivative works from
|
|
933
|
+
* the contents of this software, in whole or in part, without the prior written
|
|
934
|
+
* permission of create3000.
|
|
935
|
+
*
|
|
936
|
+
* NON-MILITARY USE ONLY
|
|
937
|
+
*
|
|
938
|
+
* All create3000 software are effectively free software with a non-military use
|
|
939
|
+
* restriction. It is free. Well commented source is provided. You may reuse the
|
|
940
|
+
* source in any way you please with the exception anything that uses it must be
|
|
941
|
+
* marked to indicate is contains 'non-military use only' components.
|
|
942
|
+
*
|
|
943
|
+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
944
|
+
*
|
|
945
|
+
* Copyright 2015, 2016 Holger Seelig <holger.seelig@yahoo.de>.
|
|
946
|
+
*
|
|
947
|
+
* This file is part of the X_ITE Project.
|
|
948
|
+
*
|
|
949
|
+
* X_ITE is free software: you can redistribute it and/or modify it under the
|
|
950
|
+
* terms of the GNU General Public License version 3 only, as published by the
|
|
951
|
+
* Free Software Foundation.
|
|
952
|
+
*
|
|
953
|
+
* X_ITE is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
954
|
+
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
|
955
|
+
* A PARTICULAR PURPOSE. See the GNU General Public License version 3 for more
|
|
956
|
+
* details (a copy is included in the LICENSE file that accompanied this code).
|
|
957
|
+
*
|
|
958
|
+
* You should have received a copy of the GNU General Public License version 3
|
|
959
|
+
* along with X_ITE. If not, see <http://www.gnu.org/licenses/gpl.html> for a
|
|
960
|
+
* copy of the GPLv3 License.
|
|
961
|
+
*
|
|
962
|
+
* For Silvio, Joy and Adi.
|
|
963
|
+
*
|
|
964
|
+
******************************************************************************/
|
|
965
|
+
|
|
966
|
+
|
|
967
|
+
define ('x_ite/Components/VolumeRendering/BoundaryEnhancementVolumeStyle',[
|
|
968
|
+
"x_ite/Fields",
|
|
969
|
+
"x_ite/Basic/X3DFieldDefinition",
|
|
970
|
+
"x_ite/Basic/FieldDefinitionArray",
|
|
971
|
+
"x_ite/Components/VolumeRendering/X3DComposableVolumeRenderStyleNode",
|
|
972
|
+
"x_ite/Bits/X3DConstants",
|
|
973
|
+
],
|
|
974
|
+
function (Fields,
|
|
975
|
+
X3DFieldDefinition,
|
|
976
|
+
FieldDefinitionArray,
|
|
977
|
+
X3DComposableVolumeRenderStyleNode,
|
|
978
|
+
X3DConstants)
|
|
979
|
+
{
|
|
980
|
+
"use strict";
|
|
981
|
+
|
|
982
|
+
function BoundaryEnhancementVolumeStyle (executionContext)
|
|
983
|
+
{
|
|
984
|
+
X3DComposableVolumeRenderStyleNode .call (this, executionContext);
|
|
985
|
+
|
|
986
|
+
this .addType (X3DConstants .BoundaryEnhancementVolumeStyle);
|
|
987
|
+
}
|
|
988
|
+
|
|
989
|
+
BoundaryEnhancementVolumeStyle .prototype = Object .assign (Object .create (X3DComposableVolumeRenderStyleNode .prototype),
|
|
990
|
+
{
|
|
991
|
+
constructor: BoundaryEnhancementVolumeStyle,
|
|
992
|
+
fieldDefinitions: new FieldDefinitionArray ([
|
|
993
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "metadata", new Fields .SFNode ()),
|
|
994
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "enabled", new Fields .SFBool (true)),
|
|
995
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "retainedOpacity", new Fields .SFFloat (0.2)),
|
|
996
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "boundaryOpacity", new Fields .SFFloat (0.9)),
|
|
997
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "opacityFactor", new Fields .SFFloat (2)),
|
|
998
|
+
]),
|
|
999
|
+
getTypeName: function ()
|
|
1000
|
+
{
|
|
1001
|
+
return "BoundaryEnhancementVolumeStyle";
|
|
1002
|
+
},
|
|
1003
|
+
getComponentName: function ()
|
|
1004
|
+
{
|
|
1005
|
+
return "VolumeRendering";
|
|
1006
|
+
},
|
|
1007
|
+
getContainerField: function ()
|
|
1008
|
+
{
|
|
1009
|
+
return "renderStyle";
|
|
1010
|
+
},
|
|
1011
|
+
addShaderFields: function (shaderNode)
|
|
1012
|
+
{
|
|
1013
|
+
if (! this .enabled_ .getValue ())
|
|
1014
|
+
return;
|
|
1015
|
+
|
|
1016
|
+
shaderNode .addUserDefinedField (X3DConstants .inputOutput, "retainedOpacity_" + this .getId (), this .retainedOpacity_ .copy ());
|
|
1017
|
+
shaderNode .addUserDefinedField (X3DConstants .inputOutput, "boundaryOpacity_" + this .getId (), this .boundaryOpacity_ .copy ());
|
|
1018
|
+
shaderNode .addUserDefinedField (X3DConstants .inputOutput, "opacityFactor_" + this .getId (), this .opacityFactor_ .copy ());
|
|
1019
|
+
},
|
|
1020
|
+
getUniformsText: function ()
|
|
1021
|
+
{
|
|
1022
|
+
if (! this .enabled_ .getValue ())
|
|
1023
|
+
return "";
|
|
1024
|
+
|
|
1025
|
+
var string = "";
|
|
1026
|
+
|
|
1027
|
+
string += "\n";
|
|
1028
|
+
string += "// BoundaryEnhancementVolumeStyle\n";
|
|
1029
|
+
string += "\n";
|
|
1030
|
+
string += "uniform float retainedOpacity_" + this .getId () + ";\n";
|
|
1031
|
+
string += "uniform float boundaryOpacity_" + this .getId () + ";\n";
|
|
1032
|
+
string += "uniform float opacityFactor_" + this .getId () + ";\n";
|
|
1033
|
+
|
|
1034
|
+
string += "\n";
|
|
1035
|
+
string += "vec4\n";
|
|
1036
|
+
string += "getBoundaryEnhancementStyle_" + this .getId () + " (in vec4 originalColor, in vec3 texCoord)\n";
|
|
1037
|
+
string += "{\n";
|
|
1038
|
+
string += " float f0 = texture (x3d_Texture3D [0], texCoord) .r;\n";
|
|
1039
|
+
string += " float f1 = texture (x3d_Texture3D [0], texCoord + vec3 (0.0, 0.0, 1.0 / x3d_TextureSize .z)) .r;\n";
|
|
1040
|
+
string += " float f = abs (f0 - f1);\n";
|
|
1041
|
+
string += "\n";
|
|
1042
|
+
string += " float retainedOpacity = retainedOpacity_" + this .getId () + ";\n";
|
|
1043
|
+
string += " float boundaryOpacity = boundaryOpacity_" + this .getId () + ";\n";
|
|
1044
|
+
string += " float opacityFactor = opacityFactor_" + this .getId () + ";\n";
|
|
1045
|
+
string += "\n";
|
|
1046
|
+
string += " return vec4 (originalColor .rgb, originalColor .a * (retainedOpacity + boundaryOpacity * pow (f, opacityFactor)));\n";
|
|
1047
|
+
string += "}\n";
|
|
1048
|
+
|
|
1049
|
+
return string;
|
|
1050
|
+
},
|
|
1051
|
+
getFunctionsText: function ()
|
|
1052
|
+
{
|
|
1053
|
+
if (! this .enabled_ .getValue ())
|
|
1054
|
+
return "";
|
|
1055
|
+
|
|
1056
|
+
var string = "";
|
|
1057
|
+
|
|
1058
|
+
string += "\n";
|
|
1059
|
+
string += " // BoundaryEnhancementVolumeStyle\n";
|
|
1060
|
+
string += "\n";
|
|
1061
|
+
string += " textureColor = getBoundaryEnhancementStyle_" + this .getId () + " (textureColor, texCoord);\n";
|
|
1062
|
+
|
|
1063
|
+
return string;
|
|
1064
|
+
},
|
|
1065
|
+
});
|
|
1066
|
+
|
|
1067
|
+
return BoundaryEnhancementVolumeStyle;
|
|
1068
|
+
});
|
|
1069
|
+
|
|
1070
|
+
/* -*- Mode: JavaScript; coding: utf-8; tab-width: 3; indent-tabs-mode: tab; c-basic-offset: 3 -*-
|
|
1071
|
+
*******************************************************************************
|
|
1072
|
+
*
|
|
1073
|
+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
1074
|
+
*
|
|
1075
|
+
* Copyright create3000, ScheffelstraÃe 31a, Leipzig, Germany 2011.
|
|
1076
|
+
*
|
|
1077
|
+
* All rights reserved. Holger Seelig <holger.seelig@yahoo.de>.
|
|
1078
|
+
*
|
|
1079
|
+
* The copyright notice above does not evidence any actual of intended
|
|
1080
|
+
* publication of such source code, and is an unpublished work by create3000.
|
|
1081
|
+
* This material contains CONFIDENTIAL INFORMATION that is the property of
|
|
1082
|
+
* create3000.
|
|
1083
|
+
*
|
|
1084
|
+
* No permission is granted to copy, distribute, or create derivative works from
|
|
1085
|
+
* the contents of this software, in whole or in part, without the prior written
|
|
1086
|
+
* permission of create3000.
|
|
1087
|
+
*
|
|
1088
|
+
* NON-MILITARY USE ONLY
|
|
1089
|
+
*
|
|
1090
|
+
* All create3000 software are effectively free software with a non-military use
|
|
1091
|
+
* restriction. It is free. Well commented source is provided. You may reuse the
|
|
1092
|
+
* source in any way you please with the exception anything that uses it must be
|
|
1093
|
+
* marked to indicate is contains 'non-military use only' components.
|
|
1094
|
+
*
|
|
1095
|
+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
1096
|
+
*
|
|
1097
|
+
* Copyright 2015, 2016 Holger Seelig <holger.seelig@yahoo.de>.
|
|
1098
|
+
*
|
|
1099
|
+
* This file is part of the X_ITE Project.
|
|
1100
|
+
*
|
|
1101
|
+
* X_ITE is free software: you can redistribute it and/or modify it under the
|
|
1102
|
+
* terms of the GNU General Public License version 3 only, as published by the
|
|
1103
|
+
* Free Software Foundation.
|
|
1104
|
+
*
|
|
1105
|
+
* X_ITE is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
1106
|
+
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
|
1107
|
+
* A PARTICULAR PURPOSE. See the GNU General Public License version 3 for more
|
|
1108
|
+
* details (a copy is included in the LICENSE file that accompanied this code).
|
|
1109
|
+
*
|
|
1110
|
+
* You should have received a copy of the GNU General Public License version 3
|
|
1111
|
+
* along with X_ITE. If not, see <http://www.gnu.org/licenses/gpl.html> for a
|
|
1112
|
+
* copy of the GPLv3 License.
|
|
1113
|
+
*
|
|
1114
|
+
* For Silvio, Joy and Adi.
|
|
1115
|
+
*
|
|
1116
|
+
******************************************************************************/
|
|
1117
|
+
|
|
1118
|
+
|
|
1119
|
+
define ('x_ite/Components/VolumeRendering/CartoonVolumeStyle',[
|
|
1120
|
+
"x_ite/Fields",
|
|
1121
|
+
"x_ite/Basic/X3DFieldDefinition",
|
|
1122
|
+
"x_ite/Basic/FieldDefinitionArray",
|
|
1123
|
+
"x_ite/Components/VolumeRendering/X3DComposableVolumeRenderStyleNode",
|
|
1124
|
+
"x_ite/Bits/X3DConstants",
|
|
1125
|
+
"x_ite/Bits/X3DCast",
|
|
1126
|
+
],
|
|
1127
|
+
function (Fields,
|
|
1128
|
+
X3DFieldDefinition,
|
|
1129
|
+
FieldDefinitionArray,
|
|
1130
|
+
X3DComposableVolumeRenderStyleNode,
|
|
1131
|
+
X3DConstants,
|
|
1132
|
+
X3DCast)
|
|
1133
|
+
{
|
|
1134
|
+
"use strict";
|
|
1135
|
+
|
|
1136
|
+
function CartoonVolumeStyle (executionContext)
|
|
1137
|
+
{
|
|
1138
|
+
X3DComposableVolumeRenderStyleNode .call (this, executionContext);
|
|
1139
|
+
|
|
1140
|
+
this .addType (X3DConstants .CartoonVolumeStyle);
|
|
1141
|
+
}
|
|
1142
|
+
|
|
1143
|
+
CartoonVolumeStyle .prototype = Object .assign (Object .create (X3DComposableVolumeRenderStyleNode .prototype),
|
|
1144
|
+
{
|
|
1145
|
+
constructor: CartoonVolumeStyle,
|
|
1146
|
+
fieldDefinitions: new FieldDefinitionArray ([
|
|
1147
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "metadata", new Fields .SFNode ()),
|
|
1148
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "enabled", new Fields .SFBool (true)),
|
|
1149
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "colorSteps", new Fields .SFInt32 (4)),
|
|
1150
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "orthogonalColor", new Fields .SFColorRGBA (1, 1, 1, 1)),
|
|
1151
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "parallelColor", new Fields .SFColorRGBA (0, 0, 0, 1)),
|
|
1152
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "surfaceNormals", new Fields .SFNode ()),
|
|
1153
|
+
]),
|
|
1154
|
+
getTypeName: function ()
|
|
1155
|
+
{
|
|
1156
|
+
return "CartoonVolumeStyle";
|
|
1157
|
+
},
|
|
1158
|
+
getComponentName: function ()
|
|
1159
|
+
{
|
|
1160
|
+
return "VolumeRendering";
|
|
1161
|
+
},
|
|
1162
|
+
getContainerField: function ()
|
|
1163
|
+
{
|
|
1164
|
+
return "renderStyle";
|
|
1165
|
+
},
|
|
1166
|
+
initialize: function ()
|
|
1167
|
+
{
|
|
1168
|
+
X3DComposableVolumeRenderStyleNode .prototype .initialize .call (this);
|
|
1169
|
+
|
|
1170
|
+
var gl = this .getBrowser () .getContext ();
|
|
1171
|
+
|
|
1172
|
+
if (gl .getVersion () < 2)
|
|
1173
|
+
return;
|
|
1174
|
+
|
|
1175
|
+
this .surfaceNormals_ .addInterest ("set_surfaceNormals__", this);
|
|
1176
|
+
|
|
1177
|
+
this .set_surfaceNormals__ ();
|
|
1178
|
+
},
|
|
1179
|
+
set_surfaceNormals__: function ()
|
|
1180
|
+
{
|
|
1181
|
+
this .surfaceNormalsNode = X3DCast (X3DConstants .X3DTexture3DNode, this .surfaceNormals_);
|
|
1182
|
+
},
|
|
1183
|
+
addShaderFields: function (shaderNode)
|
|
1184
|
+
{
|
|
1185
|
+
if (! this .enabled_ .getValue ())
|
|
1186
|
+
return;
|
|
1187
|
+
|
|
1188
|
+
shaderNode .addUserDefinedField (X3DConstants .inputOutput, "colorSteps_" + this .getId (), this .colorSteps_ .copy ());
|
|
1189
|
+
shaderNode .addUserDefinedField (X3DConstants .inputOutput, "orthogonalColor_" + this .getId (), this .orthogonalColor_ .copy ());
|
|
1190
|
+
shaderNode .addUserDefinedField (X3DConstants .inputOutput, "parallelColor_" + this .getId (), this .parallelColor_ .copy ());
|
|
1191
|
+
|
|
1192
|
+
if (this .surfaceNormalsNode)
|
|
1193
|
+
shaderNode .addUserDefinedField (X3DConstants .inputOutput, "surfaceNormals_" + this .getId (), new Fields .SFNode (this .surfaceNormalsNode));
|
|
1194
|
+
},
|
|
1195
|
+
getUniformsText: function ()
|
|
1196
|
+
{
|
|
1197
|
+
if (! this .enabled_ .getValue ())
|
|
1198
|
+
return "";
|
|
1199
|
+
|
|
1200
|
+
var string = "";
|
|
1201
|
+
|
|
1202
|
+
string += "\n";
|
|
1203
|
+
string += "// CartoonVolumeStyle\n";
|
|
1204
|
+
string += "\n";
|
|
1205
|
+
string += "uniform int colorSteps_" + this .getId () + ";\n";
|
|
1206
|
+
string += "uniform vec4 orthogonalColor_" + this .getId () + ";\n";
|
|
1207
|
+
string += "uniform vec4 parallelColor_" + this .getId () + ";\n";
|
|
1208
|
+
|
|
1209
|
+
string += this .getNormalText (this .surfaceNormalsNode);
|
|
1210
|
+
|
|
1211
|
+
string += "\n";
|
|
1212
|
+
string += "vec3\n";
|
|
1213
|
+
string += "rgb2hsv_" + this .getId () + " (in vec3 color)\n";
|
|
1214
|
+
string += "{\n";
|
|
1215
|
+
string += " float h = 0.0;\n";
|
|
1216
|
+
string += " float s = 0.0;\n";
|
|
1217
|
+
string += " float v = 0.0;\n";
|
|
1218
|
+
string += "\n";
|
|
1219
|
+
string += " float min = min (min (color .r, color .g), color .b);\n";
|
|
1220
|
+
string += " float max = max (max (color .r, color .g), color .b);\n";
|
|
1221
|
+
string += " v = max; // value\n";
|
|
1222
|
+
string += "\n";
|
|
1223
|
+
string += " float delta = max - min;\n";
|
|
1224
|
+
string += "\n";
|
|
1225
|
+
string += " if (max != 0.0 && delta != 0.0)\n";
|
|
1226
|
+
string += " {\n";
|
|
1227
|
+
string += " s = delta / max; // s\n";
|
|
1228
|
+
string += "\n";
|
|
1229
|
+
string += " if (color .r == max)\n";
|
|
1230
|
+
string += " h = (color .g - color .b) / delta; // between yellow & magenta\n";
|
|
1231
|
+
string += " else if (color .g == max)\n";
|
|
1232
|
+
string += " h = 2.0 + (color .b - color .r) / delta; // between cyan & yellow\n";
|
|
1233
|
+
string += " else\n";
|
|
1234
|
+
string += " h = 4.0 + (color .r - color .g) / delta; // between magenta & cyan\n";
|
|
1235
|
+
string += "\n";
|
|
1236
|
+
string += " h *= M_PI / 3.0; // radiants\n";
|
|
1237
|
+
string += " if (h < 0.0)\n";
|
|
1238
|
+
string += " h += M_PI * 2.0;\n";
|
|
1239
|
+
string += " }\n";
|
|
1240
|
+
string += " else\n";
|
|
1241
|
+
string += " s = h = 0.0; // s = 0, h is undefined\n";
|
|
1242
|
+
string += "\n";
|
|
1243
|
+
string += " return vec3 (h, s, v);\n";
|
|
1244
|
+
string += "}\n";
|
|
1245
|
+
|
|
1246
|
+
string += "\n";
|
|
1247
|
+
string += "vec3\n";
|
|
1248
|
+
string += "hsv2rgb_" + this .getId () + " (in vec3 hsv)\n";
|
|
1249
|
+
string += "{\n";
|
|
1250
|
+
string += " float h = hsv [0];\n";
|
|
1251
|
+
string += " float s = clamp (hsv [1], 0.0, 1.0);\n";
|
|
1252
|
+
string += " float v = clamp (hsv [2], 0.0, 1.0);\n";
|
|
1253
|
+
string += "\n";
|
|
1254
|
+
string += " // H is given on [0, 2 * Pi]. S and V are given on [0, 1].\n";
|
|
1255
|
+
string += " // RGB are each returned on [0, 1].\n";
|
|
1256
|
+
string += "\n";
|
|
1257
|
+
string += " if (s == 0.0)\n";
|
|
1258
|
+
string += " {\n";
|
|
1259
|
+
string += " // achromatic (grey)\n";
|
|
1260
|
+
string += " return vec3 (v, v, v);\n";
|
|
1261
|
+
string += " }\n";
|
|
1262
|
+
string += " else\n";
|
|
1263
|
+
string += " {\n";
|
|
1264
|
+
string += " float w = (h * (180.0 / M_PI)) / 60.0; // sector 0 to 5\n";
|
|
1265
|
+
string += "\n";
|
|
1266
|
+
string += " float i = floor (w);\n";
|
|
1267
|
+
string += " float f = w - i; // factorial part of h\n";
|
|
1268
|
+
string += " float p = v * ( 1.0 - s );\n";
|
|
1269
|
+
string += " float q = v * ( 1.0 - s * f );\n";
|
|
1270
|
+
string += " float t = v * ( 1.0 - s * ( 1.0 - f ) );\n";
|
|
1271
|
+
string += "\n";
|
|
1272
|
+
string += " switch (int (i) % 6)\n";
|
|
1273
|
+
string += " {\n";
|
|
1274
|
+
string += " case 0: return vec3 (v, t, p);\n";
|
|
1275
|
+
string += " case 1: return vec3 (q, v, p);\n";
|
|
1276
|
+
string += " case 2: return vec3 (p, v, t);\n";
|
|
1277
|
+
string += " case 3: return vec3 (p, q, v);\n";
|
|
1278
|
+
string += " case 4: return vec3 (t, p, v);\n";
|
|
1279
|
+
string += " default: return vec3 (v, p, q);\n";
|
|
1280
|
+
string += " }\n";
|
|
1281
|
+
string += " }\n";
|
|
1282
|
+
string += "\n";
|
|
1283
|
+
string += " return vec3 (0.0);\n";
|
|
1284
|
+
string += "}\n";
|
|
1285
|
+
|
|
1286
|
+
string += "\n";
|
|
1287
|
+
string += "vec3\n";
|
|
1288
|
+
string += "mix_hsv_" + this .getId () + " (in vec3 a, in vec3 b, in float t)\n";
|
|
1289
|
+
string += "{\n";
|
|
1290
|
+
string += " // Linearely interpolate in HSV space between source color @a a and destination color @a b by an amount of @a t.\n";
|
|
1291
|
+
string += " // Source and destination color must be in HSV space.\n";
|
|
1292
|
+
string += "\n";
|
|
1293
|
+
string += " float ha = a [0];\n";
|
|
1294
|
+
string += " float sa = a [1];\n";
|
|
1295
|
+
string += " float va = a [2];\n";
|
|
1296
|
+
string += "\n";
|
|
1297
|
+
string += " float hb = b [0];\n";
|
|
1298
|
+
string += " float sb = b [1];\n";
|
|
1299
|
+
string += " float vb = b [2];\n";
|
|
1300
|
+
string += "\n";
|
|
1301
|
+
string += " if (sa == 0.0)\n";
|
|
1302
|
+
string += " ha = hb;\n";
|
|
1303
|
+
string += "\n";
|
|
1304
|
+
string += " if (sb == 0.0)\n";
|
|
1305
|
+
string += " hb = ha;\n";
|
|
1306
|
+
string += "\n";
|
|
1307
|
+
string += " float range = abs (hb - ha);\n";
|
|
1308
|
+
string += "\n";
|
|
1309
|
+
string += " if (range <= M_PI)\n";
|
|
1310
|
+
string += " {\n";
|
|
1311
|
+
string += " float h = ha + t * (hb - ha);\n";
|
|
1312
|
+
string += " float s = sa + t * (sb - sa);\n";
|
|
1313
|
+
string += " float v = va + t * (vb - va);\n";
|
|
1314
|
+
string += " return vec3 (h, s, v);\n";
|
|
1315
|
+
string += " }\n";
|
|
1316
|
+
string += "\n";
|
|
1317
|
+
string += " float PI2 = M_PI * 2.0;\n";
|
|
1318
|
+
string += " float step = (PI2 - range) * t;\n";
|
|
1319
|
+
string += " float h = ha < hb ? ha - step : ha + step;\n";
|
|
1320
|
+
string += "\n";
|
|
1321
|
+
string += " if (h < 0.0)\n";
|
|
1322
|
+
string += " h += PI2;\n";
|
|
1323
|
+
string += "\n";
|
|
1324
|
+
string += " else if (h > PI2)\n";
|
|
1325
|
+
string += " h -= PI2;\n";
|
|
1326
|
+
string += "\n";
|
|
1327
|
+
string += " float s = sa + t * (sb - sa);\n";
|
|
1328
|
+
string += " float v = va + t * (vb - va);\n";
|
|
1329
|
+
string += " return vec3 (h, s, v);\n";
|
|
1330
|
+
string += "}\n";
|
|
1331
|
+
|
|
1332
|
+
string += "\n";
|
|
1333
|
+
string += "vec4\n";
|
|
1334
|
+
string += "getCartoonStyle_" + this .getId () + " (in vec4 originalColor, vec3 texCoord)\n";
|
|
1335
|
+
string += "{\n";
|
|
1336
|
+
string += " vec4 surfaceNormal = getNormal_" + this .getId () + " (texCoord);\n";
|
|
1337
|
+
string += "\n";
|
|
1338
|
+
string += " if (surfaceNormal .w == 0.0)\n";
|
|
1339
|
+
string += " return vec4 (0.0);\n";
|
|
1340
|
+
string += "\n";
|
|
1341
|
+
string += " vec4 orthogonalColor = orthogonalColor_" + this .getId () + ";\n";
|
|
1342
|
+
string += " vec4 parallelColor = parallelColor_" + this .getId () + ";\n";
|
|
1343
|
+
string += " int colorSteps = colorSteps_" + this .getId () + ";\n";
|
|
1344
|
+
string += "\n";
|
|
1345
|
+
string += " float steps = clamp (float (colorSteps), 1.0, 64.0);\n";
|
|
1346
|
+
string += " float step = M_PI / 2.0 / steps;\n";
|
|
1347
|
+
string += " float cosTheta = min (dot (surfaceNormal .xyz, normalize (vertex)), 1.0);\n";
|
|
1348
|
+
string += "\n";
|
|
1349
|
+
string += " if (cosTheta < 0.0)\n";
|
|
1350
|
+
string += " return vec4 (0.0);\n";
|
|
1351
|
+
string += "\n";
|
|
1352
|
+
string += " float t = cos (min (floor (acos (cosTheta) / step) * (steps > 1.0 ? steps / (steps - 1.0) : 1.0), steps) * step);\n";
|
|
1353
|
+
string += " vec3 orthogonalHSV = rgb2hsv_" + this .getId () + " (orthogonalColor .rgb);\n";
|
|
1354
|
+
string += " vec3 parallelHSV = rgb2hsv_" + this .getId () + " (parallelColor .rgb);\n";
|
|
1355
|
+
string += "\n";
|
|
1356
|
+
string += " return vec4 (hsv2rgb_" + this .getId () + " (mix_hsv_" + this .getId () + " (orthogonalHSV, parallelHSV, t)), originalColor .a);\n";
|
|
1357
|
+
string += "}\n";
|
|
1358
|
+
|
|
1359
|
+
return string;
|
|
1360
|
+
},
|
|
1361
|
+
getFunctionsText: function ()
|
|
1362
|
+
{
|
|
1363
|
+
if (! this .enabled_ .getValue ())
|
|
1364
|
+
return "";
|
|
1365
|
+
|
|
1366
|
+
var string = "";
|
|
1367
|
+
|
|
1368
|
+
string += "\n";
|
|
1369
|
+
string += " // CartoonVolumeStyle\n";
|
|
1370
|
+
string += "\n";
|
|
1371
|
+
string += " textureColor = getCartoonStyle_" + this .getId () + " (textureColor, texCoord);\n";
|
|
1372
|
+
|
|
1373
|
+
return string;
|
|
1374
|
+
},
|
|
1375
|
+
});
|
|
1376
|
+
|
|
1377
|
+
return CartoonVolumeStyle;
|
|
1378
|
+
});
|
|
1379
|
+
|
|
1380
|
+
/* -*- Mode: JavaScript; coding: utf-8; tab-width: 3; indent-tabs-mode: tab; c-basic-offset: 3 -*-
|
|
1381
|
+
*******************************************************************************
|
|
1382
|
+
*
|
|
1383
|
+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
1384
|
+
*
|
|
1385
|
+
* Copyright create3000, ScheffelstraÃe 31a, Leipzig, Germany 2011.
|
|
1386
|
+
*
|
|
1387
|
+
* All rights reserved. Holger Seelig <holger.seelig@yahoo.de>.
|
|
1388
|
+
*
|
|
1389
|
+
* The copyright notice above does not evidence any actual of intended
|
|
1390
|
+
* publication of such source code, and is an unpublished work by create3000.
|
|
1391
|
+
* This material contains CONFIDENTIAL INFORMATION that is the property of
|
|
1392
|
+
* create3000.
|
|
1393
|
+
*
|
|
1394
|
+
* No permission is granted to copy, distribute, or create derivative works from
|
|
1395
|
+
* the contents of this software, in whole or in part, without the prior written
|
|
1396
|
+
* permission of create3000.
|
|
1397
|
+
*
|
|
1398
|
+
* NON-MILITARY USE ONLY
|
|
1399
|
+
*
|
|
1400
|
+
* All create3000 software are effectively free software with a non-military use
|
|
1401
|
+
* restriction. It is free. Well commented source is provided. You may reuse the
|
|
1402
|
+
* source in any way you please with the exception anything that uses it must be
|
|
1403
|
+
* marked to indicate is contains 'non-military use only' components.
|
|
1404
|
+
*
|
|
1405
|
+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
1406
|
+
*
|
|
1407
|
+
* Copyright 2015, 2016 Holger Seelig <holger.seelig@yahoo.de>.
|
|
1408
|
+
*
|
|
1409
|
+
* This file is part of the X_ITE Project.
|
|
1410
|
+
*
|
|
1411
|
+
* X_ITE is free software: you can redistribute it and/or modify it under the
|
|
1412
|
+
* terms of the GNU General Public License version 3 only, as published by the
|
|
1413
|
+
* Free Software Foundation.
|
|
1414
|
+
*
|
|
1415
|
+
* X_ITE is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
1416
|
+
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
|
1417
|
+
* A PARTICULAR PURPOSE. See the GNU General Public License version 3 for more
|
|
1418
|
+
* details (a copy is included in the LICENSE file that accompanied this code).
|
|
1419
|
+
*
|
|
1420
|
+
* You should have received a copy of the GNU General Public License version 3
|
|
1421
|
+
* along with X_ITE. If not, see <http://www.gnu.org/licenses/gpl.html> for a
|
|
1422
|
+
* copy of the GPLv3 License.
|
|
1423
|
+
*
|
|
1424
|
+
* For Silvio, Joy and Adi.
|
|
1425
|
+
*
|
|
1426
|
+
******************************************************************************/
|
|
1427
|
+
|
|
1428
|
+
|
|
1429
|
+
define ('x_ite/Components/VolumeRendering/ComposedVolumeStyle',[
|
|
1430
|
+
"x_ite/Fields",
|
|
1431
|
+
"x_ite/Basic/X3DFieldDefinition",
|
|
1432
|
+
"x_ite/Basic/FieldDefinitionArray",
|
|
1433
|
+
"x_ite/Components/VolumeRendering/X3DComposableVolumeRenderStyleNode",
|
|
1434
|
+
"x_ite/Bits/X3DConstants",
|
|
1435
|
+
"x_ite/Bits/X3DCast",
|
|
1436
|
+
],
|
|
1437
|
+
function (Fields,
|
|
1438
|
+
X3DFieldDefinition,
|
|
1439
|
+
FieldDefinitionArray,
|
|
1440
|
+
X3DComposableVolumeRenderStyleNode,
|
|
1441
|
+
X3DConstants,
|
|
1442
|
+
X3DCast)
|
|
1443
|
+
{
|
|
1444
|
+
"use strict";
|
|
1445
|
+
|
|
1446
|
+
function ComposedVolumeStyle (executionContext)
|
|
1447
|
+
{
|
|
1448
|
+
X3DComposableVolumeRenderStyleNode .call (this, executionContext);
|
|
1449
|
+
|
|
1450
|
+
this .addType (X3DConstants .ComposedVolumeStyle);
|
|
1451
|
+
|
|
1452
|
+
this .renderStyleNodes = [ ];
|
|
1453
|
+
}
|
|
1454
|
+
|
|
1455
|
+
ComposedVolumeStyle .prototype = Object .assign (Object .create (X3DComposableVolumeRenderStyleNode .prototype),
|
|
1456
|
+
{
|
|
1457
|
+
constructor: ComposedVolumeStyle,
|
|
1458
|
+
fieldDefinitions: new FieldDefinitionArray ([
|
|
1459
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "metadata", new Fields .SFNode ()),
|
|
1460
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "enabled", new Fields .SFBool (true)),
|
|
1461
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "renderStyle", new Fields .MFNode ()),
|
|
1462
|
+
]),
|
|
1463
|
+
getTypeName: function ()
|
|
1464
|
+
{
|
|
1465
|
+
return "ComposedVolumeStyle";
|
|
1466
|
+
},
|
|
1467
|
+
getComponentName: function ()
|
|
1468
|
+
{
|
|
1469
|
+
return "VolumeRendering";
|
|
1470
|
+
},
|
|
1471
|
+
getContainerField: function ()
|
|
1472
|
+
{
|
|
1473
|
+
return "renderStyle";
|
|
1474
|
+
},
|
|
1475
|
+
initialize: function ()
|
|
1476
|
+
{
|
|
1477
|
+
X3DComposableVolumeRenderStyleNode .prototype .initialize .call (this);
|
|
1478
|
+
|
|
1479
|
+
var gl = this .getBrowser () .getContext ();
|
|
1480
|
+
|
|
1481
|
+
if (gl .getVersion () < 2)
|
|
1482
|
+
return;
|
|
1483
|
+
|
|
1484
|
+
this .renderStyle_ .addInterest ("set_renderStyle__", this);
|
|
1485
|
+
|
|
1486
|
+
this .set_renderStyle__ ();
|
|
1487
|
+
},
|
|
1488
|
+
addVolumeData: function (volumeDataNode)
|
|
1489
|
+
{
|
|
1490
|
+
X3DComposableVolumeRenderStyleNode .prototype .addVolumeData .call (this, volumeDataNode);
|
|
1491
|
+
|
|
1492
|
+
var renderStyleNodes = this .renderStyleNodes;
|
|
1493
|
+
|
|
1494
|
+
for (var i = 0, length = renderStyleNodes .length; i < length; ++ i)
|
|
1495
|
+
{
|
|
1496
|
+
var renderStyleNode = renderStyleNodes [i];
|
|
1497
|
+
|
|
1498
|
+
renderStyleNode .addVolumeData (volumeDataNode);
|
|
1499
|
+
}
|
|
1500
|
+
},
|
|
1501
|
+
removeVolumeData: function (volumeDataNode)
|
|
1502
|
+
{
|
|
1503
|
+
X3DComposableVolumeRenderStyleNode .prototype .removeVolumeData .call (this, volumeDataNode);
|
|
1504
|
+
|
|
1505
|
+
for (var i = 0, length = renderStyleNodes .length; i < length; ++ i)
|
|
1506
|
+
{
|
|
1507
|
+
var renderStyleNode = renderStyleNodes [i];
|
|
1508
|
+
|
|
1509
|
+
renderStyleNode .removeVolumeData (volumeDataNode);
|
|
1510
|
+
}
|
|
1511
|
+
},
|
|
1512
|
+
set_renderStyle__: function ()
|
|
1513
|
+
{
|
|
1514
|
+
var renderStyleNodes = this .renderStyleNodes;
|
|
1515
|
+
|
|
1516
|
+
for (var i = 0, length = renderStyleNodes .length; i < length; ++ i)
|
|
1517
|
+
{
|
|
1518
|
+
var renderStyleNode = renderStyleNodes [i];
|
|
1519
|
+
|
|
1520
|
+
renderStyleNode .removeInterest ("addNodeEvent", this);
|
|
1521
|
+
|
|
1522
|
+
this .getVolumeData () .forEach (function (volumeDataNode)
|
|
1523
|
+
{
|
|
1524
|
+
renderStyleNode .removeVolumeData (volumeDataNode);
|
|
1525
|
+
});
|
|
1526
|
+
}
|
|
1527
|
+
|
|
1528
|
+
renderStyleNodes .length = 0;
|
|
1529
|
+
|
|
1530
|
+
for (var i = 0, length = this .renderStyle_ .length; i < length; ++ i)
|
|
1531
|
+
{
|
|
1532
|
+
var renderStyleNode = X3DCast (X3DConstants .X3DComposableVolumeRenderStyleNode, this .renderStyle_ [i]);
|
|
1533
|
+
|
|
1534
|
+
if (renderStyleNode)
|
|
1535
|
+
renderStyleNodes .push (renderStyleNode);
|
|
1536
|
+
}
|
|
1537
|
+
|
|
1538
|
+
for (var i = 0, length = renderStyleNodes .length; i < length; ++ i)
|
|
1539
|
+
{
|
|
1540
|
+
var renderStyleNode = renderStyleNodes [i];
|
|
1541
|
+
|
|
1542
|
+
renderStyleNode .addInterest ("addNodeEvent", this);
|
|
1543
|
+
|
|
1544
|
+
this .getVolumeData () .forEach (function (volumeDataNode)
|
|
1545
|
+
{
|
|
1546
|
+
renderStyleNode .addVolumeData (volumeDataNode);
|
|
1547
|
+
});
|
|
1548
|
+
}
|
|
1549
|
+
},
|
|
1550
|
+
addShaderFields: function (shaderNode)
|
|
1551
|
+
{
|
|
1552
|
+
if (! this .enabled_ .getValue ())
|
|
1553
|
+
return;
|
|
1554
|
+
|
|
1555
|
+
var renderStyleNodes = this .renderStyleNodes;
|
|
1556
|
+
|
|
1557
|
+
for (var i = 0, length = renderStyleNodes .length; i < length; ++ i)
|
|
1558
|
+
renderStyleNodes [i] .addShaderFields (shaderNode);
|
|
1559
|
+
},
|
|
1560
|
+
getUniformsText: function ()
|
|
1561
|
+
{
|
|
1562
|
+
if (! this .enabled_ .getValue ())
|
|
1563
|
+
return "";
|
|
1564
|
+
|
|
1565
|
+
var
|
|
1566
|
+
renderStyleNodes = this .renderStyleNodes,
|
|
1567
|
+
string = "";
|
|
1568
|
+
|
|
1569
|
+
for (var i = 0, length = renderStyleNodes .length; i < length; ++ i)
|
|
1570
|
+
string += renderStyleNodes [i] .getUniformsText ();
|
|
1571
|
+
|
|
1572
|
+
string += "\n";
|
|
1573
|
+
string += "vec4\n";
|
|
1574
|
+
string += "getComposedStyle_" + this .getId () + " (in vec4 textureColor, in vec3 texCoord)\n";
|
|
1575
|
+
string += "{\n";
|
|
1576
|
+
|
|
1577
|
+
for (var i = 0, length = renderStyleNodes .length; i < length; ++ i)
|
|
1578
|
+
string += renderStyleNodes [i] .getFunctionsText ();
|
|
1579
|
+
|
|
1580
|
+
string += "\n";
|
|
1581
|
+
string += " return textureColor;\n";
|
|
1582
|
+
string += "}\n";
|
|
1583
|
+
|
|
1584
|
+
return string;
|
|
1585
|
+
},
|
|
1586
|
+
getFunctionsText: function ()
|
|
1587
|
+
{
|
|
1588
|
+
if (! this .enabled_ .getValue ())
|
|
1589
|
+
return "";
|
|
1590
|
+
|
|
1591
|
+
var string = "";
|
|
1592
|
+
|
|
1593
|
+
string += "\n";
|
|
1594
|
+
string += " // ComposedVolumeStyle\n";
|
|
1595
|
+
string += "\n";
|
|
1596
|
+
string += " textureColor = getComposedStyle_" + this .getId () + " (textureColor, texCoord);\n";
|
|
1597
|
+
|
|
1598
|
+
return string;
|
|
1599
|
+
}
|
|
1600
|
+
});
|
|
1601
|
+
|
|
1602
|
+
return ComposedVolumeStyle;
|
|
1603
|
+
});
|
|
1604
|
+
|
|
1605
|
+
/* -*- Mode: JavaScript; coding: utf-8; tab-width: 3; indent-tabs-mode: tab; c-basic-offset: 3 -*-
|
|
1606
|
+
*******************************************************************************
|
|
1607
|
+
*
|
|
1608
|
+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
1609
|
+
*
|
|
1610
|
+
* Copyright create3000, ScheffelstraÃe 31a, Leipzig, Germany 2011.
|
|
1611
|
+
*
|
|
1612
|
+
* All rights reserved. Holger Seelig <holger.seelig@yahoo.de>.
|
|
1613
|
+
*
|
|
1614
|
+
* The copyright notice above does not evidence any actual of intended
|
|
1615
|
+
* publication of such source code, and is an unpublished work by create3000.
|
|
1616
|
+
* This material contains CONFIDENTIAL INFORMATION that is the property of
|
|
1617
|
+
* create3000.
|
|
1618
|
+
*
|
|
1619
|
+
* No permission is granted to copy, distribute, or create derivative works from
|
|
1620
|
+
* the contents of this software, in whole or in part, without the prior written
|
|
1621
|
+
* permission of create3000.
|
|
1622
|
+
*
|
|
1623
|
+
* NON-MILITARY USE ONLY
|
|
1624
|
+
*
|
|
1625
|
+
* All create3000 software are effectively free software with a non-military use
|
|
1626
|
+
* restriction. It is free. Well commented source is provided. You may reuse the
|
|
1627
|
+
* source in any way you please with the exception anything that uses it must be
|
|
1628
|
+
* marked to indicate is contains 'non-military use only' components.
|
|
1629
|
+
*
|
|
1630
|
+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
1631
|
+
*
|
|
1632
|
+
* Copyright 2015, 2016 Holger Seelig <holger.seelig@yahoo.de>.
|
|
1633
|
+
*
|
|
1634
|
+
* This file is part of the X_ITE Project.
|
|
1635
|
+
*
|
|
1636
|
+
* X_ITE is free software: you can redistribute it and/or modify it under the
|
|
1637
|
+
* terms of the GNU General Public License version 3 only, as published by the
|
|
1638
|
+
* Free Software Foundation.
|
|
1639
|
+
*
|
|
1640
|
+
* X_ITE is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
1641
|
+
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
|
1642
|
+
* A PARTICULAR PURPOSE. See the GNU General Public License version 3 for more
|
|
1643
|
+
* details (a copy is included in the LICENSE file that accompanied this code).
|
|
1644
|
+
*
|
|
1645
|
+
* You should have received a copy of the GNU General Public License version 3
|
|
1646
|
+
* along with X_ITE. If not, see <http://www.gnu.org/licenses/gpl.html> for a
|
|
1647
|
+
* copy of the GPLv3 License.
|
|
1648
|
+
*
|
|
1649
|
+
* For Silvio, Joy and Adi.
|
|
1650
|
+
*
|
|
1651
|
+
******************************************************************************/
|
|
1652
|
+
|
|
1653
|
+
|
|
1654
|
+
define ('x_ite/Components/VolumeRendering/EdgeEnhancementVolumeStyle',[
|
|
1655
|
+
"x_ite/Fields",
|
|
1656
|
+
"x_ite/Basic/X3DFieldDefinition",
|
|
1657
|
+
"x_ite/Basic/FieldDefinitionArray",
|
|
1658
|
+
"x_ite/Components/VolumeRendering/X3DComposableVolumeRenderStyleNode",
|
|
1659
|
+
"x_ite/Bits/X3DConstants",
|
|
1660
|
+
"x_ite/Bits/X3DCast",
|
|
1661
|
+
],
|
|
1662
|
+
function (Fields,
|
|
1663
|
+
X3DFieldDefinition,
|
|
1664
|
+
FieldDefinitionArray,
|
|
1665
|
+
X3DComposableVolumeRenderStyleNode,
|
|
1666
|
+
X3DConstants,
|
|
1667
|
+
X3DCast)
|
|
1668
|
+
{
|
|
1669
|
+
"use strict";
|
|
1670
|
+
|
|
1671
|
+
function EdgeEnhancementVolumeStyle (executionContext)
|
|
1672
|
+
{
|
|
1673
|
+
X3DComposableVolumeRenderStyleNode .call (this, executionContext);
|
|
1674
|
+
|
|
1675
|
+
this .addType (X3DConstants .EdgeEnhancementVolumeStyle);
|
|
1676
|
+
}
|
|
1677
|
+
|
|
1678
|
+
EdgeEnhancementVolumeStyle .prototype = Object .assign (Object .create (X3DComposableVolumeRenderStyleNode .prototype),
|
|
1679
|
+
{
|
|
1680
|
+
constructor: EdgeEnhancementVolumeStyle,
|
|
1681
|
+
fieldDefinitions: new FieldDefinitionArray ([
|
|
1682
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "metadata", new Fields .SFNode ()),
|
|
1683
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "enabled", new Fields .SFBool (true)),
|
|
1684
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "edgeColor", new Fields .SFColorRGBA (0, 0, 0, 1)),
|
|
1685
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "gradientThreshold", new Fields .SFFloat (0.4)),
|
|
1686
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "surfaceNormals", new Fields .SFNode ()),
|
|
1687
|
+
]),
|
|
1688
|
+
getTypeName: function ()
|
|
1689
|
+
{
|
|
1690
|
+
return "EdgeEnhancementVolumeStyle";
|
|
1691
|
+
},
|
|
1692
|
+
getComponentName: function ()
|
|
1693
|
+
{
|
|
1694
|
+
return "VolumeRendering";
|
|
1695
|
+
},
|
|
1696
|
+
getContainerField: function ()
|
|
1697
|
+
{
|
|
1698
|
+
return "renderStyle";
|
|
1699
|
+
},
|
|
1700
|
+
initialize: function ()
|
|
1701
|
+
{
|
|
1702
|
+
X3DComposableVolumeRenderStyleNode .prototype .initialize .call (this);
|
|
1703
|
+
|
|
1704
|
+
var gl = this .getBrowser () .getContext ();
|
|
1705
|
+
|
|
1706
|
+
if (gl .getVersion () < 2)
|
|
1707
|
+
return;
|
|
1708
|
+
|
|
1709
|
+
this .surfaceNormals_ .addInterest ("set_surfaceNormals__", this);
|
|
1710
|
+
|
|
1711
|
+
this .set_surfaceNormals__ ();
|
|
1712
|
+
},
|
|
1713
|
+
set_surfaceNormals__: function ()
|
|
1714
|
+
{
|
|
1715
|
+
this .surfaceNormalsNode = X3DCast (X3DConstants .X3DTexture3DNode, this .surfaceNormals_);
|
|
1716
|
+
},
|
|
1717
|
+
addShaderFields: function (shaderNode)
|
|
1718
|
+
{
|
|
1719
|
+
if (! this .enabled_ .getValue ())
|
|
1720
|
+
return;
|
|
1721
|
+
|
|
1722
|
+
shaderNode .addUserDefinedField (X3DConstants .inputOutput, "edgeColor_" + this .getId (), this .edgeColor_ .copy ());
|
|
1723
|
+
shaderNode .addUserDefinedField (X3DConstants .inputOutput, "gradientThreshold_" + this .getId (), this .gradientThreshold_ .copy ());
|
|
1724
|
+
|
|
1725
|
+
if (this .surfaceNormalsNode)
|
|
1726
|
+
shaderNode .addUserDefinedField (X3DConstants .inputOutput, "surfaceNormals_" + this .getId (), new Fields .SFNode (this .surfaceNormalsNode));
|
|
1727
|
+
},
|
|
1728
|
+
getUniformsText: function ()
|
|
1729
|
+
{
|
|
1730
|
+
if (! this .enabled_ .getValue ())
|
|
1731
|
+
return "";
|
|
1732
|
+
|
|
1733
|
+
var string = "";
|
|
1734
|
+
|
|
1735
|
+
string += "\n";
|
|
1736
|
+
string += "// EdgeEnhancementVolumeStyle\n";
|
|
1737
|
+
string += "\n";
|
|
1738
|
+
string += "uniform vec4 edgeColor_" + this .getId () + ";\n";
|
|
1739
|
+
string += "uniform float gradientThreshold_" + this .getId () + ";\n";
|
|
1740
|
+
|
|
1741
|
+
string += this .getNormalText (this .surfaceNormalsNode);
|
|
1742
|
+
|
|
1743
|
+
string += "\n";
|
|
1744
|
+
string += "vec4\n";
|
|
1745
|
+
string += "getEdgeEnhacementStyle_" + this .getId () + " (in vec4 originalColor, in vec3 texCoord)\n";
|
|
1746
|
+
string += "{\n";
|
|
1747
|
+
string += " vec4 surfaceNormal = getNormal_" + this .getId () + " (texCoord);\n";
|
|
1748
|
+
string += "\n";
|
|
1749
|
+
string += " if (surfaceNormal .w == 0.0)\n";
|
|
1750
|
+
string += " return vec4 (0.0);\n";
|
|
1751
|
+
string += "\n";
|
|
1752
|
+
string += " vec4 edgeColor = edgeColor_" + this .getId () + ";\n";
|
|
1753
|
+
string += " float gradientThreshold = gradientThreshold_" + this .getId () + ";\n";
|
|
1754
|
+
string += "\n";
|
|
1755
|
+
string += " float angle = abs (dot (surfaceNormal .xyz, normalize (vertex)));\n";
|
|
1756
|
+
string += "\n";
|
|
1757
|
+
string += " if (angle >= cos (gradientThreshold))\n";
|
|
1758
|
+
string += " return originalColor;\n";
|
|
1759
|
+
string += " else\n";
|
|
1760
|
+
string += " return vec4 (mix (edgeColor .rgb, originalColor.rgb, angle), originalColor .a);\n";
|
|
1761
|
+
string += "}\n";
|
|
1762
|
+
|
|
1763
|
+
return string;
|
|
1764
|
+
},
|
|
1765
|
+
getFunctionsText: function ()
|
|
1766
|
+
{
|
|
1767
|
+
if (! this .enabled_ .getValue ())
|
|
1768
|
+
return "";
|
|
1769
|
+
|
|
1770
|
+
var string = "";
|
|
1771
|
+
|
|
1772
|
+
string += "\n";
|
|
1773
|
+
string += " // EdgeEnhancementVolumeStyle\n";
|
|
1774
|
+
string += "\n";
|
|
1775
|
+
string += " textureColor = getEdgeEnhacementStyle_" + this .getId () + " (textureColor, texCoord);\n";
|
|
1776
|
+
|
|
1777
|
+
return string;
|
|
1778
|
+
},
|
|
1779
|
+
});
|
|
1780
|
+
|
|
1781
|
+
return EdgeEnhancementVolumeStyle;
|
|
1782
|
+
});
|
|
1783
|
+
|
|
1784
|
+
/* -*- Mode: JavaScript; coding: utf-8; tab-width: 3; indent-tabs-mode: tab; c-basic-offset: 3 -*-
|
|
1785
|
+
*******************************************************************************
|
|
1786
|
+
*
|
|
1787
|
+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
1788
|
+
*
|
|
1789
|
+
* Copyright create3000, ScheffelstraÃe 31a, Leipzig, Germany 2011.
|
|
1790
|
+
*
|
|
1791
|
+
* All rights reserved. Holger Seelig <holger.seelig@yahoo.de>.
|
|
1792
|
+
*
|
|
1793
|
+
* The copyright notice above does not evidence any actual of intended
|
|
1794
|
+
* publication of such source code, and is an unpublished work by create3000.
|
|
1795
|
+
* This material contains CONFIDENTIAL INFORMATION that is the property of
|
|
1796
|
+
* create3000.
|
|
1797
|
+
*
|
|
1798
|
+
* No permission is granted to copy, distribute, or create derivative works from
|
|
1799
|
+
* the contents of this software, in whole or in part, without the prior written
|
|
1800
|
+
* permission of create3000.
|
|
1801
|
+
*
|
|
1802
|
+
* NON-MILITARY USE ONLY
|
|
1803
|
+
*
|
|
1804
|
+
* All create3000 software are effectively free software with a non-military use
|
|
1805
|
+
* restriction. It is free. Well commented source is provided. You may reuse the
|
|
1806
|
+
* source in any way you please with the exception anything that uses it must be
|
|
1807
|
+
* marked to indicate is contains 'non-military use only' components.
|
|
1808
|
+
*
|
|
1809
|
+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
1810
|
+
*
|
|
1811
|
+
* Copyright 2015, 2016 Holger Seelig <holger.seelig@yahoo.de>.
|
|
1812
|
+
*
|
|
1813
|
+
* This file is part of the X_ITE Project.
|
|
1814
|
+
*
|
|
1815
|
+
* X_ITE is free software: you can redistribute it and/or modify it under the
|
|
1816
|
+
* terms of the GNU General Public License version 3 only, as published by the
|
|
1817
|
+
* Free Software Foundation.
|
|
1818
|
+
*
|
|
1819
|
+
* X_ITE is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
1820
|
+
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
|
1821
|
+
* A PARTICULAR PURPOSE. See the GNU General Public License version 3 for more
|
|
1822
|
+
* details (a copy is included in the LICENSE file that accompanied this code).
|
|
1823
|
+
*
|
|
1824
|
+
* You should have received a copy of the GNU General Public License version 3
|
|
1825
|
+
* along with X_ITE. If not, see <http://www.gnu.org/licenses/gpl.html> for a
|
|
1826
|
+
* copy of the GPLv3 License.
|
|
1827
|
+
*
|
|
1828
|
+
* For Silvio, Joy and Adi.
|
|
1829
|
+
*
|
|
1830
|
+
******************************************************************************/
|
|
1831
|
+
|
|
1832
|
+
|
|
1833
|
+
define ('x_ite/Components/VolumeRendering/X3DVolumeDataNode',[
|
|
1834
|
+
"x_ite/Fields",
|
|
1835
|
+
"x_ite/Components/Core/X3DChildNode",
|
|
1836
|
+
"x_ite/Components/Grouping/X3DBoundedObject",
|
|
1837
|
+
"x_ite/Bits/X3DConstants",
|
|
1838
|
+
"x_ite/Browser/Core/TextureQuality",
|
|
1839
|
+
"standard/Math/Numbers/Vector3",
|
|
1840
|
+
],
|
|
1841
|
+
function (Fields,
|
|
1842
|
+
X3DChildNode,
|
|
1843
|
+
X3DBoundedObject,
|
|
1844
|
+
X3DConstants,
|
|
1845
|
+
TextureQuality,
|
|
1846
|
+
Vector3)
|
|
1847
|
+
{
|
|
1848
|
+
"use strict";
|
|
1849
|
+
|
|
1850
|
+
function X3DVolumeDataNode (executionContext)
|
|
1851
|
+
{
|
|
1852
|
+
X3DChildNode .call (this, executionContext);
|
|
1853
|
+
X3DBoundedObject .call (this, executionContext);
|
|
1854
|
+
|
|
1855
|
+
this .addType (X3DConstants .X3DVolumeDataNode);
|
|
1856
|
+
|
|
1857
|
+
this .proximitySensorNode = executionContext .createNode ("ProximitySensor", false);
|
|
1858
|
+
this .transformNode = executionContext .createNode ("Transform", false);
|
|
1859
|
+
this .shapeNode = executionContext .createNode ("Shape", false);
|
|
1860
|
+
this .appearanceNode = executionContext .createNode ("Appearance", false);
|
|
1861
|
+
this .textureTransformNode = executionContext .createNode ("TextureTransform3D", false);
|
|
1862
|
+
this .geometryNode = executionContext .createNode ("QuadSet", false);
|
|
1863
|
+
this .textureCoordinateNode = executionContext .createNode ("TextureCoordinate3D", false);
|
|
1864
|
+
this .coordinateNode = executionContext .createNode ("Coordinate", false);
|
|
1865
|
+
|
|
1866
|
+
this .setCameraObject (true);
|
|
1867
|
+
}
|
|
1868
|
+
|
|
1869
|
+
X3DVolumeDataNode .prototype = Object .assign (Object .create (X3DChildNode .prototype),
|
|
1870
|
+
X3DBoundedObject .prototype,
|
|
1871
|
+
{
|
|
1872
|
+
constructor: X3DVolumeDataNode,
|
|
1873
|
+
initialize: function ()
|
|
1874
|
+
{
|
|
1875
|
+
X3DChildNode .prototype .initialize .call (this);
|
|
1876
|
+
X3DBoundedObject .prototype .initialize .call (this);
|
|
1877
|
+
|
|
1878
|
+
var
|
|
1879
|
+
browser = this .getBrowser (),
|
|
1880
|
+
gl = browser .getContext ();
|
|
1881
|
+
|
|
1882
|
+
browser .getBrowserOptions () .TextureQuality_ .addInterest ("set_dimensions__", this);
|
|
1883
|
+
|
|
1884
|
+
if (gl .getVersion () >= 2)
|
|
1885
|
+
{
|
|
1886
|
+
this .dimensions_ .addInterest ("set_dimensions__", this);
|
|
1887
|
+
|
|
1888
|
+
this .set_dimensions__ ();
|
|
1889
|
+
}
|
|
1890
|
+
|
|
1891
|
+
this .appearanceNode .setPrivate (true);
|
|
1892
|
+
|
|
1893
|
+
this .proximitySensorNode .size_ = new Fields .SFVec3f (-1, -1, -1);
|
|
1894
|
+
this .transformNode .children_ = new Fields .MFNode (this .shapeNode);
|
|
1895
|
+
this .shapeNode .appearance_ = this .appearanceNode;
|
|
1896
|
+
this .shapeNode .geometry_ = this .geometryNode;
|
|
1897
|
+
this .appearanceNode .alphaMode_ = "BLEND";
|
|
1898
|
+
this .appearanceNode .textureTransform_ = this .textureTransformNode;
|
|
1899
|
+
this .textureTransformNode .translation_ = new Fields .SFVec3f (0.5, 0.5, 0.5);
|
|
1900
|
+
this .textureTransformNode .center_ = new Fields .SFVec3f (-0.5, -0.5, -0.5);
|
|
1901
|
+
this .geometryNode .texCoord_ = this .textureCoordinateNode;
|
|
1902
|
+
this .geometryNode .coord_ = this .coordinateNode;
|
|
1903
|
+
|
|
1904
|
+
this .coordinateNode .setup ();
|
|
1905
|
+
this .textureCoordinateNode .setup ();
|
|
1906
|
+
this .geometryNode .setup ();
|
|
1907
|
+
this .textureTransformNode .setup ();
|
|
1908
|
+
this .appearanceNode .setup ();
|
|
1909
|
+
this .shapeNode .setup ();
|
|
1910
|
+
this .transformNode .setup ();
|
|
1911
|
+
this .proximitySensorNode .setup ();
|
|
1912
|
+
|
|
1913
|
+
this .proximitySensorNode .orientation_changed_ .addFieldInterest (this .transformNode .rotation_);
|
|
1914
|
+
this .proximitySensorNode .orientation_changed_ .addFieldInterest (this .textureTransformNode .rotation_);
|
|
1915
|
+
|
|
1916
|
+
this .textureTransformNode .addInterest ("set_textureTransform__", this);
|
|
1917
|
+
},
|
|
1918
|
+
getBBox: function (bbox, shadow)
|
|
1919
|
+
{
|
|
1920
|
+
if (this .bboxSize_ .getValue () .equals (this .getDefaultBBoxSize ()))
|
|
1921
|
+
return bbox .set (this .dimensions_ .getValue (), Vector3 .Zero);
|
|
1922
|
+
|
|
1923
|
+
return bbox .set (this .bboxSize_ .getValue (), this .bboxCenter_ .getValue ());
|
|
1924
|
+
},
|
|
1925
|
+
getAppearance: function ()
|
|
1926
|
+
{
|
|
1927
|
+
return this .appearanceNode;
|
|
1928
|
+
},
|
|
1929
|
+
setShader: function (shaderNode)
|
|
1930
|
+
{
|
|
1931
|
+
this .getAppearance () .shaders_ [0] = shaderNode;
|
|
1932
|
+
|
|
1933
|
+
shaderNode .addUserDefinedField (X3DConstants .inputOutput, "x3d_TextureNormalMatrix" , new Fields .SFMatrix3f ());
|
|
1934
|
+
shaderNode .setup ();
|
|
1935
|
+
|
|
1936
|
+
this .set_textureTransform__ ();
|
|
1937
|
+
},
|
|
1938
|
+
getShader: function ()
|
|
1939
|
+
{
|
|
1940
|
+
var node = this .appearanceNode .shaders_ [0];
|
|
1941
|
+
|
|
1942
|
+
if (node)
|
|
1943
|
+
return node .getValue ();
|
|
1944
|
+
|
|
1945
|
+
return null;
|
|
1946
|
+
},
|
|
1947
|
+
getNumPlanes: function ()
|
|
1948
|
+
{
|
|
1949
|
+
switch (this .getBrowser () .getBrowserOptions () .getTextureQuality ())
|
|
1950
|
+
{
|
|
1951
|
+
case TextureQuality .LOW:
|
|
1952
|
+
{
|
|
1953
|
+
return 200;
|
|
1954
|
+
}
|
|
1955
|
+
case TextureQuality .MEDIUM:
|
|
1956
|
+
{
|
|
1957
|
+
return 400;
|
|
1958
|
+
}
|
|
1959
|
+
case TextureQuality .HIGH:
|
|
1960
|
+
{
|
|
1961
|
+
return 600;
|
|
1962
|
+
}
|
|
1963
|
+
}
|
|
1964
|
+
|
|
1965
|
+
return 200;
|
|
1966
|
+
},
|
|
1967
|
+
set_dimensions__: function ()
|
|
1968
|
+
{
|
|
1969
|
+
var
|
|
1970
|
+
NUM_PLANES = this .getNumPlanes (),
|
|
1971
|
+
size = this .dimensions_ .getValue () .abs (),
|
|
1972
|
+
size1_2 = size / 2,
|
|
1973
|
+
points = [ ];
|
|
1974
|
+
|
|
1975
|
+
this .coordinateNode .point_ .length = 0;
|
|
1976
|
+
|
|
1977
|
+
for (var i = 0; i < NUM_PLANES; ++ i)
|
|
1978
|
+
{
|
|
1979
|
+
var z = i / (NUM_PLANES - 1) - 0.5;
|
|
1980
|
+
|
|
1981
|
+
points .push ( size1_2, size1_2, size * z,
|
|
1982
|
+
-size1_2, size1_2, size * z,
|
|
1983
|
+
-size1_2, -size1_2, size * z,
|
|
1984
|
+
size1_2, -size1_2, size * z);
|
|
1985
|
+
}
|
|
1986
|
+
|
|
1987
|
+
this .coordinateNode .point_ = points;
|
|
1988
|
+
this .textureCoordinateNode .point_ = points;
|
|
1989
|
+
|
|
1990
|
+
this .textureTransformNode .scale_ = new Fields .SFVec3f (1 / this .dimensions_ .x, 1 / this .dimensions_ .y, 1 / this .dimensions_ .z);
|
|
1991
|
+
},
|
|
1992
|
+
set_textureTransform__: function ()
|
|
1993
|
+
{
|
|
1994
|
+
var shaderNode = this .getShader ();
|
|
1995
|
+
|
|
1996
|
+
if (shaderNode)
|
|
1997
|
+
{
|
|
1998
|
+
var invTextureMatrix = shaderNode .getField ("x3d_TextureNormalMatrix");
|
|
1999
|
+
|
|
2000
|
+
invTextureMatrix .setValue (this .textureTransformNode .getMatrix () .submatrix .inverse () .transpose ());
|
|
2001
|
+
}
|
|
2002
|
+
},
|
|
2003
|
+
traverse: function (type, renderObject)
|
|
2004
|
+
{
|
|
2005
|
+
this .proximitySensorNode .traverse (type, renderObject);
|
|
2006
|
+
this .transformNode .traverse (type, renderObject);
|
|
2007
|
+
}
|
|
2008
|
+
});
|
|
2009
|
+
|
|
2010
|
+
return X3DVolumeDataNode;
|
|
2011
|
+
});
|
|
2012
|
+
|
|
2013
|
+
|
|
2014
|
+
define('text!x_ite/Browser/VolumeRendering/VolumeStyle.vs',[],function () { return '#version 300 es\n\nprecision highp float;\nprecision highp int;\n\nuniform mat4 x3d_ProjectionMatrix;\nuniform mat4 x3d_ModelViewMatrix;\nuniform mat4 x3d_TextureMatrix [1];\n\nin float x3d_FogDepth;\nin vec4 x3d_TexCoord0;\nin vec4 x3d_Vertex;\n\nout float fogDepth;\nout vec3 vertex;\nout vec4 texCoord;\n\nvoid\nmain ()\n{\n\tvec4 position = x3d_ModelViewMatrix * x3d_Vertex;\n\n\tfogDepth = x3d_FogDepth;\n\tvertex = position .xyz;\n\ttexCoord = x3d_TextureMatrix [0] * x3d_TexCoord0;\n\n\tgl_Position = x3d_ProjectionMatrix * position;\n}\n';});
|
|
2015
|
+
|
|
2016
|
+
|
|
2017
|
+
define('text!x_ite/Browser/VolumeRendering/VolumeStyle.fs',[],function () { return '#version 300 es\n\nprecision highp float;\nprecision highp int;\nprecision highp sampler3D;\n\nuniform int x3d_NumLights;\nuniform x3d_LightSourceParameters x3d_LightSource [x3d_MaxLights];\n\nuniform int x3d_NumTextures;\nuniform sampler3D x3d_Texture3D [1];\nuniform vec3 x3d_TextureSize;\n\nuniform mat3 x3d_TextureNormalMatrix;\n\nconst float M_PI = 3.14159265359;\n\nin float fogDepth;\nin vec3 vertex;\nin vec4 texCoord;\n\n\nuniform x3d_FogParameters x3d_Fog;\n\nfloat\ngetFogInterpolant ()\n{\n\t// Returns 0.0 for fog color and 1.0 for material color.\n\n\tif (x3d_Fog .type == x3d_None)\n\t\treturn 1.0;\n\n\tif (x3d_Fog .fogCoord)\n\t\treturn clamp (1.0 - fogDepth, 0.0, 1.0);\n\n\tfloat visibilityRange = x3d_Fog .visibilityRange;\n\n\tif (visibilityRange <= 0.0)\n\t\treturn 1.0;\n\n\tfloat dV = length (x3d_Fog .matrix * vertex);\n\n\tif (dV >= visibilityRange)\n\t\treturn 0.0;\n\n\tswitch (x3d_Fog .type)\n\t{\n\t\tcase x3d_LinearFog:\n\t\t{\n\t\t\treturn (visibilityRange - dV) / visibilityRange;\n\t\t}\n\t\tcase x3d_ExponentialFog:\n\t\t{\n\t\t\treturn exp (-dV / (visibilityRange - dV));\n\t\t}\n\t\tdefault:\n\t\t{\n\t\t\treturn 1.0;\n\t\t}\n\t}\n}\n\nvec3\ngetFogColor (const in vec3 color)\n{\n\treturn mix (x3d_Fog .color, color, getFogInterpolant ());\n}\n\n// VOLUME_STYLES_UNIFORMS\n\nout vec4 x3d_FragColor;\n\n\nuniform int x3d_NumClipPlanes;\nuniform vec4 x3d_ClipPlane [x3d_MaxClipPlanes];\n\nvoid\nclip ()\n{\n\tfor (int i = 0; i < x3d_MaxClipPlanes; ++ i)\n\t{\n\t\tif (i == x3d_NumClipPlanes)\n\t\t\tbreak;\n\n\t\tif (dot (vertex, x3d_ClipPlane [i] .xyz) - x3d_ClipPlane [i] .w < 0.0)\n\t\t\tdiscard;\n\t}\n}\n\nvec4\ngetTextureColor (in vec3 texCoord)\n{\n\tif (x3d_NumTextures == 0)\n\t\tdiscard;\n\n\tif (texCoord .s < 0.0 || texCoord .s > 1.0)\n\t\tdiscard;\n\n\tif (texCoord .t < 0.0 || texCoord .t > 1.0)\n\t\tdiscard;\n\n\tif (texCoord .p < 0.0 || texCoord .p > 1.0)\n\t\tdiscard;\n\n\tvec4 textureColor = texture (x3d_Texture3D [0], texCoord);\n\n\t// Apply volume styles.\n\n// VOLUME_STYLES_FUNCTIONS\n\n\treturn textureColor;\n}\n\nvoid\nmain ()\n{\n\tclip ();\n\n\tx3d_FragColor = getTextureColor (texCoord .stp / texCoord .q);\n}\n';});
|
|
2018
|
+
|
|
2019
|
+
/* -*- Mode: JavaScript; coding: utf-8; tab-width: 3; indent-tabs-mode: tab; c-basic-offset: 3 -*-
|
|
2020
|
+
*******************************************************************************
|
|
2021
|
+
*
|
|
2022
|
+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
2023
|
+
*
|
|
2024
|
+
* Copyright create3000, ScheffelstraÃe 31a, Leipzig, Germany 2011.
|
|
2025
|
+
*
|
|
2026
|
+
* All rights reserved. Holger Seelig <holger.seelig@yahoo.de>.
|
|
2027
|
+
*
|
|
2028
|
+
* The copyright notice above does not evidence any actual of intended
|
|
2029
|
+
* publication of such source code, and is an unpublished work by create3000.
|
|
2030
|
+
* This material contains CONFIDENTIAL INFORMATION that is the property of
|
|
2031
|
+
* create3000.
|
|
2032
|
+
*
|
|
2033
|
+
* No permission is granted to copy, distribute, or create derivative works from
|
|
2034
|
+
* the contents of this software, in whole or in part, without the prior written
|
|
2035
|
+
* permission of create3000.
|
|
2036
|
+
*
|
|
2037
|
+
* NON-MILITARY USE ONLY
|
|
2038
|
+
*
|
|
2039
|
+
* All create3000 software are effectively free software with a non-military use
|
|
2040
|
+
* restriction. It is free. Well commented source is provided. You may reuse the
|
|
2041
|
+
* source in any way you please with the exception anything that uses it must be
|
|
2042
|
+
* marked to indicate is contains 'non-military use only' components.
|
|
2043
|
+
*
|
|
2044
|
+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
2045
|
+
*
|
|
2046
|
+
* Copyright 2015, 2016 Holger Seelig <holger.seelig@yahoo.de>.
|
|
2047
|
+
*
|
|
2048
|
+
* This file is part of the X_ITE Project.
|
|
2049
|
+
*
|
|
2050
|
+
* X_ITE is free software: you can redistribute it and/or modify it under the
|
|
2051
|
+
* terms of the GNU General Public License version 3 only, as published by the
|
|
2052
|
+
* Free Software Foundation.
|
|
2053
|
+
*
|
|
2054
|
+
* X_ITE is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
2055
|
+
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
|
2056
|
+
* A PARTICULAR PURPOSE. See the GNU General Public License version 3 for more
|
|
2057
|
+
* details (a copy is included in the LICENSE file that accompanied this code).
|
|
2058
|
+
*
|
|
2059
|
+
* You should have received a copy of the GNU General Public License version 3
|
|
2060
|
+
* along with X_ITE. If not, see <http://www.gnu.org/licenses/gpl.html> for a
|
|
2061
|
+
* copy of the GPLv3 License.
|
|
2062
|
+
*
|
|
2063
|
+
* For Silvio, Joy and Adi.
|
|
2064
|
+
*
|
|
2065
|
+
******************************************************************************/
|
|
2066
|
+
|
|
2067
|
+
|
|
2068
|
+
define ('x_ite/Components/VolumeRendering/IsoSurfaceVolumeData',[
|
|
2069
|
+
"x_ite/Fields",
|
|
2070
|
+
"x_ite/Basic/X3DFieldDefinition",
|
|
2071
|
+
"x_ite/Basic/FieldDefinitionArray",
|
|
2072
|
+
"x_ite/Components/VolumeRendering/X3DVolumeDataNode",
|
|
2073
|
+
"x_ite/Components/Shaders/ComposedShader",
|
|
2074
|
+
"x_ite/Components/Shaders/ShaderPart",
|
|
2075
|
+
"x_ite/Bits/X3DConstants",
|
|
2076
|
+
"x_ite/Bits/X3DCast",
|
|
2077
|
+
"text!x_ite/Browser/VolumeRendering/VolumeStyle.vs",
|
|
2078
|
+
"text!x_ite/Browser/VolumeRendering/VolumeStyle.fs",
|
|
2079
|
+
"x_ite/DEBUG",
|
|
2080
|
+
],
|
|
2081
|
+
function (Fields,
|
|
2082
|
+
X3DFieldDefinition,
|
|
2083
|
+
FieldDefinitionArray,
|
|
2084
|
+
X3DVolumeDataNode,
|
|
2085
|
+
ComposedShader,
|
|
2086
|
+
ShaderPart,
|
|
2087
|
+
X3DConstants,
|
|
2088
|
+
X3DCast,
|
|
2089
|
+
vs,
|
|
2090
|
+
fs,
|
|
2091
|
+
DEBUG)
|
|
2092
|
+
{
|
|
2093
|
+
"use strict";
|
|
2094
|
+
|
|
2095
|
+
function IsoSurfaceVolumeData (executionContext)
|
|
2096
|
+
{
|
|
2097
|
+
X3DVolumeDataNode .call (this, executionContext);
|
|
2098
|
+
|
|
2099
|
+
this .addType (X3DConstants .IsoSurfaceVolumeData);
|
|
2100
|
+
|
|
2101
|
+
this .renderStyleNodes = [ ];
|
|
2102
|
+
}
|
|
2103
|
+
|
|
2104
|
+
IsoSurfaceVolumeData .prototype = Object .assign (Object .create (X3DVolumeDataNode .prototype),
|
|
2105
|
+
{
|
|
2106
|
+
constructor: IsoSurfaceVolumeData,
|
|
2107
|
+
fieldDefinitions: new FieldDefinitionArray ([
|
|
2108
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "metadata", new Fields .SFNode ()),
|
|
2109
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "dimensions", new Fields .SFVec3f (1, 1, 1)),
|
|
2110
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "contourStepSize", new Fields .SFFloat (0)),
|
|
2111
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "surfaceValues", new Fields .MFFloat ()),
|
|
2112
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "surfaceTolerance", new Fields .SFFloat (0)),
|
|
2113
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "visible", new Fields .SFBool (true)),
|
|
2114
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "bboxDisplay", new Fields .SFBool ()),
|
|
2115
|
+
new X3DFieldDefinition (X3DConstants .initializeOnly, "bboxCenter", new Fields .SFVec3f (0, 0, 0)),
|
|
2116
|
+
new X3DFieldDefinition (X3DConstants .initializeOnly, "bboxSize", new Fields .SFVec3f (-1, -1, -1)),
|
|
2117
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "renderStyle", new Fields .MFNode ()),
|
|
2118
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "gradients", new Fields .SFNode ()),
|
|
2119
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "voxels", new Fields .SFNode ()),
|
|
2120
|
+
]),
|
|
2121
|
+
getTypeName: function ()
|
|
2122
|
+
{
|
|
2123
|
+
return "IsoSurfaceVolumeData";
|
|
2124
|
+
},
|
|
2125
|
+
getComponentName: function ()
|
|
2126
|
+
{
|
|
2127
|
+
return "VolumeRendering";
|
|
2128
|
+
},
|
|
2129
|
+
getContainerField: function ()
|
|
2130
|
+
{
|
|
2131
|
+
return "children";
|
|
2132
|
+
},
|
|
2133
|
+
initialize: function ()
|
|
2134
|
+
{
|
|
2135
|
+
X3DVolumeDataNode .prototype .initialize .call (this);
|
|
2136
|
+
|
|
2137
|
+
var gl = this .getBrowser () .getContext ();
|
|
2138
|
+
|
|
2139
|
+
if (gl .getVersion () < 2)
|
|
2140
|
+
return;
|
|
2141
|
+
|
|
2142
|
+
this .gradients_ .addInterest ("set_gradients__", this);
|
|
2143
|
+
this .renderStyle_ .addInterest ("set_renderStyle__", this);
|
|
2144
|
+
this .voxels_ .addFieldInterest (this .getAppearance () .texture_);
|
|
2145
|
+
|
|
2146
|
+
this .contourStepSize_ .addInterest ("update", this);
|
|
2147
|
+
this .surfaceValues_ .addInterest ("update", this);
|
|
2148
|
+
this .surfaceTolerance_ .addInterest ("update", this);
|
|
2149
|
+
this .renderStyle_ .addInterest ("update", this);
|
|
2150
|
+
|
|
2151
|
+
this .getAppearance () .texture_ = this .voxels_;
|
|
2152
|
+
|
|
2153
|
+
this .set_gradients__ ();
|
|
2154
|
+
this .set_renderStyle__ ();
|
|
2155
|
+
this .set_voxels__ ();
|
|
2156
|
+
|
|
2157
|
+
this .update ();
|
|
2158
|
+
},
|
|
2159
|
+
set_gradients__: function ()
|
|
2160
|
+
{
|
|
2161
|
+
this .gradientsNode = X3DCast (X3DConstants .X3DTexture3DNode, this .gradients_);
|
|
2162
|
+
},
|
|
2163
|
+
set_renderStyle__: function ()
|
|
2164
|
+
{
|
|
2165
|
+
var renderStyleNodes = this .renderStyleNodes;
|
|
2166
|
+
|
|
2167
|
+
for (var i = 0, length = renderStyleNodes .length; i < length; ++ i)
|
|
2168
|
+
{
|
|
2169
|
+
var renderStyleNode = renderStyleNodes [i];
|
|
2170
|
+
|
|
2171
|
+
renderStyleNode .removeInterest ("update", this);
|
|
2172
|
+
renderStyleNode .removeVolumeData (this);
|
|
2173
|
+
}
|
|
2174
|
+
|
|
2175
|
+
renderStyleNodes .length = 0;
|
|
2176
|
+
|
|
2177
|
+
for (var i = 0, length = this .renderStyle_ .length; i < length; ++ i)
|
|
2178
|
+
{
|
|
2179
|
+
var renderStyleNode = X3DCast (X3DConstants .X3DComposableVolumeRenderStyleNode, this .renderStyle_ [i]);
|
|
2180
|
+
|
|
2181
|
+
if (renderStyleNode)
|
|
2182
|
+
renderStyleNodes .push (renderStyleNode);
|
|
2183
|
+
}
|
|
2184
|
+
|
|
2185
|
+
for (var i = 0, length = renderStyleNodes .length; i < length; ++ i)
|
|
2186
|
+
{
|
|
2187
|
+
var renderStyleNode = renderStyleNodes [i];
|
|
2188
|
+
|
|
2189
|
+
renderStyleNode .addInterest ("update", this);
|
|
2190
|
+
renderStyleNode .addVolumeData (this);
|
|
2191
|
+
}
|
|
2192
|
+
},
|
|
2193
|
+
set_voxels__: function ()
|
|
2194
|
+
{
|
|
2195
|
+
if (this .voxelsNode)
|
|
2196
|
+
this .voxelsNode .removeInterest ("set_textureSize__", this);
|
|
2197
|
+
|
|
2198
|
+
this .voxelsNode = X3DCast (X3DConstants .X3DTexture3DNode, this .voxels_);
|
|
2199
|
+
|
|
2200
|
+
if (this .voxelsNode)
|
|
2201
|
+
{
|
|
2202
|
+
this .voxelsNode .addInterest ("set_textureSize__", this);
|
|
2203
|
+
|
|
2204
|
+
this .set_textureSize__ ();
|
|
2205
|
+
}
|
|
2206
|
+
},
|
|
2207
|
+
set_textureSize__: function ()
|
|
2208
|
+
{
|
|
2209
|
+
try
|
|
2210
|
+
{
|
|
2211
|
+
var textureSize = this .getShader () .getField ("x3d_TextureSize");
|
|
2212
|
+
|
|
2213
|
+
textureSize .x = this .voxelsNode .getWidth ();
|
|
2214
|
+
textureSize .y = this .voxelsNode .getHeight ();
|
|
2215
|
+
textureSize .z = this .voxelsNode .getDepth ();
|
|
2216
|
+
}
|
|
2217
|
+
catch (error)
|
|
2218
|
+
{
|
|
2219
|
+
if (DEBUG)
|
|
2220
|
+
console .log (error .message);
|
|
2221
|
+
}
|
|
2222
|
+
},
|
|
2223
|
+
update: function ()
|
|
2224
|
+
{
|
|
2225
|
+
this .setShader (this .createShader (vs, fs));
|
|
2226
|
+
},
|
|
2227
|
+
createShader: function (vs, fs)
|
|
2228
|
+
{
|
|
2229
|
+
// if (DEBUG)
|
|
2230
|
+
// console .log ("Creating VolumeData Shader ...");
|
|
2231
|
+
|
|
2232
|
+
var
|
|
2233
|
+
opacityMapVolumeStyle = this .getBrowser () .getDefaultVolumeStyle (),
|
|
2234
|
+
styleUniforms = opacityMapVolumeStyle .getUniformsText (),
|
|
2235
|
+
styleFunctions = opacityMapVolumeStyle .getFunctionsText ();
|
|
2236
|
+
|
|
2237
|
+
styleUniforms += "\n";
|
|
2238
|
+
styleUniforms += "uniform float surfaceValues [" + this .surfaceValues_ .length + "];\n";
|
|
2239
|
+
styleUniforms += "uniform float surfaceTolerance;\n";
|
|
2240
|
+
|
|
2241
|
+
for (var i = 0, length = this .renderStyleNodes .length; i < length; ++ i)
|
|
2242
|
+
styleUniforms += this .renderStyleNodes [i] .getUniformsText ();
|
|
2243
|
+
|
|
2244
|
+
styleFunctions += "\n";
|
|
2245
|
+
styleFunctions += " // IsoSurfaceVolumeData\n";
|
|
2246
|
+
styleFunctions += "\n";
|
|
2247
|
+
|
|
2248
|
+
if (this .gradientsNode)
|
|
2249
|
+
{
|
|
2250
|
+
styleUniforms += "\n";
|
|
2251
|
+
styleUniforms += "uniform sampler3D gradients;\n";
|
|
2252
|
+
|
|
2253
|
+
styleFunctions += " if (length (texture (gradients, texCoord) .xyz * 2.0 - 1.0) < surfaceTolerance)\n";
|
|
2254
|
+
styleFunctions += " discard;\n";
|
|
2255
|
+
}
|
|
2256
|
+
else
|
|
2257
|
+
{
|
|
2258
|
+
styleUniforms += "\n";
|
|
2259
|
+
styleUniforms += "vec4\n";
|
|
2260
|
+
styleUniforms += "getNormal (in vec3 texCoord)\n";
|
|
2261
|
+
styleUniforms += "{\n";
|
|
2262
|
+
styleUniforms += " vec4 offset = vec4 (1.0 / x3d_TextureSize, 0.0);\n";
|
|
2263
|
+
styleUniforms += " float i0 = texture (x3d_Texture3D [0], texCoord + offset .xww) .r;\n";
|
|
2264
|
+
styleUniforms += " float i1 = texture (x3d_Texture3D [0], texCoord - offset .xww) .r;\n";
|
|
2265
|
+
styleUniforms += " float i2 = texture (x3d_Texture3D [0], texCoord + offset .wyw) .r;\n";
|
|
2266
|
+
styleUniforms += " float i3 = texture (x3d_Texture3D [0], texCoord - offset .wyw) .r;\n";
|
|
2267
|
+
styleUniforms += " float i4 = texture (x3d_Texture3D [0], texCoord + offset .wwz) .r;\n";
|
|
2268
|
+
styleUniforms += " float i5 = texture (x3d_Texture3D [0], texCoord - offset .wwz) .r;\n";
|
|
2269
|
+
styleUniforms += " vec3 n = vec3 (i1 - i0, i3 - i2, i5 - i4);\n";
|
|
2270
|
+
styleUniforms += "\n";
|
|
2271
|
+
styleUniforms += " return vec4 (normalize (x3d_TextureNormalMatrix * n), length (n));\n";
|
|
2272
|
+
styleUniforms += "}\n";
|
|
2273
|
+
|
|
2274
|
+
styleFunctions += " if (getNormal (texCoord) .w < surfaceTolerance)\n";
|
|
2275
|
+
styleFunctions += " discard;\n";
|
|
2276
|
+
}
|
|
2277
|
+
|
|
2278
|
+
styleFunctions += "\n";
|
|
2279
|
+
styleFunctions += " float intensity = textureColor .r;\n";
|
|
2280
|
+
styleFunctions += "\n";
|
|
2281
|
+
|
|
2282
|
+
if (this .surfaceValues_ .length === 1)
|
|
2283
|
+
{
|
|
2284
|
+
var contourStepSize = Math .abs (this .contourStepSize_ .getValue ());
|
|
2285
|
+
|
|
2286
|
+
if (contourStepSize === 0)
|
|
2287
|
+
{
|
|
2288
|
+
styleFunctions += " if (intensity > surfaceValues [0])\n";
|
|
2289
|
+
styleFunctions += " {\n";
|
|
2290
|
+
styleFunctions += " textureColor = vec4 (vec3 (surfaceValues [0]), 1.0);\n";
|
|
2291
|
+
|
|
2292
|
+
if (this .renderStyleNodes .length)
|
|
2293
|
+
{
|
|
2294
|
+
styleFunctions += this .renderStyleNodes [0] .getFunctionsText ();
|
|
2295
|
+
}
|
|
2296
|
+
|
|
2297
|
+
styleFunctions += " }\n";
|
|
2298
|
+
styleFunctions += " else\n";
|
|
2299
|
+
styleFunctions += " {\n";
|
|
2300
|
+
styleFunctions += " discard;\n";
|
|
2301
|
+
styleFunctions += " }\n";
|
|
2302
|
+
styleFunctions += "\n";
|
|
2303
|
+
}
|
|
2304
|
+
else
|
|
2305
|
+
{
|
|
2306
|
+
var surfaceValues = [ ];
|
|
2307
|
+
|
|
2308
|
+
for (var v = this .surfaceValues_ [0] - contourStepSize; v > 0; v -= contourStepSize)
|
|
2309
|
+
surfaceValues .unshift (v);
|
|
2310
|
+
|
|
2311
|
+
surfaceValues .push (this .surfaceValues_ [0]);
|
|
2312
|
+
|
|
2313
|
+
for (var v = this .surfaceValues_ [0] + contourStepSize; v < 1; v += contourStepSize)
|
|
2314
|
+
surfaceValues .push (v);
|
|
2315
|
+
|
|
2316
|
+
styleFunctions += " if (false)\n";
|
|
2317
|
+
styleFunctions += " { }\n";
|
|
2318
|
+
|
|
2319
|
+
for (var i = surfaceValues_ .length - 1; i >= 0; -- i)
|
|
2320
|
+
{
|
|
2321
|
+
styleFunctions += " else if (intensity > " + surfaceValues [i] + ")\n";
|
|
2322
|
+
styleFunctions += " {\n";
|
|
2323
|
+
styleFunctions += " textureColor = vec4 (vec3 (" + surfaceValues [i] + "), 1.0);\n";
|
|
2324
|
+
|
|
2325
|
+
if (this .renderStyleNodes .length)
|
|
2326
|
+
{
|
|
2327
|
+
styleFunctions += this .renderStyleNodes [0] .getFunctionsText ();
|
|
2328
|
+
}
|
|
2329
|
+
|
|
2330
|
+
styleFunctions += " }\n";
|
|
2331
|
+
}
|
|
2332
|
+
|
|
2333
|
+
styleFunctions += " else\n";
|
|
2334
|
+
styleFunctions += " {\n";
|
|
2335
|
+
styleFunctions += " discard;\n";
|
|
2336
|
+
styleFunctions += " }\n";
|
|
2337
|
+
styleFunctions += "\n";
|
|
2338
|
+
}
|
|
2339
|
+
}
|
|
2340
|
+
else
|
|
2341
|
+
{
|
|
2342
|
+
styleFunctions += " if (false)\n";
|
|
2343
|
+
styleFunctions += " { }\n";
|
|
2344
|
+
|
|
2345
|
+
for (var i = this .surfaceValues_ .length - 1; i >= 0; -- i)
|
|
2346
|
+
{
|
|
2347
|
+
styleFunctions += " else if (intensity > surfaceValues [" + i + "])\n";
|
|
2348
|
+
styleFunctions += " {\n";
|
|
2349
|
+
styleFunctions += " textureColor = vec4 (vec3 (surfaceValues [" + i + "]), 1.0);\n";
|
|
2350
|
+
|
|
2351
|
+
if (this .renderStyleNodes .length)
|
|
2352
|
+
{
|
|
2353
|
+
var r = Math .min (i, this .renderStyleNodes .length - 1);
|
|
2354
|
+
|
|
2355
|
+
styleFunctions += this .renderStyleNodes [r] .getFunctionsText ();
|
|
2356
|
+
}
|
|
2357
|
+
|
|
2358
|
+
styleFunctions += " }\n";
|
|
2359
|
+
}
|
|
2360
|
+
|
|
2361
|
+
styleFunctions += " else\n";
|
|
2362
|
+
styleFunctions += " {\n";
|
|
2363
|
+
styleFunctions += " discard;\n";
|
|
2364
|
+
styleFunctions += " }\n";
|
|
2365
|
+
styleFunctions += "\n";
|
|
2366
|
+
}
|
|
2367
|
+
|
|
2368
|
+
fs = fs .replace (/\/\/ VOLUME_STYLES_UNIFORMS\n/, styleUniforms);
|
|
2369
|
+
fs = fs .replace (/\/\/ VOLUME_STYLES_FUNCTIONS\n/, styleFunctions);
|
|
2370
|
+
|
|
2371
|
+
// if (DEBUG)
|
|
2372
|
+
// this .getBrowser () .print (fs);
|
|
2373
|
+
|
|
2374
|
+
var vertexShader = new ShaderPart (this .getExecutionContext ());
|
|
2375
|
+
vertexShader .setName ("VolumeDataVertexShader");
|
|
2376
|
+
vertexShader .url_ .push ("data:x-shader/x-vertex," + vs);
|
|
2377
|
+
vertexShader .setup ();
|
|
2378
|
+
|
|
2379
|
+
var fragmentShader = new ShaderPart (this .getExecutionContext ());
|
|
2380
|
+
fragmentShader .setName ("VolumeDataFragmentShader");
|
|
2381
|
+
fragmentShader .type_ = "FRAGMENT";
|
|
2382
|
+
fragmentShader .url_ .push ("data:x-shader/x-fragment," + fs);
|
|
2383
|
+
fragmentShader .setup ();
|
|
2384
|
+
|
|
2385
|
+
var shaderNode = new ComposedShader (this .getExecutionContext ());
|
|
2386
|
+
shaderNode .setName ("VolumeDataShader");
|
|
2387
|
+
shaderNode .language_ = "GLSL";
|
|
2388
|
+
shaderNode .parts_ .push (vertexShader);
|
|
2389
|
+
shaderNode .parts_ .push (fragmentShader);
|
|
2390
|
+
|
|
2391
|
+
shaderNode .addUserDefinedField (X3DConstants .inputOutput, "surfaceValues", this .surfaceValues_ .copy ());
|
|
2392
|
+
shaderNode .addUserDefinedField (X3DConstants .inputOutput, "surfaceTolerance", this .surfaceTolerance_ .copy ());
|
|
2393
|
+
|
|
2394
|
+
if (this .gradientsNode)
|
|
2395
|
+
shaderNode .addUserDefinedField (X3DConstants .inputOutput, "grandients", new Fields .SFNode (this .gradientsNode));
|
|
2396
|
+
|
|
2397
|
+
if (this .voxelsNode)
|
|
2398
|
+
{
|
|
2399
|
+
var textureSize = new Fields .SFVec3f (this .voxelsNode .getWidth (), this .voxelsNode .getHeight (), this .voxelsNode .getDepth ());
|
|
2400
|
+
|
|
2401
|
+
shaderNode .addUserDefinedField (X3DConstants .inputOutput, "x3d_TextureSize", textureSize);
|
|
2402
|
+
}
|
|
2403
|
+
else
|
|
2404
|
+
{
|
|
2405
|
+
shaderNode .addUserDefinedField (X3DConstants .inputOutput, "x3d_TextureSize", new Fields .SFVec3f ());
|
|
2406
|
+
}
|
|
2407
|
+
|
|
2408
|
+
opacityMapVolumeStyle .addShaderFields (shaderNode);
|
|
2409
|
+
|
|
2410
|
+
for (var i = 0, length = this .renderStyleNodes .length; i < length; ++ i)
|
|
2411
|
+
this .renderStyleNodes [i] .addShaderFields (shaderNode);
|
|
2412
|
+
|
|
2413
|
+
return shaderNode;
|
|
2414
|
+
},
|
|
2415
|
+
});
|
|
2416
|
+
|
|
2417
|
+
return IsoSurfaceVolumeData;
|
|
2418
|
+
});
|
|
2419
|
+
|
|
2420
|
+
/* -*- Mode: JavaScript; coding: utf-8; tab-width: 3; indent-tabs-mode: tab; c-basic-offset: 3 -*-
|
|
2421
|
+
*******************************************************************************
|
|
2422
|
+
*
|
|
2423
|
+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
2424
|
+
*
|
|
2425
|
+
* Copyright create3000, ScheffelstraÃe 31a, Leipzig, Germany 2011.
|
|
2426
|
+
*
|
|
2427
|
+
* All rights reserved. Holger Seelig <holger.seelig@yahoo.de>.
|
|
2428
|
+
*
|
|
2429
|
+
* The copyright notice above does not evidence any actual of intended
|
|
2430
|
+
* publication of such source code, and is an unpublished work by create3000.
|
|
2431
|
+
* This material contains CONFIDENTIAL INFORMATION that is the property of
|
|
2432
|
+
* create3000.
|
|
2433
|
+
*
|
|
2434
|
+
* No permission is granted to copy, distribute, or create derivative works from
|
|
2435
|
+
* the contents of this software, in whole or in part, without the prior written
|
|
2436
|
+
* permission of create3000.
|
|
2437
|
+
*
|
|
2438
|
+
* NON-MILITARY USE ONLY
|
|
2439
|
+
*
|
|
2440
|
+
* All create3000 software are effectively free software with a non-military use
|
|
2441
|
+
* restriction. It is free. Well commented source is provided. You may reuse the
|
|
2442
|
+
* source in any way you please with the exception anything that uses it must be
|
|
2443
|
+
* marked to indicate is contains 'non-military use only' components.
|
|
2444
|
+
*
|
|
2445
|
+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
2446
|
+
*
|
|
2447
|
+
* Copyright 2015, 2016 Holger Seelig <holger.seelig@yahoo.de>.
|
|
2448
|
+
*
|
|
2449
|
+
* This file is part of the X_ITE Project.
|
|
2450
|
+
*
|
|
2451
|
+
* X_ITE is free software: you can redistribute it and/or modify it under the
|
|
2452
|
+
* terms of the GNU General Public License version 3 only, as published by the
|
|
2453
|
+
* Free Software Foundation.
|
|
2454
|
+
*
|
|
2455
|
+
* X_ITE is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
2456
|
+
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
|
2457
|
+
* A PARTICULAR PURPOSE. See the GNU General Public License version 3 for more
|
|
2458
|
+
* details (a copy is included in the LICENSE file that accompanied this code).
|
|
2459
|
+
*
|
|
2460
|
+
* You should have received a copy of the GNU General Public License version 3
|
|
2461
|
+
* along with X_ITE. If not, see <http://www.gnu.org/licenses/gpl.html> for a
|
|
2462
|
+
* copy of the GPLv3 License.
|
|
2463
|
+
*
|
|
2464
|
+
* For Silvio, Joy and Adi.
|
|
2465
|
+
*
|
|
2466
|
+
******************************************************************************/
|
|
2467
|
+
|
|
2468
|
+
|
|
2469
|
+
define ('x_ite/Components/VolumeRendering/ProjectionVolumeStyle',[
|
|
2470
|
+
"x_ite/Fields",
|
|
2471
|
+
"x_ite/Basic/X3DFieldDefinition",
|
|
2472
|
+
"x_ite/Basic/FieldDefinitionArray",
|
|
2473
|
+
"x_ite/Components/VolumeRendering/X3DVolumeRenderStyleNode",
|
|
2474
|
+
"x_ite/Bits/X3DConstants",
|
|
2475
|
+
],
|
|
2476
|
+
function (Fields,
|
|
2477
|
+
X3DFieldDefinition,
|
|
2478
|
+
FieldDefinitionArray,
|
|
2479
|
+
X3DVolumeRenderStyleNode,
|
|
2480
|
+
X3DConstants)
|
|
2481
|
+
{
|
|
2482
|
+
"use strict";
|
|
2483
|
+
|
|
2484
|
+
function ProjectionVolumeStyle (executionContext)
|
|
2485
|
+
{
|
|
2486
|
+
X3DVolumeRenderStyleNode .call (this, executionContext);
|
|
2487
|
+
|
|
2488
|
+
this .addType (X3DConstants .ProjectionVolumeStyle);
|
|
2489
|
+
}
|
|
2490
|
+
|
|
2491
|
+
ProjectionVolumeStyle .prototype = Object .assign (Object .create (X3DVolumeRenderStyleNode .prototype),
|
|
2492
|
+
{
|
|
2493
|
+
constructor: ProjectionVolumeStyle,
|
|
2494
|
+
fieldDefinitions: new FieldDefinitionArray ([
|
|
2495
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "metadata", new Fields .SFNode ()),
|
|
2496
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "enabled", new Fields .SFBool (true)),
|
|
2497
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "type", new Fields .SFString ("MAX")),
|
|
2498
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "intensityThreshold", new Fields .SFFloat (0)),
|
|
2499
|
+
]),
|
|
2500
|
+
getTypeName: function ()
|
|
2501
|
+
{
|
|
2502
|
+
return "ProjectionVolumeStyle";
|
|
2503
|
+
},
|
|
2504
|
+
getComponentName: function ()
|
|
2505
|
+
{
|
|
2506
|
+
return "VolumeRendering";
|
|
2507
|
+
},
|
|
2508
|
+
getContainerField: function ()
|
|
2509
|
+
{
|
|
2510
|
+
return "renderStyle";
|
|
2511
|
+
},
|
|
2512
|
+
addShaderFields: function (shaderNode)
|
|
2513
|
+
{
|
|
2514
|
+
if (! this .enabled_ .getValue ())
|
|
2515
|
+
return;
|
|
2516
|
+
|
|
2517
|
+
shaderNode .addUserDefinedField (X3DConstants .inputOutput, "intensityThreshold_" + this .getId (), this .intensityThreshold_ .copy ());
|
|
2518
|
+
},
|
|
2519
|
+
getUniformsText: function ()
|
|
2520
|
+
{
|
|
2521
|
+
if (! this .enabled_ .getValue ())
|
|
2522
|
+
return "";
|
|
2523
|
+
|
|
2524
|
+
var string = "";
|
|
2525
|
+
|
|
2526
|
+
string += "\n";
|
|
2527
|
+
string += "// ProjectionVolumeStyle\n";
|
|
2528
|
+
string += "\n";
|
|
2529
|
+
string += "uniform float intensityThreshold_" + this .getId () + ";\n";
|
|
2530
|
+
|
|
2531
|
+
string += "\n";
|
|
2532
|
+
string += "vec4\n";
|
|
2533
|
+
string += "getProjectionStyle_" + this .getId () + "(in vec4 originalColor, in vec3 texCoord)\n";
|
|
2534
|
+
string += "{\n";
|
|
2535
|
+
switch (this .type_ .getValue ())
|
|
2536
|
+
{
|
|
2537
|
+
default:
|
|
2538
|
+
case "MAX":
|
|
2539
|
+
{
|
|
2540
|
+
string += " float projectionColor = 0.0;\n";
|
|
2541
|
+
break;
|
|
2542
|
+
}
|
|
2543
|
+
case "MIN":
|
|
2544
|
+
{
|
|
2545
|
+
string += " float projectionColor = 1.0;\n";
|
|
2546
|
+
break;
|
|
2547
|
+
}
|
|
2548
|
+
case "AVERAGE":
|
|
2549
|
+
{
|
|
2550
|
+
string += " float projectionColor = 0.0;\n";
|
|
2551
|
+
break;
|
|
2552
|
+
}
|
|
2553
|
+
}
|
|
2554
|
+
|
|
2555
|
+
string += " const int samples = 32;\n";
|
|
2556
|
+
string += " vec3 step = normalize (x3d_TextureNormalMatrix * vec3 (0.0, 0.0, 1.0)) / float (samples);\n";
|
|
2557
|
+
string += " vec3 ray = texCoord - step * float (samples) * 0.5;\n";
|
|
2558
|
+
string += " bool first = false;\n";
|
|
2559
|
+
string += "\n";
|
|
2560
|
+
string += " for (int i = 0; i < samples; ++ i, ray += step)\n";
|
|
2561
|
+
string += " {\n";
|
|
2562
|
+
string += " if (ray .s < 0.0 || ray .s > 1.0)\n";
|
|
2563
|
+
string += " continue;\n";
|
|
2564
|
+
string += "\n";
|
|
2565
|
+
string += " if (ray .t < 0.0 || ray .t > 1.0)\n";
|
|
2566
|
+
string += " continue;\n";
|
|
2567
|
+
string += "\n";
|
|
2568
|
+
string += " if (ray .p < 0.0 || ray .p > 1.0)\n";
|
|
2569
|
+
string += " continue;\n";
|
|
2570
|
+
string += "\n";
|
|
2571
|
+
string += " float intensity = texture (x3d_Texture3D [0], ray) .r;\n";
|
|
2572
|
+
string += "\n";
|
|
2573
|
+
|
|
2574
|
+
switch (this .type_ .getValue ())
|
|
2575
|
+
{
|
|
2576
|
+
default:
|
|
2577
|
+
case "MAX":
|
|
2578
|
+
{
|
|
2579
|
+
string += " if (intensity < intensityThreshold_" + this .getId () + ")\n";
|
|
2580
|
+
string += " continue;\n";
|
|
2581
|
+
string += "\n";
|
|
2582
|
+
string += " if (intensityThreshold_" + this .getId () + " > 0.0 && first)\n";
|
|
2583
|
+
string += " break;\n";
|
|
2584
|
+
string += "\n";
|
|
2585
|
+
string += " if (intensity <= projectionColor)\n";
|
|
2586
|
+
string += " {\n";
|
|
2587
|
+
string += " first = true;\n";
|
|
2588
|
+
string += " continue;\n";
|
|
2589
|
+
string += " }\n";
|
|
2590
|
+
string += "\n";
|
|
2591
|
+
string += " projectionColor = intensity;\n";
|
|
2592
|
+
break;
|
|
2593
|
+
}
|
|
2594
|
+
case "MIN":
|
|
2595
|
+
{
|
|
2596
|
+
string += " if (intensity < intensityThreshold_" + this .getId () + ")\n";
|
|
2597
|
+
string += " continue;\n";
|
|
2598
|
+
string += "\n";
|
|
2599
|
+
string += " if (intensityThreshold_" + this .getId () + " > 0.0 && first)\n";
|
|
2600
|
+
string += " break;\n";
|
|
2601
|
+
string += "\n";
|
|
2602
|
+
string += " if (intensity >= projectionColor)\n";
|
|
2603
|
+
string += " {\n";
|
|
2604
|
+
string += " first = true;\n";
|
|
2605
|
+
string += " continue;\n";
|
|
2606
|
+
string += " }\n";
|
|
2607
|
+
string += "\n";
|
|
2608
|
+
string += " projectionColor = intensity;\n";
|
|
2609
|
+
break;
|
|
2610
|
+
}
|
|
2611
|
+
case "AVERAGE":
|
|
2612
|
+
{
|
|
2613
|
+
string += " projectionColor += intensity;\n";
|
|
2614
|
+
break;
|
|
2615
|
+
}
|
|
2616
|
+
}
|
|
2617
|
+
|
|
2618
|
+
string += " }\n";
|
|
2619
|
+
string += "\n";
|
|
2620
|
+
|
|
2621
|
+
if (this .type_ .getValue () === "AVERAGE")
|
|
2622
|
+
string += " projectionColor /= float (samples);\n";
|
|
2623
|
+
|
|
2624
|
+
string += " return vec4 (vec3 (projectionColor), originalColor .a);\n";
|
|
2625
|
+
string += "}\n";
|
|
2626
|
+
|
|
2627
|
+
return string;
|
|
2628
|
+
},
|
|
2629
|
+
getFunctionsText: function ()
|
|
2630
|
+
{
|
|
2631
|
+
if (! this .enabled_ .getValue ())
|
|
2632
|
+
return "";
|
|
2633
|
+
|
|
2634
|
+
var string = "";
|
|
2635
|
+
|
|
2636
|
+
string += "\n";
|
|
2637
|
+
string += " // ProjectionVolumeStyle\n";
|
|
2638
|
+
string += "\n";
|
|
2639
|
+
string += " textureColor = getProjectionStyle_" + this .getId () + " (textureColor, texCoord);\n";
|
|
2640
|
+
|
|
2641
|
+
return string;
|
|
2642
|
+
},
|
|
2643
|
+
});
|
|
2644
|
+
|
|
2645
|
+
return ProjectionVolumeStyle;
|
|
2646
|
+
});
|
|
2647
|
+
|
|
2648
|
+
/* -*- Mode: JavaScript; coding: utf-8; tab-width: 3; indent-tabs-mode: tab; c-basic-offset: 3 -*-
|
|
2649
|
+
*******************************************************************************
|
|
2650
|
+
*
|
|
2651
|
+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
2652
|
+
*
|
|
2653
|
+
* Copyright create3000, ScheffelstraÃe 31a, Leipzig, Germany 2011.
|
|
2654
|
+
*
|
|
2655
|
+
* All rights reserved. Holger Seelig <holger.seelig@yahoo.de>.
|
|
2656
|
+
*
|
|
2657
|
+
* The copyright notice above does not evidence any actual of intended
|
|
2658
|
+
* publication of such source code, and is an unpublished work by create3000.
|
|
2659
|
+
* This material contains CONFIDENTIAL INFORMATION that is the property of
|
|
2660
|
+
* create3000.
|
|
2661
|
+
*
|
|
2662
|
+
* No permission is granted to copy, distribute, or create derivative works from
|
|
2663
|
+
* the contents of this software, in whole or in part, without the prior written
|
|
2664
|
+
* permission of create3000.
|
|
2665
|
+
*
|
|
2666
|
+
* NON-MILITARY USE ONLY
|
|
2667
|
+
*
|
|
2668
|
+
* All create3000 software are effectively free software with a non-military use
|
|
2669
|
+
* restriction. It is free. Well commented source is provided. You may reuse the
|
|
2670
|
+
* source in any way you please with the exception anything that uses it must be
|
|
2671
|
+
* marked to indicate is contains 'non-military use only' components.
|
|
2672
|
+
*
|
|
2673
|
+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
2674
|
+
*
|
|
2675
|
+
* Copyright 2015, 2016 Holger Seelig <holger.seelig@yahoo.de>.
|
|
2676
|
+
*
|
|
2677
|
+
* This file is part of the X_ITE Project.
|
|
2678
|
+
*
|
|
2679
|
+
* X_ITE is free software: you can redistribute it and/or modify it under the
|
|
2680
|
+
* terms of the GNU General Public License version 3 only, as published by the
|
|
2681
|
+
* Free Software Foundation.
|
|
2682
|
+
*
|
|
2683
|
+
* X_ITE is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
2684
|
+
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
|
2685
|
+
* A PARTICULAR PURPOSE. See the GNU General Public License version 3 for more
|
|
2686
|
+
* details (a copy is included in the LICENSE file that accompanied this code).
|
|
2687
|
+
*
|
|
2688
|
+
* You should have received a copy of the GNU General Public License version 3
|
|
2689
|
+
* along with X_ITE. If not, see <http://www.gnu.org/licenses/gpl.html> for a
|
|
2690
|
+
* copy of the GPLv3 License.
|
|
2691
|
+
*
|
|
2692
|
+
* For Silvio, Joy and Adi.
|
|
2693
|
+
*
|
|
2694
|
+
******************************************************************************/
|
|
2695
|
+
|
|
2696
|
+
|
|
2697
|
+
define ('x_ite/Components/VolumeRendering/SegmentedVolumeData',[
|
|
2698
|
+
"x_ite/Fields",
|
|
2699
|
+
"x_ite/Basic/X3DFieldDefinition",
|
|
2700
|
+
"x_ite/Basic/FieldDefinitionArray",
|
|
2701
|
+
"x_ite/Components/VolumeRendering/X3DVolumeDataNode",
|
|
2702
|
+
"x_ite/Components/Shaders/ComposedShader",
|
|
2703
|
+
"x_ite/Components/Shaders/ShaderPart",
|
|
2704
|
+
"x_ite/Bits/X3DConstants",
|
|
2705
|
+
"x_ite/Bits/X3DCast",
|
|
2706
|
+
"text!x_ite/Browser/VolumeRendering/VolumeStyle.vs",
|
|
2707
|
+
"text!x_ite/Browser/VolumeRendering/VolumeStyle.fs",
|
|
2708
|
+
"x_ite/DEBUG",
|
|
2709
|
+
],
|
|
2710
|
+
function (Fields,
|
|
2711
|
+
X3DFieldDefinition,
|
|
2712
|
+
FieldDefinitionArray,
|
|
2713
|
+
X3DVolumeDataNode,
|
|
2714
|
+
ComposedShader,
|
|
2715
|
+
ShaderPart,
|
|
2716
|
+
X3DConstants,
|
|
2717
|
+
X3DCast,
|
|
2718
|
+
vs,
|
|
2719
|
+
fs,
|
|
2720
|
+
DEBUG)
|
|
2721
|
+
{
|
|
2722
|
+
"use strict";
|
|
2723
|
+
|
|
2724
|
+
function SegmentedVolumeData (executionContext)
|
|
2725
|
+
{
|
|
2726
|
+
X3DVolumeDataNode .call (this, executionContext);
|
|
2727
|
+
|
|
2728
|
+
this .addType (X3DConstants .SegmentedVolumeData);
|
|
2729
|
+
|
|
2730
|
+
this .segmentIdentifiersNode = null;
|
|
2731
|
+
this .renderStyleNodes = [ ];
|
|
2732
|
+
}
|
|
2733
|
+
|
|
2734
|
+
SegmentedVolumeData .prototype = Object .assign (Object .create (X3DVolumeDataNode .prototype),
|
|
2735
|
+
{
|
|
2736
|
+
constructor: SegmentedVolumeData,
|
|
2737
|
+
fieldDefinitions: new FieldDefinitionArray ([
|
|
2738
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "metadata", new Fields .SFNode ()),
|
|
2739
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "dimensions", new Fields .SFVec3f (1, 1, 1)),
|
|
2740
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "segmentEnabled", new Fields .MFBool ()),
|
|
2741
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "visible", new Fields .SFBool (true)),
|
|
2742
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "bboxDisplay", new Fields .SFBool ()),
|
|
2743
|
+
new X3DFieldDefinition (X3DConstants .initializeOnly, "bboxCenter", new Fields .SFVec3f (0, 0, 0)),
|
|
2744
|
+
new X3DFieldDefinition (X3DConstants .initializeOnly, "bboxSize", new Fields .SFVec3f (-1, -1, -1)),
|
|
2745
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "segmentIdentifiers", new Fields .SFNode ()),
|
|
2746
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "renderStyle", new Fields .MFNode ()),
|
|
2747
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "voxels", new Fields .SFNode ()),
|
|
2748
|
+
]),
|
|
2749
|
+
getTypeName: function ()
|
|
2750
|
+
{
|
|
2751
|
+
return "SegmentedVolumeData";
|
|
2752
|
+
},
|
|
2753
|
+
getComponentName: function ()
|
|
2754
|
+
{
|
|
2755
|
+
return "VolumeRendering";
|
|
2756
|
+
},
|
|
2757
|
+
getContainerField: function ()
|
|
2758
|
+
{
|
|
2759
|
+
return "children";
|
|
2760
|
+
},
|
|
2761
|
+
initialize: function ()
|
|
2762
|
+
{
|
|
2763
|
+
X3DVolumeDataNode .prototype .initialize .call (this);
|
|
2764
|
+
|
|
2765
|
+
var gl = this .getBrowser () .getContext ();
|
|
2766
|
+
|
|
2767
|
+
if (gl .getVersion () < 2)
|
|
2768
|
+
return;
|
|
2769
|
+
|
|
2770
|
+
this .segmentIdentifiers_ .addInterest ("set_segmentIdentifiers__", this);
|
|
2771
|
+
this .renderStyle_ .addInterest ("set_renderStyle__", this);
|
|
2772
|
+
this .voxels_ .addFieldInterest (this .getAppearance () .texture_);
|
|
2773
|
+
|
|
2774
|
+
this .segmentEnabled_ .addInterest ("update", this);
|
|
2775
|
+
this .segmentIdentifiers_ .addInterest ("update", this);
|
|
2776
|
+
this .renderStyle_ .addInterest ("update", this);
|
|
2777
|
+
|
|
2778
|
+
this .getAppearance () .texture_ = this .voxels_;
|
|
2779
|
+
|
|
2780
|
+
this .set_segmentIdentifiers__ ();
|
|
2781
|
+
this .set_renderStyle__ ();
|
|
2782
|
+
this .set_voxels__ ();
|
|
2783
|
+
|
|
2784
|
+
this .update ();
|
|
2785
|
+
},
|
|
2786
|
+
getSegmentEnabled: function (index)
|
|
2787
|
+
{
|
|
2788
|
+
return index < this .segmentEnabled_ .length ? this .segmentEnabled_ [index] : true;
|
|
2789
|
+
},
|
|
2790
|
+
set_segmentIdentifiers__: function ()
|
|
2791
|
+
{
|
|
2792
|
+
this .segmentIdentifiersNode = X3DCast (X3DConstants .X3DTexture3DNode, this .segmentIdentifiers_);
|
|
2793
|
+
},
|
|
2794
|
+
set_renderStyle__: function ()
|
|
2795
|
+
{
|
|
2796
|
+
var renderStyleNodes = this .renderStyleNodes;
|
|
2797
|
+
|
|
2798
|
+
for (var i = 0, length = renderStyleNodes .length; i < length; ++ i)
|
|
2799
|
+
{
|
|
2800
|
+
var renderStyleNode = renderStyleNodes [i];
|
|
2801
|
+
|
|
2802
|
+
renderStyleNode .removeInterest ("update", this);
|
|
2803
|
+
renderStyleNode .removeVolumeData (this);
|
|
2804
|
+
}
|
|
2805
|
+
|
|
2806
|
+
renderStyleNodes .length = 0;
|
|
2807
|
+
|
|
2808
|
+
for (var i = 0, length = this .renderStyle_ .length; i < length; ++ i)
|
|
2809
|
+
{
|
|
2810
|
+
var renderStyleNode = X3DCast (X3DConstants .X3DComposableVolumeRenderStyleNode, this .renderStyle_ [i]);
|
|
2811
|
+
|
|
2812
|
+
if (renderStyleNode)
|
|
2813
|
+
renderStyleNodes .push (renderStyleNode);
|
|
2814
|
+
}
|
|
2815
|
+
|
|
2816
|
+
for (var i = 0, length = renderStyleNodes .length; i < length; ++ i)
|
|
2817
|
+
{
|
|
2818
|
+
var renderStyleNode = renderStyleNodes [i];
|
|
2819
|
+
|
|
2820
|
+
renderStyleNode .addInterest ("update", this);
|
|
2821
|
+
renderStyleNode .addVolumeData (this);
|
|
2822
|
+
}
|
|
2823
|
+
},
|
|
2824
|
+
set_voxels__: function ()
|
|
2825
|
+
{
|
|
2826
|
+
if (this .voxelsNode)
|
|
2827
|
+
this .voxelsNode .removeInterest ("set_textureSize__", this);
|
|
2828
|
+
|
|
2829
|
+
this .voxelsNode = X3DCast (X3DConstants .X3DTexture3DNode, this .voxels_);
|
|
2830
|
+
|
|
2831
|
+
if (this .voxelsNode)
|
|
2832
|
+
{
|
|
2833
|
+
this .voxelsNode .addInterest ("set_textureSize__", this);
|
|
2834
|
+
|
|
2835
|
+
this .set_textureSize__ ();
|
|
2836
|
+
}
|
|
2837
|
+
},
|
|
2838
|
+
set_textureSize__: function ()
|
|
2839
|
+
{
|
|
2840
|
+
try
|
|
2841
|
+
{
|
|
2842
|
+
var textureSize = this .getShader () .getField ("x3d_TextureSize");
|
|
2843
|
+
|
|
2844
|
+
textureSize .x = this .voxelsNode .getWidth ();
|
|
2845
|
+
textureSize .y = this .voxelsNode .getHeight ();
|
|
2846
|
+
textureSize .z = this .voxelsNode .getDepth ();
|
|
2847
|
+
}
|
|
2848
|
+
catch (error)
|
|
2849
|
+
{
|
|
2850
|
+
if (DEBUG)
|
|
2851
|
+
console .log (error .message);
|
|
2852
|
+
}
|
|
2853
|
+
},
|
|
2854
|
+
update: function ()
|
|
2855
|
+
{
|
|
2856
|
+
this .setShader (this .createShader (vs, fs));
|
|
2857
|
+
},
|
|
2858
|
+
createShader: function (vs, fs)
|
|
2859
|
+
{
|
|
2860
|
+
// if (DEBUG)
|
|
2861
|
+
// console .log ("Creating SegmentedVolumeData Shader ...");
|
|
2862
|
+
|
|
2863
|
+
var
|
|
2864
|
+
opacityMapVolumeStyle = this .getBrowser () .getDefaultVolumeStyle (),
|
|
2865
|
+
styleUniforms = opacityMapVolumeStyle .getUniformsText (),
|
|
2866
|
+
styleFunctions = opacityMapVolumeStyle .getFunctionsText ();
|
|
2867
|
+
|
|
2868
|
+
if (this .segmentIdentifiersNode)
|
|
2869
|
+
{
|
|
2870
|
+
styleUniforms += "\n";
|
|
2871
|
+
styleUniforms += "uniform sampler3D segmentIdentifiers;\n";
|
|
2872
|
+
styleFunctions += "\n";
|
|
2873
|
+
|
|
2874
|
+
styleFunctions += "\n";
|
|
2875
|
+
styleFunctions += " int segment = int (texture (segmentIdentifiers, texCoord) .r * 255.0);\n";
|
|
2876
|
+
}
|
|
2877
|
+
else
|
|
2878
|
+
{
|
|
2879
|
+
styleFunctions += " int segment = 0;\n";
|
|
2880
|
+
}
|
|
2881
|
+
|
|
2882
|
+
if (this .renderStyleNodes .length)
|
|
2883
|
+
{
|
|
2884
|
+
styleFunctions += "\n";
|
|
2885
|
+
styleFunctions += " switch (segment)\n";
|
|
2886
|
+
styleFunctions += " {\n";
|
|
2887
|
+
|
|
2888
|
+
for (var i = 0, length = this .renderStyleNodes .length; i < length; ++ i)
|
|
2889
|
+
{
|
|
2890
|
+
styleFunctions += " case " + i + ":\n";
|
|
2891
|
+
styleFunctions += " {\n";
|
|
2892
|
+
|
|
2893
|
+
if (this .getSegmentEnabled (i))
|
|
2894
|
+
{
|
|
2895
|
+
styleUniforms += this .renderStyleNodes [i] .getUniformsText (),
|
|
2896
|
+
styleFunctions += this .renderStyleNodes [i] .getFunctionsText ();
|
|
2897
|
+
styleFunctions += " break;\n";
|
|
2898
|
+
}
|
|
2899
|
+
else
|
|
2900
|
+
{
|
|
2901
|
+
styleFunctions += " discard;\n";
|
|
2902
|
+
}
|
|
2903
|
+
|
|
2904
|
+
styleFunctions += " }\n";
|
|
2905
|
+
}
|
|
2906
|
+
|
|
2907
|
+
styleFunctions += " }\n";
|
|
2908
|
+
}
|
|
2909
|
+
|
|
2910
|
+
fs = fs .replace (/\/\/ VOLUME_STYLES_UNIFORMS\n/, styleUniforms);
|
|
2911
|
+
fs = fs .replace (/\/\/ VOLUME_STYLES_FUNCTIONS\n/, styleFunctions);
|
|
2912
|
+
|
|
2913
|
+
// if (DEBUG)
|
|
2914
|
+
// this .getBrowser () .print (fs);
|
|
2915
|
+
|
|
2916
|
+
var vertexShader = new ShaderPart (this .getExecutionContext ());
|
|
2917
|
+
vertexShader .setName ("SegmentedVolumeDataVertexShader");
|
|
2918
|
+
vertexShader .url_ .push ("data:x-shader/x-vertex," + vs);
|
|
2919
|
+
vertexShader .setup ();
|
|
2920
|
+
|
|
2921
|
+
var fragmentShader = new ShaderPart (this .getExecutionContext ());
|
|
2922
|
+
fragmentShader .setName ("SegmentedVolumeDataFragmentShader");
|
|
2923
|
+
fragmentShader .type_ = "FRAGMENT";
|
|
2924
|
+
fragmentShader .url_ .push ("data:x-shader/x-fragment," + fs);
|
|
2925
|
+
fragmentShader .setup ();
|
|
2926
|
+
|
|
2927
|
+
var shaderNode = new ComposedShader (this .getExecutionContext ());
|
|
2928
|
+
shaderNode .setName ("SegmentedVolumeDataShader");
|
|
2929
|
+
shaderNode .language_ = "GLSL";
|
|
2930
|
+
shaderNode .parts_ .push (vertexShader);
|
|
2931
|
+
shaderNode .parts_ .push (fragmentShader);
|
|
2932
|
+
|
|
2933
|
+
if (this .voxelsNode)
|
|
2934
|
+
{
|
|
2935
|
+
var textureSize = new Fields .SFVec3f (this .voxelsNode .getWidth (), this .voxelsNode .getHeight (), this .voxelsNode .getDepth ());
|
|
2936
|
+
|
|
2937
|
+
shaderNode .addUserDefinedField (X3DConstants .inputOutput, "x3d_TextureSize", textureSize);
|
|
2938
|
+
}
|
|
2939
|
+
else
|
|
2940
|
+
{
|
|
2941
|
+
shaderNode .addUserDefinedField (X3DConstants .inputOutput, "x3d_TextureSize", new Fields .SFVec3f ());
|
|
2942
|
+
}
|
|
2943
|
+
|
|
2944
|
+
if (this .segmentIdentifiersNode)
|
|
2945
|
+
shaderNode .addUserDefinedField (X3DConstants .inputOutput, "segmentIdentifiers", new Fields .SFNode (this .segmentIdentifiersNode));
|
|
2946
|
+
|
|
2947
|
+
opacityMapVolumeStyle .addShaderFields (shaderNode);
|
|
2948
|
+
|
|
2949
|
+
for (var i = 0, length = this .renderStyleNodes .length; i < length; ++ i)
|
|
2950
|
+
{
|
|
2951
|
+
if (this .getSegmentEnabled (i))
|
|
2952
|
+
this .renderStyleNodes [i] .addShaderFields (shaderNode);
|
|
2953
|
+
}
|
|
2954
|
+
|
|
2955
|
+
return shaderNode;
|
|
2956
|
+
},
|
|
2957
|
+
});
|
|
2958
|
+
|
|
2959
|
+
return SegmentedVolumeData;
|
|
2960
|
+
});
|
|
2961
|
+
|
|
2962
|
+
/* -*- Mode: JavaScript; coding: utf-8; tab-width: 3; indent-tabs-mode: tab; c-basic-offset: 3 -*-
|
|
2963
|
+
*******************************************************************************
|
|
2964
|
+
*
|
|
2965
|
+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
2966
|
+
*
|
|
2967
|
+
* Copyright create3000, ScheffelstraÃe 31a, Leipzig, Germany 2011.
|
|
2968
|
+
*
|
|
2969
|
+
* All rights reserved. Holger Seelig <holger.seelig@yahoo.de>.
|
|
2970
|
+
*
|
|
2971
|
+
* The copyright notice above does not evidence any actual of intended
|
|
2972
|
+
* publication of such source code, and is an unpublished work by create3000.
|
|
2973
|
+
* This material contains CONFIDENTIAL INFORMATION that is the property of
|
|
2974
|
+
* create3000.
|
|
2975
|
+
*
|
|
2976
|
+
* No permission is granted to copy, distribute, or create derivative works from
|
|
2977
|
+
* the contents of this software, in whole or in part, without the prior written
|
|
2978
|
+
* permission of create3000.
|
|
2979
|
+
*
|
|
2980
|
+
* NON-MILITARY USE ONLY
|
|
2981
|
+
*
|
|
2982
|
+
* All create3000 software are effectively free software with a non-military use
|
|
2983
|
+
* restriction. It is free. Well commented source is provided. You may reuse the
|
|
2984
|
+
* source in any way you please with the exception anything that uses it must be
|
|
2985
|
+
* marked to indicate is contains 'non-military use only' components.
|
|
2986
|
+
*
|
|
2987
|
+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
2988
|
+
*
|
|
2989
|
+
* Copyright 2015, 2016 Holger Seelig <holger.seelig@yahoo.de>.
|
|
2990
|
+
*
|
|
2991
|
+
* This file is part of the X_ITE Project.
|
|
2992
|
+
*
|
|
2993
|
+
* X_ITE is free software: you can redistribute it and/or modify it under the
|
|
2994
|
+
* terms of the GNU General Public License version 3 only, as published by the
|
|
2995
|
+
* Free Software Foundation.
|
|
2996
|
+
*
|
|
2997
|
+
* X_ITE is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
2998
|
+
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
|
2999
|
+
* A PARTICULAR PURPOSE. See the GNU General Public License version 3 for more
|
|
3000
|
+
* details (a copy is included in the LICENSE file that accompanied this code).
|
|
3001
|
+
*
|
|
3002
|
+
* You should have received a copy of the GNU General Public License version 3
|
|
3003
|
+
* along with X_ITE. If not, see <http://www.gnu.org/licenses/gpl.html> for a
|
|
3004
|
+
* copy of the GPLv3 License.
|
|
3005
|
+
*
|
|
3006
|
+
* For Silvio, Joy and Adi.
|
|
3007
|
+
*
|
|
3008
|
+
******************************************************************************/
|
|
3009
|
+
|
|
3010
|
+
|
|
3011
|
+
define ('x_ite/Components/VolumeRendering/ShadedVolumeStyle',[
|
|
3012
|
+
"x_ite/Fields",
|
|
3013
|
+
"x_ite/Basic/X3DFieldDefinition",
|
|
3014
|
+
"x_ite/Basic/FieldDefinitionArray",
|
|
3015
|
+
"x_ite/Components/VolumeRendering/X3DComposableVolumeRenderStyleNode",
|
|
3016
|
+
"x_ite/Bits/X3DConstants",
|
|
3017
|
+
"x_ite/Bits/X3DCast",
|
|
3018
|
+
],
|
|
3019
|
+
function (Fields,
|
|
3020
|
+
X3DFieldDefinition,
|
|
3021
|
+
FieldDefinitionArray,
|
|
3022
|
+
X3DComposableVolumeRenderStyleNode,
|
|
3023
|
+
X3DConstants,
|
|
3024
|
+
X3DCast)
|
|
3025
|
+
{
|
|
3026
|
+
"use strict";
|
|
3027
|
+
|
|
3028
|
+
function ShadedVolumeStyle (executionContext)
|
|
3029
|
+
{
|
|
3030
|
+
X3DComposableVolumeRenderStyleNode .call (this, executionContext);
|
|
3031
|
+
|
|
3032
|
+
this .addType (X3DConstants .ShadedVolumeStyle);
|
|
3033
|
+
}
|
|
3034
|
+
|
|
3035
|
+
ShadedVolumeStyle .prototype = Object .assign (Object .create (X3DComposableVolumeRenderStyleNode .prototype),
|
|
3036
|
+
{
|
|
3037
|
+
constructor: ShadedVolumeStyle,
|
|
3038
|
+
fieldDefinitions: new FieldDefinitionArray ([
|
|
3039
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "metadata", new Fields .SFNode ()),
|
|
3040
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "enabled", new Fields .SFBool (true)),
|
|
3041
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "lighting", new Fields .SFBool ()),
|
|
3042
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "shadows", new Fields .SFBool ()),
|
|
3043
|
+
new X3DFieldDefinition (X3DConstants .initializeOnly, "phaseFunction", new Fields .SFString ("Henyey-Greenstein")),
|
|
3044
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "material", new Fields .SFNode ()),
|
|
3045
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "surfaceNormals", new Fields .SFNode ()),
|
|
3046
|
+
]),
|
|
3047
|
+
getTypeName: function ()
|
|
3048
|
+
{
|
|
3049
|
+
return "ShadedVolumeStyle";
|
|
3050
|
+
},
|
|
3051
|
+
getComponentName: function ()
|
|
3052
|
+
{
|
|
3053
|
+
return "VolumeRendering";
|
|
3054
|
+
},
|
|
3055
|
+
getContainerField: function ()
|
|
3056
|
+
{
|
|
3057
|
+
return "renderStyle";
|
|
3058
|
+
},
|
|
3059
|
+
initialize: function ()
|
|
3060
|
+
{
|
|
3061
|
+
X3DComposableVolumeRenderStyleNode .prototype .initialize .call (this);
|
|
3062
|
+
|
|
3063
|
+
var gl = this .getBrowser () .getContext ();
|
|
3064
|
+
|
|
3065
|
+
if (gl .getVersion () < 2)
|
|
3066
|
+
return;
|
|
3067
|
+
|
|
3068
|
+
this .material_ .addInterest ("set_material__", this);
|
|
3069
|
+
this .surfaceNormals_ .addInterest ("set_surfaceNormals__", this);
|
|
3070
|
+
|
|
3071
|
+
this .set_material__ ();
|
|
3072
|
+
this .set_surfaceNormals__ ();
|
|
3073
|
+
},
|
|
3074
|
+
set_material__: function ()
|
|
3075
|
+
{
|
|
3076
|
+
if (this .materialNode)
|
|
3077
|
+
this .materialNode .removeInterest ("addNodeEvent", this);
|
|
3078
|
+
|
|
3079
|
+
this .materialNode = X3DCast (X3DConstants .X3DMaterialNode, this .material_);
|
|
3080
|
+
|
|
3081
|
+
if (this .materialNode)
|
|
3082
|
+
this .materialNode .addInterest ("addNodeEvent", this);
|
|
3083
|
+
},
|
|
3084
|
+
set_surfaceNormals__: function ()
|
|
3085
|
+
{
|
|
3086
|
+
this .surfaceNormalsNode = X3DCast (X3DConstants .X3DTexture3DNode, this .surfaceNormals_);
|
|
3087
|
+
},
|
|
3088
|
+
addShaderFields: function (shaderNode)
|
|
3089
|
+
{
|
|
3090
|
+
if (! this .enabled_ .getValue ())
|
|
3091
|
+
return;
|
|
3092
|
+
|
|
3093
|
+
if (this .materialNode)
|
|
3094
|
+
{
|
|
3095
|
+
shaderNode .addUserDefinedField (X3DConstants .inputOutput, "ambientIntensity_" + this .getId (), this .materialNode .ambientIntensity_ .copy ());
|
|
3096
|
+
shaderNode .addUserDefinedField (X3DConstants .inputOutput, "diffuseColor_" + this .getId (), this .materialNode .diffuseColor_ .copy ());
|
|
3097
|
+
shaderNode .addUserDefinedField (X3DConstants .inputOutput, "specularColor_" + this .getId (), this .materialNode .specularColor_ .copy ());
|
|
3098
|
+
shaderNode .addUserDefinedField (X3DConstants .inputOutput, "emissiveColor_" + this .getId (), this .materialNode .emissiveColor_ .copy ());
|
|
3099
|
+
shaderNode .addUserDefinedField (X3DConstants .inputOutput, "shininess_" + this .getId (), this .materialNode .shininess_ .copy ());
|
|
3100
|
+
shaderNode .addUserDefinedField (X3DConstants .inputOutput, "transparency_" + this .getId (), this .materialNode .transparency_ .copy ());
|
|
3101
|
+
}
|
|
3102
|
+
|
|
3103
|
+
if (this .surfaceNormalsNode)
|
|
3104
|
+
shaderNode .addUserDefinedField (X3DConstants .inputOutput, "surfaceNormals_" + this .getId (), new Fields .SFNode (this .surfaceNormalsNode));
|
|
3105
|
+
},
|
|
3106
|
+
getUniformsText: function ()
|
|
3107
|
+
{
|
|
3108
|
+
if (! this .enabled_ .getValue ())
|
|
3109
|
+
return "";
|
|
3110
|
+
|
|
3111
|
+
var string = "";
|
|
3112
|
+
|
|
3113
|
+
string += "\n";
|
|
3114
|
+
string += "// ShadedVolumeStyle\n";
|
|
3115
|
+
string += "\n";
|
|
3116
|
+
string += "uniform float ambientIntensity_" + this .getId () + ";\n";
|
|
3117
|
+
string += "uniform vec3 diffuseColor_" + this .getId () + ";\n";
|
|
3118
|
+
string += "uniform vec3 specularColor_" + this .getId () + ";\n";
|
|
3119
|
+
string += "uniform vec3 emissiveColor_" + this .getId () + ";\n";
|
|
3120
|
+
string += "uniform float shininess_" + this .getId () + ";\n";
|
|
3121
|
+
string += "uniform float transparency_" + this .getId () + ";\n";
|
|
3122
|
+
|
|
3123
|
+
string += this .getNormalText (this .surfaceNormalsNode);
|
|
3124
|
+
|
|
3125
|
+
string += "\n";
|
|
3126
|
+
string += "float\n";
|
|
3127
|
+
string += "getSpotFactor_" + this .getId () + " (const in float cutOffAngle, const in float beamWidth, const in vec3 L, const in vec3 d)\n";
|
|
3128
|
+
string += "{\n";
|
|
3129
|
+
string += " float spotAngle = acos (clamp (dot (-L, d), -1.0, 1.0));\n";
|
|
3130
|
+
string += "\n";
|
|
3131
|
+
string += " if (spotAngle >= cutOffAngle)\n";
|
|
3132
|
+
string += " return 0.0;\n";
|
|
3133
|
+
string += " else if (spotAngle <= beamWidth)\n";
|
|
3134
|
+
string += " return 1.0;\n";
|
|
3135
|
+
string += "\n";
|
|
3136
|
+
string += " return (spotAngle - cutOffAngle) / (beamWidth - cutOffAngle);\n";
|
|
3137
|
+
string += "}\n";
|
|
3138
|
+
|
|
3139
|
+
string += "\n";
|
|
3140
|
+
string += "vec4\n";
|
|
3141
|
+
string += "getShadedStyle_" + this .getId () + " (in vec4 originalColor, in vec3 texCoord)\n";
|
|
3142
|
+
string += "{\n";
|
|
3143
|
+
string += " vec4 surfaceNormal = getNormal_" + this .getId () + " (texCoord);\n";
|
|
3144
|
+
string += "\n";
|
|
3145
|
+
string += " if (surfaceNormal .w == 0.0)\n";
|
|
3146
|
+
string += " return vec4 (0.0);\n";
|
|
3147
|
+
string += "\n";
|
|
3148
|
+
string += " vec4 shadedColor = vec4 (0.0);\n";
|
|
3149
|
+
|
|
3150
|
+
if (this .lighting_ .getValue ())
|
|
3151
|
+
{
|
|
3152
|
+
if (this .materialNode)
|
|
3153
|
+
{
|
|
3154
|
+
string += " vec3 diffuseFactor = diffuseColor_" + this .getId () + ";\n";
|
|
3155
|
+
string += " vec3 ambientTerm = diffuseFactor * ambientIntensity_" + this .getId () + ";\n";
|
|
3156
|
+
string += "\n";
|
|
3157
|
+
string += " shadedColor .a = originalColor .a * (1.0 - transparency_" + this .getId () + ");\n";
|
|
3158
|
+
}
|
|
3159
|
+
else
|
|
3160
|
+
{
|
|
3161
|
+
string += " vec3 diffuseFactor = originalColor .rgb;\n";
|
|
3162
|
+
string += " vec3 ambientTerm = vec3 (0.0);\n";
|
|
3163
|
+
string += "\n";
|
|
3164
|
+
string += " shadedColor .a = originalColor .a;\n";
|
|
3165
|
+
}
|
|
3166
|
+
|
|
3167
|
+
string += "\n";
|
|
3168
|
+
string += " vec3 N = surfaceNormal .xyz;\n";
|
|
3169
|
+
string += " vec3 V = normalize (-vertex); // normalized vector from point on geometry to viewer's position\n";
|
|
3170
|
+
string += "\n";
|
|
3171
|
+
string += " for (int i = 0; i < x3d_MaxLights; ++ i)\n";
|
|
3172
|
+
string += " {\n";
|
|
3173
|
+
string += " if (i == x3d_NumLights)\n";
|
|
3174
|
+
string += " break;\n";
|
|
3175
|
+
string += "\n";
|
|
3176
|
+
string += " x3d_LightSourceParameters light = x3d_LightSource [i];\n";
|
|
3177
|
+
string += "\n";
|
|
3178
|
+
string += " vec3 vL = light .location - vertex; // Light to fragment\n";
|
|
3179
|
+
string += " float dL = length (light .matrix * vL);\n";
|
|
3180
|
+
string += " bool di = light .type == x3d_DirectionalLight;\n";
|
|
3181
|
+
string += "\n";
|
|
3182
|
+
string += " if (di || dL <= light .radius)\n";
|
|
3183
|
+
string += " {\n";
|
|
3184
|
+
string += " vec3 d = light .direction;\n";
|
|
3185
|
+
string += " vec3 c = light .attenuation;\n";
|
|
3186
|
+
string += " vec3 L = di ? -d : normalize (vL); // Normalized vector from point on geometry to light source i position.\n";
|
|
3187
|
+
string += " vec3 H = normalize (L + V); // Specular term\n";
|
|
3188
|
+
string += "\n";
|
|
3189
|
+
string += " float lightAngle = max (dot (N, L), 0.0); // Angle between normal and light ray.\n";
|
|
3190
|
+
string += " vec3 diffuseTerm = diffuseFactor * lightAngle;\n";
|
|
3191
|
+
string += " float specularFactor = shininess_" + this .getId () + " > 0.0 ? pow (max (dot (N, H), 0.0), shininess_" + this .getId () + " * 128.0) : 1.0;\n";
|
|
3192
|
+
string += " vec3 specularTerm = light .intensity * specularColor_" + this .getId () + " * specularFactor;\n";
|
|
3193
|
+
string += "\n";
|
|
3194
|
+
string += " float attenuationFactor = di ? 1.0 : 1.0 / max (c [0] + c [1] * dL + c [2] * (dL * dL), 1.0);\n";
|
|
3195
|
+
string += " float spotFactor = light .type == x3d_SpotLight ? getSpotFactor_" + this .getId () + " (light .cutOffAngle, light .beamWidth, L, d) : 1.0;\n";
|
|
3196
|
+
string += " float attenuationSpotFactor = attenuationFactor * spotFactor;\n";
|
|
3197
|
+
string += " vec3 ambientColor = light .ambientIntensity * ambientTerm;\n";
|
|
3198
|
+
string += " vec3 diffuseSpecularColor = light .intensity * (diffuseTerm + specularTerm);\n";
|
|
3199
|
+
string += "\n";
|
|
3200
|
+
string += " shadedColor .rgb += attenuationSpotFactor * light .color * (ambientColor + diffuseSpecularColor);\n";
|
|
3201
|
+
string += " }\n";
|
|
3202
|
+
string += "\n";
|
|
3203
|
+
string += " shadedColor .rgb += emissiveColor_" + this .getId () + ";\n";
|
|
3204
|
+
string += " shadedColor .rgb = getFogColor (shadedColor .rgb);\n";
|
|
3205
|
+
string += " }\n";
|
|
3206
|
+
}
|
|
3207
|
+
else
|
|
3208
|
+
{
|
|
3209
|
+
if (this .materialNode)
|
|
3210
|
+
{
|
|
3211
|
+
string += " shadedColor .rgb = diffuseColor_" + this .getId () + ";\n";
|
|
3212
|
+
string += " shadedColor .a = originalColor .a * (1.0 - transparency_" + this .getId () + ");\n";
|
|
3213
|
+
}
|
|
3214
|
+
else
|
|
3215
|
+
{
|
|
3216
|
+
string += " shadedColor = originalColor;\n";
|
|
3217
|
+
}
|
|
3218
|
+
}
|
|
3219
|
+
|
|
3220
|
+
string += "\n";
|
|
3221
|
+
string += " return shadedColor;\n";
|
|
3222
|
+
string += "}\n";
|
|
3223
|
+
|
|
3224
|
+
return string;
|
|
3225
|
+
},
|
|
3226
|
+
getFunctionsText: function ()
|
|
3227
|
+
{
|
|
3228
|
+
if (! this .enabled_ .getValue ())
|
|
3229
|
+
return "";
|
|
3230
|
+
|
|
3231
|
+
var string = "";
|
|
3232
|
+
|
|
3233
|
+
string += "\n";
|
|
3234
|
+
string += " // ShadedVolumeStyle\n";
|
|
3235
|
+
string += "\n";
|
|
3236
|
+
string += " textureColor = getShadedStyle_" + this .getId () + " (textureColor, texCoord);\n";
|
|
3237
|
+
|
|
3238
|
+
return string;
|
|
3239
|
+
},
|
|
3240
|
+
});
|
|
3241
|
+
|
|
3242
|
+
return ShadedVolumeStyle;
|
|
3243
|
+
});
|
|
3244
|
+
|
|
3245
|
+
/* -*- Mode: JavaScript; coding: utf-8; tab-width: 3; indent-tabs-mode: tab; c-basic-offset: 3 -*-
|
|
3246
|
+
*******************************************************************************
|
|
3247
|
+
*
|
|
3248
|
+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
3249
|
+
*
|
|
3250
|
+
* Copyright create3000, ScheffelstraÃe 31a, Leipzig, Germany 2011.
|
|
3251
|
+
*
|
|
3252
|
+
* All rights reserved. Holger Seelig <holger.seelig@yahoo.de>.
|
|
3253
|
+
*
|
|
3254
|
+
* The copyright notice above does not evidence any actual of intended
|
|
3255
|
+
* publication of such source code, and is an unpublished work by create3000.
|
|
3256
|
+
* This material contains CONFIDENTIAL INFORMATION that is the property of
|
|
3257
|
+
* create3000.
|
|
3258
|
+
*
|
|
3259
|
+
* No permission is granted to copy, distribute, or create derivative works from
|
|
3260
|
+
* the contents of this software, in whole or in part, without the prior written
|
|
3261
|
+
* permission of create3000.
|
|
3262
|
+
*
|
|
3263
|
+
* NON-MILITARY USE ONLY
|
|
3264
|
+
*
|
|
3265
|
+
* All create3000 software are effectively free software with a non-military use
|
|
3266
|
+
* restriction. It is free. Well commented source is provided. You may reuse the
|
|
3267
|
+
* source in any way you please with the exception anything that uses it must be
|
|
3268
|
+
* marked to indicate is contains 'non-military use only' components.
|
|
3269
|
+
*
|
|
3270
|
+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
3271
|
+
*
|
|
3272
|
+
* Copyright 2015, 2016 Holger Seelig <holger.seelig@yahoo.de>.
|
|
3273
|
+
*
|
|
3274
|
+
* This file is part of the X_ITE Project.
|
|
3275
|
+
*
|
|
3276
|
+
* X_ITE is free software: you can redistribute it and/or modify it under the
|
|
3277
|
+
* terms of the GNU General Public License version 3 only, as published by the
|
|
3278
|
+
* Free Software Foundation.
|
|
3279
|
+
*
|
|
3280
|
+
* X_ITE is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
3281
|
+
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
|
3282
|
+
* A PARTICULAR PURPOSE. See the GNU General Public License version 3 for more
|
|
3283
|
+
* details (a copy is included in the LICENSE file that accompanied this code).
|
|
3284
|
+
*
|
|
3285
|
+
* You should have received a copy of the GNU General Public License version 3
|
|
3286
|
+
* along with X_ITE. If not, see <http://www.gnu.org/licenses/gpl.html> for a
|
|
3287
|
+
* copy of the GPLv3 License.
|
|
3288
|
+
*
|
|
3289
|
+
* For Silvio, Joy and Adi.
|
|
3290
|
+
*
|
|
3291
|
+
******************************************************************************/
|
|
3292
|
+
|
|
3293
|
+
|
|
3294
|
+
define ('x_ite/Components/VolumeRendering/SilhouetteEnhancementVolumeStyle',[
|
|
3295
|
+
"x_ite/Fields",
|
|
3296
|
+
"x_ite/Basic/X3DFieldDefinition",
|
|
3297
|
+
"x_ite/Basic/FieldDefinitionArray",
|
|
3298
|
+
"x_ite/Components/VolumeRendering/X3DComposableVolumeRenderStyleNode",
|
|
3299
|
+
"x_ite/Bits/X3DConstants",
|
|
3300
|
+
"x_ite/Bits/X3DCast",
|
|
3301
|
+
],
|
|
3302
|
+
function (Fields,
|
|
3303
|
+
X3DFieldDefinition,
|
|
3304
|
+
FieldDefinitionArray,
|
|
3305
|
+
X3DComposableVolumeRenderStyleNode,
|
|
3306
|
+
X3DConstants,
|
|
3307
|
+
X3DCast)
|
|
3308
|
+
{
|
|
3309
|
+
"use strict";
|
|
3310
|
+
|
|
3311
|
+
function SilhouetteEnhancementVolumeStyle (executionContext)
|
|
3312
|
+
{
|
|
3313
|
+
X3DComposableVolumeRenderStyleNode .call (this, executionContext);
|
|
3314
|
+
|
|
3315
|
+
this .addType (X3DConstants .SilhouetteEnhancementVolumeStyle);
|
|
3316
|
+
}
|
|
3317
|
+
|
|
3318
|
+
SilhouetteEnhancementVolumeStyle .prototype = Object .assign (Object .create (X3DComposableVolumeRenderStyleNode .prototype),
|
|
3319
|
+
{
|
|
3320
|
+
constructor: SilhouetteEnhancementVolumeStyle,
|
|
3321
|
+
fieldDefinitions: new FieldDefinitionArray ([
|
|
3322
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "metadata", new Fields .SFNode ()),
|
|
3323
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "enabled", new Fields .SFBool (true)),
|
|
3324
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "silhouetteRetainedOpacity", new Fields .SFFloat (1)),
|
|
3325
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "silhouetteBoundaryOpacity", new Fields .SFFloat (0)),
|
|
3326
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "silhouetteSharpness", new Fields .SFFloat (0.5)),
|
|
3327
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "surfaceNormals", new Fields .SFNode ()),
|
|
3328
|
+
]),
|
|
3329
|
+
getTypeName: function ()
|
|
3330
|
+
{
|
|
3331
|
+
return "SilhouetteEnhancementVolumeStyle";
|
|
3332
|
+
},
|
|
3333
|
+
getComponentName: function ()
|
|
3334
|
+
{
|
|
3335
|
+
return "VolumeRendering";
|
|
3336
|
+
},
|
|
3337
|
+
getContainerField: function ()
|
|
3338
|
+
{
|
|
3339
|
+
return "renderStyle";
|
|
3340
|
+
},
|
|
3341
|
+
initialize: function ()
|
|
3342
|
+
{
|
|
3343
|
+
X3DComposableVolumeRenderStyleNode .prototype .initialize .call (this);
|
|
3344
|
+
|
|
3345
|
+
var gl = this .getBrowser () .getContext ();
|
|
3346
|
+
|
|
3347
|
+
if (gl .getVersion () < 2)
|
|
3348
|
+
return;
|
|
3349
|
+
|
|
3350
|
+
this .surfaceNormals_ .addInterest ("set_surfaceNormals__", this);
|
|
3351
|
+
|
|
3352
|
+
this .set_surfaceNormals__ ();
|
|
3353
|
+
},
|
|
3354
|
+
set_surfaceNormals__: function ()
|
|
3355
|
+
{
|
|
3356
|
+
this .surfaceNormalsNode = X3DCast (X3DConstants .X3DTexture3DNode, this .surfaceNormals_);
|
|
3357
|
+
},
|
|
3358
|
+
addShaderFields: function (shaderNode)
|
|
3359
|
+
{
|
|
3360
|
+
if (! this .enabled_ .getValue ())
|
|
3361
|
+
return;
|
|
3362
|
+
|
|
3363
|
+
shaderNode .addUserDefinedField (X3DConstants .inputOutput, "silhouetteRetainedOpacity_" + this .getId (), this .silhouetteRetainedOpacity_ .copy ());
|
|
3364
|
+
shaderNode .addUserDefinedField (X3DConstants .inputOutput, "silhouetteBoundaryOpacity_" + this .getId (), this .silhouetteBoundaryOpacity_ .copy ());
|
|
3365
|
+
shaderNode .addUserDefinedField (X3DConstants .inputOutput, "silhouetteSharpness_" + this .getId (), this .silhouetteSharpness_ .copy ());
|
|
3366
|
+
|
|
3367
|
+
if (this .surfaceNormalsNode)
|
|
3368
|
+
shaderNode .addUserDefinedField (X3DConstants .inputOutput, "surfaceNormals_" + this .getId (), new Fields .SFNode (this .surfaceNormalsNode));
|
|
3369
|
+
},
|
|
3370
|
+
getUniformsText: function ()
|
|
3371
|
+
{
|
|
3372
|
+
if (! this .enabled_ .getValue ())
|
|
3373
|
+
return "";
|
|
3374
|
+
|
|
3375
|
+
var string = "";
|
|
3376
|
+
|
|
3377
|
+
string += "\n";
|
|
3378
|
+
string += "// SilhouetteEnhancementVolumeStyle\n";
|
|
3379
|
+
string += "\n";
|
|
3380
|
+
string += "uniform float silhouetteRetainedOpacity_" + this .getId () + ";\n";
|
|
3381
|
+
string += "uniform float silhouetteBoundaryOpacity_" + this .getId () + ";\n";
|
|
3382
|
+
string += "uniform float silhouetteSharpness_" + this .getId () + ";\n";
|
|
3383
|
+
|
|
3384
|
+
string += this .getNormalText (this .surfaceNormalsNode);
|
|
3385
|
+
|
|
3386
|
+
string += "\n";
|
|
3387
|
+
string += "vec4\n";
|
|
3388
|
+
string += "getSilhouetteEnhancementStyle_" + this .getId () + " (in vec4 originalColor, in vec3 texCoord)\n";
|
|
3389
|
+
string += "{\n";
|
|
3390
|
+
string += " vec4 surfaceNormal = getNormal_" + this .getId () + " (texCoord);\n";
|
|
3391
|
+
string += "\n";
|
|
3392
|
+
string += " if (surfaceNormal .w == 0.0)\n";
|
|
3393
|
+
string += " return vec4 (0.0);\n";
|
|
3394
|
+
string += " \n";
|
|
3395
|
+
string += " float silhouetteRetainedOpacity = silhouetteRetainedOpacity_" + this .getId () + ";\n";
|
|
3396
|
+
string += " float silhouetteBoundaryOpacity = silhouetteBoundaryOpacity_" + this .getId () + ";\n";
|
|
3397
|
+
string += " float silhouetteSharpness = silhouetteSharpness_" + this .getId () + ";\n";
|
|
3398
|
+
string += "\n";
|
|
3399
|
+
string += " return vec4 (originalColor .rgb, originalColor .a * (silhouetteRetainedOpacity + silhouetteBoundaryOpacity * pow (1.0 - abs (dot (surfaceNormal .xyz, normalize (vertex))), silhouetteSharpness)));\n";
|
|
3400
|
+
string += "}\n";
|
|
3401
|
+
|
|
3402
|
+
return string;
|
|
3403
|
+
},
|
|
3404
|
+
getFunctionsText: function ()
|
|
3405
|
+
{
|
|
3406
|
+
if (! this .enabled_ .getValue ())
|
|
3407
|
+
return "";
|
|
3408
|
+
|
|
3409
|
+
var string = "";
|
|
3410
|
+
|
|
3411
|
+
string += "\n";
|
|
3412
|
+
string += " // SilhouetteEnhancementVolumeStyle\n";
|
|
3413
|
+
string += "\n";
|
|
3414
|
+
string += " textureColor = getSilhouetteEnhancementStyle_" + this .getId () + " (textureColor, texCoord);\n";
|
|
3415
|
+
|
|
3416
|
+
return string;
|
|
3417
|
+
},
|
|
3418
|
+
});
|
|
3419
|
+
|
|
3420
|
+
return SilhouetteEnhancementVolumeStyle;
|
|
3421
|
+
});
|
|
3422
|
+
|
|
3423
|
+
/* -*- Mode: JavaScript; coding: utf-8; tab-width: 3; indent-tabs-mode: tab; c-basic-offset: 3 -*-
|
|
3424
|
+
*******************************************************************************
|
|
3425
|
+
*
|
|
3426
|
+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
3427
|
+
*
|
|
3428
|
+
* Copyright create3000, ScheffelstraÃe 31a, Leipzig, Germany 2011.
|
|
3429
|
+
*
|
|
3430
|
+
* All rights reserved. Holger Seelig <holger.seelig@yahoo.de>.
|
|
3431
|
+
*
|
|
3432
|
+
* The copyright notice above does not evidence any actual of intended
|
|
3433
|
+
* publication of such source code, and is an unpublished work by create3000.
|
|
3434
|
+
* This material contains CONFIDENTIAL INFORMATION that is the property of
|
|
3435
|
+
* create3000.
|
|
3436
|
+
*
|
|
3437
|
+
* No permission is granted to copy, distribute, or create derivative works from
|
|
3438
|
+
* the contents of this software, in whole or in part, without the prior written
|
|
3439
|
+
* permission of create3000.
|
|
3440
|
+
*
|
|
3441
|
+
* NON-MILITARY USE ONLY
|
|
3442
|
+
*
|
|
3443
|
+
* All create3000 software are effectively free software with a non-military use
|
|
3444
|
+
* restriction. It is free. Well commented source is provided. You may reuse the
|
|
3445
|
+
* source in any way you please with the exception anything that uses it must be
|
|
3446
|
+
* marked to indicate is contains 'non-military use only' components.
|
|
3447
|
+
*
|
|
3448
|
+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
3449
|
+
*
|
|
3450
|
+
* Copyright 2015, 2016 Holger Seelig <holger.seelig@yahoo.de>.
|
|
3451
|
+
*
|
|
3452
|
+
* This file is part of the X_ITE Project.
|
|
3453
|
+
*
|
|
3454
|
+
* X_ITE is free software: you can redistribute it and/or modify it under the
|
|
3455
|
+
* terms of the GNU General Public License version 3 only, as published by the
|
|
3456
|
+
* Free Software Foundation.
|
|
3457
|
+
*
|
|
3458
|
+
* X_ITE is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
3459
|
+
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
|
3460
|
+
* A PARTICULAR PURPOSE. See the GNU General Public License version 3 for more
|
|
3461
|
+
* details (a copy is included in the LICENSE file that accompanied this code).
|
|
3462
|
+
*
|
|
3463
|
+
* You should have received a copy of the GNU General Public License version 3
|
|
3464
|
+
* along with X_ITE. If not, see <http://www.gnu.org/licenses/gpl.html> for a
|
|
3465
|
+
* copy of the GPLv3 License.
|
|
3466
|
+
*
|
|
3467
|
+
* For Silvio, Joy and Adi.
|
|
3468
|
+
*
|
|
3469
|
+
******************************************************************************/
|
|
3470
|
+
|
|
3471
|
+
|
|
3472
|
+
define ('x_ite/Components/VolumeRendering/ToneMappedVolumeStyle',[
|
|
3473
|
+
"x_ite/Fields",
|
|
3474
|
+
"x_ite/Basic/X3DFieldDefinition",
|
|
3475
|
+
"x_ite/Basic/FieldDefinitionArray",
|
|
3476
|
+
"x_ite/Components/VolumeRendering/X3DComposableVolumeRenderStyleNode",
|
|
3477
|
+
"x_ite/Bits/X3DConstants",
|
|
3478
|
+
"x_ite/Bits/X3DCast",
|
|
3479
|
+
],
|
|
3480
|
+
function (Fields,
|
|
3481
|
+
X3DFieldDefinition,
|
|
3482
|
+
FieldDefinitionArray,
|
|
3483
|
+
X3DComposableVolumeRenderStyleNode,
|
|
3484
|
+
X3DConstants,
|
|
3485
|
+
X3DCast)
|
|
3486
|
+
{
|
|
3487
|
+
"use strict";
|
|
3488
|
+
|
|
3489
|
+
function ToneMappedVolumeStyle (executionContext)
|
|
3490
|
+
{
|
|
3491
|
+
X3DComposableVolumeRenderStyleNode .call (this, executionContext);
|
|
3492
|
+
|
|
3493
|
+
this .addType (X3DConstants .ToneMappedVolumeStyle);
|
|
3494
|
+
}
|
|
3495
|
+
|
|
3496
|
+
ToneMappedVolumeStyle .prototype = Object .assign (Object .create (X3DComposableVolumeRenderStyleNode .prototype),
|
|
3497
|
+
{
|
|
3498
|
+
constructor: ToneMappedVolumeStyle,
|
|
3499
|
+
fieldDefinitions: new FieldDefinitionArray ([
|
|
3500
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "metadata", new Fields .SFNode ()),
|
|
3501
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "enabled", new Fields .SFBool (true)),
|
|
3502
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "coolColor", new Fields .SFColorRGBA (0, 0, 1, 0)),
|
|
3503
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "warmColor", new Fields .SFColorRGBA (1, 1, 0, 0)),
|
|
3504
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "surfaceNormals", new Fields .SFNode ()),
|
|
3505
|
+
]),
|
|
3506
|
+
getTypeName: function ()
|
|
3507
|
+
{
|
|
3508
|
+
return "ToneMappedVolumeStyle";
|
|
3509
|
+
},
|
|
3510
|
+
getComponentName: function ()
|
|
3511
|
+
{
|
|
3512
|
+
return "VolumeRendering";
|
|
3513
|
+
},
|
|
3514
|
+
getContainerField: function ()
|
|
3515
|
+
{
|
|
3516
|
+
return "renderStyle";
|
|
3517
|
+
},
|
|
3518
|
+
initialize: function ()
|
|
3519
|
+
{
|
|
3520
|
+
X3DComposableVolumeRenderStyleNode .prototype .initialize .call (this);
|
|
3521
|
+
|
|
3522
|
+
var gl = this .getBrowser () .getContext ();
|
|
3523
|
+
|
|
3524
|
+
if (gl .getVersion () < 2)
|
|
3525
|
+
return;
|
|
3526
|
+
|
|
3527
|
+
this .surfaceNormals_ .addInterest ("set_surfaceNormals__", this);
|
|
3528
|
+
|
|
3529
|
+
this .set_surfaceNormals__ ();
|
|
3530
|
+
},
|
|
3531
|
+
set_surfaceNormals__: function ()
|
|
3532
|
+
{
|
|
3533
|
+
this .surfaceNormalsNode = X3DCast (X3DConstants .X3DTexture3DNode, this .surfaceNormals_);
|
|
3534
|
+
},
|
|
3535
|
+
addShaderFields: function (shaderNode)
|
|
3536
|
+
{
|
|
3537
|
+
if (! this .enabled_ .getValue ())
|
|
3538
|
+
return;
|
|
3539
|
+
|
|
3540
|
+
shaderNode .addUserDefinedField (X3DConstants .inputOutput, "coolColor_" + this .getId (), this .coolColor_ .copy ());
|
|
3541
|
+
shaderNode .addUserDefinedField (X3DConstants .inputOutput, "warmColor_" + this .getId (), this .warmColor_ .copy ());
|
|
3542
|
+
|
|
3543
|
+
if (this .surfaceNormalsNode)
|
|
3544
|
+
shaderNode .addUserDefinedField (X3DConstants .inputOutput, "surfaceNormals_" + this .getId (), new Fields .SFNode (this .surfaceNormalsNode));
|
|
3545
|
+
},
|
|
3546
|
+
getUniformsText: function ()
|
|
3547
|
+
{
|
|
3548
|
+
if (! this .enabled_ .getValue ())
|
|
3549
|
+
return "";
|
|
3550
|
+
|
|
3551
|
+
var string = "";
|
|
3552
|
+
|
|
3553
|
+
string += "\n";
|
|
3554
|
+
string += "// ToneMappedVolumeStyle\n";
|
|
3555
|
+
string += "\n";
|
|
3556
|
+
string += "uniform vec4 coolColor_" + this .getId () + ";\n";
|
|
3557
|
+
string += "uniform vec4 warmColor_" + this .getId () + ";\n";
|
|
3558
|
+
|
|
3559
|
+
string += this .getNormalText (this .surfaceNormalsNode);
|
|
3560
|
+
|
|
3561
|
+
string += "\n";
|
|
3562
|
+
string += "vec4\n";
|
|
3563
|
+
string += "getToneMappedStyle_" + this .getId () + " (in vec4 originalColor, in vec3 texCoord)\n";
|
|
3564
|
+
string += "{\n";
|
|
3565
|
+
string += " vec4 surfaceNormal = getNormal_" + this .getId () + " (texCoord);\n";
|
|
3566
|
+
string += "\n";
|
|
3567
|
+
string += " if (surfaceNormal .w == 0.0)\n";
|
|
3568
|
+
string += " return vec4 (0.0);\n";
|
|
3569
|
+
string += "\n";
|
|
3570
|
+
string += " vec3 toneColor = vec3 (0.0);\n";
|
|
3571
|
+
string += " vec3 coolColor = coolColor_" + this .getId () + " .rgb;\n";
|
|
3572
|
+
string += " vec3 warmColor = warmColor_" + this .getId () + " .rgb;\n";
|
|
3573
|
+
string += "\n";
|
|
3574
|
+
string += " for (int i = 0; i < x3d_MaxLights; ++ i)\n";
|
|
3575
|
+
string += " {\n";
|
|
3576
|
+
string += " if (i == x3d_NumLights)\n";
|
|
3577
|
+
string += " break;\n";
|
|
3578
|
+
string += "\n";
|
|
3579
|
+
string += " x3d_LightSourceParameters light = x3d_LightSource [i];\n";
|
|
3580
|
+
string += "\n";
|
|
3581
|
+
string += " vec3 L = light .type == x3d_DirectionalLight ? -light .direction : normalize (light .location - vertex);\n";
|
|
3582
|
+
string += " float colorFactor = (1.0 + dot (L, surfaceNormal .xyz)) * 0.5;\n";
|
|
3583
|
+
string += "\n";
|
|
3584
|
+
string += " toneColor += mix (warmColor .rgb, coolColor .rgb, colorFactor);\n";
|
|
3585
|
+
string += " }\n";
|
|
3586
|
+
string += "\n";
|
|
3587
|
+
string += " return vec4 (toneColor, originalColor .a);\n";
|
|
3588
|
+
string += "}\n";
|
|
3589
|
+
|
|
3590
|
+
return string;
|
|
3591
|
+
},
|
|
3592
|
+
getFunctionsText: function ()
|
|
3593
|
+
{
|
|
3594
|
+
if (! this .enabled_ .getValue ())
|
|
3595
|
+
return "";
|
|
3596
|
+
|
|
3597
|
+
var string = "";
|
|
3598
|
+
|
|
3599
|
+
string += "\n";
|
|
3600
|
+
string += " // ToneMappedVolumeStyle\n";
|
|
3601
|
+
string += "\n";
|
|
3602
|
+
string += " textureColor = getToneMappedStyle_" + this .getId () + " (textureColor, texCoord);\n";
|
|
3603
|
+
|
|
3604
|
+
return string;
|
|
3605
|
+
},
|
|
3606
|
+
});
|
|
3607
|
+
|
|
3608
|
+
return ToneMappedVolumeStyle;
|
|
3609
|
+
});
|
|
3610
|
+
|
|
3611
|
+
/* -*- Mode: JavaScript; coding: utf-8; tab-width: 3; indent-tabs-mode: tab; c-basic-offset: 3 -*-
|
|
3612
|
+
*******************************************************************************
|
|
3613
|
+
*
|
|
3614
|
+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
3615
|
+
*
|
|
3616
|
+
* Copyright create3000, ScheffelstraÃe 31a, Leipzig, Germany 2011.
|
|
3617
|
+
*
|
|
3618
|
+
* All rights reserved. Holger Seelig <holger.seelig@yahoo.de>.
|
|
3619
|
+
*
|
|
3620
|
+
* The copyright notice above does not evidence any actual of intended
|
|
3621
|
+
* publication of such source code, and is an unpublished work by create3000.
|
|
3622
|
+
* This material contains CONFIDENTIAL INFORMATION that is the property of
|
|
3623
|
+
* create3000.
|
|
3624
|
+
*
|
|
3625
|
+
* No permission is granted to copy, distribute, or create derivative works from
|
|
3626
|
+
* the contents of this software, in whole or in part, without the prior written
|
|
3627
|
+
* permission of create3000.
|
|
3628
|
+
*
|
|
3629
|
+
* NON-MILITARY USE ONLY
|
|
3630
|
+
*
|
|
3631
|
+
* All create3000 software are effectively free software with a non-military use
|
|
3632
|
+
* restriction. It is free. Well commented source is provided. You may reuse the
|
|
3633
|
+
* source in any way you please with the exception anything that uses it must be
|
|
3634
|
+
* marked to indicate is contains 'non-military use only' components.
|
|
3635
|
+
*
|
|
3636
|
+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
3637
|
+
*
|
|
3638
|
+
* Copyright 2015, 2016 Holger Seelig <holger.seelig@yahoo.de>.
|
|
3639
|
+
*
|
|
3640
|
+
* This file is part of the X_ITE Project.
|
|
3641
|
+
*
|
|
3642
|
+
* X_ITE is free software: you can redistribute it and/or modify it under the
|
|
3643
|
+
* terms of the GNU General Public License version 3 only, as published by the
|
|
3644
|
+
* Free Software Foundation.
|
|
3645
|
+
*
|
|
3646
|
+
* X_ITE is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
3647
|
+
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
|
3648
|
+
* A PARTICULAR PURPOSE. See the GNU General Public License version 3 for more
|
|
3649
|
+
* details (a copy is included in the LICENSE file that accompanied this code).
|
|
3650
|
+
*
|
|
3651
|
+
* You should have received a copy of the GNU General Public License version 3
|
|
3652
|
+
* along with X_ITE. If not, see <http://www.gnu.org/licenses/gpl.html> for a
|
|
3653
|
+
* copy of the GPLv3 License.
|
|
3654
|
+
*
|
|
3655
|
+
* For Silvio, Joy and Adi.
|
|
3656
|
+
*
|
|
3657
|
+
******************************************************************************/
|
|
3658
|
+
|
|
3659
|
+
|
|
3660
|
+
define ('x_ite/Components/VolumeRendering/VolumeData',[
|
|
3661
|
+
"x_ite/Fields",
|
|
3662
|
+
"x_ite/Basic/X3DFieldDefinition",
|
|
3663
|
+
"x_ite/Basic/FieldDefinitionArray",
|
|
3664
|
+
"x_ite/Components/VolumeRendering/X3DVolumeDataNode",
|
|
3665
|
+
"x_ite/Components/Shaders/ComposedShader",
|
|
3666
|
+
"x_ite/Components/Shaders/ShaderPart",
|
|
3667
|
+
"x_ite/Bits/X3DConstants",
|
|
3668
|
+
"x_ite/Bits/X3DCast",
|
|
3669
|
+
"text!x_ite/Browser/VolumeRendering/VolumeStyle.vs",
|
|
3670
|
+
"text!x_ite/Browser/VolumeRendering/VolumeStyle.fs",
|
|
3671
|
+
"x_ite/DEBUG",
|
|
3672
|
+
],
|
|
3673
|
+
function (Fields,
|
|
3674
|
+
X3DFieldDefinition,
|
|
3675
|
+
FieldDefinitionArray,
|
|
3676
|
+
X3DVolumeDataNode,
|
|
3677
|
+
ComposedShader,
|
|
3678
|
+
ShaderPart,
|
|
3679
|
+
X3DConstants,
|
|
3680
|
+
X3DCast,
|
|
3681
|
+
vs,
|
|
3682
|
+
fs,
|
|
3683
|
+
DEBUG)
|
|
3684
|
+
{
|
|
3685
|
+
"use strict";
|
|
3686
|
+
|
|
3687
|
+
function VolumeData (executionContext)
|
|
3688
|
+
{
|
|
3689
|
+
X3DVolumeDataNode .call (this, executionContext);
|
|
3690
|
+
|
|
3691
|
+
this .addType (X3DConstants .VolumeData);
|
|
3692
|
+
|
|
3693
|
+
this .renderStyleNode = null;
|
|
3694
|
+
}
|
|
3695
|
+
|
|
3696
|
+
VolumeData .prototype = Object .assign (Object .create (X3DVolumeDataNode .prototype),
|
|
3697
|
+
{
|
|
3698
|
+
constructor: VolumeData,
|
|
3699
|
+
fieldDefinitions: new FieldDefinitionArray ([
|
|
3700
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "metadata", new Fields .SFNode ()),
|
|
3701
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "dimensions", new Fields .SFVec3f (1, 1, 1)),
|
|
3702
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "visible", new Fields .SFBool (true)),
|
|
3703
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "bboxDisplay", new Fields .SFBool ()),
|
|
3704
|
+
new X3DFieldDefinition (X3DConstants .initializeOnly, "bboxCenter", new Fields .SFVec3f (0, 0, 0)),
|
|
3705
|
+
new X3DFieldDefinition (X3DConstants .initializeOnly, "bboxSize", new Fields .SFVec3f (-1, -1, -1)),
|
|
3706
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "renderStyle", new Fields .SFNode ()),
|
|
3707
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "voxels", new Fields .SFNode ()),
|
|
3708
|
+
]),
|
|
3709
|
+
getTypeName: function ()
|
|
3710
|
+
{
|
|
3711
|
+
return "VolumeData";
|
|
3712
|
+
},
|
|
3713
|
+
getComponentName: function ()
|
|
3714
|
+
{
|
|
3715
|
+
return "VolumeRendering";
|
|
3716
|
+
},
|
|
3717
|
+
getContainerField: function ()
|
|
3718
|
+
{
|
|
3719
|
+
return "children";
|
|
3720
|
+
},
|
|
3721
|
+
initialize: function ()
|
|
3722
|
+
{
|
|
3723
|
+
X3DVolumeDataNode .prototype .initialize .call (this);
|
|
3724
|
+
|
|
3725
|
+
var gl = this .getBrowser () .getContext ();
|
|
3726
|
+
|
|
3727
|
+
if (gl .getVersion () < 2)
|
|
3728
|
+
return;
|
|
3729
|
+
|
|
3730
|
+
this .renderStyle_ .addInterest ("set_renderStyle__", this);
|
|
3731
|
+
this .voxels_ .addInterest ("set_voxels__", this);
|
|
3732
|
+
this .voxels_ .addFieldInterest (this .getAppearance () .texture_);
|
|
3733
|
+
|
|
3734
|
+
this .renderStyle_ .addInterest ("update", this);
|
|
3735
|
+
|
|
3736
|
+
this .getAppearance () .texture_ = this .voxels_;
|
|
3737
|
+
|
|
3738
|
+
this .set_renderStyle__ ();
|
|
3739
|
+
this .set_voxels__ ();
|
|
3740
|
+
|
|
3741
|
+
this .update ();
|
|
3742
|
+
},
|
|
3743
|
+
set_renderStyle__: function ()
|
|
3744
|
+
{
|
|
3745
|
+
if (this .renderStyleNode)
|
|
3746
|
+
{
|
|
3747
|
+
this .renderStyleNode .removeInterest ("update", this);
|
|
3748
|
+
this .renderStyleNode .removeVolumeData (this);
|
|
3749
|
+
}
|
|
3750
|
+
|
|
3751
|
+
this .renderStyleNode = X3DCast (X3DConstants .X3DVolumeRenderStyleNode, this .renderStyle_);
|
|
3752
|
+
|
|
3753
|
+
if (this .renderStyleNode)
|
|
3754
|
+
{
|
|
3755
|
+
this .renderStyleNode .addInterest ("update", this);
|
|
3756
|
+
this .renderStyleNode .addVolumeData (this);
|
|
3757
|
+
}
|
|
3758
|
+
},
|
|
3759
|
+
set_voxels__: function ()
|
|
3760
|
+
{
|
|
3761
|
+
if (this .voxelsNode)
|
|
3762
|
+
this .voxelsNode .removeInterest ("set_textureSize__", this);
|
|
3763
|
+
|
|
3764
|
+
this .voxelsNode = X3DCast (X3DConstants .X3DTexture3DNode, this .voxels_);
|
|
3765
|
+
|
|
3766
|
+
if (this .voxelsNode)
|
|
3767
|
+
{
|
|
3768
|
+
this .voxelsNode .addInterest ("set_textureSize__", this);
|
|
3769
|
+
|
|
3770
|
+
this .set_textureSize__ ();
|
|
3771
|
+
}
|
|
3772
|
+
},
|
|
3773
|
+
set_textureSize__: function ()
|
|
3774
|
+
{
|
|
3775
|
+
try
|
|
3776
|
+
{
|
|
3777
|
+
var textureSize = this .getShader () .getField ("x3d_TextureSize");
|
|
3778
|
+
|
|
3779
|
+
textureSize .x = this .voxelsNode .getWidth ();
|
|
3780
|
+
textureSize .y = this .voxelsNode .getHeight ();
|
|
3781
|
+
textureSize .z = this .voxelsNode .getDepth ();
|
|
3782
|
+
}
|
|
3783
|
+
catch (error)
|
|
3784
|
+
{
|
|
3785
|
+
if (DEBUG)
|
|
3786
|
+
console .log (error .message);
|
|
3787
|
+
}
|
|
3788
|
+
},
|
|
3789
|
+
update: function ()
|
|
3790
|
+
{
|
|
3791
|
+
this .setShader (this .createShader (vs, fs));
|
|
3792
|
+
},
|
|
3793
|
+
createShader: function (vs, fs)
|
|
3794
|
+
{
|
|
3795
|
+
// if (DEBUG)
|
|
3796
|
+
// console .log ("Creating VolumeData Shader ...");
|
|
3797
|
+
|
|
3798
|
+
var
|
|
3799
|
+
opacityMapVolumeStyle = this .getBrowser () .getDefaultVolumeStyle (),
|
|
3800
|
+
styleUniforms = opacityMapVolumeStyle .getUniformsText (),
|
|
3801
|
+
styleFunctions = opacityMapVolumeStyle .getFunctionsText ();
|
|
3802
|
+
|
|
3803
|
+
if (this .renderStyleNode)
|
|
3804
|
+
{
|
|
3805
|
+
styleUniforms += this .renderStyleNode .getUniformsText (),
|
|
3806
|
+
styleFunctions += this .renderStyleNode .getFunctionsText ();
|
|
3807
|
+
}
|
|
3808
|
+
|
|
3809
|
+
fs = fs .replace (/\/\/ VOLUME_STYLES_UNIFORMS\n/, styleUniforms);
|
|
3810
|
+
fs = fs .replace (/\/\/ VOLUME_STYLES_FUNCTIONS\n/, styleFunctions);
|
|
3811
|
+
|
|
3812
|
+
// if (DEBUG)
|
|
3813
|
+
// this .getBrowser () .print (fs);
|
|
3814
|
+
|
|
3815
|
+
var vertexShader = new ShaderPart (this .getExecutionContext ());
|
|
3816
|
+
vertexShader .setName ("VolumeDataVertexShader");
|
|
3817
|
+
vertexShader .url_ .push ("data:x-shader/x-vertex," + vs);
|
|
3818
|
+
vertexShader .setup ();
|
|
3819
|
+
|
|
3820
|
+
var fragmentShader = new ShaderPart (this .getExecutionContext ());
|
|
3821
|
+
fragmentShader .setName ("VolumeDataFragmentShader");
|
|
3822
|
+
fragmentShader .type_ = "FRAGMENT";
|
|
3823
|
+
fragmentShader .url_ .push ("data:x-shader/x-fragment," + fs);
|
|
3824
|
+
fragmentShader .setup ();
|
|
3825
|
+
|
|
3826
|
+
var shaderNode = new ComposedShader (this .getExecutionContext ());
|
|
3827
|
+
shaderNode .setName ("VolumeDataShader");
|
|
3828
|
+
shaderNode .language_ = "GLSL";
|
|
3829
|
+
shaderNode .parts_ .push (vertexShader);
|
|
3830
|
+
shaderNode .parts_ .push (fragmentShader);
|
|
3831
|
+
|
|
3832
|
+
if (this .voxelsNode)
|
|
3833
|
+
{
|
|
3834
|
+
var textureSize = new Fields .SFVec3f (this .voxelsNode .getWidth (), this .voxelsNode .getHeight (), this .voxelsNode .getDepth ());
|
|
3835
|
+
|
|
3836
|
+
shaderNode .addUserDefinedField (X3DConstants .inputOutput, "x3d_TextureSize", textureSize);
|
|
3837
|
+
}
|
|
3838
|
+
else
|
|
3839
|
+
{
|
|
3840
|
+
shaderNode .addUserDefinedField (X3DConstants .inputOutput, "x3d_TextureSize", new Fields .SFVec3f ());
|
|
3841
|
+
}
|
|
3842
|
+
|
|
3843
|
+
opacityMapVolumeStyle .addShaderFields (shaderNode);
|
|
3844
|
+
|
|
3845
|
+
if (this .renderStyleNode)
|
|
3846
|
+
this .renderStyleNode .addShaderFields (shaderNode);
|
|
3847
|
+
|
|
3848
|
+
return shaderNode;
|
|
3849
|
+
},
|
|
3850
|
+
});
|
|
3851
|
+
|
|
3852
|
+
return VolumeData;
|
|
3853
|
+
});
|
|
3854
|
+
|
|
3855
|
+
/*******************************************************************************
|
|
3856
|
+
*
|
|
3857
|
+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
3858
|
+
*
|
|
3859
|
+
* Copyright create3000, Scheffelstraße 31a, Leipzig, Germany 2011.
|
|
3860
|
+
*
|
|
3861
|
+
* All rights reserved. Holger Seelig <holger.seelig@yahoo.de>.
|
|
3862
|
+
*
|
|
3863
|
+
* The copyright notice above does not evidence any actual of intended
|
|
3864
|
+
* publication of such source code, and is an unpublished work by create3000.
|
|
3865
|
+
* This material contains CONFIDENTIAL INFORMATION that is the property of
|
|
3866
|
+
* create3000.
|
|
3867
|
+
*
|
|
3868
|
+
* No permission is granted to copy, distribute, or create derivative works from
|
|
3869
|
+
* the contents of this software, in whole or in part, without the prior written
|
|
3870
|
+
* permission of create3000.
|
|
3871
|
+
*
|
|
3872
|
+
* NON-MILITARY USE ONLY
|
|
3873
|
+
*
|
|
3874
|
+
* All create3000 software are effectively free software with a non-military use
|
|
3875
|
+
* restriction. It is free. Well commented source is provided. You may reuse the
|
|
3876
|
+
* source in any way you please with the exception anything that uses it must be
|
|
3877
|
+
* marked to indicate is contains 'non-military use only' components.
|
|
3878
|
+
*
|
|
3879
|
+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
3880
|
+
*
|
|
3881
|
+
* Copyright 2015, 2016 Holger Seelig <holger.seelig@yahoo.de>.
|
|
3882
|
+
*
|
|
3883
|
+
* This file is part of the X_ITE Project.
|
|
3884
|
+
*
|
|
3885
|
+
* X_ITE is free software: you can redistribute it and/or modify it under the
|
|
3886
|
+
* terms of the GNU General Public License version 3 only, as published by the
|
|
3887
|
+
* Free Software Foundation.
|
|
3888
|
+
*
|
|
3889
|
+
* X_ITE is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
3890
|
+
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
|
3891
|
+
* A PARTICULAR PURPOSE. See the GNU General Public License version 3 for more
|
|
3892
|
+
* details (a copy is included in the LICENSE file that accompanied this code).
|
|
3893
|
+
*
|
|
3894
|
+
* You should have received a copy of the GNU General Public License version 3
|
|
3895
|
+
* along with X_ITE. If not, see <http://www.gnu.org/licenses/gpl.html> for a
|
|
3896
|
+
* copy of the GPLv3 License.
|
|
3897
|
+
*
|
|
3898
|
+
* For Silvio, Joy and Adi.
|
|
3899
|
+
*
|
|
3900
|
+
******************************************************************************/
|
|
3901
|
+
|
|
3902
|
+
|
|
3903
|
+
define (require .getComponentUrl ("volume-rendering"), [
|
|
3904
|
+
"x_ite/Components",
|
|
3905
|
+
"x_ite/Browser/VolumeRendering/X3DVolumeRenderingContext",
|
|
3906
|
+
"x_ite/Components/VolumeRendering/BlendedVolumeStyle",
|
|
3907
|
+
"x_ite/Components/VolumeRendering/BoundaryEnhancementVolumeStyle",
|
|
3908
|
+
"x_ite/Components/VolumeRendering/CartoonVolumeStyle",
|
|
3909
|
+
"x_ite/Components/VolumeRendering/ComposedVolumeStyle",
|
|
3910
|
+
"x_ite/Components/VolumeRendering/EdgeEnhancementVolumeStyle",
|
|
3911
|
+
"x_ite/Components/VolumeRendering/IsoSurfaceVolumeData",
|
|
3912
|
+
"x_ite/Components/VolumeRendering/OpacityMapVolumeStyle",
|
|
3913
|
+
"x_ite/Components/VolumeRendering/ProjectionVolumeStyle",
|
|
3914
|
+
"x_ite/Components/VolumeRendering/SegmentedVolumeData",
|
|
3915
|
+
"x_ite/Components/VolumeRendering/ShadedVolumeStyle",
|
|
3916
|
+
"x_ite/Components/VolumeRendering/SilhouetteEnhancementVolumeStyle",
|
|
3917
|
+
"x_ite/Components/VolumeRendering/ToneMappedVolumeStyle",
|
|
3918
|
+
"x_ite/Components/VolumeRendering/VolumeData",
|
|
3919
|
+
"x_ite/Components/VolumeRendering/X3DComposableVolumeRenderStyleNode",
|
|
3920
|
+
"x_ite/Components/VolumeRendering/X3DVolumeDataNode",
|
|
3921
|
+
"x_ite/Components/VolumeRendering/X3DVolumeRenderStyleNode",
|
|
3922
|
+
require .getComponentUrl ("cad-geometry"),
|
|
3923
|
+
require .getComponentUrl ("texturing-3d"),
|
|
3924
|
+
],
|
|
3925
|
+
function (Components,
|
|
3926
|
+
X3DVolumeRenderingContext,
|
|
3927
|
+
BlendedVolumeStyle,
|
|
3928
|
+
BoundaryEnhancementVolumeStyle,
|
|
3929
|
+
CartoonVolumeStyle,
|
|
3930
|
+
ComposedVolumeStyle,
|
|
3931
|
+
EdgeEnhancementVolumeStyle,
|
|
3932
|
+
IsoSurfaceVolumeData,
|
|
3933
|
+
OpacityMapVolumeStyle,
|
|
3934
|
+
ProjectionVolumeStyle,
|
|
3935
|
+
SegmentedVolumeData,
|
|
3936
|
+
ShadedVolumeStyle,
|
|
3937
|
+
SilhouetteEnhancementVolumeStyle,
|
|
3938
|
+
ToneMappedVolumeStyle,
|
|
3939
|
+
VolumeData,
|
|
3940
|
+
X3DComposableVolumeRenderStyleNode,
|
|
3941
|
+
X3DVolumeDataNode,
|
|
3942
|
+
X3DVolumeRenderStyleNode)
|
|
3943
|
+
{
|
|
3944
|
+
"use strict";
|
|
3945
|
+
|
|
3946
|
+
Components .addComponent ({
|
|
3947
|
+
name: "VolumeRendering",
|
|
3948
|
+
types:
|
|
3949
|
+
{
|
|
3950
|
+
BlendedVolumeStyle: BlendedVolumeStyle,
|
|
3951
|
+
BoundaryEnhancementVolumeStyle: BoundaryEnhancementVolumeStyle,
|
|
3952
|
+
CartoonVolumeStyle: CartoonVolumeStyle,
|
|
3953
|
+
ComposedVolumeStyle: ComposedVolumeStyle,
|
|
3954
|
+
EdgeEnhancementVolumeStyle: EdgeEnhancementVolumeStyle,
|
|
3955
|
+
IsoSurfaceVolumeData: IsoSurfaceVolumeData,
|
|
3956
|
+
OpacityMapVolumeStyle: OpacityMapVolumeStyle,
|
|
3957
|
+
ProjectionVolumeStyle: ProjectionVolumeStyle,
|
|
3958
|
+
SegmentedVolumeData: SegmentedVolumeData,
|
|
3959
|
+
ShadedVolumeStyle: ShadedVolumeStyle,
|
|
3960
|
+
SilhouetteEnhancementVolumeStyle: SilhouetteEnhancementVolumeStyle,
|
|
3961
|
+
ToneMappedVolumeStyle: ToneMappedVolumeStyle,
|
|
3962
|
+
VolumeData: VolumeData,
|
|
3963
|
+
},
|
|
3964
|
+
abstractTypes:
|
|
3965
|
+
{
|
|
3966
|
+
X3DComposableVolumeRenderStyleNode: X3DComposableVolumeRenderStyleNode,
|
|
3967
|
+
X3DVolumeDataNode: X3DVolumeDataNode,
|
|
3968
|
+
X3DVolumeRenderStyleNode: X3DVolumeRenderStyleNode,
|
|
3969
|
+
},
|
|
3970
|
+
browser: X3DVolumeRenderingContext,
|
|
3971
|
+
});
|
|
3972
|
+
});
|
|
3973
|
+
|
|
3974
|
+
|
|
3975
|
+
})
|
|
3976
|
+
(typeof module === "object" ? module : undefined, typeof require === "function" ? require : undefined);
|