@realsee/dnalogel 0.1.2 → 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/ARVideoFigure/ARVideoFigureMesh.js +56 -32
- package/components/ARVideoFigure/ARVideoFigureScene.js +30 -19
- package/components/ARVideoFigure/ImgBgTransparent.js +22 -6
- package/components/ARVideoFigure/ImgBgTransparentMesh.js +40 -30
- package/components/ARVideoFigure/fragmentShader.js +2 -0
- package/components/ARVideoFigure/index.js +22 -6
- package/components/ARVideoFigure/vertexShader.js +2 -0
- package/components/GLTFView/index.d.ts +72 -0
- package/components/GLTFView/index.js +149 -0
- package/components/GlassFilters/index.js +25 -1
- package/components/ModelView/ModelViewController.js +39 -29
- package/components/ModelView/index.js +4 -2
- package/components/PaintBrush/index.js +15 -1
- package/components/PanoTag/index.js +2 -0
- package/data/1aGKl9JmrlXMXx8d.js +2 -0
- package/data/54djM0oR6ky3Ey8e.d.ts +55 -0
- package/data/54djM0oR6ky3Ey8e.js +350 -0
- package/data/6gyq3v1verxD7JO1.js +2 -0
- package/data/8054djM0oR6ky3Ey8e.d.ts +55 -0
- package/data/8054djM0oR6ky3Ey8e.js +350 -0
- package/data/KpokNd82rwjhackhQTBEoYKHg8zGbPXe.js +2 -0
- package/data/PrXel3aqGbp34JQn.js +2 -0
- package/data/XJ6NMLWnkAY3Rdx8.d.ts +843 -0
- package/data/XJ6NMLWnkAY3Rdx8.js +7989 -0
- package/data/YdoNP9K4rwQDwjJr.js +2 -0
- package/data/ZLvK29zj4L29Jowd.d.ts +55 -0
- package/data/ZLvK29zj4L29Jowd.js +372 -0
- package/data/auto3d-njL5J99VwCmnjtQElOmXQr.js +2 -0
- package/data/extrude-walls/ZLvK29zj4L29Jowd.d.ts +5 -0
- package/data/extrude-walls/ZLvK29zj4L29Jowd.js +14 -0
- package/data/extrude-walls/lo024DEgzanMj5BE.d.ts +5 -0
- package/data/extrude-walls/lo024DEgzanMj5BE.js +14 -0
- package/data/jd6oMOzPxnQ3BvxY_B7yw51J9rXlhYhjhGTOgRVqu6WeEqjNX.d.ts +85 -0
- package/data/jd6oMOzPxnQ3BvxY_B7yw51J9rXlhYhjhGTOgRVqu6WeEqjNX.js +511 -0
- package/data/lo024DEgzanMj5BE.d.ts +55 -0
- package/data/lo024DEgzanMj5BE.js +966 -0
- package/data/oPzy3ApbjjpD8YdR.js +2 -0
- package/data/qjAxMG4XbPn96wKG.js +2 -0
- package/data/rXel3aPQRRBD4JQn.js +2 -0
- package/data/vLykj3NWrllMrG06.d.ts +2 -0
- package/data/vLykj3NWrllMrG06.js +199 -2
- package/data/wz0QV9KA4ugyo9ME.js +2 -0
- package/data/zxMawr9raSg8LYjG.d.ts +53 -0
- package/data/zxMawr9raSg8LYjG.js +590 -0
- package/examples/FiveStateController/index.js +9 -15
- package/examples/VRHouse/Mobile.js +15 -1
- package/examples/VRHouse/PC.js +15 -1
- package/examples/VRHouse/index.js +15 -1
- package/index.js +4 -2
- 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} +29 -19
- 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 +8 -4
- package/plugins/AutoPreloadPlugin/index.d.ts +23 -0
- package/plugins/AutoPreloadPlugin/index.js +111 -0
- package/plugins/CSS3DRenderPlugin/components/Marker/index.js +24 -16
- package/plugins/CSS3DRenderPlugin/index.d.ts +3 -2
- package/plugins/CSS3DRenderPlugin/index.js +79 -46
- package/plugins/CameraMovementPlugin/index.js +33 -9
- package/plugins/CameraMovementPlugin/typing.js +2 -0
- package/plugins/ModelChassisCompassPlugin/index.d.ts +7 -3
- package/plugins/ModelChassisCompassPlugin/index.js +34 -33
- package/plugins/ModelEntryDoorGuidePlugin/index.d.ts +13 -1
- package/plugins/ModelEntryDoorGuidePlugin/index.js +233 -2
- package/plugins/ModelExtrudeWallsPlugin/index.d.ts +16 -0
- package/plugins/ModelExtrudeWallsPlugin/index.js +252 -0
- package/plugins/ModelRoomLabelPlugin/Controller.d.ts +35 -0
- package/plugins/ModelRoomLabelPlugin/Controller.js +153 -0
- package/plugins/ModelRoomLabelPlugin/RoomLabelItem.d.ts +8 -0
- package/plugins/ModelRoomLabelPlugin/RoomLabelItem.js +66 -0
- package/plugins/ModelRoomLabelPlugin/RoomLabelItems.d.ts +7 -0
- package/plugins/ModelRoomLabelPlugin/RoomLabelItems.js +159 -0
- package/plugins/ModelRoomLabelPlugin/index.d.ts +8 -0
- package/plugins/ModelRoomLabelPlugin/index.js +18 -0
- package/plugins/ModelRoomLabelPlugin/typings.d.ts +35 -0
- package/plugins/ModelRoomLabelPlugin/typings.js +7 -0
- package/plugins/ModelRoomLabelPlugin/utils/parseData.d.ts +3 -0
- package/plugins/ModelRoomLabelPlugin/utils/parseData.js +35 -0
- package/plugins/ModelTVVideoPlugin/index.js +100 -16
- package/plugins/ModelViewPlugin/index.js +25 -1
- package/plugins/PanoCursorRaycasterPlugin/components/MovePointTowardsCamera.js +29 -25
- package/plugins/PanoCursorRaycasterPlugin/components/PointAxesHelper.js +15 -1
- package/plugins/PanoCursorRaycasterPlugin/index.js +13 -6
- package/plugins/PanoCursorRaycasterPlugin/utils/addLineToFive.js +4 -2
- package/plugins/PanoCursorRaycasterPlugin/utils/createLine.js +15 -1
- package/plugins/PanoDoorLabelPlugin/index.js +2 -0
- package/plugins/PanoIRobotPlugin/index.js +2 -0
- package/plugins/PanoMaskSelectorPlugin/compare.d.ts +1 -0
- package/plugins/PanoMaskSelectorPlugin/compare.js +17 -0
- package/plugins/PanoMaskSelectorPlugin/createBox.d.ts +7 -0
- package/plugins/PanoMaskSelectorPlugin/createBox.js +79 -0
- package/plugins/PanoMaskSelectorPlugin/createTextures.d.ts +3 -0
- package/plugins/PanoMaskSelectorPlugin/createTextures.js +45 -0
- package/plugins/PanoMaskSelectorPlugin/fragmentShader.d.ts +1 -0
- package/plugins/PanoMaskSelectorPlugin/fragmentShader.js +10 -0
- package/plugins/PanoMaskSelectorPlugin/index.d.ts +49 -0
- package/plugins/PanoMaskSelectorPlugin/index.js +348 -0
- package/plugins/PanoMaskSelectorPlugin/vertexShader.d.ts +1 -0
- package/plugins/PanoMaskSelectorPlugin/vertexShader.js +10 -0
- package/plugins/PanoRulerPlugin/data/roomInfo.js +2 -0
- package/plugins/PanoRulerPlugin/data/roomRules.js +2 -0
- package/plugins/PanoRulerPlugin/index.js +68 -20
- package/plugins/PanoRulerPlugin/typings.js +2 -0
- package/plugins/PanoTVVideoPlugin/index.d.ts +2 -0
- package/plugins/PanoTVVideoPlugin/index.js +108 -26
- package/plugins/TreasurePlugin/Controller.js +58 -52
- package/plugins/TreasurePlugin/TreasureFaceAnime.js +36 -21
- package/plugins/TreasurePlugin/TreasureObject.js +60 -56
- package/plugins/TreasurePlugin/TreasureOpenAnime.js +38 -19
- package/plugins/TreasurePlugin/constants.js +2 -0
- package/plugins/TreasurePlugin/index.js +2 -0
- package/plugins/TreasurePlugin/typings.js +2 -0
- package/plugins/floorplan/Assets/floorplanExtraObject.js +2 -0
- package/plugins/floorplan/ModelFloorplanPlugin/Controller.js +71 -88
- package/plugins/floorplan/ModelFloorplanPlugin/components/Camera.js +25 -5
- package/plugins/floorplan/ModelFloorplanPlugin/components/Compass.js +19 -4
- package/plugins/floorplan/ModelFloorplanPlugin/components/NowFloor/RoomHighlight.js +28 -4
- package/plugins/floorplan/ModelFloorplanPlugin/components/NowFloor/RoomLabels.js +28 -5
- package/plugins/floorplan/ModelFloorplanPlugin/components/NowFloor/index.js +20 -6
- package/plugins/floorplan/ModelFloorplanPlugin/components/index.js +30 -8
- package/plugins/floorplan/ModelFloorplanPlugin/controller.style.js +2 -0
- package/plugins/floorplan/ModelFloorplanPlugin/index.js +4 -2
- package/plugins/floorplan/ModelFloorplanPlugin/typings/events.type.js +2 -0
- package/plugins/floorplan/ModelFloorplanPlugin/utils/constant.js +2 -0
- package/plugins/floorplan/ModelFloorplanPlugin/utils/correctFiveState.js +14 -22
- package/plugins/floorplan/PanoFloorplanRadarPlugin/Content/Camera.js +25 -3
- package/plugins/floorplan/PanoFloorplanRadarPlugin/Content/Camera.style.js +6 -2
- package/plugins/floorplan/PanoFloorplanRadarPlugin/Content/NowFloor/ExtraObjects.js +19 -3
- package/plugins/floorplan/PanoFloorplanRadarPlugin/Content/NowFloor/RoomHighlight.js +28 -4
- package/plugins/floorplan/PanoFloorplanRadarPlugin/Content/NowFloor/index.js +22 -6
- package/plugins/floorplan/PanoFloorplanRadarPlugin/Content/index.js +29 -19
- package/plugins/floorplan/PanoFloorplanRadarPlugin/Content/index.style.js +2 -0
- package/plugins/floorplan/PanoFloorplanRadarPlugin/Controller.js +44 -47
- package/plugins/floorplan/PanoFloorplanRadarPlugin/index.js +4 -2
- package/plugins/floorplan/TopviewFloorplanPlugin/Controller.js +50 -55
- package/plugins/floorplan/TopviewFloorplanPlugin/index.js +2 -0
- package/plugins/floorplan/TopviewFloorplanPlugin/style.js +2 -0
- package/plugins/floorplan/components/FloorplanImage.js +15 -1
- package/plugins/floorplan/typings/floorplanData.js +2 -0
- package/plugins/floorplan/typings/floorplanServerData.js +2 -0
- package/plugins/floorplan/utils/formatData.js +28 -10
- package/plugins/floorplan/utils/formatPosition.js +10 -8
- package/shared-utils/Preloader.js +6 -0
- package/shared-utils/Subscribe.js +36 -16
- package/shared-utils/animationFrame/BetterTween.js +28 -27
- package/shared-utils/animationFrame/calculateProgress.js +2 -0
- package/shared-utils/animationFrame/formatRad.js +2 -0
- package/shared-utils/animationFrame/index.js +12 -0
- package/shared-utils/animationFrame/tween.js +17 -1
- package/shared-utils/changeModelCanvansOpacity.js +14 -0
- package/shared-utils/createCanvasTextTexture.d.ts +8 -0
- package/shared-utils/createCanvasTextTexture.js +31 -0
- package/shared-utils/createFiveContainer.js +23 -17
- package/shared-utils/createLine/index.js +15 -1
- package/shared-utils/debounce.js +4 -0
- package/shared-utils/equal.js +15 -4
- package/shared-utils/filter.js +36 -2
- package/shared-utils/five/changeMode.js +13 -17
- package/shared-utils/five/useFivePlugin.js +2 -0
- package/shared-utils/formatRad.js +2 -0
- package/shared-utils/getPxmm.js +15 -1
- package/shared-utils/getRandomColor.js +10 -0
- package/shared-utils/isNil.js +2 -0
- package/shared-utils/isTruelyObject.js +4 -0
- package/shared-utils/math/evenNumber.js +2 -0
- package/shared-utils/math/planimetry.js +10 -0
- package/shared-utils/math/rad2Deg.js +2 -0
- package/shared-utils/nearlyEqual.js +2 -0
- package/shared-utils/nextFrame.js +2 -0
- package/shared-utils/noop.js +2 -0
- package/shared-utils/object3d2LocalMatrix.js +20 -14
- package/shared-utils/px2rem.js +10 -0
- package/shared-utils/tap.js +2 -0
- package/shared-utils/three/centerPoint.js +2 -0
- package/shared-utils/three/getExtraModelLoader.js +14 -0
- package/shared-utils/three/getNormal.js +4 -0
- package/shared-utils/three/getTextureLoader.js +16 -0
- package/shared-utils/three/loadFbxObj.js +13 -5
- package/shared-utils/three/loadTexture.js +13 -5
- package/shared-utils/three/transformPositionToVector3.js +2 -0
- package/shared-utils/three/transfromToMeshBasicMaterial.d.ts +2 -0
- package/shared-utils/three/transfromToMeshBasicMaterial.js +33 -0
- package/shared-utils/throttle.js +4 -0
- package/shared-utils/to.js +8 -4
- package/shared-utils/useDebounce.js +6 -0
- package/shared-utils/useThrottle.js +6 -0
- package/shared-utils/uuid.js +8 -0
- package/shared-utils/vectorTocoordinates.js +2 -0
- package/typedoc/components.js +2 -0
- package/typedoc/plugins.d.ts +2 -0
- package/typedoc/plugins.js +41 -1
- package/typedoc/shared-utils.js +2 -0
- package/typedoc/typings.js +2 -0
- package/typings/math.type.js +2 -0
- package/typings/utils.type.js +2 -0
- package/components/PBRView/index.d.ts +0 -14
- package/data/wYnRjQ4KZoV1yPoG.d.ts +0 -114
- package/data/wYnRjQ4KZoV1yPoG.js +0 -512
|
@@ -0,0 +1,650 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
require("core-js/modules/es.reflect.construct.js");
|
|
4
|
+
|
|
5
|
+
require("core-js/modules/es.array.iterator.js");
|
|
6
|
+
|
|
7
|
+
require("core-js/modules/es.string.iterator.js");
|
|
8
|
+
|
|
9
|
+
require("core-js/modules/es.weak-map.js");
|
|
10
|
+
|
|
11
|
+
require("core-js/modules/web.dom-collections.iterator.js");
|
|
12
|
+
|
|
13
|
+
require("core-js/modules/es.object.define-property.js");
|
|
14
|
+
|
|
15
|
+
require("core-js/modules/es.object.get-own-property-descriptor.js");
|
|
16
|
+
|
|
17
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
18
|
+
|
|
19
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
20
|
+
|
|
21
|
+
Object.defineProperty(exports, "__esModule", {
|
|
22
|
+
value: true
|
|
23
|
+
});
|
|
24
|
+
exports.GLTFViewer = void 0;
|
|
25
|
+
|
|
26
|
+
require("core-js/modules/es.function.bind.js");
|
|
27
|
+
|
|
28
|
+
require("core-js/modules/web.timers.js");
|
|
29
|
+
|
|
30
|
+
require("core-js/modules/es.object.assign.js");
|
|
31
|
+
|
|
32
|
+
require("core-js/modules/es.object.to-string.js");
|
|
33
|
+
|
|
34
|
+
require("core-js/modules/es.promise.js");
|
|
35
|
+
|
|
36
|
+
require("core-js/modules/es.date.to-string.js");
|
|
37
|
+
|
|
38
|
+
require("core-js/modules/es.regexp.to-string.js");
|
|
39
|
+
|
|
40
|
+
require("core-js/modules/es.number.is-integer.js");
|
|
41
|
+
|
|
42
|
+
require("core-js/modules/es.number.constructor.js");
|
|
43
|
+
|
|
44
|
+
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
45
|
+
|
|
46
|
+
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
47
|
+
|
|
48
|
+
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
49
|
+
|
|
50
|
+
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
51
|
+
|
|
52
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
53
|
+
|
|
54
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
55
|
+
|
|
56
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
57
|
+
|
|
58
|
+
var THREE = _interopRequireWildcard(require("three"));
|
|
59
|
+
|
|
60
|
+
var _hammerjs = _interopRequireDefault(require("hammerjs"));
|
|
61
|
+
|
|
62
|
+
var _GLTFLoader = require("three/examples/jsm/loaders/GLTFLoader");
|
|
63
|
+
|
|
64
|
+
var _RGBELoader = require("three/examples/jsm/loaders/RGBELoader");
|
|
65
|
+
|
|
66
|
+
var _coordsMoveByOffset = require("./coordsMoveByOffset");
|
|
67
|
+
|
|
68
|
+
var _getFrameTime = require("./getFrameTime");
|
|
69
|
+
|
|
70
|
+
var _formatRad = require("./formatRad");
|
|
71
|
+
|
|
72
|
+
var _coordsToDirection = require("./coordsToDirection");
|
|
73
|
+
|
|
74
|
+
var _mouseWheel = require("./mouseWheel");
|
|
75
|
+
|
|
76
|
+
var _requestAnimationFrameInterval = require("./requestAnimationFrameInterval");
|
|
77
|
+
|
|
78
|
+
var _uuid = _interopRequireDefault(require("./uuid"));
|
|
79
|
+
|
|
80
|
+
var _Subscribe2 = require("./Subscribe");
|
|
81
|
+
|
|
82
|
+
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); }
|
|
83
|
+
|
|
84
|
+
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; }
|
|
85
|
+
|
|
86
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
|
|
87
|
+
|
|
88
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
89
|
+
|
|
90
|
+
var defaultPos = {
|
|
91
|
+
longitude: 0,
|
|
92
|
+
latitude: -0.3,
|
|
93
|
+
fov: 35
|
|
94
|
+
};
|
|
95
|
+
var ERROR_NO_CONTROLLER = 'GLTFViewer 实例丢失';
|
|
96
|
+
var loader = new _GLTFLoader.GLTFLoader();
|
|
97
|
+
|
|
98
|
+
var Controller = /*#__PURE__*/function () {
|
|
99
|
+
function Controller(config, callbacks) {
|
|
100
|
+
var _this = this;
|
|
101
|
+
|
|
102
|
+
(0, _classCallCheck2["default"])(this, Controller);
|
|
103
|
+
(0, _defineProperty2["default"])(this, "fov", 35);
|
|
104
|
+
(0, _defineProperty2["default"])(this, "longitude", 0);
|
|
105
|
+
(0, _defineProperty2["default"])(this, "latitude", -0.3);
|
|
106
|
+
(0, _defineProperty2["default"])(this, "needsRender", false);
|
|
107
|
+
// 异步事件回调
|
|
108
|
+
this.callbacks = callbacks; // 默认状态参数
|
|
109
|
+
|
|
110
|
+
var initial = config.initial || {};
|
|
111
|
+
|
|
112
|
+
if (initial.fov !== undefined) {
|
|
113
|
+
this.fov = initial.fov;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
if (initial.latitude !== undefined) {
|
|
117
|
+
this.latitude = initial.latitude;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
if (initial.longitude !== undefined) {
|
|
121
|
+
this.longitude = initial.longitude;
|
|
122
|
+
} // 场景
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
this.scene = new THREE.Scene(); // 背景色值
|
|
126
|
+
|
|
127
|
+
if (config.backgroundColor) {
|
|
128
|
+
this.scene.background = config.backgroundColor;
|
|
129
|
+
} // 渲染器
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
this.renderer = new THREE.WebGLRenderer({
|
|
133
|
+
antialias: config.antialias,
|
|
134
|
+
alpha: true
|
|
135
|
+
});
|
|
136
|
+
this.renderer.outputEncoding = THREE.sRGBEncoding;
|
|
137
|
+
this.renderer.toneMapping = THREE.ReinhardToneMapping;
|
|
138
|
+
this.renderer.toneMappingExposure = 1.5;
|
|
139
|
+
|
|
140
|
+
if (config.backgroundColor) {
|
|
141
|
+
this.renderer.setClearColor(config.backgroundColor, 0);
|
|
142
|
+
} // 像素比
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
if (config.pixelRatio) {
|
|
146
|
+
this.renderer.setPixelRatio(config.pixelRatio);
|
|
147
|
+
} // 相机
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
this.camera = new THREE.PerspectiveCamera(this.fov, 1, 0.1, 10000); // 光照
|
|
151
|
+
|
|
152
|
+
this.pointLight = new THREE.PointLight(0xfffffff, 0.9, 10000);
|
|
153
|
+
this.scene.add(this.pointLight);
|
|
154
|
+
this.directionLight = new THREE.DirectionalLight(0xfffffff, 0.1);
|
|
155
|
+
this.directionLight.position.setY(-1);
|
|
156
|
+
this.scene.add(this.directionLight); // 背景 HDR
|
|
157
|
+
|
|
158
|
+
if (config.backgroundHDR) {
|
|
159
|
+
var pmremGenerator = new THREE.PMREMGenerator(this.renderer);
|
|
160
|
+
var rgbLoader = new _RGBELoader.RGBELoader();
|
|
161
|
+
rgbLoader.setDataType(THREE.UnsignedByteType);
|
|
162
|
+
rgbLoader.load(config.backgroundHDR, function (hdrEquirect) {
|
|
163
|
+
var hdrCubeRenderTarget = pmremGenerator.fromEquirectangular(hdrEquirect);
|
|
164
|
+
_this.scene.environment = hdrCubeRenderTarget.texture;
|
|
165
|
+
|
|
166
|
+
if (config.backgroundColor) {
|
|
167
|
+
_this.scene.background = hdrCubeRenderTarget.texture;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
hdrEquirect.dispose();
|
|
171
|
+
pmremGenerator.dispose();
|
|
172
|
+
_this.needsRender = true;
|
|
173
|
+
});
|
|
174
|
+
pmremGenerator.compileEquirectangularShader();
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
this.__interiaMovement = false;
|
|
178
|
+
var hammerManager = new _hammerjs["default"].Manager(this.element);
|
|
179
|
+
hammerManager.add(new _hammerjs["default"].Pan({
|
|
180
|
+
threshold: 0,
|
|
181
|
+
pointers: 0
|
|
182
|
+
}));
|
|
183
|
+
hammerManager.add(new _hammerjs["default"].Pinch({
|
|
184
|
+
threshold: 0,
|
|
185
|
+
pointers: 2
|
|
186
|
+
}).recognizeWith(hammerManager.get('pan')));
|
|
187
|
+
hammerManager.on('panstart pan', this.__onPanGesture.bind(this));
|
|
188
|
+
hammerManager.on('pinchstart pinch pinchend', this.__onPinchGesture.bind(this));
|
|
189
|
+
|
|
190
|
+
var __onMouseWheel = this.__onMouseWheel.bind(this);
|
|
191
|
+
|
|
192
|
+
(0, _mouseWheel.addMouseWheel)(this.element, __onMouseWheel);
|
|
193
|
+
|
|
194
|
+
this.dispose = function () {
|
|
195
|
+
hammerManager.destroy();
|
|
196
|
+
(0, _mouseWheel.removeMouseWheel)(_this.element, __onMouseWheel);
|
|
197
|
+
|
|
198
|
+
_this.clear();
|
|
199
|
+
|
|
200
|
+
_this.renderer.dispose(); // delete this.dispose
|
|
201
|
+
|
|
202
|
+
};
|
|
203
|
+
|
|
204
|
+
this.needsRender = true;
|
|
205
|
+
this.play();
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
(0, _createClass2["default"])(Controller, [{
|
|
209
|
+
key: "pause",
|
|
210
|
+
value: function pause() {}
|
|
211
|
+
}, {
|
|
212
|
+
key: "clear",
|
|
213
|
+
value: function clear() {
|
|
214
|
+
if (this.target) {
|
|
215
|
+
this.scene.remove(this.target.scene); // disposeObject(this.target)
|
|
216
|
+
|
|
217
|
+
this.update(defaultPos);
|
|
218
|
+
this.target = undefined;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
}, {
|
|
222
|
+
key: "play",
|
|
223
|
+
value: function play() {
|
|
224
|
+
var _this2 = this;
|
|
225
|
+
|
|
226
|
+
this.pause();
|
|
227
|
+
|
|
228
|
+
var _render = function _render() {
|
|
229
|
+
if (_this2.needsRender !== false) _this2.render();
|
|
230
|
+
_this2.needsRender = false;
|
|
231
|
+
};
|
|
232
|
+
|
|
233
|
+
this.pause = (0, _requestAnimationFrameInterval.requestAnimationFrameInterval)(_render);
|
|
234
|
+
|
|
235
|
+
_render();
|
|
236
|
+
}
|
|
237
|
+
}, {
|
|
238
|
+
key: "setTarget",
|
|
239
|
+
value: function setTarget(object) {
|
|
240
|
+
var _this3 = this;
|
|
241
|
+
|
|
242
|
+
if (this.target) {
|
|
243
|
+
this.scene.remove(this.target.scene);
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
this.target = object;
|
|
247
|
+
this.target.scene.visible = false;
|
|
248
|
+
this.scene.add(this.target.scene);
|
|
249
|
+
setTimeout(function () {
|
|
250
|
+
if (object === _this3.target) {
|
|
251
|
+
_this3.target.scene.visible = true;
|
|
252
|
+
|
|
253
|
+
_this3.update(defaultPos);
|
|
254
|
+
}
|
|
255
|
+
}, 50);
|
|
256
|
+
}
|
|
257
|
+
}, {
|
|
258
|
+
key: "element",
|
|
259
|
+
get: function get() {
|
|
260
|
+
return this.renderer.domElement;
|
|
261
|
+
}
|
|
262
|
+
}, {
|
|
263
|
+
key: "appendTo",
|
|
264
|
+
value: function appendTo(container, size) {
|
|
265
|
+
container.appendChild(this.element);
|
|
266
|
+
this.refresh(size);
|
|
267
|
+
var positionType = window.getComputedStyle(container).position;
|
|
268
|
+
|
|
269
|
+
if (positionType !== 'relative' && positionType !== 'absolute' && positionType !== 'fixed' && positionType !== 'sticky') {
|
|
270
|
+
container.style.position = 'relative';
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
}, {
|
|
274
|
+
key: "refresh",
|
|
275
|
+
value: function refresh() {
|
|
276
|
+
var size = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
277
|
+
var element = this.element;
|
|
278
|
+
var container = element.parentElement;
|
|
279
|
+
if (!container) return;
|
|
280
|
+
|
|
281
|
+
if (container && container.tagName && container.nodeName) {
|
|
282
|
+
var _size$width = size.width,
|
|
283
|
+
width = _size$width === void 0 ? container.offsetWidth : _size$width,
|
|
284
|
+
_size$height = size.height,
|
|
285
|
+
height = _size$height === void 0 ? container.offsetHeight : _size$height;
|
|
286
|
+
this.renderer.setSize(width, height); // 修改摄像机 aspect 比值
|
|
287
|
+
|
|
288
|
+
this.camera.aspect = width / height;
|
|
289
|
+
this.camera.updateProjectionMatrix();
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
this.needsRender = true;
|
|
293
|
+
}
|
|
294
|
+
}, {
|
|
295
|
+
key: "update",
|
|
296
|
+
value: function update(state) {
|
|
297
|
+
var fov = this.fov;
|
|
298
|
+
var longitude = this.longitude;
|
|
299
|
+
var latitude = this.latitude;
|
|
300
|
+
|
|
301
|
+
if (state.fov !== undefined) {
|
|
302
|
+
fov = state.fov;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
if (state.longitude !== undefined) {
|
|
306
|
+
longitude = state.longitude;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
if (state.latitude !== undefined) {
|
|
310
|
+
latitude = state.latitude;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
var center = new THREE.Vector3();
|
|
314
|
+
var box = new THREE.Box3();
|
|
315
|
+
|
|
316
|
+
if (this.target) {
|
|
317
|
+
box.expandByObject(this.target.scene);
|
|
318
|
+
box.getCenter(center);
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
longitude = (0, _formatRad.formatRad)(longitude);
|
|
322
|
+
latitude = Math.max(-Math.PI / 2 + 0.01, Math.min(+Math.PI / 2, latitude));
|
|
323
|
+
var distance = Math.max(center.distanceTo(box.min), center.distanceTo(box.max));
|
|
324
|
+
var direction = (0, _coordsToDirection.coordsToDirection)({
|
|
325
|
+
longitude: longitude,
|
|
326
|
+
latitude: latitude
|
|
327
|
+
});
|
|
328
|
+
direction.setLength(distance * 3);
|
|
329
|
+
this.camera.position.copy(center.clone().add(direction));
|
|
330
|
+
this.camera.lookAt(center);
|
|
331
|
+
var lightDirection = (0, _coordsToDirection.coordsToDirection)({
|
|
332
|
+
longitude: longitude,
|
|
333
|
+
latitude: -Math.PI / 6
|
|
334
|
+
});
|
|
335
|
+
lightDirection.setLength(distance * 3);
|
|
336
|
+
this.pointLight.position.copy(center.clone().add(lightDirection));
|
|
337
|
+
|
|
338
|
+
if (fov !== this.fov) {
|
|
339
|
+
fov = Math.max(25, Math.min(60, fov));
|
|
340
|
+
this.camera.fov = fov;
|
|
341
|
+
this.camera.updateProjectionMatrix();
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
var needsRender = this.fov !== fov || this.longitude !== longitude || this.latitude !== latitude;
|
|
345
|
+
Object.assign(this, {
|
|
346
|
+
longitude: longitude,
|
|
347
|
+
latitude: latitude,
|
|
348
|
+
fov: fov
|
|
349
|
+
});
|
|
350
|
+
this.needsRender = true;
|
|
351
|
+
|
|
352
|
+
if (needsRender) {
|
|
353
|
+
this.callbacks.stateChange({
|
|
354
|
+
longitude: longitude,
|
|
355
|
+
latitude: latitude,
|
|
356
|
+
fov: fov
|
|
357
|
+
});
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
}, {
|
|
361
|
+
key: "__onPanGesture",
|
|
362
|
+
value: function __onPanGesture(event) {
|
|
363
|
+
var _this4 = this;
|
|
364
|
+
|
|
365
|
+
this.__interiaMovement = false;
|
|
366
|
+
var longitude = this.longitude,
|
|
367
|
+
latitude = this.latitude;
|
|
368
|
+
var center = event.center,
|
|
369
|
+
isFinal = event.isFinal,
|
|
370
|
+
velocityX = event.velocityX,
|
|
371
|
+
velocityY = event.velocityY,
|
|
372
|
+
pointers = event.pointers;
|
|
373
|
+
|
|
374
|
+
var offset = function () {
|
|
375
|
+
if (!(_this4.__lastPanPoint && _this4.__lastPanPoint.pointerLength === pointers.length)) {
|
|
376
|
+
return {
|
|
377
|
+
x: 0,
|
|
378
|
+
y: 0
|
|
379
|
+
};
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
return {
|
|
383
|
+
x: center.x - _this4.__lastPanPoint.x,
|
|
384
|
+
y: center.y - _this4.__lastPanPoint.y
|
|
385
|
+
};
|
|
386
|
+
}();
|
|
387
|
+
|
|
388
|
+
if (!isFinal) {
|
|
389
|
+
var layout = {
|
|
390
|
+
width: this.element.offsetWidth,
|
|
391
|
+
height: this.element.offsetHeight
|
|
392
|
+
};
|
|
393
|
+
this.update((0, _coordsMoveByOffset.coordsMoveByOffset)({
|
|
394
|
+
longitude: longitude,
|
|
395
|
+
latitude: latitude
|
|
396
|
+
}, offset, layout));
|
|
397
|
+
this.__lastPanPoint = {
|
|
398
|
+
pointerLength: pointers.length,
|
|
399
|
+
x: center.x,
|
|
400
|
+
y: center.y
|
|
401
|
+
};
|
|
402
|
+
} else {
|
|
403
|
+
delete this.__lastPanPoint;
|
|
404
|
+
(0, _getFrameTime.getFrameTime)(function (frameTime) {
|
|
405
|
+
_this4.__interiaMovement = true;
|
|
406
|
+
var x = velocityX * frameTime;
|
|
407
|
+
var y = velocityY * frameTime;
|
|
408
|
+
var distance = Math.sqrt(x * x + y * y);
|
|
409
|
+
|
|
410
|
+
if (distance > 100) {
|
|
411
|
+
x = x / distance * 100;
|
|
412
|
+
y = y / distance * 100;
|
|
413
|
+
} // 滑动小于上下15度, 忽略 y 值
|
|
414
|
+
|
|
415
|
+
|
|
416
|
+
if (Math.abs(y / x) < Math.tan(20 / 180 * Math.PI)) y = 0;
|
|
417
|
+
|
|
418
|
+
_this4.__requestInteriaMovement({
|
|
419
|
+
x: x,
|
|
420
|
+
y: y
|
|
421
|
+
});
|
|
422
|
+
});
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
}, {
|
|
426
|
+
key: "__onPinchGesture",
|
|
427
|
+
value: function __onPinchGesture(event) {
|
|
428
|
+
this.__interiaMovement = false;
|
|
429
|
+
var scale = event.scale,
|
|
430
|
+
type = event.type;
|
|
431
|
+
|
|
432
|
+
if (type === 'pinchstart') {
|
|
433
|
+
this.__pinchCurrentFov = this.fov;
|
|
434
|
+
return;
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
if (type === 'pinchend') {
|
|
438
|
+
this.__pinchCurrentFov = undefined;
|
|
439
|
+
return;
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
this.update({
|
|
443
|
+
fov: (this.__pinchCurrentFov || 0) / scale
|
|
444
|
+
});
|
|
445
|
+
}
|
|
446
|
+
}, {
|
|
447
|
+
key: "__requestInteriaMovement",
|
|
448
|
+
value: function __requestInteriaMovement(offset) {
|
|
449
|
+
var _this5 = this;
|
|
450
|
+
|
|
451
|
+
if (this.__interiaMovement === false) return;
|
|
452
|
+
var x = offset.x,
|
|
453
|
+
y = offset.y;
|
|
454
|
+
var longitude = this.longitude,
|
|
455
|
+
latitude = this.latitude;
|
|
456
|
+
var friction = 0.9;
|
|
457
|
+
var layout = {
|
|
458
|
+
width: this.element.offsetWidth,
|
|
459
|
+
height: this.element.offsetHeight
|
|
460
|
+
};
|
|
461
|
+
this.update((0, _coordsMoveByOffset.coordsMoveByOffset)({
|
|
462
|
+
longitude: longitude,
|
|
463
|
+
latitude: latitude
|
|
464
|
+
}, {
|
|
465
|
+
x: x,
|
|
466
|
+
y: y
|
|
467
|
+
}, layout));
|
|
468
|
+
var notFinal = Math.abs(x) > 1 || Math.abs(y) > 1;
|
|
469
|
+
|
|
470
|
+
if (notFinal) {
|
|
471
|
+
requestAnimationFrame(function () {
|
|
472
|
+
return _this5.__requestInteriaMovement({
|
|
473
|
+
x: x * friction,
|
|
474
|
+
y: y * friction * 0.7
|
|
475
|
+
});
|
|
476
|
+
});
|
|
477
|
+
} else {
|
|
478
|
+
this.__interiaMovement = false;
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
}, {
|
|
482
|
+
key: "__onMouseWheel",
|
|
483
|
+
value: function __onMouseWheel(event) {
|
|
484
|
+
this.__interiaMovement = false;
|
|
485
|
+
this.update({
|
|
486
|
+
fov: this.fov - event.delta
|
|
487
|
+
});
|
|
488
|
+
}
|
|
489
|
+
}, {
|
|
490
|
+
key: "load",
|
|
491
|
+
value: function load(url) {
|
|
492
|
+
var _this6 = this;
|
|
493
|
+
|
|
494
|
+
return new Promise(function (resolve, reject) {
|
|
495
|
+
_this6.callbacks.willLoad();
|
|
496
|
+
|
|
497
|
+
loader.load(url, function (gltf) {
|
|
498
|
+
_this6.setTarget(gltf);
|
|
499
|
+
|
|
500
|
+
_this6.callbacks.loaded(gltf);
|
|
501
|
+
|
|
502
|
+
resolve(true);
|
|
503
|
+
}, function (xhr) {
|
|
504
|
+
_this6.callbacks.progressing(xhr.loaded / xhr.total * 100);
|
|
505
|
+
}, function (error) {
|
|
506
|
+
_this6.callbacks.loadError(error);
|
|
507
|
+
|
|
508
|
+
reject(error);
|
|
509
|
+
});
|
|
510
|
+
});
|
|
511
|
+
}
|
|
512
|
+
}, {
|
|
513
|
+
key: "render",
|
|
514
|
+
value: function render() {
|
|
515
|
+
this.renderer.render(this.scene, this.camera);
|
|
516
|
+
}
|
|
517
|
+
}]);
|
|
518
|
+
return Controller;
|
|
519
|
+
}();
|
|
520
|
+
|
|
521
|
+
var caches = {};
|
|
522
|
+
|
|
523
|
+
var GLTFViewer = /*#__PURE__*/function (_Subscribe) {
|
|
524
|
+
(0, _inherits2["default"])(GLTFViewer, _Subscribe);
|
|
525
|
+
|
|
526
|
+
var _super = _createSuper(GLTFViewer);
|
|
527
|
+
|
|
528
|
+
function GLTFViewer(config) {
|
|
529
|
+
var _this7;
|
|
530
|
+
|
|
531
|
+
(0, _classCallCheck2["default"])(this, GLTFViewer);
|
|
532
|
+
_this7 = _super.call(this);
|
|
533
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this7), "uuid", (0, _uuid["default"])());
|
|
534
|
+
var controller = new Controller(config, {
|
|
535
|
+
stateChange: function stateChange(state) {
|
|
536
|
+
return _this7.emit('stateChange', state);
|
|
537
|
+
},
|
|
538
|
+
progressing: function (_progressing) {
|
|
539
|
+
function progressing(_x) {
|
|
540
|
+
return _progressing.apply(this, arguments);
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
progressing.toString = function () {
|
|
544
|
+
return _progressing.toString();
|
|
545
|
+
};
|
|
546
|
+
|
|
547
|
+
return progressing;
|
|
548
|
+
}(function (progressing) {
|
|
549
|
+
return _this7.emit('progressing', progressing);
|
|
550
|
+
}),
|
|
551
|
+
willLoad: function willLoad() {
|
|
552
|
+
return _this7.emit('willLoad');
|
|
553
|
+
},
|
|
554
|
+
loaded: function loaded(gltf) {
|
|
555
|
+
return _this7.emit('loaded', gltf);
|
|
556
|
+
},
|
|
557
|
+
loadError: function loadError(error) {
|
|
558
|
+
return _this7.emit('loadError', error);
|
|
559
|
+
}
|
|
560
|
+
});
|
|
561
|
+
caches[_this7.uuid] = controller;
|
|
562
|
+
controller.appendTo;
|
|
563
|
+
controller.load;
|
|
564
|
+
return _this7;
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
(0, _createClass2["default"])(GLTFViewer, [{
|
|
568
|
+
key: "state",
|
|
569
|
+
get: function get() {
|
|
570
|
+
var controller = caches[this.uuid];
|
|
571
|
+
if (!controller) throw new Error(ERROR_NO_CONTROLLER);
|
|
572
|
+
var proxy = new Proxy({
|
|
573
|
+
fov: controller.fov,
|
|
574
|
+
latitude: controller.latitude,
|
|
575
|
+
longitude: controller.longitude
|
|
576
|
+
}, {
|
|
577
|
+
set: function set(obj, prop, value) {
|
|
578
|
+
if (prop === 'fov') {
|
|
579
|
+
if (!Number.isInteger(value)) {
|
|
580
|
+
throw new TypeError('The fov is not an number');
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
if (value > 60 || value < 20) {
|
|
584
|
+
throw new RangeError('The fov seems invalid~ fov: [20, 60]');
|
|
585
|
+
}
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
controller.update((0, _defineProperty2["default"])({}, prop, value));
|
|
589
|
+
return true;
|
|
590
|
+
},
|
|
591
|
+
get: function get(obj, prop) {
|
|
592
|
+
return controller[prop];
|
|
593
|
+
}
|
|
594
|
+
});
|
|
595
|
+
return proxy;
|
|
596
|
+
},
|
|
597
|
+
set: function set(_ref) {
|
|
598
|
+
var fov = _ref.fov,
|
|
599
|
+
latitude = _ref.latitude,
|
|
600
|
+
longitude = _ref.longitude;
|
|
601
|
+
var controller = caches[this.uuid];
|
|
602
|
+
if (!controller) throw new Error(ERROR_NO_CONTROLLER);
|
|
603
|
+
controller.update({
|
|
604
|
+
fov: fov === undefined ? controller.fov : fov,
|
|
605
|
+
latitude: latitude === undefined ? controller.latitude : latitude,
|
|
606
|
+
longitude: longitude === undefined ? controller.longitude : longitude
|
|
607
|
+
});
|
|
608
|
+
}
|
|
609
|
+
/**
|
|
610
|
+
*
|
|
611
|
+
* @param url glTF 模型CDN地址
|
|
612
|
+
*/
|
|
613
|
+
|
|
614
|
+
}, {
|
|
615
|
+
key: "load",
|
|
616
|
+
value: function load(url) {
|
|
617
|
+
var controller = caches[this.uuid];
|
|
618
|
+
if (!controller) throw new Error(ERROR_NO_CONTROLLER);
|
|
619
|
+
controller.load(url);
|
|
620
|
+
}
|
|
621
|
+
/**
|
|
622
|
+
* 挂载
|
|
623
|
+
* @param container
|
|
624
|
+
* @param size
|
|
625
|
+
*/
|
|
626
|
+
|
|
627
|
+
}, {
|
|
628
|
+
key: "appendTo",
|
|
629
|
+
value: function appendTo(container, size) {
|
|
630
|
+
var controller = caches[this.uuid];
|
|
631
|
+
if (!controller) throw new Error(ERROR_NO_CONTROLLER);
|
|
632
|
+
controller.appendTo(container, size);
|
|
633
|
+
}
|
|
634
|
+
/**
|
|
635
|
+
* 销毁
|
|
636
|
+
*/
|
|
637
|
+
|
|
638
|
+
}, {
|
|
639
|
+
key: "dispose",
|
|
640
|
+
value: function dispose() {
|
|
641
|
+
var controller = caches[this.uuid];
|
|
642
|
+
if (!controller) throw new Error(ERROR_NO_CONTROLLER);
|
|
643
|
+
if (controller.dispose) controller.dispose();
|
|
644
|
+
delete caches[this.uuid];
|
|
645
|
+
}
|
|
646
|
+
}]);
|
|
647
|
+
return GLTFViewer;
|
|
648
|
+
}(_Subscribe2.Subscribe);
|
|
649
|
+
|
|
650
|
+
exports.GLTFViewer = GLTFViewer;
|
|
@@ -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;
|