three-base 2.0.92 → 2.0.94

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 (2) hide show
  1. package/package.json +1 -1
  2. package/threeLoader.js +7 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "three-base",
3
- "version": "2.0.92",
3
+ "version": "2.0.94",
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
  // 获取模型文件的后缀
@@ -241,7 +244,6 @@ class ThreeLoader extends EventDispatcher {
241
244
  revokeObjectfile.push(file.name);
242
245
  if (suffixs.includes(threeUtils.getSuffix(file.name))) {
243
246
  modelurl = file.name;
244
- break;
245
247
  }
246
248
  }
247
249
  return modelurl;
@@ -256,7 +258,9 @@ class ThreeLoader extends EventDispatcher {
256
258
  responseType: "arraybuffer",
257
259
  })
258
260
  .then((res) => res.data)
259
- : url;
261
+ : url instanceof File
262
+ ? url
263
+ : url[0];
260
264
  return await JSZip.loadAsync(arrayBuffer).then(async (zip) => {
261
265
  for (let filename in zip.files) {
262
266
  if (!zip.files[filename].dir) {