From 352ae43faa21298e594a4d6e3325eba3650bd212 Mon Sep 17 00:00:00 2001 From: aixianling Date: Tue, 28 Jun 2022 15:48:12 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=A7=E5=B1=8F=E6=94=AF=E6=8C=81=E6=B8=B2?= =?UTF-8?q?=E6=9F=933D=E6=A8=A1=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- project/dvui/components/AiSprite.vue | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/project/dvui/components/AiSprite.vue b/project/dvui/components/AiSprite.vue index 7aab59a1..1c82a319 100644 --- a/project/dvui/components/AiSprite.vue +++ b/project/dvui/components/AiSprite.vue @@ -10,6 +10,7 @@ export default { props: { width: {default: 400}, height: {default: 300}, + is3D: Boolean }, data() { return { @@ -20,14 +21,20 @@ export default { init(count = 0) { const container = this.$refs[this.ref] if (container) { + let loadTasks = [] let {width, height} = this.$props - const scene = new spritejs.Scene({container, width, height, ...this.$attrs}), - layer = scene.layer() - /** - * layer 图层 - * lib spritejs的依赖库 - */ - this.$emit("init", {layer, lib: spritejs}) + if (this.is3D) { + loadTasks.push(this.$injectLib("https://unpkg.com/sprite-extend-3d/dist/sprite-extend-3d.js")) + } + Promise.all(loadTasks).then(() => { + const scene = new spritejs.Scene({container, width, height, ...this.$attrs}), + layer = scene.layer() + /** + * layer 图层 + * lib spritejs的依赖库 + */ + this.$emit("init", {layer, lib: spritejs}) + }) } else if (count == 20) { console.log(this.$refs) } else setTimeout(() => this.init(++count), 500)