'use strict';
//Point
var pointLightPosition = [0, 5, 0];
//Puntos de la curva
var startP = [-10, 0, 0];
var endP = [10, 0, -25];
var c1P = [-10, 0, -15];
var c2P = [-10, 0, -15];
var t = 0; //Tiempo animación actual
var animacion = 5000; //Tiempo de animacion
var tiempo = Date.now(); //Tiempo actual
var regreso = false; //Animacion de regreso
// Clases del grafo de escena
var Node = function() {
this.children = [];
this.localMatrix = m4.identity();
this.worldMatrix = m4.identity();
};
Node.prototype.setParent = function(parent) {
if (this.parent) {
var ndx = this.parent.children.indexOf(this);
if (ndx >= 0) {
this.parent.children.splice(ndx, 1);
}
}
if (parent) {
parent.children.push(this);
}
this.parent = parent;
};
Node.prototype.updateWorldMatrix = function(parentWorldMatrix) {
if (parentWorldMatrix) {
// a matrix was passed in so do the math
m4.multiply(parentWorldMatrix, this.localMatrix, this.worldMatrix);
} else {
// no matrix was passed in so just copy local to world
m4.copy(this.localMatrix, this.worldMatrix);
}
// now process all the children
var worldMatrix = this.worldMatrix;
this.children.forEach(function(child) {
child.updateWorldMatrix(worldMatrix);
});
};
// Main
function main() {
var canvas = document.getElementById('scene');
var gl = canvas.getContext('webgl');
if (!gl) return;
var programInfo = webglUtils.createProgramInfo(gl, [
'3d-vertex-shader',
'3d-fragment-shader'
]);
var shadowMapProgramInfo = webglUtils.createProgramInfo(gl, [
'shadowMap-vs',
'shadowMap-fs'
]);
// Fucniones utiles
function degToRad(d) {
return d * Math.PI / 180;
}
function rand(min, max) {
return Math.random() * (max - min) + min;
}
function emod(x, n) {
return x >= 0 ? x % n : (n + x % n) % n;
}
// Interpolacion lineal entre vectores
function lerp(a, b, t) {
var len = a.length;
if(b.length != len) return;
...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.