Needs a lot of cleanup. Data has been de-duplicated, and where identical copies existed, one of them has been replaced with a symlink. Some files have been excluded, such as binaries, installers and debug dumps. Some of that may still be present.
77 lines
2.2 KiB
JavaScript
77 lines
2.2 KiB
JavaScript
var LOCATION_ORIGIN = {x:-80.5, y:-22.0, z:83.5};
|
|
var LOCATION_POLAR = { min_yaw: 60, max_yaw: 200, min_radius: 6.0, max_radius: 13.0 }
|
|
|
|
|
|
randFloat = function(low, high) {
|
|
return low + Math.random() * (high - low);
|
|
}
|
|
|
|
clamp = function(x, lower, upper) {
|
|
return Math.max(lower, Math.min(upper, x));
|
|
}
|
|
|
|
smoothstep = function(edge0, edge1, x) {
|
|
var t = clamp( (x - edge0) / (edge1 - edge0), 0, 1);
|
|
return t * t * (3.0 - 2.0 * t);
|
|
}
|
|
|
|
function genLocation(seed) {
|
|
var sign = (seed >= 0.5 ? 1.0 : -1.0);
|
|
var absSeed = 2.0 * Math.abs((seed - 0.5));
|
|
//var param = smoothstep(1.0, 0.0, absSeed);
|
|
var param = (1.0 - absSeed) * (1.0 - absSeed);
|
|
var yawCoord = 0.5 + sign * 0.5 * param
|
|
var yaw = LOCATION_POLAR.min_yaw + yawCoord * (LOCATION_POLAR.max_yaw - LOCATION_POLAR.min_yaw);
|
|
|
|
var radiusCoord = (1.0 - Math.abs(2 * yawCoord - 1.0) * Math.abs(2 * yawCoord - 1.0))
|
|
// var radiusCoord = Math.cos(Math.abs(2 * yawCoord - 1.0))
|
|
var radiusNoise = Math.random()
|
|
//var radiusNoise = 1.0
|
|
radiusCoord = radiusCoord * radiusNoise;
|
|
|
|
var radius = LOCATION_POLAR.min_radius + (LOCATION_POLAR.max_radius - LOCATION_POLAR.min_radius) * radiusCoord;
|
|
|
|
var polar = { x: 0, y: yaw * Math.PI / 180, z: radius };
|
|
var p = Vec3.fromPolar(polar);
|
|
|
|
var pos = Vec3.sum(LOCATION_ORIGIN, p);
|
|
print(JSON.stringify(pos))
|
|
return pos;
|
|
}
|
|
|
|
|
|
|
|
var DEFAULT_LIFETIME = 10;
|
|
var TILE_UNIT = 0.2;
|
|
var TILE_DIM = { x: TILE_UNIT, y: TILE_UNIT, z: TILE_UNIT};
|
|
|
|
var crowd = []
|
|
|
|
function genEntity(index, position) {
|
|
return (Entities.addEntity({
|
|
type: "Shape",
|
|
shape: "Cube",
|
|
name: "Distri num " + index,
|
|
// color: getTileColor(a, b, c),
|
|
position: position,
|
|
// rotation: stageOrientation,
|
|
dimensions: TILE_DIM,
|
|
canCastShadow: true,
|
|
userData: JSON.stringify({ grabbableKey: { grabbable: false } }),
|
|
lifetime: DEFAULT_LIFETIME,
|
|
}));
|
|
|
|
}
|
|
|
|
function genCrowd(num) {
|
|
for (i = 0; i < num; i++) {
|
|
var seed = Math.random();
|
|
//var seed = i / (num - 1);
|
|
crowd.push(genEntity(i, genLocation(seed)));
|
|
}
|
|
}
|
|
|
|
genCrowd(200)
|
|
|
|
|
|
|