Skip to content

Commit

Permalink
Improve flat examples
Browse files Browse the repository at this point in the history
  • Loading branch information
yandeu committed Dec 23, 2024
1 parent 0ad4753 commit b862ff2
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/examples/flat/button-spritesheet.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
// add button
const texture = await this.load.texture('button')
texture.name = 'button'
texture.colorSpace = THREE.SRGBColorSpace

const width = window.innerWidth
const height = window.innerHeight
Expand Down
1 change: 1 addition & 0 deletions src/examples/flat/matter-physics-advanced-shapes.html
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
if (fruit === 'background') continue

const sprite = new FLAT.TextureAtlas(this.atlas, fruit)
sprite.texture.colorSpace = THREE.SRGBColorSpace
this.ui.scene.add(sprite)

let x = width / 2 + (Math.random() - 0.5) * Math.min(600, width)
Expand Down
1 change: 1 addition & 0 deletions src/examples/flat/matter-physics.html
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@

ctx.fillText(text, radius - width / 2, radius + 8)
})
texture.colorSpace = THREE.SRGBColorSpace

const x = Math.random() * window.innerWidth
const y = (Math.random() * window.innerHeight) / 2
Expand Down
3 changes: 2 additions & 1 deletion src/examples/flat/sprite-sheet.html
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@

// add hero on a plane
const heroPlane = await this.createHero()
const geometry = new THREE.PlaneBufferGeometry(heroPlane.textureWidth / 100, heroPlane.textureHeight / 100)
const geometry = new THREE.PlaneGeometry(heroPlane.textureWidth / 100, heroPlane.textureHeight / 100)
const material = new THREE.MeshLambertMaterial({
map: heroPlane.texture,
transparent: false,
Expand All @@ -76,6 +76,7 @@
async createHero() {
// add hero
const texture = await this.load.texture('hero')
texture.colorSpace = THREE.SRGBColorSpace

// for pixel art use NearestFilter (also see https://stackoverflow.com/a/16709631)
texture.magFilter = THREE.NearestFilter
Expand Down
1 change: 1 addition & 0 deletions src/examples/flat/texture-atlas.html
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@

// prepare the atlas
const atlas = await this.load.textureAtlas('ninja.png', 'ninja.json')
atlas.texture.colorSpace = THREE.SRGBColorSpace

// add the atlas to the internal cache if you want
// this.cache.add('myAtlas', atlas)
Expand Down

0 comments on commit b862ff2

Please sign in to comment.