@footgun/cobalt 0.6.6 → 0.6.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@footgun/cobalt",
3
- "version": "0.6.6",
3
+ "version": "0.6.7",
4
4
  "type": "module",
5
5
  "main": "bundle.js",
6
6
  "description": "A 2D WebGpu renderer",
package/src/tile/tile.js CHANGED
@@ -95,10 +95,21 @@ export default {
95
95
 
96
96
 
97
97
  async function init (cobalt, nodeData) {
98
- const { device } = cobalt
98
+ const { canvas, device } = cobalt
99
+
100
+ let material
99
101
 
102
+ const format = getPreferredFormat(cobalt)
103
+
100
104
  // build the tile layer and add it to the cobalt data structure
101
- const material = await createTextureFromUrl(cobalt, 'tile map', nodeData.options.textureUrl)
105
+ if (canvas) {
106
+ // browser (canvas) path
107
+ material = await createTextureFromUrl(cobalt, 'tile map', nodeData.options.textureUrl, format)
108
+ }
109
+ else {
110
+ // sdl + gpu path
111
+ material = await createTextureFromBuffer(cobalt, 'tile map', node.options.texture, format)
112
+ }
102
113
 
103
114
  const dat = new Float32Array([ nodeData.options.scrollScale, nodeData.options.scrollScale ])
104
115