|
|
@ -29,8 +29,269 @@ export function uiUpdateScene(context: any) {
|
|
|
|
params: _.cloneDeep(context.params),
|
|
|
|
params: _.cloneDeep(context.params),
|
|
|
|
programInfo: _.cloneDeep(context.programInfo),
|
|
|
|
programInfo: _.cloneDeep(context.programInfo),
|
|
|
|
shaderProgram: _.cloneDeep(context.shaderProgram),
|
|
|
|
shaderProgram: _.cloneDeep(context.shaderProgram),
|
|
|
|
fragmentShader: _.cloneDeep(context.fragmentShader),
|
|
|
|
shaders: _.cloneDeep(context.shaders),
|
|
|
|
vertexShader: _.cloneDeep(context.vertexShader),
|
|
|
|
});
|
|
|
|
|
|
|
|
let instanceRadioString;
|
|
|
|
|
|
|
|
if ($('input[name=instance]:checked', '#instanceoptions').val() ==
|
|
|
|
|
|
|
|
'normal') {
|
|
|
|
|
|
|
|
instanceRadioString = `<input type="radio" id="normal" name="` + context.scene.length + `instance" value="normal" checked>
|
|
|
|
|
|
|
|
<label for="normal">Use instance slider</label>
|
|
|
|
|
|
|
|
<input type="radio" id="one" name="` + context.scene.length + `instance" value="one">
|
|
|
|
|
|
|
|
<label for="one">Lock to one instance</label>
|
|
|
|
|
|
|
|
<input type="radio" id="zero" name="` + context.scene.length + `instance" value="zero">
|
|
|
|
|
|
|
|
<label for="zero">Do not show object</label>`;
|
|
|
|
|
|
|
|
} else if (
|
|
|
|
|
|
|
|
($('input[name=instance]:checked', '#instanceoptions').val() ==
|
|
|
|
|
|
|
|
'one')) {
|
|
|
|
|
|
|
|
instanceRadioString = `<input type="radio" id="normal" name="` + context.scene.length + `instance" value="normal">
|
|
|
|
|
|
|
|
<label for="normal">Use instance slider</label>
|
|
|
|
|
|
|
|
<input type="radio" id="one" name="` + context.scene.length + `instance" value="one" checked>
|
|
|
|
|
|
|
|
<label for="one">Lock to one instance</label>
|
|
|
|
|
|
|
|
<input type="radio" id="zero" name="` + context.scene.length + `instance" value="zero">
|
|
|
|
|
|
|
|
<label for="zero">Do not show object</label>`;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
instanceRadioString = `<input type="radio" id="normal" name="` + context.scene.length + `instance" value="normal">
|
|
|
|
|
|
|
|
<label for="normal">Use instance slider</label>
|
|
|
|
|
|
|
|
<input type="radio" id="one" name="` + context.scene.length + `instance" value="one">
|
|
|
|
|
|
|
|
<label for="one">Lock to one instance</label>
|
|
|
|
|
|
|
|
<input type="radio" id="zero" name="` + context.scene.length + `instance" value="zero" checked>
|
|
|
|
|
|
|
|
<label for="zero">Do not show object</label>`;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
$('.scene-block').append(`
|
|
|
|
|
|
|
|
<div class='ui-block'>
|
|
|
|
|
|
|
|
<div style='display: inline;'>Change shader: </div>
|
|
|
|
|
|
|
|
<button id='` + context.scene.length + `s_blackandwhite'>Black & White</button>
|
|
|
|
|
|
|
|
<button id='` + context.scene.length + `s_color'>Colored</button>
|
|
|
|
|
|
|
|
<button id='` + context.scene.length + `s_grey'>No texture</button>
|
|
|
|
|
|
|
|
<button id='` + context.scene.length + `s_texture'>Texture</button>
|
|
|
|
|
|
|
|
<button id='` + context.scene.length + `s_sobel'>Sobel Edge Detection</button>
|
|
|
|
|
|
|
|
<button id='` + context.scene.length + `s_fractal'>Fractal</button>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class='ui-block'>
|
|
|
|
|
|
|
|
<div style='display: inline;'>Change instances number: </div>
|
|
|
|
|
|
|
|
<input type="range" min="1" max="180" value="` + $('#instance').val() + `" step='1' class="slider" id="` + context.scene.length + `instance">
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class='ui-block'>
|
|
|
|
|
|
|
|
<form id="` + context.scene.length + `instanceoptions">` + instanceRadioString + `</form>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class='ui-block'>
|
|
|
|
|
|
|
|
<div style='display: inline;'>Change rotation: </div>
|
|
|
|
|
|
|
|
<div style='display: inline;'>X: </div>
|
|
|
|
|
|
|
|
<input type="range" min="0" max="6.2830" value="` + $('#rotx').val() + `" step='0.0001' class="slider" id="` + context.scene.length + `rotx">
|
|
|
|
|
|
|
|
<div style='display: inline;'>Y: </div>
|
|
|
|
|
|
|
|
<input type="range" min="0" max="6.2830" value="` + $('#roty').val() + `" step='0.0001' class="slider" id="` + context.scene.length + `roty">
|
|
|
|
|
|
|
|
<div style='display: inline;'>Z: </div>
|
|
|
|
|
|
|
|
<input type="range" min="0" max="6.2830" value="` + $('#rotz').val() + `" step='0.0001' class="slider" id="` + context.scene.length + `rotz">
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class='ui-block'>
|
|
|
|
|
|
|
|
<div style='display: inline;'>Change scale: </div>
|
|
|
|
|
|
|
|
<div style='display: inline;'>X: </div>
|
|
|
|
|
|
|
|
<input type="number" value="` + $('#scalex').val() + `" min="0" step='0.00001' id="` + context.scene.length + `scalex">
|
|
|
|
|
|
|
|
<div style='display: inline;'>Y: </div>
|
|
|
|
|
|
|
|
<input type="number" value="` + $('#scaley').val() + `" min="0" step='0.00001' id="` + context.scene.length + `scaley">
|
|
|
|
|
|
|
|
<div style='display: inline;'>Z: </div>
|
|
|
|
|
|
|
|
<input type="number" value="` + $('#scalez').val() + `" min="0" step='0.00001' id="` + context.scene.length + `scalez">
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class='ui-block'>
|
|
|
|
|
|
|
|
<div style='display: inline;'>Translate: </div>
|
|
|
|
|
|
|
|
<div style='display: inline;'>X: </div>
|
|
|
|
|
|
|
|
<input type="number" value="` + $('#posx').val() + `" step='0.00001' id="` + context.scene.length + `posx">
|
|
|
|
|
|
|
|
<div style='display: inline;'>Y: </div>
|
|
|
|
|
|
|
|
<input type="number" value="` + $('#posy').val() + `" step='0.00001' id="` + context.scene.length + `posy">
|
|
|
|
|
|
|
|
<div style='display: inline;'>Z: </div>
|
|
|
|
|
|
|
|
<input type="number" value="` + $('#posz').val() + `" step='0.00001' id="` + context.scene.length + `posz">
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class='ui-block'>
|
|
|
|
|
|
|
|
<div style='display: inline;'>Change object: </div>
|
|
|
|
|
|
|
|
<button id='` + context.scene.length + `o_sphere'>Sphere</button>
|
|
|
|
|
|
|
|
<button id='` + context.scene.length + `o_teapot'>Teapot</button>
|
|
|
|
|
|
|
|
<button id='` + context.scene.length + `o_fox'>Fox</button>
|
|
|
|
|
|
|
|
<button id='` + context.scene.length + `o_mecha'>Mecha</button>
|
|
|
|
|
|
|
|
<button id='` + context.scene.length + `o_racer'>Racer</button>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class='ui-block'>
|
|
|
|
|
|
|
|
<div style='display: inline;'>Change texture: </div>
|
|
|
|
|
|
|
|
<button id='` + context.scene.length + `t_wall'>Wall</button>
|
|
|
|
|
|
|
|
<button id='` + context.scene.length + `t_ice'>Ice</button>
|
|
|
|
|
|
|
|
<button id='` + context.scene.length + `t_noise'>Noise</button>
|
|
|
|
|
|
|
|
<button id='` + context.scene.length + `t_fox'>Fox</button>
|
|
|
|
|
|
|
|
<button id='` + context.scene.length + `t_racer'>Racer</button>
|
|
|
|
|
|
|
|
<button id='` + context.scene.length + `t_racer_wireframe'>Racer Wireframe</button>
|
|
|
|
|
|
|
|
</div>`);
|
|
|
|
|
|
|
|
$('#' + context.scene.length + 't_wall').on('click', (event) => {
|
|
|
|
|
|
|
|
const n = parseInt(event.target.id.split('t')[0]);
|
|
|
|
|
|
|
|
if (context.cache.textures.wall == null) {
|
|
|
|
|
|
|
|
context.cache.textures.wall = loadTexture(context.gl,
|
|
|
|
|
|
|
|
'/static/textures/wall.png');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
context.scene[n - 1].texture = context.cache.textures.wall;
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
$('#' + context.scene.length + 't_ice').on('click', (event) => {
|
|
|
|
|
|
|
|
const n = parseInt(event.target.id.split('t')[0]);
|
|
|
|
|
|
|
|
if (context.cache.textures.ice == null) {
|
|
|
|
|
|
|
|
context.cache.textures.ice = loadTexture(context.gl,
|
|
|
|
|
|
|
|
'/static/textures/ice.png');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
context.scene[n - 1].texture = context.cache.textures.ice;
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
$('#' + context.scene.length + 't_fox').on('click', (event) => {
|
|
|
|
|
|
|
|
const n = parseInt(event.target.id.split('t')[0]);
|
|
|
|
|
|
|
|
if (context.cache.textures.fox == null) {
|
|
|
|
|
|
|
|
context.cache.textures.fox = loadTexture(context.gl,
|
|
|
|
|
|
|
|
'/static/textures/fox.png');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
context.scene[n - 1].texture = context.cache.textures.fox;
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
$('#' + context.scene.length + 't_racer').on('click', (event) => {
|
|
|
|
|
|
|
|
const n = parseInt(event.target.id.split('t')[0]);
|
|
|
|
|
|
|
|
if (context.cache.textures.racer == null) {
|
|
|
|
|
|
|
|
context.cache.textures.racer = loadTexture(context.gl,
|
|
|
|
|
|
|
|
'/static/textures/racer.png');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
context.scene[n - 1].texture = context.cache.textures.racer;
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
$('#' + context.scene.length + 't_racer_wireframe').on('click',
|
|
|
|
|
|
|
|
(event) => {
|
|
|
|
|
|
|
|
const n = parseInt(event.target.id.split('t')[0]);
|
|
|
|
|
|
|
|
if (context.cache.textures.racerWireframe == null) {
|
|
|
|
|
|
|
|
context.cache.textures.racerWireframe = loadTexture(
|
|
|
|
|
|
|
|
context.gl,
|
|
|
|
|
|
|
|
'/static/textures/racer_wireframe.png');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
context.scene[n - 1].texture = context.cache.textures.racerWireframe;
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
$('#' + context.scene.length + 'instanceoptions input').on('change', (event) => {
|
|
|
|
|
|
|
|
const n = parseInt(event.target.attributes[2].nodeValue!.split('instance')[0]);
|
|
|
|
|
|
|
|
if ($('input[name=' + n + 'instance]:checked', '#' + n + 'instanceoptions').val() ==
|
|
|
|
|
|
|
|
'normal') {
|
|
|
|
|
|
|
|
context.scene[n - 1].params.instanceNumber = parseFloat(<string>$('#' + n + 'instance').val());
|
|
|
|
|
|
|
|
} else if (
|
|
|
|
|
|
|
|
($('input[name=' + n + 'instance]:checked', '#' + n + 'instanceoptions').val() ==
|
|
|
|
|
|
|
|
'one')) {
|
|
|
|
|
|
|
|
context.scene[n - 1].params.instanceNumber = 1;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
context.scene[n - 1].params.instanceNumber = 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
$('#' + context.scene.length + 'instance').on('input', (event) => {
|
|
|
|
|
|
|
|
const n = parseInt(event.target.id.split('instance')[0]);
|
|
|
|
|
|
|
|
if ($('input[name=' + n + 'instance]:checked', '#' + n + 'instanceoptions').val() ==
|
|
|
|
|
|
|
|
'normal') {
|
|
|
|
|
|
|
|
context.scene[n - 1].params.instanceNumber = parseFloat(<string>$('#' + n + 'instance').val());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
$('#' + context.scene.length + 'rotx').on('input', (event) => {
|
|
|
|
|
|
|
|
const n = parseInt(event.target.id.split('rot')[0]);
|
|
|
|
|
|
|
|
console.log(n);
|
|
|
|
|
|
|
|
context.scene[n - 1].params.rot.x = parseFloat(<string>$('#' + n + 'rotx').val());
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
$('#' + context.scene.length + 'roty').on('input', (event) => {
|
|
|
|
|
|
|
|
const n = parseInt(event.target.id.split('rot')[0]);
|
|
|
|
|
|
|
|
context.scene[n - 1].params.rot.y = parseFloat(<string>$('#' + n + 'roty').val());
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
$('#' + context.scene.length + 'rotz').on('input', (event) => {
|
|
|
|
|
|
|
|
const n = parseInt(event.target.id.split('rot')[0]);
|
|
|
|
|
|
|
|
context.scene[n - 1].params.rot.z = parseFloat(<string>$('#' + n + 'rotz').val());
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
$('#' + context.scene.length + 'posx').on('input', (event) => {
|
|
|
|
|
|
|
|
const n = parseInt(event.target.id.split('pos')[0]);
|
|
|
|
|
|
|
|
context.scene[n - 1].params.pos.x = parseFloat(<string>$('#' + n + 'posx').val());
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
$('#' + context.scene.length + 'posy').on('input', (event) => {
|
|
|
|
|
|
|
|
const n = parseInt(event.target.id.split('pos')[0]);
|
|
|
|
|
|
|
|
context.scene[n - 1].params.pos.y = parseFloat(<string>$('#' + n + 'posy').val());
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
$('#' + context.scene.length + 'posz').on('input', (event) => {
|
|
|
|
|
|
|
|
const n = parseInt(event.target.id.split('pos')[0]);
|
|
|
|
|
|
|
|
context.scene[n - 1].params.pos.z = parseFloat(<string>$('#' + n + 'posz').val());
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
$('#' + context.scene.length + 'scalex').on('input', (event) => {
|
|
|
|
|
|
|
|
const n = parseInt(event.target.id.split('scale')[0]);
|
|
|
|
|
|
|
|
console.log(n);
|
|
|
|
|
|
|
|
console.log(parseFloat(<string>$('#' + n + 'scalex').val()));
|
|
|
|
|
|
|
|
context.scene[n - 1].params.scale.x = parseFloat(<string>$('#' + n + 'scalex').val());
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
$('#' + context.scene.length + 'scaley').on('input', (event) => {
|
|
|
|
|
|
|
|
const n = parseInt(event.target.id.split('scale')[0]);
|
|
|
|
|
|
|
|
context.scene[n - 1].params.scale.y = parseFloat(<string>$('#' + n + 'scaley').val());
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
$('#' + context.scene.length + 'scalez').on('input', (event) => {
|
|
|
|
|
|
|
|
const n = parseInt(event.target.id.split('scale')[0]);
|
|
|
|
|
|
|
|
context.scene[n - 1].params.scale.z = parseFloat(<string>$('#' + n + 'scalez').val());
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
$('#' + context.scene.length + 's_blackandwhite').on('click', function(event) {
|
|
|
|
|
|
|
|
const n = parseInt(event.target.id.split('s')[0]);
|
|
|
|
|
|
|
|
[context.scene[n - 1].programInfo, context.scene[n - 1].shaderProgram, context.scene[n - 1].shaders.vert, context.scene[n - 1].shaders.frag] = changeFragmentShader(context, context.scene[n - 1].programInfo, context.scene[n - 1].shaderProgram, context.scene[n - 1].shaders.frag, context.scene[n - 1].shaders.vert, blackandwhite, vsSource);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
$('#' + context.scene.length + 's_color').on('click', function(event) {
|
|
|
|
|
|
|
|
const n = parseInt(event.target.id.split('s')[0]);
|
|
|
|
|
|
|
|
[context.scene[n - 1].programInfo, context.scene[n - 1].shaderProgram, context.scene[n - 1].shaders.vert, context.scene[n - 1].shaders.frag] = changeFragmentShader(context, context.scene[n - 1].programInfo, context.scene[n - 1].shaderProgram, context.scene[n - 1].shaders.frag, context.scene[n - 1].shaders.vert, colored, vsSource);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
$('#' + context.scene.length + 's_grey').on('click', function(event) {
|
|
|
|
|
|
|
|
const n = parseInt(event.target.id.split('s')[0]);
|
|
|
|
|
|
|
|
[context.scene[n - 1].programInfo, context.scene[n - 1].shaderProgram, context.scene[n - 1].shaders.vert, context.scene[n - 1].shaders.frag] = changeFragmentShader(context, context.scene[n - 1].programInfo, context.scene[n - 1].shaderProgram, context.scene[n - 1].shaders.frag, context.scene[n - 1].shaders.vert, grey, vsSource);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
$('#' + context.scene.length + 's_texture').on('click', function(event) {
|
|
|
|
|
|
|
|
const n = parseInt(event.target.id.split('s')[0]);
|
|
|
|
|
|
|
|
[context.scene[n - 1].programInfo, context.scene[n - 1].shaderProgram, context.scene[n - 1].shaders.vert, context.scene[n - 1].shaders.frag] = changeFragmentShader(context, context.scene[n - 1].programInfo, context.scene[n - 1].shaderProgram, context.scene[n - 1].shaders.frag, context.scene[n - 1].shaders.vert, texture, vsSource);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
$('#' + context.scene.length + 's_sobel').on('click', function(event) {
|
|
|
|
|
|
|
|
const n = parseInt(event.target.id.split('s')[0]);
|
|
|
|
|
|
|
|
[context.scene[n - 1].programInfo, context.scene[n - 1].shaderProgram, context.scene[n - 1].shaders.vert, context.scene[n - 1].shaders.frag] = changeFragmentShader(context, context.scene[n - 1].programInfo, context.scene[n - 1].shaderProgram, context.scene[n - 1].shaders.frag, context.scene[n - 1].shaders.vert, sobel, vsSource);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
$('#' + context.scene.length + 's_fractal').on('click', function(event) {
|
|
|
|
|
|
|
|
const n = parseInt(event.target.id.split('s')[0]);
|
|
|
|
|
|
|
|
[context.scene[n - 1].programInfo, context.scene[n - 1].shaderProgram, context.scene[n - 1].shaders.vert, context.scene[n - 1].shaders.frag] = changeFragmentShader(context, context.scene[n - 1].programInfo, context.scene[n - 1].shaderProgram, context.scene[n - 1].shaders.frag, context.scene[n - 1].shaders.vert, fractal, vsSource);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
$('#' + context.scene.length + 'o_sphere').on('click', async function(event) {
|
|
|
|
|
|
|
|
const n = parseInt(event.target.id.split('o')[0]);
|
|
|
|
|
|
|
|
if (context.cache.objs.sphere == null) {
|
|
|
|
|
|
|
|
const data = await fetchObj('/static/objs/sphere.obj');
|
|
|
|
|
|
|
|
context.cache.objs.sphere = loadObj(data);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
context.scene[n - 1].buffers = loadObjBuffers(context, context.scene[n - 1].buffers, context.cache.objs.sphere);
|
|
|
|
|
|
|
|
context.scene[n - 1].params.len = context.cache.objs.sphere.indices.length;
|
|
|
|
|
|
|
|
context.scene[n - 1].params.range = context.cache.objs.sphere.range;
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
$('#' + context.scene.length + 'o_teapot').on('click', async function(event) {
|
|
|
|
|
|
|
|
const n = parseInt(event.target.id.split('o')[0]);
|
|
|
|
|
|
|
|
if (context.cache.objs.teapot == null) {
|
|
|
|
|
|
|
|
const data = await fetchObj('/static/objs/teapot.obj');
|
|
|
|
|
|
|
|
context.cache.objs.teapot = loadObj(data);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
context.scene[n - 1].buffers = loadObjBuffers(context, context.scene[n - 1].buffers, context.cache.objs.teapot);
|
|
|
|
|
|
|
|
context.scene[n - 1].params.len = context.cache.objs.teapot.indices.length;
|
|
|
|
|
|
|
|
context.scene[n - 1].params.range = context.cache.objs.teapot.range;
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
$('#' + context.scene.length + 'o_fox').on('click', async function(event) {
|
|
|
|
|
|
|
|
const n = parseInt(event.target.id.split('o')[0]);
|
|
|
|
|
|
|
|
if (context.cache.objs.fox == null) {
|
|
|
|
|
|
|
|
const data = await fetchObj('/static/objs/fox.obj');
|
|
|
|
|
|
|
|
context.cache.objs.fox = loadObj(data);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
context.scene[n - 1].buffers = loadObjBuffers(context, context.scene[n - 1].buffers, context.cache.objs.fox);
|
|
|
|
|
|
|
|
context.scene[n - 1].params.len = context.cache.objs.fox.indices.length;
|
|
|
|
|
|
|
|
context.scene[n - 1].params.range = context.cache.objs.fox.range;
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
$('#' + context.scene.length + 'o_mecha').on('click', async function(event) {
|
|
|
|
|
|
|
|
const n = parseInt(event.target.id.split('o')[0]);
|
|
|
|
|
|
|
|
if (context.cache.objs.mecha == null) {
|
|
|
|
|
|
|
|
const data = await fetchObj('/static/objs/mecha.obj');
|
|
|
|
|
|
|
|
context.cache.objs.mecha = loadObj(data);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
context.scene[n - 1].buffers = loadObjBuffers(context, context.scene[n - 1].buffers, context.cache.objs.mecha);
|
|
|
|
|
|
|
|
context.scene[n - 1].params.len = context.cache.objs.mecha.indices.length;
|
|
|
|
|
|
|
|
context.scene[n - 1].params.range = context.cache.objs.mecha.range;
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
$('#' + context.scene.length + 'o_racer').on('click', async function(event) {
|
|
|
|
|
|
|
|
const n = parseInt(event.target.id.split('o')[0]);
|
|
|
|
|
|
|
|
if (context.cache.objs.racer == null) {
|
|
|
|
|
|
|
|
const data = await fetchObj('/static/objs/racer.obj');
|
|
|
|
|
|
|
|
context.cache.objs.racer = loadObj(data);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
context.scene[n - 1].buffers = loadObjBuffers(context, context.scene[n - 1].buffers, context.cache.objs.racer);
|
|
|
|
|
|
|
|
context.scene[n - 1].params.len = context.cache.objs.racer.indices.length;
|
|
|
|
|
|
|
|
context.scene[n - 1].params.range = context.cache.objs.racer.range;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -163,7 +424,7 @@ export function uiUpdateObject(context: any) {
|
|
|
|
const data = await fetchObj('/static/objs/sphere.obj');
|
|
|
|
const data = await fetchObj('/static/objs/sphere.obj');
|
|
|
|
context.cache.objs.sphere = loadObj(data);
|
|
|
|
context.cache.objs.sphere = loadObj(data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
loadObjBuffers(context, context.cache.objs.sphere);
|
|
|
|
context.buffers = loadObjBuffers(context, context.buffers, context.cache.objs.sphere);
|
|
|
|
context.params.len = context.cache.objs.sphere.indices.length;
|
|
|
|
context.params.len = context.cache.objs.sphere.indices.length;
|
|
|
|
context.params.range = context.cache.objs.sphere.range;
|
|
|
|
context.params.range = context.cache.objs.sphere.range;
|
|
|
|
});
|
|
|
|
});
|
|
|
@ -172,7 +433,7 @@ export function uiUpdateObject(context: any) {
|
|
|
|
const data = await fetchObj('/static/objs/teapot.obj');
|
|
|
|
const data = await fetchObj('/static/objs/teapot.obj');
|
|
|
|
context.cache.objs.teapot = loadObj(data);
|
|
|
|
context.cache.objs.teapot = loadObj(data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
loadObjBuffers(context, context.cache.objs.teapot);
|
|
|
|
context.buffers = loadObjBuffers(context, context.buffers, context.cache.objs.teapot);
|
|
|
|
context.params.len = context.cache.objs.teapot.indices.length;
|
|
|
|
context.params.len = context.cache.objs.teapot.indices.length;
|
|
|
|
context.params.range = context.cache.objs.teapot.range;
|
|
|
|
context.params.range = context.cache.objs.teapot.range;
|
|
|
|
});
|
|
|
|
});
|
|
|
@ -181,7 +442,7 @@ export function uiUpdateObject(context: any) {
|
|
|
|
const data = await fetchObj('/static/objs/fox.obj');
|
|
|
|
const data = await fetchObj('/static/objs/fox.obj');
|
|
|
|
context.cache.objs.fox = loadObj(data);
|
|
|
|
context.cache.objs.fox = loadObj(data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
loadObjBuffers(context, context.cache.objs.fox);
|
|
|
|
context.buffers = loadObjBuffers(context, context.buffers, context.cache.objs.fox);
|
|
|
|
context.params.len = context.cache.objs.fox.indices.length;
|
|
|
|
context.params.len = context.cache.objs.fox.indices.length;
|
|
|
|
context.params.range = context.cache.objs.fox.range;
|
|
|
|
context.params.range = context.cache.objs.fox.range;
|
|
|
|
});
|
|
|
|
});
|
|
|
@ -190,7 +451,7 @@ export function uiUpdateObject(context: any) {
|
|
|
|
const data = await fetchObj('/static/objs/mecha.obj');
|
|
|
|
const data = await fetchObj('/static/objs/mecha.obj');
|
|
|
|
context.cache.objs.mecha = loadObj(data);
|
|
|
|
context.cache.objs.mecha = loadObj(data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
loadObjBuffers(context, context.cache.objs.mecha);
|
|
|
|
context.buffers = loadObjBuffers(context, context.buffers, context.cache.objs.mecha);
|
|
|
|
context.params.len = context.cache.objs.mecha.indices.length;
|
|
|
|
context.params.len = context.cache.objs.mecha.indices.length;
|
|
|
|
context.params.range = context.cache.objs.mecha.range;
|
|
|
|
context.params.range = context.cache.objs.mecha.range;
|
|
|
|
});
|
|
|
|
});
|
|
|
@ -199,7 +460,7 @@ export function uiUpdateObject(context: any) {
|
|
|
|
const data = await fetchObj('/static/objs/racer.obj');
|
|
|
|
const data = await fetchObj('/static/objs/racer.obj');
|
|
|
|
context.cache.objs.racer = loadObj(data);
|
|
|
|
context.cache.objs.racer = loadObj(data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
loadObjBuffers(context, context.cache.objs.racer);
|
|
|
|
context.buffers = loadObjBuffers(context, context.buffers, context.cache.objs.racer);
|
|
|
|
context.params.len = context.cache.objs.racer.indices.length;
|
|
|
|
context.params.len = context.cache.objs.racer.indices.length;
|
|
|
|
context.params.range = context.cache.objs.racer.range;
|
|
|
|
context.params.range = context.cache.objs.racer.range;
|
|
|
|
});
|
|
|
|
});
|
|
|
@ -211,21 +472,21 @@ export function uiUpdateObject(context: any) {
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
export function uiUpdateShader(context: any) {
|
|
|
|
export function uiUpdateShader(context: any) {
|
|
|
|
$('#s_blackandwhite').on('click', function() {
|
|
|
|
$('#s_blackandwhite').on('click', function() {
|
|
|
|
changeFragmentShader(context, blackandwhite, vsSource);
|
|
|
|
[context.programInfo, context.shaderProgram, context.shaders.vert, context.shaders.frag] = changeFragmentShader(context, context.programInfo, context.shaderProgram, context.shaders.frag, context.shaders.vert, blackandwhite, vsSource);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
$('#s_color').on('click', function() {
|
|
|
|
$('#s_color').on('click', function() {
|
|
|
|
changeFragmentShader(context, colored, vsSource);
|
|
|
|
[context.programInfo, context.shaderProgram, context.shaders.vert, context.shaders.frag] = changeFragmentShader(context, context.programInfo, context.shaderProgram, context.shaders.frag, context.shaders.vert, colored, vsSource);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
$('#s_grey').on('click', function() {
|
|
|
|
$('#s_grey').on('click', function() {
|
|
|
|
changeFragmentShader(context, grey, vsSource);
|
|
|
|
[context.programInfo, context.shaderProgram, context.shaders.vert, context.shaders.frag] = changeFragmentShader(context, context.programInfo, context.shaderProgram, context.shaders.frag, context.shaders.vert, grey, vsSource);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
$('#s_texture').on('click', function() {
|
|
|
|
$('#s_texture').on('click', function() {
|
|
|
|
changeFragmentShader(context, texture, vsSource);
|
|
|
|
[context.programInfo, context.shaderProgram, context.shaders.vert, context.shaders.frag] = changeFragmentShader(context, context.programInfo, context.shaderProgram, context.shaders.frag, context.shaders.vert, texture, vsSource);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
$('#s_sobel').on('click', function() {
|
|
|
|
$('#s_sobel').on('click', function() {
|
|
|
|
changeFragmentShader(context, sobel, vsSource);
|
|
|
|
[context.programInfo, context.shaderProgram, context.shaders.vert, context.shaders.frag] = changeFragmentShader(context, context.programInfo, context.shaderProgram, context.shaders.frag, context.shaders.vert, sobel, vsSource);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
$('#s_fractal').on('click', function() {
|
|
|
|
$('#s_fractal').on('click', function() {
|
|
|
|
changeFragmentShader(context, fractal, vsSource);
|
|
|
|
[context.programInfo, context.shaderProgram, context.shaders.vert, context.shaders.frag] = changeFragmentShader(context, context.programInfo, context.shaderProgram, context.shaders.frag, context.shaders.vert, fractal, vsSource);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|