@realsee/dnalogel 0.1.5 → 0.1.7-alpha.1

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 (34) hide show
  1. package/components/GLTFView/index.d.ts +94 -0
  2. package/components/GLTFView/index.js +172 -0
  3. package/libs/gltf-viewer/Subscribe.d.ts +76 -0
  4. package/libs/gltf-viewer/Subscribe.js +231 -0
  5. package/libs/gltf-viewer/coordsMoveByOffset.d.ts +13 -0
  6. package/libs/gltf-viewer/coordsMoveByOffset.js +22 -0
  7. package/libs/gltf-viewer/coordsToDirection.d.ts +5 -0
  8. package/{components/PBRView/index.js → libs/gltf-viewer/coordsToDirection.js} +14 -18
  9. package/libs/gltf-viewer/formatRad.d.ts +1 -0
  10. package/libs/gltf-viewer/formatRad.js +13 -0
  11. package/libs/gltf-viewer/getFrameTime.d.ts +1 -0
  12. package/libs/gltf-viewer/getFrameTime.js +28 -0
  13. package/libs/gltf-viewer/index.d.ts +57 -0
  14. package/libs/gltf-viewer/index.js +648 -0
  15. package/libs/gltf-viewer/mouseWheel.d.ts +2 -0
  16. package/libs/gltf-viewer/mouseWheel.js +59 -0
  17. package/libs/gltf-viewer/requestAnimationFrame.d.ts +1 -0
  18. package/libs/gltf-viewer/requestAnimationFrame.js +18 -0
  19. package/libs/gltf-viewer/requestAnimationFrameInterval.d.ts +1 -0
  20. package/libs/gltf-viewer/requestAnimationFrameInterval.js +31 -0
  21. package/libs/gltf-viewer/uuid.d.ts +4 -0
  22. package/libs/gltf-viewer/uuid.js +28 -0
  23. package/package.json +3 -2
  24. package/plugins/ModelEntryDoorGuidePlugin/index.d.ts +2 -2
  25. package/plugins/ModelEntryDoorGuidePlugin/index.js +16 -13
  26. package/plugins/PanoMaskSelectorPlugin/createBox.js +3 -0
  27. package/plugins/PanoMaskSelectorPlugin/fragmentShader.d.ts +1 -1
  28. package/plugins/PanoMaskSelectorPlugin/fragmentShader.js +1 -1
  29. package/plugins/PanoMaskSelectorPlugin/index.js +3 -1
  30. package/plugins/PanoTVVideoPlugin/index.d.ts +2 -0
  31. package/plugins/PanoTVVideoPlugin/index.js +20 -14
  32. package/typedoc/libs.d.ts +1 -0
  33. package/typedoc/libs.js +7 -0
  34. package/components/PBRView/index.d.ts +0 -14
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+
3
+ require("core-js/modules/es.object.define-property.js");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.requestAnimationFrame = void 0;
9
+
10
+ require("core-js/modules/web.timers.js");
11
+
12
+ var _window = window;
13
+
14
+ var requestAnimationFrame = window.requestAnimationFrame || _window.mozRequestAnimationFrame || _window.webkitRequestAnimationFrame || _window.msRequestAnimationFrame || function (fn) {
15
+ return setTimeout(fn, 16);
16
+ };
17
+
18
+ exports.requestAnimationFrame = requestAnimationFrame;
@@ -0,0 +1 @@
1
+ export declare function requestAnimationFrameInterval(fn: any, context?: any, args?: any[]): () => void;
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+
3
+ require("core-js/modules/es.object.define-property.js");
4
+
5
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
6
+
7
+ Object.defineProperty(exports, "__esModule", {
8
+ value: true
9
+ });
10
+ exports.requestAnimationFrameInterval = requestAnimationFrameInterval;
11
+
12
+ require("core-js/modules/es.array.concat.js");
13
+
14
+ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
15
+
16
+ var _requestAnimationFrame = require("./requestAnimationFrame");
17
+
18
+ function requestAnimationFrameInterval(fn, context) {
19
+ var args = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
20
+ var stoped = false;
21
+
22
+ var _loop = function loop(time) {
23
+ if (fn) fn.call.apply(fn, [context, time].concat((0, _toConsumableArray2["default"])(args)));
24
+ if (!stoped && _loop) (0, _requestAnimationFrame.requestAnimationFrame)(_loop);
25
+ };
26
+
27
+ (0, _requestAnimationFrame.requestAnimationFrame)(_loop);
28
+ return function () {
29
+ _loop = null, stoped = true;
30
+ };
31
+ }
@@ -0,0 +1,4 @@
1
+ /**
2
+ * 随机生成一个uuid值
3
+ */
4
+ export default function uuid(): string;
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+
3
+ require("core-js/modules/es.object.define-property.js");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports["default"] = uuid;
9
+
10
+ require("core-js/modules/es.date.to-string.js");
11
+
12
+ require("core-js/modules/es.object.to-string.js");
13
+
14
+ require("core-js/modules/es.regexp.to-string.js");
15
+
16
+ // uuid
17
+ function S4() {
18
+ return ((1 + Math.random()) * 0x10000 | 0).toString(16).substring(1);
19
+ }
20
+ /**
21
+ * 随机生成一个uuid值
22
+ */
23
+
24
+
25
+ function uuid() {
26
+ // then to call it, plus stitch in '4' in the third group
27
+ return (S4() + S4() + '-' + S4() + '-4' + S4().substr(0, 3) + '-' + S4() + '-' + S4() + S4() + S4()).toLowerCase();
28
+ }
package/package.json CHANGED
@@ -1,12 +1,13 @@
1
1
  {
2
2
  "name": "@realsee/dnalogel",
3
- "version": "0.1.5",
3
+ "version": "0.1.7-alpha.1",
4
4
  "description": "如视前端 Componets、Plugins 兼部分 SDKs \"Dnalogel\" 库。",
5
5
  "author": "BEIKE REALSEE TECHNOLOGY (HK) LIMITED",
6
6
  "peerDependencies": {
7
7
  "@realsee/five": "^5.0.0-alpha.52",
8
8
  "@tweenjs/tween.js": "^18.6.4",
9
9
  "@types/styled-jsx": "^2.2.9",
10
+ "hammerjs": "^2.0.8",
10
11
  "react": "^16.14.0",
11
12
  "styled-jsx": "^3.4.6",
12
13
  "three": "0.117.1",
@@ -19,4 +20,4 @@
19
20
  "dependencies": {
20
21
  "core-js": "^3.20.0"
21
22
  }
22
- }
23
+ }
@@ -1,8 +1,8 @@
1
1
  import type { FivePlugin } from '@realsee/five';
