body { margin: 0; padding: 0; }
#loading {
position: fixed;
left: 1rem;
bottom: 1rem;
color: #fff;
font-family: Helvetica, Arial, sans-serif;
text-transform: uppercase;
} <script type="text/javascript" src="js/three.min.js"></script>
<script type="text/javascript" src="js/orbitcontrols.js"></script>
<div id="loading">视频加载中...</div> console.clear()
class VideoTexture {
constructor (width = 256, height = 128) {
this.video = document.createElement('video')
this.videoLoaded = false
this.canvas = document.createElement('canvas')
this.ctx = this.canvas.getContext('2d')
this.width = this.canvas.width = width
this.height = this.canvas.height = height
this.canvas.style.transform = 'scale(0.85, 0.85)'
this.canvas.style.transformOrigin = '0 0 0'
this.canvas.style.position = 'fixed'
this.canvas.style.top = this.canvas.style.left = '1rem'
document.body.appendChild(this.canvas)
this.ctx.fillStyle = '#111'
this.ctx.textAlign = 'center'
this.ctx.font = '30px Helvetica'
this.ctx.fillText('视频加载中...', this.canvas.width / 2, this.canvas.height / 2 + 10)
this.video.src = './video/ninja.3gp'
this.video.onloadedmetadata = e => {
this.video.play()
this.video.loop = true
this.videoLoaded = true
let loadText = document.querySelector('#loading')
loadText.parentNode.removeChild(loadText)
}
this.video.width = this.width
this.video.height = this.height
this.video.crossOrigin = "Anonymous"
}
updateFrame () {
if (this.videoLoaded === true) {
this.ctx.drawImage(this.video, 0, 0, this.width, this.height)
}
}
}
*
回帖描述:*
链接类型:*
下载链接:*
描述:*
回帖描述:*
链接类型:*
阅读权限:*
下载链接:



聚优部落技术论坛 © 版权所有 鲁ICP备15007479号-6
Copyright(C)web.com, All Rights Reserved.
