three-base 2.0.101 → 2.0.102

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/Grass/grass.jpg CHANGED
Binary file
Binary file
Binary file
Binary file
Binary file
package/Sky/skyMap.png CHANGED
Binary file
Binary file
package/ThreeBase.js CHANGED
@@ -539,7 +539,6 @@ export default class ThreeBase extends EventDispatcher {
539
539
  async download(fileName = "download") {
540
540
  this.render();
541
541
  const blob = await this.getThumbBlob();
542
- const base64 = this.renderer.domElement.toDataURL("image/png");
543
542
  let saveLink = document.createElement("a");
544
543
  saveLink.download = `${fileName}.png`;
545
544
  saveLink.href = URL.createObjectURL(blob);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "three-base",
3
- "version": "2.0.101",
3
+ "version": "2.0.102",
4
4
  "description": "three 3d three-base",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
package/threeLoader.d.ts CHANGED
@@ -7,6 +7,7 @@ import { STLLoader } from "three/examples/jsm/loaders/STLLoader";
7
7
  import { USDZLoader } from "three/examples/jsm/loaders/USDZLoader";
8
8
  declare class ThreeLoader extends EventDispatcher {
9
9
  constructor();
10
+ getFilename(url: string): string;
10
11
  uuid: string;
11
12
  anisotropy: number;
12
13
  setAnisotropy(v: number): void;
package/threeLoader.js CHANGED
@@ -49,18 +49,30 @@ class ThreeLoader extends EventDispatcher {
49
49
  };
50
50
  // 资源替换
51
51
  DefaultLoadingManager.setURLModifier((url) => {
52
+ //全路径匹配资源
53
+ if (this._blobs[url]) {
54
+ return this._blobs[url];
55
+ }
52
56
  const filename = url
53
57
  .replace(`blob:${location.origin}/`, "")
54
58
  .replace(/^\.\//, "");
55
59
  let new_url = this._blobs[filename] || url;
56
60
  //如果全匹配没有匹配到资源,就尝试文件名匹配
57
61
  if (!this._blobs[filename]) {
58
- const blobKey = Object.keys(this._blobs).find((key) => new RegExp(`${key}$`).test(filename)) || "";
62
+ const blobKey = Object.keys(this._blobs).find((key) => this.getFilename(key) === this.getFilename(filename)) || "";
59
63
  new_url = this._blobs[blobKey] || url;
60
64
  }
61
65
  return new_url;
62
66
  });
63
67
  }
68
+ // 从url 中提取文件名
69
+ getFilename(url) {
70
+ // 移除URL的查询字符串和哈希部分
71
+ const path = url.split("?")[0].split("#")[0];
72
+ // 使用lastIndexOf和substring从路径中提取文件名
73
+ const filename = path.substring(path.lastIndexOf("/") + 1);
74
+ return filename;
75
+ }
64
76
  uuid = generateUUID();
65
77
  // 各向异性
66
78
  anisotropy = 16;