我是三年级的初学者.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);
});
}
}