0
圖像中的上述canvas
是大但scene
小。如何使scene
或scene
中的3D對象變大並且可能匹配canvas
的高度和寬度?
代碼:
import React, { Component } from 'react';
import React3 from 'react-three-renderer';
import * as THREE from 'three';
class Graph3D extends Component {
constructor(props, context) {
super(props, context);
this.cameraPosition = new THREE.Vector3(0, 0, 5);
this.state = {
origin: new THREE.Vector3(0, 0, 0),
vector1: new THREE.Vector3(0, 0.5, 0.5),
vector2: new THREE.Vector3(0.2, 0.3, 0.1),
vector3: new THREE.Vector3(0.2, 0.4, 0.1),
vector4: new THREE.Vector3(0.6, 0.8, 0),
vector5: new THREE.Vector3(0.9, 0.9, 0.9),
vector6: new THREE.Vector3(0.2, 0.8, 0.9),
};
}
render() {
const width = window.innerWidth; // canvas width
const height = window.innerHeight; // canvas height
return (<React3
mainCamera="camera" // this points to the perspectiveCamera which has the name set to "camera" below
width={width}
height={height}
clearColor={'#ffffff'}
>
<scene>
<perspectiveCamera
name="camera"
fov={75}
aspect={width/height}
near={0.1}
far={1000}
position={this.cameraPosition}
/>
<arrowHelper
origin={this.state.origin}
dir={this.state.vector1}
/>
<arrowHelper
origin={this.state.origin}
dir={this.state.vector2}
/>
<arrowHelper
origin={this.state.origin}
dir={this.state.vector3}
/>
<arrowHelper
origin={this.state.origin}
dir={this.state.vector4}
/>
<arrowHelper
origin={this.state.origin}
dir={this.state.vector5}
/>
<arrowHelper
origin={this.state.origin}
dir={this.state.vector6}
/>
</scene>
</React3>);
}
}
隨着canvas
上面這段代碼獲取screen
的尺寸,但由於某種原因,我所有的arrowHelpers
和我scene
小的比較。
如何讓它們變大?
我試着給我的Vectors
分配較大的值,但是沒有幫助。
謝謝,但它非常像素化。我如何防止這種情況發生?試圖閱讀文檔,但有這麼多的信息 - 我試圖與fov'''''''''''''''''''''''''附近道具,但沒有幫助很多 – user2456977