three-base 2.0.66 → 2.0.68
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/package.json +1 -1
- package/threeLoader.js +18 -3
- package/threeLoader.ts +19 -3
package/package.json
CHANGED
package/threeLoader.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* @Last Modified by: xiaosihan
|
|
5
5
|
* @Last Modified time: 2023-02-07 11:11:48
|
|
6
6
|
*/
|
|
7
|
-
import { CanvasTexture, DefaultLoadingManager, EventDispatcher, Object3D, RepeatWrapping, TextureLoader, VideoTexture } from "three";
|
|
7
|
+
import { CanvasTexture, DefaultLoadingManager, EventDispatcher, Mesh, MeshStandardMaterial, Object3D, RepeatWrapping, TextureLoader, VideoTexture } from "three";
|
|
8
8
|
import { FBXLoader } from "three/examples/jsm/loaders/FBXLoader";
|
|
9
9
|
import { GLTFLoader } from "three/examples/jsm/loaders/GLTFLoader";
|
|
10
10
|
import { MTLLoader } from "three/examples/jsm/loaders/MTLLoader";
|
|
@@ -12,6 +12,9 @@ import { OBJLoader } from "three/examples/jsm/loaders/OBJLoader";
|
|
|
12
12
|
import { DRACOLoader } from "three/examples/jsm/loaders/DRACOLoader";
|
|
13
13
|
import { STLLoader } from "three/examples/jsm/loaders/STLLoader";
|
|
14
14
|
import { USDZLoader } from "three/examples/jsm/loaders/USDZLoader";
|
|
15
|
+
// import { IFCLoader } from 'web-ifc-three/dist/IFCLoader';
|
|
16
|
+
// import { IFCLoader } from 'web-ifc-three';
|
|
17
|
+
// import { IFCSPACE } from 'web-ifc';
|
|
15
18
|
// 引入静态资源
|
|
16
19
|
//@ts-ignore
|
|
17
20
|
import dracoWasmWrapperJS from "./lib/draco/draco_wasm_wrapper.js?url";
|
|
@@ -143,6 +146,18 @@ class ThreeLoader extends EventDispatcher {
|
|
|
143
146
|
console.error(`${url},加载失败`);
|
|
144
147
|
});
|
|
145
148
|
}
|
|
149
|
+
else if (["stl"].includes(suffix)) {
|
|
150
|
+
await threeLoader.stlLoader.loadAsync(url).then(geometry => {
|
|
151
|
+
Object3d = new Mesh(geometry, new MeshStandardMaterial({
|
|
152
|
+
color: "#f1fbff",
|
|
153
|
+
metalness: 0.79,
|
|
154
|
+
roughness: 0.56,
|
|
155
|
+
envMapIntensity: 0.4
|
|
156
|
+
}));
|
|
157
|
+
}).catch(() => {
|
|
158
|
+
console.error(`${url},加载失败`);
|
|
159
|
+
});
|
|
160
|
+
}
|
|
146
161
|
else if (["usdz"].includes(suffix)) {
|
|
147
162
|
await threeLoader.usdzLoader.loadAsync(url).then(res => {
|
|
148
163
|
Object3d = res; // usdz 目前还不支持骨骼动画
|
|
@@ -153,8 +168,8 @@ class ThreeLoader extends EventDispatcher {
|
|
|
153
168
|
mesh.material.transparent = true;
|
|
154
169
|
}
|
|
155
170
|
});
|
|
156
|
-
}).catch(() => {
|
|
157
|
-
console.error(`${url}
|
|
171
|
+
}).catch((err) => {
|
|
172
|
+
console.error(`${url},加载失败`, err);
|
|
158
173
|
});
|
|
159
174
|
}
|
|
160
175
|
else {
|
package/threeLoader.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* @Last Modified time: 2023-02-07 11:11:48
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import { CanvasTexture, DefaultLoadingManager, EventDispatcher, Material, Mesh, MeshLambertMaterial, Object3D, RepeatWrapping, SRGBColorSpace, Texture, TextureLoader, VideoTexture } from "three";
|
|
8
|
+
import { BoxGeometry, CanvasTexture, DefaultLoadingManager, EventDispatcher, Material, Mesh, MeshLambertMaterial, MeshStandardMaterial, Object3D, RepeatWrapping, SRGBColorSpace, Texture, TextureLoader, VideoTexture } from "three";
|
|
9
9
|
import { FBXLoader } from "three/examples/jsm/loaders/FBXLoader";
|
|
10
10
|
import { GLTFLoader } from "three/examples/jsm/loaders/GLTFLoader";
|
|
11
11
|
import { MTLLoader } from "three/examples/jsm/loaders/MTLLoader";
|
|
@@ -14,6 +14,10 @@ import { DRACOLoader } from "three/examples/jsm/loaders/DRACOLoader";
|
|
|
14
14
|
import { STLLoader } from "three/examples/jsm/loaders/STLLoader";
|
|
15
15
|
import { USDZLoader } from "three/examples/jsm/loaders/USDZLoader";
|
|
16
16
|
|
|
17
|
+
// import { IFCLoader } from 'web-ifc-three/dist/IFCLoader';
|
|
18
|
+
// import { IFCLoader } from 'web-ifc-three';
|
|
19
|
+
// import { IFCSPACE } from 'web-ifc';
|
|
20
|
+
|
|
17
21
|
|
|
18
22
|
// 引入静态资源
|
|
19
23
|
//@ts-ignore
|
|
@@ -172,6 +176,18 @@ class ThreeLoader extends EventDispatcher {
|
|
|
172
176
|
}).catch(() => {
|
|
173
177
|
console.error(`${url},加载失败`);
|
|
174
178
|
})
|
|
179
|
+
|
|
180
|
+
} else if (["stl"].includes(suffix)) {
|
|
181
|
+
await threeLoader.stlLoader.loadAsync(url).then(geometry => {
|
|
182
|
+
Object3d = new Mesh(geometry, new MeshStandardMaterial({
|
|
183
|
+
color: "#f1fbff",
|
|
184
|
+
metalness: 0.79,
|
|
185
|
+
roughness: 0.56,
|
|
186
|
+
envMapIntensity: 0.4
|
|
187
|
+
}));
|
|
188
|
+
}).catch(() => {
|
|
189
|
+
console.error(`${url},加载失败`);
|
|
190
|
+
})
|
|
175
191
|
} else if (["usdz"].includes(suffix)) {
|
|
176
192
|
await threeLoader.usdzLoader.loadAsync(url).then(res => {
|
|
177
193
|
Object3d = res; // usdz 目前还不支持骨骼动画
|
|
@@ -182,8 +198,8 @@ class ThreeLoader extends EventDispatcher {
|
|
|
182
198
|
(mesh.material as Material).transparent = true;
|
|
183
199
|
}
|
|
184
200
|
});
|
|
185
|
-
}).catch(() => {
|
|
186
|
-
console.error(`${url}
|
|
201
|
+
}).catch((err) => {
|
|
202
|
+
console.error(`${url},加载失败`, err);
|
|
187
203
|
})
|
|
188
204
|
} else {
|
|
189
205
|
if (suffix) {
|