Skip to content
Snippets Groups Projects
Commit 3fe2b42e authored by Christopher Pietsch's avatar Christopher Pietsch
Browse files

update pixijs

parent c18093e9
Branches
No related tags found
No related merge requests found
......@@ -191,12 +191,10 @@ function Canvas() {
var renderOptions = {
resolution: 1,
antialiasing: false,
width: width + margin.left + margin.right,
height: height,
};
renderer = new PIXI.WebGLRenderer(
width + margin.left + margin.right,
height,
renderOptions
);
renderer = new PIXI.Renderer(renderOptions);
renderer.backgroundColor = parseInt(
config.style.canvasBackground.substring(1),
16
......@@ -827,7 +825,7 @@ function Canvas() {
// console.log("load", d)
var url = config.loader.textures.detail.url + d.id + ".jpg";
var texture = new PIXI.Texture.fromImage(url, true);
var texture = new PIXI.Texture.fromImage(url);
var sprite = new PIXI.Sprite(texture);
var update = function () {
......@@ -862,7 +860,7 @@ function Canvas() {
var page = d.page ? "_" + d.page : "";
var url = config.loader.textures.big.url + d.id + page + ".jpg";
var texture = new PIXI.Texture.fromImage(url, true);
var texture = new PIXI.Texture.from(url);
var sprite = new PIXI.Sprite(texture);
var res = config.loader.textures.big.size;
......
......@@ -21,16 +21,15 @@ function Loader(url){
return loader;
};
loader.progress = function () {
total = (d3.event.total == 0) ? 80333701 : d3.event.total;
total = d3.event.total == 0 ? 80333701 : d3.event.total;
loaded = d3.event.loaded;
progress = parseInt((loaded / total) * 100);
indicator.style("height", progress + "%");
//console.log(progress);
}
};
loader.load = function () {
container = d3.select(".detailLoader");
container.selectAll("div").remove();
......@@ -42,7 +41,7 @@ function Loader(url){
.on("progress", loader.progress)
.on("load", function (data) {
finished(data);
container.selectAll("div")//.remove();
container.selectAll("div"); //.remove();
})
.get();
};
......@@ -69,15 +68,13 @@ function LoaderSprites(){
var loader = {};
var progress = function () {};
var pixiloader = new PIXI.loaders.Loader();
pixiloader
.use(pixiPackerParser(PIXI))
.on("progress", function (p,r) {
var pixiloader = new PIXI.Loader();
pixiloader.use(pixiPackerParser(PIXI)).on("progress", function (p, r) {
// console.log("progress", p.progress);
indicator.style("height", p.progress + "%");
if(!r.textures) return
progress(r.textures)
})
if (!r.textures) return;
progress(r.textures);
});
loader.progress = function (value) {
if (!arguments.length) return progress;
......@@ -86,13 +83,11 @@ function LoaderSprites(){
};
loader.load = function (url) {
pixiloader
.add(url)
.load(function (r) {
pixiloader.add(url).load(function (r) {
console.log("done", r);
container.selectAll("div").remove();
});
}
};
return loader;
}
......@@ -115,22 +110,19 @@ function LoaderSingleImage(){
var finished = function () {};
var pixiloader = new PIXI.loaders.Loader();
pixiloader
.on("progress", function (p,r) {
pixiloader.on("progress", function (p, r) {
console.log("progress", p.progress);
indicator.style("height", p.progress + "%");
})
});
loader.load = function (url) {
pixiloader
.add(url)
.load(function (r,s) {
pixiloader.add(url).load(function (r, s) {
// console.log("done", r, s);
container.selectAll("div").remove();
finished(s[url].texture)
finished(s[url].texture);
});
return loader
}
return loader;
};
loader.finished = function (value) {
if (!arguments.length) return finished;
......@@ -141,7 +133,6 @@ function LoaderSingleImage(){
return loader;
}
function LoaderBlob(url) {
var progress = 0,
loaded = 0,
......@@ -158,14 +149,14 @@ function LoaderBlob(url){
return loader;
};
loader.progress = function () {
total = (d3.event.total == 0) ? 80333701 : d3.event.total;
total = d3.event.total == 0 ? 80333701 : d3.event.total;
loaded = d3.event.loaded;
progress = parseInt((loaded / total) * 100);
indicator.style("height", progress + "%");
//console.log(progress);
}
};
loader.load = function () {
//console.log("load", url)
......@@ -192,20 +183,15 @@ function LoaderBlob(url){
return loader;
}
function LoaderMultiple(url) {
var progress = 0,
loaded = 0,
total = 0;
var size = 9;
var urls = d3.range(size+1).map(function(d){ return url + d + ".gz.csv"});
var urls = d3.range(size + 1).map(function (d) {
return url + d + ".gz.csv";
});
var index = 0;
var itemsLoaded = 0;
var totalProgress = 0;
......@@ -223,16 +209,16 @@ function LoaderMultiple(url){
loader.progress = function () {
//console.log(d3.event.total, d3.event.loaded)
total = (d3.event.total == 0) ? 8497147 : d3.event.total;
total = d3.event.total == 0 ? 8497147 : d3.event.total;
loaded = d3.event.loaded;
progress = parseInt((loaded / total) * 100);
totalProgress = (itemsLoaded + parseInt(progress*1.20));
totalProgress = itemsLoaded + parseInt(progress * 1.2);
label.text("loading " + totalProgress + " sketches");
indicator.style("height", (totalProgress/15) + "%");
indicator.style("height", totalProgress / 15 + "%");
// console.log(totalProgress,progress);
}
};
loader.load = function (url) {
//console.log("loading", url);
......@@ -255,18 +241,16 @@ function LoaderMultiple(url){
};
loader.init = function () {
container = d3.select(".detailLoader")
container = d3.select(".detailLoader");
container.selectAll("div").remove();
label = container.append("div").classed("label", true).text("loading");
indicator = container.append("div").classed("indicator", true);
loader.load(urls[index]);
}
};
loader.init();
return loader;
}
......@@ -16,25 +16,32 @@ function WaitForAll(count, allDone) {
};
}
window.pixiPackerParser = function (PIXI)
{
return function (resource, next)
{
window.pixiPackerParser = function (PIXI) {
return function (resource, next) {
// skip if no data, its not json, or it isn't a pixi-packer manifest
if (!resource.data || resource.type !== PIXI.loaders.Resource.TYPE.JSON || !resource.data.meta || resource.data.meta.type !== "pixi-packer") {
if (
!resource.data ||
resource.type !== PIXI.LoaderResource.TYPE.JSON ||
!resource.data.meta ||
resource.data.meta.type !== "pixi-packer"
) {
return next();
}
if (resource.data.meta.version > 1) {
throw new Error("pixi-packer manifest version " + resource.data.meta.version + " not supported");
throw new Error(
"pixi-packer manifest version " +
resource.data.meta.version +
" not supported"
);
}
var loader = this;
var loadOptions = {
crossOrigin: resource.crossOrigin,
loadType: PIXI.loaders.Resource.LOAD_TYPE.IMAGE,
parentResource: resource
loadType: PIXI.LoaderResource.LOAD_TYPE.IMAGE,
parentResource: resource,
};
var urlForManifest = resource.url.replace(loader.baseUrl, "");
......@@ -103,7 +110,13 @@ window.pixiPackerParser = function (PIXI)
}
}
res.textures[sprite.name] = new PIXI.Texture(res.texture.baseTexture, frame, crop, trim, false);
res.textures[sprite.name] = new PIXI.Texture(
res.texture.baseTexture,
frame,
crop,
trim,
false
);
// lets also add the frame to pixi's global cache for fromFrame and fromImage functions
PIXI.utils.TextureCache[sprite.name] = res.textures[sprite.name];
......
This diff is collapsed.
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment