matrix-engine
Version:
basic_timeline improved, VT func setup vide html element id with name arg.- DISABLE RAYCAST DEBUG TEST [2.3.3] Fix for GUI win desktop [2.3.0] DestrucMesh solution & loading convex objs for physics BASIC, SpriteAnimation CPU/texture solution added, Improv
134 lines (110 loc) • 4.64 kB
Markdown
https://stackoverflow.com/questions/328017/path-to-msbuild
https://blendswap.com/blend/29206
world.GL.gl.activeTexture(world.GL.gl['TEXTURE' + t]);
if(t == 0) {
var gl = world.GL.gl;
if(!object.tex) object.tex = gl.createTexture();
// var tex = gl.createTexture();
// world.GL.gl.bindTexture(world.GL.gl.TEXTURE_CUBE_MAP, object.textures[t]);
gl.bindTexture(gl.TEXTURE_CUBE_MAP, object.tex);
// Get A 2D context
/** @type {Canvas2DRenderingContext} */
if(typeof window.TEST == 'undefined') {
window.TEST = null;
var T = document.createElement("canvas");
T.id = 'blabla';
document.body.append(T);
} else {
var T = document.getElementById("blabla");
}
const ctx = T.getContext("2d");
ctx.canvas.width = 128;
ctx.canvas.height = 128;
const faceInfos = [
{target: gl.TEXTURE_CUBE_MAP_POSITIVE_X, faceColor: '#F00', textColor: '#0FF', text: '+X'},
{target: gl.TEXTURE_CUBE_MAP_NEGATIVE_X, faceColor: '#FF0', textColor: '#00F', text: '-X'},
{target: gl.TEXTURE_CUBE_MAP_POSITIVE_Y, faceColor: '#0F0', textColor: '#F0F', text: '+Y'},
{target: gl.TEXTURE_CUBE_MAP_NEGATIVE_Y, faceColor: '#0FF', textColor: '#F00', text: '-Y'},
{target: gl.TEXTURE_CUBE_MAP_POSITIVE_Z, faceColor: '#00F', textColor: '#FF0', text: '+Z'},
{target: gl.TEXTURE_CUBE_MAP_NEGATIVE_Z, faceColor: '#F0F', textColor: '#0F0', text: 'CUBEMAP'},
];
faceInfos.forEach((faceInfo) => {
const {target, faceColor, textColor, text} = faceInfo;
gen2DTextFace(ctx, faceColor, textColor, text);
// Upload the canvas to the cubemap face.
const level = 0;
const internalFormat = gl.RGBA;
const format = gl.RGBA;
const type = gl.UNSIGNED_BYTE;
gl.texImage2D(target, level, internalFormat, format, type, ctx.canvas);
});
gl.generateMipmap(gl.TEXTURE_CUBE_MAP);
gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MIN_FILTER, gl.LINEAR_MIPMAP_LINEAR);
world.GL.gl.uniform1i(object.shaderProgram.uCubeMapSampler, 0);
--- PHYSICS
var height = 5;
var damping = 0.01;
// world.Add("sphereLightTex", 1, "BALL", tex);
// var mass = 1;
// var sphereShape = new CANNON.Sphere(1);
// var mat1 = new CANNON.Material();
// var shapeBody1 = new CANNON.Body({
// mass: mass,
// material: mat1,
// position: new CANNON.Vec3(3*1, -7, height)
// });
// shapeBody1.addShape(sphereShape);
// shapeBody1.linearDamping = damping;
// physics.world.addBody(shapeBody1);
// // Physics
// App.scene.BALL.physics.currentBody = shapeBody1;
// App.scene.BALL.physics.enabled = true;
// var mm = new CANNON.ContactMaterial(groundMaterial, mat1, { friction: 0.01, restitution: 0.9 });
// physics.world.addContactMaterial(mm);
---------------------------------------------------------------
// uniform sampler2D uSampler[${numTextures}];
// uniform float uMixAmount[${numTextures}];
/*
void main() {
vec4 color = vec4(0);
for (int i = 0; i < ${numTextures}; ++i) {
vec4 texColor = texture2D(uSampler[i], vTextureCoord);
color = mix(color, texColor, uMixAmount[i]);
}
gl_FragColor = color;
}
*/
------------------------------------------------------------------
// // TEST ---------------------
// // TEST ---------------------
// // NOT WORKING PHYSICS
// var vertices = [
// 0, 0, 0, // vertex 0
// 10, 0, 0, // vertex 1
// 0, 10, 0 // vertex 2
// ];
// var indices = [
// 0, 1, 2 // triangle 0
// ];
// world.Add("generatorLightTex", 1, "floorAngle", tex, {
// radius: 1,
// custom_type: 'testTrimesh',
// custom_geometry: new CANNON.Trimesh(vertices, indices),
// });
// const testCustomBody1 = new CANNON.Body({
// shape: new CANNON.Trimesh(vertices, indices),
// // type: CANNON.Body.STATIC,
// position: new CANNON.Vec3(0, 0, 0)
// })
// // testCustomBody1.fixedRotation = true;
// // testCustomBody1.updateMassProperties();
// physics.world.addBody(testCustomBody1);
// App.scene.floorAngle.physics.currentBody = testCustomBody1;
// App.scene.floorAngle.physics.enabled = true;
// maybe not need at all for this type of geo
// App.scene['floorAngle'].geometry.setScaleByX(15);
// App.scene['floorAngle'].geometry.setScaleByZ(15);
// App.scene['floorAngle'].geometry.setScaleByY(1);
// // TEST ---------------------
// // TEST ---------------------
// // NOT WORKING PHYSICS