@realsee/dnalogel 0.1.0 → 0.1.4

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 (92) hide show
  1. package/data/8054djM0oR6ky3Ey8e.d.ts +55 -0
  2. package/data/8054djM0oR6ky3Ey8e.js +348 -0
  3. package/data/PrXel3aqGbp34JQn.js +10 -2
  4. package/data/XJ6NMLWnkAY3Rdx8.d.ts +843 -0
  5. package/data/XJ6NMLWnkAY3Rdx8.js +7987 -0
  6. package/data/jd6oMOzPxnQ3BvxY_B7yw51J9rXlhYhjhGTOgRVqu6WeEqjNX.d.ts +85 -0
  7. package/data/jd6oMOzPxnQ3BvxY_B7yw51J9rXlhYhjhGTOgRVqu6WeEqjNX.js +509 -0
  8. package/data/vLykj3NWrllMrG06.d.ts +2 -0
  9. package/data/vLykj3NWrllMrG06.js +197 -2
  10. package/data/zxMawr9raSg8LYjG.d.ts +53 -0
  11. package/data/zxMawr9raSg8LYjG.js +588 -0
  12. package/package.json +3 -3
  13. package/plugins/AutoPreloadPlugin/index.d.ts +23 -0
  14. package/plugins/AutoPreloadPlugin/index.js +85 -0
  15. package/plugins/CSS3DRenderPlugin/index.d.ts +11 -11
  16. package/plugins/CSS3DRenderPlugin/index.js +170 -120
  17. package/plugins/ModelChassisCompassPlugin/index.d.ts +7 -3
  18. package/plugins/ModelChassisCompassPlugin/index.js +13 -26
  19. package/plugins/ModelEntryDoorGuidePlugin/index.d.ts +13 -1
  20. package/plugins/ModelEntryDoorGuidePlugin/index.js +212 -2
  21. package/plugins/ModelRoomLabelPlugin/Controller.d.ts +35 -0
  22. package/plugins/ModelRoomLabelPlugin/Controller.js +147 -0
  23. package/plugins/ModelRoomLabelPlugin/RoomLabelItem.d.ts +8 -0
  24. package/plugins/ModelRoomLabelPlugin/RoomLabelItem.js +48 -0
  25. package/plugins/ModelRoomLabelPlugin/RoomLabelItems.d.ts +7 -0
  26. package/plugins/ModelRoomLabelPlugin/RoomLabelItems.js +149 -0
  27. package/plugins/ModelRoomLabelPlugin/index.d.ts +8 -0
  28. package/plugins/ModelRoomLabelPlugin/index.js +16 -0
  29. package/plugins/ModelRoomLabelPlugin/typings.d.ts +35 -0
  30. package/plugins/ModelRoomLabelPlugin/typings.js +5 -0
  31. package/plugins/ModelRoomLabelPlugin/utils/parseData.d.ts +3 -0
  32. package/plugins/ModelRoomLabelPlugin/utils/parseData.js +29 -0
  33. package/plugins/PanoMaskSelectorPlugin/compare.d.ts +1 -0
  34. package/plugins/PanoMaskSelectorPlugin/compare.js +15 -0
  35. package/plugins/PanoMaskSelectorPlugin/createBox.d.ts +7 -0
  36. package/plugins/PanoMaskSelectorPlugin/createBox.js +61 -0
  37. package/plugins/PanoMaskSelectorPlugin/createTextures.d.ts +3 -0
  38. package/plugins/PanoMaskSelectorPlugin/createTextures.js +29 -0
  39. package/plugins/PanoMaskSelectorPlugin/fragmentShader.d.ts +1 -0
  40. package/plugins/PanoMaskSelectorPlugin/fragmentShader.js +8 -0
  41. package/plugins/PanoMaskSelectorPlugin/index.d.ts +49 -0
  42. package/plugins/PanoMaskSelectorPlugin/index.js +272 -0
  43. package/plugins/PanoMaskSelectorPlugin/vertexShader.d.ts +1 -0
  44. package/plugins/PanoMaskSelectorPlugin/vertexShader.js +8 -0
  45. package/plugins/TreasurePlugin/Controller.d.ts +53 -12
  46. package/plugins/TreasurePlugin/Controller.js +129 -60
  47. package/plugins/TreasurePlugin/TreasureFaceAnime.d.ts +8 -6
  48. package/plugins/TreasurePlugin/TreasureFaceAnime.js +4 -4
  49. package/plugins/TreasurePlugin/TreasureObject.d.ts +30 -12
  50. package/plugins/TreasurePlugin/TreasureObject.js +269 -53
  51. package/plugins/TreasurePlugin/TreasureOpenAnime.d.ts +4 -2
  52. package/plugins/TreasurePlugin/TreasureOpenAnime.js +10 -5
  53. package/plugins/TreasurePlugin/constants.d.ts +32 -11
  54. package/plugins/TreasurePlugin/constants.js +52 -17
  55. package/plugins/TreasurePlugin/index.d.ts +5 -5
  56. package/plugins/TreasurePlugin/index.js +8 -0
  57. package/plugins/floorplan/ModelFloorplanPlugin/components/Camera.js +4 -2
  58. package/plugins/floorplan/ModelFloorplanPlugin/components/Compass.js +2 -1
  59. package/plugins/floorplan/ModelFloorplanPlugin/components/NowFloor/RoomLabels.js +5 -2
  60. package/plugins/floorplan/ModelFloorplanPlugin/components/index.js +1 -1
  61. package/plugins/floorplan/typings/floorplanData.d.ts +5 -1
  62. package/plugins/floorplan/utils/formatData.js +1 -22
  63. package/plugins/floorplan/utils/formatPosition.d.ts +4 -4
  64. package/shared-utils/createCanvasTextTexture.d.ts +8 -0
  65. package/shared-utils/createCanvasTextTexture.js +29 -0
  66. package/shared-utils/isNil.d.ts +10 -0
  67. package/shared-utils/isNil.js +24 -0
  68. package/shared-utils/three/getExtraModelLoader.d.ts +6 -0
  69. package/shared-utils/three/getExtraModelLoader.js +31 -0
  70. package/shared-utils/three/getTextureLoader.d.ts +6 -0
  71. package/shared-utils/three/getTextureLoader.js +34 -0
  72. package/shared-utils/three/loadFbxObj.d.ts +1 -2
  73. package/shared-utils/three/loadFbxObj.js +6 -2
  74. package/shared-utils/three/transformPositionToVector3.d.ts +7 -0
  75. package/shared-utils/three/{vecror3.js → transformPositionToVector3.js} +2 -2
  76. package/shared-utils/three/transfromToMeshBasicMaterial.d.ts +2 -0
  77. package/shared-utils/three/transfromToMeshBasicMaterial.js +27 -0
  78. package/shared-utils/to.d.ts +0 -1
  79. package/shared-utils/to.js +45 -7
  80. package/typedoc/plugins.d.ts +3 -1
  81. package/typedoc/plugins.js +63 -13
  82. package/typedoc/typings.d.ts +1 -1
  83. package/typings/math.type.d.ts +2 -2
  84. package/data/wYnRjQ4KZoV1yPoG.d.ts +0 -114
  85. package/data/wYnRjQ4KZoV1yPoG.js +0 -512
  86. package/plugins/PanoCursorRaycasterPlugin/utils/vecror3.d.ts +0 -7
  87. package/plugins/PanoCursorRaycasterPlugin/utils/vecror3.js +0 -18
  88. package/plugins/TreasurePlugin/treasureDataMap.d.ts +0 -7
  89. package/plugins/TreasurePlugin/treasureDataMap.js +0 -20
  90. package/plugins/TreasurePlugin/utils/loadTreasureTextures.d.ts +0 -7
  91. package/plugins/TreasurePlugin/utils/loadTreasureTextures.js +0 -115
  92. package/shared-utils/three/vecror3.d.ts +0 -7
@@ -0,0 +1,35 @@
1
+ export declare type ModelRoomLabelPluginData = {
2
+ model_room_labels: Readonly<{
3
+ id: string;
4
+ name: string;
5
+ longitude: number;
6
+ pano_index: number;
7
+ floor_index: number;
8
+ position: {
9
+ x: number;
10
+ y: number;
11
+ z: number;
12
+ };
13
+ }>[];
14
+ };
15
+ export interface RoomLabel {
16
+ /** 房屋 ID */
17
+ readonly id: string;
18
+ /** 房屋名 */
19
+ readonly name: string;
20
+ /** 走到对应 panoIndex 时 five 的水平角度 */
21
+ readonly longitude: number;
22
+ /** 点击标签会走到的 panoIndex */
23
+ readonly panoIndex: number;
24
+ /** 所处楼层 */
25
+ readonly floorIndex: number;
26
+ /** 引导标签的三维坐标,一般是房屋中心点 */
27
+ readonly position: {
28
+ x: number;
29
+ y: number;
30
+ z: number;
31
+ };
32
+ zIndex: number;
33
+ visible: boolean;
34
+ transform: string;
35
+ }
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
@@ -0,0 +1,3 @@
1
+ import { ModelRoomLabelPluginData, RoomLabel } from '../typings';
2
+ /** @description 下划线转驼峰 */
3
+ export declare function parseModelRoomLabelPluginData(data: ModelRoomLabelPluginData): RoomLabel[];
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.parseModelRoomLabelPluginData = parseModelRoomLabelPluginData;
7
+
8
+ /** @description 下划线转驼峰 */
9
+ function parseModelRoomLabelPluginData(data) {
10
+ return data.model_room_labels.map(function (_ref) {
11
+ var id = _ref.id,
12
+ pano_index = _ref.pano_index,
13
+ floor_index = _ref.floor_index,
14
+ name = _ref.name,
15
+ position = _ref.position,
16
+ longitude = _ref.longitude;
17
+ return {
18
+ id: id,
19
+ name: name,
20
+ position: position,
21
+ longitude: longitude,
22
+ panoIndex: pano_index,
23
+ floorIndex: floor_index,
24
+ zIndex: 0,
25
+ visible: false,
26
+ transform: ''
27
+ };
28
+ });
29
+ }
@@ -0,0 +1 @@
1
+ export declare function compare(c1: THREE.Color, c2: THREE.Color, threshold?: number): boolean;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.compare = compare;
7
+
8
+ // 判断两个颜色是否相似
9
+ function compare(c1, c2) {
10
+ var threshold = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0.025;
11
+ var r = Math.abs(c1.r - c2.r);
12
+ var g = Math.abs(c1.g - c2.g);
13
+ var b = Math.abs(c1.b - c2.b);
14
+ return r < threshold && g < threshold && b < threshold;
15
+ }
@@ -0,0 +1,7 @@
1
+ import * as THREE from 'three';
2
+ import { WorkObserver } from '@realsee/five';
3
+ export declare function createBox(textures: THREE.Texture[], observer: WorkObserver, _config?: {
4
+ opacity?: boolean;
5
+ maskColor?: THREE.Color;
6
+ thickness?: number;
7
+ }): THREE.Mesh<THREE.BoxBufferGeometry, THREE.ShaderMaterial[]>;
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+
3
+ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.createBox = createBox;
9
+
10
+ var THREE = _interopRequireWildcard(require("three"));
11
+
12
+ var _vertexShader = require("./vertexShader");
13
+
14
+ var _fragmentShader = require("./fragmentShader");
15
+
16
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
17
+
18
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
19
+
20
+ function createBox(textures, observer, _config) {
21
+ var config = Object.assign({
22
+ opacity: true,
23
+ thickness: 0.005,
24
+ maskColor: new THREE.Color(1, 0, 0)
25
+ }, _config || {});
26
+ var materials = textures.map(function (texture) {
27
+ return new THREE.ShaderMaterial({
28
+ uniforms: {
29
+ map: {
30
+ value: texture
31
+ },
32
+ enable: {
33
+ value: 1
34
+ },
35
+ opacity: {
36
+ value: config.opacity ? 0.0 : 1
37
+ },
38
+ selectedColor: {
39
+ value: new THREE.Color(0, 0, 0)
40
+ },
41
+ maskColor: {
42
+ value: config.maskColor
43
+ },
44
+ thickness: {
45
+ value: config.thickness
46
+ }
47
+ },
48
+ vertexShader: _vertexShader.vertexShader,
49
+ fragmentShader: _fragmentShader.fragmentShader,
50
+ transparent: true,
51
+ depthTest: false,
52
+ side: THREE.DoubleSide
53
+ });
54
+ });
55
+ var boxBufferGeometry = new THREE.BoxBufferGeometry(1, 1, 1);
56
+ var box = new THREE.Mesh(boxBufferGeometry, materials);
57
+ box.geometry.scale(-1, 1, 1);
58
+ box.position.set(observer.position.x, observer.position.y, observer.position.z);
59
+ box.quaternion.multiply(observer.quaternion);
60
+ return box;
61
+ }
@@ -0,0 +1,3 @@
1
+ import * as THREE from 'three';
2
+ import { WorkImage } from '@realsee/five';
3
+ export declare function createTextures(imgs: Omit<WorkImage, 'depth' | 'tiles'>): THREE.Texture[];
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+
3
+ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.createTextures = createTextures;
9
+
10
+ var THREE = _interopRequireWildcard(require("three"));
11
+
12
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
13
+
14
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
15
+
16
+ function createTextures(imgs) {
17
+ var loader = new THREE.ImageLoader();
18
+ var keys = ['up', 'down', 'right', 'left', 'front', 'back'];
19
+ var textures = keys.map(function (key) {
20
+ var url = imgs[key];
21
+ var texture = new THREE.Texture();
22
+ loader.load(url, function (image) {
23
+ texture.image = image;
24
+ texture.needsUpdate = true;
25
+ });
26
+ return texture;
27
+ });
28
+ return textures;
29
+ }
@@ -0,0 +1 @@
1
+ export declare const fragmentShader = "\nconst float PI = 3.1415926535897932384626433832795;\nuniform int enable;\nuniform sampler2D map;\nvarying vec2 vUv;\n\nuniform vec3 selectedColor;\nuniform vec3 maskColor;\nuniform float opacity;\nuniform float thickness;\n\n\n// \u5224\u65AD\u4E24\u4E2A\u989C\u8272\u662F\u5426\u76F8\u4F3C\nbool compare(vec3 c1, vec3 c2, float threshold) {\n // \u8272\u503C\u8BEF\u5DEE 0.05\n float diff = threshold;\n\n float r = abs(c1.x - c2.x);\n float g = abs(c1.y - c2.y);\n float b = abs(c1.z - c2.z);\n\n return r < diff && g < diff && b < diff;\n}\n\nvoid main(void) {\n vec3 color = texture2D(map, vUv).xyz;\n float alpha = texture2D(map, vUv).a;\n\n gl_FragColor = vec4(color, opacity);\n\n // \u5F00\u5173\n if (enable != 1) {\n gl_FragColor = vec4(color, opacity);\n return;\n }\n\n // \u9ED8\u8BA4\u503C\uFF1A\u672A\u63D0\u4F9B \u9009\u4E2D\u8272\u503C\n if (selectedColor.x == 0.0 && selectedColor.y == 0.0 && selectedColor.z == 0.0) {\n gl_FragColor = vec4(color, opacity);\n return;\n }\n\n bool similar = compare(color, selectedColor, 0.025);\n\n // \u4E0D\u76F8\u4F3C\n if (similar == false) {\n gl_FragColor = vec4(color, opacity);\n return;\n }\n\n // \u5BF9\u6BD4\u534A\u5F84\u5E45\u5EA6\n float offset1 = thickness;\n float offset2 = offset1 * sin(PI/4.0);\n\n vec3 top = texture2D(map, vec2(vUv.x, vUv.y + offset1)).xyz;\n vec3 right = texture2D(map, vec2(vUv.x + offset1, vUv.y)).xyz;\n vec3 bottom = texture2D(map, vec2(vUv.x, vUv.y - offset1)).xyz;\n vec3 left = texture2D(map, vec2(vUv.x - offset1, vUv.y)).xyz;\n \n vec3 topRight = texture2D(map, vec2(vUv.x + offset2, vUv.y + offset2)).xyz;\n vec3 rightBottom = texture2D(map, vec2(vUv.x + offset2, vUv.y - offset2)).xyz;\n vec3 bottomLeft = texture2D(map, vec2(vUv.x - offset2, vUv.y - offset2)).xyz;\n vec3 leftTop = texture2D(map, vec2(vUv.x - offset2, vUv.y + offset2)).xyz;\n\n float threshold = 0.0025;\n bool a1 = compare(color, top, threshold);\n bool b1 = compare(color, right, threshold);\n bool c1 = compare(color, bottom, threshold);\n bool d1 = compare(color, left, threshold);\n\n\n bool a2 = compare(color, topRight, threshold);\n bool b2 = compare(color, rightBottom, threshold);\n bool c2 = compare(color, bottomLeft, threshold);\n bool d2 = compare(color, leftTop, threshold);\n\n if (a1 == true && b1 == true && c1 == true && d1 == true && a2 == true && b2 == true && c2 == true && d2 == true) {\n gl_FragColor = vec4(color, opacity);\n return;\n }\n\n gl_FragColor = vec4(maskColor.x, maskColor.y, maskColor.z, 1.0);\n // gl_FragColor = vec4(154.0 / 255.0, 205.0 / 255.0, 50.0 / 255.0, 1.0) ;\n // gl_FragColor = vec4(139.0 / 255.0, 0.0 / 255.0, 0.0 / 255.0, 1.0) ;\n // gl_FragColor = vec4(255.0 / 255.0, 235.0 / 255.0, 59.0 / 255.0, 1.0) ;\n\n}\n";
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.fragmentShader = void 0;
7
+ var fragmentShader = "\nconst float PI = 3.1415926535897932384626433832795;\nuniform int enable;\nuniform sampler2D map;\nvarying vec2 vUv;\n\nuniform vec3 selectedColor;\nuniform vec3 maskColor;\nuniform float opacity;\nuniform float thickness;\n\n\n// \u5224\u65AD\u4E24\u4E2A\u989C\u8272\u662F\u5426\u76F8\u4F3C\nbool compare(vec3 c1, vec3 c2, float threshold) {\n // \u8272\u503C\u8BEF\u5DEE 0.05\n float diff = threshold;\n\n float r = abs(c1.x - c2.x);\n float g = abs(c1.y - c2.y);\n float b = abs(c1.z - c2.z);\n\n return r < diff && g < diff && b < diff;\n}\n\nvoid main(void) {\n vec3 color = texture2D(map, vUv).xyz;\n float alpha = texture2D(map, vUv).a;\n\n gl_FragColor = vec4(color, opacity);\n\n // \u5F00\u5173\n if (enable != 1) {\n gl_FragColor = vec4(color, opacity);\n return;\n }\n\n // \u9ED8\u8BA4\u503C\uFF1A\u672A\u63D0\u4F9B \u9009\u4E2D\u8272\u503C\n if (selectedColor.x == 0.0 && selectedColor.y == 0.0 && selectedColor.z == 0.0) {\n gl_FragColor = vec4(color, opacity);\n return;\n }\n\n bool similar = compare(color, selectedColor, 0.025);\n\n // \u4E0D\u76F8\u4F3C\n if (similar == false) {\n gl_FragColor = vec4(color, opacity);\n return;\n }\n\n // \u5BF9\u6BD4\u534A\u5F84\u5E45\u5EA6\n float offset1 = thickness;\n float offset2 = offset1 * sin(PI/4.0);\n\n vec3 top = texture2D(map, vec2(vUv.x, vUv.y + offset1)).xyz;\n vec3 right = texture2D(map, vec2(vUv.x + offset1, vUv.y)).xyz;\n vec3 bottom = texture2D(map, vec2(vUv.x, vUv.y - offset1)).xyz;\n vec3 left = texture2D(map, vec2(vUv.x - offset1, vUv.y)).xyz;\n \n vec3 topRight = texture2D(map, vec2(vUv.x + offset2, vUv.y + offset2)).xyz;\n vec3 rightBottom = texture2D(map, vec2(vUv.x + offset2, vUv.y - offset2)).xyz;\n vec3 bottomLeft = texture2D(map, vec2(vUv.x - offset2, vUv.y - offset2)).xyz;\n vec3 leftTop = texture2D(map, vec2(vUv.x - offset2, vUv.y + offset2)).xyz;\n\n float threshold = 0.0025;\n bool a1 = compare(color, top, threshold);\n bool b1 = compare(color, right, threshold);\n bool c1 = compare(color, bottom, threshold);\n bool d1 = compare(color, left, threshold);\n\n\n bool a2 = compare(color, topRight, threshold);\n bool b2 = compare(color, rightBottom, threshold);\n bool c2 = compare(color, bottomLeft, threshold);\n bool d2 = compare(color, leftTop, threshold);\n\n if (a1 == true && b1 == true && c1 == true && d1 == true && a2 == true && b2 == true && c2 == true && d2 == true) {\n gl_FragColor = vec4(color, opacity);\n return;\n }\n\n gl_FragColor = vec4(maskColor.x, maskColor.y, maskColor.z, 1.0);\n // gl_FragColor = vec4(154.0 / 255.0, 205.0 / 255.0, 50.0 / 255.0, 1.0) ;\n // gl_FragColor = vec4(139.0 / 255.0, 0.0 / 255.0, 0.0 / 255.0, 1.0) ;\n // gl_FragColor = vec4(255.0 / 255.0, 235.0 / 255.0, 59.0 / 255.0, 1.0) ;\n\n}\n";
8
+ exports.fragmentShader = fragmentShader;
@@ -0,0 +1,49 @@
1
+ import * as THREE from 'three';
2
+ import { FivePlugin, WorkImage } from '@realsee/five';
3
+ export interface PanoMaskObject {
4
+ color: {
5
+ r: number;
6
+ g: number;
7
+ b: number;
8
+ };
9
+ name?: string;
10
+ id: string;
11
+ }
12
+ export interface PanoMaskSelectorPluginData {
13
+ panoramaImgs: Omit<WorkImage, 'depth' | 'tiles'>[];
14
+ colorMaps: PanoMaskObject[];
15
+ config?: {
16
+ maskColor?: THREE.Color;
17
+ thickness?: number;
18
+ };
19
+ }
20
+ export interface PanoMaskSelectorPluginParameterType {
21
+ data?: PanoMaskSelectorPluginData;
22
+ }
23
+ export interface PanoMaskSelectorPluginReturnType {
24
+ /**
25
+ * 加载数据
26
+ */
27
+ load: (data: PanoMaskSelectorPluginData) => Promise<boolean>;
28
+ /**
29
+ * @returns 返回值为 选中的 物体信息;如果选中失败 则 返回 false。
30
+ */
31
+ select: (x: number, y: number) => Promise<false | PanoMaskObject>;
32
+ /**
33
+ * 擦除选中物体的 Mask(不可还原)。
34
+ */
35
+ erase: () => void;
36
+ /**
37
+ * 隐藏 选中物体的 Mask。
38
+ */
39
+ hide: () => void;
40
+ /**
41
+ * 展示 选中物体的 Mask。
42
+ */
43
+ show: () => void;
44
+ /**
45
+ * 销毁函数。
46
+ */
47
+ dispose: () => void;
48
+ }
49
+ export declare const PanoMaskSelectorPlugin: FivePlugin<PanoMaskSelectorPluginParameterType, PanoMaskSelectorPluginReturnType>;
@@ -0,0 +1,272 @@
1
+ "use strict";
2
+
3
+ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.PanoMaskSelectorPlugin = void 0;
9
+
10
+ var THREE = _interopRequireWildcard(require("three"));
11
+
12
+ var _five = require("@realsee/five");
13
+
14
+ var _createBox = require("./createBox");
15
+
16
+ var _createTextures = require("./createTextures");
17
+
18
+ var _compare = require("./compare");
19
+
20
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
21
+
22
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
23
+
24
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
25
+
26
+ function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
27
+
28
+ var PanoMaskSelectorPlugin = function PanoMaskSelectorPlugin(five) {
29
+ var parameters = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
30
+ var state = {
31
+ data: parameters.data
32
+ };
33
+
34
+ var dispose = function dispose() {
35
+ if (state.box) {
36
+ five.scene.remove(state.box);
37
+ }
38
+
39
+ five.off('panoArrived', wrapper);
40
+ five.off('modeChange', modeChangeListener);
41
+ };
42
+
43
+ var wrapper = function wrapper() {
44
+ var _state$data$config, _state$data$config2;
45
+
46
+ if (five.panoIndex === undefined) {
47
+ return;
48
+ }
49
+
50
+ if (five.panoIndex === state.currentLoadedIndex) {
51
+ return;
52
+ }
53
+
54
+ if (!state.data) {
55
+ return;
56
+ }
57
+
58
+ if (state.box) {
59
+ five.scene.remove(state.box);
60
+ }
61
+
62
+ var panoramaImgs = state.data.panoramaImgs[five.panoIndex];
63
+
64
+ if (!panoramaImgs) {
65
+ state.textures = undefined;
66
+ return false;
67
+ }
68
+
69
+ state.textures = (0, _createTextures.createTextures)(panoramaImgs);
70
+ state.box = (0, _createBox.createBox)(state.textures, five.work.observers[five.panoIndex], {
71
+ opacity: true,
72
+ maskColor: ((_state$data$config = state.data.config) === null || _state$data$config === void 0 ? void 0 : _state$data$config.maskColor) || new THREE.Color(1, 0, 0),
73
+ thickness: ((_state$data$config2 = state.data.config) === null || _state$data$config2 === void 0 ? void 0 : _state$data$config2.thickness) || 0.005
74
+ });
75
+ five.scene.add(state.box);
76
+ state.currentLoadedIndex = five.panoIndex;
77
+ return true;
78
+ };
79
+
80
+ var load = /*#__PURE__*/function () {
81
+ var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(data) {
82
+ return regeneratorRuntime.wrap(function _callee$(_context) {
83
+ while (1) {
84
+ switch (_context.prev = _context.next) {
85
+ case 0:
86
+ state.data = data;
87
+ wrapper();
88
+ return _context.abrupt("return", true);
89
+
90
+ case 3:
91
+ case "end":
92
+ return _context.stop();
93
+ }
94
+ }
95
+ }, _callee);
96
+ }));
97
+
98
+ return function load(_x2) {
99
+ return _ref.apply(this, arguments);
100
+ };
101
+ }();
102
+
103
+ var select = /*#__PURE__*/function () {
104
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(_x, _y) {
105
+ var _state$data;
106
+
107
+ var element, pixel, x, y, renderTarget, pickingBuffer, camera, renderer, newScence, observer, newBox, unit8ArrayGroup, i, selectedColor, colorMaps, object;
108
+ return regeneratorRuntime.wrap(function _callee2$(_context2) {
109
+ while (1) {
110
+ switch (_context2.prev = _context2.next) {
111
+ case 0:
112
+ if (state.textures) {
113
+ _context2.next = 2;
114
+ break;
115
+ }
116
+
117
+ return _context2.abrupt("return", false);
118
+
119
+ case 2:
120
+ if (state.box) {
121
+ _context2.next = 4;
122
+ break;
123
+ }
124
+
125
+ return _context2.abrupt("return", false);
126
+
127
+ case 4:
128
+ if (!(five.panoIndex === undefined)) {
129
+ _context2.next = 6;
130
+ break;
131
+ }
132
+
133
+ return _context2.abrupt("return", false);
134
+
135
+ case 6:
136
+ if (!(five.currentMode !== _five.Five.Mode.Panorama)) {
137
+ _context2.next = 8;
138
+ break;
139
+ }
140
+
141
+ return _context2.abrupt("return", false);
142
+
143
+ case 8:
144
+ if (five.renderer) {
145
+ _context2.next = 10;
146
+ break;
147
+ }
148
+
149
+ return _context2.abrupt("return", false);
150
+
151
+ case 10:
152
+ element = five.getElement();
153
+
154
+ if (element) {
155
+ _context2.next = 13;
156
+ break;
157
+ }
158
+
159
+ return _context2.abrupt("return", false);
160
+
161
+ case 13:
162
+ pixel = 1;
163
+ x = _x * five.renderer.getPixelRatio();
164
+ y = _y * five.renderer.getPixelRatio();
165
+ renderTarget = new THREE.WebGLRenderTarget(pixel, pixel);
166
+ pickingBuffer = new Uint8Array(4 * pixel * pixel);
167
+ camera = five.camera.clone();
168
+ renderer = five.renderer;
169
+ newScence = new THREE.Scene();
170
+ observer = five.work.observers[five.panoIndex];
171
+ newBox = (0, _createBox.createBox)(state.textures, observer, {
172
+ opacity: false
173
+ });
174
+ newScence.add(newBox);
175
+ camera.setViewOffset(element.width, element.height, x, y, pixel, pixel);
176
+ renderer.setRenderTarget(renderTarget);
177
+ renderer.render(newScence, camera);
178
+ pickingBuffer.fill(0);
179
+ renderer.readRenderTargetPixels(renderTarget, 0, 0, pixel, pixel, pickingBuffer);
180
+ camera.clearViewOffset();
181
+ renderer.setRenderTarget(null);
182
+ unit8ArrayGroup = [];
183
+
184
+ for (i = 0; i < pickingBuffer.length; i += 4 * pixel) {
185
+ unit8ArrayGroup.push(pickingBuffer.slice(i, i + 4 * pixel));
186
+ }
187
+
188
+ selectedColor = new THREE.Color(pickingBuffer[0] / 255, pickingBuffer[1] / 255, pickingBuffer[2] / 255);
189
+ colorMaps = ((_state$data = state.data) === null || _state$data === void 0 ? void 0 : _state$data.colorMaps) || [];
190
+ object = colorMaps.find(function (item) {
191
+ var objectColor = new THREE.Color(item.color.r, item.color.g, item.color.b);
192
+ return (0, _compare.compare)(objectColor, selectedColor);
193
+ });
194
+
195
+ if (object) {
196
+ _context2.next = 38;
197
+ break;
198
+ }
199
+
200
+ return _context2.abrupt("return", false);
201
+
202
+ case 38:
203
+ state.box.material.forEach(function (m) {
204
+ return m.uniforms.selectedColor.value = selectedColor;
205
+ });
206
+ five.needsRender = true;
207
+ return _context2.abrupt("return", object);
208
+
209
+ case 41:
210
+ case "end":
211
+ return _context2.stop();
212
+ }
213
+ }
214
+ }, _callee2);
215
+ }));
216
+
217
+ return function select(_x3, _x4) {
218
+ return _ref2.apply(this, arguments);
219
+ };
220
+ }();
221
+
222
+ var erase = function erase() {
223
+ if (!state.box) return;
224
+ state.box.material.forEach(function (m) {
225
+ return m.uniforms.selectedColor.value = new THREE.Color(0.0, 0.0, 0.0);
226
+ });
227
+ five.needsRender = true;
228
+ };
229
+
230
+ var hide = function hide() {
231
+ var _state$box, _state$box$material;
232
+
233
+ (_state$box = state.box) === null || _state$box === void 0 ? void 0 : (_state$box$material = _state$box.material) === null || _state$box$material === void 0 ? void 0 : _state$box$material.forEach(function (material) {
234
+ material.visible = false;
235
+ });
236
+ five.needsRender = true;
237
+ };
238
+
239
+ var show = function show() {
240
+ var _state$box2, _state$box2$material;
241
+
242
+ if (five.currentMode !== _five.Five.Mode.Panorama) {
243
+ return;
244
+ }
245
+
246
+ (_state$box2 = state.box) === null || _state$box2 === void 0 ? void 0 : (_state$box2$material = _state$box2.material) === null || _state$box2$material === void 0 ? void 0 : _state$box2$material.forEach(function (material) {
247
+ material.visible = true;
248
+ });
249
+ five.needsRender = true;
250
+ };
251
+
252
+ var modeChangeListener = function modeChangeListener(mode) {
253
+ if (mode !== _five.Five.Mode.Panorama) {
254
+ hide();
255
+ } else {
256
+ show();
257
+ }
258
+ };
259
+
260
+ five.on('panoArrived', wrapper);
261
+ five.on('modeChange', modeChangeListener);
262
+ return {
263
+ load: load,
264
+ select: select,
265
+ erase: erase,
266
+ dispose: dispose,
267
+ hide: hide,
268
+ show: show
269
+ };
270
+ };
271
+
272
+ exports.PanoMaskSelectorPlugin = PanoMaskSelectorPlugin;
@@ -0,0 +1 @@
1
+ export declare const vertexShader = "\nvarying vec2 vUv;\n\nvoid main() {\n vUv = uv;\n\n vec4 mvPosition = modelViewMatrix * vec4(position, 1.0);\n gl_Position = projectionMatrix * mvPosition;\n}\n\n";
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.vertexShader = void 0;
7
+ var vertexShader = "\nvarying vec2 vUv;\n\nvoid main() {\n vUv = uv;\n\n vec4 mvPosition = modelViewMatrix * vec4(position, 1.0);\n gl_Position = projectionMatrix * mvPosition;\n}\n\n";
8
+ exports.vertexShader = vertexShader;
@@ -1,13 +1,36 @@
1
- import { Five } from '@realsee/five';
2
- import { TreasureType } from './constants';
1
+ import * as THREE from 'three';
2
+ import { Five, Subscribe } from '@realsee/five';
3
+ import { TREASURE_TYPE } from './constants';
4
+ import { TreasureObject } from './TreasureObject';
5
+ export declare type TreasureObjectAssetMap = Map<string, Promise<THREE.Group>>;
6
+ /** 对每个宝箱实例的配置 */
7
+ export interface TreasurePluginItemConfigData {
8
+ scale?: number;
9
+ /** 宝箱模型地址 */
10
+ object_url?: string;
11
+ /** 宝箱盒子使用的贴图
12
+ * @description
13
+ * * 默认使用 object_url 文件中的盒子贴图
14
+ * * 如果传了 box_texture_url 会替换默认贴图
15
+ */
16
+ box_texture_url?: string;
17
+ /** 宝箱表情动画使用的贴图列表 */
18
+ face_anime_texture_urls?: string[];
19
+ }
3
20
  /** 宝箱数据 */
