Skip to content

Commit

Permalink
replaced floor texture with own one; tweaked settings for it
Browse files Browse the repository at this point in the history
  • Loading branch information
99-Knots committed May 29, 2024
1 parent 82023b0 commit c6dcd0f
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 4 deletions.
Binary file added assets/floortiles.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/floortiles_normal.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion assets/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
declare module '*.jpg' {
declare module '*.png' {
const value: any
export = value;
}
Binary file removed assets/wood_floor_diff_4k.jpg
Binary file not shown.
12 changes: 9 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as BABYLON from '@babylonjs/core';
import { SkyMaterial } from '@babylonjs/materials';
import img from '../assets/wood_floor_diff_4k.jpg';
import img from '../assets/floortiles.png';
import norm from '../assets/floortiles_normal.png';

const canvas = document.createElement('canvas');
canvas.id = "render-canvas";
Expand Down Expand Up @@ -29,9 +30,14 @@ cube.translate(new BABYLON.Vector3(0, 1, 0), 0.5001);
const ground = BABYLON.MeshBuilder.CreateGround('ground', {width:15, height:15}, scene);
const groundMat = new BABYLON.StandardMaterial('groundMaterial', scene);
const woodTex = new BABYLON.Texture(img, scene);
woodTex.uScale = ground._width/2;
woodTex.vScale = ground._height/2;
woodTex.uScale = ground._width;
woodTex.vScale = ground._height;
const normal = new BABYLON.Texture(norm, scene);
normal.uScale = ground._width;
normal.vScale = ground._height;
groundMat.diffuseTexture = woodTex;
groundMat.bumpTexture = normal;
groundMat.specularColor = new BABYLON.Color3(0.4, 0.4, 0.4);
groundMat.backFaceCulling = false;
ground.material = groundMat;

Expand Down

0 comments on commit c6dcd0f

Please sign in to comment.