├── .editorconfig ├── .gitignore ├── .npmignore ├── CHANGELOG.md ├── LICENSE.md ├── README.md ├── index.html ├── index.js ├── package-lock.json ├── package.json ├── screenshot.gif ├── src ├── Boid.js ├── Obstacle.js ├── Path.js ├── System.js ├── behaviors.js └── utils.js ├── types.js └── web_modules ├── common ├── es.string.replace-2c4627bc.js ├── es.typed-array.float32-array-53ec9850.js ├── es.typed-array.uint8-array-c10f937c.js ├── esnext.iterator.filter-29316bdb.js ├── esnext.iterator.map-8a38945d.js ├── esnext.iterator.to-array-85996776.js ├── esnext.typed-array.with-8c364bde.js ├── function-apply-8ffa8c0a.js ├── inherit-if-required-1c9a60b3.js ├── object-set-prototype-of-65a42c5e.js └── redefine-all-0f62e567.js ├── dat.gui.js ├── es-module-shims.js ├── gl-matrix.js ├── import-map.json ├── simplex-noise.js ├── three.js └── vector-field.js /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | end_of_line = lf 5 | charset = utf-8 6 | indent_style = space 7 | indent_size = 2 8 | trim_trailing_whitespace = true 9 | insert_final_newline = true 10 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .DS_Store 3 | types 4 | lib 5 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | web_modules 2 | examples 3 | docs 4 | coverage 5 | test 6 | .github 7 | screenshot.* 8 | index.html 9 | tsconfig.json 10 | .editorconfig 11 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. 4 | 5 | ## [0.2.1](https://github.com/dmnsgn/bird-oid/compare/v0.2.0...v0.2.1) (2022-04-26) 6 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright (C) 2020 Damien Seguin 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | bird-oid by dmnsgn (https://github.com/dmnsgn) 8 | 31 | 32 | 33 |
34 |

bird-oid

