Skip to content

Commit

Permalink
feat: add lights (update to fibbo v0.0.9)
Browse files Browse the repository at this point in the history
  • Loading branch information
Gugustinette committed Sep 25, 2024
1 parent b9c74a3 commit 5a80e49
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 36 deletions.
54 changes: 27 additions & 27 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
"preview": "vite preview"
},
"devDependencies": {
"@fibbojs/3d": "0.0.6",
"@fibbojs/core": "0.0.6",
"@fibbojs/devtools": "0.0.6",
"@fibbojs/event": "0.0.6",
"@fibbojs/3d": "^0.0.9",
"@fibbojs/core": "^0.0.9",
"@fibbojs/devtools": "^0.0.9",
"@fibbojs/event": "^0.0.9",
"typescript": "^5.2.2",
"vite": "^5.2.0",
"vite-plugin-top-level-await": "^1.4.4",
Expand Down
19 changes: 14 additions & 5 deletions src/main.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,32 @@
import * as THREE from 'three'
import RAPIER from '@dimforge/rapier3d'
import { FComponentEmpty, FCuboid, FGameCamera, FScene } from '@fibbojs/3d'
import { FAmbientLight, FComponentEmpty, FCuboid, FDirectionalLight, FGameCamera, FScene } from '@fibbojs/3d'
import { FKeyboard } from '@fibbojs/event'
import { fDebug } from '@fibbojs/devtools'
import './style.css'
import Character from './classes/Character'

(async () => {
// Initialize the scene
const scene = new FScene()
const scene = new FScene({
shadows: true,
})
scene.init()
await scene.initPhysics()
// Debug the scene
if (import.meta.env.DEV)
fDebug(scene)

// Add directional light to represent the sun
scene.addLight(new FDirectionalLight(scene, {
position: { x: 20, y: 20, z: 0 },
color: 0xFFFFFF,
intensity: 2,
}))
// Add ambient light
const light = new THREE.AmbientLight(0xFFFFFF)
scene.scene.add(light)
scene.addLight(new FAmbientLight(scene, {
color: 0x404040,
intensity: 20,
}))

// Create a death zone
const deathZone = new FComponentEmpty(scene, {
Expand Down

0 comments on commit 5a80e49

Please sign in to comment.