@footgun/cobalt 0.6.6 → 0.6.8
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/CHANGELOG.md +1 -5
- package/bundle.js +8 -2
- package/package.json +1 -1
- package/src/tile/tile.js +13 -2
package/CHANGELOG.md
CHANGED
package/bundle.js
CHANGED
|
@@ -8257,8 +8257,14 @@ var tile_default = {
|
|
|
8257
8257
|
}
|
|
8258
8258
|
};
|
|
8259
8259
|
async function init4(cobalt, nodeData) {
|
|
8260
|
-
const { device } = cobalt;
|
|
8261
|
-
|
|
8260
|
+
const { canvas, device } = cobalt;
|
|
8261
|
+
let material;
|
|
8262
|
+
const format = getPreferredFormat(cobalt);
|
|
8263
|
+
if (canvas) {
|
|
8264
|
+
material = await createTextureFromUrl(cobalt, "tile map", nodeData.options.textureUrl, format);
|
|
8265
|
+
} else {
|
|
8266
|
+
material = await createTextureFromBuffer(cobalt, "tile map", nodeData.options.texture, format);
|
|
8267
|
+
}
|
|
8262
8268
|
const dat = new Float32Array([nodeData.options.scrollScale, nodeData.options.scrollScale]);
|
|
8263
8269
|
const usage = GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST;
|
|
8264
8270
|
const descriptor = {
|
package/package.json
CHANGED
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
|
|
101
|
+
|
|
102
|
+
const format = getPreferredFormat(cobalt)
|
|
99
103
|
|
|
100
104
|
// build the tile layer and add it to the cobalt data structure
|
|
101
|
-
|
|
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', nodeData.options.texture, format)
|
|
112
|
+
}
|
|
102
113
|
|
|
103
114
|
const dat = new Float32Array([ nodeData.options.scrollScale, nodeData.options.scrollScale ])
|
|
104
115
|
|