当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript WebGLRenderer.setPixelRatio方法代码示例

本文整理汇总了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);
        }
    }
开发者ID:pinuchfab,项目名称:nlytethreejs,代码行数:33,代码来源:cabinet-view.ts

示例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 }
}
开发者ID:lucidogen,项目名称:lucy-library,代码行数:31,代码来源:three.WebGLRenderer.ts

示例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;
 }
开发者ID:403177368,项目名称:all,代码行数:8,代码来源:index.ts

示例4:

 this.hasProp("devicePixelRatio", (instance: WebGLRenderer,
                                   newValue: number): void => {
   instance.setPixelRatio(newValue);
 });
开发者ID:sychuginaanna,项目名称:react-three-renderer-fiber,代码行数:4,代码来源:webGLRenderer.ts


注:本文中的THREE.WebGLRenderer.setPixelRatio方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。