Skip to content

Commit

Permalink
update web build
Browse files Browse the repository at this point in the history
  • Loading branch information
PZerua committed Nov 15, 2024
1 parent 2f37dff commit f959208
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 24 deletions.
4 changes: 3 additions & 1 deletion src/engine/sample_engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ void SampleEngine::update(float delta_time)
{
// Lerp eye
glm::vec3 new_eye = cameras[target_camera_idx]->get_translation();
eye_lerp.value = smooth_damp(eye_lerp.value, new_eye, &eye_lerp.velocity, 0.50f, 20.0f, delta_time);
eye_lerp.value = smooth_damp(eye_lerp.value, new_eye, &eye_lerp.velocity, 0.75f / camera_interp_speed, 20.0f, delta_time);

Camera* camera = renderer->get_camera();
camera->look_at(eye_lerp.value, camera->get_center(), camera->get_up());
Expand Down Expand Up @@ -957,6 +957,8 @@ void SampleEngine::set_camera_speed(float value)
{
Camera* camera = Renderer::instance->get_camera();
camera->set_speed(value);

camera_interp_speed = value;
}

void SampleEngine::set_camera_lookat_index(int index)
Expand Down
2 changes: 2 additions & 0 deletions src/engine/sample_engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ class SampleEngine : public Engine {
std::vector<EntityCamera*> cameras;
bool rotate_scene = false;

float camera_interp_speed = 1.0f;

// Vpet connection
void* context;
void* distributor; // to send scene
Expand Down
2 changes: 1 addition & 1 deletion www/index.js

Large diffs are not rendered by default.

Binary file modified www/index.wasm
Binary file not shown.
45 changes: 23 additions & 22 deletions www/js/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ window.App = {
this.cameraTypes = [ "Orbit", "Flyover" ];
this.cameraNames = [ ];

this.cameraSpeed = 0.75;
this.cameraSpeed = 1.0;

this.urlParams = new URLSearchParams( window.location.search );

Expand All @@ -39,35 +39,35 @@ window.App = {
}
}

this.loadedCounter = 0;
// this.loadedCounter = 0;

const onSuccess = ( data, request ) => {
// const onSuccess = ( data, request ) => {

const array = new Int8Array( data );
const byteSize = array.length * array.BYTES_PER_ELEMENT;
const ptr = Module._malloc( byteSize );
// const array = new Int8Array( data );
// const byteSize = array.length * array.BYTES_PER_ELEMENT;
// const ptr = Module._malloc( byteSize );

Module.HEAP8.set( array, ptr );
// Module.HEAP8.set( array, ptr );

const url = request.responseURL;
const funcName = `set_scene_${ url.substr( url.lastIndexOf( '.' ) + 1 ) }`;
const func = Module.cwrap( funcName, "void", [ "number", "number" ] );
// const url = request.responseURL;
// const funcName = `set_scene_${ url.substr( url.lastIndexOf( '.' ) + 1 ) }`;
// const func = Module.cwrap( funcName, "void", [ "number", "number" ] );

func( ptr, byteSize );
// func( ptr, byteSize );

Module._free( ptr );
// Module._free( ptr );

this.loadedCounter++;
// this.loadedCounter++;

if (this.loadedCounter == 3) {
window.engineInstance.loadTracerScene();
}
};
// if (this.loadedCounter == 3) {
// window.engineInstance.loadTracerScene();
// }
// };

// LX.requestBinary( "https://emil-xr.eu/dl/DigitalLocation.materials", onSuccess );
LX.requestBinary( "https://emil-xr.eu/dl/DigitalLocation.nodes", onSuccess );
LX.requestBinary( "https://emil-xr.eu/dl/DigitalLocation.objects", onSuccess );
LX.requestBinary( "https://emil-xr.eu/dl/DigitalLocation.textures", onSuccess );
// LX.requestBinary( "https://emil-xr.eu/dl/DigitalLocation.nodes", onSuccess );
// LX.requestBinary( "https://emil-xr.eu/dl/DigitalLocation.objects", onSuccess );
// LX.requestBinary( "https://emil-xr.eu/dl/DigitalLocation.textures", onSuccess );

// For scene request
// {
Expand Down Expand Up @@ -174,7 +174,7 @@ window.App = {
}

p.addDropdown( "Type", this.cameraTypes, "Orbit", (value) => this.setCameraType( value ) );
p.addNumber( "Speed", this.cameraSpeed, (value) => this.setCameraSpeed( value ), { min: 0.01, max: 8.0, step: 0.1 } );
p.addNumber( "Speed", this.cameraSpeed, (value) => this.setCameraSpeed( value ), { min: 0.1, max: 5.0, step: 0.1 } );
p.addList( "Look at", this.cameraNames, "", (value) => this.lookAtCameraIndexFromName( value ) );
p.addButton( null, "Reset", () => this.resetCamera() );

Expand Down Expand Up @@ -343,7 +343,8 @@ window.App = {

if( this.cameraNames.length )
{
this.lookAtCameraIndexFromName( this.cameraNames[ 0 ] );
// this.lookAtCameraIndexFromName( this.cameraNames[ 0 ] );
this.panel.get( "Look at" ).set(this.cameraNames[ 0 ])
}
},

Expand Down

0 comments on commit f959208

Please sign in to comment.