4
21
  export interface TreasurePluginItemData {
5
22
  /** 宝箱 ID */
6
23
  id: string;
7
- /** 宝箱位置:[x, y, z] */
8
- position: number[];
9
- /** 宝箱类型 */
10
- type: TreasureType;
24
+ /** 宝箱位置 */
25
+ position: {
26
+ x: number;
27
+ y: number;
28
+ z: number;
29
+ };
30
+ /** 使用预设的宝箱类型 */
31
+ type?: TREASURE_TYPE;
32
+ /** 如果不想使用预设的宝箱,可以传入自定义的宝箱配置 */
33
+ config?: TreasurePluginItemConfigData;
11
34
  }
12
35
  export interface TreasurePluginData {
13
36
  treasures: TreasurePluginItemData[];
@@ -15,18 +38,36 @@ export interface TreasurePluginData {
15
38
  export declare type TreasurePluginParameterType = undefined;
16
39
  export declare type TreasurePluginEvents = {
17
40
  /** 点击宝箱事件
18
- * @param id: 宝箱 ID
41
+ * @param params.id: 宝箱 ID
42
+ */
43
+ tap: (params: {
44
+ id: string;
45
+ }) => void;
46
+ /** 宝箱打开的动画执行完毕
47
+ * @param params.id: 宝箱 ID
19
48
  */
20
- tap: (id: string) => void;
49
+ openAnimationEnded: (params: {
50
+ id: string;
51
+ }) => void;
21
52
  };
22
53
  export declare class TreasurePluginController {
54
+ readonly hooks: Subscribe<TreasurePluginEvents>;
55
+ readonly treasures: TreasureObject[];
23
56
  private five;
24
57
  private selfGroup;
25
- private hooks;
26
- private fbxLoader;
27
- private treasures;
58
+ private textureLoader;
59
+ private modelLoader;
28
60
  constructor(five: Five);
29
- load(data: TreasurePluginData): Promise<boolean>;
61
+ load(data: TreasurePluginData, options?: {
62
+ appendTreasuresAfterLoaded?: boolean;
63
+ }): Promise<TreasureObject[]>;
64
+ dispose: () => void;
65
+ appendChild(child: TreasureObject): TreasurePluginController;
66
+ appendChildByID(childID: string): TreasurePluginController;
67
+ getTreasureByID(id: string): TreasureObject | undefined;
30
68
  removeTreasureByID(id: string): boolean;
31
69
  private onTreasureClick;
70
+ private getTreasureObjectParams;
71
+ private onTreasureOpenAnimationEnded;
72
+ private getConfig;
32
73
  }