@realsee/dnalogel 2.0.0-alpha.33 → 2.0.0-alpha.35-beta2

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.
Files changed (139) hide show
  1. package/components/index.js +1450 -0
  2. package/dist/PanoSpatialTagPlugin/index.js +21 -7
  3. package/dist/components/PaintBrush/Controller.d.ts +43 -0
  4. package/dist/components/PaintBrush/Subscribe.d.ts +76 -0
  5. package/dist/components/PaintBrush/index.d.ts +27 -0
  6. package/dist/components/PaintBrush/style.d.ts +2 -0
  7. package/dist/components/PaintBrush/tween.d.ts +62 -0
  8. package/dist/components/PaintBrush/typings.d.ts +58 -0
  9. package/dist/components/PaintBrush/utils.d.ts +26 -0
  10. package/dist/components/index.d.ts +2 -0
  11. package/dist/index.es.js +21 -7
  12. package/dist/index.js +21 -7
  13. package/dist/index.umd.js +21 -7
  14. package/dist/shared-utils/uuid.d.ts +1 -0
  15. package/docs/classes/Magnifier.html +4 -4
  16. package/docs/classes/ModelRoomLabelController.html +4 -4
  17. package/docs/classes/PanoFloorplanRadarPluginController.html +2 -2
  18. package/docs/enums/CameraMovementEffect.html +2 -2
  19. package/docs/enums/DIRECTION.html +1 -1
  20. package/docs/enums/DISPLAY_STRATEGY_TYPE.html +1 -1
  21. package/docs/enums/FLOOR_PLAN_ATTACHED_TO.html +1 -1
  22. package/docs/enums/ITEM_LABEL_PLUGIN_DISPLAY_STRATEGY_TYPE.html +1 -1
  23. package/docs/enums/ModelFloorplanErrorType.html +1 -1
  24. package/docs/enums/Rotation.html +2 -2
  25. package/docs/index.html +1 -1
  26. package/docs/interfaces/CSS3DRenderPluginExportType.html +2 -2
  27. package/docs/interfaces/CameraMovementPluginExportType.html +2 -2
  28. package/docs/interfaces/FloorplanBounding.html +4 -4
  29. package/docs/interfaces/FloorplanData.html +2 -2
  30. package/docs/interfaces/FloorplanEntrance.html +7 -7
  31. package/docs/interfaces/FloorplanExtraObject.html +3 -3
  32. package/docs/interfaces/FloorplanExtraObject3D.html +2 -2
  33. package/docs/interfaces/FloorplanFloorData.html +2 -2
  34. package/docs/interfaces/FloorplanImagePosition.html +2 -2
  35. package/docs/interfaces/FloorplanObserver.html +2 -2
  36. package/docs/interfaces/FloorplanOutlineItem.html +2 -2
  37. package/docs/interfaces/FloorplanPosition.html +2 -2
  38. package/docs/interfaces/FloorplanRoomItem.html +6 -6
  39. package/docs/interfaces/FloorplanRoomLabelItem.html +3 -3
  40. package/docs/interfaces/FloorplanServerBounding.html +4 -4
  41. package/docs/interfaces/FloorplanServerComputedData.html +1 -1
  42. package/docs/interfaces/FloorplanServerData.html +2 -2
  43. package/docs/interfaces/FloorplanServerEntrance.html +7 -7
  44. package/docs/interfaces/FloorplanServerFloorData.html +2 -2
  45. package/docs/interfaces/FloorplanServerImagePosition.html +2 -2
  46. package/docs/interfaces/FloorplanServerObserver.html +2 -2
  47. package/docs/interfaces/FloorplanServerOutlineItem.html +2 -2
  48. package/docs/interfaces/FloorplanServerPosition.html +2 -2
  49. package/docs/interfaces/FloorplanServerRoomItem.html +7 -7
  50. package/docs/interfaces/FloorplanServerRoomLabelItem.html +3 -3
  51. package/docs/interfaces/ItemLabelPluginData.html +1 -1
  52. package/docs/interfaces/ItemLabelPluginExportReturnsType.html +1 -1
  53. package/docs/interfaces/ItemLabelPluginParametersType.html +1 -1
  54. package/docs/interfaces/LineJson.html +1 -1
  55. package/docs/interfaces/ModelChassisCompassPluginData.html +1 -1
  56. package/docs/interfaces/ModelChassisCompassPluginExportType.html +1 -1
  57. package/docs/interfaces/ModelChassisCompassPluginParameterType.html +1 -1
  58. package/docs/interfaces/ModelEntryDoorGuidePluginData.html +1 -1
  59. package/docs/interfaces/ModelEntryDoorGuidePluginExportType.html +1 -1
  60. package/docs/interfaces/ModelFloorplanParameterType.html +1 -1
  61. package/docs/interfaces/ModelFloorplanViewEvent.html +2 -2
  62. package/docs/interfaces/ModelItemLabelPluginData.html +1 -1
  63. package/docs/interfaces/ModelItemLabelPluginExportReturnsType.html +1 -1
  64. package/docs/interfaces/ModelItemLabelPluginParametersType.html +1 -1
  65. package/docs/interfaces/ModelRoomLabelPluginData.html +1 -1
  66. package/docs/interfaces/ModelTVVideoPluginData.html +1 -1
  67. package/docs/interfaces/ModelTVVideoPluginExportType.html +1 -1
  68. package/docs/interfaces/ModelTVVideoPluginParameterType.html +1 -1
  69. package/docs/interfaces/ModelViewPluginExportType.html +1 -1
  70. package/docs/interfaces/OpenParameter.html +2 -2
  71. package/docs/interfaces/PanoCompassPluginData.html +1 -1
  72. package/docs/interfaces/PanoCompassPluginParameterType.html +1 -1
  73. package/docs/interfaces/PanoCursorRaycasterPluginExportType.html +6 -6
  74. package/docs/interfaces/PanoCursorRaycasterPluginParameterType.html +1 -1
  75. package/docs/interfaces/PanoFloorplanRadarPluginControllerParameter.html +1 -1
  76. package/docs/interfaces/PanoMeasureParameterType.html +1 -1
  77. package/docs/interfaces/PanoRulerPluginExportType.html +1 -1
  78. package/docs/interfaces/PanoRulerPluginOptions.html +1 -1
  79. package/docs/interfaces/PanoRulerPluginParameterType.html +1 -1
  80. package/docs/interfaces/PanoSpatialTagPluginContentEvent.html +1 -1
  81. package/docs/interfaces/PanoSpatialTagPluginContentReplacement.html +1 -1
  82. package/docs/interfaces/PanoSpatialTagPluginData.html +1 -1
  83. package/docs/interfaces/PanoSpatialTagPluginDataElement.html +1 -1
  84. package/docs/interfaces/PanoSpatialTagPluginExportType.html +1 -1
  85. package/docs/interfaces/PanoSpatialTagPluginOriginElement.html +1 -1
  86. package/docs/interfaces/PanoSpatialTagPluginParameterType.html +1 -1
  87. package/docs/interfaces/PanoSpatialTagPluginPointElement.html +1 -1
  88. package/docs/interfaces/PanoSpatialTagPluginTagElement.html +1 -1
  89. package/docs/interfaces/Point.html +1 -1
  90. package/docs/interfaces/PointJson.html +1 -1
  91. package/docs/interfaces/Room.html +1 -1
  92. package/docs/interfaces/RoomInfo.html +1 -1
  93. package/docs/interfaces/RoomLabel.html +7 -7
  94. package/docs/interfaces/RoomRules.html +1 -1
  95. package/docs/interfaces/Rooms.html +1 -1
  96. package/docs/interfaces/TopviewFloorplanPluginParameterType.html +9 -9
  97. package/docs/modules.html +20 -20
  98. package/libs/ModelSimulationPlugin/index.d.ts +33 -0
  99. package/libs/ModelSimulationPlugin/index.js +166 -0
  100. package/libs/ModelSimulationPlugin/shaders/fragment.d.ts +2 -0
  101. package/libs/ModelSimulationPlugin/shaders/fragment.js +96 -0
  102. package/libs/ModelSimulationPlugin/shaders/vertex.d.ts +2 -0
  103. package/libs/ModelSimulationPlugin/shaders/vertex.js +23 -0
  104. package/libs/PanoSpatialTagPlugin/Plugin.js +21 -7
  105. package/libs/components/PaintBrush/Controller.d.ts +43 -0
  106. package/libs/components/PaintBrush/Controller.js +575 -0
  107. package/libs/components/PaintBrush/Subscribe.d.ts +76 -0
  108. package/libs/components/PaintBrush/Subscribe.js +121 -0
  109. package/libs/components/PaintBrush/index.d.ts +27 -0
  110. package/libs/components/PaintBrush/index.js +57 -0
  111. package/libs/components/PaintBrush/style.d.ts +2 -0
  112. package/libs/components/PaintBrush/style.js +102 -0
  113. package/libs/components/PaintBrush/tween.d.ts +62 -0
  114. package/libs/components/PaintBrush/tween.js +15 -0
  115. package/libs/components/PaintBrush/typings.d.ts +58 -0
  116. package/libs/components/PaintBrush/typings.js +6 -0
  117. package/libs/components/PaintBrush/utils.d.ts +26 -0
  118. package/libs/components/PaintBrush/utils.js +51 -0
  119. package/libs/components/index.d.ts +2 -0
  120. package/libs/components/index.js +3 -0
  121. package/libs/floorplan/ModelFloorplanPlugin/Assets/compass.d.ts +1 -0
  122. package/libs/floorplan/ModelFloorplanPlugin/Assets/compass.js +1 -0
  123. package/libs/floorplan/ModelFloorplanPlugin/Components/Camera.js +120 -0
  124. package/libs/floorplan/ModelFloorplanPlugin/Components/Compass.js +106 -0
  125. package/libs/floorplan/ModelFloorplanPlugin/Components/CurrentFloor/CurrentFloor.js +463 -0
  126. package/libs/floorplan/ModelFloorplanPlugin/Components/Main.js +375 -0
  127. package/libs/floorplan/ModelFloorplanPlugin/Components/RoomLabels/RoomLabel.js +171 -0
  128. package/libs/floorplan/ModelFloorplanPlugin/Components/RoomLabels/RoomLabels.js +265 -0
  129. package/libs/floorplan/ModelFloorplanPlugin/Components/RuleLabels/RuleItem.js +301 -0
  130. package/libs/floorplan/ModelFloorplanPlugin/Components/RuleLabels/RuleLabels.js +219 -0
  131. package/libs/shared-utils/five/useFivePlugin.d.ts +1 -0
  132. package/libs/shared-utils/five/useFivePlugin.js +8 -0
  133. package/libs/shared-utils/useDebounce.d.ts +8 -0
  134. package/libs/shared-utils/useDebounce.js +22 -0
  135. package/libs/shared-utils/useThrottle.d.ts +8 -0
  136. package/libs/shared-utils/useThrottle.js +25 -0
  137. package/libs/shared-utils/uuid.d.ts +1 -0
  138. package/libs/shared-utils/uuid.js +1 -0
  139. package/package.json +4 -2