2
2
  import { Vector3Position } from '../../typings/math.type';
3
3
  export interface ModelEntryDoorGuidePluginData {
4
- position: Vector3Position;
5
- rad: number;
4
+ position?: Vector3Position;
5
+ rad?: number;
6
6
  fbx_url?: string;
7
7
  }
8
8
  export declare type ModelEntryDoorGuidePluginParameterType = {
@@ -61,38 +61,40 @@ var ModelEntryDoorGuidePlugin = function ModelEntryDoorGuidePlugin(five, params)
61
61
 
62
62
  var load = /*#__PURE__*/function () {
63
63
  var _ref = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(data) {
64
- var _data$position, _data$position2, _data$rad, _data$fbx_url, _object$children, _object$children$, _object$children$$chi, _object$children$$chi2;
64
+ var _data$position, _data$rad, _data$fbx_url, _object$children, _object$children$, _object$children$$chi, _object$children$$chi2;
65
65
 
66
- var modelPosition, rad, fbxUrl, object, textMesh;
66
+ var position, modelPosition, rad, fbxUrl, object, textMesh;
67
67
  return _regenerator["default"].wrap(function _callee$(_context) {
68
68
  while (1) {
69
69
  switch (_context.prev = _context.next) {
70
70
  case 0:
71
- if (!(((_data$position = data === null || data === void 0 ? void 0 : data.position) !== null && _data$position !== void 0 ? _data$position : defaultModelPosition) === undefined)) {
72
- _context.next = 2;
71
+ position = (_data$position = data === null || data === void 0 ? void 0 : data.position) !== null && _data$position !== void 0 ? _data$position : defaultModelPosition;
72
+
73
+ if (position) {
74
+ _context.next = 3;
73
75
  break;
74
76
  }
75
77
 
76
78
  return _context.abrupt("return", Promise.reject("ModelEntryDoorGuidePlugin.load(): position is undefined"));
77
79
 
78
- case 2:
79
- modelPosition = (0, _transformPositionToVector["default"])((_data$position2 = data === null || data === void 0 ? void 0 : data.position) !== null && _data$position2 !== void 0 ? _data$position2 : defaultModelPosition);
80
+ case 3:
81
+ modelPosition = (0, _transformPositionToVector["default"])(position);
80
82
  rad = (_data$rad = data === null || data === void 0 ? void 0 : data.rad) !== null && _data$rad !== void 0 ? _data$rad : defaultRad;
81
83
  fbxUrl = (_data$fbx_url = data === null || data === void 0 ? void 0 : data.fbx_url) !== null && _data$fbx_url !== void 0 ? _data$fbx_url : defaultFbxUrl;
82
84
  state.rad = rad;
83
85
 
84
86
  if (!(rad === undefined)) {
85
- _context.next = 8;
87
+ _context.next = 9;
86
88
  break;
87
89
  }
88
90
 
89
91
  return _context.abrupt("return", Promise.reject("ModelEntryDoorGuidePlugin.load(): rad is ".concat(rad)));
90
92
 
91
- case 8:
92
- _context.next = 10;
93
+ case 9:
94
+ _context.next = 11;
93
95
  return new _FBXLoader.FBXLoader().loadAsync(fbxUrl);
94
96
 
95
- case 10:
97
+ case 11:
96
98
  object = _context.sent;
97
99
  // 设置位置
98
100
  object.position.copy(modelPosition);
@@ -105,13 +107,13 @@ var ModelEntryDoorGuidePlugin = function ModelEntryDoorGuidePlugin(five, params)
105
107
  textMesh = (_object$children = object.children) === null || _object$children === void 0 ? void 0 : (_object$children$ = _object$children[0]) === null || _object$children$ === void 0 ? void 0 : (_object$children$$chi = _object$children$.children) === null || _object$children$$chi === void 0 ? void 0 : (_object$children$$chi2 = _object$children$$chi[3]) === null || _object$children$$chi2 === void 0 ? void 0 : _object$children$$chi2.clone();
106
108
 
107
109
  if (textMesh) {
108
- _context.next = 18;
110
+ _context.next = 19;
109
111
  break;
110
112
  }
111
113
 
112
114
  return _context.abrupt("return", Promise.reject("ModelEntryDoorGuidePlugin.load(): textMesh is ".concat(textMesh)));
113
115
 
114
- case 18:
116
+ case 19:
115
117
  textMesh.material = new THREE.MeshBasicMaterial({
116
118
  transparent: true,
117
119
  map: (0, _createCanvasTextTexture["default"])('入户门')
@@ -121,7 +123,7 @@ var ModelEntryDoorGuidePlugin = function ModelEntryDoorGuidePlugin(five, params)
121
123
  state.object = object;
122
124
  return _context.abrupt("return", true);
123
125
 
124
- case 23:
126
+ case 24:
125
127
  case "end":
126
128
  return _context.stop();
127
129
  }
@@ -221,6 +223,7 @@ var ModelEntryDoorGuidePlugin = function ModelEntryDoorGuidePlugin(five, params)
221
223
  var enable = function enable(config) {
222
224
  if (state.enabled) return true;
223
225
  state.enabled = true;
226
+ modeChangeHandler(five.currentMode);
224
227
  five.on('modeChange', modeChangeHandler);
225
228
  show(config);
226
229
  return true;
@@ -25,6 +25,8 @@ require("core-js/modules/es.object.assign.js");
25
25
 
26
26
  require("core-js/modules/es.array.map.js");
27
27
 
28
+ require("core-js/modules/es.function.name.js");
29
+
28
30
  var THREE = _interopRequireWildcard(require("three"));
29
31
 
30
32
  var _vertexShader = require("./vertexShader");
@@ -75,5 +77,6 @@ function createBox(textures, observer, _config) {
75
77
  box.geometry.scale(-1, 1, 1);
76
78
  box.position.set(observer.position.x, observer.position.y, observer.position.z);
77
79
  box.quaternion.multiply(observer.quaternion);
80
+ box.name = 'PanoMaskSelectorPlugin';
78
81
  return box;
79
82
  }
@@ -1 +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";
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, 1.0);\n return;\n // gl_FragColor = vec4(color, opacity);\n\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";
@@ -6,5 +6,5 @@ Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
8
  exports.fragmentShader = void 0;
9
- 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";
9
+ 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, 1.0);\n return;\n // gl_FragColor = vec4(color, opacity);\n\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";
10
10
  exports.fragmentShader = fragmentShader;
@@ -133,9 +133,11 @@ var PanoMaskSelectorPlugin = function PanoMaskSelectorPlugin(five) {
133
133
 
134
134
  if (state.box) {
135
135
  five.scene.remove(state.box);
136
+ state.box = undefined;
136
137
  }
137
138
 
138
139
  var panoramaImgs = state.data.panoramaImgs[five.panoIndex];
140
+ state.currentLoadedIndex = five.panoIndex;
139
141
 
140
142
  if (!panoramaImgs) {
141
143
  state.textures = undefined;
@@ -149,7 +151,7 @@ var PanoMaskSelectorPlugin = function PanoMaskSelectorPlugin(five) {
149
151
  thickness: ((_state$data$config2 = state.data.config) === null || _state$data$config2 === void 0 ? void 0 : _state$data$config2.thickness) || 0.005
150
152
  });
151
153
  five.scene.add(state.box);
152
- state.currentLoadedIndex = five.panoIndex;
154
+ five.needsRender = true;
153
155
  return true;
154
156
  };
155
157
 
@@ -1,3 +1,4 @@
1
+ import * as THREE from 'three';
1
2
  import { FivePlugin } from '@realsee/five';
2
3
  export declare type PanoTVVideoPluginPoints = Record<string, {
3
4
  position: {
@@ -19,6 +20,7 @@ export interface PanoTVVideoPluginExportType {
19
20
  enable: () => void;
20
21
  disable: () => void;
21
22
  load: (data: PanoTVVideoPluginData, videoElement?: HTMLVideoElement) => void;
23
+ getVideoTexture: () => THREE.VideoTexture | undefined;
22
24
  }
23
25
  export declare const PanoTVVideoPlugin: FivePlugin<PanoTVVideoPluginParameterType, PanoTVVideoPluginExportType>;
24
26
  export default PanoTVVideoPlugin;
@@ -115,7 +115,7 @@ var PanoTVVideoPlugin = function PanoTVVideoPlugin(five, parameters) {
115
115
  };
116
116
  var videoMeshes = [];
117
117
 
118
- var getImageTexture = function getImageTexture(source) {
118
+ var createImageTexture = function createImageTexture(source) {
119
119
  var texture = new THREE.TextureLoader().load(source);
120
120
  texture.minFilter = THREE.LinearFilter;
121
121
  texture.magFilter = THREE.LinearFilter;
@@ -123,7 +123,7 @@ var PanoTVVideoPlugin = function PanoTVVideoPlugin(five, parameters) {
123
123
  return texture;
124
124
  };
125
125
 
126
- var getVideoTexture = function getVideoTexture(source, video) {
126
+ var createVideoTexture = function createVideoTexture(source, video) {
127
127
  return new Promise(function (resolve, reject) {
128
128
  var xhr = new XMLHttpRequest();
129
129
 
@@ -161,6 +161,10 @@ var PanoTVVideoPlugin = function PanoTVVideoPlugin(five, parameters) {
161
161
  });
162
162
  };
163
163
 
164
+ var getVideoTexture = function getVideoTexture() {
165
+ return state.videoTexture;
166
+ };
167
+
164
168
  var getPoints = function getPoints(panoIndex) {
165
169
  if (!state.rectPoints) return [];
166
170
  var rectPoints_ = state.rectPoints[panoIndex];
@@ -274,14 +278,14 @@ var PanoTVVideoPlugin = function PanoTVVideoPlugin(five, parameters) {
274
278
  points = data.points;
275
279
  state.videoSource = video_src;
276
280
  state.rectPoints = points;
277
- state.imageTexture = getImageTexture(video_poster_src);
281
+ state.imageTexture = createImageTexture(video_poster_src);
278
282
  if (videoElement) state.videoElement = videoElement;
279
283
  var panoIndex = five.state.panoIndex;
280
284
  var meshes = videoMeshes[panoIndex] = createPanoVideoMeshes(panoIndex);
281
285
  meshes.forEach(function (mesh) {
282
286
  return five.scene.add(mesh);
283
287
  });
284
- getVideoTexture(state.videoSource, state.videoElement).then(function (videoTexture_) {
288
+ createVideoTexture(state.videoSource, state.videoElement).then(function (videoTexture_) {
285
289
  if (videoTexture_.videoSource !== state.videoSource) return;
286
290
  state.videoTexture = videoTexture_;
287
291
 
@@ -370,15 +374,16 @@ var PanoTVVideoPlugin = function PanoTVVideoPlugin(five, parameters) {
370
374
  five.on('modeChange', function (mode) {
371
375
  if (!state.enabled) return;
372
376
  if (mode === _five.Five.Mode.Panorama) return;
373
- videoMeshes.forEach(function () {// if (meshes) {
374
- // meshes.forEach((mesh) => {
375
- // mesh.geometry.dispose()
376
- // mesh.material.dispose()
377
- // five.scene.remove(mesh)
378
- // })
379
- // videoMeshes[index] = undefined
380
- // if (state.videoTexture) state.videoTexture.image.pause()
381
- // }
377
+ videoMeshes.forEach(function (meshes, index) {
378
+ if (meshes) {
379
+ meshes.forEach(function (mesh) {
380
+ mesh.geometry.dispose();
381
+ mesh.material.dispose();
382
+ five.scene.remove(mesh);
383
+ });
384
+ videoMeshes[index] = undefined;
385
+ if (state.videoTexture) state.videoTexture.image.pause();
386
+ }
382
387
  });
383
388
  });
384
389
  five.on('wantsTapGesture', function (raycaster) {
@@ -418,7 +423,8 @@ var PanoTVVideoPlugin = function PanoTVVideoPlugin(five, parameters) {
418
423
  return {
419
424
  enable: enable,
420
425
  disable: disable,
421
- load: load
426
+ load: load,
427
+ getVideoTexture: getVideoTexture
422
428
  };
423
429
  };
424
430
 
@@ -0,0 +1 @@
1
+ export type { GLTFViewerSize, GLTFViewerConfig, GLTFViewerState, GLTFViewerEventMap, GLTFViewer, } from '../libs/gltf-viewer';
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+
3
+ require("core-js/modules/es.object.define-property.js");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
@@ -1,14 +0,0 @@
1
- import * as React from 'react';
2
- export interface PBRViewPropTypes {
3
- hidden?: boolean;
4
- className?: string;
5
- }
6
- /**
7
- * 查看 **PBR**模型
8
- *
9
- * @TODO 待排期
10
- *
11
- * > RD 小哥哥 正在 加班研发中 ...
12
- */
13
- declare const PBRView: React.FC<PBRViewPropTypes>;
14
- export default PBRView;