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


TypeScript mat4.create方法代码示例

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


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

示例1: constructor

 constructor() {
   this.children = [];
   this.localMatrix = mat4.create();
   this.modelMatrix = mat4.create();
   this.modelViewMatrix = mat4.create();
   this.matrixAutoUpdate = true;
   this.position = new Vector3();
   this.rotation = new Vector3();
   this.scale = new Vector3(1, 1, 1);
   this.isObject3D = true;
   this.quaternion = quat.create();
   this.quaternionLookAt = quat.create();
   this.lookAtUp = vec3.create(); // needs to be [0, 0, 0] although it should be [0, 1, 0]
 }
开发者ID:davidpaulrosser,项目名称:leonardo,代码行数:14,代码来源:Object3D.ts

示例2: constructor

 constructor(options: Options) {
   this.projectionMatrix = mat4.create();
   this.worldInverseMatrix = mat4.create();
   this.isCamera = true;
   this.isPespectiveCamera = false;
   this.isOrthographicCamera = false;
   this.near = 0.1;
   this.far = 100;
   this.fov = 70;
   this.aspect = RENDERER_DEFAULT_RATIO;
   this.position = new Vector3();
   this.target = new Vector3();
   this.up = new Vector3(0, 1, 0);
   Object.assign(this, options);
 }
开发者ID:davidpaulrosser,项目名称:leonardo,代码行数:15,代码来源:Camera.ts

示例3: example

function example(canvas: HTMLCanvasElement) {
  // Get the WebGL context.
  let gl = (canvas.getContext("webgl") ||
    canvas.getContext("experimental-webgl")) as WebGLRenderingContext;

  // Load a Braid runtime object.
  let assets = {};
  let rt = glrt(gl, assets, (n) => {});

  // A projection matrix.
  let projection = mat4.create();
  (rt as any).projection = projection;

  // Get the compiled Braid code's render function.
  let braid_render = braid_func(rt);

  // The main render loop.
  function render() {
    // Draw on the whole canvas.
    let width = gl.drawingBufferWidth;
    let height = gl.drawingBufferHeight;
    gl.viewport(0, 0, width, height);

    // Update projection matrix.
    projection_matrix(projection, width, height);

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

    // Invoke the compiled Braid code.
    braid_render.proc.apply(void 0, braid_render.env);

    // Ask to be run again.
    window.requestAnimationFrame(render);
  }

  // Start the first frame.
  window.requestAnimationFrame(render);
}
开发者ID:sampsyo,项目名称:braid,代码行数:40,代码来源:example.ts

示例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;
let outMat3Null: mat3 | null;
let outMat4Null: mat4 | null;

// vec2
outVec2 = vec2.create();
outVec2 = vec2.clone(vec2A);
outVec2 = vec2.fromValues(1, 2);
outVec2 = vec2.copy(outVec2, vec2A);
outVec2 = vec2.set(outVec2, 1, 2);
outVec2 = vec2.add(outVec2, vec2A, vec2B);
outVec2 = vec2.subtract(outVec2, vec2A, vec2B);
开发者ID:DenisCarriere,项目名称:DefinitelyTyped,代码行数:31,代码来源:gl-matrix-tests.ts

示例5: constructor

 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

export {vec2, vec3, vec4, mat3, mat4, quat} from 'gl-matrix';
import {vec3, vec4, mat4} 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();
mat4.identity(identityMat4);

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 function prod3(x: ArrayLike<number>) {
开发者ID:j6k4m8,项目名称:neuroglancer,代码行数:31,代码来源:geom.ts

示例6: create

  public create(geometry: Geometry, transformFeedbackVaryings?: string[]) {
    gl = GL.get();

    this.vertexShader = this._processShader(
      this.vertexShader,
      'vertex',
      geometry
    );
    this.fragmentShader = this._processShader(
      this.fragmentShader,
      'fragment',
      geometry
    );

    this.program.link(
      this.vertexShader,
      this.fragmentShader,
      transformFeedbackVaryings
    );

    // User defined uniforms
    this.customUniforms = this.uniforms || {};

    // Uniforms for ProjectionView uniform block
    if (GL.webgl2) {
      this.program.setUniformBlockLocation(
        'ProjectionView',
        UniformBuffers.projectionView.buffer,
        CONSTANTS.UNIFORM_PROJECTION_VIEW_LOCATION
      );
    }

    if (this.ambientLight) {
      if (GL.webgl2) {
        // Setup uniform block for point lights
        this.program.setUniformBlockLocation(
          'AmbientLight',
          this.ambientLight.uniformBuffer.buffer,
          CONSTANTS.UNIFORM_AMBIENT_LIGHT_LOCATION
        );
      } else {
        // Generate uniforms for point lights
        this.ambientLight.get().forEach((ambientLight, i) => {
          Object.keys(ambientLight.uniforms).forEach(ambientLightUniform => {
            const uniform = ambientLight.uniforms[ambientLightUniform];
            this.customUniforms[
              `uAmbientLight.${ambientLightUniform}`
            ] = uniform;
          });
        });
      }
    }

    if (this.directionalLights) {
      if (GL.webgl2) {
        // Setup uniform block for directional lights
        this.program.setUniformBlockLocation(
          'DirectionalLights',
          this.directionalLights.uniformBuffer.buffer,
          CONSTANTS.UNIFORM_DIRECTIONAL_LIGHTS_LOCATION
        );
      } else {
        // Generate uniforms for directional lights
        this.directionalLights.get().forEach((directionalLight, i) => {
          Object.keys(
            directionalLight.uniforms
          ).forEach(directionalLightUniform => {
            const uniform = directionalLight.uniforms[directionalLightUniform];
            this.customUniforms[
              `uDirectionalLights[${i}].${directionalLightUniform}`
            ] = uniform;
          });
        });
      }
    }

    if (this.pointLights) {
      if (GL.webgl2) {
        // Setup uniform block for point lights
        this.program.setUniformBlockLocation(
          'PointLights',
          this.pointLights.uniformBuffer.buffer,
          CONSTANTS.UNIFORM_POINT_LIGHTS_LOCATION
        );
      } else {
        // Generate uniforms for point lights
        this.pointLights.get().forEach((pointLight, i) => {
          Object.keys(pointLight.uniforms).forEach(pointLightUniform => {
            const uniform = pointLight.uniforms[pointLightUniform];
            this.customUniforms[
              `uPointLights[${i}].${pointLightUniform}`
            ] = uniform;
          });
        });
      }
    }

    // Generate texture indices
    const textureIndices = [
      gl.TEXTURE0,
//.........这里部分代码省略.........
开发者ID:davidpaulrosser,项目名称:leonardo,代码行数:101,代码来源:Material.ts

示例7:

} from '../shaders/Lambert.glsl';
import {
  phongFragmentShaderEs100,
  phongFragmentShaderEs300
} from '../shaders/Phong.glsl';
import { vertexShaderEs100, vertexShaderEs300 } from '../shaders/Vertex.glsl';
import ShaderParser from '../utils/ShaderParser';
import { capabilities } from './Capabilities';
import * as CONSTANTS from './Constants';
import * as GL from './GL';
import Program from './Program';
import UniformBuffers from './UniformBuffers';

let gl: WebGL2RenderingContext | WebGLRenderingContext;
const normalMatrix: mat3 = mat3.create();
const inversedModelViewMatrix: mat4 = mat4.create();

interface Options {
  name?: string;
  type?: string;
  uniforms?: any;
  fov?: number;
  hookVertexPre?: string;
  hookVertexMain?: string;
  hookVertexEnd?: string;
  hookFragmentPre?: string;
  hookFragmentMain?: string;
  hookFragmentEnd?: string;
  vertexShader?: string;
  fragmentShader?: string;
  drawType?: number;
开发者ID:davidpaulrosser,项目名称:leonardo,代码行数:31,代码来源:Material.ts

示例8:

import { mat4, quat } from 'gl-matrix'
import { addSystem } from 'shared-utils/painterState'
import * as geo from 'tvs-libs/dist/math/geometry'
import { events } from './context'
import { groundHeight } from './geometries'

let time = 0

export const wallsTransform = mat4.create()
const rotation = quat.create()

export const floorTransform = mat4.create()

export const floorMirrorView = mat4.create()

const planeEquation = geo.planeFromNormalAndCoplanarPoint(
	[0, 1, 0],
	[0, groundHeight, 0]
)
export const floorMirrorMatrix = geo.mirrorMatrixFromPlane(planeEquation)

addSystem('state', (e, s) => {
	if (e === events.FRAME) {
		time += s.device.tpf

		quat.fromEuler(
			rotation,
			Math.sin(0.0007 * time) * 1.1,
			time * 0.001,
			Math.sin(0.0008 * time) * 1.1
		)
开发者ID:trivial-space,项目名称:playground,代码行数:31,代码来源:state.ts

示例9: getFrame

export const automaton = getFrame(painter, 'automaton').update({
	layers: effect,
	selfReferencing: true,
	width: bufferSize,
	height: bufferSize,
	bufferStructure: [
		{
			flipY: true,
			wrap: 'REPEAT',
		},
	],
})

// ===== scene =====

const planMat = mat4.fromTranslation(mat4.create(), [0, 0, -3])
const rotation = 0.001
const projection = mat4.perspective(mat4.create(), 45, 1, 0.01, 10)

const form = getForm(painter, 'plane').update(plane(2, 2))

const shade = getShade(painter, 'plane').update({
	vert: planeVert,
	frag: planeFrag,
})

export const sketch = getSketch(painter, 'plane').update({
	form,
	shade,
	uniforms: {
		projection,
开发者ID:trivial-space,项目名称:playground,代码行数:31,代码来源:renderer.ts

示例10: Sphere

import { mat4, vec2, vec3 } from 'gl-matrix';
import PerspectiveCamera from '../cameras/PerspectiveCamera';
import Face from '../geometry/Face';
import Ray from '../math/Ray';
import Sphere from '../math/Sphere';
import { barycoordFromPoint } from '../math/Utils';
import Vector2 from '../math/Vector2';
import Vector3 from '../math/Vector3';
import Mesh from './Mesh';
import Scene from './Scene';

const inversedProjectionViewMatrix: mat4 = mat4.create();
const cameraDirection: vec3 = vec3.create();
const directionVector = new Vector3();

let barycoord: Vector3;
const fvA = new Vector3();
const fvB = new Vector3();
const fvC = new Vector3();
const uvA = new Vector2();
const uvB = new Vector2();
const uvC = new Vector2();
const sphere = new Sphere();

export default class RayCaster {
  public ray: Ray;
  public near: number;
  public far: number;

  constructor(origin: Vector3, direction: Vector3, near: number, far: number) {
    this.ray = new Ray();
开发者ID:davidpaulrosser,项目名称:leonardo,代码行数:31,代码来源:Raycaster.ts


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