viral-viewer-2 6.2.6 → 6.2.8
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/LICENSE +5 -52
- package/dist/components/animation/viral-animation.d.ts +9 -0
- package/dist/components/animation/viral-animation.js +71 -0
- package/dist/components/animation/viral-animation.js.map +1 -0
- package/dist/components/bvh/viral-bvh.d.ts +5 -0
- package/dist/components/bvh/viral-bvh.js +19 -0
- package/dist/components/bvh/viral-bvh.js.map +1 -0
- package/dist/components/camera/viral-camera.d.ts +40 -0
- package/dist/components/camera/viral-camera.js +207 -0
- package/dist/components/camera/viral-camera.js.map +1 -0
- package/dist/components/centralized-event-handler/viral-centralized-event-handler.d.ts +7 -0
- package/dist/components/centralized-event-handler/viral-centralized-event-handler.js +47 -0
- package/dist/components/centralized-event-handler/viral-centralized-event-handler.js.map +1 -0
- package/dist/components/compress/compress.processor.d.ts +4 -0
- package/dist/components/compress/compress.processor.js +29 -0
- package/dist/components/compress/compress.processor.js.map +1 -0
- package/dist/components/compress/viral-compress.processor.d.ts +3 -0
- package/dist/components/compress/viral-compress.processor.js +13 -0
- package/dist/components/compress/viral-compress.processor.js.map +1 -0
- package/dist/components/context-menu/viral-context-menu.d.ts +17 -0
- package/dist/components/context-menu/viral-context-menu.js +74 -0
- package/dist/components/context-menu/viral-context-menu.js.map +1 -0
- package/dist/components/custom-objects/index.d.ts +2 -0
- package/dist/components/custom-objects/index.js +6 -0
- package/dist/components/custom-objects/index.js.map +1 -0
- package/dist/components/custom-objects/viral-instanced-mesh.d.ts +31 -0
- package/dist/components/custom-objects/viral-instanced-mesh.js +203 -0
- package/dist/components/custom-objects/viral-instanced-mesh.js.map +1 -0
- package/dist/components/custom-objects/viral-mesh.d.ts +9 -0
- package/dist/components/custom-objects/viral-mesh.js +25 -0
- package/dist/components/custom-objects/viral-mesh.js.map +1 -0
- package/dist/components/data-manager/viral-data-manager.d.ts +18 -0
- package/dist/components/data-manager/viral-data-manager.js +35 -0
- package/dist/components/data-manager/viral-data-manager.js.map +1 -0
- package/dist/components/event-handler/base/event-dispatcher.d.ts +9 -0
- package/dist/components/event-handler/base/event-dispatcher.js +35 -0
- package/dist/components/event-handler/base/event-dispatcher.js.map +1 -0
- package/dist/components/event-handler/keyboard/viral-keyboard.d.ts +17 -0
- package/dist/components/event-handler/keyboard/viral-keyboard.js +78 -0
- package/dist/components/event-handler/keyboard/viral-keyboard.js.map +1 -0
- package/dist/components/event-handler/mouse/viral-mouse.d.ts +31 -0
- package/dist/components/event-handler/mouse/viral-mouse.js +239 -0
- package/dist/components/event-handler/mouse/viral-mouse.js.map +1 -0
- package/dist/components/event-handler/viral-centralized-event-handler.d.ts +14 -0
- package/dist/components/event-handler/viral-centralized-event-handler.js +186 -0
- package/dist/components/event-handler/viral-centralized-event-handler.js.map +1 -0
- package/dist/components/event-handler/viral-lifecycle-event-handler.d.ts +13 -0
- package/dist/components/event-handler/viral-lifecycle-event-handler.js +55 -0
- package/dist/components/event-handler/viral-lifecycle-event-handler.js.map +1 -0
- package/dist/components/keyboard/viral-keyboard.d.ts +17 -0
- package/dist/components/keyboard/viral-keyboard.js +76 -0
- package/dist/components/keyboard/viral-keyboard.js.map +1 -0
- package/dist/components/loader/viral-point-cloud.loader.d.ts +16 -0
- package/dist/components/loader/viral-point-cloud.loader.js +33 -0
- package/dist/components/loader/viral-point-cloud.loader.js.map +1 -0
- package/dist/components/loader/viral-revit.loader.d.ts +23 -0
- package/dist/components/loader/viral-revit.loader.js +339 -0
- package/dist/components/loader/viral-revit.loader.js.map +1 -0
- package/dist/components/loader/viral-three.loader.d.ts +11 -0
- package/dist/components/loader/viral-three.loader.js +20 -0
- package/dist/components/loader/viral-three.loader.js.map +1 -0
- package/dist/components/loader/viral-viewer-point-cloud.loader.d.ts +16 -0
- package/dist/components/loader/viral-viewer-point-cloud.loader.js +33 -0
- package/dist/components/loader/viral-viewer-point-cloud.loader.js.map +1 -0
- package/dist/components/loader/viral-viewer-revit.loader.d.ts +13 -0
- package/dist/components/loader/viral-viewer-revit.loader.js +124 -0
- package/dist/components/loader/viral-viewer-revit.loader.js.map +1 -0
- package/dist/components/loader/viral.loader.d.ts +11 -0
- package/dist/components/loader/viral.loader.js +16 -0
- package/dist/components/loader/viral.loader.js.map +1 -0
- package/dist/components/material/viral-material-manager.d.ts +14 -0
- package/dist/components/material/viral-material-manager.js +60 -0
- package/dist/components/material/viral-material-manager.js.map +1 -0
- package/dist/components/mouse/viral-mouse.d.ts +31 -0
- package/dist/components/mouse/viral-mouse.js +234 -0
- package/dist/components/mouse/viral-mouse.js.map +1 -0
- package/dist/components/navigation-cube/components/cube-camera.d.ts +15 -0
- package/dist/components/navigation-cube/components/cube-camera.js +74 -0
- package/dist/components/navigation-cube/components/cube-camera.js.map +1 -0
- package/dist/components/navigation-cube/components/cube-renderer.d.ts +9 -0
- package/dist/components/navigation-cube/components/cube-renderer.js +31 -0
- package/dist/components/navigation-cube/components/cube-renderer.js.map +1 -0
- package/dist/components/navigation-cube/components/cube-scene.d.ts +13 -0
- package/dist/components/navigation-cube/components/cube-scene.js +546 -0
- package/dist/components/navigation-cube/components/cube-scene.js.map +1 -0
- package/dist/components/navigation-cube/components/cube.mouse.d.ts +9 -0
- package/dist/components/navigation-cube/components/cube.mouse.js +109 -0
- package/dist/components/navigation-cube/components/cube.mouse.js.map +1 -0
- package/dist/components/navigation-cube/viral-navigation-cube.d.ts +16 -0
- package/dist/components/navigation-cube/viral-navigation-cube.js +50 -0
- package/dist/components/navigation-cube/viral-navigation-cube.js.map +1 -0
- package/dist/components/post-processing/ambient-occlusion-effect.d.ts +13 -0
- package/dist/components/post-processing/ambient-occlusion-effect.js +33 -0
- package/dist/components/post-processing/ambient-occlusion-effect.js.map +1 -0
- package/dist/components/post-processing/bloom-effect.d.ts +11 -0
- package/dist/components/post-processing/bloom-effect.js +29 -0
- package/dist/components/post-processing/bloom-effect.js.map +1 -0
- package/dist/components/post-processing/outline-effect.d.ts +13 -0
- package/dist/components/post-processing/outline-effect.js +33 -0
- package/dist/components/post-processing/outline-effect.js.map +1 -0
- package/dist/components/post-processing/post-processing-renderer.d.ts +19 -0
- package/dist/components/post-processing/post-processing-renderer.js +46 -0
- package/dist/components/post-processing/post-processing-renderer.js.map +1 -0
- package/dist/components/renderer/viral-renderer.d.ts +11 -0
- package/dist/components/renderer/viral-renderer.js +55 -0
- package/dist/components/renderer/viral-renderer.js.map +1 -0
- package/dist/components/scene/viral-scene.d.ts +28 -0
- package/dist/components/scene/viral-scene.js +131 -0
- package/dist/components/scene/viral-scene.js.map +1 -0
- package/dist/components/spinner/viral-spinner.d.ts +10 -0
- package/dist/components/spinner/viral-spinner.js +207 -0
- package/dist/components/spinner/viral-spinner.js.map +1 -0
- package/dist/components/stats/viral-stats.d.ts +6 -0
- package/dist/components/stats/viral-stats.js +17 -0
- package/dist/components/stats/viral-stats.js.map +1 -0
- package/dist/components/tools/tools/viral-tool-ambient-occlusion.d.ts +7 -0
- package/dist/components/tools/tools/viral-tool-ambient-occlusion.js +16 -0
- package/dist/components/tools/tools/viral-tool-ambient-occlusion.js.map +1 -0
- package/dist/components/tools/tools/viral-tool-dark-mode.d.ts +7 -0
- package/dist/components/tools/tools/viral-tool-dark-mode.js +21 -0
- package/dist/components/tools/tools/viral-tool-dark-mode.js.map +1 -0
- package/dist/components/tools/tools/viral-tool-elevation.d.ts +11 -0
- package/dist/components/tools/tools/viral-tool-elevation.js +30 -0
- package/dist/components/tools/tools/viral-tool-elevation.js.map +1 -0
- package/dist/components/tools/tools/viral-tool-measure.d.ts +33 -0
- package/dist/components/tools/tools/viral-tool-measure.js +243 -0
- package/dist/components/tools/tools/viral-tool-measure.js.map +1 -0
- package/dist/components/tools/tools/viral-tool-sunlight.d.ts +7 -0
- package/dist/components/tools/tools/viral-tool-sunlight.js +46 -0
- package/dist/components/tools/tools/viral-tool-sunlight.js.map +1 -0
- package/dist/components/tools/viral-tools.d.ts +32 -0
- package/dist/components/tools/viral-tools.js +213 -0
- package/dist/components/tools/viral-tools.js.map +1 -0
- package/dist/components/visibility-manager/viral-visibility-manager.d.ts +20 -0
- package/dist/components/visibility-manager/viral-visibility-manager.js +175 -0
- package/dist/components/visibility-manager/viral-visibility-manager.js.map +1 -0
- package/dist/components/worker/base/worker-pool.d.ts +23 -0
- package/dist/components/worker/base/worker-pool.js +68 -0
- package/dist/components/worker/base/worker-pool.js.map +1 -0
- package/dist/components/worker/base/worker-thread.d.ts +10 -0
- package/dist/components/worker/base/worker-thread.js +35 -0
- package/dist/components/worker/base/worker-thread.js.map +1 -0
- package/dist/components/worker/fetch-data.worker.d.ts +12 -0
- package/dist/components/worker/fetch-data.worker.js +31 -0
- package/dist/components/worker/fetch-data.worker.js.map +1 -0
- package/dist/components/worker/load-element-by-material-v2.worker.d.ts +11 -0
- package/dist/components/worker/load-element-by-material-v2.worker.js +80 -0
- package/dist/components/worker/load-element-by-material-v2.worker.js.map +1 -0
- package/dist/components/worker/load-element-by-material.worker.d.ts +11 -0
- package/dist/components/worker/load-element-by-material.worker.js +59 -0
- package/dist/components/worker/load-element-by-material.worker.js.map +1 -0
- package/dist/components/worker/load-element-standalone.worker.d.ts +10 -0
- package/dist/components/worker/load-element-standalone.worker.js +109 -0
- package/dist/components/worker/load-element-standalone.worker.js.map +1 -0
- package/dist/components/worker/load-model.d.ts +126 -0
- package/dist/components/worker/load-model.js +1265 -0
- package/dist/components/worker/load-model.js.map +1 -0
- package/dist/components/worker/test-worker-pool.d.ts +6 -0
- package/dist/components/worker/test-worker-pool.js +21 -0
- package/dist/components/worker/test-worker-pool.js.map +1 -0
- package/dist/components/worker/viral-viewer-2.worker.d.ts +17 -0
- package/dist/components/worker/viral-viewer-2.worker.js +127 -0
- package/dist/components/worker/viral-viewer-2.worker.js.map +1 -0
- package/dist/components/worker/viral-viewer-3.worker.d.ts +14 -0
- package/dist/components/worker/viral-viewer-3.worker.js +82 -0
- package/dist/components/worker/viral-viewer-3.worker.js.map +1 -0
- package/dist/components/worker/viral-viewer-4.worker.d.ts +10 -0
- package/dist/components/worker/viral-viewer-4.worker.js +97 -0
- package/dist/components/worker/viral-viewer-4.worker.js.map +1 -0
- package/dist/components/worker/viral-viewer.worker-pool.d.ts +0 -0
- package/dist/components/worker/viral-viewer.worker-pool.js +61 -0
- package/dist/components/worker/viral-viewer.worker-pool.js.map +1 -0
- package/dist/components/worker/viral-viewer.worker.d.ts +8 -0
- package/dist/components/worker/viral-viewer.worker.js +107 -0
- package/dist/components/worker/viral-viewer.worker.js.map +1 -0
- package/dist/components/worker/worker-pool.d.ts +21 -0
- package/dist/components/worker/worker-pool.js +47 -0
- package/dist/components/worker/worker-pool.js.map +1 -0
- package/dist/components/worker/worker-thread.d.ts +9 -0
- package/dist/components/worker/worker-thread.js +30 -0
- package/dist/components/worker/worker-thread.js.map +1 -0
- package/dist/components/worker-script/fetch-data-worker.script.d.ts +1 -0
- package/dist/components/worker-script/fetch-data-worker.script.js +56 -0
- package/dist/components/worker-script/fetch-data-worker.script.js.map +1 -0
- package/dist/components/worker-script/load-element-by-material.script.d.ts +3 -0
- package/dist/components/worker-script/load-element-by-material.script.js +131 -0
- package/dist/components/worker-script/load-element-by-material.script.js.map +1 -0
- package/dist/components/worker-script/load-element-standalone.script.d.ts +1 -0
- package/dist/components/worker-script/load-element-standalone.script.js +34172 -0
- package/dist/components/worker-script/load-element-standalone.script.js.map +1 -0
- package/dist/components/worker-script/load-model-worker-2.script.d.ts +1 -0
- package/dist/components/worker-script/load-model-worker-2.script.js +2704 -0
- package/dist/components/worker-script/load-model-worker-2.script.js.map +1 -0
- package/dist/components/worker-script/load-model-worker-3.script.d.ts +1 -0
- package/dist/components/worker-script/load-model-worker-3.script.js +34170 -0
- package/dist/components/worker-script/load-model-worker-3.script.js.map +1 -0
- package/dist/components/worker-script/load-model-worker.script.d.ts +1 -0
- package/dist/components/worker-script/load-model-worker.script.js +148 -0
- package/dist/components/worker-script/load-model-worker.script.js.map +1 -0
- package/dist/components/worker-script/material-aproach/load-element-by-material-instanced-mesh.script.d.ts +1 -0
- package/dist/components/worker-script/material-aproach/load-element-by-material-instanced-mesh.script.js +34152 -0
- package/dist/components/worker-script/material-aproach/load-element-by-material-instanced-mesh.script.js.map +1 -0
- package/dist/components/worker-script/material-aproach/load-element-by-material-mesh.script.d.ts +3 -0
- package/dist/components/worker-script/material-aproach/load-element-by-material-mesh.script.js +127 -0
- package/dist/components/worker-script/material-aproach/load-element-by-material-mesh.script.js.map +1 -0
- package/dist/components/worker-script/test-worker-pool.script.d.ts +1 -0
- package/dist/components/worker-script/test-worker-pool.script.js +12 -0
- package/dist/components/worker-script/test-worker-pool.script.js.map +1 -0
- package/dist/components/worker-script/threejs.types.d.ts +1 -0
- package/dist/components/worker-script/threejs.types.js +34162 -0
- package/dist/components/worker-script/threejs.types.js.map +1 -0
- package/dist/const/colors.d.ts +14 -0
- package/dist/const/colors.js +39 -0
- package/dist/const/colors.js.map +1 -0
- package/dist/const/fonts.d.ts +7 -0
- package/dist/const/fonts.js +17 -0
- package/dist/const/fonts.js.map +1 -0
- package/dist/const/icons.d.ts +7 -0
- package/dist/const/icons.js +11 -0
- package/dist/const/icons.js.map +1 -0
- package/dist/gui/context-menu/viral-context-menu.d.ts +17 -0
- package/dist/gui/context-menu/viral-context-menu.js +78 -0
- package/dist/gui/context-menu/viral-context-menu.js.map +1 -0
- package/dist/gui/draggable-modal/viral-draggable-modal.d.ts +21 -0
- package/dist/gui/draggable-modal/viral-draggable-modal.js +167 -0
- package/dist/gui/draggable-modal/viral-draggable-modal.js.map +1 -0
- package/dist/gui/fonts/fonts.d.ts +2 -0
- package/dist/gui/fonts/fonts.js +20 -0
- package/dist/gui/fonts/fonts.js.map +1 -0
- package/dist/gui/navigation-cube/components/cube-camera.d.ts +15 -0
- package/dist/gui/navigation-cube/components/cube-camera.js +74 -0
- package/dist/gui/navigation-cube/components/cube-camera.js.map +1 -0
- package/dist/gui/navigation-cube/components/cube-renderer.d.ts +9 -0
- package/dist/gui/navigation-cube/components/cube-renderer.js +31 -0
- package/dist/gui/navigation-cube/components/cube-renderer.js.map +1 -0
- package/dist/gui/navigation-cube/components/cube-scene.d.ts +13 -0
- package/dist/gui/navigation-cube/components/cube-scene.js +546 -0
- package/dist/gui/navigation-cube/components/cube-scene.js.map +1 -0
- package/dist/gui/navigation-cube/components/cube.mouse.d.ts +9 -0
- package/dist/gui/navigation-cube/components/cube.mouse.js +109 -0
- package/dist/gui/navigation-cube/components/cube.mouse.js.map +1 -0
- package/dist/gui/navigation-cube/viral-navigation-cube.d.ts +16 -0
- package/dist/gui/navigation-cube/viral-navigation-cube.js +50 -0
- package/dist/gui/navigation-cube/viral-navigation-cube.js.map +1 -0
- package/dist/gui/spinner/viral-spinner.d.ts +10 -0
- package/dist/gui/spinner/viral-spinner.js +102 -0
- package/dist/gui/spinner/viral-spinner.js.map +1 -0
- package/dist/gui/tools/tools/viral-tool-ambient-occlusion.d.ts +7 -0
- package/dist/gui/tools/tools/viral-tool-ambient-occlusion.js +25 -0
- package/dist/gui/tools/tools/viral-tool-ambient-occlusion.js.map +1 -0
- package/dist/gui/tools/tools/viral-tool-dark-mode.d.ts +7 -0
- package/dist/gui/tools/tools/viral-tool-dark-mode.js +21 -0
- package/dist/gui/tools/tools/viral-tool-dark-mode.js.map +1 -0
- package/dist/gui/tools/tools/viral-tool-elevation.d.ts +11 -0
- package/dist/gui/tools/tools/viral-tool-elevation.js +30 -0
- package/dist/gui/tools/tools/viral-tool-elevation.js.map +1 -0
- package/dist/gui/tools/tools/viral-tool-export-scene.d.ts +7 -0
- package/dist/gui/tools/tools/viral-tool-export-scene.js +36 -0
- package/dist/gui/tools/tools/viral-tool-export-scene.js.map +1 -0
- package/dist/gui/tools/tools/viral-tool-measure.d.ts +33 -0
- package/dist/gui/tools/tools/viral-tool-measure.js +243 -0
- package/dist/gui/tools/tools/viral-tool-measure.js.map +1 -0
- package/dist/gui/tools/tools/viral-tool-sunlight.d.ts +7 -0
- package/dist/gui/tools/tools/viral-tool-sunlight.js +46 -0
- package/dist/gui/tools/tools/viral-tool-sunlight.js.map +1 -0
- package/dist/gui/tools/viral-tools.d.ts +32 -0
- package/dist/gui/tools/viral-tools.js +213 -0
- package/dist/gui/tools/viral-tools.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +21 -0
- package/dist/index.js.map +1 -0
- package/dist/models/dictionary.model.d.ts +10 -0
- package/dist/models/dictionary.model.js +42 -0
- package/dist/models/dictionary.model.js.map +1 -0
- package/dist/services/local-storage.service.d.ts +14 -0
- package/dist/services/local-storage.service.js +57 -0
- package/dist/services/local-storage.service.js.map +1 -0
- package/dist/threejs-addon/buffer-geometry-utils.d.ts +64 -0
- package/dist/threejs-addon/buffer-geometry-utils.js +807 -0
- package/dist/threejs-addon/buffer-geometry-utils.js.map +1 -0
- package/dist/threejs-addon/gltf-loader.d.ts +17 -0
- package/dist/threejs-addon/gltf-loader.js +2796 -0
- package/dist/threejs-addon/gltf-loader.js.map +1 -0
- package/dist/threejs-addon/n8ao/n8ao.d.ts +303 -0
- package/dist/threejs-addon/n8ao/n8ao.js +1952 -0
- package/dist/threejs-addon/n8ao/n8ao.js.map +1 -0
- package/dist/threejs-addon/n8ao/post-processing.d.ts +73558 -0
- package/dist/threejs-addon/n8ao/post-processing.js +15145 -0
- package/dist/threejs-addon/n8ao/post-processing.js.map +1 -0
- package/dist/threejs-addon/post-processing/effect-composer.d.ts +27 -0
- package/dist/threejs-addon/post-processing/effect-composer.js +134 -0
- package/dist/threejs-addon/post-processing/effect-composer.js.map +1 -0
- package/dist/threejs-addon/post-processing/mask-pass.d.ts +11 -0
- package/dist/threejs-addon/post-processing/mask-pass.js +69 -0
- package/dist/threejs-addon/post-processing/mask-pass.js.map +1 -0
- package/dist/threejs-addon/post-processing/outline-pass.d.ts +58 -0
- package/dist/threejs-addon/post-processing/outline-pass.js +484 -0
- package/dist/threejs-addon/post-processing/outline-pass.js.map +1 -0
- package/dist/threejs-addon/post-processing/output-pass.d.ts +11 -0
- package/dist/threejs-addon/post-processing/output-pass.js +61 -0
- package/dist/threejs-addon/post-processing/output-pass.js.map +1 -0
- package/dist/threejs-addon/post-processing/pass.d.ts +20 -0
- package/dist/threejs-addon/post-processing/pass.js +48 -0
- package/dist/threejs-addon/post-processing/pass.js.map +1 -0
- package/dist/threejs-addon/post-processing/render-pass.d.ts +13 -0
- package/dist/threejs-addon/post-processing/render-pass.js +50 -0
- package/dist/threejs-addon/post-processing/render-pass.js.map +1 -0
- package/dist/threejs-addon/post-processing/sao-pass.d.ts +62 -0
- package/dist/threejs-addon/post-processing/sao-pass.js +296 -0
- package/dist/threejs-addon/post-processing/sao-pass.js.map +1 -0
- package/dist/threejs-addon/post-processing/shader-pass.d.ts +11 -0
- package/dist/threejs-addon/post-processing/shader-pass.js +48 -0
- package/dist/threejs-addon/post-processing/shader-pass.js.map +1 -0
- package/dist/threejs-addon/post-processing/unreal-bloom-pass.d.ts +48 -0
- package/dist/threejs-addon/post-processing/unreal-bloom-pass.js +290 -0
- package/dist/threejs-addon/post-processing/unreal-bloom-pass.js.map +1 -0
- package/dist/threejs-addon/shaders/copy-shader.d.ts +13 -0
- package/dist/threejs-addon/shaders/copy-shader.js +39 -0
- package/dist/threejs-addon/shaders/copy-shader.js.map +1 -0
- package/dist/threejs-addon/shaders/depth-limited-blur-shader.d.ts +48 -0
- package/dist/threejs-addon/shaders/depth-limited-blur-shader.js +142 -0
- package/dist/threejs-addon/shaders/depth-limited-blur-shader.js.map +1 -0
- package/dist/threejs-addon/shaders/luminosity-high-pass-shader.d.ts +27 -0
- package/dist/threejs-addon/shaders/luminosity-high-pass-shader.js +56 -0
- package/dist/threejs-addon/shaders/luminosity-high-pass-shader.js.map +1 -0
- package/dist/threejs-addon/shaders/output-shader.d.ts +13 -0
- package/dist/threejs-addon/shaders/output-shader.js +72 -0
- package/dist/threejs-addon/shaders/output-shader.js.map +1 -0
- package/dist/threejs-addon/shaders/sao-shader.d.ts +71 -0
- package/dist/threejs-addon/shaders/sao-shader.js +180 -0
- package/dist/threejs-addon/shaders/sao-shader.js.map +1 -0
- package/dist/threejs-addon/shaders/unpack-depth-rgba-shader.d.ts +13 -0
- package/dist/threejs-addon/shaders/unpack-depth-rgba-shader.js +41 -0
- package/dist/threejs-addon/shaders/unpack-depth-rgba-shader.js.map +1 -0
- package/dist/threejs-addon/simplify-modifier.d.ts +4 -0
- package/dist/threejs-addon/simplify-modifier.js +325 -0
- package/dist/threejs-addon/simplify-modifier.js.map +1 -0
- package/dist/threejs-addon/stats.d.ts +21 -0
- package/dist/threejs-addon/stats.js +102 -0
- package/dist/threejs-addon/stats.js.map +1 -0
- package/dist/threejs-addon/transform-control.d.ts +74 -0
- package/dist/threejs-addon/transform-control.js +1033 -0
- package/dist/threejs-addon/transform-control.js.map +1 -0
- package/dist/types.d.ts +145 -0
- package/dist/types.js +173 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/html.d.ts +3 -0
- package/dist/utils/html.js +12 -0
- package/dist/utils/html.js.map +1 -0
- package/dist/utils/index.d.ts +4 -0
- package/dist/utils/index.js +10 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/log.d.ts +4 -0
- package/dist/utils/log.js +14 -0
- package/dist/utils/log.js.map +1 -0
- package/dist/utils/threejs.d.ts +8 -0
- package/dist/utils/threejs.js +44 -0
- package/dist/utils/threejs.js.map +1 -0
- package/dist/viral-viewer-api.d.ts +50 -0
- package/dist/viral-viewer-api.js +76 -0
- package/dist/viral-viewer-api.js.map +1 -0
- package/package.json +2 -3
|
@@ -0,0 +1,807 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.toCreasedNormals = exports.mergeGroups = exports.computeMorphedAttributes = exports.toTrianglesDrawMode = exports.mergeVertices = exports.estimateBytesUsed = exports.interleaveAttributes = exports.mergeBufferAttributes = exports.mergeAttributes = exports.mergeBufferGeometries = exports.mergeGeometries = exports.computeMikkTSpaceTangents = exports.deinterleaveGeometry = exports.deinterleaveAttribute = exports.deepCloneAttribute = void 0;
|
|
4
|
+
const three_1 = require("three");
|
|
5
|
+
function computeMikkTSpaceTangents(geometry, MikkTSpace, negateSign = true) {
|
|
6
|
+
if (!MikkTSpace || !MikkTSpace.isReady) {
|
|
7
|
+
throw new Error('BufferGeometryUtils: Initialized MikkTSpace library required.');
|
|
8
|
+
}
|
|
9
|
+
if (!geometry.hasAttribute('position') || !geometry.hasAttribute('normal') || !geometry.hasAttribute('uv')) {
|
|
10
|
+
throw new Error('BufferGeometryUtils: Tangents require "position", "normal", and "uv" attributes.');
|
|
11
|
+
}
|
|
12
|
+
function getAttributeArray(attribute) {
|
|
13
|
+
if (attribute.normalized || attribute.isInterleavedBufferAttribute) {
|
|
14
|
+
const dstArray = new Float32Array(attribute.count * attribute.itemSize);
|
|
15
|
+
for (let i = 0, j = 0; i < attribute.count; i++) {
|
|
16
|
+
dstArray[j++] = attribute.getX(i);
|
|
17
|
+
dstArray[j++] = attribute.getY(i);
|
|
18
|
+
if (attribute.itemSize > 2) {
|
|
19
|
+
dstArray[j++] = attribute.getZ(i);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
return dstArray;
|
|
23
|
+
}
|
|
24
|
+
if (attribute.array instanceof Float32Array) {
|
|
25
|
+
return attribute.array;
|
|
26
|
+
}
|
|
27
|
+
return new Float32Array(attribute.array);
|
|
28
|
+
}
|
|
29
|
+
// MikkTSpace algorithm requires non-indexed input.
|
|
30
|
+
const _geometry = geometry.index ? geometry.toNonIndexed() : geometry;
|
|
31
|
+
// Compute vertex tangents.
|
|
32
|
+
const tangents = MikkTSpace.generateTangents(getAttributeArray(_geometry.attributes.position), getAttributeArray(_geometry.attributes.normal), getAttributeArray(_geometry.attributes.uv));
|
|
33
|
+
// Texture coordinate convention of glTF differs from the apparent
|
|
34
|
+
// default of the MikkTSpace library; .w component must be flipped.
|
|
35
|
+
if (negateSign) {
|
|
36
|
+
for (let i = 3; i < tangents.length; i += 4) {
|
|
37
|
+
tangents[i] *= -1;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
//
|
|
41
|
+
_geometry.setAttribute('tangent', new three_1.BufferAttribute(tangents, 4));
|
|
42
|
+
if (geometry !== _geometry) {
|
|
43
|
+
geometry.copy(_geometry);
|
|
44
|
+
}
|
|
45
|
+
return geometry;
|
|
46
|
+
}
|
|
47
|
+
exports.computeMikkTSpaceTangents = computeMikkTSpaceTangents;
|
|
48
|
+
/**
|
|
49
|
+
* @param {Array<BufferGeometry>} geometries
|
|
50
|
+
* @param {Boolean} useGroups
|
|
51
|
+
* @return {BufferGeometry}
|
|
52
|
+
*/
|
|
53
|
+
function mergeGeometries(geometries, useGroups = false) {
|
|
54
|
+
const isIndexed = geometries[0].index !== null;
|
|
55
|
+
const attributesUsed = new Set(Object.keys(geometries[0].attributes));
|
|
56
|
+
const morphAttributesUsed = new Set(Object.keys(geometries[0].morphAttributes));
|
|
57
|
+
const attributes = {};
|
|
58
|
+
const morphAttributes = {};
|
|
59
|
+
const morphTargetsRelative = geometries[0].morphTargetsRelative;
|
|
60
|
+
const mergedGeometry = new three_1.BufferGeometry();
|
|
61
|
+
let offset = 0;
|
|
62
|
+
for (let i = 0; i < geometries.length; ++i) {
|
|
63
|
+
const geometry = geometries[i];
|
|
64
|
+
let attributesCount = 0;
|
|
65
|
+
// ensure that all geometries are indexed, or none
|
|
66
|
+
if (isIndexed !== (geometry.index !== null)) {
|
|
67
|
+
console.error('THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index ' + i + '. All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them.');
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
// gather attributes, exit early if they're different
|
|
71
|
+
for (const name in geometry.attributes) {
|
|
72
|
+
if (!attributesUsed.has(name)) {
|
|
73
|
+
console.error('THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index ' + i + '. All geometries must have compatible attributes; make sure "' + name + '" attribute exists among all geometries, or in none of them.');
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
if (attributes[name] === undefined)
|
|
77
|
+
attributes[name] = [];
|
|
78
|
+
attributes[name].push(geometry.attributes[name]);
|
|
79
|
+
attributesCount++;
|
|
80
|
+
}
|
|
81
|
+
// ensure geometries have the same number of attributes
|
|
82
|
+
if (attributesCount !== attributesUsed.size) {
|
|
83
|
+
console.error('THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index ' + i + '. Make sure all geometries have the same number of attributes.');
|
|
84
|
+
return null;
|
|
85
|
+
}
|
|
86
|
+
// gather morph attributes, exit early if they're different
|
|
87
|
+
if (morphTargetsRelative !== geometry.morphTargetsRelative) {
|
|
88
|
+
console.error('THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index ' + i + '. .morphTargetsRelative must be consistent throughout all geometries.');
|
|
89
|
+
return null;
|
|
90
|
+
}
|
|
91
|
+
for (const name in geometry.morphAttributes) {
|
|
92
|
+
if (!morphAttributesUsed.has(name)) {
|
|
93
|
+
console.error('THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index ' + i + '. .morphAttributes must be consistent throughout all geometries.');
|
|
94
|
+
return null;
|
|
95
|
+
}
|
|
96
|
+
if (morphAttributes[name] === undefined)
|
|
97
|
+
morphAttributes[name] = [];
|
|
98
|
+
morphAttributes[name].push(geometry.morphAttributes[name]);
|
|
99
|
+
}
|
|
100
|
+
if (useGroups) {
|
|
101
|
+
let count;
|
|
102
|
+
if (isIndexed) {
|
|
103
|
+
count = geometry.index.count;
|
|
104
|
+
}
|
|
105
|
+
else if (geometry.attributes.position !== undefined) {
|
|
106
|
+
count = geometry.attributes.position.count;
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
console.error('THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index ' + i + '. The geometry must have either an index or a position attribute');
|
|
110
|
+
return null;
|
|
111
|
+
}
|
|
112
|
+
mergedGeometry.addGroup(offset, count, i);
|
|
113
|
+
offset += count;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
// merge indices
|
|
117
|
+
if (isIndexed) {
|
|
118
|
+
let indexOffset = 0;
|
|
119
|
+
const mergedIndex = [];
|
|
120
|
+
for (let i = 0; i < geometries.length; ++i) {
|
|
121
|
+
const index = geometries[i].index;
|
|
122
|
+
for (let j = 0; j < index.count; ++j) {
|
|
123
|
+
mergedIndex.push(index.getX(j) + indexOffset);
|
|
124
|
+
}
|
|
125
|
+
indexOffset += geometries[i].attributes.position.count;
|
|
126
|
+
}
|
|
127
|
+
mergedGeometry.setIndex(mergedIndex);
|
|
128
|
+
}
|
|
129
|
+
// merge attributes
|
|
130
|
+
for (const name in attributes) {
|
|
131
|
+
const mergedAttribute = mergeAttributes(attributes[name]);
|
|
132
|
+
if (!mergedAttribute) {
|
|
133
|
+
console.error('THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the ' + name + ' attribute.');
|
|
134
|
+
return null;
|
|
135
|
+
}
|
|
136
|
+
mergedGeometry.setAttribute(name, mergedAttribute);
|
|
137
|
+
}
|
|
138
|
+
// merge morph attributes
|
|
139
|
+
for (const name in morphAttributes) {
|
|
140
|
+
const numMorphTargets = morphAttributes[name][0].length;
|
|
141
|
+
if (numMorphTargets === 0)
|
|
142
|
+
break;
|
|
143
|
+
mergedGeometry.morphAttributes = mergedGeometry.morphAttributes || {};
|
|
144
|
+
mergedGeometry.morphAttributes[name] = [];
|
|
145
|
+
for (let i = 0; i < numMorphTargets; ++i) {
|
|
146
|
+
const morphAttributesToMerge = [];
|
|
147
|
+
for (let j = 0; j < morphAttributes[name].length; ++j) {
|
|
148
|
+
morphAttributesToMerge.push(morphAttributes[name][j][i]);
|
|
149
|
+
}
|
|
150
|
+
const mergedMorphAttribute = mergeAttributes(morphAttributesToMerge);
|
|
151
|
+
if (!mergedMorphAttribute) {
|
|
152
|
+
console.error('THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the ' + name + ' morphAttribute.');
|
|
153
|
+
return null;
|
|
154
|
+
}
|
|
155
|
+
mergedGeometry.morphAttributes[name].push(mergedMorphAttribute);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
return mergedGeometry;
|
|
159
|
+
}
|
|
160
|
+
exports.mergeGeometries = mergeGeometries;
|
|
161
|
+
/**
|
|
162
|
+
* @param {Array<BufferAttribute>} attributes
|
|
163
|
+
* @return {BufferAttribute}
|
|
164
|
+
*/
|
|
165
|
+
function mergeAttributes(attributes) {
|
|
166
|
+
let TypedArray;
|
|
167
|
+
let itemSize;
|
|
168
|
+
let normalized;
|
|
169
|
+
let gpuType = -1;
|
|
170
|
+
let arrayLength = 0;
|
|
171
|
+
for (let i = 0; i < attributes.length; ++i) {
|
|
172
|
+
const attribute = attributes[i];
|
|
173
|
+
if (attribute.isInterleavedBufferAttribute) {
|
|
174
|
+
console.error('THREE.BufferGeometryUtils: .mergeAttributes() failed. InterleavedBufferAttributes are not supported.');
|
|
175
|
+
return null;
|
|
176
|
+
}
|
|
177
|
+
if (TypedArray === undefined)
|
|
178
|
+
TypedArray = attribute.array.constructor;
|
|
179
|
+
if (TypedArray !== attribute.array.constructor) {
|
|
180
|
+
console.error('THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes.');
|
|
181
|
+
return null;
|
|
182
|
+
}
|
|
183
|
+
if (itemSize === undefined)
|
|
184
|
+
itemSize = attribute.itemSize;
|
|
185
|
+
if (itemSize !== attribute.itemSize) {
|
|
186
|
+
console.error('THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes.');
|
|
187
|
+
return null;
|
|
188
|
+
}
|
|
189
|
+
if (normalized === undefined)
|
|
190
|
+
normalized = attribute.normalized;
|
|
191
|
+
if (normalized !== attribute.normalized) {
|
|
192
|
+
console.error('THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes.');
|
|
193
|
+
return null;
|
|
194
|
+
}
|
|
195
|
+
if (gpuType === -1)
|
|
196
|
+
gpuType = attribute.gpuType;
|
|
197
|
+
if (gpuType !== attribute.gpuType) {
|
|
198
|
+
console.error('THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.gpuType must be consistent across matching attributes.');
|
|
199
|
+
return null;
|
|
200
|
+
}
|
|
201
|
+
arrayLength += attribute.array.length;
|
|
202
|
+
}
|
|
203
|
+
const array = new TypedArray(arrayLength);
|
|
204
|
+
let offset = 0;
|
|
205
|
+
for (let i = 0; i < attributes.length; ++i) {
|
|
206
|
+
array.set(attributes[i].array, offset);
|
|
207
|
+
offset += attributes[i].array.length;
|
|
208
|
+
}
|
|
209
|
+
const result = new three_1.BufferAttribute(array, itemSize, normalized);
|
|
210
|
+
if (gpuType !== undefined) {
|
|
211
|
+
result.gpuType = gpuType;
|
|
212
|
+
}
|
|
213
|
+
return result;
|
|
214
|
+
}
|
|
215
|
+
exports.mergeAttributes = mergeAttributes;
|
|
216
|
+
/**
|
|
217
|
+
* @param {BufferAttribute}
|
|
218
|
+
* @return {BufferAttribute}
|
|
219
|
+
*/
|
|
220
|
+
function deepCloneAttribute(attribute) {
|
|
221
|
+
if (attribute.isInstancedInterleavedBufferAttribute || attribute.isInterleavedBufferAttribute) {
|
|
222
|
+
return deinterleaveAttribute(attribute);
|
|
223
|
+
}
|
|
224
|
+
if (attribute.isInstancedBufferAttribute) {
|
|
225
|
+
return new three_1.InstancedBufferAttribute().copy(attribute);
|
|
226
|
+
}
|
|
227
|
+
return new three_1.BufferAttribute().copy(attribute);
|
|
228
|
+
}
|
|
229
|
+
exports.deepCloneAttribute = deepCloneAttribute;
|
|
230
|
+
/**
|
|
231
|
+
* @param {Array<BufferAttribute>} attributes
|
|
232
|
+
* @return {Array<InterleavedBufferAttribute>}
|
|
233
|
+
*/
|
|
234
|
+
function interleaveAttributes(attributes) {
|
|
235
|
+
// Interleaves the provided attributes into an InterleavedBuffer and returns
|
|
236
|
+
// a set of InterleavedBufferAttributes for each attribute
|
|
237
|
+
let TypedArray;
|
|
238
|
+
let arrayLength = 0;
|
|
239
|
+
let stride = 0;
|
|
240
|
+
// calculate the length and type of the interleavedBuffer
|
|
241
|
+
for (let i = 0, l = attributes.length; i < l; ++i) {
|
|
242
|
+
const attribute = attributes[i];
|
|
243
|
+
if (TypedArray === undefined)
|
|
244
|
+
TypedArray = attribute.array.constructor;
|
|
245
|
+
if (TypedArray !== attribute.array.constructor) {
|
|
246
|
+
console.error('AttributeBuffers of different types cannot be interleaved');
|
|
247
|
+
return null;
|
|
248
|
+
}
|
|
249
|
+
arrayLength += attribute.array.length;
|
|
250
|
+
stride += attribute.itemSize;
|
|
251
|
+
}
|
|
252
|
+
// Create the set of buffer attributes
|
|
253
|
+
const interleavedBuffer = new three_1.InterleavedBuffer(new TypedArray(arrayLength), stride);
|
|
254
|
+
let offset = 0;
|
|
255
|
+
const res = [];
|
|
256
|
+
const getters = ['getX', 'getY', 'getZ', 'getW'];
|
|
257
|
+
const setters = ['setX', 'setY', 'setZ', 'setW'];
|
|
258
|
+
for (let j = 0, l = attributes.length; j < l; j++) {
|
|
259
|
+
const attribute = attributes[j];
|
|
260
|
+
const itemSize = attribute.itemSize;
|
|
261
|
+
const count = attribute.count;
|
|
262
|
+
const iba = new three_1.InterleavedBufferAttribute(interleavedBuffer, itemSize, offset, attribute.normalized);
|
|
263
|
+
res.push(iba);
|
|
264
|
+
offset += itemSize;
|
|
265
|
+
// Move the data for each attribute into the new interleavedBuffer
|
|
266
|
+
// at the appropriate offset
|
|
267
|
+
for (let c = 0; c < count; c++) {
|
|
268
|
+
for (let k = 0; k < itemSize; k++) {
|
|
269
|
+
iba[setters[k]](c, attribute[getters[k]](c));
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
return res;
|
|
274
|
+
}
|
|
275
|
+
exports.interleaveAttributes = interleaveAttributes;
|
|
276
|
+
// returns a new, non-interleaved version of the provided attribute
|
|
277
|
+
function deinterleaveAttribute(attribute) {
|
|
278
|
+
const cons = attribute.data.array.constructor;
|
|
279
|
+
const count = attribute.count;
|
|
280
|
+
const itemSize = attribute.itemSize;
|
|
281
|
+
const normalized = attribute.normalized;
|
|
282
|
+
const array = new cons(count * itemSize);
|
|
283
|
+
let newAttribute;
|
|
284
|
+
if (attribute.isInstancedInterleavedBufferAttribute) {
|
|
285
|
+
newAttribute = new three_1.InstancedBufferAttribute(array, itemSize, normalized, attribute.meshPerAttribute);
|
|
286
|
+
}
|
|
287
|
+
else {
|
|
288
|
+
newAttribute = new three_1.BufferAttribute(array, itemSize, normalized);
|
|
289
|
+
}
|
|
290
|
+
for (let i = 0; i < count; i++) {
|
|
291
|
+
newAttribute.setX(i, attribute.getX(i));
|
|
292
|
+
if (itemSize >= 2) {
|
|
293
|
+
newAttribute.setY(i, attribute.getY(i));
|
|
294
|
+
}
|
|
295
|
+
if (itemSize >= 3) {
|
|
296
|
+
newAttribute.setZ(i, attribute.getZ(i));
|
|
297
|
+
}
|
|
298
|
+
if (itemSize >= 4) {
|
|
299
|
+
newAttribute.setW(i, attribute.getW(i));
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
return newAttribute;
|
|
303
|
+
}
|
|
304
|
+
exports.deinterleaveAttribute = deinterleaveAttribute;
|
|
305
|
+
// deinterleaves all attributes on the geometry
|
|
306
|
+
function deinterleaveGeometry(geometry) {
|
|
307
|
+
const attributes = geometry.attributes;
|
|
308
|
+
const morphTargets = geometry.morphTargets;
|
|
309
|
+
const attrMap = new Map();
|
|
310
|
+
for (const key in attributes) {
|
|
311
|
+
const attr = attributes[key];
|
|
312
|
+
if (attr.isInterleavedBufferAttribute) {
|
|
313
|
+
if (!attrMap.has(attr)) {
|
|
314
|
+
attrMap.set(attr, deinterleaveAttribute(attr));
|
|
315
|
+
}
|
|
316
|
+
attributes[key] = attrMap.get(attr);
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
for (const key in morphTargets) {
|
|
320
|
+
const attr = morphTargets[key];
|
|
321
|
+
if (attr.isInterleavedBufferAttribute) {
|
|
322
|
+
if (!attrMap.has(attr)) {
|
|
323
|
+
attrMap.set(attr, deinterleaveAttribute(attr));
|
|
324
|
+
}
|
|
325
|
+
morphTargets[key] = attrMap.get(attr);
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
exports.deinterleaveGeometry = deinterleaveGeometry;
|
|
330
|
+
/**
|
|
331
|
+
* @param {BufferGeometry} geometry
|
|
332
|
+
* @return {number}
|
|
333
|
+
*/
|
|
334
|
+
function estimateBytesUsed(geometry) {
|
|
335
|
+
// Return the estimated memory used by this geometry in bytes
|
|
336
|
+
// Calculate using itemSize, count, and BYTES_PER_ELEMENT to account
|
|
337
|
+
// for InterleavedBufferAttributes.
|
|
338
|
+
let mem = 0;
|
|
339
|
+
for (const name in geometry.attributes) {
|
|
340
|
+
const attr = geometry.getAttribute(name);
|
|
341
|
+
mem += attr.count * attr.itemSize * attr.array.BYTES_PER_ELEMENT;
|
|
342
|
+
}
|
|
343
|
+
const indices = geometry.getIndex();
|
|
344
|
+
mem += indices ? indices.count * indices.itemSize * indices.array.BYTES_PER_ELEMENT : 0;
|
|
345
|
+
return mem;
|
|
346
|
+
}
|
|
347
|
+
exports.estimateBytesUsed = estimateBytesUsed;
|
|
348
|
+
/**
|
|
349
|
+
* @param {BufferGeometry} geometry
|
|
350
|
+
* @param {number} tolerance
|
|
351
|
+
* @return {BufferGeometry}
|
|
352
|
+
*/
|
|
353
|
+
function mergeVertices(geometry, tolerance = 1e-4) {
|
|
354
|
+
tolerance = Math.max(tolerance, Number.EPSILON);
|
|
355
|
+
// Generate an index buffer if the geometry doesn't have one, or optimize it
|
|
356
|
+
// if it's already available.
|
|
357
|
+
const hashToIndex = {};
|
|
358
|
+
const indices = geometry.getIndex();
|
|
359
|
+
const positions = geometry.getAttribute('position');
|
|
360
|
+
const vertexCount = indices ? indices.count : positions.count;
|
|
361
|
+
// next value for triangle indices
|
|
362
|
+
let nextIndex = 0;
|
|
363
|
+
// attributes and new attribute arrays
|
|
364
|
+
const attributeNames = Object.keys(geometry.attributes);
|
|
365
|
+
const tmpAttributes = {};
|
|
366
|
+
const tmpMorphAttributes = {};
|
|
367
|
+
const newIndices = [];
|
|
368
|
+
const getters = ['getX', 'getY', 'getZ', 'getW'];
|
|
369
|
+
const setters = ['setX', 'setY', 'setZ', 'setW'];
|
|
370
|
+
// Initialize the arrays, allocating space conservatively. Extra
|
|
371
|
+
// space will be trimmed in the last step.
|
|
372
|
+
for (let i = 0, l = attributeNames.length; i < l; i++) {
|
|
373
|
+
const name = attributeNames[i];
|
|
374
|
+
const attr = geometry.attributes[name];
|
|
375
|
+
tmpAttributes[name] = new three_1.BufferAttribute(new attr.array.constructor(attr.count * attr.itemSize), attr.itemSize, attr.normalized);
|
|
376
|
+
const morphAttr = geometry.morphAttributes[name];
|
|
377
|
+
if (morphAttr) {
|
|
378
|
+
tmpMorphAttributes[name] = new three_1.BufferAttribute(new morphAttr.array.constructor(morphAttr.count * morphAttr.itemSize), morphAttr.itemSize, morphAttr.normalized);
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
// convert the error tolerance to an amount of decimal places to truncate to
|
|
382
|
+
const decimalShift = Math.log10(1 / tolerance);
|
|
383
|
+
const shiftMultiplier = Math.pow(10, decimalShift);
|
|
384
|
+
for (let i = 0; i < vertexCount; i++) {
|
|
385
|
+
const index = indices ? indices.getX(i) : i;
|
|
386
|
+
// Generate a hash for the vertex attributes at the current index 'i'
|
|
387
|
+
let hash = '';
|
|
388
|
+
for (let j = 0, l = attributeNames.length; j < l; j++) {
|
|
389
|
+
const name = attributeNames[j];
|
|
390
|
+
const attribute = geometry.getAttribute(name);
|
|
391
|
+
const itemSize = attribute.itemSize;
|
|
392
|
+
for (let k = 0; k < itemSize; k++) {
|
|
393
|
+
// double tilde truncates the decimal value
|
|
394
|
+
hash += `${~~(attribute[getters[k]](index) * shiftMultiplier)},`;
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
// Add another reference to the vertex if it's already
|
|
398
|
+
// used by another index
|
|
399
|
+
if (hash in hashToIndex) {
|
|
400
|
+
newIndices.push(hashToIndex[hash]);
|
|
401
|
+
}
|
|
402
|
+
else {
|
|
403
|
+
// copy data to the new index in the temporary attributes
|
|
404
|
+
for (let j = 0, l = attributeNames.length; j < l; j++) {
|
|
405
|
+
const name = attributeNames[j];
|
|
406
|
+
const attribute = geometry.getAttribute(name);
|
|
407
|
+
const morphAttr = geometry.morphAttributes[name];
|
|
408
|
+
const itemSize = attribute.itemSize;
|
|
409
|
+
const newarray = tmpAttributes[name];
|
|
410
|
+
const newMorphArrays = tmpMorphAttributes[name];
|
|
411
|
+
for (let k = 0; k < itemSize; k++) {
|
|
412
|
+
const getterFunc = getters[k];
|
|
413
|
+
const setterFunc = setters[k];
|
|
414
|
+
newarray[setterFunc](nextIndex, attribute[getterFunc](index));
|
|
415
|
+
if (morphAttr) {
|
|
416
|
+
for (let m = 0, ml = morphAttr.length; m < ml; m++) {
|
|
417
|
+
newMorphArrays[m][setterFunc](nextIndex, morphAttr[m][getterFunc](index));
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
hashToIndex[hash] = nextIndex;
|
|
423
|
+
newIndices.push(nextIndex);
|
|
424
|
+
nextIndex++;
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
// generate result BufferGeometry
|
|
428
|
+
const result = geometry.clone();
|
|
429
|
+
for (const name in geometry.attributes) {
|
|
430
|
+
const tmpAttribute = tmpAttributes[name];
|
|
431
|
+
result.setAttribute(name, new three_1.BufferAttribute(tmpAttribute.array.slice(0, nextIndex * tmpAttribute.itemSize), tmpAttribute.itemSize, tmpAttribute.normalized));
|
|
432
|
+
if (!(name in tmpMorphAttributes))
|
|
433
|
+
continue;
|
|
434
|
+
for (let j = 0; j < tmpMorphAttributes[name].length; j++) {
|
|
435
|
+
const tmpMorphAttribute = tmpMorphAttributes[name][j];
|
|
436
|
+
result.morphAttributes[name][j] = new three_1.BufferAttribute(tmpMorphAttribute.array.slice(0, nextIndex * tmpMorphAttribute.itemSize), tmpMorphAttribute.itemSize, tmpMorphAttribute.normalized);
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
// indices
|
|
440
|
+
result.setIndex(newIndices);
|
|
441
|
+
return result;
|
|
442
|
+
}
|
|
443
|
+
exports.mergeVertices = mergeVertices;
|
|
444
|
+
/**
|
|
445
|
+
* @param {BufferGeometry} geometry
|
|
446
|
+
* @param {number} drawMode
|
|
447
|
+
* @return {BufferGeometry}
|
|
448
|
+
*/
|
|
449
|
+
function toTrianglesDrawMode(geometry, drawMode) {
|
|
450
|
+
if (drawMode === three_1.TrianglesDrawMode) {
|
|
451
|
+
console.warn('THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles.');
|
|
452
|
+
return geometry;
|
|
453
|
+
}
|
|
454
|
+
if (drawMode === three_1.TriangleFanDrawMode || drawMode === three_1.TriangleStripDrawMode) {
|
|
455
|
+
let index = geometry.getIndex();
|
|
456
|
+
// generate index if not present
|
|
457
|
+
if (index === null) {
|
|
458
|
+
const indices = [];
|
|
459
|
+
const position = geometry.getAttribute('position');
|
|
460
|
+
if (position !== undefined) {
|
|
461
|
+
for (let i = 0; i < position.count; i++) {
|
|
462
|
+
indices.push(i);
|
|
463
|
+
}
|
|
464
|
+
geometry.setIndex(indices);
|
|
465
|
+
index = geometry.getIndex();
|
|
466
|
+
}
|
|
467
|
+
else {
|
|
468
|
+
console.error('THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible.');
|
|
469
|
+
return geometry;
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
//
|
|
473
|
+
const numberOfTriangles = index.count - 2;
|
|
474
|
+
const newIndices = [];
|
|
475
|
+
if (drawMode === three_1.TriangleFanDrawMode) {
|
|
476
|
+
// gl.TRIANGLE_FAN
|
|
477
|
+
for (let i = 1; i <= numberOfTriangles; i++) {
|
|
478
|
+
newIndices.push(index.getX(0));
|
|
479
|
+
newIndices.push(index.getX(i));
|
|
480
|
+
newIndices.push(index.getX(i + 1));
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
else {
|
|
484
|
+
// gl.TRIANGLE_STRIP
|
|
485
|
+
for (let i = 0; i < numberOfTriangles; i++) {
|
|
486
|
+
if (i % 2 === 0) {
|
|
487
|
+
newIndices.push(index.getX(i));
|
|
488
|
+
newIndices.push(index.getX(i + 1));
|
|
489
|
+
newIndices.push(index.getX(i + 2));
|
|
490
|
+
}
|
|
491
|
+
else {
|
|
492
|
+
newIndices.push(index.getX(i + 2));
|
|
493
|
+
newIndices.push(index.getX(i + 1));
|
|
494
|
+
newIndices.push(index.getX(i));
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
if ((newIndices.length / 3) !== numberOfTriangles) {
|
|
499
|
+
console.error('THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.');
|
|
500
|
+
}
|
|
501
|
+
// build final geometry
|
|
502
|
+
const newGeometry = geometry.clone();
|
|
503
|
+
newGeometry.setIndex(newIndices);
|
|
504
|
+
newGeometry.clearGroups();
|
|
505
|
+
return newGeometry;
|
|
506
|
+
}
|
|
507
|
+
else {
|
|
508
|
+
console.error('THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:', drawMode);
|
|
509
|
+
return geometry;
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
exports.toTrianglesDrawMode = toTrianglesDrawMode;
|
|
513
|
+
/**
|
|
514
|
+
* Calculates the morphed attributes of a morphed/skinned BufferGeometry.
|
|
515
|
+
* Helpful for Raytracing or Decals.
|
|
516
|
+
* @param {Mesh | Line | Points} object An instance of Mesh, Line or Points.
|
|
517
|
+
* @return {Object} An Object with original position/normal attributes and morphed ones.
|
|
518
|
+
*/
|
|
519
|
+
function computeMorphedAttributes(object) {
|
|
520
|
+
const _vA = new three_1.Vector3();
|
|
521
|
+
const _vB = new three_1.Vector3();
|
|
522
|
+
const _vC = new three_1.Vector3();
|
|
523
|
+
const _tempA = new three_1.Vector3();
|
|
524
|
+
const _tempB = new three_1.Vector3();
|
|
525
|
+
const _tempC = new three_1.Vector3();
|
|
526
|
+
const _morphA = new three_1.Vector3();
|
|
527
|
+
const _morphB = new three_1.Vector3();
|
|
528
|
+
const _morphC = new three_1.Vector3();
|
|
529
|
+
function _calculateMorphedAttributeData(object, attribute, morphAttribute, morphTargetsRelative, a, b, c, modifiedAttributeArray) {
|
|
530
|
+
_vA.fromBufferAttribute(attribute, a);
|
|
531
|
+
_vB.fromBufferAttribute(attribute, b);
|
|
532
|
+
_vC.fromBufferAttribute(attribute, c);
|
|
533
|
+
const morphInfluences = object.morphTargetInfluences;
|
|
534
|
+
if (morphAttribute && morphInfluences) {
|
|
535
|
+
_morphA.set(0, 0, 0);
|
|
536
|
+
_morphB.set(0, 0, 0);
|
|
537
|
+
_morphC.set(0, 0, 0);
|
|
538
|
+
for (let i = 0, il = morphAttribute.length; i < il; i++) {
|
|
539
|
+
const influence = morphInfluences[i];
|
|
540
|
+
const morph = morphAttribute[i];
|
|
541
|
+
if (influence === 0)
|
|
542
|
+
continue;
|
|
543
|
+
_tempA.fromBufferAttribute(morph, a);
|
|
544
|
+
_tempB.fromBufferAttribute(morph, b);
|
|
545
|
+
_tempC.fromBufferAttribute(morph, c);
|
|
546
|
+
if (morphTargetsRelative) {
|
|
547
|
+
_morphA.addScaledVector(_tempA, influence);
|
|
548
|
+
_morphB.addScaledVector(_tempB, influence);
|
|
549
|
+
_morphC.addScaledVector(_tempC, influence);
|
|
550
|
+
}
|
|
551
|
+
else {
|
|
552
|
+
_morphA.addScaledVector(_tempA.sub(_vA), influence);
|
|
553
|
+
_morphB.addScaledVector(_tempB.sub(_vB), influence);
|
|
554
|
+
_morphC.addScaledVector(_tempC.sub(_vC), influence);
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
_vA.add(_morphA);
|
|
558
|
+
_vB.add(_morphB);
|
|
559
|
+
_vC.add(_morphC);
|
|
560
|
+
}
|
|
561
|
+
if (object.isSkinnedMesh) {
|
|
562
|
+
object.applyBoneTransform(a, _vA);
|
|
563
|
+
object.applyBoneTransform(b, _vB);
|
|
564
|
+
object.applyBoneTransform(c, _vC);
|
|
565
|
+
}
|
|
566
|
+
modifiedAttributeArray[a * 3 + 0] = _vA.x;
|
|
567
|
+
modifiedAttributeArray[a * 3 + 1] = _vA.y;
|
|
568
|
+
modifiedAttributeArray[a * 3 + 2] = _vA.z;
|
|
569
|
+
modifiedAttributeArray[b * 3 + 0] = _vB.x;
|
|
570
|
+
modifiedAttributeArray[b * 3 + 1] = _vB.y;
|
|
571
|
+
modifiedAttributeArray[b * 3 + 2] = _vB.z;
|
|
572
|
+
modifiedAttributeArray[c * 3 + 0] = _vC.x;
|
|
573
|
+
modifiedAttributeArray[c * 3 + 1] = _vC.y;
|
|
574
|
+
modifiedAttributeArray[c * 3 + 2] = _vC.z;
|
|
575
|
+
}
|
|
576
|
+
const geometry = object.geometry;
|
|
577
|
+
const material = object.material;
|
|
578
|
+
let a, b, c;
|
|
579
|
+
const index = geometry.index;
|
|
580
|
+
const positionAttribute = geometry.attributes.position;
|
|
581
|
+
const morphPosition = geometry.morphAttributes.position;
|
|
582
|
+
const morphTargetsRelative = geometry.morphTargetsRelative;
|
|
583
|
+
const normalAttribute = geometry.attributes.normal;
|
|
584
|
+
const morphNormal = geometry.morphAttributes.position;
|
|
585
|
+
const groups = geometry.groups;
|
|
586
|
+
const drawRange = geometry.drawRange;
|
|
587
|
+
let i, j, il, jl;
|
|
588
|
+
let group;
|
|
589
|
+
let start, end;
|
|
590
|
+
const modifiedPosition = new Float32Array(positionAttribute.count * positionAttribute.itemSize);
|
|
591
|
+
const modifiedNormal = new Float32Array(normalAttribute.count * normalAttribute.itemSize);
|
|
592
|
+
if (index !== null) {
|
|
593
|
+
// indexed buffer geometry
|
|
594
|
+
if (Array.isArray(material)) {
|
|
595
|
+
for (i = 0, il = groups.length; i < il; i++) {
|
|
596
|
+
group = groups[i];
|
|
597
|
+
start = Math.max(group.start, drawRange.start);
|
|
598
|
+
end = Math.min((group.start + group.count), (drawRange.start + drawRange.count));
|
|
599
|
+
for (j = start, jl = end; j < jl; j += 3) {
|
|
600
|
+
a = index.getX(j);
|
|
601
|
+
b = index.getX(j + 1);
|
|
602
|
+
c = index.getX(j + 2);
|
|
603
|
+
_calculateMorphedAttributeData(object, positionAttribute, morphPosition, morphTargetsRelative, a, b, c, modifiedPosition);
|
|
604
|
+
_calculateMorphedAttributeData(object, normalAttribute, morphNormal, morphTargetsRelative, a, b, c, modifiedNormal);
|
|
605
|
+
}
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
else {
|
|
609
|
+
start = Math.max(0, drawRange.start);
|
|
610
|
+
end = Math.min(index.count, (drawRange.start + drawRange.count));
|
|
611
|
+
for (i = start, il = end; i < il; i += 3) {
|
|
612
|
+
a = index.getX(i);
|
|
613
|
+
b = index.getX(i + 1);
|
|
614
|
+
c = index.getX(i + 2);
|
|
615
|
+
_calculateMorphedAttributeData(object, positionAttribute, morphPosition, morphTargetsRelative, a, b, c, modifiedPosition);
|
|
616
|
+
_calculateMorphedAttributeData(object, normalAttribute, morphNormal, morphTargetsRelative, a, b, c, modifiedNormal);
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
else {
|
|
621
|
+
// non-indexed buffer geometry
|
|
622
|
+
if (Array.isArray(material)) {
|
|
623
|
+
for (i = 0, il = groups.length; i < il; i++) {
|
|
624
|
+
group = groups[i];
|
|
625
|
+
start = Math.max(group.start, drawRange.start);
|
|
626
|
+
end = Math.min((group.start + group.count), (drawRange.start + drawRange.count));
|
|
627
|
+
for (j = start, jl = end; j < jl; j += 3) {
|
|
628
|
+
a = j;
|
|
629
|
+
b = j + 1;
|
|
630
|
+
c = j + 2;
|
|
631
|
+
_calculateMorphedAttributeData(object, positionAttribute, morphPosition, morphTargetsRelative, a, b, c, modifiedPosition);
|
|
632
|
+
_calculateMorphedAttributeData(object, normalAttribute, morphNormal, morphTargetsRelative, a, b, c, modifiedNormal);
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
else {
|
|
637
|
+
start = Math.max(0, drawRange.start);
|
|
638
|
+
end = Math.min(positionAttribute.count, (drawRange.start + drawRange.count));
|
|
639
|
+
for (i = start, il = end; i < il; i += 3) {
|
|
640
|
+
a = i;
|
|
641
|
+
b = i + 1;
|
|
642
|
+
c = i + 2;
|
|
643
|
+
_calculateMorphedAttributeData(object, positionAttribute, morphPosition, morphTargetsRelative, a, b, c, modifiedPosition);
|
|
644
|
+
_calculateMorphedAttributeData(object, normalAttribute, morphNormal, morphTargetsRelative, a, b, c, modifiedNormal);
|
|
645
|
+
}
|
|
646
|
+
}
|
|
647
|
+
}
|
|
648
|
+
const morphedPositionAttribute = new three_1.Float32BufferAttribute(modifiedPosition, 3);
|
|
649
|
+
const morphedNormalAttribute = new three_1.Float32BufferAttribute(modifiedNormal, 3);
|
|
650
|
+
return {
|
|
651
|
+
positionAttribute: positionAttribute,
|
|
652
|
+
normalAttribute: normalAttribute,
|
|
653
|
+
morphedPositionAttribute: morphedPositionAttribute,
|
|
654
|
+
morphedNormalAttribute: morphedNormalAttribute
|
|
655
|
+
};
|
|
656
|
+
}
|
|
657
|
+
exports.computeMorphedAttributes = computeMorphedAttributes;
|
|
658
|
+
function mergeGroups(geometry) {
|
|
659
|
+
if (geometry.groups.length === 0) {
|
|
660
|
+
console.warn('THREE.BufferGeometryUtils.mergeGroups(): No groups are defined. Nothing to merge.');
|
|
661
|
+
return geometry;
|
|
662
|
+
}
|
|
663
|
+
let groups = geometry.groups;
|
|
664
|
+
// sort groups by material index
|
|
665
|
+
groups = groups.sort((a, b) => {
|
|
666
|
+
if (a.materialIndex !== b.materialIndex)
|
|
667
|
+
return a.materialIndex - b.materialIndex;
|
|
668
|
+
return a.start - b.start;
|
|
669
|
+
});
|
|
670
|
+
// create index for non-indexed geometries
|
|
671
|
+
if (geometry.getIndex() === null) {
|
|
672
|
+
const positionAttribute = geometry.getAttribute('position');
|
|
673
|
+
const indices = [];
|
|
674
|
+
for (let i = 0; i < positionAttribute.count; i += 3) {
|
|
675
|
+
indices.push(i, i + 1, i + 2);
|
|
676
|
+
}
|
|
677
|
+
geometry.setIndex(indices);
|
|
678
|
+
}
|
|
679
|
+
// sort index
|
|
680
|
+
const index = geometry.getIndex();
|
|
681
|
+
const newIndices = [];
|
|
682
|
+
for (let i = 0; i < groups.length; i++) {
|
|
683
|
+
const group = groups[i];
|
|
684
|
+
const groupStart = group.start;
|
|
685
|
+
const groupLength = groupStart + group.count;
|
|
686
|
+
for (let j = groupStart; j < groupLength; j++) {
|
|
687
|
+
newIndices.push(index.getX(j));
|
|
688
|
+
}
|
|
689
|
+
}
|
|
690
|
+
geometry.dispose(); // Required to force buffer recreation
|
|
691
|
+
geometry.setIndex(newIndices);
|
|
692
|
+
// update groups indices
|
|
693
|
+
let start = 0;
|
|
694
|
+
for (let i = 0; i < groups.length; i++) {
|
|
695
|
+
const group = groups[i];
|
|
696
|
+
group.start = start;
|
|
697
|
+
start += group.count;
|
|
698
|
+
}
|
|
699
|
+
// merge groups
|
|
700
|
+
let currentGroup = groups[0];
|
|
701
|
+
geometry.groups = [currentGroup];
|
|
702
|
+
for (let i = 1; i < groups.length; i++) {
|
|
703
|
+
const group = groups[i];
|
|
704
|
+
if (currentGroup.materialIndex === group.materialIndex) {
|
|
705
|
+
currentGroup.count += group.count;
|
|
706
|
+
}
|
|
707
|
+
else {
|
|
708
|
+
currentGroup = group;
|
|
709
|
+
geometry.groups.push(currentGroup);
|
|
710
|
+
}
|
|
711
|
+
}
|
|
712
|
+
return geometry;
|
|
713
|
+
}
|
|
714
|
+
exports.mergeGroups = mergeGroups;
|
|
715
|
+
/**
|
|
716
|
+
* Modifies the supplied geometry if it is non-indexed, otherwise creates a new,
|
|
717
|
+
* non-indexed geometry. Returns the geometry with smooth normals everywhere except
|
|
718
|
+
* faces that meet at an angle greater than the crease angle.
|
|
719
|
+
*
|
|
720
|
+
* @param {BufferGeometry} geometry
|
|
721
|
+
* @param {number} [creaseAngle]
|
|
722
|
+
* @return {BufferGeometry}
|
|
723
|
+
*/
|
|
724
|
+
function toCreasedNormals(geometry, creaseAngle = Math.PI / 3 /* 60 degrees */) {
|
|
725
|
+
const creaseDot = Math.cos(creaseAngle);
|
|
726
|
+
const hashMultiplier = (1 + 1e-10) * 1e2;
|
|
727
|
+
// reusable vectors
|
|
728
|
+
const verts = [new three_1.Vector3(), new three_1.Vector3(), new three_1.Vector3()];
|
|
729
|
+
const tempVec1 = new three_1.Vector3();
|
|
730
|
+
const tempVec2 = new three_1.Vector3();
|
|
731
|
+
const tempNorm = new three_1.Vector3();
|
|
732
|
+
const tempNorm2 = new three_1.Vector3();
|
|
733
|
+
// hashes a vector
|
|
734
|
+
function hashVertex(v) {
|
|
735
|
+
const x = ~~(v.x * hashMultiplier);
|
|
736
|
+
const y = ~~(v.y * hashMultiplier);
|
|
737
|
+
const z = ~~(v.z * hashMultiplier);
|
|
738
|
+
return `${x},${y},${z}`;
|
|
739
|
+
}
|
|
740
|
+
// BufferGeometry.toNonIndexed() warns if the geometry is non-indexed
|
|
741
|
+
// and returns the original geometry
|
|
742
|
+
const resultGeometry = geometry.index ? geometry.toNonIndexed() : geometry;
|
|
743
|
+
const posAttr = resultGeometry.attributes.position;
|
|
744
|
+
const vertexMap = {};
|
|
745
|
+
// find all the normals shared by commonly located vertices
|
|
746
|
+
for (let i = 0, l = posAttr.count / 3; i < l; i++) {
|
|
747
|
+
const i3 = 3 * i;
|
|
748
|
+
const a = verts[0].fromBufferAttribute(posAttr, i3 + 0);
|
|
749
|
+
const b = verts[1].fromBufferAttribute(posAttr, i3 + 1);
|
|
750
|
+
const c = verts[2].fromBufferAttribute(posAttr, i3 + 2);
|
|
751
|
+
tempVec1.subVectors(c, b);
|
|
752
|
+
tempVec2.subVectors(a, b);
|
|
753
|
+
// add the normal to the map for all vertices
|
|
754
|
+
const normal = new three_1.Vector3().crossVectors(tempVec1, tempVec2).normalize();
|
|
755
|
+
for (let n = 0; n < 3; n++) {
|
|
756
|
+
const vert = verts[n];
|
|
757
|
+
const hash = hashVertex(vert);
|
|
758
|
+
if (!(hash in vertexMap)) {
|
|
759
|
+
vertexMap[hash] = [];
|
|
760
|
+
}
|
|
761
|
+
vertexMap[hash].push(normal);
|
|
762
|
+
}
|
|
763
|
+
}
|
|
764
|
+
// average normals from all vertices that share a common location if they are within the
|
|
765
|
+
// provided crease threshold
|
|
766
|
+
const normalArray = new Float32Array(posAttr.count * 3);
|
|
767
|
+
const normAttr = new three_1.BufferAttribute(normalArray, 3, false);
|
|
768
|
+
for (let i = 0, l = posAttr.count / 3; i < l; i++) {
|
|
769
|
+
// get the face normal for this vertex
|
|
770
|
+
const i3 = 3 * i;
|
|
771
|
+
const a = verts[0].fromBufferAttribute(posAttr, i3 + 0);
|
|
772
|
+
const b = verts[1].fromBufferAttribute(posAttr, i3 + 1);
|
|
773
|
+
const c = verts[2].fromBufferAttribute(posAttr, i3 + 2);
|
|
774
|
+
tempVec1.subVectors(c, b);
|
|
775
|
+
tempVec2.subVectors(a, b);
|
|
776
|
+
tempNorm.crossVectors(tempVec1, tempVec2).normalize();
|
|
777
|
+
// average all normals that meet the threshold and set the normal value
|
|
778
|
+
for (let n = 0; n < 3; n++) {
|
|
779
|
+
const vert = verts[n];
|
|
780
|
+
const hash = hashVertex(vert);
|
|
781
|
+
const otherNormals = vertexMap[hash];
|
|
782
|
+
tempNorm2.set(0, 0, 0);
|
|
783
|
+
for (let k = 0, lk = otherNormals.length; k < lk; k++) {
|
|
784
|
+
const otherNorm = otherNormals[k];
|
|
785
|
+
if (tempNorm.dot(otherNorm) > creaseDot) {
|
|
786
|
+
tempNorm2.add(otherNorm);
|
|
787
|
+
}
|
|
788
|
+
}
|
|
789
|
+
tempNorm2.normalize();
|
|
790
|
+
normAttr.setXYZ(i3 + n, tempNorm2.x, tempNorm2.y, tempNorm2.z);
|
|
791
|
+
}
|
|
792
|
+
}
|
|
793
|
+
resultGeometry.setAttribute('normal', normAttr);
|
|
794
|
+
return resultGeometry;
|
|
795
|
+
}
|
|
796
|
+
exports.toCreasedNormals = toCreasedNormals;
|
|
797
|
+
function mergeBufferGeometries(geometries, useGroups = false) {
|
|
798
|
+
console.warn('THREE.BufferGeometryUtils: mergeBufferGeometries() has been renamed to mergeGeometries().'); // @deprecated, r151
|
|
799
|
+
return mergeGeometries(geometries, useGroups);
|
|
800
|
+
}
|
|
801
|
+
exports.mergeBufferGeometries = mergeBufferGeometries;
|
|
802
|
+
function mergeBufferAttributes(attributes) {
|
|
803
|
+
console.warn('THREE.BufferGeometryUtils: mergeBufferAttributes() has been renamed to mergeAttributes().'); // @deprecated, r151
|
|
804
|
+
return mergeAttributes(attributes);
|
|
805
|
+
}
|
|
806
|
+
exports.mergeBufferAttributes = mergeBufferAttributes;
|
|
807
|
+
//# sourceMappingURL=buffer-geometry-utils.js.map
|