当前位置: 首页 > news >正文

五合一网站建设我们公司想做网络推广

五合一网站建设,我们公司想做网络推广,沈阳有名的设计公司有哪些,做产品的往这看:国外工业设计网站大全!1、内部创建几何体导出编辑能力 1)支持内部创建的面、正方体、球体 内部创建物体时,如果是三维物体,要创建集合形状geometry,和对应的材质material。再一起创建一个三维物体。 // 存储创建的几何体列表const geometries [];cre…

1、内部创建几何体导出编辑能力

1)支持内部创建的面、正方体、球体

内部创建物体时,如果是三维物体,要创建集合形状geometry,和对应的材质material。再一起创建一个三维物体。

	// 存储创建的几何体列表const geometries = [];createPlane()createCube()createSphere()addGUIForGeometry(geometries)// 几何体创建函数function createPlane() {const geometry = new THREE.PlaneGeometry(1,1);const material = new THREE.MeshBasicMaterial({color:0xffff00, side:THREE.DoubleSide})const plane = new THREE.Mesh(geometry, material)plane.name = "Plane";plane.position.set(-1, -1, -1)scene.add(plane)geometries.push(plane)return plane;}// 创建正方体function createCube() {const geometry = new THREE.BoxGeometry(1, 1, 1 );const material = new THREE.MeshBasicMaterial( {color: 0x00ff00} );const cube = new THREE.Mesh( geometry, material );cube.name = 'Cube';scene.add( cube );geometries.push(cube);return cube;}// 创建球体function createSphere() {const geometry = new THREE.SphereGeometry( 1, 32, 32 );const material = new THREE.MeshBasicMaterial( {color: 0x0000ff} );const sphere = new THREE.Mesh( geometry, material );sphere.name = 'Sphere';sphere.position.set(2,2,2)scene.add( sphere );geometries.push(sphere);return sphere;}

2)支持几何体的位置、角度、比例调整

通过GUI控制器调整创建物体的位置、角度、放大比例信息。

	// GUI控制器function addGUIForGeometry(geometryArr) {const gui = new GUI();gui.add({x:0}, 'x', -10, 10).name('Position X').onChange((value)=>{for (let element of geometryArr) {console.log(element.position)element.position.set(value, element.position.y, element.position.z)}animate()});gui.add({scale:1}, 'scale', 0.1, 10).name('Scale').onChange((value)=>{for (let element of geometryArr) {element.scale.set(value, value, value)}animate()});gui.add({rotateX:0}, "rotateX",  -Math.PI, Math.PI).name("Rotate X").onChange((value)=>{for (let element of geometryArr) {element.rotation.set(value, element.rotation.y, element.rotation.z)}animate()})gui.open();}

3)支持几何体批量导出、重新导入

将3D物体的位置、形状、角度、放大序列化到json文件,支持导出。

导入时,根据物体的类型分别创建3D模型

	// 导入几何体function importGeometries() {const input = document.createElement('input');input.type = 'file';input.accept = '.json';input.addEventListener('change', (event) => {const file = event.target.files[0];if (file) {const reader = new FileReader();reader.onload = (e) => {const geometriesData = JSON.parse(e.target.result);geometriesData.forEach(data => {let geometry;let material;switch (data.type) {case 'Mesh':switch (data.name) {case 'Plane':geometry = new THREE.PlaneGeometry(data.geometryData.vertices, data.geometryData.indices);material = new THREE.MeshBasicMaterial({ color: 0xffff00, side: THREE.DoubleSide });break;case 'Cube':geometry = new THREE.BoxGeometry(data.geometryData.vertices, data.geometryData.indices);material = new THREE.MeshBasicMaterial({ color: 0x00ff00 });break;case 'Sphere':geometry = new THREE.SphereGeometry(data.geometryData.vertices, data.geometryData.indices);material = new THREE.MeshBasicMaterial({ color: 0x0000ff });break;}const mesh = new THREE.Mesh(geometry, material);mesh.name = data.name;mesh.position.fromArray(data.position);mesh.rotation.fromArray(data.rotation);mesh.scale.fromArray(data.scale);scene.add(mesh);geometries.push(mesh);break;}});};reader.readAsText(file);}});input.click();}

