ds-heightmap
Advanced tools
Comparing version 1.2.2 to 1.2.3
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.ds = void 0; | ||
const random_base_beta_1 = __importDefault(require("@stdlib/random-base-beta")); | ||
const DEFAULT_CONFIG = { | ||
@@ -37,14 +41,14 @@ width: 129, | ||
const p = side - 1; | ||
data[0][0] = Math.random() * depth; | ||
data[0][p] = Math.random() * depth; | ||
data[p][0] = Math.random() * depth; | ||
data[p][p] = Math.random() * depth; | ||
data[0][0] = (0, random_base_beta_1.default)(3, 3) * depth; | ||
data[0][p] = (0, random_base_beta_1.default)(3, 3) * depth; | ||
data[p][0] = (0, random_base_beta_1.default)(3, 3) * depth; | ||
data[p][p] = (0, random_base_beta_1.default)(3, 3) * depth; | ||
shape(side, side); | ||
const output = { data, max, min }; | ||
if (side !== width) { | ||
data.length = width; | ||
if (data.length !== width) { | ||
data.splice(width); | ||
} | ||
if (side !== height) { | ||
if (data[0].length !== height) { | ||
for (const col of data) { | ||
col.length = height; | ||
col.splice(height); | ||
} | ||
@@ -69,3 +73,3 @@ } | ||
} | ||
let n = randomize(corners.reduce((p, c) => p + c, 0) / corners.length, halfW + halfH); | ||
const n = randomize(corners.reduce((p, c) => p + c, 0) / corners.length, halfW + halfH); | ||
if (x < width && y < height) { | ||
@@ -88,11 +92,3 @@ if (n < min) | ||
return randomizer(base, range); | ||
const n = base + | ||
((((Math.random() - base / depth) * | ||
Math.max(base, depth - base) * | ||
range) / | ||
(side + side)) * | ||
rough * | ||
base) / | ||
depth; | ||
return n > depth ? depth : n < 0 ? 0 : n; | ||
return base + (Math.random() - base / depth) * range * rough; | ||
} | ||
@@ -125,3 +121,3 @@ function shape(sizeW, sizeH) { | ||
return; | ||
let n = randomize((data[x - halfW][y - halfH] + | ||
const n = randomize((data[x - halfW][y - halfH] + | ||
data[x + halfW][y - halfH] + | ||
@@ -128,0 +124,0 @@ data[x + halfW][y + halfH] + |
{ | ||
"name": "ds-heightmap", | ||
"version": "1.2.2", | ||
"version": "1.2.3", | ||
"description": "Use diamond-square algorithm to generate heightmaps.", | ||
@@ -38,4 +38,6 @@ "main": "lib/index.js", | ||
"devDependencies": { | ||
"@stdlib/random-base-beta": "^0.0.7", | ||
"buffer": "^6.0.3", | ||
"typescript": "^4.6.3" | ||
} | ||
} |
@@ -7,3 +7,3 @@ { | ||
"description": "Using diamond-square algorithm to generate heightmaps which stored in a 2D-array.", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"license": "MIT", | ||
@@ -17,3 +17,2 @@ "repository": { | ||
"ds_heightmap.js", | ||
"ds_heightmap_bg.js", | ||
"ds_heightmap.d.ts" | ||
@@ -24,7 +23,3 @@ ], | ||
"types": "ds_heightmap.d.ts", | ||
"sideEffects": false, | ||
"keywords": [ | ||
"diamond-square", | ||
"heightmap" | ||
] | ||
"sideEffects": false | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Unpublished package
Supply chain riskPackage version was not found on the registry. It may exist on a different registry and need to be configured to pull from that registry.
Found 1 instance in 1 package
Unpopular package
QualityThis package is not very popular.
Found 1 instance in 1 package
70703
0
3
411
2