@realsee/dnalogel 2.0.0-alpha.2 → 2.0.0-alpha.3

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.
@@ -0,0 +1,25 @@
1
+ import type { Five, FivePlugin } from '@realsee/five';
2
+ export interface PanoCompassPluginParameterType {
3
+ compassImageUrl?: string;
4
+ }
5
+ export interface PanoCompassPluginData {
6
+ north_rad: number;
7
+ }
8
+ export declare type PanoCompassPluginExportType = PanoCompassController;
9
+ export declare const PanoCompassPlugin: FivePlugin<PanoCompassPluginParameterType | undefined, PanoCompassController>;
10
+ export default PanoCompassPlugin;
11
+ declare class PanoCompassController {
12
+ five: Five;
13
+ data?: PanoCompassPluginData;
14
+ config?: PanoCompassPluginParameterType;
15
+ private compassMeshTween?;
16
+ private compassMesh?;
17
+ constructor(five: Five, config?: PanoCompassPluginParameterType);
18
+ load(data: PanoCompassPluginData): void;
19
+ dispose: () => void;
20
+ private loadCompassMesh;
21
+ private onFivePanoWillArrive;
22
+ private onFivePanoArrived;
23
+ private fixPosition;
24
+ private fixRotation;
25
+ }
@@ -0,0 +1,89 @@
1
+ import * as THREE from 'three';
2
+ import { loadTexture } from '../shared-utils/three/loadTexture';
3
+ import { tweenProgress } from '../shared-utils/animationFrame/BetterTween';
4
+ export const PanoCompassPlugin = function (five, config) {
5
+ return new PanoCompassController(five, config);
6
+ };
7
+ export default PanoCompassPlugin;
8
+ class PanoCompassController {
9
+ five;
10
+ data;
11
+ config;
12
+ compassMeshTween;
13
+ compassMesh;
14
+ constructor(five, config) {
15
+ this.five = five;
16
+ this.config = config;
17
+ five.once('panoLoaded', this.loadCompassMesh);
18
+ five.once('dispose', this.dispose);
19
+ this.five.on('panoArrived', this.onFivePanoArrived);
20
+ this.five.on('panoWillArrive', this.onFivePanoWillArrive);
21
+ }
22
+ load(data) {
23
+ this.data = data;
24
+ if (this.compassMesh && !this.five.scene.children.includes(this.compassMesh)) {
25
+ // 模型已经加载好了,才加载数据
26
+ this.fixRotation(data.north_rad);
27
+ this.fixPosition(this.five.panoIndex || 0);
28
+ this.five.scene.add(this.compassMesh);
29
+ }
30
+ }
31
+ dispose = () => {
32
+ this.five.off('panoArrived', this.onFivePanoArrived);
33
+ this.five.off('panoWillArrive', this.onFivePanoWillArrive);
34
+ this.five.off();
35
+ };
36
+ loadCompassMesh = async () => {
37
+ const compassImageUrl = this.config?.compassImageUrl || '//vrlab-image4.ljcdn.com/release/web/v3/north-point-circle.96498e69.png';
38
+ const texture = await loadTexture(compassImageUrl);
39
+ const compassGeometry = new THREE.CircleGeometry(0.7, 32);
40
+ const compassMaterial = new THREE.MeshBasicMaterial({
41
+ map: texture,
42
+ transparent: true,
43
+ opacity: 1,
44
+ depthTest: false,
45
+ });
46
+ const compassMesh = new THREE.Mesh(compassGeometry, compassMaterial);
47
+ compassMesh.rotateX(-Math.PI / 2);
48
+ compassMesh.name = 'pano-compass-mesh';
49
+ this.compassMesh = compassMesh;
50
+ this.fixPosition(this.five.panoIndex || 0);
51
+ if (!this.data)
52
+ return;
53
+ this.fixRotation(this.data.north_rad);
54
+ this.five.scene.add(compassMesh);
55
+ };
56
+ onFivePanoWillArrive = (panoIndex) => {
57
+ if (panoIndex === this.five.panoIndex)
58
+ return;
59
+ this.compassMeshTween?.dispose();
60
+ this.compassMesh?.material.setValues({ opacity: 0 });
61
+ };
62
+ onFivePanoArrived = (panoIndex) => {
63
+ if (this.compassMesh?.material.opacity !== 0)
64
+ return;
65
+ this.fixPosition(panoIndex);
66
+ this.compassMeshTween?.dispose();
67
+ this.compassMeshTween = tweenProgress(1000)
68
+ .onUpdate(({ progress }) => {
69
+ this.compassMesh?.material.setValues({ opacity: progress });
70
+ this.five.needsRender = true;
71
+ })
72
+ .play();
73
+ };
74
+ fixPosition(panoIndex) {
75
+ if (!this.compassMesh)
76
+ return;
77
+ const standingPosition = this.five.work.observers[panoIndex].standingPosition;
78
+ // 指南针上移 0.01m,防止与地板重合
79
+ const compassPosition = standingPosition.clone().add(new THREE.Vector3(0, 0.01, 0));
80
+ this.compassMesh.position.copy(compassPosition);
81
+ this.five.needsRender = true;
82
+ }
83
+ fixRotation(northRad) {
84
+ if (!this.compassMesh)
85
+ return;
86
+ this.compassMesh.rotateZ(northRad - Math.PI / 2);
87
+ this.five.needsRender = true;
88
+ }
89
+ }
package/libs/index.d.ts CHANGED
@@ -1,17 +1,19 @@
1
- export { default as ModelViewPlugin } from "./ModelViewPlugin";
2
- export { default as CSS3DRenderPlugin } from "./CSS3DRenderPlugin";
1
+ export { default as ModelViewPlugin } from './ModelViewPlugin';
2
+ export { default as CSS3DRenderPlugin } from './CSS3DRenderPlugin';
3
3
  export type { PanoCursorRaycasterPluginExportType } from './PanoCursorRaycasterPlugin';
