@realsee/vreo 0.2.0-alpha.2 → 0.2.0-alpha.5
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/lib/Player/custom/SpatialScenePanel/index.js +3 -12
- package/lib/Player/modules/keyframes/PanoTextLabel/index.js +4 -12
- package/lib/fivePlugins/CameraMovementPlugin/index.js +9 -6
- package/lib/fivePlugins/CameraMovementPlugin/typings.d.ts +2 -2
- package/package.json +1 -1
- package/resources/Player/custom/SpatialScenePanel/index.tsx +6 -12
- package/resources/Player/modules/keyframes/PanoTextLabel/index.tsx +2 -2
- package/resources/fivePlugins/CameraMovementPlugin/index.ts +9 -6
- package/resources/fivePlugins/CameraMovementPlugin/typings.ts +2 -2
|
@@ -39,8 +39,6 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
|
39
39
|
|
|
40
40
|
var searchV1 = function searchV1(_ref) {
|
|
41
41
|
var five = _ref.five,
|
|
42
|
-
position = _ref.position,
|
|
43
|
-
rotation = _ref.rotation,
|
|
44
42
|
dom = _ref.dom;
|
|
45
43
|
var cameraDirection = new _three.Vector3();
|
|
46
44
|
five.camera.getWorldDirection(cameraDirection);
|
|
@@ -65,14 +63,14 @@ var searchV1 = function searchV1(_ref) {
|
|
|
65
63
|
var rightTop = new _three.Vector3(right, top);
|
|
66
64
|
var rightBottom = new _three.Vector3(right, bottom);
|
|
67
65
|
var points = [leftBottom, rightBottom, rightTop, leftTop].map(function (point) {
|
|
68
|
-
point.setX(point.x / window.innerWidth * 2 -
|
|
66
|
+
point.setX(point.x / window.innerWidth * 2 - 2);
|
|
69
67
|
point.setY(-(point.y / window.innerHeight) * 2 + 1);
|
|
70
68
|
point.setZ(0.5);
|
|
71
69
|
return point.unproject(five.camera).addScaledVector(cameraDirection, 0.2);
|
|
72
70
|
}); // const colors = [0xdc143c, 0xffff00, 0x0000ff, 0x008000]
|
|
73
71
|
// points.forEach((p, index) => five.scene.add(getSphere(p, colors[index])))
|
|
74
72
|
|
|
75
|
-
var ratio = leftBottom.distanceTo(rightBottom) /
|
|
73
|
+
var ratio = leftBottom.distanceTo(rightBottom) / 120;
|
|
76
74
|
return {
|
|
77
75
|
points: points,
|
|
78
76
|
ratio: ratio
|
|
@@ -98,19 +96,15 @@ function SpatialScenePanel(props) {
|
|
|
98
96
|
return;
|
|
99
97
|
}
|
|
100
98
|
|
|
101
|
-
var data = keyframe.data;
|
|
99
|
+
var data = keyframe.data;
|
|
102
100
|
|
|
103
101
|
var _searchV = searchV1({
|
|
104
102
|
five: props.five,
|
|
105
|
-
position: new _three.Vector3(data.position.x, data.position.y, data.position.z),
|
|
106
|
-
quaternion: data.quaternion,
|
|
107
103
|
dom: ref.current
|
|
108
104
|
}),
|
|
109
105
|
points = _searchV.points,
|
|
110
106
|
ratio = _searchV.ratio;
|
|
111
107
|
|
|
112
|
-
console.log(points, ratio);
|
|
113
|
-
|
|
114
108
|
var _ref2 = rendererRef.current.create3DDomContainer(points, {
|
|
115
109
|
ratio: ratio,
|
|
116
110
|
autoRender: false
|
|
@@ -157,9 +151,6 @@ function SpatialScenePanel(props) {
|
|
|
157
151
|
}, end - start);
|
|
158
152
|
};
|
|
159
153
|
|
|
160
|
-
Object.assign(window, {
|
|
161
|
-
$SpatialScenePanelCallback: callback
|
|
162
|
-
});
|
|
163
154
|
props.subscribe.on(_VreoUnit.VreoKeyframeEnum.Custom, callback);
|
|
164
155
|
return function () {
|
|
165
156
|
props.subscribe.off(_VreoUnit.VreoKeyframeEnum.Custom, callback);
|
|
@@ -63,12 +63,8 @@ function PanoTextLabel() {
|
|
|
63
63
|
var res = project2d(new _three.Vector3(x, y, z));
|
|
64
64
|
if (!res) return;
|
|
65
65
|
var left = res.x,
|
|
66
|
-
top = res.y;
|
|
67
|
-
|
|
68
|
-
$PanoTextLabel: {
|
|
69
|
-
setState: setState
|
|
70
|
-
}
|
|
71
|
-
});
|
|
66
|
+
top = res.y; // Object.assign(window, { $PanoTextLabel: { setState } })
|
|
67
|
+
|
|
72
68
|
setState({
|
|
73
69
|
left: left,
|
|
74
70
|
top: top,
|
|
@@ -80,12 +76,8 @@ function PanoTextLabel() {
|
|
|
80
76
|
}, end - start);
|
|
81
77
|
};
|
|
82
78
|
|
|
83
|
-
controller.on(_VreoUnit.VreoKeyframeEnum.PanoTextLabel, callback);
|
|
84
|
-
|
|
85
|
-
$panoTextLabel: {
|
|
86
|
-
setState: setState
|
|
87
|
-
}
|
|
88
|
-
});
|
|
79
|
+
controller.on(_VreoUnit.VreoKeyframeEnum.PanoTextLabel, callback); // Object.assign(window, { $panoTextLabel: { setState } })
|
|
80
|
+
|
|
89
81
|
return function () {
|
|
90
82
|
controller.off(_VreoUnit.VreoKeyframeEnum.PanoTextLabel, callback);
|
|
91
83
|
|
|
@@ -128,7 +128,7 @@ var CameraMovementPlugin = function CameraMovementPlugin(five) {
|
|
|
128
128
|
var panoIndex = args.panoIndex !== undefined ? args.panoIndex : five.panoIndex;
|
|
129
129
|
|
|
130
130
|
if (panoIndex !== undefined) {
|
|
131
|
-
|
|
131
|
+
var movePanoOptions = {
|
|
132
132
|
duration: duration,
|
|
133
133
|
// 移动耗时
|
|
134
134
|
moveEndCallback: function moveEndCallback() {
|
|
@@ -137,9 +137,11 @@ var CameraMovementPlugin = function CameraMovementPlugin(five) {
|
|
|
137
137
|
// 移动结束
|
|
138
138
|
moveCancelCallback: function moveCancelCallback() {
|
|
139
139
|
return reject(false);
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
|
|
140
|
+
},
|
|
141
|
+
// 移动开始
|
|
142
|
+
effect: 'fade'
|
|
143
|
+
};
|
|
144
|
+
five.moveToPano(panoIndex, Object.assign(movePanoOptions, args));
|
|
143
145
|
} else {
|
|
144
146
|
reject(false);
|
|
145
147
|
}
|
|
@@ -239,8 +241,9 @@ var CameraMovementPlugin = function CameraMovementPlugin(five) {
|
|
|
239
241
|
// 移动结束
|
|
240
242
|
moveCancelCallback: function moveCancelCallback() {
|
|
241
243
|
return reject(false);
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
+
},
|
|
245
|
+
// 移动开始
|
|
246
|
+
effect: 'fade'
|
|
244
247
|
});
|
|
245
248
|
});
|
|
246
249
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Mode, Pose } from '@realsee/five';
|
|
1
|
+
import { Mode, MovePanoOptions, Pose } from '@realsee/five';
|
|
2
2
|
export interface CameraMovementPluginParameterType {
|
|
3
3
|
}
|
|
4
4
|
export interface CameraMovementPluginExportType {
|
|
@@ -33,7 +33,7 @@ export interface CameraMovementOptsCallback {
|
|
|
33
33
|
export declare type MoveArgs = {
|
|
34
34
|
mode: Mode;
|
|
35
35
|
panoIndex: number;
|
|
36
|
-
} & Pose
|
|
36
|
+
} & Pose & Pick<MovePanoOptions, 'effect'>;
|
|
37
37
|
export declare type MoveOpts = {
|
|
38
38
|
preload?: boolean;
|
|
39
39
|
} & CameraMovementOptsCallback;
|
package/package.json
CHANGED
|
@@ -22,13 +22,13 @@ export interface SpatialScenePanelData {
|
|
|
22
22
|
|
|
23
23
|
interface SearchParams {
|
|
24
24
|
five: Five
|
|
25
|
-
position: Vector3
|
|
26
|
-
rotation?: Vector3
|
|
27
|
-
quaternion: [number, number, number, number]
|
|
25
|
+
// position: Vector3
|
|
26
|
+
// rotation?: Vector3
|
|
27
|
+
// quaternion: [number, number, number, number]
|
|
28
28
|
dom: HTMLDivElement
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
const searchV1 = ({ five,
|
|
31
|
+
const searchV1 = ({ five, dom }: SearchParams) => {
|
|
32
32
|
const cameraDirection = new Vector3()
|
|
33
33
|
five.camera.getWorldDirection(cameraDirection)
|
|
34
34
|
const cameraPosition = five.camera.position
|
|
@@ -48,7 +48,7 @@ const searchV1 = ({ five, position, rotation, dom }: SearchParams) => {
|
|
|
48
48
|
const rightBottom = new Vector3(right, bottom)
|
|
49
49
|
|
|
50
50
|
const points = [leftBottom, rightBottom, rightTop, leftTop].map((point) => {
|
|
51
|
-
point.setX((point.x / window.innerWidth) * 2 -
|
|
51
|
+
point.setX((point.x / window.innerWidth) * 2 - 2)
|
|
52
52
|
point.setY(-(point.y / window.innerHeight) * 2 + 1)
|
|
53
53
|
point.setZ(0.5)
|
|
54
54
|
return point.unproject(five.camera).addScaledVector(cameraDirection, 0.2)
|
|
@@ -57,7 +57,7 @@ const searchV1 = ({ five, position, rotation, dom }: SearchParams) => {
|
|
|
57
57
|
// const colors = [0xdc143c, 0xffff00, 0x0000ff, 0x008000]
|
|
58
58
|
// points.forEach((p, index) => five.scene.add(getSphere(p, colors[index])))
|
|
59
59
|
|
|
60
|
-
const ratio = leftBottom.distanceTo(rightBottom) /
|
|
60
|
+
const ratio = leftBottom.distanceTo(rightBottom) / 120
|
|
61
61
|
return { points, ratio }
|
|
62
62
|
}
|
|
63
63
|
|
|
@@ -82,17 +82,12 @@ export function SpatialScenePanel(props: CustomVreoKeyframeProps) {
|
|
|
82
82
|
}
|
|
83
83
|
|
|
84
84
|
const data = keyframe.data as SpatialScenePanelData
|
|
85
|
-
// const data = mockData as SpatialScenePanelData
|
|
86
85
|
|
|
87
86
|
const { points, ratio } = searchV1({
|
|
88
87
|
five: props.five,
|
|
89
|
-
position: new Vector3(data.position.x, data.position.y, data.position.z),
|
|
90
|
-
quaternion: data.quaternion,
|
|
91
88
|
dom: ref.current!
|
|
92
89
|
})
|
|
93
90
|
|
|
94
|
-
console.log(points, ratio)
|
|
95
|
-
|
|
96
91
|
const { container, dispose, css3DObject, render } =
|
|
97
92
|
rendererRef.current.create3DDomContainer(points, { ratio, autoRender: false }) || {}
|
|
98
93
|
|
|
@@ -124,7 +119,6 @@ export function SpatialScenePanel(props: CustomVreoKeyframeProps) {
|
|
|
124
119
|
}, end - start)
|
|
125
120
|
}
|
|
126
121
|
|
|
127
|
-
Object.assign(window, {$SpatialScenePanelCallback: callback})
|
|
128
122
|
props.subscribe.on(VreoKeyframeEnum.Custom, callback)
|
|
129
123
|
|
|
130
124
|
return () => {
|
|
@@ -30,13 +30,13 @@ export function PanoTextLabel() {
|
|
|
30
30
|
if (!res) return
|
|
31
31
|
const { x: left, y: top } = res
|
|
32
32
|
|
|
33
|
-
Object.assign(window, { $PanoTextLabel: { setState } })
|
|
33
|
+
// Object.assign(window, { $PanoTextLabel: { setState } })
|
|
34
34
|
setState({ left, top, text: data.text || '', fontSize: data.fontSize || 16 })
|
|
35
35
|
timeoutRef.current = setTimeout(() => setState(null), end - start)
|
|
36
36
|
}
|
|
37
37
|
controller.on(VreoKeyframeEnum.PanoTextLabel, callback)
|
|
38
38
|
|
|
39
|
-
Object.assign(window, { $panoTextLabel: { setState } })
|
|
39
|
+
// Object.assign(window, { $panoTextLabel: { setState } })
|
|
40
40
|
return () => {
|
|
41
41
|
controller.off(VreoKeyframeEnum.PanoTextLabel, callback)
|
|
42
42
|
if (timeoutRef.current) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Five } from '@realsee/five'
|
|
1
|
+
import { Five, MovePanoOptions } from '@realsee/five'
|
|
2
2
|
import type { FivePlugin } from '@realsee/five'
|
|
3
3
|
import * as TWEEN from '@tweenjs/tween.js'
|
|
4
4
|
|
|
@@ -97,14 +97,16 @@ export const CameraMovementPlugin: FivePlugin<CameraMovementPluginParameterType,
|
|
|
97
97
|
return await new Promise<boolean>((resolve, reject) => {
|
|
98
98
|
const panoIndex = args.panoIndex !== undefined ? args.panoIndex : five.panoIndex
|
|
99
99
|
if (panoIndex !== undefined) {
|
|
100
|
+
const movePanoOptions: MovePanoOptions = {
|
|
101
|
+
duration, // 移动耗时
|
|
102
|
+
moveEndCallback: () => resolve(true), // 移动结束
|
|
103
|
+
moveCancelCallback: () => reject(false), // 移动开始
|
|
104
|
+
effect: 'fade',
|
|
105
|
+
}
|
|
100
106
|
five.moveToPano(
|
|
101
107
|
panoIndex,
|
|
102
108
|
Object.assign(
|
|
103
|
-
|
|
104
|
-
duration, // 移动耗时
|
|
105
|
-
moveEndCallback: () => resolve(true), // 移动结束
|
|
106
|
-
moveCancelCallback: () => reject(false), // 移动开始
|
|
107
|
-
},
|
|
109
|
+
movePanoOptions,
|
|
108
110
|
args,
|
|
109
111
|
),
|
|
110
112
|
)
|
|
@@ -154,6 +156,7 @@ export const CameraMovementPlugin: FivePlugin<CameraMovementPluginParameterType,
|
|
|
154
156
|
five.moveToPano(args.panoIndex, {
|
|
155
157
|
moveEndCallback: () => resolve(true), // 移动结束
|
|
156
158
|
moveCancelCallback: () => reject(false), // 移动开始
|
|
159
|
+
effect: 'fade',
|
|
157
160
|
})
|
|
158
161
|
})
|
|
159
162
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* eslint-disable prettier/prettier */
|
|
2
|
-
import { Mode, Pose } from '@realsee/five'
|
|
2
|
+
import { Mode, MovePanoOptions, Pose } from '@realsee/five'
|
|
3
3
|
|
|
4
4
|
// eslint-disable-next-line @typescript-eslint/no-empty-interface
|
|
5
5
|
export interface CameraMovementPluginParameterType { }
|
|
@@ -39,7 +39,7 @@ export interface CameraMovementOptsCallback {
|
|
|
39
39
|
export type MoveArgs = {
|
|
40
40
|
mode: Mode
|
|
41
41
|
panoIndex: number
|
|
42
|
-
} & Pose
|
|
42
|
+
} & Pose & Pick<MovePanoOptions, 'effect'>
|
|
43
43
|
|
|
44
44
|
export type MoveOpts = {
|
|
45
45
|
preload?: boolean
|