A fence can now be loaded

This commit is contained in:
2023-11-16 20:04:50 +01:00
parent f3ce27b0bb
commit 575a084f9b
5 changed files with 26 additions and 3 deletions

5
.gitignore vendored
View File

@@ -1 +1,4 @@
node_modules/
node_modules/
#backup files from Blender
blender_saves/*.blend1

View File

@@ -1,2 +1,3 @@
Personal memo :
When creating objects, they should always have their lowest part at z=0, so they are correctly on ground when loaded
Working with generated textures : https://blender.stackexchange.com/questions/239475/how-can-i-pack-procedural-textures-into-a-gltf-file

Binary file not shown.

View File

@@ -18,12 +18,12 @@
"name":"fence",
"scale":[
1,
1.5,
1.5000014305114746,
14
],
"translation":[
0,
4.380749225616455,
14.376946449279785,
-10.441571235656738
]
}

View File

@@ -24,6 +24,25 @@ export async function addAssetsOnScene(scene){
const ground = createGround();
scene.add(ground);
/* --------------------
ADDING FENCES
-------------------- */
const groundHitBox = new THREE.Box3().setFromObject(ground); // Calculating ground size
const groundXSize = groundHitBox.max.x - groundHitBox.min.x;
const groundySize = groundHitBox.max.y - groundHitBox.min.y;
let fences = [];//List of created fences
const fence = await loadModel('src/objects/models/fence.gltf');//Loading fence model
fence.scene.scale.set(0.05,0.05,0.05);
fence.scene.rotateOnWorldAxis(new THREE.Vector3(1,0,0), MathUtils.degToRad(90));//Must be standing up
const fenceHitBox = new THREE.Box3().setFromObject(fence.scene);
const fenceWidth = fenceHitBox.max.y - fenceHitBox.min.y;
alignGround(ground, fence.scene);
scene.add(fence.scene);
const player = await loadModel('src/objects/models/player.gltf');//Loading player
player.scene.scale.set(0.2,0.2,0.2);
alignGround(ground, player.scene);