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