我是三年级的初学者.js和我用的是Angular 13和三.js v0.137.0.

我导入了.ply文件,我试图在编辑器中以https://threejs.org/editor的速度预览,它加载相同的文件.完美的锉刀.how the file renders in three.js editor

我做错了什么?

public createScene(canvas: ElementRef<HTMLCanvasElement>, source: string): void {
const dataURL = `data:application/octet-stream;base64,${source}`;
this.canvas = canvas.nativeElement;

this.renderer = new THREE.WebGLRenderer({
  canvas: this.canvas,
  alpha: true,    // transparent background
  antialias: true // smooth edges
});
this.renderer.setSize((window.innerWidth / 2), (window.innerHeight / 2));

this.scene = new THREE.Scene();

this.light = new THREE.AmbientLight(0x443333);
this.light.position.z = 10;

this.camera = new THREE.PerspectiveCamera(
  45, window.innerWidth / window.innerHeight, 0.1, 1000
);

this.camera.position.z = 0.5;
this.renderer.setSize((window.innerWidth / 2), (window.innerHeight / 2));
this.scene.add(this.camera);
this.scene.add(this.light);
if (source) {
  this.loader.load(dataURL, (geometry) => {
    geometry.center();
    geometry.computeVertexNormals();
    this.mesh = new THREE.Mesh(geometry, new THREE.PointsMaterial( { size: 0.01, vertexColors: true } ));
    this.scene.add(this.mesh);
  });
}

}

推荐答案

this.mesh = new THREE.Mesh(geometry, new THREE.PointsMaterial( { size: 0.01, vertexColors: true } ));

由于正在加载点云,因此创建THREE.Mesh的实例是不正确的.用THREE.Points代替.

当几何体表示点云时,也不需要调用computeVertexNormals().

Javascript相关问答推荐

如何使用3个部件之间的路由?

错误:找不到react-redux上下文值;请确保该组件包装在React原生Expo应用程序中的提供者中

鼠标移动时更新画布

调用SEARCH函数后,程序不会结束

如何让\w token 在此RegEx中表现得不贪婪?

在JavaScript中,是否有一种方法可以创建自定义thable,在等待某些代码后自动触发它?

如何访问react路由v6加载器函数中的查询参数/搜索参数

vanillajs-datepicker未设置输入值,日期单击时未触发更改事件

如何使用侧边滚动按钮具体滚动每4个格?

Cypress -使用commands.js将数据测试id串在一起失败,但在将它们串在一起时不使用命令有效

IMDB使用 puppeteer 加载更多按钮(nodejs)

我应该绑定不影响状态的函数吗?'

无法检测卡片重叠状态的问题

从包含数百行的表中获取更改后的值(以表单形式发送到后端)的正确方法是什么?

我可以使用空手道用户界面来获取网页的当前滚动位置吗?

JavaScript不重定向配置的PATH

将范围 Select 器添加到HighChart面积图

未捕获语法错误:Hello World中的令牌无效或意外

在JavaScript中将Base64转换为JSON

在ChartJS中使用spanGaps时,是否获取空值的坐标?