A fence can now be loaded
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -1 +1,4 @@
|
||||
node_modules/
|
||||
|
||||
#backup files from Blender
|
||||
blender_saves/*.blend1
|
||||
@@ -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.
@@ -18,12 +18,12 @@
|
||||
"name":"fence",
|
||||
"scale":[
|
||||
1,
|
||||
1.5,
|
||||
1.5000014305114746,
|
||||
14
|
||||
],
|
||||
"translation":[
|
||||
0,
|
||||
4.380749225616455,
|
||||
14.376946449279785,
|
||||
-10.441571235656738
|
||||
]
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user