大屏支持渲染3D模型
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import * as spritejs from 'spritejs'
|
||||
// import * as spritejs from 'spritejs'
|
||||
|
||||
export default {
|
||||
name: "AiSprite",
|
||||
@@ -21,20 +21,14 @@ export default {
|
||||
init(count = 0) {
|
||||
const container = this.$refs[this.ref]
|
||||
if (container) {
|
||||
let loadTasks = []
|
||||
let {width, height} = this.$props
|
||||
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})
|
||||
})
|
||||
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)
|
||||
@@ -44,7 +38,13 @@ export default {
|
||||
this.ref = "AiSprite_" + new Date().getTime()
|
||||
},
|
||||
mounted() {
|
||||
this.init()
|
||||
this.$injectLib("https://unpkg.com/spritejs/dist/spritejs.min.js", () => {
|
||||
if (this.is3D) {
|
||||
this.$injectLib("http://unpkg.com/sprite-extend-3d/dist/sprite-extend-3d.js", () => {
|
||||
this.init()
|
||||
})
|
||||
} else this.init()
|
||||
})
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user