35 |
36 | 37 | 38 | 39 | 655 | 656 | 657 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | export { default as System } from "./src/System.js"; 2 | export { default as Boid } from "./src/Boid.js"; 3 | export { default as Path } from "./src/Path.js"; 4 | export { default as Obstacle } from "./src/Obstacle.js"; 5 | export * as behaviors from "./src/behaviors.js"; 6 | -------------------------------------------------------------------------------- /package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "bird-oid", 3 | "version": "0.2.1", 4 | "lockfileVersion": 2, 5 | "requires": true, 6 | "packages": { 7 | "": { 8 | "name": "bird-oid", 9 | "version": "0.2.1", 10 | "funding": [ 11 | { 12 | "type": "individual", 13 | "url": "https://paypal.me/dmnsgn" 14 | }, 15 | { 16 | "type": "individual", 17 | "url": "https://commerce.coinbase.com/checkout/56cbdf28-e323-48d8-9c98-7019e72c97f3" 18 | } 19 | ], 20 | "license": "MIT", 21 | "dependencies": { 22 | "gl-matrix": "^3.4.3" 23 | }, 24 | "devDependencies": { 25 | "dat.gui": "^0.7.9", 26 | "es-module-shims": "^1.5.4", 27 | "simplex-noise": "^3.0.1", 28 | "three": "^0.139.2", 29 | "vector-field": "^2.1.0" 30 | }, 31 | "engines": { 32 | "node": ">=16.0.0", 33 | "npm": ">=7.0.0" 34 | } 35 | }, 36 | "node_modules/dat.gui": { 37 | "version": "0.7.9", 38 | "resolved": "https://registry.npmjs.org/dat.gui/-/dat.gui-0.7.9.tgz", 39 | "integrity": "sha512-sCNc1OHobc+Erc1HqiswYgHdVNpSJUlk/Hz8vzOCsER7rl+oF/4+v8GXFUyCgtXpoCX6+bnmg07DedLvBLwYKQ==", 40 | "dev": true 41 | }, 42 | "node_modules/es-module-shims": { 43 | "version": "1.5.4", 44 | "resolved": "https://registry.npmjs.org/es-module-shims/-/es-module-shims-1.5.4.tgz", 45 | "integrity": "sha512-OoVOu69uuLCnlMIcZJnYjZmp/0qhnisTUinU2WtIHztM65S1+SozyiDrmJgowScuMdYO41g8FmII+YXrkZwypA==", 46 | "dev": true 47 | }, 48 | "node_modules/gl-matrix": { 49 | "version": "3.4.3", 50 | "resolved": "https://registry.npmjs.org/gl-matrix/-/gl-matrix-3.4.3.tgz", 51 | "integrity": "sha512-wcCp8vu8FT22BnvKVPjXa/ICBWRq/zjFfdofZy1WSpQZpphblv12/bOQLBC1rMM7SGOFS9ltVmKOHil5+Ml7gA==" 52 | }, 53 | "node_modules/simplex-noise": { 54 | "version": "3.0.1", 55 | "resolved": "https://registry.npmjs.org/simplex-noise/-/simplex-noise-3.0.1.tgz", 56 | "integrity": "sha512-eww0SFiWLyOaUKQMJ7gbdvQJvULeJdM/Y4BiC3rrOQnYHo+MSPh465/qeXSZkpTdB9/HthumpnYD3DobZweBBQ==", 57 | "dev": true 58 | }, 59 | "node_modules/three": { 60 | "version": "0.139.2", 61 | "resolved": "https://registry.npmjs.org/three/-/three-0.139.2.tgz", 62 | "integrity": "sha512-gV7q7QY8rogu7HLFZR9cWnOQAUedUhu2WXAnpr2kdXZP9YDKsG/0ychwQvWkZN5PlNw9mv5MoCTin6zNTXoONg==", 63 | "dev": true 64 | }, 65 | "node_modules/vector-field": { 66 | "version": "2.1.0", 67 | "resolved": "https://registry.npmjs.org/vector-field/-/vector-field-2.1.0.tgz", 68 | "integrity": "sha512-YdLiWhDCpLnye8iM58nb8YnioW8v3wlxib4Sm+XRgoe9IY3LU9lPa3BftolPCiYEYe/Lv0PPyjdZlChMi2hltg==", 69 | "dev": true, 70 | "funding": [ 71 | { 72 | "type": "individual", 73 | "url": "https://paypal.me/dmnsgn" 74 | }, 75 | { 76 | "type": "individual", 77 | "url": "https://commerce.coinbase.com/checkout/56cbdf28-e323-48d8-9c98-7019e72c97f3" 78 | } 79 | ], 80 | "engines": { 81 | "node": ">=15.0.0", 82 | "npm": ">=7.0.0" 83 | } 84 | } 85 | }, 86 | "dependencies": { 87 | "dat.gui": { 88 | "version": "0.7.9", 89 | "resolved": "https://registry.npmjs.org/dat.gui/-/dat.gui-0.7.9.tgz", 90 | "integrity": "sha512-sCNc1OHobc+Erc1HqiswYgHdVNpSJUlk/Hz8vzOCsER7rl+oF/4+v8GXFUyCgtXpoCX6+bnmg07DedLvBLwYKQ==", 91 | "dev": true 92 | }, 93 | "es-module-shims": { 94 | "version": "1.5.4", 95 | "resolved": "https://registry.npmjs.org/es-module-shims/-/es-module-shims-1.5.4.tgz", 96 | "integrity": "sha512-OoVOu69uuLCnlMIcZJnYjZmp/0qhnisTUinU2WtIHztM65S1+SozyiDrmJgowScuMdYO41g8FmII+YXrkZwypA==", 97 | "dev": true 98 | }, 99 | "gl-matrix": { 100 | "version": "3.4.3", 101 | "resolved": "https://registry.npmjs.org/gl-matrix/-/gl-matrix-3.4.3.tgz", 102 | "integrity": "sha512-wcCp8vu8FT22BnvKVPjXa/ICBWRq/zjFfdofZy1WSpQZpphblv12/bOQLBC1rMM7SGOFS9ltVmKOHil5+Ml7gA==" 103 | }, 104 | "simplex-noise": { 105 | "version": "3.0.1", 106 | "resolved": "https://registry.npmjs.org/simplex-noise/-/simplex-noise-3.0.1.tgz", 107 | "integrity": "sha512-eww0SFiWLyOaUKQMJ7gbdvQJvULeJdM/Y4BiC3rrOQnYHo+MSPh465/qeXSZkpTdB9/HthumpnYD3DobZweBBQ==", 108 | "dev": true 109 | }, 110 | "three": { 111 | "version": "0.139.2", 112 | "resolved": "https://registry.npmjs.org/three/-/three-0.139.2.tgz", 113 | "integrity": "sha512-gV7q7QY8rogu7HLFZR9cWnOQAUedUhu2WXAnpr2kdXZP9YDKsG/0ychwQvWkZN5PlNw9mv5MoCTin6zNTXoONg==", 114 | "dev": true 115 | }, 116 | "vector-field": { 117 | "version": "2.1.0", 118 | "resolved": "https://registry.npmjs.org/vector-field/-/vector-field-2.1.0.tgz", 119 | "integrity": "sha512-YdLiWhDCpLnye8iM58nb8YnioW8v3wlxib4Sm+XRgoe9IY3LU9lPa3BftolPCiYEYe/Lv0PPyjdZlChMi2hltg==", 120 | "dev": true 121 | } 122 | } 123 | } 124 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "bird-oid", 3 | "version": "0.2.1", 4 | "description": "A 3D boid system with accompanying emergent behaviors. Implementation mostly based on Craig Reynolds paper Steering Behaviors For Autonomous Characters.", 5 | "keywords": [ 6 | "3d", 7 | "boids", 8 | "behaviors", 9 | "behaviours", 10 | "obstacle", 11 | "path", 12 | "vector-field", 13 | "flow-field", 14 | "steering", 15 | "seek", 16 | "flee", 17 | "pursue", 18 | "evade", 19 | "arrive", 20 | "avoid-obstacles", 21 | "wander", 22 | "follow-path", 23 | "follow-flow-field", 24 | "follow-leader", 25 | "separate", 26 | "cohere", 27 | "align", 28 | "flock", 29 | "bounds", 30 | "sphere", 31 | "wrap" 32 | ], 33 | "homepage": "https://github.com/dmnsgn/bird-oid", 34 | "bugs": "https://github.com/dmnsgn/bird-oid/issues", 35 | "repository": "dmnsgn/bird-oid", 36 | "funding": [ 37 | { 38 | "type": "individual", 39 | "url": "https://paypal.me/dmnsgn" 40 | }, 41 | { 42 | "type": "individual", 43 | "url": "https://commerce.coinbase.com/checkout/56cbdf28-e323-48d8-9c98-7019e72c97f3" 44 | } 45 | ], 46 | "license": "MIT", 47 | "author": "dmnsgn (https://github.com/dmnsgn)", 48 | "type": "module", 49 | "exports": "./index.js", 50 | "main": "index.js", 51 | "types": "types/index.d.ts", 52 | "dependencies": { 53 | "gl-matrix": "^3.4.3" 54 | }, 55 | "devDependencies": { 56 | "dat.gui": "^0.7.9", 57 | "es-module-shims": "^1.5.4", 58 | "simplex-noise": "^3.0.1", 59 | "three": "^0.139.2", 60 | "vector-field": "^2.1.0" 61 | }, 62 | "engines": { 63 | "node": ">=16.0.0", 64 | "npm": ">=7.0.0" 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /screenshot.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dmnsgn/bird-oid/552ba2659d9df149c8731e7557189421daa199a7/screenshot.gif -------------------------------------------------------------------------------- /src/Boid.js: -------------------------------------------------------------------------------- 1 | import { vec3 } from "gl-matrix"; 2 | 3 | import { limit } from "./utils.js"; 4 | 5 | /** 6 | * A data structure for a single Boid. 7 | * 8 | * @property {import("gl-matrix").vec3} position 9 | * @property {import("gl-matrix").vec3} velocity 10 | * @property {import("gl-matrix").vec3} acceleration 11 | * @property {import("gl-matrix").vec3[]} target 12 | * @property {import("../types.js").BehaviorObject[]} behavious 13 | */ 14 | class Boid { 15 | /** 16 | * @param {import("../types.js").BehaviorObject[]} behaviors An array of behaviors to apply to the boid. 17 | */ 18 | constructor(behaviors) { 19 | this.position = vec3.create(); 20 | this.velocity = vec3.create(); 21 | this.acceleration = vec3.create(); 22 | this.target = vec3.create(); 23 | 24 | this.behaviors = behaviors || []; 25 | } 26 | 27 | /** 28 | * Add a force to the boid's acceleration vector. If you need mass, you can either use behaviors.scale or override. 29 | * @param {import("gl-matrix").vec3} force 30 | */ 31 | applyForce(force) { 32 | vec3.add(this.acceleration, this.acceleration, force); 33 | } 34 | 35 | /** 36 | * Compute all the behaviors specified in `boid.behaviors` and apply them via applyForce. Arguments usually come from the system and can be overridden via `behavior.options`. 37 | * @param {import("../types.js").ApplyBehaviorObject} applyOptions 38 | */ 39 | applyBehaviors({ boids, maxSpeed, maxForce, center, bounds }) { 40 | for (let i = 0; i < this.behaviors.length; i++) { 41 | const behavior = this.behaviors[i]; 42 | if (behavior.enabled === false) continue; 43 | 44 | const force = behavior.fn({ 45 | boids, 46 | maxSpeed, 47 | maxForce: this.maxForce || maxForce, 48 | center, 49 | bounds, 50 | position: this.position, 51 | velocity: this.velocity, 52 | target: this.target, 53 | ...behavior.options, 54 | }); 55 | 56 | if (force) { 57 | limit(force, force, this.maxForce || maxForce); 58 | if (behavior.scale) vec3.scale(force, force, behavior.scale || 1); 59 | 60 | this.applyForce(force); 61 | } 62 | } 63 | } 64 | 65 | /** 66 | * Update a boid's position according to its current acceleration/velocity and reset acceleration. Usually called consecutively to `boid.applyBehaviors`. 67 | * @param {number} dt 68 | * @param {number} maxSpeed 69 | */ 70 | update(dt, maxSpeed) { 71 | vec3.scaleAndAdd(this.velocity, this.velocity, this.acceleration, dt); 72 | limit(this.velocity, this.velocity, maxSpeed); 73 | vec3.scaleAndAdd(this.position, this.position, this.velocity, dt); 74 | vec3.set(this.acceleration, 0, 0, 0); 75 | } 76 | } 77 | 78 | export default Boid; 79 | -------------------------------------------------------------------------------- /src/Obstacle.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Data structure used for obstacle avoidance behavior. 3 | */ 4 | class Obstacle { 5 | /** 6 | * @param {import("gl-matrix").vec3} position The center of the obstacle. 7 | * @param {number} radius The radius of the sphere. 8 | */ 9 | constructor(position, radius) { 10 | this.position = position; 11 | this.radius = radius; 12 | } 13 | } 14 | 15 | export default Obstacle; 16 | -------------------------------------------------------------------------------- /src/Path.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Data structure used for path following behavior. 3 | */ 4 | class Path { 5 | /** 6 | * @param {import("gl-matrix").vec3[]} points An array of 3d points. 7 | * @param {number} radius 8 | */ 9 | constructor(points, radius) { 10 | this.points = points; 11 | this.radius = radius; 12 | } 13 | } 14 | 15 | export default Path; 16 | -------------------------------------------------------------------------------- /src/System.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @typedef {Object} SystemOptions 3 | * @property {number} [scale=1] A global scale for the system. 4 | * @property {number} [maxSpeed=scale] A maximum speed for the boids in the system. Can be tweaked individually via `boid.maxSpeed`. 5 | * @property {number} [maxForce=scale] A maximum force for each behavior of a boid. Can be tweaked individually via `boid.maxForce` or via `behaviors.options.maxForce`. 6 | * @property {import("gl-matrix").vec3} [center=[0, 0, 0]] A center point for the system. 7 | * @property {import("gl-matrix").vec3} [bounds=[scale, scale, scale]] Positives bounds x/y/z for the system expanding from the center point. 8 | */ 9 | 10 | /** 11 | * Handle common boids update and global state. 12 | */ 13 | class System { 14 | /** 15 | * @param {SystemOptions} options 16 | */ 17 | constructor(options) { 18 | this.boids = []; 19 | this.scale = 1; 20 | 21 | this.maxSpeed = this.scale; 22 | this.maxForce = this.scale; 23 | 24 | this.center = [0, 0, 0]; 25 | this.bounds = [this.scale, this.scale, this.scale]; 26 | 27 | Object.assign(this, options); 28 | } 29 | 30 | /** 31 | * Get a position within the system's bounds. 32 | * @returns {number[]} 33 | */ 34 | getRandomPosition() { 35 | return [ 36 | (2 * Math.random() - 1) * this.bounds[0] * 0.5 + this.center[0], 37 | (2 * Math.random() - 1) * this.bounds[1] * 0.5 + this.center[1], 38 | (2 * Math.random() - 1) * this.bounds[2] * 0.5 + this.center[2], 39 | ]; 40 | } 41 | 42 | /** 43 | * Push a new boid to the system. 44 | * @param {Boid} boid 45 | */ 46 | addBoid(boid) { 47 | this.boids.push(boid); 48 | } 49 | 50 | /** 51 | * Update all behaviours in the system. 52 | * @param {number} dt 53 | */ 54 | update(dt) { 55 | for (let i = 0; i < this.boids.length; i++) { 56 | const boid = this.boids[i]; 57 | boid.applyBehaviors({ 58 | boids: this.boids, 59 | maxSpeed: this.maxSpeed, 60 | maxForce: this.maxForce, 61 | center: this.center, 62 | bounds: this.bounds, 63 | }); 64 | boid.update(dt, boid.maxSpeed || this.maxSpeed); 65 | } 66 | } 67 | } 68 | 69 | export default System; 70 | -------------------------------------------------------------------------------- /src/behaviors.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @module behaviors 3 | * 4 | * @description 5 | * Steering based on https://www.red3d.com/cwr/steer/gdc99/ 6 | * Use these function as `fn` property of the `BehaviorObject` passed to a `Boid`. 7 | */ 8 | 9 | import { vec3 } from "gl-matrix"; 10 | import { limit } from "./utils.js"; 11 | 12 | // Utils 13 | const getPredictedOffsetFromVelocity = (velocity, maxSpeed, fixedDistance) => { 14 | const distance = fixedDistance || vec3.length(velocity) / maxSpeed; 15 | const predictedPosition = vec3.normalize(vec3.create(), velocity); 16 | return vec3.scale(predictedPosition, predictedPosition, distance); 17 | }; 18 | 19 | const checkPositionsInSphere = (target1, target2, center, radius) => 20 | vec3.distance(center, target1) <= radius || 21 | vec3.distance(center, target2) <= radius; 22 | 23 | // BASICS 24 | // desired_velocity = normalize (position - target) * max_speed 25 | // steering = desired_velocity - velocity 26 | /** 27 | * "Seek (or pursuit of a static target) acts to steer the character towards a specified position in global space." 28 | * @param {import("../types.js").BasicBehaviorOptions} options 29 | * @returns {import("gl-matrix").vec3} 30 | */ 31 | export function seek({ position, target, velocity, maxSpeed }) { 32 | const steering = vec3.create(); 33 | vec3.sub(steering, target, position); 34 | 35 | vec3.normalize(steering, steering); 36 | vec3.scale(steering, steering, maxSpeed); 37 | 38 | return vec3.sub(steering, steering, velocity); 39 | } 40 | 41 | /** 42 | * "Flee is simply the inverse of seek and acts to steer the character so that its velocity is radially aligned away from the target. The desired velocity points in the opposite direction." 43 | * @param {import("../types.js").BasicBehaviorOptions} options 44 | * @returns {import("gl-matrix").vec3} 45 | */ 46 | export function flee(options) { 47 | const steering = seek(options); 48 | return vec3.negate(steering, steering); 49 | } 50 | 51 | // EXTENDED BASICS 52 | const getPredictedPosition = (position, target, targetVelocity, maxSpeed) => { 53 | // A simple estimator of moderate quality is T=Dc where D is the distance between pursuer and quarry, and c is a turning parameter. 54 | const T = vec3.distance(position, target) / maxSpeed; 55 | 56 | const predictedTarget = vec3.create(); 57 | vec3.scale(predictedTarget, targetVelocity, T); 58 | return vec3.add(predictedTarget, target, predictedTarget); 59 | }; 60 | 61 | /** 62 | * "Pursuit is similar to seek except that the quarry (target) is another moving character. [...] The position of a character T units of time in the future (assuming it does not maneuver) can be obtained by scaling its velocity by T and adding that offset to its current position. Steering for pursuit is then simply the result of applying the seek steering behavior to the predicted target location." 63 | * @param {import("../types.js").ExtendedBasicBehaviorOptions} options 64 | * @returns {import("gl-matrix").vec3} 65 | */ 66 | export function pursue({ 67 | position, 68 | target, 69 | velocity, 70 | targetVelocity, 71 | maxSpeed, 72 | }) { 73 | const predictedTarget = getPredictedPosition( 74 | position, 75 | target, 76 | targetVelocity, 77 | maxSpeed 78 | ); 79 | 80 | return seek({ position, target: predictedTarget, velocity, maxSpeed }); 81 | } 82 | 83 | /** 84 | * "Evasion is analogous to pursuit, except that flee is used to steer away from the predicted future position of the target character." 85 | * @param {import("../types.js").ExtendedBasicBehaviorOptions} options 86 | * @returns {import("gl-matrix").vec3} 87 | */ 88 | export function evade({ 89 | position, 90 | target, 91 | velocity, 92 | targetVelocity, 93 | maxSpeed, 94 | }) { 95 | const predictedTarget = getPredictedPosition( 96 | position, 97 | target, 98 | targetVelocity, 99 | maxSpeed 100 | ); 101 | 102 | return flee({ position, target: predictedTarget, velocity, maxSpeed }); 103 | } 104 | 105 | // target_offset = target - position 106 | // distance = length (target_offset) 107 | // ramped_speed = max_speed * (distance / slowing_distance) 108 | // clipped_speed = minimum (ramped_speed, max_speed) 109 | // desired_velocity = (clipped_speed / distance) * target_offset 110 | // steering = desired_velocity - velocity 111 | 112 | /** 113 | * "Arrival behavior is identical to seek while the character is far from its target. But instead of moving through the target at full speed, this behavior causes the character to slow down as it approaches the target, eventually slowing to a stop coincident with the target" 114 | * @param {BasicWithRadiusBehaviorOptions} options 115 | * @returns {import("gl-matrix").vec3} 116 | */ 117 | export function arrive({ position, target, velocity, maxSpeed, radius }) { 118 | const steering = vec3.create(); 119 | const desiredVelocity = vec3.create(); 120 | 121 | vec3.sub(desiredVelocity, target, position); 122 | const length = vec3.length(desiredVelocity); 123 | 124 | vec3.normalize(desiredVelocity, desiredVelocity); 125 | vec3.scale( 126 | desiredVelocity, 127 | desiredVelocity, 128 | Math.min(maxSpeed * (length / radius), maxSpeed) / length 129 | ); 130 | 131 | return vec3.sub(steering, desiredVelocity, velocity); 132 | } 133 | 134 | // OBSTACLES 135 | const findClosestObstacle = ( 136 | position, 137 | obstacles, 138 | aheadVector, 139 | aheadVectorHalf 140 | ) => { 141 | let closestObstacle = null; 142 | let currentDistance; 143 | 144 | for (let i = 0; i < obstacles.length; i++) { 145 | const obstacle = obstacles[i]; 146 | // TODO: is checking for a negative dot product first more efficient? 147 | const collision = checkPositionsInSphere( 148 | aheadVector, 149 | aheadVectorHalf, 150 | obstacle.position, 151 | obstacle.radius 152 | ); 153 | 154 | if (collision) { 155 | if (closestObstacle == null) { 156 | currentDistance = vec3.distance(position, obstacle.position); 157 | closestObstacle = obstacle; 158 | } else if (vec3.distance(position, obstacle.position) < currentDistance) { 159 | currentDistance = vec3.distance(position, obstacle.position); 160 | closestObstacle = obstacle; 161 | } 162 | } 163 | } 164 | return closestObstacle; 165 | }; 166 | 167 | /** 168 | * "The implementation of obstacle avoidance behavior described here will make a simplifying assumption that both the character and obstacle can be reasonably approximated as spheres, although the basic concept can be easily extend to more precise shape models. [...] It is convenient to consider the geometrical situation from the character’s local coordinate system. The goal of the behavior is to keep an imaginary cylinder of free space in front of the character. The cylinder lies along the character’s forward axis, has a diameter equal to the character’s bounding sphere, and extends from the character’s center for a distance based on the character’s speed and agility. An obstacle further than this distance away is not an immediate threat. The obstacle avoidance behavior considers each obstacle in turn (perhaps using a spatial portioning scheme to cull out distance obstacles) and determines if they intersect with the cylinder. By localizing the center of each spherical obstacle, the test for non-intersection with the cylinder is very fast. The local obstacle center is projected onto the side-up plane (by setting its forward coordinate to zero) if the 2D distance from that point to the local origin is greater than the sum of the radii of the obstacle and the character, then there is no potential collision. Similarly obstacles which are fully behind the character, or fully ahead of the cylinder, can be quickly rejected. For any remaining obstacles a line-sphere intersection calculation is performed. The obstacle which intersects the forward axis nearest the character is selected as the “most threatening.” Steering to avoid this obstacle is computed by negating the (lateral) side-up projection of the obstacle’s center. 169 | * @param {ObstacleBehaviorOptions} options 170 | * @returns {import("gl-matrix").vec3} 171 | */ 172 | export function avoidObstacles({ 173 | position, 174 | velocity, 175 | obstacles, 176 | maxSpeed, 177 | maxAvoidForce, 178 | fixedDistance = false, 179 | }) { 180 | const steering = vec3.create(); 181 | 182 | const predictedOffset = getPredictedOffsetFromVelocity( 183 | velocity, 184 | maxSpeed, 185 | fixedDistance 186 | ); 187 | 188 | const aheadVector = vec3.create(); 189 | const aheadVectorHalf = vec3.create(); 190 | vec3.add(aheadVector, position, predictedOffset); 191 | vec3.add( 192 | aheadVectorHalf, 193 | position, 194 | vec3.scale(predictedOffset, predictedOffset, 0.5) 195 | ); 196 | 197 | const closestObstacle = findClosestObstacle( 198 | position, 199 | obstacles, 200 | aheadVector, 201 | aheadVectorHalf 202 | ); 203 | 204 | if (closestObstacle) { 205 | vec3.sub(steering, aheadVector, closestObstacle.position); 206 | vec3.normalize(steering, steering); 207 | vec3.scale(steering, steering, maxAvoidForce); 208 | return steering; 209 | } 210 | 211 | return steering; 212 | } 213 | 214 | // WANDER 215 | // TODO: noise 216 | 217 | /** 218 | * "The steering force takes a “random walk” from one direction to another. This idea [...] is to constrain the steering force to the surface of a sphere located slightly ahead of the character. To produce the steering force for the next frame: a random displacement is added to the previous value, and the sum is constrained again to the sphere’s surface. The sphere’s radius [...] determines the maximum wandering “strength” and the magnitude of the random displacement [...] determines the wander “rate.”" 219 | * Note: Don't forget to update theta and phi angles: angle += Math.random() * WANDER_SPEED - WANDER_SPEED * 0.5; 220 | * @param {WanderBehaviorOptions} options 221 | * @returns {import("gl-matrix").vec3} 222 | */ 223 | export function wander({ velocity, distance, radius, theta, phi }) { 224 | const steering = vec3.create(); 225 | 226 | const sphereCenter = vec3.clone(velocity); 227 | vec3.normalize(sphereCenter, sphereCenter); 228 | vec3.scale(sphereCenter, sphereCenter, distance); 229 | 230 | const displacement = [0, 1, 0]; 231 | vec3.scale(displacement, displacement, radius); 232 | 233 | const length = vec3.length(displacement); 234 | vec3.set( 235 | displacement, 236 | length * (Math.sin(theta) * Math.sin(phi)), 237 | length * Math.cos(theta), 238 | length * (Math.sin(theta) * Math.cos(phi)) 239 | ); 240 | 241 | vec3.add(steering, sphereCenter, displacement); 242 | 243 | return steering; 244 | } 245 | 246 | // FOLLOW 247 | const projectScalar = (position, currentPoint, nextPoint) => { 248 | const a = vec3.sub(vec3.create(), position, currentPoint); 249 | const b = vec3.sub(vec3.create(), nextPoint, currentPoint); 250 | 251 | let magnitude = vec3.length(vec3.normalize(a, a)); 252 | magnitude *= magnitude; 253 | 254 | const x = vec3.dot(a, b) / magnitude; 255 | vec3.scale(a, a, x); 256 | 257 | return vec3.add(vec3.create(), currentPoint, a); 258 | }; 259 | 260 | // TODO: could this have another version following next point in path? 261 | /** 262 | * "Path following behavior enables a character to steer along a predetermined path, such as a roadway, corridor or tunnel." 263 | * @param {FollowPathBehaviorOptions} options 264 | * @returns {import("gl-matrix").vec3} 265 | */ 266 | export function followPath({ 267 | path, 268 | position, 269 | velocity, 270 | maxSpeed, 271 | fixedDistance = false, 272 | }) { 273 | // "To compute steering for path following, a velocity-based prediction is made of the character’s future position." 274 | const predictedPosition = vec3.create(); 275 | vec3.add( 276 | predictedPosition, 277 | position, 278 | getPredictedOffsetFromVelocity(velocity, maxSpeed, fixedDistance) 279 | ); 280 | 281 | let target; 282 | // let segmentDirection = vec3.create(); 283 | let smallestDistanceToPath = Infinity; 284 | 285 | for (let i = 0; i < path.points.length; i++) { 286 | const currentPoint = path.points[i]; 287 | const nextPoint = path.points[(i + 1) % path.points.length]; 288 | 289 | // "The predicted future position is projected onto the nearest point on the path spine." 290 | const normalPoint = projectScalar( 291 | predictedPosition, 292 | currentPoint, 293 | nextPoint 294 | ); 295 | 296 | // TODO: do I need to check the projected point is on the segment? 297 | const distance = vec3.distance(predictedPosition, normalPoint); 298 | if (distance < smallestDistanceToPath) { 299 | target = target || vec3.create(); 300 | smallestDistanceToPath = distance; 301 | vec3.copy(target, normalPoint); 302 | } 303 | } 304 | 305 | // "If this projection distance (from the predicted position to the nearest on-path point) is less than the path radius, then the character is deemed to be correctly following the path and no corrective steering is required. Otherwise the character is veering away from the path, or is too far away from the path. To steer back towards the path, the seek behavior is used to steer towards the on-path projection of the predicted future position. [...]" 306 | // TODO: ahead of normal point 307 | if (smallestDistanceToPath > path.radius) { 308 | return seek({ position, target, velocity, maxSpeed }); 309 | } 310 | } 311 | 312 | /** 313 | * "In flow field following behavior the character steers to align its motion with the local tangent of a flow field (also known as a force field or a vector field). [...] The future position of a character is estimated and the flow field is sampled at that location. This flow direction [...] is the “desired velocity” and the steering direction (vector S) is simply the difference between the current velocity (vector V) and the desired velocity." 314 | * @param {FollowFlowFieldSimpleBehaviorOptions} options 315 | * @returns {import("gl-matrix").vec3} 316 | */ 317 | export function followFlowFieldSimple({ 318 | flowField, 319 | position, 320 | velocity, 321 | maxSpeed, 322 | }) { 323 | const localTangent = flowField.lookup(position); 324 | 325 | if (localTangent) { 326 | const steering = vec3.clone(localTangent.direction); 327 | vec3.normalize(steering, steering); 328 | vec3.scale(steering, steering, maxSpeed); 329 | return vec3.sub(steering, steering, velocity); 330 | } 331 | } 332 | 333 | /** 334 | * @param {FollowFlowFieldBehaviorOptions} options 335 | * @returns {import("gl-matrix").vec3} 336 | */ 337 | export function followFlowField({ 338 | flowField, 339 | position, 340 | velocity, 341 | maxSpeed, 342 | fixedDistance = false, 343 | }) { 344 | const predictedOffset = getPredictedOffsetFromVelocity( 345 | velocity, 346 | maxSpeed, 347 | fixedDistance 348 | ); 349 | 350 | const aheadVector = vec3.create(); 351 | vec3.add(aheadVector, position, predictedOffset); 352 | 353 | const localTangent = flowField.lookup(aheadVector); 354 | 355 | if (localTangent) { 356 | const steering = vec3.clone(localTangent.direction); 357 | vec3.normalize(steering, steering); 358 | vec3.scale(steering, steering, maxSpeed); 359 | return vec3.sub(steering, steering, velocity); 360 | } 361 | } 362 | 363 | /** 364 | * "Leader following behavior causes one or more character to follow another moving character designated as the leader. Generally the followers want to stay near the leader, without crowding the leader, and taking care to stay out of the leader’s way (in case they happen to find them selves in front of the leader). In addition, if there is more than one follower, they want to avoid bumping each other. The implementation of leader following relies on arrival behavior (see above) a desire to move towards a point, slowing as it draws near. The arrival target is a point offset slightly behind the leader. (The offset distance might optionally increases with speed.) If a follower finds itself in a rectangular region in front of the leader, it will steer laterally away from the leader’s path before resuming arrival behavior. In addition the followers use separation behavior to prevent crowding each other." 365 | * @param {FollowLeaderSimpleBehaviorOptions} options 366 | * @returns {import("gl-matrix").vec3} 367 | */ 368 | export function followLeaderSimple({ 369 | leader, 370 | position, 371 | velocity, 372 | maxSpeed, 373 | distance, 374 | radius, 375 | }) { 376 | const target = vec3.clone(leader.velocity); 377 | 378 | vec3.normalize(target, target); 379 | vec3.scale(target, target, distance); 380 | vec3.sub(target, leader.position, target); 381 | 382 | return arrive({ position, target, velocity, maxSpeed, radius }); 383 | } 384 | 385 | /** 386 | * Notes: next behaviour should be a separation 387 | * @param {FollowLeaderBehaviorOptions} options 388 | * @returns {import("gl-matrix").vec3} 389 | */ 390 | export function followLeader({ 391 | leader, 392 | position, 393 | velocity, 394 | maxSpeed, 395 | distance, 396 | radius, 397 | evadeScale = 1, 398 | arriveScale = 1, 399 | }) { 400 | const steering = vec3.create(); 401 | 402 | const target = vec3.clone(leader.velocity); 403 | vec3.normalize(target, target); 404 | vec3.scale(target, target, distance); 405 | 406 | const ahead = vec3.clone(leader.position); 407 | vec3.add(ahead, ahead, target); 408 | 409 | vec3.negate(target, target); 410 | const behind = vec3.clone(leader.position); 411 | vec3.add(behind, behind, target); 412 | 413 | // TODO: use target or currentPosition for forces? 414 | // Note: use sphere instead of rectangle 415 | if (checkPositionsInSphere(position, ahead, leader.position, radius)) { 416 | vec3.scaleAndAdd( 417 | steering, 418 | steering, 419 | evade({ 420 | position, 421 | target: leader.position, 422 | velocity, 423 | targetVelocity: leader.velocity, 424 | maxSpeed, 425 | }), 426 | evadeScale 427 | ); 428 | } 429 | 430 | vec3.scaleAndAdd( 431 | steering, 432 | steering, 433 | arrive({ 434 | position, 435 | target: leader.position, 436 | velocity, 437 | maxSpeed, 438 | radius, 439 | }), 440 | arriveScale 441 | ); 442 | 443 | return steering; 444 | } 445 | 446 | // GROUPS 447 | /** 448 | * "To compute steering for separation, first a search is made to find other characters within the specified neighborhood. [...] For each nearby character, a repulsive force is computed by subtracting the positions of our character and the nearby character, normalizing, and then applying a 1/r weighting. (That is, the position offset vector is scaled by 1/r 2.) Note that 1/r is just a setting that has worked well, not a fundamental value. These repulsive forces for each nearby character are summed together to produce the overall steering force." 449 | * @param {GroupsBehaviorOptions} options 450 | * @returns {import("gl-matrix").vec3} 451 | */ 452 | export function separate({ boids, maxDistance, position, velocity, maxSpeed }) { 453 | const steering = vec3.create(); 454 | 455 | const direction = vec3.create(); 456 | 457 | let neighboursCount = 0; 458 | 459 | for (let i = 0; i < boids.length; i++) { 460 | vec3.sub(direction, position, boids[i].position); 461 | const length = vec3.length(direction); 462 | 463 | if (length > 0 && length < maxDistance) { 464 | vec3.scale(direction, direction, 1 / (length * length)); 465 | vec3.add(steering, steering, direction); 466 | neighboursCount++; 467 | } 468 | } 469 | 470 | if (neighboursCount > 0) { 471 | return seek({ position, target: steering, velocity, maxSpeed }); 472 | } 473 | } 474 | 475 | /** 476 | * "Cohesion steering behavior gives an character the ability to cohere with (approach and form a group with) other nearby characters. [...] Steering for cohesion can be computed by finding all characters in the local neighborhood (as described above for separation), computing the “average position” (or “center of gravity”) of the nearby characters. The steering force can applied in the direction of that “average position” (subtracting our character position from the average position, as in the original boids model), or it can be used as the target for seek steering behavior." 477 | * @param {GroupsBehaviorOptions} options 478 | * @returns {import("gl-matrix").vec3} 479 | */ 480 | export function cohere({ boids, maxDistance, position, velocity, maxSpeed }) { 481 | const steering = vec3.create(); 482 | 483 | const direction = vec3.create(); 484 | let neighboursCount = 0; 485 | 486 | for (let i = 0; i < boids.length; i++) { 487 | vec3.sub(direction, position, boids[i].position); 488 | const length = vec3.length(direction); 489 | 490 | if (length > 0 && length < maxDistance) { 491 | vec3.add(steering, steering, boids[i].position); 492 | neighboursCount++; 493 | } 494 | } 495 | 496 | if (neighboursCount > 0) { 497 | vec3.scale(steering, steering, 1 / neighboursCount); 498 | return seek({ position, target: steering, velocity, maxSpeed }); 499 | } 500 | } 501 | 502 | /** 503 | * "Alignment steering behavior gives an character the ability to align itself with (that is, head in the same direction and/or speed as) other nearby characters [...]. Steering for alignment can be computed by finding all characters in the local neighborhood (as described above for separation), averaging together the velocity (or alternately, the unit forward vector) of the nearby characters. This average is the “desired velocity,” and so the steering vector is the difference between the average and our character’s current velocity (or alternately, its unit forward vector)." 504 | * @param {GroupsBehaviorOptions} options 505 | * @returns {import("gl-matrix").vec3} 506 | */ 507 | export function align({ boids, maxDistance, position, velocity, maxSpeed }) { 508 | const steering = vec3.create(); 509 | 510 | const direction = vec3.create(); 511 | let neighboursCount = 0; 512 | 513 | for (let i = 0; i < boids.length; i++) { 514 | vec3.sub(direction, position, boids[i].position); 515 | const length = vec3.length(direction); 516 | 517 | if (length > 0 && length < maxDistance) { 518 | vec3.add(steering, steering, boids[i].velocity); 519 | neighboursCount++; 520 | } 521 | } 522 | 523 | if (neighboursCount > 0) { 524 | vec3.scale(steering, steering, 1 / neighboursCount); 525 | 526 | vec3.normalize(steering, steering); 527 | vec3.scale(steering, steering, maxSpeed); 528 | 529 | return seek({ position, target: steering, velocity, maxSpeed }); 530 | } 531 | } 532 | 533 | /** 534 | * "[...] in addition to other applications, the separation, cohesion and alignment behaviors can be combined to produce the boids model of flocks, herds and schools" 535 | * @param {GroupsBehaviorOptions} options 536 | * @returns {import("gl-matrix").vec3} 537 | */ 538 | export function flock({ boids, maxDistance, position, velocity, maxSpeed }) { 539 | const steering = vec3.create(); 540 | 541 | const separation = separate({ 542 | boids, 543 | maxDistance, 544 | position, 545 | velocity, 546 | maxSpeed, 547 | }); 548 | if (separation) vec3.add(steering, steering, separation); 549 | 550 | const cohesion = cohere({ boids, maxDistance, position, velocity, maxSpeed }); 551 | if (cohesion) vec3.add(steering, steering, cohesion); 552 | 553 | const alignment = align({ boids, maxDistance, position, velocity, maxSpeed }); 554 | if (alignment) vec3.add(steering, steering, alignment); 555 | 556 | return steering; 557 | } 558 | 559 | // CONSTRAINTS 560 | /** 561 | * Constraint in system bounds. 562 | * @param {BoundsConstraintBehaviorOptions} options 563 | * @returns {import("gl-matrix").vec3} 564 | */ 565 | export function boundsConstrain({ 566 | center, 567 | bounds, 568 | position, 569 | velocity, 570 | maxSpeed, 571 | maxForce, 572 | fixedDistance = false, 573 | }) { 574 | const desiredVelocity = vec3.create(); 575 | 576 | const predictedPosition = vec3.create(); 577 | vec3.add( 578 | predictedPosition, 579 | position, 580 | getPredictedOffsetFromVelocity(velocity, maxSpeed, fixedDistance) 581 | ); 582 | 583 | for (let i = 0; i < 3; i++) { 584 | if (predictedPosition[i] > center[i] + bounds[i] * 0.5) { 585 | desiredVelocity[i] = -maxSpeed; 586 | } 587 | if (predictedPosition[i] < center[i] - bounds[i] * 0.5) { 588 | desiredVelocity[i] = maxSpeed; 589 | } 590 | } 591 | 592 | if (vec3.length(desiredVelocity) > 0) { 593 | const steering = vec3.clone(desiredVelocity); 594 | vec3.normalize(steering, steering); 595 | vec3.scale(steering, steering, maxSpeed); 596 | vec3.sub(steering, steering, velocity); 597 | return limit(steering, steering, maxForce); 598 | } 599 | } 600 | 601 | /** 602 | * Constraint in sphere bounds. 603 | * @param {SphereConstraintBehaviorOptions} options 604 | * @returns {import("gl-matrix").vec3} 605 | */ 606 | export function sphereConstrain({ 607 | center, 608 | radius, 609 | position, 610 | velocity, 611 | maxSpeed, 612 | maxForce, 613 | fixedDistance = false, 614 | }) { 615 | const predictedPosition = vec3.create(); 616 | vec3.add( 617 | predictedPosition, 618 | position, 619 | getPredictedOffsetFromVelocity(velocity, maxSpeed, fixedDistance) 620 | ); 621 | 622 | const distance = vec3.distance(center, predictedPosition); 623 | 624 | if (distance > radius) { 625 | const steering = vec3.clone(position); 626 | vec3.sub(steering, center, steering); 627 | vec3.normalize(steering, steering); 628 | vec3.scale(steering, steering, maxSpeed); 629 | vec3.sub(steering, steering, velocity); 630 | return limit(steering, steering, maxForce); 631 | } 632 | } 633 | 634 | // TODO: add random velocity in the right direction when respawn 635 | /** 636 | * Wrap to opposite bound (no velocity change). 637 | * @param {BoundsWrapConstraintBehaviorOptions} options 638 | * @returns {import("gl-matrix").vec3} 639 | */ 640 | export function boundsWrapConstrain({ position, center, bounds }) { 641 | for (let i = 0; i < 3; i++) { 642 | const min = center[i] - bounds[i] * 0.5; 643 | const max = center[i] + bounds[i] * 0.5; 644 | if (position[i] > max) { 645 | position[i] = min; 646 | } else if (position[i] < min) { 647 | position[i] = max; 648 | } 649 | } 650 | return false; 651 | } 652 | 653 | /** 654 | * Wrap to opposite bound (no velocity change). 655 | * @param {SphereWrapConstraintBehaviorOptions} options 656 | * @returns {import("gl-matrix").vec3} 657 | */ 658 | export function sphereWrapConstrain({ position, center, radius }) { 659 | const distance = vec3.distance(center, position); 660 | if (distance > radius) { 661 | const opposite = vec3.create(); 662 | vec3.sub(opposite, center, position); 663 | vec3.normalize(opposite, opposite); 664 | vec3.scale(opposite, opposite, radius - Number.EPSILON); 665 | vec3.copy(position, opposite); 666 | } 667 | return false; 668 | } 669 | -------------------------------------------------------------------------------- /src/utils.js: -------------------------------------------------------------------------------- 1 | import { vec3 } from "gl-matrix"; 2 | 3 | function limit(out, a, n) { 4 | const squaredLength = vec3.squaredLength(a); 5 | 6 | if (squaredLength > n * n) { 7 | const v = n / Math.sqrt(squaredLength); 8 | out[0] *= v; 9 | out[1] *= v; 10 | out[2] *= v; 11 | } 12 | 13 | return out; 14 | } 15 | 16 | export { limit }; 17 | -------------------------------------------------------------------------------- /types.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @typedef {number} Radians 3 | */ 4 | 5 | /** 6 | * @typedef {Object} BehaviorObject 7 | * @property {Function} fn 8 | * @property {boolean} enabled 9 | * @property {number} scale 10 | * @property {Object} options 11 | */ 12 | 13 | /** 14 | * @typedef {Object} ApplyBehaviorObject 15 | * @property {Boid[]} boids 16 | * @property {number} maxSpeed 17 | * @property {number} [maxForce] 18 | * @property {import("gl-matrix").vec3} center 19 | * @property {import("gl-matrix").vec3} bounds 20 | */ 21 | 22 | /** 23 | * @typedef {Object} BehaviorOptions 24 | * @property {import("gl-matrix").vec3} position 25 | * @property {import("gl-matrix").vec3} velocity 26 | * @property {number} maxSpeed 27 | */ 28 | 29 | // Basics 30 | /** 31 | * @typedef {BehaviorOptions} BasicBehaviorOptions 32 | * @property {import("gl-matrix").vec3} target 33 | */ 34 | /** 35 | * @typedef {BasicBehaviorOptions} ExtendedBasicBehaviorOptions 36 | * @property {import("gl-matrix").vec3} targetVelocity 37 | */ 38 | /** 39 | * @typedef {BasicBehaviorOptions} BasicWithRadiusBehaviorOptions 40 | * @property {number} radius 41 | */ 42 | 43 | // Obstacles 44 | /** 45 | * @typedef {BehaviorOptions} ObstacleBehaviorOptions 46 | * @property {Obstacles[]} obstacles 47 | * @property {number} maxAvoidForce 48 | * @property {boolean} [fixedDistance=false] 49 | */ 50 | 51 | // Wander 52 | /** 53 | * @typedef {Object} WanderBehaviorOptions 54 | * @property {import("gl-matrix").vec3} velocity 55 | * @property {number} distance 56 | * @property {number} maxSpeed 57 | * @property {number} radius 58 | * @property {Radians} theta 59 | * @property {Radians} phi 60 | */ 61 | 62 | // Follow 63 | /** 64 | * @typedef {BehaviorOptions} FollowPathBehaviorOptions 65 | * @property {Path} path 66 | * @property {boolean} [fixedDistance=false] 67 | */ 68 | /** 69 | * @typedef {BehaviorOptions} FollowFlowFieldSimpleBehaviorOptions 70 | * @property {import("vector-field").FlowField} flowField 71 | */ 72 | /** 73 | * @typedef {FollowFlowFieldSimpleBehaviorOptions} FollowFlowFieldBehaviorOptions 74 | * @property {import("vector-field").FlowField} flowField 75 | * @property {boolean} [fixedDistance=false] 76 | */ 77 | /** 78 | * @typedef {BehaviorOptions} FollowLeaderSimpleBehaviorOptions 79 | * @property {Boid} leader 80 | * @property {number} distance 81 | * @property {number} radius 82 | */ 83 | /** 84 | * @typedef {FollowLeaderSimpleBehaviorOptions} FollowLeaderBehaviorOptions 85 | * @property {number} [evadeScale=1] 86 | * @property {number} [arriveScale=1] 87 | */ 88 | 89 | // Groups 90 | /** 91 | * @typedef {BehaviorOptions} GroupsBehaviorOptions 92 | * @property {Boid[]} boids 93 | * @property {number} maxDistance 94 | */ 95 | 96 | // Constraints 97 | /** 98 | * @typedef {BehaviorOptions} ConstraintBehaviorOptions 99 | * @property {import("gl-matrix").vec3} center 100 | * @property {number} maxDistance 101 | * @property {boolean} [fixedDistance=false] 102 | */ 103 | /** 104 | * @typedef {ConstraintBehaviorOptions} BoundsConstraintBehaviorOptions 105 | * @property {import("gl-matrix").vec3} bounds 106 | */ 107 | /** 108 | * @typedef {ConstraintBehaviorOptions} SphereConstraintBehaviorOptions 109 | * @property {number} radius 110 | */ 111 | /** 112 | * @typedef {Object} WrapConstraintBehaviorOptions 113 | * @property {import("gl-matrix").vec3} position 114 | * @property {import("gl-matrix").vec3} center 115 | */ 116 | /** 117 | * @typedef {WrapConstraintBehaviorOptions} BoundsWrapConstraintBehaviorOptions 118 | * @property {import("gl-matrix").vec3} bounds 119 | */ 120 | /** 121 | * @typedef {WrapConstraintBehaviorOptions} SphereWrapConstraintBehaviorOptions 122 | * @property {number} radius 123 | */ 124 | 125 | export {}; 126 | -------------------------------------------------------------------------------- /web_modules/common/es.string.replace-2c4627bc.js: -------------------------------------------------------------------------------- 1 | import { g as global_1, a as anObject, b as getBuiltIn, d as aCallable, f as functionCall, e as getMethod, w as wellKnownSymbol, i as isCallable, j as fails, h as hasOwnProperty_1, c as createNonEnumerableProperty, _ as _export, t as tryToString, l as lengthOfArrayLike, o as objectIsPrototypeOf, k as isObject, m as functionUncurryThis, n as createPropertyDescriptor, p as objectSetPrototypeOf, q as copyConstructorProperties, s as shared, r as objectCreate, u as internalState, v as redefine, x as requireObjectCoercible, y as toIntegerOrInfinity, z as toObject, A as classofRaw, B as toLength } from './object-set-prototype-of-65a42c5e.js'; 2 | import { a as anInstance, f as functionBindContext, g as getIteratorMethod, i as isArrayIteratorMethod, b as getIterator, c as classof, d as inheritIfRequired } from './inherit-if-required-1c9a60b3.js'; 3 | import { i as iteratorsCore, b as iteratorClose, f as functionApply } from './function-apply-8ffa8c0a.js'; 4 | 5 | var isPure = false; 6 | 7 | // https://github.com/tc39/proposal-iterator-helpers 8 | // https://github.com/tc39/proposal-array-from-async 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | var MAX_SAFE_INTEGER = 0x1FFFFFFFFFFFFF; 17 | var TypeError$1 = global_1.TypeError; 18 | 19 | var createMethod = function (TYPE) { 20 | var IS_TO_ARRAY = TYPE == 0; 21 | var IS_FOR_EACH = TYPE == 1; 22 | var IS_EVERY = TYPE == 2; 23 | var IS_SOME = TYPE == 3; 24 | return function (iterator, fn, target) { 25 | anObject(iterator); 26 | var Promise = getBuiltIn('Promise'); 27 | var next = aCallable(iterator.next); 28 | var index = 0; 29 | var MAPPING = fn !== undefined; 30 | if (MAPPING || !IS_TO_ARRAY) aCallable(fn); 31 | 32 | return new Promise(function (resolve, reject) { 33 | var closeIteration = function (method, argument) { 34 | try { 35 | var returnMethod = getMethod(iterator, 'return'); 36 | if (returnMethod) { 37 | return Promise.resolve(functionCall(returnMethod, iterator)).then(function () { 38 | method(argument); 39 | }, function (error) { 40 | reject(error); 41 | }); 42 | } 43 | } catch (error2) { 44 | return reject(error2); 45 | } method(argument); 46 | }; 47 | 48 | var onError = function (error) { 49 | closeIteration(reject, error); 50 | }; 51 | 52 | var loop = function () { 53 | try { 54 | if (IS_TO_ARRAY && (index > MAX_SAFE_INTEGER) && MAPPING) { 55 | throw TypeError$1('The allowed number of iterations has been exceeded'); 56 | } 57 | Promise.resolve(anObject(functionCall(next, iterator))).then(function (step) { 58 | try { 59 | if (anObject(step).done) { 60 | if (IS_TO_ARRAY) { 61 | target.length = index; 62 | resolve(target); 63 | } else resolve(IS_SOME ? false : IS_EVERY || undefined); 64 | } else { 65 | var value = step.value; 66 | if (MAPPING) { 67 | Promise.resolve(IS_TO_ARRAY ? fn(value, index) : fn(value)).then(function (result) { 68 | if (IS_FOR_EACH) { 69 | loop(); 70 | } else if (IS_EVERY) { 71 | result ? loop() : closeIteration(resolve, false); 72 | } else if (IS_TO_ARRAY) { 73 | target[index++] = result; 74 | loop(); 75 | } else { 76 | result ? closeIteration(resolve, IS_SOME || value) : loop(); 77 | } 78 | }, onError); 79 | } else { 80 | target[index++] = value; 81 | loop(); 82 | } 83 | } 84 | } catch (error) { onError(error); } 85 | }, onError); 86 | } catch (error2) { onError(error2); } 87 | }; 88 | 89 | loop(); 90 | }); 91 | }; 92 | }; 93 | 94 | var asyncIteratorIteration = { 95 | toArray: createMethod(0), 96 | forEach: createMethod(1), 97 | every: createMethod(2), 98 | some: createMethod(3), 99 | find: createMethod(4) 100 | }; 101 | 102 | // https://github.com/tc39/proposal-iterator-helpers 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | var IteratorPrototype = iteratorsCore.IteratorPrototype; 112 | 113 | 114 | var TO_STRING_TAG = wellKnownSymbol('toStringTag'); 115 | 116 | var NativeIterator = global_1.Iterator; 117 | 118 | // FF56- have non-standard global helper `Iterator` 119 | var FORCED = !isCallable(NativeIterator) 120 | || NativeIterator.prototype !== IteratorPrototype 121 | // FF44- non-standard `Iterator` passes previous tests 122 | || !fails(function () { NativeIterator({}); }); 123 | 124 | var IteratorConstructor = function Iterator() { 125 | anInstance(this, IteratorPrototype); 126 | }; 127 | 128 | if (!hasOwnProperty_1(IteratorPrototype, TO_STRING_TAG)) { 129 | createNonEnumerableProperty(IteratorPrototype, TO_STRING_TAG, 'Iterator'); 130 | } 131 | 132 | if (FORCED || !hasOwnProperty_1(IteratorPrototype, 'constructor') || IteratorPrototype.constructor === Object) { 133 | createNonEnumerableProperty(IteratorPrototype, 'constructor', IteratorConstructor); 134 | } 135 | 136 | IteratorConstructor.prototype = IteratorPrototype; 137 | 138 | _export({ global: true, forced: FORCED }, { 139 | Iterator: IteratorConstructor 140 | }); 141 | 142 | var TypeError$2 = global_1.TypeError; 143 | 144 | var Result = function (stopped, result) { 145 | this.stopped = stopped; 146 | this.result = result; 147 | }; 148 | 149 | var ResultPrototype = Result.prototype; 150 | 151 | var iterate = function (iterable, unboundFunction, options) { 152 | var that = options && options.that; 153 | var AS_ENTRIES = !!(options && options.AS_ENTRIES); 154 | var IS_ITERATOR = !!(options && options.IS_ITERATOR); 155 | var INTERRUPTED = !!(options && options.INTERRUPTED); 156 | var fn = functionBindContext(unboundFunction, that); 157 | var iterator, iterFn, index, length, result, next, step; 158 | 159 | var stop = function (condition) { 160 | if (iterator) iteratorClose(iterator, 'normal', condition); 161 | return new Result(true, condition); 162 | }; 163 | 164 | var callFn = function (value) { 165 | if (AS_ENTRIES) { 166 | anObject(value); 167 | return INTERRUPTED ? fn(value[0], value[1], stop) : fn(value[0], value[1]); 168 | } return INTERRUPTED ? fn(value, stop) : fn(value); 169 | }; 170 | 171 | if (IS_ITERATOR) { 172 | iterator = iterable; 173 | } else { 174 | iterFn = getIteratorMethod(iterable); 175 | if (!iterFn) throw TypeError$2(tryToString(iterable) + ' is not iterable'); 176 | // optimisation for array iterators 177 | if (isArrayIteratorMethod(iterFn)) { 178 | for (index = 0, length = lengthOfArrayLike(iterable); length > index; index++) { 179 | result = callFn(iterable[index]); 180 | if (result && objectIsPrototypeOf(ResultPrototype, result)) return result; 181 | } return new Result(false); 182 | } 183 | iterator = getIterator(iterable, iterFn); 184 | } 185 | 186 | next = iterator.next; 187 | while (!(step = functionCall(next, iterator)).done) { 188 | try { 189 | result = callFn(step.value); 190 | } catch (error) { 191 | iteratorClose(iterator, 'throw', error); 192 | } 193 | if (typeof result == 'object' && result && objectIsPrototypeOf(ResultPrototype, result)) return result; 194 | } return new Result(false); 195 | }; 196 | 197 | var String$1 = global_1.String; 198 | 199 | var toString_1 = function (argument) { 200 | if (classof(argument) === 'Symbol') throw TypeError('Cannot convert a Symbol value to a string'); 201 | return String$1(argument); 202 | }; 203 | 204 | var normalizeStringArgument = function (argument, $default) { 205 | return argument === undefined ? arguments.length < 2 ? '' : $default : toString_1(argument); 206 | }; 207 | 208 | // `InstallErrorCause` abstract operation 209 | // https://tc39.es/proposal-error-cause/#sec-errorobjects-install-error-cause 210 | var installErrorCause = function (O, options) { 211 | if (isObject(options) && 'cause' in options) { 212 | createNonEnumerableProperty(O, 'cause', options.cause); 213 | } 214 | }; 215 | 216 | var replace = functionUncurryThis(''.replace); 217 | 218 | var TEST = (function (arg) { return String(Error(arg).stack); })('zxcasd'); 219 | var V8_OR_CHAKRA_STACK_ENTRY = /\n\s*at [^:]*:[^\n]*/; 220 | var IS_V8_OR_CHAKRA_STACK = V8_OR_CHAKRA_STACK_ENTRY.test(TEST); 221 | 222 | var clearErrorStack = function (stack, dropEntries) { 223 | if (IS_V8_OR_CHAKRA_STACK && typeof stack == 'string') { 224 | while (dropEntries--) stack = replace(stack, V8_OR_CHAKRA_STACK_ENTRY, ''); 225 | } return stack; 226 | }; 227 | 228 | var errorStackInstallable = !fails(function () { 229 | var error = Error('a'); 230 | if (!('stack' in error)) return true; 231 | // eslint-disable-next-line es/no-object-defineproperty -- safe 232 | Object.defineProperty(error, 'stack', createPropertyDescriptor(1, 7)); 233 | return error.stack !== 7; 234 | }); 235 | 236 | var wrapErrorConstructorWithCause = function (FULL_NAME, wrapper, FORCED, IS_AGGREGATE_ERROR) { 237 | var OPTIONS_POSITION = IS_AGGREGATE_ERROR ? 2 : 1; 238 | var path = FULL_NAME.split('.'); 239 | var ERROR_NAME = path[path.length - 1]; 240 | var OriginalError = getBuiltIn.apply(null, path); 241 | 242 | if (!OriginalError) return; 243 | 244 | var OriginalErrorPrototype = OriginalError.prototype; 245 | 246 | // V8 9.3- bug https://bugs.chromium.org/p/v8/issues/detail?id=12006 247 | if ( hasOwnProperty_1(OriginalErrorPrototype, 'cause')) delete OriginalErrorPrototype.cause; 248 | 249 | if (!FORCED) return OriginalError; 250 | 251 | var BaseError = getBuiltIn('Error'); 252 | 253 | var WrappedError = wrapper(function (a, b) { 254 | var message = normalizeStringArgument(IS_AGGREGATE_ERROR ? b : a, undefined); 255 | var result = IS_AGGREGATE_ERROR ? new OriginalError(a) : new OriginalError(); 256 | if (message !== undefined) createNonEnumerableProperty(result, 'message', message); 257 | if (errorStackInstallable) createNonEnumerableProperty(result, 'stack', clearErrorStack(result.stack, 2)); 258 | if (this && objectIsPrototypeOf(OriginalErrorPrototype, this)) inheritIfRequired(result, this, WrappedError); 259 | if (arguments.length > OPTIONS_POSITION) installErrorCause(result, arguments[OPTIONS_POSITION]); 260 | return result; 261 | }); 262 | 263 | WrappedError.prototype = OriginalErrorPrototype; 264 | 265 | if (ERROR_NAME !== 'Error') { 266 | if (objectSetPrototypeOf) objectSetPrototypeOf(WrappedError, BaseError); 267 | else copyConstructorProperties(WrappedError, BaseError, { name: true }); 268 | } 269 | 270 | copyConstructorProperties(WrappedError, OriginalError); 271 | 272 | try { 273 | // Safari 13- bug: WebAssembly errors does not have a proper `.name` 274 | if (OriginalErrorPrototype.name !== ERROR_NAME) { 275 | createNonEnumerableProperty(OriginalErrorPrototype, 'name', ERROR_NAME); 276 | } 277 | OriginalErrorPrototype.constructor = WrappedError; 278 | } catch (error) { /* empty */ } 279 | 280 | return WrappedError; 281 | }; 282 | 283 | /* eslint-disable no-unused-vars -- required for functions `.length` */ 284 | 285 | 286 | 287 | 288 | 289 | var WEB_ASSEMBLY = 'WebAssembly'; 290 | var WebAssembly = global_1[WEB_ASSEMBLY]; 291 | 292 | var FORCED$1 = Error('e', { cause: 7 }).cause !== 7; 293 | 294 | var exportGlobalErrorCauseWrapper = function (ERROR_NAME, wrapper) { 295 | var O = {}; 296 | O[ERROR_NAME] = wrapErrorConstructorWithCause(ERROR_NAME, wrapper, FORCED$1); 297 | _export({ global: true, forced: FORCED$1 }, O); 298 | }; 299 | 300 | var exportWebAssemblyErrorCauseWrapper = function (ERROR_NAME, wrapper) { 301 | if (WebAssembly && WebAssembly[ERROR_NAME]) { 302 | var O = {}; 303 | O[ERROR_NAME] = wrapErrorConstructorWithCause(WEB_ASSEMBLY + '.' + ERROR_NAME, wrapper, FORCED$1); 304 | _export({ target: WEB_ASSEMBLY, stat: true, forced: FORCED$1 }, O); 305 | } 306 | }; 307 | 308 | // https://github.com/tc39/proposal-error-cause 309 | exportGlobalErrorCauseWrapper('Error', function (init) { 310 | return function Error(message) { return functionApply(init, this, arguments); }; 311 | }); 312 | exportGlobalErrorCauseWrapper('EvalError', function (init) { 313 | return function EvalError(message) { return functionApply(init, this, arguments); }; 314 | }); 315 | exportGlobalErrorCauseWrapper('RangeError', function (init) { 316 | return function RangeError(message) { return functionApply(init, this, arguments); }; 317 | }); 318 | exportGlobalErrorCauseWrapper('ReferenceError', function (init) { 319 | return function ReferenceError(message) { return functionApply(init, this, arguments); }; 320 | }); 321 | exportGlobalErrorCauseWrapper('SyntaxError', function (init) { 322 | return function SyntaxError(message) { return functionApply(init, this, arguments); }; 323 | }); 324 | exportGlobalErrorCauseWrapper('TypeError', function (init) { 325 | return function TypeError(message) { return functionApply(init, this, arguments); }; 326 | }); 327 | exportGlobalErrorCauseWrapper('URIError', function (init) { 328 | return function URIError(message) { return functionApply(init, this, arguments); }; 329 | }); 330 | exportWebAssemblyErrorCauseWrapper('CompileError', function (init) { 331 | return function CompileError(message) { return functionApply(init, this, arguments); }; 332 | }); 333 | exportWebAssemblyErrorCauseWrapper('LinkError', function (init) { 334 | return function LinkError(message) { return functionApply(init, this, arguments); }; 335 | }); 336 | exportWebAssemblyErrorCauseWrapper('RuntimeError', function (init) { 337 | return function RuntimeError(message) { return functionApply(init, this, arguments); }; 338 | }); 339 | 340 | // `RegExp.prototype.flags` getter implementation 341 | // https://tc39.es/ecma262/#sec-get-regexp.prototype.flags 342 | var regexpFlags = function () { 343 | var that = anObject(this); 344 | var result = ''; 345 | if (that.global) result += 'g'; 346 | if (that.ignoreCase) result += 'i'; 347 | if (that.multiline) result += 'm'; 348 | if (that.dotAll) result += 's'; 349 | if (that.unicode) result += 'u'; 350 | if (that.sticky) result += 'y'; 351 | return result; 352 | }; 353 | 354 | // babel-minify and Closure Compiler transpiles RegExp('a', 'y') -> /a/y and it causes SyntaxError 355 | var $RegExp = global_1.RegExp; 356 | 357 | var UNSUPPORTED_Y = fails(function () { 358 | var re = $RegExp('a', 'y'); 359 | re.lastIndex = 2; 360 | return re.exec('abcd') != null; 361 | }); 362 | 363 | // UC Browser bug 364 | // https://github.com/zloirock/core-js/issues/1008 365 | var MISSED_STICKY = UNSUPPORTED_Y || fails(function () { 366 | return !$RegExp('a', 'y').sticky; 367 | }); 368 | 369 | var BROKEN_CARET = UNSUPPORTED_Y || fails(function () { 370 | // https://bugzilla.mozilla.org/show_bug.cgi?id=773687 371 | var re = $RegExp('^r', 'gy'); 372 | re.lastIndex = 2; 373 | return re.exec('str') != null; 374 | }); 375 | 376 | var regexpStickyHelpers = { 377 | BROKEN_CARET: BROKEN_CARET, 378 | MISSED_STICKY: MISSED_STICKY, 379 | UNSUPPORTED_Y: UNSUPPORTED_Y 380 | }; 381 | 382 | // babel-minify and Closure Compiler transpiles RegExp('.', 's') -> /./s and it causes SyntaxError 383 | var $RegExp$1 = global_1.RegExp; 384 | 385 | var regexpUnsupportedDotAll = fails(function () { 386 | var re = $RegExp$1('.', 's'); 387 | return !(re.dotAll && re.exec('\n') && re.flags === 's'); 388 | }); 389 | 390 | // babel-minify and Closure Compiler transpiles RegExp('(?b)', 'g') -> /(?b)/g and it causes SyntaxError 391 | var $RegExp$2 = global_1.RegExp; 392 | 393 | var regexpUnsupportedNcg = fails(function () { 394 | var re = $RegExp$2('(?b)', 'g'); 395 | return re.exec('b').groups.a !== 'b' || 396 | 'b'.replace(re, '$c') !== 'bc'; 397 | }); 398 | 399 | /* eslint-disable regexp/no-empty-capturing-group, regexp/no-empty-group, regexp/no-lazy-ends -- testing */ 400 | /* eslint-disable regexp/no-useless-quantifier -- testing */ 401 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | var getInternalState = internalState.get; 409 | 410 | 411 | 412 | var nativeReplace = shared('native-string-replace', String.prototype.replace); 413 | var nativeExec = RegExp.prototype.exec; 414 | var patchedExec = nativeExec; 415 | var charAt = functionUncurryThis(''.charAt); 416 | var indexOf = functionUncurryThis(''.indexOf); 417 | var replace$1 = functionUncurryThis(''.replace); 418 | var stringSlice = functionUncurryThis(''.slice); 419 | 420 | var UPDATES_LAST_INDEX_WRONG = (function () { 421 | var re1 = /a/; 422 | var re2 = /b*/g; 423 | functionCall(nativeExec, re1, 'a'); 424 | functionCall(nativeExec, re2, 'a'); 425 | return re1.lastIndex !== 0 || re2.lastIndex !== 0; 426 | })(); 427 | 428 | var UNSUPPORTED_Y$1 = regexpStickyHelpers.BROKEN_CARET; 429 | 430 | // nonparticipating capturing group, copied from es5-shim's String#split patch. 431 | var NPCG_INCLUDED = /()??/.exec('')[1] !== undefined; 432 | 433 | var PATCH = UPDATES_LAST_INDEX_WRONG || NPCG_INCLUDED || UNSUPPORTED_Y$1 || regexpUnsupportedDotAll || regexpUnsupportedNcg; 434 | 435 | if (PATCH) { 436 | patchedExec = function exec(string) { 437 | var re = this; 438 | var state = getInternalState(re); 439 | var str = toString_1(string); 440 | var raw = state.raw; 441 | var result, reCopy, lastIndex, match, i, object, group; 442 | 443 | if (raw) { 444 | raw.lastIndex = re.lastIndex; 445 | result = functionCall(patchedExec, raw, str); 446 | re.lastIndex = raw.lastIndex; 447 | return result; 448 | } 449 | 450 | var groups = state.groups; 451 | var sticky = UNSUPPORTED_Y$1 && re.sticky; 452 | var flags = functionCall(regexpFlags, re); 453 | var source = re.source; 454 | var charsAdded = 0; 455 | var strCopy = str; 456 | 457 | if (sticky) { 458 | flags = replace$1(flags, 'y', ''); 459 | if (indexOf(flags, 'g') === -1) { 460 | flags += 'g'; 461 | } 462 | 463 | strCopy = stringSlice(str, re.lastIndex); 464 | // Support anchored sticky behavior. 465 | if (re.lastIndex > 0 && (!re.multiline || re.multiline && charAt(str, re.lastIndex - 1) !== '\n')) { 466 | source = '(?: ' + source + ')'; 467 | strCopy = ' ' + strCopy; 468 | charsAdded++; 469 | } 470 | // ^(? + rx + ) is needed, in combination with some str slicing, to 471 | // simulate the 'y' flag. 472 | reCopy = new RegExp('^(?:' + source + ')', flags); 473 | } 474 | 475 | if (NPCG_INCLUDED) { 476 | reCopy = new RegExp('^' + source + '$(?!\\s)', flags); 477 | } 478 | if (UPDATES_LAST_INDEX_WRONG) lastIndex = re.lastIndex; 479 | 480 | match = functionCall(nativeExec, sticky ? reCopy : re, strCopy); 481 | 482 | if (sticky) { 483 | if (match) { 484 | match.input = stringSlice(match.input, charsAdded); 485 | match[0] = stringSlice(match[0], charsAdded); 486 | match.index = re.lastIndex; 487 | re.lastIndex += match[0].length; 488 | } else re.lastIndex = 0; 489 | } else if (UPDATES_LAST_INDEX_WRONG && match) { 490 | re.lastIndex = re.global ? match.index + match[0].length : lastIndex; 491 | } 492 | if (NPCG_INCLUDED && match && match.length > 1) { 493 | // Fix browsers whose `exec` methods don't consistently return `undefined` 494 | // for NPCG, like IE8. NOTE: This doesn' work for /(.?)?/ 495 | functionCall(nativeReplace, match[0], reCopy, function () { 496 | for (i = 1; i < arguments.length - 2; i++) { 497 | if (arguments[i] === undefined) match[i] = undefined; 498 | } 499 | }); 500 | } 501 | 502 | if (match && groups) { 503 | match.groups = object = objectCreate(null); 504 | for (i = 0; i < groups.length; i++) { 505 | group = groups[i]; 506 | object[group[0]] = match[group[1]]; 507 | } 508 | } 509 | 510 | return match; 511 | }; 512 | } 513 | 514 | var regexpExec = patchedExec; 515 | 516 | // `RegExp.prototype.exec` method 517 | // https://tc39.es/ecma262/#sec-regexp.prototype.exec 518 | _export({ target: 'RegExp', proto: true, forced: /./.exec !== regexpExec }, { 519 | exec: regexpExec 520 | }); 521 | 522 | // TODO: Remove from `core-js@4` since it's moved to entry points 523 | 524 | 525 | 526 | 527 | 528 | 529 | 530 | 531 | var SPECIES = wellKnownSymbol('species'); 532 | var RegExpPrototype = RegExp.prototype; 533 | 534 | var fixRegexpWellKnownSymbolLogic = function (KEY, exec, FORCED, SHAM) { 535 | var SYMBOL = wellKnownSymbol(KEY); 536 | 537 | var DELEGATES_TO_SYMBOL = !fails(function () { 538 | // String methods call symbol-named RegEp methods 539 | var O = {}; 540 | O[SYMBOL] = function () { return 7; }; 541 | return ''[KEY](O) != 7; 542 | }); 543 | 544 | var DELEGATES_TO_EXEC = DELEGATES_TO_SYMBOL && !fails(function () { 545 | // Symbol-named RegExp methods call .exec 546 | var execCalled = false; 547 | var re = /a/; 548 | 549 | if (KEY === 'split') { 550 | // We can't use real regex here since it causes deoptimization 551 | // and serious performance degradation in V8 552 | // https://github.com/zloirock/core-js/issues/306 553 | re = {}; 554 | // RegExp[@@split] doesn't call the regex's exec method, but first creates 555 | // a new one. We need to return the patched regex when creating the new one. 556 | re.constructor = {}; 557 | re.constructor[SPECIES] = function () { return re; }; 558 | re.flags = ''; 559 | re[SYMBOL] = /./[SYMBOL]; 560 | } 561 | 562 | re.exec = function () { execCalled = true; return null; }; 563 | 564 | re[SYMBOL](''); 565 | return !execCalled; 566 | }); 567 | 568 | if ( 569 | !DELEGATES_TO_SYMBOL || 570 | !DELEGATES_TO_EXEC || 571 | FORCED 572 | ) { 573 | var uncurriedNativeRegExpMethod = functionUncurryThis(/./[SYMBOL]); 574 | var methods = exec(SYMBOL, ''[KEY], function (nativeMethod, regexp, str, arg2, forceStringMethod) { 575 | var uncurriedNativeMethod = functionUncurryThis(nativeMethod); 576 | var $exec = regexp.exec; 577 | if ($exec === regexpExec || $exec === RegExpPrototype.exec) { 578 | if (DELEGATES_TO_SYMBOL && !forceStringMethod) { 579 | // The native String method already delegates to @@method (this 580 | // polyfilled function), leasing to infinite recursion. 581 | // We avoid it by directly calling the native @@method method. 582 | return { done: true, value: uncurriedNativeRegExpMethod(regexp, str, arg2) }; 583 | } 584 | return { done: true, value: uncurriedNativeMethod(str, regexp, arg2) }; 585 | } 586 | return { done: false }; 587 | }); 588 | 589 | redefine(String.prototype, KEY, methods[0]); 590 | redefine(RegExpPrototype, SYMBOL, methods[1]); 591 | } 592 | 593 | if (SHAM) createNonEnumerableProperty(RegExpPrototype[SYMBOL], 'sham', true); 594 | }; 595 | 596 | var charAt$1 = functionUncurryThis(''.charAt); 597 | var charCodeAt = functionUncurryThis(''.charCodeAt); 598 | var stringSlice$1 = functionUncurryThis(''.slice); 599 | 600 | var createMethod$1 = function (CONVERT_TO_STRING) { 601 | return function ($this, pos) { 602 | var S = toString_1(requireObjectCoercible($this)); 603 | var position = toIntegerOrInfinity(pos); 604 | var size = S.length; 605 | var first, second; 606 | if (position < 0 || position >= size) return CONVERT_TO_STRING ? '' : undefined; 607 | first = charCodeAt(S, position); 608 | return first < 0xD800 || first > 0xDBFF || position + 1 === size 609 | || (second = charCodeAt(S, position + 1)) < 0xDC00 || second > 0xDFFF 610 | ? CONVERT_TO_STRING 611 | ? charAt$1(S, position) 612 | : first 613 | : CONVERT_TO_STRING 614 | ? stringSlice$1(S, position, position + 2) 615 | : (first - 0xD800 << 10) + (second - 0xDC00) + 0x10000; 616 | }; 617 | }; 618 | 619 | var stringMultibyte = { 620 | // `String.prototype.codePointAt` method 621 | // https://tc39.es/ecma262/#sec-string.prototype.codepointat 622 | codeAt: createMethod$1(false), 623 | // `String.prototype.at` method 624 | // https://github.com/mathiasbynens/String.prototype.at 625 | charAt: createMethod$1(true) 626 | }; 627 | 628 | var charAt$2 = stringMultibyte.charAt; 629 | 630 | // `AdvanceStringIndex` abstract operation 631 | // https://tc39.es/ecma262/#sec-advancestringindex 632 | var advanceStringIndex = function (S, index, unicode) { 633 | return index + (unicode ? charAt$2(S, index).length : 1); 634 | }; 635 | 636 | var floor = Math.floor; 637 | var charAt$3 = functionUncurryThis(''.charAt); 638 | var replace$2 = functionUncurryThis(''.replace); 639 | var stringSlice$2 = functionUncurryThis(''.slice); 640 | var SUBSTITUTION_SYMBOLS = /\$([$&'`]|\d{1,2}|<[^>]*>)/g; 641 | var SUBSTITUTION_SYMBOLS_NO_NAMED = /\$([$&'`]|\d{1,2})/g; 642 | 643 | // `GetSubstitution` abstract operation 644 | // https://tc39.es/ecma262/#sec-getsubstitution 645 | var getSubstitution = function (matched, str, position, captures, namedCaptures, replacement) { 646 | var tailPos = position + matched.length; 647 | var m = captures.length; 648 | var symbols = SUBSTITUTION_SYMBOLS_NO_NAMED; 649 | if (namedCaptures !== undefined) { 650 | namedCaptures = toObject(namedCaptures); 651 | symbols = SUBSTITUTION_SYMBOLS; 652 | } 653 | return replace$2(replacement, symbols, function (match, ch) { 654 | var capture; 655 | switch (charAt$3(ch, 0)) { 656 | case '$': return '$'; 657 | case '&': return matched; 658 | case '`': return stringSlice$2(str, 0, position); 659 | case "'": return stringSlice$2(str, tailPos); 660 | case '<': 661 | capture = namedCaptures[stringSlice$2(ch, 1, -1)]; 662 | break; 663 | default: // \d\d? 664 | var n = +ch; 665 | if (n === 0) return match; 666 | if (n > m) { 667 | var f = floor(n / 10); 668 | if (f === 0) return match; 669 | if (f <= m) return captures[f - 1] === undefined ? charAt$3(ch, 1) : captures[f - 1] + charAt$3(ch, 1); 670 | return match; 671 | } 672 | capture = captures[n - 1]; 673 | } 674 | return capture === undefined ? '' : capture; 675 | }); 676 | }; 677 | 678 | var TypeError$3 = global_1.TypeError; 679 | 680 | // `RegExpExec` abstract operation 681 | // https://tc39.es/ecma262/#sec-regexpexec 682 | var regexpExecAbstract = function (R, S) { 683 | var exec = R.exec; 684 | if (isCallable(exec)) { 685 | var result = functionCall(exec, R, S); 686 | if (result !== null) anObject(result); 687 | return result; 688 | } 689 | if (classofRaw(R) === 'RegExp') return functionCall(regexpExec, R, S); 690 | throw TypeError$3('RegExp#exec called on incompatible receiver'); 691 | }; 692 | 693 | var REPLACE = wellKnownSymbol('replace'); 694 | var max = Math.max; 695 | var min = Math.min; 696 | var concat = functionUncurryThis([].concat); 697 | var push = functionUncurryThis([].push); 698 | var stringIndexOf = functionUncurryThis(''.indexOf); 699 | var stringSlice$3 = functionUncurryThis(''.slice); 700 | 701 | var maybeToString = function (it) { 702 | return it === undefined ? it : String(it); 703 | }; 704 | 705 | // IE <= 11 replaces $0 with the whole match, as if it was $& 706 | // https://stackoverflow.com/questions/6024666/getting-ie-to-replace-a-regex-with-the-literal-string-0 707 | var REPLACE_KEEPS_$0 = (function () { 708 | // eslint-disable-next-line regexp/prefer-escape-replacement-dollar-char -- required for testing 709 | return 'a'.replace(/./, '$0') === '$0'; 710 | })(); 711 | 712 | // Safari <= 13.0.3(?) substitutes nth capture where n>m with an empty string 713 | var REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE = (function () { 714 | if (/./[REPLACE]) { 715 | return /./[REPLACE]('a', '$0') === ''; 716 | } 717 | return false; 718 | })(); 719 | 720 | var REPLACE_SUPPORTS_NAMED_GROUPS = !fails(function () { 721 | var re = /./; 722 | re.exec = function () { 723 | var result = []; 724 | result.groups = { a: '7' }; 725 | return result; 726 | }; 727 | // eslint-disable-next-line regexp/no-useless-dollar-replacements -- false positive 728 | return ''.replace(re, '$') !== '7'; 729 | }); 730 | 731 | // @@replace logic 732 | fixRegexpWellKnownSymbolLogic('replace', function (_, nativeReplace, maybeCallNative) { 733 | var UNSAFE_SUBSTITUTE = REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE ? '$' : '$0'; 734 | 735 | return [ 736 | // `String.prototype.replace` method 737 | // https://tc39.es/ecma262/#sec-string.prototype.replace 738 | function replace(searchValue, replaceValue) { 739 | var O = requireObjectCoercible(this); 740 | var replacer = searchValue == undefined ? undefined : getMethod(searchValue, REPLACE); 741 | return replacer 742 | ? functionCall(replacer, searchValue, O, replaceValue) 743 | : functionCall(nativeReplace, toString_1(O), searchValue, replaceValue); 744 | }, 745 | // `RegExp.prototype[@@replace]` method 746 | // https://tc39.es/ecma262/#sec-regexp.prototype-@@replace 747 | function (string, replaceValue) { 748 | var rx = anObject(this); 749 | var S = toString_1(string); 750 | 751 | if ( 752 | typeof replaceValue == 'string' && 753 | stringIndexOf(replaceValue, UNSAFE_SUBSTITUTE) === -1 && 754 | stringIndexOf(replaceValue, '$<') === -1 755 | ) { 756 | var res = maybeCallNative(nativeReplace, rx, S, replaceValue); 757 | if (res.done) return res.value; 758 | } 759 | 760 | var functionalReplace = isCallable(replaceValue); 761 | if (!functionalReplace) replaceValue = toString_1(replaceValue); 762 | 763 | var global = rx.global; 764 | if (global) { 765 | var fullUnicode = rx.unicode; 766 | rx.lastIndex = 0; 767 | } 768 | var results = []; 769 | while (true) { 770 | var result = regexpExecAbstract(rx, S); 771 | if (result === null) break; 772 | 773 | push(results, result); 774 | if (!global) break; 775 | 776 | var matchStr = toString_1(result[0]); 777 | if (matchStr === '') rx.lastIndex = advanceStringIndex(S, toLength(rx.lastIndex), fullUnicode); 778 | } 779 | 780 | var accumulatedResult = ''; 781 | var nextSourcePosition = 0; 782 | for (var i = 0; i < results.length; i++) { 783 | result = results[i]; 784 | 785 | var matched = toString_1(result[0]); 786 | var position = max(min(toIntegerOrInfinity(result.index), S.length), 0); 787 | var captures = []; 788 | // NOTE: This is equivalent to 789 | // captures = result.slice(1).map(maybeToString) 790 | // but for some reason `nativeSlice.call(result, 1, result.length)` (called in 791 | // the slice polyfill when slicing native arrays) "doesn't work" in safari 9 and 792 | // causes a crash (https://pastebin.com/N21QzeQA) when trying to debug it. 793 | for (var j = 1; j < result.length; j++) push(captures, maybeToString(result[j])); 794 | var namedCaptures = result.groups; 795 | if (functionalReplace) { 796 | var replacerArgs = concat([matched], captures, position, S); 797 | if (namedCaptures !== undefined) push(replacerArgs, namedCaptures); 798 | var replacement = toString_1(functionApply(replaceValue, undefined, replacerArgs)); 799 | } else { 800 | replacement = getSubstitution(matched, S, position, captures, namedCaptures, replaceValue); 801 | } 802 | if (position >= nextSourcePosition) { 803 | accumulatedResult += stringSlice$3(S, nextSourcePosition, position) + replacement; 804 | nextSourcePosition = position + matched.length; 805 | } 806 | } 807 | return accumulatedResult + stringSlice$3(S, nextSourcePosition); 808 | } 809 | ]; 810 | }, !REPLACE_SUPPORTS_NAMED_GROUPS || !REPLACE_KEEPS_$0 || REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE); 811 | 812 | export { asyncIteratorIteration as a, isPure as b, iterate as i, stringMultibyte as s, toString_1 as t }; 813 | -------------------------------------------------------------------------------- /web_modules/common/es.typed-array.float32-array-53ec9850.js: -------------------------------------------------------------------------------- 1 | import { t as typedArrayConstructor } from './esnext.typed-array.with-8c364bde.js'; 2 | 3 | // `Float32Array` constructor 4 | // https://tc39.es/ecma262/#sec-typedarray-objects 5 | typedArrayConstructor('Float32', function (init) { 6 | return function Float32Array(data, byteOffset, length) { 7 | return init(this, data, byteOffset, length); 8 | }; 9 | }); 10 | -------------------------------------------------------------------------------- /web_modules/common/es.typed-array.uint8-array-c10f937c.js: -------------------------------------------------------------------------------- 1 | import { t as typedArrayConstructor } from './esnext.typed-array.with-8c364bde.js'; 2 | 3 | // `Uint8Array` constructor 4 | // https://tc39.es/ecma262/#sec-typedarray-objects 5 | typedArrayConstructor('Uint8', function (init) { 6 | return function Uint8Array(data, byteOffset, length) { 7 | return init(this, data, byteOffset, length); 8 | }; 9 | }); 10 | -------------------------------------------------------------------------------- /web_modules/common/esnext.iterator.filter-29316bdb.js: -------------------------------------------------------------------------------- 1 | import { t as typedArrayConstructor } from './esnext.typed-array.with-8c364bde.js'; 2 | import { _ as _export, a as anObject, d as aCallable } from './object-set-prototype-of-65a42c5e.js'; 3 | import { f as functionApply } from './function-apply-8ffa8c0a.js'; 4 | import { a as asyncIteratorCreateProxy, i as iteratorCreateProxy, c as callWithSafeIterationClosing } from './esnext.iterator.map-8a38945d.js'; 5 | 6 | // `Uint16Array` constructor 7 | // https://tc39.es/ecma262/#sec-typedarray-objects 8 | typedArrayConstructor('Uint16', function (init) { 9 | return function Uint16Array(data, byteOffset, length) { 10 | return init(this, data, byteOffset, length); 11 | }; 12 | }); 13 | 14 | // https://github.com/tc39/proposal-iterator-helpers 15 | 16 | 17 | 18 | 19 | 20 | 21 | var AsyncIteratorProxy = asyncIteratorCreateProxy(function (Promise, args) { 22 | var state = this; 23 | var filterer = state.filterer; 24 | 25 | return new Promise(function (resolve, reject) { 26 | var loop = function () { 27 | try { 28 | Promise.resolve(anObject(functionApply(state.next, state.iterator, args))).then(function (step) { 29 | try { 30 | if (anObject(step).done) { 31 | state.done = true; 32 | resolve({ done: true, value: undefined }); 33 | } else { 34 | var value = step.value; 35 | Promise.resolve(filterer(value)).then(function (selected) { 36 | selected ? resolve({ done: false, value: value }) : loop(); 37 | }, reject); 38 | } 39 | } catch (err) { reject(err); } 40 | }, reject); 41 | } catch (error) { reject(error); } 42 | }; 43 | 44 | loop(); 45 | }); 46 | }); 47 | 48 | _export({ target: 'AsyncIterator', proto: true, real: true, forced: true }, { 49 | filter: function filter(filterer) { 50 | return new AsyncIteratorProxy({ 51 | iterator: anObject(this), 52 | filterer: aCallable(filterer) 53 | }); 54 | } 55 | }); 56 | 57 | // https://github.com/tc39/proposal-iterator-helpers 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | var IteratorProxy = iteratorCreateProxy(function (args) { 66 | var iterator = this.iterator; 67 | var filterer = this.filterer; 68 | var next = this.next; 69 | var result, done, value; 70 | while (true) { 71 | result = anObject(functionApply(next, iterator, args)); 72 | done = this.done = !!result.done; 73 | if (done) return; 74 | value = result.value; 75 | if (callWithSafeIterationClosing(iterator, filterer, value)) return value; 76 | } 77 | }); 78 | 79 | _export({ target: 'Iterator', proto: true, real: true, forced: true }, { 80 | filter: function filter(filterer) { 81 | return new IteratorProxy({ 82 | iterator: anObject(this), 83 | filterer: aCallable(filterer) 84 | }); 85 | } 86 | }); 87 | -------------------------------------------------------------------------------- /web_modules/common/esnext.iterator.map-8a38945d.js: -------------------------------------------------------------------------------- 1 | import { a as anObject, b as getBuiltIn, u as internalState, w as wellKnownSymbol, d as aCallable, f as functionCall, e as getMethod, r as objectCreate, c as createNonEnumerableProperty, _ as _export } from './object-set-prototype-of-65a42c5e.js'; 2 | import { b as iteratorClose, a as asyncIteratorPrototype, f as functionApply, i as iteratorsCore } from './function-apply-8ffa8c0a.js'; 3 | import { r as redefineAll } from './redefine-all-0f62e567.js'; 4 | 5 | // call something on iterator step with safe closing on error 6 | var callWithSafeIterationClosing = function (iterator, fn, value, ENTRIES) { 7 | try { 8 | return ENTRIES ? fn(anObject(value)[0], value[1]) : fn(value); 9 | } catch (error) { 10 | iteratorClose(iterator, 'throw', error); 11 | } 12 | }; 13 | 14 | var Promise = getBuiltIn('Promise'); 15 | 16 | var ASYNC_ITERATOR_PROXY = 'AsyncIteratorProxy'; 17 | var setInternalState = internalState.set; 18 | var getInternalState = internalState.getterFor(ASYNC_ITERATOR_PROXY); 19 | 20 | var TO_STRING_TAG = wellKnownSymbol('toStringTag'); 21 | 22 | var asyncIteratorCreateProxy = function (nextHandler, IS_ITERATOR) { 23 | var AsyncIteratorProxy = function AsyncIterator(state) { 24 | state.type = ASYNC_ITERATOR_PROXY; 25 | state.next = aCallable(state.iterator.next); 26 | state.done = false; 27 | state.ignoreArgument = !IS_ITERATOR; 28 | setInternalState(this, state); 29 | }; 30 | 31 | AsyncIteratorProxy.prototype = redefineAll(objectCreate(asyncIteratorPrototype), { 32 | next: function next(arg) { 33 | var that = this; 34 | var hasArgument = !!arguments.length; 35 | return new Promise(function (resolve) { 36 | var state = getInternalState(that); 37 | var args = hasArgument ? [state.ignoreArgument ? undefined : arg] : IS_ITERATOR ? [] : [undefined]; 38 | state.ignoreArgument = false; 39 | resolve(state.done ? { done: true, value: undefined } : anObject(functionCall(nextHandler, state, Promise, args))); 40 | }); 41 | }, 42 | 'return': function (value) { 43 | var that = this; 44 | return new Promise(function (resolve, reject) { 45 | var state = getInternalState(that); 46 | var iterator = state.iterator; 47 | state.done = true; 48 | var $$return = getMethod(iterator, 'return'); 49 | if ($$return === undefined) return resolve({ done: true, value: value }); 50 | Promise.resolve(functionCall($$return, iterator, value)).then(function (result) { 51 | anObject(result); 52 | resolve({ done: true, value: value }); 53 | }, reject); 54 | }); 55 | }, 56 | 'throw': function (value) { 57 | var that = this; 58 | return new Promise(function (resolve, reject) { 59 | var state = getInternalState(that); 60 | var iterator = state.iterator; 61 | state.done = true; 62 | var $$throw = getMethod(iterator, 'throw'); 63 | if ($$throw === undefined) return reject(value); 64 | resolve(functionCall($$throw, iterator, value)); 65 | }); 66 | } 67 | }); 68 | 69 | if (!IS_ITERATOR) { 70 | createNonEnumerableProperty(AsyncIteratorProxy.prototype, TO_STRING_TAG, 'Generator'); 71 | } 72 | 73 | return AsyncIteratorProxy; 74 | }; 75 | 76 | // https://github.com/tc39/proposal-iterator-helpers 77 | 78 | 79 | 80 | 81 | 82 | 83 | var AsyncIteratorProxy = asyncIteratorCreateProxy(function (Promise, args) { 84 | var state = this; 85 | var mapper = state.mapper; 86 | 87 | return Promise.resolve(anObject(functionApply(state.next, state.iterator, args))).then(function (step) { 88 | if (anObject(step).done) { 89 | state.done = true; 90 | return { done: true, value: undefined }; 91 | } 92 | return Promise.resolve(mapper(step.value)).then(function (value) { 93 | return { done: false, value: value }; 94 | }); 95 | }); 96 | }); 97 | 98 | _export({ target: 'AsyncIterator', proto: true, real: true, forced: true }, { 99 | map: function map(mapper) { 100 | return new AsyncIteratorProxy({ 101 | iterator: anObject(this), 102 | mapper: aCallable(mapper) 103 | }); 104 | } 105 | }); 106 | 107 | var IteratorPrototype = iteratorsCore.IteratorPrototype; 108 | 109 | var ITERATOR_PROXY = 'IteratorProxy'; 110 | var setInternalState$1 = internalState.set; 111 | var getInternalState$1 = internalState.getterFor(ITERATOR_PROXY); 112 | 113 | var TO_STRING_TAG$1 = wellKnownSymbol('toStringTag'); 114 | 115 | var iteratorCreateProxy = function (nextHandler, IS_ITERATOR) { 116 | var IteratorProxy = function Iterator(state) { 117 | state.type = ITERATOR_PROXY; 118 | state.next = aCallable(state.iterator.next); 119 | state.done = false; 120 | state.ignoreArg = !IS_ITERATOR; 121 | setInternalState$1(this, state); 122 | }; 123 | 124 | IteratorProxy.prototype = redefineAll(objectCreate(IteratorPrototype), { 125 | next: function next(arg) { 126 | var state = getInternalState$1(this); 127 | var args = arguments.length ? [state.ignoreArg ? undefined : arg] : IS_ITERATOR ? [] : [undefined]; 128 | state.ignoreArg = false; 129 | var result = state.done ? undefined : functionCall(nextHandler, state, args); 130 | return { done: state.done, value: result }; 131 | }, 132 | 'return': function (value) { 133 | var state = getInternalState$1(this); 134 | var iterator = state.iterator; 135 | state.done = true; 136 | var $$return = getMethod(iterator, 'return'); 137 | return { done: true, value: $$return ? anObject(functionCall($$return, iterator, value)).value : value }; 138 | }, 139 | 'throw': function (value) { 140 | var state = getInternalState$1(this); 141 | var iterator = state.iterator; 142 | state.done = true; 143 | var $$throw = getMethod(iterator, 'throw'); 144 | if ($$throw) return functionCall($$throw, iterator, value); 145 | throw value; 146 | } 147 | }); 148 | 149 | if (!IS_ITERATOR) { 150 | createNonEnumerableProperty(IteratorProxy.prototype, TO_STRING_TAG$1, 'Generator'); 151 | } 152 | 153 | return IteratorProxy; 154 | }; 155 | 156 | // https://github.com/tc39/proposal-iterator-helpers 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | var IteratorProxy = iteratorCreateProxy(function (args) { 165 | var iterator = this.iterator; 166 | var result = anObject(functionApply(this.next, iterator, args)); 167 | var done = this.done = !!result.done; 168 | if (!done) return callWithSafeIterationClosing(iterator, this.mapper, result.value); 169 | }); 170 | 171 | _export({ target: 'Iterator', proto: true, real: true, forced: true }, { 172 | map: function map(mapper) { 173 | return new IteratorProxy({ 174 | iterator: anObject(this), 175 | mapper: aCallable(mapper) 176 | }); 177 | } 178 | }); 179 | 180 | export { asyncIteratorCreateProxy as a, callWithSafeIterationClosing as c, iteratorCreateProxy as i }; 181 | -------------------------------------------------------------------------------- /web_modules/common/esnext.iterator.to-array-85996776.js: -------------------------------------------------------------------------------- 1 | import { _ as _export, a as anObject, w as wellKnownSymbol, h as hasOwnProperty_1, c as createNonEnumerableProperty } from './object-set-prototype-of-65a42c5e.js'; 2 | import { a as asyncIteratorIteration, i as iterate, b as isPure } from './es.string.replace-2c4627bc.js'; 3 | import { a as anInstance } from './inherit-if-required-1c9a60b3.js'; 4 | import { a as asyncIteratorPrototype } from './function-apply-8ffa8c0a.js'; 5 | 6 | // https://github.com/tc39/proposal-iterator-helpers 7 | 8 | var $forEach = asyncIteratorIteration.forEach; 9 | 10 | _export({ target: 'AsyncIterator', proto: true, real: true, forced: true }, { 11 | forEach: function forEach(fn) { 12 | return $forEach(this, fn); 13 | } 14 | }); 15 | 16 | // https://github.com/tc39/proposal-iterator-helpers 17 | 18 | 19 | 20 | 21 | _export({ target: 'Iterator', proto: true, real: true, forced: true }, { 22 | forEach: function forEach(fn) { 23 | iterate(anObject(this), fn, { IS_ITERATOR: true }); 24 | } 25 | }); 26 | 27 | // https://github.com/tc39/proposal-iterator-helpers 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | var TO_STRING_TAG = wellKnownSymbol('toStringTag'); 37 | 38 | var AsyncIteratorConstructor = function AsyncIterator() { 39 | anInstance(this, asyncIteratorPrototype); 40 | }; 41 | 42 | AsyncIteratorConstructor.prototype = asyncIteratorPrototype; 43 | 44 | if (!hasOwnProperty_1(asyncIteratorPrototype, TO_STRING_TAG)) { 45 | createNonEnumerableProperty(asyncIteratorPrototype, TO_STRING_TAG, 'AsyncIterator'); 46 | } 47 | 48 | if ( !hasOwnProperty_1(asyncIteratorPrototype, 'constructor') || asyncIteratorPrototype.constructor === Object) { 49 | createNonEnumerableProperty(asyncIteratorPrototype, 'constructor', AsyncIteratorConstructor); 50 | } 51 | 52 | _export({ global: true, forced: isPure }, { 53 | AsyncIterator: AsyncIteratorConstructor 54 | }); 55 | 56 | // https://github.com/tc39/proposal-iterator-helpers 57 | 58 | var $toArray = asyncIteratorIteration.toArray; 59 | 60 | _export({ target: 'AsyncIterator', proto: true, real: true, forced: true }, { 61 | toArray: function toArray() { 62 | return $toArray(this, undefined, []); 63 | } 64 | }); 65 | 66 | // https://github.com/tc39/proposal-iterator-helpers 67 | 68 | 69 | 70 | 71 | var push = [].push; 72 | 73 | _export({ target: 'Iterator', proto: true, real: true, forced: true }, { 74 | toArray: function toArray() { 75 | var result = []; 76 | iterate(anObject(this), push, { that: result, IS_ITERATOR: true }); 77 | return result; 78 | } 79 | }); 80 | -------------------------------------------------------------------------------- /web_modules/common/function-apply-8ffa8c0a.js: -------------------------------------------------------------------------------- 1 | import { w as wellKnownSymbol, C as objectGetPrototypeOf, j as fails, i as isCallable, v as redefine, a as anObject, e as getMethod, f as functionCall, g as global_1, D as sharedStore, E as documentCreateElement, F as objectDefineProperty, r as objectCreate, n as createPropertyDescriptor, G as setToStringTag, H as iterators, p as objectSetPrototypeOf, c as createNonEnumerableProperty, _ as _export, I as functionName, u as internalState, J as descriptors, K as toIndexedObject, L as functionBindNative } from './object-set-prototype-of-65a42c5e.js'; 2 | 3 | var ITERATOR = wellKnownSymbol('iterator'); 4 | var BUGGY_SAFARI_ITERATORS = false; 5 | 6 | // `%IteratorPrototype%` object 7 | // https://tc39.es/ecma262/#sec-%iteratorprototype%-object 8 | var IteratorPrototype, PrototypeOfArrayIteratorPrototype, arrayIterator; 9 | 10 | /* eslint-disable es/no-array-prototype-keys -- safe */ 11 | if ([].keys) { 12 | arrayIterator = [].keys(); 13 | // Safari 8 has buggy iterators w/o `next` 14 | if (!('next' in arrayIterator)) BUGGY_SAFARI_ITERATORS = true; 15 | else { 16 | PrototypeOfArrayIteratorPrototype = objectGetPrototypeOf(objectGetPrototypeOf(arrayIterator)); 17 | if (PrototypeOfArrayIteratorPrototype !== Object.prototype) IteratorPrototype = PrototypeOfArrayIteratorPrototype; 18 | } 19 | } 20 | 21 | var NEW_ITERATOR_PROTOTYPE = IteratorPrototype == undefined || fails(function () { 22 | var test = {}; 23 | // FF44- legacy iterators case 24 | return IteratorPrototype[ITERATOR].call(test) !== test; 25 | }); 26 | 27 | if (NEW_ITERATOR_PROTOTYPE) IteratorPrototype = {}; 28 | 29 | // `%IteratorPrototype%[@@iterator]()` method 30 | // https://tc39.es/ecma262/#sec-%iteratorprototype%-@@iterator 31 | if (!isCallable(IteratorPrototype[ITERATOR])) { 32 | redefine(IteratorPrototype, ITERATOR, function () { 33 | return this; 34 | }); 35 | } 36 | 37 | var iteratorsCore = { 38 | IteratorPrototype: IteratorPrototype, 39 | BUGGY_SAFARI_ITERATORS: BUGGY_SAFARI_ITERATORS 40 | }; 41 | 42 | var iteratorClose = function (iterator, kind, value) { 43 | var innerResult, innerError; 44 | anObject(iterator); 45 | try { 46 | innerResult = getMethod(iterator, 'return'); 47 | if (!innerResult) { 48 | if (kind === 'throw') throw value; 49 | return value; 50 | } 51 | innerResult = functionCall(innerResult, iterator); 52 | } catch (error) { 53 | innerError = true; 54 | innerResult = error; 55 | } 56 | if (kind === 'throw') throw value; 57 | if (innerError) throw innerResult; 58 | anObject(innerResult); 59 | return value; 60 | }; 61 | 62 | var USE_FUNCTION_CONSTRUCTOR = 'USE_FUNCTION_CONSTRUCTOR'; 63 | var ASYNC_ITERATOR = wellKnownSymbol('asyncIterator'); 64 | var AsyncIterator = global_1.AsyncIterator; 65 | var PassedAsyncIteratorPrototype = sharedStore.AsyncIteratorPrototype; 66 | var AsyncIteratorPrototype, prototype; 67 | 68 | if (PassedAsyncIteratorPrototype) { 69 | AsyncIteratorPrototype = PassedAsyncIteratorPrototype; 70 | } else if (isCallable(AsyncIterator)) { 71 | AsyncIteratorPrototype = AsyncIterator.prototype; 72 | } else if (sharedStore[USE_FUNCTION_CONSTRUCTOR] || global_1[USE_FUNCTION_CONSTRUCTOR]) { 73 | try { 74 | // eslint-disable-next-line no-new-func -- we have no alternatives without usage of modern syntax 75 | prototype = objectGetPrototypeOf(objectGetPrototypeOf(objectGetPrototypeOf(Function('return async function*(){}()')()))); 76 | if (objectGetPrototypeOf(prototype) === Object.prototype) AsyncIteratorPrototype = prototype; 77 | } catch (error) { /* empty */ } 78 | } 79 | 80 | if (!AsyncIteratorPrototype) AsyncIteratorPrototype = {}; 81 | 82 | if (!isCallable(AsyncIteratorPrototype[ASYNC_ITERATOR])) { 83 | redefine(AsyncIteratorPrototype, ASYNC_ITERATOR, function () { 84 | return this; 85 | }); 86 | } 87 | 88 | var asyncIteratorPrototype = AsyncIteratorPrototype; 89 | 90 | // iterable DOM collections 91 | // flag - `iterable` interface - 'entries', 'keys', 'values', 'forEach' methods 92 | var domIterables = { 93 | CSSRuleList: 0, 94 | CSSStyleDeclaration: 0, 95 | CSSValueList: 0, 96 | ClientRectList: 0, 97 | DOMRectList: 0, 98 | DOMStringList: 0, 99 | DOMTokenList: 1, 100 | DataTransferItemList: 0, 101 | FileList: 0, 102 | HTMLAllCollection: 0, 103 | HTMLCollection: 0, 104 | HTMLFormElement: 0, 105 | HTMLSelectElement: 0, 106 | MediaList: 0, 107 | MimeTypeArray: 0, 108 | NamedNodeMap: 0, 109 | NodeList: 1, 110 | PaintRequestList: 0, 111 | Plugin: 0, 112 | PluginArray: 0, 113 | SVGLengthList: 0, 114 | SVGNumberList: 0, 115 | SVGPathSegList: 0, 116 | SVGPointList: 0, 117 | SVGStringList: 0, 118 | SVGTransformList: 0, 119 | SourceBufferList: 0, 120 | StyleSheetList: 0, 121 | TextTrackCueList: 0, 122 | TextTrackList: 0, 123 | TouchList: 0 124 | }; 125 | 126 | // in old WebKit versions, `element.classList` is not an instance of global `DOMTokenList` 127 | 128 | 129 | var classList = documentCreateElement('span').classList; 130 | var DOMTokenListPrototype = classList && classList.constructor && classList.constructor.prototype; 131 | 132 | var domTokenListPrototype = DOMTokenListPrototype === Object.prototype ? undefined : DOMTokenListPrototype; 133 | 134 | var UNSCOPABLES = wellKnownSymbol('unscopables'); 135 | var ArrayPrototype = Array.prototype; 136 | 137 | // Array.prototype[@@unscopables] 138 | // https://tc39.es/ecma262/#sec-array.prototype-@@unscopables 139 | if (ArrayPrototype[UNSCOPABLES] == undefined) { 140 | objectDefineProperty.f(ArrayPrototype, UNSCOPABLES, { 141 | configurable: true, 142 | value: objectCreate(null) 143 | }); 144 | } 145 | 146 | // add a key to Array.prototype[@@unscopables] 147 | var addToUnscopables = function (key) { 148 | ArrayPrototype[UNSCOPABLES][key] = true; 149 | }; 150 | 151 | var IteratorPrototype$1 = iteratorsCore.IteratorPrototype; 152 | 153 | 154 | 155 | 156 | 157 | var returnThis = function () { return this; }; 158 | 159 | var createIteratorConstructor = function (IteratorConstructor, NAME, next, ENUMERABLE_NEXT) { 160 | var TO_STRING_TAG = NAME + ' Iterator'; 161 | IteratorConstructor.prototype = objectCreate(IteratorPrototype$1, { next: createPropertyDescriptor(+!ENUMERABLE_NEXT, next) }); 162 | setToStringTag(IteratorConstructor, TO_STRING_TAG, false); 163 | iterators[TO_STRING_TAG] = returnThis; 164 | return IteratorConstructor; 165 | }; 166 | 167 | var PROPER_FUNCTION_NAME = functionName.PROPER; 168 | var CONFIGURABLE_FUNCTION_NAME = functionName.CONFIGURABLE; 169 | var IteratorPrototype$2 = iteratorsCore.IteratorPrototype; 170 | var BUGGY_SAFARI_ITERATORS$1 = iteratorsCore.BUGGY_SAFARI_ITERATORS; 171 | var ITERATOR$1 = wellKnownSymbol('iterator'); 172 | var KEYS = 'keys'; 173 | var VALUES = 'values'; 174 | var ENTRIES = 'entries'; 175 | 176 | var returnThis$1 = function () { return this; }; 177 | 178 | var defineIterator = function (Iterable, NAME, IteratorConstructor, next, DEFAULT, IS_SET, FORCED) { 179 | createIteratorConstructor(IteratorConstructor, NAME, next); 180 | 181 | var getIterationMethod = function (KIND) { 182 | if (KIND === DEFAULT && defaultIterator) return defaultIterator; 183 | if (!BUGGY_SAFARI_ITERATORS$1 && KIND in IterablePrototype) return IterablePrototype[KIND]; 184 | switch (KIND) { 185 | case KEYS: return function keys() { return new IteratorConstructor(this, KIND); }; 186 | case VALUES: return function values() { return new IteratorConstructor(this, KIND); }; 187 | case ENTRIES: return function entries() { return new IteratorConstructor(this, KIND); }; 188 | } return function () { return new IteratorConstructor(this); }; 189 | }; 190 | 191 | var TO_STRING_TAG = NAME + ' Iterator'; 192 | var INCORRECT_VALUES_NAME = false; 193 | var IterablePrototype = Iterable.prototype; 194 | var nativeIterator = IterablePrototype[ITERATOR$1] 195 | || IterablePrototype['@@iterator'] 196 | || DEFAULT && IterablePrototype[DEFAULT]; 197 | var defaultIterator = !BUGGY_SAFARI_ITERATORS$1 && nativeIterator || getIterationMethod(DEFAULT); 198 | var anyNativeIterator = NAME == 'Array' ? IterablePrototype.entries || nativeIterator : nativeIterator; 199 | var CurrentIteratorPrototype, methods, KEY; 200 | 201 | // fix native 202 | if (anyNativeIterator) { 203 | CurrentIteratorPrototype = objectGetPrototypeOf(anyNativeIterator.call(new Iterable())); 204 | if (CurrentIteratorPrototype !== Object.prototype && CurrentIteratorPrototype.next) { 205 | if ( objectGetPrototypeOf(CurrentIteratorPrototype) !== IteratorPrototype$2) { 206 | if (objectSetPrototypeOf) { 207 | objectSetPrototypeOf(CurrentIteratorPrototype, IteratorPrototype$2); 208 | } else if (!isCallable(CurrentIteratorPrototype[ITERATOR$1])) { 209 | redefine(CurrentIteratorPrototype, ITERATOR$1, returnThis$1); 210 | } 211 | } 212 | // Set @@toStringTag to native iterators 213 | setToStringTag(CurrentIteratorPrototype, TO_STRING_TAG, true); 214 | } 215 | } 216 | 217 | // fix Array.prototype.{ values, @@iterator }.name in V8 / FF 218 | if (PROPER_FUNCTION_NAME && DEFAULT == VALUES && nativeIterator && nativeIterator.name !== VALUES) { 219 | if ( CONFIGURABLE_FUNCTION_NAME) { 220 | createNonEnumerableProperty(IterablePrototype, 'name', VALUES); 221 | } else { 222 | INCORRECT_VALUES_NAME = true; 223 | defaultIterator = function values() { return functionCall(nativeIterator, this); }; 224 | } 225 | } 226 | 227 | // export additional methods 228 | if (DEFAULT) { 229 | methods = { 230 | values: getIterationMethod(VALUES), 231 | keys: IS_SET ? defaultIterator : getIterationMethod(KEYS), 232 | entries: getIterationMethod(ENTRIES) 233 | }; 234 | if (FORCED) for (KEY in methods) { 235 | if (BUGGY_SAFARI_ITERATORS$1 || INCORRECT_VALUES_NAME || !(KEY in IterablePrototype)) { 236 | redefine(IterablePrototype, KEY, methods[KEY]); 237 | } 238 | } else _export({ target: NAME, proto: true, forced: BUGGY_SAFARI_ITERATORS$1 || INCORRECT_VALUES_NAME }, methods); 239 | } 240 | 241 | // define iterator 242 | if ( IterablePrototype[ITERATOR$1] !== defaultIterator) { 243 | redefine(IterablePrototype, ITERATOR$1, defaultIterator, { name: DEFAULT }); 244 | } 245 | iterators[NAME] = defaultIterator; 246 | 247 | return methods; 248 | }; 249 | 250 | var defineProperty = objectDefineProperty.f; 251 | 252 | 253 | 254 | 255 | var ARRAY_ITERATOR = 'Array Iterator'; 256 | var setInternalState = internalState.set; 257 | var getInternalState = internalState.getterFor(ARRAY_ITERATOR); 258 | 259 | // `Array.prototype.entries` method 260 | // https://tc39.es/ecma262/#sec-array.prototype.entries 261 | // `Array.prototype.keys` method 262 | // https://tc39.es/ecma262/#sec-array.prototype.keys 263 | // `Array.prototype.values` method 264 | // https://tc39.es/ecma262/#sec-array.prototype.values 265 | // `Array.prototype[@@iterator]` method 266 | // https://tc39.es/ecma262/#sec-array.prototype-@@iterator 267 | // `CreateArrayIterator` internal method 268 | // https://tc39.es/ecma262/#sec-createarrayiterator 269 | var es_array_iterator = defineIterator(Array, 'Array', function (iterated, kind) { 270 | setInternalState(this, { 271 | type: ARRAY_ITERATOR, 272 | target: toIndexedObject(iterated), // target 273 | index: 0, // next index 274 | kind: kind // kind 275 | }); 276 | // `%ArrayIteratorPrototype%.next` method 277 | // https://tc39.es/ecma262/#sec-%arrayiteratorprototype%.next 278 | }, function () { 279 | var state = getInternalState(this); 280 | var target = state.target; 281 | var kind = state.kind; 282 | var index = state.index++; 283 | if (!target || index >= target.length) { 284 | state.target = undefined; 285 | return { value: undefined, done: true }; 286 | } 287 | if (kind == 'keys') return { value: index, done: false }; 288 | if (kind == 'values') return { value: target[index], done: false }; 289 | return { value: [index, target[index]], done: false }; 290 | }, 'values'); 291 | 292 | // argumentsList[@@iterator] is %ArrayProto_values% 293 | // https://tc39.es/ecma262/#sec-createunmappedargumentsobject 294 | // https://tc39.es/ecma262/#sec-createmappedargumentsobject 295 | var values = iterators.Arguments = iterators.Array; 296 | 297 | // https://tc39.es/ecma262/#sec-array.prototype-@@unscopables 298 | addToUnscopables('keys'); 299 | addToUnscopables('values'); 300 | addToUnscopables('entries'); 301 | 302 | // V8 ~ Chrome 45- bug 303 | if ( descriptors && values.name !== 'values') try { 304 | defineProperty(values, 'name', { value: 'values' }); 305 | } catch (error) { /* empty */ } 306 | 307 | var ITERATOR$2 = wellKnownSymbol('iterator'); 308 | var TO_STRING_TAG = wellKnownSymbol('toStringTag'); 309 | var ArrayValues = es_array_iterator.values; 310 | 311 | var handlePrototype = function (CollectionPrototype, COLLECTION_NAME) { 312 | if (CollectionPrototype) { 313 | // some Chrome versions have non-configurable methods on DOMTokenList 314 | if (CollectionPrototype[ITERATOR$2] !== ArrayValues) try { 315 | createNonEnumerableProperty(CollectionPrototype, ITERATOR$2, ArrayValues); 316 | } catch (error) { 317 | CollectionPrototype[ITERATOR$2] = ArrayValues; 318 | } 319 | if (!CollectionPrototype[TO_STRING_TAG]) { 320 | createNonEnumerableProperty(CollectionPrototype, TO_STRING_TAG, COLLECTION_NAME); 321 | } 322 | if (domIterables[COLLECTION_NAME]) for (var METHOD_NAME in es_array_iterator) { 323 | // some Chrome versions have non-configurable methods on DOMTokenList 324 | if (CollectionPrototype[METHOD_NAME] !== es_array_iterator[METHOD_NAME]) try { 325 | createNonEnumerableProperty(CollectionPrototype, METHOD_NAME, es_array_iterator[METHOD_NAME]); 326 | } catch (error) { 327 | CollectionPrototype[METHOD_NAME] = es_array_iterator[METHOD_NAME]; 328 | } 329 | } 330 | } 331 | }; 332 | 333 | for (var COLLECTION_NAME in domIterables) { 334 | handlePrototype(global_1[COLLECTION_NAME] && global_1[COLLECTION_NAME].prototype, COLLECTION_NAME); 335 | } 336 | 337 | handlePrototype(domTokenListPrototype, 'DOMTokenList'); 338 | 339 | var FunctionPrototype = Function.prototype; 340 | var apply = FunctionPrototype.apply; 341 | var call = FunctionPrototype.call; 342 | 343 | // eslint-disable-next-line es/no-reflect -- safe 344 | var functionApply = typeof Reflect == 'object' && Reflect.apply || (functionBindNative ? call.bind(apply) : function () { 345 | return call.apply(apply, arguments); 346 | }); 347 | 348 | export { asyncIteratorPrototype as a, iteratorClose as b, createIteratorConstructor as c, defineIterator as d, addToUnscopables as e, functionApply as f, iteratorsCore as i }; 349 | -------------------------------------------------------------------------------- /web_modules/common/inherit-if-required-1c9a60b3.js: -------------------------------------------------------------------------------- 1 | import { g as global_1, o as objectIsPrototypeOf, m as functionUncurryThis, L as functionBindNative, d as aCallable, w as wellKnownSymbol, H as iterators, A as classofRaw, i as isCallable, e as getMethod, a as anObject, f as functionCall, t as tryToString, p as objectSetPrototypeOf, k as isObject } from './object-set-prototype-of-65a42c5e.js'; 2 | 3 | var TypeError = global_1.TypeError; 4 | 5 | var anInstance = function (it, Prototype) { 6 | if (objectIsPrototypeOf(Prototype, it)) return it; 7 | throw TypeError('Incorrect invocation'); 8 | }; 9 | 10 | var bind = functionUncurryThis(functionUncurryThis.bind); 11 | 12 | // optional / simple context binding 13 | var functionBindContext = function (fn, that) { 14 | aCallable(fn); 15 | return that === undefined ? fn : functionBindNative ? bind(fn, that) : function (/* ...args */) { 16 | return fn.apply(that, arguments); 17 | }; 18 | }; 19 | 20 | var ITERATOR = wellKnownSymbol('iterator'); 21 | var ArrayPrototype = Array.prototype; 22 | 23 | // check on default Array iterator 24 | var isArrayIteratorMethod = function (it) { 25 | return it !== undefined && (iterators.Array === it || ArrayPrototype[ITERATOR] === it); 26 | }; 27 | 28 | var TO_STRING_TAG = wellKnownSymbol('toStringTag'); 29 | var test = {}; 30 | 31 | test[TO_STRING_TAG] = 'z'; 32 | 33 | var toStringTagSupport = String(test) === '[object z]'; 34 | 35 | var TO_STRING_TAG$1 = wellKnownSymbol('toStringTag'); 36 | var Object = global_1.Object; 37 | 38 | // ES3 wrong here 39 | var CORRECT_ARGUMENTS = classofRaw(function () { return arguments; }()) == 'Arguments'; 40 | 41 | // fallback for IE11 Script Access Denied error 42 | var tryGet = function (it, key) { 43 | try { 44 | return it[key]; 45 | } catch (error) { /* empty */ } 46 | }; 47 | 48 | // getting tag from ES6+ `Object.prototype.toString` 49 | var classof = toStringTagSupport ? classofRaw : function (it) { 50 | var O, tag, result; 51 | return it === undefined ? 'Undefined' : it === null ? 'Null' 52 | // @@toStringTag case 53 | : typeof (tag = tryGet(O = Object(it), TO_STRING_TAG$1)) == 'string' ? tag 54 | // builtinTag case 55 | : CORRECT_ARGUMENTS ? classofRaw(O) 56 | // ES3 arguments fallback 57 | : (result = classofRaw(O)) == 'Object' && isCallable(O.callee) ? 'Arguments' : result; 58 | }; 59 | 60 | var ITERATOR$1 = wellKnownSymbol('iterator'); 61 | 62 | var getIteratorMethod = function (it) { 63 | if (it != undefined) return getMethod(it, ITERATOR$1) 64 | || getMethod(it, '@@iterator') 65 | || iterators[classof(it)]; 66 | }; 67 | 68 | var TypeError$1 = global_1.TypeError; 69 | 70 | var getIterator = function (argument, usingIterator) { 71 | var iteratorMethod = arguments.length < 2 ? getIteratorMethod(argument) : usingIterator; 72 | if (aCallable(iteratorMethod)) return anObject(functionCall(iteratorMethod, argument)); 73 | throw TypeError$1(tryToString(argument) + ' is not iterable'); 74 | }; 75 | 76 | // makes subclassing work correct for wrapped built-ins 77 | var inheritIfRequired = function ($this, dummy, Wrapper) { 78 | var NewTarget, NewTargetPrototype; 79 | if ( 80 | // it can work only with native `setPrototypeOf` 81 | objectSetPrototypeOf && 82 | // we haven't completely correct pre-ES6 way for getting `new.target`, so use this 83 | isCallable(NewTarget = dummy.constructor) && 84 | NewTarget !== Wrapper && 85 | isObject(NewTargetPrototype = NewTarget.prototype) && 86 | NewTargetPrototype !== Wrapper.prototype 87 | ) objectSetPrototypeOf($this, NewTargetPrototype); 88 | return $this; 89 | }; 90 | 91 | export { anInstance as a, getIterator as b, classof as c, inheritIfRequired as d, functionBindContext as f, getIteratorMethod as g, isArrayIteratorMethod as i }; 92 | -------------------------------------------------------------------------------- /web_modules/common/object-set-prototype-of-65a42c5e.js: -------------------------------------------------------------------------------- 1 | var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; 2 | 3 | function createCommonjsModule(fn, basedir, module) { 4 | return module = { 5 | path: basedir, 6 | exports: {}, 7 | require: function (path, base) { 8 | return commonjsRequire(path, (base === undefined || base === null) ? module.path : base); 9 | } 10 | }, fn(module, module.exports), module.exports; 11 | } 12 | 13 | function commonjsRequire () { 14 | throw new Error('Dynamic requires are not currently supported by @rollup/plugin-commonjs'); 15 | } 16 | 17 | var check = function (it) { 18 | return it && it.Math == Math && it; 19 | }; 20 | 21 | // https://github.com/zloirock/core-js/issues/86#issuecomment-115759028 22 | var global_1 = 23 | // eslint-disable-next-line es/no-global-this -- safe 24 | check(typeof globalThis == 'object' && globalThis) || 25 | check(typeof window == 'object' && window) || 26 | // eslint-disable-next-line no-restricted-globals -- safe 27 | check(typeof self == 'object' && self) || 28 | check(typeof commonjsGlobal == 'object' && commonjsGlobal) || 29 | // eslint-disable-next-line no-new-func -- fallback 30 | (function () { return this; })() || Function('return this')(); 31 | 32 | var fails = function (exec) { 33 | try { 34 | return !!exec(); 35 | } catch (error) { 36 | return true; 37 | } 38 | }; 39 | 40 | // Detect IE8's incomplete defineProperty implementation 41 | var descriptors = !fails(function () { 42 | // eslint-disable-next-line es/no-object-defineproperty -- required for testing 43 | return Object.defineProperty({}, 1, { get: function () { return 7; } })[1] != 7; 44 | }); 45 | 46 | var functionBindNative = !fails(function () { 47 | var test = (function () { /* empty */ }).bind(); 48 | // eslint-disable-next-line no-prototype-builtins -- safe 49 | return typeof test != 'function' || test.hasOwnProperty('prototype'); 50 | }); 51 | 52 | var call = Function.prototype.call; 53 | 54 | var functionCall = functionBindNative ? call.bind(call) : function () { 55 | return call.apply(call, arguments); 56 | }; 57 | 58 | var $propertyIsEnumerable = {}.propertyIsEnumerable; 59 | // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe 60 | var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; 61 | 62 | // Nashorn ~ JDK8 bug 63 | var NASHORN_BUG = getOwnPropertyDescriptor && !$propertyIsEnumerable.call({ 1: 2 }, 1); 64 | 65 | // `Object.prototype.propertyIsEnumerable` method implementation 66 | // https://tc39.es/ecma262/#sec-object.prototype.propertyisenumerable 67 | var f = NASHORN_BUG ? function propertyIsEnumerable(V) { 68 | var descriptor = getOwnPropertyDescriptor(this, V); 69 | return !!descriptor && descriptor.enumerable; 70 | } : $propertyIsEnumerable; 71 | 72 | var objectPropertyIsEnumerable = { 73 | f: f 74 | }; 75 | 76 | var createPropertyDescriptor = function (bitmap, value) { 77 | return { 78 | enumerable: !(bitmap & 1), 79 | configurable: !(bitmap & 2), 80 | writable: !(bitmap & 4), 81 | value: value 82 | }; 83 | }; 84 | 85 | var FunctionPrototype = Function.prototype; 86 | var bind = FunctionPrototype.bind; 87 | var call$1 = FunctionPrototype.call; 88 | var uncurryThis = functionBindNative && bind.bind(call$1, call$1); 89 | 90 | var functionUncurryThis = functionBindNative ? function (fn) { 91 | return fn && uncurryThis(fn); 92 | } : function (fn) { 93 | return fn && function () { 94 | return call$1.apply(fn, arguments); 95 | }; 96 | }; 97 | 98 | var toString = functionUncurryThis({}.toString); 99 | var stringSlice = functionUncurryThis(''.slice); 100 | 101 | var classofRaw = function (it) { 102 | return stringSlice(toString(it), 8, -1); 103 | }; 104 | 105 | var Object$1 = global_1.Object; 106 | var split = functionUncurryThis(''.split); 107 | 108 | // fallback for non-array-like ES3 and non-enumerable old V8 strings 109 | var indexedObject = fails(function () { 110 | // throws an error in rhino, see https://github.com/mozilla/rhino/issues/346 111 | // eslint-disable-next-line no-prototype-builtins -- safe 112 | return !Object$1('z').propertyIsEnumerable(0); 113 | }) ? function (it) { 114 | return classofRaw(it) == 'String' ? split(it, '') : Object$1(it); 115 | } : Object$1; 116 | 117 | var TypeError = global_1.TypeError; 118 | 119 | // `RequireObjectCoercible` abstract operation 120 | // https://tc39.es/ecma262/#sec-requireobjectcoercible 121 | var requireObjectCoercible = function (it) { 122 | if (it == undefined) throw TypeError("Can't call method on " + it); 123 | return it; 124 | }; 125 | 126 | // toObject with fallback for non-array-like ES3 strings 127 | 128 | 129 | 130 | var toIndexedObject = function (it) { 131 | return indexedObject(requireObjectCoercible(it)); 132 | }; 133 | 134 | // `IsCallable` abstract operation 135 | // https://tc39.es/ecma262/#sec-iscallable 136 | var isCallable = function (argument) { 137 | return typeof argument == 'function'; 138 | }; 139 | 140 | var isObject = function (it) { 141 | return typeof it == 'object' ? it !== null : isCallable(it); 142 | }; 143 | 144 | var aFunction = function (argument) { 145 | return isCallable(argument) ? argument : undefined; 146 | }; 147 | 148 | var getBuiltIn = function (namespace, method) { 149 | return arguments.length < 2 ? aFunction(global_1[namespace]) : global_1[namespace] && global_1[namespace][method]; 150 | }; 151 | 152 | var objectIsPrototypeOf = functionUncurryThis({}.isPrototypeOf); 153 | 154 | var engineUserAgent = getBuiltIn('navigator', 'userAgent') || ''; 155 | 156 | var process = global_1.process; 157 | var Deno = global_1.Deno; 158 | var versions = process && process.versions || Deno && Deno.version; 159 | var v8 = versions && versions.v8; 160 | var match, version; 161 | 162 | if (v8) { 163 | match = v8.split('.'); 164 | // in old Chrome, versions of V8 isn't V8 = Chrome / 10 165 | // but their correct versions are not interesting for us 166 | version = match[0] > 0 && match[0] < 4 ? 1 : +(match[0] + match[1]); 167 | } 168 | 169 | // BrowserFS NodeJS `process` polyfill incorrectly set `.v8` to `0.0` 170 | // so check `userAgent` even if `.v8` exists, but 0 171 | if (!version && engineUserAgent) { 172 | match = engineUserAgent.match(/Edge\/(\d+)/); 173 | if (!match || match[1] >= 74) { 174 | match = engineUserAgent.match(/Chrome\/(\d+)/); 175 | if (match) version = +match[1]; 176 | } 177 | } 178 | 179 | var engineV8Version = version; 180 | 181 | /* eslint-disable es/no-symbol -- required for testing */ 182 | 183 | 184 | 185 | // eslint-disable-next-line es/no-object-getownpropertysymbols -- required for testing 186 | var nativeSymbol = !!Object.getOwnPropertySymbols && !fails(function () { 187 | var symbol = Symbol(); 188 | // Chrome 38 Symbol has incorrect toString conversion 189 | // `get-own-property-symbols` polyfill symbols converted to object are not Symbol instances 190 | return !String(symbol) || !(Object(symbol) instanceof Symbol) || 191 | // Chrome 38-40 symbols are not inherited from DOM collections prototypes to instances 192 | !Symbol.sham && engineV8Version && engineV8Version < 41; 193 | }); 194 | 195 | /* eslint-disable es/no-symbol -- required for testing */ 196 | 197 | 198 | var useSymbolAsUid = nativeSymbol 199 | && !Symbol.sham 200 | && typeof Symbol.iterator == 'symbol'; 201 | 202 | var Object$2 = global_1.Object; 203 | 204 | var isSymbol = useSymbolAsUid ? function (it) { 205 | return typeof it == 'symbol'; 206 | } : function (it) { 207 | var $Symbol = getBuiltIn('Symbol'); 208 | return isCallable($Symbol) && objectIsPrototypeOf($Symbol.prototype, Object$2(it)); 209 | }; 210 | 211 | var String$1 = global_1.String; 212 | 213 | var tryToString = function (argument) { 214 | try { 215 | return String$1(argument); 216 | } catch (error) { 217 | return 'Object'; 218 | } 219 | }; 220 | 221 | var TypeError$1 = global_1.TypeError; 222 | 223 | // `Assert: IsCallable(argument) is true` 224 | var aCallable = function (argument) { 225 | if (isCallable(argument)) return argument; 226 | throw TypeError$1(tryToString(argument) + ' is not a function'); 227 | }; 228 | 229 | // `GetMethod` abstract operation 230 | // https://tc39.es/ecma262/#sec-getmethod 231 | var getMethod = function (V, P) { 232 | var func = V[P]; 233 | return func == null ? undefined : aCallable(func); 234 | }; 235 | 236 | var TypeError$2 = global_1.TypeError; 237 | 238 | // `OrdinaryToPrimitive` abstract operation 239 | // https://tc39.es/ecma262/#sec-ordinarytoprimitive 240 | var ordinaryToPrimitive = function (input, pref) { 241 | var fn, val; 242 | if (pref === 'string' && isCallable(fn = input.toString) && !isObject(val = functionCall(fn, input))) return val; 243 | if (isCallable(fn = input.valueOf) && !isObject(val = functionCall(fn, input))) return val; 244 | if (pref !== 'string' && isCallable(fn = input.toString) && !isObject(val = functionCall(fn, input))) return val; 245 | throw TypeError$2("Can't convert object to primitive value"); 246 | }; 247 | 248 | // eslint-disable-next-line es/no-object-defineproperty -- safe 249 | var defineProperty = Object.defineProperty; 250 | 251 | var setGlobal = function (key, value) { 252 | try { 253 | defineProperty(global_1, key, { value: value, configurable: true, writable: true }); 254 | } catch (error) { 255 | global_1[key] = value; 256 | } return value; 257 | }; 258 | 259 | var SHARED = '__core-js_shared__'; 260 | var store = global_1[SHARED] || setGlobal(SHARED, {}); 261 | 262 | var sharedStore = store; 263 | 264 | var shared = createCommonjsModule(function (module) { 265 | (module.exports = function (key, value) { 266 | return sharedStore[key] || (sharedStore[key] = value !== undefined ? value : {}); 267 | })('versions', []).push({ 268 | version: '3.21.1', 269 | mode: 'global', 270 | copyright: '© 2014-2022 Denis Pushkarev (zloirock.ru)', 271 | license: 'https://github.com/zloirock/core-js/blob/v3.21.1/LICENSE', 272 | source: 'https://github.com/zloirock/core-js' 273 | }); 274 | }); 275 | 276 | var Object$3 = global_1.Object; 277 | 278 | // `ToObject` abstract operation 279 | // https://tc39.es/ecma262/#sec-toobject 280 | var toObject = function (argument) { 281 | return Object$3(requireObjectCoercible(argument)); 282 | }; 283 | 284 | var hasOwnProperty = functionUncurryThis({}.hasOwnProperty); 285 | 286 | // `HasOwnProperty` abstract operation 287 | // https://tc39.es/ecma262/#sec-hasownproperty 288 | var hasOwnProperty_1 = Object.hasOwn || function hasOwn(it, key) { 289 | return hasOwnProperty(toObject(it), key); 290 | }; 291 | 292 | var id = 0; 293 | var postfix = Math.random(); 294 | var toString$1 = functionUncurryThis(1.0.toString); 295 | 296 | var uid = function (key) { 297 | return 'Symbol(' + (key === undefined ? '' : key) + ')_' + toString$1(++id + postfix, 36); 298 | }; 299 | 300 | var WellKnownSymbolsStore = shared('wks'); 301 | var Symbol$1 = global_1.Symbol; 302 | var symbolFor = Symbol$1 && Symbol$1['for']; 303 | var createWellKnownSymbol = useSymbolAsUid ? Symbol$1 : Symbol$1 && Symbol$1.withoutSetter || uid; 304 | 305 | var wellKnownSymbol = function (name) { 306 | if (!hasOwnProperty_1(WellKnownSymbolsStore, name) || !(nativeSymbol || typeof WellKnownSymbolsStore[name] == 'string')) { 307 | var description = 'Symbol.' + name; 308 | if (nativeSymbol && hasOwnProperty_1(Symbol$1, name)) { 309 | WellKnownSymbolsStore[name] = Symbol$1[name]; 310 | } else if (useSymbolAsUid && symbolFor) { 311 | WellKnownSymbolsStore[name] = symbolFor(description); 312 | } else { 313 | WellKnownSymbolsStore[name] = createWellKnownSymbol(description); 314 | } 315 | } return WellKnownSymbolsStore[name]; 316 | }; 317 | 318 | var TypeError$3 = global_1.TypeError; 319 | var TO_PRIMITIVE = wellKnownSymbol('toPrimitive'); 320 | 321 | // `ToPrimitive` abstract operation 322 | // https://tc39.es/ecma262/#sec-toprimitive 323 | var toPrimitive = function (input, pref) { 324 | if (!isObject(input) || isSymbol(input)) return input; 325 | var exoticToPrim = getMethod(input, TO_PRIMITIVE); 326 | var result; 327 | if (exoticToPrim) { 328 | if (pref === undefined) pref = 'default'; 329 | result = functionCall(exoticToPrim, input, pref); 330 | if (!isObject(result) || isSymbol(result)) return result; 331 | throw TypeError$3("Can't convert object to primitive value"); 332 | } 333 | if (pref === undefined) pref = 'number'; 334 | return ordinaryToPrimitive(input, pref); 335 | }; 336 | 337 | // `ToPropertyKey` abstract operation 338 | // https://tc39.es/ecma262/#sec-topropertykey 339 | var toPropertyKey = function (argument) { 340 | var key = toPrimitive(argument, 'string'); 341 | return isSymbol(key) ? key : key + ''; 342 | }; 343 | 344 | var document$1 = global_1.document; 345 | // typeof document.createElement is 'object' in old IE 346 | var EXISTS = isObject(document$1) && isObject(document$1.createElement); 347 | 348 | var documentCreateElement = function (it) { 349 | return EXISTS ? document$1.createElement(it) : {}; 350 | }; 351 | 352 | // Thanks to IE8 for its funny defineProperty 353 | var ie8DomDefine = !descriptors && !fails(function () { 354 | // eslint-disable-next-line es/no-object-defineproperty -- required for testing 355 | return Object.defineProperty(documentCreateElement('div'), 'a', { 356 | get: function () { return 7; } 357 | }).a != 7; 358 | }); 359 | 360 | // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe 361 | var $getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; 362 | 363 | // `Object.getOwnPropertyDescriptor` method 364 | // https://tc39.es/ecma262/#sec-object.getownpropertydescriptor 365 | var f$1 = descriptors ? $getOwnPropertyDescriptor : function getOwnPropertyDescriptor(O, P) { 366 | O = toIndexedObject(O); 367 | P = toPropertyKey(P); 368 | if (ie8DomDefine) try { 369 | return $getOwnPropertyDescriptor(O, P); 370 | } catch (error) { /* empty */ } 371 | if (hasOwnProperty_1(O, P)) return createPropertyDescriptor(!functionCall(objectPropertyIsEnumerable.f, O, P), O[P]); 372 | }; 373 | 374 | var objectGetOwnPropertyDescriptor = { 375 | f: f$1 376 | }; 377 | 378 | // V8 ~ Chrome 36- 379 | // https://bugs.chromium.org/p/v8/issues/detail?id=3334 380 | var v8PrototypeDefineBug = descriptors && fails(function () { 381 | // eslint-disable-next-line es/no-object-defineproperty -- required for testing 382 | return Object.defineProperty(function () { /* empty */ }, 'prototype', { 383 | value: 42, 384 | writable: false 385 | }).prototype != 42; 386 | }); 387 | 388 | var String$2 = global_1.String; 389 | var TypeError$4 = global_1.TypeError; 390 | 391 | // `Assert: Type(argument) is Object` 392 | var anObject = function (argument) { 393 | if (isObject(argument)) return argument; 394 | throw TypeError$4(String$2(argument) + ' is not an object'); 395 | }; 396 | 397 | var TypeError$5 = global_1.TypeError; 398 | // eslint-disable-next-line es/no-object-defineproperty -- safe 399 | var $defineProperty = Object.defineProperty; 400 | // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe 401 | var $getOwnPropertyDescriptor$1 = Object.getOwnPropertyDescriptor; 402 | var ENUMERABLE = 'enumerable'; 403 | var CONFIGURABLE = 'configurable'; 404 | var WRITABLE = 'writable'; 405 | 406 | // `Object.defineProperty` method 407 | // https://tc39.es/ecma262/#sec-object.defineproperty 408 | var f$2 = descriptors ? v8PrototypeDefineBug ? function defineProperty(O, P, Attributes) { 409 | anObject(O); 410 | P = toPropertyKey(P); 411 | anObject(Attributes); 412 | if (typeof O === 'function' && P === 'prototype' && 'value' in Attributes && WRITABLE in Attributes && !Attributes[WRITABLE]) { 413 | var current = $getOwnPropertyDescriptor$1(O, P); 414 | if (current && current[WRITABLE]) { 415 | O[P] = Attributes.value; 416 | Attributes = { 417 | configurable: CONFIGURABLE in Attributes ? Attributes[CONFIGURABLE] : current[CONFIGURABLE], 418 | enumerable: ENUMERABLE in Attributes ? Attributes[ENUMERABLE] : current[ENUMERABLE], 419 | writable: false 420 | }; 421 | } 422 | } return $defineProperty(O, P, Attributes); 423 | } : $defineProperty : function defineProperty(O, P, Attributes) { 424 | anObject(O); 425 | P = toPropertyKey(P); 426 | anObject(Attributes); 427 | if (ie8DomDefine) try { 428 | return $defineProperty(O, P, Attributes); 429 | } catch (error) { /* empty */ } 430 | if ('get' in Attributes || 'set' in Attributes) throw TypeError$5('Accessors not supported'); 431 | if ('value' in Attributes) O[P] = Attributes.value; 432 | return O; 433 | }; 434 | 435 | var objectDefineProperty = { 436 | f: f$2 437 | }; 438 | 439 | var createNonEnumerableProperty = descriptors ? function (object, key, value) { 440 | return objectDefineProperty.f(object, key, createPropertyDescriptor(1, value)); 441 | } : function (object, key, value) { 442 | object[key] = value; 443 | return object; 444 | }; 445 | 446 | var functionToString = functionUncurryThis(Function.toString); 447 | 448 | // this helper broken in `core-js@3.4.1-3.4.4`, so we can't use `shared` helper 449 | if (!isCallable(sharedStore.inspectSource)) { 450 | sharedStore.inspectSource = function (it) { 451 | return functionToString(it); 452 | }; 453 | } 454 | 455 | var inspectSource = sharedStore.inspectSource; 456 | 457 | var WeakMap = global_1.WeakMap; 458 | 459 | var nativeWeakMap = isCallable(WeakMap) && /native code/.test(inspectSource(WeakMap)); 460 | 461 | var keys = shared('keys'); 462 | 463 | var sharedKey = function (key) { 464 | return keys[key] || (keys[key] = uid(key)); 465 | }; 466 | 467 | var hiddenKeys = {}; 468 | 469 | var OBJECT_ALREADY_INITIALIZED = 'Object already initialized'; 470 | var TypeError$6 = global_1.TypeError; 471 | var WeakMap$1 = global_1.WeakMap; 472 | var set, get, has; 473 | 474 | var enforce = function (it) { 475 | return has(it) ? get(it) : set(it, {}); 476 | }; 477 | 478 | var getterFor = function (TYPE) { 479 | return function (it) { 480 | var state; 481 | if (!isObject(it) || (state = get(it)).type !== TYPE) { 482 | throw TypeError$6('Incompatible receiver, ' + TYPE + ' required'); 483 | } return state; 484 | }; 485 | }; 486 | 487 | if (nativeWeakMap || sharedStore.state) { 488 | var store$1 = sharedStore.state || (sharedStore.state = new WeakMap$1()); 489 | var wmget = functionUncurryThis(store$1.get); 490 | var wmhas = functionUncurryThis(store$1.has); 491 | var wmset = functionUncurryThis(store$1.set); 492 | set = function (it, metadata) { 493 | if (wmhas(store$1, it)) throw new TypeError$6(OBJECT_ALREADY_INITIALIZED); 494 | metadata.facade = it; 495 | wmset(store$1, it, metadata); 496 | return metadata; 497 | }; 498 | get = function (it) { 499 | return wmget(store$1, it) || {}; 500 | }; 501 | has = function (it) { 502 | return wmhas(store$1, it); 503 | }; 504 | } else { 505 | var STATE = sharedKey('state'); 506 | hiddenKeys[STATE] = true; 507 | set = function (it, metadata) { 508 | if (hasOwnProperty_1(it, STATE)) throw new TypeError$6(OBJECT_ALREADY_INITIALIZED); 509 | metadata.facade = it; 510 | createNonEnumerableProperty(it, STATE, metadata); 511 | return metadata; 512 | }; 513 | get = function (it) { 514 | return hasOwnProperty_1(it, STATE) ? it[STATE] : {}; 515 | }; 516 | has = function (it) { 517 | return hasOwnProperty_1(it, STATE); 518 | }; 519 | } 520 | 521 | var internalState = { 522 | set: set, 523 | get: get, 524 | has: has, 525 | enforce: enforce, 526 | getterFor: getterFor 527 | }; 528 | 529 | var FunctionPrototype$1 = Function.prototype; 530 | // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe 531 | var getDescriptor = descriptors && Object.getOwnPropertyDescriptor; 532 | 533 | var EXISTS$1 = hasOwnProperty_1(FunctionPrototype$1, 'name'); 534 | // additional protection from minified / mangled / dropped function names 535 | var PROPER = EXISTS$1 && (function something() { /* empty */ }).name === 'something'; 536 | var CONFIGURABLE$1 = EXISTS$1 && (!descriptors || (descriptors && getDescriptor(FunctionPrototype$1, 'name').configurable)); 537 | 538 | var functionName = { 539 | EXISTS: EXISTS$1, 540 | PROPER: PROPER, 541 | CONFIGURABLE: CONFIGURABLE$1 542 | }; 543 | 544 | var redefine = createCommonjsModule(function (module) { 545 | var CONFIGURABLE_FUNCTION_NAME = functionName.CONFIGURABLE; 546 | 547 | var getInternalState = internalState.get; 548 | var enforceInternalState = internalState.enforce; 549 | var TEMPLATE = String(String).split('String'); 550 | 551 | (module.exports = function (O, key, value, options) { 552 | var unsafe = options ? !!options.unsafe : false; 553 | var simple = options ? !!options.enumerable : false; 554 | var noTargetGet = options ? !!options.noTargetGet : false; 555 | var name = options && options.name !== undefined ? options.name : key; 556 | var state; 557 | if (isCallable(value)) { 558 | if (String(name).slice(0, 7) === 'Symbol(') { 559 | name = '[' + String(name).replace(/^Symbol\(([^)]*)\)/, '$1') + ']'; 560 | } 561 | if (!hasOwnProperty_1(value, 'name') || (CONFIGURABLE_FUNCTION_NAME && value.name !== name)) { 562 | createNonEnumerableProperty(value, 'name', name); 563 | } 564 | state = enforceInternalState(value); 565 | if (!state.source) { 566 | state.source = TEMPLATE.join(typeof name == 'string' ? name : ''); 567 | } 568 | } 569 | if (O === global_1) { 570 | if (simple) O[key] = value; 571 | else setGlobal(key, value); 572 | return; 573 | } else if (!unsafe) { 574 | delete O[key]; 575 | } else if (!noTargetGet && O[key]) { 576 | simple = true; 577 | } 578 | if (simple) O[key] = value; 579 | else createNonEnumerableProperty(O, key, value); 580 | // add fake Function#toString for correct work wrapped methods / constructors with methods like LoDash isNative 581 | })(Function.prototype, 'toString', function toString() { 582 | return isCallable(this) && getInternalState(this).source || inspectSource(this); 583 | }); 584 | }); 585 | 586 | var ceil = Math.ceil; 587 | var floor = Math.floor; 588 | 589 | // `ToIntegerOrInfinity` abstract operation 590 | // https://tc39.es/ecma262/#sec-tointegerorinfinity 591 | var toIntegerOrInfinity = function (argument) { 592 | var number = +argument; 593 | // eslint-disable-next-line no-self-compare -- safe 594 | return number !== number || number === 0 ? 0 : (number > 0 ? floor : ceil)(number); 595 | }; 596 | 597 | var max = Math.max; 598 | var min = Math.min; 599 | 600 | // Helper for a popular repeating case of the spec: 601 | // Let integer be ? ToInteger(index). 602 | // If integer < 0, let result be max((length + integer), 0); else let result be min(integer, length). 603 | var toAbsoluteIndex = function (index, length) { 604 | var integer = toIntegerOrInfinity(index); 605 | return integer < 0 ? max(integer + length, 0) : min(integer, length); 606 | }; 607 | 608 | var min$1 = Math.min; 609 | 610 | // `ToLength` abstract operation 611 | // https://tc39.es/ecma262/#sec-tolength 612 | var toLength = function (argument) { 613 | return argument > 0 ? min$1(toIntegerOrInfinity(argument), 0x1FFFFFFFFFFFFF) : 0; // 2 ** 53 - 1 == 9007199254740991 614 | }; 615 | 616 | // `LengthOfArrayLike` abstract operation 617 | // https://tc39.es/ecma262/#sec-lengthofarraylike 618 | var lengthOfArrayLike = function (obj) { 619 | return toLength(obj.length); 620 | }; 621 | 622 | // `Array.prototype.{ indexOf, includes }` methods implementation 623 | var createMethod = function (IS_INCLUDES) { 624 | return function ($this, el, fromIndex) { 625 | var O = toIndexedObject($this); 626 | var length = lengthOfArrayLike(O); 627 | var index = toAbsoluteIndex(fromIndex, length); 628 | var value; 629 | // Array#includes uses SameValueZero equality algorithm 630 | // eslint-disable-next-line no-self-compare -- NaN check 631 | if (IS_INCLUDES && el != el) while (length > index) { 632 | value = O[index++]; 633 | // eslint-disable-next-line no-self-compare -- NaN check 634 | if (value != value) return true; 635 | // Array#indexOf ignores holes, Array#includes - not 636 | } else for (;length > index; index++) { 637 | if ((IS_INCLUDES || index in O) && O[index] === el) return IS_INCLUDES || index || 0; 638 | } return !IS_INCLUDES && -1; 639 | }; 640 | }; 641 | 642 | var arrayIncludes = { 643 | // `Array.prototype.includes` method 644 | // https://tc39.es/ecma262/#sec-array.prototype.includes 645 | includes: createMethod(true), 646 | // `Array.prototype.indexOf` method 647 | // https://tc39.es/ecma262/#sec-array.prototype.indexof 648 | indexOf: createMethod(false) 649 | }; 650 | 651 | var indexOf = arrayIncludes.indexOf; 652 | 653 | 654 | var push = functionUncurryThis([].push); 655 | 656 | var objectKeysInternal = function (object, names) { 657 | var O = toIndexedObject(object); 658 | var i = 0; 659 | var result = []; 660 | var key; 661 | for (key in O) !hasOwnProperty_1(hiddenKeys, key) && hasOwnProperty_1(O, key) && push(result, key); 662 | // Don't enum bug & hidden keys 663 | while (names.length > i) if (hasOwnProperty_1(O, key = names[i++])) { 664 | ~indexOf(result, key) || push(result, key); 665 | } 666 | return result; 667 | }; 668 | 669 | // IE8- don't enum bug keys 670 | var enumBugKeys = [ 671 | 'constructor', 672 | 'hasOwnProperty', 673 | 'isPrototypeOf', 674 | 'propertyIsEnumerable', 675 | 'toLocaleString', 676 | 'toString', 677 | 'valueOf' 678 | ]; 679 | 680 | var hiddenKeys$1 = enumBugKeys.concat('length', 'prototype'); 681 | 682 | // `Object.getOwnPropertyNames` method 683 | // https://tc39.es/ecma262/#sec-object.getownpropertynames 684 | // eslint-disable-next-line es/no-object-getownpropertynames -- safe 685 | var f$3 = Object.getOwnPropertyNames || function getOwnPropertyNames(O) { 686 | return objectKeysInternal(O, hiddenKeys$1); 687 | }; 688 | 689 | var objectGetOwnPropertyNames = { 690 | f: f$3 691 | }; 692 | 693 | // eslint-disable-next-line es/no-object-getownpropertysymbols -- safe 694 | var f$4 = Object.getOwnPropertySymbols; 695 | 696 | var objectGetOwnPropertySymbols = { 697 | f: f$4 698 | }; 699 | 700 | var concat = functionUncurryThis([].concat); 701 | 702 | // all object keys, includes non-enumerable and symbols 703 | var ownKeys = getBuiltIn('Reflect', 'ownKeys') || function ownKeys(it) { 704 | var keys = objectGetOwnPropertyNames.f(anObject(it)); 705 | var getOwnPropertySymbols = objectGetOwnPropertySymbols.f; 706 | return getOwnPropertySymbols ? concat(keys, getOwnPropertySymbols(it)) : keys; 707 | }; 708 | 709 | var copyConstructorProperties = function (target, source, exceptions) { 710 | var keys = ownKeys(source); 711 | var defineProperty = objectDefineProperty.f; 712 | var getOwnPropertyDescriptor = objectGetOwnPropertyDescriptor.f; 713 | for (var i = 0; i < keys.length; i++) { 714 | var key = keys[i]; 715 | if (!hasOwnProperty_1(target, key) && !(exceptions && hasOwnProperty_1(exceptions, key))) { 716 | defineProperty(target, key, getOwnPropertyDescriptor(source, key)); 717 | } 718 | } 719 | }; 720 | 721 | var replacement = /#|\.prototype\./; 722 | 723 | var isForced = function (feature, detection) { 724 | var value = data[normalize(feature)]; 725 | return value == POLYFILL ? true 726 | : value == NATIVE ? false 727 | : isCallable(detection) ? fails(detection) 728 | : !!detection; 729 | }; 730 | 731 | var normalize = isForced.normalize = function (string) { 732 | return String(string).replace(replacement, '.').toLowerCase(); 733 | }; 734 | 735 | var data = isForced.data = {}; 736 | var NATIVE = isForced.NATIVE = 'N'; 737 | var POLYFILL = isForced.POLYFILL = 'P'; 738 | 739 | var isForced_1 = isForced; 740 | 741 | var getOwnPropertyDescriptor$1 = objectGetOwnPropertyDescriptor.f; 742 | 743 | 744 | 745 | 746 | 747 | 748 | /* 749 | options.target - name of the target object 750 | options.global - target is the global object 751 | options.stat - export as static methods of target 752 | options.proto - export as prototype methods of target 753 | options.real - real prototype method for the `pure` version 754 | options.forced - export even if the native feature is available 755 | options.bind - bind methods to the target, required for the `pure` version 756 | options.wrap - wrap constructors to preventing global pollution, required for the `pure` version 757 | options.unsafe - use the simple assignment of property instead of delete + defineProperty 758 | options.sham - add a flag to not completely full polyfills 759 | options.enumerable - export as enumerable property 760 | options.noTargetGet - prevent calling a getter on target 761 | options.name - the .name of the function if it does not match the key 762 | */ 763 | var _export = function (options, source) { 764 | var TARGET = options.target; 765 | var GLOBAL = options.global; 766 | var STATIC = options.stat; 767 | var FORCED, target, key, targetProperty, sourceProperty, descriptor; 768 | if (GLOBAL) { 769 | target = global_1; 770 | } else if (STATIC) { 771 | target = global_1[TARGET] || setGlobal(TARGET, {}); 772 | } else { 773 | target = (global_1[TARGET] || {}).prototype; 774 | } 775 | if (target) for (key in source) { 776 | sourceProperty = source[key]; 777 | if (options.noTargetGet) { 778 | descriptor = getOwnPropertyDescriptor$1(target, key); 779 | targetProperty = descriptor && descriptor.value; 780 | } else targetProperty = target[key]; 781 | FORCED = isForced_1(GLOBAL ? key : TARGET + (STATIC ? '.' : '#') + key, options.forced); 782 | // contained in target 783 | if (!FORCED && targetProperty !== undefined) { 784 | if (typeof sourceProperty == typeof targetProperty) continue; 785 | copyConstructorProperties(sourceProperty, targetProperty); 786 | } 787 | // add a flag to not completely full polyfills 788 | if (options.sham || (targetProperty && targetProperty.sham)) { 789 | createNonEnumerableProperty(sourceProperty, 'sham', true); 790 | } 791 | // extend global 792 | redefine(target, key, sourceProperty, options); 793 | } 794 | }; 795 | 796 | // `Object.keys` method 797 | // https://tc39.es/ecma262/#sec-object.keys 798 | // eslint-disable-next-line es/no-object-keys -- safe 799 | var objectKeys = Object.keys || function keys(O) { 800 | return objectKeysInternal(O, enumBugKeys); 801 | }; 802 | 803 | // `Object.defineProperties` method 804 | // https://tc39.es/ecma262/#sec-object.defineproperties 805 | // eslint-disable-next-line es/no-object-defineproperties -- safe 806 | var f$5 = descriptors && !v8PrototypeDefineBug ? Object.defineProperties : function defineProperties(O, Properties) { 807 | anObject(O); 808 | var props = toIndexedObject(Properties); 809 | var keys = objectKeys(Properties); 810 | var length = keys.length; 811 | var index = 0; 812 | var key; 813 | while (length > index) objectDefineProperty.f(O, key = keys[index++], props[key]); 814 | return O; 815 | }; 816 | 817 | var objectDefineProperties = { 818 | f: f$5 819 | }; 820 | 821 | var html = getBuiltIn('document', 'documentElement'); 822 | 823 | /* global ActiveXObject -- old IE, WSH */ 824 | 825 | 826 | 827 | 828 | 829 | 830 | 831 | 832 | var GT = '>'; 833 | var LT = '<'; 834 | var PROTOTYPE = 'prototype'; 835 | var SCRIPT = 'script'; 836 | var IE_PROTO = sharedKey('IE_PROTO'); 837 | 838 | var EmptyConstructor = function () { /* empty */ }; 839 | 840 | var scriptTag = function (content) { 841 | return LT + SCRIPT + GT + content + LT + '/' + SCRIPT + GT; 842 | }; 843 | 844 | // Create object with fake `null` prototype: use ActiveX Object with cleared prototype 845 | var NullProtoObjectViaActiveX = function (activeXDocument) { 846 | activeXDocument.write(scriptTag('')); 847 | activeXDocument.close(); 848 | var temp = activeXDocument.parentWindow.Object; 849 | activeXDocument = null; // avoid memory leak 850 | return temp; 851 | }; 852 | 853 | // Create object with fake `null` prototype: use iframe Object with cleared prototype 854 | var NullProtoObjectViaIFrame = function () { 855 | // Thrash, waste and sodomy: IE GC bug 856 | var iframe = documentCreateElement('iframe'); 857 | var JS = 'java' + SCRIPT + ':'; 858 | var iframeDocument; 859 | iframe.style.display = 'none'; 860 | html.appendChild(iframe); 861 | // https://github.com/zloirock/core-js/issues/475 862 | iframe.src = String(JS); 863 | iframeDocument = iframe.contentWindow.document; 864 | iframeDocument.open(); 865 | iframeDocument.write(scriptTag('document.F=Object')); 866 | iframeDocument.close(); 867 | return iframeDocument.F; 868 | }; 869 | 870 | // Check for document.domain and active x support 871 | // No need to use active x approach when document.domain is not set 872 | // see https://github.com/es-shims/es5-shim/issues/150 873 | // variation of https://github.com/kitcambridge/es5-shim/commit/4f738ac066346 874 | // avoid IE GC bug 875 | var activeXDocument; 876 | var NullProtoObject = function () { 877 | try { 878 | activeXDocument = new ActiveXObject('htmlfile'); 879 | } catch (error) { /* ignore */ } 880 | NullProtoObject = typeof document != 'undefined' 881 | ? document.domain && activeXDocument 882 | ? NullProtoObjectViaActiveX(activeXDocument) // old IE 883 | : NullProtoObjectViaIFrame() 884 | : NullProtoObjectViaActiveX(activeXDocument); // WSH 885 | var length = enumBugKeys.length; 886 | while (length--) delete NullProtoObject[PROTOTYPE][enumBugKeys[length]]; 887 | return NullProtoObject(); 888 | }; 889 | 890 | hiddenKeys[IE_PROTO] = true; 891 | 892 | // `Object.create` method 893 | // https://tc39.es/ecma262/#sec-object.create 894 | var objectCreate = Object.create || function create(O, Properties) { 895 | var result; 896 | if (O !== null) { 897 | EmptyConstructor[PROTOTYPE] = anObject(O); 898 | result = new EmptyConstructor(); 899 | EmptyConstructor[PROTOTYPE] = null; 900 | // add "__proto__" for Object.getPrototypeOf polyfill 901 | result[IE_PROTO] = O; 902 | } else result = NullProtoObject(); 903 | return Properties === undefined ? result : objectDefineProperties.f(result, Properties); 904 | }; 905 | 906 | var correctPrototypeGetter = !fails(function () { 907 | function F() { /* empty */ } 908 | F.prototype.constructor = null; 909 | // eslint-disable-next-line es/no-object-getprototypeof -- required for testing 910 | return Object.getPrototypeOf(new F()) !== F.prototype; 911 | }); 912 | 913 | var IE_PROTO$1 = sharedKey('IE_PROTO'); 914 | var Object$4 = global_1.Object; 915 | var ObjectPrototype = Object$4.prototype; 916 | 917 | // `Object.getPrototypeOf` method 918 | // https://tc39.es/ecma262/#sec-object.getprototypeof 919 | var objectGetPrototypeOf = correctPrototypeGetter ? Object$4.getPrototypeOf : function (O) { 920 | var object = toObject(O); 921 | if (hasOwnProperty_1(object, IE_PROTO$1)) return object[IE_PROTO$1]; 922 | var constructor = object.constructor; 923 | if (isCallable(constructor) && object instanceof constructor) { 924 | return constructor.prototype; 925 | } return object instanceof Object$4 ? ObjectPrototype : null; 926 | }; 927 | 928 | var iterators = {}; 929 | 930 | var defineProperty$1 = objectDefineProperty.f; 931 | 932 | 933 | 934 | var TO_STRING_TAG = wellKnownSymbol('toStringTag'); 935 | 936 | var setToStringTag = function (target, TAG, STATIC) { 937 | if (target && !STATIC) target = target.prototype; 938 | if (target && !hasOwnProperty_1(target, TO_STRING_TAG)) { 939 | defineProperty$1(target, TO_STRING_TAG, { configurable: true, value: TAG }); 940 | } 941 | }; 942 | 943 | var String$3 = global_1.String; 944 | var TypeError$7 = global_1.TypeError; 945 | 946 | var aPossiblePrototype = function (argument) { 947 | if (typeof argument == 'object' || isCallable(argument)) return argument; 948 | throw TypeError$7("Can't set " + String$3(argument) + ' as a prototype'); 949 | }; 950 | 951 | /* eslint-disable no-proto -- safe */ 952 | 953 | 954 | 955 | 956 | // `Object.setPrototypeOf` method 957 | // https://tc39.es/ecma262/#sec-object.setprototypeof 958 | // Works with __proto__ only. Old v8 can't work with null proto objects. 959 | // eslint-disable-next-line es/no-object-setprototypeof -- safe 960 | var objectSetPrototypeOf = Object.setPrototypeOf || ('__proto__' in {} ? function () { 961 | var CORRECT_SETTER = false; 962 | var test = {}; 963 | var setter; 964 | try { 965 | // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe 966 | setter = functionUncurryThis(Object.getOwnPropertyDescriptor(Object.prototype, '__proto__').set); 967 | setter(test, []); 968 | CORRECT_SETTER = test instanceof Array; 969 | } catch (error) { /* empty */ } 970 | return function setPrototypeOf(O, proto) { 971 | anObject(O); 972 | aPossiblePrototype(proto); 973 | if (CORRECT_SETTER) setter(O, proto); 974 | else O.__proto__ = proto; 975 | return O; 976 | }; 977 | }() : undefined); 978 | 979 | export { engineUserAgent as $, classofRaw as A, toLength as B, objectGetPrototypeOf as C, sharedStore as D, documentCreateElement as E, objectDefineProperty as F, setToStringTag as G, iterators as H, functionName as I, descriptors as J, toIndexedObject as K, functionBindNative as L, indexedObject as M, objectKeys as N, objectGetOwnPropertySymbols as O, objectPropertyIsEnumerable as P, objectDefineProperties as Q, commonjsGlobal as R, inspectSource as S, toPropertyKey as T, toAbsoluteIndex as U, uid as V, objectGetOwnPropertyNames as W, createCommonjsModule as X, isSymbol as Y, objectGetOwnPropertyDescriptor as Z, _export as _, anObject as a, engineV8Version as a0, getBuiltIn as b, createNonEnumerableProperty as c, aCallable as d, getMethod as e, functionCall as f, global_1 as g, hasOwnProperty_1 as h, isCallable as i, fails as j, isObject as k, lengthOfArrayLike as l, functionUncurryThis as m, createPropertyDescriptor as n, objectIsPrototypeOf as o, objectSetPrototypeOf as p, copyConstructorProperties as q, objectCreate as r, shared as s, tryToString as t, internalState as u, redefine as v, wellKnownSymbol as w, requireObjectCoercible as x, toIntegerOrInfinity as y, toObject as z }; 980 | -------------------------------------------------------------------------------- /web_modules/common/redefine-all-0f62e567.js: -------------------------------------------------------------------------------- 1 | import { v as redefine } from './object-set-prototype-of-65a42c5e.js'; 2 | 3 | var redefineAll = function (target, src, options) { 4 | for (var key in src) redefine(target, key, src[key], options); 5 | return target; 6 | }; 7 | 8 | export { redefineAll as r }; 9 | -------------------------------------------------------------------------------- /web_modules/import-map.json: -------------------------------------------------------------------------------- 1 | { 2 | "imports": { 3 | "dat.gui": "./dat.gui.js", 4 | "es-module-shims": "./es-module-shims.js", 5 | "gl-matrix": "./gl-matrix.js", 6 | "simplex-noise": "./simplex-noise.js", 7 | "three": "./three.js", 8 | "vector-field": "./vector-field.js" 9 | } 10 | } -------------------------------------------------------------------------------- /web_modules/simplex-noise.js: -------------------------------------------------------------------------------- 1 | import './common/es.typed-array.float32-array-53ec9850.js'; 2 | import './common/esnext.typed-array.with-8c364bde.js'; 3 | import './common/es.typed-array.uint8-array-c10f937c.js'; 4 | import './common/object-set-prototype-of-65a42c5e.js'; 5 | import './common/redefine-all-0f62e567.js'; 6 | import './common/inherit-if-required-1c9a60b3.js'; 7 | 8 | /* 9 | * A fast javascript implementation of simplex noise by Jonas Wagner 10 | 11 | Based on a speed-improved simplex noise algorithm for 2D, 3D and 4D in Java. 12 | Which is based on example code by Stefan Gustavson (stegu@itn.liu.se). 13 | With Optimisations by Peter Eastman (peastman@drizzle.stanford.edu). 14 | Better rank ordering method by Stefan Gustavson in 2012. 15 | 16 | Copyright (c) 2021 Jonas Wagner 17 | 18 | Permission is hereby granted, free of charge, to any person obtaining a copy 19 | of this software and associated documentation files (the "Software"), to deal 20 | in the Software without restriction, including without limitation the rights 21 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 22 | copies of the Software, and to permit persons to whom the Software is 23 | furnished to do so, subject to the following conditions: 24 | 25 | The above copyright notice and this permission notice shall be included in all 26 | copies or substantial portions of the Software. 27 | 28 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 29 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 30 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 31 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 32 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 33 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 34 | SOFTWARE. 35 | */ 36 | const F2 = 0.5 * (Math.sqrt(3.0) - 1.0); 37 | const G2 = (3.0 - Math.sqrt(3.0)) / 6.0; 38 | const F3 = 1.0 / 3.0; 39 | const G3 = 1.0 / 6.0; 40 | const F4 = (Math.sqrt(5.0) - 1.0) / 4.0; 41 | const G4 = (5.0 - Math.sqrt(5.0)) / 20.0; 42 | const grad3 = new Float32Array([1, 1, 0, -1, 1, 0, 1, -1, 0, -1, -1, 0, 1, 0, 1, -1, 0, 1, 1, 0, -1, -1, 0, -1, 0, 1, 1, 0, -1, 1, 0, 1, -1, 0, -1, -1]); 43 | const grad4 = new Float32Array([0, 1, 1, 1, 0, 1, 1, -1, 0, 1, -1, 1, 0, 1, -1, -1, 0, -1, 1, 1, 0, -1, 1, -1, 0, -1, -1, 1, 0, -1, -1, -1, 1, 0, 1, 1, 1, 0, 1, -1, 1, 0, -1, 1, 1, 0, -1, -1, -1, 0, 1, 1, -1, 0, 1, -1, -1, 0, -1, 1, -1, 0, -1, -1, 1, 1, 0, 1, 1, 1, 0, -1, 1, -1, 0, 1, 1, -1, 0, -1, -1, 1, 0, 1, -1, 1, 0, -1, -1, -1, 0, 1, -1, -1, 0, -1, 1, 1, 1, 0, 1, 1, -1, 0, 1, -1, 1, 0, 1, -1, -1, 0, -1, 1, 1, 0, -1, 1, -1, 0, -1, -1, 1, 0, -1, -1, -1, 0]); 44 | /** Deterministic simplex noise generator suitable for 2D, 3D and 4D spaces. */ 45 | 46 | class SimplexNoise { 47 | /** 48 | * Creates a new `SimplexNoise` instance. 49 | * This involves some setup. You can save a few cpu cycles by reusing the same instance. 50 | * @param randomOrSeed A random number generator or a seed (string|number). 51 | * Defaults to Math.random (random irreproducible initialization). 52 | */ 53 | constructor(randomOrSeed = Math.random) { 54 | const random = typeof randomOrSeed == 'function' ? randomOrSeed : alea(randomOrSeed); 55 | this.p = buildPermutationTable(random); 56 | this.perm = new Uint8Array(512); 57 | this.permMod12 = new Uint8Array(512); 58 | 59 | for (let i = 0; i < 512; i++) { 60 | this.perm[i] = this.p[i & 255]; 61 | this.permMod12[i] = this.perm[i] % 12; 62 | } 63 | } 64 | /** 65 | * Samples the noise field in 2 dimensions 66 | * @param x 67 | * @param y 68 | * @returns a number in the interval [-1, 1] 69 | */ 70 | 71 | 72 | noise2D(x, y) { 73 | const permMod12 = this.permMod12; 74 | const perm = this.perm; 75 | let n0 = 0; // Noise contributions from the three corners 76 | 77 | let n1 = 0; 78 | let n2 = 0; // Skew the input space to determine which simplex cell we're in 79 | 80 | const s = (x + y) * F2; // Hairy factor for 2D 81 | 82 | const i = Math.floor(x + s); 83 | const j = Math.floor(y + s); 84 | const t = (i + j) * G2; 85 | const X0 = i - t; // Unskew the cell origin back to (x,y) space 86 | 87 | const Y0 = j - t; 88 | const x0 = x - X0; // The x,y distances from the cell origin 89 | 90 | const y0 = y - Y0; // For the 2D case, the simplex shape is an equilateral triangle. 91 | // Determine which simplex we are in. 92 | 93 | let i1, j1; // Offsets for second (middle) corner of simplex in (i,j) coords 94 | 95 | if (x0 > y0) { 96 | i1 = 1; 97 | j1 = 0; 98 | } // lower triangle, XY order: (0,0)->(1,0)->(1,1) 99 | else { 100 | i1 = 0; 101 | j1 = 1; 102 | } // upper triangle, YX order: (0,0)->(0,1)->(1,1) 103 | // A step of (1,0) in (i,j) means a step of (1-c,-c) in (x,y), and 104 | // a step of (0,1) in (i,j) means a step of (-c,1-c) in (x,y), where 105 | // c = (3-sqrt(3))/6 106 | 107 | 108 | const x1 = x0 - i1 + G2; // Offsets for middle corner in (x,y) unskewed coords 109 | 110 | const y1 = y0 - j1 + G2; 111 | const x2 = x0 - 1.0 + 2.0 * G2; // Offsets for last corner in (x,y) unskewed coords 112 | 113 | const y2 = y0 - 1.0 + 2.0 * G2; // Work out the hashed gradient indices of the three simplex corners 114 | 115 | const ii = i & 255; 116 | const jj = j & 255; // Calculate the contribution from the three corners 117 | 118 | let t0 = 0.5 - x0 * x0 - y0 * y0; 119 | 120 | if (t0 >= 0) { 121 | const gi0 = permMod12[ii + perm[jj]] * 3; 122 | t0 *= t0; 123 | n0 = t0 * t0 * (grad3[gi0] * x0 + grad3[gi0 + 1] * y0); // (x,y) of grad3 used for 2D gradient 124 | } 125 | 126 | let t1 = 0.5 - x1 * x1 - y1 * y1; 127 | 128 | if (t1 >= 0) { 129 | const gi1 = permMod12[ii + i1 + perm[jj + j1]] * 3; 130 | t1 *= t1; 131 | n1 = t1 * t1 * (grad3[gi1] * x1 + grad3[gi1 + 1] * y1); 132 | } 133 | 134 | let t2 = 0.5 - x2 * x2 - y2 * y2; 135 | 136 | if (t2 >= 0) { 137 | const gi2 = permMod12[ii + 1 + perm[jj + 1]] * 3; 138 | t2 *= t2; 139 | n2 = t2 * t2 * (grad3[gi2] * x2 + grad3[gi2 + 1] * y2); 140 | } // Add contributions from each corner to get the final noise value. 141 | // The result is scaled to return values in the interval [-1,1]. 142 | 143 | 144 | return 70.0 * (n0 + n1 + n2); 145 | } 146 | /** 147 | * Samples the noise field in 3 dimensions 148 | * @param x 149 | * @param y 150 | * @param z 151 | * @returns a number in the interval [-1, 1] 152 | */ 153 | 154 | 155 | noise3D(x, y, z) { 156 | const permMod12 = this.permMod12; 157 | const perm = this.perm; 158 | let n0, n1, n2, n3; // Noise contributions from the four corners 159 | // Skew the input space to determine which simplex cell we're in 160 | 161 | const s = (x + y + z) * F3; // Very nice and simple skew factor for 3D 162 | 163 | const i = Math.floor(x + s); 164 | const j = Math.floor(y + s); 165 | const k = Math.floor(z + s); 166 | const t = (i + j + k) * G3; 167 | const X0 = i - t; // Unskew the cell origin back to (x,y,z) space 168 | 169 | const Y0 = j - t; 170 | const Z0 = k - t; 171 | const x0 = x - X0; // The x,y,z distances from the cell origin 172 | 173 | const y0 = y - Y0; 174 | const z0 = z - Z0; // For the 3D case, the simplex shape is a slightly irregular tetrahedron. 175 | // Determine which simplex we are in. 176 | 177 | let i1, j1, k1; // Offsets for second corner of simplex in (i,j,k) coords 178 | 179 | let i2, j2, k2; // Offsets for third corner of simplex in (i,j,k) coords 180 | 181 | if (x0 >= y0) { 182 | if (y0 >= z0) { 183 | i1 = 1; 184 | j1 = 0; 185 | k1 = 0; 186 | i2 = 1; 187 | j2 = 1; 188 | k2 = 0; 189 | } // X Y Z order 190 | else if (x0 >= z0) { 191 | i1 = 1; 192 | j1 = 0; 193 | k1 = 0; 194 | i2 = 1; 195 | j2 = 0; 196 | k2 = 1; 197 | } // X Z Y order 198 | else { 199 | i1 = 0; 200 | j1 = 0; 201 | k1 = 1; 202 | i2 = 1; 203 | j2 = 0; 204 | k2 = 1; 205 | } // Z X Y order 206 | 207 | } else { 208 | // x0 y0) rankx++;else ranky++; 327 | if (x0 > z0) rankx++;else rankz++; 328 | if (x0 > w0) rankx++;else rankw++; 329 | if (y0 > z0) ranky++;else rankz++; 330 | if (y0 > w0) ranky++;else rankw++; 331 | if (z0 > w0) rankz++;else rankw++; // simplex[c] is a 4-vector with the numbers 0, 1, 2 and 3 in some order. 332 | // Many values of c will never occur, since e.g. x>y>z>w makes x= 3 ? 1 : 0; 341 | const j1 = ranky >= 3 ? 1 : 0; 342 | const k1 = rankz >= 3 ? 1 : 0; 343 | const l1 = rankw >= 3 ? 1 : 0; // The integer offsets for the third simplex corner 344 | 345 | const i2 = rankx >= 2 ? 1 : 0; 346 | const j2 = ranky >= 2 ? 1 : 0; 347 | const k2 = rankz >= 2 ? 1 : 0; 348 | const l2 = rankw >= 2 ? 1 : 0; // The integer offsets for the fourth simplex corner 349 | 350 | const i3 = rankx >= 1 ? 1 : 0; 351 | const j3 = ranky >= 1 ? 1 : 0; 352 | const k3 = rankz >= 1 ? 1 : 0; 353 | const l3 = rankw >= 1 ? 1 : 0; // The fifth corner has all coordinate offsets = 1, so no need to compute that. 354 | 355 | const x1 = x0 - i1 + G4; // Offsets for second corner in (x,y,z,w) coords 356 | 357 | const y1 = y0 - j1 + G4; 358 | const z1 = z0 - k1 + G4; 359 | const w1 = w0 - l1 + G4; 360 | const x2 = x0 - i2 + 2.0 * G4; // Offsets for third corner in (x,y,z,w) coords 361 | 362 | const y2 = y0 - j2 + 2.0 * G4; 363 | const z2 = z0 - k2 + 2.0 * G4; 364 | const w2 = w0 - l2 + 2.0 * G4; 365 | const x3 = x0 - i3 + 3.0 * G4; // Offsets for fourth corner in (x,y,z,w) coords 366 | 367 | const y3 = y0 - j3 + 3.0 * G4; 368 | const z3 = z0 - k3 + 3.0 * G4; 369 | const w3 = w0 - l3 + 3.0 * G4; 370 | const x4 = x0 - 1.0 + 4.0 * G4; // Offsets for last corner in (x,y,z,w) coords 371 | 372 | const y4 = y0 - 1.0 + 4.0 * G4; 373 | const z4 = z0 - 1.0 + 4.0 * G4; 374 | const w4 = w0 - 1.0 + 4.0 * G4; // Work out the hashed gradient indices of the five simplex corners 375 | 376 | const ii = i & 255; 377 | const jj = j & 255; 378 | const kk = k & 255; 379 | const ll = l & 255; // Calculate the contribution from the five corners 380 | 381 | let t0 = 0.6 - x0 * x0 - y0 * y0 - z0 * z0 - w0 * w0; 382 | if (t0 < 0) n0 = 0.0;else { 383 | const gi0 = perm[ii + perm[jj + perm[kk + perm[ll]]]] % 32 * 4; 384 | t0 *= t0; 385 | n0 = t0 * t0 * (grad4[gi0] * x0 + grad4[gi0 + 1] * y0 + grad4[gi0 + 2] * z0 + grad4[gi0 + 3] * w0); 386 | } 387 | let t1 = 0.6 - x1 * x1 - y1 * y1 - z1 * z1 - w1 * w1; 388 | if (t1 < 0) n1 = 0.0;else { 389 | const gi1 = perm[ii + i1 + perm[jj + j1 + perm[kk + k1 + perm[ll + l1]]]] % 32 * 4; 390 | t1 *= t1; 391 | n1 = t1 * t1 * (grad4[gi1] * x1 + grad4[gi1 + 1] * y1 + grad4[gi1 + 2] * z1 + grad4[gi1 + 3] * w1); 392 | } 393 | let t2 = 0.6 - x2 * x2 - y2 * y2 - z2 * z2 - w2 * w2; 394 | if (t2 < 0) n2 = 0.0;else { 395 | const gi2 = perm[ii + i2 + perm[jj + j2 + perm[kk + k2 + perm[ll + l2]]]] % 32 * 4; 396 | t2 *= t2; 397 | n2 = t2 * t2 * (grad4[gi2] * x2 + grad4[gi2 + 1] * y2 + grad4[gi2 + 2] * z2 + grad4[gi2 + 3] * w2); 398 | } 399 | let t3 = 0.6 - x3 * x3 - y3 * y3 - z3 * z3 - w3 * w3; 400 | if (t3 < 0) n3 = 0.0;else { 401 | const gi3 = perm[ii + i3 + perm[jj + j3 + perm[kk + k3 + perm[ll + l3]]]] % 32 * 4; 402 | t3 *= t3; 403 | n3 = t3 * t3 * (grad4[gi3] * x3 + grad4[gi3 + 1] * y3 + grad4[gi3 + 2] * z3 + grad4[gi3 + 3] * w3); 404 | } 405 | let t4 = 0.6 - x4 * x4 - y4 * y4 - z4 * z4 - w4 * w4; 406 | if (t4 < 0) n4 = 0.0;else { 407 | const gi4 = perm[ii + 1 + perm[jj + 1 + perm[kk + 1 + perm[ll + 1]]]] % 32 * 4; 408 | t4 *= t4; 409 | n4 = t4 * t4 * (grad4[gi4] * x4 + grad4[gi4 + 1] * y4 + grad4[gi4 + 2] * z4 + grad4[gi4 + 3] * w4); 410 | } // Sum up and scale the result to cover the range [-1,1] 411 | 412 | return 27.0 * (n0 + n1 + n2 + n3 + n4); 413 | } 414 | 415 | } 416 | /** 417 | * Builds a random permutation table. 418 | * This is exported only for (internal) testing purposes. 419 | * Do not rely on this export. 420 | * @private 421 | */ 422 | 423 | function buildPermutationTable(random) { 424 | const p = new Uint8Array(256); 425 | 426 | for (let i = 0; i < 256; i++) { 427 | p[i] = i; 428 | } 429 | 430 | for (let i = 0; i < 255; i++) { 431 | const r = i + ~~(random() * (256 - i)); 432 | const aux = p[i]; 433 | p[i] = p[r]; 434 | p[r] = aux; 435 | } 436 | 437 | return p; 438 | } 439 | /* 440 | The ALEA PRNG and masher code used by simplex-noise.js 441 | is based on code by Johannes Baagøe, modified by Jonas Wagner. 442 | See alea.md for the full license. 443 | */ 444 | 445 | function alea(seed) { 446 | let s0 = 0; 447 | let s1 = 0; 448 | let s2 = 0; 449 | let c = 1; 450 | const mash = masher(); 451 | s0 = mash(' '); 452 | s1 = mash(' '); 453 | s2 = mash(' '); 454 | s0 -= mash(seed); 455 | 456 | if (s0 < 0) { 457 | s0 += 1; 458 | } 459 | 460 | s1 -= mash(seed); 461 | 462 | if (s1 < 0) { 463 | s1 += 1; 464 | } 465 | 466 | s2 -= mash(seed); 467 | 468 | if (s2 < 0) { 469 | s2 += 1; 470 | } 471 | 472 | return function () { 473 | const t = 2091639 * s0 + c * 2.3283064365386963e-10; // 2^-32 474 | 475 | s0 = s1; 476 | s1 = s2; 477 | return s2 = t - (c = t | 0); 478 | }; 479 | } 480 | 481 | function masher() { 482 | let n = 0xefc8249d; 483 | return function (data) { 484 | data = data.toString(); 485 | 486 | for (let i = 0; i < data.length; i++) { 487 | n += data.charCodeAt(i); 488 | let h = 0.02519603282416938 * n; 489 | n = h >>> 0; 490 | h -= n; 491 | h *= n; 492 | n = h >>> 0; 493 | h -= n; 494 | n += h * 0x100000000; // 2^32 495 | } 496 | 497 | return (n >>> 0) * 2.3283064365386963e-10; // 2^-32 498 | }; 499 | } 500 | 501 | export default SimplexNoise; 502 | export { SimplexNoise, buildPermutationTable }; 503 | -------------------------------------------------------------------------------- /web_modules/vector-field.js: -------------------------------------------------------------------------------- 1 | import './common/esnext.iterator.map-8a38945d.js'; 2 | import './common/function-apply-8ffa8c0a.js'; 3 | import './common/object-set-prototype-of-65a42c5e.js'; 4 | import './common/redefine-all-0f62e567.js'; 5 | 6 | /** 7 | * Remap number 8 | * 9 | * @private 10 | * @param {number} n 11 | * @param {number} from1 12 | * @param {number} to1 13 | * @param {number} from2 14 | * @param {number} to2 15 | * @returns {number} 16 | */ 17 | const remap = (n, from1, to1, from2, to2) => from2 + (to2 - from2) * (n - from1) / (to1 - from1); 18 | /** 19 | * A data structure and lookup for 3D vector fields (flow fields). 20 | * 21 | * @property {import("./types.js").VectorFieldDirectionFn} directionFn 22 | * @property {import("./types.js").vec3} steps 23 | * @property {import("./types.js").vec3} bounds 24 | * @property {import("./types.js").vec3} halfBounds 25 | * @property {import("./types.js").VectorFieldCell[]} field 26 | */ 27 | 28 | 29 | class VectorField { 30 | /** 31 | * Creates an instance of VectorField. 32 | * @param {import("./types.js").VectorFieldDirectionFn} directionFn The custom function to compute the cell direction (often a noise function) 33 | * @param {number|import("./types.js").vec3} [steps=10] The number of steps on each dimension (all positive integer). Use integer for identical dimensions. 34 | * @param {number|import("./types.js").vec3} [bounds=1] The size of a containing box for the field. Is divided into steps for each dimension (all positive). Use integer for identical dimensions. 35 | */ 36 | constructor(directionFn, steps = 10, bounds = 1) { 37 | this.directionFn = directionFn; 38 | this.steps = Array.isArray(steps) ? steps : [steps, steps, steps]; 39 | this.bounds = Array.isArray(bounds) ? bounds : [bounds, bounds, bounds]; 40 | this.halfBounds = this.bounds.map(bound => bound * 0.5); 41 | this.field = []; 42 | } 43 | /** 44 | * Create/update the field according to the provided noise function. 45 | */ 46 | 47 | 48 | update() { 49 | for (let x = 0; x < this.steps[0]; x++) { 50 | this.field[x] = this.field[x] || []; 51 | 52 | for (let y = 0; y < this.steps[1]; y++) { 53 | this.field[x][y] = this.field[x][y] || []; 54 | 55 | for (let z = 0; z < this.steps[2]; z++) { 56 | this.field[x][y][z] = this.field[x][y][z] || {}; 57 | this.field[x][y][z].position = [this.bounds[0] * (x / this.steps[0]), this.bounds[1] * (y / this.steps[1]), this.bounds[2] * (z / this.steps[2])]; 58 | this.field[x][y][z].direction = this.directionFn(this.field[x][y][z].position, [x, y, z]); 59 | } 60 | } 61 | } 62 | } 63 | /** 64 | * Find a `VectorFieldCell` at specified position. Useful to compute a particle's velocity for instance. 65 | * 66 | * @param {import("./types.js").vec3} cell [cx, cy, cz] 67 | * @returns {VectorFieldCell|undefined} 68 | */ 69 | 70 | 71 | lookup([cx, cy, cz]) { 72 | const x = Math.round(remap(cx, -this.halfBounds[0], this.halfBounds[0], 0, this.steps[0])); 73 | const y = Math.round(remap(cy, -this.halfBounds[1], this.halfBounds[1], 0, this.steps[1])); 74 | const z = Math.round(remap(cz, -this.halfBounds[2], this.halfBounds[2], 0, this.steps[2])); 75 | return this.field[x] && this.field[x][y] && this.field[x][y][z] ? this.field[x][y][z] : undefined; 76 | } 77 | 78 | } 79 | 80 | export default VectorField; 81 | --------------------------------------------------------------------------------