当前位置:网站首页>[three.js] Web3D first experience
[three.js] Web3D first experience
2022-06-30 00:50:00 【Justkang front end】
What is? three.js
The reasons for the company's current project needs , I want to learn web Large screen visualization , In addition to showing some charts , We also need to show some buildings 3D Model , therefore webGL three.js
These two nouns entered the vocabulary of my brain . It's like opening the door to a new world , Discover the special effects of many websites (github The great earth of ) All are three.js
Written , Let's explore together
vite To start a vue3 project ( Just practice vue3+ts)
npm init [email protected] my-vue-app --template vue
vite Really fast 
npm install three.js
npm i three
// vue introduce
import * as THREE from 'three';
Write one of mine according to the official website 3D Model
// demo1.js //
import * as THREE from 'three';
// Create a scene
const scene = new THREE.Scene();
// Create a camera ( Four parameters :FOV( The scope of the scene Company : degree ), Aspect ratio ,near( near ), far( far ))
const camera = new THREE.PerspectiveCamera( 75, window.innerWidth / window.innerHeight, 0.1, 1000 );
// Create a renderer
const renderer = new THREE.WebGLRenderer();
// Sets the size of the renderer
renderer.setSize( window.innerWidth/2,window.innerHeight/2 );
// Hang the renderer to body On This is what the renderer uses to show us the scene <canvas> Elements .
document.body.appendChild( renderer.domElement );
// The geometric
const geometry = new THREE.BoxGeometry( 2, 2, 10 );
// material
const material = new THREE.MeshBasicMaterial( {
color: 0xFF0000 } );
// Data sets
const cube = new THREE.Mesh( geometry, material );
scene.add( cube );
camera.position.z = 10;
// cube.rotation.x = 5;
// cube.rotation.y = 5;
function animate() {
requestAnimationFrame( animate );
cube.rotation.x += 0.01;
cube.rotation.y += 0.01;
renderer.render( scene, camera );
}
animate();
export default animate
<template>
</template>
<script setup lang="ts"> import animate from "./three/demo1.js"; animate(); </script>
<style> * {
padding: 0; margin: 0; } #app {
font-family: Avenir, Helvetica, Arial, sans-serif; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; text-align: center; color: #2c3e50; margin-top: 60px; } </style>
effect

边栏推荐
- Quick Pow: 如何快速求幂
- Comment personnaliser les modèles et générer rapidement le code complet dans l'idée?
- 练习副“产品”:自制七彩提示字符串展示工具(for循环、if条件判断)
- 利用huggingface进行文本分类
- How to switch to root in xshell
- Which securities company is better and which platform is safer for stock speculation account opening
- Modbus TCP RTU protocol chart
- 岁月匆匆那年
- Which securities company is better and which platform is safer for stock speculation account opening
- 一些生活的思考
猜你喜欢

在线文本数字识别列表求和工具

Which direction of network development is better? Data communication engineer learning path sharing

Comment personnaliser les modèles et générer rapidement le code complet dans l'idée?

外包干了三年,废的一踏糊涂...

TwinCAT 3 EL7211模块控制倍福伺服

Botu V16 changes the model and firmware version of PLC

利用tsne将不同句子关于相似度可视化出来

TwinCAT 3 EL7211模塊控制倍福伺服

简单的页面

xshell中怎么切换到root用户
随机推荐
[qnx hypervisor 2.2 user manual]6.2.2 communication between guest and host
Relevance - canonical correlation analysis
The SQL statement concat cannot find the result
2022 6 月25 日交易总结
初始I/O及其基本操作
Netease cloud music beta music social app "mus" matches friends of the same frequency through music
Outsourcing for 3 years is a waste
[spark] basic Scala operations (continuous update)
MySQL deadlock
Which direction of network development is better? Data communication engineer learning path sharing
ML:置信区间的简介(精密度/准确度/精确度的三者区别及其关系)、使用方法、案例应用之详细攻略
In 2022, the latest and most detailed idea associated database method and visual operation of database in idea (including graphic process)
YuMinHong: my retreat and advance; The five best software architecture patterns that architects must understand; Redis kills 52 consecutive questions | manong weekly VIP member exclusive email weekly
php微信商家转账到零钱 发起商家转账API
科创人·味多美CIO胡博:数字化是不流血的革命,正确答案藏在业务的田间地头
IDEA中的常用设置
Le module twincat 3 el7211 contrôle les servocommandes baffle
latex如何输入一个矩阵
TwinCAT 3 EL7211模塊控制倍福伺服
Good test / development programmers vs. average programmers