@@ -0,0 +1,33 @@
1
+ import type { FivePlugin } from '@realsee/five';
2
+ export interface ModelSimulationPluginExportType {
3
+ enable: () => void;
4
+ disable: () => void;
5
+ play: () => void;
6
+ dispose: () => void;
7
+ init: () => void;
8
+ }
9
+ export interface ModelSimulationPluginParameterType {
10
+ simulationWorkData: ModelSimulationPluginWorkDataType;
11
+ simulationOptions: ModelSimulationPluginOptionsType;
12
+ }
13
+ export interface ModelSimulationPluginWorkDataType {
14
+ resourceUrl: string;
15
+ colorMapPath: string;
16
+ width: number;
17
+ height: number;
18
+ depth: number;
19
+ origin: number[];
20
+ step: number;
21
+ maxT: number;
22
+ minT: number;
23
+ maxKeyframes: number;
24
+ houseHeight: number;
25
+ }
26
+ export interface ModelSimulationPluginOptionsType {
27
+ globalOpacity: number;
28
+ boundingOpacity: number;
29
+ boundingOffset?: number;
30
+ keyFrameRate?: number;
31
+ }
32
+ declare const ModelSimulationPlugin: FivePlugin<ModelSimulationPluginParameterType, ModelSimulationPluginExportType>;
33
+ export default ModelSimulationPlugin;
@@ -0,0 +1,166 @@
1
+ import * as THREE from 'three';
2
+ import vertexShader from './shaders/vertex';
3
+ import fragmentShader from './shaders/fragment';
4
+ import tap from '../shared-utils/tap';
5
+ const houseOutLinePath = [
6
+ [-3.089, -4.219], [-4.834, -4.219],
7
+ [-8.197, -4.219], [-10.31, -4.219],
8
+ [-10.31, -1.002], [-10.31, 0.835],
9
+ [-10.31, 3.927], [-11.237, 3.927],
10
+ [-11.237, 5.45], [-8.104, 5.45],
11
+ [-8.104, 4.557], [-6.914, 4.557],
12
+ [-6.244, 4.557], [-6.244, 5.436],
13
+ [-3.78, 5.436], [-0.356, 5.436],
14
+ [0.286, 5.436], [0.286, 4.073],
15
+ [0.286, 0.395], [2.31, 0.395],
16
+ [2.31, -1.323], [2.31, -4.199],
17
+ [0.468, -4.199], [0.468, -3.547],
18
+ [-2.969, -3.547], [-3.089, -3.547]
19
+ ];
20
+ const defaultKeyframes = 50;
21
+ const defaultBoundingOffset = 0.2;
22
+ let isTexutreReady = false;
23
+ const ModelSimulationPlugin = (five, options) => {
24
+ let heatTexutres = [];
25
+ let geometryTexture = null;
26
+ let simulationMaterial = null;
27
+ let boundingMaterial = null;
28
+ let boundingMesh = null;
29
+ let originMaterial = null;
30
+ const enable = () => {
31
+ };
32
+ const disable = () => {
33
+ five.model.setMaterial(originMaterial);
34
+ };
35
+ const createBounding = (path, material) => {
36
+ const shape = tap(new THREE.Shape(), shape => {
37
+ shape.moveTo(path[path.length - 1][0], path[path.length - 1][1]);
38
+ path.forEach(xz => shape.lineTo(xz[0], xz[1]));
39
+ });
40
+ const settings = {
41
+ depth: options.simulationWorkData.houseHeight + 2 * options.simulationOptions.boundingOffset ?? defaultBoundingOffset,
42
+ bevelEnabled: false,
43
+ };
44
+ const geometry = new THREE.ExtrudeGeometry(shape, settings);
45
+ boundingMesh = new THREE.Mesh(geometry, material);
46
+ boundingMesh.rotateX(Math.PI / 2);
47
+ boundingMesh.translateZ(-options.simulationWorkData.houseHeight - options.simulationOptions.boundingOffset);
48
+ boundingMesh.updateMatrix();
49
+ boundingMesh.updateMatrixWorld();
50
+ return boundingMesh;
51
+ };
52
+ const createSimulationMaterial = (isBounding) => {
53
+ const simulationMaterial = new THREE.RawShaderMaterial({
54
+ uniforms: {
55
+ heatMap: { value: new THREE.Texture() },
56
+ geometryMap: { value: new THREE.Texture() },
57
+ colorMap: { value: new THREE.TextureLoader().load(options.simulationWorkData.colorMapPath) },
58
+ bboxMin: { value: new THREE.Vector3().fromArray(options.simulationWorkData.origin) },
59
+ bboxMax: { value: new THREE.Vector3().fromArray(options.simulationWorkData.origin).add(new THREE.Vector3(options.simulationWorkData.width, options.simulationWorkData.height, options.simulationWorkData.depth).multiplyScalar(options.simulationWorkData.step)) },
60
+ step: { value: options.simulationWorkData.step },
61
+ maxT: { value: options.simulationWorkData.maxT },
62
+ minT: { value: options.simulationWorkData.minT },
63
+ opacity: { value: isBounding ? options.simulationOptions.boundingOpacity : options.simulationOptions.globalOpacity }
64
+ },
65
+ vertexShader,
66
+ fragmentShader,
67
+ });
68
+ if (isBounding)
69
+ simulationMaterial.transparent = true;
70
+ return simulationMaterial;
71
+ };
72
+ const create3DTextureTask = (url) => {
73
+ return fetch(url)
74
+ .then(res => {
75
+ return res.arrayBuffer();
76
+ })
77
+ .then(res => {
78
+ const texture = new THREE.DataTexture3D(new Float32Array(res), options.simulationWorkData.width, options.simulationWorkData.height, options.simulationWorkData.depth);
79
+ texture.type = THREE.FloatType;
80
+ texture.format = THREE.RedFormat;
81
+ texture.minFilter = THREE.LinearMipmapLinearFilter;
82
+ texture.magFilter = THREE.LinearFilter;
83
+ texture.generateMipmaps = true;
84
+ texture.unpackAlignment = 1;
85
+ return texture;
86
+ })
87
+ .catch(err => console.error("拉取三维纹理数据时发生错误"));
88
+ };
89
+ const init = () => {
90
+ simulationMaterial = createSimulationMaterial(false);
91
+ boundingMaterial = createSimulationMaterial(true);
92
+ //加载外bounding
93
+ five.scene.add(createBounding(houseOutLinePath, boundingMaterial));
94
+ //缓存原来的材质
95
+ originMaterial = five.model.getMaterial();
96
+ five.model.traverse(obj => {
97
+ if (!(obj instanceof THREE.Mesh))
98
+ return;
99
+ if (Array.isArray(obj.material)) {
100
+ obj.material = obj.material.map(_mtl => simulationMaterial);
101
+ }
102
+ else {
103
+ obj.material = simulationMaterial;
104
+ }
105
+ });
106
+ //温度数据
107
+ // const geometryTaskUrl = options.resourceUrl + 'geometry.vti'
108
+ const heatTextureTasks = [];
109
+ for (let i = 0; i < options.simulationWorkData.maxKeyframes; i++) {
110
+ const fileUrl = options.simulationWorkData.resourceUrl + i + '.vti';
111
+ heatTextureTasks.push(create3DTextureTask(fileUrl));
112
+ }
113
+ // //有效值数据
114
+ // create3DTextureTask(geometryTaskUrl)
115
+ // .then(texture => {
116
+ // simulationMaterial.uniforms.geometryMap.value = texture
117
+ // boundingMaterial.uniforms.geometryMap.value = texture
118
+ // })
119
+ // .catch(err => console.error("geometry texture loading failed"))
120
+ //加载首帧进行初始化
121
+ create3DTextureTask(options.simulationWorkData.resourceUrl + '0.vti')
122
+ .then(texture => {
123
+ simulationMaterial.uniforms.heatMap.value = texture;
124
+ boundingMaterial.uniforms.heatMap.value = texture;
125
+ five.needsRender = true;
126
+ })
127
+ .catch(err => console.error("loading textures failed"));
128
+ //加载全部
129
+ Promise.all(heatTextureTasks)
130
+ .then(textures => {
131
+ //缓存结果
132
+ isTexutreReady = true;
133
+ console.log("ready");
134
+ heatTexutres = textures;
135
+ })
136
+ .catch(err => console.error("loading textures failed"));
137
+ };
138
+ const play = () => {
139
+ if (!isTexutreReady)
140
+ throw new Error("textures are not ready yet,plz try again later");
141
+ let timeCount = 0;
142
+ const stop = setInterval(() => {
143
+ if (timeCount < options.simulationWorkData.maxKeyframes) {
144
+ simulationMaterial.uniforms.heatMap.value = heatTexutres[timeCount];
145
+ boundingMaterial.uniforms.heatMap.value = heatTexutres[timeCount];
146
+ timeCount++;
147
+ five.needsRender = true;
148
+ }
149
+ }, 1000 / options.simulationOptions.keyFrameRate ?? defaultKeyframes);
150
+ };
151
+ const dispose = () => {
152
+ simulationMaterial.dispose();
153
+ boundingMaterial.dispose();
154
+ boundingMesh.geometry.dispose();
155
+ geometryTexture.dispose();
156
+ heatTexutres.forEach(texture => texture.dispose());
157
+ };
158
+ return {
159
+ enable,
160
+ disable,
161
+ play,
162
+ init,
163
+ dispose
164
+ };
165
+ };
166
+ export default ModelSimulationPlugin;
@@ -0,0 +1,2 @@
1
+ declare var _default: "#version 300 es\n#define MAX_STEPS 50\nprecision highp float;\nprecision highp sampler3D;\n\nuniform sampler3D heatMap;\nuniform sampler3D geometryMap;\nuniform sampler2D colorMap;\n\nuniform vec3 bboxMin;\nuniform vec3 bboxMax;\nuniform float step;\nuniform float minT;\nuniform float maxT;\nuniform float opacity;\n\nvec4 LinearTosRGB( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );\n}\nvec4 linearToOutputTexel( vec4 value ) { return LinearTosRGB( value ); }\n\n\nfloat getHeatByLegalPos(vec3 pos){\n\tfloat geometryFactor = texture(geometryMap,pos).r;\n\tfloat legalFactor = clamp(geometryFactor,0.0,1.0);\n\treturn texture(heatMap,pos).r * legalFactor;\n}\n\nfloat sampleOc(vec3 pos){\n\t//平滑滤波步长\n\t//todo:可以作为define传入的外部常量还是直接传\n\tfloat step_x = step / (bboxMax.x - bboxMin.x) * 0.5;\n\tfloat step_y = step / (bboxMax.y - bboxMin.y) * 0.5;\n\tfloat step_z = step / (bboxMax.z - bboxMin.z) * 0.5;\n\tvec3 p1 = pos + vec3(step_x,step_y,step_z);\n\tvec3 p2 = pos + vec3(step_x,-step_y,step_z);\n\tvec3 p3 = pos + vec3(step_x,step_y,-step_z);\n\tvec3 p4 = pos + vec3(step_x,-step_y,-step_z);\n\tvec3 p5 = pos + vec3(-step_x,step_y,step_z);\n\tvec3 p6 = pos + vec3(-step_x,-step_y,step_z);\n\tvec3 p7 = pos + vec3(-step_x,step_y,-step_z);\n\tvec3 p8 = pos + vec3(-step_x,-step_y,-step_z);\n\n\treturn (getHeatByLegalPos(p1) + getHeatByLegalPos(p2) + getHeatByLegalPos(p3) + getHeatByLegalPos(p4) + getHeatByLegalPos(p5) + getHeatByLegalPos(p6) + getHeatByLegalPos(p7) + getHeatByLegalPos(p8)) * 0.125;\n\n}\n\n//考虑到有效仿真值连通域在三维空间中是封闭流形,这里直接按照normal方向搜索,牺牲一定精度,以保证展示效果\nfloat sampleByNormal(vec3 normal, vec3 pos){\n\tfloat searchStep = step ;\n\tvec3 currentPos = pos;\n\tfor (int iter=0; iter < MAX_STEPS; iter++) {\n\t\tif(iter >= MAX_STEPS){\n\t\t\treturn texture(heatMap,currentPos).r;\n\t\t}\n\t\tif(texture(geometryMap,currentPos).r < 0.5){\n\t\t\tcurrentPos += normal * searchStep;\n\t\t}else{\n\t\t\treturn texture(heatMap,currentPos).r;\n\t\t}\n\t}\n}\n\nfloat sample1(vec3 normal, vec3 pos){\n\treturn texture(heatMap,pos).r;\n}\n\nin vec2 vUv;\nin vec3 vPosition;\nin vec3 vNormal;\nout highp vec4 pc_fragColor;\n\n\nfloat normalizeHeat(float t){\n\tfloat _t = clamp(t,minT,maxT);\n\treturn (_t - minT)/(maxT - minT);\n}\n\nvec3 posToTexCood(vec3 pos){\n\tfloat x = (pos.x - bboxMin.x) / (bboxMax.x - bboxMin.x);\n\tfloat y = (pos.y - bboxMin.y) / (bboxMax.y - bboxMin.y);\n\tfloat z = (pos.z - bboxMin.z) / (bboxMax.z - bboxMin.z);\n\treturn vec3(x,y,z);\n}\n\n\nvoid main() {\n\tvec3 texCood = posToTexCood(vPosition);\n\t// float color = sampleByNormal(vNormal,texCood);\n\tfloat color = sample1(vNormal,texCood);\n\tfloat normalColor= normalizeHeat(color);\n\tvec4 colorMapColor = texture(colorMap,vec2(normalColor,0.2));\n\tpc_fragColor = vec4(colorMapColor.xyz,opacity);\n\t// pc_fragColor = linearToOutputTexel(vec4(colorMapColor.xyz,opacity));\n\t}\n";
2
+ export default _default;
@@ -0,0 +1,96 @@
1
+ export default `#version 300 es
2
+ #define MAX_STEPS 50
3
+ precision highp float;
4
+ precision highp sampler3D;
5
+
6
+ uniform sampler3D heatMap;
7
+ uniform sampler3D geometryMap;
8
+ uniform sampler2D colorMap;
9
+
10
+ uniform vec3 bboxMin;
11
+ uniform vec3 bboxMax;
12
+ uniform float step;
13
+ uniform float minT;
14
+ uniform float maxT;
15
+ uniform float opacity;
16
+
17
+ vec4 LinearTosRGB( in vec4 value ) {
18
+ return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );
19
+ }
20
+ vec4 linearToOutputTexel( vec4 value ) { return LinearTosRGB( value ); }
21
+
22
+
23
+ float getHeatByLegalPos(vec3 pos){
24
+ float geometryFactor = texture(geometryMap,pos).r;
25
+ float legalFactor = clamp(geometryFactor,0.0,1.0);
26
+ return texture(heatMap,pos).r * legalFactor;
27
+ }
28
+
29
+ float sampleOc(vec3 pos){
30
+ //平滑滤波步长
31
+ //todo:可以作为define传入的外部常量还是直接传
32
+ float step_x = step / (bboxMax.x - bboxMin.x) * 0.5;
33
+ float step_y = step / (bboxMax.y - bboxMin.y) * 0.5;
34
+ float step_z = step / (bboxMax.z - bboxMin.z) * 0.5;
35
+ vec3 p1 = pos + vec3(step_x,step_y,step_z);
36
+ vec3 p2 = pos + vec3(step_x,-step_y,step_z);
37
+ vec3 p3 = pos + vec3(step_x,step_y,-step_z);
38
+ vec3 p4 = pos + vec3(step_x,-step_y,-step_z);
39
+ vec3 p5 = pos + vec3(-step_x,step_y,step_z);
40
+ vec3 p6 = pos + vec3(-step_x,-step_y,step_z);
41
+ vec3 p7 = pos + vec3(-step_x,step_y,-step_z);
42
+ vec3 p8 = pos + vec3(-step_x,-step_y,-step_z);
43
+
44
+ return (getHeatByLegalPos(p1) + getHeatByLegalPos(p2) + getHeatByLegalPos(p3) + getHeatByLegalPos(p4) + getHeatByLegalPos(p5) + getHeatByLegalPos(p6) + getHeatByLegalPos(p7) + getHeatByLegalPos(p8)) * 0.125;
45
+
46
+ }
47
+
48
+ //考虑到有效仿真值连通域在三维空间中是封闭流形,这里直接按照normal方向搜索,牺牲一定精度,以保证展示效果
49
+ float sampleByNormal(vec3 normal, vec3 pos){
50
+ float searchStep = step ;
51
+ vec3 currentPos = pos;
52
+ for (int iter=0; iter < MAX_STEPS; iter++) {
53
+ if(iter >= MAX_STEPS){
54
+ return texture(heatMap,currentPos).r;
55
+ }
56
+ if(texture(geometryMap,currentPos).r < 0.5){
57
+ currentPos += normal * searchStep;
58
+ }else{
59
+ return texture(heatMap,currentPos).r;
60
+ }
61
+ }
62
+ }
63
+
64
+ float sample1(vec3 normal, vec3 pos){
65
+ return texture(heatMap,pos).r;
66
+ }
67
+
68
+ in vec2 vUv;
69
+ in vec3 vPosition;
70
+ in vec3 vNormal;
71
+ out highp vec4 pc_fragColor;
72
+
73
+
74
+ float normalizeHeat(float t){
75
+ float _t = clamp(t,minT,maxT);
76
+ return (_t - minT)/(maxT - minT);
77
+ }
78
+
79
+ vec3 posToTexCood(vec3 pos){
80
+ float x = (pos.x - bboxMin.x) / (bboxMax.x - bboxMin.x);
81
+ float y = (pos.y - bboxMin.y) / (bboxMax.y - bboxMin.y);
82
+ float z = (pos.z - bboxMin.z) / (bboxMax.z - bboxMin.z);
83
+ return vec3(x,y,z);
84
+ }
85
+
86
+
87
+ void main() {
88
+ vec3 texCood = posToTexCood(vPosition);
89
+ // float color = sampleByNormal(vNormal,texCood);
90
+ float color = sample1(vNormal,texCood);
91
+ float normalColor= normalizeHeat(color);
92
+ vec4 colorMapColor = texture(colorMap,vec2(normalColor,0.2));
93
+ pc_fragColor = vec4(colorMapColor.xyz,opacity);
94
+ // pc_fragColor = linearToOutputTexel(vec4(colorMapColor.xyz,opacity));
95
+ }
96
+ `;
@@ -0,0 +1,2 @@
1
+ declare var _default: "#version 300 es\n\tin vec3 position;\n\tin vec3 normal;\n\tout vec3 vPosition;\n\tout vec3 vNormal;\n\n\tuniform mat4 modelViewMatrix;\n\tuniform mat4 projectionMatrix;\n\tuniform vec3 cameraPos;\n\t// uniform vec3 normalMatrix;\n\tuniform mat4 modelMatrix;\n\n\tvoid main() {\n\n\t\tvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\n\t\tvec4 worldPosition = modelMatrix * vec4(position.xyz,1.0);\n\t\tvPosition = worldPosition.xyz;\n\t\t// vec3 transformedNormal = normalMatrix * normal;\n\t\tvNormal = normalize(normal);\n\n\t\tgl_Position = projectionMatrix * mvPosition;\n\t}\n";
2
+ export default _default;
@@ -0,0 +1,23 @@
1
+ export default `#version 300 es
2
+ in vec3 position;
3
+ in vec3 normal;
4
+ out vec3 vPosition;
5
+ out vec3 vNormal;
6
+
7
+ uniform mat4 modelViewMatrix;
8
+ uniform mat4 projectionMatrix;
9
+ uniform vec3 cameraPos;
10
+ // uniform vec3 normalMatrix;
11
+ uniform mat4 modelMatrix;
12
+
13
+ void main() {
14
+
15
+ vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );
16
+ vec4 worldPosition = modelMatrix * vec4(position.xyz,1.0);
17
+ vPosition = worldPosition.xyz;
18
+ // vec3 transformedNormal = normalMatrix * normal;
19
+ vNormal = normalize(normal);
20
+
21
+ gl_Position = projectionMatrix * mvPosition;
22
+ }
23
+ `;
@@ -6,7 +6,6 @@ import Tag from './Components/tag';
6
6
  import { pluginStyle } from './style';
