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


TypeScript WebGLRenderer.render方法代码示例

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


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

示例1: animate

/**
 * Main animation loop
 */
function animate() {
    requestAnimationFrame(animate);

    now = performance.now();
    deltaTime = now - lastFrame;

    if (deltaTime >= snakeSpeed) {
        lastFrame = now;

        snake.move(playerOrientation);

        if (snake.getPosition().x > frustrumWidth) {
            snake.setPosition(new Vector3(-frustrumWidth, snake.getPosition().y));
        } else if (snake.getPosition().x < -frustrumWidth) {
            snake.setPosition(new Vector3(frustrumWidth, snake.getPosition().y));
        }

        if (snake.getPosition().y > frustrumHeight) {
            snake.setPosition(new Vector3(snake.getPosition().x, -frustrumHeight));
        } else if (snake.getPosition().y < -frustrumHeight) {
            snake.setPosition(new Vector3(snake.getPosition().x, frustrumHeight));
        }

        renderer.render(scene, camera);
    }
}
开发者ID:nbabanov,项目名称:threejs-playground,代码行数:29,代码来源:main.ts

示例2: animate

function animate() {
  requestAnimationFrame(animate);

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

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

示例3: constructor

 constructor(rendererSettings: THREE.WebGLRendererParameters = {},
             cameraSettings: PerspectiveCameraParameters = {}){
   super();
   this.addClass('ThreeRendererWidget');
   this._scene = new THREE.Scene();
   this._canvas = document.createElement('canvas');
   $(this._canvas).css({position: "absolute"});
   rendererSettings.canvas = this._canvas;
   this._renderer = new THREE.WebGLRenderer(rendererSettings);
   this._camera = new THREE.PerspectiveCamera(cameraSettings.fov,
                                              cameraSettings.aspect,
                                              cameraSettings.near,
                                              cameraSettings.far);
   this._scene.add(this._camera);
   this._renderer.render(this._scene, this._camera);
   this.node.appendChild(this._canvas);
 }
开发者ID:wheeler-microfluidics,项目名称:Microdrop-3.0,代码行数:17,代码来源:widgets.ts

示例4: getWrappedAttributes

    const renderFunction = (scene: Scene, camera: Camera, renderTarget?: RenderTarget, forceClear?: boolean) => {
      const oldWarn = window.console.warn;

      // get rid of useless message but warn about everything else
      window.console.warn = (...args: string[]) => {
        if (args.length === 2
          && args[0] === "THREE.WebGLProgram: gl.getProgramInfoLog()"
          && args[1].match(/^\s*$/) !== null) {
          return;
        }

        oldWarn.call(window.console, ...args);
      };

      rendererInstance.render(scene, camera, renderTarget, forceClear);

      window.console.warn = oldWarn;

      // redefine to wrap
      Object.defineProperty(this.wrapper, "render", getWrappedAttributes(property, rendererInstance, "render"));
    };
开发者ID:sychuginaanna,项目名称:react-three-renderer-fiber,代码行数:21,代码来源:webGLRenderer.ts

示例5: render

function render() {
	requestAnimationFrame(render);

	// line.rotation.x += 0.01;
	// line.rotation.y += 0.01;
	// shapeMesh.rotation.y += 0.01;

	geometry.vertices = [];

	points[renderIteration].forEach((point) => {
		geometry.vertices.push(new THREE.Vector3(worldX(point[0]), worldY(point[1])));
	});
	geometry.verticesNeedUpdate = true;

	renderer.render(scene, camera);

	renderIteration++;

	if (renderIteration > 2) {
		renderIteration = 0;
	}
}
开发者ID:egorovsa,项目名称:simple-2D-gl,代码行数:22,代码来源:app.ts

示例6: requestAnimationFrame

const animate = () => {
  cube.rotation.x += 0.01;
  cube.rotation.y += 0.01;
  renderer.render(scene, camera);
  requestAnimationFrame(animate);
};
开发者ID:dandart,项目名称:projects,代码行数:6,代码来源:index.ts

示例7:

const geometry = new THREE.SphereGeometry(sphereRadius, numSegments, numSegments)
const attributes = {
  displacement: {
    type: 'f'
  , value: []
  }
}


const sceneObjects = [
  , new THREE.Mesh(geometry, unlitMaterial)
  , new THREE.Mesh(geometry, fakeLitMaterial)
  , new THREE.Mesh(attributes, geometry, morphingFakeLitMaterial)
]
const sceneObjectOffset:number = 50
const centeredContentOffset:number = Math.floor(sceneObjects.length / 2) * sphereDiameter * -1
sceneObjects.reduce((offset, mesh) => {
  mesh.position.set(offset, 100, 100)
  scene.add(mesh)

  offset += sphereDiameter + sceneObjectOffset
  return offset

}, centeredContentOffset)

attributes.displacement.value = geometry.vertices.map(() => Math.random() * 30)
renderer.setSize(window.innerWidth, window.innerHeight)
camera.position.z = 500
document.body.appendChild(renderer.domElement)
renderer.render(scene, camera)
开发者ID:agconti,项目名称:intro-webgl,代码行数:30,代码来源:main.ts

示例8: animate

 public animate() {
   window.requestAnimationFrame(_ => this.animate());
   this.controls.update();
   this.renderer.render(this.scene, this.camera);
 }
开发者ID:NomadHu,项目名称:first_steps,代码行数:5,代码来源:render-service.ts

示例9: 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

示例10: render

function render(): void {
	let timer = 0.002 * Date.now()
	box.position.y = 0.5 + 0.5 * Math.sin(timer)
	box.rotation.x += 0.1
	renderer.render(scene, camera)
}
开发者ID:pinqy520,项目名称:three-typescript-starter,代码行数:6,代码来源:index.ts


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