three-base 1.0.80 → 1.0.82
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/lib/ApngTexture.js +107 -40
- package/lib/ApngTextureManage.js +100 -51
- package/lib/EventMesh.js +42 -22
- package/lib/ExtrudeMesh.js +178 -147
- package/lib/FPScontrol.js +133 -116
- package/lib/InstancedGroupMesh.js +45 -25
- package/lib/KeyFrameAnimation.js +54 -37
- package/lib/PlaneText.js +34 -14
- package/lib/PlaneWithHtml.js +126 -48
- package/lib/PointLight/PointLight.js +65 -45
- package/lib/Sky/Sky.js +30 -11
- package/lib/SpriteText2.js +166 -90
- package/lib/Text3D/Text3D.js +61 -40
- package/lib/Text3D/fontController.js +284 -149
- package/lib/ThreeBase.js +341 -204
- package/lib/ThreeMouse.js +203 -244
- package/lib/Transition.js +162 -96
- package/lib/Transition.ts +1 -1
- package/lib/keyContorls.js +102 -74
- package/lib/planeModal1/PlaneModal1.js +162 -90
- package/lib/shaders.js +36 -178
- package/lib/spriteModal1/SpriteModal1.js +165 -93
- package/lib/threeLoader.js +89 -66
- package/lib/threeUtils.js +84 -59
- package/package.json +1 -1
|
@@ -4,106 +4,178 @@
|
|
|
4
4
|
* @Last Modified by: xiaosihan
|
|
5
5
|
* @Last Modified time: 2023-03-08 02:05:25
|
|
6
6
|
*/
|
|
7
|
+
var __extends = (this && this.__extends) || (function () {
|
|
8
|
+
var extendStatics = function (d, b) {
|
|
9
|
+
extendStatics = Object.setPrototypeOf ||
|
|
10
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
11
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
12
|
+
return extendStatics(d, b);
|
|
13
|
+
};
|
|
14
|
+
return function (d, b) {
|
|
15
|
+
if (typeof b !== "function" && b !== null)
|
|
16
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
17
|
+
extendStatics(d, b);
|
|
18
|
+
function __() { this.constructor = d; }
|
|
19
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
20
|
+
};
|
|
21
|
+
})();
|
|
22
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
23
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
24
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
25
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
26
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
27
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
28
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
29
|
+
});
|
|
30
|
+
};
|
|
31
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
32
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
33
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
34
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
35
|
+
function step(op) {
|
|
36
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
37
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
38
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
39
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
40
|
+
switch (op[0]) {
|
|
41
|
+
case 0: case 1: t = op; break;
|
|
42
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
43
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
44
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
45
|
+
default:
|
|
46
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
47
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
48
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
49
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
50
|
+
if (t[2]) _.ops.pop();
|
|
51
|
+
_.trys.pop(); continue;
|
|
52
|
+
}
|
|
53
|
+
op = body.call(thisArg, _);
|
|
54
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
55
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
56
|
+
}
|
|
57
|
+
};
|
|
7
58
|
import { Sprite, CanvasTexture, Vector2 } from "three";
|
|
8
59
|
import spriteModal1PNG from "./spriteModal1.png";
|
|
9
60
|
// sprit弹窗1
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
61
|
+
var SpritModal1 = /** @class */ (function (_super) {
|
|
62
|
+
__extends(SpritModal1, _super);
|
|
63
|
+
function SpritModal1(config) {
|
|
64
|
+
if (config === void 0) { config = {}; }
|
|
65
|
+
var _this = _super.call(this) || this;
|
|
66
|
+
_this.canvas = (function () {
|
|
67
|
+
var canvas = document.createElement("canvas");
|
|
68
|
+
canvas.width = 1024;
|
|
69
|
+
canvas.height = 1024;
|
|
70
|
+
return canvas;
|
|
71
|
+
})();
|
|
72
|
+
_this.context = _this.canvas.getContext("2d");
|
|
73
|
+
_this.texture = new CanvasTexture(_this.canvas);
|
|
74
|
+
// 配置
|
|
75
|
+
_this._config = {
|
|
76
|
+
size: 10,
|
|
77
|
+
title: "SpritModal1",
|
|
78
|
+
titleColor: "#ffffff",
|
|
79
|
+
texts: []
|
|
80
|
+
// [
|
|
81
|
+
// {
|
|
82
|
+
// text: "1",
|
|
83
|
+
// color: "#ffff00",
|
|
84
|
+
// size: 40
|
|
85
|
+
// },
|
|
86
|
+
// {
|
|
87
|
+
// text: "2",
|
|
88
|
+
// color: "#ff00ff",
|
|
89
|
+
// size: 40
|
|
90
|
+
// },
|
|
91
|
+
// ]
|
|
92
|
+
};
|
|
93
|
+
_this.updata(config);
|
|
94
|
+
_this.material.map = _this.texture;
|
|
95
|
+
_this.material.transparent = true;
|
|
96
|
+
_this.material.alphaTest = 0.01;
|
|
97
|
+
return _this;
|
|
17
98
|
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
var arrText = text.split('');
|
|
80
|
-
var line = '';
|
|
81
|
-
// 文字自动换行计算
|
|
82
|
-
for (var n = 0; n < arrText.length; n++) {
|
|
83
|
-
var metrics = this.context.measureText(line + arrText[n]);
|
|
84
|
-
var testWidth = metrics.width;
|
|
85
|
-
if ((testWidth > maxWidth && n > 0) || arrText[n] === "\n") {
|
|
86
|
-
this.context.fillText(line, textPos.x, textPos.y);
|
|
87
|
-
line = "";
|
|
88
|
-
textPos.y += size;
|
|
99
|
+
SpritModal1.prototype.updata = function (config) {
|
|
100
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
101
|
+
var textPos, maxWidth;
|
|
102
|
+
var _this = this;
|
|
103
|
+
return __generator(this, function (_a) {
|
|
104
|
+
switch (_a.label) {
|
|
105
|
+
case 0:
|
|
106
|
+
Object.assign(this._config, config);
|
|
107
|
+
//绘制背景
|
|
108
|
+
this.context.clearRect(0, 0, 1024, 1024);
|
|
109
|
+
_a.label = 1;
|
|
110
|
+
case 1:
|
|
111
|
+
if (!!SpritModal1.img.complete) return [3 /*break*/, 3];
|
|
112
|
+
return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 100); })];
|
|
113
|
+
case 2:
|
|
114
|
+
_a.sent();
|
|
115
|
+
return [3 /*break*/, 1];
|
|
116
|
+
case 3:
|
|
117
|
+
// 设置大小
|
|
118
|
+
this.scale.set(this._config.size, this._config.size, this._config.size);
|
|
119
|
+
// this.context.fillStyle = "#00000088";
|
|
120
|
+
// this.context.fillRect(0, 0, 1024, 1024);
|
|
121
|
+
//绘制背景
|
|
122
|
+
this.context.drawImage(SpritModal1.img, 186, 0);
|
|
123
|
+
// 绘制标题
|
|
124
|
+
this.context.fillStyle = this._config.titleColor;
|
|
125
|
+
this.context.font = '40px serif'; // 设置字体大小
|
|
126
|
+
this.context.textAlign = "left";
|
|
127
|
+
this.context.textBaseline = "top";
|
|
128
|
+
this.context.fillText(this._config.title, 250, 72);
|
|
129
|
+
textPos = new Vector2(250, 150);
|
|
130
|
+
maxWidth = 530;
|
|
131
|
+
// 绘制内容
|
|
132
|
+
this._config.texts.map(function (_a) {
|
|
133
|
+
var _b = _a.text, text = _b === void 0 ? "text" : _b, _c = _a.color, color = _c === void 0 ? "#ffffff" : _c, _d = _a.size, size = _d === void 0 ? 40 : _d;
|
|
134
|
+
_this.context.fillStyle = color;
|
|
135
|
+
_this.context.font = "".concat(size, "px serif"); // 设置字体大小
|
|
136
|
+
_this.context.textAlign = "left";
|
|
137
|
+
_this.context.textBaseline = "top";
|
|
138
|
+
// 字符分隔为数组
|
|
139
|
+
var arrText = text.split('');
|
|
140
|
+
var line = '';
|
|
141
|
+
// 文字自动换行计算
|
|
142
|
+
for (var n = 0; n < arrText.length; n++) {
|
|
143
|
+
var metrics = _this.context.measureText(line + arrText[n]);
|
|
144
|
+
var testWidth = metrics.width;
|
|
145
|
+
if ((testWidth > maxWidth && n > 0) || arrText[n] === "\n") {
|
|
146
|
+
_this.context.fillText(line, textPos.x, textPos.y);
|
|
147
|
+
line = "";
|
|
148
|
+
textPos.y += size;
|
|
149
|
+
}
|
|
150
|
+
else {
|
|
151
|
+
line += arrText[n];
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
_this.context.fillText(line, textPos.x, textPos.y);
|
|
155
|
+
textPos.y += size;
|
|
156
|
+
});
|
|
157
|
+
this.texture.needsUpdate = true;
|
|
158
|
+
this.dispatchEvent({ type: "loaded" });
|
|
159
|
+
return [2 /*return*/];
|
|
89
160
|
}
|
|
90
|
-
|
|
91
|
-
line += arrText[n];
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
this.context.fillText(line, textPos.x, textPos.y);
|
|
95
|
-
textPos.y += size;
|
|
161
|
+
});
|
|
96
162
|
});
|
|
97
|
-
|
|
98
|
-
this.dispatchEvent({ type: "loaded" });
|
|
99
|
-
}
|
|
163
|
+
};
|
|
100
164
|
//鼠标拾取计算
|
|
101
|
-
raycast(raycaster, intersects) {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
165
|
+
SpritModal1.prototype.raycast = function (raycaster, intersects) {
|
|
166
|
+
var intersect = [];
|
|
167
|
+
_super.prototype.raycast.call(this, raycaster, intersect);
|
|
168
|
+
var inte = intersect[0];
|
|
105
169
|
if (inte && (inte.uv.x > 0.22 && inte.uv.x < 0.78) && (inte.uv.y > 0.54 && inte.uv.y < 0.94)) {
|
|
106
170
|
intersects.push(inte);
|
|
107
171
|
}
|
|
108
|
-
}
|
|
109
|
-
|
|
172
|
+
};
|
|
173
|
+
// 背景图
|
|
174
|
+
SpritModal1.img = (function () {
|
|
175
|
+
var img = new Image();
|
|
176
|
+
img.src = spriteModal1PNG;
|
|
177
|
+
return img;
|
|
178
|
+
})();
|
|
179
|
+
return SpritModal1;
|
|
180
|
+
}(Sprite));
|
|
181
|
+
export default SpritModal1;
|
package/lib/threeLoader.js
CHANGED
|
@@ -4,6 +4,21 @@
|
|
|
4
4
|
* @Last Modified by: xiaosihan
|
|
5
5
|
* @Last Modified time: 2023-02-07 11:11:48
|
|
6
6
|
*/
|
|
7
|
+
var __extends = (this && this.__extends) || (function () {
|
|
8
|
+
var extendStatics = function (d, b) {
|
|
9
|
+
extendStatics = Object.setPrototypeOf ||
|
|
10
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
11
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
12
|
+
return extendStatics(d, b);
|
|
13
|
+
};
|
|
14
|
+
return function (d, b) {
|
|
15
|
+
if (typeof b !== "function" && b !== null)
|
|
16
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
17
|
+
extendStatics(d, b);
|
|
18
|
+
function __() { this.constructor = d; }
|
|
19
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
20
|
+
};
|
|
21
|
+
})();
|
|
7
22
|
import { DefaultLoadingManager, EventDispatcher, RepeatWrapping, TextureLoader, VideoTexture } from "three";
|
|
8
23
|
import { FBXLoader } from "three/examples/jsm/loaders/FBXLoader";
|
|
9
24
|
import { GLTFLoader } from "three/examples/jsm/loaders/GLTFLoader";
|
|
@@ -18,51 +33,90 @@ import dracoDecoderJS from "./draco/draco_decoder.js?url";
|
|
|
18
33
|
//@ts-ignore
|
|
19
34
|
import dracoDecoderWASM from "./draco/draco_decoder.wasm?url";
|
|
20
35
|
// 加载器
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
36
|
+
var ThreeLoader = /** @class */ (function (_super) {
|
|
37
|
+
__extends(ThreeLoader, _super);
|
|
38
|
+
function ThreeLoader() {
|
|
39
|
+
var _this = _super.call(this) || this;
|
|
40
|
+
// 各向异性
|
|
41
|
+
_this.anisotropy = 1;
|
|
42
|
+
// 纹理对向缓存
|
|
43
|
+
_this.textureMap = new Map();
|
|
44
|
+
// 纹理加载器
|
|
45
|
+
_this.textureLoader = new TextureLoader();
|
|
46
|
+
// fbx模型加载器
|
|
47
|
+
_this.fbxLoader = new FBXLoader();
|
|
48
|
+
//obj 加载器
|
|
49
|
+
_this.objLoader = new OBJLoader();
|
|
50
|
+
// 材质加载器
|
|
51
|
+
_this.mtlLoader = new MTLLoader();
|
|
52
|
+
// gltf 加载器
|
|
53
|
+
_this.gltfLoader = (function () {
|
|
54
|
+
var loader = new GLTFLoader();
|
|
55
|
+
var dracoLoader = new /** @class */ (function (_super) {
|
|
56
|
+
__extends(ThreeBaseDRACOLoader, _super);
|
|
57
|
+
function ThreeBaseDRACOLoader() {
|
|
58
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
59
|
+
}
|
|
60
|
+
ThreeBaseDRACOLoader.prototype._loadLibrary = function (url, responseType) {
|
|
61
|
+
//@ts-ignore
|
|
62
|
+
var urlConf = (process.env.NODE_ENV === "development") ? {
|
|
63
|
+
"draco_decoder.js": "draco_decoder.js",
|
|
64
|
+
"draco_wasm_wrapper.js": "draco_wasm_wrapper.js",
|
|
65
|
+
"draco_decoder.wasm": "draco_decoder.wasm"
|
|
66
|
+
} : {
|
|
67
|
+
"draco_decoder.js": dracoWasmWrapperJS,
|
|
68
|
+
"draco_wasm_wrapper.js": dracoDecoderJS,
|
|
69
|
+
"draco_decoder.wasm": dracoDecoderWASM
|
|
70
|
+
};
|
|
71
|
+
//@ts-ignore
|
|
72
|
+
return _super.prototype._loadLibrary.call(this, urlConf[url], responseType);
|
|
73
|
+
};
|
|
74
|
+
return ThreeBaseDRACOLoader;
|
|
75
|
+
}(DRACOLoader))();
|
|
76
|
+
//@ts-ignore
|
|
77
|
+
dracoLoader.setDecoderPath((process.env.NODE_ENV === "development") ? '/node_modules/three/examples/jsm/libs/draco/' : '');
|
|
78
|
+
loader.setDRACOLoader(dracoLoader);
|
|
79
|
+
return loader;
|
|
80
|
+
})();
|
|
81
|
+
// 是否加载完成
|
|
82
|
+
_this.onload = true;
|
|
83
|
+
DefaultLoadingManager.onStart = function () {
|
|
84
|
+
_this.onload = false;
|
|
26
85
|
};
|
|
27
86
|
// 有资源加载完成时通知渲染器
|
|
28
|
-
DefaultLoadingManager.onProgress = ()
|
|
29
|
-
|
|
87
|
+
DefaultLoadingManager.onProgress = function () {
|
|
88
|
+
_this.dispatchEvent({ type: "progress" });
|
|
30
89
|
};
|
|
31
|
-
DefaultLoadingManager.onLoad = ()
|
|
32
|
-
|
|
90
|
+
DefaultLoadingManager.onLoad = function () {
|
|
91
|
+
_this.onload = true;
|
|
33
92
|
};
|
|
93
|
+
return _this;
|
|
34
94
|
}
|
|
35
|
-
// 各向异性
|
|
36
|
-
anisotropy = 1;
|
|
37
95
|
// 设置各向异性 由渲染器来调用并设置
|
|
38
|
-
setAnisotropy(v) {
|
|
96
|
+
ThreeLoader.prototype.setAnisotropy = function (v) {
|
|
39
97
|
this.anisotropy = v;
|
|
40
|
-
}
|
|
98
|
+
};
|
|
41
99
|
;
|
|
42
|
-
// 纹理对向缓存
|
|
43
|
-
textureMap = new Map();
|
|
44
|
-
// 纹理加载器
|
|
45
|
-
textureLoader = new TextureLoader();
|
|
46
100
|
// 获取地址对应的单例纹理对象
|
|
47
|
-
getTexture(src) {
|
|
48
|
-
|
|
101
|
+
ThreeLoader.prototype.getTexture = function (src) {
|
|
102
|
+
var texture = this.textureMap.get(src);
|
|
49
103
|
if (!texture) {
|
|
50
104
|
if (/\.mp4$/.test(src)) {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
document.addEventListener("pointerup", ()
|
|
59
|
-
|
|
60
|
-
|
|
105
|
+
var videoDom_1 = document.createElement("video");
|
|
106
|
+
videoDom_1.autoplay = true;
|
|
107
|
+
videoDom_1.loop = true;
|
|
108
|
+
videoDom_1.muted = true;
|
|
109
|
+
videoDom_1.preload = "auto";
|
|
110
|
+
videoDom_1.playsInline = true;
|
|
111
|
+
videoDom_1.src = src;
|
|
112
|
+
document.addEventListener("pointerup", function () {
|
|
113
|
+
videoDom_1.pause();
|
|
114
|
+
videoDom_1.play();
|
|
61
115
|
});
|
|
62
|
-
texture = new VideoTexture(
|
|
116
|
+
texture = new VideoTexture(videoDom_1);
|
|
63
117
|
}
|
|
64
118
|
else {
|
|
65
|
-
texture = this.textureLoader.load(src, tex
|
|
119
|
+
texture = this.textureLoader.load(src, function (tex) {
|
|
66
120
|
tex.image.crossOrigin = "anonymous";
|
|
67
121
|
});
|
|
68
122
|
}
|
|
@@ -71,40 +125,9 @@ class ThreeLoader extends EventDispatcher {
|
|
|
71
125
|
texture.wrapS = texture.wrapT = RepeatWrapping;
|
|
72
126
|
texture.anisotropy = this.anisotropy;
|
|
73
127
|
return texture;
|
|
74
|
-
}
|
|
128
|
+
};
|
|
75
129
|
;
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
objLoader = new OBJLoader();
|
|
80
|
-
// 材质加载器
|
|
81
|
-
mtlLoader = new MTLLoader();
|
|
82
|
-
// gltf 加载器
|
|
83
|
-
gltfLoader = (() => {
|
|
84
|
-
const loader = new GLTFLoader();
|
|
85
|
-
const dracoLoader = new class ThreeBaseDRACOLoader extends DRACOLoader {
|
|
86
|
-
_loadLibrary(url, responseType) {
|
|
87
|
-
//@ts-ignore
|
|
88
|
-
let urlConf = (process.env.NODE_ENV === "development") ? {
|
|
89
|
-
"draco_decoder.js": "draco_decoder.js",
|
|
90
|
-
"draco_wasm_wrapper.js": "draco_wasm_wrapper.js",
|
|
91
|
-
"draco_decoder.wasm": "draco_decoder.wasm"
|
|
92
|
-
} : {
|
|
93
|
-
"draco_decoder.js": dracoWasmWrapperJS,
|
|
94
|
-
"draco_wasm_wrapper.js": dracoDecoderJS,
|
|
95
|
-
"draco_decoder.wasm": dracoDecoderWASM
|
|
96
|
-
};
|
|
97
|
-
//@ts-ignore
|
|
98
|
-
return super._loadLibrary(urlConf[url], responseType);
|
|
99
|
-
}
|
|
100
|
-
}();
|
|
101
|
-
//@ts-ignore
|
|
102
|
-
dracoLoader.setDecoderPath((process.env.NODE_ENV === "development") ? '/node_modules/three/examples/jsm/libs/draco/' : '');
|
|
103
|
-
loader.setDRACOLoader(dracoLoader);
|
|
104
|
-
return loader;
|
|
105
|
-
})();
|
|
106
|
-
// 是否加载完成
|
|
107
|
-
onload = true;
|
|
108
|
-
}
|
|
109
|
-
const threeLoader = new ThreeLoader();
|
|
130
|
+
return ThreeLoader;
|
|
131
|
+
}(EventDispatcher));
|
|
132
|
+
var threeLoader = new ThreeLoader();
|
|
110
133
|
export default threeLoader;
|