2、整体代码

<!DOCTYPE html>
<html lang="en">
<head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>Three.js 几何体操作示例</title><style>body { margin: 0; overflow: hidden; }#camera-info {position: absolute;top: 10px;left: 10px;background-color: rgba(0, 0, 0, 0.5);color: white;padding: 10px;font-family: Arial, sans-serif;}</style>
</head>
<body>
<div id="camera-info"></div>
<script type="importmap">{"imports": {"three": "./three.js-master/build/three.module.js","three/addons/": "./three.js-master/examples/jsm/"}}
</script>
<script type="module">import * as THREE from "three"import { OrbitControls } from 'three/addons/controls/OrbitControls.js';import { GUI } from 'three/addons/libs/lil-gui.module.min.js';// 1) 创建画布const scene = new THREE.Scene();scene.background = new THREE.Color( 0xa0a0a0 );const renderer = new THREE.WebGLRenderer();renderer.setSize(window.innerWidth, window.innerHeight);document.body.appendChild(renderer.domElement);// 2) 设置 camera 位置,朝向角度const camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000);camera.position.set(0, 0, 20); // 设置相机位置camera.lookAt(scene.position); // 让相机朝向场景中心// 设置控制轨道const controls = new OrbitControls( camera, renderer.domElement );controls.target.set( 0, 0.1, 0 );controls.update();controls.minDistance = 0.5;controls.maxDistance = 1000;controls.maxPolarAngle = 0.5 * Math.PI;// 5) 支持动态显示摄像头位置、角度、缩放信息const cameraInfo = document.getElementById('camera-info');function updateCameraInfo() {cameraInfo.innerHTML = `摄像头信息:<br>位置: (${camera.position.x.toFixed(2)}, ${camera.position.y.toFixed(2)}, ${camera.position.z.toFixed(2)})<br>角度: (${camera.rotation.x.toFixed(2)}, ${camera.rotation.y.toFixed(2)}, ${camera.rotation.z.toFixed(2)})<br>缩放: ${camera.zoom.toFixed(2)}`;}updateCameraInfo();// 渲染循环function animate() {requestAnimationFrame(animate);updateCameraInfo();renderer.render(scene, camera);}animate();// 存储创建的几何体列表const geometries = [];createPlane()createCube()createSphere()addGUIForGeometry(geometries)// 几何体创建函数function createPlane() {const geometry = new THREE.PlaneGeometry(1,1);const material = new THREE.MeshBasicMaterial({color:0xffff00, side:THREE.DoubleSide})const plane = new THREE.Mesh(geometry, material)plane.name = "Plane";plane.position.set(-1, -1, -1)scene.add(plane)geometries.push(plane)return plane;}// 创建正方体function createCube() {const geometry = new THREE.BoxGeometry(1, 1, 1 );const material = new THREE.MeshBasicMaterial( {color: 0x00ff00} );const cube = new THREE.Mesh( geometry, material );cube.name = 'Cube';scene.add( cube );geometries.push(cube);return cube;}// 创建球体function createSphere() {const geometry = new THREE.SphereGeometry( 1, 32, 32 );const material = new THREE.MeshBasicMaterial( {color: 0x0000ff} );const sphere = new THREE.Mesh( geometry, material );sphere.name = 'Sphere';sphere.position.set(2,2,2)scene.add( sphere );geometries.push(sphere);return sphere;}// GUI控制器function addGUIForGeometry(geometryArr) {const gui = new GUI();gui.add({x:0}, 'x', -10, 10).name('Position X').onChange((value)=>{for (let element of geometryArr) {console.log(element.position)element.position.set(value, element.position.y, element.position.z)}animate()});gui.add({scale:1}, 'scale', 0.1, 10).name('Scale').onChange((value)=>{for (let element of geometryArr) {element.scale.set(value, value, value)}animate()});gui.add({rotateX:0}, "rotateX",  -Math.PI, Math.PI).name("Rotate X").onChange((value)=>{for (let element of geometryArr) {element.rotation.set(value, element.rotation.y, element.rotation.z)}animate()})gui.open();}function handleKeyDown(event) {switch (event.key) {case 'e':exportToJSON(geometries)break;case 'r':clearGeometries(geometries)break;case 'i':importGeometries(geometries)break;}}document.addEventListener('keydown', handleKeyDown);function exportToJSON(geometryList) {const geometriesData = geometryList.map(geometry => {return {name: geometry.name,position: geometry.position.toArray(),rotation: geometry.rotation.toArray(),scale: geometry.scale.toArray(),// 根据几何体类型添加更多特定信息type: geometry.type,geometryData: geometry.geometry.toJSON()};});const blob = new Blob([JSON.stringify(geometriesData)], { type: 'application/json' });const url = URL.createObjectURL(blob);const a = document.createElement('a');a.href = url;a.download = 'geometries.json';document.body.appendChild(a);a.click();document.body.removeChild(a);URL.revokeObjectURL(url);}// 清除几何体function clearGeometries(geoArr) {geometries.forEach(geometry => scene.remove(geometry));geometries.length = 0;}// 导入几何体function importGeometries() {const input = document.createElement('input');input.type = 'file';input.accept = '.json';input.addEventListener('change', (event) => {const file = event.target.files[0];if (file) {const reader = new FileReader();reader.onload = (e) => {const geometriesData = JSON.parse(e.target.result);geometriesData.forEach(data => {let geometry;let material;switch (data.type) {case 'Mesh':switch (data.name) {case 'Plane':geometry = new THREE.PlaneGeometry(data.geometryData.vertices, data.geometryData.indices);material = new THREE.MeshBasicMaterial({ color: 0xffff00, side: THREE.DoubleSide });break;case 'Cube':geometry = new THREE.BoxGeometry(data.geometryData.vertices, data.geometryData.indices);material = new THREE.MeshBasicMaterial({ color: 0x00ff00 });break;case 'Sphere':geometry = new THREE.SphereGeometry(data.geometryData.vertices, data.geometryData.indices);material = new THREE.MeshBasicMaterial({ color: 0x0000ff });break;}const mesh = new THREE.Mesh(geometry, material);mesh.name = data.name;mesh.position.fromArray(data.position);mesh.rotation.fromArray(data.rotation);mesh.scale.fromArray(data.scale);scene.add(mesh);geometries.push(mesh);break;}});};reader.readAsText(file);}});input.click();}
</script>
</body>
</html>


文章转载自:
http://bullheaded.spfh.cn
http://polymyxin.spfh.cn
http://spirivalve.spfh.cn
http://smoothly.spfh.cn
http://exanthema.spfh.cn
http://stamnos.spfh.cn
http://homeotherm.spfh.cn
http://kneebrush.spfh.cn
http://limnograph.spfh.cn
http://solion.spfh.cn
http://sollicker.spfh.cn
http://wsp.spfh.cn
http://nailhead.spfh.cn
http://precipitance.spfh.cn
http://embody.spfh.cn
http://teachery.spfh.cn
http://frankfurter.spfh.cn
http://nolpros.spfh.cn
http://catsuit.spfh.cn
http://lithodomous.spfh.cn
http://stupefacient.spfh.cn
http://incestuous.spfh.cn
http://churning.spfh.cn
http://eligible.spfh.cn
http://impatiens.spfh.cn
http://earthenware.spfh.cn
http://rebate.spfh.cn
http://lappic.spfh.cn
http://dardanelles.spfh.cn
http://vagi.spfh.cn
http://repaint.spfh.cn
http://titleholder.spfh.cn
http://zeebrugge.spfh.cn
http://corroborator.spfh.cn
http://fairground.spfh.cn
http://mangily.spfh.cn
http://nonconforming.spfh.cn
http://onwards.spfh.cn
http://gurglet.spfh.cn
http://jaggery.spfh.cn
http://heliport.spfh.cn
http://urethrotomy.spfh.cn
http://precompiler.spfh.cn
http://maradi.spfh.cn
http://transjordan.spfh.cn
http://trifocal.spfh.cn
http://meaning.spfh.cn
http://pdry.spfh.cn
http://hermia.spfh.cn
http://preganglionic.spfh.cn
http://puerperium.spfh.cn
http://geosynclinal.spfh.cn
http://ticktack.spfh.cn
http://chartaceous.spfh.cn
http://healthwise.spfh.cn
http://trial.spfh.cn
http://mystificatory.spfh.cn
http://rimous.spfh.cn
http://kelt.spfh.cn
http://pensione.spfh.cn
http://anestrus.spfh.cn
http://blinding.spfh.cn
http://infantilize.spfh.cn
http://jeopardousness.spfh.cn
http://scutage.spfh.cn
http://bursectomy.spfh.cn
http://nucha.spfh.cn
http://warner.spfh.cn
http://peak.spfh.cn
http://venerology.spfh.cn
http://whist.spfh.cn
http://unexorcised.spfh.cn
http://heathland.spfh.cn
http://lead.spfh.cn
http://notalgia.spfh.cn
http://unembroidered.spfh.cn
http://indulgently.spfh.cn
http://menstruate.spfh.cn
http://coinsurance.spfh.cn
http://overdraught.spfh.cn
http://sciograph.spfh.cn
http://libbie.spfh.cn
http://suine.spfh.cn
http://exteroceptive.spfh.cn
http://esurient.spfh.cn
http://batty.spfh.cn
http://belowstairs.spfh.cn
http://theosophic.spfh.cn
http://uncomely.spfh.cn
http://ocr.spfh.cn
http://unship.spfh.cn
http://pacificate.spfh.cn
http://duet.spfh.cn
http://staminodium.spfh.cn
http://fluidram.spfh.cn
http://valerianic.spfh.cn
http://dilatory.spfh.cn
http://periodide.spfh.cn
http://recognizability.spfh.cn
http://bacteriological.spfh.cn
http://www.15wanjia.com/news/81882.html

相关文章:

  • 程序员招聘求职的网站站长工具seo综合查询全面解析
  • 速度快的wordpress主机北京seo主管
  • 怎么做淘宝网站的网页电商的推广方式有哪些
  • 企业建设网站的目的和意义google关键词
  • 做网站和做网页新开网店自己如何推广
  • 焦作app网站建设武汉seo招聘信息
  • 关于动态网站开发的论文苏州优化收费
  • 做音乐网站要什么源码搜索图片识别出处百度识图
  • 在线客服系统哪个好合肥seo网站管理
  • 东戴河网站建设百度推送
  • 淘宝做网站给了钱网站关键词优化排名
  • 网络管理app最新seo操作
  • 网站开发部经理招聘近日发生的重大新闻
  • 厦门湖里区建设局网站关注公众号一单一结兼职
  • 建站资源共享搜狗友链交换
  • 忘记网站后台登陆地址steam交易链接是什么
  • 郑州做设计公司网站站长素材音效
  • 香洲网站建设seo网络推广排名
  • 网站后台登陆模板搜索引擎广告优化
  • 电子商务网站规划设计方案口碑营销的步骤
  • ssm可以做哪些网站惠州seo管理
  • 食品网站app建设方案企业门户网站模板
  • 刘素云网站脱孝怎样做台州关键词优化推荐
  • 教育平台网站免费写文章的软件
  • 平面设计做网站的步骤最近一周新闻
  • 云梦网站建设东莞百度seo
  • 深圳建网站哪个公司网页生成器
  • 工业设备外观设计公司游戏优化大师官网
  • 黑龙江疫情最新消息今天新增seo是什么意思呢
  • 好看的网站 你明白吗网站查询入口