PageSourceSearch

https://fraesen.instawerk.de/assets/js/debug.js

js instawerk.de collected 2026-10-04 05:42:56 UTC 3,913 bytes, 152 lines download raw bytes

1function Debug(scene) {
2  this.scene = scene;
3  this.debugPointGeo = new THREE.Geometry();
4  this.debugLineGeo = new THREE.Geometry();
5}
6
7Debug.prototype.loop = function (loop, fn) {
8  if (fn === undefined) {
9    fn = function () {
10      return true;
11    };
12  }
13  var curr = loop.vertex;
14  do {
15    if (fn(curr)) {
16      this.point(curr.v);
17    }
18    curr = curr.next;
19  } while (curr != loop.vertex);
20};
21Debug.prototype.line = function (v, w, n, lastonly, o, axis) {
22  if (n === undefined) {
23    n = 1;
24  }
25  if (lastonly === undefined) {
26    lastonly = false;
27  }
28  if (o === undefined) {
29    o = 0;
30  }
31  if (axis === undefined) {
32    axis = "z";
33  }
34
35  for (var i = 0; i <= n; i++) {
36    if (lastonly && (n == 0 || i < n - 1)) {
37      continue;
38    }
39    var vert = w.clone().multiplyScalar(i / n).add(v.clone().multiplyScalar((n - i) / n));
40    vert.z += o;
41    this.debugPointGeo.vertices.push(vert);
42  }
43  var vv = v.clone();
44  vv.z += o;
45  var ww = w.clone();
46  ww.z += o;
47  this.debugLineGeo.vertices.push(vv);
48  this.debugLineGeo.vertices.push(ww);
49  this.debugPointGeo.verticesNeedUpdate = true;
50};
51Debug.prototype.oneline = function (v, w, o, axis, c) {
52  if (o === undefined) {
53    o = 0;
54  }
55  if (axis === undefined) {
56    axis = "z";
57  }
58  if (c === undefined) {
59    c = 0xff6666;
60  }
61
62  var vv = v.clone();
63  vv[axis] += o;
64  var ww = w.clone();
65  ww[axis] += o;
66
67  var geo = new THREE.Geometry();
68  geo.vertices.push(vv);
69  geo.vertices.push(ww);
70  var mat = new THREE.LineBasicMaterial({color: c, linewidth: 1});
71  var mesh = new THREE.LineSegments(geo, mat);
72  mesh.name = "debugLine";
73  this.scene.add(mesh);
74
75  //this.point(vv);
76  //this.point(ww);
77};
78Debug.prototype.ray = function (v, r, l) {
79  this.line(v, v.clone().add(r.clone().setLength(l)));
80};
81Debug.prototype.segmentPair = function (s, se, t, te) {
82  var ms = s.clone().add(se).divideScalar(2);
83  var mt = t.clone().add(te).divideScalar(2);
84  this.line(ms, mt);
85};
86Debug.prototype.point = function (v, o, axis) {
87  if (o === undefined) {
88    o = 0;
89  }
90  if (axis === undefined) {
91    axis = "z";
92  }
93  var vv = v;
94  if (o !== 0) {
95    vv = v.clone();
96    vv[axis] += o;
97  }
98
99  this.debugPointGeo.vertices.push(vv);
100  this.debugPointGeo.verticesNeedUpdate = true;
101};
102Debug.prototype.face = function (f, vs) {
103  var [a, b, c] = faceGetVerts(f, vs);
104  this.point(a.clone().add(b).add(c).divideScalar(3));
105};
106Debug.prototype.fedges = function (f, vs) {
107  var [a, b, c] = faceGetVerts(f, vs);
108  this.oneline(a, b, 0, undefined, 0x66ff66);
109  this.oneline(b, c, 0, undefined, 0x66ff66);
110  this.oneline(c, a, 0, undefined, 0x66ff66);
111};
112Debug.prototype.points = function (idx, incr) {
113  var color = 0xff6666;
114  if (incr === undefined) {
115    incr = 0;
116  }
117  if (idx !== undefined) {
118    color = Number.parseInt(("0." + Math.sin(idx + incr).toString().substr(6)) * 0xffffff);
119  } else {
120    idx = 0;
121  }
122  var debugMaterial = new THREE.PointsMaterial({color: color, size: 3, sizeAttenuation: false});
123  var debugMesh = new THREE.Points(this.debugPointGeo, debugMaterial);
124  debugMesh.name = "debug";
125  this.scene.add(debugMesh);
126
127  this.debugPointGeo = new THREE.Geometry();
128};
129Debug.prototype.lines = function (idx, incr) {
130  var color = 0xff6666;
131  if (incr === undefined) {
132    incr = 0;
133  }
134  if (idx !== undefined) {
135    color = Number.parseInt(("0." + Math.sin(idx + incr).toString().substr(6)) * 0xffffff);
136    //console.log("%c idx "+idx, 'color: #'+color.toString(16));
137  } else {
138    idx = 0;
139  }
140  var debugLineMaterial = new THREE.LineBasicMaterial({color: color, linewidth: 1});
141  var debugLineMesh = new THREE.LineSegments(this.debugLineGeo, debugLineMaterial);
142  debugLineMesh.name = "debugLine";
143  this.scene.add(debugLineMesh);
144
145  this.debugLineGeo = new THREE.Geometry();
146
147  this.points();
148};
149Debug.prototype.cleanup = function () {
150  removeMeshByName(this.scene, "debug");
151  removeMeshByName(this.scene, "debugLine");
152};

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.