@realsee/dnalogel 2.0.0-alpha.8 → 2.0.0-alpha.9
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/CHANGELOG.md +3 -0
- package/dist/CSS3DRenderPlugin/index.d.ts +49 -0
- package/dist/CSS3DRenderPlugin/index.js +233 -0
- package/dist/CSS3DRenderPlugin/utils/createResizeObserver.d.ts +7 -0
- package/dist/CameraMovementPlugin/index.d.ts +7 -0
- package/dist/CameraMovementPlugin/index.js +302 -0
- package/dist/CameraMovementPlugin/typing.d.ts +68 -0
- package/dist/ModelChassisCompassPlugin/index.d.ts +19 -0
- package/dist/ModelChassisCompassPlugin/index.js +142 -0
- package/dist/ModelEntryDoorGuidePlugin/index.d.ts +26 -0
- package/dist/ModelEntryDoorGuidePlugin/index.js +196 -0
- package/dist/ModelRoomLabelPlugin/Assets/roomLabelBg.d.ts +1 -0
- package/dist/ModelRoomLabelPlugin/Controller.d.ts +36 -0
- package/dist/ModelRoomLabelPlugin/index.d.ts +12 -0
- package/dist/ModelRoomLabelPlugin/index.js +461 -0
- package/dist/ModelRoomLabelPlugin/typings.d.ts +35 -0
- package/dist/ModelRoomLabelPlugin/utils/parseData.d.ts +3 -0
- package/dist/ModelViewPlugin/index.d.ts +17 -0
- package/dist/ModelViewPlugin/index.js +187 -0
- package/dist/PanoCompassPlugin/Assets/roomInfoIcon.d.ts +1 -0
- package/dist/PanoCompassPlugin/getRoomInfoInstance.d.ts +8 -0
- package/dist/PanoCompassPlugin/index.d.ts +51 -0
- package/dist/PanoCompassPlugin/index.js +523 -0
- package/dist/PanoCursorRaycasterPlugin/index.d.ts +48 -0
- package/dist/PanoCursorRaycasterPlugin/index.js +88 -0
- package/dist/PanoMeasurePlugin/Controller/BaseController.d.ts +36 -0
- package/dist/PanoMeasurePlugin/Controller/EditController.d.ts +52 -0
- package/dist/PanoMeasurePlugin/Controller/ShortcutKeyController.d.ts +12 -0
- package/dist/PanoMeasurePlugin/Controller/WatchController.d.ts +25 -0
- package/dist/PanoMeasurePlugin/Controller/index.d.ts +61 -0
- package/dist/PanoMeasurePlugin/Model/index.d.ts +38 -0
- package/dist/PanoMeasurePlugin/Model/line.d.ts +30 -0
- package/dist/PanoMeasurePlugin/Model/point.d.ts +16 -0
- package/dist/PanoMeasurePlugin/Model/polyline.d.ts +16 -0
- package/dist/PanoMeasurePlugin/Modules/DeleteDom/_Assets/delete.svg.d.ts +2 -0
- package/dist/PanoMeasurePlugin/Modules/DeleteDom/_Assets/delete_bg.png.d.ts +2 -0
- package/dist/PanoMeasurePlugin/Modules/DeleteDom/_Assets/delete_hover_bg.png.d.ts +2 -0
- package/dist/PanoMeasurePlugin/Modules/DeleteDom/index.d.ts +22 -0
- package/dist/PanoMeasurePlugin/Modules/FiveHelper.d.ts +11 -0
- package/dist/PanoMeasurePlugin/Modules/GuideController.d.ts +18 -0
- package/dist/PanoMeasurePlugin/Modules/Magnifier.d.ts +24 -0
- package/dist/PanoMeasurePlugin/Modules/UIController/HTML.d.ts +6 -0
- package/dist/PanoMeasurePlugin/Modules/UIController/MainBtnController.d.ts +18 -0
- package/dist/PanoMeasurePlugin/Modules/UIController/Revoke/index.d.ts +12 -0
- package/dist/PanoMeasurePlugin/Modules/UIController/index.d.ts +16 -0
- package/dist/PanoMeasurePlugin/Modules/UIController/style.d.ts +17 -0
- package/dist/PanoMeasurePlugin/index.d.ts +7 -0
- package/dist/PanoMeasurePlugin/index.js +4789 -0
- package/dist/PanoMeasurePlugin/typings/data.d.ts +28 -0
- package/dist/PanoMeasurePlugin/typings/event.type.d.ts +28 -0
- package/dist/PanoMeasurePlugin/typings/utils.type.d.ts +1 -0
- package/dist/PanoMeasurePlugin/utils/clearGroup.d.ts +2 -0
- package/dist/PanoMeasurePlugin/utils/constants.d.ts +4 -0
- package/dist/PanoMeasurePlugin/utils/distanceDom.d.ts +28 -0
- package/dist/PanoMeasurePlugin/utils/findAssociatedLines.d.ts +2 -0
- package/dist/PanoMeasurePlugin/utils/findClosestPoint.d.ts +10 -0
- package/dist/PanoMeasurePlugin/utils/getIntersectionFromEvent.d.ts +4 -0
- package/dist/PanoMeasurePlugin/utils/getPointFromHammerEvent.d.ts +10 -0
- package/dist/PanoMeasurePlugin/utils/ironbox.d.ts +1 -0
- package/dist/PanoMeasurePlugin/utils/isNDCPointInScreen.d.ts +2 -0
- package/dist/PanoMeasurePlugin/utils/line.d.ts +17 -0
- package/dist/PanoMeasurePlugin/utils/math.d.ts +17 -0
- package/dist/PanoMeasurePlugin/utils/mouseGroup.d.ts +2 -0
- package/dist/PanoMeasurePlugin/utils/ndc2Screen.d.ts +5 -0
- package/dist/PanoRulerPlugin/index.d.ts +31 -0
- package/dist/PanoRulerPlugin/index.js +610 -0
- package/dist/PanoRulerPlugin/style.d.ts +2 -0
- package/dist/PanoRulerPlugin/typings.d.ts +21 -0
- package/dist/floorplan/Assets/camera.d.ts +1 -0
- package/dist/floorplan/Assets/floorplanExtraObject.d.ts +1 -0
- package/dist/floorplan/ModelFloorplanPlugin/Assets/compass.d.ts +1 -0
- package/dist/floorplan/ModelFloorplanPlugin/Controller.d.ts +104 -0
- package/dist/floorplan/ModelFloorplanPlugin/index.d.ts +9 -0
- package/dist/floorplan/ModelFloorplanPlugin/index.js +3827 -0
- package/dist/floorplan/ModelFloorplanPlugin/typings/events.type.d.ts +23 -0
- package/dist/floorplan/ModelFloorplanPlugin/utils/constant.d.ts +15 -0
- package/dist/floorplan/ModelFloorplanPlugin/utils/correctFiveState.d.ts +14 -0
- package/dist/floorplan/PanoFloorplanRadarPlugin/Controller.d.ts +28 -0
- package/dist/floorplan/PanoFloorplanRadarPlugin/index.d.ts +8 -0
- package/dist/floorplan/PanoFloorplanRadarPlugin/index.js +1673 -0
- package/dist/floorplan/TopviewFloorplanPlugin/Controller.d.ts +61 -0
- package/dist/floorplan/TopviewFloorplanPlugin/index.d.ts +5 -0
- package/dist/floorplan/TopviewFloorplanPlugin/index.js +3466 -0
- package/dist/floorplan/TopviewFloorplanPlugin/style.d.ts +1 -0
- package/dist/floorplan/constant.d.ts +5 -0
- package/dist/floorplan/typings/floorplanData.d.ts +137 -0
- package/dist/floorplan/typings/floorplanServerData.d.ts +131 -0
- package/dist/floorplan/typings/utility.d.ts +2 -0
- package/dist/floorplan/utils/formatData.d.ts +5 -0
- package/dist/floorplan/utils/formatPosition.d.ts +36 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.es.js +11887 -0
- package/dist/index.js +11925 -0
- package/dist/index.umd.js +11920 -0
- package/dist/shared-utils/Preloader.d.ts +6 -0
- package/dist/shared-utils/Subscribe.d.ts +45 -0
- package/dist/shared-utils/animationFrame/BetterTween.d.ts +11 -0
- package/dist/shared-utils/animationFrame/calculateProgress.d.ts +8 -0
- package/dist/shared-utils/animationFrame/formatRad.d.ts +15 -0
- package/dist/shared-utils/animationFrame/index.d.ts +15 -0
- package/dist/shared-utils/animationFrame/tween.d.ts +75 -0
- package/dist/shared-utils/changeModelCanvasOpacity.d.ts +2 -0
- package/dist/shared-utils/createCanvasTextTexture.d.ts +8 -0
- package/dist/shared-utils/createLine/index.d.ts +3 -0
- package/dist/shared-utils/debounce.d.ts +6 -0
- package/dist/shared-utils/equal.d.ts +11 -0
- package/dist/shared-utils/filter.d.ts +27 -0
- package/dist/shared-utils/five/changeMode.d.ts +2 -0
- package/dist/shared-utils/five/useFivePlugin.d.ts +1 -0
- package/dist/shared-utils/formatRad.d.ts +7 -0
- package/dist/shared-utils/getPxmm.d.ts +11 -0
- package/dist/shared-utils/getRandomColor.d.ts +1 -0
- package/dist/shared-utils/isNil.d.ts +10 -0
- package/dist/shared-utils/isTruelyObject.d.ts +18 -0
- package/dist/shared-utils/math/evenNumber.d.ts +3 -0
- package/dist/shared-utils/math/planimetry.d.ts +116 -0
- package/dist/shared-utils/math/rad2Deg.d.ts +1 -0
- package/dist/shared-utils/nearlyEqual.d.ts +7 -0
- package/dist/shared-utils/nextFrame.d.ts +1 -0
- package/dist/shared-utils/noop.d.ts +5 -0
- package/dist/shared-utils/object3d2LocalMatrix.d.ts +12 -0
- package/dist/shared-utils/px2rem.d.ts +1 -0
- package/dist/shared-utils/removeArrayItem.d.ts +7 -0
- package/dist/shared-utils/tap.d.ts +8 -0
- package/dist/shared-utils/three/centerPoint.d.ts +2 -0
- package/dist/shared-utils/three/getExtraModelLoader.d.ts +6 -0
- package/dist/shared-utils/three/getNormal.d.ts +2 -0
- package/dist/shared-utils/three/getTextureLoader.d.ts +6 -0
- package/dist/shared-utils/three/loadFbxObj.d.ts +2 -0
- package/dist/shared-utils/three/loadTexture.d.ts +2 -0
- package/dist/shared-utils/three/transformPositionToVector3.d.ts +7 -0
- package/dist/shared-utils/three/transfromToMeshBasicMaterial.d.ts +2 -0
- package/dist/shared-utils/throttle.d.ts +7 -0
- package/dist/shared-utils/to.d.ts +8 -0
- package/dist/shared-utils/useDebounce.d.ts +8 -0
- package/dist/shared-utils/useThrottle.d.ts +8 -0
- package/dist/shared-utils/uuid.d.ts +4 -0
- package/dist/shared-utils/vectorTocoordinates.d.ts +7 -0
- package/dist/typings/math.type.d.ts +44 -0
- package/dist/typings/utils.type.d.ts +2 -0
- package/docs/classes/ModelRoomLabelController.html +6 -6
- package/docs/enums/FLOOR_PLAN_ATTACHED_TO.html +1 -1
- package/docs/enums/ModelFloorplanErrorType.html +1 -1
- package/docs/interfaces/LineJson.html +1 -1
- package/docs/interfaces/ModelChassisCompassPluginData.html +1 -1
- package/docs/interfaces/ModelChassisCompassPluginExportType.html +1 -1
- package/docs/interfaces/ModelChassisCompassPluginParameterType.html +1 -1
- package/docs/interfaces/ModelEntryDoorGuidePluginData.html +1 -1
- package/docs/interfaces/ModelEntryDoorGuidePluginExportType.html +1 -1
- package/docs/interfaces/ModelFloorplanParameterType.html +1 -1
- package/docs/interfaces/ModelFloorplanViewEvent.html +2 -2
- package/docs/interfaces/ModelRoomLabelPluginData.html +1 -1
- package/docs/interfaces/PanoCompassPluginData.html +1 -1
- package/docs/interfaces/PanoCompassPluginParameterType.html +1 -1
- package/docs/interfaces/PanoCursorRaycasterPluginExportType.html +6 -6
- package/docs/interfaces/PanoRulerPluginExportType.html +1 -1
- package/docs/interfaces/PanoRulerPluginOptions.html +1 -1
- package/docs/interfaces/PanoRulerPluginParameterType.html +1 -1
- package/docs/interfaces/PointJson.html +1 -1
- package/docs/interfaces/RoomLabel.html +7 -7
- package/docs/interfaces/TopviewFloorplanPluginParameterType.html +1 -1
- package/docs/modules.html +11 -11
- package/libs/ModelRoomLabelPlugin/Controller.js +2 -2
- package/libs/ModelRoomLabelPlugin/RoomLabelItem.js +121 -0
- package/libs/ModelRoomLabelPlugin/RoomLabelItems.js +253 -0
- package/libs/PanoMeasurePlugin/Controller/EditController.js +1 -1
- package/libs/floorplan/Components/BaseImage.js +217 -0
- package/libs/floorplan/Components/Normalmage.js +63 -0
- package/libs/floorplan/Components/RoomHighlight/Room.js +70 -0
- package/libs/floorplan/Components/RoomHighlight/RoomHighlight.js +289 -0
- package/libs/floorplan/Components/RoomMaterials/RoomMaterial.js +328 -0
- package/libs/floorplan/Components/RoomMaterials/RoomMaterial_0.js +64 -0
- package/libs/floorplan/Components/RoomMaterials/RoomMaterial_1.js +103 -0
- package/libs/floorplan/Components/RoomMaterials/RoomMaterial_2.js +140 -0
- package/libs/floorplan/Components/SvgImage.js +83 -0
- package/libs/floorplan/ModelFloorplanPlugin/Components/Camera.js +120 -0
- package/libs/floorplan/ModelFloorplanPlugin/Components/Compass.js +106 -0
- package/libs/floorplan/ModelFloorplanPlugin/Components/CurrentFloor/CurrentFloor.js +463 -0
- package/libs/floorplan/ModelFloorplanPlugin/Components/Main.js +375 -0
- package/libs/floorplan/ModelFloorplanPlugin/Components/RoomLabels/RoomLabel.js +171 -0
- package/libs/floorplan/ModelFloorplanPlugin/Components/RoomLabels/RoomLabels.js +265 -0
- package/libs/floorplan/ModelFloorplanPlugin/Components/RuleLabels/RuleItem.js +301 -0
- package/libs/floorplan/ModelFloorplanPlugin/Components/RuleLabels/RuleLabels.js +219 -0
- package/libs/floorplan/ModelFloorplanPlugin/Controller.js +1 -1
- package/libs/floorplan/PanoFloorplanRadarPlugin/Components/Camera.js +152 -0
- package/libs/floorplan/PanoFloorplanRadarPlugin/Components/CurrentFloor/CurrentFloor.js +248 -0
- package/libs/floorplan/PanoFloorplanRadarPlugin/Components/CurrentFloor/ExtraObjects.js +154 -0
- package/libs/floorplan/PanoFloorplanRadarPlugin/Components/Main.js +312 -0
- package/libs/floorplan/PanoFloorplanRadarPlugin/Controller.js +1 -1
- package/libs/floorplan/TopviewFloorplanPlugin/Controller.js +1 -1
- package/package.json +18 -10
- package/dist/dnalogel.cjs.js +0 -7
- package/dist/dnalogel.es.js +0 -41280
- package/dist/dnalogel.umd.js +0 -7
- package/dist/style.css +0 -1
- package/libs/ModelRoomLabelPlugin/RoomLabelItem.svelte +0 -63
- package/libs/ModelRoomLabelPlugin/RoomLabelItem.svelte.map +0 -1
- package/libs/ModelRoomLabelPlugin/RoomLabelItems.svelte +0 -80
- package/libs/ModelRoomLabelPlugin/RoomLabelItems.svelte.map +0 -1
- package/libs/floorplan/Components/BaseImage.svelte +0 -25
- package/libs/floorplan/Components/BaseImage.svelte.map +0 -1
- package/libs/floorplan/Components/Normalmage.svelte +0 -11
- package/libs/floorplan/Components/Normalmage.svelte.map +0 -1
- package/libs/floorplan/Components/RoomHighlight/Room.svelte +0 -21
- package/libs/floorplan/Components/RoomHighlight/Room.svelte.map +0 -1
- package/libs/floorplan/Components/RoomHighlight/RoomHighlight.svelte +0 -60
- package/libs/floorplan/Components/RoomHighlight/RoomHighlight.svelte.map +0 -1
- package/libs/floorplan/Components/RoomMaterials/RoomMaterial.svelte +0 -35
- package/libs/floorplan/Components/RoomMaterials/RoomMaterial.svelte.map +0 -1
- package/libs/floorplan/Components/RoomMaterials/RoomMaterial_0.svelte +0 -7
- package/libs/floorplan/Components/RoomMaterials/RoomMaterial_0.svelte.map +0 -1
- package/libs/floorplan/Components/RoomMaterials/RoomMaterial_1.svelte +0 -16
- package/libs/floorplan/Components/RoomMaterials/RoomMaterial_1.svelte.map +0 -1
- package/libs/floorplan/Components/RoomMaterials/RoomMaterial_2.svelte +0 -17
- package/libs/floorplan/Components/RoomMaterials/RoomMaterial_2.svelte.map +0 -1
- package/libs/floorplan/Components/SvgImage.svelte +0 -25
- package/libs/floorplan/Components/SvgImage.svelte.map +0 -1
- package/libs/floorplan/ModelFloorplanPlugin/Components/Camera.svelte +0 -46
- package/libs/floorplan/ModelFloorplanPlugin/Components/Camera.svelte.map +0 -1
- package/libs/floorplan/ModelFloorplanPlugin/Components/Compass.svelte +0 -48
- package/libs/floorplan/ModelFloorplanPlugin/Components/Compass.svelte.map +0 -1
- package/libs/floorplan/ModelFloorplanPlugin/Components/CurrentFloor/CurrentFloor.svelte +0 -37
- package/libs/floorplan/ModelFloorplanPlugin/Components/CurrentFloor/CurrentFloor.svelte.map +0 -1
- package/libs/floorplan/ModelFloorplanPlugin/Components/Main.svelte +0 -50
- package/libs/floorplan/ModelFloorplanPlugin/Components/Main.svelte.map +0 -1
- package/libs/floorplan/ModelFloorplanPlugin/Components/RoomLabels/RoomLabel.svelte +0 -41
- package/libs/floorplan/ModelFloorplanPlugin/Components/RoomLabels/RoomLabel.svelte.map +0 -1
- package/libs/floorplan/ModelFloorplanPlugin/Components/RoomLabels/RoomLabels.svelte +0 -25
- package/libs/floorplan/ModelFloorplanPlugin/Components/RoomLabels/RoomLabels.svelte.map +0 -1
- package/libs/floorplan/ModelFloorplanPlugin/Components/RuleLabels/RuleItem.svelte +0 -148
- package/libs/floorplan/ModelFloorplanPlugin/Components/RuleLabels/RuleItem.svelte.map +0 -1
- package/libs/floorplan/ModelFloorplanPlugin/Components/RuleLabels/RuleLabels.svelte +0 -15
- package/libs/floorplan/ModelFloorplanPlugin/Components/RuleLabels/RuleLabels.svelte.map +0 -1
- package/libs/floorplan/PanoFloorplanRadarPlugin/Components/Camera.svelte +0 -84
- package/libs/floorplan/PanoFloorplanRadarPlugin/Components/Camera.svelte.map +0 -1
- package/libs/floorplan/PanoFloorplanRadarPlugin/Components/CurrentFloor/CurrentFloor.svelte +0 -18
- package/libs/floorplan/PanoFloorplanRadarPlugin/Components/CurrentFloor/CurrentFloor.svelte.map +0 -1
- package/libs/floorplan/PanoFloorplanRadarPlugin/Components/CurrentFloor/ExtraObjects.svelte +0 -40
- package/libs/floorplan/PanoFloorplanRadarPlugin/Components/CurrentFloor/ExtraObjects.svelte.map +0 -1
- package/libs/floorplan/PanoFloorplanRadarPlugin/Components/Main.svelte +0 -61
- package/libs/floorplan/PanoFloorplanRadarPlugin/Components/Main.svelte.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { FivePlugin } from '@realsee/five';
|
|
2
|
+
import { Vector3 } from 'three';
|
|
3
|
+
import { CSS3DObject } from 'three/examples/jsm/renderers/CSS3DRenderer';
|
|
4
|
+
import { Vector3Position } from '../typings/math.type';
|
|
5
|
+
export declare type CSS3DRenderPluginParameterType = undefined;
|
|
6
|
+
export interface CSS3DRenderPluginExportType {
|
|
7
|
+
/**
|
|
8
|
+
* @description: 根据传入的四个点位创建一个3d dom容器,可以通过ReactDom.render()的方式将react组件放到容器中
|
|
9
|
+
* @param {Five} five
|
|
10
|
+
* @param {Vector3[] | Vector3Position[]} points: 矩形四个点坐标
|
|
11
|
+
* @param {number} config.ratio: 1px对应多少米,默认为 0.002,即1px对应2mm
|
|
12
|
+
* @param {number} config.dpr: dpr, 默认为1
|
|
13
|
+
* @param {HTMLElement} config.container: HTMLElement
|
|
14
|
+
* @param {number} config.autoRender: 默认为true,如果需要手动render则传false
|
|
15
|
+
* @param {'front' | 'behind'} config.mode: 两种模式
|
|
16
|
+
* @param {HTMLElement} config.behindFiveContainer: 如果config.mode为'behind',需要传入容器,并确保此容器位five下方,且中间没有其他dom元素遮挡
|
|
17
|
+
* @return {{ container: HTMLElement; dispose: () => void }}: container: dom容器, dispose: 清理函数
|
|
18
|
+
*/
|
|
19
|
+
create3DDomContainer: (points: Vector3[] | Vector3Position[], config?: {
|
|
20
|
+
ratio?: number;
|
|
21
|
+
dpr?: number;
|
|
22
|
+
autoRender?: boolean;
|
|
23
|
+
container?: HTMLElement;
|
|
24
|
+
[key: string]: any;
|
|
25
|
+
} & ({
|
|
26
|
+
mode?: 'front';
|
|
27
|
+
} | {
|
|
28
|
+
mode: 'behind';
|
|
29
|
+
behindFiveContainer: HTMLElement;
|
|
30
|
+
})) => {
|
|
31
|
+
container: HTMLElement;
|
|
32
|
+
dispose: () => void;
|
|
33
|
+
css3DObject: CSS3DObject;
|
|
34
|
+
render?: () => void;
|
|
35
|
+
} | void;
|
|
36
|
+
/**
|
|
37
|
+
* @description: 销毁所有的渲染内容
|
|
38
|
+
* @return {void}
|
|
39
|
+
*/
|
|
40
|
+
disposeAll: () => void;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* **CSS3DRenderPlugin** 提供矩形区域(三维空间四个坐标点),你可以在此矩形区域中渲染 DOM 内容。
|
|
44
|
+
* 实现原理参考[CSS3DRenderer](https://threejs.org/docs/index.html?q=CSS3D#examples/en/renderers/CSS3DRenderer)。
|
|
45
|
+
*
|
|
46
|
+
* @returns
|
|
47
|
+
*/
|
|
48
|
+
export declare const CSS3DRenderPlugin: FivePlugin<CSS3DRenderPluginParameterType, CSS3DRenderPluginExportType>;
|
|
49
|
+
export default CSS3DRenderPlugin;
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var THREE = require('three');
|
|
6
|
+
var CSS3DRenderer = require('three/examples/jsm/renderers/CSS3DRenderer');
|
|
7
|
+
|
|
8
|
+
function _interopNamespace(e) {
|
|
9
|
+
if (e && e.__esModule) return e;
|
|
10
|
+
var n = Object.create(null);
|
|
11
|
+
if (e) {
|
|
12
|
+
Object.keys(e).forEach(function (k) {
|
|
13
|
+
if (k !== 'default') {
|
|
14
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
15
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
16
|
+
enumerable: true,
|
|
17
|
+
get: function () { return e[k]; }
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
n["default"] = e;
|
|
23
|
+
return Object.freeze(n);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
var THREE__namespace = /*#__PURE__*/_interopNamespace(THREE);
|
|
27
|
+
|
|
28
|
+
function evenNumber(num, config) {
|
|
29
|
+
const roundNum = Math.round(num);
|
|
30
|
+
return roundNum % 2 === 0 ? roundNum : roundNum + Number(config?.smaller ? -1 : 1);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function centerPoint(point1, point2) {
|
|
34
|
+
return new THREE.Vector3((point1.x + point2.x) / 2, (point1.y + point2.y) / 2, (point1.z + point2.z) / 2);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const transformPositionToVector3 = ({ x, y, z }) => new THREE.Vector3(x, y, z);
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* @description: 究极简陋的 ResizeObserver polyfill
|
|
41
|
+
*/
|
|
42
|
+
function createResizeObserver(func, element) {
|
|
43
|
+
if (!element || typeof ResizeObserver === 'undefined') {
|
|
44
|
+
return {
|
|
45
|
+
observe: () => window.addEventListener('resize', func),
|
|
46
|
+
unobserve: () => window.removeEventListener('resize', func),
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
const observer = new ResizeObserver(func);
|
|
51
|
+
return {
|
|
52
|
+
observe: () => observer.observe(element),
|
|
53
|
+
unobserve: () => observer.unobserve(element),
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* **CSS3DRenderPlugin** 提供矩形区域(三维空间四个坐标点),你可以在此矩形区域中渲染 DOM 内容。
|
|
60
|
+
* 实现原理参考[CSS3DRenderer](https://threejs.org/docs/index.html?q=CSS3D#examples/en/renderers/CSS3DRenderer)。
|
|
61
|
+
*
|
|
62
|
+
* @returns
|
|
63
|
+
*/
|
|
64
|
+
const CSS3DRenderPlugin = (five) => {
|
|
65
|
+
const state = { disposeCallbacks: [] };
|
|
66
|
+
const create3DDomContainer = (...params) => {
|
|
67
|
+
const points = params[0].map((point) => (point instanceof THREE.Vector3 ? point : transformPositionToVector3(point)));
|
|
68
|
+
const config = params[1];
|
|
69
|
+
if (points?.length < 4)
|
|
70
|
+
return console.error('points must be equal or greater than than 4');
|
|
71
|
+
if (!five?.model?.loaded)
|
|
72
|
+
return console.error('five.model.loaded is: ', five?.model?.loaded);
|
|
73
|
+
const fiveElement = five.getElement();
|
|
74
|
+
if (!fiveElement)
|
|
75
|
+
return console.error('five.getElement() is ' + fiveElement);
|
|
76
|
+
const disposers = [];
|
|
77
|
+
const ratio = config?.ratio || 0.00216;
|
|
78
|
+
if (ratio <= 0.00215)
|
|
79
|
+
console.warn('if you need click css3DElement on safari, ratio must be greater than 0.00215');
|
|
80
|
+
const dpr = config?.dpr || 1;
|
|
81
|
+
const mode = config?.mode || 'front';
|
|
82
|
+
const autoRender = config?.autoRender ?? true;
|
|
83
|
+
const behindFiveContainer = config?.behindFiveContainer || fiveElement.parentElement || document.body;
|
|
84
|
+
const container = config?.container || document.createElement('div');
|
|
85
|
+
container.classList.add('__Dnalogel-plugin--CSS3DRenderPlugin');
|
|
86
|
+
// 获取css3DObject, 如果mode为behind的话,一起获取mesh
|
|
87
|
+
const { css3DObject, mesh } = createObject(points, { ratio, dpr, container, mode });
|
|
88
|
+
// ======= INIT START =======
|
|
89
|
+
let resizeObserver;
|
|
90
|
+
const frontModeUnInited = mode === 'front' && !state.frontMode;
|
|
91
|
+
const behindModeUnInited = mode === 'behind' && !state.behindMode;
|
|
92
|
+
const inited = !(frontModeUnInited || behindModeUnInited);
|
|
93
|
+
let stopRenderFlag = false;
|
|
94
|
+
let requestAnimationFrameId = null;
|
|
95
|
+
if (behindModeUnInited) {
|
|
96
|
+
state.behindMode = { scene: new THREE.Scene(), css3DRenderer: new CSS3DRenderer.CSS3DRenderer() };
|
|
97
|
+
}
|
|
98
|
+
if (frontModeUnInited) {
|
|
99
|
+
state.frontMode = { scene: new THREE.Scene(), css3DRenderer: new CSS3DRenderer.CSS3DRenderer() };
|
|
100
|
+
}
|
|
101
|
+
const { scene, css3DRenderer } = mode === 'behind' ? state.behindMode : state.frontMode;
|
|
102
|
+
const render = (() => {
|
|
103
|
+
if (!inited) {
|
|
104
|
+
const css3DRendererSetSize = () => {
|
|
105
|
+
// 这里evenNumber策略是遇到奇数会加1,不知道为啥会触发滚动条显示,导致fiveElement变小,fiveElement变小又触发了这里的resize,宽高变小,滚动条消失,然后又触发resize。。。无限循环
|
|
106
|
+
// 为了规避上面这种情况,evenNumber设置了一个参数,遇到奇数可选择减一
|
|
107
|
+
const rendererWidth = evenNumber(fiveElement.clientWidth, { smaller: true });
|
|
108
|
+
const rendererHeight = evenNumber(fiveElement.clientHeight, { smaller: true });
|
|
109
|
+
css3DRenderer.setSize(rendererWidth, rendererHeight);
|
|
110
|
+
};
|
|
111
|
+
css3DRendererSetSize();
|
|
112
|
+
resizeObserver = createResizeObserver(css3DRendererSetSize, fiveElement);
|
|
113
|
+
css3DRenderer.domElement.style.position = 'absolute';
|
|
114
|
+
css3DRenderer.domElement.style.top = '0';
|
|
115
|
+
css3DRenderer.domElement.style.userSelect = 'none';
|
|
116
|
+
css3DRenderer.domElement.style.pointerEvents = 'none';
|
|
117
|
+
const renderEveryFrame = () => {
|
|
118
|
+
if (stopRenderFlag)
|
|
119
|
+
return;
|
|
120
|
+
requestAnimationFrameId = requestAnimationFrame(renderEveryFrame);
|
|
121
|
+
css3DRenderer.render(scene, five.camera);
|
|
122
|
+
};
|
|
123
|
+
return () => {
|
|
124
|
+
scene.add(css3DObject);
|
|
125
|
+
resizeObserver?.observe?.();
|
|
126
|
+
renderEveryFrame();
|
|
127
|
+
if (mode === 'behind' && mesh) {
|
|
128
|
+
five.scene.add(mesh);
|
|
129
|
+
disposers.push(() => mesh && five.scene.remove(mesh));
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
else {
|
|
134
|
+
return () => {
|
|
135
|
+
scene.add(css3DObject);
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
})();
|
|
139
|
+
if (frontModeUnInited) {
|
|
140
|
+
const wrapper = fiveElement.parentElement || document.body;
|
|
141
|
+
wrapper.appendChild(css3DRenderer.domElement);
|
|
142
|
+
}
|
|
143
|
+
if (behindModeUnInited) {
|
|
144
|
+
const wrapper = behindFiveContainer;
|
|
145
|
+
wrapper.appendChild(css3DRenderer.domElement);
|
|
146
|
+
}
|
|
147
|
+
// ======= INIT END =======
|
|
148
|
+
const dispose = () => {
|
|
149
|
+
stopRenderFlag = true;
|
|
150
|
+
disposers.forEach((d) => d?.());
|
|
151
|
+
scene.remove(css3DObject);
|
|
152
|
+
if (typeof requestAnimationFrameId === 'number')
|
|
153
|
+
cancelAnimationFrame(requestAnimationFrameId);
|
|
154
|
+
if (scene.children.length === 0) {
|
|
155
|
+
css3DRenderer.domElement.remove();
|
|
156
|
+
if (mode === 'front')
|
|
157
|
+
state.frontMode = undefined;
|
|
158
|
+
if (mode === 'behind')
|
|
159
|
+
state.behindMode = undefined;
|
|
160
|
+
if (!state.behindMode && !state.frontMode) {
|
|
161
|
+
resizeObserver?.unobserve?.();
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
return true;
|
|
165
|
+
};
|
|
166
|
+
const idx = state.disposeCallbacks.findIndex((item) => item === dispose);
|
|
167
|
+
if (idx !== -1) {
|
|
168
|
+
state.disposeCallbacks.splice(idx, 1);
|
|
169
|
+
}
|
|
170
|
+
else {
|
|
171
|
+
state.disposeCallbacks.push(dispose);
|
|
172
|
+
}
|
|
173
|
+
if (autoRender)
|
|
174
|
+
render();
|
|
175
|
+
return { container, dispose, css3DObject, render: autoRender ? undefined : render };
|
|
176
|
+
};
|
|
177
|
+
const createObject = (points, config) => {
|
|
178
|
+
const { ratio, dpr, container: element, mode } = config;
|
|
179
|
+
const planeWidth = points[0].distanceTo(points[1]);
|
|
180
|
+
const planeHeight = points[1].distanceTo(points[2]);
|
|
181
|
+
const domWidthPx = evenNumber((planeWidth / ratio) * dpr);
|
|
182
|
+
const domHeightPx = evenNumber((planeHeight / ratio) * dpr);
|
|
183
|
+
const css3DObject = new CSS3DRenderer.CSS3DObject(element);
|
|
184
|
+
css3DObject.scale.set(ratio, ratio, ratio);
|
|
185
|
+
element.style.width = domWidthPx + 'px';
|
|
186
|
+
element.style.height = domHeightPx + 'px';
|
|
187
|
+
element.style.pointerEvents = 'none';
|
|
188
|
+
const centerPosition = centerPoint(points[0], points[2]);
|
|
189
|
+
const vector01 = points[1].clone().sub(points[0]); // 点0 -> 点1 的向量
|
|
190
|
+
const vector12 = points[2].clone().sub(points[1]); // 点1 -> 点2 的向量
|
|
191
|
+
// 旋转
|
|
192
|
+
const rotateXAngle = new THREE.Vector3(0, 1, 0).angleTo(new THREE.Vector3(0, vector12.y, vector12.z));
|
|
193
|
+
const rotateYAngle = new THREE.Vector3(1, 0, 0).angleTo(new THREE.Vector3(vector01.x, 0, vector01.z));
|
|
194
|
+
const rotateZAngle = vector01.angleTo(new THREE.Vector3(vector01.x, 0, vector01.z));
|
|
195
|
+
/**
|
|
196
|
+
* [0,1,0] => [0,0,1] 为rolate Worldx正方向
|
|
197
|
+
* [0,0,1] => [0,1,0] 为rolate Worldy正方向
|
|
198
|
+
* [0,1,1] => [-1,0,0] 为rolate Worldz正方向
|
|
199
|
+
*/
|
|
200
|
+
const rotateX = (vector12.z > 0 ? -1 : 1) * rotateXAngle;
|
|
201
|
+
const rotateY = (vector01.z < 0 ? 1 : -1) * rotateYAngle;
|
|
202
|
+
const rotateZ = ((vector01.x > 0 && vector01.y < 0) || (vector01.x < 0 && vector01.y > 0) ? -1 : 1) * rotateZAngle;
|
|
203
|
+
css3DObject.rotateOnWorldAxis(new THREE.Vector3(1, 0, 0), rotateX); // x
|
|
204
|
+
css3DObject.rotateOnWorldAxis(new THREE.Vector3(0, 1, 0), rotateY); // y
|
|
205
|
+
css3DObject.rotateOnWorldAxis(new THREE.Vector3(0, 0, 1), rotateZ); // z
|
|
206
|
+
css3DObject.position.set(centerPosition.x, centerPosition.y, centerPosition.z);
|
|
207
|
+
let mesh;
|
|
208
|
+
if (mode === 'behind') {
|
|
209
|
+
const material = new THREE__namespace.MeshBasicMaterial({
|
|
210
|
+
opacity: 0,
|
|
211
|
+
transparent: false,
|
|
212
|
+
side: THREE__namespace.DoubleSide,
|
|
213
|
+
});
|
|
214
|
+
const geometry = new THREE__namespace.PlaneGeometry(domWidthPx, domHeightPx);
|
|
215
|
+
mesh = new THREE__namespace.Mesh(geometry, material);
|
|
216
|
+
mesh.name = 'CSS3DRenderPlugin-mesh';
|
|
217
|
+
mesh.position.copy(css3DObject.position);
|
|
218
|
+
mesh.rotation.copy(css3DObject.rotation);
|
|
219
|
+
mesh.scale.copy(css3DObject.scale);
|
|
220
|
+
}
|
|
221
|
+
return { css3DObject, mesh };
|
|
222
|
+
};
|
|
223
|
+
return {
|
|
224
|
+
create3DDomContainer,
|
|
225
|
+
disposeAll: () => {
|
|
226
|
+
state.disposeCallbacks.forEach((d) => d?.());
|
|
227
|
+
state.disposeCallbacks = [];
|
|
228
|
+
},
|
|
229
|
+
};
|
|
230
|
+
};
|
|
231
|
+
|
|
232
|
+
exports.CSS3DRenderPlugin = CSS3DRenderPlugin;
|
|
233
|
+
exports["default"] = CSS3DRenderPlugin;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { FivePlugin } from '@realsee/five';
|
|
2
|
+
import { CameraMovementPluginExportType, CameraMovementPluginParameterType } from './typing';
|
|
3
|
+
/**
|
|
4
|
+
* **运镜插件** 模拟类似于电影运镜效果。
|
|
5
|
+
*/
|
|
6
|
+
export declare const CameraMovementPlugin: FivePlugin<CameraMovementPluginParameterType, CameraMovementPluginExportType>;
|
|
7
|
+
export default CameraMovementPlugin;
|
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var five = require('@realsee/five');
|
|
6
|
+
var TWEEN = require('@tweenjs/tween.js');
|
|
7
|
+
|
|
8
|
+
function _interopNamespace(e) {
|
|
9
|
+
if (e && e.__esModule) return e;
|
|
10
|
+
var n = Object.create(null);
|
|
11
|
+
if (e) {
|
|
12
|
+
Object.keys(e).forEach(function (k) {
|
|
13
|
+
if (k !== 'default') {
|
|
14
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
15
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
16
|
+
enumerable: true,
|
|
17
|
+
get: function () { return e[k]; }
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
n["default"] = e;
|
|
23
|
+
return Object.freeze(n);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
var TWEEN__namespace = /*#__PURE__*/_interopNamespace(TWEEN);
|
|
27
|
+
|
|
28
|
+
const _requestAnimationFrame = window.requestAnimationFrame || ((fn) => setTimeout(fn, 16));
|
|
29
|
+
const _cancelAnimationFrame = window.cancelAnimationFrame || clearTimeout;
|
|
30
|
+
function nextFrame(fn, delay = 0) {
|
|
31
|
+
if (delay <= 0)
|
|
32
|
+
_requestAnimationFrame(fn);
|
|
33
|
+
else
|
|
34
|
+
_requestAnimationFrame(() => nextFrame(fn, delay - 1));
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* 在每个 AnimationFrame 中调用传入的函数
|
|
38
|
+
* @param callback 每次 AnimationFrame 中调用的函数
|
|
39
|
+
* @param frame 每秒运行多少次
|
|
40
|
+
* @returns 返回一个函数,调用可以停止 AnimationFrameLoop
|
|
41
|
+
*/
|
|
42
|
+
function requestAnimationFrameInterval(callback, frame = 60) {
|
|
43
|
+
let index = -1;
|
|
44
|
+
let oldTime = 0;
|
|
45
|
+
let startTime = -1;
|
|
46
|
+
const minDeltaTime = 1000 / frame;
|
|
47
|
+
function loop(time) {
|
|
48
|
+
startTime === -1 && (startTime = time);
|
|
49
|
+
index = _requestAnimationFrame(loop);
|
|
50
|
+
const deltaTime = time - oldTime;
|
|
51
|
+
if (deltaTime < minDeltaTime)
|
|
52
|
+
return;
|
|
53
|
+
oldTime = time;
|
|
54
|
+
callback && callback(time - startTime);
|
|
55
|
+
}
|
|
56
|
+
index = _requestAnimationFrame(loop);
|
|
57
|
+
return function stop() {
|
|
58
|
+
_cancelAnimationFrame(index);
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
// export { Easing } from './tween'
|
|
62
|
+
// export { default as tween } from './tween'
|
|
63
|
+
|
|
64
|
+
const Easing = TWEEN__namespace.Easing;
|
|
65
|
+
/**
|
|
66
|
+
* 对象变化的补间动画
|
|
67
|
+
* 1. 应用 requestAnimationFrameInterval 做 update
|
|
68
|
+
* 2. 在原生 tween 上新增 destroy 方法和 onDestroy 监听
|
|
69
|
+
* DOC: https://github.com/tweenjs/tween.js
|
|
70
|
+
* @param from 对象起始状态
|
|
71
|
+
* @param to 对象末尾状态
|
|
72
|
+
* @param duration 经历时间(s)
|
|
73
|
+
* @param easing 过程动画,默认是 Easing.Linear.None
|
|
74
|
+
*/
|
|
75
|
+
function tween(from, to, duration, easing = Easing.Linear.None) {
|
|
76
|
+
const tween = new TWEEN__namespace.Tween(from).to(to, duration).easing(easing);
|
|
77
|
+
// 这里注意一下,因为 requestAnimationFrameInterval 给的时间是从 0 开始的,tween 动画也从 0 开始
|
|
78
|
+
nextFrame(() => tween.start(0));
|
|
79
|
+
const cancelAnimationFrame = requestAnimationFrameInterval((time) => {
|
|
80
|
+
if (tween.update(time) === false)
|
|
81
|
+
cancelAnimationFrame();
|
|
82
|
+
});
|
|
83
|
+
const destroyMethods = [];
|
|
84
|
+
tween.onDestroy = (fn) => {
|
|
85
|
+
destroyMethods.push(fn);
|
|
86
|
+
return tween;
|
|
87
|
+
};
|
|
88
|
+
tween.destroy = function () {
|
|
89
|
+
this.stop();
|
|
90
|
+
Object.assign(tween, {
|
|
91
|
+
_onStartCallback: null,
|
|
92
|
+
_onUpdateCallback: null,
|
|
93
|
+
_onCompleteCallback: null,
|
|
94
|
+
_onStopCallbackL: null,
|
|
95
|
+
});
|
|
96
|
+
let destroyMethod;
|
|
97
|
+
while ((destroyMethod = destroyMethods.shift()))
|
|
98
|
+
destroyMethod();
|
|
99
|
+
cancelAnimationFrame();
|
|
100
|
+
};
|
|
101
|
+
return tween;
|
|
102
|
+
}
|
|
103
|
+
function tweenProgress(duration, easing) {
|
|
104
|
+
return tween({ progress: 0 }, { progress: 1 }, duration, easing);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* 运镜效果
|
|
109
|
+
*/
|
|
110
|
+
var CameraMovementEffect;
|
|
111
|
+
(function (CameraMovementEffect) {
|
|
112
|
+
CameraMovementEffect["Move"] = "Move";
|
|
113
|
+
CameraMovementEffect["Rotate"] = "Rotate";
|
|
114
|
+
})(CameraMovementEffect || (CameraMovementEffect = {}));
|
|
115
|
+
/**
|
|
116
|
+
* 旋转类型
|
|
117
|
+
*/
|
|
118
|
+
var Rotation;
|
|
119
|
+
(function (Rotation) {
|
|
120
|
+
Rotation["Clockwise"] = "Clockwise";
|
|
121
|
+
Rotation["Anticlockwise"] = "Anticlockwise";
|
|
122
|
+
Rotation["Loop"] = "Loop";
|
|
123
|
+
})(Rotation || (Rotation = {}));
|
|
124
|
+
|
|
125
|
+
const PI_2 = Math.PI * 2;
|
|
126
|
+
/**
|
|
127
|
+
* 把一个任意角度的弧度值转换为一个 [0, 2PI] 的弧度值
|
|
128
|
+
* @param rad 弧度值
|
|
129
|
+
*/
|
|
130
|
+
function formatLongitude(rad) {
|
|
131
|
+
return ((rad % PI_2) + PI_2) % PI_2;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* 把一个任意角度的弧度值转换为一个 [-2PI, 2PI] 的弧度值
|
|
135
|
+
* @param rad 弧度值
|
|
136
|
+
*/
|
|
137
|
+
function formatLatitude(rad) {
|
|
138
|
+
return rad % PI_2;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* 线性过程插值
|
|
143
|
+
*/
|
|
144
|
+
function progressNumber(from, to, pst) {
|
|
145
|
+
return from + (to - from) * pst;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
const getLongitudeParams = (from, to, rotation) => {
|
|
149
|
+
const PI = Math.PI;
|
|
150
|
+
const PI_2 = PI * 2;
|
|
151
|
+
from = formatLongitude(from);
|
|
152
|
+
to = formatLongitude(to);
|
|
153
|
+
// 逆时针旋转,初始值必须是较大的值
|
|
154
|
+
if (rotation === Rotation.Anticlockwise && from < to)
|
|
155
|
+
from += PI_2;
|
|
156
|
+
// 顺时针旋转,结束值必须是较大值
|
|
157
|
+
if (rotation === Rotation.Clockwise && to < from)
|
|
158
|
+
to += PI_2;
|
|
159
|
+
// Loop 旋转,找锐角旋转
|
|
160
|
+
// 如果 to 比 from 大 180°,逆时针转
|
|
161
|
+
// 如果 from 比 to 大 180°,顺时针转
|
|
162
|
+
if (rotation === Rotation.Loop && to - from > PI)
|
|
163
|
+
return getLongitudeParams(from, to, Rotation.Anticlockwise);
|
|
164
|
+
if (rotation === Rotation.Loop && from - to > PI)
|
|
165
|
+
return getLongitudeParams(from, to, Rotation.Clockwise);
|
|
166
|
+
return { from, to };
|
|
167
|
+
};
|
|
168
|
+
/**
|
|
169
|
+
* **运镜插件** 模拟类似于电影运镜效果。
|
|
170
|
+
*/
|
|
171
|
+
const CameraMovementPlugin = (five$1) => {
|
|
172
|
+
const state = {};
|
|
173
|
+
const move = async (args, duration, opts = { preload: true }) => {
|
|
174
|
+
if (state.interruptCallback) {
|
|
175
|
+
state.interruptCallback(false);
|
|
176
|
+
}
|
|
177
|
+
if (opts.asyncStartCallback) {
|
|
178
|
+
await opts.asyncStartCallback();
|
|
179
|
+
}
|
|
180
|
+
if (args.mode && args.mode !== five$1.currentMode) {
|
|
181
|
+
await five$1.changeMode(args.mode);
|
|
182
|
+
}
|
|
183
|
+
if (opts.preload && args.panoIndex !== undefined && args.panoIndex !== five$1.panoIndex) {
|
|
184
|
+
await five$1.preloadPano(args.panoIndex);
|
|
185
|
+
}
|
|
186
|
+
if (opts.asyncEndCallback) {
|
|
187
|
+
await opts.asyncEndCallback();
|
|
188
|
+
}
|
|
189
|
+
if (args.panoIndex === undefined &&
|
|
190
|
+
args.fov === undefined &&
|
|
191
|
+
args.latitude === undefined &&
|
|
192
|
+
args.longitude === undefined) {
|
|
193
|
+
return true;
|
|
194
|
+
}
|
|
195
|
+
return await new Promise((resolve, reject) => {
|
|
196
|
+
const panoIndex = args.panoIndex !== undefined ? args.panoIndex : five$1.panoIndex;
|
|
197
|
+
if (panoIndex !== undefined) {
|
|
198
|
+
five$1.moveToPano(panoIndex, Object.assign({
|
|
199
|
+
duration,
|
|
200
|
+
moveEndCallback: () => resolve(true),
|
|
201
|
+
moveCancelCallback: () => reject(false), // 移动开始
|
|
202
|
+
}, args));
|
|
203
|
+
}
|
|
204
|
+
else {
|
|
205
|
+
reject(false);
|
|
206
|
+
}
|
|
207
|
+
});
|
|
208
|
+
};
|
|
209
|
+
const getAnimeParams = (args) => {
|
|
210
|
+
const currentFiveState = five$1.state;
|
|
211
|
+
// latitude
|
|
212
|
+
const fromLatitude = formatLatitude(currentFiveState.latitude);
|
|
213
|
+
const toLatitude = formatLatitude(args.latitude);
|
|
214
|
+
// longitude
|
|
215
|
+
const { from: fromLongitude, to: toLongitude } = getLongitudeParams(currentFiveState.longitude, args.longitude, args.rotation || Rotation.Loop);
|
|
216
|
+
// fov
|
|
217
|
+
const fromFov = currentFiveState.fov;
|
|
218
|
+
const toFov = args.fov;
|
|
219
|
+
return {
|
|
220
|
+
from: { latitude: fromLatitude, longitude: fromLongitude, fov: fromFov },
|
|
221
|
+
to: { latitude: toLatitude, longitude: toLongitude, fov: toFov },
|
|
222
|
+
};
|
|
223
|
+
};
|
|
224
|
+
const rotate = async (args, duration, opts = {}) => {
|
|
225
|
+
if (state.interruptCallback) {
|
|
226
|
+
state.interruptCallback(false);
|
|
227
|
+
}
|
|
228
|
+
if (opts.asyncStartCallback) {
|
|
229
|
+
await opts.asyncStartCallback();
|
|
230
|
+
}
|
|
231
|
+
if (five$1.currentMode !== five.Five.Mode.Panorama) {
|
|
232
|
+
await five$1.changeMode(five.Five.Mode.Panorama);
|
|
233
|
+
}
|
|
234
|
+
if (args.panoIndex !== undefined && args.panoIndex !== five$1.panoIndex) {
|
|
235
|
+
if (opts.preload)
|
|
236
|
+
await five$1.preloadPano(args.panoIndex);
|
|
237
|
+
await new Promise((resolve, reject) => {
|
|
238
|
+
if (!args.panoIndex) {
|
|
239
|
+
resolve(true);
|
|
240
|
+
return;
|
|
241
|
+
}
|
|
242
|
+
five$1.moveToPano(args.panoIndex, {
|
|
243
|
+
moveEndCallback: () => resolve(true),
|
|
244
|
+
moveCancelCallback: () => reject(false), // 移动开始
|
|
245
|
+
});
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
if (opts.asyncEndCallback) {
|
|
249
|
+
await opts.asyncEndCallback();
|
|
250
|
+
}
|
|
251
|
+
const { from, to } = getAnimeParams(args);
|
|
252
|
+
return await new Promise((resolve) => {
|
|
253
|
+
const onUpdate = ({ progress }) => {
|
|
254
|
+
const state = {};
|
|
255
|
+
state.longitude = progressNumber(from.longitude, to.longitude, progress);
|
|
256
|
+
state.latitude = progressNumber(from.latitude, to.latitude, progress);
|
|
257
|
+
state.fov = progressNumber(from.fov, to.fov, progress);
|
|
258
|
+
five$1.setState(state, true);
|
|
259
|
+
};
|
|
260
|
+
const onComplete = () => {
|
|
261
|
+
resolve(true);
|
|
262
|
+
};
|
|
263
|
+
const onDestroy = () => {
|
|
264
|
+
resolve(false);
|
|
265
|
+
};
|
|
266
|
+
const animeDuration = args.rotateSpeed
|
|
267
|
+
? Math.ceil((Math.abs(to.longitude - from.longitude) / args.rotateSpeed) * 1000)
|
|
268
|
+
: duration;
|
|
269
|
+
const tween = tweenProgress(animeDuration, TWEEN__namespace.Easing.Linear.None)
|
|
270
|
+
.onUpdate(onUpdate)
|
|
271
|
+
.onComplete(onComplete)
|
|
272
|
+
.onDestroy(onDestroy);
|
|
273
|
+
if (args.rotation === Rotation.Loop) {
|
|
274
|
+
tween.repeat(Infinity).yoyo(true);
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* 中断回调:可能会被其他动画中断。
|
|
278
|
+
*/
|
|
279
|
+
state.interruptCallback = (flag = true) => {
|
|
280
|
+
tween.destroy();
|
|
281
|
+
state.interruptCallback = undefined;
|
|
282
|
+
if (state.timeoutId) {
|
|
283
|
+
clearTimeout(state.timeoutId);
|
|
284
|
+
state.timeoutId = undefined;
|
|
285
|
+
}
|
|
286
|
+
resolve(flag);
|
|
287
|
+
};
|
|
288
|
+
state.timeoutId = setTimeout(() => {
|
|
289
|
+
// 总时间到了之后强制结束,同时也是 Loop 模式的结束方式
|
|
290
|
+
if (state.interruptCallback)
|
|
291
|
+
state.interruptCallback(true);
|
|
292
|
+
}, duration);
|
|
293
|
+
});
|
|
294
|
+
};
|
|
295
|
+
return {
|
|
296
|
+
move,
|
|
297
|
+
rotate,
|
|
298
|
+
};
|
|
299
|
+
};
|
|
300
|
+
|
|
301
|
+
exports.CameraMovementPlugin = CameraMovementPlugin;
|
|
302
|
+
exports["default"] = CameraMovementPlugin;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { Mode, Pose } from '@realsee/five';
|
|
2
|
+
export interface CameraMovementPluginParameterType {
|
|
3
|
+
}
|
|
4
|
+
export interface CameraMovementPluginExportType {
|
|
5
|
+
/**
|
|
6
|
+
* 运镜:移动
|
|
7
|
+
* @param moveArgs 移动参数
|
|
8
|
+
* @param duration 移动耗时
|
|
9
|
+
* @param opts 额外配置
|
|
10
|
+
*/
|
|
11
|
+
move(moveArgs: Partial<MoveArgs>, duration: number, opts?: MoveOpts): Promise<boolean>;
|
|
12
|
+
/**
|
|
13
|
+
* 运镜:旋转
|
|
14
|
+
* @param rotateArgs 旋转参数
|
|
15
|
+
* @param duration 旋转耗时
|
|
16
|
+
* @param opts 额外配置
|
|
17
|
+
*/
|
|
18
|
+
rotate(rotateArgs: Partial<RotateArgs>, duration: number, opts?: RotateOpts): Promise<boolean>;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* 运镜效果
|
|
22
|
+
*/
|
|
23
|
+
export declare enum CameraMovementEffect {
|
|
24
|
+
Move = "Move",
|
|
25
|
+
Rotate = "Rotate"
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* 旋转类型
|
|
29
|
+
*/
|
|
30
|
+
export declare enum Rotation {
|
|
31
|
+
Clockwise = "Clockwise",
|
|
32
|
+
Anticlockwise = "Anticlockwise",
|
|
33
|
+
Loop = "Loop"
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* 回调配置
|
|
37
|
+
*/
|
|
38
|
+
export interface CameraMovementOptsCallback {
|
|
39
|
+
asyncStartCallback?: () => void;
|
|
40
|
+
asyncEndCallback?: () => void;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* 移动运镜参数
|
|
44
|
+
*/
|
|
45
|
+
export declare type MoveArgs = {
|
|
46
|
+
mode: Mode;
|
|
47
|
+
panoIndex: number;
|
|
48
|
+
} & Pose;
|
|
49
|
+
/**
|
|
50
|
+
* 移动运镜配置
|
|
51
|
+
*/
|
|
52
|
+
export declare type MoveOpts = {
|
|
53
|
+
preload?: boolean;
|
|
54
|
+
} & CameraMovementOptsCallback;
|
|
55
|
+
/**
|
|
56
|
+
* 旋转运镜参数
|
|
57
|
+
*/
|
|
58
|
+
export declare type RotateArgs = {
|
|
59
|
+
panoIndex?: number;
|
|
60
|
+
rotateSpeed?: number;
|
|
61
|
+
rotation?: Rotation;
|
|
62
|
+
} & Pose;
|
|
63
|
+
/**
|
|
64
|
+
* 旋转运镜配置
|
|
65
|
+
*/
|
|
66
|
+
export declare type RotateOpts = {
|
|
67
|
+
preload?: boolean;
|
|
68
|
+
} & CameraMovementOptsCallback;
|