view3d-core 1.1.0 → 1.1.1
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/dist/index.cjs +19 -19
- package/dist/index.d.ts +2 -0
- package/dist/index.js +10 -10
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const e = require("three"), t = require("gsap"), s = require("./SerializationPlugin-IbKL3PYe.cjs"), i = require("three/examples/jsm/
|
|
3
|
+
const e = require("three"), t = require("gsap"), s = require("./SerializationPlugin-IbKL3PYe.cjs"), i = require("three/examples/jsm/loaders/GLTFLoader.js"), n = require("three/examples/jsm/loaders/DRACOLoader.js"), r = require("three/examples/jsm/loaders/FBXLoader.js"), o = require("three/examples/jsm/loaders/OBJLoader.js"), a = require("three/examples/jsm/utils/BufferGeometryUtils.js");
|
|
4
4
|
function c(e2) {
|
|
5
5
|
const t2 = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
6
6
|
if (e2) {
|
|
@@ -658,7 +658,7 @@ exports.AnimationPlugin = s.AnimationPlugin, exports.CSSRendererPlugin = s.CSSRe
|
|
|
658
658
|
});
|
|
659
659
|
}
|
|
660
660
|
}), { meshCount: t2, triangleCount: Math.floor(s2), vertexCount: i2, materialCount: n2.size, textureCount: r2.size };
|
|
661
|
-
}, exports.getSupportedFormats = S, exports.isSupportedFormat = C, exports.loadModelFromFile = async function(t2, s2 = {},
|
|
661
|
+
}, exports.getSupportedFormats = S, exports.isSupportedFormat = C, exports.loadModelFromFile = async function(t2, s2 = {}, a2) {
|
|
662
662
|
const c2 = t2.name, l2 = P(c2);
|
|
663
663
|
if (!l2 || !C(c2)) throw new Error(`不支持的文件格式: ${l2 || "未知"}。支持的格式: ${["glb", "gltf", "fbx", "obj"].join(", ")}`);
|
|
664
664
|
const h2 = l2, p2 = URL.createObjectURL(t2);
|
|
@@ -666,33 +666,33 @@ exports.AnimationPlugin = s.AnimationPlugin, exports.CSSRendererPlugin = s.CSSRe
|
|
|
666
666
|
let t3, l3 = [];
|
|
667
667
|
if ("glb" === h2 || "gltf" === h2) {
|
|
668
668
|
const e2 = await (async function(e3, t4, s3) {
|
|
669
|
-
return new Promise((
|
|
670
|
-
const
|
|
671
|
-
|
|
672
|
-
const l4 = new
|
|
673
|
-
false !== t4.useDraco && l4.setDRACOLoader(
|
|
674
|
-
|
|
669
|
+
return new Promise((r2, o2) => {
|
|
670
|
+
const a3 = new n.DRACOLoader(), c3 = t4.dracoPath || w;
|
|
671
|
+
a3.setDecoderPath(c3), a3.setDecoderConfig({ type: "js" });
|
|
672
|
+
const l4 = new i.GLTFLoader();
|
|
673
|
+
false !== t4.useDraco && l4.setDRACOLoader(a3), l4.load(e3, (e4) => {
|
|
674
|
+
a3.dispose(), r2(e4);
|
|
675
675
|
}, (e4) => {
|
|
676
676
|
s3 && e4.lengthComputable && s3({ loaded: e4.loaded, total: e4.total, percent: e4.loaded / e4.total * 100 });
|
|
677
677
|
}, (e4) => {
|
|
678
|
-
|
|
678
|
+
a3.dispose(), o2(e4);
|
|
679
679
|
});
|
|
680
680
|
});
|
|
681
|
-
})(p2, s2,
|
|
681
|
+
})(p2, s2, a2);
|
|
682
682
|
t3 = e2.scene, l3 = e2.animations || [];
|
|
683
683
|
} else "fbx" === h2 ? (t3 = await (async function(e2, t4) {
|
|
684
|
-
return new Promise((s3,
|
|
685
|
-
new
|
|
684
|
+
return new Promise((s3, i2) => {
|
|
685
|
+
new r.FBXLoader().load(e2, (e3) => s3(e3), (e3) => {
|
|
686
686
|
t4 && e3.lengthComputable && t4({ loaded: e3.loaded, total: e3.total, percent: e3.loaded / e3.total * 100 });
|
|
687
|
-
}, (e3) =>
|
|
687
|
+
}, (e3) => i2(e3));
|
|
688
688
|
});
|
|
689
|
-
})(p2,
|
|
690
|
-
return new Promise((s3,
|
|
691
|
-
new
|
|
689
|
+
})(p2, a2), l3 = t3.animations || []) : t3 = await (async function(e2, t4) {
|
|
690
|
+
return new Promise((s3, i2) => {
|
|
691
|
+
new o.OBJLoader().load(e2, (e3) => s3(e3), (e3) => {
|
|
692
692
|
t4 && e3.lengthComputable && t4({ loaded: e3.loaded, total: e3.total, percent: e3.loaded / e3.total * 100 });
|
|
693
|
-
}, (e3) =>
|
|
693
|
+
}, (e3) => i2(e3));
|
|
694
694
|
});
|
|
695
|
-
})(p2,
|
|
695
|
+
})(p2, a2);
|
|
696
696
|
t3.name = c2;
|
|
697
697
|
const d2 = new e.Box3().setFromObject(t3), g2 = d2.getCenter(new e.Vector3());
|
|
698
698
|
return { model: t3, fileName: c2, format: h2, boundingBox: { center: g2, size: d2.getSize(new e.Vector3()), min: d2.min.clone(), max: d2.max.clone() }, animations: l3 };
|
|
@@ -702,7 +702,7 @@ exports.AnimationPlugin = s.AnimationPlugin, exports.CSSRendererPlugin = s.CSSRe
|
|
|
702
702
|
}, exports.mergeStaticGeometries = function(e2, t2 = false) {
|
|
703
703
|
if (0 === e2.length) return null;
|
|
704
704
|
try {
|
|
705
|
-
return
|
|
705
|
+
return a.mergeGeometries(e2, t2);
|
|
706
706
|
} catch (e3) {
|
|
707
707
|
return null;
|
|
708
708
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -22,6 +22,8 @@ export { EnvironmentPlugin } from './plugins/environment';
|
|
|
22
22
|
export { SerializationPlugin } from './plugins/serialization';
|
|
23
23
|
export { GUIPlugin } from './plugins/gui';
|
|
24
24
|
export * from './utils';
|
|
25
|
+
export { loadModelFromFile, selectModelFile, calculateBestCameraPosition, isSupportedFormat, getSupportedFormats } from './utils/fileLoader';
|
|
26
|
+
export type { SupportedModelFormat, FileLoaderConfig, FileLoadProgress, FileLoadResult } from './utils/fileLoader';
|
|
25
27
|
export type { EngineConfig, RendererConfig, CameraConfig, ComposerConfig, OrbitControllerConfig, TransformControllerConfig, LoaderConfig, EditorPluginConfig, ThreeEditorConfig, ScreenshotOptions } from './types/config.types';
|
|
26
28
|
export type { HandlerMode, ModelType, DrawMode, PointMode, ParticleSportType, RenderWay, LoaderService, RootInfo, ClickInfo, ViewAngle, Box3Info, TransformInfo, CurveAnimationController, AnimationPlayParams, ExtendedObject3D, GeoInfo, RaycastResult, GsapQuery } from './types/core.types';
|
|
27
29
|
export type { EventMap, EventCallback, Unsubscribe } from './types/event.types';
|
package/dist/index.js
CHANGED
|
@@ -3,11 +3,11 @@ import { Scene as t, CubeTextureLoader as i, Mesh as n, Light as r, PerspectiveC
|
|
|
3
3
|
import I from "gsap";
|
|
4
4
|
import { I as D, J as O, a as B, O as T, T as F, L as H, C as K, f as J, E as ee, t as te, w as se, K as ie } from "./SerializationPlugin-BGlmM0W4.js";
|
|
5
5
|
import { A, k, u, m, G, M, o, q, P, v, S, s, W, $, a3, V, Z, X, a2, Y, U, N, Q, a0, _, R, a1 } from "./SerializationPlugin-BGlmM0W4.js";
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
6
|
+
import { GLTFLoader as ne } from "three/examples/jsm/loaders/GLTFLoader.js";
|
|
7
|
+
import { DRACOLoader as re } from "three/examples/jsm/loaders/DRACOLoader.js";
|
|
8
|
+
import { FBXLoader as ae } from "three/examples/jsm/loaders/FBXLoader.js";
|
|
9
|
+
import { OBJLoader as oe } from "three/examples/jsm/loaders/OBJLoader.js";
|
|
10
|
+
import { mergeGeometries as ce } from "three/examples/jsm/utils/BufferGeometryUtils.js";
|
|
11
11
|
class he {
|
|
12
12
|
constructor() {
|
|
13
13
|
this.listeners = /* @__PURE__ */ new Map();
|
|
@@ -617,7 +617,7 @@ function Se(e2, t2, s2, i2) {
|
|
|
617
617
|
function Pe(e2, t2 = false) {
|
|
618
618
|
if (0 === e2.length) return null;
|
|
619
619
|
try {
|
|
620
|
-
return
|
|
620
|
+
return ce(e2, t2);
|
|
621
621
|
} catch (e3) {
|
|
622
622
|
return null;
|
|
623
623
|
}
|
|
@@ -680,9 +680,9 @@ async function De(e2, t2 = {}, s2) {
|
|
|
680
680
|
if ("glb" === r2 || "gltf" === r2) {
|
|
681
681
|
const i3 = await (async function(e4, t3, s3) {
|
|
682
682
|
return new Promise((i4, n4) => {
|
|
683
|
-
const r3 = new
|
|
683
|
+
const r3 = new re(), a5 = t3.dracoPath || Le;
|
|
684
684
|
r3.setDecoderPath(a5), r3.setDecoderConfig({ type: "js" });
|
|
685
|
-
const o3 = new
|
|
685
|
+
const o3 = new ne();
|
|
686
686
|
false !== t3.useDraco && o3.setDRACOLoader(r3), o3.load(e4, (e5) => {
|
|
687
687
|
r3.dispose(), i4(e5);
|
|
688
688
|
}, (e5) => {
|
|
@@ -695,13 +695,13 @@ async function De(e2, t2 = {}, s2) {
|
|
|
695
695
|
e3 = i3.scene, n3 = i3.animations || [];
|
|
696
696
|
} else "fbx" === r2 ? (e3 = await (async function(e4, t3) {
|
|
697
697
|
return new Promise((s3, i3) => {
|
|
698
|
-
new
|
|
698
|
+
new ae().load(e4, (e5) => s3(e5), (e5) => {
|
|
699
699
|
t3 && e5.lengthComputable && t3({ loaded: e5.loaded, total: e5.total, percent: e5.loaded / e5.total * 100 });
|
|
700
700
|
}, (e5) => i3(e5));
|
|
701
701
|
});
|
|
702
702
|
})(a4, s2), n3 = e3.animations || []) : e3 = await (async function(e4, t3) {
|
|
703
703
|
return new Promise((s3, i3) => {
|
|
704
|
-
new
|
|
704
|
+
new oe().load(e4, (e5) => s3(e5), (e5) => {
|
|
705
705
|
t3 && e5.lengthComputable && t3({ loaded: e5.loaded, total: e5.total, percent: e5.loaded / e5.total * 100 });
|
|
706
706
|
}, (e5) => i3(e5));
|
|
707
707
|
});
|