@realsee/dnalogel 0.1.5 → 0.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/GLTFView/index.d.ts +72 -0
- package/components/GLTFView/index.js +149 -0
- package/libs/gltf-viewer/Subscribe.d.ts +76 -0
- package/libs/gltf-viewer/Subscribe.js +231 -0
- package/libs/gltf-viewer/coordsMoveByOffset.d.ts +13 -0
- package/libs/gltf-viewer/coordsMoveByOffset.js +22 -0
- package/libs/gltf-viewer/coordsToDirection.d.ts +5 -0
- package/{components/PBRView/index.js → libs/gltf-viewer/coordsToDirection.js} +14 -18
- package/libs/gltf-viewer/formatRad.d.ts +1 -0
- package/libs/gltf-viewer/formatRad.js +13 -0
- package/libs/gltf-viewer/getFrameTime.d.ts +1 -0
- package/libs/gltf-viewer/getFrameTime.js +28 -0
- package/libs/gltf-viewer/index.d.ts +55 -0
- package/libs/gltf-viewer/index.js +650 -0
- package/libs/gltf-viewer/mouseWheel.d.ts +2 -0
- package/libs/gltf-viewer/mouseWheel.js +59 -0
- package/libs/gltf-viewer/requestAnimationFrame.d.ts +1 -0
- package/libs/gltf-viewer/requestAnimationFrame.js +18 -0
- package/libs/gltf-viewer/requestAnimationFrameInterval.d.ts +1 -0
- package/libs/gltf-viewer/requestAnimationFrameInterval.js +31 -0
- package/libs/gltf-viewer/uuid.d.ts +4 -0
- package/libs/gltf-viewer/uuid.js +28 -0
- package/package.json +3 -2
- package/plugins/ModelEntryDoorGuidePlugin/index.d.ts +2 -2
- package/plugins/ModelEntryDoorGuidePlugin/index.js +16 -13
- package/plugins/PanoTVVideoPlugin/index.d.ts +2 -0
- package/plugins/PanoTVVideoPlugin/index.js +20 -14
- package/components/PBRView/index.d.ts +0 -14
|
@@ -0,0 +1,59 @@
|
|
|
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.addMouseWheel = addMouseWheel;
|
|
9
|
+
exports.removeMouseWheel = removeMouseWheel;
|
|
10
|
+
// 兼容 滚轮事件
|
|
11
|
+
var _document = document;
|
|
12
|
+
var _window = window;
|
|
13
|
+
var eventName = _document.mozFullScreen ? 'DOMMouseScroll' : 'mousewheel';
|
|
14
|
+
var isW3cEvent = !!window.addEventListener;
|
|
15
|
+
var isIEEvent = !!_window.attachEvent;
|
|
16
|
+
|
|
17
|
+
function fnWrapper(element, fn) {
|
|
18
|
+
return fn.__mouseWheelWrapper = function (event) {
|
|
19
|
+
event = event || window.event;
|
|
20
|
+
|
|
21
|
+
if (isW3cEvent) {
|
|
22
|
+
event.preventDefault();
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if (isIEEvent) {
|
|
26
|
+
event.returnValue = false;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if (eventName == 'DOMMouseScroll' || eventName == 'mousewheel') {
|
|
30
|
+
event.delta = event.wheelDelta ? event.wheelDelta / 120 : -(event.detail || 0) / 3;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
fn.call(element, event);
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function addMouseWheel(element, fn) {
|
|
38
|
+
var __mouseWheelWrapper = fnWrapper(element, fn);
|
|
39
|
+
|
|
40
|
+
if (isW3cEvent) {
|
|
41
|
+
element.addEventListener(eventName, __mouseWheelWrapper, false);
|
|
42
|
+
} else if (isIEEvent) {
|
|
43
|
+
var _element = element;
|
|
44
|
+
|
|
45
|
+
_element.attachEvent('on' + eventName, __mouseWheelWrapper);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function removeMouseWheel(element, fn) {
|
|
50
|
+
if (isW3cEvent) {
|
|
51
|
+
element.removeEventListener(eventName, fn.__mouseWheelWrapper, false);
|
|
52
|
+
} else if (isIEEvent) {
|
|
53
|
+
var _element = element;
|
|
54
|
+
|
|
55
|
+
_element.detachEvent('on' + eventName, fn.__mouseWheelWrapper);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
delete fn.__mouseWheelWrapper;
|
|
59
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const requestAnimationFrame: ((callback: FrameRequestCallback) => number) & typeof globalThis.requestAnimationFrame;
|
|
@@ -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,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.
|
|
3
|
+
"version": "0.1.7",
|
|
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
|
|
5
|
-
rad
|
|
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$
|
|
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
|
-
|
|
72
|
-
|
|
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
|
|
79
|
-
modelPosition = (0, _transformPositionToVector["default"])(
|
|
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 =
|
|
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
|
|
92
|
-
_context.next =
|
|
93
|
+
case 9:
|
|
94
|
+
_context.next = 11;
|
|
93
95
|
return new _FBXLoader.FBXLoader().loadAsync(fbxUrl);
|
|
94
96
|
|
|
95
|
-
case
|
|
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 =
|
|
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
|
|
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
|
|
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;
|
|
@@ -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
|
|
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
|
|
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 =
|
|
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
|
-
|
|
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 (
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
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
|
|
|
@@ -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;
|