kitchen-simulator 5.0.0-test.5 → 5.0.0-test.6
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/package.json +24 -41
- package/src/@history.js +3 -0
- package/src/AppContext.js +5 -0
- package/src/KitchenConfigurator.jsx +1517 -0
- package/src/KitchenConfiguratorApp.jsx +443 -0
- package/src/actions/area-actions.js +15 -0
- package/src/actions/export.js +38 -0
- package/src/actions/groups-actions.js +102 -0
- package/src/actions/holes-actions.js +152 -0
- package/src/actions/items-actions.js +393 -0
- package/src/actions/lines-actions.js +103 -0
- package/src/actions/project-actions.js +391 -0
- package/src/actions/scene-actions.js +44 -0
- package/src/actions/user-actions.js +75 -0
- package/src/actions/vertices-actions.js +34 -0
- package/src/actions/viewer2d-actions.js +79 -0
- package/src/actions/viewer3d-actions.js +32 -0
- package/src/catalog/areas/area/planner-element.jsx +43 -0
- package/src/catalog/catalog.js +258 -0
- package/src/catalog/factories/area-factory-3d.js +252 -0
- package/src/catalog/factories/area-factory.jsx +102 -0
- package/src/catalog/factories/export.js +9 -0
- package/src/catalog/factories/wall-factory-3d.js +296 -0
- package/src/catalog/factories/wall-factory.jsx +321 -0
- package/src/catalog/holes/door-closet/planner-element.jsx +251 -0
- package/src/catalog/holes/door-double/planner-element.jsx +391 -0
- package/src/catalog/holes/door-exterior/planner-element.jsx +245 -0
- package/src/catalog/holes/door-interior/planner-element.jsx +256 -0
- package/src/catalog/holes/door-panic/planner-element.jsx +594 -0
- package/src/catalog/holes/door-panic-double/planner-element.jsx +574 -0
- package/src/catalog/holes/door-sliding/planner-element.jsx +256 -0
- package/src/catalog/holes/doorway-framed/planner-element.jsx +169 -0
- package/src/catalog/holes/doorway-frameless/planner-element.jsx +116 -0
- package/src/catalog/holes/window-clear/planner-element.jsx +181 -0
- package/src/catalog/holes/window-cross/planner-element.jsx +180 -0
- package/src/catalog/holes/window-double-hung/planner-element.jsx +366 -0
- package/src/catalog/holes/window-vertical/planner-element.jsx +290 -0
- package/src/catalog/lines/wall/planner-element.jsx +73 -0
- package/src/catalog/molding/molding-dcm/planner-element.jsx +35 -0
- package/src/catalog/molding/molding-fbm/planner-element.jsx +35 -0
- package/src/catalog/molding/molding-lrm/planner-element.jsx +35 -0
- package/src/catalog/properties/export.js +33 -0
- package/src/catalog/properties/property-checkbox.jsx +123 -0
- package/src/catalog/properties/property-color.jsx +52 -0
- package/src/catalog/properties/property-enum.jsx +87 -0
- package/src/catalog/properties/property-hidden.jsx +22 -0
- package/src/catalog/properties/property-lenght-measure.jsx +113 -0
- package/src/catalog/properties/property-length-measure.jsx +129 -0
- package/src/catalog/properties/property-length-measure_hole.jsx +110 -0
- package/src/catalog/properties/property-number.jsx +63 -0
- package/src/catalog/properties/property-read-only.jsx +37 -0
- package/src/catalog/properties/property-string.jsx +59 -0
- package/src/catalog/properties/property-toggle.jsx +51 -0
- package/src/catalog/properties/shared-property-style.js +13 -0
- package/src/catalog/utils/FuseUtils.js +61 -0
- package/src/catalog/utils/exporter.js +173 -0
- package/src/catalog/utils/geom-utils.js +301 -0
- package/src/catalog/utils/item-loader.jsx +2122 -0
- package/src/catalog/utils/load-obj.js +113 -0
- package/src/catalog/utils/mtl-loader.js +462 -0
- package/src/catalog/utils/obj-loader.js +544 -0
- package/src/class/FuseUtils.js +61 -0
- package/src/class/area.js +159 -0
- package/src/class/export.js +37 -0
- package/src/class/group.js +565 -0
- package/src/class/guide.js +44 -0
- package/src/class/hole.js +1359 -0
- package/src/class/item.js +2050 -0
- package/src/class/layer.js +926 -0
- package/src/class/line.js +1780 -0
- package/src/class/project.js +875 -0
- package/src/class/vertex.js +409 -0
- package/src/components/atoms/Snackbar/index.jsx +43 -0
- package/src/components/atoms/radio-button/index.jsx +20 -0
- package/src/components/atoms/radio-button/styles.js +56 -0
- package/src/components/button/MainButton.jsx +157 -0
- package/src/components/button/ToggleMeasureButton.jsx +65 -0
- package/src/components/catalog-view/catalog-breadcrumb.jsx +53 -0
- package/src/components/catalog-view/catalog-item.jsx +229 -0
- package/src/components/catalog-view/catalog-list.jsx +173 -0
- package/src/components/catalog-view/catalog-page-item.jsx +110 -0
- package/src/components/catalog-view/catalog-turn-back-page-item.jsx +80 -0
- package/src/components/configurator/custom-configurator.jsx +77 -0
- package/src/components/configurator/project-configurator.jsx +120 -0
- package/src/components/content.jsx +136 -0
- package/src/components/export.js +36 -0
- package/src/components/firstsetting/button/styles.js +223 -0
- package/src/components/firstsetting/export.js +9 -0
- package/src/components/firstsetting/firstsetting-content-button.jsx +198 -0
- package/src/components/firstsetting/firstsetting-toggle-button.jsx +101 -0
- package/src/components/firstsetting/firstsetting.jsx +814 -0
- package/src/components/footerbar/button/ControlButton.jsx +43 -0
- package/src/components/footerbar/button/DirectionButton.jsx +54 -0
- package/src/components/footerbar/button/DirectionPanSpinButton.jsx +36 -0
- package/src/components/footerbar/button/ToggleButton.jsx +58 -0
- package/src/components/footerbar/button/ToggleConvertButton.jsx +48 -0
- package/src/components/footerbar/button/ToggleMeasureButton.jsx +33 -0
- package/src/components/footerbar/button/styles.js +217 -0
- package/src/components/footerbar/export.js +9 -0
- package/src/components/footerbar/footer-content-button.jsx +198 -0
- package/src/components/footerbar/footer-toggle-button.jsx +101 -0
- package/src/components/footerbar/footerbar.jsx +1103 -0
- package/src/components/footerbar/styles.js +263 -0
- package/src/components/header/button/MenuButton.jsx +46 -0
- package/src/components/header/button/SaveButton.jsx +54 -0
- package/src/components/header/button/styles.js +181 -0
- package/src/components/header/export.js +5 -0
- package/src/components/header/header.jsx +631 -0
- package/src/components/header/styles.js +320 -0
- package/src/components/login/Login.js +77 -0
- package/src/components/login/LoginForm/index.js +108 -0
- package/src/components/login/Register.js +83 -0
- package/src/components/login/RegisterForm/index.js +171 -0
- package/src/components/login/jwtService.js +201 -0
- package/src/components/molecules/slider/index.jsx +15 -0
- package/src/components/molecules/slider/styles.js +0 -0
- package/src/components/myprojects/export.js +5 -0
- package/src/components/myprojects/index.jsx +445 -0
- package/src/components/myprojects/styles.js +241 -0
- package/src/components/sidebar/custom-accordion.jsx +48 -0
- package/src/components/sidebar/export.js +15 -0
- package/src/components/sidebar/panel-element-editor/attributes-editor/attributes-editor.jsx +73 -0
- package/src/components/sidebar/panel-element-editor/attributes-editor/confirm-popup.jsx +101 -0
- package/src/components/sidebar/panel-element-editor/attributes-editor/hole-attributes-editor.jsx +149 -0
- package/src/components/sidebar/panel-element-editor/attributes-editor/item-attributes-editor.jsx +316 -0
- package/src/components/sidebar/panel-element-editor/attributes-editor/line-attributes-editor.jsx +108 -0
- package/src/components/sidebar/panel-element-editor/element-editor.jsx +1070 -0
- package/src/components/sidebar/panel-element-editor/multi-elements-editor.jsx +0 -0
- package/src/components/sidebar/panel-element-editor/panel-element-editor.jsx +104 -0
- package/src/components/sidebar/panel-element-editor/panel-multi-elements-editor.jsx +155 -0
- package/src/components/sidebar/panel-group-editor.jsx +272 -0
- package/src/components/sidebar/panel-groups.jsx +310 -0
- package/src/components/sidebar/panel-guides.jsx +192 -0
- package/src/components/sidebar/panel-layer-elements.jsx +298 -0
- package/src/components/sidebar/panel-layers.jsx +381 -0
- package/src/components/sidebar/panel.jsx +71 -0
- package/src/components/sidebar/sidebar.jsx +106 -0
- package/src/components/sidebar/toolbar-panel.jsx +139 -0
- package/src/components/sign/export.js +7 -0
- package/src/components/sign/main/index.jsx +523 -0
- package/src/components/sign/main/styles.js +163 -0
- package/src/components/style/button.jsx +95 -0
- package/src/components/style/cancel-button.jsx +20 -0
- package/src/components/style/content-container.jsx +29 -0
- package/src/components/style/content-title.jsx +20 -0
- package/src/components/style/delete-button.jsx +23 -0
- package/src/components/style/export.jsx +48 -0
- package/src/components/style/form-block.jsx +13 -0
- package/src/components/style/form-color-input.jsx +27 -0
- package/src/components/style/form-label.jsx +15 -0
- package/src/components/style/form-number-input.jsx +196 -0
- package/src/components/style/form-number-input_2.jsx +191 -0
- package/src/components/style/form-select.jsx +38 -0
- package/src/components/style/form-slider.jsx +36 -0
- package/src/components/style/form-submit-button.jsx +23 -0
- package/src/components/style/form-text-input.jsx +65 -0
- package/src/components/toolbar/button/ControlButton.jsx +41 -0
- package/src/components/toolbar/button/DirectionButton.jsx +34 -0
- package/src/components/toolbar/button/RightButton.jsx +103 -0
- package/src/components/toolbar/button/ToggleButton.jsx +41 -0
- package/src/components/toolbar/button/index.jsx +55 -0
- package/src/components/toolbar/button/styles.js +127 -0
- package/src/components/toolbar/components/DoorStyleMenu.jsx +103 -0
- package/src/components/toolbar/components/Pricing.jsx +126 -0
- package/src/components/toolbar/components/ReviewForQuote.jsx +635 -0
- package/src/components/toolbar/export.js +21 -0
- package/src/components/toolbar/main/Alert.js +122 -0
- package/src/components/toolbar/main/TakePictureModal.jsx +104 -0
- package/src/components/toolbar/main/confirm-popup.jsx +99 -0
- package/src/components/toolbar/main/index.jsx +5687 -0
- package/src/components/toolbar/main/myComponents.js +123 -0
- package/src/components/toolbar/main/styles.js +696 -0
- package/src/components/toolbar/plugin-item.jsx +123 -0
- package/src/components/toolbar/popup/appliance/appliance-category/index.jsx +73 -0
- package/src/components/toolbar/popup/appliance/choose-appliance/index.jsx +102 -0
- package/src/components/toolbar/popup/appliance/index.jsx +83 -0
- package/src/components/toolbar/popup/autosaveprompt/index.jsx +150 -0
- package/src/components/toolbar/popup/autosaveprompt/styles.js +40 -0
- package/src/components/toolbar/popup/cabinet/cabinet-category/index.jsx +73 -0
- package/src/components/toolbar/popup/cabinet/choose-product/index.jsx +119 -0
- package/src/components/toolbar/popup/cabinet/index.jsx +85 -0
- package/src/components/toolbar/popup/doorStyle/choose-style/index.jsx +63 -0
- package/src/components/toolbar/popup/doorStyle/index.jsx +71 -0
- package/src/components/toolbar/popup/doorStyle/style-category/index.jsx +139 -0
- package/src/components/toolbar/popup/downloadsummary/downloadSummaryContext.js +2 -0
- package/src/components/toolbar/popup/downloadsummary/downloadSummaryTemp.jsx +157 -0
- package/src/components/toolbar/popup/downloadsummary/index.jsx +643 -0
- package/src/components/toolbar/popup/downloadsummary/show2D/show2DView.jsx +51 -0
- package/src/components/toolbar/popup/downloadsummary/show2D/viewer2DDownLoad.jsx +175 -0
- package/src/components/toolbar/popup/downloadsummary/show3D/show3DView.jsx +283 -0
- package/src/components/toolbar/popup/downloadsummary/show3D/viewer3DDownLoad.jsx +2257 -0
- package/src/components/toolbar/popup/downloadsummary/showCabinetInfo.js +93 -0
- package/src/components/toolbar/popup/downloadsummary/showElevation/showElevationView.jsx +132 -0
- package/src/components/toolbar/popup/downloadsummary/showElevation/viewer3DElevationDownload.jsx +2198 -0
- package/src/components/toolbar/popup/downloadsummary/showElevation/viewerElevationDownload.jsx +152 -0
- package/src/components/toolbar/popup/downloadsummary/showWarranty.jsx +149 -0
- package/src/components/toolbar/popup/downloadsummary/styles.js +453 -0
- package/src/components/toolbar/popup/finishingtouch/category/index.jsx +34 -0
- package/src/components/toolbar/popup/finishingtouch/index.jsx +58 -0
- package/src/components/toolbar/popup/finishingtouch/material-edit.jsx +112 -0
- package/src/components/toolbar/popup/finishingtouch/product/index.jsx +116 -0
- package/src/components/toolbar/popup/floorplan/choose-floor/confirm-popup.jsx +101 -0
- package/src/components/toolbar/popup/floorplan/choose-floor/index.jsx +254 -0
- package/src/components/toolbar/popup/floorplan/choose-floor/styles.js +86 -0
- package/src/components/toolbar/popup/floorplan/floor-category/index.jsx +109 -0
- package/src/components/toolbar/popup/floorplan/index.jsx +60 -0
- package/src/components/toolbar/popup/index.jsx +241 -0
- package/src/components/toolbar/popup/newproject/index.jsx +59 -0
- package/src/components/toolbar/popup/newproject/styles.js +41 -0
- package/src/components/toolbar/popup/product/appliance.jsx +54 -0
- package/src/components/toolbar/popup/product/cabinetproduct.jsx +15 -0
- package/src/components/toolbar/popup/product/doorstyle.jsx +58 -0
- package/src/components/toolbar/popup/product/doorstyleproduct.jsx +47 -0
- package/src/components/toolbar/popup/product/floor.jsx +36 -0
- package/src/components/toolbar/popup/product/floorproduct.jsx +42 -0
- package/src/components/toolbar/popup/product/index.jsx +36 -0
- package/src/components/toolbar/popup/product/primary.jsx +77 -0
- package/src/components/toolbar/popup/product/productline.jsx +93 -0
- package/src/components/toolbar/popup/product/reviewItem.jsx +427 -0
- package/src/components/toolbar/popup/product/reviewMolding.jsx +310 -0
- package/src/components/toolbar/popup/product/styles.js +260 -0
- package/src/components/toolbar/popup/savedesign/FullPictureForm.jsx +146 -0
- package/src/components/toolbar/popup/savedesign/index.jsx +495 -0
- package/src/components/toolbar/popup/savedesign/styles.js +151 -0
- package/src/components/toolbar/popup/setDoorStyleOption/index.jsx +87 -0
- package/src/components/toolbar/popup/styles.js +909 -0
- package/src/components/toolbar/popup/submitforquote/AddToCartOptions.jsx +192 -0
- package/src/components/toolbar/popup/submitforquote/CustomerRequestsForm.jsx +96 -0
- package/src/components/toolbar/popup/submitforquote/SkipDesignerReview.jsx +54 -0
- package/src/components/toolbar/popup/submitforquote/StepDots.jsx +25 -0
- package/src/components/toolbar/popup/submitforquote/cart-choice.jsx +116 -0
- package/src/components/toolbar/popup/submitforquote/doorstyle-menus.js +38 -0
- package/src/components/toolbar/popup/submitforquote/index.jsx +698 -0
- package/src/components/toolbar/popup/submitforquote/styles.js +294 -0
- package/src/components/toolbar/popup/submitprompt/index.jsx +89 -0
- package/src/components/toolbar/popup/submitprompt/styles.js +42 -0
- package/src/components/toolbar/toolbar-button.jsx +90 -0
- package/src/components/toolbar/toolbar-load-button.jsx +36 -0
- package/src/components/toolbar/toolbar-save-button.jsx +32 -0
- package/src/components/tutorial-view/Modal.jsx +584 -0
- package/src/components/tutorial-view/styles.js +65 -0
- package/src/components/viewer2d/area.jsx +98 -0
- package/src/components/viewer2d/export.js +48 -0
- package/src/components/viewer2d/grids/grid-horizontal-streak.jsx +40 -0
- package/src/components/viewer2d/grids/grid-streak.jsx +32 -0
- package/src/components/viewer2d/grids/grid-vertical-streak.jsx +41 -0
- package/src/components/viewer2d/grids/grids.jsx +30 -0
- package/src/components/viewer2d/group.jsx +57 -0
- package/src/components/viewer2d/item.jsx +618 -0
- package/src/components/viewer2d/layer.jsx +214 -0
- package/src/components/viewer2d/line.jsx +1358 -0
- package/src/components/viewer2d/ruler.jsx +136 -0
- package/src/components/viewer2d/rulerDist.jsx +192 -0
- package/src/components/viewer2d/rulerX.jsx +141 -0
- package/src/components/viewer2d/rulerY.jsx +138 -0
- package/src/components/viewer2d/scene.jsx +94 -0
- package/src/components/viewer2d/snap.jsx +118 -0
- package/src/components/viewer2d/state.jsx +77 -0
- package/src/components/viewer2d/utils.js +195 -0
- package/src/components/viewer2d/vertex.jsx +76 -0
- package/src/components/viewer2d/viewer2d.jsx +1830 -0
- package/src/components/viewer3d/camera-controls-module/camera-controls.module.js +3078 -0
- package/src/components/viewer3d/dcm.js +226 -0
- package/src/components/viewer3d/fbm.js +383 -0
- package/src/components/viewer3d/front3D.jsx +63 -0
- package/src/components/viewer3d/grid-creator.js +25 -0
- package/src/components/viewer3d/grids/grid-horizontal-streak.js +41 -0
- package/src/components/viewer3d/grids/grid-streak.js +34 -0
- package/src/components/viewer3d/grids/grid-vertical-streak.js +42 -0
- package/src/components/viewer3d/libs/first-person-controls.js +70 -0
- package/src/components/viewer3d/libs/helvetiker_regular.typeface.js +1265 -0
- package/src/components/viewer3d/libs/mtl-loader.js +462 -0
- package/src/components/viewer3d/libs/obj-loader.js +653 -0
- package/src/components/viewer3d/libs/orbit-controls.js +945 -0
- package/src/components/viewer3d/libs/pointer-lock-controls.js +67 -0
- package/src/components/viewer3d/lrm.js +358 -0
- package/src/components/viewer3d/model.js +830 -0
- package/src/components/viewer3d/pointer-lock-navigation.js +140 -0
- package/src/components/viewer3d/ruler-utils/itemRect.jsx +91 -0
- package/src/components/viewer3d/ruler-utils/layer3D.jsx +528 -0
- package/src/components/viewer3d/ruler-utils/ruler3D.jsx +218 -0
- package/src/components/viewer3d/ruler-utils/scene3D.jsx +87 -0
- package/src/components/viewer3d/ruler-utils/state3D.jsx +25 -0
- package/src/components/viewer3d/scene-creator.js +5172 -0
- package/src/components/viewer3d/three-memory-cleaner.js +65 -0
- package/src/components/viewer3d/viewer3d-first-person.js +395 -0
- package/src/components/viewer3d/viewer3d.js +3376 -0
- package/src/components/wizardstep/button/styles.js +677 -0
- package/src/components/wizardstep/export.js +5 -0
- package/src/components/wizardstep/index.jsx +1372 -0
- package/src/components/wizardstep/styles.js +688 -0
- package/src/components/wizardstep/wizardstep-content-button.jsx +198 -0
- package/src/components/wizardstep/wizardstep-toggle-button.jsx +101 -0
- package/src/constants.js +731 -0
- package/src/hooks/useCheckCart.js +38 -0
- package/src/hooks/useGetPricesBySku.js +59 -0
- package/src/hooks/useValidateToken.js +181 -0
- package/src/index.js +32 -0
- package/src/models.js +541 -0
- package/src/plugins/SVGLoader.js +1991 -0
- package/src/plugins/autosave.js +39 -0
- package/src/plugins/console-debugger.js +36 -0
- package/src/plugins/export.js +11 -0
- package/src/plugins/keyboard.js +194 -0
- package/src/reducers/areas-reducer.js +13 -0
- package/src/reducers/export.js +39 -0
- package/src/reducers/groups-reducer.js +73 -0
- package/src/reducers/holes-reducer.js +125 -0
- package/src/reducers/items-reducer.js +286 -0
- package/src/reducers/lines-reducer.js +96 -0
- package/src/reducers/project-reducer.js +239 -0
- package/src/reducers/reducer.js +59 -0
- package/src/reducers/scene-reducer.js +41 -0
- package/src/reducers/user-reducer.js +30 -0
- package/src/reducers/vertices-reducer.js +34 -0
- package/src/reducers/viewer2d-reducer.js +81 -0
- package/src/reducers/viewer3d-reducer.js +65 -0
- package/src/shared-style.js +72 -0
- package/src/styles/export.js +7 -0
- package/src/translator/en.js +106 -0
- package/src/translator/it.js +80 -0
- package/src/translator/ru.js +80 -0
- package/src/translator/translator.js +81 -0
- package/src/utils/browser.js +36 -0
- package/src/utils/email-validator.js +5 -0
- package/src/utils/export.js +39 -0
- package/src/utils/geometry.js +2572 -0
- package/src/utils/get-edges-of-subgraphs.js +29 -0
- package/src/utils/graph-cycles.js +259 -0
- package/src/utils/graph-inner-cycles.js +49 -0
- package/src/utils/graph.js +147 -0
- package/src/utils/helper.js +431 -0
- package/src/utils/history.js +37 -0
- package/src/utils/id-broker.js +9 -0
- package/src/utils/logger.js +8 -0
- package/src/utils/math.js +51 -0
- package/src/utils/molding.js +973 -0
- package/src/utils/name-generator.js +5 -0
- package/src/utils/objects-utils.js +56 -0
- package/src/utils/phone-validator.js +4 -0
- package/src/utils/process-black-list.js +10 -0
- package/src/utils/react-if.jsx +20 -0
- package/src/utils/snap-scene.js +102 -0
- package/src/utils/snap.js +184 -0
- package/src/utils/threeCSG.es6.js +578 -0
- package/src/version.js +1 -0
- package/es/@history.js +0 -3
- package/es/@history.js.map +0 -1
- package/es/AppContext.js +0 -4
- package/es/AppContext.js.map +0 -1
- package/es/KitchenConfigurator.js +0 -1345
- package/es/KitchenConfigurator.js.map +0 -1
- package/es/KitchenConfiguratorApp.js +0 -532
- package/es/KitchenConfiguratorApp.js.map +0 -1
- package/es/actions/area-actions.js +0 -15
- package/es/actions/area-actions.js.map +0 -1
- package/es/actions/export.js +0 -26
- package/es/actions/export.js.map +0 -1
- package/es/actions/groups-actions.js +0 -90
- package/es/actions/groups-actions.js.map +0 -1
- package/es/actions/holes-actions.js +0 -120
- package/es/actions/holes-actions.js.map +0 -1
- package/es/actions/items-actions.js +0 -314
- package/es/actions/items-actions.js.map +0 -1
- package/es/actions/lines-actions.js +0 -83
- package/es/actions/lines-actions.js.map +0 -1
- package/es/actions/project-actions.js +0 -282
- package/es/actions/project-actions.js.map +0 -1
- package/es/actions/scene-actions.js +0 -34
- package/es/actions/scene-actions.js.map +0 -1
- package/es/actions/user-actions.js +0 -59
- package/es/actions/user-actions.js.map +0 -1
- package/es/actions/vertices-actions.js +0 -28
- package/es/actions/vertices-actions.js.map +0 -1
- package/es/actions/viewer2d-actions.js +0 -59
- package/es/actions/viewer2d-actions.js.map +0 -1
- package/es/actions/viewer3d-actions.js +0 -24
- package/es/actions/viewer3d-actions.js.map +0 -1
- package/es/catalog/areas/area/planner-element.js +0 -41
- package/es/catalog/areas/area/planner-element.js.map +0 -1
- package/es/catalog/catalog.js +0 -278
- package/es/catalog/catalog.js.map +0 -1
- package/es/catalog/factories/area-factory-3d.js +0 -183
- package/es/catalog/factories/area-factory-3d.js.map +0 -1
- package/es/catalog/factories/area-factory.js +0 -82
- package/es/catalog/factories/area-factory.js.map +0 -1
- package/es/catalog/factories/export.js +0 -8
- package/es/catalog/factories/export.js.map +0 -1
- package/es/catalog/factories/wall-factory-3d.js +0 -203
- package/es/catalog/factories/wall-factory-3d.js.map +0 -1
- package/es/catalog/factories/wall-factory.js +0 -269
- package/es/catalog/factories/wall-factory.js.map +0 -1
- package/es/catalog/holes/door-closet/planner-element.js +0 -223
- package/es/catalog/holes/door-closet/planner-element.js.map +0 -1
- package/es/catalog/holes/door-double/planner-element.js +0 -316
- package/es/catalog/holes/door-double/planner-element.js.map +0 -1
- package/es/catalog/holes/door-exterior/planner-element.js +0 -216
- package/es/catalog/holes/door-exterior/planner-element.js.map +0 -1
- package/es/catalog/holes/door-interior/planner-element.js +0 -228
- package/es/catalog/holes/door-interior/planner-element.js.map +0 -1
- package/es/catalog/holes/door-panic/planner-element.js +0 -504
- package/es/catalog/holes/door-panic/planner-element.js.map +0 -1
- package/es/catalog/holes/door-panic-double/planner-element.js +0 -464
- package/es/catalog/holes/door-panic-double/planner-element.js.map +0 -1
- package/es/catalog/holes/door-sliding/planner-element.js +0 -226
- package/es/catalog/holes/door-sliding/planner-element.js.map +0 -1
- package/es/catalog/holes/doorway-framed/planner-element.js +0 -146
- package/es/catalog/holes/doorway-framed/planner-element.js.map +0 -1
- package/es/catalog/holes/doorway-frameless/planner-element.js +0 -105
- package/es/catalog/holes/doorway-frameless/planner-element.js.map +0 -1
- package/es/catalog/holes/window-clear/planner-element.js +0 -167
- package/es/catalog/holes/window-clear/planner-element.js.map +0 -1
- package/es/catalog/holes/window-cross/planner-element.js +0 -166
- package/es/catalog/holes/window-cross/planner-element.js.map +0 -1
- package/es/catalog/holes/window-double-hung/planner-element.js +0 -304
- package/es/catalog/holes/window-double-hung/planner-element.js.map +0 -1
- package/es/catalog/holes/window-vertical/planner-element.js +0 -277
- package/es/catalog/holes/window-vertical/planner-element.js.map +0 -1
- package/es/catalog/lines/wall/planner-element.js +0 -71
- package/es/catalog/lines/wall/planner-element.js.map +0 -1
- package/es/catalog/molding/molding-dcm/planner-element.js +0 -30
- package/es/catalog/molding/molding-dcm/planner-element.js.map +0 -1
- package/es/catalog/molding/molding-fbm/planner-element.js +0 -30
- package/es/catalog/molding/molding-fbm/planner-element.js.map +0 -1
- package/es/catalog/molding/molding-lrm/planner-element.js +0 -30
- package/es/catalog/molding/molding-lrm/planner-element.js.map +0 -1
- package/es/catalog/properties/export.js +0 -22
- package/es/catalog/properties/export.js.map +0 -1
- package/es/catalog/properties/property-checkbox.js +0 -72
- package/es/catalog/properties/property-checkbox.js.map +0 -1
- package/es/catalog/properties/property-color.js +0 -40
- package/es/catalog/properties/property-color.js.map +0 -1
- package/es/catalog/properties/property-enum.js +0 -56
- package/es/catalog/properties/property-enum.js.map +0 -1
- package/es/catalog/properties/property-hidden.js +0 -20
- package/es/catalog/properties/property-hidden.js.map +0 -1
- package/es/catalog/properties/property-lenght-measure.js +0 -102
- package/es/catalog/properties/property-lenght-measure.js.map +0 -1
- package/es/catalog/properties/property-length-measure.js +0 -86
- package/es/catalog/properties/property-length-measure.js.map +0 -1
- package/es/catalog/properties/property-length-measure_hole.js +0 -102
- package/es/catalog/properties/property-length-measure_hole.js.map +0 -1
- package/es/catalog/properties/property-number.js +0 -49
- package/es/catalog/properties/property-number.js.map +0 -1
- package/es/catalog/properties/property-read-only.js +0 -27
- package/es/catalog/properties/property-read-only.js.map +0 -1
- package/es/catalog/properties/property-string.js +0 -49
- package/es/catalog/properties/property-string.js.map +0 -1
- package/es/catalog/properties/property-toggle.js +0 -40
- package/es/catalog/properties/property-toggle.js.map +0 -1
- package/es/catalog/properties/shared-property-style.js +0 -15
- package/es/catalog/properties/shared-property-style.js.map +0 -1
- package/es/catalog/utils/FuseUtils.js +0 -83
- package/es/catalog/utils/FuseUtils.js.map +0 -1
- package/es/catalog/utils/exporter.js +0 -149
- package/es/catalog/utils/exporter.js.map +0 -1
- package/es/catalog/utils/geom-utils.js +0 -190
- package/es/catalog/utils/geom-utils.js.map +0 -1
- package/es/catalog/utils/item-loader.js +0 -1522
- package/es/catalog/utils/item-loader.js.map +0 -1
- package/es/catalog/utils/load-obj.js +0 -92
- package/es/catalog/utils/load-obj.js.map +0 -1
- package/es/catalog/utils/mtl-loader.js +0 -358
- package/es/catalog/utils/mtl-loader.js.map +0 -1
- package/es/catalog/utils/obj-loader.js +0 -477
- package/es/catalog/utils/obj-loader.js.map +0 -1
- package/es/class/FuseUtils.js +0 -83
- package/es/class/FuseUtils.js.map +0 -1
- package/es/class/area.js +0 -146
- package/es/class/area.js.map +0 -1
- package/es/class/export.js +0 -25
- package/es/class/export.js.map +0 -1
- package/es/class/group.js +0 -441
- package/es/class/group.js.map +0 -1
- package/es/class/guide.js +0 -63
- package/es/class/guide.js.map +0 -1
- package/es/class/hole.js +0 -931
- package/es/class/hole.js.map +0 -1
- package/es/class/item.js +0 -1888
- package/es/class/item.js.map +0 -1
- package/es/class/layer.js +0 -668
- package/es/class/layer.js.map +0 -1
- package/es/class/line.js +0 -1290
- package/es/class/line.js.map +0 -1
- package/es/class/project.js +0 -823
- package/es/class/project.js.map +0 -1
- package/es/class/vertex.js +0 -267
- package/es/class/vertex.js.map +0 -1
- package/es/components/atoms/Snackbar/index.js +0 -50
- package/es/components/atoms/Snackbar/index.js.map +0 -1
- package/es/components/atoms/radio-button/index.js +0 -26
- package/es/components/atoms/radio-button/index.js.map +0 -1
- package/es/components/atoms/radio-button/styles.js +0 -5
- package/es/components/atoms/radio-button/styles.js.map +0 -1
- package/es/components/button/MainButton.js +0 -92
- package/es/components/button/MainButton.js.map +0 -1
- package/es/components/button/ToggleMeasureButton.js +0 -56
- package/es/components/button/ToggleMeasureButton.js.map +0 -1
- package/es/components/catalog-view/catalog-breadcrumb.js +0 -53
- package/es/components/catalog-view/catalog-breadcrumb.js.map +0 -1
- package/es/components/catalog-view/catalog-item.js +0 -226
- package/es/components/catalog-view/catalog-item.js.map +0 -1
- package/es/components/catalog-view/catalog-list.js +0 -182
- package/es/components/catalog-view/catalog-list.js.map +0 -1
- package/es/components/catalog-view/catalog-page-item.js +0 -130
- package/es/components/catalog-view/catalog-page-item.js.map +0 -1
- package/es/components/catalog-view/catalog-turn-back-page-item.js +0 -106
- package/es/components/catalog-view/catalog-turn-back-page-item.js.map +0 -1
- package/es/components/configurator/custom-configurator.js +0 -94
- package/es/components/configurator/custom-configurator.js.map +0 -1
- package/es/components/configurator/project-configurator.js +0 -131
- package/es/components/configurator/project-configurator.js.map +0 -1
- package/es/components/content.js +0 -123
- package/es/components/content.js.map +0 -1
- package/es/components/export.js +0 -24
- package/es/components/export.js.map +0 -1
- package/es/components/firstsetting/button/styles.js +0 -27
- package/es/components/firstsetting/button/styles.js.map +0 -1
- package/es/components/firstsetting/export.js +0 -9
- package/es/components/firstsetting/export.js.map +0 -1
- package/es/components/firstsetting/firstsetting-content-button.js +0 -217
- package/es/components/firstsetting/firstsetting-content-button.js.map +0 -1
- package/es/components/firstsetting/firstsetting-toggle-button.js +0 -126
- package/es/components/firstsetting/firstsetting-toggle-button.js.map +0 -1
- package/es/components/firstsetting/firstsetting.js +0 -626
- package/es/components/firstsetting/firstsetting.js.map +0 -1
- package/es/components/footerbar/button/ControlButton.js +0 -72
- package/es/components/footerbar/button/ControlButton.js.map +0 -1
- package/es/components/footerbar/button/DirectionButton.js +0 -69
- package/es/components/footerbar/button/DirectionButton.js.map +0 -1
- package/es/components/footerbar/button/DirectionPanSpinButton.js +0 -50
- package/es/components/footerbar/button/DirectionPanSpinButton.js.map +0 -1
- package/es/components/footerbar/button/ToggleButton.js +0 -76
- package/es/components/footerbar/button/ToggleButton.js.map +0 -1
- package/es/components/footerbar/button/ToggleConvertButton.js +0 -73
- package/es/components/footerbar/button/ToggleConvertButton.js.map +0 -1
- package/es/components/footerbar/button/ToggleMeasureButton.js +0 -52
- package/es/components/footerbar/button/ToggleMeasureButton.js.map +0 -1
- package/es/components/footerbar/button/styles.js +0 -22
- package/es/components/footerbar/button/styles.js.map +0 -1
- package/es/components/footerbar/export.js +0 -9
- package/es/components/footerbar/export.js.map +0 -1
- package/es/components/footerbar/footer-content-button.js +0 -217
- package/es/components/footerbar/footer-content-button.js.map +0 -1
- package/es/components/footerbar/footer-toggle-button.js +0 -126
- package/es/components/footerbar/footer-toggle-button.js.map +0 -1
- package/es/components/footerbar/footerbar.js +0 -801
- package/es/components/footerbar/footerbar.js.map +0 -1
- package/es/components/footerbar/styles.js +0 -34
- package/es/components/footerbar/styles.js.map +0 -1
- package/es/components/header/button/MenuButton.js +0 -70
- package/es/components/header/button/MenuButton.js.map +0 -1
- package/es/components/header/button/SaveButton.js +0 -48
- package/es/components/header/button/SaveButton.js.map +0 -1
- package/es/components/header/button/styles.js +0 -59
- package/es/components/header/button/styles.js.map +0 -1
- package/es/components/header/export.js +0 -5
- package/es/components/header/export.js.map +0 -1
- package/es/components/header/header.js +0 -550
- package/es/components/header/header.js.map +0 -1
- package/es/components/header/styles.js +0 -41
- package/es/components/header/styles.js.map +0 -1
- package/es/components/login/Login.js +0 -86
- package/es/components/login/Login.js.map +0 -1
- package/es/components/login/LoginForm/index.js +0 -132
- package/es/components/login/LoginForm/index.js.map +0 -1
- package/es/components/login/Register.js +0 -96
- package/es/components/login/Register.js.map +0 -1
- package/es/components/login/RegisterForm/index.js +0 -230
- package/es/components/login/RegisterForm/index.js.map +0 -1
- package/es/components/login/jwtService.js +0 -232
- package/es/components/login/jwtService.js.map +0 -1
- package/es/components/molecules/slider/index.js +0 -13
- package/es/components/molecules/slider/index.js.map +0 -1
- package/es/components/molecules/slider/styles.js +0 -2
- package/es/components/molecules/slider/styles.js.map +0 -1
- package/es/components/myprojects/export.js +0 -5
- package/es/components/myprojects/export.js.map +0 -1
- package/es/components/myprojects/index.js +0 -446
- package/es/components/myprojects/index.js.map +0 -1
- package/es/components/myprojects/styles.js +0 -24
- package/es/components/myprojects/styles.js.map +0 -1
- package/es/components/sidebar/custom-accordion.js +0 -38
- package/es/components/sidebar/custom-accordion.js.map +0 -1
- package/es/components/sidebar/export.js +0 -14
- package/es/components/sidebar/export.js.map +0 -1
- package/es/components/sidebar/panel-element-editor/attributes-editor/attributes-editor.js +0 -65
- package/es/components/sidebar/panel-element-editor/attributes-editor/attributes-editor.js.map +0 -1
- package/es/components/sidebar/panel-element-editor/attributes-editor/confirm-popup.js +0 -116
- package/es/components/sidebar/panel-element-editor/attributes-editor/confirm-popup.js.map +0 -1
- package/es/components/sidebar/panel-element-editor/attributes-editor/hole-attributes-editor.js +0 -126
- package/es/components/sidebar/panel-element-editor/attributes-editor/hole-attributes-editor.js.map +0 -1
- package/es/components/sidebar/panel-element-editor/attributes-editor/item-attributes-editor.js +0 -251
- package/es/components/sidebar/panel-element-editor/attributes-editor/item-attributes-editor.js.map +0 -1
- package/es/components/sidebar/panel-element-editor/attributes-editor/line-attributes-editor.js +0 -75
- package/es/components/sidebar/panel-element-editor/attributes-editor/line-attributes-editor.js.map +0 -1
- package/es/components/sidebar/panel-element-editor/element-editor.js +0 -878
- package/es/components/sidebar/panel-element-editor/element-editor.js.map +0 -1
- package/es/components/sidebar/panel-element-editor/multi-elements-editor.js +0 -2
- package/es/components/sidebar/panel-element-editor/multi-elements-editor.js.map +0 -1
- package/es/components/sidebar/panel-element-editor/panel-element-editor.js +0 -49
- package/es/components/sidebar/panel-element-editor/panel-element-editor.js.map +0 -1
- package/es/components/sidebar/panel-element-editor/panel-multi-elements-editor.js +0 -118
- package/es/components/sidebar/panel-element-editor/panel-multi-elements-editor.js.map +0 -1
- package/es/components/sidebar/panel-group-editor.js +0 -211
- package/es/components/sidebar/panel-group-editor.js.map +0 -1
- package/es/components/sidebar/panel-groups.js +0 -267
- package/es/components/sidebar/panel-groups.js.map +0 -1
- package/es/components/sidebar/panel-guides.js +0 -185
- package/es/components/sidebar/panel-guides.js.map +0 -1
- package/es/components/sidebar/panel-layer-elements.js +0 -251
- package/es/components/sidebar/panel-layer-elements.js.map +0 -1
- package/es/components/sidebar/panel-layers.js +0 -340
- package/es/components/sidebar/panel-layers.js.map +0 -1
- package/es/components/sidebar/panel.js +0 -103
- package/es/components/sidebar/panel.js.map +0 -1
- package/es/components/sidebar/sidebar.js +0 -109
- package/es/components/sidebar/sidebar.js.map +0 -1
- package/es/components/sidebar/toolbar-panel.js +0 -164
- package/es/components/sidebar/toolbar-panel.js.map +0 -1
- package/es/components/sign/export.js +0 -6
- package/es/components/sign/export.js.map +0 -1
- package/es/components/sign/main/index.js +0 -560
- package/es/components/sign/main/index.js.map +0 -1
- package/es/components/sign/main/styles.js +0 -20
- package/es/components/sign/main/styles.js.map +0 -1
- package/es/components/style/button.js +0 -114
- package/es/components/style/button.js.map +0 -1
- package/es/components/style/cancel-button.js +0 -23
- package/es/components/style/cancel-button.js.map +0 -1
- package/es/components/style/content-container.js +0 -34
- package/es/components/style/content-container.js.map +0 -1
- package/es/components/style/content-title.js +0 -30
- package/es/components/style/content-title.js.map +0 -1
- package/es/components/style/delete-button.js +0 -26
- package/es/components/style/delete-button.js.map +0 -1
- package/es/components/style/export.js +0 -32
- package/es/components/style/export.js.map +0 -1
- package/es/components/style/form-block.js +0 -25
- package/es/components/style/form-block.js.map +0 -1
- package/es/components/style/form-color-input.js +0 -28
- package/es/components/style/form-color-input.js.map +0 -1
- package/es/components/style/form-label.js +0 -27
- package/es/components/style/form-label.js.map +0 -1
- package/es/components/style/form-number-input.js +0 -190
- package/es/components/style/form-number-input.js.map +0 -1
- package/es/components/style/form-number-input_2.js +0 -207
- package/es/components/style/form-number-input_2.js.map +0 -1
- package/es/components/style/form-select.js +0 -21
- package/es/components/style/form-select.js.map +0 -1
- package/es/components/style/form-slider.js +0 -46
- package/es/components/style/form-slider.js.map +0 -1
- package/es/components/style/form-submit-button.js +0 -27
- package/es/components/style/form-submit-button.js.map +0 -1
- package/es/components/style/form-text-input.js +0 -77
- package/es/components/style/form-text-input.js.map +0 -1
- package/es/components/toolbar/button/ControlButton.js +0 -69
- package/es/components/toolbar/button/ControlButton.js.map +0 -1
- package/es/components/toolbar/button/DirectionButton.js +0 -50
- package/es/components/toolbar/button/DirectionButton.js.map +0 -1
- package/es/components/toolbar/button/RightButton.js +0 -133
- package/es/components/toolbar/button/RightButton.js.map +0 -1
- package/es/components/toolbar/button/ToggleButton.js +0 -59
- package/es/components/toolbar/button/ToggleButton.js.map +0 -1
- package/es/components/toolbar/button/index.js +0 -88
- package/es/components/toolbar/button/index.js.map +0 -1
- package/es/components/toolbar/button/styles.js +0 -14
- package/es/components/toolbar/button/styles.js.map +0 -1
- package/es/components/toolbar/components/DoorStyleMenu.js +0 -105
- package/es/components/toolbar/components/DoorStyleMenu.js.map +0 -1
- package/es/components/toolbar/components/Pricing.js +0 -101
- package/es/components/toolbar/components/Pricing.js.map +0 -1
- package/es/components/toolbar/components/ReviewForQuote.js +0 -476
- package/es/components/toolbar/components/ReviewForQuote.js.map +0 -1
- package/es/components/toolbar/export.js +0 -14
- package/es/components/toolbar/export.js.map +0 -1
- package/es/components/toolbar/main/Alert.js +0 -125
- package/es/components/toolbar/main/Alert.js.map +0 -1
- package/es/components/toolbar/main/TakePictureModal.js +0 -100
- package/es/components/toolbar/main/TakePictureModal.js.map +0 -1
- package/es/components/toolbar/main/confirm-popup.js +0 -88
- package/es/components/toolbar/main/confirm-popup.js.map +0 -1
- package/es/components/toolbar/main/index.js +0 -4612
- package/es/components/toolbar/main/index.js.map +0 -1
- package/es/components/toolbar/main/myComponents.js +0 -118
- package/es/components/toolbar/main/myComponents.js.map +0 -1
- package/es/components/toolbar/main/styles.js +0 -64
- package/es/components/toolbar/main/styles.js.map +0 -1
- package/es/components/toolbar/plugin-item.js +0 -150
- package/es/components/toolbar/plugin-item.js.map +0 -1
- package/es/components/toolbar/popup/appliance/appliance-category/index.js +0 -77
- package/es/components/toolbar/popup/appliance/appliance-category/index.js.map +0 -1
- package/es/components/toolbar/popup/appliance/choose-appliance/index.js +0 -76
- package/es/components/toolbar/popup/appliance/choose-appliance/index.js.map +0 -1
- package/es/components/toolbar/popup/appliance/index.js +0 -81
- package/es/components/toolbar/popup/appliance/index.js.map +0 -1
- package/es/components/toolbar/popup/autosaveprompt/index.js +0 -91
- package/es/components/toolbar/popup/autosaveprompt/index.js.map +0 -1
- package/es/components/toolbar/popup/autosaveprompt/styles.js +0 -9
- package/es/components/toolbar/popup/autosaveprompt/styles.js.map +0 -1
- package/es/components/toolbar/popup/cabinet/cabinet-category/index.js +0 -77
- package/es/components/toolbar/popup/cabinet/cabinet-category/index.js.map +0 -1
- package/es/components/toolbar/popup/cabinet/choose-product/index.js +0 -98
- package/es/components/toolbar/popup/cabinet/choose-product/index.js.map +0 -1
- package/es/components/toolbar/popup/cabinet/index.js +0 -83
- package/es/components/toolbar/popup/cabinet/index.js.map +0 -1
- package/es/components/toolbar/popup/doorStyle/choose-style/index.js +0 -50
- package/es/components/toolbar/popup/doorStyle/choose-style/index.js.map +0 -1
- package/es/components/toolbar/popup/doorStyle/index.js +0 -61
- package/es/components/toolbar/popup/doorStyle/index.js.map +0 -1
- package/es/components/toolbar/popup/doorStyle/style-category/index.js +0 -143
- package/es/components/toolbar/popup/doorStyle/style-category/index.js.map +0 -1
- package/es/components/toolbar/popup/downloadsummary/downloadSummaryContext.js +0 -3
- package/es/components/toolbar/popup/downloadsummary/downloadSummaryContext.js.map +0 -1
- package/es/components/toolbar/popup/downloadsummary/downloadSummaryTemp.js +0 -119
- package/es/components/toolbar/popup/downloadsummary/downloadSummaryTemp.js.map +0 -1
- package/es/components/toolbar/popup/downloadsummary/index.js +0 -564
- package/es/components/toolbar/popup/downloadsummary/index.js.map +0 -1
- package/es/components/toolbar/popup/downloadsummary/show2D/show2DView.js +0 -51
- package/es/components/toolbar/popup/downloadsummary/show2D/show2DView.js.map +0 -1
- package/es/components/toolbar/popup/downloadsummary/show2D/viewer2DDownLoad.js +0 -191
- package/es/components/toolbar/popup/downloadsummary/show2D/viewer2DDownLoad.js.map +0 -1
- package/es/components/toolbar/popup/downloadsummary/show3D/show3DView.js +0 -245
- package/es/components/toolbar/popup/downloadsummary/show3D/show3DView.js.map +0 -1
- package/es/components/toolbar/popup/downloadsummary/show3D/viewer3DDownLoad.js +0 -1758
- package/es/components/toolbar/popup/downloadsummary/show3D/viewer3DDownLoad.js.map +0 -1
- package/es/components/toolbar/popup/downloadsummary/showCabinetInfo.js +0 -87
- package/es/components/toolbar/popup/downloadsummary/showCabinetInfo.js.map +0 -1
- package/es/components/toolbar/popup/downloadsummary/showElevation/showElevationView.js +0 -116
- package/es/components/toolbar/popup/downloadsummary/showElevation/showElevationView.js.map +0 -1
- package/es/components/toolbar/popup/downloadsummary/showElevation/viewer3DElevationDownload.js +0 -1710
- package/es/components/toolbar/popup/downloadsummary/showElevation/viewer3DElevationDownload.js.map +0 -1
- package/es/components/toolbar/popup/downloadsummary/showElevation/viewerElevationDownload.js +0 -175
- package/es/components/toolbar/popup/downloadsummary/showElevation/viewerElevationDownload.js.map +0 -1
- package/es/components/toolbar/popup/downloadsummary/showWarranty.js +0 -106
- package/es/components/toolbar/popup/downloadsummary/showWarranty.js.map +0 -1
- package/es/components/toolbar/popup/downloadsummary/styles.js +0 -40
- package/es/components/toolbar/popup/downloadsummary/styles.js.map +0 -1
- package/es/components/toolbar/popup/finishingtouch/category/index.js +0 -35
- package/es/components/toolbar/popup/finishingtouch/category/index.js.map +0 -1
- package/es/components/toolbar/popup/finishingtouch/index.js +0 -47
- package/es/components/toolbar/popup/finishingtouch/index.js.map +0 -1
- package/es/components/toolbar/popup/finishingtouch/material-edit.js +0 -156
- package/es/components/toolbar/popup/finishingtouch/material-edit.js.map +0 -1
- package/es/components/toolbar/popup/finishingtouch/product/index.js +0 -56
- package/es/components/toolbar/popup/finishingtouch/product/index.js.map +0 -1
- package/es/components/toolbar/popup/floorplan/choose-floor/confirm-popup.js +0 -116
- package/es/components/toolbar/popup/floorplan/choose-floor/confirm-popup.js.map +0 -1
- package/es/components/toolbar/popup/floorplan/choose-floor/index.js +0 -246
- package/es/components/toolbar/popup/floorplan/choose-floor/index.js.map +0 -1
- package/es/components/toolbar/popup/floorplan/choose-floor/styles.js +0 -11
- package/es/components/toolbar/popup/floorplan/choose-floor/styles.js.map +0 -1
- package/es/components/toolbar/popup/floorplan/floor-category/index.js +0 -90
- package/es/components/toolbar/popup/floorplan/floor-category/index.js.map +0 -1
- package/es/components/toolbar/popup/floorplan/index.js +0 -49
- package/es/components/toolbar/popup/floorplan/index.js.map +0 -1
- package/es/components/toolbar/popup/index.js +0 -188
- package/es/components/toolbar/popup/index.js.map +0 -1
- package/es/components/toolbar/popup/newproject/index.js +0 -67
- package/es/components/toolbar/popup/newproject/index.js.map +0 -1
- package/es/components/toolbar/popup/newproject/styles.js +0 -9
- package/es/components/toolbar/popup/newproject/styles.js.map +0 -1
- package/es/components/toolbar/popup/product/appliance.js +0 -65
- package/es/components/toolbar/popup/product/appliance.js.map +0 -1
- package/es/components/toolbar/popup/product/cabinetproduct.js +0 -25
- package/es/components/toolbar/popup/product/cabinetproduct.js.map +0 -1
- package/es/components/toolbar/popup/product/doorstyle.js +0 -50
- package/es/components/toolbar/popup/product/doorstyle.js.map +0 -1
- package/es/components/toolbar/popup/product/doorstyleproduct.js +0 -51
- package/es/components/toolbar/popup/product/doorstyleproduct.js.map +0 -1
- package/es/components/toolbar/popup/product/floor.js +0 -52
- package/es/components/toolbar/popup/product/floor.js.map +0 -1
- package/es/components/toolbar/popup/product/floorproduct.js +0 -61
- package/es/components/toolbar/popup/product/floorproduct.js.map +0 -1
- package/es/components/toolbar/popup/product/index.js +0 -52
- package/es/components/toolbar/popup/product/index.js.map +0 -1
- package/es/components/toolbar/popup/product/primary.js +0 -63
- package/es/components/toolbar/popup/product/primary.js.map +0 -1
- package/es/components/toolbar/popup/product/productline.js +0 -120
- package/es/components/toolbar/popup/product/productline.js.map +0 -1
- package/es/components/toolbar/popup/product/reviewItem.js +0 -338
- package/es/components/toolbar/popup/product/reviewItem.js.map +0 -1
- package/es/components/toolbar/popup/product/reviewMolding.js +0 -282
- package/es/components/toolbar/popup/product/reviewMolding.js.map +0 -1
- package/es/components/toolbar/popup/product/styles.js +0 -71
- package/es/components/toolbar/popup/product/styles.js.map +0 -1
- package/es/components/toolbar/popup/savedesign/FullPictureForm.js +0 -161
- package/es/components/toolbar/popup/savedesign/FullPictureForm.js.map +0 -1
- package/es/components/toolbar/popup/savedesign/index.js +0 -508
- package/es/components/toolbar/popup/savedesign/index.js.map +0 -1
- package/es/components/toolbar/popup/savedesign/styles.js +0 -19
- package/es/components/toolbar/popup/savedesign/styles.js.map +0 -1
- package/es/components/toolbar/popup/setDoorStyleOption/index.js +0 -57
- package/es/components/toolbar/popup/setDoorStyleOption/index.js.map +0 -1
- package/es/components/toolbar/popup/styles.js +0 -98
- package/es/components/toolbar/popup/styles.js.map +0 -1
- package/es/components/toolbar/popup/submitforquote/AddToCartOptions.js +0 -157
- package/es/components/toolbar/popup/submitforquote/AddToCartOptions.js.map +0 -1
- package/es/components/toolbar/popup/submitforquote/CustomerRequestsForm.js +0 -85
- package/es/components/toolbar/popup/submitforquote/CustomerRequestsForm.js.map +0 -1
- package/es/components/toolbar/popup/submitforquote/SkipDesignerReview.js +0 -36
- package/es/components/toolbar/popup/submitforquote/SkipDesignerReview.js.map +0 -1
- package/es/components/toolbar/popup/submitforquote/StepDots.js +0 -33
- package/es/components/toolbar/popup/submitforquote/StepDots.js.map +0 -1
- package/es/components/toolbar/popup/submitforquote/cart-choice.js +0 -132
- package/es/components/toolbar/popup/submitforquote/cart-choice.js.map +0 -1
- package/es/components/toolbar/popup/submitforquote/doorstyle-menus.js +0 -43
- package/es/components/toolbar/popup/submitforquote/doorstyle-menus.js.map +0 -1
- package/es/components/toolbar/popup/submitforquote/index.js +0 -690
- package/es/components/toolbar/popup/submitforquote/index.js.map +0 -1
- package/es/components/toolbar/popup/submitforquote/styles.js +0 -31
- package/es/components/toolbar/popup/submitforquote/styles.js.map +0 -1
- package/es/components/toolbar/popup/submitprompt/index.js +0 -71
- package/es/components/toolbar/popup/submitprompt/index.js.map +0 -1
- package/es/components/toolbar/popup/submitprompt/styles.js +0 -9
- package/es/components/toolbar/popup/submitprompt/styles.js.map +0 -1
- package/es/components/toolbar/toolbar-button.js +0 -105
- package/es/components/toolbar/toolbar-button.js.map +0 -1
- package/es/components/toolbar/toolbar-load-button.js +0 -29
- package/es/components/toolbar/toolbar-load-button.js.map +0 -1
- package/es/components/toolbar/toolbar-save-button.js +0 -27
- package/es/components/toolbar/toolbar-save-button.js.map +0 -1
- package/es/components/tutorial-view/Modal.js +0 -498
- package/es/components/tutorial-view/Modal.js.map +0 -1
- package/es/components/tutorial-view/styles.js +0 -6
- package/es/components/tutorial-view/styles.js.map +0 -1
- package/es/components/viewer2d/area.js +0 -83
- package/es/components/viewer2d/area.js.map +0 -1
- package/es/components/viewer2d/export.js +0 -32
- package/es/components/viewer2d/export.js.map +0 -1
- package/es/components/viewer2d/grids/grid-horizontal-streak.js +0 -38
- package/es/components/viewer2d/grids/grid-horizontal-streak.js.map +0 -1
- package/es/components/viewer2d/grids/grid-streak.js +0 -38
- package/es/components/viewer2d/grids/grid-streak.js.map +0 -1
- package/es/components/viewer2d/grids/grid-vertical-streak.js +0 -38
- package/es/components/viewer2d/grids/grid-vertical-streak.js.map +0 -1
- package/es/components/viewer2d/grids/grids.js +0 -36
- package/es/components/viewer2d/grids/grids.js.map +0 -1
- package/es/components/viewer2d/group.js +0 -54
- package/es/components/viewer2d/group.js.map +0 -1
- package/es/components/viewer2d/item.js +0 -514
- package/es/components/viewer2d/item.js.map +0 -1
- package/es/components/viewer2d/layer.js +0 -165
- package/es/components/viewer2d/layer.js.map +0 -1
- package/es/components/viewer2d/line.js +0 -889
- package/es/components/viewer2d/line.js.map +0 -1
- package/es/components/viewer2d/ruler.js +0 -101
- package/es/components/viewer2d/ruler.js.map +0 -1
- package/es/components/viewer2d/rulerDist.js +0 -147
- package/es/components/viewer2d/rulerDist.js.map +0 -1
- package/es/components/viewer2d/rulerX.js +0 -152
- package/es/components/viewer2d/rulerX.js.map +0 -1
- package/es/components/viewer2d/rulerY.js +0 -154
- package/es/components/viewer2d/rulerY.js.map +0 -1
- package/es/components/viewer2d/scene.js +0 -141
- package/es/components/viewer2d/scene.js.map +0 -1
- package/es/components/viewer2d/snap.js +0 -75
- package/es/components/viewer2d/snap.js.map +0 -1
- package/es/components/viewer2d/state.js +0 -79
- package/es/components/viewer2d/state.js.map +0 -1
- package/es/components/viewer2d/utils.js +0 -163
- package/es/components/viewer2d/utils.js.map +0 -1
- package/es/components/viewer2d/vertex.js +0 -67
- package/es/components/viewer2d/vertex.js.map +0 -1
- package/es/components/viewer2d/viewer2d.js +0 -1402
- package/es/components/viewer2d/viewer2d.js.map +0 -1
- package/es/components/viewer3d/camera-controls-module/camera-controls.module.js +0 -2593
- package/es/components/viewer3d/camera-controls-module/camera-controls.module.js.map +0 -1
- package/es/components/viewer3d/dcm.js +0 -402
- package/es/components/viewer3d/dcm.js.map +0 -1
- package/es/components/viewer3d/fbm.js +0 -415
- package/es/components/viewer3d/fbm.js.map +0 -1
- package/es/components/viewer3d/front3D.js +0 -67
- package/es/components/viewer3d/front3D.js.map +0 -1
- package/es/components/viewer3d/grid-creator.js +0 -26
- package/es/components/viewer3d/grid-creator.js.map +0 -1
- package/es/components/viewer3d/grids/grid-horizontal-streak.js +0 -37
- package/es/components/viewer3d/grids/grid-horizontal-streak.js.map +0 -1
- package/es/components/viewer3d/grids/grid-streak.js +0 -28
- package/es/components/viewer3d/grids/grid-streak.js.map +0 -1
- package/es/components/viewer3d/grids/grid-vertical-streak.js +0 -37
- package/es/components/viewer3d/grids/grid-vertical-streak.js.map +0 -1
- package/es/components/viewer3d/libs/first-person-controls.js +0 -68
- package/es/components/viewer3d/libs/first-person-controls.js.map +0 -1
- package/es/components/viewer3d/libs/helvetiker_regular.typeface.js +0 -1282
- package/es/components/viewer3d/libs/helvetiker_regular.typeface.js.map +0 -1
- package/es/components/viewer3d/libs/mtl-loader.js +0 -358
- package/es/components/viewer3d/libs/mtl-loader.js.map +0 -1
- package/es/components/viewer3d/libs/obj-loader.js +0 -463
- package/es/components/viewer3d/libs/obj-loader.js.map +0 -1
- package/es/components/viewer3d/libs/orbit-controls.js +0 -699
- package/es/components/viewer3d/libs/orbit-controls.js.map +0 -1
- package/es/components/viewer3d/libs/pointer-lock-controls.js +0 -46
- package/es/components/viewer3d/libs/pointer-lock-controls.js.map +0 -1
- package/es/components/viewer3d/lrm.js +0 -306
- package/es/components/viewer3d/lrm.js.map +0 -1
- package/es/components/viewer3d/model.js +0 -709
- package/es/components/viewer3d/model.js.map +0 -1
- package/es/components/viewer3d/pointer-lock-navigation.js +0 -116
- package/es/components/viewer3d/pointer-lock-navigation.js.map +0 -1
- package/es/components/viewer3d/ruler-utils/itemRect.js +0 -62
- package/es/components/viewer3d/ruler-utils/itemRect.js.map +0 -1
- package/es/components/viewer3d/ruler-utils/layer3D.js +0 -496
- package/es/components/viewer3d/ruler-utils/layer3D.js.map +0 -1
- package/es/components/viewer3d/ruler-utils/ruler3D.js +0 -228
- package/es/components/viewer3d/ruler-utils/ruler3D.js.map +0 -1
- package/es/components/viewer3d/ruler-utils/scene3D.js +0 -62
- package/es/components/viewer3d/ruler-utils/scene3D.js.map +0 -1
- package/es/components/viewer3d/ruler-utils/state3D.js +0 -19
- package/es/components/viewer3d/ruler-utils/state3D.js.map +0 -1
- package/es/components/viewer3d/scene-creator.js +0 -3607
- package/es/components/viewer3d/scene-creator.js.map +0 -1
- package/es/components/viewer3d/three-memory-cleaner.js +0 -52
- package/es/components/viewer3d/three-memory-cleaner.js.map +0 -1
- package/es/components/viewer3d/viewer3d-first-person.js +0 -316
- package/es/components/viewer3d/viewer3d-first-person.js.map +0 -1
- package/es/components/viewer3d/viewer3d.js +0 -2504
- package/es/components/viewer3d/viewer3d.js.map +0 -1
- package/es/components/wizardstep/button/styles.js +0 -60
- package/es/components/wizardstep/button/styles.js.map +0 -1
- package/es/components/wizardstep/export.js +0 -5
- package/es/components/wizardstep/export.js.map +0 -1
- package/es/components/wizardstep/index.js +0 -971
- package/es/components/wizardstep/index.js.map +0 -1
- package/es/components/wizardstep/styles.js +0 -61
- package/es/components/wizardstep/styles.js.map +0 -1
- package/es/components/wizardstep/wizardstep-content-button.js +0 -217
- package/es/components/wizardstep/wizardstep-content-button.js.map +0 -1
- package/es/components/wizardstep/wizardstep-toggle-button.js +0 -126
- package/es/components/wizardstep/wizardstep-toggle-button.js.map +0 -1
- package/es/constants.js +0 -637
- package/es/constants.js.map +0 -1
- package/es/hooks/useCheckCart.js +0 -53
- package/es/hooks/useCheckCart.js.map +0 -1
- package/es/hooks/useGetPricesBySku.js +0 -74
- package/es/hooks/useGetPricesBySku.js.map +0 -1
- package/es/hooks/useValidateToken.js +0 -201
- package/es/hooks/useValidateToken.js.map +0 -1
- package/es/index.js +0 -17
- package/es/index.js.map +0 -1
- package/es/models.js +0 -511
- package/es/models.js.map +0 -1
- package/es/plugins/SVGLoader.js +0 -1413
- package/es/plugins/SVGLoader.js.map +0 -1
- package/es/plugins/autosave.js +0 -34
- package/es/plugins/autosave.js.map +0 -1
- package/es/plugins/console-debugger.js +0 -38
- package/es/plugins/console-debugger.js.map +0 -1
- package/es/plugins/export.js +0 -10
- package/es/plugins/export.js.map +0 -1
- package/es/plugins/keyboard.js +0 -102
- package/es/plugins/keyboard.js.map +0 -1
- package/es/reducers/areas-reducer.js +0 -13
- package/es/reducers/areas-reducer.js.map +0 -1
- package/es/reducers/export.js +0 -26
- package/es/reducers/export.js.map +0 -1
- package/es/reducers/groups-reducer.js +0 -39
- package/es/reducers/groups-reducer.js.map +0 -1
- package/es/reducers/holes-reducer.js +0 -63
- package/es/reducers/holes-reducer.js.map +0 -1
- package/es/reducers/items-reducer.js +0 -144
- package/es/reducers/items-reducer.js.map +0 -1
- package/es/reducers/lines-reducer.js +0 -46
- package/es/reducers/lines-reducer.js.map +0 -1
- package/es/reducers/project-reducer.js +0 -130
- package/es/reducers/project-reducer.js.map +0 -1
- package/es/reducers/reducer.js +0 -20
- package/es/reducers/reducer.js.map +0 -1
- package/es/reducers/scene-reducer.js +0 -29
- package/es/reducers/scene-reducer.js.map +0 -1
- package/es/reducers/user-reducer.js +0 -42
- package/es/reducers/user-reducer.js.map +0 -1
- package/es/reducers/vertices-reducer.js +0 -20
- package/es/reducers/vertices-reducer.js.map +0 -1
- package/es/reducers/viewer2d-reducer.js +0 -76
- package/es/reducers/viewer2d-reducer.js.map +0 -1
- package/es/reducers/viewer3d-reducer.js +0 -57
- package/es/reducers/viewer3d-reducer.js.map +0 -1
- package/es/shared-style.js +0 -67
- package/es/shared-style.js.map +0 -1
- package/es/styles/export.js +0 -6
- package/es/styles/export.js.map +0 -1
- package/es/translator/en.js +0 -105
- package/es/translator/en.js.map +0 -1
- package/es/translator/it.js +0 -80
- package/es/translator/it.js.map +0 -1
- package/es/translator/ru.js +0 -80
- package/es/translator/ru.js.map +0 -1
- package/es/translator/translator.js +0 -85
- package/es/translator/translator.js.map +0 -1
- package/es/utils/browser.js +0 -34
- package/es/utils/browser.js.map +0 -1
- package/es/utils/email-validator.js +0 -5
- package/es/utils/email-validator.js.map +0 -1
- package/es/utils/export.js +0 -26
- package/es/utils/export.js.map +0 -1
- package/es/utils/geometry.js +0 -2237
- package/es/utils/geometry.js.map +0 -1
- package/es/utils/get-edges-of-subgraphs.js +0 -27
- package/es/utils/get-edges-of-subgraphs.js.map +0 -1
- package/es/utils/graph-cycles.js +0 -239
- package/es/utils/graph-cycles.js.map +0 -1
- package/es/utils/graph-inner-cycles.js +0 -47
- package/es/utils/graph-inner-cycles.js.map +0 -1
- package/es/utils/graph.js +0 -150
- package/es/utils/graph.js.map +0 -1
- package/es/utils/helper.js +0 -337
- package/es/utils/helper.js.map +0 -1
- package/es/utils/history.js +0 -30
- package/es/utils/history.js.map +0 -1
- package/es/utils/id-broker.js +0 -20
- package/es/utils/id-broker.js.map +0 -1
- package/es/utils/logger.js +0 -9
- package/es/utils/logger.js.map +0 -1
- package/es/utils/math.js +0 -51
- package/es/utils/math.js.map +0 -1
- package/es/utils/molding.js +0 -840
- package/es/utils/molding.js.map +0 -1
- package/es/utils/name-generator.js +0 -19
- package/es/utils/name-generator.js.map +0 -1
- package/es/utils/objects-utils.js +0 -51
- package/es/utils/objects-utils.js.map +0 -1
- package/es/utils/phone-validator.js +0 -5
- package/es/utils/phone-validator.js.map +0 -1
- package/es/utils/process-black-list.js +0 -19
- package/es/utils/process-black-list.js.map +0 -1
- package/es/utils/react-if.js +0 -19
- package/es/utils/react-if.js.map +0 -1
- package/es/utils/snap-scene.js +0 -100
- package/es/utils/snap-scene.js.map +0 -1
- package/es/utils/snap.js +0 -238
- package/es/utils/snap.js.map +0 -1
- package/es/utils/threeCSG.es6.js +0 -499
- package/es/utils/threeCSG.es6.js.map +0 -1
- package/es/version.js +0 -2
- package/es/version.js.map +0 -1
- /package/{es → src}/catalog/areas/area/textures/ceramic-tile.jpg +0 -0
- /package/{es → src}/catalog/areas/area/textures/grass.jpg +0 -0
- /package/{es → src}/catalog/areas/area/textures/parquet.jpg +0 -0
- /package/{es → src}/catalog/areas/area/textures/strand-porcelain.jpg +0 -0
- /package/{es → src}/catalog/areas/area/textures/tile1.jpg +0 -0
- /package/{es → src}/catalog/back.png +0 -0
- /package/{es → src}/catalog/doors.png +0 -0
- /package/{es → src}/catalog/doorways.png +0 -0
- /package/{es → src}/catalog/envMap/nx.hdr +0 -0
- /package/{es → src}/catalog/envMap/ny.hdr +0 -0
- /package/{es → src}/catalog/envMap/nz.hdr +0 -0
- /package/{es → src}/catalog/envMap/px.hdr +0 -0
- /package/{es → src}/catalog/envMap/py.hdr +0 -0
- /package/{es → src}/catalog/envMap/pz.hdr +0 -0
- /package/{es → src}/catalog/holes/door-double/door_double.png +0 -0
- /package/{es → src}/catalog/holes/door-panic/panicDoor.png +0 -0
- /package/{es → src}/catalog/holes/door-panic-double/panicDoorDouble.png +0 -0
- /package/{es → src}/catalog/holes/gate/gate.jpg +0 -0
- /package/{es → src}/catalog/holes/window-clear/texture.png +0 -0
- /package/{es → src}/catalog/holes/window-cross/texture.png +0 -0
- /package/{es → src}/catalog/holes/window-double-hung/texture.png +0 -0
- /package/{es → src}/catalog/holes/window-vertical/texture.png +0 -0
- /package/{es → src}/catalog/lines/wall/textures/bricks-normal.jpg +0 -0
- /package/{es → src}/catalog/lines/wall/textures/bricks-normal2.jpg +0 -0
- /package/{es → src}/catalog/lines/wall/textures/bricks.jpg +0 -0
- /package/{es → src}/catalog/lines/wall/textures/bricks2.jpg +0 -0
- /package/{es → src}/catalog/lines/wall/textures/bricks3.jpg +0 -0
- /package/{es → src}/catalog/lines/wall/textures/morden-normal.jpg +0 -0
- /package/{es → src}/catalog/lines/wall/textures/morden.jpg +0 -0
- /package/{es → src}/catalog/lines/wall/textures/painted-normal.jpg +0 -0
- /package/{es → src}/catalog/lines/wall/textures/painted.jpg +0 -0
- /package/{es → src}/catalog/lines/wall/textures/plaster-normal.jpg +0 -0
- /package/{es → src}/catalog/lines/wall/textures/plaster.jpg +0 -0
- /package/{es → src}/catalog/lines/wall/wall.png +0 -0
- /package/{es → src}/catalog/molding/molding-dcm/texture.png +0 -0
- /package/{es → src}/catalog/molding/molding-fbm/texture.png +0 -0
- /package/{es → src}/catalog/molding/molding-lrm/texture.png +0 -0
- /package/{es → src}/catalog/windows.png +0 -0
- /package/{es → src}/components/header/header.style.css +0 -0
- /package/{es → src}/components/login/style.css +0 -0
- /package/{es → src}/components/login/style.scss +0 -0
- /package/{es → src}/components/molecules/slider/styles.scss +0 -0
- /package/{es → src}/components/toolbar/main/lShaped.json +0 -0
- /package/{es → src}/components/toolbar/main/longNarrow.json +0 -0
- /package/{es → src}/components/toolbar/main/oRectangle.json +0 -0
- /package/{es → src}/components/toolbar/main/rectangle.json +0 -0
- /package/{es → src}/components/toolbar/main/style.css +0 -0
- /package/{es → src}/components/toolbar/popup/autosaveprompt/styles.css +0 -0
- /package/{es → src}/components/toolbar/popup/downloadsummary/styles.css +0 -0
- /package/{es → src}/components/toolbar/popup/floorplan/choose-floor/lShaped.json +0 -0
- /package/{es → src}/components/toolbar/popup/floorplan/choose-floor/longNarrow.json +0 -0
- /package/{es → src}/components/toolbar/popup/floorplan/choose-floor/oRectangle.json +0 -0
- /package/{es → src}/components/toolbar/popup/floorplan/choose-floor/rectangle.json +0 -0
- /package/{es → src}/components/toolbar/popup/newproject/styles.css +0 -0
- /package/{es → src}/components/toolbar/popup/product/style.css +0 -0
- /package/{es → src}/components/toolbar/popup/savedesign/savedesign.style.css +0 -0
- /package/{es → src}/components/toolbar/popup/submitforquote/styles.css +0 -0
- /package/{es → src}/components/toolbar/popup/submitprompt/styles.css +0 -0
- /package/{es → src}/components/tutorial-view/style.css +0 -0
- /package/{es → src}/styles/tabs.css +0 -0
|
@@ -0,0 +1,3078 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* camera-controls
|
|
3
|
+
* https://github.com/yomotsu/camera-controls
|
|
4
|
+
* (c) 2017 @yomotsu
|
|
5
|
+
* Released under the MIT License.
|
|
6
|
+
*/
|
|
7
|
+
// see https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons#value
|
|
8
|
+
const MOUSE_BUTTON = {
|
|
9
|
+
LEFT: 1,
|
|
10
|
+
RIGHT: 2,
|
|
11
|
+
MIDDLE: 4
|
|
12
|
+
};
|
|
13
|
+
const ACTION = Object.freeze({
|
|
14
|
+
NONE: 0,
|
|
15
|
+
ROTATE: 1,
|
|
16
|
+
TRUCK: 2,
|
|
17
|
+
OFFSET: 4,
|
|
18
|
+
DOLLY: 8,
|
|
19
|
+
ZOOM: 16,
|
|
20
|
+
TOUCH_ROTATE: 32,
|
|
21
|
+
TOUCH_TRUCK: 64,
|
|
22
|
+
TOUCH_OFFSET: 128,
|
|
23
|
+
TOUCH_DOLLY: 256,
|
|
24
|
+
TOUCH_ZOOM: 512,
|
|
25
|
+
TOUCH_DOLLY_TRUCK: 1024,
|
|
26
|
+
TOUCH_DOLLY_OFFSET: 2048,
|
|
27
|
+
TOUCH_DOLLY_ROTATE: 4096,
|
|
28
|
+
TOUCH_ZOOM_TRUCK: 8192,
|
|
29
|
+
TOUCH_ZOOM_OFFSET: 16384,
|
|
30
|
+
TOUCH_ZOOM_ROTATE: 32768
|
|
31
|
+
});
|
|
32
|
+
const DOLLY_DIRECTION = {
|
|
33
|
+
NONE: 0,
|
|
34
|
+
IN: 1,
|
|
35
|
+
OUT: -1
|
|
36
|
+
};
|
|
37
|
+
function isPerspectiveCamera(camera) {
|
|
38
|
+
return camera.isPerspectiveCamera;
|
|
39
|
+
}
|
|
40
|
+
function isOrthographicCamera(camera) {
|
|
41
|
+
return camera.isOrthographicCamera;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const PI_2 = Math.PI * 2;
|
|
45
|
+
const PI_HALF = Math.PI / 2;
|
|
46
|
+
|
|
47
|
+
const EPSILON = 1e-5;
|
|
48
|
+
const DEG2RAD = Math.PI / 180;
|
|
49
|
+
function clamp(value, min, max) {
|
|
50
|
+
return Math.max(min, Math.min(max, value));
|
|
51
|
+
}
|
|
52
|
+
function approxZero(number, error = EPSILON) {
|
|
53
|
+
return Math.abs(number) < error;
|
|
54
|
+
}
|
|
55
|
+
function approxEquals(a, b, error = EPSILON) {
|
|
56
|
+
return approxZero(a - b, error);
|
|
57
|
+
}
|
|
58
|
+
function roundToStep(value, step) {
|
|
59
|
+
return Math.round(value / step) * step;
|
|
60
|
+
}
|
|
61
|
+
function infinityToMaxNumber(value) {
|
|
62
|
+
if (isFinite(value)) return value;
|
|
63
|
+
if (value < 0) return -Number.MAX_VALUE;
|
|
64
|
+
return Number.MAX_VALUE;
|
|
65
|
+
}
|
|
66
|
+
function maxNumberToInfinity(value) {
|
|
67
|
+
if (Math.abs(value) < Number.MAX_VALUE) return value;
|
|
68
|
+
return value * Infinity;
|
|
69
|
+
}
|
|
70
|
+
// https://docs.unity3d.com/ScriptReference/Mathf.SmoothDamp.html
|
|
71
|
+
// https://github.com/Unity-Technologies/UnityCsReference/blob/a2bdfe9b3c4cd4476f44bf52f848063bfaf7b6b9/Runtime/Export/Math/Mathf.cs#L308
|
|
72
|
+
function smoothDamp(
|
|
73
|
+
current,
|
|
74
|
+
target,
|
|
75
|
+
currentVelocityRef,
|
|
76
|
+
smoothTime,
|
|
77
|
+
maxSpeed = Infinity,
|
|
78
|
+
deltaTime
|
|
79
|
+
) {
|
|
80
|
+
// Based on Game Programming Gems 4 Chapter 1.10
|
|
81
|
+
smoothTime = Math.max(0.0001, smoothTime);
|
|
82
|
+
const omega = 2 / smoothTime;
|
|
83
|
+
const x = omega * deltaTime;
|
|
84
|
+
const exp = 1 / (1 + x + 0.48 * x * x + 0.235 * x * x * x);
|
|
85
|
+
let change = current - target;
|
|
86
|
+
const originalTo = target;
|
|
87
|
+
// Clamp maximum speed
|
|
88
|
+
const maxChange = maxSpeed * smoothTime;
|
|
89
|
+
change = clamp(change, -maxChange, maxChange);
|
|
90
|
+
target = current - change;
|
|
91
|
+
const temp = (currentVelocityRef.value + omega * change) * deltaTime;
|
|
92
|
+
currentVelocityRef.value = (currentVelocityRef.value - omega * temp) * exp;
|
|
93
|
+
let output = target + (change + temp) * exp;
|
|
94
|
+
// Prevent overshooting
|
|
95
|
+
if (originalTo - current > 0.0 === output > originalTo) {
|
|
96
|
+
output = originalTo;
|
|
97
|
+
currentVelocityRef.value = (output - originalTo) / deltaTime;
|
|
98
|
+
}
|
|
99
|
+
return output;
|
|
100
|
+
}
|
|
101
|
+
// https://docs.unity3d.com/ScriptReference/Vector3.SmoothDamp.html
|
|
102
|
+
// https://github.com/Unity-Technologies/UnityCsReference/blob/a2bdfe9b3c4cd4476f44bf52f848063bfaf7b6b9/Runtime/Export/Math/Vector3.cs#L97
|
|
103
|
+
function smoothDampVec3(
|
|
104
|
+
current,
|
|
105
|
+
target,
|
|
106
|
+
currentVelocityRef,
|
|
107
|
+
smoothTime,
|
|
108
|
+
maxSpeed = Infinity,
|
|
109
|
+
deltaTime,
|
|
110
|
+
out
|
|
111
|
+
) {
|
|
112
|
+
// Based on Game Programming Gems 4 Chapter 1.10
|
|
113
|
+
smoothTime = Math.max(0.0001, smoothTime);
|
|
114
|
+
const omega = 2 / smoothTime;
|
|
115
|
+
const x = omega * deltaTime;
|
|
116
|
+
const exp = 1 / (1 + x + 0.48 * x * x + 0.235 * x * x * x);
|
|
117
|
+
let targetX = target.x;
|
|
118
|
+
let targetY = target.y;
|
|
119
|
+
let targetZ = target.z;
|
|
120
|
+
let changeX = current.x - targetX;
|
|
121
|
+
let changeY = current.y - targetY;
|
|
122
|
+
let changeZ = current.z - targetZ;
|
|
123
|
+
const originalToX = targetX;
|
|
124
|
+
const originalToY = targetY;
|
|
125
|
+
const originalToZ = targetZ;
|
|
126
|
+
// Clamp maximum speed
|
|
127
|
+
const maxChange = maxSpeed * smoothTime;
|
|
128
|
+
const maxChangeSq = maxChange * maxChange;
|
|
129
|
+
const magnitudeSq = changeX * changeX + changeY * changeY + changeZ * changeZ;
|
|
130
|
+
if (magnitudeSq > maxChangeSq) {
|
|
131
|
+
const magnitude = Math.sqrt(magnitudeSq);
|
|
132
|
+
changeX = (changeX / magnitude) * maxChange;
|
|
133
|
+
changeY = (changeY / magnitude) * maxChange;
|
|
134
|
+
changeZ = (changeZ / magnitude) * maxChange;
|
|
135
|
+
}
|
|
136
|
+
targetX = current.x - changeX;
|
|
137
|
+
targetY = current.y - changeY;
|
|
138
|
+
targetZ = current.z - changeZ;
|
|
139
|
+
const tempX = (currentVelocityRef.x + omega * changeX) * deltaTime;
|
|
140
|
+
const tempY = (currentVelocityRef.y + omega * changeY) * deltaTime;
|
|
141
|
+
const tempZ = (currentVelocityRef.z + omega * changeZ) * deltaTime;
|
|
142
|
+
currentVelocityRef.x = (currentVelocityRef.x - omega * tempX) * exp;
|
|
143
|
+
currentVelocityRef.y = (currentVelocityRef.y - omega * tempY) * exp;
|
|
144
|
+
currentVelocityRef.z = (currentVelocityRef.z - omega * tempZ) * exp;
|
|
145
|
+
out.x = targetX + (changeX + tempX) * exp;
|
|
146
|
+
out.y = targetY + (changeY + tempY) * exp;
|
|
147
|
+
out.z = targetZ + (changeZ + tempZ) * exp;
|
|
148
|
+
// Prevent overshooting
|
|
149
|
+
const origMinusCurrentX = originalToX - current.x;
|
|
150
|
+
const origMinusCurrentY = originalToY - current.y;
|
|
151
|
+
const origMinusCurrentZ = originalToZ - current.z;
|
|
152
|
+
const outMinusOrigX = out.x - originalToX;
|
|
153
|
+
const outMinusOrigY = out.y - originalToY;
|
|
154
|
+
const outMinusOrigZ = out.z - originalToZ;
|
|
155
|
+
if (
|
|
156
|
+
origMinusCurrentX * outMinusOrigX +
|
|
157
|
+
origMinusCurrentY * outMinusOrigY +
|
|
158
|
+
origMinusCurrentZ * outMinusOrigZ >
|
|
159
|
+
0
|
|
160
|
+
) {
|
|
161
|
+
out.x = originalToX;
|
|
162
|
+
out.y = originalToY;
|
|
163
|
+
out.z = originalToZ;
|
|
164
|
+
currentVelocityRef.x = (out.x - originalToX) / deltaTime;
|
|
165
|
+
currentVelocityRef.y = (out.y - originalToY) / deltaTime;
|
|
166
|
+
currentVelocityRef.z = (out.z - originalToZ) / deltaTime;
|
|
167
|
+
}
|
|
168
|
+
return out;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
function extractClientCoordFromEvent(pointers, out) {
|
|
172
|
+
out.set(0, 0);
|
|
173
|
+
pointers.forEach(pointer => {
|
|
174
|
+
out.x += pointer.clientX;
|
|
175
|
+
out.y += pointer.clientY;
|
|
176
|
+
});
|
|
177
|
+
out.x /= pointers.length;
|
|
178
|
+
out.y /= pointers.length;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
function notSupportedInOrthographicCamera(camera, message) {
|
|
182
|
+
if (isOrthographicCamera(camera)) {
|
|
183
|
+
console.warn(`${message} is not supported in OrthographicCamera`);
|
|
184
|
+
return true;
|
|
185
|
+
}
|
|
186
|
+
return false;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
class EventDispatcher {
|
|
190
|
+
constructor() {
|
|
191
|
+
this._listeners = {};
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Adds the specified event listener.
|
|
195
|
+
* @param type event name
|
|
196
|
+
* @param listener handler function
|
|
197
|
+
* @category Methods
|
|
198
|
+
*/
|
|
199
|
+
addEventListener(type, listener) {
|
|
200
|
+
const listeners = this._listeners;
|
|
201
|
+
if (listeners[type] === undefined) listeners[type] = [];
|
|
202
|
+
if (listeners[type].indexOf(listener) === -1)
|
|
203
|
+
listeners[type].push(listener);
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Presence of the specified event listener.
|
|
207
|
+
* @param type event name
|
|
208
|
+
* @param listener handler function
|
|
209
|
+
* @category Methods
|
|
210
|
+
*/
|
|
211
|
+
hasEventListener(type, listener) {
|
|
212
|
+
const listeners = this._listeners;
|
|
213
|
+
return (
|
|
214
|
+
listeners[type] !== undefined && listeners[type].indexOf(listener) !== -1
|
|
215
|
+
);
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Removes the specified event listener
|
|
219
|
+
* @param type event name
|
|
220
|
+
* @param listener handler function
|
|
221
|
+
* @category Methods
|
|
222
|
+
*/
|
|
223
|
+
removeEventListener(type, listener) {
|
|
224
|
+
const listeners = this._listeners;
|
|
225
|
+
const listenerArray = listeners[type];
|
|
226
|
+
if (listenerArray !== undefined) {
|
|
227
|
+
const index = listenerArray.indexOf(listener);
|
|
228
|
+
if (index !== -1) listenerArray.splice(index, 1);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* Removes all event listeners
|
|
233
|
+
* @param type event name
|
|
234
|
+
* @category Methods
|
|
235
|
+
*/
|
|
236
|
+
removeAllEventListeners(type) {
|
|
237
|
+
if (!type) {
|
|
238
|
+
this._listeners = {};
|
|
239
|
+
return;
|
|
240
|
+
}
|
|
241
|
+
if (Array.isArray(this._listeners[type])) this._listeners[type].length = 0;
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* Fire an event type.
|
|
245
|
+
* @param event DispatcherEvent
|
|
246
|
+
* @category Methods
|
|
247
|
+
*/
|
|
248
|
+
dispatchEvent(event) {
|
|
249
|
+
const listeners = this._listeners;
|
|
250
|
+
const listenerArray = listeners[event.type];
|
|
251
|
+
if (listenerArray !== undefined) {
|
|
252
|
+
event.target = this;
|
|
253
|
+
const array = listenerArray.slice(0);
|
|
254
|
+
for (let i = 0, l = array.length; i < l; i++) {
|
|
255
|
+
array[i].call(this, event);
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
var _a;
|
|
262
|
+
const VERSION = '2.8.4'; // will be replaced with `version` in package.json during the build process.
|
|
263
|
+
const TOUCH_DOLLY_FACTOR = 1 / 8;
|
|
264
|
+
const isMac = /Mac/.test(
|
|
265
|
+
(_a =
|
|
266
|
+
globalThis === null || globalThis === void 0
|
|
267
|
+
? void 0
|
|
268
|
+
: globalThis.navigator) === null || _a === void 0
|
|
269
|
+
? void 0
|
|
270
|
+
: _a.platform
|
|
271
|
+
);
|
|
272
|
+
let THREE;
|
|
273
|
+
let _ORIGIN;
|
|
274
|
+
let _AXIS_Y;
|
|
275
|
+
let _AXIS_Z;
|
|
276
|
+
let _v2;
|
|
277
|
+
let _v3A;
|
|
278
|
+
let _v3B;
|
|
279
|
+
let _v3C;
|
|
280
|
+
let _cameraDirection;
|
|
281
|
+
let _xColumn;
|
|
282
|
+
let _yColumn;
|
|
283
|
+
let _zColumn;
|
|
284
|
+
let _deltaTarget;
|
|
285
|
+
let _deltaOffset;
|
|
286
|
+
let _sphericalA;
|
|
287
|
+
let _sphericalB;
|
|
288
|
+
let _box3A;
|
|
289
|
+
let _box3B;
|
|
290
|
+
let _sphere;
|
|
291
|
+
let _quaternionA;
|
|
292
|
+
let _quaternionB;
|
|
293
|
+
let _rotationMatrix;
|
|
294
|
+
let _raycaster;
|
|
295
|
+
class CameraControls extends EventDispatcher {
|
|
296
|
+
/**
|
|
297
|
+
* Injects THREE as the dependency. You can then proceed to use CameraControls.
|
|
298
|
+
*
|
|
299
|
+
* e.g
|
|
300
|
+
* ```javascript
|
|
301
|
+
* CameraControls.install( { THREE: THREE } );
|
|
302
|
+
* ```
|
|
303
|
+
*
|
|
304
|
+
* Note: If you do not wish to use enter three.js to reduce file size(tree-shaking for example), make a subset to install.
|
|
305
|
+
*
|
|
306
|
+
* ```js
|
|
307
|
+
* import {
|
|
308
|
+
* Vector2,
|
|
309
|
+
* Vector3,
|
|
310
|
+
* Vector4,
|
|
311
|
+
* Quaternion,
|
|
312
|
+
* Matrix4,
|
|
313
|
+
* Spherical,
|
|
314
|
+
* Box3,
|
|
315
|
+
* Sphere,
|
|
316
|
+
* Raycaster,
|
|
317
|
+
* MathUtils,
|
|
318
|
+
* } from 'three';
|
|
319
|
+
*
|
|
320
|
+
* const subsetOfTHREE = {
|
|
321
|
+
* Vector2 : Vector2,
|
|
322
|
+
* Vector3 : Vector3,
|
|
323
|
+
* Vector4 : Vector4,
|
|
324
|
+
* Quaternion: Quaternion,
|
|
325
|
+
* Matrix4 : Matrix4,
|
|
326
|
+
* Spherical : Spherical,
|
|
327
|
+
* Box3 : Box3,
|
|
328
|
+
* Sphere : Sphere,
|
|
329
|
+
* Raycaster : Raycaster,
|
|
330
|
+
* };
|
|
331
|
+
|
|
332
|
+
* CameraControls.install( { THREE: subsetOfTHREE } );
|
|
333
|
+
* ```
|
|
334
|
+
* @category Statics
|
|
335
|
+
*/
|
|
336
|
+
static install(libs) {
|
|
337
|
+
THREE = libs.THREE;
|
|
338
|
+
_ORIGIN = Object.freeze(new THREE.Vector3(0, 0, 0));
|
|
339
|
+
_AXIS_Y = Object.freeze(new THREE.Vector3(0, 1, 0));
|
|
340
|
+
_AXIS_Z = Object.freeze(new THREE.Vector3(0, 0, 1));
|
|
341
|
+
_v2 = new THREE.Vector2();
|
|
342
|
+
_v3A = new THREE.Vector3();
|
|
343
|
+
_v3B = new THREE.Vector3();
|
|
344
|
+
_v3C = new THREE.Vector3();
|
|
345
|
+
_cameraDirection = new THREE.Vector3();
|
|
346
|
+
_xColumn = new THREE.Vector3();
|
|
347
|
+
_yColumn = new THREE.Vector3();
|
|
348
|
+
_zColumn = new THREE.Vector3();
|
|
349
|
+
_deltaTarget = new THREE.Vector3();
|
|
350
|
+
_deltaOffset = new THREE.Vector3();
|
|
351
|
+
_sphericalA = new THREE.Spherical();
|
|
352
|
+
_sphericalB = new THREE.Spherical();
|
|
353
|
+
_box3A = new THREE.Box3();
|
|
354
|
+
_box3B = new THREE.Box3();
|
|
355
|
+
_sphere = new THREE.Sphere();
|
|
356
|
+
_quaternionA = new THREE.Quaternion();
|
|
357
|
+
_quaternionB = new THREE.Quaternion();
|
|
358
|
+
_rotationMatrix = new THREE.Matrix4();
|
|
359
|
+
_raycaster = new THREE.Raycaster();
|
|
360
|
+
}
|
|
361
|
+
/**
|
|
362
|
+
* list all ACTIONs
|
|
363
|
+
* @category Statics
|
|
364
|
+
*/
|
|
365
|
+
static get ACTION() {
|
|
366
|
+
return ACTION;
|
|
367
|
+
}
|
|
368
|
+
/**
|
|
369
|
+
* Creates a `CameraControls` instance.
|
|
370
|
+
*
|
|
371
|
+
* Note:
|
|
372
|
+
* You **must install** three.js before using camera-controls. see [#install](#install)
|
|
373
|
+
* Not doing so will lead to runtime errors (`undefined` references to THREE).
|
|
374
|
+
*
|
|
375
|
+
* e.g.
|
|
376
|
+
* ```
|
|
377
|
+
* CameraControls.install( { THREE } );
|
|
378
|
+
* const cameraControls = new CameraControls( camera, domElement );
|
|
379
|
+
* ```
|
|
380
|
+
*
|
|
381
|
+
* @param camera A `THREE.PerspectiveCamera` or `THREE.OrthographicCamera` to be controlled.
|
|
382
|
+
* @param domElement A `HTMLElement` for the draggable area, usually `renderer.domElement`.
|
|
383
|
+
* @category Constructor
|
|
384
|
+
*/
|
|
385
|
+
constructor(camera, domElement) {
|
|
386
|
+
super();
|
|
387
|
+
/**
|
|
388
|
+
* Minimum vertical angle in radians.
|
|
389
|
+
* The angle has to be between `0` and `.maxPolarAngle` inclusive.
|
|
390
|
+
* The default value is `0`.
|
|
391
|
+
*
|
|
392
|
+
* e.g.
|
|
393
|
+
* ```
|
|
394
|
+
* cameraControls.maxPolarAngle = 0;
|
|
395
|
+
* ```
|
|
396
|
+
* @category Properties
|
|
397
|
+
*/
|
|
398
|
+
this.minPolarAngle = 0; // radians
|
|
399
|
+
/**
|
|
400
|
+
* Maximum vertical angle in radians.
|
|
401
|
+
* The angle has to be between `.maxPolarAngle` and `Math.PI` inclusive.
|
|
402
|
+
* The default value is `Math.PI`.
|
|
403
|
+
*
|
|
404
|
+
* e.g.
|
|
405
|
+
* ```
|
|
406
|
+
* cameraControls.maxPolarAngle = Math.PI;
|
|
407
|
+
* ```
|
|
408
|
+
* @category Properties
|
|
409
|
+
*/
|
|
410
|
+
this.maxPolarAngle = Math.PI; // radians
|
|
411
|
+
/**
|
|
412
|
+
* Minimum horizontal angle in radians.
|
|
413
|
+
* The angle has to be less than `.maxAzimuthAngle`.
|
|
414
|
+
* The default value is `- Infinity`.
|
|
415
|
+
*
|
|
416
|
+
* e.g.
|
|
417
|
+
* ```
|
|
418
|
+
* cameraControls.minAzimuthAngle = - Infinity;
|
|
419
|
+
* ```
|
|
420
|
+
* @category Properties
|
|
421
|
+
*/
|
|
422
|
+
this.minAzimuthAngle = -Infinity; // radians
|
|
423
|
+
/**
|
|
424
|
+
* Maximum horizontal angle in radians.
|
|
425
|
+
* The angle has to be greater than `.minAzimuthAngle`.
|
|
426
|
+
* The default value is `Infinity`.
|
|
427
|
+
*
|
|
428
|
+
* e.g.
|
|
429
|
+
* ```
|
|
430
|
+
* cameraControls.maxAzimuthAngle = Infinity;
|
|
431
|
+
* ```
|
|
432
|
+
* @category Properties
|
|
433
|
+
*/
|
|
434
|
+
this.maxAzimuthAngle = Infinity; // radians
|
|
435
|
+
// How far you can dolly in and out ( PerspectiveCamera only )
|
|
436
|
+
/**
|
|
437
|
+
* Minimum distance for dolly. The value must be higher than `0`. Default is `Number.EPSILON`.
|
|
438
|
+
* PerspectiveCamera only.
|
|
439
|
+
* @category Properties
|
|
440
|
+
*/
|
|
441
|
+
this.minDistance = Number.EPSILON;
|
|
442
|
+
/**
|
|
443
|
+
* Maximum distance for dolly. The value must be higher than `minDistance`. Default is `Infinity`.
|
|
444
|
+
* PerspectiveCamera only.
|
|
445
|
+
* @category Properties
|
|
446
|
+
*/
|
|
447
|
+
this.maxDistance = Infinity;
|
|
448
|
+
/**
|
|
449
|
+
* `true` to enable Infinity Dolly for wheel and pinch. Use this with `minDistance` and `maxDistance`
|
|
450
|
+
* If the Dolly distance is less (or over) than the `minDistance` (or `maxDistance`), `infinityDolly` will keep the distance and pushes the target position instead.
|
|
451
|
+
* @category Properties
|
|
452
|
+
*/
|
|
453
|
+
this.infinityDolly = false;
|
|
454
|
+
/**
|
|
455
|
+
* Minimum camera zoom.
|
|
456
|
+
* @category Properties
|
|
457
|
+
*/
|
|
458
|
+
this.minZoom = 0.01;
|
|
459
|
+
/**
|
|
460
|
+
* Maximum camera zoom.
|
|
461
|
+
* @category Properties
|
|
462
|
+
*/
|
|
463
|
+
this.maxZoom = Infinity;
|
|
464
|
+
/**
|
|
465
|
+
* Approximate time in seconds to reach the target. A smaller value will reach the target faster.
|
|
466
|
+
* @category Properties
|
|
467
|
+
*/
|
|
468
|
+
this.smoothTime = 0.25;
|
|
469
|
+
/**
|
|
470
|
+
* the smoothTime while dragging
|
|
471
|
+
* @category Properties
|
|
472
|
+
*/
|
|
473
|
+
this.draggingSmoothTime = 0.125;
|
|
474
|
+
/**
|
|
475
|
+
* Max transition speed in unit-per-seconds
|
|
476
|
+
* @category Properties
|
|
477
|
+
*/
|
|
478
|
+
this.maxSpeed = Infinity;
|
|
479
|
+
/**
|
|
480
|
+
* Speed of azimuth (horizontal) rotation.
|
|
481
|
+
* @category Properties
|
|
482
|
+
*/
|
|
483
|
+
this.azimuthRotateSpeed = 1.0;
|
|
484
|
+
/**
|
|
485
|
+
* Speed of polar (vertical) rotation.
|
|
486
|
+
* @category Properties
|
|
487
|
+
*/
|
|
488
|
+
this.polarRotateSpeed = 1.0;
|
|
489
|
+
/**
|
|
490
|
+
* Speed of mouse-wheel dollying.
|
|
491
|
+
* @category Properties
|
|
492
|
+
*/
|
|
493
|
+
this.dollySpeed = 1.0;
|
|
494
|
+
/**
|
|
495
|
+
* `true` to invert direction when dollying or zooming via drag
|
|
496
|
+
* @category Properties
|
|
497
|
+
*/
|
|
498
|
+
this.dollyDragInverted = false;
|
|
499
|
+
/**
|
|
500
|
+
* Speed of drag for truck and pedestal.
|
|
501
|
+
* @category Properties
|
|
502
|
+
*/
|
|
503
|
+
this.truckSpeed = 2.0;
|
|
504
|
+
/**
|
|
505
|
+
* `true` to enable Dolly-in to the mouse cursor coords.
|
|
506
|
+
* @category Properties
|
|
507
|
+
*/
|
|
508
|
+
this.dollyToCursor = false;
|
|
509
|
+
/**
|
|
510
|
+
* @category Properties
|
|
511
|
+
*/
|
|
512
|
+
this.dragToOffset = false;
|
|
513
|
+
/**
|
|
514
|
+
* The same as `.screenSpacePanning` in three.js's OrbitControls.
|
|
515
|
+
* @category Properties
|
|
516
|
+
*/
|
|
517
|
+
this.verticalDragToForward = false;
|
|
518
|
+
/**
|
|
519
|
+
* Friction ratio of the boundary.
|
|
520
|
+
* @category Properties
|
|
521
|
+
*/
|
|
522
|
+
this.boundaryFriction = 0.0;
|
|
523
|
+
/**
|
|
524
|
+
* Controls how soon the `rest` event fires as the camera slows.
|
|
525
|
+
* @category Properties
|
|
526
|
+
*/
|
|
527
|
+
this.restThreshold = 0.01;
|
|
528
|
+
/**
|
|
529
|
+
* An array of Meshes to collide with camera.
|
|
530
|
+
* Be aware colliderMeshes may decrease performance. The collision test uses 4 raycasters from the camera since the near plane has 4 corners.
|
|
531
|
+
* @category Properties
|
|
532
|
+
*/
|
|
533
|
+
this.colliderMeshes = [];
|
|
534
|
+
/**
|
|
535
|
+
* Force cancel user dragging.
|
|
536
|
+
* @category Methods
|
|
537
|
+
*/
|
|
538
|
+
// cancel will be overwritten in the constructor.
|
|
539
|
+
this.cancel = () => {};
|
|
540
|
+
this._enabled = true;
|
|
541
|
+
this._state = ACTION.NONE;
|
|
542
|
+
this._viewport = null;
|
|
543
|
+
this._changedDolly = 0;
|
|
544
|
+
this._changedZoom = 0;
|
|
545
|
+
this._hasRested = true;
|
|
546
|
+
this._boundaryEnclosesCamera = false;
|
|
547
|
+
this._needsUpdate = true;
|
|
548
|
+
this._updatedLastTime = false;
|
|
549
|
+
this._elementRect = new DOMRect();
|
|
550
|
+
this._isDragging = false;
|
|
551
|
+
this._dragNeedsUpdate = true;
|
|
552
|
+
this._activePointers = [];
|
|
553
|
+
this._lockedPointer = null;
|
|
554
|
+
this._interactiveArea = new DOMRect(0, 0, 1, 1);
|
|
555
|
+
// Use draggingSmoothTime over smoothTime while true.
|
|
556
|
+
// set automatically true on user-dragging start.
|
|
557
|
+
// set automatically false on programmable methods call.
|
|
558
|
+
this._isUserControllingRotate = false;
|
|
559
|
+
this._isUserControllingDolly = false;
|
|
560
|
+
this._isUserControllingTruck = false;
|
|
561
|
+
this._isUserControllingOffset = false;
|
|
562
|
+
this._isUserControllingZoom = false;
|
|
563
|
+
this._lastDollyDirection = DOLLY_DIRECTION.NONE;
|
|
564
|
+
// velocities for smoothDamp
|
|
565
|
+
this._thetaVelocity = { value: 0 };
|
|
566
|
+
this._phiVelocity = { value: 0 };
|
|
567
|
+
this._radiusVelocity = { value: 0 };
|
|
568
|
+
this._targetVelocity = new THREE.Vector3();
|
|
569
|
+
this._focalOffsetVelocity = new THREE.Vector3();
|
|
570
|
+
this._zoomVelocity = { value: 0 };
|
|
571
|
+
this._truckInternal = (deltaX, deltaY, dragToOffset) => {
|
|
572
|
+
let truckX;
|
|
573
|
+
let pedestalY;
|
|
574
|
+
if (isPerspectiveCamera(this._camera)) {
|
|
575
|
+
const offset = _v3A.copy(this._camera.position).sub(this._target);
|
|
576
|
+
// half of the fov is center to top of screen
|
|
577
|
+
const fov = this._camera.getEffectiveFOV() * DEG2RAD;
|
|
578
|
+
const targetDistance = offset.length() * Math.tan(fov * 0.5);
|
|
579
|
+
truckX =
|
|
580
|
+
(this.truckSpeed * deltaX * targetDistance) /
|
|
581
|
+
this._elementRect.height;
|
|
582
|
+
pedestalY =
|
|
583
|
+
(this.truckSpeed * deltaY * targetDistance) /
|
|
584
|
+
this._elementRect.height;
|
|
585
|
+
} else if (isOrthographicCamera(this._camera)) {
|
|
586
|
+
const camera = this._camera;
|
|
587
|
+
truckX =
|
|
588
|
+
(deltaX * (camera.right - camera.left)) /
|
|
589
|
+
camera.zoom /
|
|
590
|
+
this._elementRect.width;
|
|
591
|
+
pedestalY =
|
|
592
|
+
(deltaY * (camera.top - camera.bottom)) /
|
|
593
|
+
camera.zoom /
|
|
594
|
+
this._elementRect.height;
|
|
595
|
+
} else {
|
|
596
|
+
return;
|
|
597
|
+
}
|
|
598
|
+
if (this.verticalDragToForward) {
|
|
599
|
+
dragToOffset
|
|
600
|
+
? this.setFocalOffset(
|
|
601
|
+
this._focalOffsetEnd.x + truckX,
|
|
602
|
+
this._focalOffsetEnd.y,
|
|
603
|
+
this._focalOffsetEnd.z,
|
|
604
|
+
true
|
|
605
|
+
)
|
|
606
|
+
: this.truck(truckX, 0, true);
|
|
607
|
+
this.forward(-pedestalY, true);
|
|
608
|
+
} else {
|
|
609
|
+
dragToOffset
|
|
610
|
+
? this.setFocalOffset(
|
|
611
|
+
this._focalOffsetEnd.x + truckX,
|
|
612
|
+
this._focalOffsetEnd.y + pedestalY,
|
|
613
|
+
this._focalOffsetEnd.z,
|
|
614
|
+
true
|
|
615
|
+
)
|
|
616
|
+
: this.truck(truckX, pedestalY, true);
|
|
617
|
+
}
|
|
618
|
+
};
|
|
619
|
+
this._rotateInternal = (deltaX, deltaY) => {
|
|
620
|
+
const theta =
|
|
621
|
+
(PI_2 * this.azimuthRotateSpeed * deltaX) / this._elementRect.height; // divide by *height* to refer the resolution
|
|
622
|
+
const phi =
|
|
623
|
+
(PI_2 * this.polarRotateSpeed * deltaY) / this._elementRect.height;
|
|
624
|
+
this.rotate(theta, phi, true);
|
|
625
|
+
};
|
|
626
|
+
this._dollyInternal = (delta, x, y) => {
|
|
627
|
+
const dollyScale = Math.pow(0.95, -delta * this.dollySpeed);
|
|
628
|
+
const lastDistance = this._sphericalEnd.radius;
|
|
629
|
+
const distance = this._sphericalEnd.radius * dollyScale;
|
|
630
|
+
const clampedDistance = clamp(
|
|
631
|
+
distance,
|
|
632
|
+
this.minDistance,
|
|
633
|
+
this.maxDistance
|
|
634
|
+
);
|
|
635
|
+
const overflowedDistance = clampedDistance - distance;
|
|
636
|
+
if (this.infinityDolly && this.dollyToCursor) {
|
|
637
|
+
this._dollyToNoClamp(distance, true);
|
|
638
|
+
} else if (this.infinityDolly && !this.dollyToCursor) {
|
|
639
|
+
this.dollyInFixed(overflowedDistance, true);
|
|
640
|
+
this._dollyToNoClamp(clampedDistance, true);
|
|
641
|
+
} else {
|
|
642
|
+
this._dollyToNoClamp(clampedDistance, true);
|
|
643
|
+
}
|
|
644
|
+
if (this.dollyToCursor) {
|
|
645
|
+
this._changedDolly +=
|
|
646
|
+
(this.infinityDolly ? distance : clampedDistance) - lastDistance;
|
|
647
|
+
this._dollyControlCoord.set(x, y);
|
|
648
|
+
}
|
|
649
|
+
this._lastDollyDirection = Math.sign(-delta);
|
|
650
|
+
};
|
|
651
|
+
this._zoomInternal = (delta, x, y) => {
|
|
652
|
+
const zoomScale = Math.pow(0.95, delta * this.dollySpeed);
|
|
653
|
+
const lastZoom = this._zoom;
|
|
654
|
+
const zoom = this._zoom * zoomScale;
|
|
655
|
+
// for both PerspectiveCamera and OrthographicCamera
|
|
656
|
+
this.zoomTo(zoom, true);
|
|
657
|
+
if (this.dollyToCursor) {
|
|
658
|
+
this._changedZoom += zoom - lastZoom;
|
|
659
|
+
this._dollyControlCoord.set(x, y);
|
|
660
|
+
}
|
|
661
|
+
};
|
|
662
|
+
// Check if the user has installed THREE
|
|
663
|
+
if (typeof THREE === 'undefined') {
|
|
664
|
+
console.error(
|
|
665
|
+
'camera-controls: `THREE` is undefined. You must first run `CameraControls.install( { THREE: THREE } )`. Check the docs for further information.'
|
|
666
|
+
);
|
|
667
|
+
}
|
|
668
|
+
this._camera = camera;
|
|
669
|
+
this._yAxisUpSpace = new THREE.Quaternion().setFromUnitVectors(
|
|
670
|
+
this._camera.up,
|
|
671
|
+
_AXIS_Y
|
|
672
|
+
);
|
|
673
|
+
// this._yAxisUpSpaceInverse = this._yAxisUpSpace.clone().invert();
|
|
674
|
+
this._yAxisUpSpaceInverse = this._yAxisUpSpace.clone();
|
|
675
|
+
this._state = ACTION.NONE;
|
|
676
|
+
// the location
|
|
677
|
+
this._target = new THREE.Vector3();
|
|
678
|
+
this._targetEnd = this._target.clone();
|
|
679
|
+
this._focalOffset = new THREE.Vector3();
|
|
680
|
+
this._focalOffsetEnd = this._focalOffset.clone();
|
|
681
|
+
// rotation
|
|
682
|
+
this._spherical = new THREE.Spherical().setFromVector3(
|
|
683
|
+
_v3A.copy(this._camera.position).applyQuaternion(this._yAxisUpSpace)
|
|
684
|
+
);
|
|
685
|
+
this._sphericalEnd = this._spherical.clone();
|
|
686
|
+
this._lastDistance = this._spherical.radius;
|
|
687
|
+
this._zoom = this._camera.zoom;
|
|
688
|
+
this._zoomEnd = this._zoom;
|
|
689
|
+
this._lastZoom = this._zoom;
|
|
690
|
+
// collisionTest uses nearPlane.s
|
|
691
|
+
this._nearPlaneCorners = [
|
|
692
|
+
new THREE.Vector3(),
|
|
693
|
+
new THREE.Vector3(),
|
|
694
|
+
new THREE.Vector3(),
|
|
695
|
+
new THREE.Vector3()
|
|
696
|
+
];
|
|
697
|
+
this._updateNearPlaneCorners();
|
|
698
|
+
// Target cannot move outside of this box
|
|
699
|
+
this._boundary = new THREE.Box3(
|
|
700
|
+
new THREE.Vector3(-Infinity, -Infinity, -Infinity),
|
|
701
|
+
new THREE.Vector3(Infinity, Infinity, Infinity)
|
|
702
|
+
);
|
|
703
|
+
// reset
|
|
704
|
+
this._cameraUp0 = this._camera.up.clone();
|
|
705
|
+
this._target0 = this._target.clone();
|
|
706
|
+
this._position0 = this._camera.position.clone();
|
|
707
|
+
this._zoom0 = this._zoom;
|
|
708
|
+
this._focalOffset0 = this._focalOffset.clone();
|
|
709
|
+
this._dollyControlCoord = new THREE.Vector2();
|
|
710
|
+
// configs
|
|
711
|
+
this.mouseButtons = {
|
|
712
|
+
left: ACTION.ROTATE,
|
|
713
|
+
middle: ACTION.DOLLY,
|
|
714
|
+
right: ACTION.TRUCK,
|
|
715
|
+
wheel: isPerspectiveCamera(this._camera)
|
|
716
|
+
? ACTION.DOLLY
|
|
717
|
+
: isOrthographicCamera(this._camera)
|
|
718
|
+
? ACTION.ZOOM
|
|
719
|
+
: ACTION.NONE
|
|
720
|
+
};
|
|
721
|
+
this.touches = {
|
|
722
|
+
one: ACTION.TOUCH_ROTATE,
|
|
723
|
+
two: isPerspectiveCamera(this._camera)
|
|
724
|
+
? ACTION.TOUCH_DOLLY_TRUCK
|
|
725
|
+
: isOrthographicCamera(this._camera)
|
|
726
|
+
? ACTION.TOUCH_ZOOM_TRUCK
|
|
727
|
+
: ACTION.NONE,
|
|
728
|
+
three: ACTION.TOUCH_TRUCK
|
|
729
|
+
};
|
|
730
|
+
const dragStartPosition = new THREE.Vector2();
|
|
731
|
+
const lastDragPosition = new THREE.Vector2();
|
|
732
|
+
const dollyStart = new THREE.Vector2();
|
|
733
|
+
const onPointerDown = event => {
|
|
734
|
+
if (!this._enabled || !this._domElement) return;
|
|
735
|
+
if (
|
|
736
|
+
this._interactiveArea.left !== 0 ||
|
|
737
|
+
this._interactiveArea.top !== 0 ||
|
|
738
|
+
this._interactiveArea.width !== 1 ||
|
|
739
|
+
this._interactiveArea.height !== 1
|
|
740
|
+
) {
|
|
741
|
+
const elRect = this._domElement.getBoundingClientRect();
|
|
742
|
+
const left = event.clientX / elRect.width;
|
|
743
|
+
const top = event.clientY / elRect.height;
|
|
744
|
+
// check if the interactiveArea contains the drag start position.
|
|
745
|
+
if (
|
|
746
|
+
left < this._interactiveArea.left ||
|
|
747
|
+
left > this._interactiveArea.right ||
|
|
748
|
+
top < this._interactiveArea.top ||
|
|
749
|
+
top > this._interactiveArea.bottom
|
|
750
|
+
)
|
|
751
|
+
return;
|
|
752
|
+
}
|
|
753
|
+
// Don't call `event.preventDefault()` on the pointerdown event
|
|
754
|
+
// to keep receiving pointermove evens outside dragging iframe
|
|
755
|
+
// https://taye.me/blog/tips/2015/11/16/mouse-drag-outside-iframe/
|
|
756
|
+
const mouseButton =
|
|
757
|
+
event.pointerType !== 'mouse'
|
|
758
|
+
? null
|
|
759
|
+
: (event.buttons & MOUSE_BUTTON.LEFT) === MOUSE_BUTTON.LEFT
|
|
760
|
+
? MOUSE_BUTTON.LEFT
|
|
761
|
+
: (event.buttons & MOUSE_BUTTON.MIDDLE) === MOUSE_BUTTON.MIDDLE
|
|
762
|
+
? MOUSE_BUTTON.MIDDLE
|
|
763
|
+
: (event.buttons & MOUSE_BUTTON.RIGHT) === MOUSE_BUTTON.RIGHT
|
|
764
|
+
? MOUSE_BUTTON.RIGHT
|
|
765
|
+
: null;
|
|
766
|
+
if (mouseButton !== null) {
|
|
767
|
+
const zombiePointer = this._findPointerByMouseButton(mouseButton);
|
|
768
|
+
zombiePointer && this._disposePointer(zombiePointer);
|
|
769
|
+
}
|
|
770
|
+
if (
|
|
771
|
+
(event.buttons & MOUSE_BUTTON.LEFT) === MOUSE_BUTTON.LEFT &&
|
|
772
|
+
this._lockedPointer
|
|
773
|
+
)
|
|
774
|
+
return;
|
|
775
|
+
const pointer = {
|
|
776
|
+
pointerId: event.pointerId,
|
|
777
|
+
clientX: event.clientX,
|
|
778
|
+
clientY: event.clientY,
|
|
779
|
+
deltaX: 0,
|
|
780
|
+
deltaY: 0,
|
|
781
|
+
mouseButton
|
|
782
|
+
};
|
|
783
|
+
this._activePointers.push(pointer);
|
|
784
|
+
// eslint-disable-next-line no-undef
|
|
785
|
+
this._domElement.ownerDocument.removeEventListener(
|
|
786
|
+
'pointermove',
|
|
787
|
+
onPointerMove,
|
|
788
|
+
{ passive: false }
|
|
789
|
+
);
|
|
790
|
+
this._domElement.ownerDocument.removeEventListener(
|
|
791
|
+
'pointerup',
|
|
792
|
+
onPointerUp
|
|
793
|
+
);
|
|
794
|
+
this._domElement.ownerDocument.addEventListener(
|
|
795
|
+
'pointermove',
|
|
796
|
+
onPointerMove,
|
|
797
|
+
{ passive: false }
|
|
798
|
+
);
|
|
799
|
+
this._domElement.ownerDocument.addEventListener('pointerup', onPointerUp);
|
|
800
|
+
this._isDragging = true;
|
|
801
|
+
startDragging(event);
|
|
802
|
+
};
|
|
803
|
+
const onPointerMove = event => {
|
|
804
|
+
if (event.cancelable) event.preventDefault();
|
|
805
|
+
const pointerId = event.pointerId;
|
|
806
|
+
const pointer = this._lockedPointer || this._findPointerById(pointerId);
|
|
807
|
+
if (!pointer) return;
|
|
808
|
+
pointer.clientX = event.clientX;
|
|
809
|
+
pointer.clientY = event.clientY;
|
|
810
|
+
pointer.deltaX = event.movementX;
|
|
811
|
+
pointer.deltaY = event.movementY;
|
|
812
|
+
this._state = 0;
|
|
813
|
+
if (event.pointerType === 'touch') {
|
|
814
|
+
switch (this._activePointers.length) {
|
|
815
|
+
case 1:
|
|
816
|
+
this._state = this.touches.one;
|
|
817
|
+
break;
|
|
818
|
+
case 2:
|
|
819
|
+
this._state = this.touches.two;
|
|
820
|
+
break;
|
|
821
|
+
case 3:
|
|
822
|
+
this._state = this.touches.three;
|
|
823
|
+
break;
|
|
824
|
+
}
|
|
825
|
+
} else {
|
|
826
|
+
if (
|
|
827
|
+
(!this._isDragging && this._lockedPointer) ||
|
|
828
|
+
(this._isDragging &&
|
|
829
|
+
(event.buttons & MOUSE_BUTTON.LEFT) === MOUSE_BUTTON.LEFT)
|
|
830
|
+
) {
|
|
831
|
+
this._state = this._state | this.mouseButtons.left;
|
|
832
|
+
}
|
|
833
|
+
if (
|
|
834
|
+
this._isDragging &&
|
|
835
|
+
(event.buttons & MOUSE_BUTTON.MIDDLE) === MOUSE_BUTTON.MIDDLE
|
|
836
|
+
) {
|
|
837
|
+
this._state = this._state | this.mouseButtons.middle;
|
|
838
|
+
}
|
|
839
|
+
if (
|
|
840
|
+
this._isDragging &&
|
|
841
|
+
(event.buttons & MOUSE_BUTTON.RIGHT) === MOUSE_BUTTON.RIGHT
|
|
842
|
+
) {
|
|
843
|
+
this._state = this._state | this.mouseButtons.right;
|
|
844
|
+
}
|
|
845
|
+
}
|
|
846
|
+
dragging();
|
|
847
|
+
};
|
|
848
|
+
const onPointerUp = event => {
|
|
849
|
+
const pointer = this._findPointerById(event.pointerId);
|
|
850
|
+
if (pointer && pointer === this._lockedPointer) return;
|
|
851
|
+
pointer && this._disposePointer(pointer);
|
|
852
|
+
if (event.pointerType === 'touch') {
|
|
853
|
+
switch (this._activePointers.length) {
|
|
854
|
+
case 0:
|
|
855
|
+
this._state = ACTION.NONE;
|
|
856
|
+
break;
|
|
857
|
+
case 1:
|
|
858
|
+
this._state = this.touches.one;
|
|
859
|
+
break;
|
|
860
|
+
case 2:
|
|
861
|
+
this._state = this.touches.two;
|
|
862
|
+
break;
|
|
863
|
+
case 3:
|
|
864
|
+
this._state = this.touches.three;
|
|
865
|
+
break;
|
|
866
|
+
}
|
|
867
|
+
} else {
|
|
868
|
+
this._state = ACTION.NONE;
|
|
869
|
+
}
|
|
870
|
+
endDragging();
|
|
871
|
+
};
|
|
872
|
+
let lastScrollTimeStamp = -1;
|
|
873
|
+
const onMouseWheel = event => {
|
|
874
|
+
if (!this._domElement) return;
|
|
875
|
+
if (!this._enabled || this.mouseButtons.wheel === ACTION.NONE) return;
|
|
876
|
+
if (
|
|
877
|
+
this._interactiveArea.left !== 0 ||
|
|
878
|
+
this._interactiveArea.top !== 0 ||
|
|
879
|
+
this._interactiveArea.width !== 1 ||
|
|
880
|
+
this._interactiveArea.height !== 1
|
|
881
|
+
) {
|
|
882
|
+
const elRect = this._domElement.getBoundingClientRect();
|
|
883
|
+
const left = event.clientX / elRect.width;
|
|
884
|
+
const top = event.clientY / elRect.height;
|
|
885
|
+
// check if the interactiveArea contains the drag start position.
|
|
886
|
+
if (
|
|
887
|
+
left < this._interactiveArea.left ||
|
|
888
|
+
left > this._interactiveArea.right ||
|
|
889
|
+
top < this._interactiveArea.top ||
|
|
890
|
+
top > this._interactiveArea.bottom
|
|
891
|
+
)
|
|
892
|
+
return;
|
|
893
|
+
}
|
|
894
|
+
event.preventDefault();
|
|
895
|
+
if (
|
|
896
|
+
this.dollyToCursor ||
|
|
897
|
+
this.mouseButtons.wheel === ACTION.ROTATE ||
|
|
898
|
+
this.mouseButtons.wheel === ACTION.TRUCK
|
|
899
|
+
) {
|
|
900
|
+
const now = performance.now();
|
|
901
|
+
// only need to fire this at scroll start.
|
|
902
|
+
if (lastScrollTimeStamp - now < 1000)
|
|
903
|
+
this._getClientRect(this._elementRect);
|
|
904
|
+
lastScrollTimeStamp = now;
|
|
905
|
+
}
|
|
906
|
+
// Ref: https://github.com/cedricpinson/osgjs/blob/00e5a7e9d9206c06fdde0436e1d62ab7cb5ce853/sources/osgViewer/input/source/InputSourceMouse.js#L89-L103
|
|
907
|
+
const deltaYFactor = isMac ? -1 : -3;
|
|
908
|
+
const delta =
|
|
909
|
+
event.deltaMode === 1
|
|
910
|
+
? event.deltaY / deltaYFactor
|
|
911
|
+
: event.deltaY / (deltaYFactor * 10);
|
|
912
|
+
const x = this.dollyToCursor
|
|
913
|
+
? ((event.clientX - this._elementRect.x) / this._elementRect.width) *
|
|
914
|
+
2 -
|
|
915
|
+
1
|
|
916
|
+
: 0;
|
|
917
|
+
const y = this.dollyToCursor
|
|
918
|
+
? ((event.clientY - this._elementRect.y) / this._elementRect.height) *
|
|
919
|
+
-2 +
|
|
920
|
+
1
|
|
921
|
+
: 0;
|
|
922
|
+
switch (this.mouseButtons.wheel) {
|
|
923
|
+
case ACTION.ROTATE: {
|
|
924
|
+
this._rotateInternal(event.deltaX, event.deltaY);
|
|
925
|
+
this._isUserControllingRotate = true;
|
|
926
|
+
break;
|
|
927
|
+
}
|
|
928
|
+
case ACTION.TRUCK: {
|
|
929
|
+
this._truckInternal(event.deltaX, event.deltaY, false);
|
|
930
|
+
this._isUserControllingTruck = true;
|
|
931
|
+
break;
|
|
932
|
+
}
|
|
933
|
+
case ACTION.OFFSET: {
|
|
934
|
+
this._truckInternal(event.deltaX, event.deltaY, true);
|
|
935
|
+
this._isUserControllingOffset = true;
|
|
936
|
+
break;
|
|
937
|
+
}
|
|
938
|
+
case ACTION.DOLLY: {
|
|
939
|
+
this._dollyInternal(-delta, x, y);
|
|
940
|
+
this._isUserControllingDolly = true;
|
|
941
|
+
break;
|
|
942
|
+
}
|
|
943
|
+
case ACTION.ZOOM: {
|
|
944
|
+
this._zoomInternal(-delta, x, y);
|
|
945
|
+
this._isUserControllingZoom = true;
|
|
946
|
+
break;
|
|
947
|
+
}
|
|
948
|
+
}
|
|
949
|
+
this.dispatchEvent({ type: 'control' });
|
|
950
|
+
};
|
|
951
|
+
const onContextMenu = event => {
|
|
952
|
+
if (!this._domElement || !this._enabled) return;
|
|
953
|
+
// contextmenu event is fired right after pointerdown
|
|
954
|
+
// remove attached handlers and active pointer, if interrupted by contextmenu.
|
|
955
|
+
if (this.mouseButtons.right === CameraControls.ACTION.NONE) {
|
|
956
|
+
const pointerId = event instanceof PointerEvent ? event.pointerId : 0;
|
|
957
|
+
const pointer = this._findPointerById(pointerId);
|
|
958
|
+
pointer && this._disposePointer(pointer);
|
|
959
|
+
// eslint-disable-next-line no-undef
|
|
960
|
+
this._domElement.ownerDocument.removeEventListener(
|
|
961
|
+
'pointermove',
|
|
962
|
+
onPointerMove,
|
|
963
|
+
{ passive: false }
|
|
964
|
+
);
|
|
965
|
+
this._domElement.ownerDocument.removeEventListener(
|
|
966
|
+
'pointerup',
|
|
967
|
+
onPointerUp
|
|
968
|
+
);
|
|
969
|
+
return;
|
|
970
|
+
}
|
|
971
|
+
event.preventDefault();
|
|
972
|
+
};
|
|
973
|
+
const startDragging = event => {
|
|
974
|
+
if (!this._enabled) return;
|
|
975
|
+
extractClientCoordFromEvent(this._activePointers, _v2);
|
|
976
|
+
this._getClientRect(this._elementRect);
|
|
977
|
+
dragStartPosition.copy(_v2);
|
|
978
|
+
lastDragPosition.copy(_v2);
|
|
979
|
+
const isMultiTouch = this._activePointers.length >= 2;
|
|
980
|
+
if (isMultiTouch) {
|
|
981
|
+
// 2 finger pinch
|
|
982
|
+
const dx = _v2.x - this._activePointers[1].clientX;
|
|
983
|
+
const dy = _v2.y - this._activePointers[1].clientY;
|
|
984
|
+
const distance = Math.sqrt(dx * dx + dy * dy);
|
|
985
|
+
dollyStart.set(0, distance);
|
|
986
|
+
// center coords of 2 finger truck
|
|
987
|
+
const x =
|
|
988
|
+
(this._activePointers[0].clientX + this._activePointers[1].clientX) *
|
|
989
|
+
0.5;
|
|
990
|
+
const y =
|
|
991
|
+
(this._activePointers[0].clientY + this._activePointers[1].clientY) *
|
|
992
|
+
0.5;
|
|
993
|
+
lastDragPosition.set(x, y);
|
|
994
|
+
}
|
|
995
|
+
this._state = 0;
|
|
996
|
+
if (!event) {
|
|
997
|
+
if (this._lockedPointer)
|
|
998
|
+
this._state = this._state | this.mouseButtons.left;
|
|
999
|
+
} else if ('pointerType' in event && event.pointerType === 'touch') {
|
|
1000
|
+
switch (this._activePointers.length) {
|
|
1001
|
+
case 1:
|
|
1002
|
+
this._state = this.touches.one;
|
|
1003
|
+
break;
|
|
1004
|
+
case 2:
|
|
1005
|
+
this._state = this.touches.two;
|
|
1006
|
+
break;
|
|
1007
|
+
case 3:
|
|
1008
|
+
this._state = this.touches.three;
|
|
1009
|
+
break;
|
|
1010
|
+
}
|
|
1011
|
+
} else {
|
|
1012
|
+
if (
|
|
1013
|
+
!this._lockedPointer &&
|
|
1014
|
+
(event.buttons & MOUSE_BUTTON.LEFT) === MOUSE_BUTTON.LEFT
|
|
1015
|
+
) {
|
|
1016
|
+
this._state = this._state | this.mouseButtons.left;
|
|
1017
|
+
}
|
|
1018
|
+
if ((event.buttons & MOUSE_BUTTON.MIDDLE) === MOUSE_BUTTON.MIDDLE) {
|
|
1019
|
+
this._state = this._state | this.mouseButtons.middle;
|
|
1020
|
+
}
|
|
1021
|
+
if ((event.buttons & MOUSE_BUTTON.RIGHT) === MOUSE_BUTTON.RIGHT) {
|
|
1022
|
+
this._state = this._state | this.mouseButtons.right;
|
|
1023
|
+
}
|
|
1024
|
+
}
|
|
1025
|
+
// stop current movement on drag start
|
|
1026
|
+
if (
|
|
1027
|
+
(this._state & ACTION.ROTATE) === ACTION.ROTATE ||
|
|
1028
|
+
(this._state & ACTION.TOUCH_ROTATE) === ACTION.TOUCH_ROTATE ||
|
|
1029
|
+
(this._state & ACTION.TOUCH_DOLLY_ROTATE) ===
|
|
1030
|
+
ACTION.TOUCH_DOLLY_ROTATE ||
|
|
1031
|
+
(this._state & ACTION.TOUCH_ZOOM_ROTATE) === ACTION.TOUCH_ZOOM_ROTATE
|
|
1032
|
+
) {
|
|
1033
|
+
this._sphericalEnd.theta = this._spherical.theta;
|
|
1034
|
+
this._sphericalEnd.phi = this._spherical.phi;
|
|
1035
|
+
this._thetaVelocity.value = 0;
|
|
1036
|
+
this._phiVelocity.value = 0;
|
|
1037
|
+
}
|
|
1038
|
+
if (
|
|
1039
|
+
(this._state & ACTION.TRUCK) === ACTION.TRUCK ||
|
|
1040
|
+
(this._state & ACTION.TOUCH_TRUCK) === ACTION.TOUCH_TRUCK ||
|
|
1041
|
+
(this._state & ACTION.TOUCH_DOLLY_TRUCK) === ACTION.TOUCH_DOLLY_TRUCK ||
|
|
1042
|
+
(this._state & ACTION.TOUCH_ZOOM_TRUCK) === ACTION.TOUCH_ZOOM_TRUCK
|
|
1043
|
+
) {
|
|
1044
|
+
this._targetEnd.copy(this._target);
|
|
1045
|
+
this._targetVelocity.set(0, 0, 0);
|
|
1046
|
+
}
|
|
1047
|
+
if (
|
|
1048
|
+
(this._state & ACTION.DOLLY) === ACTION.DOLLY ||
|
|
1049
|
+
(this._state & ACTION.TOUCH_DOLLY) === ACTION.TOUCH_DOLLY ||
|
|
1050
|
+
(this._state & ACTION.TOUCH_DOLLY_TRUCK) === ACTION.TOUCH_DOLLY_TRUCK ||
|
|
1051
|
+
(this._state & ACTION.TOUCH_DOLLY_OFFSET) ===
|
|
1052
|
+
ACTION.TOUCH_DOLLY_OFFSET ||
|
|
1053
|
+
(this._state & ACTION.TOUCH_DOLLY_ROTATE) === ACTION.TOUCH_DOLLY_ROTATE
|
|
1054
|
+
) {
|
|
1055
|
+
this._sphericalEnd.radius = this._spherical.radius;
|
|
1056
|
+
this._radiusVelocity.value = 0;
|
|
1057
|
+
}
|
|
1058
|
+
if (
|
|
1059
|
+
(this._state & ACTION.ZOOM) === ACTION.ZOOM ||
|
|
1060
|
+
(this._state & ACTION.TOUCH_ZOOM) === ACTION.TOUCH_ZOOM ||
|
|
1061
|
+
(this._state & ACTION.TOUCH_ZOOM_TRUCK) === ACTION.TOUCH_ZOOM_TRUCK ||
|
|
1062
|
+
(this._state & ACTION.TOUCH_ZOOM_OFFSET) === ACTION.TOUCH_ZOOM_OFFSET ||
|
|
1063
|
+
(this._state & ACTION.TOUCH_ZOOM_ROTATE) === ACTION.TOUCH_ZOOM_ROTATE
|
|
1064
|
+
) {
|
|
1065
|
+
this._zoomEnd = this._zoom;
|
|
1066
|
+
this._zoomVelocity.value = 0;
|
|
1067
|
+
}
|
|
1068
|
+
if (
|
|
1069
|
+
(this._state & ACTION.OFFSET) === ACTION.OFFSET ||
|
|
1070
|
+
(this._state & ACTION.TOUCH_OFFSET) === ACTION.TOUCH_OFFSET ||
|
|
1071
|
+
(this._state & ACTION.TOUCH_DOLLY_OFFSET) ===
|
|
1072
|
+
ACTION.TOUCH_DOLLY_OFFSET ||
|
|
1073
|
+
(this._state & ACTION.TOUCH_ZOOM_OFFSET) === ACTION.TOUCH_ZOOM_OFFSET
|
|
1074
|
+
) {
|
|
1075
|
+
this._focalOffsetEnd.copy(this._focalOffset);
|
|
1076
|
+
this._focalOffsetVelocity.set(0, 0, 0);
|
|
1077
|
+
}
|
|
1078
|
+
this.dispatchEvent({ type: 'controlstart' });
|
|
1079
|
+
};
|
|
1080
|
+
const dragging = () => {
|
|
1081
|
+
if (!this._enabled || !this._dragNeedsUpdate) return;
|
|
1082
|
+
this._dragNeedsUpdate = false;
|
|
1083
|
+
extractClientCoordFromEvent(this._activePointers, _v2);
|
|
1084
|
+
// When pointer lock is enabled clientX, clientY, screenX, and screenY remain 0.
|
|
1085
|
+
// If pointer lock is enabled, use the Delta directory, and assume active-pointer is not multiple.
|
|
1086
|
+
const isPointerLockActive =
|
|
1087
|
+
this._domElement &&
|
|
1088
|
+
this._domElement.ownerDocument.pointerLockElement === this._domElement;
|
|
1089
|
+
const lockedPointer = isPointerLockActive
|
|
1090
|
+
? this._lockedPointer || this._activePointers[0]
|
|
1091
|
+
: null;
|
|
1092
|
+
const deltaX = lockedPointer
|
|
1093
|
+
? -lockedPointer.deltaX
|
|
1094
|
+
: lastDragPosition.x - _v2.x;
|
|
1095
|
+
const deltaY = lockedPointer
|
|
1096
|
+
? -lockedPointer.deltaY
|
|
1097
|
+
: lastDragPosition.y - _v2.y;
|
|
1098
|
+
lastDragPosition.copy(_v2);
|
|
1099
|
+
if (
|
|
1100
|
+
(this._state & ACTION.ROTATE) === ACTION.ROTATE ||
|
|
1101
|
+
(this._state & ACTION.TOUCH_ROTATE) === ACTION.TOUCH_ROTATE ||
|
|
1102
|
+
(this._state & ACTION.TOUCH_DOLLY_ROTATE) ===
|
|
1103
|
+
ACTION.TOUCH_DOLLY_ROTATE ||
|
|
1104
|
+
(this._state & ACTION.TOUCH_ZOOM_ROTATE) === ACTION.TOUCH_ZOOM_ROTATE
|
|
1105
|
+
) {
|
|
1106
|
+
this._rotateInternal(deltaX, deltaY);
|
|
1107
|
+
this._isUserControllingRotate = true;
|
|
1108
|
+
}
|
|
1109
|
+
if (
|
|
1110
|
+
(this._state & ACTION.DOLLY) === ACTION.DOLLY ||
|
|
1111
|
+
(this._state & ACTION.ZOOM) === ACTION.ZOOM
|
|
1112
|
+
) {
|
|
1113
|
+
const dollyX = this.dollyToCursor
|
|
1114
|
+
? ((dragStartPosition.x - this._elementRect.x) /
|
|
1115
|
+
this._elementRect.width) *
|
|
1116
|
+
2 -
|
|
1117
|
+
1
|
|
1118
|
+
: 0;
|
|
1119
|
+
const dollyY = this.dollyToCursor
|
|
1120
|
+
? ((dragStartPosition.y - this._elementRect.y) /
|
|
1121
|
+
this._elementRect.height) *
|
|
1122
|
+
-2 +
|
|
1123
|
+
1
|
|
1124
|
+
: 0;
|
|
1125
|
+
const dollyDirection = this.dollyDragInverted ? -1 : 1;
|
|
1126
|
+
if ((this._state & ACTION.DOLLY) === ACTION.DOLLY) {
|
|
1127
|
+
this._dollyInternal(
|
|
1128
|
+
dollyDirection * deltaY * TOUCH_DOLLY_FACTOR,
|
|
1129
|
+
dollyX,
|
|
1130
|
+
dollyY
|
|
1131
|
+
);
|
|
1132
|
+
this._isUserControllingDolly = true;
|
|
1133
|
+
} else {
|
|
1134
|
+
this._zoomInternal(
|
|
1135
|
+
dollyDirection * deltaY * TOUCH_DOLLY_FACTOR,
|
|
1136
|
+
dollyX,
|
|
1137
|
+
dollyY
|
|
1138
|
+
);
|
|
1139
|
+
this._isUserControllingZoom = true;
|
|
1140
|
+
}
|
|
1141
|
+
}
|
|
1142
|
+
if (
|
|
1143
|
+
(this._state & ACTION.TOUCH_DOLLY) === ACTION.TOUCH_DOLLY ||
|
|
1144
|
+
(this._state & ACTION.TOUCH_ZOOM) === ACTION.TOUCH_ZOOM ||
|
|
1145
|
+
(this._state & ACTION.TOUCH_DOLLY_TRUCK) === ACTION.TOUCH_DOLLY_TRUCK ||
|
|
1146
|
+
(this._state & ACTION.TOUCH_ZOOM_TRUCK) === ACTION.TOUCH_ZOOM_TRUCK ||
|
|
1147
|
+
(this._state & ACTION.TOUCH_DOLLY_OFFSET) ===
|
|
1148
|
+
ACTION.TOUCH_DOLLY_OFFSET ||
|
|
1149
|
+
(this._state & ACTION.TOUCH_ZOOM_OFFSET) === ACTION.TOUCH_ZOOM_OFFSET ||
|
|
1150
|
+
(this._state & ACTION.TOUCH_DOLLY_ROTATE) ===
|
|
1151
|
+
ACTION.TOUCH_DOLLY_ROTATE ||
|
|
1152
|
+
(this._state & ACTION.TOUCH_ZOOM_ROTATE) === ACTION.TOUCH_ZOOM_ROTATE
|
|
1153
|
+
) {
|
|
1154
|
+
const dx = _v2.x - this._activePointers[1].clientX;
|
|
1155
|
+
const dy = _v2.y - this._activePointers[1].clientY;
|
|
1156
|
+
const distance = Math.sqrt(dx * dx + dy * dy);
|
|
1157
|
+
const dollyDelta = dollyStart.y - distance;
|
|
1158
|
+
dollyStart.set(0, distance);
|
|
1159
|
+
const dollyX = this.dollyToCursor
|
|
1160
|
+
? ((lastDragPosition.x - this._elementRect.x) /
|
|
1161
|
+
this._elementRect.width) *
|
|
1162
|
+
2 -
|
|
1163
|
+
1
|
|
1164
|
+
: 0;
|
|
1165
|
+
const dollyY = this.dollyToCursor
|
|
1166
|
+
? ((lastDragPosition.y - this._elementRect.y) /
|
|
1167
|
+
this._elementRect.height) *
|
|
1168
|
+
-2 +
|
|
1169
|
+
1
|
|
1170
|
+
: 0;
|
|
1171
|
+
if (
|
|
1172
|
+
(this._state & ACTION.TOUCH_DOLLY) === ACTION.TOUCH_DOLLY ||
|
|
1173
|
+
(this._state & ACTION.TOUCH_DOLLY_ROTATE) ===
|
|
1174
|
+
ACTION.TOUCH_DOLLY_ROTATE ||
|
|
1175
|
+
(this._state & ACTION.TOUCH_DOLLY_TRUCK) ===
|
|
1176
|
+
ACTION.TOUCH_DOLLY_TRUCK ||
|
|
1177
|
+
(this._state & ACTION.TOUCH_DOLLY_OFFSET) ===
|
|
1178
|
+
ACTION.TOUCH_DOLLY_OFFSET
|
|
1179
|
+
) {
|
|
1180
|
+
this._dollyInternal(dollyDelta * TOUCH_DOLLY_FACTOR, dollyX, dollyY);
|
|
1181
|
+
this._isUserControllingDolly = true;
|
|
1182
|
+
} else {
|
|
1183
|
+
this._zoomInternal(dollyDelta * TOUCH_DOLLY_FACTOR, dollyX, dollyY);
|
|
1184
|
+
this._isUserControllingZoom = true;
|
|
1185
|
+
}
|
|
1186
|
+
}
|
|
1187
|
+
if (
|
|
1188
|
+
(this._state & ACTION.TRUCK) === ACTION.TRUCK ||
|
|
1189
|
+
(this._state & ACTION.TOUCH_TRUCK) === ACTION.TOUCH_TRUCK ||
|
|
1190
|
+
(this._state & ACTION.TOUCH_DOLLY_TRUCK) === ACTION.TOUCH_DOLLY_TRUCK ||
|
|
1191
|
+
(this._state & ACTION.TOUCH_ZOOM_TRUCK) === ACTION.TOUCH_ZOOM_TRUCK
|
|
1192
|
+
) {
|
|
1193
|
+
this._truckInternal(deltaX, deltaY, false);
|
|
1194
|
+
this._isUserControllingTruck = true;
|
|
1195
|
+
}
|
|
1196
|
+
if (
|
|
1197
|
+
(this._state & ACTION.OFFSET) === ACTION.OFFSET ||
|
|
1198
|
+
(this._state & ACTION.TOUCH_OFFSET) === ACTION.TOUCH_OFFSET ||
|
|
1199
|
+
(this._state & ACTION.TOUCH_DOLLY_OFFSET) ===
|
|
1200
|
+
ACTION.TOUCH_DOLLY_OFFSET ||
|
|
1201
|
+
(this._state & ACTION.TOUCH_ZOOM_OFFSET) === ACTION.TOUCH_ZOOM_OFFSET
|
|
1202
|
+
) {
|
|
1203
|
+
this._truckInternal(deltaX, deltaY, true);
|
|
1204
|
+
this._isUserControllingOffset = true;
|
|
1205
|
+
}
|
|
1206
|
+
this.dispatchEvent({ type: 'control' });
|
|
1207
|
+
};
|
|
1208
|
+
const endDragging = () => {
|
|
1209
|
+
extractClientCoordFromEvent(this._activePointers, _v2);
|
|
1210
|
+
lastDragPosition.copy(_v2);
|
|
1211
|
+
this._dragNeedsUpdate = false;
|
|
1212
|
+
if (
|
|
1213
|
+
this._activePointers.length === 0 ||
|
|
1214
|
+
(this._activePointers.length === 1 &&
|
|
1215
|
+
this._activePointers[0] === this._lockedPointer)
|
|
1216
|
+
) {
|
|
1217
|
+
this._isDragging = false;
|
|
1218
|
+
}
|
|
1219
|
+
if (this._activePointers.length === 0 && this._domElement) {
|
|
1220
|
+
// eslint-disable-next-line no-undef
|
|
1221
|
+
this._domElement.ownerDocument.removeEventListener(
|
|
1222
|
+
'pointermove',
|
|
1223
|
+
onPointerMove,
|
|
1224
|
+
{ passive: false }
|
|
1225
|
+
);
|
|
1226
|
+
this._domElement.ownerDocument.removeEventListener(
|
|
1227
|
+
'pointerup',
|
|
1228
|
+
onPointerUp
|
|
1229
|
+
);
|
|
1230
|
+
this.dispatchEvent({ type: 'controlend' });
|
|
1231
|
+
}
|
|
1232
|
+
};
|
|
1233
|
+
this.lockPointer = () => {
|
|
1234
|
+
if (!this._enabled || !this._domElement) return;
|
|
1235
|
+
this.cancel();
|
|
1236
|
+
// Element.requestPointerLock is allowed to happen without any pointer active - create a faux one for compatibility with controls
|
|
1237
|
+
this._lockedPointer = {
|
|
1238
|
+
pointerId: -1,
|
|
1239
|
+
clientX: 0,
|
|
1240
|
+
clientY: 0,
|
|
1241
|
+
deltaX: 0,
|
|
1242
|
+
deltaY: 0,
|
|
1243
|
+
mouseButton: null
|
|
1244
|
+
};
|
|
1245
|
+
this._activePointers.push(this._lockedPointer);
|
|
1246
|
+
// eslint-disable-next-line no-undef
|
|
1247
|
+
this._domElement.ownerDocument.removeEventListener(
|
|
1248
|
+
'pointermove',
|
|
1249
|
+
onPointerMove,
|
|
1250
|
+
{ passive: false }
|
|
1251
|
+
);
|
|
1252
|
+
this._domElement.ownerDocument.removeEventListener(
|
|
1253
|
+
'pointerup',
|
|
1254
|
+
onPointerUp
|
|
1255
|
+
);
|
|
1256
|
+
this._domElement.requestPointerLock();
|
|
1257
|
+
this._domElement.ownerDocument.addEventListener(
|
|
1258
|
+
'pointerlockchange',
|
|
1259
|
+
onPointerLockChange
|
|
1260
|
+
);
|
|
1261
|
+
this._domElement.ownerDocument.addEventListener(
|
|
1262
|
+
'pointerlockerror',
|
|
1263
|
+
onPointerLockError
|
|
1264
|
+
);
|
|
1265
|
+
this._domElement.ownerDocument.addEventListener(
|
|
1266
|
+
'pointermove',
|
|
1267
|
+
onPointerMove,
|
|
1268
|
+
{ passive: false }
|
|
1269
|
+
);
|
|
1270
|
+
this._domElement.ownerDocument.addEventListener('pointerup', onPointerUp);
|
|
1271
|
+
startDragging();
|
|
1272
|
+
};
|
|
1273
|
+
this.unlockPointer = () => {
|
|
1274
|
+
var _a, _b, _c;
|
|
1275
|
+
if (this._lockedPointer !== null) {
|
|
1276
|
+
this._disposePointer(this._lockedPointer);
|
|
1277
|
+
this._lockedPointer = null;
|
|
1278
|
+
}
|
|
1279
|
+
(_a = this._domElement) === null || _a === void 0
|
|
1280
|
+
? void 0
|
|
1281
|
+
: _a.ownerDocument.exitPointerLock();
|
|
1282
|
+
(_b = this._domElement) === null || _b === void 0
|
|
1283
|
+
? void 0
|
|
1284
|
+
: _b.ownerDocument.removeEventListener(
|
|
1285
|
+
'pointerlockchange',
|
|
1286
|
+
onPointerLockChange
|
|
1287
|
+
);
|
|
1288
|
+
(_c = this._domElement) === null || _c === void 0
|
|
1289
|
+
? void 0
|
|
1290
|
+
: _c.ownerDocument.removeEventListener(
|
|
1291
|
+
'pointerlockerror',
|
|
1292
|
+
onPointerLockError
|
|
1293
|
+
);
|
|
1294
|
+
this.cancel();
|
|
1295
|
+
};
|
|
1296
|
+
const onPointerLockChange = () => {
|
|
1297
|
+
const isPointerLockActive =
|
|
1298
|
+
this._domElement &&
|
|
1299
|
+
this._domElement.ownerDocument.pointerLockElement === this._domElement;
|
|
1300
|
+
if (!isPointerLockActive) this.unlockPointer();
|
|
1301
|
+
};
|
|
1302
|
+
const onPointerLockError = () => {
|
|
1303
|
+
this.unlockPointer();
|
|
1304
|
+
};
|
|
1305
|
+
this._addAllEventListeners = domElement => {
|
|
1306
|
+
this._domElement = domElement;
|
|
1307
|
+
this._domElement.style.touchAction = 'none';
|
|
1308
|
+
this._domElement.style.userSelect = 'none';
|
|
1309
|
+
this._domElement.style.webkitUserSelect = 'none';
|
|
1310
|
+
this._domElement.addEventListener('pointerdown', onPointerDown);
|
|
1311
|
+
this._domElement.addEventListener('pointercancel', onPointerUp);
|
|
1312
|
+
this._domElement.addEventListener('wheel', onMouseWheel, {
|
|
1313
|
+
passive: false
|
|
1314
|
+
});
|
|
1315
|
+
this._domElement.addEventListener('contextmenu', onContextMenu);
|
|
1316
|
+
};
|
|
1317
|
+
this._removeAllEventListeners = () => {
|
|
1318
|
+
if (!this._domElement) return;
|
|
1319
|
+
this._domElement.style.touchAction = '';
|
|
1320
|
+
this._domElement.style.userSelect = '';
|
|
1321
|
+
this._domElement.style.webkitUserSelect = '';
|
|
1322
|
+
this._domElement.removeEventListener('pointerdown', onPointerDown);
|
|
1323
|
+
this._domElement.removeEventListener('pointercancel', onPointerUp);
|
|
1324
|
+
// https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/removeEventListener#matching_event_listeners_for_removal
|
|
1325
|
+
// > it's probably wise to use the same values used for the call to `addEventListener()` when calling `removeEventListener()`
|
|
1326
|
+
// see https://github.com/microsoft/TypeScript/issues/32912#issuecomment-522142969
|
|
1327
|
+
// eslint-disable-next-line no-undef
|
|
1328
|
+
this._domElement.removeEventListener('wheel', onMouseWheel, {
|
|
1329
|
+
passive: false
|
|
1330
|
+
});
|
|
1331
|
+
this._domElement.removeEventListener('contextmenu', onContextMenu);
|
|
1332
|
+
// eslint-disable-next-line no-undef
|
|
1333
|
+
this._domElement.ownerDocument.removeEventListener(
|
|
1334
|
+
'pointermove',
|
|
1335
|
+
onPointerMove,
|
|
1336
|
+
{ passive: false }
|
|
1337
|
+
);
|
|
1338
|
+
this._domElement.ownerDocument.removeEventListener(
|
|
1339
|
+
'pointerup',
|
|
1340
|
+
onPointerUp
|
|
1341
|
+
);
|
|
1342
|
+
this._domElement.ownerDocument.removeEventListener(
|
|
1343
|
+
'pointerlockchange',
|
|
1344
|
+
onPointerLockChange
|
|
1345
|
+
);
|
|
1346
|
+
this._domElement.ownerDocument.removeEventListener(
|
|
1347
|
+
'pointerlockerror',
|
|
1348
|
+
onPointerLockError
|
|
1349
|
+
);
|
|
1350
|
+
};
|
|
1351
|
+
this.cancel = () => {
|
|
1352
|
+
if (this._state === ACTION.NONE) return;
|
|
1353
|
+
this._state = ACTION.NONE;
|
|
1354
|
+
this._activePointers.length = 0;
|
|
1355
|
+
endDragging();
|
|
1356
|
+
};
|
|
1357
|
+
if (domElement) this.connect(domElement);
|
|
1358
|
+
this.update(0);
|
|
1359
|
+
}
|
|
1360
|
+
/**
|
|
1361
|
+
* The camera to be controlled
|
|
1362
|
+
* @category Properties
|
|
1363
|
+
*/
|
|
1364
|
+
get camera() {
|
|
1365
|
+
return this._camera;
|
|
1366
|
+
}
|
|
1367
|
+
set camera(camera) {
|
|
1368
|
+
this._camera = camera;
|
|
1369
|
+
this.updateCameraUp();
|
|
1370
|
+
this._camera.updateProjectionMatrix();
|
|
1371
|
+
this._updateNearPlaneCorners();
|
|
1372
|
+
this._needsUpdate = true;
|
|
1373
|
+
}
|
|
1374
|
+
/**
|
|
1375
|
+
* Whether or not the controls are enabled.
|
|
1376
|
+
* `false` to disable user dragging/touch-move, but all methods works.
|
|
1377
|
+
* @category Properties
|
|
1378
|
+
*/
|
|
1379
|
+
get enabled() {
|
|
1380
|
+
return this._enabled;
|
|
1381
|
+
}
|
|
1382
|
+
set enabled(enabled) {
|
|
1383
|
+
this._enabled = enabled;
|
|
1384
|
+
if (!this._domElement) return;
|
|
1385
|
+
if (enabled) {
|
|
1386
|
+
this._domElement.style.touchAction = 'none';
|
|
1387
|
+
this._domElement.style.userSelect = 'none';
|
|
1388
|
+
this._domElement.style.webkitUserSelect = 'none';
|
|
1389
|
+
} else {
|
|
1390
|
+
this.cancel();
|
|
1391
|
+
this._domElement.style.touchAction = '';
|
|
1392
|
+
this._domElement.style.userSelect = '';
|
|
1393
|
+
this._domElement.style.webkitUserSelect = '';
|
|
1394
|
+
}
|
|
1395
|
+
}
|
|
1396
|
+
/**
|
|
1397
|
+
* Returns `true` if the controls are active updating.
|
|
1398
|
+
* readonly value.
|
|
1399
|
+
* @category Properties
|
|
1400
|
+
*/
|
|
1401
|
+
get active() {
|
|
1402
|
+
return !this._hasRested;
|
|
1403
|
+
}
|
|
1404
|
+
/**
|
|
1405
|
+
* Getter for the current `ACTION`.
|
|
1406
|
+
* readonly value.
|
|
1407
|
+
* @category Properties
|
|
1408
|
+
*/
|
|
1409
|
+
get currentAction() {
|
|
1410
|
+
return this._state;
|
|
1411
|
+
}
|
|
1412
|
+
/**
|
|
1413
|
+
* get/set Current distance.
|
|
1414
|
+
* @category Properties
|
|
1415
|
+
*/
|
|
1416
|
+
get distance() {
|
|
1417
|
+
return this._spherical.radius;
|
|
1418
|
+
}
|
|
1419
|
+
set distance(distance) {
|
|
1420
|
+
if (
|
|
1421
|
+
this._spherical.radius === distance &&
|
|
1422
|
+
this._sphericalEnd.radius === distance
|
|
1423
|
+
)
|
|
1424
|
+
return;
|
|
1425
|
+
this._spherical.radius = distance;
|
|
1426
|
+
this._sphericalEnd.radius = distance;
|
|
1427
|
+
this._needsUpdate = true;
|
|
1428
|
+
}
|
|
1429
|
+
// horizontal angle
|
|
1430
|
+
/**
|
|
1431
|
+
* get/set the azimuth angle (horizontal) in radians.
|
|
1432
|
+
* Every 360 degrees turn is added to `.azimuthAngle` value, which is accumulative.
|
|
1433
|
+
* @category Properties
|
|
1434
|
+
*/
|
|
1435
|
+
get azimuthAngle() {
|
|
1436
|
+
return this._spherical.theta;
|
|
1437
|
+
}
|
|
1438
|
+
set azimuthAngle(azimuthAngle) {
|
|
1439
|
+
if (
|
|
1440
|
+
this._spherical.theta === azimuthAngle &&
|
|
1441
|
+
this._sphericalEnd.theta === azimuthAngle
|
|
1442
|
+
)
|
|
1443
|
+
return;
|
|
1444
|
+
this._spherical.theta = azimuthAngle;
|
|
1445
|
+
this._sphericalEnd.theta = azimuthAngle;
|
|
1446
|
+
this._needsUpdate = true;
|
|
1447
|
+
}
|
|
1448
|
+
// vertical angle
|
|
1449
|
+
/**
|
|
1450
|
+
* get/set the polar angle (vertical) in radians.
|
|
1451
|
+
* @category Properties
|
|
1452
|
+
*/
|
|
1453
|
+
get polarAngle() {
|
|
1454
|
+
return this._spherical.phi;
|
|
1455
|
+
}
|
|
1456
|
+
set polarAngle(polarAngle) {
|
|
1457
|
+
if (
|
|
1458
|
+
this._spherical.phi === polarAngle &&
|
|
1459
|
+
this._sphericalEnd.phi === polarAngle
|
|
1460
|
+
)
|
|
1461
|
+
return;
|
|
1462
|
+
this._spherical.phi = polarAngle;
|
|
1463
|
+
this._sphericalEnd.phi = polarAngle;
|
|
1464
|
+
this._needsUpdate = true;
|
|
1465
|
+
}
|
|
1466
|
+
/**
|
|
1467
|
+
* Whether camera position should be enclosed in the boundary or not.
|
|
1468
|
+
* @category Properties
|
|
1469
|
+
*/
|
|
1470
|
+
get boundaryEnclosesCamera() {
|
|
1471
|
+
return this._boundaryEnclosesCamera;
|
|
1472
|
+
}
|
|
1473
|
+
set boundaryEnclosesCamera(boundaryEnclosesCamera) {
|
|
1474
|
+
this._boundaryEnclosesCamera = boundaryEnclosesCamera;
|
|
1475
|
+
this._needsUpdate = true;
|
|
1476
|
+
}
|
|
1477
|
+
/**
|
|
1478
|
+
* Set drag-start, touches and wheel enable area in the domElement.
|
|
1479
|
+
* each values are between `0` and `1` inclusive, where `0` is left/top and `1` is right/bottom of the screen.
|
|
1480
|
+
* e.g. `{ x: 0, y: 0, width: 1, height: 1 }` for entire area.
|
|
1481
|
+
* @category Properties
|
|
1482
|
+
*/
|
|
1483
|
+
set interactiveArea(interactiveArea) {
|
|
1484
|
+
this._interactiveArea.width = clamp(interactiveArea.width, 0, 1);
|
|
1485
|
+
this._interactiveArea.height = clamp(interactiveArea.height, 0, 1);
|
|
1486
|
+
this._interactiveArea.x = clamp(
|
|
1487
|
+
interactiveArea.x,
|
|
1488
|
+
0,
|
|
1489
|
+
1 - this._interactiveArea.width
|
|
1490
|
+
);
|
|
1491
|
+
this._interactiveArea.y = clamp(
|
|
1492
|
+
interactiveArea.y,
|
|
1493
|
+
0,
|
|
1494
|
+
1 - this._interactiveArea.height
|
|
1495
|
+
);
|
|
1496
|
+
}
|
|
1497
|
+
/**
|
|
1498
|
+
* Adds the specified event listener.
|
|
1499
|
+
* Applicable event types (which is `K`) are:
|
|
1500
|
+
* | Event name | Timing |
|
|
1501
|
+
* | ------------------- | ------ |
|
|
1502
|
+
* | `'controlstart'` | When the user starts to control the camera via mouse / touches. ¹ |
|
|
1503
|
+
* | `'control'` | When the user controls the camera (dragging). |
|
|
1504
|
+
* | `'controlend'` | When the user ends to control the camera. ¹ |
|
|
1505
|
+
* | `'transitionstart'` | When any kind of transition starts, either user control or using a method with `enableTransition = true` |
|
|
1506
|
+
* | `'update'` | When the camera position is updated. |
|
|
1507
|
+
* | `'wake'` | When the camera starts moving. |
|
|
1508
|
+
* | `'rest'` | When the camera movement is below `.restThreshold` ². |
|
|
1509
|
+
* | `'sleep'` | When the camera end moving. |
|
|
1510
|
+
*
|
|
1511
|
+
* 1. `mouseButtons.wheel` (Mouse wheel control) does not emit `'controlstart'` and `'controlend'`. `mouseButtons.wheel` uses scroll-event internally, and scroll-event happens intermittently. That means "start" and "end" cannot be detected.
|
|
1512
|
+
* 2. Due to damping, `sleep` will usually fire a few seconds after the camera _appears_ to have stopped moving. If you want to do something (e.g. enable UI, perform another transition) at the point when the camera has stopped, you probably want the `rest` event. This can be fine tuned using the `.restThreshold` parameter. See the [Rest and Sleep Example](https://yomotsu.github.io/camera-controls/examples/rest-and-sleep.html).
|
|
1513
|
+
*
|
|
1514
|
+
* e.g.
|
|
1515
|
+
* ```
|
|
1516
|
+
* cameraControl.addEventListener( 'controlstart', myCallbackFunction );
|
|
1517
|
+
* ```
|
|
1518
|
+
* @param type event name
|
|
1519
|
+
* @param listener handler function
|
|
1520
|
+
* @category Methods
|
|
1521
|
+
*/
|
|
1522
|
+
addEventListener(type, listener) {
|
|
1523
|
+
super.addEventListener(type, listener);
|
|
1524
|
+
}
|
|
1525
|
+
/**
|
|
1526
|
+
* Removes the specified event listener
|
|
1527
|
+
* e.g.
|
|
1528
|
+
* ```
|
|
1529
|
+
* cameraControl.addEventListener( 'controlstart', myCallbackFunction );
|
|
1530
|
+
* ```
|
|
1531
|
+
* @param type event name
|
|
1532
|
+
* @param listener handler function
|
|
1533
|
+
* @category Methods
|
|
1534
|
+
*/
|
|
1535
|
+
removeEventListener(type, listener) {
|
|
1536
|
+
super.removeEventListener(type, listener);
|
|
1537
|
+
}
|
|
1538
|
+
/**
|
|
1539
|
+
* Rotate azimuthal angle(horizontal) and polar angle(vertical).
|
|
1540
|
+
* Every value is added to the current value.
|
|
1541
|
+
* @param azimuthAngle Azimuth rotate angle. In radian.
|
|
1542
|
+
* @param polarAngle Polar rotate angle. In radian.
|
|
1543
|
+
* @param enableTransition Whether to move smoothly or immediately
|
|
1544
|
+
* @category Methods
|
|
1545
|
+
*/
|
|
1546
|
+
rotate(azimuthAngle, polarAngle, enableTransition = false) {
|
|
1547
|
+
return this.rotateTo(
|
|
1548
|
+
this._sphericalEnd.theta + azimuthAngle,
|
|
1549
|
+
this._sphericalEnd.phi + polarAngle,
|
|
1550
|
+
enableTransition
|
|
1551
|
+
);
|
|
1552
|
+
}
|
|
1553
|
+
/**
|
|
1554
|
+
* Rotate azimuthal angle(horizontal) to the given angle and keep the same polar angle(vertical) target.
|
|
1555
|
+
*
|
|
1556
|
+
* e.g.
|
|
1557
|
+
* ```
|
|
1558
|
+
* cameraControls.rotateAzimuthTo( 30 * THREE.MathUtils.DEG2RAD, true );
|
|
1559
|
+
* ```
|
|
1560
|
+
* @param azimuthAngle Azimuth rotate angle. In radian.
|
|
1561
|
+
* @param enableTransition Whether to move smoothly or immediately
|
|
1562
|
+
* @category Methods
|
|
1563
|
+
*/
|
|
1564
|
+
rotateAzimuthTo(azimuthAngle, enableTransition = false) {
|
|
1565
|
+
return this.rotateTo(
|
|
1566
|
+
azimuthAngle,
|
|
1567
|
+
this._sphericalEnd.phi,
|
|
1568
|
+
enableTransition
|
|
1569
|
+
);
|
|
1570
|
+
}
|
|
1571
|
+
/**
|
|
1572
|
+
* Rotate polar angle(vertical) to the given angle and keep the same azimuthal angle(horizontal) target.
|
|
1573
|
+
*
|
|
1574
|
+
* e.g.
|
|
1575
|
+
* ```
|
|
1576
|
+
* cameraControls.rotatePolarTo( 30 * THREE.MathUtils.DEG2RAD, true );
|
|
1577
|
+
* ```
|
|
1578
|
+
* @param polarAngle Polar rotate angle. In radian.
|
|
1579
|
+
* @param enableTransition Whether to move smoothly or immediately
|
|
1580
|
+
* @category Methods
|
|
1581
|
+
*/
|
|
1582
|
+
rotatePolarTo(polarAngle, enableTransition = false) {
|
|
1583
|
+
return this.rotateTo(
|
|
1584
|
+
this._sphericalEnd.theta,
|
|
1585
|
+
polarAngle,
|
|
1586
|
+
enableTransition
|
|
1587
|
+
);
|
|
1588
|
+
}
|
|
1589
|
+
/**
|
|
1590
|
+
* Rotate azimuthal angle(horizontal) and polar angle(vertical) to the given angle.
|
|
1591
|
+
* Camera view will rotate over the orbit pivot absolutely:
|
|
1592
|
+
*
|
|
1593
|
+
* azimuthAngle
|
|
1594
|
+
* ```
|
|
1595
|
+
* 0º
|
|
1596
|
+
* \
|
|
1597
|
+
* 90º -----+----- -90º
|
|
1598
|
+
* \
|
|
1599
|
+
* 180º
|
|
1600
|
+
* ```
|
|
1601
|
+
* | direction | angle |
|
|
1602
|
+
* | --------- | ---------------------- |
|
|
1603
|
+
* | front | 0º |
|
|
1604
|
+
* | left | 90º (`Math.PI / 2`) |
|
|
1605
|
+
* | right | -90º (`- Math.PI / 2`) |
|
|
1606
|
+
* | back | 180º (`Math.PI`) |
|
|
1607
|
+
*
|
|
1608
|
+
* polarAngle
|
|
1609
|
+
* ```
|
|
1610
|
+
* 180º
|
|
1611
|
+
* |
|
|
1612
|
+
* 90º
|
|
1613
|
+
* |
|
|
1614
|
+
* 0º
|
|
1615
|
+
* ```
|
|
1616
|
+
* | direction | angle |
|
|
1617
|
+
* | -------------------- | ---------------------- |
|
|
1618
|
+
* | top/sky | 180º (`Math.PI`) |
|
|
1619
|
+
* | horizontal from view | 90º (`Math.PI / 2`) |
|
|
1620
|
+
* | bottom/floor | 0º |
|
|
1621
|
+
*
|
|
1622
|
+
* @param azimuthAngle Azimuth rotate angle to. In radian.
|
|
1623
|
+
* @param polarAngle Polar rotate angle to. In radian.
|
|
1624
|
+
* @param enableTransition Whether to move smoothly or immediately
|
|
1625
|
+
* @category Methods
|
|
1626
|
+
*/
|
|
1627
|
+
rotateTo(azimuthAngle, polarAngle, enableTransition = false) {
|
|
1628
|
+
this._isUserControllingRotate = false;
|
|
1629
|
+
const theta = clamp(
|
|
1630
|
+
azimuthAngle,
|
|
1631
|
+
this.minAzimuthAngle,
|
|
1632
|
+
this.maxAzimuthAngle
|
|
1633
|
+
);
|
|
1634
|
+
const phi = clamp(polarAngle, this.minPolarAngle, this.maxPolarAngle);
|
|
1635
|
+
this._sphericalEnd.theta = theta;
|
|
1636
|
+
this._sphericalEnd.phi = phi;
|
|
1637
|
+
this._sphericalEnd.makeSafe();
|
|
1638
|
+
this._needsUpdate = true;
|
|
1639
|
+
if (!enableTransition) {
|
|
1640
|
+
this._spherical.theta = this._sphericalEnd.theta;
|
|
1641
|
+
this._spherical.phi = this._sphericalEnd.phi;
|
|
1642
|
+
}
|
|
1643
|
+
const resolveImmediately =
|
|
1644
|
+
!enableTransition ||
|
|
1645
|
+
(approxEquals(
|
|
1646
|
+
this._spherical.theta,
|
|
1647
|
+
this._sphericalEnd.theta,
|
|
1648
|
+
this.restThreshold
|
|
1649
|
+
) &&
|
|
1650
|
+
approxEquals(
|
|
1651
|
+
this._spherical.phi,
|
|
1652
|
+
this._sphericalEnd.phi,
|
|
1653
|
+
this.restThreshold
|
|
1654
|
+
));
|
|
1655
|
+
return this._createOnRestPromise(resolveImmediately);
|
|
1656
|
+
}
|
|
1657
|
+
/**
|
|
1658
|
+
* Dolly in/out camera position.
|
|
1659
|
+
* @param distance Distance of dollyIn. Negative number for dollyOut.
|
|
1660
|
+
* @param enableTransition Whether to move smoothly or immediately.
|
|
1661
|
+
* @category Methods
|
|
1662
|
+
*/
|
|
1663
|
+
dolly(distance, enableTransition = false) {
|
|
1664
|
+
return this.dollyTo(this._sphericalEnd.radius - distance, enableTransition);
|
|
1665
|
+
}
|
|
1666
|
+
/**
|
|
1667
|
+
* Dolly in/out camera position to given distance.
|
|
1668
|
+
* @param distance Distance of dolly.
|
|
1669
|
+
* @param enableTransition Whether to move smoothly or immediately.
|
|
1670
|
+
* @category Methods
|
|
1671
|
+
*/
|
|
1672
|
+
dollyTo(distance, enableTransition = false) {
|
|
1673
|
+
this._isUserControllingDolly = false;
|
|
1674
|
+
this._lastDollyDirection = DOLLY_DIRECTION.NONE;
|
|
1675
|
+
this._changedDolly = 0;
|
|
1676
|
+
return this._dollyToNoClamp(
|
|
1677
|
+
clamp(distance, this.minDistance, this.maxDistance),
|
|
1678
|
+
enableTransition
|
|
1679
|
+
);
|
|
1680
|
+
}
|
|
1681
|
+
_dollyToNoClamp(distance, enableTransition = false) {
|
|
1682
|
+
const lastRadius = this._sphericalEnd.radius;
|
|
1683
|
+
const hasCollider = this.colliderMeshes.length >= 1;
|
|
1684
|
+
if (hasCollider) {
|
|
1685
|
+
const maxDistanceByCollisionTest = this._collisionTest();
|
|
1686
|
+
const isCollided = approxEquals(
|
|
1687
|
+
maxDistanceByCollisionTest,
|
|
1688
|
+
this._spherical.radius
|
|
1689
|
+
);
|
|
1690
|
+
const isDollyIn = lastRadius > distance;
|
|
1691
|
+
if (!isDollyIn && isCollided) return Promise.resolve();
|
|
1692
|
+
this._sphericalEnd.radius = Math.min(
|
|
1693
|
+
distance,
|
|
1694
|
+
maxDistanceByCollisionTest
|
|
1695
|
+
);
|
|
1696
|
+
} else {
|
|
1697
|
+
this._sphericalEnd.radius = distance;
|
|
1698
|
+
}
|
|
1699
|
+
this._needsUpdate = true;
|
|
1700
|
+
if (!enableTransition) {
|
|
1701
|
+
this._spherical.radius = this._sphericalEnd.radius;
|
|
1702
|
+
}
|
|
1703
|
+
const resolveImmediately =
|
|
1704
|
+
!enableTransition ||
|
|
1705
|
+
approxEquals(
|
|
1706
|
+
this._spherical.radius,
|
|
1707
|
+
this._sphericalEnd.radius,
|
|
1708
|
+
this.restThreshold
|
|
1709
|
+
);
|
|
1710
|
+
return this._createOnRestPromise(resolveImmediately);
|
|
1711
|
+
}
|
|
1712
|
+
/**
|
|
1713
|
+
* Dolly in, but does not change the distance between the target and the camera, and moves the target position instead.
|
|
1714
|
+
* Specify a negative value for dolly out.
|
|
1715
|
+
* @param distance Distance of dolly.
|
|
1716
|
+
* @param enableTransition Whether to move smoothly or immediately.
|
|
1717
|
+
* @category Methods
|
|
1718
|
+
*/
|
|
1719
|
+
dollyInFixed(distance, enableTransition = false) {
|
|
1720
|
+
this._targetEnd.add(
|
|
1721
|
+
this._getCameraDirection(_cameraDirection).multiplyScalar(distance)
|
|
1722
|
+
);
|
|
1723
|
+
if (!enableTransition) {
|
|
1724
|
+
this._target.copy(this._targetEnd);
|
|
1725
|
+
}
|
|
1726
|
+
const resolveImmediately =
|
|
1727
|
+
!enableTransition ||
|
|
1728
|
+
(approxEquals(this._target.x, this._targetEnd.x, this.restThreshold) &&
|
|
1729
|
+
approxEquals(this._target.y, this._targetEnd.y, this.restThreshold) &&
|
|
1730
|
+
approxEquals(this._target.z, this._targetEnd.z, this.restThreshold));
|
|
1731
|
+
return this._createOnRestPromise(resolveImmediately);
|
|
1732
|
+
}
|
|
1733
|
+
/**
|
|
1734
|
+
* Zoom in/out camera. The value is added to camera zoom.
|
|
1735
|
+
* Limits set with `.minZoom` and `.maxZoom`
|
|
1736
|
+
* @param zoomStep zoom scale
|
|
1737
|
+
* @param enableTransition Whether to move smoothly or immediately
|
|
1738
|
+
* @category Methods
|
|
1739
|
+
*/
|
|
1740
|
+
zoom(zoomStep, enableTransition = false) {
|
|
1741
|
+
return this.zoomTo(this._zoomEnd + zoomStep, enableTransition);
|
|
1742
|
+
}
|
|
1743
|
+
/**
|
|
1744
|
+
* Zoom in/out camera to given scale. The value overwrites camera zoom.
|
|
1745
|
+
* Limits set with .minZoom and .maxZoom
|
|
1746
|
+
* @param zoom
|
|
1747
|
+
* @param enableTransition
|
|
1748
|
+
* @category Methods
|
|
1749
|
+
*/
|
|
1750
|
+
zoomTo(zoom, enableTransition = false) {
|
|
1751
|
+
this._isUserControllingZoom = false;
|
|
1752
|
+
this._zoomEnd = clamp(zoom, this.minZoom, this.maxZoom);
|
|
1753
|
+
this._needsUpdate = true;
|
|
1754
|
+
if (!enableTransition) {
|
|
1755
|
+
this._zoom = this._zoomEnd;
|
|
1756
|
+
}
|
|
1757
|
+
const resolveImmediately =
|
|
1758
|
+
!enableTransition ||
|
|
1759
|
+
approxEquals(this._zoom, this._zoomEnd, this.restThreshold);
|
|
1760
|
+
this._changedZoom = 0;
|
|
1761
|
+
return this._createOnRestPromise(resolveImmediately);
|
|
1762
|
+
}
|
|
1763
|
+
/**
|
|
1764
|
+
* @deprecated `pan()` has been renamed to `truck()`
|
|
1765
|
+
* @category Methods
|
|
1766
|
+
*/
|
|
1767
|
+
pan(x, y, enableTransition = false) {
|
|
1768
|
+
console.warn('`pan` has been renamed to `truck`');
|
|
1769
|
+
return this.truck(x, y, enableTransition);
|
|
1770
|
+
}
|
|
1771
|
+
/**
|
|
1772
|
+
* Truck and pedestal camera using current azimuthal angle
|
|
1773
|
+
* @param x Horizontal translate amount
|
|
1774
|
+
* @param y Vertical translate amount
|
|
1775
|
+
* @param enableTransition Whether to move smoothly or immediately
|
|
1776
|
+
* @category Methods
|
|
1777
|
+
*/
|
|
1778
|
+
truck(x, y, enableTransition = false) {
|
|
1779
|
+
this._camera.updateMatrix();
|
|
1780
|
+
_xColumn.setFromMatrixColumn(this._camera.matrix, 0);
|
|
1781
|
+
_yColumn.setFromMatrixColumn(this._camera.matrix, 1);
|
|
1782
|
+
_xColumn.multiplyScalar(x);
|
|
1783
|
+
_yColumn.multiplyScalar(-y);
|
|
1784
|
+
const offset = _v3A.copy(_xColumn).add(_yColumn);
|
|
1785
|
+
const to = _v3B.copy(this._targetEnd).add(offset);
|
|
1786
|
+
return this.moveTo(to.x, to.y, to.z, enableTransition);
|
|
1787
|
+
}
|
|
1788
|
+
/**
|
|
1789
|
+
* Move forward / backward.
|
|
1790
|
+
* @param distance Amount to move forward / backward. Negative value to move backward
|
|
1791
|
+
* @param enableTransition Whether to move smoothly or immediately
|
|
1792
|
+
* @category Methods
|
|
1793
|
+
*/
|
|
1794
|
+
forward(distance, enableTransition = false) {
|
|
1795
|
+
_v3A.setFromMatrixColumn(this._camera.matrix, 0);
|
|
1796
|
+
_v3A.crossVectors(this._camera.up, _v3A);
|
|
1797
|
+
_v3A.multiplyScalar(distance);
|
|
1798
|
+
const to = _v3B.copy(this._targetEnd).add(_v3A);
|
|
1799
|
+
return this.moveTo(to.x, to.y, to.z, enableTransition);
|
|
1800
|
+
}
|
|
1801
|
+
/**
|
|
1802
|
+
* Move up / down.
|
|
1803
|
+
* @param height Amount to move up / down. Negative value to move down
|
|
1804
|
+
* @param enableTransition Whether to move smoothly or immediately
|
|
1805
|
+
* @category Methods
|
|
1806
|
+
*/
|
|
1807
|
+
elevate(height, enableTransition = false) {
|
|
1808
|
+
_v3A.copy(this._camera.up).multiplyScalar(height);
|
|
1809
|
+
return this.moveTo(
|
|
1810
|
+
this._targetEnd.x + _v3A.x,
|
|
1811
|
+
this._targetEnd.y + _v3A.y,
|
|
1812
|
+
this._targetEnd.z + _v3A.z,
|
|
1813
|
+
enableTransition
|
|
1814
|
+
);
|
|
1815
|
+
}
|
|
1816
|
+
/**
|
|
1817
|
+
* Move target position to given point.
|
|
1818
|
+
* @param x x coord to move center position
|
|
1819
|
+
* @param y y coord to move center position
|
|
1820
|
+
* @param z z coord to move center position
|
|
1821
|
+
* @param enableTransition Whether to move smoothly or immediately
|
|
1822
|
+
* @category Methods
|
|
1823
|
+
*/
|
|
1824
|
+
moveTo(x, y, z, enableTransition = false) {
|
|
1825
|
+
this._isUserControllingTruck = false;
|
|
1826
|
+
const offset = _v3A.set(x, y, z).sub(this._targetEnd);
|
|
1827
|
+
this._encloseToBoundary(this._targetEnd, offset, this.boundaryFriction);
|
|
1828
|
+
this._needsUpdate = true;
|
|
1829
|
+
if (!enableTransition) {
|
|
1830
|
+
this._target.copy(this._targetEnd);
|
|
1831
|
+
}
|
|
1832
|
+
const resolveImmediately =
|
|
1833
|
+
!enableTransition ||
|
|
1834
|
+
(approxEquals(this._target.x, this._targetEnd.x, this.restThreshold) &&
|
|
1835
|
+
approxEquals(this._target.y, this._targetEnd.y, this.restThreshold) &&
|
|
1836
|
+
approxEquals(this._target.z, this._targetEnd.z, this.restThreshold));
|
|
1837
|
+
return this._createOnRestPromise(resolveImmediately);
|
|
1838
|
+
}
|
|
1839
|
+
/**
|
|
1840
|
+
* Look in the given point direction.
|
|
1841
|
+
* @param x point x.
|
|
1842
|
+
* @param y point y.
|
|
1843
|
+
* @param z point z.
|
|
1844
|
+
* @param enableTransition Whether to move smoothly or immediately.
|
|
1845
|
+
* @returns Transition end promise
|
|
1846
|
+
* @category Methods
|
|
1847
|
+
*/
|
|
1848
|
+
lookInDirectionOf(x, y, z, enableTransition = false) {
|
|
1849
|
+
const point = _v3A.set(x, y, z);
|
|
1850
|
+
const direction = point.sub(this._targetEnd).normalize();
|
|
1851
|
+
const position = direction
|
|
1852
|
+
.multiplyScalar(-this._sphericalEnd.radius)
|
|
1853
|
+
.add(this._targetEnd);
|
|
1854
|
+
return this.setPosition(
|
|
1855
|
+
position.x,
|
|
1856
|
+
position.y,
|
|
1857
|
+
position.z,
|
|
1858
|
+
enableTransition
|
|
1859
|
+
);
|
|
1860
|
+
}
|
|
1861
|
+
/**
|
|
1862
|
+
* Fit the viewport to the box or the bounding box of the object, using the nearest axis. paddings are in unit.
|
|
1863
|
+
* set `cover: true` to fill enter screen.
|
|
1864
|
+
* e.g.
|
|
1865
|
+
* ```
|
|
1866
|
+
* cameraControls.fitToBox( myMesh );
|
|
1867
|
+
* ```
|
|
1868
|
+
* @param box3OrObject Axis aligned bounding box to fit the view.
|
|
1869
|
+
* @param enableTransition Whether to move smoothly or immediately.
|
|
1870
|
+
* @param options | `<object>` { cover: boolean, paddingTop: number, paddingLeft: number, paddingBottom: number, paddingRight: number }
|
|
1871
|
+
* @returns Transition end promise
|
|
1872
|
+
* @category Methods
|
|
1873
|
+
*/
|
|
1874
|
+
fitToBox(
|
|
1875
|
+
box3OrObject,
|
|
1876
|
+
enableTransition,
|
|
1877
|
+
{
|
|
1878
|
+
cover = false,
|
|
1879
|
+
paddingLeft = 0,
|
|
1880
|
+
paddingRight = 0,
|
|
1881
|
+
paddingBottom = 0,
|
|
1882
|
+
paddingTop = 0
|
|
1883
|
+
} = {}
|
|
1884
|
+
) {
|
|
1885
|
+
const promises = [];
|
|
1886
|
+
const aabb = box3OrObject.isBox3
|
|
1887
|
+
? _box3A.copy(box3OrObject)
|
|
1888
|
+
: _box3A.setFromObject(box3OrObject);
|
|
1889
|
+
if (aabb.isEmpty()) {
|
|
1890
|
+
console.warn(
|
|
1891
|
+
'camera-controls: fitTo() cannot be used with an empty box. Aborting'
|
|
1892
|
+
);
|
|
1893
|
+
Promise.resolve();
|
|
1894
|
+
}
|
|
1895
|
+
// round to closest axis ( forward | backward | right | left | top | bottom )
|
|
1896
|
+
const theta = roundToStep(this._sphericalEnd.theta, PI_HALF);
|
|
1897
|
+
const phi = roundToStep(this._sphericalEnd.phi, PI_HALF);
|
|
1898
|
+
promises.push(this.rotateTo(theta, phi, enableTransition));
|
|
1899
|
+
const normal = _v3A.setFromSpherical(this._sphericalEnd).normalize();
|
|
1900
|
+
const rotation = _quaternionA.setFromUnitVectors(normal, _AXIS_Z);
|
|
1901
|
+
const viewFromPolar = approxEquals(Math.abs(normal.y), 1);
|
|
1902
|
+
if (viewFromPolar) {
|
|
1903
|
+
rotation.multiply(_quaternionB.setFromAxisAngle(_AXIS_Y, theta));
|
|
1904
|
+
}
|
|
1905
|
+
rotation.multiply(this._yAxisUpSpaceInverse);
|
|
1906
|
+
// make oriented bounding box
|
|
1907
|
+
const bb = _box3B.makeEmpty();
|
|
1908
|
+
// left bottom back corner
|
|
1909
|
+
_v3B.copy(aabb.min).applyQuaternion(rotation);
|
|
1910
|
+
bb.expandByPoint(_v3B);
|
|
1911
|
+
// right bottom back corner
|
|
1912
|
+
_v3B.copy(aabb.min).setX(aabb.max.x).applyQuaternion(rotation);
|
|
1913
|
+
bb.expandByPoint(_v3B);
|
|
1914
|
+
// left top back corner
|
|
1915
|
+
_v3B.copy(aabb.min).setY(aabb.max.y).applyQuaternion(rotation);
|
|
1916
|
+
bb.expandByPoint(_v3B);
|
|
1917
|
+
// right top back corner
|
|
1918
|
+
_v3B.copy(aabb.max).setZ(aabb.min.z).applyQuaternion(rotation);
|
|
1919
|
+
bb.expandByPoint(_v3B);
|
|
1920
|
+
// left bottom front corner
|
|
1921
|
+
_v3B.copy(aabb.min).setZ(aabb.max.z).applyQuaternion(rotation);
|
|
1922
|
+
bb.expandByPoint(_v3B);
|
|
1923
|
+
// right bottom front corner
|
|
1924
|
+
_v3B.copy(aabb.max).setY(aabb.min.y).applyQuaternion(rotation);
|
|
1925
|
+
bb.expandByPoint(_v3B);
|
|
1926
|
+
// left top front corner
|
|
1927
|
+
_v3B.copy(aabb.max).setX(aabb.min.x).applyQuaternion(rotation);
|
|
1928
|
+
bb.expandByPoint(_v3B);
|
|
1929
|
+
// right top front corner
|
|
1930
|
+
_v3B.copy(aabb.max).applyQuaternion(rotation);
|
|
1931
|
+
bb.expandByPoint(_v3B);
|
|
1932
|
+
// add padding
|
|
1933
|
+
bb.min.x -= paddingLeft;
|
|
1934
|
+
bb.min.y -= paddingBottom;
|
|
1935
|
+
bb.max.x += paddingRight;
|
|
1936
|
+
bb.max.y += paddingTop;
|
|
1937
|
+
rotation.setFromUnitVectors(_AXIS_Z, normal);
|
|
1938
|
+
if (viewFromPolar) {
|
|
1939
|
+
rotation.premultiply(_quaternionB.invert());
|
|
1940
|
+
}
|
|
1941
|
+
rotation.premultiply(this._yAxisUpSpace);
|
|
1942
|
+
const bbSize = bb.getSize(_v3A);
|
|
1943
|
+
const center = bb.getCenter(_v3B).applyQuaternion(rotation);
|
|
1944
|
+
if (isPerspectiveCamera(this._camera)) {
|
|
1945
|
+
const distance = this.getDistanceToFitBox(
|
|
1946
|
+
bbSize.x,
|
|
1947
|
+
bbSize.y,
|
|
1948
|
+
bbSize.z,
|
|
1949
|
+
cover
|
|
1950
|
+
);
|
|
1951
|
+
promises.push(
|
|
1952
|
+
this.moveTo(center.x, center.y, center.z, enableTransition)
|
|
1953
|
+
);
|
|
1954
|
+
promises.push(this.dollyTo(distance, enableTransition));
|
|
1955
|
+
promises.push(this.setFocalOffset(0, 0, 0, enableTransition));
|
|
1956
|
+
} else if (isOrthographicCamera(this._camera)) {
|
|
1957
|
+
const camera = this._camera;
|
|
1958
|
+
const width = camera.right - camera.left;
|
|
1959
|
+
const height = camera.top - camera.bottom;
|
|
1960
|
+
const zoom = cover
|
|
1961
|
+
? Math.max(width / bbSize.x, height / bbSize.y)
|
|
1962
|
+
: Math.min(width / bbSize.x, height / bbSize.y);
|
|
1963
|
+
promises.push(
|
|
1964
|
+
this.moveTo(center.x, center.y, center.z, enableTransition)
|
|
1965
|
+
);
|
|
1966
|
+
promises.push(this.zoomTo(zoom, enableTransition));
|
|
1967
|
+
promises.push(this.setFocalOffset(0, 0, 0, enableTransition));
|
|
1968
|
+
}
|
|
1969
|
+
return Promise.all(promises);
|
|
1970
|
+
}
|
|
1971
|
+
/**
|
|
1972
|
+
* Fit the viewport to the sphere or the bounding sphere of the object.
|
|
1973
|
+
* @param sphereOrMesh
|
|
1974
|
+
* @param enableTransition
|
|
1975
|
+
* @category Methods
|
|
1976
|
+
*/
|
|
1977
|
+
fitToSphere(sphereOrMesh, enableTransition) {
|
|
1978
|
+
const promises = [];
|
|
1979
|
+
const isSphere = 'isSphere' in sphereOrMesh;
|
|
1980
|
+
const boundingSphere = isSphere
|
|
1981
|
+
? _sphere.copy(sphereOrMesh)
|
|
1982
|
+
: CameraControls.createBoundingSphere(sphereOrMesh, _sphere);
|
|
1983
|
+
promises.push(
|
|
1984
|
+
this.moveTo(
|
|
1985
|
+
boundingSphere.center.x,
|
|
1986
|
+
boundingSphere.center.y,
|
|
1987
|
+
boundingSphere.center.z,
|
|
1988
|
+
enableTransition
|
|
1989
|
+
)
|
|
1990
|
+
);
|
|
1991
|
+
if (isPerspectiveCamera(this._camera)) {
|
|
1992
|
+
const distanceToFit = this.getDistanceToFitSphere(boundingSphere.radius);
|
|
1993
|
+
promises.push(this.dollyTo(distanceToFit, enableTransition));
|
|
1994
|
+
} else if (isOrthographicCamera(this._camera)) {
|
|
1995
|
+
const width = this._camera.right - this._camera.left;
|
|
1996
|
+
const height = this._camera.top - this._camera.bottom;
|
|
1997
|
+
const diameter = 2 * boundingSphere.radius;
|
|
1998
|
+
const zoom = Math.min(width / diameter, height / diameter);
|
|
1999
|
+
promises.push(this.zoomTo(zoom, enableTransition));
|
|
2000
|
+
}
|
|
2001
|
+
promises.push(this.setFocalOffset(0, 0, 0, enableTransition));
|
|
2002
|
+
return Promise.all(promises);
|
|
2003
|
+
}
|
|
2004
|
+
/**
|
|
2005
|
+
* Look at the `target` from the `position`.
|
|
2006
|
+
* @param positionX
|
|
2007
|
+
* @param positionY
|
|
2008
|
+
* @param positionZ
|
|
2009
|
+
* @param targetX
|
|
2010
|
+
* @param targetY
|
|
2011
|
+
* @param targetZ
|
|
2012
|
+
* @param enableTransition
|
|
2013
|
+
* @category Methods
|
|
2014
|
+
*/
|
|
2015
|
+
setLookAt(
|
|
2016
|
+
positionX,
|
|
2017
|
+
positionY,
|
|
2018
|
+
positionZ,
|
|
2019
|
+
targetX,
|
|
2020
|
+
targetY,
|
|
2021
|
+
targetZ,
|
|
2022
|
+
enableTransition = false
|
|
2023
|
+
) {
|
|
2024
|
+
this._isUserControllingRotate = false;
|
|
2025
|
+
this._isUserControllingDolly = false;
|
|
2026
|
+
this._isUserControllingTruck = false;
|
|
2027
|
+
this._lastDollyDirection = DOLLY_DIRECTION.NONE;
|
|
2028
|
+
this._changedDolly = 0;
|
|
2029
|
+
const target = _v3B.set(targetX, targetY, targetZ);
|
|
2030
|
+
const position = _v3A.set(positionX, positionY, positionZ);
|
|
2031
|
+
this._targetEnd.copy(target);
|
|
2032
|
+
this._sphericalEnd.setFromVector3(
|
|
2033
|
+
position.sub(target).applyQuaternion(this._yAxisUpSpace)
|
|
2034
|
+
);
|
|
2035
|
+
this.normalizeRotations();
|
|
2036
|
+
this._needsUpdate = true;
|
|
2037
|
+
if (!enableTransition) {
|
|
2038
|
+
this._target.copy(this._targetEnd);
|
|
2039
|
+
this._spherical.copy(this._sphericalEnd);
|
|
2040
|
+
}
|
|
2041
|
+
const resolveImmediately =
|
|
2042
|
+
!enableTransition ||
|
|
2043
|
+
(approxEquals(this._target.x, this._targetEnd.x, this.restThreshold) &&
|
|
2044
|
+
approxEquals(this._target.y, this._targetEnd.y, this.restThreshold) &&
|
|
2045
|
+
approxEquals(this._target.z, this._targetEnd.z, this.restThreshold) &&
|
|
2046
|
+
approxEquals(
|
|
2047
|
+
this._spherical.theta,
|
|
2048
|
+
this._sphericalEnd.theta,
|
|
2049
|
+
this.restThreshold
|
|
2050
|
+
) &&
|
|
2051
|
+
approxEquals(
|
|
2052
|
+
this._spherical.phi,
|
|
2053
|
+
this._sphericalEnd.phi,
|
|
2054
|
+
this.restThreshold
|
|
2055
|
+
) &&
|
|
2056
|
+
approxEquals(
|
|
2057
|
+
this._spherical.radius,
|
|
2058
|
+
this._sphericalEnd.radius,
|
|
2059
|
+
this.restThreshold
|
|
2060
|
+
));
|
|
2061
|
+
return this._createOnRestPromise(resolveImmediately);
|
|
2062
|
+
}
|
|
2063
|
+
/**
|
|
2064
|
+
* Similar to setLookAt, but it interpolates between two states.
|
|
2065
|
+
* @param positionAX
|
|
2066
|
+
* @param positionAY
|
|
2067
|
+
* @param positionAZ
|
|
2068
|
+
* @param targetAX
|
|
2069
|
+
* @param targetAY
|
|
2070
|
+
* @param targetAZ
|
|
2071
|
+
* @param positionBX
|
|
2072
|
+
* @param positionBY
|
|
2073
|
+
* @param positionBZ
|
|
2074
|
+
* @param targetBX
|
|
2075
|
+
* @param targetBY
|
|
2076
|
+
* @param targetBZ
|
|
2077
|
+
* @param t
|
|
2078
|
+
* @param enableTransition
|
|
2079
|
+
* @category Methods
|
|
2080
|
+
*/
|
|
2081
|
+
lerpLookAt(
|
|
2082
|
+
positionAX,
|
|
2083
|
+
positionAY,
|
|
2084
|
+
positionAZ,
|
|
2085
|
+
targetAX,
|
|
2086
|
+
targetAY,
|
|
2087
|
+
targetAZ,
|
|
2088
|
+
positionBX,
|
|
2089
|
+
positionBY,
|
|
2090
|
+
positionBZ,
|
|
2091
|
+
targetBX,
|
|
2092
|
+
targetBY,
|
|
2093
|
+
targetBZ,
|
|
2094
|
+
t,
|
|
2095
|
+
enableTransition = false
|
|
2096
|
+
) {
|
|
2097
|
+
this._isUserControllingRotate = false;
|
|
2098
|
+
this._isUserControllingDolly = false;
|
|
2099
|
+
this._isUserControllingTruck = false;
|
|
2100
|
+
this._lastDollyDirection = DOLLY_DIRECTION.NONE;
|
|
2101
|
+
this._changedDolly = 0;
|
|
2102
|
+
const targetA = _v3A.set(targetAX, targetAY, targetAZ);
|
|
2103
|
+
const positionA = _v3B.set(positionAX, positionAY, positionAZ);
|
|
2104
|
+
_sphericalA.setFromVector3(
|
|
2105
|
+
positionA.sub(targetA).applyQuaternion(this._yAxisUpSpace)
|
|
2106
|
+
);
|
|
2107
|
+
const targetB = _v3C.set(targetBX, targetBY, targetBZ);
|
|
2108
|
+
const positionB = _v3B.set(positionBX, positionBY, positionBZ);
|
|
2109
|
+
_sphericalB.setFromVector3(
|
|
2110
|
+
positionB.sub(targetB).applyQuaternion(this._yAxisUpSpace)
|
|
2111
|
+
);
|
|
2112
|
+
this._targetEnd.copy(targetA.lerp(targetB, t)); // tricky
|
|
2113
|
+
const deltaTheta = _sphericalB.theta - _sphericalA.theta;
|
|
2114
|
+
const deltaPhi = _sphericalB.phi - _sphericalA.phi;
|
|
2115
|
+
const deltaRadius = _sphericalB.radius - _sphericalA.radius;
|
|
2116
|
+
this._sphericalEnd.set(
|
|
2117
|
+
_sphericalA.radius + deltaRadius * t,
|
|
2118
|
+
_sphericalA.phi + deltaPhi * t,
|
|
2119
|
+
_sphericalA.theta + deltaTheta * t
|
|
2120
|
+
);
|
|
2121
|
+
this.normalizeRotations();
|
|
2122
|
+
this._needsUpdate = true;
|
|
2123
|
+
if (!enableTransition) {
|
|
2124
|
+
this._target.copy(this._targetEnd);
|
|
2125
|
+
this._spherical.copy(this._sphericalEnd);
|
|
2126
|
+
}
|
|
2127
|
+
const resolveImmediately =
|
|
2128
|
+
!enableTransition ||
|
|
2129
|
+
(approxEquals(this._target.x, this._targetEnd.x, this.restThreshold) &&
|
|
2130
|
+
approxEquals(this._target.y, this._targetEnd.y, this.restThreshold) &&
|
|
2131
|
+
approxEquals(this._target.z, this._targetEnd.z, this.restThreshold) &&
|
|
2132
|
+
approxEquals(
|
|
2133
|
+
this._spherical.theta,
|
|
2134
|
+
this._sphericalEnd.theta,
|
|
2135
|
+
this.restThreshold
|
|
2136
|
+
) &&
|
|
2137
|
+
approxEquals(
|
|
2138
|
+
this._spherical.phi,
|
|
2139
|
+
this._sphericalEnd.phi,
|
|
2140
|
+
this.restThreshold
|
|
2141
|
+
) &&
|
|
2142
|
+
approxEquals(
|
|
2143
|
+
this._spherical.radius,
|
|
2144
|
+
this._sphericalEnd.radius,
|
|
2145
|
+
this.restThreshold
|
|
2146
|
+
));
|
|
2147
|
+
return this._createOnRestPromise(resolveImmediately);
|
|
2148
|
+
}
|
|
2149
|
+
/**
|
|
2150
|
+
* Set angle and distance by given position.
|
|
2151
|
+
* An alias of `setLookAt()`, without target change. Thus keep gazing at the current target
|
|
2152
|
+
* @param positionX
|
|
2153
|
+
* @param positionY
|
|
2154
|
+
* @param positionZ
|
|
2155
|
+
* @param enableTransition
|
|
2156
|
+
* @category Methods
|
|
2157
|
+
*/
|
|
2158
|
+
setPosition(positionX, positionY, positionZ, enableTransition = false) {
|
|
2159
|
+
return this.setLookAt(
|
|
2160
|
+
positionX,
|
|
2161
|
+
positionY,
|
|
2162
|
+
positionZ,
|
|
2163
|
+
this._targetEnd.x,
|
|
2164
|
+
this._targetEnd.y,
|
|
2165
|
+
this._targetEnd.z,
|
|
2166
|
+
enableTransition
|
|
2167
|
+
);
|
|
2168
|
+
}
|
|
2169
|
+
/**
|
|
2170
|
+
* Set the target position where gaze at.
|
|
2171
|
+
* An alias of `setLookAt()`, without position change. Thus keep the same position.
|
|
2172
|
+
* @param targetX
|
|
2173
|
+
* @param targetY
|
|
2174
|
+
* @param targetZ
|
|
2175
|
+
* @param enableTransition
|
|
2176
|
+
* @category Methods
|
|
2177
|
+
*/
|
|
2178
|
+
setTarget(targetX, targetY, targetZ, enableTransition = false) {
|
|
2179
|
+
const pos = this.getPosition(_v3A);
|
|
2180
|
+
const promise = this.setLookAt(
|
|
2181
|
+
pos.x,
|
|
2182
|
+
pos.y,
|
|
2183
|
+
pos.z,
|
|
2184
|
+
targetX,
|
|
2185
|
+
targetY,
|
|
2186
|
+
targetZ,
|
|
2187
|
+
enableTransition
|
|
2188
|
+
);
|
|
2189
|
+
// see https://github.com/yomotsu/camera-controls/issues/335
|
|
2190
|
+
this._sphericalEnd.phi = clamp(
|
|
2191
|
+
this._sphericalEnd.phi,
|
|
2192
|
+
this.minPolarAngle,
|
|
2193
|
+
this.maxPolarAngle
|
|
2194
|
+
);
|
|
2195
|
+
return promise;
|
|
2196
|
+
}
|
|
2197
|
+
/**
|
|
2198
|
+
* Set focal offset using the screen parallel coordinates. z doesn't affect in Orthographic as with Dolly.
|
|
2199
|
+
* @param x
|
|
2200
|
+
* @param y
|
|
2201
|
+
* @param z
|
|
2202
|
+
* @param enableTransition
|
|
2203
|
+
* @category Methods
|
|
2204
|
+
*/
|
|
2205
|
+
setFocalOffset(x, y, z, enableTransition = false) {
|
|
2206
|
+
this._isUserControllingOffset = false;
|
|
2207
|
+
this._focalOffsetEnd.set(x, y, z);
|
|
2208
|
+
this._needsUpdate = true;
|
|
2209
|
+
if (!enableTransition) this._focalOffset.copy(this._focalOffsetEnd);
|
|
2210
|
+
const resolveImmediately =
|
|
2211
|
+
!enableTransition ||
|
|
2212
|
+
(approxEquals(
|
|
2213
|
+
this._focalOffset.x,
|
|
2214
|
+
this._focalOffsetEnd.x,
|
|
2215
|
+
this.restThreshold
|
|
2216
|
+
) &&
|
|
2217
|
+
approxEquals(
|
|
2218
|
+
this._focalOffset.y,
|
|
2219
|
+
this._focalOffsetEnd.y,
|
|
2220
|
+
this.restThreshold
|
|
2221
|
+
) &&
|
|
2222
|
+
approxEquals(
|
|
2223
|
+
this._focalOffset.z,
|
|
2224
|
+
this._focalOffsetEnd.z,
|
|
2225
|
+
this.restThreshold
|
|
2226
|
+
));
|
|
2227
|
+
return this._createOnRestPromise(resolveImmediately);
|
|
2228
|
+
}
|
|
2229
|
+
/**
|
|
2230
|
+
* Set orbit point without moving the camera.
|
|
2231
|
+
* SHOULD NOT RUN DURING ANIMATIONS. `setOrbitPoint()` will immediately fix the positions.
|
|
2232
|
+
* @param targetX
|
|
2233
|
+
* @param targetY
|
|
2234
|
+
* @param targetZ
|
|
2235
|
+
* @category Methods
|
|
2236
|
+
*/
|
|
2237
|
+
setOrbitPoint(targetX, targetY, targetZ) {
|
|
2238
|
+
this._camera.updateMatrixWorld();
|
|
2239
|
+
_xColumn.setFromMatrixColumn(this._camera.matrixWorldInverse, 0);
|
|
2240
|
+
_yColumn.setFromMatrixColumn(this._camera.matrixWorldInverse, 1);
|
|
2241
|
+
_zColumn.setFromMatrixColumn(this._camera.matrixWorldInverse, 2);
|
|
2242
|
+
const position = _v3A.set(targetX, targetY, targetZ);
|
|
2243
|
+
const distance = position.distanceTo(this._camera.position);
|
|
2244
|
+
const cameraToPoint = position.sub(this._camera.position);
|
|
2245
|
+
_xColumn.multiplyScalar(cameraToPoint.x);
|
|
2246
|
+
_yColumn.multiplyScalar(cameraToPoint.y);
|
|
2247
|
+
_zColumn.multiplyScalar(cameraToPoint.z);
|
|
2248
|
+
_v3A.copy(_xColumn).add(_yColumn).add(_zColumn);
|
|
2249
|
+
_v3A.z = _v3A.z + distance;
|
|
2250
|
+
this.dollyTo(distance, false);
|
|
2251
|
+
this.setFocalOffset(-_v3A.x, _v3A.y, -_v3A.z, false);
|
|
2252
|
+
this.moveTo(targetX, targetY, targetZ, false);
|
|
2253
|
+
}
|
|
2254
|
+
/**
|
|
2255
|
+
* Set the boundary box that encloses the target of the camera. box3 is in THREE.Box3
|
|
2256
|
+
* @param box3
|
|
2257
|
+
* @category Methods
|
|
2258
|
+
*/
|
|
2259
|
+
setBoundary(box3) {
|
|
2260
|
+
if (!box3) {
|
|
2261
|
+
this._boundary.min.set(-Infinity, -Infinity, -Infinity);
|
|
2262
|
+
this._boundary.max.set(Infinity, Infinity, Infinity);
|
|
2263
|
+
this._needsUpdate = true;
|
|
2264
|
+
return;
|
|
2265
|
+
}
|
|
2266
|
+
this._boundary.copy(box3);
|
|
2267
|
+
this._boundary.clampPoint(this._targetEnd, this._targetEnd);
|
|
2268
|
+
this._needsUpdate = true;
|
|
2269
|
+
}
|
|
2270
|
+
/**
|
|
2271
|
+
* Set (or unset) the current viewport.
|
|
2272
|
+
* Set this when you want to use renderer viewport and .dollyToCursor feature at the same time.
|
|
2273
|
+
* @param viewportOrX
|
|
2274
|
+
* @param y
|
|
2275
|
+
* @param width
|
|
2276
|
+
* @param height
|
|
2277
|
+
* @category Methods
|
|
2278
|
+
*/
|
|
2279
|
+
setViewport(viewportOrX, y, width, height) {
|
|
2280
|
+
if (viewportOrX === null) {
|
|
2281
|
+
// null
|
|
2282
|
+
this._viewport = null;
|
|
2283
|
+
return;
|
|
2284
|
+
}
|
|
2285
|
+
this._viewport = this._viewport || new THREE.Vector4();
|
|
2286
|
+
if (typeof viewportOrX === 'number') {
|
|
2287
|
+
// number
|
|
2288
|
+
this._viewport.set(viewportOrX, y, width, height);
|
|
2289
|
+
} else {
|
|
2290
|
+
// Vector4
|
|
2291
|
+
this._viewport.copy(viewportOrX);
|
|
2292
|
+
}
|
|
2293
|
+
}
|
|
2294
|
+
/**
|
|
2295
|
+
* Calculate the distance to fit the box.
|
|
2296
|
+
* @param width box width
|
|
2297
|
+
* @param height box height
|
|
2298
|
+
* @param depth box depth
|
|
2299
|
+
* @returns distance
|
|
2300
|
+
* @category Methods
|
|
2301
|
+
*/
|
|
2302
|
+
getDistanceToFitBox(width, height, depth, cover = false) {
|
|
2303
|
+
if (notSupportedInOrthographicCamera(this._camera, 'getDistanceToFitBox'))
|
|
2304
|
+
return this._spherical.radius;
|
|
2305
|
+
const boundingRectAspect = width / height;
|
|
2306
|
+
const fov = this._camera.getEffectiveFOV() * DEG2RAD;
|
|
2307
|
+
const aspect = this._camera.aspect;
|
|
2308
|
+
const heightToFit = (
|
|
2309
|
+
cover ? boundingRectAspect > aspect : boundingRectAspect < aspect
|
|
2310
|
+
)
|
|
2311
|
+
? height
|
|
2312
|
+
: width / aspect;
|
|
2313
|
+
return (heightToFit * 0.5) / Math.tan(fov * 0.5) + depth * 0.5;
|
|
2314
|
+
}
|
|
2315
|
+
/**
|
|
2316
|
+
* Calculate the distance to fit the sphere.
|
|
2317
|
+
* @param radius sphere radius
|
|
2318
|
+
* @returns distance
|
|
2319
|
+
* @category Methods
|
|
2320
|
+
*/
|
|
2321
|
+
getDistanceToFitSphere(radius) {
|
|
2322
|
+
if (
|
|
2323
|
+
notSupportedInOrthographicCamera(this._camera, 'getDistanceToFitSphere')
|
|
2324
|
+
)
|
|
2325
|
+
return this._spherical.radius;
|
|
2326
|
+
// https://stackoverflow.com/a/44849975
|
|
2327
|
+
const vFOV = this._camera.getEffectiveFOV() * DEG2RAD;
|
|
2328
|
+
const hFOV = Math.atan(Math.tan(vFOV * 0.5) * this._camera.aspect) * 2;
|
|
2329
|
+
const fov = 1 < this._camera.aspect ? vFOV : hFOV;
|
|
2330
|
+
return radius / Math.sin(fov * 0.5);
|
|
2331
|
+
}
|
|
2332
|
+
/**
|
|
2333
|
+
* Returns the orbit center position, where the camera looking at.
|
|
2334
|
+
* @param out The receiving Vector3 instance to copy the result
|
|
2335
|
+
* @param receiveEndValue Whether receive the transition end coords or current. default is `true`
|
|
2336
|
+
* @category Methods
|
|
2337
|
+
*/
|
|
2338
|
+
getTarget(out, receiveEndValue = true) {
|
|
2339
|
+
const _out = !!out && out.isVector3 ? out : new THREE.Vector3();
|
|
2340
|
+
return _out.copy(receiveEndValue ? this._targetEnd : this._target);
|
|
2341
|
+
}
|
|
2342
|
+
/**
|
|
2343
|
+
* Returns the camera position.
|
|
2344
|
+
* @param out The receiving Vector3 instance to copy the result
|
|
2345
|
+
* @param receiveEndValue Whether receive the transition end coords or current. default is `true`
|
|
2346
|
+
* @category Methods
|
|
2347
|
+
*/
|
|
2348
|
+
getPosition(out, receiveEndValue = true) {
|
|
2349
|
+
const _out = !!out && out.isVector3 ? out : new THREE.Vector3();
|
|
2350
|
+
return _out
|
|
2351
|
+
.setFromSpherical(receiveEndValue ? this._sphericalEnd : this._spherical)
|
|
2352
|
+
.applyQuaternion(this._yAxisUpSpaceInverse)
|
|
2353
|
+
.add(receiveEndValue ? this._targetEnd : this._target);
|
|
2354
|
+
}
|
|
2355
|
+
/**
|
|
2356
|
+
* Returns the spherical coordinates of the orbit.
|
|
2357
|
+
* @param out The receiving Spherical instance to copy the result
|
|
2358
|
+
* @param receiveEndValue Whether receive the transition end coords or current. default is `true`
|
|
2359
|
+
* @category Methods
|
|
2360
|
+
*/
|
|
2361
|
+
getSpherical(out, receiveEndValue = true) {
|
|
2362
|
+
const _out = out || new THREE.Spherical();
|
|
2363
|
+
return _out.copy(receiveEndValue ? this._sphericalEnd : this._spherical);
|
|
2364
|
+
}
|
|
2365
|
+
/**
|
|
2366
|
+
* Returns the focal offset, which is how much the camera appears to be translated in screen parallel coordinates.
|
|
2367
|
+
* @param out The receiving Vector3 instance to copy the result
|
|
2368
|
+
* @param receiveEndValue Whether receive the transition end coords or current. default is `true`
|
|
2369
|
+
* @category Methods
|
|
2370
|
+
*/
|
|
2371
|
+
getFocalOffset(out, receiveEndValue = true) {
|
|
2372
|
+
const _out = !!out && out.isVector3 ? out : new THREE.Vector3();
|
|
2373
|
+
return _out.copy(
|
|
2374
|
+
receiveEndValue ? this._focalOffsetEnd : this._focalOffset
|
|
2375
|
+
);
|
|
2376
|
+
}
|
|
2377
|
+
/**
|
|
2378
|
+
* Normalize camera azimuth angle rotation between 0 and 360 degrees.
|
|
2379
|
+
* @category Methods
|
|
2380
|
+
*/
|
|
2381
|
+
normalizeRotations() {
|
|
2382
|
+
this._sphericalEnd.theta = this._sphericalEnd.theta % PI_2;
|
|
2383
|
+
if (this._sphericalEnd.theta < 0) this._sphericalEnd.theta += PI_2;
|
|
2384
|
+
this._spherical.theta +=
|
|
2385
|
+
PI_2 *
|
|
2386
|
+
Math.round((this._sphericalEnd.theta - this._spherical.theta) / PI_2);
|
|
2387
|
+
}
|
|
2388
|
+
/**
|
|
2389
|
+
* Reset all rotation and position to defaults.
|
|
2390
|
+
* @param enableTransition
|
|
2391
|
+
* @category Methods
|
|
2392
|
+
*/
|
|
2393
|
+
reset(enableTransition = false) {
|
|
2394
|
+
if (
|
|
2395
|
+
!approxEquals(this._camera.up.x, this._cameraUp0.x) ||
|
|
2396
|
+
!approxEquals(this._camera.up.y, this._cameraUp0.y) ||
|
|
2397
|
+
!approxEquals(this._camera.up.z, this._cameraUp0.z)
|
|
2398
|
+
) {
|
|
2399
|
+
this._camera.up.copy(this._cameraUp0);
|
|
2400
|
+
const position = this.getPosition(_v3A);
|
|
2401
|
+
this.updateCameraUp();
|
|
2402
|
+
this.setPosition(position.x, position.y, position.z);
|
|
2403
|
+
}
|
|
2404
|
+
const promises = [
|
|
2405
|
+
this.setLookAt(
|
|
2406
|
+
this._position0.x,
|
|
2407
|
+
this._position0.y,
|
|
2408
|
+
this._position0.z,
|
|
2409
|
+
this._target0.x,
|
|
2410
|
+
this._target0.y,
|
|
2411
|
+
this._target0.z,
|
|
2412
|
+
enableTransition
|
|
2413
|
+
),
|
|
2414
|
+
this.setFocalOffset(
|
|
2415
|
+
this._focalOffset0.x,
|
|
2416
|
+
this._focalOffset0.y,
|
|
2417
|
+
this._focalOffset0.z,
|
|
2418
|
+
enableTransition
|
|
2419
|
+
),
|
|
2420
|
+
this.zoomTo(this._zoom0, enableTransition)
|
|
2421
|
+
];
|
|
2422
|
+
return Promise.all(promises);
|
|
2423
|
+
}
|
|
2424
|
+
/**
|
|
2425
|
+
* Set current camera position as the default position.
|
|
2426
|
+
* @category Methods
|
|
2427
|
+
*/
|
|
2428
|
+
saveState() {
|
|
2429
|
+
this._cameraUp0.copy(this._camera.up);
|
|
2430
|
+
this.getTarget(this._target0);
|
|
2431
|
+
this.getPosition(this._position0);
|
|
2432
|
+
this._zoom0 = this._zoom;
|
|
2433
|
+
this._focalOffset0.copy(this._focalOffset);
|
|
2434
|
+
}
|
|
2435
|
+
/**
|
|
2436
|
+
* Sync camera-up direction.
|
|
2437
|
+
* When camera-up vector is changed, `.updateCameraUp()` must be called.
|
|
2438
|
+
* @category Methods
|
|
2439
|
+
*/
|
|
2440
|
+
updateCameraUp() {
|
|
2441
|
+
this._yAxisUpSpace.setFromUnitVectors(this._camera.up, _AXIS_Y);
|
|
2442
|
+
this._yAxisUpSpaceInverse.copy(this._yAxisUpSpace).invert();
|
|
2443
|
+
}
|
|
2444
|
+
/**
|
|
2445
|
+
* Apply current camera-up direction to the camera.
|
|
2446
|
+
* The orbit system will be re-initialized with the current position.
|
|
2447
|
+
* @category Methods
|
|
2448
|
+
*/
|
|
2449
|
+
applyCameraUp() {
|
|
2450
|
+
const cameraDirection = _v3A
|
|
2451
|
+
.subVectors(this._target, this._camera.position)
|
|
2452
|
+
.normalize();
|
|
2453
|
+
// So first find the vector off to the side, orthogonal to both this.object.up and
|
|
2454
|
+
// the "view" vector.
|
|
2455
|
+
const side = _v3B.crossVectors(cameraDirection, this._camera.up);
|
|
2456
|
+
// Then find the vector orthogonal to both this "side" vector and the "view" vector.
|
|
2457
|
+
// This vector will be the new "up" vector.
|
|
2458
|
+
this._camera.up.crossVectors(side, cameraDirection).normalize();
|
|
2459
|
+
this._camera.updateMatrixWorld();
|
|
2460
|
+
const position = this.getPosition(_v3A);
|
|
2461
|
+
this.updateCameraUp();
|
|
2462
|
+
this.setPosition(position.x, position.y, position.z);
|
|
2463
|
+
}
|
|
2464
|
+
/**
|
|
2465
|
+
* Update camera position and directions.
|
|
2466
|
+
* This should be called in your tick loop every time, and returns true if re-rendering is needed.
|
|
2467
|
+
* @param delta
|
|
2468
|
+
* @returns updated
|
|
2469
|
+
* @category Methods
|
|
2470
|
+
*/
|
|
2471
|
+
update(delta) {
|
|
2472
|
+
const deltaTheta = this._sphericalEnd.theta - this._spherical.theta;
|
|
2473
|
+
const deltaPhi = this._sphericalEnd.phi - this._spherical.phi;
|
|
2474
|
+
const deltaRadius = this._sphericalEnd.radius - this._spherical.radius;
|
|
2475
|
+
const deltaTarget = _deltaTarget.subVectors(this._targetEnd, this._target);
|
|
2476
|
+
const deltaOffset = _deltaOffset.subVectors(
|
|
2477
|
+
this._focalOffsetEnd,
|
|
2478
|
+
this._focalOffset
|
|
2479
|
+
);
|
|
2480
|
+
const deltaZoom = this._zoomEnd - this._zoom;
|
|
2481
|
+
// update theta
|
|
2482
|
+
if (approxZero(deltaTheta)) {
|
|
2483
|
+
this._thetaVelocity.value = 0;
|
|
2484
|
+
this._spherical.theta = this._sphericalEnd.theta;
|
|
2485
|
+
} else {
|
|
2486
|
+
const smoothTime = this._isUserControllingRotate
|
|
2487
|
+
? this.draggingSmoothTime
|
|
2488
|
+
: this.smoothTime;
|
|
2489
|
+
this._spherical.theta = smoothDamp(
|
|
2490
|
+
this._spherical.theta,
|
|
2491
|
+
this._sphericalEnd.theta,
|
|
2492
|
+
this._thetaVelocity,
|
|
2493
|
+
smoothTime,
|
|
2494
|
+
Infinity,
|
|
2495
|
+
delta
|
|
2496
|
+
);
|
|
2497
|
+
this._needsUpdate = true;
|
|
2498
|
+
}
|
|
2499
|
+
// update phi
|
|
2500
|
+
if (approxZero(deltaPhi)) {
|
|
2501
|
+
this._phiVelocity.value = 0;
|
|
2502
|
+
this._spherical.phi = this._sphericalEnd.phi;
|
|
2503
|
+
} else {
|
|
2504
|
+
const smoothTime = this._isUserControllingRotate
|
|
2505
|
+
? this.draggingSmoothTime
|
|
2506
|
+
: this.smoothTime;
|
|
2507
|
+
this._spherical.phi = smoothDamp(
|
|
2508
|
+
this._spherical.phi,
|
|
2509
|
+
this._sphericalEnd.phi,
|
|
2510
|
+
this._phiVelocity,
|
|
2511
|
+
smoothTime,
|
|
2512
|
+
Infinity,
|
|
2513
|
+
delta
|
|
2514
|
+
);
|
|
2515
|
+
this._needsUpdate = true;
|
|
2516
|
+
}
|
|
2517
|
+
// update distance
|
|
2518
|
+
if (approxZero(deltaRadius)) {
|
|
2519
|
+
this._radiusVelocity.value = 0;
|
|
2520
|
+
this._spherical.radius = this._sphericalEnd.radius;
|
|
2521
|
+
} else {
|
|
2522
|
+
const smoothTime = this._isUserControllingDolly
|
|
2523
|
+
? this.draggingSmoothTime
|
|
2524
|
+
: this.smoothTime;
|
|
2525
|
+
this._spherical.radius = smoothDamp(
|
|
2526
|
+
this._spherical.radius,
|
|
2527
|
+
this._sphericalEnd.radius,
|
|
2528
|
+
this._radiusVelocity,
|
|
2529
|
+
smoothTime,
|
|
2530
|
+
this.maxSpeed,
|
|
2531
|
+
delta
|
|
2532
|
+
);
|
|
2533
|
+
this._needsUpdate = true;
|
|
2534
|
+
}
|
|
2535
|
+
// update target position
|
|
2536
|
+
if (
|
|
2537
|
+
approxZero(deltaTarget.x) &&
|
|
2538
|
+
approxZero(deltaTarget.y) &&
|
|
2539
|
+
approxZero(deltaTarget.z)
|
|
2540
|
+
) {
|
|
2541
|
+
this._targetVelocity.set(0, 0, 0);
|
|
2542
|
+
this._target.copy(this._targetEnd);
|
|
2543
|
+
} else {
|
|
2544
|
+
const smoothTime = this._isUserControllingTruck
|
|
2545
|
+
? this.draggingSmoothTime
|
|
2546
|
+
: this.smoothTime;
|
|
2547
|
+
smoothDampVec3(
|
|
2548
|
+
this._target,
|
|
2549
|
+
this._targetEnd,
|
|
2550
|
+
this._targetVelocity,
|
|
2551
|
+
smoothTime,
|
|
2552
|
+
this.maxSpeed,
|
|
2553
|
+
delta,
|
|
2554
|
+
this._target
|
|
2555
|
+
);
|
|
2556
|
+
this._needsUpdate = true;
|
|
2557
|
+
}
|
|
2558
|
+
// update focalOffset
|
|
2559
|
+
if (
|
|
2560
|
+
approxZero(deltaOffset.x) &&
|
|
2561
|
+
approxZero(deltaOffset.y) &&
|
|
2562
|
+
approxZero(deltaOffset.z)
|
|
2563
|
+
) {
|
|
2564
|
+
this._focalOffsetVelocity.set(0, 0, 0);
|
|
2565
|
+
this._focalOffset.copy(this._focalOffsetEnd);
|
|
2566
|
+
} else {
|
|
2567
|
+
const smoothTime = this._isUserControllingOffset
|
|
2568
|
+
? this.draggingSmoothTime
|
|
2569
|
+
: this.smoothTime;
|
|
2570
|
+
smoothDampVec3(
|
|
2571
|
+
this._focalOffset,
|
|
2572
|
+
this._focalOffsetEnd,
|
|
2573
|
+
this._focalOffsetVelocity,
|
|
2574
|
+
smoothTime,
|
|
2575
|
+
this.maxSpeed,
|
|
2576
|
+
delta,
|
|
2577
|
+
this._focalOffset
|
|
2578
|
+
);
|
|
2579
|
+
this._needsUpdate = true;
|
|
2580
|
+
}
|
|
2581
|
+
// update zoom
|
|
2582
|
+
if (approxZero(deltaZoom)) {
|
|
2583
|
+
this._zoomVelocity.value = 0;
|
|
2584
|
+
this._zoom = this._zoomEnd;
|
|
2585
|
+
} else {
|
|
2586
|
+
const smoothTime = this._isUserControllingZoom
|
|
2587
|
+
? this.draggingSmoothTime
|
|
2588
|
+
: this.smoothTime;
|
|
2589
|
+
this._zoom = smoothDamp(
|
|
2590
|
+
this._zoom,
|
|
2591
|
+
this._zoomEnd,
|
|
2592
|
+
this._zoomVelocity,
|
|
2593
|
+
smoothTime,
|
|
2594
|
+
Infinity,
|
|
2595
|
+
delta
|
|
2596
|
+
);
|
|
2597
|
+
}
|
|
2598
|
+
if (this.dollyToCursor) {
|
|
2599
|
+
if (isPerspectiveCamera(this._camera) && this._changedDolly !== 0) {
|
|
2600
|
+
const dollyControlAmount = this._spherical.radius - this._lastDistance;
|
|
2601
|
+
const camera = this._camera;
|
|
2602
|
+
const cameraDirection = this._getCameraDirection(_cameraDirection);
|
|
2603
|
+
const planeX = _v3A.copy(cameraDirection).cross(camera.up).normalize();
|
|
2604
|
+
if (planeX.lengthSq() === 0) planeX.x = 1.0;
|
|
2605
|
+
const planeY = _v3B.crossVectors(planeX, cameraDirection);
|
|
2606
|
+
const worldToScreen =
|
|
2607
|
+
this._sphericalEnd.radius *
|
|
2608
|
+
Math.tan(camera.getEffectiveFOV() * DEG2RAD * 0.5);
|
|
2609
|
+
const prevRadius = this._sphericalEnd.radius - dollyControlAmount;
|
|
2610
|
+
const lerpRatio =
|
|
2611
|
+
(prevRadius - this._sphericalEnd.radius) / this._sphericalEnd.radius;
|
|
2612
|
+
const cursor = _v3C
|
|
2613
|
+
.copy(this._targetEnd)
|
|
2614
|
+
.add(
|
|
2615
|
+
planeX.multiplyScalar(
|
|
2616
|
+
this._dollyControlCoord.x * worldToScreen * camera.aspect
|
|
2617
|
+
)
|
|
2618
|
+
)
|
|
2619
|
+
.add(
|
|
2620
|
+
planeY.multiplyScalar(this._dollyControlCoord.y * worldToScreen)
|
|
2621
|
+
);
|
|
2622
|
+
const newTargetEnd = _v3A.copy(this._targetEnd).lerp(cursor, lerpRatio);
|
|
2623
|
+
const isMin =
|
|
2624
|
+
this._lastDollyDirection === DOLLY_DIRECTION.IN &&
|
|
2625
|
+
this._spherical.radius <= this.minDistance;
|
|
2626
|
+
const isMax =
|
|
2627
|
+
this._lastDollyDirection === DOLLY_DIRECTION.OUT &&
|
|
2628
|
+
this.maxDistance <= this._spherical.radius;
|
|
2629
|
+
if (this.infinityDolly && (isMin || isMax)) {
|
|
2630
|
+
this._sphericalEnd.radius -= dollyControlAmount;
|
|
2631
|
+
this._spherical.radius -= dollyControlAmount;
|
|
2632
|
+
const dollyAmount = _v3B
|
|
2633
|
+
.copy(cameraDirection)
|
|
2634
|
+
.multiplyScalar(-dollyControlAmount);
|
|
2635
|
+
newTargetEnd.add(dollyAmount);
|
|
2636
|
+
}
|
|
2637
|
+
// target position may be moved beyond boundary.
|
|
2638
|
+
this._boundary.clampPoint(newTargetEnd, newTargetEnd);
|
|
2639
|
+
const targetEndDiff = _v3B.subVectors(newTargetEnd, this._targetEnd);
|
|
2640
|
+
this._targetEnd.copy(newTargetEnd);
|
|
2641
|
+
this._target.add(targetEndDiff);
|
|
2642
|
+
this._changedDolly -= dollyControlAmount;
|
|
2643
|
+
if (approxZero(this._changedDolly)) this._changedDolly = 0;
|
|
2644
|
+
} else if (
|
|
2645
|
+
isOrthographicCamera(this._camera) &&
|
|
2646
|
+
this._changedZoom !== 0
|
|
2647
|
+
) {
|
|
2648
|
+
const dollyControlAmount = this._zoom - this._lastZoom;
|
|
2649
|
+
const camera = this._camera;
|
|
2650
|
+
const worldCursorPosition = _v3A
|
|
2651
|
+
.set(
|
|
2652
|
+
this._dollyControlCoord.x,
|
|
2653
|
+
this._dollyControlCoord.y,
|
|
2654
|
+
(camera.near + camera.far) / (camera.near - camera.far)
|
|
2655
|
+
)
|
|
2656
|
+
.unproject(camera);
|
|
2657
|
+
const quaternion = _v3B
|
|
2658
|
+
.set(0, 0, -1)
|
|
2659
|
+
.applyQuaternion(camera.quaternion);
|
|
2660
|
+
const cursor = _v3C
|
|
2661
|
+
.copy(worldCursorPosition)
|
|
2662
|
+
.add(quaternion.multiplyScalar(-worldCursorPosition.dot(camera.up)));
|
|
2663
|
+
const prevZoom = this._zoom - dollyControlAmount;
|
|
2664
|
+
const lerpRatio = -(prevZoom - this._zoom) / this._zoom;
|
|
2665
|
+
// find the "distance" (aka plane constant in three.js) of Plane
|
|
2666
|
+
// from a given position (this._targetEnd) and normal vector (cameraDirection)
|
|
2667
|
+
// https://www.maplesoft.com/support/help/maple/view.aspx?path=MathApps%2FEquationOfAPlaneNormal#bkmrk0
|
|
2668
|
+
const cameraDirection = this._getCameraDirection(_cameraDirection);
|
|
2669
|
+
const prevPlaneConstant = this._targetEnd.dot(cameraDirection);
|
|
2670
|
+
const newTargetEnd = _v3A.copy(this._targetEnd).lerp(cursor, lerpRatio);
|
|
2671
|
+
const newPlaneConstant = newTargetEnd.dot(cameraDirection);
|
|
2672
|
+
// Pull back the camera depth that has moved, to be the camera stationary as zoom
|
|
2673
|
+
const pullBack = cameraDirection.multiplyScalar(
|
|
2674
|
+
newPlaneConstant - prevPlaneConstant
|
|
2675
|
+
);
|
|
2676
|
+
newTargetEnd.sub(pullBack);
|
|
2677
|
+
// target position may be moved beyond boundary.
|
|
2678
|
+
this._boundary.clampPoint(newTargetEnd, newTargetEnd);
|
|
2679
|
+
const targetEndDiff = _v3B.subVectors(newTargetEnd, this._targetEnd);
|
|
2680
|
+
this._targetEnd.copy(newTargetEnd);
|
|
2681
|
+
this._target.add(targetEndDiff);
|
|
2682
|
+
// this._target.copy( this._targetEnd );
|
|
2683
|
+
this._changedZoom -= dollyControlAmount;
|
|
2684
|
+
if (approxZero(this._changedZoom)) this._changedZoom = 0;
|
|
2685
|
+
}
|
|
2686
|
+
}
|
|
2687
|
+
if (this._camera.zoom !== this._zoom) {
|
|
2688
|
+
this._camera.zoom = this._zoom;
|
|
2689
|
+
this._camera.updateProjectionMatrix();
|
|
2690
|
+
this._updateNearPlaneCorners();
|
|
2691
|
+
this._needsUpdate = true;
|
|
2692
|
+
}
|
|
2693
|
+
this._dragNeedsUpdate = true;
|
|
2694
|
+
// collision detection
|
|
2695
|
+
const maxDistance = this._collisionTest();
|
|
2696
|
+
this._spherical.radius = Math.min(this._spherical.radius, maxDistance);
|
|
2697
|
+
// decompose spherical to the camera position
|
|
2698
|
+
this._spherical.makeSafe();
|
|
2699
|
+
this._camera.position
|
|
2700
|
+
.setFromSpherical(this._spherical)
|
|
2701
|
+
.applyQuaternion(this._yAxisUpSpaceInverse)
|
|
2702
|
+
.add(this._target);
|
|
2703
|
+
this._camera.lookAt(this._target);
|
|
2704
|
+
// set offset after the orbit movement
|
|
2705
|
+
const affectOffset =
|
|
2706
|
+
!approxZero(this._focalOffset.x) ||
|
|
2707
|
+
!approxZero(this._focalOffset.y) ||
|
|
2708
|
+
!approxZero(this._focalOffset.z);
|
|
2709
|
+
if (affectOffset) {
|
|
2710
|
+
this._camera.updateMatrixWorld();
|
|
2711
|
+
_xColumn.setFromMatrixColumn(this._camera.matrix, 0);
|
|
2712
|
+
_yColumn.setFromMatrixColumn(this._camera.matrix, 1);
|
|
2713
|
+
_zColumn.setFromMatrixColumn(this._camera.matrix, 2);
|
|
2714
|
+
_xColumn.multiplyScalar(this._focalOffset.x);
|
|
2715
|
+
_yColumn.multiplyScalar(-this._focalOffset.y);
|
|
2716
|
+
_zColumn.multiplyScalar(this._focalOffset.z); // notice: z-offset will not affect in Orthographic.
|
|
2717
|
+
_v3A.copy(_xColumn).add(_yColumn).add(_zColumn);
|
|
2718
|
+
this._camera.position.add(_v3A);
|
|
2719
|
+
}
|
|
2720
|
+
if (this._boundaryEnclosesCamera) {
|
|
2721
|
+
this._encloseToBoundary(
|
|
2722
|
+
this._camera.position.copy(this._target),
|
|
2723
|
+
_v3A
|
|
2724
|
+
.setFromSpherical(this._spherical)
|
|
2725
|
+
.applyQuaternion(this._yAxisUpSpaceInverse),
|
|
2726
|
+
1.0
|
|
2727
|
+
);
|
|
2728
|
+
}
|
|
2729
|
+
const updated = this._needsUpdate;
|
|
2730
|
+
if (updated && !this._updatedLastTime) {
|
|
2731
|
+
this._hasRested = false;
|
|
2732
|
+
this.dispatchEvent({ type: 'wake' });
|
|
2733
|
+
this.dispatchEvent({ type: 'update' });
|
|
2734
|
+
} else if (updated) {
|
|
2735
|
+
this.dispatchEvent({ type: 'update' });
|
|
2736
|
+
if (
|
|
2737
|
+
approxZero(deltaTheta, this.restThreshold) &&
|
|
2738
|
+
approxZero(deltaPhi, this.restThreshold) &&
|
|
2739
|
+
approxZero(deltaRadius, this.restThreshold) &&
|
|
2740
|
+
approxZero(deltaTarget.x, this.restThreshold) &&
|
|
2741
|
+
approxZero(deltaTarget.y, this.restThreshold) &&
|
|
2742
|
+
approxZero(deltaTarget.z, this.restThreshold) &&
|
|
2743
|
+
approxZero(deltaOffset.x, this.restThreshold) &&
|
|
2744
|
+
approxZero(deltaOffset.y, this.restThreshold) &&
|
|
2745
|
+
approxZero(deltaOffset.z, this.restThreshold) &&
|
|
2746
|
+
approxZero(deltaZoom, this.restThreshold) &&
|
|
2747
|
+
!this._hasRested
|
|
2748
|
+
) {
|
|
2749
|
+
this._hasRested = true;
|
|
2750
|
+
this.dispatchEvent({ type: 'rest' });
|
|
2751
|
+
}
|
|
2752
|
+
} else if (!updated && this._updatedLastTime) {
|
|
2753
|
+
this.dispatchEvent({ type: 'sleep' });
|
|
2754
|
+
}
|
|
2755
|
+
this._lastDistance = this._spherical.radius;
|
|
2756
|
+
this._lastZoom = this._zoom;
|
|
2757
|
+
this._updatedLastTime = updated;
|
|
2758
|
+
this._needsUpdate = false;
|
|
2759
|
+
return updated;
|
|
2760
|
+
}
|
|
2761
|
+
/**
|
|
2762
|
+
* Get all state in JSON string
|
|
2763
|
+
* @category Methods
|
|
2764
|
+
*/
|
|
2765
|
+
toJSON() {
|
|
2766
|
+
return JSON.stringify({
|
|
2767
|
+
enabled: this._enabled,
|
|
2768
|
+
minDistance: this.minDistance,
|
|
2769
|
+
maxDistance: infinityToMaxNumber(this.maxDistance),
|
|
2770
|
+
minZoom: this.minZoom,
|
|
2771
|
+
maxZoom: infinityToMaxNumber(this.maxZoom),
|
|
2772
|
+
minPolarAngle: this.minPolarAngle,
|
|
2773
|
+
maxPolarAngle: infinityToMaxNumber(this.maxPolarAngle),
|
|
2774
|
+
minAzimuthAngle: infinityToMaxNumber(this.minAzimuthAngle),
|
|
2775
|
+
maxAzimuthAngle: infinityToMaxNumber(this.maxAzimuthAngle),
|
|
2776
|
+
smoothTime: this.smoothTime,
|
|
2777
|
+
draggingSmoothTime: this.draggingSmoothTime,
|
|
2778
|
+
dollySpeed: this.dollySpeed,
|
|
2779
|
+
truckSpeed: this.truckSpeed,
|
|
2780
|
+
dollyToCursor: this.dollyToCursor,
|
|
2781
|
+
verticalDragToForward: this.verticalDragToForward,
|
|
2782
|
+
target: this._targetEnd.toArray(),
|
|
2783
|
+
position: _v3A
|
|
2784
|
+
.setFromSpherical(this._sphericalEnd)
|
|
2785
|
+
.add(this._targetEnd)
|
|
2786
|
+
.toArray(),
|
|
2787
|
+
zoom: this._zoomEnd,
|
|
2788
|
+
focalOffset: this._focalOffsetEnd.toArray(),
|
|
2789
|
+
target0: this._target0.toArray(),
|
|
2790
|
+
position0: this._position0.toArray(),
|
|
2791
|
+
zoom0: this._zoom0,
|
|
2792
|
+
focalOffset0: this._focalOffset0.toArray()
|
|
2793
|
+
});
|
|
2794
|
+
}
|
|
2795
|
+
/**
|
|
2796
|
+
* Reproduce the control state with JSON. enableTransition is where anim or not in a boolean.
|
|
2797
|
+
* @param json
|
|
2798
|
+
* @param enableTransition
|
|
2799
|
+
* @category Methods
|
|
2800
|
+
*/
|
|
2801
|
+
fromJSON(json, enableTransition = false) {
|
|
2802
|
+
const obj = JSON.parse(json);
|
|
2803
|
+
this.enabled = obj.enabled;
|
|
2804
|
+
this.minDistance = obj.minDistance;
|
|
2805
|
+
this.maxDistance = maxNumberToInfinity(obj.maxDistance);
|
|
2806
|
+
this.minZoom = obj.minZoom;
|
|
2807
|
+
this.maxZoom = maxNumberToInfinity(obj.maxZoom);
|
|
2808
|
+
this.minPolarAngle = obj.minPolarAngle;
|
|
2809
|
+
this.maxPolarAngle = maxNumberToInfinity(obj.maxPolarAngle);
|
|
2810
|
+
this.minAzimuthAngle = maxNumberToInfinity(obj.minAzimuthAngle);
|
|
2811
|
+
this.maxAzimuthAngle = maxNumberToInfinity(obj.maxAzimuthAngle);
|
|
2812
|
+
this.smoothTime = obj.smoothTime;
|
|
2813
|
+
this.draggingSmoothTime = obj.draggingSmoothTime;
|
|
2814
|
+
this.dollySpeed = obj.dollySpeed;
|
|
2815
|
+
this.truckSpeed = obj.truckSpeed;
|
|
2816
|
+
this.dollyToCursor = obj.dollyToCursor;
|
|
2817
|
+
this.verticalDragToForward = obj.verticalDragToForward;
|
|
2818
|
+
this._target0.fromArray(obj.target0);
|
|
2819
|
+
this._position0.fromArray(obj.position0);
|
|
2820
|
+
this._zoom0 = obj.zoom0;
|
|
2821
|
+
this._focalOffset0.fromArray(obj.focalOffset0);
|
|
2822
|
+
this.moveTo(obj.target[0], obj.target[1], obj.target[2], enableTransition);
|
|
2823
|
+
_sphericalA.setFromVector3(
|
|
2824
|
+
_v3A
|
|
2825
|
+
.fromArray(obj.position)
|
|
2826
|
+
.sub(this._targetEnd)
|
|
2827
|
+
.applyQuaternion(this._yAxisUpSpace)
|
|
2828
|
+
);
|
|
2829
|
+
this.rotateTo(_sphericalA.theta, _sphericalA.phi, enableTransition);
|
|
2830
|
+
this.dollyTo(_sphericalA.radius, enableTransition);
|
|
2831
|
+
this.zoomTo(obj.zoom, enableTransition);
|
|
2832
|
+
this.setFocalOffset(
|
|
2833
|
+
obj.focalOffset[0],
|
|
2834
|
+
obj.focalOffset[1],
|
|
2835
|
+
obj.focalOffset[2],
|
|
2836
|
+
enableTransition
|
|
2837
|
+
);
|
|
2838
|
+
this._needsUpdate = true;
|
|
2839
|
+
}
|
|
2840
|
+
/**
|
|
2841
|
+
* Attach all internal event handlers to enable drag control.
|
|
2842
|
+
* @category Methods
|
|
2843
|
+
*/
|
|
2844
|
+
connect(domElement) {
|
|
2845
|
+
if (this._domElement) {
|
|
2846
|
+
console.warn('camera-controls is already connected.');
|
|
2847
|
+
return;
|
|
2848
|
+
}
|
|
2849
|
+
domElement.setAttribute('data-camera-controls-version', VERSION);
|
|
2850
|
+
this._addAllEventListeners(domElement);
|
|
2851
|
+
this._getClientRect(this._elementRect);
|
|
2852
|
+
}
|
|
2853
|
+
/**
|
|
2854
|
+
* Detach all internal event handlers to disable drag control.
|
|
2855
|
+
*/
|
|
2856
|
+
disconnect() {
|
|
2857
|
+
this.cancel();
|
|
2858
|
+
this._removeAllEventListeners();
|
|
2859
|
+
if (this._domElement) {
|
|
2860
|
+
this._domElement.removeAttribute('data-camera-controls-version');
|
|
2861
|
+
this._domElement = undefined;
|
|
2862
|
+
}
|
|
2863
|
+
}
|
|
2864
|
+
/**
|
|
2865
|
+
* Dispose the cameraControls instance itself, remove all eventListeners.
|
|
2866
|
+
* @category Methods
|
|
2867
|
+
*/
|
|
2868
|
+
dispose() {
|
|
2869
|
+
// remove all user event listeners
|
|
2870
|
+
this.removeAllEventListeners();
|
|
2871
|
+
// remove all internal event listeners
|
|
2872
|
+
this.disconnect();
|
|
2873
|
+
}
|
|
2874
|
+
// it's okay to expose public though
|
|
2875
|
+
_getTargetDirection(out) {
|
|
2876
|
+
// divide by distance to normalize, lighter than `Vector3.prototype.normalize()`
|
|
2877
|
+
return out
|
|
2878
|
+
.setFromSpherical(this._spherical)
|
|
2879
|
+
.divideScalar(this._spherical.radius)
|
|
2880
|
+
.applyQuaternion(this._yAxisUpSpaceInverse);
|
|
2881
|
+
}
|
|
2882
|
+
// it's okay to expose public though
|
|
2883
|
+
_getCameraDirection(out) {
|
|
2884
|
+
return this._getTargetDirection(out).negate();
|
|
2885
|
+
}
|
|
2886
|
+
_findPointerById(pointerId) {
|
|
2887
|
+
return this._activePointers.find(
|
|
2888
|
+
activePointer => activePointer.pointerId === pointerId
|
|
2889
|
+
);
|
|
2890
|
+
}
|
|
2891
|
+
_findPointerByMouseButton(mouseButton) {
|
|
2892
|
+
return this._activePointers.find(
|
|
2893
|
+
activePointer => activePointer.mouseButton === mouseButton
|
|
2894
|
+
);
|
|
2895
|
+
}
|
|
2896
|
+
_disposePointer(pointer) {
|
|
2897
|
+
this._activePointers.splice(this._activePointers.indexOf(pointer), 1);
|
|
2898
|
+
}
|
|
2899
|
+
_encloseToBoundary(position, offset, friction) {
|
|
2900
|
+
const offsetLength2 = offset.lengthSq();
|
|
2901
|
+
if (offsetLength2 === 0.0) {
|
|
2902
|
+
// sanity check
|
|
2903
|
+
return position;
|
|
2904
|
+
}
|
|
2905
|
+
// See: https://twitter.com/FMS_Cat/status/1106508958640988161
|
|
2906
|
+
const newTarget = _v3B.copy(offset).add(position); // target
|
|
2907
|
+
const clampedTarget = this._boundary.clampPoint(newTarget, _v3C); // clamped target
|
|
2908
|
+
const deltaClampedTarget = clampedTarget.sub(newTarget); // newTarget -> clampedTarget
|
|
2909
|
+
const deltaClampedTargetLength2 = deltaClampedTarget.lengthSq(); // squared length of deltaClampedTarget
|
|
2910
|
+
if (deltaClampedTargetLength2 === 0.0) {
|
|
2911
|
+
// when the position doesn't have to be clamped
|
|
2912
|
+
return position.add(offset);
|
|
2913
|
+
} else if (deltaClampedTargetLength2 === offsetLength2) {
|
|
2914
|
+
// when the position is completely stuck
|
|
2915
|
+
return position;
|
|
2916
|
+
} else if (friction === 0.0) {
|
|
2917
|
+
return position.add(offset).add(deltaClampedTarget);
|
|
2918
|
+
} else {
|
|
2919
|
+
const offsetFactor =
|
|
2920
|
+
1.0 +
|
|
2921
|
+
(friction * deltaClampedTargetLength2) / offset.dot(deltaClampedTarget);
|
|
2922
|
+
return position
|
|
2923
|
+
.add(_v3B.copy(offset).multiplyScalar(offsetFactor))
|
|
2924
|
+
.add(deltaClampedTarget.multiplyScalar(1.0 - friction));
|
|
2925
|
+
}
|
|
2926
|
+
}
|
|
2927
|
+
_updateNearPlaneCorners() {
|
|
2928
|
+
if (isPerspectiveCamera(this._camera)) {
|
|
2929
|
+
const camera = this._camera;
|
|
2930
|
+
const near = camera.near;
|
|
2931
|
+
const fov = camera.getEffectiveFOV() * DEG2RAD;
|
|
2932
|
+
const heightHalf = Math.tan(fov * 0.5) * near; // near plain half height
|
|
2933
|
+
const widthHalf = heightHalf * camera.aspect; // near plain half width
|
|
2934
|
+
this._nearPlaneCorners[0].set(-widthHalf, -heightHalf, 0);
|
|
2935
|
+
this._nearPlaneCorners[1].set(widthHalf, -heightHalf, 0);
|
|
2936
|
+
this._nearPlaneCorners[2].set(widthHalf, heightHalf, 0);
|
|
2937
|
+
this._nearPlaneCorners[3].set(-widthHalf, heightHalf, 0);
|
|
2938
|
+
} else if (isOrthographicCamera(this._camera)) {
|
|
2939
|
+
const camera = this._camera;
|
|
2940
|
+
const zoomInv = 1 / camera.zoom;
|
|
2941
|
+
const left = camera.left * zoomInv;
|
|
2942
|
+
const right = camera.right * zoomInv;
|
|
2943
|
+
const top = camera.top * zoomInv;
|
|
2944
|
+
const bottom = camera.bottom * zoomInv;
|
|
2945
|
+
this._nearPlaneCorners[0].set(left, top, 0);
|
|
2946
|
+
this._nearPlaneCorners[1].set(right, top, 0);
|
|
2947
|
+
this._nearPlaneCorners[2].set(right, bottom, 0);
|
|
2948
|
+
this._nearPlaneCorners[3].set(left, bottom, 0);
|
|
2949
|
+
}
|
|
2950
|
+
}
|
|
2951
|
+
// lateUpdate
|
|
2952
|
+
_collisionTest() {
|
|
2953
|
+
let distance = Infinity;
|
|
2954
|
+
const hasCollider = this.colliderMeshes.length >= 1;
|
|
2955
|
+
if (!hasCollider) return distance;
|
|
2956
|
+
if (notSupportedInOrthographicCamera(this._camera, '_collisionTest'))
|
|
2957
|
+
return distance;
|
|
2958
|
+
const rayDirection = this._getTargetDirection(_cameraDirection);
|
|
2959
|
+
_rotationMatrix.lookAt(_ORIGIN, rayDirection, this._camera.up);
|
|
2960
|
+
for (let i = 0; i < 4; i++) {
|
|
2961
|
+
const nearPlaneCorner = _v3B.copy(this._nearPlaneCorners[i]);
|
|
2962
|
+
nearPlaneCorner.applyMatrix4(_rotationMatrix);
|
|
2963
|
+
const origin = _v3C.addVectors(this._target, nearPlaneCorner);
|
|
2964
|
+
_raycaster.set(origin, rayDirection);
|
|
2965
|
+
_raycaster.far = this._spherical.radius + 1;
|
|
2966
|
+
const intersects = _raycaster.intersectObjects(this.colliderMeshes);
|
|
2967
|
+
if (intersects.length !== 0 && intersects[0].distance < distance) {
|
|
2968
|
+
distance = intersects[0].distance;
|
|
2969
|
+
}
|
|
2970
|
+
}
|
|
2971
|
+
return distance;
|
|
2972
|
+
}
|
|
2973
|
+
/**
|
|
2974
|
+
* Get its client rect and package into given `DOMRect` .
|
|
2975
|
+
*/
|
|
2976
|
+
_getClientRect(target) {
|
|
2977
|
+
if (!this._domElement) return;
|
|
2978
|
+
const rect = this._domElement.getBoundingClientRect();
|
|
2979
|
+
target.x = rect.left;
|
|
2980
|
+
target.y = rect.top;
|
|
2981
|
+
if (this._viewport) {
|
|
2982
|
+
target.x += this._viewport.x;
|
|
2983
|
+
target.y += rect.height - this._viewport.w - this._viewport.y;
|
|
2984
|
+
target.width = this._viewport.z;
|
|
2985
|
+
target.height = this._viewport.w;
|
|
2986
|
+
} else {
|
|
2987
|
+
target.width = rect.width;
|
|
2988
|
+
target.height = rect.height;
|
|
2989
|
+
}
|
|
2990
|
+
return target;
|
|
2991
|
+
}
|
|
2992
|
+
_createOnRestPromise(resolveImmediately) {
|
|
2993
|
+
if (resolveImmediately) return Promise.resolve();
|
|
2994
|
+
this._hasRested = false;
|
|
2995
|
+
this.dispatchEvent({ type: 'transitionstart' });
|
|
2996
|
+
return new Promise(resolve => {
|
|
2997
|
+
const onResolve = () => {
|
|
2998
|
+
this.removeEventListener('rest', onResolve);
|
|
2999
|
+
resolve();
|
|
3000
|
+
};
|
|
3001
|
+
this.addEventListener('rest', onResolve);
|
|
3002
|
+
});
|
|
3003
|
+
}
|
|
3004
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
3005
|
+
_addAllEventListeners(_domElement) {}
|
|
3006
|
+
_removeAllEventListeners() {}
|
|
3007
|
+
/**
|
|
3008
|
+
* backward compatible
|
|
3009
|
+
* @deprecated use smoothTime (in seconds) instead
|
|
3010
|
+
* @category Properties
|
|
3011
|
+
*/
|
|
3012
|
+
get dampingFactor() {
|
|
3013
|
+
console.warn(
|
|
3014
|
+
'.dampingFactor has been deprecated. use smoothTime (in seconds) instead.'
|
|
3015
|
+
);
|
|
3016
|
+
return 0;
|
|
3017
|
+
}
|
|
3018
|
+
/**
|
|
3019
|
+
* backward compatible
|
|
3020
|
+
* @deprecated use smoothTime (in seconds) instead
|
|
3021
|
+
* @category Properties
|
|
3022
|
+
*/
|
|
3023
|
+
set dampingFactor(_) {
|
|
3024
|
+
console.warn(
|
|
3025
|
+
'.dampingFactor has been deprecated. use smoothTime (in seconds) instead.'
|
|
3026
|
+
);
|
|
3027
|
+
}
|
|
3028
|
+
/**
|
|
3029
|
+
* backward compatible
|
|
3030
|
+
* @deprecated use draggingSmoothTime (in seconds) instead
|
|
3031
|
+
* @category Properties
|
|
3032
|
+
*/
|
|
3033
|
+
get draggingDampingFactor() {
|
|
3034
|
+
console.warn(
|
|
3035
|
+
'.draggingDampingFactor has been deprecated. use draggingSmoothTime (in seconds) instead.'
|
|
3036
|
+
);
|
|
3037
|
+
return 0;
|
|
3038
|
+
}
|
|
3039
|
+
/**
|
|
3040
|
+
* backward compatible
|
|
3041
|
+
* @deprecated use draggingSmoothTime (in seconds) instead
|
|
3042
|
+
* @category Properties
|
|
3043
|
+
*/
|
|
3044
|
+
set draggingDampingFactor(_) {
|
|
3045
|
+
console.warn(
|
|
3046
|
+
'.draggingDampingFactor has been deprecated. use draggingSmoothTime (in seconds) instead.'
|
|
3047
|
+
);
|
|
3048
|
+
}
|
|
3049
|
+
static createBoundingSphere(object3d, out = new THREE.Sphere()) {
|
|
3050
|
+
const boundingSphere = out;
|
|
3051
|
+
const center = boundingSphere.center;
|
|
3052
|
+
_box3A.makeEmpty();
|
|
3053
|
+
// find the center
|
|
3054
|
+
object3d.traverseVisible(object => {
|
|
3055
|
+
if (!object.isMesh) return;
|
|
3056
|
+
_box3A.expandByObject(object);
|
|
3057
|
+
});
|
|
3058
|
+
_box3A.getCenter(center);
|
|
3059
|
+
// find the radius
|
|
3060
|
+
let maxRadiusSq = 0;
|
|
3061
|
+
object3d.traverseVisible(object => {
|
|
3062
|
+
if (!object.isMesh) return;
|
|
3063
|
+
const mesh = object;
|
|
3064
|
+
const geometry = mesh.geometry.clone();
|
|
3065
|
+
geometry.applyMatrix4(mesh.matrixWorld);
|
|
3066
|
+
const bufferGeometry = geometry;
|
|
3067
|
+
const position = bufferGeometry.attributes.position;
|
|
3068
|
+
for (let i = 0, l = position.count; i < l; i++) {
|
|
3069
|
+
_v3A.fromBufferAttribute(position, i);
|
|
3070
|
+
maxRadiusSq = Math.max(maxRadiusSq, center.distanceToSquared(_v3A));
|
|
3071
|
+
}
|
|
3072
|
+
});
|
|
3073
|
+
boundingSphere.radius = Math.sqrt(maxRadiusSq);
|
|
3074
|
+
return boundingSphere;
|
|
3075
|
+
}
|
|
3076
|
+
}
|
|
3077
|
+
|
|
3078
|
+
export { EventDispatcher, CameraControls as default };
|