@realsee/vreo 0.2.0-alpha.12 → 0.2.0-alpha.15
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.md +1 -1
- package/docs/assets/search.js +1 -1
- package/docs/classes/Player.AudioLike.html +52 -0
- package/docs/classes/Player.Controller.html +3 -3
- package/docs/classes/Player.Player-1.html +3 -3
- package/docs/classes/Player.VideoAgentMesh.html +12 -12
- package/docs/classes/Player.VideoAgentScene.html +1 -1
- package/docs/demo/assets/AppReact.0de930ef.js +1 -0
- package/docs/demo/assets/default.34811e91.js +64 -0
- package/docs/demo/assets/default.70243c83.css +1 -0
- package/docs/demo/assets/dynamic.e9ba8b28.js +1 -0
- package/docs/demo/assets/examples.5b87fcb8.js +25 -0
- package/docs/demo/assets/examples.dac4a6fe.css +1 -0
- package/docs/demo/assets/index.863d264e.js +1 -0
- package/docs/demo/assets/index.a7bafdff.css +1 -0
- package/docs/demo/assets/main.09d23dce.js +1 -0
- package/docs/demo/assets/react.aa3cf7f7.css +1 -0
- package/docs/demo/assets/react.b5f48ad5.js +25 -0
- package/docs/demo/assets/vendor.f4c5cb32.js +3902 -0
- package/docs/demo/assets/znRoyv06SZQeqA7m.0057e8ae.js +1 -0
- package/docs/demo/examples.html +18 -0
- package/docs/demo/index-react-dynamic.html +21 -0
- package/docs/demo/index-react.html +21 -0
- package/docs/demo/index.html +20 -0
- package/docs/enums/Player.InfoPanelStyleEnum.html +1 -1
- package/docs/enums/Player.InfoPanelTypeEnum.html +1 -1
- package/docs/enums/Player.PanoEffectEnum.html +1 -1
- package/docs/enums/Player.PanoTagEnum.html +1 -1
- package/docs/enums/Player.PanoTagStyleEnum.html +2 -2
- package/docs/enums/Player.VreoKeyframeEnum.html +12 -12
- package/docs/enums/fivePlugins.CameraMovementEffect.html +1 -1
- package/docs/enums/fivePlugins.Rotation.html +1 -1
- package/docs/index.html +1 -1
- package/docs/interfaces/Player.CustomVreoKeyframeProps.html +1 -1
- package/docs/interfaces/Player.PlayerConfigs.html +2 -2
- package/docs/interfaces/Player.Vertex.html +1 -1
- package/docs/interfaces/Player.VideoAgentMeshOptions.html +1 -1
- package/docs/interfaces/Player.VreoKeyframe.html +1 -1
- package/docs/interfaces/Player.VreoUnit.html +1 -1
- package/docs/interfaces/Player.VreoVideo.html +1 -1
- package/docs/interfaces/fivePlugins.CSS3DRenderPluginExportType.html +4 -0
- package/docs/interfaces/fivePlugins.CameraMovementOptsCallback.html +1 -1
- package/docs/interfaces/fivePlugins.CameraMovementPluginExportType.html +2 -2
- package/docs/interfaces/fivePlugins.ModelTVVideoPluginData.html +1 -1
- package/docs/interfaces/fivePlugins.ModelTVVideoPluginExportType.html +1 -1
- package/docs/interfaces/fivePlugins.ModelTVVideoPluginParameterType.html +1 -1
- package/docs/interfaces/fivePlugins.Vector3Position.html +3 -0
- package/docs/interfaces/react.VreoActionCallbacks.html +6 -6
- package/docs/interfaces/react.VreoProviderProps.html +1 -1
- package/docs/modules/Player.html +18 -14
- package/docs/modules/custom.html +1 -1
- package/docs/modules/fivePlugins.html +5 -2
- package/docs/modules/react.html +1 -1
- package/lib/Player/Controller.d.ts +1 -1
- package/lib/Player/custom/SpatialScenePanel/index.js +2 -2
- package/lib/Player/index.js +9 -15
- package/lib/Player/modules/VideoAgent/VideoAgentMesh.d.ts +4 -2
- package/lib/Player/modules/VideoAgent/VideoAgentMesh.js +67 -21
- package/lib/Player/modules/VideoAgent/VideoAgentScene.js +2 -1
- package/lib/Player/modules/keyframes/PanoTextLabel/index.d.ts +3 -0
- package/lib/Player/modules/keyframes/PanoTextLabel/index.js +96 -43
- package/lib/fivePlugins/CSS3DRenderPlugin/centerPoint.d.ts +2 -0
- package/lib/fivePlugins/CSS3DRenderPlugin/centerPoint.js +12 -0
- package/lib/fivePlugins/CSS3DRenderPlugin/createResizeObserver.d.ts +7 -0
- package/lib/fivePlugins/CSS3DRenderPlugin/createResizeObserver.js +32 -0
- package/lib/fivePlugins/CSS3DRenderPlugin/evenNumber.d.ts +3 -0
- package/lib/fivePlugins/CSS3DRenderPlugin/evenNumber.js +11 -0
- package/lib/fivePlugins/CSS3DRenderPlugin/index.d.ts +56 -0
- package/lib/fivePlugins/CSS3DRenderPlugin/index.js +275 -0
- package/lib/fivePlugins/CSS3DRenderPlugin/transformPositionToVector3.d.ts +7 -0
- package/lib/fivePlugins/CSS3DRenderPlugin/transformPositionToVector3.js +18 -0
- package/lib/shared-utils/AduioLike.d.ts +37 -0
- package/lib/shared-utils/AduioLike.js +165 -0
- package/lib/typings/VreoUnit.d.ts +11 -0
- package/package.json +2 -2
- package/resources/Player/Controller.ts +2 -0
- package/resources/Player/custom/SpatialScenePanel/index.tsx +4 -4
- package/resources/Player/index.tsx +38 -28
- package/resources/Player/modules/VideoAgent/VideoAgentMesh.ts +37 -7
- package/resources/Player/modules/VideoAgent/VideoAgentScene.ts +2 -0
- package/resources/Player/modules/keyframes/PanoTextLabel/index.tsx +87 -34
- package/resources/fivePlugins/CSS3DRenderPlugin/centerPoint.ts +5 -0
- package/resources/fivePlugins/CSS3DRenderPlugin/createResizeObserver.ts +17 -0
- package/resources/fivePlugins/CSS3DRenderPlugin/evenNumber.ts +4 -0
- package/resources/fivePlugins/CSS3DRenderPlugin/index.ts +254 -0
- package/resources/fivePlugins/CSS3DRenderPlugin/transformPositionToVector3.ts +5 -0
- package/resources/shared-utils/AduioLike.ts +108 -0
- package/resources/typings/VreoUnit.ts +13 -1
- package/stylesheets/default.css +5 -1
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
import { FivePlugin } from '@realsee/five'
|
|
2
|
+
import * as THREE from 'three'
|
|
3
|
+
import { Scene, Vector3 } from 'three'
|
|
4
|
+
import { CSS3DObject, CSS3DRenderer } from 'three/examples/jsm/renderers/CSS3DRenderer'
|
|
5
|
+
import evenNumber from './evenNumber'
|
|
6
|
+
import centerPoint from './centerPoint'
|
|
7
|
+
import transformPositionToVector3 from './transformPositionToVector3'
|
|
8
|
+
import createResizeObserver from './createResizeObserver'
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* 三维向量
|
|
12
|
+
*/
|
|
13
|
+
export interface Vector3Position {
|
|
14
|
+
x: number
|
|
15
|
+
y: number
|
|
16
|
+
z: number
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export type CSS3DRenderPluginParameterType = undefined
|
|
20
|
+
export interface CSS3DRenderPluginExportType {
|
|
21
|
+
/**
|
|
22
|
+
* @description: 根据传入的四个点位创建一个3d dom容器,可以通过ReactDom.render()的方式将react组件放到容器中
|
|
23
|
+
* @param {Five} five
|
|
24
|
+
* @param {Vector3[] | Vector3Position[]} points: 矩形四个点坐标
|
|
25
|
+
* @param {number} config.ratio: 1px对应多少米,默认为 0.002,即1px对应2mm
|
|
26
|
+
* @param {number} config.dpr: dpr, 默认为1
|
|
27
|
+
* @param {HTMLElement} config.container: HTMLElement
|
|
28
|
+
* @param {number} config.autoRender: 默认为true,如果需要手动render则传false
|
|
29
|
+
* @param {'front' | 'behind'} config.mode: 两种模式
|
|
30
|
+
* @param {HTMLElement} config.behindFiveContainer: 如果config.mode为'behind',需要传入容器,并确保此容器位five下方,且中间没有其他dom元素遮挡
|
|
31
|
+
* @return {{ container: HTMLElement; dispose: () => void }}: container: dom容器, dispose: 清理函数
|
|
32
|
+
*/
|
|
33
|
+
create3DDomContainer: (
|
|
34
|
+
points: Vector3[] | Vector3Position[],
|
|
35
|
+
config?: { ratio?: number; dpr?: number; autoRender?: boolean; container?: HTMLElement; [key: string]: any } & (
|
|
36
|
+
| { mode?: 'front' }
|
|
37
|
+
| { mode: 'behind'; behindFiveContainer: HTMLElement }
|
|
38
|
+
),
|
|
39
|
+
) => { container: HTMLElement; dispose: () => void; css3DObject: CSS3DObject; render?: () => void } | void
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* @description: 销毁所有的渲染内容
|
|
43
|
+
* @return {void}
|
|
44
|
+
*/
|
|
45
|
+
disposeAll: () => void
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
type Create3DDomContainerInterface = CSS3DRenderPluginExportType['create3DDomContainer']
|
|
49
|
+
type Create3DDomContainerConfigInterface = NonNullable<Parameters<Create3DDomContainerInterface>[1]>
|
|
50
|
+
interface CSS3DRenderPluginState {
|
|
51
|
+
disposeCallbacks: (() => boolean)[]
|
|
52
|
+
frontMode?: {
|
|
53
|
+
scene: Scene
|
|
54
|
+
css3DRenderer: CSS3DRenderer
|
|
55
|
+
}
|
|
56
|
+
behindMode?: {
|
|
57
|
+
scene: Scene
|
|
58
|
+
css3DRenderer: CSS3DRenderer
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* **CSS3DRenderPlugin** 提供矩形区域(三维空间四个坐标点),你可以在此矩形区域中渲染 DOM 内容。
|
|
64
|
+
* 实现原理参考[CSS3DRenderer](https://threejs.org/docs/index.html?q=CSS3D#examples/en/renderers/CSS3DRenderer)。
|
|
65
|
+
*
|
|
66
|
+
* @returns
|
|
67
|
+
*/
|
|
68
|
+
export const CSS3DRenderPlugin: FivePlugin<CSS3DRenderPluginParameterType, CSS3DRenderPluginExportType> = (five) => {
|
|
69
|
+
const state: CSS3DRenderPluginState = { disposeCallbacks: [] }
|
|
70
|
+
const create3DDomContainer = (
|
|
71
|
+
...params: Parameters<Create3DDomContainerInterface>
|
|
72
|
+
): ReturnType<Create3DDomContainerInterface> => {
|
|
73
|
+
const points = params[0].map((point) => (point instanceof Vector3 ? point : transformPositionToVector3(point)))
|
|
74
|
+
const config = params[1]
|
|
75
|
+
if (points?.length < 4) return console.error('points must be equal or greater than than 4')
|
|
76
|
+
if (!five?.model?.loaded) return console.error('five.model.loaded is: ', five?.model?.loaded)
|
|
77
|
+
const fiveElement = five.getElement()
|
|
78
|
+
if (!fiveElement) return console.error('five.getElement() is ' + fiveElement)
|
|
79
|
+
|
|
80
|
+
const disposers: any[] = []
|
|
81
|
+
const ratio = config?.ratio || 0.00216
|
|
82
|
+
if (ratio <= 0.00215) console.warn('if you need click css3DElement on safari, ratio must be greater than 0.00215')
|
|
83
|
+
const dpr = config?.dpr || 1
|
|
84
|
+
const mode = config?.mode || 'front'
|
|
85
|
+
const autoRender = config?.autoRender ?? true
|
|
86
|
+
const behindFiveContainer = config?.behindFiveContainer || fiveElement.parentElement || document.body
|
|
87
|
+
const container = config?.container || document.createElement('div')
|
|
88
|
+
container.classList.add('__Dnalogel-plugin--CSS3DRenderPlugin')
|
|
89
|
+
|
|
90
|
+
// 获取css3DObject, 如果mode为behind的话,一起获取mesh
|
|
91
|
+
const { css3DObject, mesh } = createObject(points, { ratio, dpr, container, mode })
|
|
92
|
+
|
|
93
|
+
// ======= INIT START =======
|
|
94
|
+
let resizeObserver:
|
|
95
|
+
| {
|
|
96
|
+
observe?: () => void
|
|
97
|
+
unobserve?: () => void
|
|
98
|
+
}
|
|
99
|
+
| undefined
|
|
100
|
+
const frontModeUnInited = mode === 'front' && !state.frontMode
|
|
101
|
+
const behindModeUnInited = mode === 'behind' && !state.behindMode
|
|
102
|
+
const inited = !(frontModeUnInited || behindModeUnInited)
|
|
103
|
+
let stopRenderFlag = false
|
|
104
|
+
let requestAnimationFrameId: number | null = null
|
|
105
|
+
|
|
106
|
+
if (behindModeUnInited) {
|
|
107
|
+
state.behindMode = { scene: new Scene(), css3DRenderer: new CSS3DRenderer() }
|
|
108
|
+
}
|
|
109
|
+
if (frontModeUnInited) {
|
|
110
|
+
state.frontMode = { scene: new Scene(), css3DRenderer: new CSS3DRenderer() }
|
|
111
|
+
}
|
|
112
|
+
const { scene, css3DRenderer } = mode === 'behind' ? state.behindMode! : state.frontMode!
|
|
113
|
+
|
|
114
|
+
const render = (() => {
|
|
115
|
+
if (!inited) {
|
|
116
|
+
const css3DRendererSetSize = () => {
|
|
117
|
+
// 这里evenNumber策略是遇到奇数会加1,不知道为啥会触发滚动条显示,导致fiveElement变小,fiveElement变小又触发了这里的resize,宽高变小,滚动条消失,然后又触发resize。。。无限循环
|
|
118
|
+
// 为了规避上面这种情况,evenNumber设置了一个参数,遇到奇数可选择减一
|
|
119
|
+
const rendererWidth = evenNumber(fiveElement.clientWidth, { smaller: true })
|
|
120
|
+
const rendererHeight = evenNumber(fiveElement.clientHeight, { smaller: true })
|
|
121
|
+
css3DRenderer.setSize(rendererWidth, rendererHeight)
|
|
122
|
+
}
|
|
123
|
+
css3DRendererSetSize()
|
|
124
|
+
resizeObserver = createResizeObserver(css3DRendererSetSize, fiveElement)
|
|
125
|
+
css3DRenderer.domElement.style.position = 'absolute'
|
|
126
|
+
css3DRenderer.domElement.style.top = '0'
|
|
127
|
+
css3DRenderer.domElement.style.userSelect = 'none'
|
|
128
|
+
css3DRenderer.domElement.style.pointerEvents = 'none'
|
|
129
|
+
|
|
130
|
+
const renderEveryFrame = () => {
|
|
131
|
+
if (stopRenderFlag) return
|
|
132
|
+
requestAnimationFrameId = requestAnimationFrame(renderEveryFrame)
|
|
133
|
+
css3DRenderer.render(scene!, five.camera)
|
|
134
|
+
}
|
|
135
|
+
return () => {
|
|
136
|
+
scene.add(css3DObject)
|
|
137
|
+
resizeObserver?.observe?.()
|
|
138
|
+
renderEveryFrame()
|
|
139
|
+
if (mode === 'behind' && mesh) {
|
|
140
|
+
five.scene.add(mesh)
|
|
141
|
+
disposers.push(() => mesh && five.scene.remove(mesh))
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
} else {
|
|
145
|
+
return () => {
|
|
146
|
+
scene.add(css3DObject)
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
})()
|
|
150
|
+
if (frontModeUnInited) {
|
|
151
|
+
const wrapper = fiveElement.parentElement || document.body
|
|
152
|
+
wrapper.appendChild(css3DRenderer.domElement)
|
|
153
|
+
}
|
|
154
|
+
if (behindModeUnInited) {
|
|
155
|
+
const wrapper = behindFiveContainer
|
|
156
|
+
wrapper.appendChild(css3DRenderer.domElement)
|
|
157
|
+
}
|
|
158
|
+
// ======= INIT END =======
|
|
159
|
+
|
|
160
|
+
const dispose = () => {
|
|
161
|
+
stopRenderFlag = true
|
|
162
|
+
disposers.forEach((d) => d?.())
|
|
163
|
+
scene.remove(css3DObject)
|
|
164
|
+
if (typeof requestAnimationFrameId === 'number') cancelAnimationFrame(requestAnimationFrameId)
|
|
165
|
+
if (scene.children.length === 0) {
|
|
166
|
+
css3DRenderer.domElement.remove()
|
|
167
|
+
if (mode === 'front') state.frontMode = undefined
|
|
168
|
+
if (mode === 'behind') state.behindMode = undefined
|
|
169
|
+
if (!state.behindMode && !state.frontMode) {
|
|
170
|
+
resizeObserver?.unobserve?.()
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
return true
|
|
174
|
+
}
|
|
175
|
+
const idx = state.disposeCallbacks.findIndex((item) => item === dispose)
|
|
176
|
+
if (idx !== -1) {
|
|
177
|
+
state.disposeCallbacks.splice(idx, 1)
|
|
178
|
+
} else {
|
|
179
|
+
state.disposeCallbacks.push(dispose)
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
if (autoRender) render()
|
|
183
|
+
return { container, dispose, css3DObject, render: autoRender ? undefined : render }
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
const createObject = (
|
|
187
|
+
points: Vector3[],
|
|
188
|
+
config: Required<Pick<Create3DDomContainerConfigInterface, 'ratio' | 'dpr' | 'container'>> &
|
|
189
|
+
Pick<Create3DDomContainerConfigInterface, 'mode'>,
|
|
190
|
+
) => {
|
|
191
|
+
const { ratio, dpr, container: element, mode } = config
|
|
192
|
+
const planeWidth = points[0].distanceTo(points[1])
|
|
193
|
+
const planeHeight = points[1].distanceTo(points[2])
|
|
194
|
+
const domWidthPx = evenNumber((planeWidth / ratio) * dpr)
|
|
195
|
+
const domHeightPx = evenNumber((planeHeight / ratio) * dpr)
|
|
196
|
+
|
|
197
|
+
const css3DObject = new CSS3DObject(element)
|
|
198
|
+
css3DObject.scale.set(ratio, ratio, ratio)
|
|
199
|
+
element.style.width = domWidthPx + 'px'
|
|
200
|
+
element.style.height = domHeightPx + 'px'
|
|
201
|
+
element.style.pointerEvents = 'none'
|
|
202
|
+
|
|
203
|
+
const centerPosition = centerPoint(points[0], points[2])
|
|
204
|
+
|
|
205
|
+
const vector01 = points[1].clone().sub(points[0]) // 点0 -> 点1 的向量
|
|
206
|
+
const vector12 = points[2].clone().sub(points[1]) // 点1 -> 点2 的向量
|
|
207
|
+
|
|
208
|
+
// 旋转
|
|
209
|
+
const rotateXAngle = new Vector3(0, 1, 0).angleTo(new Vector3(0, vector12.y, vector12.z))
|
|
210
|
+
const rotateYAngle = new Vector3(1, 0, 0).angleTo(new Vector3(vector01.x, 0, vector01.z))
|
|
211
|
+
const rotateZAngle = vector01.angleTo(new Vector3(vector01.x, 0, vector01.z))
|
|
212
|
+
/**
|
|
213
|
+
* [0,1,0] => [0,0,1] 为rolate Worldx正方向
|
|
214
|
+
* [0,0,1] => [0,1,0] 为rolate Worldy正方向
|
|
215
|
+
* [0,1,1] => [-1,0,0] 为rolate Worldz正方向
|
|
216
|
+
*/
|
|
217
|
+
const rotateX = (vector12.z > 0 ? -1 : 1) * rotateXAngle
|
|
218
|
+
const rotateY = (vector01.z < 0 ? 1 : -1) * rotateYAngle
|
|
219
|
+
const rotateZ = ((vector01.x > 0 && vector01.y < 0) || (vector01.x < 0 && vector01.y > 0) ? -1 : 1) * rotateZAngle
|
|
220
|
+
|
|
221
|
+
css3DObject.rotateOnWorldAxis(new Vector3(1, 0, 0), rotateX) // x
|
|
222
|
+
css3DObject.rotateOnWorldAxis(new Vector3(0, 1, 0), rotateY) // y
|
|
223
|
+
css3DObject.rotateOnWorldAxis(new Vector3(0, 0, 1), rotateZ) // z
|
|
224
|
+
|
|
225
|
+
css3DObject.position.set(centerPosition.x, centerPosition.y, centerPosition.z)
|
|
226
|
+
|
|
227
|
+
let mesh: THREE.Mesh<THREE.PlaneGeometry, THREE.MeshBasicMaterial> | undefined
|
|
228
|
+
if (mode === 'behind') {
|
|
229
|
+
const material = new THREE.MeshBasicMaterial({
|
|
230
|
+
opacity: 0,
|
|
231
|
+
transparent: false,
|
|
232
|
+
side: THREE.DoubleSide,
|
|
233
|
+
})
|
|
234
|
+
const geometry = new THREE.PlaneGeometry(domWidthPx, domHeightPx)
|
|
235
|
+
mesh = new THREE.Mesh(geometry, material)
|
|
236
|
+
mesh.name = 'CSS3DRenderPlugin-mesh'
|
|
237
|
+
mesh.position.copy(css3DObject.position)
|
|
238
|
+
mesh.rotation.copy(css3DObject.rotation)
|
|
239
|
+
mesh.scale.copy(css3DObject.scale)
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
return { css3DObject, mesh }
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
return {
|
|
246
|
+
create3DDomContainer,
|
|
247
|
+
disposeAll: () => {
|
|
248
|
+
state.disposeCallbacks.forEach((d) => d?.())
|
|
249
|
+
state.disposeCallbacks = []
|
|
250
|
+
},
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
export default CSS3DRenderPlugin
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { Subscribe } from '@realsee/five'
|
|
2
|
+
import { requestAnimationFrameInterval } from './animationFrame'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* 模拟 `<Audio>` 事件。
|
|
6
|
+
*/
|
|
7
|
+
export type AudioLikeEvent = {
|
|
8
|
+
// 播放
|
|
9
|
+
play: () => void
|
|
10
|
+
// 语音状态 播放 -> 暂停
|
|
11
|
+
pause: () => void
|
|
12
|
+
// 语音时间刷新
|
|
13
|
+
timeupdate: () => void
|
|
14
|
+
// 播放
|
|
15
|
+
ended: () => void
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* 模拟 `<Audio>` 功能:没有音频,但执行逻辑跟 `<Audio>` 相似。
|
|
21
|
+
*/
|
|
22
|
+
export class AudioLike extends Subscribe<AudioLikeEvent> {
|
|
23
|
+
private $timestamp = 0
|
|
24
|
+
private $currentTime = 0
|
|
25
|
+
private $duration = 0
|
|
26
|
+
private stopInterval?: () => void
|
|
27
|
+
muted = false
|
|
28
|
+
src = ''
|
|
29
|
+
|
|
30
|
+
setAttribute(name: string, value: string) {
|
|
31
|
+
// nothing todo
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
constructor({ duration }: { duration?: number } = {}) {
|
|
35
|
+
super()
|
|
36
|
+
if (duration) {
|
|
37
|
+
this.$duration = duration
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
play() {
|
|
42
|
+
if (this.$timestamp === 0) {
|
|
43
|
+
this.$timestamp = performance.now()
|
|
44
|
+
}
|
|
45
|
+
if (this.$currentTime === this.$duration) {
|
|
46
|
+
this.$currentTime = 0
|
|
47
|
+
}
|
|
48
|
+
this.stopInterval = requestAnimationFrameInterval(() => this.requestAnimationFrameLoop())
|
|
49
|
+
this.emit('play')
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
pause() {
|
|
53
|
+
if (this.stopInterval) {
|
|
54
|
+
this.stopInterval()
|
|
55
|
+
this.emit('pause')
|
|
56
|
+
this.stopInterval = undefined
|
|
57
|
+
}
|
|
58
|
+
this.$timestamp = 0
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
requestAnimationFrameLoop() {
|
|
62
|
+
const now = performance.now()
|
|
63
|
+
this.$currentTime = now - this.$timestamp
|
|
64
|
+
this.emit('timeupdate')
|
|
65
|
+
if (this.$currentTime >= this.$duration - 10) {
|
|
66
|
+
this.$currentTime = this.$duration
|
|
67
|
+
this.pause()
|
|
68
|
+
this.emit('ended')
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
get currentTime() {
|
|
73
|
+
return this.$currentTime / 1000
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
set currentTime(time: number) {
|
|
77
|
+
this.$currentTime = time
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
get duration() {
|
|
81
|
+
return this.$duration
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
set duration(duration: number) {
|
|
85
|
+
this.pause()
|
|
86
|
+
this.$duration = duration
|
|
87
|
+
this.$timestamp = 0
|
|
88
|
+
this.$currentTime = 0
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
get ended() {
|
|
92
|
+
return this.$currentTime === this.$duration
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
get paused() {
|
|
96
|
+
return !this.stopInterval
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
addEventListener(evtName: keyof AudioLikeEvent, callback: () => void, useCapture = false) {
|
|
100
|
+
this.on(evtName, callback)
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
removeEventListener(evtName: keyof AudioLikeEvent, callback: () => void, useCapture = false) {
|
|
104
|
+
this.off(evtName, callback)
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export default AudioLike
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Mode,
|
|
1
|
+
import { Mode, Pose } from '@realsee/five'
|
|
2
2
|
import { CameraMovementEffect, Rotation } from '../fivePlugins/CameraMovementPlugin/typings'
|
|
3
3
|
|
|
4
4
|
export enum VreoKeyframeEnum {
|
|
@@ -191,12 +191,24 @@ export type ModelVideoData = {
|
|
|
191
191
|
matrixWorld?: number[]
|
|
192
192
|
}
|
|
193
193
|
|
|
194
|
+
/**
|
|
195
|
+
* 四元数
|
|
196
|
+
*/
|
|
197
|
+
export type Quaternion = {
|
|
198
|
+
x: number,
|
|
199
|
+
y: number,
|
|
200
|
+
z: number,
|
|
201
|
+
w: number
|
|
202
|
+
}
|
|
203
|
+
|
|
194
204
|
/**
|
|
195
205
|
* 全景文本标签
|
|
196
206
|
*/
|
|
197
207
|
export type PanoTextLabelData = {
|
|
198
208
|
text: string
|
|
199
209
|
vertex: Vertex
|
|
210
|
+
normal?: Vertex
|
|
211
|
+
quaternion?: Quaternion
|
|
200
212
|
fontSize?: number
|
|
201
213
|
}
|
|
202
214
|
|
package/stylesheets/default.css
CHANGED
|
@@ -430,7 +430,11 @@
|
|
|
430
430
|
transform-style: preserve-3d;
|
|
431
431
|
pointer-events: none;
|
|
432
432
|
z-index: 999999;
|
|
433
|
-
|
|
433
|
+
}
|
|
434
|
+
.__Dnalogel-plugin--CSS3DRenderPlugin {
|
|
435
|
+
display: flex;
|
|
436
|
+
align-items: center;
|
|
437
|
+
justify-content: center;
|
|
434
438
|
}
|
|
435
439
|
|
|
436
440
|
@keyframes straightPopPTL {
|