7
7
  import render from '../shared-utils/tinyEJSrender';
8
8
  const MESH_SIZE = 0.001;
9
- const RAY_ORIGIN_Y = 1.4;
10
9
  const RAY_TOLERANT_DISTANCE = 0.01;
11
10
  const BLUR_IMAGE_URL = 'https://vrlab-image4.ljcdn.com/release/web/PanoSpatialTagPlugin__blur.png';
12
11
  const MIN_DISTANCE = 1.2;
@@ -17,6 +16,7 @@ const MAX_DISTANCE = 3.5;
17
16
  export const PanoSpatialTagPlugin = (five, params) => {
18
17
  var _a, _b, _c, _d, _e, _f;
19
18
  let wrapper = params === null || params === void 0 ? void 0 : params.container;
19
+ let centerY = 1.4;
20
20
  const wait = (_a = params === null || params === void 0 ? void 0 : params.wait) !== null && _a !== void 0 ? _a : 200;
21
21
  const maxNumberOnScreen = (_b = params === null || params === void 0 ? void 0 : params.maxNumberOnScreen) !== null && _b !== void 0 ? _b : 3;
22
22
  const minRad = (_c = params === null || params === void 0 ? void 0 : params.minRad) !== null && _c !== void 0 ? _c : Math.PI / 4;
@@ -75,7 +75,7 @@ export const PanoSpatialTagPlugin = (five, params) => {
75
75
  projScreenMatrix.multiplyMatrices(camera.projectionMatrix, camera.matrixWorldInverse);
76
76
  frustum.setFromProjectionMatrix(projScreenMatrix);
77
77
  state.tags.forEach(tag => {
78
- const distance = camera.position.clone().setY(RAY_ORIGIN_Y).distanceTo(tag.position);
78
+ const distance = camera.position.clone().setY(centerY).distanceTo(tag.position);
79
79
  if (distance < MIN_DISTANCE || distance > MAX_DISTANCE)
80
80
  return tag.destroying = true;
81
81
  if (!frustum.containsPoint(tag.position))
@@ -170,7 +170,7 @@ export const PanoSpatialTagPlugin = (five, params) => {
170
170
  const points = state.points.reduce((result, point) => {
171
171
  if (state.tags.find(tag => point.id === tag.id && !tag.destroying))
172
172
  return result;
173
- const distance = camera.position.clone().setY(RAY_ORIGIN_Y).distanceTo(point.position);
173
+ const distance = camera.position.clone().setY(centerY).distanceTo(point.position);
174
174
  if (distance < MIN_DISTANCE || distance > MAX_DISTANCE)
175
175
  return result;
176
176
  if (!frustum.containsPoint(point.position))
@@ -231,10 +231,12 @@ export const PanoSpatialTagPlugin = (five, params) => {
231
231
  Math.pow((mouse.y - _mouse.y) / 2 * clientHeight, 2)) > nearTolerance;
232
232
  }))
233
233
  continue;
234
- const raycaster = new THREE.Raycaster(camera.position.clone().setY(RAY_ORIGIN_Y), point.position.clone().sub(camera.position.clone().setY(RAY_ORIGIN_Y)).normalize(), 0, point.distance + RAY_TOLERANT_DISTANCE);
235
- const [intersect] = five.model.bvhs.loaded ?
236
- five.model.intersectRaycaster(raycaster) :
237
- raycaster.intersectObjects(five.model.children, true);
234
+ const raycaster = new THREE.Raycaster(camera.position.clone().setY(centerY), point.position.clone().sub(camera.position.clone().setY(centerY)).normalize(), 0, point.distance + RAY_TOLERANT_DISTANCE);
235
+ const [intersect] = state.intersectObjects ?
236
+ raycaster.intersectObjects(state.intersectObjects, true) :
237
+ (five.model.bvhs.loaded ?
238
+ five.model.intersectRaycaster(raycaster) :
239
+ raycaster.intersectObjects(five.model.children, true));
238
240
  if (!intersect)
239
241
  continue;
240
242
  if (point.distance - intersect.distance < RAY_TOLERANT_DISTANCE) {
@@ -301,6 +303,13 @@ export const PanoSpatialTagPlugin = (five, params) => {
301
303
  if (data.folded === true)
302
304
  state.folded = data.folded;
303
305
  };
306
+ /** 设置射线碰撞检测objects
307
+ *
308
+ */
309
+ const setIntersectObjects = (objects) => {
310
+ state.intersectObjects = objects;
311
+ updateTags();
312
+ };
304
313
  /** 标签启用
305
314
  * 启用插件并重新计算展示标签
306
315
  */
@@ -374,13 +383,16 @@ export const PanoSpatialTagPlugin = (five, params) => {
374
383
  five.off('panoArrived', onPanoArrived);
375
384
  five.off('modeChange', onModeChange);
376
385
  five.off('cameraUpdate', onCameraUpdate);
386
+ window.removeEventListener('resize', updateOrigins, false);
377
387
  };
388
+ window.addEventListener('resize', updateOrigins, false);
378
389
  if ((_f = five === null || five === void 0 ? void 0 : five.model) === null || _f === void 0 ? void 0 : _f.loaded) {
379
390
  if (!wrapper)
380
391
  wrapper = five.getElement().parentElement;
381
392
  if (wrapper)
382
393
  wrapper.appendChild(container);
383
394
  state.forbidden = false;
395
+ centerY = five.model.bounding.getCenter(new THREE.Vector3()).y;
384
396
  updateTags();
385
397
  five.on('panoWillArrive', onPanoWillArrive);
386
398
  five.on('panoArrived', onPanoArrived);
@@ -393,6 +405,7 @@ export const PanoSpatialTagPlugin = (five, params) => {
393
405
  wrapper = five.getElement().parentElement;
394
406
  if (wrapper)
395
407
  wrapper.appendChild(container);
408
+ centerY = five.model.bounding.getCenter(new THREE.Vector3()).y;
396
409
  state.forbidden = false;
397
410
  updateTags();
398
411
  five.on('panoWillArrive', onPanoWillArrive);
@@ -404,6 +417,7 @@ export const PanoSpatialTagPlugin = (five, params) => {
404
417
  five.on('dispose', dispose);
405
418
  return {
406
419
  load,
420
+ setIntersectObjects,
407
421
  unfoldAll,
408
422
  foldAll,
409
423
  unfold,
@@ -0,0 +1,43 @@
1
+ import { noop } from './utils';
2
+ import { PaintBrushAction, PaintBrushConfigs, PaintBrushEventMap, PaintBrushState } from './typings';
3
+ import { Subscribe } from './Subscribe';
4
+ export declare class Controller extends Subscribe<PaintBrushEventMap> {
5
+ configs: PaintBrushConfigs;
6
+ private clientWidth;
7
+ private clientHeight;
8
+ private ready;
9
+ private uuid;
10
+ private tween?;
11
+ private tweening;
12
+ private container;
13
+ private canvas;
14
+ private data;
15
+ private tempLine;
16
+ get color(): string;
17
+ get state(): Record<string, PaintBrushState[]>;
18
+ get dpr(): number;
19
+ constructor(configs: PaintBrushConfigs);
20
+ ifInsertToDOM(): HTMLDivElement;
21
+ /**
22
+ *
23
+ * @param className 初始化画板
24
+ * @returns
25
+ */
26
+ initCanvas(className: string): HTMLCanvasElement;
27
+ /**
28
+ * 初始化操作面板
29
+ * @returns
30
+ */
31
+ initCtrl(): HTMLDivElement;
32
+ openBrush(): void;
33
+ closeBrush(): void;
34
+ updateCurrentColor(color: string): void;
35
+ openBrushHandle(): void;
36
+ emitStateChange(action: PaintBrushAction, userAction?: boolean): void;
37
+ action(action: PaintBrushAction): void;
38
+ handleDrawLine(_uuid: string, data: PaintBrushState, { withUndo }: {
39
+ withUndo?: boolean;
40
+ }, callback?: typeof noop): void;
41
+ handleUndo(uuid: string): void;
42
+ destroyBrush(): void;
43
+ }