import { WebGL } from 'glkit';
const CTX = new WebGL();
const gl = CTX.WebGLRenderingContext;
const { TRIANGLES } = gl;
const camera = new CTX.Obj({
draw() {
camera.updateMatrix();
camera.viewMatrix.getInverse(camera.matrix.arr);
}
});
camera.projectionMatrix = new CTX.Mat4({ name: 'projectionMatrix' });
camera.projectionMatrix.makePerspective();
camera.viewMatrix = new CTX.Mat4({ name: 'viewMatrix' });
camera.translateZ(-100);
camera.draw();
const material = new CTX.Material({
uniforms: [
camera.projectionMatrix,
camera.viewMatrix,
],
vertexShader:
`
precision ${ CTX.maxPrecision.vs.float } float;
attribute vec3 position;
uniform mat4 projectionMatrix;
uniform mat4 viewMatrix;
void main() {
gl_Position = projectionMatrix * viewMatrix * vec4(position, 1.);
}
`,
fragmentShader:
`
precision ${ CTX.maxPrecision.fs.float } float;
void main() {
gl_FragColor = vec4(1.);
}
`,
});
const { program } = material;
const position = new CTX.VBO({
name: 'position',
content: new Float32Array([ ... ]),
location: 0,
});
const verticesNum = position.content.length / 3;
const triangle = new CTX.Obj({
draw() {
gl.useProgram(program);
position.enable();
gl.drawArrays(TRIANGLES, 0, verticesNum);
},
});
triangle.draw();
This package has been deprecated
Author message:
Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.
glkit
0.0.2065 • Public • PublishedDependencies (0)
Dev Dependencies (57)
- @babel/core
- @babel/polyfill
- babel-plugin-transform-member-expression-literals
- babel-plugin-transform-property-literals
- @babel/plugin-transform-reserved-words
- @babel/plugin-transform-property-mutators
- @babel/plugin-transform-arrow-functions
- @babel/plugin-transform-block-scoped-functions
- @babel/plugin-transform-block-scoping
- @babel/plugin-transform-classes
- @babel/plugin-transform-computed-properties
- @babel/plugin-transform-destructuring
- @babel/plugin-transform-duplicate-keys
- @babel/plugin-transform-for-of
- @babel/plugin-transform-function-name
- @babel/plugin-transform-instanceof
- @babel/plugin-transform-literals
- @babel/plugin-transform-new-target
- @babel/plugin-transform-object-super
- @babel/plugin-transform-parameters
- @babel/plugin-transform-shorthand-properties
- @babel/plugin-transform-spread
- @babel/plugin-transform-sticky-regex
- @babel/plugin-transform-template-literals
- @babel/plugin-transform-typeof-symbol
- @babel/plugin-transform-unicode-regex
- @babel/plugin-transform-exponentiation-operator
- @babel/plugin-transform-async-to-generator
- @babel/plugin-proposal-async-generator-functions
- @babel/plugin-transform-dotall-regex
- @babel/plugin-proposal-object-rest-spread
- @babel/plugin-proposal-optional-catch-binding
- @babel/plugin-proposal-unicode-property-regex
- @babel/plugin-proposal-class-properties
- @babel/plugin-proposal-decorators
- @babel/plugin-proposal-do-expressions
- @babel/plugin-proposal-export-default-from
- @babel/plugin-proposal-export-namespace-from
- @babel/plugin-proposal-function-bind
- @babel/plugin-proposal-function-sent
- @babel/plugin-proposal-logical-assignment-operators
- @babel/plugin-proposal-nullish-coalescing-operator
- @babel/plugin-proposal-numeric-separator
- @babel/plugin-proposal-optional-chaining
- @babel/plugin-proposal-pipeline-operator
- @babel/plugin-proposal-throw-expressions
- eslint
- eslint-config-strict
- webpack
- webpack-cli
- babel-loader
- eslint-loader
- extended-define-webpack-plugin
- uglifyjs-webpack-plugin
- clean-webpack-plugin
- copy-webpack-plugin
- cross-env
Package Sidebar
Install
npm i glkit
Weekly Downloads
106
Version
0.0.2065
License
MIT
Unpacked Size
83.2 kB
Total Files
6