【问题标题】:Don't know how to access ParametricGeometry in Three.js不知道如何在 Three.js 中访问 ParametricGeometry
【发布时间】:2022-01-26 03:14:26
【问题描述】:

我尝试研究如何访问 ParametricGeometry,因为每次尝试使用它时都会收到此消息“THREE.ParametricGeometry 已移至 /examples/jsm/geometries/ParametricGeometry.js”

任何想法将不胜感激。

【问题讨论】:

  • 也许import {ParametricGeometry} from 'https://threejs.org/examples/jsm/geometries/ParametricGeometry.js' ?
  • 感谢您的建议,但不幸的是,它似乎仍然不起作用。也许生病检查不同的框架或其他东西......
  • 听起来你正准备换车,但你却找不到钥匙孔来启动它的引擎,而你只需要按下一个按钮 :)
  • 是的...你说得对,我最终通过使用

标签: javascript three.js


【解决方案1】:

这是一个使用文档构建的工作示例:

body{
  overflow: hidden;
  margin: 0;
}
<script type="module">
import * as THREE from "https://cdn.skypack.dev/three@0.136.0";
import {OrbitControls} from "https://cdn.skypack.dev/three@0.136.0/examples/jsm/controls/OrbitControls";
import {ParametricGeometry} from "https://cdn.skypack.dev/three@0.136.0/examples/jsm/geometries/ParametricGeometry";
import {ParametricGeometries} from "https://cdn.skypack.dev/three@0.136.0/examples/jsm/geometries/ParametricGeometries";

let scene = new THREE.Scene();
let camera = new THREE.PerspectiveCamera(60, innerWidth / innerHeight, 1, 1000);
camera.position.setScalar(10);
let renderer = new THREE.WebGLRenderer();
renderer.setSize(innerWidth, innerHeight);
document.body.appendChild(renderer.domElement);

let contorls = new OrbitControls(camera, renderer.domElement);

const geometry = new ParametricGeometry( ParametricGeometries.klein, 25, 25 );
const material = new THREE.MeshBasicMaterial( { map: new THREE.TextureLoader().load("https://threejs.org/examples/textures/uv_grid_opengl.jpg") } );
const klein = new THREE.Mesh( geometry, material );
scene.add( klein );

renderer.setAnimationLoop(() => {
  renderer.render(scene, camera);
});
</script>

【讨论】:

  • 谢谢,这似乎完美地完成了这项工作,非常感谢。
猜你喜欢
  • 1970-01-01
  • 2018-11-26
  • 2011-12-27
  • 2018-09-08
  • 2017-05-29
  • 2021-02-18
  • 1970-01-01
  • 1970-01-01
  • 2018-02-17
相关资源
最近更新 更多