@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,1759 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Euler, OrthographicCamera, Vector3,
|
|
3
|
+
} from 'three';
|
|
4
|
+
/* eslint-disable max-len */
|
|
5
|
+
import TWEEN, { Group } from '@tweenjs/tween.js';
|
|
6
|
+
import { SceneUtils } from 'three/examples/jsm/utils/SceneUtils.js';
|
|
7
|
+
import { Externals, NS_THREE } from '../stage/externals';
|
|
8
|
+
import { BasicTools } from '../utils/basic-tools';
|
|
9
|
+
import { Overlay } from './overlay';
|
|
10
|
+
import { View } from '../view/view';
|
|
11
|
+
import { OwllyEvents, Events } from '../utils/events';
|
|
12
|
+
import { Env, EnvironmentUtils } from '../utils/environment-utils';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* POI元素, 包含一个图标与一段文字
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* const poiOverlay = new PoiOverlay();
|
|
19
|
+
* const poi = poiOverlay.createPoi(new Vector3(0, 0, 0));
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
interface Rect {
|
|
23
|
+
xMin: number; xMax: number; yMin: number; yMax: number;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
enum MouseState {
|
|
28
|
+
IDLE,
|
|
29
|
+
DOWN,
|
|
30
|
+
MOVE,
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* POI覆盖层, 可以展示POI图标与文字, 存在图标时以图标中心为中心, 否则为文字中心
|
|
35
|
+
* @example
|
|
36
|
+
* ```typescript
|
|
37
|
+
* const poiOverlay = new PoiOverlay();
|
|
38
|
+
* // 任意View
|
|
39
|
+
* view.addOverlay(poiOverlay);
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
|
|
43
|
+
class Poi3DOverlay extends Overlay {
|
|
44
|
+
static canvas: HTMLCanvasElement;
|
|
45
|
+
|
|
46
|
+
static ctx: CanvasRenderingContext2D;
|
|
47
|
+
|
|
48
|
+
private parent: View;
|
|
49
|
+
|
|
50
|
+
private rectMap: Map<Rect, Poi3D>;
|
|
51
|
+
|
|
52
|
+
private pois: Set<Poi3D>; // 按照level递增的顺序排
|
|
53
|
+
|
|
54
|
+
private mouseState: MouseState;
|
|
55
|
+
|
|
56
|
+
private mousePositionBuffer: NS_THREE.Vector2;
|
|
57
|
+
|
|
58
|
+
private eventTarget: Poi3D;
|
|
59
|
+
|
|
60
|
+
private enabled: boolean;
|
|
61
|
+
|
|
62
|
+
private renderThisFrame: boolean;
|
|
63
|
+
|
|
64
|
+
private visible: boolean; // 兼容
|
|
65
|
+
|
|
66
|
+
public camera: NS_THREE.Camera;
|
|
67
|
+
|
|
68
|
+
public scene: NS_THREE.Scene;
|
|
69
|
+
|
|
70
|
+
public renderCamera: NS_THREE.OrthographicCamera;
|
|
71
|
+
|
|
72
|
+
public renderer: NS_THREE.WebGL1Renderer;
|
|
73
|
+
|
|
74
|
+
public orderPois: Function;
|
|
75
|
+
|
|
76
|
+
// 这里有接收小程序传入的canvas,会调用小程序中的方法
|
|
77
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
78
|
+
// public canvas: any = {};
|
|
79
|
+
|
|
80
|
+
public prevPosition: NS_THREE.Vector3 | null;
|
|
81
|
+
|
|
82
|
+
public prevQuaternion: NS_THREE.Quaternion | null;
|
|
83
|
+
|
|
84
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
85
|
+
public prevZoom: any;
|
|
86
|
+
|
|
87
|
+
private needRender = false;
|
|
88
|
+
|
|
89
|
+
private listeners: {
|
|
90
|
+
pointerDown: (event: MouseEvent) => void;
|
|
91
|
+
pointerUp: (event: MouseEvent) => void;
|
|
92
|
+
touchStart: (event: TouchEvent) => void;
|
|
93
|
+
touchEnd: (event: TouchEvent) => void;
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
constructor(canvas?: HTMLCanvasElement) {
|
|
97
|
+
super();
|
|
98
|
+
if (EnvironmentUtils.GetEnv() === Env.Miniapp) {
|
|
99
|
+
if (!canvas) throw Error('poi-overlay need a offscreenCanvas');
|
|
100
|
+
Poi3DOverlay.canvas = canvas;
|
|
101
|
+
} else if (!Poi3DOverlay.canvas) {
|
|
102
|
+
Poi3DOverlay.canvas = document.createElement('canvas');
|
|
103
|
+
}
|
|
104
|
+
// fix: poi名字太长展示不全
|
|
105
|
+
const dpr = EnvironmentUtils.GetGlobalDPR();
|
|
106
|
+
Poi3DOverlay.canvas.width = 500 * dpr;
|
|
107
|
+
Poi3DOverlay.canvas.height = 500 * dpr;
|
|
108
|
+
Poi3DOverlay.ctx = Poi3DOverlay.canvas.getContext('2d') as CanvasRenderingContext2D;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
112
|
+
// get canvas(): any {
|
|
113
|
+
// return PoiOverlay.canvas;
|
|
114
|
+
// }
|
|
115
|
+
|
|
116
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
117
|
+
// get ctx(): any {
|
|
118
|
+
// return PoiOverlay.canvas.getContext('2d');
|
|
119
|
+
// }
|
|
120
|
+
|
|
121
|
+
init(parent: View): void {
|
|
122
|
+
const { THREE } = Externals.getInstance();
|
|
123
|
+
this.rectMap = new Map();
|
|
124
|
+
this.parent = parent;
|
|
125
|
+
this.scene = parent.stage.scene;
|
|
126
|
+
const width = parent.getViewWidth();
|
|
127
|
+
const height = parent.getViewHeight();
|
|
128
|
+
this.renderCamera = new NS_THREE.OrthographicCamera(-width / 2, width / 2, height / 2, -height / 2, 0.1, 1000);
|
|
129
|
+
this.renderCamera.up.set(0, 1, 0);
|
|
130
|
+
this.renderCamera.position.set(0, 0, 50);
|
|
131
|
+
this.renderCamera.lookAt(0, 0, 0);
|
|
132
|
+
this.camera = this.parent.camera as NS_THREE.Camera;
|
|
133
|
+
this.renderer = this.parent.renderer as NS_THREE.WebGL1Renderer;
|
|
134
|
+
// const canvas = this.canvas;
|
|
135
|
+
// canvas.width = parent.getViewWidth();
|
|
136
|
+
// canvas.height = parent.getViewHeight();
|
|
137
|
+
// this.canvas = canvas; // 离屏canvas
|
|
138
|
+
this.pois = new Set();
|
|
139
|
+
this.enabled = true;
|
|
140
|
+
this.orderPois = BasicTools.debounce(this.orderPoisByLevel.bind(this), 50);
|
|
141
|
+
this.listeners = {
|
|
142
|
+
pointerDown: (e): void => { this.onPointerDown(e); },
|
|
143
|
+
pointerUp: (e): void => { this.onPointerUp(e); },
|
|
144
|
+
touchStart: (e): void => { this.onTouchStart(e); },
|
|
145
|
+
touchEnd: (e): void => { this.onTouchEnd(e); },
|
|
146
|
+
};
|
|
147
|
+
this.mouseState = MouseState.IDLE;
|
|
148
|
+
this.mousePositionBuffer = new THREE.Vector2();
|
|
149
|
+
|
|
150
|
+
this.parent.on(OwllyEvents.MOUSE_DOWN, this.listeners.pointerDown);
|
|
151
|
+
this.parent.on(OwllyEvents.MOUSE_UP, this.listeners.pointerUp);
|
|
152
|
+
this.parent.on(OwllyEvents.TOUCH_START, this.listeners.touchStart);
|
|
153
|
+
this.parent.on(OwllyEvents.TOUCH_END, this.listeners.touchEnd);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
update(): boolean {
|
|
157
|
+
if (this.renderThisFrame || Array.from(this.pois).reduce((r, p) => (p.update() || r), false)) {
|
|
158
|
+
this.renderThisFrame = false;
|
|
159
|
+
this.needRender = true;
|
|
160
|
+
return true;
|
|
161
|
+
}
|
|
162
|
+
return false;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
forceRenderInThisFrame(): void {
|
|
166
|
+
this.renderThisFrame = true;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
render(): void {
|
|
170
|
+
if (!this.enabled) return;
|
|
171
|
+
const { THREE } = Externals.getInstance();
|
|
172
|
+
const frustum = new THREE.Frustum();
|
|
173
|
+
frustum.setFromProjectionMatrix(
|
|
174
|
+
new THREE.Matrix4().multiplyMatrices(
|
|
175
|
+
this.parent.camera!.projectionMatrix,
|
|
176
|
+
this.parent.camera!.matrixWorldInverse,
|
|
177
|
+
),
|
|
178
|
+
);
|
|
179
|
+
const viewWidth = this.parent.getViewWidth();
|
|
180
|
+
const viewHeight = this.parent.getViewHeight();
|
|
181
|
+
|
|
182
|
+
const euler = new THREE.Euler();
|
|
183
|
+
euler.setFromQuaternion(this.parent.camera!.quaternion, 'ZYX');
|
|
184
|
+
this.checkUpdate();
|
|
185
|
+
if (this.needRender || this.renderThisFrame) {
|
|
186
|
+
this.rectMap.clear();
|
|
187
|
+
const inFrustumPois: Poi3D[] = [];
|
|
188
|
+
this.pois.forEach((p) => {
|
|
189
|
+
p.draw();
|
|
190
|
+
const { isInFrustum } = p.calcPosAndSize(
|
|
191
|
+
frustum,
|
|
192
|
+
viewWidth / 2,
|
|
193
|
+
viewHeight / 2,
|
|
194
|
+
);
|
|
195
|
+
if (isInFrustum) {
|
|
196
|
+
inFrustumPois.push(p);
|
|
197
|
+
}
|
|
198
|
+
});
|
|
199
|
+
this.recalculateVisibilities(inFrustumPois); // 计算可见性
|
|
200
|
+
Array.from(this.pois).forEach((p) => {
|
|
201
|
+
p.updatePosition(
|
|
202
|
+
euler,
|
|
203
|
+
(this.parent.camera as OrthographicCamera)!.zoom,
|
|
204
|
+
);
|
|
205
|
+
});
|
|
206
|
+
// this.renderer.clearDepth();
|
|
207
|
+
// this.renderer.render(this.scene, this.camera);
|
|
208
|
+
}
|
|
209
|
+
this.renderThisFrame = false;
|
|
210
|
+
this.needRender = false;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
orderPoisByLevel(): void { // 按level递增顺序排序, 以使得collision为false时 level高的渲染的比较高
|
|
214
|
+
const pois = Array.from(this.pois);
|
|
215
|
+
pois.sort((p, q) => p.getLevel() - q.getLevel());
|
|
216
|
+
this.pois = new Set(pois);
|
|
217
|
+
this.renderThisFrame = true;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
recalculateVisibilities(pois: Poi3D[]): void { // 确定是否在视野范围内, 再推到range里, 不
|
|
221
|
+
// 碰撞测试
|
|
222
|
+
const range: [number, number, number, number][] = [];
|
|
223
|
+
let first = true;
|
|
224
|
+
Array.from(pois)
|
|
225
|
+
.sort((p, q) => (q.collision ? -1 : (q.getLevel() - p.getLevel())))
|
|
226
|
+
.forEach((poi): void => {
|
|
227
|
+
const {
|
|
228
|
+
xMin, yMin, xMax, yMax,
|
|
229
|
+
} = poi.getBoundingRect(); // 最小级别的碰撞检测盒
|
|
230
|
+
|
|
231
|
+
if (!poi.collision) {
|
|
232
|
+
poi.setHidden(false);
|
|
233
|
+
range.push([xMin, xMax, yMin, yMax]);
|
|
234
|
+
first = false;
|
|
235
|
+
return;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
const {
|
|
239
|
+
xMin: oXMin, yMin: oYMin, xMax: oXMax, yMax: oYMax,
|
|
240
|
+
} = poi.getOuterRect(); // 最外层碰撞检测盒
|
|
241
|
+
|
|
242
|
+
if (first) {
|
|
243
|
+
range.push([xMin, xMax, yMin, yMax]);
|
|
244
|
+
first = false;
|
|
245
|
+
poi.setHidden(false);
|
|
246
|
+
return;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
const valid = !range.some(([lx, rx, by, ty]) => {
|
|
250
|
+
const xIntersect = xMax < lx || xMin > rx; // x方向不重叠
|
|
251
|
+
const yIntersect = yMax < by || yMin > ty; // y 方向不重叠
|
|
252
|
+
return !xIntersect && !yIntersect;
|
|
253
|
+
});
|
|
254
|
+
if (valid) {
|
|
255
|
+
range.push([xMin, xMax, yMin, yMax]);
|
|
256
|
+
poi.setHidden(false);
|
|
257
|
+
} else if (poi.collisionMode === 'outer') {
|
|
258
|
+
poi.setHidden(true); // 全部隐藏
|
|
259
|
+
} else if (poi.collisionMode === 'icon' || poi.collisionMode === 'label') {
|
|
260
|
+
const subvalid = !range.some(([lx, rx, by, ty]) => {
|
|
261
|
+
const xIntersect = oXMax < lx || oXMin > rx; // x方向不重叠
|
|
262
|
+
const yIntersect = oYMax < by || oYMin > ty; // y 方向不重叠
|
|
263
|
+
return !xIntersect && !yIntersect;
|
|
264
|
+
});
|
|
265
|
+
if (subvalid) {
|
|
266
|
+
range.push([xMin, xMax, yMin, yMax]);
|
|
267
|
+
poi.setHidden(true, true); // 部分显示
|
|
268
|
+
} else {
|
|
269
|
+
poi.setHidden(true); // 全部隐藏
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
checkUpdate(): void {
|
|
276
|
+
// 检查更新
|
|
277
|
+
const { THREE } = Externals.getInstance();
|
|
278
|
+
if (this.renderThisFrame) return;
|
|
279
|
+
const poiNeedUpdate = Array.from(this.pois).some((p) => p.update());
|
|
280
|
+
if (poiNeedUpdate) {
|
|
281
|
+
this.renderThisFrame = true;
|
|
282
|
+
return;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
const { camera } = this.parent;
|
|
286
|
+
const {
|
|
287
|
+
quaternion, position, zoom, up,
|
|
288
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
289
|
+
} = camera as any;
|
|
290
|
+
// 检查平移
|
|
291
|
+
const curPos = position.clone();
|
|
292
|
+
const curQuaternion = quaternion.clone();
|
|
293
|
+
const curZoom = zoom;
|
|
294
|
+
|
|
295
|
+
if (!this.prevPosition) {
|
|
296
|
+
this.prevPosition = curPos.clone();
|
|
297
|
+
this.prevQuaternion = curQuaternion.clone();
|
|
298
|
+
this.prevZoom = curZoom;
|
|
299
|
+
this.renderThisFrame = true;
|
|
300
|
+
return;
|
|
301
|
+
}
|
|
302
|
+
const quat1 = new THREE.Quaternion().setFromUnitVectors(up, new THREE.Vector3(0, 1, 0));
|
|
303
|
+
const lookAtVector1 = new THREE.Vector3(0, 0, -1).applyQuaternion(this.prevQuaternion as NS_THREE.Quaternion);
|
|
304
|
+
lookAtVector1.applyQuaternion(quat1);
|
|
305
|
+
const spherical1 = new THREE.Spherical();
|
|
306
|
+
spherical1.setFromVector3(lookAtVector1);
|
|
307
|
+
|
|
308
|
+
const quat2 = new THREE.Quaternion().setFromUnitVectors(up, new THREE.Vector3(0, 1, 0));
|
|
309
|
+
const lookAtVector2 = new THREE.Vector3(0, 0, -1).applyQuaternion(curQuaternion);
|
|
310
|
+
lookAtVector2.applyQuaternion(quat2);
|
|
311
|
+
const spherical2 = new THREE.Spherical();
|
|
312
|
+
spherical2.setFromVector3(lookAtVector2);
|
|
313
|
+
|
|
314
|
+
// eslint-disable-next-line max-len
|
|
315
|
+
if (Math.abs(spherical1.phi * (180 / Math.PI) - spherical2.phi * (180 / Math.PI)) + Math.abs(spherical1.theta * (180 / Math.PI) - spherical2.theta * (180 / Math.PI)) > 0.0001) {
|
|
316
|
+
this.prevPosition = curPos.clone();
|
|
317
|
+
this.prevQuaternion = curQuaternion.clone();
|
|
318
|
+
this.prevZoom = curZoom;
|
|
319
|
+
this.renderThisFrame = true;
|
|
320
|
+
return;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
const viewWidth = this.parent.getViewWidth();
|
|
324
|
+
const viewHeight = this.parent.getViewHeight();
|
|
325
|
+
const curPagePos = curPos.clone().project(camera as THREE.Camera);
|
|
326
|
+
const curPagePosX = (curPagePos.x - 1) / 2 * viewWidth;
|
|
327
|
+
const curPagePosY = (1 - curPagePos.y) / 2 * viewHeight;
|
|
328
|
+
curPagePos.set(curPagePosX, curPagePosY, 0);
|
|
329
|
+
const prevPagePos = this.prevPosition.clone().project(camera as THREE.Camera);
|
|
330
|
+
const prevPagePosX = (prevPagePos.x - 1) / 2 * viewWidth;
|
|
331
|
+
const prevPagePosY = (1 - prevPagePos.y) / 2 * viewHeight;
|
|
332
|
+
prevPagePos.set(prevPagePosX, prevPagePosY, 0);
|
|
333
|
+
if (curPagePos.distanceTo(prevPagePos) > 0.0001) {
|
|
334
|
+
// console.log('检测到平移更新', prevPagePos, curPagePos, curPos, curPos.x, curPos.y, this.prevPosition.x, this.prevPosition.y, camera, quaternion);
|
|
335
|
+
// 平移
|
|
336
|
+
this.prevPosition = curPos.clone();
|
|
337
|
+
this.prevQuaternion = curQuaternion.clone();
|
|
338
|
+
this.prevZoom = curZoom;
|
|
339
|
+
this.renderThisFrame = true;
|
|
340
|
+
return;
|
|
341
|
+
}
|
|
342
|
+
// 非线性, zoom越小, 更新频率越快
|
|
343
|
+
// curZoom > this.prevZoom 时 在放大 zoom变大相同大小带来的更新减缓
|
|
344
|
+
// curZoom < this.prevZoom 时 在减小 zoom变小相同大小带来的更新加快
|
|
345
|
+
if (this.prevZoom !== curZoom
|
|
346
|
+
&& (Math.abs((curZoom - this.prevZoom) / curZoom) > 0.0001)
|
|
347
|
+
|| (Math.abs((this.prevZoom - curZoom) / this.prevZoom) > 0.0001)) {
|
|
348
|
+
// console.log('检测到zoom更新');
|
|
349
|
+
this.prevPosition = curPos.clone();
|
|
350
|
+
this.prevQuaternion = curQuaternion.clone();
|
|
351
|
+
this.prevZoom = curZoom;
|
|
352
|
+
this.renderThisFrame = true;
|
|
353
|
+
return;
|
|
354
|
+
}
|
|
355
|
+
this.renderThisFrame = false;
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
public dispose(): void {
|
|
359
|
+
this.parent.off(OwllyEvents.MOUSE_DOWN, this.listeners.pointerDown);
|
|
360
|
+
this.parent.off(OwllyEvents.MOUSE_UP, this.listeners.pointerUp);
|
|
361
|
+
this.parent.off(OwllyEvents.TOUCH_START, this.listeners.touchStart);
|
|
362
|
+
this.parent.off(OwllyEvents.TOUCH_END, this.listeners.touchEnd);
|
|
363
|
+
this.clearPoi();
|
|
364
|
+
if (Poi3DOverlay.canvas) {
|
|
365
|
+
Poi3DOverlay.canvas.remove();
|
|
366
|
+
Poi3DOverlay.canvas = null as unknown as HTMLCanvasElement;
|
|
367
|
+
}
|
|
368
|
+
if (Poi3DOverlay.ctx) {
|
|
369
|
+
Poi3DOverlay.ctx = null as unknown as CanvasRenderingContext2D;
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
private onPointerDown(e: MouseEvent): void {
|
|
374
|
+
const { clientX, clientY } = e;
|
|
375
|
+
const [left, top] = this.parent.getViewOffset();
|
|
376
|
+
const x = clientX - left;
|
|
377
|
+
const y = clientY - top;
|
|
378
|
+
let target = null;
|
|
379
|
+
Array.from(this.rectMap).some(([rect, poi]) => {
|
|
380
|
+
// v.visible && ( !v.hide || v.subHide)
|
|
381
|
+
const {
|
|
382
|
+
xMin, yMin, xMax, yMax,
|
|
383
|
+
} = rect;
|
|
384
|
+
const box2 = new NS_THREE.Box2(
|
|
385
|
+
new NS_THREE.Vector2(xMin, yMin), new NS_THREE.Vector2(xMax, yMax),
|
|
386
|
+
);
|
|
387
|
+
if (box2.containsPoint(new NS_THREE.Vector2(x, y))) {
|
|
388
|
+
target = poi;
|
|
389
|
+
return true;
|
|
390
|
+
}
|
|
391
|
+
return false;
|
|
392
|
+
});
|
|
393
|
+
if (target) {
|
|
394
|
+
this.onNodePointerDown(target, x, y, e.button);
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
private onPointerUp(e: MouseEvent): void {
|
|
399
|
+
const { THREE } = Externals.getInstance();
|
|
400
|
+
const { clientX, clientY } = e;
|
|
401
|
+
const [left, top] = this.parent.getViewOffset();
|
|
402
|
+
const x = clientX - left;
|
|
403
|
+
const y = clientY - top;
|
|
404
|
+
const distance = new THREE.Vector2(x, y).distanceToSquared(this.mousePositionBuffer);
|
|
405
|
+
this.emit(Events.POI_UP, this.eventTarget, e.button);
|
|
406
|
+
if (this.mouseState === MouseState.DOWN && distance < 100) {
|
|
407
|
+
this.emit(Events.POI_CLICKED, this.eventTarget, e.button);
|
|
408
|
+
}
|
|
409
|
+
this.mouseState = MouseState.IDLE;
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
private onTouchStart(e: TouchEvent): void {
|
|
413
|
+
const { clientX, clientY } = e.touches[0];
|
|
414
|
+
const [left, top] = this.parent.getViewOffset();
|
|
415
|
+
const x = clientX - left;
|
|
416
|
+
const y = clientY - top;
|
|
417
|
+
let target = null;
|
|
418
|
+
Array.from(this.rectMap).some(([rect, poi]) => {
|
|
419
|
+
// v.visible && ( !v.hide || v.subHide)
|
|
420
|
+
const {
|
|
421
|
+
xMin, yMin, xMax, yMax,
|
|
422
|
+
} = rect;
|
|
423
|
+
const box2 = new NS_THREE.Box2(
|
|
424
|
+
new NS_THREE.Vector2(xMin, yMin), new NS_THREE.Vector2(xMax, yMax),
|
|
425
|
+
);
|
|
426
|
+
if (box2.containsPoint(new NS_THREE.Vector2(x, y))) {
|
|
427
|
+
target = poi;
|
|
428
|
+
return true;
|
|
429
|
+
}
|
|
430
|
+
return false;
|
|
431
|
+
});
|
|
432
|
+
if (target) {
|
|
433
|
+
this.onNodePointerDown(target, x, y, 0);
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
private onTouchEnd(e: TouchEvent): void {
|
|
438
|
+
const { THREE } = Externals.getInstance();
|
|
439
|
+
const { clientX, clientY } = e.changedTouches[0];
|
|
440
|
+
const [left, top] = this.parent.getViewOffset();
|
|
441
|
+
const x = clientX - left;
|
|
442
|
+
const y = clientY - top;
|
|
443
|
+
const distance = new THREE.Vector2(x, y).distanceToSquared(this.mousePositionBuffer);
|
|
444
|
+
this.emit(Events.POI_UP, this.eventTarget, 0);
|
|
445
|
+
if (this.mouseState === MouseState.DOWN && distance < 100) {
|
|
446
|
+
this.emit(Events.POI_CLICKED, this.eventTarget, 0);
|
|
447
|
+
}
|
|
448
|
+
this.mouseState = MouseState.IDLE;
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
private onNodePointerDown(target: Poi3D, x: number, y: number, button = 0): void {
|
|
452
|
+
if (this.mouseState !== MouseState.IDLE) return;
|
|
453
|
+
this.mouseState = MouseState.DOWN;
|
|
454
|
+
this.mousePositionBuffer.set(x, y);
|
|
455
|
+
this.eventTarget = target;
|
|
456
|
+
this.emit(Events.POI_DOWN, target, button);
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
/**
|
|
460
|
+
* 新建POI
|
|
461
|
+
* @param position POI在3D空间中的位置
|
|
462
|
+
*/
|
|
463
|
+
public createPoi(position: NS_THREE.Vector3): Poi3D {
|
|
464
|
+
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
465
|
+
const poi = new Poi3D();
|
|
466
|
+
poi.setParent(this);
|
|
467
|
+
this.renderThisFrame = true;
|
|
468
|
+
poi.setPosition(position);
|
|
469
|
+
if (!this.pois) throw Error('poiOverlay need bind a view, use view.addOverlay()');
|
|
470
|
+
this.pois.add(poi);
|
|
471
|
+
this.scene.add(poi.group!);
|
|
472
|
+
return poi;
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
public setRectMap(rect: Rect, ele: Poi3D): void {
|
|
476
|
+
this.rectMap.set(rect, ele);
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
/**
|
|
480
|
+
* 删除POI
|
|
481
|
+
* @param poi 待删除的POI
|
|
482
|
+
*/
|
|
483
|
+
public removePoi(poi: Poi3D): void {
|
|
484
|
+
this.pois.delete(poi);
|
|
485
|
+
this.scene.remove(poi.group!);
|
|
486
|
+
poi.dispose();
|
|
487
|
+
this.renderThisFrame = true;
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
public clearPoi(): void{
|
|
491
|
+
const pois = Array.from(this.pois);
|
|
492
|
+
pois.forEach((poi) => {
|
|
493
|
+
this.scene.remove(poi.group!);
|
|
494
|
+
});
|
|
495
|
+
this.pois.clear();
|
|
496
|
+
this.renderThisFrame = true;
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
/**
|
|
500
|
+
* 设置覆盖层可见性 兼容旧poi
|
|
501
|
+
* @param visible 覆盖层是否可见
|
|
502
|
+
*/
|
|
503
|
+
public setVisibility(visible: boolean): void {
|
|
504
|
+
this.visible = visible;
|
|
505
|
+
this.enabled = visible;
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
public setEnabled(value: boolean): void {
|
|
509
|
+
this.enabled = value;
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
public resize(viewWidth: number, viewHeight: number): void {
|
|
513
|
+
this.updateCameraAspect(viewWidth, viewHeight);
|
|
514
|
+
this.renderThisFrame = true;
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
private updateCameraAspect(viewWidth: number, viewHeight: number): void {
|
|
518
|
+
const width = viewWidth;
|
|
519
|
+
const height = viewHeight;
|
|
520
|
+
this.renderCamera.left = -width / 2;
|
|
521
|
+
this.renderCamera.right = width / 2;
|
|
522
|
+
this.renderCamera.top = height / 2;
|
|
523
|
+
this.renderCamera.bottom = -height / 2;
|
|
524
|
+
this.renderCamera.updateProjectionMatrix();
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
// Poi3DOverlay.canvas = document.createElement('canvas');
|
|
528
|
+
// Poi3DOverlay.ctx = Poi3DOverlay.canvas.getContext('2d') as CanvasRenderingContext2D;
|
|
529
|
+
|
|
530
|
+
|
|
531
|
+
class Poi3D {
|
|
532
|
+
static ImageMaterialMap = new Map();
|
|
533
|
+
|
|
534
|
+
private position: NS_THREE.Vector3;
|
|
535
|
+
|
|
536
|
+
private screenPosition: { x: number; y: number };
|
|
537
|
+
|
|
538
|
+
private visible: boolean;
|
|
539
|
+
|
|
540
|
+
private hide: boolean;
|
|
541
|
+
|
|
542
|
+
private parent: Poi3DOverlay|null;
|
|
543
|
+
|
|
544
|
+
private subHide: boolean;
|
|
545
|
+
|
|
546
|
+
private textVisibility: boolean; // 做兼容, 未用到
|
|
547
|
+
|
|
548
|
+
private iconVisibility: boolean; // 做兼容, 未用到
|
|
549
|
+
|
|
550
|
+
private animationEnabled: boolean;
|
|
551
|
+
|
|
552
|
+
public isInFrustum: boolean;
|
|
553
|
+
|
|
554
|
+
private textPosInfo: {
|
|
555
|
+
anchor: 'center' | 'left' | 'right' | 'top' | 'bottom' | 'topleft' | 'topright' | 'bottomleft' | 'bottomright';
|
|
556
|
+
offsetX: number; // 相对position
|
|
557
|
+
offsetY: number; // 相对position
|
|
558
|
+
anchorOffsetX: number; // 相对设置的position, 为 正 表示向右偏移
|
|
559
|
+
anchorOffsetY: number; // 相对设置的position, 为 正 表示向上偏移
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
private iconPosInfo: {
|
|
563
|
+
anchor: 'center' | 'left' | 'right' | 'top' | 'bottom' | 'topleft' | 'topright' | 'bottomleft' | 'bottomright';
|
|
564
|
+
offsetX: number; // 相对锚点
|
|
565
|
+
offsetY: number; // 相对锚点
|
|
566
|
+
anchorOffsetX: number; // 相对设置的position
|
|
567
|
+
anchorOffsetY: number; // 相对设置的position
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
// 是否开启自动旋转
|
|
571
|
+
// 开启时跟随画布一起旋转
|
|
572
|
+
// 默认:false
|
|
573
|
+
private autoRotation: boolean;
|
|
574
|
+
|
|
575
|
+
private rotation: number;
|
|
576
|
+
|
|
577
|
+
public collision: boolean;
|
|
578
|
+
|
|
579
|
+
private boundingBox: NS_THREE.Group | null;
|
|
580
|
+
|
|
581
|
+
private overlapArea: { x: number; y: number }; // 开启碰撞检测时允许设置可重叠区域
|
|
582
|
+
|
|
583
|
+
public collisionMode: string; // icon || label || outer
|
|
584
|
+
|
|
585
|
+
private withBoundingBox: boolean;
|
|
586
|
+
|
|
587
|
+
private subAreaOpacity: number; // 在设置
|
|
588
|
+
|
|
589
|
+
private abandonedAreaOpacity: number;
|
|
590
|
+
|
|
591
|
+
private visiblePartWhenCollision: string;
|
|
592
|
+
|
|
593
|
+
// 用于计算poi碰撞边界
|
|
594
|
+
private boundingRect: Rect;
|
|
595
|
+
|
|
596
|
+
// 用于计算poi全部展示区域边界
|
|
597
|
+
private outerRect: Rect;
|
|
598
|
+
|
|
599
|
+
private iconCircleOptions: {
|
|
600
|
+
width: number;
|
|
601
|
+
color: string;
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
private iconInCircle: boolean;
|
|
605
|
+
|
|
606
|
+
private iconRect: Rect;
|
|
607
|
+
|
|
608
|
+
private textRect: Rect;
|
|
609
|
+
|
|
610
|
+
private visibilityAnimation: {
|
|
611
|
+
anim: TWEEN.Tween | null;
|
|
612
|
+
from: number | null;
|
|
613
|
+
to: number | null;
|
|
614
|
+
current: number | null;
|
|
615
|
+
};
|
|
616
|
+
|
|
617
|
+
private textWidth: number;
|
|
618
|
+
|
|
619
|
+
private textHeight: number;
|
|
620
|
+
|
|
621
|
+
private iconSize: [number, number];
|
|
622
|
+
|
|
623
|
+
private textMaterial: NS_THREE.MeshBasicMaterial | null;
|
|
624
|
+
|
|
625
|
+
private iconMaterial: NS_THREE.MeshBasicMaterial | null;
|
|
626
|
+
|
|
627
|
+
private iconCircleMaterial: NS_THREE.MeshBasicMaterial | null;
|
|
628
|
+
|
|
629
|
+
private rectMaterial: NS_THREE.MeshBasicMaterial | null;
|
|
630
|
+
|
|
631
|
+
|
|
632
|
+
private text: NS_THREE.Mesh | null;
|
|
633
|
+
|
|
634
|
+
private icon: NS_THREE.Group | null;
|
|
635
|
+
|
|
636
|
+
public group: NS_THREE.Group | null;
|
|
637
|
+
|
|
638
|
+
public poiId: number;
|
|
639
|
+
|
|
640
|
+
// private renderThisFrame: boolean;
|
|
641
|
+
|
|
642
|
+
private iconOptions: { size: [number, number]; src: null | string };
|
|
643
|
+
|
|
644
|
+
private labelOptions: { fontSize: number; padding: number; content: null | string };
|
|
645
|
+
|
|
646
|
+
// eslint-disable-next-line max-len
|
|
647
|
+
private rectOptions: { width: number; height: number; fill: number | string; opacity: number; offsetX: number; offsetY: number };
|
|
648
|
+
|
|
649
|
+
private withRect: boolean;
|
|
650
|
+
|
|
651
|
+
private rect: NS_THREE.Group | null;
|
|
652
|
+
|
|
653
|
+
private level: number;
|
|
654
|
+
|
|
655
|
+
private dpr: number;
|
|
656
|
+
|
|
657
|
+
private isFlipY: boolean;
|
|
658
|
+
|
|
659
|
+
private _renderThisFrame = false;
|
|
660
|
+
|
|
661
|
+
private labelOpacity: number;
|
|
662
|
+
|
|
663
|
+
private iconOpacity: number;
|
|
664
|
+
|
|
665
|
+
private set renderThisFrame(value: boolean) {
|
|
666
|
+
this._renderThisFrame = value;
|
|
667
|
+
}
|
|
668
|
+
|
|
669
|
+
private get renderThisFrame(): boolean {
|
|
670
|
+
return this._renderThisFrame;
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
constructor(position?: NS_THREE.Vector3) {
|
|
674
|
+
const { THREE } = Externals.getInstance();
|
|
675
|
+
this.dpr = EnvironmentUtils.GetGlobalDPR();
|
|
676
|
+
this.isFlipY = false;
|
|
677
|
+
this.position = position || new THREE.Vector3();
|
|
678
|
+
this.group = new NS_THREE.Group();
|
|
679
|
+
// this.group.rotateX(MathUtils.degToRad(90));
|
|
680
|
+
this.textVisibility = true;
|
|
681
|
+
this.iconVisibility = true;
|
|
682
|
+
this.iconInCircle = false;
|
|
683
|
+
this.iconCircleOptions = {
|
|
684
|
+
width: 0,
|
|
685
|
+
color: '#ffffff',
|
|
686
|
+
};
|
|
687
|
+
this.textPosInfo = {
|
|
688
|
+
anchor: 'center',
|
|
689
|
+
offsetX: 0,
|
|
690
|
+
offsetY: 0,
|
|
691
|
+
anchorOffsetX: 0,
|
|
692
|
+
anchorOffsetY: 0,
|
|
693
|
+
};
|
|
694
|
+
this.iconPosInfo = {
|
|
695
|
+
anchor: 'center',
|
|
696
|
+
offsetX: 0,
|
|
697
|
+
offsetY: 0,
|
|
698
|
+
anchorOffsetX: 0,
|
|
699
|
+
anchorOffsetY: 0,
|
|
700
|
+
};
|
|
701
|
+
this.level = 1;
|
|
702
|
+
this.isInFrustum = false;
|
|
703
|
+
this.animationEnabled = false;
|
|
704
|
+
this.text = null;
|
|
705
|
+
this.icon = null;
|
|
706
|
+
this.rect = null;
|
|
707
|
+
this.boundingBox = null;
|
|
708
|
+
this.overlapArea = { x: 0, y: 0 };
|
|
709
|
+
this.visible = true; // 检查是否用到
|
|
710
|
+
this.hide = false;
|
|
711
|
+
this.subHide = false;
|
|
712
|
+
this.rotation = 0;
|
|
713
|
+
this.autoRotation = false;
|
|
714
|
+
this.collision = true;
|
|
715
|
+
this.collisionMode = 'outer';
|
|
716
|
+
this.iconRect = {
|
|
717
|
+
xMin: 0,
|
|
718
|
+
yMin: 0,
|
|
719
|
+
xMax: 0,
|
|
720
|
+
yMax: 0,
|
|
721
|
+
};
|
|
722
|
+
this.textRect = {
|
|
723
|
+
xMin: 0,
|
|
724
|
+
yMin: 0,
|
|
725
|
+
xMax: 0,
|
|
726
|
+
yMax: 0,
|
|
727
|
+
};
|
|
728
|
+
this.boundingRect = {
|
|
729
|
+
xMin: 0,
|
|
730
|
+
yMin: 0,
|
|
731
|
+
xMax: 0,
|
|
732
|
+
yMax: 0,
|
|
733
|
+
};
|
|
734
|
+
|
|
735
|
+
this.outerRect = {
|
|
736
|
+
xMin: 0,
|
|
737
|
+
yMin: 0,
|
|
738
|
+
xMax: 0,
|
|
739
|
+
yMax: 0,
|
|
740
|
+
};
|
|
741
|
+
this.visibilityAnimation = {
|
|
742
|
+
anim: null,
|
|
743
|
+
from: 1,
|
|
744
|
+
to: 1,
|
|
745
|
+
current: 1,
|
|
746
|
+
};
|
|
747
|
+
this.text = null;
|
|
748
|
+
this.textWidth = 0;
|
|
749
|
+
this.textHeight = 0;
|
|
750
|
+
this.icon = null;
|
|
751
|
+
this.iconOptions = {
|
|
752
|
+
size: [20, 20],
|
|
753
|
+
src: null,
|
|
754
|
+
};
|
|
755
|
+
this.labelOptions = {
|
|
756
|
+
fontSize: 12,
|
|
757
|
+
padding: 0,
|
|
758
|
+
content: null,
|
|
759
|
+
};
|
|
760
|
+
|
|
761
|
+
this.rectOptions = {
|
|
762
|
+
width: 0,
|
|
763
|
+
height: 0,
|
|
764
|
+
fill: 0xff0000,
|
|
765
|
+
opacity: 0.5,
|
|
766
|
+
offsetX: 0,
|
|
767
|
+
offsetY: 0,
|
|
768
|
+
};
|
|
769
|
+
this.visiblePartWhenCollision = 'none';
|
|
770
|
+
this.subAreaOpacity = 1;
|
|
771
|
+
this.abandonedAreaOpacity = 1;
|
|
772
|
+
this.screenPosition = { x: 0, y: 0 };
|
|
773
|
+
this.labelOpacity = 1;
|
|
774
|
+
this.iconOpacity = 1;
|
|
775
|
+
}
|
|
776
|
+
|
|
777
|
+
public dispose(): void{
|
|
778
|
+
if (this.group) {
|
|
779
|
+
BasicTools.dispose(this.group, true);
|
|
780
|
+
}
|
|
781
|
+
this.parent = null;
|
|
782
|
+
this.iconCircleMaterial = null;
|
|
783
|
+
this.iconMaterial = null;
|
|
784
|
+
this.textMaterial = null;
|
|
785
|
+
this.icon = null;
|
|
786
|
+
this.rect = null;
|
|
787
|
+
this.boundingBox = null;
|
|
788
|
+
this.group = null;
|
|
789
|
+
}
|
|
790
|
+
|
|
791
|
+
public setParent(parent: Poi3DOverlay): void {
|
|
792
|
+
this.parent = parent;
|
|
793
|
+
}
|
|
794
|
+
|
|
795
|
+
public setPosition(position: NS_THREE.Vector3, tolerance = 0.0001): void {
|
|
796
|
+
if (position.distanceTo(this.position) < tolerance) return;
|
|
797
|
+
this.position.copy(position);
|
|
798
|
+
// eslint-disable-next-line no-unused-expressions
|
|
799
|
+
this.group && this.group.position.copy(position);
|
|
800
|
+
this.renderThisFrame = true;
|
|
801
|
+
}
|
|
802
|
+
|
|
803
|
+
public setOpacity(labelOpacity = this.labelOpacity, iconOpacity = this.iconOpacity): void {
|
|
804
|
+
this.labelOpacity = labelOpacity;
|
|
805
|
+
this.iconOpacity = iconOpacity;
|
|
806
|
+
if (this.textMaterial) {
|
|
807
|
+
this.textMaterial.opacity = labelOpacity;
|
|
808
|
+
}
|
|
809
|
+
if (this.iconMaterial) {
|
|
810
|
+
this.iconMaterial.opacity = iconOpacity;
|
|
811
|
+
}
|
|
812
|
+
this.renderThisFrame = true;
|
|
813
|
+
}
|
|
814
|
+
|
|
815
|
+
/**
|
|
816
|
+
* 设置旋转角度
|
|
817
|
+
* @param rotation 旋转角度
|
|
818
|
+
*/
|
|
819
|
+
public setRotation(rotation: number, tolerance = 0.0001): void {
|
|
820
|
+
if (Math.abs(rotation - this.rotation) < tolerance) return;
|
|
821
|
+
this.group!.rotateZ(rotation - this.rotation);
|
|
822
|
+
this.rotation = rotation;
|
|
823
|
+
this.renderThisFrame = true;
|
|
824
|
+
}
|
|
825
|
+
|
|
826
|
+
/**
|
|
827
|
+
* 设置是否碰撞
|
|
828
|
+
* @param collision 是否碰撞
|
|
829
|
+
*/
|
|
830
|
+
public setCollision(collision: boolean): void {
|
|
831
|
+
this.collision = collision;
|
|
832
|
+
this.renderThisFrame = true;
|
|
833
|
+
}
|
|
834
|
+
|
|
835
|
+
/**
|
|
836
|
+
* 设置碰撞模式
|
|
837
|
+
* @param mode 碰撞模式 label || icon || outer(默认)
|
|
838
|
+
*/
|
|
839
|
+
public setCollisionMode(mode: string): void {
|
|
840
|
+
this.collisionMode = mode;
|
|
841
|
+
this.renderThisFrame = true;
|
|
842
|
+
}
|
|
843
|
+
|
|
844
|
+
public setLabelVisibility(visible: boolean): void {
|
|
845
|
+
this.textVisibility = visible;
|
|
846
|
+
this.renderThisFrame = true;
|
|
847
|
+
}
|
|
848
|
+
|
|
849
|
+
public setIconVisiblity(visible: boolean): void {
|
|
850
|
+
this.iconVisibility = visible;
|
|
851
|
+
this.renderThisFrame = true;
|
|
852
|
+
}
|
|
853
|
+
|
|
854
|
+
public setHideModeWhenCollision(mode: string): void {
|
|
855
|
+
// 即将废弃
|
|
856
|
+
if (mode === 'all') {
|
|
857
|
+
this.setVisiblePartWhenCollision('none');
|
|
858
|
+
} else if (mode === 'none') {
|
|
859
|
+
this.setVisiblePartWhenCollision('all');
|
|
860
|
+
} else {
|
|
861
|
+
this.setVisiblePartWhenCollision(mode);
|
|
862
|
+
}
|
|
863
|
+
}
|
|
864
|
+
|
|
865
|
+
// 碰撞下的显隐: 全部显示 / 全部隐藏 / label隐藏 / icon隐藏
|
|
866
|
+
public setVisiblePartWhenCollision(part: string): void {
|
|
867
|
+
this.visiblePartWhenCollision = part;
|
|
868
|
+
}
|
|
869
|
+
|
|
870
|
+
public setCollisionOverlap(x: number, y: number): void {
|
|
871
|
+
this.overlapArea = { x, y };
|
|
872
|
+
this.renderThisFrame = true;
|
|
873
|
+
}
|
|
874
|
+
|
|
875
|
+
/**
|
|
876
|
+
* 设置POI层级
|
|
877
|
+
* @param level 层级
|
|
878
|
+
*/
|
|
879
|
+
public setLevel(level: number, forceOrder = false): void {
|
|
880
|
+
this.level = level;
|
|
881
|
+
this.renderThisFrame = true;
|
|
882
|
+
this.parent!.orderPois(forceOrder);
|
|
883
|
+
}
|
|
884
|
+
|
|
885
|
+
/**
|
|
886
|
+
* 获取POI层级
|
|
887
|
+
*/
|
|
888
|
+
public getLevel(): number {
|
|
889
|
+
return this.level;
|
|
890
|
+
}
|
|
891
|
+
|
|
892
|
+
/**
|
|
893
|
+
* 设置POI可见性
|
|
894
|
+
* @param visible 可见性
|
|
895
|
+
*/
|
|
896
|
+
public setVisibility(visible: boolean): void {
|
|
897
|
+
if (this.visible !== visible) this.renderThisFrame = true;
|
|
898
|
+
this.visible = visible;
|
|
899
|
+
}
|
|
900
|
+
|
|
901
|
+
/**
|
|
902
|
+
* 设置POI是否暂时隐藏
|
|
903
|
+
* @param hide true 全部隐藏 false: 根据 hideModeWhenCollision 做显隐判断
|
|
904
|
+
*/
|
|
905
|
+
public setHidden(hide: boolean, subHide = false): void {
|
|
906
|
+
// 优先级 hide > subHide
|
|
907
|
+
// hide 为 false 完全显示
|
|
908
|
+
// hide === true && subHide === true 部分显示
|
|
909
|
+
// hide === true && subHide === false 全部隐藏
|
|
910
|
+
if (!this.animationEnabled) {
|
|
911
|
+
if (this.hide !== hide || this.subHide !== subHide) {
|
|
912
|
+
this.hide = hide;
|
|
913
|
+
this.subHide = subHide;
|
|
914
|
+
this.renderThisFrame = true;
|
|
915
|
+
}
|
|
916
|
+
} else {
|
|
917
|
+
// 在动画中 判断终点是否相同
|
|
918
|
+
// eslint-disable-next-line no-nested-ternary
|
|
919
|
+
const to = !hide ? 1 : (subHide ? 0.5 : 0);
|
|
920
|
+
if (this.visibilityAnimation.anim && to === this.visibilityAnimation.to) return;
|
|
921
|
+
// 不在动画中 判断 hide === this.hide && subHide === this.subHide
|
|
922
|
+
if (!this.visibilityAnimation.anim && (hide === this.hide && subHide === this.subHide)) return;
|
|
923
|
+
if (this.visibilityAnimation.anim) { // 假设之前在执行, ani.stop()
|
|
924
|
+
this.visibilityAnimation.anim!.stop();
|
|
925
|
+
this.visibilityAnimation.anim = null;
|
|
926
|
+
}
|
|
927
|
+
const start = { subAreaOpacity: this.subAreaOpacity, abandonedAreaOpacity: this.abandonedAreaOpacity };
|
|
928
|
+
const end = { subAreaOpacity: 0, abandonedAreaOpacity: 0 };
|
|
929
|
+
|
|
930
|
+
if (hide) { // hide = true 隐藏 || 部分显示
|
|
931
|
+
if (subHide) {
|
|
932
|
+
// 部分显示
|
|
933
|
+
end.subAreaOpacity = 1;
|
|
934
|
+
end.abandonedAreaOpacity = 0;
|
|
935
|
+
} else {
|
|
936
|
+
// 全部隐藏
|
|
937
|
+
end.subAreaOpacity = 0;
|
|
938
|
+
end.abandonedAreaOpacity = 0;
|
|
939
|
+
}
|
|
940
|
+
} else { // !hide 完全展示
|
|
941
|
+
end.subAreaOpacity = 1;
|
|
942
|
+
end.abandonedAreaOpacity = 1;
|
|
943
|
+
}
|
|
944
|
+
let subMaterials: NS_THREE.MeshBasicMaterial[] = [];
|
|
945
|
+
const abandonedMaterials: NS_THREE.MeshBasicMaterial[] = [];
|
|
946
|
+
switch (this.visiblePartWhenCollision) {
|
|
947
|
+
case 'all':
|
|
948
|
+
if (this.text) {
|
|
949
|
+
subMaterials.push(this.textMaterial as NS_THREE.MeshBasicMaterial);
|
|
950
|
+
}
|
|
951
|
+
// if (this.rect) {
|
|
952
|
+
// subMaterials.push(this.rectMaterial);
|
|
953
|
+
// }
|
|
954
|
+
if (this.icon) {
|
|
955
|
+
subMaterials.push(this.iconMaterial as NS_THREE.MeshBasicMaterial);
|
|
956
|
+
if (this.iconCircleMaterial && this.iconCircleMaterial.visible) {
|
|
957
|
+
subMaterials.push(this.iconCircleMaterial as NS_THREE.MeshBasicMaterial);
|
|
958
|
+
}
|
|
959
|
+
}
|
|
960
|
+
break;
|
|
961
|
+
case 'none':
|
|
962
|
+
if (this.text) {
|
|
963
|
+
abandonedMaterials.push(this.textMaterial as NS_THREE.MeshBasicMaterial);
|
|
964
|
+
}
|
|
965
|
+
if (this.icon) {
|
|
966
|
+
abandonedMaterials.push(this.iconMaterial as NS_THREE.MeshBasicMaterial);
|
|
967
|
+
if (this.iconCircleMaterial && this.iconCircleMaterial.visible) {
|
|
968
|
+
abandonedMaterials.push(this.iconCircleMaterial as NS_THREE.MeshBasicMaterial);
|
|
969
|
+
}
|
|
970
|
+
}
|
|
971
|
+
break;
|
|
972
|
+
case 'label':
|
|
973
|
+
// eslint-disable-next-line max-len
|
|
974
|
+
subMaterials = [this.textMaterial as NS_THREE.MeshBasicMaterial, this.rectMaterial as NS_THREE.MeshBasicMaterial];
|
|
975
|
+
if (this.text) {
|
|
976
|
+
subMaterials.push(this.textMaterial as NS_THREE.MeshBasicMaterial);
|
|
977
|
+
}
|
|
978
|
+
if (this.icon) {
|
|
979
|
+
abandonedMaterials.push(this.iconMaterial as NS_THREE.MeshBasicMaterial);
|
|
980
|
+
if (this.iconCircleMaterial && this.iconCircleMaterial.visible) {
|
|
981
|
+
abandonedMaterials.push(this.iconCircleMaterial as NS_THREE.MeshBasicMaterial);
|
|
982
|
+
}
|
|
983
|
+
}
|
|
984
|
+
break;
|
|
985
|
+
case 'icon':
|
|
986
|
+
if (this.text) {
|
|
987
|
+
abandonedMaterials.push(this.textMaterial as NS_THREE.MeshBasicMaterial);
|
|
988
|
+
}
|
|
989
|
+
if (this.icon) {
|
|
990
|
+
subMaterials.push(this.iconMaterial as NS_THREE.MeshBasicMaterial);
|
|
991
|
+
if (this.iconCircleMaterial && this.iconCircleMaterial.visible) {
|
|
992
|
+
subMaterials.push(this.iconCircleMaterial as NS_THREE.MeshBasicMaterial);
|
|
993
|
+
}
|
|
994
|
+
}
|
|
995
|
+
break;
|
|
996
|
+
default:
|
|
997
|
+
break;
|
|
998
|
+
}
|
|
999
|
+
this.visibilityAnimation.from = this.visibilityAnimation.current;
|
|
1000
|
+
// eslint-disable-next-line no-nested-ternary
|
|
1001
|
+
this.visibilityAnimation.to = !hide ? 1 : (subHide ? 0.5 : 0);
|
|
1002
|
+
// 动画
|
|
1003
|
+
const duration = 300;
|
|
1004
|
+
this.visibilityAnimation.anim = new TWEEN.Tween(start).to(end, duration).onUpdate((cur) => {
|
|
1005
|
+
this.subAreaOpacity = cur.subAreaOpacity;
|
|
1006
|
+
this.abandonedAreaOpacity = cur.abandonedAreaOpacity;
|
|
1007
|
+
subMaterials.forEach((areaM: NS_THREE.MeshBasicMaterial) => {
|
|
1008
|
+
areaM.opacity = cur.subAreaOpacity;
|
|
1009
|
+
});
|
|
1010
|
+
abandonedMaterials.forEach((areaM: NS_THREE.MeshBasicMaterial) => {
|
|
1011
|
+
areaM.opacity = cur.abandonedAreaOpacity;
|
|
1012
|
+
});
|
|
1013
|
+
}).start()
|
|
1014
|
+
.onComplete(() => {
|
|
1015
|
+
this.visibilityAnimation.anim = null;
|
|
1016
|
+
this.visibilityAnimation.from = null;
|
|
1017
|
+
this.visibilityAnimation.current = null;
|
|
1018
|
+
this.visibilityAnimation.to = null;
|
|
1019
|
+
this.hide = hide;
|
|
1020
|
+
this.subHide = subHide;
|
|
1021
|
+
});
|
|
1022
|
+
}
|
|
1023
|
+
}
|
|
1024
|
+
|
|
1025
|
+
/**
|
|
1026
|
+
* 设置Rect是否可见
|
|
1027
|
+
* @param withRect 可见性
|
|
1028
|
+
*/
|
|
1029
|
+
public setRect(withRect: boolean): void {
|
|
1030
|
+
this.withRect = withRect;
|
|
1031
|
+
this.renderThisFrame = true;
|
|
1032
|
+
}
|
|
1033
|
+
|
|
1034
|
+
/**
|
|
1035
|
+
* 设置Rect默认宽高 未废弃, 不发挥作用
|
|
1036
|
+
* @param withRect 可见性
|
|
1037
|
+
*/
|
|
1038
|
+
private setRectDefSize(width: number, height: number): void {
|
|
1039
|
+
this.rectOptions.width = width;
|
|
1040
|
+
this.rectOptions.height = height;
|
|
1041
|
+
this.renderThisFrame = true;
|
|
1042
|
+
}
|
|
1043
|
+
|
|
1044
|
+
/**
|
|
1045
|
+
* 设置Rect背景色 未废弃, 不发挥作用
|
|
1046
|
+
* @param color
|
|
1047
|
+
*/
|
|
1048
|
+
public setRectFill(color: number | string): void {
|
|
1049
|
+
this.rectOptions.fill = color;
|
|
1050
|
+
this.renderThisFrame = true;
|
|
1051
|
+
}
|
|
1052
|
+
|
|
1053
|
+
/**
|
|
1054
|
+
* 设置Rect偏移 未废弃, 不发挥作用
|
|
1055
|
+
* @param x
|
|
1056
|
+
* @param y
|
|
1057
|
+
*/
|
|
1058
|
+
public setRectOffset(x = 0, y = 0): void {
|
|
1059
|
+
this.rectOptions.offsetX = x;
|
|
1060
|
+
this.rectOptions.offsetY = y;
|
|
1061
|
+
this.renderThisFrame = true;
|
|
1062
|
+
}
|
|
1063
|
+
|
|
1064
|
+
public setIconImage(src: string): void {
|
|
1065
|
+
if (this.iconOptions && this.iconOptions.src === src) return;
|
|
1066
|
+
this.iconOptions.src = src;
|
|
1067
|
+
this.clearIcon();
|
|
1068
|
+
this.renderThisFrame = true;
|
|
1069
|
+
}
|
|
1070
|
+
|
|
1071
|
+
public setIconSize(width: number, height: number): void {
|
|
1072
|
+
this.iconSize = [width, height];
|
|
1073
|
+
this.iconOptions.size = [width, height];
|
|
1074
|
+
this.renderThisFrame = true;
|
|
1075
|
+
}
|
|
1076
|
+
|
|
1077
|
+
/**
|
|
1078
|
+
* 设置POI中icon的显示
|
|
1079
|
+
*/
|
|
1080
|
+
public setIconShowInCircle(lineWidth: number, lineColor: string): void {
|
|
1081
|
+
this.iconInCircle = true;
|
|
1082
|
+
this.iconCircleOptions = {
|
|
1083
|
+
width: lineWidth,
|
|
1084
|
+
color: lineColor,
|
|
1085
|
+
};
|
|
1086
|
+
}
|
|
1087
|
+
|
|
1088
|
+
drawIcon(): void {
|
|
1089
|
+
const { src, size } = this.iconOptions;
|
|
1090
|
+
if (!src) return;
|
|
1091
|
+
if (this.icon
|
|
1092
|
+
&& this.group!.getObjectByName('poi_icon')
|
|
1093
|
+
&& !!this.iconInCircle === !!this.iconCircleMaterial
|
|
1094
|
+
) return;
|
|
1095
|
+
if (!Poi3D.ImageMaterialMap.has(src)) {
|
|
1096
|
+
Poi3D.ImageMaterialMap.set(src, 'dealing');
|
|
1097
|
+
const loader = new NS_THREE.TextureLoader();
|
|
1098
|
+
loader.load(src, (texture) => {
|
|
1099
|
+
texture.needsUpdate = true;
|
|
1100
|
+
texture.magFilter = NS_THREE.LinearFilter;
|
|
1101
|
+
texture.flipY = this.isFlipY;
|
|
1102
|
+
const material = new NS_THREE.MeshBasicMaterial({
|
|
1103
|
+
map: texture,
|
|
1104
|
+
transparent: true,
|
|
1105
|
+
opacity: this.iconOpacity,
|
|
1106
|
+
});
|
|
1107
|
+
material.needsUpdate = true;
|
|
1108
|
+
material.visible = true;
|
|
1109
|
+
Poi3D.ImageMaterialMap.set(src, material);
|
|
1110
|
+
});
|
|
1111
|
+
} else if (Poi3D.ImageMaterialMap.get(src) === 'dealing') {
|
|
1112
|
+
this.renderThisFrame = true;
|
|
1113
|
+
} else {
|
|
1114
|
+
if (this.icon) this.group!.remove(this.icon);
|
|
1115
|
+
this.iconMaterial = Poi3D.ImageMaterialMap.get(src).clone();
|
|
1116
|
+
this.iconMaterial!.opacity = this.iconOpacity;
|
|
1117
|
+
const { width: cWidth, color: cColor } = this.iconCircleOptions;
|
|
1118
|
+
const ifDrawCircle = cWidth && this.iconInCircle;
|
|
1119
|
+
if (ifDrawCircle) {
|
|
1120
|
+
this.iconCircleMaterial = new NS_THREE.MeshBasicMaterial({
|
|
1121
|
+
color: cColor,
|
|
1122
|
+
transparent: true,
|
|
1123
|
+
opacity: this.iconOpacity,
|
|
1124
|
+
});
|
|
1125
|
+
}
|
|
1126
|
+
const mats = ifDrawCircle ? [
|
|
1127
|
+
this.iconCircleMaterial as NS_THREE.Material,
|
|
1128
|
+
this.iconMaterial as NS_THREE.Material,
|
|
1129
|
+
] : [
|
|
1130
|
+
this.iconMaterial as NS_THREE.Material,
|
|
1131
|
+
];
|
|
1132
|
+
const iconGeo = ifDrawCircle ? new NS_THREE.CircleGeometry(size[0] / 2, 30) : new NS_THREE.PlaneGeometry(size[0], size[1]);
|
|
1133
|
+
const icon = SceneUtils.createMultiMaterialObject(
|
|
1134
|
+
iconGeo,
|
|
1135
|
+
mats,
|
|
1136
|
+
);
|
|
1137
|
+
this.icon = icon;
|
|
1138
|
+
if (this.icon) {
|
|
1139
|
+
// console.log('cWidth', size[0], cWidth);
|
|
1140
|
+
if (this.icon.children.length > 1) {
|
|
1141
|
+
this.icon!.children[1].scale.set(size[0] / (cWidth + size[0]), size[0] / (cWidth + size[0]), 1);
|
|
1142
|
+
}
|
|
1143
|
+
this.icon.renderOrder = 3;
|
|
1144
|
+
this.icon.name = 'poi_icon';
|
|
1145
|
+
this.group!.add(this.icon);
|
|
1146
|
+
this.renderThisFrame = true;
|
|
1147
|
+
}
|
|
1148
|
+
}
|
|
1149
|
+
}
|
|
1150
|
+
|
|
1151
|
+
private clearIcon(): void {
|
|
1152
|
+
if (!this.icon) return;
|
|
1153
|
+
if (this.group) {
|
|
1154
|
+
this.group.remove(this.icon);
|
|
1155
|
+
}
|
|
1156
|
+
this.icon.children.forEach((mesh: NS_THREE.Mesh) => {
|
|
1157
|
+
if (mesh.geometry) {
|
|
1158
|
+
mesh.geometry.dispose();
|
|
1159
|
+
}
|
|
1160
|
+
});
|
|
1161
|
+
if (this.iconMaterial) {
|
|
1162
|
+
this.iconMaterial.dispose();
|
|
1163
|
+
this.iconMaterial = null;
|
|
1164
|
+
}
|
|
1165
|
+
if (this.iconCircleMaterial) {
|
|
1166
|
+
this.iconCircleMaterial.dispose();
|
|
1167
|
+
this.iconCircleMaterial = null;
|
|
1168
|
+
}
|
|
1169
|
+
this.icon = null;
|
|
1170
|
+
}
|
|
1171
|
+
|
|
1172
|
+
/**
|
|
1173
|
+
* 设置图标相对(0,0)的位置
|
|
1174
|
+
* @param direction: x / y value: + / - 表示方向
|
|
1175
|
+
* x = 2 的时候, 表示label 中心 和 icon 中心 同一条y轴, label 右边框 距离 icon 左边框2个单位
|
|
1176
|
+
*/
|
|
1177
|
+
public setIconAnchor(
|
|
1178
|
+
anchor: 'center' | 'left' | 'right' | 'top' | 'bottom' | 'topleft' | 'topright' | 'bottomleft' | 'bottomright',
|
|
1179
|
+
): void {
|
|
1180
|
+
this.iconPosInfo.anchor = anchor;
|
|
1181
|
+
this.renderThisFrame = true;
|
|
1182
|
+
}
|
|
1183
|
+
|
|
1184
|
+
/**
|
|
1185
|
+
* 设置图标反转
|
|
1186
|
+
*/
|
|
1187
|
+
public setIconFlipY(flipY: boolean): void {
|
|
1188
|
+
this.isFlipY = flipY;
|
|
1189
|
+
}
|
|
1190
|
+
|
|
1191
|
+
public setIconOffset(x: number, y: number): void {
|
|
1192
|
+
this.iconPosInfo.anchorOffsetX = x;
|
|
1193
|
+
this.iconPosInfo.anchorOffsetY = y;
|
|
1194
|
+
this.renderThisFrame = true;
|
|
1195
|
+
}
|
|
1196
|
+
|
|
1197
|
+
/**
|
|
1198
|
+
* 设置文字字体大小
|
|
1199
|
+
* @param fontSize 字号, 单位为px
|
|
1200
|
+
*/
|
|
1201
|
+
public setFontSize(fontSize: number): void {
|
|
1202
|
+
this.labelOptions.fontSize = fontSize;
|
|
1203
|
+
this.renderThisFrame = true;
|
|
1204
|
+
}
|
|
1205
|
+
|
|
1206
|
+
public setFontPadding(fPadding: number): void {
|
|
1207
|
+
this.labelOptions.padding = fPadding;
|
|
1208
|
+
this.renderThisFrame = true;
|
|
1209
|
+
}
|
|
1210
|
+
|
|
1211
|
+
public setLabelText(text: string): void {
|
|
1212
|
+
this.labelOptions.content = text;
|
|
1213
|
+
this.renderThisFrame = true;
|
|
1214
|
+
}
|
|
1215
|
+
|
|
1216
|
+
public drawText(): void {
|
|
1217
|
+
if (!this.labelOptions.content) return;
|
|
1218
|
+
if (this.group!.getObjectByName('poi_text')) return;
|
|
1219
|
+
const dpr = this.dpr;
|
|
1220
|
+
const { fontSize, padding, content } = this.labelOptions;
|
|
1221
|
+
(Poi3DOverlay.ctx as CanvasRenderingContext2D).font = `${fontSize * dpr}px sans-serif`;
|
|
1222
|
+
(Poi3DOverlay.ctx as CanvasRenderingContext2D).fillStyle = 'black';
|
|
1223
|
+
const textSize = (Poi3DOverlay.ctx as CanvasRenderingContext2D).measureText(content as string);
|
|
1224
|
+
const textWidth = Math.ceil(textSize.width) + 10 + (padding * 2);
|
|
1225
|
+
const textHeight = (fontSize + 5 + (padding * 2)) * dpr;
|
|
1226
|
+
this.textWidth = textWidth / dpr;
|
|
1227
|
+
this.textHeight = textHeight / dpr;
|
|
1228
|
+
this.setRectDefSize(this.textWidth, this.textHeight); // 根据text占据位置自动设置rect大小
|
|
1229
|
+
(Poi3DOverlay.ctx as CanvasRenderingContext2D).clearRect(0, 0, textWidth, textHeight);
|
|
1230
|
+
(Poi3DOverlay.ctx as CanvasRenderingContext2D).fillText(content as string, padding * dpr, (fontSize + padding) * dpr);
|
|
1231
|
+
const textImageData = (Poi3DOverlay.ctx as CanvasRenderingContext2D).getImageData(0, 0, textWidth, textHeight);
|
|
1232
|
+
this.textMaterial = new NS_THREE.MeshBasicMaterial({
|
|
1233
|
+
transparent: true,
|
|
1234
|
+
map: new NS_THREE.DataTexture(
|
|
1235
|
+
Uint8Array.from(textImageData.data),
|
|
1236
|
+
textWidth,
|
|
1237
|
+
textHeight,
|
|
1238
|
+
NS_THREE.RGBAFormat,
|
|
1239
|
+
),
|
|
1240
|
+
side: NS_THREE.DoubleSide,
|
|
1241
|
+
opacity: this.labelOpacity,
|
|
1242
|
+
});
|
|
1243
|
+
this.text = new NS_THREE.Mesh(
|
|
1244
|
+
new NS_THREE.PlaneGeometry(this.textWidth, this.textHeight),
|
|
1245
|
+
this.textMaterial as NS_THREE.MeshBasicMaterial,
|
|
1246
|
+
);
|
|
1247
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1248
|
+
(this.text.material as any).map.flipY = true;
|
|
1249
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1250
|
+
(this.text.material as any).map.flipX = true;
|
|
1251
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1252
|
+
(this.text.material as any).map.needsUpdate = true;
|
|
1253
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1254
|
+
(this.text.material as any).map.magFilter = NS_THREE.LinearFilter;
|
|
1255
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1256
|
+
(this.text.material as any).visible = true;
|
|
1257
|
+
this.text.name = 'poi_text';
|
|
1258
|
+
this.text.renderOrder = 4;
|
|
1259
|
+
const {
|
|
1260
|
+
offsetX, offsetY,
|
|
1261
|
+
} = this.recalcOffset(
|
|
1262
|
+
this.textWidth,
|
|
1263
|
+
this.textHeight,
|
|
1264
|
+
this.textPosInfo.anchor,
|
|
1265
|
+
this.textPosInfo.anchorOffsetX,
|
|
1266
|
+
this.textPosInfo.anchorOffsetY,
|
|
1267
|
+
);
|
|
1268
|
+
this.textPosInfo.offsetX = offsetX;
|
|
1269
|
+
this.textPosInfo.offsetY = offsetY;
|
|
1270
|
+
this.group!.add(this.text);
|
|
1271
|
+
}
|
|
1272
|
+
|
|
1273
|
+
public recalcOffset(width: number,
|
|
1274
|
+
height: number,
|
|
1275
|
+
anchor: string,
|
|
1276
|
+
anchorOffsetX: number,
|
|
1277
|
+
anchorOffsetY: number): { offsetX: number; offsetY: number } {
|
|
1278
|
+
// 在已有text宽高情况下计算 textOffsetX 和 textOffsetY
|
|
1279
|
+
let offsetX = 0;
|
|
1280
|
+
let offsetY = 0;
|
|
1281
|
+
switch (anchor) {
|
|
1282
|
+
case 'center':
|
|
1283
|
+
// 默认
|
|
1284
|
+
offsetX = anchorOffsetX;
|
|
1285
|
+
offsetY = anchorOffsetY;
|
|
1286
|
+
break;
|
|
1287
|
+
case 'left':
|
|
1288
|
+
offsetX = width / 2 + anchorOffsetX;
|
|
1289
|
+
offsetY = anchorOffsetY;
|
|
1290
|
+
break;
|
|
1291
|
+
case 'right':
|
|
1292
|
+
offsetX = -width / 2 + anchorOffsetX;
|
|
1293
|
+
offsetY = anchorOffsetY;
|
|
1294
|
+
break;
|
|
1295
|
+
case 'top':
|
|
1296
|
+
offsetX = anchorOffsetX;
|
|
1297
|
+
offsetY = -height / 2 + anchorOffsetY;
|
|
1298
|
+
break;
|
|
1299
|
+
case 'bottom':
|
|
1300
|
+
offsetX = anchorOffsetX;
|
|
1301
|
+
offsetY = height / 2 + anchorOffsetY;
|
|
1302
|
+
break;
|
|
1303
|
+
case 'topleft':
|
|
1304
|
+
offsetX = width / 2 + anchorOffsetX;
|
|
1305
|
+
offsetY = -height / 2 + anchorOffsetY;
|
|
1306
|
+
break;
|
|
1307
|
+
case 'topright':
|
|
1308
|
+
offsetX = -width / 2 + anchorOffsetX;
|
|
1309
|
+
offsetY = -height / 2 + anchorOffsetY;
|
|
1310
|
+
break;
|
|
1311
|
+
case 'bottomleft':
|
|
1312
|
+
offsetX = width / 2 + anchorOffsetX;
|
|
1313
|
+
offsetY = height / 2 + anchorOffsetY;
|
|
1314
|
+
break;
|
|
1315
|
+
case 'bottomright':
|
|
1316
|
+
offsetX = -width / 2 + anchorOffsetX;
|
|
1317
|
+
offsetY = height / 2 + anchorOffsetY;
|
|
1318
|
+
break;
|
|
1319
|
+
default:
|
|
1320
|
+
break;
|
|
1321
|
+
}
|
|
1322
|
+
return { offsetX, offsetY };
|
|
1323
|
+
}
|
|
1324
|
+
|
|
1325
|
+
/**
|
|
1326
|
+
* 设置POI文字相对(0,0)的位置。在有icon 和 无icon时锚点不同
|
|
1327
|
+
* @param direction: x / y value: + / - 表示方向
|
|
1328
|
+
* x = 2 的时候, 表示label 中心 和 icon 中心 同一条y轴, label 右边框 距离 icon 左边框2个单位
|
|
1329
|
+
*/
|
|
1330
|
+
public setLabelAnchor(
|
|
1331
|
+
anchor: 'center' | 'left' | 'right' | 'top' | 'bottom' | 'topleft' | 'topright' | 'bottomleft' | 'bottomright',
|
|
1332
|
+
): void {
|
|
1333
|
+
// center label的锚点在 position
|
|
1334
|
+
// top position在label 上方线条的中心
|
|
1335
|
+
// left position在label 左边线条的中心
|
|
1336
|
+
this.textPosInfo.anchor = anchor;
|
|
1337
|
+
this.renderThisFrame = true;
|
|
1338
|
+
}
|
|
1339
|
+
|
|
1340
|
+
public setLabelOffset(x: number, y: number): void {
|
|
1341
|
+
this.textPosInfo.anchorOffsetX = x;
|
|
1342
|
+
this.textPosInfo.anchorOffsetY = y;
|
|
1343
|
+
this.renderThisFrame = true;
|
|
1344
|
+
}
|
|
1345
|
+
|
|
1346
|
+
public getLabelAnchor(): 'center' | 'left' | 'right' | 'top' | 'bottom' | 'topleft' | 'topright' | 'bottomleft' | 'bottomright' {
|
|
1347
|
+
return this.textPosInfo.anchor;
|
|
1348
|
+
}
|
|
1349
|
+
|
|
1350
|
+
public getLabelOffset(): { x: number; y: number } {
|
|
1351
|
+
const { anchorOffsetX, anchorOffsetY } = this.textPosInfo;
|
|
1352
|
+
return { x: anchorOffsetX, y: anchorOffsetY };
|
|
1353
|
+
}
|
|
1354
|
+
|
|
1355
|
+
calcBoundingSize(): void { // 2D画布上的 size
|
|
1356
|
+
const pos = this.screenPosition;
|
|
1357
|
+
const textOffsetX = this.textPosInfo.offsetX;
|
|
1358
|
+
const textOffsetY = this.textPosInfo.offsetY;
|
|
1359
|
+
|
|
1360
|
+
const iconOffsetX = this.iconPosInfo.offsetX;
|
|
1361
|
+
const iconOffsetY = this.iconPosInfo.offsetY;
|
|
1362
|
+
|
|
1363
|
+
const label = {
|
|
1364
|
+
xMin: this.text ? pos.x - this.textWidth / 2 + textOffsetX : pos.x,
|
|
1365
|
+
xMax: this.text ? pos.x + this.textWidth / 2 + textOffsetX : pos.x,
|
|
1366
|
+
yMin: this.text ? pos.y - this.textHeight / 2 - textOffsetY : pos.y,
|
|
1367
|
+
yMax: this.text ? pos.y + this.textHeight / 2 - textOffsetY : pos.y,
|
|
1368
|
+
};
|
|
1369
|
+
|
|
1370
|
+
const icon = {
|
|
1371
|
+
xMin: this.icon ? pos.x - this.iconOptions.size[0] / 2 + iconOffsetX : pos.x,
|
|
1372
|
+
xMax: this.icon ? pos.x + this.iconOptions.size[0] / 2 + iconOffsetX : pos.x,
|
|
1373
|
+
yMin: this.icon ? pos.y - this.iconOptions.size[1] / 2 - iconOffsetY : pos.y,
|
|
1374
|
+
yMax: this.icon ? pos.y + this.iconOptions.size[1] / 2 - iconOffsetY : pos.y,
|
|
1375
|
+
};
|
|
1376
|
+
|
|
1377
|
+
let xMax = Math.max(icon.xMax, label.xMax);
|
|
1378
|
+
let xMin = Math.min(icon.xMin, label.xMin);
|
|
1379
|
+
let yMax = Math.max(icon.yMax, label.yMax);
|
|
1380
|
+
let yMin = Math.min(icon.yMin, label.yMin);
|
|
1381
|
+
|
|
1382
|
+
this.iconRect = {
|
|
1383
|
+
xMin: this.icon ? pos.x - this.iconOptions.size[0] / 2 + iconOffsetX : pos.x,
|
|
1384
|
+
xMax: this.icon ? pos.x + this.iconOptions.size[0] / 2 + iconOffsetX : pos.x,
|
|
1385
|
+
yMin: this.icon ? pos.y - this.iconOptions.size[1] / 2 - iconOffsetY : pos.y,
|
|
1386
|
+
yMax: this.icon ? pos.y + this.iconOptions.size[1] / 2 - iconOffsetY : pos.y,
|
|
1387
|
+
};
|
|
1388
|
+
|
|
1389
|
+
this.textRect = {
|
|
1390
|
+
xMin: this.text ? pos.x - this.textWidth / 2 + textOffsetX : pos.x,
|
|
1391
|
+
xMax: this.text ? pos.x + this.textWidth / 2 + textOffsetX : pos.x,
|
|
1392
|
+
yMin: this.text ? pos.y - this.textHeight / 2 - textOffsetY : pos.y,
|
|
1393
|
+
yMax: this.text ? pos.y + this.textHeight / 2 - textOffsetY : pos.y,
|
|
1394
|
+
};
|
|
1395
|
+
this.outerRect = {
|
|
1396
|
+
xMax, xMin, yMax, yMin,
|
|
1397
|
+
};
|
|
1398
|
+
if (this.collisionMode === 'icon') {
|
|
1399
|
+
xMax = icon.xMax;
|
|
1400
|
+
xMin = icon.xMin;
|
|
1401
|
+
yMax = icon.yMax;
|
|
1402
|
+
yMin = icon.yMin;
|
|
1403
|
+
} else if (this.collisionMode === 'label') {
|
|
1404
|
+
xMax = label.xMax;
|
|
1405
|
+
xMin = label.xMin;
|
|
1406
|
+
yMax = label.yMax;
|
|
1407
|
+
yMin = label.yMin;
|
|
1408
|
+
}
|
|
1409
|
+
// 得到 x 的 最大(> 0)和最小(< 0), y 的 最大(>0)和最小(<0)
|
|
1410
|
+
this.boundingRect.xMax = xMax;
|
|
1411
|
+
this.boundingRect.yMax = yMax;
|
|
1412
|
+
this.boundingRect.xMin = xMin;
|
|
1413
|
+
this.boundingRect.yMin = yMin;
|
|
1414
|
+
}
|
|
1415
|
+
|
|
1416
|
+
private drawRect(): void {
|
|
1417
|
+
if (!this.withRect || !this.labelOptions.content) return;
|
|
1418
|
+
if (this.rect && this.group!.getObjectByName('poi_rect')) return;
|
|
1419
|
+
this.rect = new NS_THREE.Group();
|
|
1420
|
+
const rWidth = this.rectOptions.width || this.textWidth;
|
|
1421
|
+
const rHeight = this.rectOptions.height || this.textHeight;
|
|
1422
|
+
const cornerR = 10;
|
|
1423
|
+
const x = 0;
|
|
1424
|
+
const y = 0;
|
|
1425
|
+
const rightT1 = [x + rWidth / 2 - cornerR, y + rHeight / 2];
|
|
1426
|
+
const rightT2 = [x + rWidth / 2, y + rHeight / 2 - cornerR];
|
|
1427
|
+
const rightB1 = [x + rWidth / 2, y - rHeight / 2 + cornerR];
|
|
1428
|
+
const rightB2 = [x + rWidth / 2 - cornerR, y - rHeight / 2];
|
|
1429
|
+
const leftB1 = [x - rWidth / 2 + cornerR, y - rHeight / 2];
|
|
1430
|
+
const leftB2 = [x - rWidth / 2, y - rHeight / 2 + cornerR];
|
|
1431
|
+
const leftT1 = [x - rWidth / 2, y + rHeight / 2 - cornerR];
|
|
1432
|
+
const leftT2 = [x - rWidth / 2 + cornerR, y + rHeight / 2];
|
|
1433
|
+
const rectShape = new NS_THREE.Shape();
|
|
1434
|
+
rectShape.moveTo(rightT1[0], rightT1[1]);
|
|
1435
|
+
rectShape.bezierCurveTo(rightT1[0], rightT1[1], x + rWidth / 2, y + rHeight / 2, rightT2[0], rightT2[1]);
|
|
1436
|
+
rectShape.moveTo(rightB1[0], rightB1[1]);
|
|
1437
|
+
rectShape.bezierCurveTo(rightB1[0], rightB1[1], x + rWidth / 2, y - rHeight / 2, rightB2[0], rightB2[1]);
|
|
1438
|
+
rectShape.moveTo(leftB1[0], leftB1[1]);
|
|
1439
|
+
rectShape.bezierCurveTo(leftB1[0], leftB1[1], x - rWidth / 2, y - rHeight / 2, leftB2[0], leftB2[1]);
|
|
1440
|
+
rectShape.moveTo(leftT1[0], leftT1[1]);
|
|
1441
|
+
rectShape.bezierCurveTo(leftT1[0], leftT1[1], x - rWidth / 2, y + rHeight / 2, leftT2[0], leftT2[1]);
|
|
1442
|
+
rectShape.moveTo(rightT1[0], rightT1[1]);
|
|
1443
|
+
const geometry = new NS_THREE.ShapeGeometry(rectShape);
|
|
1444
|
+
const material = new NS_THREE.MeshBasicMaterial({
|
|
1445
|
+
color: 0x0000ff,
|
|
1446
|
+
transparent: true,
|
|
1447
|
+
opacity: 0.5,
|
|
1448
|
+
});
|
|
1449
|
+
this.rectMaterial = material;
|
|
1450
|
+
const mesh = new NS_THREE.Mesh(geometry, material);
|
|
1451
|
+
rectShape.autoClose = true;
|
|
1452
|
+
const points = rectShape.getPoints();
|
|
1453
|
+
const geometryPoints = new NS_THREE.BufferGeometry().setFromPoints(points);
|
|
1454
|
+
const line = new NS_THREE.Line(geometryPoints, new NS_THREE.LineBasicMaterial({ color: 0xff0000 }));
|
|
1455
|
+
line.position.set(0, 0, 0);
|
|
1456
|
+
this.rect.add(mesh);
|
|
1457
|
+
this.rect.add(line);
|
|
1458
|
+
this.rect.renderOrder = 2;
|
|
1459
|
+
this.rect.name = 'poi_rect';
|
|
1460
|
+
this.group!.add(this.rect);
|
|
1461
|
+
}
|
|
1462
|
+
|
|
1463
|
+
private drawBoundingBox(): void {
|
|
1464
|
+
if (!this.withBoundingBox) return;
|
|
1465
|
+
if (this.group!.getObjectByName('poi_bounding_rect')) return;
|
|
1466
|
+
if (this.outerRect.xMin === 0 && this.outerRect.xMax === 0) return;
|
|
1467
|
+
const {
|
|
1468
|
+
xMax, yMax, xMin, yMin,
|
|
1469
|
+
} = this.outerRect;
|
|
1470
|
+
this.boundingBox = new NS_THREE.Group();
|
|
1471
|
+
const cornerR = 10;
|
|
1472
|
+
const x = 0;
|
|
1473
|
+
const y = 0;
|
|
1474
|
+
const width = xMax - xMin;
|
|
1475
|
+
const height = yMax - yMin;
|
|
1476
|
+
const rightT1 = [x + width / 2 - cornerR, y + height / 2];
|
|
1477
|
+
const rightT2 = [x + width / 2, y + height / 2 - cornerR];
|
|
1478
|
+
const rightB1 = [x + width / 2, y - height / 2 + cornerR];
|
|
1479
|
+
const rightB2 = [x + width / 2 - cornerR, y - height / 2];
|
|
1480
|
+
const leftB1 = [x - width / 2 + cornerR, y - height / 2];
|
|
1481
|
+
const leftB2 = [x - width / 2, y - height / 2 + cornerR];
|
|
1482
|
+
const leftT1 = [x - width / 2, y + height / 2 - cornerR];
|
|
1483
|
+
const leftT2 = [x - width / 2 + cornerR, y + height / 2];
|
|
1484
|
+
const rectShape = new NS_THREE.Shape();
|
|
1485
|
+
rectShape.moveTo(rightT1[0], rightT1[1]);
|
|
1486
|
+
rectShape.bezierCurveTo(rightT1[0], rightT1[1], x + width / 2, y + height / 2, rightT2[0], rightT2[1]);
|
|
1487
|
+
rectShape.moveTo(rightB1[0], rightB1[1]);
|
|
1488
|
+
rectShape.bezierCurveTo(rightB1[0], rightB1[1], x + width / 2, y - height / 2, rightB2[0], rightB2[1]);
|
|
1489
|
+
rectShape.moveTo(leftB1[0], leftB1[1]);
|
|
1490
|
+
rectShape.bezierCurveTo(leftB1[0], leftB1[1], x - width / 2, y - height / 2, leftB2[0], leftB2[1]);
|
|
1491
|
+
rectShape.moveTo(leftT1[0], leftT1[1]);
|
|
1492
|
+
rectShape.bezierCurveTo(leftT1[0], leftT1[1], x - width / 2, y + height / 2, leftT2[0], leftT2[1]);
|
|
1493
|
+
rectShape.moveTo(rightT1[0], rightT1[1]);
|
|
1494
|
+
const geometry = new NS_THREE.ShapeGeometry(rectShape);
|
|
1495
|
+
const material = new NS_THREE.MeshBasicMaterial({
|
|
1496
|
+
color: 0xff0000,
|
|
1497
|
+
transparent: true,
|
|
1498
|
+
opacity: 0.5,
|
|
1499
|
+
});
|
|
1500
|
+
const mesh = new NS_THREE.Mesh(geometry, material);
|
|
1501
|
+
rectShape.autoClose = true;
|
|
1502
|
+
const points = rectShape.getPoints();
|
|
1503
|
+
const geometryPoints = new NS_THREE.BufferGeometry().setFromPoints(points);
|
|
1504
|
+
const line = new NS_THREE.Line(geometryPoints, new NS_THREE.LineBasicMaterial({ color: 0xff0000, linewidth: 2 }));
|
|
1505
|
+
line.position.set(0, 0, 0);
|
|
1506
|
+
this.boundingBox.name = 'poi_bounding_rect';
|
|
1507
|
+
this.boundingBox.add(mesh);
|
|
1508
|
+
this.boundingBox.add(line);
|
|
1509
|
+
this.boundingBox.renderOrder = 0;
|
|
1510
|
+
this.group!.add(this.boundingBox);
|
|
1511
|
+
}
|
|
1512
|
+
|
|
1513
|
+
public setBoundingBox(): void {
|
|
1514
|
+
this.withBoundingBox = true;
|
|
1515
|
+
}
|
|
1516
|
+
|
|
1517
|
+
/** @ignore */
|
|
1518
|
+
public getBoundingRect(): { xMin: number; yMin: number; xMax: number; yMax: number } {
|
|
1519
|
+
const { x: ox, y: oy } = this.overlapArea;
|
|
1520
|
+
const {
|
|
1521
|
+
xMin: xmin, yMin: ymin, xMax: xmax, yMax: ymax,
|
|
1522
|
+
} = this.boundingRect;
|
|
1523
|
+
return {
|
|
1524
|
+
xMin: xmin + ox,
|
|
1525
|
+
yMin: ymin + oy,
|
|
1526
|
+
xMax: xmax - ox,
|
|
1527
|
+
yMax: ymax - oy,
|
|
1528
|
+
};
|
|
1529
|
+
}
|
|
1530
|
+
|
|
1531
|
+
/** @ignore */
|
|
1532
|
+
public getOuterRect(): { xMin: number; yMin: number; xMax: number; yMax: number } {
|
|
1533
|
+
const { x: ox, y: oy } = this.overlapArea;
|
|
1534
|
+
const {
|
|
1535
|
+
xMin: xmin, yMin: ymin, xMax: xmax, yMax: ymax,
|
|
1536
|
+
} = this.outerRect;
|
|
1537
|
+
return {
|
|
1538
|
+
xMin: xmin + ox,
|
|
1539
|
+
yMin: ymin + oy,
|
|
1540
|
+
xMax: xmax - ox,
|
|
1541
|
+
yMax: ymax - oy,
|
|
1542
|
+
};
|
|
1543
|
+
}
|
|
1544
|
+
|
|
1545
|
+
public setAnimationEnabled(value: boolean): void {
|
|
1546
|
+
this.animationEnabled = value;
|
|
1547
|
+
}
|
|
1548
|
+
|
|
1549
|
+
// 获取旋转角度
|
|
1550
|
+
private calcPoiRotation(cameraDeg: number): number {
|
|
1551
|
+
if (this.autoRotation) {
|
|
1552
|
+
return cameraDeg + this.rotation;
|
|
1553
|
+
}
|
|
1554
|
+
return this.rotation;
|
|
1555
|
+
}
|
|
1556
|
+
|
|
1557
|
+
public getVisibility(): boolean {
|
|
1558
|
+
return this.visible;
|
|
1559
|
+
}
|
|
1560
|
+
|
|
1561
|
+
public calcPosAndSize(frustum: NS_THREE.Frustum, widthHalf: number, heightHalf: number): { isInFrustum: boolean } { // 重新计算位置和包围盒/ 不现实的话不推入rectMap
|
|
1562
|
+
if (!this.parent) {
|
|
1563
|
+
return { isInFrustum: this.isInFrustum };
|
|
1564
|
+
}
|
|
1565
|
+
let isInFrustum = this.visible && frustum.containsPoint(this.position);
|
|
1566
|
+
if (isInFrustum) {
|
|
1567
|
+
const p = this.position.clone().project(this.parent!.camera);
|
|
1568
|
+
this.screenPosition = { x: (p.x + 1) * widthHalf, y: (1 - p.y) * heightHalf };
|
|
1569
|
+
this.calcBoundingSize();
|
|
1570
|
+
// 计算与view是否相交
|
|
1571
|
+
if (this.outerRect.xMin < 0 || this.outerRect.xMax > widthHalf * 2 || this.outerRect.yMin < 0 || this.outerRect.yMax > heightHalf * 2) {
|
|
1572
|
+
isInFrustum = false;
|
|
1573
|
+
}
|
|
1574
|
+
}
|
|
1575
|
+
this.isInFrustum = isInFrustum;
|
|
1576
|
+
return {
|
|
1577
|
+
isInFrustum: this.isInFrustum,
|
|
1578
|
+
};
|
|
1579
|
+
}
|
|
1580
|
+
|
|
1581
|
+
|
|
1582
|
+
public draw(): void {
|
|
1583
|
+
this.drawText();
|
|
1584
|
+
this.drawIcon();
|
|
1585
|
+
this.drawRect();
|
|
1586
|
+
this.drawBoundingBox();
|
|
1587
|
+
}
|
|
1588
|
+
|
|
1589
|
+
public updatePosition( // 根据已计算出的position, offset, visible 等更新渲染位置, 显隐
|
|
1590
|
+
euler: Euler,
|
|
1591
|
+
zoom: number,
|
|
1592
|
+
): void {
|
|
1593
|
+
if (!this.group) return;
|
|
1594
|
+
if (!this.isInFrustum) {
|
|
1595
|
+
this.hide = true;
|
|
1596
|
+
this.subHide = false;
|
|
1597
|
+
this.group!.visible = false;
|
|
1598
|
+
return;
|
|
1599
|
+
}
|
|
1600
|
+
|
|
1601
|
+
this.group!.visible = this.visible;
|
|
1602
|
+
if (!this.visible) {
|
|
1603
|
+
return;
|
|
1604
|
+
}
|
|
1605
|
+
const textOffsetX = this.textPosInfo.offsetX;
|
|
1606
|
+
const textOffsetY = this.textPosInfo.offsetY;
|
|
1607
|
+
const iconOffsetX = this.iconPosInfo.offsetX;
|
|
1608
|
+
const iconOffsetY = this.iconPosInfo.offsetY;
|
|
1609
|
+
const position = new Vector3().copy(this.position);
|
|
1610
|
+
// poi要沿着X轴旋转90度之后会立起来,z值需要做相应调整
|
|
1611
|
+
position.z += this.iconSize[1] / 2;
|
|
1612
|
+
this.group.position.copy(position);
|
|
1613
|
+
this.group.rotation.copy(euler);
|
|
1614
|
+
this.group.scale.copy(new Vector3(1 / zoom, 1 / zoom, 1));
|
|
1615
|
+
if (zoom < 1) {
|
|
1616
|
+
// poi 放大了 需要往上移动
|
|
1617
|
+
position.z += (this.iconSize[1] * (1 - zoom)) / 2;
|
|
1618
|
+
} else {
|
|
1619
|
+
position.z -= (this.iconSize[1] * (1 - 1 / zoom)) / 2;
|
|
1620
|
+
}
|
|
1621
|
+
this.group.position.copy(position);
|
|
1622
|
+
|
|
1623
|
+
if (this.text) {
|
|
1624
|
+
this.text.position.set(textOffsetX, textOffsetY, 0);
|
|
1625
|
+
}
|
|
1626
|
+
if (this.rect) {
|
|
1627
|
+
this.rect.position.set(textOffsetX, textOffsetY, 0);
|
|
1628
|
+
}
|
|
1629
|
+
if (this.icon) {
|
|
1630
|
+
this.icon.position.set(iconOffsetX, iconOffsetY, 0);
|
|
1631
|
+
}
|
|
1632
|
+
if (this.boundingBox) {
|
|
1633
|
+
const pos2dx = (this.outerRect.xMax + this.outerRect.xMin) / 2;
|
|
1634
|
+
const pos2dy = (this.outerRect.yMax + this.outerRect.yMin) / 2;
|
|
1635
|
+
this.boundingBox.position.set(pos2dx - this.screenPosition.x, this.screenPosition.y - pos2dy, 0);
|
|
1636
|
+
}
|
|
1637
|
+
|
|
1638
|
+
const animating = this.visibilityAnimation.anim; // onComplete 时候会销毁
|
|
1639
|
+
const groupVisible = !!animating || (!animating && (!this.hide || this.subHide));
|
|
1640
|
+
this.group!.visible = groupVisible;
|
|
1641
|
+
// console.log('groupVisible', groupVisible, !this.hide, this.subHide, (!this.hide || this.subHide));
|
|
1642
|
+
// subArea 和 abandonedArea 的展示
|
|
1643
|
+
// 1- 根据碰撞检测结果和碰撞类型判断group icon text 的显示
|
|
1644
|
+
// 2- 上一步通过, 则判断 当前是否设置了 iconVisibility 和 textVisibility
|
|
1645
|
+
if (groupVisible && (!animating || !this.animationEnabled)) { // 显示 && 动画执行完 || 无设置动画效果
|
|
1646
|
+
let subAreas: Array<NS_THREE.Mesh | NS_THREE.Group> = [];
|
|
1647
|
+
let abandonedAreas: Array<NS_THREE.Mesh | NS_THREE.Group> = [];
|
|
1648
|
+
switch (this.visiblePartWhenCollision) {
|
|
1649
|
+
case 'all':
|
|
1650
|
+
subAreas = [this.group!];
|
|
1651
|
+
abandonedAreas = [];
|
|
1652
|
+
break;
|
|
1653
|
+
case 'none':
|
|
1654
|
+
subAreas = [];
|
|
1655
|
+
abandonedAreas = [this.group!];
|
|
1656
|
+
break;
|
|
1657
|
+
case 'label':
|
|
1658
|
+
subAreas = [];
|
|
1659
|
+
if (this.text) {
|
|
1660
|
+
subAreas.push(this.text);
|
|
1661
|
+
}
|
|
1662
|
+
if (this.rect) {
|
|
1663
|
+
subAreas.push(this.rect);
|
|
1664
|
+
}
|
|
1665
|
+
if (this.icon) {
|
|
1666
|
+
abandonedAreas.push(this.icon);
|
|
1667
|
+
}
|
|
1668
|
+
break;
|
|
1669
|
+
case 'icon':
|
|
1670
|
+
if (this.icon) {
|
|
1671
|
+
subAreas.push(this.icon);
|
|
1672
|
+
}
|
|
1673
|
+
if (this.text) {
|
|
1674
|
+
abandonedAreas.push(this.text);
|
|
1675
|
+
}
|
|
1676
|
+
if (this.rect) {
|
|
1677
|
+
abandonedAreas.push(this.rect);
|
|
1678
|
+
}
|
|
1679
|
+
break;
|
|
1680
|
+
default:
|
|
1681
|
+
subAreas = [];
|
|
1682
|
+
abandonedAreas = [this.group!];
|
|
1683
|
+
break;
|
|
1684
|
+
}
|
|
1685
|
+
if (this.subHide) { // 部分显示
|
|
1686
|
+
subAreas.forEach((area: NS_THREE.Mesh | NS_THREE.Group) => {
|
|
1687
|
+
area.visible = true;
|
|
1688
|
+
if (area instanceof NS_THREE.Group) {
|
|
1689
|
+
area.children.forEach((child: NS_THREE.Mesh) => {
|
|
1690
|
+
child.visible = true;
|
|
1691
|
+
});
|
|
1692
|
+
}
|
|
1693
|
+
});
|
|
1694
|
+
abandonedAreas.forEach((area: NS_THREE.Mesh | NS_THREE.Group) => {
|
|
1695
|
+
area.visible = false;
|
|
1696
|
+
if (area instanceof NS_THREE.Group) {
|
|
1697
|
+
area.children.forEach((child: NS_THREE.Mesh) => {
|
|
1698
|
+
child.visible = false;
|
|
1699
|
+
});
|
|
1700
|
+
}
|
|
1701
|
+
});
|
|
1702
|
+
} else if (!this.hide) { // 全部显示
|
|
1703
|
+
subAreas.forEach((area: NS_THREE.Mesh | NS_THREE.Group) => {
|
|
1704
|
+
area.visible = true;
|
|
1705
|
+
if (area instanceof NS_THREE.Group) {
|
|
1706
|
+
area.children.forEach((child: NS_THREE.Mesh) => {
|
|
1707
|
+
child.visible = true;
|
|
1708
|
+
});
|
|
1709
|
+
}
|
|
1710
|
+
});
|
|
1711
|
+
abandonedAreas.forEach((area: NS_THREE.Mesh | NS_THREE.Group) => {
|
|
1712
|
+
area.visible = true;
|
|
1713
|
+
if (area instanceof NS_THREE.Group) {
|
|
1714
|
+
area.children.forEach((child: NS_THREE.Mesh) => {
|
|
1715
|
+
child.visible = true;
|
|
1716
|
+
});
|
|
1717
|
+
}
|
|
1718
|
+
});
|
|
1719
|
+
}
|
|
1720
|
+
if (this.icon && !this.iconVisibility) { // 独立设置了icon不允许显示
|
|
1721
|
+
this.icon.visible = false;
|
|
1722
|
+
}
|
|
1723
|
+
if (this.text && !this.textVisibility) { // 独立设置了text不允许显示
|
|
1724
|
+
this.text.visible = false;
|
|
1725
|
+
}
|
|
1726
|
+
}
|
|
1727
|
+
if (!groupVisible) {
|
|
1728
|
+
// do nothing
|
|
1729
|
+
} else if (this.subHide) {
|
|
1730
|
+
if (this.parent) {
|
|
1731
|
+
// 部分显示
|
|
1732
|
+
if (this.visiblePartWhenCollision === 'icon') {
|
|
1733
|
+
this.parent!.setRectMap(this.iconRect, this);
|
|
1734
|
+
} else {
|
|
1735
|
+
this.parent!.setRectMap(this.textRect, this);
|
|
1736
|
+
}
|
|
1737
|
+
}
|
|
1738
|
+
} else if (this.parent) {
|
|
1739
|
+
// fix: poi-click 不触发
|
|
1740
|
+
this.parent.setRectMap(this.textRect, this);
|
|
1741
|
+
this.parent.setRectMap(this.iconRect, this);
|
|
1742
|
+
}
|
|
1743
|
+
|
|
1744
|
+
// this.renderThisFrame = true;
|
|
1745
|
+
}
|
|
1746
|
+
|
|
1747
|
+
public update(): boolean {
|
|
1748
|
+
const needRender = this.renderThisFrame || (this.isInFrustum && !!this.iconOptions.src && !this.icon);
|
|
1749
|
+
this.renderThisFrame = false;
|
|
1750
|
+
return needRender;
|
|
1751
|
+
}
|
|
1752
|
+
|
|
1753
|
+
public setPoiId(poiId: number): void {
|
|
1754
|
+
this.poiId = poiId;
|
|
1755
|
+
}
|
|
1756
|
+
}
|
|
1757
|
+
Poi3D.ImageMaterialMap = new Map();
|
|
1758
|
+
|
|
1759
|
+
export { Poi3DOverlay, Poi3D };
|