Skip to content

Commit

Permalink
update build files
Browse files Browse the repository at this point in the history
  • Loading branch information
king2088 committed Sep 12, 2023
1 parent a874491 commit 1bb60c5
Show file tree
Hide file tree
Showing 7 changed files with 120 additions and 86 deletions.
2 changes: 1 addition & 1 deletion dist/style.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions dist/types/3dLoader/vue3dLoader.vue.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Object3D, Vector2, Scene, Raycaster, WebGLRenderer, PerspectiveCamera, Clock, Light } from "three";
import { Object3D, Vector2, Scene, Raycaster, WebGLRenderer, PerspectiveCamera, AnimationMixer, Clock, Light } from "three";
import { OrbitControls } from "three/examples/jsm/controls/OrbitControls";
export interface coordinates {
x: number;
Expand Down Expand Up @@ -212,7 +212,7 @@ declare const _default: import("vue").DefineComponent<{
loader: any;
requestAnimationId: number;
stats: any;
mixer: any;
mixers: AnimationMixer | AnimationMixer[];
textureLoader: any;
size: import("vue").Ref<{
width: number;
Expand Down Expand Up @@ -258,6 +258,8 @@ declare const _default: import("vue").DefineComponent<{
generateCanvas: (text: string, style: any) => HTMLCanvasElement;
getObjectIndex: (object: any) => any;
playAnimations: () => void;
playSingleModel: (item: Object3D) => void;
playMultipleModels: (obj: Object3D) => void;
}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("mousedown" | "mousemove" | "mouseup" | "click" | "dblclick" | "load" | "process" | "error")[], "mousedown" | "mousemove" | "mouseup" | "click" | "dblclick" | "load" | "process" | "error", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
filePath: {
type: (StringConstructor | ArrayConstructor)[];
Expand Down
4 changes: 3 additions & 1 deletion dist/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ declare const _default: {
loader: any;
requestAnimationId: number;
stats: any;
mixer: any;
mixers: Three.AnimationMixer | Three.AnimationMixer[];
textureLoader: any;
size: import("vue").Ref<{
width: number;
Expand Down Expand Up @@ -256,6 +256,8 @@ declare const _default: {
generateCanvas: (text: string, style: any) => HTMLCanvasElement;
getObjectIndex: (object: any) => any;
playAnimations: () => void;
playSingleModel: (item: Three.Object3D<Three.Event>) => void;
playMultipleModels: (obj: Three.Object3D<Three.Event>) => void;
}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("mousedown" | "mousemove" | "mouseup" | "click" | "dblclick" | "load" | "process" | "error")[], "mousedown" | "mousemove" | "mouseup" | "click" | "dblclick" | "load" | "process" | "error", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
filePath: {
type: (StringConstructor | ArrayConstructor)[];
Expand Down
56 changes: 28 additions & 28 deletions dist/vue-3d-loader.cjs.js

Large diffs are not rendered by default.

78 changes: 54 additions & 24 deletions dist/vue-3d-loader.esm.js
Original file line number Diff line number Diff line change
Expand Up @@ -40831,7 +40831,7 @@ const _sfc_main = defineComponent({
let loader = null;
let requestAnimationId = 0;
let stats = null;
let mixer = null;
let mixers = null;
let textureLoader = null;
const size = ref({ width: props.width || 0, height: props.height || 0 });
const loaderIndex = ref(0);
Expand Down Expand Up @@ -40885,7 +40885,14 @@ const _sfc_main = defineComponent({
playAnimations();
});
onMounted(() => {
const { filePath, outputEncoding, webGLRendererOptions, showFps, enableDamping, dampingFactor } = props;
const {
filePath,
outputEncoding,
webGLRendererOptions,
showFps,
enableDamping,
dampingFactor
} = props;
if (filePath && typeof filePath === "object") {
isMultipleModels.value = true;
}
Expand Down Expand Up @@ -41136,9 +41143,9 @@ const _sfc_main = defineComponent({
if (!filePath)
return;
const index2 = fileIndex || loaderIndex.value;
const filePathStrng = !isMultipleModels.value ? filePath : filePath[index2];
const filePathString = !isMultipleModels.value ? filePath : filePath[index2];
const fileTypeString = typeof fileType === "string" ? fileType : fileType ? fileType[index2] : "";
const loaderObject3d = getLoader(filePathStrng, fileTypeString, enableDraco2, dracoDir);
const loaderObject3d = getLoader(filePathString, fileTypeString, enableDraco2, dracoDir);
loader = loaderObject3d.loader;
const getObjectFun = loaderObject3d.getObject ? loaderObject3d.getObject : getObject;
if (object && index2 === 0) {
Expand All @@ -41153,16 +41160,16 @@ const _sfc_main = defineComponent({
if (mtlPath) {
const isMultipleMTL = typeof mtlPath === "object";
if (!isMultipleMTL) {
loadMtl(filePathStrng, getObjectFun, index2);
loadMtl(filePathString, getObjectFun, index2);
} else {
if (!mtlPath[index2]) {
loadFilePath(filePathStrng, getObjectFun, index2);
loadFilePath(filePathString, getObjectFun, index2);
return;
}
loadMtl(filePathStrng, getObjectFun, index2);
loadMtl(filePathString, getObjectFun, index2);
}
} else {
loadFilePath(filePathStrng, getObjectFun, index2);
loadFilePath(filePathString, getObjectFun, index2);
}
}
function loadFilePath(filePath, getObject2, index2) {
Expand Down Expand Up @@ -41230,8 +41237,14 @@ const _sfc_main = defineComponent({
requestAnimationId = requestAnimationFrame(animate);
updateStats();
const delta = clock.getDelta();
if (mixer)
mixer.update(delta);
if (mixers && mixers instanceof AnimationMixer) {
mixers.update(delta);
}
if (mixers && mixers instanceof Array) {
mixers.forEach((m) => {
m.update(delta);
});
}
render();
}
function render() {
Expand Down Expand Up @@ -41398,16 +41411,40 @@ const _sfc_main = defineComponent({
return objIndex;
}
function playAnimations() {
const { autoPlay } = props;
const obj = getAllObject();
if (!obj)
return;
const play = (item) => {
mixer = new AnimationMixer(obj);
if (item.animations) {
if (isMultipleModels.value) {
playMultipleModels(obj);
return;
}
playSingleModel(obj);
}
function playSingleModel(item) {
const { autoPlay } = props;
mixers = new AnimationMixer(item);
if (item.animations && item.animations.length > 0) {
item.animations.forEach((clip) => {
if (clip) {
const action = mixers.clipAction(clip);
if (autoPlay) {
action.play();
} else {
action.stop();
}
}
});
}
}
function playMultipleModels(obj) {
const { autoPlay } = props;
mixers = [];
obj.children.forEach((item, index2) => {
mixers.push(new AnimationMixer(item));
if (item.animations && item.animations.length > 0) {
item.animations.forEach((clip) => {
if (clip) {
const action = mixer.clipAction(clip);
const action = mixers[index2].clipAction(clip);
if (autoPlay) {
action.play();
} else {
Expand All @@ -41416,14 +41453,7 @@ const _sfc_main = defineComponent({
}
});
}
};
if (isMultipleModels.value) {
obj.children.forEach((item) => {
play(item);
});
return;
}
play(obj);
});
}
return (_ctx, _cache) => {
return openBlock(), createElementBlock("div", {
Expand All @@ -41440,7 +41470,7 @@ const _sfc_main = defineComponent({
};
}
});
var vue3dLoader = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-07257ca0"]]);
var vue3dLoader = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-04ca652e"]]);
const install = (app) => {
app.component(vue3dLoader.name, vue3dLoader);
};
Expand Down
58 changes: 29 additions & 29 deletions dist/vue-3d-loader.global.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "vue-3d-loader",
"private": false,
"version": "2.1.0",
"version": "2.1.1",
"main": "dist/vue-3d-loader.cjs.js",
"module": "dist/vue-3d-loader.esm.js",
"types": "dist/types/index.d.ts",
Expand Down

0 comments on commit 1bb60c5

Please sign in to comment.