• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript gl-matrix.mat4类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中gl-matrix.mat4的典型用法代码示例。如果您正苦于以下问题:TypeScript mat4类的具体用法?TypeScript mat4怎么用?TypeScript mat4使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: setup

export function setup() {
  // ProjectionView
  const projectionViewData = new Float32Array(mat4.create());

  uniformBuffers.projectionView = new UniformBuffer(projectionViewData);
}
开发者ID:davidpaulrosser,项目名称:leonardo,代码行数:6,代码来源:UniformBuffers.ts


示例2: Float32Array

let vecArray = new Float32Array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]);

let vec2A = vec2.fromValues(1, 2);
let vec2B = vec2.fromValues(3, 4);
let vec3A = vec3.fromValues(1, 2, 3);
let vec3B = vec3.fromValues(3, 4, 5);
let vec4A = vec4.fromValues(1, 2, 3, 4);
let vec4B = vec4.fromValues(3, 4, 5, 6);
let mat2A = mat2.fromValues(1, 2, 3, 4);
let mat2B = mat2.fromValues(1, 2, 3, 4);
let mat2dA = mat2d.fromValues(1, 2, 3, 4, 5, 6);
let mat2dB = mat2d.fromValues(1, 2, 3, 4, 5, 6);
let mat3A = mat3.fromValues(1, 2, 3, 4, 5, 6, 7, 8, 9);
let mat3B = mat3.fromValues(1, 2, 3, 4, 5, 6, 7, 8, 9);
let mat4A = mat4.fromValues(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16);
let mat4B = mat4.fromValues(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16);
let quatA = quat.fromValues(1, 2, 3, 4);
let quatB = quat.fromValues(5, 6, 7, 8);

let outVec2 = vec2.create();
let outVec3 = vec3.create();
let outVec4 = vec4.create();
let outMat2 = mat2.create();
let outMat2d = mat2d.create();
let outMat3 = mat3.create();
let outMat4 = mat4.create();
let outQuat = quat.create();

let outMat2Null: mat2 | null;
let outMat2dNull: mat2d | null;
开发者ID:ArtemZag,项目名称:DefinitelyTyped,代码行数:30,代码来源:gl-matrix-tests.ts


示例3: start_gl

