【发布时间】:2021-02-27 11:54:57
【问题描述】:
我真正想要的是把网格放在物体上,然后让相机聚焦在那个网格上。我认为他们使用lookAt函数来做到这一点,但我不知道如何正确使用它。
我从这个页面得到了帮助:https://www.babylonjs-playground.com/#1CSVHO#12
我尝试了一些函数演示。
setCamera_Mesh = () => {
let { currentWidth, currentDepth, rowCount } = this.currentConfig;
let sphere = Mesh.CreateSphere("sphere", 1, this.scene);
let referenceBox = Mesh.CreateBox("referenceBox", { width: 1, height: 1, depth: 1, updatable: true });
sphere.scaling = new Vector3(0.1, 0.1, 0.1);
sphere.position = this.scene.cameras[0].position;
sphere.parent = this.scene.cameras[0];
this.referenceBox && this.referenceBox.dispose()
referenceBox.position = new Vector3(0, 0, 0.08);
referenceBox.enableEdgesRendering();
referenceBox.edgesWidth = 1;
referenceBox.edgesColor = new Color4(0, 0, 1, 0.05);
referenceBox.visibility = 0.5;
referenceBox.scaling = new Vector3(currentDepth / 40, rowCount / 3, currentWidth / 100);
this.referenceBox = referenceBox;
sphere.lookAt(referenceBox.position);
}
【问题讨论】:
标签: reactjs camera mesh babylonjs