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


TypeScript WebGLRenderer.setSize方法代码示例

本文整理汇总了TypeScript中THREE.WebGLRenderer.setSize方法的典型用法代码示例。如果您正苦于以下问题:TypeScript WebGLRenderer.setSize方法的具体用法?TypeScript WebGLRenderer.setSize怎么用?TypeScript WebGLRenderer.setSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在THREE.WebGLRenderer的用法示例。


在下文中一共展示了WebGLRenderer.setSize方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1:

/// <reference path="../../typings/main.d.ts" />

import * as THREE from 'three';
import * as _ from 'lodash';

var renderer: THREE.Renderer = new THREE.WebGLRenderer({
	antialias: true,
	alpha: true,
	precision: 'lowp'
});

renderer.setSize(window.innerWidth, window.innerHeight);
document.body.appendChild(renderer.domElement);

var camera: THREE.Camera = new THREE.OrthographicCamera(
	window.innerWidth / - 2,
	window.innerWidth / 2,
	window.innerHeight / 2,
	window.innerHeight / - 2,
	-1000,
	1000
);

camera.position.set(0, 0, 0);
camera.lookAt(new THREE.Vector3(0, 0, 0));

var scene: THREE.Scene = new THREE.Scene();

var material: any = new THREE.LineBasicMaterial({
	color: 0x2586D3,
	linewidth: 2
开发者ID:egorovsa,项目名称:simple-2D-gl,代码行数:31,代码来源:app.ts

示例2: animate

import * as OrbitControls from 'three-orbitcontrols';
import * as THREE from 'three';

const width = window.innerWidth;
const height = window.innerHeight;

const scene = new THREE.Scene();
const camera = new THREE.PerspectiveCamera(75, width/height, 0.1, 1000);

const renderer = new THREE.WebGLRenderer();
renderer.setSize(width, height);
document.body.appendChild(renderer.domElement);

const geometry = new THREE.BoxGeometry(1, 1, 1);
const material = new THREE.MeshBasicMaterial({ color: 0x00ff00 });
const cube = new THREE.Mesh(geometry, material);
scene.add(cube);

camera.position.z = 5;

const controls = new OrbitControls(camera, renderer.domElement);

function animate() {
  requestAnimationFrame(animate);

  cube.rotation.x += 0.01;
  cube.rotation.y += 0.01;

  renderer.render(scene, camera);
}
开发者ID:fibo,项目名称:three-orbitcontrols,代码行数:30,代码来源:index.ts

示例3: createThreeObj

const renderer = (state: State) => {
  let r = new THREE.WebGLRenderer()
  r.setSize(window.innerWidth, window.innerHeight)
  document.body.appendChild(r.domElement)
  createThreeObj(state, 'renderer', r)
}
开发者ID:wwju,项目名称:economics_game,代码行数:6,代码来源:init.ts

示例4: WebGLRenderer

const renderer = new WebGLRenderer();
const camera =
    new PerspectiveCamera(
        VIEW_ANGLE,
        ASPECT,
        NEAR,
        FAR
    );

const scene = new Scene();

// Add the camera to the scene.
scene.add(camera);

// Start the renderer.
renderer.setSize(WIDTH, HEIGHT);

// Attach the renderer-supplied
// DOM element.
document.body.appendChild(renderer.domElement);

const Orientation = {
    UP: new Vector3(0, 1, 0),
    DOWN: new Vector3(0, -1, 0),
    LEFT: new Vector3(-1, 0, 0),
    RIGHT: new Vector3(1, 0, 0)
};


let playerOrientation = Orientation.RIGHT;
开发者ID:nbabanov,项目名称:threejs-playground,代码行数:30,代码来源:main.ts

示例5: onWindowResize

 function onWindowResize() {
     camera.aspect = window.innerWidth / window.innerHeight;
     camera.updateProjectionMatrix();
     renderer.setSize(window.innerWidth, window.innerHeight);
 }
开发者ID:pinuchfab,项目名称:nlytethreejs,代码行数:5,代码来源:cabinet-view.ts

示例6: animate

function animate(time: number) {
  animationId = requestAnimationFrame(animate);

  if (previousTime != null) {
    const elapsedTime = time - previousTime;
    accumulatedTime = Math.min(accumulatedTime + elapsedTime, maxAccumulatedTime);
  }
  previousTime = time;

  const ticks = Math.floor(accumulatedTime / clientTickDuration);
  accumulatedTime -= ticks * clientTickDuration;

  if (pub != null && pub.match == null) {
    sceneAngleY += Math.PI / 640;
  } else {
    if (Math.abs(sceneAngleY) > 0.1) sceneAngleY = lerp(sceneAngleY, 0, 0.15);
    else sceneAngleY = 0;
  }
  if (sceneAngleY > Math.PI) sceneAngleY -= Math.PI * 2;
  scene.setRotationFromEuler(tmpEuler.set(0, sceneAngleY, 0));

  let width = canvas.parentElement.clientWidth;
  let height = canvas.parentElement.clientHeight;
  if (width > height * 4 / 3) width = height * 4 / 3;
  if (height > width * 3 / 4) height = width * 3 / 4;

  canvas.width = width;
  canvas.height = height;

  camera.updateProjectionMatrix();

  threeRenderer.setSize(canvas.width, canvas.height, false);
  threeRenderer.render(scene, camera);

  input.gather();
  if (input.hasJustPressedLeftTrigger) { socket.emit("throwBall"); }

  for (const playerId in modelsById) {
    const model = modelsById[playerId];
    const { avatar } = players.byId[playerId];
    const hasBall = pub.ball.playerId === playerId;

    model.nametag.setRotationFromEuler(tmpEuler.set(0, -sceneAngleY, 0));

    if (playerId === myPlayerId) {
      for (let i = 0; i < ticks; i++) input.predict(pub.match != null, pub.ball.playerId === myPlayerId, ballThrownTimer > 0);

      model.root.position.set(input.prediction.x, 0, input.prediction.z);
      model.body.setRotationFromEuler(tmpEuler.set(0, -input.prediction.angleY, 0));
      model.shoulders.setRotationFromEuler(tmpEuler.set(0, 0, input.prediction.catching || hasBall ? input.prediction.angleX : -Math.PI * 0.4));
    } else {
      // TODO: Lerp between previous and current!
      model.root.position.set(avatar.x, 0, avatar.z);
      model.body.setRotationFromEuler(tmpEuler.set(0, -avatar.angleY, 0));
      model.shoulders.setRotationFromEuler(tmpEuler.set(0, 0, avatar.catching || hasBall ? avatar.angleX : -Math.PI * 0.4));
    }

    model.root.position.y = shared.getAvatarY(avatar.jump);
  }

  if (pub != null && pub.ball.playerId == null) {
    ballModel.position.set(pub.ball.x, pub.ball.y, pub.ball.z);
    ballMarker.position.set(pub.ball.x, 0.01, pub.ball.z);
  }
}
开发者ID:elisee,项目名称:bball,代码行数:65,代码来源:index.ts


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