Web前端最全vue3的three场景加入背景图_vue3 threejs scene 设置背景图片(2),2024年最新阿里三面通过然后一直等

最后

推荐一些系统学习的途径和方法。

路线图

每个Web开发人员必备,很权威很齐全的Web开发文档。作为学习辞典使用,可以查询到每个概念、方法、属性的详细解释,注意使用英文关键字搜索。里面的一些 HTML,CSS,HTTP 技术教程也相当不错。

开源分享:【大厂前端面试题解析+核心总结学习笔记+真实项目实战+最新讲解视频】

HTML 和 CSS:

html5知识

css基础知识

import {OrbitControls} from ‘three/examples/jsm/controls/OrbitControls’
import { defineComponent, onMounted, reactive, toRefs} from ‘vue’;
export default defineComponent({
setup () {
console.log(THREE)
const state = reactive({
controls:null
})
const render = () =>{
//1.创建场景
scene = new THREE.Scene();
//场景创建背景色
const sceneLoader = new THREE.TextureLoader();
const sceneColorTexture = sceneLoader.load(“./1008.png”);

   scene.background = sceneColorTexture
   //2.创建相机
   camera = new THREE.PerspectiveCamera(35,window.innerWidth/window.innerHeight,0.1,1000);
   //设置相机位置
   camera.position.set(0,0,10);
   scene.add(camera);
   //3.定义材质贴图
   const textureLoader = new THREE.TextureLoader();
   const doorColorTexture = textureLoader.load("./1002.png");
   
   //4.添加物体
   const cubeGeometry = new THREE.ConeGeometry(1,2,32);
   //材质
   const basicMaterial = new THREE.MeshBasicMaterial({
    map:doorColorTexture
   })
   cube = new THREE.Mesh(cubeGeometry,basicMaterial);
   scene.add(cube);

   //5.初始化渲染器
   renderer = new THREE.WebGLRenderer();
   //设置渲染器尺寸大小
   renderer.setSize(window.innerWidth,window.innerHeight);
   //将webgl渲染的canvas内容添加到div
   let container = document.getElementById('container');
   container.appendChild(renderer.domElement);
   //使用渲染器 通过相机将场景渲染出来
   renderer.render(scene,camera);
   
   console.log(OrbitControls);
   state.controls = new OrbitControls(camera,renderer.domElement);
}
const animate = () => {
    requestAnimationFrame(animate);
    renderer.render(scene,camera);
}
onMounted(()=>{
    render()
    animate()
})
return {
    ...toRefs(state)
};

},

})

  • 3
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值