export function start_gl(container: HTMLElement, perfCbk?: PerfHandler,
                         perfMode?: boolean): Update
{
  // Create a <canvas> element to do our drawing in. Then set it up to fill
  // the container and resize when the window resizes.
  let canvas = document.createElement('canvas');
  container.appendChild(canvas);
  function fit() {
    let width = container.clientWidth;
    let height = container.clientHeight;
    canvas.setAttribute('width', width + 'px');
    canvas.setAttribute('height', height + 'px');
  }
  window.addEventListener('resize', fit);
  fit();

  // Attach a `canvas-orbit-camera` thing, which handles user input for
  // manipulating the view.
  let camera = canvasOrbitCamera(canvas, {});

  // Initialize the OpenGL context with our rendering function.
  let gl = (canvas.getContext("webgl") ||
    canvas.getContext("experimental-webgl")) as WebGLRenderingContext;

  // Create the transform matrices. Alternatively, these can be created using
  // `new Float32Array(16)`.
  let projection = mat4.create();
  let view = mat4.create();

  // Performance measurement.
  let frame_count = 0;
  let last_sample = performance.now();
  let last_frame = performance.now();
  let sample_rate = 1000;  // Measure every second.
  let latencies: number[] = [];
  let draw_latencies: number[] = [0];
  function drawtime(ms: number) {
    if (perfCbk) {
      draw_latencies[draw_latencies.length - 1] += ms;
    }
  }

  // Initially, the SHFL function does nothing. The client needs to call us
  // back to fill in the function. Then, we will update this variable.
  let shfl_render: { proc: any, env: any } | null = null;

  // This function requests to render the next frame. In performance
  // measurement mode, we ask to run as quickly as possible. In ordinary mode,
  // we ask to run in the browser's render loop---i.e., only at a reasonable
  // frame rate like 60fps or whatever the browser likes.
  let nextFrame: () => void;
  if (perfMode) {
    nextFrame = () => setTimeout(render, 0);
  } else {
    nextFrame = () => window.requestAnimationFrame(render);
  }

  // A flag that, when set, saves the current image as a PNG.
  let download_image = false;

  // The main render loop.
  function render() {
    // Get the current size of the canvas.
    let width = gl.drawingBufferWidth;
    let height = gl.drawingBufferHeight;

    // Handle user input and update the resulting camera view matrix.
    camera.view(view);
    camera.tick();

    // Update the projection matrix for translating to 2D screen space.
    projection_matrix(projection, width, height);

    // Draw on the whole canvas.
    gl.viewport(0, 0, width, height);

    // Rendering flags.
    gl.depthFunc(gl.LESS);
    gl.enable(gl.DEPTH_TEST);  // Prevent triangle overlap.

    // Invoke the compiled SHFL code.
    let start = performance.now();
    if (shfl_render) {
      shfl_render.proc.apply(void 0, shfl_render.env);
    }
    let end = performance.now();

    // Framerate tracking.
    if (perfCbk) {
      ++frame_count;
      let now = performance.now();
      let elapsed = now - last_sample;  // Milliseconds.
      latencies.push(end - start);
      last_frame = now;
      if (elapsed > sample_rate) {
        perfCbk(frame_count, elapsed, latencies, draw_latencies);
        last_sample = performance.now();
        frame_count = 0;
        latencies = [];
        draw_latencies = [0];
//.........这里部分代码省略.........
开发者ID:sampsyo,项目名称:braid,代码行数:101,代码来源:gl.ts


示例4: constructor

 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import {mat4, vec3, vec4} from 'gl-matrix';

export {mat2, mat3, mat4, quat, vec2, vec3, vec4} from 'gl-matrix';

export type Vec2 = Float32Array;
export type Vec3 = Float32Array;
export type Vec4 = Float32Array;
export type Mat3 = Float32Array;
export type Mat4 = Float32Array;
export type Quat = Float32Array;

export const identityMat4 = mat4.create();

export const AXES_NAMES = ['x', 'y', 'z'];

export class BoundingBox {
  constructor(public lower: Vec3, public upper: Vec3) {}
};

export const kAxes =
    [vec4.fromValues(1, 0, 0, 0), vec4.fromValues(0, 1, 0, 0), vec4.fromValues(0, 0, 1, 0)];
export const kZeroVec = vec3.fromValues(0, 0, 0);
export const kInfinityVec = vec3.fromValues(Infinity, Infinity, Infinity);

export function prod3(x: ArrayLike<number>) {
  return x[0] * x[1] * x[2];
}
开发者ID:funkey,项目名称:neuroglancer,代码行数:31,代码来源:geom.ts


示例5: applyMatrix

 public applyMatrix(matrix: mat4) {
   vec3.transformMat4(this.center.v, this.center.v, matrix);
   const scaling = mat4.getScaling(vec3.create(), matrix);
   this.radius *= Math.max(scaling[0], scaling[1], scaling[2]);
 }
开发者ID:davidpaulrosser,项目名称:leonardo,代码行数:5,代码来源:Sphere.ts


示例6:

		view: () =>
			mat4.multiply(
				state.ground.groundMirrorView,
				state.viewPort.camera.viewMat,
				state.ground.mirrorMatrix as any,
			),
开发者ID:trivial-space,项目名称:playground,代码行数:6,代码来源:renderer.ts


示例7: _generateViewMatrix

 /**
  * Generate view matrix
  *
  * ビュー行列を生成します。
  */
 private _generateViewMatrix(): void {
   mat4.lookAt(this.viewMatrix.rawElements, this.Transformer.GlobalPosition.rawElements, Vector3.add(this.Transformer.forward, this.Transformer.GlobalPosition).rawElements, this.Transformer.up.rawElements);
 }
开发者ID:kyasbal-1994,项目名称:jThree,代码行数:8,代码来源:ViewCameraBase.ts



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript gl-matrix.quat类代码示例发布时间:2022-05-25
下一篇:
TypeScript gl-matrix.mat3类代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap