PageSourceSearch

https://sciencevsmagic.net/castles/js/chainmethods.js

js sciencevsmagic.net collected 2026-10-01 13:07:52 UTC 1,489 bytes, 53 lines download raw bytes

1modules.chain=(function(){
2  'use strict';
3  //the undo redo chain. funny name, but i've grown attached to it.
4  //the hashing stuff is the worst part of this ATM. Needs a real rework to easy to use and useful across projects.
5  var chain=modules.chain;
6  var lists=modules.lists;
7  var actions=modules.actions;
8  var base64=modules.base64;
9  var appcam=modules.appcam;
10  var scene=modules.scene;
11  var voxer=modules.voxer;
12
13  chain.resetmethod=function(){
14    voxer.reset();
15    appcam.movecamera(new THREE.Vector3(0,0,1));
16    scene.settilt();
17    scene.resetspin();
18    scene.focus();
19  };
20  chain.encodemethod=function(){
21    var hash='';
22    hash=hash+modules.painter.gethash();
23    hash=hash+modules.blocksize.size;
24    hash=hash+lists.reduce(chain.actions,function(memo,command){
25			var hash=command.hash;
26      var threechars=('AA'+base64.encode(hash)).substr(-3);
27			return memo+threechars;
28		},'');
29    return hash;
30	};
31  chain.decodemethod=function(string){
32    if (string.length<12){
33      return;
34    }
35    modules.blocksize.set(string.substr(12,1)-0);
36    modules.brush.resize();
37
38    chain.reset();
39
40    var start=string.substr(0,12);
41    modules.painter.loadhash(start);
42    modules.scene.colorin(modules.painter.paints);
43
44    var rest=string.substr(13);
45    var hashes=rest.match(/.{3}/g)||[];
46    lists.each(hashes,function(hash){
47      hash=base64.decode(hash);
48      chain.unhash({type:'place',hash:hash});
49    });
50    modules.scene.focus();
51  };
52  return chain;
53}());

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.