three-base 2.0.91 → 2.0.93

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.
@@ -39,7 +39,16 @@ export default class InstancedMeshBase extends MeshBase {
39
39
  }
40
40
  else if (url instanceof Array) {
41
41
  let modelurl = "";
42
- const suffixs = ["obj", "glb", "gltf", "fbx", "dae", "stl", "usdz"];
42
+ const suffixs = [
43
+ "zip",
44
+ "obj",
45
+ "glb",
46
+ "gltf",
47
+ "fbx",
48
+ "dae",
49
+ "stl",
50
+ "usdz",
51
+ ];
43
52
  for (let file of url) {
44
53
  if (suffixs.includes(threeUtils.getSuffix(file.name))) {
45
54
  modelurl = file.name;
package/MeshBase.js CHANGED
@@ -39,7 +39,16 @@ export default class MeshBase extends Group {
39
39
  }
40
40
  else if (url instanceof Array) {
41
41
  let modelurl = "";
42
- const suffixs = ["obj", "glb", "gltf", "fbx", "dae", "stl", "usdz"];
42
+ const suffixs = [
43
+ "zip",
44
+ "obj",
45
+ "glb",
46
+ "gltf",
47
+ "fbx",
48
+ "dae",
49
+ "stl",
50
+ "usdz",
51
+ ];
43
52
  for (let file of url) {
44
53
  if (suffixs.includes(threeUtils.getSuffix(file.name))) {
45
54
  modelurl = file.name;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "three-base",
3
- "version": "2.0.91",
3
+ "version": "2.0.93",
4
4
  "description": "three 3d three-base",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
package/threeLoader.js CHANGED
@@ -25,7 +25,7 @@ import axios from "axios";
25
25
  import dracoDecoderWASM from "./lib/draco/draco_decoder.wasm?url";
26
26
  import threeUtils from "./threeUtils";
27
27
  import { generateUUID } from "three/src/math/MathUtils";
28
- import { isString } from "lodash";
28
+ import { isEmpty, isString } from "lodash";
29
29
  // 加载器
30
30
  class ThreeLoader extends EventDispatcher {
31
31
  constructor() {
@@ -181,6 +181,9 @@ class ThreeLoader extends EventDispatcher {
181
181
  }
182
182
  /** 加载模型支持glb,gltf,fbx,stl,obj,usdz,dae,zip */
183
183
  async loadModel(url, filename = "") {
184
+ if (isEmpty(url)) {
185
+ throw new Error(`loadModel:无效的参数 url=${url}`);
186
+ }
184
187
  // 本次需要销毁的bloburl,加载完成后就去销毁本次的文件
185
188
  const revokeObjectfile = [];
186
189
  // 获取模型文件的后缀
@@ -193,7 +196,16 @@ class ThreeLoader extends EventDispatcher {
193
196
  }
194
197
  else if (url instanceof Array) {
195
198
  let suffix = "";
196
- const suffixs = ["obj", "glb", "gltf", "fbx", "dae", "stl", "usdz"];
199
+ const suffixs = [
200
+ "zip",
201
+ "obj",
202
+ "glb",
203
+ "gltf",
204
+ "fbx",
205
+ "dae",
206
+ "stl",
207
+ "usdz",
208
+ ];
197
209
  for (let file of url) {
198
210
  suffix = threeUtils.getSuffix(file.name);
199
211
  if (suffixs.includes(suffix)) {
@@ -216,13 +228,23 @@ class ThreeLoader extends EventDispatcher {
216
228
  }
217
229
  else if (url instanceof Array) {
218
230
  let modelurl = "";
219
- const suffixs = ["obj", "glb", "gltf", "fbx", "dae", "stl", "usdz"];
231
+ const suffixs = [
232
+ "zip",
233
+ "obj",
234
+ "glb",
235
+ "gltf",
236
+ "fbx",
237
+ "dae",
238
+ "stl",
239
+ "usdz",
240
+ ];
220
241
  for (let file of url) {
221
242
  const bloburl = await threeUtils.fileToBloburl(file);
222
243
  this._blobs[file.name] = bloburl;
223
244
  revokeObjectfile.push(file.name);
224
245
  if (suffixs.includes(threeUtils.getSuffix(file.name))) {
225
246
  modelurl = file.name;
247
+ break;
226
248
  }
227
249
  }
228
250
  return modelurl;
@@ -237,7 +259,9 @@ class ThreeLoader extends EventDispatcher {
237
259
  responseType: "arraybuffer",
238
260
  })
239
261
  .then((res) => res.data)
240
- : url;
262
+ : url instanceof File
263
+ ? url
264
+ : url[0];
241
265
  return await JSZip.loadAsync(arrayBuffer).then(async (zip) => {
242
266
  for (let filename in zip.files) {
243
267
  if (!zip.files[filename].dir) {