Skip to content

Commit

Permalink
Minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
valeriodiste authored Sep 24, 2023
1 parent fbd1bd0 commit e9b472f
Showing 1 changed file with 21 additions and 15 deletions.
36 changes: 21 additions & 15 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,18 @@ let hostname = window.location.hostname;
// console.log("Root folder path: " + root_folder);
// console.log("Hostname: " + hostname);

console.log("Version 1.1.0");
console.log("Version 1.2.0");

function get_url(resource) {
if (resource.startsWith("/")) resource = resource.substring(1);
if (resource.startsWith("./")) resource = resource.substring(2);
return root_folder + resource;
function get_url(resource, flag = false) {
if (!flag) {
if (resource.startsWith("/")) resource = resource.substring(1);
if (resource.startsWith("./")) resource = resource.substring(2);
return root_folder + resource;
} else {
if (resource.startsWith("/")) resource = ".." + resource;
if (resource.startsWith("./")) resource = "." + resource;
return resource;
}
}

// Make it so that, on any error, a <div> is added to the page with the error message, in the top-middle of the page
Expand Down Expand Up @@ -444,7 +450,7 @@ let crab_base_texture_loader = new THREE.TextureLoader();
// Load the crab GLTF model
function load_crab_model(crab_texture_image = null) {
let loader = new GLTFLoader();
loader.load(get_url('/3d/crab/crab.gltf'), function (object) {
loader.load(get_url('/3d/crab/crab.gltf', true), function (object) {
crab_model = object.scene;
crab_model.name = 'crab_crab_model';
crab_model.position.set(crab_spawn_position.x, crab_spawn_position.y + keyboard_base_height + crab_bases_height + sub_base_height + additional_crab_base_height, crab_spawn_position.z);
Expand Down Expand Up @@ -1969,7 +1975,7 @@ async function start_scene() {
let button_model;
await loader.loadAsync(
// resource URL
get_url('/3d/general/typewriter_button.gltf')).then(
get_url('/3d/general/typewriter_button.gltf', true)).then(
// called when the resource is loaded
function (gltf) {
button_model = gltf.scene;
Expand Down Expand Up @@ -2016,7 +2022,7 @@ async function start_scene() {

if (selected_keyboard_version == keyboard_versions.laptop_keyboard) {
// Add the "keyboard_normal_map.png" normal map to the sub base material to get a PC case silver look
const normal_map = new THREE.TextureLoader().load(get_url('/3d/general/keyboard_normal_map.png'));
const normal_map = new THREE.TextureLoader().load(get_url('/3d/general/keyboard_normal_map.png', true));
normal_map.wrapS = THREE.ClampToEdgeWrapping;
normal_map.wrapT = THREE.ClampToEdgeWrapping;
normal_map.repeat.set(1, 1);
Expand All @@ -2034,7 +2040,7 @@ async function start_scene() {
sub_base_material.metalness = 0.5;
sub_base_material.roughness = 0.1;
// Add the metalness map
const metalness_map = new THREE.TextureLoader().load(get_url('/3d/general/keyboard_metalness_map.png'));
const metalness_map = new THREE.TextureLoader().load(get_url('/3d/general/keyboard_metalness_map.png', true));
metalness_map.wrapS = THREE.RepeatWrapping;
metalness_map.wrapT = THREE.RepeatWrapping;
// Copy the same metalness map
Expand Down Expand Up @@ -2668,7 +2674,7 @@ async function start_scene() {
set_crab_base_as_active(selected_crab_base_index);

crab_base_texture_loader.load(
get_url('/3d/crab/Crab_Base_color_' + crab_texture_colors[selected_keyboard_version] + '.png'),
get_url('/3d/crab/Crab_Base_color_' + crab_texture_colors[selected_keyboard_version] + '.png', true),
function (texture) {
load_crab_model(texture);
});
Expand Down Expand Up @@ -2710,7 +2716,7 @@ async function start_scene() {
let guitar_model_container = undefined, guitar_model = undefined;
function load_guitar_model() {
let loader = new GLTFLoader();
loader.load(get_url('/3d/guitar/guitar.gltf'), function (object) {
loader.load(get_url('/3d/guitar/guitar.gltf', true), function (object) {
guitar_model = object.scene;
guitar_model.name = 'guitar_model';
let guitar_scale = 1;
Expand Down Expand Up @@ -2745,7 +2751,7 @@ async function start_scene() {
let piano_model_container = undefined, piano_model = undefined;
function load_piano_model() {
let loader = new GLTFLoader();
loader.load(get_url('/3d/piano/piano.gltf'), function (object) {
loader.load(get_url('/3d/piano/piano.gltf', true), function (object) {
piano_model = object.scene;
piano_model.name = 'piano_model';
let piano_scale = 1.385;
Expand Down Expand Up @@ -2815,7 +2821,7 @@ async function start_scene() {
let dj_station_model_container = undefined, dj_station_model = undefined;
function load_dj_station_model() {
let loader = new GLTFLoader();
loader.load(get_url('/3d/dj_station/dj_station.gltf'), function (object) {
loader.load(get_url('/3d/dj_station/dj_station.gltf', true), function (object) {
dj_station_model = object.scene;
dj_station_model.name = 'dj_station_model';
// let dj_station_scale = 0.675;
Expand Down Expand Up @@ -2852,7 +2858,7 @@ async function start_scene() {
let bass_model_container = undefined, bass_model = undefined;
function load_bass_model() {
let loader = new GLTFLoader();
loader.load(get_url('/3d/bass/bass.gltf'), function (object) {
loader.load(get_url('/3d/bass/bass.gltf', true), function (object) {
bass_model = object.scene;
bass_model.name = 'bass_model';
let bass_scale = 1.475;
Expand Down Expand Up @@ -2889,7 +2895,7 @@ async function start_scene() {
let synth_model_container = undefined, synth_model = undefined;
function load_synth_model() {
let loader = new GLTFLoader();
loader.load(get_url('/3d/synth/synth.gltf'), function (object) {
loader.load(get_url('/3d/synth/synth.gltf', true), function (object) {
synth_model = object.scene;
synth_model.name = 'synth_model';
let synth_scale = 0.2;
Expand Down

0 comments on commit e9b472f

Please sign in to comment.