最后
推荐一些系统学习的途径和方法。
每个Web开发人员必备,很权威很齐全的Web开发文档。作为学习辞典使用,可以查询到每个概念、方法、属性的详细解释,注意使用英文关键字搜索。里面的一些 HTML,CSS,HTTP 技术教程也相当不错。
开源分享:【大厂前端面试题解析+核心总结学习笔记+真实项目实战+最新讲解视频】
HTML 和 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)
};
},
})