PageSourceSearch

https://dww.surge.sh/DWW/js/DWW_trail.js

js dww.surge.sh collected 2026-10-03 14:57:03 UTC 2,430 bytes, 65 lines download raw bytes

1/**
2* A trail is a graphical element that follows a movement particle about the screen. A trail is a property of a movement. 
3**/
4
5function Trail(fromStudioID, toStudioID, role, offset){
6	// this.path = getPath(getStudio(fromStudioName), getStudio(toStudioName));
7	// this.localTrailLength = this.calculateLocalTrailLength(this.path.getLength());
8	this.fromStudioID = fromStudioID;
9	this.toStudioID = toStudioID;
10	this.role = role;
11	this.offset = offset;
12}
13
14/**
15* Static variable indicating the length of all trails
16**/
17Trail.prototype.globalTrailLength = 0.1;
18
19Trail.prototype.buildTrail = function(initPos){
20	var geometry = new THREE.Geometry();
21	for(var i=0; i<10; i++){
22		var v = initPos ? new THREE.Vector3(initPos.x, initPos.y, initPos.z) : new THREE.Vector3();
23		geometry.vertices.push(v);
24	}
25	var mat = applyShader(TrailShader);
26	mat.uniforms = clone(TrailShader.uniforms);
27	mat.attributes = clone(TrailShader.attributes); //!important - as different copies of this shader are being applied to different line instances
28	mat.linewidth = 1.5;
29	var fromStudio = getStudio(this.fromStudioID);
30	var toStudio = getStudio(this.toStudioID);
31	mat.uniforms.offset.value = this.offset; 
32	mat.uniforms.from.value = new THREE.Vector2(fromStudio.lat(), fromStudio.lon());
33	mat.uniforms.to.value = new THREE.Vector2(toStudio.lat(), toStudio.lon());
34	for(var i=0; i<geometry.vertices.length; i++){
35		mat.attributes.index.value.push(i);
36		mat.attributes.normIndex.value.push(norm(i, 0, geometry.vertices.length));
37		mat.attributes.customColor.value.push( getRole(this.role).color );
38	}
39	var line = new THREE.Line(geometry, mat);
40	scene.add(line);
41	return line;
42}
43
44Trail.prototype.calculateLocalTrailLength = function(pathDistance){
45	var totalNumStops = Path.prototype.stopCount;
46	var stopDistance = pathDistance / totalNumStops;
47	return Math.round(this.globalTrailLength / stopDistance);
48}
49
50Trail.prototype.createTrail = function(initPos){
51	if(!this.line) this.line = this.buildTrail(initPos);
52}
53
54Trail.prototype.updateTrail = function(normalisedValue, highlight){
55	if(!this.line) return;
56	this.line.material.uniforms.progression.value = normalisedValue;
57	this.line.material.uniforms.progression.needsUpdate = true;
58	this.line.material.uniforms.highlight.value = highlight;
59	this.line.material.uniforms.highlight.needsUpdate = true;
60}
61
62Trail.prototype.destroyTrail = function(){
63	if(this.line) scene.remove(this.line);
64	this.line = null;
65}

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.