@realsee/dnalogel 2.0.0-alpha.26 → 2.0.0-alpha.28
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 +6 -0
- package/dist/CSS3DRenderPlugin/Plugin.d.ts +49 -0
- package/dist/CSS3DRenderPlugin/index.d.ts +3 -48
- package/dist/CameraMovementPlugin/CameraMovementPlugin.d.ts +7 -0
- package/dist/CameraMovementPlugin/index.d.ts +4 -6
- package/dist/CameraMovementPlugin/index.js +12 -12
- package/dist/ModelChassisCompassPlugin/Plugin.d.ts +19 -0
- package/dist/ModelChassisCompassPlugin/index.d.ts +3 -18
- package/dist/ModelEntryDoorGuidePlugin/Plugin.d.ts +26 -0
- package/dist/ModelEntryDoorGuidePlugin/index.d.ts +3 -25
- package/dist/ModelEntryDoorGuidePlugin/index.js +0 -5
- package/dist/ModelItemLabelPlugin/ModelItemLabelPlugin.d.ts +4 -0
- package/dist/ModelItemLabelPlugin/index.d.ts +8 -3
- package/dist/ModelItemLabelPlugin/index.js +13 -7
- package/dist/ModelTVVideoPlugin/Plugin.d.ts +4 -0
- package/dist/ModelTVVideoPlugin/index.d.ts +4 -3
- package/dist/ModelTVVideoPlugin/index.js +3 -3
- package/dist/ModelViewPlugin/Plugin.d.ts +17 -0
- package/dist/ModelViewPlugin/index.d.ts +3 -16
- package/dist/PanoCompassPlugin/Plugin.d.ts +47 -0
- package/dist/PanoCompassPlugin/index.d.ts +4 -47
- package/dist/PanoCompassPlugin/index.js +5 -4
- package/dist/PanoMeasurePlugin/index.d.ts +1 -1
- package/dist/PanoMeasurePlugin/index.js +4 -1
- package/dist/PanoRulerPlugin/Plugin.d.ts +31 -0
- package/dist/PanoRulerPlugin/index.d.ts +4 -30
- package/dist/PanoRulerPlugin/index.js +0 -5
- package/dist/PanoSpatialTagPlugin/Plugin.d.ts +33 -0
- package/dist/PanoSpatialTagPlugin/index.d.ts +4 -32
- package/dist/PanoSpatialTagPlugin/index.js +23 -21
- package/dist/_index.d.ts +30 -0
- package/dist/floorplan/index.d.ts +6 -0
- package/dist/index.d.ts +15 -30
- package/dist/index.es.js +149 -22
- package/dist/index.js +177 -43
- package/dist/index.umd.js +180 -47
- package/docs/assets/search.js +1 -1
- package/docs/classes/ModelRoomLabelController.html +5 -8
- package/docs/classes/PanoFloorplanRadarPluginController.html +3 -0
- package/docs/enums/CameraMovementEffect.html +3 -0
- package/docs/enums/DIRECTION.html +1 -0
- package/docs/enums/DISPLAY_STRATEGY_TYPE.html +1 -0
- package/docs/enums/FLOOR_PLAN_ATTACHED_TO.html +1 -1
- package/docs/enums/ModelFloorplanErrorType.html +1 -1
- package/docs/enums/Rotation.html +3 -0
- package/docs/index.html +2 -2
- package/docs/interfaces/CSS3DRenderPluginExportType.html +4 -0
- package/docs/interfaces/CameraMovementPluginExportType.html +17 -0
- package/docs/interfaces/FloorplanBounding.html +10 -0
- package/docs/interfaces/FloorplanData.html +3 -0
- package/docs/interfaces/FloorplanEntrance.html +15 -0
- package/docs/interfaces/FloorplanExtraObject.html +7 -0
- package/docs/interfaces/FloorplanExtraObject3D.html +3 -0
- package/docs/interfaces/FloorplanFloorData.html +3 -0
- package/docs/interfaces/FloorplanImagePosition.html +3 -0
- package/docs/interfaces/FloorplanObserver.html +5 -0
- package/docs/interfaces/FloorplanOutlineItem.html +3 -0
- package/docs/interfaces/FloorplanPosition.html +3 -0
- package/docs/interfaces/FloorplanRoomItem.html +17 -0
- package/docs/interfaces/FloorplanRoomLabelItem.html +7 -0
- package/docs/interfaces/FloorplanServerBounding.html +10 -0
- package/docs/interfaces/FloorplanServerComputedData.html +1 -0
- package/docs/interfaces/FloorplanServerData.html +3 -0
- package/docs/interfaces/FloorplanServerEntrance.html +15 -0
- package/docs/interfaces/FloorplanServerFloorData.html +3 -0
- package/docs/interfaces/FloorplanServerImagePosition.html +3 -0
- package/docs/interfaces/FloorplanServerObserver.html +5 -0
- package/docs/interfaces/FloorplanServerOutlineItem.html +3 -0
- package/docs/interfaces/FloorplanServerPosition.html +3 -0
- package/docs/interfaces/FloorplanServerRoomItem.html +20 -0
- package/docs/interfaces/FloorplanServerRoomLabelItem.html +7 -0
- 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 +3 -3
- package/docs/interfaces/ModelItemLabelPluginData.html +1 -1
- package/docs/interfaces/ModelItemLabelPluginExportReturnsType.html +1 -1
- package/docs/interfaces/ModelItemLabelPluginParametersType.html +1 -1
- package/docs/interfaces/ModelRoomLabelPluginData.html +1 -1
- package/docs/interfaces/ModelTVVideoPluginData.html +1 -1
- package/docs/interfaces/ModelTVVideoPluginExportType.html +1 -1
- package/docs/interfaces/ModelTVVideoPluginParameterType.html +1 -1
- package/docs/interfaces/ModelViewPluginExportType.html +1 -0
- package/docs/interfaces/PanoCompassPluginData.html +1 -1
- package/docs/interfaces/PanoCompassPluginParameterType.html +1 -1
- package/docs/interfaces/PanoCursorRaycasterPluginExportType.html +6 -6
- package/docs/interfaces/PanoCursorRaycasterPluginParameterType.html +1 -0
- package/docs/interfaces/PanoFloorplanRadarPluginControllerParameter.html +1 -0
- package/docs/interfaces/PanoRulerPluginExportType.html +1 -1
- package/docs/interfaces/PanoRulerPluginOptions.html +1 -1
- package/docs/interfaces/PanoRulerPluginParameterType.html +1 -1
- package/docs/interfaces/PanoSpatialTagPluginContentEvent.html +1 -0
- package/docs/interfaces/PanoSpatialTagPluginContentReplacement.html +1 -0
- package/docs/interfaces/PanoSpatialTagPluginData.html +1 -1
- package/docs/interfaces/PanoSpatialTagPluginDataElement.html +1 -0
- package/docs/interfaces/PanoSpatialTagPluginExportType.html +1 -1
- package/docs/interfaces/PanoSpatialTagPluginOriginElement.html +1 -0
- package/docs/interfaces/PanoSpatialTagPluginParameterType.html +1 -1
- package/docs/interfaces/PanoSpatialTagPluginPointElement.html +1 -0
- package/docs/interfaces/PanoSpatialTagPluginTagElement.html +1 -0
- package/docs/interfaces/Point.html +1 -0
- package/docs/interfaces/PointJson.html +1 -1
- package/docs/interfaces/Room.html +1 -0
- package/docs/interfaces/RoomInfo.html +1 -0
- package/docs/interfaces/RoomLabel.html +7 -7
- package/docs/interfaces/RoomRules.html +1 -0
- package/docs/interfaces/Rooms.html +1 -0
- package/docs/interfaces/TopviewFloorplanPluginParameterType.html +10 -10
- package/docs/modules.html +28 -12
- package/libs/CSS3DRenderPlugin/Plugin.d.ts +49 -0
- package/libs/CSS3DRenderPlugin/Plugin.js +182 -0
- package/libs/CSS3DRenderPlugin/index.d.ts +3 -48
- package/libs/CSS3DRenderPlugin/index.js +2 -181
- package/libs/CameraMovementPlugin/CameraMovementPlugin.d.ts +7 -0
- package/libs/CameraMovementPlugin/CameraMovementPlugin.js +159 -0
- package/libs/CameraMovementPlugin/index.d.ts +4 -6
- package/libs/CameraMovementPlugin/index.js +3 -158
- package/libs/ModelChassisCompassPlugin/Plugin.d.ts +19 -0
- package/libs/ModelChassisCompassPlugin/Plugin.js +75 -0
- package/libs/ModelChassisCompassPlugin/index.d.ts +3 -18
- package/libs/ModelChassisCompassPlugin/index.js +2 -74
- package/libs/ModelEntryDoorGuidePlugin/Plugin.d.ts +26 -0
- package/libs/ModelEntryDoorGuidePlugin/Plugin.js +140 -0
- package/libs/ModelEntryDoorGuidePlugin/index.d.ts +3 -25
- package/libs/ModelEntryDoorGuidePlugin/index.js +2 -139
- package/libs/ModelItemLabelPlugin/ModelItemLabelPlugin.d.ts +4 -0
- package/libs/ModelItemLabelPlugin/ModelItemLabelPlugin.js +120 -0
- package/libs/ModelItemLabelPlugin/index.d.ts +8 -3
- package/libs/ModelItemLabelPlugin/index.js +7 -119
- package/libs/ModelTVVideoPlugin/Plugin.d.ts +4 -0
- package/libs/ModelTVVideoPlugin/Plugin.js +254 -0
- package/libs/ModelTVVideoPlugin/index.d.ts +4 -3
- package/libs/ModelTVVideoPlugin/index.js +3 -253
- package/libs/ModelViewPlugin/Plugin.d.ts +17 -0
- package/libs/ModelViewPlugin/Plugin.js +160 -0
- package/libs/ModelViewPlugin/index.d.ts +3 -16
- package/libs/ModelViewPlugin/index.js +2 -159
- package/libs/PanoCompassPlugin/Plugin.d.ts +47 -0
- package/libs/PanoCompassPlugin/Plugin.js +249 -0
- package/libs/PanoCompassPlugin/index.d.ts +4 -47
- package/libs/PanoCompassPlugin/index.js +3 -249
- package/libs/PanoMeasurePlugin/index.d.ts +1 -1
- package/libs/PanoMeasurePlugin/index.js +1 -1
- package/libs/PanoRulerPlugin/Plugin.d.ts +31 -0
- package/libs/PanoRulerPlugin/Plugin.js +402 -0
- package/libs/PanoRulerPlugin/index.d.ts +4 -30
- package/libs/PanoRulerPlugin/index.js +2 -401
- package/libs/PanoSpatialTagPlugin/Plugin.d.ts +33 -0
- package/libs/PanoSpatialTagPlugin/Plugin.js +415 -0
- package/libs/PanoSpatialTagPlugin/index.d.ts +4 -32
- package/libs/PanoSpatialTagPlugin/index.js +4 -412
- package/libs/_index.d.ts +30 -0
- package/libs/_index.js +18 -0
- package/libs/floorplan/index.d.ts +6 -0
- package/libs/floorplan/index.js +7 -0
- package/libs/index.d.ts +15 -30
- package/libs/index.js +25 -17
- package/package.json +5 -4
|
@@ -1,159 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
import { tweenProgress } from '../shared-utils/animationFrame/tween';
|
|
4
|
-
import { Rotation, } from './typing';
|
|
5
|
-
import { formatLongitude, formatLatitude } from '../shared-utils/animationFrame/formatRad';
|
|
6
|
-
import { progressNumber } from '../shared-utils/animationFrame/calculateProgress';
|
|
7
|
-
const getLongitudeParams = (from, to, rotation) => {
|
|
8
|
-
const PI = Math.PI;
|
|
9
|
-
const PI_2 = PI * 2;
|
|
10
|
-
from = formatLongitude(from);
|
|
11
|
-
to = formatLongitude(to);
|
|
12
|
-
// 逆时针旋转,初始值必须是较大的值
|
|
13
|
-
if (rotation === Rotation.Anticlockwise && from < to)
|
|
14
|
-
from += PI_2;
|
|
15
|
-
// 顺时针旋转,结束值必须是较大值
|
|
16
|
-
if (rotation === Rotation.Clockwise && to < from)
|
|
17
|
-
to += PI_2;
|
|
18
|
-
// Loop 旋转,找锐角旋转
|
|
19
|
-
// 如果 to 比 from 大 180°,逆时针转
|
|
20
|
-
// 如果 from 比 to 大 180°,顺时针转
|
|
21
|
-
if (rotation === Rotation.Loop && to - from > PI)
|
|
22
|
-
return getLongitudeParams(from, to, Rotation.Anticlockwise);
|
|
23
|
-
if (rotation === Rotation.Loop && from - to > PI)
|
|
24
|
-
return getLongitudeParams(from, to, Rotation.Clockwise);
|
|
25
|
-
return { from, to };
|
|
26
|
-
};
|
|
27
|
-
/**
|
|
28
|
-
* **运镜插件** 模拟类似于电影运镜效果。
|
|
29
|
-
*/
|
|
30
|
-
export const CameraMovementPlugin = (five) => {
|
|
31
|
-
const state = {};
|
|
32
|
-
const move = async (args, duration, opts = { preload: true }) => {
|
|
33
|
-
if (state.interruptCallback) {
|
|
34
|
-
state.interruptCallback(false);
|
|
35
|
-
}
|
|
36
|
-
if (opts.asyncStartCallback) {
|
|
37
|
-
await opts.asyncStartCallback();
|
|
38
|
-
}
|
|
39
|
-
if (args.mode && args.mode !== five.currentMode) {
|
|
40
|
-
await five.changeMode(args.mode);
|
|
41
|
-
}
|
|
42
|
-
if (opts.preload && args.panoIndex !== undefined && args.panoIndex !== five.panoIndex) {
|
|
43
|
-
await five.preloadPano(args.panoIndex);
|
|
44
|
-
}
|
|
45
|
-
if (opts.asyncEndCallback) {
|
|
46
|
-
await opts.asyncEndCallback();
|
|
47
|
-
}
|
|
48
|
-
if (args.panoIndex === undefined &&
|
|
49
|
-
args.fov === undefined &&
|
|
50
|
-
args.latitude === undefined &&
|
|
51
|
-
args.longitude === undefined) {
|
|
52
|
-
return true;
|
|
53
|
-
}
|
|
54
|
-
return await new Promise((resolve, reject) => {
|
|
55
|
-
const panoIndex = args.panoIndex !== undefined ? args.panoIndex : five.panoIndex;
|
|
56
|
-
if (panoIndex !== undefined) {
|
|
57
|
-
five.moveToPano(panoIndex, Object.assign({
|
|
58
|
-
duration,
|
|
59
|
-
moveEndCallback: () => resolve(true),
|
|
60
|
-
moveCancelCallback: () => reject(false), // 移动开始
|
|
61
|
-
}, args));
|
|
62
|
-
}
|
|
63
|
-
else {
|
|
64
|
-
reject(false);
|
|
65
|
-
}
|
|
66
|
-
});
|
|
67
|
-
};
|
|
68
|
-
const getAnimeParams = (args) => {
|
|
69
|
-
const currentFiveState = five.state;
|
|
70
|
-
// latitude
|
|
71
|
-
const fromLatitude = formatLatitude(currentFiveState.latitude);
|
|
72
|
-
const toLatitude = formatLatitude(args.latitude);
|
|
73
|
-
// longitude
|
|
74
|
-
const { from: fromLongitude, to: toLongitude } = getLongitudeParams(currentFiveState.longitude, args.longitude, args.rotation || Rotation.Loop);
|
|
75
|
-
// fov
|
|
76
|
-
const fromFov = currentFiveState.fov;
|
|
77
|
-
const toFov = args.fov;
|
|
78
|
-
return {
|
|
79
|
-
from: { latitude: fromLatitude, longitude: fromLongitude, fov: fromFov },
|
|
80
|
-
to: { latitude: toLatitude, longitude: toLongitude, fov: toFov },
|
|
81
|
-
};
|
|
82
|
-
};
|
|
83
|
-
const rotate = async (args, duration, opts = {}) => {
|
|
84
|
-
if (state.interruptCallback) {
|
|
85
|
-
state.interruptCallback(false);
|
|
86
|
-
}
|
|
87
|
-
if (opts.asyncStartCallback) {
|
|
88
|
-
await opts.asyncStartCallback();
|
|
89
|
-
}
|
|
90
|
-
if (five.currentMode !== Five.Mode.Panorama) {
|
|
91
|
-
await five.changeMode(Five.Mode.Panorama);
|
|
92
|
-
}
|
|
93
|
-
if (args.panoIndex !== undefined && args.panoIndex !== five.panoIndex) {
|
|
94
|
-
if (opts.preload)
|
|
95
|
-
await five.preloadPano(args.panoIndex);
|
|
96
|
-
await new Promise((resolve, reject) => {
|
|
97
|
-
if (!args.panoIndex) {
|
|
98
|
-
resolve(true);
|
|
99
|
-
return;
|
|
100
|
-
}
|
|
101
|
-
five.moveToPano(args.panoIndex, {
|
|
102
|
-
moveEndCallback: () => resolve(true),
|
|
103
|
-
moveCancelCallback: () => reject(false), // 移动开始
|
|
104
|
-
});
|
|
105
|
-
});
|
|
106
|
-
}
|
|
107
|
-
if (opts.asyncEndCallback) {
|
|
108
|
-
await opts.asyncEndCallback();
|
|
109
|
-
}
|
|
110
|
-
const { from, to } = getAnimeParams(args);
|
|
111
|
-
return await new Promise((resolve) => {
|
|
112
|
-
const onUpdate = ({ progress }) => {
|
|
113
|
-
const state = {};
|
|
114
|
-
state.longitude = progressNumber(from.longitude, to.longitude, progress);
|
|
115
|
-
state.latitude = progressNumber(from.latitude, to.latitude, progress);
|
|
116
|
-
state.fov = progressNumber(from.fov, to.fov, progress);
|
|
117
|
-
five.setState(state, true);
|
|
118
|
-
};
|
|
119
|
-
const onComplete = () => {
|
|
120
|
-
resolve(true);
|
|
121
|
-
};
|
|
122
|
-
const onDestroy = () => {
|
|
123
|
-
resolve(false);
|
|
124
|
-
};
|
|
125
|
-
const animeDuration = args.rotateSpeed
|
|
126
|
-
? Math.ceil((Math.abs(to.longitude - from.longitude) / args.rotateSpeed) * 1000)
|
|
127
|
-
: duration;
|
|
128
|
-
const tween = tweenProgress(animeDuration, TWEEN.Easing.Linear.None)
|
|
129
|
-
.onUpdate(onUpdate)
|
|
130
|
-
.onComplete(onComplete)
|
|
131
|
-
.onDestroy(onDestroy);
|
|
132
|
-
if (args.rotation === Rotation.Loop) {
|
|
133
|
-
tween.repeat(Infinity).yoyo(true);
|
|
134
|
-
}
|
|
135
|
-
/**
|
|
136
|
-
* 中断回调:可能会被其他动画中断。
|
|
137
|
-
*/
|
|
138
|
-
state.interruptCallback = (flag = true) => {
|
|
139
|
-
tween.destroy();
|
|
140
|
-
state.interruptCallback = undefined;
|
|
141
|
-
if (state.timeoutId) {
|
|
142
|
-
clearTimeout(state.timeoutId);
|
|
143
|
-
state.timeoutId = undefined;
|
|
144
|
-
}
|
|
145
|
-
resolve(flag);
|
|
146
|
-
};
|
|
147
|
-
state.timeoutId = setTimeout(() => {
|
|
148
|
-
// 总时间到了之后强制结束,同时也是 Loop 模式的结束方式
|
|
149
|
-
if (state.interruptCallback)
|
|
150
|
-
state.interruptCallback(true);
|
|
151
|
-
}, duration);
|
|
152
|
-
});
|
|
153
|
-
};
|
|
154
|
-
return {
|
|
155
|
-
move,
|
|
156
|
-
rotate,
|
|
157
|
-
};
|
|
158
|
-
};
|
|
1
|
+
import CameraMovementPlugin from "./CameraMovementPlugin";
|
|
2
|
+
export { CameraMovementPlugin };
|
|
159
3
|
export default CameraMovementPlugin;
|
|
4
|
+
export { CameraMovementEffect, Rotation } from './typing';
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { FivePlugin } from '@realsee/five';
|
|
2
|
+
export interface ModelChassisCompassPluginParameterType {
|
|
3
|
+
north_rad?: number;
|
|
4
|
+
fbx_url?: string;
|
|
5
|
+
}
|
|
6
|
+
export interface ModelChassisCompassPluginData {
|
|
7
|
+
north_rad?: number;
|
|
8
|
+
fbx_url?: string;
|
|
9
|
+
}
|
|
10
|
+
export interface ModelChassisCompassPluginExportType {
|
|
11
|
+
enable: () => void;
|
|
12
|
+
disable: () => void;
|
|
13
|
+
load: (data?: ModelChassisCompassPluginData) => Promise<boolean>;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* 模型底盘指南针插件
|
|
17
|
+
*/
|
|
18
|
+
export declare const ModelChassisCompassPlugin: FivePlugin<ModelChassisCompassPluginParameterType, ModelChassisCompassPluginExportType>;
|
|
19
|
+
export default ModelChassisCompassPlugin;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import * as THREE from 'three';
|
|
2
|
+
import { FBXLoader } from 'three/examples/jsm/loaders/FBXLoader';
|
|
3
|
+
import object3d2LocalMatrix from '../shared-utils/object3d2LocalMatrix';
|
|
4
|
+
import transfromToMeshBasicMaterial from '../shared-utils/three/transfromToMeshBasicMaterial';
|
|
5
|
+
/**
|
|
6
|
+
* 模型底盘指南针插件
|
|
7
|
+
*/
|
|
8
|
+
export const ModelChassisCompassPlugin = (five, params) => {
|
|
9
|
+
const defaultFbxUrl = params.fbx_url || '//vrlab-static.ljcdn.com/release/web/v3/dipan3/dipan.FBX';
|
|
10
|
+
const defaultNorthRad = params.north_rad || undefined;
|
|
11
|
+
// 局部状态
|
|
12
|
+
const state = {};
|
|
13
|
+
const load = async (data) => {
|
|
14
|
+
const fbxUrl = (data === null || data === void 0 ? void 0 : data.fbx_url) || defaultFbxUrl;
|
|
15
|
+
const northRad = (data === null || data === void 0 ? void 0 : data.north_rad) || defaultNorthRad;
|
|
16
|
+
if (!northRad) {
|
|
17
|
+
throw new Error('"northRad"配置参数缺失:未配置指南针指向!');
|
|
18
|
+
}
|
|
19
|
+
const bounding = five.model.bounding;
|
|
20
|
+
const xOffset = bounding.max.x - bounding.min.x;
|
|
21
|
+
const zOffset = bounding.max.z - bounding.min.z;
|
|
22
|
+
const maxOffset = Math.max(xOffset, zOffset);
|
|
23
|
+
const fbxLoader = new FBXLoader();
|
|
24
|
+
const object = await fbxLoader.loadAsync(fbxUrl);
|
|
25
|
+
transfromToMeshBasicMaterial(object, {
|
|
26
|
+
transparent: true,
|
|
27
|
+
side: THREE.DoubleSide,
|
|
28
|
+
blending: THREE.AdditiveBlending,
|
|
29
|
+
});
|
|
30
|
+
const rotation = [0, northRad - Math.PI / 2, 0];
|
|
31
|
+
const { model: { bounding: { max: { x: xMax, z: zMax }, min: { x: xMin, y: yMin, z: zMin }, }, }, } = five;
|
|
32
|
+
state.yBase = yMin;
|
|
33
|
+
const position = { x: (xMax + xMin) / 2, y: yMin - 1.6, z: (zMax + zMin) / 2 };
|
|
34
|
+
const scale = 0.0045 * maxOffset;
|
|
35
|
+
object3d2LocalMatrix(object, { position, rotation, scale });
|
|
36
|
+
state.object = object;
|
|
37
|
+
return true;
|
|
38
|
+
};
|
|
39
|
+
const onCameraUpdate = ({ latitude }) => {
|
|
40
|
+
if (!state.object)
|
|
41
|
+
return;
|
|
42
|
+
const y = getPositionY(latitude);
|
|
43
|
+
if (y) {
|
|
44
|
+
state.object.position.y = y;
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
const getPositionY = (latitude) => {
|
|
48
|
+
if (state.yBase === undefined)
|
|
49
|
+
return;
|
|
50
|
+
const difference = 0.6;
|
|
51
|
+
if (latitude >= Math.PI / 4)
|
|
52
|
+
return state.yBase - (difference + 1.6);
|
|
53
|
+
const ratio = latitude * (4 / Math.PI);
|
|
54
|
+
return state.yBase - (difference * ratio + 1.6);
|
|
55
|
+
};
|
|
56
|
+
const enable = () => {
|
|
57
|
+
if (!state.object)
|
|
58
|
+
return;
|
|
59
|
+
const y = getPositionY(five.getPose().latitude);
|
|
60
|
+
if (y)
|
|
61
|
+
state.object.position.y = y;
|
|
62
|
+
five.scene.add(state.object);
|
|
63
|
+
five.needsRender = true;
|
|
64
|
+
five.on('cameraDirectionUpdate', onCameraUpdate);
|
|
65
|
+
};
|
|
66
|
+
const disable = () => {
|
|
67
|
+
if (!state.object)
|
|
68
|
+
return;
|
|
69
|
+
five.scene.remove(state.object);
|
|
70
|
+
five.needsRender = true;
|
|
71
|
+
five.off('cameraDirectionUpdate', onCameraUpdate);
|
|
72
|
+
};
|
|
73
|
+
return { load, disable, enable };
|
|
74
|
+
};
|
|
75
|
+
export default ModelChassisCompassPlugin;
|
|
@@ -1,19 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
export
|
|
3
|
-
north_rad?: number;
|
|
4
|
-
fbx_url?: string;
|
|
5
|
-
}
|
|
6
|
-
export interface ModelChassisCompassPluginData {
|
|
7
|
-
north_rad?: number;
|
|
8
|
-
fbx_url?: string;
|
|
9
|
-
}
|
|
10
|
-
export interface ModelChassisCompassPluginExportType {
|
|
11
|
-
enable: () => void;
|
|
12
|
-
disable: () => void;
|
|
13
|
-
load: (data?: ModelChassisCompassPluginData) => Promise<boolean>;
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* 模型底盘指南针插件
|
|
17
|
-
*/
|
|
18
|
-
export declare const ModelChassisCompassPlugin: FivePlugin<ModelChassisCompassPluginParameterType, ModelChassisCompassPluginExportType>;
|
|
1
|
+
import ModelChassisCompassPlugin from './Plugin';
|
|
2
|
+
export { ModelChassisCompassPlugin };
|
|
19
3
|
export default ModelChassisCompassPlugin;
|
|
4
|
+
export type { ModelChassisCompassPluginParameterType, ModelChassisCompassPluginData, ModelChassisCompassPluginExportType } from './Plugin';
|
|
@@ -1,75 +1,3 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
import object3d2LocalMatrix from '../shared-utils/object3d2LocalMatrix';
|
|
4
|
-
import transfromToMeshBasicMaterial from '../shared-utils/three/transfromToMeshBasicMaterial';
|
|
5
|
-
/**
|
|
6
|
-
* 模型底盘指南针插件
|
|
7
|
-
*/
|
|
8
|
-
export const ModelChassisCompassPlugin = (five, params) => {
|
|
9
|
-
const defaultFbxUrl = params.fbx_url || '//vrlab-static.ljcdn.com/release/web/v3/dipan3/dipan.FBX';
|
|
10
|
-
const defaultNorthRad = params.north_rad || undefined;
|
|
11
|
-
// 局部状态
|
|
12
|
-
const state = {};
|
|
13
|
-
const load = async (data) => {
|
|
14
|
-
const fbxUrl = (data === null || data === void 0 ? void 0 : data.fbx_url) || defaultFbxUrl;
|
|
15
|
-
const northRad = (data === null || data === void 0 ? void 0 : data.north_rad) || defaultNorthRad;
|
|
16
|
-
if (!northRad) {
|
|
17
|
-
throw new Error('"northRad"配置参数缺失:未配置指南针指向!');
|
|
18
|
-
}
|
|
19
|
-
const bounding = five.model.bounding;
|
|
20
|
-
const xOffset = bounding.max.x - bounding.min.x;
|
|
21
|
-
const zOffset = bounding.max.z - bounding.min.z;
|
|
22
|
-
const maxOffset = Math.max(xOffset, zOffset);
|
|
23
|
-
const fbxLoader = new FBXLoader();
|
|
24
|
-
const object = await fbxLoader.loadAsync(fbxUrl);
|
|
25
|
-
transfromToMeshBasicMaterial(object, {
|
|
26
|
-
transparent: true,
|
|
27
|
-
side: THREE.DoubleSide,
|
|
28
|
-
blending: THREE.AdditiveBlending,
|
|
29
|
-
});
|
|
30
|
-
const rotation = [0, northRad - Math.PI / 2, 0];
|
|
31
|
-
const { model: { bounding: { max: { x: xMax, z: zMax }, min: { x: xMin, y: yMin, z: zMin }, }, }, } = five;
|
|
32
|
-
state.yBase = yMin;
|
|
33
|
-
const position = { x: (xMax + xMin) / 2, y: yMin - 1.6, z: (zMax + zMin) / 2 };
|
|
34
|
-
const scale = 0.0045 * maxOffset;
|
|
35
|
-
object3d2LocalMatrix(object, { position, rotation, scale });
|
|
36
|
-
state.object = object;
|
|
37
|
-
return true;
|
|
38
|
-
};
|
|
39
|
-
const onCameraUpdate = ({ latitude }) => {
|
|
40
|
-
if (!state.object)
|
|
41
|
-
return;
|
|
42
|
-
const y = getPositionY(latitude);
|
|
43
|
-
if (y) {
|
|
44
|
-
state.object.position.y = y;
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
const getPositionY = (latitude) => {
|
|
48
|
-
if (state.yBase === undefined)
|
|
49
|
-
return;
|
|
50
|
-
const difference = 0.6;
|
|
51
|
-
if (latitude >= Math.PI / 4)
|
|
52
|
-
return state.yBase - (difference + 1.6);
|
|
53
|
-
const ratio = latitude * (4 / Math.PI);
|
|
54
|
-
return state.yBase - (difference * ratio + 1.6);
|
|
55
|
-
};
|
|
56
|
-
const enable = () => {
|
|
57
|
-
if (!state.object)
|
|
58
|
-
return;
|
|
59
|
-
const y = getPositionY(five.getPose().latitude);
|
|
60
|
-
if (y)
|
|
61
|
-
state.object.position.y = y;
|
|
62
|
-
five.scene.add(state.object);
|
|
63
|
-
five.needsRender = true;
|
|
64
|
-
five.on('cameraDirectionUpdate', onCameraUpdate);
|
|
65
|
-
};
|
|
66
|
-
const disable = () => {
|
|
67
|
-
if (!state.object)
|
|
68
|
-
return;
|
|
69
|
-
five.scene.remove(state.object);
|
|
70
|
-
five.needsRender = true;
|
|
71
|
-
five.off('cameraDirectionUpdate', onCameraUpdate);
|
|
72
|
-
};
|
|
73
|
-
return { load, disable, enable };
|
|
74
|
-
};
|
|
1
|
+
import ModelChassisCompassPlugin from './Plugin';
|
|
2
|
+
export { ModelChassisCompassPlugin };
|
|
75
3
|
export default ModelChassisCompassPlugin;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { FivePlugin } from '@realsee/five';
|
|
2
|
+
import type { Vector3Position } from '../typings/math.type';
|
|
3
|
+
export interface ModelEntryDoorGuidePluginData {
|
|
4
|
+
position?: Vector3Position;
|
|
5
|
+
rad?: number;
|
|
6
|
+
fbx_url?: string;
|
|
7
|
+
}
|
|
8
|
+
export declare type ModelEntryDoorGuidePluginParameterType = {
|
|
9
|
+
animationEnabled?: boolean;
|
|
10
|
+
} & ModelEntryDoorGuidePluginData;
|
|
11
|
+
export interface ModelEntryDoorGuidePluginExportType {
|
|
12
|
+
enable: (config?: {
|
|
13
|
+
animationEnable?: boolean;
|
|
14
|
+
}) => boolean;
|
|
15
|
+
disable: () => boolean;
|
|
16
|
+
load: (data?: Partial<ModelEntryDoorGuidePluginData>) => Promise<boolean>;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* 模型入户门引导插件
|
|
20
|
+
*/
|
|
21
|
+
export declare const ModelEntryDoorGuidePlugin: FivePlugin<ModelEntryDoorGuidePluginParameterType, ModelEntryDoorGuidePluginExportType>;
|
|
22
|
+
export declare const modelEntryDoorGuidePluginServerParams: {
|
|
23
|
+
name: string;
|
|
24
|
+
version: number;
|
|
25
|
+
};
|
|
26
|
+
export default ModelEntryDoorGuidePlugin;
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { AnimationMixer, MeshBasicMaterial } from 'three';
|
|
2
|
+
import * as THREE from 'three';
|
|
3
|
+
import { FBXLoader } from 'three/examples/jsm/loaders/FBXLoader';
|
|
4
|
+
import createCanvasTextTexture from '../shared-utils/createCanvasTextTexture';
|
|
5
|
+
import transformPositionToVector3 from '../shared-utils/three/transformPositionToVector3';
|
|
6
|
+
import transfromToMeshBasicMaterial from '../shared-utils/three/transfromToMeshBasicMaterial';
|
|
7
|
+
/**
|
|
8
|
+
* 模型入户门引导插件
|
|
9
|
+
*/
|
|
10
|
+
export const ModelEntryDoorGuidePlugin = (five, params) => {
|
|
11
|
+
var _a, _b, _c;
|
|
12
|
+
// 局部状态
|
|
13
|
+
const state = {};
|
|
14
|
+
const defaultAnimationEnable = (_a = params.animationEnabled) !== null && _a !== void 0 ? _a : true;
|
|
15
|
+
const defaultModelPosition = (_b = params.position) !== null && _b !== void 0 ? _b : undefined;
|
|
16
|
+
const defaultRad = (_c = params.rad) !== null && _c !== void 0 ? _c : undefined;
|
|
17
|
+
const defaultFbxUrl = params.fbx_url || '//vrlab-image4.ljcdn.com/release/web/entryDoorMini/Anim_Door1.fbx';
|
|
18
|
+
const mixers = [];
|
|
19
|
+
const load = async (data) => {
|
|
20
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
21
|
+
const position = (_a = data === null || data === void 0 ? void 0 : data.position) !== null && _a !== void 0 ? _a : defaultModelPosition;
|
|
22
|
+
if (!position)
|
|
23
|
+
return Promise.reject(`ModelEntryDoorGuidePlugin.load(): position is undefined`);
|
|
24
|
+
const modelPosition = transformPositionToVector3(position);
|
|
25
|
+
const rad = (_b = data === null || data === void 0 ? void 0 : data.rad) !== null && _b !== void 0 ? _b : defaultRad;
|
|
26
|
+
const fbxUrl = (_c = data === null || data === void 0 ? void 0 : data.fbx_url) !== null && _c !== void 0 ? _c : defaultFbxUrl;
|
|
27
|
+
state.rad = rad;
|
|
28
|
+
if (rad === undefined)
|
|
29
|
+
return Promise.reject(`ModelEntryDoorGuidePlugin.load(): rad is ${rad}`);
|
|
30
|
+
// 加载模型
|
|
31
|
+
const object = await new FBXLoader().loadAsync(fbxUrl);
|
|
32
|
+
// 设置位置
|
|
33
|
+
object.position.copy(modelPosition);
|
|
34
|
+
object.rotation.z = rad;
|
|
35
|
+
object.scale.set(0.8, 0.8, 0.8);
|
|
36
|
+
transfromToMeshBasicMaterial(object, { transparent: true, side: THREE.DoubleSide });
|
|
37
|
+
const textMesh = (_g = (_f = (_e = (_d = object.children) === null || _d === void 0 ? void 0 : _d[0]) === null || _e === void 0 ? void 0 : _e.children) === null || _f === void 0 ? void 0 : _f[3]) === null || _g === void 0 ? void 0 : _g.clone();
|
|
38
|
+
if (!textMesh)
|
|
39
|
+
return Promise.reject(`ModelEntryDoorGuidePlugin.load(): textMesh is ${textMesh}`);
|
|
40
|
+
textMesh.material = new MeshBasicMaterial({ transparent: true, map: createCanvasTextTexture('入户门') });
|
|
41
|
+
textMesh.renderOrder = 3;
|
|
42
|
+
object.children[0].add(textMesh);
|
|
43
|
+
state.object = object;
|
|
44
|
+
return true;
|
|
45
|
+
};
|
|
46
|
+
const initAnimation = () => {
|
|
47
|
+
if (state.animation)
|
|
48
|
+
return;
|
|
49
|
+
if (!state.object)
|
|
50
|
+
return console.error('ModelEntryDoorGuidePlugin.initAnimation(): state.object is ', state.object);
|
|
51
|
+
// action
|
|
52
|
+
const animationSpeed = 1;
|
|
53
|
+
const mixer = new AnimationMixer(state.object);
|
|
54
|
+
mixers.push(mixer);
|
|
55
|
+
const action = mixer.clipAction(state.object.animations[0]);
|
|
56
|
+
action.timeScale = animationSpeed;
|
|
57
|
+
let stopAnimation;
|
|
58
|
+
const requestAnimationFrameLoop = () => {
|
|
59
|
+
let index = 0;
|
|
60
|
+
let oldTime = 0;
|
|
61
|
+
const minDeltaTime = 1000 / 30;
|
|
62
|
+
const animation = (time) => {
|
|
63
|
+
index = requestAnimationFrame(animation);
|
|
64
|
+
const deltaTime = time - oldTime;
|
|
65
|
+
if (deltaTime < minDeltaTime)
|
|
66
|
+
return;
|
|
67
|
+
oldTime = time;
|
|
68
|
+
mixers.forEach((mixer) => mixer.update(deltaTime / 1000));
|
|
69
|
+
five.needsRender = true;
|
|
70
|
+
};
|
|
71
|
+
index = requestAnimationFrame(animation);
|
|
72
|
+
return () => {
|
|
73
|
+
cancelAnimationFrame(index);
|
|
74
|
+
};
|
|
75
|
+
};
|
|
76
|
+
const play = () => {
|
|
77
|
+
if (stopAnimation)
|
|
78
|
+
return;
|
|
79
|
+
action.play();
|
|
80
|
+
stopAnimation = requestAnimationFrameLoop();
|
|
81
|
+
// 开始播动画时,rotation可能会还原
|
|
82
|
+
requestAnimationFrame(() => {
|
|
83
|
+
if (state.object && state.object.rotation.z !== state.rad)
|
|
84
|
+
state.object.rotation.z = state.rad;
|
|
85
|
+
});
|
|
86
|
+
};
|
|
87
|
+
const stop = () => {
|
|
88
|
+
action.stop();
|
|
89
|
+
stopAnimation === null || stopAnimation === void 0 ? void 0 : stopAnimation();
|
|
90
|
+
stopAnimation = undefined;
|
|
91
|
+
};
|
|
92
|
+
const animation = { play, stop };
|
|
93
|
+
state.animation = animation;
|
|
94
|
+
};
|
|
95
|
+
const show = (config) => {
|
|
96
|
+
var _a;
|
|
97
|
+
if (!state.object)
|
|
98
|
+
return console.error('ModelEntryDoorGuidePlugin.enable(): object is ', state.object);
|
|
99
|
+
const animationEnable = (_a = config === null || config === void 0 ? void 0 : config.animationEnable) !== null && _a !== void 0 ? _a : defaultAnimationEnable;
|
|
100
|
+
if (animationEnable) {
|
|
101
|
+
if (!state.animation)
|
|
102
|
+
initAnimation();
|
|
103
|
+
state.animation.play();
|
|
104
|
+
}
|
|
105
|
+
five.scene.add(state.object);
|
|
106
|
+
five.needsRender = true;
|
|
107
|
+
};
|
|
108
|
+
const hide = () => {
|
|
109
|
+
if (!state.object)
|
|
110
|
+
return;
|
|
111
|
+
if (state.animation)
|
|
112
|
+
state.animation.stop();
|
|
113
|
+
five.scene.remove(state.object);
|
|
114
|
+
five.needsRender = true;
|
|
115
|
+
};
|
|
116
|
+
const modeChangeHandler = (mode) => (mode === 'Floorplan' ? show() : hide());
|
|
117
|
+
const enable = (config) => {
|
|
118
|
+
if (state.enabled)
|
|
119
|
+
return true;
|
|
120
|
+
state.enabled = true;
|
|
121
|
+
modeChangeHandler(five.currentMode);
|
|
122
|
+
five.on('modeChange', modeChangeHandler);
|
|
123
|
+
show(config);
|
|
124
|
+
return true;
|
|
125
|
+
};
|
|
126
|
+
const disable = () => {
|
|
127
|
+
if (!state.enabled)
|
|
128
|
+
return true;
|
|
129
|
+
state.enabled = false;
|
|
130
|
+
hide();
|
|
131
|
+
five.off('modeChange', modeChangeHandler);
|
|
132
|
+
return true;
|
|
133
|
+
};
|
|
134
|
+
return { load, enable, disable };
|
|
135
|
+
};
|
|
136
|
+
export const modelEntryDoorGuidePluginServerParams = {
|
|
137
|
+
name: 'ModelEntryDoorGuidePlugin',
|
|
138
|
+
version: 0,
|
|
139
|
+
};
|
|
140
|
+
export default ModelEntryDoorGuidePlugin;
|
|
@@ -1,26 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
export interface ModelEntryDoorGuidePluginData {
|
|
4
|
-
position?: Vector3Position;
|
|
5
|
-
rad?: number;
|
|
6
|
-
fbx_url?: string;
|
|
7
|
-
}
|
|
8
|
-
export declare type ModelEntryDoorGuidePluginParameterType = {
|
|
9
|
-
animationEnabled?: boolean;
|
|
10
|
-
} & ModelEntryDoorGuidePluginData;
|
|
11
|
-
export interface ModelEntryDoorGuidePluginExportType {
|
|
12
|
-
enable: (config?: {
|
|
13
|
-
animationEnable?: boolean;
|
|
14
|
-
}) => boolean;
|
|
15
|
-
disable: () => boolean;
|
|
16
|
-
load: (data?: Partial<ModelEntryDoorGuidePluginData>) => Promise<boolean>;
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* 模型入户门引导插件
|
|
20
|
-
*/
|
|
21
|
-
export declare const ModelEntryDoorGuidePlugin: FivePlugin<ModelEntryDoorGuidePluginParameterType, ModelEntryDoorGuidePluginExportType>;
|
|
22
|
-
export declare const modelEntryDoorGuidePluginServerParams: {
|
|
23
|
-
name: string;
|
|
24
|
-
version: number;
|
|
25
|
-
};
|
|
1
|
+
import ModelEntryDoorGuidePlugin from './Plugin';
|
|
2
|
+
export { ModelEntryDoorGuidePlugin };
|
|
26
3
|
export default ModelEntryDoorGuidePlugin;
|
|
4
|
+
export type { ModelEntryDoorGuidePluginData, ModelEntryDoorGuidePluginParameterType, ModelEntryDoorGuidePluginExportType } from './Plugin';
|