Skip to content

Commit

Permalink
supports multiple objects
Browse files Browse the repository at this point in the history
  • Loading branch information
oov committed Apr 9, 2022
1 parent 2dfdc6c commit 9ef07c3
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 23 deletions.
46 changes: 24 additions & 22 deletions index.html
Expand Up @@ -16,44 +16,46 @@
<script type="module">
import { load, setCamera, render } from './main.js';

let file = "a";
let state = null;
let position = null;
let target = null;
const layers = window.layers = {};
AviUtlBrowser.registerRenderer(async params => {
if (file !== params.userfile) {
file = params.userfile;
if (file == null) {
state = await load(null, null);
const [layer, t, px, py, pz, tx, ty, tz, r, fov] = params.param.split(" ").map((v, idx) => parseFloat(v));
const l = layers[layer] = (layers[layer] || {
state: null,
position: null,
target: null,
file: "a",
});
if (l.file !== params.userfile) {
l.file = params.userfile;
if (l.file == null) {
l.state = await load(null, null);
} else {
state = await load(await fetch('/userfile').then(r => r.arrayBuffer()), {
l.state = await load(await fetch('/userfile').then(r => r.arrayBuffer()), {
hdr: await fetch('/assets/studio_small_08_4k.hdr').then(r => r.arrayBuffer()),
luts:{
lut_ggx_file: '/assets/lut_ggx.png',
lut_charlie_file: '/assets/lut_charlie.png',
lut_sheen_E_file: '/assets/lut_sheen_E.png',
},
});
state.renderingParameters.renderEnvironmentMap = false;
l.state.renderingParameters.renderEnvironmentMap = false;
}
position = state.userCamera.getPosition();
target = state.userCamera.getTarget();
window.state = state;
l.position = l.state.userCamera.getPosition();
l.target = l.state.userCamera.getTarget();
}

const [t, px, py, pz, tx, ty, tz, r, fov] = params.param.split(" ").map((v, idx) => parseFloat(v));
if (t) {
state.animationTimer.setFixedTime(t);
l.state.animationTimer.setFixedTime(t);
} else {
state.animationTimer.paused = true;
state.animationTimer.pausedTime = 0;
l.state.animationTimer.paused = true;
l.state.animationTimer.pausedTime = 0;
}
setCamera(state,
[position[0] + px, position[1] + py, position[2] + pz],
[target[0] + tx, target[1] + ty, target[2] + tz],
setCamera(l.state,
[l.position[0] + px, l.position[1] + py, l.position[2] + pz],
[l.target[0] + tx, l.target[1] + ty, l.target[2] + tz],
r*Math.PI/180);
state.userCamera.setVerticalFoV(fov*Math.PI/180);
render(state);
l.state.userCamera.setVerticalFoV(fov*Math.PI/180);
render(l.state);
return '';
});
</script>
Expand Down
2 changes: 1 addition & 1 deletion lua/@GLB.anm
Expand Up @@ -10,7 +10,7 @@ obj.load("tempbuffer")
require("browser").execute({
dir = "GLB",
tabid = "",
param = string.format("%f %f %f %f %f %f %f %f %f", obj.time, p[1], p[2], p[3], t[1], t[2], t[3], r, f),
param = string.format("%f %f %f %f %f %f %f %f %f %f", obj.layer, obj.time, p[1], p[2], p[3], t[1], t[2], t[3], r, f),
userfile = file,
dev = obj.check0,
});

0 comments on commit 9ef07c3

Please sign in to comment.