4
- export { default as PanoCursorRaycasterPlugin } from "./PanoCursorRaycasterPlugin";
5
- export type { ModelRoomLabelController, ModelRoomLabelPluginData, RoomLabel, ModelRoomLabelPluginReturnType, ModelRoomLabelPluginParameters } from './ModelRoomLabelPlugin';
4
+ export { default as PanoCursorRaycasterPlugin } from './PanoCursorRaycasterPlugin';
5
+ export type { ModelRoomLabelController, ModelRoomLabelPluginData, RoomLabel, ModelRoomLabelPluginReturnType, ModelRoomLabelPluginParameters, } from './ModelRoomLabelPlugin';
6
6
  export { default as ModelRoomLabelPlugin } from './ModelRoomLabelPlugin';
7
- export type { TopviewFloorplanPluginReturnType, TopviewFloorplanPluginParameterType } from './floorplan/TopviewFloorplanPlugin';
7
+ export type { TopviewFloorplanPluginReturnType, TopviewFloorplanPluginParameterType, } from './floorplan/TopviewFloorplanPlugin';
8
8
  export { default as TopviewFloorplanPlugin } from './floorplan/TopviewFloorplanPlugin';
9
- export type { PanoFloorplanRadarPluginReturnType, PanoFloorplanRadarPluginParameterType } from './floorplan/PanoFloorplanRadarPlugin';
9
+ export type { PanoFloorplanRadarPluginReturnType, PanoFloorplanRadarPluginParameterType, } from './floorplan/PanoFloorplanRadarPlugin';
10
10
  export { default as PanoFloorplanRadarPlugin } from './floorplan/PanoFloorplanRadarPlugin';
11
- export type { ModelFloorplanParameterType, ModelFloorplanPluginReturnType, ModelFloorplanErrorType, ModelFloorplanPluginsConfigs, ModelFloorplanEventHandlers, ModelFloorplanViewEvent } from './floorplan/ModelFloorplanPlugin';
11
+ export type { ModelFloorplanParameterType, ModelFloorplanPluginReturnType, ModelFloorplanErrorType, ModelFloorplanPluginsConfigs, ModelFloorplanEventHandlers, ModelFloorplanViewEvent, } from './floorplan/ModelFloorplanPlugin';
12
12
  export { default as ModelFloorplanPlugin } from './floorplan/ModelFloorplanPlugin';
13
- export type { ModelChassisCompassPluginParameterType, ModelChassisCompassPluginData, ModelChassisCompassPluginExportType } from './ModelChassisCompassPlugin';
13
+ export type { ModelChassisCompassPluginParameterType, ModelChassisCompassPluginData, ModelChassisCompassPluginExportType, } from './ModelChassisCompassPlugin';
14
14
  export { default as ModelChassisCompassPlugin } from './ModelChassisCompassPlugin';
15
- export type { ModelEntryDoorGuidePluginParameterType, ModelEntryDoorGuidePluginData, ModelEntryDoorGuidePluginExportType } from './ModelEntryDoorGuidePlugin';
15
+ export type { ModelEntryDoorGuidePluginParameterType, ModelEntryDoorGuidePluginData, ModelEntryDoorGuidePluginExportType, } from './ModelEntryDoorGuidePlugin';
16
16
  export { default as ModelEntryDoorGuidePlugin } from './ModelEntryDoorGuidePlugin';
17
17
  export { default as CameraMovementPlugin } from './CameraMovementPlugin';
18
+ export type { PanoCompassPluginParameterType, PanoCompassPluginExportType, PanoCompassPluginData, } from './PanoCompassPlugin';
19
+ export { default as PanoCompassPluginPlugin } from './PanoCompassPlugin';
package/libs/index.js CHANGED
@@ -1,6 +1,6 @@
1
- export { default as ModelViewPlugin } from "./ModelViewPlugin";
2
- export { default as CSS3DRenderPlugin } from "./CSS3DRenderPlugin";
3
- export { default as PanoCursorRaycasterPlugin } from "./PanoCursorRaycasterPlugin";
1
+ export { default as ModelViewPlugin } from './ModelViewPlugin';
2
+ export { default as CSS3DRenderPlugin } from './CSS3DRenderPlugin';
3
+ export { default as PanoCursorRaycasterPlugin } from './PanoCursorRaycasterPlugin';
4
4
  export { default as ModelRoomLabelPlugin } from './ModelRoomLabelPlugin';
5
5
  export { default as TopviewFloorplanPlugin } from './floorplan/TopviewFloorplanPlugin';
6
6
  export { default as PanoFloorplanRadarPlugin } from './floorplan/PanoFloorplanRadarPlugin';
@@ -8,3 +8,4 @@ export { default as ModelFloorplanPlugin } from './floorplan/ModelFloorplanPlugi
8
8
  export { default as ModelChassisCompassPlugin } from './ModelChassisCompassPlugin';
9
9
  export { default as ModelEntryDoorGuidePlugin } from './ModelEntryDoorGuidePlugin';
10
10
  export { default as CameraMovementPlugin } from './CameraMovementPlugin';
11
+ export { default as PanoCompassPluginPlugin } from './PanoCompassPlugin';
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "author": "REALSEE-DEVELOPER",
6
6
  "repository": "https://github.com/realsee-developer/dnalogel.git",
7
7
  "private": false,
8
- "version": "2.0.0-alpha.2",
8
+ "version": "2.0.0-alpha.3",
9
9
  "license": "SEE LICENSE IN TERMS.txt",
10
10
  "scripts": {
11
11
  "build:dev": "yarn tsb && vite build --watch",