@aibee/owlly 1.0.25
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/README.external.md +75 -0
- package/README.md +28 -0
- package/lib/src/external/lines/line-geometry.d.ts +9 -0
- package/lib/src/external/lines/line-geometry.js +52 -0
- package/lib/src/external/lines/line-geometry.js.map +1 -0
- package/lib/src/external/lines/line-material.d.ts +10 -0
- package/lib/src/external/lines/line-material.js +377 -0
- package/lib/src/external/lines/line-material.js.map +1 -0
- package/lib/src/external/lines/line-segments-2.d.ts +7 -0
- package/lib/src/external/lines/line-segments-2.js +144 -0
- package/lib/src/external/lines/line-segments-2.js.map +1 -0
- package/lib/src/external/lines/line-segments-geometry.d.ts +15 -0
- package/lib/src/external/lines/line-segments-geometry.js +141 -0
- package/lib/src/external/lines/line-segments-geometry.js.map +1 -0
- package/lib/src/external/loaders/gltf-loader.d.ts +77 -0
- package/lib/src/external/loaders/gltf-loader.js +2319 -0
- package/lib/src/external/loaders/gltf-loader.js.map +1 -0
- package/lib/src/external/orbit-controls.d.ts +44 -0
- package/lib/src/external/orbit-controls.js +746 -0
- package/lib/src/external/orbit-controls.js.map +1 -0
- package/lib/src/external/renderers/css-2d-renderer.d.ts +16 -0
- package/lib/src/external/renderers/css-2d-renderer.js +122 -0
- package/lib/src/external/renderers/css-2d-renderer.js.map +1 -0
- package/lib/src/external/renderers/css-3d-renderer.d.ts +18 -0
- package/lib/src/external/renderers/css-3d-renderer.js +139 -0
- package/lib/src/external/renderers/css-3d-renderer.js.map +1 -0
- package/lib/src/external/transform-controls.d.ts +106 -0
- package/lib/src/external/transform-controls.js +1113 -0
- package/lib/src/external/transform-controls.js.map +1 -0
- package/lib/src/external/util/buffer-geometry-utils.d.ts +45 -0
- package/lib/src/external/util/buffer-geometry-utils.js +569 -0
- package/lib/src/external/util/buffer-geometry-utils.js.map +1 -0
- package/lib/src/owlly/controller/aerial-element-controller.d.ts +65 -0
- package/lib/src/owlly/controller/aerial-element-controller.js +236 -0
- package/lib/src/owlly/controller/aerial-element-controller.js.map +1 -0
- package/lib/src/owlly/controller/basic-controller.d.ts +324 -0
- package/lib/src/owlly/controller/basic-controller.js +1239 -0
- package/lib/src/owlly/controller/basic-controller.js.map +1 -0
- package/lib/src/owlly/controller/camera-controller.d.ts +37 -0
- package/lib/src/owlly/controller/camera-controller.js +138 -0
- package/lib/src/owlly/controller/camera-controller.js.map +1 -0
- package/lib/src/owlly/controller/controller.d.ts +61 -0
- package/lib/src/owlly/controller/controller.js +24 -0
- package/lib/src/owlly/controller/controller.js.map +1 -0
- package/lib/src/owlly/controller/index.d.ts +2 -0
- package/lib/src/owlly/controller/index.js +14 -0
- package/lib/src/owlly/controller/index.js.map +1 -0
- package/lib/src/owlly/controller/mouse-indicator-controller.d.ts +34 -0
- package/lib/src/owlly/controller/mouse-indicator-controller.js +119 -0
- package/lib/src/owlly/controller/mouse-indicator-controller.js.map +1 -0
- package/lib/src/owlly/controller/orbit-control.d.ts +147 -0
- package/lib/src/owlly/controller/orbit-control.js +265 -0
- package/lib/src/owlly/controller/orbit-control.js.map +1 -0
- package/lib/src/owlly/controller/panorama-adjust-controller.d.ts +45 -0
- package/lib/src/owlly/controller/panorama-adjust-controller.js +158 -0
- package/lib/src/owlly/controller/panorama-adjust-controller.js.map +1 -0
- package/lib/src/owlly/controller/panorama-controller.d.ts +441 -0
- package/lib/src/owlly/controller/panorama-controller.js +1944 -0
- package/lib/src/owlly/controller/panorama-controller.js.map +1 -0
- package/lib/src/owlly/controller/panorama-transform-controller.d.ts +66 -0
- package/lib/src/owlly/controller/panorama-transform-controller.js +137 -0
- package/lib/src/owlly/controller/panorama-transform-controller.js.map +1 -0
- package/lib/src/owlly/controller/plane-controller.d.ts +43 -0
- package/lib/src/owlly/controller/plane-controller.js +174 -0
- package/lib/src/owlly/controller/plane-controller.js.map +1 -0
- package/lib/src/owlly/controller/texture-controller.d.ts +181 -0
- package/lib/src/owlly/controller/texture-controller.js +876 -0
- package/lib/src/owlly/controller/texture-controller.js.map +1 -0
- package/lib/src/owlly/controller/tile-panorama-controller.d.ts +308 -0
- package/lib/src/owlly/controller/tile-panorama-controller.js +1354 -0
- package/lib/src/owlly/controller/tile-panorama-controller.js.map +1 -0
- package/lib/src/owlly/controller/transform-controller.d.ts +106 -0
- package/lib/src/owlly/controller/transform-controller.js +546 -0
- package/lib/src/owlly/controller/transform-controller.js.map +1 -0
- package/lib/src/owlly/element/bottom-nav-element.d.ts +65 -0
- package/lib/src/owlly/element/bottom-nav-element.js +258 -0
- package/lib/src/owlly/element/bottom-nav-element.js.map +1 -0
- package/lib/src/owlly/element/camera.d.ts +82 -0
- package/lib/src/owlly/element/camera.js +284 -0
- package/lib/src/owlly/element/camera.js.map +1 -0
- package/lib/src/owlly/element/dom-2d-element.d.ts +35 -0
- package/lib/src/owlly/element/dom-2d-element.js +49 -0
- package/lib/src/owlly/element/dom-2d-element.js.map +1 -0
- package/lib/src/owlly/element/dom-3d-element.d.ts +27 -0
- package/lib/src/owlly/element/dom-3d-element.js +34 -0
- package/lib/src/owlly/element/dom-3d-element.js.map +1 -0
- package/lib/src/owlly/element/dom-label-2d.d.ts +116 -0
- package/lib/src/owlly/element/dom-label-2d.js +383 -0
- package/lib/src/owlly/element/dom-label-2d.js.map +1 -0
- package/lib/src/owlly/element/element.d.ts +53 -0
- package/lib/src/owlly/element/element.js +76 -0
- package/lib/src/owlly/element/element.js.map +1 -0
- package/lib/src/owlly/element/floor-model.d.ts +83 -0
- package/lib/src/owlly/element/floor-model.js +228 -0
- package/lib/src/owlly/element/floor-model.js.map +1 -0
- package/lib/src/owlly/element/gif-kit/Gif.d.ts +96 -0
- package/lib/src/owlly/element/gif-kit/Gif.js +433 -0
- package/lib/src/owlly/element/gif-kit/Gif.js.map +1 -0
- package/lib/src/owlly/element/gif-kit/GifColor.d.ts +21 -0
- package/lib/src/owlly/element/gif-kit/GifColor.js +38 -0
- package/lib/src/owlly/element/gif-kit/GifColor.js.map +1 -0
- package/lib/src/owlly/element/gif-kit/GifCompressedCodesToByteArrayConverter.d.ts +20 -0
- package/lib/src/owlly/element/gif-kit/GifCompressedCodesToByteArrayConverter.js +51 -0
- package/lib/src/owlly/element/gif-kit/GifCompressedCodesToByteArrayConverter.js.map +1 -0
- package/lib/src/owlly/element/gif-kit/GifFrame.d.ts +31 -0
- package/lib/src/owlly/element/gif-kit/GifFrame.js +97 -0
- package/lib/src/owlly/element/gif-kit/GifFrame.js.map +1 -0
- package/lib/src/owlly/element/gif-kit/GifImage.d.ts +23 -0
- package/lib/src/owlly/element/gif-kit/GifImage.js +8 -0
- package/lib/src/owlly/element/gif-kit/GifImage.js.map +1 -0
- package/lib/src/owlly/element/gif-kit/GifParser.d.ts +17 -0
- package/lib/src/owlly/element/gif-kit/GifParser.js +197 -0
- package/lib/src/owlly/element/gif-kit/GifParser.js.map +1 -0
- package/lib/src/owlly/element/gif-kit/GifPresenter.d.ts +20 -0
- package/lib/src/owlly/element/gif-kit/GifPresenter.js +44 -0
- package/lib/src/owlly/element/gif-kit/GifPresenter.js.map +1 -0
- package/lib/src/owlly/element/gif-kit/GifVersion.d.ts +10 -0
- package/lib/src/owlly/element/gif-kit/GifVersion.js +13 -0
- package/lib/src/owlly/element/gif-kit/GifVersion.js.map +1 -0
- package/lib/src/owlly/element/gltf-mesh-element.d.ts +31 -0
- package/lib/src/owlly/element/gltf-mesh-element.js +137 -0
- package/lib/src/owlly/element/gltf-mesh-element.js.map +1 -0
- package/lib/src/owlly/element/index.d.ts +20 -0
- package/lib/src/owlly/element/index.js +25 -0
- package/lib/src/owlly/element/index.js.map +1 -0
- package/lib/src/owlly/element/map-kit/area.d.ts +24 -0
- package/lib/src/owlly/element/map-kit/area.js +218 -0
- package/lib/src/owlly/element/map-kit/area.js.map +1 -0
- package/lib/src/owlly/element/map-kit/block-set.d.ts +39 -0
- package/lib/src/owlly/element/map-kit/block-set.js +91 -0
- package/lib/src/owlly/element/map-kit/block-set.js.map +1 -0
- package/lib/src/owlly/element/map-kit/block.d.ts +77 -0
- package/lib/src/owlly/element/map-kit/block.js +339 -0
- package/lib/src/owlly/element/map-kit/block.js.map +1 -0
- package/lib/src/owlly/element/map-kit/index.d.ts +4 -0
- package/lib/src/owlly/element/map-kit/index.js +7 -0
- package/lib/src/owlly/element/map-kit/index.js.map +1 -0
- package/lib/src/owlly/element/map-kit/shape.d.ts +131 -0
- package/lib/src/owlly/element/map-kit/shape.js +190 -0
- package/lib/src/owlly/element/map-kit/shape.js.map +1 -0
- package/lib/src/owlly/element/mesh-element.d.ts +22 -0
- package/lib/src/owlly/element/mesh-element.js +64 -0
- package/lib/src/owlly/element/mesh-element.js.map +1 -0
- package/lib/src/owlly/element/mesh-line-2d.d.ts +82 -0
- package/lib/src/owlly/element/mesh-line-2d.js +888 -0
- package/lib/src/owlly/element/mesh-line-2d.js.map +1 -0
- package/lib/src/owlly/element/meshline-o.d.ts +64 -0
- package/lib/src/owlly/element/meshline-o.js +679 -0
- package/lib/src/owlly/element/meshline-o.js.map +1 -0
- package/lib/src/owlly/element/panorama-group.d.ts +241 -0
- package/lib/src/owlly/element/panorama-group.js +967 -0
- package/lib/src/owlly/element/panorama-group.js.map +1 -0
- package/lib/src/owlly/element/panorama.d.ts +132 -0
- package/lib/src/owlly/element/panorama.js +813 -0
- package/lib/src/owlly/element/panorama.js.map +1 -0
- package/lib/src/owlly/element/path-group.d.ts +69 -0
- package/lib/src/owlly/element/path-group.js +172 -0
- package/lib/src/owlly/element/path-group.js.map +1 -0
- package/lib/src/owlly/element/path.d.ts +99 -0
- package/lib/src/owlly/element/path.js +532 -0
- package/lib/src/owlly/element/path.js.map +1 -0
- package/lib/src/owlly/element/placeable-2d.d.ts +158 -0
- package/lib/src/owlly/element/placeable-2d.js +471 -0
- package/lib/src/owlly/element/placeable-2d.js.map +1 -0
- package/lib/src/owlly/element/polygon-mesh.d.ts +107 -0
- package/lib/src/owlly/element/polygon-mesh.js +308 -0
- package/lib/src/owlly/element/polygon-mesh.js.map +1 -0
- package/lib/src/owlly/element/ring-element.d.ts +79 -0
- package/lib/src/owlly/element/ring-element.js +384 -0
- package/lib/src/owlly/element/ring-element.js.map +1 -0
- package/lib/src/owlly/element/sphere-mesh.d.ts +28 -0
- package/lib/src/owlly/element/sphere-mesh.js +70 -0
- package/lib/src/owlly/element/sphere-mesh.js.map +1 -0
- package/lib/src/owlly/element/svg-floor-model.d.ts +22 -0
- package/lib/src/owlly/element/svg-floor-model.js +185 -0
- package/lib/src/owlly/element/svg-floor-model.js.map +1 -0
- package/lib/src/owlly/element/svg-floors.d.ts +27 -0
- package/lib/src/owlly/element/svg-floors.js +110 -0
- package/lib/src/owlly/element/svg-floors.js.map +1 -0
- package/lib/src/owlly/element/tile-panorama-group.d.ts +335 -0
- package/lib/src/owlly/element/tile-panorama-group.js +1007 -0
- package/lib/src/owlly/element/tile-panorama-group.js.map +1 -0
- package/lib/src/owlly/element/tile-panorama.d.ts +161 -0
- package/lib/src/owlly/element/tile-panorama.js +511 -0
- package/lib/src/owlly/element/tile-panorama.js.map +1 -0
- package/lib/src/owlly/element/tile-plane.d.ts +105 -0
- package/lib/src/owlly/element/tile-plane.js +361 -0
- package/lib/src/owlly/element/tile-plane.js.map +1 -0
- package/lib/src/owlly/element/video-element.d.ts +33 -0
- package/lib/src/owlly/element/video-element.js +160 -0
- package/lib/src/owlly/element/video-element.js.map +1 -0
- package/lib/src/owlly/geometries/ExtrudeGeometry2.d.ts +15 -0
- package/lib/src/owlly/geometries/ExtrudeGeometry2.js +211 -0
- package/lib/src/owlly/geometries/ExtrudeGeometry2.js.map +1 -0
- package/lib/src/owlly/index.d.ts +13 -0
- package/lib/src/owlly/index.js +17 -0
- package/lib/src/owlly/index.js.map +1 -0
- package/lib/src/owlly/overlay/canvas-overlay.d.ts +96 -0
- package/lib/src/owlly/overlay/canvas-overlay.js +511 -0
- package/lib/src/owlly/overlay/canvas-overlay.js.map +1 -0
- package/lib/src/owlly/overlay/css-2d-overlay.d.ts +14 -0
- package/lib/src/owlly/overlay/css-2d-overlay.js +36 -0
- package/lib/src/owlly/overlay/css-2d-overlay.js.map +1 -0
- package/lib/src/owlly/overlay/css-3d-overlay.d.ts +16 -0
- package/lib/src/owlly/overlay/css-3d-overlay.js +37 -0
- package/lib/src/owlly/overlay/css-3d-overlay.js.map +1 -0
- package/lib/src/owlly/overlay/index.d.ts +6 -0
- package/lib/src/owlly/overlay/index.js +12 -0
- package/lib/src/owlly/overlay/index.js.map +1 -0
- package/lib/src/owlly/overlay/label-overlay.d.ts +62 -0
- package/lib/src/owlly/overlay/label-overlay.js +329 -0
- package/lib/src/owlly/overlay/label-overlay.js.map +1 -0
- package/lib/src/owlly/overlay/overlay.d.ts +14 -0
- package/lib/src/owlly/overlay/overlay.js +5 -0
- package/lib/src/owlly/overlay/overlay.js.map +1 -0
- package/lib/src/owlly/overlay/path-overlay.d.ts +39 -0
- package/lib/src/owlly/overlay/path-overlay.js +125 -0
- package/lib/src/owlly/overlay/path-overlay.js.map +1 -0
- package/lib/src/owlly/overlay/path-overlay2.d.ts +35 -0
- package/lib/src/owlly/overlay/path-overlay2.js +119 -0
- package/lib/src/owlly/overlay/path-overlay2.js.map +1 -0
- package/lib/src/owlly/overlay/poi-overlay-3d.d.ts +278 -0
- package/lib/src/owlly/overlay/poi-overlay-3d.js +1433 -0
- package/lib/src/owlly/overlay/poi-overlay-3d.js.map +1 -0
- package/lib/src/owlly/overlay/poi-overlay.d.ts +277 -0
- package/lib/src/owlly/overlay/poi-overlay.js +1412 -0
- package/lib/src/owlly/overlay/poi-overlay.js.map +1 -0
- package/lib/src/owlly/owlly-2d/index.d.ts +28 -0
- package/lib/src/owlly/owlly-2d/index.js +93 -0
- package/lib/src/owlly/owlly-2d/index.js.map +1 -0
- package/lib/src/owlly/screen/index.d.ts +1 -0
- package/lib/src/owlly/screen/index.js +2 -0
- package/lib/src/owlly/screen/index.js.map +1 -0
- package/lib/src/owlly/screen/screen.d.ts +73 -0
- package/lib/src/owlly/screen/screen.js +237 -0
- package/lib/src/owlly/screen/screen.js.map +1 -0
- package/lib/src/owlly/stage/__test__/stage.spec.d.ts +1 -0
- package/lib/src/owlly/stage/__test__/stage.spec.js +15 -0
- package/lib/src/owlly/stage/__test__/stage.spec.js.map +1 -0
- package/lib/src/owlly/stage/externals.d.ts +19 -0
- package/lib/src/owlly/stage/externals.js +25 -0
- package/lib/src/owlly/stage/externals.js.map +1 -0
- package/lib/src/owlly/stage/index.d.ts +4 -0
- package/lib/src/owlly/stage/index.js +7 -0
- package/lib/src/owlly/stage/index.js.map +1 -0
- package/lib/src/owlly/stage/owlly.d.ts +38 -0
- package/lib/src/owlly/stage/owlly.js +168 -0
- package/lib/src/owlly/stage/owlly.js.map +1 -0
- package/lib/src/owlly/stage/stage.d.ts +108 -0
- package/lib/src/owlly/stage/stage.js +235 -0
- package/lib/src/owlly/stage/stage.js.map +1 -0
- package/lib/src/owlly/utils/alignment-utils.d.ts +20 -0
- package/lib/src/owlly/utils/alignment-utils.js +64 -0
- package/lib/src/owlly/utils/alignment-utils.js.map +1 -0
- package/lib/src/owlly/utils/basic-calc.d.ts +18 -0
- package/lib/src/owlly/utils/basic-calc.js +130 -0
- package/lib/src/owlly/utils/basic-calc.js.map +1 -0
- package/lib/src/owlly/utils/basic-tools.d.ts +71 -0
- package/lib/src/owlly/utils/basic-tools.js +236 -0
- package/lib/src/owlly/utils/basic-tools.js.map +1 -0
- package/lib/src/owlly/utils/bvh-tree.d.ts +105 -0
- package/lib/src/owlly/utils/bvh-tree.js +540 -0
- package/lib/src/owlly/utils/bvh-tree.js.map +1 -0
- package/lib/src/owlly/utils/camera.d.ts +37 -0
- package/lib/src/owlly/utils/camera.js +51 -0
- package/lib/src/owlly/utils/camera.js.map +1 -0
- package/lib/src/owlly/utils/cube-texture-cache.d.ts +25 -0
- package/lib/src/owlly/utils/cube-texture-cache.js +144 -0
- package/lib/src/owlly/utils/cube-texture-cache.js.map +1 -0
- package/lib/src/owlly/utils/device-utils.d.ts +18 -0
- package/lib/src/owlly/utils/device-utils.js +42 -0
- package/lib/src/owlly/utils/device-utils.js.map +1 -0
- package/lib/src/owlly/utils/environment-utils.d.ts +37 -0
- package/lib/src/owlly/utils/environment-utils.js +74 -0
- package/lib/src/owlly/utils/environment-utils.js.map +1 -0
- package/lib/src/owlly/utils/event-hub.d.ts +50 -0
- package/lib/src/owlly/utils/event-hub.js +107 -0
- package/lib/src/owlly/utils/event-hub.js.map +1 -0
- package/lib/src/owlly/utils/events.d.ts +219 -0
- package/lib/src/owlly/utils/events.js +220 -0
- package/lib/src/owlly/utils/events.js.map +1 -0
- package/lib/src/owlly/utils/geometry-utils.d.ts +119 -0
- package/lib/src/owlly/utils/geometry-utils.js +623 -0
- package/lib/src/owlly/utils/geometry-utils.js.map +1 -0
- package/lib/src/owlly/utils/helper.d.ts +6 -0
- package/lib/src/owlly/utils/helper.js +25 -0
- package/lib/src/owlly/utils/helper.js.map +1 -0
- package/lib/src/owlly/utils/index.d.ts +14 -0
- package/lib/src/owlly/utils/index.js +18 -0
- package/lib/src/owlly/utils/index.js.map +1 -0
- package/lib/src/owlly/utils/lru-cache.d.ts +26 -0
- package/lib/src/owlly/utils/lru-cache.js +110 -0
- package/lib/src/owlly/utils/lru-cache.js.map +1 -0
- package/lib/src/owlly/utils/map-utils.d.ts +7 -0
- package/lib/src/owlly/utils/map-utils.js +53 -0
- package/lib/src/owlly/utils/map-utils.js.map +1 -0
- package/lib/src/owlly/utils/number-utils.d.ts +8 -0
- package/lib/src/owlly/utils/number-utils.js +73 -0
- package/lib/src/owlly/utils/number-utils.js.map +1 -0
- package/lib/src/owlly/utils/panorama-model-util.d.ts +46 -0
- package/lib/src/owlly/utils/panorama-model-util.js +246 -0
- package/lib/src/owlly/utils/panorama-model-util.js.map +1 -0
- package/lib/src/owlly/utils/path-utils.d.ts +80 -0
- package/lib/src/owlly/utils/path-utils.js +729 -0
- package/lib/src/owlly/utils/path-utils.js.map +1 -0
- package/lib/src/owlly/utils/svgutils.d.ts +138 -0
- package/lib/src/owlly/utils/svgutils.js +562 -0
- package/lib/src/owlly/utils/svgutils.js.map +1 -0
- package/lib/src/owlly/utils/texture-cache.d.ts +29 -0
- package/lib/src/owlly/utils/texture-cache.js +116 -0
- package/lib/src/owlly/utils/texture-cache.js.map +1 -0
- package/lib/src/owlly/utils/tile-util.d.ts +187 -0
- package/lib/src/owlly/utils/tile-util.js +457 -0
- package/lib/src/owlly/utils/tile-util.js.map +1 -0
- package/lib/src/owlly/utils/time-profiler.d.ts +21 -0
- package/lib/src/owlly/utils/time-profiler.js +49 -0
- package/lib/src/owlly/utils/time-profiler.js.map +1 -0
- package/lib/src/owlly/view/__test__/perspective-view.spec.d.ts +0 -0
- package/lib/src/owlly/view/__test__/perspective-view.spec.js +22 -0
- package/lib/src/owlly/view/__test__/perspective-view.spec.js.map +1 -0
- package/lib/src/owlly/view/camera-view.d.ts +35 -0
- package/lib/src/owlly/view/camera-view.js +102 -0
- package/lib/src/owlly/view/camera-view.js.map +1 -0
- package/lib/src/owlly/view/index.d.ts +3 -0
- package/lib/src/owlly/view/index.js +6 -0
- package/lib/src/owlly/view/index.js.map +1 -0
- package/lib/src/owlly/view/orthographic-view.d.ts +40 -0
- package/lib/src/owlly/view/orthographic-view.js +95 -0
- package/lib/src/owlly/view/orthographic-view.js.map +1 -0
- package/lib/src/owlly/view/perspective-view.d.ts +40 -0
- package/lib/src/owlly/view/perspective-view.js +96 -0
- package/lib/src/owlly/view/perspective-view.js.map +1 -0
- package/lib/src/owlly/view/svg-map-view.d.ts +46 -0
- package/lib/src/owlly/view/svg-map-view.js +145 -0
- package/lib/src/owlly/view/svg-map-view.js.map +1 -0
- package/lib/src/owlly/view/view.d.ts +146 -0
- package/lib/src/owlly/view/view.js +318 -0
- package/lib/src/owlly/view/view.js.map +1 -0
- package/lib/src/web/main.centroid.d.ts +0 -0
- package/lib/src/web/main.centroid.js +74 -0
- package/lib/src/web/main.centroid.js.map +1 -0
- package/lib/src/web/main.hyma.meshline2d.d.ts +1 -0
- package/lib/src/web/main.hyma.meshline2d.js +76 -0
- package/lib/src/web/main.hyma.meshline2d.js.map +1 -0
- package/lib/src/web/main.jyfang.sample.d.ts +0 -0
- package/lib/src/web/main.jyfang.sample.js +122 -0
- package/lib/src/web/main.jyfang.sample.js.map +1 -0
- package/lib/src/web/main.rpeng.extrude.d.ts +1 -0
- package/lib/src/web/main.rpeng.extrude.js +180 -0
- package/lib/src/web/main.rpeng.extrude.js.map +1 -0
- package/lib/src/web/main.rpeng.mes.plane.d.ts +1 -0
- package/lib/src/web/main.rpeng.mes.plane.js +135 -0
- package/lib/src/web/main.rpeng.mes.plane.js.map +1 -0
- package/lib/src/web/main.rpeng.sample.d.ts +0 -0
- package/lib/src/web/main.rpeng.sample.js +318 -0
- package/lib/src/web/main.rpeng.sample.js.map +1 -0
- package/lib/src/web/main.rpeng.vr.d.ts +1 -0
- package/lib/src/web/main.rpeng.vr.js +141 -0
- package/lib/src/web/main.rpeng.vr.js.map +1 -0
- package/lib/src/web/main.sample.d.ts +1 -0
- package/lib/src/web/main.sample.js +52 -0
- package/lib/src/web/main.sample.js.map +1 -0
- package/lib/src/web/quattree.hyma.d.ts +0 -0
- package/lib/src/web/quattree.hyma.js +150 -0
- package/lib/src/web/quattree.hyma.js.map +1 -0
- package/lib/src/web/sensor-vr-plugin.d.ts +0 -0
- package/lib/src/web/sensor-vr-plugin.js +166 -0
- package/lib/src/web/sensor-vr-plugin.js.map +1 -0
- package/package.json +142 -0
- package/src/@types/SceneUtils.d.ts +9 -0
- package/src/@types/chaikin-smooth.d.ts +5 -0
- package/src/@types/global.d.ts +3 -0
- package/src/@types/snapsvg.d.ts +11 -0
- package/src/@types/svgson.d.ts +30 -0
- package/src/assets/favicon.ico +0 -0
- package/src/external/lines/line-geometry.ts +70 -0
- package/src/external/lines/line-material.ts +453 -0
- package/src/external/lines/line-segments-2.ts +194 -0
- package/src/external/lines/line-segments-geometry.ts +197 -0
- package/src/external/loaders/gltf-loader.ts +3004 -0
- package/src/external/orbit-controls.ts +1070 -0
- package/src/external/renderers/css-2d-renderer.ts +185 -0
- package/src/external/renderers/css-3d-renderer.ts +245 -0
- package/src/external/transform-controls.ts +1532 -0
- package/src/external/util/buffer-geometry-utils.ts +783 -0
- package/src/owlly/controller/aerial-element-controller.ts +277 -0
- package/src/owlly/controller/basic-controller.ts +1509 -0
- package/src/owlly/controller/camera-controller.ts +155 -0
- package/src/owlly/controller/controller.ts +76 -0
- package/src/owlly/controller/index.ts +15 -0
- package/src/owlly/controller/mouse-indicator-controller.ts +157 -0
- package/src/owlly/controller/orbit-control.ts +310 -0
- package/src/owlly/controller/panorama-adjust-controller.ts +183 -0
- package/src/owlly/controller/panorama-controller.ts +2234 -0
- package/src/owlly/controller/panorama-transform-controller.ts +151 -0
- package/src/owlly/controller/plane-controller.ts +222 -0
- package/src/owlly/controller/texture-controller.ts +949 -0
- package/src/owlly/controller/tile-panorama-controller.ts +1633 -0
- package/src/owlly/controller/transform-controller.ts +684 -0
- package/src/owlly/element/bottom-nav-element.ts +352 -0
- package/src/owlly/element/camera.ts +389 -0
- package/src/owlly/element/dom-2d-element.ts +88 -0
- package/src/owlly/element/dom-3d-element.ts +87 -0
- package/src/owlly/element/dom-label-2d.ts +497 -0
- package/src/owlly/element/element.ts +117 -0
- package/src/owlly/element/floor-model.ts +290 -0
- package/src/owlly/element/gif-kit/Gif.ts +509 -0
- package/src/owlly/element/gif-kit/GifColor.ts +44 -0
- package/src/owlly/element/gif-kit/GifCompressedCodesToByteArrayConverter.ts +56 -0
- package/src/owlly/element/gif-kit/GifFrame.ts +207 -0
- package/src/owlly/element/gif-kit/GifImage.ts +26 -0
- package/src/owlly/element/gif-kit/GifParser.ts +254 -0
- package/src/owlly/element/gif-kit/GifPresenter.ts +46 -0
- package/src/owlly/element/gif-kit/GifVersion.ts +12 -0
- package/src/owlly/element/gltf-mesh-element.ts +184 -0
- package/src/owlly/element/index.ts +25 -0
- package/src/owlly/element/map-kit/area.ts +232 -0
- package/src/owlly/element/map-kit/block-set.ts +102 -0
- package/src/owlly/element/map-kit/block.ts +417 -0
- package/src/owlly/element/map-kit/index.ts +6 -0
- package/src/owlly/element/map-kit/shape.ts +285 -0
- package/src/owlly/element/mesh-element.ts +94 -0
- package/src/owlly/element/mesh-line-2d.ts +1032 -0
- package/src/owlly/element/meshline-o.ts +802 -0
- package/src/owlly/element/panorama-group.ts +1250 -0
- package/src/owlly/element/panorama.ts +1044 -0
- package/src/owlly/element/path-group.ts +212 -0
- package/src/owlly/element/path.ts +727 -0
- package/src/owlly/element/placeable-2d.ts +627 -0
- package/src/owlly/element/polygon-mesh.ts +344 -0
- package/src/owlly/element/ring-element.ts +517 -0
- package/src/owlly/element/sphere-mesh.ts +96 -0
- package/src/owlly/element/svg-floor-model.ts +200 -0
- package/src/owlly/element/svg-floors.ts +121 -0
- package/src/owlly/element/tile-panorama-group.ts +1314 -0
- package/src/owlly/element/tile-panorama.ts +636 -0
- package/src/owlly/element/tile-plane.ts +430 -0
- package/src/owlly/element/video-element.ts +190 -0
- package/src/owlly/geometries/ExtrudeGeometry2.ts +255 -0
- package/src/owlly/index.ts +19 -0
- package/src/owlly/overlay/canvas-overlay.ts +642 -0
- package/src/owlly/overlay/css-2d-overlay.ts +48 -0
- package/src/owlly/overlay/css-3d-overlay.ts +50 -0
- package/src/owlly/overlay/index.ts +11 -0
- package/src/owlly/overlay/label-overlay.ts +419 -0
- package/src/owlly/overlay/overlay.ts +17 -0
- package/src/owlly/overlay/path-overlay.ts +170 -0
- package/src/owlly/overlay/path-overlay2.ts +149 -0
- package/src/owlly/overlay/poi-overlay-3d.ts +1759 -0
- package/src/owlly/overlay/poi-overlay.ts +1739 -0
- package/src/owlly/owlly-2d/index.ts +108 -0
- package/src/owlly/screen/index.ts +1 -0
- package/src/owlly/screen/screen.ts +323 -0
- package/src/owlly/stage/__test__/stage.spec.ts +15 -0
- package/src/owlly/stage/externals.ts +45 -0
- package/src/owlly/stage/index.ts +12 -0
- package/src/owlly/stage/owlly.ts +223 -0
- package/src/owlly/stage/stage.ts +274 -0
- package/src/owlly/utils/alignment-utils.ts +84 -0
- package/src/owlly/utils/basic-calc.ts +141 -0
- package/src/owlly/utils/basic-tools.ts +286 -0
- package/src/owlly/utils/bvh-tree.ts +695 -0
- package/src/owlly/utils/camera.ts +72 -0
- package/src/owlly/utils/cube-texture-cache.ts +155 -0
- package/src/owlly/utils/device-utils.ts +53 -0
- package/src/owlly/utils/environment-utils.ts +81 -0
- package/src/owlly/utils/event-hub.ts +120 -0
- package/src/owlly/utils/events.ts +266 -0
- package/src/owlly/utils/geometry-utils.ts +749 -0
- package/src/owlly/utils/helper.ts +33 -0
- package/src/owlly/utils/index.ts +17 -0
- package/src/owlly/utils/lru-cache.ts +126 -0
- package/src/owlly/utils/map-utils.ts +55 -0
- package/src/owlly/utils/number-utils.ts +75 -0
- package/src/owlly/utils/panorama-model-util.ts +255 -0
- package/src/owlly/utils/path-utils.ts +837 -0
- package/src/owlly/utils/svgutils.ts +732 -0
- package/src/owlly/utils/texture-cache.ts +132 -0
- package/src/owlly/utils/tile-util.ts +563 -0
- package/src/owlly/utils/time-profiler.ts +57 -0
- package/src/owlly/view/__test__/perspective-view.spec.ts +23 -0
- package/src/owlly/view/camera-view.ts +114 -0
- package/src/owlly/view/index.ts +5 -0
- package/src/owlly/view/orthographic-view.ts +124 -0
- package/src/owlly/view/perspective-view.ts +125 -0
- package/src/owlly/view/svg-map-view.ts +187 -0
- package/src/owlly/view/view.ts +409 -0
- package/src/public/js/jsmpeg.min.js +3129 -0
- package/src/web/index.html +52 -0
- package/src/web/main.centroid.ts +85 -0
- package/src/web/main.hyma.meshline2d.ts +84 -0
- package/src/web/main.jyfang.sample.ts +139 -0
- package/src/web/main.rpeng.extrude.ts +194 -0
- package/src/web/main.rpeng.mes.plane.ts +161 -0
- package/src/web/main.rpeng.sample.ts +345 -0
- package/src/web/main.rpeng.vr.ts +159 -0
- package/src/web/main.sample.ts +59 -0
- package/src/web/quattree.hyma.ts +163 -0
- package/src/web/sensor-vr-plugin.ts +201 -0
- package/src/web/testPixel.png +0 -0
|
@@ -0,0 +1,1509 @@
|
|
|
1
|
+
import TWEEN from '@tweenjs/tween.js';
|
|
2
|
+
import { Externals, NS_THREE } from '../stage/externals';
|
|
3
|
+
import { Controller } from './controller';
|
|
4
|
+
import { OrthographicView } from '../view/orthographic-view';
|
|
5
|
+
import { PerspectiveView } from '../view/perspective-view';
|
|
6
|
+
import { Events, OwllyEvents } from '../utils/events';
|
|
7
|
+
import { View } from '../view/view';
|
|
8
|
+
import { Env, EnvironmentUtils } from '../utils/environment-utils';
|
|
9
|
+
import { BasicTools } from '../utils';
|
|
10
|
+
|
|
11
|
+
enum STATE {
|
|
12
|
+
IDLE,
|
|
13
|
+
ROTATE,
|
|
14
|
+
ORBIT,
|
|
15
|
+
PAN,
|
|
16
|
+
DOLLY,
|
|
17
|
+
TOUCH_ROTATE,
|
|
18
|
+
TOUCH_ORBIT,
|
|
19
|
+
TOUCH_PAN,
|
|
20
|
+
TOUCH_DOLLY_ROTATE,
|
|
21
|
+
TOUCH_DOLLY_PAN,
|
|
22
|
+
TOUCH_MAP,
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const EPS = 0.000001;
|
|
26
|
+
|
|
27
|
+
type MouseButtons = { LEFT: NS_THREE.MOUSE; MIDDLE: NS_THREE.MOUSE; RIGHT: NS_THREE.MOUSE };
|
|
28
|
+
|
|
29
|
+
type Touches = { ONE: NS_THREE.TOUCH; TWO: NS_THREE.TOUCH | 'map' };
|
|
30
|
+
|
|
31
|
+
class BasicController extends Controller {
|
|
32
|
+
private bindingView: View | null;
|
|
33
|
+
|
|
34
|
+
private camera: NS_THREE.PerspectiveCamera | NS_THREE.OrthographicCamera;
|
|
35
|
+
|
|
36
|
+
private target: NS_THREE.Vector3;
|
|
37
|
+
|
|
38
|
+
private enabled: boolean;
|
|
39
|
+
|
|
40
|
+
private state: STATE;
|
|
41
|
+
|
|
42
|
+
private eventListeners: {
|
|
43
|
+
onMouseDown: (e: MouseEvent) => void;
|
|
44
|
+
onMouseMove: (e: MouseEvent) => void;
|
|
45
|
+
onMouseUp: (e: MouseEvent) => void;
|
|
46
|
+
onMouseWheel: (e: WheelEvent) => void;
|
|
47
|
+
onContextMenu: (e: MouseEvent) => void;
|
|
48
|
+
onTouchStart: (e: TouchEvent) => void;
|
|
49
|
+
onTouchMove: (e: TouchEvent) => void;
|
|
50
|
+
onTouchEnd: (e: TouchEvent) => void;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
private needUpdate: boolean;
|
|
54
|
+
|
|
55
|
+
private enableDamping: boolean;
|
|
56
|
+
|
|
57
|
+
private dampingFactor: number;
|
|
58
|
+
|
|
59
|
+
private mouseButtons: MouseButtons;
|
|
60
|
+
|
|
61
|
+
private touches: Touches;
|
|
62
|
+
|
|
63
|
+
private boundaryEnabled: boolean;
|
|
64
|
+
|
|
65
|
+
private boundary: NS_THREE.Box3;
|
|
66
|
+
|
|
67
|
+
/* calculation vectors */
|
|
68
|
+
|
|
69
|
+
private lastTick: number;
|
|
70
|
+
|
|
71
|
+
private timeStart: number;
|
|
72
|
+
|
|
73
|
+
private timeEnd: number;
|
|
74
|
+
|
|
75
|
+
private touchCenter: NS_THREE.Vector2;
|
|
76
|
+
|
|
77
|
+
// -- inertial
|
|
78
|
+
|
|
79
|
+
private inertiaFactor: number;
|
|
80
|
+
|
|
81
|
+
// -- rotation
|
|
82
|
+
|
|
83
|
+
private enableRotate: boolean;
|
|
84
|
+
|
|
85
|
+
private rotateMode: 'self' | 'orbit';
|
|
86
|
+
|
|
87
|
+
private rotateSpeed: number;
|
|
88
|
+
|
|
89
|
+
private rotateStart: NS_THREE.Vector2;
|
|
90
|
+
|
|
91
|
+
private rotateDelta: NS_THREE.Vector2;
|
|
92
|
+
|
|
93
|
+
private rotateEnd: NS_THREE.Vector2;
|
|
94
|
+
|
|
95
|
+
private rotateLineStart: NS_THREE.Vector2;
|
|
96
|
+
|
|
97
|
+
private rotateLineEnd: NS_THREE.Vector2;
|
|
98
|
+
|
|
99
|
+
private rotateInertiaType: 'normal' | 'map';
|
|
100
|
+
|
|
101
|
+
private spherical: NS_THREE.Spherical;
|
|
102
|
+
|
|
103
|
+
private sphericalDelta: NS_THREE.Spherical;
|
|
104
|
+
|
|
105
|
+
private maxSpherical: NS_THREE.Spherical;
|
|
106
|
+
|
|
107
|
+
private minSpherical: NS_THREE.Spherical;
|
|
108
|
+
|
|
109
|
+
private lastQuaternion: NS_THREE.Quaternion;
|
|
110
|
+
|
|
111
|
+
private rotateInertiaDirection: NS_THREE.Vector2;
|
|
112
|
+
|
|
113
|
+
private rotateInertiaEnabled: boolean;
|
|
114
|
+
|
|
115
|
+
private rotateInertiaBase: number;
|
|
116
|
+
|
|
117
|
+
private rotateInertia: number;
|
|
118
|
+
|
|
119
|
+
private rotateInertiaDuration: number;
|
|
120
|
+
|
|
121
|
+
// -- dolly
|
|
122
|
+
|
|
123
|
+
private enableZoom: boolean;
|
|
124
|
+
|
|
125
|
+
private dollyStart: NS_THREE.Vector2;
|
|
126
|
+
|
|
127
|
+
private dollyEnd: NS_THREE.Vector2;
|
|
128
|
+
|
|
129
|
+
private zoomMode: 'zoom' | 'fov';
|
|
130
|
+
|
|
131
|
+
private zoomDelta: number;
|
|
132
|
+
|
|
133
|
+
private zoomRange: { min: number; max: number };
|
|
134
|
+
|
|
135
|
+
private fovRange: { min: number; max: number };
|
|
136
|
+
|
|
137
|
+
private zoomInertiaEnabled: boolean;
|
|
138
|
+
|
|
139
|
+
private zoomInertiaBase: number;
|
|
140
|
+
|
|
141
|
+
private zoomInertia: number;
|
|
142
|
+
|
|
143
|
+
private zoomInertiaDuration: number;
|
|
144
|
+
|
|
145
|
+
// -- pan
|
|
146
|
+
|
|
147
|
+
private enablePan: boolean;
|
|
148
|
+
|
|
149
|
+
private panStart: NS_THREE.Vector2;
|
|
150
|
+
|
|
151
|
+
private panDelta: NS_THREE.Vector2;
|
|
152
|
+
|
|
153
|
+
private panEnd: NS_THREE.Vector2;
|
|
154
|
+
|
|
155
|
+
private panOffset: NS_THREE.Vector3;
|
|
156
|
+
|
|
157
|
+
private panSpeed: number;
|
|
158
|
+
|
|
159
|
+
private lastPosition: NS_THREE.Vector3;
|
|
160
|
+
|
|
161
|
+
private screenSpacePanning: boolean;
|
|
162
|
+
|
|
163
|
+
private panInertiaDirection: NS_THREE.Vector2;
|
|
164
|
+
|
|
165
|
+
private panInertiaEnabled: boolean;
|
|
166
|
+
|
|
167
|
+
private panInertiaBase: number;
|
|
168
|
+
|
|
169
|
+
private panInertia: number;
|
|
170
|
+
|
|
171
|
+
private panInertiaDuration: number;
|
|
172
|
+
|
|
173
|
+
public zoomScale: number;
|
|
174
|
+
|
|
175
|
+
public followMouse: boolean;
|
|
176
|
+
|
|
177
|
+
private mouseXY: NS_THREE.Vector2;
|
|
178
|
+
|
|
179
|
+
constructor(view: PerspectiveView | OrthographicView) { // OrthographicView |
|
|
180
|
+
super();
|
|
181
|
+
const { THREE } = Externals.getInstance();
|
|
182
|
+
|
|
183
|
+
this.eventListeners = {
|
|
184
|
+
onMouseDown: (e): void => { this.onMouseDown(e); },
|
|
185
|
+
onMouseMove: (e): void => { this.onMouseMove(e); },
|
|
186
|
+
onMouseUp: (e): void => { this.onMouseUp(e); },
|
|
187
|
+
onMouseWheel: (e): void => { this.onMouseWheel(e); },
|
|
188
|
+
onTouchStart: (e): void => { this.onTouchStart(e); },
|
|
189
|
+
onTouchMove: (e): void => { this.onTouchMove(e); },
|
|
190
|
+
onTouchEnd: (e): void => { this.onTouchEnd(e); },
|
|
191
|
+
onContextMenu: (e): void => { this.onContextMenu(e); },
|
|
192
|
+
};
|
|
193
|
+
|
|
194
|
+
this.state = STATE.IDLE;
|
|
195
|
+
this.enabled = true;
|
|
196
|
+
|
|
197
|
+
this.target = new THREE.Vector3();
|
|
198
|
+
this.lastTick = Date.now();
|
|
199
|
+
this.enableDamping = false;
|
|
200
|
+
this.dampingFactor = 0;
|
|
201
|
+
this.mouseButtons = {
|
|
202
|
+
LEFT: THREE.MOUSE.ROTATE,
|
|
203
|
+
MIDDLE: THREE.MOUSE.DOLLY,
|
|
204
|
+
RIGHT: THREE.MOUSE.PAN,
|
|
205
|
+
};
|
|
206
|
+
this.touches = { ONE: THREE.TOUCH.ROTATE, TWO: THREE.TOUCH.DOLLY_PAN };
|
|
207
|
+
|
|
208
|
+
this.boundaryEnabled = false;
|
|
209
|
+
this.boundary = new THREE.Box3(
|
|
210
|
+
new THREE.Vector3(-Infinity, -Infinity, -Infinity),
|
|
211
|
+
new THREE.Vector3(Infinity, Infinity, Infinity),
|
|
212
|
+
);
|
|
213
|
+
|
|
214
|
+
this.touchCenter = new THREE.Vector2();
|
|
215
|
+
this.inertiaFactor = 1;
|
|
216
|
+
|
|
217
|
+
this.enableRotate = true;
|
|
218
|
+
this.rotateMode = 'self';
|
|
219
|
+
this.rotateSpeed = 1;
|
|
220
|
+
this.rotateStart = new THREE.Vector2();
|
|
221
|
+
this.rotateEnd = new THREE.Vector2();
|
|
222
|
+
this.rotateDelta = new THREE.Vector2();
|
|
223
|
+
this.rotateLineStart = new THREE.Vector2();
|
|
224
|
+
this.rotateLineEnd = new THREE.Vector2();
|
|
225
|
+
this.rotateInertiaDirection = new THREE.Vector2();
|
|
226
|
+
this.rotateInertiaEnabled = true;
|
|
227
|
+
this.rotateInertiaBase = 0;
|
|
228
|
+
this.rotateInertia = 0;
|
|
229
|
+
this.rotateInertiaType = 'normal';
|
|
230
|
+
this.spherical = new THREE.Spherical();
|
|
231
|
+
this.sphericalDelta = new THREE.Spherical();
|
|
232
|
+
this.maxSpherical = new THREE.Spherical(1, Infinity, Infinity);
|
|
233
|
+
this.minSpherical = new THREE.Spherical(1, -Infinity, -Infinity);
|
|
234
|
+
this.lastQuaternion = new THREE.Quaternion();
|
|
235
|
+
|
|
236
|
+
this.enableZoom = true;
|
|
237
|
+
this.dollyStart = new THREE.Vector2();
|
|
238
|
+
this.dollyEnd = new THREE.Vector2();
|
|
239
|
+
this.zoomMode = 'zoom';
|
|
240
|
+
this.zoomDelta = 0;
|
|
241
|
+
this.zoomRange = { min: 1, max: 10 };
|
|
242
|
+
this.fovRange = { min: 60, max: 90 };
|
|
243
|
+
this.zoomInertiaEnabled = true;
|
|
244
|
+
this.zoomInertiaBase = 0;
|
|
245
|
+
this.zoomInertia = 0;
|
|
246
|
+
this.zoomScale = 1;
|
|
247
|
+
|
|
248
|
+
this.enablePan = true;
|
|
249
|
+
this.panStart = new THREE.Vector2();
|
|
250
|
+
this.panDelta = new THREE.Vector2();
|
|
251
|
+
this.panEnd = new THREE.Vector2();
|
|
252
|
+
this.panOffset = new THREE.Vector3();
|
|
253
|
+
this.panSpeed = 1;
|
|
254
|
+
this.screenSpacePanning = true;
|
|
255
|
+
this.lastPosition = new THREE.Vector3();
|
|
256
|
+
this.panInertiaDirection = new THREE.Vector2();
|
|
257
|
+
this.panInertiaEnabled = true;
|
|
258
|
+
this.panInertiaBase = 0;
|
|
259
|
+
this.panInertia = 0;
|
|
260
|
+
this.mouseXY = new THREE.Vector2();
|
|
261
|
+
this.bindView(view);
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
private registerEvents(): void {
|
|
265
|
+
if (!this.bindingView) return;
|
|
266
|
+
this.bindingView.on(OwllyEvents.MOUSE_DOWN, this.eventListeners.onMouseDown);
|
|
267
|
+
this.bindingView.on(OwllyEvents.MOUSE_MOVE, this.eventListeners.onMouseMove);
|
|
268
|
+
this.bindingView.on(OwllyEvents.MOUSE_UP, this.eventListeners.onMouseUp);
|
|
269
|
+
this.bindingView.on(OwllyEvents.MOUSE_WHEEL, this.eventListeners.onMouseWheel);
|
|
270
|
+
this.bindingView.on(OwllyEvents.TOUCH_START, this.eventListeners.onTouchStart);
|
|
271
|
+
this.bindingView.on(OwllyEvents.TOUCH_MOVE, this.eventListeners.onTouchMove);
|
|
272
|
+
this.bindingView.on(OwllyEvents.TOUCH_END, this.eventListeners.onTouchEnd);
|
|
273
|
+
this.bindingView.on(OwllyEvents.CONTEXT_MENU, this.eventListeners.onContextMenu);
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
private unregisterEvents(): void {
|
|
277
|
+
if (!this.bindingView) return;
|
|
278
|
+
this.bindingView.off(OwllyEvents.MOUSE_DOWN, this.eventListeners.onMouseDown);
|
|
279
|
+
this.bindingView.off(OwllyEvents.MOUSE_MOVE, this.eventListeners.onMouseMove);
|
|
280
|
+
this.bindingView.off(OwllyEvents.MOUSE_UP, this.eventListeners.onMouseUp);
|
|
281
|
+
this.bindingView.off(OwllyEvents.MOUSE_WHEEL, this.eventListeners.onMouseWheel);
|
|
282
|
+
this.bindingView.off(OwllyEvents.TOUCH_START, this.eventListeners.onTouchStart);
|
|
283
|
+
this.bindingView.off(OwllyEvents.TOUCH_MOVE, this.eventListeners.onTouchMove);
|
|
284
|
+
this.bindingView.off(OwllyEvents.TOUCH_END, this.eventListeners.onTouchEnd);
|
|
285
|
+
this.bindingView.off(OwllyEvents.CONTEXT_MENU, this.eventListeners.onContextMenu);
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
/* Event Callbacks */
|
|
289
|
+
|
|
290
|
+
private onMouseDown(e: MouseEvent): void {
|
|
291
|
+
e.preventDefault();
|
|
292
|
+
|
|
293
|
+
let mouseAction;
|
|
294
|
+
|
|
295
|
+
switch (e.button) {
|
|
296
|
+
case 0: mouseAction = this.mouseButtons.LEFT; break;
|
|
297
|
+
case 1: mouseAction = this.mouseButtons.MIDDLE; break;
|
|
298
|
+
case 2: mouseAction = this.mouseButtons.RIGHT; break;
|
|
299
|
+
default: break;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
switch (mouseAction) {
|
|
303
|
+
case NS_THREE.MOUSE.ROTATE: if (this.enableRotate) this.state = STATE.ROTATE; break;
|
|
304
|
+
case NS_THREE.MOUSE.PAN: if (this.enablePan) this.state = STATE.PAN; break;
|
|
305
|
+
case NS_THREE.MOUSE.DOLLY: if (this.enableZoom) this.state = STATE.DOLLY; break;
|
|
306
|
+
default: this.state = STATE.IDLE; break;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
switch (this.state) {
|
|
310
|
+
case STATE.ROTATE: this.handleMouseDownRotate(e); break;
|
|
311
|
+
case STATE.PAN: this.handleMouseDownPan(e); break;
|
|
312
|
+
case STATE.DOLLY: this.handleMouseDownDolly(e); break;
|
|
313
|
+
default: break;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
if (this.state !== STATE.IDLE) {
|
|
317
|
+
if (this.bindingView) {
|
|
318
|
+
this.bindingView.on(OwllyEvents.MOUSE_MOVE, this.eventListeners.onMouseMove);
|
|
319
|
+
this.bindingView.on(OwllyEvents.MOUSE_UP, this.eventListeners.onMouseUp);
|
|
320
|
+
}
|
|
321
|
+
this.panInertiaBase = 0;
|
|
322
|
+
this.rotateInertiaBase = 0;
|
|
323
|
+
this.zoomInertiaBase = 0;
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
private onMouseMove(e: MouseEvent): void {
|
|
328
|
+
e.preventDefault();
|
|
329
|
+
|
|
330
|
+
switch (this.state) {
|
|
331
|
+
case STATE.ROTATE: this.handleMouseMoveSelfRotate(e); break;
|
|
332
|
+
case STATE.PAN: this.handleMouseMovePan(e); break;
|
|
333
|
+
case STATE.DOLLY: this.handleMouseMoveDolly(e); break;
|
|
334
|
+
default: break;
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
private onMouseUp(e: MouseEvent): void {
|
|
339
|
+
e.preventDefault();
|
|
340
|
+
|
|
341
|
+
if (this.bindingView) {
|
|
342
|
+
this.bindingView.off(OwllyEvents.MOUSE_MOVE, this.eventListeners.onMouseMove);
|
|
343
|
+
this.bindingView.off(OwllyEvents.MOUSE_UP, this.eventListeners.onMouseUp);
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
switch (this.state) {
|
|
347
|
+
case STATE.ROTATE: this.handleUpRotate(); break;
|
|
348
|
+
case STATE.PAN: this.handleUpPan(); break;
|
|
349
|
+
default: break;
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
this.state = STATE.IDLE;
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
private onMouseWheel(e: WheelEvent): void {
|
|
356
|
+
if (!this.enableZoom || (this.state !== STATE.IDLE && this.state !== STATE.ROTATE)) return;
|
|
357
|
+
e.preventDefault();
|
|
358
|
+
e.stopPropagation();
|
|
359
|
+
this.handleMouseWheel(e);
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
private onContextMenu(e: MouseEvent): void {
|
|
363
|
+
e.preventDefault();
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
private onTouchStart(e: TouchEvent): void {
|
|
367
|
+
if (EnvironmentUtils.GetEnv() !== Env.Miniapp) {
|
|
368
|
+
e.preventDefault();
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
this.timeStart = e.timeStamp;
|
|
372
|
+
|
|
373
|
+
switch (e.touches.length) {
|
|
374
|
+
case 1:
|
|
375
|
+
switch (this.touches.ONE) {
|
|
376
|
+
case NS_THREE.TOUCH.PAN: if (this.enablePan) this.state = STATE.TOUCH_PAN; break;
|
|
377
|
+
case NS_THREE.TOUCH.ROTATE: if (this.enableRotate) this.state = STATE.TOUCH_ROTATE; break;
|
|
378
|
+
default: this.state = STATE.IDLE; break;
|
|
379
|
+
}
|
|
380
|
+
break;
|
|
381
|
+
case 2:
|
|
382
|
+
this.touchCenter.set(
|
|
383
|
+
(e.touches[0].clientX + e.touches[1].clientX) / 2,
|
|
384
|
+
(e.touches[0].clientY + e.touches[1].clientY) / 2,
|
|
385
|
+
);
|
|
386
|
+
switch (this.touches.TWO) {
|
|
387
|
+
case NS_THREE.TOUCH.DOLLY_PAN: this.state = STATE.TOUCH_DOLLY_PAN; break;
|
|
388
|
+
case NS_THREE.TOUCH.DOLLY_ROTATE: this.state = STATE.TOUCH_DOLLY_ROTATE; break;
|
|
389
|
+
case 'map': this.state = STATE.TOUCH_MAP; break;
|
|
390
|
+
default: this.state = STATE.IDLE; break;
|
|
391
|
+
}
|
|
392
|
+
break;
|
|
393
|
+
default: this.state = STATE.IDLE; break;
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
switch (this.state) {
|
|
397
|
+
case STATE.TOUCH_PAN: this.handleTouchStartPan(e); break;
|
|
398
|
+
case STATE.TOUCH_ROTATE: this.handleTouchStartRotate(e); break;
|
|
399
|
+
case STATE.TOUCH_DOLLY_ROTATE: this.handleTouchStartDollyRotate(e); break;
|
|
400
|
+
case STATE.TOUCH_DOLLY_PAN: this.handleTouchStartDollyPan(e); break;
|
|
401
|
+
case STATE.TOUCH_MAP: this.handleTouchStartMap(e); break;
|
|
402
|
+
default: break;
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
if (this.state !== STATE.IDLE) {
|
|
406
|
+
if (this.bindingView) {
|
|
407
|
+
this.bindingView.on(OwllyEvents.MOUSE_MOVE, this.eventListeners.onMouseMove);
|
|
408
|
+
this.bindingView.on(OwllyEvents.MOUSE_UP, this.eventListeners.onMouseUp);
|
|
409
|
+
}
|
|
410
|
+
this.panInertiaBase = 0;
|
|
411
|
+
this.rotateInertiaBase = 0;
|
|
412
|
+
this.zoomInertiaBase = 0;
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
private onTouchMove(e: TouchEvent): void {
|
|
417
|
+
if (EnvironmentUtils.GetEnv() !== Env.Miniapp) {
|
|
418
|
+
e.preventDefault();
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
if (e.touches.length === 2) {
|
|
422
|
+
this.touchCenter.set(
|
|
423
|
+
(e.touches[0].clientX + e.touches[1].clientX) / 2,
|
|
424
|
+
(e.touches[0].clientY + e.touches[1].clientY) / 2,
|
|
425
|
+
);
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
switch (this.state) {
|
|
429
|
+
case STATE.TOUCH_PAN: this.handleTouchMovePan(e); break;
|
|
430
|
+
case STATE.TOUCH_ROTATE: this.handleTouchMoveSelfRotate(e); break;
|
|
431
|
+
case STATE.TOUCH_DOLLY_ROTATE: this.handleTouchMoveDollyRotate(e); break;
|
|
432
|
+
case STATE.TOUCH_DOLLY_PAN: this.handleTouchMoveDollyPan(e); break;
|
|
433
|
+
case STATE.TOUCH_MAP: this.handleTouchMoveAll(e); break;
|
|
434
|
+
default: break;
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
this.timeEnd = this.timeStart;
|
|
438
|
+
this.timeStart = e.timeStamp;
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
private onTouchEnd(e: TouchEvent): void {
|
|
442
|
+
if (EnvironmentUtils.GetEnv() !== Env.Miniapp) {
|
|
443
|
+
e.preventDefault();
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
switch (this.state) {
|
|
447
|
+
case STATE.TOUCH_ROTATE:
|
|
448
|
+
case STATE.TOUCH_DOLLY_ROTATE: this.handleUpRotate(); break;
|
|
449
|
+
case STATE.TOUCH_PAN:
|
|
450
|
+
case STATE.TOUCH_DOLLY_PAN: this.handleUpPan(); break;
|
|
451
|
+
case STATE.TOUCH_MAP: this.handleUpAll(); break;
|
|
452
|
+
default: break;
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
this.state = STATE.IDLE;
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
/* Action Handlers */
|
|
459
|
+
|
|
460
|
+
private handleMouseDownRotate(e: MouseEvent): void {
|
|
461
|
+
this.handleDownRotate(e.offsetX, e.offsetY);
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
private handleMouseMoveSelfRotate(e: MouseEvent): void {
|
|
465
|
+
this.handleMoveRotate(e.offsetX, e.offsetY);
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
private handleTouchStartRotate(e: TouchEvent): void {
|
|
469
|
+
if (e.touches.length === 1) {
|
|
470
|
+
this.handleDownRotate(e.touches[0].clientX, e.touches[0].clientY);
|
|
471
|
+
} else if (this.state === STATE.TOUCH_MAP) {
|
|
472
|
+
const slope = (e.touches[1].clientY - e.touches[0].clientY) / (e.touches[1].clientX - e.touches[0].clientX);
|
|
473
|
+
const intercept = e.touches[0].clientY - slope * e.touches[0].clientX;
|
|
474
|
+
this.rotateLineStart.set(slope, intercept);
|
|
475
|
+
} else {
|
|
476
|
+
const x = 0.5 * (e.touches[0].clientX + e.touches[1].clientX);
|
|
477
|
+
const y = 0.5 * (e.touches[0].clientY + e.touches[1].clientY);
|
|
478
|
+
this.handleDownRotate(x, y);
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
private handleTouchMoveSelfRotate(e: TouchEvent): void {
|
|
483
|
+
if (!this.bindingView) return;
|
|
484
|
+
if (e.touches.length === 1) {
|
|
485
|
+
this.handleMoveRotate(e.touches[0].clientX, e.touches[0].clientY);
|
|
486
|
+
} else if (this.state === STATE.TOUCH_MAP) {
|
|
487
|
+
const slope = (e.touches[1].clientY - e.touches[0].clientY) / (e.touches[1].clientX - e.touches[0].clientX);
|
|
488
|
+
const intercept = e.touches[0].clientY - slope * e.touches[0].clientX;
|
|
489
|
+
this.rotateLineEnd.set(slope, intercept);
|
|
490
|
+
|
|
491
|
+
if (Number.isFinite(this.rotateLineEnd.x) && Number.isFinite(this.rotateLineStart.x)) {
|
|
492
|
+
const interceptionX = (this.rotateLineStart.y - this.rotateLineEnd.y)
|
|
493
|
+
/ (this.rotateLineEnd.x - this.rotateLineStart.x);
|
|
494
|
+
const interceptionY = slope * interceptionX + intercept;
|
|
495
|
+
|
|
496
|
+
if (Number.isFinite(interceptionX) && Number.isFinite(interceptionY)) {
|
|
497
|
+
let angleDelta = Math.atan(this.rotateLineEnd.x) - Math.atan(this.rotateLineStart.x);
|
|
498
|
+
if (Math.PI - Math.abs(angleDelta) < 0.5) {
|
|
499
|
+
angleDelta = -Math.sign(angleDelta) * (Math.PI - Math.abs(angleDelta));
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
if (Math.abs(angleDelta) > 0.01) {
|
|
503
|
+
const cameraCenter = this.rotateLineStart.clone().set(
|
|
504
|
+
// TODO: 这里需要处理为View的尺寸
|
|
505
|
+
this.bindingView.getViewWidth() / 2,
|
|
506
|
+
this.bindingView.getViewHeight() / 2,
|
|
507
|
+
);
|
|
508
|
+
const rotateCenter = this.rotateLineStart.clone().set(interceptionX, interceptionY);
|
|
509
|
+
const cameraDelta = cameraCenter.clone().rotateAround(rotateCenter, angleDelta).sub(cameraCenter);
|
|
510
|
+
this.handlePanDelta(cameraDelta.x, cameraDelta.y);
|
|
511
|
+
|
|
512
|
+
this.rotateDelta.set(angleDelta, 0);
|
|
513
|
+
this.handleRotateSphericalDelta(this.rotateDelta.x, this.rotateDelta.y);
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
this.rotateLineStart.copy(this.rotateLineEnd);
|
|
519
|
+
} else {
|
|
520
|
+
const x = 0.5 * (e.touches[0].clientX + e.touches[1].clientX);
|
|
521
|
+
const y = 0.5 * (e.touches[0].clientY + e.touches[1].clientY);
|
|
522
|
+
this.handleMoveRotate(x, y);
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
private handleDownRotate(x: number, y: number): void {
|
|
527
|
+
this.rotateStart.set(x, y);
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
private handleMoveRotate(x: number, y: number): void {
|
|
531
|
+
this.rotateEnd.set(x, y);
|
|
532
|
+
this.rotateDelta.subVectors(this.rotateEnd, this.rotateStart).multiplyScalar(this.rotateSpeed);
|
|
533
|
+
|
|
534
|
+
this.handleRotateDelta(this.rotateDelta.x, this.rotateDelta.y);
|
|
535
|
+
|
|
536
|
+
this.rotateStart.copy(this.rotateEnd);
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
private handleRotateDelta(deltaX: number, deltaY: number): void {
|
|
540
|
+
if (!this.bindingView) return;
|
|
541
|
+
// TODO: 这里需要处理为View的尺寸
|
|
542
|
+
const clientHeight = this.bindingView.getViewHeight();
|
|
543
|
+
const xCorrection = this.rotateMode === 'self' ? -1 : 1;
|
|
544
|
+
let factor = 1;
|
|
545
|
+
|
|
546
|
+
if ((this.camera as NS_THREE.PerspectiveCamera).isPerspectiveCamera) {
|
|
547
|
+
const camera = this.camera as NS_THREE.PerspectiveCamera;
|
|
548
|
+
factor *= camera.fov / camera.zoom / 360;
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
this.handleRotateSphericalDelta(
|
|
552
|
+
-xCorrection * 2 * Math.PI * deltaX / clientHeight * factor,
|
|
553
|
+
-2 * Math.PI * deltaY / clientHeight * factor,
|
|
554
|
+
);
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
private handleRotateSphericalDelta(deltaTheta: number, deltaPhi: number): void {
|
|
558
|
+
this.sphericalDelta.theta += deltaTheta;
|
|
559
|
+
this.sphericalDelta.phi += deltaPhi;
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
private handleUpRotate(): void {
|
|
563
|
+
if (!this.rotateInertiaEnabled || !this.bindingView) return;
|
|
564
|
+
|
|
565
|
+
const timeElapsed = this.timeStart - this.timeEnd;
|
|
566
|
+
|
|
567
|
+
if (this.state === STATE.TOUCH_MAP) {
|
|
568
|
+
// do nothing now
|
|
569
|
+
this.rotateInertiaType = 'map';
|
|
570
|
+
const speed = this.rotateDelta.x / timeElapsed;
|
|
571
|
+
if (Number.isFinite(speed) && speed > 0.001) {
|
|
572
|
+
this.rotateInertiaBase = this.rotateDelta.x / 10;
|
|
573
|
+
this.rotateInertiaDuration = 0;
|
|
574
|
+
this.rotateInertia = this.rotateInertiaBase;
|
|
575
|
+
}
|
|
576
|
+
} else {
|
|
577
|
+
this.rotateInertiaType = 'normal';
|
|
578
|
+
const speed = this.rotateDelta.length() * this.rotateSpeed / timeElapsed;
|
|
579
|
+
|
|
580
|
+
// TODO: 这里需要处理为View的尺寸
|
|
581
|
+
const clientWidth = this.bindingView.getViewWidth();
|
|
582
|
+
const factor = speed * 1000 / clientWidth * 0.6;
|
|
583
|
+
|
|
584
|
+
if (timeElapsed === 0 || !Number.isFinite(speed)) return;
|
|
585
|
+
|
|
586
|
+
if (Number.isFinite(speed) && speed > 0.3) {
|
|
587
|
+
this.rotateInertiaBase = speed * factor * this.inertiaFactor;
|
|
588
|
+
this.rotateInertiaDuration = 0;
|
|
589
|
+
this.rotateInertiaDirection = this.rotateDelta.clone().normalize();
|
|
590
|
+
this.rotateInertia = this.rotateInertiaBase;
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
private handleMouseDownPan(e: MouseEvent): void {
|
|
596
|
+
this.handleDownPan(e.offsetX, e.offsetY);
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
private handleMouseMovePan(e: MouseEvent): void {
|
|
600
|
+
this.handleMovePan(e.offsetX, e.offsetY);
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
private handleTouchStartPan(e: TouchEvent): void {
|
|
604
|
+
if (e.touches.length === 1) {
|
|
605
|
+
this.handleDownPan(e.touches[0].clientX, e.touches[0].clientY);
|
|
606
|
+
} else {
|
|
607
|
+
const x = 0.5 * (e.touches[0].clientX + e.touches[1].clientX);
|
|
608
|
+
const y = 0.5 * (e.touches[0].clientY + e.touches[1].clientY);
|
|
609
|
+
this.handleDownPan(x, y);
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
private handleTouchMovePan(e: TouchEvent): void {
|
|
614
|
+
if (e.touches.length === 1) {
|
|
615
|
+
this.handleMovePan(e.touches[0].clientX, e.touches[0].clientY);
|
|
616
|
+
} else {
|
|
617
|
+
const x = 0.5 * (e.touches[0].clientX + e.touches[1].clientX);
|
|
618
|
+
const y = 0.5 * (e.touches[0].clientY + e.touches[1].clientY);
|
|
619
|
+
this.handleMovePan(x, y);
|
|
620
|
+
}
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
private handleDownPan(x: number, y: number): void {
|
|
624
|
+
this.panStart.set(x, y);
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
private handleMovePan(x: number, y: number): void {
|
|
628
|
+
this.panEnd.set(x, y);
|
|
629
|
+
this.panDelta.subVectors(this.panEnd, this.panStart).multiplyScalar(this.panSpeed);
|
|
630
|
+
|
|
631
|
+
this.handlePanDelta(this.panDelta.x, this.panDelta.y);
|
|
632
|
+
|
|
633
|
+
this.panStart.copy(this.panEnd);
|
|
634
|
+
}
|
|
635
|
+
|
|
636
|
+
private handlePanDelta(deltaX: number, deltaY: number): void {
|
|
637
|
+
if (!this.bindingView) return;
|
|
638
|
+
const { THREE } = Externals.getInstance();
|
|
639
|
+
const v = new THREE.Vector3();
|
|
640
|
+
// TODO: 这里需要处理为View的尺寸
|
|
641
|
+
const clientWidth = this.bindingView.getViewWidth();
|
|
642
|
+
const clientHeight = this.bindingView.getViewHeight();
|
|
643
|
+
let offsetX = 0;
|
|
644
|
+
let offsetY = 0;
|
|
645
|
+
if ((this.camera as NS_THREE.PerspectiveCamera).isPerspectiveCamera) {
|
|
646
|
+
const camera = this.camera as NS_THREE.PerspectiveCamera;
|
|
647
|
+
v.subVectors(this.target, this.camera.position);
|
|
648
|
+
|
|
649
|
+
let targetDistance = v.length();
|
|
650
|
+
|
|
651
|
+
targetDistance *= Math.tan((camera.fov / 2) * Math.PI / 180.0);
|
|
652
|
+
|
|
653
|
+
offsetX = 2 * deltaX * targetDistance / clientHeight;
|
|
654
|
+
offsetY = 2 * deltaY * targetDistance / clientHeight;
|
|
655
|
+
} else {
|
|
656
|
+
const camera = this.camera as NS_THREE.OrthographicCamera;
|
|
657
|
+
offsetX = deltaX * (camera.right - camera.left) / camera.zoom / clientWidth;
|
|
658
|
+
offsetY = deltaY * (camera.top - camera.bottom) / camera.zoom / clientHeight;
|
|
659
|
+
}
|
|
660
|
+
|
|
661
|
+
v.setFromMatrixColumn(this.camera.matrix, 0);
|
|
662
|
+
v.multiplyScalar(-offsetX);
|
|
663
|
+
this.panOffset.add(v);
|
|
664
|
+
|
|
665
|
+
if (this.screenSpacePanning) {
|
|
666
|
+
v.setFromMatrixColumn(this.camera.matrix, 1);
|
|
667
|
+
} else {
|
|
668
|
+
v.setFromMatrixColumn(this.camera.matrix, 0);
|
|
669
|
+
v.crossVectors(this.camera.up, v);
|
|
670
|
+
}
|
|
671
|
+
|
|
672
|
+
v.multiplyScalar(offsetY);
|
|
673
|
+
this.panOffset.add(v);
|
|
674
|
+
}
|
|
675
|
+
|
|
676
|
+
private handleUpPan(): void {
|
|
677
|
+
if (!this.panInertiaEnabled) return;
|
|
678
|
+
|
|
679
|
+
const timeElapsed = this.timeStart - this.timeEnd;
|
|
680
|
+
const speed = this.panDelta.length() * 10 * this.panSpeed / timeElapsed;
|
|
681
|
+
|
|
682
|
+
if (timeElapsed === 0 || !Number.isFinite(speed)) return;
|
|
683
|
+
|
|
684
|
+
if (Number.isFinite(speed) && speed > 1) {
|
|
685
|
+
this.panInertiaBase = speed * this.inertiaFactor;
|
|
686
|
+
this.panInertiaDuration = 0;
|
|
687
|
+
this.panInertiaDirection = this.panDelta.clone().normalize();
|
|
688
|
+
this.panInertia = this.panInertiaBase;
|
|
689
|
+
}
|
|
690
|
+
}
|
|
691
|
+
|
|
692
|
+
private handleMouseWheel(e: WheelEvent): void {
|
|
693
|
+
this.zoomDelta = e.deltaY / 67;
|
|
694
|
+
this.mouseXY.set(e.offsetX, e.offsetY);
|
|
695
|
+
// console.log(e);
|
|
696
|
+
}
|
|
697
|
+
|
|
698
|
+
private handleZoom(delta: number): void {
|
|
699
|
+
if (Math.abs(delta) < 0.0001) return;
|
|
700
|
+
let zoomChange = 0;
|
|
701
|
+
let lastPos: NS_THREE.Vector3|null = null;
|
|
702
|
+
if (this.followMouse) {
|
|
703
|
+
lastPos = BasicTools.getHorizontalPlaneCoordinate3(
|
|
704
|
+
{ x: this.mouseXY.x, y: this.mouseXY.y }, this.bindingView!, this.camera,
|
|
705
|
+
);
|
|
706
|
+
}
|
|
707
|
+
// eslint-disable-next-line no-param-reassign
|
|
708
|
+
delta *= this.zoomScale;
|
|
709
|
+
if (this.zoomMode === 'zoom') {
|
|
710
|
+
const tZoom = Math.min(
|
|
711
|
+
Math.max(this.camera.zoom * (1 + delta), this.zoomRange.min),
|
|
712
|
+
this.zoomRange.max,
|
|
713
|
+
);
|
|
714
|
+
zoomChange = tZoom - this.camera.zoom;
|
|
715
|
+
this.camera.zoom = tZoom;
|
|
716
|
+
} else if ((this.camera as NS_THREE.PerspectiveCamera).isPerspectiveCamera) {
|
|
717
|
+
const camera = this.camera as NS_THREE.PerspectiveCamera;
|
|
718
|
+
camera.fov = Math.min(
|
|
719
|
+
Math.max(camera.fov + delta * 66.67, this.fovRange.min),
|
|
720
|
+
this.fovRange.max,
|
|
721
|
+
);
|
|
722
|
+
}
|
|
723
|
+
|
|
724
|
+
this.camera.updateProjectionMatrix();
|
|
725
|
+
this.needUpdate = true;
|
|
726
|
+
this.emit(Events.CAMERA_ZOOM,
|
|
727
|
+
this.zoomMode,
|
|
728
|
+
this.zoomMode === 'zoom' ? this.camera.zoom : (this.camera as NS_THREE.PerspectiveCamera).fov,
|
|
729
|
+
this);
|
|
730
|
+
|
|
731
|
+
if (this.followMouse && zoomChange && this.bindingView) {
|
|
732
|
+
const nowPos = BasicTools.getHorizontalPlaneCoordinate3(
|
|
733
|
+
{ x: this.mouseXY.x, y: this.mouseXY.y }, this.bindingView!, this.camera,
|
|
734
|
+
);
|
|
735
|
+
if (lastPos! && nowPos) {
|
|
736
|
+
const vector = nowPos.clone().sub(lastPos!);
|
|
737
|
+
this.setCameraPosition(this.camera.position.clone().sub(vector), true);
|
|
738
|
+
}
|
|
739
|
+
}
|
|
740
|
+
}
|
|
741
|
+
|
|
742
|
+
private handleUpZoom(): void {
|
|
743
|
+
if (!this.zoomInertiaEnabled) return;
|
|
744
|
+
|
|
745
|
+
const timeElapsed = this.timeStart - this.timeEnd;
|
|
746
|
+
const speed = this.zoomDelta / timeElapsed;
|
|
747
|
+
|
|
748
|
+
if (timeElapsed === 0 || !Number.isFinite(speed)) return;
|
|
749
|
+
|
|
750
|
+
if (Math.abs(speed) > 0.001) {
|
|
751
|
+
this.zoomInertiaBase = speed * this.inertiaFactor * 2;
|
|
752
|
+
this.zoomInertiaDuration = 0;
|
|
753
|
+
this.zoomInertia = this.zoomInertiaBase;
|
|
754
|
+
}
|
|
755
|
+
}
|
|
756
|
+
|
|
757
|
+
private handleMouseDownDolly(e: MouseEvent): void {
|
|
758
|
+
this.dollyStart.set(e.offsetX, e.offsetY);
|
|
759
|
+
}
|
|
760
|
+
|
|
761
|
+
private handleMouseMoveDolly(e: MouseEvent): void {
|
|
762
|
+
this.dollyEnd.set(e.offsetX, e.offsetY);
|
|
763
|
+
|
|
764
|
+
const sign = -Math.sign(this.dollyEnd.y - this.dollyStart.y);
|
|
765
|
+
const distance = this.dollyStart.distanceTo(this.dollyEnd);
|
|
766
|
+
|
|
767
|
+
// const { innerWidth, innerHeight } = window;
|
|
768
|
+
// const diagonalDist = Math.sqrt((innerWidth ** 2) + (innerHeight ** 2));
|
|
769
|
+
const clientWidth = this.bindingView!.getViewWidth();
|
|
770
|
+
const clientHeight = this.bindingView!.getViewHeight();
|
|
771
|
+
const diagonalDist = Math.sqrt((clientWidth ** 2) + (clientHeight ** 2));
|
|
772
|
+
const distRatio = distance / diagonalDist;
|
|
773
|
+
|
|
774
|
+
this.zoomDelta = sign * Math.floor(distRatio * diagonalDist) * EnvironmentUtils.GetGlobalDPR();
|
|
775
|
+
|
|
776
|
+
this.dollyStart.copy(this.dollyEnd);
|
|
777
|
+
}
|
|
778
|
+
|
|
779
|
+
private handleTouchStartDolly(e: TouchEvent): void {
|
|
780
|
+
const dx = e.touches[0].clientX - e.touches[1].clientX;
|
|
781
|
+
const dy = e.touches[0].clientY - e.touches[1].clientY;
|
|
782
|
+
|
|
783
|
+
const distance = Math.sqrt(dx * dx + dy * dy);
|
|
784
|
+
|
|
785
|
+
this.dollyStart.set(0, distance);
|
|
786
|
+
}
|
|
787
|
+
|
|
788
|
+
private handleTouchMoveDolly(e: TouchEvent): void {
|
|
789
|
+
if (!this.bindingView) return;
|
|
790
|
+
const dx = e.touches[0].clientX - e.touches[1].clientX;
|
|
791
|
+
const dy = e.touches[0].clientY - e.touches[1].clientY;
|
|
792
|
+
|
|
793
|
+
const distance = Math.sqrt(dx * dx + dy * dy);
|
|
794
|
+
|
|
795
|
+
this.dollyEnd.set(0, distance);
|
|
796
|
+
|
|
797
|
+
// let innerWidth = 0;
|
|
798
|
+
// let innerHeight = 0;
|
|
799
|
+
// if (EnvironmentUtils.GetEnv() !== Env.Miniapp) {
|
|
800
|
+
// innerWidth = window.innerWidth;
|
|
801
|
+
// innerHeight = window.innerWidth;
|
|
802
|
+
// } else {
|
|
803
|
+
// innerWidth = this.bindingView.canvas.clientWidth;
|
|
804
|
+
// innerHeight = this.bindingView.canvas.clientHeight;
|
|
805
|
+
// }
|
|
806
|
+
const innerWidth = this.bindingView.canvas.clientWidth;
|
|
807
|
+
const innerHeight = this.bindingView.canvas.clientHeight;
|
|
808
|
+
const diagonalDist = Math.sqrt((innerWidth ** 2) + (innerHeight ** 2));
|
|
809
|
+
const distRatio = (distance - this.dollyStart.y) / diagonalDist;
|
|
810
|
+
|
|
811
|
+
this.zoomDelta = -distRatio;
|
|
812
|
+
|
|
813
|
+
let d = 1 + Math.abs(this.zoomDelta);
|
|
814
|
+
if (this.zoomDelta > 0) d = 1 / d;
|
|
815
|
+
this.zoomDelta = d - 1;
|
|
816
|
+
this.zoomDelta *= 2;
|
|
817
|
+
|
|
818
|
+
const cameraCenter = this.touchCenter.clone().set(
|
|
819
|
+
// TODO: 这里需要处理为View的尺寸
|
|
820
|
+
this.bindingView.getViewWidth() / 2,
|
|
821
|
+
this.bindingView.getViewHeight() / 2,
|
|
822
|
+
);
|
|
823
|
+
const zoomPanDelta = this.touchCenter.clone().sub(cameraCenter).multiplyScalar(-this.zoomDelta);
|
|
824
|
+
|
|
825
|
+
this.mouseXY.set(this.touchCenter.x, this.touchCenter.y);
|
|
826
|
+
this.zoomDelta *= EnvironmentUtils.GetGlobalDPR();
|
|
827
|
+
|
|
828
|
+
this.handlePanDelta(zoomPanDelta.x, zoomPanDelta.y);
|
|
829
|
+
|
|
830
|
+
this.dollyStart.copy(this.dollyEnd);
|
|
831
|
+
}
|
|
832
|
+
|
|
833
|
+
private handleTouchStartDollyRotate(e: TouchEvent): void {
|
|
834
|
+
if (this.enableZoom) this.handleTouchStartDolly(e);
|
|
835
|
+
if (this.enableRotate) this.handleTouchStartRotate(e);
|
|
836
|
+
}
|
|
837
|
+
|
|
838
|
+
private handleTouchMoveDollyRotate(e: TouchEvent): void {
|
|
839
|
+
if (this.enableZoom) this.handleTouchMoveDolly(e);
|
|
840
|
+
if (this.enableRotate) this.handleTouchMoveSelfRotate(e);
|
|
841
|
+
}
|
|
842
|
+
|
|
843
|
+
private handleTouchStartDollyPan(e: TouchEvent): void {
|
|
844
|
+
if (this.enableZoom) this.handleTouchStartDolly(e);
|
|
845
|
+
if (this.enablePan) this.handleTouchStartPan(e);
|
|
846
|
+
}
|
|
847
|
+
|
|
848
|
+
private handleTouchMoveDollyPan(e: TouchEvent): void {
|
|
849
|
+
if (this.enableZoom) this.handleTouchMoveDolly(e);
|
|
850
|
+
if (this.enablePan) this.handleTouchMovePan(e);
|
|
851
|
+
}
|
|
852
|
+
|
|
853
|
+
private handleTouchStartMap(e: TouchEvent): void {
|
|
854
|
+
if (this.enableZoom) this.handleTouchStartDolly(e);
|
|
855
|
+
if (this.enablePan) this.handleTouchStartPan(e);
|
|
856
|
+
if (this.enableRotate) this.handleTouchStartRotate(e);
|
|
857
|
+
}
|
|
858
|
+
|
|
859
|
+
private handleTouchMoveAll(e: TouchEvent): void {
|
|
860
|
+
if (this.enableZoom) this.handleTouchMoveDolly(e);
|
|
861
|
+
if (this.enablePan) this.handleTouchMovePan(e);
|
|
862
|
+
if (this.enableRotate) this.handleTouchMoveSelfRotate(e);
|
|
863
|
+
}
|
|
864
|
+
|
|
865
|
+
private handleUpAll(): void {
|
|
866
|
+
this.handleUpZoom();
|
|
867
|
+
this.handleUpPan();
|
|
868
|
+
this.handleUpRotate();
|
|
869
|
+
}
|
|
870
|
+
|
|
871
|
+
private resetVectors(): void {
|
|
872
|
+
this.panInertiaBase = 0;
|
|
873
|
+
this.panInertia = 0;
|
|
874
|
+
this.panDelta.set(0, 0);
|
|
875
|
+
this.rotateInertiaBase = 0;
|
|
876
|
+
this.rotateInertia = 0;
|
|
877
|
+
this.rotateDelta.set(0, 0);
|
|
878
|
+
}
|
|
879
|
+
|
|
880
|
+
/* Camera Movement */
|
|
881
|
+
|
|
882
|
+
/** @ignore 暂缓开放 */
|
|
883
|
+
public async moveCameraTo(
|
|
884
|
+
position: NS_THREE.Vector3,
|
|
885
|
+
duration = 1000,
|
|
886
|
+
callbacks?: {
|
|
887
|
+
onUpdate?: (progress: number) => void;
|
|
888
|
+
},
|
|
889
|
+
): Promise<void> {
|
|
890
|
+
return new Promise((resolve) => {
|
|
891
|
+
const { THREE } = Externals.getInstance();
|
|
892
|
+
const from = this.camera.position.clone();
|
|
893
|
+
const positionVector = new THREE.Vector3();
|
|
894
|
+
|
|
895
|
+
const cb = callbacks || {};
|
|
896
|
+
|
|
897
|
+
new TWEEN.Tween({ progress: 0 })
|
|
898
|
+
.to({ progress: 1 }, duration)
|
|
899
|
+
.easing(TWEEN.Easing.Quadratic.InOut)
|
|
900
|
+
.onUpdate(
|
|
901
|
+
(
|
|
902
|
+
{ progress }: { progress: number },
|
|
903
|
+
) => {
|
|
904
|
+
positionVector.lerpVectors(from, position, progress);
|
|
905
|
+
this.camera.position.copy(positionVector);
|
|
906
|
+
|
|
907
|
+
if (cb.onUpdate) cb.onUpdate(progress);
|
|
908
|
+
|
|
909
|
+
this.needUpdate = true;
|
|
910
|
+
},
|
|
911
|
+
)
|
|
912
|
+
.onComplete(() => {
|
|
913
|
+
resolve();
|
|
914
|
+
})
|
|
915
|
+
.start();
|
|
916
|
+
});
|
|
917
|
+
}
|
|
918
|
+
|
|
919
|
+
/* Getter & Setters */
|
|
920
|
+
|
|
921
|
+
/**
|
|
922
|
+
* 设置相机位置坐标
|
|
923
|
+
* @param position 位置坐标
|
|
924
|
+
* @param updateTarget 是否更新目标点坐标, 默认为true
|
|
925
|
+
*/
|
|
926
|
+
public setCameraPosition(position: NS_THREE.Vector3, updateTarget = true): void {
|
|
927
|
+
const { THREE } = Externals.getInstance();
|
|
928
|
+
const lookAtVector = new THREE.Vector3().subVectors(this.target, this.camera.position);
|
|
929
|
+
this.camera.position.copy(position);
|
|
930
|
+
if (updateTarget) this.target.copy(position.clone().add(lookAtVector));
|
|
931
|
+
this.needUpdate = true;
|
|
932
|
+
}
|
|
933
|
+
|
|
934
|
+
/**
|
|
935
|
+
* 获取相机位置坐标
|
|
936
|
+
*/
|
|
937
|
+
public getCameraPosition(): NS_THREE.Vector3 {
|
|
938
|
+
return this.camera.position.clone();
|
|
939
|
+
}
|
|
940
|
+
|
|
941
|
+
/**
|
|
942
|
+
* 设置当前相机看向目标位置
|
|
943
|
+
* @param target 目标点坐标
|
|
944
|
+
* @param updateCameraPosition 是否同步更新相机位置, 默认值为false
|
|
945
|
+
*/
|
|
946
|
+
public setCameraLookAt(target: NS_THREE.Vector3, updateCameraPosition = false): void {
|
|
947
|
+
const { THREE } = Externals.getInstance();
|
|
948
|
+
const lookAtVector = new THREE.Vector3().subVectors(this.camera.position, this.target);
|
|
949
|
+
this.target.copy(target);
|
|
950
|
+
if (updateCameraPosition) this.camera.position.copy(target.clone().add(lookAtVector));
|
|
951
|
+
this.camera.lookAt(target);
|
|
952
|
+
this.needUpdate = true;
|
|
953
|
+
}
|
|
954
|
+
|
|
955
|
+
/**
|
|
956
|
+
* 获取相机看向目标位置
|
|
957
|
+
* @returns vec3
|
|
958
|
+
*/
|
|
959
|
+
public getCameraTarget(): NS_THREE.Vector3 {
|
|
960
|
+
return this.target.clone();
|
|
961
|
+
}
|
|
962
|
+
|
|
963
|
+
/**
|
|
964
|
+
* 设置当前相机视线方向
|
|
965
|
+
* @param direction 方向向量
|
|
966
|
+
* @param distance 目标距离, 默认值为1
|
|
967
|
+
*/
|
|
968
|
+
public setCameraLookAtVector(direction: NS_THREE.Vector3, distance = 1): void {
|
|
969
|
+
this.setCameraLookAt(this.camera.position.clone().add(direction.normalize().multiplyScalar(distance)));
|
|
970
|
+
}
|
|
971
|
+
|
|
972
|
+
/**
|
|
973
|
+
* 设置是否开启阻尼
|
|
974
|
+
* @param enable 布尔值
|
|
975
|
+
*/
|
|
976
|
+
public setDampingEnabled(enable: boolean): void {
|
|
977
|
+
this.enableDamping = enable;
|
|
978
|
+
}
|
|
979
|
+
|
|
980
|
+
/**
|
|
981
|
+
* 设置阻尼系数, 默认值为0
|
|
982
|
+
* @param factor 阻尼系数
|
|
983
|
+
*/
|
|
984
|
+
public setDampingFactor(factor: number): void {
|
|
985
|
+
this.dampingFactor = factor;
|
|
986
|
+
}
|
|
987
|
+
|
|
988
|
+
/**
|
|
989
|
+
* 获取阻尼系数
|
|
990
|
+
*/
|
|
991
|
+
public getDampingFactor(): number {
|
|
992
|
+
return this.dampingFactor;
|
|
993
|
+
}
|
|
994
|
+
|
|
995
|
+
/**
|
|
996
|
+
* 设置是否激活缩放
|
|
997
|
+
* @param enable 布尔值
|
|
998
|
+
*/
|
|
999
|
+
public setZoomEnabled(enable: boolean): void {
|
|
1000
|
+
this.enableZoom = enable;
|
|
1001
|
+
}
|
|
1002
|
+
|
|
1003
|
+
/**
|
|
1004
|
+
* 设置放大模式, 可选值: 'zoom': 使用变焦放大, 'fov': 使用fov放大
|
|
1005
|
+
* @param mode 放大模式
|
|
1006
|
+
*/
|
|
1007
|
+
public setZoomMode(mode: 'zoom' | 'fov'): void {
|
|
1008
|
+
if ((this.camera as NS_THREE.OrthographicCamera).isOrthographicCamera && mode === 'fov') {
|
|
1009
|
+
throw new Error('[BasicController] Cannot use fov zoom mode for OrthographicCamera');
|
|
1010
|
+
}
|
|
1011
|
+
this.zoomMode = mode;
|
|
1012
|
+
}
|
|
1013
|
+
|
|
1014
|
+
/**
|
|
1015
|
+
* 设置相机fov范围, 默认值为[60, 90]
|
|
1016
|
+
* @param min 最小值
|
|
1017
|
+
* @param max 最大值
|
|
1018
|
+
*/
|
|
1019
|
+
public setFovRange(min: number, max: number): void {
|
|
1020
|
+
this.fovRange.min = min;
|
|
1021
|
+
this.fovRange.max = max;
|
|
1022
|
+
|
|
1023
|
+
if (!(this.camera as NS_THREE.PerspectiveCamera).isPerspectiveCamera) return;
|
|
1024
|
+
|
|
1025
|
+
const camera = this.camera as NS_THREE.PerspectiveCamera;
|
|
1026
|
+
|
|
1027
|
+
camera.fov = Math.min(
|
|
1028
|
+
Math.max(camera.fov, this.fovRange.min),
|
|
1029
|
+
this.fovRange.max,
|
|
1030
|
+
);
|
|
1031
|
+
camera.updateProjectionMatrix();
|
|
1032
|
+
this.needUpdate = true;
|
|
1033
|
+
}
|
|
1034
|
+
|
|
1035
|
+
/**
|
|
1036
|
+
* 设置当前相机fov, 仅限透视投影相机使用
|
|
1037
|
+
* @param fov FOV值
|
|
1038
|
+
*/
|
|
1039
|
+
public setFov(fov: number): void {
|
|
1040
|
+
if (!(this.camera as NS_THREE.PerspectiveCamera).isPerspectiveCamera) return;
|
|
1041
|
+
|
|
1042
|
+
const camera = this.camera as NS_THREE.PerspectiveCamera;
|
|
1043
|
+
|
|
1044
|
+
camera.fov = Math.min(
|
|
1045
|
+
Math.max(fov, this.fovRange.min),
|
|
1046
|
+
this.fovRange.max,
|
|
1047
|
+
);
|
|
1048
|
+
camera.updateProjectionMatrix();
|
|
1049
|
+
this.needUpdate = true;
|
|
1050
|
+
}
|
|
1051
|
+
|
|
1052
|
+
/**
|
|
1053
|
+
* 获取当前相机fov, 仅限透视投影相机使用
|
|
1054
|
+
*/
|
|
1055
|
+
public getFov(): number | null {
|
|
1056
|
+
if (!(this.camera as NS_THREE.PerspectiveCamera).isPerspectiveCamera) return null;
|
|
1057
|
+
return (this.camera as NS_THREE.PerspectiveCamera).fov;
|
|
1058
|
+
}
|
|
1059
|
+
|
|
1060
|
+
/**
|
|
1061
|
+
* 设置变焦倍数范围, 默认值为[0, 10]
|
|
1062
|
+
* @param min 最小值
|
|
1063
|
+
* @param max 最大值
|
|
1064
|
+
*/
|
|
1065
|
+
public setZoomRange(min: number, max: number): void {
|
|
1066
|
+
this.zoomRange.min = min;
|
|
1067
|
+
this.zoomRange.max = max;
|
|
1068
|
+
|
|
1069
|
+
this.camera.zoom = Math.min(
|
|
1070
|
+
Math.max(this.camera.zoom, this.zoomRange.min),
|
|
1071
|
+
this.zoomRange.max,
|
|
1072
|
+
);
|
|
1073
|
+
this.camera.updateProjectionMatrix();
|
|
1074
|
+
this.needUpdate = true;
|
|
1075
|
+
}
|
|
1076
|
+
|
|
1077
|
+
/**
|
|
1078
|
+
* 设置当前变焦倍数, 倍数受倍数范围影响
|
|
1079
|
+
* @param zoom 变焦倍数
|
|
1080
|
+
*/
|
|
1081
|
+
public setZoom(zoom: number): void {
|
|
1082
|
+
this.camera.zoom = Math.min(
|
|
1083
|
+
Math.max(zoom, this.zoomRange.min),
|
|
1084
|
+
this.zoomRange.max,
|
|
1085
|
+
);
|
|
1086
|
+
this.camera.updateProjectionMatrix();
|
|
1087
|
+
this.needUpdate = true;
|
|
1088
|
+
}
|
|
1089
|
+
|
|
1090
|
+
/**
|
|
1091
|
+
* 获取当前变焦倍数
|
|
1092
|
+
*/
|
|
1093
|
+
public getZoom(): number {
|
|
1094
|
+
return this.camera.zoom;
|
|
1095
|
+
}
|
|
1096
|
+
|
|
1097
|
+
/**
|
|
1098
|
+
* 设置是否激活变焦的惯性
|
|
1099
|
+
* @param enabled 布尔值
|
|
1100
|
+
*/
|
|
1101
|
+
public setZoomInertiaEnabled(enabled: boolean): void {
|
|
1102
|
+
this.zoomInertiaEnabled = enabled;
|
|
1103
|
+
}
|
|
1104
|
+
|
|
1105
|
+
/**
|
|
1106
|
+
* 设置是否激活旋转
|
|
1107
|
+
* @param enable 布尔值
|
|
1108
|
+
*/
|
|
1109
|
+
public setRotateEnabled(enable: boolean): void {
|
|
1110
|
+
this.enableRotate = enable;
|
|
1111
|
+
}
|
|
1112
|
+
|
|
1113
|
+
/**
|
|
1114
|
+
* 设置旋转模式, 可选值 'self':自转, 'orbit': 公转
|
|
1115
|
+
* @param mode 旋转模式
|
|
1116
|
+
*/
|
|
1117
|
+
public setRotateMode(mode: 'self' | 'orbit'): void {
|
|
1118
|
+
this.rotateMode = mode;
|
|
1119
|
+
}
|
|
1120
|
+
|
|
1121
|
+
/**
|
|
1122
|
+
* 设置旋转速度
|
|
1123
|
+
* @param speed 旋转速度倍数
|
|
1124
|
+
*/
|
|
1125
|
+
public setRotateSpeed(speed: number): void {
|
|
1126
|
+
this.rotateSpeed = speed;
|
|
1127
|
+
}
|
|
1128
|
+
|
|
1129
|
+
/**
|
|
1130
|
+
* 获取旋转速度
|
|
1131
|
+
*/
|
|
1132
|
+
public getRotateSpeed(): number {
|
|
1133
|
+
return this.rotateSpeed;
|
|
1134
|
+
}
|
|
1135
|
+
|
|
1136
|
+
/**
|
|
1137
|
+
* 设置是否激活旋转运动的惯性
|
|
1138
|
+
* @param enabled 布尔值
|
|
1139
|
+
*/
|
|
1140
|
+
public setRotateInertiaEnabled(enabled: boolean): void {
|
|
1141
|
+
this.rotateInertiaEnabled = enabled;
|
|
1142
|
+
}
|
|
1143
|
+
|
|
1144
|
+
/**
|
|
1145
|
+
* 设置横向转动角度
|
|
1146
|
+
* @param azimuth 弧度
|
|
1147
|
+
*/
|
|
1148
|
+
public setAzimuthAngle(azimuth: number): void {
|
|
1149
|
+
const { THREE } = Externals.getInstance();
|
|
1150
|
+
const quat = new THREE.Quaternion().setFromUnitVectors(this.camera.up, new THREE.Vector3(0, 1, 0));
|
|
1151
|
+
const quatInverse = quat.clone().invert();
|
|
1152
|
+
const lookAtVector = new THREE.Vector3().subVectors(this.target, this.camera.position);
|
|
1153
|
+
|
|
1154
|
+
if (this.rotateMode === 'orbit') lookAtVector.multiplyScalar(-1);
|
|
1155
|
+
|
|
1156
|
+
lookAtVector.applyQuaternion(quat);
|
|
1157
|
+
this.spherical.setFromVector3(lookAtVector);
|
|
1158
|
+
|
|
1159
|
+
this.spherical.theta = azimuth;
|
|
1160
|
+
|
|
1161
|
+
this.spherical.makeSafe();
|
|
1162
|
+
|
|
1163
|
+
lookAtVector.setFromSpherical(this.spherical);
|
|
1164
|
+
lookAtVector.applyQuaternion(quatInverse);
|
|
1165
|
+
|
|
1166
|
+
if (this.rotateMode === 'self') {
|
|
1167
|
+
this.target.copy(this.camera.position.clone().add(lookAtVector));
|
|
1168
|
+
} else {
|
|
1169
|
+
this.camera.position.copy(this.target.clone().add(lookAtVector));
|
|
1170
|
+
}
|
|
1171
|
+
|
|
1172
|
+
this.camera.lookAt(this.target);
|
|
1173
|
+
this.needUpdate = true;
|
|
1174
|
+
}
|
|
1175
|
+
|
|
1176
|
+
/**
|
|
1177
|
+
* 获取当前横向转动值, 范围区间为[-2 * PI, 2 * PI]
|
|
1178
|
+
*/
|
|
1179
|
+
public getAzimuthAngle(): number {
|
|
1180
|
+
return this.spherical.theta;
|
|
1181
|
+
}
|
|
1182
|
+
|
|
1183
|
+
/**
|
|
1184
|
+
* 设置纵向旋转角度
|
|
1185
|
+
* @param polar 弧度
|
|
1186
|
+
*/
|
|
1187
|
+
public setPolarAngle(polar: number): void {
|
|
1188
|
+
const { THREE } = Externals.getInstance();
|
|
1189
|
+
const quat = new THREE.Quaternion().setFromUnitVectors(this.camera.up, new THREE.Vector3(0, 1, 0));
|
|
1190
|
+
const quatInverse = quat.clone().invert();
|
|
1191
|
+
const lookAtVector = new THREE.Vector3().subVectors(this.target, this.camera.position);
|
|
1192
|
+
|
|
1193
|
+
if (this.rotateMode === 'orbit') lookAtVector.multiplyScalar(-1);
|
|
1194
|
+
|
|
1195
|
+
lookAtVector.applyQuaternion(quat);
|
|
1196
|
+
this.spherical.setFromVector3(lookAtVector);
|
|
1197
|
+
|
|
1198
|
+
this.spherical.phi = polar;
|
|
1199
|
+
|
|
1200
|
+
this.spherical.makeSafe();
|
|
1201
|
+
|
|
1202
|
+
lookAtVector.setFromSpherical(this.spherical);
|
|
1203
|
+
lookAtVector.applyQuaternion(quatInverse);
|
|
1204
|
+
|
|
1205
|
+
if (this.rotateMode === 'self') {
|
|
1206
|
+
this.target.copy(this.camera.position.clone().add(lookAtVector));
|
|
1207
|
+
} else {
|
|
1208
|
+
this.camera.position.copy(this.target.clone().add(lookAtVector));
|
|
1209
|
+
}
|
|
1210
|
+
|
|
1211
|
+
this.camera.lookAt(this.target);
|
|
1212
|
+
this.needUpdate = true;
|
|
1213
|
+
}
|
|
1214
|
+
|
|
1215
|
+
/**
|
|
1216
|
+
* 获取当前纵向转动值
|
|
1217
|
+
*/
|
|
1218
|
+
public getPolarAngle(): number {
|
|
1219
|
+
return this.spherical.phi;
|
|
1220
|
+
}
|
|
1221
|
+
|
|
1222
|
+
/**
|
|
1223
|
+
* 设置横向转动范围, 范围区间为[-2 * PI, 2 * PI]
|
|
1224
|
+
* @param min 最小值
|
|
1225
|
+
* @param max 最大值
|
|
1226
|
+
*/
|
|
1227
|
+
public setAzimuthRange(min: number, max: number): void {
|
|
1228
|
+
this.minSpherical.theta = min;
|
|
1229
|
+
this.maxSpherical.theta = max;
|
|
1230
|
+
}
|
|
1231
|
+
|
|
1232
|
+
/**
|
|
1233
|
+
* 设置纵向旋转范围, 范围区间为[0, PI]
|
|
1234
|
+
* @param min 最小值
|
|
1235
|
+
* @param max 最大值
|
|
1236
|
+
*/
|
|
1237
|
+
public setPolarRange(min: number, max: number): void {
|
|
1238
|
+
this.minSpherical.phi = min;
|
|
1239
|
+
this.maxSpherical.phi = max;
|
|
1240
|
+
}
|
|
1241
|
+
|
|
1242
|
+
/**
|
|
1243
|
+
* 设置是否激活摇镜运动的惯性
|
|
1244
|
+
* @param enabled 布尔值
|
|
1245
|
+
*/
|
|
1246
|
+
public setPanInertiaEnabled(enabled: boolean): void {
|
|
1247
|
+
this.panInertiaEnabled = enabled;
|
|
1248
|
+
}
|
|
1249
|
+
|
|
1250
|
+
/**
|
|
1251
|
+
* 设置惯性系数
|
|
1252
|
+
* @param factor 惯性系数
|
|
1253
|
+
*/
|
|
1254
|
+
public setInertiaFactor(factor: number): void {
|
|
1255
|
+
this.inertiaFactor = factor;
|
|
1256
|
+
}
|
|
1257
|
+
|
|
1258
|
+
/**
|
|
1259
|
+
* 设置是否激活摇镜(移动)
|
|
1260
|
+
* @param enable 布尔值
|
|
1261
|
+
*/
|
|
1262
|
+
public setPanEnabled(enable: boolean): void {
|
|
1263
|
+
this.enablePan = enable;
|
|
1264
|
+
}
|
|
1265
|
+
|
|
1266
|
+
/**
|
|
1267
|
+
* 设置摇镜操作是否跟随屏幕空间朝向
|
|
1268
|
+
* @param enabled 布尔值
|
|
1269
|
+
*/
|
|
1270
|
+
public setScreenSpacePanning(enabled: boolean): void {
|
|
1271
|
+
this.screenSpacePanning = enabled;
|
|
1272
|
+
}
|
|
1273
|
+
|
|
1274
|
+
/**
|
|
1275
|
+
* 设置鼠标操作关联
|
|
1276
|
+
* @param mouseButtons 鼠标操作关联
|
|
1277
|
+
*/
|
|
1278
|
+
public setMouseButtons(mouseButtons: MouseButtons): void {
|
|
1279
|
+
this.mouseButtons = mouseButtons;
|
|
1280
|
+
}
|
|
1281
|
+
|
|
1282
|
+
/**
|
|
1283
|
+
* 设置触摸操作关联
|
|
1284
|
+
* @param touches 触摸操作关联
|
|
1285
|
+
*/
|
|
1286
|
+
public setTouches(touches: Touches): void {
|
|
1287
|
+
this.touches = touches;
|
|
1288
|
+
}
|
|
1289
|
+
|
|
1290
|
+
/**
|
|
1291
|
+
* 设置是否限制相机运动范围
|
|
1292
|
+
* @param enable 是否限制
|
|
1293
|
+
*/
|
|
1294
|
+
public setBoundaryEnabled(enable: boolean): void {
|
|
1295
|
+
this.boundaryEnabled = enable;
|
|
1296
|
+
}
|
|
1297
|
+
|
|
1298
|
+
/**
|
|
1299
|
+
* 设置相机运动范围, 范围是一个包围盒, 使用最小值点与最大值点描述
|
|
1300
|
+
* @param min 包围盒最小值点坐标, 默认值为无限小
|
|
1301
|
+
* @param max 包围盒最大值点坐标, 默认值为无限大
|
|
1302
|
+
*/
|
|
1303
|
+
public setBoundary(min: NS_THREE.Vector3, max: NS_THREE.Vector3): void {
|
|
1304
|
+
this.boundary.set(min, max);
|
|
1305
|
+
}
|
|
1306
|
+
|
|
1307
|
+
/**
|
|
1308
|
+
* 设置BasicController是否激活可用
|
|
1309
|
+
* @param enabled 是否激活
|
|
1310
|
+
*/
|
|
1311
|
+
public setEnabled(enabled: boolean): void {
|
|
1312
|
+
if (enabled === this.enabled) return;
|
|
1313
|
+
this.enabled = enabled;
|
|
1314
|
+
if (enabled) {
|
|
1315
|
+
this.registerEvents();
|
|
1316
|
+
} else {
|
|
1317
|
+
this.unregisterEvents();
|
|
1318
|
+
this.resetVectors();
|
|
1319
|
+
}
|
|
1320
|
+
}
|
|
1321
|
+
|
|
1322
|
+
/**
|
|
1323
|
+
* 获取当前激活状态
|
|
1324
|
+
*/
|
|
1325
|
+
public getEnabled(): boolean {
|
|
1326
|
+
return this.enabled;
|
|
1327
|
+
}
|
|
1328
|
+
|
|
1329
|
+
/** @ignore */
|
|
1330
|
+
bindView(view: PerspectiveView | OrthographicView): void { // OrthographicView |
|
|
1331
|
+
this.unbindView();
|
|
1332
|
+
if (!view.container && !view.canvas) {
|
|
1333
|
+
throw new Error('View needed initialized with an HTML container or Canvas');
|
|
1334
|
+
}
|
|
1335
|
+
if (!view.camera) throw new Error('[BasicController] View for basic controller should have a camera.');
|
|
1336
|
+
if (
|
|
1337
|
+
!(view.camera as NS_THREE.PerspectiveCamera).isPerspectiveCamera
|
|
1338
|
+
&& !(view.camera as NS_THREE.OrthographicCamera).isOrthographicCamera
|
|
1339
|
+
) {
|
|
1340
|
+
throw new Error('[BasicController] Only supports PerspectiveCamera or OrthographicCamera.');
|
|
1341
|
+
}
|
|
1342
|
+
const { THREE } = Externals.getInstance();
|
|
1343
|
+
this.camera = view.camera;
|
|
1344
|
+
this.bindingView = view;
|
|
1345
|
+
this.target = new THREE.Vector3(0, 0, -1).applyQuaternion(this.camera.quaternion);
|
|
1346
|
+
this.registerEvents();
|
|
1347
|
+
}
|
|
1348
|
+
|
|
1349
|
+
/** @ignore */
|
|
1350
|
+
update(): boolean {
|
|
1351
|
+
const now = Date.now();
|
|
1352
|
+
const timeElapsed = now - this.lastTick;
|
|
1353
|
+
this.lastTick = now;
|
|
1354
|
+
|
|
1355
|
+
const { THREE } = Externals.getInstance();
|
|
1356
|
+
const quat = new THREE.Quaternion().setFromUnitVectors(this.camera.up, new THREE.Vector3(0, 1, 0));
|
|
1357
|
+
const quatInverse = quat.clone().invert();
|
|
1358
|
+
|
|
1359
|
+
const lookAtVector = new THREE.Vector3().subVectors(this.target, this.camera.position);
|
|
1360
|
+
|
|
1361
|
+
if (this.rotateMode === 'orbit') lookAtVector.multiplyScalar(-1);
|
|
1362
|
+
|
|
1363
|
+
if (Math.abs(this.zoomInertiaBase) > 0 && this.zoomInertiaDuration < 600) {
|
|
1364
|
+
this.handleZoom(this.zoomInertia);
|
|
1365
|
+
|
|
1366
|
+
const q = this.zoomInertiaDuration / 600;
|
|
1367
|
+
this.zoomInertia = this.zoomInertiaBase * ((1 - q) ** 2);
|
|
1368
|
+
this.zoomInertia = Math.max(0, Math.abs(this.zoomInertia)) * Math.sign(this.zoomInertia);
|
|
1369
|
+
this.zoomInertiaDuration += timeElapsed;
|
|
1370
|
+
}
|
|
1371
|
+
|
|
1372
|
+
if (this.panInertiaBase > 0 && this.panInertiaDuration < 600) {
|
|
1373
|
+
const { x, y } = this.panInertiaDirection;
|
|
1374
|
+
this.handlePanDelta(x * this.panInertia, y * this.panInertia);
|
|
1375
|
+
|
|
1376
|
+
const q = this.panInertiaDuration / 600;
|
|
1377
|
+
this.panInertia = this.panInertiaBase * ((1 - q) ** 2);
|
|
1378
|
+
this.panInertia = Math.max(0, this.panInertia);
|
|
1379
|
+
this.panInertiaDuration += timeElapsed;
|
|
1380
|
+
}
|
|
1381
|
+
|
|
1382
|
+
if (this.rotateInertiaBase > 0 && this.rotateInertiaDuration < 600) {
|
|
1383
|
+
if (this.rotateInertiaType === 'normal') {
|
|
1384
|
+
const { x, y } = this.rotateInertiaDirection;
|
|
1385
|
+
this.handleRotateDelta(x * this.rotateInertia, y * this.rotateInertia);
|
|
1386
|
+
} else {
|
|
1387
|
+
this.handleRotateSphericalDelta(this.rotateInertia, 0);
|
|
1388
|
+
}
|
|
1389
|
+
const q = this.rotateInertiaDuration / 600;
|
|
1390
|
+
this.rotateInertia = this.rotateInertiaBase * ((1 - q) ** 2);
|
|
1391
|
+
this.rotateInertia = Math.max(0, this.rotateInertia);
|
|
1392
|
+
this.rotateInertiaDuration += timeElapsed;
|
|
1393
|
+
}
|
|
1394
|
+
|
|
1395
|
+
lookAtVector.applyQuaternion(quat);
|
|
1396
|
+
|
|
1397
|
+
this.spherical.setFromVector3(lookAtVector);
|
|
1398
|
+
|
|
1399
|
+
const sphericalDelta = this.sphericalDelta.clone();
|
|
1400
|
+
let { zoomDelta } = this;
|
|
1401
|
+
|
|
1402
|
+
if (this.enableDamping) {
|
|
1403
|
+
sphericalDelta.theta *= this.dampingFactor;
|
|
1404
|
+
sphericalDelta.phi *= this.dampingFactor;
|
|
1405
|
+
zoomDelta *= this.dampingFactor;
|
|
1406
|
+
}
|
|
1407
|
+
|
|
1408
|
+
this.spherical.theta += sphericalDelta.theta;
|
|
1409
|
+
this.spherical.phi += sphericalDelta.phi;
|
|
1410
|
+
|
|
1411
|
+
let { theta: minAzimuth } = this.minSpherical;
|
|
1412
|
+
let { theta: maxAzimuth } = this.maxSpherical;
|
|
1413
|
+
const twoPI = Math.PI * 2;
|
|
1414
|
+
|
|
1415
|
+
if (Number.isFinite(minAzimuth) && Number.isFinite(maxAzimuth)) {
|
|
1416
|
+
if (minAzimuth < -Math.PI) minAzimuth += twoPI;
|
|
1417
|
+
else if (minAzimuth > Math.PI) minAzimuth -= twoPI;
|
|
1418
|
+
|
|
1419
|
+
if (maxAzimuth < -Math.PI) maxAzimuth += twoPI;
|
|
1420
|
+
else if (maxAzimuth > Math.PI) maxAzimuth -= twoPI;
|
|
1421
|
+
|
|
1422
|
+
if (minAzimuth < maxAzimuth) {
|
|
1423
|
+
this.spherical.theta = Math.max(minAzimuth, Math.min(maxAzimuth, this.spherical.theta));
|
|
1424
|
+
} else {
|
|
1425
|
+
this.spherical.theta = (this.spherical.theta > (minAzimuth + maxAzimuth) / 2)
|
|
1426
|
+
? Math.max(minAzimuth, this.spherical.theta)
|
|
1427
|
+
: Math.min(maxAzimuth, this.spherical.theta);
|
|
1428
|
+
}
|
|
1429
|
+
}
|
|
1430
|
+
this.spherical.phi = Math.max(this.minSpherical.phi, Math.min(this.maxSpherical.phi, this.spherical.phi));
|
|
1431
|
+
|
|
1432
|
+
this.spherical.makeSafe();
|
|
1433
|
+
|
|
1434
|
+
lookAtVector.setFromSpherical(this.spherical);
|
|
1435
|
+
lookAtVector.applyQuaternion(quatInverse);
|
|
1436
|
+
|
|
1437
|
+
this.handleZoom(zoomDelta);
|
|
1438
|
+
|
|
1439
|
+
if (this.enableDamping) {
|
|
1440
|
+
if (this.rotateMode === 'self') this.camera.position.addScaledVector(this.panOffset, this.dampingFactor);
|
|
1441
|
+
else this.target.addScaledVector(this.panOffset, this.dampingFactor);
|
|
1442
|
+
} else {
|
|
1443
|
+
// eslint-disable-next-line no-lonely-if
|
|
1444
|
+
if (this.rotateMode === 'self') this.camera.position.add(this.panOffset);
|
|
1445
|
+
else this.target.add(this.panOffset);
|
|
1446
|
+
}
|
|
1447
|
+
|
|
1448
|
+
if (this.boundaryEnabled) {
|
|
1449
|
+
if (this.rotateMode === 'self') {
|
|
1450
|
+
this.camera.position.x = Math.min(this.boundary.max.x, Math.max(this.boundary.min.x, this.camera.position.x));
|
|
1451
|
+
this.camera.position.y = Math.min(this.boundary.max.y, Math.max(this.boundary.min.y, this.camera.position.y));
|
|
1452
|
+
this.camera.position.z = Math.min(this.boundary.max.z, Math.max(this.boundary.min.z, this.camera.position.z));
|
|
1453
|
+
} else {
|
|
1454
|
+
this.target.x = Math.min(this.boundary.max.x, Math.max(this.boundary.min.x, this.target.x));
|
|
1455
|
+
this.target.y = Math.min(this.boundary.max.y, Math.max(this.boundary.min.y, this.target.y));
|
|
1456
|
+
this.target.z = Math.min(this.boundary.max.z, Math.max(this.boundary.min.z, this.target.z));
|
|
1457
|
+
}
|
|
1458
|
+
}
|
|
1459
|
+
|
|
1460
|
+
if (this.rotateMode === 'self') {
|
|
1461
|
+
this.target.copy(this.camera.position.clone().add(lookAtVector));
|
|
1462
|
+
} else {
|
|
1463
|
+
this.camera.position.copy(this.target.clone().add(lookAtVector));
|
|
1464
|
+
}
|
|
1465
|
+
|
|
1466
|
+
this.camera.lookAt(this.target);
|
|
1467
|
+
|
|
1468
|
+
if (this.enableDamping) {
|
|
1469
|
+
this.sphericalDelta.theta *= (1 - this.dampingFactor);
|
|
1470
|
+
this.sphericalDelta.phi *= (1 - this.dampingFactor);
|
|
1471
|
+
this.panOffset.multiplyScalar(1 - this.dampingFactor);
|
|
1472
|
+
this.zoomDelta *= (1 - this.dampingFactor);
|
|
1473
|
+
} else {
|
|
1474
|
+
this.sphericalDelta.set(0, 0, 0);
|
|
1475
|
+
this.panOffset.set(0, 0, 0);
|
|
1476
|
+
this.zoomDelta = 0;
|
|
1477
|
+
}
|
|
1478
|
+
if (
|
|
1479
|
+
this.needUpdate
|
|
1480
|
+
|| this.lastPosition.distanceToSquared(this.camera.position) > EPS
|
|
1481
|
+
|| 8 * (1 - this.lastQuaternion.dot(this.camera.quaternion)) > EPS
|
|
1482
|
+
) {
|
|
1483
|
+
this.lastPosition.copy(this.camera.position);
|
|
1484
|
+
this.lastQuaternion.copy(this.camera.quaternion);
|
|
1485
|
+
this.needUpdate = false;
|
|
1486
|
+
this.emit(
|
|
1487
|
+
Events.CAMERA_CHANGED,
|
|
1488
|
+
this.camera.position.clone(),
|
|
1489
|
+
this.camera.quaternion.clone(),
|
|
1490
|
+
this,
|
|
1491
|
+
);
|
|
1492
|
+
return true;
|
|
1493
|
+
}
|
|
1494
|
+
return false;
|
|
1495
|
+
}
|
|
1496
|
+
|
|
1497
|
+
/** @ignore */
|
|
1498
|
+
unbind(): void {
|
|
1499
|
+
this.dispose();
|
|
1500
|
+
this.unbindView();
|
|
1501
|
+
}
|
|
1502
|
+
|
|
1503
|
+
unbindView(): void {
|
|
1504
|
+
this.unregisterEvents();
|
|
1505
|
+
this.bindingView = null;
|
|
1506
|
+
}
|
|
1507
|
+
}
|
|
1508
|
+
|
|
1509
|
+
export { BasicController };
|