本文整理汇总了TypeScript中THREE.WebGLRenderer.setPixelRatio方法的典型用法代码示例。如果您正苦于以下问题:TypeScript WebGLRenderer.setPixelRatio方法的具体用法?TypeScript WebGLRenderer.setPixelRatio怎么用?TypeScript WebGLRenderer.setPixelRatio使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类THREE.WebGLRenderer
的用法示例。
在下文中一共展示了WebGLRenderer.setPixelRatio方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: initCubeScene
initCubeScene() {
var camera, scene, renderer;
var mesh;
camera = new THREE.PerspectiveCamera(70, window.innerWidth / window.innerHeight, 1, 1000);
camera.position.z = 400;
scene = new THREE.Scene();
//var texture = new THREE.TextureLoader().load('textures/crate.gif');
var geometry = new THREE.BoxBufferGeometry(200, 200, 200);
//var material = new THREE.MeshBasicMaterial({ map: texture });
mesh = new THREE.Mesh(geometry);
scene.add(mesh);
renderer = new THREE.WebGLRenderer();
renderer.setPixelRatio(window.devicePixelRatio);
renderer.setSize(window.innerWidth, window.innerHeight);
document.body.appendChild(renderer.domElement);
window.addEventListener('resize', onWindowResize, false);
animate();
function onWindowResize() {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);
}
function animate() {
requestAnimationFrame(animate);
mesh.rotation.x += 0.005;
mesh.rotation.y += 0.01;
renderer.render(scene, camera);
}
}
示例2: require
( { require, cache, detached } ) => {
const THREE = require ( 'THREE' )
const container = document.getElementById ( 'screen' )
const screen: Screen = container.getBoundingClientRect ()
if ( !cache.renderer ) {
const renderer = new THREE.WebGLRenderer ( { antialias: true } )
renderer.setPixelRatio ( window.devicePixelRatio )
renderer.setSize ( screen.width, screen.height )
container.appendChild ( renderer.domElement )
cache.renderer = renderer
cache.camera = new THREE.PerspectiveCamera
( 60, screen.width / screen.height, 0.1, 100 )
}
const renderer = cache.renderer
const camera = cache.camera
if ( detached ) {
container.removeChild ( renderer.domElement )
}
camera.position.z = 2
camera.aspect = screen.width / screen.height
camera.updateProjectionMatrix ()
renderer.setSize ( screen.width, screen.height )
return { renderer, camera, screen }
}
示例3: createRenderer
createRenderer() {
var renderer = new THREE.WebGLRenderer({ alpha: true, antialias: true });
renderer.setPixelRatio(window.devicePixelRatio);
renderer.setClearColor('#ebe5e7');
renderer.setSize(this.WIDTH, this.HEIGHT);
renderer.shadowMap.enabled = true;
return renderer;
}
示例4:
this.hasProp("devicePixelRatio", (instance: WebGLRenderer,
newValue: number): void => {
instance.setPixelRatio(newValue);
});